oasis-editor 0.0.417 → 0.0.419
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OasisEditorApp-DAqRW7aB.js +1 -0
- package/dist/assets/{importDocxWorker-ChuR4jqX.js → importDocxWorker-FgGrfnHp.js} +3800 -2669
- package/dist/core/commands/builtinCommands.d.ts +1 -1
- package/dist/core/commands/publicCommandTypes.d.ts +13 -0
- package/dist/core/commands/text.d.ts +1 -1
- package/dist/core/document/contentControlTransactions.d.ts +20 -0
- package/dist/core/document/contentControlTraversal.d.ts +9 -0
- package/dist/core/document/contentControlValues.d.ts +8 -0
- package/dist/core/document/documentProtection.d.ts +3 -0
- package/dist/core/document/inlineContentControlEdit.d.ts +8 -0
- package/dist/core/document/repeatingSectionRows.d.ts +4 -0
- package/dist/core/model/types/document.d.ts +6 -0
- package/dist/core/model/types/docxSourcePackage.d.ts +4 -0
- package/dist/core/model/types/nodes.d.ts +4 -0
- package/dist/defaultToolbar-Ux_dvdoA.js +1 -0
- package/dist/export/docx/docxPackageXml.d.ts +1 -1
- package/dist/export/docx/synchronizeBoundContentControls.d.ts +7 -1
- package/dist/export/docx/text/sdtSubtypeSource.d.ts +2 -0
- package/dist/import/docx/opc/sourcePackage.d.ts +1 -0
- package/dist/import/docx/settings.d.ts +5 -0
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +1 -1
- package/dist/ooxml/word/customXmlBinding.d.ts +5 -0
- package/dist/plugins/internal/essentialsCapabilities.d.ts +3 -0
- package/dist/sourcePackage-GLrWYLnd.js +1 -0
- package/dist/ui/app/useEditorTransactions.d.ts +2 -0
- package/package.json +1 -1
- package/dist/OasisEditorApp-Dis4OFNS.js +0 -1
- package/dist/defaultToolbar-y3saZHkk.js +0 -1
- package/dist/sourcePackage-BhGtQ-1k.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-CjpNFd0O.js";import{$ as t,$i as n,$n as r,$r as o,$t as a,A as i,Ai as s,An as l,Ar as c,At as d,B as u,Bi as p,Bn as f,C as g,Ci as m,Cn as h,Cr as b,Ct as y,D as v,Di as x,Dn as w,Dr as I,Dt as S,E as C,Ei as k,En as T,Er as P,Et as R,F as M,Fn as A,Fr as O,Ft as B,G as F,Gi as E,Gn as D,Gt as L,H as N,Hi as z,Hn as $,I as H,In as j,It as W,J as U,Ji as V,Jn as _,Jr as K,Jt as q,K as X,Ki as G,Kn as Y,Kt as Z,L as J,Ln as Q,Lt as ee,M as te,Mn as ne,Mr as re,Mt as oe,N as ae,Nn as ie,Nr as se,Nt as le,O as ce,Oi as de,On as ue,Or as pe,Ot as fe,P as ge,Pn as me,Pt as he,Q as be,Qn as ye,Qr as ve,Qt as xe,R as we,Rn as Ie,Rt as Se,S as Ce,Si as ke,Sn as Te,Sr as Pe,St as Re,T as Me,Ti as Ae,Tn as Oe,Tr as Be,Tt as Fe,U as Ee,Ui as De,Un as Le,V as Ne,Vi as ze,Vn as $e,W as He,Wi as je,Wn as We,Wt as Ue,X as Ve,Xi as _e,Xn as Ke,Xr as qe,Xt as Xe,Y as Ge,Yi as Ye,Yn as Ze,Yr as Je,Yt as Qe,Z as et,Zi as tt,Zn as nt,Zr as rt,Zt as ot,_ as at,_a as it,_i as st,_n as lt,_r as ct,_t as dt,a as ut,aa as pt,ai as ft,an as gt,ar as mt,at as ht,b as bt,bi as yt,bn as vt,br as xt,bt as wt,c as It,ca as St,ci as Ct,cn as kt,cr as Tt,ct as Pt,d as Rt,da as Mt,dn as At,dr as Ot,dt as Bt,ea as Ft,ei as Et,en as Dt,er as Lt,et as Nt,f as zt,fa as $t,fi as Ht,fn as jt,fr as Wt,ft as Ut,g as Vt,ga as _t,gn as Kt,gr as qt,gt as Xt,h as Gt,ha as Yt,hi as Zt,hn as Jt,hr as Qt,ht as en,i as tn,ia as nn,ii as rn,in as on,ir as an,it as sn,j as ln,jn as cn,jr as dn,k as un,ki as pn,kn as fn,kr as gn,kt as mn,l as hn,la as bn,li as yn,ln as vn,lr as xn,lt as wn,m as In,mi as Sn,mn as Cn,mr as kn,mt as Tn,n as Pn,na as Rn,ni as Mn,nn as An,nr as On,nt as Bn,o as Fn,oa as En,oi as Dn,on as Ln,or as Nn,ot as zn,p as $n,pa as Hn,pi as jn,pn as Wn,pr as Un,q as Vn,qi as _n,qn as Kn,qt as qn,r as Xn,ra as Gn,ri as Yn,rn as Zn,rr as Jn,rt as Qn,s as er,sa as tr,si as nr,sn as rr,sr as or,st as ar,t as ir,ti as sr,tn as lr,tr as cr,tt as dr,u as ur,ua as pr,un as fr,ur as gr,ut as mr,v as hr,vi as br,vn as yr,vr,vt as xr,w as wr,wi as Ir,wn as Sr,wr as Cr,wt as kr,x as Tr,xi as Pr,xn as Rr,xr as Mr,xt as Ar,y as Or,yi as Br,yn as Fr,yr as Er,yt as Dr,z as Lr,zi as Nr,zn as zr}from"./defaultToolbar-y3saZHkk.js";import{$ as $r,$n as Hr,$t as jr,A as Wr,Ar as Ur,B as Vr,Bn as _r,C as Kr,Cn as qr,Cr as Xr,Ct as Gr,D as Yr,Dr as Zr,En as Jr,Er as Qr,F as eo,Fn as to,Fr as no,G as ro,Gt as oo,H as ao,Hn as io,I as so,In as lo,Ir as co,J as uo,Jn as po,K as fo,Kn as go,Kt as mo,L as ho,Ln as bo,Lr as yo,Mn as vo,Mr as xo,Nn as wo,Nr as Io,O as So,Pn as Co,Pr as ko,Qn as To,Qt as Po,R as Ro,Rn as Mo,Rr as Ao,S as Oo,St as Bo,T as Fo,Tn as Eo,Tr as Do,Un as Lo,Ut as No,Vn as zo,W as $o,Wn as Ho,Wt as jo,X as Wo,Xn as Uo,Xt as Vo,Y as _o,Yn as Ko,Yt as qo,Zn as Xo,_ as Go,_n as Yo,_r as Zo,_t as Jo,a as Qo,an as ea,ar as ta,b as na,bn as ra,br as oa,bt as aa,c as ia,cn as sa,ct as la,d as ca,dr as da,dt as ua,en as pa,er as fa,et as ga,f as ma,ft as ha,g as ba,gn as ya,gr as va,gt as xa,h as wa,ht as Ia,i as Sa,in as Ca,ir as ka,it as Ta,j as Pa,jn as Ra,jr as Ma,k as Aa,kn as Oa,kr as Ba,l as Fa,ln as Ea,lt as Da,m as La,mn as Na,mr as za,mt as $a,n as Ha,nn as ja,nr as Wa,nt as Ua,o as Va,on as _a,or as Ka,ot as qa,p as Xa,pn as Ga,pt as Ya,qn as Za,qt as Ja,rn as Qa,rr as ei,rt as ti,s as ni,sn as ri,tn as oi,tt as ai,u as ii,ur as si,ut as li,v as ci,vn as di,vr as ui,vt as pi,w as fi,wn as gi,wr as mi,wt as hi,x as bi,xn as yi,y as vi,yn as xi,yt as wi,z as Ii,zn as Si,zr as Ci}from"./sourcePackage-BhGtQ-1k.js";function ki(e,t){return{document:e.document,selection:t}}function Ti(e,t){if(!ri(e.selection))return ln(e,t<0?"start":"end");const{paragraphs:n,index:r,offset:o}=ae(e),a=r+t;if(a<0||a>=n.length)return e;const i=n[a];return ki(e,J(Xo(i,Math.min(o,Za(i)))))}function Pi(e,t){const{paragraphs:n,paragraph:r,index:o,offset:a}=ae(e),i=Za(r);if(t<0&&a>0)return ki(e,{anchor:e.selection.anchor,focus:Xo(r,a-1)});if(t>0&&a<i)return ki(e,{anchor:e.selection.anchor,focus:Xo(r,a+1)});if(t<0&&o>0){const t=n[o-1];return ki(e,{anchor:e.selection.anchor,focus:Xo(t,Za(t))})}if(t>0&&o<n.length-1){const t=n[o+1];return ki(e,{anchor:e.selection.anchor,focus:Xo(t,0)})}return e}function Ri(e,t){const{paragraphs:n,index:r,offset:o}=ae(e),a=r+t;if(a<0||a>=n.length)return e;const i=n[a];return ki(e,{anchor:e.selection.anchor,focus:Xo(i,Math.min(o,Za(i)))})}function Mi(e){const t=sa(e);if(t.isCollapsed)return"";const n=xi(e);if(t.startIndex===t.endIndex){const e=n[t.startIndex];return po(e).slice(t.startParagraphOffset,t.endParagraphOffset)}const r=[],o=n[t.startIndex],a=n[t.endIndex];r.push(po(o).slice(t.startParagraphOffset));for(let i=t.startIndex+1;i<t.endIndex;i+=1)r.push(po(n[i]));return r.push(po(a).slice(0,t.endParagraphOffset)),r.join("\n")}function Ai(e,t){return{...e,selection:{anchor:Qa(e,t.anchor),focus:Qa(e,t.focus)}}}function Oi(e){if(!ri(e.selection))return ln(e,"start");const{paragraph:t,index:n,offset:r}=ae(e),o=xi(e);if(Ko(t,r)&&"before-markers"!==e.selection.focus.fieldBoundaryAffinity)return{...e,selection:J(Uo(t,r,"before-markers"))};if(r>0)return{...e,selection:J(Uo(t,r-1,"after-markers"))};if(0===n)return e;const a=o[n-1];return{...e,selection:J(Uo(a,Za(a),"after-markers"))}}function Bi(e){if(!ri(e.selection))return ln(e,"end");const{paragraph:t,index:n,offset:r}=ae(e),o=xi(e),a=Za(t);if(Ko(t,r)&&"after-markers"!==e.selection.focus.fieldBoundaryAffinity)return{...e,selection:J(Uo(t,r,"after-markers"))};if(r<a)return{...e,selection:J(Uo(t,r+1,"before-markers"))};if(n>=o.length-1)return e;const i=o[n+1];return{...e,selection:J(Uo(i,0,"before-markers"))}}function Fi(e,t){const n=sa(e);if(n.isCollapsed||n.startIndex!==n.endIndex||n.endParagraphOffset-n.startParagraphOffset!==1)return null;const r=xi(e)[n.startIndex];if(!r)return null;let o=0;for(let a=0;a<r.runs.length;a+=1){const e=r.runs[a],i=o;if(o+=e.text.length,t(e)&&1===e.text.length&&i===n.startParagraphOffset)return{paragraph:r,paragraphIndex:n.startIndex,run:e,runIndex:a,offset:i}}return null}var Ei=No(),Di="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Li="http://schemas.microsoft.com/office/2011/relationships",Ni="application/vnd.openxmlformats-officedocument.",zi=16777216,$i=4096,Hi=/* @__PURE__ */new Map([[Di+"/chart",/* @__PURE__ */new Set([Ni+"drawingml.chart+xml"])],[Li+"/chartStyle",/* @__PURE__ */new Set(["application/vnd.ms-office.chartstyle+xml"])],[Li+"/chartColorStyle",/* @__PURE__ */new Set(["application/vnd.ms-office.chartcolorstyle+xml"])],[Di+"/image",/* @__PURE__ */new Set(["image/png","image/jpeg","image/gif","image/bmp","image/tiff"])],[Di+"/package",/* @__PURE__ */new Set([Ni+"spreadsheetml.sheet"])]]),ji="oasis.opc-chart-transfer.v1",Wi=e=>{throw Error("Opaque transfer rejected: "+e)};function Ui(e){if(!e||"object"!=typeof e||Array.isArray(e))return Wi("expected record");const t=Object.getPrototypeOf(e);return t!==Object.prototype&&null!==t?Wi("unexpected record prototype"):e}function Vi(e,t=zi){return"string"!=typeof e||!e.length||e.length>t?Wi("invalid string or size"):e}function _i(e,t){return!Array.isArray(e)||e.length>t?Wi("invalid array or count"):e}function Ki(e){const t=Vi(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?Wi("unsafe part path"):t}function qi(e){if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(e))return Wi("unsafe XML declaration");const t=new Ei.DOMParser({onError:()=>Wi("malformed XML")}).parseFromString(e,"application/xml").documentElement;return t||Wi("missing XML root")}function Xi(e,t){const n=_i(e,$i).map(e=>function(e,t){const n=Ui(e),r=Vi(n.id,256),o=Vi(n.type,512),a=Vi(n.target,512);if(!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(r)||!Hi.has(o))return Wi("unsupported relationship");if(void 0!==n.targetMode&&"Internal"!==n.targetMode)return Wi("external relationship");if(!/^[A-Za-z0-9_.\-/]+$/.test(a))return Wi("unsafe relationship URI");const i=Ki(n.resolvedTarget);return xa(t,a)!==i?Wi("inconsistent relationship target"):{id:r,type:o,target:a,targetMode:"Internal",resolvedTarget:i}}(e,t));return new Set(n.map(e=>e.id)).size!==n.length?Wi("duplicate relationship ID"):n}function Gi(e){const t=Ui(e),n=Ki(t.path),r=Vi(t.contentType,256),o=Vi(t.data),a=r.endsWith("+xml");return[...Hi.values()].some(e=>e.has(r))?t.kind!==(a?"xml":"binary")||t.encoding!==(a?"utf8":"base64")?Wi("inconsistent part encoding"):a||/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(o)?(a&&qi(o),{path:n,contentType:r,kind:a?"xml":"binary",encoding:a?"utf8":"base64",data:o,relationships:Xi(t.relationships,n)}):Wi("invalid base64"):Wi("unsupported content type")}function Yi(e){const t=Ui(e);if("oasis.opc-chart-transfer.v1"!==t.format)return Wi("unsupported format");const n=Ki(t.ownerPath),r=Vi(t.fragmentXml,1048576),o=Vi(t.signature,2097152),a=Xi(t.relationships,n),i=_i(t.parts,128).map(Ui);let s=r.length+o.length,l=a.length;for(const m of i){if(s+=Vi(m.data).length,l+=_i(m.relationships,$i).length,3*s>zi)return Wi("aggregate size limit");if(l>$i)return Wi("aggregate relationship limit")}const c=i.map(Gi),d=qi(r),u=Wr(d);if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==d.namespaceURI||"drawing"!==d.localName||!u||"chart"!==u.objectKind||"inline"!==u.placement||u.signature!==o)return Wi("unsupported or changed chart fragment");if(1!==a.filter(e=>e.type===Di+"/chart").length||a.some(e=>e.type!==Di+"/chart")||JSON.stringify([...u.relationshipIds].sort())!==JSON.stringify(a.map(e=>e.id).sort()))return Wi("chart relationship mismatch");const p=new Map(c.map(e=>[e.path,e]));if(p.size!==c.length||p.has(n))return Wi("duplicate or story-dependent part");if(new Set([n,...p.keys()].map(e=>e.toLowerCase())).size!==c.length+1)return Wi("aliased part path");const f=[...a],g=/* @__PURE__ */new Set;for(let m=0;m<f.length;m++){const e=f[m],t=p.get(e.resolvedTarget);if(!t||!Hi.get(e.type)?.has(t.contentType))return Wi("missing dependency or incompatible relationship type");if(!g.has(t.path)){if(g.add(t.path),t.contentType!==Ni+"drawingml.chart+xml"&&t.relationships.length)return Wi("unsupported nested dependency owner");if(t.relationships.some(e=>e.type===Di+"/chart"))return Wi("nested chart dependency");f.push(...t.relationships)}}return g.size!==c.length?Wi("unreachable payload part"):{format:ji,ownerPath:n,fragmentXml:r,signature:o,relationships:a,parts:c.sort((e,t)=>e.path<t.path?-1:e.path>t.path?1:0)}}var Zi=/* @__PURE__ */e(aa(),1);var Ji=new Set(["chart","diagramData","diagramLayout","diagramQuickStyle","diagramColors","oleObject","package","image"].map(e=>"http://schemas.openxmlformats.org/officeDocument/2006/relationships/"+e)),Qi=(e,t)=>Object.hasOwn(e.parts,t),es=e=>Array.from(e.childNodes).filter(e=>1===e.nodeType);function ts(e){if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(e))throw Error("Unsupported XML declarations");const t=new Ei.DOMParser({onError:()=>{throw Error("Invalid XML")}}).parseFromString(e,"application/xml");if(!t.documentElement)throw Error("Missing XML root");return t}function ns(e){return/^[A-Za-z0-9_.\-/]+$/.test(e)&&!e.startsWith("/")&&!e.split("/").some(e=>""===e||"."===e||".."===e)}function rs(e,t,n){const r=t.parts[e],o=n.parts[e];if(!r||!o||!ns(e)||r.kind!==o.kind||r.data!==o.data||r.contentType!==o.contentType||r.encoding!==o.encoding)return!1;const a=r.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 os(e,t){if(e.includes(t))return!0;const n=[ts(e).documentElement];for(;n.length;){const e=n.pop();if(Array.from(e.attributes).some(e=>e.value.includes(t)))return!0;for(const r of Array.from(e.childNodes))if(1===r.nodeType)n.push(r);else if(r.nodeValue?.includes(t))return!0}return!1}function as(e,t){return e.id===t.id&&e.type===t.type&&e.mode===(t.targetMode??"Internal")&&e.resolved===t.resolvedTarget}function is(e,t,n){const r=e=>({removeEdges:[],removeParts:[],...e?{skippedReason:e}:{}});if(!n.length)return r();try{if(e.mainDocumentPart!==t.mainDocumentPart)return r("Main part changed");if(Object.keys(t.parts).some(e=>e.startsWith("_xmlsignatures/")))return r("Signed package");const o=Aa(e),a=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(const b of n){const n=o.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 r("Ambiguous deletion intent");for(const r of s.partPaths)rs(r,e,t)&&a.add(r);for(const e of s.relationshipIds)i.add(e)}if(!a.size)return r();const s=function(e){const t=[];for(const[n,r]of Object.entries(e.parts)){const o=ha(n);if(void 0===o)continue;if(null!==o&&!Qi(e,o))throw Error("Relationship without owner");if("xml"!==r.kind)throw Error("Non-XML relationship part");const a=ts(r.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 r of es(a)){if("http://schemas.openxmlformats.org/package/2006/relationships"!==r.namespaceURI||"Relationship"!==r.localName)throw Error("Unknown relationship element");const a=r.getAttribute("Id"),s=r.getAttribute("Type"),l=r.getAttribute("Target"),c=r.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:o,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=xa(o,l);if(!t||!ns(t)||!Qi(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 r("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)&&Ji.has(n.type)&&e.parts[e.mainDocumentPart]?.relationships?.find(e=>as(n,e))&&!os(l.data,n.id)&&c.add(n);if(!c.size)return r();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 f=/* @__PURE__ */new Set,g=[...c].flatMap(e=>e.resolved?[e.resolved]:[]);for(let e=0;e<g.length;e++){const t=g[e];if(a.has(t)&&!f.has(t)){f.add(t);for(const e of d.get(t)??[])e.resolved&&g.push(e.resolved)}}const m=[...f].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 r("Retained incoming edge");return{removeEdges:[...c],removeParts:m}}catch(o){return r(o instanceof Error?o.message:String(o))}}var ss="word/comments.xml";function ls(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function cs(e){return e.localName??e.tagName}function ds(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(r?.localName===t)return r.value}}function us(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(!r)continue;const o=r.localName??r.name;(r.namespaceURI?t.hasAttributeNS(r.namespaceURI,o):t.hasAttribute(r.name))||(r.namespaceURI?t.setAttributeNS(r.namespaceURI,r.name,r.value):t.setAttribute(r.name,r.value))}}function ps(e){let t="";for(const n of ls(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n.namespaceURI){if("t"===cs(n)){t+=n.textContent??"";continue}if("tab"===cs(n)){t+="\t";continue}if("br"===cs(n)||"cr"===cs(n)){t+="\n";continue}}t+=ps(n)}return t}function fs(e){return ls(e).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"p"===cs(e))}function gs(e){return fs(e).map(ps).join("\n").trim()}function ms(e){const t=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"comments"===cs(t)?t:void 0}function hs(e,t){const n=ds(fs(t)[0]??t,"paraId");for(;t.firstChild;)t.removeChild(t.firstChild);for(let o=0;o<e.childNodes.length;o+=1){const n=e.childNodes[o];n&&t.appendChild(n.cloneNode(!0))}const r=fs(t)[0];n&&r&&r.setAttributeNS(Gr,"w14:paraId",n)}function bs(e,t){const n=fs(e),r=fs(t);n[0]&&r[0]&&Fo(n[0],r[0]);const o=new Set(ls(t).filter(e=>e.namespaceURI!==hi).map(e=>`${e.namespaceURI??""}\0${cs(e)}`));for(const a of ls(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===a.namespaceURI)continue;const e=`${a.namespaceURI??""}\0${cs(a)}`;o.has(e)||(t.appendChild(a.cloneNode(!0)),o.add(e))}}async function ys(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),r=t.file(ss);if(!n||!r)return!1;const o=await r.async("string"),a=function(e,t){const n=ms(e),r=ms(t);if(!n||!r)return t;const o=/* @__PURE__ */new Map;for(const i of ls(r)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==cs(i))continue;const e=ds(i,"id");void 0!==e&&o.set(e,i)}let a=!1;for(const i of ls(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==cs(i))continue;const e=ds(i,"id"),t=void 0!==e?o.get(e):void 0;if(!t)continue;const n=(new Ei.XMLSerializer).serializeToString(t);us(i,t),gs(i)===gs(t)?hs(i,t):bs(i,t),(new Ei.XMLSerializer).serializeToString(t)!==n&&(a=!0)}return a?(new Ei.XMLSerializer).serializeToString(r.ownerDocument):t}(n,o);return a!==o&&(t.file(ss,a),!0)}var vs="http://schemas.microsoft.com/office/word/2012/wordml",xs="word/commentsExtended.xml";function ws(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function Is(e){return e.localName??e.tagName}function Ss(e){return`${e.namespaceURI??""}\0${Is(e)}`}function Cs(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(r?.localName===t)return r.value}}function ks(e,t,n){t.namespaceURI?e.setAttributeNS(t.namespaceURI,t.name,n):e.setAttribute(t.name,n)}function Ts(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),r=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===r?.kind?r.data:void 0}function Ps(e){const t=/* @__PURE__ */new Map,n=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;if(!n)return t;for(const r of Array.from(n.getElementsByTagNameNS(hi,"comment"))){const e=Cs(r,"id"),n=r.getElementsByTagNameNS(hi,"p").item(0),o=n?Cs(n,"paraId"):void 0;void 0!==e&&o&&t.set(e,o)}return t}function Rs(e){const t=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;return t?.namespaceURI===vs&&"commentsEx"===Is(t)?t:void 0}function Ms(e,t,n){for(let o=0;o<e.attributes.length;o+=1){const r=e.attributes.item(o);if(!r)continue;const a=r.localName??r.name;"paraId"!==a&&((r.namespaceURI?t.hasAttributeNS(r.namespaceURI,a):t.hasAttribute(r.name))||ks(t,r,"paraIdParent"===a?n.get(r.value)??r.value:r.value))}const r=new Set(ws(t).map(Ss));for(const o of ws(e))r.has(Ss(o))||t.appendChild(o.cloneNode(!0))}function As(e,t,n,r){const o=Rs(t),a=Rs(r);if(!o||!a)return r;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(!r)continue;const o=r.localName??r.name;(r.namespaceURI?t.hasAttributeNS(r.namespaceURI,o):t.hasAttribute(r.name))||ks(t,r,r.value)}}(o,a);const i=Ps(e),s=Ps(n),l=/* @__PURE__ */new Map;for(const[p,f]of i){const e=s.get(p);e&&l.set(f,e)}const c=function(e){const t=/* @__PURE__ */new Map;for(const n of ws(e)){if(n.namespaceURI!==vs||"commentEx"!==Is(n))continue;const e=Cs(n,"paraId");e&&t.set(e,n)}return t}(a),d=ws(o),u=new Set(ws(a).filter(e=>!(e.namespaceURI===vs&&"commentEx"===Is(e))).map(Ss));for(const p of d){if(p.namespaceURI===vs&&"commentEx"===Is(p)){const e=Cs(p,"paraId"),t=e?l.get(e):void 0,n=t?c.get(t):void 0;n&&Ms(p,n,l);continue}u.has(Ss(p))||(a.appendChild(p.cloneNode(!0)),u.add(Ss(p)))}return(new Ei.XMLSerializer).serializeToString(a.ownerDocument)}var Os="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Bs(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function Fs(e){return e.localName??e.tagName}function Es(e){return`${e.namespaceURI??""}\0${Fs(e)}`}function Ds(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(r?.localName===t)return r.value}}function Ls(e,t){return Bs(e).find(e=>e.namespaceURI===Os&&Fs(e)===t)}function Ns(e,t){return e.filter(e=>e.namespaceURI===Os&&t.has(Fs(e)))}function zs(e){if(e.namespaceURI!==Os)return;const t=Fs(e);if("p"===t){const t=Ds(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=Ls(e,"sdtPr"),n=t?Ls(t,"id"):void 0,r=n?Ds(n,"val"):void 0;return r?`sdt:${r}`:void 0}}function $s(e,t,n){const r=(new Ei.DOMParser).parseFromString(e,"application/xml"),o=(new Ei.DOMParser).parseFromString(t,"application/xml"),a=r.documentElement,i=o.documentElement;if(!a||!i||a.namespaceURI!==Os||i.namespaceURI!==Os||Fs(a)!==n||Fs(i)!==n)return t;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(!r)continue;const o=r.localName??r.name;(r.namespaceURI?t.hasAttributeNS(r.namespaceURI,o):t.hasAttribute(r.name))||(r.namespaceURI?t.setAttributeNS(r.namespaceURI,r.name,r.value):t.setAttribute(r.name,r.value))}}(a,i);const s=Bs(a),l=Bs(i),c=new Set(l.map(Es));return s.forEach((e,t)=>{if(e.namespaceURI===Os||c.has(Es(e)))return;const n=s.slice(t+1).map(e=>l.find(t=>Es(t)===Es(e))).find(e=>Boolean(e));i.insertBefore(e.cloneNode(!0),n??null)}),(new Ei.XMLSerializer).serializeToString(o)}function Hs(e,t,n,r=/* @__PURE__ */new Set(["p","tbl","sdt"])){const o=$s(e,t,n),a=(new Ei.DOMParser).parseFromString(e,"application/xml"),i=(new Ei.DOMParser).parseFromString(o,"application/xml"),s=a.documentElement,l=i.documentElement;if(!s||!l||s.namespaceURI!==Os||l.namespaceURI!==Os||Fs(s)!==n||Fs(l)!==n)return o;const c=Bs(s),d=Bs(l),u=function(e,t,n){const r=Ns(e,n),o=Ns(t,n);return r.length===o.length&&r.every((e,t)=>Fs(e)===Fs(o[t]))}(c,d,r),p=/* @__PURE__ */new Map;return c.forEach((e,t)=>{if(e.namespaceURI!==Os||r.has(Fs(e)))return;const n=Es(e),o=p.get(n)??0;if(p.set(n,o+1),Bs(l).filter(e=>Es(e)===n)[o])return;const a=function(e,t,n,r,o){const a=e.slice(t+1).find(e=>e.namespaceURI===Os&&r.has(Fs(e)));if(!a)return;const i=zs(a);if(i){const e=Ns(n,r).find(e=>zs(e)===i);if(e)return e}if(!o)return;const s=Ns(e,r),l=Ns(n,r),c=s.indexOf(a);return c>=0?l[c]:void 0}(c,t,d,r,u);(a||u)&&l.insertBefore(e.cloneNode(!0),a??null)}),(new Ei.XMLSerializer).serializeToString(i)}var js="word/document.xml",Ws=/* @__PURE__ */new Set(["p","tbl","sdt","sectPr"]);function Us(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function Vs(e){return e.localName??e.tagName}function _s(e){return`${e.namespaceURI??""}\0${Vs(e)}`}function Ks(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(r?.localName===t)return r.value}}function qs(e,t){return Us(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Vs(e)===t)}function Xs(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Ws.has(Vs(e))}function Gs(e){return e.filter(Xs)}function Ys(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI)return;const t=Vs(e);if("p"===t){const t=Ks(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=qs(e,"sdtPr"),n=t?Ks(qs(t,"id")??t,"val"):void 0;return n?`sdt:${n}`:void 0}return"sectPr"===t?"sectPr:final":void 0}function Zs(e,t){const n=(new Ei.DOMParser).parseFromString(e,"application/xml"),r=(new Ei.DOMParser).parseFromString(t,"application/xml"),o=n.documentElement,a=r.documentElement;if(!o||!a||"http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==o.namespaceURI||"http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==a.namespaceURI||"document"!==Vs(o)||"document"!==Vs(a))return t;!function(e,t){const n=Us(e),r=qs(t,"body");if(!r)return;let o=r;const a=n.filter(e=>!("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"body"===Vs(e))),i=/* @__PURE__ */new Set;for(let s=a.length-1;s>=0;s-=1){const e=a[s],n=Us(t).find(t=>!i.has(t)&&_s(t)===_s(e)),r=n??e.cloneNode(!0);n&&i.add(n),t.insertBefore(r,o),o=r}}(o,a);const i=qs(o,"body"),s=qs(a,"body");if(!i||!s)return t;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(!r)continue;const o=r.localName??r.name;(r.namespaceURI?t.hasAttributeNS(r.namespaceURI,o):t.hasAttribute(r.name))||(r.namespaceURI?t.setAttributeNS(r.namespaceURI,r.name,r.value):t.setAttribute(r.name,r.value))}}(i,s);const l=Us(i),c=Us(s),d=function(e,t){const n=Gs(e),r=Gs(t);return n.length===r.length&&n.every((e,t)=>Vs(e)===Vs(r[t]))}(l,c),u=/* @__PURE__ */new Map;return l.forEach((e,t)=>{if(Xs(e))return;const n=_s(e),r=u.get(n)??0;if(u.set(n,r+1),Us(s).filter(e=>_s(e)===n)[r])return;const o=function(e,t,n){const r=e.slice(t+1).find(Xs);if(!r)return;const o=Ys(r);return o?Gs(n).find(e=>Ys(e)===o):void 0}(l,t,c),a=d?function(e,t,n){const r=Gs(e),o=Gs(n),a=e.slice(t+1).find(Xs);if(a){const e=r.indexOf(a);if(e>=0)return o[e]}}(l,t,c):void 0,i=o??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"===Vs(e))}(c)??null)}),(new Ei.XMLSerializer).serializeToString(r)}async function Js(e,t){const n=e.parts[e.mainDocumentPart],r=t.file(js);if("xml"!==n?.kind||!r)return!1;const o=await r.async("string"),a=function(e,t){return Zs(e,$s(e,t,"document"))}(n.data,o);return a!==o&&(t.file(js,a),!0)}function Qs(e){return e.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","id")||void 0}function el(e){return e.getAttributeNS("http://schemas.openxmlformats.org/wordprocessingml/2006/main","type")||"default"}function tl(e,t){const n=e.getAttributeNodeNS(Bo,"id");return!(!n||n.value===t)&&(e.setAttributeNS(Bo,n.name,t),!0)}var nl="word/document.xml",rl="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function ol(e){const t=(new Ei.DOMParser).parseFromString(e,"application/xml");return Array.from(t.getElementsByTagNameNS(rl,"sectPr")).filter(e=>Boolean(e)&&"sectPrChange"!==e.parentNode?.localName)}function al(e){const t=[];return ol(e).forEach((e,n)=>{const r=/* @__PURE__ */new Map;for(const o of function(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}(e)){const e=o.namespaceURI===rl&&"headerReference"===o.localName?"header":o.namespaceURI===rl&&"footerReference"===o.localName?"footer":void 0;if(!e)continue;const a=Qs(o);if(!a)continue;const i=el(o),s=`${e}:${i}`,l=r.get(s)??0;r.set(s,l+1),t.push({key:`${n}:${e}:${i}:${l}`,kind:e,relationshipId:a})}}),t}function il(e){return new Map(e.map(e=>[e.id,e]))}async function sl(e,t){const n=e.parts[e.mainDocumentPart],r=await(t.file(nl)?.async("string"));if("xml"!==n?.kind||!r)return!1;const o=ol(n.data),a=ol(r);if(o.length!==a.length)return!1;const i=al(n.data),s=al(r),l=new Map(i.map(e=>[e.key,e])),c=il(n.relationships??[]),d=il(await async function(e){const t=await(e.file(function(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t):"",r=t>=0?e.slice(t+1):e;return n?`${n}/_rels/${r}.rels`:`_rels/${r}.rels`}(nl))?.async("string"));return Jo(nl,Ia(t))}(t));let u=!1;for(const p of s){const n=l.get(p.key);if(!n||n.kind!==p.kind)continue;const r=c.get(n.relationshipId),o=d.get(p.relationshipId);if("External"===r?.targetMode||"External"===o?.targetMode||!r?.resolvedTarget||!o?.resolvedTarget)continue;const a=e.parts[r.resolvedTarget];if("xml"!==a?.kind)continue;const i=o.resolvedTarget,s=await(t.file(i)?.async("string"));if(!s)continue;const f="header"===p.kind?"hdr":"ftr",g=Hs(a.data,s,f);g!==s&&(t.file(i,g),u=!0)}return u}var ll="word/document.xml",cl={"/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"},dl=["/officeDocument",...Object.keys(cl)];function ul(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}function pl(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t):"",r=t>=0?e.slice(t+1):e;return n?`${n}/_rels/${r}.rels`:`_rels/${r}.rels`}function fl(e){for(const[t,n]of Object.entries(cl))if(e.type.endsWith(t))return n}function gl(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:pl(t.get(n)??n)}function ml(e,t){for(const[n,r]of t)if(r===e)return n;return e}function hl(e,t){if(null===e)return t;const n=function(e){const t=e.lastIndexOf("/");return t<0?[]:e.slice(0,t).split("/")}(e),r=t.split("/");let o=0;for(;o<n.length&&o<r.length&&n[o]===r[o];)o+=1;return[...Array.from({length:n.length-o},()=>".."),...r.slice(o)].join("/")}function bl(e,t){const n=e.parts[t];return"xml"===n?.kind?Ia(n.data):[]}function yl(e,t){const n=null===t?e.rootRelationships.length>0?e.rootRelationships:bl(e,ua):e.parts[t]?.relationships??bl(e,pl(t));return Jo(t,n)}function vl(e,t,n){return yl(e,t).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!n.has(e.resolvedTarget))}function xl(e,t,n,r,o){return e.map(e=>{if("External"===e.targetMode)return e;const a=(i=e.type,dl.find(e=>i.endsWith(e)));var i;const s=a?t.find(e=>"External"!==e.targetMode&&e.type.endsWith(a)):void 0,l=Jo(n,[e])[0]?.resolvedTarget,c=s?.resolvedTarget??(l?o.get(l)??l:void 0);return c?{...e,...s?{id:s.id,type:s.type}:{},target:hl(r,c),targetMode:"Internal",resolvedTarget:c}:e})}function wl(e,t,n){const r=[...t],o=new Map(t.map(e=>[e.id,e]));for(const a of e){const e=o.get(a.id);if(e){if(ul(e)===ul(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.`)}r.push(a)}return r}function Il(e,t,n){const r=t.parts[n];r&&("base64"===r.encoding?e.file(n,r.data,{base64:!0}):e.file(n,r.data))}function Sl(e,t,n,r){const o=e.rebuiltPartHashes?.[t];return Boolean(o&&e.parts[n]&&o===Qo(r))}async function Cl(e,t){const n=e.sourcePackage;if(!n)return t;const r=await Zi.default.loadAsync(t),o=new Set(Object.entries(r.files).filter(([,e])=>!e.dir).map(([e])=>Ya(e))),a=function(e){const t=/* @__PURE__ */new Map;t.set(ll,e.mainDocumentPart);const n=e.parts[e.mainDocumentPart];for(const r of n?.relationships??[]){if("External"===r.targetMode||!r.resolvedTarget)continue;const e=fl(r);e&&t.set(e,r.resolvedTarget)}return t}(n),i=function(e,t,n){const r=/* @__PURE__ */new Set;for(const[o,a]of t)o!==ll&&e.rebuiltPartHashes?.[o]&&!n.has(o)&&e.parts[a]&&r.add(a);return r}(n,a,o),s=new Zi.default;for(const c of Object.keys(n.parts))Il(s,n,c);for(const c of i)s.remove(c),s.remove(pl(c));!function(e,t,n,r,o){if(0!==o.size)for(const a of Object.keys(t.parts)){const i=ha(a);if(null==i)continue;const s=yl(t,i),l=s.filter(e=>"External"===e.targetMode||!e.resolvedTarget||!o.has(e.resolvedTarget));if(l.length===s.length)continue;const c=ml(i,n);r.has(pl(c))||(0===l.length?e.remove(a):e.file(a,wi(l)))}}(s,n,a,o,i);let l=null;for(const[c,d]of Object.entries(r.files)){if(d.dir)continue;const e=Ya(c);if("[Content_Types].xml"===e){l=await d.async("string");continue}const t=gl(e,a),r=ha(e);if(void 0!==r){const e=r,o=null===e?null:a.get(e)??e,l=vl(n,o,i),c=wl(l,xl(Ia(await d.async("string")),l,e,o,a),t);s.file(t,wi(c));continue}const o=await d.async("uint8array");Sl(n,e,t,o)||s.file(t,o)}return l&&s.file(Da,function(e,t,n,r){const o=$a(t),a={};for(const[s,l]of Object.entries(o.overrides))a[n.get(s)??s]=l;const i=Object.fromEntries(Object.entries(e.overrides).filter(([e])=>!r.has(e)));return pi({defaults:{...e.defaults,...o.defaults},overrides:{...i,...a}})}(n.contentTypes,l,a,i)),s.generateAsync({type:"arraybuffer"})}var kl="word/document.xml",Tl=["first","even","default"];function Pl(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t):"",r=t>=0?e.slice(t+1):e;return n?`${n}/_rels/${r}.rels`:`_rels/${r}.rels`}function Rl(e,t){const n=function(e){const t=e.lastIndexOf("/");return t<0?[]:e.slice(0,t).split("/")}(e),r=t.split("/");let o=0;for(;o<n.length&&o<r.length&&n[o]===r[o];)o+=1;return[...Array.from({length:n.length-o},()=>".."),...r.slice(o)].join("/")}function Ml(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function Al(e,t){const n=[],r=e=>{for(const o of Ml(e))"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===o.namespaceURI&&o.localName===t&&n.push(o),r(o)};return r(e),n}function Ol(e){const t=(new Ei.DOMParser).parseFromString(e,"application/xml"),n=[],r=Al(t,"sectPr").filter(e=>"sectPrChange"!==e.parentNode?.localName);return r.forEach((e,t)=>{const r=/* @__PURE__ */new Map;for(const o of Ml(e)){const e="http://schemas.openxmlformats.org/wordprocessingml/2006/main"===o.namespaceURI&&"headerReference"===o.localName?"header":"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===o.namespaceURI&&"footerReference"===o.localName?"footer":void 0;if(!e)continue;const a=Qs(o);if(!a)continue;const i=el(o),s=`${e}:${i}`,l=r.get(s)??0;r.set(s,l+1),n.push({key:`${t}:${e}:${i}:${l}`,sectionIndex:t,kind:e,type:i,occurrence:l,relationshipId:a})}}),{references:n,sectionCount:r.length}}function Bl(e,t){const n=e.parts[t];return"xml"===n?.kind?n.data:void 0}function Fl(e,t){const n=e.parts[t]?.relationships??Ia(Bl(e,Pl(t)));return Jo(t,n)}function El(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 r="header"===e.kind?"/header":"/footer";return t.type.endsWith(r)?[{...e,relationship:t,partPath:t.resolvedTarget}]:[]})}async function Dl(e,t){const n=Bl(e,e.mainDocumentPart),r=await(t.file(kl)?.async("string"));if(!n||!r)return{matches:[],deletedSourcePartPaths:/* @__PURE__ */new Set,sourceRelationshipByCurrentId:/* @__PURE__ */new Map};const o=Ol(n),a=Ol(r),i=El(o.references,Fl(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=Tl.indexOf(e.type),r=Tl.indexOf(t.type),o=n<0?99:n,a=r<0?99:r;return o!==a?o-a:e.type!==t.type?e.type.localeCompare(t.type):e.occurrence-t.occurrence});let n=1,r=1;for(const o of t)"header"===o.kind?(o.baselinePath=`word/header${n}.xml`,n+=1):(o.baselinePath=`word/footer${r}.xml`,r+=1)}(i);const s=El(a.references,await async function(e,t){const n=await(e.file(Pl(t))?.async("string"));return Jo(t,Ia(n))}(t,kl)),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:o.sectionCount===a.sectionCount?new Set(i.map(e=>e.partPath).filter(e=>!d.has(e))):/* @__PURE__ */new Set,sourceRelationshipByCurrentId:u}}function Ll(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}async function Nl(e,t,n,r){if(!r)return!1;const o=t.rebuiltPartHashes?.[r],a=e.file(n);return a?!!o&&o===Qo(await a.async("uint8array")):void 0===o}async function zl(e,t,n,r){for(const o of n)if(!(await Nl(e,t,r?Pl(o.current.partPath):o.current.partPath,o.source.baselinePath?r?Pl(o.source.baselinePath):o.source.baselinePath:void 0)))return!1;return!0}async function $l(e,t,n){if(t.length<2)return;const r=/* @__PURE__ */new Set;for(const o of t){const t=n?Pl(o.current.partPath):o.current.partPath,a=await(e.file(t)?.async("uint8array"));r.add(a?Qo(a):"<missing>")}if(r.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 r=await(e.file(kl)?.async("string"));if(r){const o=t.rebuiltPartHashes?.[kl],a=Qo((new TextEncoder).encode(r));if(!o||o!==a){const t=function(e,t){const n=(new Ei.DOMParser).parseFromString(e,"application/xml");let r=!1;for(const o of["headerReference","footerReference"])for(const e of Al(n,o)){const n=Qs(e),o=n?t.get(n):void 0;o&&(r=tl(e,o.id)||r)}return r?(new Ei.XMLSerializer).serializeToString(n):void 0}(r,n.sourceRelationshipByCurrentId);t&&e.file(kl,t)}}const o=Pl(kl),a=Ia(await(e.file(o)?.async("string"))).map(e=>{const t=n.sourceRelationshipByCurrentId.get(e.id);return t?.resolvedTarget?{...t,target:Rl(kl,t.resolvedTarget),targetMode:"Internal"}:e});e.file(o,wi(function(e,t){const n=[],r=/* @__PURE__ */new Map;for(const o of e){const e=r.get(o.id);if(e){if(Ll(e)===Ll(o))continue;throw new Error(`Cannot safely preserve ${t}: relationship id ${o.id} is used for different targets.`)}r.set(o.id,o),n.push(o)}return n}(a,o)))}async function jl(e,t,n){const r=n[0],o=r.source.partPath;if(!(await zl(e,t,n,!1))){await $l(e,n,!1);const t=await(e.file(r.current.partPath)?.async("uint8array"));if(!t)throw new Error(`Cannot preserve ${o}: rebuilt header/footer part is missing.`);e.file(o,t)}for(const i of n)i.current.partPath!==o&&e.remove(i.current.partPath);const a=Pl(o);if(!(await zl(e,t,n,!0))){await $l(e,n,!0);const t=Pl(r.current.partPath),i=await(e.file(t)?.async("string"));i&&e.file(a,wi(function(e,t,n){return e.map(e=>{if("External"===e.targetMode)return e;const r=Jo(t,[e])[0]?.resolvedTarget;return r?{...e,target:Rl(n,r),targetMode:"Internal",resolvedTarget:r}:e})}(Ia(i),r.current.partPath,o)))}for(const i of n){const t=Pl(i.current.partPath);t!==a&&e.remove(t)}}async function Wl(e,t,n){for(const r 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 jl(e,t,r)}async function Ul(e,t){const n=e.sourcePackage;if(!n)return t;const r=await Zi.default.loadAsync(t),o=await Dl(n,r);o.matches.length>0&&(await Hl(r,n,o),await Wl(r,n,o),await async function(e,t){const n=await(e.file(Da)?.async("string"));if(!n)return;const r=$a(n);for(const o of t.matches){const e=r.overrides[o.current.partPath];e&&(r.overrides[o.source.partPath]=e),o.current.partPath!==o.source.partPath&&delete r.overrides[o.current.partPath]}e.file(Da,pi(r))}(r,o));const a=o.matches.length>0?await r.generateAsync({type:"arraybuffer"}):t;return Cl(function(e,t){const n=e.sourcePackage;if(!n||0===t.size)return e;const r={defaults:{...n.contentTypes.defaults},overrides:Object.fromEntries(Object.entries(n.contentTypes.overrides).filter(([e])=>!t.has(e)))},o={...n.parts};for(const d of t)delete o[d],delete o[Pl(d)];const a=o[n.mainDocumentPart],i=Fl(n,n.mainDocumentPart).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!t.has(e.resolvedTarget));a&&(o[n.mainDocumentPart]={...a,relationships:i});const s=Pl(n.mainDocumentPart),l=o[s];l&&(o[s]={...l,data:wi(i)});const c=o[Da];return c&&(o[Da]={...c,data:pi(r)}),{...e,sourcePackage:{...n,contentTypes:r,parts:o}}}(e,o.deletedSourcePartPaths),a)}var Vl=[{kind:"footnote",relationshipSuffix:"/footnotes",rebuiltPath:"word/footnotes.xml",rootName:"footnotes",entryName:"footnote"},{kind:"endnote",relationshipSuffix:"/endnotes",rebuiltPath:"word/endnotes.xml",rootName:"endnotes",entryName:"endnote"}],_l=/* @__PURE__ */new Set(["p","tbl"]),Kl=/* @__PURE__ */new Set(["separator","continuationSeparator","continuationNotice"]);function ql(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function Xl(e){return e.localName??e.tagName}function Gl(e){return`${e.namespaceURI??""}\0${Xl(e)}`}function Yl(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(r?.localName===t)return r.value}}function Zl(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),r=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===r?.kind?r.data:void 0}function Jl(e,t){const n=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&Xl(n)===t?n:void 0}function Ql(e){const t=Yl(e,"type");if(t&&Kl.has(t))return`type:${t}`;const n=Yl(e,"id");return n?`id:${n}`:void 0}function ec(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&_l.has(Xl(e))}function tc(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"p"!==Xl(e))return;const t=Yl(e,"paraId");return t?`p:${t}`:void 0}function nc(e,t){!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(!r)continue;const o=r.localName??r.name;(r.namespaceURI?t.hasAttributeNS(r.namespaceURI,o):t.hasAttribute(r.name))||(r.namespaceURI?t.setAttributeNS(r.namespaceURI,r.name,r.value):t.setAttribute(r.name,r.value))}}(e,t);const n=ql(e),r=ql(t),o=function(e,t){const n=e.filter(ec),r=t.filter(ec);return n.length===r.length&&n.every((e,t)=>Xl(e)===Xl(r[t]))}(n,r),a=/* @__PURE__ */new Map;n.forEach((e,i)=>{if(ec(e))return;const s=Gl(e),l=a.get(s)??0;if(a.set(s,l+1),ql(t).filter(e=>Gl(e)===s)[l])return;const c=function(e,t,n,r){const o=e.slice(t+1).find(ec);if(!o)return;const a=tc(o);if(a){const e=n.filter(ec).find(e=>tc(e)===a);if(e)return e}if(!r)return;const i=e.filter(ec),s=n.filter(ec),l=i.indexOf(o);return l>=0?s[l]:void 0}(n,i,r,o);("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||c||o)&&t.insertBefore(e.cloneNode(!0),c??null)})}function rc(e,t,n,r){const o=Jl(t,r.rootName),a=Jl(n,r.rootName);if(!o||!a)return n;const i=ql(o).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Xl(e)===r.entryName),s=/* @__PURE__ */new Map;for(const c of ql(a)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==c.namespaceURI||Xl(c)!==r.entryName)continue;const e=Ql(c);e&&s.set(e,c)}const l=function(e,t){const n="footnote"===t?e.footnotes?.items:e.endnotes?.items,r=/* @__PURE__ */new Set;for(const o of Object.values(n??{}))void 0!==o.docxId&&Number.isSafeInteger(o.docxId)&&o.docxId>=1&&r.add(String(o.docxId));return r}(e,r.kind);for(const c of i){const e=Ql(c);if(!e)continue;const t=s.get(e),n=Yl(c,"type");if(t){n&&Kl.has(n)?a.replaceChild(c.cloneNode(!0),t):nc(c,t);continue}if("continuationNotice"===n){a.appendChild(c.cloneNode(!0));continue}const r=Yl(c,"id");r&&l.has(r)&&a.appendChild(c.cloneNode(!0))}return(new Ei.XMLSerializer).serializeToString(a.ownerDocument)}var oc="http://schemas.openxmlformats.org/wordprocessingml/2006/main",ac="word/numbering.xml";function ic(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function sc(e){return e.localName??e.tagName}function lc(e){return`${e.namespaceURI??""}\0${sc(e)}`}function cc(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(r?.localName===t)return r.value}}function dc(e,t,n){for(let r=0;r<e.attributes.length;r+=1){const o=e.attributes.item(r);if(o?.localName===t)return void e.setAttribute(o.name,n)}e.setAttributeNS(oc,`w:${t}`,n)}function uc(e,t){return ic(e).find(e=>e.namespaceURI===oc&&sc(e)===t)}function pc(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(!r)continue;const o=r.localName??r.name;(r.namespaceURI?t.hasAttributeNS(r.namespaceURI,o):t.hasAttribute(r.name))||(r.namespaceURI?t.setAttributeNS(r.namespaceURI,r.name,r.value):t.setAttribute(r.name,r.value))}}function fc(e,t){const n=new Set(ic(t).map(lc));for(const r of ic(e))r.namespaceURI===oc||n.has(lc(r))||t.appendChild(r.cloneNode(!0))}function gc(e,t,n,r,o){const a=e.slice(t+1).map(o).find(e=>Boolean(e));r.insertBefore(n.cloneNode(!0),a??null)}var mc=/* @__PURE__ */new Set(["start","numFmt","lvlRestart","pStyle","lvlText","lvlJc","suff","isLgl"]);function hc(e,t){pc(e,t);const n=ic(e),r=new Map(ic(t).map(e=>[lc(e),e]));n.forEach((e,o)=>{const a=lc(e),i=r.get(a),s=sc(e);if(i)return pc(e,i),void(e.namespaceURI===oc&&"rPr"===s?function(e,t){pc(e,t);const n=ic(e),r=new Map(ic(t).map(e=>[lc(e),e]));n.forEach((e,o)=>{const a=lc(e),i=r.get(a);if(i)return pc(e,i),void fc(e,i);e.namespaceURI===oc&&"rFonts"===sc(e)||gc(n,o,e,t,e=>r.get(lc(e)))})}(e,i):fc(e,i));if(e.namespaceURI!==oc||!mc.has(s)){if(e.namespaceURI===oc&&"rPr"===s){const n=function(e){const t=e.cloneNode(!1);let n=!1;for(const r of ic(e))r.namespaceURI===oc&&"rFonts"===sc(r)||(t.appendChild(r.cloneNode(!0)),n=!0);return n?t:void 0}(e);return void(n&&t.appendChild(n))}gc(n,o,e,t,e=>r.get(lc(e)))}})}function bc(e){return function(e){return e.namespaceURI===oc&&"lvl"===sc(e)?`${lc(e)}\0${cc(e,"ilvl")??"0"}`:lc(e)}(e)}function yc(e,t,n){const r=uc(t,"abstractNumId"),o=r?cc(r,"val"):void 0;if(!o)return;const a=ic(e).find(e=>e.namespaceURI===oc&&"abstractNum"===sc(e)&&cc(e,"abstractNumId")===o);return a?ic(a).find(e=>e.namespaceURI===oc&&"lvl"===sc(e)&&(cc(e,"ilvl")??"0")===n):void 0}function vc(e,t){const n=t.cloneNode(!0);hc(e,n);const r=uc(e,"pPr"),o=uc(n,"pPr");return r?o?n.replaceChild(r.cloneNode(!0),o):n.appendChild(r.cloneNode(!0)):o&&n.removeChild(o),n}function xc(e,t){if(!t)return e.cloneNode(!0);const n=e.cloneNode(!1),r=cc(uc(t,"start")??t,"val")??"1";for(const o of ic(e)){const e=sc(o);if(o.namespaceURI===oc&&"startOverride"===e){const e=o.cloneNode(!0);dc(e,"val",r),n.appendChild(e);continue}o.namespaceURI!==oc||"lvl"!==e?n.appendChild(o.cloneNode(!0)):n.appendChild(vc(o,t))}return n}function wc(e){if(e.namespaceURI!==oc)return lc(e);const t=sc(e);return"abstractNum"===t?`${lc(e)}\0${cc(e,"abstractNumId")??""}`:"num"===t?`${lc(e)}\0${cc(e,"numId")??""}`:lc(e)}function Ic(e,t){const n=function(e,t){const n=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement,r=(new Ei.DOMParser).parseFromString(t,"application/xml").documentElement;if(n&&r&&n.namespaceURI===oc&&r.namespaceURI===oc&&"numbering"===sc(n)&&"numbering"===sc(r))return{sourceRoot:n,rebuiltRoot:r}}(e,t);if(!n)return t;const{sourceRoot:r,rebuiltRoot:o}=n;pc(r,o);const a=ic(r),i=new Map(ic(o).map(e=>[wc(e),e]));return a.forEach((e,t)=>{const n=wc(e),r=i.get(n),s=sc(e);if(r)return pc(e,r),void(e.namespaceURI===oc&&"abstractNum"===s?function(e,t){pc(e,t);const n=ic(e),r=new Map(ic(t).map(e=>[bc(e),e]));n.forEach((e,o)=>{const a=bc(e),i=r.get(a);if(i)return pc(e,i),void(e.namespaceURI===oc&&"lvl"===sc(e)?hc(e,i):fc(e,i));gc(n,o,e,t,e=>r.get(bc(e)))})}(e,r):e.namespaceURI===oc&&"num"===s?function(e,t,n){pc(e,t);const r=uc(t,"abstractNumId"),o=/* @__PURE__ */new Map;for(const a of ic(t))a.namespaceURI===oc&&"lvlOverride"===sc(a)&&o.set(cc(a,"ilvl")??"0",a);for(const a of ic(e)){const e=sc(a);if(a.namespaceURI!==oc||"abstractNumId"!==e){if(a.namespaceURI===oc&&"lvlOverride"===e){const e=cc(a,"ilvl")??"0",r=xc(a,yc(n,t,e)),i=o.get(e);i?t.replaceChild(r,i):t.appendChild(r),o.set(e,r);continue}a.namespaceURI===oc||ic(t).some(e=>lc(e)===lc(a))||t.appendChild(a.cloneNode(!0))}else r&&(pc(a,r),fc(a,r))}}(e,r,o):fc(e,r));gc(a,t,e,o,e=>i.get(wc(e)))}),(new Ei.XMLSerializer).serializeToString(o.ownerDocument)}async function Sc(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),r=t.file(ac);if(!n||!r)return!1;const o=await r.async("string"),a=Ic(n,o);return a!==o&&(t.file(ac,a),!0)}var Cc=[{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 kc(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),r=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===r?.kind?r.data:void 0}var Tc="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Pc=/* @__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 r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function Mc(e){return e.localName??e.tagName}function Ac(e){return`${e.namespaceURI??""}\0${Mc(e)}`}function Oc(e){const t=[],n=e=>{for(const r of Rc(e))r.namespaceURI===Tc&&"sectPr"===Mc(r)&&"sectPrChange"!==r.parentNode?.localName&&t.push(r),n(r)};return n(e),t}function Bc(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(!r)continue;const o=r.localName??r.name;(r.namespaceURI?t.hasAttributeNS(r.namespaceURI,o):t.hasAttribute(r.name))||(r.namespaceURI?t.setAttributeNS(r.namespaceURI,r.name,r.value):t.setAttribute(r.name,r.value))}}function Fc(e){return e.namespaceURI===Tc&&Pc.has(Mc(e))}function Ec(e,t){const n=(new Ei.DOMParser).parseFromString(e,"application/xml"),r=(new Ei.DOMParser).parseFromString(t,"application/xml"),o=n.documentElement,a=r.documentElement;if(!o||!a)return t;const i=Oc(n),s=Oc(r);return 0===i.length||i.length!==s.length?t:(Bc(o,a),i.forEach((e,t)=>{!function(e,t){Bc(e,t);const n=Rc(e),r=Rc(t),o=/* @__PURE__ */new Map;for(const i of r){const e=Ac(i),t=o.get(e);t?t.push(i):o.set(e,[i])}const a=/* @__PURE__ */new Map;for(let i=0;i<n.length;i+=1){const e=n[i],r=Ac(e),s=a.get(r)??0;a.set(r,s+1);const l=o.get(r)?.[s];if(l){Bc(e,l);continue}if(Fc(e))continue;const c=n.slice(i+1).map(e=>o.get(Ac(e))?.[0]).find(e=>Boolean(e));t.insertBefore(e.cloneNode(!0),c??null)}}(e,s[t])}),(new Ei.XMLSerializer).serializeToString(r))}var Dc="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Lc(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function Nc(e){return e.localName??e.tagName}function zc(e,t){const n=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;return n?.namespaceURI===Dc&&Nc(n)===t?n:void 0}function $c(e){return Lc(e).length>0?(new Ei.XMLSerializer).serializeToString(e.ownerDocument):void 0}var Hc=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]),jc=/* @__PURE__ */new Map([["compat",/* @__PURE__ */new Set(["allowSpaceOfSameStyleInTable"])],["footnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])],["endnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])]]);function Wc(e){const t=zc(e,"settings");if(!t)return e;for(const n of[...Lc(t)]){if(n.namespaceURI!==Dc)continue;const e=Nc(n);if(Hc.has(e)){t.removeChild(n);continue}const r=jc.get(e);if(r){for(const e of[...Lc(n)])e.namespaceURI===Dc&&r.has(Nc(e))&&n.removeChild(e);0===Lc(n).length&&t.removeChild(n)}}return $c(t)}function Uc(e){const t=zc(e,"styles");if(!t)return e;for(const n of[...Lc(t)])n.namespaceURI===Dc&&"style"===Nc(n)&&t.removeChild(n);return $c(t)}function Vc(e){const t=zc(e,"fonts");if(!t)return e;for(const n of[...Lc(t)])n.namespaceURI===Dc&&"font"===Nc(n)&&t.removeChild(n);return $c(t)}async function _c(e,t,n){const r=e.file(t);if(!r)return!1;const o=await r.async("string"),a=n(o);return a!==o&&(void 0===a?e.remove(t):e.file(t,a),!0)}var Kc="word/styles.xml";function qc(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function Xc(e){return e.localName??e.tagName}function Gc(e){return`${e.namespaceURI??""}\0${Xc(e)}`}function Yc(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(r?.localName===t)return r.value}}function Zc(e,t){return qc(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Xc(e)===t)}function Jc(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===Xc(e)?`${Gc(e)}\0${Yc(e,"type")??""}`:Gc(e)}function Qc(e){const t=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===Xc(t)?t:void 0}function ed(e,t){const n=Zc(e,"pPr");if(!n)return!1;const r=Zc(t,"pPr"),o=new Ei.XMLSerializer,a=o.serializeToString(n),i=r?o.serializeToString(r):"",s=na(a,i);if(s===i)return!1;if(!s)return!!r&&(t.removeChild(r),!0);const l=function(e){if(!e)return;const t=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"pPr"===Xc(t)?t:void 0}(s);if(!l)return!1;const c=l.cloneNode(!0);return r?t.replaceChild(c,r):function(e,t,n,r){const o=qc(e),a=o.indexOf(n),i=qc(t),s=new Map(i.map(e=>[Jc(e),e])),l=o.slice(a+1).map(e=>s.get(Jc(e))).find(e=>Boolean(e));t.insertBefore(r,l??null)}(e,t,n,c),!0}async function td(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),r=t.file(Kc);if(!n||!r)return!1;const o=await r.async("string"),a=function(e,t){const n=Qc(e),r=Qc(t);if(!n||!r)return t;const o=/* @__PURE__ */new Map;for(const i of qc(r)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Xc(i))continue;const e=Yc(i,"styleId");e&&o.set(e,i)}let a=!1;for(const i of qc(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Xc(i))continue;const e=Yc(i,"styleId"),t=e?o.get(e):void 0;t&&(a=ed(i,t)||a)}return a?(new Ei.XMLSerializer).serializeToString(r.ownerDocument):t}(n,o);return a!==o&&(t.file(Kc,a),!0)}function nd(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function rd(e){return e.localName??e.tagName}function od(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 ad(e,t){const n=function(e){if(!e)return;const t=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===rd(t)?t:void 0}(e);if(!n)return t;const r=`<w:r xmlns:w="${hi}" xmlns:w14="${Gr}">${t}<w:t/></w:r>`,o={id:"ooxml-style-rpr-source",kind:"text",text:""};ao(o,`<w:r xmlns:w="${hi}" xmlns:w14="${Gr}">${e}<w:t/></w:r>`);const a=function(e){const t=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"r"===rd(t)?t:void 0}(bi(o,r));if(!a)return t;let i=nd(a).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"rPr"===rd(e));return!i&&od(n)&&(i=a.ownerDocument.createElementNS(hi,"w:rPr"),a.insertBefore(i,a.firstChild)),i?(Fo(n,i),0!==nd(i).length||od(i)?(new Ei.XMLSerializer).serializeToString(i):""):""}var id="word/styles.xml";function sd(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function ld(e){return e.localName??e.tagName}function cd(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(r?.localName===t)return r.value}}function dd(e,t){return sd(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&ld(e)===t)}function ud(e){const t=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===ld(t)?t:void 0}function pd(e,t){const n=dd(e,"rPr");if(!n)return!1;const r=dd(t,"rPr"),o=new Ei.XMLSerializer,a=o.serializeToString(n),i=r?o.serializeToString(r):"",s=ad(a,i);if(s===i)return!1;if(!s)return!!r&&(t.removeChild(r),!0);const l=function(e){if(!e)return;const t=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===ld(t)?t:void 0}(s);if(!l)return!1;const c=l.cloneNode(!0);return r?t.replaceChild(c,r):function(e,t,n,r){const o=sd(e),a=o.indexOf(n),i=sd(t),s=o.slice(a+1).map(e=>i.find(t=>t.namespaceURI===e.namespaceURI&&ld(t)===ld(e))).find(e=>Boolean(e));t.insertBefore(r,s??null)}(e,t,n,c),!0}async function fd(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),r=t.file(id);if(!n||!r)return!1;const o=await r.async("string"),a=function(e,t){const n=ud(e),r=ud(t);if(!n||!r)return t;const o=/* @__PURE__ */new Map;for(const i of sd(r)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==ld(i))continue;const e=cd(i,"styleId");e&&o.set(e,i)}let a=!1;for(const i of sd(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==ld(i))continue;const e=cd(i,"styleId"),t=e?o.get(e):void 0;t&&(a=pd(i,t)||a)}return a?(new Ei.XMLSerializer).serializeToString(r.ownerDocument):t}(n,o);return a!==o&&(t.file(id,a),!0)}var gd="word/styles.xml",md=/* @__PURE__ */new Set(["pPr","rPr","tblPr","trPr","tcPr"]);function hd(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function bd(e){return e.localName??e.tagName}function yd(e){return`${e.namespaceURI??""}\0${bd(e)}`}function vd(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(r?.localName===t)return r.value}}function xd(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(!r)continue;const o=r.localName??r.name;(r.namespaceURI?t.hasAttributeNS(r.namespaceURI,o):t.hasAttribute(r.name))||(r.namespaceURI?t.setAttributeNS(r.namespaceURI,r.name,r.value):t.setAttribute(r.name,r.value))}}function wd(e,t){return hd(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&bd(e)===t)}function Id(e){return e?(new Ei.XMLSerializer).serializeToString(e):""}function Sd(e,t){if(!e)return;const n=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&bd(n)===t?n:void 0}function Cd(e,t,n){switch(e){case"pPr":return na(t,n);case"rPr":return ad(t,n);case"tblPr":return Kr(t,n);case"trPr":return fi(t,n);case"tcPr":return Oo(t,n);default:return n}}function kd(e,t,n,r){const o=hd(e),a=o.indexOf(n),i=o.slice(a+1).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&md.has(bd(e)));return i?wd(t,bd(i))??null:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"style"===bd(e)&&md.has(r)?hd(t).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===bd(e))??null:null}function Td(e,t,n){const r=wd(e,n);if(!r)return!1;const o=wd(t,n),a=Id(o),i=Cd(n,Id(r),a);if(i===a)return!1;if(!i)return!!o&&(t.removeChild(o),!0);const s=Sd(i,n);if(!s)return!1;const l=s.cloneNode(!0);return o?(t.replaceChild(l,o),!0):(t.insertBefore(l,kd(e,t,r,n)),!0)}function Pd(e,t){xd(e,t);let n=!1;for(const o of md)n=Td(e,t,o)||n;const r=new Set(hd(t).map(yd));for(const o of hd(e))"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===o.namespaceURI&&md.has(bd(o))||r.has(yd(o))||(t.appendChild(o.cloneNode(!0)),r.add(yd(o)),n=!0);return n}function Rd(e){const t=e.ownerDocument;if(!t)return;const n=t.createElementNS(hi,"w:tblStylePr");xd(e,n);let r=!1;for(const o of hd(e)){const e=bd(o);if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===o.namespaceURI&&md.has(e)){const t=Sd(Cd(e,Id(o),""),e);t&&(n.appendChild(t.cloneNode(!0)),r=!0);continue}n.appendChild(o.cloneNode(!0)),r=!0}return r?n:void 0}function Md(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"tblStylePr"!==bd(e))return;const t=vd(e,"type");return t?`tblStylePr:${t}`:void 0}function Ad(e,t){let n=!1;n=Td(e,t,"tblPr")||n;const r=hd(e).filter(e=>void 0!==Md(e)),o=/* @__PURE__ */new Map;for(const a of hd(t)){const e=Md(a);e&&o.set(e,a)}for(const a of r){const r=Md(a),i=o.get(r);if(i){n=Pd(a,i)||n;continue}const s=Rd(a);if(!s)continue;const l=hd(e),c=l.indexOf(a),d=l.slice(c+1).find(e=>void 0!==Md(e)),u=d?o.get(Md(d))??null:null;t.insertBefore(s.cloneNode(!0),u),n=!0}return n}function Od(e){const t=(new Ei.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===bd(t)?t:void 0}async function Bd(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),r=t.file(gd);if(!n||!r)return!1;const o=await r.async("string"),a=function(e,t){const n=Od(e),r=Od(t);if(!n||!r)return t;const o=/* @__PURE__ */new Map;for(const i of hd(r))if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===i.namespaceURI&&"style"===bd(i)){const e=vd(i,"styleId");e&&o.set(e,i)}let a=!1;for(const i of hd(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==bd(i))continue;if("table"!==vd(i,"type"))continue;const e=vd(i,"styleId"),t=e?o.get(e):void 0;t&&(a=Ad(i,t)||a)}return a?(new Ei.XMLSerializer).serializeToString(r.ownerDocument):t}(n,o);return a!==o&&(t.file(gd,a),!0)}var Fd="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Ed(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function Dd(e){return e.localName??e.tagName}function Ld(e){return`${e.namespaceURI??""}\0${Dd(e)}`}function Nd(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(r?.localName===t)return r.value}}function zd(e,t){for(let n=0;n<e.attributes.length;n+=1){const r=e.attributes.item(n);if(!r)continue;const o=r.localName??r.name;(r.namespaceURI?t.hasAttributeNS(r.namespaceURI,o):t.hasAttribute(r.name))||(r.namespaceURI?t.setAttributeNS(r.namespaceURI,r.name,r.value):t.setAttribute(r.name,r.value))}}function $d(e,t,n){const r=(new Ei.DOMParser).parseFromString(e,"application/xml"),o=(new Ei.DOMParser).parseFromString(t,"application/xml"),a=r.documentElement,i=o.documentElement;if(a&&i&&a.namespaceURI===Fd&&i.namespaceURI===Fd&&Dd(a)===n&&Dd(i)===n)return{sourceRoot:a,rebuiltRoot:i}}function Hd(e,t,n,r,o){const a=e.slice(t+1).map(o).find(e=>Boolean(e));r.insertBefore(n.cloneNode(!0),a??null)}function jd(e,t){const n=new Set(Ed(t).map(Ld));for(const r of Ed(e))r.namespaceURI===Fd||n.has(Ld(r))||t.appendChild(r.cloneNode(!0))}var Wd=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]);var Ud=/* @__PURE__ */new Set(["name","basedOn","next","uiPriority","qFormat","semiHidden","unhideWhenUsed","pPr","rPr","tblPr","tblStylePr"]);function Vd(e){return e.namespaceURI===Fd&&"tblStylePr"===Dd(e)?`${Ld(e)}\0${Nd(e,"type")??""}`:Ld(e)}function _d(e){return e.namespaceURI===Fd&&"style"===Dd(e)?`${Ld(e)}\0${Nd(e,"styleId")??""}`:Ld(e)}var Kd=/* @__PURE__ */new Set(["altName","panose1","charset","family","pitch","sig"]);function qd(e){return e.namespaceURI===Fd&&"font"===Dd(e)?`${Ld(e)}\0${Nd(e,"name")??""}`:Ld(e)}var Xd=[{relationshipSuffix:"/settings",rebuiltPath:"word/settings.xml",merge:function(e,t){const n=$d(e,t,"settings");if(!n)return t;const{sourceRoot:r,rebuiltRoot:o}=n;zd(r,o);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=Ed(r),s=new Map(Ed(o).map(e=>[Ld(e),e]));return i.forEach((e,t)=>{const n=Ld(e),r=s.get(n),l=Dd(e),c=e.namespaceURI===Fd?a.get(l):void 0;if(r)return zd(e,r),void(c?function(e,t,n){zd(e,t);const r=Ed(t),o=new Map(r.map(e=>[Ld(e),e])),a=Ed(e);a.forEach((e,r)=>{const i=Ld(e),s=o.get(i);if(s)return zd(e,s),void jd(e,s);e.namespaceURI===Fd&&n.has(Dd(e))||Hd(a,r,e,t,e=>o.get(Ld(e)))})}(e,r,c):jd(e,r));if(c){const n=function(e,t){const n=e.cloneNode(!1);let r=!1;for(const o of Ed(e))o.namespaceURI===Fd&&t.has(Dd(o))||(n.appendChild(o.cloneNode(!0)),r=!0);return r?n:void 0}(e,c);if(n){const e=i.slice(t+1).map(e=>s.get(Ld(e))).find(e=>Boolean(e));o.insertBefore(n,e??null)}return}e.namespaceURI===Fd&&Wd.has(l)||Hd(i,t,e,o,e=>s.get(Ld(e)))}),(new Ei.XMLSerializer).serializeToString(o.ownerDocument)}},{relationshipSuffix:"/styles",rebuiltPath:"word/styles.xml",merge:function(e,t){const n=$d(e,t,"styles");if(!n)return t;const{sourceRoot:r,rebuiltRoot:o}=n;zd(r,o);const a=Ed(r),i=new Map(Ed(o).map(e=>[_d(e),e]));return a.forEach((e,t)=>{const n=_d(e),r=i.get(n);if(r)return zd(e,r),void(e.namespaceURI===Fd&&"style"===Dd(e)?function(e,t){zd(e,t);const n=Ed(e),r=new Map(Ed(t).map(e=>[Vd(e),e]));n.forEach((e,o)=>{const a=Vd(e),i=r.get(a);if(i)return zd(e,i),void jd(e,i);e.namespaceURI===Fd&&Ud.has(Dd(e))||Hd(n,o,e,t,e=>r.get(Vd(e)))})}(e,r):jd(e,r));Hd(a,t,e,o,e=>i.get(_d(e)))}),(new Ei.XMLSerializer).serializeToString(o.ownerDocument)}},{relationshipSuffix:"/numbering",rebuiltPath:"word/numbering.xml"},{relationshipSuffix:"/fontTable",rebuiltPath:"word/fontTable.xml",merge:function(e,t){const n=$d(e,t,"fonts");if(!n)return t;const{sourceRoot:r,rebuiltRoot:o}=n;zd(r,o);const a=Ed(r),i=new Map(Ed(o).map(e=>[qd(e),e]));return a.forEach((e,t)=>{const n=qd(e),r=i.get(n);if(r)return zd(e,r),void(e.namespaceURI===Fd&&"font"===Dd(e)&&function(e,t){zd(e,t);const n=Ed(e),r=new Map(Ed(t).map(e=>[Ld(e),e]));n.forEach((e,o)=>{const a=Ld(e),i=r.get(a);i?zd(e,i):e.namespaceURI===Fd&&Kd.has(Dd(e))||Hd(n,o,e,t,e=>r.get(Ld(e)))})}(e,r));Hd(a,t,e,o,e=>i.get(qd(e)))}),(new Ei.XMLSerializer).serializeToString(o.ownerDocument)}}];function Gd(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),r=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===r?.kind?r.data:void 0}var Yd="word/document.xml";function Zd(e){const t=(new Ei.DOMParser).parseFromString(e,"application/xml").getElementsByTagNameNS(hi,"sectPr");let n=0;for(let r=0;r<t.length;r+=1){const e=t.item(r),o=e?.parentNode;e&&"sectPrChange"!==o?.localName&&(n+=1)}return n}async function Jd(e,t){const n=e.sourcePackage;if(!n)return t;const r=n.parts[n.mainDocumentPart];if("xml"!==r?.kind)return Cl(e,t);const o=await Zi.default.loadAsync(t),a=Boolean(o.file("word/numbering.xml")),i={settings:Boolean(o.file("word/settings.xml")),styles:Boolean(o.file("word/styles.xml")),fontTable:Boolean(o.file("word/fontTable.xml"))};let s=await async function(e,t){let n=!1;for(const r of Xd){const o=Gd(e,r.relationshipSuffix);if(!o)continue;const a=t.file(r.rebuiltPath);if(!a){t.file(r.rebuiltPath,o),n=!0;continue}if(!r.merge)continue;const i=await a.async("string"),s=r.merge(o,i);s!==i&&(t.file(r.rebuiltPath,s),n=!0)}return n}(n,o);a&&(s=await Sc(n,o)||s),i.styles&&(s=await td(n,o)||s,s=await fd(n,o)||s,s=await Bd(n,o)||s),s=await async function(e,t){let n=!1;return t.settings||(n=await _c(e,"word/settings.xml",Wc)||n),t.styles||(n=await _c(e,"word/styles.xml",Uc)||n),t.fontTable||(n=await _c(e,"word/fontTable.xml",Vc)||n),n}(o,i)||s,s=await async function(e,t){let n=!1;for(const r of Cc){const o=kc(e,r.relationshipSuffix),a=t.file(r.rebuiltPath);if(!o||!a)continue;const i=await a.async("string"),s=$s(o,i,r.rootLocalName);s!==i&&(t.file(r.rebuiltPath,s),n=!0)}return n}(n,o)||s,s=await async function(e,t,n){let r=!1;for(const o of Vl){const a=Zl(t,o.relationshipSuffix),i=n.file(o.rebuiltPath);if(!a||!i)continue;const s=await i.async("string"),l=rc(e,a,s,o);l!==s&&(n.file(o.rebuiltPath,l),r=!0)}return r}(e,n,o)||s,s=await ys(n,o)||s,s=await async function(e,t){const n=Ts(e,"/comments"),r=Ts(e,"/commentsExtended"),o=t.file("word/comments.xml"),a=t.file(xs);if(!(n&&r&&o&&a))return!1;const i=await o.async("string"),s=await a.async("string"),l=As(n,r,i,s);return l!==s&&(t.file(xs,l),!0)}(n,o)||s,s=await sl(n,o)||s,s=await Js(n,o)||s;const l=await(o.file(Yd)?.async("string"));if(!l||Zd(r.data)!==Zd(l)){return Cl(e,s?await o.generateAsync({type:"arraybuffer"}):t)}const c=Ec(r.data,l);c!==l&&(o.file(Yd,c),s=!0);return Ul(e,s?await o.generateAsync({type:"arraybuffer"}):t)}function Qd(e){return e.trim().replace(/[{}]/g,"").toLowerCase()}function eu(e){const t=(new Ei.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 tu(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 nu(e,t,n,r){if(e.localName!==n)return!1;if(!t)return!e.namespaceURI;const o=r.get(t);return void 0!==o&&e.namespaceURI===o}function ru(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const r=e.childNodes[n];r?.nodeType===r.ELEMENT_NODE&&t.push(r)}return t}function ou(e,t,n){if(!e||!t?.storeItemID||!t.xpath)return!1;const r=function(e,t){const n=Qd(t);for(const r of Object.values(e.parts)){if("xml"!==r.kind||!/^customXml\/item\d+\.xml$/i.test(r.path))continue;const t=(r.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/customXmlProps")&&e.resolvedTarget))?.resolvedTarget;if(!t)continue;const o=e.parts[t];if(!o||"xml"!==o.kind)continue;const a=eu(o.data);if(a&&Qd(a)===n)return{storeItemId:a,itemPartPath:r.path,itemPropsPartPath:t,xml:r.data}}return null}(e,t.storeItemID);if(!r)return!1;const o=function(e,t,n){const r=(new Ei.DOMParser).parseFromString(e,"application/xml"),o=r.documentElement;if(!o)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=tu(i[0]);if(!l||1!==l.index)return null;if(!nu(o,l.prefix,l.localName,n))return null;let c=o;for(let m=1;m<i.length;m+=1){const e=tu(i[m]);if(!e)return null;const t=ru(c).filter(t=>nu(t,e.prefix,e.localName,n))[e.index-1];if(!t)return null;c=t}if(!s)return{document:r,element:c};const d=s.slice(1),u=d.indexOf(":");if(u<0)return{document:r,element:c,attribute:{localName:d,qualifiedName:d}};const p=d.slice(0,u),f=d.slice(u+1),g=n.get(p);return g?{document:r,element:c,attribute:{namespaceUri:g,localName:f,qualifiedName:`${p}:${f}`}}:null}(r.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(!o)return!1;if(o.attribute)o.attribute.namespaceUri?o.element.setAttributeNS(o.attribute.namespaceUri,o.attribute.qualifiedName,n):o.element.setAttribute(o.attribute.localName,n);else{if(ru(o.element).length>0)return!1;for(;o.element.firstChild;)o.element.removeChild(o.element.firstChild);o.element.appendChild(o.document.createTextNode(n))}const a=e.parts[r.itemPartPath];return!!a&&(a.data=(new Ei.XMLSerializer).serializeToString(o.document),!0)}function au(e,t,n,r){if(!t.sdtPr.dataBinding)return;const o=e.get(t.groupId);o?o.value+=`${r}${n}`:e.set(t.groupId,{wrapper:t,value:n})}function iu(e){return e.blocks.map(lu).filter(Boolean).join("\n")}function su(e){return e.cells.map(iu).filter(Boolean).join("\t")}function lu(e){return"paragraph"===e.type?po(e):e.rows.map(su).filter(Boolean).join("\n")}function cu(e,t){for(const n of e.runs){for(const e of n.sdtWrappers??[])au(t,e,n.text,"");"textBox"===n.kind&&uu(n.textBox.blocks,t)}}function du(e,t){for(const n of e.rows){const e=su(n);for(const r of n.sdtWrappers??[])au(t,r,e,"\n");for(const r of n.cells){const e=iu(r);for(const n of r.sdtWrappers??[])au(t,n,e,"\n");uu(r.blocks,t)}}}function uu(e,t){if(e)for(const n of e){const e=lu(n);for(const r of n.sdtWrappers??[])au(t,r,e,"\n");"paragraph"===n.type?cu(n,t):du(n,t)}}async function pu(e,t={}){if(!e.sourcePackage)return Va(e);const n=(r=e.sourcePackage,{...r,contentTypes:{defaults:{...r.contentTypes.defaults},overrides:{...r.contentTypes.overrides}},rootRelationships:r.rootRelationships.map(e=>({...e})),parts:Object.fromEntries(Object.entries(r.parts).map(([e,t])=>[e,{...t,...t.relationships?{relationships:t.relationships.map(e=>({...e}))}:{}}])),...r.diagnostics?{diagnostics:r.diagnostics.map(e=>({...e}))}:{},...r.rebuiltPartHashes?{rebuiltPartHashes:{...r.rebuiltPartHashes}}:{}});var r;const o=Aa(n),a=o.diagnostics.filter(e=>"error"===e.level);if(a.length)throw new Yr(a);n.opaqueObjects=o.objects;const i={...e,sourcePackage:n};!function(e){if(!e.sourcePackage)return 0;const t=/* @__PURE__ */new Map;for(const r of _r(e))uu(r.blocks,t),uu(r.header,t),uu(r.firstPageHeader,t),uu(r.evenPageHeader,t),uu(r.footer,t),uu(r.firstPageFooter,t),uu(r.evenPageFooter,t);let n=0;for(const{wrapper:r,value:o}of t.values()){const t=r.sdtPr.dataBinding;t&&ou(e.sourcePackage,t,o)&&(n+=1)}}(i);const s=o.objects.length>0,l=e.opaqueRelocationIntent,c=l?Fa(n,l,l.destinationOwner):void 0,d=await ia(i,n);let u=await Jd(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 Zi.default.loadAsync(e);if(!n.file(t.destinationOwner))throw Error("Original destination story was not retained");const r=t.destinationOwner.lastIndexOf("/"),o=(r>=0?t.destinationOwner.slice(0,r+1):"")+"_rels/"+t.destinationOwner.slice(r+1)+".rels",a=await(n.file(o)?.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 Ei.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(li,"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(li,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(o,(new Ei.XMLSerializer).serializeToString(i)),n.generateAsync({type:"arraybuffer"})}(u,c)}if(s||t.requireOpaquePreservation||c||e.opaqueDeletionIntents?.length){const{captureDocxSourcePackage:r}=await import("./sourcePackage-BhGtQ-1k.js").then(e=>e.r),o=await r(u),a=So(n,o,e.opaqueDeletionIntents,c?function(e,t){const n=e.opaqueObjects?.find(e=>e.ownerPath===t.sourceOwner&&e.ordinal===t.sourceOrdinal&&e.signature===t.sourceSignature),r=e.parts[t.destinationOwner];if(!n||!r)throw Error("Relocation source missing");const o={...e,parts:{...e.parts,[t.destinationOwner]:{...r,relationships:[...r.relationships??[],...t.addedRelationships]}}},a=Pa(o,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 Yr(a);const i=e.opaqueDeletionIntents??[];if(i.length&&!1!==t.pruneDeletedOpaqueDependencies){const t=is(n,o,i);if(t.removeEdges.length||t.removeParts.length){const o=await async function(e,t){if(!t.removeParts.length&&!t.removeEdges.length)return e;const n=await Zi.default.loadAsync(e),r=new Ei.XMLSerializer,o=async e=>{const t=n.file(e);if(!t)throw Error("Missing planned OPC part "+e);return ts(await t.async("string"))};for(const l of new Set(t.removeEdges.map(e=>e.relPath))){const e=await o(l),a=e.documentElement,i=new Set(t.removeEdges.filter(e=>e.relPath===l).map(e=>e.id));for(const t of es(a))i.has(t.getAttribute("Id")??"")&&(i.delete(t.getAttribute("Id")),a.removeChild(t));if(i.size)throw Error("OPC relationship plan became stale");es(a).length?n.file(l,r.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 o(Da),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 es(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(Da,r.serializeToString(i)),n.generateAsync({type:"arraybuffer"})}(u,t),a=await r(o),s=So(n,a,i);if(s.length)throw new Yr(s);return qa(o,e)}}}return qa(u,e)}async function fu(e,t={}){if(!e.sourcePackage)return ni(e);const n=await pu(e,t);return new Blob([n],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}var gu="http://schemas.openxmlformats.org/wordprocessingml/2006/main",mu="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",hu="http://schemas.openxmlformats.org/officeDocument/2006/relationships",bu=e=>{throw Error("Opaque insertion rejected: "+e)};function yu(e){if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(e))return bu("unsafe XML declaration");const t=new Ei.DOMParser({onError:()=>bu("malformed XML")}).parseFromString(e,"application/xml").documentElement;return t||bu("missing XML root")}function vu(e){const t=[],n=[e];for(let r=0;r<n.length;r++){const e=n[r];t.push(e);for(const t of Array.from(e.childNodes))1===t.nodeType&&n.push(t)}return t}function xu(e){const t=e.lastIndexOf("/");return e.slice(0,t+1)+"_rels/"+e.slice(t+1)+".rels"}function wu(e,t){const n=e.split("/").slice(0,-1),r=t.split("/");for(;n.length&&r.length&&n[0]===r[0];)n.shift(),r.shift();const o="../".repeat(n.length)+r.join("/");return xa(e,o)!==t?bu("unrepresentable relative target"):o}function Iu(e){return/^[A-Za-z0-9_.\-/]+$/.test(e)&&!e.split("/").some(e=>!e||"."===e||".."===e)}var Su={"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 Cu="http://schemas.openxmlformats.org/wordprocessingml/2006/main",ku="[Content_Types].xml",Tu="application/vnd.openxmlformats-package.relationships+xml",Pu=e=>{throw Error("Opaque transfer application rejected: "+e)};function Ru(e,t,n){if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(e))return Pu("unsafe XML declaration");const r=new Ei.DOMParser({onError:()=>Pu("malformed XML")}).parseFromString(e,"application/xml");return r.documentElement?.namespaceURI!==t||r.documentElement.localName!==n?Pu("unexpected XML root"):r}function Mu(e){return Array.from(e.childNodes).filter(e=>1===e.nodeType)}function Au(e){const t=e.lastIndexOf("/");return e.slice(0,t+1)+"_rels/"+e.slice(t+1)+".rels"}function Ou(e){return(new Ei.XMLSerializer).serializeToString(e)}function Bu(e,t){return e.byteLength===t.byteLength&&e.every((e,n)=>e===t[n])}function Fu(e){const t=/* @__PURE__ */new Set;for(const[n,r]of Object.entries(e.files)){if(r.dir)continue;const e=n.toLowerCase();if(t.has(e)||void 0!==r.unsafeOriginalName&&r.unsafeOriginalName!==n)return Pu("ambiguous ZIP entry");if(t.add(e),e.startsWith("_xmlsignatures/"))return Pu("signed package")}}async function Eu(e,t,n){const r=await Zi.default.loadAsync(e);Fu(r);const o=await Ha(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")))Pu("signed package")}(o);const a=function(e,t){const n=Yi(e),r=t.mainDocumentPart,o=Object.hasOwn(t.parts,r)?t.parts[r]:void 0;if(!Iu(r)||!o||"xml"!==o.kind)return bu("missing destination main story");const a=yu(o.data);if(a.namespaceURI!==gu||"document"!==a.localName)return bu("only Transitional main story is supported");if(Aa(t).diagnostics.some(e=>"error"===e.level))return bu("destination opaque inspection errors");const i=/* @__PURE__ */new Set,s=e=>{if("[Content_Types].xml"!==e&&!Iu(e))return bu("ambiguous destination OPC path");i.add(e.toLowerCase())};for(const[T,P]of Object.entries(t.parts)){if(P.path!==T)return bu("inconsistent destination part path");s(T),"[Content_Types].xml"===T||T.endsWith(".rels")||s(xu(T));for(const e of P.relationships??[])if("External"!==e.targetMode){if(!e.resolvedTarget||xa(T,e.target)!==e.resolvedTarget)return bu("unresolved destination relationship");s(e.resolvedTarget)}}for(const T of Object.keys(t.contentTypes.overrides))s(T);for(const T of t.rootRelationships)if("External"!==T.targetMode){if(!T.resolvedTarget||xa(null,T.target)!==T.resolvedTarget)return bu("unresolved root relationship");s(T.resolvedTarget)}if(new Set(Object.keys(t.parts).map(e=>e.toLowerCase())).size!==Object.keys(t.parts).length)return bu("aliased destination parts");let l="";for(let T=1;T<=1e5;T++){const e="word/oasis-transfer-"+T;if(![...i].some(t=>t===e||t.startsWith(e+"/")||e.startsWith(t+"/"))){l=e;break}}if(!l)return bu("part namespace exhausted");const c=new Map(n.parts.map((e,t)=>[e.path,l+"/part-"+(t+1)+"."+Su[e.contentType]])),d=(e,t,n=e.id)=>{const r=c.get(e.resolvedTarget);return r?{...e,id:n,target:wu(t,r),resolvedTarget:r,targetMode:"Internal"}:bu("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((o.relationships??[]).map(e=>e.id));if(p.size!==(o.relationships??[]).length)return bu("duplicate destination relationship ID");const f=vu(a).flatMap(e=>Array.from(e.attributes).map(e=>e.value));let g=1;const m=n.relationships.map(e=>{let t;do{t="rIdOasisTransfer"+g++}while(p.has(t)||o.data.includes(t)||f.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,r,h.get(e.id))),y=yu(n.fragmentXml),v=vu(y),x=v.filter(e=>e.namespaceURI===mu&&"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(hu,"id")??""))return bu("ambiguous chart or drawing identity");for(const T of v){if(T!==y&&T.namespaceURI===gu)return bu("nested WordprocessingML in chart drawing");for(const e of Array.from(T.attributes)){if("http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"===e.namespaceURI)return bu("unsupported extended drawing identity");if(e.namespaceURI===hu||"http://purl.oclc.org/ooxml/officeDocument/relationships"===e.namespaceURI||"urn:schemas-microsoft-com:office:office"===e.namespaceURI&&"relid"===e.localName){if(T!==w[0]||e.namespaceURI!==hu||"id"!==e.localName||!h.has(e.value))return bu("unknown chart relationship reference");T.setAttributeNS(hu,e.name,h.get(e.value))}else if("http://www.w3.org/2000/xmlns/"!==e.namespaceURI&&h.has(e.value))return bu("unknown attribute may reference a relationship")}}const I=/* @__PURE__ */new Set;for(const T of Object.values(t.parts)){if("xml"!==T.kind||!T.data.includes("docPr"))continue;const e=T.path===r?a:yu(T.data);for(const t of vu(e)){if(t.namespaceURI!==mu||"docPr"!==t.localName)continue;const e=t.getAttribute("id")??"";if(!/^\d+$/.test(e)||Number(e)>4294967295)return bu("invalid destination drawing ID");I.add(Number(e))}}let S=1879048192;for(;I.has(S)&&S<2147483647;)S++;if(I.has(S))return bu("drawing identity exhausted");x[0].setAttribute("id",String(S));const C=Wr(y);if(!C)return bu("chart projection lost");const k=Yi({...n,ownerPath:r,fragmentXml:C.fragmentXml,signature:C.signature,relationships:b,parts:u});return{destinationOwner:r,destinationRun:C,addedRelationships:k.relationships,addedParts:k.parts,contentTypeOverrides:Object.fromEntries(k.parts.map(e=>[e.path,e.contentType])),pathMapping:[...c].map(([e,t])=>({from:e,to:t})),relationshipMapping:m,drawingId:S}}(t,o),i=a.destinationOwner,s=o.parts[i],l=Ru(s.data,Cu,"document"),c=l.documentElement,d=Mu(c).filter(e=>e.namespaceURI===Cu&&"body"===e.localName);if(1!==d.length)return Pu("ambiguous document body");const u=Mu(d[0]).filter(e=>e.namespaceURI===Cu&&"p"===e.localName);if(!Number.isSafeInteger(n)||n<0||n>=u.length)return Pu("invalid paragraph index");const p=u[n],f=Ru(a.destinationRun.fragmentXml,Cu,"drawing"),g=l.createElementNS(Cu,c.prefix?c.prefix+":r":"r");g.appendChild(l.importNode(f.documentElement,!0)),p.appendChild(g);const m=Ou(l),h=Au(i),b=function(e,t){const n=Ru(e,li,"Relationships"),r=n.documentElement,o=/* @__PURE__ */new Set;for(const a of Mu(r)){const e=a.getAttribute("Id")??"";if("http://schemas.openxmlformats.org/package/2006/relationships"!==a.namespaceURI||"Relationship"!==a.localName||!e||o.has(e)||!a.getAttribute("Type")||!a.getAttribute("Target"))return Pu("ambiguous existing relationships");const t=a.getAttribute("TargetMode");if(t&&"Internal"!==t&&"External"!==t)return Pu("unknown relationship mode");o.add(e)}for(const a of t){if(o.has(a.id))return Pu("relationship collision");o.add(a.id);const e=n.createElementNS(li,r.prefix?r.prefix+":Relationship":"Relationship");e.setAttribute("Id",a.id),e.setAttribute("Type",a.type),e.setAttribute("Target",a.target),r.appendChild(e)}return Ou(n)}(await(r.file(h)?.async("string"))??'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"/>',a.addedRelationships),y=await(r.file(ku)?.async("string"));if(!y)return Pu("missing content types");const v=function(e,t){const n=Ru(e,la,"Types"),r=n.documentElement,o=/* @__PURE__ */new Set,a=/* @__PURE__ */new Set;let i;for(const s of Mu(r)){if("http://schemas.openxmlformats.org/package/2006/content-types"!==s.namespaceURI)return Pu("unexpected content type element");const e=s.getAttribute("ContentType")??"";if(!e)return Pu("missing content type");if("Default"===s.localName){const t=(s.getAttribute("Extension")??"").toLowerCase();if(!t||a.has(t))return Pu("duplicate or invalid content type default");a.add(t),"rels"===t&&(i=e)}else{if("Override"!==s.localName)return Pu("unknown content type element");{const e=(s.getAttribute("PartName")??"").toLowerCase();if(!e.startsWith("/")||o.has(e))return Pu("duplicate or invalid content type override");o.add(e)}}}if(i&&i!==Tu)return Pu("inconsistent relationship content type");if(!i){const e=n.createElementNS(la,r.prefix?r.prefix+":Default":"Default");e.setAttribute("Extension","rels"),e.setAttribute("ContentType",Tu),r.insertBefore(e,Mu(r).find(e=>"Override"===e.localName)??null)}for(const[s,l]of Object.entries(t.contentTypeOverrides)){const e="/"+s;if(o.has(e.toLowerCase()))return Pu("content type override collision");o.add(e.toLowerCase());const t=n.createElementNS(la,r.prefix?r.prefix+":Override":"Override");t.setAttribute("PartName",e),t.setAttribute("ContentType",l),r.appendChild(t)}return Ou(n)}(y,a),x={...o,parts:{...o.parts,[i]:{...s,data:m,relationships:[...s.relationships??[],...a.addedRelationships]}},contentTypes:{defaults:{...o.contentTypes.defaults,rels:Tu},overrides:{...o.contentTypes.overrides,...a.contentTypeOverrides}}};for(const N of a.addedParts)x.parts[N.path]={...N,originalHash:""};const w=Aa(o),I=Aa(x);if(I.diagnostics.some(e=>"error"===e.level)||I.objects.length!==w.objects.length+1)return Pu("unexpected predicted inventory");const S=I.objects.filter(e=>e.ownerPath===i&&e.signature===a.destinationRun.signature);if(1!==S.length||JSON.stringify(S[0].partPaths)!==JSON.stringify(a.addedParts.map(e=>e.path).sort()))return Pu("predicted inserted closure mismatch");const C=I.objects.filter(e=>e!==S[0]),k=e=>JSON.stringify([e.ownerPath,e.kind,e.signature,e.edges,e.partPaths]);if(JSON.stringify(C.map(k).sort())!==JSON.stringify(w.objects.map(k).sort()))return Pu("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 Pu("drawing ID collision");const T=await Zi.default.loadAsync(e),P=/* @__PURE__ */new Set,R=new Set(Object.keys(T.files).map(e=>e.toLowerCase())),M=(e,t,n=!1)=>{const r=e.toLowerCase();if(R.has(r)||P.has(r))return Pu("part collision");P.add(r),T.file(e,t,{base64:n})};for(const N of a.addedParts)M(N.path,N.data,"base64"===N.encoding),N.relationships.length&&M(Au(N.path),wi(N.relationships));r.file(h)||P.add(h.toLowerCase()),T.file(i,m),T.file(h,b),T.file(ku,v);const A=await T.generateAsync({type:"arraybuffer",compression:"DEFLATE"}),O=await Zi.default.loadAsync(A);Fu(O);const B=await Ha(A),F=So(x,B);if(F.length)throw new Yr(F);const E=/* @__PURE__ */new Set([i,h,ku]);for(const[N,z]of Object.entries(r.files)){if(z.dir||E.has(N))continue;const e=O.file(N);if(!e||!Bu(await z.async("uint8array"),await e.async("uint8array")))return Pu("existing part changed: "+N)}for(const[N,z]of Object.entries(O.files))if(!z.dir&&!r.file(N)&&!P.has(N.toLowerCase()))return Pu("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 Pu("copied payload mismatch")}for(const[N,z]of Object.entries(o.parts))if(B.parts[N]?.contentType!==z.contentType)return Pu("existing part content type changed");for(const[N,z]of Object.entries(o.contentTypes.defaults))if(B.contentTypes.defaults[N]!==z)return Pu("existing default changed");for(const[N,z]of Object.entries(o.contentTypes.overrides))if(B.contentTypes.overrides[N]!==z)return Pu("existing override changed");const D=B.parts[i]?.relationships??[],L=x.parts[i].relationships??[];return JSON.stringify(D)!==JSON.stringify(L)?Pu("owner relationships changed"):{buffer:A,plan:a}}var Du=e=>{throw Error("Opaque editor transfer rejected: "+e)};function Lu(e){return 1!==e.sections?.length?Du("only one section is supported"):e.sections[0].blocks.filter(e=>"paragraph"===e.type)}function Nu(e){if(!e.document.sourcePackage||"main"!==Yo(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 Du("unsupported state or pending opaque edit")}function zu(e){Nu(e);const t=Fi(e,e=>"opaque"===e.kind);if(!t||"opaque"!==t.run.kind||t.run.revision||t.run.sdtWrappers?.length||!Lu(e.document).some(e=>e.id===t.paragraph.id))return Du("select one unwrapped chart in the main story");const n=e.document.sourcePackage,r=t.run.opaque,o=Aa(n).objects.filter(e=>e.ownerPath===n.mainDocumentPart&&e.signature===r.signature),a=1===o.length?o[0]:void 0;return a&&a.fragmentXml===r.fragmentXml&&JSON.stringify(a.relationshipIds)===JSON.stringify(r.relationshipIds)?function(e,t){const n=Aa(e);if(n.diagnostics.some(e=>"error"===e.level))return Wi("source inspection errors");const r=n.objects.filter(e=>e.signature===t.signature),o=1===r.length?r[0]:void 0;if(!o||o.ownerPath!==t.ownerPath||o.ordinal!==t.ordinal)return Wi("ambiguous original identity");if("chart"!==o.kind||"inline"!==o.geometry?.placement)return Wi("only inline charts are supported");const a=Pa(e,o.ownerPath,o.relationshipIds);if(a.issues.length)return Wi("unresolved source closure");const i=e.parts[o.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??[]}:Wi("missing source part")});return Yi({format:ji,ownerPath:o.ownerPath,fragmentXml:o.fragmentXml,signature:o.signature,relationships:(i.relationships??[]).filter(e=>o.relationshipIds.includes(e.id)),parts:s})}(n,a):Du("selection is not an unchanged original")}function $u(e){return JSON.stringify(Lu(e).map(e=>{const t=[];let n=0;for(const r of e.runs)"opaque"===r.kind&&t.push([n,r.kind,r.opaque.signature]),n+=r.text.length;return[e.runs.map(e=>e.text).join(""),t]}))}function Hu(e,t,n,r){const o=we(t,n,[r]),a=Xo(o,n+1);return Cn(e,xi(e).map(e=>e.id===t.id?o:e),{anchor:a,focus:a})}async function ju(e,t){Nu(e);const n=sa(e);if(!n.isCollapsed)return Du("paste requires a collapsed caret");const r=xi(e)[n.startIndex],o=Lu(e.document).findIndex(e=>e.id===r?.id);if(!r||o<0)return Du("caret must be in a direct body paragraph");const a=n.startParagraphOffset;if(!Number.isSafeInteger(a)||a<0||a>Za(r))return Du("invalid caret");if(r.runs.some(e=>"text"!==e.kind&&"opaque"!==e.kind||e.revision||e.sdtWrappers?.length||e.styles?.link))return Du("unsupported destination runs");const i=await pu(e.document);if($u(await xe(i.slice(0)))!==$u(e.document))return Du("destination body projection mismatch");const s=await Eu(i,t,o),l=await Ha(s.buffer),c=l.opaqueObjects?.filter(e=>e.signature===s.plan.destinationRun.signature&&e.ownerPath===l.mainDocumentPart);if(1!==c?.length)return Du("staged chart identity mismatch");const d={...s.plan.destinationRun,fragmentXml:c[0].fragmentXml,relationshipIds:[...c[0].relationshipIds]},u={id:Ur("run"),kind:"opaque",text:"",opaque:d,styles:{}},p=function(e,t){const n=e.document.sourcePackage,r=Aa(n).objects,o=Aa(t).objects,a=/* @__PURE__ */new Set,i=xi(e).map(e=>{let i=!1;const s=e.runs.map(e=>{if("opaque"!==e.kind)return e;const s=e.opaque,l=r.filter(e=>e.signature===s.signature),c=o.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 r=n.parts[e],o=t.parts[e];return!r||!o||r.kind!==o.kind||r.contentType!==o.contentType||r.encoding!==o.encoding||r.data!==o.data})||a.has(d.signature)?Du("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 Cn(e,i,e.selection)}(e,l),f=xi(p).find(e=>e.id===r.id);if(!f)return Du("target paragraph lost during rebind");const g={...Hu(p,f,Za(f),u).document,sourcePackage:l};if($u(await xe(s.buffer))!==$u(g))return Du("staged body projection mismatch");l.rebuiltPartHashes=await Sa(g,l);const m=Hu(p,f,a,u),h={...m,document:{...m.document,sourcePackage:l}},b=await pu(h.document);return $u(await xe(b))!==$u(h.document)?Du("exported caret position mismatch"):h}var Wu="application/x-oasis-chart-token",Uu="web "+Wu;function Vu(e){return"application/x-oasis-chart-token"===e||"web application/x-oasis-chart-token"===e}var _u,Ku=0;function qu(e){const t=++Ku;_u=void 0;const n=zu(e),r=globalThis.crypto.randomUUID();let o=!1;return{token:r,confirm:()=>!o&&t===Ku&&(o=!0,_u={token:r,manifest:n,expires:Date.now()+3e5},!0)}}function Xu(e){return _u&&Date.now()>=_u.expires&&(_u=void 0),_u&&_u.token===e?structuredClone(_u.manifest):void 0}function Gu(e){const t=xi(e),n=sa(e,t);if(n.isCollapsed)return!1;for(let r=n.startIndex;r<=n.endIndex;r++){const e=t[r];if(!e)continue;const o=r===n.startIndex?n.startParagraphOffset:0,a=r===n.endIndex?n.endParagraphOffset:Za(e);let i=0;for(const t of e.runs){const e=i+t.text.length;if("opaque"===t.kind&&i<a&&e>o)return!0;i=e}}return!1}function Yu(e){const t=sa(e);if(t.isCollapsed)return"";const n=xi(e),r=[];let o=null;const a=()=>{o&&(r.push("bullet"===o?"</ul>":"</ol>"),o=null)};for(let i=t.startIndex;i<=t.endIndex;i+=1){const s=n[i];if(!s)continue;const l=i===t.startIndex?t.startParagraphOffset:0,c=i===t.endIndex?t.endParagraphOffset:Za(s),d=sn(s,l,c),u=yt(s,e.document,d.map(e=>e.text).join("")),p=st(d,e.document);if(s.list?.kind){const e="bullet"===s.list.kind?"ul":"ol";o!==s.list.kind&&(a(),r.push(`<${e}>`),o=s.list.kind),r.push(`<li${u}>${p}</li>`);continue}a(),r.push(`<p${u}>${p}</p>`)}return a(),r.join("")}function Zu(e,t){if(0===t.length||be(e))return e;const n=ri(e.selection)?e:te(e),{paragraph:r,index:o,offset:a}=ae(n),i=xi(n),s=0===Za(r);if(be(n))return e;const{beforeRuns:l,afterRuns:c}=Lr(r,a),d=t.map(e=>{const t=xo(e.runs.map(e=>({text:e.text,styles:ro(e.styles),image:e.image?{...e.image}:void 0})));return t.style=e.style?{...e.style}:void 0,t.list=e.list?{...e.list}:void 0,t});let p,f=J(Xo(r,a));if(1===d.length){const e=d[0],t=e.runs.reduce((e,t)=>e+t.text.length,0),n=u(r,[...l,...e.runs.map(Ro),...c],Qn(r,a));n.style=s&&void 0!==e.style?.tabs?{...r.style,tabs:e.style.tabs}:r.style?{...r.style}:e.style?{...e.style}:void 0,n.list=r.list?{...r.list}:e.list?{...e.list}:void 0,p=[...ho(i.slice(0,o)),n,...ho(i.slice(o+1))],f=J(Xo(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=u(r,[...l,...e.runs.map(Ro)],Qn(r,a));g.style=s&&void 0!==e.style?.tabs?{...r.style,tabs:e.style.tabs}:r.style?{...r.style}:e.style?{...e.style}:void 0,g.list=r.list?{...r.list}:e.list?{...e.list}:void 0;const m=d.slice(1,-1).map(eo),h=u(t,[...t.runs.map(Ro),...c],void 0);h.list=t.list?{...t.list}:void 0,p=[...ho(i.slice(0,o)),g,...m,h,...ho(i.slice(o+1))],f=J(Xo(h,n))}return Cn(n,p,f)}function Ju(e){return e.map(Ro)}function Qu(e){return e.reduce((e,t)=>e+t.text.length,0)}function ep(e,t,n){if(0===n.length)return e;const r=xi(e),o=r.findIndex(e=>e.id===t.paragraphId);if(-1===o)return e;const a=r[o],i=To(a,t),s=Ju(n[0].runs);if(1===n.length){const t=we(a,i,s),n=r.map((e,n)=>n===o?t:e),l=Qu(s),c=Xo(t,i),d=Xo(t,i+l);return Cn(e,n,{anchor:c,focus:d})}const l=sn(a,0,i),c=sn(a,i,Za(a)),d=n[n.length-1],p=n.slice(1,-1),f=u(eo(n[0].paragraphTemplate),[...l,...s],Qn(a,i)),g=p.map(e=>u(eo(e.paragraphTemplate),Ju(e.runs))),m=u(eo(d.paragraphTemplate),[...Ju(d.runs),...c],Qn(a,i)),h=[...r.slice(0,o),f,...g,m,...r.slice(o+1)],b=Xo(f,Qu(l)),y=Xo(m,Qu(d.runs));return Cn(e,h,{anchor:b,focus:y})}function tp(e,n,r={}){const o=sa(e);if(o.isCollapsed)return e;if(function(e,t){const n=sa(e);if(n.isCollapsed)return!1;const r=xi(e),o=r.findIndex(e=>e.id===t.paragraphId);if(-1===o)return!1;if(o<n.startIndex||o>n.endIndex)return!1;const a=r[o],i=To(a,t);return!(o===n.startIndex&&i<n.startParagraphOffset||o===n.endIndex&&i>n.endParagraphOffset)}(e,n))return e;if(be(e))return e;const a=xi(e).find(e=>e.id===n.paragraphId);if(a&&(t(a)||et(a,To(a,n),To(a,n))))return e;const i=function(e){const t=sa(e);if(t.isCollapsed)return[];const n=xi(e),r=[];for(let o=t.startIndex;o<=t.endIndex;o+=1){const e=n[o],a=o===t.startIndex?t.startParagraphOffset:0,i=o===t.endIndex?t.endParagraphOffset:Za(e),s=sn(e,a,i);r.push({paragraphTemplate:eo(e),runs:s})}return r}(e);if(0===i.length)return e;const s=i.flatMap(e=>e.runs);if(s.some(e=>"opaque"===e.kind)){if(r.copy||e.trackChangesEnabled||1!==s.length||"opaque"!==s[0].kind||s[0].revision||s[0].sdtWrappers?.length||1!==i.length)return e;const t=xi(e),a=t.findIndex(e=>e.id===n.paragraphId);if(a<0)return e;const l=t[a],c=To(l,n),d=o.endParagraphOffset-o.startParagraphOffset,u=a===o.startIndex&&c>o.endParagraphOffset?c-d:c,p=te(e),f=xi(p).find(e=>e.id===l.id);return f?ep(p,Xo(f,u),i):e}if(r.copy)return ep(e,n,i);const l=function(e,t){const n=sa(e),r=xi(e),o=r.findIndex(e=>e.id===t.paragraphId);if(-1===o)return t;const a=r[o],i=To(a,t);if(n.startIndex===n.endIndex){if(o!==n.startIndex||i<=n.endParagraphOffset)return t;const e=r[n.startIndex];return Xo(e,i-(n.endParagraphOffset-n.startParagraphOffset))}return t}(e,n);return ep(te(e),l,i)}function np(e,t,n){if(0===t.length)return e;if(ri(e.selection)&&!e.trackChangesEnabled?Vn(e):be(e))return e;const r=ri(e.selection)?e:te(e),{paragraph:o,index:a,offset:i}=ae(r),s=n?{...n}:Qn(o,i),l={id:`run:${Math.random().toString(36).slice(2,9)}`,text:t,styles:s,kind:"text"};r.trackChangesEnabled&&(l.revision={id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"insert",author:"User",date:Date.now()});const c=!e.trackChangesEnabled&&ri(e.selection)?e.selection.focus.fieldBoundaryAffinity:void 0,d=we(o,i,[l],c),u=xi(r).map((e,t)=>t===a?d:e);return Cn(r,u,J(Uo(d,i+t.length,c)))}function rp(e){return np(e,"\v")}function op(e,n,r){if(0===n.length)return e;const o=n.replace(/\r\n/g,"\n").replace(/\r/g,"\n");if(!o.includes("\n"))return np(e,o,r);if(Ve(e))return e;const a=ri(e.selection)?e:te(e),{paragraph:i,index:s,offset:l}=ae(a);if(Ve(a))return e;const c=o.split("\n"),d=r?{...r}:Qn(i,l),{beforeRuns:p,afterRuns:f}=Lr(i,l,a.selection.focus.fieldBoundaryAffinity),g=u(i,[...p,ko(c[0],d)],d),m=c.slice(1,-1).map(e=>Ee([{text:e,styles:d}])),h=u(t(i)?He(i,[]):Ee([]),[ko(c[c.length-1],d),...f],d),b=xi(a),y=[...b.slice(0,s),g,...m,h,...b.slice(s+1)];return Cn(a,y,J(Uo(h,c[c.length-1].length,"before-markers")))}function ap(e,t){const n=xi(e),r=sa(e,n);if(r.startIndex!==r.endIndex)return;const o=n[r.startIndex];if(!o)return;let a=r.startParagraphOffset,i=r.endParagraphOffset;if(r.isCollapsed&&("backward"===t?a-=1:i+=1),a<0||i>Za(o)||i-a!==1)return;let s,l=0;for(const h of o.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"!==Yo(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],f=e.document.opaqueDeletionIntents??[];if(f.some(e=>e.ownerPath===p.ownerPath&&e.ordinal===p.ordinal))return e;const g=te({...e,selection:{anchor:Xo(o,a),focus:Xo(o,i)}}),m={ownerPath:p.ownerPath,ordinal:p.ordinal,signature:p.signature};return{...g,document:{...g.document,opaqueDeletionIntents:[...f,m]}}}function ip(e){const n=ap(e,"backward");if(void 0!==n)return n;if(!ri(e.selection))return te(e);const{paragraph:r,index:o,offset:a}=ae(e),i=xi(e);if(a>0){if(e.trackChangesEnabled&&Nt(e)||F(e,r,a-1,a))return e;if(t(r)){const t={...e,selection:{anchor:Xo(r,a-1),focus:Xo(r,a)}};return te(t)}if(e.trackChangesEnabled){const t=r.runs;let n=0,s=-1,l=-1;for(let e=0;e<t.length;e+=1){const r=n+t[e].text.length;if(a<=r){s=e,l=a-n;break}n=r}if(-1!==s){const n=t[s];if("insert"===n.revision?.type){const t=[...sn(r,0,a-1),...sn(r,a,Za(r))],n=u(r,t),s=i.map((e,t)=>t===o?n:e);return Cn(e,s,J(Xo(n,a-1)))}const c=n.text[l-1],d={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...n.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=[...sn(r,0,a-1),d,...sn(r,a,Za(r))],f=u(r,p),g=i.map((e,t)=>t===o?f:e);return Cn(e,g,J(Xo(f,a-1)))}}const n=u(r,[...sn(r,0,a-1),...sn(r,a,Za(r))],Qn(r,a-1)),s=i.map((e,t)=>t===o?n:e);return Cn(e,s,J(Xo(n,a-1)))}if(0===o)return e;const s=i[o-1];if(Ge(e,s,r))return e;const l=u(s,[...s.runs.map(Ro),...r.runs.map(Ro)]),c=[...i.slice(0,o-1),l,...i.slice(o+1)];return Cn(e,c,J(Uo(l,Za(s),U(s,r))))}function sp(e){const n=ap(e,"forward");if(void 0!==n)return n;if(!ri(e.selection))return te(e);const{paragraph:r,index:o,offset:a}=ae(e),i=xi(e);if(a<Za(r)){if(e.trackChangesEnabled&&Nt(e)||F(e,r,a,a+1))return e;if(t(r)){const t={...e,selection:{anchor:Xo(r,a),focus:Xo(r,a+1)}};return te(t)}if(e.trackChangesEnabled){const t=r.runs;let n=0,s=-1,l=-1;for(let e=0;e<t.length;e+=1){const r=n+t[e].text.length;if(a<r){s=e,l=a-n;break}n=r}if(-1!==s){const n=t[s];if("insert"===n.revision?.type){const t=[...sn(r,0,a),...sn(r,a+1,Za(r))],n=u(r,t),s=i.map((e,t)=>t===o?n:e);return Cn(e,s,J(Xo(n,a)))}const c=n.text[l],d={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...n.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=[...sn(r,0,a),d,...sn(r,a+1,Za(r))],f=u(r,p),g=i.map((e,t)=>t===o?f:e);return Cn(e,g,J(Xo(f,a)))}}const n=u(r,[...sn(r,0,a),...sn(r,a+1,Za(r))],Qn(r,a)),s=i.map((e,t)=>t===o?n:e);return Cn(e,s,J(Xo(n,a)))}if(o>=i.length-1)return e;const s=i[o+1];if(Ge(e,r,s))return e;const l=u(r,[...r.runs.map(Ro),...s.runs.map(Ro)]),c=[...i.slice(0,o),l,...i.slice(o+2)];return Cn(e,c,J(Uo(l,a,U(r,s))))}function lp(e,t,n,r,o){let a=fo(n,r,o);const i=Ho(a,t.style?.styleId,e.document.styles);return!o&&i[r]&&(a={...a,[r]:!1}),!o||"superscript"!==r&&"subscript"!==r||(a=lp(e,t,a,"superscript"===r?"subscript":"superscript",!1)),a}function cp(e,t){const n=sa(e);if(n.isCollapsed||X(e))return e;const r=xi(e),o=r.slice(n.startIndex,n.endIndex+1).flatMap((t,r)=>{const o=n.startIndex+r,a=o===n.startIndex?n.startParagraphOffset:0,i=o===n.endIndex?n.endParagraphOffset:Za(t);return sn(t,a,i).map(n=>({...n,styles:Ho(n.styles,t.style?.styleId,e.document.styles)}))}).filter(e=>e.text.length>0);if(0===o.length)return e;const a=!o.every(e=>Boolean(e.styles?.[t])),i=r.map((r,o)=>{if(o<n.startIndex||o>n.endIndex)return r;const i=o===n.startIndex?n.startParagraphOffset:0,s=o===n.endIndex?n.endParagraphOffset:Za(r);return M(e,r,i,s,n=>({...n,styles:lp(e,r,n.styles,t,a)}))});return Cn(e,i,H(i,n))}function dp(e,t,n){const r=sa(e);if(r.isCollapsed||X(e))return e;const o=xi(e).map((o,a)=>{if(a<r.startIndex||a>r.endIndex)return o;const i=a===r.startIndex?r.startParagraphOffset:0,s=a===r.endIndex?r.endParagraphOffset:Za(o);return M(e,o,i,s,e=>({...e,styles:uo(e.styles,t,n)}))});return Cn(e,o,H(o,r))}function up(e,t){const n=sa(e);if(n.isCollapsed||X(e))return e;const r=xi(e),o=e.document.styles,a=r.map((r,a)=>{if(a<n.startIndex||a>n.endIndex)return r;const i=a===n.startIndex?n.startParagraphOffset:0,s=a===n.endIndex?n.endParagraphOffset:Za(r);return M(e,r,i,s,e=>{const n=(Ho(e.styles,r.style?.styleId,o).fontSize??14.6667)*Xr,a=Math.max(1,Math.min(1638,n+t));return{...e,styles:uo(e.styles,"fontSize",a/Xr)}})});return Cn(e,a,H(a,n))}var pp={width:.5,type:"solid",color:"#000000"};function fp(e,t){const n={...e??{}};return t?n.textBorder=pp:delete n.textBorder,Object.keys(n).length>0?n:void 0}function gp(e){return/\p{L}/u.test(e)}function mp(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 r of e){const e=gp(r);t+=e&&!n?r.toUpperCase():r,n=e}return t}(e);case"toggle":return function(e){let t="";for(const n of e){const e=n.toUpperCase(),r=n.toLowerCase();t+=n===r&&n!==e?e:n===e&&n!==r?r:n}return t}(e);default:return function(e){let t="",n=!0;for(const r of e.toLowerCase())n&&gp(r)?(t+=r.toUpperCase(),n=!1):(t+=r,"."!==r&&"!"!==r&&"?"!==r||(n=!0));return t}(e)}}function hp(e,t){return function(e,t){const n=sa(e);if(n.isCollapsed)return e;const r=xi(e).map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const o=r===n.startIndex?n.startParagraphOffset:0,a=r===n.endIndex?n.endParagraphOffset:Za(e),i=t(sn(e,o,a).map(e=>e.text).join(""));let s=0;return ge(e,o,a,e=>{const t=e.text.length,n=i.slice(s,s+t);return s+=t,{...e,text:n}})});return Cn(e,r,H(r,n))}(e,e=>mp(e,t))}var bp=["bold","italic","underline","underlineStyle","underlineColor","strike","doubleStrike","smallCaps","allCaps","superscript","subscript","link"];function yp(e,t){const n=ro(e)??{};delete n.link;for(const r of bp)void 0!==t?.[r]&&Object.assign(n,{[r]:t[r]});return Object.keys(n).length>0?n:void 0}function vp(e,t){if(0===t.length)return[];const n=sa(e),r=xi(e)[n.startIndex];if(!r)return t;const o=Qn(r,n.startParagraphOffset);return t.map(e=>({runs:e.runs.map(e=>({...e,styles:yp(o,e.styles)})),style:$o(r.style),list:r.list?{...r.list}:void 0}))}function xp(e){if("undefined"==typeof document||0===e.trim().length)return[];const t=document.createElement("template");t.innerHTML=e;const n=[],r=Array.from(t.content.childNodes),o=(e,t,r)=>{const o=t.length>0?t:[ko("")];n.push({runs:o.map(e=>{const t=da(e);return{text:e.text,styles:ro(e.styles),image:t?{...t}:void 0}}),style:e?Br(e):void 0,list:r})},a=(e,t)=>{for(const n of Array.from(e.children))"LI"===n.tagName&&o(n,de(n,void 0),{kind:t,level:0})};for(const i of r){if(i.nodeType===Node.TEXT_NODE){const e=i.textContent??"";e.trim().length>0&&o(null,[ko(e)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const e=i,t=s(e.tagName);if(t){a(e,t);continue}if(pn(e.tagName)){o(e,de(e,void 0),"LI"===e.tagName?{kind:"bullet",level:0}:void 0);continue}const n=de(e,void 0);n.length>0&&o(null,n)}return n}async function wp(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(),r={anchor:{...n.selection.anchor},focus:{...n.selection.focus}};let o;try{o=await async function(e){const t=navigator.clipboard;let n=/* @__PURE__ */new Error("Clipboard access unavailable"),r=!1,o=!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(Vu).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};r=!0,o=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:""};r=!0}catch(i){n=i}if(r)return{kind:o?"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"===o.kind){if("rich"!==t||!e.stateSnapshot)return e.onIssue?.("unsupported"),!1;const r=Xu(o.token);if(!r)return e.onIssue?.("unsupported"),!1;if(e.stateSnapshot()!==n)return e.onIssue?.("document-changed"),!1;let a;try{a=await ju(n,r)}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"!==o.kind)return e.onIssue?.(o.kind),!1;const a="text"!==t?xp(o.html):[],i="merge"===t?vp({...n,selection:r},a):a;if(0===i.length&&0===o.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:r},l=e.applyTableAwareParagraphEdit(a,e=>i.length>0?Zu(e,i):op(e,o.text));return s=l.document!==t.document,l}),s&&e.focusInput(),s}function Ip(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 Sp(e){const t="undefined"!=typeof navigator?navigator.clipboard:void 0;if(t?.writeText)try{return t.writeText(e).then(()=>!0,()=>Ip(e))}catch{}return Promise.resolve(Ip(e))}async function Cp(e,t){if(Gu(e)){let n;try{n=qu(e)}catch{return t?.("unsupported"),!1}const r="undefined"!=typeof navigator?navigator.clipboard:void 0;if(!r?.write||"undefined"==typeof ClipboardItem)return t?.("unsupported"),!1;try{const e=new ClipboardItem({[Uu]:new Blob([n.token],{type:Uu.slice(4)})});return await r.write([e]),n.confirm()}catch{return t?.("access-denied"),!1}}const n=await function(e){const t=Mi(e);if(!t)return Promise.resolve(!1);const n="undefined"!=typeof navigator?navigator.clipboard:void 0;if(n?.write&&"undefined"!=typeof ClipboardItem)try{const r=Yu(e),o=new ClipboardItem({"text/plain":new Blob([t],{type:"text/plain"}),"text/html":new Blob([r],{type:"text/html"})});return n.write([o]).then(()=>!0,()=>Sp(t))}catch{}return Sp(t)}(e);return!n&&Mi(e)&&t?.("access-denied"),n}function kp(e){return function(e){const[t,n]=$t();let r,o=0;Hn()&&_t(()=>{o++});const a=()=>{n(void 0),r=void 0},i=()=>{o++,a()},s=async(t,i="rich")=>{const s=++o;a();const l=e.stateSnapshot?.()??e.state(),c=a=>{s===o&&(n({action:t,issue:a,..."paste"===t?{mode:i}:{}}),"access-denied"!==a&&"unsupported"!==a||("paste"!==t||"unsupported"===a&&"rich"!==i||(r={document:l.document,mode:i}),e.focusInput()),e.onIssue?.(a))};if("copy"===t)return Cp(l,c);const d={...e,onIssue:c,isReadOnly:()=>s!==o||e.isReadOnly()};return"cut"===t?async function(e){if(e.isReadOnly())return!1;const t=e.stateSnapshot?.()??e.state();if(Gu(t))return e.onIssue?.("unsupported"),!1;if(!Mi(t))return!1;if(!(await Cp(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 r=!1;return e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(o=>{if(e.isReadOnly()||o.document!==t.document)return o;const a={...o,selection:n},i=e.applyTableAwareParagraphEdit(a,e=>ip(e));return r=i.document!==o.document,i}),r&&e.focusInput(),r}(d):wp(d,i)},l=()=>{const t=r;return i(),t?.document===e.state().document?t.mode:void 0},c=(t,r)=>{o++,a(),n({action:t,issue:r,..."paste"===t?{mode:"rich"}:{}}),e.onIssue?.(r)};return{notice:t,dismiss:i,reportNativeIssue:c,requestGeneration:()=>o,consumePasteMode:l,copy:()=>s("copy"),cut:()=>s("cut"),paste:(e="rich")=>s("paste",e),hasSelection:()=>Mi(e.state()).length>0}}(e)}var Tp=/*#__PURE__*/Gn("<div class=oasis-editor-clipboard-feedback role=status aria-live=polite aria-atomic=true>"),Pp=/*#__PURE__*/Gn("<div class=oasis-editor-clipboard-feedback-message data-testid=editor-clipboard-feedback>");function Rp(e){const t=E();let n;const[r,o]=$t(12);bn(()=>{if(!e.notice())return;const t=n?.parentElement;if(!t)return;const r=()=>{const e=t.getBoundingClientRect(),r=t.querySelector(".oasis-editor-toolbar"),a=r?r.getBoundingClientRect().bottom-e.top+8:12,i=Math.max(12,12-e.top),s=window.innerHeight-e.top-(n?.offsetHeight??0)-12;o(Math.max(i,Math.min(a,s)))};queueMicrotask(r);const a=new ResizeObserver(r);a.observe(t),n&&a.observe(n);const i=t.querySelector(".oasis-editor-toolbar");i&&a.observe(i),window.addEventListener("resize",r),window.addEventListener("scroll",r,!0),_t(()=>{a.disconnect(),window.removeEventListener("resize",r),window.removeEventListener("scroll",r,!0)})});return a=Tp(),"function"==typeof n?nn(n,a):n=a,_e(a,St(En,{get when(){return e.notice()},children:n=>{return r=Pp(),_e(r,St(ft,{name:"clipboard"}),null),_e(r,St(Mn,{get children(){return(e=>{const n=`${/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl+"}${"copy"===e.action?"C":"cut"===e.action?"X":"V"}`,r="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(r,[n])})(n())}}),null),_e(r,St(Se,{variant:"ghost",size:"sm",icon:"x",get label(){return t("generic.close")},get onClick(){return e.onDismiss},"data-testid":"editor-clipboard-feedback-close"}),null),r;var r}})),Mt(e=>Ft(a,"top",`${r()}px`)),a;var a}var Mp=/[\s\-–—/_([{]/;function Ap(e,t){const n=e.trim().toLowerCase();if(0===n.length)return 0;const r=t.toLowerCase();if(r===n)return 1e3;const o=r.indexOf(n);if(o>=0){let e=400;return 0===o?e+=400:!function(e,t){return 0===t||Mp.test(e[t-1]??"")}(r,o)?e+=100:e+=200,e+=Math.round(n.length/r.length*50),e}let a=0,i=-1,s=-1,l=0;for(const d of n){const e=r.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 Op(e,t){const n=e.trim().toLowerCase();if(0===n.length)return 0;const r=Ap(n,t.label),o=Ap(n,t.command),a=Math.max(r??Number.NEGATIVE_INFINITY,(o??Number.NEGATIVE_INFINITY)-50);return Number.isFinite(a)?a:null}var Bp=/*#__PURE__*/Gn("<ul id=editor-command-search-listbox class=oasis-command-search-list role=listbox data-testid=editor-command-search-listbox>"),Fp=/*#__PURE__*/Gn("<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>"),Ep=/*#__PURE__*/Gn("<kbd class=oasis-command-search-shortcut>"),Dp=/*#__PURE__*/Gn("<li role=option class=oasis-command-search-option data-testid=editor-command-search-item>");function Lp(e){const t=E(),[r,o]=$t(""),[a,i]=$t(0);let s;bn(()=>{e.isOpen&&(o(""),i(0),queueMicrotask(()=>{s?.focus()}))});const l=pr(()=>function(e,t,n=24){const r=e.trim().toLowerCase();if(0===r.length)return t.map(e=>({...e,score:0})).sort((e,t)=>e.label.localeCompare(t.label)).slice(0,n);const o=[];for(const a of t){const e=Op(r,a);null!==e&&o.push({...a,score:e})}return o.sort((e,t)=>t.score-e.score||e.label.length-t.label.length),o.slice(0,n)}(r(),e.entries,12));bn(()=>{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)},u=e=>{const t=l().length;0!==t&&i(n=>(n+e+t)%t)},p=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),u(1);break;case"ArrowUp":t.preventDefault(),u(-1);break;case"Enter":{t.preventDefault();const e=l()[a()];e&&d(e);break}case"Escape":t.preventDefault(),e.onClose()}};return St(En,{get when(){return e.isOpen},get children(){var u=Fp(),f=u.firstChild;return _n(u,"click",e.onClose,!0),f.$$keydown=p,f.$$click=e=>e.stopPropagation(),_e(f,St(R,{id:"editor-command-search-input",get placeholder(){return t("commandSearch.placeholder")},get value(){return r()},onChange:e=>{o(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 tt(()=>!!l()[a()])()?`editor-command-search-option-${a()}`:void 0},"data-testid":"editor-command-search-input",autocomplete:"off",spellcheck:!1}),null),_e(f,St(Mn,{class:"oasis-command-search-hint",get children(){return t("commandSearch.hint")}}),null),_e(f,St(En,{get when(){return l().length>0},get fallback(){return St(Mn,{as:"p",class:"oasis-command-search-empty","data-testid":"editor-command-search-empty",get children(){return t("commandSearch.noResults")}})},get children(){var e=Bp();return _e(e,St(pt,{get each(){return l()},children:(e,t)=>{const r=()=>t()===a(),o=()=>c(e);return(s=Dp()).$$click=()=>d(e),s.addEventListener("mouseenter",()=>{i(t())}),_e(s,St(Mn,{as:"span",get children(){return e.label}}),null),_e(s,St(En,{get when(){return e.shortcut},get children(){var t=Ep();return _e(t,()=>e.shortcut),t}}),null),Mt(a=>{var i=`editor-command-search-option-${t()}`,l=r(),c=!o()||void 0,d=!!r(),u=!o(),p=e.command;return i!==a.e&&n(s,"id",a.e=i),l!==a.t&&n(s,"aria-selected",a.t=l),c!==a.a&&n(s,"aria-disabled",a.a=c),d!==a.o&&s.classList.toggle("oasis-command-search-option-active",a.o=d),u!==a.i&&s.classList.toggle("oasis-command-search-option-disabled",a.i=u),p!==a.n&&n(s,"data-command",a.n=p),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),s;var s}})),e}}),null),_e(f,St(Yn,{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),Mt(()=>n(f,"aria-label",t("commandSearch.title"))),u}})}function Np(e){return e?"string"==typeof e?{command:e}:"object"==typeof e&&"string"==typeof e.name?{command:e.name,payload:e.payload}:null:null}function zp(e){return Np(e.command)}Ye(["click","keydown"]);var $p=!1,Hp=null,jp=null,Wp=null,Up=[];function Vp(){"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}()?$p&&(delete window.__oasisCanvasDebug,$p=!1):$p||(window.__oasisCanvasDebug={getLastHit:()=>Hp?{...Hp}:null,getLayoutSnapshot:()=>jp?{...jp,surfaceRect:{...jp.surfaceRect},pages:jp.pages.map(e=>({...e})),paragraphs:jp.paragraphs.map(e=>({...e,lines:e.lines.map(e=>({...e,slots:e.slots.map(e=>({...e}))})),tableCell:e.tableCell?{...e.tableCell}:void 0})),inlineImages:jp.inlineImages.map(e=>({...e})),inlineTextBoxes:jp.inlineTextBoxes.map(e=>({...e})),unsupportedRegions:jp.unsupportedRegions.map(e=>({...e}))}:null,getSelection:()=>Wp?{anchor:{...Wp.anchor},focus:{...Wp.focus},activeZone:Wp.activeZone,activeSectionIndex:Wp.activeSectionIndex}:null,getMissEvents:()=>Up.map(e=>({...e})),clearMissEvents:()=>{Up=[]}},$p=!0))}function _p(e){$p&&e&&(Hp={timestamp:Date.now(),zone:e.zone,paragraphId:e.paragraphId,paragraphOffset:e.paragraphOffset,source:e.source,missReason:e.missReason,resolvedFromParagraph:e.resolvedFromParagraph})}var Kp=["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 qp(e,t,n){const r=n?.trim();if(!r)return;const o=r.toLowerCase();t.has(o)||(t.add(o),e.push(r))}function Xp(e){return function(e){const[t,n]=$t([]),r=()=>function(e,t,n=[]){const r=/* @__PURE__ */new Set,o=[],a=[];for(const i of Object.values(e?.styles??{}))qp(o,r,i.textStyle?.fontFamily);qp(o,r,t.fontFamily);for(const i of n)qp(a,r,i);for(const i of Kp)qp(a,r,i);return[...o.sort((e,t)=>e.localeCompare(t)),...a.sort((e,t)=>e.localeCompare(t))]}(e.state().document,e.toolbarStyleState(),t()),o=()=>function(e,t){const n=new Set(Pn);for(const o of Object.values(e?.styles??{})){const e=o.textStyle?.fontSize;"number"==typeof e&&Number.isFinite(e)&&n.add(tn(e))}const r=tn(Number(t.fontSize));return Number.isFinite(r)&&r>0&&n.add(r),Array.from(n).sort((e,t)=>e-t)}(e.state().document,e.toolbarStyleState());return{computeFontFamilyOptions:r,computeFontSizeOptions:o,loadLocalFontFamilyOptions:async()=>{if(t().length>0)return;const e=await h();e.length>0&&n(e)}}}(e)}var Gp="insertText",Yp="composition",Zp="insertImage",Jp="insertTable",Qp="moveImage",ef="splitListItem",tf="link",nf="imageAlt",rf="imageCaption",of="imageResize",af="imageCrop",sf="imageFlip",lf="imageRotate",cf="imageTransparency",df="imageReset",uf="layoutWrapPolygon",pf="specialIndent",ff="paraBorders",gf="paragraphMoveUp",mf="paragraphMoveDown",hf="findReplace",bf="findReplaceAll",yf="tableProperties",vf="paragraph-dialog",xf="font-dialog",wf="copyTextByDrag",If="moveTextByDrag",Sf="mergeTable",Cf="splitTable",kf="insertTableColumn",Tf="deleteTableColumn",Pf="insertTableRow",Rf="deleteTableRow",Mf="tableShading",Af="tableBorders",Of="tableWidth",Bf="tableAlign",Ff="tableCellAlignment",Ef="tableCellVerticalAlign",Df="tableCellTextDirection",Lf="tableCellWidth",Nf="tableColumnWidth",zf="tableToText",$f="textToTable",Hf="tableSplitAtRow",jf="tableSortAscending",Wf="tableSortDescending",Uf="tableDelete",Vf="deleteTableCell",_f="tableAutoFit",Kf="tableRepeatHeaderRows",qf="tableCellMargins",Xf="tableFormula",Gf="tableRowHeight",Yf="tableStyleOptions",Zf="tableStyleGallery",Jf="tableDistribute",Qf="layoutWrapPreset",eg="layoutFixedPosition",tg="shapeFill",ng="shapeOutline",rg="shapeOutlineWidth",og="floatingAlign",ag="floatingReorder",ig="floatingNudge",sg="floatingFixedPosition",lg="floatingRotation",cg="floatingWrap",dg="floatingWrapText",ug="floatingPositionPreset",pg="shapePreset",fg="textBoxTextDirection",gg="textBoxVerticalAlign",mg="textBoxAlt",hg="textBoxRotate",bg="textBoxWidthCm",yg="textBoxHeightCm";function vg(e,t){const n={...e},r=(e,t)=>{null==t?delete n[e]:n[e]=t};return r("align",t.align),r("indentLeft",t.indentLeft),r("indentRight",t.indentRight),r("indentFirstLine",t.indentFirstLine),r("indentHanging",t.indentHanging),n.mirrorIndents=t.mirrorIndents,r("spacingBefore",t.spacingBefore),r("spacingAfter",t.spacingAfter),r("lineHeight",t.lineHeight),r("lineRule",t.lineRule),n.contextualSpacing=t.contextualSpacing,r("outlineLevel",t.outlineLevel),r("shading",t.shading),r("borderTop",t.borders.top),r("borderRight",t.borders.right),r("borderBottom",t.borders.bottom),r("borderLeft",t.borders.left),n.pageBreakBefore=t.pageBreakBefore,n.keepWithNext=t.keepWithNext,n.keepLinesTogether=t.keepLinesTogether,n.widowControl=t.widowControl,r("tabs",t.tabs.length>0?t.tabs:null),n}function xg(){return{id:`rev:${Math.random().toString(36).slice(2,9)}`,author:"User",date:Date.now()}}function wg(e,t,n){const r={...e??{}};return null===n?delete r[t]:r[t]=n,Object.keys(r).length>0?r:void 0}function Ig(e,t){const n=Si(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})),r=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,o=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:r,endnotes:o}}}function Sg(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:Sg(e.blocks,t)}))}))}})}function Cg(e,t,n){const r=Si(e)[t];if(r)return"header"===n?r.header:"footer"===n?r.footer:r.blocks}function kg(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Tg(e){const t=ya(e),n=wo(e.document,e.selection.focus.paragraphId,t);return n?{activeSectionIndex:t,loc:kg(n)}:null}function Pg(e,t,n){const r=t[0];if(!r)return e;const o=e[r.tableBlockIndex];if(!o||"table"!==o.type)return e;if(1===t.length){const t=n(o);if(t===o)return e;const a=[...e];return a[r.tableBlockIndex]=t,a}const a=o.rows[r.rowIndex],i=a?.cells[r.cellIndex];if(!a||!i)return e;const s=Pg(i.blocks,t.slice(1),n);if(s===i.blocks)return e;const l=[...a.cells];l[r.cellIndex]={...i,blocks:s};const c=[...o.rows];c[r.rowIndex]={...a,cells:l};const d=[...e];return d[r.tableBlockIndex]={...o,rows:c},d}function Rg(e,t){return Boolean(e?.some(e=>Mo(e).some(e=>e.id===t)))}function Mg(e,t,n){if("main"===t)return e.blocks;if("header"===t||"footer"===t){const r=function(e,t,n){return"header"===t?Rg(e.firstPageHeader,n)?"firstPage":Rg(e.evenPageHeader,n)?"evenPage":"default":Rg(e.firstPageFooter,n)?"firstPage":Rg(e.evenPageFooter,n)?"evenPage":"default"}(e,t,n);return e[yi(t,r)]??null}return null}function Ag(e,t,n,r){return"main"===t?{...e,blocks:r(e.blocks)}:"header"===t?Rg(e.firstPageHeader,n)?{...e,firstPageHeader:r(e.firstPageHeader)}:Rg(e.evenPageHeader,n)?{...e,evenPageHeader:r(e.evenPageHeader)}:{...e,header:e.header?r(e.header):e.header}:"footer"===t?Rg(e.firstPageFooter,n)?{...e,firstPageFooter:r(e.firstPageFooter)}:Rg(e.evenPageFooter,n)?{...e,evenPageFooter:r(e.evenPageFooter)}:{...e,footer:e.footer?r(e.footer):e.footer}:e}function Og(e,t){const n=t[0];if(!n||!e)return null;const r=e[n.tableBlockIndex];if(!r||"table"!==r.type)return null;if(1===t.length)return r;const o=r.rows[n.rowIndex],a=o?.cells[n.cellIndex];return o&&a?Og(a.blocks,t.slice(1)):null}function Bg(e,t,n){const r=t[0];if(!r)return null;const o=e[r.tableBlockIndex];if(!o||"table"!==o.type)return null;if(1===t.length)return[...e.slice(0,r.tableBlockIndex),...n,...e.slice(r.tableBlockIndex+1)];const a=o.rows[r.rowIndex],i=a?.cells[r.cellIndex];if(!a||!i)return null;const s=Bg(i.blocks,t.slice(1),n);if(!s)return null;const l=[...a.cells];l[r.cellIndex]={...i,blocks:s};const c=[...o.rows];c[r.rowIndex]={...a,cells:l};const d=[...e];return d[r.tableBlockIndex]={...o,rows:c},d}function Fg(e){const t=Tg(e);if(!t)return null;const{activeSectionIndex:n,loc:r}=t,o=e.selection.focus.paragraphId;if("footnote"===r.zone)return Dg(e,o);const a=Si(e.document)[n];return a?Mg(a,r.zone,o):null}function Eg(e){const t=e.selection.focus.paragraphId,n=Yo(e);if("footnote"===n)return Dg(e,t);const r=ya(e),o=Si(e.document)[r];return o?Mg(o,n,t):null}function Dg(e,t){const n=Ra(e.document,t)?.footnoteId??e.activeFootnoteId,r=e.document.footnotes;return(n?r?.items[n]:void 0)?.blocks??null}function Lg(e,t){const n=Tg(e);if(!n)return e;const{activeSectionIndex:r,loc:o}=n,a=e.selection.focus.paragraphId,i=e=>Bg(e,o.tablePath,t)??e;if("footnote"===o.zone){const t=Ra(e.document,a)?.footnoteId??e.activeFootnoteId,n=e.document.footnotes,r=t?n?.items[t]:void 0;return t&&n&&r?{...e,document:{...e.document,footnotes:{...n,items:{...n.items,[t]:{...r,blocks:i(r.blocks)}}}}}:e}const s=Si(e.document).map((e,t)=>t===r?Ag(e,o.zone,a,i):e);return{...e,document:{...e.document,sections:s}}}function Ng(e,t){const n=Tg(e);if(!n)return e;const{activeSectionIndex:r,loc:o}=n,a=e.selection.focus.paragraphId,i=e=>Pg(e,o.tablePath,t);if("footnote"===o.zone){const t=Ra(e.document,a)?.footnoteId??e.activeFootnoteId,n=e.document.footnotes,r=t?n?.items[t]:void 0;return t&&n&&r?{...e,document:{...e.document,footnotes:{...n,items:{...n.items,[t]:{...r,blocks:i(r.blocks)}}}}}:e}const s=Si(e.document).map((e,t)=>t===r?Ag(e,o.zone,a,i):e);return{...e,document:{...e.document,sections:s}}}var zg={width:.5,type:"solid",color:"#000000"},$g={width:0,type:"none",color:"transparent"};function Hg(e){const t=ya(e),n=wo(e.document,e.selection.anchor.paragraphId,t),r=wo(e.document,e.selection.focus.paragraphId,t);if(!n||!r||n.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 r=e[n],o=t[n];if(r.tableBlockIndex!==o.tableBlockIndex)return!1;if(n<e.length-1&&(r.rowIndex!==o.rowIndex||r.cellIndex!==o.cellIndex))return!1}return!0}(n.tablePath,r.tablePath))return null;const o=Cg(e.document,t,n.zone);if(!o)return null;const a=bo(o,n.tablePath),i=bo(o,r.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=r.tablePath[r.tablePath.length-1];if(!c||!d)return null;const u=Vo(s.table),p=u.find(e=>e.rowIndex===c.rowIndex&&e.cellIndex===c.cellIndex),f=u.find(e=>e.rowIndex===d.rowIndex&&e.cellIndex===d.cellIndex);if(!p||!f)return null;const g=Math.min(p.visualRowIndex,f.visualRowIndex),m=Math.max(p.visualRowIndex+p.rowSpan-1,f.visualRowIndex+f.rowSpan-1),h=Math.min(p.visualColumnIndex,f.visualColumnIndex),b=Math.max(p.visualColumnIndex+p.colSpan-1,f.visualColumnIndex+f.colSpan-1);return{entries:u,selectedEntries:u.filter(e=>e.visualRowIndex<=m&&e.visualRowIndex+e.rowSpan-1>=g&&e.visualColumnIndex<=b&&e.visualColumnIndex+e.colSpan-1>=h),startRow:g,endRow:m,startCol:h,endCol:b}}function jg(e,t,n){const r=function(e){const t=/* @__PURE__ */new Set,n=Hg(e);if(!n)return t;for(const r of n.selectedEntries)for(const e of r.cell.blocks)for(const n of Mo(e))t.add(n.id);return t}(e);if(0===r.size)for(const i of function(e){const t=/* @__PURE__ */new Set,n=sa(e),r=xi(e);for(let o=n.startIndex;o<=n.endIndex;o+=1)t.add(r[o].id);return t}(e))r.add(i);const o=r=>{let o=r.style;return e.trackChangesEnabled&&"revision"!==t&&"propertyRevision"!==t&&!o?.propertyRevision&&(o={...o??{},propertyRevision:{...xg(),type:"property",previous:{...o??{}}}}),{...r,style:wg(o,t,n)}},a=Si(e.document).map(e=>({...e,blocks:Kt(e.blocks,r,o),header:e.header?Kt(e.header,r,o):void 0,footer:e.footer?Kt(e.footer,r,o):void 0}));return{...e,document:{...e.document,sections:a}}}function Wg(e,t){let n=jg(e,"borderTop",t);return n=jg(n,"borderRight",t),n=jg(n,"borderBottom",t),n=jg(n,"borderLeft",t),n}function Ug(e,t,n){const r=function(e){const t=sa(e),n=xi(e),r=/* @__PURE__ */new Set;for(let o=t.startIndex;o<=t.endIndex;o+=1)r.add(n[o].id);return r}(e),o=a=>a.map(a=>{if("paragraph"===a.type)return a;const i=a.rows.map(e=>({...e,cells:e.cells.map(e=>({...e,blocks:o(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,r)?(r=>{let o=r.style;return e.trackChangesEnabled&&"revision"!==t&&!o?.revision&&(o={...o??{},revision:{...xg(),type:"property",previous:{...o??{}}}}),{...r,style:wg(o,t,n)}})(s):s});return Ig(e,o)}function Vg(e,t,n,r){const o=o=>{if(o.id!==t)return o;let a=o.style;return e.trackChangesEnabled&&"revision"!==n&&!a?.revision&&(a={...a??{},revision:{...xg(),type:"property",previous:{...a??{}}}}),{...o,style:wg(a,n,r)}};return Ig(e,e=>Sg(e,o))}function _g(e,t,n){const r=Tg(e);if(!r)return e;return Ng(e,o=>{const a=o.rows.map((o,a)=>a===r.loc.rowIndex?(()=>{let r=o.style;return e.trackChangesEnabled&&"revision"!==t&&"propertyRevision"!==t&&!r?.propertyRevision&&(r={...r??{},propertyRevision:{...xg(),type:"property",previous:{...r??{}}}}),{...o,style:wg(r,t,n)}})():o);return{...o,rows:a}})}function Kg(e,t){const n=Tg(e);if(!n)return e;return Ng(e,r=>({...r,rows:r.rows.map((r,o)=>{if(o!==n.loc.rowIndex)return r;let a=r.style;e.trackChangesEnabled&&!a?.propertyRevision&&(a={...a??{},propertyRevision:{...xg(),type:"property",previous:{...a??{},isHeader:r.isHeader}}});const i=null===t?void 0:t;return{...r,isHeader:i,style:wg(a,"isHeader",i??null)}})}))}function qg(e,t,n){const r=r=>{if(r.id!==t)return r;const o=r.rows.map((t,r)=>{if(!Object.prototype.hasOwnProperty.call(n,r))return t;let o=t.style;return e.trackChangesEnabled&&!o?.propertyRevision&&(o={...o??{},propertyRevision:{...xg(),type:"property",previous:{...o??{}}}}),{...t,style:wg(o,"height",n[r])}});return{...r,rows:o}};return Ig(e,e=>Sg(e,r))}function Xg(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*Xr:null}if(!/^[+-]?\d+(\.\d+)?$/.test(t))return null;const n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function Gg(e,t,n,r,o){const a=a=>{if(a.id!==t)return a;const i=Vo(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=Xg(n[e]);if(null!==t){c[e]=Math.max(1,t),d=!0;continue}const r=a.gridCols?.[e];if(!("number"==typeof r&&Number.isFinite(r)&&r>0)){u=!1;break}c[e]=r}const p=a.rows.map((t,r)=>{const o=t.cells.map((t,o)=>{const a=s.get(`${r}:${o}`);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?{...xg(),type:"property",previous:{...t.style??{}}}:t.style?.propertyRevision;return{...t,style:{...t.style??{},width:i,...n?{propertyRevision:n}:{}}}}return t});return{...t,cells:o}}),f={...a.style??{}};return!e.trackChangesEnabled||f.revision||void 0===r&&void 0===o||(f.revision={...xg(),type:"property",previous:{...a.style??{}}}),void 0!==r&&(f.width=r),void 0!==o&&(f.indentLeft="number"==typeof o?o:Number(o)),{...a,rows:p,gridCols:d&&u?c:a.gridCols,gridRevision:e.trackChangesEnabled&&d&&u&&!a.gridRevision?{...xg(),type:"grid",previous:[...a.gridCols??[]]}:a.gridRevision,style:Object.keys(f).length>0?f:void 0}};return Ig(e,e=>Sg(e,a))}function Yg(e){const t=Tg(e);if(!t)return e;const n=Fg(e);if(!n)return e;const r=Og(n,t.loc.tablePath);if(!r)return e;const o=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(eo(n));return t}(r);if(0===o.length)return e;const a=Lg(e,o);if(a===e)return e;const i=o[0];return{...a,selection:J(Xo(i,0))}}function Zg(e){if(Tg(e))return e;if(!Eg(e))return e;const t=xi(e);if(0===t.length)return e;const n=sa(e,t),r=t.slice(n.startIndex,n.endIndex+1);if(0===r.length)return e;const o=function(e){const t=e.map(Jg),n=Math.max(1,...t.map(e=>e.length)),r=t.map(e=>yo(Array.from({length:n},(t,n)=>{const r=e[n]??[],o={id:Ur("paragraph"),type:"paragraph",runs:r.length>0?r:[Io("")]};return co([o])})));return no(r)}(r),a=r[0].id,i=r[r.length-1].id;let s=null,l=!1;const c=function(e,t){const n=e.selection.focus.paragraphId,r=Yo(e),o=ya(e);if("footnote"===r){const r=Ra(e.document,n)?.footnoteId??e.activeFootnoteId,o=e.document.footnotes,a=r?o?.items[r]:void 0;return r&&o&&a?{...e,document:{...e.document,footnotes:{...o,items:{...o.items,[r]:{...a,blocks:t(a.blocks)}}}}}:e}const a=Si(e.document).map((e,a)=>a===o?Ag(e,r,n,t):e);return{...e,document:{...e.document,sections:a}}}(e,e=>{const{nextBlocks:t,cell:n}=function(e,t,n,r){let o=-1,a=-1;for(let s=0;s<e.length;s+=1){const r=e[s];"paragraph"===r.type&&(r.id===t&&(o=s),r.id===n&&(a=s))}if(-1===o||-1===a||o>a)return{nextBlocks:null,cell:null};for(let s=o;s<=a;s+=1)if("paragraph"!==e[s].type)return{nextBlocks:null,cell:null};const i=r.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return{nextBlocks:[...e.slice(0,o),r,...e.slice(a+1)],cell:i??null}}(e,a,i,o);return t&&n?(s=n,l=!0,t):e});return l&&s?{...c,selection:J(Xo(s,0))}:e}function Jg(e){const t=[];let n=[];const r=()=>{n.length>0&&t.push(n),n=[]};for(const o of e.runs){const e=o.text.split("\t");for(let t=0;t<e.length;t+=1){t>0&&r();const a=e[t];if(a.length>0){const e=Ro(o);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 Qg(e,t){const n=Tg(e);if(!n)return e;const r=n.loc.cellIndex;return Ng(e,e=>{const n=function(e,t,n){const r=[],o=[];for(const l of e.rows)l.isHeader?r.push(l):o.push(l);if(o.length<2)return e.rows;const a="ascending"===n?1:-1,i=[...o].sort((e,n)=>{const r=em(e.cells[t]),o=em(n.cells[t]);return r.localeCompare(o,void 0,{numeric:!0})*a}),s=[...r,...i];return s.length===e.rows.length&&s.every((t,n)=>t===e.rows[n])?e.rows:s}(e,r,t);return n===e.rows?e:{...e,rows:n}})}function em(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:Mo(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function tm(e){return!0===e.isHeader}function nm(e){return null!==Tg(e)}function rm(e){return null!==Tg(e)}var om=/* @__PURE__ */new Set(["left","center","right"]);function am(e,t){const n=Tg(e);if(!n)return e;if(null!==t&&!om.has(t))return e;const r=function(e,t){const n=Tg(e);if(!n)return null;const r=bo(t,n.loc.tablePath);return(r?.[r.length-1])?.table??null}(e,Cg(e.document,n.activeSectionIndex,n.loc.zone)??[]);if(!r)return e;const o=r.style?.align,a=null===t?void 0:t;return o===a?e:Ug(e,"align",a)}function im(e){return null!==Tg(e)}var sm=["SUM","AVERAGE","COUNT","MIN","MAX"];function lm(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(),r=t[2].toUpperCase();return sm.includes(n)&&["ABOVE","BELOW","LEFT","RIGHT"].includes(r)?{function:n,direction:r}:null}(t);if(!n)return e;const r=Tg(e);if(!r)return e;const o=Fg(e);if(!o)return e;const a=Og(o,r.loc.tablePath);if(!a)return e;const i=function(e,t,n){const r=Vo(e),o=r.find(e=>e.rowIndex===n.rowIndex&&e.cellIndex===n.cellIndex);if(!o)return[];const a=[];for(const i of r){if(i.rowIndex===n.rowIndex&&i.cellIndex===n.cellIndex)continue;if(!dm(o,i,t))continue;if(!um(o,i,t))continue;const e=pm(cm(i.cell));null!==e&&a.push(e)}return a}(a,n.direction,r.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=r.loc.rowIndex,c=r.loc.cellIndex,d=Ng(e,e=>({...e,rows:e.rows.map((e,t)=>t!==l?e:{...e,cells:e.cells.map((e,t)=>t!==c?e:{...e,blocks:[Ma(s)]})})}));if(d===e)return e;const u=Ma(s);return{...d,selection:J(Xo(u,s.length))}}function cm(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:Mo(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function dm(e,t,n){if("LEFT"===n||"RIGHT"===n){const n=e.visualRowIndex+e.rowSpan,r=t.visualRowIndex+t.rowSpan;return e.visualRowIndex<r&&t.visualRowIndex<n}const r=e.visualColumnIndex+e.colSpan,o=t.visualColumnIndex+t.colSpan;return e.visualColumnIndex<o&&t.visualColumnIndex<r}function um(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 pm(e){const t=/\d+(?:[.,]\d+)?/.exec(e);if(!t)return null;const n=t[0].replace(",","."),r=Number(n);return Number.isFinite(r)?r:null}function fm(e,t){const n=function(e){const t=Tg(e);if(!t)return null;const n=Fg(e);if(!n)return null;const r=Og(n,t.loc.tablePath);if(!r)return null;const o=Vo(r),a=o.find(e=>e.rowIndex===t.loc.rowIndex&&e.cellIndex===t.loc.cellIndex);return a?{table:r,entries:o,active:a}:null}(e);if(!n)return e;const{table:r,entries:o,active:a}=n,i=function(e,t,n,r){switch(r){case"cell":return[n];case"row":{const e=n.visualRowIndex,r=n.visualRowIndex+n.rowSpan;return t.filter(t=>{const n=t.visualRowIndex,o=t.visualRowIndex+t.rowSpan;return n<r&&e<o})}case"column":{const e=n.visualColumnIndex,r=n.visualColumnIndex+n.colSpan;return t.filter(t=>{const n=t.visualColumnIndex,o=t.visualColumnIndex+t.colSpan;return n<r&&e<o})}case"table":return[...t]}}(0,o,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=gm(l),u=gm(c),p=d[0],f=u[u.length-1];return p&&f?{...e,selection:{anchor:Xo(p,0),focus:Xo(f,po(f).length)}}:e}function gm(e){return e.blocks.flatMap(Mo)}function mm(e){const t=function(e){const t=Tg(e);if(!t)return null;const n=Fg(e);if(!n)return null;const r=Og(n,t.loc.tablePath);return r?r.rows[t.loc.rowIndex]??null:null}(e);return Boolean(t&&t.cells.length>1)}function hm(e){const t=Tg(e);if(!t)return e;const n=Fg(e);if(!n)return e;const r=Og(n,t.loc.tablePath);if(!r)return e;const o=t.loc.rowIndex,a=t.loc.cellIndex,i=r.rows[o];if(!i||i.cells.length<=1||a>=i.cells.length)return e;const s=Ng(e,e=>{const t=e.rows.map((e,t)=>{if(t!==o)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(Mo)[0]??null:null;return c?{...s,selection:J(Xo(c,0))}:s}var bm={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 ym(e){const t=ya(e),n=wo(e.document,e.selection.focus.paragraphId,t),r=n?.tablePath[n.tablePath.length-1];if(!n||!r)return null;const o=bo(function(e,t){const n=Si(e.document)[ya(e)];return n?"header"===t?n.header??[]:"footer"===t?n.footer??[]:n.blocks:[]}(e,n.zone),n.tablePath),a=o?.[o.length-1]?.table;if(!a)return null;const i=Vo(a).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex);return{table:a,tableId:a.id,rowIndex:r.rowIndex,cellIndex:r.cellIndex,visualColumnIndex:i?.visualColumnIndex??r.cellIndex}}function vm(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 xm(e){return!!e&&"none"!==e.type&&e.width>0}function wm(e,t="table"){const n=vm(e.table.style?.width),r=e.table.rows[e.rowIndex],o=r?.cells[e.cellIndex],a=vm(r?.style?.height),i=vm(o?.style?.width),s=e.table.gridCols?.[e.visualColumnIndex],l=vm(s),c=o?.style??{},d=[c.borderTop,c.borderRight,c.borderBottom,c.borderLeft,c.borderStart,c.borderEnd,c.borderTopLeftToBottomRight,c.borderTopRightToBottomLeft].filter(xm)[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{...bm,activeTab:t,tableWidth:n.value,tableWidthUnit:n.unit,tableAlign:e.table.style?.align??"",tableIndentLeft:vm(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:r?.style?.heightRule??"",repeatHeader:Boolean(r?.isHeader),allowBreakAcrossPages:!0!==r?.style?.cantSplit,hiddenRow:!0===r?.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:xm(c.borderTop),borderRight:xm(c.borderRight),borderBottom:xm(c.borderBottom),borderLeft:xm(c.borderLeft),borderStart:xm(c.borderStart),borderEnd:xm(c.borderEnd),borderTopLeftToBottomRight:xm(c.borderTopLeftToBottomRight),borderTopRightToBottomLeft:xm(c.borderTopRightToBottomLeft),shading:c.shading??"",altTitle:e.table.style?.altTitle??"",altDescription:e.table.style?.altDescription??""}}function Im(e,t,n){return jg(e,t,n)}function Sm(e){return Boolean(ym(e))}function Cm(e,t="table"){const n=ym(e);return n?wm(n,t):null}function km(e){const t=()=>Sm(e.state());return{isInsideTable:t,openTablePropertiesDialog:(t="table")=>{const n=Cm(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=ym(e);if(!n)return e;let r=e;return r=Vg(r,n.tableId,"width",t.tableWidth),r=Vg(r,n.tableId,"align",t.tableAlign),r=Vg(r,n.tableId,"indentLeft",t.tableIndentLeft),r=Vg(r,n.tableId,"floating",t.tableFloating),r=Vg(r,n.tableId,"tblOverlap",t.tableOverlap),r=Vg(r,n.tableId,"altTitle",t.altTitle),r=Vg(r,n.tableId,"altDescription",t.altDescription),r=Kg(r,t.repeatHeader),r=_g(r,"height",t.rowHeight),r=_g(r,"heightRule",t.rowHeightRule),r=_g(r,"cantSplit",t.cantSplit),r=_g(r,"hidden",t.hiddenRow),null!==t.columnWidth&&(r=Gg(r,n.tableId,{[n.visualColumnIndex]:t.columnWidth})),r=Im(r,"width",t.cellWidth),r=Im(r,"verticalAlign",t.cellVerticalAlign),r=Im(r,"textDirection",t.cellTextDirection),r=Im(r,"noWrap",t.cellNoWrap),r=Im(r,"fitText",t.cellFitText),r=Im(r,"hideMark",t.cellHideMark),r=Im(r,"paddingTop",t.margins.top),r=Im(r,"paddingRight",t.margins.right),r=Im(r,"paddingBottom",t.margins.bottom),r=Im(r,"paddingLeft",t.margins.left),r=Im(r,"borderTop",t.borders.top),r=Im(r,"borderRight",t.borders.right),r=Im(r,"borderBottom",t.borders.bottom),r=Im(r,"borderLeft",t.borders.left),r=Im(r,"borderStart",t.borders.start),r=Im(r,"borderEnd",t.borders.end),r=Im(r,"borderTopLeftToBottomRight",t.borders.topLeftToBottomRight),r=Im(r,"borderTopRightToBottomLeft",t.borders.topRightToBottomLeft),r=Im(r,"shading",t.shading),r}(e,n),{mergeKey:yf}),e.focusInput())}}}function Tm(e){return function(e){const t=e.t,n=e.clipboardActions??kp({...e,onIssue:t=>e.logger.warn("contextMenu:clipboard:not-completed",{issue:t})}),r=n.copy,o=n.cut,a=()=>n.paste("rich"),i=()=>{const n=!ri(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:()=>{o()}},{id:"copy",label:t("contextmenu.copy"),icon:"copy",shortcut:"Ctrl+C",disabled:!n,testId:"editor-context-menu-copy",onSelect:()=>{r()}},{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:r,programmaticCut:o,programmaticPaste:a}}(e)}function Pm(e){const{state:t,tableOps:n,applyTableContextCommand:r}=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:()=>r(e=>n.mergeSelectedTable(e),Sf),split:()=>r(e=>n.splitSelectedTable(e),Cf),insertColumnBefore:()=>r(e=>n.insertSelectedTableColumn(e,-1),kf),insertColumnAfter:()=>r(e=>n.insertSelectedTableColumn(e,1),kf),deleteColumn:()=>r(e=>n.deleteSelectedTableColumn(e),Tf),insertRowBefore:()=>r(e=>n.insertSelectedTableRow(e,-1),Pf),insertRowAfter:()=>r(e=>n.insertSelectedTableRow(e,1),Pf),deleteRow:()=>r(e=>n.deleteSelectedTableRow(e),Rf)}}function Rm(e){return function(e){const{computeFontFamilyOptions:t,computeFontSizeOptions:n,loadLocalFontFamilyOptions:r}=Xp({state:e.state,toolbarStyleState:e.toolbarStyleState}),o=function(e){return{openFontDialog:()=>{var t;e.loadLocalFontFamilyOptions(),e.setFontDialog({isOpen:!0,initial:(t=e.toolbarStyleState(),{fontFamily:t.fontFamily??"",fontSize:ut(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()||(ri(e.selection())||(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(e=>{let r=e;t.fontFamily!==(n.fontFamily||null)&&(r=dp(r,"fontFamily",t.fontFamily)),t.fontSize!==(n.fontSize?Number(n.fontSize):null)&&(r=dp(r,"fontSize",er(t.fontSize)));const o="automatic"===n.colorMode?null:n.color||null;t.color!==o&&(r=dp(r,"color",t.color)),(t.highlight??"")!==(n.highlight??"")&&(r=dp(r,"highlight",t.highlight)),(t.shading??"")!==(n.shading??"")&&(r=dp(r,"shading",t.shading)),t.bold!==Boolean(n.bold)&&(r=cp(r,"bold")),t.italic!==Boolean(n.italic)&&(r=cp(r,"italic"));const a=n.underline?n.underlineStyle??"single":null;(t.underlineStyle??null)!==(a??null)&&(r=dp(r,"underlineStyle",t.underlineStyle));const i=n.underline&&n.underlineColor||null;(t.underlineColor??null)!==(i??null)&&(r=dp(r,"underlineColor",t.underlineColor)),t.underline!==Boolean(n.underline)&&(r=cp(r,"underline")),t.strike!==Boolean(n.strike)&&(r=cp(r,"strike")),t.doubleStrike!==Boolean(n.doubleStrike)&&(r=cp(r,"doubleStrike")),t.superscript!==Boolean(n.superscript)&&(r=cp(r,"superscript")),t.subscript!==Boolean(n.subscript)&&(r=cp(r,"subscript")),t.superscript&&t.subscript&&(r=cp(r,"subscript")),t.strike&&t.doubleStrike&&(r=cp(r,"doubleStrike")),t.smallCaps!==Boolean(n.smallCaps)&&(r=cp(r,"smallCaps")),t.allCaps!==Boolean(n.allCaps)&&(r=cp(r,"allCaps")),t.hidden!==Boolean(n.hidden)&&(r=cp(r,"hidden"));const s=n.characterScale?Number(n.characterScale):null;(t.characterScale??null)!==(s??null)&&(r=dp(r,"characterScale",t.characterScale));const l=n.characterSpacing?Number(n.characterSpacing):null;(t.characterSpacing??null)!==(l??null)&&(r=dp(r,"characterSpacing",t.characterSpacing));const c=n.baselineShift?Number(n.baselineShift):null;(t.baselineShift??null)!==(c??null)&&(r=dp(r,"baselineShift",t.baselineShift));const d=n.kerningThreshold?Number(n.kerningThreshold):null;(t.kerningThreshold??null)!==(d??null)&&(r=dp(r,"kerningThreshold",t.kerningThreshold)),(t.ligatures??null)!==(n.ligatures||null)&&(r=dp(r,"ligatures",t.ligatures)),(t.numberSpacing??null)!==(n.numberSpacing||null)&&(r=dp(r,"numberSpacing",t.numberSpacing)),(t.numberForm??null)!==(n.numberForm||null)&&(r=dp(r,"numberForm",t.numberForm));const u=n.stylisticSet?Number(n.stylisticSet):null;return(t.stylisticSet??null)!==(u??null)&&(r=dp(r,"stylisticSet",t.stylisticSet)),t.contextualAlternates!==Boolean(n.contextualAlternates)&&(r=cp(r,"contextualAlternates")),r},{mergeKey:xf})),e.focusInput())}}}({toolbarStyleState:e.toolbarStyleState,selection:e.selection,isReadOnly:e.isReadOnly,loadLocalFontFamilyOptions:r,setFontDialog:e.setFontDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),a=o.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(Wn,e)),void e.focusInput();const r=e=>{if(""===e.trim())return null;const t=Number(e);return Number.isFinite(t)?t:null};e.applyTransactionalState(e=>{let o=e;t.align!==(n.align||null)&&(o=ce(o,"align",t.align)),t.indentLeft!==r(n.indentLeft)&&(o=ce(o,"indentLeft",t.indentLeft)),t.indentRight!==r(n.indentRight)&&(o=ce(o,"indentRight",t.indentRight)),t.indentFirstLine!==r(n.indentFirstLine)&&(o=ce(o,"indentFirstLine",t.indentFirstLine)),t.indentHanging!==r(n.indentHanging)&&(o=ce(o,"indentHanging",t.indentHanging)),t.spacingBefore!==r(n.spacingBefore)&&(o=ce(o,"spacingBefore",t.spacingBefore)),t.spacingAfter!==r(n.spacingAfter)&&(o=ce(o,"spacingAfter",t.spacingAfter)),t.lineHeight!==r(n.lineHeight)&&(o=ce(o,"lineHeight",t.lineHeight));const a=n.lineRule||null;t.lineRule!==a&&(o=ce(o,"lineRule",t.lineRule)),t.shading!==(n.shading||null)&&(o=ce(o,"shading",t.shading)),t.mirrorIndents!==(n.mirrorIndents??!1)&&(o=ce(o,"mirrorIndents",t.mirrorIndents)),t.contextualSpacing!==(n.contextualSpacing??!1)&&(o=ce(o,"contextualSpacing",t.contextualSpacing));const i=""===n.outlineLevel.trim()?null:Number(n.outlineLevel);t.outlineLevel!==i&&(o=ce(o,"outlineLevel",t.outlineLevel)),t.pageBreakBefore!==(n.pageBreakBefore??!1)&&(o=ce(o,"pageBreakBefore",t.pageBreakBefore)),t.keepWithNext!==(n.keepWithNext??!1)&&(o=ce(o,"keepWithNext",t.keepWithNext)),t.keepLinesTogether!==(n.keepLinesTogether??!1)&&(o=ce(o,"keepLinesTogether",t.keepLinesTogether)),t.widowControl!==(n.widowControl??!0)&&(o=ce(o,"widowControl",t.widowControl)),t.tabChanges?.length?o=t.tabChanges.reduce(Wn,o):JSON.stringify(t.tabs)!==JSON.stringify(n.tabs??[])&&(o=ce(o,"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])&&(o=ce(o,t,c[t]));return o},{mergeKey:vf}),e.focusInput()},setParagraphDialogDefault:t=>{e.isReadOnly()||(e.resetTransactionGrouping(),e.applyTransactionalState(e=>{const n=e.document.styles,r=io(n);if(!r||!n?.[r])return e;const o=n[r];return{...e,document:{...e.document,styles:{...n,[r]:{...o,paragraphStyle:vg(o.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=km({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=Tm({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:Pm({state:e.state,tableOps:e.tableOps,isInsideTable:l.isInsideTable,openTablePropertiesDialog:c,applyTableContextCommand:d})});return{computeFontFamilyOptions:t,computeFontSizeOptions:n,applyFontDialogValues:o.applyFontDialogValues,applyParagraphDialogValues:i.applyParagraphDialogValues,setParagraphDialogDefault:i.setParagraphDialogDefault,applyTablePropertiesDialogValues:l.applyTablePropertiesDialogValues,buildContextMenuItems:u.buildContextMenuItems,handleEditorContextMenu:u.handleEditorContextMenu,closeContextMenu:u.closeContextMenu}}(e)}function Mm(e){const t=pr(()=>{const t=e.targetPos(),n=e.surfaceRef;if(!n)return null;const r=e.snapshotProvider.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()});let o=0,a=0,i=28;if(r){const n=xi(e.state).find(e=>e.id===t.paragraphId),o=n?To(n,t):0,a=Je(r,t,o);if(a)return{viewportLeft:a.left,viewportTop:a.top,height:Math.min(a.height||28,32)};const i=rt(r,t.paragraphId,"end");if(i)return{viewportLeft:i.left,viewportTop:i.top,height:i.height||28}}const s=e.caretViewport?.()??null;if(s)return o=s.left,a=s.top,i=Math.max(12,Math.min(36,s.height)),{viewportLeft:o,viewportTop:a,height:i};const l=e.pointerPos?.()??null;return l?(o=l.x,a=l.y-12,i=24,{viewportLeft:o,viewportTop:a,height:i}):{viewportLeft:o,viewportTop:a,height:i}});return St(En,{get when(){return t()},children:e=>St(kt,{active:!0,fixed:!0,get left(){return e().viewportLeft},get top(){return e().viewportTop},get height(){return e().height}})})}var Am=/*#__PURE__*/Gn("<div class=oasis-editor-table-resize-guide>"),Om=/*#__PURE__*/Gn("<div class=oasis-editor-table-resize-outline>"),Bm=/*#__PURE__*/Gn("<img class=oasis-editor-image-ghost>"),Fm=/*#__PURE__*/Gn("<div class=oasis-editor-table-ghost>");function Em(e){return[St(En,{get when(){return e.tableResize.resizing()},children:e=>{return t=Am(),Mt(n=>{var r=!("column"!==e().type),o=!("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 r!==n.e&&t.classList.toggle("oasis-editor-table-resize-guide-column",n.e=r),o!==n.t&&t.classList.toggle("oasis-editor-table-resize-guide-row",n.t=o),n.a=Rn(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t;var t}}),St(En,{get when(){return e.tableCornerResize.previewRect()},children:e=>{return t=Om(),Mt(n=>{var r=`${e().left}px`,o=`${e().top}px`,a=`${e().width}px`,i=`${e().height}px`;return r!==n.e&&Ft(t,"left",n.e=r),o!==n.t&&Ft(t,"top",n.t=o),a!==n.a&&Ft(t,"width",n.a=a),i!==n.o&&Ft(t,"height",n.o=i),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),St(En,{get when(){return tt(()=>!!e.imageOps.dragging())()&&e.imageOps.draggedImageInfo()},children:t=>{return r=Bm(),Mt(o=>{var a=t().src,i=`${t().width}px`,s=`${t().height}px`,l=e.imageOps.mousePos().x-t().offsetX+"px",c=e.imageOps.mousePos().y-t().offsetY+"px";return a!==o.e&&n(r,"src",o.e=a),i!==o.t&&Ft(r,"width",o.t=i),s!==o.a&&Ft(r,"height",o.a=s),l!==o.o&&Ft(r,"left",o.o=l),c!==o.i&&Ft(r,"top",o.i=c),o},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r;var r}}),St(En,{get when(){return tt(()=>!!e.tableDrag.dragging())()&&e.tableDrag.draggedTableInfo()},children:t=>{return n=Fm(),Mt(r=>{var o=`${t().width}px`,a=`${t().height}px`,i=e.tableDrag.mousePos().x-t().offsetX+"px",s=e.tableDrag.mousePos().y-t().offsetY+"px";return o!==r.e&&Ft(n,"width",r.e=o),a!==r.t&&Ft(n,"height",r.t=a),i!==r.a&&Ft(n,"left",r.a=i),s!==r.o&&Ft(n,"top",r.o=s),r},{e:void 0,t:void 0,a:void 0,o:void 0}),n;var n}}),St(En,{get when(){return tt(()=>!!e.tableDrag.dragging())()&&e.tableDrag.dropTargetPos()},children:t=>St(Mm,{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})}),St(En,{get when(){return tt(()=>!!e.imageOps.dragging())()&&e.imageOps.dropTargetPos()},children:t=>St(Mm,{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})}),St(En,{get when(){return tt(()=>!!e.textDrag.dragging())()&&e.textDrag.dropTargetPos()},children:t=>St(Mm,{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 Dm(e){return[St(rr,{variant:"secondary",get onClick(){return e.onCancel},get"data-testid"(){return e.cancelTestId},get children(){return e.cancelLabel}}),St(rr,{variant:"primary",get onClick(){return e.onConfirm},get"data-testid"(){return e.confirmTestId},get children(){return e.confirmLabel}})]}function Lm(e){const t=E(),[n,r]=$t(e.initialValue);let o;bn(()=>{e.isOpen&&(r(e.initialValue),setTimeout(()=>o?.focus(),50))});const a=()=>{e.onConfirm(n()),e.onClose()};return St(le,{get isOpen(){return e.isOpen},get title(){return e.title},get onClose(){return e.onClose},get footer(){return St(Dm,{get onCancel(){return e.onClose},onConfirm:a,get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return e.confirmLabel},get cancelTestId(){return e.testIds?.cancel},get confirmTestId(){return e.testIds?.confirm}})},get children(){return St(R,{ref(e){"function"==typeof o?o(e):o=e},get label(){return e.label},get value(){return n()},onChange:r,onKeyDown:e=>"Enter"===e.key&&a(),get placeholder(){return e.placeholder},get"data-testid"(){return e.testIds?.input}})}})}function Nm(e){const t=E();return St(Lm,{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 zm(e){const t=E();return St(Lm,{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 $m(e){const t=E();return St(Lm,{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__*/Gn("<div class=oasis-editor-comment-composer-parent data-testid=comment-reply-context>"),jm=/*#__PURE__*/Gn("<div class=oasis-editor-comment-composer>");function Wm(e){const t=E(),[n,r]=$t(""),[o,a]=$t("");let i;const s=e.composer.draft,l=()=>("edit"===s()?.mode||n().trim().length>0)&&o().trim().length>0,c=()=>{l()&&e.composer.submit(n(),o())};return bn(()=>{s()&&(r("edit"===s()?.mode?s()?.commentAuthor??"":e.composer.authorName()),a("edit"===s()?.mode?s()?.commentText??"":""),queueMicrotask(()=>i?.focus()))}),St(le,{get isOpen(){return null!==s()},get title(){return t("edit"===s()?.mode?"toolbar.editComment":"reply"===s()?.mode?"toolbar.replyComment":"toolbar.newComment")},get onClose(){return e.composer.close},get footer(){return[St(rr,{get onClick(){return e.composer.close},"data-testid":"comment-composer-cancel",get children(){return t("generic.cancel")}}),St(rr,{variant:"primary",get disabled(){return!l()},onClick:c,"data-testid":"comment-composer-submit",get children(){return t("generic.save")}})]},get children(){var l=jm();return _e(l,St(En,{get when(){return"reply"===s()?.mode},get children(){var e=Hm();return _e(e,St(Mn,{as:"strong",get children(){return[tt(()=>t("comment.replyTo"))," ",tt(()=>s()?.parentAuthor)]}}),null),_e(e,St(Mn,{as:"p",get children(){return s()?.parentText}}),null),e}}),null),_e(l,St(R,{get label(){return t("comment.author")},get value(){return n()},onChange:r,maxLength:150,required:!0,get disabled(){return"edit"===s()?.mode||e.composer.authorLocked()},"data-testid":"comment-composer-author"}),null),_e(l,St(Fe,{ref(e){"function"==typeof i?i(e):i=e},get label(){return t("comment.body")},controlClass:"oasis-editor-comment-composer-textarea",get value(){return o()},onChange:a,onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),c())},rows:5,maxLength:2e4,get placeholder(){return t("comment.placeholder")},"data-testid":"comment-composer-body"}),null),l}})}var Um=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],Vm=[33,50,66,75,90,100,105,110,115,120,150,200];function _m(e){const t=Number(e.trim());return Number.isFinite(t)&&t>0?t:null}function Km(e){const t=Number(e.trim());return Number.isFinite(t)&&t>=0?t:null}function qm(e){return null==e||""===e?"":String(e)}function Xm(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"expanded":"condensed":"normal"}function Gm(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"raised":"lowered":"normal"}function Ym(e){if(!e.trim())return null;const t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:null}function Zm(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 Jm(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 Qm(e,t){const n=[],r=Ym(e);return null!==r&&n.push(`"ss${String(r).padStart(2,"0")}" 1`),t&&n.push('"calt" 1'),n.join(", ")||void 0}function eh(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 th(e){return{characterScale:qm(e.characterScale),spacingMode:Xm(e.characterSpacing),spacingAmount:e.characterSpacing?String(Math.abs(Number(e.characterSpacing))):"",positionMode:Gm(e.baselineShift),positionAmount:e.baselineShift?String(Math.abs(Number(e.baselineShift))):"",kerningEnabled:""!==e.kerningThreshold,kerningThreshold:qm(e.kerningThreshold),ligatures:e.ligatures,numberSpacing:e.numberSpacing,numberForm:e.numberForm,stylisticSet:qm(e.stylisticSet),contextualAlternates:Boolean(e.contextualAlternates)}}function nh(e){const t=E(),[n,r]=$t("font"),[o,a]=$t(eh(e.initial)),[i,s]=$t(th(e.initial));bn(()=>{e.isOpen&&(r("font"),a(eh(e.initial)),s(th(e.initial)))});const l=pr(()=>{return e=o().bold,t=o().italic,e&&t?"boldItalic":e?"bold":t?"italic":"regular";var e,t}),c=pr(()=>{const t=o().familyFilter.trim().toLowerCase();return t?e.familyOptions.filter(e=>e.toLowerCase().includes(t)):e.familyOptions}),d=pr(()=>{const t=new Set(Um);for(const r of e.sizeOptions)t.add(r);const n=Number(o().fontSize);return Number.isFinite(n)&&n>0&&t.add(n),Array.from(t).sort((e,t)=>e-t)}),u=pr(()=>{const e=o().fontSize.trim();if(!e)return"";const n=Number(e);return Number.isFinite(n)&&n>0?"":t("dialog.font.sizeInvalid")}),p=pr(()=>{const e=i();return e.characterScale.trim()&&null===_m(e.characterScale)?t("dialog.font.advancedScaleInvalid"):"normal"!==e.spacingMode&&null===Km(e.spacingAmount)||"normal"!==e.positionMode&&null===Km(e.positionAmount)?t("dialog.font.advancedAmountInvalid"):e.kerningThreshold.trim()&&null===Km(e.kerningThreshold)?t("dialog.font.advancedKerningInvalid"):e.stylisticSet.trim()&&null===Ym(e.stylisticSet)?t("dialog.font.advancedStylisticSetInvalid"):""}),f=pr(()=>function(e,t){const n=Number(e.fontSize),r=_m(t.characterScale)??100,o="normal"===t.spacingMode?null:Km(t.spacingAmount),a="normal"===t.positionMode?null:Km(t.positionAmount),i=null===o?void 0:"condensed"===t.spacingMode?`-${o}pt`:`${o}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":`${r}%`,"letter-spacing":i,"font-variant-ligatures":Zm(t.ligatures),"font-variant-numeric":Jm(t.numberSpacing,t.numberForm),"font-feature-settings":Qm(t.stylisticSet,t.contextualAlternates)}}(o(),i()));return{activeTab:n,setActiveTab:e=>r(e),fontTabValues:o,setFontTabValues:a,advancedTabValues:i,setAdvancedTabValues:s,updateFontTab:(e,t)=>{a(n=>({...n,[e]:t}))},updateAdvancedTab:(e,t)=>{s(n=>({...n,[e]:t}))},selectedFontStyle:l,visibleFamilyOptions:c,effectiveSizeOptions:d,customSizeError:u,advancedValidationError:p,previewStyle:f,applyFontStylePreset:e=>{a(t=>({...t,bold:"bold"===e||"boldItalic"===e,italic:"italic"===e||"boldItalic"===e}))},handleApply:()=>{if(p())return;const t=function(e,t){const n=Number(e.fontSize),r=Number.isFinite(n)&&n>0,o="none"===e.underlineStyle?null:e.underlineStyle,a=null!==o,i=t.characterScale.trim()?_m(t.characterScale):null,s="normal"===t.spacingMode?null:Km(t.spacingAmount),l="normal"===t.positionMode?null:Km(t.positionAmount),c=t.kerningEnabled&&t.kerningThreshold.trim()?Km(t.kerningThreshold):null,d=Ym(t.stylisticSet);return{fontFamily:e.fontFamily.trim()?e.fontFamily.trim():null,fontSize:r?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:o,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}}(o(),i());e.onApply(t,e.initial),e.onClose()}}}var rh=/*#__PURE__*/Gn("<div>");function oh(e){const t=E();return r=rh(),_e(r,()=>t("dialog.font.previewText")),Mt(t=>{var o=e.class??"oasis-editor-dialog-preview",a=e.testId,i=e.style;return o!==t.e&&V(r,t.e=o),a!==t.t&&n(r,"data-testid",t.t=a),t.a=Rn(r,i,t.a),t},{e:void 0,t:void 0,a:void 0}),r;var r}var ah=/*#__PURE__*/Gn('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel">');function ih(e){const t=E(),{ctrl:n}=e;return r=ah(),_e(r,St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:12,get children(){return St(R,{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"})}}),St(fe,{size:{xs:12,md:8},get children(){return St(Re,{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}))]}})}}),St(fe,{size:{xs:12,md:4},get children(){return St(Re,{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)}))]}})}}),St(fe,{size:{xs:12,md:4},get children(){return[St(R,{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"}),St(d,{class:"oasis-editor-dialog-help-text",get children(){return n.customSizeError()}})]}}),St(fe,{size:{xs:12,md:8},get children(){return St(Re,{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),_e(r,St(fe,{container:!0,spacing:1.5,class:"oasis-editor-font-dialog-color-row",get children(){return[St(fe,{size:{xs:12,md:4},get children(){return St(Re,{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")}]}})}}),St(fe,{size:{xs:12,md:4},get children(){return St(kr,{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"})}}),St(fe,{size:{xs:12,md:2},get children(){return St(kr,{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"})}}),St(fe,{size:{xs:12,md:2},get children(){return St(kr,{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),_e(r,St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:8},get children(){return St(Re,{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")},...Pt.map(e=>({value:e.value,label:t(e.labelKey)}))]}})}}),St(fe,{size:{xs:12,md:4},get children(){return St(kr,{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),_e(r,St(S,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("dialog.font.style")},get children(){return St(mn,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return St(pt,{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=>St(dt,{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),_e(r,St(S,{get label(){return t("dialog.font.preview")},get children(){return St(oh,{testId:"editor-font-dialog-preview",get style(){return n.previewStyle()}})}}),null),r;var r}var sh=/*#__PURE__*/Gn("<div class=oasis-editor-font-dialog-kerning-line>"),lh=/*#__PURE__*/Gn('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel">');function ch(e){const t=E(),{ctrl:n}=e;return r=lh(),_e(r,St(xr,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedCharacterSpacingGroup")},get children(){return St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:4},get children(){return St(Re,{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 Vm.map(e=>({value:String(e),label:`${e}%`}))}})}}),St(fe,{size:{xs:12,md:8},get children(){return St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:8},get children(){return St(Re,{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")}]}})}}),St(fe,{size:{xs:12,md:4},get children(){return St(R,{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"})}})]}})}}),St(fe,{size:{xs:12,md:8},get children(){return St(Re,{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")}]}})}}),St(fe,{size:{xs:12,md:4},get children(){return St(R,{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"})}}),St(fe,{size:12,get children(){var e=sh();return _e(e,St(y,{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),_e(e,St(R,{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),_e(e,St(d,{class:"oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix",get children(){return t("dialog.font.advancedKerningAbove")}}),null),e}})]}})}}),null),_e(r,St(xr,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedOpenTypeGroup")},get children(){return[St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:6},get children(){return St(Re,{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")}]}})}}),St(fe,{size:{xs:12,md:6},get children(){return St(Re,{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")}]}})}}),St(fe,{size:{xs:12,md:6},get children(){return St(Re,{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")}]}})}}),St(fe,{size:{xs:12,md:6},get children(){return St(Re,{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)}))]}})}})]}}),St(y,{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),_e(r,St(xr,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedPreviewGroup")},get children(){return St(oh,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return n.previewStyle()}})}}),null),_e(r,St(d,{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),r;var r}function dh(e){const t=E(),n=nh(e);return St(le,{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 St(Dm,{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 St(oe,{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:St(ih,{ctrl:n})},{id:"advanced",label:t("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:St(ch,{ctrl:n})}]}})}})}var uh=/*#__PURE__*/Gn("<div class=oasis-editor-word-tabs-fields><div><div class=oasis-editor-word-tabs-list role=group>"),ph=/*#__PURE__*/Gn("<div class=oasis-editor-word-tabs-fields>"),fh=/*#__PURE__*/Gn("<div class=oasis-editor-word-tabs-actions>"),gh=(e,t)=>Math.abs(e-t)<jt,mh=e=>null!==e&&Number.isFinite(e)&&Math.abs(e)<=1584;function hh(e){const t=E(),[r,o]=$t([]),[a,i]=$t([]),[s,l]=$t(null),[c,u]=$t("left"),[p,f]=$t("none"),[g,m]=$t(36),[h,b]=$t(36),y=e=>{l(e.position),"clear"!==e.type&&u(e.type),f(e.leader??"none")};bn(()=>{if(!e.isOpen)return;const t=e.initial.filter(e=>"clear"!==e.type).map(e=>({...e})).sort((e,t)=>e.position-t.position);o(t),i([]);const n=e.initialDefault??36;m(n),b(n),l(null),u("left"),f("none");const r=t.find(t=>void 0!==e.selectedPosition&&gh(t.position,e.selectedPosition));r&&y(r)});const v=()=>r().find(e=>null!==s()&&gh(e.position,s())),x=()=>{const e=g();return null!==e&&Number.isFinite(e)&&e>=1&&e<=1584},w=()=>mh(s())&&(Boolean(v())||r().length<64),I=()=>{const e=s();if(!mh(e)||!w())return;const t={position:e,type:c(),..."bar"!==c()&&"none"!==p()?{leader:p()}:{}};o(n=>[...n.filter(t=>!gh(t.position,e)),t].sort((e,t)=>e.position-t.position)),i(e=>[...e,{set:[t]}])},S=()=>{const e=s();mh(e)&&v()&&(o(t=>t.filter(t=>!gh(t.position,e))),i(t=>[...t,{clear:[e]}]),l(null))},C=()=>{o([]),l(null),i(e=>[...e,{clearAll:!0}])},k=()=>{if(!x())return;const t=[...a()];g()!==h()&&t.push({default:g()}),e.onApply(r().map(e=>({...e})),t),e.onClose()};return St(le,{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[St(rr,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-tab-stops-cancel",get children(){return t("generic.cancel")}}),St(rr,{variant:"primary",get disabled(){return!x()},onClick:k,"data-testid":"editor-tab-stops-apply",get children(){return t("generic.apply")}})]},get children(){return[(a=uh(),i=a.firstChild,h=i.firstChild,_e(i,St(Ar,{get label(){return t("paragraph.tabsPosition")},step:"0.05",min:-At,max:At,get value(){return s()??""},onChange:l,"data-testid":"editor-tab-stops-position",get error(){return tt(()=>!(null===s()||mh(s())))()?t("paragraph.tabsInvalidPosition"):void 0}}),h),_e(h,St(pt,{get each(){return r()},get fallback(){return St(d,{as:"p",get children(){return t("paragraph.tabsEmpty")}})},children:e=>St(rr,{variant:"ghost",class:"oasis-editor-word-tabs-option",get"aria-pressed"(){return tt(()=>null!==s())()&&gh(s(),e.position)},onClick:()=>y(e),"data-testid":"editor-tab-stops-option",get children(){return[tt(()=>Number(e.position.toFixed(2)))," pt"]}})})),_e(a,St(Ar,{get label(){return t("paragraph.tabsDefaultInterval")},step:"0.05",min:"1",max:At,get value(){return g()??""},onChange:m,"data-testid":"editor-tab-stops-default",get error(){return tt(()=>!x())()?t("paragraph.tabsInvalidInterval"):void 0}}),null),Mt(()=>n(h,"aria-label",t("paragraph.tabsDefined"))),a),(o=ph(),_e(o,St(wt,{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=>u(e)}),null),_e(o,St(wt,{get label(){return t("paragraph.tabsLeader")},get value(){return tt(()=>"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=>f(e)}),null),o),(e=fh(),_e(e,St(rr,{get disabled(){return!w()},onClick:I,"data-testid":"editor-tab-stops-set",get children(){return t("paragraph.tabsSet")}}),null),_e(e,St(rr,{get disabled(){return!v()},onClick:S,"data-testid":"editor-tab-stops-remove",get children(){return t("paragraph.tabsClear")}}),null),_e(e,St(rr,{onClick:C,"data-testid":"editor-tab-stops-clear",get children(){return t("paragraph.tabsClearAll")}}),null),e),St(d,{as:"p",get children(){return t("paragraph.tabsDraftHelp")}})];var e,o,a,i,h}})}var bh=96/72;function yh(e){const[t,n]=$t(""),[r,o]=$t(""),[a,i]=$t(null),[s,l]=$t(null),[c,d]=$t("none"),[u,p]=$t(null),[f,g]=$t(!1),[m,h]=$t(null),[b,y]=$t(null),[v,x]=$t("multiple"),[w,I]=$t(null),[S,C]=$t(!1),[k,T]=$t(""),[P,R]=$t("none"),[M,A]=$t(null),[O,B]=$t(""),[F,E]=$t(!1),[D,L]=$t(!1),[N,z]=$t(!1),[$,H]=$t(!1),[j,W]=$t(!1),[U,V]=$t(!1),[_,K]=$t(!1),[q,X]=$t(!0),[G,Y]=$t([]),[Z,J]=$t([]),[Q,ee]=$t(36);bn(()=>{if(e.isOpen){n(e.initial.align??""),o(e.initial.outlineLevel??""),i(ar(e.initial.indentLeft??"")),l(ar(e.initial.indentRight??"")),g(e.initial.mirrorIndents??!1),h(ar(e.initial.spacingBefore??"")),y(ar(e.initial.spacingAfter??"")),C(e.initial.contextualSpacing??!1),T(e.initial.shading??"");const{mode:a,at:s}=(t=e.initial.lineRule??"",r=ar(e.initial.lineHeight??""),"exact"===t||"atLeast"===t?{mode:t,at:null!==r?Math.round(r/bh):null}:null===r?{mode:"multiple",at:null}:1===r?{mode:"single",at:null}:1.5===r?{mode:"onePointFive",at:null}:2===r?{mode:"double",at:null}:{mode:"multiple",at:r});x(a),I(s);const c=e.initial.borderStyle;R("solid"===c||"dashed"===c||"dotted"===c?c:"none"),A(ar(e.initial.borderWidth??"")),B(e.initial.borderColor??""),E(e.initial.borderSideTop??!1),L(e.initial.borderSideRight??!1),z(e.initial.borderSideBottom??!1),H(e.initial.borderSideLeft??!1),W(e.initial.pageBreakBefore??!1),V(e.initial.keepWithNext??!1),K(e.initial.keepLinesTogether??!1),X(e.initial.widowControl??!0),Y(e.initial.tabs??[]),J([]),ee(e.initial.defaultTabStop??36);const u=ar(e.initial.indentFirstLine??""),f=ar(e.initial.indentHanging??"");null!==f&&f>0?(d("hanging"),p(f)):null!==u&&u>0?(d("firstLine"),p(u)):(d("none"),p(null))}var t,r});const te=()=>{switch(v()){case"single":return{lineHeight:1,lineRule:null};case"onePointFive":return{lineHeight:1.5,lineRule:null};case"double":return{lineHeight:2,lineRule:null};case"multiple":return{lineHeight:w(),lineRule:null};case"atLeast":return{lineHeight:null!==w()?w()*bh:null,lineRule:"atLeast"};case"exact":return{lineHeight:null!==w()?w()*bh:null,lineRule:"exact"}}},ne=pr(()=>{const e=a(),n=s(),r="firstLine"===c()?u():null,o="hanging"===c()?u():null,i=null!==r?r:null!==o?-o:null,l="none"!==P()?`${M()??.5}pt ${P()} ${O().trim()||"#000000"}`:void 0,{lineHeight:d,lineRule:p}=te(),f=null===d?void 0:"exact"===p||"atLeast"===p?`${d}px`:String(d);return{"text-align":t()||void 0,"line-height":f,"padding-left":null!==e?`${e+(o??0)}pt`:void 0,"padding-right":null!==n?`${n}pt`:void 0,"text-indent":null!==i?`${i}pt`:void 0,"background-color":k().trim()||void 0,"border-top":l&&F()?l:void 0,"border-right":l&&D()?l:void 0,"border-bottom":l&&N()?l:void 0,"border-left":l&&$()?l:void 0}}),re=()=>{const e=P();if("none"===e)return{top:null,right:null,bottom:null,left:null};const t=M(),n={type:e,width:null!==t&&t>0?t:.5,color:O().trim()||"#000000"};return{top:F()?n:null,right:D()?n:null,bottom:N()?n:null,left:$()?n:null}},oe=()=>{const e=u(),{lineHeight:n,lineRule:o}=te(),i=r();return{align:t()||null,indentLeft:a(),indentRight:s(),indentFirstLine:"firstLine"===c()?e:null,indentHanging:"hanging"===c()?e:null,mirrorIndents:f(),spacingBefore:m(),spacingAfter:b(),lineHeight:n,lineRule:o,contextualSpacing:S(),outlineLevel:""===i?null:Number(i),shading:k().trim()||null,borders:re(),pageBreakBefore:j(),keepWithNext:U(),keepLinesTogether:_(),widowControl:q(),tabs:G(),...Z().length?{tabChanges:Z()}:{}}};return{align:t,setAlign:n,outlineLevel:r,setOutlineLevel:o,indentLeft:a,setIndentLeft:i,indentRight:s,setIndentRight:l,special:c,setSpecial:d,specialBy:u,setSpecialBy:p,mirrorIndents:f,setMirrorIndents:g,spacingBefore:m,setSpacingBefore:h,spacingAfter:b,setSpacingAfter:y,lineMode:v,setLineMode:x,lineAt:w,setLineAt:I,contextualSpacing:S,setContextualSpacing:C,shading:k,setShading:T,borderStyle:P,setBorderStyle:R,borderWidth:M,setBorderWidth:A,borderColor:O,setBorderColor:B,sideTop:F,setSideTop:E,sideRight:D,setSideRight:L,sideBottom:N,setSideBottom:z,sideLeft:$,setSideLeft:H,pageBreakBefore:j,setPageBreakBefore:W,keepWithNext:U,setKeepWithNext:V,keepLinesTogether:_,setKeepLinesTogether:K,widowControl:q,setWidowControl:X,tabs:G,setTabs:Y,defaultTabStop:Q,setDefaultTabStop:ee,setTabChanges:J,atEnabled:()=>"multiple"===v()||"atLeast"===v()||"exact"===v(),previewStyle:ne,handleApply:()=>{e.onApply(oe(),e.initial),e.onClose()},handleSetDefault:()=>{e.onSetDefault?.(oe()),e.onClose()}}}var vh=/*#__PURE__*/Gn("<div class=oasis-editor-paragraph-dialog-panel>"),xh=/*#__PURE__*/Gn("<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>"),wh=/*#__PURE__*/Gn("<div>"),Ih=/*#__PURE__*/Gn("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function Sh(e){const t=E(),[n,r]=$t(!1),{align:o,setAlign:a,outlineLevel:i,setOutlineLevel:s,indentLeft:l,setIndentLeft:c,indentRight:d,setIndentRight:u,special:p,setSpecial:f,specialBy:g,setSpecialBy:m,mirrorIndents:h,setMirrorIndents:b,spacingBefore:v,setSpacingBefore:x,spacingAfter:w,setSpacingAfter:I,lineMode:C,setLineMode:k,lineAt:T,setLineAt:P,contextualSpacing:R,setContextualSpacing:M,shading:A,setShading:O,borderStyle:B,setBorderStyle:F,borderWidth:D,setBorderWidth:L,borderColor:N,setBorderColor:z,sideTop:$,setSideTop:H,sideRight:j,setSideRight:W,sideBottom:U,setSideBottom:V,sideLeft:_,setSideLeft:K,pageBreakBefore:q,setPageBreakBefore:X,keepWithNext:G,setKeepWithNext:Y,keepLinesTogether:Z,setKeepLinesTogether:J,widowControl:Q,setWidowControl:ee,tabs:te,setTabs:ne,defaultTabStop:re,setDefaultTabStop:ae,setTabChanges:ie,atEnabled:se,previewStyle:ce,handleApply:de,handleSetDefault:ue}=yh(e),pe=St(Re,{get label(){return t("paragraph.alignLabel")},get value(){return o()},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")}]}}),ge=St(Re,{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])}))]}}),me=(he=vh(),_e(he,St(xr,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupGeneral")},get children(){return St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:6},children:pe}),St(fe,{size:{xs:12,md:6},children:ge})]}})}}),null),_e(he,St(xr,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupIndent")},get children(){return St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:6},get children(){return St(Ar,{get label(){return t("paragraph.indentLeftLabel")},step:"1",get value(){return l()??""},onChange:c,"data-testid":"editor-paragraph-dialog-indent-left"})}}),St(fe,{size:{xs:12,md:6},get children(){return St(Ar,{get label(){return t("paragraph.indentRightLabel")},step:"1",get value(){return d()??""},onChange:u,"data-testid":"editor-paragraph-dialog-indent-right"})}}),St(fe,{size:{xs:12,md:6},get children(){return St(Re,{get label(){return t("paragraph.specialLabel")},get value(){return p()},onChange:e=>{const t=e;f(t),"none"===t&&m(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")}]}})}}),St(fe,{size:{xs:12,md:6},get children(){return St(Ar,{get label(){return t("paragraph.specialByLabel")},min:"0",step:"1",get disabled(){return"none"===p()},get value(){return g()??""},onChange:m,"data-testid":"editor-paragraph-dialog-special-by"})}}),St(fe,{size:12,get children(){return St(y,{get label(){return t("paragraph.mirrorIndentsLabel")},get checked(){return h()},onChange:b,"data-testid":"editor-paragraph-dialog-mirror-indents"})}})]}})}}),null),_e(he,St(xr,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupSpacing")},get children(){return St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:4},get children(){return St(Ar,{get label(){return t("paragraph.spacingBeforeLabel")},min:"0",step:"1",get value(){return v()??""},onChange:x,"data-testid":"editor-paragraph-dialog-spacing-before"})}}),St(fe,{size:{xs:12,md:4},get children(){return St(Ar,{get label(){return t("paragraph.spacingAfterLabel")},min:"0",step:"1",get value(){return w()??""},onChange:I,"data-testid":"editor-paragraph-dialog-spacing-after"})}}),St(fe,{size:{xs:12,md:4}}),St(fe,{size:{xs:12,md:8},get children(){return St(Re,{get label(){return t("paragraph.lineSpacingLabel")},get value(){return C()},onChange:e=>{k(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")}]}})}}),St(fe,{size:{xs:12,md:4},get children(){return St(Ar,{get label(){return t("paragraph.lineSpacingAt")},min:"0",get step(){return"multiple"===C()?"0.05":"1"},get disabled(){return!se()},get value(){return T()??""},onChange:P,"data-testid":"editor-paragraph-dialog-line-at"})}}),St(fe,{size:12,get children(){return St(y,{get label(){return t("paragraph.contextualSpacingLabel")},get checked(){return R()},onChange:M,"data-testid":"editor-paragraph-dialog-contextual-spacing"})}})]}})}}),null),_e(he,St(xr,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupBorders")},get children(){return[St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:3},get children(){return St(Re,{get label(){return t("paragraph.borderStyleLabel")},get value(){return B()},onChange:e=>{const t=e;F(t),"none"===t?(H(!1),W(!1),V(!1),K(!1)):$()||j()||U()||_()||(H(!0),W(!0),V(!0),K(!0))},"data-testid":"editor-paragraph-dialog-border-style",get options(){return[{value:"none",label:t("paragraph.borderNone")},{value:"solid",label:t("paragraph.borderSolid")},{value:"dashed",label:t("paragraph.borderDashed")},{value:"dotted",label:t("paragraph.borderDotted")}]}})}}),St(fe,{size:{xs:12,md:3},get children(){return St(Ar,{get label(){return t("paragraph.borderWidthLabel")},min:"0",step:"0.25",get disabled(){return"none"===B()},get value(){return D()??""},onChange:L,"data-testid":"editor-paragraph-dialog-border-width"})}}),St(fe,{size:{xs:12,md:3},get children(){return St(kr,{get label(){return t("paragraph.borderColorLabel")},get disabled(){return"none"===B()},get value(){return N()||"#000000"},onChange:z,"data-testid":"editor-paragraph-dialog-border-color"})}}),St(fe,{size:{xs:12,md:3},get children(){return St(kr,{get label(){return t("paragraph.shadingLabel")},get value(){return A()||"#ffffff"},onChange:O,"data-testid":"editor-paragraph-dialog-shading"})}})]}}),St(S,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("paragraph.borderSidesLabel")},get children(){return St(mn,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[St(y,{get label(){return t("paragraph.borderSideTop")},get disabled(){return"none"===B()},get checked(){return $()},onChange:H,"data-testid":"editor-paragraph-dialog-border-side-top"}),St(y,{get label(){return t("paragraph.borderSideRight")},get disabled(){return"none"===B()},get checked(){return j()},onChange:W,"data-testid":"editor-paragraph-dialog-border-side-right"}),St(y,{get label(){return t("paragraph.borderSideBottom")},get disabled(){return"none"===B()},get checked(){return U()},onChange:V,"data-testid":"editor-paragraph-dialog-border-side-bottom"}),St(y,{get label(){return t("paragraph.borderSideLeft")},get disabled(){return"none"===B()},get checked(){return _()},onChange:K,"data-testid":"editor-paragraph-dialog-border-side-left"})]}})}})]}}),null),he);var he;const be=(ye=vh(),_e(ye,St(xr,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupPagination")},get children(){return St(mn,{direction:"column",spacing:1,get children(){return[St(y,{get label(){return t("paragraph.widowControlLabel")},get checked(){return Q()},onChange:ee,"data-testid":"editor-paragraph-dialog-widow-control"}),St(y,{get label(){return t("paragraph.keepWithNextLabel")},get checked(){return G()},onChange:Y,"data-testid":"editor-paragraph-dialog-keep-with-next"}),St(y,{get label(){return t("paragraph.keepLinesTogetherLabel")},get checked(){return Z()},onChange:J,"data-testid":"editor-paragraph-dialog-keep-lines-together"}),St(y,{get label(){return t("paragraph.pageBreakBeforeLabel")},get checked(){return q()},onChange:X,"data-testid":"editor-paragraph-dialog-page-break-before"})]}})}})),ye);var ye,ve;return ve=wh(),_e(ve,St(le,{get isOpen(){return tt(()=>!(!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=Ih(),o=n.firstChild,a=o.nextSibling,_e(o,St(rr,{variant:"secondary",onClick:()=>{r(!0)},"data-testid":"editor-paragraph-dialog-tabs",get children(){return t("paragraph.tabsButton")}}),null),_e(o,St(rr,{variant:"secondary",onClick:ue,"data-testid":"editor-paragraph-dialog-set-default",get children(){return t("paragraph.setAsDefault")}}),null),_e(a,St(rr,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-paragraph-dialog-cancel",get children(){return t("generic.cancel")}}),null),_e(a,St(rr,{variant:"primary",onClick:de,"data-testid":"editor-paragraph-dialog-apply",get children(){return t("generic.apply")}}),null),n;var n,o,a},get children(){return[St(oe,{get ariaLabel(){return t("paragraph.title")},get items(){return[{id:"indents",label:t("paragraph.tabIndentsSpacing"),panel:me,testId:"editor-paragraph-dialog-tab-indents"},{id:"breaks",label:t("paragraph.tabLineBreaks"),panel:be,testId:"editor-paragraph-dialog-tab-breaks"}]}}),St(S,{get label(){return t("paragraph.preview")},get children(){var e=xh();return _e(e,()=>t("paragraph.previewText")),Mt(t=>Rn(e,ce(),t)),e}})]}}),null),_e(ve,St(hh,{get isOpen(){return tt(()=>!!e.isOpen)()&&(n()||!!e.initial.tabsOnly)},get initial(){return te()},get initialDefault(){return re()},get selectedPosition(){return e.initial.selectedTabPosition},onClose:()=>{r(!1),e.initial.tabsOnly&&e.onClose()},onApply:(t,n)=>{ne(t),ie(e=>[...e,...n]);for(const e of n)"number"==typeof e.default&&ae(e.default);e.initial.tabsOnly&&de()}}),null),ve}function Ch(e,t){const n=ar(e);return null===n?null:"percent"===t?`${n}%`:n}function kh(e,t,n){if("none"===e)return null;const r=ar(t);return{type:e,width:null!==r&&r>0?r:.5,color:n.trim()||"#000000"}}function Th(e){const[t,n]=Ht({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:""});bn(()=>{var t;e.isOpen&&n(jn({activeTab:(t=e.initial).activeTab??"table",tableWidth:t.tableWidth,tableWidthUnit:t.tableWidthUnit,tableAlign:t.tableAlign,tableIndentLeft:t.tableIndentLeft,tableWrapping:t.tableWrapping,floatingHorizontalAnchor:t.floatingHorizontalAnchor,floatingVerticalAnchor:t.floatingVerticalAnchor,floatingX:t.floatingX,floatingY:t.floatingY,floatingXAlign:t.floatingXAlign,floatingYAlign:t.floatingYAlign,floatingDistanceTop:t.floatingDistanceTop,floatingDistanceRight:t.floatingDistanceRight,floatingDistanceBottom:t.floatingDistanceBottom,floatingDistanceLeft:t.floatingDistanceLeft,floatingOverlap:t.floatingOverlap,rowHeight:t.rowHeight,rowHeightRule:t.rowHeightRule,repeatHeader:t.repeatHeader,allowBreakAcrossPages:t.allowBreakAcrossPages,hiddenRow:t.hiddenRow,columnWidth:t.columnWidth,cellWidth:t.cellWidth,cellVerticalAlign:t.cellVerticalAlign,cellTextDirection:t.cellTextDirection,cellNoWrap:t.cellNoWrap,cellFitText:t.cellFitText,cellHideMark:t.cellHideMark,marginTop:t.marginTop,marginRight:t.marginRight,marginBottom:t.marginBottom,marginLeft:t.marginLeft,borderStyle:t.borderStyle,borderWidth:t.borderWidth,borderColor:t.borderColor,borderTop:t.borderTop,borderRight:t.borderRight,borderBottom:t.borderBottom,borderLeft:t.borderLeft,borderStart:t.borderStart,borderEnd:t.borderEnd,borderTlBr:t.borderTopLeftToBottomRight,borderTrBl:t.borderTopRightToBottomLeft,shading:t.shading,altTitle:t.altTitle,altDescription:t.altDescription}))});return{form:t,set:n,handleApply:()=>{e.onApply(function(e){const t=kh(e.borderStyle,e.borderWidth,e.borderColor);return{tableWidth:Ch(e.tableWidth,e.tableWidthUnit),tableAlign:e.tableAlign||null,tableIndentLeft:Ch(e.tableIndentLeft,"points"),tableFloating:"around"===e.tableWrapping?{horizontalAnchor:e.floatingHorizontalAnchor,verticalAnchor:e.floatingVerticalAnchor,...e.floatingXAlign?{xAlign:e.floatingXAlign}:{x:ar(e.floatingX)??0},...e.floatingYAlign?{yAlign:e.floatingYAlign}:{y:ar(e.floatingY)??0},distanceTop:ar(e.floatingDistanceTop)??0,distanceRight:ar(e.floatingDistanceRight)??0,distanceBottom:ar(e.floatingDistanceBottom)??0,distanceLeft:ar(e.floatingDistanceLeft)??0}:null,tableOverlap:"around"===e.tableWrapping?e.floatingOverlap:null,rowHeight:Ch(e.rowHeight,"points"),rowHeightRule:e.rowHeightRule||null,repeatHeader:e.repeatHeader,cantSplit:!e.allowBreakAcrossPages,hiddenRow:e.hiddenRow,columnWidth:Ch(e.columnWidth,"points"),cellWidth:Ch(e.cellWidth,"points"),cellVerticalAlign:e.cellVerticalAlign||null,cellTextDirection:e.cellTextDirection||null,cellNoWrap:e.cellNoWrap,cellFitText:e.cellFitText,cellHideMark:e.cellHideMark,margins:{top:ar(e.marginTop),right:ar(e.marginRight),bottom:ar(e.marginBottom),left:ar(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 Ph(e,t,n,r,o=!1,a=!1){return St(R,{class:"oasis-editor-dialog-input-group-grow",type:"number",label:e,min:a?void 0:"0",step:"1",get value(){return t()},disabled:o,onChange:n,"data-testid":r})}var Rh=/*#__PURE__*/Gn("<div class=oasis-editor-table-properties-panel>");function Mh(e){const t=E(),n=()=>e.ctrl.form,r=e.ctrl.set;return o=Rh(),_e(o,St(xr,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.sizeSection")},get children(){return St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:6},get children(){return Ph(t("table.preferredWidth"),()=>n().tableWidth,e=>r("tableWidth",e),"editor-table-properties-table-width")}}),St(fe,{size:{xs:12,md:6},get children(){return St(Re,{get label(){return t("table.measureIn")},get value(){return n().tableWidthUnit},onChange:e=>r("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),_e(o,St(xr,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.alignmentSection")},get children(){return[St(wt,{class:"oasis-editor-dialog-style-row",name:"table-align",get value(){return n().tableAlign},onChange:e=>r("tableAlign",e),get children(){return["left","center","right"].map(e=>St(Dr,{value:e,get label(){return t(`table.align${e[0].toUpperCase()}${e.slice(1)}`)},"data-testid":`editor-table-properties-align-${e}`}))}}),St(fe,{container:!0,spacing:1.5,get children(){return St(fe,{size:{xs:12,md:6},get children(){return Ph(t("table.indentFromLeft"),()=>n().tableIndentLeft,e=>r("tableIndentLeft",e),"editor-table-properties-indent-left")}})}})]}}),null),_e(o,St(xr,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.textWrappingSection")},get children(){return[St(mn,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[St(y,{get label(){return t("table.wrapNone")},get checked(){return"none"===n().tableWrapping},onChange:()=>r("tableWrapping","none"),"data-testid":"editor-table-properties-wrap-none"}),St(y,{get label(){return t("table.wrapAround")},get checked(){return"around"===n().tableWrapping},onChange:()=>r("tableWrapping","around"),"data-testid":"editor-table-properties-wrap-around"})]}}),St(En,{get when(){return"around"===n().tableWrapping},get children(){return[St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:6},get children(){return St(Re,{get label(){return t("table.horizontalAnchor")},get value(){return n().floatingHorizontalAnchor},onChange:e=>r("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")}]}})}}),St(fe,{size:{xs:12,md:6},get children(){return St(Re,{get label(){return t("table.verticalAnchor")},get value(){return n().floatingVerticalAnchor},onChange:e=>r("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")}]}})}}),St(fe,{size:{xs:12,md:3},get children(){return Ph(t("table.positionX"),()=>n().floatingX,e=>r("floatingX",e),"editor-table-properties-floating-x",Boolean(n().floatingXAlign),!0)}}),St(fe,{size:{xs:12,md:3},get children(){return Ph(t("table.positionY"),()=>n().floatingY,e=>r("floatingY",e),"editor-table-properties-floating-y",Boolean(n().floatingYAlign),!0)}}),St(fe,{size:{xs:12,md:3},get children(){return St(Re,{get label(){return t("table.horizontalAlignment")},get value(){return n().floatingXAlign},onChange:e=>r("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}))]}})}}),St(fe,{size:{xs:12,md:3},get children(){return St(Re,{get label(){return t("table.verticalAlignment")},get value(){return n().floatingYAlign},onChange:e=>r("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}))]}})}}),St(fe,{size:{xs:12,md:3},get children(){return Ph(t("table.distanceTop"),()=>n().floatingDistanceTop,e=>r("floatingDistanceTop",e),"editor-table-properties-floating-distance-top")}}),St(fe,{size:{xs:12,md:3},get children(){return Ph(t("table.distanceRight"),()=>n().floatingDistanceRight,e=>r("floatingDistanceRight",e),"editor-table-properties-floating-distance-right")}}),St(fe,{size:{xs:12,md:3},get children(){return Ph(t("table.distanceBottom"),()=>n().floatingDistanceBottom,e=>r("floatingDistanceBottom",e),"editor-table-properties-floating-distance-bottom")}}),St(fe,{size:{xs:12,md:3},get children(){return Ph(t("table.distanceLeft"),()=>n().floatingDistanceLeft,e=>r("floatingDistanceLeft",e),"editor-table-properties-floating-distance-left")}})]}}),St(y,{get label(){return t("table.allowOverlap")},get checked(){return"overlap"===n().floatingOverlap},onChange:e=>r("floatingOverlap",e?"overlap":"never"),"data-testid":"editor-table-properties-floating-overlap"})]}})]}}),null),o;var o}var Ah=/*#__PURE__*/Gn("<div class=oasis-editor-table-properties-panel>");function Oh(e){const t=E(),n=()=>e.ctrl.form,r=e.ctrl.set;return o=Ah(),_e(o,St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:6},get children(){return Ph(t("table.rowHeight"),()=>n().rowHeight,e=>r("rowHeight",e),"editor-table-properties-row-height")}}),St(fe,{size:{xs:12,md:6},get children(){return St(Re,{get label(){return t("table.rowHeightRule")},get value(){return n().rowHeightRule},onChange:e=>r("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),_e(o,St(mn,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[St(y,{get label(){return t("table.repeatHeader")},get checked(){return n().repeatHeader},onChange:e=>r("repeatHeader",e),"data-testid":"editor-table-properties-repeat-header"}),St(y,{get label(){return t("table.allowBreakAcrossPages")},get checked(){return n().allowBreakAcrossPages},onChange:e=>r("allowBreakAcrossPages",e),"data-testid":"editor-table-properties-allow-break"}),St(y,{get label(){return t("table.hiddenRow")},get checked(){return n().hiddenRow},onChange:e=>r("hiddenRow",e),"data-testid":"editor-table-properties-hidden-row"})]}}),null),o;var o}var Bh=/*#__PURE__*/Gn("<div class=oasis-editor-table-properties-panel>");function Fh(e){const t=E(),n=e.ctrl.set;return r=Bh(),_e(r,St(fe,{container:!0,spacing:1.5,get children(){return St(fe,{size:{xs:12,md:6},get children(){return Ph(t("table.columnWidth"),()=>e.ctrl.form.columnWidth,e=>n("columnWidth",e),"editor-table-properties-column-width")}})}})),r;var r}var Eh=/*#__PURE__*/Gn("<div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>"),Dh=/*#__PURE__*/Gn("<div class=oasis-editor-table-properties-panel>");function Lh(e){const t=E(),n=()=>e.ctrl.form,r=e.ctrl.set,o=pr(()=>{const e=kh(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=Dh(),_e(i,St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:4},get children(){return Ph(t("table.cellWidth"),()=>n().cellWidth,e=>r("cellWidth",e),"editor-table-properties-cell-width")}}),St(fe,{size:{xs:12,md:4},get children(){return St(Re,{get label(){return t("table.verticalAlignment")},get value(){return n().cellVerticalAlign},onChange:e=>r("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")}]}})}}),St(fe,{size:{xs:12,md:4},get children(){return St(Re,{get label(){return t("table.textDirection")},get value(){return n().cellTextDirection},onChange:e=>r("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),_e(i,St(xr,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.options")},get children(){return St(mn,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[St(y,{get label(){return t("table.noWrap")},get checked(){return n().cellNoWrap},onChange:e=>r("cellNoWrap",e),"data-testid":"editor-table-properties-cell-nowrap"}),St(y,{get label(){return t("table.fitText")},get checked(){return n().cellFitText},onChange:e=>r("cellFitText",e),"data-testid":"editor-table-properties-cell-fit-text"}),St(y,{get label(){return t("table.hideMark")},get checked(){return n().cellHideMark},onChange:e=>r("cellHideMark",e),"data-testid":"editor-table-properties-cell-hide-mark"})]}})}}),null),_e(i,St(xr,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.cellMargins")},get children(){return St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:3},get children(){return Ph(t("paragraph.borderSideTop"),()=>n().marginTop,e=>r("marginTop",e),"editor-table-properties-margin-top")}}),St(fe,{size:{xs:12,md:3},get children(){return Ph(t("paragraph.borderSideRight"),()=>n().marginRight,e=>r("marginRight",e),"editor-table-properties-margin-right")}}),St(fe,{size:{xs:12,md:3},get children(){return Ph(t("paragraph.borderSideBottom"),()=>n().marginBottom,e=>r("marginBottom",e),"editor-table-properties-margin-bottom")}}),St(fe,{size:{xs:12,md:3},get children(){return Ph(t("paragraph.borderSideLeft"),()=>n().marginLeft,e=>r("marginLeft",e),"editor-table-properties-margin-left")}})]}})}}),null),_e(i,St(xr,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("paragraph.bordersSection")},get children(){return[St(fe,{container:!0,spacing:1.5,get children(){return[St(fe,{size:{xs:12,md:3},get children(){return St(Re,{get label(){return t("paragraph.borderStyleLabel")},get value(){return n().borderStyle},onChange:e=>{const t=e;r("borderStyle",t),"none"===t?(r("borderTop",!1),r("borderRight",!1),r("borderBottom",!1),r("borderLeft",!1),r("borderStart",!1),r("borderEnd",!1),r("borderTlBr",!1),r("borderTrBl",!1)):n().borderTop||n().borderRight||n().borderBottom||n().borderLeft||(r("borderTop",!0),r("borderRight",!0),r("borderBottom",!0),r("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")}]}})}}),St(fe,{size:{xs:12,md:3},get children(){return Ph(t("paragraph.borderWidthLabel"),()=>n().borderWidth,e=>r("borderWidth",e),"editor-table-properties-border-width",a())}}),St(fe,{size:{xs:12,md:3},get children(){return St(kr,{get label(){return t("paragraph.borderColorLabel")},get value(){return n().borderColor||"#000000"},get disabled(){return a()},onChange:e=>r("borderColor",e),"data-testid":"editor-table-properties-border-color"})}}),St(fe,{size:{xs:12,md:3},get children(){return St(kr,{get label(){return t("paragraph.shadingLabel")},get value(){return n().shading||"#ffffff"},onChange:e=>r("shading",e),"data-testid":"editor-table-properties-shading"})}})]}}),St(mn,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[St(y,{get label(){return t("paragraph.borderSideTop")},get checked(){return n().borderTop},get disabled(){return a()},onChange:e=>r("borderTop",e),"data-testid":"editor-table-properties-border-top"}),St(y,{get label(){return t("paragraph.borderSideRight")},get checked(){return n().borderRight},get disabled(){return a()},onChange:e=>r("borderRight",e),"data-testid":"editor-table-properties-border-right"}),St(y,{get label(){return t("paragraph.borderSideBottom")},get checked(){return n().borderBottom},get disabled(){return a()},onChange:e=>r("borderBottom",e),"data-testid":"editor-table-properties-border-bottom"}),St(y,{get label(){return t("paragraph.borderSideLeft")},get checked(){return n().borderLeft},get disabled(){return a()},onChange:e=>r("borderLeft",e),"data-testid":"editor-table-properties-border-left"}),St(y,{get label(){return t("table.borderStart")},get checked(){return n().borderStart},get disabled(){return a()},onChange:e=>r("borderStart",e),"data-testid":"editor-table-properties-border-start"}),St(y,{get label(){return t("table.borderEnd")},get checked(){return n().borderEnd},get disabled(){return a()},onChange:e=>r("borderEnd",e),"data-testid":"editor-table-properties-border-end"}),St(y,{get label(){return t("table.borderTlBr")},get checked(){return n().borderTlBr},get disabled(){return a()},onChange:e=>r("borderTlBr",e),"data-testid":"editor-table-properties-border-tlbr"}),St(y,{get label(){return t("table.borderTrBl")},get checked(){return n().borderTrBl},get disabled(){return a()},onChange:e=>r("borderTrBl",e),"data-testid":"editor-table-properties-border-trbl"})]}}),(e=Eh(),Mt(t=>Rn(e,o(),t)),e)];var e}}),null),i;var i}var Nh=/*#__PURE__*/Gn("<div class=oasis-editor-table-properties-panel>");function zh(e){const t=E(),n=()=>e.ctrl.form,r=e.ctrl.set;return o=Nh(),_e(o,St(R,{get label(){return t("table.altTitle")},get value(){return n().altTitle},onChange:e=>r("altTitle",e),"data-testid":"editor-table-properties-alt-title"}),null),_e(o,St(Fe,{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=>r("altDescription",e),"data-testid":"editor-table-properties-alt-description"}),null),o;var o}function $h(e){const t=E(),n=Th(e);return St(le,{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 St(Dm,{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 St(oe,{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:St(Mh,{ctrl:n})},{id:"row",label:t("table.tabRow"),testId:"editor-table-properties-tab-row",panel:St(Oh,{ctrl:n})},{id:"column",label:t("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:St(Fh,{ctrl:n})},{id:"cell",label:t("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:St(Lh,{ctrl:n})},{id:"altText",label:t("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:St(zh,{ctrl:n})}]}})}})}var Hh=/*#__PURE__*/Gn("<p data-testid=editor-new-document-message>");function jh(e){const t=E();return St(le,{get isOpen(){return e.isOpen},get title(){return t("dialog.newDocument.title")},get onClose(){return e.onClose},closeOnOverlayClick:!1,size:"sm",get footer(){return St(Dm,{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 _e(e,()=>t("dialog.newDocument.message")),e}})}function Wh(e){const t=E(),n=()=>"accept"===e.action;return St(le,{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 St(Dm,{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 St(Mn,{as:"p","data-testid":"editor-revision-bulk-message",get children(){return t(n()?"review.bulkAcceptMessage":"review.bulkRejectMessage",[e.count])}})}})}var Uh=/*#__PURE__*/Gn("<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>"),Vh=/*#__PURE__*/Gn("<div class=oasis-editor-symbol-dialog-recent><span></span><div class=oasis-editor-symbol-dialog-recent-list>"),_h=/*#__PURE__*/Gn("<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>"),Kh=/*#__PURE__*/Gn("<option>"),qh=/*#__PURE__*/Gn("<button type=button class=oasis-editor-symbol-dialog-tile>"),Xh=/*#__PURE__*/Gn("<button type=button class=oasis-editor-symbol-dialog-tile role=gridcell>"),Gh=["Segoe UI Symbol","Arial Unicode MS","Cambria Math","Times New Roman"];function Yh(e){const t=E(),[r,o]=$t("common"),[a,i]=$t(Rt[0]),[s,l]=$t(Gh[0]),[c,d]=$t(Rt[0].codePoint),u=pr(()=>(e.isOpen,hn())),p=pr(()=>"all"===r()?zt.flatMap(e=>e.entries):zt.find(e=>e.id===r())?.entries??Rt),f=e=>{i(e),d(e.codePoint)},g=()=>{const t=a().character;t&&(ur(t),e.onInsert(t,s()),e.onClose())};return St(le,{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[St(rr,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-symbol-dialog-cancel",get children(){return t("generic.cancel")}}),St(rr,{variant:"primary",onClick:g,"data-testid":"editor-symbol-dialog-insert",get children(){return t("dialog.symbol.insert")}})]},get children(){return[(I=Uh(),S=I.firstChild,C=S.firstChild,k=C.nextSibling,T=S.nextSibling.firstChild,P=T.nextSibling,R=P.firstChild,_e(C,()=>t("dialog.symbol.font")),k.addEventListener("change",e=>{l(e.currentTarget.value)}),_e(k,St(pt,{each:Gh,children:e=>{return(t=Kh()).value=e,_e(t,e),t;var t}})),_e(T,()=>t("dialog.symbol.subset")),P.addEventListener("change",e=>{o(e.currentTarget.value)}),_e(R,()=>t("symbols.category.all")),_e(P,St(pt,{each:zt,children:e=>{return n=Kh(),_e(n,()=>t(e.labelKey)),Mt(()=>n.value=e.id),n;var n}}),null),Mt(()=>k.value=s()),Mt(()=>P.value=r()),I),(e=_h(),m=e.firstChild,h=m.nextSibling.firstChild,b=h.nextSibling,y=b.nextSibling,v=y.firstChild,x=v.nextSibling,w=y.nextSibling,_e(m,St(En,{get when(){return u().length>0},get children(){var e=Vh(),r=e.firstChild,o=r.nextSibling;return _e(r,()=>t("dialog.symbol.recent")),_e(o,St(pt,{get each(){return u()},children:e=>{return(t=qh()).$$click=()=>f(e),_e(t,()=>e.character),Mt(r=>{var o=`${e.character} (${e.codePoint})`,a=`${e.character} (${e.codePoint})`;return o!==r.e&&n(t,"title",r.e=o),a!==r.t&&n(t,"aria-label",r.t=a),r},{e:void 0,t:void 0}),t;var t}})),e}}),null),_e(m,St(pt,{get each(){return p()},children:e=>{return(t=Xh()).$$dblclick=g,t.$$click=()=>f(e),_e(t,()=>e.character),Mt(r=>{var o=!(a().character!==e.character),i=`${e.character} (${e.codePoint})`,s=`${e.character} (${e.codePoint})`,l=`editor-symbol-dialog-${e.codePoint.replace(/[^A-Z0-9]/g,"-")}`;return o!==r.e&&t.classList.toggle("oasis-editor-symbol-dialog-tile-active",r.e=o),i!==r.t&&n(t,"title",r.t=i),s!==r.a&&n(t,"aria-label",r.a=s),l!==r.o&&n(t,"data-testid",r.o=l),r},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),null),_e(h,()=>t("dialog.symbol.preview")),_e(b,()=>a().character),_e(v,()=>t("dialog.symbol.code")),x.$$input=e=>(e=>{d(e);const t=e.trim().toUpperCase().replace(/^U\+/,""),n=Number.parseInt(t,16);!Number.isFinite(n)||n<0||n>1114111||i({character:String.fromCodePoint(n),codePoint:`U+${n.toString(16).toUpperCase().padStart(4,"0")}`})})(e.currentTarget.value),n(x,"spellcheck",!1),_e(w,()=>t("dialog.symbol.doubleClickHelp")),Mt(e=>{var r=t("dialog.symbol.title"),o=s();return r!==e.e&&n(m,"aria-label",e.e=r),o!==e.t&&Ft(b,"font-family",e.t=o),e},{e:void 0,t:void 0}),Mt(()=>x.value=c()),e)];var e,m,h,b,y,v,x,w,I,S,C,k,T,P,R}})}Ye(["input","click","dblclick"]);var Zh=/*#__PURE__*/Gn("<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>"),Jh=/*#__PURE__*/Gn("<button type=button data-testid=editor-equation-template>"),Qh=[["\\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 eb(e){const t=E(),[r,o]=$t(""),[a,i]=$t(Nr);bn(()=>{if(!e.isOpen)return;const t=e.initial??Nr;i(t),o(Ot(t))});const s=e=>{o(e),i(gr(e))};return St(le,{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[St(rr,{variant:"secondary",get onClick(){return e.onClose},get children(){return t("generic.cancel")}}),St(rr,{variant:"primary",onClick:()=>e.onApply(a()),"data-testid":"editor-equation-apply",get children(){return t("dialog.equation.insert")}})]},get children(){var e=Zh(),o=e.firstChild,i=o.nextSibling,l=i.firstChild,c=l.nextSibling,d=i.nextSibling;return _e(o,St(pt,{each:Qh,children:([e,t])=>{return(n=Jh()).$$click=()=>s(t),_e(n,e),n;var n}})),_e(l,()=>t("dialog.equation.linear")),c.$$input=e=>s(e.currentTarget.value),n(c,"spellcheck",!1),_e(d,()=>Ot(a())||t("dialog.equation.empty")),Mt(()=>n(o,"aria-label",t("dialog.equation.structures"))),Mt(()=>c.value=r()),e}})}Ye(["input","click"]);var tb=/*#__PURE__*/Gn("<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 nb(e){const t=E(),{fr:n}=e,r=e=>{n.isOpen()&&"Escape"===e.key&&n.setIsOpen(!1)},o=e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?n.findPrevious():n.findNext())};return it(()=>{window.addEventListener("keydown",r,!0)}),_t(()=>{window.removeEventListener("keydown",r,!0)}),St(En,{get when(){return n.isOpen()},get children(){var e=tb(),r=e.firstChild,a=r.nextSibling,i=a.firstChild,s=i.firstChild,l=i.nextSibling;return e.$$keydown=o,_e(r,St(Mn,{get children(){return t("find.title")}}),null),_e(r,St(Yn,{class:"oasis-editor-fr-close",icon:"x",onClick:()=>n.setIsOpen(!1),get label(){return t("generic.close")}}),null),_e(s,St(R,{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),_e(s,St(d,{class:"oasis-editor-fr-counter",get children(){return tt(()=>n.matches().length>0)()?`${n.currentIndex()+1} / ${n.matches().length}`:t("find.noMatches")}}),null),_e(i,St(mn,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[St(Yn,{get onClick(){return n.findPrevious},get disabled(){return 0===n.matches().length},icon:"chevron-up",get label(){return t("find.prevTooltip")}}),St(Yn,{get onClick(){return n.findNext},get disabled(){return 0===n.matches().length},icon:"chevron-down",get label(){return t("find.nextTooltip")}})]}}),null),_e(l,St(R,{type:"text",get placeholder(){return t("replace.placeholder")},get value(){return n.replaceTerm()},onChange:e=>n.setReplaceTerm(e),controlClass:"oasis-editor-fr-input"}),null),_e(l,St(mn,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[St(Yn,{class:"oasis-editor-fr-btn-text",get onClick(){return n.replace},get disabled(){return 0===n.matches().length},get children(){return t("replace.one")}}),St(Yn,{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),_e(a,St(mn,{class:"oasis-editor-fr-options",direction:"row",spacing:1,get children(){return[St(y,{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})}),St(y,{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}})}Ye(["keydown"]);var rb=/*#__PURE__*/Gn("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),ob=/*#__PURE__*/Gn("<i>"),ab=/*#__PURE__*/Gn("<span class=oasis-editor-context-menu-shortcut>"),ib=/*#__PURE__*/Gn("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),sb=/*#__PURE__*/Gn("<div class=oasis-editor-context-menu-separator>"),lb=/*#__PURE__*/Gn("<span aria-hidden=true style=visibility:hidden;flex-shrink:0>");function cb(e){let t;sr({refs:()=>[t],open:()=>e.isOpen,onDismiss:()=>e.onClose()});const r=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},o=()=>{e.isOpen&&e.onClose()};return it(()=>{window.addEventListener("contextmenu",r,!0),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o,!0)}),_t(()=>{window.removeEventListener("contextmenu",r,!0),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o,!0)}),bn(()=>{if(!e.isOpen||!t)return;const n=t.getBoundingClientRect(),r=Math.max(4,window.innerWidth-n.width-4),o=Math.max(4,window.innerHeight-n.height-4),a=Math.min(e.x,r),i=Math.min(e.y,o);t.style.left=`${a}px`,t.style.top=`${i}px`}),St(En,{get when(){return e.isOpen},get children(){var r=rb();r.$$contextmenu=e=>e.preventDefault();return"function"==typeof t?nn(t,r):t=r,_e(r,St(pt,{get each(){return e.items},children:t=>St(En,{get when(){return"separator"!==t.type},get fallback(){return sb()},get children(){var r=ib(),o=r.firstChild;return r.$$click=()=>{t.disabled||(t.onSelect?.(),e.onClose())},_e(r,St(En,{get when(){return t.icon},get fallback(){return e=lb(),_e(e,St(rn,{size:16})),e;var e},get children(){var e=ob();return Mt(()=>n(e,"data-lucide",t.icon)),e}}),o),_e(o,()=>t.label),_e(r,St(En,{get when(){return t.shortcut},get children(){var e=ab();return _e(e,()=>t.shortcut),e}}),null),Mt(e=>{var o=t.disabled,a=t.testId;return o!==e.e&&(r.disabled=e.e=o),a!==e.t&&n(r,"data-testid",e.t=a),e},{e:void 0,t:void 0}),r}})})),Mt(t=>{var n=`${e.x}px`,o=`${e.y}px`;return n!==t.e&&Ft(r,"left",t.e=n),o!==t.t&&Ft(r,"top",t.t=o),t},{e:void 0,t:void 0}),r}})}function db(e){const{linkDialog:t,setLinkDialog:n,imageAltDialog:r,setImageAltDialog:o,imageCaptionDialog:a,setImageCaptionDialog:i,contextMenu:s,fontDialog:l,setFontDialog:c,paragraphDialog:d,setParagraphDialog:u,tablePropertiesDialog:p,setTablePropertiesDialog:f,newDocumentDialog:g,setNewDocumentDialog:m,revisionBulkDialog:h,setRevisionBulkDialog:b,symbolDialog:y,setSymbolDialog:v,equationDialog:x,setEquationDialog:w}=e.dialogs;return[St(jh,{get isOpen(){return g().isOpen},onClose:()=>{m({isOpen:!1}),e.focusInput()},onConfirm:()=>{m({isOpen:!1}),e.confirmNewDocument()}}),St(Wh,{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)}}),St(Yh,{get isOpen(){return y().isOpen},onClose:()=>{v({isOpen:!1}),e.focusInput()},onInsert:(t,n)=>{v({isOpen:!1}),e.insertSymbol(t,n)}}),St(eb,{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)}}),St(Nm,{get isOpen(){return t().isOpen},get initialHref(){return t().initialHref},onClose:()=>{n({...t(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyLinkCommand(t.trim()||null)}),St(zm,{get isOpen(){return r().isOpen},get initialAlt(){return r().initialAlt},onClose:()=>{o({...r(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageAltCommand(t.trim())}),St($m,{get isOpen(){return a().isOpen},get initialCaption(){return a().initialCaption},onClose:()=>{i({...a(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageCaptionCommand(t.trim())}),St(Wm,{get composer(){return e.commentComposer}}),St(nb,{get fr(){return e.findReplace}}),St(dh,{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}}),St(Sh,{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}}),St($h,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{f({...p(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyTablePropertiesDialogValues}}),St(cb,{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}})]}Ye(["contextmenu","click"]);var ub=/*#__PURE__*/Gn("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function pb(e){let t,n;const r=L(),o=n=>{t=n,e.view.refs.onSurfaceRef?.(n)},a=t=>{n=t,e.view.refs.onViewportRef?.(t)},i=Ue({state:e.runtime.state,documentLayout:e.view.documentLayout,surfaceRef:()=>t,viewportRef:()=>n,zoomFactor:e.view.layout.zoomFactor,snapshotProvider:r});return[St(En,{get when(){return e.useComposedShell()},get children(){return(()=>{const t=e.shellComponent(),{runtime:n,chrome:r,view:o}=e;return St(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 r.showChrome()},get showTitleBar(){return r.showTitleBar()},get showMenubar(){return r.showMenubar()},get showToolbar(){return r.showToolbar()},get showOutline(){return r.showOutline},get showRuler(){return r.showRuler()},get toolbarView(){return r.toolbarView()},get toolbarLayout(){return r.toolbarLayout()},get isReadOnly(){return o.isReadOnly()},get measuredBlockHeights(){return o.measuredBlockHeights},get measuredParagraphLayouts(){return o.measuredParagraphLayouts},get documentLayout(){return o.documentLayout},get viewportHeight(){return o.viewportHeight},get layout(){return o.layout},get overlays(){return o.overlays},get refs(){return o.refs},get surfaceHandlers(){return o.surfaceHandlers},get inputHandlers(){return o.inputHandlers},get fileHandlers(){return o.fileHandlers}})})()}}),St(En,{get when(){return!e.useComposedShell()},get children(){return St(ee,{get editor(){return e.runtime.runtimeEditor},get children(){var s=ub(),l=s.firstChild;return _e(s,St(En,{get when(){return e.chrome.showOutline()},get children(){return St(K,{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:r})}}),l),_e(l,St(Z,{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:o,onViewportRef:a}},get surfaceHandlers(){return e.view.surfaceHandlers},get inputHandlers(){return e.view.inputHandlers},get fileHandlers(){return e.view.fileHandlers}})),s}})}})]}var fb=/*#__PURE__*/Gn("<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 gb(e){const t=E(),n=()=>{Rr(),ue(),e.onClose()},r=()=>{w(!1),ue(),e.onClose()};return St(En,{get when(){return e.isOpen},get children(){var e=fb(),o=e.firstChild,a=o.firstChild,i=a.nextSibling,s=i.nextSibling,l=s.nextSibling;return _e(o,St(De,{height:72,class:"oasis-editor-welcome-mark"}),a),_e(a,()=>t("welcome.title")),_e(i,()=>t("welcome.body")),_e(s,()=>t("welcome.note")),_e(l,St(rr,{variant:"secondary",onClick:r,"data-testid":"editor-welcome-skip",get children(){return t("welcome.skip")}}),null),_e(l,St(rr,{variant:"primary",onClick:n,"data-testid":"editor-welcome-enable",get children(){return t("welcome.enable")}}),null),e}})}function mb(e){switch(e){case"dashed":return[ht(5),ht(3)];case"dotted":return[ht(1),ht(3)];default:return}}async function hb(e,t,n,r,o,a,i,s){const l=t.rotation;l&&(e.saveGraphicsState(n.pageIndex),e.rotateAbout(n.pageIndex,ht(r+a/2),ht(o+i/2),l)),function(e,t,n,r,o,a,i){const s=A(n.shape?.preset,ht(r),ht(o),ht(a),ht(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,r,o,a,i),await async function(e,t,n,r,o,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=r+l.left,d=o+l.top,u=Math.max(1,a-l.left-l.right),p=Math.max(1,i-l.top-l.bottom),f=Kn({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===f.length)return;const g=gi(n.document);e.saveGraphicsState(n.pageIndex),e.clipRect(n.pageIndex,ht(c),ht(d),ht(u),ht(p));let m=d;for(const h of f){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,g,s);break;case"table":await s.drawTableBlock(e,n.pageIndex,h,n.document,c,m,u,n.fontRegistry,g,s);break;default:va(h.sourceBlock,"block")}m+=Math.max(0,h.estimatedHeight)}e.restoreGraphicsState(n.pageIndex)}(e,t,n,r,o,a,i,s),l&&e.restoreGraphicsState(n.pageIndex)}async function bb(e){const{writer:t,document:n,fontRegistry:r,pageIndex:o,lines:a,pageSettings:i,contentLeft:s,contentTop:l,contentWidth:c,paragraphTop:d,drawers:u}=e;for(const p of a){const a=new Map(p.slots.map(e=>[e.offset,e]));for(const f of p.fragments){const g=f.textBox;if(!g?.floating)continue;const m=Boolean(g.floating.behindDoc);if(e.layer&&"behind"===e.layer!==m)continue;const h=s+(a.get(f.startOffset)?.left??0),b=d+p.top,y=nt({object:Ke(g),pageSettings:i,contentLeft:s,contentTop:l,contentWidth:c,paragraphTop:d,lineTop:b,anchorLeft:h});await hb(t,g,{document:n,fontRegistry:r,pageIndex:o},y.x,y.y,y.width,y.height,u)}}}var yb=/* @__PURE__ */new WeakMap;function vb(e){const t=/^data:([^;,]+)(;base64)?,(.*)$/i.exec(e);if(!t)return null;const n=t[1].toLowerCase(),r=Boolean(t[2]),o=t[3]??"";if(!r)return{mediaType:n,data:(new TextEncoder).encode(decodeURIComponent(o))};const a="function"==typeof atob?atob(o):Buffer.from(o,"base64").toString("binary");return{mediaType:n,data:Uint8Array.from(a,e=>e.charCodeAt(0))}}async function xb(e,t,n){let r=e;r.startsWith("data:")||(r=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(),r=new Uint8Array(await n.arrayBuffer()),o=Array.from(r,e=>String.fromCharCode(e)).join(""),a="function"==typeof btoa?btoa(o):Buffer.from(r).toString("base64");return`data:${n.type||"application/octet-stream"};base64,${a}`}(r)??r);let o=vb(r);if(!o)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})}(r):null,i=null!=a&&a.naturalWidth>0&&a.naturalHeight>0;if("image/jpeg"!==o.mediaType&&"image/jpg"!==o.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(o=e?vb(e):null,!o)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:o.data}}async function wb(e,t,n){const r=zo(t,n.src);if(!r)return null;let o=yb.get(e);o||(o=/* @__PURE__ */new Map,yb.set(e,o));const a=o.get(r);if(a)return a;const i=xb(r,n.width,n.height).then(t=>t?e.registerImageResource({width:t.width,height:t.height,data:t.data,filter:"DCTDecode"}):null);return o.set(r,i),i}async function Ib(e,t,n,r,o,a,i,s){const l=await wb(e,n,r);if(!l)return;const c=r.intrinsicWidth??r.width,d=r.intrinsicHeight??r.height,u=c/Math.max(1,d),p=i/Math.max(1,s);let f=o,g=a,m=i,h=s;"fit"===r.cropFit&&u>0&&(u>p?(h=i/u,g+=(s-h)/2):(m=s*u,f+=(i-m)/2));const b="fill"!==r.cropFit||r.crop?r.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=r.cropShape?.preset,v=y?function(e,t,n,r,o,a){if(!a)return e;const i=t+r/2,s=n+o/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),r=c(e.x,e.y);return{type:"cubic",x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:r.x,y:r.y}}const t=c(e.x,e.y);return{type:e.type,x:t.x,y:t.y}})}(A(y,o,a,i,s),o,a,i,s,r.rotation??0):null,x=r.transparency??0,w="fit"===r.cropFit&&Boolean(r.rotation);v&&(e.saveGraphicsState(t),e.clipPath(t,v)),w&&(e.saveGraphicsState(t),e.rotateAbout(t,o+i/2,a+s/2,r.rotation??0)),x>0&&e.saveGraphicsState(t),x>0&&e.setOpacity(t,1-Math.min(1,x)),e.drawImage(t,{resourceName:l,x:f,y:g,width:m,height:h,rotation:w?void 0:r.rotation,crop:b}),x>0&&e.restoreGraphicsState(t),w&&e.restoreGraphicsState(t),v&&e.restoreGraphicsState(t);const I=r.border;if(!I)return;const S=r.rotation;S&&!v&&(e.saveGraphicsState(t),e.rotateAbout(t,o+i/2,a+s/2,S));const C=O(I.dash);v?e.drawPath(t,{segments:v,stroke:I.color,lineWidth:I.widthPt??1}):e.drawRect(t,{x:o,y:a,width:i,height:s,stroke:I.color,lineWidth:I.widthPt??1,...C.length>0?{dashArray:C}:{}}),S&&!v&&e.restoreGraphicsState(t)}function Sb(e,t){const n=new Map(e.slots.map(e=>[e.offset,e])),r=[];for(const o of t.chars){if("\n"===o.char||"\t"===o.char)continue;const e=n.get(o.paragraphOffset);e&&r.push({char:o.char,left:e.left,offset:o.paragraphOffset})}return r}function Cb(e,t,n){const r=Sb(e,t);if(0===r.length)return null;const o=new Map(e.slots.map(e=>[e.offset,e])),a=r[0],i=r[r.length-1],s=o.get(i.offset+1);return{left:a.left,right:s?.left??i.left+.55*n}}function kb(e,t,n,r,o,a,i){const s=Cb(e,t,n.fontSize??14.6667);return s?{x:ht(r+s.left),y:ht(o+e.top+a),width:ht(Math.max(0,s.right-s.left)),height:ht(Math.max(2,e.height-i))}:null}function Tb(e,t,n,r,o,a,i){const s=i.textFill;if(!s||"gradient"!==s.type||s.stops.length<2)return;const l=Cb(n,r,i.fontSize??14.6667);if(!l)return;const c=o+l.left,d=o+l.right,u=a+n.top,p=a+n.top+n.height,f=ne(c,u,d,p,s.angle??0);return e.registerAxialGradient(t,{x0:ht(f.x0),y0:ht(f.y0),x1:ht(f.x1),y1:ht(f.y1),stops:s.stops.map(e=>({offset:e.position,color:e.color}))})??void 0}function Pb(e,t,n,r,o,a,i){const s=x(i),c=(o,i)=>{e.drawLine(t,{x1:ht(n),y1:ht(o),x2:ht(r),y2:ht(o),stroke:a,lineWidth:ht(s),dashArray:i})};if(m(i))return c(o-l),void c(o+l);Ir(i)?function(e,t,n,r,o,a,i){let s=n,l=o;for(let c=n;c<=r;c+=1){const r=o+Math.sin((c-n)/4*Math.PI)*ke;e.drawLine(t,{x1:ht(s),y1:ht(l),x2:ht(c),y2:ht(r),stroke:a,lineWidth:ht(i)}),s=c,l=r}}(e,t,n,r,o,a,s):c(o,k(i))}function Rb(e,t,n,r,o,a,i){const s=new Map(n.slots.map(e=>[e.offset,e]));for(const l of r.chars){if("\t"!==l.char)continue;const r=s.get(l.paragraphOffset),c=s.get(l.paragraphOffset+1);if(!r||!c)continue;const d=n.resolvedTabs?.[l.paragraphOffset]?.leader;if(!d||c.left<=r.left+2)continue;const u="underscore"===d?a+2:a;e.drawLine(t,{x1:ht(o+r.left),y1:ht(u),x2:ht(o+c.left),y2:ht(u),stroke:i,lineWidth:ht("heavy"===d?1.5:1),dashArray:"dot"===d||"middleDot"===d?[1,3]:"hyphen"===d?[5,3]:void 0})}}function Mb(e,t){const n=jr(Po(e));if(!n)return e;const r=Math.max(0,Math.min(1,t));return pa(255+(n[0]-255)*r,255+(n[1]-255)*r,255+(n[2]-255)*r)}function Ab(e,t,n){const{writer:r,pageIndex:o,baselineY:a,fontSizePt:i,mainColor:s,gradientShadingName:l,styles:c,baseTextOptions:d}=e,u=ht(1);if(c.emboss||c.imprint){const e=c.imprint?1:-1;r.drawText(o,{...d,x:ht(t)+u*e,y:ht(a)+u*e,text:n,color:"#BFBFBF"})}if(c.glow){const e=c.glow,i=.5*ht(e.radiusPt*Do),s=Mb(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)r.drawText(o,{...d,x:ht(t)+c,y:ht(a)+u,text:n,color:s})}if(c.textShadow){const e=c.textShadow,i=e.dirDeg*Math.PI/180,s=ht(e.distPt*Do);r.drawText(o,{...d,x:ht(t)+Math.cos(i)*s,y:ht(a)+Math.sin(i)*s,text:n,color:e.color})}else c.shadow&&r.drawText(o,{...d,x:ht(t)+u,y:ht(a)+u,text:n,color:"#808080"});if(c.reflection){const e=c.reflection,l=Mb(s,.6*((e.startAlpha+e.endAlpha)/2));r.drawText(o,{...d,x:ht(t),y:ht(a)+ht(e.distPt*Do)+i,text:n,color:l})}const p=c.textOutline;r.drawText(o,{...d,x:ht(t),y:ht(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 Ob(e){for(const t of e.lines){const n=new Map(t.slots.map(e=>[e.offset,e]));for(const r of t.fragments){const o=r.image;if(!o?.floating)continue;const a=Boolean(o.floating.behindDoc);if("behind"===e.layer!==a)continue;const i=n.get(r.startOffset),s=nt({object:Ze(o),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 Ib(e.writer,e.pageIndex,e.document,o,ht(s.x),ht(s.y),ht(s.width),ht(s.height))}}}function Bb(e,t,n,r,o,a,i,s){const l=Cb(n,r,i.fontSize??14.6667);if(!l)return;const c=a+cn(s,n.top,n.height),d=o+l.left,u=o+l.right,p="underline"===s?i.underlineColor??i.color??"#000000":i.color??"#000000";if("strike"!==s)return"doubleStrike"===s?(e.drawLine(t,{x1:ht(d),y1:ht(c-fn),x2:ht(u),y2:ht(c-fn),stroke:p,lineWidth:ht(1)}),void e.drawLine(t,{x1:ht(d),y1:ht(c+fn),x2:ht(u),y2:ht(c+fn),stroke:p,lineWidth:ht(1)})):void Pb(e,t,d,u,c,p,i.underlineStyle);e.drawLine(t,{x1:ht(d),y1:ht(c),x2:ht(u),y2:ht(c),stroke:p,lineWidth:ht(1)})}async function Fb(e,t,n,r,o,a,i,s,l,c){if(o.opaque){const n=r.slots.find(e=>e.offset===o.startOffset);if(!n)return;const a=i+n.left,l=s+r.top+r.height-o.opaque.height,c=o.opaque.width,d=o.opaque.height;for(const[r,o,i,s]of[[a,l,a+c,l],[a+c,l,a+c,l+d],[a+c,l+d,a,l+d],[a,l+d,a,l],[a,l,a+c,l+d]])e.drawLine(t,{x1:ht(r),y1:ht(o),x2:ht(i),y2:ht(s),stroke:"#64748b",lineWidth:.75});return}if(o.image){if(o.image.floating)return;const n=r.slots.find(e=>e.offset===o.startOffset)??r.slots.find(e=>e.offset>=o.startOffset);if(!n)return;return void(await Ib(e,t,a,o.image,ht(i+n.left),ht(s+r.top+r.height-o.image.height),ht(o.image.width),ht(o.image.height)))}if(o.textBox){if(o.textBox.floating)return;const n=r.slots.find(e=>e.offset===o.startOffset)??r.slots.find(e=>e.offset>=o.startOffset);if(!n)return;return void(await hb(e,o.textBox,{document:a,fontRegistry:l,pageIndex:t},i+n.left,s+r.top+r.height-o.textBox.height,o.textBox.width,o.textBox.height,c))}if(o.math){const c=r.slots.find(e=>e.offset===o.startOffset)??r.slots.find(e=>e.offset>=o.startOffset);if(!c)return;const d=Ho(o.styles,n.style?.styleId,a.styles),u=l.resolveFontFace({fontFamily:"Cambria Math",bold:!1,italic:!1});return void e.drawText(t,{x:ht(i+c.left),y:ht(s+r.top+r.height*vr),text:xn(o.math),fontSize:zn(d),color:d.color??"#000000",fontResourceName:u.writerResourceName})}const d=Ho(o.styles,n.style?.styleId,a.styles);if(d.hidden)return;const u=l.resolveFontFace({fontFamily:d.fontFamily,bold:d.bold,italic:d.italic}),p=zn(d),f=(d.baselineShift??0)*Do,g=Lo(n.style,a.styles),m=xt(g.textAlignment,d.fontSize??14.6667,r.height),h=s+r.top+r.height*vr-f+m,b=Sb(r,o),y=b.map(e=>Un(e.char,d)).join("");if(0===b.length||0===y.length)return void Rb(e,t,r,o,i,h,d.color??"#000000");!function(e,t,n,r,o,a,i){if(!i.link)return;const s=Cb(n,r,i.fontSize??14.6667);if(!s||s.right<=s.left)return;const l=i.link.startsWith("#");e.addLinkAnnotation(t,{x:ht(o+s.left),y:ht(a+n.top),width:ht(s.right-s.left),height:ht(n.height),...l?{destName:i.link.slice(1)}:{uri:i.link}})}(e,t,r,o,i,s,d),function(e,t,n,r,o,a,i){if(!i.shading)return;const s=kb(n,r,i,o,a,2,4);s&&e.drawRect(t,{...s,fill:i.shading})}(e,t,r,o,i,s,d),function(e,t,n,r,o,a,i){if(!i.highlight)return;const s=kb(n,r,i,o,a,2,4);s&&e.drawRect(t,{...s,fill:i.highlight})}(e,t,r,o,i,s,d),function(e,t,n,r,o,a,i){const s=i.textBorder;if(!s||"none"===s.type||s.width<=0)return;const l=kb(n,r,i,o,a,1,2);l&&e.drawRect(t,{...l,stroke:s.color,lineWidth:ht(Math.max(.5,s.width*Do))})}(e,t,r,o,i,s,d),Rb(e,t,r,o,i,h,d.color??"#000000");const v=Lo(n.style,a.styles).align??"left",x=Ae(d,zn(d)),w={fontSize:p,bold:d.bold,italic:d.italic,fontResourceName:u.writerResourceName,characterSpacing:d.characterSpacing??0,horizontalScale:d.characterScale??100,fontFeatures:x};!function(e,t,n,r,o,a,i){const s="justify"===i?function(e){const t=[];let n=[];for(const r of e){const e=n[n.length-1];e&&r.offset>e.offset+1&&(t.push(n),n=[])," "!==r.char?n.push(r):n.length>0&&(t.push(n),n=[])}return n.length>0&&t.push(n),t}(t):function(e){const t=[];let n=[];for(const r of e){const e=n[n.length-1];e&&r.offset>e.offset+1&&(t.push(n),n=[]),n.push(r)}return n.length>0&&t.push(n),t}(t);for(const l of s){let t=[],o=!1;const a=()=>{if(0===t.length)return;const a=t.map(e=>Un(e.char,r)).join("");if(a.length>0){const r=o?.8*e.fontSizePt:e.fontSizePt;Ab({...e,fontSizePt:r,baseTextOptions:{...e.baseTextOptions,fontSize:r}},n+t[0].left,a)}t=[]};for(const e of l){const n=Boolean(r.smallCaps&&Wt(e.char));t.length>0&&n!==o&&a(),o=n,t.push(e)}a()}if(o.trailingHyphen&&a.endOffset>=o.endOffset){const t=o.slots.find(e=>e.offset===o.endOffset)??o.slots[o.slots.length-1];t&&Ab(e,n+t.left,"-")}}({writer:e,pageIndex:t,baselineY:h,fontSizePt:p,mainColor:"solid"===d.textFill?.type?d.textFill.color:"gradient"===d.textFill?.type&&d.textFill.stops[0]?d.textFill.stops[0].color:d.color??"#000000",gradientShadingName:Tb(e,t,r,o,i,s,d),styles:d,baseTextOptions:w},b,i,d,r,o,v),d.underline&&Bb(e,t,r,o,i,s,d,"underline"),d.strike&&Bb(e,t,r,o,i,s,d,"strike"),d.doubleStrike&&Bb(e,t,r,o,i,s,d,"doubleStrike"),d.emphasisMark&&function(e,t,n,r,o,a,i){const s=i.emphasisMark;if(!s||"none"===s)return;const l=Pr[s];if(!l)return;const c=Sb(n,r),d="underDot"===s,u=Math.max(4,.35*n.height),p=d?a+n.top+n.height+u:a+n.top+u;for(let f=0;f<c.length;f+=1){const r=c[f];if(" "===r.char||"\t"===r.char||"\n"===r.char)continue;const a=c[f+1],s=a?(r.left+a.left)/2:r.left+.25*n.height;e.drawText(t,{x:ht(o+s-.25*u),y:ht(p),text:l,fontSize:ht(u),color:i.color??"#000000"})}}(e,t,r,o,i,s,d)}async function Eb(e,t,n,r,o,a,i,s,l){if(0!==r.index)return;const c=Eo(n,l),d=r.slots[0];if(!d)return;const u=Jr(n,o.styles),p="bullet"===u?.kind,f=p?u?.bulletFont:void 0,g=p?u.bulletPicture:void 0;if(g){const s=g.widthPx??16,l=g.heightPx??s,c=await wb(e,o,{src:g.src,width:s,height:l,...g.altText?{alt:g.altText}:{}});if(c)return void e.drawImage(t,{resourceName:c,x:ht(a+Math.max(0,Tt(n,o.styles))),y:ht(i+r.top+r.height*vr-l),width:ht(s),height:ht(l)})}if(!c)return;const m=Ho(void 0,n.style?.styleId,o.styles),h=s.resolveFontFace({fontFamily:f??m.fontFamily,bold:m.bold,italic:m.italic}),b=Tt(n,o.styles),y=zn(m),v=c.length*y*.62*Do,x=or(n,o.styles,d.left,v);e.drawText(t,{x:ht(a+Math.max(0,x||b)),y:ht(i+r.top+r.height*vr),text:c,fontSize:y,color:m.color??"#000000",bold:m.bold,italic:m.italic,fontResourceName:h.writerResourceName})}function Db(e,t,n,r,o,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 r)c=Math.max(c,h.top+h.height);if(c<=0)return;const d=Mr(n),u=d.top+c+d.bottom,p=o+(n.indentLeft??0),f=o+i-(n.indentRight??0),g=a+u;n.shading&&e.drawRect(t,{x:ht(p),y:ht(a),width:ht(Math.max(0,f-p)),height:ht(u),fill:n.shading});for(const[h,b]of s){if(!h||"none"===h.type||h.width<=0)continue;const[n,r,o,i]="top"===b?[p,a,f,a]:"bottom"===b?[p,g,f,g]:"left"===b?[p,a,p,g]:[f,a,f,g];e.drawLine(t,{x1:ht(n),y1:ht(r),x2:ht(o),y2:ht(i),stroke:h.color,lineWidth:h.width,dashArray:mb(h.type)})}const m=n.borderBar;m&&"none"!==m.type&&m.width>0&&e.drawLine(t,{x1:ht(p),y1:ht(a),x2:ht(p),y2:ht(g),stroke:m.color,lineWidth:m.width,dashArray:mb(m.type)})}async function Lb(e,t,n,r,o,a,i,s,l,c){for(const d of r){for(const n of d.barTabPositionsPx??[])e.drawLine(t,{x1:ht(a+n),y1:ht(i+d.top),x2:ht(a+n),y2:ht(i+d.top+d.height),stroke:"#000000",lineWidth:ht(1)});await Eb(e,t,n,d,o,a,i,s,l);for(const r of d.fragments)await Fb(e,t,n,d,r,o,a,i,s,c)}}function Nb(e,t,n,r,o,a,i){"none"===n.type||n.width<=0||e.drawLine(t,{x1:ht(r),y1:ht(o),x2:ht(a),y2:ht(i),stroke:n.color,lineWidth:ht(n.width),dashArray:mb(n.type)})}function zb(e,t,n,r,o){const a=r+n.left,i=o+n.top,s=a+n.width,l=i+n.height;Nb(e,t,n.borders.top,a,i,s,i),Nb(e,t,n.borders.right,s,i,s,l),Nb(e,t,n.borders.bottom,a,l,s,l),Nb(e,t,n.borders.left,a,i,a,l),n.borders.topLeftToBottomRight&&Nb(e,t,n.borders.topLeftToBottomRight,a,i,s,l),n.borders.topRightToBottomLeft&&Nb(e,t,n.borders.topRightToBottomLeft,s,i,a,l)}async function $b(e,t,n,r,o,a,i,s,l,c){if("table"!==n.sourceBlock.type)return;const d=n.sourceBlock,u=n.tableSegment?qo(d,n.tableSegment):d;if(0===u.rows.length)return;const p=j({table:u,state:{document:r},pageIndex:0,originX:0,originY:0,contentWidth:i,estimatedHeight:n.estimatedHeight});for(const f of p.cells)f.shading&&e.drawRect(t,{x:ht(o+f.left),y:ht(a+f.top),width:ht(f.width),height:ht(f.height),fill:f.shading});for(const f of p.cells)if(zb(e,t,f,o,a),f.revision){const n="insert"===f.revision.type?"#059669":"delete"===f.revision.type?"#dc2626":"#d97706";e.drawRect(t,{x:ht(o+f.left+1),y:ht(a+f.top+1),width:ht(Math.max(0,f.width-2)),height:ht(Math.max(0,f.height-2)),stroke:n,lineWidth:ht(2)})}for(const f of p.cells)for(const n of f.paragraphs)await Lb(e,t,n.paragraph,n.lines,r,o+n.originX,a+n.originY,s,l,c)}var Hb={drawParagraph:Lb,drawTableBlock:$b};async function jb(e,t,n,r,o,a,i,s,l,c,d){if(!n||0===n.length)return;const u=a;let p=a;for(let f=0;f<n.length;f+=1){const g=n[f];switch(g.sourceBlock.type){case"paragraph":{if(!g.layout)break;const n=Lo(g.sourceBlock.style,r.styles),f=p+(0===g.layout.startOffset&&p>a?n.spacingBefore??0:0);d?.(g.sourceBlock.id,f);const m=f+Mr(n).top;Db(e,t,n,g.layout.lines,o,f,i),c&&(await Ob({writer:e,pageIndex:t,lines:g.layout.lines,document:r,pageSettings:c,contentLeft:o,contentTop:u,contentWidth:i,paragraphTop:m,layer:"behind"}),await bb({writer:e,document:r,fontRegistry:s,pageIndex:t,lines:g.layout.lines,pageSettings:c,contentLeft:o,contentTop:u,contentWidth:i,paragraphTop:f,drawers:Hb,layer:"behind"})),await Lb(e,t,g.sourceBlock,g.layout.lines,r,o,m,s,l,Hb),c&&(await Ob({writer:e,pageIndex:t,lines:g.layout.lines,document:r,pageSettings:c,contentLeft:o,contentTop:u,contentWidth:i,paragraphTop:m,layer:"front"}),await bb({writer:e,document:r,fontRegistry:s,pageIndex:t,lines:g.layout.lines,pageSettings:c,contentLeft:o,contentTop:u,contentWidth:i,paragraphTop:f,drawers:Hb,layer:"front"}));break}case"table":if(g.sourceBlock.style?.floating&&c){const n=Q(g.sourceBlock,i),a=ye({floating:g.sourceBlock.style.floating,pageSettings:c,contentLeft:o,contentTop:u,contentWidth:i,anchorTop:p,width:n,height:g.floatingTableHeight??1,pageIndex:t});a.y+=g.floatingTableOffsetY??0,await $b(e,t,{...g,estimatedHeight:a.height},r,a.x,a.y,i,s,l,Hb);break}await $b(e,t,g,r,o,p,i,s,l,Hb);break;default:va(g.sourceBlock,"block")}if("paragraph"===g.sourceBlock.type&&g.layout){const s=n[f+1];if("paragraph"===s?.sourceBlock.type&&s.layout&&s.sourceBlock.id!==g.sourceBlock.id){const n=Lo(g.sourceBlock.style,r.styles),l=Lo(s.sourceBlock.style,r.styles);if(Pe(n,l)){const r=p+(0===g.layout.startOffset&&p>a?n.spacingBefore??0:0)+Mr(n).top;let s=0;for(const e of g.layout.lines)s=Math.max(s,e.top+e.height);const l=r+s,c=o+(n.indentLeft??0),d=o+i-(n.indentRight??0),u=n.borderBetween;e.drawLine(t,{x1:ht(c),y1:ht(l),x2:ht(d),y2:ht(l),stroke:u.color,lineWidth:u.width,dashArray:mb(u.type)})}}}p+=Math.max(0,g.estimatedHeight)}}async function Wb(e,t,n,r,o,a,i){if(e.drawRect(t,{x:0,y:0,width:n,height:r,fill:o?.pageColor||"#ffffff"}),a){const o=a.distance??12,i="dashed"===a.style?[6,4]:"dotted"===a.style?[1,3]:void 0;if(e.drawRect(t,{x:o,y:o,width:n-2*o,height:r-2*o,fill:void 0,stroke:a.color,lineWidth:a.width,...i?{dashArray:i}:{}}),"double"===a.style){const i=o+2*a.width;e.drawRect(t,{x:i,y:i,width:n-2*i,height:r-2*i,stroke:a.color,lineWidth:a.width})}}const s=o?.watermark;if("text"===s?.kind&&s.text)e.saveGraphicsState(t),e.rotateAbout(t,n/2,r/2,s.rotation??-45),e.setOpacity(t,s.opacity??.25),e.drawText(t,{x:n/2,y:r/2,text:s.text,fontSize:s.fontSize??48,color:s.color??"#94a3b8"}),e.restoreGraphicsState(t);else if("image"===s?.kind&&s.src&&i){const o={src:s.src,width:360,height:180},a=await wb(e,i,o);if(a){const i=s.scale??1,l=o.width*i,c=o.height*i;e.saveGraphicsState(t),e.rotateAbout(t,n/2,r/2,s.rotation??-45),e.setOpacity(t,s.opacity??.25),e.drawImage(t,{resourceName:a,x:(n-l)/2,y:(r-c)/2,width:l,height:c}),e.restoreGraphicsState(t)}}}var Ub=[{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 Vb(e,t,n){return`${e.toLowerCase()}:${t?"bold":"regular"}${n?"italic":""}`}function _b(e){return e.replace(/[^A-Za-z0-9_]/g,"")}var Kb=class{faces=/* @__PURE__ */new Map;fallbackFamily="Helvetica";constructor(){for(const e of Ub)this.registerFontFace(e)}registerFontFace(e){this.faces.set(Vb(e.family,e.bold,e.italic),e)}resolveFontFace(e){const t=gn(e.fontFamily),n=Boolean(e.bold),r=Boolean(e.italic);return this.faces.get(Vb(t,n,r))??this.faces.get(Vb(this.fallbackFamily,n,r))??this.faces.get(Vb(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(gn).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[r,o]of Object.entries(I)){const e=await pe(o);if(!e)continue;const t="bold"===r||"bolditalic"===r,n="italic"===r||"bolditalic"===r,a=`Roboto${r[0].toUpperCase()}${r.slice(1)}`;this.registerFontFace({key:`roboto:${r}`,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 kn(e.families);for(const n of t){const e=`Remote${_b(n.postscriptName||n.family)}`;this.registerFontFace({key:Vb(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 P){const r=[n.family,...n.aliases].map(e=>e.toLowerCase());if(e&&!r.some(t=>e.has(t)))continue;for(const e of r)t.add(e);const o=[];for(const[e,t]of Object.entries(n.files)){const r=await pe(t);if(!r)continue;const a="bold"===e||"bolditalic"===e,i="italic"===e||"bolditalic"===e,s=`${_b(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:r}};this.registerFontFace(l),o.push(l)}for(const e of n.aliases)for(const t of o)this.registerFontFace({...t,key:`${e.toLowerCase()}:${t.key.split(":")[1]}`,family:e})}return t}},qb="%PDF-1.4\n% Oasis PDF\n",Xb=[{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 Gb(e){return Number.isFinite(e)?Number(e.toFixed(3)).toString():"0"}function Yb(e){return Math.max(0,e).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function Zb(e,t){if(!e)return t;const n=jr(Po(e));return n?[n[0]/255,n[1]/255,n[2]/255]:t}function Jb(e,t,n){const[r,o,a]=Zb(e,n);return`${Gb(r)} ${Gb(o)} ${Gb(a)} ${t}`}function Qb(e,t){return(e&&e.trim().length>0?e:t).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}var ey=/* @__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 ty(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:ey.get(t)??63}(e).toString(16).padStart(2,"0").toUpperCase()).join("")}function ny(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(Yb).join("")}function ry(e,t=[]){const n=new TextEncoder,r=n.encode(["<< /Length "+e.byteLength,...t,">>"].join(" ")+"\nstream\n"),o=n.encode("\nendstream"),a=new Uint8Array(r.length+e.length+o.length);return a.set(r),a.set(e,r.length),a.set(o,r.length+e.length),a}function oy(e,t=[]){return ry(re(e,{level:9}),["/Filter /FlateDecode",...t])}function ay(e,t){const n=[...new Set(t)].sort((e,t)=>e-t),r=[];let o=-1,a=-2,i=[];const s=()=>{i.length&&r.push(o+" ["+i.join(" ")+"]")};for(const l of n)(l!==a+1||o<0)&&(s(),o=l,i=[]),i.push(Gb(e[l]??0)),a=l;return s(),r.join(" ")}function iy(e){return Yb(e)}function sy(e){return`% OasisText ${ny(Array.from(e).map(e=>e.codePointAt(0)??65533))}`}function ly(e){return e&&0!==e.length?`[${e.map(e=>Gb(e)).join(" ")}] 0 d`:null}var cy=class{page;fonts;images;shadings;constructor(e,t,n,r){this.page=e,this.fonts=t,this.images=n,this.shadings=r}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(Jb(e.fill,"rg",[1,1,1])),e.stroke){n.push(Jb(e.stroke,"RG",[0,0,0])),n.push(`${Gb(e.lineWidth??1)} w`);const t=ly(e.dashArray);t&&n.push(t)}n.push([Gb(e.x),Gb(t.height-e.y-e.height),Gb(e.width),Gb(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=ly(e.dashArray),r=["q",Jb(e.stroke,"RG",[0,0,0])];n&&r.push(n),r.push(`${Gb(e.lineWidth??1)} w`,`${Gb(e.x1)} ${Gb(t.height-e.y1)} m`,`${Gb(e.x2)} ${Gb(t.height-e.y2)} l`,"S","Q"),t.commands.push(r.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,r=["q"];e.fill&&r.push(Jb(e.fill,"rg",[1,1,1])),e.stroke&&(r.push(Jb(e.stroke,"RG",[0,0,0])),r.push(`${Gb(e.lineWidth??1)} w`));for(const o of e.segments)switch(o.type){case"move":r.push(`${Gb(o.x)} ${Gb(n(o.y))} m`);break;case"line":r.push(`${Gb(o.x)} ${Gb(n(o.y))} l`);break;case"cubic":r.push(`${Gb(o.x1)} ${Gb(n(o.y1))} ${Gb(o.x2)} ${Gb(n(o.y2))} ${Gb(o.x)} ${Gb(n(o.y))} c`);break;case"close":r.push("h")}e.fill&&e.stroke?r.push("B"):e.fill?r.push("f"):r.push("S"),r.push("Q"),t.commands.push(r.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 r=this.page;if(!n)return;const o=r.height-t,a=-n*Math.PI/180,i=Math.cos(a),s=Math.sin(a),l=e-e*i+o*s,c=o-e*s-o*i;r.commands.push(`${Gb(i)} ${Gb(s)} ${Gb(-s)} ${Gb(i)} ${Gb(l)} ${Gb(c)} cm`)}clipRect(e,t,n,r){const o=this.page;n<=0||r<=0||o.commands.push(`${Gb(e)} ${Gb(o.height-t-r)} ${Gb(n)} ${Gb(r)} re`,"W","n")}clipPath(e){const t=this.page;if(0===e.length)return;const n=e=>t.height-e,r=[];for(const o of e)switch(o.type){case"move":r.push(`${Gb(o.x)} ${Gb(n(o.y))} m`);break;case"line":r.push(`${Gb(o.x)} ${Gb(n(o.y))} l`);break;case"cubic":r.push(`${Gb(o.x1)} ${Gb(n(o.y1))} ${Gb(o.x2)} ${Gb(n(o.y2))} ${Gb(o.x)} ${Gb(n(o.y))} c`);break;case"close":r.push("h")}r.push("W","n"),t.commands.push(r.join("\n"))}drawText(e){if(0===e.text.length)return;const t=this.fonts.resolveAndMarkFontName(e),n=this.fonts.getUnicodeState(t),r=n?this.fonts.buildUnicodeShowCommand(n,e.text,e.fontFeatures):`<${ty(e.text)}> Tj`;null!==r&&(e.gradientShadingName?this.emitGradientTextBlock(t,r,e,e.gradientShadingName):this.emitTextBlock(t,r,e))}textSetupCommands(e,t){return[`/${e} ${Gb(t.fontSize??12)} Tf`,...t.horizontalScale&&t.horizontalScale>0&&100!==t.horizontalScale?[`${Gb(t.horizontalScale)} Tz`]:[],...t.characterSpacing&&0!==t.characterSpacing?[`${Gb(t.characterSpacing)} Tc`]:[]]}emitTextBlock(e,t,n){const r=this.page;r.commands.push([sy(n.text),"BT",Jb(n.color,"rg",[0,0,0]),...n.renderMode&&0!==n.renderMode?[Jb(n.strokeColor??n.color,"RG",[0,0,0]),`${Gb(n.strokeWidth??Math.max(.3,.03*(n.fontSize??12)))} w`,`${n.renderMode} Tr`]:[],...this.textSetupCommands(e,n),`${Gb(n.x)} ${Gb(r.height-n.y)} Td`,t,"ET"].join("\n"))}emitGradientTextBlock(e,t,n,r){const o=this.page;o.commands.push([sy(n.text),"q","BT",...this.textSetupCommands(e,n),"7 Tr",`${Gb(n.x)} ${Gb(o.height-n.y)} Td`,t,"ET",`/${r} 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,r=Number.isFinite(e.rotation)?e.rotation??0:0,o=e.crop,a=o?.left??0,i=o?.top??0,s=o?.right??0,l=o?.bottom??0;if(o&&(a>0||i>0||s>0||l>0))return void this.drawCroppedImage(e,n,r,{left:a,top:i,right:s,bottom:l});if(0===r)return void t.commands.push(["q",[Gb(e.width),"0","0",Gb(e.height),Gb(e.x),Gb(n),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"));const c=-r*Math.PI/180,d=Math.cos(c),u=Math.sin(c),p=e.width*d,f=e.width*u,g=-e.height*u,m=e.height*d,h=e.x+e.width/2-.5*p-.5*g,b=n+e.height/2-.5*f-.5*m;t.commands.push(["q",[Gb(p),Gb(f),Gb(g),Gb(m),Gb(h),Gb(b),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}drawCroppedImage(e,t,n,r){const o=this.page,{width:a,height:i}=e,s=a/Math.max(1e-4,1-r.left-r.right),l=i/Math.max(1e-4,1-r.top-r.bottom),c=-r.left*s,d=-r.bottom*l,u=-n*Math.PI/180,p=Math.cos(u),f=Math.sin(u),g=a/2,m=i/2,h=p,b=f,y=-f,v=p,x=e.x+a/2-(h*g+y*m),w=t+i/2-(b*g+v*m);o.commands.push(["q",[Gb(h),Gb(b),Gb(y),Gb(v),Gb(x),Gb(w),"cm"].join(" "),`0 0 ${Gb(a)} ${Gb(i)} re W n`,[Gb(s),"0","0",Gb(l),Gb(c),Gb(d),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}};function dy(e,t,n){if(e.seek(t),1!==e.u16())return null;const r=e.u16();return n(e,t+e.u32(),r)}function uy(e,t){const n=new Array(t);for(let r=0;r<t;r+=1)n[r]=e.u16();return n}function py(e,t,n){const r=new Array(t);for(let o=0;o<t;o+=1)r[o]=n+e.u16();return r}function fy(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=/* @__PURE__ */new Map;for(let r=0;r<t;r+=1)n.set(e.u16(),r);return e=>n.get(e)??-1}if(2===n){const t=e.u16(),n=[];for(let r=0;r<t;r+=1){const t=e.u16(),r=e.u16(),o=e.u16();n.push({start:t,end:r,startIndex:o})}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 gy(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=e.u16(),r=uy(e,n);return e=>{const o=e-t;return o>=0&&o<n?r[o]:0}}if(2===n){const t=e.u16(),n=[];for(let r=0;r<t;r+=1){const t=e.u16(),r=e.u16(),o=e.u16();n.push({start:t,end:r,classValue:o})}return e=>{for(const t of n)if(e>=t.start&&e<=t.end)return t.classValue;return 0}}return()=>0}function my(e){e.seek(0),e.skip(2),e.skip(2);const t=e.u16(),n=e.u16(),r=e.u16(),o=function(e,t){e.seek(t);const n=e.u16(),r=[];for(let o=0;o<n;o+=1){const n=e.tag(),o=t+e.u16();r.push({tag:n,offset:o})}return r.map(({tag:t,offset:n})=>(e.seek(n),e.skip(2),{tag:t,lookupIndices:uy(e,e.u16())}))}(e,n),a=function(e,t){e.seek(t);const n=e.u16(),r=[];for(let c=0;c<n;c+=1){const n=e.tag(),o=t+e.u16();r.push({tag:n,offset:o})}if(0===r.length)return[];const o=r.find(e=>"latn"===e.tag)??r.find(e=>"DFLT"===e.tag)??r[0];e.seek(o.offset);const a=e.u16();if(0===a)return[];e.seek(o.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=o[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:r}}function hy(e,t,n){return e.seek(t),py(e,e.u16(),t).map(t=>{e.seek(t);const r=e.u16();e.skip(2);const o=py(e,e.u16(),t),a=[];for(const i of o)try{const t=n(e,i,r);t&&a.push(t)}catch{}return{lookupType:r,subtables:a}})}function by(e,t){const n=/* @__PURE__ */new Set;for(const r of t)for(const t of e.get(r)??[])n.add(t);return Array.from(n).sort((e,t)=>e-t)}function yy(e,t){if(e.seek(t),1!==e.u16())return null;const n=t+e.u16(),r=e.u16(),o=py(e,r,t).map(t=>(e.seek(t),uy(e,e.u16())));return{coverage:fy(e,n),sets:o}}function vy(e,t){const n=new Array(t);for(let r=0;r<t;r+=1){const t=e.u16(),o=e.u16();n[r]={sequenceIndex:t,lookupListIndex:o}}return n}function xy(e,t,n,r){for(const o of n)r.applyLookupIndexAt(o.lookupListIndex,e,t+o.sequenceIndex)}function wy(e,t){e.seek(t);const n=e.u16();return py(e,n,t).map(t=>(e.seek(t),{backtrack:uy(e,e.u16()),input:uy(e,Math.max(0,e.u16()-1)),lookahead:uy(e,e.u16()),records:vy(e,e.u16())}))}function Iy(e,t,n,r,o){const a=(e,n)=>{const r=t[e];return r?o?"b"===n?o.backtrack(r.id):"l"===n?o.lookahead(r.id):o.input(r.id):r.id:null};for(const i of e){const e=i.input.length+1;if(n+e>t.length)continue;let o=!0;for(let t=0;t<i.input.length;t+=1)if(a(n+1+t,"i")!==i.input[t]){o=!1;break}if(o){for(let e=0;e<i.backtrack.length;e+=1)if(a(n-1-e,"b")!==i.backtrack[e]){o=!1;break}if(o){for(let t=0;t<i.lookahead.length;t+=1)if(a(n+e+t,"l")!==i.lookahead[t]){o=!1;break}if(o)return xy(t,n,i.records,r),e}}}return null}function Sy(e,t,n){switch(n){case 1:return function(e,t){e.seek(t);const n=e.u16(),r=t+e.u16();if(1===n){const t=e.i16(),n=fy(e,r);return{apply(e,r){const o=e[r];return!o||n(o.id)<0?null:(o.id=o.id+t&65535,1)}}}if(2===n){const t=e.u16(),n=uy(e,t),o=fy(e,r);return{apply(e,r){const a=e[r];if(!a)return null;const i=o(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=yy(e,t);if(!n)return null;const{coverage:r,sets:o}=n;return{apply(e,t){const n=e[t];if(!n)return null;const a=r(n.id);if(a<0||a>=o.length)return null;const i=o[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=yy(e,t);if(!n)return null;const{coverage:r,sets:o}=n;return{apply(e,t){const n=e[t];if(!n)return null;const a=r(n.id);if(a<0||a>=o.length)return null;const i=o[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(),r=e.u16(),o=py(e,r,t).map(t=>(e.seek(t),py(e,e.u16(),t).map(t=>{e.seek(t);const n=e.u16(),r=e.u16();return{ligatureGlyph:n,components:uy(e,Math.max(0,r-1))}}))),a=fy(e,n);return{apply(e,t){const n=e[t];if(!n)return null;const r=a(n.id);if(r<0||r>=o.length)return null;for(const a of o[r]){const{components:n}=a;if(t+n.length>e.length-1)continue;let r=!0;for(let a=0;a<n.length;a+=1)if(e[t+1+a].id!==n[a]){r=!1;break}if(!r)continue;const o=n.length+1,i=[];for(let a=0;a<o;a+=1)i.push(...e[t+a].codePoints);return e.splice(t,o,{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=py(e,e.u16(),t),r=py(e,e.u16(),t),o=py(e,e.u16(),t),a=vy(e,e.u16()),i=n.map(t=>fy(e,t)),s=r.map(t=>fy(e,t)),l=o.map(t=>fy(e,t));return{apply(e,t,n){if(0===s.length)return null;if(t+s.length>e.length)return null;for(let r=0;r<s.length;r+=1)if(s[r](e[t+r].id)<0)return null;for(let r=0;r<i.length;r+=1){const n=e[t-1-r];if(!n||i[r](n.id)<0)return null}for(let r=0;r<l.length;r+=1){const n=e[t+s.length+r];if(!n||l[r](n.id)<0)return null}return xy(e,t,a,n),s.length}}}if(1===n){const n=t+e.u16(),r=e.u16(),o=py(e,r,t),a=fy(e,n),i=o.map(t=>wy(e,t));return{apply(e,t,n){const r=e[t];if(!r)return null;const o=a(r.id);return o<0||o>=i.length?null:Iy(i[o],e,t,n,null)}}}if(2===n){const n=t+e.u16(),r=t+e.u16(),o=t+e.u16(),a=t+e.u16(),i=e.u16(),s=new Array(i);for(let f=0;f<i;f+=1){const n=e.u16();s[f]=0===n?0:t+n}const l=fy(e,n),c=gy(e,r),d=gy(e,o),u=gy(e,a),p=s.map(t=>0===t?[]:wy(e,t));return{apply(e,t,n){const r=e[t];if(!r)return null;if(l(r.id)<0)return null;const o=d(r.id),a=p[o];return a?Iy(a,e,t,n,{backtrack:c,input:d,lookahead:u}):null}}}return null}(e,t);case 7:return dy(e,t,Sy);default:return null}}var Cy=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new ct(t),{featureToLookups:r,lookupListOffset:o}=my(n),a=hy(n,o,Sy);return new e(a,r)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}collectLookupIndices(e){return by(this.featureToLookups,e)}applyLookupIndexAt(e,t,n){const r=this.lookups[e];if(!r||n<0||n>=t.length)return null;for(const o of r.subtables){const e=o.apply(t,n,this);if(null!==e)return e}return null}shape(e,t){const n=this.collectLookupIndices(t);for(const r of n){let t=0;for(;t<e.length;){const n=this.applyLookupIndexAt(r,e,t);t+=n&&n>0?n:1}}}};function ky(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 Ty(e){let t=0;for(let n=0;n<8;n+=1)e&1<<n&&(t+=1);return 2*t}function Py(e,t,n){switch(n){case 1:return function(e,t){e.seek(t);const n=e.u16(),r=t+e.u16();if(1===n){const t=ky(e,e.u16()),n=fy(e,r);return 0===t?null:{apply:(e,r,o)=>n(e[o])<0?null:(r[o]+=t,1)}}if(2===n){const t=e.u16(),n=e.u16(),o=Ty(t),a=e.tell(),i=new Array(n);for(let r=0;r<n;r+=1)e.seek(a+r*o),i[r]=ky(e,t);const s=fy(e,r);return{apply(e,t,r){const o=s(e[r]);if(o<0||o>=n)return null;const a=i[o];return 0===a?null:(t[r]+=a,1)}}}return null}(e,t);case 2:return function(e,t){e.seek(t);const n=e.u16(),r=t+e.u16(),o=e.u16(),a=e.u16(),i=!!(4&a);if(1===n){const n=e.u16(),s=py(e,n,t).map(t=>{e.seek(t);const n=e.u16(),r=/* @__PURE__ */new Map;for(let i=0;i<n;i+=1){const t=e.u16(),n=ky(e,o),i=ky(e,a);r.set(t,{secondGlyph:t,value1XAdvance:n,value2XAdvance:i})}return r}),l=fy(e,r);return{apply(e,t,n){const r=e[n+1];if(void 0===r)return null;const o=l(e[n]);if(o<0||o>=s.length)return null;const a=s[o].get(r);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=Ty(o),u=d+Ty(a),p=e.tell(),f=new Array(l*c),g=new Array(l*c);for(let t=0;t<l;t+=1)for(let n=0;n<c;n+=1){const r=(t*c+n)*u;e.seek(p+r),f[t*c+n]=ky(e,o),e.seek(p+r+d),g[t*c+n]=ky(e,a)}const m=fy(e,r),h=gy(e,n),b=gy(e,s);return{apply(e,t,n){const r=e[n],o=e[n+1];if(void 0===o)return null;if(m(r)<0)return null;const a=h(r),s=b(o);if(a>=l||s>=c)return null;const d=a*c+s,u=f[d],p=g[d];return 0===u&&0===p?null:(t[n]+=u,t[n+1]+=p,i?2:1)}}}return null}(e,t);case 9:return dy(e,t,Py);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 ct(t),{featureToLookups:r,lookupListOffset:o}=my(n),a=hy(n,o,Py);return new e(a,r)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}position(e,t,n){const r=by(this.featureToLookups,n);for(const o of r){const n=this.lookups[o];if(!n)continue;let r=0;for(;r<e.length;){let o=null;for(const a of n.subtables)if(o=a.apply(e,t,r),null!==o)break;r+=o&&o>0?o:1}}}},My=/* @__PURE__ */new Set(["kern"]),Ay=class{font;gsub;gpos;constructor(e){this.font=e;const t=e.getRawTableData("GSUB");this.gsub=t?Cy.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 r=t?.filter(e=>!My.has(e))??[],o=t?.filter(e=>My.has(e))??[];this.gsub&&r.length>0&&this.gsub.shape(n,r);const a=n.map(e=>this.font.advanceWidthForGlyph(e.id));this.gpos&&o.length>0&&this.gpos.position(n.map(e=>e.id),a,o);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),r=a[c];i.push({id:e.id,codePoints:e.codePoints,advanceWidth:t}),s.push({xAdvance:r}),l+=r}return{glyphs:i,positions:s,advanceWidth:l}}},Oy=class{font;constructor(e){this.font=e}layout(e){const t=[],n=[];let r=0;for(const o of e){const e=o.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}),r+=i}return{glyphs:t,positions:n,advanceWidth:r}}};function By(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Fy(e,t){return By(e).getUint16(t)}function Ey(e,t){return By(e).getInt16(t)}function Dy(e,t,n){By(e).setUint16(t,n,!1)}function Ly(e,t,n){By(e).setUint32(t,n,!1)}function Ny(e){return e+3&-4}function zy(e){const t=e.reduce((e,t)=>e+Ny(t.byteLength),0),n=new Uint8Array(t);let r=0;for(const o of e)n.set(o,r),r+=Ny(o.byteLength);return n}function $y(e,t){const n=[],r=By(e);if(0===t)for(let o=0;o+1<e.byteLength;o+=2)n.push(2*r.getUint16(o));else for(let o=0;o+3<e.byteLength;o+=4)n.push(r.getUint32(o));return n}function Hy(e,t){const n=e[t],r=e[t+1];return void 0===n||void 0===r?null:{start:n,end:r}}function jy(e,t){if(e.byteLength<10||Ey(e,0)>=0)return;let n=10,r=0;do{if(n+4>e.byteLength)throw new Error("Truncated composite glyph");r=Fy(e,n),t(Fy(e,n+2),n+2),n+=4,n+=1&r?4:2,8&r?n+=2:64&r?n+=4:128&r&&(n+=8)}while(32&r)}function Wy(e,t,n){const r=/* @__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 o=n.get(e.glyphForCodePoint(t));o&&r.set(t,o)}const o=[...r].sort(([e],[t])=>e-t),a=[];for(const[h,b]of o){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);Dy(i,0,12),Ly(i,4,i.length),Ly(i,12,a.length),a.forEach((e,t)=>{const n=16+12*t;Ly(i,n,e.start),Ly(i,n+4,e.end),Ly(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));Dy(d,0,4),Dy(d,2,c),Dy(d,6,2*l),Dy(d,8,2*e),Dy(d,10,Math.log2(e)),Dy(d,12,2*l-2*e),s.forEach((e,t)=>{Dy(d,14+2*t,e.end),Dy(d,16+2*l+2*t,e.start),Dy(d,16+4*l+2*t,e.gid-e.start&65535)})}if(d&&o.every(([e])=>e<65535)){const e=new Uint8Array(12+d.length);return Dy(e,2,1),Dy(e,4,3),Dy(e,6,1),Ly(e,8,12),e.set(d,12),e}const u=d?2:1,p=4+8*u,f=new Uint8Array(p+(d?.length??0)+i.length);Dy(f,2,u),d&&(Dy(f,4,3),Dy(f,6,1),Ly(f,8,p),f.set(d,p));const g=d?12:4,m=p+(d?.length??0);return Dy(f,g,3),Dy(f,g+2,10),Ly(f,g+4,m),f.set(i,m),f}function Uy(e,t,n,r){const o=e.getRawTableData("glyf"),a=e.getRawTableData("loca"),i=e.getRawTableData("head"),s=e.getRawTableData("hhea"),l=e.getRawTableData("maxp");if(!(o&&a&&i&&s&&l))throw new Error("Missing required TrueType tables for subsetting");const c=$y(a,Fy(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>o.length)throw new Error("Invalid glyph range");if(e.end===e.start)continue;const t=o.slice(e.start,e.end);jy(t,(e,r)=>{const o=n.get(e);if(void 0===o)throw new Error("Missing composite dependency");Dy(t,r,o)}),u.push(t),p+=Ny(t.length)}d.push(p);const f=function(e){const t=e.every(e=>e%2==0&&e<=131070),n=new Uint8Array(e.length*(t?2:4));return e.forEach((e,r)=>{t?Dy(n,2*r,e/2):Ly(n,4*r,e)}),{data:n,format:t?0:1}}(d),g=function(e,t,n){const r=e.getRawTableData("hmtx"),o=Fy(n,34);if(!r||o<1||o>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<o?4*e+2:4*o+2*(e-o),l=t<i?4*t+2:4*i+2*(t-i);t<i&&Dy(s,4*t,a[t]),By(s).setInt16(l,Ey(r,n))}),{data:s,longCount:i}}(e,t,s),m=i.slice();Ly(m,8,0),Dy(m,50,f.format);const h=s.slice();Dy(h,34,g.longCount);const b=l.slice();Dy(b,4,t.length);const y={cmap:Wy(e,r,n),head:m,hhea:h,maxp:b,hmtx:g.data,loca:f.data,glyf:zy(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),Ly(y.post,0,196608)),y}var Vy=class{createSubset(e,t){const n=/* @__PURE__ */new Map,r=[];for(const d of t)r.push(d.id),n.has(d.id)||n.set(d.id,d.codePoints);const o=function(e,t){const n=e.getRawTableData("glyf"),r=e.getRawTableData("loca"),o=e.getRawTableData("head");if(!n||!r||!o)return Array.from(/* @__PURE__ */new Set([0,...t])).sort((e,t)=>e-t);const a=$y(r,Fy(o,50)),i=/* @__PURE__ */new Set([0,...t]),s=Array.from(i);for(;s.length>0;){const t=s.pop(),r=Hy(a,t);if(!r||t>=e.glyphCount||r.end<r.start||r.end>n.byteLength)throw new Error("Invalid subset glyph range");r.end!==r.start&&jy(n.slice(r.start,r.end),e=>{i.has(e)||(i.add(e),s.push(e))})}return Array.from(i).sort((e,t)=>e-t)}(e,r),a=new Map(o.map((e,t)=>[e,t])),i=Uy(e,o,a,n),s=dn(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 o)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 _y=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 Ay(e);return{program:e,layouter:t.hasShaping?t:new Oy(e),subsetter:new Vy}}(function(e){const t=c.decodeSync(e);return qt.parse(t)}(e.fontData)),n=1e3/t.program.unitsPerEm,r={id:0,codePoints:[0],advanceWidth:t.program.advanceWidthForGlyph(0)};this.unicodeFontStates.set(e.resourceName,{resource:e,font:t,usedGlyphs:/* @__PURE__ */new Map([[0,r]]),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 r=this.layoutUnicodeText(e,t,n),o=this.encodeUnicodeGlyphRun(e,r);return 0===o.length?null:o.some(e=>Math.abs(e.nominalWidth-e.desiredAdvance)>.01)?`[${o.map(e=>{const t=e.nominalWidth-e.desiredAdvance;return 0===t?`<${iy(e.glyphId)}>`:`<${iy(e.glyphId)}> ${Gb(t)}`}).join(" ")}] TJ`:`<${o.map(e=>iy(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 r=`${n?.join(",")??""}\0${t}`,o=e.layoutCache.get(r);if(o)return o;const a=e.font.layouter.layout(t,n);return e.layoutCache.set(r,a),a}encodeUnicodeGlyphRun(e,t){return t.glyphs.map((n,r)=>{e.usedGlyphs.has(n.id)||e.usedGlyphs.set(n.id,n);const o=t.positions[r],a=n.advanceWidth*e.scale,i=(o?.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()),r=n.fontFile,o=t(oy(r,[`/Length1 ${r.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=`${Qb(`${e.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${Qb(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(Gb).join(" ")}]`,`/ItalicAngle ${Gb(a.italicAngle)}`,`/Ascent ${Gb(a.ascent*e.scale)}`,`/Descent ${Gb(a.descent*e.scale)}`,`/CapHeight ${Gb(a.capHeight*e.scale)}`,`/XHeight ${Gb(a.xHeight*e.scale)}`,"/StemV 0",`/FontFile2 ${o} 0 R`,">>"].join("\n")),u=[...e.usedGlyphs.keys()],p=Math.max(0,...u),f=new Uint8Array(2*(p+1)),g=new DataView(f.buffer);for(const v of u)g.setUint16(2*v,n.encodeGlyph(v));const m=u.every(e=>n.encodeGlyph(e)===e)?"/Identity":t(oy(f))+" 0 R",h=t(["<< /Type /Font","/Subtype /CIDFontType2",`/BaseFont /${l}`,"/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>",`/FontDescriptor ${d} 0 R`,`/W [${ay(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])=>"<"+Yb(e)+"> <"+ny([...t])+">"),n=[];for(let r=0;r<t.length;r+=100){const e=t.slice(r,r+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(oy((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"))}},Ky=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(ry(e.data,["/Filter /DCTDecode","/Type /XObject","/Subtype /Image",`/Width ${e.width}`,`/Height ${e.height}`,"/ColorSpace /DeviceRGB","/BitsPerComponent 8"]))}},qy=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:r}of this.shadings)t.set(n,this.addShadingObject(r,e));return t}addShadingObject(e,t){const n=t(function(e){if(2===e.length)return Xy(e[0].rgb,e[1].rgb);const t=[];for(let o=0;o<e.length-1;o+=1)t.push(Xy(e[o].rgb,e[o+1].rgb));const n=e.slice(1,-1).map(e=>Gb(e.offset)),r=e.slice(0,-1).map(()=>"0 1").join(" ");return["<< /FunctionType 3","/Domain [0 1]",`/Functions [${t.join(" ")}]`,`/Bounds [${n.join(" ")}]`,`/Encode [${r}]`,">>"].join("\n")}(function(e){const t=e.map(e=>({offset:Math.min(1,Math.max(0,e.offset)),rgb:Zb(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(Gb).join(" ")}]`,"/Domain [0 1]",`/Function ${n} 0 R`,"/Extend [true true]",">>"].join("\n"))}};function Xy(e,t){return["<< /FunctionType 2","/Domain [0 1]",`/C0 [${e.map(Gb).join(" ")}]`,`/C1 [${t.map(Gb).join(" ")}]`,"/N 1",">>"].join("\n")}var Gy=new TextEncoder;function Yy(e){return"string"==typeof e?(t=e,(new TextEncoder).encode(t).byteLength):e.length;var t}function Zy(e){return oy(Gy.encode(e))}function Jy(e){return e.replace(/[\\()]/g,e=>`\\${e}`)}function Qy(e){return`<FEFF${ny(Array.from(e).map(e=>e.codePointAt(0)??63))}>`}function ev(e){const t=[];if(e.title&&t.push(`/Title ${Qy(e.title)}`),e.author&&t.push(`/Author ${Qy(e.author)}`),e.subject&&t.push(`/Subject ${Qy(e.subject)}`),e.keywords&&t.push(`/Keywords ${Qy(e.keywords)}`),e.producer&&t.push(`/Producer (${Jy(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 tv(e){return e.children.reduce((e,t)=>e+1+tv(t),0)}function nv(e,t,n,r,o=[],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),f=r.buildShadingObjects(l),g=/* @__PURE__ */new Map;for(const M of e)for(const[e,t]of M.graphicsStateOpacities??[])g.has(e)||g.set(e,l(`<< /Type /ExtGState /ca ${Gb(t)} /CA ${Gb(t)} >>`));const m=[];for(const M of e){const e=l(Zy(`${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} >>`:"",r=Array.from(M.shadingResourceNames).map(e=>{const t=f.get(e);return t?`/${e} ${t} 0 R`:""}).filter(Boolean).join(" "),o=r?` /Shading << ${r} >>`:"",a=Array.from(M.graphicsStateOpacities?.keys()??[]).map(e=>`/${e} ${g.get(e)} 0 R`).join(" "),i=a?` /ExtGState << ${a} >>`:"",s=M.annotations.map(e=>{const t=e.x,n=e.x+e.width,r=M.height-e.y-e.height,o=M.height-e.y,a=void 0!==e.destName?`/A << /Type /Action /S /GoTo /D (${Jy(e.destName)}) >>`:`/A << /Type /Action /S /URI /URI (${Jy(e.uri??"")}) >>`;return l(["<< /Type /Annot /Subtype /Link",`/Rect [${Gb(t)} ${Gb(r)} ${Gb(n)} ${Gb(o)}]`,"/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 ${Gb(M.width)} ${Gb(M.height)}]`,`/Resources << /Font << ${u} >>${n}${o}${i} >>`,`/Contents ${e} 0 R${c}`,">>"].join("\n"));m.push(h)}let h;const b=o.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],r=e[t.pageIndex].height-t.y;return`(${Jy(t.name)}) [${n} 0 R /XYZ ${Gb(t.x)} ${Gb(r)} null]`}).join(" ")}] >>`)} 0 R >>`));const v=new Set(b.map(e=>e.name)),x=function(e){const t=[],n=[];for(const r of e){const e={title:r.title,destName:r.destName,children:[]};for(;n.length>0&&n[n.length-1].level>=r.level;)n.pop();0===n.length?t.push(e):n[n.length-1].node.children.push(e),n.push({node:e,level:r.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((r,o)=>{const a=r,i=o>0?e[o-1]:void 0,l=o<e.length-1?e[o+1]:void 0,c=["<< /Title "+Qy(r.title),`/Parent ${t} 0 R`,i?`/Prev ${i.id} 0 R`:"",l?`/Next ${l.id} 0 R`:"",`/Dest (${Jy(r.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 ${tv(r)}`)),c.push(">>"),s[a.id-1].body=c.filter(Boolean).join("\n"),n(r.children,a.id)})};n(x,y);const r=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 ${r}`,">>"].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=ev(i);e&&(w=l(e))}const I=[qb];let S=Yy(qb);const C=[0],k=e=>{I.push(e),S+=Yy(e)};for(const M of s)C[M.id]=S,k(`${M.id} 0 obj\n`),k(M.body),k("\nendobj\n");const T=S;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`;k(P);const R=void 0!==w?` /Info ${w} 0 R`:"";return k(["trailer",`<< /Size ${s.length+1} /Root ${c} 0 R${R} >>`,"startxref",String(T),"%%EOF",""].join("\n")),function(e){const t=e.reduce((e,t)=>e+Yy(t),0),n=new Uint8Array(t);let r=0;for(const o of e){const e="string"==typeof o?Gy.encode(o):o;n.set(e,r),r+=e.length}return n}(I)}var rv=class{pages=[];streams=[];fonts;images=new Ky;shadings=new qy;namedDestinations=[];outlineItems=[];documentInfo;constructor(e=Xb){this.fonts=new _y(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 cy(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,r){this.streams[e]?.rotateAbout(t,n,r)}clipRect(e,t,n,r,o){this.streams[e]?.clipRect(t,n,r,o)}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}),nv(this.pages,this.fonts,this.images,this.shadings,this.namedDestinations,this.outlineItems,this.documentInfo)}};function ov(e,t,n,r,o){if(0!==r.size||0!==o.size)return(a,i)=>{const s=ht(i),l=ht(n);for(const n of r.get(a)??[])e.addNamedDestination({name:n,pageIndex:t,x:l,y:s});const c=o.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 av(e){e=ba(e);const t=new Kb,n=b(e);await t.loadBundledUnicodeFaces({families:n}),await t.loadRemoteWebFontFaces({families:n});const r=new rv(t.getPdfFontResources());r.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 o=f(e),a=function(e){return gi(e)}(e),i=function(e){const t=/* @__PURE__ */new Map,n=e.bookmarks;if(!n)return t;for(const r of n.order){const e=n.items[r],o=e?.start?.paragraphId;if(!e||!o)continue;const a=t.get(o)??[];a.push(e.name),t.set(o,a)}return t}(e),s=new Map(Et(e).map(e=>[e.id,{level:e.level,title:e.text}]));for(const l of o.pages){const n=Math.max(1,ht(l.pageSettings.width)),o=Math.max(1,ht(l.pageSettings.height)),c=r.addPage({width:n,height:o});await Wb(r,c,n,o,e.design,e.sections?.[l.sectionIndex??0]?.pageBorder,e);const d=l.pageSettings.margins.left+l.pageSettings.margins.gutter,u=ka(l.pageSettings);await jb(r,c,l.headerBlocks,e,d,l.headerTop??ta(l.pageSettings),u,t,a,l.pageSettings);const p=l.bodyTop??Wa(l.pageSettings);if(l.blocks.some(e=>void 0!==e.columnIndex)){const n=ei(l.pageSettings),o=/* @__PURE__ */new Map;for(const e of l.blocks){const t=e.columnIndex??0,n=o.get(t)??[];n.push(e),o.set(t,n)}for(const[d,u]of o){const o=n[d]??n[0];await jb(r,c,u,e,o.left,p,o.width,t,a,l.pageSettings,ov(r,c,o.left,i,s))}}else await jb(r,c,l.blocks,e,d,p,u,t,a,l.pageSettings,ov(r,c,d,i,s));await jb(r,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&&r.drawLine(c,{x1:ht(d),y1:ht(l.footnoteSeparatorTop+.5),x2:ht(d+Math.min(180,.35*u)),y2:ht(l.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:ht(1)}),await sv(r,c,l.footnoteBlocks,l.footnoteReferenceIds??[],e,d,l.footnoteTop,u,t,a))}if(0===r.getPageCount()){const t=r.addPage({width:612,height:792});await Wb(r,t,612,792,e.design,void 0,e)}return r.toArrayBuffer()}async function iv(e){const t=await av(e);return new Blob([t],{type:"application/pdf"})}async function sv(e,t,n,r,o,a,i,s,l,c){let d=i;const u=/* @__PURE__ */new Set,p=new Map(r.map(e=>[e,$r(o,e)?.run.text??""]));for(const f of n){const n=r.find(e=>f.blockId.startsWith(`${e}:`));if(n&&!u.has(n)){const r=p.get(n);if(r){const n="paragraph"===f.sourceBlock.type?f.sourceBlock:void 0,i=Ho(void 0,n?.style?.styleId,o.styles),s=l.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});e.drawText(t,{x:ht(a),y:ht(d+12),text:r,fontSize:zn(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:s.writerResourceName})}u.add(n)}await jb(e,t,[f],o,a+24,d,Math.max(24,s-24),l,c),d+=Math.max(0,f.estimatedHeight)+2}}function lv(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}function cv(e){return new Promise(t=>{const n=URL.createObjectURL(e),r=document.createElement("iframe");r.setAttribute("aria-hidden","true"),r.style.position="fixed",r.style.right="0",r.style.bottom="0",r.style.width="0",r.style.height="0",r.style.border="0";let o=!1;const a=()=>{o||(o=!0,r.remove(),URL.revokeObjectURL(n),t())},i=()=>{if(!o){if(!window.open(n,"_blank")){const e=document.createElement("a");e.href=n,e.download="oasis-editor.pdf",e.click()}a()}};r.addEventListener("load",()=>{try{const e=r.contentWindow;if(!e)return void i();e.addEventListener("afterprint",a),globalThis.setTimeout(a,6e4),e.focus(),e.print()}catch{i()}}),r.src=n,document.body.appendChild(r)})}async function dv(e){return"function"==typeof e.arrayBuffer?e.arrayBuffer():new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>n(r.error??/* @__PURE__ */new Error("Failed to read file.")),r.onload=()=>{const e=r.result;e instanceof ArrayBuffer?t(e):n(/* @__PURE__ */new Error("Failed to read file as ArrayBuffer."))},r.readAsArrayBuffer(e)})}function uv(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 pv(e){return function(e){const t=Co(e),n=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;let o=0,a=0;for(const i of t){const t=Lo(i.style,e.styles);r.set(t.align,(r.get(t.align)??0)+1);for(const r of i.runs){const t=Ho(r.styles,i.style?.styleId,e.styles),s=t.fontFamily??"<null>";n.set(s,(n.get(s)??0)+1),null!==t.characterSpacing&&(o+=1),null!==t.characterScale&&(a+=1)}}return{paragraphCount:t.length,alignCounts:Array.from(r.entries()),fontCounts:Array.from(n.entries()),characterSpacingRuns:o,characterScaleRuns:a,firstParagraphs:t.slice(0,30).map((t,n)=>{const r=Lo(t.style,e.styles),o=t.runs[0],a=Ho(o?.styles,t.style?.styleId,e.styles);return{index:n,textLength:po(t).length,runCount:t.runs.length,rawParagraphStyle:t.style,align:r.align,indentFirstLine:r.indentFirstLine,lineGridPitch:r.lineGridPitch,lineGridType:r.lineGridType,fontFamily:a.fontFamily,fontSize:a.fontSize,characterSpacing:a.characterSpacing,characterScale:a.characterScale,firstRunStyle:o?.styles}})}}(e)}function fv(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 gv(e){return e?e.behindDoc?"behind":e.wrap&&"none"!==e.wrap?e.wrap:"front":"inline"}function mv(e,t){return{...e,positionV:{...e.positionV??{},relativeFrom:t?"page":"paragraph"}}}function hv(e){return"page"===e?.positionV?.relativeFrom}function bv(e){return Fi(e,e=>"image"===e.kind)}function yv(e,t,n){return Pv(e,e=>({...e,width:Math.max(24,Math.round(t)),height:Math.max(24,Math.round(n))}))}function vv(e){return!e||!Number.isFinite(e)||e<0?0:Math.min(e,.99)}function xv(e,t){return Pv(e,e=>{const n={...e},r=function(e){if(!e)return;const t=vv(e.left),n=vv(e.top),r=vv(e.right),o=vv(e.bottom),a=Math.min(r,Math.max(0,.99-t)),i=Math.min(o,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 r?n.crop=r: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 wv(e,t){const n=bv(e),r=n&&da(n.run);return r?xv(e,function(e,t){if("reset"===t)return{crop:null};const n=t,{width:r,height:o}=e;if(!Number.isFinite(n)||n<=0||r<=0||o<=0)return{crop:e.crop??null};const a=e.crop??{},i=vv(a.left),s=vv(a.top),l=vv(a.right),c=vv(a.bottom),d=r/o;if(d>n){const e=o*n,t=(r-e)/r*Math.max(0,1-i-l);return{crop:{...a,left:i+t/2,right:l+t/2},width:e}}if(d<n){const e=r/n,t=(o-e)/o*Math.max(0,1-s-c);return{crop:{...a,top:s+t/2,bottom:c+t/2},height:e}}return{crop:e.crop??null}}(r,t)):e}function Iv(e){const t=e.intrinsicWidth??e.width,n=e.intrinsicHeight??e.height,r=t>0&&n>0?t/n:e.width/Math.max(1,e.height),o=e.width/Math.max(1,e.height);if(!Number.isFinite(r)||!Number.isFinite(o))return{};if(r>o){const e=o/r,t=Math.max(0,(1-e)/2);return{left:t,right:t}}if(r<o){const e=r/o,t=Math.max(0,(1-e)/2);return{top:t,bottom:t}}return{}}function Sv(e){return Pv(e,e=>{const t={...e};return delete t.crop,delete t.cropFit,delete t.cropShape,t})}function Cv(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}function kv(e,t,n=90){const r=bv(e);if(!r||!da(r.run))return e;const o="right"===t?-n:n,a=Cv(function(e){const t=bv(e);return(t&&da(t.run))?.rotation??0}(e)+o);return Pv(e,e=>({...e,rotation:a}))}function Tv(e,t){const n=function(e){const t=bv(e),n=t&&da(t.run);return n?{flipH:Boolean(n.flipH),flipV:Boolean(n.flipV)}:null}(e);return n?Pv(e,"horizontal"===t?e=>({...e,flipH:!n.flipH}):e=>({...e,flipV:!n.flipV})):e}function Pv(e,t){const n=bv(e);if(!n||!da(n.run))return e;const r=xi(e),{paragraphIndex:o,run:a}=n,i=r.map((e,n)=>n!==o?eo(e):{...eo(e),runs:e.runs.map(e=>e.id===a.id&&"image"===e.kind?{...e,image:t(e.image)}:Ro(e))});return Cn(e,i,H(i,sa(e)))}function Rv(e,t){return Pv(e,e=>{const n=t(e.floating);if(n)return{...e,floating:n};const{floating:r,...o}=e;return o})}function Mv(e,t){const n=bv(e);if(!n)return e;const r=xi(e),{paragraphIndex:o,offset:a,run:i}=n,s=_a(r,t.paragraphId);if(s<0)return e;const l=r[s],c=To(l,t),d=s===o&&c>a?c-1:c;if(s===o&&d===a)return e;const p=e=>u(e,[...sn(e,0,a),...sn(e,a+1,Za(e))]),f=(e,t)=>we(e,Math.max(0,Math.min(t,Za(e))),[ko("",Qn(e,t),da(i))]),g=r.map((e,t)=>t===o&&t===s?f(p(e),d):t===o?p(e):t===s?f(e,d):ho([e])[0]),m=g[s],h=Math.max(0,Math.min(d+1,Za(m)));return Cn(e,g,J(Xo(m,h)))}function Av(e,t,n,r=0){const o=ka(fa(t));if(!n)return o;const a=_(t,n,r);return null!==a&&Number.isFinite(a)&&a>0?Math.min(o,a):o}function Ov(e){return{insertImageFromFile:async(t,n)=>{e.logger.info(`image insert:start name="${t.name}" type=${t.type} size=${t.size}`);const r=await dv(t),o=`data:${t.type};base64,${function(e){return btoa(new Uint8Array(e).reduce((e,t)=>e+String.fromCharCode(t),""))}(r)}`,a=new Image;a.src=o,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=Av(e.surfaceRef(),l.document,c,l.activeSectionIndex??0),u=i>d?d/i:1,p=Math.max(24,Math.round(i*u)),f=Math.max(24,Math.round(s*u));e.logger.info(`image insert:decoded natural=${i}x${s} fitted=${p}x${f} maxWidth=${d}`),e.applyTransactionalState(e=>function(e,t){const n=ri(e.selection)?e:te(e),{paragraph:r,index:o,offset:a}=ae(n),i=ko("",Qn(r,a),t),s=we(r,a,[i]),l=xi(n).map((e,t)=>t===o?s:eo(e));return Cn(n,l,J(Xo(s,a+1)))}(n?Ai(e,{anchor:n,focus:n}):e,{src:o,width:p,height:f,intrinsicWidth:i,intrinsicHeight:s}),{mergeKey:Zp})}}}var Bv={"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 Fv(e){return function(e){const[t,n]=$t(null),r=(e,t)=>{const[n,r]=Bv[e];return void 0!==t&&Number.isFinite(t)?Math.round(10*(n+(r-n)*Math.min(1,Math.max(0,t))))/10:r},o=(e,t)=>{n({phase:e,progress:r(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=ot(t);if(!n)return e.setImportPhase("error"),e.logger.error("import:unsupported-format",{name:t.name,type:t.type}),void e.clearImportProgressSoon();const r=e.now();e.logger.info("import:start",{format:n.id,name:t.name,size:t.size}),e.setImportPhase("reading-file");const o="docx"===n.id?e.requestLocalFontAccess().catch(()=>!1):Promise.resolve(!1);try{const a=e.now(),i=await dv(t);e.logger.info("import:phase",{phase:"reading-file",durationMs:Qt(e.now()-a,2)});let s=null,l=-1,c=0;const d=await n.import(i,(t,n)=>{const r=e.now(),o=void 0!==n&&Number.isFinite(n)?Math.floor(100*n):void 0,a=t!==s;if(!(a||void 0!==o&&(l<0||o-l>=1)||r-c>=40))return;s=t,l=o??l,c=r,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",pv(d));const u=e.now();e.setImportPhase("preparing-fonts"),await o,await e.prepareDocumentFonts(d),e.logger.info("import:phase",{phase:"preparing-fonts",durationMs:Qt(e.now()-u,2)}),e.setImportPhase("applying-editor-state"),e.resetEditorChromeState(),e.applyState(oi(d));const p=e.now();e.setImportPhase("stabilizing-layout"),await e.stabilizeLayoutAfterImport(),e.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:Qt(e.now()-p,2)});const f=_r(d).reduce((e,t)=>e+(t.header?.length??0)+t.blocks.length+(t.footer?.length??0),0),g=to(d).length;e.setImportPhase("done"),e.logger.info("import:done",{format:n.id,blocks:f,paragraphs:g,durationMs:Qt(e.now()-r,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:o,clearImportProgressSoon:a,now:()=>performance.now(),logger:e.logger}),s=Ov({state:e.state,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,logger:e.logger}),l=function(e){const t=e.download??lv,n=e.print??cv;let r=!1;return{handleExportDocx:async()=>{const n=await fu(e.document());return t(n,"oasis-editor.docx"),e.focusInput(),n},handleExportPdf:async()=>{const n=await iv(e.document());return t(n,"oasis-editor.pdf"),e.focusInput(),n},handlePrint:async()=>{const t=await iv(e.document());if(!r){r=!0;try{await n(t)}finally{r=!1}}return e.focusInput(),t},exportDocxBlob:()=>fu(e.document()),exportPdfBlob:()=>iv(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 Ev(e,t){return e.paragraph.runs.map(e=>e.text).join("")[t]??""}function Dv(e){return" "===e||"\t"===e||"\n"===e}function Lv(e,t,n){if(n.isCollapsed)return null;const r=t.get(e);return void 0===r||r<n.startIndex||r>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 Nv(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=Nv(n.blocks,t);if(e)return e}}return null}function zv(e,t){const n=sa(t),r=[],o=e.surfaceRect,a=new Map(xi(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,r=e.inlineImages.find(t)??e.floatingImages.find(t);if(r&&(i={paragraphId:r.paragraphId,startOffset:r.startOffset,endOffset:r.endOffset,left:r.left-o.left,top:r.top-o.top,width:r.width,height:r.height,rotation:r.rotation??0}),!i){const t=e=>e.paragraphId===n.start.paragraphId&&e.startOffset===n.startParagraphOffset&&e.endOffset===n.endParagraphOffset,r=e.floatingTextBoxes.find(t),a=r?void 0:e.inlineTextBoxes.find(t),i=r??a;i&&(s={paragraphId:i.paragraphId,startOffset:i.startOffset,endOffset:i.endOffset,left:i.left-o.left,top:i.top-o.top,width:i.width,height:i.height,rotation:i.rotation??0,floating:Boolean(r)})}}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 Si(e))for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter]){const n=Nv(e,t);if(n)return n}for(const n of Object.values(e.footnotes?.items??{})){const e=Nv(n.blocks,t);if(e)return e}return null}(t.document,l.tableId);if(n){const t=Vo(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),r.push({left:a.tableCell.left-o.left,top:a.tableCell.top-o.top,width:a.tableCell.width,height:a.tableCell.height}))}}}}}}if(!(d||n.isCollapsed||i||s))for(const w of e.paragraphs){const e=Lv(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&&Dv(Ev(w,e));)e+=1;for(;a>e&&Dv(Ev(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;r.push({left:s.left-o.left+1,top:d-o.top,width:Math.max(1,l.left-s.left+1-1),height:u})}}const u=t.selection.focus.paragraphId,p=e.paragraphsById.get(u)??[],f=p[0]?.paragraph,g=function(e,t){if(0===e.length)return null;const n=e.find(e=>t>=e.startOffset&&t<=e.endOffset)??e[e.length-1],r=n.lines.flatMap(e=>e.slots);if(0===r.length)return{left:n.left,top:n.top,height:Math.max(18,n.height)};let o=r[0],a=Math.abs(t-o.offset);for(const s of r){const e=Math.abs(t-s.offset);e<a&&(o=s,a=e)}const i=n.lines[0];return 0===n.startOffset&&void 0!==i&&t>=i.startOffset&&t<=i.endOffset&&o.top>n.top?{left:o.left,top:n.top,height:o.top+o.height-n.top}:{left:o.left,top:o.top,height:o.height}}(p,f?To(f,t.selection.focus):t.selection.focus.offset),m=(g?.left??o.left)-o.left,h=(g?.top??o.top)-o.top,b=Math.max(18,g?.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,r=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(const o of e.paragraphs){const e=o.tableCell;e&&e.tableId===x&&(t=Math.min(t,e.left),n=Math.min(n,e.top),r=Math.max(r,e.left+e.width),a=Math.max(a,e.top+e.height))}Number.isFinite(t)&&r>t&&a>n&&(v={tableId:x,left:t-o.left,top:n-o.top,width:r-t,height:a-n})}return{selectionBoxes:r,inputBox:{left:m,top:h,height:b},caretBox:y,selectedImageBox:i,selectedTextBoxBox:s,selectedTableBox:v}}function $v(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)$v(n.blocks,t);else t.push(n.id)}function Hv(e){const t=[],n=e=>{if(e)for(const r of e)if("paragraph"!==r.type)for(const e of r.rows)for(const t of e.cells)n(t.blocks);else for(const e of r.runs)t.push(e.text)};return n(e),t.join("").trim()}function jv(e){return e.cells.flatMap(e=>e.blocks)}function Wv(e){return e.rows.flatMap(jv)}function Uv(e){return{id:e.id,type:e.type,author:e.author,date:e.date}}function Vv(e){return{id:e.id,type:"property",author:e.author,date:e.date}}function _v(e){const t=[];return e.style?.revision&&t.push(Uv(e.style.revision)),e.style?.propertyRevision&&t.push(Vv(e.style.propertyRevision)),t}function Kv(e){const t=[];return e.style?.revision&&t.push(Uv(e.style.revision)),e.style?.propertyRevision&&t.push(Vv(e.style.propertyRevision)),e.propertyExceptionsRevision&&t.push(Vv(e.propertyExceptionsRevision)),t}function qv(e){const t=[];return e.style?.revision&&t.push(Vv(e.style.revision)),e.gridRevision&&t.push({id:e.gridRevision.id,type:"grid",author:e.gridRevision.author,date:e.gridRevision.date}),t}function Xv(e){const t=[],n=/* @__PURE__ */new Set,r=(e,r,o,a,i,s)=>{if(n.has(e.id))return;n.add(e.id);const l=[];$v(s,l),t.push({...e,scope:r,tableId:o,rowIndex:a,cellIndex:i,paragraphIds:l,snippet:Hv(s)})},o=e=>{if(e)for(const t of e)if("paragraph"!==t.type){for(const e of qv(t))r(e,"table",t.id,void 0,void 0,Wv(t));t.rows.forEach((e,n)=>{for(const o of Kv(e))r(o,"row",t.id,n,void 0,jv(e));e.cells.forEach((e,a)=>{for(const o of _v(e))r(o,"cell",t.id,n,a,e.blocks);o(e.blocks)})})}};for(const a of Si(e.document))for(const e of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])o(e);for(const a of Object.values(e.document.footnotes?.items??{}))o(a.blocks);for(const a of Object.values(e.document.endnotes?.items??{}))o(a.blocks);return t}function Gv(e){const t=[],n=/* @__PURE__ */new Set;return Si(e.document).forEach((e,r)=>{const o=e.propertyRevision;if(!o||n.has(o.id))return;n.add(o.id);const a=[];$v(e.blocks,a);const i=Hv(e.blocks);t.push({id:o.id,type:"property",author:o.author,date:o.date,sectionId:e.id,sectionIndex:r,paragraphIds:a,snippet:i.length>96?`${i.slice(0,93)}…`:i})}),t}var Yv={insertions:"showMarkupInsertions",deletions:"showMarkupDeletions",comments:"showMarkupComments",formatting:"showMarkupFormatting"};function Zv(e,t){return e[Yv[t]]??!0}function Jv(e,t){return"boolean"==typeof t.allAuthors?nx(e,t.allAuthors?void 0:[]):"string"==typeof t.author?function(e,t,n){const r=e.markupAuthors??[...n],o=rx(r.includes(t)?r.filter(e=>e!==t):[...r,t]),a=rx(n);return nx(e,o.length===a.length&&o.every((e,t)=>e===a[t])?void 0:o)}(e,t.author,ax(e)):t.section?function(e,t){const n=Yv[t],r=!(e[n]??!0);return e[n]===r?e:{...e,[n]:r}}(e,t.section):e}function Qv(e,t){return e.markupAuthors?.includes(t)??!0}function ex(e,t,n){return!("insert"===t&&!Zv(e,"insertions"))&&(!("delete"===t&&!Zv(e,"deletions"))&&(!("property"===t&&!Zv(e,"formatting"))&&Qv(e,n)))}function tx(e){const t=/* @__PURE__ */new Map;for(const n of Xv(e))if(ex(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 Gv(e))ex(e,n.type,n.author)&&t.push(...n.paragraphIds);return t}(e))t.has(n)||t.set(n,null);for(const n of Co(e.document)){const r=[];let o=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=ex(e,"property",s.author)):l=ex(e,a.type,a.author),l&&(i?r.push({start:Math.max(0,o-1),end:o+1}):n>0&&r.push({start:o,end:o+n})),i||(o+=n)}if(0===r.length)continue;const a=t.get(n.id);void 0===a?t.set(n.id,r):null!==a&&t.set(n.id,[...a,...r])}return t}function nx(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 rx(e){return[...new Set(e)].sort()}function ox(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 ax(e){const t=/* @__PURE__ */new Set,n=e=>{e&&t.add(e)},r=e=>{if(e)for(const o of e)if("paragraph"!==o.type){n(o.style?.revision?.author),n(o.gridRevision?.author);for(const e of o.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),r(t.blocks)}}else ox(o,t)},o=Co(e.document);for(const l of o)ox(l,t);for(const l of Si(e.document)){for(const e of[l.blocks,l.header,l.firstPageHeader,l.evenPageHeader,l.footer,l.firstPageFooter,l.evenPageFooter])r(e);n(l.propertyRevision?.author)}const a=e.document.footnotes?.items??{};for(const l of Object.values(a))r(l.blocks);const i=e.document.endnotes?.items??{};for(const l of Object.values(i))r(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 ix(e,t){const n=[];let r=0;for(const o of e.runs){const e=r,a=r+o.text.length;r=a;const i=o.revision,s=o.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&&ex(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 sx(e,t){const n=e.surfaceRect,r=[];for(const o of e.paragraphs){const e=ix(o.paragraph,t);if(0!==e.length)for(const t of o.lines)for(const o of e){const e=Math.max(o.start,t.startOffset),a=Math.min(o.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&&r.push({revisionId:o.revisionId,type:o.type,left:i.left-n.left,top:t.top-n.top,width:Math.max(1,s.left-i.left),height:t.height})}}return r.push(...function(e,t){const{surfaceRect:n}=e,r=[],o=/* @__PURE__ */new Set;for(const i of e.paragraphs){const e=i.tableCell;if(!e)continue;const t=`${e.tableId}:${e.rowIndex}:${e.cellIndex}`;o.has(t)||(o.add(t),r.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 Xv(t)){if(!ex(t,i.type,i.author))continue;const e=r.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 o=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:o-n.left,top:s-n.top,width:l-o,height:c-s})}return a}(e,t)),r.push(...function(e,t){const{surfaceRect:n}=e,r=[];for(const o of Gv(t)){if(!ex(t,o.type,o.author))continue;const a=new Set(o.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));r.push({revisionId:o.id,type:o.type,variant:"section",left:t-n.left,top:a-n.top,width:i-t,height:s-a})}}return r}(e,t)),r}var lx=e=>e.length>96?`${e.slice(0,93)}…`:e;function cx(e,t){const{surfaceRect:n}=e,r=e.paragraphs,o=/* @__PURE__ */new Map;for(const c of r){const e=c.left+c.width,t=o.get(c.pageIndex);(void 0===t||e>t)&&o.set(c.pageIndex,e)}const a=/* @__PURE__ */new Map;for(const c of e.pages??[]){const e=c.left+c.width,t=o.get(c.index)??e-Math.min(96,c.width),r=Math.max(0,e-t),i=Math.min(168,Math.max(84,r-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,r)=>{const o=t.get(e.id);if(o)return o.paragraphIds.push(...n),void(r&&o.snippetParts.push(r));t.set(e.id,{...e,paragraphIds:[...n],snippetParts:r?[r]:[]})};for(const r of Co(e.document))for(const e of r.runs){const t=e.revision,o=e.styles?.propertyRevision,a=!t||"insert"!==t.type&&"delete"!==t.type?o?{id:o.id,type:"property",author:o.author,date:o.date,scope:"run"}:void 0:{id:t.id,type:t.type,author:t.author,date:t.date,scope:"run"};a&&n(a,[r.id],e.text)}for(const r of Xv(e))n({id:r.id,type:r.type,author:r.author,date:r.date,scope:r.scope},r.paragraphIds,r.snippet);for(const r of Gv(e))n({id:r.id,type:r.type,author:r.author,date:r.date,scope:"section"},r.paragraphIds,r.snippet);return[...t.values()].map(e=>({id:e.id,type:e.type,author:e.author,date:e.date,scope:e.scope,snippet:lx(e.snippetParts.join("").trim()),paragraphIds:[...new Set(e.paragraphIds)]}))}(t)){if(!ex(t,c.type,c.author))continue;const e=new Set(c.paragraphIds);let o;for(const t of r)e.has(t.paragraphId)&&(!o||t.top<o.top)&&(o=t);if(!o||!a.has(o.pageIndex))continue;const s=o.lines[0];i.push({descriptor:c,pageIndex:o.pageIndex,top:(s?s.top:o.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),r=c.descriptor;l.push({revisionId:r.id,type:r.type,variant:"balloon",left:n.left,top:t,width:n.width,height:58,author:r.author,date:r.date,snippet:r.snippet})}return l}var dx={composeMeasuredParagraphLines:e=>mt.composeMeasuredParagraphLines(e),resolveRenderedLineHeightPx:(e,t)=>mt.resolveRenderedLineHeightPx(e,t)};function ux(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t)}function px(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>{const r=e?.[n];return r?.blockIndex===t.blockIndex&&r?.offset===t.offset})}function fx(){let e=/* @__PURE__ */new Map,t=/* @__PURE__ */new Map;return function(n){const r=/* @__PURE__ */new Map,o=t=>t?.map(t=>{const n=e.get(t.blockId),o=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&&ux(e.tableSegment?.startRowCellBlockStarts,t.tableSegment?.startRowCellBlockStarts)&&ux(e.tableSegment?.endRowCellBlockEnds,t.tableSegment?.endRowCellBlockEnds)&&px(e.tableSegment?.startRowCellBlockPositions,t.tableSegment?.startRowCellBlockPositions)&&px(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 r=e.lines[n];return void 0!==r&&r.startOffset===t.startOffset&&r.endOffset===t.endOffset&&r.top===t.top&&r.height===t.height})}(e.layout,t.layout))}(n,t)?n:t;return r.set(o.blockId,o),o}),a=n.pages.map(e=>{const n={...e,blocks:o(e.blocks)??[],headerBlocks:o(e.headerBlocks),footerBlocks:o(e.footerBlocks),footnoteBlocks:o(e.footnoteBlocks)},r=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 r=(e,t)=>(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t);return r(e.blocks,t.blocks)&&r(e.headerBlocks,t.headerBlocks)&&r(e.footerBlocks,t.footerBlocks)&&r(e.footnoteBlocks,t.footnoteBlocks)&&(o=e.footnoteReferenceIds,a=t.footnoteReferenceIds,(o?.length??0)===(a?.length??0)&&(a??[]).every((e,t)=>o?.[t]===e));var o,a}(r,n)?r:n});return e=r,t=new Map(a.map(e=>[e.id,e])),{pages:a}}}function gx(e,t){if(0===t.length)return e;let n;for(const r of t)Object.prototype.hasOwnProperty.call(e,r)&&(n??={...e},delete n[r]);return n??e}function mx(e){return function(e){const[t,n]=$t({}),[r,o]=$t({}),[a,i]=$t({left:0,top:0,height:28}),[s,l]=$t([]),[c,d]=$t([]),[u,p]=$t([]),[g,m]=$t([]),[h,b]=$t(null),[y,v]=$t(null),[x,w]=$t(null),[I,S]=$t({left:0,top:0,height:28,visible:!1}),[C,k]=$t(null),T=fx(),P=pr(()=>{zr();const t=void 0===(n=e.state.reviewDisplayMode)||"all"===n?null:"original"===n?"original":"final";var n;return null===t?e.state.document:Bt(e.state.document,t).document}),R=pr(()=>(zr(),T(f(P(),void 0,t(),r(),{measurer:dx})))),M=L();let A=0;const O=(t="selection")=>{const n=e.surfaceRef();if(!n)return l([]),d([]),p([]),m([]),b(null),v(null),w(null),void S(e=>({...e,visible:!1}));const r=M.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:R(),zoomFactor:e.zoomFactor?.()});if(!r)return l([]),d([]),p([]),m([]),b(null),v(null),w(null),void S(e=>({...e,visible:!1}));const o=e.state.reviewDisplayMode??"all";if("all"!==o)return l([]),b(null),v(null),w(null),S({left:0,top:0,height:28,visible:!1}),i({left:0,top:0,height:28}),d([]),p([]),void m("simple"===o&&!1!==e.state.showRevisionMarkup?function(e,t){const n=tx(t);if(0===n.size)return[];const r=e.surfaceRect,o=/* @__PURE__ */new Map;for(const s of e.paragraphs){const e=o.get(s.pageIndex);(void 0===e||s.left<e)&&o.set(s.pageIndex,s.left)}const a=/* @__PURE__ */new Map;for(const s of e.pages??[]){const e=o.get(s.index),t=void 0===e?0:e-s.left;a.set(s.index,s.left+(t>0?.5*t:12)-r.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-r.left-12,o=s.lines;if(0===o.length){i.push({paragraphId:s.paragraphId,left:t,top:s.top-r.top,height:Math.max(1,s.height)});continue}const l=null===e?o:o.filter(t=>e.some(e=>e.start<t.endOffset&&e.end>t.startOffset)),c=l.length>0?l:[o[0]];for(const n of c)i.push({paragraphId:s.paragraphId,left:t,top:n.top-r.top,height:Math.max(1,n.height)})}return i}(r,e.state):[]);const a=zv(r,e.state);m([]),l(a.selectionBoxes),p(!1===e.state.showRevisionMarkup?[]:[...sx(r,e.state),...cx(r,e.state)]),d(function(e,t){const n=t.document.comments;if(!n||0===n.order.length||!Zv(t,"comments"))return[];const r=e.surfaceRect,o=new Map(xi(t).map((e,t)=>[e.id,t])),a=[];for(const i of n.order){const s=n.items[i];if(!s?.start||!s?.end||!Qv(t,s.author))continue;const l=o.get(s.start.paragraphId),c=o.get(s.end.paragraphId);if(void 0!==l&&void 0!==c)for(const t of e.paragraphs){const e=o.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 o of t.lines){const e=Math.max(u,o.startOffset),t=Math.min(p,o.endOffset);if(e>=t)continue;const n=o.slots.find(t=>t.offset===e),s=o.slots.find(e=>e.offset===t)??o.slots[o.slots.length-1];n&&s&&a.push({commentId:i,left:n.left-r.left,top:o.top-r.top,width:Math.max(1,s.left-n.left),height:o.height})}}}return a}(r,e.state)),b(a.selectedImageBox),v(a.selectedTextBoxBox),w(a.selectedTableBox),i(a.inputBox),S(a.caretBox)},B=(e="selection")=>{const t=++A;queueMicrotask(()=>{t===A&&O(e)})},F=(e="content-change")=>(B(e),!1),E=(e,t={})=>(t.paragraphIds&&t.paragraphIds.length>0&&(o(e=>gx(e,t.paragraphIds??[])),Ie()),B(e),t.resolveWhenDone?Promise.resolve():null),D=t=>{if(!e.isImporting?.()){if(t.dirtyAll||t.structureChanged)n({}),o({}),Ie();else if((t.dirtyParagraphIds?.length??0)>0){const e=t.dirtyParagraphIds??[];o(t=>gx(t,e)),Ie()}B("content-change")}},N=async()=>{n({}),o({}),Ie(),await new Promise(e=>{var t;t=()=>e(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>t()):globalThis.setTimeout(t,16)}),B("import")};bn(()=>{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,B("selection")}),bn(()=>{e.state.document,e.state.activeSectionIndex,e.state.activeZone,e.isImporting?.()||B("content-change")}),bn(()=>{e.state.showRevisionMarkup,e.state.showMarkupInsertions,e.state.showMarkupDeletions,e.state.showMarkupComments,e.state.showMarkupFormatting,e.state.markupAuthors,B("content-change")}),bn(()=>{e.state.reviewDisplayMode,B("content-change")}),bn(()=>{const t=e.viewportRef();if(!t)return;const n=()=>{B("scroll")},r=()=>{B("resize")};t.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",r),_t(()=>{t.removeEventListener("scroll",n),window.removeEventListener("resize",r)})});const z=()=>k(null),$=()=>{A+=1,M.clear()};return{measuredBlockHeights:t,measuredParagraphLayouts:r,documentLayout:R,canvasSnapshotProvider:M,inputBox:a,selectionBoxes:s,commentHighlights:c,revisionMarkupBoxes:u,changeBarBoxes:g,selectedImageBox:h,selectedTextBoxBox:y,selectedTableBox:x,caretBox:I,preferredColumnX:C,setPreferredColumnX:k,clearPreferredColumn:z,requestInputBoxSync:B,scheduleDeferredLayoutMeasurement:E,stabilizeLayoutAfterImport:N,syncMeasuredLayoutMetrics:F,syncInputBox:O,setMeasuredBlockHeights:n,setMeasuredParagraphLayouts:o,applyInvalidation:D,onCleanupHook:$}}(e)}function hx(e){return Array.isArray(e)?e.map(hx):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,hx(t)])):e}function bx(e){const{builtinStyle:t,customStyle:n,...r}=e;return JSON.stringify(hx(r))}var yx=new Map(Object.values(Zo).flatMap(e=>{const t=D(e);return t?[[e.id,{key:t,signature:bx(e)}]]:[]}));function vx(e){if(!0===e.customStyle||void 0!==e.builtinStyle)return;const t=yx.get(e.id);return t?.signature===bx(e)?t.key:void 0}function xx(e,t,n){const[r,o]=$t("Initial"),[a,i]=$t(!1),s=()=>n.enabled??!1,l=n.persistence,c=ve(async e=>{if(s()&&a()){o("Saving...");try{const t=JSON.parse(JSON.stringify(Sn(e)));await l.saveDocument(t),o("Saved")}catch(t){n.logger?.error("persistence:autosave failed",t),o("Error")}}},1e3);return bn(Yt(()=>e.document,e=>{s()&&a()&&c(e)},{defer:!0})),it(async()=>{if(!s())return i(!0),void o("Saved");try{const e=await l.loadDocument();e&&t(function(e){if(e.sourcePackage||!e.styles)return e;let t;for(const[n,r]of Object.entries(e.styles)){const o=vx(r);o&&(t??={...e.styles},t[n]={...r,builtinStyle:o})}return t?{...e,styles:t}:e}(e))}catch(e){n.logger?.error("persistence:load failed",e)}finally{i(!0),o("Saved")}}),{status:r}}function wx(e,t){const n=Math.max(0,249),r=Math.max(0,e.length-n);return[...e.slice(r),t]}function Ix(e){return function(e){const t=(e,t)=>{const n=_r(e.document),r=Math.max(0,Math.min(ya(e),n.length-1)),o=Yo(e),a=n[r];if(!a)return e;const i=[...n],s={...a},l=Ma("");if("header"===o){const e=[...a.header??[]];t<0?e.unshift(l):e.push(l),s.header=e}else if("footer"===o){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[r]=s,{...e,document:{...e.document,sections:i}}},n=()=>{const t=(n=e.getHistoryState(),r=e.stateSnapshot(),0===n.undoStack.length?null:{history:{undoStack:n.undoStack.slice(0,-1),redoStack:wx(n.redoStack,r),lastTransactionMeta:null},nextState:n.undoStack[n.undoStack.length-1]});var n,r;t&&(e.updateHistoryState(()=>t.history),e.clearPreferredColumn(),e.applyHistoryState(t.nextState),e.focusInput())},r=()=>{const t=(n=e.getHistoryState(),r=e.stateSnapshot(),0===n.redoStack.length?null:{history:{undoStack:wx(n.undoStack,r),redoStack:n.redoStack.slice(0,-1),lastTransactionMeta:null},nextState:n.redoStack[n.redoStack.length-1]});var n,r;t&&(e.updateHistoryState(()=>t.history),e.clearPreferredColumn(),e.applyHistoryState(t.nextState),e.focusInput())},o=n=>{const r=e.imageOps().getSelectedImageInfo(e.state());if(!r)return!1;const o=xi(e.state()),a=o.findIndex(e=>e.id===r.paragraph.id);if(a<0)return!1;const i=a+n;if(i<0||i>=o.length){const r=e.state(),o=t(r,n),a=xi(o),i=n<0?a[0]:a[a.length-1];if(!i)return!1;const s=Xo(i,n<0?Za(i):0);return e.applyTransactionalState(()=>Mv(o,s),{mergeKey:Qp}),e.focusInput(),!0}const s=o[i],l=n<0?Za(s):0;return e.applyTransactionalState(e=>Mv(e,Xo(s,l)),{mergeKey:Qp}),e.focusInput(),!0},a=t=>{const n=e.stateSnapshot();e.applyHistoryState({...n,document:{...n.document,sections:n.document.sections?.map(Xt)},selection:{anchor:{...t.anchor},focus:{...t.focus}}})};return{performUndo:n,performRedo:r,moveSelectedImageByParagraph:o,applySelectionPreservingStructure:a}}(e)}function Sx(e={}){const t=e.dbName??"oasis-editor-db",n=e.storeName??"documents",r=e.key??"current-document";let o=null;async function a(){return o||(o=await function(e){return new Promise((t,n)=>{const r=indexedDB.open(e.name,e.version);r.onerror=()=>{n(/* @__PURE__ */new Error(`Failed to open IndexedDB: ${r.error?.message}`))},r.onsuccess=()=>{t(r.result)},r.onupgradeneeded=t=>{const n=r.result;e.onUpgrade(n,t.oldVersion,t.newVersion)}})}({name:t,version:1,onUpgrade:e=>{e.objectStoreNames.contains(n)||e.createObjectStore(n)}}),o)}return{async saveDocument(e){await function(e,t,n,r){return new Promise((o,a)=>{try{const i=e.transaction([t],"readwrite"),s=i.objectStore(t).put(r,n);s.onerror=()=>{a(/* @__PURE__ */new Error(`Failed to put item in ${t}: ${s.error?.message}`))},i.oncomplete=()=>{o()},i.onabort=i.onerror=()=>{a(/* @__PURE__ */new Error(`Transaction failed putting item in ${t}: ${i.error?.message}`))}}catch(i){a(i)}})}(await a(),n,r,e)},loadDocument:async()=>function(e,t,n){return new Promise((r,o)=>{try{const a=e.transaction([t],"readonly").objectStore(t).get(n);a.onerror=()=>{o(/* @__PURE__ */new Error(`Failed to get item from ${t}: ${a.error?.message}`))},a.onsuccess=()=>{r(a.result??null)}}catch(a){o(a)}})}(await a(),n,r),async clearDocument(){await function(e,t,n){return new Promise((r,o)=>{try{const a=e.transaction([t],"readwrite"),i=a.objectStore(t).delete(n);i.onerror=()=>{o(/* @__PURE__ */new Error(`Failed to delete item from ${t}: ${i.error?.message}`))},a.oncomplete=()=>{r()},a.onabort=a.onerror=()=>{o(/* @__PURE__ */new Error(`Transaction failed deleting item from ${t}: ${a.error?.message}`))}}catch(a){o(a)}})}(await a(),n,r)},close(){o&&(o.close(),o=null)}}}function Cx(e){return function(e){const[t,n]=$t([]),[r,o]=$t([]);let a={undoStack:[],redoStack:[],lastTransactionMeta:null};const i=()=>{n(a.undoStack),o(a.redoStack)},s=t=>{e.commitState(e.cloneState(t))},l=(t,n)=>{const r=e.stateSnapshot(),o=On("txn:produce",()=>t(r),0);if(o===r)return;a=function(e,t,n,r,o=Date.now()){return{undoStack:void 0!==r?.mergeKey&&e.lastTransactionMeta?.mergeKey===r.mergeKey&&o-e.lastTransactionMeta.timestamp<1e3?e.undoStack:wx(e.undoStack,t),redoStack:[],lastTransactionMeta:r?.mergeKey?{mergeKey:r.mergeKey,timestamp:o}:null}}(a,r,0,n),i();const s=On("txn:invalidate",()=>function(e,t){if(e===t||e.document===t.document)return{};const n=e=>_r(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 r=xi(e),o=xi(t),a=/* @__PURE__ */new Map;for(const s of r)a.set(s.id,s);const i=[];for(const s of o){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 r=e.runs[n],o=s.runs[n];if(r===o)continue;if(r.id!==o.id||r.text!==o.text){t=!0;break}const a=da(r),i=da(o);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}}(r,o),0);e.applyLayoutInvalidation(s),On("txn:setState",()=>e.commitState(o),0)};return{undoStack:t,redoStack:r,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 kx(e){let t=e.state.document,n=e.state.selection;bn(()=>{const r=e.state.document,o=e.state.selection,a=r!==t,i=o!==n;var s;if(t=r,n=o,e.state.activeSectionIndex,e.state.activeZone,s=e.state,$p&&(Wp={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:r,state:o,commitState:a,getStateSnapshot:i,applyState:s,cloneState:l,isReadOnly:c,focusInput:d,surfaceRef:u,viewportRef:p,zoomFactor:f,getImageOps:g}=e,m=Fv({state:()=>o,applyState:s,applyTransactionalState:(e,t)=>W(e,t),isReadOnly:c,surfaceRef:()=>u()??null,stabilizeLayoutAfterImport:async()=>{await F()},resetEditorChromeState:()=>G(),focusInput:d,requestLocalFontAccess:Rr,prepareDocumentFonts:async e=>{await Fr(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:I,commentHighlights:S,revisionMarkupBoxes:C,changeBarBoxes:k,selectedImageBox:T,selectedTextBoxBox:P,selectedTableBox:R,caretBox:M,preferredColumnX:A,setPreferredColumnX:O,clearPreferredColumn:B,stabilizeLayoutAfterImport:F,setMeasuredBlockHeights:E,setMeasuredParagraphLayouts:D,applyInvalidation:L,onCleanupHook:N}=mx({state:o,surfaceRef:u,viewportRef:p,isImporting:h,zoomFactor:f}),z=Sx({key:t().persistenceKey}),{status:$}=xx(o,e=>{n.info("persistence:loaded",{docId:e.id});const t=oi(e);a(t),G()},{enabled:t().persistenceEnabled??!1,persistence:t().persistence??z,logger:n}),{undoStack:H,redoStack:j,applyTransactionalState:W,applyHistoryState:U,resetTransactionGrouping:V,updateHistoryState:_,getHistoryState:K,clearHistory:q}=Cx({stateSnapshot:i,commitState:a,cloneState:l,applyLayoutInvalidation:L}),X=Ix({state:()=>o,stateSnapshot:i,applyHistoryState:U,applyTransactionalState:W,focusInput:d,clearPreferredColumn:B,imageOps:g,updateHistoryState:_,getHistoryState:K}),G=()=>{B(),E({}),D({}),Ie(),x.clear(),q()};return kx({state:o,isImportInProgress:h,cloneState:l,getStateSnapshot:i,getOnStateChange:()=>t().onStateChange,emit:r.emit}),{docIO:m,isImportInProgress:h,measuredBlockHeights:b,measuredParagraphLayouts:y,documentLayout:v,canvasSnapshotProvider:x,inputBox:w,selectionBoxes:I,commentHighlights:S,revisionMarkupBoxes:C,changeBarBoxes:k,selectedImageBox:T,selectedTextBoxBox:P,selectedTableBox:R,caretBox:M,preferredColumnX:A,setPreferredColumnX:O,clearPreferredColumn:B,stabilizeLayoutAfterImport:F,setMeasuredBlockHeights:E,setMeasuredParagraphLayouts:D,applyLayoutInvalidation:L,onCleanupHook:N,fallbackPersistence:z,persistenceStatus:$,undoStack:H,redoStack:j,applyTransactionalState:W,applyHistoryState:U,resetTransactionGrouping:V,updateHistoryState:_,getHistoryState:K,clearHistory:q,historyActions:X,resetEditorChromeState:G}}(e)}function Px(e){return Fi(e,e=>"textBox"===e.kind)}function Rx(e,t){const n=Px(e);if(!n||!za(n.run))return e;const r=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}(t),{paragraphIndex:o,run:a}=n,i=xi(e).map((e,t)=>t!==o?eo(e):{...eo(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:r}}:Ro(e))});return Cn(e,i,H(i,sa(e)))}function Mx(e,t){const n=Px(e);if(!n||!za(n.run))return e;const{paragraphIndex:r,run:o}=n,a=xi(e).map((e,n)=>n!==r?eo(e):{...eo(e),runs:e.runs.map(e=>{if(e.id!==o.id||"textBox"!==e.kind)return Ro(e);const n=t(e.textBox.floating),r={...e.textBox};return n?r.floating=n:delete r.floating,{...e,textBox:r}})});return Cn(e,a,H(a,sa(e)))}function Ax(e,t,n,r={}){const o=Px(e),a=o&&za(o.run);if(!o||!a)return e;const i=r.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:f}=o,g=d-a.width,m=u-a.height,h=xi(e).map((e,t)=>t!==p?eo(e):{...eo(e),runs:e.runs.map(e=>{if(e.id!==f.id||"textBox"!==e.kind)return Ro(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,r,o){let a=e;if(r&&0!==t){const n=e.positionH;n?.align||(a={...a,positionH:{...n??{},offset:(n?.offset??0)-t*oa}})}if(o&&0!==n){const e=a.positionV;e?.align||(a={...a,positionV:{...e??{},offset:(e?.offset??0)-n*oa}})}return a}(t.floating,g,m,l,c)),{...e,textBox:n}})});return Cn(e,h,H(h,sa(e)))}var Ox=e=>e.cells.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),Bx=e=>e.rows.reduce((e,t)=>Math.max(e,Ox(t)),0),Fx=(e,t)=>{let n=0;for(const r of e.cells){const e=Math.max(1,r.colSpan??1);if(t>=n&&t<n+e)return r;n+=e}return null};function Ex(e){if(!e)return null;for(const t of e.blocks){const e=Mo(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=Ex(e);if(t)return t}return null};function Lx(e,t){return e.some(e=>Mo(e).some(e=>e.id===t))}var Nx=(e,t,n)=>{const r=Ra(e,t);if(!r)return{kind:"outside"};const o=wo(e,t,r.sectionIndex);if(!o)return{kind:"outside"};const a=function(e,t,n){for(const r of e){if(!Lx(r,n))continue;const e=bo(r,t),o=e?.[e.length-1]?.table;if(o)return o}return null}(function(e,t){const n=Ra(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 r=Si(e)[n.sectionIndex];return r?"main"===n.zone?[r.blocks]:"header"===n.zone?[r.header,r.firstPageHeader,r.evenPageHeader].filter(e=>Boolean(e)):[r.footer,r.firstPageFooter,r.evenPageFooter].filter(e=>Boolean(e)):[]}(e,t),o.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=>Mo(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(Mo),p=d?u[0]:c.blocks.find(e=>"paragraph"===e.type)??u[0];if(!p)return{kind:"blocked"};const f=d?u[u.length-1]:p;return{kind:"adjacent",selection:{anchor:Xo(p,0),focus:Xo(f,Za(f))}}},zx=(e,t,n)=>{const r=Nx(e,t,n);return"adjacent"===r.kind?r.selection.anchor:null};function $x(e,t){return Boolean(e?.some(e=>Mo(e).some(e=>e.id===t)))}function Hx(e,t,n){if("main"===n)return"blocks";const r=e.selection.focus.paragraphId;return"header"===n?[["header",t.header],["firstPageHeader",t.firstPageHeader],["evenPageHeader",t.evenPageHeader]].find(([,e])=>$x(e,r))?.[0]??"header":"footer"===n?[["footer",t.footer],["firstPageFooter",t.firstPageFooter],["evenPageFooter",t.evenPageFooter]].find(([,e])=>$x(e,r))?.[0]??"footer":"blocks"}function jx(e){const t=Ra(e.document,e.selection.focus.paragraphId);return"footnote"===t?.zone?t.footnoteId:e.activeFootnoteId}function Wx(e,t){if("footnote"===t){const t=jx(e);return t?e.document.footnotes?.items[t]?.blocks??[]:[]}const n=_r(e.document),r=ya(e),o=n[Math.max(0,Math.min(r,n.length-1))];if(!o)return[];const a=Hx(e,o,t);return"blocks"===a?o.blocks:o[a]??[]}var Ux=(e,t,n="main")=>{if("footnote"===n){const n=jx(e),r=e.document.footnotes,o=n?r?.items[n]:void 0;return n&&r&&o?{...e,document:{...e.document,footnotes:{...r,items:{...r.items,[n]:{...o,blocks:t}}}}}:e}const r=ya(e),o=_r(e.document),a=Math.max(0,Math.min(r,o.length-1)),i=o[a];if(!i)return e;const s=Hx(e,i,n),l=[...o];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 _x(e,t){const n=bo(e,t.tablePath),r=n?.[n.length-1];return r?{tableBlock:r.table,targetCell:r.cell,location:Vx(t),targetBlocks:e}:null}function Kx(e,t,n){const r=n.tablePath[0];if(!r)return null;const o=t(e,n.zone),a=o[r.tableBlockIndex];if(!a||"table"!==a.type)return null;const i=[...o];return i[r.tableBlockIndex]=Tn(a),_x(i,n)}var qx=(e,t,n)=>{const r=Ra(e.document,e.selection.focus.paragraphId),o=Ra(e.document,e.selection.anchor.paragraphId);if(!r||!o)return n(e);if(r.zone!==o.zone||r.sectionIndex!==o.sectionIndex||r.footnoteId!==o.footnoteId)return e;const a=wo(e.document,e.selection.focus.paragraphId,ya(e)),i=r.zone;let s,l;if(a){const n=function(e,t,n){const r=n.tablePath[0];if(!r)return null;const o=t(e,n.zone),a=o[r.tableBlockIndex];return a&&"table"===a.type?_x(function(e,t){const n=[...e];let r=n;for(let o=0;o<t.length;o+=1){const e=t[o];if(!e)break;const n=r[e.tableBlockIndex];if(!n||"table"!==n.type)break;const a={...n,rows:[...n.rows]};r[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,r=c.blocks}return n}(o,n.tablePath),n):null}(e,t,a);if(!n)return e;s=n.targetBlocks,l=n.targetCell.blocks}else{const r=t(e,i);if(r.length&&r.every(e=>"paragraph"===e.type)&&r.some(t=>t.id===e.selection.anchor.paragraphId)&&r.some(t=>t.id===e.selection.focus.paragraphId))return n(e);s=[...r],l=s}const c=function(e,t){const n=e.findIndex(e=>"paragraph"===e.type&&e.id===t.anchor.paragraphId),r=e.findIndex(e=>"paragraph"===e.type&&e.id===t.focus.paragraphId);if(n<0||r<0)return null;let o=Math.min(n,r),a=Math.max(n,r)+1;if(e.slice(o,a).some(e=>"paragraph"!==e.type))return null;for(;o>0&&"paragraph"===e[o-1]?.type;)o--;for(;a<e.length&&"paragraph"===e[a]?.type;)a++;return{start:o,end:a}}(l,e.selection);if(!c)return e;const d=Ea(l.slice(c.start,c.end).map(e=>"paragraph"===e.type?eo(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),f=_r(p.document)[0]?.blocks??[];if(p===u&&JSON.stringify(f)===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,...f);const g=Ux(e,s,i),m=xi(e),h=xi(g),b=e.document.bookmarks,y=e.document.comments;return{...g,document:{...g.document,...b?{bookmarks:yr(b,m,h)}:{},...y?{comments:lt(y,m,h)}:{}},selection:p.selection}};function Xx(e,t){const n=wo(e.document,e.selection.focus.paragraphId,ya(e));return n?Kx(e,t,n):null}function Gx(e,t,n,r){const o=Ux(e,t,n);return r?{...o,selection:{anchor:Xo(r,0),focus:Xo(r,0)}}:o}function Yx(e,t,n,r){const o=t.getTargetBlocks(e,n),a=bo(o,r);return a?.[a.length-1]?.table??null}function Zx(e,t){const n=wo(e.document,e.selection.focus.paragraphId,ya(e)),r=n?.tablePath[n.tablePath.length-1];if(!n||!r)return null;const o=Yx(e,t,n.zone,n.tablePath);return o?{table:o,rowIndex:r.rowIndex,cellIndex:r.cellIndex}:null}function Jx(e){return function(e){const t=t=>{const n=e.resolveHorizontalTableCellRange(t);return Boolean(n&&n.endCellIndex>n.startCellIndex)},n=t=>{const n=Zx(t,e);if(!n)return!1;const r=n.table.rows[n.rowIndex]?.cells[n.cellIndex];return Boolean((r?.colSpan??1)>1)},r=t=>{const n=e.resolveVerticalTableCellRange(t);if(!n)return!1;const r=Yx(t,e,n.zone,n.tablePath);if(!r)return!1;for(let e=n.startRowIndex;e<=n.endRowIndex;e+=1){const t=r.rows[e]?.cells[n.cellIndex];if(!t||"continue"===t.vMerge||1!==t.blocks.length||"paragraph"!==t.blocks[0]?.type)return!1}return!0},o=e=>t(e)||r(e),a=t=>{const n=Zx(t,e);if(!n)return!1;const r=n.table.rows[n.rowIndex]?.cells[n.cellIndex];return Boolean((r?.rowSpan??1)>1&&"restart"===r?.vMerge)},i=e=>n(e)||a(e),s=t=>null!==Zx(t,e),l=t=>{const n=Zx(t,e);return Boolean(n&&Bx(n.table)>1)};return{canMergeSelectedTableCells:t,canSplitSelectedTableCell:n,canMergeSelectedTableRows:r,canMergeSelectedTable:o,canSplitSelectedTableCellVertically:a,canSplitSelectedTable:i,canEditSelectedTableRow:s,canEditSelectedTableColumn:l}}(e)}function Qx(e,t){return e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex!==t.visualColumnIndex?e.visualColumnIndex-t.visualColumnIndex:0}function ew(e){return e.blocks.flatMap(Mo)}function tw(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function nw(e,t){return function(e,t){const n=e.selection,r=ya(e),o=wo(e.document,n.anchor.paragraphId,r),a=wo(e.document,n.focus.paragraphId,r);if(!o||!a||o.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 r=e[n],o=t[n];if(r.tableBlockIndex!==o.tableBlockIndex)return!1;if(n<e.length-1&&(r.rowIndex!==o.rowIndex||r.cellIndex!==o.cellIndex))return!1}return!0}(o.tablePath,a.tablePath))return null;const i=t.getTargetBlocks(e,o.zone),s=bo(i,o.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=tw(o),p=tw(a),f=c.table,g=Vo(f),m=g.find(e=>e.rowIndex===u.rowIndex&&e.cellIndex===u.cellIndex),h=g.find(e=>e.rowIndex===p.rowIndex&&e.cellIndex===p.cellIndex);return m&&h?{anchorLocation:u,focusLocation:p,anchorCell:m,focusCell:h,tableBlock:f,tableLayout:g}:null}(e,t)}function rw(e){return function(e){const t=t=>{const n=t.selection,r=nw(t,e);if(!r||r.anchorLocation.rowIndex===r.focusLocation.rowIndex&&r.anchorLocation.cellIndex===r.focusLocation.cellIndex)return e.logger?.debug(`resolveTableCellRangeSelection: no expansion (anchor=${n.anchor.paragraphId} focus=${n.focus.paragraphId})`),null;const o=Math.min(r.anchorLocation.rowIndex,r.focusLocation.rowIndex),a=Math.max(r.anchorLocation.rowIndex,r.focusLocation.rowIndex),i=Math.min(r.anchorLocation.cellIndex,r.focusLocation.cellIndex),s=Math.max(r.anchorLocation.cellIndex,r.focusLocation.cellIndex);e.logger?.info(`resolveTableCellRangeSelection: expanding r${r.anchorLocation.rowIndex}:c${r.anchorLocation.cellIndex}->r${r.focusLocation.rowIndex}:c${r.focusLocation.cellIndex} (anchor=${n.anchor.paragraphId} focus=${n.focus.paragraphId}) range=[rows ${o}..${a}, cells ${i}..${s}]`);const l=Qx(r.anchorCell,r.focusCell)<=0?r.anchorLocation:r.focusLocation,c=Qx(r.anchorCell,r.focusCell)<=0?r.focusLocation:r.anchorLocation,d=r.tableBlock.rows[l.rowIndex]?.cells[l.cellIndex],u=r.tableBlock.rows[c.rowIndex]?.cells[c.cellIndex],p=d?ew(d)[0]:void 0,f=u?ew(u):[],g=f[f.length-1];return p&&g?{anchor:Xo(p,0),focus:Xo(g,Za(g))}:null},n=t=>{const n=nw(t,e);if(!n)return null;const r=Math.min(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex),o=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<=o&&e.visualRowIndex+e.rowSpan-1>=r&&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}},r=t=>{const n=nw(t,e);if(!n||n.anchorCell.visualRowIndex!==n.focusCell.visualRowIndex)return null;const r=Qx(n.anchorCell,n.focusCell);if(0===r)return null;const o=r<=0?n.anchorLocation:n.focusLocation,a=r<=0?n.focusLocation:n.anchorLocation;return{blockIndex:n.anchorLocation.blockIndex,tablePath:n.anchorLocation.tablePath.map(e=>({...e})),rowIndex:o.rowIndex,startCellIndex:o.cellIndex,endCellIndex:a.cellIndex,zone:n.anchorLocation.zone}},o=t=>{const n=nw(t,e);if(!n||n.anchorLocation.cellIndex!==n.focusLocation.cellIndex)return null;const r=Math.min(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex),o=Math.max(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex);return r===o?null:{blockIndex:n.anchorLocation.blockIndex,tablePath:n.anchorLocation.tablePath.map(e=>({...e})),startRowIndex:r,endRowIndex:o,cellIndex:n.anchorLocation.cellIndex,zone:n.anchorLocation.zone}};return{resolveTableCellRangeSelection:t,resolveSelectedTableCells:n,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o}}(e)}function ow(e){if(e)for(const t of e.blocks){const e=Mo(t)[0];if(e)return e}}function aw(e,t,n){const r=n.tablePath[n.tablePath.length-1];return r?Kx(e,t.getTargetBlocks,{blockIndex:n.blockIndex,rowIndex:r.rowIndex,cellIndex:r.cellIndex,paragraphIndex:0,tablePath:n.tablePath,zone:n.zone}):null}function iw(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=>Tn(e))}),n=n=>{const r=e.resolveHorizontalTableCellRange(n);if(!r)return n;const o=aw(n,e,r);if(!o)return n;const{tableBlock:a,targetBlocks:i}=o,s=a.rows[r.rowIndex];if(!s)return n;const l=s.cells.slice(r.startCellIndex,r.endCellIndex+1);if(l.length<2)return n;const c=n.trackChangesEnabled?xg():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=>Tn(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(r.startCellIndex,l.length,d);const u=ow(d);return u?Gx(n,i,r.zone,u):n},r=n=>{const r=e.resolveVerticalTableCellRange(n);if(!r)return n;const o=aw(n,e,r);if(!o)return n;const{tableBlock:a,targetBlocks:i}=o,s=[];for(let e=r.startRowIndex;e<=r.endRowIndex;e+=1){const t=a.rows[e],o=t?.cells[r.cellIndex];if(!t||!o||"continue"===o.vMerge||1!==o.blocks.length||"paragraph"!==o.blocks[0]?.type)return n;s.push(o)}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?xg():void 0,d={...s[0],rowSpan:s.length,vMerge:"restart",blocks:s.flatMap(e=>e.blocks.map(e=>Tn(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[r.startRowIndex].cells[r.cellIndex]=d;for(let e=r.startRowIndex+1;e<=r.endRowIndex;e+=1){const t=co([Ma("")],l);t.blocks=[],t.vMerge="continue",a.rows[e].cells[r.cellIndex]=t}const u=ow(d);return u?Gx(n,i,r.zone,u):n},o=t=>e.canMergeSelectedTableCells(t)?n(t):e.canMergeSelectedTableRows(t)?r(t):t,a=n=>{const r=Xx(n,e.getTargetBlocks);if(!r)return n;const{tableBlock:o,location:a,targetBlocks:i}=r,s=o.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?xg():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 r=o.rows[a.rowIndex+n+1]?.cells[a.cellIndex];return r?t(r):co([],u)})]});for(let e=1;e<l;e+=1){const t=o.rows[a.rowIndex+e];if(!t)break;const n=co([Ma("")],u);t.cells[a.cellIndex]=n}const p=ow(s);return p?Gx(n,i,a.zone,p):n},i=n=>{const r=Xx(n,e.getTargetBlocks);if(!r)return n;const{tableBlock:o,location:a,targetBlocks:i}=r,s=o.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?xg():void 0,p=[{...l,colSpan:void 0,blocks:l.blocks.map(e=>Tn(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},()=>co([Ma("")]))];s.cells.splice(a.cellIndex,1,...p);const f=ow(p[0]);return f?Gx(n,i,a.zone,f):n},s=t=>e.canSplitSelectedTableCellVertically(t)?a(t):e.canSplitSelectedTableCell(t)?i(t):t;return{mergeSelectedTableCells:n,mergeSelectedTableRows:r,mergeSelectedTable:o,splitSelectedTableCellVertically:a,splitSelectedTableCell:i,splitSelectedTable:s}}(e)}function sw(e,t){e.style={...e.style??{},revision:{...xg(),type:t}}}function lw(e){if(!e)return null;for(const t of e.blocks){const e=Mo(t)[0];if(e)return e}return null}function cw(e,t,n){const r=lw(t);if(r)return r;if(n)for(const o of n.cells){if("continue"===o.vMerge)continue;const e=lw(o);if(e)return e}return Dx(e)}function dw(e){return function(e){const t=(t,n)=>{const r=Xx(t,e.getTargetBlocks);if(!r)return t;const{tableBlock:o,location:a,targetBlocks:i}=r,s=o.rows[a.rowIndex];if(!s)return t;const l=Math.max(0,Math.min(o.rows.length,a.rowIndex+(n>0?1:0)));let c;if(o.rows.some(e=>e.cells.some(e=>Math.max(1,e.rowSpan??1)>1||void 0!==e.vMerge))){const e=Vo(o),n=e.find(e=>e.rowIndex===a.rowIndex&&e.cellIndex===a.cellIndex),r=e.filter(e=>e.rowIndex===a.rowIndex),s=r.length>0?r:e.filter(e=>e.rowIndex===Math.max(0,a.rowIndex-1));c=yo(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=co([Ma("")],t.colSpan);return e.blocks=[],e.vMerge="continue",e}return co([Ma("")],t.colSpan)})),t.trackChangesEnabled&&sw(c,"insert"),o.rows.splice(l,0,c);const d=n?.visualColumnIndex??a.cellIndex,u=cw(o,Fx(c,d),c);return Gx(t,i,a.zone,u)}c=yo(s.cells.map(e=>co([Ma("")],Math.max(1,e.colSpan??1)))),t.trackChangesEnabled&&sw(c,"insert"),o.rows.splice(l,0,c);const d=cw(o,c.cells[Math.min(a.cellIndex,c.cells.length-1)],c);return Gx(t,i,a.zone,d)},n=t=>{const n=Xx(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:r,targetBlocks:o,location:a}=n,i=r.rows[r.rows.length-1];if(!i||!i.cells.length)return t;const s=i.cells.map(e=>{const t=co([Ma("")],Math.max(1,e.colSpan??1));if(e.style){const{revision:n,...r}=e.style;t.style=r}return t}),l=Math.max(r.gridCols?.length??0,Bx(r));for(let e=s.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0);e<l;e++)s.push(co([Ma("")]));const c=yo(s);return t.trackChangesEnabled&&sw(c,"insert"),r.rows.push(c),Gx(t,o,a.zone,lw(s[0]))},r=t=>{const n=Xx(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:r,location:o,targetBlocks:a}=n;if(r.rows.length<=1&&!t.trackChangesEnabled)return t;const i=r.rows[o.rowIndex];if(!i)return t;if(t.trackChangesEnabled)return sw(i,"delete"),Gx(t,a,o.zone,null);if(i.cells.some(e=>"continue"!==e.vMerge&&Math.max(1,e.rowSpan??1)>1))return t;const s=r.rows.some(e=>e.cells.some(e=>Math.max(1,e.rowSpan??1)>1||void 0!==e.vMerge)),l=s?Vo(r).find(e=>e.rowIndex===o.rowIndex&&e.cellIndex===o.cellIndex):null;if(s){const e=Vo(r);for(const t of e)t.visualRowIndex<o.rowIndex&&t.visualRowIndex+t.rowSpan>o.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")}r.rows.splice(o.rowIndex,1);const c=r.rows[Math.min(o.rowIndex,r.rows.length-1)],d=cw(r,c?Fx(c,Math.min(l?.visualColumnIndex??o.cellIndex,Math.max(0,Ox(c)-1))):null);return Gx(t,a,o.zone,d)},o=(t,n)=>{const r=Xx(t,e.getTargetBlocks);if(!r)return t;const{tableBlock:o,location:a,targetBlocks:i}=r;if(o.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=Vo(o).find(e=>e.rowIndex===a.rowIndex&&e.cellIndex===a.cellIndex),r=(e?.visualColumnIndex??a.cellIndex)+(n>0?Math.max(1,e?.colSpan??1):0);for(const n of o.rows){const e=[];let o=0,a=!1;for(const i of n.cells){const n=Math.max(1,i.colSpan??1);if(!a&&r<=o){const n=co([Ma("")]);t.trackChangesEnabled&&sw(n,"insert"),e.push(n),a=!0}!a&&o<r&&r<o+n?(e.push({...i,colSpan:n+1,...t.trackChangesEnabled?{style:{...i.style??{},revision:{...xg(),type:"merge",previous:{colSpan:i.colSpan}}}}:{}}),a=!0):e.push(i),o+=n}if(!a){const n=co([Ma("")]);t.trackChangesEnabled&&sw(n,"insert"),e.push(n)}n.cells=e}const s=o.rows[a.rowIndex],l=cw(o,s?Fx(s,r):null);return Gx(t,i,a.zone,l)}const s=Math.max(0,Math.min(o.rows[0]?.cells.length??0,a.cellIndex+(n>0?1:0)));for(const e of o.rows){const n=co([Ma("")]);t.trackChangesEnabled&&sw(n,"insert"),e.cells.splice(s,0,n)}const l=o.rows[a.rowIndex]?.cells[s],c=cw(o,l);return Gx(t,i,a.zone,c)},a=t=>{const n=Xx(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:r,location:o,targetBlocks:a}=n;if(Bx(r)<=1)return t;if(t.trackChangesEnabled){const e=Vo(r).find(e=>e.rowIndex===o.rowIndex&&e.cellIndex===o.cellIndex)?.visualColumnIndex??o.cellIndex;for(const t of r.rows){const n=Fx(t,e);n&&sw(n,"delete")}return Gx(t,a,o.zone,null)}if(r.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=Vo(r).find(e=>e.rowIndex===o.rowIndex&&e.cellIndex===o.cellIndex)?.visualColumnIndex??o.cellIndex;for(const t of r.rows){const n=[];let r=0;for(const o of t.cells){const t=Math.max(1,o.colSpan??1);e>=r&&e<r+t?t>1&&n.push({...o,colSpan:t-1>1?t-1:void 0}):n.push(o),r+=t}t.cells=n}const n=r.rows[o.rowIndex],i=cw(r,n&&Fx(n,Math.min(e,Math.max(0,Ox(n)-1))));return Gx(t,a,o.zone,i)}if(r.rows[0]?.cells.length<=1)return t;for(const e of r.rows)e.cells.splice(o.cellIndex,1);const i=r.rows[o.rowIndex],s=i?.cells[Math.min(o.cellIndex,i.cells.length-1)],l=cw(r,s);return Gx(t,a,o.zone,l)};return{insertSelectedTableRow:t,appendTableRowForTab:n,deleteSelectedTableRow:r,insertSelectedTableColumn:o,deleteSelectedTableColumn:a}}(e)}function uw(e){return function(e){const t=t=>{const n=e.resolveTableCellRangeSelection(t);return n?e.applySelectionToStatePreservingStructure(t,n):t},n=(n,r)=>{e.applyTransactionalState(o=>{const a=e.resolveSelectedTableCells(o);if(!a||a.cells.length<=1){const a=t(o);return a!==o&&e.logger?.info(`${r}: 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(`${r}: 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(Mo);d.push(...t),u.push(t.length)}if(0===d.length)return o;const p={...o,activeSectionIndex:0,activeZone:"main",document:{...Ea(d,o.document.pageSettings,void 0,o.document.styles,void 0,o.document.assets),settings:o.document.settings},selection:{anchor:Xo(d[0],0),focus:Xo(d[d.length-1],Za(d[d.length-1]))}},f=n(p);if(f===p)return o;const g=xi(f);if(g.length!==d.length)return o;const m=s[s.length-1];if(!m)return o;const h=Kx(o,e.getTargetBlocks,{blockIndex:i,rowIndex:m.rowIndex,cellIndex:m.cellIndex,paragraphIndex:0,tablePath:s,zone:c});if(!h)return o;let b=0;for(let e=0;e<l.length;e+=1){const t=l[e],n=u[e]??0,r=g.slice(b,b+n);b+=n;const o=h.tableBlock.rows[t.rowIndex]?.cells[t.cellIndex];o&&(o.blocks=Jt(o.blocks,r))}return Ux(o,h.targetBlocks,c)})};return{withExpandedTableCellSelection:t,applySelectionAwareTextCommand:e=>{n(e,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:e=>{n(e,"applySelectionAwareParagraphCommand")}}}(e)}function pw(e){return function(e){const t=Wx,{resolveTableCellRangeSelection:n,resolveSelectedTableCells:r,resolveHorizontalTableCellRange:o,resolveVerticalTableCellRange:a}=rw({getTargetBlocks:t,logger:e.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:s,canMergeSelectedTableRows:l,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:f}=Jx({getTargetBlocks:t,resolveHorizontalTableCellRange:o,resolveVerticalTableCellRange:a}),{mergeSelectedTableCells:g,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v}=iw({getTargetBlocks:t,resolveHorizontalTableCellRange:o,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canMergeSelectedTableRows:l,canSplitSelectedTableCell:s,canSplitSelectedTableCellVertically:d}),{insertSelectedTableRow:x,appendTableRowForTab:w,deleteSelectedTableRow:I,insertSelectedTableColumn:S,deleteSelectedTableColumn:C}=dw({getTargetBlocks:t}),k=(e,n)=>qx(e,t,n),{withExpandedTableCellSelection:T,applySelectionAwareTextCommand:P,applySelectionAwareParagraphCommand:R}=uw({applyTransactionalState:e.applyTransactionalState,applySelectionToStatePreservingStructure:e.applySelectionToStatePreservingStructure,getTargetBlocks:t,resolveTableCellRangeSelection:n,resolveSelectedTableCells:r,logger:e.logger}),M=(t,n)=>{e.logger?.info(`insertTableCommand: ${t}x${n}`),e.applyTransactionalState(e=>function(e,t,n){const r=100/Math.max(1,n)+"%",o=e.trackChangesEnabled?xg():void 0,a=[];for(let b=0;b<t;b+=1){const e=[];for(let o=0;o<n;o+=1)e.push({...co([Ma("")]),style:{width:r}});const t=yo(e);o&&(t.style={revision:{...o,type:"insert"}}),a.push(t)}const i={...no(a),style:{width:"100%"}},s=Qa(e,e.selection.focus),l=Si(e.document),c=ya(e),d=Yo(e),u=e=>{const t=e.findIndex(e=>e.id===s.paragraphId||"paragraph"!==e.type&&Mo(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 f={...p};let g=!1;if("header"===d){const e=u(p.header??[]);f.header=e.nextBlocks,g=e.found}else if("footer"===d){const e=u(p.footer??[]);f.footer=e.nextBlocks,g=e.found}else{const e=u(p.blocks);f.blocks=e.nextBlocks,g=e.found}if(!g)return e;const m=[...l];m[c]=f;const h=i.rows[0].cells[0].blocks[0];return"paragraph"!==h.type?e:{...e,document:{...e.document,sections:m},selection:J(Xo(h,0))}}(e,t,n),{mergeKey:Jp}),e.focusInput()};return{resolveTableCellRangeSelection:n,resolveHorizontalTableCellRange:o,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canSplitSelectedTableCell:s,canMergeSelectedTableRows:l,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:f,mergeSelectedTableCells:g,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v,insertSelectedTableRow:x,appendTableRowForTab:w,deleteSelectedTableRow:I,insertSelectedTableColumn:S,deleteSelectedTableColumn:C,getRowVisualWidth:Ox,getTableVisualWidth:Bx,findCellAtVisualColumn:Fx,findFirstNavigableParagraphInTable:Dx,updateBlocksInCurrentSection:Ux,resolveAdjacentTableCellPosition:zx,resolveTableTabTarget:Nx,applyTableAwareParagraphEdit:k,withExpandedTableCellSelection:T,applySelectionAwareTextCommand:P,applySelectionAwareParagraphCommand:R,insertTableCommand:M}}(e)}function fw(){let e=null;return{claim:t=>{e=t.pointerId??null},owns:t=>null===e||t.pointerId===e,release:()=>{e=null}}}function gw(e,t){let n=null;const r=(e,t,n)=>{const r=xi(e).find(e=>e.id===t);return r?{anchor:Xo(r,n),focus:Xo(r,n+1)}:null},o=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),a=fw(),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:f}=Xe(s,c,d,i.shiftKey,u),g=r(t.state,s.paragraphId,s.paragraphOffset);g?t.applyState(e.applyResize(o(t.state,g),p,f,s.handleDirection)):t.logger.warn(`${e.label} resize:missing paragraph`,s)},s=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:wx(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 f=r(p,l,c);if(!f)return;const g=e.getSelected(o(p,f));g&&(n={paragraphId:l,paragraphOffset:c,handleDirection:d,startClientX:u.clientX,startClientY:u.clientY,startWidth:g.width,startHeight:g.height,aspectRatio:g.width/g.height,initialState:t.cloneState(p)},a.claim(u),window.addEventListener("pointermove",i),window.addEventListener("pointerup",s),window.addEventListener("pointercancel",s))},stop:l}}function mw(e,t){let n=null;const r=fw(),o=o=>{if(!r.owns(o))return;const a=n;if(!a)return;let i=((180*Math.atan2(o.clientY-a.centerY,o.clientX-a.centerX)/Math.PI+90)%360+360)%360;o.shiftKey&&(i=15*Math.round(i/15)%360);const s=((e,t,n)=>{const r=xi(e).find(e=>e.id===t);return r?{anchor:Xo(r,n),focus:Xo(r,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:wx(n.undoStack,t.cloneState(e.initialState)),redoStack:[]})),i(),t.focusInput()},i=()=>{n=null,r.release(),window.removeEventListener("pointermove",o),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)},r.claim(s),window.addEventListener("pointermove",o),window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a)},stop:i}}function hw(e,t){return Math.max(1e-4,1-e-t)}function bw(e,t,n,r){const o=Math.max(.01,1-e-t),a=Math.max(0,Math.min(n,.99-t)),i=Math.max(0,Math.min(r,.99-a));return a+i>=.99?{near:Math.max(0,.99-o-t),far:t}:{near:a,far:i}}function yw(e){let t=null;const n=(e,t,n)=>{const r=xi(e).find(e=>e.id===t);return r?{anchor:Xo(r,n),focus:Xo(r,n+1)}:null},r=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),o=fw(),a=a=>{if(!o.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:r,startHeight:o}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,s=e.startCrop.right??0,l=e.startCrop.bottom??0,c=hw(a,s)/r,d=hw(i,l)/o,u=1-a-s,p=1-i-l,f=Math.max(0,Math.min(1-u,a-t*c)),g=Math.max(0,Math.min(1-p,i-n*d));return{crop:{left:f,right:Math.max(0,1-u-f),top:g,bottom:Math.max(0,1-p-g)},width:Math.round(r),height:Math.round(o)}}(i,l,c):function(e,t,n){const{startWidth:r,startHeight:o}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,s=e.startCrop.right??0,l=e.startCrop.bottom??0,c=hw(a,s)/r,d=hw(i,l)/o,u=q(e.handleDirection,"x"),p=q(e.handleDirection,"y");let f=a,g=s,m=r;if(0!==u)if(u<0){m=Qe(r-t,24,r+a/c);const e=bw(a,s,a-(m-r)*c,s);f=e.near,g=e.far}else{m=Qe(r+t,24,r+s/c);const e=bw(a,s,a,s-(m-r)*c);f=e.near,g=e.far}let h=i,b=l,y=o;if(0!==p)if(p<0){y=Qe(o-n,24,o+i/d);const e=bw(i,l,i-(y-o)*d,l);h=e.near,b=e.far}else{y=Qe(o+n,24,o+l/d);const e=bw(i,l,i,l-(y-o)*d);h=e.near,b=e.far}return{crop:{left:f,top:h,right:g,bottom:b},width:Math.round(m),height:Math.round(y)}}(i,l,c),u=n(e.state,i.paragraphId,i.paragraphOffset);u?e.applyState(xv(r(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:wx(t.undoStack,e.cloneState(n.initialState)),redoStack:[]})),s(),e.focusInput()},s=()=>{t=null,o.release(),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)},l=(s,l,c,d,u,p)=>{const f=n(u,s,l);if(!f)return;const g=bv(r(u,f)),m=g&&da(g.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},o.claim(d),window.addEventListener("pointermove",a),window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i)};return{start:(e,t,n,r,o)=>l(e,t,n,r,o,"handle"),startMove:(e,t,n,r)=>l(e,t,"se",n,r,"move"),stop:s}}function vw(e){return function(e){const[t,n]=$t(!1),[r,o]=$t(!1),[a,i]=$t(null);bn(()=>{r()&&!m(e.state)&&o(!1)});const s=()=>{m(e.state)?o(e=>!e):o(!1)},[l,c]=$t({x:0,y:0}),[d,u]=$t(null);let p=null,f=null,g=null;const m=e=>{const t=sa(e);if(t.isCollapsed||t.startIndex!==t.endIndex||t.endParagraphOffset-t.startParagraphOffset!==1)return null;const n=xi(e)[t.startIndex];if(!n)return null;let r=0;for(const o of n.runs){const a=r;if(r+=o.text.length,"image"===o.kind&&1===o.text.length&&a===t.startParagraphOffset)return{paragraph:n,run:o,startOffset:a,width:o.image.width,height:o.image.height,src:zo(e.document,o.image.src)}}return null},h=(t,n)=>e.resolvePositionAtSurfacePoint(t,n),b=()=>{g||(g=document.createElement("style"),g.setAttribute("data-oasis-image-drag-cursor",""),g.textContent="*, *::before, *::after { cursor: grabbing !important; }",document.head.appendChild(g))},y=()=>{g&&(g.remove(),g=null),document.body.style.cursor=""},v=fw(),x=()=>{y(),f=null,p=null,n(!1),i(null),u(null),v.release(),window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",T),window.removeEventListener("pointercancel",T)},w=()=>{x()},I=gw({label:"image",getSelected:e=>m(e),applyResize:(e,t,n)=>yv(e,t,n),getMaxWidth:(t,n)=>Av(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}),S=mw({label:"image",applyRotate:(e,t)=>function(e,t){const n=Cv(t);return Pv(e,e=>({...e,rotation:n}))}(e,t)},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger}),C=yw({state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),k=t=>{if(!v.owns(t))return;let r=p;if(!r){const o=f;if(!o)return;if(Math.abs(t.clientX-o.startClientX)+Math.abs(t.clientY-o.startClientY)<4)return;r={paragraphId:o.paragraphId,paragraphOffset:o.paragraphOffset,src:o.src,width:o.width,height:o.height,offsetX:o.offsetX,offsetY:o.offsetY},p=r,f=null,n(!0),b(),e.logger.info(`image drag:start ${r.paragraphId}@${r.paragraphOffset} client=(${t.clientX},${t.clientY})`)}c({x:t.clientX,y:t.clientY}),i({...r}),u(h(t.clientX,t.clientY))},T=t=>{if(!v.owns(t))return;const n=p;if(n||f){if(n){const r=h(t.clientX,t.clientY);r?(e.logger.info(`image drag:done ${n.paragraphId} -> ${r.paragraphId}:${r.runId}[${r.offset}]`),e.applyTransactionalState(e=>Mv(e,r),{mergeKey:Qp})):e.logger.warn(`image drag:cancel ${n.paragraphId} no target at (${t.clientX},${t.clientY})`)}x(),e.focusInput()}else e.focusInput()},P=(t,r,o,a)=>{const s=o.currentTarget,l=a?{left:a.left,top:a.top,width:a.width,height:a.height}:s?.getBoundingClientRect();if(!l)return;const d=m(e.state);f={paragraphId:t,paragraphOffset:r,startClientX:o.clientX,startClientY:o.clientY,src:d?.src??"",width:d?.width??l.width,height:d?.height??l.height,offsetX:o.clientX-l.left,offsetY:o.clientY-l.top},p=null,c({x:o.clientX,y:o.clientY}),n(!1),i(null),u(null),v.claim(o),window.addEventListener("pointermove",k),window.addEventListener("pointerup",T),window.addEventListener("pointercancel",T)},R=(t,n,r)=>{r.preventDefault(),r.stopPropagation();const o=Co(e.state.document).find(e=>e.id===t);o&&e.applyState(Ai(e.state,{anchor:Xo(o,n),focus:Xo(o,n+1)})),P(t,n,r),e.focusInputAfterPointerSelection()},M=(t,n,r,o)=>{o.preventDefault(),o.stopPropagation(),I.start(t,n,r,o,e.state)},A=(t,n,r)=>{r.preventDefault(),r.stopPropagation(),S.start(t,n,r,e.state)},O=(t,n,r,o)=>{o.preventDefault(),o.stopPropagation(),C.start(t,n,r,o,e.state)},B=(t,n,r)=>{r.preventDefault(),r.stopPropagation(),C.startMove(t,n,r,e.state)};return{dragging:t,cropMode:r,setCropMode:o,toggleCropMode:s,draggedImageInfo:a,mousePos:l,dropTargetPos:d,getSelectedImageInfo:m,startImageDrag:P,stopImageDrag:w,stopImageResize:I.stop,stopImageRotate:S.stop,stopImageCrop:C.stop,handleImagePointerDown:R,handleImageResizeHandlePointerDown:M,handleImageRotateHandlePointerDown:A,handleImageCropHandlePointerDown:O,handleImageCropBodyPointerDown:B}}(e)}function xw(e){return function(e){const t=e=>{const t=Px(e),n=t&&za(t.run);return n?{width:n.width,height:me(n,e,0)}:null},n=gw({label:"text box",getSelected:t,applyResize:(e,t,n,r)=>Ax(e,t,n,{handleDirection:r}),getMaxWidth:(n,r)=>{const o=Av(e.surfaceRef(),n.document,r,n.activeSectionIndex??0),a=t(n);return a?Math.max(o,a.width):o}},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),r=mw({label:"text box",applyRotate:(e,t)=>Rx(e,t)},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger}),o=(t,r,o,a)=>{a.preventDefault(),a.stopPropagation(),n.start(t,r,o,a,e.state)},a=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),r.start(t,n,o,e.state)};return{handleTextBoxResizeHandlePointerDown:o,handleTextBoxRotateHandlePointerDown:a,stopTextBoxResize:n.stop,stopTextBoxRotate:r.stop}}(e)}function ww(e){return function(e){const[t,n]=$t(void 0),r=()=>{n(void 0)};bn(()=>{ri(e.state().selection)||r()});const o=(e,t)=>{n(n=>{const r={...n??{}};return null==t||""===t?delete r[e]:r[e]=t,Object.keys(r).length>0?r:void 0})},a=(e,t)=>{n(n=>{const r={...n??{}};return r[e]=t,"superscript"===e&&t&&(r.subscript=!1),"subscript"===e&&t&&(r.superscript=!1),r})},i=()=>{const n=fr(e.state()),r=t();return ri(e.state().selection)&&r?{...n,bold:r.bold??n.bold,italic:r.italic??n.italic,underline:r.underline??n.underline,underlineStyle:void 0!==r.underlineStyle?String(r.underlineStyle??""):n.underlineStyle,strike:r.strike??n.strike,superscript:r.superscript??n.superscript,subscript:r.subscript??n.subscript,fontFamily:r.fontFamily??n.fontFamily,fontSize:void 0!==r.fontSize&&null!==r.fontSize?String(r.fontSize):n.fontSize,color:r.color??n.color,highlight:r.highlight??n.highlight,textShading:r.shading??n.textShading,link:r.link??n.link,characterStyleId:void 0!==r.styleId&&null!==r.styleId?String(r.styleId):n.characterStyleId}:n},s=(t,n)=>{if(ri(e.state().selection))return e.logger.info(`setPendingStyle:${t}=${JSON.stringify(n)}`),e.clearPreferredColumn(),e.resetTransactionGrouping(),o(t,n),void e.focusInput();e.commandsController().applyValueStyleCommand(t,n)},l=t=>{if(ri(e.state().selection)){const n=!i()[t];return e.logger.info(`setPendingStyle:${t}=${JSON.stringify(n)}`),e.clearPreferredColumn(),e.resetTransactionGrouping(),a(t,n),void e.focusInput()}e.commandsController().applyBooleanStyleCommand(t)},c=t=>{if(ri(e.state().selection))return e.clearPreferredColumn(),e.resetTransactionGrouping(),n(e=>({...e,underline:null!==t,underlineStyle:"single"===t?null:t})),void e.focusInput();e.commandsController().applyUnderlineStyleCommand(t)};return{pendingCaretTextStyle:t,clearPendingCaretTextStyle:r,toolbarStyleState:i,applyToolbarValueStyleCommand:s,applyToolbarUnderlineStyleCommand:c,applyToolbarBooleanStyleCommand:l}}(e)}function Iw(e,t,n={}){if(!t)return[];const r=[],o=Co(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 o.forEach((e,t)=>{const n=po(e);let o;for(c.lastIndex=0;null!==(o=c.exec(n));){const n=o.index,a=o.index+o[0].length;r.push({anchor:Xo(e,n),focus:Xo(e,a),paragraphIndex:t}),o.index===c.lastIndex&&c.lastIndex++}}),r}function Sw(e,t,n,r={}){const o=Iw(e.document,t,r);if(0===o.length)return e;let a=e;for(let i=o.length-1;i>=0;i-=1){const e=o[i];a=Ai(a,{anchor:e.anchor,focus:e.focus}),a=np(a,n)}return a}function Cw(e,t,n,r,o,a){const i=e+n,s=t+r;return(a<t?t-a:a>s?a-s:0)*Er+(o<e?e-o:o>i?o-i:0)}function kw(e,t,n){if(0===e.slots.length)return{offset:e.startOffset,score:Number.POSITIVE_INFINITY};let r=e.slots[0].offset,o=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*Er+c;d<o&&(o=d,r=l.offset,a=l.left,i=l.top,s=l.height)}return{offset:r,score:o,slotLeft:a,slotTop:i,slotHeight:s}}function Tw(e,t,n){let r=e.startOffset,o=Number.POSITIVE_INFINITY;for(const a of e.lines){const{offset:e,score:i}=kw(a,t,n);i<o&&(o=i,r=e)}return Math.max(e.startOffset,Math.min(r,e.endOffset))}function Pw(e,t,n){return e>=n.left&&e<=n.left+n.width&&t>=n.top&&t<=n.top+n.height}function Rw(e){const{snapshot:t,state:n}=e,r=e.pierce??!1,o=e.zoomFactor&&e.zoomFactor>0?e.zoomFactor:1,a=t.surfaceRect,i=a.left+(e.clientX-a.left)/o,s=a.top+(e.clientY-a.top)/o,l=function(e,t,n){if(0===e.length)return null;let r=e[0],o=Number.POSITIVE_INFINITY;for(const a of e){const e=Cw(a.left,a.top,a.width,a.height,t,n);e<o&&(o=e,r=a)}return r}(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,r,o,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)&&r>=s.left&&r<=s.left+s.width&&o>=s.top&&o<=s.top+s.height)return s}return null}(t,l.index,c,i,s,r);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=Xo(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,r,o,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)&&Pw(r,o,s))return s}for(const i of e.inlineImages)if(i.pageIndex===t&&i.zone===n&&Pw(r,o,i))return i;return null}(t,l.index,c,i,s,r);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=Xo(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 r=null;for(const i of e)for(const e of i.lines){const o=e.top-2,a=e.top+e.height+2;if(n<o||n>a)continue;const{offset:s,score:l,slotLeft:c,slotTop:d,slotHeight:u}=kw(e,t,n);(!r||l<r.score)&&(r={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(r)return{paragraph:r.paragraph,offset:r.offset,caretViewport:r.caretViewport};let o=null,a=Number.POSITIVE_INFINITY;for(const i of e){const e=Cw(i.left,i.top,Math.max(1,i.width),Math.max(1,i.height),t,n);e<a&&(a=e,o=i)}return o?{paragraph:o,offset:Tw(o,t,n),caretViewport:{left:o.left,top:o.top,height:Math.max(16,Math.min(32,o.height||24))}}:null}(t.paragraphs.filter(e=>e.pageIndex===l.index&&e.zone===c),i,s);if(!p){const e=n.selection.focus.paragraphId,r=n.selection.focus.offset,o=function(e,t,n,r,o){return e.unsupportedRegions.find(e=>e.pageIndex===t&&e.zone===n&&r>=e.left&&r<=e.left+e.width&&o>=e.top&&o<=e.top+e.height)?.reason??null}(t,l.index,c,i,s);return{zone:c,paragraphId:e,paragraphOffset:r,position:{...n.selection.focus},source:"canvas-layout",resolvedFromParagraph:!1,missReason:o??"zone-without-paragraph"}}const f=p.paragraph,g=Math.max(0,Math.min(p.offset,f.textLength)),m=p.caretViewport;let h;if(m&&i!==m.left){const e=f.lines.filter(e=>s>=e.top&&s<=e.top+e.height&&e.slots.some(e=>e.offset===g&&e.left===m.left&&e.top===m.top));if(1===e.length){const t=e[0].slots,n=t.filter(e=>e.offset===g),r=t.find(e=>e.offset===g-1),o=t.find(e=>e.offset===g+1);1===n.length&&r&&o&&r.left<m.left&&m.left<o.left&&(h=i<m.left?"before-markers":"after-markers")}}const b=Uo(f.paragraph,g,h);return{zone:c,footnoteId:f.footnoteId,paragraphId:f.paragraphId,paragraphOffset:g,position:b,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:f.tableCell?.anchorPosition,caretViewport:p.caretViewport,insideTextLine:f.lines.some(e=>{if(s<e.top||s>e.top+e.height||e.slots.length<2)return!1;const t=e.slots.map(e=>e.left);return i>=Math.min(...t)&&i<=Math.max(...t)})}}function Mw(e){return function(e){const t=(t,n,r={})=>{const o=e.surfaceRef();if(!o)return null;const a=e.state(),i=e.zoomFactor(),s=e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:o,state:a,documentLayout:e.documentLayout(),zoomFactor:i});if(function(e){$p&&(jp=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 _p(null),null;const l=Rw({snapshot:s,state:a,clientX:t,clientY:n,pierce:r.pierce??!1,zoomFactor:i});return _p(l),l};return{resolveSurfaceHitAtPoint:t}}(e)}var Aw=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],Ow=/* @__PURE__ */new Map;function Bw(){return Aw.map(e=>({...e}))}var Fw=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function Ew(e,t,n){const[r,o]=e,[a,i]=t,[s,l]=n,c=s-a,d=l-i,u=c*c+d*d;return 0===u?Math.hypot(r-a,o-i):Math.abs(c*(i-o)-d*(a-r))/Math.sqrt(u)}function Dw(e,t){if(e.length<3)return e.slice();let n=0,r=0;const o=e[0],a=e[e.length-1];for(let l=1;l<e.length-1;l+=1){const t=Ew(e[l],o,a);t>n&&(n=t,r=l)}if(n<=t)return[o,a];const i=Dw(e.slice(0,r+1),t),s=Dw(e.slice(r),t);return[...i.slice(0,-1),...s]}function Lw(e,t,n){let r=0;for(let l=0;l<e.length;l+=1)1===e[l]&&(r+=1);if(t<=0||n<=0||0===r||r/(t*n)>=.985)return Bw();const o=function(e,t,n){const r=(r,o)=>r>=0&&r<t&&o>=0&&o<n&&1===e[o*t+r];let o=-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]){o=n,a=u;break}if(o<0)return[];const i=[];let s=o,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,[o,a]=Fw[n],d=s+o,u=l+a;if(r(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===o&&l===a&&i.length>1)break}return i}(e,t,n);if(o.length<3)return Bw();const a=.012*Math.max(t,n);let i=Dw(o,a),s=a;for(;i.length>40;)s*=1.6,i=Dw(o,s);return i.length<3?Bw():i.map(([e,r])=>({x:Math.min(1,Math.max(0,e/t)),y:Math.min(1,Math.max(0,r/n))}))}function Nw(e){const t=e.src,n=Ow.get(t);if(n)return n.map(e=>({...e}));const r=function(e){const t=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(!t||!n)return null;const r=Math.min(1,256/Math.max(t,n)),o=Math.max(1,Math.round(t*r)),a=Math.max(1,Math.round(n*r)),i=document.createElement("canvas");i.width=o,i.height=a;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return null;let l;s.drawImage(e,0,0,o,a);try{l=s.getImageData(0,0,o,a).data}catch{return null}const c=new Uint8Array(o*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:o,height:a,foreground:d}}(e);if(!r)return Bw();const o=Lw(r.mask,r.width,r.height);return Ow.set(t,o),o.map(e=>({...e}))}function zw(e){const{state:t,resetTransactionGrouping:n,applyTransactionalState:r,focusInput:o}=e,a=()=>bv(t())?"image":Px(t())?"textBox":null,i=(e,t)=>{const i=a();i&&(n(),r(e=>t(e,i),{mergeKey:e}),o())},s=(e,n)=>{const o=zo(t().document,n),a=t=>{const n=Nw(t);r(t=>function(e,t,n){const r=xi(e);let o=!1;const a=r.map(e=>e.runs.some(e=>e.id===t&&"image"===e.kind)?{...eo(e),runs:e.runs.map(e=>{if(e.id!==t||"image"!==e.kind)return Ro(e);o=!0;const r={...e.image};return n&&n.length>0?r.wrapPolygon=n:delete r.wrapPolygon,{...e,image:r}})}:eo(e));return o?Cn(e,a,H(a,sa(e))):e}(t,e,n),{mergeKey:uf})},i=ie(o,()=>{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=bv(e),n=t&&da(t.run);return n?gv(n.floating):null}(t()):"textBox"===e?function(e){const t=Px(e),n=t&&za(t.run);return n?gv(n.floating):null}(t()):null},fixedPosition:()=>{const e=a();return"image"===e?function(e){const t=bv(e),n=t&&da(t.run);return hv(n?.floating)}(t()):"textBox"===e&&function(e){const t=Px(e),n=t&&za(t.run);return hv(n?.floating)}(t())},setPreset:e=>{if(i(Qf,(t,n)=>"image"===n?function(e,t){return Rv(e,e=>fv(e,t))}(t,e):function(e,t){return Mx(e,e=>fv(e,t))}(t,e)),"tight"===e||"through"===e){const e=bv(t()),n=e&&da(e.run);n&&!n.wrapPolygon&&s(e.run.id,n.src)}},setFixedPosition:e=>i(eg,(t,n)=>"image"===n?function(e,t){return Rv(e,e=>e?mv(e,t):e)}(t,e):function(e,t){return Mx(e,e=>e?mv(e,t):e)}(t,e))}}function $w(e){return function(e){let t=0;Hn()&&_t(()=>{t++});const n=n=>{if(t++,e.onNativeClipboardStart?.(),Gu(e.state()))return n.preventDefault(),void(n.clipboardData&&function(e,t){try{const n=qu(e);return t.setData(Wu,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 r=Mi(e.state());if(0!==r.length&&(n.preventDefault(),n.clipboardData)){try{n.clipboardData.setData("text/plain",r),n.clipboardData.setData("text/html",Yu(e.state()))}catch{return}e.onNativeClipboardSuccess?.()}},r=n=>{if(t++,e.onNativeClipboardStart?.(),e.isReadOnly())return void n.preventDefault();if(Gu(e.state()))return n.preventDefault(),void e.onNativeClipboardIssue?.("cut","unsupported");const r=Mi(e.state());if(0!==r.length&&(n.preventDefault(),n.clipboardData)){try{n.clipboardData.setData("text/plain",r),n.clipboardData.setData("text/html",Yu(e.state()))}catch{return}e.onNativeClipboardSuccess?.(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ip(e))),e.focusInput()}},o=n=>{const r=++t;if(e.isReadOnly())return void n.preventDefault();const o=e.consumePasteMode?.(),a=e.clipboardRequestGeneration?.(),i=()=>r!==t||e.clipboardRequestGeneration?.()!==a,s=Array.from(n.clipboardData?.types??[]).filter(Vu);if(n.clipboardData&&s.length){n.preventDefault();const t=e.forcePlainTextPaste();e.setForcePlainTextPaste(!1);const r=1===s.length?Xu(n.clipboardData.getData(s[0])):void 0,a=e.stateSnapshot?.();return t||o&&"rich"!==o||!r||!a?void e.onNativeClipboardIssue?.("paste","unsupported"):(n.currentTarget.value="",(async()=>{let t;try{t=await ju(a,r)}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(r=>i()||e.isReadOnly()||r!==a?r:(n=!0,t)),n?(e.onNativeClipboardSuccess?.(),e.focusInput()):e.onNativeClipboardIssue?.("paste","document-changed")})())}if(e.forcePlainTextPaste()||"text"===o){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=>op(e,t))),n.currentTarget.value="",void e.focusInput())}const l="merge"!==o?uv(n.clipboardData):null;if(l)return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.insertImageFromFile(l),n.currentTarget.value="",void e.focusInput();const c=xp(n.clipboardData?.getData("text/html")??""),d="merge"===o?vp(e.state(),c):c;if(d.length>0)return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Zu(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=>op(e,u))),n.currentTarget.value="",e.focusInput())},a=n=>{if(t++,e.onNativeClipboardStart?.(),e.isReadOnly())return void n.preventDefault();const r=uv(n.dataTransfer);if(!r)return;n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping();const o=e.resolvePositionAtSurfacePoint(n.clientX,n.clientY)??e.state().selection.focus;e.insertImageFromFile(r,o),e.focusInput()};return{handleCopy:n,handleCut:r,handlePaste:o,handleDrop:a}}(e)}var Hw=/* @__PURE__ */new WeakMap;function jw(e,t){return function(e){return _r(e.document).flatMap(e=>[...e.header??[],...e.blocks,...e.footer??[]])}(e).find(e=>"table"===e.type&&e.id===t)??null}function Ww(e,t,n,r,o){const a=r.getCanvasLayoutSnapshot({surface:e,state:t,documentLayout:n,zoomFactor:o});if(!a)return[];const i=Hw.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 r=n.get(t);r||(r={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,r),s.set(e.tableId,n));const o=d.lines.flatMap(e=>e.slots.map(e=>e.left)),a=d.lines.map(e=>e.top+e.height),i=o.length>0?Math.min(...o):d.left,c=o.length>0?Math.max(...o):d.left,u=d.lines.length>0?d.lines[0].top:d.top,p=a.length>0?Math.max(...a):d.top+d.height,f=`${e.tableId}:${d.pageIndex}:${e.rowIndex}:${e.cellIndex}`,g=l.get(f);g?(g.left=Math.min(g.left,i),g.top=Math.min(g.top,u),g.right=Math.max(g.right,c),g.bottom=Math.max(g.bottom,p)):l.set(f,{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)),r=Math.max(...e.map(e=>e.right)),o=Math.max(...e.map(e=>e.bottom));c.push({tableId:d,cells:e,bounds:{left:t,top:n,right:r,bottom:o,width:Math.max(1,r-t),height:Math.max(1,o-n)}})}return Hw.set(a,c),c}function Uw(e,t,n,r,o,a){const i=Ww(t,n,r,o,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,r=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 r=Math.abs(e.clientX-t.right);r<=4&&(!s||r<s.distance)&&(s={geometry:d,cell:t,side:"right",distance:r})}if(r){const n=Math.abs(e.clientY-t.top);n<=4&&(!s||n<s.distance)&&(s={geometry:d,cell:t,side:"top",distance:n});const r=Math.abs(e.clientY-t.bottom);r<=4&&(!s||r<s.distance)&&(s={geometry:d,cell:t,side:"bottom",distance:r})}}if(!s)return null;const l=jw(n,s.geometry.tableId);if(!l)return null;const c=Vo(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 _w(e){return.75*e}function Kw(e){return e*Vw}var qw=Xg;function Xw(e){return("number"==typeof e.style?.padding&&Number.isFinite(e.style.padding)?2*Math.max(0,Kw(e.style.padding)):Math.max(0,(void 0!==e.style?.paddingLeft?Kw(e.style.paddingLeft):7.2)+(void 0!==e.style?.paddingRight?Kw(e.style.paddingRight):7.2)))+(e.style?.borderLeft?Math.max(0,Kw(e.style.borderLeft.width)):1)+(e.style?.borderRight?Math.max(0,Kw(e.style.borderRight.width)):1)}function Gw(e,t,n){const r=Math.max(1,e.rows.length),o=n.bounds.height/r,a=Array(r).fill(o),i=new Map(n.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));for(let s=0;s<r;s+=1){const n=qw(e.rows[s]?.style?.height);if(null!==n){a[s]=Math.max(1,Kw(n));continue}const r=t.find(e=>e.rowIndex===s&&1===e.rowSpan);if(r){const e=i.get(`${r.rowIndex}:${r.cellIndex}`);e&&(a[s]=Math.max(1,e.height))}}return a}function Yw(e,t,n){const r=Math.max(1,...t.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),o=r-1,a=Array(r).fill(n.bounds.width/r),i=new Map(n.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));if(e.gridCols&&e.gridCols.length>=r)for(let l=0;l<r;l+=1)a[l]=Math.max(1,Kw(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<r;l+=1)s[l]=Math.max(10,_w(a[l]));return{widthsPt:s,maxColumnIndex:o}}function Zw(e,t,n){if("row"!==t.type)return e;const r=t.initialRowHeightPx??Kw(10),o=Math.max(Kw(10),t.minRowHeightPx??Kw(10)),a=Math.max(10,_w(Math.max(o,r+n)));return function(e,t,n,r){return qg(e,t,{[n]:r})}(e,t.tableId,t.index,a)}function Jw(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 Qw=null;function eI(e,t){Qw=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 tI(e){e&&Qw!==e||(Qw=null,document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize"))}function nI(e,t){eI(e,t)}function rI(e){return"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(e):globalThis.setTimeout(e,16)}function oI(e){"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)}function aI(e){const[t,n]=$t(null);let r=null,o=null,a=null,i=null;const s={},l=()=>{r=null;const n=o;if(o=null,!n||t())return;const a=e.surfaceRef();if(!a)return void tI();const i=Uw(n,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());i?eI("left"===i.side||"right"===i.side,s):tI()},c=fw(),d=e=>{c.owns(e)&&t()&&(i={clientX:e.clientX,clientY:e.clientY},null===a&&(a=rI(u)))},u=()=>{a=null;const r=i;i=null;const o=t();r&&o&&n({...o,currentPos:"column"===o.type?r.clientX:r.clientY,guideBounds:Jw(e.viewportRef)})},p=()=>{o=null,i=null,null!==r&&(oI(r),r=null),null!==a&&(oI(a),a=null),n(null),tI(s),c.release(),window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f)},f=n=>{if(!c.owns(n))return;const r=t();if(!r)return;const o=e.zoomFactor?.()??1,a=(("column"===r.type?n.clientX:n.clientY)-r.initialPos)/o;Math.abs(a)>=2&&e.applyTransactionalState(e=>"row"===r.type?Zw(e,r,a):function(e,t,n){if("column"!==t.type)return e;const r=_w(n),o=t.maxColumnIndex??t.index,a={...t.columnWidthsPt??{}};for(let m=0;m<=o;m+=1)void 0===a[m]&&(a[m]=10);const i=t.minColumnWidthsPx??{},s=a[t.index]??10,l=Math.max(10,_w(i[t.index]??Kw(10)));if(t.resizeFromLeftEdge){const n=Math.max(0,t.initialTableIndentLeftPt??0);let o=Math.max(l,s-r),i=s-o;n+i<0&&(i=-n,o=s-i),a[t.index]=o;const c=Object.values(a).reduce((e,t)=>e+t,0),d=Math.max(0,n+i);return Gg(e,t.tableId,a,c,d)}let c=Math.max(l,s+r);const d=t.index===o;if(d)a[t.index]=c;else{const e=t.index+1,n=a[e]??10,r=Math.max(10,_w(i[e]??Kw(10)));let o=n-(c-s);o<r&&(o=r,c=s+(n-r),c=Math.max(l,c)),a[t.index]=c,a[e]=o}const u=Object.values(a).reduce((e,t)=>e+t,0),p=jw(e,t.tableId),f=qw(p?.style?.width),g=d?u:null!==f?f:void 0;return Gg(e,t.tableId,a,g)}(e,r,a)),p()};return{resizing:t,handlePointerMove:e=>{c.owns(e)&&(t()||(o={clientX:e.clientX,clientY:e.clientY},null===r&&(r=rI(l))))},handlePointerDown:t=>{o=null,null!==r&&(oI(r),r=null),tI();const a=e.surfaceRef();if(!a)return!1;const i=Uw(t,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());if(!i)return!1;const l=e.state(),u=Vo(i.tableNode);if("left"===i.side||"right"===i.side){const r="left"===i.side&&0===i.layoutEntry.visualColumnIndex,o=r?0:"left"===i.side?i.layoutEntry.visualColumnIndex-1:i.layoutEntry.visualColumnIndex+i.layoutEntry.colSpan-1;if(o<0)return!1;const a="left"===i.side?i.rect.left:i.rect.right,{widthsPt:p,maxColumnIndex:g}=Yw(i.tableNode,u,i.tableGeometry),m=function(e,t,n,r){const o=Kw(10),a={},i=new Map(r.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 r=s.visualColumnIndex,l=a[r]??o,c=n.blocks.reduce((t,n)=>"paragraph"!==n.type?t:Math.max(t,Nn(n,e.document.styles)),1);a[r]=Math.max(l,c+Xw(n)+12,o)}return a}(l,i.tableNode,u,i.tableGeometry);return n({type:"column",tableId:i.tableId,index:o,initialPos:a,currentPos:a,columnWidthsPt:p,maxColumnIndex:g,minColumnWidthsPx:m,resizeFromLeftEdge:r,initialTableIndentLeftPt:qw(i.tableNode.style?.indentLeft)??0,guideBounds:Jw(e.viewportRef)}),nI(!0,s),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",f),t.preventDefault(),t.stopPropagation(),!0}const p=Gw(i.tableNode,u,i.tableGeometry),g="top"===i.side?i.layoutEntry.visualRowIndex-1:i.layoutEntry.visualRowIndex+i.layoutEntry.rowSpan-1;if(g<0||g>=p.length)return!1;const m="top"===i.side?i.rect.top:i.rect.bottom,h=function(e,t,n,r){const o=e.rows[r];if(!o)return Kw(10);const a=Kw(10);let i=a;for(let s=0;s<o.cells.length;s+=1){if(!o.cells[s])continue;const e=t.find(e=>e.rowIndex===r&&e.cellIndex===s);if(!e||1!==e.rowSpan)continue;const a=n.cells.find(e=>e.rowIndex===r&&e.cellIndex===s);a&&(i=Math.max(i,a.contentMinHeight+4))}return Math.max(a,i)}(i.tableNode,u,i.tableGeometry,g);return n({type:"row",tableId:i.tableId,index:g,initialPos:m,currentPos:m,initialRowHeightPx:p[g],minRowHeightPx:h,guideBounds:Jw(e.viewportRef)}),nI(!1,s),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",f),t.preventDefault(),t.stopPropagation(),!0},stop:p}}var iI=null;function sI(e){const t=(e.bounds.width+(e.currentClientX-e.startClientX))/e.bounds.width,n=(e.bounds.height+(e.currentClientY-e.startClientY))/e.bounds.height,r=Object.values(e.widthsPt),o=r.length>0?Math.min(...r):1,a=o>0?10/o:0,i=Kw(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 lI(e){const[t,n]=$t(null);let r=null,o=null;const a={},i=fw(),s=e=>{i.owns(e)&&t()&&(o={clientX:e.clientX,clientY:e.clientY},null===r&&(r=rI(l)))},l=()=>{r=null;const e=o;o=null,e&&n(t=>t?{...t,currentClientX:e.clientX,currentClientY:e.clientY}:null)},c=()=>{o=null,null!==r&&(oI(r),r=null),n(null),i.release(),window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d),iI===a&&(iI=null,"nwse-resize"===document.body.style.cursor&&(document.body.style.cursor=""))},d=n=>{if(!i.owns(n))return;const r=t();if(r){const t=Math.abs(n.clientX-r.startClientX),o=Math.abs(n.clientY-r.startClientY);if(t>=2||o>=2){const t={...r,currentClientX:n.clientX,currentClientY:n.clientY},{scaleX:o,scaleY:a}=sI(t);e.applyTransactionalState(e=>function(e,t,n,r){const o={};for(const l of Object.keys(t.widthsPt)){const e=Number(l);o[e]=Math.max(10,t.widthsPt[e]*n)}const a=Object.values(o).reduce((e,t)=>e+t,0),i=Gg(e,t.tableId,o,a),s={};return t.rowHeightsPx.forEach((e,t)=>{s[t]=Math.max(10,_w(e*r))}),qg(i,t.tableId,s)}(e,t,o,a))}}c()};return{resizing:t,previewRect:()=>{const e=t();if(!e)return null;const{scaleX:n,scaleY:r}=sI(e);return{left:e.bounds.left,top:e.bounds.top,width:e.bounds.width*n,height:e.bounds.height*r}},handlePointerDown:(t,r)=>{const o=e.surfaceRef();if(!o)return;const l=Ww(o,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.()).find(e=>e.tableId===t),c=jw(e.state(),t);if(!l||!c)return;const u=Vo(c),{widthsPt:p}=Yw(c,u,l),f=Gw(c,u,l),g=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:r.clientX,startClientY:r.clientY,currentClientX:r.clientX,currentClientY:r.clientY,widthsPt:p,totalWidthPt:g,rowHeightsPx:f}),iI=a,document.body.style.cursor="nwse-resize",i.claim(r),window.addEventListener("pointermove",s),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),r.preventDefault(),r.stopPropagation()},stop:c}}var cI=null;function dI(e,t,n,r){if(!e)return null;for(const o of e)if("table"===o.type){if(o.id===t)return{table:o,nested:n,movableTopLevelStory:r};for(const e of o.rows)for(const n of e.cells){const e=dI(n.blocks,t,!0,!1);if(e)return e}}return null}function uI(e,t){for(const n of Si(e)){for(const e of[n.blocks,n.header,n.footer]){const n=dI(e,t,!1,!0);if(n)return n}for(const e of[n.firstPageHeader,n.evenPageHeader,n.firstPageFooter,n.evenPageFooter]){const n=dI(e,t,!1,!1);if(n)return n}}for(const n of Object.values(e.footnotes?.items??{})){const e=dI(n.blocks,t,!1,!1);if(e)return e}for(const n of Object.values(e.endnotes?.items??{})){const e=dI(n.blocks,t,!1,!1);if(e)return e}return null}function pI(e){return function(e){const[t,n]=$t(!1),[r,o]=$t(null),[a,i]=$t(null),[s,l]=$t(0),[c,d]=$t(0),[u,p]=$t({x:0,y:0});let f=null,g=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=fw(),v=()=>{g=null,null!==f&&(oI(f),f=null),n(!1),o(null),i(null),y.release(),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",I),window.removeEventListener("pointercancel",I),cI===m&&(cI=null,"grabbing"===document.body.style.cursor&&(document.body.style.cursor=""))},x=()=>{f=null;const n=g;if(g=null,!n||!t())return;p({x:n.clientX,y:n.clientY});const o=e.resolvePositionAtSurfacePoint(n.clientX,n.clientY),a=r()?.tableId;o&&a&&function(e,t,n){const r=uI(e,n);return Boolean(r?.table&&Mo(r.table).some(e=>e.id===t))}(e.state().document,o.paragraphId,a)?b(null):b(o)},w=e=>{if(y.owns(e)){if(!t()){if(Math.abs(e.clientY-s())<=4)return;n(!0),cI=m,document.body.style.cursor="grabbing"}g={clientX:e.clientX,clientY:e.clientY},null===f&&(f=rI(x))}},I=n=>{if(!y.owns(n))return;const o=r();if(t()){const t=e.resolvePositionAtSurfacePoint(n.clientX,n.clientY),r=o?.tableId;r&&e.applyTransactionalState(e=>{const o=uI(e.document,r),a=o?.table;if(a?.style?.floating){const t=a.style.floating;return Vg(e,r,"floating",{...t,x:(t.x??0)+(n.clientX-c())*Xr,y:(t.y??0)+(n.clientY-s())*Xr,xAlign:void 0,yAlign:void 0})}return o&&!o.nested&&o.movableTopLevelStory&&t?C(e,r,t):e})}v(),e.focusInput()};return{dragging:t,draggedTableInfo:r,mousePos:u,dropTargetPos:a,handlePointerDown:(e,t)=>{t.preventDefault(),t.stopPropagation();const r=t.currentTarget.getBoundingClientRect(),a=r;o({tableId:e,width:a.width,height:a.height,offsetX:t.clientX-r.left,offsetY:t.clientY-r.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)}function fI(e){const t=oo(e);if(t.error||"TC"!==t.command)return;const[n,...r]=t.tokens.slice(1);if(!n||"quoted"!==n.kind||!n.value.trim()||n.value.length>4096||/[\u0000-\u001f\u007f]/.test(n.value))return;let o,a=1,i=!1;const s=/* @__PURE__ */new Set;for(let l=0;l<r.length;l++){const e=r[l];if("switch"!==e.kind)return;const t=e.value.toLowerCase();if(s.has(t))return;if(s.add(t),"n"===t){i=!0;continue}if("f"!==t&&"l"!==t)return;const n=r[++l];if(!n||"switch"===n.kind)return;if("l"===t){if(!/^[1-9]$/.test(n.value))return;a=Number(n.value)}else{if(!/^[A-Za-z]$/.test(n.value))return;o=n.value}}return{text:n.value,level:a,...void 0===o?{}:{identifier:o},omitPageNumber:i}}function gI(e){const t=oo(e);if(t.error||"TOC"!==t.command)return;const n=t.tokens.slice(1);let r,o,a,i,s,l,c,d,u,p,f,g,m,h,b=!1,y=!1,v=!1;const x=/* @__PURE__ */new Set;for(let I=0;I<n.length;I++){const e=n[I];if("switch"!==e.kind)return;const t=e.value.toLowerCase();if(x.has(t))return;if(x.add(t),"f"===t){const e=n[++I];if(!e||"switch"===e.kind||!/^[A-Za-z]$/.test(e.value))return;i=e.value.toUpperCase()}else if("l"===t){const e=n[++I];if(!e||"switch"===e.kind)return;const t=/^([1-9])-([1-9])$/.exec(e.value);if(!t||Number(t[1])>Number(t[2]))return;s=[Number(t[1]),Number(t[2])]}else if("o"===t){const e=n[++I];if("quoted"!==e?.kind)return;const t=/^([1-9])-([1-9])$/.exec(e.value);if(!t)return;if(r=Number(t[1]),o=Number(t[2]),r>o)return}else if("t"===t){const e=n[++I];if("quoted"!==e?.kind||e.value.length>4096||/[\r\n\t\\]/.test(e.value))return;const t=e.value.split(",").map(e=>e.trim());if(t.length<2||t.length%2||t.length>128)return;const r=/* @__PURE__ */new Set,o=[];for(let n=0;n<t.length;n+=2){const e=t[n],a=t[n+1],i=e.toLowerCase();if(!e||e.length>256||!/^[1-9]$/.test(a)||r.has(i))return;r.add(i),o.push({name:e,level:Number(a)})}a=o}else if("h"===t)b=!0;else if("z"===t)y=!0;else if("u"===t)v=!0;else if("c"===t||"a"===t||"b"===t||"s"===t){const e=n[++I];if(!e||"switch"===e.kind||!e.value||e.value.length>64||!/^[A-Za-z_][A-Za-z0-9_ ]*$/.test(e.value))return;if("c"===t){if(void 0!==l||void 0!==c)return;l=e.value}else if("a"===t){if(void 0!==l||void 0!==c)return;c=e.value}else if("b"===t){if(void 0!==d)return;d=e.value}else{if(void 0!==u)return;u=e.value}}else if("d"===t||"p"===t){const e=n[++I];if("quoted"!==e?.kind||!e.value||e.value.length>15||[...e.value.replace(/^\t$/,"")].some(e=>e.charCodeAt(0)<32||127===e.charCodeAt(0)))return;if("d"===t){if(void 0!==p)return;p=e.value}else{if(void 0!==f)return;f=e.value}}else if("n"===t){const e=n[++I];if(!e||"switch"===e.kind)return;const t=/^([1-9])-([1-9])$/.exec(e.value);if(!t||Number(t[1])>Number(t[2])||g)return;g=[Number(t[1]),Number(t[2])]}else if("w"===t)m=!0;else{if("x"!==t)return;h=!0}}if(void 0!==l||void 0!==c){if(void 0!==r||a||v||void 0!==i||s)return;return{startLevel:1,endLevel:9,hyperlinks:b,hideWebNumbers:y,useOutline:!1,...l?{captionIdentifier:l}:{},...c?{unlabeledIdentifier:c}:{},...d?{scopeBookmark:d}:{},...u?{chapterIdentifier:u}:{},...p?{chapterSeparator:p}:{},...f?{entryPageSeparator:f}:{},...g?{omitPages:g}:{},...m?{preserveTabs:m}:{},...h?{preserveLineBreaks:h}:{}}}if(void 0!==i&&void 0===r&&!a&&!v)return{startLevel:s?.[0]??1,endLevel:s?.[1]??9,hyperlinks:b,hideWebNumbers:y,useOutline:v,tcIdentifier:i};if(s&&void 0===i)return;const w=void 0===i?{}:{tcIdentifier:i,tcMixedRange:s??[1,9]};if(void 0===r||void 0===o){if(v&&!a)return{startLevel:1,endLevel:9,hyperlinks:b,hideWebNumbers:y,useOutline:v,...w};if(!a||v)return;return{startLevel:1,endLevel:Math.max(...a.map(e=>e.level)),hyperlinks:b,hideWebNumbers:y,useOutline:v,styleMappings:a,customOnly:!0,...w}}return{startLevel:r,endLevel:o,hyperlinks:b,hideWebNumbers:y,useOutline:v,...a?{styleMappings:a}:{},...w}}function mI(e){return!e.sdtWrappers?.length&&!e.numberingRevision&&!e.dropCap&&e.runs.every(e=>!(e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.hidden||e.styles?.rtl))}function hI(e,t=!1){if(!mI(e)||e.list||e.dropCap||1!==e.runs.length)return!1;const n=e.runs[0];return"text"===n.kind&&n.text.length<=8192&&(n.text.includes("\t")||t&&n.text.length>0)&&!/[\r\n]/.test(n.text)}function bI(e){const t=[];for(let n=0;n<e.length;){if("paragraph"!==e[n]?.type){n++;continue}const r=n,o=[];for(;n<e.length&&"paragraph"===e[n]?.type;)o.push(e[n]),n++;const a=Wo(o);if(!a.diagnostics.length)for(const e of a.spans){if(null!==e.parentIndex||!e.separator||!e.end||e.beginMarker.fieldLock||e.beginMarker.dirty||e.code.some(e=>"instruction"!==e.kind)||e.begin.paragraphIndex!==e.separator.paragraphIndex||e.begin.paragraphIndex>=e.end.paragraphIndex)continue;const n=o[e.begin.paragraphIndex],a=o[e.end.paragraphIndex];if(!mI(n)||!mI(a)||0!==e.begin.runIndex||e.separator.runIndex!==n.runs.length-1||0!==e.end.runIndex||1!==a.runs.length||"fieldChar"!==n.runs[0]?.kind||"fieldChar"!==n.runs.at(-1)?.kind||"fieldChar"!==a.runs[0]?.kind)continue;const i=gI(e.code.map(e=>"instruction"===e.kind?e.raw:"").join(""));if(!i)continue;const s=e.begin.paragraphIndex,l=e.end.paragraphIndex;o.slice(s+1,l).every(e=>hI(e,void 0!==i.tcIdentifier))&&(e.result.length!==l-s-1||e.result.some((e,t)=>"run"!==e.kind||e.point.paragraphIndex!==s+t+1)||t.push({...i,startBlockIndex:r+s,endBlockIndex:r+l}))}}return 1===t.length?t[0]:void 0}function yI(e,t){const n=Y(e,t),r=Si(e),o=/* @__PURE__ */new Map;return r.forEach((e,t)=>{for(const n of e.blocks)"paragraph"===n.type&&o.set(n.id,o.has(n.id)?null:t)}),(a,i)=>{if(i)return i.paragraphId===a?function(e,t,n,r=Y(e,t)){if(n.omitPageNumber)return"";const o=r.pageIndexAt(n.paragraphId,n.offset);if(void 0===o)return;const a=r.forPage(o);if(a.sectionNumber!==n.sectionIndex+1||void 0===a.pageNumber)return;const i=Si(e)[n.sectionIndex];if(!i)return;const s=mo(a.pageNumber,i.pageNumbering?.format);return void 0===s?void 0:String(s)}(e,t,i,n):void 0;const s=o.get(a);if(null==s)return;const l=r[s],c=n.pageIndexAt(a,0);if(void 0===c)return;const d=n.forPage(c);return d.sectionNumber===s+1&&void 0!==d.pageNumber?mo(d.pageNumber,l.pageNumbering?.format):void 0}}var vI=e=>` TOC \\o "1-${e}" \\h \\z \\u `,xI=e=>Math.round(e/Qr*96);function wI(e,t,n=9){if(n<t.endLevel||t.styleMappings?.some(e=>e.level>n))return;if(void 0!==t.tcIdentifier){const r=Si(e.document);if(r.some(e=>e.blocks.some(e=>"paragraph"!==e.type||e.runs.some(e=>"textBox"===e.kind||"opaque"===e.kind))))return;const o=function(e){const t=[],n=Si(e),r=/* @__PURE__ */new Set;for(const[o,a]of n.entries()){for(const e of a.blocks){if(r.has(e.id))return;r.add(e.id)}for(let e=0;e<a.blocks.length;){if("paragraph"!==a.blocks[e]?.type){e++;continue}const n=[];for(;"paragraph"===a.blocks[e]?.type;)n.push(a.blocks[e++]);const r=Wo(n);if(r.diagnostics.length)return;for(const e of r.spans){const r=e.code.map(e=>"instruction"===e.kind?e.raw:"").join("");if("TC"!==oo(r).command)continue;const a=fI(r);if(!a||null!==e.parentIndex||!e.end||e.separator||e.begin.paragraphIndex!==e.end.paragraphIndex||e.beginMarker.fieldLock||e.beginMarker.dirty||e.code.some(e=>"instruction"!==e.kind)||e.result.length)return;const i=n[e.begin.paragraphIndex],s=i.runs.slice(e.begin.runIndex,e.end.runIndex+1);if(i.sdtWrappers?.length||i.numberingRevision||i.dropCap||new Set(i.runs.map(e=>e.id)).size!==i.runs.length||s.some(e=>e.text.length||e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.link||"fieldChar"!==e.kind&&"fieldInstruction"!==e.kind))return;if(t.push({...a,sectionIndex:o,paragraphId:i.id,runId:e.begin.runId,offset:e.begin.offset,raw:r}),t.length>2048)return}}}return t}(e.document);if(!o)return;if("C"===t.tcIdentifier&&o.some(e=>void 0===e.identifier))return;const[a,i]=t.tcMixedRange??[t.startLevel,t.endLevel];if(i>n)return;const s=o.filter(e=>e.identifier?.toUpperCase()===t.tcIdentifier&&e.level>=a&&e.level<=i).map(e=>({id:e.paragraphId,level:e.level,text:e.text,tc:e}));if(!t.tcMixedRange)return s;const{tcIdentifier:l,tcMixedRange:c,...d}=t,u=wI(e,d,n);if(!u)return;const p=/* @__PURE__ */new Map,f=/* @__PURE__ */new Set;for(const e of r){const t=bI(e.blocks);if(t)for(const n of e.blocks.slice(t.startBlockIndex,t.endBlockIndex+1))f.add(n.id);for(const n of e.blocks)p.set(n.id,p.size)}const g=new Set(o.map(e=>e.paragraphId));if(u.some(e=>g.has(e.id)||f.has(e.id)||!p.has(e.id))||s.some(e=>f.has(e.id)||!p.has(e.id)))return;return[...u,...s].sort((e,t)=>p.get(e.id)-p.get(t.id)||(e.tc?.offset??0)-(t.tc?.offset??0))}if(!t.styleMappings&&!t.useOutline)return function(e,t=3){const n=[];for(const r of Co(e.document)){const e=o(r.style?.styleId);if(null===e||e>t)continue;const a=po(r).trim();a&&n.push({id:r.id,level:e,text:a})}return n}(e,t.endLevel).filter(e=>e.level>=t.startLevel);const r=t.useOutline?function(e){const t=e.styles,n=/* @__PURE__ */new Map;for(const o of Object.values(t??{}))n.set(o.id,n.has(o.id)?null:o);const r=e=>null===e||9===e?null:Number.isInteger(e)&&e>=0&&e<9?e+1:void 0,a=[...n.values()].filter(e=>"paragraph"===e?.type&&e.isDefault),i=1===a.length?a[0].id:io(t);return e=>{if(void 0!==e.style?.outlineLevel)return r(e.style.outlineLevel);if(!e.style?.styleId&&a.length>1)return;let t=e.style?.styleId??i;const s=/* @__PURE__ */new Set;for(;t;){if(s.has(t)||s.size>=128)return;s.add(t);const e=n.get(t);if(null===e)return;if(!e){const e=o(t);return null!==e?e:/^(normal|caption)$/i.test(t)?null:void 0}if("paragraph"!==e.type)return;if(void 0!==e.paragraphStyle?.outlineLevel)return r(e.paragraphStyle.outlineLevel);const a=D(e)??We(e),i=o(a);if(null!==i)return i;t=e.basedOn}return null}}(e.document):void 0,a=Object.values(e.document.styles??{}),i=e=>e.trim().toLowerCase(),s=/* @__PURE__ */new Map;for(const{name:o,level:d}of t.styleMappings??[]){const e=i(o),t=a.filter(t=>i(t.id)===e||i(t.name)===e);if(1!==t.length||"paragraph"!==t[0].type)return;const n=t[0].id;if(s.has(n))return;s.set(n,d)}const l=/* @__PURE__ */new Set;for(const o of Si(e.document)){const e=bI(o.blocks);if(e)for(const t of o.blocks.slice(e.startBlockIndex,e.endBlockIndex+1))l.add(t.id)}const c=[];for(const d of Co(e.document)){const e=d.style?.styleId,n=void 0===e?void 0:s.get(e),a=r?r(d):t.customOnly?null:o(e);if(void 0===a)return;const i=null!==a&&a>=t.startLevel&&a<=t.endLevel?a:void 0;if(void 0!==n&&void 0!==i&&n!==i)return;const u=n??i;if(void 0===u)continue;if(l.has(d.id))return;const p=po(d).trim();p&&c.push({id:d.id,level:u,text:p})}return c}function II(e){const t=Io(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 SI(e,t){const n=Ma("");return n.runs=e,t&&(n.style=t),n}function CI(e,t){return e.tc?.omitPageNumber?e.text:e.text+"\t"+(t??"")}function kI(e,t,n){return SI([II({text:CI(e,t)})],{...e.tc?.omitPageNumber?{}:{tabs:[{position:n,type:"right",leader:"dot"}]},spacingAfter:xI(40),indentLeft:xI(397*(e.level-1))})}function TI(e){const{width:t,margins:n}=e.pageSettings,r=Math.max(0,t-n.left-n.right);return Qt(r*Xr,2)}function PI(e){return SI([II({text:"",fieldChar:{kind:"begin"}}),II({text:"",fieldInstruction:vI(e)}),II({text:"",fieldChar:{kind:"separate"}})])}function RI(e,t,n,r){const o=Si(e.document),a=o[t];if(!a)return e;const i=[...o];return i[t]={...a,blocks:n},{...e,document:{...e.document,sections:i},selection:J(Xo(r,0))}}function MI(e,t=()=>{},n=3){if("main"!==Yo(e)||!Number.isInteger(n)||n<1||n>9)return e;const r=ya(e),o=Si(e.document)[r];if(!o)return e;const a=wI(e,{startLevel:1,endLevel:n,hyperlinks:!0,hideWebNumbers:!0,useOutline:!0},n);if(!a)return e;const i=function(e,t,n,r){const o=e.map(e=>{const r=t(e.id);return kI(e,void 0!==r&&Ja(r)?r:void 0,n)});return[PI(r),...o,SI([II({text:"",fieldChar:{kind:"end"}})])]}(a,t,TI(o),n),s=Qa(e,e.selection.focus),l=o.blocks.findIndex(e=>e.id===s.paragraphId||"paragraph"!==e.type&&Mo(e).some(e=>e.id===s.paragraphId)),c=-1===l?o.blocks.length:l+1;return RI(e,r,[...o.blocks.slice(0,c),...i,...o.blocks.slice(c)],i[0])}var AI=bI;function OI(e,t=()=>{},n=9){if("main"!==Yo(e)||!Number.isInteger(n)||n<1||n>9)return e;const r=ya(e),o=Si(e.document)[r];if(!o)return e;const a=AI(o.blocks);if(!a||n<a.endLevel)return e;const i=wI(e,a,n);if(!i)return e;const s=new Map(Co(e.document).map(e=>[e.id,e]));if(i.some(e=>{const t=s.get(e.id);return e.tc?!t:!t||t.sdtWrappers?.length||t.numberingRevision||t.dropCap||t.runs.some(e=>"text"!==e.kind||e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.hidden||e.styles?.rtl)||e.text.length>4096||/[\r\n\t]/.test(e.text)}))return e;const l=o.blocks.slice(a.startBlockIndex+1,a.endBlockIndex),c=i.map(e=>e.tc?.omitPageNumber?"":t(e.id,e.tc));if(c.some((e,t)=>!i[t].tc?.omitPageNumber&&(void 0!==e&&!Ja(e)||void 0===e&&(!!i[t].tc||!!a.tcMixedRange))))return e;if(c.some(e=>void 0===e)&&l.some(e=>"paragraph"===e.type&&/\t\S/.test(po(e))))return e;const d=i.map((e,t)=>kI(e,c[t],TI(o)));if(l.length===d.length&&l.every((e,t)=>"paragraph"===e.type&&po(e)===po(d[t])))return e;if(l.some(e=>"paragraph"===e.type&&e.runs.some(e=>e.styles?.link)))return e;if(void 0!==a.tcIdentifier){const t=new Set(l.map(e=>e.id));if(e.trackChangesEnabled||t.has(e.selection.anchor.paragraphId)||t.has(e.selection.focus.paragraphId)||[...Object.values(e.document.bookmarks?.items??{}),...Object.values(e.document.comments?.items??{})].some(e=>[e.start,e.end].some(e=>e&&t.has(e.paragraphId))))return e}return RI(e,r,[...o.blocks.slice(0,a.startBlockIndex+1),...d,...o.blocks.slice(a.endBlockIndex)],d[0]??o.blocks[a.startBlockIndex])}var BI=e=>e.map(e=>"instruction"===e.kind?e.raw??"":"").join(""),FI=e=>["text","fieldChar","fieldInstruction"].includes(e.kind)&&!e.revision&&!e.revisionRangeMarker&&!e.sdtWrappers?.length&&!e.styles?.hidden&&!e.styles?.rtl,EI=e=>!e.numberingRevision&&!e.dropCap&&!e.list&&!e.style?.bidi&&(!e.style?.textDirection||"lrTb"===e.style.textDirection)&&e.runs.every(FI)&&new Set(e.runs.map(e=>e.id)).size===e.runs.length,DI="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function LI(e){const t=e.sdtPr;return!!e.groupId&&(!t.lock||"unlocked"===t.lock||"sdtLocked"===t.lock)&&!t.dataBinding&&!t.temporary&&!t.showingPlcHdr&&!t.repeatingSectionProperties&&!t.subtype&&function(e){if(!e||e.length>8192||/<!|<\?/.test(e))return!1;try{const t=(new Ei.DOMParser).parseFromString('<root xmlns:w="'+DI+'">'+e+"</root>","application/xml").documentElement;if(!t||"root"!==t.localName)return!1;const n=e=>{const t=[];for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes.item(n);if(1===r?.nodeType)t.push(r);else if(3!==r?.nodeType||r.nodeValue?.trim())return}return t},r=n(t);if(1!==r?.length||r[0].namespaceURI!==DI||"docPartObj"!==r[0].localName)return!1;const o=n(r[0]);if(!o||o.length<1||o.length>3)return!1;const a=/* @__PURE__ */new Set;for(const e of o){const t=e.localName;if(e.namespaceURI!==DI||!t||a.has(t)||!["docPartGallery","docPartCategory","docPartUnique"].includes(t)||0!==n(e)?.length)return!1;a.add(t);const r=e.getAttributeNS(DI,"val");if("docPartGallery"===t&&"Table of Contents"!==r)return!1;if("docPartCategory"===t&&!r)return!1;if("docPartUnique"===t&&r&&!["1","0","true","false","on","off"].includes(r))return!1}return a.has("docPartGallery")}catch{return!1}}(t.unknownXml??"")}function NI(e){const t=e[0]?.sdtWrappers??[];if(!t.length)return e.every(e=>!e.sdtWrappers?.length);if(1!==t.length||!LI(t[0]))return!1;const n=JSON.stringify(t);return e.every(e=>JSON.stringify(e.sdtWrappers??[])===n)}function zI(e,t=ya(e),n=!1){if(!n&&("main"!==Yo(e)||e.trackChangesEnabled))return;const r=Si(e.document)[t];if(!r)return;const o=[];let a=0;for(let i=0;i<r.blocks.length;){if("paragraph"!==r.blocks[i]?.type){i++;continue}const e=[];for(;"paragraph"===r.blocks[i]?.type;)e.push(r.blocks[i++]);const t=Wo(e);if(t.diagnostics.length)return;for(const n of t.spans){const r=BI(n.code);if("TOC"!==oo(r).command)continue;a++;const i=gI(r);if(!i||void 0!==i.tcIdentifier||null!==n.parentIndex||!n.separator||!n.end||n.beginMarker.fieldLock||n.beginMarker.dirty||n.code.some(e=>"instruction"!==e.kind)||n.begin.paragraphIndex!==n.separator.paragraphIndex||0!==n.begin.runIndex||n.end.runIndex!==e[n.end.paragraphIndex].runs.length-1)continue;const s=n.begin.paragraphIndex,l=n.end.paragraphIndex,c=e.slice(s,l+1);if(c.length>2050||!c.every(EI)||!NI(c)||new Set(c.map(e=>e.id)).size!==c.length)continue;const d=[],u=/* @__PURE__ */new Set;let p=!0;for(let o=s;o<=l;o++){const r=e[o],a=o===s?n.separator.runIndex+1:0,i=o===l?n.end.runIndex:r.runs.length;if(a===i&&(o===s||o===l))continue;const c=t.spans.filter(e=>e.parentIndex===n.index&&e.begin.paragraphIndex===o);if(1!==c.length){p=!1;break}const f=c[0];if(!f.separator||!f.end||f.beginMarker.fieldLock||f.beginMarker.dirty||f.end.paragraphIndex!==o||f.separator.paragraphIndex!==o||f.begin.runIndex<=a||f.end.runIndex!==i-1||f.code.some(e=>"instruction"!==e.kind)||!f.result.length||f.result.length>128||f.result.some(e=>"run"!==e.kind)){p=!1;break}const g=ti(BI(f.code));if("PAGEREF"!==g?.type){p=!1;break}const m=r.runs.slice(a,f.begin.runIndex),h=m.map(e=>e.text).join(""),b=r.runs.slice(f.separator.runIndex+1,f.end.runIndex),y=b.map(e=>e.text).join("");if(b.length!==f.result.length||b.some((e,t)=>{const n=f.result[t];return"text"!==e.kind||!e.text.length||"run"!==n?.kind||n.point.paragraphIndex!==o||n.point.runIndex!==f.separator.runIndex+1+t})||!y.length||y.length>128||/[\r\n\t]/.test(y)||b.length>1&&!/^(?:[0-9]+|[A-Za-z]+)$/.test(y)||h.length>8192||!h.endsWith("\t")||!h.slice(0,-1).trim()||/[\r\n]/.test(h)||!m.every(e=>"text"===e.kind)||[...m,...b].some(e=>e.styles?.link&&e.styles.link!=="#"+g.bookmark)){p=!1;break}u.add(f.index),d.push({paragraphId:r.id,runIds:b.map(e=>e.id),bookmark:g.bookmark})}!p||!d.length||d.length>2048||n.result.some(e=>"nested"===e.kind&&!u.has(e.fieldIndex))||t.spans.some(e=>e.parentIndex===n.index&&!u.has(e.index))||o.push({entries:d,paragraphIds:new Set(c.map(e=>e.id)),hyperlinks:i.hyperlinks})}}return 1===a&&1===o.length?o[0]:void 0}function $I(e){return!!zI(e)}function HI(e,t,n){const r=Si(e),o=/* @__PURE__ */new Map;r.forEach((e,t)=>e.blocks.forEach(e=>{"paragraph"===e.type&&o.set(e.id,o.has(e.id)?null:{p:e,section:t})}));const a=e.bookmarks,i=/* @__PURE__ */new Map;for(const l of Object.values(a?.items??{})){const e=l.name.toLowerCase();i.set(e,i.has(e)?null:l)}const s=Y(e,t);return n.entries.map(e=>{const t=i.get(e.bookmark.toLowerCase());if(!t||t.name!==e.bookmark||!a?.order.includes(t.id)||!t.start||!t.end||void 0!==t.colFirst||void 0!==t.colLast||t.start.paragraphId!==t.end.paragraphId||n.paragraphIds.has(t.start.paragraphId))return;const l=o.get(t.start.paragraphId);if(!l||!Number.isInteger(t.start.offset)||!Number.isInteger(t.end.offset)||t.start.offset<0||t.end.offset<t.start.offset||t.end.offset>Za(l.p))return;const c=s.pageIndexAt(l.p.id,t.start.offset);if(void 0===c)return;const d=s.forPage(c);if(d.sectionNumber!==l.section+1||void 0===d.pageNumber)return;const u=mo(d.pageNumber,r[l.section].pageNumbering?.format);return void 0===u?void 0:String(u)})}function jI(e,t){if(e.length<t.length)return;let n=0;return t.map((r,o)=>{const a=o===t.length-1?e.length-n:Math.min(r,e.length-n-(t.length-o-1)),i=e.slice(n,n+a);return n+=a,i})}function WI(e,t,n){if(!Number.isInteger(n)||n<0)return;const r=Si(e.document),o=r.flatMap((e,n)=>e.blocks.filter(e=>e.id===t&&"paragraph"===e.type).map(e=>({p:e,i:n})));if(1!==o.length)return;const{p:a,i:i}=o[0];if("paragraph"!==a.type||n>Za(a))return;const s=r[i].blocks,l=bI(s);let c,d,u;if(l?.hyperlinks&&s.slice(l.startBlockIndex+1,l.endBlockIndex).some(e=>e.id===t)){const n=a.runs[0]?.styles?.link;if(!n?.startsWith("#")||n.length<2)return;if(c=n.slice(1),void 0!==l.tcIdentifier){const n=wI(e,l),r=s.slice(l.startBlockIndex+1,l.endBlockIndex),o=n?.[r.findIndex(e=>e.id===t)];if(!o||n?.length!==r.length)return;const i=po(a);if(o.tc?.omitPageNumber?i!==o.text:!i.startsWith(o.text+"\t"))return;u=o}d=new Set(s.slice(l.startBlockIndex,l.endBlockIndex+1).map(e=>e.id))}else{const r=function(e,t,n,r){const o=zI(e,t,!0);if(!o?.hyperlinks)return;const a=o.entries.find(e=>e.paragraphId===n),i=Si(e.document)[t]?.blocks.find(e=>e.id===n);if(!a||!i||"paragraph"!==i.type||!Number.isInteger(r)||r<0||r>Za(i))return;const s=a.bookmark;let l=0;for(const c of i.runs){const e=l+c.text.length;if(c.text.length>0&&r>=l&&(r<e||r===e&&e===Za(i)))return"text"===c.kind&&c.styles?.link==="#"+s?{name:s,excluded:o.paragraphIds}:void 0;l=e}}(e,i,t,n);if(!r)return;({name:c,excluded:d}=r)}const p=e.document.bookmarks;if(!p)return;const f=Object.values(p.items).filter(e=>e.name.toLowerCase()===c.toLowerCase());if(1!==f.length)return;const g=f[0];if(g.name!==c||!g.start||!g.end||!p.order.includes(g.id)||g.start.paragraphId!==g.end.paragraphId||d.has(g.start.paragraphId)||void 0!==g.colFirst||void 0!==g.colLast)return;if(u&&(!g.hidden||g.start.paragraphId!==u.id||g.start.offset!==(u.tc?.offset??0)))return;if(u?.tc&&g.end.offset!==u.tc.offset)return;const m=r.flatMap((e,t)=>e.blocks.filter(e=>e.id===g.start.paragraphId&&"paragraph"===e.type).map(e=>({p:e,i:t})));if(1!==m.length)return;const{p:h,i:b}=m[0];if("paragraph"!==h.type||!Number.isInteger(g.start.offset)||!Number.isInteger(g.end.offset)||g.start.offset<0||g.end.offset<g.start.offset||g.end.offset>Za(h))return;if(u&&!u.tc&&g.end.offset!==Za(h))return;const y=Xo(h,g.start.offset);return{...e,activeZone:"main",activeFootnoteId:void 0,activeSectionIndex:b,selection:{anchor:y,focus:y}}}var UI=e=>"touch"===e.pointerType;function VI(e,t){if(!e||0===e.length){const e=Ci(t);return{paragraph:e,blocks:[e]}}const n=e[0];return{paragraph:"paragraph"===n.type?n:Mo(n)[0]??null,blocks:e}}function _I(e,t,n){const r=Co(e.document).filter(t=>{const r=Ra(e.document,t.id);return null!==r&&r.zone===n}),o=r.findIndex(e=>e.id===t.id),a=o>=0?r[o+1]:void 0;return{start:Xo(t,0),end:a?Xo(a,0):Xo(t,po(t).length)}}function KI(e){return function(e){let t=null,n=null,r=null,o=0,a=0,i=0,s=0,l=0,c=null,d=0,u=0,p=0,f=null,g=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,r,o)=>{const a=n!==(t.activeZone??"main"),i="footnote"===n&&o?Ra(r.document,o.paragraphId)?.footnoteId:void 0,s="footnote"===n&&i!==t.activeFootnoteId;if(!a&&!s)return void e.applyState(r);let l=r.document,c=t.activeSectionIndex??0;if(!l.sections||0===l.sections.length){const e=Ci("header"),t=Ci("footer");l={...l,sections:[{id:"section:1",blocks:[],pageSettings:Ka(l.pageSettings??Hr),header:[e],footer:[t]}]},c=0}const d=l.sections,u=d[c];let p=u.header,f=u.footer,g=null;if("header"===n){const e=VI(p,"header");g=e.paragraph,p=e.blocks}else if("footer"===n){const e=VI(f,"footer");g=e.paragraph,f=e.blocks}if(p!==u.header||f!==u.footer){const e=[...d];e[c]={...u,header:p,footer:f},l={...l,sections:e}}const m=o||(g?Xo(g,0):r.selection.anchor);e.applyState({...r,document:l,selection:{anchor:m,focus:m},activeSectionIndex:c,activeZone:n,activeFootnoteId:"footnote"===n?i:void 0})},y=t=>{const n=e.state(),r=n.selection,o=ya(n),a=vo(n.document,r.anchor.paragraphId,o),i=vo(n.document,r.focus.paragraphId,o),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} ${r.anchor.paragraphId}[${r.anchor.offset}]→${r.focus.paragraphId}[${r.focus.offset}] [${s}→${l}]`)},v=()=>{g?.longPressHandle&&clearTimeout(g.longPressHandle),g=null},x=()=>{t=null,r=null,f=null,v(),null!==n&&(h(n),n=null),window.removeEventListener("pointermove",C),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",T)},w=e=>{f=e,window.addEventListener("pointermove",C),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",T)},I=()=>{if(n=null,!t)return;const o=r;if(r=null,!o)return;const a=e.resolveSurfaceHitAtPoint(o.clientX,o.clientY,{forDrag:!0});if(!a?.resolvedFromParagraph)return;const i=e.state();if(Ra(i.document,t.paragraphId)?.sectionIndex!==Ra(i.document,a.paragraphId)?.sectionIndex)return;const s=Ai(i,{anchor:t,focus:a.position});b(i,a.zone,s,a.position),y("selection:drag")},S=()=>{r&&(null!==n&&(h(n),n=null),I())},C=e=>{null!==f&&e.pointerId!==f||(!g||g.longPressFired?t&&(r={clientX:e.clientX,clientY:e.clientY},null===n&&(n=m(I))):Math.hypot(e.clientX-g.clientX,e.clientY-g.clientY)>20&&x())},k=t=>{if(null===f||t.pointerId===f){if(g&&!g.longPressFired){const n=g,r=Math.hypot(t.clientX-n.clientX,t.clientY-n.clientY)<=20&&Date.now()-n.startedAt<=500;return v(),x(),void(r&&(E(n.hit,n.clickDetail,t),e.onSelectionFinalized?.()))}S(),y("selection:end"),x(),e.onSelectionFinalized?.(),e.focusInputAfterPointerSelection()}},T=e=>{null!==f&&e.pointerId!==f||x()},P=(n,r,o)=>{if(o<2)return t=null,x(),void e.focusInputAfterPointerSelection();t=null,r.resolvedFromParagraph?b(n,r.zone,{...n,selection:{anchor:{...r.position},focus:{...r.position}}},r.position):b(n,r.zone,n),x(),e.focusInputAfterPointerSelection()},R=(n,r)=>{const o=e.getParagraphById(n.document,r.textBox.paragraphId);if(!o)return void e.focusInputAfterPointerSelection();t=null;const a=Xo(o,r.textBox.startOffset),i=Xo(o,r.textBox.endOffset);b(n,r.zone,Ai(n,{anchor:a,focus:i}),a),x(),e.focusInputAfterPointerSelection()},M=(n,r,o)=>{const a=e.getParagraphById(n.document,r.image.paragraphId);if(!a)return void e.focusInputAfterPointerSelection();t=null;const i=Xo(a,r.image.startOffset),s=Xo(a,r.image.endOffset);b(n,r.zone,Ai(n,{anchor:i,focus:s}),i),x(),UI(o)||e.imageOps.startImageDrag(r.image.paragraphId,r.image.startOffset,o,{left:r.image.left,top:r.image.top,width:r.image.width,height:r.image.height}),e.focusInputAfterPointerSelection()},A=(n,r,o)=>{t=n.selection.anchor,b(n,r.zone,Ai(n,{anchor:n.selection.anchor,focus:r.position}),r.position),w(o),e.focusInputAfterPointerSelection()},O=(n,r,o)=>{t=null;const a=_I(n,o,r.zone);b(n,r.zone,Ai(n,{anchor:a.start,focus:a.end}),a.start),x(),e.focusInputAfterPointerSelection()},B=(n,r,o)=>{t=null;let a=0;const i=o.runs.find(e=>{const t="math"===e.kind&&r.paragraphOffset>=a&&r.paragraphOffset<=a+e.text.length;return a+=e.text.length,t});if("math"===i?.kind){const t=Xo(o,r.paragraphOffset);return b(n,r.zone,Ai(n,{anchor:t,focus:t}),t),x(),void e.openEquationDialog(i.math,i.id)}const s=Ln(po(o),r.paragraphOffset),l=Xo(o,s.start),c=Xo(o,s.end);b(n,r.zone,Ai(n,{anchor:l,focus:c}),l),x(),e.focusInputAfterPointerSelection()},F=(n,r,a,i)=>{if(e.imageOps.stopImageDrag(),e.imageOps.stopImageResize(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!r)return void e.focusInputAfterPointerSelection();if(!UI(i)&&(i.ctrlKey||i.metaKey)&&!i.altKey&&!i.shiftKey&&"main"===r.zone&&r.resolvedFromParagraph&&r.insideTextLine&&!r.image&&!r.textBox){const t=WI(n,r.paragraphId,r.paragraphOffset);if(t)return x(),o=0,e.applyState(t),e.focusInputAfterPointerSelection(),void e.scrollToLinkedParagraph?.(t.selection.focus.paragraphId)}if(!UI(i)&&e.textDrag?.tryStartTextDrag(i,r))return t=null,x(),void e.focusInputAfterPointerSelection();const s=e.getParagraphById(n.document,r.paragraphId);r.zone===(n.activeZone??"main")?r.textBox?R(n,r):r.image?M(n,r,i):i.shiftKey&&r.resolvedFromParagraph?A(n,r,i.pointerId):a>=3&&s?O(n,r,s):2===a&&s?B(n,r,s):r.resolvedFromParagraph?(t=r.position,b(n,r.zone,{...n,selection:{anchor:{...r.position},focus:{...r.position}}},r.position),UI(i)||w(i.pointerId),e.focusInputAfterPointerSelection()):e.focusInputAfterPointerSelection():P(n,r,a)},E=(t,n,r)=>{F(e.state(),t,n,r),e.focusInputSync()},D=()=>{const n=g;if(!n)return;n.longPressHandle=null,n.longPressFired=!0;const r=n.hit;if(!r?.resolvedFromParagraph)return;const o=e.state(),a=e.getParagraphById(o.document,r.paragraphId);if(!a)return;const i=Ln(po(a),r.paragraphOffset),s=Xo(a,i.start),l=Xo(a,i.end);b(o,r.zone,Ai(o,{anchor:s,focus:l}),s),t=s,e.focusInputSync()},L=t=>{if(0!==t.button)return;const n=Date.now(),r=Math.hypot(t.clientX-i,t.clientY-s);o=n-a<=450&&r<=((e,t)=>UI(e)?20:t)(t,6)&&t.button===l?o+1:1,a=n,i=t.clientX,s=t.clientY,l=t.button;const f=Math.max(t.detail,o),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,UI(t))return v(),g={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY,startedAt:n,hit:h,clickDetail:f,longPressHandle:setTimeout(D,500),longPressFired:!1},void w(t.pointerId);t.preventDefault(),F(m,h,f,t)},N=n=>{if(n.ctrlKey||n.metaKey||n.detail<3)return;n.preventDefault();const r=e.state(),o=Math.hypot(n.clientX-u,n.clientY-p),a=Date.now()-d<=600&&o<=8?c:e.resolveSurfaceHitAtPoint(n.clientX,n.clientY);if(!a?.resolvedFromParagraph)return void e.focusInputAfterPointerSelection();const i=e.getParagraphById(r.document,a.paragraphId);if(!i)return void e.focusInputAfterPointerSelection();t=null;const s=_I(r,i,a.zone);b(r,a.zone,Ai(r,{anchor:s.start,focus:s.end}),s.start),x(),e.focusInputAfterPointerSelection()},z=(e,t)=>{0===t.button&&(UI(t)||t.preventDefault(),L(t))};return{handleSurfacePointerDown:L,handleSurfaceClick:N,handleSurfaceDblClick:e=>{e.preventDefault()},handleParagraphPointerDown:z,stopDragging:x}}(e)}function qI(e){return function(e){const[n,r]=$t(!1);let o,a=0,i="",s=null;const l=()=>{a=0,i="",o=void 0},c=(n,r)=>{if(!r&&n===i)return;if(0===a&&0===n.length)return void(r&&l());const c=a,d=ro(o);e.clearPreferredColumn(),e.applyTransactionalState(r=>e.applyTableAwareParagraphEdit(r,e=>{const r=function(e,n){if(n<=0)return e;const{paragraph:r,index:o,offset:a}=ae(e);if(a<n)return e;const i=xi(e),s=a-n;if(F(e,r,s,a))return e;const l=u(r,t(r)?dr(r,s,a,()=>null):[...sn(r,0,s),...sn(r,a,Za(r))],Qn(r,s)),c=i.map((e,t)=>t===o?l:e);return Cn(e,c,J(Xo(l,s)))}(e,c);return n.length>0?np(r,n,d):r}),{mergeKey:Yp}),r?(l(),s=n.length>0?n:null):(a=n.length,i=n)},d=t=>{if(cr("input:text"),e.isReadOnly())return e.logger.debug(`input:readonly ignored value=${JSON.stringify(t.currentTarget.value)}`),t.currentTarget.value="",void l();const r=t.currentTarget.value;if(0===r.length)return;if(n())return e.logger.debug(`input:composing buffer=${JSON.stringify(r)}`),void c(r,!1);if(null!==s){const n=r===s;if(s=null,n)return e.logger.debug(`input:suppressed text=${JSON.stringify(r)}`),void(t.currentTarget.value="")}const o=e.state(),a=o.selection,i=xi(o).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(r)} (len=${r.length}) at ${a.anchor.paragraphId}:${a.anchor.runId}[${a.anchor.offset}] run:${JSON.stringify(d)}`),e.clearPreferredColumn();const u=ro(e.pendingCaretTextStyle());e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>np(e,r,u)),{mergeKey:Gp}),t.currentTarget.value="",e.focusInput(),Lt("input:text")},p=()=>{e.logger.debug("input:composition start"),l(),s=null,o=ro(e.pendingCaretTextStyle()),r(!0)},f=t=>{e.isReadOnly()||c(t.data??"",!1)},g=t=>{if(r(!1),e.isReadOnly())return t.currentTarget.value="",void l();const n=t.data??t.currentTarget.value,o=e.state().selection;e.logger.info(`input:composition end ${JSON.stringify(n)} (len=${n.length}) at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}]`),c(n,!0),t.currentTarget.value="",e.focusInput()};return{handleTextInput:d,handleCompositionStart:p,handleCompositionUpdate:f,handleCompositionEnd:g,composing:n}}(e)}var XI="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 GI(e,t){const n=sa(e);if(n.isCollapsed)return!1;const r=xi(e),o=r.findIndex(e=>e.id===t.paragraphId);if(o<n.startIndex||o>n.endIndex)return!1;const a=r[o];if(!a)return!1;const i=To(a,t);return!(o===n.startIndex&&i<n.startParagraphOffset)&&!(o===n.endIndex&&i>n.endParagraphOffset)}function YI(e,t,n,r,o,a){if(n.zone===Yo(e))return o(e,e=>tp(e,t,{copy:r}));if(r||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,r=Yo(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"!==r&&"header"!==r&&"footer"!==r)throw Error("Unsupported source zone");if(r===t.zone||"main"!==r&&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 o=Fi(e,e=>"opaque"===e.kind);if(!o||"opaque"!==o.run.kind||"inline"!==o.run.opaque.placement||o.run.revision||o.run.sdtWrappers?.length)throw Error("Select exactly one unwrapped inline opaque object");const a=ii(n,r),i=ii(n,t.zone),s=o.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=Fa(n,c,i),u=e.document.sections[0],p="main"===r?u.blocks:u[r],f="main"===t.zone?u.blocks:u[t.zone];if(!p?.some(e=>"paragraph"===e.type&&e.id===o.paragraph.id)||!f?.some(e=>"paragraph"===e.type&&e.id===t.paragraphId))throw Error("Only top-level paragraphs of existing stories are supported");const g={...e,activeSectionIndex:0,activeZone:t.zone,activeHeaderFooterStory:"default"},m=xi(g).find(e=>e.id===t.paragraphId);if(!m||!Number.isInteger(t.offset)||t.offset<0||t.offset>Za(m))throw Error("Invalid destination offset");const h={...te(e),activeZone:t.zone,activeSectionIndex:0,activeHeaderFooterStory:"default"},b=xi(h),y=b.find(e=>e.id===t.paragraphId);if(!y)throw Error("Destination unavailable after deletion");const v=Ro(o.run);if("opaque"!==v.kind)throw Error("Invalid cloned object");const x=we(y,t.offset,[{...v,opaque:d.destinationRun}]),w=Cn(h,b.map(e=>e.id===x.id?x:e),{anchor:Xo(x,t.offset),focus:Xo(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 ZI(e){return function(e){const[t,n]=$t(!1),[r,o]=$t(null),[a,i]=$t(!1),[s,l]=$t(null),[c,d]=$t(null);let u=null,p=null,f=null,g=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: ${XI} !important; }`,document.head.appendChild(p))},b=fw(),y=()=>{e.logger?.info("text-drag:stop",{dragging:t(),dropTarget:r()?`${r().paragraphId}:${r().runId}[${r().offset}]`:null,copyMode:a()}),u=null,f=null,g=null,n(!1),o(null),i(!1),l(null),d(null),m(),b.release(),window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)},v=r=>{if(!b.owns(r))return;if(!u)return;const a=r.ctrlKey||r.metaKey;if(i(a),!t()){const t=Math.abs(r.clientX-u.x),o=Math.abs(r.clientY-u.y);if(t+o<4)return;e.logger?.info("text-drag:activate",{start:u,at:{x:r.clientX,y:r.clientY},deltaX:t,deltaY:o}),n(!0),h()}l({x:r.clientX,y:r.clientY});const s=e.resolveSurfaceHitAtPoint(r.clientX,r.clientY,{forDrag:!0});if(g=s?.resolvedFromParagraph?s:null,!s?.resolvedFromParagraph)return e.logger?.debug("text-drag:hit-miss",{x:r.clientX,y:r.clientY}),o(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!==f&&(e.logger?.info("text-drag:target",{x:r.clientX,y:r.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"}),f=p),o(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:r()?`${r().paragraphId}:${r().runId}[${r().offset}]`:null}),"pointercancel"!==n.type){if(t()&&r()&&g){const t=r(),o=n.ctrlKey||n.metaKey,a=g;e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(n=>YI(n,t,a,o,e.applyTableAwareParagraphEdit,t=>e.logger?.warn?.("text-drag:relocation-rejected",t)),{mergeKey:o?wf:If}),e.logger?.info("text-drag:apply",{mode:o?"copy":"move",destination:`${t.paragraphId}:${t.runId}[${t.offset}]`})}else if(u){const t=u.position,n=e.state(),r=GI(o=n,i=t)?Ai(o,{anchor:i,focus:i}):o;r!==n&&e.applyState(r),e.logger?.info("text-drag:collapse",{at:`${t.paragraphId}:${t.runId}[${t.offset}]`})}var o,i;y(),e.focusInputAfterPointerSelection()}else y()},w=(t,r)=>e.isReadOnly()||!r?.resolvedFromParagraph?(e.logger?.debug("text-drag:skip-start",{reason:e.isReadOnly()?"readonly":"no-hit",x:t.clientX,y:t.clientY}),!1):GI(e.state(),r.position)?(e.logger?.info("text-drag:start-pending",{x:t.clientX,y:t.clientY,hit:`${r.position.paragraphId}:${r.position.runId}[${r.position.offset}]`,zone:r.zone}),u={x:t.clientX,y:t.clientY,position:r.position},l({x:t.clientX,y:t.clientY}),i(t.ctrlKey||t.metaKey),o(null),g=null,d(r.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:`${r.position.paragraphId}:${r.position.runId}[${r.position.offset}]`}),!1);return{dragging:t,dropTargetPos:r,copyMode:a,pointerPos:s,caretViewport:c,tryStartTextDrag:w,stopDrag:y}}(e)}function JI(e){return e.blocks.flatMap(Mo)}function QI(e,t){if(!e)return;const n=JI(e);return"start"===t?n[0]:n[n.length-1]}function eS(e){return function(e){const t=(t,n)=>{const r=e.state(),o=xi(r).find(e=>e.id===r.selection.focus.paragraphId);if(!o)return!1;const a="start"===t?0:po(o).length,i=Xo(o,a);return e.clearPreferredColumn(),e.applyState(Ai(r,{anchor:n?r.selection.anchor:i,focus:i})),!0},n=(t,n)=>{const r=e.state(),o=xi(r);if(0===o.length)return!1;const a="start"===t?o[0]:o[o.length-1],i="start"===t?0:po(a).length,s=Xo(a,i);return e.clearPreferredColumn(),e.applyState(Ai(r,{anchor:n?r.selection.anchor:s,focus:s})),!0},r=(t,n)=>{const r=e.state(),o=xi(r),a=o.findIndex(e=>e.id===r.selection.focus.paragraphId),i=o[a];if(!i)return!1;const s=po(i),l=To(i,r.selection.focus),c=s.length;if(!n&&!ri(r.selection))return e.clearPreferredColumn(),e.applyState("left"===t?Oi(r):Bi(r)),!0;let d=i,u=l;"left"===t?0===l&&a>0?(d=o[a-1],u=po(d).length):u=gt(s,l):l===c&&a<o.length-1?(d=o[a+1],u=0):u=on(s,l);const p=Xo(d,u);return e.clearPreferredColumn(),e.applyState(Ai(r,{anchor:n?r.selection.anchor:p,focus:p})),!0},o=e=>a(e,!1),a=(t,n)=>{const r=e.state(),o=xi(r),a=o.findIndex(e=>e.id===r.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:r,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()}):null;let u=a+t;const p=wo(r.document,r.selection.focus.paragraphId,ya(r)),f=p?.tablePath[p.tablePath.length-1];if(p&&f){const e=Wx(r,p.zone),n=bo(e,p.tablePath),a=n?.[n.length-1]?.table;if(a){const e=Vo(a),n=e.find(e=>e.rowIndex===f.rowIndex&&e.cellIndex===f.cellIndex);if(n){const r=[];for(let e=n.visualRowIndex+t;e>=0&&e<a.rows.length;e+=t)r.push(e);for(const n of r){const r=e.filter(e=>e.visualRowIndex===n&&JI(e.cell).length>0&&"continue"!==e.cell.vMerge);if(0===r.length)continue;const i=r.map(e=>{const t=QI(e.cell,"start")?.id,n=t?d?.paragraphs.find(e=>e.paragraphId===t&&e.tableCell&&e.tableCell.tableId===a.id)?.tableCell:null,r=n?.left??c,o=n?n.left+n.width:c;return{entry:e,distance:c<r?r-c:c>o?c-o:0}}).sort((e,t)=>e.distance-t.distance)[0]?.entry;if(!i)continue;const s=QI(i.cell,t<0?"end":"start");u=s?o.findIndex(e=>e.id===s.id):-1;break}}else if(t<0){const e=QI(a.rows[0]?.cells[0],"start");e&&(u=o.findIndex(t=>t.id===e.id)-1)}else{const e=a.rows[a.rows.length-1],t=e?.cells[e.cells.length-1],n=QI(t,"end");n&&(u=o.findIndex(e=>e.id===n.id)+1)}}}if(u<0||u>=o.length)return!1;const g=o[u];let m=0;const h=d?qe(d,g.id):[],b=t<0?h[h.length-1]:h[0];if(b&&b.lines.length>0){const e=b.lines,n=t<0?e[e.length-1]:e[0];m=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 m=Math.min(To(g,r.selection.focus),po(g).length);return e.setPreferredColumnX(c),e.resetTransactionGrouping(),e.applyTransactionalState(e=>Ai(e,{anchor:n?e.selection.anchor:Xo(g,m),focus:Xo(g,m)})),e.focusInput(),!0},i=()=>{const t=e.state();if(!ri(t.selection))return!1;const n=e.surfaceRef(),r=e.caretBox();if(!n||!r.visible)return!1;const o=xi(t).find(e=>e.id===t.selection.focus.paragraphId);if(!o)return!1;const a=To(o,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 r=e.filter(e=>e.startOffset<=t&&e.endOffset>=t&&n>=e.top-.5&&n<e.top+e.height-.5);return 1===r.length&&r[0].startOffset===t}(qe(i,o.id).flatMap(e=>e.lines),a,r.top+i.surfaceRect.top+Math.min(1,r.height/2))};return{isCaretAtWrappedLineStart:i,moveSelectionToParagraphBoundary:t,moveSelectionToDocumentBoundary:n,moveSelectionByWord:r,moveVerticalByBlock:o,moveVerticalSelection:a}}(e)}function tS(e){return function(e){const[t,n]=$t(null),r=(t,r)=>{const o=xi(e.state());let a;for(const e of o){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 Si(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=r.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:r,handleRevisionMouseLeave:()=>{n(null)}}}(e)}function nS(e){const t=xi(e);if(!t.length)return null;const n=sa(e,t),r=t[n.startIndex];if(!r)return null;const o=(n.isCollapsed?[]:sn(r,n.startParagraphOffset,n.startIndex===n.endIndex?n.endParagraphOffset:Za(r))).find(e=>"text"===e.kind&&e.text.length>0),a=function(e){const t=ro(e);if(t)return delete t.link,delete t.propertyRevision,Object.keys(t).length>0?t:void 0}(Ho(o?o.styles:Qn(r,n.startParagraphOffset),r.style?.styleId,e.document.styles)),i=n.isCollapsed||0===n.startParagraphOffset&&(n.endIndex>n.startIndex||n.endParagraphOffset===Za(r));return{text:a,paragraph:i?$o(r.style):void 0,list:i&&r.list?{...r.list}:void 0,copyParagraph:i}}function rS(e,t){const n=xi(e);if(!n.length)return e;const r=sa(e,n);if(r.isCollapsed)return e;let o=!1;const a=n.map((e,n)=>{if(n<r.startIndex||n>r.endIndex)return e;const a=n===r.startIndex?r.startParagraphOffset:0,i=n===r.endIndex?r.endParagraphOffset:Za(e),s=t.copyParagraph&&function(e,t,n){return(t>n.startIndex||0===n.startParagraphOffset)&&(t<n.endIndex||n.endParagraphOffset===Za(e))}(e,n,r),l=s?$o(t.paragraph):e.style,c=s?t.list?{...t.list}:void 0:e.list,d=s&&(JSON.stringify(l)!==JSON.stringify(e.style)||JSON.stringify(c)!==JSON.stringify(e.list)),u=a<i&&sn(e,a,i).some(e=>{if("text"!==e.kind||0===e.text.length)return!1;const n=ro(t.text)??{};void 0!==e.styles?.link&&(n.link=e.styles.link),void 0!==e.styles?.propertyRevision&&(n.propertyRevision=e.styles.propertyRevision);const r=Object.keys(n).length?n:void 0;return!_o(e.styles,r)});if(!d&&!u)return e;o=!0;let p=u?ge(e,a,i,e=>{if("text"!==e.kind)return e;const n=ro(t.text)??{};return void 0!==e.styles?.link&&(n.link=e.styles.link),void 0!==e.styles?.propertyRevision&&(n.propertyRevision=e.styles.propertyRevision),{...e,styles:Object.keys(n).length?n:void 0}}):e;return s&&(p={...p,style:l,list:c}),p});return o?Cn(e,a,H(a,r)):e}function oS(e){const t=xi(e);if(!t.length)return"";const n=sa(e,t);return[e.activeSectionIndex??0,e.activeZone??"main",n.start.paragraphId,n.startParagraphOffset,n.end.paragraphId,n.endParagraphOffset].join(":")}function aS(e){const[t,n]=$t(null);let r=null,o=null,a="";const i=()=>{r=null,o=null,a="",n(null)};Hn()&&(bn(()=>{t()&&(e.isReadOnly()||e.state().document!==o)&&i()}),_t(i));const s=()=>!e.isReadOnly()&&xi(e.state()).length>0,l=t=>{if(!s())return!1;const i=e.state(),l=nS(i);return!!l&&(r=l,o=i.document,a=oS(i),n(t),e.focusInput(),!0)};return{mode:t,canCapture:s,armOnce:()=>l("once"),armContinuous:()=>l("continuous"),cancel:i,applyToSelection:n=>{if(!r||!t())return!1;if(e.isReadOnly()||e.state().document!==o)return i(),!1;const s=e.state();if(oS(s)===a)return!1;const l=function(e,t){const n=xi(e);if(0===n.length)return null;const r=sa(e,n);if(!r.isCollapsed)return e;if(!t)return null;const o=n[r.startIndex];if(!o)return null;const a=Ln(po(o),r.startParagraphOffset);return a.end<=a.start?null:{...e,selection:{anchor:Xo(o,a.start),focus:Xo(o,a.end)}}}(s,"pointer"===n);if(!l)return!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let c=!1;return tr(()=>{e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==o)return t;const n=e.applyTableAwareParagraphEdit({...t,selection:l.selection},e=>rS(e,r));return c=n.document!==t.document,n}),"once"===t()?i():c&&(o=e.state().document)}),c&&e.focusInput(),c}}}function iS(e){return function(e){const{state:t,logger:n,isReadOnly:r,applyState:o,cloneState:a,focusInput:i,focusInputAfterPointerSelection:s,focusInputSync:l,surfaceRef:c,viewportRef:d,zoomFactor:u,insertImageFromFile:p,getForcePlainTextPaste:f,setForcePlainTextPaste:g,getCommandsController:m,applyTransactionalState:h,clearPreferredColumn:b,resetTransactionGrouping:y,updateHistoryState:v,caretBox:x,preferredColumnX:w,setPreferredColumnX:I,documentLayout:S,canvasSnapshotProvider:C}=e,k=()=>bv(t),T=()=>Px(t),P=zw({state:()=>t,resetTransactionGrouping:y,applyTransactionalState:h,focusInput:i}),R=Mw({state:()=>t,surfaceRef:()=>c()??null,viewportRef:()=>d()??null,documentLayout:S,canvasSnapshotProvider:C,zoomFactor:u}).resolveSurfaceHitAtPoint,M=function(e){const[t,n]=$t(""),[r,o]=$t(""),[a,i]=$t({matchCase:!1,wholeWord:!1}),[s,l]=$t([]),[c,d]=$t(-1),[u,p]=$t(!1);bn(Yt([()=>e.state.document,t,a],([e,t,n])=>{const r=Iw(e,t,n);l(r),0===r.length?d(-1):(c()>=r.length||-1===c())&&d(0)}));const f=t=>{const n=s()[t];n&&e.applyState(Ai(e.state,{anchor:n.anchor,focus:n.focus}))};return{searchTerm:t,setSearchTerm:n,replaceTerm:r,setReplaceTerm:o,findOptions:a,setFindOptions:i,matches:s,currentIndex:c,findNext:()=>{const e=s().length;if(0===e)return;const t=(c()+1)%e;d(t),f(t)},findPrevious:()=>{const e=s().length;if(0===e)return;const t=(c()-1+e)%e;d(t),f(t)},replace:()=>{if(0===s().length||-1===c())return;const t=s()[c()];e.applyTransactionalState(e=>np(Ai(e,{anchor:t.anchor,focus:t.focus}),r()),{mergeKey:hf})},replaceAll:()=>{const n=t();0!==n.length&&(e.applyTransactionalState(e=>Sw(e,n,r(),a()),{mergeKey:bf}),p(!1),e.focusInput())},isOpen:u,setIsOpen:p}}({state:t,applyState:o,applyTransactionalState:h,focusInput:i}),A=pw({applyTransactionalState:h,applySelectionToStatePreservingStructure:(e,t)=>({...e,document:en(e).document,selection:t}),focusInput:i,logger:n}),O=aS({state:()=>t,isReadOnly:r,applyTransactionalState:h,applyTableAwareParagraphEdit:A.applyTableAwareParagraphEdit,clearPreferredColumn:b,resetTransactionGrouping:y,focusInput:i}),B=(e,t)=>R(e,t)?.position??null,F=vw({state:t,surfaceRef:c,resolvePositionAtSurfacePoint:B,applyState:o,applyTransactionalState:h,updateHistoryState:v,focusInput:i,focusInputAfterPointerSelection:s,cloneState:a,logger:n,zoomFactor:u}),E=xw({state:t,surfaceRef:c,applyState:o,updateHistoryState:v,focusInput:i,cloneState:a,logger:n,zoomFactor:u}),D=ww({state:()=>t,commandsController:m,clearPreferredColumn:b,resetTransactionGrouping:y,focusInput:i,logger:n}),L=function(e){const t=()=>e.state,n=aI({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,viewportRef:e.viewportRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),r=lI({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),o=pI({state:t,applyTransactionalState:e.applyTransactionalState,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint,focusInput:e.focusInput}),a=tS({state:t,surfaceRef:()=>e.surfaceRef()??null,zoomFactor:e.zoomFactor}),i=ZI({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=KI({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,scrollToLinkedParagraph:Ue({state:t,documentLayout:e.documentLayout,surfaceRef:e.surfaceRef,viewportRef:e.viewportRef,zoomFactor:e.zoomFactor,snapshotProvider:e.canvasSnapshotProvider}),resolveSurfaceHitAtPoint:e.resolveSurfaceHitAtPoint,getParagraphById:lo,textDrag:{tryStartTextDrag:i.tryStartTextDrag},logger:e.logger,openEquationDialog:e.openEquationDialog}),l=qI({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=eS({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:f}=$w({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:r,tableDrag:o,revisionController:a,textDrag:i,surfaceEvents:s,textInput:l,navigation:c,handleCopy:d,handleCut:u,handlePaste:p,handleDrop:f}}({state:t,getStateSnapshot:e.getStateSnapshot,applyState:o,applyTransactionalState:h,isReadOnly:r,logger:n,focusInput:i,focusInputAfterPointerSelection:s,focusInputSync:l,clearPreferredColumn:b,resetTransactionGrouping:y,surfaceRef:c,viewportRef:d,caretBox:()=>x(),preferredColumnX:()=>w(),setPreferredColumnX:I,zoomFactor:u,documentLayout:S,canvasSnapshotProvider:C,resolveSurfaceHitAtPoint:R,resolvePositionAtSurfacePoint:B,tableOps:A,imageOps:F,styleController:D,formatPainter:O,getForcePlainTextPaste:f,setForcePlainTextPaste:g,clipboardActions:e.clipboardActions,insertImageFromFile:p,openEquationDialog:e.openEquationDialog}),N=e=>{0===e.button&&(D.clearPendingCaretTextStyle(),e.preventDefault(),i())};return{selectedImageRun:k,selectedTextBoxRun:T,layoutOptionsOverlay:P,fr:M,resolveSurfaceHitAtPoint:R,resolvePositionAtSurfacePoint:B,tableOps:A,imageOps:F,textBoxOps:E,styleController:D,formatPainter:O,onEditorPointerDown:N,tableResize:L.tableResize,tableCornerResize:L.tableCornerResize,tableDrag:L.tableDrag,revisionController:L.revisionController,textDrag:L.textDrag,surfaceEventsWithTextDrag:L.surfaceEvents,textInput:L.textInput,navigation:L.navigation,handleCopy:L.handleCopy,handleCut:L.handleCut,handlePaste:L.handlePaste,handleDrop:L.handleDrop}}(e)}function sS(e){if("main"!==(e.activeZone??"main"))return e;const t=ri(e.selection)?e:te(e),{paragraph:n,index:r,offset:o}=ae(t),a=Ba(),i=function(e){const t=e.footnotes,n=t?.settings?.numberFormat??"decimal";let r=(t?.settings?.startAt??1)-1;const o=/* @__PURE__ */new Set;for(const{run:a}of ai(e)){const e=si(a);e&&!e.customMark&&(o.has(e.footnoteId)||(o.add(e.footnoteId),r+=1))}return ga(r+1,n)}(t.document),s=Ao(a.id,i),l=we(n,o,[s]),c=xi(t).map((e,t)=>t===r?l:e),d=Xo(l,o+i.length),u=Cn(t,c,ea(d)),p=function(e){return e||{items:{}}}(u.document.footnotes),f={...u.document,footnotes:{...p,items:{...p.items,[a.id]:a}}},g=Ua(f),m=a.blocks.flatMap(Mo).find(Boolean);return m?{...u,document:g,selection:ea(Xo(m,0)),activeZone:"footnote",activeFootnoteId:a.id}:{...u,document:g}}function lS(e){if(!e)return;const{propertyRevision:t,...n}=e;return Object.keys(n).length>0?n:void 0}function cS(e,t,n){return e.flatMap(e=>{if("paragraph"===e.type)return[e];let r=e.style;if(r?.revision?.id===t)if(n){const{revision:e,...t}=r;r=t}else r={...r.revision.previous};let o=e.gridCols,a=e.gridRevision;a?.id===t&&(o=n?o:[...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 r=0;r<e.cells.length;r+=1){const o=e.cells[r],a=o.mergeRevisionState;if(a&&a.revisionId===t){if(n){const{mergeRevisionState:t,...n}=o;e.cells[r]=n;continue}"horizontal"===a.orientation?e.cells.splice(r,a.currentCellCount,...a.previousCells):a.previousCells.forEach((e,t)=>{const n=i[l+t];n&&(n.cells[r]=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 r=e.style;if(r?.propertyRevision?.id===t)if(n){const{propertyRevision:e,...t}=r;r=t}else r={...r.propertyRevision.previous,revision:r.revision};if(r?.revision?.id===t){const{revision:e,...t}=r;r=t}const o=e.cells.flatMap(e=>{if(e.style?.revision?.id===t&&(n&&"delete"===e.style.revision.type||!n&&"insert"===e.style.revision.type))return[];let r=e.style;if(r?.propertyRevision?.id===t)if(n){const{propertyRevision:e,...t}=r;r=t}else r={...r.propertyRevision.previous,revision:r.revision};let o={...e,style:r,blocks:cS(e.blocks,t,n)};if(r?.revision?.id===t&&e.mergeRevisionState?.revisionId!==t){const e=r.revision,{revision:t,...a}=r;o={...o,...n||"merge"!==e.type?{}:e.previous,style:a}}return[o]});return[{...e,isHeader:r&&"isHeader"in r?r.isHeader:e.isHeader,style:r,cells:o}]});return 0===s.length?[]:[{...e,style:r,gridCols:o,gridRevision:a,rows:s}]})}function dS(e,t,n){const r=Si(e.document).map(e=>({...e,blocks:cS(e.blocks,t,n),header:e.header?cS(e.header,t,n):void 0,firstPageHeader:e.firstPageHeader?cS(e.firstPageHeader,t,n):void 0,evenPageHeader:e.evenPageHeader?cS(e.evenPageHeader,t,n):void 0,footer:e.footer?cS(e.footer,t,n):void 0,firstPageFooter:e.firstPageFooter?cS(e.firstPageFooter,t,n):void 0,evenPageFooter:e.evenPageFooter?cS(e.evenPageFooter,t,n):void 0}));return{...e,document:{...e.document,sections:r}}}function uS(e,t,n){const r=Si(e.document),o=r.findIndex(e=>e.propertyRevision?.id===t);if(-1===o)return e;const a=r[o],i=a.propertyRevision,s=[...r];if(n)s[o]={...a,propertyRevision:void 0};else{const e=structuredClone(i.previous);s[o]={...a,pageSettings:e.pageSettings,pageBorder:e.pageBorder,pageNumbering:e.pageNumbering,verticalAlignment:e.verticalAlignment,bidi:e.bidi,propertyRevision:void 0};const t=s[o+1];t&&(s[o+1]={...t,breakType:e.nextBreakType})}return{...e,document:{...e.document,sections:s}}}function pS(e,t){const n=xi(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:lS(e.styles)}:e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:u(e,n)});return uS(dS(Cn(e,n,H(n,sa(e))),t,!0),t,!0)}function fS(e,t){const n=xi(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:lS(n.previous)}:e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:u(e,n)});return uS(dS(Cn(e,n,H(n,sa(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 mS(e,t,n){for(const r of e)if("paragraph"!==r.type){gS(r,t)&&(r.style?.revision&&n.add(r.style.revision.id),r.gridRevision&&n.add(r.gridRevision.id));for(const e of r.rows){const r=e.cells.filter(e=>e.blocks.some(e=>gS(e,t)));r.length>0&&(e.style?.revision&&n.add(e.style.revision.id),e.style?.propertyRevision&&n.add(e.style.propertyRevision.id));for(const e of r)e.style?.revision&&n.add(e.style.revision.id),e.style?.propertyRevision&&n.add(e.style.propertyRevision.id),mS(e.blocks,t,n)}}}function hS(e){const t=sa(e),n=xi(e),r=/* @__PURE__ */new Set;for(let a=t.startIndex;a<=t.endIndex;a+=1){const e=n[a],o=a===t.startIndex?t.startParagraphOffset:0,i=a===t.endIndex?t.endParagraphOffset:Za(e),s=sn(e,o,i);for(const t of s)t.revision?.id&&r.add(t.revision.id),t.styles?.propertyRevision?.id&&r.add(t.styles.propertyRevision.id)}const o=new Set(n.slice(t.startIndex,t.endIndex+1).map(e=>e.id));for(const a of Si(e.document))for(const e of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])e&&mS(e,o,r);for(const a of Gv(e))a.paragraphIds.some(e=>o.has(e))&&r.add(a.id);return r}function bS(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)},r=e=>{if(e)for(const o of e)if("paragraph"!==o.type){o.style?.revision&&t.add(o.style.revision.id),o.gridRevision&&t.add(o.gridRevision.id);for(const e of o.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),r(n.blocks)}}else n(o.runs)};for(const i of Si(e.document))i.propertyRevision&&t.add(i.propertyRevision.id),r(i.blocks),r(i.header),r(i.firstPageHeader),r(i.evenPageHeader),r(i.footer),r(i.firstPageFooter),r(i.evenPageFooter);const o=e.document.footnotes?.items??{};for(const i of Object.values(o))r(i.blocks);const a=e.document.endnotes?.items??{};for(const i of Object.values(a))r(i.blocks);return t}function yS(e){return bS(e).size>0}function vS(e,t){if(!yS(e))return e;const n=Ut(e.document,t);if(!n.changed)return e;const r=xi({...e,document:n.document}),o=H(r,sa(e));return{...e,document:n.document,selection:o}}function xS(e){const t=sa(e),n=xi(e);if(t.isCollapsed){const e=n[t.startIndex];return e?Bn(e,t.startParagraphOffset)?.href??null:null}const r=n.slice(t.startIndex,t.endIndex+1).flatMap((e,n)=>{const r=t.startIndex+n,o=r===t.startIndex?t.startParagraphOffset:0,a=r===t.endIndex?t.endParagraphOffset:Za(e);return sn(e,o,a)}).filter(e=>e.text.length>0&&"image"!==e.kind);if(0===r.length)return null;const o=r[0]?.styles?.link;return o&&r.every(e=>e.styles?.link===o)?o:null}function wS(e){const t=sa(e),n=xi(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return eo(e);if(!e.list)return eo(e);const r=e.list.level??0;return r<=0?Ne(e):N(e,r-1)});return Cn(e,n,H(n,t))}function IS(e){return SS(e,null)}function SS(e,t){const n=sa(e),r=xi(e).map((e,r)=>r<n.startIndex||r>n.endIndex?eo(e):e.list?{...eo(e),list:{...e.list,startAt:null!==t?t:void 0}}:eo(e));return Cn(e,r,H(r,n))}function CS(e){return function(e){const{state:t,logger:n,applyState:r,applyTransactionalState:o,applySelectionAwareTextCommand:a,applySelectionAwareParagraphCommand:s,applyTableAwareParagraphEdit:l,focusInput:c,clearPreferredColumn:d,resetTransactionGrouping:p,toolbarStyleState:f,selectionCollapsed:g,selectedImageRun:m}=e,h=e=>{d(),p(),r(e),c()},b=e=>{d(),p(),a(e),c()},y=e=>{d(),p(),s(e),c()},x=(e,t)=>{d(),p(),o(e,t),c()},w=()=>{const e=sa(t);return xi(t).slice(e.startIndex,e.endIndex+1)},I=()=>w().some(e=>Boolean(e.list)),S=()=>{const e=t.selection.focus.paragraphId;return xi(t).find(t=>t.id===e)??null},C=()=>{const e=S();return!!e?.list&&(d(),p(),g()&&0===po(e).length?s(e=>function(e){const t=sa(e),n=xi(e).map((e,n)=>n<t.startIndex||n>t.endIndex?eo(e):Ne(e));return Cn(e,n,H(n,t))}(e)):o(e=>l(e,e=>function(e){if(be(e))return e;const t=ri(e.selection)?e:te(e),{paragraph:n,index:r,offset:o}=ae(t);if(be(t))return e;const{beforeRuns:a,afterRuns:i}=Lr(n,o),s=u(n,a,Qn(n,o)),l=i.length>0?u(He(n,[]),i):(()=>{const e=Ma("");return e.style=n.style?{...n.style}:void 0,e.list=so(n.list),e})(),c=xi(t),d=[...ho(c.slice(0,r)),s,l,...ho(c.slice(r+1))];return Cn(t,d,J(Xo(l,0)))}(e)),{mergeKey:ef}),c(),!0)},k=()=>{const e=t.selection,n=ya(t),r=vo(t.document,e.anchor.paragraphId,n),o=vo(t.document,e.focus.paragraphId,n);return r&&o&&r.blockIndex===o.blockIndex?` [table b${r.blockIndex} r${r.rowIndex}:c${r.cellIndex}→r${o.rowIndex}:c${o.cellIndex}]`:""},T=e=>{if(g())return;const r=t.selection;n.info(`toggleStyle:${e} at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}..${r.focus.offset}]${k()}`),b(t=>cp(t,e))},P=e=>{g()||b(t=>function(e,t){const n=sa(e);if(n.isCollapsed||X(e))return e;const r=xi(e).map((r,o)=>{if(o<n.startIndex||o>n.endIndex)return r;const a=o===n.startIndex?n.startParagraphOffset:0,i=o===n.endIndex?n.endParagraphOffset:Za(r);return M(e,r,a,i,n=>{let o=uo(lp(e,r,n.styles,"underline",null!==t),"underlineStyle","single"===t?null:t);return"single"!==t&&null!==t||!Ho(o,r.style?.styleId,e.document.styles).underlineStyle||(o={...o,underlineStyle:t}),{...n,styles:o}})});return Cn(e,r,H(r,n))}(t,e))},R=(e,r)=>{if(g())return;const o=t.selection;n.info(`setStyle:${e}=${JSON.stringify(r)} at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}..${o.focus.offset}]${k()}`),b(t=>dp(t,e,r))},A=(e,t)=>{y(n=>ce(n,e,t))},O=e=>{const t=!f()[e];A(e,"widowControl"===e?t:!!t||null)},B=()=>{x(e=>l(e,e=>wr(e)))},F=()=>"main"===(t.activeZone??"main"),E=()=>{F()&&x(e=>sS(e))},D=e=>{const n=xS(t);g()&&!n||x(t=>function(e,t){const n=sa(e);if(!n.isCollapsed)return dp(e,"link",t);const r=xi(e)[n.startIndex];if(!r)return e;const o=Bn(r,n.startParagraphOffset);if(!o)return e;const a=dp(Ai(e,{anchor:Xo(r,o.startOffset),focus:Xo(r,o.endOffset)}),"link",t),i=xi(a)[n.startIndex];return i?{...a,selection:{anchor:Xo(i,o.startOffset),focus:Xo(i,o.endOffset)}}:a}(t,e),{mergeKey:tf})},L=()=>{const n=xS(t)??"";g()&&!n||e.openLinkDialog(n)},z=()=>e.openFontDialog(),$=t=>e.openParagraphDialog(t),j=()=>{D(null)},W=()=>{const t=m();if(!t)return;const n=da(t.run)?.alt??"";e.openImageAltDialog(n)},U=t=>{m()&&x(n=>function(e,t,n){const r=bv(e);if(!r||!da(r.run))return e;const o=xi(e),a=r.paragraphIndex+1,i=a<o.length&&La(o[a]),s=i?Go(o[a],t,n):ca(t,n,1);if(i&&s===o[a])return e;const l=a<o.length&&La(o[a])?[...ho(o.slice(0,a)),s,...ho(o.slice(a+1))]:[...ho(o.slice(0,a)),s,...ho(o.slice(a))],c=wa(l,e.document.styles),d=c[a]??s;return Cn(e,c,J(Xo(d,ma(d))))}(n,t,e.imageCaptionLabel()),{mergeKey:rf})},V=()=>{m()&&e.openImageCaptionDialog(function(e){const t=bv(e);if(!t||!da(t.run))return null;const n=xi(e);return Xa(n[t.paragraphIndex+1])}(t)??"")};return{applyBooleanStyleCommand:T,applyToggleCharacterBorderCommand:()=>{g()||b(e=>function(e){const t=sa(e);if(t.isCollapsed||X(e))return e;const n=xi(e),r=n.slice(t.startIndex,t.endIndex+1).flatMap((e,n)=>{const r=t.startIndex+n,o=r===t.startIndex?t.startParagraphOffset:0,a=r===t.endIndex?t.endParagraphOffset:Za(e);return sn(e,o,a)}).filter(e=>e.text.length>0);if(0===r.length)return e;const o=!r.every(e=>Boolean(e.styles?.textBorder)),a=n.map((n,r)=>{if(r<t.startIndex||r>t.endIndex)return n;const a=r===t.startIndex?t.startParagraphOffset:0,i=r===t.endIndex?t.endParagraphOffset:Za(n);return M(e,n,a,i,e=>({...e,styles:fp(e.styles,o)}))});return Cn(e,a,H(a,t))}(e))},applyValueStyleCommand:R,applyUnderlineStyleCommand:P,applyChangeTextCaseCommand:e=>{g()||b(t=>hp(t,e))},applyClearFormattingCommand:()=>{g()||b(e=>function(e){const t=sa(e);if(t.isCollapsed||X(e))return e;const n=xi(e).map((n,r)=>{if(r<t.startIndex||r>t.endIndex)return n;const o=r===t.startIndex?t.startParagraphOffset:0,a=r===t.endIndex?t.endParagraphOffset:Za(n);return M(e,n,o,a,e=>{const t=e.styles?.link,n=null!=t&&""!==t?{link:t}:{};return{...e,styles:n}})});return Cn(e,n,H(n,t))}(e))},applyParagraphStyleCommand:A,toggleParagraphFlagCommand:O,applyParagraphListCommand:e=>{y(t=>function(e,t){const n=sa(e),r=xi(e),o=n.startIndex,a=n.endIndex,i=r.slice(o,a+1),s=i.length>0&&i.every(e=>e.list?.kind===t),l=r.map((e,n)=>{if(n<o||n>a)return eo(e);const r=eo(e);return s?(delete r.list,r):(r.list={kind:t,level:e.list?.level??0,format:e.list?.format,startAt:e.list?.startAt},r)});return Cn(e,l,H(l,n))}(t,e))},handleListFormatChange:e=>{y(t=>function(e,t){if(null!==t&&!Oa(t))return e;const n=sa(e),r=xi(e).map((e,r)=>r<n.startIndex||r>n.endIndex?eo(e):e.list?{...eo(e),list:{...e.list,format:t||void 0}}:eo(e));return Cn(e,r,H(r,n))}(t,e))},handleListStartAtChange:e=>{y(t=>SS(t,e))},applyInsertSectionBreakCommand:e=>{h(Me(t,e))},applyInsertPageBreakCommand:B,canInsertFootnoteCommand:F,applyInsertFootnoteCommand:E,handleStyleChange:e=>{y(t=>v(t,e||null))},applyUpdateSectionSettingsCommand:(e,n)=>{h(i(t,e,n))},applyToggleTrackChangesCommand:()=>{h(function(e){return{...e,trackChangesEnabled:!e.trackChangesEnabled}}(t))},applyToggleRevisionMarkupCommand:()=>{h(function(e){return{...e,showRevisionMarkup:!(e.showRevisionMarkup??!0)}}(t))},applySetReviewDisplayModeCommand:e=>{h(function(e,t){return(e.reviewDisplayMode??"all")===(t??"all")?e:{...e,reviewDisplayMode:t}}(t,e))},applyShowMarkupCommand:e=>{h(Jv(t,e))},applyToggleShowMarginsCommand:()=>{r({...t,showMargins:!t.showMargins}),c()},applyToggleShowParagraphMarksCommand:()=>{r({...t,showParagraphMarks:!t.showParagraphMarks}),c()},applyAcceptRevisionsCommand:()=>{x(e=>function(e){let t=e;for(const n of hS(e))t=pS(t,n);return t}(e))},applyRejectRevisionsCommand:()=>{x(e=>function(e){let t=e;for(const n of hS(e))t=fS(t,n);return t}(e))},applyAcceptAllRevisionsCommand:()=>{x(e=>function(e){return vS(e,"accept")}(e))},applyRejectAllRevisionsCommand:()=>{x(e=>function(e){return vS(e,"reject")}(e))},applyLinkCommand:D,promptForLink:L,openFontDialog:z,openParagraphDialog:$,openStylesDialog:()=>{n.warn("stylesDialog not yet implemented")},openPageSetupDialog:()=>{n.warn("pageSetupDialog not yet implemented")},removeLinkCommand:j,applyImageAltCommand:e=>{m()&&x(t=>function(e,t){return Pv(e,e=>({...e,alt:t??void 0}))}(t,e),{mergeKey:nf})},promptForImageAlt:W,applyImageCaptionCommand:U,promptForImageCaption:V,applyImageWidthCmCommand:e=>{!m()||!Number.isFinite(e)||e<=0||x(t=>function(e,t){const n=bv(e),r=n&&da(n.run);if(!r||!Number.isFinite(t)||t<=0)return e;const o=Math.max(24,Math.round(t*mi));return yv(e,o,o*(r.height/r.width))}(t,e),{mergeKey:of})},applyImageHeightCmCommand:e=>{!m()||!Number.isFinite(e)||e<=0||x(t=>function(e,t){const n=bv(e),r=n&&da(n.run);if(!r||!Number.isFinite(t)||t<=0)return e;const o=Math.max(24,Math.round(t*mi));return yv(e,o*(r.width/r.height),o)}(t,e),{mergeKey:of})},applyImageCropAspectCommand:e=>{if(!m())return;const t=function(e){const t=e.trim().toLowerCase();if("reset"===t||"fit"===t||"fill"===t)return"reset";const n=t.split(/[:/]/);if(2!==n.length)return null;const r=Number(n[0]),o=Number(n[1]);return!Number.isFinite(r)||!Number.isFinite(o)||r<=0||o<=0?null:r/o}(e);null!==t&&x(e=>"reset"===t?Sv(e):wv(e,t),{mergeKey:af})},applyImageCropShapeCommand:e=>{m()&&x(t=>function(e,t){const n=t?.trim();return Pv(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:af})},applyImageCropFillCommand:()=>{m()&&x(e=>function(e){const t=bv(e),n=t&&da(t.run);return n?Pv(xv(e,{crop:Iv(n)}),e=>({...e,cropFit:"fill"})):e}(e),{mergeKey:af})},applyImageCropFitCommand:()=>{m()&&x(e=>function(e){return Pv(e,e=>{const t={...e,cropFit:"fit"};return delete t.crop,t})}(e),{mergeKey:af})},resetImageCropCommand:()=>{m()&&x(e=>Sv(e),{mergeKey:af})},applyImageBorderCommand:e=>{m()&&x(t=>function(e,t){return Pv(e,e=>{if(null===t.color){const{border:t,...n}=e;return n}const n={...e.border??{color:"#000000"}};return void 0!==t.color&&(n.color=t.color),void 0!==t.widthPt&&(n.widthPt=t.widthPt),void 0!==t.dash&&(n.dash=t.dash),{...e,border:n}})}(t,e))},flipImageCommand:e=>{m()&&x(t=>Tv(t,e),{mergeKey:sf})},rotateImageCommand:e=>{m()&&x(t=>kv(t,e),{mergeKey:lf})},applyImageTransparencyCommand:e=>{m()&&x(t=>function(e,t){return null===bv(e)?e:Pv(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:cf})},resetImageCommand:()=>{m()&&x(e=>function(e){return null===bv(e)?e:Pv(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:df})},handleListTab:e=>!vo(t.document,t.selection.focus.paragraphId,ya(t))&&(!!I()&&(y(t=>"indent"===e?function(e){const t=sa(e),n=xi(e).map((e,n)=>n<t.startIndex||n>t.endIndex?eo(e):e.list?N(e,(e.list.level??0)+1):eo(e));return Cn(e,n,H(n,t))}(t):wS(t)),!0)),handleListEnter:C,handleListBoundaryBackspace:e=>{const n=S();return!(!n?.list||!g())&&(0===To(n,t.selection.focus)&&(d(),p(),s(e=>wS(e)),e.currentTarget.value="",c(),!0))}}}(e)}function kS(e){return{fontFamily:e.fontFamily??"",fontSize:ut(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 TS(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 PS(e){return function(e){const t=CS({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:()=>ri(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:kS(e.toolbarStyleState())})},openParagraphDialog:t=>{e.setParagraphDialog({isOpen:!0,initial:{...TS(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 RS(e){return()=>{e.isDirty()?e.requestConfirmation():e.resetDocument()}}function MS(e){const t=e.document.settings?.defaultTabStop;return("number"==typeof t&&Number.isFinite(t)&&t>0?t:36)*Do}function AS(e,t){const n=xi(e);if(!n.length)return e;const r=sa(e,n),o=MS(e);let a=!1;const i=n.map((n,i)=>{if(i<r.startIndex||i>r.endIndex)return n;if(n.list){const e=n.list.level??0,r=Math.max(0,Math.min(8,e+t));return r===e?n:(a=!0,N(n,r))}const s=Lo(n.style,e.document.styles).indentLeft??0;if(t<0&&s<=0)return n;const l=t<0?Math.max(0,s-o):s+o;return l!==s&&Number.isFinite(l)?(a=!0,{...n,style:{...n.style,indentLeft:l}}):n});return a?Cn(e,i,e.selection):e}function OS(e,t){const n=xi(e);if(!n.length)return e;const r=sa(e,n);if(!r.isCollapsed||0!==r.startParagraphOffset)return e;const o=n[r.startIndex];if(!o||o.list)return e;const a=Lo(o.style,e.document.styles),i=a.indentFirstLine??0,s=a.indentHanging??0;if(t>0&&(0!==i||0!==s))return AS(e,1);if(t<0&&i<=0)return e;const l=t>0?MS(e):Math.max(0,i-MS(e)),c=n.map((e,t)=>t===r.startIndex?{...e,style:{...e.style,indentFirstLine:l,indentHanging:0}}:e);return Cn(e,c,e.selection)}function BS(e){const t=xi(e);if(!t.length)return null;const n=sa(e,t);if(!n.isCollapsed||0!==n.startParagraphOffset)return null;const r=t[n.startIndex];if(!r||r.list)return null;const o=Lo(r.style,e.document.styles);return(o.indentLeft??0)>0?"paragraph":(o.indentFirstLine??0)>0&&(o.indentHanging??0)<=0?"firstLine":null}function FS(e){const t=BS(e);return"paragraph"===t?AS(e,-1):"firstLine"===t?OS(e,-1):e}var ES=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 r=e.ctrlKey||e.metaKey,o=e.key.toLowerCase();for(const a of this.bindings.values())if(a.key.toLowerCase()===o&&Boolean(a.ctrlOrMeta)===r&&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}},DS=[{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=xi(t);if(0===n.length)return!1;const r=n[0],o=n[n.length-1];return e.clearPreferredColumn(),e.applyState(Ai(t,{anchor:Xo(r,0),focus:Xo(o,po(o).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:"updateSelectedFields",command:"updateSelectedFields",key:"F9",execute:e=>!!e.executeCommand&&(!1!==e.canExecuteCommand?.("updateSelectedFields")&&e.executeCommand("updateSelectedFields"),!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=>wr(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=>np(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=>rp(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=>un(e))),e.focusInput()),!0)}];function LS(e){return function(e){const t=new ES;DS.forEach(e=>t.register(e));const n=n=>{if(n.defaultPrevented)return;const r=e.state();if(e.isReadOnly()){const e=n.key,t=e.toLowerCase(),r="Tab"===e||"ArrowLeft"===e||"ArrowRight"===e||"ArrowUp"===e||"ArrowDown"===e||"Home"===e||"End"===e||"PageUp"===e||"PageDown"===e,o="Shift"===e||"Control"===e||"Meta"===e||"Alt"===e,a=(n.ctrlKey||n.metaKey)&&("a"===t||"c"===t);return void(r||o||a||n.preventDefault())}if(n.isComposing||229===n.keyCode)return;const o=e.executeCommand?{executeCommand:(t,n)=>e.executeCommand?.(t,n),canExecuteCommand:(t,n)=>e.canExecuteCommand?.(t,n)}:void 0;if(!t.execute(n,e,o)){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(),!ri(r.selection))return e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ip(e))),n.currentTarget.value="",void e.focusInput();const t=xi(r),o=t[t.findIndex(e=>e.id===r.selection.focus.paragraphId)];if(!o)return n.currentTarget.value="",void e.focusInput();if("Backspace"===n.key&&o.list&&0===To(o,r.selection.focus))return e.applySelectionAwareParagraphCommand(e=>wS(e)),n.currentTarget.value="",void e.focusInput();const a=To(o,r.selection.focus),i=po(o),s="Backspace"===n.key?gt(i,a):on(i,a);return"Backspace"===n.key?0===a||s===a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ip(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Ai(t,{anchor:Xo(o,s),focus:Xo(o,a)}),e=>ip(e))):a>=i.length?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>sp(e))):s>a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Ai(t,{anchor:Xo(o,a),focus:Xo(o,s)}),e=>ip(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>sp(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||!BS(r)?(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>ip(e))),n.currentTarget.value="",void e.focusInput()):(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!1!==e.canExecuteCommand?.("outdent")&&e.applySelectionAwareParagraphCommand(FS),n.currentTarget.value="",void e.focusInput());case"Delete":return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>sp(e))),n.currentTarget.value="",void e.focusInput();case"Tab":return void function(e,t,n){const r=t.selection.focus.paragraphId,o=Ra(t.document,r),a=!!o&&Boolean(wo(t.document,r,o.sectionIndex)),i=xi(t);if(!i.length)return;const s=sa(t,i),l=i[s.startIndex];if(!l)return;const c=!s.isCollapsed&&(s.startIndex!==s.endIndex||0===s.startParagraphOffset&&s.endParagraphOffset===Za(l)),d=Lo(l.style,t.document.styles),u=s.isCollapsed&&0===s.startParagraphOffset&&!l.list,p=e.autoTabIndentEnabled?.()??!0,f=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&&po(l).length>0,reverseFirstLineIndent:n.shiftKey&&p&&u&&(d.indentLeft??0)<=0&&(d.indentFirstLine??0)>0});if("passThrough"!==f){switch(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),f){case"insertLiteralTab":{const t=ro(e.pendingCaretTextStyle?.());e.applyTransactionalState(n=>e.applyTableAwareParagraphEdit(n,e=>np(e,"\t",t)));break}case"navigateCell":{const o=n.shiftKey?-1:1,a=e.resolveTableTabTarget?.(t.document,r,o);if("adjacent"===a?.kind)e.applySelectionPreservingStructure(a.selection);else if("afterLast"===a?.kind&&1===o&&e.appendTableRowForTab&&!1!==e.canExecuteCommand?.("tableInsertRowAfter"))e.applyTransactionalState(e.appendTableRowForTab);else if(!a){const n=e.resolveAdjacentTableCellPosition(t.document,r,o);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"===f?OS(e,n.shiftKey?-1:1):AS(e,n.shiftKey?-1:1));break}}n.currentTarget.value="",e.focusInput()}}(e,r,n);case"ArrowLeft":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(Pi(r,-1))):(e.clearPreferredColumn(),e.applyState(Oi(r))),void e.focusInput();case"ArrowRight":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(function(e){return Pi(e,1)}(r))):(e.clearPreferredColumn(),e.applyState(Bi(r))),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)}(r)),e.focusInput()):e.moveVerticalByBlock(-1)||(e.applyState(function(e){return Ti(e,-1)}(r)),e.focusInput()));case"ArrowDown":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(1,!0)||(e.applyState(function(e){return Ri(e,1)}(r)),e.focusInput()):e.moveVerticalByBlock(1)||(e.applyState(function(e){return Ti(e,1)}(r)),e.focusInput()));default:return}}};return{handleKeyDown:n,registry:t}}(e)}var NS=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];var zS={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"}},$S={oasis:{color:"#0f766e",heading:"#115e59"},office:{color:"#4472c4",heading:"#2f5597"},monochrome:{color:"#374151",heading:"#111827"},warm:{color:"#c2410c",heading:"#9a3412"}},HS={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 jS(e,t){const n={...e.document.design??{},...t};return{...e,document:{...e.document,design:n}}}function WS(e,t){return function(e,t){const n=zS[t],r=e.document.styles??{},o=Object.fromEntries(Object.entries(r).map(([e,t])=>{if(!/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e))return[e,t];const r=/^heading[1-9]$/i.test(e)||/title|quote/i.test(e);return[e,{...t,textStyle:{...t.textStyle??{},color:r?n.heading:n.body,...r?{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:o}}}(e,t)}function US(e){return null==e||""===e?null:!0===e||"true"===e||1===e}function VS(e){return null==e||""===e?null:"string"==typeof e?e:String(e)}function _S(e){return null!=e&&""!==e?Number(e):null}function KS({gate:e,style:t,selection:n,history:r,formatting:o,dialog:a,link:i,command:s,valueCommand:l,actionCommand:c}){const d=t.state;return{selectAll:s("selectAll",o.selectAll),selectWord:s("selectWord",o.selectWord),selectSentence:s("selectSentence",o.selectSentence),selectParagraph:s("selectParagraph",o.selectParagraph),selectCollapse:c("selectCollapse",e=>{const t=e??{};o.selectCollapse(Boolean(t.end))}),selectText:l("selectText",e=>{const t=e??{};return o.selectText(t.text??"",null==t.occurrence?1:Number(t.occurrence))},()=>""),selectRange:c("selectRange",e=>{const t=e??{};t.anchor&&t.focus&&o.selectRange(t.anchor,t.focus)}),insertFootnote:s("insertFootnote",o.insertFootnote),setNoteOptions:c("setNoteOptions",e=>{const t=e??{},n="endnote"===t.kind?"endnote":"footnote";o.setNoteOptions({kind:n,...void 0!==t.numberFormat?{numberFormat:t.numberFormat}:{},...void 0!==t.startAt?{startAt:_S(t.startAt)}:{},...void 0!==t.restart?{restart:t.restart}:{}})},()=>({value:o.getNoteOptions("footnote")})),insertTableOfContents:s("insertTableOfContents",o.insertTableOfContents),updateTableOfContents:s("updateTableOfContents",o.updateTableOfContents,()=>({isEnabled:e.isCommandEnabled("updateTableOfContents")&&o.hasTableOfContents()})),insertText:c("insertText",e=>{const t="object"==typeof e&&null!==e&&"text"in e?e:{text:e};o.insertText(String(t.text??""),"string"==typeof t.fontFamily?t.fontFamily:null)}),insertEquation:c("insertEquation",e=>{o.insertEquation(e)}),updateEquation:c("updateEquation",e=>{const t=e;o.updateEquation(t.runId,t.expression)}),pastePlainText:s("pastePlainText",o.pastePlainText),formatPainter:s("formatPainter",o.formatPainterOnce,()=>({isEnabled:e.isCommandEnabled("formatPainter")&&o.canCaptureFormatPainter(),isActive:null!==o.formatPainterMode()})),formatPainterContinuous:s("formatPainterContinuous",o.formatPainterContinuous,()=>({isEnabled:e.isCommandEnabled("formatPainterContinuous")&&o.canCaptureFormatPainter(),isActive:"continuous"===o.formatPainterMode()})),cancelFormatPainter:s("cancelFormatPainter",o.cancelFormatPainter,()=>({isEnabled:null!==o.formatPainterMode()})),bold:s("bold",o.bold,()=>({isActive:Boolean(d().bold)})),italic:s("italic",o.italic,()=>({isActive:Boolean(d().italic)})),underline:s("underline",o.underline,()=>({isActive:Boolean(d().underline)})),doubleUnderline:s("doubleUnderline",o.doubleUnderline,()=>({isActive:"double"===d().underlineStyle})),wordUnderline:s("wordUnderline",o.wordUnderline,()=>({isActive:"words"===d().underlineStyle})),strike:s("strike",o.strike,()=>({isActive:Boolean(d().strike)})),doubleStrike:s("doubleStrike",o.doubleStrike,()=>({isActive:Boolean(d().doubleStrike)})),smallCaps:s("smallCaps",o.smallCaps,()=>({isActive:Boolean(d().smallCaps)})),allCaps:s("allCaps",o.allCaps,()=>({isActive:Boolean(d().allCaps)})),hidden:s("hidden",o.hidden,()=>({isActive:Boolean(d().hidden)})),noProof:s("noProof",o.noProof,()=>({isActive:Boolean(d().noProof)})),webHidden:s("webHidden",o.webHidden,()=>({isActive:Boolean(d().webHidden)})),specVanish:s("specVanish",o.specVanish,()=>({isActive:Boolean(d().specVanish)})),contextualAlternates:s("contextualAlternates",o.contextualAlternates,()=>({isActive:Boolean(d().contextualAlternates)})),characterBorder:s("characterBorder",o.toggleCharacterBorder,()=>({isActive:Boolean(d().characterBorder)})),shadow:s("shadow",o.shadow,()=>({isActive:Boolean(d().shadow)})),emboss:s("emboss",o.emboss,()=>({isActive:Boolean(d().emboss)})),engrave:s("engrave",o.engrave,()=>({isActive:Boolean(d().imprint)})),outline:s("outline",o.outline,()=>({isActive:Boolean(d().outline)})),superscript:s("superscript",o.superscript,()=>({isActive:Boolean(d().superscript)})),subscript:s("subscript",o.subscript,()=>({isActive:Boolean(d().subscript)})),link:s("link",()=>(i.prompt(),!0),()=>({isEnabled:e.isCommandEnabled("link")&&i.canPrompt(),isActive:Boolean(d().link)})),alignLeft:s("alignLeft",o.alignLeft,()=>({isActive:"left"===d().align})),alignCenter:s("alignCenter",o.alignCenter,()=>({isActive:"center"===d().align})),alignRight:s("alignRight",o.alignRight,()=>({isActive:"right"===d().align})),alignJustify:s("alignJustify",o.alignJustify,()=>({isActive:"justify"===d().align})),orderedList:s("orderedList",o.orderedList,()=>({isActive:"ordered"===d().listKind})),bulletList:s("bulletList",o.bulletList,()=>({isActive:"bullet"===d().listKind})),find:s("find",o.find),replace:s("replace",o.replace),replaceAll:c("replaceAll",e=>{const t=e??{};"string"==typeof t.search&&t.search.length>0&&o.replaceAll(t)}),setReviewDisplayMode:l("setReviewDisplayMode",e=>{const t="string"==typeof e?e:e?.mode;return("all"===t||"final"===t||"original"===t||"simple"===t)&&o.setReviewDisplayMode(t)},()=>o.reviewDisplayMode()),toggleTrackChanges:s("toggleTrackChanges",o.toggleTrackChanges,()=>({isActive:o.isTrackChangesEnabled()})),toggleRevisionMarkup:s("toggleRevisionMarkup",o.toggleRevisionMarkup,()=>({isActive:o.areRevisionMarkupVisible()})),showMarkupOptions:l("showMarkupOptions",()=>!1,()=>o.showMarkupOptions()),applyShowMarkup:c("applyShowMarkup",e=>{o.applyShowMarkup(e??{})}),toggleOutlinePanel:s("toggleOutlinePanel",o.toggleOutlinePanel,()=>({isActive:o.areOutlineVisible()})),toggleRevisionsPanel:s("toggleRevisionsPanel",o.toggleRevisionsPanel,()=>({isActive:o.areRevisionsPanelVisible()})),acceptRevisions:s("acceptRevisions",o.acceptRevisions,()=>({isEnabled:e.isCommandEnabled("acceptRevisions")&&o.hasRevisionsInSelection()})),rejectRevisions:s("rejectRevisions",o.rejectRevisions,()=>({isEnabled:e.isCommandEnabled("rejectRevisions")&&o.hasRevisionsInSelection()})),acceptAllRevisions:s("acceptAllRevisions",o.acceptAllRevisions,()=>({isEnabled:e.isCommandEnabled("acceptAllRevisions")&&o.hasRevisionsInDocument()})),rejectAllRevisions:s("rejectAllRevisions",o.rejectAllRevisions,()=>({isEnabled:e.isCommandEnabled("rejectAllRevisions")&&o.hasRevisionsInDocument()})),requestAcceptAllRevisions:s("requestAcceptAllRevisions",()=>(a.requestAcceptAllRevisions(),!0),()=>({isEnabled:e.isCommandEnabled("requestAcceptAllRevisions")&&o.hasRevisionsInDocument()})),requestRejectAllRevisions:s("requestRejectAllRevisions",()=>(a.requestRejectAllRevisions(),!0),()=>({isEnabled:e.isCommandEnabled("requestRejectAllRevisions")&&o.hasRevisionsInDocument()})),nextRevision:s("nextRevision",o.navigateRevisionNext,()=>({isEnabled:e.isCommandEnabled("nextRevision")&&o.hasNavigableRevisions()})),previousRevision:s("previousRevision",o.navigateRevisionPrevious,()=>({isEnabled:e.isCommandEnabled("previousRevision")&&o.hasNavigableRevisions()})),newComment:s("newComment",o.newComment,()=>({isEnabled:e.isCommandEnabled("newComment")&&o.canCreateComment()})),replyComment:s("replyComment",o.replyComment,()=>({isEnabled:e.isCommandEnabled("replyComment")&&o.canReplyToComment()})),toggleCommentsPanel:s("toggleCommentsPanel",o.toggleCommentsPanel,()=>({isEnabled:e.isCommandEnabled("toggleCommentsPanel"),isActive:o.isCommentsPanelOpen()})),editComment:s("editComment",o.editComment,()=>({isEnabled:e.isCommandEnabled("editComment")&&o.canEditComment()})),nextComment:s("nextComment",o.navigateCommentNext,()=>({isEnabled:e.isCommandEnabled("nextComment")&&o.hasNavigableComments()})),previousComment:s("previousComment",o.navigateCommentPrevious,()=>({isEnabled:e.isCommandEnabled("previousComment")&&o.hasNavigableComments()})),resolveComment:s("resolveComment",o.resolveSelectedComment,()=>({isEnabled:e.isCommandEnabled("resolveComment")&&o.canManageSelectedComment()&&!o.isSelectedCommentResolved()})),reopenComment:s("reopenComment",o.reopenSelectedComment,()=>({isEnabled:e.isCommandEnabled("reopenComment")&&o.canManageSelectedComment()&&o.isSelectedCommentResolved()})),deleteComment:s("deleteComment",o.deleteSelectedComment,()=>({isEnabled:e.isCommandEnabled("deleteComment")&&o.canDeleteSelectedComment()})),toggleShowMargins:s("toggleShowMargins",o.toggleShowMargins,()=>({isActive:o.areMarginsVisible()})),toggleShowParagraphMarks:s("toggleShowParagraphMarks",o.toggleShowParagraphMarks,()=>({isActive:o.areParagraphMarksVisible()})),togglePreciseFonts:s("togglePreciseFonts",o.togglePreciseFonts,()=>(Be(),{isActive:Cr()})),undo:s("undo",r.undo,()=>({isEnabled:e.isCommandEnabled("undo")&&r.canUndo()})),redo:s("redo",r.redo,()=>({isEnabled:e.isCommandEnabled("redo")&&r.canRedo()})),pageBreak:s("pageBreak",o.pageBreak),lineBreak:s("lineBreak",o.lineBreak),columnBreak:s("columnBreak",o.columnBreak),splitBlock:s("splitBlock",o.splitBlock),insertNonBreakingSpace:s("insertNonBreakingSpace",()=>o.insertSpecialChar("nbsp")),insertNonBreakingHyphen:s("insertNonBreakingHyphen",()=>o.insertSpecialChar("nbHyphen")),insertOptionalHyphen:s("insertOptionalHyphen",()=>o.insertSpecialChar("optionalHyphen")),insertEmDash:s("insertEmDash",()=>o.insertSpecialChar("emDash")),insertEllipsis:s("insertEllipsis",()=>o.insertSpecialChar("ellipsis")),insertCopyright:s("insertCopyright",()=>o.insertSpecialChar("copyright")),insertRegistered:s("insertRegistered",()=>o.insertSpecialChar("registered")),insertTrademark:s("insertTrademark",()=>o.insertSpecialChar("trademark")),setFontFamily:l("setFontFamily",e=>o.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 o.setFontSize(null);if("string"!=typeof t&&"number"!=typeof t)return!1;const n=er(t);return null!==n&&o.setFontSize(n)},()=>ut(d().fontSize)),increaseFontSize:s("increaseFontSize",o.increaseFontSize),decreaseFontSize:s("decreaseFontSize",o.decreaseFontSize),growFont1:s("growFont1",o.growFont1),shrinkFont1:s("shrinkFont1",o.shrinkFont1),changeTextCase:c("changeTextCase",e=>{o.changeTextCase(e??"sentence")},()=>({isEnabled:e.isCommandEnabled("changeTextCase")&&!n.isCollapsed()})),clearFormatting:s("clearFormatting",o.clearFormatting),setColor:l("setColor",e=>o.setColor(e??null),()=>d().color||null),setHighlight:l("setHighlight",e=>o.setHighlight(e??null),()=>d().highlight||null),setTextShading:l("setTextShading",e=>o.setTextShading(e??null),()=>d().textShading||null),setStyleId:l("setStyleId",e=>o.setStyleId(String(e)),()=>{const e=d();return e.mixedParagraphStyles?"":e.styleId||"normal"}),setCharacterStyleId:l("setCharacterStyleId",e=>o.setCharacterStyleId(String(e)),()=>d().characterStyleId||""),applyUnderlineStyle:l("applyUnderlineStyle",e=>(o.applyUnderlineStyle(e),!0),()=>d().underlineStyle),setUnderlineStyle:l("setUnderlineStyle",e=>(o.setUnderlineStyle(e||null),!0),()=>d().underlineStyle),setUnderlineColor:l("setUnderlineColor",e=>o.setUnderlineColor(e||null),()=>d().underlineColor),setCharacterScale:l("setCharacterScale",e=>o.setCharacterScale(_S(e)),()=>d().characterScale),setCharacterSpacing:l("setCharacterSpacing",e=>o.setCharacterSpacing(_S(e)),()=>d().characterSpacing),setRunSnapToGrid:l("setRunSnapToGrid",e=>o.setRunSnapToGrid(US(e)),()=>d().snapToGrid),setFitText:l("setFitText",e=>o.setFitText(_S(e)),()=>d().fitText),setBaselineShift:l("setBaselineShift",e=>o.setBaselineShift(_S(e)),()=>d().baselineShift),setEmphasisMark:l("setEmphasisMark",e=>o.setEmphasisMark(e||null),()=>d().emphasisMark),setTextEffect:l("setTextEffect",e=>o.setTextEffect(e||null),()=>d().textEffect),setKerning:l("setKerning",e=>o.setKerning(_S(e)),()=>d().kerningThreshold),setLigatures:l("setLigatures",e=>o.setLigatures(e||null),()=>d().ligatures),setNumberSpacing:l("setNumberSpacing",e=>o.setNumberSpacing(e||null),()=>d().numberSpacing),setNumberForm:l("setNumberForm",e=>o.setNumberForm(e||null),()=>d().numberForm),setStylisticSet:l("setStylisticSet",e=>o.setStylisticSet(_S(e)),()=>d().stylisticSet)}}function qS({gate:e,style:t,document:n,link:r,image:o,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",()=>r.remove(),()=>({isEnabled:e.isCommandEnabled("unlink")&&Boolean(s().link),isActive:Boolean(s().link)})),editImageAlt:i("editImageAlt",()=>o.promptAlt(),()=>({isEnabled:o.isSelected(),isActive:o.isSelected()})),insertImageCaption:i("insertImageCaption",()=>o.promptCaption(),()=>({isEnabled:o.isSelected(),isActive:o.isSelected()})),imageContext:i("imageContext",()=>{},()=>({isEnabled:o.isSelected(),isActive:o.isSelected(),value:null})),imageWidthCm:i("imageWidthCm",e=>o.setWidthCm(Number(e)),()=>({isEnabled:o.isSelected(),value:o.getSizeCm()?.width??null})),imageHeightCm:i("imageHeightCm",e=>o.setHeightCm(Number(e)),()=>({isEnabled:o.isSelected(),value:o.getSizeCm()?.height??null})),imageCrop:i("imageCrop",()=>o.toggleCrop(),()=>({isEnabled:o.isSelected(),isActive:o.isCropActive()})),imageCropAspect:i("imageCropAspect",e=>o.applyCropAspect(String(e)),()=>({isEnabled:o.isSelected()})),imageCropShape:i("imageCropShape",e=>o.applyCropShape(String(e)),()=>({isEnabled:o.isSelected(),value:o.getCropShape()})),imageCropFill:i("imageCropFill",()=>o.applyCropFill(),()=>({isEnabled:o.isSelected()})),imageCropFit:i("imageCropFit",()=>o.applyCropFit(),()=>({isEnabled:o.isSelected()})),imageCropReset:i("imageCropReset",()=>o.resetCrop(),()=>({isEnabled:o.isSelected()})),imageFlip:i("imageFlip",e=>o.flip(e??"horizontal"),()=>({isEnabled:o.isSelected()})),imageRotate:i("imageRotate",e=>o.rotate(e??"left"),()=>({isEnabled:o.isSelected()})),imageBorder:i("imageBorder",e=>o.setBorder(e),()=>({isEnabled:o.isSelected(),value:o.getBorder()})),imageTransparency:i("imageTransparency",e=>o.setTransparency("number"==typeof e?e:null==e?0:Number(e)),()=>({isEnabled:o.isSelected(),value:o.getTransparency()})),resetImage:i("resetImage",()=>o.reset(),()=>({isEnabled:o.canReset()}))}}function XS({style:e,paragraph:t,section:n,valueCommand:r,actionCommand:o}){const a=e.state;return{outdent:o("outdent",()=>t.outdent()),indent:o("indent",()=>t.indent()),moveParagraphsUp:o("moveParagraphsUp",()=>t.moveParagraphsUp(),()=>({isEnabled:t.canMoveParagraphsUp()})),moveParagraphsDown:o("moveParagraphsDown",()=>t.moveParagraphsDown(),()=>({isEnabled:t.canMoveParagraphsDown()})),togglePageBreakBefore:o("togglePageBreakBefore",()=>t.togglePageBreakBefore(),()=>({isActive:Boolean(a().pageBreakBefore)})),toggleKeepWithNext:o("toggleKeepWithNext",()=>t.toggleKeepWithNext(),()=>({isActive:Boolean(a().keepWithNext)})),toggleKeepLinesTogether:o("toggleKeepLinesTogether",()=>t.toggleKeepLinesTogether(),()=>({isActive:Boolean(a().keepLinesTogether)})),toggleWidowControl:o("toggleWidowControl",()=>t.toggleWidowControl(),()=>({isActive:Boolean(a().widowControl)})),toggleParagraphBidi:o("toggleParagraphBidi",()=>t.setBidi(!a().bidi||null),()=>({isActive:Boolean(a().bidi)})),setParagraphBidi:r("setParagraphBidi",e=>(t.setBidi(US(e)),!0),()=>a().bidi),setParagraphAlign:r("setParagraphAlign",e=>(t.setParagraphAlign(e),!0),()=>a().align),sortParagraphs:o("sortParagraphs",e=>t.sortParagraphs(!0===e||"true"===e||Boolean(e?.descending))),promote:o("promote",()=>t.promote()),demote:o("demote",()=>t.demote()),resetParagraphFormatting:o("resetParagraphFormatting",()=>t.resetParagraphFormatting()),setOutlineLevel:o("setOutlineLevel",e=>{const n=e??void 0,r=null==n||"body"===n||""===n?null:Number(n);t.setOutlineLevel(null===r||Number.isNaN(r)?null:r)},()=>({value:Number(e.state().outlineLevel)||null})),setParagraphTabStops:o("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:r("setSpacingAfter",e=>(t.setSpacingAfter(_S(e)),!0),()=>a().spacingAfter),setSpacingBefore:r("setSpacingBefore",e=>(t.setSpacingBefore(_S(e)),!0),()=>a().spacingBefore),setContextualSpacing:r("setContextualSpacing",e=>(t.setContextualSpacing(US(e)),!0),()=>a().contextualSpacing),setLineRule:r("setLineRule",e=>(t.setLineRule(VS(e)),!0),()=>a().lineRule),setTextDirection:r("setTextDirection",e=>(t.setTextDirection(VS(e)),!0),()=>a().textDirection),setSuppressAutoHyphens:r("setSuppressAutoHyphens",e=>(t.setSuppressAutoHyphens(US(e)),!0),()=>a().suppressAutoHyphens),setSuppressLineNumbers:r("setSuppressLineNumbers",e=>(t.setSuppressLineNumbers(US(e)),!0),()=>a().suppressLineNumbers),setKinsoku:r("setKinsoku",e=>(t.setKinsoku(US(e)),!0),()=>a().kinsoku),setOverflowPunct:r("setOverflowPunct",e=>(t.setOverflowPunct(US(e)),!0),()=>a().overflowPunct),setWordWrap:r("setWordWrap",e=>(t.setWordWrap(US(e)),!0),()=>a().wordWrap),setAutoSpaceDE:r("setAutoSpaceDE",e=>(t.setAutoSpaceDE(US(e)),!0),()=>a().autoSpaceDE),setAutoSpaceDN:r("setAutoSpaceDN",e=>(t.setAutoSpaceDN(US(e)),!0),()=>a().autoSpaceDN),setAdjustRightInd:r("setAdjustRightInd",e=>(t.setAdjustRightInd(US(e)),!0),()=>a().adjustRightInd),setTopLinePunct:r("setTopLinePunct",e=>(t.setTopLinePunct(US(e)),!0),()=>a().topLinePunct),setPageBreakBefore:r("setPageBreakBefore",e=>(t.setPageBreakBefore(US(e)),!0),()=>a().pageBreakBefore),setKeepWithNext:r("setKeepWithNext",e=>(t.setKeepWithNext(US(e)),!0),()=>a().keepWithNext),setKeepLinesTogether:r("setKeepLinesTogether",e=>(t.setKeepLinesTogether(US(e)),!0),()=>a().keepLinesTogether),setWidowControl:r("setWidowControl",e=>(t.setWidowControl(US(e)),!0),()=>a().widowControl),setMirrorIndents:r("setMirrorIndents",e=>(t.setMirrorIndents(US(e)),!0),()=>a().mirrorIndents),setIndentLeft:r("setIndentLeft",e=>(t.setIndentLeft(_S(e)),!0),()=>a().indentLeft),setIndentRight:r("setIndentRight",e=>(t.setIndentRight(_S(e)),!0),()=>a().indentRight),setIndentFirstLine:r("setIndentFirstLine",e=>(t.setIndentFirstLine(_S(e)),!0),()=>a().indentFirstLine),setIndentHanging:r("setIndentHanging",e=>(t.setIndentHanging(_S(e)),!0),()=>a().indentHanging),setSpecialIndent:o("setSpecialIndent",e=>{const n=e??{};t.setSpecialIndent(n.kind??"none",_S(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:r("setParagraphShading",e=>(t.setShading(e??null),!0),()=>a().shading||"#ffffff"),applyParagraphBorders:o("applyParagraphBorders",()=>t.applyBorders()),applyHorizontalLine:o("applyHorizontalLine",()=>t.addHorizontalLine()),setDropCap:o("setDropCap",e=>{const n=e??{};t.setDropCap(n)},()=>({value:t.hasDropCap()})),setLineHeight:r("setLineHeight",e=>(t.setLineHeight(_S(e)),!0),()=>a().lineHeight),setListFormat:o("setListFormat",e=>t.setListFormat(String(e))),setListStartAt:o("setListStartAt",e=>t.setListStartAt(_S(e))),restartList:o("restartList",e=>{const n=e;t.restartList("number"==typeof n&&Number.isFinite(n)?Math.max(0,Math.floor(n)):void 0)}),continueList:o("continueList",()=>t.continueList()),setListLevel:o("setListLevel",e=>t.setListLevel(_S(e)??0)),toggleOrientation:o("toggleOrientation",()=>n.toggleOrientation(),()=>({isActive:n.isLandscape()})),setOrientation:o("setOrientation",e=>n.setOrientation(e)),sectionBreakNextPage:o("sectionBreakNextPage",()=>n.breakNextPage()),sectionBreakContinuous:o("sectionBreakContinuous",()=>n.breakContinuous()),sectionBreakEvenPage:o("sectionBreakEvenPage",()=>n.breakEvenPage()),sectionBreakOddPage:o("sectionBreakOddPage",()=>n.breakOddPage()),sectionBreakNextColumn:o("sectionBreakNextColumn",()=>n.breakNextColumn()),setPageMargins:o("setPageMargins",e=>{n.setPageMargins(e??{})},()=>({value:n.getMargins()})),setMarginsPreset:o("setMarginsPreset",e=>{"string"==typeof e&&e.length>0&&n.setMarginsPreset(e)}),setSectionPageNumbering:o("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:o("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:o("setPaperSizePreset",e=>{"string"==typeof e&&e.length>0&&n.setPaperSizePreset(e)}),setColumns:o("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:o("setColumnsPreset",e=>{if("string"==typeof e&&e.length>0){const t=Gt(e);if(!t)return;n.setColumns({count:t.count})}}),setSectionVerticalAlign:o("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:o("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:o("setSectionBidi",e=>{const t=e??void 0;n.setBidi(t??!0)},()=>({value:n.getBidi()})),setHyphenation:o("setHyphenation",e=>{const t=e??{};n.setHyphenation(t)},()=>({value:n.getHyphenation().value}))}}function GS({gate:e,headerFooter:t,command:n,actionCommand:r}){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:r("exitHeaderFooter",()=>t.exit(),()=>({isEnabled:e.isCommandEnabled("exitHeaderFooter")&&t.isInHeaderFooter()})),setDifferentFirstPage:r("setDifferentFirstPage",e=>{const n=e??void 0;t.setDifferentFirstPage(n??!0)},()=>({value:t.getDifferentFirstPage()})),setDifferentOddEven:r("setDifferentOddEven",e=>{const n=e??void 0;t.setDifferentOddEven(n??!0)},()=>({value:t.getDifferentOddEven()}))}}function YS({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 ZS({fields:e,actionCommand:t}){const n=(e,n,r)=>{const o=t(e,()=>{},()=>({isEnabled:n()}));return{...o,execute:e=>!1!==o.refresh?.().isEnabled&&r(e)}};return{markIndexEntry:n("markIndexEntry",()=>!!e.markIndexEntry&&!!e.canMarkIndexEntry?.(),t=>{if(!t||"object"!=typeof t)return!1;const n=t;return!(!Array.isArray(n.path)||!n.path.every(e=>"string"==typeof e)||void 0!==n.identifier&&"string"!=typeof n.identifier||void 0!==n.boldPage&&"boolean"!=typeof n.boldPage||void 0!==n.italicPage&&"boolean"!=typeof n.italicPage)&&(e.markIndexEntry?.(n)??!1)}),insertIndex:n("insertIndex",()=>!!e.insertIndex&&!!e.canInsertIndex?.(),t=>{if(!t||"object"!=typeof t)return!1;const n=t;return"string"==typeof n.locale&&(void 0===n.identifier||"string"==typeof n.identifier)&&(e.insertIndex?.(n)??!1)}),updateIndex:n("updateIndex",()=>!!e.updateIndex&&!!e.canUpdateIndex?.(),t=>{if(void 0!==t&&(!t||"object"!=typeof t||Array.isArray(t)))return!1;const n=t?.locale;return(void 0===n||"string"==typeof n)&&(e.updateIndex?.(n)??!1)}),updateBodyFields:t("updateBodyFields",()=>{e.updateBodyFields?.()},()=>({isEnabled:!!e.updateBodyFields&&(e.canUpdateBodyFields?.()??!0)})),updateSelectedFields:t("updateSelectedFields",()=>{e.updateSelectedFields?.()},()=>({isEnabled:!!e.updateSelectedFields&&(e.canUpdateBodyFields?.()??!0)})),insertFieldCode:n("insertFieldCode",()=>!!e.insertFieldCode,t=>!("string"!=typeof t||!t)&&(e.insertFieldCode?.(t)??!1)),editFieldCode:n("editFieldCode",()=>!!e.editFieldCode,t=>{if(!t||"object"!=typeof t)return!1;const n=t;return"string"==typeof n.instructionRunId&&"string"==typeof n.code&&(e.editFieldCode?.(n.instructionRunId,n.code)??!1)}),editFieldCodeAtSelection:n("editFieldCodeAtSelection",()=>!!e.editFieldCodeAtSelection,t=>!("string"!=typeof t||!t)&&(e.editFieldCodeAtSelection?.(t)??!1)),toggleFieldLock:n("toggleFieldLock",()=>!!e.toggleFieldLock,t=>"string"==typeof t&&(e.toggleFieldLock?.(t)??!1)),toggleFieldCodes:t("toggleFieldCodes",t=>{const n="boolean"==typeof t?t:void 0;e.toggleFieldCodes?.(n??!0)}),nextField:t("nextField",()=>{e.navigateField?.("next")}),previousField:t("previousField",()=>{e.navigateField?.("previous")}),markAuthorityEntry:n("markAuthorityEntry",()=>!!e.markAuthorityEntry,t=>{if(!t||"object"!=typeof t)return!1;const n=t;return!("string"!=typeof n.long||void 0!==n.short&&"string"!=typeof n.short||void 0!==n.category&&"string"!=typeof n.category)&&(e.markAuthorityEntry?.(n)??!1)}),insertTableOfAuthorities:n("insertTableOfAuthorities",()=>!!e.insertTableOfAuthorities,t=>{if(!t||"object"!=typeof t)return!1;const n=t;return"string"==typeof n.locale&&"string"==typeof n.category&&(e.insertTableOfAuthorities?.(n)??!1)}),updateTableOfAuthorities:n("updateTableOfAuthorities",()=>!!e.updateTableOfAuthorities,t=>{if(void 0!==t&&("object"!=typeof t||null===t))return!1;const n=t?.locale;return(void 0===n||"string"==typeof n)&&(e.updateTableOfAuthorities?.(n)??!1)}),insertTableOfFigures:n("insertTableOfFigures",()=>!!e.insertTableOfFigures,t=>{if(!t||"object"!=typeof t)return!1;const n=t;return"string"==typeof n.identifier&&(void 0===n.unlabeled||"boolean"==typeof n.unlabeled)&&(e.insertTableOfFigures?.(n)??!1)}),updateTableOfFigures:n("updateTableOfFigures",()=>!!e.updateTableOfFigures,()=>e.updateTableOfFigures?.()??!1),previewMergeRecord:n("previewMergeRecord",()=>!!e.previewMergeRecord,t=>{if(!t||"object"!=typeof t)return!1;const n=t;return!(!Array.isArray(n.records)||!Number.isInteger(n.index))&&(e.previewMergeRecord?.(n.records,n.index)??!1)}),mergeToNewDocuments:t("mergeToNewDocuments",t=>{const n=t??{};Array.isArray(n.records)&&e.mergeToNewDocuments?.(n.records)}),updateVariableFields:n("updateVariableFields",()=>!!e.updateVariableFields,()=>e.updateVariableFields?.()??!1),setFormFieldValue:n("setFormFieldValue",()=>!!e.setFormFieldValue,t=>{if(!t||"object"!=typeof t)return!1;const n=t;return"string"==typeof n.name&&"string"==typeof n.value&&(e.setFormFieldValue?.(n.name,n.value)??!1)}),toggleFormCheckbox:n("toggleFormCheckbox",()=>!!e.toggleFormCheckbox,t=>"string"==typeof t&&(e.toggleFormCheckbox?.(t)??!1)),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 r="PAGEREF"===n.type?"PAGEREF":"REF";e.insertCrossReference({type:r,bookmark:n.bookmark})})}}function JS({gate:e,table:t,actionCommand:n,valueCommand:r}){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(US(e))),tableSetCellFitText:n("tableSetCellFitText",e=>t.setCellFitText(US(e))),tableSetRowHeight:n("tableSetRowHeight",e=>t.setActiveTableRowHeight(e??{height:null}),()=>({isEnabled:e.isCommandEnabled("tableSetRowHeight")&&t.canSetActiveTableRowHeight()})),tableSetBreakAcrossPages:r("tableSetBreakAcrossPages",e=>(t.setActiveTableRowBreakAcrossPages(US(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetBreakAcrossPages")&&t.canSetActiveTableRowBreakAcrossPages()})),tableSetHeaderRow:r("tableSetHeaderRow",e=>(t.setActiveTableRowHeader(US(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetHeaderRow")&&t.canSetActiveTableRowHeader()})),tableSetColumnWidth:r("tableSetColumnWidth",e=>(t.setActiveTableColumnWidth(e),!0),()=>({isEnabled:e.isCommandEnabled("tableSetColumnWidth")&&t.canSetActiveTableColumnWidth()})),tableSetTableWidth:r("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(_S(e)),()=>({isEnabled:e.isCommandEnabled("tableSetCellSpacing")&&t.canSetCellSpacing()})),tableSetTableIndent:n("tableSetTableIndent",e=>t.setTableIndent(_S(e)),()=>({isEnabled:e.isCommandEnabled("tableSetTableIndent")&&t.canSetTableIndent()})),tableSetAlignment:n("tableSetAlignment",e=>t.setTableAlignment(VS(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:r,columns:o}=e??{},a=r??o;n&&a&&t.insert(n,a)})}}function QS({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 eC({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 tC=/* @__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"]),nC=/* @__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"]),rC=/* @__PURE__ */new WeakMap;function oC(e){return{isCommandEnabled:t=>"openSymbolDialog"===t||("openEquationDialog"===t||("repeatLastAction"===t?!e.isReadOnly()&&e.canRepeatLastAction():(!nC.has(t)||!function(e){const t=e.state?.();if(!t)return!1;const n=t.document,r=t.selection;if(!n||!r)return!1;let o=rC.get(n);o||(o=/* @__PURE__ */new WeakMap,rC.set(n,o));const a=o.get(r);if(void 0!==a)return a;const i=null!==Fi(t,e=>"image"===e.kind||"textBox"===e.kind);return o.set(r,i),i}(e))&&((tC.has(t)||!e.isReadOnly())&&("insertFootnote"!==t||e.commandsController.canInsertFootnoteCommand()))))}}function aC(e){return{state:()=>e.styleController.toolbarStyleState()}}function iC(e){return{isCollapsed:()=>ri(e.state().selection)}}function sC(e){return{canUndo:()=>e.undoStack().length>0,canRedo:()=>e.redoStack().length>0,undo:()=>(e.historyActions.performUndo(),!0),redo:()=>(e.historyActions.performRedo(),!0)}}var lC={nbsp:" ",nbHyphen:"‑",optionalHyphen:"",emDash:"—",ellipsis:"…",copyright:"©",registered:"®",trademark:"™"};function cC(e){return/\p{L}|\p{N}/u.test(e)}function dC(e){return"."===e||"!"===e||"?"===e}function uC(e,t){return Xo(e,t)}function pC(e,t,n,r){return e-n||t-r}function fC(e,t){const n=xi(e),r=n[t.startIndex],o=n[t.endIndex];return r&&o?{...e,selection:{anchor:uC(r,t.startOffset),focus:uC(o,t.endOffset)}}:e}function gC(e,t,n){if(!t.length)return null;const r=xi(e),o=new Map(r.map((e,t)=>[e.id,t])),a="next"===n?sa(e,r).end:sa(e,r).start,i=o.get(a.paragraphId);if(void 0===i)return null;const s=r[i],l=To(s,a);return("next"===n?t.find(e=>pC(e.startIndex,e.startOffset,i,l)>0):[...t].reverse().find(e=>pC(e.startIndex,e.startOffset,i,l)<0))??("next"===n?t[0]:t[t.length-1])}function mC(e){const t=xi(e),n=[],r=/* @__PURE__ */new Set,o=/* @__PURE__ */new Map;for(const a of[...Xv(e),...Gv(e)]){const e=a.paragraphIds[0];if(!e)continue;const t=o.get(e)??[];t.push(a.id),o.set(e,t)}return t.forEach((e,t)=>{for(const i of o.get(e.id)??[])r.has(i)||(r.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 o of e.runs){const e=[o.revision?.id,o.styles?.propertyRevision?.id].filter(e=>"string"==typeof e);for(const i of e)r.has(i)||(r.add(i),n.push({id:i,startIndex:t,startOffset:a,endIndex:t,endOffset:a+o.text.length}));a+=o.text.length}}),n}function hC(e,t){const n=gC(e,mC(e),t);return n?fC(e,n):e}function bC(e){const t=xi(e),n=new Map(t.map((e,t)=>[e.id,t])),r=e.document.comments;if(!r)return[];const o=[];for(const a of r.order){const e=r.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)));pC(i,d,s,u)>0||o.push({id:a,startIndex:i,startOffset:d,endIndex:s,endOffset:u})}return o.sort((e,t)=>pC(e.startIndex,e.startOffset,t.startIndex,t.startOffset))}function yC(e,t){const n=gC(e,bC(e),t);return n?fC(e,n):e}function vC(e){const t=bC(e);if(!t.length)return null;const n=sa(e),r=t.find(e=>0===pC(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)&&0===pC(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset))??t.find(e=>pC(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)<=0&&pC(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset)>=0);return r?e.document.comments?.items[r.id]??null:null}function xC(e,t){const n=mC(e).find(e=>e.id===t);return n?fC(e,n):e}function wC(e,t=f,n=6,r=9){const o=(t,n,r)=>({state:e,layout:r,status:t,passes:n,updatedEntries:0});if("main"!==Yo(e)||e.trackChangesEnabled||!Number.isSafeInteger(n)||n<1||!Number.isSafeInteger(r)||r<1||r>9)return o("unsupported",0);const a=Math.min(n,6),i=ya(e),s=Si(e.document)[i];if(!s)return o("unsupported",0);const l=bI(s.blocks);if(!l||r<l.endLevel)return o("unsupported",0);const c=s.blocks[l.startBlockIndex].id,d=s.blocks[l.endBlockIndex].id,u=new Set(s.blocks.slice(l.startBlockIndex+1,l.endBlockIndex).map(e=>e.id)),p=wI(e,l,r);if(!p||p.length>2048)return o("unsupported",0);const g=JSON.stringify(p.map(e=>[e.id,e.level,e.text,e.tc])),m=/* @__PURE__ */new Set;let h,b=e;for(let f=1;f<=a;f++){let n;try{n=t(b.document)}catch{return o("unsupported",f,h)}h??=n;const a=Si(b.document)[i]?.blocks,s=a&&bI(a);if(!a||!s||a[s.startBlockIndex]?.id!==c||a[s.endBlockIndex]?.id!==d)return o("unsupported",f,h);const l=wI(b,s,r);if(!l||JSON.stringify(l.map(e=>[e.id,e.level,e.text,e.tc]))!==g)return o("unsupported",f,h);const p=yI(b.document,n),y=l.map(e=>p(e.id,e.tc));if(y.some(e=>void 0===e))return o("unresolved",f,h);const v=OI(b,p,r);if(v===b){const t=a.slice(s.startBlockIndex+1,s.endBlockIndex);return t.length!==l.length||t.some((e,t)=>"paragraph"!==e.type||po(e)!==CI(l[t],y[t]))?o("unsupported",f,h):{state:b===e?e:{...b,selection:e.selection},layout:n,status:b===e?"unchanged":"updated",passes:f,updatedEntries:b===e?0:l.length}}if(u.has(e.selection.anchor.paragraphId)||u.has(e.selection.focus.paragraphId))return o("unsupported",f,h);const x=JSON.stringify([l.map((e,t)=>[e.id,e.tc?.runId,e.text,y[t]]),n.pages.map(e=>[e.index,e.sectionIndex])]);if(m.has(x))return o("nonconvergent",f,h);m.add(x),b={...v,selection:e.selection}}return o("nonconvergent",a,h)}var IC=e=>/^_TocOasis(?:[0-9a-f]{30}|[0-9a-f]{32})$/.test(e);function SC(e,t=f){const n=(t,n)=>({state:e,status:t,layout:n});if("main"!==Yo(e)||e.trackChangesEnabled)return n("unsupported");const r=ya(e),o=Si(e.document),a=o[r];if(!a)return n("unsupported");const i=bI(a.blocks);if(!i?.hyperlinks)return n("unsupported");const s=wI(e,i),l=a.blocks.slice(i.startBlockIndex+1,i.endBlockIndex);if(!s||s.length>2048||l.length!==s.length)return n("unsupported");const c=/* @__PURE__ */new Map;for(const f of o)for(const e of f.blocks)if("paragraph"===e.type){if(c.has(e.id))return n("unsupported");c.set(e.id,e)}const d=e.document.bookmarks,u={...d?.items},p=[...d?.order??[]];if(new Set(p).size!==p.length||p.length!==Object.keys(u).length||p.some(e=>!Object.hasOwn(u,e)||u[e]?.id!==e))return n("unsupported");const g=/* @__PURE__ */new Map;for(const f of Object.values(u)){const e=f.name.toLowerCase();g.set(e,g.has(e)?null:f)}let m;try{m=t(e.document)}catch{return n("unsupported")}const h=yI(e.document,m),b=s.map(e=>h(e.id,e.tc));if(b.some(e=>void 0===e))return n("unresolved",m);const y=void 0!==i.tcIdentifier?Y(e.document,m):void 0,v=(e,t,n)=>!!e&&!0===e.hidden&&void 0===e.colFirst&&void 0===e.colLast&&e.start?.paragraphId===t.id&&e.start.offset===(n.tc?.offset??0)&&e.end?.paragraphId===t.id&&e.end.offset===(n.tc?.offset??Za(t));let x=!1;const w=/* @__PURE__ */new Map;for(const[f,T]of s.entries()){const e=l[f],t=c.get(T.id);if(!e||"paragraph"!==e.type||!t||t===e||t.sdtWrappers?.length||t.numberingRevision||t.dropCap||t.runs.some(e=>e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.rtl||("text"===e.kind?!!e.styles?.hidden:!T.tc||0!==e.text.length||"fieldChar"!==e.kind&&"fieldInstruction"!==e.kind))||/[\r\n\t]/.test(T.text)||po(e)!==CI(T,b[f]))return n("unsupported",m);if(T.tc){const e=T.tc.offset;if(!Number.isSafeInteger(e)||e<0||e>Za(t))return n("unsupported",m);const r=y?.pageIndexAt(t.id,e);if(void 0===r||y?.forPage(r).sectionNumber!==T.tc.sectionIndex+1)return n("unresolved",m)}const r=e.runs[0],o=r.styles?.link;if(o){if(!o.startsWith("#")||!v(g.get(o.slice(1).toLowerCase()),t,T)||g.get(o.slice(1).toLowerCase())?.name!==o.slice(1))return n("unsupported",m);continue}let a=Object.values(u).find(e=>IC(e.name)&&g.get(e.name.toLowerCase())===e&&v(e,t,T));if(!a){const e=Zr(),r="_TocOasis"+e.replace(/^bookmark:/,"").replace(/-/g,"").slice(0,30);if(!IC(r)||Object.hasOwn(u,e)||g.has(r.toLowerCase()))return n("unsupported",m);a={id:e,name:r,hidden:!0,start:{paragraphId:t.id,offset:T.tc?.offset??0},end:{paragraphId:t.id,offset:T.tc?.offset??Za(t)}},u[e]=a,p.push(e),g.set(r.toLowerCase(),a)}w.set(e.id,{...e,runs:[{...r,styles:{...r.styles,link:"#"+a.name}}]}),x=!0}if(!x)return n("unchanged",m);const I=o.map((e,t)=>t!==r?e:{...e,blocks:e.blocks.map(e=>w.get(e.id)??e)}),S={...e.document,sections:I,bookmarks:{items:u,order:p}};let C;try{C=t(S)}catch{return n("unsupported",m)}const k=yI(S,C);if(s.some((e,t)=>k(e.id,e.tc)!==b[t]))return n("unresolved",m);if(void 0!==i.tcIdentifier){const e=Y(S,C);if(s.some(t=>{if(!t.tc)return!1;const n=e.pageIndexAt(t.id,t.tc.offset);return void 0===n||e.forPage(n).sectionNumber!==t.tc.sectionIndex+1}))return n("unresolved",m)}return{state:{...e,document:S},status:"updated",layout:C}}function CC(e){const t=Si(e.document)[ya(e)],n=t&&bI(t.blocks);return!n&&$I(e)?function(e,t=e=>f(e,void 0,void 0,void 0,{cachedBodyPageFields:!0})){let n;const r=(t,r)=>({state:e,status:t,passes:r,layout:n,updatedEntries:0}),o=zI(e);if(!o)return r("unsupported",0);const a=Si(e.document).flatMap(e=>e.blocks);if(new Set(a.map(e=>e.id)).size!==a.length)return r("unsupported",0);const i=/* @__PURE__ */new Set;for(const u of[e.document.bookmarks,e.document.comments])for(const e of Object.values(u?.items??{}))for(const t of[e.start,e.end])t&&i.add(t.paragraphId);i.add(e.selection.anchor.paragraphId),i.add(e.selection.focus.paragraphId);const s=JSON.stringify(o.entries),l=/* @__PURE__ */new Set,c=/* @__PURE__ */new Set;let d=e;for(let u=1;u<=6;u++){let o;try{o=t(d.document)}catch{return r("unsupported",u)}n??=o;const a=zI(d);if(!a||JSON.stringify(a.entries)!==s)return r("unsupported",u);const p=HI(d.document,o,a);if(p.some(e=>void 0===e))return r("unresolved",u);const f=Si(d.document).flatMap(e=>e.blocks),g=/* @__PURE__ */new Map,m=[];for(const[e,t]of a.entries.entries()){const n=f.find(e=>e.id===t.paragraphId);if(!n||"paragraph"!==n.type)return r("unsupported",u);const o=t.runIds.map(e=>n.runs.find(t=>t.id===e));if(o.some(e=>!e||"text"!==e.kind))return r("unsupported",u);const a=o.map(e=>e.text.length),s=o.map(e=>e.text).join("");m.push(s);const l=p[e];if(s===l)continue;const d=jI(l,a);if(!d)return r("unsupported",u);if(d.some((e,t)=>e.length!==a[t])&&i.has(t.paragraphId))return r("unsupported",u);g.set(t.paragraphId,new Map(t.runIds.map((e,t)=>[e,d[t]]))),c.add(t.paragraphId)}if(!g.size)return{state:d,layout:o,status:d===e?"unchanged":"updated",passes:u,updatedEntries:c.size};const h=JSON.stringify([m,p]);if(l.has(h))return r("nonconvergent",u);l.add(h),d={...d,document:{...d.document,sections:Si(d.document).map(e=>({...e,blocks:e.blocks.map(e=>{const t=g.get(e.id);return t&&"paragraph"===e.type?{...e,runs:e.runs.map(e=>t.has(e.id)&&t.get(e.id)!==e.text?{...e,text:t.get(e.id)}:e)}:e})}))}}}return r("nonconvergent",6)}(e):n?.hyperlinks?function(e,t=f){let n=0;const r=e=>(n++,t(e)),o=t=>({state:e,status:t,passes:n,updatedEntries:0});if("main"!==Yo(e)||e.trackChangesEnabled)return o("unsupported");const a=ya(e),i=Si(e.document),s=i[a],l=s&&bI(s.blocks);if(!s||!l?.hyperlinks)return o("unsupported");const c=s.blocks.slice(l.startBlockIndex+1,l.endBlockIndex),d=SC(e,r);if("unchanged"===d.status)return{...d,passes:n,updatedEntries:0};if("updated"===d.status)return{...d,passes:n,updatedEntries:c.length};if("unresolved"===d.status)return o("unresolved");const u=Object.values(e.document.bookmarks?.items??{}),p=/* @__PURE__ */new Map;for(const f of c){if("paragraph"!==f.type)return o("unsupported");const e=f.runs[0],t=e.styles?.link;if(!t)continue;if(!t.startsWith("#")||!IC(t.slice(1)))return o("unsupported");const n=u.filter(e=>e.name.toLowerCase()===t.slice(1).toLowerCase());if(n.length>1||n.some(e=>e.name!==t.slice(1)||!e.hidden||void 0!==e.colFirst||void 0!==e.colLast))return o("unsupported");const{link:r,...a}=e.styles;p.set(f.id,{...f,runs:[{...e,styles:a}]})}const g=new Set(c.map(e=>e.id));if(u.some(e=>[e.start,e.end].some(e=>e&&g.has(e.paragraphId))))return o("unsupported");const m=wC(p.size?{...e,document:{...e.document,sections:i.map((e,t)=>t===a?{...e,blocks:e.blocks.map(e=>p.get(e.id)??e)}:e)}}:e,r);if("updated"!==m.status&&"unchanged"!==m.status)return o(m.status);const h=SC(m.state,r);if("updated"!==h.status&&"unchanged"!==h.status)return o(h.status);const b=wI(h.state,l);return b?{state:h.state,layout:h.layout,status:"updated",passes:n,updatedEntries:b.length}:o("unsupported")}(e):wC(e)}function kC(e){const t=t=>{const n=Number(e.styleController.toolbarStyleState().fontSize),r=Number.isFinite(n)&&n>0?tn(n):11,o="increase"===t?Fn(r):It(r);return e.styleController.applyToolbarValueStyleCommand("fontSize",Xn(o)),!0};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=Co(e.state().document);if(0===t.length)return!1;const n=t[0],r=t[t.length-1];return e.applyState({...e.state(),selection:{anchor:Xo(n,0),focus:Xo(r,po(r).length)}}),e.focusInput(),!0},selectWord:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=ae(e),r=po(t);let o=n,a=n;for(;o>0&&cC(r[o-1]);)o-=1;for(;a<r.length&&cC(r[a]);)a+=1;return Ai(e,{anchor:Xo(t,o),focus:Xo(t,a)})}(e.state())),e.focusInput(),!0),selectSentence:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=ae(e),r=po(t);let o=n;for(;o>0&&!dC(r[o-1]);)o-=1;for(;o<r.length&&/\s/u.test(r[o]);)o+=1;let a=n;for(;a<r.length&&!dC(r[a]);)a+=1;return a<r.length&&(a+=1),Ai(e,{anchor:Xo(t,o),focus:Xo(t,Math.min(a,r.length))})}(e.state())),e.focusInput(),!0),selectParagraph:()=>!e.isReadOnly()&&(e.applyState(function(e){const t=xi(e),n=sa(e),r=t[n.startIndex],o=t[n.endIndex];return r&&o?Ai(e,{anchor:Xo(r,0),focus:Xo(o,Za(o))}):e}(e.state())),e.focusInput(),!0),selectCollapse:(t=!1)=>!e.isReadOnly()&&(e.applyState(function(e,t=!1){const n=e.selection.anchor,r=e.selection.focus,o=xi(e),a=Ca(o,n,r),i=t?a<=0?r:n:a<=0?n:r;return Ai(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 r=Iw(e.document,t)[Math.max(1,n)-1];return r?Ai(e,{anchor:r.anchor,focus:r.focus}):e}(e.state(),t,n)),e.focusInput(),!0),selectRange:(t,n)=>(e.applyState(function(e,t,n){return Ai(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,r={...("endnote"===n?e.document.endnotes?.settings:e.document.footnotes?.settings)??{}};let o=!1;if(void 0!==t.numberFormat){const e=null===t.numberFormat?void 0:t.numberFormat;r.numberFormat!==e&&(r.numberFormat=e,o=!0)}if(void 0!==t.startAt){const e=null===t.startAt?void 0:Math.max(1,Math.round(t.startAt));r.startAt!==e&&(r.startAt=e,o=!0)}if(void 0!==t.restart){const e=null===t.restart?void 0:t.restart;r.restart!==e&&(r.restart=e,o=!0)}if(!o)return e;const a=Object.keys(r).length>0?{...r}: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 r=n?{fontFamily:n}:void 0;return e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>np(e,t,r))),e.focusInput(),!0},insertEquation:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){if(be(e))return e;const n=ri(e.selection)?e:te(e),{paragraph:r,index:o,offset:a}=ae(n),i=Qn(r,a),s={id:`run:${Math.random().toString(36).slice(2,9)}`,text:"",styles:i,kind:"math",math:t},l=we(r,a,[s]),c=xi(n).map((e,t)=>t===o?l:e);return Cn(n,c,J(Xo(l,a+1)))}(e,t))),e.focusInput(),!0),updateEquation:(t,n)=>(e.applyTransactionalState(e=>function(e,t,n){let r=!1;const o=xi(e).map(e=>{let o=!1;const a=e.runs.map(e=>e.id!==t||"math"!==e.kind?e:(r=!0,o=!0,{...e,math:n,text:""}));return o?{...e,runs:a}:e});return r?Cn(e,o,e.selection):e}(e,t,n)),e.focusInput(),!0),hasTableOfContents:()=>function(e){if("main"!==Yo(e))return!1;const t=Si(e.document)[ya(e)];return!!t&&void 0!==AI(t.blocks)}(e.state())||$I(e.state()),hasRevisionsInSelection:()=>hS(e.state()).size>0,hasRevisionsInDocument:()=>yS(e.state()),hasNavigableRevisions:()=>mC(e.state()).length>0,hasNavigableComments:()=>{return(t=e.state(),bC(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=hC(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateRevisionPrevious:()=>{const t=e.state(),n=hC(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentNext:()=>{const t=e.state(),n=yC(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentPrevious:()=>{const t=e.state(),n=yC(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},hasSelectedComment:()=>null!==vC(e.state()),isSelectedCommentResolved:()=>Boolean(vC(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=>{const t=MI(e);if(t===e)return e;const n=CC(t);return"updated"===n.status||"unchanged"===n.status?n.state:t}),e.focusInput(),!0),updateTableOfContents:()=>(e.applyTransactionalState(e=>CC(e).state),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=>Sw(e,t.search,t.replace,{matchCase:t.matchCase,wholeWord:t.wholeWord}),{mergeKey:bf}),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:Zv(e,"insertions"),deletions:Zv(e,"deletions"),comments:Zv(e,"comments"),formatting:Zv(e,"formatting"),allAuthors:t,visibleAuthors:e.markupAuthors??[],knownAuthors:ax(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:()=>(Sr(),!0),pageBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>wr(e))),e.focusInput(),!0),lineBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>np(e,"\n"))),e.focusInput(),!0),columnBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>rp(e))),e.focusInput(),!0),splitBlock:()=>(e.commandsController.handleListEnter()||(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>un(e))),e.focusInput()),!0),insertSpecialChar:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){return np(e,lC[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=>up(e,1)),e.focusInput(),!0),shrinkFont1:()=>(e.applyTransactionalState(e=>up(e,-1)),e.focusInput(),!0),changeTextCase:t=>(e.commandsController.applyChangeTextCaseCommand(t),!0),clearFormatting:()=>ri(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 TC(e,t){const n=Px(e),r=n&&za(n.run);if(!n||!r)return e;const{paragraphIndex:o,run:a}=n,i=xi(e).map((e,n)=>n!==o?eo(e):{...eo(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,shape:t(e.textBox.shape??{})}}:Ro(e))});return Cn(e,i,H(i,sa(e)))}function PC(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 RC(e,t,n){const r={...e??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating"},o=r.positionH??{},a=r.positionV??{};return{...r,wrap:"none"===r.wrap?r.wrap:r.wrap??"square",positionH:{...o,offset:(o.offset??0)+Math.round(t*oa),align:void 0},positionV:{...a,offset:(a.offset??0)+Math.round(n*oa)}}}function MC(e,t){const n=Fi(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const r=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}(t),{paragraphIndex:o,run:a}=n,i=xi(e).map((e,t)=>t!==o?eo(e):{...eo(e),runs:e.runs.map(e=>e.id!==a.id?Ro(e):"image"===e.kind?{...e,image:{...e.image,rotation:r}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:r}}:Ro(e))});return Cn(e,i,H(i,sa(e)))}function AC(e,t,n=90){return OC(e,e=>{const r="right"===t?-n:n,o=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}((e.rotation??0)+r);return{...e,rotation:o}})}function OC(e,t){const n=Px(e);if(!n||!za(n.run))return e;const{paragraphIndex:r,run:o}=n,a=xi(e).map((e,n)=>n!==r?eo(e):{...eo(e),runs:e.runs.map(e=>e.id===o.id&&"textBox"===e.kind?{...e,textBox:t(e.textBox)}:Ro(e))});return Cn(e,a,H(a,sa(e)))}function BC(e,t){return OC(e,e=>({...e,body:t(e.body??{})}))}var FC={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 EC(e,t=!0){const n=D(e)??(t?vx(e):void 0);return n?FC[n]:void 0}function DC(e){return{documentStyles:()=>{const t=e.state().document,n=t?.styles??{},r=/* @__PURE__ */new Set;for(const e of Co(t)){e.style?.styleId&&r.add(e.style.styleId);for(const t of e.runs)t.styles?.styleId&&r.add(t.styles.styleId)}return Object.values(n).map(e=>{const o=go(e.id,n),a="table"===e.type?Na(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:EC(e,!t.sourcePackage),type:e.type,qFormat:e.qFormat,uiPriority:e.uiPriority,semiHidden:e.semiHidden,unhideWhenUsed:e.unhideWhenUsed,isUsed:r.has(e.id),fontFamily:o.fontFamily?.trim()||void 0,fontSize:"number"==typeof o.fontSize?o.fontSize:void 0,color:o.color??void 0,bold:o.bold??void 0,italic:o.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:()=>Sm(e.state()),openTableProperties:t=>e.openTablePropertiesDialog(t??"table"),exportDocx:()=>{e.docIO.handleExportDocx()},exportPdf:()=>{e.docIO.handleExportPdf()},printDocument:()=>{e.docIO.handlePrint()},importDocument:()=>e.importInputRef()?.click(),insertImage:()=>e.imageInputRef()?.click(),insertHtml:t=>e.applyTransactionalState(e=>function(e,t){if(!t.trim())return e;const n=br(t),r=_r(n)[0]?.blocks??[];if(0===r.length)return e;if(r.every(e=>"paragraph"===e.type))return Zu(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 o=ri(e.selection)?e:te(e),{paragraph:a,offset:i}=ae(o),s=sn(a,0,i),l=sn(a,i,Za(a)),c=Ma(""),d={...a,runs:s.length?s:Ma("").runs},u={...a,id:c.id,runs:l.length?l:c.runs},p=[...i>0?[d]:[],...r,...l.length||"table"===r[r.length-1]?.type?[u]:[]];let f=!1;const g=e=>{let t=!1;const n=e.flatMap(e=>{if("paragraph"===e.type&&e.id===a.id)return f=!0,t=!0,p;if("table"!==e.type)return[e];let n=!1;const r=e.rows.map(e=>{let t=!1;const r=e.cells.map(e=>{const n=g(e.blocks);return n===e.blocks?e:(t=!0,{...e,blocks:n})});return t?(n=!0,{...e,cells:r}):e});return n?(t=!0,[{...e,rows:r}]):[e]});return t?n:e},m=o.activeZone??"main";let h=o.document;if("footnote"===m&&o.activeFootnoteId&&o.document.footnotes?.items[o.activeFootnoteId]){const e=o.document.footnotes,t=e.items[o.activeFootnoteId],n=g(t.blocks);f&&(h={...o.document,footnotes:{...e,items:{...e.items,[o.activeFootnoteId]:{...t,blocks:n}}}})}else{const t=_r(o.document),n=Math.max(0,Math.min(o.activeSectionIndex??0,t.length-1)),r=t[n];if(!r)return e;const a="header"===m?"header":"footer"===m?"footer":"blocks",i=g(r[a]??[]);if(f){const e=[...t];e[n]={...r,[a]:i},h={...o.document,sections:e}}}if(!f)return e;const b=r[r.length-1],y="paragraph"!==b.type||l.length?Xo(u,0):Xo(b,Za(b));return{...o,document:h,selection:J(y)}}(e,t)),insertShape:t=>e.applyTransactionalState(e=>function(e,t){const n=ri(e.selection)?e:te(e),{paragraph:r,index:o,offset:a}=ae(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:[Ma("")],shape:{preset:t,fill:i.fill,borderColor:i.border,borderWidthPt:1},floating:fv(void 0,"front")},l=ko("",Qn(r,a),void 0,s),c=we(r,a,[l]),d=xi(n).map((e,t)=>t===o?c:eo(e));return Cn(n,d,J(Xo(c,a+1)))}(e,t)),setShapeFill:t=>e.applyTransactionalState(e=>function(e,t){return TC(e,e=>({...e,fill:t??void 0}))}(e,t),{mergeKey:tg}),setShapeOutline:t=>e.applyTransactionalState(e=>{return n=t,TC(e,e=>({...e,borderColor:n??void 0}));var n},{mergeKey:ng}),setShapeOutlineWidth:t=>e.applyTransactionalState(e=>function(e,t){return TC(e,e=>({...e,borderWidthPt:Math.max(0,t)}))}(e,t),{mergeKey:rg}),alignFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=Fi(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:r,run:o}=n,a=xi(e).map((e,n)=>n!==r?eo(e):{...eo(e),runs:e.runs.map(e=>e.id!==o.id?Ro(e):"image"===e.kind?{...e,image:{...e.image,floating:PC(e.image.floating,t)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:PC(e.textBox.floating,t)}}:Ro(e))});return Cn(e,a,H(a,sa(e)))}(e,t),{mergeKey:og}),reorderFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=Fi(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:r,run:o}=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=xi(e).map((e,t)=>t!==r?eo(e):{...eo(e),runs:e.runs.map(e=>e.id!==o.id?Ro(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)}}:Ro(e))});return Cn(e,i,H(i,sa(e)))}(e,t),{mergeKey:ag}),nudgeFloatingObject:(t,n)=>e.applyTransactionalState(e=>function(e,t,n){const r=Fi(e,e=>"image"===e.kind||"textBox"===e.kind);if(!r)return e;const{paragraphIndex:o,run:a}=r,i=xi(e).map((e,r)=>r!==o?eo(e):{...eo(e),runs:e.runs.map(e=>e.id!==a.id?Ro(e):"image"===e.kind?{...e,image:{...e.image,floating:RC(e.image.floating,t,n)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:RC(e.textBox.floating,t,n)}}:Ro(e))});return Cn(e,i,H(i,sa(e)))}(e,t,n),{mergeKey:ig}),setFloatingFixedPosition:t=>e.applyTransactionalState(e=>function(e,t){const n=Fi(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:r,run:o}=n,a=xi(e).map((e,n)=>n!==r?eo(e):{...eo(e),runs:e.runs.map(e=>{if(e.id!==o.id)return Ro(e);if("image"===e.kind){const n=e.image.floating;return{...e,image:{...e.image,floating:n?mv(n,t):n}}}if("textBox"===e.kind){const n=e.textBox.floating;return{...e,textBox:{...e.textBox,floating:n?mv(n,t):n}}}return Ro(e)})});return Cn(e,a,H(a,sa(e)))}(e,t),{mergeKey:sg}),setFloatingRotation:t=>e.applyTransactionalState(e=>MC(e,t),{mergeKey:lg}),setFloatingWrapPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=Fi(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const r=e=>fv(e,t),{paragraphIndex:o,run:a}=n,i=xi(e).map((e,t)=>t!==o?eo(e):{...eo(e),runs:e.runs.map(e=>{if(e.id!==a.id)return Ro(e);if("image"===e.kind){const t=r(e.image.floating),n=t?{...e.image,floating:t}:(()=>{const{floating:t,...n}=e.image;return n})();return{...e,image:n}}if("textBox"===e.kind){const t=r(e.textBox.floating),n=t?{...e.textBox,floating:t}:(()=>{const{floating:t,...n}=e.textBox;return n})();return{...e,textBox:n}}return Ro(e)})});return Cn(e,i,H(i,sa(e)))}(e,t),{mergeKey:cg}),setFloatingWrapText:t=>e.applyTransactionalState(e=>function(e,t){const n=Fi(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const r=e=>{if(!e)return e;if("bothSides"===t){const{wrapText:t,...n}=e;return n}return{...e,wrapText:t}},{paragraphIndex:o,run:a}=n,i=xi(e).map((e,t)=>t!==o?eo(e):{...eo(e),runs:e.runs.map(e=>e.id!==a.id?Ro(e):"image"===e.kind?{...e,image:{...e.image,floating:r(e.image.floating)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:r(e.textBox.floating)}}:Ro(e))});return Cn(e,i,H(i,sa(e)))}(e,t),{mergeKey:dg}),setFloatingPositionPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=Fi(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{h:r,v:o}=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:r,offset:0},i={relativeFrom:"margin",align:o,offset:0},{paragraphIndex:s,run:l}=n,c=xi(e).map((e,t)=>t!==s?eo(e):{...eo(e),runs:e.runs.map(e=>{if(e.id!==l.id)return Ro(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 Ro(e)})});return Cn(e,c,H(c,sa(e)))}(e,t),{mergeKey:ug}),setShapePreset:t=>e.applyTransactionalState(e=>function(e,t){return TC(e,e=>({...e,preset:t}))}(e,t),{mergeKey:pg}),setTextBoxTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n="horz"===t?"horz":"vert"===t?"vert":"vert270"===t?"vert270":"wordArtVert";return BC(e,e=>({...e,vert:n}))}(e,t),{mergeKey:fg}),setTextBoxVerticalAlign:t=>e.applyTransactionalState(e=>function(e,t){const n="b"===t?"b":"ctr"===t?"ctr":"t";return BC(e,e=>({...e,anchor:n}))}(e,t),{mergeKey:gg}),setTextBoxAlt:t=>e.applyTransactionalState(e=>function(e,t){return OC(e,e=>({...e,alt:t??void 0}))}(e,t),{mergeKey:mg}),rotateTextBox:t=>e.applyTransactionalState(e=>AC(e,t),{mergeKey:hg}),getTextBoxSizeCm:()=>function(e){const t=Px(e),n=t&&za(t.run);return n?{width:n.width/mi,height:n.height/mi}:null}(e.state()),isTextBoxSelected:()=>null!==Px(e.state()),setTextBoxWidthCm:t=>e.applyTransactionalState(e=>function(e,t){return OC(e,e=>({...e,width:Math.max(24,Math.round(t*mi))}))}(e,t),{mergeKey:bg}),setTextBoxHeightCm:t=>e.applyTransactionalState(e=>function(e,t){return OC(e,e=>({...e,height:Math.max(24,Math.round(t*mi))}))}(e,t),{mergeKey:yg})}}function LC(e){return{prompt:()=>e.commandsController.promptForLink(),remove:()=>e.commandsController.removeLinkCommand(),canPrompt:()=>!ri(e.state().selection)||Boolean(e.styleController.toolbarStyleState().link)}}function NC(e){return{promptAlt:()=>e.commandsController.promptForImageAlt(),promptCaption:()=>e.commandsController.promptForImageCaption(),isSelected:()=>Boolean(e.selectedImageRun()),getSizeCm:()=>function(e){const t=bv(e),n=t&&da(t.run);return n?{width:n.width/mi,height:n.height/mi}: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=bv(e);return(t&&da(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=bv(e);return(t&&da(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=bv(e),n=t&&da(t.run);return n?n.transparency??0:null}(e.state()),setTransparency:t=>e.commandsController.applyImageTransparencyCommand(t),reset:()=>e.commandsController.resetImageCommand(),canReset:()=>null!==bv(e.state())}}function zC(e){const t=e.clipboardActions??kp({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 $C(e,t){const n=Yo(e),r=Si(e.document);if("header"===n||"footer"===n){const o=ya(e),a=r[o];if(!a)return e;const i=e.activeHeaderFooterStory??"default",s=qr(a,n,i,t),l=[...r];return l[o]=s,{...e,document:{...e.document,sections:l}}}if("main"===n){const n=ya(e),o=r[n];if(!o)return e;const a=[...r];return a[n]={...o,blocks:t},{...e,document:{...e.document,sections:a}}}return e}function HC(e,t){return null!==WC(e,t)}function jC(e,t){const n=WC(e,t);if(!n)return e;const{nextBlocks:r}=n,o=$C(e,r),a=r.flatMap(Mo);return{...o,selection:UC(e.selection,a)}}function WC(e,t){const n=Yo(e);if("footnote"===n)return null;const r=di(e,n);if(0===r.length)return null;const o=sa(e),a=function(e,t,n,r){const o=/* @__PURE__ */new Set;for(let s=n;s<=r;s+=1){const e=t[s];if(void 0===e)return null;o.add(e)}if(0===o.size)return null;const a=Math.min(...o),i=Math.max(...o);for(let s=a;s<=i;s+=1)if("paragraph"!==e[s].type)return null;return{lo:a,hi:i}}(r,function(e){const t=[];return e.forEach((e,n)=>{Mo(e).forEach(()=>{t.push(n)})}),t}(r),o.startIndex,o.endIndex);if(!a)return null;const{lo:i,hi:s}=a,l=r.slice(i,s+1);let c;if("up"===t){if(0===i)return null;const e=r[i-1];if("paragraph"!==e.type)return null;c=[...r.slice(0,i-1),...l,e,...r.slice(s+1)]}else{if(s===r.length-1)return null;const e=r[s+1];if("paragraph"!==e.type)return null;c=[...r.slice(0,i),e,...l,...r.slice(s+2)]}return{nextBlocks:c}}function UC(e,t){const n=new Map(t.map((e,t)=>[e.id,t])),r=e=>{const r=n.get(e.paragraphId);if(void 0===r)return e;const o=t[r];return Xo(o,Math.min(e.offset,Za(o)))};return{anchor:r(e.anchor),focus:r(e.focus)}}function VC(e,t){const n=function(e){const t=Yo(e);if("footnote"===t)return null;const n=di(e,t);if(0===n.length)return null;const r=sa(e),o=/* @__PURE__ */new Set;for(let s=r.startIndex;s<=r.endIndex;s+=1){let e=0,t=-1;for(let r=0;r<n.length;r+=1){const o=Mo(n[r]).length;if(s<e+o){t=r;break}e+=o}if(t<0)return null;o.add(t)}if(0===o.size)return null;const a=Math.min(...o),i=Math.max(...o);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:r,hi:o,blocks:a}=n,i=a.slice(r,o+1).map((e,t)=>({block:e,index:t,key:_C(po(e))}));i.sort((e,n)=>{const r=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!==r?t?-r:r:e.index-n.index});const s=[...a.slice(0,r),...i.map(e=>e.block),...a.slice(o+1)],l=$C(e,s),c=s.flatMap(Mo);return{...l,selection:KC(e.selection,c)}}function _C(e){const t=e.trim(),n=/^(\d+(?:\.\d+)?)/.exec(t)?.[1];return{num:void 0===n?void 0:Number(n),text:e}}function KC(e,t){const n=new Map(t.map((e,t)=>[e.id,t])),r=e=>{const r=n.get(e.paragraphId);if(void 0===r)return e;const o=t[r];return Xo(o,Math.min(e.offset,Za(o)))};return{anchor:r(e.anchor),focus:r(e.focus)}}function qC(e,t){const n=sa(e),r=xi(e);let a=1;for(let l=0;l<n.startIndex;l+=1){const e=o(r[l]?.style?.styleId);null!==e&&(a=e)}let i=!1;const s=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return eo(e);const s=o(e.style?.styleId);if(e.list&&e.list.kind){const n=e.list.level??0,r=t?Math.max(0,n-1):Math.min(8,n+1);return r===n?eo(e):(i=!0,N(e,r))}if(null!==s){const n=t?Math.max(1,s-1):Math.min(9,s+1);if(n===s)return eo(e);i=!0;const r=eo(e);return r.style={...e.style??{},styleId:`heading${n}`,outlineLevel:void 0},r}if(!t)return eo(e);i=!0;const l=eo(e);return l.style={...e.style??{},styleId:`heading${a}`,outlineLevel:void 0},l});return i?Cn(e,s,H(s,n)):e}var XC=["align","spacingBefore","spacingAfter","lineHeight","lineRule","indentLeft","indentRight","indentFirstLine","indentHanging","mirrorIndents","contextualSpacing","outlineLevel","shading","borderTop","borderRight","borderBottom","borderLeft","tabs","pageBreakBefore","keepWithNext","keepLinesTogether","widowControl","bidi"];var GC=/* @__PURE__ */new Set(["auto","exact","atLeast"]);var YC=/* @__PURE__ */new Set(["lrTb","tbRl","btLr","lrTbV","tbRlV"]);var ZC={width:1.5,type:"solid",color:"#000000"};function JC(e,t){const n=t.text??po(e).slice(0,1),r=Math.max(1,Math.min(10,Math.round(t.lines??3))),o=e.runs[0]?.styles,a=t.font;return{text:n,lines:r,type:"margin"===t.type?"margin":"drop",style:void 0!==a?{...o??{},fontFamily:a}:o}}function QC(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=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.lineRule,i=(()=>{if(null!==t&&"auto"!==t)return GC.has(t)?t:a})();if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.textDirection,i=null===t||"lrTb"===t?void 0:YC.has(t)?t:a;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setSuppressAutoHyphens:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.suppressAutoHyphens,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setSuppressLineNumbers:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.suppressLineNumbers,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setKinsoku:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.kinsoku,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setOverflowPunct:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.overflowPunct,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setWordWrap:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.wordWrap,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setAutoSpaceDE:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.autoSpaceDE,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setAutoSpaceDN:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.autoSpaceDN,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setAdjustRightInd:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.adjustRightInd,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setTopLinePunct:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.topLinePunct,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setPageBreakBefore:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.pageBreakBefore,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setKeepWithNext:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.keepWithNext,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setKeepLinesTogether:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.keepLinesTogether,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setWidowControl:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.widowControl,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setContextualSpacing:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.contextualSpacing,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(a,n)):e}(e,t)),setMirrorIndents:t=>e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e);let o=!1;const a=r.map((e,r)=>{if(r<n.startIndex||r>n.endIndex)return e;const a=e.style?.mirrorIndents,i=null===t?void 0:t;if(a===i)return e;o=!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{...eo(e),style:s}});return o?Cn(e,a,H(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 r=n??48;e.applyTransactionalState(e=>{let n=ce(e,"indentFirstLine",null);return n=ce(n,"indentHanging",null),"firstLine"===t?n=ce(n,"indentFirstLine",r):"hanging"===t&&(n=ce(n,"indentHanging",r)),n},{mergeKey:pf}),e.focusInput()},setShading:t=>e.commandsController.applyParagraphStyleCommand("shading",t),applyBorders:()=>{const t={width:1,type:"solid",color:"#000000"};e.applyTransactionalState(e=>{let n=ce(e,"borderTop",t);return n=ce(n,"borderRight",t),n=ce(n,"borderBottom",t),n=ce(n,"borderLeft",t),n},{mergeKey:ff}),e.focusInput()},addHorizontalLine:()=>{e.applyTransactionalState(e=>ce(e,"borderBottom",ZC),{mergeKey:ff}),e.focusInput()},setLineHeight:t=>e.commandsController.applyParagraphStyleCommand("lineHeight",t),setListFormat:t=>e.commandsController.handleListFormatChange(t),setListStartAt:t=>e.commandsController.handleListStartAtChange(t),restartList:t=>{e.applyTransactionalState(e=>function(e,t=1){return SS(e,t)}(e,t)),e.focusInput()},continueList:()=>{e.applyTransactionalState(IS),e.focusInput()},setListLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=Math.min(8,Math.max(0,Math.round(t))),o=xi(e);let a=!1;const i=o.map((e,t)=>t<n.startIndex||t>n.endIndex?e:e.list?(e.list.level??0)===r?e:(a=!0,N(e,r)):e);return a?Cn(e,i,H(i,n)):e}(e,t)),e.focusInput()},outdent:()=>{e.clearPreferredColumn(),e.resetTransactionGrouping(),e.tableOps.applySelectionAwareParagraphCommand(e=>AS(e,-1)),e.focusInput()},indent:()=>{e.clearPreferredColumn(),e.resetTransactionGrouping(),e.tableOps.applySelectionAwareParagraphCommand(e=>AS(e,1)),e.focusInput()},moveParagraphsUp:()=>{HC(e.state(),"up")?(e.applyTransactionalState(e=>jC(e,"up"),{mergeKey:gf}),e.focusInput()):e.focusInput()},moveParagraphsDown:()=>{HC(e.state(),"down")?(e.applyTransactionalState(e=>jC(e,"down"),{mergeKey:mf}),e.focusInput()):e.focusInput()},canMoveParagraphsUp:()=>HC(e.state(),"up"),canMoveParagraphsDown:()=>HC(e.state(),"down"),promote:()=>{e.applyTransactionalState(e=>qC(e,!0)),e.focusInput()},demote:()=>{e.applyTransactionalState(e=>qC(e,!1)),e.focusInput()},resetParagraphFormatting:()=>{e.applyTransactionalState(e=>function(e){const t=sa(e),n=xi(e);let r=!1;const o=n.map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return e;const o=e.style;if(!o||XC.every(e=>!(e in o)))return e;r=!0;const a=eo(e),i=o.styleId?{styleId:o.styleId}:{};return a.style=Object.keys(i).length>0?i:void 0,a});return r?Cn(e,o,H(o,t)):e}(e)),e.focusInput()},setTabStops:t=>{e.resetTransactionGrouping(),e.applyTransactionalState(e=>Wn(e,t),{mergeKey:vf}),e.focusInput()},setOutlineLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=sa(e),r=xi(e),o=null==t?null:Math.min(8,Math.max(0,Math.round(t)));let a=!1;const i=r.map((e,t)=>{if(t<n.startIndex||t>n.endIndex)return e;if((e.style?.outlineLevel??null)===o)return e;a=!0;const r={...e.style??{}};null===o?delete r.outlineLevel:r.outlineLevel=o;const i=eo(e);return i.style=Object.keys(r).length>0?r:void 0,i});return a?Cn(e,i,H(i,n)):e}(e,t)),e.focusInput()},setBidi:t=>e.commandsController.applyParagraphStyleCommand("bidi",t),setParagraphAlign:t=>{e.applyTransactionalState(e=>function(e,t){return ce(e,"align",t)}(e,t))},sortParagraphs:(t=!1)=>e.applyTransactionalState(e=>VC(e,t)),hasDropCap:()=>function(e){const t=sa(e);return xi(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=sa(e),r=xi(e),o=n.startIndex,a=n.endIndex,i="none"===t.type||0===t.lines||void 0!==t.text&&0===t.text.length,s=r.map((e,n)=>n<o||n>a?eo(e):i?{...eo(e),dropCap:void 0}:{...eo(e),dropCap:JC(e,{...t,type:"margin"===t.type?"margin":"drop"})});return Cn(e,s,H(s,n))}(e,t)),e.focusInput()}}}function ek(e){const t=Si(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(ya(e),t.length-1))}}function tk(e,t){const{sections:n,sectionIndex:r}=ek(e);if(0===n.length)return e;const o=t(n[r]);if(o===n[r])return e;const a=[...n];return a[r]=o,{...e,document:{...e.document,sections:a}}}function nk(e,t,n="default"){const r=yi(t,n);return tk(e,e=>e[r]?e:{...e,[r]:[Ci(t)]})}function rk(e,t,n="default"){const r=yi(t,n),o=tk(e,e=>e[r]?{...e,[r]:void 0}:e);return o===e?e:Yo(o)===t?sk(o):o}function ok(e,t,n="default"){const r=nk(e,t,n),{sections:o,sectionIndex:a}=ek(r),i=(o[a][yi(t,n)]??[]).flatMap(Mo).find(Boolean);return i?{...r,selection:ea(Xo(i,0)),activeSectionIndex:a,activeZone:t,activeHeaderFooterStory:n}:r}function ak(e){const{sections:t,sectionIndex:n}=ek(e),r=t[n];return Boolean(r&&(r.firstPageHeader||r.firstPageFooter))}function ik(e){const{sections:t,sectionIndex:n}=ek(e),r=t[n];return Boolean(r&&(r.evenPageHeader||r.evenPageFooter))}function sk(e){const{sections:t,sectionIndex:n}=ek(e),r=(t[n]?.blocks??[]).flatMap(Mo).find(Boolean);return r?{...e,selection:ea(Xo(r,0)),activeSectionIndex:n,activeZone:"main",activeHeaderFooterStory:void 0}:{...e,activeZone:"main",activeHeaderFooterStory:void 0}}function lk(e){return function(e,t){const n=ri(e.selection)?e:te(e),{paragraph:r,index:o,offset:a}=ae(n),i=sn(r,0,a),s=sn(r,a,Za(r)),l={id:`run:field:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:{type:t},styles:Qn(r,a)},c=u(r,[...i,l,...s]),d=xi(n),p=[...ho(d.slice(0,o)),c,...ho(d.slice(o+1))];return Cn(n,p,J(Xo(c,a+l.text.length)))}(e,"PAGE")}function ck(e,t,n,r){return{id:n,text:"1",kind:"field",field:r&&"decimal"!==r?{type:e,format:r}:{type:e},styles:t}}function dk(e,t){const n=Math.random().toString(36).slice(2,9);return"xOfY"===e?[{id:`run:page-of-prefix:${n}`,text:"Page ",kind:"text"},ck("PAGE",void 0,`run:page-field:${n}`,t),{id:`run:page-of-separator:${n}`,text:" of ",kind:"text"},ck("NUMPAGES",void 0,`run:numpages-field:${n}`,t)]:[ck("PAGE",void 0,`run:page-field:${n}`,t)]}function uk(e,t="page",n){return function(e,t){const n=ri(e.selection)?e:te(e),{paragraph:r,index:o,offset:a}=ae(n),i=Qn(r,a),s=t.map((e,t)=>e.styles?e:{...e,styles:i,id:`${e.id}:${t}`}),l=u(r,[...sn(r,0,a),...s,...sn(r,a,Za(r))]),c=xi(n),d=[...ho(c.slice(0,o)),l,...ho(c.slice(o+1))],p=s.reduce((e,t)=>e+t.text.length,0);return Cn(n,d,J(Xo(l,a+p)))}(e,dk(t,n))}function pk(e){const t=Si(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(ya(e),t.length-1))}}function fk(e,t,n={}){const{kind:r="page",format:o,align:a="center"}=n;if("current"===t)return uk(e,r,o);const i="top"===t?"header":"footer",s=yi(i,"default"),{sections:l,sectionIndex:c}=pk(e);if(0===l.length)return e;const d={id:Ur("paragraph"),type:"paragraph",runs:dk(r,o),style:{styleId:i,align:a}},u={...l[c],[s]:[d]},p=[...l];return p[c]=u,{...e,document:{...e.document,sections:p},selection:ea(Xo(d,0)),activeSectionIndex:c,activeZone:i}}function gk(e){const t={isLandscape:()=>{const t=ya(e.state());return"landscape"===(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.orientation},setOrientation:t=>{const n=ya(e.state()),r=e.state().document.sections?.[n]??e.state().document;r&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...r.pageSettings,orientation:t}})},toggleOrientation:()=>{const n=ya(e.state()),r=e.state().document.sections?.[n]??e.state().document;if(!r)return;const o=r.pageSettings?.orientation??"portrait";t.setOrientation("portrait"===o?"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=ya(e.state());return(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.margins},setPageMargins:t=>{const n=ya(e.state()),r=e.state().document.sections?.[n]??e.state().document;r?.pageSettings&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...r.pageSettings,margins:{...r.pageSettings.margins,...t}}})},setMarginsPreset:t=>{e.applyTransactionalState(e=>bt(e,t)),e.focusInput()},getPageNumbering:()=>{const t=ya(e.state());return e.state().document.sections?.[t]?.pageNumbering},setPageNumbering:t=>{e.applyTransactionalState(e=>function(e,t){const{sections:n,sectionIndex:r}=pk(e);if(0===n.length)return e;const o={...n[r].pageNumbering,...void 0!==t.start?{start:t.start}:{},...void 0!==t.format?{format:t.format}:{}};return i(e,r,{pageNumbering:o})}(e,t)),e.focusInput()},getPaperSize:()=>In(e.state()),setPaperSize:t=>{e.applyTransactionalState(e=>Tr(e,t)),e.focusInput()},setPaperSizePreset:t=>{e.applyTransactionalState(e=>Ce(e,t)),e.focusInput()},getColumns:()=>$n(e.state()),setColumns:t=>{e.applyTransactionalState(e=>Or(e,t)),e.focusInput()},getVerticalAlign:()=>at(e.state()),setVerticalAlign:t=>{e.applyTransactionalState(e=>g(e,t)),e.focusInput()},getSectionStart:()=>{const t=ya(e.state());return e.state().document.sections?.[t]?.breakType},setSectionStart:t=>{const n=ya(e.state());(e.state().document.sections?.[n]??e.state().document)&&e.commandsController.applyUpdateSectionSettingsCommand(n,{breakType:t})},getBidi:()=>Vt(e.state()),setBidi:t=>{e.applyTransactionalState(e=>hr(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,r={...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:r}}}(e,t)),e.focusInput()}};return t}function mk(e){const t=t=>{e.applyTransactionalState(t),e.focusInput()};return{editHeader:()=>t(e=>ok(e,"header")),editFooter:()=>t(e=>ok(e,"footer")),editFirstPageHeader:()=>t(e=>ok(e,"header","firstPage")),editEvenPageHeader:()=>t(e=>ok(e,"header","evenPage")),editFirstPageFooter:()=>t(e=>ok(e,"footer","firstPage")),editEvenPageFooter:()=>t(e=>ok(e,"footer","evenPage")),insertPageNumber:()=>t(e=>lk(e)),insertPageNumberXOfY:()=>t(e=>uk(e,"xOfY")),placePageNumberTop:()=>t(e=>fk(e,"top")),placePageNumberBottom:()=>t(e=>fk(e,"bottom")),exit:()=>t(e=>function(e){return sk(e)}(e)),isInHeaderFooter:()=>{const t=e.state().activeZone;return"header"===t||"footer"===t},getDifferentFirstPage:()=>ak(e.state()),setDifferentFirstPage:e=>t(t=>function(e,t){if(ak(e)===t)return e;let n=e;return t?(n=nk(n,"header","firstPage"),n=nk(n,"footer","firstPage"),n):(n=rk(n,"header","firstPage"),rk(n,"footer","firstPage"))}(t,e)),getDifferentOddEven:()=>ik(e.state()),setDifferentOddEven:e=>t(t=>function(e,t){if(ik(e)===t)return e;let n=e;return t?(n=nk(n,"header","evenPage"),n=nk(n,"footer","evenPage"),n):(n=rk(n,"header","evenPage"),rk(n,"footer","evenPage"))}(t,e))}}function hk(e){const t=e.document.bookmarks;return t?t.order.map(e=>t.items[e]).filter(e=>Boolean(e)):[]}function bk(e){return{insert:t=>{e.applyTransactionalState(e=>function(e,t){const{start:n,end:r,isCollapsed:o}=sa(e),a=e.document.bookmarks,i=a?.order??[],s=t&&t.trim().length>0?t.trim():`Bookmark${i.length+1}`,l={id:Zr(),name:s,start:{paragraphId:n.paragraphId,offset:n.offset},...o?{}:{end:{paragraphId:r.paragraphId,offset:r.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 r={...n.items};delete r[t];const o={items:r,order:n.order.filter(e=>e!==t)};return{...e,document:{...e.document,bookmarks:o}}}(e,t)),e.focusInput()},list:()=>hk(e.state()).map(e=>({id:e.id,name:e.name}))}}var yk=["January","February","March","April","May","June","July","August","September","October","November","December"],vk=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function xk(e,t){let n="";const r=e=>String(e).padStart(2,"0");let o=0;const a=t;for(;o<a.length;){const t=a[o];let i=t;for(;o+i.length<a.length&&a[o+i.length]===t;)i+=t;const s=e.getHours();switch(t){case"d":n+=i.length>=4?vk[e.getDay()]:3===i.length?vk[e.getDay()].slice(0,3):2===i.length?r(e.getDate()):String(e.getDate());break;case"M":n+=i.length>=4?yk[e.getMonth()]:3===i.length?yk[e.getMonth()].slice(0,3):2===i.length?r(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+=r(s);break;case"h":n+=i.length>=2?r(s%12==0?12:s%12):String(s%12==0?12:s%12);break;case"m":n+=i.length>=2?r(e.getMinutes()):String(e.getMinutes());break;case"s":n+=i.length>=2?r(e.getSeconds()):String(e.getSeconds());break;default:if(a.slice(o).toLowerCase().startsWith("am/pm")){n+=s<12?"am":"pm",o+=5;continue}n+=t}o+=i.length}return n}var wk=e=>f(e,void 0,void 0,void 0,{cachedBodyPageFields:!0});function Ik(e,t){const n=t.get(e.paragraphId);if(!n)return e;let r=0;for(const o of n.edits){if(e.offset<=o.start)break;if(e.offset<o.end)throw Error("interior anchor must be rejected before mapping");r+=o.text.length-(o.end-o.start)}return r?{...e,offset:e.offset+r}:e}function Sk(e,t){if(!e)return e;let n=!1;const r={...e.items};for(const[o,a]of Object.entries(r)){const e=a.start?Ik(a.start,t):void 0,i=a.end?Ik(a.end,t):void 0;e===a.start&&i===a.end||(r[o]={...a,start:e,end:i},n=!0)}return n?{...e,items:r}:e}function Ck(e,t,n){const r=t.get(e.paragraphId)?.edits.find(t=>t.runId===e.runId);if(!r)return e;const o=e.offset===r.end-r.start?r.text.length:"selection"===n?Math.min(e.offset,r.text.length):e.offset;return o===e.offset?e:{...e,offset:o}}function kk(e){return!e.list&&!e.dropCap&&!e.sdtWrappers?.length&&!e.numberingRevision&&!e.style?.bidi&&(!e.style?.textDirection||"lrTb"===e.style.textDirection)&&e.runs.every($)&&new Set(e.runs.map(e=>e.id)).size===e.runs.length}function Tk(e){const t=/* @__PURE__ */new Map;for(const n of[e.document.bookmarks,e.document.comments])for(const e of Object.values(n?.items??{}))for(const n of[e.start,e.end]){if(!n)continue;const e=t.get(n.paragraphId)??[];e.push(n.offset),t.set(n.paragraphId,e)}return t}function Pk(e,t=wk,n="all",r){const o=r||e.document.coreTimestamps?{...e.document.coreTimestamps,...r}:void 0,a=t(e.document),i=(t,n)=>({state:e,layout:a,status:t,passes:n,updatedFields:0}),s=Si(e.document),l=s.flatMap(e=>e.blocks);if(e.trackChangesEnabled||"main"!==Yo(e)||Object.keys(e.document.footnotes?.items??{}).length||Object.keys(e.document.endnotes?.items??{}).length||s.some((e,t)=>t>0&&e.breakType&&"nextPage"!==e.breakType)||l.some(e=>"paragraph"!==e.type)||new Set(l.map(e=>e.id)).size!==l.length)return i("unsupported",0);let c=/* @__PURE__ */new Map;if($e(l,c),"selection"===n&&(c=function(e,t,n){const r=e=>{const n=t.findIndex(t=>t.id===e.paragraphId);if(n<0)return;const r=t[n],o=r.runs.findIndex(t=>t.id===e.runId);return o<0||!Number.isInteger(e.offset)||e.offset<0||e.offset>r.runs[o].text.length?void 0:{index:n,runIndex:o,offset:r.runs.slice(0,o).reduce((e,t)=>e+t.text.length,0)+e.offset,affinity:e.fieldBoundaryAffinity}},o=r(e.selection.anchor),a=r(e.selection.focus),i=/* @__PURE__ */new Map;if(!o||!a)return i;const[s,l]=o.index<a.index||o.index===a.index&&o.offset<=a.offset?[o,a]:[a,o],c=s.index===l.index&&s.offset===l.offset;if(c&&(o.runIndex!==a.runIndex||o.affinity!==a.affinity))return i;for(let d=s.index;d<=l.index;d++){const e=t[d],r=n.get(e.id);if(!r)continue;let o=0;const a=e.runs.map(e=>{const t=o;return o+=e.text.length,t}),u=r.filter(t=>{const n=a[t.runIndex],r=n+e.runs[t.runIndex].text.length;return n!==r&&(c?!("before-markers"===s.affinity&&s.offset===n||"after-markers"===s.affinity&&s.offset===r)&&(s.offset>n&&s.offset<r||s.runIndex===t.runIndex&&s.offset>=n&&s.offset<=r):n<(d===l.index?l.offset:o)&&r>(d===s.index?s.offset:0))});u.length&&i.set(e.id,u)}return i}(e,l,c)),!c.size)return i("unchanged",0);const d=ci(e.document);let u=e,p=a;const f=/* @__PURE__ */new Set,g=/* @__PURE__ */new Set;for(let m=1;m<=6;m++){const r=Y(u.document,p),a=Le(u.document,p),s=Si(u.document),l=Tk(u),h=/* @__PURE__ */new Map,b=/* @__PURE__ */new Map;for(const e of p.pages)for(const t of e.blocks){if("paragraph"!==t.sourceBlock.type||!t.layout)continue;const n=t.sourceBlock.id,r=t.layout.startOffset??0,o=t.layout.endOffset??r+t.layout.text.length;r!==(b.get(n)??0)||o<r||o-r!==t.layout.text.length||o>Za(t.sourceBlock)?h.set(n,null):(b.set(n,o),h.has(n)?h.get(n)!==e.index&&h.set(n,null):h.set(n,e.index))}const y=/* @__PURE__ */new Map,v=/* @__PURE__ */new Set,x=[];for(const e of s)for(const t of e.blocks){if("paragraph"!==t.type||!kk(t))continue;const i=c.get(t.id),p=h.get(t.id);if(!i||null==p||b.get(t.id)!==Za(t))continue;const g=r.forPage(p),m=[];let w=0;for(const e of t.runs)m.push(w),w+=e.text.length;for(const{runIndex:r,field:c}of i){const i=t.runs[r],h=JSON.stringify([t.id,r]);if(x.push(JSON.stringify([h,i.text,p])),"PAGE"===c.type&&!c.format&&e.pageNumbering?.format&&"decimal"!==e.pageNumbering.format)continue;if("PAGEREF"===c.type&&s.some(e=>e.pageNumbering?.format&&"decimal"!==e.pageNumbering.format))continue;const b=i.styles?.language?.value?.toLowerCase(),I="pt-br"===b?"pt-BR":b?.startsWith("en")?"en-US":o?.locale,S=Ta(c,{...g,styleRefText:(e,n,o)=>a.forBody(t.id,e,n,{output:o,offset:m[r],locale:"pt-BR"===I?"pt-BR":"en-US"}),sequenceValue:d.get(vi(t.id,r)),documentVariables:u.document.documentVariables,documentProperties:u.document.documentProperties,temporal:o?{...o,locale:I}:void 0},i.text),C=m[r],k=C+i.text.length;if("resolved"!==S.status||!S.text.length||S.text.length>65536||!i.text.length||/[\r\n\t]/.test(S.text)||Array.from(S.text).length!==S.text.length)continue;if(S.text!==i.text&&((l.get(t.id)??[]).some(e=>!Number.isInteger(e)||e<0||e>w||e>C&&e<k)||"all"===n&&[u.selection.anchor,u.selection.focus].some(e=>e.paragraphId===t.id&&e.runId===i.id&&0!==e.offset&&e.offset!==i.text.length)))continue;if(v.add(h),S.text===i.text)continue;const T=y.get(t.id)??{paragraph:t,edits:[]};T.edits.push({runIndex:r,runId:i.id,start:C,end:k,text:S.text}),y.set(t.id,T),f.add(h)}}if([...f].some(e=>!v.has(e)))return i("nonconvergent",m);if(!y.size)return{state:u,layout:p,status:u===e?"unchanged":"updated",passes:m,updatedFields:f.size};const w=JSON.stringify([p.pages.length,x]);if(g.has(w))return i("nonconvergent",m);g.add(w);for(const e of y.values())e.edits.sort((e,t)=>e.start-t.start);const I={...u.document,sections:s.map(e=>({...e,blocks:e.blocks.map(e=>{const t=y.get(e.id);if("paragraph"!==e.type||!t)return e;const n=new Map(t.edits.map(e=>[e.runIndex,e.text]));return{...e,runs:e.runs.map((e,t)=>n.has(t)?{...e,text:n.get(t)}:e)}})})),bookmarks:Sk(u.document.bookmarks,y),comments:Sk(u.document.comments,y)};u={...u,document:I,selection:{anchor:Ck(u.selection.anchor,y,n),focus:Ck(u.selection.focus,y,n)}},p=t(I)}return i("nonconvergent",6)}var Rk=(e,t)=>e.length<=t&&!!e.trim()&&!/[\u0000-\u001f\u007f]/.test(e);function Mk(e){const t=oo(e);if(t.error||"XE"!==t.command)return;const[n,...r]=t.tokens.slice(1);if("quoted"!==n?.kind||!Rk(n.value,4096)||n.value.includes("\\"))return;const o=n.value.split(":");if(o.length>9||o.some(e=>!Rk(e,1024)))return;let a,i=!1,s=!1,l={kind:"page"};const c=/* @__PURE__ */new Set;for(let d=0;d<r.length;d++){const e=r[d];if("switch"!==e.kind)return;const t=e.value.toLowerCase();if(c.has(t))return;if(c.add(t),"b"===t){i=!0;continue}if("i"===t){s=!0;continue}if("f"!==t&&"r"!==t&&"t"!==t)return;const n=r[++d];if(!n||"switch"===n.kind)return;if("f"!==t){if("page"!==l.kind)return;if("r"===t){if(!/^[A-Za-z_][A-Za-z0-9_]{0,39}$/.test(n.value))return;l={kind:"bookmarkRange",bookmark:n.value}}else{if("quoted"!==n.kind||!Rk(n.value,4096))return;l={kind:"crossReference",text:n.value}}}else{if(!/^[A-Za-z]$/.test(n.value))return;a=n.value}}return"crossReference"!==l.kind||!i&&!s?{path:o,...void 0===a?{}:{identifier:a},boldPage:i,italicPage:s,reference:l}:void 0}function Ak(e){const t=[],n=/* @__PURE__ */new Set;for(const[r,o]of Si(e).entries()){const e=[];for(const t of o.blocks){if("paragraph"!==t.type||n.has(t.id)||t.runs.some(e=>"textBox"===e.kind||"opaque"===e.kind))return;n.add(t.id),e.push(t)}const a=Wo(e);if(a.diagnostics.length)return;for(const n of a.spans){const o=n.code.map(e=>"instruction"===e.kind?e.raw:"").join("");if("XE"!==oo(o).command&&!/^\s*XE(?=\s|\\|"|$)/i.test(o))continue;const a=Mk(o);if(!a||null!==n.parentIndex||!n.end||n.separator||n.begin.paragraphIndex!==n.end.paragraphIndex||n.beginMarker.fieldLock||n.beginMarker.dirty||n.code.some(e=>"instruction"!==e.kind)||n.result.length)return;const i=e[n.begin.paragraphIndex];if(i.sdtWrappers?.length||i.numberingRevision||i.dropCap||new Set(i.runs.map(e=>e.id)).size!==i.runs.length||i.runs.slice(n.begin.runIndex,n.end.runIndex+1).some(e=>e.text.length||e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.link||"fieldChar"!==e.kind&&"fieldInstruction"!==e.kind))return;if(t.push({...a,sectionIndex:r,paragraphId:i.id,runId:n.begin.runId,offset:n.begin.offset,raw:o}),t.length>4096)return}}return t}function Ok(e,t,n,r=Y(e,t)){if("page"!==n.reference.kind)return;const o=r.pageIndexAt(n.paragraphId,n.offset);if(void 0===o)return;const a=r.forPage(o);if(a.sectionNumber!==n.sectionIndex+1||void 0===a.pageNumber)return;const i=Si(e)[n.sectionIndex];if(!i)return;const s=mo(a.pageNumber,i.pageNumbering?.format);return void 0===s?void 0:{physicalPageIndex:o,label:String(s)}}function Bk(e,t,n,r=Y(e,t)){const o=e.bookmarks;if(!o||new Set(o.order).size!==o.order.length||o.order.length!==Object.keys(o.items).length||o.order.some(e=>o.items[e]?.id!==e))return;const a=Object.values(o.items).filter(e=>e.name.toLowerCase()===n.toLowerCase()),i=a[0];if(1!==a.length||!i||i.name!==n||!i.start||!i.end||void 0!==i.colFirst||void 0!==i.colLast)return;const s=Si(e),l=[],c=/* @__PURE__ */new Map;for(const[h,b]of s.entries())for(const e of b.blocks){if("paragraph"!==e.type||c.has(e.id))return;c.set(e.id,l.length),l.push({p:e,sectionIndex:h})}const d=c.get(i.start.paragraphId),u=c.get(i.end.paragraphId);if(void 0===d||void 0===u||d>u)return;const p=(e,t)=>Number.isSafeInteger(t)&&t>=0&&t<=Za(l[e].p);if(!p(d,i.start.offset)||!p(u,i.end.offset)||d===u&&i.start.offset>=i.end.offset)return;let f,g;for(let h=d;h<=u;h++){const{p:e,sectionIndex:t}=l[h],n=h===d?i.start.offset:0,o=h===u?i.end.offset:Za(e);if(o<=n)continue;if(e.sdtWrappers?.length||e.numberingRevision||e.dropCap||e.runs.some(e=>e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.text.length>0&&("text"!==e.kind||e.styles?.hidden)))return;const a=r.pageIndexAt(e.id,n),s=r.pageIndexAt(e.id,o-1);if(void 0===a||void 0===s||a>s||r.forPage(a).sectionNumber!==t+1||r.forPage(s).sectionNumber!==t+1||void 0!==g&&a<g)return;f??=a,g=s}if(void 0===f||void 0===g||g-f>=4096)return;const m=[];for(let h=f;h<=g;h++){const e=r.forPage(h);if(void 0===e.sectionNumber||void 0===e.pageNumber)return;const t=e.sectionNumber-1,n=s[t];if(!n)return;const o=mo(e.pageNumber,n.pageNumbering?.format);if(void 0===o)return;m.push({physicalPageIndex:h,sectionIndex:t,label:String(o)})}return m}function Fk(e,t,n,r){const o=function(e,t){const n=e.bookmarks;if(!n)return;const r=Object.values(n.items).filter(e=>e.name===t);return 1===r.length?r[0]:void 0}(e,t);if(!o?.start||!o.end||void 0!==o.colFirst||void 0!==o.colLast)return;const a=Si(e),i=/* @__PURE__ */new Map;let s=0;for(const m of a)for(const e of m.blocks){if("paragraph"!==e.type)return;i.set(e.id,s++)}const l=i.get(o.start.paragraphId),c=i.get(o.end.paragraphId),d=i.get(n);if(void 0===l||void 0===c||void 0===d||l>c)return;const u=a.flatMap(e=>e.blocks),p=u.find(e=>e.id===o.start.paragraphId),f=u.find(e=>e.id===o.end.paragraphId),g=u.find(e=>e.id===n);return"paragraph"!==p?.type||"paragraph"!==f?.type||"paragraph"!==g?.type||!Number.isSafeInteger(o.start.offset)||o.start.offset<0||o.start.offset>Za(p)||!Number.isSafeInteger(o.end.offset)||o.end.offset<0||o.end.offset>Za(f)||l===c&&o.start.offset>=o.end.offset?void 0:!(d<l||d>c)&&(!(d===l&&r<o.start.offset)&&(!(d===c&&r>=o.end.offset)&&!(d!==c&&r>Za(g))))}var Ek={1033:"en-US",2057:"en-GB",1046:"pt-BR",2070:"pt-PT",1034:"es-ES",1036:"fr-FR",1031:"de-DE"};function Dk(e){if(/^[A-Za-z]{2,3}(?:-[A-Za-z]{2})?$/.test(e))try{const t=Intl.getCanonicalLocales(e)[0];return t&&Intl.Collator.supportedLocalesOf([t]).length?t:void 0}catch{return}}function Lk(e){const t=oo(e);if(t.error||"INDEX"!==t.command)return;const n={entrySeparator:", ",pageSeparator:", ",crossReferenceSeparator:". "},r=t.tokens.slice(1),o=/* @__PURE__ */new Set;for(let a=0;a<r.length;a++){const e=r[a];if("switch"!==e.kind)return;const t=e.value.toLowerCase();if(o.has(t))return;if(o.add(t),"r"===t||"y"===t){"r"===t?n.runIn=!0:n.yomi=!0;continue}const i=r[++a];if(!i||"switch"===i.kind)return;if("f"===t){if(!/^[A-Za-z]$/.test(i.value))return;n.identifier=i.value}else if("z"===t){const e=Dk(Ek[i.value]??i.value);if(!e)return;n.locale=e}else if("c"===t){const e=Number(i.value);if(!Number.isInteger(e)||e<1||e>4)return;1!==e&&(n.columns=e)}else if("b"===t||"s"===t){if(!/^[A-Za-z_][A-Za-z0-9_]{0,39}$/.test(i.value))return;"s"===t?n.seqIdentifier=i.value:n.bookmark=i.value}else if("h"===t){if("quoted"!==i.kind||!i.value||i.value.length>128||[...i.value].some(e=>e.charCodeAt(0)<32||127===e.charCodeAt(0)))return;n.heading=i.value}else if("p"===t){if("!"!==i.value&&!/^[A-Za-z]-[A-Za-z]$/.test(i.value))return;if("!"!==i.value&&i.value.charCodeAt(0)>i.value.charCodeAt(2))return;n.letterRange=i.value.toLowerCase()}else{if("e"!==t&&"l"!==t&&"k"!==t&&"g"!==t&&"d"!==t)return;if("quoted"!==i.kind||i.value.length>15||[...i.value].some(e=>e.charCodeAt(0)<32||127===e.charCodeAt(0)))return;"e"===t?n.entrySeparator=i.value:"l"===t?n.pageSeparator=i.value:"g"===t?n.rangeSeparator=i.value:"d"===t?n.seqSeparator=i.value:n.crossReferenceSeparator=i.value}}return n}function Nk(e,t,n,r){const o=Lk(n);if(!o)return;const a=o.locale??(r?Dk(r):void 0);if(!a)return;const i=Ak(e);if(!i)return;let s=i;if(o.bookmark){s=[];for(const t of i){const n=Fk(e,o.bookmark,t.paragraphId,t.offset);if(void 0===n)return;n&&s.push(t)}if(!s.length)return}const l=Y(e,t),c=new Intl.Collator(a,{usage:"sort",sensitivity:"accent",numeric:!1,ignorePunctuation:!1}),d=o.seqIdentifier?function(e,t){let n;for(const r of Si(e)){const e=r.blocks.filter(e=>"paragraph"===e.type);if(e.length!==r.blocks.length)return;const o=Wo(e);if(o.diagnostics.length)return;for(const r of o.spans){const o=r.code.map(e=>"instruction"===e.kind?e.raw:"").join(""),a=ti(o);if("SEQ"!==a?.type||a.identifier!==t.toLowerCase())continue;if(!r.separator||!r.end||r.result.some(e=>"run"!==e.kind))return;const i=e[r.begin.paragraphIndex],s=r.result.map(e=>"run"===e.kind?i.runs.find(t=>t.id===e.point.runId)?.text??"":"").join("").trim();if(!s||s.length>64||!/^[A-Za-z0-9.-]+$/.test(s))return;n=s}}return n}(e,o.seqIdentifier):void 0;if(o.seqIdentifier&&void 0===d)return;const u=/* @__PURE__ */new Map;let p=0,f=0;for(const m of s){if(m.identifier!==o.identifier){if(void 0!==m.identifier&&void 0!==o.identifier&&m.identifier.toUpperCase()===o.identifier.toUpperCase())return;continue}if(m.path.some(e=>e.includes(";")||e!==e.trim()))return;let n,r=u;const a=[];for(const e of m.path){if(a.push(e),n=r.get(e),!n){if(++p>8192)return;n={label:e,path:[...a],children:/* @__PURE__ */new Map,pages:/* @__PURE__ */new Map,ranges:/* @__PURE__ */new Map,crossReferences:/* @__PURE__ */new Set},r.set(e,n)}r=n.children}if(!n)return;if("crossReference"===m.reference.kind){n.crossReferences.add(m.reference.text);continue}if("bookmarkRange"===m.reference.kind){const r=Bk(e,t,m.reference.bookmark,l);if(!r)return;const o=r[0].physicalPageIndex+":"+r.at(-1).physicalPageIndex,a=n.ranges.get(o);if(a&&(a.bold!==m.boldPage||a.italic!==m.italicPage||JSON.stringify(a.pages)!==JSON.stringify(r)))return;if(!a){if(f+=r.length,f>32768)return;n.ranges.set(o,{pages:r,bold:m.boldPage,italic:m.italicPage})}continue}const i=Ok(e,t,m,l);if(!i)return;const s={...i,bold:m.boldPage,italic:m.italicPage},c=n.pages.get(i.physicalPageIndex);if(c&&(c.label!==s.label||c.bold!==s.bold||c.italic!==s.italic))return;n.pages.set(i.physicalPageIndex,s)}const g=[];return function e(t){const n=[...t.values()].sort((e,t)=>c.compare(e.label,t.label));for(let r=1;r<n.length;r++)if(0===c.compare(n[r-1].label,n[r].label))return!1;for(const r of n){if(r.crossReferences.size>1||r.crossReferences.size&&(r.pages.size||r.ranges.size))return!1;const t=[...r.ranges.values()].sort((e,t)=>e.pages[0].physicalPageIndex-t.pages[0].physicalPageIndex);let n=-1;for(const e of t){if(e.pages[0].physicalPageIndex<=n||e.pages.some(e=>r.pages.has(e.physicalPageIndex)))return!1;n=e.pages.at(-1).physicalPageIndex}if(g.push({path:r.path,pages:[...r.pages.values()].sort((e,t)=>e.physicalPageIndex-t.physicalPageIndex),...t.length?{ranges:t}:{},crossReferences:[...r.crossReferences]}),!e(r.children))return!1}return!0}(u)?{settings:void 0===d?o:{...o,seqPrefix:`${d}${o.seqSeparator??"-"}`},locale:a,entries:g}:void 0}var zk=e=>!e.sdtWrappers?.length&&!e.list&&!e.numberingRevision&&!e.dropCap&&!e.style?.propertyRevision&&e.runs.every(e=>!(e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.propertyRevision||e.styles?.hidden||e.styles?.rtl||e.styles?.link)),$k="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Hk(e){if(!e)return!0;if(e.length>262144||/<!|<\?/.test(e))return!1;try{const t=(new Ei.DOMParser).parseFromString('<root xmlns:w="'+$k+'">'+e+"</root>","application/xml").documentElement;if(!t||"root"!==t.localName)return!1;const n={root:["p","pPr","r"],p:["pPr","r"],pPr:["ind"],r:["rPr","t"],rPr:["b","i"],ind:[],b:[],i:[],t:[]},r={p:[],pPr:[],r:[],rPr:[],ind:["left"],b:["val"],i:["val"],t:[]};function o(e,t){for(let n=0;n<e.attributes.length;n++){const o=e.attributes.item(n);if("http://www.w3.org/2000/xmlns/"!==o.namespaceURI&&("t"!==t||"http://www.w3.org/XML/1998/namespace"!==o.namespaceURI||"space"!==o.localName||"preserve"!==o.value&&"default"!==o.value)){if(o.namespaceURI!==$k||!o.localName||!r[t]?.includes(o.localName))return!1;if("ind"===t&&!/^\d+$/.test(o.value))return!1;if(("b"===t||"i"===t)&&!/^(?:0|1|true|false|on|off)$/.test(o.value))return!1}}for(let r=0;r<e.childNodes.length;r++){const a=e.childNodes.item(r);if(1===a.nodeType){const e=a;if(e.namespaceURI!==$k||!e.localName||!n[t]?.includes(e.localName)||!o(e,e.localName))return!1}else if(3!==a.nodeType||"t"!==t&&a.nodeValue?.trim())return!1}return!0}return o(t,"root")}catch{return!1}}function jk(e,t){return Object.entries(e??{}).every(([e,n])=>void 0===n||t.includes(e))}function Wk(e){if(!zk(e)||!jk(e.style,["indentLeft","styleId"])||void 0!==e.style?.styleId&&"IndexHeading"!==e.style.styleId||!Number.isFinite(e.style?.indentLeft??0)||!e.runs.length||po(e).length>32768)return!1;const t=Ii(e);return!(t?.attributes?.trim()||!Hk(t?.xml)||!Hk(t?.paragraphProperties?.xml))&&e.runs.every(e=>"text"===e.kind&&!/[\r\n]/.test(e.text)&&("\t"!==e.text||1===e.text.length)&&jk(e.styles,["bold","italic"])&&Hk(Vr(e)?.xml))}function Uk(e){if(e.some(e=>"paragraph"!==e.type))return;const t=e,n=Wo(t);if(n.diagnostics.length)return;const r=n.spans.filter(e=>{const t=e.code.map(e=>"instruction"===e.kind?e.raw:"").join("");return"INDEX"===oo(t).command||/^\s*INDEX(?=\s|\\|"|$)/i.test(t)});if(1!==r.length)return;const o=r[0],a=o.code.map(e=>"instruction"===e.kind?e.raw:"").join("");if(!Lk(a)||null!==o.parentIndex||!o.separator||!o.end||o.beginMarker.fieldLock||o.beginMarker.dirty||o.code.some(e=>"instruction"!==e.kind)||o.begin.paragraphIndex!==o.separator.paragraphIndex||o.begin.paragraphIndex>=o.end.paragraphIndex)return;const i=o.begin.paragraphIndex,s=o.end.paragraphIndex,l=t[i],c=t[s];if(!zk(l)||!zk(c)||0!==o.begin.runIndex||o.separator.runIndex!==l.runs.length-1||0!==o.end.runIndex||1!==c.runs.length||l.runs.some(e=>e.text.length||"fieldChar"!==e.kind&&"fieldInstruction"!==e.kind)||0!==c.runs[0]?.text.length)return;const d=t.slice(i+1,s);return d.every(Wk)&&!o.result.some(e=>"run"!==e.kind||e.point.paragraphIndex<=i||e.point.paragraphIndex>=s)&&o.result.length===d.reduce((e,t)=>e+t.runs.length,0)?{start:i,end:s,raw:a}:void 0}function Vk(e,t="tabs"){if(!e.entries.length||e.entries.length>2048)return;const n=e.settings.letterRange,r=n&&"!"!==n?e.entries.filter(e=>{const t=(e.path.at(-1)?.[0]??"").normalize("NFD").replace(/\p{M}/gu,"").toLowerCase();return t>=n[0]&&t<=n[2]}):e.entries;if(!r.length)return;const o=[],a=[];e.settings.heading&&o.push({indent:0,fragments:[{text:e.settings.heading}],styleId:"IndexHeading"});for(const l of r){const t=e.settings.runIn?l.path.join(":"):l.path.at(-1);if(!t)return;const n=[];e.settings.seqPrefix&&n.push({text:e.settings.seqPrefix}),n.push({text:t});const r=l.pages.map(e=>({index:e.physicalPageIndex,fragment:{text:e.label,bold:e.bold,italic:e.italic}}));for(const o of l.ranges??[]){const t=o.pages[0],n=o.pages.at(-1);if(!t||!n||o.pages.some(e=>e.sectionIndex!==t.sectionIndex)||t!==n&&t.label===n.label)return;r.push({index:t.physicalPageIndex,fragment:{text:t===n?t.label:t.label+(e.settings.rangeSeparator??"–")+n.label,bold:o.bold,italic:o.italic}})}if(r.sort((e,t)=>e.index-t.index),r.length){if(l.crossReferences.length)return;n.push({text:e.settings.entrySeparator}),r.forEach((t,r)=>{r&&n.push({text:e.settings.pageSeparator}),n.push(t.fragment)})}else if(l.crossReferences.length){if(1!==l.crossReferences.length)return;n.push({text:e.settings.crossReferenceSeparator},{text:l.crossReferences[0]})}if(n.some(e=>/[\r\n\t]/.test(e.text))||n.reduce((e,t)=>e+t.text.length,0)>32768)return;a.push({indent:e.settings.runIn?0:24*(l.path.length-1),fragments:n})}const i=Math.min(4,Math.max(1,e.settings.columns??1));if(1===i||"section"===t)return[...o,...a];const s=Math.ceil(a.length/i);for(let l=0;l<i;l++){const e=a.slice(l*s,(l+1)*s);if(!e.length)break;l&&o.push({indent:0,fragments:[{text:"\t"}]}),o.push(...e)}return o}function _k(e){const t=[];for(const n of e){if(!n.text)continue;const e=!!n.bold,r=!!n.italic,o=t.at(-1);o&&o.bold===e&&o.italic===r?o.text+=n.text:t.push({text:n.text,bold:e,italic:r})}return t}function Kk(e,t){return"paragraph"===e.type&&(e.style?.indentLeft??0)===t.indent&&(e.style?.styleId??void 0)===t.styleId&&JSON.stringify(_k(e.runs.map(e=>({text:e.text,bold:e.styles?.bold,italic:e.styles?.italic}))))===JSON.stringify(_k(t.fragments))}function qk(e){const t=xo(_k(e.fragments).map(e=>({text:e.text,...e.bold||e.italic?{styles:{...e.bold?{bold:!0}:{},...e.italic?{italic:!0}:{}}}:{}})));return(e.indent||e.styleId)&&(t.style={...e.indent?{indentLeft:e.indent}:{},...e.styleId?{styleId:e.styleId}:{}}),t}function Xk(e,t,n,r){const o=/* @__PURE__ */new Map;for(const s of Si(e.document))for(const e of s.blocks)o.set(e.id,o.size);if(t.has(e.selection.anchor.paragraphId)||t.has(e.selection.focus.paragraphId))return!0;const a=o.get(n),i=o.get(r);if(void 0===a||void 0===i)return!0;for(const s of[...Object.values(e.document.bookmarks?.items??{}),...Object.values(e.document.comments?.items??{})]){const e=s.start?o.get(s.start.paragraphId):void 0,t=s.end?o.get(s.end.paragraphId):void 0;if(void 0===e||void 0===t||e>t||e<=i&&t>=a)return!0}return!1}function Gk(e,t,n=f,r=6){let o;const a=e,i=(e,t)=>({state:a,status:e,passes:t,updatedEntries:0,layout:o});if("main"!==Yo(e)||e.trackChangesEnabled||!Number.isSafeInteger(r)||r<1)return i("unsupported",0);let s=ya(e);const l=Si(e.document),c=l[s];if(!c||(c.pageSettings.columns?.count??1)>1&&("continuous"!==c.breakType||!Uk(c.blocks)))return i("unsupported",0);const d=Uk(c.blocks);if(!d)return i("unsupported",0);const u=Math.min(4,Math.max(1,Lk(d.raw)?.columns??1)),p=c.blocks[d.start].id,g=c.blocks[d.end].id,m=new Set(c.blocks.slice(d.start+1,d.end).map(e=>e.id));u>1&&c.pageSettings.columns?.count!==u&&(e={...e,document:{...e.document,sections:l.map((e,t)=>t===s?{...e,pageSettings:{...e.pageSettings,columns:{count:u,space:24}},breakType:"continuous"}:e)}});const h=Ak(e.document);if(!h)return i("unsupported",0);const b=JSON.stringify(h);let y=e;const v=/* @__PURE__ */new Set,x=Math.min(r,6);for(let f=1;f<=x;f++){let r;try{r=n(y.document)}catch{return i("unsupported",f)}o??=r;const a=Si(y.document);let l=s;if(u>1&&(l=a.findIndex(e=>"continuous"===e.breakType&&e.pageSettings.columns?.count===u&&Uk(e.blocks)?.raw===d.raw),l<0))return i("unsupported",f);const c=a[l],h=c&&Uk(c.blocks);if(!c||!h||h.raw!==d.raw||c.blocks[h.start].id!==p||c.blocks[h.end].id!==g||JSON.stringify(Ak(y.document))!==b)return i("unsupported",f);const x=Nk(y.document,r,h.raw,t);if(!x)return i("unresolved",f);const w=Vk(x,u>1?"section":"tabs");if(!w)return i("unsupported",f);const I=c.blocks.slice(h.start+1,h.end);if(I.length===w.length&&I.every((e,t)=>Kk(e,w[t])))return{state:y,status:y===e?"unchanged":"updated",passes:f,updatedEntries:y===e?0:w.length,layout:r};if(Xk(e,m,p,g))return i("unsupported",f);const S=JSON.stringify([w,r.pages.map(e=>[e.index,e.sectionIndex])]);if(v.has(S))return i("nonconvergent",f);v.add(S);const C=[...c.blocks.slice(0,h.start+1),...w.map(qk),...c.blocks.slice(h.end)];y={...y,document:{...y.document,sections:a.map((e,t)=>t===l?{...e,blocks:C}:e)},selection:e.selection}}return i("nonconvergent",x)}function Yk(e,t=!1){return{...Io(""),kind:"fieldInstruction",fieldInstruction:e,...t?{styles:{hidden:!0}}:{}}}function Zk(e,t=!1){return{...Io(""),kind:"fieldChar",fieldChar:{kind:e},...t?{styles:{hidden:!0}}:{}}}function Jk(e){if("main"!==Yo(e)||e.trackChangesEnabled||!ri(e.selection))return;const t=Si(e.document),n=ya(e),r=t[n];if(!r||r.blocks.some(e=>"paragraph"!==e.type))return;const o=r.blocks,a=o.findIndex(t=>t.id===e.selection.focus.paragraphId),i=o[a];if(!i||To(i,e.selection.focus)!==Za(i)||i.sdtWrappers?.length||i.list||i.numberingRevision||i.dropCap||i.style?.propertyRevision||i.runs.some(e=>e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.propertyRevision))return;const s=Wo(o);return s.diagnostics.length?void 0:{sections:t,index:n,section:r,paragraphs:o,at:a,p:i,graph:s}}function Qk(e,t,n){return{...e,document:{...e.document,sections:t.sections.map((e,r)=>r===t.index?{...e,blocks:n}:e)}}}function eT(e){return void 0===e||/^[A-Za-z]$/.test(e)}function tT(e){const t=Jk(e);return!!t&&(!(Ii(t.p)||t.p.runs.some(e=>"text"!==e.kind||e.styles?.hidden||e.styles?.rtl)||t.graph.spans.some(e=>e.begin.paragraphIndex<=t.at&&(e.end?.paragraphIndex??1/0)>=t.at))&&(![...Object.values(e.document.bookmarks?.items??{}),...Object.values(e.document.comments?.items??{})].some(e=>e.start?.paragraphId===t.p.id||e.end?.paragraphId===t.p.id)&&void 0!==Ak(e.document)))}function nT(e){const t=Jk(e);if(!t||Object.keys(e.document.bookmarks?.items??{}).length||Object.keys(e.document.comments?.items??{}).length||(t.section.pageSettings.columns?.count??1)>1)return!1;if(t.graph.spans.some(e=>e.begin.paragraphIndex<=t.at&&(e.end?.paragraphIndex??1/0)>t.at))return!1;for(const n of t.sections){if(n.blocks.some(e=>"paragraph"!==e.type))return!1;const e=Wo(n.blocks);if(e.diagnostics.length||e.spans.some(e=>{const t=e.code.map(e=>"instruction"===e.kind?e.raw:"").join("");return"INDEX"===oo(t).command||/^\s*INDEX(?=\s|\\|"|$)/i.test(t)}))return!1}return!!Ak(e.document)?.length}function rT(e){if("main"!==Yo(e)||e.trackChangesEnabled)return!1;const t=Si(e.document);return t.some(e=>1===(e.pageSettings.columns?.count??1)&&!!Uk(e.blocks))||t.some(e=>"continuous"===e.breakType&&(e.pageSettings.columns?.count??1)>1&&!!Uk(e.blocks))}var oT=e=>`${e}:${Math.random().toString(36).slice(2,11)}`;function aT(e,t){return{id:oT("run:fld"),kind:"fieldChar",text:"",fieldChar:{kind:e},styles:t?{...t}:void 0}}function iT(e,t,n){const r=xi(e),o=r[t],a={...o,runs:o.runs.map(e=>n.get(e.id)??Ro(e))};return Cn(e,[...ho(r.slice(0,t)),a,...ho(r.slice(t+1))],e.selection)}function sT(e,t,n){if("string"!=typeof n||oo(n).error)return e;const r=function(e,t){const n=xi(e),r=Wo(n);if(!r.diagnostics.length)return r.spans.find(e=>null===e.parentIndex&&(e.begin.runId===t||e.code.some(e=>"instruction"===e.kind&&e.point.runId===t))&&e.code.every(e=>"instruction"===e.kind)&&!!e.separator&&!!e.end&&e.begin.paragraphIndex===e.end.paragraphIndex)}(e,t);if(!r||r.beginMarker.fieldLock)return e;const o=r.code.filter(e=>"instruction"===e.kind).map(e=>e.point.runId);if(!o.includes(t))return e;const a=/* @__PURE__ */new Map,i=xi(e)[r.begin.paragraphIndex];if(o.forEach((e,t)=>{const r=i.runs.find(t=>t.id===e);r&&"fieldInstruction"===r.kind&&a.set(e,{...r,fieldInstruction:0===t?n:""})}),a.size!==o.length)return e;const s=i.runs.find(e=>e.id===r.begin.runId);return s&&"fieldChar"===s.kind?(a.set(r.begin.runId,{...s,fieldChar:{...s.fieldChar,dirty:!0}}),iT(e,r.begin.paragraphIndex,a)):e}var lT=(e,t)=>e.length>0&&e.length<=t&&!!e.trim()&&![...e].some(e=>e.charCodeAt(0)<32||127===e.charCodeAt(0));function cT(e){const t=oo(e);if(t.error||"TA"!==t.command)return;const n=t.tokens.slice(1);if(!n.length)return;let r,o,a,i="1",s=!1,l=!1;const c=/* @__PURE__ */new Set;for(let d=0;d<n.length;d++){const e=n[d];if("switch"!==e.kind)return;const t=e.value.toLowerCase();if(c.has(t))return;if(c.add(t),"b"===t){s=!0;continue}if("i"===t){l=!0;continue}if("l"!==t&&"s"!==t&&"c"!==t&&"r"!==t)return;const u=n[++d];if(!u||"switch"===u.kind)return;if("l"===t||"s"===t){if("quoted"!==u.kind||!lT(u.value,4096))return;"l"===t?r=u.value:o=u.value}else if("c"===t){if(!lT(u.value,32)||/\s/.test(u.value))return;i=u.value}else{if(!/^[A-Za-z_][A-Za-z0-9_]{0,39}$/.test(u.value))return;a=u.value}}return r?{long:r,...o?{short:o}:{},category:i,boldPage:s,italicPage:l,...a?{bookmark:a}:{}}:void 0}function dT(e){const t=[],n=/* @__PURE__ */new Set;for(const[r,o]of Si(e).entries()){const e=[];for(const t of o.blocks){if("paragraph"!==t.type||n.has(t.id)||t.runs.some(e=>"textBox"===e.kind||"opaque"===e.kind))return;n.add(t.id),e.push(t)}const a=Wo(e);if(a.diagnostics.length)return;for(const n of a.spans){const o=n.code.map(e=>"instruction"===e.kind?e.raw:"").join("");if("TA"!==oo(o).command&&!/^\s*TA(?=\s|\\|"|$)/i.test(o))continue;const a=cT(o);if(!a||null!==n.parentIndex||!n.end||n.separator||n.begin.paragraphIndex!==n.end.paragraphIndex||n.beginMarker.fieldLock||n.beginMarker.dirty||n.code.some(e=>"instruction"!==e.kind)||n.result.length)return;const i=e[n.begin.paragraphIndex];if(i.sdtWrappers?.length||i.numberingRevision||i.dropCap||new Set(i.runs.map(e=>e.id)).size!==i.runs.length||i.runs.slice(n.begin.runIndex,n.end.runIndex+1).some(e=>e.text.length||e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.link||"fieldChar"!==e.kind&&"fieldInstruction"!==e.kind))return;if(t.push({...a,sectionIndex:r,paragraphId:i.id,runId:n.begin.runId,offset:n.begin.offset,raw:o}),t.length>4096)return}}return t}function uT(e,t,n,r=Y(e,t)){if(n.bookmark)return;const o=r.pageIndexAt(n.paragraphId,n.offset);if(void 0===o)return;const a=r.forPage(o);if(a.sectionNumber!==n.sectionIndex+1||void 0===a.pageNumber)return;const i=Si(e)[n.sectionIndex];if(!i)return;const s=mo(a.pageNumber,i.pageNumbering?.format);return void 0===s?void 0:{physicalPageIndex:o,label:String(s)}}var pT=e=>e.length>0&&e.length<=15&&![...e.replace(/^\t$/,"")].some(e=>e.charCodeAt(0)<32||127===e.charCodeAt(0));function fT(e){const t=oo(e);if(t.error||"TOA"!==t.command)return;const n=t.tokens.slice(1);let r,o,a;const i={category:"1",entrySeparator:"\t",pageSeparator:", ",rangeSeparator:"–",seqSeparator:"-",passim:!1,includeHeading:!1,stripSourceFormatting:!1},s=/* @__PURE__ */new Set;for(let l=0;l<n.length;l++){const e=n[l];if("switch"!==e.kind)return;const t=e.value.toLowerCase();if(s.has(t))return;if(s.add(t),"p"===t){i.passim=!0;continue}if("h"===t){i.includeHeading=!0;continue}if("f"===t){i.stripSourceFormatting=!0;continue}if(!["c","b","e","g","l","s","d"].includes(t))return;const c=n[++l];if(!c||"switch"===c.kind)return;if("c"===t){if(!c.value||c.value.length>32||/\s|["\\]/.test(c.value))return;r=c.value}else if("b"===t||"s"===t){if(!/^[A-Za-z_][A-Za-z0-9_]{0,39}$/.test(c.value))return;"b"===t?o=c.value:a=c.value}else{if(!pT(c.value)||"quoted"!==c.kind&&"\t"!==c.value)return;"e"===t?i.entrySeparator=c.value:"l"===t?i.pageSeparator=c.value:"g"===t?i.rangeSeparator=c.value:i.seqSeparator=c.value}}return r?{...i,category:r,...o?{bookmark:o}:{},...a?{seqIdentifier:a}:{}}:void 0}function gT(e,t,n,r){const o=fT(n);if(!o)return;if(!r||!/^[A-Za-z]{2,3}(?:-[A-Za-z]{2})?$/.test(r))return;let a;try{a=new Intl.Collator(r)}catch{return}const i=dT(e);if(!i)return;let s=i;if(o.bookmark){s=[];for(const t of i){const n=Fk(e,o.bookmark,t.paragraphId,t.offset);if(void 0===n)return;n&&s.push(t)}if(!s.length)return}const l=Y(e,t),c=o.seqIdentifier?ci(e).get(o.seqIdentifier.toLowerCase()):void 0;if(o.seqIdentifier&&(void 0===c||!Number.isSafeInteger(c)))return;const d=/* @__PURE__ */new Map;for(const p of s){if(p.category.toLowerCase()!==o.category.toLowerCase())continue;const n=p.short??p.long;if(n.length>4096||/[\r\n\t]/.test(n))return;let r=d.get(n);if(r||(r={label:n,pages:[],bold:p.boldPage,italic:p.italicPage},d.set(n,r)),r.bold!==p.boldPage||r.italic!==p.italicPage)return;if(p.bookmark){const n=Bk(e,t,p.bookmark,l);if(!n)return;r.ranges??=[];const o=n[0].physicalPageIndex,a=n.at(-1).physicalPageIndex;r.ranges.some(e=>e[0].physicalPageIndex===o&&e.at(-1).physicalPageIndex===a)||r.ranges.push(n);continue}const a=uT(e,t,p,l);if(!a)return;r.pages.some(e=>e.physicalPageIndex===a.physicalPageIndex)||r.pages.push(a)}const u=[...d.values()];if(u.sort((e,t)=>a.compare(e.label,t.label)),!(u.length>2048)){for(const e of u)e.pages.sort((e,t)=>e.physicalPageIndex-t.physicalPageIndex),void 0!==c&&(e.prefix=`${c}${o.seqSeparator}`);return{settings:o,locale:r,category:o.category,entries:u}}}var mT=e=>!e.sdtWrappers?.length&&!e.list&&!e.numberingRevision&&!e.dropCap&&!e.style?.propertyRevision&&e.runs.every(e=>!(e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.propertyRevision||e.styles?.hidden||e.styles?.rtl||e.styles?.link));function hT(e){if(e.some(e=>"paragraph"!==e.type))return;const t=e,n=Wo(t);if(n.diagnostics.length)return;const r=n.spans.filter(e=>{const t=e.code.map(e=>"instruction"===e.kind?e.raw:"").join("");return"TOA"===oo(t).command||/^\s*TOA(?=\s|\\|"|$)/i.test(t)});if(1!==r.length)return;const o=r[0],a=o.code.map(e=>"instruction"===e.kind?e.raw:"").join("");if(!fT(a)||null!==o.parentIndex||!o.separator||!o.end||o.beginMarker.fieldLock||o.beginMarker.dirty||o.code.some(e=>"instruction"!==e.kind)||o.begin.paragraphIndex!==o.separator.paragraphIndex||o.begin.paragraphIndex>=o.end.paragraphIndex)return;const i=o.begin.paragraphIndex,s=o.end.paragraphIndex,l=t[i],c=t[s];if(!mT(l)||!mT(c)||0!==o.begin.runIndex||o.separator.runIndex!==l.runs.length-1||0!==o.end.runIndex||1!==c.runs.length||l.runs.some(e=>e.text.length||"fieldChar"!==e.kind&&"fieldInstruction"!==e.kind)||0!==c.runs[0]?.text.length)return;const d=t.slice(i+1,s);return d.every(e=>mT(e)&&e.runs.every(e=>"text"===e.kind&&e.text.length<=32768))&&!o.result.some(e=>"run"!==e.kind||e.point.paragraphIndex<=i||e.point.paragraphIndex>=s)&&o.result.length===d.reduce((e,t)=>e+t.runs.length,0)?{start:i,end:s,raw:a}:void 0}function bT(e){if(e.entries.length>2048)return;const{settings:t}=e,n=[];t.includeHeading&&n.push({fragments:[{text:e.category}]});for(const r of e.entries){const e=[];r.prefix&&e.push({text:r.prefix}),e.push({text:r.label});const o=t.passim&&r.pages.length>=5?[{text:"passim"}]:r.pages.map((e,n)=>({text:`${n?t.pageSeparator:""}${e.label}`,bold:r.bold,italic:r.italic}));for(const n of r.ranges??[]){const e=n[0],a=n.at(-1);if(!e||!a||n.some(t=>t.sectionIndex!==e.sectionIndex)||e!==a&&e.label===a.label)return;o.push({text:t.pageSeparator,bold:r.bold,italic:r.italic}),o.push({text:e===a?e.label:`${e.label}${t.rangeSeparator}${a.label}`,bold:r.bold,italic:r.italic})}if(o.length&&e.push({text:t.entrySeparator},...o),e.some(e=>!e.text||e.text.length>4e4))return;n.push({fragments:e})}return n.length?n:void 0}function yT(e){const t=[];for(const n of e){if(!n.text)continue;const e=t.at(-1);e&&e.bold===!!n.bold&&e.italic===!!n.italic?e.text+=n.text:t.push({text:n.text,bold:!!n.bold,italic:!!n.italic})}return t}var vT=(e,t)=>"paragraph"===e.type&&JSON.stringify(yT(e.runs.map(e=>({text:e.text,bold:e.styles?.bold,italic:e.styles?.italic}))))===JSON.stringify(yT(t.fragments)),xT=e=>xo(yT(e.fragments).map(e=>({text:e.text,...e.bold||e.italic?{styles:{...e.bold?{bold:!0}:{},...e.italic?{italic:!0}:{}}}:{}})));function wT(e,t,n=f,r=6){let o;const a=(t,n)=>({state:e,status:t,passes:n,updatedEntries:0,layout:o});if("main"!==Yo(e)||e.trackChangesEnabled||!Number.isSafeInteger(r)||r<1||r>6)return a("unsupported",0);const i=ya(e),s=Si(e.document)[i];if(!s)return a("unsupported",0);const l=hT(s.blocks);if(!l)return a("unsupported",0);const c=s.blocks[l.start].id,d=s.blocks[l.end].id;let u=e;const p=/* @__PURE__ */new Set;for(let f=1;f<=r;f++){let r;try{r=n(u.document)}catch{return a("unsupported",f)}o??=r;const s=Si(u.document),g=s[i],m=g&&hT(g.blocks);if(!g||!m||m.raw!==l.raw||g.blocks[m.start].id!==c||g.blocks[m.end].id!==d)return a("unsupported",f);const h=gT(u.document,r,m.raw,t);if(!h)return a("unresolved",f);const b=bT(h);if(!b)return a("unsupported",f);const y=g.blocks.slice(m.start+1,m.end);if(y.length===b.length&&y.every((e,t)=>vT(e,b[t])))return{state:u,status:u===e?"unchanged":"updated",passes:f,updatedEntries:u===e?0:b.length,layout:r};const v=JSON.stringify([b,r.pages.map(e=>[e.index,e.sectionIndex])]);if(p.has(v))return a("nonconvergent",f);p.add(v);const x=[...g.blocks.slice(0,m.start+1),...b.map(xT),...g.blocks.slice(m.end)];u={...u,document:{...u.document,sections:s.map((e,t)=>t===i?{...e,blocks:x}:e)},selection:e.selection}}return a("nonconvergent",r)}var IT=(e,t=!1)=>({...Io(""),kind:"fieldInstruction",fieldInstruction:e,...t?{styles:{hidden:!0}}:{}}),ST=(e,t=!1)=>({...Io(""),kind:"fieldChar",fieldChar:{kind:e},...t?{styles:{hidden:!0}}:{}});function CT(e){if("main"!==Yo(e)||e.trackChangesEnabled||!ri(e.selection))return;const t=Si(e.document),n=ya(e),r=t[n];if(!r||r.blocks.some(e=>"paragraph"!==e.type))return;const o=r.blocks,a=o.findIndex(t=>t.id===e.selection.focus.paragraphId),i=o[a];if(!i||To(i,e.selection.focus)!==Za(i)||i.sdtWrappers?.length||i.list||i.numberingRevision||i.dropCap||i.style?.propertyRevision||i.runs.some(e=>e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.propertyRevision))return;const s=Wo(o);return s.diagnostics.length?void 0:{sections:t,index:n,section:r,paragraphs:o,at:a,p:i,graph:s}}function kT(e,t,n){return{...e,document:{...e.document,sections:t.sections.map((e,r)=>r===t.index?{...e,blocks:n}:e)}}}var TT=e=>"string"==typeof e&&!!e.trim()&&e.length<=4096&&!/[\r\n\t\\;"]/.test(e),PT=e=>"string"==typeof e&&!!e&&e.length<=32&&!/\s|["\\]/.test(e);function RT(e,t){const n=CT(e);if(!n||!function(e){const t=CT(e);return!(!t||Ii(t.p)||t.p.runs.some(e=>"text"!==e.kind||e.styles?.hidden||e.styles?.rtl)||t.graph.spans.some(e=>e.begin.paragraphIndex<=t.at&&(e.end?.paragraphIndex??1/0)>=t.at)||[...Object.values(e.document.bookmarks?.items??{}),...Object.values(e.document.comments?.items??{})].some(e=>e.start?.paragraphId===t.p.id||e.end?.paragraphId===t.p.id)||void 0===dT(e.document))}(e)||!TT(t.long)||void 0!==t.short&&!TT(t.short)||void 0!==t.category&&!PT(t.category))return e;const r=t.category??"1",o=` TA \\l "${t.long}"`+(t.short?` \\s "${t.short}"`:"")+` \\c ${r}`+(t.boldPage?" \\b":"")+(t.italicPage?" \\i":"")+" ";if(!cT(o))return e;const a={...n.p,runs:[...n.p.runs,ST("begin",!0),IT(o,!0),ST("end",!0)]},i=kT(e,n,n.paragraphs.map((e,t)=>t===n.at?a:e));return dT(i.document)?i:e}function MT(e,t,n=f){const r=CT(e);if(!(r&&function(e){const t=CT(e);if(!t||Object.keys(e.document.bookmarks?.items??{}).length||Object.keys(e.document.comments?.items??{}).length||(t.section.pageSettings.columns?.count??1)>1)return!1;if(t.graph.spans.some(e=>{const t=e.code.map(e=>"instruction"===e.kind?e.raw:"").join("");return"TOA"===oo(t).command||/^\s*TOA(?=\s|\\|"|$)/i.test(t)}))return!1;for(const n of t.sections){if(n.blocks.some(e=>"paragraph"!==e.type))return!1;const e=Wo(n.blocks);if(e.diagnostics.length||e.spans.some(e=>{const t=e.code.map(e=>"instruction"===e.kind?e.raw:"").join("");return"TOA"===oo(t).command||/^\s*TOA(?=\s|\\|"|$)/i.test(t)}))return!1}return!!dT(e.document)?.length}(e)&&PT(t.category)&&/^[A-Za-z]{2,3}(?:-[A-Za-z]{2})?$/.test(t.locale)))return e;const o=` TOA \\c "${t.category}"`+(t.heading?" \\h":"")+(t.passim?" \\p":"")+" ";if(!fT(o))return e;const a=Ma("");a.runs=[ST("begin"),IT(o),ST("separate")];const i=Ma("");i.runs=[ST("end")];const s=wT(kT(e,r,[...r.paragraphs.slice(0,r.at+1),a,i,...r.paragraphs.slice(r.at+1)]),t.locale,n);return"updated"===s.status?s.state:e}function AT(e,t,n,r=Y(e,t)){const o=r.pageIndexAt(n.paragraphId,n.offset);if(void 0===o)return;const a=r.forPage(o);if(a.sectionNumber!==n.sectionIndex+1||void 0===a.pageNumber)return;const i=Si(e)[n.sectionIndex];if(!i)return;const s=mo(a.pageNumber,i.pageNumbering?.format);return void 0===s?void 0:{physicalPageIndex:o,label:String(s)}}var OT=e=>!e.sdtWrappers?.length&&!e.list&&!e.numberingRevision&&!e.dropCap&&!e.style?.propertyRevision&&e.runs.every(e=>!(e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.propertyRevision||e.styles?.hidden||e.styles?.rtl||e.styles?.link));function BT(e){if(e.some(e=>"paragraph"!==e.type))return;const t=e,n=Wo(t);if(n.diagnostics.length)return;const r=n.spans.filter(e=>{const t=gI(e.code.map(e=>"instruction"===e.kind?e.raw:"").join(""));return void 0!==t?.captionIdentifier||void 0!==t?.unlabeledIdentifier});if(1!==r.length)return;const o=r[0],a=o.code.map(e=>"instruction"===e.kind?e.raw:"").join(""),i=gI(a);if(null!==o.parentIndex||!o.separator||!o.end||o.beginMarker.fieldLock||o.beginMarker.dirty||o.code.some(e=>"instruction"!==e.kind)||o.begin.paragraphIndex!==o.separator.paragraphIndex||o.begin.paragraphIndex>=o.end.paragraphIndex)return;const s=o.begin.paragraphIndex,l=o.end.paragraphIndex,c=t[s],d=t[l];if(!OT(c)||!OT(d)||0!==o.begin.runIndex||o.separator.runIndex!==c.runs.length-1||0!==o.end.runIndex||1!==d.runs.length||c.runs.some(e=>e.text.length||"fieldChar"!==e.kind&&"fieldInstruction"!==e.kind)||0!==d.runs[0]?.text.length)return;const u=t.slice(s+1,l);return u.every(e=>OT(e)&&e.runs.every(e=>"text"===e.kind&&e.text.length<=32768))&&!o.result.some(e=>"run"!==e.kind||e.point.paragraphIndex<=s||e.point.paragraphIndex>=l)&&o.result.length===u.reduce((e,t)=>e+t.runs.length,0)?{start:s,end:l,raw:a,settings:i}:void 0}function FT(e,t,n){const r=gI(n);if(!r||void 0===r.captionIdentifier&&void 0===r.unlabeledIdentifier)return;const o=function(e,t,n=!1){if(!t||t.length>64||!/^[A-Za-z_][A-Za-z0-9_ ]*$/.test(t))return;const r=ci(e),o=[];for(const[a,i]of Si(e).entries()){const e=[];for(const t of i.blocks){if("paragraph"!==t.type)return;e.push(t)}const s=Wo(e);if(s.diagnostics.length)return;for(const i of s.spans){const s=i.code.map(e=>"instruction"===e.kind?e.raw:"").join(""),l=ti(s);if("SEQ"!==l?.type||l.identifier!==t.toLowerCase())continue;if(null!==i.parentIndex||!i.end||!i.separator||i.code.some(e=>"instruction"!==e.kind)||1!==i.result.length||"run"!==i.result[0]?.kind||i.beginMarker.fieldLock)return;const c=e[i.begin.paragraphIndex];if(i.begin.paragraphIndex!==i.end.paragraphIndex||c.sdtWrappers?.length||c.numberingRevision||c.dropCap||c.runs.some(e=>e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.link))return;const d=i.result[0].point.runIndex,u=r.get(vi(c.id,d));if(void 0===u)return;const p=c.runs.slice(0,i.begin.runIndex).map(e=>e.text).join("").replace(/^\s+/,""),f=c.runs.slice(i.end.runIndex+1).map(e=>e.text).join("").trim();if(p.length>256||f.length>4096||/[\r\n]/.test(p+f))return;const g=f.replace(/^[:;\-\s]+/,""),m=n?g:`${p}${u}${f?`: ${g}`:""}`;if(!m||m.length>4096)return;o.push({identifier:t,number:u,display:m,paragraphId:c.id,offset:i.begin.offset,sectionIndex:a})}}return o.sort((e,t)=>e.sectionIndex-t.sectionIndex||e.offset-t.offset)}(e,r.captionIdentifier??r.unlabeledIdentifier,!!r.unlabeledIdentifier);if(!o||o.length>2048)return;const a=r.chapterIdentifier?ci(e).get(r.chapterIdentifier.toLowerCase()):void 0;if(r.chapterIdentifier&&void 0===a)return;const i=Y(e,t),s=[];for(const l of o){const n=r.scopeBookmark?void 0:AT(e,t,l,i);if(!r.scopeBookmark&&!n)return;const o=void 0===a?l.display:`${a}${r.chapterSeparator??"-"}${l.display}`;if(o.length>4096)return;s.push({display:o,page:n})}return{settings:r,entries:s}}function ET(e){if(!e.entries.length)return;const t=[],n=e.settings.entryPageSeparator??"\t";for(const r of e.entries){const o=[{text:r.display}],a=e.settings.omitPages,i=Number(r.display.match(/\d+/)?.[0]??0),s=a&&i>=a[0]&&i<=a[1];if(r.page&&!s&&o.push({text:n},{text:r.page.label}),o.some(e=>!e.text||e.text.length>4e4))return;t.push({fragments:o})}return t}function DT(e){const t=[];for(const n of e){if(!n.text)continue;const e=t.at(-1);e&&e.bold===!!n.bold&&e.italic===!!n.italic?e.text+=n.text:t.push({text:n.text,bold:!!n.bold,italic:!!n.italic})}return t}var LT=(e,t)=>"paragraph"===e.type&&JSON.stringify(DT(e.runs.map(e=>({text:e.text,bold:e.styles?.bold,italic:e.styles?.italic}))))===JSON.stringify(DT(t.fragments)),NT=e=>xo(DT(e.fragments).map(e=>({text:e.text})));function zT(e,t=f,n=6){let r;const o=(t,n)=>({state:e,status:t,passes:n,updatedEntries:0,layout:r});if("main"!==Yo(e)||e.trackChangesEnabled||!Number.isSafeInteger(n)||n<1||n>6)return o("unsupported",0);const a=ya(e),i=Si(e.document)[a];if(!i)return o("unsupported",0);const s=BT(i.blocks);if(!s)return o("unsupported",0);const l=i.blocks[s.start].id,c=i.blocks[s.end].id;let d=e;const u=/* @__PURE__ */new Set;for(let p=1;p<=n;p++){let n;try{n=t(d.document)}catch{return o("unsupported",p)}r??=n;const i=Si(d.document),f=i[a],g=f&&BT(f.blocks);if(!f||!g||g.raw!==s.raw||f.blocks[g.start].id!==l||f.blocks[g.end].id!==c)return o("unsupported",p);const m=FT(d.document,n,g.raw);if(!m)return o("unresolved",p);const h=ET(m);if(!h)return o("unsupported",p);const b=f.blocks.slice(g.start+1,g.end);if(b.length===h.length&&b.every((e,t)=>LT(e,h[t])))return{state:d,status:d===e?"unchanged":"updated",passes:p,updatedEntries:d===e?0:h.length,layout:n};const y=JSON.stringify([h,n.pages.map(e=>[e.index,e.sectionIndex])]);if(u.has(y))return o("nonconvergent",p);u.add(y);const v=[...f.blocks.slice(0,g.start+1),...h.map(NT),...f.blocks.slice(g.end)];d={...d,document:{...d.document,sections:i.map((e,t)=>t===a?{...e,blocks:v}:e)},selection:e.selection}}return o("nonconvergent",n)}var $T=e=>({...Io(""),kind:"fieldInstruction",fieldInstruction:e}),HT=e=>({...Io(""),kind:"fieldChar",fieldChar:{kind:e}});function jT(e){if("main"!==Yo(e)||e.trackChangesEnabled||!ri(e.selection))return;const t=Si(e.document),n=ya(e),r=t[n];if(!r||r.blocks.some(e=>"paragraph"!==e.type))return;const o=r.blocks,a=o.findIndex(t=>t.id===e.selection.focus.paragraphId),i=o[a];if(!i||To(i,e.selection.focus)!==Za(i)||i.sdtWrappers?.length||i.list||i.numberingRevision||i.dropCap||i.style?.propertyRevision||i.runs.some(e=>e.revision||e.revisionRangeMarker||e.sdtWrappers?.length||e.styles?.propertyRevision))return;const s=Wo(o);return s.diagnostics.length?void 0:{sections:t,index:n,section:r,paragraphs:o,at:a,graph:s}}function WT(e,t,n=f){const r=jT(e);if(!(r&&function(e){const t=jT(e);if(!t||Object.keys(e.document.bookmarks?.items??{}).length||Object.keys(e.document.comments?.items??{}).length||(t.section.pageSettings.columns?.count??1)>1)return!1;if(t.graph.spans.some(e=>{const t=gI(e.code.map(e=>"instruction"===e.kind?e.raw:"").join(""));return void 0!==t?.captionIdentifier||void 0!==t?.unlabeledIdentifier}))return!1;for(const n of t.sections){if(n.blocks.some(e=>"paragraph"!==e.type))return!1;const e=Wo(n.blocks);if(e.diagnostics.length||e.spans.some(e=>{const t=gI(e.code.map(e=>"instruction"===e.kind?e.raw:"").join(""));return void 0!==t?.captionIdentifier||void 0!==t?.unlabeledIdentifier}))return!1}return!0}(e)&&t.identifier&&/^[A-Za-z_][A-Za-z0-9_ ]{0,63}$/.test(t.identifier)))return e;const o=t.unlabeled?` TOC \\a ${t.identifier} `:` TOC \\c "${t.identifier}" `;if(!gI(o))return e;const a=Ma("");a.runs=[HT("begin"),$T(o),HT("separate")];const i=Ma("");i.runs=[HT("end")];const s=function(e,t,n){return{...e,document:{...e.document,sections:t.sections.map((e,r)=>r===t.index?{...e,blocks:n}:e)}}}(e,r,[...r.paragraphs.slice(0,r.at+1),a,i,...r.paragraphs.slice(r.at+1)]),l=zT(s,n);return"updated"===l.status?l.state:e}function UT(e){const t=[];let n="",r=!1;for(let o=0;o<e.length;o++){const a=e[o];if("'"!==a)if(";"!==a||r)n+=a;else{if(!n)return;t.push(n),n=""}else r=!r,n+=a}if(!r&&n)return t.push(n),t.length<=3?t:void 0}function VT(e){let t="",n="",r="",o=!1,a=!1,i=!1;for(let s=0;s<e.length;s++){const l=e[s];if("'"===l){const r=e.indexOf("'",s+1);if(r<0)return;const a=e.slice(s+1,r);o?n+=a:t+=a,s=r;continue}if("0"!==l&&"#"!==l&&"x"!==l)if(!o||"."!==l&&","!==l)if("%"!==l){if(!/[\s+\-$€£¥()]/.test(l))return;o?n+=l:t+=l}else i=!0,o?n+=l:t+=l;else","===l&&(a=!0),r+=l;else r+=l,o=!0}return{prefix:t,suffix:n,mask:r,grouping:a,percent:i}}function _T(e){if(!e||e.length>256||[...e].some(e=>e.charCodeAt(0)<32||127===e.charCodeAt(0)))return!1;const t=UT(e);if(!t)return!1;const n=t.map(e=>VT(e));return n.every(e=>!!e)&&n.some(e=>/[0#x]/.test(e.mask))}function KT(e,t){if(!Number.isFinite(e)||!_T(t))return;const n=UT(t).map(e=>VT(e));let r,o=!1;1===n.length?(r=n[0],o=e<0&&!r.prefix.includes("-")):r=2===n.length?e<0?n[1]:n[0]:0===e?n[2]:e<0?n[1]:n[0];const a=function(e,t){if(!/[0#x]/.test(t.mask))return t.prefix+t.suffix;const n=t.mask.indexOf(".");if(n>=0&&t.mask.indexOf(".",n+1)>=0)return;const r=n<0?t.mask:t.mask.slice(0,n),o=n<0?"":t.mask.slice(n+1),a=(r.match(/0/g)??[]).length,i=(o.match(/0/g)??[]).length,s=(o.match(/x/g)??[]).length,l=(o.match(/[0#x]/g)??[]).length;if(a>21||l>20||l<i+s)return;let c,d=Math.abs(e);if(t.percent&&(d*=100),s>0){const e=10**s;d=Math.floor(d*e)/e}try{c=new Intl.NumberFormat("en-US",{useGrouping:t.grouping,minimumIntegerDigits:a||1,minimumFractionDigits:i,maximumFractionDigits:l}).format(d)}catch{return}return t.prefix+c+t.suffix}(e,r);return void 0===a?void 0:o?`-${a}`:a}var qT=/* @__PURE__ */new Set(["MERGEFORMAT","CHARFORMAT","Caps","FirstCap","Upper","Lower"]),XT=/* @__PURE__ */new Set(["alphabetic","ALPHABETIC","Arabic","CardText","DollarText","Hex","OrdText","Ordinal","roman","ROMAN"]);function GT(e,t){if(!e||"quoted"!==e.kind&&"word"!==e.kind)return;const n=e.value;return!n||n.length>256||[...n].some(e=>e.charCodeAt(0)<32||127===e.charCodeAt(0))?void 0:t(n)?n:void 0}var YT=/* @__PURE__ */new Set(["=","<>",">","<",">=","<="]),ZT=/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;function JT(e,t,n){if(r=n,!YT.has(r)||e.length>4096||t.length>4096||[...e+t].some(e=>e.charCodeAt(0)<32))return;var r;if(ZT.test(e)&&ZT.test(t)){const r=Number(e),o=Number(t);if(!Number.isFinite(r)||!Number.isFinite(o))return;switch(n){case"=":return r===o;case"<>":return r!==o;case">":return r>o;case"<":return r<o;case">=":return r>=o;case"<=":return r<=o}}if("="!==n&&"<>"!==n)return;if(!(e.includes("*")||e.includes("?")||t.includes("*")||t.includes("?")))return"="===n?e===t:e!==t;if(e.length+t.length>128)return;const o=(e=>e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\?/g,".").replace(/\*/g,".*"))(t.includes("*")||t.includes("?")?t:e),a=t.includes("*")||t.includes("?")?e:t;let i;try{i=new RegExp(`^${o}$`,"u").test(a)}catch{return}return"="===n?i:!i}var QT=e=>!!e&&e.length<=128&&/^[\p{L}_][\p{L}\p{N}_ .-]*$/u.test(e);function eP(e,t){const n=e[t];if(n&&"switch"!==n.kind){if("MERGEFIELD"===n.value){const n=e[t+1];if(!n||"switch"===n.kind||!QT(n.value))return;return{value:{kind:"mergeField",name:n.value},next:t+2}}if(!(n.value.length>4096||/[\r\n\t]/.test(n.value)))return{value:{kind:"literal",value:n.value,quoted:"quoted"===n.kind},next:t+1}}}function tP(e){const t=oo(e);if(t.error||!t.command)return;const n=t.tokens.slice(1);if("NEXT"===t.command)return n.length?void 0:{type:"NEXT"};if("NEXTIF"===t.command||"SKIPIF"===t.command){const e=eP(n,0),r=e&&n[e.next];if(!e||!r||"word"!==r.kind)return;const o=eP(n,e.next+1);if(!o||o.next!==n.length)return;return{type:t.command,left:e.value,operator:r.value,right:o.value}}if("MERGEFIELD"!==t.command)return;const r=n[0];if(!r||"switch"===r.kind||!QT(r.value))return;const o=function(e,t){const n={},r=[],o=/* @__PURE__ */new Set;for(let a=0;a<e.length;a++){const i=e[a];if("switch"!==i.kind){r.push(i);continue}const s=i.value;if("*"===s){if(!t.text&&!t.number){r.push(i);continue}const s=e[++a];if(!s||"word"!==s.kind)return;const l=s.value;if(qT.has(l)){if(!t.text||o.has("text"))return;o.add("text"),"MERGEFORMAT"===l?n.mergeFormat=!0:"CHARFORMAT"===l?n.charFormat=!0:n.capitalization=l}else if(XT.has(l)){if(!t.number||o.has("number"))return;o.add("number"),n.capitalization=l}else{if("ArabicDash"!==l)return;if(!t.arabicDash||o.has("number"))return;o.add("number"),n.capitalization="ArabicDash"}}else if("#"===s){if(!t.numericPicture){r.push(i);continue}if(o.has("numeric"))return;const s=GT(e[++a],_T);if(void 0===s)return;o.add("numeric"),n.numericPicture=s}else if("@"===s){if(!t.datePicture){r.push(i);continue}if(o.has("date"))return;const s=GT(e[++a],jo);if(void 0===s)return;o.add("date"),n.datePicture=s}else r.push(i)}return{switches:n,remaining:r}}(n.slice(1),{text:!0});if(!o)return;const a={type:"MERGEFIELD",name:r.value};for(let i=0;i<o.remaining.length;i++){const e=o.remaining[i];if("switch"!==e.kind)return;const t=e.value.toLowerCase();if("m"===t){if(a.mapped)return;a.mapped=!0;continue}if("v"===t){if(a.vertical)return;a.vertical=!0;continue}if("b"!==t&&"f"!==t)return;const n=o.remaining[++i];if(!n||"quoted"!==n.kind||n.value.length>4096)return;if("b"===t){if(void 0!==a.before)return;a.before=n.value}else{if(void 0!==a.after)return;a.after=n.value}}return Object.keys(o.switches).length&&(a.format=o.switches),a}function nP(e,t){return"mergeField"===e.kind?t[e.name]:e.quoted?e.value:t[e.value]??e.value}function rP(e,t){const n=t[e.name];if(void 0!==n)return n?`${e.before??""}${n}${e.after??""}`:""}function oP(e,t){if("NEXT"===e.type)return{advanceInPlace:!0,skipDocument:!1};if(!e.left||!e.right||!e.operator)return;const n=nP(e.left,t),r=nP(e.right,t);if(void 0===n||void 0===r)return;const o=JT(n,r,e.operator);return void 0!==o?"NEXTIF"===e.type?{advanceInPlace:o,skipDocument:!1}:{advanceInPlace:!1,skipDocument:o}:void 0}function aP(e){const t=[],n=/* @__PURE__ */new Set;for(const r of Si(e)){const e=[];for(const t of r.blocks){if("paragraph"!==t.type||n.has(t.id))return;n.add(t.id),e.push(t)}const o=Wo(e);if(o.diagnostics.length)return;for(const n of o.spans){const r=n.code.map(e=>"instruction"===e.kind?e.raw:"").join(""),o=oo(r);if("MERGEFIELD"!==o.command&&"NEXT"!==o.command&&"NEXTIF"!==o.command&&"SKIPIF"!==o.command)continue;const a=tP(r);if(!a||null!==n.parentIndex)return;t.push({span:n,paragraph:e[n.begin.paragraphIndex],instruction:a})}}return t}function iP(e){if("MERGEFIELD"===e.instruction.type)return!0;if(e.span.begin.paragraphIndex!==(e.span.end?.paragraphIndex??-1))return!1;const t=e.span.code.map(e=>"instruction"===e.kind?e.raw:"").join("");return!/NEXTIF|SKIPIF|\bNEXT\b/i.test(t.replace(/^\s*(?:NEXT|NEXTIF|SKIPIF)\b/i,""))}function sP(e,t){const n=aP(e);if(!n||!n.every(iP))return;const r=/* @__PURE__ */new Map,o=e=>{let t=r.get(e.id);return t||(t={...e,runs:e.runs.map(e=>({...e}))},r.set(e.id,t)),t};let a=null;for(const{span:s,paragraph:l,instruction:c}of n){const e=o(l);if("MERGEFIELD"===c.type){const n=rP(c,t);if(void 0===n)return;for(const t of s.result){if("run"!==t.kind)return;const r=e.runs[t.point.runIndex];if(!r)return;r.text=n}}else{const n=oP(c,t);if(!n)return;a??=n;for(const t of s.result){if("run"!==t.kind)return;e.runs[t.point.runIndex].text=""}}}const i=Si(e).map(e=>({...e,blocks:e.blocks.map(e=>"paragraph"===e.type?r.get(e.id)??e:e)}));return{document:{...e,sections:i},decision:a}}function lP(e,t,n=!1){return"paragraph"!==e.type?e:{...e,id:`${e.id}${t}`,...n?{style:{...e.style,pageBreakBefore:!0}}:{},runs:e.runs.map(e=>({...e,id:`${e.id}${t}`}))}}function cP(e,t,n){const r=/* @__PURE__ */new Map;for(const[o,a]of t.entries())for(const e of Si(a))for(const t of e.blocks)if("paragraph"===t.type&&n.has(t.id)){const e=r.get(t.id)??[];e.push(lP(t,`:merge:${o}`,o>0)),r.set(t.id,e)}return{...e,sections:Si(e).map(e=>({...e,blocks:e.blocks.flatMap(e=>"paragraph"===e.type&&n.has(e.id)?r.get(e.id)??[e]:[e])}))}}function dP(e,t){if(e)return function(e,t){if(!Array.isArray(e)||e.length>1e3)return;const n=aP(t);if(!n||!n.every(iP))return;const r=new Set(n.map(e=>e.paragraph.id)),o=[];let a=[];for(const i of e){const e=sP(t,i);if(!e)return;e.decision?.skipDocument?a=[]:(a.push(e.document),e.decision?.advanceInPlace||(o.push(cP(t,a,r)),a=[]))}return a.length&&o.push(cP(t,a,r)),o}(t,e.document)}var uP={ABS:1,INT:1,ROUND:2,SIGN:1,MOD:2,MIN:-1,MAX:-1,SUM:-1,PRODUCT:-1,AVERAGE:-1,COUNT:-1,AND:-1,OR:-1,NOT:1,TRUE:0,FALSE:0,DEFINED:1},pP=e=>"number"==typeof e&&Number.isFinite(e)&&Math.abs(e)<=1e12;function fP(e,t={},n=0){if(n>32||"string"!=typeof e)return;const r=function(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(/\s/.test(r)){n++;continue}if(t.length>=256)return;if(/[0-9.]/.test(r)){let r=n;for(;r<e.length&&/[0-9.]/.test(e[r]);)r++;const o=e.slice(n,r);if(!/^(?:\d+(?:\.\d*)?|\.\d+)$/.test(o))return;t.push({kind:"number",value:o}),n=r;continue}if(/[\p{L}_]/u.test(r)){let r=n;for(;r<e.length&&/[\p{L}\p{N}_.]/u.test(e[r]);)r++;t.push({kind:"identifier",value:e.slice(n,r)}),n=r;continue}if("()".includes(r)){t.push({kind:"paren",value:r}),n++;continue}if(","===r||";"===r){t.push({kind:"comma",value:r}),n++;continue}const o=e.slice(n,n+2);if(["<=",">=","<>"].includes(o))t.push({kind:"operator",value:o}),n+=2;else{if(!["+","-","*","/","%","^","=","<",">"].includes(r))return;t.push({kind:"operator",value:r}),n++}}return t.length?t:void 0}(e);if(!r)return;let o=0;const a=()=>r[o],i=()=>r[o++],s=e=>"boolean"==typeof e?e?1:0:pP(e)?e:void 0,l=()=>{const e=i();if(!e)return;if("number"===e.kind)return Number(e.value);if("paren"===e.kind){const e=f();return"paren"===a()?.kind&&")"===a()?.value?(i(),e):void 0}if("identifier"!==e.kind)return;const n=e.value.toUpperCase();if("paren"!==a()?.kind||"("!==a()?.value)return(e=>{const n=e.toLowerCase(),r=t.variables?.[n]??t.variables?.[e]??t.record?.[e];if(void 0!==r)return"TRUE"===r||"true"===r||"FALSE"!==r&&"false"!==r&&(pP(Number(r))?Number(r):void 0)})(e.value);if(!(n in uP))return;i();const r=a()?.value,o=[];if(")"===a()?.value)i();else for(;;){const e=f();if(void 0===e)return;o.push(e);const t=a();if("comma"!==t?.kind){if("paren"===t?.kind&&")"===t.value){i();break}return}i()}const l=uP[n];if(l>=0&&o.length!==l)return;const c=o.map(s);switch(n){case"TRUE":return!0;case"FALSE":return!1;case"DEFINED":{const e=r??"";return void 0!==t.variables?.[e.toLowerCase()]||void 0!==t.variables?.[e]||void 0!==t.record?.[e]}case"NOT":return!s(c[0]);case"AND":return o.every(e=>!!s(e));case"OR":return o.some(e=>!!s(e));case"ABS":return Math.abs(c[0]);case"INT":return Math.trunc(c[0]);case"SIGN":return Math.sign(c[0]);case"MOD":return c[0]%c[1];case"ROUND":{const e=c[1]??0;if(!Number.isSafeInteger(e)||e<0||e>10)return;const t=10**e;return Math.round(c[0]*t)/t}case"MIN":return Math.min(...c);case"MAX":return Math.max(...c);case"SUM":return c.reduce((e,t)=>e+t,0);case"PRODUCT":return c.reduce((e,t)=>e*t,1);case"AVERAGE":return c.reduce((e,t)=>e+t,0)/c.length;case"COUNT":return c.length;default:return}},c=()=>{const e=a();if("operator"===e?.kind&&("+"===e.value||"-"===e.value)){i();const t=s(c());return void 0===t?void 0:"-"===e.value?-t:t}return l()},d=()=>{const e=s(c());if(void 0!==e){if("operator"===a()?.kind&&"^"===a()?.value){i();const t=s(c());if(void 0===t||!Number.isSafeInteger(t)||Math.abs(t)>64)return;return e**t}return e}},u=()=>{let e=s(d());if(void 0!==e){for(;;){const t=a();if("operator"!==t?.kind||!["*","/","%"].includes(t.value))break;i();const n=s(d());if(void 0===n)return;if(e="*"===t.value?e*n:"/"===t.value?0===n?void 0:e/n:e%n,void 0===e||!pP(e))return}return e}},p=()=>{let e=s(u());if(void 0!==e){for(;;){const t=a();if("operator"!==t?.kind||!["+","-"].includes(t.value))break;i();const n=s(u());if(void 0===n)return;if(e="+"===t.value?e+n:e-n,!pP(e))return}return e}},f=()=>{let e=p();if(void 0!==e){for(;;){const t=a();if(!t)break;if("identifier"===t.kind&&["AND","OR"].includes(t.value.toUpperCase())){i();const n=p();if(void 0===n)return;e="AND"===t.value.toUpperCase()?!!s(e)&&!!s(n):!!s(e)||!!s(n);continue}if("operator"!==t.kind||!["=","<>","<","<=",">",">="].includes(t.value))break;i();const n=p();if(void 0===n)return;switch(t.value){case"=":e=e===n;break;case"<>":e=e!==n;break;case"<":e=s(e)<s(n);break;case"<=":e=s(e)<=s(n);break;case">":e=s(e)>s(n);break;case">=":e=s(e)>=s(n);break;default:return}}return e}},g=f();return o===r.length?g:void 0}var gP=e=>!!e&&e.length<=128&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e),mP=(e,t=4096)=>e&&("quoted"===e.kind||"word"===e.kind)&&e.value.length<=t&&![...e.value].some(e=>e.charCodeAt(0)<32)?e.value:void 0;function hP(e){const t=oo(e);if(t.error||!t.command)return;const n=t.tokens.slice(1);if("SET"===t.command){const e=n[0],t=n[1];if(!e||!gP(e.value)||2!==n.length||"quoted"!==t?.kind&&"word"!==t?.kind)return;const r=mP(t);return void 0===r?void 0:{type:"SET",name:e.value,value:r}}if("ASK"===t.command||"FILLIN"===t.command){const e="ASK"===t.command,r=n[0],o=e?mP(n[1]):void 0===r?"":mP(r);if(void 0===o)return;let a,i,s=!1,l=e?2:1;if(e){if(!r||!gP(r.value))return;a=r.value}const c=/* @__PURE__ */new Set;for(;l<n.length;l++){const e=n[l];if("switch"!==e.kind)return;const t=e.value.toLowerCase();if(c.has(t))return;if(c.add(t),"o"===t){if(s)return;s=!0;continue}if("d"!==t)return;const r=n[++l],o="quoted"===r?.kind?mP(r):void 0;if(void 0===o||void 0!==i)return;i=o}return e?{type:"ASK",name:a,prompt:o,...void 0!==i?{defaultValue:i}:{},once:s}:{type:"FILLIN",prompt:o,...void 0!==i?{defaultValue:i}:{},once:s}}if("COMPARE"===t.command){const e=n[0],t=n[1],r=n[2];if(!e||!t||!r||3!==n.length||"word"!==t.kind||"switch"===e.kind||"switch"===r.kind)return;const o=mP(e),a=mP(r);if(void 0===o||void 0===a)return;return{type:"COMPARE",left:o,right:a,operator:t.value,quoted:["quoted"===e.kind,"quoted"===r.kind]}}if("="===t.command){const e=n.findIndex(e=>"switch"===e.kind&&"#"===e.value),t=e<0?n:n.slice(0,e);if(!t.length||t.some(e=>"switch"===e.kind))return;const r=t.map(e=>e.raw).join(" ");if(r.length>4096)return;let o;if(e>=0){if(e!==n.length-2||"quoted"!==n[e+1]?.kind)return;if(o=mP(n[e+1],256),!o||!_T(o))return}return{type:"FORMULA",expression:r,...o?{picture:o}:{}}}}function bP(e,t,n){const r=e.toLowerCase();return n[r]??t.variables?.[r]??t.record?.[e]}function yP(e,t,n,r){const o=()=>({text:r,variables:n,status:"preserved"});if("SET"===e.type){const r=bP(e.value,t,n)??e.value;return{text:"",variables:{...n,[e.name.toLowerCase()]:r},status:"resolved"}}if("ASK"===e.type){if(!t.prompt)return o();const r=t.prompt(e.prompt,e.defaultValue);return void 0===r||r.length>4096||/[\r\n\t]/.test(r)?o():{text:"",variables:{...n,[e.name.toLowerCase()]:r},status:"resolved"}}if("FILLIN"===e.type){if(!t.prompt)return o();const r=t.prompt(e.prompt,e.defaultValue);return void 0===r||r.length>4096||/[\r\n\t]/.test(r)?o():{text:r,variables:n,status:"resolved"}}if("COMPARE"===e.type){const r=JT(e.quoted[0]?e.left:bP(e.left,t,n)??e.left,e.quoted[1]?e.right:bP(e.right,t,n)??e.right,e.operator);return void 0===r?o():{text:r?"1":"0",variables:n,status:"resolved"}}const a={...t.variables,...n,...t.record},i=fP(e.expression,{variables:a});if(void 0===i)return o();const s="boolean"==typeof i?i?1:0:i,l=e.picture?KT(s,e.picture):String(s);return void 0===l?o():{text:l,variables:n,status:"resolved"}}function vP(e,t){if("main"===Yo(e)&&!e.trackChangesEnabled&&t)for(const n of Si(e.document)){const e=[];for(const t of n.blocks){if("paragraph"!==t.type)return;e.push(t)}const r=Wo(e);if(r.diagnostics.length)return;for(const n of r.spans){const r=e[n.begin.paragraphIndex],o=r.runs.find(e=>e.id===n.begin.runId);if("fieldChar"!==o?.kind||o.fieldChar.formField?.name!==t)continue;if(null!==n.parentIndex||!n.separator||!n.end||n.code.some(e=>"instruction"!==e.kind)||n.result.some(e=>"run"!==e.kind))return;const a=o.fieldChar.formField;return{name:t,control:a.control,value:a.value,enabled:a.enabled,paragraphId:r.id,beginRunId:o.id,resultRunIds:n.result.map(e=>"run"===e.kind?e.point.runId:"")}}}}function xP(e,t){if("string"!=typeof t||t.length>4096||[...t].some(e=>e.charCodeAt(0)<32))return!1;if("text"===e.control){const n=e.textInput?.maxLength;return!(void 0!==n&&t.length>n)&&!("number"===e.textInput?.type&&t&&!/^-?(?:\d+)(?:\.\d+)?$/.test(t))}return"checkBox"===e.control?""===t||"x"===t:(e.ddList?.listEntries??[]).includes(t)}function wP(e,t,n){const r=vP(e,t);if(!r||!r.enabled)return e;const o=Si(e.document);for(const[a,i]of o.entries()){const t=i.blocks.findIndex(e=>e.id===r.paragraphId);if(t<0)continue;const s=i.blocks[t],l=s.runs.find(e=>e.id===r.beginRunId);if("fieldChar"!==l?.kind||!l.fieldChar.formField||!xP(l.fieldChar.formField,n))return e;const c=s.runs.map(e=>{if(e.id===r.beginRunId&&"fieldChar"===e.kind){const t=e.fieldChar.formField;return{...e,fieldChar:{...e.fieldChar,formField:{...t,value:n,..."checkBox"===t.control?{checkBox:{...t.checkBox,checked:"x"===n}}:{}}}}}return r.resultRunIds.includes(e.id)?{...e,text:e.id===r.resultRunIds[0]?n:""}:e}),d={...s,runs:c},u=[...i.blocks];return u[t]=d,{...e,document:{...e.document,sections:o.map((e,t)=>t===a?{...e,blocks:u}:e)}}}return e}function IP(e,t){const n=t.type??"REF",r=function(e,t){return hk(e).find(e=>e.name===t)}(e,t.bookmark);if(!r)return e;const o=ri(e.selection)?e:te(e),{paragraph:a,index:i,offset:s}=ae(o),l=Qn(a,s),c={type:n,bookmark:t.bookmark},d="REF"===n?Y(e.document).bookmarkText(r.name):void 0,p={id:`run:${n.toLowerCase()}:${Math.random().toString(36).slice(2,9)}`,text:d&&!/[\r\n]/.test(d)?d:"1",kind:"field",field:c,styles:l},f=u(a,[...sn(a,0,s),p,...sn(a,s,Za(a))]),g=xi(o),m=[...ho(g.slice(0,i)),f,...ho(g.slice(i+1))];return Cn(o,m,J(Xo(f,s+p.text.length)))}function SP(e){const t=()=>!e.isReadOnly()&&"main"===Yo(e.state())&&!e.state().trackChangesEnabled,n=n=>{if(!t())return;e.resetTransactionGrouping();const r={now:Date.now(),timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone};e.applyTransactionalState(e=>Pk(e,void 0,n,r).state),e.clearPreferredColumn(),e.focusInput()},r=(t,n)=>{if(e.isReadOnly()||!t(e.state()))return!1;let r=!1;return e.resetTransactionGrouping(),e.applyTransactionalState(o=>{if(e.isReadOnly()||!t(o))return o;const a=n(o);return r=a!==o,a}),r&&(e.clearPreferredColumn(),e.focusInput()),r},o=t=>{if(e.isReadOnly())return!1;let n=!1;return e.resetTransactionGrouping(),e.applyTransactionalState(e=>{const r=t(e);return n=r!==e,r}),n&&(e.clearPreferredColumn(),e.focusInput()),n};return{canMarkIndexEntry:()=>!e.isReadOnly()&&tT(e.state()),canInsertIndex:()=>!e.isReadOnly()&&nT(e.state()),canUpdateIndex:()=>!e.isReadOnly()&&rT(e.state()),markIndexEntry:e=>r(tT,t=>function(e,t){const n=Jk(e);if(!n||!eT(t.identifier)||!Array.isArray(t.path)||!t.path.length||t.path.some(e=>"string"!=typeof e||e.trim()!==e||!e||/[:;\\]/.test(e)||[...e].some(e=>e.charCodeAt(0)<32||127===e.charCodeAt(0))))return e;if(!tT(e))return e;const r=' XE "'+t.path.join(":").replace(/"/g,'\\"')+'"'+(t.identifier?" \\f "+t.identifier:"")+(t.boldPage?" \\b":"")+(t.italicPage?" \\i":"")+" ";if(!Mk(r))return e;const o={...n.p,runs:[...n.p.runs,Zk("begin",!0),Yk(r,!0),Zk("end",!0)]},a=Qk(e,n,n.paragraphs.map((e,t)=>t===n.at?o:e));return Ak(a.document)?a:e}(t,e)),insertIndex:e=>r(nT,t=>function(e,t,n=f){const r=Jk(e);if(!r||!eT(t.identifier)||"string"!=typeof t.locale||!/^[A-Za-z]{2,3}(?:-[A-Za-z]{2})?$/.test(t.locale)||Object.keys(e.document.bookmarks?.items??{}).length||Object.keys(e.document.comments?.items??{}).length)return e;if(!nT(e))return e;const o=' INDEX \\z "'+t.locale+'"'+(t.identifier?" \\f "+t.identifier:"")+" ";if(!Lk(o))return e;const a=Ma("");a.runs=[Zk("begin"),Yk(o),Zk("separate")];const i=Ma("");i.runs=[Zk("end")];const s=Gk(Qk(e,r,[...r.paragraphs.slice(0,r.at+1),a,i,...r.paragraphs.slice(r.at+1)]),void 0,n);return"updated"===s.status?s.state:e}(t,e)),updateIndex:e=>r(rT,t=>function(e,t){const n=Gk(e,t);return"updated"===n.status?n.state:e}(t,e)),canUpdateBodyFields:t,updateBodyFields:()=>n("all"),updateSelectedFields:()=>n("selection"),insertFieldCode:e=>o(t=>function(e,t){if("string"!=typeof t||oo(t).error||Vn(e))return e;const n=ri(e.selection)?e:te(e),{paragraph:r,index:o,offset:a}=ae(n),i=Qn(r,a),s={id:oT("run:instr"),kind:"fieldInstruction",text:"",fieldInstruction:t,styles:i?{...i}:void 0},l={id:oT("run:fld"),kind:"fieldChar",text:"",fieldChar:{kind:"begin",dirty:!0},styles:i?{...i}:void 0},c=aT("separate",i),d=aT("end",i),u={id:oT("run:result"),kind:"text",text:"",styles:i?{...i}:void 0},p={...r,runs:[...sn(r,0,a),l,s,c,u,d,...sn(r,a,Za(r))]},f=xi(n);return Cn(n,[...ho(f.slice(0,o)),p,...ho(f.slice(o+1))],J(Xo(p,a)))}(t,e)),editFieldCode:(e,t)=>o(n=>sT(n,e,t)),editFieldCodeAtSelection:e=>o(t=>{const n=function(e){const t=xi(e),n=Wo(t);if(n.diagnostics.length)return;const{anchor:r}=e.selection,o=n.spans.find(e=>null===e.parentIndex&&e.begin.paragraphId===r.paragraphId&&e.end&&e.begin.offset<=r.offset&&e.end.offset>=r.offset);return o&&!o.code.some(e=>"instruction"!==e.kind)?o.code.find(e=>"instruction"===e.kind)?.point.runId:void 0}(t);return n?sT(t,n,e):t}),toggleFieldLock:e=>o(t=>function(e,t){const n=xi(e),r=Wo(n);if(r.diagnostics.length)return e;const o=r.spans.find(e=>null===e.parentIndex&&e.begin.runId===t&&!!e.separator&&!!e.end&&e.begin.paragraphIndex===e.end.paragraphIndex);if(!o)return e;const a=n[o.begin.paragraphIndex].runs.find(e=>e.id===o.begin.runId);return a&&"fieldChar"===a.kind?iT(e,o.begin.paragraphIndex,/* @__PURE__ */new Map([[a.id,{...a,fieldChar:{...a.fieldChar,fieldLock:!a.fieldChar.fieldLock||void 0}}]])):e}(t,e)),toggleFieldCodes:t=>e.applyState(function(e,t){return e.showFieldCodes===t?e:{...e,showFieldCodes:t}}(e.state(),t)),navigateField:t=>e.applyState(function(e,t){const n=xi(e),r=Wo(n);if(r.diagnostics.length)return e;const o=r.spans.filter(e=>null===e.parentIndex&&!!e.separator&&!!e.end);if(o.length<2)return e;const{anchor:a}=e.selection,i=o.findIndex(e=>n[e.begin.paragraphIndex]?.id===a.paragraphId&&e.begin.offset<=a.offset&&(e.end?.offset??0)>=a.offset),s="next"===t?o[i<0?0:(i+1)%o.length]:o[i<0?o.length-1:(i-1+o.length)%o.length],l=n[s.begin.paragraphIndex];return{...e,selection:J(Xo(l,s.begin.offset))}}(e.state(),t)),markAuthorityEntry:e=>o(t=>RT(t,e)),insertTableOfAuthorities:e=>o(t=>MT(t,e)),updateTableOfAuthorities:e=>o(t=>function(e,t){const n=wT(e,t);return"updated"===n.status?n.state:e}(t,e)),insertTableOfFigures:e=>o(t=>WT(t,e)),updateTableOfFigures:()=>o(e=>function(e){const t=zT(e);return"updated"===t.status?t.state:e}(e)),previewMergeRecord:(e,t)=>o(n=>function(e,t,n){if(!e||!Array.isArray(t)||!Number.isSafeInteger(n)||n<0||n>=t.length||t.length>1e3)return e;const r=sP(e.document,t[n]);return r?{...e,document:r.document}:e}(n,e,t)),mergeToNewDocuments:t=>dP(e.state(),t)?.length??0,updateVariableFields:()=>{let t=!1;return e.applyTransactionalState(e=>{const n=function(e,t={}){if("main"!==Yo(e)||e.trackChangesEnabled)return{state:e,updated:0,variables:{}};let n={...t.variables},r=0;const o=/* @__PURE__ */new Map,a=Si(e.document),i=[];for(const[l,c]of a.entries()){const t=[];for(const o of c.blocks){if("paragraph"!==o.type)return{state:e,updated:0,variables:n};t.push(o)}const r=Wo(t);if(r.diagnostics.length)return{state:e,updated:0,variables:n};for(const e of r.spans){const n=e.code.map(e=>"instruction"===e.kind?e.raw:"").join("");if(!hP(n)||null!==e.parentIndex||!e.separator||!e.end||e.code.some(e=>"instruction"!==e.kind)||e.beginMarker.fieldLock)continue;const r=t[e.begin.paragraphIndex];i.push({sectionIndex:l,paragraph:r,raw:n,runIds:e.result.flatMap(e=>"run"===e.kind?[e.point.runId]:[]),locked:!!e.beginMarker.fieldLock})}}for(const l of i){const e=yP(hP(l.raw),t,n,l.paragraph.runs.filter(e=>l.runIds.includes(e.id)).map(e=>e.text).join(""));if(n=e.variables,"preserved"===e.status)continue;let a=o.get(l.paragraph.id);a||(a={...l.paragraph,runs:l.paragraph.runs.map(e=>({...e}))},o.set(a.id,a));for(const t of l.runIds){const n=a.runs.find(e=>e.id===t);n&&(n.text=t===l.runIds[0]?e.text:"")}r++}const s=a.map(e=>({...e,blocks:e.blocks.map(e=>"paragraph"===e.type?o.get(e.id)??e:e)}));return{state:{...e,document:{...e.document,sections:s}},updated:r,variables:n}}(e,{prompt:(e,t)=>"undefined"==typeof window?void 0:window.prompt(e,t??"")??void 0});return t=n.updated>0,n.state}),t},setFormFieldValue:(e,t)=>o(n=>wP(n,e,t)),toggleFormCheckbox:e=>o(t=>function(e,t){const n=vP(e,t);return n&&"checkBox"===n.control?wP(e,t,"x"===n.value?"":"x"):e}(t,e)),insertDate:()=>{e.applyTransactionalState(e=>function(e,t={}){const n=(t.dateFormat??"M/d/yyyy").trim(),r=t.value??/* @__PURE__ */new Date,o=ri(e.selection)?e:te(e),{paragraph:a,index:i,offset:s}=ae(o),l=Qn(a,s),c=n.length>0&&"M/d/yyyy"!==n?{type:"DATE",dateFormat:n}:{type:"DATE"},d={id:`run:date:${Math.random().toString(36).slice(2,9)}`,text:xk(r,n),kind:"field",field:c,styles:l},p=u(a,[...sn(a,0,s),d,...sn(a,s,Za(a))]),f=xi(o),g=[...ho(f.slice(0,i)),p,...ho(f.slice(i+1))],m=d.text.length;return Cn(o,g,J(Xo(p,s+m)))}(e)),e.focusInput()},insertDateTime:t=>{e.applyTransactionalState(e=>function(e,t="M/d/yyyy",n=/* @__PURE__ */new Date){const r=xk(n,t);return 0===r.length?e:np(e,r)}(e,t)),e.focusInput()},insertCrossReference:t=>{e.applyTransactionalState(e=>IP(e,t)),e.focusInput()}}}function CP(e){let t=!1,n=!1;const r=(t,n)=>{e.applyTransactionalState(t,{mergeKey:n}),e.focusInput()},o={firstRow:!1,lastRow:!1,firstCol:!1,lastCol:!1,noHBand:!1,noVBand:!1},a=e=>{const t=ya(e),n=wo(e.document,e.selection.focus.paragraphId,t);if(!n)return null;const r=function(e,t,n){if("footnote"===n){const t=e.activeFootnoteId;return t?e.document.footnotes?.items[t]?.blocks??null:null}const r=Si(e.document)[t];return r?"header"===n?r.header??[]:"footer"===n?r.footer??[]:r.blocks:null}(e,t,n.zone);if(!r)return null;const o=bo(r,n.tablePath);return o?.[o.length-1]?.table??null},i=e=>{const t=a(e);if(!t)return null;const n=Ga(t,e.document.styles);return{...o,...n.tblLook??{}}};return{insideTable:()=>Boolean(wo(e.state().document,e.state().selection.focus.paragraphId,ya(e.state()))),selectionLabel:()=>{const t=e.state();if(sa(t).isCollapsed)return null;const n=ya(t),r=wo(t.document,t.selection.anchor.paragraphId,n),o=wo(t.document,t.selection.focus.paragraphId,n),a=r?.tablePath[r.tablePath.length-1],i=o?.tablePath[o.tablePath.length-1];if(!r||!o||!a||!i||r.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 r=e[n],o=t[n];if(r.tableBlockIndex!==o.tableBlockIndex)return!1;if(n<e.length-1&&(r.rowIndex!==o.rowIndex||r.cellIndex!==o.cellIndex))return!1}return!0}(r.tablePath,o.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=>r(t=>{const n=i(t);if(!n)return t;const r={...n};switch(e){case"firstRow":r.firstRow=!n.firstRow;break;case"lastRow":r.lastRow=!n.lastRow;break;case"firstCol":r.firstCol=!n.firstCol;break;case"lastCol":r.lastCol=!n.lastCol;break;case"bandedRows":r.noHBand=!n.noHBand;break;case"bandedCols":r.noVBand=!n.noVBand}return Ug(t,"tblLook",r)},Yf),getStyleId:()=>a(e.state())?.style?.styleId??null,setStyleId:e=>r(t=>Ug(t,"styleId",e||null),Zf),getLayout:()=>a(e.state())?.style?.layout??null,toggleAutoFit:()=>r(e=>Ug(e,"layout","autofit"===a(e)?.style?.layout?"fixed":"autofit"),Jf),canSetAutoFit:()=>null!==Tg(e.state()),setAutoFit:e=>r(t=>function(e,t){const n="fixed"===t?"fixed":"autofit";return Ng(e,r=>{let o=r.style;e.trackChangesEnabled&&!o?.revision&&(o={...o??{},revision:{...xg(),type:"property",previous:{...o??{}}}});let a=wg(o,"layout",n);return"window"===t?a=wg(a,"width","100%"):"contents"===t&&(a=wg(a,"width",null)),{...r,style:a}})}(t,e),_f),distributeColumns:()=>r(e=>Ng(e,e=>{const t=Vo(e),n=Math.max(1,...t.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),r=(e.gridCols??[]).reduce((e,t)=>e+("number"==typeof t&&t>0?t:0),0),o=r>0?r:120*n,a=o/n,i=Array.from({length:n},()=>a),s=e.rows.map((e,n)=>({...e,cells:e.cells.map((e,r)=>{const o=t.find(e=>e.rowIndex===n&&e.cellIndex===r);return o?{...e,style:{...e.style??{},width:a*Math.max(1,o.colSpan)}}:e})}));return{...e,gridCols:i,rows:s,style:{...e.style??{},width:o}}}),Jf),distributeRows:()=>r(e=>Ng(e,e=>{let t=0;for(const r of e.rows){const e=r.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}}),Jf),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!==Tg(e.state()),convertToText:()=>r(e=>Yg(e),zf),canConvertToTable:()=>{return!Tg(t=e.state())&&null!==Eg(t);var t},convertToTable:()=>r(e=>Zg(e),$f),canSplitTableAtRow:()=>function(e){const t=Tg(e);if(!t)return!1;const n=Fg(e);if(!n)return!1;const r=Og(n,t.loc.tablePath);if(!r)return!1;const o=t.loc.rowIndex;return o>0&&o<r.rows.length}(e.state()),splitTableAtRow:()=>r(e=>function(e){const t=Tg(e);if(!t)return e;const n=Fg(e);if(!n)return e;const r=Og(n,t.loc.tablePath);if(!r)return e;const o=t.loc.rowIndex;if(o<=0||o>=r.rows.length)return e;const a=r.rows.slice(0,o),i=r.rows.slice(o),s={...r,rows:a},l=no(i),c=Lg(e,[s,Ma(""),l]);if(c===e)return e;const d=l.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return d?{...c,selection:J(Xo(d,0))}:e}(e),Hf),canSortTable:()=>function(e){const t=Tg(e);if(!t)return!1;const n=Fg(e);if(!n)return!1;const r=Og(n,t.loc.tablePath);return!!r&&function(e){let t=0;for(const n of e)n.isHeader||(t+=1);return t}(r.rows)>=2}(e.state()),sortTable:e=>r(t=>Qg(t,e),"ascending"===e?jf:Wf),canDeleteTable:()=>null!==Tg(e.state()),deleteTable:()=>r(e=>function(e){const t=Tg(e);if(!t)return e;const n=Fg(e);if(!n)return e;const r=t.loc.tablePath[0]?.tableBlockIndex;if(void 0===r||"table"!==n[r]?.type)return e;if(1===n.length){const t=Ma(""),n=Lg(e,[t]);return n===e?e:{...n,selection:J(Xo(t,0))}}const o=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,r),a=Lg(e,[]);if(a===e)return e;if(o){const e=xi(a).find(e=>e.id===o);if(e)return{...a,selection:J(Xo(e,0))}}return a}(e),Uf),canToggleRepeatHeaderRows:()=>function(e){const t=Tg(e);if(!t)return!1;const n=Fg(e);if(!n)return!1;const r=Og(n,t.loc.tablePath);return null!==r&&r.rows.length>0}(e.state()),isRepeatHeaderRowsActive:()=>function(e){const t=Tg(e);if(!t)return!1;const n=Fg(e);if(!n)return!1;const r=Og(n,t.loc.tablePath);return!(!r||0===r.rows.length)&&tm(r.rows[0])}(e.state()),toggleRepeatHeaderRows:()=>r(e=>function(e){const t=Tg(e);if(!t)return e;const n=Fg(e);if(!n)return e;const r=Og(n,t.loc.tablePath);if(!r||0===r.rows.length)return e;const o=tm(r.rows[0]);return Ng(e,e=>({...e,rows:e.rows.map((e,t)=>0!==t?e:o?{...e,isHeader:void 0}:{...e,isHeader:!0})}))}(e),Kf),merge:()=>r(t=>e.tableOps.mergeSelectedTable(t),Sf),split:()=>r(t=>e.tableOps.splitSelectedTable(t),Cf),insertColumnBefore:()=>r(t=>e.tableOps.insertSelectedTableColumn(t,-1),kf),insertColumnAfter:()=>r(t=>e.tableOps.insertSelectedTableColumn(t,1),kf),deleteColumn:()=>r(t=>e.tableOps.deleteSelectedTableColumn(t),Tf),insertRowBefore:()=>r(t=>e.tableOps.insertSelectedTableRow(t,-1),Pf),insertRowAfter:()=>r(t=>e.tableOps.insertSelectedTableRow(t,1),Pf),deleteRow:()=>r(t=>e.tableOps.deleteSelectedTableRow(t),Rf),canDeleteCell:()=>mm(e.state()),deleteCell:()=>r(e=>hm(e),Vf),cellShading:e=>r(t=>jg(t,"shading",e||null),Mf),cellBorders:()=>r(e=>Wg(e,{width:1,type:"solid",color:"#64748b"}),Af),cellNoBorders:()=>r(e=>Wg(e,{width:0,type:"none",color:"transparent"}),Af),applyBorderPreset:e=>r(t=>function(e,t,n=zg){const r=Hg(e);if(!r)return e;const o=/* @__PURE__ */new Map,a=new Set(r.selectedEntries.map(e=>e.cell.id)),i=/* @__PURE__ */new Map;for(const m of r.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,r=n)=>{if(!e)return;const a=o.get(e.cell.id)??{};a[t]=r,o.set(e.cell.id,a)},l=(e,t,r,o,a=n)=>{s(e,t,a),r&&r.cell.id!==e?.cell.id&&s(r,o,a)},c=(e,t=n)=>{if("top"===e||"bottom"===e){const n="top"===e?r.startRow:r.endRow,o=n+("top"===e?-1:1);for(let s=r.startCol;s<=r.endCol;s+=1){const r=i.get(`${n}:${s}`);r&&a.has(r.cell.id)&&l(r,"top"===e?"borderTop":"borderBottom",i.get(`${o}:${s}`),"top"===e?"borderBottom":"borderTop",t)}return}const o="left"===e?r.startCol:r.endCol,s=o+("left"===e?-1:1);for(let n=r.startRow;n<=r.endRow;n+=1){const r=i.get(`${n}:${o}`);r&&a.has(r.cell.id)&&l(r,"left"===e?"borderLeft":"borderRight",i.get(`${n}:${s}`),"left"===e?"borderRight":"borderLeft",t)}},d=()=>{for(let e=r.startRow+1;e<=r.endRow;e+=1)for(let t=r.startCol;t<=r.endCol;t+=1){const n=i.get(`${e-1}:${t}`),r=i.get(`${e}:${t}`);n&&r&&n.cell.id!==r.cell.id&&a.has(n.cell.id)&&a.has(r.cell.id)&&l(n,"borderBottom",r,"borderTop")}},u=()=>{for(let e=r.startCol+1;e<=r.endCol;e+=1)for(let t=r.startRow;t<=r.endRow;t+=1){const n=i.get(`${t}:${e-1}`),r=i.get(`${t}:${e}`);n&&r&&n.cell.id!==r.cell.id&&a.has(n.cell.id)&&a.has(r.cell.id)&&l(n,"borderRight",r,"borderLeft")}};switch(t){case"none":for(const e of r.selectedEntries)for(const t of["borderTop","borderRight","borderBottom","borderLeft","borderStart","borderEnd","borderTopLeftToBottomRight","borderTopRightToBottomLeft"])s(e,t,$g);c("top",$g),c("right",$g),c("bottom",$g),c("left",$g);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 r.selectedEntries)s(e,"borderTopLeftToBottomRight");break;case"diagonalUp":for(const e of r.selectedEntries)s(e,"borderTopRightToBottomLeft")}if(0===o.size)return e;const p=/* @__PURE__ */new Set;for(const m of r.entries)if(o.has(m.cell.id))for(const e of m.cell.blocks)for(const t of Mo(e))p.add(t.id);const f=t=>{const n=o.get(t.id);if(!n)return t;let r=t.style;e.trackChangesEnabled&&!r?.propertyRevision&&(r={...r??{},propertyRevision:{...xg(),type:"property",previous:{...r??{}}}});for(const[e,o]of Object.entries(n))r=wg(r,e,o);return{...t,style:r}},g=Si(e.document).map(e=>({...e,blocks:Kt(e.blocks,p,f),header:e.header?Kt(e.header,p,f):void 0,footer:e.footer?Kt(e.footer,p,f):void 0}));return{...e,document:{...e.document,sections:g}}}(t,e),Af),isDrawingBorders:()=>t,toggleDrawingBorders:()=>{t=!t,e.applyState({...e.state()})},isShowingGridlines:()=>n,toggleGridlines:()=>{n=!n,e.applyState({...e.state()})},width100:()=>r(e=>Ug(e,"width","100%"),Of),alignLeft:()=>r(e=>jg(e,"horizontalAlign","left"),Bf),alignCenter:()=>r(e=>jg(e,"horizontalAlign","center"),Bf),alignRight:()=>r(e=>jg(e,"horizontalAlign","right"),Bf),setCellAlignment:e=>r(t=>{return n=t,r=e.horizontal,o=e.vertical,jg(jg(n,"horizontalAlign",r),"verticalAlign",o);var n,r,o},Ff),getCellAlignmentState:()=>function(e){const t=Hg(e);if(!t||0===t.selectedEntries.length)return null;const n=t.selectedEntries.map(({cell:e})=>e.style?.horizontalAlign??"left"),r=t.selectedEntries.map(({cell:e})=>e.style?.verticalAlign??"top"),o=(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:o(n,["left","center","right"]),vertical:o(r,["top","middle","bottom"])}}(e.state()),setCellVerticalAlign:e=>r(t=>jg(t,"verticalAlign",e),Ef),setCellTextDirection:e=>r(t=>jg(t,"textDirection",e),Df),setCellWidth:e=>r(t=>function(e,t){return jg(e,"width",t)}(t,e),Lf),setCellNoWrap:e=>r(t=>function(e,t){return jg(e,"noWrap",t)}(t,e),Lf),setCellFitText:e=>r(t=>function(e,t){return jg(e,"fitText",t)}(t,e),Lf),canSetCellMargins:()=>null!==Tg(e.state()),setCellMargins:e=>r(t=>function(e,t){let n=e;return void 0!==t.top&&(n=jg(n,"paddingTop",t.top)),void 0!==t.right&&(n=jg(n,"paddingRight",t.right)),void 0!==t.bottom&&(n=jg(n,"paddingBottom",t.bottom)),void 0!==t.left&&(n=jg(n,"paddingLeft",t.left)),n}(t,e),qf),canSetCellSpacing:()=>nm(e.state()),setCellSpacing:e=>r(t=>function(e,t){return nm(e)?Ug(e,"cellSpacing",null===t||t<0?null===t?null:0:Math.round(2*t)/2):e}(t,e),qf),canSetTableIndent:()=>rm(e.state()),setTableIndent:e=>r(t=>function(e,t){return rm(e)?null===t||t<0||Number.isNaN(t)||!Number.isFinite(t)?Ug(e,"indentLeft",null):Ug(e,"indentLeft",Math.round(2*t)/2):e}(t,e),qf),canSetTableAlignment:()=>null!==Tg(e.state()),setTableAlignment:e=>r(t=>am(t,e),qf),canEvaluateTableFormula:()=>null!==Tg(e.state()),evaluateTableFormula:e=>r(t=>lm(t,e),Xf),canSelectTable:()=>null!==Tg(e.state()),selectTablePart:t=>e.applyState(fm(e.state(),t)),canSetActiveTableRowHeight:()=>null!==Tg(e.state()),setActiveTableRowHeight:e=>r(t=>function(e,t){let n=e;return n=_g(n,"height",t.height),void 0!==t.heightRule&&(n=_g(n,"heightRule",t.heightRule)),n}(t,e),Gf),canSetActiveTableRowBreakAcrossPages:()=>im(e.state()),setActiveTableRowBreakAcrossPages:e=>r(t=>function(e,t){return im(e)?_g(e,"cantSplit",null===t?null:!t):e}(t,e),Gf),canSetActiveTableRowHeader:()=>null!==Tg(e.state()),setActiveTableRowHeader:e=>r(t=>Kg(t,e),Kf),canSetActiveTableColumnWidth:()=>null!==Tg(e.state()),setActiveTableColumnWidth:e=>r(t=>function(e,t){const n=Tg(e);if(!n)return e;const{activeSectionIndex:r,loc:o}=n,a=Og(Cg(e.document,r,o.zone),o.tablePath);if(!a)return e;const i=Vo(a).find(e=>e.rowIndex===o.rowIndex&&e.cellIndex===o.cellIndex);if(!i)return e;const s=i.visualColumnIndex;return null===t?e:Gg(e,a.id,{[s]:t})}(t,e),Nf),canSetActiveTableWidth:()=>null!==Tg(e.state()),setActiveTableWidth:e=>r(t=>function(e,t){const n=Tg(e);if(!n)return e;const{activeSectionIndex:r,loc:o}=n,a=Og(Cg(e.document,r,o.zone),o.tablePath);return a?Vg(e,a.id,"width",t):e}(t,e),Of),insert:(t,n)=>e.tableOps.insertTableCommand(t,n)}}function kP(e){const t=t=>e.applyTransactionalState(t);return{applyTheme:e=>t(t=>WS(t,e)),setColorScheme:e=>t(t=>function(e,t){const n=$S[t]??$S.oasis,r=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 r=/^heading[1-9]$/i.test(e)||/title|quote/i.test(e);return[e,{...t,textStyle:{...t.textStyle??{},color:r?n.heading:n.color}}]}));return{...e,document:{...e.document,styles:r,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,r]=HS[t]??HS.aptos,o=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)?r: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:r.split(",")[0].trim()},minor:{...e.document.design?.themeData?.fonts?.minor??{},minorHAnsi:n.split(",")[0].trim()}}}},styles:o}}}(t,e)),setParagraphSpacing:e=>t(t=>function(e,t){const n={compact:[0,4],tight:[0,6],open:[0,10],relaxed:[4,12]},[r,o]=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:r,spacingAfter:o}}]:[e,t]));return{...e,document:{...e.document,design:{...e.document.design??{},paragraphSpacingId:t},styles:a}}}(t,e)),setEffects:e=>t(t=>jS(t,{effectsId:e,themeData:{...t.document.design?.themeData??{},sourceXml:void 0,effectsXml:void 0}})),setPageColor:e=>t(t=>function(e,t){return jS(e,{pageColor:t})}(t,e)),setWatermark:e=>t(t=>function(e,t){return jS(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 TP(e){return function(e){const t=(n=e.gate.isCommandEnabled,(e,t,r)=>({execute:t,refresh:()=>{const t=r?.()??{};return{...t,isEnabled:n(e)&&(t.isEnabled??!0)}}}));var n;const r=function(e){return(t,n,r)=>({execute:n,refresh:()=>({isEnabled:e(t),value:r()})})}(e.gate.isCommandEnabled),o=function(e){return(t,n,r)=>({execute:e=>(n(e),!0),refresh:()=>{const n=r?.()??{};return{...n,isEnabled:e(t)&&(n.isEnabled??!0)}}})}(e.gate.isCommandEnabled);return{name:"Essentials",commands:{...KS({gate:e.gate,style:e.style,selection:e.selection,history:e.history,formatting:e.formatting,dialog:e.dialog,link:e.link,command:t,valueCommand:r,actionCommand:o}),...qS({gate:e.gate,style:e.style,document:e.document,link:e.link,image:e.image,browser:e.browser,actionCommand:o}),...XS({style:e.style,paragraph:e.paragraph,section:e.section,valueCommand:r,actionCommand:o}),...eC({dialog:e.dialog,actionCommand:o}),...GS({gate:e.gate,headerFooter:e.headerFooter,command:t,actionCommand:o}),...JS({gate:e.gate,table:e.table,actionCommand:o,valueCommand:r}),...QS({design:e.design,actionCommand:o}),...YS({bookmark:e.bookmark,actionCommand:o}),...ZS({fields:e.fields,actionCommand:o})}}}({gate:oC(e),style:aC(e),selection:iC(e),history:sC(e),formatting:kC(e),document:DC(e),link:LC(e),image:NC(e),browser:zC(e),paragraph:QC(e),section:gk(e),headerFooter:mk(e),table:CP(e),design:kP(e),bookmark:bk(e),fields:SP(e),dialog:{openFontDialog:e.openFontDialog,openParagraphDialog:e.openParagraphDialog,requestAcceptAllRevisions:e.requestAcceptAllRevisions,requestRejectAllRevisions:e.requestRejectAllRevisions}})}var PP=[{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_update_selected_fields",path:"Tools/Update Selected Fields",labelKey:"menu.tools.updateSelectedFields",command:"updateSelectedFields",icon:"refresh-cw",shortcut:"F9"},{id:"tools_update_body_fields",path:"Tools/Update All Body Fields",labelKey:"menu.tools.updateBodyFields",command:"updateBodyFields",icon:"refresh-cw"},{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 RP(e){const t=TP(e.essentials),{runtimePlugins:n,toolbarRegistry:r,menuRegistry:o,dispose:a}=function(e){const t=[e.essentialsPlugin,...e.externalPlugins??[]],n=[],r=[],o=mr(),a=new wn;for(const i of ir(e.t))o.register(i);for(const i of PP)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};o.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}),r.push(e.id)}return e.customizeToolbar?.(o),e.customizeMenubar?.(a),{runtimePlugins:t,toolbarRegistry:o,menuRegistry:a,dispose:()=>{for(const e of n)o.remove(e);for(const e of r)a.unregister(e)}}}({essentialsPlugin:t,externalPlugins:e.externalPlugins,t:e.t,customizeToolbar:e.customizeToolbar,customizeMenubar:e.customizeMenubar}),i=function(e){const[t,n]=$t(!1),[r,o]=$t(new yn({doc:e.initialDocument}));let a=!1;const i=e=>{const t=p(e),n=r().commands.get(t);if(!n)return{isEnabled:!1,isActive:!1,value:void 0};const o=n.refresh?.()??{isEnabled:!0};return{isEnabled:!1!==o.isEnabled,isActive:Boolean(o.isActive),value:o.value}};return{runtimeReady:t,runtimeEditor:r,commandStateOf:i,toolbarHost:()=>({commands:{execute:(e,t)=>{const n=ze(e,t);return r().commands.execute(n.name,n.payload)},canExecute:(e,t)=>{const n=ze(e,t);return r().commands.canExecute(n.name,n.payload)},state:i},focusEditor:e.focusEditor}),initialize:async()=>{try{const t=await yn.create({doc:e.initialDocument,plugins:e.runtimePlugins});if(e.onExecuted&&(t.commands.onExecuted=e.onExecuted),a)return void(await t.destroy());const i=r();o(t),await i.destroy(),n(!0),requestAnimationFrame(()=>{e.onSettled?.(),e.onReady?.(t)})}catch(t){e.logger.error("runtime:init failed",t),e.onError?.(t),e.onSettled?.()}},dispose:async()=>{a=!0,await r().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 it(()=>{i.initialize()}),_t(()=>{i.dispose(),a()}),{toolbarRegistry:r,menuRegistry:o,runtimeReady:i.runtimeReady,runtimeEditor:i.runtimeEditor,commandStateOf:i.commandStateOf,toolbarHost:i.toolbarHost}}var MP=/* @__PURE__ */new Set(["undo","redo","repeatLastAction","find","replace","replaceAll","print","newDocument","saveDocument","insertHtml","insertImageFromFile","openSymbolDialog","openEquationDialog","openCommandSearch","importDocument","exportDocx","exportPdf"]);function AP(e,t){let n=null;return{lastCommand:()=>n?.command??null,record:(e,t)=>{(function(e){return!MP.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 OP(e){return function(e){const{document:t,interaction:n,runtimeClient:r}=e,{commandsController:o,keyboardCommandsController:a}=PS({state:e.state,logger:e.logger,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInput:e.focusInput,selectedImageRun:n.selectedImageRun,tableOps:n.tableOps,toolbarStyleState:n.styleController.toolbarStyleState,applyBooleanStyleCommand:e=>n.styleController.applyToolbarBooleanStyleCommand(e),locale:e.locale,setLinkDialog:e.setLinkDialog,setImageAltDialog:e.setImageAltDialog,setImageCaptionDialog:e.setImageCaptionDialog,setFontDialog:e.setFontDialog,setParagraphDialog:e.setParagraphDialog});let i;const s=AP((e,t)=>{if(!i)throw new Error("repeat tracking used before ready");return i().commands.execute(e,t)},(e,t)=>!!i&&i().commands.canExecute(e,t)),l=()=>{s.execute()},c=()=>s.canExecute(),{runtimeReady:d,runtimeEditor:u,commandStateOf:p,toolbarHost:f,toolbarRegistry:g,menuRegistry:m}=RP({essentials:{clipboardActions:e.clipboardActions,state:()=>e.state,isReadOnly:e.isReadOnly,forcePlainTextPaste:{get:e.getForcePlainTextPaste,set:e.setForcePlainTextPaste},undoStack:t.undoStack,redoStack:t.redoStack,commandsController:o,keyboardCommandsController:a,historyActions:t.historyActions,styleController:n.styleController,formatPainter:n.formatPainter,commentComposer:e.commentComposer,tableOps:n.tableOps,docIO:t.docIO,importInputRef:e.importInputRef,imageInputRef:e.imageInputRef,selectedImageRun:n.selectedImageRun,imageCropMode:{isActive:n.imageOps.cropMode,toggle:n.imageOps.toggleCropMode},selectionBoxes:t.selectionBoxes,focusInput:e.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,findReplace:{setIsOpen:n.fr.setIsOpen},newDocument:RS({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:l,canRepeatLastAction:c,openTablePropertiesDialog:t=>{const n=Cm(e.state,t??"table");n&&e.setTablePropertiesDialog({isOpen:!0,initial:n})},openEquationDialog:()=>{const t=e.state.selection.focus,n=Co(e.state.document).find(e=>e.id===t.paragraphId);if("paragraph"===n?.type){let r=0;for(const o of n.runs){if("math"===o.kind&&t.offset>=r&&t.offset<=r+o.text.length)return void e.setEquationDialog({isOpen:!0,initial:o.math,targetRunId:o.id});r+=o.text.length}}e.setEquationDialog({isOpen:!0})},openFontDialog:o.openFontDialog,openParagraphDialog:o.openParagraphDialog,requestAcceptAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"accept",count:bS(e.state).size})},requestRejectAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"reject",count:bS(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)=>{s.record(t,n),e.onExecutedTap?.()},onReady:t=>{i=()=>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(oi(e)),t.resetEditorChromeState(),t.focusInput()},applyTransactionalState:t.applyTransactionalState,resetDocument:()=>{let e=ja();try{const t=globalThis.localStorage?.getItem("oasis-design-default");if(t){const n=JSON.parse(t);n.themeId&&(e=WS(e,n.themeId)),e=jS(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:d,runtimeEditor:u,getStateSnapshot:e.getStateSnapshot,cloneState:e.cloneState,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,resetEditorChromeState:t.resetEditorChromeState,focusInput:e.focusInput,setFocused:e.setFocused,clearHistory:t.clearHistory,getPersistence:()=>e.documentOptions().persistence??t.fallbackPersistence,docIO:t.docIO,getUiState:e.getUiState,updateUiState:e.updateUiState,getZoom:e.zoom.zoomPercent,setZoom:e.zoom.setZoomPercent,adjustZoom:e.zoom.adjustZoom,toolbarRegistry:g,menuRegistry:m}),bn(()=>{if(!d())return;e.state.document,e.state.selection,e.state.activeSectionIndex,e.state.activeZone;const t=e.cloneState(e.getStateSnapshot());u().dispatch(()=>t)});const{handleKeyDown:h}=function(e){const{state:t,isReadOnly:n,logger:r,focusInput:o,clearPreferredColumn:a,resetTransactionGrouping:i,applyState:s,applyTransactionalState:l,setForcePlainTextPaste:c,selectedImageRun:d,commandsController:u,tableOps:p,navigation:f,historyActions:g,styleController:m,findReplace:h,commandSearch:b,runtimeEditor:y}=e,{handleKeyDown:v}=LS({state:t,isReadOnly:n,clearPreferredColumn:a,resetTransactionGrouping:i,applyState:s,applyTransactionalState:l,applyTableAwareParagraphEdit:p.applyTableAwareParagraphEdit,applySelectionAwareParagraphCommand:p.applySelectionAwareParagraphCommand,focusInput:o,commandsController:u,pendingCaretTextStyle:m.pendingCaretTextStyle,autoTabIndentEnabled:Oe,isMacPlatform:()=>"undefined"!=typeof navigator&&/Mac|iPhone|iPad/.test(navigator.platform),isCaretAtWrappedLineStart:f.isCaretAtWrappedLineStart,selectedImageRun:d,setForcePlainTextPaste:c,moveSelectionByWord:f.moveSelectionByWord,moveSelectionToDocumentBoundary:f.moveSelectionToDocumentBoundary,moveSelectionToParagraphBoundary:f.moveSelectionToParagraphBoundary,moveSelectedImageByParagraph:g.moveSelectedImageByParagraph,performUndo:g.performUndo,performRedo:g.performRedo,moveVerticalSelection:f.moveVerticalSelection,moveVerticalByBlock:f.moveVerticalByBlock,resolveAdjacentTableCellPosition:p.resolveAdjacentTableCellPosition,resolveTableTabTarget:p.resolveTableTabTarget,appendTableRowForTab:p.appendTableRowForTab,applySelectionPreservingStructure:g.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=>{NS.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("+"),o=n?`${n}+${e.key}`:e.key,a=t().selection;r.debug(`key:down ${o} at ${a.anchor.paragraphId}:${a.anchor.runId}[${a.anchor.offset}]`),cr("input-to-layout"),v(e),Lt("input-to-layout")}}}({state:()=>e.state,isReadOnly:e.isReadOnly,logger:e.logger,focusInput:e.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,setForcePlainTextPaste:e.setForcePlainTextPaste,selectedImageRun:n.selectedImageRun,commandsController:a,tableOps:n.tableOps,navigation:n.navigation,historyActions:t.historyActions,styleController:n.styleController,findReplace:n.fr,commandSearch:e.commandSearch,runtimeEditor:u});return{commandsController:o,runtimeReady:d,runtimeEditor:u,commandStateOf:p,toolbarHost:f,toolbarRegistry:g,menuRegistry:m,handleKeyDown:h}}(e)}function BP(e,t){const n=e.document.comments?.items;if(!n?.[t])return null;const r=/* @__PURE__ */new Set;let o=t;for(;n[o]?.parentId&&!r.has(o);){r.add(o);const e=n[o].parentId;if(!n[e])break;o=e}return o}function FP(e,t,n){if(t.document===e.document)return e;const r=e.document.comments?.items[n.commentId]??t.document.comments?.items[n.commentId];if(!r)return t;const o=BP(e,n.commentId)??BP(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:o,...n.parentId?{parentId:n.parentId}:{},actorName:n.actorName,...n.actorId?{actorId:n.actorId}:{},targetAuthor:r.author,timestamp:n.timestamp,..."comment-deleted"===n.kind?{affectedCount:Math.max(1,a-i)}:{}})}function EP(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 DP(e,t,n){if(!t?.items[n])return!1;if(!e||e.canModerate)return!0;if(!EP(e,t.items[n]))return!1;const r=/* @__PURE__ */new Set([n]),o=[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(;o.length;){const n=o.pop();for(const i of a.get(n)??[])if(!r.has(i)){if(r.add(i),!EP(e,t.items[i]))return!1;o.push(i)}}return!0}function LP(e){const[t,n]=$t(null),[r,o]=$t(""),[a,i]=$t(!1),s=()=>e.access?.(),l=()=>{const e=s()?.identity;return e?.id.trim()&&e.displayName.trim()?{id:e.id.trim(),displayName:e.displayName.trim()}:null},c=()=>!(e.isReadOnly()||s()&&null===l()),d=()=>c()&&null!==lr(e.state()),u=t=>c()&&Boolean(e.state().document.comments?.items[t]),p=()=>c()&&null!==vC(e.state()),f=t=>!e.isReadOnly()&&EP(s(),e.state().document.comments?.items[t]),g=()=>{const t=vC(e.state());return null!==t&&f(t.id)},m=t=>!e.isReadOnly()&&DP(s(),e.state().document.comments,t),h=f,b=(e="Local editor")=>{const t=l();return t?{actorName:t.displayName,actorId:t.id}:{actorName:e}},y=(e,t,n,r,o,a)=>FP(e,t,{id:Ur("review-activity"),kind:n,commentId:r,...b(o),timestamp:Date.now(),...a?{parentId:a}:{}}),v=t=>{if(!u(t))return!1;const r=e.state(),o=r.document.comments?.items[t];return!!o&&(n({mode:"reply",snapshot:r,parentId:o.id,parentAuthor:o.author,parentText:o.text}),!0)},x=t=>{if(!f(t))return!1;const r=e.state(),o=r.document.comments?.items[t];return!!o&&(n({mode:"edit",snapshot:r,commentId:t,commentAuthor:o.author,commentText:o.text}),!0)},w=()=>{n(null),e.focusInput()},I=t=>{if(!m(t))return!1;const n=e.state();let r=!1;return e.applyTransactionalState(o=>{if(e.isReadOnly()||o.document!==n.document||!DP(s(),o.document.comments,t))return o;const a=function(e,t){const n=e.document.comments;if(!n?.items[t])return e;const r=/* @__PURE__ */new Set([t]),o=[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(;o.length>0;){const e=o.pop();for(const t of a.get(e)??[])r.has(t)||(r.add(t),o.push(t))}const i=Object.fromEntries(Object.entries(n.items).filter(([e])=>!r.has(e)));return{...e,document:{...e.document,comments:{...n,items:i,order:n.order.filter(e=>!r.has(e))}}}}(o,t);return r=a.document!==o.document,r?y(o,a,"comment-deleted",t):a}),r},S=(t,n)=>{if(!h(t))return!1;const r=e.state();let o=!1;return e.applyTransactionalState(a=>{if(e.isReadOnly()||a.document!==r.document||!EP(s(),a.document.comments?.items[t]))return a;const i=function(e,t,n){const r=e.document.comments,o=r?.items[t];return r&&o&&Boolean(o.resolved)!==n?{...e,document:{...e.document,comments:{...r,items:{...r.items,[t]:{...o,resolved:n}}}}}:e}(a,t,n);return o=i.document!==a.document,o?y(a,i,n?"comment-resolved":"comment-reopened",t):i}),o};return{draft:t,lastAuthor:r,panelOpen:a,togglePanel:()=>(i(!a()),!0),closePanel:()=>{i(!1)},canCreate:d,canReply:p,canReplyId:u,canEdit:g,canEditId:f,canDeleteId:m,canDeleteSelected:()=>{const t=vC(e.state());return null!==t&&m(t.id)},deleteSelected:()=>{const t=vC(e.state());return!!t&&I(t.id)},deleteById:I,canResolveId:h,canResolveSelected:()=>{const t=vC(e.state());return null!==t&&h(t.id)},resolveSelected:t=>{const n=vC(e.state());return!!n&&S(n.id,t)},resolveById:S,authorName:()=>l()?.displayName??r(),authorLocked:()=>void 0!==s(),openNew:()=>!!d()&&(n({mode:"new",snapshot:e.state()}),!0),openReply:()=>{if(!p())return!1;const t=vC(e.state());return!!t&&v(t.id)},openReplyToId:v,openEdit:()=>{if(!g())return!1;const t=vC(e.state());return!!t&&x(t.id)},openEditToId:x,close:w,submit:(n,r)=>{const a=t();if(!a||e.isReadOnly())return!1;if("edit"===a.mode&&!f(a.commentId))return!1;if("edit"!==a.mode&&!c())return!1;const i="edit"===a.mode?a.commentAuthor?.trim()??"":l()?.displayName??n.trim(),d=r.trim();if(!i||!d||e.state().document!==a.snapshot.document)return!1;if("edit"===a.mode&&a.commentText===d)return w(),!0;const u="edit"===a.mode?null:{id:Ur("comment"),author:i,...l()?{authorId:l().id}:{},text:d,date:Date.now()};let p=!1;return e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==a.snapshot.document)return t;if("edit"===a.mode&&!EP(s(),t.document.comments?.items[a.commentId]))return t;if("edit"!==a.mode&&!c())return t;const n="edit"===a.mode?Dt(t,a.commentId,d):"reply"===a.mode?Zn(t,a.parentId,u):An({...t,selection:a.snapshot.selection,activeSectionIndex:a.snapshot.activeSectionIndex,activeZone:a.snapshot.activeZone,activeFootnoteId:a.snapshot.activeFootnoteId},u);return p=n.document!==t.document,p?y(t,n,"new"===a.mode?"comment-created":"reply"===a.mode?"comment-replied":"comment-edited","edit"===a.mode?a.commentId:u.id,i,"reply"===a.mode?a.parentId:void 0):n}),p&&("edit"!==a.mode&&o(i),w()),p}}}var NP=/*#__PURE__*/Gn("<div class=oasis-review-comments-filters role=group>"),zP=/*#__PURE__*/Gn("<div class=oasis-review-comments-list>"),$P=/*#__PURE__*/Gn("<div class=oasis-review-activity-list data-testid=review-activity-list role=list>"),HP=/*#__PURE__*/Gn("<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>"),jP=/*#__PURE__*/Gn("<div class=oasis-review-thread-replies>"),WP=/*#__PURE__*/Gn("<div class=oasis-review-thread><div class=oasis-review-thread-header></div><div class=oasis-review-thread-actions>"),UP=/*#__PURE__*/Gn("<div class=oasis-review-reply><div class=oasis-review-thread-actions>"),VP=/*#__PURE__*/Gn("<div class=oasis-review-activity-entry role=listitem data-testid=review-activity-entry><div class=oasis-review-activity-heading>");function _P(e){const t=E(),[r,o]=$t("all"),[i,s]=$t(!1),[l,c]=$t(""),[d,u]=$t(null),[p,f]=$t(null),g=()=>e.state().document.comments,m=pr(()=>{const e=g();if(!e)return[];const t=l().trim().toLocaleLowerCase();return e.order.map(t=>e.items[t]).filter(t=>Boolean(t&&(!t.parentId||!e.items[t.parentId]))).filter(n=>("open"!==r()||!n.resolved)&&(!("resolved"===r()&&!n.resolved)&&(!t||[n,...a(e.items,n.id)].some(e=>(e.text+" "+e.author).toLocaleLowerCase().includes(t)))))}),h=e=>a(g()?.items??{},e),b=pr(()=>{const t=l().trim().toLocaleLowerCase();return[...e.state().document.reviewActivity??[]].filter(e=>!t||(e.actorName+" "+e.targetAuthor+" "+e.kind).toLocaleLowerCase().includes(t)).reverse()}),y=t=>Number.isFinite(t)?new Date(t).toLocaleString(e.locale?.()??"pt-BR"):"",v=t=>{p()===t?e.composer.deleteById(t)&&(f(null),d()===t&&u(null)):f(t)};return x=HP(),w=x.firstChild,I=w.nextSibling,_e(w,St(Mn,{as:"strong",get children(){return t("review.commentsPanel")}}),null),_e(w,St(rr,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-comments-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),_e(I,St(rr,{size:"sm",variant:"ghost",get"aria-pressed"(){return!i()},onClick:()=>{s(!1)},"data-testid":"review-show-discussions",get children(){return t("review.commentsPanel")}}),null),_e(I,St(rr,{size:"sm",variant:"ghost",get"aria-pressed"(){return i()},onClick:()=>{s(!0)},"data-testid":"review-show-activity",get children(){return t("review.activity.title")}}),null),_e(x,St(Mn,{as:"p",get children(){return tt(()=>!!i())()?`${t("review.activity.title")}: ${e.state().document.reviewActivity?.length??0}`:`${t("review.discussionCount")}: ${g()?.order.length??0}`}}),null),_e(x,St(R,{get label(){return tt(()=>!!i())()?t("review.activity.search"):t("review.searchComments")},get value(){return l()},onChange:c,"data-testid":"review-comments-search"}),null),_e(x,St(En,{get when(){return!i()},get children(){return[(i=NP(),_e(i,St(rr,{size:"sm",variant:"ghost",get"aria-pressed"(){return"all"===r()},onClick:()=>{o("all")},get children(){return t("review.filterAll")}}),null),_e(i,St(rr,{size:"sm",variant:"ghost",get"aria-pressed"(){return"open"===r()},onClick:()=>{o("open")},get children(){return t("review.filterOpen")}}),null),_e(i,St(rr,{size:"sm",variant:"ghost",get"aria-pressed"(){return"resolved"===r()},onClick:()=>{o("resolved")},get children(){return t("review.filterResolved")}}),null),Mt(()=>n(i,"aria-label",t("review.filterComments"))),i),(a=zP(),_e(a,St(En,{get when(){return 0===m().length},get children(){return St(Mn,{as:"p",get children(){return t("review.noComments")}})}}),null),_e(a,St(pt,{get each(){return m()},children:r=>{return o=WP(),a=o.firstChild,i=a.nextSibling,_e(a,St(Mn,{as:"strong",get children(){return r.author||"—"}}),null),_e(a,St(Mn,{as:"span",get children(){return tt(()=>!!r.resolved)()?t("review.filterResolved"):t("review.filterOpen")}}),null),_e(o,St(Mn,{as:"p",get children(){return r.text}}),i),_e(i,St(rr,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(r.id),"data-testid":"review-comment-navigate",get children(){return t("review.goToComment")}}),null),_e(i,St(En,{get when(){return e.composer.canEditId(r.id)},get children(){return St(rr,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(r.id)},"data-testid":"review-comment-edit",get children(){return t("toolbar.editComment")}})}}),null),_e(i,St(En,{get when(){return e.composer.canResolveId(r.id)},get children(){return St(rr,{size:"sm",variant:"ghost",onClick:()=>{e.composer.resolveById(r.id,!r.resolved)},"data-testid":"review-comment-resolve",get children(){return tt(()=>!!r.resolved)()?t("toolbar.reopenComment"):t("toolbar.resolveComment")}})}}),null),_e(i,St(En,{get when(){return e.composer.canReplyId(r.id)},get children(){return St(rr,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(r.id)},"data-testid":"review-comment-reply",get children(){return t("toolbar.replyComment")}})}}),null),_e(i,St(En,{get when(){return e.composer.canDeleteId(r.id)},get children(){return[St(rr,{size:"sm",variant:"ghost",onClick:()=>v(r.id),"data-testid":"review-comment-delete",get children(){return tt(()=>p()===r.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),St(En,{get when(){return p()===r.id},get children(){return St(rr,{size:"sm",variant:"ghost",onClick:()=>{f(null)},get children(){return t("generic.cancel")}})}})]}}),null),_e(o,St(En,{get when(){return h(r.id).length>0},get children(){return St(rr,{size:"sm",variant:"ghost",get"aria-expanded"(){return d()===r.id},"data-testid":"review-toggle-replies",onClick:()=>{u(d()===r.id?null:r.id)},get children(){return tt(()=>d()===r.id)()?t("comment.showFewerReplies"):`${t("comment.showAllReplies")} (${h(r.id).length})`}})}}),null),_e(o,St(En,{get when(){return d()===r.id},get children(){var o=jP();return _e(o,St(pt,{get each(){return h(r.id)},children:r=>{return o=UP(),a=o.firstChild,_e(o,St(Mn,{as:"strong",get children(){return r.author||"—"}}),a),_e(o,St(Mn,{as:"p",get children(){return r.text}}),a),_e(a,St(En,{get when(){return e.composer.canEditId(r.id)},get children(){return St(rr,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(r.id)},"data-testid":"review-reply-edit",get children(){return t("toolbar.editComment")}})}}),null),_e(a,St(En,{get when(){return e.composer.canReplyId(r.id)},get children(){return St(rr,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(r.id)},get children(){return t("toolbar.replyComment")}})}}),null),_e(a,St(En,{get when(){return e.composer.canDeleteId(r.id)},get children(){return[St(rr,{size:"sm",variant:"ghost",onClick:()=>v(r.id),"data-testid":"review-reply-delete",get children(){return tt(()=>p()===r.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),St(En,{get when(){return p()===r.id},get children(){return St(rr,{size:"sm",variant:"ghost",onClick:()=>{f(null)},get children(){return t("generic.cancel")}})}})]}}),null),Mt(()=>n(o,"data-comment-id",r.id)),o;var o,a}})),o}}),null),Mt(()=>n(o,"data-comment-id",r.id)),o;var o,a,i}}),null),a)];var a,i}}),null),_e(x,St(En,{get when(){return i()},get children(){var r=$P();return _e(r,St(En,{get when(){return 0===b().length},get children(){return St(Mn,{as:"p",get children(){return t("review.activity.empty")}})}}),null),_e(r,St(pt,{get each(){return b()},children:r=>{return o=VP(),a=o.firstChild,_e(a,St(Mn,{as:"strong",get children(){return r.actorName}}),null),_e(a,St(Mn,{as:"span",get children(){return y(r.timestamp)}}),null),_e(o,St(Mn,{as:"p",get children(){return[tt(()=>(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")}})(r.kind))," — ",tt(()=>r.targetAuthor),tt(()=>tt(()=>!!(r.affectedCount&&r.affectedCount>1))()?` (${r.affectedCount})`:"")]}}),null),_e(o,St(En,{get when(){return Boolean(g()?.items[r.commentId])},get children(){return St(rr,{size:"sm",variant:"ghost","data-testid":"review-activity-navigate",onClick:()=>e.onNavigate(r.commentId),get children(){return t("review.goToComment")}})}}),null),Mt(()=>n(o,"data-activity-kind",r.kind)),o;var o,a}}),null),Mt(()=>n(r,"aria-label",t("review.activity.title"))),r}}),null),Mt(e=>{var r=t("review.commentsPanel"),o=t("review.displayMode");return r!==e.e&&n(x,"aria-label",e.e=r),o!==e.t&&n(I,"aria-label",e.t=o),e},{e:void 0,t:void 0}),x;var x,w,I}var KP="oasis-reviewing-pane-v1",qP={open:!1,scrollTop:0};function XP(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:0}function GP(){const e=function(){try{const e=globalThis.localStorage?.getItem(KP);if(!e)return qP;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 qP;const n=t;return{open:!0===n.open,scrollTop:XP(n.scrollTop)}}catch{return qP}}(),[t,n]=$t(e.open),[r,o]=$t(e.scrollTop),a=()=>{!function(e){try{globalThis.localStorage?.setItem(KP,JSON.stringify(e))}catch{}}({open:t(),scrollTop:r()})},i=e=>{n(e),a()};return{open:()=>t(),toggle:()=>(i(!t()),!0),close:()=>{i(!1)},scrollTop:()=>r(),setScrollTop:e=>{const t=XP(e);t!==r()&&(o(t),a())}}}var YP=/*#__PURE__*/Gn("<ul class=oasis-review-revisions-list data-testid=review-revisions-list>"),ZP=/*#__PURE__*/Gn("<div class=oasis-review-revision-footer>"),JP=/*#__PURE__*/Gn('<div role=region class="oasis-review-comments-panel oasis-review-revisions-panel"data-testid=review-revisions-panel><div class=oasis-review-comments-heading>'),QP=/*#__PURE__*/Gn("<li class=oasis-review-revision-item><div class=oasis-review-revision-body></div><div class=oasis-review-revision-actions>");function eR(e,t){const n=xi(e),r=[];for(const a of n)for(const e of a.runs)e.revision?.id!==t&&e.styles?.propertyRevision?.id!==t||r.push(e.text);const o=r.join("").trim();return o.length>96?`${o.slice(0,93)}…`:o}function tR(e){const t=E(),r=pr(()=>{const t=e.state(),n=xi(t),r=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;for(const e of n)for(const t of e.runs){const e=t.revision;e&&(r.has(e.id)||r.set(e.id,e.author),o.has(e.id)||o.set(e.id,{date:e.date,type:e.type}));const n=t.styles?.propertyRevision;n&&(r.has(n.id)||r.set(n.id,n.author),o.has(n.id)||o.set(n.id,{date:n.date,type:"property"}))}const a=new Map(Xv(t).map(e=>[e.id,e])),i=new Map(Gv(t).map(e=>[e.id,e]));return mC(t).map(e=>{const n=o.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:r.get(e.id)??s?.author??l?.author??"—",date:n?.date??s?.date??l?.date,snippet:eR(t,e.id)||s?.snippet||l?.snippet||"",section:void 0!==l}})}),o=pr(()=>{const t=e.state();return r().filter(e=>ex(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))};bn(()=>{o().length,i||queueMicrotask(s)});return l=JP(),c=l.firstChild,_e(c,St(Mn,{as:"strong",get children(){return t("review.reviewingPane")}}),null),_e(c,St(rr,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-revisions-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),_e(l,St(Mn,{as:"p",get children(){return[tt(()=>t("review.revisionCount")),": ",tt(()=>o().length)]}}),null),_e(l,St(En,{get when(){return r().length-o().length>0},get children(){return St(Mn,{as:"p",class:"oasis-review-revisions-filtered","data-testid":"review-revisions-filtered",get children(){return t("review.revisionsHiddenByShowMarkup")}})}}),null),_e(l,St(En,{get when(){return o().length>0},get fallback(){return St(Mn,{as:"p",get children(){return t("review.noRevisions")}})},get children(){var r=YP();return r.addEventListener("scroll",t=>{e.onScroll?.(t.currentTarget.scrollTop)}),nn(e=>{a=e,queueMicrotask(s)},r),_e(r,St(pt,{get each(){return o()},children:r=>{return o=QP(),a=o.firstChild,i=a.nextSibling,_e(a,St(Mn,{as:"span",get class(){return"oasis-review-revision-type "+(e=r.type,r.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 r.type},get children(){return[St(ft,{get name(){return"delete"===(e=r.type)?"minus":"insert"===e?"plus":"pencil";var e}}),St(Mn,{as:"span",get children(){return e=r.type,n=r.section,t(n?"review.revisionSection":"insert"===e||"delete"===e?"insert"===e?"review.revisionInsert":"review.revisionDelete":"grid"===e?"review.revisionGrid":"review.revisionProperty");var e,n}})]}}),null),_e(a,St(Mn,{as:"p",get children(){return r.snippet||"—"}}),null),_e(a,St(Mn,{as:"span",get children(){return r.author}}),null),_e(i,St(rr,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(r.id),"data-testid":"review-revision-navigate",get children(){return t("review.goToComment")}}),null),_e(i,St(rr,{size:"sm",variant:"ghost",onClick:()=>e.onAccept(r.id),"data-testid":"review-revision-accept",get children(){return t("toolbar.accept")}}),null),_e(i,St(rr,{size:"sm",variant:"ghost",onClick:()=>e.onReject(r.id),"data-testid":"review-revision-reject",get children(){return t("toolbar.reject")}}),null),Mt(e=>{var t=r.id,a=r.section?"true":void 0;return t!==e.e&&n(o,"data-comment-id",e.e=t),a!==e.t&&n(o,"data-revision-section",e.t=a),e},{e:void 0,t:void 0}),o;var o,a,i}})),r}}),null),_e(l,St(En,{get when(){return o().length>0},get children(){var n=ZP();return _e(n,St(rr,{size:"sm",variant:"ghost",get onClick(){return e.onRejectAll},"data-testid":"review-revisions-reject-all",get children(){return t("toolbar.rejectAll")}}),null),_e(n,St(rr,{size:"sm",variant:"primary",get onClick(){return e.onAcceptAll},"data-testid":"review-revisions-accept-all",get children(){return t("toolbar.acceptAll")}}),null),n}}),null),Mt(()=>n(l,"aria-label",t("review.reviewingPane"))),l;var l,c}var nR=/*#__PURE__*/Gn('<div class="oasis-editor-shell oasis-editor-app">');function rR(e={}){const t=e.runtime?.client??Zt(),[o,a]=$t({}),i=()=>({...e.ui??{},...o(),toolbar:{...e.ui?.toolbar??{},...o().toolbar??{}}}),s=()=>({...e.document??{},...void 0===o().readOnly?{}:{readOnly:o().readOnly}}),l=()=>({...i(),readOnly:s().readOnly}),c=e=>(a(t=>({...t,...e,toolbar:{...t.toolbar??{},...e.toolbar??{}}})),{...l(),...e}),d=()=>e.runtime??{};Vp();const u=G(()=>i().locale??"pt-BR"),p=Ct("app"),{state:f,commitState:g,getStateSnapshot:m}=function(e){const t=e.initialState?en(e.initialState):e.initialDocument?oi(e.initialDocument):ja();let n=t;const[r,o]=$t(t),a=new Proxy({},{get(e,t){const n=r();if(null!==n&&("object"==typeof n||"function"==typeof n))return Reflect.get(n,t)},has(e,t){const n=r();return null!==n&&("object"==typeof n||"function"==typeof n)&&Reflect.has(n,t)},ownKeys(e){const t=r();return null===t||"object"!=typeof t&&"function"!=typeof t?[]:Reflect.ownKeys(t)},getOwnPropertyDescriptor(e,t){const n=r();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:o,commitState:e=>{const t=ra(e===a?n:e);n=t,o(t)},getStateSnapshot:()=>n}}({initialDocument:s().initialDocument,initialState:s().initialState}),h=e=>{g(e)},b=en;let y=!1;const{showChrome:v,showTitleBar:x,showMenubar:w,showToolbar:I,showOutline:S,showRuler:C,toggleOutline:k,toolbarView:P,toolbarLayout:R,isReadOnly:M,useComposedShell:A,loadingOptions:O,loadingLabel:F,shellComponent:E}=function(e){const{ui:t,documentOptions:n,updateUiState:r,state:o}=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:()=>{r({showOutline:!(t().showOutline??!0)})},toolbarView:()=>t().toolbar?.view??"ribbon",toolbarLayout:()=>t().toolbar?.layout??"overflow",isReadOnly:()=>(n().readOnly??!1)||"all"!==(o().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?B:"balloon"===e?he:W}}}({ui:i,documentOptions:s,updateUiState:c,state:()=>f}),D=function(){const[e,t]=$t(!1);let n,r,o,a,i;return{focused:e,setFocused:t,focusInput:()=>{t(!0),queueMicrotask(()=>{o?.focus({preventScroll:!0}),o&&(o.selectionStart=o.value.length,o.selectionEnd=o.value.length)})},focusInputAfterPointerSelection:()=>{t(!0),queueMicrotask(()=>{requestAnimationFrame(()=>{o?.focus({preventScroll:!0}),o&&(o.selectionStart=o.value.length,o.selectionEnd=o.value.length)})})},focusInputSync:()=>{t(!0),o?.focus({preventScroll:!0}),o&&(o.selectionStart=o.value.length,o.selectionEnd=o.value.length)},get viewportRef(){return n},set viewportRef(e){n=e},get surfaceRef(){return r},set surfaceRef(e){r=e},get textareaRef(){return o},set textareaRef(e){o=e},get importInputRef(){return a},set importInputRef(e){a=e},get imageInputRef(){return i},set imageInputRef(e){i=e}}}(),L=D.focused,N=D.setFocused,$=D.focusInput,H=D.focusInputAfterPointerSelection,j=D.focusInputSync,[U,V]=$t(!1!==i().loading),_=qn(),{linkDialog:K,setLinkDialog:q,imageAltDialog:X,setImageAltDialog:Y,imageCaptionDialog:Z,setImageCaptionDialog:J,contextMenu:Q,setContextMenu:ee,fontDialog:te,setFontDialog:ne,paragraphDialog:re,setParagraphDialog:oe,tablePropertiesDialog:ae,setTablePropertiesDialog:ie,revisionBulkDialog:le,setRevisionBulkDialog:ce,newDocumentDialog:de,setNewDocumentDialog:ue,symbolDialog:pe,setSymbolDialog:fe,equationDialog:ge,setEquationDialog:me}=function(){const[e,t]=$t({isOpen:!1}),[n,r]=$t({isOpen:!1}),[o,a]=$t({isOpen:!1}),[i,s]=$t({isOpen:!1,initialHref:""}),[l,c]=$t({isOpen:!1,initialAlt:""}),[d,u]=$t({isOpen:!1,initialCaption:""}),[p,f]=$t({isOpen:!1,x:0,y:0}),[g,m]=$t({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]=$t({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]=$t({isOpen:!1,action:"accept",count:0}),[x,w]=$t({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:r,equationDialog:o,setEquationDialog:a,linkDialog:i,setLinkDialog:s,imageAltDialog:l,setImageAltDialog:c,imageCaptionDialog:d,setImageCaptionDialog:u,contextMenu:p,setContextMenu:f,fontDialog:g,setFontDialog:m,paragraphDialog:h,setParagraphDialog:b,tablePropertiesDialog:x,setTablePropertiesDialog:w,revisionBulkDialog:y,setRevisionBulkDialog:v}}(),[be,ye]=$t(!1),ve=()=>D.viewportRef,xe=()=>D.surfaceRef,we=Tx({documentOptions:s,logger:p,runtimeClient:t,state:f,commitState:g,getStateSnapshot:m,applyState:h,cloneState:b,isReadOnly:M,focusInput:$,surfaceRef:xe,viewportRef:ve,zoomFactor:_.zoomFactor,getImageOps:()=>Xe.imageOps}),{docIO:Ie,measuredBlockHeights:Se,measuredParagraphLayouts:Ce,documentLayout:ke,canvasSnapshotProvider:Pe,inputBox:Re,selectionBoxes:Me,commentHighlights:Ae,revisionMarkupBoxes:Oe,changeBarBoxes:Be,selectedImageBox:Fe,selectedTextBoxBox:Ee,selectedTableBox:De,caretBox:Le,preferredColumnX:Ne,setPreferredColumnX:ze,clearPreferredColumn:$e,onCleanupHook:He,persistenceStatus:We,applyTransactionalState:Ue,resetTransactionGrouping:Ve,updateHistoryState:Ke}=we,qe=kp({state:()=>f,stateSnapshot:m,isReadOnly:M,applyTransactionalState:Ue,applyTableAwareParagraphEdit:(e,t)=>Xe.tableOps.applyTableAwareParagraphEdit(e,t),clearPreferredColumn:$e,resetTransactionGrouping:Ve,focusInput:$}),Xe=iS({clipboardActions:qe,state:f,getStateSnapshot:m,logger:p,isReadOnly:M,applyState:h,cloneState:b,focusInput:$,focusInputAfterPointerSelection:H,focusInputSync:j,surfaceRef:xe,viewportRef:ve,zoomFactor:_.zoomFactor,insertImageFromFile:Ie.insertImageFromFile,getForcePlainTextPaste:()=>y,setForcePlainTextPaste:e=>{y=e},getCommandsController:()=>xt.commandsController,applyTransactionalState:Ue,clearPreferredColumn:$e,resetTransactionGrouping:Ve,updateHistoryState:Ke,caretBox:Le,preferredColumnX:Ne,setPreferredColumnX:ze,measuredBlockHeights:Se,measuredParagraphLayouts:Ce,documentLayout:ke,canvasSnapshotProvider:Pe,openEquationDialog:(e,t)=>{me({isOpen:!0,initial:e,targetRunId:t})}}),{layoutOptionsOverlay:Ge,fr:Ye,tableOps:Ze,imageOps:Je,textBoxOps:Qe,styleController:et,onEditorPointerDown:nt,tableResize:rt,tableCornerResize:ot,tableDrag:at,revisionController:st,textDrag:lt,surfaceEventsWithTextDrag:ct,textInput:dt,handleCopy:ut,handleCut:pt,handlePaste:ft,handleDrop:gt}=Xe,[mt,ht]=$t(!1),bt=GP(),yt=LP({state:()=>f,isReadOnly:M,applyTransactionalState:Ue,focusInput:$,access:()=>d().review}),xt=OP({commandSearch:{isOpen:mt,setIsOpen:e=>{ht(e)}},setCommandSearchOpen:ht,clipboardActions:qe,document:we,interaction:Xe,commentComposer:yt,state:f,logger:p,isReadOnly:M,focusInput:$,applyState:h,getStateSnapshot:m,cloneState:b,setFocused:N,setInitialLoading:V,getForcePlainTextPaste:()=>y,setForcePlainTextPaste:e=>{y=e},locale:()=>i().locale??"pt-BR",translator:u,runtimeClient:t,runtimeOptions:d,documentOptions:s,getUiState:l,updateUiState:c,zoom:_,importInputRef:()=>D.importInputRef,imageInputRef:()=>D.imageInputRef,setLinkDialog:q,setImageAltDialog:Y,setImageCaptionDialog:J,setNewDocumentDialog:ue,setSymbolDialog:fe,setEquationDialog:me,setTablePropertiesDialog:ie,setFontDialog:ne,setParagraphDialog:oe,setRevisionBulkDialog:ce,toggleOutline:k,isOutlineVisible:S,toggleRevisionsPanel:()=>{bt.toggle()},revisionsPanelVisible:bt.open}),{commandsController:wt,runtimeReady:It,runtimeEditor:kt,toolbarHost:Tt,toolbarRegistry:Pt,menuRegistry:Rt,handleKeyDown:At}=xt,Ot=()=>function(e,t,n){const r=[],o=/* @__PURE__ */new Set;for(const a of e){if("hidden"in a&&!0===a.hidden)continue;const e=zp(a);if(!e)continue;const t=a.label;if("string"!=typeof t||!t.trim())continue;if(o.has(e.command))continue;o.add(e.command);const n={id:a.id,label:t,command:e.command,...void 0===e.payload?{}:{payload:e.payload},source:"ribbon"};r.push(n)}for(const a of t){if(!0===a.hidden)continue;const e=Np(a.command);if(!e)continue;if(o.has(e.command))continue;o.add(e.command);const t=a.labelKey?n(a.labelKey):a.id;r.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 r}(Pt.getOrdered(),Rt.getItems(),u),Bt=e=>{try{return!1!==kt().commands.canExecute(e)}catch{return!1}},{computeFontFamilyOptions:Ft,computeFontSizeOptions:Et,applyFontDialogValues:Dt,applyParagraphDialogValues:Lt,setParagraphDialogDefault:Nt,applyTablePropertiesDialogValues:zt,buildContextMenuItems:Ht,handleEditorContextMenu:jt,closeContextMenu:Wt}=Rm({clipboardActions:qe,state:()=>f,selection:()=>f.selection,toolbarStyleState:et.toolbarStyleState,isReadOnly:M,t:u,logger:p,setFontDialog:ne,setParagraphDialog:oe,setTablePropertiesDialog:ie,setContextMenu:ee,clearPreferredColumn:$e,resetTransactionGrouping:Ve,applyTransactionalState:Ue,applyTableAwareParagraphEdit:Ze.applyTableAwareParagraphEdit,focusInput:$,promptForLink:wt.promptForLink,tableOps:Ze}),{layout:Ut,overlays:Vt,refs:Kt,surfaceHandlers:qt,inputHandlers:Xt,fileHandlers:Gt}=function(e){const{layout:t,overlays:n,refs:r,surface:o,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=>{r.focusController.viewportRef=e},onSurfaceRef:e=>{r.focusController.surfaceRef=e},onTextareaRef:e=>{r.focusController.textareaRef=e},onImportInputRef:e=>{r.focusController.importInputRef=e},onImageInputRef:e=>{r.focusController.imageInputRef=e}},surfaceHandlers:{onDragOver:e=>e.preventDefault(),onDrop:o.handleDrop,onEditorPointerDown:o.onEditorPointerDown,onSurfacePointerDown:o.surfaceEvents.handleSurfacePointerDown,onSurfaceClick:o.surfaceEvents.handleSurfaceClick,onSurfacePointerMove:o.tableResize.handlePointerMove,onSurfaceDblClick:o.surfaceEvents.handleSurfaceDblClick,onParagraphPointerDown:o.surfaceEvents.handleParagraphPointerDown,onImagePointerDown:o.handleImagePointerDown,onImageResizeHandlePointerDown:o.handleImageResizeHandlePointerDown,onTextBoxResizeHandlePointerDown:o.handleTextBoxResizeHandlePointerDown,onImageRotateHandlePointerDown:o.handleImageRotateHandlePointerDown,onImageCropHandlePointerDown:o.handleImageCropHandlePointerDown,onImageCropBodyPointerDown:o.handleImageCropBodyPointerDown,onTextBoxRotateHandlePointerDown:o.handleTextBoxRotateHandlePointerDown,onTableDragHandlePointerDown:o.tableDrag.handlePointerDown,onTableCornerResizeHandlePointerDown:o.tableCornerResize.handlePointerDown,onRevisionMouseEnter:o.revisionController.handleRevisionMouseEnter,onRevisionMouseLeave:o.revisionController.handleRevisionMouseLeave,onEditorContextMenu:e=>o.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:ke,remoteWebFonts:s().remoteWebFonts,pageGutter:i().pageGutter,initialZoomMode:i().zoom?.initialMode,viewportHeight:i().viewportHeight,className:i().class,style:i().style,zoomPercent:_.zoomPercent,setZoomPercent:_.setZoomPercent,zoomFactor:_.zoomFactor},overlays:{selectionBoxes:Me,commentHighlights:Ae,revisionMarkupBoxes:Oe,changeBarBoxes:Be,onReplyToComment:e=>{yt.openReplyToId(e)},onEditComment:e=>{yt.openEditToId(e)},canEditComment:yt.canEditId,canReplyComment:yt.canReplyId,selectedImageBox:Fe,selectedTextBoxBox:Ee,selectedTableBox:De,layoutOptions:Ge,caretBox:Le,inputBox:Re,hoveredRevision:st.hoveredRevision,focused:L,showCaret:()=>function(e,t){if(!t.visible||!ri(e.selection))return!1;const n=ya(e),r=vo(e.document,e.selection.anchor.paragraphId,n),o=vo(e.document,e.selection.focus.paragraphId,n);return!(r&&o&&r.blockIndex===o.blockIndex&&(r.rowIndex!==o.rowIndex||r.cellIndex!==o.cellIndex))}(f,Le()),importProgress:Ie.importProgress,imageCropMode:Je.cropMode},refs:{focusController:D},files:{handleImportFile:Ie.handleImportFile,handleInsertImage:Ie.handleInsertImage},surface:{surfaceEvents:ct,tableResize:rt,tableCornerResize:ot,tableDrag:at,revisionController:st,handleDrop:gt,onEditorPointerDown:nt,handleImagePointerDown:Je.handleImagePointerDown,handleImageResizeHandlePointerDown:Je.handleImageResizeHandlePointerDown,handleTextBoxResizeHandlePointerDown:Qe.handleTextBoxResizeHandlePointerDown,handleImageRotateHandlePointerDown:Je.handleImageRotateHandlePointerDown,handleImageCropHandlePointerDown:Je.handleImageCropHandlePointerDown,handleImageCropBodyPointerDown:Je.handleImageCropBodyPointerDown,handleTextBoxRotateHandlePointerDown:Qe.handleTextBoxRotateHandlePointerDown,handleEditorContextMenu:jt},input:{textInput:dt,setFocused:N,handleCopy:ut,handleCut:pt,handlePaste:ft,handleKeyDown:e=>{if("Escape"===e.key&&Xe.formatPainter.mode())return Xe.formatPainter.cancel(),void e.preventDefault();At(e)},handleKeyUp:e=>{Xe.formatPainter.mode()&&(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Shift"].includes(e.key)||(e.ctrlKey||e.metaKey)&&"a"===e.key.toLowerCase())&&Xe.formatPainter.applyToSelection("keyboard")}}});return it(()=>{Dn(),an(),r(),Jn(()=>xe()??null),vt(),(i().showWelcome??!0)&&!T()&&Te()&&ye(!0)}),_t(()=>{He(),ct.stopDragging(),lt.stopDrag(),rt.stop(),ot.stop(),at.stop(),Je.stopImageDrag(),Je.stopImageResize(),Je.stopImageCrop(),Qe.stopTextBoxResize(),nr()}),St(je,{translator:u,get children(){var e=nR();return _e(e,St(En,{get when(){return tt(()=>!(A()||!v()))()&&I()},get children(){return St(se,{host:Tt,registry:Pt,get showFileGroup(){return!!tt(()=>"ribbon"===P())()||!w()},get view(){return P()},get layout(){return R()}})}}),null),_e(e,St(Rp,{get notice(){return qe.notice},onDismiss:()=>{qe.dismiss(),$()}}),null),_e(e,St(En,{get when(){return yt.panelOpen()},get children(){return St(_P,{state:()=>f,composer:yt,locale:()=>i().locale??"pt-BR",get onClose(){return yt.closePanel},onNavigate:e=>{const t=function(e,t){const n=e.document.comments?.items;if(!n?.[t])return e;let r=n[t];const o=/* @__PURE__ */new Set;for(;r&&!r.start&&r.parentId&&!o.has(r.id);)o.add(r.id),r=n[r.parentId];const a=r?.start,i=r?.end;if(!a||!i)return e;const s=xi(e),l=s.find(e=>e.id===a.paragraphId),c=s.find(e=>e.id===i.paragraphId);return l&&c?{...e,selection:{anchor:Xo(l,a.offset),focus:Xo(c,i.offset)}}:e}(f,e);t!==f&&(h(t),$())}})}}),null),_e(e,St(En,{get when(){return bt.open()},get children(){return St(tR,{state:()=>f,get onClose(){return bt.close},get scrollTop(){return bt.scrollTop()},get onScroll(){return bt.setScrollTop},onNavigate:e=>{const t=xC(f,e);t!==f&&(h(t),$())},onAccept:e=>{const t=xC(f,e);t!==f&&(h(t),wt.applyAcceptRevisionsCommand(),$())},onReject:e=>{const t=xC(f,e);t!==f&&(h(t),wt.applyRejectRevisionsCommand(),$())},onAcceptAll:()=>kt().commands.execute("requestAcceptAllRevisions"),onRejectAll:()=>kt().commands.execute("requestRejectAllRevisions")})}}),null),_e(e,St(Lp,{get isOpen(){return mt()},get entries(){return Ot()},isEnabled:Bt,onExecute:e=>{kt().commands.execute(e.command,e.payload),ht(!1),$()},onClose:()=>{ht(!1),$()}}),null),_e(e,St(db,{commentComposer:yt,dialogs:{linkDialog:K,setLinkDialog:q,imageAltDialog:X,setImageAltDialog:Y,imageCaptionDialog:Z,setImageCaptionDialog:J,contextMenu:Q,setContextMenu:ee,fontDialog:te,setFontDialog:ne,paragraphDialog:re,setParagraphDialog:oe,tablePropertiesDialog:ae,setTablePropertiesDialog:ie,revisionBulkDialog:le,setRevisionBulkDialog:ce,newDocumentDialog:de,setNewDocumentDialog:ue,symbolDialog:pe,setSymbolDialog:fe,equationDialog:ge,setEquationDialog:me},findReplace:Ye,fontFamilyOptions:Ft,fontSizeOptions:Et,contextMenuItems:Ht,focusInput:$,get applyLinkCommand(){return wt.applyLinkCommand},get applyImageAltCommand(){return wt.applyImageAltCommand},get applyImageCaptionCommand(){return wt.applyImageCaptionCommand},applyFontDialogValues:Dt,applyParagraphDialogValues:Lt,setParagraphDialogDefault:Nt,applyTablePropertiesDialogValues:zt,confirmNewDocument:()=>t.resetDocument(),applyBulkRevisions:e=>{kt().commands.execute("accept"===e?"acceptAllRevisions":"rejectAllRevisions"),$()},insertSymbol:(e,t)=>{kt().commands.execute("insertText",{text:e,fontFamily:t}),$()},applyEquation:(e,t)=>{t?kt().commands.execute("updateEquation",{runId:t,expression:e}):kt().commands.execute("insertEquation",e),$()},closeContextMenu:Wt}),null),_e(e,St(pb,{useComposedShell:A,shellComponent:E,runtime:{state:()=>f,toolbarHost:Tt,runtimeEditor:kt,persistenceStatus:We,toolbarRegistry:Pt,menuRegistry:Rt},chrome:{showChrome:v,showTitleBar:x,showMenubar:w,showToolbar:I,showOutline:S,showRuler:C,toolbarView:P,toolbarLayout:R},view:{isReadOnly:M,viewportHeight:()=>i().viewportHeight,measuredBlockHeights:Se,measuredParagraphLayouts:Ce,documentLayout:ke,layout:Ut,overlays:Vt,refs:Kt,surfaceHandlers:qt,inputHandlers:Xt,fileHandlers:Gt}}),null),_e(e,St(Em,{state:f,get surfaceRef(){return xe()},documentLayout:ke,snapshotProvider:Pe,get zoomFactor(){return _.zoomFactor},tableResize:rt,tableCornerResize:ot,imageOps:Je,tableDrag:at,textDrag:lt}),null),_e(e,St(En,{get when(){return U()||!It()},get children(){return St(z,{get label(){return F()},get class(){return O()?.class},get style(){return O()?.style}})}}),null),_e(e,St(gb,{get isOpen(){return tt(()=>!(!be()||U()))()&&It()},onClose:()=>ye(!1)}),null),Mt(t=>{var r=i().theme??"light",o=!!A(),a=!!M(),s=!("two-line"!==i().toolbar?.ribbonStyle),l=!("simplified"!==i().toolbar?.ribbonStyle),c=!(null===Xe.formatPainter.mode()),d={"--oasis-editor-gutter-x":`${vn(i().pageGutter)}px`,...void 0!==i().pageGutter?{"--oasis-editor-gutter-top":`${vn(i().pageGutter)}px`,"--oasis-editor-gutter-bottom":`${vn(i().pageGutter)}px`}:{}};return r!==t.e&&n(e,"data-theme",t.e=r),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),s!==t.o&&e.classList.toggle("oasis-editor-ribbon-two-line",t.o=s),l!==t.i&&e.classList.toggle("oasis-editor-ribbon-simplified",t.i=l),c!==t.n&&e.classList.toggle("oasis-editor-format-painter-active",t.n=c),t.s=Rn(e,d,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{rR as OasisEditorApp};
|