oasis-editor 0.0.79 → 0.0.81
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.
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
*
|
|
22
22
|
* This source code is licensed under the ISC license.
|
|
23
23
|
* See the LICENSE file in the root directory of this source tree.
|
|
24
|
-
*/let lT=null;const sT={DEV:!1,MODE:"lib"};let dT=!1,cT=null,hT=null,pT=null,uT=[];function fT(){"undefined"!=typeof window&&(!function(){var t;const e=sT??{},a=(null==(t=globalThis.process)?void 0:t.env)??{};return!0===e.DEV||"test"===e.MODE||"test"===a.NODE_ENV||"1"===e.VITE_OASIS_CANVAS_DEBUG}()?dT&&(delete window.__oasisCanvasDebug,dT=!1):dT||(window.__oasisCanvasDebug={getLastHit:()=>cT?{...cT}:null,getLayoutSnapshot:()=>hT?{...hT,surfaceRect:{...hT.surfaceRect},pages:hT.pages.map(t=>({...t})),paragraphs:hT.paragraphs.map(t=>({...t,lines:t.lines.map(t=>({...t,slots:t.slots.map(t=>({...t}))})),tableCell:t.tableCell?{...t.tableCell}:void 0})),inlineImages:hT.inlineImages.map(t=>({...t})),inlineTextBoxes:hT.inlineTextBoxes.map(t=>({...t})),unsupportedRegions:hT.unsupportedRegions.map(t=>({...t}))}:null,getSelection:()=>pT?{anchor:{...pT.anchor},focus:{...pT.focus},activeZone:pT.activeZone,activeSectionIndex:pT.activeSectionIndex}:null,getMissEvents:()=>uT.map(t=>({...t})),clearMissEvents:()=>{uT=[]}},dT=!0))}function gT(t){dT&&t&&(cT={timestamp:Date.now(),zone:t.zone,paragraphId:t.paragraphId,paragraphOffset:t.paragraphOffset,source:t.source,missReason:t.missReason,resolvedFromParagraph:t.resolvedFromParagraph})}const mT=["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 vT(t,e,a){const n=null==a?void 0:a.trim();if(!n)return;const r=n.toLowerCase();e.has(r)||(e.add(r),t.push(n))}function bT(t){const[e,a]=y([]);return{computeFontFamilyOptions:()=>function(t,e,a=[]){var n;const r=new Set,o=[],i=[];for(const l of Object.values((null==t?void 0:t.styles)??{}))vT(o,r,null==(n=l.textStyle)?void 0:n.fontFamily);vT(o,r,e.fontFamily);for(const l of a)vT(i,r,l);for(const l of mT)vT(i,r,l);return[...o.sort((t,e)=>t.localeCompare(e)),...i.sort((t,e)=>t.localeCompare(e))]}(t.state().document,t.toolbarStyleState(),e()),computeFontSizeOptions:()=>function(t,e){var a;const n=new Set(MM);for(const o of Object.values((null==t?void 0:t.styles)??{})){const t=null==(a=o.textStyle)?void 0:a.fontSize;"number"==typeof t&&Number.isFinite(t)&&n.add(xM(t))}const r=xM(Number(e.fontSize));return Number.isFinite(r)&&r>0&&n.add(r),Array.from(n).sort((t,e)=>t-e)}(t.state().document,t.toolbarStyleState()),loadLocalFontFamilyOptions:async()=>{if(e().length>0)return;const t=await bc();t.length>0&&a(t)}}}function yT(t){return t?{...t}:void 0}function MT(t,e){return JSON.stringify(t??null)===JSON.stringify(e??null)}function xT(t,e,a){const n={...t??{}};return a?n[e]=!0:delete n[e],Object.keys(n).length>0?n:void 0}function wT(t,e,a){const n={...t??{}};return null==a||""===a?delete n[e]:n[e]=a,Object.keys(n).length>0?n:void 0}function ST(t,e,a){const n={...t??{}};return null==a?delete n[e]:n[e]=a,Object.keys(n).length>0?n:void 0}function AT(t){return{...t,floating:t.floating?{...t.floating,positionH:t.floating.positionH?{...t.floating.positionH}:void 0,positionV:t.floating.positionV?{...t.floating.positionV}:void 0}:void 0,shape:t.shape?{...t.shape}:void 0,body:t.body?{...t.body}:void 0,blocks:VT(t.blocks)}}function IT(t){return{...t,styles:yT(t.styles),image:t.image?{...t.image}:void 0,textBox:t.textBox?AT(t.textBox):void 0,field:t.field?{...t.field}:void 0,fieldChar:t.fieldChar?{...t.fieldChar}:void 0,revision:t.revision?{...t.revision}:void 0,footnoteReference:t.footnoteReference?{...t.footnoteReference}:void 0,endnoteReference:t.endnoteReference?{...t.endnoteReference}:void 0}}function TT(t){return{...t,runs:t.runs.map(IT),style:t.style?{...t.style}:void 0,list:t.list?{...t.list}:void 0}}function CT(t){return t?{...t}:void 0}function kT(t){return t.map(TT)}function VT(t){return t.map(t=>{switch(t.type){case"paragraph":return TT(t);case"table":return{...t,style:t.style?{...t.style,defaultCellMargins:t.style.defaultCellMargins?{...t.style.defaultCellMargins}:void 0,floating:t.style.floating?{...t.style.floating}:void 0,revisionXml:t.style.revisionXml?[...t.style.revisionXml]:void 0}:void 0,tblGridChangeXml:t.tblGridChangeXml,rows:t.rows.map(t=>({...t,style:t.style?{...t.style,revisionXml:t.style.revisionXml?[...t.style.revisionXml]:void 0}:void 0,cells:t.cells.map(t=>({...t,style:t.style?{...t.style,revisionXml:t.style.revisionXml?[...t.style.revisionXml]:void 0}:void 0,blocks:kT(t.blocks)}))}))};default:return pe(t,"block")}})}function ET(t,e){const a=[];for(const n of t){if(0===n.text.length)continue;const t=a[a.length-1];!t||ue(n)||ue(t)||!MT(t.styles,n.styles)?a.push({...n,styles:yT(n.styles)}):t.text+=n.text}return a.length>0?a:[wa("",e)]}function RT(t,e,a){return{...t,runs:ET(e,a),style:t.style?{...t.style}:void 0}}function LT(t){return Aa(t)}function zT(t,e){const a=LT(e);return a.style=t.style?{...t.style}:void 0,a.list=CT(t.list),a}function NT(t,e){const a=TT(t);return a.list?(a.list={...a.list,level:Math.max(0,e)},a):a}function qT(t){const e=TT(t);return delete e.list,e}function OT(t,e){var a;if(0===t.runs.length)return;let n=0;for(let r=0;r<t.runs.length;r+=1){const a=t.runs[r],o=n+a.text.length;if(e<o)return yT(a.styles);if(e===o){if(a.text.length>0)return yT(a.styles);const e=t.runs[r+1];return yT((null==e?void 0:e.styles)??a.styles)}n=o}return yT(null==(a=t.runs[t.runs.length-1])?void 0:a.styles)}function PT(t,e){var a,n,r;const o=function(t,e){let a=0;for(let n=0;n<t.runs.length;n+=1){const r=t.runs[n],o=a,i=a+r.text.length;if(e<i)return{run:r,startOffset:o,endOffset:i};if(e===i){if(r.text.length>0)return{run:r,startOffset:o,endOffset:i};const e=t.runs[n+1];return e?{run:e,startOffset:i,endOffset:i+e.text.length}:{run:r,startOffset:o,endOffset:i}}a=i}return null}(t,e),i=null==(a=null==o?void 0:o.run.styles)?void 0:a.link;if(!o||!i||o.run.image)return null;let l=o.startOffset,s=o.endOffset,d=0;const c=t.runs,h=c.findIndex(t=>t.id===o.run.id);if(-1===h)return null;for(let p=0;p<h;p+=1)d+=c[p].text.length;l=d,s=d+o.run.text.length;for(let p=h-1;p>=0;p-=1){const t=c[p];if(t.image||(null==(n=t.styles)?void 0:n.link)!==i)break;l-=t.text.length}for(let p=h+1;p<c.length;p+=1){const t=c[p];if(t.image||(null==(r=t.styles)?void 0:r.link)!==i)break;s+=t.text.length}return{href:i,startOffset:l,endOffset:s}}function WT(t,e,a){const n=Math.max(0,Math.min(e,ke(t))),r=Math.max(n,Math.min(a,ke(t))),o=[];let i=0;for(const l of t.runs){const t=i,e=i+l.text.length,a=Math.max(n,t),s=Math.min(r,e);if(a<s){const e=ue(l),n={id:`run:${Math.random().toString(36).slice(2,9)}`,text:e?"":l.text.slice(a-t,s-t)};l.styles&&(n.styles={...l.styles}),l.image&&(n.image={...l.image}),l.textBox&&(n.textBox=AT(l.textBox)),l.revision&&(n.revision={...l.revision}),l.field&&(n.field={...l.field}),l.footnoteReference&&(n.footnoteReference={...l.footnoteReference}),l.endnoteReference&&(n.endnoteReference={...l.endnoteReference}),o.push(n)}i=e}return o}function HT(t,e,a){const n=WT(t,0,e),r=WT(t,e,ke(t)),o=OT(t,e);return RT(t,[...n,...a.map(t=>({...t,styles:yT(t.styles??o)})),...r],o)}function UT(t){const e=[],a=new Map,n=[];let r=0;for(const o of t){const t=Ce(o);e.push({id:o.id,base:r,length:t.length}),a.has(o.id)||a.set(o.id,r),n.push(t),r+=t.length+1}return{text:n.join("\n"),spans:e,baseById:a}}function FT(t,e,a){return t<e?e:t>a?a:t}function BT(t,e,a){const n=UT(e);let r=!1;for(const f of t.order){const e=t.items[f];if(e&&(e.start&&n.baseById.has(e.start.paragraphId)||e.end&&n.baseById.has(e.end.paragraphId))){r=!0;break}}if(!r)return t;const o=UT(a);if(n.text===o.text)return t;const i=n.text.length,l=o.text.length,s=Math.min(i,l),d=function(t,e,a){let n=0;for(;n<a&&t.charCodeAt(t.length-1-n)===e.charCodeAt(e.length-1-n);)n+=1;return n}(n.text,o.text,s),c=function(t,e,a){let n=0;for(;n<a&&t.charCodeAt(n)===e.charCodeAt(n);)n+=1;return n}(n.text,o.text,s-d),h=t=>{const e=n.baseById.get(t.paragraphId);if(void 0===e)return t;const a=e+FT(t.offset,0,i-e),r=FT(function(t,e,a,n,r){return t<=n?t:t>=e-r?t+(a-e):n}(a,i,l,c,d),0,l),s=function(t,e){for(const n of e)if(t<=n.base+n.length)return{paragraphId:n.id,offset:Math.max(0,t-n.base)};const a=e[e.length-1];return{paragraphId:a.id,offset:a.length}}(r,o.spans);return s.paragraphId===t.paragraphId&&s.offset===t.offset?t:{...t,paragraphId:s.paragraphId,offset:s.offset}};let p=!1;const u={...t.items};for(const f of t.order){const e=t.items[f];if(!e)continue;let a=e;if(e.start&&n.baseById.has(e.start.paragraphId)){const t=h(e.start);t!==e.start&&(a={...a,start:t})}if(e.end&&n.baseById.has(e.end.paragraphId)){const t=h(e.end);t!==e.end&&(a={...a,end:t})}a!==e&&(u[f]=a,p=!0)}return p?{...t,items:u}:t}function GT(t,e){if(!function(t){for(const e of t)if("table"===e.type)return!0;return!1}(t))return e;let a=0;const n=t=>{let r=!1;const o=t.map(t=>{if("paragraph"===t.type){const n=e[a++]??t;return n!==t&&(r=!0),n}let o=!1;const i=t.rows.map(t=>{let e=!1;const a=t.cells.map(t=>{const a=n(t.blocks);return a===t.blocks?t:(e=!0,{...t,blocks:a})});return e?(o=!0,{...t,cells:a}):t});return o?(r=!0,{...t,rows:i}):t});return r?o:t};return n(t)}function ZT(t,e,a){const n=da(t);if("footnote"===n){const n=t.activeFootnoteId,r=t.document.footnotes;if(!n||!r||!r.items[n])return{...t,selection:a};const o=r.items[n],i=GT(o.blocks,e);return{...t,document:{...t.document,footnotes:{...r,items:{...r.items,[n]:{...o,blocks:i}}}},selection:a}}const r=Be(t.document),o=Math.max(0,Math.min(sa(t),r.length-1)),i=r[o];if(!i)return{...t,selection:a};const l=function(t,e,a){return"header"===a?{...t,header:GT(t.header??[],e)}:"footer"===a?{...t,footer:GT(t.footer??[],e)}:{...t,blocks:GT(t.blocks,e)}}(i,e,n),s=[...r];s[o]=l;const d=t.document.bookmarks,c=d&&d.order.length>0?BT(d,ha(t),e):d;return{...t,document:{...t.document,sections:s,...c!==d?{bookmarks:c}:{}},selection:a}}function DT(t,e,a){let n=!1;const r=t.map(t=>{if("paragraph"===t.type)return t;let r=!1;const o=t.rows.map(t=>{let n=!1;const o=t.cells.map(t=>{if(!t.blocks.some(t=>e.has(t.id)))return t;const r=a(t);return r!==t&&(n=!0),r});return n?(r=!0,{...t,cells:o}):t});return r?(n=!0,{...t,rows:o}):t});return n?r:t}function KT(t){return ga(t)}function jT(t){const e=ha(t),a=ua(t,t.selection.focus),n=pa(e,a.paragraphId),r=e[n];return{paragraph:r,index:n,offset:Ee(r,a)}}function XT(t){const e=va(t);if(e.isCollapsed)return t;const a=ha(t);if(t.trackChangesEnabled){const n=`rev:${Math.random().toString(36).slice(2,9)}`,r="User",o=Date.now();return ZT(t,a.map((t,a)=>{if(a<e.startIndex||a>e.endIndex)return TT(t);return JT(t,a===e.startIndex?e.startParagraphOffset:0,a===e.endIndex?e.endParagraphOffset:ke(t),t=>{var e;return"insert"===(null==(e=t.revision)?void 0:e.type)?{...t,text:""}:{...t,revision:{id:n,type:"delete",author:r,date:o}}})}),KT(e.start))}const n=a[e.startIndex],r=a[e.endIndex],o=Ee(n,e.start),i=Ee(r,e.end),l=RT(n,[...WT(n,0,o),...WT(r,i,ke(r))]);return ZT(t,[...kT(a.slice(0,e.startIndex)),l,...kT(a.slice(e.endIndex+1))],KT(Ve(l,o)))}function JT(t,e,a,n){return RT(t,[...WT(t,0,e),...WT(t,e,a).map(n),...WT(t,a,ke(t))])}function YT(t,e){const a=t[e.startIndex],n=t[e.endIndex];return{anchor:Ve(a,e.startParagraphOffset),focus:Ve(n,e.endParagraphOffset)}}function QT(t,e){const a=va(t);return a.isCollapsed?t:{document:t.document,selection:KT("start"===e?a.start:a.end)}}function _T(t){return t.map(IT)}function $T(t){return t.reduce((t,e)=>t+e.text.length,0)}function tC(t,e,a){if(0===a.length)return t;const n=ha(t),r=n.findIndex(t=>t.id===e.paragraphId);if(-1===r)return t;const o=n[r],i=Ee(o,e),l=_T(a[0].runs);if(1===a.length){const e=HT(o,i,l),a=n.map((t,a)=>a===r?e:t),s=$T(l);return ZT(t,a,{anchor:Ve(e,i),focus:Ve(e,i+s)})}const s=WT(o,0,i),d=WT(o,i,ke(o)),c=a[a.length-1],h=a.slice(1,-1),p=RT(TT(a[0].paragraphTemplate),[...s,...l],OT(o,i)),u=h.map(t=>RT(TT(t.paragraphTemplate),_T(t.runs))),f=RT(TT(c.paragraphTemplate),[..._T(c.runs),...d],OT(o,i));return ZT(t,[...n.slice(0,r),p,...u,f,...n.slice(r+1)],{anchor:Ve(p,$T(s)),focus:Ve(f,$T(c.runs))})}function eC(t,e,a={}){if(va(t).isCollapsed)return t;if(function(t,e){const a=va(t);if(a.isCollapsed)return!1;const n=ha(t),r=n.findIndex(t=>t.id===e.paragraphId);if(-1===r)return!1;if(r<a.startIndex||r>a.endIndex)return!1;const o=Ee(n[r],e);return!(r===a.startIndex&&o<a.startParagraphOffset||r===a.endIndex&&o>a.endParagraphOffset)}(t,e))return t;const n=function(t){const e=va(t);if(e.isCollapsed)return[];const a=ha(t),n=[];for(let r=e.startIndex;r<=e.endIndex;r+=1){const t=a[r],o=WT(t,r===e.startIndex?e.startParagraphOffset:0,r===e.endIndex?e.endParagraphOffset:ke(t));n.push({paragraphTemplate:TT(t),runs:o})}return n}(t);if(0===n.length)return t;if(a.copy)return tC(t,e,n);const r=function(t,e){const a=va(t),n=ha(t),r=n.findIndex(t=>t.id===e.paragraphId);if(-1===r)return e;const o=Ee(n[r],e);if(a.startIndex===a.endIndex)return r!==a.startIndex||o<=a.endParagraphOffset?e:Ve(n[a.startIndex],o-(a.endParagraphOffset-a.startParagraphOffset));return e}(t,e);return tC(XT(t),r,n)}function aC(t,e,a){if(0===e.length)return t;const n=ma(t.selection)?t:XT(t),{paragraph:r,index:o,offset:i}=jT(n),l=a?{...a}:OT(r,i),s={id:`run:${Math.random().toString(36).slice(2,9)}`,text:e,styles:l};n.trackChangesEnabled&&(s.revision={id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"insert",author:"User",date:Date.now()});const d=HT(r,i,[s]);return ZT(n,ha(n).map((t,e)=>e===o?d:t),KT(Ve(d,i+e.length)))}function nC(t,e,a){if(0===e.length)return t;const n=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n");if(!n.includes("\n"))return aC(t,n,a);const r=ma(t.selection)?t:XT(t),{paragraph:o,index:i,offset:l}=jT(r),s=n.split("\n"),d=OT(o,l),c=RT(o,[...WT(o,0,l),wa(s[0],d)],d),h=WT(o,l,ke(o)),p=s.slice(1,-1).map(t=>LT([{text:t,styles:d}])),u=LT([{text:s[s.length-1],styles:d},...h.map(t=>({text:t.text,styles:t.styles}))]),f=ha(r);return ZT(r,[...f.slice(0,i),c,...p,u,...f.slice(i+1)],KT(Ve(u,s[s.length-1].length)))}function rC(t){var e;if(!ma(t.selection))return XT(t);const{paragraph:a,index:n,offset:r}=jT(t),o=ha(t);if(r>0){if(t.trackChangesEnabled){const i=a.runs;let l=0,s=-1,d=-1;for(let t=0;t<i.length;t+=1){const e=l+i[t].text.length;if(r<=e){s=t,d=r-l;break}l=e}if(-1!==s){const l=i[s];if("insert"===(null==(e=l.revision)?void 0:e.type)){const e=RT(a,[...WT(a,0,r-1),...WT(a,r,ke(a))]);return ZT(t,o.map((t,a)=>a===n?e:t),KT(Ve(e,r-1)))}const c=l.text[d-1],h={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,styles:{...l.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=RT(a,[...WT(a,0,r-1),h,...WT(a,r,ke(a))]);return ZT(t,o.map((t,e)=>e===n?p:t),KT(Ve(p,r-1)))}}const i=RT(a,[...WT(a,0,r-1),...WT(a,r,ke(a))],OT(a,r-1));return ZT(t,o.map((t,e)=>e===n?i:t),KT(Ve(i,r-1)))}if(0===n)return t;const i=o[n-1],l=RT(i,[...i.runs.map(IT),...a.runs.map(IT)]);return ZT(t,[...o.slice(0,n-1),l,...o.slice(n+1)],KT(Ve(l,ke(i))))}function oC(t){var e;if(!ma(t.selection))return XT(t);const{paragraph:a,index:n,offset:r}=jT(t),o=ha(t);if(r<ke(a)){if(t.trackChangesEnabled){const i=a.runs;let l=0,s=-1,d=-1;for(let t=0;t<i.length;t+=1){const e=l+i[t].text.length;if(r<e){s=t,d=r-l;break}l=e}if(-1!==s){const l=i[s];if("insert"===(null==(e=l.revision)?void 0:e.type)){const e=RT(a,[...WT(a,0,r),...WT(a,r+1,ke(a))]);return ZT(t,o.map((t,a)=>a===n?e:t),KT(Ve(e,r)))}const c=l.text[d],h={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,styles:{...l.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=RT(a,[...WT(a,0,r),h,...WT(a,r+1,ke(a))]);return ZT(t,o.map((t,e)=>e===n?p:t),KT(Ve(p,r)))}}const i=RT(a,[...WT(a,0,r),...WT(a,r+1,ke(a))],OT(a,r));return ZT(t,o.map((t,e)=>e===n?i:t),KT(Ve(i,r)))}if(n>=o.length-1)return t;const i=o[n+1],l=RT(a,[...a.runs.map(IT),...i.runs.map(IT)]);return ZT(t,[...o.slice(0,n),l,...o.slice(n+2)],KT(Ve(l,r)))}function iC(t,e){const a=va(t);if(a.isCollapsed)return t;const n=ha(t),r=n.slice(a.startIndex,a.endIndex+1).flatMap((t,e)=>{const n=a.startIndex+e;return WT(t,n===a.startIndex?a.startParagraphOffset:0,n===a.endIndex?a.endParagraphOffset:ke(t))}).filter(t=>t.text.length>0);if(0===r.length)return t;const o=!r.every(t=>{var a;return Boolean(null==(a=t.styles)?void 0:a[e])}),i=n.map((t,n)=>{if(n<a.startIndex||n>a.endIndex)return t;return JT(t,n===a.startIndex?a.startParagraphOffset:0,n===a.endIndex?a.endParagraphOffset:ke(t),t=>({...t,styles:xT(t.styles,e,o)}))});return ZT(t,i,YT(i,a))}function lC(t,e,a){const n=va(t);if(n.isCollapsed)return t;const r=ha(t).map((t,r)=>{if(r<n.startIndex||r>n.endIndex)return t;return JT(t,r===n.startIndex?n.startParagraphOffset:0,r===n.endIndex?n.endParagraphOffset:ke(t),t=>({...t,styles:wT(t.styles,e,a)}))});return ZT(t,r,YT(r,n))}function sC(t){return new RegExp("\\p{L}","u").test(t)}function dC(t,e){switch(e){case"lower":return t.toLowerCase();case"upper":return t.toUpperCase();case"capitalize":return function(t){let e="",a=!1;for(const n of t){const t=sC(n);e+=t&&!a?n.toUpperCase():n,a=t}return e}(t);case"toggle":return function(t){let e="";for(const a of t){const t=a.toUpperCase(),n=a.toLowerCase();e+=a===n&&a!==t?t:a===t&&a!==n?n:a}return e}(t);default:return function(t){let e="",a=!0;for(const n of t.toLowerCase())a&&sC(n)?(e+=n.toUpperCase(),a=!1):(e+=n,"."!==n&&"!"!==n&&"?"!==n||(a=!0));return e}(t)}}function cC(t,e){return function(t,e){const a=va(t);if(a.isCollapsed)return t;const n=ha(t).map((t,n)=>{if(n<a.startIndex||n>a.endIndex)return t;const r=n===a.startIndex?a.startParagraphOffset:0,o=n===a.endIndex?a.endParagraphOffset:ke(t),i=WT(t,r,o).map(t=>t.text).join(""),l=e(i);let s=0;return JT(t,r,o,t=>{const e=t.text.length,a=l.slice(s,s+e);return s+=e,{...t,text:a}})});return ZT(t,n,YT(n,a))}(t,t=>dC(t,e))}function hC(t,e,a){var n;let r;const o=t=>{const a=t.findIndex(t=>t.id===e);return a>=0?(r=t[a],[...t.slice(0,a),...t.slice(a+1)]):t},i={...t.document};if(i.sections&&i.sections.length>0&&(i.sections=i.sections.map(t=>({...t,blocks:o(t.blocks),header:t.header?o(t.header):void 0,footer:t.footer?o(t.footer):void 0}))),!r)return t;const l=a.paragraphId;if("table"===r.type){if(Ge(r).some(t=>t.id===l))return t}const s=t=>{const e=t.findIndex(t=>t.id===l||"table"===t.type&&Ge(t).some(t=>t.id===l));if(e<0)return{nextBlocks:t,found:!1};return{nextBlocks:[...t.slice(0,e),r,...t.slice(e)],found:!0}},d=sa(t),c=da(t),h={...null==(n=i.sections)?void 0:n[d]};let p=!1;if("header"===c){const t=s(h.header??[]);h.header=t.nextBlocks,p=t.found}else if("footer"===c){const t=s(h.footer??[]);h.footer=t.nextBlocks,p=t.found}else{const t=s(h.blocks);h.blocks=t.nextBlocks,p=t.found}return p||(h.blocks=[...h.blocks,r]),i.sections=[...i.sections??[]],i.sections[d]=h,{...t,document:i}}function pC(t){const e=ma(t.selection)?t:XT(t),{paragraph:a,index:n,offset:r}=jT(e),o=RT(a,WT(a,0,r),OT(a,r)),i=WT(a,r,ke(a)),l=i.length>0?zT(a,i.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Sa("");return t.style=a.style?{...a.style}:void 0,t.list=a.list?{...a.list}:void 0,t})(),s=ha(e);return ZT(e,[...kT(s.slice(0,n)),o,l,...kT(s.slice(n+1))],KT(Ve(l,0)))}function uC(t){const e=ma(t.selection)?t:XT(t),{paragraph:a,index:n,offset:r}=jT(e),o=RT(a,WT(a,0,r),OT(a,r)),i=WT(a,r,ke(a)),l=i.length>0?zT(a,i.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Sa("");return t.style=a.style?{...a.style}:void 0,t.list=a.list?{...a.list}:void 0,t})();l.style={...a.style??{},pageBreakBefore:!0};const s=ha(e);return ZT(e,[...kT(s.slice(0,n)),o,l,...kT(s.slice(n+1))],KT(Ve(l,0)))}function fC(t,e,a){const n=va(t),r=ha(t),o=n.startIndex,i=n.endIndex,l=r.map((t,n)=>n<o||n>i?TT(t):{...TT(t),style:ST(t.style,e,a)});return ZT(t,l,YT(l,n))}function gC(t,e,a){const n={...t??{}};return null===a?delete n[e]:n[e]=a,Object.keys(n).length>0?n:void 0}function mC(t,e){const a=Be(t.document).map(t=>({...t,blocks:e(t.blocks),header:t.header?e(t.header):void 0,footer:t.footer?e(t.footer):void 0}));return{...t,document:{...t.document,sections:a}}}function vC(t,e){return t.map(t=>"table"===t.type?e(t):t)}function bC(t,e){return t.map(t=>"paragraph"===t.type?t:{...e(t),rows:t.rows.map(t=>({...t,cells:t.cells.map(t=>({...t,blocks:bC(t.blocks,e)}))}))})}function yC(t){const e=sa(t),a=_e(t.document,t.selection.focus.paragraphId,e);return a?{activeSectionIndex:e,loc:a}:null}function MC(t,e){const a=yC(t);if(!a)return t;const{activeSectionIndex:n,loc:r}=a,o=da(t),i=(t,a)=>t.map((t,n)=>"table"===t.type&&n===r.blockIndex&&a===r.zone?e(t):t),l=Be(t.document).map((t,e)=>e!==n?t:{...t,blocks:"main"===o?i(t.blocks,"main"):t.blocks,header:"header"===o&&t.header?i(t.header,"header"):t.header,footer:"footer"===o&&t.footer?i(t.footer,"footer"):t.footer});return{...t,document:{...t.document,sections:l}}}function xC(t){const e=new Set,a=sa(t),n=_e(t.document,t.selection.anchor.paragraphId,a),r=_e(t.document,t.selection.focus.paragraphId,a);if(!n||!r||n.blockIndex!==r.blockIndex||n.zone!==r.zone)return e;const o=function(t,e,a){const n=Be(t)[e];if(n)return"header"===a?n.header:"footer"===a?n.footer:n.blocks}(t.document,a,n.zone),i=null==o?void 0:o[n.blockIndex];if(!i||"table"!==i.type)return e;const l=sn(i),s=l.find(t=>t.rowIndex===n.rowIndex&&t.cellIndex===n.cellIndex),d=l.find(t=>t.rowIndex===r.rowIndex&&t.cellIndex===r.cellIndex);if(!s||!d)return e;const c=Math.min(s.visualRowIndex,d.visualRowIndex),h=Math.max(s.visualRowIndex+s.rowSpan-1,d.visualRowIndex+d.rowSpan-1),p=Math.min(s.visualColumnIndex,d.visualColumnIndex),u=Math.max(s.visualColumnIndex+s.colSpan-1,d.visualColumnIndex+d.colSpan-1),f=l.filter(t=>t.visualRowIndex<=h&&t.visualRowIndex+t.rowSpan-1>=c&&t.visualColumnIndex<=u&&t.visualColumnIndex+t.colSpan-1>=p);for(const g of f)for(const t of g.cell.blocks)e.add(t.id);return e}function wC(t,e,a){const n=xC(t);if(0===n.size)for(const i of function(t){const e=new Set,a=va(t),n=ha(t);for(let r=a.startIndex;r<=a.endIndex;r+=1)e.add(n[r].id);return e}(t))n.add(i);const r=t=>({...t,style:gC(t.style,e,a)}),o=Be(t.document).map(t=>({...t,blocks:DT(t.blocks,n,r),header:t.header?DT(t.header,n,r):void 0,footer:t.footer?DT(t.footer,n,r):void 0}));return{...t,document:{...t.document,sections:o}}}function SC(t,e){let a=wC(t,"borderTop",e);return a=wC(a,"borderRight",e),a=wC(a,"borderBottom",e),a=wC(a,"borderLeft",e),a}function AC(t,e,a){const n=function(t){const e=va(t),a=ha(t),n=new Set;for(let r=e.startIndex;r<=e.endIndex;r+=1)n.add(a[r].id);return n}(t),r=t=>t.map(t=>{if("paragraph"===t.type)return t;const o=Ge(t).some(t=>n.has(t.id)),i=t.rows.map(t=>({...t,cells:t.cells.map(t=>({...t,blocks:r(t.blocks)}))})),l={...t,rows:i};return o?(s=l,{...s,style:gC(s.style,e,a)}):l;var s});return mC(t,r)}function IC(t,e,a,n){const r=t=>t.id!==e?t:{...t,style:gC(t.style,a,n)};return mC(t,t=>bC(t,r))}function TC(t,e,a){const n=yC(t);if(!n)return t;return MC(t,t=>{const r=t.rows.map((t,r)=>r===n.loc.rowIndex?{...t,style:gC(t.style,e,a)}:t);return{...t,rows:r}})}function CC(t){if("number"==typeof t&&Number.isFinite(t))return t;if("string"!=typeof t)return null;const e=t.trim().toLowerCase();if(!e||e.includes("%"))return null;if(e.endsWith("pt")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t:null}if(e.endsWith("px")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t*wn:null}if(!/^[+-]?\d+(\.\d+)?$/.test(e))return null;const a=Number.parseFloat(e);return Number.isFinite(a)?a:null}function kC(t,e,a,n,r){const o=t=>{var o;if(t.id!==e)return t;const i=sn(t),l=Math.max(1,...i.map(t=>t.visualColumnIndex+Math.max(1,t.colSpan))),s=Array(l);let d=!1,c=!0;for(let e=0;e<l;e+=1){const n=CC(a[e]);if(null!==n){s[e]=Math.max(1,n),d=!0;continue}const r=null==(o=t.gridCols)?void 0:o[e];if(!("number"==typeof r&&Number.isFinite(r)&&r>0)){c=!1;break}s[e]=r}const h=t.rows.map((t,e)=>{const n=t.cells.map((t,n)=>{const r=i.find(t=>t.rowIndex===e&&t.cellIndex===n);if(!r)return t;const o=r.visualColumnIndex+r.colSpan-1,l=a[o];return void 0!==l&&1===r.colSpan?{...t,style:{...t.style??{},width:l}}:t});return{...t,cells:n}}),p={...t.style??{}};return void 0!==n&&(p.width=n),void 0!==r&&(p.indentLeft="number"==typeof r?r:Number(r)),{...t,rows:h,gridCols:d&&c?s:t.gridCols,style:Object.keys(p).length>0?p:void 0}};return mC(t,t=>vC(t,o))}const VC={activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingSummary:"",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,shading:"",altTitle:"",altDescription:""};function EC(t){const e=sa(t),a=_e(t.document,t.selection.focus.paragraphId,e);if(!a)return null;const n=function(t,e){const a=Be(t.document)[sa(t)];return a?"header"===e?a.header??[]:"footer"===e?a.footer??[]:a.blocks:[]}(t,a.zone)[a.blockIndex];if(!n||"table"!==n.type)return null;const r=sn(n).find(t=>t.rowIndex===a.rowIndex&&t.cellIndex===a.cellIndex);return{table:n,tableId:n.id,rowIndex:a.rowIndex,cellIndex:a.cellIndex,visualColumnIndex:(null==r?void 0:r.visualColumnIndex)??a.cellIndex}}function RC(t){if("number"==typeof t&&Number.isFinite(t))return{value:String(t),unit:"points"};if("string"==typeof t){const e=t.trim();if(e.endsWith("%"))return{value:e.slice(0,-1),unit:"percent"};const a=e.match(/^([0-9.]+)(pt)?$/i);if(null==a?void 0:a[1])return{value:a[1],unit:"points"}}return{value:"",unit:"points"}}function LC(t){return!!t&&"none"!==t.type&&t.width>0}function zC(t,e="table"){var a,n,r,o,i,l,s,d,c,h,p;const u=RC(null==(a=t.table.style)?void 0:a.width),f=t.table.rows[t.rowIndex],g=null==f?void 0:f.cells[t.cellIndex],m=RC(null==(n=null==f?void 0:f.style)?void 0:n.height),v=RC(null==(r=null==g?void 0:g.style)?void 0:r.width),b=RC(null==(o=t.table.gridCols)?void 0:o[t.visualColumnIndex]),y=(null==g?void 0:g.style)??{},M=[y.borderTop,y.borderRight,y.borderBottom,y.borderLeft].filter(LC)[0],x=function(t){var e;const a=null==(e=t.style)?void 0:e.floating;return a&&0!==Object.keys(a).length?Object.entries(a).map(([t,e])=>`${t}=${e}`).join(", "):""}(t.table);return{...VC,activeTab:e,tableWidth:u.value,tableWidthUnit:u.unit,tableAlign:(null==(i=t.table.style)?void 0:i.align)??"",tableIndentLeft:RC(null==(l=t.table.style)?void 0:l.indentLeft).value,tableWrapping:x?"around":"none",floatingSummary:x,rowHeight:m.value,rowHeightRule:(null==(s=null==f?void 0:f.style)?void 0:s.heightRule)??"",repeatHeader:Boolean(null==f?void 0:f.isHeader),allowBreakAcrossPages:!0!==(null==(d=null==f?void 0:f.style)?void 0:d.cantSplit),hiddenRow:!0===(null==(c=null==f?void 0:f.style)?void 0:c.hidden),columnWidth:b.value,cellWidth:v.value,cellVerticalAlign:y.verticalAlign??"",cellTextDirection:y.textDirection??"",cellNoWrap:!0===y.noWrap,cellFitText:!0===y.fitText,cellHideMark:!0===y.hideMark,marginTop:null!=y.paddingTop?String(y.paddingTop):"",marginRight:null!=y.paddingRight?String(y.paddingRight):"",marginBottom:null!=y.paddingBottom?String(y.paddingBottom):"",marginLeft:null!=y.paddingLeft?String(y.paddingLeft):"",borderStyle:(null==M?void 0:M.type)??"none",borderWidth:M?String(M.width):"",borderColor:(null==M?void 0:M.color)??"",borderTop:LC(y.borderTop),borderRight:LC(y.borderRight),borderBottom:LC(y.borderBottom),borderLeft:LC(y.borderLeft),shading:y.shading??"",altTitle:(null==(h=t.table.style)?void 0:h.altTitle)??"",altDescription:(null==(p=t.table.style)?void 0:p.altDescription)??""}}function NC(t,e,a){return wC(t,e,a)}function qC(t,e){const a=EC(t);if(!a)return t;let n=t;return n=IC(n,a.tableId,"width",e.tableWidth),n=IC(n,a.tableId,"align",e.tableAlign),n=IC(n,a.tableId,"indentLeft",e.tableIndentLeft),n=IC(n,a.tableId,"altTitle",e.altTitle),n=IC(n,a.tableId,"altDescription",e.altDescription),n=function(t,e){const a=yC(t);return a?MC(t,t=>({...t,rows:t.rows.map((t,n)=>n===a.loc.rowIndex?{...t,isHeader:null===e?void 0:e}:t)})):t}(n,e.repeatHeader),n=TC(n,"height",e.rowHeight),n=TC(n,"heightRule",e.rowHeightRule),n=TC(n,"cantSplit",e.cantSplit),n=TC(n,"hidden",e.hiddenRow),null!==e.columnWidth&&(n=kC(n,a.tableId,{[a.visualColumnIndex]:e.columnWidth})),n=NC(n,"width",e.cellWidth),n=NC(n,"verticalAlign",e.cellVerticalAlign),n=NC(n,"textDirection",e.cellTextDirection),n=NC(n,"noWrap",e.cellNoWrap),n=NC(n,"fitText",e.cellFitText),n=NC(n,"hideMark",e.cellHideMark),n=NC(n,"paddingTop",e.margins.top),n=NC(n,"paddingRight",e.margins.right),n=NC(n,"paddingBottom",e.margins.bottom),n=NC(n,"paddingLeft",e.margins.left),n=NC(n,"borderTop",e.borders.top),n=NC(n,"borderRight",e.borders.right),n=NC(n,"borderBottom",e.borders.bottom),n=NC(n,"borderLeft",e.borders.left),n=NC(n,"shading",e.shading),n}function OC(t){const e=()=>{return e=t.state(),Boolean(EC(e));var e};return{isInsideTable:e,openTablePropertiesDialog:(e="table")=>{const a=function(t,e="table"){const a=EC(t);return a?zC(a,e):null}(t.state(),e);a&&(t.setContextMenu({isOpen:!1,x:0,y:0}),t.setTablePropertiesDialog({isOpen:!0,initial:a}))},applyTablePropertiesDialogValues:a=>{t.isReadOnly()||e()&&(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(t=>qC(t,a),{mergeKey:"tableProperties"}),t.focusInput())}}}function PC(t){if(!t)return"";const e=[];t.fontFamily&&e.push(`font-family:${t.fontFamily}`),void 0!==t.fontSize&&null!==t.fontSize&&e.push(`font-size:${t.fontSize}px`),t.color&&e.push(`color:${t.color}`),t.highlight?e.push(`background-color:${t.highlight}`):t.shading&&e.push(`background-color:${t.shading}`),t.superscript?(e.push("vertical-align:super"),e.push("font-size:0.75em")):t.subscript&&(e.push("vertical-align:sub"),e.push("font-size:0.75em")),t.bold&&e.push("font-weight:700"),t.italic&&e.push("font-style:italic"),t.hidden&&e.push("display:none"),t.allCaps&&e.push("text-transform:uppercase"),t.smallCaps&&e.push("font-variant:small-caps"),void 0!==t.characterScale&&null!==t.characterScale&&e.push(`font-stretch:${t.characterScale}%`),void 0!==t.characterSpacing&&null!==t.characterSpacing&&e.push(`letter-spacing:${t.characterSpacing}pt`),WC(t.language)&&e.push("hyphens:auto"),void 0!==t.baselineShift&&null!==t.baselineShift&&e.push(`vertical-align:${t.baselineShift}pt`);const a=function(t){switch(t){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 null}}(t.ligatures);a&&e.push(`font-variant-ligatures:${a}`);const n=function(t,e){const a=[];"proportional"===t&&a.push("proportional-nums");"tabular"===t&&a.push("tabular-nums");"lining"===e&&a.push("lining-nums");"oldStyle"===e&&a.push("oldstyle-nums");return a.join(" ")||null}(t.numberSpacing,t.numberForm);n&&e.push(`font-variant-numeric:${n}`);const r=function(t,e){const a=[];"number"==typeof t&&t>=1&&t<=20&&a.push(`"ss${String(t).padStart(2,"0")}" 1`);e&&a.push('"calt" 1');return a.join(", ")||null}(t.stylisticSet,t.contextualAlternates);r&&e.push(`font-feature-settings:${r}`);const o=[];if((t.underline||t.link)&&o.push("underline"),t.strike&&o.push("line-through"),t.doubleStrike&&o.push("line-through"),o.length>0&&(e.push(`text-decoration:${o.join(" ")}`),t.underline||t.link)){const a=function(t){switch(t){case"double":case"wavyDouble":return"double";case"dotted":case"dottedHeavy":return"dotted";case"dash":case"dashedHeavy":case"dashLong":case"dashLongHeavy":case"dotDash":case"dashDotHeavy":case"dotDotDash":case"dashDotDotHeavy":return"dashed";case"wave":case"wavyHeavy":return"wavy";default:return null}}(t.underlineStyle);a&&e.push(`text-decoration-style:${a}`),t.underlineColor&&e.push(`text-decoration-color:${t.underlineColor}`)}return e.join(";")}function WC(t){return(null==t?void 0:t.value)??(null==t?void 0:t.bidi)??(null==t?void 0:t.eastAsia)??null}function HC(t){if(!t)return"";const e=[];if(t.align&&e.push(`text-align:${t.align}`),void 0!==t.lineHeight&&null!==t.lineHeight){const a="exact"===t.lineRule||"atLeast"===t.lineRule;e.push(`line-height:${t.lineHeight}${a?"px":""}`)}return void 0!==t.spacingBefore&&null!==t.spacingBefore&&e.push(`padding-top:${t.spacingBefore}px`),void 0!==t.spacingAfter&&null!==t.spacingAfter&&e.push(`padding-bottom:${t.spacingAfter}px`),void 0!==t.indentLeft&&null!==t.indentLeft&&e.push(`padding-left:${t.indentLeft}px`),void 0!==t.indentRight&&null!==t.indentRight&&e.push(`padding-right:${t.indentRight}px`),void 0!==t.indentFirstLine&&null!==t.indentFirstLine&&e.push(`text-indent:${t.indentFirstLine}px`),e.join(";")}function UC(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function FC(t,e){if(t.image)return function(t,e){var a;if(!t.image)return"";const n=Ue(e,t.image.src),r=void 0!==t.image.alt?` alt="${UC(t.image.alt)}"`:"",o=`<img src="${UC(n)}" width="${Math.max(1,Math.round(t.image.width))}" height="${Math.max(1,Math.round(t.image.height))}"${r}>`;return(null==(a=t.styles)?void 0:a.link)?`<a href="${UC(t.styles.link)}">${o}</a>`:o}(t,e);let a=UC(t.text).replace(/\n/g,"<br>");const n=t.styles??void 0;(null==n?void 0:n.strike)&&(a=`<s>${a}</s>`),(null==n?void 0:n.underline)&&(a=`<u>${a}</u>`),(null==n?void 0:n.italic)&&(a=`<em>${a}</em>`),(null==n?void 0:n.bold)&&(a=`<strong>${a}</strong>`),(null==n?void 0:n.superscript)?a=`<sup>${a}</sup>`:(null==n?void 0:n.subscript)&&(a=`<sub>${a}</sub>`);const r=PC(n),o=function(t){if(!t)return"";const e=[],a=WC(t);return a&&e.push(`lang="${UC(a)}"`),t.value&&e.push(`data-oasis-lang-value="${UC(t.value)}"`),t.eastAsia&&e.push(`data-oasis-lang-east-asia="${UC(t.eastAsia)}"`),t.bidi&&e.push(`data-oasis-lang-bidi="${UC(t.bidi)}"`),e.length>0?` ${e.join(" ")}`:""}(null==n?void 0:n.language);if(r.length>0||o.length>0){a=`<span${r.length>0?` style="${r}"`:""}${o}>${a}</span>`}return(null==n?void 0:n.link)&&(a=`<a href="${UC(n.link)}">${a}</a>`),a}function BC(t,e){return t.map(t=>FC(t,e)).join("")||"<br>"}function GC(t){var e;const a=va(t);if(a.isCollapsed)return"";const n=ha(t),r=[];let o=null;const i=()=>{o&&(r.push("bullet"===o?"</ul>":"</ol>"),o=null)};for(let l=a.startIndex;l<=a.endIndex;l+=1){const s=n[l];if(!s)continue;const d=WT(s,l===a.startIndex?a.startParagraphOffset:0,l===a.endIndex?a.endParagraphOffset:ke(s)),c=HC(s.style),h=c.length>0?` style="${c}"`:"",p=BC(d,t.document);if(null==(e=s.list)?void 0:e.kind){const t="bullet"===s.list.kind?"ul":"ol";o!==s.list.kind&&(i(),r.push(`<${t}>`),o=s.list.kind),r.push(`<li${h}>${p}</li>`);continue}i(),r.push(`<p${h}>${p}</p>`)}return i(),r.join("")}function ZC(t,e){if(0===e.length)return t;const a=ma(t.selection)?t:XT(t),{paragraph:n,index:r,offset:o}=jT(a),i=ha(a),l=WT(n,0,o),s=WT(n,o,ke(n)),d=e.map(t=>{const e=Aa(t.runs.map(t=>({text:t.text,styles:yT(t.styles),image:t.image?{...t.image}:void 0})));return e.style=t.style?{...t.style}:void 0,e.list=t.list?{...t.list}:void 0,e});let c,h=KT(Ve(n,o));if(1===d.length){const t=d[0],e=t.runs.reduce((t,e)=>t+e.text.length,0),a=RT(n,[...l,...t.runs.map(IT),...s],OT(n,o));a.style=n.style?{...n.style}:t.style?{...t.style}:void 0,a.list=n.list?{...n.list}:t.list?{...t.list}:void 0,c=[...kT(i.slice(0,r)),a,...kT(i.slice(r+1))],h=KT(Ve(a,l.reduce((t,e)=>t+e.text.length,0)+e))}else{const t=d[0],e=d[d.length-1],a=e.runs.reduce((t,e)=>t+e.text.length,0),p=RT(n,[...l,...t.runs.map(IT)],OT(n,o));p.style=n.style?{...n.style}:t.style?{...t.style}:void 0,p.list=n.list?{...n.list}:t.list?{...t.list}:void 0;const u=d.slice(1,-1).map(TT),f=RT(e,[...e.runs.map(IT),...s],void 0);f.list=e.list?{...e.list}:void 0,c=[...kT(i.slice(0,r)),p,...u,f,...kT(i.slice(r+1))],h=KT(Ve(f,a))}return ZT(a,c,h)}function DC(t,e){return{document:t.document,selection:e}}function KC(t,e){if(!ma(t.selection))return QT(t,e<0?"start":"end");const{index:a,offset:n}=jT(t),r=ha(t),o=a+e;if(o<0||o>=r.length)return t;const i=r[o];return DC(t,KT(Ve(i,Math.min(n,ke(i)))))}function jC(t,e){const a=ua(t,t.selection.focus),n=ha(t),r=pa(n,a.paragraphId),o=n[r],i=Ee(o,a),l=ke(o);if(e<0&&i>0)return DC(t,{anchor:t.selection.anchor,focus:Ve(o,i-1)});if(e>0&&i<l)return DC(t,{anchor:t.selection.anchor,focus:Ve(o,i+1)});if(e<0&&r>0){const e=n[r-1];return DC(t,{anchor:t.selection.anchor,focus:Ve(e,ke(e))})}if(e>0&&r<n.length-1){const e=n[r+1];return DC(t,{anchor:t.selection.anchor,focus:Ve(e,0)})}return t}function XC(t,e){const a=ua(t,t.selection.focus),n=ha(t),r=pa(n,a.paragraphId),o=Ee(n[r],a),i=r+e;if(i<0||i>=n.length)return t;const l=n[i];return DC(t,{anchor:t.selection.anchor,focus:Ve(l,Math.min(o,ke(l)))})}function JC(t){const e=va(t);if(e.isCollapsed)return"";const a=ha(t);if(e.startIndex===e.endIndex){return Ce(a[e.startIndex]).slice(e.startParagraphOffset,e.endParagraphOffset)}const n=[],r=a[e.startIndex],o=a[e.endIndex];n.push(Ce(r).slice(e.startParagraphOffset));for(let i=e.startIndex+1;i<e.endIndex;i+=1)n.push(Ce(a[i]));return n.push(Ce(o).slice(0,e.endParagraphOffset)),n.join("\n")}function YC(t,e){return{...t,selection:{anchor:ua(t,e.anchor),focus:ua(t,e.focus)}}}function QC(t){if(!ma(t.selection))return QT(t,"start");const{paragraph:e,index:a,offset:n}=jT(t),r=ha(t);if(n>0)return{document:t.document,selection:KT(Ve(e,n-1))};if(0===a)return t;const o=r[a-1];return{document:t.document,selection:KT(Ve(o,ke(o)))}}function _C(t){if(!ma(t.selection))return QT(t,"end");const{paragraph:e,index:a,offset:n}=jT(t),r=ha(t);if(n<ke(e))return{document:t.document,selection:KT(Ve(e,n+1))};if(a>=r.length-1)return t;const o=r[a+1];return{document:t.document,selection:KT(Ve(o,0))}}function $C(t){if("undefined"==typeof document||0===t.trim().length)return[];const e=document.createElement("template");e.innerHTML=t;const a=[],n=Array.from(e.content.childNodes),r=(t,e,n)=>{const r=e.length>0?e:[wa("")];a.push({runs:r.map(t=>({text:t.text,styles:yT(t.styles),image:t.image?{...t.image}:void 0})),style:t?jb(t):void 0,list:n})},o=(t,e)=>{for(const a of Array.from(t.children))"LI"===a.tagName&&r(a,Zb(a,void 0),{kind:e,level:0})};for(const i of n){if(i.nodeType===Node.TEXT_NODE){const t=i.textContent??"";t.trim().length>0&&r(null,[wa(t)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const t=i,e=Kb(t.tagName);if(e){o(t,e);continue}if(Db(t.tagName)){r(t,Zb(t,void 0),"LI"===t.tagName?{kind:"bullet",level:0}:void 0);continue}const a=Zb(t,void 0);a.length>0&&r(null,a)}return a}function tk(t){const{state:e,tableOps:a,applyTableContextCommand:n}=t;return{isInsideTable:t.isInsideTable,canMerge:()=>a.canMergeSelectedTable(e()),canSplit:()=>a.canSplitSelectedTable(e()),canEditColumn:()=>a.canEditSelectedTableColumn(e()),canEditRow:()=>a.canEditSelectedTableRow(e()),openProperties:()=>t.openTablePropertiesDialog("table"),openBordersAndShading:()=>t.openTablePropertiesDialog("cell"),merge:()=>n(t=>a.mergeSelectedTable(t),"mergeTable"),split:()=>n(t=>a.splitSelectedTable(t),"splitTable"),insertColumnBefore:()=>n(t=>a.insertSelectedTableColumn(t,-1),"insertTableColumn"),insertColumnAfter:()=>n(t=>a.insertSelectedTableColumn(t,1),"insertTableColumn"),deleteColumn:()=>n(t=>a.deleteSelectedTableColumn(t),"deleteTableColumn"),insertRowBefore:()=>n(t=>a.insertSelectedTableRow(t,-1),"insertTableRow"),insertRowAfter:()=>n(t=>a.insertSelectedTableRow(t,1),"insertTableRow"),deleteRow:()=>n(t=>a.deleteSelectedTableRow(t),"deleteTableRow")}}function ek(t){const{computeFontFamilyOptions:e,computeFontSizeOptions:a,loadLocalFontFamilyOptions:n}=bT({state:t.state,toolbarStyleState:t.toolbarStyleState}),r=function(t){return{openFontDialog:()=>{var e;t.loadLocalFontFamilyOptions(),t.setFontDialog({isOpen:!0,initial:(e=t.toolbarStyleState(),{fontFamily:e.fontFamily??"",fontSize:SM(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)})}),t.setContextMenu({isOpen:!1,x:0,y:0})},applyFontDialogValues:(e,a)=>{t.isReadOnly()||(ma(t.selection())||(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(t=>{let n=t;e.fontFamily!==(a.fontFamily||null)&&(n=lC(n,"fontFamily",e.fontFamily)),e.fontSize!==(a.fontSize?Number(a.fontSize):null)&&(n=lC(n,"fontSize",AM(e.fontSize)));const r="automatic"===a.colorMode?null:a.color||null;e.color!==r&&(n=lC(n,"color",e.color)),(e.highlight??"")!==(a.highlight??"")&&(n=lC(n,"highlight",e.highlight)),(e.shading??"")!==(a.shading??"")&&(n=lC(n,"shading",e.shading)),e.bold!==Boolean(a.bold)&&(n=iC(n,"bold")),e.italic!==Boolean(a.italic)&&(n=iC(n,"italic"));const o=a.underline?a.underlineStyle??"single":null;(e.underlineStyle??null)!==(o??null)&&(n=lC(n,"underlineStyle",e.underlineStyle));const i=a.underline&&a.underlineColor||null;(e.underlineColor??null)!==(i??null)&&(n=lC(n,"underlineColor",e.underlineColor)),e.underline!==Boolean(a.underline)&&(n=iC(n,"underline")),e.strike!==Boolean(a.strike)&&(n=iC(n,"strike")),e.doubleStrike!==Boolean(a.doubleStrike)&&(n=iC(n,"doubleStrike")),e.superscript!==Boolean(a.superscript)&&(n=iC(n,"superscript")),e.subscript!==Boolean(a.subscript)&&(n=iC(n,"subscript")),e.superscript&&e.subscript&&(n=iC(n,"subscript")),e.strike&&e.doubleStrike&&(n=iC(n,"doubleStrike")),e.smallCaps!==Boolean(a.smallCaps)&&(n=iC(n,"smallCaps")),e.allCaps!==Boolean(a.allCaps)&&(n=iC(n,"allCaps")),e.hidden!==Boolean(a.hidden)&&(n=iC(n,"hidden"));const l=a.characterScale?Number(a.characterScale):null;(e.characterScale??null)!==(l??null)&&(n=lC(n,"characterScale",e.characterScale));const s=a.characterSpacing?Number(a.characterSpacing):null;(e.characterSpacing??null)!==(s??null)&&(n=lC(n,"characterSpacing",e.characterSpacing));const d=a.baselineShift?Number(a.baselineShift):null;(e.baselineShift??null)!==(d??null)&&(n=lC(n,"baselineShift",e.baselineShift));const c=a.kerningThreshold?Number(a.kerningThreshold):null;(e.kerningThreshold??null)!==(c??null)&&(n=lC(n,"kerningThreshold",e.kerningThreshold)),(e.ligatures??null)!==(a.ligatures||null)&&(n=lC(n,"ligatures",e.ligatures)),(e.numberSpacing??null)!==(a.numberSpacing||null)&&(n=lC(n,"numberSpacing",e.numberSpacing)),(e.numberForm??null)!==(a.numberForm||null)&&(n=lC(n,"numberForm",e.numberForm));const h=a.stylisticSet?Number(a.stylisticSet):null;return(e.stylisticSet??null)!==(h??null)&&(n=lC(n,"stylisticSet",e.stylisticSet)),e.contextualAlternates!==Boolean(a.contextualAlternates)&&(n=iC(n,"contextualAlternates")),n},{mergeKey:"font-dialog"})),t.focusInput())}}}({toolbarStyleState:t.toolbarStyleState,selection:t.selection,isReadOnly:t.isReadOnly,loadLocalFontFamilyOptions:n,setFontDialog:t.setFontDialog,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,focusInput:t.focusInput}),o=r.openFontDialog,i=function(t){return{openParagraphDialog:()=>{var e;t.setParagraphDialog({isOpen:!0,initial:(e=t.toolbarStyleState(),{align:e.align??"",indentLeft:e.indentLeft??"",indentRight:e.indentRight??"",indentFirstLine:e.indentFirstLine??"",indentHanging:e.indentHanging??"",spacingBefore:e.spacingBefore??"",spacingAfter:e.spacingAfter??"",lineHeight:e.lineHeight??"",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})}),t.setContextMenu({isOpen:!1,x:0,y:0})},applyParagraphDialogValues:(e,a)=>{if(t.isReadOnly())return;t.clearPreferredColumn(),t.resetTransactionGrouping();const n=t=>{if(""===t.trim())return null;const e=Number(t);return Number.isFinite(e)?e:null};t.applyTransactionalState(t=>{let r=t;e.align!==(a.align||null)&&(r=fC(r,"align",e.align)),e.indentLeft!==n(a.indentLeft)&&(r=fC(r,"indentLeft",e.indentLeft)),e.indentRight!==n(a.indentRight)&&(r=fC(r,"indentRight",e.indentRight)),e.indentFirstLine!==n(a.indentFirstLine)&&(r=fC(r,"indentFirstLine",e.indentFirstLine)),e.indentHanging!==n(a.indentHanging)&&(r=fC(r,"indentHanging",e.indentHanging)),e.spacingBefore!==n(a.spacingBefore)&&(r=fC(r,"spacingBefore",e.spacingBefore)),e.spacingAfter!==n(a.spacingAfter)&&(r=fC(r,"spacingAfter",e.spacingAfter)),e.lineHeight!==n(a.lineHeight)&&(r=fC(r,"lineHeight",e.lineHeight)),e.shading!==(a.shading||null)&&(r=fC(r,"shading",e.shading));const o="solid"===a.borderStyle||"dashed"===a.borderStyle||"dotted"===a.borderStyle?{type:a.borderStyle,width:Number(a.borderWidth)||0,color:a.borderColor||"#000000"}:null,i={borderTop:a.borderSideTop?o:null,borderRight:a.borderSideRight?o:null,borderBottom:a.borderSideBottom?o:null,borderLeft:a.borderSideLeft?o:null},l={borderTop:e.borders.top,borderRight:e.borders.right,borderBottom:e.borders.bottom,borderLeft:e.borders.left};for(const e of["borderTop","borderRight","borderBottom","borderLeft"])JSON.stringify(l[e])!==JSON.stringify(i[e])&&(r=fC(r,e,l[e]));return r},{mergeKey:"paragraph-dialog"}),t.focusInput()}}}({toolbarStyleState:t.toolbarStyleState,isReadOnly:t.isReadOnly,setParagraphDialog:t.setParagraphDialog,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,focusInput:t.focusInput}),l=i.openParagraphDialog,s=OC({state:t.state,isReadOnly:t.isReadOnly,setTablePropertiesDialog:t.setTablePropertiesDialog,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,focusInput:t.focusInput}),d=s.openTablePropertiesDialog,c=function(t){const e=t.t,a=async()=>{var e;const a=t.state(),n=JC(a);if(!n)return;const r=GC(a);try{"undefined"!=typeof ClipboardItem&&(null==(e=navigator.clipboard)?void 0:e.write)?await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([n],{type:"text/plain"}),"text/html":new Blob([r],{type:"text/html"})})]):await navigator.clipboard.writeText(n)}catch(o){t.logger.warn("contextMenu:copy:failed",{error:String(o)});try{await navigator.clipboard.writeText(n)}catch{}}},n=async()=>{t.isReadOnly()||JC(t.state())&&(await a(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>rC(t))),t.focusInput())},r=async()=>{var e,a;if(t.isReadOnly())return;let n="",r="";try{if(null==(e=navigator.clipboard)?void 0:e.read){const t=await navigator.clipboard.read();for(const e of t){if(e.types.includes("text/html")){const t=await e.getType("text/html");n=await t.text()}if(e.types.includes("text/plain")){const t=await e.getType("text/plain");r=await t.text()}}}else(null==(a=navigator.clipboard)?void 0:a.readText)&&(r=await navigator.clipboard.readText())}catch(i){t.logger.warn("contextMenu:paste:failed",{error:String(i)});try{r=await navigator.clipboard.readText()}catch{return}}const o=$C(n);if(o.length>0)return t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>ZC(t,o))),void t.focusInput();r&&(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>nC(t,r))),t.focusInput())};return{buildContextMenuItems:()=>{const o=!ma(t.state().selection),i=t.isReadOnly(),l=[{id:"cut",label:e("contextmenu.cut"),icon:"scissors",shortcut:"Ctrl+X",disabled:i||!o,testId:"editor-context-menu-cut",onSelect:()=>{n()}},{id:"copy",label:e("contextmenu.copy"),icon:"copy",shortcut:"Ctrl+C",disabled:!o,testId:"editor-context-menu-copy",onSelect:()=>{a()}},{id:"paste",label:e("contextmenu.paste"),icon:"clipboard",shortcut:"Ctrl+V",disabled:i,testId:"editor-context-menu-paste",onSelect:()=>{r()}},{id:"sep1",type:"separator"},{id:"link",label:e("contextmenu.link"),icon:"link",disabled:i||!o,testId:"editor-context-menu-link",onSelect:t.promptForLink},{id:"font",label:e("contextmenu.font"),icon:"type",disabled:i||!o,testId:"editor-context-menu-font",onSelect:t.openFontDialog},{id:"paragraph",label:e("contextmenu.paragraph"),icon:"pilcrow",disabled:i,testId:"editor-context-menu-paragraph",onSelect:t.openParagraphDialog}],s=t.table;return(null==s?void 0:s.isInsideTable())&&l.push({id:"sep-table",type:"separator"},{id:"table-properties",label:e("contextmenu.tableProperties"),icon:"table-properties",disabled:i,testId:"editor-context-menu-table-properties",onSelect:s.openProperties},{id:"table-insert-row-above",label:e("table.insertRowAbove"),icon:"rows-3",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-insert-row-above",onSelect:s.insertRowBefore},{id:"table-insert-row-below",label:e("table.insertRowBelow"),icon:"rows-3",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-insert-row-below",onSelect:s.insertRowAfter},{id:"table-insert-column-left",label:e("table.insertColumnLeft"),icon:"columns-3",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-insert-column-left",onSelect:s.insertColumnBefore},{id:"table-insert-column-right",label:e("table.insertColumnRight"),icon:"columns-3",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-insert-column-right",onSelect:s.insertColumnAfter},{id:"table-delete-row",label:e("table.deleteRow"),icon:"trash-2",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-delete-row",onSelect:s.deleteRow},{id:"table-delete-column",label:e("table.deleteColumn"),icon:"trash-2",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-delete-column",onSelect:s.deleteColumn},{id:"table-merge",label:e("table.mergeTooltip"),icon:"combine",disabled:i||!s.canMerge(),testId:"editor-context-menu-table-merge",onSelect:s.merge},{id:"table-split",label:e("table.splitTooltip"),icon:"split",disabled:i||!s.canSplit(),testId:"editor-context-menu-table-split",onSelect:s.split},{id:"table-borders-shading",label:e("contextmenu.bordersAndShading"),icon:"frame",disabled:i,testId:"editor-context-menu-table-borders-shading",onSelect:s.openBordersAndShading}),l},closeContextMenu:()=>{t.setContextMenu({isOpen:!1,x:0,y:0})},handleEditorContextMenu:e=>{e.preventDefault(),t.setContextMenu({isOpen:!0,x:e.clientX,y:e.clientY})},programmaticCopy:a,programmaticCut:n,programmaticPaste:r}}({state:t.state,isReadOnly:t.isReadOnly,t:t.t,logger:t.logger,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.applyTableAwareParagraphEdit,focusInput:t.focusInput,promptForLink:t.promptForLink,openFontDialog:o,openParagraphDialog:l,table:tk({state:t.state,tableOps:t.tableOps,isInsideTable:s.isInsideTable,openTablePropertiesDialog:d,applyTableContextCommand:(e,a)=>{t.applyTransactionalState(e,{mergeKey:a}),t.focusInput()}})});return{computeFontFamilyOptions:e,computeFontSizeOptions:a,applyFontDialogValues:r.applyFontDialogValues,applyParagraphDialogValues:i.applyParagraphDialogValues,applyTablePropertiesDialogValues:s.applyTablePropertiesDialogValues,buildContextMenuItems:c.buildContextMenuItems,handleEditorContextMenu:c.handleEditorContextMenu,closeContextMenu:c.closeContextMenu}}function ak(t){const e=w(()=>{var e,a;const n=t.targetPos(),r=t.surfaceRef;if(!r)return null;const o=qs({surface:r,state:t.state});let i=0,l=0,s=28;if(o){const e=ha(t.state).find(t=>t.id===n.paragraphId),a=e?Ee(e,n):0,r=function(t,e,a){const n=Ps(t,e.paragraphId);if(0===n.length)return null;const r=function(t,e){if(0===t.length)return null;for(const a of t)if(e>=a.startOffset&&e<=a.endOffset)return a;return t[t.length-1]??null}(n,a);if(!r)return null;const o=function(t,e){if(0===t.lines.length)return null;for(const a of t.lines)if(e>=a.startOffset&&e<=a.endOffset)return a;return t.lines[t.lines.length-1]??null}(r,a);if(!o||0===o.slots.length)return Os(r.left,r.top,1,Math.max(r.height,16));const i=o.slots.find(t=>t.offset===a)??o.slots.reduce((t,e)=>Math.abs(e.offset-a)<Math.abs(t.offset-a)?e:t,o.slots[0]);return Os(i.left,i.top,1,i.height||o.height)}(o,n,a);if(r)return{viewportLeft:r.left,viewportTop:r.top,height:Math.min(r.height||28,32)};const i=function(t,e,a="start"){const n=Ps(t,e);if(0===n.length)return null;const r="end"===a?n[n.length-1]:n[0];return Os(r.left,r.top,r.width,r.height)}(o,n.paragraphId,"end");if(i)return{viewportLeft:i.left,viewportTop:i.top,height:i.height||28}}const d=(null==(e=t.caretViewport)?void 0:e.call(t))??null;if(d)return i=d.left,l=d.top,s=Math.max(12,Math.min(36,d.height)),{viewportLeft:i,viewportTop:l,height:s};const c=(null==(a=t.pointerPos)?void 0:a.call(t))??null;return c?(i=c.x,l=c.y-12,s=24,{viewportLeft:i,viewportTop:l,height:s}):{viewportLeft:i,viewportTop:l,height:s}});return D(at,{get when(){return e()},children:t=>D(cp,{active:!0,fixed:!0,get left(){return t().viewportLeft},get top(){return t().viewportTop},get height(){return t().height}})})}var nk=ut("<div class=oasis-editor-table-resize-guide>"),rk=ut("<img class=oasis-editor-image-ghost>"),ok=ut("<div class=oasis-editor-table-ghost>");function ik(t){return[D(at,{get when(){return t.tableResize.resizing()},children:t=>{return e=nk(),M(a=>{var n=!("column"!==t().type),r=!("row"!==t().type),o={..."column"===t().type?{left:`${t().currentPos}px`,top:`${t().guideBounds.top}px`,width:"0px",height:`${t().guideBounds.height}px`}:{left:`${t().guideBounds.left}px`,top:`${t().currentPos}px`,width:`${t().guideBounds.width}px`,height:"0px"}};return n!==a.e&&e.classList.toggle("oasis-editor-table-resize-guide-column",a.e=n),r!==a.t&&e.classList.toggle("oasis-editor-table-resize-guide-row",a.t=r),a.a=yt(e,o,a.a),a},{e:void 0,t:void 0,a:void 0}),e;var e}}),D(at,{get when(){return ct(()=>!!t.imageOps.dragging())()&&t.imageOps.draggedImageInfo()},children:e=>{return a=rk(),M(n=>{var r=e().src,o=`${e().width}px`,i=`${e().height}px`,l=t.imageOps.mousePos().x-e().offsetX+"px",s=t.imageOps.mousePos().y-e().offsetY+"px";return r!==n.e&>(a,"src",n.e=r),o!==n.t&&Mt(a,"width",n.t=o),i!==n.a&&Mt(a,"height",n.a=i),l!==n.o&&Mt(a,"left",n.o=l),s!==n.i&&Mt(a,"top",n.i=s),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),a;var a}}),D(at,{get when(){return ct(()=>!!t.tableDrag.dragging())()&&t.tableDrag.draggedTableInfo()},children:e=>{return a=ok(),M(n=>{var r=`${e().width}px`,o=`${e().height}px`,i=t.tableDrag.mousePos().x-e().offsetX+"px",l=t.tableDrag.mousePos().y-e().offsetY+"px";return r!==n.e&&Mt(a,"width",n.e=r),o!==n.t&&Mt(a,"height",n.t=o),i!==n.a&&Mt(a,"left",n.a=i),l!==n.o&&Mt(a,"top",n.o=l),n},{e:void 0,t:void 0,a:void 0,o:void 0}),a;var a}}),D(at,{get when(){return ct(()=>!!t.tableDrag.dragging())()&&t.tableDrag.dropTargetPos()},children:e=>D(ak,{get surfaceRef(){return t.surfaceRef},get state(){return t.state},targetPos:e})}),D(at,{get when(){return ct(()=>!!t.imageOps.dragging())()&&t.imageOps.dropTargetPos()},children:e=>D(ak,{get surfaceRef(){return t.surfaceRef},get state(){return t.state},targetPos:e})}),D(at,{get when(){return ct(()=>!!t.textDrag.dragging())()&&t.textDrag.dropTargetPos()},children:e=>D(ak,{get surfaceRef(){return t.surfaceRef},get state(){return t.state},targetPos:e,get pointerPos(){return t.textDrag.pointerPos},get caretViewport(){return t.textDrag.caretViewport}})})]}var lk=ut("<div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=text class=oasis-editor-dialog-input data-testid=editor-link-dialog-input>"),sk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-link-dialog-cancel>'),dk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-link-dialog-apply>');function ck(t){const e=Wt(),[a,n]=y(t.initialHref);let r;x(()=>{t.isOpen&&(n(t.initialHref),setTimeout(()=>null==r?void 0:r.focus(),50))});const o=()=>{t.onConfirm(a()),t.onClose()};return D(Ky,{get isOpen(){return t.isOpen},get title(){return e("dialog.link.title")},get onClose(){return t.onClose},get footer(){return[(n=sk(),vt(n,"click",t.onClose,!0),St(n,()=>e("generic.cancel")),n),(a=dk(),a.$$click=o,St(a,()=>e("generic.apply")),a)];var a,n},get children(){var t=lk(),i=t.firstChild,l=i.nextSibling;St(i,()=>e("dialog.link.label")),l.$$keydown=t=>"Enter"===t.key&&o(),l.$$input=t=>n(t.currentTarget.value);return"function"==typeof r?wt(r,l):r=l,M(()=>gt(l,"placeholder",e("dialog.link.placeholder"))),M(()=>l.value=a()),t}})}ft(["input","keydown","click"]);var hk=ut("<div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=text class=oasis-editor-dialog-input>"),pk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary">'),uk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary">');function fk(t){const e=Wt(),[a,n]=y(t.initialAlt);let r;x(()=>{t.isOpen&&(n(t.initialAlt),setTimeout(()=>null==r?void 0:r.focus(),50))});const o=()=>{t.onConfirm(a()),t.onClose()};return D(Ky,{get isOpen(){return t.isOpen},get title(){return e("dialog.imageAlt.title")},get onClose(){return t.onClose},get footer(){return[(n=pk(),vt(n,"click",t.onClose,!0),St(n,()=>e("generic.cancel")),n),(a=uk(),a.$$click=o,St(a,()=>e("generic.save")),a)];var a,n},get children(){var t=hk(),i=t.firstChild,l=i.nextSibling;St(i,()=>e("dialog.imageAlt.label")),l.$$keydown=t=>"Enter"===t.key&&o(),l.$$input=t=>n(t.currentTarget.value);return"function"==typeof r?wt(r,l):r=l,M(()=>gt(l,"placeholder",e("dialog.imageAlt.placeholder"))),M(()=>l.value=a()),t}})}ft(["input","keydown","click"]);var gk=ut("<div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=text class=oasis-editor-dialog-input>"),mk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary">'),vk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary">');function bk(t){const e=Wt(),[a,n]=y(t.initialCaption);let r;x(()=>{t.isOpen&&(n(t.initialCaption),setTimeout(()=>null==r?void 0:r.focus(),50))});const o=()=>{t.onConfirm(a()),t.onClose()};return D(Ky,{get isOpen(){return t.isOpen},get title(){return e("dialog.imageCaption.title")},get onClose(){return t.onClose},get footer(){return[(n=mk(),vt(n,"click",t.onClose,!0),St(n,()=>e("generic.cancel")),n),(a=vk(),a.$$click=o,St(a,()=>e("generic.save")),a)];var a,n},get children(){var t=gk(),i=t.firstChild,l=i.nextSibling;St(i,()=>e("dialog.imageCaption.label")),l.$$keydown=t=>"Enter"===t.key&&o(),l.$$input=t=>n(t.currentTarget.value);return"function"==typeof r?wt(r,l):r=l,M(()=>gt(l,"placeholder",e("dialog.imageCaption.placeholder"))),M(()=>l.value=a()),t}})}ft(["input","keydown","click"]);const yk="#111827",Mk=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],xk=[33,50,66,75,90,100,105,110,115,120,150,200];function wk(t){const e=Number(t.trim());return Number.isFinite(e)&&e>0?e:null}function Sk(t){const e=Number(t.trim());return Number.isFinite(e)&&e>=0?e:null}function Ak(t){return null==t||""===t?"":String(t)}function Ik(t){const e=Number(t);return Number.isFinite(e)&&0!==e?e>0?"expanded":"condensed":"normal"}function Tk(t){const e=Number(t);return Number.isFinite(e)&&0!==e?e>0?"raised":"lowered":"normal"}function Ck(t){if(!t.trim())return null;const e=Number(t);return Number.isInteger(e)&&e>=1&&e<=20?e:null}function kk(t){switch(t){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 Vk(t,e){const a=[];return"proportional"===t&&a.push("proportional-nums"),"tabular"===t&&a.push("tabular-nums"),"lining"===e&&a.push("lining-nums"),"oldStyle"===e&&a.push("oldstyle-nums"),a.join(" ")||void 0}function Ek(t,e){const a=[],n=Ck(t);return null!==n&&a.push(`"ss${String(n).padStart(2,"0")}" 1`),e&&a.push('"calt" 1'),a.join(", ")||void 0}function Rk(t){return{familyFilter:"",fontFamily:t.fontFamily??"",fontSize:t.fontSize??"",colorMode:t.colorMode,color:t.color||yk,highlight:t.highlight||"",shading:t.shading||"",bold:Boolean(t.bold),italic:Boolean(t.italic),underline:Boolean(t.underline),underlineStyle:t.underline?t.underlineStyle??"single":"none",underlineColor:t.underlineColor||yk,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)}}function Lk(t){return{characterScale:Ak(t.characterScale),spacingMode:Ik(t.characterSpacing),spacingAmount:t.characterSpacing?String(Math.abs(Number(t.characterSpacing))):"",positionMode:Tk(t.baselineShift),positionAmount:t.baselineShift?String(Math.abs(Number(t.baselineShift))):"",kerningEnabled:""!==t.kerningThreshold,kerningThreshold:Ak(t.kerningThreshold),ligatures:t.ligatures,numberSpacing:t.numberSpacing,numberForm:t.numberForm,stylisticSet:Ak(t.stylisticSet),contextualAlternates:Boolean(t.contextualAlternates)}}function zk(t){const e=Wt(),[a,n]=y("font"),[r,o]=y(Rk(t.initial)),[i,l]=y(Lk(t.initial));x(()=>{t.isOpen&&(n("font"),o(Rk(t.initial)),l(Lk(t.initial)))});const s=w(()=>{return t=r().bold,e=r().italic,t&&e?"boldItalic":t?"bold":e?"italic":"regular";var t,e}),d=w(()=>{const e=r().familyFilter.trim().toLowerCase();return e?t.familyOptions.filter(t=>t.toLowerCase().includes(e)):t.familyOptions}),c=w(()=>{const e=new Set(Mk);for(const n of t.sizeOptions)e.add(n);const a=Number(r().fontSize);return Number.isFinite(a)&&a>0&&e.add(a),Array.from(e).sort((t,e)=>t-e)}),h=w(()=>{const t=r().fontSize.trim();if(!t)return"";const a=Number(t);return Number.isFinite(a)&&a>0?"":e("dialog.font.sizeInvalid")}),p=w(()=>{const t=i();return t.characterScale.trim()&&null===wk(t.characterScale)?e("dialog.font.advancedScaleInvalid"):"normal"!==t.spacingMode&&null===Sk(t.spacingAmount)||"normal"!==t.positionMode&&null===Sk(t.positionAmount)?e("dialog.font.advancedAmountInvalid"):t.kerningThreshold.trim()&&null===Sk(t.kerningThreshold)?e("dialog.font.advancedKerningInvalid"):t.stylisticSet.trim()&&null===Ck(t.stylisticSet)?e("dialog.font.advancedStylisticSetInvalid"):""}),u=w(()=>function(t,e){const a=Number(t.fontSize),n=wk(e.characterScale)??100,r="normal"===e.spacingMode?null:Sk(e.spacingAmount),o="normal"===e.positionMode?null:Sk(e.positionAmount),i=null===r?void 0:"condensed"===e.spacingMode?`-${r}pt`:`${r}pt`,l=null===o?void 0:"lowered"===e.positionMode?`-${o}pt`:`${o}pt`,s=[];return t.underline&&"none"!==t.underlineStyle&&s.push("underline"),t.strike&&s.push("line-through"),t.doubleStrike&&s.push("line-through"),{"font-family":t.fontFamily||"inherit","font-size":Number.isFinite(a)&&a>0?`${a}pt`:void 0,"font-weight":t.bold?700:400,"font-style":t.italic?"italic":"normal","text-decoration":s.join(" ")||"none",color:"automatic"===t.colorMode?"inherit":t.color,"background-color":t.highlight||t.shading||void 0,"vertical-align":l??(t.superscript?"super":t.subscript?"sub":"baseline"),"font-stretch":`${n}%`,"letter-spacing":i,"font-variant-ligatures":kk(e.ligatures),"font-variant-numeric":Vk(e.numberSpacing,e.numberForm),"font-feature-settings":Ek(e.stylisticSet,e.contextualAlternates)}}(r(),i()));return{activeTab:a,setActiveTab:t=>n(t),fontTabValues:r,setFontTabValues:o,advancedTabValues:i,setAdvancedTabValues:l,updateFontTab:(t,e)=>{o(a=>({...a,[t]:e}))},updateAdvancedTab:(t,e)=>{l(a=>({...a,[t]:e}))},selectedFontStyle:s,visibleFamilyOptions:d,effectiveSizeOptions:c,customSizeError:h,advancedValidationError:p,previewStyle:u,applyFontStylePreset:t=>{o(e=>({...e,bold:"bold"===t||"boldItalic"===t,italic:"italic"===t||"boldItalic"===t}))},handleApply:()=>{if(p())return;const e=function(t,e){const a=Number(t.fontSize),n=Number.isFinite(a)&&a>0,r="none"===t.underlineStyle?null:t.underlineStyle,o=null!==r,i=e.characterScale.trim()?wk(e.characterScale):null,l="normal"===e.spacingMode?null:Sk(e.spacingAmount),s="normal"===e.positionMode?null:Sk(e.positionAmount),d=e.kerningEnabled&&e.kerningThreshold.trim()?Sk(e.kerningThreshold):null,c=Ck(e.stylisticSet);return{fontFamily:t.fontFamily.trim()?t.fontFamily.trim():null,fontSize:n?a:null,colorMode:t.colorMode,color:"automatic"===t.colorMode?null:t.color||null,highlight:t.highlight||null,shading:t.shading||null,bold:t.bold,italic:t.italic,underline:o,underlineStyle:r,underlineColor:o&&t.underlineColor||null,strike:t.strike,doubleStrike:t.doubleStrike,superscript:t.superscript,subscript:t.subscript,smallCaps:t.smallCaps,allCaps:t.allCaps,hidden:t.hidden,characterScale:i,characterSpacing:null===l?null:"condensed"===e.spacingMode?-l:l,baselineShift:null===s?null:"lowered"===e.positionMode?-s:s,kerningThreshold:d,ligatures:e.ligatures||null,numberSpacing:e.numberSpacing||null,numberForm:e.numberForm||null,stylisticSet:c,contextualAlternates:e.contextualAlternates}}(r(),i());t.onApply(e,t.initial),t.onClose()}}}var Nk=ut("<div>");function qk(t){const e=Wt();return St(a=Nk(),()=>e("dialog.font.previewText")),M(e=>{var n=t.class??"oasis-editor-dialog-preview",r=t.testId,o=t.style;return n!==e.e&&mt(a,e.e=n),r!==e.t&>(a,"data-testid",e.t=r),e.a=yt(a,o,e.a),e},{e:void 0,t:void 0,a:void 0}),a;var a}var Ok=ut('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel"><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input class=oasis-editor-dialog-input data-testid=editor-font-dialog-family-filter></div></div><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-family><option value>—</option></select></div><div class="oasis-editor-dialog-input-group oasis-editor-font-dialog-size-group"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-size><option value>—</option></select></div></div><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-font-dialog-custom-size-group"><label class=oasis-editor-dialog-label></label><input class=oasis-editor-dialog-input data-testid=editor-font-dialog-custom-size><span class=oasis-editor-dialog-help-text></span></div><div class="oasis-editor-dialog-input-group oasis-editor-font-dialog-style-list-group"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-style-list><option value=regular></option><option value=italic></option><option value=bold></option><option value=boldItalic></option></select></div></div><div class="oasis-editor-dialog-row oasis-editor-font-dialog-color-row"><div class="oasis-editor-dialog-input-group oasis-editor-font-dialog-color-mode-group"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-color-mode><option value=automatic></option><option value=custom></option></select><input type=color class=oasis-editor-dialog-color data-testid=editor-font-dialog-color></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-color data-testid=editor-font-dialog-highlight></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-color data-testid=editor-font-dialog-shading></div></div><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-underline-style><option value=none></option></select></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-color data-testid=editor-font-dialog-underline-color></div></div><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><div class=oasis-editor-dialog-style-row><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-bold><span style=font-weight:700></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-italic><span style=font-style:italic></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-underline><span style=text-decoration:underline></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-strike><span style=text-decoration:line-through></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-double-strike><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-superscript><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-subscript><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-small-caps><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-all-caps><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-hidden><span></span></label></div></div></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label>'),Pk=ut("<option>");function Wk(t){const e=Wt(),{ctrl:a}=t;return(()=>{var t=Ok(),n=t.firstChild,r=n.firstChild.firstChild,o=r.nextSibling,i=n.nextSibling,l=i.firstChild,s=l.firstChild,d=s.nextSibling;d.firstChild;var c=l.nextSibling.firstChild,h=c.nextSibling;h.firstChild;var p=i.nextSibling,u=p.firstChild,f=u.firstChild,g=f.nextSibling,m=g.nextSibling,v=u.nextSibling.firstChild,b=v.nextSibling,y=b.firstChild,x=y.nextSibling,w=x.nextSibling,S=w.nextSibling,A=p.nextSibling,I=A.firstChild,T=I.firstChild,C=T.nextSibling,k=C.firstChild,V=k.nextSibling,E=C.nextSibling,R=I.nextSibling,L=R.firstChild,z=L.nextSibling,N=R.nextSibling.firstChild,q=N.nextSibling,O=A.nextSibling,P=O.firstChild,W=P.firstChild,H=W.nextSibling,U=H.firstChild,F=P.nextSibling.firstChild,B=F.nextSibling,G=O.nextSibling,Z=G.firstChild.firstChild,K=Z.nextSibling.firstChild,j=K.firstChild,X=j.nextSibling,J=K.nextSibling,Y=J.firstChild,Q=Y.nextSibling,_=J.nextSibling,$=_.firstChild,et=$.nextSibling,at=_.nextSibling,nt=at.firstChild,rt=nt.nextSibling,ot=at.nextSibling,it=ot.firstChild,lt=it.nextSibling,st=ot.nextSibling,dt=st.firstChild,ct=dt.nextSibling,ht=st.nextSibling,pt=ht.firstChild,ut=pt.nextSibling,ft=ht.nextSibling,gt=ft.firstChild,mt=gt.nextSibling,vt=ft.nextSibling,bt=vt.firstChild,yt=bt.nextSibling,Mt=vt.nextSibling.firstChild,xt=Mt.nextSibling,wt=G.nextSibling,At=wt.firstChild;return St(r,()=>e("dialog.font.familyFilter")),o.$$input=t=>a.updateFontTab("familyFilter",t.currentTarget.value),St(s,()=>e("dialog.font.family")),d.addEventListener("change",t=>a.updateFontTab("fontFamily",t.currentTarget.value)),St(d,D(tt,{get each(){return a.visibleFamilyOptions()},children:t=>{return(e=Pk()).value=t,St(e,t),e;var e}}),null),St(c,()=>e("dialog.font.size")),h.addEventListener("change",t=>a.updateFontTab("fontSize",t.currentTarget.value)),St(h,D(tt,{get each(){return a.effectiveSizeOptions()},children:t=>{return St(e=Pk(),t),M(()=>e.value=String(t)),e;var e}}),null),St(f,()=>e("dialog.font.customSize")),g.$$input=t=>a.updateFontTab("fontSize",t.currentTarget.value),St(m,()=>a.customSizeError()),St(v,()=>e("dialog.font.styleList")),b.addEventListener("change",t=>a.applyFontStylePreset(t.currentTarget.value)),St(y,()=>e("dialog.font.styleRegular")),St(x,()=>e("dialog.font.styleItalic")),St(w,()=>e("dialog.font.styleBold")),St(S,()=>e("dialog.font.styleBoldItalic")),St(T,()=>e("dialog.font.color")),C.addEventListener("change",t=>a.updateFontTab("colorMode",t.currentTarget.value)),St(k,()=>e("toolbar.colorAutomatic")),St(V,()=>e("dialog.font.customColor")),E.$$input=t=>a.setFontTabValues(e=>({...e,color:t.currentTarget.value,colorMode:"custom"})),St(L,()=>e("dialog.font.highlight")),z.$$input=t=>a.updateFontTab("highlight",t.currentTarget.value),St(N,()=>e("dialog.font.shading")),q.$$input=t=>a.updateFontTab("shading",t.currentTarget.value),St(W,()=>e("dialog.font.underlineStyle")),H.addEventListener("change",t=>a.setFontTabValues(e=>({...e,underlineStyle:t.currentTarget.value,underline:"none"!==t.currentTarget.value}))),St(U,()=>e("toolbar.underlineRemove")),St(H,D(tt,{each:IM,children:t=>{return St(a=Pk(),()=>e(t.labelKey)),M(()=>a.value=t.value),a;var a}}),null),St(F,()=>e("dialog.font.underlineColor")),B.$$input=t=>a.setFontTabValues(e=>({...e,underlineColor:t.currentTarget.value,underline:"none"!==e.underlineStyle})),St(Z,()=>e("dialog.font.style")),j.addEventListener("change",t=>a.updateFontTab("bold",t.currentTarget.checked)),St(X,()=>e("dialog.font.bold")),Y.addEventListener("change",t=>a.updateFontTab("italic",t.currentTarget.checked)),St(Q,()=>e("dialog.font.italic")),$.addEventListener("change",t=>a.setFontTabValues(e=>({...e,underline:t.currentTarget.checked,underlineStyle:t.currentTarget.checked?"none"===e.underlineStyle?"single":e.underlineStyle:"none"}))),St(et,()=>e("dialog.font.underline")),nt.addEventListener("change",t=>a.setFontTabValues(e=>({...e,strike:t.currentTarget.checked,doubleStrike:!t.currentTarget.checked&&e.doubleStrike}))),St(rt,()=>e("dialog.font.strike")),it.addEventListener("change",t=>a.setFontTabValues(e=>({...e,doubleStrike:t.currentTarget.checked,strike:!t.currentTarget.checked&&e.strike}))),St(lt,()=>e("dialog.font.doubleStrike")),dt.addEventListener("change",t=>a.setFontTabValues(e=>({...e,superscript:t.currentTarget.checked,subscript:!t.currentTarget.checked&&e.subscript}))),St(ct,()=>e("toolbar.superscript")),pt.addEventListener("change",t=>a.setFontTabValues(e=>({...e,subscript:t.currentTarget.checked,superscript:!t.currentTarget.checked&&e.superscript}))),St(ut,()=>e("toolbar.subscript")),gt.addEventListener("change",t=>a.updateFontTab("smallCaps",t.currentTarget.checked)),St(mt,()=>e("dialog.font.smallCaps")),bt.addEventListener("change",t=>a.updateFontTab("allCaps",t.currentTarget.checked)),St(yt,()=>e("dialog.font.allCaps")),Mt.addEventListener("change",t=>a.updateFontTab("hidden",t.currentTarget.checked)),St(xt,()=>e("dialog.font.hidden")),St(At,()=>e("dialog.font.preview")),St(wt,D(qk,{testId:"editor-font-dialog-preview",get style(){return a.previewStyle()}}),null),M(t=>{var e="automatic"===a.fontTabValues().colorMode,n="none"===a.fontTabValues().underlineStyle;return e!==t.e&&(E.disabled=t.e=e),n!==t.t&&(B.disabled=t.t=n),t},{e:void 0,t:void 0}),M(()=>o.value=a.fontTabValues().familyFilter),M(()=>d.value=a.fontTabValues().fontFamily),M(()=>h.value=a.fontTabValues().fontSize),M(()=>g.value=a.fontTabValues().fontSize),M(()=>b.value=a.selectedFontStyle()),M(()=>C.value=a.fontTabValues().colorMode),M(()=>E.value=a.fontTabValues().color),M(()=>z.value=a.fontTabValues().highlight||"#fef08a"),M(()=>q.value=a.fontTabValues().shading||"#fef3c7"),M(()=>H.value=a.fontTabValues().underlineStyle),M(()=>B.value=a.fontTabValues().underlineColor||yk),M(()=>j.checked=a.fontTabValues().bold),M(()=>Y.checked=a.fontTabValues().italic),M(()=>$.checked=a.fontTabValues().underline),M(()=>nt.checked=a.fontTabValues().strike),M(()=>it.checked=a.fontTabValues().doubleStrike),M(()=>dt.checked=a.fontTabValues().superscript),M(()=>pt.checked=a.fontTabValues().subscript),M(()=>gt.checked=a.fontTabValues().smallCaps),M(()=>bt.checked=a.fontTabValues().allCaps),M(()=>Mt.checked=a.fontTabValues().hidden),t})()}ft(["input"]);var Hk=ut('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel"><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-scale></select></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-spacing-mode><option value=normal></option><option value=expanded></option><option value=condensed></option></select><label class="oasis-editor-dialog-label oasis-editor-font-dialog-by-label"></label><input class="oasis-editor-dialog-input oasis-editor-font-dialog-small-input"data-testid=editor-font-dialog-advanced-spacing-amount></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-position-mode><option value=normal></option><option value=raised></option><option value=lowered></option></select><label class="oasis-editor-dialog-label oasis-editor-font-dialog-by-label"></label><input class="oasis-editor-dialog-input oasis-editor-font-dialog-small-input"data-testid=editor-font-dialog-advanced-position-amount></div><div class="oasis-editor-font-dialog-word-row oasis-editor-font-dialog-kerning-row"><label class="oasis-editor-dialog-style-toggle oasis-editor-font-dialog-kerning-toggle"><input type=checkbox data-testid=editor-font-dialog-advanced-kerning-enabled><span></span></label><input class="oasis-editor-dialog-input oasis-editor-font-dialog-kerning-input"data-testid=editor-font-dialog-advanced-kerning><span class="oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix"></span></div></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-ligatures><option value></option><option value=none></option><option value=standard></option><option value=contextual></option><option value=historical></option><option value=standardContextual></option></select></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-number-spacing><option value></option><option value=proportional></option><option value=tabular></option></select></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-number-form><option value></option><option value=lining></option><option value=oldStyle></option></select></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-stylistic-set><option value></option></select></div><label class="oasis-editor-dialog-style-toggle oasis-editor-font-dialog-contextual-toggle"><input type=checkbox data-testid=editor-font-dialog-advanced-contextual-alternates><span></span></label></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend></fieldset><p class=oasis-editor-dialog-help-text data-testid=editor-font-dialog-advanced-placeholder>'),Uk=ut("<option>%"),Fk=ut("<option>");function Bk(t){const e=Wt(),{ctrl:a}=t;return n=Hk(),r=n.firstChild,o=r.firstChild,i=o.nextSibling,l=i.firstChild,s=l.nextSibling,d=i.nextSibling,c=d.firstChild,h=c.nextSibling,p=h.firstChild,u=p.nextSibling,f=u.nextSibling,g=h.nextSibling,m=g.nextSibling,v=d.nextSibling,b=v.firstChild,y=b.nextSibling,x=y.firstChild,w=x.nextSibling,S=w.nextSibling,A=y.nextSibling,I=A.nextSibling,T=v.nextSibling.firstChild,C=T.firstChild,k=C.nextSibling,V=T.nextSibling,E=V.nextSibling,R=r.nextSibling,L=R.firstChild,z=L.nextSibling,N=z.firstChild,q=N.nextSibling,O=q.firstChild,P=O.nextSibling,W=P.nextSibling,H=W.nextSibling,U=H.nextSibling,F=U.nextSibling,B=z.nextSibling,G=B.firstChild,Z=G.nextSibling,K=Z.firstChild,j=K.nextSibling,X=j.nextSibling,J=B.nextSibling,Y=J.firstChild,Q=Y.nextSibling,_=Q.firstChild,$=_.nextSibling,et=$.nextSibling,at=J.nextSibling,nt=at.firstChild,rt=nt.nextSibling,ot=rt.firstChild,it=at.nextSibling.firstChild,lt=it.nextSibling,st=R.nextSibling,dt=st.firstChild,ct=st.nextSibling,St(o,()=>e("dialog.font.advancedCharacterSpacingGroup")),St(l,()=>e("dialog.font.advancedScale")),s.addEventListener("change",t=>a.updateAdvancedTab("characterScale",t.currentTarget.value)),St(s,D(tt,{each:xk,children:t=>{return e=Uk(),a=e.firstChild,St(e,t,a),M(()=>e.value=String(t)),e;var e,a}})),St(c,()=>e("dialog.font.advancedSpacing")),h.addEventListener("change",t=>a.updateAdvancedTab("spacingMode",t.currentTarget.value)),St(p,()=>e("dialog.font.advancedNormal")),St(u,()=>e("dialog.font.advancedExpanded")),St(f,()=>e("dialog.font.advancedCondensed")),St(g,()=>e("dialog.font.advancedBy")),m.$$input=t=>a.updateAdvancedTab("spacingAmount",t.currentTarget.value),St(b,()=>e("dialog.font.advancedPosition")),y.addEventListener("change",t=>a.updateAdvancedTab("positionMode",t.currentTarget.value)),St(x,()=>e("dialog.font.advancedNormal")),St(w,()=>e("dialog.font.advancedRaised")),St(S,()=>e("dialog.font.advancedLowered")),St(A,()=>e("dialog.font.advancedBy")),I.$$input=t=>a.updateAdvancedTab("positionAmount",t.currentTarget.value),C.addEventListener("change",t=>a.setAdvancedTabValues(e=>({...e,kerningEnabled:t.currentTarget.checked,kerningThreshold:t.currentTarget.checked?e.kerningThreshold||"1":e.kerningThreshold}))),St(k,()=>e("dialog.font.advancedKerning")),V.$$input=t=>a.updateAdvancedTab("kerningThreshold",t.currentTarget.value),St(E,()=>e("dialog.font.advancedKerningAbove")),St(L,()=>e("dialog.font.advancedOpenTypeGroup")),St(N,()=>e("dialog.font.advancedLigatures")),q.addEventListener("change",t=>a.updateAdvancedTab("ligatures",t.currentTarget.value)),St(O,()=>e("dialog.font.advancedDefault")),St(P,()=>e("dialog.font.advancedLigaturesNone")),St(W,()=>e("dialog.font.advancedLigaturesStandard")),St(H,()=>e("dialog.font.advancedLigaturesContextual")),St(U,()=>e("dialog.font.advancedLigaturesHistorical")),St(F,()=>e("dialog.font.advancedLigaturesStandardContextual")),St(G,()=>e("dialog.font.advancedNumberSpacing")),Z.addEventListener("change",t=>a.updateAdvancedTab("numberSpacing",t.currentTarget.value)),St(K,()=>e("dialog.font.advancedDefault")),St(j,()=>e("dialog.font.advancedNumberSpacingProportional")),St(X,()=>e("dialog.font.advancedNumberSpacingTabular")),St(Y,()=>e("dialog.font.advancedNumberForm")),Q.addEventListener("change",t=>a.updateAdvancedTab("numberForm",t.currentTarget.value)),St(_,()=>e("dialog.font.advancedDefault")),St($,()=>e("dialog.font.advancedNumberFormLining")),St(et,()=>e("dialog.font.advancedNumberFormOldStyle")),St(nt,()=>e("dialog.font.advancedStylisticSet")),rt.addEventListener("change",t=>a.updateAdvancedTab("stylisticSet",t.currentTarget.value)),St(ot,()=>e("dialog.font.advancedDefault")),St(rt,D(tt,{get each(){return Array.from({length:20},(t,e)=>e+1)},children:t=>{return St(e=Fk(),t),M(()=>e.value=String(t)),e;var e}}),null),it.addEventListener("change",t=>a.updateAdvancedTab("contextualAlternates",t.currentTarget.checked)),St(lt,()=>e("dialog.font.advancedContextualAlternates")),St(dt,()=>e("dialog.font.advancedPreviewGroup")),St(st,D(qk,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return a.previewStyle()}}),null),St(ct,()=>a.advancedValidationError()||e("dialog.font.advancedPlaceholder")),M(t=>{var e="normal"===a.advancedTabValues().spacingMode,n="normal"===a.advancedTabValues().positionMode,r=!a.advancedTabValues().kerningEnabled;return e!==t.e&&(m.disabled=t.e=e),n!==t.t&&(I.disabled=t.t=n),r!==t.a&&(V.disabled=t.a=r),t},{e:void 0,t:void 0,a:void 0}),M(()=>s.value=a.advancedTabValues().characterScale||"100"),M(()=>h.value=a.advancedTabValues().spacingMode),M(()=>m.value=a.advancedTabValues().spacingAmount),M(()=>y.value=a.advancedTabValues().positionMode),M(()=>I.value=a.advancedTabValues().positionAmount),M(()=>C.checked=a.advancedTabValues().kerningEnabled),M(()=>V.value=a.advancedTabValues().kerningThreshold),M(()=>q.value=a.advancedTabValues().ligatures),M(()=>Z.value=a.advancedTabValues().numberSpacing),M(()=>Q.value=a.advancedTabValues().numberForm),M(()=>rt.value=a.advancedTabValues().stylisticSet),M(()=>it.checked=a.advancedTabValues().contextualAlternates),n;var n,r,o,i,l,s,d,c,h,p,u,f,g,m,v,b,y,x,w,S,A,I,T,C,k,V,E,R,L,z,N,q,O,P,W,H,U,F,B,G,Z,K,j,X,J,Y,Q,_,$,et,at,nt,rt,ot,it,lt,st,dt,ct}ft(["input"]);var Gk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-font-dialog-cancel>'),Zk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-font-dialog-apply>');function Dk(t){const e=Wt(),a=zk(t);return D(Ky,{get isOpen(){return t.isOpen},get title(){return e("dialog.font.title")},get onClose(){return t.onClose},class:"oasis-editor-font-dialog",bodyClass:"oasis-editor-font-dialog-body",size:"font",get footer(){return[(r=Gk(),vt(r,"click",t.onClose,!0),St(r,()=>e("generic.cancel")),r),(n=Zk(),vt(n,"click",a.handleApply,!0),St(n,()=>e("generic.ok")),n)];var n,r},get children(){return D(Qy,{class:"oasis-editor-font-dialog-tabs",get ariaLabel(){return e("dialog.font.title")},get value(){return a.activeTab()},onChange:t=>a.setActiveTab(t),get items(){return[{id:"font",label:e("dialog.font.tabFont"),testId:"editor-font-dialog-tab-font",panel:D(Wk,{ctrl:a})},{id:"advanced",label:e("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:D(Bk,{ctrl:a})}]}})}})}ft(["click"]);var Kk=ut('<div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-paragraph-dialog-align><option value=left></option><option value=center></option><option value=right></option><option value=justify>'),jk=ut('<div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input step=1 data-testid=editor-paragraph-dialog-indent-left></div><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input step=1 data-testid=editor-paragraph-dialog-indent-right>'),Xk=ut('<div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-paragraph-dialog-special><option value=none></option><option value=firstLine></option><option value=hanging></option></select></div><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input min=0 step=1 data-testid=editor-paragraph-dialog-special-by>'),Jk=ut('<div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input min=0 step=1 data-testid=editor-paragraph-dialog-spacing-before></div><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input min=0 step=1 data-testid=editor-paragraph-dialog-spacing-after></div><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input min=0.5 step=0.05 data-testid=editor-paragraph-dialog-line-height>'),Yk=ut('<div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-paragraph-dialog-border-style><option value=none></option><option value=solid></option><option value=dashed></option><option value=dotted></option></select></div><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input min=0 step=0.25 data-testid=editor-paragraph-dialog-border-width></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-input data-testid=editor-paragraph-dialog-border-color></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-input data-testid=editor-paragraph-dialog-shading>'),Qk=ut('<div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><div class=oasis-editor-dialog-style-row><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-paragraph-dialog-border-side-top></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-paragraph-dialog-border-side-right></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-paragraph-dialog-border-side-bottom></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-paragraph-dialog-border-side-left>'),_k=ut("<div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>"),$k=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-paragraph-dialog-cancel>'),tV=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-paragraph-dialog-apply>');const eV="#000000";function aV(t){if(""===t.trim())return null;const e=Number(t);return Number.isFinite(e)?e:null}function nV(t){const e=Wt(),[a,n]=y(""),[r,o]=y(""),[i,l]=y(""),[s,d]=y("none"),[c,h]=y(""),[p,u]=y(""),[f,g]=y(""),[m,v]=y(""),[b,S]=y(""),[A,I]=y("none"),[T,C]=y(""),[k,V]=y(""),[E,R]=y(!1),[L,z]=y(!1),[N,q]=y(!1),[O,P]=y(!1);x(()=>{if(t.isOpen){n(t.initial.align??""),o(t.initial.indentLeft??""),l(t.initial.indentRight??""),u(t.initial.spacingBefore??""),g(t.initial.spacingAfter??""),v(t.initial.lineHeight??""),S(t.initial.shading??"");const e=t.initial.borderStyle;I("solid"===e||"dashed"===e||"dotted"===e?e:"none"),C(t.initial.borderWidth??""),V(t.initial.borderColor??""),R(t.initial.borderSideTop??!1),z(t.initial.borderSideRight??!1),q(t.initial.borderSideBottom??!1),P(t.initial.borderSideLeft??!1);const a=aV(t.initial.indentFirstLine??""),r=aV(t.initial.indentHanging??"");null!==r&&r>0?(d("hanging"),h(t.initial.indentHanging??"")):null!==a&&a>0?(d("firstLine"),h(t.initial.indentFirstLine??"")):(d("none"),h(""))}});const W=w(()=>{const t=aV(m()),e=aV(r()),n=aV(i()),o="firstLine"===s()?aV(c()):null,l="hanging"===s()?aV(c()):null,d=null!==o?o:null!==l?-l:null,h="none"!==A()?`${aV(T())??.5}pt ${A()} ${k().trim()||eV}`:void 0;return{"text-align":a()||void 0,"line-height":null!==t&&t>0?String(t):void 0,"padding-left":null!==e?`${e+(l??0)}pt`:void 0,"padding-right":null!==n?`${n}pt`:void 0,"text-indent":null!==d?`${d}pt`:void 0,"background-color":b().trim()||void 0,"border-top":h&&E()?h:void 0,"border-right":h&&L()?h:void 0,"border-bottom":h&&N()?h:void 0,"border-left":h&&O()?h:void 0}}),H=()=>{const t=A();if("none"===t)return{top:null,right:null,bottom:null,left:null};const e=aV(T()),a={type:t,width:null!==e&&e>0?e:.5,color:k().trim()||eV};return{top:E()?a:null,right:L()?a:null,bottom:N()?a:null,left:O()?a:null}},U=()=>{const e=aV(c());t.onApply({align:a()||null,indentLeft:aV(r()),indentRight:aV(i()),indentFirstLine:"firstLine"===s()?e:null,indentHanging:"hanging"===s()?e:null,spacingBefore:aV(p()),spacingAfter:aV(f()),lineHeight:aV(m()),shading:b().trim()||null,borders:H()},t.initial),t.onClose()};return D(Ky,{get isOpen(){return t.isOpen},get title(){return e("paragraph.title")},get onClose(){return t.onClose},get footer(){return[(n=$k(),vt(n,"click",t.onClose,!0),St(n,()=>e("generic.cancel")),n),(a=tV(),a.$$click=U,St(a,()=>e("generic.apply")),a)];var a,n},get children(){return[(Ot=Kk(),Pt=Ot.firstChild.firstChild,Wt=Pt.nextSibling,Ht=Wt.firstChild,Ut=Ht.nextSibling,Ft=Ut.nextSibling,Bt=Ft.nextSibling,St(Pt,()=>e("paragraph.alignLabel")),Wt.addEventListener("change",t=>n(t.currentTarget.value)),St(Ht,()=>e("paragraph.alignLeft")),St(Ut,()=>e("paragraph.alignCenter")),St(Ft,()=>e("paragraph.alignRight")),St(Bt,()=>e("paragraph.alignJustify")),M(()=>Wt.value=a()),Ot),(Et=jk(),Rt=Et.firstChild,Lt=Rt.firstChild,zt=Lt.nextSibling,Nt=Rt.nextSibling.firstChild,qt=Nt.nextSibling,St(Lt,()=>e("paragraph.indentLeftLabel")),zt.$$input=t=>o(t.currentTarget.value),St(Nt,()=>e("paragraph.indentRightLabel")),qt.$$input=t=>l(t.currentTarget.value),M(()=>zt.value=r()),M(()=>qt.value=i()),Et),(Mt=Xk(),xt=Mt.firstChild,wt=xt.firstChild,At=wt.nextSibling,It=At.firstChild,Tt=It.nextSibling,Ct=Tt.nextSibling,kt=xt.nextSibling.firstChild,Vt=kt.nextSibling,St(wt,()=>e("paragraph.specialLabel")),At.addEventListener("change",t=>{const e=t.currentTarget.value;d(e),"none"===e&&h("")}),St(It,()=>e("paragraph.specialNone")),St(Tt,()=>e("paragraph.specialFirstLine")),St(Ct,()=>e("paragraph.specialHanging")),St(kt,()=>e("paragraph.specialByLabel")),Vt.$$input=t=>h(t.currentTarget.value),M(()=>Vt.disabled="none"===s()),M(()=>At.value=s()),M(()=>Vt.value=c()),Mt),(ct=Jk(),ht=ct.firstChild,pt=ht.firstChild,ut=pt.nextSibling,ft=ht.nextSibling,gt=ft.firstChild,mt=gt.nextSibling,vt=ft.nextSibling.firstChild,bt=vt.nextSibling,St(pt,()=>e("paragraph.spacingBeforeLabel")),ut.$$input=t=>u(t.currentTarget.value),St(gt,()=>e("paragraph.spacingAfterLabel")),mt.$$input=t=>g(t.currentTarget.value),St(vt,()=>e("paragraph.lineSpacingLabel")),bt.$$input=t=>v(t.currentTarget.value),M(()=>ut.value=p()),M(()=>mt.value=f()),M(()=>bt.value=m()),ct),(X=Yk(),J=X.firstChild,Y=J.firstChild,Q=Y.nextSibling,_=Q.firstChild,$=_.nextSibling,tt=$.nextSibling,et=tt.nextSibling,at=J.nextSibling,nt=at.firstChild,rt=nt.nextSibling,ot=at.nextSibling,it=ot.firstChild,lt=it.nextSibling,st=ot.nextSibling.firstChild,dt=st.nextSibling,St(Y,()=>e("paragraph.borderStyleLabel")),Q.addEventListener("change",t=>{const e=t.currentTarget.value;I(e),"none"===e?(R(!1),z(!1),q(!1),P(!1)):E()||L()||N()||O()||(R(!0),z(!0),q(!0),P(!0))}),St(_,()=>e("paragraph.borderNone")),St($,()=>e("paragraph.borderSolid")),St(tt,()=>e("paragraph.borderDashed")),St(et,()=>e("paragraph.borderDotted")),St(nt,()=>e("paragraph.borderWidthLabel")),rt.$$input=t=>C(t.currentTarget.value),St(it,()=>e("paragraph.borderColorLabel")),lt.$$input=t=>V(t.currentTarget.value),St(st,()=>e("paragraph.shadingLabel")),dt.$$input=t=>S(t.currentTarget.value),M(t=>{var e="none"===A(),a="none"===A();return e!==t.e&&(rt.disabled=t.e=e),a!==t.t&&(lt.disabled=t.t=a),t},{e:void 0,t:void 0}),M(()=>Q.value=A()),M(()=>rt.value=T()),M(()=>lt.value=k()||eV),M(()=>dt.value=b()||"#ffffff"),X),(w=Qk(),H=w.firstChild.firstChild,U=H.nextSibling.firstChild,F=U.firstChild,B=U.nextSibling,G=B.firstChild,Z=B.nextSibling,D=Z.firstChild,K=Z.nextSibling,j=K.firstChild,St(H,()=>e("paragraph.borderSidesLabel")),F.addEventListener("change",t=>R(t.currentTarget.checked)),St(U,()=>e("paragraph.borderSideTop"),null),G.addEventListener("change",t=>z(t.currentTarget.checked)),St(B,()=>e("paragraph.borderSideRight"),null),D.addEventListener("change",t=>q(t.currentTarget.checked)),St(Z,()=>e("paragraph.borderSideBottom"),null),j.addEventListener("change",t=>P(t.currentTarget.checked)),St(K,()=>e("paragraph.borderSideLeft"),null),M(t=>{var e="none"===A(),a="none"===A(),n="none"===A(),r="none"===A();return e!==t.e&&(F.disabled=t.e=e),a!==t.t&&(G.disabled=t.t=a),n!==t.a&&(D.disabled=t.a=n),r!==t.o&&(j.disabled=t.o=r),t},{e:void 0,t:void 0,a:void 0,o:void 0}),M(()=>F.checked=E()),M(()=>G.checked=L()),M(()=>D.checked=N()),M(()=>j.checked=O()),w),(t=_k(),y=t.firstChild,x=y.nextSibling,St(y,()=>e("paragraph.preview")),St(x,()=>e("paragraph.previewText")),M(t=>yt(x,W(),t)),t)];var t,y,x,w,H,U,F,B,G,Z,D,K,j,X,J,Y,Q,_,$,tt,et,at,nt,rt,ot,it,lt,st,dt,ct,ht,pt,ut,ft,gt,mt,vt,bt,Mt,xt,wt,At,It,Tt,Ct,kt,Vt,Et,Rt,Lt,zt,Nt,qt,Ot,Pt,Wt,Ht,Ut,Ft,Bt}})}ft(["input","click"]);var rV=ut('<div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input min=0 step=1>'),oV=ut("<label class=oasis-editor-dialog-style-toggle><input type=checkbox>"),iV=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-table-properties-cancel>'),lV=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-table-properties-apply>'),sV=ut('<div class=oasis-editor-table-properties-panel><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-dialog-row><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-table-properties-table-width-unit><option value=points></option><option value=percent></option></select></div></div></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-dialog-style-row></div><div class=oasis-editor-dialog-row></div></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-dialog-style-row><button type=button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"disabled data-testid=editor-table-properties-positioning></button></div><div class=oasis-editor-dialog-help-text>'),dV=ut("<label class=oasis-editor-dialog-style-toggle><input type=radio name=table-align>"),cV=ut('<div class=oasis-editor-table-properties-panel><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-table-properties-row-height-rule><option value></option><option value=atLeast></option><option value=exact></option></select></div></div><div class=oasis-editor-dialog-style-row>'),hV=ut("<div class=oasis-editor-table-properties-panel><div class=oasis-editor-dialog-row>"),pV=ut('<div class=oasis-editor-table-properties-panel><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-table-properties-cell-valign><option value></option><option value=top></option><option value=middle></option><option value=bottom></option></select></div><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-table-properties-cell-direction><option value></option><option value=lrTb>lrTb</option><option value=tbRl>tbRl</option><option value=btLr>btLr</option><option value=lrTbV>lrTbV</option><option value=tbRlV>tbRlV</option></select></div></div><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-dialog-style-row></div></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-dialog-row></div></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-table-properties-border-style><option value=none></option><option value=solid></option><option value=dashed></option><option value=dotted></option></select></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-input data-testid=editor-table-properties-border-color></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-input data-testid=editor-table-properties-shading></div></div><div class=oasis-editor-dialog-style-row></div><div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>'),uV=ut('<div class=oasis-editor-table-properties-panel><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input class=oasis-editor-dialog-input data-testid=editor-table-properties-alt-title></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><textarea class="oasis-editor-dialog-input oasis-editor-table-properties-textarea"data-testid=editor-table-properties-alt-description>');const fV="#000000";function gV(t){if(""===t.trim())return null;const e=Number(t);return Number.isFinite(e)?e:null}function mV(t,e){const a=gV(t);return null===a?null:"percent"===e?`${a}%`:a}function vV(t,e,a){if("none"===t)return null;const n=gV(e);return{type:t,width:null!==n&&n>0?n:.5,color:a.trim()||fV}}function bV(t){const e=Wt(),[a,n]=y("table"),[r,o]=y(""),[i,l]=y("points"),[s,d]=y(""),[c,h]=y(""),[p,u]=y("none"),[f,g]=y(""),[m,v]=y(""),[b,S]=y(!1),[A,I]=y(!0),[T,C]=y(!1),[k,V]=y(""),[E,R]=y(""),[L,z]=y(""),[N,q]=y(""),[O,P]=y(!1),[W,H]=y(!1),[U,F]=y(!1),[B,G]=y(""),[Z,K]=y(""),[j,X]=y(""),[J,Y]=y(""),[Q,_]=y("none"),[$,tt]=y(""),[et,at]=y(""),[nt,rt]=y(!1),[ot,it]=y(!1),[lt,st]=y(!1),[dt,ct]=y(!1),[ht,pt]=y(""),[ut,ft]=y(""),[mt,bt]=y("");x(()=>{t.isOpen&&(n(t.initial.activeTab??"table"),o(t.initial.tableWidth),l(t.initial.tableWidthUnit),d(t.initial.tableAlign),h(t.initial.tableIndentLeft),u(t.initial.tableWrapping),g(t.initial.rowHeight),v(t.initial.rowHeightRule),S(t.initial.repeatHeader),I(t.initial.allowBreakAcrossPages),C(t.initial.hiddenRow),V(t.initial.columnWidth),R(t.initial.cellWidth),z(t.initial.cellVerticalAlign),q(t.initial.cellTextDirection),P(t.initial.cellNoWrap),H(t.initial.cellFitText),F(t.initial.cellHideMark),G(t.initial.marginTop),K(t.initial.marginRight),X(t.initial.marginBottom),Y(t.initial.marginLeft),_(t.initial.borderStyle),tt(t.initial.borderWidth),at(t.initial.borderColor),rt(t.initial.borderTop),it(t.initial.borderRight),st(t.initial.borderBottom),ct(t.initial.borderLeft),pt(t.initial.shading),ft(t.initial.altTitle),bt(t.initial.altDescription))});const Mt=w(()=>{const t=vV(Q(),$(),et()),e=t?`${t.width}pt ${t.type} ${t.color}`:void 0;return{"background-color":ht().trim()||void 0,"border-top":e&&nt()?e:"1px solid #dadce0","border-right":e&&ot()?e:"1px solid #dadce0","border-bottom":e&<()?e:"1px solid #dadce0","border-left":e&&dt()?e:"1px solid #dadce0"}}),xt=()=>{const e=vV(Q(),$(),et());t.onApply({tableWidth:mV(r(),i()),tableAlign:s()||null,tableIndentLeft:mV(c(),"points"),rowHeight:mV(f(),"points"),rowHeightRule:m()||null,repeatHeader:b(),cantSplit:!A(),hiddenRow:T(),columnWidth:mV(k(),"points"),cellWidth:mV(E(),"points"),cellVerticalAlign:L()||null,cellTextDirection:N()||null,cellNoWrap:O(),cellFitText:W(),cellHideMark:U(),margins:{top:gV(B()),right:gV(Z()),bottom:gV(j()),left:gV(J())},borders:{top:nt()?e:null,right:ot()?e:null,bottom:lt()?e:null,left:dt()?e:null},shading:ht().trim()||null,altTitle:ut().trim()||null,altDescription:mt().trim()||null},t.initial),t.onClose()},wt=(t,e,a,n,r=!1)=>{return o=rV(),i=o.firstChild,l=i.nextSibling,St(i,t),l.$$input=t=>a(t.currentTarget.value),l.disabled=r,gt(l,"data-testid",n),M(()=>l.value=e()),o;var o,i,l},At=(t,e,a,n,r=!1)=>{return o=oV(),(i=o.firstChild).addEventListener("change",t=>a(t.currentTarget.checked)),i.disabled=r,gt(i,"data-testid",n),St(o,t,null),M(()=>i.checked=e()),o;var o,i};return D(Ky,{get isOpen(){return t.isOpen},get title(){return e("table.propertiesTitle")},get onClose(){return t.onClose},size:"lg",class:"oasis-editor-table-properties-dialog",bodyClass:"oasis-editor-table-properties-body",get footer(){return[(n=iV(),vt(n,"click",t.onClose,!0),St(n,()=>e("generic.cancel")),n),(a=lV(),a.$$click=xt,St(a,()=>e("generic.ok")),a)];var a,n},get children(){return D(Qy,{get value(){return a()},onChange:n,get ariaLabel(){return e("table.propertiesTitle")},class:"oasis-editor-table-properties-tabs",get items(){return[{id:"table",label:e("table.tabTable"),testId:"editor-table-properties-tab-table",panel:(ue=sV(),fe=ue.firstChild,ge=fe.firstChild,me=ge.nextSibling,ve=me.firstChild,be=ve.firstChild,ye=be.nextSibling,Me=ye.firstChild,xe=Me.nextSibling,we=fe.nextSibling,Se=we.firstChild,Ae=Se.nextSibling,Ie=Ae.nextSibling,Te=we.nextSibling.firstChild,Ce=Te.nextSibling,ke=Ce.firstChild,Ve=Ce.nextSibling,St(ge,()=>e("table.sizeSection")),St(me,()=>wt(e("table.preferredWidth"),r,o,"editor-table-properties-table-width"),ve),St(be,()=>e("table.measureIn")),ye.addEventListener("change",t=>l(t.currentTarget.value)),St(Me,()=>e("table.points")),St(xe,()=>e("table.percent")),St(Se,()=>e("table.alignmentSection")),St(Ae,()=>["left","center","right"].map(t=>{return a=dV(),(n=a.firstChild).addEventListener("change",()=>d(t)),gt(n,"data-testid",`editor-table-properties-align-${t}`),St(a,()=>e(`table.align${t[0].toUpperCase()}${t.slice(1)}`),null),M(()=>n.checked=s()===t),a;var a,n})),St(Ie,()=>wt(e("table.indentFromLeft"),c,h,"editor-table-properties-indent-left")),St(Te,()=>e("table.textWrappingSection")),St(Ce,()=>At(e("table.wrapNone"),()=>"none"===p(),()=>u("none"),"editor-table-properties-wrap-none"),ke),St(Ce,()=>At(e("table.wrapAround"),()=>"around"===p(),()=>u("around"),"editor-table-properties-wrap-around",!t.initial.floatingSummary),ke),St(ke,()=>e("table.positioning")),St(Ve,()=>t.initial.floatingSummary||e("table.positioningReadOnly")),M(()=>ye.value=i()),ue)},{id:"row",label:e("table.tabRow"),testId:"editor-table-properties-tab-row",panel:(re=cV(),oe=re.firstChild,ie=oe.firstChild,le=ie.firstChild,se=le.nextSibling,de=se.firstChild,ce=de.nextSibling,he=ce.nextSibling,pe=oe.nextSibling,St(oe,()=>wt(e("table.rowHeight"),f,g,"editor-table-properties-row-height"),ie),St(le,()=>e("table.rowHeightRule")),se.addEventListener("change",t=>v(t.currentTarget.value)),St(de,()=>e("table.rowAuto")),St(ce,()=>e("table.rowAtLeast")),St(he,()=>e("table.rowExactly")),St(pe,()=>At(e("table.repeatHeader"),b,S,"editor-table-properties-repeat-header"),null),St(pe,()=>At(e("table.allowBreakAcrossPages"),A,I,"editor-table-properties-allow-break"),null),St(pe,()=>At(e("table.hiddenRow"),T,C,"editor-table-properties-hidden-row"),null),M(()=>se.value=m()),re)},{id:"column",label:e("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:(ne=hV(),St(ne.firstChild,()=>wt(e("table.columnWidth"),k,V,"editor-table-properties-column-width")),ne)},{id:"cell",label:e("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:(vt=pV(),xt=vt.firstChild,It=xt.firstChild,Tt=It.firstChild,Ct=Tt.nextSibling,kt=Ct.firstChild,Vt=kt.nextSibling,Et=Vt.nextSibling,Rt=Et.nextSibling,Lt=It.nextSibling.firstChild,zt=Lt.nextSibling,Nt=zt.firstChild,qt=xt.nextSibling,Ot=qt.firstChild,Pt=Ot.nextSibling,Wt=qt.nextSibling,Ht=Wt.firstChild,Ut=Ht.nextSibling,Ft=Wt.nextSibling.firstChild,Bt=Ft.nextSibling,Gt=Bt.firstChild,Zt=Gt.firstChild,Dt=Zt.nextSibling,Kt=Dt.firstChild,jt=Kt.nextSibling,Xt=jt.nextSibling,Jt=Xt.nextSibling,Yt=Gt.nextSibling,Qt=Yt.firstChild,_t=Qt.nextSibling,$t=Yt.nextSibling.firstChild,te=$t.nextSibling,ee=Bt.nextSibling,ae=ee.nextSibling,St(xt,()=>wt(e("table.cellWidth"),E,R,"editor-table-properties-cell-width"),It),St(Tt,()=>e("table.verticalAlignment")),Ct.addEventListener("change",t=>z(t.currentTarget.value)),St(kt,()=>e("table.inherit")),St(Vt,()=>e("table.valignTop")),St(Et,()=>e("table.valignMiddle")),St(Rt,()=>e("table.valignBottom")),St(Lt,()=>e("table.textDirection")),zt.addEventListener("change",t=>q(t.currentTarget.value)),St(Nt,()=>e("table.inherit")),St(Ot,()=>e("table.options")),St(Pt,()=>At(e("table.noWrap"),O,P,"editor-table-properties-cell-nowrap"),null),St(Pt,()=>At(e("table.fitText"),W,H,"editor-table-properties-cell-fit-text"),null),St(Pt,()=>At(e("table.hideMark"),U,F,"editor-table-properties-cell-hide-mark"),null),St(Ht,()=>e("table.cellMargins")),St(Ut,()=>wt(e("paragraph.borderSideTop"),B,G,"editor-table-properties-margin-top"),null),St(Ut,()=>wt(e("paragraph.borderSideRight"),Z,K,"editor-table-properties-margin-right"),null),St(Ut,()=>wt(e("paragraph.borderSideBottom"),j,X,"editor-table-properties-margin-bottom"),null),St(Ut,()=>wt(e("paragraph.borderSideLeft"),J,Y,"editor-table-properties-margin-left"),null),St(Ft,()=>e("paragraph.bordersSection")),St(Zt,()=>e("paragraph.borderStyleLabel")),Dt.addEventListener("change",t=>{const e=t.currentTarget.value;_(e),"none"===e?(rt(!1),it(!1),st(!1),ct(!1)):nt()||ot()||lt()||dt()||(rt(!0),it(!0),st(!0),ct(!0))}),St(Kt,()=>e("paragraph.borderNone")),St(jt,()=>e("paragraph.borderSolid")),St(Xt,()=>e("paragraph.borderDashed")),St(Jt,()=>e("paragraph.borderDotted")),St(Bt,()=>wt(e("paragraph.borderWidthLabel"),$,tt,"editor-table-properties-border-width","none"===Q()),Yt),St(Qt,()=>e("paragraph.borderColorLabel")),_t.$$input=t=>at(t.currentTarget.value),St($t,()=>e("paragraph.shadingLabel")),te.$$input=t=>pt(t.currentTarget.value),St(ee,()=>At(e("paragraph.borderSideTop"),nt,rt,"editor-table-properties-border-top","none"===Q()),null),St(ee,()=>At(e("paragraph.borderSideRight"),ot,it,"editor-table-properties-border-right","none"===Q()),null),St(ee,()=>At(e("paragraph.borderSideBottom"),lt,st,"editor-table-properties-border-bottom","none"===Q()),null),St(ee,()=>At(e("paragraph.borderSideLeft"),dt,ct,"editor-table-properties-border-left","none"===Q()),null),M(t=>{var e="none"===Q(),a=Mt();return e!==t.e&&(_t.disabled=t.e=e),t.t=yt(ae,a,t.t),t},{e:void 0,t:void 0}),M(()=>Ct.value=L()),M(()=>zt.value=N()),M(()=>Dt.value=Q()),M(()=>_t.value=et()||fV),M(()=>te.value=ht()||"#ffffff"),vt)},{id:"altText",label:e("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:(a=uV(),n=a.firstChild,y=n.firstChild,x=y.nextSibling,w=n.nextSibling.firstChild,D=w.nextSibling,St(y,()=>e("table.altTitle")),x.$$input=t=>ft(t.currentTarget.value),St(w,()=>e("table.altDescription")),D.$$input=t=>bt(t.currentTarget.value),M(()=>x.value=ut()),M(()=>D.value=mt()),a)}];var a,n,y,x,w,D,vt,xt,It,Tt,Ct,kt,Vt,Et,Rt,Lt,zt,Nt,qt,Ot,Pt,Wt,Ht,Ut,Ft,Bt,Gt,Zt,Dt,Kt,jt,Xt,Jt,Yt,Qt,_t,$t,te,ee,ae,ne,re,oe,ie,le,se,de,ce,he,pe,ue,fe,ge,me,ve,be,ye,Me,xe,we,Se,Ae,Ie,Te,Ce,ke,Ve}})}})}ft(["input","click"]);var yV=ut("<div class=oasis-editor-find-replace-dialog><div class=oasis-editor-fr-header><span></span><button class=oasis-editor-fr-close><i data-lucide=x></i></button></div><div class=oasis-editor-fr-body><div class=oasis-editor-fr-input-group><div class=oasis-editor-fr-input-wrapper><input type=text autofocus class=oasis-editor-fr-input><span class=oasis-editor-fr-counter></span></div><div class=oasis-editor-fr-actions><button><i data-lucide=chevron-up></i></button><button><i data-lucide=chevron-down></i></button></div></div><div class=oasis-editor-fr-input-group><input type=text class=oasis-editor-fr-input><div class=oasis-editor-fr-actions><button class=oasis-editor-fr-btn-text></button><button class=oasis-editor-fr-btn-text></button></div></div><div class=oasis-editor-fr-options><label class=oasis-editor-fr-checkbox><input type=checkbox><span></span></label><label class=oasis-editor-fr-checkbox><input type=checkbox><span>");function MV(t){const e=Wt(),{fr:a}=t,n=t=>{"Enter"===t.key?(t.preventDefault(),t.shiftKey?a.findPrevious():a.findNext()):"Escape"===t.key&&a.setIsOpen(!1)};return D(at,{get when(){return a.isOpen()},get children(){var t,r=yV(),o=r.firstChild,i=o.firstChild,l=i.nextSibling,s=o.nextSibling.firstChild,d=s.firstChild,c=d.firstChild,h=c.nextSibling,p=d.nextSibling.firstChild,u=p.nextSibling,f=s.nextSibling,g=f.firstChild,m=g.nextSibling.firstChild,v=m.nextSibling,b=f.nextSibling.firstChild,y=b.firstChild,x=y.nextSibling,w=b.nextSibling.firstChild,S=w.nextSibling;return r.$$keydown=n,St(i,()=>e("find.title")),l.$$click=()=>a.setIsOpen(!1),c.$$input=t=>a.setSearchTerm(t.currentTarget.value),St(h,(t=ct(()=>a.matches().length>0),()=>t()?`${a.currentIndex()+1} / ${a.matches().length}`:e("find.noMatches"))),vt(p,"click",a.findPrevious,!0),vt(u,"click",a.findNext,!0),g.$$input=t=>a.setReplaceTerm(t.currentTarget.value),vt(m,"click",a.replace,!0),St(m,()=>e("replace.one")),vt(v,"click",a.replaceAll,!0),St(v,()=>e("replace.allBtn")),y.addEventListener("change",t=>a.setFindOptions({...a.findOptions(),matchCase:t.currentTarget.checked})),St(x,()=>e("find.matchCase")),w.addEventListener("change",t=>a.setFindOptions({...a.findOptions(),wholeWord:t.currentTarget.checked})),St(S,()=>e("find.wholeWord")),M(t=>{var n=e("generic.close"),r=e("find.placeholder"),o=0===a.matches().length,i=e("find.prevTooltip"),s=0===a.matches().length,d=e("find.nextTooltip"),h=e("replace.placeholder"),f=0===a.matches().length,b=0===a.matches().length;return n!==t.e&>(l,"aria-label",t.e=n),r!==t.t&>(c,"placeholder",t.t=r),o!==t.a&&(p.disabled=t.a=o),i!==t.o&>(p,"title",t.o=i),s!==t.i&&(u.disabled=t.i=s),d!==t.n&>(u,"title",t.n=d),h!==t.s&>(g,"placeholder",t.s=h),f!==t.h&&(m.disabled=t.h=f),b!==t.r&&(v.disabled=t.r=b),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),M(()=>c.value=a.searchTerm()),M(()=>g.value=a.replaceTerm()),M(()=>y.checked=a.findOptions().matchCase),M(()=>w.checked=a.findOptions().wholeWord),r}})}ft(["keydown","click","input"]);var xV=ut("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),wV=ut("<i>"),SV=ut("<span class=oasis-editor-context-menu-shortcut>"),AV=ut("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),IV=ut("<div class=oasis-editor-context-menu-separator>"),TV=ut("<i data-lucide=check style=visibility:hidden>");function CV(t){let e;const a=e=>{t.isOpen&&"Escape"===e.key&&(e.preventDefault(),t.onClose())},n=a=>{t.isOpen&&(e&&a.target instanceof Node&&e.contains(a.target)||t.onClose())},r=a=>{t.isOpen&&(e&&a.target instanceof Node&&e.contains(a.target)||t.onClose())},o=()=>{t.isOpen&&t.onClose()};return I(()=>{window.addEventListener("keydown",a,!0),window.addEventListener("mousedown",n,!0),window.addEventListener("contextmenu",r,!0),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o,!0)}),T(()=>{window.removeEventListener("keydown",a,!0),window.removeEventListener("mousedown",n,!0),window.removeEventListener("contextmenu",r,!0),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o,!0)}),x(()=>{if(!t.isOpen||!e)return;const a=e.getBoundingClientRect(),n=Math.max(4,window.innerWidth-a.width-4),r=Math.max(4,window.innerHeight-a.height-4),o=Math.min(t.x,n),i=Math.min(t.y,r);e.style.left=`${o}px`,e.style.top=`${i}px`}),D(at,{get when(){return t.isOpen},get children(){var a=xV();a.$$contextmenu=t=>t.preventDefault();return"function"==typeof e?wt(e,a):e=a,St(a,D(tt,{get each(){return t.items},children:e=>D(at,{get when(){return"separator"!==e.type},get fallback(){return IV()},get children(){var a=AV(),n=a.firstChild;return a.$$click=()=>{var a;e.disabled||(null==(a=e.onSelect)||a.call(e),t.onClose())},St(a,D(at,{get when(){return e.icon},get fallback(){return TV()},get children(){var t=wV();return M(()=>gt(t,"data-lucide",e.icon)),t}}),n),St(n,()=>e.label),St(a,D(at,{get when(){return e.shortcut},get children(){var t=SV();return St(t,()=>e.shortcut),t}}),null),M(t=>{var n=e.disabled,r=e.testId;return n!==t.e&&(a.disabled=t.e=n),r!==t.t&>(a,"data-testid",t.t=r),t},{e:void 0,t:void 0}),a}})})),M(e=>{var n=`${t.x}px`,r=`${t.y}px`;return n!==e.e&&Mt(a,"left",e.e=n),r!==e.t&&Mt(a,"top",e.t=r),e},{e:void 0,t:void 0}),a}})}function kV(t){const{linkDialog:e,setLinkDialog:a,imageAltDialog:n,setImageAltDialog:r,imageCaptionDialog:o,setImageCaptionDialog:i,contextMenu:l,fontDialog:s,setFontDialog:d,paragraphDialog:c,setParagraphDialog:h,tablePropertiesDialog:p,setTablePropertiesDialog:u}=t.dialogs;return[D(ck,{get isOpen(){return e().isOpen},get initialHref(){return e().initialHref},onClose:()=>{a({...e(),isOpen:!1}),t.focusInput()},onConfirm:e=>t.applyLinkCommand(e.trim()||null)}),D(fk,{get isOpen(){return n().isOpen},get initialAlt(){return n().initialAlt},onClose:()=>{r({...n(),isOpen:!1}),t.focusInput()},onConfirm:e=>t.applyImageAltCommand(e.trim())}),D(bk,{get isOpen(){return o().isOpen},get initialCaption(){return o().initialCaption},onClose:()=>{i({...o(),isOpen:!1}),t.focusInput()},onConfirm:e=>t.applyImageCaptionCommand(e.trim())}),D(MV,{get fr(){return t.findReplace}}),D(Dk,{get isOpen(){return s().isOpen},get initial(){return s().initial},get familyOptions(){return t.fontFamilyOptions()},get sizeOptions(){return t.fontSizeOptions()},onClose:()=>{d({...s(),isOpen:!1}),t.focusInput()},get onApply(){return t.applyFontDialogValues}}),D(nV,{get isOpen(){return c().isOpen},get initial(){return c().initial},onClose:()=>{h({...c(),isOpen:!1}),t.focusInput()},get onApply(){return t.applyParagraphDialogValues}}),D(bV,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{u({...p(),isOpen:!1}),t.focusInput()},get onApply(){return t.applyTablePropertiesDialogValues}}),D(CV,{get isOpen(){return l().isOpen},get x(){return l().x},get y(){return l().y},get items(){return t.contextMenuItems()},get onClose(){return t.closeContextMenu}})]}ft(["contextmenu","click"]);var VV=ut("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function EV(t){return[D(at,{get when(){return t.useComposedShell()},get children(){return(()=>{const e=t.shellComponent(),{runtime:a,chrome:n,view:r}=t;return D(e,{get state(){return a.state()},get toolbarHost(){return a.toolbarHost},get runtimeEditor(){return a.runtimeEditor},get persistenceStatus(){return a.persistenceStatus},get toolbarRegistry(){return a.toolbarRegistry},get menuRegistry(){return a.menuRegistry},get showChrome(){return n.showChrome()},get showTitleBar(){return n.showTitleBar()},get showMenubar(){return n.showMenubar()},get showToolbar(){return n.showToolbar()},get showOutline(){return n.showOutline()},get toolbarView(){return n.toolbarView()},get toolbarLayout(){return n.toolbarLayout()},get isReadOnly(){return r.isReadOnly()},get measuredBlockHeights(){return r.measuredBlockHeights},get measuredParagraphLayouts(){return r.measuredParagraphLayouts},get viewportHeight(){return r.viewportHeight},get showFloatingTableToolbar(){return a.showFloatingTableToolbar},get layout(){return r.layout},get overlays(){return r.overlays},get refs(){return r.refs},get surfaceHandlers(){return r.surfaceHandlers},get inputHandlers(){return r.inputHandlers},get fileHandlers(){return r.fileHandlers}})})()}}),D(at,{get when(){return!t.useComposedShell()},get children(){return D(Ny,{get editor(){return t.runtime.runtimeEditor},get children(){var e=VV();return St(e.firstChild,D(by,{get state(){return t.runtime.state},get layout(){return{...t.view.layout,measuredBlockHeights:t.view.measuredBlockHeights,measuredParagraphLayouts:t.view.measuredParagraphLayouts,readOnly:t.view.isReadOnly()}},get overlays(){return{...t.view.overlays,toolbarHost:t.runtime.toolbarHost,persistenceStatus:t.runtime.persistenceStatus,showFloatingTableToolbar:t.runtime.showFloatingTableToolbar}},get refs(){return t.view.refs},get surfaceHandlers(){return t.view.surfaceHandlers},get inputHandlers(){return t.view.inputHandlers},get fileHandlers(){return t.view.fileHandlers}})),e}})}})]}var RV=ut('<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><button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-welcome-skip></button><button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-welcome-enable>');function LV(t){const e=Wt(),a=()=>{xc(),hc(),t.onClose()},n=()=>{pc(!1),hc(),t.onClose()};return D(at,{get when(){return t.isOpen},get children(){var t=RV(),r=t.firstChild,o=r.firstChild,i=o.nextSibling,l=i.nextSibling,s=l.nextSibling.firstChild,d=s.nextSibling;return St(r,D(Ft,{height:72,class:"oasis-editor-welcome-mark"}),o),St(o,()=>e("welcome.title")),St(i,()=>e("welcome.body")),St(l,()=>e("welcome.note")),s.$$click=n,St(s,()=>e("welcome.skip")),d.$$click=a,St(d,()=>e("welcome.enable")),t}})}ft(["click"]);const zV="http://schemas.openxmlformats.org/wordprocessingml/2006/main",NV="http://schemas.openxmlformats.org/package/2006/relationships",qV="http://schemas.openxmlformats.org/officeDocument/2006/relationships",OV="http://schemas.microsoft.com/office/word/2010/wordml";function PV(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function WV(t,e){return Number.isFinite(t)?Math.max(0,Math.round(t/Mn*In)):e}function HV(t){return null!=t&&Number.isFinite(t)?Math.round(t/Mn*In):null}function UV(t){return null!=t&&Number.isFinite(t)?Math.max(0,Math.round(20*t)):null}function FV(t,e="000000"){const a=null==t?void 0:t.trim().replace(/^#/,"");return a&&/^[0-9a-fA-F]{6}$/.test(a)?a.toUpperCase():e}function BV(t){if("end"===t.kind)return`<w:bookmarkEnd w:id="${t.wId}"/>`;const e=(void 0!==t.colFirst?` w:colFirst="${t.colFirst}"`:"")+(void 0!==t.colLast?` w:colLast="${t.colLast}"`:"");return`<w:bookmarkStart w:id="${t.wId}" w:name="${PV(t.name??"")}"${e}/>`}function GV(t){switch(t.kind){case"start":return`<w:commentRangeStart w:id="${t.wId}"/>`;case"end":return`<w:commentRangeEnd w:id="${t.wId}"/>`;case"reference":return`<w:r><w:commentReference w:id="${t.wId}"/></w:r>`}}const ZV=`xmlns:w="${zV}" xmlns:w14="${OV}" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"`;function DV(t){const e=t.comments.map(({comment:t,wId:e,paraId:a})=>{const n=void 0!==t.date?` w:date="${new Date(t.date).toISOString().replace(/\.\d{3}Z$/,"Z")}"`:"",r=t.initials?` w:initials="${PV(t.initials)}"`:"";return`<w:comment w:id="${e}" w:author="${PV(t.author)}"${n}${r}><w:p w14:paraId="${a}">${o=t.text,`<w:r>${o.split("\n").map((t,e)=>`${e>0?"<w:br/>":""}<w:t xml:space="preserve">${PV(t)}</w:t>`).join("")}</w:r>`}</w:p></w:comment>`;var o}).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:comments ${ZV}>${e}</w:comments>`}function KV(t,e="000000"){if("none"===t.type||t.width<=0)return'w:val="nil"/>';return`w:val="${"dotted"===t.type?"dotted":"dashed"===t.type?"dashed":"single"}" w:sz="${Math.max(1,Math.round(8*t.width))}" w:space="0" w:color="${FV(t.color,e)}"/>`}function jV(t){const e=[["top",t.borderTop],["left",t.borderLeft],["bottom",t.borderBottom],["right",t.borderRight]].filter(t=>null!=t[1]).map(([t,e])=>`<w:${t} ${KV(e)}`);return e.length>0?`<w:pBdr>${e.join("")}</w:pBdr>`:""}const XV="6F6F6F";function JV(t,e){return void 0===e?"":e?`<w:${t}/>`:`<w:${t} w:val="0"/>`}function YV(t,e,a={}){if("number"==typeof e&&Number.isFinite(e))return`<w:${t} w:w="${UV(e)??0}" w:type="dxa"/>`;if("string"==typeof e){const a=e.trim();if("auto"===a)return`<w:${t} w:w="0" w:type="auto"/>`;if(a.endsWith("%")){const e=Number.parseFloat(a.slice(0,-1));if(Number.isFinite(e))return`<w:${t} w:w="${Math.round(50*e)}" w:type="pct"/>`}const n=Number.parseFloat(a);if(Number.isFinite(n))return`<w:${t} w:w="${Math.round(n)}" w:type="dxa"/>`}return a.fallbackAuto?`<w:${t} w:w="0" w:type="auto"/>`:""}function QV(t){return KV(t??{width:.75,type:"solid",color:`#${XV}`},XV)}function _V(t,e){var a,n,r,o,i,l,s,d,c,h;const p=Math.max(1,Math.floor(t.colSpan??1)),u=[],f=YV("tcW",(null==(a=t.style)?void 0:a.width)??e);f&&u.push(f),p>1&&u.push(`<w:gridSpan w:val="${p}"/>`),"restart"===t.vMerge?u.push('<w:vMerge w:val="restart"/>'):"continue"===t.vMerge&&u.push("<w:vMerge/>"),(null==(n=t.style)?void 0:n.shading)&&u.push(`<w:shd w:val="clear" w:color="auto" w:fill="${FV(t.style.shading,"FFFFFF")}"/>`);const g=JV("noWrap",null==(r=t.style)?void 0:r.noWrap);g&&u.push(g);const m=JV("tcFitText",null==(o=t.style)?void 0:o.fitText);if(m&&u.push(m),(null==(i=t.style)?void 0:i.headers)&&u.push(`<w:headers w:val="${PV(t.style.headers)}"/>`),null==(l=t.style)?void 0:l.verticalAlign){const e="middle"===t.style.verticalAlign?"center":t.style.verticalAlign;u.push(`<w:vAlign w:val="${e}"/>`)}(null==(s=t.style)?void 0:s.textDirection)&&u.push(`<w:textDirection w:val="${t.style.textDirection}"/>`),u.push(function(t){const e=t.style,a=null==e?void 0:e.padding,n=UV(a??(null==e?void 0:e.paddingTop)??0),r=UV(a??(null==e?void 0:e.paddingBottom)??0);return`<w:tcMar><w:top w:w="${n??0}" w:type="dxa"/><w:left w:w="${UV(a??(null==e?void 0:e.paddingLeft)??5.4)??0}" w:type="dxa"/><w:bottom w:w="${r??0}" w:type="dxa"/><w:right w:w="${UV(a??(null==e?void 0:e.paddingRight)??5.4)??0}" w:type="dxa"/>${void 0!==(null==e?void 0:e.paddingStart)?`<w:start w:w="${UV(e.paddingStart)??0}" w:type="dxa"/>`:""}${void 0!==(null==e?void 0:e.paddingEnd)?`<w:end w:w="${UV(e.paddingEnd)??0}" w:type="dxa"/>`:""}</w:tcMar>`}(t)),u.push(function(t){var e,a,n,r,o,i,l,s;const d=[`<w:top ${QV(null==(e=t.style)?void 0:e.borderTop)}`,`<w:left ${QV(null==(a=t.style)?void 0:a.borderLeft)}`,`<w:bottom ${QV(null==(n=t.style)?void 0:n.borderBottom)}`,`<w:right ${QV(null==(r=t.style)?void 0:r.borderRight)}`];return(null==(o=t.style)?void 0:o.borderStart)&&d.push(`<w:start ${QV(t.style.borderStart)}`),(null==(i=t.style)?void 0:i.borderEnd)&&d.push(`<w:end ${QV(t.style.borderEnd)}`),(null==(l=t.style)?void 0:l.borderTopLeftToBottomRight)&&d.push(`<w:tl2br ${QV(t.style.borderTopLeftToBottomRight)}`),(null==(s=t.style)?void 0:s.borderTopRightToBottomLeft)&&d.push(`<w:tr2bl ${QV(t.style.borderTopRightToBottomLeft)}`),`<w:tcBorders>${d.join("")}</w:tcBorders>`}(t));const v=JV("hideMark",null==(d=t.style)?void 0:d.hideMark);return v&&u.push(v),(null==(h=null==(c=t.style)?void 0:c.revisionXml)?void 0:h.length)&&u.push(...t.style.revisionXml),u.length>0?`<w:tcPr>${u.join("")}</w:tcPr>`:""}function $V(t,e){if(void 0===e||!Number.isFinite(e))return"";const a=Math.floor(e);return a>0?`<w:${t} w:val="${a}"/>`:""}function tE(t,e){const a="number"==typeof t?UV(t):"string"==typeof t?Number.parseFloat(t):null,n=null!==a&&Number.isFinite(a);if(!n&&!e)return"";const r=[];return n&&r.push(`w:val="${Math.round(a)}"`),r.push(`w:hRule="${e??"atLeast"}"`),`<w:trHeight ${r.join(" ")}/>`}function eE(t){var e,a,n,r,o,i,l,s,d;const c=[],h=$V("gridBefore",null==(e=t.style)?void 0:e.gridBefore);h&&c.push(h);const p=$V("gridAfter",null==(a=t.style)?void 0:a.gridAfter);p&&c.push(p);const u=YV("wBefore",null==(n=t.style)?void 0:n.widthBefore);u&&c.push(u);const f=YV("wAfter",null==(r=t.style)?void 0:r.widthAfter);f&&c.push(f);const g=YV("tblCellSpacing",null==(o=t.style)?void 0:o.cellSpacing);g&&c.push(g);const m=function(t){var e,a;return tE(null==(e=t.style)?void 0:e.height,null==(a=t.style)?void 0:a.heightRule)}(t);m&&c.push(m);const v=JV("cantSplit",null==(i=t.style)?void 0:i.cantSplit);v&&c.push(v),t.isHeader&&c.push("<w:tblHeader/>");const b=JV("hidden",null==(l=t.style)?void 0:l.hidden);return b&&c.push(b),(null==(d=null==(s=t.style)?void 0:s.revisionXml)?void 0:d.length)&&c.push(...t.style.revisionXml),c.length>0?`<w:trPr>${c.join("")}</w:trPr>`:""}function aE(t){var e,a,n,r,o,i,l,s,d,c,h,p,u,f,g;const m=[];if((null==(e=t.style)?void 0:e.styleId)&&m.push(`<w:tblStyle w:val="${PV(t.style.styleId)}"/>`),null==(a=t.style)?void 0:a.tblLook){const e=t.style.tblLook;m.push(`<w:tblLook w:firstRow="${e.firstRow?"1":"0"}" w:lastRow="${e.lastRow?"1":"0"}" w:firstColumn="${e.firstCol?"1":"0"}" w:lastColumn="${e.lastCol?"1":"0"}" w:noHBand="${e.noHBand?"1":"0"}" w:noVBand="${e.noVBand?"1":"0"}"/>`)}(null==(n=t.style)?void 0:n.altTitle)&&m.push(`<w:tblCaption w:val="${PV(t.style.altTitle)}"/>`),(null==(r=t.style)?void 0:r.altDescription)&&m.push(`<w:tblDescription w:val="${PV(t.style.altDescription)}"/>`);const v=(b=null==(o=t.style)?void 0:o.floating)&&0!==Object.keys(b).length?`<w:tblpPr ${Object.entries(b).map(([t,e])=>`w:${t}="${PV(e)}"`).join(" ")}/>`:"";var b;v&&m.push(v);const y=t.gridCols&&t.gridCols.length>0?t.gridCols.reduce((t,e)=>t+e,0):void 0;m.push(function(t,e=!0){return YV("tblW",t,{fallbackAuto:e})}((null==(i=t.style)?void 0:i.width)??y)),(null==(l=t.style)?void 0:l.align)&&m.push(`<w:jc w:val="${t.style.align}"/>`);const M=YV("tblCellSpacing",null==(s=t.style)?void 0:s.cellSpacing);M&&m.push(M);const x=function(t){if(!t)return"";const e=[],a=(t,a)=>{void 0!==a&&Number.isFinite(a)&&e.push(`<w:${t} w:w="${UV(a)??0}" w:type="dxa"/>`)};return a("top",t.top),a("left",t.left),a("bottom",t.bottom),a("right",t.right),a("start",t.start),a("end",t.end),e.length>0?`<w:tblCellMar>${e.join("")}</w:tblCellMar>`:""}(null==(d=t.style)?void 0:d.defaultCellMargins);x&&m.push(x);const w=YV("tblInd",null==(c=t.style)?void 0:c.indentLeft);w&&m.push(w),m.push(`<w:tblLayout w:type="${(null==(h=t.style)?void 0:h.layout)??"fixed"}"/>`);const S=JV("bidiVisual",null==(p=t.style)?void 0:p.bidiVisual);return S&&m.push(S),(null==(u=t.style)?void 0:u.tblOverlap)&&m.push(`<w:tblOverlap w:val="${PV(t.style.tblOverlap)}"/>`),(null==(g=null==(f=t.style)?void 0:f.revisionXml)?void 0:g.length)&&m.push(...t.style.revisionXml),`<w:tblPr>${m.join("")}</w:tblPr>`}function nE(t,e){const a=sn(t),n=new Map(a.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t])),r=t.rows.map((a,r)=>{const o=a.cells.map((a,o)=>{const i=n.get(`${r}:${o}`),l=i&&t.gridCols?t.gridCols.slice(i.visualColumnIndex,i.visualColumnIndex+Math.max(1,i.colSpan)).reduce((t,e)=>t+e,0):void 0,s=(a.blocks.length>0?a.blocks:[{id:"",type:"paragraph",runs:[{id:"",text:""}]}]).map(t=>e(t,a)).join(""),d="continue"===a.vMerge?"<w:p/>":s;return`<w:tc>${_V(a,l)}${d}</w:tc>`}).join("");return`<w:tr>${a.tblPrExXml??""}${eE(a)}${o}</w:tr>`}).join(""),o=t.gridCols?`<w:tblGrid>${t.gridCols.map(t=>`<w:gridCol w:w="${UV(t)??0}"/>`).join("")}${t.tblGridChangeXml??""}</w:tblGrid>`:"";return`<w:tbl>${aE(t)}${o}${r}</w:tbl>`}function rE(t){if(!t||0===t.length)return"";const e=t.map(t=>{const e=UV(t.position);if(null===e)return"";const a=[`w:val="${t.type}"`,`w:pos="${e}"`];return t.leader&&"none"!==t.leader?a.push(`w:leader="${t.leader}"`):"none"===t.leader&&a.push('w:leader="none"'),`<w:tab ${a.join(" ")}/>`}).filter(Boolean);return e.length>0?`<w:tabs>${e.join("")}</w:tabs>`:""}function oE(t){const e=[];if(t.align&&e.push(`<w:jc w:val="${t.align}"/>`),void 0!==t.spacingBefore||void 0!==t.spacingAfter||void 0!==t.lineHeight){const a=[],n=HV(t.spacingBefore),r=HV(t.spacingAfter),o=void 0!==t.lineHeight&&null!==t.lineHeight&&Number.isFinite(t.lineHeight),i="exact"===t.lineRule||"atLeast"===t.lineRule,l=o?i?WV(t.lineHeight,0):Math.round(240*t.lineHeight):null;null!==n&&a.push(`w:before="${n}"`),null!==r&&a.push(`w:after="${r}"`),null!==l&&a.push(`w:line="${l}"`),null!==l&&i&&a.push(`w:lineRule="${t.lineRule}"`),a.length>0&&e.push(`<w:spacing ${a.join(" ")}/>`)}if(void 0!==t.indentLeft||void 0!==t.indentRight||void 0!==t.indentFirstLine||void 0!==t.indentHanging){const a=[],n=HV(t.indentLeft),r=HV(t.indentRight),o=HV(t.indentFirstLine),i=HV(t.indentHanging);null!==n&&a.push(`w:left="${n}"`),null!==r&&a.push(`w:right="${r}"`),null!==o&&a.push(`w:firstLine="${o}"`),null!==i&&a.push(`w:hanging="${i}"`),a.length>0&&e.push(`<w:ind ${a.join(" ")}/>`)}const a=rE(t.tabs);a&&e.push(a),t.pageBreakBefore&&e.push("<w:pageBreakBefore/>"),t.keepWithNext&&e.push("<w:keepNext/>"),t.keepLinesTogether&&e.push("<w:keepLines/>"),!1===t.widowControl&&e.push('<w:widowControl w:val="0"/>'),t.contextualSpacing&&e.push("<w:contextualSpacing/>");const n=jV(t);return n&&e.push(n),t.shading&&e.push(`<w:shd w:val="clear" w:color="auto" w:fill="${FV(t.shading,"FFFFFF")}"/>`),t.textDirection&&e.push(`<w:textDirection w:val="${t.textDirection}"/>`),null!=t.outlineLevel&&e.push(`<w:outlineLvl w:val="${t.outlineLevel}"/>`),e.length>0?`<w:pPr>${e.join("")}</w:pPr>`:""}function iE(t,e,a,n){var r,o;const i=[],l=function(t,e){const a=He(t.style,e);return{align:a.align,spacingBefore:a.spacingBefore,spacingAfter:a.spacingAfter,contextualSpacing:a.contextualSpacing,lineHeight:a.lineHeight,lineRule:a.lineRule,indentLeft:a.indentLeft,indentRight:a.indentRight,indentFirstLine:a.indentFirstLine,indentHanging:a.indentHanging,pageBreakBefore:a.pageBreakBefore,keepWithNext:a.keepWithNext,keepLinesTogether:a.keepLinesTogether,widowControl:a.widowControl,shading:a.shading,borderTop:a.borderTop,borderRight:a.borderRight,borderBottom:a.borderBottom,borderLeft:a.borderLeft,tabs:a.tabs,textDirection:a.textDirection,outlineLevel:a.outlineLevel}}(t,a),s=(null==(r=t.style)?void 0:r.align)??(null==n?void 0:n.align)??l.align;if((null==(o=t.style)?void 0:o.styleId)&&i.push(`<w:pStyle w:val="${PV(t.style.styleId)}"/>`),s&&i.push(`<w:jc w:val="${s}"/>`),void 0!==l.spacingBefore||void 0!==l.spacingAfter||void 0!==l.lineHeight){const t=[],e=HV(l.spacingBefore),a=HV(l.spacingAfter),n=void 0!==l.lineHeight&&null!==l.lineHeight&&Number.isFinite(l.lineHeight),r="exact"===l.lineRule||"atLeast"===l.lineRule,o=n?r?WV(l.lineHeight,0):Math.round(240*l.lineHeight):null;null!==e&&t.push(`w:before="${e}"`),null!==a&&t.push(`w:after="${a}"`),null!==o&&t.push(`w:line="${o}"`),null!==o&&r&&t.push(`w:lineRule="${l.lineRule}"`),t.length>0&&i.push(`<w:spacing ${t.join(" ")}/>`)}if(void 0!==l.indentLeft||void 0!==l.indentRight||void 0!==l.indentFirstLine||void 0!==l.indentHanging){const t=[],e=HV(l.indentLeft),a=HV(l.indentRight),n=HV(l.indentFirstLine),r=HV(l.indentHanging);null!==e&&t.push(`w:left="${e}"`),null!==a&&t.push(`w:right="${a}"`),null!==n&&t.push(`w:firstLine="${n}"`),null!==r&&t.push(`w:hanging="${r}"`),t.length>0&&i.push(`<w:ind ${t.join(" ")}/>`)}const d=rE(l.tabs);d&&i.push(d),l.pageBreakBefore&&i.push("<w:pageBreakBefore/>"),l.keepWithNext&&i.push("<w:keepNext/>"),l.keepLinesTogether&&i.push("<w:keepLines/>"),!1===l.widowControl&&i.push('<w:widowControl w:val="0"/>'),l.contextualSpacing&&i.push("<w:contextualSpacing/>");const c=jV(l);c&&i.push(c),l.shading&&i.push(`<w:shd w:val="clear" w:color="auto" w:fill="${FV(l.shading,"FFFFFF")}"/>`),l.textDirection&&i.push(`<w:textDirection w:val="${l.textDirection}"/>`),null!=l.outlineLevel&&i.push(`<w:outlineLvl w:val="${l.outlineLevel}"/>`);const h=e.get(t.id);return h&&i.push(`<w:numPr><w:ilvl w:val="${h.level}"/><w:numId w:val="${h.numId}"/></w:numPr>`),i.length>0?`<w:pPr>${i.join("")}</w:pPr>`:""}const lE={black:[0,0,0],blue:[0,0,255],cyan:[0,255,255],green:[0,128,0],magenta:[255,0,255],red:[255,0,0],yellow:[255,255,0],white:[255,255,255],darkBlue:[0,0,139],darkCyan:[0,139,139],darkGreen:[0,100,0],darkMagenta:[139,0,139],darkRed:[139,0,0],darkYellow:[184,134,11],darkGray:[169,169,169],lightGray:[211,211,211]},sE={ffff00:"yellow",fef08a:"yellow",ff0000:"red","00ff00":"green","0000ff":"blue","00ffff":"cyan",ff00ff:"magenta","000000":"black",ffffff:"white"};function dE(t){if(t in lE)return t;const e=t.trim().replace(/^#/,"").toLowerCase(),a=sE[e];if(a)return a;const n=function(t){const e=t.trim().replace(/^#/,"");return/^[0-9a-fA-F]{6}$/.test(e)?[Number.parseInt(e.slice(0,2),16),Number.parseInt(e.slice(2,4),16),Number.parseInt(e.slice(4,6),16)]:null}(t);if(!n)return"yellow";let r="yellow",o=Number.POSITIVE_INFINITY;for(const[i,l]of Object.entries(lE)){const t=(l[0]-n[0])**2+(l[1]-n[1])**2+(l[2]-n[2])**2;t<o&&(o=t,r=i)}return r}function cE(t){if(!t)return"";const e=[];if(t.bold&&e.push("<w:b/>","<w:bCs/>"),t.italic&&e.push("<w:i/>","<w:iCs/>"),t.underline){const a=t.underlineStyle??"single",n=t.underlineColor?` w:color="${PV(t.underlineColor.replace(/^#/,""))}"`:"";e.push(`<w:u w:val="${PV(a)}"${n}/>`)}if(t.strike&&e.push("<w:strike/>"),t.doubleStrike&&e.push("<w:dstrike/>"),t.smallCaps&&e.push("<w:smallCaps/>"),t.allCaps&&e.push("<w:caps/>"),t.hidden&&e.push("<w:vanish/>"),t.noProof&&e.push("<w:noProof/>"),t.webHidden&&e.push("<w:webHidden/>"),t.specVanish&&e.push("<w:specVanish/>"),t.textEffect&&e.push(`<w:effect w:val="${PV(t.textEffect)}"/>`),void 0!==t.characterScale&&null!==t.characterScale&&Number.isFinite(t.characterScale)&&e.push(`<w:w w:val="${Math.max(1,Math.round(t.characterScale))}"/>`),void 0!==t.characterSpacing&&null!==t.characterSpacing){const n=null!=(a=t.characterSpacing)&&Number.isFinite(a)?Math.round(20*a):null;null!==n&&e.push(`<w:spacing w:val="${n}"/>`)}var a;void 0!==t.baselineShift&&null!==t.baselineShift&&Number.isFinite(t.baselineShift)&&e.push(`<w:position w:val="${Math.round(2*t.baselineShift)}"/>`),void 0!==t.kerningThreshold&&null!==t.kerningThreshold&&Number.isFinite(t.kerningThreshold)&&e.push(`<w:kern w:val="${Math.max(0,Math.round(2*t.kerningThreshold))}"/>`);const n=function(t){switch(t){case"none":return"none";case"standard":return"standard";case"contextual":return"contextual";case"historical":return"historical";case"standardContextual":return"standardContextual";default:return null}}(t.ligatures);n&&e.push(`<w14:ligatures w14:val="${n}"/>`);const r=function(t){switch(t){case"proportional":return"proportional";case"tabular":return"tabular";default:return null}}(t.numberSpacing);r&&e.push(`<w14:numSpacing w14:val="${r}"/>`);const o=function(t){switch(t){case"lining":return"lining";case"oldStyle":return"oldStyle";default:return null}}(t.numberForm);o&&e.push(`<w14:numForm w14:val="${o}"/>`);const i=function(t){return"number"!=typeof t||t<1||t>20?null:(1<<t-1).toString(16).toUpperCase().padStart(8,"0")}(t.stylisticSet);if(i&&e.push(`<w14:stylisticSets w14:val="${i}"/>`),t.contextualAlternates&&e.push('<w14:cntxtAlts w14:val="1"/>'),t.superscript?e.push('<w:vertAlign w:val="superscript"/>'):t.subscript&&e.push('<w:vertAlign w:val="subscript"/>'),t.fontFamily&&e.push(`<w:rFonts w:ascii="${PV(t.fontFamily)}" w:hAnsi="${PV(t.fontFamily)}" w:cs="${PV(t.fontFamily)}"/>`),void 0!==t.fontSize&&null!==t.fontSize){const a=function(t){return null!=t&&Number.isFinite(t)?Math.round(t/Mn*72*2):null}(t.fontSize);null!==a&&e.push(`<w:sz w:val="${a}"/>`,`<w:szCs w:val="${a}"/>`)}if(t.color&&e.push(`<w:color w:val="${PV(t.color.replace(/^#/,""))}"/>`),t.highlight&&e.push(`<w:highlight w:val="${PV(dE(t.highlight))}"/>`),t.shading&&e.push(`<w:shd w:val="clear" w:color="auto" w:fill="${FV(t.shading,"FFFFFF")}"/>`),t.language){const a=[];t.language.value&&a.push(`w:val="${PV(t.language.value)}"`),t.language.eastAsia&&a.push(`w:eastAsia="${PV(t.language.eastAsia)}"`),t.language.bidi&&a.push(`w:bidi="${PV(t.language.bidi)}"`),a.length>0&&e.push(`<w:lang ${a.join(" ")}/>`)}return e.length>0?`<w:rPr>${e.join("")}</w:rPr>`:""}function hE(t){if(0===t.length)return"";var e;return`<w:t${/^\s|\s$/.test(e=t)||e.includes(" ")?' xml:space="preserve"':""}>${PV(t)}</w:t>`}function pE(t){if(0===t.length)return"<w:t></w:t>";let e="",a="";for(const n of t)"\n"!==n?"\t"!==n?"‑"!==n?""!==n?a+=n:(e+=hE(a),a="",e+="<w:softHyphen/>"):(e+=hE(a),a="",e+="<w:noBreakHyphen/>"):(e+=hE(a),a="",e+="<w:tab/>"):(e+=hE(a),a="",e+="<w:br/>");return e+=hE(a),e||"<w:t></w:t>"}function uE(t,e){return t??e?"1":"0"}function fE(t,e,a){const n=PV((null==e?void 0:e.relativeFrom)??a);if(null==e?void 0:e.align)return`<wp:${t} relativeFrom="${n}"><wp:align>${PV(e.align)}</wp:align></wp:${t}>`;return`<wp:${t} relativeFrom="${n}"><wp:posOffset>${(null==e?void 0:e.offset)??0}</wp:posOffset></wp:${t}>`}function gE(t){if(!t||t.length<3)return"";const e=t=>Math.round(21600*Math.min(1,Math.max(0,t))),a=(t,a)=>`<wp:${a} x="${e(t.x)}" y="${e(t.y)}"/>`,n=t[0];return`<wp:wrapPolygon edited="0">${[a(n,"start"),...t.slice(1).map(t=>a(t,"lineTo")),a(n,"lineTo")].join("")}</wp:wrapPolygon>`}function mE(t){const{cx:e,cy:a,floating:n,docPrId:r,docPrName:o,altAttr:i,graphicXml:l}=t,s=PV(o);if(!n)return`<w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${e}" cy="${a}"/><wp:effectExtent l="0" t="0" r="0" b="0"/><wp:docPr id="${r}" name="${s}"${i}/>${l}</wp:inline></w:drawing>`;const d=n.distT??0,c=n.distB??0,h=n.distL??0,p=n.distR??0,u=fE("positionH",n.positionH,"column"),f=fE("positionV",n.positionV,"paragraph"),g=function(t,e){switch(t){case"square":return'<wp:wrapSquare wrapText="bothSides"/>';case"tight":{const t=gE(e);return t?`<wp:wrapTight wrapText="bothSides">${t}</wp:wrapTight>`:'<wp:wrapTight wrapText="bothSides"/>'}case"through":{const t=gE(e);return t?`<wp:wrapThrough wrapText="bothSides">${t}</wp:wrapThrough>`:'<wp:wrapThrough wrapText="bothSides"/>'}case"topAndBottom":return"<wp:wrapTopAndBottom/>";default:return"<wp:wrapNone/>"}}(n.wrap,t.wrapPolygon);return`<w:drawing><wp:anchor distT="${d}" distB="${c}" distL="${h}" distR="${p}" simplePos="${uE(n.simplePos,!1)}" relativeHeight="${n.relativeHeight??0}" behindDoc="${uE(n.behindDoc,!1)}" locked="${uE(n.locked,!1)}" layoutInCell="${uE(n.layoutInCell,!0)}" allowOverlap="${uE(n.allowOverlap,!0)}"><wp:simplePos x="0" y="0"/>${u}${f}<wp:extent cx="${e}" cy="${a}"/><wp:effectExtent l="0" t="0" r="0" b="0"/>${g}<wp:docPr id="${r}" name="${s}"${i}/>${l}</wp:anchor></w:drawing>`}function vE(t,e,a,n){const r=a.images.find(t=>t.rId===e);if(!r)return null;const o=(parseInt(e.replace(/\D+/g,""),10)||0)+1,i=void 0!==r.alt?` descr="${PV(r.alt)}" title="${PV(r.alt)}"`:"",l=function(t){let e="";if(t.rotation){const a=Math.round(6e4*t.rotation);0!==a&&(e+=` rot="${a}"`)}return t.flipH&&(e+=' flipH="1"'),t.flipV&&(e+=' flipV="1"'),e}(r),s=function(t){if(!t)return"";const e=t=>t?Math.round(1e5*t):0,a=e(t.left),n=e(t.top),r=e(t.right),o=e(t.bottom);return 0===a&&0===n&&0===r&&0===o?"":`<a:srcRect l="${a}" t="${n}" r="${r}" b="${o}"/>`}(r.crop),d="tile"===r.fillMode?"<a:tile/>":"<a:stretch><a:fillRect/></a:stretch>",c=function(t,e,a,n){return mE({cx:t.cx,cy:t.cy,floating:t.floating,docPrId:e,docPrName:"Picture",altAttr:a,graphicXml:n,wrapPolygon:t.wrapPolygon})}(r,o,i,`<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:nvPicPr><pic:cNvPr id="0" name="Picture"${i}/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip ${"linked"===r.kind?`r:link="${e}"`:`r:embed="${e}"`} xmlns:r="${qV}"/>${s}${d}</pic:blipFill><pic:spPr><a:xfrm${l}><a:off x="0" y="0"/><a:ext cx="${r.cx}" cy="${r.cy}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData></a:graphic>`);return`<w:r>${n}${c}</w:r>`}function bE(t,e,a,n,r,o){const i=Math.round(e.width*An),l=Math.round(e.height*An),s=a.textBoxDocPrIds.get(t.id)??1,d=e.name??"Text Box",c=void 0!==e.alt?` descr="${PV(e.alt)}" title="${PV(e.alt)}"`:"",h=function(t,e,a,n,r,o){const i=t.shape,l=PV((null==i?void 0:i.preset)??"rect"),s=t.rotation?Math.round(6e4*t.rotation):0,d=0!==s?` rot="${s}"`:"",c=(null==i?void 0:i.fill)?`<a:solidFill><a:srgbClr val="${PV(i.fill.replace(/^#/,""))}"/></a:solidFill>`:"";let h="";((null==i?void 0:i.borderColor)||void 0!==(null==i?void 0:i.borderWidthPt))&&(h=`<a:ln${void 0!==(null==i?void 0:i.borderWidthPt)?` w="${Math.round(12700*i.borderWidthPt)}"`:""}>${(null==i?void 0:i.borderColor)?`<a:solidFill><a:srgbClr val="${PV(i.borderColor.replace(/^#/,""))}"/></a:solidFill>`:""}<a:miter lim="800000"/></a:ln>`);const p=t.body,u=['rot="0"',`vert="${PV((null==p?void 0:p.vert)??"horz")}"`];u.push(`wrap="${PV((null==p?void 0:p.wrap)??"square")}"`),void 0!==(null==p?void 0:p.paddingLeft)&&u.push(`lIns="${Math.round(p.paddingLeft*An)}"`),void 0!==(null==p?void 0:p.paddingTop)&&u.push(`tIns="${Math.round(p.paddingTop*An)}"`),void 0!==(null==p?void 0:p.paddingRight)&&u.push(`rIns="${Math.round(p.paddingRight*An)}"`),void 0!==(null==p?void 0:p.paddingBottom)&&u.push(`bIns="${Math.round(p.paddingBottom*An)}"`),u.push(`anchor="${PV((null==p?void 0:p.anchor)??"t")}"`),u.push('anchorCtr="0"');const f=(null==p?void 0:p.autoFit)?"<a:spAutoFit/>":"",g=t.blocks.length>0,m=g?o(t.blocks,n,r):"";return'<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"><wps:wsp>'+(g?'<wps:cNvSpPr txBox="1"><a:spLocks noChangeArrowheads="1"/></wps:cNvSpPr>':"<wps:cNvSpPr/>")+`<wps:spPr bwMode="auto"><a:xfrm${d}><a:off x="0" y="0"/><a:ext cx="${e}" cy="${a}"/></a:xfrm><a:prstGeom prst="${l}"><a:avLst/></a:prstGeom>`+c+h+"</wps:spPr>"+(g?`<wps:txbx><w:txbxContent>${m}</w:txbxContent></wps:txbx>`:"")+`<wps:bodyPr ${u.join(" ")}>${f}</wps:bodyPr></wps:wsp></a:graphicData></a:graphic>`}(e,i,l,a,n,o);return`<w:r>${r}${mE({cx:i,cy:l,floating:e.floating,docPrId:s,docPrName:d,altAttr:c,graphicXml:h})}</w:r>`}const yE={footnote:"FootnoteReference",endnote:"EndnoteReference"};function ME(t){return`<w:r><w:rPr><w:rStyle w:val="${yE[t]}"/><w:vertAlign w:val="superscript"/></w:rPr><w:${t}Ref/></w:r>`}function xE(t,e,a,n){if(!e)return null;const r="footnote"===t?n.footnoteIdMap:n.endnoteIdMap,o=null==r?void 0:r.get(e.noteId);if(void 0===o)return null;const i={...a??{},superscript:!0},l=e.customMark?' w:customMarkFollows="1"':"",s=e.customMark?`<w:t xml:space="preserve">${PV(e.customMark)}</w:t>`:"";return`<w:r>${cE(i)}<w:${t}Reference${l} w:id="${o}"/>${s}</w:r>`}function wE(t,e,a,n,r){if(t.__isFootnoteRefMarker)return ME("footnote");if(t.__isEndnoteRefMarker)return ME("endnote");const o=function(t,e,a){var n;const r=We(t.styles,e,a),o={bold:r.bold,italic:r.italic,underline:r.underline,underlineStyle:r.underlineStyle,underlineColor:r.underlineColor,strike:r.strike,doubleStrike:r.doubleStrike,superscript:r.superscript,subscript:r.subscript,smallCaps:r.smallCaps,allCaps:r.allCaps,hidden:r.hidden,noProof:r.noProof,webHidden:r.webHidden,specVanish:r.specVanish,textEffect:r.textEffect,characterScale:r.characterScale,characterSpacing:r.characterSpacing,baselineShift:r.baselineShift,kerningThreshold:r.kerningThreshold,ligatures:r.ligatures,numberSpacing:r.numberSpacing,numberForm:r.numberForm,stylisticSet:r.stylisticSet,contextualAlternates:r.contextualAlternates,fontFamily:r.fontFamily,fontSize:r.fontSize,color:r.color,highlight:r.highlight,shading:r.shading,language:r.language};return(null==(n=t.styles)?void 0:n.link)&&(o.link=t.styles.link),o}(t,a,n);if(t.footnoteReference){const a=function(t,e,a){const n=t.footnoteReference;return xE("footnote",n?{noteId:n.footnoteId,customMark:n.customMark}:void 0,e,a)}(t,o,e);if(null!==a)return a}if(t.endnoteReference){const a=function(t,e,a){const n=t.endnoteReference;return xE("endnote",n?{noteId:n.endnoteId,customMark:n.customMark}:void 0,e,a)}(t,o,e);if(null!==a)return a}if(t.fieldChar)return function(t,e){const a=(t.fieldLock?' w:fldLock="true"':"")+(t.dirty?' w:dirty="true"':"");return`<w:r>${e}<w:fldChar w:fldCharType="${t.kind}"${a}/></w:r>`}(t.fieldChar,cE(o));if(void 0!==t.fieldInstruction)return i=t.fieldInstruction,`<w:r>${cE(o)}<w:instrText xml:space="preserve">${PV(i)}</w:instrText></w:r>`;var i;if(t.field)return function(t,e){return`<w:fldSimple w:instr="${"PAGE"===t?" PAGE ":" NUMPAGES "}"><w:r>${e}<w:t>1</w:t></w:r></w:fldSimple>`}(t.field.type,cE(o));if(t.textBox)return bE(t,t.textBox,e,n,cE(o),r);if(t.image){const a=e.imageMap.get(t.id);if(a){const n=vE(t.id,a,e,cE(o));if(null!==n)return n}}if(t.sym){const{font:e,char:a}=t.sym;return`<w:r>${cE(o)}<w:sym w:font="${PV(e)}" w:char="${a}"/></w:r>`}return`<w:r>${cE(o)}${pE(t.text)}</w:r>`}function SE(t,e,a,n,r){var o;const i=wE(t,e,a,n,r),l=null==(o=t.styles)?void 0:o.link;return l?function(t,e,a){if(e.startsWith("#"))return`<w:hyperlink w:anchor="${PV(e.slice(1))}">${t}</w:hyperlink>`;const n=a.hyperlinkMap.get(e);return n?`<w:hyperlink r:id="${n}">${t}</w:hyperlink>`:t}(i,l,e):i}function AE(t){return!(t.image||t.textBox||t.field||t.fieldChar||void 0!==t.fieldInstruction||t.footnoteReference||t.endnoteReference)}function IE(t,e,a){return t.map(t=>{var n;switch(t.type){case"paragraph":return TE(t,e,a);case"table":return((null==(n=t.style)?void 0:n.pageBreakBefore)?'<w:p><w:r><w:br w:type="page"/></w:r></w:p>':"")+nE(t,(t,n)=>{var r;return TE(t,e,a,{align:null==(r=n.style)?void 0:r.horizontalAlign})});default:return pe(t,"block")}}).join("")}function TE(t,e,a,n){var r,o,i;const l=t.runs.length>0?t.runs:[{id:"",text:""}],s=t.dropCap?function(t){const e=cE(t.style);var a;return`<w:p><w:pPr><w:keepNext/><w:framePr w:dropCap="${t.type}" w:lines="${t.lines}" w:wrap="around" w:vAnchor="text" w:hAnchor="text"/><w:spacing w:after="0"/>${e?`<w:rPr>${a=e,a.replace(/^<w:rPr>/,"").replace(/<\/w:rPr>$/,"")}</w:rPr>`:""}</w:pPr><w:r>${e}${pE(t.text)}</w:r></w:p>`}(t.dropCap):"",d=null==(r=e.bookmarkEventsByParagraph)?void 0:r.get(t.id),c=null==(o=e.commentEventsByParagraph)?void 0:o.get(t.id),h=[...(d??[]).map(t=>({offset:t.offset,seq:t.seq,xml:BV(t)})),...(c??[]).map(t=>({offset:t.offset,seq:t.seq,xml:GV(t)}))],p=h.length>0?function(t,e,a,n,r){const o=[...e].sort((t,e)=>t.offset-e.offset||t.seq-e.seq);let i=0,l=0,s="";const d=t=>{for(;i<o.length&&o[i].offset<=t;)s+=o[i].xml,i+=1};for(const c of t){const t=l,e=t+c.text.length;if(d(t),AE(c)&&c.text.length>0){let l=t;for(;i<o.length&&o[i].offset<e;){const e=o[i];e.offset>l&&(s+=SE({...c,text:c.text.slice(l-t,e.offset-t)},a,n,r,IE)),s+=e.xml,i+=1,l=e.offset}l<e&&(s+=SE({...c,text:c.text.slice(l-t)},a,n,r,IE))}else s+=SE(c,a,n,r,IE);l=e}return d(Number.POSITIVE_INFINITY),s}(l,h,e,null==(i=t.style)?void 0:i.styleId,a):l.map(n=>{var r;return SE(n,e,null==(r=t.style)?void 0:r.styleId,a,IE)}).join("");return`${s}<w:p>${iE(t,e.numberingInfo,a,n)}${p}</w:p>`}function CE(t){if(0===t.length)return[kE()];const[e,...a]=t;return"paragraph"!==e.type?[kE(!0),e,...a]:[(n=e,{...n,runs:[{id:"synthetic:footnoteRef",text:"",styles:{styleId:"FootnoteReference",superscript:!0},__isFootnoteRefMarker:!0},...n.runs],style:(null==(r=n.style)?void 0:r.styleId)?n.style:{...n.style??{},styleId:"FootnoteText"}}),...a];var n,r}function kE(t=!0){return{id:"synthetic:footnote-body-empty",type:"paragraph",runs:[...t?[{id:"synthetic:footnoteRef",text:"",styles:{styleId:"FootnoteReference",superscript:!0},__isFootnoteRefMarker:!0}]:[],{id:"synthetic:footnote-body-empty-text",text:""}],style:{styleId:"FootnoteText"}}}function VE(t){if(0===t.length)return[EE()];const[e,...a]=t;return"paragraph"!==e.type?[EE(!0),e,...a]:[(n=e,{...n,runs:[{id:"synthetic:endnoteRef",text:"",styles:{styleId:"EndnoteReference",superscript:!0},__isEndnoteRefMarker:!0},...n.runs],style:(null==(r=n.style)?void 0:r.styleId)?n.style:{...n.style??{},styleId:"EndnoteText"}}),...a];var n,r}function EE(t=!0){return{id:"synthetic:endnote-body-empty",type:"paragraph",runs:[...t?[{id:"synthetic:endnoteRef",text:"",styles:{styleId:"EndnoteReference",superscript:!0},__isEndnoteRefMarker:!0}]:[],{id:"synthetic:endnote-body-empty-text",text:""}],style:{styleId:"EndnoteText"}}}const RE=["wholeTable","band1Horz","band2Horz","band1Vert","band2Vert","firstCol","lastCol","firstRow","lastRow","nwCell","neCell","swCell","seCell"];function LE(t,e){const a=[],n=e.paragraphStyle?oE(e.paragraphStyle):"";n&&a.push(n);const r=e.textStyle?cE(e.textStyle):"";r&&a.push(r);const o=e.rowStyle?function(t){var e;if(!t)return"";const a=[],n=$V("gridBefore",t.gridBefore);n&&a.push(n);const r=$V("gridAfter",t.gridAfter);r&&a.push(r);const o=YV("wBefore",t.widthBefore);o&&a.push(o);const i=YV("wAfter",t.widthAfter);i&&a.push(i);const l=YV("tblCellSpacing",t.cellSpacing);l&&a.push(l);const s=tE(t.height,t.heightRule);s&&a.push(s);const d=JV("cantSplit",t.cantSplit);d&&a.push(d);const c=JV("hidden",t.hidden);return c&&a.push(c),(null==(e=t.revisionXml)?void 0:e.length)&&a.push(...t.revisionXml),a.length>0?`<w:trPr>${a.join("")}</w:trPr>`:""}(e.rowStyle):"";o&&a.push(o);const i=function(t){const e=[];if(t.borders){const a=t.borders,n=[["top",a.borderTop],["left",a.borderLeft],["bottom",a.borderBottom],["right",a.borderRight]].filter(t=>null!=t[1]).map(([t,e])=>`<w:${t} ${KV(e)}`).join("");n&&e.push(`<w:tcBorders>${n}</w:tcBorders>`)}return t.shading&&e.push(`<w:shd w:val="clear" w:color="auto" w:fill="${FV(t.shading,"FFFFFF")}"/>`),e.length>0?`<w:tcPr>${e.join("")}</w:tcPr>`:""}(e);return i&&a.push(i),0===a.length?"":`<w:tblStylePr w:type="${PV(t)}">${a.join("")}</w:tblStylePr>`}function zE(t){const e=[];if(e.push(`<w:name w:val="${PV(t.name)}"/>`),t.basedOn&&e.push(`<w:basedOn w:val="${PV(t.basedOn)}"/>`),t.nextStyle&&e.push(`<w:next w:val="${PV(t.nextStyle)}"/>`),("paragraph"===t.type||"table"===t.type)&&t.paragraphStyle){const a=oE(t.paragraphStyle);a&&e.push(a)}if(t.textStyle){const a=cE(t.textStyle);a&&e.push(a)}if("table"===t.type&&t.tableStyle){const a=t.tableStyle,n=[];if(void 0!==a.rowBandSize&&n.push(`<w:tblStyleRowBandSize w:val="${a.rowBandSize}"/>`),void 0!==a.colBandSize&&n.push(`<w:tblStyleColBandSize w:val="${a.colBandSize}"/>`),void 0!==a.indentLeft){const t="number"==typeof a.indentLeft?UV(a.indentLeft):null;null!==t&&n.push(`<w:tblInd w:w="${t}" w:type="dxa"/>`)}if(n.length>0&&e.push(`<w:tblPr>${n.join("")}</w:tblPr>`),a.conditionalFormats){const t=[...RE.filter(t=>t in a.conditionalFormats),...Object.keys(a.conditionalFormats).filter(t=>!RE.includes(t))];for(const n of t){const t=a.conditionalFormats[n];if(t){const a=LE(n,t);a&&e.push(a)}}}}return`<w:style w:type="${"character"===t.type?"character":"table"===t.type?"table":"paragraph"}" w:styleId="${PV(t.id)}">${e.join("")}</w:style>`}function NE(t,e,a,n,r,o,i,l){const s=n.map(t=>{const e="header"===t.kind?"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml":"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml";return`<Override PartName="/word/${t.path}" ContentType="${e}"/>`}).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/>${function(t){const e=new Set;let a="";for(const n of t){const t=n.toLowerCase();if(e.has(t))continue;const r=Uv[t];r&&(e.add(t),a+=`<Default Extension="${t}" ContentType="${r}"/>`)}return a}(e)}<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>${i?'<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>':""}${t?'<Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/>':""}${a?'<Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/>':""}${r?'<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"/>':""}${o?'<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"/>':""}${l?'<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"/><Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml"/>':""}${s}</Types>`}const qE={decimal:"decimal",lowerRoman:"lowerRoman",upperRoman:"upperRoman",lowerLetter:"lowerLetter",upperLetter:"upperLetter",symbol:"symbol"},OE={continuous:"continuous",eachSection:"eachSect"};function PE(t,e){if(!e)return null;const a=[];return e.numberFormat&&a.push(`<w:numFmt w:val="${qE[e.numberFormat]}"/>`),void 0!==e.startAt&&a.push(`<w:numStart w:val="${Math.max(1,e.startAt)}"/>`),e.restart&&a.push(`<w:numRestart w:val="${OE[e.restart]}"/>`),a.length>0?`<w:${t}>${a.join("")}</w:${t}>`:null}function WE(t,e){let a="";for(const n of e)a+=`<Relationship Id="${n.rId}" Type="${qV}/hyperlink" Target="${PV(n.href)}" TargetMode="External"/>`;for(const n of t){const t="linked"===n.kind?' TargetMode="External"':"";a+=`<Relationship Id="${n.rId}" Type="${qV}/image" Target="${PV(n.target)}"${t}/>`}return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${NV}">${a}</Relationships>`}function HE(t,e){e(t);for(const a of t.runs)a.textBox&&UE(a.textBox.blocks,e)}function UE(t,e){for(const a of t)switch(a.type){case"paragraph":HE(a,e);break;case"table":for(const t of a.rows)for(const a of t.cells)for(const t of a.blocks)HE(t,e);break;default:pe(a,"block")}}const FE=`xmlns:w="${zV}" xmlns:w14="${OV}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:r="${qV}"`;function BE(t,e,a){const n=Be(t).map((n,r)=>IE(n.blocks,e,t.styles)+function(t,e){var a,n,r,o,i,l,s,d,c;const h=WV(t.width,12240),p=WV(t.height,15840),u=t.margins,f="landscape"===t.orientation?' w:orient="landscape"':"",g=[(null==(a=null==e?void 0:e.header)?void 0:a.first)?`<w:headerReference w:type="first" r:id="${e.header.first.relId}"/>`:"",(null==(n=null==e?void 0:e.header)?void 0:n.even)?`<w:headerReference w:type="even" r:id="${e.header.even.relId}"/>`:"",(null==(r=null==e?void 0:e.header)?void 0:r.default)?`<w:headerReference w:type="default" r:id="${e.header.default.relId}"/>`:"",(null==(o=null==e?void 0:e.footer)?void 0:o.first)?`<w:footerReference w:type="first" r:id="${e.footer.first.relId}"/>`:"",(null==(i=null==e?void 0:e.footer)?void 0:i.even)?`<w:footerReference w:type="even" r:id="${e.footer.even.relId}"/>`:"",(null==(l=null==e?void 0:e.footer)?void 0:l.default)?`<w:footerReference w:type="default" r:id="${e.footer.default.relId}"/>`:""].join(""),m=(null==(s=null==e?void 0:e.header)?void 0:s.first)||(null==(d=null==e?void 0:e.footer)?void 0:d.first)?"<w:titlePg/>":"",v=t.columns;let b="";if(v&&v.count>1){const t=WV(v.space,0),e=v.separator?' w:sep="1"':"";if(!1===v.equalWidth&&(null==(c=v.columns)?void 0:c.length)){const a=v.columns.map(t=>`<w:col w:w="${WV(t.width,0)}" w:space="${WV(t.space,0)}"/>`).join("");b=`<w:cols w:num="${v.count}" w:space="${t}" w:equalWidth="0"${e}>${a}</w:cols>`}else b=`<w:cols w:num="${v.count}" w:space="${t}"${e}/>`}return`<w:sectPr>${g}${m}<w:pgSz w:w="${h}" w:h="${p}"${f}/><w:pgMar w:top="${WV(u.top,1440)}" w:right="${WV(u.right,1440)}" w:bottom="${WV(u.bottom,1440)}" w:left="${WV(u.left,1440)}" w:header="${WV(u.header,720)}" w:footer="${WV(u.footer,720)}" w:gutter="${WV(u.gutter,0)}"/>${b}</w:sectPr>`}(n.pageSettings,a[r])).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document ${FE}><w:body>${n}</w:body></w:document>`}function GE(t,e,a,n){const r="header"===t?"hdr":"ftr";return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:${r} ${FE}>${IE(e,a,n)}</w:${r}>`}function ZE(t){const e=xa("");return e.fieldChar={kind:t},e}function DE(t){const e=xa("");return e.fieldInstruction=t,e}function KE(t,e,a){const n=Aa([{text:`${e} `},{text:String(a)},{text:t?`: ${t}`:""}]);return n.style={styleId:"Caption",align:"center"},n.runs=[n.runs[0],ZE("begin"),DE(" SEQ Figure \\* ARABIC "),ZE("separate"),n.runs[1],ZE("end"),n.runs[2]],n}function jE(t){var e,a;if(!t)return!1;return"caption"===(null==(a=null==(e=t.style)?void 0:e.styleId)?void 0:a.toLowerCase())&&t.runs.some(t=>void 0!==t.fieldInstruction&&new RegExp("\\bSEQ\\s+Figure\\b","i").test(t.fieldInstruction))}function XE(t,e){if(!jE(t))return TT(t);let a=!1,n=!1;const r=t.runs.map(t=>{var r,o;return"separate"===(null==(r=t.fieldChar)?void 0:r.kind)?(a=!0,{...t,fieldChar:{...t.fieldChar}}):"end"===(null==(o=t.fieldChar)?void 0:o.kind)?(a=!1,{...t,fieldChar:{...t.fieldChar}}):a&&""!==t.text?t.text===String(e)?{...t}:(n=!0,{...t,text:String(e)}):{...t}});return n?{...TT(t),runs:r}:TT(t)}function JE(t,e){return t.map(t=>{switch(t.type){case"paragraph":return jE(t)?XE(t,e.next++):TT(t);case"table":return{...t,rows:t.rows.map(t=>({...t,cells:t.cells.map(t=>({...t,blocks:JE(t.blocks,e)}))}))};default:return pe(t,"block")}})}function YE(t){const e={next:1},a=Be(t).map(t=>({...t,blocks:JE(t.blocks,e),header:t.header?VT(t.header):void 0,footer:t.footer?VT(t.footer):void 0}));return{...t,sections:a}}function QE(t,e,a,n){const r=[],o=new Map,i=new Map,l=[],s=new Map;return UE(t,t=>{var e;for(const d of t.runs){const t=null==(e=d.styles)?void 0:e.link;if(t&&!t.startsWith("#")&&!s.has(t)){const e=`rIdLink${l.length+1}`;s.set(t,e),l.push({rId:e,href:t})}if(d.textBox&&!i.has(d.id)&&(i.set(d.id,a.nextTextBoxDocPrId),a.nextTextBoxDocPrId+=1),!d.image)continue;const c=a.nextImageId,h=`rIdImg${c}`,p={rId:h,runId:d.id,cx:Math.round(d.image.width*An),cy:Math.round(d.image.height*An),alt:d.image.alt,crop:d.image.crop,fillMode:d.image.fillMode,rotation:d.image.rotation,flipH:d.image.flipH,flipV:d.image.flipV,floating:d.image.floating,wrapPolygon:d.image.wrapPolygon};if(d.image.linkedSrc){r.push({...p,kind:"linked",target:d.image.linkedSrc}),o.set(d.id,h),a.nextImageId+=1;continue}const u=Ue(n,d.image.src).match(/^data:([^;,]+);base64,(.*)$/);if(!u)continue;const f=Bv(u[1]);if(!f)continue;const g=u[2],m=`media/image${c}.${f}`;r.push({...p,kind:"embedded",target:m,base64:g}),o.set(d.id,h),a.nextImageId+=1}}),{numberingInfo:e.numberingInfo,definitions:e.definitions,images:r,imageMap:o,textBoxDocPrIds:i,hyperlinks:l,hyperlinkMap:s}}async function _E(t){var e,a,n,r,o,i;t=YE(t);const l=new Wp,s=function(t){const e=new Map,a=new Map,n=[];let r=1,o=1;const i=t=>{if(!t.list)return;const i=Math.max(0,t.list.level??0),l=t.list.bulletGlyph??"",s=t.list.instanceId?`instance:${t.list.instanceId}`:`legacy:${t.list.kind}:${i}:${l}`;let d=a.get(s);d||(d={abstractNumId:r++,numId:o++,levels:[]},a.set(s,d),n.push(d)),d.levels.some(t=>t.level===i)||d.levels.push({kind:t.list.kind,level:i,format:t.list.format,startAt:t.list.startAt,levelText:t.list.levelText,suffix:t.list.suffix,alignment:t.list.alignment,legal:t.list.legal,bulletGlyph:t.list.bulletGlyph,bulletFont:t.list.bulletFont}),e.set(t.id,{numId:d.numId,level:i})};for(const l of Be(t))UE(l.blocks,i),l.header&&UE(l.header,i),l.firstPageHeader&&UE(l.firstPageHeader,i),l.evenPageHeader&&UE(l.evenPageHeader,i),l.footer&&UE(l.footer,i),l.firstPageFooter&&UE(l.firstPageFooter,i),l.evenPageFooter&&UE(l.evenPageFooter,i);return{numberingInfo:e,definitions:n}}(t),d={nextImageId:1,nextTextBoxDocPrId:1000001},c=Be(t),h=function(t){var e;const a=null==(e=t.footnotes)?void 0:e.items;if(!a)return[];const n=new Map;let r=1;for(const{run:o}of Gl(t)){const t=o.footnoteReference;if(!t)continue;if(n.has(t.footnoteId))continue;const e=a[t.footnoteId];e&&(n.set(t.footnoteId,{footnoteId:t.footnoteId,docxId:r,footnote:e}),r+=1)}return Array.from(n.values())}(t),p=function(t){const e=new Map;for(const a of t)e.set(a.footnoteId,a.docxId);return e}(h),u=h.length>0,f=function(t){var e;const a=null==(e=t.endnotes)?void 0:e.items;if(!a)return[];const n=new Map;let r=1;for(const{run:o}of _l(t)){const t=o.endnoteReference;if(!t)continue;if(n.has(t.endnoteId))continue;const e=a[t.endnoteId];e&&(n.set(t.endnoteId,{endnoteId:t.endnoteId,docxId:r,endnote:e}),r+=1)}return Array.from(n.values())}(t),g=function(t){const e=new Map;for(const a of t)e.set(a.endnoteId,a.docxId);return e}(f),m=f.length>0,v=QE(c.flatMap(t=>t.blocks),s,d,t);v.footnoteIdMap=p,v.endnoteIdMap=g;const b=function(t){const e=t.bookmarks;if(!e||0===e.order.length)return;const a=new Map,n=new Set;for(const l of e.order){const t=e.items[l];if(!t)continue;const r=t.docxIdHint;void 0!==r&&r>=0&&!n.has(r)&&(a.set(l,r),n.add(r))}let r=0;for(const l of e.order)if(!a.has(l)){for(;n.has(r);)r+=1;a.set(l,r),n.add(r),r+=1}const o=new Map,i=(t,e)=>{const a=o.get(t);a?a.push(e):o.set(t,[e])};for(const l of e.order){const t=e.items[l];if(!t)continue;const n=a.get(l);t.start&&i(t.start.paragraphId,{kind:"start",offset:t.start.offset,seq:t.start.seq??0,wId:n,name:t.name,...void 0!==t.colFirst?{colFirst:t.colFirst}:{},...void 0!==t.colLast?{colLast:t.colLast}:{}}),t.end&&i(t.end.paragraphId,{kind:"end",offset:t.end.offset,seq:t.end.seq??0,wId:n})}return o}(t);v.bookmarkEventsByParagraph=b;const y=function(t){const e=t.comments;if(!e||0===e.order.length)return;const a=new Map,n=new Set;for(const s of e.order){const t=e.items[s];if(!t)continue;const r=t.docxIdHint;void 0!==r&&r>=0&&!n.has(r)&&(a.set(s,r),n.add(r))}let r=0;for(const s of e.order)if(!a.has(s)){for(;n.has(r);)r+=1;a.set(s,r),n.add(r),r+=1}const o=new Map,i=(t,e)=>{const a=o.get(t);a?a.push(e):o.set(t,[e])},l=[];return e.order.forEach((t,n)=>{const r=e.items[t];if(!r)return;const o=a.get(t),s=(1073741824+n).toString(16).toUpperCase();l.push({comment:r,wId:o,paraId:s}),r.start&&i(r.start.paragraphId,{kind:"start",offset:r.start.offset,seq:r.start.seq??0,wId:o}),r.end&&(i(r.end.paragraphId,{kind:"end",offset:r.end.offset,seq:r.end.seq??0,wId:o}),i(r.end.paragraphId,{kind:"reference",offset:r.end.offset,seq:(r.end.seq??0)+.5,wId:o}))}),{eventsByParagraph:o,comments:l}}(t);v.commentEventsByParagraph=null==y?void 0:y.eventsByParagraph;const M=void 0!==y,x=[],w=c.map(()=>({}));let S=1,A=1;c.forEach((e,a)=>{const n=(e,n,r)=>{var o;if(!r||0===r.length)return;const i="header"===e?S:A,l=`${e}${i}.xml`,c=`rId${"header"===e?"Header":"Footer"}${i}`,h=QE(r,s,d,t);h.footnoteIdMap=p,h.endnoteIdMap=g,h.bookmarkEventsByParagraph=b,h.commentEventsByParagraph=null==y?void 0:y.eventsByParagraph,x.push({kind:e,type:n,path:l,relId:c,blocks:r,context:h});const u="header"===e?"header":"footer";((o=w[a])[u]??(o[u]={}))[n]={relId:c},"header"===e?S+=1:A+=1};n("header","first",e.firstPageHeader),n("header","even",e.evenPageHeader),n("header","default",e.header),n("footer","first",e.firstPageFooter),n("footer","even",e.evenPageFooter),n("footer","default",e.footer)});const I=s.definitions.length>0,T=c.some(t=>{var e,a;return((null==(e=t.evenPageHeader)?void 0:e.length)??0)>0||((null==(a=t.evenPageFooter)?void 0:a.length)??0)>0}),C=T||void 0!==(null==(e=t.settings)?void 0:e.defaultTabStop)||void 0!==(null==(a=t.footnotes)?void 0:a.settings)||void 0!==(null==(n=t.endnotes)?void 0:n.settings),k=[...v.images,...x.flatMap(t=>t.context.images)],V=u?function(t,e,a,n,r,o,i){const l=r(e.flatMap(t=>CE(t.footnote.blocks)));l.footnoteIdMap=i;const s=e.map(t=>{const e=CE(t.footnote.blocks).map(t=>"paragraph"===t.type?TE(t,l,o):nE(t,(t,e)=>{var a;return TE(t,l,o,{align:null==(a=e.style)?void 0:a.horizontalAlign})})).join("");return`<w:footnote w:id="${t.docxId}">${e}</w:footnote>`}).join("");return{xml:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:footnotes xmlns:w="${zV}" xmlns:w14="${OV}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:r="${qV}"><w:footnote w:type="separator" w:id="-1"><w:p><w:r><w:separator/></w:r></w:p></w:footnote><w:footnote w:type="continuationSeparator" w:id="0"><w:p><w:r><w:continuationSeparator/></w:r></w:p></w:footnote>${s}</w:footnotes>`,partContext:l}}(0,h,0,0,e=>QE(e,s,d,t),t.styles,p):null;V&&k.push(...V.partContext.images);const E=m?function(t,e,a,n,r,o,i){const l=r(e.flatMap(t=>VE(t.endnote.blocks)));l.endnoteIdMap=i;const s=e.map(t=>{const e=VE(t.endnote.blocks).map(t=>"paragraph"===t.type?TE(t,l,o):nE(t,(t,e)=>{var a;return TE(t,l,o,{align:null==(a=e.style)?void 0:a.horizontalAlign})})).join("");return`<w:endnote w:id="${t.docxId}">${e}</w:endnote>`}).join("");return{xml:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:endnotes xmlns:w="${zV}" xmlns:w14="${OV}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:r="${qV}"><w:endnote w:type="separator" w:id="-1"><w:p><w:r><w:separator/></w:r></w:p></w:endnote><w:endnote w:type="continuationSeparator" w:id="0"><w:p><w:r><w:continuationSeparator/></w:r></w:p></w:endnote>${s}</w:endnotes>`,partContext:l}}(0,f,0,0,e=>QE(e,s,d,t),t.styles,g):null;E&&k.push(...E.partContext.images);const R=k.filter(t=>"embedded"===t.kind).map(t=>{var e;return null==(e=t.target.split(".").pop())?void 0:e.toLowerCase()}).filter(t=>Boolean(t)),L=null!=t.styles&&Object.keys(t.styles).length>0;l.file("[Content_Types].xml",NE(I,R,C,x,u,m,L,M)),l.file("_rels/.rels",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${NV}"><Relationship Id="rId1" Type="${qV}/officeDocument" Target="word/document.xml"/></Relationships>`),l.file("word/document.xml",BE(t,v,w)),L&&l.file("word/styles.xml",function(t){const e=Object.values(t).map(zE).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="${OV}">${e}</w:styles>`}(t.styles)),I&&l.file("word/numbering.xml",function(t){const e=t.map(({abstractNumId:t,levels:e})=>`<w:abstractNum w:abstractNumId="${t}">${e.sort((t,e)=>t.level-e.level).map(({kind:t,level:e,format:a,startAt:n,levelText:r,suffix:o,alignment:i,legal:l,bulletGlyph:s,bulletFont:d})=>{const c="bullet"===t?"bullet":a??"decimal",h=r??("bullet"===t?s??"":`%${e+1}.`),p=n??1,u="bullet"===t?d??"Symbol":void 0,f=u?`<w:rPr><w:rFonts w:ascii="${PV(u)}" w:hAnsi="${PV(u)}" w:hint="default"/></w:rPr>`:"",g=o&&"tab"!==o?`<w:suff w:val="${o}"/>`:"",m=l?"<w:isLgl/>":"";return`<w:lvl w:ilvl="${e}"><w:start w:val="${p}"/><w:numFmt w:val="${c}"/><w:lvlText w:val="${PV(h)}"/><w:lvlJc w:val="${i??"left"}"/>${g}${m}${f}</w:lvl>`}).join("")}</w:abstractNum>`).join(""),a=t.map(({abstractNumId:t,numId:e})=>`<w:num w:numId="${e}"><w:abstractNumId w:val="${t}"/></w:num>`).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:numbering xmlns:w="${zV}">${e}${a}</w:numbering>`}(s.definitions)),(L||I||C||v.images.length>0||v.hyperlinks.length>0||x.length>0||u||m||M)&&l.file("word/_rels/document.xml.rels",function(t,e,a,n,r,o,i,l,s){let d="";l&&(d+=`<Relationship Id="rIdStyles" Type="${qV}/styles" Target="styles.xml"/>`),t&&(d+=`<Relationship Id="rIdNum" Type="${qV}/numbering" Target="numbering.xml"/>`),e&&(d+=`<Relationship Id="rIdSettings" Type="${qV}/settings" Target="settings.xml"/>`);for(const c of n)d+=`<Relationship Id="${c.rId}" Type="${qV}/hyperlink" Target="${PV(c.href)}" TargetMode="External"/>`;for(const c of a){const t="linked"===c.kind?' TargetMode="External"':"";d+=`<Relationship Id="${c.rId}" Type="${qV}/image" Target="${PV(c.target)}"${t}/>`}for(const c of r){const t="header"===c.kind?"header":"footer";d+=`<Relationship Id="${c.relId}" Type="${qV}/${t}" Target="${c.path}"/>`}return o&&(d+=`<Relationship Id="rIdFootnotes" Type="${qV}/footnotes" Target="footnotes.xml"/>`),i&&(d+=`<Relationship Id="rIdEndnotes" Type="${qV}/endnotes" Target="endnotes.xml"/>`),s&&(d+=`<Relationship Id="rIdComments" Type="${qV}/comments" Target="comments.xml"/>`,d+='<Relationship Id="rIdCommentsExtended" Type="http://schemas.microsoft.com/office/2011/relationships/commentsExtended" Target="commentsExtended.xml"/>'),`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${NV}">${d}</Relationships>`}(I,C,v.images,v.hyperlinks,x,u,m,L,M)),C&&l.file("word/settings.xml",function(t,e,a,n){const r=[],o=UV(e);null!==o&&r.push(`<w:defaultTabStop w:val="${o}"/>`);const i=PE("footnotePr",a);i&&r.push(i);const l=PE("endnotePr",n);return l&&r.push(l),t&&r.push("<w:evenAndOddHeaders/>"),`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:settings xmlns:w="${zV}">${r.join("")}</w:settings>`}(T,null==(r=t.settings)?void 0:r.defaultTabStop,null==(o=t.footnotes)?void 0:o.settings,null==(i=t.endnotes)?void 0:i.settings));for(const z of x)l.file(`word/${z.path}`,GE(z.kind,z.blocks,z.context,t.styles)),(z.context.images.length>0||z.context.hyperlinks.length>0)&&l.file(`word/_rels/${z.path}.rels`,WE(z.context.images,z.context.hyperlinks));V&&(l.file("word/footnotes.xml",V.xml),(V.partContext.images.length>0||V.partContext.hyperlinks.length>0)&&l.file("word/_rels/footnotes.xml.rels",WE(V.partContext.images,V.partContext.hyperlinks))),E&&(l.file("word/endnotes.xml",E.xml),(E.partContext.images.length>0||E.partContext.hyperlinks.length>0)&&l.file("word/_rels/endnotes.xml.rels",WE(E.partContext.images,E.partContext.hyperlinks))),y&&(l.file("word/comments.xml",DV(y)),l.file("word/commentsExtended.xml",function(t){const e=t.comments.map(({comment:t,paraId:e})=>`<w15:commentEx w15:paraId="${e}" w15:done="${t.resolved?"1":"0"}"/>`).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w15:commentsEx ${ZV}>${e}</w15:commentsEx>`}(y)));for(const z of k)"embedded"===z.kind&&z.base64&&l.file(`word/${z.target}`,z.base64,{base64:!0});return l.generateAsync({type:"arraybuffer"})}function $E(t){switch(t){case"dashed":return[bM(5),bM(3)];case"dotted":return[bM(1),bM(3)];default:return}}async function tR(t,e,a,n,r,o,i,l){const s=e.rotation;s&&(t.saveGraphicsState(a.pageIndex),t.rotateAbout(a.pageIndex,bM(n+o/2),bM(r+i/2),s)),function(t,e,a,n,r,o,i){var l,s,d,c;const h=nh(null==(l=a.shape)?void 0:l.preset,bM(n),bM(r),bM(o),bM(i)),p=null==(s=a.shape)?void 0:s.fill,u=null==(d=a.shape)?void 0:d.borderColor,f=(null==(c=a.shape)?void 0:c.borderWidthPt)??(u?.75:0);t.drawPath(e,{segments:h,fill:p,stroke:u&&f>0?u:void 0,lineWidth:f})}(t,a.pageIndex,e,n,r,o,i),await async function(t,e,a,n,r,o,i,l){var s;if(0===e.blocks.length)return;const d=function(t){var e,a,n,r;return{left:(null==(e=t.body)?void 0:e.paddingLeft)??0,top:(null==(a=t.body)?void 0:a.paddingTop)??0,right:(null==(n=t.body)?void 0:n.paddingRight)??0,bottom:(null==(r=t.body)?void 0:r.paddingBottom)??0}}(e),c=n+d.left,h=r+d.top,p=Math.max(1,o-d.left-d.right),u=Math.max(1,i-d.top-d.bottom),f=(null==(s=zl({blocks:e.blocks,pageSettings:{width:p,height:u,orientation:"portrait",margins:{top:0,right:0,bottom:0,left:0,header:0,footer:0,gutter:0}},maxPageHeight:u,styles:a.document.styles,pageOffset:a.pageIndex})[0])?void 0:s.blocks)??[];if(0===f.length)return;const g=ia(a.document);t.saveGraphicsState(a.pageIndex),t.clipRect(a.pageIndex,bM(c),bM(h),bM(p),bM(u));let m=h;for(const v of f){switch(v.sourceBlock.type){case"paragraph":v.layout&&await l.drawParagraph(t,a.pageIndex,v.sourceBlock,v.layout.lines,a.document,c,m,a.fontRegistry,g,l);break;case"table":await l.drawTableBlock(t,a.pageIndex,v,a.document,c,m,p,a.fontRegistry,g,l);break;default:pe(v.sourceBlock,"block")}m+=Math.max(0,v.estimatedHeight)}t.restoreGraphicsState(a.pageIndex)}(t,e,a,n,r,o,i,l),s&&t.restoreGraphicsState(a.pageIndex)}async function eR(t){const{writer:e,document:a,fontRegistry:n,pageIndex:r,lines:o,pageSettings:i,contentLeft:l,contentTop:s,contentWidth:d,paragraphTop:c,drawers:h}=t;for(const p of o){const t=new Map(p.slots.map(t=>[t.offset,t]));for(const o of p.fragments){const u=o.textBox;if(!(null==u?void 0:u.floating))continue;const f=t.get(o.startOffset),g=l+((null==f?void 0:f.left)??0),m=c+p.top,v=Bi({object:Wi(u),pageSettings:i,contentLeft:l,contentTop:s,contentWidth:d,paragraphTop:c,lineTop:m,anchorLeft:g});await tR(e,u,{document:a,fontRegistry:n,pageIndex:r},v.x,v.y,v.width,v.height,h)}}}const aR=new WeakMap;function nR(t){const e=/^data:([^;,]+)(;base64)?,(.*)$/i.exec(t);if(!e)return null;const a=e[1].toLowerCase(),n=Boolean(e[2]),r=e[3]??"";if(!n)return{mediaType:a,data:(new TextEncoder).encode(decodeURIComponent(r))};const o="function"==typeof atob?atob(r):Buffer.from(r,"base64").toString("binary");return{mediaType:a,data:Uint8Array.from(o,t=>t.charCodeAt(0))}}async function rR(t,e,a){let n=t;n.startsWith("data:")||(n=await async function(t){if("function"!=typeof fetch)return null;const e=await fetch(t);if(!e.ok)return null;const a=await e.blob(),n=new Uint8Array(await a.arrayBuffer()),r=Array.from(n,t=>String.fromCharCode(t)).join(""),o="function"==typeof btoa?btoa(r):Buffer.from(n).toString("base64");return`data:${a.type||"application/octet-stream"};base64,${o}`}(n)??n);let r=nR(n);if(!r)return null;const o="undefined"!=typeof Image?await async function(t){return"undefined"==typeof Image?null:await new Promise(e=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>e(a),a.onerror=()=>e(null),a.src=t})}(n):null,i=null!=o&&o.naturalWidth>0&&o.naturalHeight>0;if("image/jpeg"!==r.mediaType&&"image/jpg"!==r.mediaType){if(!i)return null;const t=function(t){if("undefined"==typeof document)return null;const e=document.createElement("canvas");e.width=t.naturalWidth,e.height=t.naturalHeight;const a=e.getContext("2d");return a?(a.fillStyle="#ffffff",a.fillRect(0,0,e.width,e.height),a.drawImage(t,0,0),e.toDataURL("image/jpeg",.92)):null}(o);if(r=t?nR(t):null,!r)return null}const l=i?o.naturalWidth:e,s=i?o.naturalHeight:a;return{width:Math.max(1,Math.round(l)),height:Math.max(1,Math.round(s)),data:r.data}}function oR(t,e){const a=new Map(t.slots.map(t=>[t.offset,t])),n=[];for(const r of e.chars){if("\n"===r.char||"\t"===r.char)continue;const t=a.get(r.paragraphOffset);t&&n.push({char:r.char,left:t.left,offset:r.paragraphOffset})}return n}function iR(t,e,a){const n=oR(t,e);if(0===n.length)return null;const r=new Map(t.slots.map(t=>[t.offset,t])),o=n[0],i=n[n.length-1],l=r.get(i.offset+1);return{left:o.left,right:(null==l?void 0:l.left)??i.left+.55*a}}function lR(t,e,a,n,r,o,i,l){const s=iR(a,n,i.fontSize??vM);if(!s)return;const d="underline"===l?o+a.top+a.height-2:"doubleStrike"===l?o+a.top+.5*a.height:o+a.top+.52*a.height,c=r+s.left,h=r+s.right,p="underline"===l?i.underlineColor??i.color??"#000000":i.color??"#000000";if("strike"!==l){if("doubleStrike"===l){const a=1.3;return t.drawLine(e,{x1:bM(c),y1:bM(d-a),x2:bM(h),y2:bM(d-a),stroke:p,lineWidth:bM(1)}),void t.drawLine(e,{x1:bM(c),y1:bM(d+a),x2:bM(h),y2:bM(d+a),stroke:p,lineWidth:bM(1)})}!function(t,e,a,n,r,o,i){const l=dh(i),s=(r,i)=>{t.drawLine(e,{x1:bM(a),y1:bM(r),x2:bM(n),y2:bM(r),stroke:o,lineWidth:bM(l),dashArray:i})};if(lh(i))return s(r-1.5),void s(r+1.5);if(sh(i))return void function(t,e,a,n,r,o,i){const l=4,s=1.5;let d=a,c=r;for(let h=a;h<=n;h+=1){const n=r+Math.sin((h-a)/l*Math.PI)*s;t.drawLine(e,{x1:bM(d),y1:bM(c),x2:bM(h),y2:bM(n),stroke:o,lineWidth:bM(i)}),d=h,c=n}}(t,e,a,n,r,o,l);s(r,ch(i))}(t,e,c,h,d,p,i.underlineStyle)}else t.drawLine(e,{x1:bM(c),y1:bM(d),x2:bM(h),y2:bM(d),stroke:p,lineWidth:bM(1)})}function sR(t,e,a,n){var r;const o=He(t.style,n.styles).tabs??[];if(0===o.length)return;const i=a-((null==(r=e.slots[0])?void 0:r.left)??0),l=o.filter(t=>"clear"!==t.type).map(t=>({...t,positionPx:t.position*xn})).filter(t=>t.positionPx>i+.01).sort((t,e)=>t.positionPx-e.positionPx)[0];return(null==l?void 0:l.leader)&&"none"!==l.leader?l.leader:void 0}async function dR(t,e,a,n,r,o,i,l,s,d){var c;if(r.image){const a=n.slots.find(t=>t.offset===r.startOffset)??n.slots.find(t=>t.offset>=r.startOffset);if(!a)return;const s=await async function(t,e,a){const n=Ue(e,a.src);if(!n)return null;let r=aR.get(t);r||(r=new Map,aR.set(t,r));const o=r.get(n);if(o)return o;const i=rR(n,a.width,a.height).then(e=>e?t.registerImageResource({width:e.width,height:e.height,data:e.data,filter:"DCTDecode"}):null);return r.set(n,i),i}(t,o,r.image);if(!s)return;return void t.drawImage(e,{resourceName:s,x:bM(i+a.left),y:bM(l+n.top+n.height-r.image.height),width:bM(r.image.width),height:bM(r.image.height),rotation:r.image.rotation})}if(r.textBox)return void(await async function(t,e,a,n,r,o,i,l,s){const d=n.textBox;if(!d||d.floating)return;const c=a.slots.find(t=>t.offset===n.startOffset)??a.slots.find(t=>t.offset>=n.startOffset);c&&await tR(t,d,{document:r,fontRegistry:l,pageIndex:e},o+c.left,i+a.top+a.height-d.height,d.width,d.height,s)}(t,e,n,r,o,i,l,s,d));const h=We(r.styles,null==(c=a.style)?void 0:c.styleId,o.styles);if(h.hidden)return;const p=s.resolveFontFace({fontFamily:h.fontFamily,bold:h.bold,italic:h.italic}),u=h.smallCaps?.8*yM(h):yM(h),f=(h.baselineShift??0)*xn,g=l+n.top+.8*n.height-f,m=oR(n,r),v=m.map(t=>h.allCaps?t.char.toUpperCase():t.char).join("");if(!m[0]||0===v.length)return;!function(t,e,a,n,r,o,i){if(!i.shading)return;const l=iR(a,n,i.fontSize??vM);l&&t.drawRect(e,{x:bM(r+l.left),y:bM(o+a.top+2),width:bM(Math.max(0,l.right-l.left)),height:bM(Math.max(2,a.height-4)),fill:i.shading})}(t,e,n,r,i,l,h),function(t,e,a,n,r,o,i){if(!i.highlight)return;const l=iR(a,n,i.fontSize??vM);l&&t.drawRect(e,{x:bM(r+l.left),y:bM(o+a.top+2),width:bM(Math.max(0,l.right-l.left)),height:bM(Math.max(2,a.height-4)),fill:i.highlight})}(t,e,n,r,i,l,h),function(t,e,a,n,r,o,i,l,s){const d=new Map(n.slots.map(t=>[t.offset,t]));for(const c of r.chars){if("\t"!==c.char)continue;const r=d.get(c.paragraphOffset),h=d.get(c.paragraphOffset+1);if(!r||!h)continue;const p=sR(a,n,r.left,o);if(!p)continue;const u="underscore"===p?l+2:l;t.drawLine(e,{x1:bM(i+r.left),y1:bM(u),x2:bM(i+h.left),y2:bM(u),stroke:s,lineWidth:bM("heavy"===p?1.5:1),dashArray:"dot"===p||"middleDot"===p?[1,3]:"hyphen"===p?[5,3]:void 0})}}(t,e,a,n,r,o,i,g,h.color??"#000000");if("justify"===(He(a.style,o.styles).align??"left")){const a=function(t){const e=[];let a=[];for(const n of t)" "!==n.char?a.push(n):a.length>0&&(e.push(a),a=[]);return a.length>0&&e.push(a),e}(m);for(const n of a){const a=n.map(t=>h.allCaps?t.char.toUpperCase():t.char).join("");0!==a.length&&t.drawText(e,{x:bM(i+n[0].left),y:bM(g),text:a,fontSize:u,color:h.color??"#000000",bold:h.bold,italic:h.italic,fontResourceName:p.writerResourceName,characterSpacing:h.characterSpacing??0,horizontalScale:h.characterScale??100})}}else{const a=function(t){const e=[];let a=[];for(const n of t){const t=a[a.length-1];t&&n.offset>t.offset+1&&(e.push(a),a=[]),a.push(n)}return a.length>0&&e.push(a),e}(m);for(const n of a){const a=n.map(t=>h.allCaps?t.char.toUpperCase():t.char).join("");0!==a.length&&t.drawText(e,{x:bM(i+n[0].left),y:bM(g),text:a,fontSize:u,color:h.color??"#000000",bold:h.bold,italic:h.italic,fontResourceName:p.writerResourceName,characterSpacing:h.characterSpacing??0,horizontalScale:h.characterScale??100})}}h.underline&&lR(t,e,n,r,i,l,h,"underline"),h.strike&&lR(t,e,n,r,i,l,h,"strike"),h.doubleStrike&&lR(t,e,n,r,i,l,h,"doubleStrike")}function cR(t,e,a,n,r,o,i,l,s){var d;if(0!==n.index)return;const c=la(a,s);if(!c)return;const h=n.slots[0];if(!h)return;const p=We(void 0,null==(d=a.style)?void 0:d.styleId,r.styles),u=l.resolveFontFace({fontFamily:p.fontFamily,bold:p.bold,italic:p.italic}),f=oi(a,r.styles),g=yM(p),m=c.length*g*.62*xn,v=ii(a,r.styles,h.left,m);t.drawText(e,{x:bM(o+Math.max(0,v||f)),y:bM(i+n.top+.8*n.height),text:c,fontSize:g,color:p.color??"#000000",bold:p.bold,italic:p.italic,fontResourceName:u.writerResourceName})}function hR(t,e,a,n,r,o,i){const l=[[a.borderTop,"top"],[a.borderRight,"right"],[a.borderBottom,"bottom"],[a.borderLeft,"left"]],s=l.some(([t])=>t&&"none"!==t.type&&t.width>0);if(!a.shading&&!s)return;let d=0;for(const g of n)d=Math.max(d,g.top+g.height);if(d<=0)return;const c=Cn(a),h=c.top+d+c.bottom,p=r+(a.indentLeft??0),u=r+i-(a.indentRight??0),f=o+h;a.shading&&t.drawRect(e,{x:bM(p),y:bM(o),width:bM(Math.max(0,u-p)),height:bM(h),fill:a.shading});for(const[g,m]of l){if(!g||"none"===g.type||g.width<=0)continue;const[a,n,r,i]="top"===m?[p,o,u,o]:"bottom"===m?[p,f,u,f]:"left"===m?[p,o,p,f]:[u,o,u,f];t.drawLine(e,{x1:bM(a),y1:bM(n),x2:bM(r),y2:bM(i),stroke:g.color,lineWidth:g.width,dashArray:$E(g.type)})}}async function pR(t,e,a,n,r,o,i,l,s,d){for(const c of n){cR(t,e,a,c,r,o,i,l,s);for(const n of c.fragments)await dR(t,e,a,c,n,r,o,i,l,d)}}function uR(t,e,a,n,r,o,i){"none"===a.type||a.width<=0||t.drawLine(e,{x1:bM(n),y1:bM(r),x2:bM(o),y2:bM(i),stroke:a.color,lineWidth:bM(a.width),dashArray:$E(a.type)})}function fR(t,e,a,n,r){const o=n+a.left,i=r+a.top,l=o+a.width,s=i+a.height;uR(t,e,a.borders.top,o,i,l,i),uR(t,e,a.borders.right,l,i,l,s),uR(t,e,a.borders.bottom,o,s,l,s),uR(t,e,a.borders.left,o,i,o,s)}async function gR(t,e,a,n,r,o,i,l,s,d){if("table"!==a.sourceBlock.type)return;const c=a.sourceBlock,h=a.tableSegment?dn(c,a.tableSegment):c;if(0===h.rows.length)return;const p=Is({table:h,state:{document:n},pageIndex:0,originX:0,originY:0,contentWidth:i,estimatedHeight:a.estimatedHeight});for(const u of p.cells)u.shading&&t.drawRect(e,{x:bM(r+u.left),y:bM(o+u.top),width:bM(u.width),height:bM(u.height),fill:u.shading});for(const u of p.cells)fR(t,e,u,r,o);for(const u of p.cells)for(const a of u.paragraphs)await pR(t,e,a.paragraph,a.lines,n,r+a.originX,o+a.originY,l,s,d)}const mR={drawParagraph:pR,drawTableBlock:gR};async function vR(t,e,a,n,r,o,i,l,s,d){if(!a||0===a.length)return;const c=o;let h=o;for(const p of a){switch(p.sourceBlock.type){case"paragraph":{if(!p.layout)break;const a=He(p.sourceBlock.style,n.styles),u=h+(0===p.layout.startOffset&&h>o?a.spacingBefore??0:0),f=u+Cn(a).top;hR(t,e,a,p.layout.lines,r,u,i),await pR(t,e,p.sourceBlock,p.layout.lines,n,r,f,l,s,mR),d&&await eR({writer:t,document:n,fontRegistry:l,pageIndex:e,lines:p.layout.lines,pageSettings:d,contentLeft:r,contentTop:c,contentWidth:i,paragraphTop:u,drawers:mR});break}case"table":await gR(t,e,p,n,r,h,i,l,s,mR);break;default:pe(p.sourceBlock,"block")}h+=Math.max(0,p.estimatedHeight)}}function bR(t,e,a,n){t.drawRect(e,{x:0,y:0,width:a,height:n,fill:"#ffffff"})}const yR=[{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 MR(t,e,a){return`${t.toLowerCase()}:${e?"bold":"regular"}${a?"italic":""}`}function xR(t){return t.replace(/[^A-Za-z0-9_]/g,"")}class wR{constructor(){a(this,"faces",new Map),a(this,"fallbackFamily","Helvetica");for(const t of yR)this.registerFontFace(t)}registerFontFace(t){this.faces.set(MR(t.family,t.bold,t.italic),t)}resolveFontFace(t){const e=ro(t.fontFamily),a=Boolean(t.bold),n=Boolean(t.italic);return this.faces.get(MR(e,a,n))??this.faces.get(MR(this.fallbackFamily,a,n))??this.faces.get(MR(this.fallbackFamily,!1,!1))}getPdfFontResources(){const t=new Map;for(const e of this.faces.values())t.set(e.pdfResource.resourceName,e.pdfResource);return Array.from(t.values())}async loadBundledUnicodeFaces(t={}){const e=t.families?new Set(Array.from(t.families).map(ro).map(t=>t.toLowerCase())):null,a=await this.registerOfficeCompatibleFaces(e);if(!e||e.has("roboto")||Array.from(e).some(t=>"helvetica"!==t&&!a.has(t)))for(const[n,r]of Object.entries(ao)){const t=await uo(r);if(!t)continue;const e="bold"===n||"bolditalic"===n,a="italic"===n||"bolditalic"===n,o=`Roboto${n[0].toUpperCase()}${n.slice(1)}`;this.registerFontFace({key:`roboto:${n}`,family:"Roboto",bold:e,italic:a,writerResourceName:o,pdfResource:{kind:"unicode",resourceName:o,family:"Roboto",fontData:t}}),this.fallbackFamily="Roboto"}}async registerOfficeCompatibleFaces(t){const e=new Set;for(const a of no){const n=[a.family,...a.aliases].map(t=>t.toLowerCase());if(!(!t||n.some(e=>t.has(e))))continue;for(const t of n)e.add(t);const r=[];for(const[t,e]of Object.entries(a.files)){const n=await uo(e);if(!n)continue;const o="bold"===t||"bolditalic"===t,i="italic"===t||"bolditalic"===t,l=`${xR(a.family)}${t[0].toUpperCase()}${t.slice(1)}`,s={key:`${a.family.toLowerCase()}:${t}`,family:a.family,bold:o,italic:i,writerResourceName:l,pdfResource:{kind:"unicode",resourceName:l,family:a.family,fontData:n}};this.registerFontFace(s),r.push(s)}for(const t of a.aliases)for(const e of r)this.registerFontFace({...e,key:`${t.toLowerCase()}:${e.key.split(":")[1]}`,family:t})}return e}}class SR{constructor(t){this.font=t}layout(t){const e=[],a=[];let n=0;for(const r of t){const t=r.codePointAt(0)??65533,o=this.font.glyphForCodePoint(t),i=this.font.advanceWidthForGlyph(o);e.push({id:o,codePoints:0===o?[65533]:[t],advanceWidth:i}),a.push({xAdvance:i}),n+=i}return{glyphs:e,positions:a,advanceWidth:n}}}function AR(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function IR(t,e){return AR(t).getUint16(e)}function TR(t,e,a){AR(t).setUint16(e,a,!1)}function CR(t,e,a){AR(t).setUint32(e,a,!1)}function kR(t){return t+3&-4}function VR(t){const e=t.reduce((t,e)=>t+kR(e.byteLength),0),a=new Uint8Array(e);let n=0;for(const r of t)a.set(r,n),n+=kR(r.byteLength);return a}function ER(t,e){const a=[],n=AR(t);if(0===e)for(let r=0;r+1<t.byteLength;r+=2)a.push(2*n.getUint16(r));else for(let r=0;r+3<t.byteLength;r+=4)a.push(n.getUint32(r));return a}function RR(t,e){const a=t[e],n=t[e+1];return void 0===a||void 0===n?null:{start:a,end:n}}function LR(t,e){if(t.byteLength<10||function(t,e){return AR(t).getInt16(e)}(t,0)>=0)return;let a=10,n=0;do{if(a+4>t.byteLength)return;n=IR(t,a),e(IR(t,a+2)),a+=4,a+=1&n?4:2,8&n?a+=2:64&n?a+=4:128&n&&(a+=8)}while(32&n)}function zR(t){const e=new Uint8Array(4*t.length);return t.forEach((t,a)=>CR(e,4*a,t)),e}function NR(t,e){const a=new Uint8Array(4*(e+1));for(let n=0;n<=e;n+=1)TR(a,4*n,t.advanceWidthForGlyph(n)),TR(a,4*n+2,0);return a}class qR{createSubset(t,e){const a=new Map,n=[];for(const c of e)n.push(c.id),a.has(c.id)||a.set(c.id,c.codePoints);const r=function(t,e){const a=t.getRawTableData("glyf"),n=t.getRawTableData("loca"),r=t.getRawTableData("head");if(!a||!n||!r)return Array.from(new Set([0,...e])).sort((t,e)=>t-e);const o=ER(n,IR(r,50)),i=new Set([0,...e]),l=Array.from(i);for(;l.length>0;){const t=RR(o,l.pop());!t||t.end<=t.start||t.end>a.byteLength||LR(a.slice(t.start,t.end),t=>{i.has(t)||(i.add(t),l.push(t))})}return Array.from(i).sort((t,e)=>t-e)}(t,n),o=function(t,e){const a=t.getRawTableData("glyf"),n=t.getRawTableData("loca"),r=t.getRawTableData("head"),o=t.getRawTableData("hhea"),i=t.getRawTableData("maxp"),l=t.getRawTableData("cmap");if(!(a&&n&&r&&o&&i&&l))throw new Error("Missing required TrueType tables for subsetting");const s=Math.max(0,...e),d=new Set(e),c=ER(n,IR(r,50)),h=[],p=[];let u=0;for(let b=0;b<=s;b+=1){h.push(u);const t=RR(c,b);if(d.has(b)&&t&&t.end>t.start){const e=a.slice(t.start,t.end);p.push(e),u+=kR(e.byteLength)}}h.push(u);const f=r.slice();CR(f,8,0),TR(f,50,1);const g=o.slice();TR(g,34,s+1);const m=i.slice();TR(m,4,s+1);const v={cmap:l,head:f,hhea:g,hmtx:NR(t,s),loca:zR(h),maxp:m,glyf:VR(p)};for(const b of["OS/2","name","post"]){const e=t.getRawTableData(b);e&&(v[b]=e)}return v}(t,r),i=zr(65536,new Map(Object.entries(o).map(([t,e])=>[t.charCodeAt(0)<<24|t.charCodeAt(1)<<16|t.charCodeAt(2)<<8|t.charCodeAt(3),e]))).ttf,l=Math.max(0,...r),s=[],d=[];for(let c=0;c<=l;c+=1)s[c]=t.advanceWidthForGlyph(c)/t.unitsPerEm*1e3,d[c]=a.get(c)??[0];return{fontFile:i,widths:s,unicode:d,encodeGlyph:t=>t}}}const OR=[{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 PR(t){return Number.isFinite(t)?Number(t.toFixed(3)).toString():"0"}function WR(t){return(new TextEncoder).encode(t).byteLength}function HR(t){return Array.from(t).map(t=>t.toString(16).padStart(2,"0").toUpperCase()).join("")}function UR(t){return Math.max(0,t).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function FR(t,e,a){const[n,r,o]=function(t,e){if(!t)return e;const a=t.trim().replace(/^#/,"");return/^[0-9a-fA-F]{6}$/.test(a)?[Number.parseInt(a.slice(0,2),16)/255,Number.parseInt(a.slice(2,4),16)/255,Number.parseInt(a.slice(4,6),16)/255]:e}(t,a);return`${PR(n)} ${PR(r)} ${PR(o)} ${e}`}function BR(t,e){return(t&&t.trim().length>0?t:e).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}const GR=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 ZR(t){return Array.from(t).map(t=>function(t){const e=t.codePointAt(0)??63;return e>=32&&e<=126||e>=160&&e<=255?e:GR.get(e)??63}(t).toString(16).padStart(2,"0").toUpperCase()).join("")}function DR(t){const e=[];for(let a of t)a>65535?(a-=65536,e.push(a>>>10&1023|55296),e.push(1023&a|56320)):e.push(a);return e.map(UR).join("")}function KR(t){return UR(t)}function jR(t){return`% OasisText ${DR(Array.from(t).map(t=>t.codePointAt(0)??65533))}`}class XR{constructor(t=OR){a(this,"pages",[]),a(this,"fontResources",new Map),a(this,"unicodeFontStates",new Map),a(this,"usedFontResourceNames",new Set),a(this,"imageResources",new Map);for(const e of t)this.registerFontResource(e)}registerFontResource(t){if(this.fontResources.set(t.resourceName,t),"unicode"===t.kind&&!this.unicodeFontStates.has(t.resourceName)){const a={program:e=function(t){const e=eo.decodeSync(t);return To.parse(e)}(t.fontData),layouter:new SR(e),subsetter:new qR},n=1e3/a.program.unitsPerEm,r={id:0,codePoints:[0],advanceWidth:a.program.advanceWidthForGlyph(0)};this.unicodeFontStates.set(t.resourceName,{resource:t,font:a,usedGlyphs:new Map([[0,r]]),scale:n,layoutCache:new Map})}var e}addPage(t){return this.pages.push({width:Math.max(1,t.width),height:Math.max(1,t.height),commands:[],imageResourceNames:new Set}),this.pages.length-1}getPageCount(){return this.pages.length}drawRect(t,e){const a=this.pages[t];if(!a||e.width<=0||e.height<=0)return;const n=["q"];e.fill&&n.push(FR(e.fill,"rg",[1,1,1])),e.stroke&&(n.push(FR(e.stroke,"RG",[0,0,0])),n.push(`${PR(e.lineWidth??1)} w`)),n.push([PR(e.x),PR(a.height-e.y-e.height),PR(e.width),PR(e.height),"re"].join(" ")),e.fill&&e.stroke?n.push("B"):e.fill?n.push("f"):e.stroke&&n.push("S"),n.push("Q"),a.commands.push(n.join("\n"))}drawLine(t,e){const a=this.pages[t];if(!a)return;const n=e.dashArray&&e.dashArray.length>0?`[${e.dashArray.map(t=>PR(t)).join(" ")}] 0 d`:null,r=["q",FR(e.stroke,"RG",[0,0,0])];n&&r.push(n),r.push(`${PR(e.lineWidth??1)} w`,`${PR(e.x1)} ${PR(a.height-e.y1)} m`,`${PR(e.x2)} ${PR(a.height-e.y2)} l`,"S","Q"),a.commands.push(r.join("\n"))}drawPath(t,e){const a=this.pages[t];if(!a||0===e.segments.length)return;if(!e.fill&&!e.stroke)return;const n=t=>a.height-t,r=["q"];e.fill&&r.push(FR(e.fill,"rg",[1,1,1])),e.stroke&&(r.push(FR(e.stroke,"RG",[0,0,0])),r.push(`${PR(e.lineWidth??1)} w`));for(const o of e.segments)switch(o.type){case"move":r.push(`${PR(o.x)} ${PR(n(o.y))} m`);break;case"line":r.push(`${PR(o.x)} ${PR(n(o.y))} l`);break;case"cubic":r.push(`${PR(o.x1)} ${PR(n(o.y1))} ${PR(o.x2)} ${PR(n(o.y2))} ${PR(o.x)} ${PR(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"),a.commands.push(r.join("\n"))}saveGraphicsState(t){const e=this.pages[t];e&&e.commands.push("q")}restoreGraphicsState(t){const e=this.pages[t];e&&e.commands.push("Q")}rotateAbout(t,e,a,n){const r=this.pages[t];if(!r||!n)return;const o=r.height-a,i=-n*Math.PI/180,l=Math.cos(i),s=Math.sin(i),d=e-e*l+o*s,c=o-e*s-o*l;r.commands.push(`${PR(l)} ${PR(s)} ${PR(-s)} ${PR(l)} ${PR(d)} ${PR(c)} cm`)}clipRect(t,e,a,n,r){const o=this.pages[t];!o||n<=0||r<=0||o.commands.push(`${PR(e)} ${PR(o.height-a-r)} ${PR(n)} ${PR(r)} re`,"W","n")}drawText(t,e){const a=this.pages[t];if(!a||0===e.text.length)return;const n=function(t){return t.fontResourceName?t.fontResourceName:t.bold&&t.italic?"F4":t.bold?"F2":t.italic?"F3":"F1"}(e);this.usedFontResourceNames.add(n);const r=this.unicodeFontStates.get(n);r?this.drawUnicodeText(a,r,e):a.commands.push([jR(e.text),"BT",FR(e.color,"rg",[0,0,0]),`/${n} ${PR(e.fontSize??12)} Tf`,...e.horizontalScale&&e.horizontalScale>0&&100!==e.horizontalScale?[`${PR(e.horizontalScale)} Tz`]:[],...e.characterSpacing&&0!==e.characterSpacing?[`${PR(e.characterSpacing)} Tc`]:[],`${PR(e.x)} ${PR(a.height-e.y)} Td`,`<${ZR(e.text)}> Tj`,"ET"].join("\n"))}registerImageResource(t){const e=t.resourceName??`Im${this.imageResources.size+1}`;return this.imageResources.has(e)||this.imageResources.set(e,{resourceName:e,width:Math.max(1,Math.round(t.width)),height:Math.max(1,Math.round(t.height)),data:t.data,filter:t.filter}),e}drawImage(t,e){const a=this.pages[t];if(!a||e.width<=0||e.height<=0||!this.imageResources.has(e.resourceName))return;a.imageResourceNames.add(e.resourceName);const n=a.height-e.y-e.height,r=Number.isFinite(e.rotation)?e.rotation??0:0;if(0===r)return void a.commands.push(["q",[PR(e.width),"0","0",PR(e.height),PR(e.x),PR(n),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"));const o=-r*Math.PI/180,i=Math.cos(o),l=Math.sin(o),s=e.width*i,d=e.width*l,c=-e.height*l,h=e.height*i,p=e.x+e.width/2-.5*s-.5*c,u=n+e.height/2-.5*d-.5*h;a.commands.push(["q",[PR(s),PR(d),PR(c),PR(h),PR(p),PR(u),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}layoutUnicodeText(t,e){const a=t.layoutCache.get(e);if(a)return a;const n=t.font.layouter.layout(e);return t.layoutCache.set(e,n),n}encodeUnicodeGlyphRun(t,e){return e.glyphs.map((a,n)=>{t.usedGlyphs.has(a.id)||t.usedGlyphs.set(a.id,a);const r=e.positions[n],o=a.advanceWidth*t.scale,i=((null==r?void 0:r.xAdvance)??a.advanceWidth)*t.scale;return{glyphId:a.id,nominalWidth:o,desiredAdvance:i}})}drawUnicodeText(t,e,a){const n=this.layoutUnicodeText(e,a.text),r=this.encodeUnicodeGlyphRun(e,n);if(0===r.length)return;const o=r.some(t=>Math.abs(t.nominalWidth-t.desiredAdvance)>.01)?`[${r.map(t=>{const e=t.nominalWidth-t.desiredAdvance;return 0===e?`<${KR(t.glyphId)}>`:`<${KR(t.glyphId)}> ${PR(e)}`}).join(" ")}] TJ`:`<${r.map(t=>KR(t.glyphId)).join("")}> Tj`;t.commands.push([jR(a.text),"BT",FR(a.color,"rg",[0,0,0]),`/${e.resource.resourceName} ${PR(a.fontSize??12)} Tf`,...a.horizontalScale&&a.horizontalScale>0&&100!==a.horizontalScale?[`${PR(a.horizontalScale)} Tz`]:[],...a.characterSpacing&&0!==a.characterSpacing?[`${PR(a.characterSpacing)} Tc`]:[],`${PR(a.x)} ${PR(t.height-a.y)} Td`,o,"ET"].join("\n"))}toArrayBuffer(){const t=this.toUint8Array();return Uint8Array.from(t).buffer}toBlob(){return new Blob([this.toArrayBuffer()],{type:"application/pdf"})}toUint8Array(){0===this.pages.length&&this.addPage({width:612,height:792});const t=[],e=e=>{const a=t.length+1;return t.push({id:a,body:e}),a},a=e(""),n=e(""),r=Array.from(this.fontResources.values()).filter(t=>"base14"===t.kind||this.usedFontResourceNames.has(t.resourceName)),o=r.map(t=>{if("unicode"===t.kind){const a=this.unicodeFontStates.get(t.resourceName);if(a)return this.addUnicodeFontObjects(a,e)}return e(function(t){switch(t.kind){case"base14":return`<< /Type /Font /Subtype /Type1 /BaseFont /${t.baseFont} /Encoding /WinAnsiEncoding >>`;case"unicode":return"<< /Type /Font /Subtype /Type0 /BaseFont /OasisPending /Encoding /Identity-H >>"}}(t))}),i=r.map((t,e)=>`/${t.resourceName} ${o[e]} 0 R`).join(" "),l=new Map;for(const p of this.imageResources.values())l.set(p.resourceName,this.addImageObject(p,e));const s=[];for(const p of this.pages){const t=`${p.commands.join("\n")}\n`,a=e(`<< /Length ${WR(t)} >>\nstream\n${t}endstream`),r=Array.from(p.imageResourceNames).map(t=>{const e=l.get(t);return e?`/${t} ${e} 0 R`:""}).filter(Boolean).join(" "),o=r?` /XObject << ${r} >>`:"",d=e(["<< /Type /Page",`/Parent ${n} 0 R`,`/MediaBox [0 0 ${PR(p.width)} ${PR(p.height)}]`,`/Resources << /Font << ${i} >>${o} >>`,`/Contents ${a} 0 R`,">>"].join("\n"));s.push(d)}t[a-1].body=`<< /Type /Catalog /Pages ${n} 0 R >>`,t[n-1].body=["<< /Type /Pages",`/Kids [${s.map(t=>`${t} 0 R`).join(" ")}]`,`/Count ${s.length}`,">>"].join("\n");let d="%PDF-1.4\n% Oasis PDF\n";const c=[0];for(const p of t)c[p.id]=WR(d),d+=`${p.id} 0 obj\n${p.body}\nendobj\n`;const h=WR(d);d+=`xref\n0 ${t.length+1}\n`,d+="0000000000 65535 f \n";for(const p of t)d+=`${String(c[p.id]??0).padStart(10,"0")} 00000 n \n`;return d+=["trailer",`<< /Size ${t.length+1} /Root ${a} 0 R >>`,"startxref",String(h),"%%EOF",""].join("\n"),(new TextEncoder).encode(d)}addImageObject(t,e){return e(function(t,e){const a=`${HR(t)}>`;return[`<< /Length ${WR(a)}`," /Filter [/ASCIIHexDecode /DCTDecode]",` ${e.join(" ")}`," >>","stream",a,"endstream"].join("\n")}(t.data,["/Type /XObject","/Subtype /Image",`/Width ${t.width}`,`/Height ${t.height}`,"/ColorSpace /DeviceRGB","/BitsPerComponent 8"]))}addUnicodeFontObjects(t,e){const a=t.font.subsetter.createSubset(t.font.program,t.usedGlyphs.values()),n=e(function(t,e=""){const a=`${HR(t)}>`,n=e?` /${e.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${WR(a)} /Filter /ASCIIHexDecode${n} >>\nstream\n${a}\nendstream`}(a.fontFile)),r=t.font.program.metadata,o=r.familyClass>>8||0;let i=4;r.isFixedPitch&&(i|=1),o>=1&&o<=7&&(i|=2),10===o&&(i|=8),r.macStyleItalic&&(i|=64);const l=`${BR(`${t.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${BR(r.postscriptName,t.resource.family)}`,s=r.bbox,d=e(["<< /Type /FontDescriptor",`/FontName /${l}`,`/Flags ${i}`,`/FontBBox [${[s.minX*t.scale,s.minY*t.scale,s.maxX*t.scale,s.maxY*t.scale].map(PR).join(" ")}]`,`/ItalicAngle ${PR(r.italicAngle)}`,`/Ascent ${PR(r.ascent*t.scale)}`,`/Descent ${PR(r.descent*t.scale)}`,`/CapHeight ${PR(r.capHeight*t.scale)}`,`/XHeight ${PR(r.xHeight*t.scale)}`,"/StemV 0",`/FontFile2 ${n} 0 R`,">>"].join("\n")),c=e(["<< /Type /Font","/Subtype /CIDFontType2",`/BaseFont /${l}`,"/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>",`/FontDescriptor ${d} 0 R`,`/W [0 [${a.widths.map(t=>PR(t??0)).join(" ")}]]`,"/CIDToGIDMap /Identity",">>"].filter(Boolean).join("\n")),h=e(function(t,e=""){const a=e?` /${e.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${WR(t)}${a} >>\nstream\n${t}endstream`}(function(t){const e=t.map(t=>`<${DR(t)}>`).filter(t=>"<>"!==t);0===e.length&&e.push("<0000>");const a=[];for(let n=0;n<e.length;n+=256){const t=Math.min(n+256,e.length);a.push(`<${UR(n)}> <${UR(t-1)}> [${e.slice(n,t).join(" ")}]`)}return["/CIDInit /ProcSet findresource begin","12 dict begin","begincmap","/CIDSystemInfo <<"," /Registry (Adobe)"," /Ordering (UCS)"," /Supplement 0",">> def","/CMapName /Adobe-Identity-UCS def","/CMapType 2 def","1 begincodespacerange","<0000><ffff>","endcodespacerange",`${a.length} beginbfrange`,a.join("\n"),"endbfrange","endcmap","CMapName currentdict /CMap defineresource pop","end","end",""].join("\n")}(a.unicode)));return e(["<< /Type /Font","/Subtype /Type0",`/BaseFont /${l}`,"/Encoding /Identity-H",`/DescendantFonts [${c} 0 R]`,`/ToUnicode ${h} 0 R`,">>"].join("\n"))}}async function JR(t){t=YE(t);const e=new wR;await e.loadBundledUnicodeFaces({families:Ac(t)});const a=new XR(e.getPdfFontResources()),n=is(t),r=function(t){return ia(t)}(t);for(const o of n.pages){const n=Math.max(1,bM(o.pageSettings.width)),i=Math.max(1,bM(o.pageSettings.height)),l=a.addPage({width:n,height:i});bR(a,l,n,i);const s=o.pageSettings.margins.left+o.pageSettings.margins.gutter,d=xe(o.pageSettings);await vR(a,l,o.headerBlocks,t,s,o.headerTop??Ae(o.pageSettings),d,e,r,o.pageSettings);const c=o.bodyTop??Ie(o.pageSettings);if(o.blocks.some(t=>void 0!==t.columnIndex)){const n=we(o.pageSettings),i=new Map;for(const t of o.blocks){const e=t.columnIndex??0,a=i.get(e)??[];a.push(t),i.set(e,a)}for(const[s,d]of i){const i=n[s]??n[0];await vR(a,l,d,t,i.left,c,i.width,e,r,o.pageSettings)}}else await vR(a,l,o.blocks,t,s,c,d,e,r,o.pageSettings);await vR(a,l,o.footerBlocks,t,s,o.footerTop??o.bodyBottom??o.pageSettings.height,d,e,r,o.pageSettings),o.footnoteBlocks&&o.footnoteBlocks.length>0&&void 0!==o.footnoteTop&&(void 0!==o.footnoteSeparatorTop&&a.drawLine(l,{x1:bM(s),y1:bM(o.footnoteSeparatorTop+.5),x2:bM(s+Math.min(180,.35*d)),y2:bM(o.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:bM(1)}),await YR(a,l,o.footnoteBlocks,o.footnoteReferenceIds??[],t,s,o.footnoteTop,d,e,r))}if(0===a.getPageCount()){const t=a.addPage({width:612,height:792});bR(a,t,612,792)}return a.toArrayBuffer()}async function YR(t,e,a,n,r,o,i,l,s,d){var c;let h=i;const p=new Set,u=new Map(n.map(t=>{var e;return[t,(null==(e=Jl(r,t))?void 0:e.run.text)??""]}));for(const f of a){const a=n.find(t=>f.blockId.startsWith(`${t}:`));if(a&&!p.has(a)){const n=u.get(a);if(n){const a="paragraph"===f.sourceBlock.type?f.sourceBlock:void 0,i=We(void 0,null==(c=null==a?void 0:a.style)?void 0:c.styleId,r.styles),l=s.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});t.drawText(e,{x:bM(o),y:bM(h+12),text:n,fontSize:yM(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:l.writerResourceName})}p.add(a)}await vR(t,e,[f],r,o+pn,h,Math.max(24,l-pn),s,d),h+=Math.max(0,f.estimatedHeight)+2}}function QR(t,e){const a=URL.createObjectURL(t),n=document.createElement("a");n.href=a,n.download=e,n.click(),URL.revokeObjectURL(a)}function _R(t){const e=t.download??QR;return{handleExportDocx:async()=>{const a=await async function(t){const e=await _E(t);return new Blob([e],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}(t.document());e(a,"oasis-editor.docx"),t.focusInput()},handleExportPdf:async()=>{const a=await async function(t){const e=await JR(t);return new Blob([e],{type:"application/pdf"})}(t.document());e(a,"oasis-editor.pdf"),t.focusInput()}}}async function $R(t){return"function"==typeof t.arrayBuffer?t.arrayBuffer():new Promise((e,a)=>{const n=new FileReader;n.onerror=()=>a(n.error??new Error("Failed to read file.")),n.onload=()=>{const t=n.result;t instanceof ArrayBuffer?e(t):a(new Error("Failed to read file as ArrayBuffer."))},n.readAsArrayBuffer(t)})}function tL(t){if(!t)return null;for(const e of Array.from(t.items??[])){if("file"!==e.kind)continue;const t=e.getAsFile();if(t&&t.type.startsWith("image/"))return t}for(const e of Array.from(t.files??[]))if(e.type.startsWith("image/"))return e;return null}function eL(t){return{handleImportFile:async e=>{if(!e)return;const a=function(t){return ny.find(e=>e.matches(t))}(e);if(!a)return t.setImportPhase("error"),t.logger.error("import:unsupported-format",{name:e.name,type:e.type}),void t.clearImportProgressSoon();const n=t.now();t.logger.info("import:start",{format:a.id,name:e.name,size:e.size}),t.setImportPhase("reading-file");try{const r=t.now(),o=await $R(e);t.logger.info("import:phase",{phase:"reading-file",durationMs:Math.round(100*(t.now()-r))/100});let i=null,l=-1,s=0;const d=await a.import(o,(e,a)=>{const n=t.now(),r=void 0!==a&&Number.isFinite(a)?Math.floor(100*a):void 0,o=e!==i;if(!o&&!(void 0!==r&&(l<0||r-l>=1))&&!(n-s>=40))return;i=e,l=r??l,s=n,t.setImportPhase(e,a);const d={phase:e,subProgress:a};o||void 0===a||1===a?t.logger.info("import:phase",d):t.logger.debug("import:phase",d)});t.logger.info("import:document-diagnostics",function(t){var e;const a=Je(t),n=new Map,r=new Map;let o=0,i=0;for(const l of a){const a=He(l.style,t.styles);r.set(a.align,(r.get(a.align)??0)+1);for(const r of l.runs){const a=We(r.styles,null==(e=l.style)?void 0:e.styleId,t.styles),s=a.fontFamily??"<null>";n.set(s,(n.get(s)??0)+1),null!==a.characterSpacing&&(o+=1),null!==a.characterScale&&(i+=1)}}return{paragraphCount:a.length,alignCounts:Array.from(r.entries()),fontCounts:Array.from(n.entries()),characterSpacingRuns:o,characterScaleRuns:i,firstParagraphs:a.slice(0,30).map((e,a)=>{var n;const r=He(e.style,t.styles),o=e.runs[0],i=We(null==o?void 0:o.styles,null==(n=e.style)?void 0:n.styleId,t.styles);return{index:a,text:Ce(e).slice(0,160),runCount:e.runs.length,rawParagraphStyle:e.style,align:r.align,indentFirstLine:r.indentFirstLine,lineGridPitch:r.lineGridPitch,lineGridType:r.lineGridType,fontFamily:i.fontFamily,fontSize:i.fontSize,characterSpacing:i.characterSpacing,characterScale:i.characterScale,firstRunStyle:null==o?void 0:o.styles}})}}(d)),t.setImportPhase("applying-editor-state"),t.resetEditorChromeState(),t.applyState(Ra(d));const c=t.now();t.setImportPhase("stabilizing-layout"),await t.stabilizeLayoutAfterImport(),t.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:Math.round(100*(t.now()-c))/100});const h=Fe(d).reduce((t,e)=>{var a,n;return t+((null==(a=e.header)?void 0:a.length)??0)+e.blocks.length+((null==(n=e.footer)?void 0:n.length)??0)},0),p=Xe(d).length;t.setImportPhase("done"),t.logger.info("import:done",{format:a.id,blocks:h,paragraphs:p,durationMs:Math.round(100*(t.now()-n))/100}),t.focusInput()}catch(r){t.setImportPhase("error"),t.logger.error("import:error",r)}finally{t.clearImportProgressSoon()}}}}function aL(t,e){const a=va(t);if(a.isCollapsed||a.startIndex!==a.endIndex||a.endParagraphOffset-a.startParagraphOffset!==1)return null;const n=ha(t)[a.startIndex];if(!n)return null;let r=0;for(let o=0;o<n.runs.length;o+=1){const t=n.runs[o],i=r;if(r+=t.text.length,e(t)&&1===t.text.length&&i===a.startParagraphOffset)return{paragraph:n,paragraphIndex:a.startIndex,run:t,runIndex:o,offset:i}}return null}function nL(t,e){if("inline"===e)return;const a={...t??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating"};switch(e){case"square":case"tight":case"through":case"topAndBottom":return{...a,wrap:e,behindDoc:!1};case"behind":return{...a,wrap:"none",behindDoc:!0};case"front":return{...a,wrap:"none",behindDoc:!1}}}function rL(t){return t?t.behindDoc?"behind":t.wrap&&"none"!==t.wrap?t.wrap:"front":"inline"}function oL(t,e){return{...t,positionV:{...t.positionV??{},relativeFrom:e?"page":"paragraph"}}}function iL(t){var e;return"page"===(null==(e=null==t?void 0:t.positionV)?void 0:e.relativeFrom)}function lL(t){return aL(t,t=>Boolean(t.image))}function sL(t,e){const a=lL(t);if(!a)return t;const n=function(t){if(!Number.isFinite(t))return;const e=(Math.round(t)%360+360)%360;return 0===e?void 0:e}(e),r=ha(t),{paragraphIndex:o,run:i}=a,l=r.map((t,e)=>e!==o?TT(t):{...TT(t),runs:t.runs.map(t=>t.id===i.id&&t.image?{...t,image:{...t.image,rotation:n}}:IT(t))});return ZT(t,l,YT(l,va(t)))}function dL(t,e){const a=lL(t);if(!(null==a?void 0:a.run.image))return t;const n=ha(t),{paragraphIndex:r,run:o}=a,i=n.map((t,a)=>a!==r?TT(t):{...TT(t),runs:t.runs.map(t=>{if(t.id!==o.id||!t.image)return IT(t);const a=e(t.image.floating),n={...t.image};return a?n.floating=a:delete n.floating,{...t,image:n}})});return ZT(t,i,YT(i,va(t)))}function cL(t){const e=lL(t);if(!(null==e?void 0:e.run.image))return null;return function(t){var e;if(!jE(t))return"";let a=!1,n="";for(const r of t.runs)a?n+=r.text:"end"===(null==(e=r.fieldChar)?void 0:e.kind)&&(a=!0);return n.replace(/^[:\-\s]+/,"")}(ha(t)[e.paragraphIndex+1])}function hL(t,e,a){const n=lL(t);if(!(null==n?void 0:n.run.image))return t;const r=ha(t),o=n.paragraphIndex+1,i=o<r.length&&jE(r[o])?function(t,e,a){var n;const r=(null==(n=t.runs.find(t=>/^\d+$/.test(t.text)))?void 0:n.text)??"1",o=KE(e,a,Number.parseInt(r,10)||1);return o.id=t.id,o}(r[o],e,a):KE(e,a,1),l=function(t){let e=1;return t.map(t=>jE(t)?XE(t,e++):TT(t))}(o<r.length&&jE(r[o])?[...kT(r.slice(0,o)),i,...kT(r.slice(o+1))]:[...kT(r.slice(0,o)),i,...kT(r.slice(o))]),s=l[o]??i;return ZT(t,l,KT(Ve(s,ke(s))))}function pL(t,e){const a=lL(t);if(!a)return t;const n=ha(t),{paragraphIndex:r,offset:o,run:i}=a,l=pa(n,e.paragraphId);if(l<0)return t;const s=Ee(n[l],e),d=l===r&&s>o?s-1:s;if(l===r&&d===o)return t;const c=t=>RT(t,[...WT(t,0,o),...WT(t,o+1,ke(t))]),h=(t,e)=>HT(t,Math.max(0,Math.min(e,ke(t))),[wa("",OT(t,e),i.image)]),p=n.map((t,e)=>e===r&&e===l?h(c(t),d):e===r?c(t):e===l?h(t,d):kT([t])[0]),u=p[l];return ZT(t,p,KT(Ve(u,Math.max(0,Math.min(d+1,ke(u))))))}function uL(t,e,a,n=0){const r=xe(Me(e));if(!a)return r;const o=dl(e,a,n);return null!==o&&Number.isFinite(o)&&o>0?Math.min(r,o):r}function fL(t){return{insertImageFromFile:async(e,a)=>{t.logger.info(`image insert:start name="${e.name}" type=${e.type} size=${e.size}`);const n=await $R(e),r=`data:${e.type};base64,${function(t){return btoa(new Uint8Array(t).reduce((t,e)=>t+String.fromCharCode(e),""))}(n)}`,o=new Image;o.src=r,await new Promise(t=>{o.onload=t,o.onerror=t});const i=o.naturalWidth||300,l=o.naturalHeight||300,s=t.state(),d=(null==a?void 0:a.paragraphId)??s.selection.focus.paragraphId,c=uL(t.surfaceRef(),s.document,d,s.activeSectionIndex??0),h=i>c?c/i:1,p=Math.max(24,Math.round(i*h)),u=Math.max(24,Math.round(l*h));t.logger.info(`image insert:decoded natural=${i}x${l} fitted=${p}x${u} maxWidth=${c}`),t.applyTransactionalState(t=>function(t,e){const a=ma(t.selection)?t:XT(t),{paragraph:n,index:r,offset:o}=jT(a),i=HT(n,o,[wa("",OT(n,o),e)]);return ZT(a,ha(a).map((t,e)=>e===r?i:TT(t)),KT(Ve(i,o+1)))}(a?YC(t,{anchor:a,focus:a}):t,{src:r,width:p,height:u}),{mergeKey:"insertImage"})}}}const gL={"reading-file":[0,8],opening:[8,20],parsing:[20,72],finishing:[72,78],"applying-editor-state":[78,88],"stabilizing-layout":[88,98],done:[100,100],error:[100,100]};function mL(t,e){return t.paragraph.runs.map(t=>t.text).join("")[e]??""}function vL(t){return" "===t||"\t"===t||"\n"===t}function bL(t,e,a){if(a.isCollapsed)return null;const n=e.get(t);return void 0===n||n<a.startIndex||n>a.endIndex?null:a.startIndex===a.endIndex?{start:a.startParagraphOffset,end:a.endParagraphOffset}:t===a.start.paragraphId?{start:a.startParagraphOffset,end:Number.POSITIVE_INFINITY}:t===a.end.paragraphId?{start:0,end:a.endParagraphOffset}:{start:0,end:Number.POSITIVE_INFINITY}}function yL(t,e){var a,n,r,o;const i=va(e),l=[],s=t.surfaceRect,d=new Map(ha(e).map((t,e)=>[t.id,e]));let c=null,h=null;if(!i.isCollapsed&&i.startIndex===i.endIndex&&i.endParagraphOffset-i.startParagraphOffset===1){const e=t=>t.paragraphId===i.start.paragraphId&&t.startOffset===i.startParagraphOffset&&t.endOffset===i.endParagraphOffset,a=t.inlineImages.find(e)??t.floatingImages.find(e);if(a&&(c={paragraphId:a.paragraphId,startOffset:a.startOffset,endOffset:a.endOffset,left:a.left-s.left,top:a.top-s.top,width:a.width,height:a.height,rotation:a.rotation??0}),!c){const e=t=>t.paragraphId===i.start.paragraphId&&t.startOffset===i.startParagraphOffset&&t.endOffset===i.endParagraphOffset,a=t.floatingTextBoxes.find(e),n=a?void 0:t.inlineTextBoxes.find(e),r=a??n;r&&(h={paragraphId:r.paragraphId,startOffset:r.startOffset,endOffset:r.endOffset,left:r.left-s.left,top:r.top-s.top,width:r.width,height:r.height,rotation:r.rotation??0,floating:Boolean(a)})}}const p=sa(e),u=_e(e.document,e.selection.anchor.paragraphId,p),f=_e(e.document,e.selection.focus.paragraphId,p);let g=!1;if(u&&f&&u.blockIndex===f.blockIndex&&u.zone===f.zone&&(u.rowIndex!==f.rowIndex||u.cellIndex!==f.cellIndex)){const o=Be(e.document)[p];let i;if(i="header"===u.zone?null==(a=null==o?void 0:o.header)?void 0:a[u.blockIndex]:"footer"===u.zone?null==(n=null==o?void 0:o.footer)?void 0:n[u.blockIndex]:null==(r=null==o?void 0:o.blocks)?void 0:r[u.blockIndex],i&&"table"===i.type){g=!0;const e=sn(i),a=e.find(t=>t.rowIndex===u.rowIndex&&t.cellIndex===u.cellIndex),n=e.find(t=>t.rowIndex===f.rowIndex&&t.cellIndex===f.cellIndex);if(a&&n){const r=Math.min(a.visualRowIndex,n.visualRowIndex),o=Math.max(a.visualRowIndex+a.rowSpan-1,n.visualRowIndex+n.rowSpan-1),d=Math.min(a.visualColumnIndex,n.visualColumnIndex),c=Math.max(a.visualColumnIndex+a.colSpan-1,n.visualColumnIndex+n.colSpan-1),h=new Set;for(const a of t.paragraphs)if(a.tableCell&&a.tableCell.tableId===i.id){const t=e.find(t=>t.rowIndex===a.tableCell.rowIndex&&t.cellIndex===a.tableCell.cellIndex);if(t){const e=t.visualRowIndex<=o&&t.visualRowIndex+t.rowSpan-1>=r,n=t.visualColumnIndex<=c&&t.visualColumnIndex+t.colSpan-1>=d;if(e&&n){const e=`${t.rowIndex}:${t.cellIndex}`;h.has(e)||(h.add(e),l.push({left:a.tableCell.left-s.left,top:a.tableCell.top-s.top,width:a.tableCell.width,height:a.tableCell.height}))}}}}}}if(!(g||i.isCollapsed||c||h))for(const S of t.paragraphs){const t=bL(S.paragraphId,d,i);if(!t)continue;const e=Math.max(t.start,S.startOffset),a=Math.min(t.end,S.endOffset);if(!(e>=a))for(const n of S.lines){let t=Math.max(e,n.startOffset),r=Math.min(a,n.endOffset);for(;t<r&&vL(mL(S,t));)t+=1;for(;r>t&&vL(mL(S,r-1));)r-=1;if(t>=r)continue;const o=n.slots.find(e=>e.offset===t),i=n.slots.find(t=>t.offset===r)??n.slots[n.slots.length-1];if(!o||!i)continue;const d=0===S.startOffset&&n.startOffset===S.startOffset&&n.top>S.top,c=d?S.top:n.top,h=d?n.top+n.height-S.top:n.height;l.push({left:o.left-s.left+1,top:c-s.top,width:Math.max(1,i.left-o.left+1-1),height:h})}}const m=e.selection.focus.paragraphId,v=t.paragraphsById.get(m)??[],b=null==(o=v[0])?void 0:o.paragraph,y=function(t,e){if(0===t.length)return null;const a=t.find(t=>e>=t.startOffset&&e<=t.endOffset)??t[t.length-1],n=a.lines.flatMap(t=>t.slots);if(0===n.length)return{left:a.left,top:a.top,height:Math.max(18,a.height)};let r=n[0],o=Math.abs(e-r.offset);for(const l of n){const t=Math.abs(e-l.offset);t<o&&(r=l,o=t)}const i=a.lines[0];return 0===a.startOffset&&void 0!==i&&e>=i.startOffset&&e<=i.endOffset&&r.top>a.top?{left:r.left,top:a.top,height:r.top+r.height-a.top}:{left:r.left,top:r.top,height:r.height}}(v,b?Ee(b,e.selection.focus):e.selection.focus.offset),M=((null==y?void 0:y.left)??s.left)-s.left,x=((null==y?void 0:y.top)??s.top)-s.top,w=Math.max(18,(null==y?void 0:y.height)??28);return{selectionBoxes:l,inputBox:{left:M,top:x,height:w},caretBox:{left:M,top:x,height:w,visible:v.length>0&&!g&&!c&&!h},selectedImageBox:c,selectedTextBoxBox:h}}function ML(t,e){if(0===e.length)return t;const a={...t};for(const n of e)delete a[n];return a}function xL(t){const[e,a]=y({}),[n,r]=y({}),[o,i]=y({left:0,top:0,height:28}),[l,s]=y([]),[d,c]=y([]),[h,p]=y(null),[u,f]=y(null),[g,m]=y({left:0,top:0,height:28,visible:!1}),[v,b]=y(null);let M=0;const w=(a="selection")=>{var r;const o=t.surfaceRef();if(!o)return s([]),c([]),p(null),f(null),void m(t=>({...t,visible:!1}));const l=qs({surface:o,state:t.state,measuredBlockHeights:e(),measuredParagraphLayouts:n(),zoomFactor:null==(r=t.zoomFactor)?void 0:r.call(t)});if(!l)return s([]),c([]),p(null),f(null),void m(t=>({...t,visible:!1}));const d=yL(l,t.state);s(d.selectionBoxes),c(function(t,e){const a=e.document.comments;if(!a||0===a.order.length)return[];const n=t.surfaceRect,r=new Map(ha(e).map((t,e)=>[t.id,e])),o=[];for(const i of a.order){const e=a.items[i];if(!(null==e?void 0:e.start)||!(null==e?void 0:e.end))continue;const l=r.get(e.start.paragraphId),s=r.get(e.end.paragraphId);if(void 0!==l&&void 0!==s)for(const a of t.paragraphs){const t=r.get(a.paragraphId);if(void 0===t||t<l||t>s)continue;const d=t===l?e.start.offset:0,c=t===s?e.end.offset:Number.POSITIVE_INFINITY,h=Math.max(d,a.startOffset),p=Math.min(c,a.endOffset);if(!(h>=p))for(const e of a.lines){const t=Math.max(h,e.startOffset),a=Math.min(p,e.endOffset);if(t>=a)continue;const r=e.slots.find(e=>e.offset===t),l=e.slots.find(t=>t.offset===a)??e.slots[e.slots.length-1];r&&l&&o.push({commentId:i,left:r.left-n.left,top:e.top-n.top,width:Math.max(1,l.left-r.left),height:e.height})}}}return o}(l,t.state)),p(d.selectedImageBox),f(d.selectedTextBoxBox),i(d.inputBox),m(d.caretBox)},S=(t="selection")=>{const e=++M;queueMicrotask(()=>{e===M&&w(t)})};x(()=>{t.state.selection.anchor.paragraphId,t.state.selection.anchor.runId,t.state.selection.anchor.offset,t.state.selection.focus.paragraphId,t.state.selection.focus.runId,t.state.selection.focus.offset,S("selection")}),x(()=>{var e;t.state.document,t.state.activeSectionIndex,t.state.activeZone,(null==(e=t.isImporting)?void 0:e.call(t))||S("content-change")}),x(()=>{const e=t.viewportRef();if(!e)return;const a=()=>{S("scroll")},n=()=>{S("resize")};e.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",n),T(()=>{e.removeEventListener("scroll",a),window.removeEventListener("resize",n)})});return{measuredBlockHeights:e,measuredParagraphLayouts:n,inputBox:o,selectionBoxes:l,commentHighlights:d,selectedImageBox:h,selectedTextBoxBox:u,caretBox:g,preferredColumnX:v,setPreferredColumnX:b,clearPreferredColumn:()=>b(null),requestInputBoxSync:S,scheduleDeferredLayoutMeasurement:(t,e={})=>(e.paragraphIds&&e.paragraphIds.length>0&&r(t=>ML(t,e.paragraphIds??[])),S(t),e.resolveWhenDone?Promise.resolve():null),stabilizeLayoutAfterImport:async()=>{a({}),r({}),await new Promise(t=>{var e;e=()=>t(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>e()):globalThis.setTimeout(e,16)}),S("import")},syncMeasuredLayoutMetrics:(t="content-change")=>(S(t),!1),syncInputBox:w,setMeasuredBlockHeights:a,setMeasuredParagraphLayouts:r,applyInvalidation:e=>{var n,o;if(!(null==(n=t.isImporting)?void 0:n.call(t))){if(e.dirtyAll||e.structureChanged)a({}),r({});else if(((null==(o=e.dirtyParagraphIds)?void 0:o.length)??0)>0){const t=e.dirtyParagraphIds??[];r(e=>ML(e,t))}S("content-change")}},onCleanupHook:()=>{M+=1}}}function wL(t){return{performUndo:()=>{const e=(a=t.getHistoryState(),n=t.stateSnapshot(),0===a.undoStack.length?null:{history:{undoStack:a.undoStack.slice(0,-1),redoStack:[...a.redoStack,n],lastTransactionMeta:null},nextState:a.undoStack[a.undoStack.length-1]});var a,n;e&&(t.updateHistoryState(()=>e.history),t.clearPreferredColumn(),t.applyHistoryState(e.nextState),t.focusInput())},performRedo:()=>{const e=(a=t.getHistoryState(),n=t.stateSnapshot(),0===a.redoStack.length?null:{history:{undoStack:[...a.undoStack,n],redoStack:a.redoStack.slice(0,-1),lastTransactionMeta:null},nextState:a.redoStack[a.redoStack.length-1]});var a,n;e&&(t.updateHistoryState(()=>e.history),t.clearPreferredColumn(),t.applyHistoryState(e.nextState),t.focusInput())},moveSelectedImageByParagraph:e=>{const a=t.imageOps().getSelectedImageInfo(t.state());if(!a)return!1;const n=ha(t.state()),r=n.findIndex(t=>t.id===a.paragraph.id);if(r<0)return!1;const o=r+e;if(o<0||o>=n.length){const a=((t,e)=>{const a=Fe(t.document),n=Math.max(0,Math.min(sa(t),a.length-1)),r=da(t),o=a[n];if(!o)return t;const i=[...a],l={...o},s=Sa("");if("header"===r){const t=[...o.header??[]];e<0?t.unshift(s):t.push(s),l.header=t}else if("footer"===r){const t=[...o.footer??[]];e<0?t.unshift(s):t.push(s),l.footer=t}else{const t=[...o.blocks];e<0?t.unshift(s):t.push(s),l.blocks=t}return i[n]=l,{...t,document:{...t.document,sections:i}}})(t.state(),e),n=ha(a),r=e<0?n[0]:n[n.length-1];if(!r)return!1;const o=Ve(r,e<0?ke(r):0);return t.applyTransactionalState(()=>pL(a,o),{mergeKey:"moveImage"}),t.focusInput(),!0}const i=n[o],l=e<0?ke(i):0;return t.applyTransactionalState(t=>pL(t,Ve(i,l)),{mergeKey:"moveImage"}),t.focusInput(),!0},applySelectionPreservingStructure:e=>{var a;const n=t.stateSnapshot();t.applyHistoryState({...n,document:{...n.document,sections:null==(a=n.document.sections)?void 0:a.map(Lx)},selection:{anchor:{...e.anchor},focus:{...e.focus}}})}}}function SL(t={}){const e=t.dbName??"oasis-editor-db",a=t.storeName??"documents",n=t.key??"current-document";let r=null;async function o(){return r||(r=await function(t){return new Promise((e,a)=>{const n=indexedDB.open(t.name,t.version);n.onerror=()=>{var t;a(new Error(`Failed to open IndexedDB: ${null==(t=n.error)?void 0:t.message}`))},n.onsuccess=()=>{e(n.result)},n.onupgradeneeded=e=>{const a=n.result;t.onUpgrade(a,e.oldVersion,e.newVersion)}})}({name:e,version:1,onUpgrade:t=>{t.objectStoreNames.contains(a)||t.createObjectStore(a)}}),r)}return{async saveDocument(t){await function(t,e,a,n){return new Promise((r,o)=>{try{const i=t.transaction([e],"readwrite").objectStore(e).put(n,a);i.onerror=()=>{var t;o(new Error(`Failed to put item in ${e}: ${null==(t=i.error)?void 0:t.message}`))},i.onsuccess=()=>{r()}}catch(i){o(i)}})}(await o(),a,n,t)},loadDocument:async()=>function(t,e,a){return new Promise((n,r)=>{try{const o=t.transaction([e],"readonly").objectStore(e).get(a);o.onerror=()=>{var t;r(new Error(`Failed to get item from ${e}: ${null==(t=o.error)?void 0:t.message}`))},o.onsuccess=()=>{n(o.result??null)}}catch(o){r(o)}})}(await o(),a,n),async clearDocument(){await function(t,e,a){return new Promise((n,r)=>{try{const o=t.transaction([e],"readwrite").objectStore(e).delete(a);o.onerror=()=>{var t;r(new Error(`Failed to delete item from ${e}: ${null==(t=o.error)?void 0:t.message}`))},o.onsuccess=()=>{n()}}catch(o){r(o)}})}(await o(),a,n)},close(){r&&(r.close(),r=null)}}}function AL(t){const[e,a]=y([]),[n,r]=y([]);let o={undoStack:[],redoStack:[],lastTransactionMeta:null};const i=()=>{a(o.undoStack),r(o.redoStack)};return{undoStack:e,redoStack:n,applyTransactionalState:(e,a)=>{const n=t.stateSnapshot(),r=Ri("txn:produce",()=>e(n),0);if(r===n)return;o=function(t,e,a,n,r=Date.now()){var o;return{undoStack:void 0!==(null==n?void 0:n.mergeKey)&&(null==(o=t.lastTransactionMeta)?void 0:o.mergeKey)===n.mergeKey&&r-t.lastTransactionMeta.timestamp<1e3?t.undoStack:[...t.undoStack,e],redoStack:[],lastTransactionMeta:(null==n?void 0:n.mergeKey)?{mergeKey:n.mergeKey,timestamp:r}:null}}(o,n,0,a),i();const l=Ri("txn:invalidate",()=>function(t,e){var a,n,r,o,i,l,s,d,c,h,p,u,f,g,m,v;if(t===e||t.document===e.document)return{};const b=t=>Fe(t.document).map(t=>[...(t.header??[]).map(t=>t.id),...t.blocks.map(t=>t.id),...(t.footer??[]).map(t=>t.id)].join("|")).join("||");if(b(t)!==b(e))return{dirtyAll:!0,structureChanged:!0};const y=ha(t),M=ha(e),x=new Map;for(const S of y)x.set(S.id,S);const w=[];for(const S of M){const t=x.get(S.id);if(!t){w.push(S.id);continue}if(t===S)continue;if(t.runs.length!==S.runs.length){w.push(S.id);continue}let e=!1;for(let b=0;b<t.runs.length;b+=1){const y=t.runs[b],M=S.runs[b];if(y!==M){if(y.id!==M.id||y.text!==M.text){e=!0;break}if(Boolean(y.image)!==Boolean(M.image)||((null==(a=y.image)?void 0:a.width)??-1)!==((null==(n=M.image)?void 0:n.width)??-1)||((null==(r=y.image)?void 0:r.height)??-1)!==((null==(o=M.image)?void 0:o.height)??-1)||((null==(l=null==(i=y.image)?void 0:i.floating)?void 0:l.wrap)??"")!==((null==(d=null==(s=M.image)?void 0:s.floating)?void 0:d.wrap)??"")||Boolean(null==(h=null==(c=y.image)?void 0:c.floating)?void 0:h.behindDoc)!==Boolean(null==(u=null==(p=M.image)?void 0:p.floating)?void 0:u.behindDoc)||((null==(g=null==(f=y.image)?void 0:f.wrapPolygon)?void 0:g.length)??-1)!==((null==(v=null==(m=M.image)?void 0:m.wrapPolygon)?void 0:v.length)??-1)){e=!0;break}}}e&&w.push(S.id)}return{dirtyParagraphIds:w}}(n,r),0);t.applyLayoutInvalidation(l),Ri("txn:setState",()=>t.commitState(r),0)},applyHistoryState:e=>{t.commitState(t.cloneState(e))},resetTransactionGrouping:()=>{var t;t=o,o={...t,lastTransactionMeta:null}},updateHistoryState:t=>{o=t(o),i()},getHistoryState:()=>o,clearHistory:()=>{o={undoStack:[],redoStack:[],lastTransactionMeta:null},i()}}}function IL(t){x(()=>{var e,a;if(t.state.document,t.state.selection,t.state.activeSectionIndex,t.state.activeZone,a=t.state,dT&&(pT={anchor:{paragraphId:a.selection.anchor.paragraphId,runId:a.selection.anchor.runId,offset:a.selection.anchor.offset},focus:{paragraphId:a.selection.focus.paragraphId,runId:a.selection.focus.runId,offset:a.selection.focus.offset},activeZone:a.activeZone??"main",activeSectionIndex:a.activeSectionIndex??0}),t.isImportInProgress())return;const n=t.cloneState(t.getStateSnapshot());null==(e=t.getOnStateChange())||e(n),t.emit("change",n),t.emit("documentChange",n.document),t.emit("selectionChange",n.selection)})}function TL(t){const{documentOptions:e,logger:a,runtimeClient:n,state:r,commitState:o,getStateSnapshot:i,applyState:l,cloneState:s,isReadOnly:d,focusInput:c,surfaceRef:h,viewportRef:p,zoomFactor:u,getImageOps:f}=t,g=function(t){const[e,a]=y(null),n=(t,e)=>{const[a,n]=gL[t];return void 0!==e&&Number.isFinite(e)?Math.round(10*(a+(n-a)*Math.min(1,Math.max(0,e))))/10:n},r=eL({applyState:t.applyState,stabilizeLayoutAfterImport:t.stabilizeLayoutAfterImport,resetEditorChromeState:t.resetEditorChromeState,focusInput:t.focusInput,setImportPhase:(t,e)=>{a({phase:t,progress:n(t,e),subProgress:e})},clearImportProgressSoon:()=>{globalThis.setTimeout(()=>{a(t=>"done"===(null==t?void 0:t.phase)||"error"===(null==t?void 0:t.phase)?null:t)},1200)},now:()=>performance.now(),logger:t.logger}),o=fL({state:t.state,applyTransactionalState:t.applyTransactionalState,surfaceRef:t.surfaceRef,logger:t.logger}),i=_R({document:()=>t.state().document,focusInput:t.focusInput}),l=async(t,e)=>{await o.insertImageFromFile(t,e)};return{importProgress:e,handleImportFile:async e=>{t.isReadOnly()||await r.handleImportFile(e)},handleExportDocx:async()=>{await i.handleExportDocx()},handleExportPdf:async()=>{await i.handleExportPdf()},insertImageFromFile:l,handleInsertImage:async e=>{t.isReadOnly()||e&&(await l(e),t.focusInput())}}}({state:()=>r,applyState:l,applyTransactionalState:(t,e)=>B(t,e),isReadOnly:d,surfaceRef:()=>h()??null,stabilizeLayoutAfterImport:async()=>{await L()},resetEditorChromeState:()=>J(),focusInput:c,logger:a}),m=()=>{var t,e;return"done"!==(null==(t=g.importProgress())?void 0:t.phase)&&"error"!==(null==(e=g.importProgress())?void 0:e.phase)&&null!==g.importProgress()},{measuredBlockHeights:v,measuredParagraphLayouts:b,inputBox:M,selectionBoxes:w,commentHighlights:S,selectedImageBox:T,selectedTextBoxBox:C,caretBox:k,preferredColumnX:V,setPreferredColumnX:E,clearPreferredColumn:R,stabilizeLayoutAfterImport:L,setMeasuredBlockHeights:z,setMeasuredParagraphLayouts:N,applyInvalidation:q,onCleanupHook:O}=xL({state:r,surfaceRef:h,viewportRef:p,isImporting:m,zoomFactor:u}),P=SL({key:e().persistenceKey}),{status:W}=function(t,e,a){const[n,r]=y("Initial"),[o,i]=y(!1),l=()=>a.enabled??!1,s=a.persistence,d=ln(async t=>{var e;if(l()&&o()){r("Saving...");try{const e=JSON.parse(JSON.stringify(ne(t)));await s.saveDocument(e),r("Saved")}catch(n){null==(e=a.logger)||e.error("persistence:autosave failed",n),r("Error")}}},1e3);return x(A(()=>t.document,t=>{l()&&o()&&d(t)},{defer:!0})),I(async()=>{var t;if(!l())return i(!0),void r("Saved");try{const t=await s.loadDocument();t&&e(t)}catch(n){null==(t=a.logger)||t.error("persistence:load failed",n)}finally{i(!0),r("Saved")}}),{status:n}}(r,t=>{a.info("persistence:loaded",{docId:t.id});const e=Ra(t);o(e),J()},{enabled:e().persistenceEnabled??!1,persistence:e().persistence??P,logger:a}),H=AL({stateSnapshot:i,commitState:o,cloneState:s,applyLayoutInvalidation:q}),{undoStack:U,redoStack:F,applyTransactionalState:B,applyHistoryState:G,resetTransactionGrouping:Z,updateHistoryState:D,getHistoryState:K,clearHistory:j}=H,X=wL({state:()=>r,stateSnapshot:i,applyHistoryState:G,applyTransactionalState:B,focusInput:c,clearPreferredColumn:R,imageOps:f,updateHistoryState:D,getHistoryState:K}),J=()=>{R(),z({}),N({}),j()};return IL({state:r,isImportInProgress:m,cloneState:s,getStateSnapshot:i,getOnStateChange:()=>e().onStateChange,emit:n.emit}),{docIO:g,isImportInProgress:m,measuredBlockHeights:v,measuredParagraphLayouts:b,inputBox:M,selectionBoxes:w,commentHighlights:S,selectedImageBox:T,selectedTextBoxBox:C,caretBox:k,preferredColumnX:V,setPreferredColumnX:E,clearPreferredColumn:R,stabilizeLayoutAfterImport:L,setMeasuredBlockHeights:z,setMeasuredParagraphLayouts:N,applyLayoutInvalidation:q,onCleanupHook:O,fallbackPersistence:P,persistenceStatus:W,undoStack:U,redoStack:F,applyTransactionalState:B,applyHistoryState:G,resetTransactionGrouping:Z,updateHistoryState:D,getHistoryState:K,clearHistory:j,historyActions:X,resetEditorChromeState:J}}function CL(t){return aL(t,t=>Boolean(t.textBox))}function kL(t,e){const a=CL(t);if(!a||!a.run.textBox)return t;const n=function(t){if(!Number.isFinite(t))return;const e=(Math.round(t)%360+360)%360;return 0===e?void 0:e}(e),{paragraphIndex:r,run:o}=a,i=ha(t).map((t,e)=>e!==r?TT(t):{...TT(t),runs:t.runs.map(t=>t.id===o.id&&t.textBox?{...t,textBox:{...t.textBox,rotation:n}}:IT(t))});return ZT(t,i,YT(i,va(t)))}function VL(t,e){const a=CL(t);if(!(null==a?void 0:a.run.textBox))return t;const{paragraphIndex:n,run:r}=a,o=ha(t).map((t,a)=>a!==n?TT(t):{...TT(t),runs:t.runs.map(t=>{if(t.id!==r.id||!t.textBox)return IT(t);const a=e(t.textBox.floating),n={...t.textBox};return a?n.floating=a:delete n.floating,{...t,textBox:n}})});return ZT(t,o,YT(o,va(t)))}function EL(t,e,a,n={}){const r=CL(t);if(!r||!r.run.textBox)return t;const o=n.handleDirection??"se",i=o.includes("n")||o.includes("s"),l=o.includes("w"),s=o.includes("n"),d=Math.max(24,Math.round(e)),c=Math.max(24,Math.round(a)),{paragraphIndex:h,run:p}=r,u=d-r.run.textBox.width,f=c-r.run.textBox.height,g=ha(t).map((t,e)=>e!==h?TT(t):{...TT(t),runs:t.runs.map(t=>{var e;if(t.id!==p.id||!t.textBox)return IT(t);const a=t.textBox,n={...a,width:d,height:c};return i&&(null==(e=a.body)?void 0:e.autoFit)&&(n.body={...a.body,autoFit:!1}),a.floating&&(n.floating=function(t,e,a,n,r){let o=t;if(n&&0!==e){const a=t.positionH;(null==a?void 0:a.align)||(o={...o,positionH:{...a??{},offset:((null==a?void 0:a.offset)??0)-e*An}})}if(r&&0!==a){const t=o.positionV;(null==t?void 0:t.align)||(o={...o,positionV:{...t??{},offset:((null==t?void 0:t.offset)??0)-a*An}})}return o}(a.floating,u,f,l,s)),{...t,textBox:n}})});return ZT(t,g,YT(g,va(t)))}const RL=t=>t.cells.reduce((t,e)=>t+Math.max(1,e.colSpan??1),0),LL=t=>t.rows.reduce((t,e)=>Math.max(t,RL(e)),0),zL=(t,e)=>{let a=0;for(const n of t.cells){const t=Math.max(1,n.colSpan??1);if(e>=a&&e<a+t)return n;a+=t}return null},NL=t=>{for(const e of t.rows)for(const t of e.cells){if("continue"===t.vMerge)continue;const e=t.blocks[0];if(e)return e}return null},qL=(t,e,a)=>{const n=Be(t);for(const r of n){const t=[...r.header||[],...r.blocks,...r.footer||[]];for(const n of t){if("table"!==n.type)continue;const t=n.rows.flatMap(t=>t.cells.filter(t=>"continue"!==t.vMerge&&t.blocks.length>0)),r=t.findIndex(t=>t.blocks.some(t=>t.id===e));if(-1===r)continue;const o=t[r+a],i=null==o?void 0:o.blocks[0];return i?Ve(i,0):null}}return null},OL=(t,e,a="main")=>{const n=sa(t),r=Fe(t.document),o=Math.max(0,Math.min(n,r.length-1)),i=r[o];if(!i)return t;const l=[...r];return l[o]="header"===a?{...i,header:e}:"footer"===a?{...i,footer:e}:{...i,blocks:e},{...t,document:{...t.document,sections:l}}};function PL(t,e){return t.visualRowIndex!==e.visualRowIndex?t.visualRowIndex-e.visualRowIndex:t.visualColumnIndex!==e.visualColumnIndex?t.visualColumnIndex-e.visualColumnIndex:0}function WL(t,e){const a=t.selection,n=sa(t),r=_e(t.document,a.anchor.paragraphId,n),o=_e(t.document,a.focus.paragraphId,n);if(!r||!o||r.blockIndex!==o.blockIndex||r.zone!==o.zone)return null;const i=e.getTargetBlocks(t,r.zone)[r.blockIndex];if(!i||"table"!==i.type)return null;const l=sn(i),s=l.find(t=>t.rowIndex===r.rowIndex&&t.cellIndex===r.cellIndex),d=l.find(t=>t.rowIndex===o.rowIndex&&t.cellIndex===o.cellIndex);return s&&d?{anchorLocation:r,focusLocation:o,anchorCell:s,focusCell:d,tableBlock:i,tableLayout:l}:null}function HL(t){const e=(t,e)=>{const a=Fe(t.document),n=sa(t),r=a[Math.max(0,Math.min(n,a.length-1))];return r?"header"===e?r.header||[]:"footer"===e?r.footer||[]:r.blocks:[]},{resolveTableCellRangeSelection:a,resolveSelectedTableCells:n,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o}=function(t){return{resolveTableCellRangeSelection:e=>{var a,n,r,o,i;const l=e.selection,s=WL(e,t);if(!s||s.anchorLocation.rowIndex===s.focusLocation.rowIndex&&s.anchorLocation.cellIndex===s.focusLocation.cellIndex)return null==(a=t.logger)||a.debug(`resolveTableCellRangeSelection: no expansion (anchor=${l.anchor.paragraphId} focus=${l.focus.paragraphId})`),null;const d=Math.min(s.anchorLocation.rowIndex,s.focusLocation.rowIndex),c=Math.max(s.anchorLocation.rowIndex,s.focusLocation.rowIndex),h=Math.min(s.anchorLocation.cellIndex,s.focusLocation.cellIndex),p=Math.max(s.anchorLocation.cellIndex,s.focusLocation.cellIndex);null==(n=t.logger)||n.info(`resolveTableCellRangeSelection: expanding r${s.anchorLocation.rowIndex}:c${s.anchorLocation.cellIndex}->r${s.focusLocation.rowIndex}:c${s.focusLocation.cellIndex} (anchor=${l.anchor.paragraphId} focus=${l.focus.paragraphId}) range=[rows ${d}..${c}, cells ${h}..${p}]`);const u=PL(s.anchorCell,s.focusCell)<=0?s.anchorLocation:s.focusLocation,f=PL(s.anchorCell,s.focusCell)<=0?s.focusLocation:s.anchorLocation,g=null==(o=null==(r=s.tableBlock.rows[u.rowIndex])?void 0:r.cells[u.cellIndex])?void 0:o.blocks[0],m=null==(i=s.tableBlock.rows[f.rowIndex])?void 0:i.cells[f.cellIndex],v=null==m?void 0:m.blocks[m.blocks.length-1];return g&&v?{anchor:Ve(g,0),focus:Ve(v,Ce(v).length)}:null},resolveSelectedTableCells:e=>{const a=WL(e,t);if(!a)return null;const n=Math.min(a.anchorCell.visualRowIndex,a.focusCell.visualRowIndex),r=Math.max(a.anchorCell.visualRowIndex+a.anchorCell.rowSpan-1,a.focusCell.visualRowIndex+a.focusCell.rowSpan-1),o=Math.min(a.anchorCell.visualColumnIndex,a.focusCell.visualColumnIndex),i=Math.max(a.anchorCell.visualColumnIndex+a.anchorCell.colSpan-1,a.focusCell.visualColumnIndex+a.focusCell.colSpan-1),l=a.tableLayout.filter(t=>t.visualRowIndex<=r&&t.visualRowIndex+t.rowSpan-1>=n&&t.visualColumnIndex<=i&&t.visualColumnIndex+t.colSpan-1>=o);return{blockIndex:a.anchorLocation.blockIndex,cells:l,zone:a.anchorLocation.zone}},resolveHorizontalTableCellRange:e=>{const a=WL(e,t);if(!a||a.anchorCell.visualRowIndex!==a.focusCell.visualRowIndex)return null;const n=PL(a.anchorCell,a.focusCell);if(0===n)return null;const r=n<=0?a.anchorLocation:a.focusLocation,o=n<=0?a.focusLocation:a.anchorLocation;return{blockIndex:a.anchorLocation.blockIndex,rowIndex:r.rowIndex,startCellIndex:r.cellIndex,endCellIndex:o.cellIndex,zone:a.anchorLocation.zone}},resolveVerticalTableCellRange:e=>{const a=WL(e,t);if(!a||a.anchorLocation.cellIndex!==a.focusLocation.cellIndex)return null;const n=Math.min(a.anchorCell.visualRowIndex,a.focusCell.visualRowIndex),r=Math.max(a.anchorCell.visualRowIndex,a.focusCell.visualRowIndex);return n===r?null:{blockIndex:a.anchorLocation.blockIndex,startRowIndex:n,endRowIndex:r,cellIndex:a.anchorLocation.cellIndex,zone:a.anchorLocation.zone}}}}({getTargetBlocks:e,logger:t.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:d,canSplitSelectedTableCellVertically:c,canSplitSelectedTable:h,canEditSelectedTableRow:p,canEditSelectedTableColumn:u}=function(t){const e=e=>{const a=t.resolveHorizontalTableCellRange(e);return Boolean(a&&a.endCellIndex>a.startCellIndex)},a=e=>{var a;const n=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!n)return!1;const r=t.getTargetBlocks(e,n.zone)[n.blockIndex];if(!r||"table"!==r.type)return!1;const o=null==(a=r.rows[n.rowIndex])?void 0:a.cells[n.cellIndex];return Boolean(((null==o?void 0:o.colSpan)??1)>1)},n=e=>{var a;const n=t.resolveVerticalTableCellRange(e);if(!n)return!1;const r=t.getTargetBlocks(e,n.zone)[n.blockIndex];if(!r||"table"!==r.type)return!1;for(let t=n.startRowIndex;t<=n.endRowIndex;t+=1){const e=null==(a=r.rows[t])?void 0:a.cells[n.cellIndex];if(!e||"continue"===e.vMerge||1!==e.blocks.length)return!1}return!0},r=e=>{var a;const n=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!n)return!1;const r=t.getTargetBlocks(e,n.zone)[n.blockIndex];if(!r||"table"!==r.type)return!1;const o=null==(a=r.rows[n.rowIndex])?void 0:a.cells[n.cellIndex];return Boolean(((null==o?void 0:o.rowSpan)??1)>1&&"restart"===(null==o?void 0:o.vMerge))};return{canMergeSelectedTableCells:e,canSplitSelectedTableCell:a,canMergeSelectedTableRows:n,canMergeSelectedTable:t=>e(t)||n(t),canSplitSelectedTableCellVertically:r,canSplitSelectedTable:t=>a(t)||r(t),canEditSelectedTableRow:e=>{const a=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!a)return!1;const n=t.getTargetBlocks(e,a.zone)[a.blockIndex];return Boolean(n&&"table"===n.type)},canEditSelectedTableColumn:e=>{const a=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!a)return!1;const n=t.getTargetBlocks(e,a.zone)[a.blockIndex];return!(!n||"table"!==n.type)&&LL(n)>1}}}({getTargetBlocks:e,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o}),{mergeSelectedTableCells:f,mergeSelectedTableRows:g,mergeSelectedTable:m,splitSelectedTableCellVertically:v,splitSelectedTableCell:b,splitSelectedTable:y}=function(t){const e=e=>{const a=t.resolveHorizontalTableCellRange(e);if(!a)return e;const n=t.getTargetBlocks(e,a.zone).map(Rx),r=n[a.blockIndex];if(!r||"table"!==r.type)return e;const o=r.rows[a.rowIndex];if(!o)return e;const i=o.cells.slice(a.startCellIndex,a.endCellIndex+1);if(i.length<2)return e;const l={...i[0],colSpan:i.reduce((t,e)=>t+Math.max(1,e.colSpan??1),0),blocks:i.flatMap(t=>t.blocks.map(t=>Rx(t)))};o.cells.splice(a.startCellIndex,i.length,l);const s=l.blocks[0];return s?{...OL(e,n,a.zone),selection:{anchor:Ve(s,0),focus:Ve(s,0)}}:e},a=e=>{const a=t.resolveVerticalTableCellRange(e);if(!a)return e;const n=t.getTargetBlocks(e,a.zone).map(Rx),r=n[a.blockIndex];if(!r||"table"!==r.type)return e;const o=[];for(let t=a.startRowIndex;t<=a.endRowIndex;t+=1){const n=r.rows[t],i=null==n?void 0:n.cells[a.cellIndex];if(!n||!i||"continue"===i.vMerge||1!==i.blocks.length)return e;o.push(i)}if(o.length<2)return e;const i=Math.max(1,o[0].colSpan??1);if(!o.every(t=>Math.max(1,t.colSpan??1)===i))return e;const l={...o[0],rowSpan:o.length,vMerge:"restart",blocks:o.flatMap(t=>t.blocks.map(t=>Rx(t)))};r.rows[a.startRowIndex].cells[a.cellIndex]=l;for(let t=a.startRowIndex+1;t<=a.endRowIndex;t+=1){const e=Ia([Sa("")],i);e.blocks=[],e.vMerge="continue",r.rows[t].cells[a.cellIndex]=e}const s=l.blocks[0];return s?{...OL(e,n,a.zone),selection:{anchor:Ve(s,0),focus:Ve(s,0)}}:e},n=e=>{var a;const n=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!n)return e;const r=t.getTargetBlocks(e,n.zone).map(Rx),o=r[n.blockIndex];if(!o||"table"!==o.type)return e;const i=null==(a=o.rows[n.rowIndex])?void 0:a.cells[n.cellIndex],l=Math.max(1,(null==i?void 0:i.rowSpan)??1);if(!i||l<=1||"restart"!==i.vMerge)return e;i.rowSpan=void 0,i.vMerge=void 0;const s=Math.max(1,i.colSpan??1);for(let t=1;t<l;t+=1){const e=o.rows[n.rowIndex+t];if(!e)break;const a=Ia([Sa("")],s);e.cells[n.cellIndex]=a}const d=i.blocks[0];return d?{...OL(e,r,n.zone),selection:{anchor:Ve(d,0),focus:Ve(d,0)}}:e},r=e=>{var a;const n=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!n)return e;const r=t.getTargetBlocks(e,n.zone).map(Rx),o=r[n.blockIndex];if(!o||"table"!==o.type)return e;const i=o.rows[n.rowIndex],l=null==i?void 0:i.cells[n.cellIndex],s=Math.max(1,(null==l?void 0:l.colSpan)??1);if(!i||!l||s<=1)return e;const d=[{...l,colSpan:1,blocks:l.blocks.map(t=>Rx(t))},...Array.from({length:s-1},()=>Ia([Sa("")]))];i.cells.splice(n.cellIndex,1,...d);const c=null==(a=d[0])?void 0:a.blocks[0];return c?{...OL(e,r,n.zone),selection:{anchor:Ve(c,0),focus:Ve(c,0)}}:e};return{mergeSelectedTableCells:e,mergeSelectedTableRows:a,mergeSelectedTable:n=>t.canMergeSelectedTableCells(n)?e(n):t.canMergeSelectedTableRows(n)?a(n):n,splitSelectedTableCellVertically:n,splitSelectedTableCell:r,splitSelectedTable:e=>t.canSplitSelectedTableCellVertically(e)?n(e):t.canSplitSelectedTableCell(e)?r(e):e}}({getTargetBlocks:e,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o,canMergeSelectedTableCells:i,canMergeSelectedTableRows:s,canSplitSelectedTableCell:l,canSplitSelectedTableCellVertically:c}),{insertSelectedTableRow:M,deleteSelectedTableRow:x,insertSelectedTableColumn:w,deleteSelectedTableColumn:S}=function(t){return{insertSelectedTableRow:(e,a)=>{var n,r;const o=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!o)return e;const i=t.getTargetBlocks(e,o.zone).map(Rx),l=i[o.blockIndex];if(!l||"table"!==l.type)return e;const s=l.rows[o.rowIndex];if(!s)return e;const d=Math.max(0,Math.min(l.rows.length,o.rowIndex+(a>0?1:0)));let c;if(l.rows.some(t=>t.cells.some(t=>Math.max(1,t.rowSpan??1)>1||void 0!==t.vMerge))){const t=sn(l),a=t.find(t=>t.rowIndex===o.rowIndex&&t.cellIndex===o.cellIndex),r=t.filter(t=>t.rowIndex===o.rowIndex);c=Ta((r.length>0?r:t.filter(t=>t.rowIndex===Math.max(0,o.rowIndex-1))).map(e=>{const a=t.find(t=>t.visualColumnIndex===e.visualColumnIndex&&t.visualRowIndex<d&&t.visualRowIndex+t.rowSpan>d);if(a){a.cell.rowSpan=Math.max(1,a.cell.rowSpan??1)+1,a.cell.vMerge="restart";const t=Ia([Sa("")],e.colSpan);return t.blocks=[],t.vMerge="continue",t}return Ia([Sa("")],e.colSpan)})),l.rows.splice(d,0,c);const s=(null==a?void 0:a.visualColumnIndex)??o.cellIndex,h=zL(c,s),p=(null==h?void 0:h.blocks[0])??(null==(n=c.cells.find(t=>"continue"!==t.vMerge&&t.blocks[0]))?void 0:n.blocks[0])??NL(l);return p?{...OL(e,i,o.zone),selection:{anchor:Ve(p,0),focus:Ve(p,0)}}:OL(e,i,o.zone)}c=Ta(s.cells.map(t=>Ia([Sa("")],Math.max(1,t.colSpan??1)))),l.rows.splice(d,0,c);const h=c.cells[Math.min(o.cellIndex,c.cells.length-1)],p=(null==h?void 0:h.blocks[0])??(null==(r=c.cells.find(t=>"continue"!==t.vMerge&&t.blocks[0]))?void 0:r.blocks[0])??NL(l);return p?{...OL(e,i,o.zone),selection:{anchor:Ve(p,0),focus:Ve(p,0)}}:OL(e,i,o.zone)},deleteSelectedTableRow:e=>{const a=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!a)return e;const n=t.getTargetBlocks(e,a.zone).map(Rx),r=n[a.blockIndex];if(!r||"table"!==r.type)return e;if(r.rows.length<=1)return e;const o=r.rows[a.rowIndex];if(!o)return e;if(o.cells.some(t=>"continue"!==t.vMerge&&Math.max(1,t.rowSpan??1)>1))return e;const i=r.rows.some(t=>t.cells.some(t=>Math.max(1,t.rowSpan??1)>1||void 0!==t.vMerge)),l=i?sn(r).find(t=>t.rowIndex===a.rowIndex&&t.cellIndex===a.cellIndex):null;if(i){const t=sn(r);for(const e of t)e.visualRowIndex<a.rowIndex&&e.visualRowIndex+e.rowSpan>a.rowIndex&&(e.cell.rowSpan=Math.max(1,e.cell.rowSpan??1)-1,e.cell.rowSpan<=1?(e.cell.rowSpan=void 0,e.cell.vMerge=void 0):e.cell.vMerge="restart")}r.rows.splice(a.rowIndex,1);const s=r.rows[Math.min(a.rowIndex,r.rows.length-1)],d=s?zL(s,Math.min((null==l?void 0:l.visualColumnIndex)??a.cellIndex,Math.max(0,RL(s)-1))):null,c=(null==d?void 0:d.blocks[0])??NL(r);return c?{...OL(e,n,a.zone),selection:{anchor:Ve(c,0),focus:Ve(c,0)}}:OL(e,n,a.zone)},insertSelectedTableColumn:(e,a)=>{var n;const r=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!r)return e;const o=t.getTargetBlocks(e,r.zone).map(Rx),i=o[r.blockIndex];if(!i||"table"!==i.type)return e;if(i.rows.some(t=>t.cells.some(t=>Math.max(1,t.colSpan??1)>1))){const t=sn(i).find(t=>t.rowIndex===r.rowIndex&&t.cellIndex===r.cellIndex),n=((null==t?void 0:t.visualColumnIndex)??r.cellIndex)+(a>0?Math.max(1,(null==t?void 0:t.colSpan)??1):0);for(const e of i.rows){const t=[];let a=0,r=!1;for(const o of e.cells){const e=Math.max(1,o.colSpan??1);!r&&n<=a&&(t.push(Ia([Sa("")])),r=!0),!r&&a<n&&n<a+e?(t.push({...o,colSpan:e+1}),r=!0):t.push(o),a+=e}r||t.push(Ia([Sa("")])),e.cells=t}const l=i.rows[r.rowIndex],s=l?zL(l,n):null,d=(null==s?void 0:s.blocks[0])??NL(i);return d?{...OL(e,o,r.zone),selection:{anchor:Ve(d,0),focus:Ve(d,0)}}:OL(e,o,r.zone)}const l=Math.max(0,Math.min((null==(n=i.rows[0])?void 0:n.cells.length)??0,r.cellIndex+(a>0?1:0)));for(const t of i.rows)t.cells.splice(l,0,Ia([Sa("")]));const s=i.rows[r.rowIndex],d=null==s?void 0:s.cells[l],c=(null==d?void 0:d.blocks[0])??NL(i);return c?{...OL(e,o,r.zone),selection:{anchor:Ve(c,0),focus:Ve(c,0)}}:OL(e,o,r.zone)},deleteSelectedTableColumn:e=>{var a;const n=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!n)return e;const r=t.getTargetBlocks(e,n.zone).map(Rx),o=r[n.blockIndex];if(!o||"table"!==o.type)return e;if(LL(o)<=1)return e;if(o.rows.some(t=>t.cells.some(t=>Math.max(1,t.colSpan??1)>1))){const t=sn(o).find(t=>t.rowIndex===n.rowIndex&&t.cellIndex===n.cellIndex),a=(null==t?void 0:t.visualColumnIndex)??n.cellIndex;for(const e of o.rows){const t=[];let n=0;for(const r of e.cells){const e=Math.max(1,r.colSpan??1);a>=n&&a<n+e?e>1&&t.push({...r,colSpan:e-1>1?e-1:void 0}):t.push(r),n+=e}e.cells=t}const i=o.rows[n.rowIndex],l=i&&zL(i,Math.min(a,Math.max(0,RL(i)-1))),s=(null==l?void 0:l.blocks[0])??NL(o);return s?{...OL(e,r,n.zone),selection:{anchor:Ve(s,0),focus:Ve(s,0)}}:OL(e,r,n.zone)}if((null==(a=o.rows[0])?void 0:a.cells.length)<=1)return e;for(const t of o.rows)t.cells.splice(n.cellIndex,1);const i=o.rows[n.rowIndex],l=null==i?void 0:i.cells[Math.min(n.cellIndex,i.cells.length-1)],s=(null==l?void 0:l.blocks[0])??NL(o);return s?{...OL(e,r,n.zone),selection:{anchor:Ve(s,0),focus:Ve(s,0)}}:OL(e,r,n.zone)}}}({getTargetBlocks:e}),{withExpandedTableCellSelection:A,applySelectionAwareTextCommand:I,applySelectionAwareParagraphCommand:T}=function(t){const e=e=>{const a=t.resolveTableCellRangeSelection(e);return a?t.applySelectionToStatePreservingStructure(e,a):e},a=(a,n)=>{t.applyTransactionalState(r=>{var o,i,l;const s=t.resolveSelectedTableCells(r);if(!s||s.cells.length<=1){const i=e(r);return i!==r&&(null==(o=t.logger)||o.info(`${n}: expanded selection to ${i.selection.anchor.paragraphId}[${i.selection.anchor.offset}]..${i.selection.focus.paragraphId}[${i.selection.focus.offset}]`)),a(i)}const{blockIndex:d,cells:c,zone:h}=s;null==(i=t.logger)||i.info(`${n}: multi-cell selection in table block ${d} (${c.length} cells) in zone ${h}`);const p=[],u=[];for(const t of c)p.push(...t.cell.blocks),u.push(t.cell.blocks.length);if(0===p.length)return r;const f={...r,document:Ea(p,void 0,void 0,void 0,void 0,r.document.assets),selection:{anchor:Ve(p[0],0),focus:Ve(p[p.length-1],Ce(p[p.length-1]).length)}},g=ha(a(f)),m=t.getTargetBlocks(r,h),v=Rx(m[d]);if(!v)return r;const b=m.map((t,e)=>e===d?v:t),y=v;let M=0;for(let t=0;t<c.length;t+=1){const e=c[t],a=u[t],n=g.slice(M,M+a);M+=a;const r=null==(l=y.rows[e.rowIndex])?void 0:l.cells[e.cellIndex];r&&(r.blocks=n)}return OL(r,b,h)})};return{withExpandedTableCellSelection:e,applySelectionAwareTextCommand:t=>{a(t,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:t=>{a(t,"applySelectionAwareParagraphCommand")}}}({applyTransactionalState:t.applyTransactionalState,applySelectionToStatePreservingStructure:t.applySelectionToStatePreservingStructure,getTargetBlocks:e,resolveTableCellRangeSelection:a,resolveSelectedTableCells:n,logger:t.logger});return{resolveTableCellRangeSelection:a,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o,canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:d,canSplitSelectedTableCellVertically:c,canSplitSelectedTable:h,canEditSelectedTableRow:p,canEditSelectedTableColumn:u,mergeSelectedTableCells:f,mergeSelectedTableRows:g,mergeSelectedTable:m,splitSelectedTableCellVertically:v,splitSelectedTableCell:b,splitSelectedTable:y,insertSelectedTableRow:M,deleteSelectedTableRow:x,insertSelectedTableColumn:w,deleteSelectedTableColumn:S,getRowVisualWidth:RL,getTableVisualWidth:LL,findCellAtVisualColumn:zL,findFirstNavigableParagraphInTable:NL,updateBlocksInCurrentSection:OL,resolveAdjacentTableCellPosition:qL,applyTableAwareParagraphEdit:(t,a)=>((t,e,a)=>{var n;const r=_e(t.document,t.selection.focus.paragraphId,sa(t));if(!r||t.selection.anchor.paragraphId!==t.selection.focus.paragraphId)return a(t);const o=r.zone,i=e(t,o),l=Rx(i[r.blockIndex]);if(!l||"table"!==l.type)return a(t);const s=i.map((t,e)=>e===r.blockIndex?l:t),d=null==(n=l.rows[r.rowIndex])?void 0:n.cells[r.cellIndex];if(!d)return a(t);const c=a({...t,document:Ea(d.blocks,void 0,void 0,void 0,void 0,t.document.assets),selection:{anchor:{...t.selection.anchor},focus:{...t.selection.focus}}}),h=Je(c.document).filter(t=>"paragraph"===t.type);return d.blocks.splice(0,d.blocks.length,...h),{...OL(t,s,o),selection:c.selection}})(t,e,a),withExpandedTableCellSelection:A,applySelectionAwareTextCommand:I,applySelectionAwareParagraphCommand:T,insertTableCommand:(e,a)=>{var n;null==(n=t.logger)||n.info(`insertTableCommand: ${e}x${a}`),t.applyTransactionalState(t=>function(t,e,a){const n=100/Math.max(1,a)+"%",r=[];for(let g=0;g<e;g+=1){const t=[];for(let e=0;e<a;e+=1)t.push({...Ia([Sa("")]),style:{width:n}});r.push(Ta(t))}const o={...Ca(r),style:{width:"100%"}},i=ua(t,t.selection.focus),l=Be(t.document),s=sa(t),d=da(t),c=t=>{const e=t.findIndex(t=>t.id===i.paragraphId||"paragraph"!==t.type&&Ge(t).some(t=>t.id===i.paragraphId));return-1===e?{nextBlocks:t,found:!1}:{nextBlocks:[...t.slice(0,e+1),o,...t.slice(e+1)],found:!0}},h=l[s];if(!h)return t;const p={...h};let u=!1;if("header"===d){const t=c(h.header??[]);p.header=t.nextBlocks,u=t.found}else if("footer"===d){const t=c(h.footer??[]);p.footer=t.nextBlocks,u=t.found}else{const t=c(h.blocks);p.blocks=t.nextBlocks,u=t.found}if(!u)return t;const f=[...l];return f[s]=p,{...t,document:{...t.document,sections:f},selection:KT(Ve(o.rows[0].cells[0].blocks[0],0))}}(t,e,a),{mergeKey:"insertTable"}),t.focusInput()}}}function UL(t,e){let a=null;const n=(t,e,a)=>{const n=ha(t).find(t=>t.id===e);return n?{anchor:Ve(n,a),focus:Ve(n,a+1)}:null},r=(t,e)=>({...t,selection:{anchor:{...e.anchor},focus:{...e.focus}}}),o=o=>{var i;const l=a;if(!l)return;const s=(null==(i=e.zoomFactor)?void 0:i.call(e))??1,d=(o.clientX-l.startClientX)/s,c=(o.clientY-l.startClientY)/s,h=t.getMaxWidth(e.state,l.paragraphId),{width:p,height:u}=function(t,e,a,n,r){const o=ly(t.handleDirection,"x"),i=ly(t.handleDirection,"y"),l=0===o?t.startWidth:t.startWidth+e*o,s=0===i?t.startHeight:t.startHeight+a*i;let d=iy(l,oy,r),c=iy(s,oy);if(!n)return{width:d,height:c};const h=t.aspectRatio||1,p=0!==o;if(p&&0!==i){const e=d/t.startWidth,a=c/t.startHeight,n=Math.abs(e-1)>=Math.abs(a-1)?e:a;return d=iy(t.startWidth*n,oy,r),c=iy(d/h,oy),{width:d,height:c}}return p?(d=iy(d,oy,r),c=iy(d/h,oy),{width:d,height:c}):(c=iy(c,oy),d=iy(c*h,oy,r),c=iy(d/h,oy),{width:d,height:c})}(l,d,c,o.shiftKey,h),f=n(e.state,l.paragraphId,l.paragraphOffset);f?e.applyState(t.applyResize(r(e.state,f),p,u,l.handleDirection)):e.logger.warn(`${t.label} resize:missing paragraph`,l)},i=()=>{const t=a;t&&e.updateHistoryState(a=>({...a,undoStack:[...a.undoStack,e.cloneState(t.initialState)],redoStack:[]})),l(),e.focusInput()},l=()=>{a=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",i)};return{start:(l,s,d,c,h)=>{const p=n(h,l,s);if(!p)return;const u=t.getSelected(r(h,p));u&&(a={paragraphId:l,paragraphOffset:s,handleDirection:d,startClientX:c.clientX,startClientY:c.clientY,startWidth:u.width,startHeight:u.height,aspectRatio:u.width/u.height,initialState:e.cloneState(h)},window.addEventListener("mousemove",o),window.addEventListener("mouseup",i))},stop:l}}function FL(t,e){let a=null;const n=n=>{const r=a;if(!r)return;let o=((180*Math.atan2(n.clientY-r.centerY,n.clientX-r.centerX)/Math.PI+90)%360+360)%360;n.shiftKey&&(o=15*Math.round(o/15)%360);const i=((t,e,a)=>{const n=ha(t).find(t=>t.id===e);return n?{anchor:Ve(n,a),focus:Ve(n,a+1)}:null})(e.state,r.paragraphId,r.paragraphOffset);i?e.applyState(t.applyRotate(((t,e)=>({...t,selection:{anchor:{...e.anchor},focus:{...e.focus}}}))(e.state,i),o)):e.logger.warn(`${t.label} rotate:missing paragraph`,r)},r=()=>{const t=a;t&&e.updateHistoryState(a=>({...a,undoStack:[...a.undoStack,e.cloneState(t.initialState)],redoStack:[]})),o(),e.focusInput()},o=()=>{a=null,window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",r)};return{start:(t,o,i,l)=>{const s=i.currentTarget.closest(".oasis-editor-selection-overlay");if(!s)return;const d=s.getBoundingClientRect();a={paragraphId:t,paragraphOffset:o,centerX:d.left+d.width/2,centerY:d.top+d.height/2,initialState:e.cloneState(l)},window.addEventListener("mousemove",n),window.addEventListener("mouseup",r)},stop:o}}function BL(t){const[e,a]=y(!1),[n,r]=y(null),[o,i]=y({x:0,y:0}),[l,s]=y(null);let d=null,c=null,h=null;const p=t=>{const e=va(t);if(e.isCollapsed||e.startIndex!==e.endIndex||e.endParagraphOffset-e.startParagraphOffset!==1)return null;const a=ha(t)[e.startIndex];if(!a)return null;let n=0;for(const r of a.runs){const o=n;if(n+=r.text.length,r.image&&1===r.text.length&&o===e.startParagraphOffset)return{paragraph:a,run:r,startOffset:o,width:r.image.width,height:r.image.height,src:Ue(t.document,r.image.src)}}return null},u=(e,a)=>t.resolvePositionAtSurfacePoint(e,a),f=()=>{h&&(h.remove(),h=null),document.body.style.cursor="",c=null,d=null,a(!1),r(null),s(null),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b)},g=UL({label:"image",getSelected:t=>p(t),applyResize:(t,e,a)=>function(t,e,a){const n=lL(t);if(!n)return t;const r=ha(t),{paragraphIndex:o,run:i}=n,l=r.map((t,n)=>n!==o?TT(t):{...TT(t),runs:t.runs.map(t=>t.id===i.id&&t.image?{...t,image:{...t.image,width:Math.max(24,Math.round(e)),height:Math.max(24,Math.round(a))}}:IT(t))});return ZT(t,l,YT(l,va(t)))}(t,e,a),getMaxWidth:(e,a)=>uL(t.surfaceRef(),e.document,a,e.activeSectionIndex??0)},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger,zoomFactor:t.zoomFactor}),m=FL({label:"image",applyRotate:(t,e)=>sL(t,e)},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger}),v=e=>{let n=d;if(!n){const r=c;if(!r)return;if(Math.abs(e.clientX-r.startClientX)+Math.abs(e.clientY-r.startClientY)<4)return;n={paragraphId:r.paragraphId,paragraphOffset:r.paragraphOffset,src:r.src,width:r.width,height:r.height,offsetX:r.offsetX,offsetY:r.offsetY},d=n,c=null,a(!0),h||(h=document.createElement("style"),h.setAttribute("data-oasis-image-drag-cursor",""),h.textContent="*, *::before, *::after { cursor: grabbing !important; }",document.head.appendChild(h)),t.logger.info(`image drag:start ${n.paragraphId}@${n.paragraphOffset} client=(${e.clientX},${e.clientY})`)}i({x:e.clientX,y:e.clientY}),r({...n}),s(u(e.clientX,e.clientY))},b=e=>{const a=d;if(a||c){if(a){const n=u(e.clientX,e.clientY);n?(t.logger.info(`image drag:done ${a.paragraphId} -> ${n.paragraphId}:${n.runId}[${n.offset}]`),t.applyTransactionalState(t=>pL(t,n),{mergeKey:"moveImage"})):t.logger.warn(`image drag:cancel ${a.paragraphId} no target at (${e.clientX},${e.clientY})`)}f(),t.focusInput()}else t.focusInput()},M=(e,n,o,l)=>{const h=o.currentTarget,u=l?{left:l.left,top:l.top,width:l.width,height:l.height}:null==h?void 0:h.getBoundingClientRect();if(!u)return;const f=p(t.state);c={paragraphId:e,paragraphOffset:n,startClientX:o.clientX,startClientY:o.clientY,src:(null==f?void 0:f.src)??"",width:(null==f?void 0:f.width)??u.width,height:(null==f?void 0:f.height)??u.height,offsetX:o.clientX-u.left,offsetY:o.clientY-u.top},d=null,i({x:o.clientX,y:o.clientY}),a(!1),r(null),s(null),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b)};return{dragging:e,draggedImageInfo:n,mousePos:o,dropTargetPos:l,getSelectedImageInfo:p,startImageDrag:M,stopImageDrag:()=>{f()},stopImageResize:g.stop,stopImageRotate:m.stop,handleImageMouseDown:(e,a,n)=>{n.preventDefault(),n.stopPropagation();const r=Je(t.state.document).find(t=>t.id===e);r&&t.applyState(YC(t.state,{anchor:Ve(r,a),focus:Ve(r,a+1)})),M(e,a,n),t.focusInputAfterPointerSelection()},handleImageResizeHandleMouseDown:(e,a,n,r)=>{r.preventDefault(),r.stopPropagation(),g.start(e,a,n,r,t.state)},handleImageRotateHandleMouseDown:(e,a,n)=>{n.preventDefault(),n.stopPropagation(),m.start(e,a,n,t.state)}}}function GL(t){const[e,a]=y(void 0),n=()=>{a(void 0)};x(()=>{ma(t.state().selection)||n()});const r=()=>{const a=ep(t.state()),n=e();return ma(t.state().selection)&&n?{...a,bold:n.bold??a.bold,italic:n.italic??a.italic,underline:n.underline??a.underline,underlineStyle:void 0!==n.underlineStyle&&null!==n.underlineStyle?String(n.underlineStyle):a.underlineStyle,strike:n.strike??a.strike,superscript:n.superscript??a.superscript,subscript:n.subscript??a.subscript,fontFamily:n.fontFamily??a.fontFamily,fontSize:void 0!==n.fontSize&&null!==n.fontSize?String(n.fontSize):a.fontSize,color:n.color??a.color,highlight:n.highlight??a.highlight,textShading:n.shading??a.textShading,link:n.link??a.link}:a};return{pendingCaretTextStyle:e,clearPendingCaretTextStyle:n,toolbarStyleState:r,applyToolbarValueStyleCommand:(e,n)=>{if(ma(t.state().selection))return t.logger.info(`setPendingStyle:${e}=${JSON.stringify(n)}`),t.clearPreferredColumn(),t.resetTransactionGrouping(),((t,e)=>{a(a=>{const n={...a??{}};return null==e||""===e?delete n[t]:n[t]=e,Object.keys(n).length>0?n:void 0})})(e,n),void t.focusInput();t.commandsController().applyValueStyleCommand(e,n)},applyToolbarBooleanStyleCommand:e=>{if(ma(t.state().selection)){const n=!r()[e];return t.logger.info(`setPendingStyle:${e}=${JSON.stringify(n)}`),t.clearPreferredColumn(),t.resetTransactionGrouping(),((t,e)=>{a(a=>{const n={...a??{}};return n[t]=e,"superscript"===t&&e&&(n.subscript=!1),"subscript"===t&&e&&(n.superscript=!1),n})})(e,n),void t.focusInput()}t.commandsController().applyBooleanStyleCommand(e)}}}function ZL(t){const[e,a]=y(""),[n,r]=y(""),[o,i]=y({matchCase:!1,wholeWord:!1}),[l,s]=y([]),[d,c]=y(-1),[h,p]=y(!1);x(A([()=>t.state.document,e,o],([t,e,a])=>{const n=function(t,e,a={}){if(!e)return[];const n=[],r=Je(t),{matchCase:o=!1,wholeWord:i=!1}=a,l=o?"g":"gi";let s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i&&(s=`\\b${s}\\b`);const d=new RegExp(s,l);return r.forEach((t,e)=>{const a=Ce(t);let r;for(d.lastIndex=0;null!==(r=d.exec(a));){const a=r.index,o=r.index+r[0].length;n.push({anchor:Ve(t,a),focus:Ve(t,o),paragraphIndex:e}),r.index===d.lastIndex&&d.lastIndex++}}),n}(t,e,a);s(n),0===n.length?c(-1):(d()>=n.length||-1===d())&&c(0)}));const u=e=>{const a=l()[e];a&&t.applyState(YC(t.state,{anchor:a.anchor,focus:a.focus}))};return{searchTerm:e,setSearchTerm:a,replaceTerm:n,setReplaceTerm:r,findOptions:o,setFindOptions:i,matches:l,currentIndex:d,findNext:()=>{const t=l().length;if(0===t)return;const e=(d()+1)%t;c(e),u(e)},findPrevious:()=>{const t=l().length;if(0===t)return;const e=(d()-1+t)%t;c(e),u(e)},replace:()=>{if(0===l().length||-1===d())return;const e=l()[d()];t.applyTransactionalState(t=>aC(YC(t,{anchor:e.anchor,focus:e.focus}),n()),{mergeKey:"findReplace"})},replaceAll:()=>{const e=l();0!==e.length&&(t.applyTransactionalState(t=>{let a=t;for(let r=e.length-1;r>=0;r--){const t=e[r];a=YC(a,{anchor:t.anchor,focus:t.focus}),a=aC(a,n())}return a},{mergeKey:"findReplaceAll"}),p(!1),t.focusInput())},isOpen:h,setIsOpen:p}}function DL(t,e,a,n,r,o){const i=t+a,l=e+n;return 1e3*(o<e?e-o:o>l?o-l:0)+(r<t?t-r:r>i?r-i:0)}function KL(t,e,a){if(0===t.slots.length)return{offset:t.startOffset,score:Number.POSITIVE_INFINITY};let n=t.slots[0].offset,r=Number.POSITIVE_INFINITY,o=t.slots[0].left,i=t.slots[0].top,l=t.slots[0].height;for(const s of t.slots){const t=1e3*(a<s.top?s.top-a:a>s.top+s.height?a-(s.top+s.height):0)+Math.abs(e-s.left);t<r&&(r=t,n=s.offset,o=s.left,i=s.top,l=s.height)}return{offset:n,score:r,slotLeft:o,slotTop:i,slotHeight:l}}function jL(t,e,a){let n=t.startOffset,r=Number.POSITIVE_INFINITY;for(const o of t.lines){const{offset:t,score:i}=KL(o,e,a);i<r&&(r=i,n=t)}return Math.max(t.startOffset,Math.min(n,t.endOffset))}function XL(t,e,a){return t>=a.left&&t<=a.left+a.width&&e>=a.top&&e<=a.top+a.height}function JL(t){var e,a,n;const{snapshot:r,state:o}=t,i=t.pierce??!1,l=t.zoomFactor&&t.zoomFactor>0?t.zoomFactor:1,s=r.surfaceRect,d=s.left+(t.clientX-s.left)/l,c=s.top+(t.clientY-s.top)/l,h=function(t,e,a){if(0===t.length)return null;let n=t[0],r=Number.POSITIVE_INFINITY;for(const o of t){const t=DL(o.left,o.top,o.width,o.height,e,a);t<r&&(r=t,n=o)}return n}(r.pages,d,c);if(!h)return null;const p=function(t,e){const a=e-t.top;return a<t.bodyTop?"header":void 0!==t.footnoteSeparatorTop&&a>=t.footnoteSeparatorTop&&a<(t.footerTop??t.height)?"footnote":a>=t.bodyBottom?"footer":"main"}(h,c),u=function(t,e,a,n,r,o){for(let i=t.floatingTextBoxes.length-1;i>=0;i-=1){const l=t.floatingTextBoxes[i];if(l.pageIndex===e&&l.zone===a&&(!l.behindDoc||o)&&n>=l.left&&n<=l.left+l.width&&r>=l.top&&r<=l.top+l.height)return l}return null}(r,h.index,p,d,c,i);if(u){const t=r.paragraphsById.get(u.paragraphId)??[],a=t.find(t=>t.pageIndex===h.index&&t.zone===p&&u.startOffset>=t.startOffset&&u.startOffset<=t.endOffset)??t[0];if(a){const t=Math.max(a.startOffset,Math.min(u.startOffset,a.endOffset)),n=Ve(a.paragraph,t);return{zone:p,footnoteId:a.footnoteId,paragraphId:u.paragraphId,paragraphOffset:t,position:n,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:null==(e=a.tableCell)?void 0:e.anchorPosition,caretViewport:{left:u.left,top:u.top,height:u.height},textBox:{paragraphId:u.paragraphId,paragraphOffset:t,startOffset:u.startOffset,endOffset:u.endOffset,left:u.left,top:u.top,width:u.width,height:u.height}}}}const f=function(t,e,a,n,r,o){for(let i=t.floatingImages.length-1;i>=0;i-=1){const l=t.floatingImages[i];if(l.pageIndex===e&&l.zone===a&&(!l.behindDoc||o)&&XL(n,r,l))return l}for(const i of t.inlineImages)if(i.pageIndex===e&&i.zone===a&&XL(n,r,i))return i;return null}(r,h.index,p,d,c,i);if(f){const t=r.paragraphsById.get(f.paragraphId)??[],e=t.find(t=>t.pageIndex===h.index&&t.zone===p&&f.startOffset>=t.startOffset&&f.startOffset<=t.endOffset)??t[0];if(e){const t=Math.max(e.startOffset,Math.min(f.startOffset,e.endOffset)),n=Ve(e.paragraph,t);return{zone:p,footnoteId:e.footnoteId,paragraphId:f.paragraphId,paragraphOffset:t,position:n,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:null==(a=e.tableCell)?void 0:a.anchorPosition,caretViewport:{left:f.left,top:f.top,height:f.height},image:{paragraphId:f.paragraphId,paragraphOffset:t,startOffset:f.startOffset,endOffset:f.endOffset,left:f.left,top:f.top,width:f.width,height:f.height}}}}const g=function(t,e,a){if(0===t.length)return null;let n=null;for(const i of t)for(const t of i.lines){const r=t.top-2,o=t.top+t.height+2;if(a<r||a>o)continue;const{offset:l,score:s,slotLeft:d,slotTop:c,slotHeight:h}=KL(t,e,a);(!n||s<n.score)&&(n={paragraph:i,offset:l,score:s,caretViewport:void 0!==d&&void 0!==c&&void 0!==h?{left:d,top:c,height:h}:void 0})}if(n)return{paragraph:n.paragraph,offset:n.offset,caretViewport:n.caretViewport};let r=null,o=Number.POSITIVE_INFINITY;for(const i of t){const t=DL(i.left,i.top,Math.max(1,i.width),Math.max(1,i.height),e,a);t<o&&(o=t,r=i)}return r?{paragraph:r,offset:jL(r,e,a),caretViewport:{left:r.left,top:r.top,height:Math.max(16,Math.min(32,r.height||24))}}:null}(r.paragraphs.filter(t=>t.pageIndex===h.index&&t.zone===p),d,c);if(!g){const t=o.selection.focus.paragraphId,e=o.selection.focus.offset,a=function(t,e,a,n,r){const o=t.unsupportedRegions.find(t=>t.pageIndex===e&&t.zone===a&&n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height);return(null==o?void 0:o.reason)??null}(r,h.index,p,d,c);return{zone:p,paragraphId:t,paragraphOffset:e,position:{...o.selection.focus},source:"canvas-layout",resolvedFromParagraph:!1,missReason:a??"zone-without-paragraph"}}const m=g.paragraph,v=Math.max(0,Math.min(g.offset,m.textLength)),b=Ve(m.paragraph,v);return{zone:p,footnoteId:m.footnoteId,paragraphId:m.paragraphId,paragraphOffset:v,position:b,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:null==(n=m.tableCell)?void 0:n.anchorPosition,caretViewport:g.caretViewport}}function YL(t){let e=null;return{resolveSurfaceHitAtPoint:(a,n,r={})=>{const o=t.surfaceRef(),i=t.viewportRef();if(!o)return null;const l=t.measuredBlockHeights(),s=t.measuredParagraphLayouts(),d=t.state(),c=(null==i?void 0:i.scrollTop)??0,h=(null==i?void 0:i.scrollLeft)??0,p=window.innerWidth,u=window.innerHeight,f=t.zoomFactor(),g=e&&e.documentRef===d.document&&e.measuredBlockHeightsRef===l&&e.measuredParagraphLayoutsRef===s&&e.surfaceRef===o&&e.viewportScrollTop===c&&e.viewportScrollLeft===h&&e.surfaceClientWidth===o.clientWidth&&e.surfaceClientHeight===o.clientHeight&&e.windowWidth===p&&e.windowHeight===u&&e.zoomFactor===f,m=g?e.snapshot:qs({surface:o,state:d,measuredBlockHeights:l,measuredParagraphLayouts:s,zoomFactor:f});if(g||(e={snapshot:m,documentRef:d.document,measuredBlockHeightsRef:l,measuredParagraphLayoutsRef:s,surfaceRef:o,viewportScrollTop:c,viewportScrollLeft:h,surfaceClientWidth:o.clientWidth,surfaceClientHeight:o.clientHeight,windowWidth:p,windowHeight:u,zoomFactor:f}),function(t){dT&&(hT=t?function(t){return{surfaceRect:{left:t.surfaceRect.left,top:t.surfaceRect.top,width:t.surfaceRect.width,height:t.surfaceRect.height},pages:(e=t.pages,e.map(t=>({index:t.index,left:t.left,top:t.top,width:t.width,height:t.height,bodyTop:t.bodyTop,bodyBottom:t.bodyBottom}))),paragraphs:t.paragraphs.map(t=>{return{paragraphId:t.paragraphId,paragraphIndex:t.paragraphIndex,zone:t.zone,pageIndex:t.pageIndex,startOffset:t.startOffset,endOffset:t.endOffset,textLength:t.textLength,left:t.left,top:t.top,width:t.width,height:t.height,lines:(e=t.lines,e.map(t=>{return{startOffset:t.startOffset,endOffset:t.endOffset,top:t.top,height:t.height,slots:(e=t.slots,e.map(t=>({offset:t.offset,left:t.left,top:t.top,height:t.height})))};var e})),tableCell:t.tableCell?{tableId:t.tableCell.tableId,rowIndex:t.tableCell.rowIndex,cellIndex:t.tableCell.cellIndex,left:t.tableCell.left,top:t.tableCell.top,width:t.tableCell.width,height:t.tableCell.height}:void 0,verticalMode:t.verticalMode};var e}),inlineImages:t.inlineImages.map(t=>({paragraphId:t.paragraphId,paragraphIndex:t.paragraphIndex,zone:t.zone,pageIndex:t.pageIndex,startOffset:t.startOffset,endOffset:t.endOffset,left:t.left,top:t.top,width:t.width,height:t.height})),inlineTextBoxes:t.inlineTextBoxes.map(t=>({paragraphId:t.paragraphId,paragraphIndex:t.paragraphIndex,zone:t.zone,pageIndex:t.pageIndex,startOffset:t.startOffset,endOffset:t.endOffset,left:t.left,top:t.top,width:t.width,height:t.height,rotation:t.rotation})),unsupportedRegions:t.unsupportedRegions.map(t=>({...t}))};var e}(t):null)}(m),!m)return gT(null),null;const v=JL({snapshot:m,state:d,clientX:a,clientY:n,pierce:r.pierce??!1,zoomFactor:f});return gT(v),v}}}const QL=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],_L=new Map;function $L(){return QL.map(t=>({...t}))}const tz=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function ez(t,e,a){const[n,r]=t,[o,i]=e,[l,s]=a,d=l-o,c=s-i,h=d*d+c*c;if(0===h)return Math.hypot(n-o,r-i);return Math.abs(d*(i-r)-c*(o-n))/Math.sqrt(h)}function az(t,e){if(t.length<3)return t.slice();let a=0,n=0;const r=t[0],o=t[t.length-1];for(let s=1;s<t.length-1;s+=1){const e=ez(t[s],r,o);e>a&&(a=e,n=s)}if(a<=e)return[r,o];const i=az(t.slice(0,n+1),e),l=az(t.slice(n),e);return[...i.slice(0,-1),...l]}function nz(t,e,a){let n=0;for(let s=0;s<t.length;s+=1)1===t[s]&&(n+=1);if(e<=0||a<=0||0===n||n/(e*a)>=.985)return $L();const r=function(t,e,a){const n=(n,r)=>n>=0&&n<e&&r>=0&&r<a&&1===t[r*e+n];let r=-1,o=-1;for(let h=0;h<a&&o<0;h+=1)for(let a=0;a<e;a+=1)if(1===t[h*e+a]){r=a,o=h;break}if(r<0)return[];const i=[];let l=r,s=o,d=6;const c=e*a*4;for(let h=0;h<c;h+=1){let t=!1;for(let e=1;e<=8;e+=1){const a=(d+e)%8,[r,o]=tz[a],c=l+r,h=s+o;if(n(c,h)){i.push([l,s]),d=(a+4)%8,l=c,s=h,t=!0;break}}if(!t){i.push([l,s]);break}if(l===r&&s===o&&i.length>1)break}return i}(t,e,a);if(r.length<3)return $L();const o=.012*Math.max(e,a);let i=az(r,o),l=o;for(;i.length>40;)l*=1.6,i=az(r,l);return i.length<3?$L():i.map(([t,n])=>({x:Math.min(1,Math.max(0,t/e)),y:Math.min(1,Math.max(0,n/a))}))}function rz(t){const e=t.src,a=_L.get(e);if(a)return a.map(t=>({...t}));const n=function(t){const e=t.naturalWidth||t.width,a=t.naturalHeight||t.height;if(!e||!a)return null;const n=Math.min(1,256/Math.max(e,a)),r=Math.max(1,Math.round(e*n)),o=Math.max(1,Math.round(a*n)),i=document.createElement("canvas");i.width=r,i.height=o;const l=i.getContext("2d",{willReadFrequently:!0});if(!l)return null;let s;l.drawImage(t,0,0,r,o);try{s=l.getImageData(0,0,r,o).data}catch{return null}const d=new Uint8Array(r*o);let c=0;for(let h=0;h<d.length;h+=1)s[4*h+3]>=128&&(d[h]=1,c+=1);return{mask:d,width:r,height:o,foreground:c}}(t);if(!n)return $L();const r=nz(n.mask,n.width,n.height);return _L.set(e,r),r.map(t=>({...t}))}function oz(t){const{state:e,resetTransactionGrouping:a,applyTransactionalState:n,focusInput:r}=t,o=()=>lL(e())?"image":CL(e())?"textBox":null,i=(t,e)=>{const i=o();i&&(a(),n(t=>e(t,i),{mergeKey:t}),r())},l=(t,a)=>{const r=Ue(e().document,a),o=e=>{const a=rz(e);n(e=>function(t,e,a){const n=ha(t);let r=!1;const o=n.map(t=>t.runs.some(t=>t.id===e&&t.image)?{...TT(t),runs:t.runs.map(t=>{if(t.id!==e||!t.image)return IT(t);r=!0;const n={...t.image};return a&&a.length>0?n.wrapPolygon=a:delete n.wrapPolygon,{...t,image:n}})}:TT(t));return r?ZT(t,o,YT(o,va(t))):t}(e,t,a),{mergeKey:"layoutWrapPolygon"})},i=Rc(r,()=>{i.naturalWidth>0&&o(i)});i.complete&&i.naturalWidth>0&&o(i)};return{target:o,preset:()=>{const t=o();return"image"===t?function(t){const e=lL(t);return(null==e?void 0:e.run.image)?rL(e.run.image.floating):null}(e()):"textBox"===t?function(t){const e=CL(t);return(null==e?void 0:e.run.textBox)?rL(e.run.textBox.floating):null}(e()):null},fixedPosition:()=>{const t=o();return"image"===t?function(t){var e;const a=lL(t);return iL(null==(e=null==a?void 0:a.run.image)?void 0:e.floating)}(e()):"textBox"===t&&function(t){var e;const a=CL(t);return iL(null==(e=null==a?void 0:a.run.textBox)?void 0:e.floating)}(e())},setPreset:t=>{if(i("layoutWrapPreset",(e,a)=>"image"===a?function(t,e){return dL(t,t=>nL(t,e))}(e,t):function(t,e){return VL(t,t=>nL(t,e))}(e,t)),"tight"===t||"through"===t){const t=lL(e()),a=null==t?void 0:t.run.image;a&&!a.wrapPolygon&&l(t.run.id,a.src)}},setFixedPosition:t=>i("layoutFixedPosition",(e,a)=>"image"===a?function(t,e){return dL(t,t=>t?oL(t,e):t)}(e,t):function(t,e){return VL(t,t=>t?oL(t,e):t)}(e,t))}}function iz(t,e){const a=function(t){return Fe(t.document).flatMap(t=>[...t.header??[],...t.blocks,...t.footer??[]])}(t).find(t=>"table"===t.type&&t.id===e);return a??null}function lz(t,e,a){const n=function(t,e){const a=qs({surface:t,state:e});if(!a)return[];const n=new Map,r=new Map;for(const i of a.paragraphs){const t=i.tableCell;if(!t)continue;const e=`${i.pageIndex}:${t.rowIndex}:${t.cellIndex}`,a=n.get(t.tableId)??new Map;let o=a.get(e);o||(o={tableId:t.tableId,rowIndex:t.rowIndex,cellIndex:t.cellIndex,pageIndex:i.pageIndex,left:t.left,top:t.top,right:t.left+t.width,bottom:t.top+t.height,width:t.width,height:t.height,contentMinWidth:0,contentMinHeight:0},a.set(e,o),n.set(t.tableId,a));const l=i.lines.flatMap(t=>t.slots.map(t=>t.left)),s=i.lines.map(t=>t.top+t.height),d=l.length>0?Math.min(...l):i.left,c=l.length>0?Math.max(...l):i.left,h=i.lines.length>0?i.lines[0].top:i.top,p=s.length>0?Math.max(...s):i.top+i.height,u=`${t.tableId}:${i.pageIndex}:${t.rowIndex}:${t.cellIndex}`,f=r.get(u);f?(f.left=Math.min(f.left,d),f.top=Math.min(f.top,h),f.right=Math.max(f.right,c),f.bottom=Math.max(f.bottom,p)):r.set(u,{left:d,top:h,right:c,bottom:p})}for(const[i,l]of n.entries())for(const t of l.values()){const e=r.get(`${i}:${t.pageIndex}:${t.rowIndex}:${t.cellIndex}`);e&&(t.contentMinWidth=Math.max(0,e.right-e.left),t.contentMinHeight=Math.max(0,e.bottom-e.top))}const o=[];for(const[i,l]of n.entries()){const t=Array.from(l.values());if(0===t.length)continue;const e=Math.min(...t.map(t=>t.left)),a=Math.min(...t.map(t=>t.top)),n=Math.max(...t.map(t=>t.right)),r=Math.max(...t.map(t=>t.bottom));o.push({tableId:i,cells:t,bounds:{left:e,top:a,right:n,bottom:r,width:Math.max(1,n-e),height:Math.max(1,r-a)}})}return o}(e,a);if(0===n.length)return null;let r=null;for(const l of n)for(const e of l.cells){const a=t.clientY>=e.top-4&&t.clientY<=e.bottom+4,n=t.clientX>=e.left-4&&t.clientX<=e.right+4;if(a){const a=Math.abs(t.clientX-e.left);a<=4&&(!r||a<r.distance)&&(r={geometry:l,cell:e,side:"left",distance:a});const n=Math.abs(t.clientX-e.right);n<=4&&(!r||n<r.distance)&&(r={geometry:l,cell:e,side:"right",distance:n})}if(n){const a=Math.abs(t.clientY-e.top);a<=4&&(!r||a<r.distance)&&(r={geometry:l,cell:e,side:"top",distance:a});const n=Math.abs(t.clientY-e.bottom);n<=4&&(!r||n<r.distance)&&(r={geometry:l,cell:e,side:"bottom",distance:n})}}if(!r)return null;const o=iz(a,r.geometry.tableId);if(!o)return null;const i=sn(o).find(t=>t.rowIndex===r.cell.rowIndex&&t.cellIndex===r.cell.cellIndex);return i?{tableId:r.geometry.tableId,rowIndex:r.cell.rowIndex,cellIndex:r.cell.cellIndex,side:r.side,rect:r.cell,tableNode:o,layoutEntry:i,tableGeometry:r.geometry}:null}const sz=1/.75,dz=10;function cz(t){return.75*t}function hz(t){return t*sz}function pz(t){if("number"==typeof t&&Number.isFinite(t))return t;if("string"!=typeof t)return null;const e=t.trim().toLowerCase();if(!e)return null;if(e.endsWith("pt")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t:null}if(e.endsWith("px")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?cz(t):null}if(e.includes("%"))return null;if(!/^[+-]?\d+(\.\d+)?$/.test(e))return null;const a=Number.parseFloat(e);return Number.isFinite(a)?a:null}function uz(t){var e,a,n,r,o;return("number"==typeof(null==(e=t.style)?void 0:e.padding)&&Number.isFinite(t.style.padding)?2*Math.max(0,hz(t.style.padding)):Math.max(0,(void 0!==(null==(a=t.style)?void 0:a.paddingLeft)?hz(t.style.paddingLeft):7.2)+(void 0!==(null==(n=t.style)?void 0:n.paddingRight)?hz(t.style.paddingRight):7.2)))+((null==(r=t.style)?void 0:r.borderLeft)?Math.max(0,hz(t.style.borderLeft.width)):1)+((null==(o=t.style)?void 0:o.borderRight)?Math.max(0,hz(t.style.borderRight.width)):1)}function fz(t,e,a){if("row"!==e.type)return t;const n=e.initialRowHeightPx??hz(dz),r=Math.max(hz(dz),e.minRowHeightPx??hz(dz)),o=Math.max(dz,cz(Math.max(r,n+a)));return function(t,e,a,n){const r=t=>{if(t.id!==e)return t;const r=[...t.rows],o=r[a];return o&&(r[a]={...o,style:gC(o.style,"height",n)}),{...t,rows:r}};return mC(t,t=>vC(t,r))}(t,e.tableId,e.index,o)}function gz(t){const e=t();if(!e)return{left:0,top:0,width:window.innerWidth,height:window.innerHeight};const a=e.getBoundingClientRect();return{left:a.left,top:a.top,width:Math.max(0,a.width),height:Math.max(0,a.height)}}function mz(t){t?(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 vz(){document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize")}function bz(t){mz(t)}function yz(t){const[e,a]=y(null),n=n=>{const r=e();r&&(a({...r,currentPos:"column"===r.type?n.clientX:n.clientY,guideBounds:gz(t.viewportRef)}),bz("column"===r.type))},r=o=>{var i;const l=e();if(!l)return;const s=(null==(i=t.zoomFactor)?void 0:i.call(t))??1,d=(("column"===l.type?o.clientX:o.clientY)-l.initialPos)/s;Math.abs(d)>=2&&t.applyTransactionalState(t=>"row"===l.type?fz(t,l,d):function(t,e,a){var n;if("column"!==e.type)return t;const r=cz(a),o=e.maxColumnIndex??e.index,i={...e.columnWidthsPt??{}};for(let m=0;m<=o;m+=1)void 0===i[m]&&(i[m]=dz);const l=e.minColumnWidthsPx??{},s=i[e.index]??dz,d=Math.max(dz,cz(l[e.index]??hz(dz)));if(e.resizeFromLeftEdge){const a=Math.max(0,e.initialTableIndentLeftPt??0);let n=Math.max(d,s-r),o=s-n;a+o<0&&(o=-a,n=s-o),i[e.index]=n;const l=Object.values(i).reduce((t,e)=>t+e,0),c=Math.max(0,a+o);return kC(t,e.tableId,i,l,c)}let c=Math.max(d,s+r);const h=e.index===o;if(h)i[e.index]=c;else{const t=e.index+1,a=i[t]??dz,n=Math.max(dz,cz(l[t]??hz(dz)));let r=a-(c-s);r<n&&(r=n,c=s+(a-n),c=Math.max(d,c)),i[e.index]=c,i[t]=r}const p=Object.values(i).reduce((t,e)=>t+e,0),u=iz(t,e.tableId),f=pz(null==(n=null==u?void 0:u.style)?void 0:n.width),g=h?p:null!==f?f:void 0;return kC(t,e.tableId,i,g)}(t,l,d)),a(null),vz(),window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",r)};return{resizing:e,handleMouseMove:a=>{if(e())return void bz("column"===e().type);const n=t.surfaceRef();if(!n)return void vz();const r=lz(a,n,t.state());r?mz("left"===r.side||"right"===r.side):vz()},handleMouseDown:e=>{var o;const i=t.surfaceRef();if(!i)return!1;const l=lz(e,i,t.state());if(!l)return!1;const s=t.state(),d=sn(l.tableNode);if("left"===l.side||"right"===l.side){const i="left"===l.side&&0===l.layoutEntry.visualColumnIndex,c=i?0:"left"===l.side?l.layoutEntry.visualColumnIndex-1:l.layoutEntry.visualColumnIndex+l.layoutEntry.colSpan-1;if(c<0)return!1;const h="left"===l.side?l.rect.left:l.rect.right,{widthsPt:p,maxColumnIndex:u}=function(t,e,a){const n=Math.max(1,...e.map(t=>t.visualColumnIndex+Math.max(1,t.colSpan))),r=n-1,o=Array(n).fill(a.bounds.width/n),i=new Map(a.cells.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t]));if(t.gridCols&&t.gridCols.length>=n)for(let s=0;s<n;s+=1)o[s]=Math.max(1,hz(t.gridCols[s]));else for(const s of e){if(1!==s.colSpan)continue;const t=i.get(`${s.rowIndex}:${s.cellIndex}`);t&&(o[s.visualColumnIndex]=Math.max(1,t.width))}const l={};for(let s=0;s<n;s+=1)l[s]=Math.max(dz,cz(o[s]));return{widthsPt:l,maxColumnIndex:r}}(l.tableNode,d,l.tableGeometry),f=function(t,e,a,n){var r;const o=hz(dz),i={},l=new Map(n.cells.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t]));for(const s of a){if(1!==s.colSpan)continue;if(!l.get(`${s.rowIndex}:${s.cellIndex}`))continue;const a=null==(r=e.rows[s.rowIndex])?void 0:r.cells[s.cellIndex];if(!a)continue;const n=s.visualColumnIndex,d=i[n]??o,c=a.blocks.reduce((e,a)=>Math.max(e,wi(a,t.document.styles)),1);i[n]=Math.max(d,c+uz(a)+12,o)}return i}(s,l.tableNode,d,l.tableGeometry);return a({type:"column",tableId:l.tableId,index:c,initialPos:h,currentPos:h,columnWidthsPt:p,maxColumnIndex:u,minColumnWidthsPx:f,resizeFromLeftEdge:i,initialTableIndentLeftPt:pz(null==(o=l.tableNode.style)?void 0:o.indentLeft)??0,guideBounds:gz(t.viewportRef)}),bz(!0),window.addEventListener("mousemove",n),window.addEventListener("mouseup",r),e.preventDefault(),e.stopPropagation(),!0}const c=function(t,e,a){var n,r;const o=Math.max(1,t.rows.length),i=a.bounds.height/o,l=Array(o).fill(i),s=new Map(a.cells.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t]));for(let d=0;d<o;d+=1){const a=pz(null==(r=null==(n=t.rows[d])?void 0:n.style)?void 0:r.height);if(null!==a){l[d]=Math.max(1,hz(a));continue}const o=e.find(t=>t.rowIndex===d&&1===t.rowSpan);if(o){const t=s.get(`${o.rowIndex}:${o.cellIndex}`);t&&(l[d]=Math.max(1,t.height))}}return l}(l.tableNode,d,l.tableGeometry),h="top"===l.side?l.layoutEntry.visualRowIndex-1:l.layoutEntry.visualRowIndex+l.layoutEntry.rowSpan-1;if(h<0||h>=c.length)return!1;const p="top"===l.side?l.rect.top:l.rect.bottom,u=function(t,e,a,n){const r=t.rows[n];if(!r)return hz(dz);const o=hz(dz);let i=o;for(let l=0;l<r.cells.length;l+=1){if(!r.cells[l])continue;const t=e.find(t=>t.rowIndex===n&&t.cellIndex===l);if(!t||1!==t.rowSpan)continue;const o=a.cells.find(t=>t.rowIndex===n&&t.cellIndex===l);o&&(i=Math.max(i,o.contentMinHeight+4))}return Math.max(o,i)}(l.tableNode,d,l.tableGeometry,h);return a({type:"row",tableId:l.tableId,index:h,initialPos:p,currentPos:p,initialRowHeightPx:c[h],minRowHeightPx:u,guideBounds:gz(t.viewportRef)}),bz(!1),window.addEventListener("mousemove",n),window.addEventListener("mouseup",r),e.preventDefault(),e.stopPropagation(),!0}}}function Mz(t){const[e,a]=y(!1),[n,r]=y(null),[o,i]=y(null),[l,s]=y(0),[d,c]=y({x:0,y:0}),h=r=>{var o;if(c({x:r.clientX,y:r.clientY}),!e()){if(!(Math.abs(r.clientY-l())>4))return;a(!0),document.body.style.cursor="grabbing"}document.body.style.cursor="grabbing";const s=t.resolvePositionAtSurfacePoint(r.clientX,r.clientY),d=null==(o=n())?void 0:o.tableId;if(s&&d){const e=t.state(),a=_e(e.document,s.paragraphId,sa(e));if(a){const t=ca(e,a.zone)[a.blockIndex];if(t&&"table"===t.type&&t.id===d)return void i(null)}}i(s)},p=o=>{const l=n();if(e()){const e=t.resolvePositionAtSurfacePoint(o.clientX,o.clientY),a=null==l?void 0:l.tableId;e&&a&&t.applyTransactionalState(t=>hC(t,a,e))}a(!1),r(null),i(null),window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",p),document.body.style.cursor="",t.focusInput()};return{dragging:e,draggedTableInfo:n,mousePos:d,dropTargetPos:o,handleMouseDown:(t,e)=>{e.preventDefault(),e.stopPropagation();const n=e.currentTarget.getBoundingClientRect(),o=n;r({tableId:t,width:o.width,height:o.height,offsetX:e.clientX-n.left,offsetY:e.clientY-n.top}),s(e.clientY),c({x:e.clientX,y:e.clientY}),a(!1),i(null),window.addEventListener("mousemove",h),window.addEventListener("mouseup",p)}}}function xz(t){return/[\p{L}\p{N}_]/u.test(t)}function wz(t,e){if(0===t.length)return{start:0,end:0};const a=Math.max(0,Math.min(e,t.length)),n=a===t.length?Math.max(0,a-1):a,r=t[n];if(!r||!xz(r))return{start:a,end:Math.min(t.length,a+1)};let o=n,i=n+1;for(;o>0&&xz(t[o-1]);)o-=1;for(;i<t.length&&xz(t[i]);)i+=1;return{start:o,end:i}}function Sz(t,e,a){const n=Je(t.document).filter(e=>{const n=Qe(t.document,e.id);return null!==n&&n.zone===a}),r=n.findIndex(t=>t.id===e.id),o=r>=0?n[r+1]:void 0;return{start:Ve(e,0),end:o?Ve(o,0):Ve(e,Ce(e).length)}}function Az(t){let e=null,a=null,n=null,r=0,o=0,i=0,l=0,s=0,d=null,c=0,h=0,p=0;const u=(e,a,n,r)=>{var o;const i=a!==(e.activeZone??"main"),l="footnote"===a&&r?null==(o=Qe(n.document,r.paragraphId))?void 0:o.footnoteId:void 0,s="footnote"===a&&l!==e.activeFootnoteId;if(!i&&!s)return void t.applyState(n);let d=n.document,c=e.activeSectionIndex??0;if(!d.sections||0===d.sections.length){const t=La("header"),e=La("footer");d={...d,sections:[{id:"section:1",blocks:[],pageSettings:ye(d.pageSettings??be),header:[t],footer:[e]}]},c=0}const h=d.sections,p=h[c];let u=p.header,f=p.footer,g=null;if("header"===a)if(u&&0!==u.length){const t=u[0];g="paragraph"===t.type?t:Ge(t)[0]??null}else g=La("header"),u=[g];else if("footer"===a)if(f&&0!==f.length){const t=f[0];g="paragraph"===t.type?t:Ge(t)[0]??null}else g=La("footer"),f=[g];if(u!==p.header||f!==p.footer){const t=[...h];t[c]={...p,header:u,footer:f},d={...d,sections:t}}const m=r||(g?Ve(g,0):n.selection.anchor);t.applyState({...n,document:d,selection:{anchor:m,focus:m},activeSectionIndex:c,activeZone:a,activeFootnoteId:"footnote"===a?l:void 0})},f=e=>{const a=t.state(),n=a.selection,r=sa(a),o=_e(a.document,n.anchor.paragraphId,r),i=_e(a.document,n.focus.paragraphId,r),l=o?`b${o.blockIndex}r${o.rowIndex}c${o.cellIndex}`:"",s=i?`b${i.blockIndex}r${i.rowIndex}c${i.cellIndex}`:"";t.logger.debug(`${e} ${n.anchor.paragraphId}[${n.anchor.offset}]→${n.focus.paragraphId}[${n.focus.offset}] [${l}→${s}]`)},g=()=>{var t;e=null,n=null,null!==a&&(t=a,"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(t):window.cancelAnimationFrame(t),a=null),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b)},m=()=>{if(a=null,!e)return;const r=n;if(n=null,!r)return;const o=t.resolveSurfaceHitAtPoint(r.clientX,r.clientY,{forDrag:!0});if(!(null==o?void 0:o.resolvedFromParagraph))return;const i=t.state(),l=YC(i,{anchor:e,focus:o.position});u(i,o.zone,l,o.position),f("selection:drag")},v=t=>{var r;e&&(n={clientX:t.clientX,clientY:t.clientY},null===a&&(r=m,a="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>r()):globalThis.setTimeout(r,16)))},b=()=>{f("selection:end"),g(),t.focusInputAfterPointerSelection()},y=a=>{var n;if(0!==a.button)return;const f=Date.now(),m=Math.hypot(a.clientX-i,a.clientY-l),y=f-o<=450&&m<=6&&a.button===s;r=y?r+1:1,o=f,i=a.clientX,l=a.clientY,s=a.button;const M=Math.max(a.detail,r),x=t.state();if(t.clearPendingCaretTextStyle(),t.tableResize.handleMouseDown(a))return;a.preventDefault(),t.imageOps.stopImageDrag(),t.imageOps.stopImageResize(),t.clearPreferredColumn(),t.resetTransactionGrouping();const w=t.resolveSurfaceHitAtPoint(a.clientX,a.clientY,{pierce:a.altKey});if(d=w,c=f,h=a.clientX,p=a.clientY,!w)return void t.focusInputAfterPointerSelection();if(null==(n=t.textDrag)?void 0:n.tryStartTextDrag(a,w))return e=null,g(),void t.focusInputAfterPointerSelection();const S=t.getParagraphById(x.document,w.paragraphId);if(w.zone!==(x.activeZone??"main"))return M<2?(e=null,g(),void t.focusInputAfterPointerSelection()):(e=null,w.resolvedFromParagraph?u(x,w.zone,{...x,selection:{anchor:{...w.position},focus:{...w.position}}},w.position):u(x,w.zone,x),g(),void t.focusInputAfterPointerSelection());if(w.textBox){const a=t.getParagraphById(x.document,w.textBox.paragraphId);if(!a)return void t.focusInputAfterPointerSelection();e=null;const n=Ve(a,w.textBox.startOffset),r=Ve(a,w.textBox.endOffset);return u(x,w.zone,YC(x,{anchor:n,focus:r}),n),g(),void t.focusInputAfterPointerSelection()}if(w.image){const n=t.getParagraphById(x.document,w.image.paragraphId);if(!n)return void t.focusInputAfterPointerSelection();e=null;const r=Ve(n,w.image.startOffset),o=Ve(n,w.image.endOffset);return u(x,w.zone,YC(x,{anchor:r,focus:o}),r),g(),t.imageOps.startImageDrag(w.image.paragraphId,w.image.startOffset,a,{left:w.image.left,top:w.image.top,width:w.image.width,height:w.image.height}),void t.focusInputAfterPointerSelection()}if(a.shiftKey&&w.resolvedFromParagraph)return e=x.selection.anchor,u(x,w.zone,YC(x,{anchor:x.selection.anchor,focus:w.position}),w.position),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b),void t.focusInputAfterPointerSelection();if(M>=3&&S){e=null;const a=Sz(x,S,w.zone);return u(x,w.zone,YC(x,{anchor:a.start,focus:a.end}),a.start),g(),void t.focusInputAfterPointerSelection()}if(2===M&&S){e=null;const a=wz(Ce(S),w.paragraphOffset),n=Ve(S,a.start),r=Ve(S,a.end);return u(x,w.zone,YC(x,{anchor:n,focus:r}),n),g(),void t.focusInputAfterPointerSelection()}w.resolvedFromParagraph?(e=w.position,u(x,w.zone,{...x,selection:{anchor:{...w.position},focus:{...w.position}}},w.position),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b),t.focusInputAfterPointerSelection()):t.focusInputAfterPointerSelection()};return{handleSurfaceMouseDown:y,handleSurfaceClick:a=>{if(a.detail<3)return;a.preventDefault();const n=t.state(),r=Math.hypot(a.clientX-h,a.clientY-p),o=Date.now()-c<=600&&r<=8?d:t.resolveSurfaceHitAtPoint(a.clientX,a.clientY);if(!(null==o?void 0:o.resolvedFromParagraph))return void t.focusInputAfterPointerSelection();const i=t.getParagraphById(n.document,o.paragraphId);if(!i)return void t.focusInputAfterPointerSelection();e=null;const l=Sz(n,i,o.zone);u(n,o.zone,YC(n,{anchor:l.start,focus:l.end}),l.start),g(),t.focusInputAfterPointerSelection()},handleSurfaceDblClick:t=>{t.preventDefault()},handleParagraphMouseDown:(t,e)=>{0===e.button&&(e.preventDefault(),y(e))},stopDragging:g}}function Iz(t,e){const a=va(t);if(a.isCollapsed)return!1;const n=ha(t),r=n.findIndex(t=>t.id===e.paragraphId);if(r<a.startIndex||r>a.endIndex)return!1;const o=n[r];if(!o)return!1;const i=Ee(o,e);return!(r===a.startIndex&&i<a.startParagraphOffset)&&!(r===a.endIndex&&i>a.endParagraphOffset)}function Tz(t){const[e,a]=y(!1),[n,r]=y(null),[o,i]=y(!1),[l,s]=y(null),[d,c]=y(null);let h=null,p=null,u=null;const f=()=>{var l;null==(l=t.logger)||l.info("text-drag:stop",{dragging:e(),dropTarget:n()?`${n().paragraphId}:${n().runId}[${n().offset}]`:null,copyMode:o()}),h=null,u=null,a(!1),r(null),i(!1),s(null),c(null),p&&(p.remove(),p=null),window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",m)},g=n=>{var o,l,d;if(!h)return;const f=n.ctrlKey||n.metaKey;if(i(f),!e()){const e=Math.abs(n.clientX-h.x),r=Math.abs(n.clientY-h.y);if(e+r<4)return;null==(o=t.logger)||o.info("text-drag:activate",{start:h,at:{x:n.clientX,y:n.clientY},deltaX:e,deltaY:r}),a(!0),p||(p=document.createElement("style"),p.setAttribute("data-oasis-text-drag-cursor",""),p.textContent="*, *::before, *::after { cursor: 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 !important; }",document.head.appendChild(p))}s({x:n.clientX,y:n.clientY});const g=t.resolveSurfaceHitAtPoint(n.clientX,n.clientY);if(!(null==g?void 0:g.resolvedFromParagraph))return null==(l=t.logger)||l.debug("text-drag:hit-miss",{x:n.clientX,y:n.clientY}),r(null),void c(null);const m=g.tableCellAnchorPosition??g.position,v=`${m.paragraphId}:${m.runId}[${m.offset}]|${g.zone}|src=${g.tableCellAnchorPosition?"cell-anchor":"hit"}`;v!==u&&(null==(d=t.logger)||d.info("text-drag:target",{x:n.clientX,y:n.clientY,zone:g.zone,resolvedFromParagraph:g.resolvedFromParagraph,paragraphId:g.paragraphId,paragraphOffset:g.paragraphOffset,hitPosition:`${g.position.paragraphId}:${g.position.runId}[${g.position.offset}]`,target:`${m.paragraphId}:${m.runId}[${m.offset}]`,source:g.tableCellAnchorPosition?"tableCellAnchorPosition":"position"}),u=v),r(m),c(g.caretViewport??null)},m=a=>{var r,i,l;if(null==(r=t.logger)||r.info("text-drag:mouseup",{x:a.clientX,y:a.clientY,dragging:e(),copyMode:o(),dropTarget:n()?`${n().paragraphId}:${n().runId}[${n().offset}]`:null}),e()&&n()){const e=n(),a=o();t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(n=>t.applyTableAwareParagraphEdit(n,t=>eC(t,e,{copy:a})),{mergeKey:a?"copyTextByDrag":"moveTextByDrag"}),null==(i=t.logger)||i.info("text-drag:apply",{mode:a?"copy":"move",destination:`${e.paragraphId}:${e.runId}[${e.offset}]`})}else if(h){const e=h.position;t.applyTransactionalState(t=>Iz(t,e)?YC(t,{anchor:e,focus:e}):t,{mergeKey:"collapseSelectionByClick"}),null==(l=t.logger)||l.info("text-drag:collapse",{at:`${e.paragraphId}:${e.runId}[${e.offset}]`})}f(),t.focusInputAfterPointerSelection()};return{dragging:e,dropTargetPos:n,copyMode:o,pointerPos:l,caretViewport:d,tryStartTextDrag:(e,n)=>{var o,l,d;if(t.isReadOnly()||!(null==n?void 0:n.resolvedFromParagraph))return null==(o=t.logger)||o.debug("text-drag:skip-start",{reason:t.isReadOnly()?"readonly":"no-hit",x:e.clientX,y:e.clientY}),!1;return Iz(t.state(),n.position)?(null==(d=t.logger)||d.info("text-drag:start-pending",{x:e.clientX,y:e.clientY,hit:`${n.position.paragraphId}:${n.position.runId}[${n.position.offset}]`,zone:n.zone}),h={x:e.clientX,y:e.clientY,position:n.tableCellAnchorPosition??n.position},s({x:e.clientX,y:e.clientY}),i(e.ctrlKey||e.metaKey),r(null),c(n.caretViewport??null),a(!1),window.addEventListener("mousemove",g),window.addEventListener("mouseup",m),!0):(null==(l=t.logger)||l.debug("text-drag:skip-start",{reason:"outside-selection",x:e.clientX,y:e.clientY,hit:`${n.position.paragraphId}:${n.position.runId}[${n.position.offset}]`}),!1)},stopDrag:f}}function Cz(t){const e=(e,a)=>{var n,r,o,i,l,s;const d=t.state(),c=ha(d),h=c.findIndex(t=>t.id===d.selection.focus.paragraphId);if(-1===h)return!1;const p=t.surfaceRef(),u=(null==p?void 0:p.getBoundingClientRect())??null,f=t.preferredColumnX(),g=null===f?t.caretBox().left+((null==u?void 0:u.left)??0):f,m=p?qs({surface:p,state:d,zoomFactor:null==(n=t.zoomFactor)?void 0:n.call(t)}):null;let v=h+e;const b=_e(d.document,d.selection.focus.paragraphId,sa(d));if(b){const t=ca(d,b.zone)[b.blockIndex];if(t&&"table"===t.type){const a=sn(t),n=a.find(t=>t.rowIndex===b.rowIndex&&t.cellIndex===b.cellIndex);if(n){const o=[];for(let a=n.visualRowIndex+e;a>=0&&a<t.rows.length;a+=e)o.push(a);for(const n of o){const o=a.filter(t=>t.visualRowIndex===n&&t.cell.blocks.length>0&&"continue"!==t.cell.vMerge);if(0===o.length)continue;const i=null==(r=o.map(e=>{var a,n;const r=null==(a=e.cell.blocks[0])?void 0:a.id,o=r?null==(n=null==m?void 0:m.paragraphs.find(e=>e.paragraphId===r&&e.tableCell&&e.tableCell.tableId===t.id))?void 0:n.tableCell:null,i=(null==o?void 0:o.left)??g,l=o?o.left+o.width:g;return{entry:e,distance:g<i?i-g:g>l?g-l:0}}).sort((t,e)=>t.distance-e.distance)[0])?void 0:r.entry;if(!i)continue;const l=e<0?i.cell.blocks[i.cell.blocks.length-1].id:i.cell.blocks[0].id;v=c.findIndex(t=>t.id===l);break}}else if(e<0){const e=null==(l=null==(i=null==(o=t.rows[0])?void 0:o.cells[0])?void 0:i.blocks[0])?void 0:l.id;e&&(v=c.findIndex(t=>t.id===e)-1)}else{const e=t.rows[t.rows.length-1],a=null==e?void 0:e.cells[e.cells.length-1],n=null==(s=null==a?void 0:a.blocks[a.blocks.length-1])?void 0:s.id;n&&(v=c.findIndex(t=>t.id===n)+1)}}}if(v<0||v>=c.length)return!1;const y=c[v];let M=0;const x=m?Ps(m,y.id):[],w=e<0?x[x.length-1]:x[0];if(w&&w.lines.length>0){const t=w.lines,a=e<0?t[t.length-1]:t[0];M=a.slots.length?a.slots.reduce((t,e)=>Math.abs(g-e.left)<Math.abs(g-t.left)?e:t,a.slots[0]).offset:0}else M=Math.min(Ee(y,d.selection.focus),Ce(y).length);return t.setPreferredColumnX(g),t.resetTransactionGrouping(),t.applyTransactionalState(t=>YC(t,{anchor:a?t.selection.anchor:Ve(y,M),focus:Ve(y,M)})),t.focusInput(),!0};return{moveSelectionToParagraphBoundary:(e,a)=>{const n=t.state(),r=ha(n).find(t=>t.id===n.selection.focus.paragraphId);if(!r)return!1;const o=Ve(r,"start"===e?0:Ce(r).length);return t.clearPreferredColumn(),t.applyState(YC(n,{anchor:a?n.selection.anchor:o,focus:o})),!0},moveSelectionToDocumentBoundary:(e,a)=>{const n=t.state(),r=ha(n);if(0===r.length)return!1;const o="start"===e?r[0]:r[r.length-1],i=Ve(o,"start"===e?0:Ce(o).length);return t.clearPreferredColumn(),t.applyState(YC(n,{anchor:a?n.selection.anchor:i,focus:i})),!0},moveSelectionByWord:(e,a)=>{const n=t.state(),r=ha(n),o=r.findIndex(t=>t.id===n.selection.focus.paragraphId),i=r[o];if(!i)return!1;const l=Ce(i),s=n.selection.focus.offset,d=l.length;if(!a&&!ma(n.selection))return t.clearPreferredColumn(),t.applyState("left"===e?QC(n):_C(n)),!0;let c=i,h=s;"left"===e?0===s&&o>0?(c=r[o-1],h=Ce(c).length):h=function(t,e){if(0===t.length)return 0;let a=Math.max(0,Math.min(e,t.length));if(0===a)return 0;if(xz(t[a-1]??"")){for(;a>0&&xz(t[a-1]??"");)a-=1;return a}for(;a>0&&!xz(t[a-1]??"");)a-=1;for(;a>0&&xz(t[a-1]??"");)a-=1;return a}(l,s):s===d&&o<r.length-1?(c=r[o+1],h=0):h=function(t,e){if(0===t.length)return 0;let a=Math.max(0,Math.min(e,t.length));if(a>=t.length)return t.length;if(xz(t[a]??"")){for(;a<t.length&&xz(t[a]??"");)a+=1;for(;a<t.length&&!xz(t[a]??"");)a+=1;return a}for(;a<t.length&&!xz(t[a]??"");)a+=1;return a}(l,s);const p=Ve(c,h);return t.clearPreferredColumn(),t.applyState(YC(n,{anchor:a?n.selection.anchor:p,focus:p})),!0},moveVerticalByBlock:t=>e(t,!1),moveVerticalSelection:e}}function kz(t){const e=()=>t.state,a=yz({state:e,applyTransactionalState:t.applyTransactionalState,surfaceRef:t.surfaceRef,viewportRef:t.viewportRef,zoomFactor:t.zoomFactor}),n=Mz({state:e,applyTransactionalState:t.applyTransactionalState,resolvePositionAtSurfacePoint:t.resolvePositionAtSurfacePoint,focusInput:t.focusInput}),r=function(t){const[e,a]=y(null);return{hoveredRevision:e,handleRevisionMouseEnter:(e,n)=>{var r,o,i;const l=ha(t.state());let s;for(const t of l){for(const a of t.runs)if((null==(r=a.revision)?void 0:r.id)===e){s=a.revision;break}if(s)break}if(!s)return;const d=n.currentTarget.getBoundingClientRect(),c=null==(o=t.surfaceRef())?void 0:o.getBoundingClientRect();if(!c)return;const h=(null==(i=t.zoomFactor)?void 0:i.call(t))??1;a({revisionId:s.id,author:s.author,date:s.date,type:s.type,left:(d.left-c.left)/h,top:(d.top-c.top)/h})},handleRevisionMouseLeave:()=>{a(null)}}}({state:e,surfaceRef:()=>t.surfaceRef()??null,zoomFactor:t.zoomFactor}),o=Tz({state:e,isReadOnly:t.isReadOnly,resolveSurfaceHitAtPoint:t.resolveSurfaceHitAtPoint,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInputAfterPointerSelection:t.focusInputAfterPointerSelection,logger:t.logger}),i=Az({state:e,applyState:t.applyState,tableResize:a,imageOps:t.imageOps,clearPendingCaretTextStyle:t.styleController.clearPendingCaretTextStyle,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInputAfterPointerSelection:t.focusInputAfterPointerSelection,resolveSurfaceHitAtPoint:t.resolveSurfaceHitAtPoint,getParagraphById:Ye,textDrag:{tryStartTextDrag:o.tryStartTextDrag},logger:t.logger}),l=function(t){const[e,a]=y(!1);let n=null;return{handleTextInput:a=>{var r,o,i,l;if(Vi("input:text"),t.isReadOnly())return t.logger.debug(`input:readonly ignored value=${JSON.stringify(a.currentTarget.value)}`),void(a.currentTarget.value="");const s=a.currentTarget.value;if(0===s.length)return;if(e())return void t.logger.debug(`input:composing buffer=${JSON.stringify(s)}`);if(null!==n&&s===n)return t.logger.debug(`input:suppressed text=${JSON.stringify(s)}`),n=null,void(a.currentTarget.value="");const d=t.state(),c=d.selection,h=null==(r=ha(d).find(t=>t.id===c.anchor.paragraphId))?void 0:r.runs.find(t=>t.id===c.anchor.runId),p=h?{bold:null==(o=h.styles)?void 0:o.bold,italic:null==(i=h.styles)?void 0:i.italic,underline:null==(l=h.styles)?void 0:l.underline}:null;t.logger.info(`input:text ${JSON.stringify(s)} (len=${s.length}) at ${c.anchor.paragraphId}:${c.anchor.runId}[${c.anchor.offset}] run:${JSON.stringify(p)}`),t.clearPreferredColumn();const u=yT(t.pendingCaretTextStyle());t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>aC(t,s,u)),{mergeKey:"insertText"}),a.currentTarget.value="",t.focusInput(),Ei("input:text")},handleCompositionStart:()=>{t.logger.debug("input:composition start"),a(!0)},handleCompositionEnd:e=>{if(t.isReadOnly())return e.currentTarget.value="",void a(!1);const r=e.data??e.currentTarget.value;if(a(!1),0===r.length)return void(e.currentTarget.value="");const o=t.state().selection;t.logger.info(`input:composition end ${JSON.stringify(r)} (len=${r.length}) at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}]`),n=r,t.clearPreferredColumn();const i=yT(t.pendingCaretTextStyle());t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>aC(t,r,i)),{mergeKey:"insertText"}),e.currentTarget.value="",t.focusInput()},composing:e}}({state:e,isReadOnly:t.isReadOnly,logger:t.logger,clearPreferredColumn:t.clearPreferredColumn,pendingCaretTextStyle:t.styleController.pendingCaretTextStyle,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,focusInput:t.focusInput}),s=Cz({state:e,applyState:t.applyState,applyTransactionalState:t.applyTransactionalState,surfaceRef:()=>t.surfaceRef()??null,caretBox:t.caretBox,preferredColumnX:t.preferredColumnX,setPreferredColumnX:t.setPreferredColumnX,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInput:t.focusInput,zoomFactor:t.zoomFactor}),{handleCopy:d,handleCut:c,handlePaste:h,handleDrop:p}=(u={state:e,isReadOnly:t.isReadOnly,forcePlainTextPaste:t.getForcePlainTextPaste,setForcePlainTextPaste:t.setForcePlainTextPaste,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,focusInput:t.focusInput,insertImageFromFile:t.insertImageFromFile,resolvePositionAtSurfacePoint:t.resolvePositionAtSurfacePoint},{handleCopy:t=>{var e,a;const n=JC(u.state());0!==n.length&&(t.preventDefault(),null==(e=t.clipboardData)||e.setData("text/plain",n),null==(a=t.clipboardData)||a.setData("text/html",GC(u.state())))},handleCut:t=>{var e,a;if(u.isReadOnly())return void t.preventDefault();const n=JC(u.state());0!==n.length&&(t.preventDefault(),null==(e=t.clipboardData)||e.setData("text/plain",n),null==(a=t.clipboardData)||a.setData("text/html",GC(u.state())),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>rC(t))),u.focusInput())},handlePaste:t=>{var e,a,n;if(u.isReadOnly())return void t.preventDefault();if(u.forcePlainTextPaste()){u.setForcePlainTextPaste(!1);const a=(null==(e=t.clipboardData)?void 0:e.getData("text/plain"))??"";return 0===a.length?void t.preventDefault():(t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>nC(t,a))),t.currentTarget.value="",void u.focusInput())}const r=tL(t.clipboardData);if(r)return t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.insertImageFromFile(r),t.currentTarget.value="",void u.focusInput();const o=$C((null==(a=t.clipboardData)?void 0:a.getData("text/html"))??"");if(o.length>0)return t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>ZC(t,o))),t.currentTarget.value="",void u.focusInput();const i=(null==(n=t.clipboardData)?void 0:n.getData("text/plain"))??"";0!==i.length&&(t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>nC(t,i))),t.currentTarget.value="",u.focusInput())},handleDrop:t=>{if(u.isReadOnly())return void t.preventDefault();const e=tL(t.dataTransfer);if(!e)return;t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping();const a=u.resolvePositionAtSurfacePoint(t.clientX,t.clientY)??u.state().selection.focus;u.insertImageFromFile(e,a),u.focusInput()}});var u;return{tableResize:a,tableDrag:n,revisionController:r,textDrag:o,surfaceEvents:i,textInput:l,navigation:s,handleCopy:d,handleCut:c,handlePaste:h,handleDrop:p}}function Vz(t){const{state:e,logger:a,isReadOnly:n,applyState:r,cloneState:o,focusInput:i,focusInputAfterPointerSelection:l,surfaceRef:s,viewportRef:d,zoomFactor:c,insertImageFromFile:h,getForcePlainTextPaste:p,setForcePlainTextPaste:u,getCommandsController:f,applyTransactionalState:g,clearPreferredColumn:m,resetTransactionGrouping:v,updateHistoryState:b,caretBox:y,preferredColumnX:M,setPreferredColumnX:x,measuredBlockHeights:w,measuredParagraphLayouts:S}=t,A=oz({state:()=>e,resetTransactionGrouping:v,applyTransactionalState:g,focusInput:i}),I=YL({state:()=>e,surfaceRef:()=>s()??null,viewportRef:()=>d()??null,measuredBlockHeights:w,measuredParagraphLayouts:S,zoomFactor:c}).resolveSurfaceHitAtPoint,T=ZL({state:e,applyState:r,applyTransactionalState:g,focusInput:i}),C=HL({applyTransactionalState:g,applySelectionToStatePreservingStructure:(t,e)=>({...t,document:Px(t).document,selection:e}),focusInput:i,logger:a}),k=(t,e)=>{var a;return(null==(a=I(t,e))?void 0:a.position)??null},V=BL({state:e,surfaceRef:s,resolvePositionAtSurfacePoint:k,applyState:r,applyTransactionalState:g,updateHistoryState:b,focusInput:i,focusInputAfterPointerSelection:l,cloneState:o,logger:a,zoomFactor:c}),E=function(t){const e=t=>{const e=CL(t);return(null==e?void 0:e.run.textBox)?{width:e.run.textBox.width,height:ks(e.run.textBox,t,0)}:null},a=UL({label:"text box",getSelected:e,applyResize:(t,e,a,n)=>EL(t,e,a,{handleDirection:n}),getMaxWidth:(a,n)=>{const r=uL(t.surfaceRef(),a.document,n,a.activeSectionIndex??0),o=e(a);return o?Math.max(r,o.width):r}},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger,zoomFactor:t.zoomFactor}),n=FL({label:"text box",applyRotate:(t,e)=>kL(t,e)},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger});return{handleTextBoxResizeHandleMouseDown:(e,n,r,o)=>{o.preventDefault(),o.stopPropagation(),a.start(e,n,r,o,t.state)},handleTextBoxRotateHandleMouseDown:(e,a,r)=>{r.preventDefault(),r.stopPropagation(),n.start(e,a,r,t.state)},stopTextBoxResize:a.stop,stopTextBoxRotate:n.stop}}({state:e,surfaceRef:s,applyState:r,updateHistoryState:b,focusInput:i,cloneState:o,logger:a,zoomFactor:c}),R=GL({state:()=>e,commandsController:f,clearPreferredColumn:m,resetTransactionGrouping:v,focusInput:i,logger:a}),L=kz({state:e,applyState:r,applyTransactionalState:g,isReadOnly:n,logger:a,focusInput:i,focusInputAfterPointerSelection:l,clearPreferredColumn:m,resetTransactionGrouping:v,surfaceRef:s,viewportRef:d,caretBox:()=>y(),preferredColumnX:()=>M(),setPreferredColumnX:x,zoomFactor:c,resolveSurfaceHitAtPoint:I,resolvePositionAtSurfacePoint:k,tableOps:C,imageOps:V,styleController:R,getForcePlainTextPaste:p,setForcePlainTextPaste:u,insertImageFromFile:h});return{selectedImageRun:()=>lL(e),selectedTextBoxRun:()=>CL(e),layoutOptionsOverlay:A,fr:T,resolveSurfaceHitAtPoint:I,resolvePositionAtSurfacePoint:k,tableOps:C,imageOps:V,textBoxOps:E,styleController:R,onEditorMouseDown:t=>{0===t.button&&(R.clearPendingCaretTextStyle(),t.preventDefault(),i())},tableResize:L.tableResize,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}}function Ez(t){if("main"!==(t.activeZone??"main"))return t;const e=ma(t.selection)?t:XT(t),{paragraph:a,index:n,offset:r}=jT(e),o=function(){const t=[ka("",{styleId:"footnoteText"})];return{id:ba("footnote"),blocks:t}}(),i=function(t){var e,a;const n=t.footnotes,r=(null==(e=null==n?void 0:n.settings)?void 0:e.numberFormat)??"decimal";let o=((null==(a=null==n?void 0:n.settings)?void 0:a.startAt)??1)-1;const i=new Set;for(const{run:l}of Gl(t)){const t=l.footnoteReference;t&&!t.customMark&&(i.has(t.footnoteId)||(i.add(t.footnoteId),o+=1))}return Xl(o+1,r)}(e.document),l=function(t,e){const a=wa(e,{styleId:"footnoteReference",superscript:!0}),n={footnoteId:t};return a.footnoteReference=n,a}(o.id,i),s=HT(a,r,[l]),d=ZT(e,ha(e).map((t,e)=>e===n?s:t),ga(Ve(s,r+i.length))),c=function(t){return t||{items:{}}}(d.document.footnotes),h=Yl({...d.document,footnotes:{...c,items:{...c.items,[o.id]:o}}}),p=o.blocks.flatMap(Ge).find(Boolean);return p?{...d,document:h,selection:ga(Ve(p,0)),activeZone:"footnote",activeFootnoteId:o.id}:{...d,document:h}}function Rz(t,e){const a=ha(t).map(t=>{const a=t.runs.filter(t=>{var a;return!((null==(a=t.revision)?void 0:a.id)===e&&"delete"===t.revision.type)}).map(t=>{var a;if((null==(a=t.revision)?void 0:a.id)===e&&"insert"===t.revision.type){const e={...t};return delete e.revision,e}return t});return a.length===t.runs.length&&a.every((e,a)=>e===t.runs[a])?t:RT(t,a)});return ZT(t,a,YT(a,va(t)))}function Lz(t,e){const a=ha(t).map(t=>{const a=t.runs.filter(t=>{var a;return!((null==(a=t.revision)?void 0:a.id)===e&&"insert"===t.revision.type)}).map(t=>{var a;if((null==(a=t.revision)?void 0:a.id)===e&&"delete"===t.revision.type){const e={...t};return delete e.revision,e}return t});return a.length===t.runs.length&&a.every((e,a)=>e===t.runs[a])?t:RT(t,a)});return ZT(t,a,YT(a,va(t)))}function zz(t){var e,a,n;const r=va(t),o=ha(t);if(r.isCollapsed){const t=o[r.startIndex];return t?(null==(e=PT(t,r.startParagraphOffset))?void 0:e.href)??null:null}const i=o.slice(r.startIndex,r.endIndex+1).flatMap((t,e)=>{const a=r.startIndex+e;return WT(t,a===r.startIndex?r.startParagraphOffset:0,a===r.endIndex?r.endParagraphOffset:ke(t))}).filter(t=>t.text.length>0&&!t.image);if(0===i.length)return null;const l=null==(n=null==(a=i[0])?void 0:a.styles)?void 0:n.link;return l&&i.every(t=>{var e;return(null==(e=t.styles)?void 0:e.link)===l})?l:null}function Nz(t){const e=va(t),a=ha(t).map((t,a)=>{if(a<e.startIndex||a>e.endIndex)return TT(t);if(!t.list)return TT(t);const n=t.list.level??0;return n<=0?qT(t):NT(t,n-1)});return ZT(t,a,YT(a,e))}function qz(t){const{state:e,logger:a,applyState:n,applyTransactionalState:r,applySelectionAwareTextCommand:o,applySelectionAwareParagraphCommand:i,applyTableAwareParagraphEdit:l,focusInput:s,clearPreferredColumn:d,resetTransactionGrouping:c,toolbarStyleState:h,selectionCollapsed:p,selectedImageRun:u}=t,f=()=>(()=>{const t=va(e);return ha(e).slice(t.startIndex,t.endIndex+1)})().some(t=>Boolean(t.list)),g=()=>{const t=e.selection.focus.paragraphId;return ha(e).find(e=>e.id===t)??null},m=()=>{const t=e.selection,a=sa(e),n=_e(e.document,t.anchor.paragraphId,a),r=_e(e.document,t.focus.paragraphId,a);return n&&r&&n.blockIndex===r.blockIndex?` [table b${n.blockIndex} r${n.rowIndex}:c${n.cellIndex}→r${r.rowIndex}:c${r.cellIndex}]`:""},v=(t,e)=>{d(),c(),i(a=>fC(a,t,e)),s()},b=()=>"main"===(e.activeZone??"main"),y=t=>{const a=zz(e);p()&&!a||(d(),c(),r(e=>function(t,e){const a=va(t);if(!a.isCollapsed)return lC(t,"link",e);const n=ha(t)[a.startIndex];if(!n)return t;const r=PT(n,a.startParagraphOffset);if(!r)return t;const o=lC(YC(t,{anchor:Ve(n,r.startOffset),focus:Ve(n,r.endOffset)}),"link",e),i=ha(o)[a.startIndex];return i?{...o,selection:{anchor:Ve(i,r.startOffset),focus:Ve(i,r.endOffset)}}:o}(e,t),{mergeKey:"link"}),s())};return{applyBooleanStyleCommand:t=>{if(p())return;const n=e.selection;a.info(`toggleStyle:${t} at ${n.anchor.paragraphId}:${n.anchor.runId}[${n.anchor.offset}..${n.focus.offset}]${m()}`),d(),c(),o(e=>iC(e,t)),s()},applyValueStyleCommand:(t,n)=>{if(p())return;const r=e.selection;a.info(`setStyle:${t}=${JSON.stringify(n)} at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}..${r.focus.offset}]${m()}`),d(),c(),o(e=>lC(e,t,n)),s()},applyChangeTextCaseCommand:t=>{p()||(d(),c(),o(e=>cC(e,t)),s())},applyClearFormattingCommand:()=>{p()||(d(),c(),o(t=>function(t){const e=va(t);if(e.isCollapsed)return t;const a=ha(t).map((t,a)=>a<e.startIndex||a>e.endIndex?t:JT(t,a===e.startIndex?e.startParagraphOffset:0,a===e.endIndex?e.endParagraphOffset:ke(t),t=>{var e;const a=null==(e=t.styles)?void 0:e.link,n=null!=a&&""!==a?{link:a}:{};return{...t,styles:n}}));return ZT(t,a,YT(a,e))}(t)),s())},applyParagraphStyleCommand:v,toggleParagraphFlagCommand:t=>{const e=!h()[t];v(t,!!e||null)},applyParagraphListCommand:t=>{d(),c(),i(e=>function(t,e){const a=va(t),n=ha(t),r=a.startIndex,o=a.endIndex,i=n.slice(r,o+1),l=i.length>0&&i.every(t=>{var a;return(null==(a=t.list)?void 0:a.kind)===e}),s=n.map((t,a)=>{var n,i,s;if(a<r||a>o)return TT(t);const d=TT(t);return l?(delete d.list,d):(d.list={kind:e,level:(null==(n=t.list)?void 0:n.level)??0,format:null==(i=t.list)?void 0:i.format,startAt:null==(s=t.list)?void 0:s.startAt},d)});return ZT(t,s,YT(s,a))}(e,t)),s()},handleListFormatChange:t=>{d(),c(),i(e=>function(t,e){const a=va(t),n=ha(t).map((t,n)=>n<a.startIndex||n>a.endIndex?TT(t):t.list?{...TT(t),list:{...t.list,format:e||void 0}}:TT(t));return ZT(t,n,YT(n,a))}(e,t)),s()},handleListStartAtChange:t=>{d(),c(),i(e=>function(t,e){const a=va(t),n=ha(t).map((t,n)=>n<a.startIndex||n>a.endIndex?TT(t):t.list?{...TT(t),list:{...t.list,startAt:null!==e?e:void 0}}:TT(t));return ZT(t,n,YT(n,a))}(e,t)),s()},applyInsertSectionBreakCommand:t=>{d(),c(),n(function(t,e){const a=ma(t.selection)?t:XT(t),{paragraph:n,offset:r}=jT(a),o=Be(a.document),i=sa(a);if("main"!==da(a))return t;const l=o[i];if(!l)return t;const s=l.blocks.findIndex(t=>"paragraph"===t.type&&t.id===n.id);if(-1===s)return t;const d=l.blocks.slice(0,s),c=l.blocks.slice(s+1),h=RT(n,WT(n,0,r),OT(n,r)),p=WT(n,r,ke(n)),u=p.length>0?zT(n,p.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Sa("");return t.style=n.style?{...n.style}:void 0,t.list=n.list?{...n.list}:void 0,t})(),f={id:`section:${Math.random().toString(36).slice(2,9)}`,blocks:[u,...c],pageSettings:{...l.pageSettings},header:l.header?VT(l.header):void 0,footer:l.footer?VT(l.footer):void 0,breakType:e},g={...l,blocks:[...d,h]},m=[...o.slice(0,i),g,f,...o.slice(i+1)];return{...a,document:{...a.document,sections:m},activeSectionIndex:i+1,selection:KT(Ve(u,0))}}(e,t)),s()},applyInsertPageBreakCommand:()=>{d(),c(),r(t=>l(t,t=>uC(t))),s()},canInsertFootnoteCommand:b,applyInsertFootnoteCommand:()=>{b()&&(d(),c(),r(t=>Ez(t)),s())},handleStyleChange:t=>{d(),c(),i(e=>function(t,e){return fC(t,"styleId",e)}(e,t||null)),s()},applyUpdateSectionSettingsCommand:(t,a)=>{d(),c(),n(function(t,e,a){var n;const r=Be(t.document);if(e<0||e>=r.length)return t;const o=[...r];return o[e]={...o[e],...a,pageSettings:{...o[e].pageSettings,...a.pageSettings??{},margins:{...o[e].pageSettings.margins,...(null==(n=a.pageSettings)?void 0:n.margins)??{}}}},{...t,document:{...t.document,sections:o}}}(e,t,a)),s()},applyToggleTrackChangesCommand:()=>{d(),c(),n(function(t){return{...t,trackChangesEnabled:!t.trackChangesEnabled}}(e)),s()},applyToggleShowMarginsCommand:()=>{n({...e,showMargins:!e.showMargins}),s()},applyToggleShowParagraphMarksCommand:()=>{n({...e,showParagraphMarks:!e.showParagraphMarks}),s()},applyAcceptRevisionsCommand:()=>{d(),c(),n(function(t){var e;const a=va(t),n=ha(t),r=new Set;for(let i=a.startIndex;i<=a.endIndex;i+=1){const t=n[i],o=WT(t,i===a.startIndex?a.startParagraphOffset:0,i===a.endIndex?a.endParagraphOffset:ke(t));for(const a of o)(null==(e=a.revision)?void 0:e.id)&&r.add(a.revision.id)}let o=t;for(const i of r)o=Rz(o,i);return o}(e)),s()},applyRejectRevisionsCommand:()=>{d(),c(),n(function(t){var e;const a=va(t),n=ha(t),r=new Set;for(let i=a.startIndex;i<=a.endIndex;i+=1){const t=n[i],o=WT(t,i===a.startIndex?a.startParagraphOffset:0,i===a.endIndex?a.endParagraphOffset:ke(t));for(const a of o)(null==(e=a.revision)?void 0:e.id)&&r.add(a.revision.id)}let o=t;for(const i of r)o=Lz(o,i);return o}(e)),s()},applyLinkCommand:y,promptForLink:()=>{const a=zz(e)??"";p()&&!a||t.openLinkDialog(a)},removeLinkCommand:()=>{y(null)},applyImageAltCommand:t=>{u()&&(d(),c(),r(e=>function(t,e){const a=lL(t);if(!(null==a?void 0:a.run.image))return t;const n=ha(t).map((t,n)=>n!==a.paragraphIndex?TT(t):{...TT(t),runs:t.runs.map(t=>t.id===a.run.id&&t.image?{...t,image:{...t.image,alt:e??void 0}}:IT(t))});return ZT(t,n,YT(n,va(t)))}(e,t),{mergeKey:"imageAlt"}),s())},promptForImageAlt:()=>{var e;const a=u();if(!a)return;const n=(null==(e=a.run.image)?void 0:e.alt)??"";t.openImageAltDialog(n)},applyImageCaptionCommand:e=>{u()&&(d(),c(),r(a=>hL(a,e,t.imageCaptionLabel()),{mergeKey:"imageCaption"}),s())},promptForImageCaption:()=>{u()&&t.openImageCaptionDialog(cL(e)??"")},handleListTab:t=>!_e(e.document,e.selection.focus.paragraphId,sa(e))&&(!!f()&&(d(),c(),i(e=>"indent"===t?function(t){const e=va(t),a=ha(t).map((t,a)=>a<e.startIndex||a>e.endIndex?TT(t):t.list?NT(t,(t.list.level??0)+1):TT(t));return ZT(t,a,YT(a,e))}(e):Nz(e)),s(),!0)),handleListEnter:()=>{const t=g();return!!(null==t?void 0:t.list)&&(d(),c(),p()&&0===Ce(t).length?i(t=>function(t){const e=va(t),a=ha(t).map((t,a)=>a<e.startIndex||a>e.endIndex?TT(t):qT(t));return ZT(t,a,YT(a,e))}(t)):r(t=>l(t,t=>function(t){const e=ma(t.selection)?t:XT(t),{paragraph:a,index:n,offset:r}=jT(e),o=RT(a,WT(a,0,r),OT(a,r)),i=WT(a,r,ke(a)),l=i.length>0?zT(a,i.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Sa("");return t.style=a.style?{...a.style}:void 0,t.list=CT(a.list),t})(),s=ha(e);return ZT(e,[...kT(s.slice(0,n)),o,l,...kT(s.slice(n+1))],KT(Ve(l,0)))}(t)),{mergeKey:"splitListItem"}),s(),!0)},handleListBoundaryBackspace:t=>{const a=g();if(!(null==a?void 0:a.list)||!p())return!1;return 0===Ee(a,e.selection.focus)&&(d(),c(),i(t=>Nz(t)),t.currentTarget.value="",s(),!0)}}}class Oz{constructor(){a(this,"bindings",new Map)}register(t){this.bindings.set(t.id,t)}unregister(t){this.bindings.delete(t)}getBindings(){return Array.from(this.bindings.values())}execute(t,e,a){var n;const r=t.ctrlKey||t.metaKey,o=t.key.toLowerCase();for(const i of this.bindings.values())if(i.key.toLowerCase()===o&&Boolean(i.ctrlOrMeta)===r&&Boolean(i.shift)===t.shiftKey&&Boolean(i.alt)===t.altKey){if(i.command&&a){if((null==(n=a.canExecuteCommand)?void 0:n.call(a,i.command))??!0)return a.executeCommand(i.command),t.preventDefault(),!0}if(!1!==i.execute(e,t))return t.preventDefault(),!0}return!1}}const Pz=[{id:"selectAll",command:"selectAll",key:"a",ctrlOrMeta:!0,execute:t=>{const e=t.state(),a=ha(e);if(0===a.length)return!1;const n=a[0],r=a[a.length-1];return t.clearPreferredColumn(),t.applyState(YC(e,{anchor:Ve(n,0),focus:Ve(r,Ce(r).length)})),t.focusInput(),!0}},{id:"editImageAlt",command:"editImageAlt",key:"a",ctrlOrMeta:!0,alt:!0,execute:t=>!!t.selectedImageRun()&&(t.commandsController.promptForImageAlt(),!0)},{id:"insertFootnote",command:"insertFootnote",key:"f",ctrlOrMeta:!0,alt:!0,execute:t=>(t.commandsController.applyInsertFootnoteCommand(),!0)},{id:"pastePlainText",command:"pastePlainText",key:"v",ctrlOrMeta:!0,shift:!0,execute:t=>(t.setForcePlainTextPaste(!0),t.focusInput(),!0)},{id:"bold",command:"bold",key:"b",ctrlOrMeta:!0,execute:t=>(t.commandsController.applyBooleanStyleCommand("bold"),!0)},{id:"italic",command:"italic",key:"i",ctrlOrMeta:!0,execute:t=>(t.commandsController.applyBooleanStyleCommand("italic"),!0)},{id:"underline",command:"underline",key:"u",ctrlOrMeta:!0,execute:t=>(t.commandsController.applyBooleanStyleCommand("underline"),!0)},{id:"link",command:"link",key:"k",ctrlOrMeta:!0,execute:t=>(t.commandsController.promptForLink(),!0)},{id:"orderedList",command:"orderedList",key:"7",ctrlOrMeta:!0,shift:!0,execute:t=>(t.commandsController.applyParagraphListCommand("ordered"),!0)},{id:"bulletList",command:"bulletList",key:"8",ctrlOrMeta:!0,shift:!0,execute:t=>(t.commandsController.applyParagraphListCommand("bullet"),!0)},{id:"find",command:"find",key:"f",ctrlOrMeta:!0,execute:t=>(t.toggleFindReplace(!0),!0)},{id:"replace",command:"replace",key:"h",ctrlOrMeta:!0,execute:t=>(t.toggleReplace(!0),!0)},{id:"undo",command:"undo",key:"z",ctrlOrMeta:!0,execute:t=>(t.performUndo(),!0)},{id:"redo",command:"redo",key:"z",ctrlOrMeta:!0,shift:!0,execute:t=>(t.performRedo(),!0)},{id:"redoAlternative",command:"redo",key:"y",ctrlOrMeta:!0,execute:t=>(t.performRedo(),!0)},{id:"pageBreak",command:"pageBreak",key:"Enter",ctrlOrMeta:!0,execute:t=>(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>uC(t))),t.focusInput(),!0)},{id:"lineBreak",command:"lineBreak",key:"Enter",shift:!0,execute:t=>(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>aC(t,"\n"))),t.focusInput(),!0)},{id:"splitBlock",command:"splitBlock",key:"Enter",execute:t=>(t.commandsController.handleListEnter()||(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>pC(t))),t.focusInput()),!0)}];function Wz(t){const e=new Oz;Pz.forEach(t=>e.register(t));return{handleKeyDown:a=>{const n=t.state();if(t.isReadOnly()){const t=a.key,e=t.toLowerCase(),n="ArrowLeft"===t||"ArrowRight"===t||"ArrowUp"===t||"ArrowDown"===t||"Home"===t||"End"===t||"PageUp"===t||"PageDown"===t,r="Shift"===t||"Control"===t||"Meta"===t||"Alt"===t,o=(a.ctrlKey||a.metaKey)&&("a"===e||"c"===e);return void(n||r||o||a.preventDefault())}const r=t.executeCommand?{executeCommand:(e,a)=>{var n;return null==(n=t.executeCommand)?void 0:n.call(t,e,a)},canExecuteCommand:(e,a)=>{var n;return null==(n=t.canExecuteCommand)?void 0:n.call(t,e,a)}}:void 0;if(!e.execute(a,t,r)){if((a.ctrlKey||a.metaKey)&&!a.altKey){if(("ArrowLeft"===a.key||"ArrowRight"===a.key)&&(a.preventDefault(),t.resetTransactionGrouping(),t.moveSelectionByWord("ArrowLeft"===a.key?"left":"right",a.shiftKey)))return void t.focusInput();if("Backspace"===a.key||"Delete"===a.key){if(a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),!ma(n.selection))return t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>rC(t))),a.currentTarget.value="",void t.focusInput();const e=ha(n),r=e.findIndex(t=>t.id===n.selection.focus.paragraphId),o=e[r];if(!o)return a.currentTarget.value="",void t.focusInput();if("Backspace"===a.key&&o.list){if(0===Ee(o,n.selection.focus))return t.applySelectionAwareParagraphCommand(t=>Nz(t)),a.currentTarget.value="",void t.focusInput()}const i=n.selection.focus.offset,l=Ce(o),s=wz(l,i);return"Backspace"===a.key?0===i||s.start===i?t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>rC(t))):t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(YC(e,{anchor:Ve(o,s.start),focus:Ve(o,i)}),t=>rC(t))):i>=l.length?t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>oC(t))):s.end>i?t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(YC(e,{anchor:Ve(o,i),focus:Ve(o,s.end)}),t=>rC(t))):t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>oC(t))),a.currentTarget.value="",void t.focusInput()}}if("Home"===a.key||"End"===a.key){a.preventDefault(),t.resetTransactionGrouping();const e="Home"===a.key?"start":"end";return a.ctrlKey||a.metaKey?t.moveSelectionToDocumentBoundary(e,a.shiftKey):t.moveSelectionToParagraphBoundary(e,a.shiftKey),void t.focusInput()}if(!a.altKey||a.ctrlKey||a.metaKey||"ArrowUp"!==a.key&&"ArrowDown"!==a.key||(a.preventDefault(),t.resetTransactionGrouping(),t.clearPreferredColumn(),!t.moveSelectedImageByParagraph("ArrowUp"===a.key?-1:1)))switch(a.key){case"Backspace":return t.commandsController.handleListBoundaryBackspace(a)?void a.preventDefault():(a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>rC(t))),a.currentTarget.value="",void t.focusInput());case"Delete":return a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>oC(t))),a.currentTarget.value="",void t.focusInput();case"Tab":{if(t.commandsController.handleListTab(a.shiftKey?"outdent":"indent"))return void a.preventDefault();const e=t.resolveAdjacentTableCellPosition(n.document,n.selection.focus.paragraphId,a.shiftKey?-1:1);if(e)return a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applySelectionPreservingStructure({anchor:e,focus:e}),void t.focusInput();break}case"ArrowLeft":return a.preventDefault(),t.resetTransactionGrouping(),a.shiftKey?(t.clearPreferredColumn(),t.applyState(jC(n,-1))):(t.clearPreferredColumn(),t.applyState(QC(n))),void t.focusInput();case"ArrowRight":return a.preventDefault(),t.resetTransactionGrouping(),a.shiftKey?(t.clearPreferredColumn(),t.applyState(function(t){return jC(t,1)}(n))):(t.clearPreferredColumn(),t.applyState(_C(n))),void t.focusInput();case"ArrowUp":return a.preventDefault(),t.resetTransactionGrouping(),void(a.shiftKey?t.moveVerticalSelection(-1,!0)||(t.applyState(function(t){return XC(t,-1)}(n)),t.focusInput()):t.moveVerticalByBlock(-1)||(t.applyState(function(t){return KC(t,-1)}(n)),t.focusInput()));case"ArrowDown":return a.preventDefault(),t.resetTransactionGrouping(),void(a.shiftKey?t.moveVerticalSelection(1,!0)||(t.applyState(function(t){return XC(t,1)}(n)),t.focusInput()):t.moveVerticalByBlock(1)||(t.applyState(function(t){return KC(t,1)}(n)),t.focusInput()));default:return}}},registry:e}}const Hz=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];const Uz=t=>Math.round(t/In*Mn);function Fz(t,e=3){var a;const n=[];for(const r of Je(t.document)){const t=on(null==(a=r.style)?void 0:a.styleId);if(null===t||t>e)continue;const o=Ce(r).trim();o&&n.push({id:r.id,level:t,text:o})}return n}function Bz(t){const e=xa(t.text??"");return{...e,...t,id:e.id}}function Gz(t,e){const a=Sa("");return a.runs=t,e&&(a.style=e),a}function Zz(t,e,a){const n=void 0!==e?String(e):"";return Gz([Bz({text:`${t.text}\t${n}`})],{tabs:[{position:a,type:"right",leader:"dot"}],spacingAfter:Uz(40),indentLeft:Uz(397*(t.level-1))})}function Dz(t){const{width:e,margins:a}=t.pageSettings,n=Math.max(0,e-a.left-a.right);return Math.round(n*wn*100)/100}function Kz(t,e,a,n){const r=Be(t.document),o=r[e];if(!o)return t;const i=[...r];return i[e]={...o,blocks:a},{...t,document:{...t.document,sections:i},selection:KT(Ve(n,0))}}function jz(t,e=()=>{},a=3){if("main"!==da(t))return t;const n=sa(t),r=Be(t.document)[n];if(!r)return t;const o=function(t,e,a){const n=t.map(t=>Zz(t,e(t.id),a));return[Gz([Bz({text:"",fieldChar:{kind:"begin"}}),Bz({text:"",fieldInstruction:' TOC \\o "1-3" \\h \\z \\u '}),Bz({text:"",fieldChar:{kind:"separate"}})]),...n,Gz([Bz({text:"",fieldChar:{kind:"end"}})])]}(Fz(t,a),e,Dz(r)),i=ua(t,t.selection.focus),l=r.blocks.findIndex(t=>t.id===i.paragraphId||"paragraph"!==t.type&&Ge(t).some(t=>t.id===i.paragraphId)),s=-1===l?r.blocks.length:l+1;return Kz(t,n,[...r.blocks.slice(0,s),...o,...r.blocks.slice(s)],o[0])}function Xz(t,e=()=>{},a=3){const n=sa(t),r=Be(t.document)[n];if(!r)return t;const o=function(t){var e,a,n;let r=0,o="",i=-1,l=-1,s=!1;for(let d=0;d<t.length;d+=1){const c=t[d];if("paragraph"===c.type)for(const t of c.runs)if("begin"===(null==(e=t.fieldChar)?void 0:e.kind))r+=1,1===r&&(l=d,o="",s=!1,i=-1);else if(1===r&&void 0!==t.fieldInstruction)o+=t.fieldInstruction,/\bTOC\b/i.test(o)&&(s=!0);else if("separate"===(null==(a=t.fieldChar)?void 0:a.kind))1===r&&(i=d);else if("end"===(null==(n=t.fieldChar)?void 0:n.kind)){if(1===r&&s)return{startBlockIndex:i>=0?i:l,endBlockIndex:d};r=Math.max(0,r-1)}}return null}(r.blocks);if(!o)return t;const i=Fz(t,a).map(t=>Zz(t,e(t.id),Dz(r)));return Kz(t,n,[...r.blocks.slice(0,o.startBlockIndex+1),...i,...r.blocks.slice(o.endBlockIndex)],i[0]??r.blocks[o.startBlockIndex])}function Jz(t){return null!=t&&""!==t?Number(t):null}function Yz({gate:t,style:e,selection:a,history:n,formatting:r,link:o,command:i,valueCommand:l,actionCommand:s}){const d=e.state;return{selectAll:i("selectAll",r.selectAll),insertFootnote:i("insertFootnote",r.insertFootnote),pastePlainText:i("pastePlainText",r.pastePlainText),bold:i("bold",r.bold,()=>({isActive:Boolean(d().bold)})),italic:i("italic",r.italic,()=>({isActive:Boolean(d().italic)})),underline:i("underline",r.underline,()=>({isActive:Boolean(d().underline)})),strike:i("strike",r.strike,()=>({isActive:Boolean(d().strike)})),superscript:i("superscript",r.superscript,()=>({isActive:Boolean(d().superscript)})),subscript:i("subscript",r.subscript,()=>({isActive:Boolean(d().subscript)})),link:i("link",()=>(o.prompt(),!0),()=>({isEnabled:t.isCommandEnabled("link")&&o.canPrompt(),isActive:Boolean(d().link)})),alignLeft:i("alignLeft",r.alignLeft,()=>({isActive:"left"===d().align})),alignCenter:i("alignCenter",r.alignCenter,()=>({isActive:"center"===d().align})),alignRight:i("alignRight",r.alignRight,()=>({isActive:"right"===d().align})),alignJustify:i("alignJustify",r.alignJustify,()=>({isActive:"justify"===d().align})),orderedList:i("orderedList",r.orderedList,()=>({isActive:"ordered"===d().listKind})),bulletList:i("bulletList",r.bulletList,()=>({isActive:"bullet"===d().listKind})),find:i("find",r.find),replace:i("replace",r.replace),toggleTrackChanges:i("toggleTrackChanges",r.toggleTrackChanges),acceptRevisions:i("acceptRevisions",r.acceptRevisions),rejectRevisions:i("rejectRevisions",r.rejectRevisions),toggleShowMargins:i("toggleShowMargins",r.toggleShowMargins),toggleShowParagraphMarks:i("toggleShowParagraphMarks",r.toggleShowParagraphMarks),togglePreciseFonts:i("togglePreciseFonts",r.togglePreciseFonts,()=>(Ro(),{isActive:Lo()})),undo:i("undo",n.undo,()=>({isEnabled:t.isCommandEnabled("undo")&&n.canUndo()})),redo:i("redo",n.redo,()=>({isEnabled:t.isCommandEnabled("redo")&&n.canRedo()})),pageBreak:i("pageBreak",r.pageBreak),lineBreak:i("lineBreak",r.lineBreak),splitBlock:i("splitBlock",r.splitBlock),setFontFamily:l("setFontFamily",t=>r.setFontFamily(t||null),()=>d().fontFamily),setFontSize:l("setFontSize",t=>{const e=t&&"object"==typeof t&&"size"in t?t.size:t;return r.setFontSize(null!=e&&""!==e?AM(e):null),!0},()=>SM(d().fontSize)),increaseFontSize:i("increaseFontSize",r.increaseFontSize),decreaseFontSize:i("decreaseFontSize",r.decreaseFontSize),changeTextCase:s("changeTextCase",t=>{r.changeTextCase(t??"sentence")},()=>({isEnabled:t.isCommandEnabled("changeTextCase")&&!a.isCollapsed()})),clearFormatting:i("clearFormatting",r.clearFormatting),setColor:l("setColor",t=>r.setColor(t??null),()=>d().color||null),setHighlight:l("setHighlight",t=>r.setHighlight(t??null),()=>d().highlight||null),setTextShading:l("setTextShading",t=>r.setTextShading(t??null),()=>d().textShading||null),setStyleId:l("setStyleId",t=>r.setStyleId(String(t)),()=>d().styleId||"normal"),setUnderlineStyle:l("setUnderlineStyle",t=>(r.setUnderlineStyle(t||null),!0),()=>d().underlineStyle)}}function Qz({gate:t,style:e,document:a,link:n,image:r,browser:o,actionCommand:i}){const l=e.state;return{documentStyles:i("documentStyles",()=>{},()=>({isEnabled:!0,value:a.documentStyles()})),print:i("print",()=>o.print(),()=>({isEnabled:!0})),copy:i("copy",()=>o.copy(),()=>({isEnabled:!0})),exportDocx:i("exportDocx",()=>a.exportDocx()),exportPdf:i("exportPdf",()=>a.exportPdf()),importDocument:i("importDocument",()=>a.importDocument()),insertImage:i("insertImage",()=>a.insertImage()),insertShape:i("insertShape",t=>a.insertShape(String(t))),unlink:i("unlink",()=>n.remove(),()=>({isEnabled:t.isCommandEnabled("unlink")&&Boolean(l().link),isActive:Boolean(l().link)})),editImageAlt:i("editImageAlt",()=>r.promptAlt(),()=>({isEnabled:r.isSelected(),isActive:r.isSelected()})),insertImageCaption:i("insertImageCaption",()=>r.promptCaption(),()=>({isEnabled:r.isSelected(),isActive:r.isSelected()}))}}function _z({style:t,paragraph:e,section:a,valueCommand:n,actionCommand:r}){const o=t.state;return{outdent:r("outdent",()=>e.outdent()),indent:r("indent",()=>e.indent()),togglePageBreakBefore:r("togglePageBreakBefore",()=>e.togglePageBreakBefore(),()=>({isActive:Boolean(o().pageBreakBefore)})),toggleKeepWithNext:r("toggleKeepWithNext",()=>e.toggleKeepWithNext(),()=>({isActive:Boolean(o().keepWithNext)})),setSpacingAfter:n("setSpacingAfter",t=>(e.setSpacingAfter(Jz(t)),!0),()=>o().spacingAfter),setSpacingBefore:n("setSpacingBefore",t=>(e.setSpacingBefore(Jz(t)),!0),()=>o().spacingBefore),setIndentLeft:n("setIndentLeft",t=>(e.setIndentLeft(Jz(t)),!0),()=>o().indentLeft),setIndentRight:n("setIndentRight",t=>(e.setIndentRight(Jz(t)),!0),()=>o().indentRight),setIndentFirstLine:n("setIndentFirstLine",t=>(e.setIndentFirstLine(Jz(t)),!0),()=>o().indentFirstLine),setIndentHanging:n("setIndentHanging",t=>(e.setIndentHanging(Jz(t)),!0),()=>o().indentHanging),setSpecialIndent:r("setSpecialIndent",t=>{const a=t??{};e.setSpecialIndent(a.kind??"none",Jz(a.value))},()=>{const t=Number(o().indentFirstLine),e=Number(o().indentHanging),a=Number.isFinite(e)&&e>0?"hanging":Number.isFinite(t)&&t>0?"firstLine":"none";return{isActive:"none"!==a,value:a}}),setParagraphShading:n("setParagraphShading",t=>(e.setShading(t??null),!0),()=>o().shading||"#ffffff"),applyParagraphBorders:r("applyParagraphBorders",()=>e.applyBorders()),setLineHeight:n("setLineHeight",t=>(e.setLineHeight(Jz(t)),!0),()=>o().lineHeight),setListFormat:r("setListFormat",t=>e.setListFormat(String(t))),setListStartAt:r("setListStartAt",t=>e.setListStartAt(Jz(t))),toggleOrientation:r("toggleOrientation",()=>a.toggleOrientation(),()=>({isActive:a.isLandscape()})),setOrientation:r("setOrientation",t=>a.setOrientation(t)),sectionBreakNextPage:r("sectionBreakNextPage",()=>a.breakNextPage()),sectionBreakContinuous:r("sectionBreakContinuous",()=>a.breakContinuous()),setPageMargins:r("setPageMargins",t=>{a.setPageMargins(t??{})},()=>({value:a.getMargins()}))}}function $z({gate:t,table:e,actionCommand:a}){return{tableContext:a("tableContext",()=>{},()=>({isEnabled:e.insideTable(),isActive:e.insideTable(),value:e.selectionLabel()})),tableMerge:a("tableMerge",()=>e.merge(),()=>({isEnabled:t.isCommandEnabled("tableMerge")&&e.canMerge()})),tableSplit:a("tableSplit",()=>e.split(),()=>({isEnabled:t.isCommandEnabled("tableSplit")&&e.canSplit()})),tableInsertColumnBefore:a("tableInsertColumnBefore",()=>e.insertColumnBefore(),()=>({isEnabled:t.isCommandEnabled("tableInsertColumnBefore")&&e.canEditColumn()})),tableInsertColumnAfter:a("tableInsertColumnAfter",()=>e.insertColumnAfter(),()=>({isEnabled:t.isCommandEnabled("tableInsertColumnAfter")&&e.canEditColumn()})),tableDeleteColumn:a("tableDeleteColumn",()=>e.deleteColumn(),()=>({isEnabled:t.isCommandEnabled("tableDeleteColumn")&&e.canEditColumn()})),tableInsertRowBefore:a("tableInsertRowBefore",()=>e.insertRowBefore(),()=>({isEnabled:t.isCommandEnabled("tableInsertRowBefore")&&e.canEditRow()})),tableInsertRowAfter:a("tableInsertRowAfter",()=>e.insertRowAfter(),()=>({isEnabled:t.isCommandEnabled("tableInsertRowAfter")&&e.canEditRow()})),tableDeleteRow:a("tableDeleteRow",()=>e.deleteRow(),()=>({isEnabled:t.isCommandEnabled("tableDeleteRow")&&e.canEditRow()})),tableCellShading:a("tableCellShading",t=>e.cellShading(t??null)),tableCellBorders:a("tableCellBorders",()=>e.cellBorders()),tableCellNoBorders:a("tableCellNoBorders",()=>e.cellNoBorders()),tableWidth100:a("tableWidth100",()=>e.width100()),tableAlignLeft:a("tableAlignLeft",()=>e.alignLeft()),tableAlignCenter:a("tableAlignCenter",()=>e.alignCenter()),tableAlignRight:a("tableAlignRight",()=>e.alignRight()),tableSetCellWidth:a("tableSetCellWidth",t=>e.setCellWidth(String(t))),insertTable:a("insertTable",t=>{const{rows:a,cols:n,columns:r}=t??{},o=n??r;a&&o&&e.insert(a,o)})}}function tN(t){const e=e=>{const a=Number(t.styleController.toolbarStyleState().fontSize),n=Number.isFinite(a)&&a>0?xM(a):11,r="increase"===e?function(t){for(const e of MM)if(e>t+1e-6)return e;return Math.round(t)+10}(n):function(t){for(let e=MM.length-1;e>=0;e-=1){const a=MM[e];if(a<t-1e-6)return a}return Math.max(1,Math.round(t)-1)}(n);return t.styleController.applyToolbarValueStyleCommand("fontSize",wM(r)),!0},a=t=>{const e=is(t.document),a=new Map;for(const n of e.pages)for(const t of n.blocks){const e=t.paragraphId;e&&!a.has(e)&&a.set(e,n.index+1)}return t=>a.get(t)},n={isLandscape:()=>{var e,a;const n=sa(t.state()),r=(null==(e=t.state().document.sections)?void 0:e[n])??t.state().document;return"landscape"===(null==(a=null==r?void 0:r.pageSettings)?void 0:a.orientation)},setOrientation:e=>{var a;const n=sa(t.state()),r=(null==(a=t.state().document.sections)?void 0:a[n])??t.state().document;r&&t.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...r.pageSettings,orientation:e}})},toggleOrientation:()=>{var e,a;const r=sa(t.state()),o=(null==(e=t.state().document.sections)?void 0:e[r])??t.state().document;if(!o)return;const i=(null==(a=o.pageSettings)?void 0:a.orientation)??"portrait";n.setOrientation("portrait"===i?"landscape":"portrait")},breakNextPage:()=>t.commandsController.applyInsertSectionBreakCommand("nextPage"),breakContinuous:()=>t.commandsController.applyInsertSectionBreakCommand("continuous"),getMargins:()=>{var e,a;const n=sa(t.state()),r=(null==(e=t.state().document.sections)?void 0:e[n])??t.state().document;return null==(a=null==r?void 0:r.pageSettings)?void 0:a.margins},setPageMargins:e=>{var a;const n=sa(t.state()),r=(null==(a=t.state().document.sections)?void 0:a[n])??t.state().document;(null==r?void 0:r.pageSettings)&&t.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...r.pageSettings,margins:{...r.pageSettings.margins,...e}}})}};return function(t){const e=(a=t.gate.isCommandEnabled,(t,e,n)=>({execute:e,refresh:()=>({isEnabled:a(t),...null==n?void 0:n()})}));var a;const n=function(t){return(e,a,n)=>({execute:a,refresh:()=>({isEnabled:t(e),value:n()})})}(t.gate.isCommandEnabled),r=function(t){return(e,a,n)=>({execute:t=>(a(t),!0),refresh:()=>({isEnabled:t(e),...null==n?void 0:n()})})}(t.gate.isCommandEnabled);return{name:"Essentials",commands:{...Yz({gate:t.gate,style:t.style,selection:t.selection,history:t.history,formatting:t.formatting,link:t.link,command:e,valueCommand:n,actionCommand:r}),...Qz({gate:t.gate,style:t.style,document:t.document,link:t.link,image:t.image,browser:t.browser,actionCommand:r}),..._z({style:t.style,paragraph:t.paragraph,section:t.section,valueCommand:n,actionCommand:r}),...$z({gate:t.gate,table:t.table,actionCommand:r})}}}({gate:{isCommandEnabled:e=>!t.isReadOnly()&&("insertFootnote"!==e||t.commandsController.canInsertFootnoteCommand())},style:{state:()=>t.styleController.toolbarStyleState()},selection:{isCollapsed:()=>ma(t.state().selection)},history:{canUndo:()=>t.undoStack().length>0,canRedo:()=>t.redoStack().length>0,undo:()=>(t.historyActions.performUndo(),!0),redo:()=>(t.historyActions.performRedo(),!0)},formatting:{selectAll:()=>{const e=Je(t.state().document);if(0===e.length)return!1;const a=e[0],n=e[e.length-1];return t.applyState({...t.state(),selection:{anchor:Ve(a,0),focus:Ve(n,Ce(n).length)}}),t.focusInput(),!0},insertFootnote:()=>(t.commandsController.applyInsertFootnoteCommand(),!0),insertTableOfContents:()=>(t.applyTransactionalState(t=>jz(t,a(t))),t.focusInput(),!0),updateTableOfContents:()=>(t.applyTransactionalState(t=>Xz(t,a(t))),t.focusInput(),!0),pastePlainText:()=>(t.forcePlainTextPaste.set(!0),t.focusInput(),!0),bold:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("bold"),!0),italic:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("italic"),!0),underline:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("underline"),!0),strike:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("strike"),!0),superscript:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("superscript"),!0),subscript:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("subscript"),!0),alignLeft:()=>(t.commandsController.applyParagraphStyleCommand("align","left"),!0),alignCenter:()=>(t.commandsController.applyParagraphStyleCommand("align","center"),!0),alignRight:()=>(t.commandsController.applyParagraphStyleCommand("align","right"),!0),alignJustify:()=>(t.commandsController.applyParagraphStyleCommand("align","justify"),!0),orderedList:()=>(t.commandsController.applyParagraphListCommand("ordered"),!0),bulletList:()=>(t.commandsController.applyParagraphListCommand("bullet"),!0),find:()=>(t.findReplace.setIsOpen(!0),!0),replace:()=>(t.findReplace.setIsOpen(!0),!0),toggleTrackChanges:()=>(t.commandsController.applyToggleTrackChangesCommand(),!0),acceptRevisions:()=>(t.commandsController.applyAcceptRevisionsCommand(),!0),rejectRevisions:()=>(t.commandsController.applyRejectRevisionsCommand(),!0),toggleShowMargins:()=>(t.commandsController.applyToggleShowMarginsCommand(),!0),toggleShowParagraphMarks:()=>(t.commandsController.applyToggleShowParagraphMarksCommand(),!0),togglePreciseFonts:()=>(wc(),!0),pageBreak:()=>(t.applyTransactionalState(e=>t.tableOps.applyTableAwareParagraphEdit(e,t=>uC(t))),t.focusInput(),!0),lineBreak:()=>(t.applyTransactionalState(e=>t.tableOps.applyTableAwareParagraphEdit(e,t=>aC(t,"\n"))),t.focusInput(),!0),splitBlock:()=>(t.commandsController.handleListEnter()||(t.applyTransactionalState(e=>t.tableOps.applyTableAwareParagraphEdit(e,t=>pC(t))),t.focusInput()),!0),setFontFamily:e=>(t.styleController.applyToolbarValueStyleCommand("fontFamily",e),!0),setFontSize:e=>(t.styleController.applyToolbarValueStyleCommand("fontSize",e),!0),increaseFontSize:()=>e("increase"),decreaseFontSize:()=>e("decrease"),changeTextCase:e=>(t.commandsController.applyChangeTextCaseCommand(e),!0),clearFormatting:()=>ma(t.state().selection)?(t.styleController.clearPendingCaretTextStyle(),t.focusInput(),!0):(t.commandsController.applyClearFormattingCommand(),!0),setColor:e=>(t.styleController.applyToolbarValueStyleCommand("color",e),!0),setHighlight:e=>(t.styleController.applyToolbarValueStyleCommand("highlight",e),!0),setTextShading:e=>(t.styleController.applyToolbarValueStyleCommand("shading",e),!0),setStyleId:e=>(t.commandsController.handleStyleChange(e),!0),setUnderlineStyle:e=>t.styleController.applyToolbarValueStyleCommand("underlineStyle",e)},document:{documentStyles:()=>{var e;return Object.values((null==(e=t.state().document)?void 0:e.styles)??{}).map(t=>{var e,a,n;return{id:t.id,name:t.name,fontFamily:(null==(a=null==(e=t.textStyle)?void 0:e.fontFamily)?void 0:a.trim())||void 0,fontSize:"number"==typeof(null==(n=t.textStyle)?void 0:n.fontSize)?t.textStyle.fontSize:void 0}})},exportDocx:()=>{t.docIO.handleExportDocx()},exportPdf:()=>{t.docIO.handleExportPdf()},importDocument:()=>{var e;return null==(e=t.importInputRef())?void 0:e.click()},insertImage:()=>{var e;return null==(e=t.imageInputRef())?void 0:e.click()},insertShape:e=>t.applyTransactionalState(t=>function(t,e){const a=ma(t.selection)?t:XT(t),{paragraph:n,index:r,offset:o}=jT(a),i={width:150,height:100,blocks:[Sa("")],shape:{preset:e,fill:"#4472C4",borderColor:"#2F528F",borderWidthPt:1},floating:nL(void 0,"front")},l=HT(n,o,[wa("",OT(n,o),void 0,i)]);return ZT(a,ha(a).map((t,e)=>e===r?l:TT(t)),KT(Ve(l,o+1)))}(t,e))},link:{prompt:()=>t.commandsController.promptForLink(),remove:()=>t.commandsController.removeLinkCommand(),canPrompt:()=>!ma(t.state().selection)||Boolean(t.styleController.toolbarStyleState().link)},image:{promptAlt:()=>t.commandsController.promptForImageAlt(),promptCaption:()=>t.commandsController.promptForImageCaption(),isSelected:()=>Boolean(t.selectedImageRun())},browser:{print:()=>window.print(),copy:()=>{document.execCommand("copy")}},paragraph:{togglePageBreakBefore:()=>t.commandsController.toggleParagraphFlagCommand("pageBreakBefore"),toggleKeepWithNext:()=>t.commandsController.toggleParagraphFlagCommand("keepWithNext"),setSpacingAfter:e=>t.commandsController.applyParagraphStyleCommand("spacingAfter",e),setSpacingBefore:e=>t.commandsController.applyParagraphStyleCommand("spacingBefore",e),setIndentLeft:e=>t.commandsController.applyParagraphStyleCommand("indentLeft",e),setIndentRight:e=>t.commandsController.applyParagraphStyleCommand("indentRight",e),setIndentFirstLine:e=>t.commandsController.applyParagraphStyleCommand("indentFirstLine",e),setIndentHanging:e=>t.commandsController.applyParagraphStyleCommand("indentHanging",e),setSpecialIndent:(e,a)=>{const n=a??48;t.applyTransactionalState(t=>{let a=fC(t,"indentFirstLine",null);return a=fC(a,"indentHanging",null),"firstLine"===e?a=fC(a,"indentFirstLine",n):"hanging"===e&&(a=fC(a,"indentHanging",n)),a},{mergeKey:"specialIndent"}),t.focusInput()},setShading:e=>t.commandsController.applyParagraphStyleCommand("shading",e),applyBorders:()=>{const e={width:1,type:"solid",color:"#000000"};t.applyTransactionalState(t=>{let a=fC(t,"borderTop",e);return a=fC(a,"borderRight",e),a=fC(a,"borderBottom",e),a=fC(a,"borderLeft",e),a},{mergeKey:"paraBorders"}),t.focusInput()},setLineHeight:e=>t.commandsController.applyParagraphStyleCommand("lineHeight",e),setListFormat:e=>t.commandsController.handleListFormatChange(e),setListStartAt:e=>t.commandsController.handleListStartAtChange(e),outdent:()=>{t.commandsController.handleListTab("outdent")},indent:()=>{t.commandsController.handleListTab("indent")}},section:n,table:(()=>{const e=(e,a)=>{t.applyTransactionalState(e,{mergeKey:a}),t.focusInput()};return{insideTable:()=>Boolean(_e(t.state().document,t.state().selection.focus.paragraphId,sa(t.state()))),selectionLabel:()=>{if(va(t.state()).isCollapsed)return null;const e=sa(t.state()),a=_e(t.state().document,t.state().selection.anchor.paragraphId,e),n=_e(t.state().document,t.state().selection.focus.paragraphId,e);if(!a||!n||a.blockIndex!==n.blockIndex||a.rowIndex===n.rowIndex&&a.cellIndex===n.cellIndex)return null;const r=t.selectionBoxes().length;return 0===r?null:`Table selection: ${r} cell${1===r?"":"s"}`},canMerge:()=>t.tableOps.canMergeSelectedTable(t.state()),canSplit:()=>t.tableOps.canSplitSelectedTable(t.state()),canEditColumn:()=>t.tableOps.canEditSelectedTableColumn(t.state()),canEditRow:()=>t.tableOps.canEditSelectedTableRow(t.state()),merge:()=>e(e=>t.tableOps.mergeSelectedTable(e),"mergeTable"),split:()=>e(e=>t.tableOps.splitSelectedTable(e),"splitTable"),insertColumnBefore:()=>e(e=>t.tableOps.insertSelectedTableColumn(e,-1),"insertTableColumn"),insertColumnAfter:()=>e(e=>t.tableOps.insertSelectedTableColumn(e,1),"insertTableColumn"),deleteColumn:()=>e(e=>t.tableOps.deleteSelectedTableColumn(e),"deleteTableColumn"),insertRowBefore:()=>e(e=>t.tableOps.insertSelectedTableRow(e,-1),"insertTableRow"),insertRowAfter:()=>e(e=>t.tableOps.insertSelectedTableRow(e,1),"insertTableRow"),deleteRow:()=>e(e=>t.tableOps.deleteSelectedTableRow(e),"deleteTableRow"),cellShading:t=>e(e=>wC(e,"shading",t||null),"tableShading"),cellBorders:()=>e(t=>SC(t,{width:1,type:"solid",color:"#64748b"}),"tableBorders"),cellNoBorders:()=>e(t=>SC(t,{width:0,type:"none",color:"transparent"}),"tableBorders"),width100:()=>e(t=>AC(t,"width","100%"),"tableWidth"),alignLeft:()=>e(t=>wC(t,"horizontalAlign","left"),"tableAlign"),alignCenter:()=>e(t=>wC(t,"horizontalAlign","center"),"tableAlign"),alignRight:()=>e(t=>wC(t,"horizontalAlign","right"),"tableAlign"),setCellWidth:t=>e(e=>function(t,e){return wC(t,"width",e)}(e,t),"tableCellWidth"),insert:(e,a)=>t.tableOps.insertTableCommand(e,a)}})()})}const eN=[{id:"file_new",path:"File/New",labelKey:"menu.file.new",shortcut:"Ctrl+N",hidden:!0,icon:"file-plus"},{id:"file_import",path:"File/Import",labelKey:"toolbar.import",shortcut:"Ctrl+O",command:"importDocument",icon:"upload"},{id:"file_save",path:"File/Save",labelKey:"generic.save",shortcut:"Ctrl+S",hidden:!0,icon:"save"},{id:"file_export",path:"File/Export",labelKey:"menu.file.export",icon:"download"},{id:"file_export_pdf",path:"File/Export/PDF",command:"exportPdf",icon:"file-down"},{id:"file_export_docx",path:"File/Export/DOCX",command:"exportDocx",icon:"file-text"},{id:"file_export_html",path:"File/Export/HTML",hidden:!0},{id:"file_export_md",path:"File/Export/MD",hidden:!0},{id:"file_print",path:"File/Print",labelKey:"menu.file.print",shortcut:"Ctrl+P",command:"print",icon:"printer"},{id:"edit_undo",path:"Edit/Undo",labelKey:"toolbar.undo",shortcut:"Ctrl+Z",command:"undo",icon:"undo-2"},{id:"edit_redo",path:"Edit/Redo",labelKey:"toolbar.redo",shortcut:"Ctrl+Y",command:"redo",icon:"redo-2"},{id:"edit_cut",path:"Edit/Cut",labelKey:"menu.edit.cut",shortcut:"Ctrl+X",hidden:!0},{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",hidden:!0},{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:"view_outline",path:"View/Show Outline",labelKey:"menu.view.outline",hidden:!0},{id:"view_ruler",path:"View/Show Ruler",hidden:!0},{id:"view_margins",path:"View/Show Margins",labelKey:"menu.view.margins",command:"toggleShowMargins",icon:t=>t.commands.state("toggleShowMargins").isActive?"check-square":"square"},{id:"view_paragraph_marks",path:"View/Show Paragraph Marks",labelKey:"menu.view.paragraphMarks",command:"toggleShowParagraphMarks",icon:t=>t.commands.state("toggleShowParagraphMarks").isActive?"check-square":"square"},{id:"view_precise_fonts",path:"View/Precise Fonts",labelKey:"menu.view.preciseFonts",command:"togglePreciseFonts",icon:t=>t.commands.state("togglePreciseFonts").isActive?"check-square":"square"},{id:"view_fullscreen",path:"View/Full Screen",labelKey:"menu.view.fullscreen",hidden:!0},{id:"view_zoom",path:"View/Zoom",labelKey:"status.zoom",hidden:!0},{id:"view_zoom_50",path:"View/Zoom/50%",hidden:!0},{id:"view_zoom_75",path:"View/Zoom/75%",hidden:!0},{id:"view_zoom_100",path:"View/Zoom/100%",hidden:!0},{id:"view_zoom_125",path:"View/Zoom/125%",hidden:!0},{id:"view_zoom_150",path:"View/Zoom/150%",hidden:!0},{id:"view_zoom_200",path:"View/Zoom/200%",hidden:!0},{id:"insert_image",path:"Insert/Image",labelKey:"toolbar.image",command:"insertImage",icon:"image"},{id:"insert_image_caption",path:"Insert/Image Caption",labelKey:"toolbar.imageCaption",command:"insertImageCaption",icon:"subtitles"},{id:"insert_table",path:"Insert/Table",labelKey:"toolbar.table",command:{name:"insertTable",payload:{rows:3,cols:3}},icon:"table"},{id:"insert_link",path:"Insert/Link",labelKey:"toolbar.link",command:"link",icon:"link"},{id:"insert_footnote",path:"Insert/Footnote",labelKey:"toolbar.footnote",shortcut:"Ctrl+Alt+F",command:"insertFootnote",icon:"footnote"},{id:"insert_toc",path:"Insert/Table of Contents",labelKey:"menu.insert.toc",command:"insertTableOfContents",icon:"list"},{id:"insert_toc_update",path:"Insert/Update Table of Contents",labelKey:"menu.insert.updateToc",command:"updateTableOfContents",icon:"refresh-cw"},{id:"insert_hr",path:"Insert/Horizontal Rule",hidden:!0},{id:"insert_pageBreak",path:"Insert/Page Break",labelKey:"metric.pageBreak",command:"pageBreak",icon:"file-minus"},{id:"insert_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:t=>t.commands.state("toggleOrientation").isActive?"":"check"},{id:"layout_orientation_landscape",path:"Layout/Orientation/Landscape",labelKey:"section.landscape",command:{name:"setOrientation",payload:"landscape"},icon:t=>t.commands.state("toggleOrientation").isActive?"check":""},{id:"tools_wordcount",path:"Tools/Word count",labelKey:"menu.tools.wordcount",hidden:!0},{id:"tools_spelling",hidden:!0,path:"Tools/Spelling"},{id:"tools_preferences",path:"Tools/Preferences",hidden:!0},{id:"help_shortcuts",path:"Help/Keyboard shortcuts",labelKey:"menu.help.shortcuts",hidden:!0},{id:"help_about",path:"Help/About",labelKey:"menu.help.about",hidden:!0}];function aN(t){const e=tN(t.essentials),{runtimePlugins:a,toolbarRegistry:n,menuRegistry:r,dispose:o}=function(t){var e,a;const n=[t.essentialsPlugin,...t.externalPlugins??[]],r=[],o=[],i=fM(),l=new gM;for(const s of Ex(t.t))i.register(s);for(const s of eN)l.register(s);for(const s of n){for(const t of s.toolbar??[]){const e={type:"button",id:t.id,testId:t.id,command:t.command,iconName:t.icon,tab:t.tab??"plugins",group:t.group??"general",row:t.row??1,ribbonSize:t.ribbonSize,order:t.order};i.register(e),r.push(t.id)}for(const t of s.menubar??[])l.register({id:t.id,path:t.path,command:t.command,icon:t.icon,shortcut:t.shortcut}),o.push(t.id)}return null==(e=t.customizeToolbar)||e.call(t,i),null==(a=t.customizeMenubar)||a.call(t,l),{runtimePlugins:n,toolbarRegistry:i,menuRegistry:l,dispose:()=>{for(const t of r)i.remove(t);for(const t of o)l.unregister(t)}}}({essentialsPlugin:e,externalPlugins:t.externalPlugins,t:t.t,customizeToolbar:t.customizeToolbar,customizeMenubar:t.customizeMenubar}),i=function(t){const[e,a]=y(!1),[n,r]=y(new Ua({doc:t.initialDocument}));let o=!1;const i=t=>{var e;const a=jt(t),r=n().commands.get(a);if(!r)return{isEnabled:!1,isActive:!1,value:void 0};const o=(null==(e=r.refresh)?void 0:e.call(r))??{isEnabled:!0};return{isEnabled:!1!==o.isEnabled,isActive:Boolean(o.isActive),value:o.value}};return{runtimeReady:e,runtimeEditor:n,commandStateOf:i,toolbarHost:()=>({commands:{execute:(t,e)=>{const a=Xt(t,e);return n().commands.execute(a.name,a.payload)},canExecute:(t,e)=>{const a=Xt(t,e);return n().commands.canExecute(a.name,a.payload)},state:i},focusEditor:t.focusEditor}),initialize:async()=>{var e,i;try{const e=await Ua.create({doc:t.initialDocument,plugins:t.runtimePlugins});if(o)return void(await e.destroy());const i=n();r(e),await i.destroy(),a(!0),requestAnimationFrame(()=>{var a,n;null==(a=t.onSettled)||a.call(t),null==(n=t.onReady)||n.call(t,e)})}catch(l){t.logger.error("runtime:init failed",l),null==(e=t.onError)||e.call(t,l),null==(i=t.onSettled)||i.call(t)}},dispose:async()=>{o=!0,await n().destroy()}}}({initialDocument:t.initialDocument,runtimePlugins:a,focusEditor:t.focusEditor,logger:t.logger,onReady:t.onReady,onSettled:t.onSettled,onError:t.onError});return I(()=>{i.initialize()}),T(()=>{i.dispose(),o()}),{toolbarRegistry:n,menuRegistry:r,runtimeReady:i.runtimeReady,runtimeEditor:i.runtimeEditor,commandStateOf:i.commandStateOf,toolbarHost:i.toolbarHost}}function nN(t){const{document:e,interaction:a,runtimeClient:n}=t,{commandsController:r,keyboardCommandsController:o}=function(t){const e=qz({state:t.state,logger:t.logger,applyState:t.applyState,applyTransactionalState:t.applyTransactionalState,applySelectionAwareTextCommand:t.tableOps.applySelectionAwareTextCommand,applySelectionAwareParagraphCommand:t.tableOps.applySelectionAwareParagraphCommand,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,focusInput:t.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,toolbarStyleState:t.toolbarStyleState,selectionCollapsed:()=>ma(t.state.selection),selectedImageRun:t.selectedImageRun,openLinkDialog:e=>t.setLinkDialog({isOpen:!0,initialHref:e}),openImageAltDialog:e=>t.setImageAltDialog({isOpen:!0,initialAlt:e}),openImageCaptionDialog:e=>t.setImageCaptionDialog({isOpen:!0,initialCaption:e}),imageCaptionLabel:()=>t.locale().startsWith("en")?"Figure":"Figura"});return{commandsController:e,keyboardCommandsController:{...e,applyBooleanStyleCommand:e=>t.applyBooleanStyleCommand(e)}}}({state:t.state,logger:t.logger,applyState:t.applyState,applyTransactionalState:e.applyTransactionalState,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:t.focusInput,selectedImageRun:a.selectedImageRun,tableOps:a.tableOps,toolbarStyleState:a.styleController.toolbarStyleState,applyBooleanStyleCommand:t=>a.styleController.applyToolbarBooleanStyleCommand(t),locale:t.locale,setLinkDialog:t.setLinkDialog,setImageAltDialog:t.setImageAltDialog,setImageCaptionDialog:t.setImageCaptionDialog}),{runtimeReady:i,runtimeEditor:l,commandStateOf:s,toolbarHost:d,toolbarRegistry:c,menuRegistry:h}=aN({essentials:{state:()=>t.state,isReadOnly:t.isReadOnly,forcePlainTextPaste:{get:t.getForcePlainTextPaste,set:t.setForcePlainTextPaste},undoStack:e.undoStack,redoStack:e.redoStack,commandsController:r,keyboardCommandsController:o,historyActions:e.historyActions,styleController:a.styleController,tableOps:a.tableOps,docIO:e.docIO,importInputRef:t.importInputRef,imageInputRef:t.imageInputRef,selectedImageRun:a.selectedImageRun,selectionBoxes:e.selectionBoxes,focusInput:t.focusInput,applyState:t.applyState,applyTransactionalState:e.applyTransactionalState,findReplace:{setIsOpen:a.fr.setIsOpen}},externalPlugins:t.runtimeOptions().plugins,t:t.translator,customizeToolbar:t.runtimeOptions().customizeToolbar,customizeMenubar:t.runtimeOptions().customizeMenubar,initialDocument:t.getStateSnapshot().document,focusEditor:t.focusInput,logger:t.logger,onReady:e=>{var a,r;n.resolveReady(e),null==(r=(a=t.runtimeOptions()).onReady)||r.call(a,n)},onSettled:()=>{t.setInitialLoading(!1)},onError:t=>n.rejectReady(t)});!function(t,e){const a=()=>e.cloneState(e.getStateSnapshot());t.connectHost({getRuntimeEditor:()=>e.runtimeReady()?e.runtimeEditor():null,getState:()=>a(),getDocument:()=>a().document,setDocument:t=>{e.applyState(Ra(t)),e.resetEditorChromeState(),e.focusInput()},resetDocument:()=>{e.applyState(za()),e.resetEditorChromeState(),e.focusInput()},saveDocument:async()=>{await e.getPersistence().saveDocument(a().document)},getSelection:()=>a().selection,setSelection:t=>{e.applyState({...a(),selection:t}),e.focusInput()},focus:()=>e.focusInput(),blur:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e.setFocused(!1)},clearHistory:()=>e.clearHistory(),importDocx:t=>e.docIO.handleImportFile(t),exportDocx:()=>e.docIO.handleExportDocx(),exportPdf:()=>e.docIO.handleExportPdf()})}(n,{runtimeReady:i,runtimeEditor:l,getStateSnapshot:t.getStateSnapshot,cloneState:t.cloneState,applyState:t.applyState,resetEditorChromeState:e.resetEditorChromeState,focusInput:t.focusInput,setFocused:t.setFocused,clearHistory:e.clearHistory,getPersistence:()=>t.documentOptions().persistence??e.fallbackPersistence,docIO:e.docIO}),x(()=>{if(!i())return;t.state.document,t.state.selection,t.state.activeSectionIndex,t.state.activeZone;const e=t.cloneState(t.getStateSnapshot());l().dispatch(()=>e)});const{handleKeyDown:p}=function(t){const{state:e,isReadOnly:a,logger:n,focusInput:r,clearPreferredColumn:o,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,setForcePlainTextPaste:d,selectedImageRun:c,commandsController:h,tableOps:p,navigation:u,historyActions:f,styleController:g,findReplace:m,runtimeEditor:v}=t,{handleKeyDown:b}=Wz({state:e,isReadOnly:a,clearPreferredColumn:o,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,applyTableAwareParagraphEdit:p.applyTableAwareParagraphEdit,applySelectionAwareParagraphCommand:p.applySelectionAwareParagraphCommand,focusInput:r,commandsController:h,selectedImageRun:c,setForcePlainTextPaste:d,moveSelectionByWord:u.moveSelectionByWord,moveSelectionToDocumentBoundary:u.moveSelectionToDocumentBoundary,moveSelectionToParagraphBoundary:u.moveSelectionToParagraphBoundary,moveSelectedImageByParagraph:f.moveSelectedImageByParagraph,performUndo:f.performUndo,performRedo:f.performRedo,moveVerticalSelection:u.moveVerticalSelection,moveVerticalByBlock:u.moveVerticalByBlock,resolveAdjacentTableCellPosition:p.resolveAdjacentTableCellPosition,applySelectionPreservingStructure:f.applySelectionPreservingStructure,toggleFindReplace:t=>{m.setIsOpen(t??!m.isOpen())},toggleReplace:t=>{m.setIsOpen(t??!m.isOpen())},executeCommand:(t,e)=>v().commands.execute(t,e),canExecuteCommand:t=>v().commands.canExecute(t)});return{handleKeyDown:t=>{Hz.includes(t.key)&&g.clearPendingCaretTextStyle();const a=[t.ctrlKey?"Ctrl":null,t.metaKey?"Meta":null,t.altKey?"Alt":null,t.shiftKey?"Shift":null].filter(Boolean).join("+"),r=a?`${a}+${t.key}`:t.key,o=e().selection;n.debug(`key:down ${r} at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}]`),Vi("input-to-layout"),b(t),Ei("input-to-layout")}}}({state:()=>t.state,isReadOnly:t.isReadOnly,logger:t.logger,focusInput:t.focusInput,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyState:t.applyState,applyTransactionalState:e.applyTransactionalState,setForcePlainTextPaste:t.setForcePlainTextPaste,selectedImageRun:a.selectedImageRun,commandsController:o,tableOps:a.tableOps,navigation:a.navigation,historyActions:e.historyActions,styleController:a.styleController,findReplace:a.fr,runtimeEditor:l});return{commandsController:r,runtimeReady:i,runtimeEditor:l,commandStateOf:s,toolbarHost:d,toolbarRegistry:c,menuRegistry:h,handleKeyDown:p}}var rN=ut('<div class="oasis-editor-shell oasis-editor-app">');const oN=Object.freeze(Object.defineProperty({__proto__:null,OasisEditorApp:function(t={}){var e;const a=(null==(e=t.runtime)?void 0:e.client)??Jt(),n=()=>t.ui??{},r=()=>t.document??{};fT();const o=Ot(()=>n().locale??"pt-BR"),i=bo("app"),{state:l,commitState:s,getStateSnapshot:d}=function(t){const e=t.initialState?Px(t.initialState):t.initialDocument?Ra(t.initialDocument):za();let a=e;const[n,r]=y(e);return{state:new Proxy({},{get(t,e){const a=n();if(null!==a&&("object"==typeof a||"function"==typeof a))return Reflect.get(a,e)},has(t,e){const a=n();return null!==a&&("object"==typeof a||"function"==typeof a)&&Reflect.has(a,e)},ownKeys(t){const e=n();return null===e||"object"!=typeof e&&"function"!=typeof e?[]:Reflect.ownKeys(e)},getOwnPropertyDescriptor(t,e){const a=n();return null===a||"object"!=typeof a&&"function"!=typeof a?{configurable:!0,enumerable:!0}:{...Reflect.getOwnPropertyDescriptor(a,e),configurable:!0,enumerable:!0}}}),setStateSignal:r,commitState:t=>{a=t,r(t)},getStateSnapshot:()=>a}}({initialDocument:r().initialDocument,initialState:r().initialState}),c=t=>{s(t)},h=Px;let p=!1;const{showChrome:u,showTitleBar:f,showMenubar:g,showToolbar:m,showOutline:v,toolbarView:b,toolbarLayout:x,isReadOnly:S,useComposedShell:A,loadingOptions:C,loadingLabel:k,shellComponent:V}=function(t){const{ui:e,documentOptions:a}=t,n=()=>{const t=e().loading;return"object"==typeof t&&null!==t?t:void 0};return{showChrome:()=>e().showChrome??!0,showTitleBar:()=>e().showTitleBar??!0,showMenubar:()=>e().showMenubar??!0,showToolbar:()=>e().showToolbar??!0,showOutline:()=>e().showOutline??!0,toolbarView:()=>{var t;return(null==(t=e().toolbar)?void 0:t.view)??"ribbon"},toolbarLayout:()=>{var t;return(null==(t=e().toolbar)?void 0:t.layout)??"overflow"},isReadOnly:()=>a().readOnly??!1,useComposedShell:()=>"docs"===e().uiVariant||"document"!==(e().shell??"document"),loadingOptions:n,loadingLabel:()=>{var t;return(null==(t=n())?void 0:t.label)??"Loading oasis-editor..."},shellComponent:()=>{const t=e().shell??"document";return"inline"===t?Uy:"balloon"===t?Gy:Py}}}({ui:n,documentOptions:r}),E=function(){const[t,e]=y(!1);let a,n,r,o,i;return{focused:t,setFocused:e,focusInput:()=>{e(!0),queueMicrotask(()=>{null==r||r.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})},focusInputAfterPointerSelection:()=>{e(!0),queueMicrotask(()=>{requestAnimationFrame(()=>{null==r||r.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})})},get viewportRef(){return a},set viewportRef(t){a=t},get surfaceRef(){return n},set surfaceRef(t){n=t},get textareaRef(){return r},set textareaRef(t){r=t},get importInputRef(){return o},set importInputRef(t){o=t},get imageInputRef(){return i},set imageInputRef(t){i=t}}}(),R=E.focused,L=E.setFocused,z=E.focusInput,N=E.focusInputAfterPointerSelection,[q,O]=y(!1!==n().loading),P=function(t=100){const[e,a]=y(py(t)),n=w(()=>e()/100);return{zoomPercent:e,setZoomPercent:t=>a(py(t)),adjustZoom:t=>a(e=>py(e+t)),zoomFactor:n}}(),{linkDialog:W,setLinkDialog:H,imageAltDialog:U,setImageAltDialog:F,imageCaptionDialog:B,setImageCaptionDialog:G,contextMenu:Z,setContextMenu:K,fontDialog:j,setFontDialog:X,paragraphDialog:J,setParagraphDialog:Y,tablePropertiesDialog:Q,setTablePropertiesDialog:_}=function(){const[t,e]=y({isOpen:!1,initialHref:""}),[a,n]=y({isOpen:!1,initialAlt:""}),[r,o]=y({isOpen:!1,initialCaption:""}),[i,l]=y({isOpen:!1,x:0,y:0}),[s,d]=y({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}}),[c,h]=y({isOpen:!1,initial:{align:"",indentLeft:"",indentRight:"",indentFirstLine:"",indentHanging:"",spacingBefore:"",spacingAfter:"",lineHeight:"",shading:"",borderStyle:"",borderWidth:"",borderColor:"",borderSideTop:!1,borderSideRight:!1,borderSideBottom:!1,borderSideLeft:!1}}),[p,u]=y({isOpen:!1,initial:{activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingSummary:"",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,shading:"",altTitle:"",altDescription:""}});return{linkDialog:t,setLinkDialog:e,imageAltDialog:a,setImageAltDialog:n,imageCaptionDialog:r,setImageCaptionDialog:o,contextMenu:i,setContextMenu:l,fontDialog:s,setFontDialog:d,paragraphDialog:c,setParagraphDialog:h,tablePropertiesDialog:p,setTablePropertiesDialog:u}}(),[$,tt]=y(!1),et=()=>E.viewportRef,nt=()=>E.surfaceRef,rt=TL({documentOptions:r,logger:i,runtimeClient:a,state:l,commitState:s,getStateSnapshot:d,applyState:c,cloneState:h,isReadOnly:S,focusInput:z,surfaceRef:nt,viewportRef:et,zoomFactor:P.zoomFactor,getImageOps:()=>It.imageOps}),{docIO:ot,measuredBlockHeights:it,measuredParagraphLayouts:lt,inputBox:st,selectionBoxes:dt,commentHighlights:ht,selectedImageBox:pt,selectedTextBoxBox:ut,caretBox:ft,preferredColumnX:gt,setPreferredColumnX:mt,clearPreferredColumn:vt,onCleanupHook:bt,persistenceStatus:yt,applyTransactionalState:xt,resetTransactionGrouping:wt,updateHistoryState:At}=rt,It=Vz({state:l,logger:i,isReadOnly:S,applyState:c,cloneState:h,focusInput:z,focusInputAfterPointerSelection:N,surfaceRef:nt,viewportRef:et,zoomFactor:P.zoomFactor,insertImageFromFile:ot.insertImageFromFile,getForcePlainTextPaste:()=>p,setForcePlainTextPaste:t=>{p=t},getCommandsController:()=>Qt.commandsController,applyTransactionalState:xt,clearPreferredColumn:vt,resetTransactionGrouping:wt,updateHistoryState:At,caretBox:ft,preferredColumnX:gt,setPreferredColumnX:mt,measuredBlockHeights:it,measuredParagraphLayouts:lt}),{selectedImageRun:Tt,layoutOptionsOverlay:Ct,fr:kt,resolveSurfaceHitAtPoint:Vt,resolvePositionAtSurfacePoint:Et,tableOps:Rt,imageOps:Lt,textBoxOps:zt,styleController:Nt,onEditorMouseDown:qt,tableResize:Pt,tableDrag:Wt,revisionController:Ut,textDrag:Ft,surfaceEventsWithTextDrag:Bt,textInput:Gt,navigation:Zt,handleCopy:Kt,handleCut:jt,handlePaste:Xt,handleDrop:Yt}=It,Qt=nN({document:rt,interaction:It,state:l,logger:i,isReadOnly:S,focusInput:z,applyState:c,getStateSnapshot:d,cloneState:h,setFocused:L,setInitialLoading:O,getForcePlainTextPaste:()=>p,setForcePlainTextPaste:t=>{p=t},locale:()=>n().locale??"pt-BR",translator:o,runtimeClient:a,runtimeOptions:()=>t.runtime??{},documentOptions:r,importInputRef:()=>E.importInputRef,imageInputRef:()=>E.imageInputRef,setLinkDialog:H,setImageAltDialog:F,setImageCaptionDialog:G}),{commandsController:_t,runtimeReady:$t,runtimeEditor:te,commandStateOf:ee,toolbarHost:ae,toolbarRegistry:ne,menuRegistry:re,handleKeyDown:oe}=Qt,{computeFontFamilyOptions:ie,computeFontSizeOptions:le,applyFontDialogValues:se,applyParagraphDialogValues:de,applyTablePropertiesDialogValues:ce,buildContextMenuItems:he,handleEditorContextMenu:pe,closeContextMenu:ue}=ek({state:()=>l,selection:()=>l.selection,toolbarStyleState:Nt.toolbarStyleState,isReadOnly:S,t:o,logger:i,setFontDialog:X,setParagraphDialog:Y,setTablePropertiesDialog:_,setContextMenu:K,clearPreferredColumn:vt,resetTransactionGrouping:wt,applyTransactionalState:xt,applyTableAwareParagraphEdit:Rt.applyTableAwareParagraphEdit,focusInput:z,promptForLink:_t.promptForLink,tableOps:Rt}),{layout:fe,overlays:ge,refs:me,surfaceHandlers:ve,inputHandlers:be,fileHandlers:ye}=function(t){const e={onImportInputChange:e=>{var a;return t.handleImportFile((null==(a=e.currentTarget.files)?void 0:a[0])??null)},onImageInputChange:e=>{var a;return t.handleInsertImage((null==(a=e.currentTarget.files)?void 0:a[0])??null)}};return{layout:{viewportHeight:t.viewportHeight,class:t.className,style:t.style,zoomPercent:t.zoomPercent,setZoomPercent:t.setZoomPercent,zoomFactor:t.zoomFactor},overlays:{selectionBoxes:t.selectionBoxes,commentHighlights:t.commentHighlights,selectedImageBox:t.selectedImageBox,selectedTextBoxBox:t.selectedTextBoxBox,layoutOptions:t.layoutOptions,caretBox:t.caretBox,inputBox:t.inputBox,hoveredRevision:t.hoveredRevision,focused:t.focused,showCaret:t.showCaret,importProgress:t.importProgress},refs:{onViewportRef:e=>{t.focusController.viewportRef=e},onSurfaceRef:e=>{t.focusController.surfaceRef=e},onTextareaRef:e=>{t.focusController.textareaRef=e},onImportInputRef:e=>{t.focusController.importInputRef=e},onImageInputRef:e=>{t.focusController.imageInputRef=e}},surfaceHandlers:{onDragOver:t=>t.preventDefault(),onDrop:t.handleDrop,onEditorMouseDown:t.onEditorMouseDown,onSurfaceMouseDown:t.surfaceEvents.handleSurfaceMouseDown,onSurfaceClick:t.surfaceEvents.handleSurfaceClick,onSurfaceMouseMove:t.tableResize.handleMouseMove,onSurfaceDblClick:t.surfaceEvents.handleSurfaceDblClick,onParagraphMouseDown:t.surfaceEvents.handleParagraphMouseDown,onImageMouseDown:t.handleImageMouseDown,onImageResizeHandleMouseDown:t.handleImageResizeHandleMouseDown,onTextBoxResizeHandleMouseDown:t.handleTextBoxResizeHandleMouseDown,onImageRotateHandleMouseDown:t.handleImageRotateHandleMouseDown,onTextBoxRotateHandleMouseDown:t.handleTextBoxRotateHandleMouseDown,onTableDragHandleMouseDown:t.tableDrag.handleMouseDown,onRevisionMouseEnter:t.revisionController.handleRevisionMouseEnter,onRevisionMouseLeave:t.revisionController.handleRevisionMouseLeave,onEditorContextMenu:e=>t.handleEditorContextMenu(e)},inputHandlers:{onInputBlur:()=>t.setFocused(!1),onInputFocus:()=>t.setFocused(!0),onCompositionEnd:t.textInput.handleCompositionEnd,onCompositionStart:t.textInput.handleCompositionStart,onCopy:t.handleCopy,onCut:t.handleCut,onInput:t.textInput.handleTextInput,onKeyDown:t.handleKeyDown,onPaste:t.handlePaste},fileHandlers:e}}({viewportHeight:n().viewportHeight,className:n().class,style:n().style,zoomPercent:P.zoomPercent,setZoomPercent:P.setZoomPercent,zoomFactor:P.zoomFactor,selectionBoxes:dt,commentHighlights:ht,selectedImageBox:pt,selectedTextBoxBox:ut,layoutOptions:Ct,caretBox:ft,inputBox:st,hoveredRevision:Ut.hoveredRevision,focused:R,showCaret:()=>function(t,e){if(!e.visible||!ma(t.selection))return!1;const a=sa(t),n=_e(t.document,t.selection.anchor.paragraphId,a),r=_e(t.document,t.selection.focus.paragraphId,a);return!(n&&r&&n.blockIndex===r.blockIndex&&(n.rowIndex!==r.rowIndex||n.cellIndex!==r.cellIndex))}(l,ft()),importProgress:ot.importProgress,focusController:E,handleImportFile:ot.handleImportFile,handleInsertImage:ot.handleInsertImage,surfaceEvents:Bt,tableResize:Pt,tableDrag:Wt,revisionController:Ut,handleDrop:Yt,onEditorMouseDown:qt,handleImageMouseDown:Lt.handleImageMouseDown,handleImageResizeHandleMouseDown:Lt.handleImageResizeHandleMouseDown,handleTextBoxResizeHandleMouseDown:zt.handleTextBoxResizeHandleMouseDown,handleImageRotateHandleMouseDown:Lt.handleImageRotateHandleMouseDown,handleTextBoxRotateHandleMouseDown:zt.handleTextBoxRotateHandleMouseDown,handleEditorContextMenu:pe,textInput:Gt,setFocused:L,handleCopy:Kt,handleCut:jt,handlePaste:Xt,handleKeyDown:oe});return I(()=>{!function(t=document.body){lT||(iT({icons:oT,nameAttr:"data-lucide",root:t}),lT=new MutationObserver(e=>{let a=!1;for(const t of e)if(t.addedNodes.length>0||"attributes"===t.type){a=!0;break}a&&lT&&(lT.disconnect(),iT({icons:oT,nameAttr:"data-lucide",root:t}),lT.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-lucide"]}))}),lT.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-lucide"]}))}(),function(){if(!Ci&&window.PerformanceObserver)try{Ci=new PerformanceObserver(t=>{for(const e of t.getEntries())Ti.push({duration:Math.round(100*e.duration)/100,startTime:Math.round(e.startTime)})}),Ci.observe({type:"longtask",buffered:!0})}catch{}}(),window.__OASIS_PERF_REPORT=()=>{const t=Ii.filter(t=>t.name.startsWith("layout:")).map(t=>t.duration),e=Ii.filter(t=>"input-to-layout"===t.name).map(t=>t.duration),a=Ii.filter(t=>"input:text"===t.name).map(t=>t.duration),n=Ni(t),r=Ni(e),o=Ni(a),i=Ni(Ti.map(t=>t.duration));console.group("%c[perf] Summary","color: #f59e0b; font-weight: bold;"),console.info(`input:text → p50=${o.p50}ms p95=${o.p95}ms p99=${o.p99}ms max=${o.max}ms (n=${o.count})`),console.info(`input-to-layout → p50=${r.p50}ms p95=${r.p95}ms p99=${r.p99}ms max=${r.max}ms (n=${r.count})`),console.info(`layout:sync → p50=${n.p50}ms p95=${n.p95}ms p99=${n.p99}ms max=${n.max}ms (n=${n.count})`),console.info(`longtasks → p50=${i.p50}ms p95=${i.p95}ms p99=${i.p99}ms max=${i.max}ms (n=${i.count})`),console.groupEnd()},window.__OASIS_DOM_STATS=()=>{const t=(e=(null==Li?void 0:Li())??null)?{totalNodes:e.querySelectorAll("*").length,pages:e.querySelectorAll('[data-renderer="canvas"][data-page-index]').length,blocks:0,paragraphs:0,lines:0,charSpans:0,segmentSpans:0,runSpans:0}:{totalNodes:0,pages:0,blocks:0,paragraphs:0,lines:0,charSpans:0,segmentSpans:0,runSpans:0};var e;return console.info("%c[perf] DOM stats","color: #f59e0b; font-weight: bold;",t),t},Li=()=>nt()??null,Sc(),"1"!==dc(lc)&&vc()&&tt(!0)}),T(()=>{bt(),Bt.stopDragging(),Ft.stopDrag(),Lt.stopImageDrag(),Lt.stopImageResize(),zt.stopTextBoxResize(),null==lT||lT.disconnect(),lT=null}),D(Ht,{translator:o,get children(){var t=rN();return Mt(t,"--oasis-editor-gutter-x","34px"),St(t,D(at,{get when(){return ct(()=>!(A()||!u()))()&&m()},get children(){return D(ic,{host:ae,registry:ne,get view(){return b()},get layout(){return x()}})}}),null),St(t,D(kV,{dialogs:{linkDialog:W,setLinkDialog:H,imageAltDialog:U,setImageAltDialog:F,imageCaptionDialog:B,setImageCaptionDialog:G,contextMenu:Z,setContextMenu:K,fontDialog:j,setFontDialog:X,paragraphDialog:J,setParagraphDialog:Y,tablePropertiesDialog:Q,setTablePropertiesDialog:_},findReplace:kt,fontFamilyOptions:ie,fontSizeOptions:le,contextMenuItems:he,focusInput:z,get applyLinkCommand(){return _t.applyLinkCommand},get applyImageAltCommand(){return _t.applyImageAltCommand},get applyImageCaptionCommand(){return _t.applyImageCaptionCommand},applyFontDialogValues:se,applyParagraphDialogValues:de,applyTablePropertiesDialogValues:ce,closeContextMenu:ue}),null),St(t,D(EV,{useComposedShell:A,shellComponent:V,runtime:{state:()=>l,toolbarHost:ae,runtimeEditor:te,persistenceStatus:yt,toolbarRegistry:ne,menuRegistry:re,showFloatingTableToolbar:()=>!S()&&null!==ee("tableContext").value},chrome:{showChrome:u,showTitleBar:f,showMenubar:g,showToolbar:m,showOutline:v,toolbarView:b,toolbarLayout:x},view:{isReadOnly:S,viewportHeight:()=>n().viewportHeight,measuredBlockHeights:it,measuredParagraphLayouts:lt,layout:fe,overlays:ge,refs:me,surfaceHandlers:ve,inputHandlers:be,fileHandlers:ye}}),null),St(t,D(ik,{state:l,get surfaceRef(){return nt()},tableResize:Pt,imageOps:Lt,tableDrag:Wt,textDrag:Ft}),null),St(t,D(at,{get when(){return q()||!$t()},get children(){return D(Dt,{get label(){return k()},get class(){var t;return null==(t=C())?void 0:t.class},get style(){var t;return null==(t=C())?void 0:t.style}})}}),null),St(t,D(LV,{get isOpen(){return ct(()=>!(!$()||q()))()&&$t()},onClose:()=>tt(!1)}),null),M(e=>{var a=!!A(),n=!!S();return a!==e.e&&t.classList.toggle("oasis-editor-docs",e.e=a),n!==e.t&&t.classList.toggle("oasis-editor-read-only",e.t=n),e},{e:void 0,t:void 0}),t}})}},Symbol.toStringTag,{value:"Module"}));t.BalloonShell=Gy,t.Button=function(t){const[e,a]=Q(t,["type","variant","size","icon","iconPosition","fullWidth","class","classList","children"]),n=()=>e.iconPosition??"start";return r=_y(),o=r.firstChild,xt(r,Y({get type(){return e.type??"button"},get class(){return`oasis-editor-ui-button ${e.class??""}`},get classList(){return{[`oasis-editor-ui-button-${e.variant??"secondary"}`]:!0,[`oasis-editor-ui-button-${e.size??"md"}`]:!0,"oasis-editor-ui-button-full":e.fullWidth,...e.classList}}},a),!1,!0),St(r,D(at,{get when(){return ct(()=>!!e.icon)()&&"start"===n()},get children(){return D(Da,{get name(){return e.icon}})}}),o),St(o,()=>e.children),St(r,D(at,{get when(){return ct(()=>!!e.icon)()&&"end"===n()},get children(){return D(Da,{get name(){return e.icon}})}}),null),r;var r,o},t.Checkbox=function(t){const e=$(),[a,n]=Q(t,["label","description","error","onChange","class","id"]),r=()=>a.id??e,o=()=>`${r()}-description`,i=()=>`${r()}-error`;return l=oM(),s=l.firstChild,d=s.nextSibling,c=d.firstChild,s.addEventListener("change",t=>{var e;return null==(e=a.onChange)?void 0:e.call(a,t.currentTarget.checked)}),xt(s,Y({get id(){return r()},get"aria-invalid"(){return a.error?"true":void 0},get"aria-describedby"(){return[a.description?o():null,a.error?i():null].filter(Boolean).join(" ")}},n),!1,!1),St(c,()=>a.label),St(d,D(at,{get when(){return a.description},get children(){var t=nM();return St(t,()=>a.description),M(()=>gt(t,"id",o())),t}}),null),St(d,D(at,{get when(){return a.error},get children(){var t=rM();return St(t,()=>a.error),M(()=>gt(t,"id",i())),t}}),null),M(t=>{var e=`oasis-editor-ui-checkbox ${a.class??""}`,n=r();return e!==t.e&&mt(l,t.e=e),n!==t.t&>(l,"for",t.t=n),t},{e:void 0,t:void 0}),l;var l,s,d,c},t.ColorPicker=Cd,t.CommandRegistry=qa,t.DEFAULT_PALETTE=Nd,t.Dialog=Ky,t.DialogFooter=function(t){const[e,a]=Q(t,["align","class","classList","children"]);return xt(n=hM(),Y({get class(){return`oasis-editor-ui-dialog-footer ${e.class??""}`},get classList(){return{[`oasis-editor-ui-dialog-footer-${e.align??"end"}`]:!0,...e.classList}}},a),!1,!0),St(n,()=>e.children),n;var n},t.DocumentShell=Py,t.Editor=Ua,t.FloatingActionButton=My,t.GridPicker=zd,t.IconButton=Cy,t.InlineShell=Uy,t.Menu=dd,t.MenuRegistry=gM,t.OASIS_BUILTIN_COMMANDS=["selectAll","insertFootnote","insertTableOfContents","updateTableOfContents","pastePlainText","bold","italic","underline","strike","superscript","subscript","link","unlink","alignLeft","alignCenter","alignRight","alignJustify","orderedList","bulletList","find","replace","toggleTrackChanges","acceptRevisions","rejectRevisions","toggleShowMargins","toggleShowParagraphMarks","togglePreciseFonts","undo","redo","pageBreak","lineBreak","splitBlock","setFontFamily","setFontSize","increaseFontSize","decreaseFontSize","changeTextCase","clearFormatting","setColor","setHighlight","setTextShading","setStyleId","setUnderlineStyle","documentStyles","print","copy","exportDocx","exportPdf","importDocument","insertImage","editImageAlt","insertImageCaption","outdent","indent","togglePageBreakBefore","toggleKeepWithNext","setSpacingAfter","setSpacingBefore","setIndentLeft","setIndentRight","setIndentFirstLine","setIndentHanging","setSpecialIndent","setParagraphShading","applyParagraphBorders","setLineHeight","setListFormat","setListStartAt","toggleOrientation","setOrientation","sectionBreakNextPage","sectionBreakContinuous","setPageMargins","tableContext","tableMerge","tableSplit","tableInsertColumnBefore","tableInsertColumnAfter","tableDeleteColumn","tableInsertRowBefore","tableInsertRowAfter","tableDeleteRow","tableCellShading","tableCellBorders","tableCellNoBorders","tableWidth100","tableAlignLeft","tableAlignCenter","tableAlignRight","tableSetCellWidth","insertTable"],t.OASIS_MENU_ITEMS={fileNew:"file_new",fileImport:"file_import",fileSave:"file_save",fileExport:"file_export",fileExportPdf:"file_export_pdf",fileExportDocx:"file_export_docx",filePrint:"file_print",editUndo:"edit_undo",editRedo:"edit_redo",editCopy:"edit_copy",editFind:"edit_find",editSelectAll:"edit_selectAll",viewMargins:"view_margins",viewParagraphMarks:"view_paragraph_marks",viewPreciseFonts:"view_precise_fonts",insertImage:"insert_image",insertImageCaption:"insert_image_caption",insertTable:"insert_table",insertLink:"insert_link",insertFootnote:"insert_footnote",insertPageBreak:"insert_pageBreak",formatText:"format_text",formatTextBold:"format_text_bold",formatTextItalic:"format_text_italic",formatTextUnderline:"format_text_underline",formatTextStrike:"format_text_strike",formatAlign:"format_align",formatAlignLeft:"format_align_left",formatAlignCenter:"format_align_center",formatAlignRight:"format_align_right",formatAlignJustify:"format_align_justify",formatLists:"format_lists",formatListsBullet:"format_lists_bullet",formatListsNumbered:"format_lists_numbered"},t.OASIS_TOOLBAR_ITEMS={fileDropdown:"editor-toolbar-file-dropdown",exportDocx:"editor-toolbar-export-docx",exportPdf:"editor-toolbar-export-pdf",importDocument:"editor-toolbar-import-document",undo:"editor-toolbar-undo",redo:"editor-toolbar-redo",style:"editor-toolbar-style",fontFamily:"editor-toolbar-font-family",fontSize:"editor-toolbar-font-size",color:"editor-toolbar-color",highlight:"editor-toolbar-highlight",textShading:"editor-toolbar-text-shading",bold:"editor-toolbar-bold",italic:"editor-toolbar-italic",underlineControl:"editor-toolbar-underline-control",strike:"editor-toolbar-strike",superscript:"editor-toolbar-superscript",subscript:"editor-toolbar-subscript",insertImage:"editor-toolbar-insert-image",insertTable:"editor-toolbar-insert-table",link:"editor-toolbar-link",unlink:"editor-toolbar-unlink",footnote:"editor-toolbar-footnote",imageAlt:"editor-toolbar-image-alt",imageCaption:"editor-toolbar-image-caption",alignLeft:"editor-toolbar-align-left",alignCenter:"editor-toolbar-align-center",alignRight:"editor-toolbar-align-right",alignJustify:"editor-toolbar-align-justify",bulletList:"editor-toolbar-list-bullet",orderedList:"editor-toolbar-list-ordered",outdent:"editor-toolbar-list-outdent",indent:"editor-toolbar-list-indent",listOptions:"editor-toolbar-list-options",specialIndent:"editor-toolbar-special-indent",lineSpacing:"editor-toolbar-line-spacing-control",metrics:"editor-toolbar-metrics",table:"editor-toolbar-table",margins:"editor-toolbar-margins",section:"editor-toolbar-section"},t.OasisEditorAppLazy=Kt,t.OasisEditorContainer=Yt,t.OasisEditorLoading=Dt,t.PluginCollection=Na,t.Popover=ad,t.RIBBON_TABS=Bd,t.Select=hd,t.SelectField=function(t){const e=$(),[a,n]=Q(t,["label","description","error","options","onChange","class","id"]),r=()=>a.id??e,o=()=>`${r()}-description`,i=()=>`${r()}-error`;return l=dM(),s=l.firstChild,St(l,D(at,{get when(){return a.label},get children(){var t=iM();return St(t,()=>a.label),t}}),s),s.addEventListener("change",t=>{var e;return null==(e=a.onChange)?void 0:e.call(a,t.currentTarget.value)}),xt(s,Y({get id(){return r()},get"aria-invalid"(){return a.error?"true":void 0},get"aria-describedby"(){return[a.description?o():null,a.error?i():null].filter(Boolean).join(" ")}},n),!1,!0),St(s,D(tt,{get each(){return a.options},children:t=>{return St(e=cM(),()=>t.label),M(()=>e.disabled=t.disabled),M(()=>e.value=t.value),e;var e}})),St(l,D(at,{get when(){return a.description},get children(){var t=lM();return St(t,()=>a.description),M(()=>gt(t,"id",o())),t}}),null),St(l,D(at,{get when(){return a.error},get children(){var t=sM();return St(t,()=>a.error),M(()=>gt(t,"id",i())),t}}),null),M(t=>{var e=`oasis-editor-ui-field ${a.class??""}`,n=r();return e!==t.e&&mt(l,t.e=e),n!==t.t&>(l,"for",t.t=n),t},{e:void 0,t:void 0}),l;var l,s},t.Separator=ud,t.SidePanel=Sy,t.SidePanelBody=Iy,t.SidePanelFooter=function(t){const[e,a]=Q(t,["class","children"]);return xt(n=wy(),Y({get class(){return`oasis-editor-plugin-side-panel-footer ${e.class??""}`}},a),!1,!0),St(n,()=>e.children),n;var n},t.SidePanelHeader=Ay,t.SplitButton=gd,t.Tabs=Qy,t.TextField=function(t){const e=$(),[a,n]=Q(t,["label","description","error","onChange","class","id"]),r=()=>a.id??e,o=()=>`${r()}-description`,i=()=>`${r()}-error`;return l=aM(),s=l.firstChild,St(l,D(at,{get when(){return a.label},get children(){var t=$y();return St(t,()=>a.label),t}}),s),s.$$input=t=>{var e;return null==(e=a.onChange)?void 0:e.call(a,t.currentTarget.value)},xt(s,Y({get id(){return r()},get"aria-invalid"(){return a.error?"true":void 0},get"aria-describedby"(){return[a.description?o():null,a.error?i():null].filter(Boolean).join(" ")}},n),!1,!1),St(l,D(at,{get when(){return a.description},get children(){var t=tM();return St(t,()=>a.description),M(()=>gt(t,"id",o())),t}}),null),St(l,D(at,{get when(){return a.error},get children(){var t=eM();return St(t,()=>a.error),M(()=>gt(t,"id",i())),t}}),null),M(t=>{var e=`oasis-editor-ui-field ${a.class??""}`,n=r();return e!==t.e&&mt(l,t.e=e),n!==t.t&>(l,"for",t.t=n),t},{e:void 0,t:void 0}),l;var l,s},t.Toolbar=ic,t.ToolbarButton=$s,t.ToolbarColorPicker=Cd,t.ToolbarGridPicker=zd,t.ToolbarMenu=dd,t.ToolbarSelect=hd,t.ToolbarSeparator=ud,t.ToolbarSplitButton=gd,t.buildRibbonTabDefinitions=Dd,t.commandRefName=jt,t.createDefaultToolbarPreset=Ex,t.createEditorCommandBus=function(t){return{execute(e,a){const n=Xt(e,a);return t.commands.execute(n.name,n.payload)},canExecute(e,a){const n=Xt(e,a);return t.commands.canExecute(n.name,n.payload)},state(e){const a=Xt(e);return t.commands.state(a.name,a.payload)}}},t.createOasisEditor=function(t,e={}){const a=Jt(),n=pt(()=>Kt({...e,runtime:{...e.runtime,client:a}}),t);return a.setDispose(()=>{n(),t.innerHTML=""}),a},t.createOasisEditorContainer=function(t,e={}){const a=Jt(),n=pt(()=>Yt({...e,runtime:{...e.runtime,client:a}}),t);return a.setDispose(()=>{n(),t.innerHTML=""}),a},t.createToolbarRegistry=fM,t.mount=function(t,e={}){const a=Jt(),n=pt(()=>D(Kt,Y(e,{get runtime(){return{...e.runtime,client:a}}})),t);return a.setDispose(()=>{n(),t.innerHTML=""}),Object.assign(a,{unmount:()=>a.dispose()})},t.registerToolbarRenderer=function(t,e){Ud.set(t,e)},t.resolveCommandRef=Xt,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
24
|
+
*/let lT=null;const sT={DEV:!1,MODE:"lib"};let dT=!1,cT=null,hT=null,pT=null,uT=[];function fT(){"undefined"!=typeof window&&(!function(){var t;const e=sT??{},a=(null==(t=globalThis.process)?void 0:t.env)??{};return!0===e.DEV||"test"===e.MODE||"test"===a.NODE_ENV||"1"===e.VITE_OASIS_CANVAS_DEBUG}()?dT&&(delete window.__oasisCanvasDebug,dT=!1):dT||(window.__oasisCanvasDebug={getLastHit:()=>cT?{...cT}:null,getLayoutSnapshot:()=>hT?{...hT,surfaceRect:{...hT.surfaceRect},pages:hT.pages.map(t=>({...t})),paragraphs:hT.paragraphs.map(t=>({...t,lines:t.lines.map(t=>({...t,slots:t.slots.map(t=>({...t}))})),tableCell:t.tableCell?{...t.tableCell}:void 0})),inlineImages:hT.inlineImages.map(t=>({...t})),inlineTextBoxes:hT.inlineTextBoxes.map(t=>({...t})),unsupportedRegions:hT.unsupportedRegions.map(t=>({...t}))}:null,getSelection:()=>pT?{anchor:{...pT.anchor},focus:{...pT.focus},activeZone:pT.activeZone,activeSectionIndex:pT.activeSectionIndex}:null,getMissEvents:()=>uT.map(t=>({...t})),clearMissEvents:()=>{uT=[]}},dT=!0))}function gT(t){dT&&t&&(cT={timestamp:Date.now(),zone:t.zone,paragraphId:t.paragraphId,paragraphOffset:t.paragraphOffset,source:t.source,missReason:t.missReason,resolvedFromParagraph:t.resolvedFromParagraph})}const mT=["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 vT(t,e,a){const n=null==a?void 0:a.trim();if(!n)return;const r=n.toLowerCase();e.has(r)||(e.add(r),t.push(n))}function bT(t){const[e,a]=y([]);return{computeFontFamilyOptions:()=>function(t,e,a=[]){var n;const r=new Set,o=[],i=[];for(const l of Object.values((null==t?void 0:t.styles)??{}))vT(o,r,null==(n=l.textStyle)?void 0:n.fontFamily);vT(o,r,e.fontFamily);for(const l of a)vT(i,r,l);for(const l of mT)vT(i,r,l);return[...o.sort((t,e)=>t.localeCompare(e)),...i.sort((t,e)=>t.localeCompare(e))]}(t.state().document,t.toolbarStyleState(),e()),computeFontSizeOptions:()=>function(t,e){var a;const n=new Set(MM);for(const o of Object.values((null==t?void 0:t.styles)??{})){const t=null==(a=o.textStyle)?void 0:a.fontSize;"number"==typeof t&&Number.isFinite(t)&&n.add(xM(t))}const r=xM(Number(e.fontSize));return Number.isFinite(r)&&r>0&&n.add(r),Array.from(n).sort((t,e)=>t-e)}(t.state().document,t.toolbarStyleState()),loadLocalFontFamilyOptions:async()=>{if(e().length>0)return;const t=await bc();t.length>0&&a(t)}}}function yT(t){return t?{...t}:void 0}function MT(t,e){return JSON.stringify(t??null)===JSON.stringify(e??null)}function xT(t,e,a){const n={...t??{}};return a?n[e]=!0:delete n[e],Object.keys(n).length>0?n:void 0}function wT(t,e,a){const n={...t??{}};return null==a||""===a?delete n[e]:n[e]=a,Object.keys(n).length>0?n:void 0}function ST(t,e,a){const n={...t??{}};return null==a?delete n[e]:n[e]=a,Object.keys(n).length>0?n:void 0}function AT(t){return{...t,floating:t.floating?{...t.floating,positionH:t.floating.positionH?{...t.floating.positionH}:void 0,positionV:t.floating.positionV?{...t.floating.positionV}:void 0}:void 0,shape:t.shape?{...t.shape}:void 0,body:t.body?{...t.body}:void 0,blocks:VT(t.blocks)}}function IT(t){return{...t,styles:yT(t.styles),image:t.image?{...t.image}:void 0,textBox:t.textBox?AT(t.textBox):void 0,field:t.field?{...t.field}:void 0,fieldChar:t.fieldChar?{...t.fieldChar}:void 0,revision:t.revision?{...t.revision}:void 0,footnoteReference:t.footnoteReference?{...t.footnoteReference}:void 0,endnoteReference:t.endnoteReference?{...t.endnoteReference}:void 0}}function TT(t){return{...t,runs:t.runs.map(IT),style:t.style?{...t.style}:void 0,list:t.list?{...t.list}:void 0}}function CT(t){return t?{...t}:void 0}function kT(t){return t.map(TT)}function VT(t){return t.map(t=>{switch(t.type){case"paragraph":return TT(t);case"table":return{...t,style:t.style?{...t.style,defaultCellMargins:t.style.defaultCellMargins?{...t.style.defaultCellMargins}:void 0,floating:t.style.floating?{...t.style.floating}:void 0,revisionXml:t.style.revisionXml?[...t.style.revisionXml]:void 0}:void 0,tblGridChangeXml:t.tblGridChangeXml,rows:t.rows.map(t=>({...t,style:t.style?{...t.style,revisionXml:t.style.revisionXml?[...t.style.revisionXml]:void 0}:void 0,cells:t.cells.map(t=>({...t,style:t.style?{...t.style,revisionXml:t.style.revisionXml?[...t.style.revisionXml]:void 0}:void 0,blocks:kT(t.blocks)}))}))};default:return pe(t,"block")}})}function ET(t,e){const a=[];for(const n of t){if(0===n.text.length)continue;const t=a[a.length-1];!t||ue(n)||ue(t)||!MT(t.styles,n.styles)?a.push({...n,styles:yT(n.styles)}):t.text+=n.text}return a.length>0?a:[wa("",e)]}function RT(t,e,a){return{...t,runs:ET(e,a),style:t.style?{...t.style}:void 0}}function LT(t){return Aa(t)}function zT(t,e){const a=LT(e);return a.style=t.style?{...t.style}:void 0,a.list=CT(t.list),a}function NT(t,e){const a=TT(t);return a.list?(a.list={...a.list,level:Math.max(0,e)},a):a}function qT(t){const e=TT(t);return delete e.list,e}function OT(t,e){var a;if(0===t.runs.length)return;let n=0;for(let r=0;r<t.runs.length;r+=1){const a=t.runs[r],o=n+a.text.length;if(e<o)return yT(a.styles);if(e===o){if(a.text.length>0)return yT(a.styles);const e=t.runs[r+1];return yT((null==e?void 0:e.styles)??a.styles)}n=o}return yT(null==(a=t.runs[t.runs.length-1])?void 0:a.styles)}function PT(t,e){var a,n,r;const o=function(t,e){let a=0;for(let n=0;n<t.runs.length;n+=1){const r=t.runs[n],o=a,i=a+r.text.length;if(e<i)return{run:r,startOffset:o,endOffset:i};if(e===i){if(r.text.length>0)return{run:r,startOffset:o,endOffset:i};const e=t.runs[n+1];return e?{run:e,startOffset:i,endOffset:i+e.text.length}:{run:r,startOffset:o,endOffset:i}}a=i}return null}(t,e),i=null==(a=null==o?void 0:o.run.styles)?void 0:a.link;if(!o||!i||o.run.image)return null;let l=o.startOffset,s=o.endOffset,d=0;const c=t.runs,h=c.findIndex(t=>t.id===o.run.id);if(-1===h)return null;for(let p=0;p<h;p+=1)d+=c[p].text.length;l=d,s=d+o.run.text.length;for(let p=h-1;p>=0;p-=1){const t=c[p];if(t.image||(null==(n=t.styles)?void 0:n.link)!==i)break;l-=t.text.length}for(let p=h+1;p<c.length;p+=1){const t=c[p];if(t.image||(null==(r=t.styles)?void 0:r.link)!==i)break;s+=t.text.length}return{href:i,startOffset:l,endOffset:s}}function WT(t,e,a){const n=Math.max(0,Math.min(e,ke(t))),r=Math.max(n,Math.min(a,ke(t))),o=[];let i=0;for(const l of t.runs){const t=i,e=i+l.text.length,a=Math.max(n,t),s=Math.min(r,e);if(a<s){const e=ue(l),n={id:`run:${Math.random().toString(36).slice(2,9)}`,text:e?"":l.text.slice(a-t,s-t)};l.styles&&(n.styles={...l.styles}),l.image&&(n.image={...l.image}),l.textBox&&(n.textBox=AT(l.textBox)),l.revision&&(n.revision={...l.revision}),l.field&&(n.field={...l.field}),l.footnoteReference&&(n.footnoteReference={...l.footnoteReference}),l.endnoteReference&&(n.endnoteReference={...l.endnoteReference}),o.push(n)}i=e}return o}function HT(t,e,a){const n=WT(t,0,e),r=WT(t,e,ke(t)),o=OT(t,e);return RT(t,[...n,...a.map(t=>({...t,styles:yT(t.styles??o)})),...r],o)}function UT(t){const e=[],a=new Map,n=[];let r=0;for(const o of t){const t=Ce(o);e.push({id:o.id,base:r,length:t.length}),a.has(o.id)||a.set(o.id,r),n.push(t),r+=t.length+1}return{text:n.join("\n"),spans:e,baseById:a}}function FT(t,e,a){return t<e?e:t>a?a:t}function BT(t,e,a){const n=UT(e);let r=!1;for(const f of t.order){const e=t.items[f];if(e&&(e.start&&n.baseById.has(e.start.paragraphId)||e.end&&n.baseById.has(e.end.paragraphId))){r=!0;break}}if(!r)return t;const o=UT(a);if(n.text===o.text)return t;const i=n.text.length,l=o.text.length,s=Math.min(i,l),d=function(t,e,a){let n=0;for(;n<a&&t.charCodeAt(t.length-1-n)===e.charCodeAt(e.length-1-n);)n+=1;return n}(n.text,o.text,s),c=function(t,e,a){let n=0;for(;n<a&&t.charCodeAt(n)===e.charCodeAt(n);)n+=1;return n}(n.text,o.text,s-d),h=t=>{const e=n.baseById.get(t.paragraphId);if(void 0===e)return t;const a=e+FT(t.offset,0,i-e),r=FT(function(t,e,a,n,r){return t<=n?t:t>=e-r?t+(a-e):n}(a,i,l,c,d),0,l),s=function(t,e){for(const n of e)if(t<=n.base+n.length)return{paragraphId:n.id,offset:Math.max(0,t-n.base)};const a=e[e.length-1];return{paragraphId:a.id,offset:a.length}}(r,o.spans);return s.paragraphId===t.paragraphId&&s.offset===t.offset?t:{...t,paragraphId:s.paragraphId,offset:s.offset}};let p=!1;const u={...t.items};for(const f of t.order){const e=t.items[f];if(!e)continue;let a=e;if(e.start&&n.baseById.has(e.start.paragraphId)){const t=h(e.start);t!==e.start&&(a={...a,start:t})}if(e.end&&n.baseById.has(e.end.paragraphId)){const t=h(e.end);t!==e.end&&(a={...a,end:t})}a!==e&&(u[f]=a,p=!0)}return p?{...t,items:u}:t}function GT(t,e){if(!function(t){for(const e of t)if("table"===e.type)return!0;return!1}(t))return e;let a=0;const n=t=>{let r=!1;const o=t.map(t=>{if("paragraph"===t.type){const n=e[a++]??t;return n!==t&&(r=!0),n}let o=!1;const i=t.rows.map(t=>{let e=!1;const a=t.cells.map(t=>{const a=n(t.blocks);return a===t.blocks?t:(e=!0,{...t,blocks:a})});return e?(o=!0,{...t,cells:a}):t});return o?(r=!0,{...t,rows:i}):t});return r?o:t};return n(t)}function ZT(t,e,a){const n=da(t);if("footnote"===n){const n=t.activeFootnoteId,r=t.document.footnotes;if(!n||!r||!r.items[n])return{...t,selection:a};const o=r.items[n],i=GT(o.blocks,e);return{...t,document:{...t.document,footnotes:{...r,items:{...r.items,[n]:{...o,blocks:i}}}},selection:a}}const r=Be(t.document),o=Math.max(0,Math.min(sa(t),r.length-1)),i=r[o];if(!i)return{...t,selection:a};const l=function(t,e,a){return"header"===a?{...t,header:GT(t.header??[],e)}:"footer"===a?{...t,footer:GT(t.footer??[],e)}:{...t,blocks:GT(t.blocks,e)}}(i,e,n),s=[...r];s[o]=l;const d=t.document.bookmarks,c=d&&d.order.length>0?BT(d,ha(t),e):d;return{...t,document:{...t.document,sections:s,...c!==d?{bookmarks:c}:{}},selection:a}}function DT(t,e,a){let n=!1;const r=t.map(t=>{if("paragraph"===t.type)return t;let r=!1;const o=t.rows.map(t=>{let n=!1;const o=t.cells.map(t=>{if(!t.blocks.some(t=>e.has(t.id)))return t;const r=a(t);return r!==t&&(n=!0),r});return n?(r=!0,{...t,cells:o}):t});return r?(n=!0,{...t,rows:o}):t});return n?r:t}function KT(t){return ga(t)}function jT(t){const e=ha(t),a=ua(t,t.selection.focus),n=pa(e,a.paragraphId),r=e[n];return{paragraph:r,index:n,offset:Ee(r,a)}}function XT(t){const e=va(t);if(e.isCollapsed)return t;const a=ha(t);if(t.trackChangesEnabled){const n=`rev:${Math.random().toString(36).slice(2,9)}`,r="User",o=Date.now();return ZT(t,a.map((t,a)=>{if(a<e.startIndex||a>e.endIndex)return TT(t);return JT(t,a===e.startIndex?e.startParagraphOffset:0,a===e.endIndex?e.endParagraphOffset:ke(t),t=>{var e;return"insert"===(null==(e=t.revision)?void 0:e.type)?{...t,text:""}:{...t,revision:{id:n,type:"delete",author:r,date:o}}})}),KT(e.start))}const n=a[e.startIndex],r=a[e.endIndex],o=Ee(n,e.start),i=Ee(r,e.end),l=RT(n,[...WT(n,0,o),...WT(r,i,ke(r))]);return ZT(t,[...kT(a.slice(0,e.startIndex)),l,...kT(a.slice(e.endIndex+1))],KT(Ve(l,o)))}function JT(t,e,a,n){return RT(t,[...WT(t,0,e),...WT(t,e,a).map(n),...WT(t,a,ke(t))])}function YT(t,e){const a=t[e.startIndex],n=t[e.endIndex];return{anchor:Ve(a,e.startParagraphOffset),focus:Ve(n,e.endParagraphOffset)}}function QT(t,e){const a=va(t);return a.isCollapsed?t:{document:t.document,selection:KT("start"===e?a.start:a.end)}}function _T(t){return t.map(IT)}function $T(t){return t.reduce((t,e)=>t+e.text.length,0)}function tC(t,e,a){if(0===a.length)return t;const n=ha(t),r=n.findIndex(t=>t.id===e.paragraphId);if(-1===r)return t;const o=n[r],i=Ee(o,e),l=_T(a[0].runs);if(1===a.length){const e=HT(o,i,l),a=n.map((t,a)=>a===r?e:t),s=$T(l);return ZT(t,a,{anchor:Ve(e,i),focus:Ve(e,i+s)})}const s=WT(o,0,i),d=WT(o,i,ke(o)),c=a[a.length-1],h=a.slice(1,-1),p=RT(TT(a[0].paragraphTemplate),[...s,...l],OT(o,i)),u=h.map(t=>RT(TT(t.paragraphTemplate),_T(t.runs))),f=RT(TT(c.paragraphTemplate),[..._T(c.runs),...d],OT(o,i));return ZT(t,[...n.slice(0,r),p,...u,f,...n.slice(r+1)],{anchor:Ve(p,$T(s)),focus:Ve(f,$T(c.runs))})}function eC(t,e,a={}){if(va(t).isCollapsed)return t;if(function(t,e){const a=va(t);if(a.isCollapsed)return!1;const n=ha(t),r=n.findIndex(t=>t.id===e.paragraphId);if(-1===r)return!1;if(r<a.startIndex||r>a.endIndex)return!1;const o=Ee(n[r],e);return!(r===a.startIndex&&o<a.startParagraphOffset||r===a.endIndex&&o>a.endParagraphOffset)}(t,e))return t;const n=function(t){const e=va(t);if(e.isCollapsed)return[];const a=ha(t),n=[];for(let r=e.startIndex;r<=e.endIndex;r+=1){const t=a[r],o=WT(t,r===e.startIndex?e.startParagraphOffset:0,r===e.endIndex?e.endParagraphOffset:ke(t));n.push({paragraphTemplate:TT(t),runs:o})}return n}(t);if(0===n.length)return t;if(a.copy)return tC(t,e,n);const r=function(t,e){const a=va(t),n=ha(t),r=n.findIndex(t=>t.id===e.paragraphId);if(-1===r)return e;const o=Ee(n[r],e);if(a.startIndex===a.endIndex)return r!==a.startIndex||o<=a.endParagraphOffset?e:Ve(n[a.startIndex],o-(a.endParagraphOffset-a.startParagraphOffset));return e}(t,e);return tC(XT(t),r,n)}function aC(t,e,a){if(0===e.length)return t;const n=ma(t.selection)?t:XT(t),{paragraph:r,index:o,offset:i}=jT(n),l=a?{...a}:OT(r,i),s={id:`run:${Math.random().toString(36).slice(2,9)}`,text:e,styles:l};n.trackChangesEnabled&&(s.revision={id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"insert",author:"User",date:Date.now()});const d=HT(r,i,[s]);return ZT(n,ha(n).map((t,e)=>e===o?d:t),KT(Ve(d,i+e.length)))}function nC(t,e,a){if(0===e.length)return t;const n=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n");if(!n.includes("\n"))return aC(t,n,a);const r=ma(t.selection)?t:XT(t),{paragraph:o,index:i,offset:l}=jT(r),s=n.split("\n"),d=OT(o,l),c=RT(o,[...WT(o,0,l),wa(s[0],d)],d),h=WT(o,l,ke(o)),p=s.slice(1,-1).map(t=>LT([{text:t,styles:d}])),u=LT([{text:s[s.length-1],styles:d},...h.map(t=>({text:t.text,styles:t.styles}))]),f=ha(r);return ZT(r,[...f.slice(0,i),c,...p,u,...f.slice(i+1)],KT(Ve(u,s[s.length-1].length)))}function rC(t){var e;if(!ma(t.selection))return XT(t);const{paragraph:a,index:n,offset:r}=jT(t),o=ha(t);if(r>0){if(t.trackChangesEnabled){const i=a.runs;let l=0,s=-1,d=-1;for(let t=0;t<i.length;t+=1){const e=l+i[t].text.length;if(r<=e){s=t,d=r-l;break}l=e}if(-1!==s){const l=i[s];if("insert"===(null==(e=l.revision)?void 0:e.type)){const e=RT(a,[...WT(a,0,r-1),...WT(a,r,ke(a))]);return ZT(t,o.map((t,a)=>a===n?e:t),KT(Ve(e,r-1)))}const c=l.text[d-1],h={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,styles:{...l.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=RT(a,[...WT(a,0,r-1),h,...WT(a,r,ke(a))]);return ZT(t,o.map((t,e)=>e===n?p:t),KT(Ve(p,r-1)))}}const i=RT(a,[...WT(a,0,r-1),...WT(a,r,ke(a))],OT(a,r-1));return ZT(t,o.map((t,e)=>e===n?i:t),KT(Ve(i,r-1)))}if(0===n)return t;const i=o[n-1],l=RT(i,[...i.runs.map(IT),...a.runs.map(IT)]);return ZT(t,[...o.slice(0,n-1),l,...o.slice(n+1)],KT(Ve(l,ke(i))))}function oC(t){var e;if(!ma(t.selection))return XT(t);const{paragraph:a,index:n,offset:r}=jT(t),o=ha(t);if(r<ke(a)){if(t.trackChangesEnabled){const i=a.runs;let l=0,s=-1,d=-1;for(let t=0;t<i.length;t+=1){const e=l+i[t].text.length;if(r<e){s=t,d=r-l;break}l=e}if(-1!==s){const l=i[s];if("insert"===(null==(e=l.revision)?void 0:e.type)){const e=RT(a,[...WT(a,0,r),...WT(a,r+1,ke(a))]);return ZT(t,o.map((t,a)=>a===n?e:t),KT(Ve(e,r)))}const c=l.text[d],h={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,styles:{...l.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=RT(a,[...WT(a,0,r),h,...WT(a,r+1,ke(a))]);return ZT(t,o.map((t,e)=>e===n?p:t),KT(Ve(p,r)))}}const i=RT(a,[...WT(a,0,r),...WT(a,r+1,ke(a))],OT(a,r));return ZT(t,o.map((t,e)=>e===n?i:t),KT(Ve(i,r)))}if(n>=o.length-1)return t;const i=o[n+1],l=RT(a,[...a.runs.map(IT),...i.runs.map(IT)]);return ZT(t,[...o.slice(0,n),l,...o.slice(n+2)],KT(Ve(l,r)))}function iC(t,e){const a=va(t);if(a.isCollapsed)return t;const n=ha(t),r=n.slice(a.startIndex,a.endIndex+1).flatMap((t,e)=>{const n=a.startIndex+e;return WT(t,n===a.startIndex?a.startParagraphOffset:0,n===a.endIndex?a.endParagraphOffset:ke(t))}).filter(t=>t.text.length>0);if(0===r.length)return t;const o=!r.every(t=>{var a;return Boolean(null==(a=t.styles)?void 0:a[e])}),i=n.map((t,n)=>{if(n<a.startIndex||n>a.endIndex)return t;return JT(t,n===a.startIndex?a.startParagraphOffset:0,n===a.endIndex?a.endParagraphOffset:ke(t),t=>({...t,styles:xT(t.styles,e,o)}))});return ZT(t,i,YT(i,a))}function lC(t,e,a){const n=va(t);if(n.isCollapsed)return t;const r=ha(t).map((t,r)=>{if(r<n.startIndex||r>n.endIndex)return t;return JT(t,r===n.startIndex?n.startParagraphOffset:0,r===n.endIndex?n.endParagraphOffset:ke(t),t=>({...t,styles:wT(t.styles,e,a)}))});return ZT(t,r,YT(r,n))}function sC(t){return new RegExp("\\p{L}","u").test(t)}function dC(t,e){switch(e){case"lower":return t.toLowerCase();case"upper":return t.toUpperCase();case"capitalize":return function(t){let e="",a=!1;for(const n of t){const t=sC(n);e+=t&&!a?n.toUpperCase():n,a=t}return e}(t);case"toggle":return function(t){let e="";for(const a of t){const t=a.toUpperCase(),n=a.toLowerCase();e+=a===n&&a!==t?t:a===t&&a!==n?n:a}return e}(t);default:return function(t){let e="",a=!0;for(const n of t.toLowerCase())a&&sC(n)?(e+=n.toUpperCase(),a=!1):(e+=n,"."!==n&&"!"!==n&&"?"!==n||(a=!0));return e}(t)}}function cC(t,e){return function(t,e){const a=va(t);if(a.isCollapsed)return t;const n=ha(t).map((t,n)=>{if(n<a.startIndex||n>a.endIndex)return t;const r=n===a.startIndex?a.startParagraphOffset:0,o=n===a.endIndex?a.endParagraphOffset:ke(t),i=WT(t,r,o).map(t=>t.text).join(""),l=e(i);let s=0;return JT(t,r,o,t=>{const e=t.text.length,a=l.slice(s,s+e);return s+=e,{...t,text:a}})});return ZT(t,n,YT(n,a))}(t,t=>dC(t,e))}function hC(t,e,a){var n;let r;const o=t=>{const a=t.findIndex(t=>t.id===e);return a>=0?(r=t[a],[...t.slice(0,a),...t.slice(a+1)]):t},i={...t.document};if(i.sections&&i.sections.length>0&&(i.sections=i.sections.map(t=>({...t,blocks:o(t.blocks),header:t.header?o(t.header):void 0,footer:t.footer?o(t.footer):void 0}))),!r)return t;const l=a.paragraphId;if("table"===r.type){if(Ge(r).some(t=>t.id===l))return t}const s=t=>{const e=t.findIndex(t=>t.id===l||"table"===t.type&&Ge(t).some(t=>t.id===l));if(e<0)return{nextBlocks:t,found:!1};return{nextBlocks:[...t.slice(0,e),r,...t.slice(e)],found:!0}},d=sa(t),c=da(t),h={...null==(n=i.sections)?void 0:n[d]};let p=!1;if("header"===c){const t=s(h.header??[]);h.header=t.nextBlocks,p=t.found}else if("footer"===c){const t=s(h.footer??[]);h.footer=t.nextBlocks,p=t.found}else{const t=s(h.blocks);h.blocks=t.nextBlocks,p=t.found}return p||(h.blocks=[...h.blocks,r]),i.sections=[...i.sections??[]],i.sections[d]=h,{...t,document:i}}function pC(t){const e=ma(t.selection)?t:XT(t),{paragraph:a,index:n,offset:r}=jT(e),o=RT(a,WT(a,0,r),OT(a,r)),i=WT(a,r,ke(a)),l=i.length>0?zT(a,i.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Sa("");return t.style=a.style?{...a.style}:void 0,t.list=a.list?{...a.list}:void 0,t})(),s=ha(e);return ZT(e,[...kT(s.slice(0,n)),o,l,...kT(s.slice(n+1))],KT(Ve(l,0)))}function uC(t){const e=ma(t.selection)?t:XT(t),{paragraph:a,index:n,offset:r}=jT(e),o=RT(a,WT(a,0,r),OT(a,r)),i=WT(a,r,ke(a)),l=i.length>0?zT(a,i.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Sa("");return t.style=a.style?{...a.style}:void 0,t.list=a.list?{...a.list}:void 0,t})();l.style={...a.style??{},pageBreakBefore:!0};const s=ha(e);return ZT(e,[...kT(s.slice(0,n)),o,l,...kT(s.slice(n+1))],KT(Ve(l,0)))}function fC(t,e,a){const n=va(t),r=ha(t),o=n.startIndex,i=n.endIndex,l=r.map((t,n)=>n<o||n>i?TT(t):{...TT(t),style:ST(t.style,e,a)});return ZT(t,l,YT(l,n))}function gC(t,e,a){const n={...t??{}};return null===a?delete n[e]:n[e]=a,Object.keys(n).length>0?n:void 0}function mC(t,e){const a=Be(t.document).map(t=>({...t,blocks:e(t.blocks),header:t.header?e(t.header):void 0,footer:t.footer?e(t.footer):void 0}));return{...t,document:{...t.document,sections:a}}}function vC(t,e){return t.map(t=>"table"===t.type?e(t):t)}function bC(t,e){return t.map(t=>"paragraph"===t.type?t:{...e(t),rows:t.rows.map(t=>({...t,cells:t.cells.map(t=>({...t,blocks:bC(t.blocks,e)}))}))})}function yC(t){const e=sa(t),a=_e(t.document,t.selection.focus.paragraphId,e);return a?{activeSectionIndex:e,loc:a}:null}function MC(t,e){const a=yC(t);if(!a)return t;const{activeSectionIndex:n,loc:r}=a,o=da(t),i=(t,a)=>t.map((t,n)=>"table"===t.type&&n===r.blockIndex&&a===r.zone?e(t):t),l=Be(t.document).map((t,e)=>e!==n?t:{...t,blocks:"main"===o?i(t.blocks,"main"):t.blocks,header:"header"===o&&t.header?i(t.header,"header"):t.header,footer:"footer"===o&&t.footer?i(t.footer,"footer"):t.footer});return{...t,document:{...t.document,sections:l}}}function xC(t){const e=new Set,a=sa(t),n=_e(t.document,t.selection.anchor.paragraphId,a),r=_e(t.document,t.selection.focus.paragraphId,a);if(!n||!r||n.blockIndex!==r.blockIndex||n.zone!==r.zone)return e;const o=function(t,e,a){const n=Be(t)[e];if(n)return"header"===a?n.header:"footer"===a?n.footer:n.blocks}(t.document,a,n.zone),i=null==o?void 0:o[n.blockIndex];if(!i||"table"!==i.type)return e;const l=sn(i),s=l.find(t=>t.rowIndex===n.rowIndex&&t.cellIndex===n.cellIndex),d=l.find(t=>t.rowIndex===r.rowIndex&&t.cellIndex===r.cellIndex);if(!s||!d)return e;const c=Math.min(s.visualRowIndex,d.visualRowIndex),h=Math.max(s.visualRowIndex+s.rowSpan-1,d.visualRowIndex+d.rowSpan-1),p=Math.min(s.visualColumnIndex,d.visualColumnIndex),u=Math.max(s.visualColumnIndex+s.colSpan-1,d.visualColumnIndex+d.colSpan-1),f=l.filter(t=>t.visualRowIndex<=h&&t.visualRowIndex+t.rowSpan-1>=c&&t.visualColumnIndex<=u&&t.visualColumnIndex+t.colSpan-1>=p);for(const g of f)for(const t of g.cell.blocks)e.add(t.id);return e}function wC(t,e,a){const n=xC(t);if(0===n.size)for(const i of function(t){const e=new Set,a=va(t),n=ha(t);for(let r=a.startIndex;r<=a.endIndex;r+=1)e.add(n[r].id);return e}(t))n.add(i);const r=t=>({...t,style:gC(t.style,e,a)}),o=Be(t.document).map(t=>({...t,blocks:DT(t.blocks,n,r),header:t.header?DT(t.header,n,r):void 0,footer:t.footer?DT(t.footer,n,r):void 0}));return{...t,document:{...t.document,sections:o}}}function SC(t,e){let a=wC(t,"borderTop",e);return a=wC(a,"borderRight",e),a=wC(a,"borderBottom",e),a=wC(a,"borderLeft",e),a}function AC(t,e,a){const n=function(t){const e=va(t),a=ha(t),n=new Set;for(let r=e.startIndex;r<=e.endIndex;r+=1)n.add(a[r].id);return n}(t),r=t=>t.map(t=>{if("paragraph"===t.type)return t;const o=Ge(t).some(t=>n.has(t.id)),i=t.rows.map(t=>({...t,cells:t.cells.map(t=>({...t,blocks:r(t.blocks)}))})),l={...t,rows:i};return o?(s=l,{...s,style:gC(s.style,e,a)}):l;var s});return mC(t,r)}function IC(t,e,a,n){const r=t=>t.id!==e?t:{...t,style:gC(t.style,a,n)};return mC(t,t=>bC(t,r))}function TC(t,e,a){const n=yC(t);if(!n)return t;return MC(t,t=>{const r=t.rows.map((t,r)=>r===n.loc.rowIndex?{...t,style:gC(t.style,e,a)}:t);return{...t,rows:r}})}function CC(t){if("number"==typeof t&&Number.isFinite(t))return t;if("string"!=typeof t)return null;const e=t.trim().toLowerCase();if(!e||e.includes("%"))return null;if(e.endsWith("pt")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t:null}if(e.endsWith("px")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t*wn:null}if(!/^[+-]?\d+(\.\d+)?$/.test(e))return null;const a=Number.parseFloat(e);return Number.isFinite(a)?a:null}function kC(t,e,a,n,r){const o=t=>{var o;if(t.id!==e)return t;const i=sn(t),l=Math.max(1,...i.map(t=>t.visualColumnIndex+Math.max(1,t.colSpan))),s=Array(l);let d=!1,c=!0;for(let e=0;e<l;e+=1){const n=CC(a[e]);if(null!==n){s[e]=Math.max(1,n),d=!0;continue}const r=null==(o=t.gridCols)?void 0:o[e];if(!("number"==typeof r&&Number.isFinite(r)&&r>0)){c=!1;break}s[e]=r}const h=t.rows.map((t,e)=>{const n=t.cells.map((t,n)=>{const r=i.find(t=>t.rowIndex===e&&t.cellIndex===n);if(!r)return t;const o=r.visualColumnIndex+r.colSpan-1,l=a[o];return void 0!==l&&1===r.colSpan?{...t,style:{...t.style??{},width:l}}:t});return{...t,cells:n}}),p={...t.style??{}};return void 0!==n&&(p.width=n),void 0!==r&&(p.indentLeft="number"==typeof r?r:Number(r)),{...t,rows:h,gridCols:d&&c?s:t.gridCols,style:Object.keys(p).length>0?p:void 0}};return mC(t,t=>vC(t,o))}const VC={activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingSummary:"",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,shading:"",altTitle:"",altDescription:""};function EC(t){const e=sa(t),a=_e(t.document,t.selection.focus.paragraphId,e);if(!a)return null;const n=function(t,e){const a=Be(t.document)[sa(t)];return a?"header"===e?a.header??[]:"footer"===e?a.footer??[]:a.blocks:[]}(t,a.zone)[a.blockIndex];if(!n||"table"!==n.type)return null;const r=sn(n).find(t=>t.rowIndex===a.rowIndex&&t.cellIndex===a.cellIndex);return{table:n,tableId:n.id,rowIndex:a.rowIndex,cellIndex:a.cellIndex,visualColumnIndex:(null==r?void 0:r.visualColumnIndex)??a.cellIndex}}function RC(t){if("number"==typeof t&&Number.isFinite(t))return{value:String(t),unit:"points"};if("string"==typeof t){const e=t.trim();if(e.endsWith("%"))return{value:e.slice(0,-1),unit:"percent"};const a=e.match(/^([0-9.]+)(pt)?$/i);if(null==a?void 0:a[1])return{value:a[1],unit:"points"}}return{value:"",unit:"points"}}function LC(t){return!!t&&"none"!==t.type&&t.width>0}function zC(t,e="table"){var a,n,r,o,i,l,s,d,c,h,p;const u=RC(null==(a=t.table.style)?void 0:a.width),f=t.table.rows[t.rowIndex],g=null==f?void 0:f.cells[t.cellIndex],m=RC(null==(n=null==f?void 0:f.style)?void 0:n.height),v=RC(null==(r=null==g?void 0:g.style)?void 0:r.width),b=RC(null==(o=t.table.gridCols)?void 0:o[t.visualColumnIndex]),y=(null==g?void 0:g.style)??{},M=[y.borderTop,y.borderRight,y.borderBottom,y.borderLeft].filter(LC)[0],x=function(t){var e;const a=null==(e=t.style)?void 0:e.floating;return a&&0!==Object.keys(a).length?Object.entries(a).map(([t,e])=>`${t}=${e}`).join(", "):""}(t.table);return{...VC,activeTab:e,tableWidth:u.value,tableWidthUnit:u.unit,tableAlign:(null==(i=t.table.style)?void 0:i.align)??"",tableIndentLeft:RC(null==(l=t.table.style)?void 0:l.indentLeft).value,tableWrapping:x?"around":"none",floatingSummary:x,rowHeight:m.value,rowHeightRule:(null==(s=null==f?void 0:f.style)?void 0:s.heightRule)??"",repeatHeader:Boolean(null==f?void 0:f.isHeader),allowBreakAcrossPages:!0!==(null==(d=null==f?void 0:f.style)?void 0:d.cantSplit),hiddenRow:!0===(null==(c=null==f?void 0:f.style)?void 0:c.hidden),columnWidth:b.value,cellWidth:v.value,cellVerticalAlign:y.verticalAlign??"",cellTextDirection:y.textDirection??"",cellNoWrap:!0===y.noWrap,cellFitText:!0===y.fitText,cellHideMark:!0===y.hideMark,marginTop:null!=y.paddingTop?String(y.paddingTop):"",marginRight:null!=y.paddingRight?String(y.paddingRight):"",marginBottom:null!=y.paddingBottom?String(y.paddingBottom):"",marginLeft:null!=y.paddingLeft?String(y.paddingLeft):"",borderStyle:(null==M?void 0:M.type)??"none",borderWidth:M?String(M.width):"",borderColor:(null==M?void 0:M.color)??"",borderTop:LC(y.borderTop),borderRight:LC(y.borderRight),borderBottom:LC(y.borderBottom),borderLeft:LC(y.borderLeft),shading:y.shading??"",altTitle:(null==(h=t.table.style)?void 0:h.altTitle)??"",altDescription:(null==(p=t.table.style)?void 0:p.altDescription)??""}}function NC(t,e,a){return wC(t,e,a)}function qC(t,e){const a=EC(t);if(!a)return t;let n=t;return n=IC(n,a.tableId,"width",e.tableWidth),n=IC(n,a.tableId,"align",e.tableAlign),n=IC(n,a.tableId,"indentLeft",e.tableIndentLeft),n=IC(n,a.tableId,"altTitle",e.altTitle),n=IC(n,a.tableId,"altDescription",e.altDescription),n=function(t,e){const a=yC(t);return a?MC(t,t=>({...t,rows:t.rows.map((t,n)=>n===a.loc.rowIndex?{...t,isHeader:null===e?void 0:e}:t)})):t}(n,e.repeatHeader),n=TC(n,"height",e.rowHeight),n=TC(n,"heightRule",e.rowHeightRule),n=TC(n,"cantSplit",e.cantSplit),n=TC(n,"hidden",e.hiddenRow),null!==e.columnWidth&&(n=kC(n,a.tableId,{[a.visualColumnIndex]:e.columnWidth})),n=NC(n,"width",e.cellWidth),n=NC(n,"verticalAlign",e.cellVerticalAlign),n=NC(n,"textDirection",e.cellTextDirection),n=NC(n,"noWrap",e.cellNoWrap),n=NC(n,"fitText",e.cellFitText),n=NC(n,"hideMark",e.cellHideMark),n=NC(n,"paddingTop",e.margins.top),n=NC(n,"paddingRight",e.margins.right),n=NC(n,"paddingBottom",e.margins.bottom),n=NC(n,"paddingLeft",e.margins.left),n=NC(n,"borderTop",e.borders.top),n=NC(n,"borderRight",e.borders.right),n=NC(n,"borderBottom",e.borders.bottom),n=NC(n,"borderLeft",e.borders.left),n=NC(n,"shading",e.shading),n}function OC(t){const e=()=>{return e=t.state(),Boolean(EC(e));var e};return{isInsideTable:e,openTablePropertiesDialog:(e="table")=>{const a=function(t,e="table"){const a=EC(t);return a?zC(a,e):null}(t.state(),e);a&&(t.setContextMenu({isOpen:!1,x:0,y:0}),t.setTablePropertiesDialog({isOpen:!0,initial:a}))},applyTablePropertiesDialogValues:a=>{t.isReadOnly()||e()&&(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(t=>qC(t,a),{mergeKey:"tableProperties"}),t.focusInput())}}}function PC(t){if(!t)return"";const e=[];t.fontFamily&&e.push(`font-family:${t.fontFamily}`),void 0!==t.fontSize&&null!==t.fontSize&&e.push(`font-size:${t.fontSize}px`),t.color&&e.push(`color:${t.color}`),t.highlight?e.push(`background-color:${t.highlight}`):t.shading&&e.push(`background-color:${t.shading}`),t.superscript?(e.push("vertical-align:super"),e.push("font-size:0.75em")):t.subscript&&(e.push("vertical-align:sub"),e.push("font-size:0.75em")),t.bold&&e.push("font-weight:700"),t.italic&&e.push("font-style:italic"),t.hidden&&e.push("display:none"),t.allCaps&&e.push("text-transform:uppercase"),t.smallCaps&&e.push("font-variant:small-caps"),void 0!==t.characterScale&&null!==t.characterScale&&e.push(`font-stretch:${t.characterScale}%`),void 0!==t.characterSpacing&&null!==t.characterSpacing&&e.push(`letter-spacing:${t.characterSpacing}pt`),WC(t.language)&&e.push("hyphens:auto"),void 0!==t.baselineShift&&null!==t.baselineShift&&e.push(`vertical-align:${t.baselineShift}pt`);const a=function(t){switch(t){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 null}}(t.ligatures);a&&e.push(`font-variant-ligatures:${a}`);const n=function(t,e){const a=[];"proportional"===t&&a.push("proportional-nums");"tabular"===t&&a.push("tabular-nums");"lining"===e&&a.push("lining-nums");"oldStyle"===e&&a.push("oldstyle-nums");return a.join(" ")||null}(t.numberSpacing,t.numberForm);n&&e.push(`font-variant-numeric:${n}`);const r=function(t,e){const a=[];"number"==typeof t&&t>=1&&t<=20&&a.push(`"ss${String(t).padStart(2,"0")}" 1`);e&&a.push('"calt" 1');return a.join(", ")||null}(t.stylisticSet,t.contextualAlternates);r&&e.push(`font-feature-settings:${r}`);const o=[];if((t.underline||t.link)&&o.push("underline"),t.strike&&o.push("line-through"),t.doubleStrike&&o.push("line-through"),o.length>0&&(e.push(`text-decoration:${o.join(" ")}`),t.underline||t.link)){const a=function(t){switch(t){case"double":case"wavyDouble":return"double";case"dotted":case"dottedHeavy":return"dotted";case"dash":case"dashedHeavy":case"dashLong":case"dashLongHeavy":case"dotDash":case"dashDotHeavy":case"dotDotDash":case"dashDotDotHeavy":return"dashed";case"wave":case"wavyHeavy":return"wavy";default:return null}}(t.underlineStyle);a&&e.push(`text-decoration-style:${a}`),t.underlineColor&&e.push(`text-decoration-color:${t.underlineColor}`)}return e.join(";")}function WC(t){return(null==t?void 0:t.value)??(null==t?void 0:t.bidi)??(null==t?void 0:t.eastAsia)??null}function HC(t){if(!t)return"";const e=[];if(t.align&&e.push(`text-align:${t.align}`),void 0!==t.lineHeight&&null!==t.lineHeight){const a="exact"===t.lineRule||"atLeast"===t.lineRule;e.push(`line-height:${t.lineHeight}${a?"px":""}`)}return void 0!==t.spacingBefore&&null!==t.spacingBefore&&e.push(`padding-top:${t.spacingBefore}px`),void 0!==t.spacingAfter&&null!==t.spacingAfter&&e.push(`padding-bottom:${t.spacingAfter}px`),void 0!==t.indentLeft&&null!==t.indentLeft&&e.push(`padding-left:${t.indentLeft}px`),void 0!==t.indentRight&&null!==t.indentRight&&e.push(`padding-right:${t.indentRight}px`),void 0!==t.indentFirstLine&&null!==t.indentFirstLine&&e.push(`text-indent:${t.indentFirstLine}px`),e.join(";")}function UC(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function FC(t,e){if(t.image)return function(t,e){var a;if(!t.image)return"";const n=Ue(e,t.image.src),r=void 0!==t.image.alt?` alt="${UC(t.image.alt)}"`:"",o=`<img src="${UC(n)}" width="${Math.max(1,Math.round(t.image.width))}" height="${Math.max(1,Math.round(t.image.height))}"${r}>`;return(null==(a=t.styles)?void 0:a.link)?`<a href="${UC(t.styles.link)}">${o}</a>`:o}(t,e);let a=UC(t.text).replace(/\n/g,"<br>");const n=t.styles??void 0;(null==n?void 0:n.strike)&&(a=`<s>${a}</s>`),(null==n?void 0:n.underline)&&(a=`<u>${a}</u>`),(null==n?void 0:n.italic)&&(a=`<em>${a}</em>`),(null==n?void 0:n.bold)&&(a=`<strong>${a}</strong>`),(null==n?void 0:n.superscript)?a=`<sup>${a}</sup>`:(null==n?void 0:n.subscript)&&(a=`<sub>${a}</sub>`);const r=PC(n),o=function(t){if(!t)return"";const e=[],a=WC(t);return a&&e.push(`lang="${UC(a)}"`),t.value&&e.push(`data-oasis-lang-value="${UC(t.value)}"`),t.eastAsia&&e.push(`data-oasis-lang-east-asia="${UC(t.eastAsia)}"`),t.bidi&&e.push(`data-oasis-lang-bidi="${UC(t.bidi)}"`),e.length>0?` ${e.join(" ")}`:""}(null==n?void 0:n.language);if(r.length>0||o.length>0){a=`<span${r.length>0?` style="${r}"`:""}${o}>${a}</span>`}return(null==n?void 0:n.link)&&(a=`<a href="${UC(n.link)}">${a}</a>`),a}function BC(t,e){return t.map(t=>FC(t,e)).join("")||"<br>"}function GC(t){var e;const a=va(t);if(a.isCollapsed)return"";const n=ha(t),r=[];let o=null;const i=()=>{o&&(r.push("bullet"===o?"</ul>":"</ol>"),o=null)};for(let l=a.startIndex;l<=a.endIndex;l+=1){const s=n[l];if(!s)continue;const d=WT(s,l===a.startIndex?a.startParagraphOffset:0,l===a.endIndex?a.endParagraphOffset:ke(s)),c=HC(s.style),h=c.length>0?` style="${c}"`:"",p=BC(d,t.document);if(null==(e=s.list)?void 0:e.kind){const t="bullet"===s.list.kind?"ul":"ol";o!==s.list.kind&&(i(),r.push(`<${t}>`),o=s.list.kind),r.push(`<li${h}>${p}</li>`);continue}i(),r.push(`<p${h}>${p}</p>`)}return i(),r.join("")}function ZC(t,e){if(0===e.length)return t;const a=ma(t.selection)?t:XT(t),{paragraph:n,index:r,offset:o}=jT(a),i=ha(a),l=WT(n,0,o),s=WT(n,o,ke(n)),d=e.map(t=>{const e=Aa(t.runs.map(t=>({text:t.text,styles:yT(t.styles),image:t.image?{...t.image}:void 0})));return e.style=t.style?{...t.style}:void 0,e.list=t.list?{...t.list}:void 0,e});let c,h=KT(Ve(n,o));if(1===d.length){const t=d[0],e=t.runs.reduce((t,e)=>t+e.text.length,0),a=RT(n,[...l,...t.runs.map(IT),...s],OT(n,o));a.style=n.style?{...n.style}:t.style?{...t.style}:void 0,a.list=n.list?{...n.list}:t.list?{...t.list}:void 0,c=[...kT(i.slice(0,r)),a,...kT(i.slice(r+1))],h=KT(Ve(a,l.reduce((t,e)=>t+e.text.length,0)+e))}else{const t=d[0],e=d[d.length-1],a=e.runs.reduce((t,e)=>t+e.text.length,0),p=RT(n,[...l,...t.runs.map(IT)],OT(n,o));p.style=n.style?{...n.style}:t.style?{...t.style}:void 0,p.list=n.list?{...n.list}:t.list?{...t.list}:void 0;const u=d.slice(1,-1).map(TT),f=RT(e,[...e.runs.map(IT),...s],void 0);f.list=e.list?{...e.list}:void 0,c=[...kT(i.slice(0,r)),p,...u,f,...kT(i.slice(r+1))],h=KT(Ve(f,a))}return ZT(a,c,h)}function DC(t,e){return{document:t.document,selection:e}}function KC(t,e){if(!ma(t.selection))return QT(t,e<0?"start":"end");const{index:a,offset:n}=jT(t),r=ha(t),o=a+e;if(o<0||o>=r.length)return t;const i=r[o];return DC(t,KT(Ve(i,Math.min(n,ke(i)))))}function jC(t,e){const a=ua(t,t.selection.focus),n=ha(t),r=pa(n,a.paragraphId),o=n[r],i=Ee(o,a),l=ke(o);if(e<0&&i>0)return DC(t,{anchor:t.selection.anchor,focus:Ve(o,i-1)});if(e>0&&i<l)return DC(t,{anchor:t.selection.anchor,focus:Ve(o,i+1)});if(e<0&&r>0){const e=n[r-1];return DC(t,{anchor:t.selection.anchor,focus:Ve(e,ke(e))})}if(e>0&&r<n.length-1){const e=n[r+1];return DC(t,{anchor:t.selection.anchor,focus:Ve(e,0)})}return t}function XC(t,e){const a=ua(t,t.selection.focus),n=ha(t),r=pa(n,a.paragraphId),o=Ee(n[r],a),i=r+e;if(i<0||i>=n.length)return t;const l=n[i];return DC(t,{anchor:t.selection.anchor,focus:Ve(l,Math.min(o,ke(l)))})}function JC(t){const e=va(t);if(e.isCollapsed)return"";const a=ha(t);if(e.startIndex===e.endIndex){return Ce(a[e.startIndex]).slice(e.startParagraphOffset,e.endParagraphOffset)}const n=[],r=a[e.startIndex],o=a[e.endIndex];n.push(Ce(r).slice(e.startParagraphOffset));for(let i=e.startIndex+1;i<e.endIndex;i+=1)n.push(Ce(a[i]));return n.push(Ce(o).slice(0,e.endParagraphOffset)),n.join("\n")}function YC(t,e){return{...t,selection:{anchor:ua(t,e.anchor),focus:ua(t,e.focus)}}}function QC(t){if(!ma(t.selection))return QT(t,"start");const{paragraph:e,index:a,offset:n}=jT(t),r=ha(t);if(n>0)return{document:t.document,selection:KT(Ve(e,n-1))};if(0===a)return t;const o=r[a-1];return{document:t.document,selection:KT(Ve(o,ke(o)))}}function _C(t){if(!ma(t.selection))return QT(t,"end");const{paragraph:e,index:a,offset:n}=jT(t),r=ha(t);if(n<ke(e))return{document:t.document,selection:KT(Ve(e,n+1))};if(a>=r.length-1)return t;const o=r[a+1];return{document:t.document,selection:KT(Ve(o,0))}}function $C(t){if("undefined"==typeof document||0===t.trim().length)return[];const e=document.createElement("template");e.innerHTML=t;const a=[],n=Array.from(e.content.childNodes),r=(t,e,n)=>{const r=e.length>0?e:[wa("")];a.push({runs:r.map(t=>({text:t.text,styles:yT(t.styles),image:t.image?{...t.image}:void 0})),style:t?jb(t):void 0,list:n})},o=(t,e)=>{for(const a of Array.from(t.children))"LI"===a.tagName&&r(a,Zb(a,void 0),{kind:e,level:0})};for(const i of n){if(i.nodeType===Node.TEXT_NODE){const t=i.textContent??"";t.trim().length>0&&r(null,[wa(t)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const t=i,e=Kb(t.tagName);if(e){o(t,e);continue}if(Db(t.tagName)){r(t,Zb(t,void 0),"LI"===t.tagName?{kind:"bullet",level:0}:void 0);continue}const a=Zb(t,void 0);a.length>0&&r(null,a)}return a}function tk(t){const{state:e,tableOps:a,applyTableContextCommand:n}=t;return{isInsideTable:t.isInsideTable,canMerge:()=>a.canMergeSelectedTable(e()),canSplit:()=>a.canSplitSelectedTable(e()),canEditColumn:()=>a.canEditSelectedTableColumn(e()),canEditRow:()=>a.canEditSelectedTableRow(e()),openProperties:()=>t.openTablePropertiesDialog("table"),openBordersAndShading:()=>t.openTablePropertiesDialog("cell"),merge:()=>n(t=>a.mergeSelectedTable(t),"mergeTable"),split:()=>n(t=>a.splitSelectedTable(t),"splitTable"),insertColumnBefore:()=>n(t=>a.insertSelectedTableColumn(t,-1),"insertTableColumn"),insertColumnAfter:()=>n(t=>a.insertSelectedTableColumn(t,1),"insertTableColumn"),deleteColumn:()=>n(t=>a.deleteSelectedTableColumn(t),"deleteTableColumn"),insertRowBefore:()=>n(t=>a.insertSelectedTableRow(t,-1),"insertTableRow"),insertRowAfter:()=>n(t=>a.insertSelectedTableRow(t,1),"insertTableRow"),deleteRow:()=>n(t=>a.deleteSelectedTableRow(t),"deleteTableRow")}}function ek(t){const{computeFontFamilyOptions:e,computeFontSizeOptions:a,loadLocalFontFamilyOptions:n}=bT({state:t.state,toolbarStyleState:t.toolbarStyleState}),r=function(t){return{openFontDialog:()=>{var e;t.loadLocalFontFamilyOptions(),t.setFontDialog({isOpen:!0,initial:(e=t.toolbarStyleState(),{fontFamily:e.fontFamily??"",fontSize:SM(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)})}),t.setContextMenu({isOpen:!1,x:0,y:0})},applyFontDialogValues:(e,a)=>{t.isReadOnly()||(ma(t.selection())||(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(t=>{let n=t;e.fontFamily!==(a.fontFamily||null)&&(n=lC(n,"fontFamily",e.fontFamily)),e.fontSize!==(a.fontSize?Number(a.fontSize):null)&&(n=lC(n,"fontSize",AM(e.fontSize)));const r="automatic"===a.colorMode?null:a.color||null;e.color!==r&&(n=lC(n,"color",e.color)),(e.highlight??"")!==(a.highlight??"")&&(n=lC(n,"highlight",e.highlight)),(e.shading??"")!==(a.shading??"")&&(n=lC(n,"shading",e.shading)),e.bold!==Boolean(a.bold)&&(n=iC(n,"bold")),e.italic!==Boolean(a.italic)&&(n=iC(n,"italic"));const o=a.underline?a.underlineStyle??"single":null;(e.underlineStyle??null)!==(o??null)&&(n=lC(n,"underlineStyle",e.underlineStyle));const i=a.underline&&a.underlineColor||null;(e.underlineColor??null)!==(i??null)&&(n=lC(n,"underlineColor",e.underlineColor)),e.underline!==Boolean(a.underline)&&(n=iC(n,"underline")),e.strike!==Boolean(a.strike)&&(n=iC(n,"strike")),e.doubleStrike!==Boolean(a.doubleStrike)&&(n=iC(n,"doubleStrike")),e.superscript!==Boolean(a.superscript)&&(n=iC(n,"superscript")),e.subscript!==Boolean(a.subscript)&&(n=iC(n,"subscript")),e.superscript&&e.subscript&&(n=iC(n,"subscript")),e.strike&&e.doubleStrike&&(n=iC(n,"doubleStrike")),e.smallCaps!==Boolean(a.smallCaps)&&(n=iC(n,"smallCaps")),e.allCaps!==Boolean(a.allCaps)&&(n=iC(n,"allCaps")),e.hidden!==Boolean(a.hidden)&&(n=iC(n,"hidden"));const l=a.characterScale?Number(a.characterScale):null;(e.characterScale??null)!==(l??null)&&(n=lC(n,"characterScale",e.characterScale));const s=a.characterSpacing?Number(a.characterSpacing):null;(e.characterSpacing??null)!==(s??null)&&(n=lC(n,"characterSpacing",e.characterSpacing));const d=a.baselineShift?Number(a.baselineShift):null;(e.baselineShift??null)!==(d??null)&&(n=lC(n,"baselineShift",e.baselineShift));const c=a.kerningThreshold?Number(a.kerningThreshold):null;(e.kerningThreshold??null)!==(c??null)&&(n=lC(n,"kerningThreshold",e.kerningThreshold)),(e.ligatures??null)!==(a.ligatures||null)&&(n=lC(n,"ligatures",e.ligatures)),(e.numberSpacing??null)!==(a.numberSpacing||null)&&(n=lC(n,"numberSpacing",e.numberSpacing)),(e.numberForm??null)!==(a.numberForm||null)&&(n=lC(n,"numberForm",e.numberForm));const h=a.stylisticSet?Number(a.stylisticSet):null;return(e.stylisticSet??null)!==(h??null)&&(n=lC(n,"stylisticSet",e.stylisticSet)),e.contextualAlternates!==Boolean(a.contextualAlternates)&&(n=iC(n,"contextualAlternates")),n},{mergeKey:"font-dialog"})),t.focusInput())}}}({toolbarStyleState:t.toolbarStyleState,selection:t.selection,isReadOnly:t.isReadOnly,loadLocalFontFamilyOptions:n,setFontDialog:t.setFontDialog,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,focusInput:t.focusInput}),o=r.openFontDialog,i=function(t){return{openParagraphDialog:()=>{var e;t.setParagraphDialog({isOpen:!0,initial:(e=t.toolbarStyleState(),{align:e.align??"",indentLeft:e.indentLeft??"",indentRight:e.indentRight??"",indentFirstLine:e.indentFirstLine??"",indentHanging:e.indentHanging??"",spacingBefore:e.spacingBefore??"",spacingAfter:e.spacingAfter??"",lineHeight:e.lineHeight??"",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})}),t.setContextMenu({isOpen:!1,x:0,y:0})},applyParagraphDialogValues:(e,a)=>{if(t.isReadOnly())return;t.clearPreferredColumn(),t.resetTransactionGrouping();const n=t=>{if(""===t.trim())return null;const e=Number(t);return Number.isFinite(e)?e:null};t.applyTransactionalState(t=>{let r=t;e.align!==(a.align||null)&&(r=fC(r,"align",e.align)),e.indentLeft!==n(a.indentLeft)&&(r=fC(r,"indentLeft",e.indentLeft)),e.indentRight!==n(a.indentRight)&&(r=fC(r,"indentRight",e.indentRight)),e.indentFirstLine!==n(a.indentFirstLine)&&(r=fC(r,"indentFirstLine",e.indentFirstLine)),e.indentHanging!==n(a.indentHanging)&&(r=fC(r,"indentHanging",e.indentHanging)),e.spacingBefore!==n(a.spacingBefore)&&(r=fC(r,"spacingBefore",e.spacingBefore)),e.spacingAfter!==n(a.spacingAfter)&&(r=fC(r,"spacingAfter",e.spacingAfter)),e.lineHeight!==n(a.lineHeight)&&(r=fC(r,"lineHeight",e.lineHeight)),e.shading!==(a.shading||null)&&(r=fC(r,"shading",e.shading));const o="solid"===a.borderStyle||"dashed"===a.borderStyle||"dotted"===a.borderStyle?{type:a.borderStyle,width:Number(a.borderWidth)||0,color:a.borderColor||"#000000"}:null,i={borderTop:a.borderSideTop?o:null,borderRight:a.borderSideRight?o:null,borderBottom:a.borderSideBottom?o:null,borderLeft:a.borderSideLeft?o:null},l={borderTop:e.borders.top,borderRight:e.borders.right,borderBottom:e.borders.bottom,borderLeft:e.borders.left};for(const e of["borderTop","borderRight","borderBottom","borderLeft"])JSON.stringify(l[e])!==JSON.stringify(i[e])&&(r=fC(r,e,l[e]));return r},{mergeKey:"paragraph-dialog"}),t.focusInput()}}}({toolbarStyleState:t.toolbarStyleState,isReadOnly:t.isReadOnly,setParagraphDialog:t.setParagraphDialog,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,focusInput:t.focusInput}),l=i.openParagraphDialog,s=OC({state:t.state,isReadOnly:t.isReadOnly,setTablePropertiesDialog:t.setTablePropertiesDialog,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,focusInput:t.focusInput}),d=s.openTablePropertiesDialog,c=function(t){const e=t.t,a=async()=>{var e;const a=t.state(),n=JC(a);if(!n)return;const r=GC(a);try{"undefined"!=typeof ClipboardItem&&(null==(e=navigator.clipboard)?void 0:e.write)?await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([n],{type:"text/plain"}),"text/html":new Blob([r],{type:"text/html"})})]):await navigator.clipboard.writeText(n)}catch(o){t.logger.warn("contextMenu:copy:failed",{error:String(o)});try{await navigator.clipboard.writeText(n)}catch{}}},n=async()=>{t.isReadOnly()||JC(t.state())&&(await a(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>rC(t))),t.focusInput())},r=async()=>{var e,a;if(t.isReadOnly())return;let n="",r="";try{if(null==(e=navigator.clipboard)?void 0:e.read){const t=await navigator.clipboard.read();for(const e of t){if(e.types.includes("text/html")){const t=await e.getType("text/html");n=await t.text()}if(e.types.includes("text/plain")){const t=await e.getType("text/plain");r=await t.text()}}}else(null==(a=navigator.clipboard)?void 0:a.readText)&&(r=await navigator.clipboard.readText())}catch(i){t.logger.warn("contextMenu:paste:failed",{error:String(i)});try{r=await navigator.clipboard.readText()}catch{return}}const o=$C(n);if(o.length>0)return t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>ZC(t,o))),void t.focusInput();r&&(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>nC(t,r))),t.focusInput())};return{buildContextMenuItems:()=>{const o=!ma(t.state().selection),i=t.isReadOnly(),l=[{id:"cut",label:e("contextmenu.cut"),icon:"scissors",shortcut:"Ctrl+X",disabled:i||!o,testId:"editor-context-menu-cut",onSelect:()=>{n()}},{id:"copy",label:e("contextmenu.copy"),icon:"copy",shortcut:"Ctrl+C",disabled:!o,testId:"editor-context-menu-copy",onSelect:()=>{a()}},{id:"paste",label:e("contextmenu.paste"),icon:"clipboard",shortcut:"Ctrl+V",disabled:i,testId:"editor-context-menu-paste",onSelect:()=>{r()}},{id:"sep1",type:"separator"},{id:"link",label:e("contextmenu.link"),icon:"link",disabled:i||!o,testId:"editor-context-menu-link",onSelect:t.promptForLink},{id:"font",label:e("contextmenu.font"),icon:"type",disabled:i||!o,testId:"editor-context-menu-font",onSelect:t.openFontDialog},{id:"paragraph",label:e("contextmenu.paragraph"),icon:"pilcrow",disabled:i,testId:"editor-context-menu-paragraph",onSelect:t.openParagraphDialog}],s=t.table;return(null==s?void 0:s.isInsideTable())&&l.push({id:"sep-table",type:"separator"},{id:"table-properties",label:e("contextmenu.tableProperties"),icon:"table-properties",disabled:i,testId:"editor-context-menu-table-properties",onSelect:s.openProperties},{id:"table-insert-row-above",label:e("table.insertRowAbove"),icon:"rows-3",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-insert-row-above",onSelect:s.insertRowBefore},{id:"table-insert-row-below",label:e("table.insertRowBelow"),icon:"rows-3",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-insert-row-below",onSelect:s.insertRowAfter},{id:"table-insert-column-left",label:e("table.insertColumnLeft"),icon:"columns-3",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-insert-column-left",onSelect:s.insertColumnBefore},{id:"table-insert-column-right",label:e("table.insertColumnRight"),icon:"columns-3",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-insert-column-right",onSelect:s.insertColumnAfter},{id:"table-delete-row",label:e("table.deleteRow"),icon:"trash-2",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-delete-row",onSelect:s.deleteRow},{id:"table-delete-column",label:e("table.deleteColumn"),icon:"trash-2",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-delete-column",onSelect:s.deleteColumn},{id:"table-merge",label:e("table.mergeTooltip"),icon:"combine",disabled:i||!s.canMerge(),testId:"editor-context-menu-table-merge",onSelect:s.merge},{id:"table-split",label:e("table.splitTooltip"),icon:"split",disabled:i||!s.canSplit(),testId:"editor-context-menu-table-split",onSelect:s.split},{id:"table-borders-shading",label:e("contextmenu.bordersAndShading"),icon:"frame",disabled:i,testId:"editor-context-menu-table-borders-shading",onSelect:s.openBordersAndShading}),l},closeContextMenu:()=>{t.setContextMenu({isOpen:!1,x:0,y:0})},handleEditorContextMenu:e=>{e.preventDefault(),t.setContextMenu({isOpen:!0,x:e.clientX,y:e.clientY})},programmaticCopy:a,programmaticCut:n,programmaticPaste:r}}({state:t.state,isReadOnly:t.isReadOnly,t:t.t,logger:t.logger,setContextMenu:t.setContextMenu,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.applyTableAwareParagraphEdit,focusInput:t.focusInput,promptForLink:t.promptForLink,openFontDialog:o,openParagraphDialog:l,table:tk({state:t.state,tableOps:t.tableOps,isInsideTable:s.isInsideTable,openTablePropertiesDialog:d,applyTableContextCommand:(e,a)=>{t.applyTransactionalState(e,{mergeKey:a}),t.focusInput()}})});return{computeFontFamilyOptions:e,computeFontSizeOptions:a,applyFontDialogValues:r.applyFontDialogValues,applyParagraphDialogValues:i.applyParagraphDialogValues,applyTablePropertiesDialogValues:s.applyTablePropertiesDialogValues,buildContextMenuItems:c.buildContextMenuItems,handleEditorContextMenu:c.handleEditorContextMenu,closeContextMenu:c.closeContextMenu}}function ak(t){const e=w(()=>{var e,a;const n=t.targetPos(),r=t.surfaceRef;if(!r)return null;const o=qs({surface:r,state:t.state});let i=0,l=0,s=28;if(o){const e=ha(t.state).find(t=>t.id===n.paragraphId),a=e?Ee(e,n):0,r=function(t,e,a){const n=Ps(t,e.paragraphId);if(0===n.length)return null;const r=function(t,e){if(0===t.length)return null;for(const a of t)if(e>=a.startOffset&&e<=a.endOffset)return a;return t[t.length-1]??null}(n,a);if(!r)return null;const o=function(t,e){if(0===t.lines.length)return null;for(const a of t.lines)if(e>=a.startOffset&&e<=a.endOffset)return a;return t.lines[t.lines.length-1]??null}(r,a);if(!o||0===o.slots.length)return Os(r.left,r.top,1,Math.max(r.height,16));const i=o.slots.find(t=>t.offset===a)??o.slots.reduce((t,e)=>Math.abs(e.offset-a)<Math.abs(t.offset-a)?e:t,o.slots[0]);return Os(i.left,i.top,1,i.height||o.height)}(o,n,a);if(r)return{viewportLeft:r.left,viewportTop:r.top,height:Math.min(r.height||28,32)};const i=function(t,e,a="start"){const n=Ps(t,e);if(0===n.length)return null;const r="end"===a?n[n.length-1]:n[0];return Os(r.left,r.top,r.width,r.height)}(o,n.paragraphId,"end");if(i)return{viewportLeft:i.left,viewportTop:i.top,height:i.height||28}}const d=(null==(e=t.caretViewport)?void 0:e.call(t))??null;if(d)return i=d.left,l=d.top,s=Math.max(12,Math.min(36,d.height)),{viewportLeft:i,viewportTop:l,height:s};const c=(null==(a=t.pointerPos)?void 0:a.call(t))??null;return c?(i=c.x,l=c.y-12,s=24,{viewportLeft:i,viewportTop:l,height:s}):{viewportLeft:i,viewportTop:l,height:s}});return D(at,{get when(){return e()},children:t=>D(cp,{active:!0,fixed:!0,get left(){return t().viewportLeft},get top(){return t().viewportTop},get height(){return t().height}})})}var nk=ut("<div class=oasis-editor-table-resize-guide>"),rk=ut("<img class=oasis-editor-image-ghost>"),ok=ut("<div class=oasis-editor-table-ghost>");function ik(t){return[D(at,{get when(){return t.tableResize.resizing()},children:t=>{return e=nk(),M(a=>{var n=!("column"!==t().type),r=!("row"!==t().type),o={..."column"===t().type?{left:`${t().currentPos}px`,top:`${t().guideBounds.top}px`,width:"0px",height:`${t().guideBounds.height}px`}:{left:`${t().guideBounds.left}px`,top:`${t().currentPos}px`,width:`${t().guideBounds.width}px`,height:"0px"}};return n!==a.e&&e.classList.toggle("oasis-editor-table-resize-guide-column",a.e=n),r!==a.t&&e.classList.toggle("oasis-editor-table-resize-guide-row",a.t=r),a.a=yt(e,o,a.a),a},{e:void 0,t:void 0,a:void 0}),e;var e}}),D(at,{get when(){return ct(()=>!!t.imageOps.dragging())()&&t.imageOps.draggedImageInfo()},children:e=>{return a=rk(),M(n=>{var r=e().src,o=`${e().width}px`,i=`${e().height}px`,l=t.imageOps.mousePos().x-e().offsetX+"px",s=t.imageOps.mousePos().y-e().offsetY+"px";return r!==n.e&>(a,"src",n.e=r),o!==n.t&&Mt(a,"width",n.t=o),i!==n.a&&Mt(a,"height",n.a=i),l!==n.o&&Mt(a,"left",n.o=l),s!==n.i&&Mt(a,"top",n.i=s),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),a;var a}}),D(at,{get when(){return ct(()=>!!t.tableDrag.dragging())()&&t.tableDrag.draggedTableInfo()},children:e=>{return a=ok(),M(n=>{var r=`${e().width}px`,o=`${e().height}px`,i=t.tableDrag.mousePos().x-e().offsetX+"px",l=t.tableDrag.mousePos().y-e().offsetY+"px";return r!==n.e&&Mt(a,"width",n.e=r),o!==n.t&&Mt(a,"height",n.t=o),i!==n.a&&Mt(a,"left",n.a=i),l!==n.o&&Mt(a,"top",n.o=l),n},{e:void 0,t:void 0,a:void 0,o:void 0}),a;var a}}),D(at,{get when(){return ct(()=>!!t.tableDrag.dragging())()&&t.tableDrag.dropTargetPos()},children:e=>D(ak,{get surfaceRef(){return t.surfaceRef},get state(){return t.state},targetPos:e})}),D(at,{get when(){return ct(()=>!!t.imageOps.dragging())()&&t.imageOps.dropTargetPos()},children:e=>D(ak,{get surfaceRef(){return t.surfaceRef},get state(){return t.state},targetPos:e})}),D(at,{get when(){return ct(()=>!!t.textDrag.dragging())()&&t.textDrag.dropTargetPos()},children:e=>D(ak,{get surfaceRef(){return t.surfaceRef},get state(){return t.state},targetPos:e,get pointerPos(){return t.textDrag.pointerPos},get caretViewport(){return t.textDrag.caretViewport}})})]}var lk=ut("<div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=text class=oasis-editor-dialog-input data-testid=editor-link-dialog-input>"),sk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-link-dialog-cancel>'),dk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-link-dialog-apply>');function ck(t){const e=Wt(),[a,n]=y(t.initialHref);let r;x(()=>{t.isOpen&&(n(t.initialHref),setTimeout(()=>null==r?void 0:r.focus(),50))});const o=()=>{t.onConfirm(a()),t.onClose()};return D(Ky,{get isOpen(){return t.isOpen},get title(){return e("dialog.link.title")},get onClose(){return t.onClose},get footer(){return[(n=sk(),vt(n,"click",t.onClose,!0),St(n,()=>e("generic.cancel")),n),(a=dk(),a.$$click=o,St(a,()=>e("generic.apply")),a)];var a,n},get children(){var t=lk(),i=t.firstChild,l=i.nextSibling;St(i,()=>e("dialog.link.label")),l.$$keydown=t=>"Enter"===t.key&&o(),l.$$input=t=>n(t.currentTarget.value);return"function"==typeof r?wt(r,l):r=l,M(()=>gt(l,"placeholder",e("dialog.link.placeholder"))),M(()=>l.value=a()),t}})}ft(["input","keydown","click"]);var hk=ut("<div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=text class=oasis-editor-dialog-input>"),pk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary">'),uk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary">');function fk(t){const e=Wt(),[a,n]=y(t.initialAlt);let r;x(()=>{t.isOpen&&(n(t.initialAlt),setTimeout(()=>null==r?void 0:r.focus(),50))});const o=()=>{t.onConfirm(a()),t.onClose()};return D(Ky,{get isOpen(){return t.isOpen},get title(){return e("dialog.imageAlt.title")},get onClose(){return t.onClose},get footer(){return[(n=pk(),vt(n,"click",t.onClose,!0),St(n,()=>e("generic.cancel")),n),(a=uk(),a.$$click=o,St(a,()=>e("generic.save")),a)];var a,n},get children(){var t=hk(),i=t.firstChild,l=i.nextSibling;St(i,()=>e("dialog.imageAlt.label")),l.$$keydown=t=>"Enter"===t.key&&o(),l.$$input=t=>n(t.currentTarget.value);return"function"==typeof r?wt(r,l):r=l,M(()=>gt(l,"placeholder",e("dialog.imageAlt.placeholder"))),M(()=>l.value=a()),t}})}ft(["input","keydown","click"]);var gk=ut("<div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=text class=oasis-editor-dialog-input>"),mk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary">'),vk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary">');function bk(t){const e=Wt(),[a,n]=y(t.initialCaption);let r;x(()=>{t.isOpen&&(n(t.initialCaption),setTimeout(()=>null==r?void 0:r.focus(),50))});const o=()=>{t.onConfirm(a()),t.onClose()};return D(Ky,{get isOpen(){return t.isOpen},get title(){return e("dialog.imageCaption.title")},get onClose(){return t.onClose},get footer(){return[(n=mk(),vt(n,"click",t.onClose,!0),St(n,()=>e("generic.cancel")),n),(a=vk(),a.$$click=o,St(a,()=>e("generic.save")),a)];var a,n},get children(){var t=gk(),i=t.firstChild,l=i.nextSibling;St(i,()=>e("dialog.imageCaption.label")),l.$$keydown=t=>"Enter"===t.key&&o(),l.$$input=t=>n(t.currentTarget.value);return"function"==typeof r?wt(r,l):r=l,M(()=>gt(l,"placeholder",e("dialog.imageCaption.placeholder"))),M(()=>l.value=a()),t}})}ft(["input","keydown","click"]);const yk="#111827",Mk=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],xk=[33,50,66,75,90,100,105,110,115,120,150,200];function wk(t){const e=Number(t.trim());return Number.isFinite(e)&&e>0?e:null}function Sk(t){const e=Number(t.trim());return Number.isFinite(e)&&e>=0?e:null}function Ak(t){return null==t||""===t?"":String(t)}function Ik(t){const e=Number(t);return Number.isFinite(e)&&0!==e?e>0?"expanded":"condensed":"normal"}function Tk(t){const e=Number(t);return Number.isFinite(e)&&0!==e?e>0?"raised":"lowered":"normal"}function Ck(t){if(!t.trim())return null;const e=Number(t);return Number.isInteger(e)&&e>=1&&e<=20?e:null}function kk(t){switch(t){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 Vk(t,e){const a=[];return"proportional"===t&&a.push("proportional-nums"),"tabular"===t&&a.push("tabular-nums"),"lining"===e&&a.push("lining-nums"),"oldStyle"===e&&a.push("oldstyle-nums"),a.join(" ")||void 0}function Ek(t,e){const a=[],n=Ck(t);return null!==n&&a.push(`"ss${String(n).padStart(2,"0")}" 1`),e&&a.push('"calt" 1'),a.join(", ")||void 0}function Rk(t){return{familyFilter:"",fontFamily:t.fontFamily??"",fontSize:t.fontSize??"",colorMode:t.colorMode,color:t.color||yk,highlight:t.highlight||"",shading:t.shading||"",bold:Boolean(t.bold),italic:Boolean(t.italic),underline:Boolean(t.underline),underlineStyle:t.underline?t.underlineStyle??"single":"none",underlineColor:t.underlineColor||yk,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)}}function Lk(t){return{characterScale:Ak(t.characterScale),spacingMode:Ik(t.characterSpacing),spacingAmount:t.characterSpacing?String(Math.abs(Number(t.characterSpacing))):"",positionMode:Tk(t.baselineShift),positionAmount:t.baselineShift?String(Math.abs(Number(t.baselineShift))):"",kerningEnabled:""!==t.kerningThreshold,kerningThreshold:Ak(t.kerningThreshold),ligatures:t.ligatures,numberSpacing:t.numberSpacing,numberForm:t.numberForm,stylisticSet:Ak(t.stylisticSet),contextualAlternates:Boolean(t.contextualAlternates)}}function zk(t){const e=Wt(),[a,n]=y("font"),[r,o]=y(Rk(t.initial)),[i,l]=y(Lk(t.initial));x(()=>{t.isOpen&&(n("font"),o(Rk(t.initial)),l(Lk(t.initial)))});const s=w(()=>{return t=r().bold,e=r().italic,t&&e?"boldItalic":t?"bold":e?"italic":"regular";var t,e}),d=w(()=>{const e=r().familyFilter.trim().toLowerCase();return e?t.familyOptions.filter(t=>t.toLowerCase().includes(e)):t.familyOptions}),c=w(()=>{const e=new Set(Mk);for(const n of t.sizeOptions)e.add(n);const a=Number(r().fontSize);return Number.isFinite(a)&&a>0&&e.add(a),Array.from(e).sort((t,e)=>t-e)}),h=w(()=>{const t=r().fontSize.trim();if(!t)return"";const a=Number(t);return Number.isFinite(a)&&a>0?"":e("dialog.font.sizeInvalid")}),p=w(()=>{const t=i();return t.characterScale.trim()&&null===wk(t.characterScale)?e("dialog.font.advancedScaleInvalid"):"normal"!==t.spacingMode&&null===Sk(t.spacingAmount)||"normal"!==t.positionMode&&null===Sk(t.positionAmount)?e("dialog.font.advancedAmountInvalid"):t.kerningThreshold.trim()&&null===Sk(t.kerningThreshold)?e("dialog.font.advancedKerningInvalid"):t.stylisticSet.trim()&&null===Ck(t.stylisticSet)?e("dialog.font.advancedStylisticSetInvalid"):""}),u=w(()=>function(t,e){const a=Number(t.fontSize),n=wk(e.characterScale)??100,r="normal"===e.spacingMode?null:Sk(e.spacingAmount),o="normal"===e.positionMode?null:Sk(e.positionAmount),i=null===r?void 0:"condensed"===e.spacingMode?`-${r}pt`:`${r}pt`,l=null===o?void 0:"lowered"===e.positionMode?`-${o}pt`:`${o}pt`,s=[];return t.underline&&"none"!==t.underlineStyle&&s.push("underline"),t.strike&&s.push("line-through"),t.doubleStrike&&s.push("line-through"),{"font-family":t.fontFamily||"inherit","font-size":Number.isFinite(a)&&a>0?`${a}pt`:void 0,"font-weight":t.bold?700:400,"font-style":t.italic?"italic":"normal","text-decoration":s.join(" ")||"none",color:"automatic"===t.colorMode?"inherit":t.color,"background-color":t.highlight||t.shading||void 0,"vertical-align":l??(t.superscript?"super":t.subscript?"sub":"baseline"),"font-stretch":`${n}%`,"letter-spacing":i,"font-variant-ligatures":kk(e.ligatures),"font-variant-numeric":Vk(e.numberSpacing,e.numberForm),"font-feature-settings":Ek(e.stylisticSet,e.contextualAlternates)}}(r(),i()));return{activeTab:a,setActiveTab:t=>n(t),fontTabValues:r,setFontTabValues:o,advancedTabValues:i,setAdvancedTabValues:l,updateFontTab:(t,e)=>{o(a=>({...a,[t]:e}))},updateAdvancedTab:(t,e)=>{l(a=>({...a,[t]:e}))},selectedFontStyle:s,visibleFamilyOptions:d,effectiveSizeOptions:c,customSizeError:h,advancedValidationError:p,previewStyle:u,applyFontStylePreset:t=>{o(e=>({...e,bold:"bold"===t||"boldItalic"===t,italic:"italic"===t||"boldItalic"===t}))},handleApply:()=>{if(p())return;const e=function(t,e){const a=Number(t.fontSize),n=Number.isFinite(a)&&a>0,r="none"===t.underlineStyle?null:t.underlineStyle,o=null!==r,i=e.characterScale.trim()?wk(e.characterScale):null,l="normal"===e.spacingMode?null:Sk(e.spacingAmount),s="normal"===e.positionMode?null:Sk(e.positionAmount),d=e.kerningEnabled&&e.kerningThreshold.trim()?Sk(e.kerningThreshold):null,c=Ck(e.stylisticSet);return{fontFamily:t.fontFamily.trim()?t.fontFamily.trim():null,fontSize:n?a:null,colorMode:t.colorMode,color:"automatic"===t.colorMode?null:t.color||null,highlight:t.highlight||null,shading:t.shading||null,bold:t.bold,italic:t.italic,underline:o,underlineStyle:r,underlineColor:o&&t.underlineColor||null,strike:t.strike,doubleStrike:t.doubleStrike,superscript:t.superscript,subscript:t.subscript,smallCaps:t.smallCaps,allCaps:t.allCaps,hidden:t.hidden,characterScale:i,characterSpacing:null===l?null:"condensed"===e.spacingMode?-l:l,baselineShift:null===s?null:"lowered"===e.positionMode?-s:s,kerningThreshold:d,ligatures:e.ligatures||null,numberSpacing:e.numberSpacing||null,numberForm:e.numberForm||null,stylisticSet:c,contextualAlternates:e.contextualAlternates}}(r(),i());t.onApply(e,t.initial),t.onClose()}}}var Nk=ut("<div>");function qk(t){const e=Wt();return St(a=Nk(),()=>e("dialog.font.previewText")),M(e=>{var n=t.class??"oasis-editor-dialog-preview",r=t.testId,o=t.style;return n!==e.e&&mt(a,e.e=n),r!==e.t&>(a,"data-testid",e.t=r),e.a=yt(a,o,e.a),e},{e:void 0,t:void 0,a:void 0}),a;var a}var Ok=ut('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel"><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input class=oasis-editor-dialog-input data-testid=editor-font-dialog-family-filter></div></div><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-family><option value>—</option></select></div><div class="oasis-editor-dialog-input-group oasis-editor-font-dialog-size-group"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-size><option value>—</option></select></div></div><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-font-dialog-custom-size-group"><label class=oasis-editor-dialog-label></label><input class=oasis-editor-dialog-input data-testid=editor-font-dialog-custom-size><span class=oasis-editor-dialog-help-text></span></div><div class="oasis-editor-dialog-input-group oasis-editor-font-dialog-style-list-group"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-style-list><option value=regular></option><option value=italic></option><option value=bold></option><option value=boldItalic></option></select></div></div><div class="oasis-editor-dialog-row oasis-editor-font-dialog-color-row"><div class="oasis-editor-dialog-input-group oasis-editor-font-dialog-color-mode-group"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-color-mode><option value=automatic></option><option value=custom></option></select><input type=color class=oasis-editor-dialog-color data-testid=editor-font-dialog-color></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-color data-testid=editor-font-dialog-highlight></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-color data-testid=editor-font-dialog-shading></div></div><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-underline-style><option value=none></option></select></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-color data-testid=editor-font-dialog-underline-color></div></div><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><div class=oasis-editor-dialog-style-row><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-bold><span style=font-weight:700></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-italic><span style=font-style:italic></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-underline><span style=text-decoration:underline></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-strike><span style=text-decoration:line-through></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-double-strike><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-superscript><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-subscript><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-small-caps><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-all-caps><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-hidden><span></span></label></div></div></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label>'),Pk=ut("<option>");function Wk(t){const e=Wt(),{ctrl:a}=t;return(()=>{var t=Ok(),n=t.firstChild,r=n.firstChild.firstChild,o=r.nextSibling,i=n.nextSibling,l=i.firstChild,s=l.firstChild,d=s.nextSibling;d.firstChild;var c=l.nextSibling.firstChild,h=c.nextSibling;h.firstChild;var p=i.nextSibling,u=p.firstChild,f=u.firstChild,g=f.nextSibling,m=g.nextSibling,v=u.nextSibling.firstChild,b=v.nextSibling,y=b.firstChild,x=y.nextSibling,w=x.nextSibling,S=w.nextSibling,A=p.nextSibling,I=A.firstChild,T=I.firstChild,C=T.nextSibling,k=C.firstChild,V=k.nextSibling,E=C.nextSibling,R=I.nextSibling,L=R.firstChild,z=L.nextSibling,N=R.nextSibling.firstChild,q=N.nextSibling,O=A.nextSibling,P=O.firstChild,W=P.firstChild,H=W.nextSibling,U=H.firstChild,F=P.nextSibling.firstChild,B=F.nextSibling,G=O.nextSibling,Z=G.firstChild.firstChild,K=Z.nextSibling.firstChild,j=K.firstChild,X=j.nextSibling,J=K.nextSibling,Y=J.firstChild,Q=Y.nextSibling,_=J.nextSibling,$=_.firstChild,et=$.nextSibling,at=_.nextSibling,nt=at.firstChild,rt=nt.nextSibling,ot=at.nextSibling,it=ot.firstChild,lt=it.nextSibling,st=ot.nextSibling,dt=st.firstChild,ct=dt.nextSibling,ht=st.nextSibling,pt=ht.firstChild,ut=pt.nextSibling,ft=ht.nextSibling,gt=ft.firstChild,mt=gt.nextSibling,vt=ft.nextSibling,bt=vt.firstChild,yt=bt.nextSibling,Mt=vt.nextSibling.firstChild,xt=Mt.nextSibling,wt=G.nextSibling,At=wt.firstChild;return St(r,()=>e("dialog.font.familyFilter")),o.$$input=t=>a.updateFontTab("familyFilter",t.currentTarget.value),St(s,()=>e("dialog.font.family")),d.addEventListener("change",t=>a.updateFontTab("fontFamily",t.currentTarget.value)),St(d,D(tt,{get each(){return a.visibleFamilyOptions()},children:t=>{return(e=Pk()).value=t,St(e,t),e;var e}}),null),St(c,()=>e("dialog.font.size")),h.addEventListener("change",t=>a.updateFontTab("fontSize",t.currentTarget.value)),St(h,D(tt,{get each(){return a.effectiveSizeOptions()},children:t=>{return St(e=Pk(),t),M(()=>e.value=String(t)),e;var e}}),null),St(f,()=>e("dialog.font.customSize")),g.$$input=t=>a.updateFontTab("fontSize",t.currentTarget.value),St(m,()=>a.customSizeError()),St(v,()=>e("dialog.font.styleList")),b.addEventListener("change",t=>a.applyFontStylePreset(t.currentTarget.value)),St(y,()=>e("dialog.font.styleRegular")),St(x,()=>e("dialog.font.styleItalic")),St(w,()=>e("dialog.font.styleBold")),St(S,()=>e("dialog.font.styleBoldItalic")),St(T,()=>e("dialog.font.color")),C.addEventListener("change",t=>a.updateFontTab("colorMode",t.currentTarget.value)),St(k,()=>e("toolbar.colorAutomatic")),St(V,()=>e("dialog.font.customColor")),E.$$input=t=>a.setFontTabValues(e=>({...e,color:t.currentTarget.value,colorMode:"custom"})),St(L,()=>e("dialog.font.highlight")),z.$$input=t=>a.updateFontTab("highlight",t.currentTarget.value),St(N,()=>e("dialog.font.shading")),q.$$input=t=>a.updateFontTab("shading",t.currentTarget.value),St(W,()=>e("dialog.font.underlineStyle")),H.addEventListener("change",t=>a.setFontTabValues(e=>({...e,underlineStyle:t.currentTarget.value,underline:"none"!==t.currentTarget.value}))),St(U,()=>e("toolbar.underlineRemove")),St(H,D(tt,{each:IM,children:t=>{return St(a=Pk(),()=>e(t.labelKey)),M(()=>a.value=t.value),a;var a}}),null),St(F,()=>e("dialog.font.underlineColor")),B.$$input=t=>a.setFontTabValues(e=>({...e,underlineColor:t.currentTarget.value,underline:"none"!==e.underlineStyle})),St(Z,()=>e("dialog.font.style")),j.addEventListener("change",t=>a.updateFontTab("bold",t.currentTarget.checked)),St(X,()=>e("dialog.font.bold")),Y.addEventListener("change",t=>a.updateFontTab("italic",t.currentTarget.checked)),St(Q,()=>e("dialog.font.italic")),$.addEventListener("change",t=>a.setFontTabValues(e=>({...e,underline:t.currentTarget.checked,underlineStyle:t.currentTarget.checked?"none"===e.underlineStyle?"single":e.underlineStyle:"none"}))),St(et,()=>e("dialog.font.underline")),nt.addEventListener("change",t=>a.setFontTabValues(e=>({...e,strike:t.currentTarget.checked,doubleStrike:!t.currentTarget.checked&&e.doubleStrike}))),St(rt,()=>e("dialog.font.strike")),it.addEventListener("change",t=>a.setFontTabValues(e=>({...e,doubleStrike:t.currentTarget.checked,strike:!t.currentTarget.checked&&e.strike}))),St(lt,()=>e("dialog.font.doubleStrike")),dt.addEventListener("change",t=>a.setFontTabValues(e=>({...e,superscript:t.currentTarget.checked,subscript:!t.currentTarget.checked&&e.subscript}))),St(ct,()=>e("toolbar.superscript")),pt.addEventListener("change",t=>a.setFontTabValues(e=>({...e,subscript:t.currentTarget.checked,superscript:!t.currentTarget.checked&&e.superscript}))),St(ut,()=>e("toolbar.subscript")),gt.addEventListener("change",t=>a.updateFontTab("smallCaps",t.currentTarget.checked)),St(mt,()=>e("dialog.font.smallCaps")),bt.addEventListener("change",t=>a.updateFontTab("allCaps",t.currentTarget.checked)),St(yt,()=>e("dialog.font.allCaps")),Mt.addEventListener("change",t=>a.updateFontTab("hidden",t.currentTarget.checked)),St(xt,()=>e("dialog.font.hidden")),St(At,()=>e("dialog.font.preview")),St(wt,D(qk,{testId:"editor-font-dialog-preview",get style(){return a.previewStyle()}}),null),M(t=>{var e="automatic"===a.fontTabValues().colorMode,n="none"===a.fontTabValues().underlineStyle;return e!==t.e&&(E.disabled=t.e=e),n!==t.t&&(B.disabled=t.t=n),t},{e:void 0,t:void 0}),M(()=>o.value=a.fontTabValues().familyFilter),M(()=>d.value=a.fontTabValues().fontFamily),M(()=>h.value=a.fontTabValues().fontSize),M(()=>g.value=a.fontTabValues().fontSize),M(()=>b.value=a.selectedFontStyle()),M(()=>C.value=a.fontTabValues().colorMode),M(()=>E.value=a.fontTabValues().color),M(()=>z.value=a.fontTabValues().highlight||"#fef08a"),M(()=>q.value=a.fontTabValues().shading||"#fef3c7"),M(()=>H.value=a.fontTabValues().underlineStyle),M(()=>B.value=a.fontTabValues().underlineColor||yk),M(()=>j.checked=a.fontTabValues().bold),M(()=>Y.checked=a.fontTabValues().italic),M(()=>$.checked=a.fontTabValues().underline),M(()=>nt.checked=a.fontTabValues().strike),M(()=>it.checked=a.fontTabValues().doubleStrike),M(()=>dt.checked=a.fontTabValues().superscript),M(()=>pt.checked=a.fontTabValues().subscript),M(()=>gt.checked=a.fontTabValues().smallCaps),M(()=>bt.checked=a.fontTabValues().allCaps),M(()=>Mt.checked=a.fontTabValues().hidden),t})()}ft(["input"]);var Hk=ut('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel"><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-scale></select></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-spacing-mode><option value=normal></option><option value=expanded></option><option value=condensed></option></select><label class="oasis-editor-dialog-label oasis-editor-font-dialog-by-label"></label><input class="oasis-editor-dialog-input oasis-editor-font-dialog-small-input"data-testid=editor-font-dialog-advanced-spacing-amount></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-position-mode><option value=normal></option><option value=raised></option><option value=lowered></option></select><label class="oasis-editor-dialog-label oasis-editor-font-dialog-by-label"></label><input class="oasis-editor-dialog-input oasis-editor-font-dialog-small-input"data-testid=editor-font-dialog-advanced-position-amount></div><div class="oasis-editor-font-dialog-word-row oasis-editor-font-dialog-kerning-row"><label class="oasis-editor-dialog-style-toggle oasis-editor-font-dialog-kerning-toggle"><input type=checkbox data-testid=editor-font-dialog-advanced-kerning-enabled><span></span></label><input class="oasis-editor-dialog-input oasis-editor-font-dialog-kerning-input"data-testid=editor-font-dialog-advanced-kerning><span class="oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix"></span></div></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-ligatures><option value></option><option value=none></option><option value=standard></option><option value=contextual></option><option value=historical></option><option value=standardContextual></option></select></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-number-spacing><option value></option><option value=proportional></option><option value=tabular></option></select></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-number-form><option value></option><option value=lining></option><option value=oldStyle></option></select></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-stylistic-set><option value></option></select></div><label class="oasis-editor-dialog-style-toggle oasis-editor-font-dialog-contextual-toggle"><input type=checkbox data-testid=editor-font-dialog-advanced-contextual-alternates><span></span></label></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend></fieldset><p class=oasis-editor-dialog-help-text data-testid=editor-font-dialog-advanced-placeholder>'),Uk=ut("<option>%"),Fk=ut("<option>");function Bk(t){const e=Wt(),{ctrl:a}=t;return n=Hk(),r=n.firstChild,o=r.firstChild,i=o.nextSibling,l=i.firstChild,s=l.nextSibling,d=i.nextSibling,c=d.firstChild,h=c.nextSibling,p=h.firstChild,u=p.nextSibling,f=u.nextSibling,g=h.nextSibling,m=g.nextSibling,v=d.nextSibling,b=v.firstChild,y=b.nextSibling,x=y.firstChild,w=x.nextSibling,S=w.nextSibling,A=y.nextSibling,I=A.nextSibling,T=v.nextSibling.firstChild,C=T.firstChild,k=C.nextSibling,V=T.nextSibling,E=V.nextSibling,R=r.nextSibling,L=R.firstChild,z=L.nextSibling,N=z.firstChild,q=N.nextSibling,O=q.firstChild,P=O.nextSibling,W=P.nextSibling,H=W.nextSibling,U=H.nextSibling,F=U.nextSibling,B=z.nextSibling,G=B.firstChild,Z=G.nextSibling,K=Z.firstChild,j=K.nextSibling,X=j.nextSibling,J=B.nextSibling,Y=J.firstChild,Q=Y.nextSibling,_=Q.firstChild,$=_.nextSibling,et=$.nextSibling,at=J.nextSibling,nt=at.firstChild,rt=nt.nextSibling,ot=rt.firstChild,it=at.nextSibling.firstChild,lt=it.nextSibling,st=R.nextSibling,dt=st.firstChild,ct=st.nextSibling,St(o,()=>e("dialog.font.advancedCharacterSpacingGroup")),St(l,()=>e("dialog.font.advancedScale")),s.addEventListener("change",t=>a.updateAdvancedTab("characterScale",t.currentTarget.value)),St(s,D(tt,{each:xk,children:t=>{return e=Uk(),a=e.firstChild,St(e,t,a),M(()=>e.value=String(t)),e;var e,a}})),St(c,()=>e("dialog.font.advancedSpacing")),h.addEventListener("change",t=>a.updateAdvancedTab("spacingMode",t.currentTarget.value)),St(p,()=>e("dialog.font.advancedNormal")),St(u,()=>e("dialog.font.advancedExpanded")),St(f,()=>e("dialog.font.advancedCondensed")),St(g,()=>e("dialog.font.advancedBy")),m.$$input=t=>a.updateAdvancedTab("spacingAmount",t.currentTarget.value),St(b,()=>e("dialog.font.advancedPosition")),y.addEventListener("change",t=>a.updateAdvancedTab("positionMode",t.currentTarget.value)),St(x,()=>e("dialog.font.advancedNormal")),St(w,()=>e("dialog.font.advancedRaised")),St(S,()=>e("dialog.font.advancedLowered")),St(A,()=>e("dialog.font.advancedBy")),I.$$input=t=>a.updateAdvancedTab("positionAmount",t.currentTarget.value),C.addEventListener("change",t=>a.setAdvancedTabValues(e=>({...e,kerningEnabled:t.currentTarget.checked,kerningThreshold:t.currentTarget.checked?e.kerningThreshold||"1":e.kerningThreshold}))),St(k,()=>e("dialog.font.advancedKerning")),V.$$input=t=>a.updateAdvancedTab("kerningThreshold",t.currentTarget.value),St(E,()=>e("dialog.font.advancedKerningAbove")),St(L,()=>e("dialog.font.advancedOpenTypeGroup")),St(N,()=>e("dialog.font.advancedLigatures")),q.addEventListener("change",t=>a.updateAdvancedTab("ligatures",t.currentTarget.value)),St(O,()=>e("dialog.font.advancedDefault")),St(P,()=>e("dialog.font.advancedLigaturesNone")),St(W,()=>e("dialog.font.advancedLigaturesStandard")),St(H,()=>e("dialog.font.advancedLigaturesContextual")),St(U,()=>e("dialog.font.advancedLigaturesHistorical")),St(F,()=>e("dialog.font.advancedLigaturesStandardContextual")),St(G,()=>e("dialog.font.advancedNumberSpacing")),Z.addEventListener("change",t=>a.updateAdvancedTab("numberSpacing",t.currentTarget.value)),St(K,()=>e("dialog.font.advancedDefault")),St(j,()=>e("dialog.font.advancedNumberSpacingProportional")),St(X,()=>e("dialog.font.advancedNumberSpacingTabular")),St(Y,()=>e("dialog.font.advancedNumberForm")),Q.addEventListener("change",t=>a.updateAdvancedTab("numberForm",t.currentTarget.value)),St(_,()=>e("dialog.font.advancedDefault")),St($,()=>e("dialog.font.advancedNumberFormLining")),St(et,()=>e("dialog.font.advancedNumberFormOldStyle")),St(nt,()=>e("dialog.font.advancedStylisticSet")),rt.addEventListener("change",t=>a.updateAdvancedTab("stylisticSet",t.currentTarget.value)),St(ot,()=>e("dialog.font.advancedDefault")),St(rt,D(tt,{get each(){return Array.from({length:20},(t,e)=>e+1)},children:t=>{return St(e=Fk(),t),M(()=>e.value=String(t)),e;var e}}),null),it.addEventListener("change",t=>a.updateAdvancedTab("contextualAlternates",t.currentTarget.checked)),St(lt,()=>e("dialog.font.advancedContextualAlternates")),St(dt,()=>e("dialog.font.advancedPreviewGroup")),St(st,D(qk,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return a.previewStyle()}}),null),St(ct,()=>a.advancedValidationError()||e("dialog.font.advancedPlaceholder")),M(t=>{var e="normal"===a.advancedTabValues().spacingMode,n="normal"===a.advancedTabValues().positionMode,r=!a.advancedTabValues().kerningEnabled;return e!==t.e&&(m.disabled=t.e=e),n!==t.t&&(I.disabled=t.t=n),r!==t.a&&(V.disabled=t.a=r),t},{e:void 0,t:void 0,a:void 0}),M(()=>s.value=a.advancedTabValues().characterScale||"100"),M(()=>h.value=a.advancedTabValues().spacingMode),M(()=>m.value=a.advancedTabValues().spacingAmount),M(()=>y.value=a.advancedTabValues().positionMode),M(()=>I.value=a.advancedTabValues().positionAmount),M(()=>C.checked=a.advancedTabValues().kerningEnabled),M(()=>V.value=a.advancedTabValues().kerningThreshold),M(()=>q.value=a.advancedTabValues().ligatures),M(()=>Z.value=a.advancedTabValues().numberSpacing),M(()=>Q.value=a.advancedTabValues().numberForm),M(()=>rt.value=a.advancedTabValues().stylisticSet),M(()=>it.checked=a.advancedTabValues().contextualAlternates),n;var n,r,o,i,l,s,d,c,h,p,u,f,g,m,v,b,y,x,w,S,A,I,T,C,k,V,E,R,L,z,N,q,O,P,W,H,U,F,B,G,Z,K,j,X,J,Y,Q,_,$,et,at,nt,rt,ot,it,lt,st,dt,ct}ft(["input"]);var Gk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-font-dialog-cancel>'),Zk=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-font-dialog-apply>');function Dk(t){const e=Wt(),a=zk(t);return D(Ky,{get isOpen(){return t.isOpen},get title(){return e("dialog.font.title")},get onClose(){return t.onClose},class:"oasis-editor-font-dialog",bodyClass:"oasis-editor-font-dialog-body",size:"font",get footer(){return[(r=Gk(),vt(r,"click",t.onClose,!0),St(r,()=>e("generic.cancel")),r),(n=Zk(),vt(n,"click",a.handleApply,!0),St(n,()=>e("generic.ok")),n)];var n,r},get children(){return D(Qy,{class:"oasis-editor-font-dialog-tabs",get ariaLabel(){return e("dialog.font.title")},get value(){return a.activeTab()},onChange:t=>a.setActiveTab(t),get items(){return[{id:"font",label:e("dialog.font.tabFont"),testId:"editor-font-dialog-tab-font",panel:D(Wk,{ctrl:a})},{id:"advanced",label:e("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:D(Bk,{ctrl:a})}]}})}})}ft(["click"]);var Kk=ut('<div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-paragraph-dialog-align><option value=left></option><option value=center></option><option value=right></option><option value=justify>'),jk=ut('<div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input step=1 data-testid=editor-paragraph-dialog-indent-left></div><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input step=1 data-testid=editor-paragraph-dialog-indent-right>'),Xk=ut('<div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-paragraph-dialog-special><option value=none></option><option value=firstLine></option><option value=hanging></option></select></div><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input min=0 step=1 data-testid=editor-paragraph-dialog-special-by>'),Jk=ut('<div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input min=0 step=1 data-testid=editor-paragraph-dialog-spacing-before></div><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input min=0 step=1 data-testid=editor-paragraph-dialog-spacing-after></div><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input min=0.5 step=0.05 data-testid=editor-paragraph-dialog-line-height>'),Yk=ut('<div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-paragraph-dialog-border-style><option value=none></option><option value=solid></option><option value=dashed></option><option value=dotted></option></select></div><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input min=0 step=0.25 data-testid=editor-paragraph-dialog-border-width></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-input data-testid=editor-paragraph-dialog-border-color></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-input data-testid=editor-paragraph-dialog-shading>'),Qk=ut('<div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><div class=oasis-editor-dialog-style-row><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-paragraph-dialog-border-side-top></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-paragraph-dialog-border-side-right></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-paragraph-dialog-border-side-bottom></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-paragraph-dialog-border-side-left>'),_k=ut("<div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>"),$k=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-paragraph-dialog-cancel>'),tV=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-paragraph-dialog-apply>');const eV="#000000";function aV(t){if(""===t.trim())return null;const e=Number(t);return Number.isFinite(e)?e:null}function nV(t){const e=Wt(),[a,n]=y(""),[r,o]=y(""),[i,l]=y(""),[s,d]=y("none"),[c,h]=y(""),[p,u]=y(""),[f,g]=y(""),[m,v]=y(""),[b,S]=y(""),[A,I]=y("none"),[T,C]=y(""),[k,V]=y(""),[E,R]=y(!1),[L,z]=y(!1),[N,q]=y(!1),[O,P]=y(!1);x(()=>{if(t.isOpen){n(t.initial.align??""),o(t.initial.indentLeft??""),l(t.initial.indentRight??""),u(t.initial.spacingBefore??""),g(t.initial.spacingAfter??""),v(t.initial.lineHeight??""),S(t.initial.shading??"");const e=t.initial.borderStyle;I("solid"===e||"dashed"===e||"dotted"===e?e:"none"),C(t.initial.borderWidth??""),V(t.initial.borderColor??""),R(t.initial.borderSideTop??!1),z(t.initial.borderSideRight??!1),q(t.initial.borderSideBottom??!1),P(t.initial.borderSideLeft??!1);const a=aV(t.initial.indentFirstLine??""),r=aV(t.initial.indentHanging??"");null!==r&&r>0?(d("hanging"),h(t.initial.indentHanging??"")):null!==a&&a>0?(d("firstLine"),h(t.initial.indentFirstLine??"")):(d("none"),h(""))}});const W=w(()=>{const t=aV(m()),e=aV(r()),n=aV(i()),o="firstLine"===s()?aV(c()):null,l="hanging"===s()?aV(c()):null,d=null!==o?o:null!==l?-l:null,h="none"!==A()?`${aV(T())??.5}pt ${A()} ${k().trim()||eV}`:void 0;return{"text-align":a()||void 0,"line-height":null!==t&&t>0?String(t):void 0,"padding-left":null!==e?`${e+(l??0)}pt`:void 0,"padding-right":null!==n?`${n}pt`:void 0,"text-indent":null!==d?`${d}pt`:void 0,"background-color":b().trim()||void 0,"border-top":h&&E()?h:void 0,"border-right":h&&L()?h:void 0,"border-bottom":h&&N()?h:void 0,"border-left":h&&O()?h:void 0}}),H=()=>{const t=A();if("none"===t)return{top:null,right:null,bottom:null,left:null};const e=aV(T()),a={type:t,width:null!==e&&e>0?e:.5,color:k().trim()||eV};return{top:E()?a:null,right:L()?a:null,bottom:N()?a:null,left:O()?a:null}},U=()=>{const e=aV(c());t.onApply({align:a()||null,indentLeft:aV(r()),indentRight:aV(i()),indentFirstLine:"firstLine"===s()?e:null,indentHanging:"hanging"===s()?e:null,spacingBefore:aV(p()),spacingAfter:aV(f()),lineHeight:aV(m()),shading:b().trim()||null,borders:H()},t.initial),t.onClose()};return D(Ky,{get isOpen(){return t.isOpen},get title(){return e("paragraph.title")},get onClose(){return t.onClose},get footer(){return[(n=$k(),vt(n,"click",t.onClose,!0),St(n,()=>e("generic.cancel")),n),(a=tV(),a.$$click=U,St(a,()=>e("generic.apply")),a)];var a,n},get children(){return[(Ot=Kk(),Pt=Ot.firstChild.firstChild,Wt=Pt.nextSibling,Ht=Wt.firstChild,Ut=Ht.nextSibling,Ft=Ut.nextSibling,Bt=Ft.nextSibling,St(Pt,()=>e("paragraph.alignLabel")),Wt.addEventListener("change",t=>n(t.currentTarget.value)),St(Ht,()=>e("paragraph.alignLeft")),St(Ut,()=>e("paragraph.alignCenter")),St(Ft,()=>e("paragraph.alignRight")),St(Bt,()=>e("paragraph.alignJustify")),M(()=>Wt.value=a()),Ot),(Et=jk(),Rt=Et.firstChild,Lt=Rt.firstChild,zt=Lt.nextSibling,Nt=Rt.nextSibling.firstChild,qt=Nt.nextSibling,St(Lt,()=>e("paragraph.indentLeftLabel")),zt.$$input=t=>o(t.currentTarget.value),St(Nt,()=>e("paragraph.indentRightLabel")),qt.$$input=t=>l(t.currentTarget.value),M(()=>zt.value=r()),M(()=>qt.value=i()),Et),(Mt=Xk(),xt=Mt.firstChild,wt=xt.firstChild,At=wt.nextSibling,It=At.firstChild,Tt=It.nextSibling,Ct=Tt.nextSibling,kt=xt.nextSibling.firstChild,Vt=kt.nextSibling,St(wt,()=>e("paragraph.specialLabel")),At.addEventListener("change",t=>{const e=t.currentTarget.value;d(e),"none"===e&&h("")}),St(It,()=>e("paragraph.specialNone")),St(Tt,()=>e("paragraph.specialFirstLine")),St(Ct,()=>e("paragraph.specialHanging")),St(kt,()=>e("paragraph.specialByLabel")),Vt.$$input=t=>h(t.currentTarget.value),M(()=>Vt.disabled="none"===s()),M(()=>At.value=s()),M(()=>Vt.value=c()),Mt),(ct=Jk(),ht=ct.firstChild,pt=ht.firstChild,ut=pt.nextSibling,ft=ht.nextSibling,gt=ft.firstChild,mt=gt.nextSibling,vt=ft.nextSibling.firstChild,bt=vt.nextSibling,St(pt,()=>e("paragraph.spacingBeforeLabel")),ut.$$input=t=>u(t.currentTarget.value),St(gt,()=>e("paragraph.spacingAfterLabel")),mt.$$input=t=>g(t.currentTarget.value),St(vt,()=>e("paragraph.lineSpacingLabel")),bt.$$input=t=>v(t.currentTarget.value),M(()=>ut.value=p()),M(()=>mt.value=f()),M(()=>bt.value=m()),ct),(X=Yk(),J=X.firstChild,Y=J.firstChild,Q=Y.nextSibling,_=Q.firstChild,$=_.nextSibling,tt=$.nextSibling,et=tt.nextSibling,at=J.nextSibling,nt=at.firstChild,rt=nt.nextSibling,ot=at.nextSibling,it=ot.firstChild,lt=it.nextSibling,st=ot.nextSibling.firstChild,dt=st.nextSibling,St(Y,()=>e("paragraph.borderStyleLabel")),Q.addEventListener("change",t=>{const e=t.currentTarget.value;I(e),"none"===e?(R(!1),z(!1),q(!1),P(!1)):E()||L()||N()||O()||(R(!0),z(!0),q(!0),P(!0))}),St(_,()=>e("paragraph.borderNone")),St($,()=>e("paragraph.borderSolid")),St(tt,()=>e("paragraph.borderDashed")),St(et,()=>e("paragraph.borderDotted")),St(nt,()=>e("paragraph.borderWidthLabel")),rt.$$input=t=>C(t.currentTarget.value),St(it,()=>e("paragraph.borderColorLabel")),lt.$$input=t=>V(t.currentTarget.value),St(st,()=>e("paragraph.shadingLabel")),dt.$$input=t=>S(t.currentTarget.value),M(t=>{var e="none"===A(),a="none"===A();return e!==t.e&&(rt.disabled=t.e=e),a!==t.t&&(lt.disabled=t.t=a),t},{e:void 0,t:void 0}),M(()=>Q.value=A()),M(()=>rt.value=T()),M(()=>lt.value=k()||eV),M(()=>dt.value=b()||"#ffffff"),X),(w=Qk(),H=w.firstChild.firstChild,U=H.nextSibling.firstChild,F=U.firstChild,B=U.nextSibling,G=B.firstChild,Z=B.nextSibling,D=Z.firstChild,K=Z.nextSibling,j=K.firstChild,St(H,()=>e("paragraph.borderSidesLabel")),F.addEventListener("change",t=>R(t.currentTarget.checked)),St(U,()=>e("paragraph.borderSideTop"),null),G.addEventListener("change",t=>z(t.currentTarget.checked)),St(B,()=>e("paragraph.borderSideRight"),null),D.addEventListener("change",t=>q(t.currentTarget.checked)),St(Z,()=>e("paragraph.borderSideBottom"),null),j.addEventListener("change",t=>P(t.currentTarget.checked)),St(K,()=>e("paragraph.borderSideLeft"),null),M(t=>{var e="none"===A(),a="none"===A(),n="none"===A(),r="none"===A();return e!==t.e&&(F.disabled=t.e=e),a!==t.t&&(G.disabled=t.t=a),n!==t.a&&(D.disabled=t.a=n),r!==t.o&&(j.disabled=t.o=r),t},{e:void 0,t:void 0,a:void 0,o:void 0}),M(()=>F.checked=E()),M(()=>G.checked=L()),M(()=>D.checked=N()),M(()=>j.checked=O()),w),(t=_k(),y=t.firstChild,x=y.nextSibling,St(y,()=>e("paragraph.preview")),St(x,()=>e("paragraph.previewText")),M(t=>yt(x,W(),t)),t)];var t,y,x,w,H,U,F,B,G,Z,D,K,j,X,J,Y,Q,_,$,tt,et,at,nt,rt,ot,it,lt,st,dt,ct,ht,pt,ut,ft,gt,mt,vt,bt,Mt,xt,wt,At,It,Tt,Ct,kt,Vt,Et,Rt,Lt,zt,Nt,qt,Ot,Pt,Wt,Ht,Ut,Ft,Bt}})}ft(["input","click"]);var rV=ut('<div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input type=number class=oasis-editor-dialog-input min=0 step=1>'),oV=ut("<label class=oasis-editor-dialog-style-toggle><input type=checkbox>"),iV=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-table-properties-cancel>'),lV=ut('<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-table-properties-apply>'),sV=ut('<div class=oasis-editor-table-properties-panel><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-dialog-row><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-table-properties-table-width-unit><option value=points></option><option value=percent></option></select></div></div></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-dialog-style-row></div><div class=oasis-editor-dialog-row></div></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-dialog-style-row><button type=button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"disabled data-testid=editor-table-properties-positioning></button></div><div class=oasis-editor-dialog-help-text>'),dV=ut("<label class=oasis-editor-dialog-style-toggle><input type=radio name=table-align>"),cV=ut('<div class=oasis-editor-table-properties-panel><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-table-properties-row-height-rule><option value></option><option value=atLeast></option><option value=exact></option></select></div></div><div class=oasis-editor-dialog-style-row>'),hV=ut("<div class=oasis-editor-table-properties-panel><div class=oasis-editor-dialog-row>"),pV=ut('<div class=oasis-editor-table-properties-panel><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-table-properties-cell-valign><option value></option><option value=top></option><option value=middle></option><option value=bottom></option></select></div><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-table-properties-cell-direction><option value></option><option value=lrTb>lrTb</option><option value=tbRl>tbRl</option><option value=btLr>btLr</option><option value=lrTbV>lrTbV</option><option value=tbRlV>tbRlV</option></select></div></div><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-dialog-style-row></div></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-dialog-row></div></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-table-properties-border-style><option value=none></option><option value=solid></option><option value=dashed></option><option value=dotted></option></select></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-input data-testid=editor-table-properties-border-color></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-input data-testid=editor-table-properties-shading></div></div><div class=oasis-editor-dialog-style-row></div><div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>'),uV=ut('<div class=oasis-editor-table-properties-panel><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input class=oasis-editor-dialog-input data-testid=editor-table-properties-alt-title></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><textarea class="oasis-editor-dialog-input oasis-editor-table-properties-textarea"data-testid=editor-table-properties-alt-description>');const fV="#000000";function gV(t){if(""===t.trim())return null;const e=Number(t);return Number.isFinite(e)?e:null}function mV(t,e){const a=gV(t);return null===a?null:"percent"===e?`${a}%`:a}function vV(t,e,a){if("none"===t)return null;const n=gV(e);return{type:t,width:null!==n&&n>0?n:.5,color:a.trim()||fV}}function bV(t){const e=Wt(),[a,n]=y("table"),[r,o]=y(""),[i,l]=y("points"),[s,d]=y(""),[c,h]=y(""),[p,u]=y("none"),[f,g]=y(""),[m,v]=y(""),[b,S]=y(!1),[A,I]=y(!0),[T,C]=y(!1),[k,V]=y(""),[E,R]=y(""),[L,z]=y(""),[N,q]=y(""),[O,P]=y(!1),[W,H]=y(!1),[U,F]=y(!1),[B,G]=y(""),[Z,K]=y(""),[j,X]=y(""),[J,Y]=y(""),[Q,_]=y("none"),[$,tt]=y(""),[et,at]=y(""),[nt,rt]=y(!1),[ot,it]=y(!1),[lt,st]=y(!1),[dt,ct]=y(!1),[ht,pt]=y(""),[ut,ft]=y(""),[mt,bt]=y("");x(()=>{t.isOpen&&(n(t.initial.activeTab??"table"),o(t.initial.tableWidth),l(t.initial.tableWidthUnit),d(t.initial.tableAlign),h(t.initial.tableIndentLeft),u(t.initial.tableWrapping),g(t.initial.rowHeight),v(t.initial.rowHeightRule),S(t.initial.repeatHeader),I(t.initial.allowBreakAcrossPages),C(t.initial.hiddenRow),V(t.initial.columnWidth),R(t.initial.cellWidth),z(t.initial.cellVerticalAlign),q(t.initial.cellTextDirection),P(t.initial.cellNoWrap),H(t.initial.cellFitText),F(t.initial.cellHideMark),G(t.initial.marginTop),K(t.initial.marginRight),X(t.initial.marginBottom),Y(t.initial.marginLeft),_(t.initial.borderStyle),tt(t.initial.borderWidth),at(t.initial.borderColor),rt(t.initial.borderTop),it(t.initial.borderRight),st(t.initial.borderBottom),ct(t.initial.borderLeft),pt(t.initial.shading),ft(t.initial.altTitle),bt(t.initial.altDescription))});const Mt=w(()=>{const t=vV(Q(),$(),et()),e=t?`${t.width}pt ${t.type} ${t.color}`:void 0;return{"background-color":ht().trim()||void 0,"border-top":e&&nt()?e:"1px solid #dadce0","border-right":e&&ot()?e:"1px solid #dadce0","border-bottom":e&<()?e:"1px solid #dadce0","border-left":e&&dt()?e:"1px solid #dadce0"}}),xt=()=>{const e=vV(Q(),$(),et());t.onApply({tableWidth:mV(r(),i()),tableAlign:s()||null,tableIndentLeft:mV(c(),"points"),rowHeight:mV(f(),"points"),rowHeightRule:m()||null,repeatHeader:b(),cantSplit:!A(),hiddenRow:T(),columnWidth:mV(k(),"points"),cellWidth:mV(E(),"points"),cellVerticalAlign:L()||null,cellTextDirection:N()||null,cellNoWrap:O(),cellFitText:W(),cellHideMark:U(),margins:{top:gV(B()),right:gV(Z()),bottom:gV(j()),left:gV(J())},borders:{top:nt()?e:null,right:ot()?e:null,bottom:lt()?e:null,left:dt()?e:null},shading:ht().trim()||null,altTitle:ut().trim()||null,altDescription:mt().trim()||null},t.initial),t.onClose()},wt=(t,e,a,n,r=!1)=>{return o=rV(),i=o.firstChild,l=i.nextSibling,St(i,t),l.$$input=t=>a(t.currentTarget.value),l.disabled=r,gt(l,"data-testid",n),M(()=>l.value=e()),o;var o,i,l},At=(t,e,a,n,r=!1)=>{return o=oV(),(i=o.firstChild).addEventListener("change",t=>a(t.currentTarget.checked)),i.disabled=r,gt(i,"data-testid",n),St(o,t,null),M(()=>i.checked=e()),o;var o,i};return D(Ky,{get isOpen(){return t.isOpen},get title(){return e("table.propertiesTitle")},get onClose(){return t.onClose},size:"lg",class:"oasis-editor-table-properties-dialog",bodyClass:"oasis-editor-table-properties-body",get footer(){return[(n=iV(),vt(n,"click",t.onClose,!0),St(n,()=>e("generic.cancel")),n),(a=lV(),a.$$click=xt,St(a,()=>e("generic.ok")),a)];var a,n},get children(){return D(Qy,{get value(){return a()},onChange:n,get ariaLabel(){return e("table.propertiesTitle")},class:"oasis-editor-table-properties-tabs",get items(){return[{id:"table",label:e("table.tabTable"),testId:"editor-table-properties-tab-table",panel:(ue=sV(),fe=ue.firstChild,ge=fe.firstChild,me=ge.nextSibling,ve=me.firstChild,be=ve.firstChild,ye=be.nextSibling,Me=ye.firstChild,xe=Me.nextSibling,we=fe.nextSibling,Se=we.firstChild,Ae=Se.nextSibling,Ie=Ae.nextSibling,Te=we.nextSibling.firstChild,Ce=Te.nextSibling,ke=Ce.firstChild,Ve=Ce.nextSibling,St(ge,()=>e("table.sizeSection")),St(me,()=>wt(e("table.preferredWidth"),r,o,"editor-table-properties-table-width"),ve),St(be,()=>e("table.measureIn")),ye.addEventListener("change",t=>l(t.currentTarget.value)),St(Me,()=>e("table.points")),St(xe,()=>e("table.percent")),St(Se,()=>e("table.alignmentSection")),St(Ae,()=>["left","center","right"].map(t=>{return a=dV(),(n=a.firstChild).addEventListener("change",()=>d(t)),gt(n,"data-testid",`editor-table-properties-align-${t}`),St(a,()=>e(`table.align${t[0].toUpperCase()}${t.slice(1)}`),null),M(()=>n.checked=s()===t),a;var a,n})),St(Ie,()=>wt(e("table.indentFromLeft"),c,h,"editor-table-properties-indent-left")),St(Te,()=>e("table.textWrappingSection")),St(Ce,()=>At(e("table.wrapNone"),()=>"none"===p(),()=>u("none"),"editor-table-properties-wrap-none"),ke),St(Ce,()=>At(e("table.wrapAround"),()=>"around"===p(),()=>u("around"),"editor-table-properties-wrap-around",!t.initial.floatingSummary),ke),St(ke,()=>e("table.positioning")),St(Ve,()=>t.initial.floatingSummary||e("table.positioningReadOnly")),M(()=>ye.value=i()),ue)},{id:"row",label:e("table.tabRow"),testId:"editor-table-properties-tab-row",panel:(re=cV(),oe=re.firstChild,ie=oe.firstChild,le=ie.firstChild,se=le.nextSibling,de=se.firstChild,ce=de.nextSibling,he=ce.nextSibling,pe=oe.nextSibling,St(oe,()=>wt(e("table.rowHeight"),f,g,"editor-table-properties-row-height"),ie),St(le,()=>e("table.rowHeightRule")),se.addEventListener("change",t=>v(t.currentTarget.value)),St(de,()=>e("table.rowAuto")),St(ce,()=>e("table.rowAtLeast")),St(he,()=>e("table.rowExactly")),St(pe,()=>At(e("table.repeatHeader"),b,S,"editor-table-properties-repeat-header"),null),St(pe,()=>At(e("table.allowBreakAcrossPages"),A,I,"editor-table-properties-allow-break"),null),St(pe,()=>At(e("table.hiddenRow"),T,C,"editor-table-properties-hidden-row"),null),M(()=>se.value=m()),re)},{id:"column",label:e("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:(ne=hV(),St(ne.firstChild,()=>wt(e("table.columnWidth"),k,V,"editor-table-properties-column-width")),ne)},{id:"cell",label:e("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:(vt=pV(),xt=vt.firstChild,It=xt.firstChild,Tt=It.firstChild,Ct=Tt.nextSibling,kt=Ct.firstChild,Vt=kt.nextSibling,Et=Vt.nextSibling,Rt=Et.nextSibling,Lt=It.nextSibling.firstChild,zt=Lt.nextSibling,Nt=zt.firstChild,qt=xt.nextSibling,Ot=qt.firstChild,Pt=Ot.nextSibling,Wt=qt.nextSibling,Ht=Wt.firstChild,Ut=Ht.nextSibling,Ft=Wt.nextSibling.firstChild,Bt=Ft.nextSibling,Gt=Bt.firstChild,Zt=Gt.firstChild,Dt=Zt.nextSibling,Kt=Dt.firstChild,jt=Kt.nextSibling,Xt=jt.nextSibling,Jt=Xt.nextSibling,Yt=Gt.nextSibling,Qt=Yt.firstChild,_t=Qt.nextSibling,$t=Yt.nextSibling.firstChild,te=$t.nextSibling,ee=Bt.nextSibling,ae=ee.nextSibling,St(xt,()=>wt(e("table.cellWidth"),E,R,"editor-table-properties-cell-width"),It),St(Tt,()=>e("table.verticalAlignment")),Ct.addEventListener("change",t=>z(t.currentTarget.value)),St(kt,()=>e("table.inherit")),St(Vt,()=>e("table.valignTop")),St(Et,()=>e("table.valignMiddle")),St(Rt,()=>e("table.valignBottom")),St(Lt,()=>e("table.textDirection")),zt.addEventListener("change",t=>q(t.currentTarget.value)),St(Nt,()=>e("table.inherit")),St(Ot,()=>e("table.options")),St(Pt,()=>At(e("table.noWrap"),O,P,"editor-table-properties-cell-nowrap"),null),St(Pt,()=>At(e("table.fitText"),W,H,"editor-table-properties-cell-fit-text"),null),St(Pt,()=>At(e("table.hideMark"),U,F,"editor-table-properties-cell-hide-mark"),null),St(Ht,()=>e("table.cellMargins")),St(Ut,()=>wt(e("paragraph.borderSideTop"),B,G,"editor-table-properties-margin-top"),null),St(Ut,()=>wt(e("paragraph.borderSideRight"),Z,K,"editor-table-properties-margin-right"),null),St(Ut,()=>wt(e("paragraph.borderSideBottom"),j,X,"editor-table-properties-margin-bottom"),null),St(Ut,()=>wt(e("paragraph.borderSideLeft"),J,Y,"editor-table-properties-margin-left"),null),St(Ft,()=>e("paragraph.bordersSection")),St(Zt,()=>e("paragraph.borderStyleLabel")),Dt.addEventListener("change",t=>{const e=t.currentTarget.value;_(e),"none"===e?(rt(!1),it(!1),st(!1),ct(!1)):nt()||ot()||lt()||dt()||(rt(!0),it(!0),st(!0),ct(!0))}),St(Kt,()=>e("paragraph.borderNone")),St(jt,()=>e("paragraph.borderSolid")),St(Xt,()=>e("paragraph.borderDashed")),St(Jt,()=>e("paragraph.borderDotted")),St(Bt,()=>wt(e("paragraph.borderWidthLabel"),$,tt,"editor-table-properties-border-width","none"===Q()),Yt),St(Qt,()=>e("paragraph.borderColorLabel")),_t.$$input=t=>at(t.currentTarget.value),St($t,()=>e("paragraph.shadingLabel")),te.$$input=t=>pt(t.currentTarget.value),St(ee,()=>At(e("paragraph.borderSideTop"),nt,rt,"editor-table-properties-border-top","none"===Q()),null),St(ee,()=>At(e("paragraph.borderSideRight"),ot,it,"editor-table-properties-border-right","none"===Q()),null),St(ee,()=>At(e("paragraph.borderSideBottom"),lt,st,"editor-table-properties-border-bottom","none"===Q()),null),St(ee,()=>At(e("paragraph.borderSideLeft"),dt,ct,"editor-table-properties-border-left","none"===Q()),null),M(t=>{var e="none"===Q(),a=Mt();return e!==t.e&&(_t.disabled=t.e=e),t.t=yt(ae,a,t.t),t},{e:void 0,t:void 0}),M(()=>Ct.value=L()),M(()=>zt.value=N()),M(()=>Dt.value=Q()),M(()=>_t.value=et()||fV),M(()=>te.value=ht()||"#ffffff"),vt)},{id:"altText",label:e("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:(a=uV(),n=a.firstChild,y=n.firstChild,x=y.nextSibling,w=n.nextSibling.firstChild,D=w.nextSibling,St(y,()=>e("table.altTitle")),x.$$input=t=>ft(t.currentTarget.value),St(w,()=>e("table.altDescription")),D.$$input=t=>bt(t.currentTarget.value),M(()=>x.value=ut()),M(()=>D.value=mt()),a)}];var a,n,y,x,w,D,vt,xt,It,Tt,Ct,kt,Vt,Et,Rt,Lt,zt,Nt,qt,Ot,Pt,Wt,Ht,Ut,Ft,Bt,Gt,Zt,Dt,Kt,jt,Xt,Jt,Yt,Qt,_t,$t,te,ee,ae,ne,re,oe,ie,le,se,de,ce,he,pe,ue,fe,ge,me,ve,be,ye,Me,xe,we,Se,Ae,Ie,Te,Ce,ke,Ve}})}})}ft(["input","click"]);var yV=ut("<div class=oasis-editor-find-replace-dialog><div class=oasis-editor-fr-header><span></span><button class=oasis-editor-fr-close><i data-lucide=x></i></button></div><div class=oasis-editor-fr-body><div class=oasis-editor-fr-input-group><div class=oasis-editor-fr-input-wrapper><input type=text autofocus class=oasis-editor-fr-input><span class=oasis-editor-fr-counter></span></div><div class=oasis-editor-fr-actions><button><i data-lucide=chevron-up></i></button><button><i data-lucide=chevron-down></i></button></div></div><div class=oasis-editor-fr-input-group><input type=text class=oasis-editor-fr-input><div class=oasis-editor-fr-actions><button class=oasis-editor-fr-btn-text></button><button class=oasis-editor-fr-btn-text></button></div></div><div class=oasis-editor-fr-options><label class=oasis-editor-fr-checkbox><input type=checkbox><span></span></label><label class=oasis-editor-fr-checkbox><input type=checkbox><span>");function MV(t){const e=Wt(),{fr:a}=t,n=t=>{"Enter"===t.key?(t.preventDefault(),t.shiftKey?a.findPrevious():a.findNext()):"Escape"===t.key&&a.setIsOpen(!1)};return D(at,{get when(){return a.isOpen()},get children(){var t,r=yV(),o=r.firstChild,i=o.firstChild,l=i.nextSibling,s=o.nextSibling.firstChild,d=s.firstChild,c=d.firstChild,h=c.nextSibling,p=d.nextSibling.firstChild,u=p.nextSibling,f=s.nextSibling,g=f.firstChild,m=g.nextSibling.firstChild,v=m.nextSibling,b=f.nextSibling.firstChild,y=b.firstChild,x=y.nextSibling,w=b.nextSibling.firstChild,S=w.nextSibling;return r.$$keydown=n,St(i,()=>e("find.title")),l.$$click=()=>a.setIsOpen(!1),c.$$input=t=>a.setSearchTerm(t.currentTarget.value),St(h,(t=ct(()=>a.matches().length>0),()=>t()?`${a.currentIndex()+1} / ${a.matches().length}`:e("find.noMatches"))),vt(p,"click",a.findPrevious,!0),vt(u,"click",a.findNext,!0),g.$$input=t=>a.setReplaceTerm(t.currentTarget.value),vt(m,"click",a.replace,!0),St(m,()=>e("replace.one")),vt(v,"click",a.replaceAll,!0),St(v,()=>e("replace.allBtn")),y.addEventListener("change",t=>a.setFindOptions({...a.findOptions(),matchCase:t.currentTarget.checked})),St(x,()=>e("find.matchCase")),w.addEventListener("change",t=>a.setFindOptions({...a.findOptions(),wholeWord:t.currentTarget.checked})),St(S,()=>e("find.wholeWord")),M(t=>{var n=e("generic.close"),r=e("find.placeholder"),o=0===a.matches().length,i=e("find.prevTooltip"),s=0===a.matches().length,d=e("find.nextTooltip"),h=e("replace.placeholder"),f=0===a.matches().length,b=0===a.matches().length;return n!==t.e&>(l,"aria-label",t.e=n),r!==t.t&>(c,"placeholder",t.t=r),o!==t.a&&(p.disabled=t.a=o),i!==t.o&>(p,"title",t.o=i),s!==t.i&&(u.disabled=t.i=s),d!==t.n&>(u,"title",t.n=d),h!==t.s&>(g,"placeholder",t.s=h),f!==t.h&&(m.disabled=t.h=f),b!==t.r&&(v.disabled=t.r=b),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),M(()=>c.value=a.searchTerm()),M(()=>g.value=a.replaceTerm()),M(()=>y.checked=a.findOptions().matchCase),M(()=>w.checked=a.findOptions().wholeWord),r}})}ft(["keydown","click","input"]);var xV=ut("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),wV=ut("<i>"),SV=ut("<span class=oasis-editor-context-menu-shortcut>"),AV=ut("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),IV=ut("<div class=oasis-editor-context-menu-separator>"),TV=ut("<i data-lucide=check style=visibility:hidden>");function CV(t){let e;const a=e=>{t.isOpen&&"Escape"===e.key&&(e.preventDefault(),t.onClose())},n=a=>{t.isOpen&&(e&&a.target instanceof Node&&e.contains(a.target)||t.onClose())},r=a=>{t.isOpen&&(e&&a.target instanceof Node&&e.contains(a.target)||t.onClose())},o=()=>{t.isOpen&&t.onClose()};return I(()=>{window.addEventListener("keydown",a,!0),window.addEventListener("mousedown",n,!0),window.addEventListener("contextmenu",r,!0),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o,!0)}),T(()=>{window.removeEventListener("keydown",a,!0),window.removeEventListener("mousedown",n,!0),window.removeEventListener("contextmenu",r,!0),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o,!0)}),x(()=>{if(!t.isOpen||!e)return;const a=e.getBoundingClientRect(),n=Math.max(4,window.innerWidth-a.width-4),r=Math.max(4,window.innerHeight-a.height-4),o=Math.min(t.x,n),i=Math.min(t.y,r);e.style.left=`${o}px`,e.style.top=`${i}px`}),D(at,{get when(){return t.isOpen},get children(){var a=xV();a.$$contextmenu=t=>t.preventDefault();return"function"==typeof e?wt(e,a):e=a,St(a,D(tt,{get each(){return t.items},children:e=>D(at,{get when(){return"separator"!==e.type},get fallback(){return IV()},get children(){var a=AV(),n=a.firstChild;return a.$$click=()=>{var a;e.disabled||(null==(a=e.onSelect)||a.call(e),t.onClose())},St(a,D(at,{get when(){return e.icon},get fallback(){return TV()},get children(){var t=wV();return M(()=>gt(t,"data-lucide",e.icon)),t}}),n),St(n,()=>e.label),St(a,D(at,{get when(){return e.shortcut},get children(){var t=SV();return St(t,()=>e.shortcut),t}}),null),M(t=>{var n=e.disabled,r=e.testId;return n!==t.e&&(a.disabled=t.e=n),r!==t.t&>(a,"data-testid",t.t=r),t},{e:void 0,t:void 0}),a}})})),M(e=>{var n=`${t.x}px`,r=`${t.y}px`;return n!==e.e&&Mt(a,"left",e.e=n),r!==e.t&&Mt(a,"top",e.t=r),e},{e:void 0,t:void 0}),a}})}function kV(t){const{linkDialog:e,setLinkDialog:a,imageAltDialog:n,setImageAltDialog:r,imageCaptionDialog:o,setImageCaptionDialog:i,contextMenu:l,fontDialog:s,setFontDialog:d,paragraphDialog:c,setParagraphDialog:h,tablePropertiesDialog:p,setTablePropertiesDialog:u}=t.dialogs;return[D(ck,{get isOpen(){return e().isOpen},get initialHref(){return e().initialHref},onClose:()=>{a({...e(),isOpen:!1}),t.focusInput()},onConfirm:e=>t.applyLinkCommand(e.trim()||null)}),D(fk,{get isOpen(){return n().isOpen},get initialAlt(){return n().initialAlt},onClose:()=>{r({...n(),isOpen:!1}),t.focusInput()},onConfirm:e=>t.applyImageAltCommand(e.trim())}),D(bk,{get isOpen(){return o().isOpen},get initialCaption(){return o().initialCaption},onClose:()=>{i({...o(),isOpen:!1}),t.focusInput()},onConfirm:e=>t.applyImageCaptionCommand(e.trim())}),D(MV,{get fr(){return t.findReplace}}),D(Dk,{get isOpen(){return s().isOpen},get initial(){return s().initial},get familyOptions(){return t.fontFamilyOptions()},get sizeOptions(){return t.fontSizeOptions()},onClose:()=>{d({...s(),isOpen:!1}),t.focusInput()},get onApply(){return t.applyFontDialogValues}}),D(nV,{get isOpen(){return c().isOpen},get initial(){return c().initial},onClose:()=>{h({...c(),isOpen:!1}),t.focusInput()},get onApply(){return t.applyParagraphDialogValues}}),D(bV,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{u({...p(),isOpen:!1}),t.focusInput()},get onApply(){return t.applyTablePropertiesDialogValues}}),D(CV,{get isOpen(){return l().isOpen},get x(){return l().x},get y(){return l().y},get items(){return t.contextMenuItems()},get onClose(){return t.closeContextMenu}})]}ft(["contextmenu","click"]);var VV=ut("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function EV(t){return[D(at,{get when(){return t.useComposedShell()},get children(){return(()=>{const e=t.shellComponent(),{runtime:a,chrome:n,view:r}=t;return D(e,{get state(){return a.state()},get toolbarHost(){return a.toolbarHost},get runtimeEditor(){return a.runtimeEditor},get persistenceStatus(){return a.persistenceStatus},get toolbarRegistry(){return a.toolbarRegistry},get menuRegistry(){return a.menuRegistry},get showChrome(){return n.showChrome()},get showTitleBar(){return n.showTitleBar()},get showMenubar(){return n.showMenubar()},get showToolbar(){return n.showToolbar()},get showOutline(){return n.showOutline()},get toolbarView(){return n.toolbarView()},get toolbarLayout(){return n.toolbarLayout()},get isReadOnly(){return r.isReadOnly()},get measuredBlockHeights(){return r.measuredBlockHeights},get measuredParagraphLayouts(){return r.measuredParagraphLayouts},get viewportHeight(){return r.viewportHeight},get showFloatingTableToolbar(){return a.showFloatingTableToolbar},get layout(){return r.layout},get overlays(){return r.overlays},get refs(){return r.refs},get surfaceHandlers(){return r.surfaceHandlers},get inputHandlers(){return r.inputHandlers},get fileHandlers(){return r.fileHandlers}})})()}}),D(at,{get when(){return!t.useComposedShell()},get children(){return D(Ny,{get editor(){return t.runtime.runtimeEditor},get children(){var e=VV();return St(e.firstChild,D(by,{get state(){return t.runtime.state},get layout(){return{...t.view.layout,measuredBlockHeights:t.view.measuredBlockHeights,measuredParagraphLayouts:t.view.measuredParagraphLayouts,readOnly:t.view.isReadOnly()}},get overlays(){return{...t.view.overlays,toolbarHost:t.runtime.toolbarHost,persistenceStatus:t.runtime.persistenceStatus,showFloatingTableToolbar:t.runtime.showFloatingTableToolbar}},get refs(){return t.view.refs},get surfaceHandlers(){return t.view.surfaceHandlers},get inputHandlers(){return t.view.inputHandlers},get fileHandlers(){return t.view.fileHandlers}})),e}})}})]}var RV=ut('<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><button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-welcome-skip></button><button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-welcome-enable>');function LV(t){const e=Wt(),a=()=>{xc(),hc(),t.onClose()},n=()=>{pc(!1),hc(),t.onClose()};return D(at,{get when(){return t.isOpen},get children(){var t=RV(),r=t.firstChild,o=r.firstChild,i=o.nextSibling,l=i.nextSibling,s=l.nextSibling.firstChild,d=s.nextSibling;return St(r,D(Ft,{height:72,class:"oasis-editor-welcome-mark"}),o),St(o,()=>e("welcome.title")),St(i,()=>e("welcome.body")),St(l,()=>e("welcome.note")),s.$$click=n,St(s,()=>e("welcome.skip")),d.$$click=a,St(d,()=>e("welcome.enable")),t}})}ft(["click"]);const zV="http://schemas.openxmlformats.org/wordprocessingml/2006/main",NV="http://schemas.openxmlformats.org/package/2006/relationships",qV="http://schemas.openxmlformats.org/officeDocument/2006/relationships",OV="http://schemas.microsoft.com/office/word/2010/wordml";function PV(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function WV(t,e){return Number.isFinite(t)?Math.max(0,Math.round(t/Mn*In)):e}function HV(t){return null!=t&&Number.isFinite(t)?Math.round(t/Mn*In):null}function UV(t){return null!=t&&Number.isFinite(t)?Math.max(0,Math.round(20*t)):null}function FV(t,e="000000"){const a=null==t?void 0:t.trim().replace(/^#/,"");return a&&/^[0-9a-fA-F]{6}$/.test(a)?a.toUpperCase():e}function BV(t){if("end"===t.kind)return`<w:bookmarkEnd w:id="${t.wId}"/>`;const e=(void 0!==t.colFirst?` w:colFirst="${t.colFirst}"`:"")+(void 0!==t.colLast?` w:colLast="${t.colLast}"`:"");return`<w:bookmarkStart w:id="${t.wId}" w:name="${PV(t.name??"")}"${e}/>`}function GV(t){switch(t.kind){case"start":return`<w:commentRangeStart w:id="${t.wId}"/>`;case"end":return`<w:commentRangeEnd w:id="${t.wId}"/>`;case"reference":return`<w:r><w:commentReference w:id="${t.wId}"/></w:r>`}}const ZV=`xmlns:w="${zV}" xmlns:w14="${OV}" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"`;function DV(t){const e=t.comments.map(({comment:t,wId:e,paraId:a})=>{const n=void 0!==t.date?` w:date="${new Date(t.date).toISOString().replace(/\.\d{3}Z$/,"Z")}"`:"",r=t.initials?` w:initials="${PV(t.initials)}"`:"";return`<w:comment w:id="${e}" w:author="${PV(t.author)}"${n}${r}><w:p w14:paraId="${a}">${o=t.text,`<w:r>${o.split("\n").map((t,e)=>`${e>0?"<w:br/>":""}<w:t xml:space="preserve">${PV(t)}</w:t>`).join("")}</w:r>`}</w:p></w:comment>`;var o}).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:comments ${ZV}>${e}</w:comments>`}function KV(t,e="000000"){if("none"===t.type||t.width<=0)return'w:val="nil"/>';return`w:val="${"dotted"===t.type?"dotted":"dashed"===t.type?"dashed":"single"}" w:sz="${Math.max(1,Math.round(8*t.width))}" w:space="0" w:color="${FV(t.color,e)}"/>`}function jV(t){const e=[["top",t.borderTop],["left",t.borderLeft],["bottom",t.borderBottom],["right",t.borderRight]].filter(t=>null!=t[1]).map(([t,e])=>`<w:${t} ${KV(e)}`);return e.length>0?`<w:pBdr>${e.join("")}</w:pBdr>`:""}const XV="6F6F6F";function JV(t,e){return void 0===e?"":e?`<w:${t}/>`:`<w:${t} w:val="0"/>`}function YV(t,e,a={}){if("number"==typeof e&&Number.isFinite(e))return`<w:${t} w:w="${UV(e)??0}" w:type="dxa"/>`;if("string"==typeof e){const a=e.trim();if("auto"===a)return`<w:${t} w:w="0" w:type="auto"/>`;if(a.endsWith("%")){const e=Number.parseFloat(a.slice(0,-1));if(Number.isFinite(e))return`<w:${t} w:w="${Math.round(50*e)}" w:type="pct"/>`}const n=Number.parseFloat(a);if(Number.isFinite(n))return`<w:${t} w:w="${Math.round(n)}" w:type="dxa"/>`}return a.fallbackAuto?`<w:${t} w:w="0" w:type="auto"/>`:""}function QV(t){return KV(t??{width:.75,type:"solid",color:`#${XV}`},XV)}function _V(t,e){var a,n,r,o,i,l,s,d,c,h;const p=Math.max(1,Math.floor(t.colSpan??1)),u=[],f=YV("tcW",(null==(a=t.style)?void 0:a.width)??e);f&&u.push(f),p>1&&u.push(`<w:gridSpan w:val="${p}"/>`),"restart"===t.vMerge?u.push('<w:vMerge w:val="restart"/>'):"continue"===t.vMerge&&u.push("<w:vMerge/>"),(null==(n=t.style)?void 0:n.shading)&&u.push(`<w:shd w:val="clear" w:color="auto" w:fill="${FV(t.style.shading,"FFFFFF")}"/>`);const g=JV("noWrap",null==(r=t.style)?void 0:r.noWrap);g&&u.push(g);const m=JV("tcFitText",null==(o=t.style)?void 0:o.fitText);if(m&&u.push(m),(null==(i=t.style)?void 0:i.headers)&&u.push(`<w:headers w:val="${PV(t.style.headers)}"/>`),null==(l=t.style)?void 0:l.verticalAlign){const e="middle"===t.style.verticalAlign?"center":t.style.verticalAlign;u.push(`<w:vAlign w:val="${e}"/>`)}(null==(s=t.style)?void 0:s.textDirection)&&u.push(`<w:textDirection w:val="${t.style.textDirection}"/>`),u.push(function(t){const e=t.style,a=null==e?void 0:e.padding,n=UV(a??(null==e?void 0:e.paddingTop)??0),r=UV(a??(null==e?void 0:e.paddingBottom)??0);return`<w:tcMar><w:top w:w="${n??0}" w:type="dxa"/><w:left w:w="${UV(a??(null==e?void 0:e.paddingLeft)??5.4)??0}" w:type="dxa"/><w:bottom w:w="${r??0}" w:type="dxa"/><w:right w:w="${UV(a??(null==e?void 0:e.paddingRight)??5.4)??0}" w:type="dxa"/>${void 0!==(null==e?void 0:e.paddingStart)?`<w:start w:w="${UV(e.paddingStart)??0}" w:type="dxa"/>`:""}${void 0!==(null==e?void 0:e.paddingEnd)?`<w:end w:w="${UV(e.paddingEnd)??0}" w:type="dxa"/>`:""}</w:tcMar>`}(t)),u.push(function(t){var e,a,n,r,o,i,l,s;const d=[`<w:top ${QV(null==(e=t.style)?void 0:e.borderTop)}`,`<w:left ${QV(null==(a=t.style)?void 0:a.borderLeft)}`,`<w:bottom ${QV(null==(n=t.style)?void 0:n.borderBottom)}`,`<w:right ${QV(null==(r=t.style)?void 0:r.borderRight)}`];return(null==(o=t.style)?void 0:o.borderStart)&&d.push(`<w:start ${QV(t.style.borderStart)}`),(null==(i=t.style)?void 0:i.borderEnd)&&d.push(`<w:end ${QV(t.style.borderEnd)}`),(null==(l=t.style)?void 0:l.borderTopLeftToBottomRight)&&d.push(`<w:tl2br ${QV(t.style.borderTopLeftToBottomRight)}`),(null==(s=t.style)?void 0:s.borderTopRightToBottomLeft)&&d.push(`<w:tr2bl ${QV(t.style.borderTopRightToBottomLeft)}`),`<w:tcBorders>${d.join("")}</w:tcBorders>`}(t));const v=JV("hideMark",null==(d=t.style)?void 0:d.hideMark);return v&&u.push(v),(null==(h=null==(c=t.style)?void 0:c.revisionXml)?void 0:h.length)&&u.push(...t.style.revisionXml),u.length>0?`<w:tcPr>${u.join("")}</w:tcPr>`:""}function $V(t,e){if(void 0===e||!Number.isFinite(e))return"";const a=Math.floor(e);return a>0?`<w:${t} w:val="${a}"/>`:""}function tE(t,e){const a="number"==typeof t?UV(t):"string"==typeof t?Number.parseFloat(t):null,n=null!==a&&Number.isFinite(a);if(!n&&!e)return"";const r=[];return n&&r.push(`w:val="${Math.round(a)}"`),r.push(`w:hRule="${e??"atLeast"}"`),`<w:trHeight ${r.join(" ")}/>`}function eE(t){var e,a,n,r,o,i,l,s,d;const c=[],h=$V("gridBefore",null==(e=t.style)?void 0:e.gridBefore);h&&c.push(h);const p=$V("gridAfter",null==(a=t.style)?void 0:a.gridAfter);p&&c.push(p);const u=YV("wBefore",null==(n=t.style)?void 0:n.widthBefore);u&&c.push(u);const f=YV("wAfter",null==(r=t.style)?void 0:r.widthAfter);f&&c.push(f);const g=YV("tblCellSpacing",null==(o=t.style)?void 0:o.cellSpacing);g&&c.push(g);const m=function(t){var e,a;return tE(null==(e=t.style)?void 0:e.height,null==(a=t.style)?void 0:a.heightRule)}(t);m&&c.push(m);const v=JV("cantSplit",null==(i=t.style)?void 0:i.cantSplit);v&&c.push(v),t.isHeader&&c.push("<w:tblHeader/>");const b=JV("hidden",null==(l=t.style)?void 0:l.hidden);return b&&c.push(b),(null==(d=null==(s=t.style)?void 0:s.revisionXml)?void 0:d.length)&&c.push(...t.style.revisionXml),c.length>0?`<w:trPr>${c.join("")}</w:trPr>`:""}function aE(t){var e,a,n,r,o,i,l,s,d,c,h,p,u,f,g;const m=[];if((null==(e=t.style)?void 0:e.styleId)&&m.push(`<w:tblStyle w:val="${PV(t.style.styleId)}"/>`),null==(a=t.style)?void 0:a.tblLook){const e=t.style.tblLook;m.push(`<w:tblLook w:firstRow="${e.firstRow?"1":"0"}" w:lastRow="${e.lastRow?"1":"0"}" w:firstColumn="${e.firstCol?"1":"0"}" w:lastColumn="${e.lastCol?"1":"0"}" w:noHBand="${e.noHBand?"1":"0"}" w:noVBand="${e.noVBand?"1":"0"}"/>`)}(null==(n=t.style)?void 0:n.altTitle)&&m.push(`<w:tblCaption w:val="${PV(t.style.altTitle)}"/>`),(null==(r=t.style)?void 0:r.altDescription)&&m.push(`<w:tblDescription w:val="${PV(t.style.altDescription)}"/>`);const v=(b=null==(o=t.style)?void 0:o.floating)&&0!==Object.keys(b).length?`<w:tblpPr ${Object.entries(b).map(([t,e])=>`w:${t}="${PV(e)}"`).join(" ")}/>`:"";var b;v&&m.push(v);const y=t.gridCols&&t.gridCols.length>0?t.gridCols.reduce((t,e)=>t+e,0):void 0;m.push(function(t,e=!0){return YV("tblW",t,{fallbackAuto:e})}((null==(i=t.style)?void 0:i.width)??y)),(null==(l=t.style)?void 0:l.align)&&m.push(`<w:jc w:val="${t.style.align}"/>`);const M=YV("tblCellSpacing",null==(s=t.style)?void 0:s.cellSpacing);M&&m.push(M);const x=function(t){if(!t)return"";const e=[],a=(t,a)=>{void 0!==a&&Number.isFinite(a)&&e.push(`<w:${t} w:w="${UV(a)??0}" w:type="dxa"/>`)};return a("top",t.top),a("left",t.left),a("bottom",t.bottom),a("right",t.right),a("start",t.start),a("end",t.end),e.length>0?`<w:tblCellMar>${e.join("")}</w:tblCellMar>`:""}(null==(d=t.style)?void 0:d.defaultCellMargins);x&&m.push(x);const w=YV("tblInd",null==(c=t.style)?void 0:c.indentLeft);w&&m.push(w),m.push(`<w:tblLayout w:type="${(null==(h=t.style)?void 0:h.layout)??"fixed"}"/>`);const S=JV("bidiVisual",null==(p=t.style)?void 0:p.bidiVisual);return S&&m.push(S),(null==(u=t.style)?void 0:u.tblOverlap)&&m.push(`<w:tblOverlap w:val="${PV(t.style.tblOverlap)}"/>`),(null==(g=null==(f=t.style)?void 0:f.revisionXml)?void 0:g.length)&&m.push(...t.style.revisionXml),`<w:tblPr>${m.join("")}</w:tblPr>`}function nE(t,e){const a=sn(t),n=new Map(a.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t])),r=t.rows.map((a,r)=>{const o=a.cells.map((a,o)=>{const i=n.get(`${r}:${o}`),l=i&&t.gridCols?t.gridCols.slice(i.visualColumnIndex,i.visualColumnIndex+Math.max(1,i.colSpan)).reduce((t,e)=>t+e,0):void 0,s=(a.blocks.length>0?a.blocks:[{id:"",type:"paragraph",runs:[{id:"",text:""}]}]).map(t=>e(t,a)).join(""),d="continue"===a.vMerge?"<w:p/>":s;return`<w:tc>${_V(a,l)}${d}</w:tc>`}).join("");return`<w:tr>${a.tblPrExXml??""}${eE(a)}${o}</w:tr>`}).join(""),o=t.gridCols?`<w:tblGrid>${t.gridCols.map(t=>`<w:gridCol w:w="${UV(t)??0}"/>`).join("")}${t.tblGridChangeXml??""}</w:tblGrid>`:"";return`<w:tbl>${aE(t)}${o}${r}</w:tbl>`}function rE(t){if(!t||0===t.length)return"";const e=t.map(t=>{const e=UV(t.position);if(null===e)return"";const a=[`w:val="${t.type}"`,`w:pos="${e}"`];return t.leader&&"none"!==t.leader?a.push(`w:leader="${t.leader}"`):"none"===t.leader&&a.push('w:leader="none"'),`<w:tab ${a.join(" ")}/>`}).filter(Boolean);return e.length>0?`<w:tabs>${e.join("")}</w:tabs>`:""}function oE(t){const e=[];if(t.align&&e.push(`<w:jc w:val="${t.align}"/>`),void 0!==t.spacingBefore||void 0!==t.spacingAfter||void 0!==t.lineHeight){const a=[],n=HV(t.spacingBefore),r=HV(t.spacingAfter),o=void 0!==t.lineHeight&&null!==t.lineHeight&&Number.isFinite(t.lineHeight),i="exact"===t.lineRule||"atLeast"===t.lineRule,l=o?i?WV(t.lineHeight,0):Math.round(240*t.lineHeight):null;null!==n&&a.push(`w:before="${n}"`),null!==r&&a.push(`w:after="${r}"`),null!==l&&a.push(`w:line="${l}"`),null!==l&&i&&a.push(`w:lineRule="${t.lineRule}"`),a.length>0&&e.push(`<w:spacing ${a.join(" ")}/>`)}if(void 0!==t.indentLeft||void 0!==t.indentRight||void 0!==t.indentFirstLine||void 0!==t.indentHanging){const a=[],n=HV(t.indentLeft),r=HV(t.indentRight),o=HV(t.indentFirstLine),i=HV(t.indentHanging);null!==n&&a.push(`w:left="${n}"`),null!==r&&a.push(`w:right="${r}"`),null!==o&&a.push(`w:firstLine="${o}"`),null!==i&&a.push(`w:hanging="${i}"`),a.length>0&&e.push(`<w:ind ${a.join(" ")}/>`)}const a=rE(t.tabs);a&&e.push(a),t.pageBreakBefore&&e.push("<w:pageBreakBefore/>"),t.keepWithNext&&e.push("<w:keepNext/>"),t.keepLinesTogether&&e.push("<w:keepLines/>"),!1===t.widowControl&&e.push('<w:widowControl w:val="0"/>'),t.contextualSpacing&&e.push("<w:contextualSpacing/>");const n=jV(t);return n&&e.push(n),t.shading&&e.push(`<w:shd w:val="clear" w:color="auto" w:fill="${FV(t.shading,"FFFFFF")}"/>`),t.textDirection&&e.push(`<w:textDirection w:val="${t.textDirection}"/>`),null!=t.outlineLevel&&e.push(`<w:outlineLvl w:val="${t.outlineLevel}"/>`),e.length>0?`<w:pPr>${e.join("")}</w:pPr>`:""}function iE(t,e,a,n){var r,o;const i=[],l=function(t,e){const a=He(t.style,e);return{align:a.align,spacingBefore:a.spacingBefore,spacingAfter:a.spacingAfter,contextualSpacing:a.contextualSpacing,lineHeight:a.lineHeight,lineRule:a.lineRule,indentLeft:a.indentLeft,indentRight:a.indentRight,indentFirstLine:a.indentFirstLine,indentHanging:a.indentHanging,pageBreakBefore:a.pageBreakBefore,keepWithNext:a.keepWithNext,keepLinesTogether:a.keepLinesTogether,widowControl:a.widowControl,shading:a.shading,borderTop:a.borderTop,borderRight:a.borderRight,borderBottom:a.borderBottom,borderLeft:a.borderLeft,tabs:a.tabs,textDirection:a.textDirection,outlineLevel:a.outlineLevel}}(t,a),s=(null==(r=t.style)?void 0:r.align)??(null==n?void 0:n.align)??l.align;if((null==(o=t.style)?void 0:o.styleId)&&i.push(`<w:pStyle w:val="${PV(t.style.styleId)}"/>`),s&&i.push(`<w:jc w:val="${s}"/>`),void 0!==l.spacingBefore||void 0!==l.spacingAfter||void 0!==l.lineHeight){const t=[],e=HV(l.spacingBefore),a=HV(l.spacingAfter),n=void 0!==l.lineHeight&&null!==l.lineHeight&&Number.isFinite(l.lineHeight),r="exact"===l.lineRule||"atLeast"===l.lineRule,o=n?r?WV(l.lineHeight,0):Math.round(240*l.lineHeight):null;null!==e&&t.push(`w:before="${e}"`),null!==a&&t.push(`w:after="${a}"`),null!==o&&t.push(`w:line="${o}"`),null!==o&&r&&t.push(`w:lineRule="${l.lineRule}"`),t.length>0&&i.push(`<w:spacing ${t.join(" ")}/>`)}if(void 0!==l.indentLeft||void 0!==l.indentRight||void 0!==l.indentFirstLine||void 0!==l.indentHanging){const t=[],e=HV(l.indentLeft),a=HV(l.indentRight),n=HV(l.indentFirstLine),r=HV(l.indentHanging);null!==e&&t.push(`w:left="${e}"`),null!==a&&t.push(`w:right="${a}"`),null!==n&&t.push(`w:firstLine="${n}"`),null!==r&&t.push(`w:hanging="${r}"`),t.length>0&&i.push(`<w:ind ${t.join(" ")}/>`)}const d=rE(l.tabs);d&&i.push(d),l.pageBreakBefore&&i.push("<w:pageBreakBefore/>"),l.keepWithNext&&i.push("<w:keepNext/>"),l.keepLinesTogether&&i.push("<w:keepLines/>"),!1===l.widowControl&&i.push('<w:widowControl w:val="0"/>'),l.contextualSpacing&&i.push("<w:contextualSpacing/>");const c=jV(l);c&&i.push(c),l.shading&&i.push(`<w:shd w:val="clear" w:color="auto" w:fill="${FV(l.shading,"FFFFFF")}"/>`),l.textDirection&&i.push(`<w:textDirection w:val="${l.textDirection}"/>`),null!=l.outlineLevel&&i.push(`<w:outlineLvl w:val="${l.outlineLevel}"/>`);const h=e.get(t.id);return h&&i.push(`<w:numPr><w:ilvl w:val="${h.level}"/><w:numId w:val="${h.numId}"/></w:numPr>`),i.length>0?`<w:pPr>${i.join("")}</w:pPr>`:""}const lE={black:[0,0,0],blue:[0,0,255],cyan:[0,255,255],green:[0,128,0],magenta:[255,0,255],red:[255,0,0],yellow:[255,255,0],white:[255,255,255],darkBlue:[0,0,139],darkCyan:[0,139,139],darkGreen:[0,100,0],darkMagenta:[139,0,139],darkRed:[139,0,0],darkYellow:[184,134,11],darkGray:[169,169,169],lightGray:[211,211,211]},sE={ffff00:"yellow",fef08a:"yellow",ff0000:"red","00ff00":"green","0000ff":"blue","00ffff":"cyan",ff00ff:"magenta","000000":"black",ffffff:"white"};function dE(t){if(t in lE)return t;const e=t.trim().replace(/^#/,"").toLowerCase(),a=sE[e];if(a)return a;const n=function(t){const e=t.trim().replace(/^#/,"");return/^[0-9a-fA-F]{6}$/.test(e)?[Number.parseInt(e.slice(0,2),16),Number.parseInt(e.slice(2,4),16),Number.parseInt(e.slice(4,6),16)]:null}(t);if(!n)return"yellow";let r="yellow",o=Number.POSITIVE_INFINITY;for(const[i,l]of Object.entries(lE)){const t=(l[0]-n[0])**2+(l[1]-n[1])**2+(l[2]-n[2])**2;t<o&&(o=t,r=i)}return r}function cE(t){if(!t)return"";const e=[];if(t.bold&&e.push("<w:b/>","<w:bCs/>"),t.italic&&e.push("<w:i/>","<w:iCs/>"),t.underline){const a=t.underlineStyle??"single",n=t.underlineColor?` w:color="${PV(t.underlineColor.replace(/^#/,""))}"`:"";e.push(`<w:u w:val="${PV(a)}"${n}/>`)}if(t.strike&&e.push("<w:strike/>"),t.doubleStrike&&e.push("<w:dstrike/>"),t.smallCaps&&e.push("<w:smallCaps/>"),t.allCaps&&e.push("<w:caps/>"),t.hidden&&e.push("<w:vanish/>"),t.noProof&&e.push("<w:noProof/>"),t.webHidden&&e.push("<w:webHidden/>"),t.specVanish&&e.push("<w:specVanish/>"),t.textEffect&&e.push(`<w:effect w:val="${PV(t.textEffect)}"/>`),void 0!==t.characterScale&&null!==t.characterScale&&Number.isFinite(t.characterScale)&&e.push(`<w:w w:val="${Math.max(1,Math.round(t.characterScale))}"/>`),void 0!==t.characterSpacing&&null!==t.characterSpacing){const n=null!=(a=t.characterSpacing)&&Number.isFinite(a)?Math.round(20*a):null;null!==n&&e.push(`<w:spacing w:val="${n}"/>`)}var a;void 0!==t.baselineShift&&null!==t.baselineShift&&Number.isFinite(t.baselineShift)&&e.push(`<w:position w:val="${Math.round(2*t.baselineShift)}"/>`),void 0!==t.kerningThreshold&&null!==t.kerningThreshold&&Number.isFinite(t.kerningThreshold)&&e.push(`<w:kern w:val="${Math.max(0,Math.round(2*t.kerningThreshold))}"/>`);const n=function(t){switch(t){case"none":return"none";case"standard":return"standard";case"contextual":return"contextual";case"historical":return"historical";case"standardContextual":return"standardContextual";default:return null}}(t.ligatures);n&&e.push(`<w14:ligatures w14:val="${n}"/>`);const r=function(t){switch(t){case"proportional":return"proportional";case"tabular":return"tabular";default:return null}}(t.numberSpacing);r&&e.push(`<w14:numSpacing w14:val="${r}"/>`);const o=function(t){switch(t){case"lining":return"lining";case"oldStyle":return"oldStyle";default:return null}}(t.numberForm);o&&e.push(`<w14:numForm w14:val="${o}"/>`);const i=function(t){return"number"!=typeof t||t<1||t>20?null:(1<<t-1).toString(16).toUpperCase().padStart(8,"0")}(t.stylisticSet);if(i&&e.push(`<w14:stylisticSets w14:val="${i}"/>`),t.contextualAlternates&&e.push('<w14:cntxtAlts w14:val="1"/>'),t.superscript?e.push('<w:vertAlign w:val="superscript"/>'):t.subscript&&e.push('<w:vertAlign w:val="subscript"/>'),t.fontFamily&&e.push(`<w:rFonts w:ascii="${PV(t.fontFamily)}" w:hAnsi="${PV(t.fontFamily)}" w:cs="${PV(t.fontFamily)}"/>`),void 0!==t.fontSize&&null!==t.fontSize){const a=function(t){return null!=t&&Number.isFinite(t)?Math.round(t/Mn*72*2):null}(t.fontSize);null!==a&&e.push(`<w:sz w:val="${a}"/>`,`<w:szCs w:val="${a}"/>`)}if(t.color&&e.push(`<w:color w:val="${PV(t.color.replace(/^#/,""))}"/>`),t.highlight&&e.push(`<w:highlight w:val="${PV(dE(t.highlight))}"/>`),t.shading&&e.push(`<w:shd w:val="clear" w:color="auto" w:fill="${FV(t.shading,"FFFFFF")}"/>`),t.language){const a=[];t.language.value&&a.push(`w:val="${PV(t.language.value)}"`),t.language.eastAsia&&a.push(`w:eastAsia="${PV(t.language.eastAsia)}"`),t.language.bidi&&a.push(`w:bidi="${PV(t.language.bidi)}"`),a.length>0&&e.push(`<w:lang ${a.join(" ")}/>`)}return e.length>0?`<w:rPr>${e.join("")}</w:rPr>`:""}function hE(t){if(0===t.length)return"";var e;return`<w:t${/^\s|\s$/.test(e=t)||e.includes(" ")?' xml:space="preserve"':""}>${PV(t)}</w:t>`}function pE(t){if(0===t.length)return"<w:t></w:t>";let e="",a="";for(const n of t)"\n"!==n?"\t"!==n?"‑"!==n?""!==n?a+=n:(e+=hE(a),a="",e+="<w:softHyphen/>"):(e+=hE(a),a="",e+="<w:noBreakHyphen/>"):(e+=hE(a),a="",e+="<w:tab/>"):(e+=hE(a),a="",e+="<w:br/>");return e+=hE(a),e||"<w:t></w:t>"}function uE(t,e){return t??e?"1":"0"}function fE(t,e,a){const n=PV((null==e?void 0:e.relativeFrom)??a);if(null==e?void 0:e.align)return`<wp:${t} relativeFrom="${n}"><wp:align>${PV(e.align)}</wp:align></wp:${t}>`;return`<wp:${t} relativeFrom="${n}"><wp:posOffset>${(null==e?void 0:e.offset)??0}</wp:posOffset></wp:${t}>`}function gE(t){if(!t||t.length<3)return"";const e=t=>Math.round(21600*Math.min(1,Math.max(0,t))),a=(t,a)=>`<wp:${a} x="${e(t.x)}" y="${e(t.y)}"/>`,n=t[0];return`<wp:wrapPolygon edited="0">${[a(n,"start"),...t.slice(1).map(t=>a(t,"lineTo")),a(n,"lineTo")].join("")}</wp:wrapPolygon>`}function mE(t){const{cx:e,cy:a,floating:n,docPrId:r,docPrName:o,altAttr:i,graphicXml:l}=t,s=PV(o);if(!n)return`<w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${e}" cy="${a}"/><wp:effectExtent l="0" t="0" r="0" b="0"/><wp:docPr id="${r}" name="${s}"${i}/>${l}</wp:inline></w:drawing>`;const d=n.distT??0,c=n.distB??0,h=n.distL??0,p=n.distR??0,u=fE("positionH",n.positionH,"column"),f=fE("positionV",n.positionV,"paragraph"),g=function(t,e){switch(t){case"square":return'<wp:wrapSquare wrapText="bothSides"/>';case"tight":{const t=gE(e);return t?`<wp:wrapTight wrapText="bothSides">${t}</wp:wrapTight>`:'<wp:wrapTight wrapText="bothSides"/>'}case"through":{const t=gE(e);return t?`<wp:wrapThrough wrapText="bothSides">${t}</wp:wrapThrough>`:'<wp:wrapThrough wrapText="bothSides"/>'}case"topAndBottom":return"<wp:wrapTopAndBottom/>";default:return"<wp:wrapNone/>"}}(n.wrap,t.wrapPolygon);return`<w:drawing><wp:anchor distT="${d}" distB="${c}" distL="${h}" distR="${p}" simplePos="${uE(n.simplePos,!1)}" relativeHeight="${n.relativeHeight??0}" behindDoc="${uE(n.behindDoc,!1)}" locked="${uE(n.locked,!1)}" layoutInCell="${uE(n.layoutInCell,!0)}" allowOverlap="${uE(n.allowOverlap,!0)}"><wp:simplePos x="0" y="0"/>${u}${f}<wp:extent cx="${e}" cy="${a}"/><wp:effectExtent l="0" t="0" r="0" b="0"/>${g}<wp:docPr id="${r}" name="${s}"${i}/>${l}</wp:anchor></w:drawing>`}function vE(t,e,a,n){const r=a.images.find(t=>t.rId===e);if(!r)return null;const o=(parseInt(e.replace(/\D+/g,""),10)||0)+1,i=void 0!==r.alt?` descr="${PV(r.alt)}" title="${PV(r.alt)}"`:"",l=function(t){let e="";if(t.rotation){const a=Math.round(6e4*t.rotation);0!==a&&(e+=` rot="${a}"`)}return t.flipH&&(e+=' flipH="1"'),t.flipV&&(e+=' flipV="1"'),e}(r),s=function(t){if(!t)return"";const e=t=>t?Math.round(1e5*t):0,a=e(t.left),n=e(t.top),r=e(t.right),o=e(t.bottom);return 0===a&&0===n&&0===r&&0===o?"":`<a:srcRect l="${a}" t="${n}" r="${r}" b="${o}"/>`}(r.crop),d="tile"===r.fillMode?"<a:tile/>":"<a:stretch><a:fillRect/></a:stretch>",c=function(t,e,a,n){return mE({cx:t.cx,cy:t.cy,floating:t.floating,docPrId:e,docPrName:"Picture",altAttr:a,graphicXml:n,wrapPolygon:t.wrapPolygon})}(r,o,i,`<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:nvPicPr><pic:cNvPr id="0" name="Picture"${i}/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip ${"linked"===r.kind?`r:link="${e}"`:`r:embed="${e}"`} xmlns:r="${qV}"/>${s}${d}</pic:blipFill><pic:spPr><a:xfrm${l}><a:off x="0" y="0"/><a:ext cx="${r.cx}" cy="${r.cy}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData></a:graphic>`);return`<w:r>${n}${c}</w:r>`}function bE(t,e,a,n,r,o){const i=Math.round(e.width*An),l=Math.round(e.height*An),s=a.textBoxDocPrIds.get(t.id)??1,d=e.name??"Text Box",c=void 0!==e.alt?` descr="${PV(e.alt)}" title="${PV(e.alt)}"`:"",h=function(t,e,a,n,r,o){const i=t.shape,l=PV((null==i?void 0:i.preset)??"rect"),s=t.rotation?Math.round(6e4*t.rotation):0,d=0!==s?` rot="${s}"`:"",c=(null==i?void 0:i.fill)?`<a:solidFill><a:srgbClr val="${PV(i.fill.replace(/^#/,""))}"/></a:solidFill>`:"";let h="";((null==i?void 0:i.borderColor)||void 0!==(null==i?void 0:i.borderWidthPt))&&(h=`<a:ln${void 0!==(null==i?void 0:i.borderWidthPt)?` w="${Math.round(12700*i.borderWidthPt)}"`:""}>${(null==i?void 0:i.borderColor)?`<a:solidFill><a:srgbClr val="${PV(i.borderColor.replace(/^#/,""))}"/></a:solidFill>`:""}<a:miter lim="800000"/></a:ln>`);const p=t.body,u=['rot="0"',`vert="${PV((null==p?void 0:p.vert)??"horz")}"`];u.push(`wrap="${PV((null==p?void 0:p.wrap)??"square")}"`),void 0!==(null==p?void 0:p.paddingLeft)&&u.push(`lIns="${Math.round(p.paddingLeft*An)}"`),void 0!==(null==p?void 0:p.paddingTop)&&u.push(`tIns="${Math.round(p.paddingTop*An)}"`),void 0!==(null==p?void 0:p.paddingRight)&&u.push(`rIns="${Math.round(p.paddingRight*An)}"`),void 0!==(null==p?void 0:p.paddingBottom)&&u.push(`bIns="${Math.round(p.paddingBottom*An)}"`),u.push(`anchor="${PV((null==p?void 0:p.anchor)??"t")}"`),u.push('anchorCtr="0"');const f=(null==p?void 0:p.autoFit)?"<a:spAutoFit/>":"",g=t.blocks.length>0,m=g?o(t.blocks,n,r):"";return'<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"><wps:wsp>'+(g?'<wps:cNvSpPr txBox="1"><a:spLocks noChangeArrowheads="1"/></wps:cNvSpPr>':"<wps:cNvSpPr/>")+`<wps:spPr bwMode="auto"><a:xfrm${d}><a:off x="0" y="0"/><a:ext cx="${e}" cy="${a}"/></a:xfrm><a:prstGeom prst="${l}"><a:avLst/></a:prstGeom>`+c+h+"</wps:spPr>"+(g?`<wps:txbx><w:txbxContent>${m}</w:txbxContent></wps:txbx>`:"")+`<wps:bodyPr ${u.join(" ")}>${f}</wps:bodyPr></wps:wsp></a:graphicData></a:graphic>`}(e,i,l,a,n,o);return`<w:r>${r}${mE({cx:i,cy:l,floating:e.floating,docPrId:s,docPrName:d,altAttr:c,graphicXml:h})}</w:r>`}const yE={footnote:"FootnoteReference",endnote:"EndnoteReference"};function ME(t){return`<w:r><w:rPr><w:rStyle w:val="${yE[t]}"/><w:vertAlign w:val="superscript"/></w:rPr><w:${t}Ref/></w:r>`}function xE(t,e,a,n){if(!e)return null;const r="footnote"===t?n.footnoteIdMap:n.endnoteIdMap,o=null==r?void 0:r.get(e.noteId);if(void 0===o)return null;const i={...a??{},superscript:!0},l=e.customMark?' w:customMarkFollows="1"':"",s=e.customMark?`<w:t xml:space="preserve">${PV(e.customMark)}</w:t>`:"";return`<w:r>${cE(i)}<w:${t}Reference${l} w:id="${o}"/>${s}</w:r>`}function wE(t,e,a,n,r){if(t.__isFootnoteRefMarker)return ME("footnote");if(t.__isEndnoteRefMarker)return ME("endnote");const o=function(t,e,a){var n;const r=We(t.styles,e,a),o={bold:r.bold,italic:r.italic,underline:r.underline,underlineStyle:r.underlineStyle,underlineColor:r.underlineColor,strike:r.strike,doubleStrike:r.doubleStrike,superscript:r.superscript,subscript:r.subscript,smallCaps:r.smallCaps,allCaps:r.allCaps,hidden:r.hidden,noProof:r.noProof,webHidden:r.webHidden,specVanish:r.specVanish,textEffect:r.textEffect,characterScale:r.characterScale,characterSpacing:r.characterSpacing,baselineShift:r.baselineShift,kerningThreshold:r.kerningThreshold,ligatures:r.ligatures,numberSpacing:r.numberSpacing,numberForm:r.numberForm,stylisticSet:r.stylisticSet,contextualAlternates:r.contextualAlternates,fontFamily:r.fontFamily,fontSize:r.fontSize,color:r.color,highlight:r.highlight,shading:r.shading,language:r.language};return(null==(n=t.styles)?void 0:n.link)&&(o.link=t.styles.link),o}(t,a,n);if(t.footnoteReference){const a=function(t,e,a){const n=t.footnoteReference;return xE("footnote",n?{noteId:n.footnoteId,customMark:n.customMark}:void 0,e,a)}(t,o,e);if(null!==a)return a}if(t.endnoteReference){const a=function(t,e,a){const n=t.endnoteReference;return xE("endnote",n?{noteId:n.endnoteId,customMark:n.customMark}:void 0,e,a)}(t,o,e);if(null!==a)return a}if(t.fieldChar)return function(t,e){const a=(t.fieldLock?' w:fldLock="true"':"")+(t.dirty?' w:dirty="true"':"");return`<w:r>${e}<w:fldChar w:fldCharType="${t.kind}"${a}/></w:r>`}(t.fieldChar,cE(o));if(void 0!==t.fieldInstruction)return i=t.fieldInstruction,`<w:r>${cE(o)}<w:instrText xml:space="preserve">${PV(i)}</w:instrText></w:r>`;var i;if(t.field)return function(t,e){return`<w:fldSimple w:instr="${"PAGE"===t?" PAGE ":" NUMPAGES "}"><w:r>${e}<w:t>1</w:t></w:r></w:fldSimple>`}(t.field.type,cE(o));if(t.textBox)return bE(t,t.textBox,e,n,cE(o),r);if(t.image){const a=e.imageMap.get(t.id);if(a){const n=vE(t.id,a,e,cE(o));if(null!==n)return n}}if(t.sym){const{font:e,char:a}=t.sym;return`<w:r>${cE(o)}<w:sym w:font="${PV(e)}" w:char="${a}"/></w:r>`}return`<w:r>${cE(o)}${pE(t.text)}</w:r>`}function SE(t,e,a,n,r){var o;const i=wE(t,e,a,n,r),l=null==(o=t.styles)?void 0:o.link;return l?function(t,e,a){if(e.startsWith("#"))return`<w:hyperlink w:anchor="${PV(e.slice(1))}">${t}</w:hyperlink>`;const n=a.hyperlinkMap.get(e);return n?`<w:hyperlink r:id="${n}">${t}</w:hyperlink>`:t}(i,l,e):i}function AE(t){return!(t.image||t.textBox||t.field||t.fieldChar||void 0!==t.fieldInstruction||t.footnoteReference||t.endnoteReference)}function IE(t,e,a){return t.map(t=>{var n;switch(t.type){case"paragraph":return TE(t,e,a);case"table":return((null==(n=t.style)?void 0:n.pageBreakBefore)?'<w:p><w:r><w:br w:type="page"/></w:r></w:p>':"")+nE(t,(t,n)=>{var r;return TE(t,e,a,{align:null==(r=n.style)?void 0:r.horizontalAlign})});default:return pe(t,"block")}}).join("")}function TE(t,e,a,n){var r,o,i;const l=t.runs.length>0?t.runs:[{id:"",text:""}],s=t.dropCap?function(t){const e=cE(t.style);var a;return`<w:p><w:pPr><w:keepNext/><w:framePr w:dropCap="${t.type}" w:lines="${t.lines}" w:wrap="around" w:vAnchor="text" w:hAnchor="text"/><w:spacing w:after="0"/>${e?`<w:rPr>${a=e,a.replace(/^<w:rPr>/,"").replace(/<\/w:rPr>$/,"")}</w:rPr>`:""}</w:pPr><w:r>${e}${pE(t.text)}</w:r></w:p>`}(t.dropCap):"",d=null==(r=e.bookmarkEventsByParagraph)?void 0:r.get(t.id),c=null==(o=e.commentEventsByParagraph)?void 0:o.get(t.id),h=[...(d??[]).map(t=>({offset:t.offset,seq:t.seq,xml:BV(t)})),...(c??[]).map(t=>({offset:t.offset,seq:t.seq,xml:GV(t)}))],p=h.length>0?function(t,e,a,n,r){const o=[...e].sort((t,e)=>t.offset-e.offset||t.seq-e.seq);let i=0,l=0,s="";const d=t=>{for(;i<o.length&&o[i].offset<=t;)s+=o[i].xml,i+=1};for(const c of t){const t=l,e=t+c.text.length;if(d(t),AE(c)&&c.text.length>0){let l=t;for(;i<o.length&&o[i].offset<e;){const e=o[i];e.offset>l&&(s+=SE({...c,text:c.text.slice(l-t,e.offset-t)},a,n,r,IE)),s+=e.xml,i+=1,l=e.offset}l<e&&(s+=SE({...c,text:c.text.slice(l-t)},a,n,r,IE))}else s+=SE(c,a,n,r,IE);l=e}return d(Number.POSITIVE_INFINITY),s}(l,h,e,null==(i=t.style)?void 0:i.styleId,a):l.map(n=>{var r;return SE(n,e,null==(r=t.style)?void 0:r.styleId,a,IE)}).join("");return`${s}<w:p>${iE(t,e.numberingInfo,a,n)}${p}</w:p>`}function CE(t){if(0===t.length)return[kE()];const[e,...a]=t;return"paragraph"!==e.type?[kE(!0),e,...a]:[(n=e,{...n,runs:[{id:"synthetic:footnoteRef",text:"",styles:{styleId:"FootnoteReference",superscript:!0},__isFootnoteRefMarker:!0},...n.runs],style:(null==(r=n.style)?void 0:r.styleId)?n.style:{...n.style??{},styleId:"FootnoteText"}}),...a];var n,r}function kE(t=!0){return{id:"synthetic:footnote-body-empty",type:"paragraph",runs:[...t?[{id:"synthetic:footnoteRef",text:"",styles:{styleId:"FootnoteReference",superscript:!0},__isFootnoteRefMarker:!0}]:[],{id:"synthetic:footnote-body-empty-text",text:""}],style:{styleId:"FootnoteText"}}}function VE(t){if(0===t.length)return[EE()];const[e,...a]=t;return"paragraph"!==e.type?[EE(!0),e,...a]:[(n=e,{...n,runs:[{id:"synthetic:endnoteRef",text:"",styles:{styleId:"EndnoteReference",superscript:!0},__isEndnoteRefMarker:!0},...n.runs],style:(null==(r=n.style)?void 0:r.styleId)?n.style:{...n.style??{},styleId:"EndnoteText"}}),...a];var n,r}function EE(t=!0){return{id:"synthetic:endnote-body-empty",type:"paragraph",runs:[...t?[{id:"synthetic:endnoteRef",text:"",styles:{styleId:"EndnoteReference",superscript:!0},__isEndnoteRefMarker:!0}]:[],{id:"synthetic:endnote-body-empty-text",text:""}],style:{styleId:"EndnoteText"}}}const RE=["wholeTable","band1Horz","band2Horz","band1Vert","band2Vert","firstCol","lastCol","firstRow","lastRow","nwCell","neCell","swCell","seCell"];function LE(t,e){const a=[],n=e.paragraphStyle?oE(e.paragraphStyle):"";n&&a.push(n);const r=e.textStyle?cE(e.textStyle):"";r&&a.push(r);const o=e.rowStyle?function(t){var e;if(!t)return"";const a=[],n=$V("gridBefore",t.gridBefore);n&&a.push(n);const r=$V("gridAfter",t.gridAfter);r&&a.push(r);const o=YV("wBefore",t.widthBefore);o&&a.push(o);const i=YV("wAfter",t.widthAfter);i&&a.push(i);const l=YV("tblCellSpacing",t.cellSpacing);l&&a.push(l);const s=tE(t.height,t.heightRule);s&&a.push(s);const d=JV("cantSplit",t.cantSplit);d&&a.push(d);const c=JV("hidden",t.hidden);return c&&a.push(c),(null==(e=t.revisionXml)?void 0:e.length)&&a.push(...t.revisionXml),a.length>0?`<w:trPr>${a.join("")}</w:trPr>`:""}(e.rowStyle):"";o&&a.push(o);const i=function(t){const e=[];if(t.borders){const a=t.borders,n=[["top",a.borderTop],["left",a.borderLeft],["bottom",a.borderBottom],["right",a.borderRight]].filter(t=>null!=t[1]).map(([t,e])=>`<w:${t} ${KV(e)}`).join("");n&&e.push(`<w:tcBorders>${n}</w:tcBorders>`)}return t.shading&&e.push(`<w:shd w:val="clear" w:color="auto" w:fill="${FV(t.shading,"FFFFFF")}"/>`),e.length>0?`<w:tcPr>${e.join("")}</w:tcPr>`:""}(e);return i&&a.push(i),0===a.length?"":`<w:tblStylePr w:type="${PV(t)}">${a.join("")}</w:tblStylePr>`}function zE(t){const e=[];if(e.push(`<w:name w:val="${PV(t.name)}"/>`),t.basedOn&&e.push(`<w:basedOn w:val="${PV(t.basedOn)}"/>`),t.nextStyle&&e.push(`<w:next w:val="${PV(t.nextStyle)}"/>`),("paragraph"===t.type||"table"===t.type)&&t.paragraphStyle){const a=oE(t.paragraphStyle);a&&e.push(a)}if(t.textStyle){const a=cE(t.textStyle);a&&e.push(a)}if("table"===t.type&&t.tableStyle){const a=t.tableStyle,n=[];if(void 0!==a.rowBandSize&&n.push(`<w:tblStyleRowBandSize w:val="${a.rowBandSize}"/>`),void 0!==a.colBandSize&&n.push(`<w:tblStyleColBandSize w:val="${a.colBandSize}"/>`),void 0!==a.indentLeft){const t="number"==typeof a.indentLeft?UV(a.indentLeft):null;null!==t&&n.push(`<w:tblInd w:w="${t}" w:type="dxa"/>`)}if(n.length>0&&e.push(`<w:tblPr>${n.join("")}</w:tblPr>`),a.conditionalFormats){const t=[...RE.filter(t=>t in a.conditionalFormats),...Object.keys(a.conditionalFormats).filter(t=>!RE.includes(t))];for(const n of t){const t=a.conditionalFormats[n];if(t){const a=LE(n,t);a&&e.push(a)}}}}return`<w:style w:type="${"character"===t.type?"character":"table"===t.type?"table":"paragraph"}" w:styleId="${PV(t.id)}">${e.join("")}</w:style>`}function NE(t,e,a,n,r,o,i,l){const s=n.map(t=>{const e="header"===t.kind?"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml":"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml";return`<Override PartName="/word/${t.path}" ContentType="${e}"/>`}).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/>${function(t){const e=new Set;let a="";for(const n of t){const t=n.toLowerCase();if(e.has(t))continue;const r=Uv[t];r&&(e.add(t),a+=`<Default Extension="${t}" ContentType="${r}"/>`)}return a}(e)}<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>${i?'<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>':""}${t?'<Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/>':""}${a?'<Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/>':""}${r?'<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"/>':""}${o?'<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"/>':""}${l?'<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"/><Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml"/>':""}${s}</Types>`}const qE={decimal:"decimal",lowerRoman:"lowerRoman",upperRoman:"upperRoman",lowerLetter:"lowerLetter",upperLetter:"upperLetter",symbol:"symbol"},OE={continuous:"continuous",eachSection:"eachSect"};function PE(t,e){if(!e)return null;const a=[];return e.numberFormat&&a.push(`<w:numFmt w:val="${qE[e.numberFormat]}"/>`),void 0!==e.startAt&&a.push(`<w:numStart w:val="${Math.max(1,e.startAt)}"/>`),e.restart&&a.push(`<w:numRestart w:val="${OE[e.restart]}"/>`),a.length>0?`<w:${t}>${a.join("")}</w:${t}>`:null}function WE(t,e){let a="";for(const n of e)a+=`<Relationship Id="${n.rId}" Type="${qV}/hyperlink" Target="${PV(n.href)}" TargetMode="External"/>`;for(const n of t){const t="linked"===n.kind?' TargetMode="External"':"";a+=`<Relationship Id="${n.rId}" Type="${qV}/image" Target="${PV(n.target)}"${t}/>`}return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${NV}">${a}</Relationships>`}function HE(t,e){e(t);for(const a of t.runs)a.textBox&&UE(a.textBox.blocks,e)}function UE(t,e){for(const a of t)switch(a.type){case"paragraph":HE(a,e);break;case"table":for(const t of a.rows)for(const a of t.cells)for(const t of a.blocks)HE(t,e);break;default:pe(a,"block")}}const FE=`xmlns:w="${zV}" xmlns:w14="${OV}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:r="${qV}"`;function BE(t,e,a){const n=Be(t).map((n,r)=>IE(n.blocks,e,t.styles)+function(t,e){var a,n,r,o,i,l,s,d,c;const h=WV(t.width,12240),p=WV(t.height,15840),u=t.margins,f="landscape"===t.orientation?' w:orient="landscape"':"",g=[(null==(a=null==e?void 0:e.header)?void 0:a.first)?`<w:headerReference w:type="first" r:id="${e.header.first.relId}"/>`:"",(null==(n=null==e?void 0:e.header)?void 0:n.even)?`<w:headerReference w:type="even" r:id="${e.header.even.relId}"/>`:"",(null==(r=null==e?void 0:e.header)?void 0:r.default)?`<w:headerReference w:type="default" r:id="${e.header.default.relId}"/>`:"",(null==(o=null==e?void 0:e.footer)?void 0:o.first)?`<w:footerReference w:type="first" r:id="${e.footer.first.relId}"/>`:"",(null==(i=null==e?void 0:e.footer)?void 0:i.even)?`<w:footerReference w:type="even" r:id="${e.footer.even.relId}"/>`:"",(null==(l=null==e?void 0:e.footer)?void 0:l.default)?`<w:footerReference w:type="default" r:id="${e.footer.default.relId}"/>`:""].join(""),m=(null==(s=null==e?void 0:e.header)?void 0:s.first)||(null==(d=null==e?void 0:e.footer)?void 0:d.first)?"<w:titlePg/>":"",v=t.columns;let b="";if(v&&v.count>1){const t=WV(v.space,0),e=v.separator?' w:sep="1"':"";if(!1===v.equalWidth&&(null==(c=v.columns)?void 0:c.length)){const a=v.columns.map(t=>`<w:col w:w="${WV(t.width,0)}" w:space="${WV(t.space,0)}"/>`).join("");b=`<w:cols w:num="${v.count}" w:space="${t}" w:equalWidth="0"${e}>${a}</w:cols>`}else b=`<w:cols w:num="${v.count}" w:space="${t}"${e}/>`}return`<w:sectPr>${g}${m}<w:pgSz w:w="${h}" w:h="${p}"${f}/><w:pgMar w:top="${WV(u.top,1440)}" w:right="${WV(u.right,1440)}" w:bottom="${WV(u.bottom,1440)}" w:left="${WV(u.left,1440)}" w:header="${WV(u.header,720)}" w:footer="${WV(u.footer,720)}" w:gutter="${WV(u.gutter,0)}"/>${b}</w:sectPr>`}(n.pageSettings,a[r])).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document ${FE}><w:body>${n}</w:body></w:document>`}function GE(t,e,a,n){const r="header"===t?"hdr":"ftr";return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:${r} ${FE}>${IE(e,a,n)}</w:${r}>`}function ZE(t){const e=xa("");return e.fieldChar={kind:t},e}function DE(t){const e=xa("");return e.fieldInstruction=t,e}function KE(t,e,a){const n=Aa([{text:`${e} `},{text:String(a)},{text:t?`: ${t}`:""}]);return n.style={styleId:"Caption",align:"center"},n.runs=[n.runs[0],ZE("begin"),DE(" SEQ Figure \\* ARABIC "),ZE("separate"),n.runs[1],ZE("end"),n.runs[2]],n}function jE(t){var e,a;if(!t)return!1;return"caption"===(null==(a=null==(e=t.style)?void 0:e.styleId)?void 0:a.toLowerCase())&&t.runs.some(t=>void 0!==t.fieldInstruction&&new RegExp("\\bSEQ\\s+Figure\\b","i").test(t.fieldInstruction))}function XE(t,e){if(!jE(t))return TT(t);let a=!1,n=!1;const r=t.runs.map(t=>{var r,o;return"separate"===(null==(r=t.fieldChar)?void 0:r.kind)?(a=!0,{...t,fieldChar:{...t.fieldChar}}):"end"===(null==(o=t.fieldChar)?void 0:o.kind)?(a=!1,{...t,fieldChar:{...t.fieldChar}}):a&&""!==t.text?t.text===String(e)?{...t}:(n=!0,{...t,text:String(e)}):{...t}});return n?{...TT(t),runs:r}:TT(t)}function JE(t,e){return t.map(t=>{switch(t.type){case"paragraph":return jE(t)?XE(t,e.next++):TT(t);case"table":return{...t,rows:t.rows.map(t=>({...t,cells:t.cells.map(t=>({...t,blocks:JE(t.blocks,e)}))}))};default:return pe(t,"block")}})}function YE(t){const e={next:1},a=Be(t).map(t=>({...t,blocks:JE(t.blocks,e),header:t.header?VT(t.header):void 0,footer:t.footer?VT(t.footer):void 0}));return{...t,sections:a}}function QE(t,e,a,n){const r=[],o=new Map,i=new Map,l=[],s=new Map;return UE(t,t=>{var e;for(const d of t.runs){const t=null==(e=d.styles)?void 0:e.link;if(t&&!t.startsWith("#")&&!s.has(t)){const e=`rIdLink${l.length+1}`;s.set(t,e),l.push({rId:e,href:t})}if(d.textBox&&!i.has(d.id)&&(i.set(d.id,a.nextTextBoxDocPrId),a.nextTextBoxDocPrId+=1),!d.image)continue;const c=a.nextImageId,h=`rIdImg${c}`,p={rId:h,runId:d.id,cx:Math.round(d.image.width*An),cy:Math.round(d.image.height*An),alt:d.image.alt,crop:d.image.crop,fillMode:d.image.fillMode,rotation:d.image.rotation,flipH:d.image.flipH,flipV:d.image.flipV,floating:d.image.floating,wrapPolygon:d.image.wrapPolygon};if(d.image.linkedSrc){r.push({...p,kind:"linked",target:d.image.linkedSrc}),o.set(d.id,h),a.nextImageId+=1;continue}const u=Ue(n,d.image.src).match(/^data:([^;,]+);base64,(.*)$/);if(!u)continue;const f=Bv(u[1]);if(!f)continue;const g=u[2],m=`media/image${c}.${f}`;r.push({...p,kind:"embedded",target:m,base64:g}),o.set(d.id,h),a.nextImageId+=1}}),{numberingInfo:e.numberingInfo,definitions:e.definitions,images:r,imageMap:o,textBoxDocPrIds:i,hyperlinks:l,hyperlinkMap:s}}async function _E(t){var e,a,n,r,o,i;t=YE(t);const l=new Wp,s=function(t){const e=new Map,a=new Map,n=[];let r=1,o=1;const i=t=>{if(!t.list)return;const i=Math.max(0,t.list.level??0),l=t.list.bulletGlyph??"",s=t.list.instanceId?`instance:${t.list.instanceId}`:`legacy:${t.list.kind}:${i}:${l}`;let d=a.get(s);d||(d={abstractNumId:r++,numId:o++,levels:[]},a.set(s,d),n.push(d)),d.levels.some(t=>t.level===i)||d.levels.push({kind:t.list.kind,level:i,format:t.list.format,startAt:t.list.startAt,levelText:t.list.levelText,suffix:t.list.suffix,alignment:t.list.alignment,legal:t.list.legal,bulletGlyph:t.list.bulletGlyph,bulletFont:t.list.bulletFont}),e.set(t.id,{numId:d.numId,level:i})};for(const l of Be(t))UE(l.blocks,i),l.header&&UE(l.header,i),l.firstPageHeader&&UE(l.firstPageHeader,i),l.evenPageHeader&&UE(l.evenPageHeader,i),l.footer&&UE(l.footer,i),l.firstPageFooter&&UE(l.firstPageFooter,i),l.evenPageFooter&&UE(l.evenPageFooter,i);return{numberingInfo:e,definitions:n}}(t),d={nextImageId:1,nextTextBoxDocPrId:1000001},c=Be(t),h=function(t){var e;const a=null==(e=t.footnotes)?void 0:e.items;if(!a)return[];const n=new Map;let r=1;for(const{run:o}of Gl(t)){const t=o.footnoteReference;if(!t)continue;if(n.has(t.footnoteId))continue;const e=a[t.footnoteId];e&&(n.set(t.footnoteId,{footnoteId:t.footnoteId,docxId:r,footnote:e}),r+=1)}return Array.from(n.values())}(t),p=function(t){const e=new Map;for(const a of t)e.set(a.footnoteId,a.docxId);return e}(h),u=h.length>0,f=function(t){var e;const a=null==(e=t.endnotes)?void 0:e.items;if(!a)return[];const n=new Map;let r=1;for(const{run:o}of _l(t)){const t=o.endnoteReference;if(!t)continue;if(n.has(t.endnoteId))continue;const e=a[t.endnoteId];e&&(n.set(t.endnoteId,{endnoteId:t.endnoteId,docxId:r,endnote:e}),r+=1)}return Array.from(n.values())}(t),g=function(t){const e=new Map;for(const a of t)e.set(a.endnoteId,a.docxId);return e}(f),m=f.length>0,v=QE(c.flatMap(t=>t.blocks),s,d,t);v.footnoteIdMap=p,v.endnoteIdMap=g;const b=function(t){const e=t.bookmarks;if(!e||0===e.order.length)return;const a=new Map,n=new Set;for(const l of e.order){const t=e.items[l];if(!t)continue;const r=t.docxIdHint;void 0!==r&&r>=0&&!n.has(r)&&(a.set(l,r),n.add(r))}let r=0;for(const l of e.order)if(!a.has(l)){for(;n.has(r);)r+=1;a.set(l,r),n.add(r),r+=1}const o=new Map,i=(t,e)=>{const a=o.get(t);a?a.push(e):o.set(t,[e])};for(const l of e.order){const t=e.items[l];if(!t)continue;const n=a.get(l);t.start&&i(t.start.paragraphId,{kind:"start",offset:t.start.offset,seq:t.start.seq??0,wId:n,name:t.name,...void 0!==t.colFirst?{colFirst:t.colFirst}:{},...void 0!==t.colLast?{colLast:t.colLast}:{}}),t.end&&i(t.end.paragraphId,{kind:"end",offset:t.end.offset,seq:t.end.seq??0,wId:n})}return o}(t);v.bookmarkEventsByParagraph=b;const y=function(t){const e=t.comments;if(!e||0===e.order.length)return;const a=new Map,n=new Set;for(const s of e.order){const t=e.items[s];if(!t)continue;const r=t.docxIdHint;void 0!==r&&r>=0&&!n.has(r)&&(a.set(s,r),n.add(r))}let r=0;for(const s of e.order)if(!a.has(s)){for(;n.has(r);)r+=1;a.set(s,r),n.add(r),r+=1}const o=new Map,i=(t,e)=>{const a=o.get(t);a?a.push(e):o.set(t,[e])},l=[];return e.order.forEach((t,n)=>{const r=e.items[t];if(!r)return;const o=a.get(t),s=(1073741824+n).toString(16).toUpperCase();l.push({comment:r,wId:o,paraId:s}),r.start&&i(r.start.paragraphId,{kind:"start",offset:r.start.offset,seq:r.start.seq??0,wId:o}),r.end&&(i(r.end.paragraphId,{kind:"end",offset:r.end.offset,seq:r.end.seq??0,wId:o}),i(r.end.paragraphId,{kind:"reference",offset:r.end.offset,seq:(r.end.seq??0)+.5,wId:o}))}),{eventsByParagraph:o,comments:l}}(t);v.commentEventsByParagraph=null==y?void 0:y.eventsByParagraph;const M=void 0!==y,x=[],w=c.map(()=>({}));let S=1,A=1;c.forEach((e,a)=>{const n=(e,n,r)=>{var o;if(!r||0===r.length)return;const i="header"===e?S:A,l=`${e}${i}.xml`,c=`rId${"header"===e?"Header":"Footer"}${i}`,h=QE(r,s,d,t);h.footnoteIdMap=p,h.endnoteIdMap=g,h.bookmarkEventsByParagraph=b,h.commentEventsByParagraph=null==y?void 0:y.eventsByParagraph,x.push({kind:e,type:n,path:l,relId:c,blocks:r,context:h});const u="header"===e?"header":"footer";((o=w[a])[u]??(o[u]={}))[n]={relId:c},"header"===e?S+=1:A+=1};n("header","first",e.firstPageHeader),n("header","even",e.evenPageHeader),n("header","default",e.header),n("footer","first",e.firstPageFooter),n("footer","even",e.evenPageFooter),n("footer","default",e.footer)});const I=s.definitions.length>0,T=c.some(t=>{var e,a;return((null==(e=t.evenPageHeader)?void 0:e.length)??0)>0||((null==(a=t.evenPageFooter)?void 0:a.length)??0)>0}),C=T||void 0!==(null==(e=t.settings)?void 0:e.defaultTabStop)||void 0!==(null==(a=t.footnotes)?void 0:a.settings)||void 0!==(null==(n=t.endnotes)?void 0:n.settings),k=[...v.images,...x.flatMap(t=>t.context.images)],V=u?function(t,e,a,n,r,o,i){const l=r(e.flatMap(t=>CE(t.footnote.blocks)));l.footnoteIdMap=i;const s=e.map(t=>{const e=CE(t.footnote.blocks).map(t=>"paragraph"===t.type?TE(t,l,o):nE(t,(t,e)=>{var a;return TE(t,l,o,{align:null==(a=e.style)?void 0:a.horizontalAlign})})).join("");return`<w:footnote w:id="${t.docxId}">${e}</w:footnote>`}).join("");return{xml:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:footnotes xmlns:w="${zV}" xmlns:w14="${OV}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:r="${qV}"><w:footnote w:type="separator" w:id="-1"><w:p><w:r><w:separator/></w:r></w:p></w:footnote><w:footnote w:type="continuationSeparator" w:id="0"><w:p><w:r><w:continuationSeparator/></w:r></w:p></w:footnote>${s}</w:footnotes>`,partContext:l}}(0,h,0,0,e=>QE(e,s,d,t),t.styles,p):null;V&&k.push(...V.partContext.images);const E=m?function(t,e,a,n,r,o,i){const l=r(e.flatMap(t=>VE(t.endnote.blocks)));l.endnoteIdMap=i;const s=e.map(t=>{const e=VE(t.endnote.blocks).map(t=>"paragraph"===t.type?TE(t,l,o):nE(t,(t,e)=>{var a;return TE(t,l,o,{align:null==(a=e.style)?void 0:a.horizontalAlign})})).join("");return`<w:endnote w:id="${t.docxId}">${e}</w:endnote>`}).join("");return{xml:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:endnotes xmlns:w="${zV}" xmlns:w14="${OV}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:r="${qV}"><w:endnote w:type="separator" w:id="-1"><w:p><w:r><w:separator/></w:r></w:p></w:endnote><w:endnote w:type="continuationSeparator" w:id="0"><w:p><w:r><w:continuationSeparator/></w:r></w:p></w:endnote>${s}</w:endnotes>`,partContext:l}}(0,f,0,0,e=>QE(e,s,d,t),t.styles,g):null;E&&k.push(...E.partContext.images);const R=k.filter(t=>"embedded"===t.kind).map(t=>{var e;return null==(e=t.target.split(".").pop())?void 0:e.toLowerCase()}).filter(t=>Boolean(t)),L=null!=t.styles&&Object.keys(t.styles).length>0;l.file("[Content_Types].xml",NE(I,R,C,x,u,m,L,M)),l.file("_rels/.rels",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${NV}"><Relationship Id="rId1" Type="${qV}/officeDocument" Target="word/document.xml"/></Relationships>`),l.file("word/document.xml",BE(t,v,w)),L&&l.file("word/styles.xml",function(t){const e=Object.values(t).map(zE).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="${OV}">${e}</w:styles>`}(t.styles)),I&&l.file("word/numbering.xml",function(t){const e=t.map(({abstractNumId:t,levels:e})=>`<w:abstractNum w:abstractNumId="${t}">${e.sort((t,e)=>t.level-e.level).map(({kind:t,level:e,format:a,startAt:n,levelText:r,suffix:o,alignment:i,legal:l,bulletGlyph:s,bulletFont:d})=>{const c="bullet"===t?"bullet":a??"decimal",h=r??("bullet"===t?s??"":`%${e+1}.`),p=n??1,u="bullet"===t?d??"Symbol":void 0,f=u?`<w:rPr><w:rFonts w:ascii="${PV(u)}" w:hAnsi="${PV(u)}" w:hint="default"/></w:rPr>`:"",g=o&&"tab"!==o?`<w:suff w:val="${o}"/>`:"",m=l?"<w:isLgl/>":"";return`<w:lvl w:ilvl="${e}"><w:start w:val="${p}"/><w:numFmt w:val="${c}"/><w:lvlText w:val="${PV(h)}"/><w:lvlJc w:val="${i??"left"}"/>${g}${m}${f}</w:lvl>`}).join("")}</w:abstractNum>`).join(""),a=t.map(({abstractNumId:t,numId:e})=>`<w:num w:numId="${e}"><w:abstractNumId w:val="${t}"/></w:num>`).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:numbering xmlns:w="${zV}">${e}${a}</w:numbering>`}(s.definitions)),(L||I||C||v.images.length>0||v.hyperlinks.length>0||x.length>0||u||m||M)&&l.file("word/_rels/document.xml.rels",function(t,e,a,n,r,o,i,l,s){let d="";l&&(d+=`<Relationship Id="rIdStyles" Type="${qV}/styles" Target="styles.xml"/>`),t&&(d+=`<Relationship Id="rIdNum" Type="${qV}/numbering" Target="numbering.xml"/>`),e&&(d+=`<Relationship Id="rIdSettings" Type="${qV}/settings" Target="settings.xml"/>`);for(const c of n)d+=`<Relationship Id="${c.rId}" Type="${qV}/hyperlink" Target="${PV(c.href)}" TargetMode="External"/>`;for(const c of a){const t="linked"===c.kind?' TargetMode="External"':"";d+=`<Relationship Id="${c.rId}" Type="${qV}/image" Target="${PV(c.target)}"${t}/>`}for(const c of r){const t="header"===c.kind?"header":"footer";d+=`<Relationship Id="${c.relId}" Type="${qV}/${t}" Target="${c.path}"/>`}return o&&(d+=`<Relationship Id="rIdFootnotes" Type="${qV}/footnotes" Target="footnotes.xml"/>`),i&&(d+=`<Relationship Id="rIdEndnotes" Type="${qV}/endnotes" Target="endnotes.xml"/>`),s&&(d+=`<Relationship Id="rIdComments" Type="${qV}/comments" Target="comments.xml"/>`,d+='<Relationship Id="rIdCommentsExtended" Type="http://schemas.microsoft.com/office/2011/relationships/commentsExtended" Target="commentsExtended.xml"/>'),`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${NV}">${d}</Relationships>`}(I,C,v.images,v.hyperlinks,x,u,m,L,M)),C&&l.file("word/settings.xml",function(t,e,a,n){const r=[],o=UV(e);null!==o&&r.push(`<w:defaultTabStop w:val="${o}"/>`);const i=PE("footnotePr",a);i&&r.push(i);const l=PE("endnotePr",n);return l&&r.push(l),t&&r.push("<w:evenAndOddHeaders/>"),`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:settings xmlns:w="${zV}">${r.join("")}</w:settings>`}(T,null==(r=t.settings)?void 0:r.defaultTabStop,null==(o=t.footnotes)?void 0:o.settings,null==(i=t.endnotes)?void 0:i.settings));for(const z of x)l.file(`word/${z.path}`,GE(z.kind,z.blocks,z.context,t.styles)),(z.context.images.length>0||z.context.hyperlinks.length>0)&&l.file(`word/_rels/${z.path}.rels`,WE(z.context.images,z.context.hyperlinks));V&&(l.file("word/footnotes.xml",V.xml),(V.partContext.images.length>0||V.partContext.hyperlinks.length>0)&&l.file("word/_rels/footnotes.xml.rels",WE(V.partContext.images,V.partContext.hyperlinks))),E&&(l.file("word/endnotes.xml",E.xml),(E.partContext.images.length>0||E.partContext.hyperlinks.length>0)&&l.file("word/_rels/endnotes.xml.rels",WE(E.partContext.images,E.partContext.hyperlinks))),y&&(l.file("word/comments.xml",DV(y)),l.file("word/commentsExtended.xml",function(t){const e=t.comments.map(({comment:t,paraId:e})=>`<w15:commentEx w15:paraId="${e}" w15:done="${t.resolved?"1":"0"}"/>`).join("");return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w15:commentsEx ${ZV}>${e}</w15:commentsEx>`}(y)));for(const z of k)"embedded"===z.kind&&z.base64&&l.file(`word/${z.target}`,z.base64,{base64:!0});return l.generateAsync({type:"arraybuffer"})}function $E(t){switch(t){case"dashed":return[bM(5),bM(3)];case"dotted":return[bM(1),bM(3)];default:return}}async function tR(t,e,a,n,r,o,i,l){const s=e.rotation;s&&(t.saveGraphicsState(a.pageIndex),t.rotateAbout(a.pageIndex,bM(n+o/2),bM(r+i/2),s)),function(t,e,a,n,r,o,i){var l,s,d,c;const h=nh(null==(l=a.shape)?void 0:l.preset,bM(n),bM(r),bM(o),bM(i)),p=null==(s=a.shape)?void 0:s.fill,u=null==(d=a.shape)?void 0:d.borderColor,f=(null==(c=a.shape)?void 0:c.borderWidthPt)??(u?.75:0);t.drawPath(e,{segments:h,fill:p,stroke:u&&f>0?u:void 0,lineWidth:f})}(t,a.pageIndex,e,n,r,o,i),await async function(t,e,a,n,r,o,i,l){var s;if(0===e.blocks.length)return;const d=function(t){var e,a,n,r;return{left:(null==(e=t.body)?void 0:e.paddingLeft)??0,top:(null==(a=t.body)?void 0:a.paddingTop)??0,right:(null==(n=t.body)?void 0:n.paddingRight)??0,bottom:(null==(r=t.body)?void 0:r.paddingBottom)??0}}(e),c=n+d.left,h=r+d.top,p=Math.max(1,o-d.left-d.right),u=Math.max(1,i-d.top-d.bottom),f=(null==(s=zl({blocks:e.blocks,pageSettings:{width:p,height:u,orientation:"portrait",margins:{top:0,right:0,bottom:0,left:0,header:0,footer:0,gutter:0}},maxPageHeight:u,styles:a.document.styles,pageOffset:a.pageIndex})[0])?void 0:s.blocks)??[];if(0===f.length)return;const g=ia(a.document);t.saveGraphicsState(a.pageIndex),t.clipRect(a.pageIndex,bM(c),bM(h),bM(p),bM(u));let m=h;for(const v of f){switch(v.sourceBlock.type){case"paragraph":v.layout&&await l.drawParagraph(t,a.pageIndex,v.sourceBlock,v.layout.lines,a.document,c,m,a.fontRegistry,g,l);break;case"table":await l.drawTableBlock(t,a.pageIndex,v,a.document,c,m,p,a.fontRegistry,g,l);break;default:pe(v.sourceBlock,"block")}m+=Math.max(0,v.estimatedHeight)}t.restoreGraphicsState(a.pageIndex)}(t,e,a,n,r,o,i,l),s&&t.restoreGraphicsState(a.pageIndex)}async function eR(t){const{writer:e,document:a,fontRegistry:n,pageIndex:r,lines:o,pageSettings:i,contentLeft:l,contentTop:s,contentWidth:d,paragraphTop:c,drawers:h}=t;for(const p of o){const t=new Map(p.slots.map(t=>[t.offset,t]));for(const o of p.fragments){const u=o.textBox;if(!(null==u?void 0:u.floating))continue;const f=t.get(o.startOffset),g=l+((null==f?void 0:f.left)??0),m=c+p.top,v=Bi({object:Wi(u),pageSettings:i,contentLeft:l,contentTop:s,contentWidth:d,paragraphTop:c,lineTop:m,anchorLeft:g});await tR(e,u,{document:a,fontRegistry:n,pageIndex:r},v.x,v.y,v.width,v.height,h)}}}const aR=new WeakMap;function nR(t){const e=/^data:([^;,]+)(;base64)?,(.*)$/i.exec(t);if(!e)return null;const a=e[1].toLowerCase(),n=Boolean(e[2]),r=e[3]??"";if(!n)return{mediaType:a,data:(new TextEncoder).encode(decodeURIComponent(r))};const o="function"==typeof atob?atob(r):Buffer.from(r,"base64").toString("binary");return{mediaType:a,data:Uint8Array.from(o,t=>t.charCodeAt(0))}}async function rR(t,e,a){let n=t;n.startsWith("data:")||(n=await async function(t){if("function"!=typeof fetch)return null;const e=await fetch(t);if(!e.ok)return null;const a=await e.blob(),n=new Uint8Array(await a.arrayBuffer()),r=Array.from(n,t=>String.fromCharCode(t)).join(""),o="function"==typeof btoa?btoa(r):Buffer.from(n).toString("base64");return`data:${a.type||"application/octet-stream"};base64,${o}`}(n)??n);let r=nR(n);if(!r)return null;const o="undefined"!=typeof Image?await async function(t){return"undefined"==typeof Image?null:await new Promise(e=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>e(a),a.onerror=()=>e(null),a.src=t})}(n):null,i=null!=o&&o.naturalWidth>0&&o.naturalHeight>0;if("image/jpeg"!==r.mediaType&&"image/jpg"!==r.mediaType){if(!i)return null;const t=function(t){if("undefined"==typeof document)return null;const e=document.createElement("canvas");e.width=t.naturalWidth,e.height=t.naturalHeight;const a=e.getContext("2d");return a?(a.fillStyle="#ffffff",a.fillRect(0,0,e.width,e.height),a.drawImage(t,0,0),e.toDataURL("image/jpeg",.92)):null}(o);if(r=t?nR(t):null,!r)return null}const l=i?o.naturalWidth:e,s=i?o.naturalHeight:a;return{width:Math.max(1,Math.round(l)),height:Math.max(1,Math.round(s)),data:r.data}}function oR(t,e){const a=new Map(t.slots.map(t=>[t.offset,t])),n=[];for(const r of e.chars){if("\n"===r.char||"\t"===r.char)continue;const t=a.get(r.paragraphOffset);t&&n.push({char:r.char,left:t.left,offset:r.paragraphOffset})}return n}function iR(t,e,a){const n=oR(t,e);if(0===n.length)return null;const r=new Map(t.slots.map(t=>[t.offset,t])),o=n[0],i=n[n.length-1],l=r.get(i.offset+1);return{left:o.left,right:(null==l?void 0:l.left)??i.left+.55*a}}function lR(t,e,a,n,r,o,i,l){const s=iR(a,n,i.fontSize??vM);if(!s)return;const d="underline"===l?o+a.top+a.height-2:"doubleStrike"===l?o+a.top+.5*a.height:o+a.top+.52*a.height,c=r+s.left,h=r+s.right,p="underline"===l?i.underlineColor??i.color??"#000000":i.color??"#000000";if("strike"!==l){if("doubleStrike"===l){const a=1.3;return t.drawLine(e,{x1:bM(c),y1:bM(d-a),x2:bM(h),y2:bM(d-a),stroke:p,lineWidth:bM(1)}),void t.drawLine(e,{x1:bM(c),y1:bM(d+a),x2:bM(h),y2:bM(d+a),stroke:p,lineWidth:bM(1)})}!function(t,e,a,n,r,o,i){const l=dh(i),s=(r,i)=>{t.drawLine(e,{x1:bM(a),y1:bM(r),x2:bM(n),y2:bM(r),stroke:o,lineWidth:bM(l),dashArray:i})};if(lh(i))return s(r-1.5),void s(r+1.5);if(sh(i))return void function(t,e,a,n,r,o,i){const l=4,s=1.5;let d=a,c=r;for(let h=a;h<=n;h+=1){const n=r+Math.sin((h-a)/l*Math.PI)*s;t.drawLine(e,{x1:bM(d),y1:bM(c),x2:bM(h),y2:bM(n),stroke:o,lineWidth:bM(i)}),d=h,c=n}}(t,e,a,n,r,o,l);s(r,ch(i))}(t,e,c,h,d,p,i.underlineStyle)}else t.drawLine(e,{x1:bM(c),y1:bM(d),x2:bM(h),y2:bM(d),stroke:p,lineWidth:bM(1)})}function sR(t,e,a,n){var r;const o=He(t.style,n.styles).tabs??[];if(0===o.length)return;const i=a-((null==(r=e.slots[0])?void 0:r.left)??0),l=o.filter(t=>"clear"!==t.type).map(t=>({...t,positionPx:t.position*xn})).filter(t=>t.positionPx>i+.01).sort((t,e)=>t.positionPx-e.positionPx)[0];return(null==l?void 0:l.leader)&&"none"!==l.leader?l.leader:void 0}async function dR(t,e,a,n,r,o,i,l,s,d){var c;if(r.image){const a=n.slots.find(t=>t.offset===r.startOffset)??n.slots.find(t=>t.offset>=r.startOffset);if(!a)return;const s=await async function(t,e,a){const n=Ue(e,a.src);if(!n)return null;let r=aR.get(t);r||(r=new Map,aR.set(t,r));const o=r.get(n);if(o)return o;const i=rR(n,a.width,a.height).then(e=>e?t.registerImageResource({width:e.width,height:e.height,data:e.data,filter:"DCTDecode"}):null);return r.set(n,i),i}(t,o,r.image);if(!s)return;return void t.drawImage(e,{resourceName:s,x:bM(i+a.left),y:bM(l+n.top+n.height-r.image.height),width:bM(r.image.width),height:bM(r.image.height),rotation:r.image.rotation})}if(r.textBox)return void(await async function(t,e,a,n,r,o,i,l,s){const d=n.textBox;if(!d||d.floating)return;const c=a.slots.find(t=>t.offset===n.startOffset)??a.slots.find(t=>t.offset>=n.startOffset);c&&await tR(t,d,{document:r,fontRegistry:l,pageIndex:e},o+c.left,i+a.top+a.height-d.height,d.width,d.height,s)}(t,e,n,r,o,i,l,s,d));const h=We(r.styles,null==(c=a.style)?void 0:c.styleId,o.styles);if(h.hidden)return;const p=s.resolveFontFace({fontFamily:h.fontFamily,bold:h.bold,italic:h.italic}),u=h.smallCaps?.8*yM(h):yM(h),f=(h.baselineShift??0)*xn,g=l+n.top+.8*n.height-f,m=oR(n,r),v=m.map(t=>h.allCaps?t.char.toUpperCase():t.char).join("");if(!m[0]||0===v.length)return;!function(t,e,a,n,r,o,i){if(!i.shading)return;const l=iR(a,n,i.fontSize??vM);l&&t.drawRect(e,{x:bM(r+l.left),y:bM(o+a.top+2),width:bM(Math.max(0,l.right-l.left)),height:bM(Math.max(2,a.height-4)),fill:i.shading})}(t,e,n,r,i,l,h),function(t,e,a,n,r,o,i){if(!i.highlight)return;const l=iR(a,n,i.fontSize??vM);l&&t.drawRect(e,{x:bM(r+l.left),y:bM(o+a.top+2),width:bM(Math.max(0,l.right-l.left)),height:bM(Math.max(2,a.height-4)),fill:i.highlight})}(t,e,n,r,i,l,h),function(t,e,a,n,r,o,i,l,s){const d=new Map(n.slots.map(t=>[t.offset,t]));for(const c of r.chars){if("\t"!==c.char)continue;const r=d.get(c.paragraphOffset),h=d.get(c.paragraphOffset+1);if(!r||!h)continue;const p=sR(a,n,r.left,o);if(!p)continue;const u="underscore"===p?l+2:l;t.drawLine(e,{x1:bM(i+r.left),y1:bM(u),x2:bM(i+h.left),y2:bM(u),stroke:s,lineWidth:bM("heavy"===p?1.5:1),dashArray:"dot"===p||"middleDot"===p?[1,3]:"hyphen"===p?[5,3]:void 0})}}(t,e,a,n,r,o,i,g,h.color??"#000000");if("justify"===(He(a.style,o.styles).align??"left")){const a=function(t){const e=[];let a=[];for(const n of t)" "!==n.char?a.push(n):a.length>0&&(e.push(a),a=[]);return a.length>0&&e.push(a),e}(m);for(const n of a){const a=n.map(t=>h.allCaps?t.char.toUpperCase():t.char).join("");0!==a.length&&t.drawText(e,{x:bM(i+n[0].left),y:bM(g),text:a,fontSize:u,color:h.color??"#000000",bold:h.bold,italic:h.italic,fontResourceName:p.writerResourceName,characterSpacing:h.characterSpacing??0,horizontalScale:h.characterScale??100})}}else{const a=function(t){const e=[];let a=[];for(const n of t){const t=a[a.length-1];t&&n.offset>t.offset+1&&(e.push(a),a=[]),a.push(n)}return a.length>0&&e.push(a),e}(m);for(const n of a){const a=n.map(t=>h.allCaps?t.char.toUpperCase():t.char).join("");0!==a.length&&t.drawText(e,{x:bM(i+n[0].left),y:bM(g),text:a,fontSize:u,color:h.color??"#000000",bold:h.bold,italic:h.italic,fontResourceName:p.writerResourceName,characterSpacing:h.characterSpacing??0,horizontalScale:h.characterScale??100})}}h.underline&&lR(t,e,n,r,i,l,h,"underline"),h.strike&&lR(t,e,n,r,i,l,h,"strike"),h.doubleStrike&&lR(t,e,n,r,i,l,h,"doubleStrike")}function cR(t,e,a,n,r,o,i,l,s){var d;if(0!==n.index)return;const c=la(a,s);if(!c)return;const h=n.slots[0];if(!h)return;const p=We(void 0,null==(d=a.style)?void 0:d.styleId,r.styles),u=l.resolveFontFace({fontFamily:p.fontFamily,bold:p.bold,italic:p.italic}),f=oi(a,r.styles),g=yM(p),m=c.length*g*.62*xn,v=ii(a,r.styles,h.left,m);t.drawText(e,{x:bM(o+Math.max(0,v||f)),y:bM(i+n.top+.8*n.height),text:c,fontSize:g,color:p.color??"#000000",bold:p.bold,italic:p.italic,fontResourceName:u.writerResourceName})}function hR(t,e,a,n,r,o,i){const l=[[a.borderTop,"top"],[a.borderRight,"right"],[a.borderBottom,"bottom"],[a.borderLeft,"left"]],s=l.some(([t])=>t&&"none"!==t.type&&t.width>0);if(!a.shading&&!s)return;let d=0;for(const g of n)d=Math.max(d,g.top+g.height);if(d<=0)return;const c=Cn(a),h=c.top+d+c.bottom,p=r+(a.indentLeft??0),u=r+i-(a.indentRight??0),f=o+h;a.shading&&t.drawRect(e,{x:bM(p),y:bM(o),width:bM(Math.max(0,u-p)),height:bM(h),fill:a.shading});for(const[g,m]of l){if(!g||"none"===g.type||g.width<=0)continue;const[a,n,r,i]="top"===m?[p,o,u,o]:"bottom"===m?[p,f,u,f]:"left"===m?[p,o,p,f]:[u,o,u,f];t.drawLine(e,{x1:bM(a),y1:bM(n),x2:bM(r),y2:bM(i),stroke:g.color,lineWidth:g.width,dashArray:$E(g.type)})}}async function pR(t,e,a,n,r,o,i,l,s,d){for(const c of n){cR(t,e,a,c,r,o,i,l,s);for(const n of c.fragments)await dR(t,e,a,c,n,r,o,i,l,d)}}function uR(t,e,a,n,r,o,i){"none"===a.type||a.width<=0||t.drawLine(e,{x1:bM(n),y1:bM(r),x2:bM(o),y2:bM(i),stroke:a.color,lineWidth:bM(a.width),dashArray:$E(a.type)})}function fR(t,e,a,n,r){const o=n+a.left,i=r+a.top,l=o+a.width,s=i+a.height;uR(t,e,a.borders.top,o,i,l,i),uR(t,e,a.borders.right,l,i,l,s),uR(t,e,a.borders.bottom,o,s,l,s),uR(t,e,a.borders.left,o,i,o,s)}async function gR(t,e,a,n,r,o,i,l,s,d){if("table"!==a.sourceBlock.type)return;const c=a.sourceBlock,h=a.tableSegment?dn(c,a.tableSegment):c;if(0===h.rows.length)return;const p=Is({table:h,state:{document:n},pageIndex:0,originX:0,originY:0,contentWidth:i,estimatedHeight:a.estimatedHeight});for(const u of p.cells)u.shading&&t.drawRect(e,{x:bM(r+u.left),y:bM(o+u.top),width:bM(u.width),height:bM(u.height),fill:u.shading});for(const u of p.cells)fR(t,e,u,r,o);for(const u of p.cells)for(const a of u.paragraphs)await pR(t,e,a.paragraph,a.lines,n,r+a.originX,o+a.originY,l,s,d)}const mR={drawParagraph:pR,drawTableBlock:gR};async function vR(t,e,a,n,r,o,i,l,s,d){if(!a||0===a.length)return;const c=o;let h=o;for(const p of a){switch(p.sourceBlock.type){case"paragraph":{if(!p.layout)break;const a=He(p.sourceBlock.style,n.styles),u=h+(0===p.layout.startOffset&&h>o?a.spacingBefore??0:0),f=u+Cn(a).top;hR(t,e,a,p.layout.lines,r,u,i),await pR(t,e,p.sourceBlock,p.layout.lines,n,r,f,l,s,mR),d&&await eR({writer:t,document:n,fontRegistry:l,pageIndex:e,lines:p.layout.lines,pageSettings:d,contentLeft:r,contentTop:c,contentWidth:i,paragraphTop:u,drawers:mR});break}case"table":await gR(t,e,p,n,r,h,i,l,s,mR);break;default:pe(p.sourceBlock,"block")}h+=Math.max(0,p.estimatedHeight)}}function bR(t,e,a,n){t.drawRect(e,{x:0,y:0,width:a,height:n,fill:"#ffffff"})}const yR=[{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 MR(t,e,a){return`${t.toLowerCase()}:${e?"bold":"regular"}${a?"italic":""}`}function xR(t){return t.replace(/[^A-Za-z0-9_]/g,"")}class wR{constructor(){a(this,"faces",new Map),a(this,"fallbackFamily","Helvetica");for(const t of yR)this.registerFontFace(t)}registerFontFace(t){this.faces.set(MR(t.family,t.bold,t.italic),t)}resolveFontFace(t){const e=ro(t.fontFamily),a=Boolean(t.bold),n=Boolean(t.italic);return this.faces.get(MR(e,a,n))??this.faces.get(MR(this.fallbackFamily,a,n))??this.faces.get(MR(this.fallbackFamily,!1,!1))}getPdfFontResources(){const t=new Map;for(const e of this.faces.values())t.set(e.pdfResource.resourceName,e.pdfResource);return Array.from(t.values())}async loadBundledUnicodeFaces(t={}){const e=t.families?new Set(Array.from(t.families).map(ro).map(t=>t.toLowerCase())):null,a=await this.registerOfficeCompatibleFaces(e);if(!e||e.has("roboto")||Array.from(e).some(t=>"helvetica"!==t&&!a.has(t)))for(const[n,r]of Object.entries(ao)){const t=await uo(r);if(!t)continue;const e="bold"===n||"bolditalic"===n,a="italic"===n||"bolditalic"===n,o=`Roboto${n[0].toUpperCase()}${n.slice(1)}`;this.registerFontFace({key:`roboto:${n}`,family:"Roboto",bold:e,italic:a,writerResourceName:o,pdfResource:{kind:"unicode",resourceName:o,family:"Roboto",fontData:t}}),this.fallbackFamily="Roboto"}}async registerOfficeCompatibleFaces(t){const e=new Set;for(const a of no){const n=[a.family,...a.aliases].map(t=>t.toLowerCase());if(!(!t||n.some(e=>t.has(e))))continue;for(const t of n)e.add(t);const r=[];for(const[t,e]of Object.entries(a.files)){const n=await uo(e);if(!n)continue;const o="bold"===t||"bolditalic"===t,i="italic"===t||"bolditalic"===t,l=`${xR(a.family)}${t[0].toUpperCase()}${t.slice(1)}`,s={key:`${a.family.toLowerCase()}:${t}`,family:a.family,bold:o,italic:i,writerResourceName:l,pdfResource:{kind:"unicode",resourceName:l,family:a.family,fontData:n}};this.registerFontFace(s),r.push(s)}for(const t of a.aliases)for(const e of r)this.registerFontFace({...e,key:`${t.toLowerCase()}:${e.key.split(":")[1]}`,family:t})}return e}}class SR{constructor(t){this.font=t}layout(t){const e=[],a=[];let n=0;for(const r of t){const t=r.codePointAt(0)??65533,o=this.font.glyphForCodePoint(t),i=this.font.advanceWidthForGlyph(o);e.push({id:o,codePoints:0===o?[65533]:[t],advanceWidth:i}),a.push({xAdvance:i}),n+=i}return{glyphs:e,positions:a,advanceWidth:n}}}function AR(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function IR(t,e){return AR(t).getUint16(e)}function TR(t,e,a){AR(t).setUint16(e,a,!1)}function CR(t,e,a){AR(t).setUint32(e,a,!1)}function kR(t){return t+3&-4}function VR(t){const e=t.reduce((t,e)=>t+kR(e.byteLength),0),a=new Uint8Array(e);let n=0;for(const r of t)a.set(r,n),n+=kR(r.byteLength);return a}function ER(t,e){const a=[],n=AR(t);if(0===e)for(let r=0;r+1<t.byteLength;r+=2)a.push(2*n.getUint16(r));else for(let r=0;r+3<t.byteLength;r+=4)a.push(n.getUint32(r));return a}function RR(t,e){const a=t[e],n=t[e+1];return void 0===a||void 0===n?null:{start:a,end:n}}function LR(t,e){if(t.byteLength<10||function(t,e){return AR(t).getInt16(e)}(t,0)>=0)return;let a=10,n=0;do{if(a+4>t.byteLength)return;n=IR(t,a),e(IR(t,a+2)),a+=4,a+=1&n?4:2,8&n?a+=2:64&n?a+=4:128&n&&(a+=8)}while(32&n)}function zR(t){const e=new Uint8Array(4*t.length);return t.forEach((t,a)=>CR(e,4*a,t)),e}function NR(t,e){const a=new Uint8Array(4*(e+1));for(let n=0;n<=e;n+=1)TR(a,4*n,t.advanceWidthForGlyph(n)),TR(a,4*n+2,0);return a}class qR{createSubset(t,e){const a=new Map,n=[];for(const c of e)n.push(c.id),a.has(c.id)||a.set(c.id,c.codePoints);const r=function(t,e){const a=t.getRawTableData("glyf"),n=t.getRawTableData("loca"),r=t.getRawTableData("head");if(!a||!n||!r)return Array.from(new Set([0,...e])).sort((t,e)=>t-e);const o=ER(n,IR(r,50)),i=new Set([0,...e]),l=Array.from(i);for(;l.length>0;){const t=RR(o,l.pop());!t||t.end<=t.start||t.end>a.byteLength||LR(a.slice(t.start,t.end),t=>{i.has(t)||(i.add(t),l.push(t))})}return Array.from(i).sort((t,e)=>t-e)}(t,n),o=function(t,e){const a=t.getRawTableData("glyf"),n=t.getRawTableData("loca"),r=t.getRawTableData("head"),o=t.getRawTableData("hhea"),i=t.getRawTableData("maxp"),l=t.getRawTableData("cmap");if(!(a&&n&&r&&o&&i&&l))throw new Error("Missing required TrueType tables for subsetting");const s=Math.max(0,...e),d=new Set(e),c=ER(n,IR(r,50)),h=[],p=[];let u=0;for(let b=0;b<=s;b+=1){h.push(u);const t=RR(c,b);if(d.has(b)&&t&&t.end>t.start){const e=a.slice(t.start,t.end);p.push(e),u+=kR(e.byteLength)}}h.push(u);const f=r.slice();CR(f,8,0),TR(f,50,1);const g=o.slice();TR(g,34,s+1);const m=i.slice();TR(m,4,s+1);const v={cmap:l,head:f,hhea:g,hmtx:NR(t,s),loca:zR(h),maxp:m,glyf:VR(p)};for(const b of["OS/2","name","post"]){const e=t.getRawTableData(b);e&&(v[b]=e)}return v}(t,r),i=zr(65536,new Map(Object.entries(o).map(([t,e])=>[t.charCodeAt(0)<<24|t.charCodeAt(1)<<16|t.charCodeAt(2)<<8|t.charCodeAt(3),e]))).ttf,l=Math.max(0,...r),s=[],d=[];for(let c=0;c<=l;c+=1)s[c]=t.advanceWidthForGlyph(c)/t.unitsPerEm*1e3,d[c]=a.get(c)??[0];return{fontFile:i,widths:s,unicode:d,encodeGlyph:t=>t}}}const OR=[{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 PR(t){return Number.isFinite(t)?Number(t.toFixed(3)).toString():"0"}function WR(t){return(new TextEncoder).encode(t).byteLength}function HR(t){return Array.from(t).map(t=>t.toString(16).padStart(2,"0").toUpperCase()).join("")}function UR(t){return Math.max(0,t).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function FR(t,e,a){const[n,r,o]=function(t,e){if(!t)return e;const a=t.trim().replace(/^#/,"");return/^[0-9a-fA-F]{6}$/.test(a)?[Number.parseInt(a.slice(0,2),16)/255,Number.parseInt(a.slice(2,4),16)/255,Number.parseInt(a.slice(4,6),16)/255]:e}(t,a);return`${PR(n)} ${PR(r)} ${PR(o)} ${e}`}function BR(t,e){return(t&&t.trim().length>0?t:e).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}const GR=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 ZR(t){return Array.from(t).map(t=>function(t){const e=t.codePointAt(0)??63;return e>=32&&e<=126||e>=160&&e<=255?e:GR.get(e)??63}(t).toString(16).padStart(2,"0").toUpperCase()).join("")}function DR(t){const e=[];for(let a of t)a>65535?(a-=65536,e.push(a>>>10&1023|55296),e.push(1023&a|56320)):e.push(a);return e.map(UR).join("")}function KR(t){return UR(t)}function jR(t){return`% OasisText ${DR(Array.from(t).map(t=>t.codePointAt(0)??65533))}`}class XR{constructor(t=OR){a(this,"pages",[]),a(this,"fontResources",new Map),a(this,"unicodeFontStates",new Map),a(this,"usedFontResourceNames",new Set),a(this,"imageResources",new Map);for(const e of t)this.registerFontResource(e)}registerFontResource(t){if(this.fontResources.set(t.resourceName,t),"unicode"===t.kind&&!this.unicodeFontStates.has(t.resourceName)){const a={program:e=function(t){const e=eo.decodeSync(t);return To.parse(e)}(t.fontData),layouter:new SR(e),subsetter:new qR},n=1e3/a.program.unitsPerEm,r={id:0,codePoints:[0],advanceWidth:a.program.advanceWidthForGlyph(0)};this.unicodeFontStates.set(t.resourceName,{resource:t,font:a,usedGlyphs:new Map([[0,r]]),scale:n,layoutCache:new Map})}var e}addPage(t){return this.pages.push({width:Math.max(1,t.width),height:Math.max(1,t.height),commands:[],imageResourceNames:new Set}),this.pages.length-1}getPageCount(){return this.pages.length}drawRect(t,e){const a=this.pages[t];if(!a||e.width<=0||e.height<=0)return;const n=["q"];e.fill&&n.push(FR(e.fill,"rg",[1,1,1])),e.stroke&&(n.push(FR(e.stroke,"RG",[0,0,0])),n.push(`${PR(e.lineWidth??1)} w`)),n.push([PR(e.x),PR(a.height-e.y-e.height),PR(e.width),PR(e.height),"re"].join(" ")),e.fill&&e.stroke?n.push("B"):e.fill?n.push("f"):e.stroke&&n.push("S"),n.push("Q"),a.commands.push(n.join("\n"))}drawLine(t,e){const a=this.pages[t];if(!a)return;const n=e.dashArray&&e.dashArray.length>0?`[${e.dashArray.map(t=>PR(t)).join(" ")}] 0 d`:null,r=["q",FR(e.stroke,"RG",[0,0,0])];n&&r.push(n),r.push(`${PR(e.lineWidth??1)} w`,`${PR(e.x1)} ${PR(a.height-e.y1)} m`,`${PR(e.x2)} ${PR(a.height-e.y2)} l`,"S","Q"),a.commands.push(r.join("\n"))}drawPath(t,e){const a=this.pages[t];if(!a||0===e.segments.length)return;if(!e.fill&&!e.stroke)return;const n=t=>a.height-t,r=["q"];e.fill&&r.push(FR(e.fill,"rg",[1,1,1])),e.stroke&&(r.push(FR(e.stroke,"RG",[0,0,0])),r.push(`${PR(e.lineWidth??1)} w`));for(const o of e.segments)switch(o.type){case"move":r.push(`${PR(o.x)} ${PR(n(o.y))} m`);break;case"line":r.push(`${PR(o.x)} ${PR(n(o.y))} l`);break;case"cubic":r.push(`${PR(o.x1)} ${PR(n(o.y1))} ${PR(o.x2)} ${PR(n(o.y2))} ${PR(o.x)} ${PR(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"),a.commands.push(r.join("\n"))}saveGraphicsState(t){const e=this.pages[t];e&&e.commands.push("q")}restoreGraphicsState(t){const e=this.pages[t];e&&e.commands.push("Q")}rotateAbout(t,e,a,n){const r=this.pages[t];if(!r||!n)return;const o=r.height-a,i=-n*Math.PI/180,l=Math.cos(i),s=Math.sin(i),d=e-e*l+o*s,c=o-e*s-o*l;r.commands.push(`${PR(l)} ${PR(s)} ${PR(-s)} ${PR(l)} ${PR(d)} ${PR(c)} cm`)}clipRect(t,e,a,n,r){const o=this.pages[t];!o||n<=0||r<=0||o.commands.push(`${PR(e)} ${PR(o.height-a-r)} ${PR(n)} ${PR(r)} re`,"W","n")}drawText(t,e){const a=this.pages[t];if(!a||0===e.text.length)return;const n=function(t){return t.fontResourceName?t.fontResourceName:t.bold&&t.italic?"F4":t.bold?"F2":t.italic?"F3":"F1"}(e);this.usedFontResourceNames.add(n);const r=this.unicodeFontStates.get(n);r?this.drawUnicodeText(a,r,e):a.commands.push([jR(e.text),"BT",FR(e.color,"rg",[0,0,0]),`/${n} ${PR(e.fontSize??12)} Tf`,...e.horizontalScale&&e.horizontalScale>0&&100!==e.horizontalScale?[`${PR(e.horizontalScale)} Tz`]:[],...e.characterSpacing&&0!==e.characterSpacing?[`${PR(e.characterSpacing)} Tc`]:[],`${PR(e.x)} ${PR(a.height-e.y)} Td`,`<${ZR(e.text)}> Tj`,"ET"].join("\n"))}registerImageResource(t){const e=t.resourceName??`Im${this.imageResources.size+1}`;return this.imageResources.has(e)||this.imageResources.set(e,{resourceName:e,width:Math.max(1,Math.round(t.width)),height:Math.max(1,Math.round(t.height)),data:t.data,filter:t.filter}),e}drawImage(t,e){const a=this.pages[t];if(!a||e.width<=0||e.height<=0||!this.imageResources.has(e.resourceName))return;a.imageResourceNames.add(e.resourceName);const n=a.height-e.y-e.height,r=Number.isFinite(e.rotation)?e.rotation??0:0;if(0===r)return void a.commands.push(["q",[PR(e.width),"0","0",PR(e.height),PR(e.x),PR(n),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"));const o=-r*Math.PI/180,i=Math.cos(o),l=Math.sin(o),s=e.width*i,d=e.width*l,c=-e.height*l,h=e.height*i,p=e.x+e.width/2-.5*s-.5*c,u=n+e.height/2-.5*d-.5*h;a.commands.push(["q",[PR(s),PR(d),PR(c),PR(h),PR(p),PR(u),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}layoutUnicodeText(t,e){const a=t.layoutCache.get(e);if(a)return a;const n=t.font.layouter.layout(e);return t.layoutCache.set(e,n),n}encodeUnicodeGlyphRun(t,e){return e.glyphs.map((a,n)=>{t.usedGlyphs.has(a.id)||t.usedGlyphs.set(a.id,a);const r=e.positions[n],o=a.advanceWidth*t.scale,i=((null==r?void 0:r.xAdvance)??a.advanceWidth)*t.scale;return{glyphId:a.id,nominalWidth:o,desiredAdvance:i}})}drawUnicodeText(t,e,a){const n=this.layoutUnicodeText(e,a.text),r=this.encodeUnicodeGlyphRun(e,n);if(0===r.length)return;const o=r.some(t=>Math.abs(t.nominalWidth-t.desiredAdvance)>.01)?`[${r.map(t=>{const e=t.nominalWidth-t.desiredAdvance;return 0===e?`<${KR(t.glyphId)}>`:`<${KR(t.glyphId)}> ${PR(e)}`}).join(" ")}] TJ`:`<${r.map(t=>KR(t.glyphId)).join("")}> Tj`;t.commands.push([jR(a.text),"BT",FR(a.color,"rg",[0,0,0]),`/${e.resource.resourceName} ${PR(a.fontSize??12)} Tf`,...a.horizontalScale&&a.horizontalScale>0&&100!==a.horizontalScale?[`${PR(a.horizontalScale)} Tz`]:[],...a.characterSpacing&&0!==a.characterSpacing?[`${PR(a.characterSpacing)} Tc`]:[],`${PR(a.x)} ${PR(t.height-a.y)} Td`,o,"ET"].join("\n"))}toArrayBuffer(){const t=this.toUint8Array();return Uint8Array.from(t).buffer}toBlob(){return new Blob([this.toArrayBuffer()],{type:"application/pdf"})}toUint8Array(){0===this.pages.length&&this.addPage({width:612,height:792});const t=[],e=e=>{const a=t.length+1;return t.push({id:a,body:e}),a},a=e(""),n=e(""),r=Array.from(this.fontResources.values()).filter(t=>"base14"===t.kind||this.usedFontResourceNames.has(t.resourceName)),o=r.map(t=>{if("unicode"===t.kind){const a=this.unicodeFontStates.get(t.resourceName);if(a)return this.addUnicodeFontObjects(a,e)}return e(function(t){switch(t.kind){case"base14":return`<< /Type /Font /Subtype /Type1 /BaseFont /${t.baseFont} /Encoding /WinAnsiEncoding >>`;case"unicode":return"<< /Type /Font /Subtype /Type0 /BaseFont /OasisPending /Encoding /Identity-H >>"}}(t))}),i=r.map((t,e)=>`/${t.resourceName} ${o[e]} 0 R`).join(" "),l=new Map;for(const p of this.imageResources.values())l.set(p.resourceName,this.addImageObject(p,e));const s=[];for(const p of this.pages){const t=`${p.commands.join("\n")}\n`,a=e(`<< /Length ${WR(t)} >>\nstream\n${t}endstream`),r=Array.from(p.imageResourceNames).map(t=>{const e=l.get(t);return e?`/${t} ${e} 0 R`:""}).filter(Boolean).join(" "),o=r?` /XObject << ${r} >>`:"",d=e(["<< /Type /Page",`/Parent ${n} 0 R`,`/MediaBox [0 0 ${PR(p.width)} ${PR(p.height)}]`,`/Resources << /Font << ${i} >>${o} >>`,`/Contents ${a} 0 R`,">>"].join("\n"));s.push(d)}t[a-1].body=`<< /Type /Catalog /Pages ${n} 0 R >>`,t[n-1].body=["<< /Type /Pages",`/Kids [${s.map(t=>`${t} 0 R`).join(" ")}]`,`/Count ${s.length}`,">>"].join("\n");let d="%PDF-1.4\n% Oasis PDF\n";const c=[0];for(const p of t)c[p.id]=WR(d),d+=`${p.id} 0 obj\n${p.body}\nendobj\n`;const h=WR(d);d+=`xref\n0 ${t.length+1}\n`,d+="0000000000 65535 f \n";for(const p of t)d+=`${String(c[p.id]??0).padStart(10,"0")} 00000 n \n`;return d+=["trailer",`<< /Size ${t.length+1} /Root ${a} 0 R >>`,"startxref",String(h),"%%EOF",""].join("\n"),(new TextEncoder).encode(d)}addImageObject(t,e){return e(function(t,e){const a=`${HR(t)}>`;return[`<< /Length ${WR(a)}`," /Filter [/ASCIIHexDecode /DCTDecode]",` ${e.join(" ")}`," >>","stream",a,"endstream"].join("\n")}(t.data,["/Type /XObject","/Subtype /Image",`/Width ${t.width}`,`/Height ${t.height}`,"/ColorSpace /DeviceRGB","/BitsPerComponent 8"]))}addUnicodeFontObjects(t,e){const a=t.font.subsetter.createSubset(t.font.program,t.usedGlyphs.values()),n=e(function(t,e=""){const a=`${HR(t)}>`,n=e?` /${e.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${WR(a)} /Filter /ASCIIHexDecode${n} >>\nstream\n${a}\nendstream`}(a.fontFile)),r=t.font.program.metadata,o=r.familyClass>>8||0;let i=4;r.isFixedPitch&&(i|=1),o>=1&&o<=7&&(i|=2),10===o&&(i|=8),r.macStyleItalic&&(i|=64);const l=`${BR(`${t.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${BR(r.postscriptName,t.resource.family)}`,s=r.bbox,d=e(["<< /Type /FontDescriptor",`/FontName /${l}`,`/Flags ${i}`,`/FontBBox [${[s.minX*t.scale,s.minY*t.scale,s.maxX*t.scale,s.maxY*t.scale].map(PR).join(" ")}]`,`/ItalicAngle ${PR(r.italicAngle)}`,`/Ascent ${PR(r.ascent*t.scale)}`,`/Descent ${PR(r.descent*t.scale)}`,`/CapHeight ${PR(r.capHeight*t.scale)}`,`/XHeight ${PR(r.xHeight*t.scale)}`,"/StemV 0",`/FontFile2 ${n} 0 R`,">>"].join("\n")),c=e(["<< /Type /Font","/Subtype /CIDFontType2",`/BaseFont /${l}`,"/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>",`/FontDescriptor ${d} 0 R`,`/W [0 [${a.widths.map(t=>PR(t??0)).join(" ")}]]`,"/CIDToGIDMap /Identity",">>"].filter(Boolean).join("\n")),h=e(function(t,e=""){const a=e?` /${e.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${WR(t)}${a} >>\nstream\n${t}endstream`}(function(t){const e=t.map(t=>`<${DR(t)}>`).filter(t=>"<>"!==t);0===e.length&&e.push("<0000>");const a=[];for(let n=0;n<e.length;n+=256){const t=Math.min(n+256,e.length);a.push(`<${UR(n)}> <${UR(t-1)}> [${e.slice(n,t).join(" ")}]`)}return["/CIDInit /ProcSet findresource begin","12 dict begin","begincmap","/CIDSystemInfo <<"," /Registry (Adobe)"," /Ordering (UCS)"," /Supplement 0",">> def","/CMapName /Adobe-Identity-UCS def","/CMapType 2 def","1 begincodespacerange","<0000><ffff>","endcodespacerange",`${a.length} beginbfrange`,a.join("\n"),"endbfrange","endcmap","CMapName currentdict /CMap defineresource pop","end","end",""].join("\n")}(a.unicode)));return e(["<< /Type /Font","/Subtype /Type0",`/BaseFont /${l}`,"/Encoding /Identity-H",`/DescendantFonts [${c} 0 R]`,`/ToUnicode ${h} 0 R`,">>"].join("\n"))}}async function JR(t){t=YE(t);const e=new wR;await e.loadBundledUnicodeFaces({families:Ac(t)});const a=new XR(e.getPdfFontResources()),n=is(t),r=function(t){return ia(t)}(t);for(const o of n.pages){const n=Math.max(1,bM(o.pageSettings.width)),i=Math.max(1,bM(o.pageSettings.height)),l=a.addPage({width:n,height:i});bR(a,l,n,i);const s=o.pageSettings.margins.left+o.pageSettings.margins.gutter,d=xe(o.pageSettings);await vR(a,l,o.headerBlocks,t,s,o.headerTop??Ae(o.pageSettings),d,e,r,o.pageSettings);const c=o.bodyTop??Ie(o.pageSettings);if(o.blocks.some(t=>void 0!==t.columnIndex)){const n=we(o.pageSettings),i=new Map;for(const t of o.blocks){const e=t.columnIndex??0,a=i.get(e)??[];a.push(t),i.set(e,a)}for(const[s,d]of i){const i=n[s]??n[0];await vR(a,l,d,t,i.left,c,i.width,e,r,o.pageSettings)}}else await vR(a,l,o.blocks,t,s,c,d,e,r,o.pageSettings);await vR(a,l,o.footerBlocks,t,s,o.footerTop??o.bodyBottom??o.pageSettings.height,d,e,r,o.pageSettings),o.footnoteBlocks&&o.footnoteBlocks.length>0&&void 0!==o.footnoteTop&&(void 0!==o.footnoteSeparatorTop&&a.drawLine(l,{x1:bM(s),y1:bM(o.footnoteSeparatorTop+.5),x2:bM(s+Math.min(180,.35*d)),y2:bM(o.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:bM(1)}),await YR(a,l,o.footnoteBlocks,o.footnoteReferenceIds??[],t,s,o.footnoteTop,d,e,r))}if(0===a.getPageCount()){const t=a.addPage({width:612,height:792});bR(a,t,612,792)}return a.toArrayBuffer()}async function YR(t,e,a,n,r,o,i,l,s,d){var c;let h=i;const p=new Set,u=new Map(n.map(t=>{var e;return[t,(null==(e=Jl(r,t))?void 0:e.run.text)??""]}));for(const f of a){const a=n.find(t=>f.blockId.startsWith(`${t}:`));if(a&&!p.has(a)){const n=u.get(a);if(n){const a="paragraph"===f.sourceBlock.type?f.sourceBlock:void 0,i=We(void 0,null==(c=null==a?void 0:a.style)?void 0:c.styleId,r.styles),l=s.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});t.drawText(e,{x:bM(o),y:bM(h+12),text:n,fontSize:yM(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:l.writerResourceName})}p.add(a)}await vR(t,e,[f],r,o+pn,h,Math.max(24,l-pn),s,d),h+=Math.max(0,f.estimatedHeight)+2}}function QR(t,e){const a=URL.createObjectURL(t),n=document.createElement("a");n.href=a,n.download=e,n.click(),URL.revokeObjectURL(a)}function _R(t){const e=t.download??QR;return{handleExportDocx:async()=>{const a=await async function(t){const e=await _E(t);return new Blob([e],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}(t.document());e(a,"oasis-editor.docx"),t.focusInput()},handleExportPdf:async()=>{const a=await async function(t){const e=await JR(t);return new Blob([e],{type:"application/pdf"})}(t.document());e(a,"oasis-editor.pdf"),t.focusInput()}}}async function $R(t){return"function"==typeof t.arrayBuffer?t.arrayBuffer():new Promise((e,a)=>{const n=new FileReader;n.onerror=()=>a(n.error??new Error("Failed to read file.")),n.onload=()=>{const t=n.result;t instanceof ArrayBuffer?e(t):a(new Error("Failed to read file as ArrayBuffer."))},n.readAsArrayBuffer(t)})}function tL(t){if(!t)return null;for(const e of Array.from(t.items??[])){if("file"!==e.kind)continue;const t=e.getAsFile();if(t&&t.type.startsWith("image/"))return t}for(const e of Array.from(t.files??[]))if(e.type.startsWith("image/"))return e;return null}function eL(t){return{handleImportFile:async e=>{if(!e)return;const a=function(t){return ny.find(e=>e.matches(t))}(e);if(!a)return t.setImportPhase("error"),t.logger.error("import:unsupported-format",{name:e.name,type:e.type}),void t.clearImportProgressSoon();const n=t.now();t.logger.info("import:start",{format:a.id,name:e.name,size:e.size}),t.setImportPhase("reading-file");try{const r=t.now(),o=await $R(e);t.logger.info("import:phase",{phase:"reading-file",durationMs:Math.round(100*(t.now()-r))/100});let i=null,l=-1,s=0;const d=await a.import(o,(e,a)=>{const n=t.now(),r=void 0!==a&&Number.isFinite(a)?Math.floor(100*a):void 0,o=e!==i;if(!o&&!(void 0!==r&&(l<0||r-l>=1))&&!(n-s>=40))return;i=e,l=r??l,s=n,t.setImportPhase(e,a);const d={phase:e,subProgress:a};o||void 0===a||1===a?t.logger.info("import:phase",d):t.logger.debug("import:phase",d)});t.logger.info("import:document-diagnostics",function(t){var e;const a=Je(t),n=new Map,r=new Map;let o=0,i=0;for(const l of a){const a=He(l.style,t.styles);r.set(a.align,(r.get(a.align)??0)+1);for(const r of l.runs){const a=We(r.styles,null==(e=l.style)?void 0:e.styleId,t.styles),s=a.fontFamily??"<null>";n.set(s,(n.get(s)??0)+1),null!==a.characterSpacing&&(o+=1),null!==a.characterScale&&(i+=1)}}return{paragraphCount:a.length,alignCounts:Array.from(r.entries()),fontCounts:Array.from(n.entries()),characterSpacingRuns:o,characterScaleRuns:i,firstParagraphs:a.slice(0,30).map((e,a)=>{var n;const r=He(e.style,t.styles),o=e.runs[0],i=We(null==o?void 0:o.styles,null==(n=e.style)?void 0:n.styleId,t.styles);return{index:a,text:Ce(e).slice(0,160),runCount:e.runs.length,rawParagraphStyle:e.style,align:r.align,indentFirstLine:r.indentFirstLine,lineGridPitch:r.lineGridPitch,lineGridType:r.lineGridType,fontFamily:i.fontFamily,fontSize:i.fontSize,characterSpacing:i.characterSpacing,characterScale:i.characterScale,firstRunStyle:null==o?void 0:o.styles}})}}(d)),t.setImportPhase("applying-editor-state"),t.resetEditorChromeState(),t.applyState(Ra(d));const c=t.now();t.setImportPhase("stabilizing-layout"),await t.stabilizeLayoutAfterImport(),t.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:Math.round(100*(t.now()-c))/100});const h=Fe(d).reduce((t,e)=>{var a,n;return t+((null==(a=e.header)?void 0:a.length)??0)+e.blocks.length+((null==(n=e.footer)?void 0:n.length)??0)},0),p=Xe(d).length;t.setImportPhase("done"),t.logger.info("import:done",{format:a.id,blocks:h,paragraphs:p,durationMs:Math.round(100*(t.now()-n))/100}),t.focusInput()}catch(r){t.setImportPhase("error"),t.logger.error("import:error",r)}finally{t.clearImportProgressSoon()}}}}function aL(t,e){const a=va(t);if(a.isCollapsed||a.startIndex!==a.endIndex||a.endParagraphOffset-a.startParagraphOffset!==1)return null;const n=ha(t)[a.startIndex];if(!n)return null;let r=0;for(let o=0;o<n.runs.length;o+=1){const t=n.runs[o],i=r;if(r+=t.text.length,e(t)&&1===t.text.length&&i===a.startParagraphOffset)return{paragraph:n,paragraphIndex:a.startIndex,run:t,runIndex:o,offset:i}}return null}function nL(t,e){if("inline"===e)return;const a={...t??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating"};switch(e){case"square":case"tight":case"through":case"topAndBottom":return{...a,wrap:e,behindDoc:!1};case"behind":return{...a,wrap:"none",behindDoc:!0};case"front":return{...a,wrap:"none",behindDoc:!1}}}function rL(t){return t?t.behindDoc?"behind":t.wrap&&"none"!==t.wrap?t.wrap:"front":"inline"}function oL(t,e){return{...t,positionV:{...t.positionV??{},relativeFrom:e?"page":"paragraph"}}}function iL(t){var e;return"page"===(null==(e=null==t?void 0:t.positionV)?void 0:e.relativeFrom)}function lL(t){return aL(t,t=>Boolean(t.image))}function sL(t,e){const a=lL(t);if(!a)return t;const n=function(t){if(!Number.isFinite(t))return;const e=(Math.round(t)%360+360)%360;return 0===e?void 0:e}(e),r=ha(t),{paragraphIndex:o,run:i}=a,l=r.map((t,e)=>e!==o?TT(t):{...TT(t),runs:t.runs.map(t=>t.id===i.id&&t.image?{...t,image:{...t.image,rotation:n}}:IT(t))});return ZT(t,l,YT(l,va(t)))}function dL(t,e){const a=lL(t);if(!(null==a?void 0:a.run.image))return t;const n=ha(t),{paragraphIndex:r,run:o}=a,i=n.map((t,a)=>a!==r?TT(t):{...TT(t),runs:t.runs.map(t=>{if(t.id!==o.id||!t.image)return IT(t);const a=e(t.image.floating),n={...t.image};return a?n.floating=a:delete n.floating,{...t,image:n}})});return ZT(t,i,YT(i,va(t)))}function cL(t){const e=lL(t);if(!(null==e?void 0:e.run.image))return null;return function(t){var e;if(!jE(t))return"";let a=!1,n="";for(const r of t.runs)a?n+=r.text:"end"===(null==(e=r.fieldChar)?void 0:e.kind)&&(a=!0);return n.replace(/^[:\-\s]+/,"")}(ha(t)[e.paragraphIndex+1])}function hL(t,e,a){const n=lL(t);if(!(null==n?void 0:n.run.image))return t;const r=ha(t),o=n.paragraphIndex+1,i=o<r.length&&jE(r[o])?function(t,e,a){var n;const r=(null==(n=t.runs.find(t=>/^\d+$/.test(t.text)))?void 0:n.text)??"1",o=KE(e,a,Number.parseInt(r,10)||1);return o.id=t.id,o}(r[o],e,a):KE(e,a,1),l=function(t){let e=1;return t.map(t=>jE(t)?XE(t,e++):TT(t))}(o<r.length&&jE(r[o])?[...kT(r.slice(0,o)),i,...kT(r.slice(o+1))]:[...kT(r.slice(0,o)),i,...kT(r.slice(o))]),s=l[o]??i;return ZT(t,l,KT(Ve(s,ke(s))))}function pL(t,e){const a=lL(t);if(!a)return t;const n=ha(t),{paragraphIndex:r,offset:o,run:i}=a,l=pa(n,e.paragraphId);if(l<0)return t;const s=Ee(n[l],e),d=l===r&&s>o?s-1:s;if(l===r&&d===o)return t;const c=t=>RT(t,[...WT(t,0,o),...WT(t,o+1,ke(t))]),h=(t,e)=>HT(t,Math.max(0,Math.min(e,ke(t))),[wa("",OT(t,e),i.image)]),p=n.map((t,e)=>e===r&&e===l?h(c(t),d):e===r?c(t):e===l?h(t,d):kT([t])[0]),u=p[l];return ZT(t,p,KT(Ve(u,Math.max(0,Math.min(d+1,ke(u))))))}function uL(t,e,a,n=0){const r=xe(Me(e));if(!a)return r;const o=dl(e,a,n);return null!==o&&Number.isFinite(o)&&o>0?Math.min(r,o):r}function fL(t){return{insertImageFromFile:async(e,a)=>{t.logger.info(`image insert:start name="${e.name}" type=${e.type} size=${e.size}`);const n=await $R(e),r=`data:${e.type};base64,${function(t){return btoa(new Uint8Array(t).reduce((t,e)=>t+String.fromCharCode(e),""))}(n)}`,o=new Image;o.src=r,await new Promise(t=>{o.onload=t,o.onerror=t});const i=o.naturalWidth||300,l=o.naturalHeight||300,s=t.state(),d=(null==a?void 0:a.paragraphId)??s.selection.focus.paragraphId,c=uL(t.surfaceRef(),s.document,d,s.activeSectionIndex??0),h=i>c?c/i:1,p=Math.max(24,Math.round(i*h)),u=Math.max(24,Math.round(l*h));t.logger.info(`image insert:decoded natural=${i}x${l} fitted=${p}x${u} maxWidth=${c}`),t.applyTransactionalState(t=>function(t,e){const a=ma(t.selection)?t:XT(t),{paragraph:n,index:r,offset:o}=jT(a),i=HT(n,o,[wa("",OT(n,o),e)]);return ZT(a,ha(a).map((t,e)=>e===r?i:TT(t)),KT(Ve(i,o+1)))}(a?YC(t,{anchor:a,focus:a}):t,{src:r,width:p,height:u}),{mergeKey:"insertImage"})}}}const gL={"reading-file":[0,8],opening:[8,20],parsing:[20,72],finishing:[72,78],"applying-editor-state":[78,88],"stabilizing-layout":[88,98],done:[100,100],error:[100,100]};function mL(t,e){return t.paragraph.runs.map(t=>t.text).join("")[e]??""}function vL(t){return" "===t||"\t"===t||"\n"===t}function bL(t,e,a){if(a.isCollapsed)return null;const n=e.get(t);return void 0===n||n<a.startIndex||n>a.endIndex?null:a.startIndex===a.endIndex?{start:a.startParagraphOffset,end:a.endParagraphOffset}:t===a.start.paragraphId?{start:a.startParagraphOffset,end:Number.POSITIVE_INFINITY}:t===a.end.paragraphId?{start:0,end:a.endParagraphOffset}:{start:0,end:Number.POSITIVE_INFINITY}}function yL(t,e){var a,n,r,o;const i=va(e),l=[],s=t.surfaceRect,d=new Map(ha(e).map((t,e)=>[t.id,e]));let c=null,h=null;if(!i.isCollapsed&&i.startIndex===i.endIndex&&i.endParagraphOffset-i.startParagraphOffset===1){const e=t=>t.paragraphId===i.start.paragraphId&&t.startOffset===i.startParagraphOffset&&t.endOffset===i.endParagraphOffset,a=t.inlineImages.find(e)??t.floatingImages.find(e);if(a&&(c={paragraphId:a.paragraphId,startOffset:a.startOffset,endOffset:a.endOffset,left:a.left-s.left,top:a.top-s.top,width:a.width,height:a.height,rotation:a.rotation??0}),!c){const e=t=>t.paragraphId===i.start.paragraphId&&t.startOffset===i.startParagraphOffset&&t.endOffset===i.endParagraphOffset,a=t.floatingTextBoxes.find(e),n=a?void 0:t.inlineTextBoxes.find(e),r=a??n;r&&(h={paragraphId:r.paragraphId,startOffset:r.startOffset,endOffset:r.endOffset,left:r.left-s.left,top:r.top-s.top,width:r.width,height:r.height,rotation:r.rotation??0,floating:Boolean(a)})}}const p=sa(e),u=_e(e.document,e.selection.anchor.paragraphId,p),f=_e(e.document,e.selection.focus.paragraphId,p);let g=!1;if(u&&f&&u.blockIndex===f.blockIndex&&u.zone===f.zone&&(u.rowIndex!==f.rowIndex||u.cellIndex!==f.cellIndex)){const o=Be(e.document)[p];let i;if(i="header"===u.zone?null==(a=null==o?void 0:o.header)?void 0:a[u.blockIndex]:"footer"===u.zone?null==(n=null==o?void 0:o.footer)?void 0:n[u.blockIndex]:null==(r=null==o?void 0:o.blocks)?void 0:r[u.blockIndex],i&&"table"===i.type){g=!0;const e=sn(i),a=e.find(t=>t.rowIndex===u.rowIndex&&t.cellIndex===u.cellIndex),n=e.find(t=>t.rowIndex===f.rowIndex&&t.cellIndex===f.cellIndex);if(a&&n){const r=Math.min(a.visualRowIndex,n.visualRowIndex),o=Math.max(a.visualRowIndex+a.rowSpan-1,n.visualRowIndex+n.rowSpan-1),d=Math.min(a.visualColumnIndex,n.visualColumnIndex),c=Math.max(a.visualColumnIndex+a.colSpan-1,n.visualColumnIndex+n.colSpan-1),h=new Set;for(const a of t.paragraphs)if(a.tableCell&&a.tableCell.tableId===i.id){const t=e.find(t=>t.rowIndex===a.tableCell.rowIndex&&t.cellIndex===a.tableCell.cellIndex);if(t){const e=t.visualRowIndex<=o&&t.visualRowIndex+t.rowSpan-1>=r,n=t.visualColumnIndex<=c&&t.visualColumnIndex+t.colSpan-1>=d;if(e&&n){const e=`${t.rowIndex}:${t.cellIndex}`;h.has(e)||(h.add(e),l.push({left:a.tableCell.left-s.left,top:a.tableCell.top-s.top,width:a.tableCell.width,height:a.tableCell.height}))}}}}}}if(!(g||i.isCollapsed||c||h))for(const S of t.paragraphs){const t=bL(S.paragraphId,d,i);if(!t)continue;const e=Math.max(t.start,S.startOffset),a=Math.min(t.end,S.endOffset);if(!(e>=a))for(const n of S.lines){let t=Math.max(e,n.startOffset),r=Math.min(a,n.endOffset);for(;t<r&&vL(mL(S,t));)t+=1;for(;r>t&&vL(mL(S,r-1));)r-=1;if(t>=r)continue;const o=n.slots.find(e=>e.offset===t),i=n.slots.find(t=>t.offset===r)??n.slots[n.slots.length-1];if(!o||!i)continue;const d=0===S.startOffset&&n.startOffset===S.startOffset&&n.top>S.top,c=d?S.top:n.top,h=d?n.top+n.height-S.top:n.height;l.push({left:o.left-s.left+1,top:c-s.top,width:Math.max(1,i.left-o.left+1-1),height:h})}}const m=e.selection.focus.paragraphId,v=t.paragraphsById.get(m)??[],b=null==(o=v[0])?void 0:o.paragraph,y=function(t,e){if(0===t.length)return null;const a=t.find(t=>e>=t.startOffset&&e<=t.endOffset)??t[t.length-1],n=a.lines.flatMap(t=>t.slots);if(0===n.length)return{left:a.left,top:a.top,height:Math.max(18,a.height)};let r=n[0],o=Math.abs(e-r.offset);for(const l of n){const t=Math.abs(e-l.offset);t<o&&(r=l,o=t)}const i=a.lines[0];return 0===a.startOffset&&void 0!==i&&e>=i.startOffset&&e<=i.endOffset&&r.top>a.top?{left:r.left,top:a.top,height:r.top+r.height-a.top}:{left:r.left,top:r.top,height:r.height}}(v,b?Ee(b,e.selection.focus):e.selection.focus.offset),M=((null==y?void 0:y.left)??s.left)-s.left,x=((null==y?void 0:y.top)??s.top)-s.top,w=Math.max(18,(null==y?void 0:y.height)??28);return{selectionBoxes:l,inputBox:{left:M,top:x,height:w},caretBox:{left:M,top:x,height:w,visible:v.length>0&&!g&&!c&&!h},selectedImageBox:c,selectedTextBoxBox:h}}function ML(t,e){if(0===e.length)return t;const a={...t};for(const n of e)delete a[n];return a}function xL(t){const[e,a]=y({}),[n,r]=y({}),[o,i]=y({left:0,top:0,height:28}),[l,s]=y([]),[d,c]=y([]),[h,p]=y(null),[u,f]=y(null),[g,m]=y({left:0,top:0,height:28,visible:!1}),[v,b]=y(null);let M=0;const w=(a="selection")=>{var r;const o=t.surfaceRef();if(!o)return s([]),c([]),p(null),f(null),void m(t=>({...t,visible:!1}));const l=qs({surface:o,state:t.state,measuredBlockHeights:e(),measuredParagraphLayouts:n(),zoomFactor:null==(r=t.zoomFactor)?void 0:r.call(t)});if(!l)return s([]),c([]),p(null),f(null),void m(t=>({...t,visible:!1}));const d=yL(l,t.state);s(d.selectionBoxes),c(function(t,e){const a=e.document.comments;if(!a||0===a.order.length)return[];const n=t.surfaceRect,r=new Map(ha(e).map((t,e)=>[t.id,e])),o=[];for(const i of a.order){const e=a.items[i];if(!(null==e?void 0:e.start)||!(null==e?void 0:e.end))continue;const l=r.get(e.start.paragraphId),s=r.get(e.end.paragraphId);if(void 0!==l&&void 0!==s)for(const a of t.paragraphs){const t=r.get(a.paragraphId);if(void 0===t||t<l||t>s)continue;const d=t===l?e.start.offset:0,c=t===s?e.end.offset:Number.POSITIVE_INFINITY,h=Math.max(d,a.startOffset),p=Math.min(c,a.endOffset);if(!(h>=p))for(const e of a.lines){const t=Math.max(h,e.startOffset),a=Math.min(p,e.endOffset);if(t>=a)continue;const r=e.slots.find(e=>e.offset===t),l=e.slots.find(t=>t.offset===a)??e.slots[e.slots.length-1];r&&l&&o.push({commentId:i,left:r.left-n.left,top:e.top-n.top,width:Math.max(1,l.left-r.left),height:e.height})}}}return o}(l,t.state)),p(d.selectedImageBox),f(d.selectedTextBoxBox),i(d.inputBox),m(d.caretBox)},S=(t="selection")=>{const e=++M;queueMicrotask(()=>{e===M&&w(t)})};x(()=>{t.state.selection.anchor.paragraphId,t.state.selection.anchor.runId,t.state.selection.anchor.offset,t.state.selection.focus.paragraphId,t.state.selection.focus.runId,t.state.selection.focus.offset,S("selection")}),x(()=>{var e;t.state.document,t.state.activeSectionIndex,t.state.activeZone,(null==(e=t.isImporting)?void 0:e.call(t))||S("content-change")}),x(()=>{const e=t.viewportRef();if(!e)return;const a=()=>{S("scroll")},n=()=>{S("resize")};e.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",n),T(()=>{e.removeEventListener("scroll",a),window.removeEventListener("resize",n)})});return{measuredBlockHeights:e,measuredParagraphLayouts:n,inputBox:o,selectionBoxes:l,commentHighlights:d,selectedImageBox:h,selectedTextBoxBox:u,caretBox:g,preferredColumnX:v,setPreferredColumnX:b,clearPreferredColumn:()=>b(null),requestInputBoxSync:S,scheduleDeferredLayoutMeasurement:(t,e={})=>(e.paragraphIds&&e.paragraphIds.length>0&&r(t=>ML(t,e.paragraphIds??[])),S(t),e.resolveWhenDone?Promise.resolve():null),stabilizeLayoutAfterImport:async()=>{a({}),r({}),await new Promise(t=>{var e;e=()=>t(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>e()):globalThis.setTimeout(e,16)}),S("import")},syncMeasuredLayoutMetrics:(t="content-change")=>(S(t),!1),syncInputBox:w,setMeasuredBlockHeights:a,setMeasuredParagraphLayouts:r,applyInvalidation:e=>{var n,o;if(!(null==(n=t.isImporting)?void 0:n.call(t))){if(e.dirtyAll||e.structureChanged)a({}),r({});else if(((null==(o=e.dirtyParagraphIds)?void 0:o.length)??0)>0){const t=e.dirtyParagraphIds??[];r(e=>ML(e,t))}S("content-change")}},onCleanupHook:()=>{M+=1}}}function wL(t){return{performUndo:()=>{const e=(a=t.getHistoryState(),n=t.stateSnapshot(),0===a.undoStack.length?null:{history:{undoStack:a.undoStack.slice(0,-1),redoStack:[...a.redoStack,n],lastTransactionMeta:null},nextState:a.undoStack[a.undoStack.length-1]});var a,n;e&&(t.updateHistoryState(()=>e.history),t.clearPreferredColumn(),t.applyHistoryState(e.nextState),t.focusInput())},performRedo:()=>{const e=(a=t.getHistoryState(),n=t.stateSnapshot(),0===a.redoStack.length?null:{history:{undoStack:[...a.undoStack,n],redoStack:a.redoStack.slice(0,-1),lastTransactionMeta:null},nextState:a.redoStack[a.redoStack.length-1]});var a,n;e&&(t.updateHistoryState(()=>e.history),t.clearPreferredColumn(),t.applyHistoryState(e.nextState),t.focusInput())},moveSelectedImageByParagraph:e=>{const a=t.imageOps().getSelectedImageInfo(t.state());if(!a)return!1;const n=ha(t.state()),r=n.findIndex(t=>t.id===a.paragraph.id);if(r<0)return!1;const o=r+e;if(o<0||o>=n.length){const a=((t,e)=>{const a=Fe(t.document),n=Math.max(0,Math.min(sa(t),a.length-1)),r=da(t),o=a[n];if(!o)return t;const i=[...a],l={...o},s=Sa("");if("header"===r){const t=[...o.header??[]];e<0?t.unshift(s):t.push(s),l.header=t}else if("footer"===r){const t=[...o.footer??[]];e<0?t.unshift(s):t.push(s),l.footer=t}else{const t=[...o.blocks];e<0?t.unshift(s):t.push(s),l.blocks=t}return i[n]=l,{...t,document:{...t.document,sections:i}}})(t.state(),e),n=ha(a),r=e<0?n[0]:n[n.length-1];if(!r)return!1;const o=Ve(r,e<0?ke(r):0);return t.applyTransactionalState(()=>pL(a,o),{mergeKey:"moveImage"}),t.focusInput(),!0}const i=n[o],l=e<0?ke(i):0;return t.applyTransactionalState(t=>pL(t,Ve(i,l)),{mergeKey:"moveImage"}),t.focusInput(),!0},applySelectionPreservingStructure:e=>{var a;const n=t.stateSnapshot();t.applyHistoryState({...n,document:{...n.document,sections:null==(a=n.document.sections)?void 0:a.map(Lx)},selection:{anchor:{...e.anchor},focus:{...e.focus}}})}}}function SL(t={}){const e=t.dbName??"oasis-editor-db",a=t.storeName??"documents",n=t.key??"current-document";let r=null;async function o(){return r||(r=await function(t){return new Promise((e,a)=>{const n=indexedDB.open(t.name,t.version);n.onerror=()=>{var t;a(new Error(`Failed to open IndexedDB: ${null==(t=n.error)?void 0:t.message}`))},n.onsuccess=()=>{e(n.result)},n.onupgradeneeded=e=>{const a=n.result;t.onUpgrade(a,e.oldVersion,e.newVersion)}})}({name:e,version:1,onUpgrade:t=>{t.objectStoreNames.contains(a)||t.createObjectStore(a)}}),r)}return{async saveDocument(t){await function(t,e,a,n){return new Promise((r,o)=>{try{const i=t.transaction([e],"readwrite").objectStore(e).put(n,a);i.onerror=()=>{var t;o(new Error(`Failed to put item in ${e}: ${null==(t=i.error)?void 0:t.message}`))},i.onsuccess=()=>{r()}}catch(i){o(i)}})}(await o(),a,n,t)},loadDocument:async()=>function(t,e,a){return new Promise((n,r)=>{try{const o=t.transaction([e],"readonly").objectStore(e).get(a);o.onerror=()=>{var t;r(new Error(`Failed to get item from ${e}: ${null==(t=o.error)?void 0:t.message}`))},o.onsuccess=()=>{n(o.result??null)}}catch(o){r(o)}})}(await o(),a,n),async clearDocument(){await function(t,e,a){return new Promise((n,r)=>{try{const o=t.transaction([e],"readwrite").objectStore(e).delete(a);o.onerror=()=>{var t;r(new Error(`Failed to delete item from ${e}: ${null==(t=o.error)?void 0:t.message}`))},o.onsuccess=()=>{n()}}catch(o){r(o)}})}(await o(),a,n)},close(){r&&(r.close(),r=null)}}}function AL(t){const[e,a]=y([]),[n,r]=y([]);let o={undoStack:[],redoStack:[],lastTransactionMeta:null};const i=()=>{a(o.undoStack),r(o.redoStack)};return{undoStack:e,redoStack:n,applyTransactionalState:(e,a)=>{const n=t.stateSnapshot(),r=Ri("txn:produce",()=>e(n),0);if(r===n)return;o=function(t,e,a,n,r=Date.now()){var o;return{undoStack:void 0!==(null==n?void 0:n.mergeKey)&&(null==(o=t.lastTransactionMeta)?void 0:o.mergeKey)===n.mergeKey&&r-t.lastTransactionMeta.timestamp<1e3?t.undoStack:[...t.undoStack,e],redoStack:[],lastTransactionMeta:(null==n?void 0:n.mergeKey)?{mergeKey:n.mergeKey,timestamp:r}:null}}(o,n,0,a),i();const l=Ri("txn:invalidate",()=>function(t,e){var a,n,r,o,i,l,s,d,c,h,p,u,f,g,m,v;if(t===e||t.document===e.document)return{};const b=t=>Fe(t.document).map(t=>[...(t.header??[]).map(t=>t.id),...t.blocks.map(t=>t.id),...(t.footer??[]).map(t=>t.id)].join("|")).join("||");if(b(t)!==b(e))return{dirtyAll:!0,structureChanged:!0};const y=ha(t),M=ha(e),x=new Map;for(const S of y)x.set(S.id,S);const w=[];for(const S of M){const t=x.get(S.id);if(!t){w.push(S.id);continue}if(t===S)continue;if(t.runs.length!==S.runs.length){w.push(S.id);continue}let e=!1;for(let b=0;b<t.runs.length;b+=1){const y=t.runs[b],M=S.runs[b];if(y!==M){if(y.id!==M.id||y.text!==M.text){e=!0;break}if(Boolean(y.image)!==Boolean(M.image)||((null==(a=y.image)?void 0:a.width)??-1)!==((null==(n=M.image)?void 0:n.width)??-1)||((null==(r=y.image)?void 0:r.height)??-1)!==((null==(o=M.image)?void 0:o.height)??-1)||((null==(l=null==(i=y.image)?void 0:i.floating)?void 0:l.wrap)??"")!==((null==(d=null==(s=M.image)?void 0:s.floating)?void 0:d.wrap)??"")||Boolean(null==(h=null==(c=y.image)?void 0:c.floating)?void 0:h.behindDoc)!==Boolean(null==(u=null==(p=M.image)?void 0:p.floating)?void 0:u.behindDoc)||((null==(g=null==(f=y.image)?void 0:f.wrapPolygon)?void 0:g.length)??-1)!==((null==(v=null==(m=M.image)?void 0:m.wrapPolygon)?void 0:v.length)??-1)){e=!0;break}}}e&&w.push(S.id)}return{dirtyParagraphIds:w}}(n,r),0);t.applyLayoutInvalidation(l),Ri("txn:setState",()=>t.commitState(r),0)},applyHistoryState:e=>{t.commitState(t.cloneState(e))},resetTransactionGrouping:()=>{var t;t=o,o={...t,lastTransactionMeta:null}},updateHistoryState:t=>{o=t(o),i()},getHistoryState:()=>o,clearHistory:()=>{o={undoStack:[],redoStack:[],lastTransactionMeta:null},i()}}}function IL(t){x(()=>{var e,a;if(t.state.document,t.state.selection,t.state.activeSectionIndex,t.state.activeZone,a=t.state,dT&&(pT={anchor:{paragraphId:a.selection.anchor.paragraphId,runId:a.selection.anchor.runId,offset:a.selection.anchor.offset},focus:{paragraphId:a.selection.focus.paragraphId,runId:a.selection.focus.runId,offset:a.selection.focus.offset},activeZone:a.activeZone??"main",activeSectionIndex:a.activeSectionIndex??0}),t.isImportInProgress())return;const n=t.cloneState(t.getStateSnapshot());null==(e=t.getOnStateChange())||e(n),t.emit("change",n),t.emit("documentChange",n.document),t.emit("selectionChange",n.selection)})}function TL(t){const{documentOptions:e,logger:a,runtimeClient:n,state:r,commitState:o,getStateSnapshot:i,applyState:l,cloneState:s,isReadOnly:d,focusInput:c,surfaceRef:h,viewportRef:p,zoomFactor:u,getImageOps:f}=t,g=function(t){const[e,a]=y(null),n=(t,e)=>{const[a,n]=gL[t];return void 0!==e&&Number.isFinite(e)?Math.round(10*(a+(n-a)*Math.min(1,Math.max(0,e))))/10:n},r=eL({applyState:t.applyState,stabilizeLayoutAfterImport:t.stabilizeLayoutAfterImport,resetEditorChromeState:t.resetEditorChromeState,focusInput:t.focusInput,setImportPhase:(t,e)=>{a({phase:t,progress:n(t,e),subProgress:e})},clearImportProgressSoon:()=>{globalThis.setTimeout(()=>{a(t=>"done"===(null==t?void 0:t.phase)||"error"===(null==t?void 0:t.phase)?null:t)},1200)},now:()=>performance.now(),logger:t.logger}),o=fL({state:t.state,applyTransactionalState:t.applyTransactionalState,surfaceRef:t.surfaceRef,logger:t.logger}),i=_R({document:()=>t.state().document,focusInput:t.focusInput}),l=async(t,e)=>{await o.insertImageFromFile(t,e)};return{importProgress:e,handleImportFile:async e=>{t.isReadOnly()||await r.handleImportFile(e)},handleExportDocx:async()=>{await i.handleExportDocx()},handleExportPdf:async()=>{await i.handleExportPdf()},insertImageFromFile:l,handleInsertImage:async e=>{t.isReadOnly()||e&&(await l(e),t.focusInput())}}}({state:()=>r,applyState:l,applyTransactionalState:(t,e)=>B(t,e),isReadOnly:d,surfaceRef:()=>h()??null,stabilizeLayoutAfterImport:async()=>{await L()},resetEditorChromeState:()=>J(),focusInput:c,logger:a}),m=()=>{var t,e;return"done"!==(null==(t=g.importProgress())?void 0:t.phase)&&"error"!==(null==(e=g.importProgress())?void 0:e.phase)&&null!==g.importProgress()},{measuredBlockHeights:v,measuredParagraphLayouts:b,inputBox:M,selectionBoxes:w,commentHighlights:S,selectedImageBox:T,selectedTextBoxBox:C,caretBox:k,preferredColumnX:V,setPreferredColumnX:E,clearPreferredColumn:R,stabilizeLayoutAfterImport:L,setMeasuredBlockHeights:z,setMeasuredParagraphLayouts:N,applyInvalidation:q,onCleanupHook:O}=xL({state:r,surfaceRef:h,viewportRef:p,isImporting:m,zoomFactor:u}),P=SL({key:e().persistenceKey}),{status:W}=function(t,e,a){const[n,r]=y("Initial"),[o,i]=y(!1),l=()=>a.enabled??!1,s=a.persistence,d=ln(async t=>{var e;if(l()&&o()){r("Saving...");try{const e=JSON.parse(JSON.stringify(ne(t)));await s.saveDocument(e),r("Saved")}catch(n){null==(e=a.logger)||e.error("persistence:autosave failed",n),r("Error")}}},1e3);return x(A(()=>t.document,t=>{l()&&o()&&d(t)},{defer:!0})),I(async()=>{var t;if(!l())return i(!0),void r("Saved");try{const t=await s.loadDocument();t&&e(t)}catch(n){null==(t=a.logger)||t.error("persistence:load failed",n)}finally{i(!0),r("Saved")}}),{status:n}}(r,t=>{a.info("persistence:loaded",{docId:t.id});const e=Ra(t);o(e),J()},{enabled:e().persistenceEnabled??!1,persistence:e().persistence??P,logger:a}),H=AL({stateSnapshot:i,commitState:o,cloneState:s,applyLayoutInvalidation:q}),{undoStack:U,redoStack:F,applyTransactionalState:B,applyHistoryState:G,resetTransactionGrouping:Z,updateHistoryState:D,getHistoryState:K,clearHistory:j}=H,X=wL({state:()=>r,stateSnapshot:i,applyHistoryState:G,applyTransactionalState:B,focusInput:c,clearPreferredColumn:R,imageOps:f,updateHistoryState:D,getHistoryState:K}),J=()=>{R(),z({}),N({}),j()};return IL({state:r,isImportInProgress:m,cloneState:s,getStateSnapshot:i,getOnStateChange:()=>e().onStateChange,emit:n.emit}),{docIO:g,isImportInProgress:m,measuredBlockHeights:v,measuredParagraphLayouts:b,inputBox:M,selectionBoxes:w,commentHighlights:S,selectedImageBox:T,selectedTextBoxBox:C,caretBox:k,preferredColumnX:V,setPreferredColumnX:E,clearPreferredColumn:R,stabilizeLayoutAfterImport:L,setMeasuredBlockHeights:z,setMeasuredParagraphLayouts:N,applyLayoutInvalidation:q,onCleanupHook:O,fallbackPersistence:P,persistenceStatus:W,undoStack:U,redoStack:F,applyTransactionalState:B,applyHistoryState:G,resetTransactionGrouping:Z,updateHistoryState:D,getHistoryState:K,clearHistory:j,historyActions:X,resetEditorChromeState:J}}function CL(t){return aL(t,t=>Boolean(t.textBox))}function kL(t,e){const a=CL(t);if(!a||!a.run.textBox)return t;const n=function(t){if(!Number.isFinite(t))return;const e=(Math.round(t)%360+360)%360;return 0===e?void 0:e}(e),{paragraphIndex:r,run:o}=a,i=ha(t).map((t,e)=>e!==r?TT(t):{...TT(t),runs:t.runs.map(t=>t.id===o.id&&t.textBox?{...t,textBox:{...t.textBox,rotation:n}}:IT(t))});return ZT(t,i,YT(i,va(t)))}function VL(t,e){const a=CL(t);if(!(null==a?void 0:a.run.textBox))return t;const{paragraphIndex:n,run:r}=a,o=ha(t).map((t,a)=>a!==n?TT(t):{...TT(t),runs:t.runs.map(t=>{if(t.id!==r.id||!t.textBox)return IT(t);const a=e(t.textBox.floating),n={...t.textBox};return a?n.floating=a:delete n.floating,{...t,textBox:n}})});return ZT(t,o,YT(o,va(t)))}function EL(t,e,a,n={}){const r=CL(t);if(!r||!r.run.textBox)return t;const o=n.handleDirection??"se",i=o.includes("n")||o.includes("s"),l=o.includes("w"),s=o.includes("n"),d=Math.max(24,Math.round(e)),c=Math.max(24,Math.round(a)),{paragraphIndex:h,run:p}=r,u=d-r.run.textBox.width,f=c-r.run.textBox.height,g=ha(t).map((t,e)=>e!==h?TT(t):{...TT(t),runs:t.runs.map(t=>{var e;if(t.id!==p.id||!t.textBox)return IT(t);const a=t.textBox,n={...a,width:d,height:c};return i&&(null==(e=a.body)?void 0:e.autoFit)&&(n.body={...a.body,autoFit:!1}),a.floating&&(n.floating=function(t,e,a,n,r){let o=t;if(n&&0!==e){const a=t.positionH;(null==a?void 0:a.align)||(o={...o,positionH:{...a??{},offset:((null==a?void 0:a.offset)??0)-e*An}})}if(r&&0!==a){const t=o.positionV;(null==t?void 0:t.align)||(o={...o,positionV:{...t??{},offset:((null==t?void 0:t.offset)??0)-a*An}})}return o}(a.floating,u,f,l,s)),{...t,textBox:n}})});return ZT(t,g,YT(g,va(t)))}const RL=t=>t.cells.reduce((t,e)=>t+Math.max(1,e.colSpan??1),0),LL=t=>t.rows.reduce((t,e)=>Math.max(t,RL(e)),0),zL=(t,e)=>{let a=0;for(const n of t.cells){const t=Math.max(1,n.colSpan??1);if(e>=a&&e<a+t)return n;a+=t}return null},NL=t=>{for(const e of t.rows)for(const t of e.cells){if("continue"===t.vMerge)continue;const e=t.blocks[0];if(e)return e}return null},qL=(t,e,a)=>{const n=Be(t);for(const r of n){const t=[...r.header||[],...r.blocks,...r.footer||[]];for(const n of t){if("table"!==n.type)continue;const t=n.rows.flatMap(t=>t.cells.filter(t=>"continue"!==t.vMerge&&t.blocks.length>0)),r=t.findIndex(t=>t.blocks.some(t=>t.id===e));if(-1===r)continue;const o=t[r+a],i=null==o?void 0:o.blocks[0];return i?Ve(i,0):null}}return null},OL=(t,e,a="main")=>{const n=sa(t),r=Fe(t.document),o=Math.max(0,Math.min(n,r.length-1)),i=r[o];if(!i)return t;const l=[...r];return l[o]="header"===a?{...i,header:e}:"footer"===a?{...i,footer:e}:{...i,blocks:e},{...t,document:{...t.document,sections:l}}};function PL(t,e){return t.visualRowIndex!==e.visualRowIndex?t.visualRowIndex-e.visualRowIndex:t.visualColumnIndex!==e.visualColumnIndex?t.visualColumnIndex-e.visualColumnIndex:0}function WL(t,e){const a=t.selection,n=sa(t),r=_e(t.document,a.anchor.paragraphId,n),o=_e(t.document,a.focus.paragraphId,n);if(!r||!o||r.blockIndex!==o.blockIndex||r.zone!==o.zone)return null;const i=e.getTargetBlocks(t,r.zone)[r.blockIndex];if(!i||"table"!==i.type)return null;const l=sn(i),s=l.find(t=>t.rowIndex===r.rowIndex&&t.cellIndex===r.cellIndex),d=l.find(t=>t.rowIndex===o.rowIndex&&t.cellIndex===o.cellIndex);return s&&d?{anchorLocation:r,focusLocation:o,anchorCell:s,focusCell:d,tableBlock:i,tableLayout:l}:null}function HL(t){const e=(t,e)=>{const a=Fe(t.document),n=sa(t),r=a[Math.max(0,Math.min(n,a.length-1))];return r?"header"===e?r.header||[]:"footer"===e?r.footer||[]:r.blocks:[]},{resolveTableCellRangeSelection:a,resolveSelectedTableCells:n,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o}=function(t){return{resolveTableCellRangeSelection:e=>{var a,n,r,o,i;const l=e.selection,s=WL(e,t);if(!s||s.anchorLocation.rowIndex===s.focusLocation.rowIndex&&s.anchorLocation.cellIndex===s.focusLocation.cellIndex)return null==(a=t.logger)||a.debug(`resolveTableCellRangeSelection: no expansion (anchor=${l.anchor.paragraphId} focus=${l.focus.paragraphId})`),null;const d=Math.min(s.anchorLocation.rowIndex,s.focusLocation.rowIndex),c=Math.max(s.anchorLocation.rowIndex,s.focusLocation.rowIndex),h=Math.min(s.anchorLocation.cellIndex,s.focusLocation.cellIndex),p=Math.max(s.anchorLocation.cellIndex,s.focusLocation.cellIndex);null==(n=t.logger)||n.info(`resolveTableCellRangeSelection: expanding r${s.anchorLocation.rowIndex}:c${s.anchorLocation.cellIndex}->r${s.focusLocation.rowIndex}:c${s.focusLocation.cellIndex} (anchor=${l.anchor.paragraphId} focus=${l.focus.paragraphId}) range=[rows ${d}..${c}, cells ${h}..${p}]`);const u=PL(s.anchorCell,s.focusCell)<=0?s.anchorLocation:s.focusLocation,f=PL(s.anchorCell,s.focusCell)<=0?s.focusLocation:s.anchorLocation,g=null==(o=null==(r=s.tableBlock.rows[u.rowIndex])?void 0:r.cells[u.cellIndex])?void 0:o.blocks[0],m=null==(i=s.tableBlock.rows[f.rowIndex])?void 0:i.cells[f.cellIndex],v=null==m?void 0:m.blocks[m.blocks.length-1];return g&&v?{anchor:Ve(g,0),focus:Ve(v,Ce(v).length)}:null},resolveSelectedTableCells:e=>{const a=WL(e,t);if(!a)return null;const n=Math.min(a.anchorCell.visualRowIndex,a.focusCell.visualRowIndex),r=Math.max(a.anchorCell.visualRowIndex+a.anchorCell.rowSpan-1,a.focusCell.visualRowIndex+a.focusCell.rowSpan-1),o=Math.min(a.anchorCell.visualColumnIndex,a.focusCell.visualColumnIndex),i=Math.max(a.anchorCell.visualColumnIndex+a.anchorCell.colSpan-1,a.focusCell.visualColumnIndex+a.focusCell.colSpan-1),l=a.tableLayout.filter(t=>t.visualRowIndex<=r&&t.visualRowIndex+t.rowSpan-1>=n&&t.visualColumnIndex<=i&&t.visualColumnIndex+t.colSpan-1>=o);return{blockIndex:a.anchorLocation.blockIndex,cells:l,zone:a.anchorLocation.zone}},resolveHorizontalTableCellRange:e=>{const a=WL(e,t);if(!a||a.anchorCell.visualRowIndex!==a.focusCell.visualRowIndex)return null;const n=PL(a.anchorCell,a.focusCell);if(0===n)return null;const r=n<=0?a.anchorLocation:a.focusLocation,o=n<=0?a.focusLocation:a.anchorLocation;return{blockIndex:a.anchorLocation.blockIndex,rowIndex:r.rowIndex,startCellIndex:r.cellIndex,endCellIndex:o.cellIndex,zone:a.anchorLocation.zone}},resolveVerticalTableCellRange:e=>{const a=WL(e,t);if(!a||a.anchorLocation.cellIndex!==a.focusLocation.cellIndex)return null;const n=Math.min(a.anchorCell.visualRowIndex,a.focusCell.visualRowIndex),r=Math.max(a.anchorCell.visualRowIndex,a.focusCell.visualRowIndex);return n===r?null:{blockIndex:a.anchorLocation.blockIndex,startRowIndex:n,endRowIndex:r,cellIndex:a.anchorLocation.cellIndex,zone:a.anchorLocation.zone}}}}({getTargetBlocks:e,logger:t.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:d,canSplitSelectedTableCellVertically:c,canSplitSelectedTable:h,canEditSelectedTableRow:p,canEditSelectedTableColumn:u}=function(t){const e=e=>{const a=t.resolveHorizontalTableCellRange(e);return Boolean(a&&a.endCellIndex>a.startCellIndex)},a=e=>{var a;const n=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!n)return!1;const r=t.getTargetBlocks(e,n.zone)[n.blockIndex];if(!r||"table"!==r.type)return!1;const o=null==(a=r.rows[n.rowIndex])?void 0:a.cells[n.cellIndex];return Boolean(((null==o?void 0:o.colSpan)??1)>1)},n=e=>{var a;const n=t.resolveVerticalTableCellRange(e);if(!n)return!1;const r=t.getTargetBlocks(e,n.zone)[n.blockIndex];if(!r||"table"!==r.type)return!1;for(let t=n.startRowIndex;t<=n.endRowIndex;t+=1){const e=null==(a=r.rows[t])?void 0:a.cells[n.cellIndex];if(!e||"continue"===e.vMerge||1!==e.blocks.length)return!1}return!0},r=e=>{var a;const n=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!n)return!1;const r=t.getTargetBlocks(e,n.zone)[n.blockIndex];if(!r||"table"!==r.type)return!1;const o=null==(a=r.rows[n.rowIndex])?void 0:a.cells[n.cellIndex];return Boolean(((null==o?void 0:o.rowSpan)??1)>1&&"restart"===(null==o?void 0:o.vMerge))};return{canMergeSelectedTableCells:e,canSplitSelectedTableCell:a,canMergeSelectedTableRows:n,canMergeSelectedTable:t=>e(t)||n(t),canSplitSelectedTableCellVertically:r,canSplitSelectedTable:t=>a(t)||r(t),canEditSelectedTableRow:e=>{const a=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!a)return!1;const n=t.getTargetBlocks(e,a.zone)[a.blockIndex];return Boolean(n&&"table"===n.type)},canEditSelectedTableColumn:e=>{const a=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!a)return!1;const n=t.getTargetBlocks(e,a.zone)[a.blockIndex];return!(!n||"table"!==n.type)&&LL(n)>1}}}({getTargetBlocks:e,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o}),{mergeSelectedTableCells:f,mergeSelectedTableRows:g,mergeSelectedTable:m,splitSelectedTableCellVertically:v,splitSelectedTableCell:b,splitSelectedTable:y}=function(t){const e=e=>{const a=t.resolveHorizontalTableCellRange(e);if(!a)return e;const n=t.getTargetBlocks(e,a.zone).map(Rx),r=n[a.blockIndex];if(!r||"table"!==r.type)return e;const o=r.rows[a.rowIndex];if(!o)return e;const i=o.cells.slice(a.startCellIndex,a.endCellIndex+1);if(i.length<2)return e;const l={...i[0],colSpan:i.reduce((t,e)=>t+Math.max(1,e.colSpan??1),0),blocks:i.flatMap(t=>t.blocks.map(t=>Rx(t)))};o.cells.splice(a.startCellIndex,i.length,l);const s=l.blocks[0];return s?{...OL(e,n,a.zone),selection:{anchor:Ve(s,0),focus:Ve(s,0)}}:e},a=e=>{const a=t.resolveVerticalTableCellRange(e);if(!a)return e;const n=t.getTargetBlocks(e,a.zone).map(Rx),r=n[a.blockIndex];if(!r||"table"!==r.type)return e;const o=[];for(let t=a.startRowIndex;t<=a.endRowIndex;t+=1){const n=r.rows[t],i=null==n?void 0:n.cells[a.cellIndex];if(!n||!i||"continue"===i.vMerge||1!==i.blocks.length)return e;o.push(i)}if(o.length<2)return e;const i=Math.max(1,o[0].colSpan??1);if(!o.every(t=>Math.max(1,t.colSpan??1)===i))return e;const l={...o[0],rowSpan:o.length,vMerge:"restart",blocks:o.flatMap(t=>t.blocks.map(t=>Rx(t)))};r.rows[a.startRowIndex].cells[a.cellIndex]=l;for(let t=a.startRowIndex+1;t<=a.endRowIndex;t+=1){const e=Ia([Sa("")],i);e.blocks=[],e.vMerge="continue",r.rows[t].cells[a.cellIndex]=e}const s=l.blocks[0];return s?{...OL(e,n,a.zone),selection:{anchor:Ve(s,0),focus:Ve(s,0)}}:e},n=e=>{var a;const n=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!n)return e;const r=t.getTargetBlocks(e,n.zone).map(Rx),o=r[n.blockIndex];if(!o||"table"!==o.type)return e;const i=null==(a=o.rows[n.rowIndex])?void 0:a.cells[n.cellIndex],l=Math.max(1,(null==i?void 0:i.rowSpan)??1);if(!i||l<=1||"restart"!==i.vMerge)return e;i.rowSpan=void 0,i.vMerge=void 0;const s=Math.max(1,i.colSpan??1);for(let t=1;t<l;t+=1){const e=o.rows[n.rowIndex+t];if(!e)break;const a=Ia([Sa("")],s);e.cells[n.cellIndex]=a}const d=i.blocks[0];return d?{...OL(e,r,n.zone),selection:{anchor:Ve(d,0),focus:Ve(d,0)}}:e},r=e=>{var a;const n=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!n)return e;const r=t.getTargetBlocks(e,n.zone).map(Rx),o=r[n.blockIndex];if(!o||"table"!==o.type)return e;const i=o.rows[n.rowIndex],l=null==i?void 0:i.cells[n.cellIndex],s=Math.max(1,(null==l?void 0:l.colSpan)??1);if(!i||!l||s<=1)return e;const d=[{...l,colSpan:1,blocks:l.blocks.map(t=>Rx(t))},...Array.from({length:s-1},()=>Ia([Sa("")]))];i.cells.splice(n.cellIndex,1,...d);const c=null==(a=d[0])?void 0:a.blocks[0];return c?{...OL(e,r,n.zone),selection:{anchor:Ve(c,0),focus:Ve(c,0)}}:e};return{mergeSelectedTableCells:e,mergeSelectedTableRows:a,mergeSelectedTable:n=>t.canMergeSelectedTableCells(n)?e(n):t.canMergeSelectedTableRows(n)?a(n):n,splitSelectedTableCellVertically:n,splitSelectedTableCell:r,splitSelectedTable:e=>t.canSplitSelectedTableCellVertically(e)?n(e):t.canSplitSelectedTableCell(e)?r(e):e}}({getTargetBlocks:e,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o,canMergeSelectedTableCells:i,canMergeSelectedTableRows:s,canSplitSelectedTableCell:l,canSplitSelectedTableCellVertically:c}),{insertSelectedTableRow:M,deleteSelectedTableRow:x,insertSelectedTableColumn:w,deleteSelectedTableColumn:S}=function(t){return{insertSelectedTableRow:(e,a)=>{var n,r;const o=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!o)return e;const i=t.getTargetBlocks(e,o.zone).map(Rx),l=i[o.blockIndex];if(!l||"table"!==l.type)return e;const s=l.rows[o.rowIndex];if(!s)return e;const d=Math.max(0,Math.min(l.rows.length,o.rowIndex+(a>0?1:0)));let c;if(l.rows.some(t=>t.cells.some(t=>Math.max(1,t.rowSpan??1)>1||void 0!==t.vMerge))){const t=sn(l),a=t.find(t=>t.rowIndex===o.rowIndex&&t.cellIndex===o.cellIndex),r=t.filter(t=>t.rowIndex===o.rowIndex);c=Ta((r.length>0?r:t.filter(t=>t.rowIndex===Math.max(0,o.rowIndex-1))).map(e=>{const a=t.find(t=>t.visualColumnIndex===e.visualColumnIndex&&t.visualRowIndex<d&&t.visualRowIndex+t.rowSpan>d);if(a){a.cell.rowSpan=Math.max(1,a.cell.rowSpan??1)+1,a.cell.vMerge="restart";const t=Ia([Sa("")],e.colSpan);return t.blocks=[],t.vMerge="continue",t}return Ia([Sa("")],e.colSpan)})),l.rows.splice(d,0,c);const s=(null==a?void 0:a.visualColumnIndex)??o.cellIndex,h=zL(c,s),p=(null==h?void 0:h.blocks[0])??(null==(n=c.cells.find(t=>"continue"!==t.vMerge&&t.blocks[0]))?void 0:n.blocks[0])??NL(l);return p?{...OL(e,i,o.zone),selection:{anchor:Ve(p,0),focus:Ve(p,0)}}:OL(e,i,o.zone)}c=Ta(s.cells.map(t=>Ia([Sa("")],Math.max(1,t.colSpan??1)))),l.rows.splice(d,0,c);const h=c.cells[Math.min(o.cellIndex,c.cells.length-1)],p=(null==h?void 0:h.blocks[0])??(null==(r=c.cells.find(t=>"continue"!==t.vMerge&&t.blocks[0]))?void 0:r.blocks[0])??NL(l);return p?{...OL(e,i,o.zone),selection:{anchor:Ve(p,0),focus:Ve(p,0)}}:OL(e,i,o.zone)},deleteSelectedTableRow:e=>{const a=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!a)return e;const n=t.getTargetBlocks(e,a.zone).map(Rx),r=n[a.blockIndex];if(!r||"table"!==r.type)return e;if(r.rows.length<=1)return e;const o=r.rows[a.rowIndex];if(!o)return e;if(o.cells.some(t=>"continue"!==t.vMerge&&Math.max(1,t.rowSpan??1)>1))return e;const i=r.rows.some(t=>t.cells.some(t=>Math.max(1,t.rowSpan??1)>1||void 0!==t.vMerge)),l=i?sn(r).find(t=>t.rowIndex===a.rowIndex&&t.cellIndex===a.cellIndex):null;if(i){const t=sn(r);for(const e of t)e.visualRowIndex<a.rowIndex&&e.visualRowIndex+e.rowSpan>a.rowIndex&&(e.cell.rowSpan=Math.max(1,e.cell.rowSpan??1)-1,e.cell.rowSpan<=1?(e.cell.rowSpan=void 0,e.cell.vMerge=void 0):e.cell.vMerge="restart")}r.rows.splice(a.rowIndex,1);const s=r.rows[Math.min(a.rowIndex,r.rows.length-1)],d=s?zL(s,Math.min((null==l?void 0:l.visualColumnIndex)??a.cellIndex,Math.max(0,RL(s)-1))):null,c=(null==d?void 0:d.blocks[0])??NL(r);return c?{...OL(e,n,a.zone),selection:{anchor:Ve(c,0),focus:Ve(c,0)}}:OL(e,n,a.zone)},insertSelectedTableColumn:(e,a)=>{var n;const r=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!r)return e;const o=t.getTargetBlocks(e,r.zone).map(Rx),i=o[r.blockIndex];if(!i||"table"!==i.type)return e;if(i.rows.some(t=>t.cells.some(t=>Math.max(1,t.colSpan??1)>1))){const t=sn(i).find(t=>t.rowIndex===r.rowIndex&&t.cellIndex===r.cellIndex),n=((null==t?void 0:t.visualColumnIndex)??r.cellIndex)+(a>0?Math.max(1,(null==t?void 0:t.colSpan)??1):0);for(const e of i.rows){const t=[];let a=0,r=!1;for(const o of e.cells){const e=Math.max(1,o.colSpan??1);!r&&n<=a&&(t.push(Ia([Sa("")])),r=!0),!r&&a<n&&n<a+e?(t.push({...o,colSpan:e+1}),r=!0):t.push(o),a+=e}r||t.push(Ia([Sa("")])),e.cells=t}const l=i.rows[r.rowIndex],s=l?zL(l,n):null,d=(null==s?void 0:s.blocks[0])??NL(i);return d?{...OL(e,o,r.zone),selection:{anchor:Ve(d,0),focus:Ve(d,0)}}:OL(e,o,r.zone)}const l=Math.max(0,Math.min((null==(n=i.rows[0])?void 0:n.cells.length)??0,r.cellIndex+(a>0?1:0)));for(const t of i.rows)t.cells.splice(l,0,Ia([Sa("")]));const s=i.rows[r.rowIndex],d=null==s?void 0:s.cells[l],c=(null==d?void 0:d.blocks[0])??NL(i);return c?{...OL(e,o,r.zone),selection:{anchor:Ve(c,0),focus:Ve(c,0)}}:OL(e,o,r.zone)},deleteSelectedTableColumn:e=>{var a;const n=_e(e.document,e.selection.focus.paragraphId,sa(e));if(!n)return e;const r=t.getTargetBlocks(e,n.zone).map(Rx),o=r[n.blockIndex];if(!o||"table"!==o.type)return e;if(LL(o)<=1)return e;if(o.rows.some(t=>t.cells.some(t=>Math.max(1,t.colSpan??1)>1))){const t=sn(o).find(t=>t.rowIndex===n.rowIndex&&t.cellIndex===n.cellIndex),a=(null==t?void 0:t.visualColumnIndex)??n.cellIndex;for(const e of o.rows){const t=[];let n=0;for(const r of e.cells){const e=Math.max(1,r.colSpan??1);a>=n&&a<n+e?e>1&&t.push({...r,colSpan:e-1>1?e-1:void 0}):t.push(r),n+=e}e.cells=t}const i=o.rows[n.rowIndex],l=i&&zL(i,Math.min(a,Math.max(0,RL(i)-1))),s=(null==l?void 0:l.blocks[0])??NL(o);return s?{...OL(e,r,n.zone),selection:{anchor:Ve(s,0),focus:Ve(s,0)}}:OL(e,r,n.zone)}if((null==(a=o.rows[0])?void 0:a.cells.length)<=1)return e;for(const t of o.rows)t.cells.splice(n.cellIndex,1);const i=o.rows[n.rowIndex],l=null==i?void 0:i.cells[Math.min(n.cellIndex,i.cells.length-1)],s=(null==l?void 0:l.blocks[0])??NL(o);return s?{...OL(e,r,n.zone),selection:{anchor:Ve(s,0),focus:Ve(s,0)}}:OL(e,r,n.zone)}}}({getTargetBlocks:e}),{withExpandedTableCellSelection:A,applySelectionAwareTextCommand:I,applySelectionAwareParagraphCommand:T}=function(t){const e=e=>{const a=t.resolveTableCellRangeSelection(e);return a?t.applySelectionToStatePreservingStructure(e,a):e},a=(a,n)=>{t.applyTransactionalState(r=>{var o,i,l;const s=t.resolveSelectedTableCells(r);if(!s||s.cells.length<=1){const i=e(r);return i!==r&&(null==(o=t.logger)||o.info(`${n}: expanded selection to ${i.selection.anchor.paragraphId}[${i.selection.anchor.offset}]..${i.selection.focus.paragraphId}[${i.selection.focus.offset}]`)),a(i)}const{blockIndex:d,cells:c,zone:h}=s;null==(i=t.logger)||i.info(`${n}: multi-cell selection in table block ${d} (${c.length} cells) in zone ${h}`);const p=[],u=[];for(const t of c)p.push(...t.cell.blocks),u.push(t.cell.blocks.length);if(0===p.length)return r;const f={...r,document:Ea(p,void 0,void 0,void 0,void 0,r.document.assets),selection:{anchor:Ve(p[0],0),focus:Ve(p[p.length-1],Ce(p[p.length-1]).length)}},g=ha(a(f)),m=t.getTargetBlocks(r,h),v=Rx(m[d]);if(!v)return r;const b=m.map((t,e)=>e===d?v:t),y=v;let M=0;for(let t=0;t<c.length;t+=1){const e=c[t],a=u[t],n=g.slice(M,M+a);M+=a;const r=null==(l=y.rows[e.rowIndex])?void 0:l.cells[e.cellIndex];r&&(r.blocks=n)}return OL(r,b,h)})};return{withExpandedTableCellSelection:e,applySelectionAwareTextCommand:t=>{a(t,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:t=>{a(t,"applySelectionAwareParagraphCommand")}}}({applyTransactionalState:t.applyTransactionalState,applySelectionToStatePreservingStructure:t.applySelectionToStatePreservingStructure,getTargetBlocks:e,resolveTableCellRangeSelection:a,resolveSelectedTableCells:n,logger:t.logger});return{resolveTableCellRangeSelection:a,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:o,canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:d,canSplitSelectedTableCellVertically:c,canSplitSelectedTable:h,canEditSelectedTableRow:p,canEditSelectedTableColumn:u,mergeSelectedTableCells:f,mergeSelectedTableRows:g,mergeSelectedTable:m,splitSelectedTableCellVertically:v,splitSelectedTableCell:b,splitSelectedTable:y,insertSelectedTableRow:M,deleteSelectedTableRow:x,insertSelectedTableColumn:w,deleteSelectedTableColumn:S,getRowVisualWidth:RL,getTableVisualWidth:LL,findCellAtVisualColumn:zL,findFirstNavigableParagraphInTable:NL,updateBlocksInCurrentSection:OL,resolveAdjacentTableCellPosition:qL,applyTableAwareParagraphEdit:(t,a)=>((t,e,a)=>{var n;const r=_e(t.document,t.selection.focus.paragraphId,sa(t));if(!r||t.selection.anchor.paragraphId!==t.selection.focus.paragraphId)return a(t);const o=r.zone,i=e(t,o),l=Rx(i[r.blockIndex]);if(!l||"table"!==l.type)return a(t);const s=i.map((t,e)=>e===r.blockIndex?l:t),d=null==(n=l.rows[r.rowIndex])?void 0:n.cells[r.cellIndex];if(!d)return a(t);const c=a({...t,document:Ea(d.blocks,void 0,void 0,void 0,void 0,t.document.assets),selection:{anchor:{...t.selection.anchor},focus:{...t.selection.focus}}}),h=Je(c.document).filter(t=>"paragraph"===t.type);return d.blocks.splice(0,d.blocks.length,...h),{...OL(t,s,o),selection:c.selection}})(t,e,a),withExpandedTableCellSelection:A,applySelectionAwareTextCommand:I,applySelectionAwareParagraphCommand:T,insertTableCommand:(e,a)=>{var n;null==(n=t.logger)||n.info(`insertTableCommand: ${e}x${a}`),t.applyTransactionalState(t=>function(t,e,a){const n=100/Math.max(1,a)+"%",r=[];for(let g=0;g<e;g+=1){const t=[];for(let e=0;e<a;e+=1)t.push({...Ia([Sa("")]),style:{width:n}});r.push(Ta(t))}const o={...Ca(r),style:{width:"100%"}},i=ua(t,t.selection.focus),l=Be(t.document),s=sa(t),d=da(t),c=t=>{const e=t.findIndex(t=>t.id===i.paragraphId||"paragraph"!==t.type&&Ge(t).some(t=>t.id===i.paragraphId));return-1===e?{nextBlocks:t,found:!1}:{nextBlocks:[...t.slice(0,e+1),o,...t.slice(e+1)],found:!0}},h=l[s];if(!h)return t;const p={...h};let u=!1;if("header"===d){const t=c(h.header??[]);p.header=t.nextBlocks,u=t.found}else if("footer"===d){const t=c(h.footer??[]);p.footer=t.nextBlocks,u=t.found}else{const t=c(h.blocks);p.blocks=t.nextBlocks,u=t.found}if(!u)return t;const f=[...l];return f[s]=p,{...t,document:{...t.document,sections:f},selection:KT(Ve(o.rows[0].cells[0].blocks[0],0))}}(t,e,a),{mergeKey:"insertTable"}),t.focusInput()}}}function UL(t,e){let a=null;const n=(t,e,a)=>{const n=ha(t).find(t=>t.id===e);return n?{anchor:Ve(n,a),focus:Ve(n,a+1)}:null},r=(t,e)=>({...t,selection:{anchor:{...e.anchor},focus:{...e.focus}}}),o=o=>{var i;const l=a;if(!l)return;const s=(null==(i=e.zoomFactor)?void 0:i.call(e))??1,d=(o.clientX-l.startClientX)/s,c=(o.clientY-l.startClientY)/s,h=t.getMaxWidth(e.state,l.paragraphId),{width:p,height:u}=function(t,e,a,n,r){const o=ly(t.handleDirection,"x"),i=ly(t.handleDirection,"y"),l=0===o?t.startWidth:t.startWidth+e*o,s=0===i?t.startHeight:t.startHeight+a*i;let d=iy(l,oy,r),c=iy(s,oy);if(!n)return{width:d,height:c};const h=t.aspectRatio||1,p=0!==o;if(p&&0!==i){const e=d/t.startWidth,a=c/t.startHeight,n=Math.abs(e-1)>=Math.abs(a-1)?e:a;return d=iy(t.startWidth*n,oy,r),c=iy(d/h,oy),{width:d,height:c}}return p?(d=iy(d,oy,r),c=iy(d/h,oy),{width:d,height:c}):(c=iy(c,oy),d=iy(c*h,oy,r),c=iy(d/h,oy),{width:d,height:c})}(l,d,c,o.shiftKey,h),f=n(e.state,l.paragraphId,l.paragraphOffset);f?e.applyState(t.applyResize(r(e.state,f),p,u,l.handleDirection)):e.logger.warn(`${t.label} resize:missing paragraph`,l)},i=()=>{const t=a;t&&e.updateHistoryState(a=>({...a,undoStack:[...a.undoStack,e.cloneState(t.initialState)],redoStack:[]})),l(),e.focusInput()},l=()=>{a=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",i)};return{start:(l,s,d,c,h)=>{const p=n(h,l,s);if(!p)return;const u=t.getSelected(r(h,p));u&&(a={paragraphId:l,paragraphOffset:s,handleDirection:d,startClientX:c.clientX,startClientY:c.clientY,startWidth:u.width,startHeight:u.height,aspectRatio:u.width/u.height,initialState:e.cloneState(h)},window.addEventListener("mousemove",o),window.addEventListener("mouseup",i))},stop:l}}function FL(t,e){let a=null;const n=n=>{const r=a;if(!r)return;let o=((180*Math.atan2(n.clientY-r.centerY,n.clientX-r.centerX)/Math.PI+90)%360+360)%360;n.shiftKey&&(o=15*Math.round(o/15)%360);const i=((t,e,a)=>{const n=ha(t).find(t=>t.id===e);return n?{anchor:Ve(n,a),focus:Ve(n,a+1)}:null})(e.state,r.paragraphId,r.paragraphOffset);i?e.applyState(t.applyRotate(((t,e)=>({...t,selection:{anchor:{...e.anchor},focus:{...e.focus}}}))(e.state,i),o)):e.logger.warn(`${t.label} rotate:missing paragraph`,r)},r=()=>{const t=a;t&&e.updateHistoryState(a=>({...a,undoStack:[...a.undoStack,e.cloneState(t.initialState)],redoStack:[]})),o(),e.focusInput()},o=()=>{a=null,window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",r)};return{start:(t,o,i,l)=>{const s=i.currentTarget.closest(".oasis-editor-selection-overlay");if(!s)return;const d=s.getBoundingClientRect();a={paragraphId:t,paragraphOffset:o,centerX:d.left+d.width/2,centerY:d.top+d.height/2,initialState:e.cloneState(l)},window.addEventListener("mousemove",n),window.addEventListener("mouseup",r)},stop:o}}function BL(t){const[e,a]=y(!1),[n,r]=y(null),[o,i]=y({x:0,y:0}),[l,s]=y(null);let d=null,c=null,h=null;const p=t=>{const e=va(t);if(e.isCollapsed||e.startIndex!==e.endIndex||e.endParagraphOffset-e.startParagraphOffset!==1)return null;const a=ha(t)[e.startIndex];if(!a)return null;let n=0;for(const r of a.runs){const o=n;if(n+=r.text.length,r.image&&1===r.text.length&&o===e.startParagraphOffset)return{paragraph:a,run:r,startOffset:o,width:r.image.width,height:r.image.height,src:Ue(t.document,r.image.src)}}return null},u=(e,a)=>t.resolvePositionAtSurfacePoint(e,a),f=()=>{h&&(h.remove(),h=null),document.body.style.cursor="",c=null,d=null,a(!1),r(null),s(null),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b)},g=UL({label:"image",getSelected:t=>p(t),applyResize:(t,e,a)=>function(t,e,a){const n=lL(t);if(!n)return t;const r=ha(t),{paragraphIndex:o,run:i}=n,l=r.map((t,n)=>n!==o?TT(t):{...TT(t),runs:t.runs.map(t=>t.id===i.id&&t.image?{...t,image:{...t.image,width:Math.max(24,Math.round(e)),height:Math.max(24,Math.round(a))}}:IT(t))});return ZT(t,l,YT(l,va(t)))}(t,e,a),getMaxWidth:(e,a)=>uL(t.surfaceRef(),e.document,a,e.activeSectionIndex??0)},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger,zoomFactor:t.zoomFactor}),m=FL({label:"image",applyRotate:(t,e)=>sL(t,e)},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger}),v=e=>{let n=d;if(!n){const r=c;if(!r)return;if(Math.abs(e.clientX-r.startClientX)+Math.abs(e.clientY-r.startClientY)<4)return;n={paragraphId:r.paragraphId,paragraphOffset:r.paragraphOffset,src:r.src,width:r.width,height:r.height,offsetX:r.offsetX,offsetY:r.offsetY},d=n,c=null,a(!0),h||(h=document.createElement("style"),h.setAttribute("data-oasis-image-drag-cursor",""),h.textContent="*, *::before, *::after { cursor: grabbing !important; }",document.head.appendChild(h)),t.logger.info(`image drag:start ${n.paragraphId}@${n.paragraphOffset} client=(${e.clientX},${e.clientY})`)}i({x:e.clientX,y:e.clientY}),r({...n}),s(u(e.clientX,e.clientY))},b=e=>{const a=d;if(a||c){if(a){const n=u(e.clientX,e.clientY);n?(t.logger.info(`image drag:done ${a.paragraphId} -> ${n.paragraphId}:${n.runId}[${n.offset}]`),t.applyTransactionalState(t=>pL(t,n),{mergeKey:"moveImage"})):t.logger.warn(`image drag:cancel ${a.paragraphId} no target at (${e.clientX},${e.clientY})`)}f(),t.focusInput()}else t.focusInput()},M=(e,n,o,l)=>{const h=o.currentTarget,u=l?{left:l.left,top:l.top,width:l.width,height:l.height}:null==h?void 0:h.getBoundingClientRect();if(!u)return;const f=p(t.state);c={paragraphId:e,paragraphOffset:n,startClientX:o.clientX,startClientY:o.clientY,src:(null==f?void 0:f.src)??"",width:(null==f?void 0:f.width)??u.width,height:(null==f?void 0:f.height)??u.height,offsetX:o.clientX-u.left,offsetY:o.clientY-u.top},d=null,i({x:o.clientX,y:o.clientY}),a(!1),r(null),s(null),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b)};return{dragging:e,draggedImageInfo:n,mousePos:o,dropTargetPos:l,getSelectedImageInfo:p,startImageDrag:M,stopImageDrag:()=>{f()},stopImageResize:g.stop,stopImageRotate:m.stop,handleImageMouseDown:(e,a,n)=>{n.preventDefault(),n.stopPropagation();const r=Je(t.state.document).find(t=>t.id===e);r&&t.applyState(YC(t.state,{anchor:Ve(r,a),focus:Ve(r,a+1)})),M(e,a,n),t.focusInputAfterPointerSelection()},handleImageResizeHandleMouseDown:(e,a,n,r)=>{r.preventDefault(),r.stopPropagation(),g.start(e,a,n,r,t.state)},handleImageRotateHandleMouseDown:(e,a,n)=>{n.preventDefault(),n.stopPropagation(),m.start(e,a,n,t.state)}}}function GL(t){const[e,a]=y(void 0),n=()=>{a(void 0)};x(()=>{ma(t.state().selection)||n()});const r=()=>{const a=ep(t.state()),n=e();return ma(t.state().selection)&&n?{...a,bold:n.bold??a.bold,italic:n.italic??a.italic,underline:n.underline??a.underline,underlineStyle:void 0!==n.underlineStyle&&null!==n.underlineStyle?String(n.underlineStyle):a.underlineStyle,strike:n.strike??a.strike,superscript:n.superscript??a.superscript,subscript:n.subscript??a.subscript,fontFamily:n.fontFamily??a.fontFamily,fontSize:void 0!==n.fontSize&&null!==n.fontSize?String(n.fontSize):a.fontSize,color:n.color??a.color,highlight:n.highlight??a.highlight,textShading:n.shading??a.textShading,link:n.link??a.link}:a};return{pendingCaretTextStyle:e,clearPendingCaretTextStyle:n,toolbarStyleState:r,applyToolbarValueStyleCommand:(e,n)=>{if(ma(t.state().selection))return t.logger.info(`setPendingStyle:${e}=${JSON.stringify(n)}`),t.clearPreferredColumn(),t.resetTransactionGrouping(),((t,e)=>{a(a=>{const n={...a??{}};return null==e||""===e?delete n[t]:n[t]=e,Object.keys(n).length>0?n:void 0})})(e,n),void t.focusInput();t.commandsController().applyValueStyleCommand(e,n)},applyToolbarBooleanStyleCommand:e=>{if(ma(t.state().selection)){const n=!r()[e];return t.logger.info(`setPendingStyle:${e}=${JSON.stringify(n)}`),t.clearPreferredColumn(),t.resetTransactionGrouping(),((t,e)=>{a(a=>{const n={...a??{}};return n[t]=e,"superscript"===t&&e&&(n.subscript=!1),"subscript"===t&&e&&(n.superscript=!1),n})})(e,n),void t.focusInput()}t.commandsController().applyBooleanStyleCommand(e)}}}function ZL(t){const[e,a]=y(""),[n,r]=y(""),[o,i]=y({matchCase:!1,wholeWord:!1}),[l,s]=y([]),[d,c]=y(-1),[h,p]=y(!1);x(A([()=>t.state.document,e,o],([t,e,a])=>{const n=function(t,e,a={}){if(!e)return[];const n=[],r=Je(t),{matchCase:o=!1,wholeWord:i=!1}=a,l=o?"g":"gi";let s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i&&(s=`\\b${s}\\b`);const d=new RegExp(s,l);return r.forEach((t,e)=>{const a=Ce(t);let r;for(d.lastIndex=0;null!==(r=d.exec(a));){const a=r.index,o=r.index+r[0].length;n.push({anchor:Ve(t,a),focus:Ve(t,o),paragraphIndex:e}),r.index===d.lastIndex&&d.lastIndex++}}),n}(t,e,a);s(n),0===n.length?c(-1):(d()>=n.length||-1===d())&&c(0)}));const u=e=>{const a=l()[e];a&&t.applyState(YC(t.state,{anchor:a.anchor,focus:a.focus}))};return{searchTerm:e,setSearchTerm:a,replaceTerm:n,setReplaceTerm:r,findOptions:o,setFindOptions:i,matches:l,currentIndex:d,findNext:()=>{const t=l().length;if(0===t)return;const e=(d()+1)%t;c(e),u(e)},findPrevious:()=>{const t=l().length;if(0===t)return;const e=(d()-1+t)%t;c(e),u(e)},replace:()=>{if(0===l().length||-1===d())return;const e=l()[d()];t.applyTransactionalState(t=>aC(YC(t,{anchor:e.anchor,focus:e.focus}),n()),{mergeKey:"findReplace"})},replaceAll:()=>{const e=l();0!==e.length&&(t.applyTransactionalState(t=>{let a=t;for(let r=e.length-1;r>=0;r--){const t=e[r];a=YC(a,{anchor:t.anchor,focus:t.focus}),a=aC(a,n())}return a},{mergeKey:"findReplaceAll"}),p(!1),t.focusInput())},isOpen:h,setIsOpen:p}}function DL(t,e,a,n,r,o){const i=t+a,l=e+n;return 1e3*(o<e?e-o:o>l?o-l:0)+(r<t?t-r:r>i?r-i:0)}function KL(t,e,a){if(0===t.slots.length)return{offset:t.startOffset,score:Number.POSITIVE_INFINITY};let n=t.slots[0].offset,r=Number.POSITIVE_INFINITY,o=t.slots[0].left,i=t.slots[0].top,l=t.slots[0].height;for(const s of t.slots){const t=1e3*(a<s.top?s.top-a:a>s.top+s.height?a-(s.top+s.height):0)+Math.abs(e-s.left);t<r&&(r=t,n=s.offset,o=s.left,i=s.top,l=s.height)}return{offset:n,score:r,slotLeft:o,slotTop:i,slotHeight:l}}function jL(t,e,a){let n=t.startOffset,r=Number.POSITIVE_INFINITY;for(const o of t.lines){const{offset:t,score:i}=KL(o,e,a);i<r&&(r=i,n=t)}return Math.max(t.startOffset,Math.min(n,t.endOffset))}function XL(t,e,a){return t>=a.left&&t<=a.left+a.width&&e>=a.top&&e<=a.top+a.height}function JL(t){var e,a,n;const{snapshot:r,state:o}=t,i=t.pierce??!1,l=t.zoomFactor&&t.zoomFactor>0?t.zoomFactor:1,s=r.surfaceRect,d=s.left+(t.clientX-s.left)/l,c=s.top+(t.clientY-s.top)/l,h=function(t,e,a){if(0===t.length)return null;let n=t[0],r=Number.POSITIVE_INFINITY;for(const o of t){const t=DL(o.left,o.top,o.width,o.height,e,a);t<r&&(r=t,n=o)}return n}(r.pages,d,c);if(!h)return null;const p=function(t,e){const a=e-t.top;return a<t.bodyTop?"header":void 0!==t.footnoteSeparatorTop&&a>=t.footnoteSeparatorTop&&a<(t.footerTop??t.height)?"footnote":a>=t.bodyBottom?"footer":"main"}(h,c),u=function(t,e,a,n,r,o){for(let i=t.floatingTextBoxes.length-1;i>=0;i-=1){const l=t.floatingTextBoxes[i];if(l.pageIndex===e&&l.zone===a&&(!l.behindDoc||o)&&n>=l.left&&n<=l.left+l.width&&r>=l.top&&r<=l.top+l.height)return l}return null}(r,h.index,p,d,c,i);if(u){const t=r.paragraphsById.get(u.paragraphId)??[],a=t.find(t=>t.pageIndex===h.index&&t.zone===p&&u.startOffset>=t.startOffset&&u.startOffset<=t.endOffset)??t[0];if(a){const t=Math.max(a.startOffset,Math.min(u.startOffset,a.endOffset)),n=Ve(a.paragraph,t);return{zone:p,footnoteId:a.footnoteId,paragraphId:u.paragraphId,paragraphOffset:t,position:n,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:null==(e=a.tableCell)?void 0:e.anchorPosition,caretViewport:{left:u.left,top:u.top,height:u.height},textBox:{paragraphId:u.paragraphId,paragraphOffset:t,startOffset:u.startOffset,endOffset:u.endOffset,left:u.left,top:u.top,width:u.width,height:u.height}}}}const f=function(t,e,a,n,r,o){for(let i=t.floatingImages.length-1;i>=0;i-=1){const l=t.floatingImages[i];if(l.pageIndex===e&&l.zone===a&&(!l.behindDoc||o)&&XL(n,r,l))return l}for(const i of t.inlineImages)if(i.pageIndex===e&&i.zone===a&&XL(n,r,i))return i;return null}(r,h.index,p,d,c,i);if(f){const t=r.paragraphsById.get(f.paragraphId)??[],e=t.find(t=>t.pageIndex===h.index&&t.zone===p&&f.startOffset>=t.startOffset&&f.startOffset<=t.endOffset)??t[0];if(e){const t=Math.max(e.startOffset,Math.min(f.startOffset,e.endOffset)),n=Ve(e.paragraph,t);return{zone:p,footnoteId:e.footnoteId,paragraphId:f.paragraphId,paragraphOffset:t,position:n,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:null==(a=e.tableCell)?void 0:a.anchorPosition,caretViewport:{left:f.left,top:f.top,height:f.height},image:{paragraphId:f.paragraphId,paragraphOffset:t,startOffset:f.startOffset,endOffset:f.endOffset,left:f.left,top:f.top,width:f.width,height:f.height}}}}const g=function(t,e,a){if(0===t.length)return null;let n=null;for(const i of t)for(const t of i.lines){const r=t.top-2,o=t.top+t.height+2;if(a<r||a>o)continue;const{offset:l,score:s,slotLeft:d,slotTop:c,slotHeight:h}=KL(t,e,a);(!n||s<n.score)&&(n={paragraph:i,offset:l,score:s,caretViewport:void 0!==d&&void 0!==c&&void 0!==h?{left:d,top:c,height:h}:void 0})}if(n)return{paragraph:n.paragraph,offset:n.offset,caretViewport:n.caretViewport};let r=null,o=Number.POSITIVE_INFINITY;for(const i of t){const t=DL(i.left,i.top,Math.max(1,i.width),Math.max(1,i.height),e,a);t<o&&(o=t,r=i)}return r?{paragraph:r,offset:jL(r,e,a),caretViewport:{left:r.left,top:r.top,height:Math.max(16,Math.min(32,r.height||24))}}:null}(r.paragraphs.filter(t=>t.pageIndex===h.index&&t.zone===p),d,c);if(!g){const t=o.selection.focus.paragraphId,e=o.selection.focus.offset,a=function(t,e,a,n,r){const o=t.unsupportedRegions.find(t=>t.pageIndex===e&&t.zone===a&&n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height);return(null==o?void 0:o.reason)??null}(r,h.index,p,d,c);return{zone:p,paragraphId:t,paragraphOffset:e,position:{...o.selection.focus},source:"canvas-layout",resolvedFromParagraph:!1,missReason:a??"zone-without-paragraph"}}const m=g.paragraph,v=Math.max(0,Math.min(g.offset,m.textLength)),b=Ve(m.paragraph,v);return{zone:p,footnoteId:m.footnoteId,paragraphId:m.paragraphId,paragraphOffset:v,position:b,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:null==(n=m.tableCell)?void 0:n.anchorPosition,caretViewport:g.caretViewport}}function YL(t){let e=null;return{resolveSurfaceHitAtPoint:(a,n,r={})=>{const o=t.surfaceRef(),i=t.viewportRef();if(!o)return null;const l=t.measuredBlockHeights(),s=t.measuredParagraphLayouts(),d=t.state(),c=(null==i?void 0:i.scrollTop)??0,h=(null==i?void 0:i.scrollLeft)??0,p=window.innerWidth,u=window.innerHeight,f=t.zoomFactor(),g=e&&e.documentRef===d.document&&e.measuredBlockHeightsRef===l&&e.measuredParagraphLayoutsRef===s&&e.surfaceRef===o&&e.viewportScrollTop===c&&e.viewportScrollLeft===h&&e.surfaceClientWidth===o.clientWidth&&e.surfaceClientHeight===o.clientHeight&&e.windowWidth===p&&e.windowHeight===u&&e.zoomFactor===f,m=g?e.snapshot:qs({surface:o,state:d,measuredBlockHeights:l,measuredParagraphLayouts:s,zoomFactor:f});if(g||(e={snapshot:m,documentRef:d.document,measuredBlockHeightsRef:l,measuredParagraphLayoutsRef:s,surfaceRef:o,viewportScrollTop:c,viewportScrollLeft:h,surfaceClientWidth:o.clientWidth,surfaceClientHeight:o.clientHeight,windowWidth:p,windowHeight:u,zoomFactor:f}),function(t){dT&&(hT=t?function(t){return{surfaceRect:{left:t.surfaceRect.left,top:t.surfaceRect.top,width:t.surfaceRect.width,height:t.surfaceRect.height},pages:(e=t.pages,e.map(t=>({index:t.index,left:t.left,top:t.top,width:t.width,height:t.height,bodyTop:t.bodyTop,bodyBottom:t.bodyBottom}))),paragraphs:t.paragraphs.map(t=>{return{paragraphId:t.paragraphId,paragraphIndex:t.paragraphIndex,zone:t.zone,pageIndex:t.pageIndex,startOffset:t.startOffset,endOffset:t.endOffset,textLength:t.textLength,left:t.left,top:t.top,width:t.width,height:t.height,lines:(e=t.lines,e.map(t=>{return{startOffset:t.startOffset,endOffset:t.endOffset,top:t.top,height:t.height,slots:(e=t.slots,e.map(t=>({offset:t.offset,left:t.left,top:t.top,height:t.height})))};var e})),tableCell:t.tableCell?{tableId:t.tableCell.tableId,rowIndex:t.tableCell.rowIndex,cellIndex:t.tableCell.cellIndex,left:t.tableCell.left,top:t.tableCell.top,width:t.tableCell.width,height:t.tableCell.height}:void 0,verticalMode:t.verticalMode};var e}),inlineImages:t.inlineImages.map(t=>({paragraphId:t.paragraphId,paragraphIndex:t.paragraphIndex,zone:t.zone,pageIndex:t.pageIndex,startOffset:t.startOffset,endOffset:t.endOffset,left:t.left,top:t.top,width:t.width,height:t.height})),inlineTextBoxes:t.inlineTextBoxes.map(t=>({paragraphId:t.paragraphId,paragraphIndex:t.paragraphIndex,zone:t.zone,pageIndex:t.pageIndex,startOffset:t.startOffset,endOffset:t.endOffset,left:t.left,top:t.top,width:t.width,height:t.height,rotation:t.rotation})),unsupportedRegions:t.unsupportedRegions.map(t=>({...t}))};var e}(t):null)}(m),!m)return gT(null),null;const v=JL({snapshot:m,state:d,clientX:a,clientY:n,pierce:r.pierce??!1,zoomFactor:f});return gT(v),v}}}const QL=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],_L=new Map;function $L(){return QL.map(t=>({...t}))}const tz=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function ez(t,e,a){const[n,r]=t,[o,i]=e,[l,s]=a,d=l-o,c=s-i,h=d*d+c*c;if(0===h)return Math.hypot(n-o,r-i);return Math.abs(d*(i-r)-c*(o-n))/Math.sqrt(h)}function az(t,e){if(t.length<3)return t.slice();let a=0,n=0;const r=t[0],o=t[t.length-1];for(let s=1;s<t.length-1;s+=1){const e=ez(t[s],r,o);e>a&&(a=e,n=s)}if(a<=e)return[r,o];const i=az(t.slice(0,n+1),e),l=az(t.slice(n),e);return[...i.slice(0,-1),...l]}function nz(t,e,a){let n=0;for(let s=0;s<t.length;s+=1)1===t[s]&&(n+=1);if(e<=0||a<=0||0===n||n/(e*a)>=.985)return $L();const r=function(t,e,a){const n=(n,r)=>n>=0&&n<e&&r>=0&&r<a&&1===t[r*e+n];let r=-1,o=-1;for(let h=0;h<a&&o<0;h+=1)for(let a=0;a<e;a+=1)if(1===t[h*e+a]){r=a,o=h;break}if(r<0)return[];const i=[];let l=r,s=o,d=6;const c=e*a*4;for(let h=0;h<c;h+=1){let t=!1;for(let e=1;e<=8;e+=1){const a=(d+e)%8,[r,o]=tz[a],c=l+r,h=s+o;if(n(c,h)){i.push([l,s]),d=(a+4)%8,l=c,s=h,t=!0;break}}if(!t){i.push([l,s]);break}if(l===r&&s===o&&i.length>1)break}return i}(t,e,a);if(r.length<3)return $L();const o=.012*Math.max(e,a);let i=az(r,o),l=o;for(;i.length>40;)l*=1.6,i=az(r,l);return i.length<3?$L():i.map(([t,n])=>({x:Math.min(1,Math.max(0,t/e)),y:Math.min(1,Math.max(0,n/a))}))}function rz(t){const e=t.src,a=_L.get(e);if(a)return a.map(t=>({...t}));const n=function(t){const e=t.naturalWidth||t.width,a=t.naturalHeight||t.height;if(!e||!a)return null;const n=Math.min(1,256/Math.max(e,a)),r=Math.max(1,Math.round(e*n)),o=Math.max(1,Math.round(a*n)),i=document.createElement("canvas");i.width=r,i.height=o;const l=i.getContext("2d",{willReadFrequently:!0});if(!l)return null;let s;l.drawImage(t,0,0,r,o);try{s=l.getImageData(0,0,r,o).data}catch{return null}const d=new Uint8Array(r*o);let c=0;for(let h=0;h<d.length;h+=1)s[4*h+3]>=128&&(d[h]=1,c+=1);return{mask:d,width:r,height:o,foreground:c}}(t);if(!n)return $L();const r=nz(n.mask,n.width,n.height);return _L.set(e,r),r.map(t=>({...t}))}function oz(t){const{state:e,resetTransactionGrouping:a,applyTransactionalState:n,focusInput:r}=t,o=()=>lL(e())?"image":CL(e())?"textBox":null,i=(t,e)=>{const i=o();i&&(a(),n(t=>e(t,i),{mergeKey:t}),r())},l=(t,a)=>{const r=Ue(e().document,a),o=e=>{const a=rz(e);n(e=>function(t,e,a){const n=ha(t);let r=!1;const o=n.map(t=>t.runs.some(t=>t.id===e&&t.image)?{...TT(t),runs:t.runs.map(t=>{if(t.id!==e||!t.image)return IT(t);r=!0;const n={...t.image};return a&&a.length>0?n.wrapPolygon=a:delete n.wrapPolygon,{...t,image:n}})}:TT(t));return r?ZT(t,o,YT(o,va(t))):t}(e,t,a),{mergeKey:"layoutWrapPolygon"})},i=Rc(r,()=>{i.naturalWidth>0&&o(i)});i.complete&&i.naturalWidth>0&&o(i)};return{target:o,preset:()=>{const t=o();return"image"===t?function(t){const e=lL(t);return(null==e?void 0:e.run.image)?rL(e.run.image.floating):null}(e()):"textBox"===t?function(t){const e=CL(t);return(null==e?void 0:e.run.textBox)?rL(e.run.textBox.floating):null}(e()):null},fixedPosition:()=>{const t=o();return"image"===t?function(t){var e;const a=lL(t);return iL(null==(e=null==a?void 0:a.run.image)?void 0:e.floating)}(e()):"textBox"===t&&function(t){var e;const a=CL(t);return iL(null==(e=null==a?void 0:a.run.textBox)?void 0:e.floating)}(e())},setPreset:t=>{if(i("layoutWrapPreset",(e,a)=>"image"===a?function(t,e){return dL(t,t=>nL(t,e))}(e,t):function(t,e){return VL(t,t=>nL(t,e))}(e,t)),"tight"===t||"through"===t){const t=lL(e()),a=null==t?void 0:t.run.image;a&&!a.wrapPolygon&&l(t.run.id,a.src)}},setFixedPosition:t=>i("layoutFixedPosition",(e,a)=>"image"===a?function(t,e){return dL(t,t=>t?oL(t,e):t)}(e,t):function(t,e){return VL(t,t=>t?oL(t,e):t)}(e,t))}}function iz(t,e){const a=function(t){return Fe(t.document).flatMap(t=>[...t.header??[],...t.blocks,...t.footer??[]])}(t).find(t=>"table"===t.type&&t.id===e);return a??null}function lz(t,e,a){const n=function(t,e){const a=qs({surface:t,state:e});if(!a)return[];const n=new Map,r=new Map;for(const i of a.paragraphs){const t=i.tableCell;if(!t)continue;const e=`${i.pageIndex}:${t.rowIndex}:${t.cellIndex}`,a=n.get(t.tableId)??new Map;let o=a.get(e);o||(o={tableId:t.tableId,rowIndex:t.rowIndex,cellIndex:t.cellIndex,pageIndex:i.pageIndex,left:t.left,top:t.top,right:t.left+t.width,bottom:t.top+t.height,width:t.width,height:t.height,contentMinWidth:0,contentMinHeight:0},a.set(e,o),n.set(t.tableId,a));const l=i.lines.flatMap(t=>t.slots.map(t=>t.left)),s=i.lines.map(t=>t.top+t.height),d=l.length>0?Math.min(...l):i.left,c=l.length>0?Math.max(...l):i.left,h=i.lines.length>0?i.lines[0].top:i.top,p=s.length>0?Math.max(...s):i.top+i.height,u=`${t.tableId}:${i.pageIndex}:${t.rowIndex}:${t.cellIndex}`,f=r.get(u);f?(f.left=Math.min(f.left,d),f.top=Math.min(f.top,h),f.right=Math.max(f.right,c),f.bottom=Math.max(f.bottom,p)):r.set(u,{left:d,top:h,right:c,bottom:p})}for(const[i,l]of n.entries())for(const t of l.values()){const e=r.get(`${i}:${t.pageIndex}:${t.rowIndex}:${t.cellIndex}`);e&&(t.contentMinWidth=Math.max(0,e.right-e.left),t.contentMinHeight=Math.max(0,e.bottom-e.top))}const o=[];for(const[i,l]of n.entries()){const t=Array.from(l.values());if(0===t.length)continue;const e=Math.min(...t.map(t=>t.left)),a=Math.min(...t.map(t=>t.top)),n=Math.max(...t.map(t=>t.right)),r=Math.max(...t.map(t=>t.bottom));o.push({tableId:i,cells:t,bounds:{left:e,top:a,right:n,bottom:r,width:Math.max(1,n-e),height:Math.max(1,r-a)}})}return o}(e,a);if(0===n.length)return null;let r=null;for(const l of n)for(const e of l.cells){const a=t.clientY>=e.top-4&&t.clientY<=e.bottom+4,n=t.clientX>=e.left-4&&t.clientX<=e.right+4;if(a){const a=Math.abs(t.clientX-e.left);a<=4&&(!r||a<r.distance)&&(r={geometry:l,cell:e,side:"left",distance:a});const n=Math.abs(t.clientX-e.right);n<=4&&(!r||n<r.distance)&&(r={geometry:l,cell:e,side:"right",distance:n})}if(n){const a=Math.abs(t.clientY-e.top);a<=4&&(!r||a<r.distance)&&(r={geometry:l,cell:e,side:"top",distance:a});const n=Math.abs(t.clientY-e.bottom);n<=4&&(!r||n<r.distance)&&(r={geometry:l,cell:e,side:"bottom",distance:n})}}if(!r)return null;const o=iz(a,r.geometry.tableId);if(!o)return null;const i=sn(o).find(t=>t.rowIndex===r.cell.rowIndex&&t.cellIndex===r.cell.cellIndex);return i?{tableId:r.geometry.tableId,rowIndex:r.cell.rowIndex,cellIndex:r.cell.cellIndex,side:r.side,rect:r.cell,tableNode:o,layoutEntry:i,tableGeometry:r.geometry}:null}const sz=1/.75,dz=10;function cz(t){return.75*t}function hz(t){return t*sz}function pz(t){if("number"==typeof t&&Number.isFinite(t))return t;if("string"!=typeof t)return null;const e=t.trim().toLowerCase();if(!e)return null;if(e.endsWith("pt")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t:null}if(e.endsWith("px")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?cz(t):null}if(e.includes("%"))return null;if(!/^[+-]?\d+(\.\d+)?$/.test(e))return null;const a=Number.parseFloat(e);return Number.isFinite(a)?a:null}function uz(t){var e,a,n,r,o;return("number"==typeof(null==(e=t.style)?void 0:e.padding)&&Number.isFinite(t.style.padding)?2*Math.max(0,hz(t.style.padding)):Math.max(0,(void 0!==(null==(a=t.style)?void 0:a.paddingLeft)?hz(t.style.paddingLeft):7.2)+(void 0!==(null==(n=t.style)?void 0:n.paddingRight)?hz(t.style.paddingRight):7.2)))+((null==(r=t.style)?void 0:r.borderLeft)?Math.max(0,hz(t.style.borderLeft.width)):1)+((null==(o=t.style)?void 0:o.borderRight)?Math.max(0,hz(t.style.borderRight.width)):1)}function fz(t,e,a){if("row"!==e.type)return t;const n=e.initialRowHeightPx??hz(dz),r=Math.max(hz(dz),e.minRowHeightPx??hz(dz)),o=Math.max(dz,cz(Math.max(r,n+a)));return function(t,e,a,n){const r=t=>{if(t.id!==e)return t;const r=[...t.rows],o=r[a];return o&&(r[a]={...o,style:gC(o.style,"height",n)}),{...t,rows:r}};return mC(t,t=>vC(t,r))}(t,e.tableId,e.index,o)}function gz(t){const e=t();if(!e)return{left:0,top:0,width:window.innerWidth,height:window.innerHeight};const a=e.getBoundingClientRect();return{left:a.left,top:a.top,width:Math.max(0,a.width),height:Math.max(0,a.height)}}function mz(t){t?(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 vz(){document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize")}function bz(t){mz(t)}function yz(t){const[e,a]=y(null),n=n=>{const r=e();r&&(a({...r,currentPos:"column"===r.type?n.clientX:n.clientY,guideBounds:gz(t.viewportRef)}),bz("column"===r.type))},r=o=>{var i;const l=e();if(!l)return;const s=(null==(i=t.zoomFactor)?void 0:i.call(t))??1,d=(("column"===l.type?o.clientX:o.clientY)-l.initialPos)/s;Math.abs(d)>=2&&t.applyTransactionalState(t=>"row"===l.type?fz(t,l,d):function(t,e,a){var n;if("column"!==e.type)return t;const r=cz(a),o=e.maxColumnIndex??e.index,i={...e.columnWidthsPt??{}};for(let m=0;m<=o;m+=1)void 0===i[m]&&(i[m]=dz);const l=e.minColumnWidthsPx??{},s=i[e.index]??dz,d=Math.max(dz,cz(l[e.index]??hz(dz)));if(e.resizeFromLeftEdge){const a=Math.max(0,e.initialTableIndentLeftPt??0);let n=Math.max(d,s-r),o=s-n;a+o<0&&(o=-a,n=s-o),i[e.index]=n;const l=Object.values(i).reduce((t,e)=>t+e,0),c=Math.max(0,a+o);return kC(t,e.tableId,i,l,c)}let c=Math.max(d,s+r);const h=e.index===o;if(h)i[e.index]=c;else{const t=e.index+1,a=i[t]??dz,n=Math.max(dz,cz(l[t]??hz(dz)));let r=a-(c-s);r<n&&(r=n,c=s+(a-n),c=Math.max(d,c)),i[e.index]=c,i[t]=r}const p=Object.values(i).reduce((t,e)=>t+e,0),u=iz(t,e.tableId),f=pz(null==(n=null==u?void 0:u.style)?void 0:n.width),g=h?p:null!==f?f:void 0;return kC(t,e.tableId,i,g)}(t,l,d)),a(null),vz(),window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",r)};return{resizing:e,handleMouseMove:a=>{if(e())return void bz("column"===e().type);const n=t.surfaceRef();if(!n)return void vz();const r=lz(a,n,t.state());r?mz("left"===r.side||"right"===r.side):vz()},handleMouseDown:e=>{var o;const i=t.surfaceRef();if(!i)return!1;const l=lz(e,i,t.state());if(!l)return!1;const s=t.state(),d=sn(l.tableNode);if("left"===l.side||"right"===l.side){const i="left"===l.side&&0===l.layoutEntry.visualColumnIndex,c=i?0:"left"===l.side?l.layoutEntry.visualColumnIndex-1:l.layoutEntry.visualColumnIndex+l.layoutEntry.colSpan-1;if(c<0)return!1;const h="left"===l.side?l.rect.left:l.rect.right,{widthsPt:p,maxColumnIndex:u}=function(t,e,a){const n=Math.max(1,...e.map(t=>t.visualColumnIndex+Math.max(1,t.colSpan))),r=n-1,o=Array(n).fill(a.bounds.width/n),i=new Map(a.cells.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t]));if(t.gridCols&&t.gridCols.length>=n)for(let s=0;s<n;s+=1)o[s]=Math.max(1,hz(t.gridCols[s]));else for(const s of e){if(1!==s.colSpan)continue;const t=i.get(`${s.rowIndex}:${s.cellIndex}`);t&&(o[s.visualColumnIndex]=Math.max(1,t.width))}const l={};for(let s=0;s<n;s+=1)l[s]=Math.max(dz,cz(o[s]));return{widthsPt:l,maxColumnIndex:r}}(l.tableNode,d,l.tableGeometry),f=function(t,e,a,n){var r;const o=hz(dz),i={},l=new Map(n.cells.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t]));for(const s of a){if(1!==s.colSpan)continue;if(!l.get(`${s.rowIndex}:${s.cellIndex}`))continue;const a=null==(r=e.rows[s.rowIndex])?void 0:r.cells[s.cellIndex];if(!a)continue;const n=s.visualColumnIndex,d=i[n]??o,c=a.blocks.reduce((e,a)=>Math.max(e,wi(a,t.document.styles)),1);i[n]=Math.max(d,c+uz(a)+12,o)}return i}(s,l.tableNode,d,l.tableGeometry);return a({type:"column",tableId:l.tableId,index:c,initialPos:h,currentPos:h,columnWidthsPt:p,maxColumnIndex:u,minColumnWidthsPx:f,resizeFromLeftEdge:i,initialTableIndentLeftPt:pz(null==(o=l.tableNode.style)?void 0:o.indentLeft)??0,guideBounds:gz(t.viewportRef)}),bz(!0),window.addEventListener("mousemove",n),window.addEventListener("mouseup",r),e.preventDefault(),e.stopPropagation(),!0}const c=function(t,e,a){var n,r;const o=Math.max(1,t.rows.length),i=a.bounds.height/o,l=Array(o).fill(i),s=new Map(a.cells.map(t=>[`${t.rowIndex}:${t.cellIndex}`,t]));for(let d=0;d<o;d+=1){const a=pz(null==(r=null==(n=t.rows[d])?void 0:n.style)?void 0:r.height);if(null!==a){l[d]=Math.max(1,hz(a));continue}const o=e.find(t=>t.rowIndex===d&&1===t.rowSpan);if(o){const t=s.get(`${o.rowIndex}:${o.cellIndex}`);t&&(l[d]=Math.max(1,t.height))}}return l}(l.tableNode,d,l.tableGeometry),h="top"===l.side?l.layoutEntry.visualRowIndex-1:l.layoutEntry.visualRowIndex+l.layoutEntry.rowSpan-1;if(h<0||h>=c.length)return!1;const p="top"===l.side?l.rect.top:l.rect.bottom,u=function(t,e,a,n){const r=t.rows[n];if(!r)return hz(dz);const o=hz(dz);let i=o;for(let l=0;l<r.cells.length;l+=1){if(!r.cells[l])continue;const t=e.find(t=>t.rowIndex===n&&t.cellIndex===l);if(!t||1!==t.rowSpan)continue;const o=a.cells.find(t=>t.rowIndex===n&&t.cellIndex===l);o&&(i=Math.max(i,o.contentMinHeight+4))}return Math.max(o,i)}(l.tableNode,d,l.tableGeometry,h);return a({type:"row",tableId:l.tableId,index:h,initialPos:p,currentPos:p,initialRowHeightPx:c[h],minRowHeightPx:u,guideBounds:gz(t.viewportRef)}),bz(!1),window.addEventListener("mousemove",n),window.addEventListener("mouseup",r),e.preventDefault(),e.stopPropagation(),!0}}}function Mz(t){const[e,a]=y(!1),[n,r]=y(null),[o,i]=y(null),[l,s]=y(0),[d,c]=y({x:0,y:0}),h=r=>{var o;if(c({x:r.clientX,y:r.clientY}),!e()){if(!(Math.abs(r.clientY-l())>4))return;a(!0),document.body.style.cursor="grabbing"}document.body.style.cursor="grabbing";const s=t.resolvePositionAtSurfacePoint(r.clientX,r.clientY),d=null==(o=n())?void 0:o.tableId;if(s&&d){const e=t.state(),a=_e(e.document,s.paragraphId,sa(e));if(a){const t=ca(e,a.zone)[a.blockIndex];if(t&&"table"===t.type&&t.id===d)return void i(null)}}i(s)},p=o=>{const l=n();if(e()){const e=t.resolvePositionAtSurfacePoint(o.clientX,o.clientY),a=null==l?void 0:l.tableId;e&&a&&t.applyTransactionalState(t=>hC(t,a,e))}a(!1),r(null),i(null),window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",p),document.body.style.cursor="",t.focusInput()};return{dragging:e,draggedTableInfo:n,mousePos:d,dropTargetPos:o,handleMouseDown:(t,e)=>{e.preventDefault(),e.stopPropagation();const n=e.currentTarget.getBoundingClientRect(),o=n;r({tableId:t,width:o.width,height:o.height,offsetX:e.clientX-n.left,offsetY:e.clientY-n.top}),s(e.clientY),c({x:e.clientX,y:e.clientY}),a(!1),i(null),window.addEventListener("mousemove",h),window.addEventListener("mouseup",p)}}}function xz(t){return/[\p{L}\p{N}_]/u.test(t)}function wz(t,e){if(0===t.length)return{start:0,end:0};const a=Math.max(0,Math.min(e,t.length)),n=a===t.length?Math.max(0,a-1):a,r=t[n];if(!r||!xz(r))return{start:a,end:Math.min(t.length,a+1)};let o=n,i=n+1;for(;o>0&&xz(t[o-1]);)o-=1;for(;i<t.length&&xz(t[i]);)i+=1;return{start:o,end:i}}function Sz(t,e,a){const n=Je(t.document).filter(e=>{const n=Qe(t.document,e.id);return null!==n&&n.zone===a}),r=n.findIndex(t=>t.id===e.id),o=r>=0?n[r+1]:void 0;return{start:Ve(e,0),end:o?Ve(o,0):Ve(e,Ce(e).length)}}function Az(t){let e=null,a=null,n=null,r=0,o=0,i=0,l=0,s=0,d=null,c=0,h=0,p=0;const u=(e,a,n,r)=>{var o;const i=a!==(e.activeZone??"main"),l="footnote"===a&&r?null==(o=Qe(n.document,r.paragraphId))?void 0:o.footnoteId:void 0,s="footnote"===a&&l!==e.activeFootnoteId;if(!i&&!s)return void t.applyState(n);let d=n.document,c=e.activeSectionIndex??0;if(!d.sections||0===d.sections.length){const t=La("header"),e=La("footer");d={...d,sections:[{id:"section:1",blocks:[],pageSettings:ye(d.pageSettings??be),header:[t],footer:[e]}]},c=0}const h=d.sections,p=h[c];let u=p.header,f=p.footer,g=null;if("header"===a)if(u&&0!==u.length){const t=u[0];g="paragraph"===t.type?t:Ge(t)[0]??null}else g=La("header"),u=[g];else if("footer"===a)if(f&&0!==f.length){const t=f[0];g="paragraph"===t.type?t:Ge(t)[0]??null}else g=La("footer"),f=[g];if(u!==p.header||f!==p.footer){const t=[...h];t[c]={...p,header:u,footer:f},d={...d,sections:t}}const m=r||(g?Ve(g,0):n.selection.anchor);t.applyState({...n,document:d,selection:{anchor:m,focus:m},activeSectionIndex:c,activeZone:a,activeFootnoteId:"footnote"===a?l:void 0})},f=e=>{const a=t.state(),n=a.selection,r=sa(a),o=_e(a.document,n.anchor.paragraphId,r),i=_e(a.document,n.focus.paragraphId,r),l=o?`b${o.blockIndex}r${o.rowIndex}c${o.cellIndex}`:"",s=i?`b${i.blockIndex}r${i.rowIndex}c${i.cellIndex}`:"";t.logger.debug(`${e} ${n.anchor.paragraphId}[${n.anchor.offset}]→${n.focus.paragraphId}[${n.focus.offset}] [${l}→${s}]`)},g=()=>{var t;e=null,n=null,null!==a&&(t=a,"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(t):window.cancelAnimationFrame(t),a=null),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b)},m=()=>{if(a=null,!e)return;const r=n;if(n=null,!r)return;const o=t.resolveSurfaceHitAtPoint(r.clientX,r.clientY,{forDrag:!0});if(!(null==o?void 0:o.resolvedFromParagraph))return;const i=t.state(),l=YC(i,{anchor:e,focus:o.position});u(i,o.zone,l,o.position),f("selection:drag")},v=t=>{var r;e&&(n={clientX:t.clientX,clientY:t.clientY},null===a&&(r=m,a="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>r()):globalThis.setTimeout(r,16)))},b=()=>{f("selection:end"),g(),t.focusInputAfterPointerSelection()},y=a=>{var n;if(0!==a.button)return;const f=Date.now(),m=Math.hypot(a.clientX-i,a.clientY-l),y=f-o<=450&&m<=6&&a.button===s;r=y?r+1:1,o=f,i=a.clientX,l=a.clientY,s=a.button;const M=Math.max(a.detail,r),x=t.state();if(t.clearPendingCaretTextStyle(),t.tableResize.handleMouseDown(a))return;a.preventDefault(),t.imageOps.stopImageDrag(),t.imageOps.stopImageResize(),t.clearPreferredColumn(),t.resetTransactionGrouping();const w=t.resolveSurfaceHitAtPoint(a.clientX,a.clientY,{pierce:a.altKey});if(d=w,c=f,h=a.clientX,p=a.clientY,!w)return void t.focusInputAfterPointerSelection();if(null==(n=t.textDrag)?void 0:n.tryStartTextDrag(a,w))return e=null,g(),void t.focusInputAfterPointerSelection();const S=t.getParagraphById(x.document,w.paragraphId);if(w.zone!==(x.activeZone??"main"))return M<2?(e=null,g(),void t.focusInputAfterPointerSelection()):(e=null,w.resolvedFromParagraph?u(x,w.zone,{...x,selection:{anchor:{...w.position},focus:{...w.position}}},w.position):u(x,w.zone,x),g(),void t.focusInputAfterPointerSelection());if(w.textBox){const a=t.getParagraphById(x.document,w.textBox.paragraphId);if(!a)return void t.focusInputAfterPointerSelection();e=null;const n=Ve(a,w.textBox.startOffset),r=Ve(a,w.textBox.endOffset);return u(x,w.zone,YC(x,{anchor:n,focus:r}),n),g(),void t.focusInputAfterPointerSelection()}if(w.image){const n=t.getParagraphById(x.document,w.image.paragraphId);if(!n)return void t.focusInputAfterPointerSelection();e=null;const r=Ve(n,w.image.startOffset),o=Ve(n,w.image.endOffset);return u(x,w.zone,YC(x,{anchor:r,focus:o}),r),g(),t.imageOps.startImageDrag(w.image.paragraphId,w.image.startOffset,a,{left:w.image.left,top:w.image.top,width:w.image.width,height:w.image.height}),void t.focusInputAfterPointerSelection()}if(a.shiftKey&&w.resolvedFromParagraph)return e=x.selection.anchor,u(x,w.zone,YC(x,{anchor:x.selection.anchor,focus:w.position}),w.position),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b),void t.focusInputAfterPointerSelection();if(M>=3&&S){e=null;const a=Sz(x,S,w.zone);return u(x,w.zone,YC(x,{anchor:a.start,focus:a.end}),a.start),g(),void t.focusInputAfterPointerSelection()}if(2===M&&S){e=null;const a=wz(Ce(S),w.paragraphOffset),n=Ve(S,a.start),r=Ve(S,a.end);return u(x,w.zone,YC(x,{anchor:n,focus:r}),n),g(),void t.focusInputAfterPointerSelection()}w.resolvedFromParagraph?(e=w.position,u(x,w.zone,{...x,selection:{anchor:{...w.position},focus:{...w.position}}},w.position),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b),t.focusInputAfterPointerSelection()):t.focusInputAfterPointerSelection()};return{handleSurfaceMouseDown:y,handleSurfaceClick:a=>{if(a.detail<3)return;a.preventDefault();const n=t.state(),r=Math.hypot(a.clientX-h,a.clientY-p),o=Date.now()-c<=600&&r<=8?d:t.resolveSurfaceHitAtPoint(a.clientX,a.clientY);if(!(null==o?void 0:o.resolvedFromParagraph))return void t.focusInputAfterPointerSelection();const i=t.getParagraphById(n.document,o.paragraphId);if(!i)return void t.focusInputAfterPointerSelection();e=null;const l=Sz(n,i,o.zone);u(n,o.zone,YC(n,{anchor:l.start,focus:l.end}),l.start),g(),t.focusInputAfterPointerSelection()},handleSurfaceDblClick:t=>{t.preventDefault()},handleParagraphMouseDown:(t,e)=>{0===e.button&&(e.preventDefault(),y(e))},stopDragging:g}}function Iz(t,e){const a=va(t);if(a.isCollapsed)return!1;const n=ha(t),r=n.findIndex(t=>t.id===e.paragraphId);if(r<a.startIndex||r>a.endIndex)return!1;const o=n[r];if(!o)return!1;const i=Ee(o,e);return!(r===a.startIndex&&i<a.startParagraphOffset)&&!(r===a.endIndex&&i>a.endParagraphOffset)}function Tz(t){const[e,a]=y(!1),[n,r]=y(null),[o,i]=y(!1),[l,s]=y(null),[d,c]=y(null);let h=null,p=null,u=null;const f=()=>{var l;null==(l=t.logger)||l.info("text-drag:stop",{dragging:e(),dropTarget:n()?`${n().paragraphId}:${n().runId}[${n().offset}]`:null,copyMode:o()}),h=null,u=null,a(!1),r(null),i(!1),s(null),c(null),p&&(p.remove(),p=null),window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",m)},g=n=>{var o,l,d;if(!h)return;const f=n.ctrlKey||n.metaKey;if(i(f),!e()){const e=Math.abs(n.clientX-h.x),r=Math.abs(n.clientY-h.y);if(e+r<4)return;null==(o=t.logger)||o.info("text-drag:activate",{start:h,at:{x:n.clientX,y:n.clientY},deltaX:e,deltaY:r}),a(!0),p||(p=document.createElement("style"),p.setAttribute("data-oasis-text-drag-cursor",""),p.textContent="*, *::before, *::after { cursor: 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 !important; }",document.head.appendChild(p))}s({x:n.clientX,y:n.clientY});const g=t.resolveSurfaceHitAtPoint(n.clientX,n.clientY);if(!(null==g?void 0:g.resolvedFromParagraph))return null==(l=t.logger)||l.debug("text-drag:hit-miss",{x:n.clientX,y:n.clientY}),r(null),void c(null);const m=g.tableCellAnchorPosition??g.position,v=`${m.paragraphId}:${m.runId}[${m.offset}]|${g.zone}|src=${g.tableCellAnchorPosition?"cell-anchor":"hit"}`;v!==u&&(null==(d=t.logger)||d.info("text-drag:target",{x:n.clientX,y:n.clientY,zone:g.zone,resolvedFromParagraph:g.resolvedFromParagraph,paragraphId:g.paragraphId,paragraphOffset:g.paragraphOffset,hitPosition:`${g.position.paragraphId}:${g.position.runId}[${g.position.offset}]`,target:`${m.paragraphId}:${m.runId}[${m.offset}]`,source:g.tableCellAnchorPosition?"tableCellAnchorPosition":"position"}),u=v),r(m),c(g.caretViewport??null)},m=a=>{var r,i,l;if(null==(r=t.logger)||r.info("text-drag:mouseup",{x:a.clientX,y:a.clientY,dragging:e(),copyMode:o(),dropTarget:n()?`${n().paragraphId}:${n().runId}[${n().offset}]`:null}),e()&&n()){const e=n(),a=o();t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(n=>t.applyTableAwareParagraphEdit(n,t=>eC(t,e,{copy:a})),{mergeKey:a?"copyTextByDrag":"moveTextByDrag"}),null==(i=t.logger)||i.info("text-drag:apply",{mode:a?"copy":"move",destination:`${e.paragraphId}:${e.runId}[${e.offset}]`})}else if(h){const e=h.position;t.applyTransactionalState(t=>Iz(t,e)?YC(t,{anchor:e,focus:e}):t,{mergeKey:"collapseSelectionByClick"}),null==(l=t.logger)||l.info("text-drag:collapse",{at:`${e.paragraphId}:${e.runId}[${e.offset}]`})}f(),t.focusInputAfterPointerSelection()};return{dragging:e,dropTargetPos:n,copyMode:o,pointerPos:l,caretViewport:d,tryStartTextDrag:(e,n)=>{var o,l,d;if(t.isReadOnly()||!(null==n?void 0:n.resolvedFromParagraph))return null==(o=t.logger)||o.debug("text-drag:skip-start",{reason:t.isReadOnly()?"readonly":"no-hit",x:e.clientX,y:e.clientY}),!1;return Iz(t.state(),n.position)?(null==(d=t.logger)||d.info("text-drag:start-pending",{x:e.clientX,y:e.clientY,hit:`${n.position.paragraphId}:${n.position.runId}[${n.position.offset}]`,zone:n.zone}),h={x:e.clientX,y:e.clientY,position:n.tableCellAnchorPosition??n.position},s({x:e.clientX,y:e.clientY}),i(e.ctrlKey||e.metaKey),r(null),c(n.caretViewport??null),a(!1),window.addEventListener("mousemove",g),window.addEventListener("mouseup",m),!0):(null==(l=t.logger)||l.debug("text-drag:skip-start",{reason:"outside-selection",x:e.clientX,y:e.clientY,hit:`${n.position.paragraphId}:${n.position.runId}[${n.position.offset}]`}),!1)},stopDrag:f}}function Cz(t){const e=(e,a)=>{var n,r,o,i,l,s;const d=t.state(),c=ha(d),h=c.findIndex(t=>t.id===d.selection.focus.paragraphId);if(-1===h)return!1;const p=t.surfaceRef(),u=(null==p?void 0:p.getBoundingClientRect())??null,f=t.preferredColumnX(),g=null===f?t.caretBox().left+((null==u?void 0:u.left)??0):f,m=p?qs({surface:p,state:d,zoomFactor:null==(n=t.zoomFactor)?void 0:n.call(t)}):null;let v=h+e;const b=_e(d.document,d.selection.focus.paragraphId,sa(d));if(b){const t=ca(d,b.zone)[b.blockIndex];if(t&&"table"===t.type){const a=sn(t),n=a.find(t=>t.rowIndex===b.rowIndex&&t.cellIndex===b.cellIndex);if(n){const o=[];for(let a=n.visualRowIndex+e;a>=0&&a<t.rows.length;a+=e)o.push(a);for(const n of o){const o=a.filter(t=>t.visualRowIndex===n&&t.cell.blocks.length>0&&"continue"!==t.cell.vMerge);if(0===o.length)continue;const i=null==(r=o.map(e=>{var a,n;const r=null==(a=e.cell.blocks[0])?void 0:a.id,o=r?null==(n=null==m?void 0:m.paragraphs.find(e=>e.paragraphId===r&&e.tableCell&&e.tableCell.tableId===t.id))?void 0:n.tableCell:null,i=(null==o?void 0:o.left)??g,l=o?o.left+o.width:g;return{entry:e,distance:g<i?i-g:g>l?g-l:0}}).sort((t,e)=>t.distance-e.distance)[0])?void 0:r.entry;if(!i)continue;const l=e<0?i.cell.blocks[i.cell.blocks.length-1].id:i.cell.blocks[0].id;v=c.findIndex(t=>t.id===l);break}}else if(e<0){const e=null==(l=null==(i=null==(o=t.rows[0])?void 0:o.cells[0])?void 0:i.blocks[0])?void 0:l.id;e&&(v=c.findIndex(t=>t.id===e)-1)}else{const e=t.rows[t.rows.length-1],a=null==e?void 0:e.cells[e.cells.length-1],n=null==(s=null==a?void 0:a.blocks[a.blocks.length-1])?void 0:s.id;n&&(v=c.findIndex(t=>t.id===n)+1)}}}if(v<0||v>=c.length)return!1;const y=c[v];let M=0;const x=m?Ps(m,y.id):[],w=e<0?x[x.length-1]:x[0];if(w&&w.lines.length>0){const t=w.lines,a=e<0?t[t.length-1]:t[0];M=a.slots.length?a.slots.reduce((t,e)=>Math.abs(g-e.left)<Math.abs(g-t.left)?e:t,a.slots[0]).offset:0}else M=Math.min(Ee(y,d.selection.focus),Ce(y).length);return t.setPreferredColumnX(g),t.resetTransactionGrouping(),t.applyTransactionalState(t=>YC(t,{anchor:a?t.selection.anchor:Ve(y,M),focus:Ve(y,M)})),t.focusInput(),!0};return{moveSelectionToParagraphBoundary:(e,a)=>{const n=t.state(),r=ha(n).find(t=>t.id===n.selection.focus.paragraphId);if(!r)return!1;const o=Ve(r,"start"===e?0:Ce(r).length);return t.clearPreferredColumn(),t.applyState(YC(n,{anchor:a?n.selection.anchor:o,focus:o})),!0},moveSelectionToDocumentBoundary:(e,a)=>{const n=t.state(),r=ha(n);if(0===r.length)return!1;const o="start"===e?r[0]:r[r.length-1],i=Ve(o,"start"===e?0:Ce(o).length);return t.clearPreferredColumn(),t.applyState(YC(n,{anchor:a?n.selection.anchor:i,focus:i})),!0},moveSelectionByWord:(e,a)=>{const n=t.state(),r=ha(n),o=r.findIndex(t=>t.id===n.selection.focus.paragraphId),i=r[o];if(!i)return!1;const l=Ce(i),s=n.selection.focus.offset,d=l.length;if(!a&&!ma(n.selection))return t.clearPreferredColumn(),t.applyState("left"===e?QC(n):_C(n)),!0;let c=i,h=s;"left"===e?0===s&&o>0?(c=r[o-1],h=Ce(c).length):h=function(t,e){if(0===t.length)return 0;let a=Math.max(0,Math.min(e,t.length));if(0===a)return 0;if(xz(t[a-1]??"")){for(;a>0&&xz(t[a-1]??"");)a-=1;return a}for(;a>0&&!xz(t[a-1]??"");)a-=1;for(;a>0&&xz(t[a-1]??"");)a-=1;return a}(l,s):s===d&&o<r.length-1?(c=r[o+1],h=0):h=function(t,e){if(0===t.length)return 0;let a=Math.max(0,Math.min(e,t.length));if(a>=t.length)return t.length;if(xz(t[a]??"")){for(;a<t.length&&xz(t[a]??"");)a+=1;for(;a<t.length&&!xz(t[a]??"");)a+=1;return a}for(;a<t.length&&!xz(t[a]??"");)a+=1;return a}(l,s);const p=Ve(c,h);return t.clearPreferredColumn(),t.applyState(YC(n,{anchor:a?n.selection.anchor:p,focus:p})),!0},moveVerticalByBlock:t=>e(t,!1),moveVerticalSelection:e}}function kz(t){const e=()=>t.state,a=yz({state:e,applyTransactionalState:t.applyTransactionalState,surfaceRef:t.surfaceRef,viewportRef:t.viewportRef,zoomFactor:t.zoomFactor}),n=Mz({state:e,applyTransactionalState:t.applyTransactionalState,resolvePositionAtSurfacePoint:t.resolvePositionAtSurfacePoint,focusInput:t.focusInput}),r=function(t){const[e,a]=y(null);return{hoveredRevision:e,handleRevisionMouseEnter:(e,n)=>{var r,o,i;const l=ha(t.state());let s;for(const t of l){for(const a of t.runs)if((null==(r=a.revision)?void 0:r.id)===e){s=a.revision;break}if(s)break}if(!s)return;const d=n.currentTarget.getBoundingClientRect(),c=null==(o=t.surfaceRef())?void 0:o.getBoundingClientRect();if(!c)return;const h=(null==(i=t.zoomFactor)?void 0:i.call(t))??1;a({revisionId:s.id,author:s.author,date:s.date,type:s.type,left:(d.left-c.left)/h,top:(d.top-c.top)/h})},handleRevisionMouseLeave:()=>{a(null)}}}({state:e,surfaceRef:()=>t.surfaceRef()??null,zoomFactor:t.zoomFactor}),o=Tz({state:e,isReadOnly:t.isReadOnly,resolveSurfaceHitAtPoint:t.resolveSurfaceHitAtPoint,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInputAfterPointerSelection:t.focusInputAfterPointerSelection,logger:t.logger}),i=Az({state:e,applyState:t.applyState,tableResize:a,imageOps:t.imageOps,clearPendingCaretTextStyle:t.styleController.clearPendingCaretTextStyle,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInputAfterPointerSelection:t.focusInputAfterPointerSelection,resolveSurfaceHitAtPoint:t.resolveSurfaceHitAtPoint,getParagraphById:Ye,textDrag:{tryStartTextDrag:o.tryStartTextDrag},logger:t.logger}),l=function(t){const[e,a]=y(!1);let n=null;return{handleTextInput:a=>{var r,o,i,l;if(Vi("input:text"),t.isReadOnly())return t.logger.debug(`input:readonly ignored value=${JSON.stringify(a.currentTarget.value)}`),void(a.currentTarget.value="");const s=a.currentTarget.value;if(0===s.length)return;if(e())return void t.logger.debug(`input:composing buffer=${JSON.stringify(s)}`);if(null!==n&&s===n)return t.logger.debug(`input:suppressed text=${JSON.stringify(s)}`),n=null,void(a.currentTarget.value="");const d=t.state(),c=d.selection,h=null==(r=ha(d).find(t=>t.id===c.anchor.paragraphId))?void 0:r.runs.find(t=>t.id===c.anchor.runId),p=h?{bold:null==(o=h.styles)?void 0:o.bold,italic:null==(i=h.styles)?void 0:i.italic,underline:null==(l=h.styles)?void 0:l.underline}:null;t.logger.info(`input:text ${JSON.stringify(s)} (len=${s.length}) at ${c.anchor.paragraphId}:${c.anchor.runId}[${c.anchor.offset}] run:${JSON.stringify(p)}`),t.clearPreferredColumn();const u=yT(t.pendingCaretTextStyle());t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>aC(t,s,u)),{mergeKey:"insertText"}),a.currentTarget.value="",t.focusInput(),Ei("input:text")},handleCompositionStart:()=>{t.logger.debug("input:composition start"),a(!0)},handleCompositionEnd:e=>{if(t.isReadOnly())return e.currentTarget.value="",void a(!1);const r=e.data??e.currentTarget.value;if(a(!1),0===r.length)return void(e.currentTarget.value="");const o=t.state().selection;t.logger.info(`input:composition end ${JSON.stringify(r)} (len=${r.length}) at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}]`),n=r,t.clearPreferredColumn();const i=yT(t.pendingCaretTextStyle());t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>aC(t,r,i)),{mergeKey:"insertText"}),e.currentTarget.value="",t.focusInput()},composing:e}}({state:e,isReadOnly:t.isReadOnly,logger:t.logger,clearPreferredColumn:t.clearPreferredColumn,pendingCaretTextStyle:t.styleController.pendingCaretTextStyle,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,focusInput:t.focusInput}),s=Cz({state:e,applyState:t.applyState,applyTransactionalState:t.applyTransactionalState,surfaceRef:()=>t.surfaceRef()??null,caretBox:t.caretBox,preferredColumnX:t.preferredColumnX,setPreferredColumnX:t.setPreferredColumnX,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInput:t.focusInput,zoomFactor:t.zoomFactor}),{handleCopy:d,handleCut:c,handlePaste:h,handleDrop:p}=(u={state:e,isReadOnly:t.isReadOnly,forcePlainTextPaste:t.getForcePlainTextPaste,setForcePlainTextPaste:t.setForcePlainTextPaste,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyTransactionalState:t.applyTransactionalState,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,focusInput:t.focusInput,insertImageFromFile:t.insertImageFromFile,resolvePositionAtSurfacePoint:t.resolvePositionAtSurfacePoint},{handleCopy:t=>{var e,a;const n=JC(u.state());0!==n.length&&(t.preventDefault(),null==(e=t.clipboardData)||e.setData("text/plain",n),null==(a=t.clipboardData)||a.setData("text/html",GC(u.state())))},handleCut:t=>{var e,a;if(u.isReadOnly())return void t.preventDefault();const n=JC(u.state());0!==n.length&&(t.preventDefault(),null==(e=t.clipboardData)||e.setData("text/plain",n),null==(a=t.clipboardData)||a.setData("text/html",GC(u.state())),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>rC(t))),u.focusInput())},handlePaste:t=>{var e,a,n;if(u.isReadOnly())return void t.preventDefault();if(u.forcePlainTextPaste()){u.setForcePlainTextPaste(!1);const a=(null==(e=t.clipboardData)?void 0:e.getData("text/plain"))??"";return 0===a.length?void t.preventDefault():(t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>nC(t,a))),t.currentTarget.value="",void u.focusInput())}const r=tL(t.clipboardData);if(r)return t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.insertImageFromFile(r),t.currentTarget.value="",void u.focusInput();const o=$C((null==(a=t.clipboardData)?void 0:a.getData("text/html"))??"");if(o.length>0)return t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>ZC(t,o))),t.currentTarget.value="",void u.focusInput();const i=(null==(n=t.clipboardData)?void 0:n.getData("text/plain"))??"";0!==i.length&&(t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping(),u.applyTransactionalState(t=>u.applyTableAwareParagraphEdit(t,t=>nC(t,i))),t.currentTarget.value="",u.focusInput())},handleDrop:t=>{if(u.isReadOnly())return void t.preventDefault();const e=tL(t.dataTransfer);if(!e)return;t.preventDefault(),u.clearPreferredColumn(),u.resetTransactionGrouping();const a=u.resolvePositionAtSurfacePoint(t.clientX,t.clientY)??u.state().selection.focus;u.insertImageFromFile(e,a),u.focusInput()}});var u;return{tableResize:a,tableDrag:n,revisionController:r,textDrag:o,surfaceEvents:i,textInput:l,navigation:s,handleCopy:d,handleCut:c,handlePaste:h,handleDrop:p}}function Vz(t){const{state:e,logger:a,isReadOnly:n,applyState:r,cloneState:o,focusInput:i,focusInputAfterPointerSelection:l,surfaceRef:s,viewportRef:d,zoomFactor:c,insertImageFromFile:h,getForcePlainTextPaste:p,setForcePlainTextPaste:u,getCommandsController:f,applyTransactionalState:g,clearPreferredColumn:m,resetTransactionGrouping:v,updateHistoryState:b,caretBox:y,preferredColumnX:M,setPreferredColumnX:x,measuredBlockHeights:w,measuredParagraphLayouts:S}=t,A=oz({state:()=>e,resetTransactionGrouping:v,applyTransactionalState:g,focusInput:i}),I=YL({state:()=>e,surfaceRef:()=>s()??null,viewportRef:()=>d()??null,measuredBlockHeights:w,measuredParagraphLayouts:S,zoomFactor:c}).resolveSurfaceHitAtPoint,T=ZL({state:e,applyState:r,applyTransactionalState:g,focusInput:i}),C=HL({applyTransactionalState:g,applySelectionToStatePreservingStructure:(t,e)=>({...t,document:Px(t).document,selection:e}),focusInput:i,logger:a}),k=(t,e)=>{var a;return(null==(a=I(t,e))?void 0:a.position)??null},V=BL({state:e,surfaceRef:s,resolvePositionAtSurfacePoint:k,applyState:r,applyTransactionalState:g,updateHistoryState:b,focusInput:i,focusInputAfterPointerSelection:l,cloneState:o,logger:a,zoomFactor:c}),E=function(t){const e=t=>{const e=CL(t);return(null==e?void 0:e.run.textBox)?{width:e.run.textBox.width,height:ks(e.run.textBox,t,0)}:null},a=UL({label:"text box",getSelected:e,applyResize:(t,e,a,n)=>EL(t,e,a,{handleDirection:n}),getMaxWidth:(a,n)=>{const r=uL(t.surfaceRef(),a.document,n,a.activeSectionIndex??0),o=e(a);return o?Math.max(r,o.width):r}},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger,zoomFactor:t.zoomFactor}),n=FL({label:"text box",applyRotate:(t,e)=>kL(t,e)},{state:t.state,applyState:t.applyState,updateHistoryState:t.updateHistoryState,cloneState:t.cloneState,focusInput:t.focusInput,logger:t.logger});return{handleTextBoxResizeHandleMouseDown:(e,n,r,o)=>{o.preventDefault(),o.stopPropagation(),a.start(e,n,r,o,t.state)},handleTextBoxRotateHandleMouseDown:(e,a,r)=>{r.preventDefault(),r.stopPropagation(),n.start(e,a,r,t.state)},stopTextBoxResize:a.stop,stopTextBoxRotate:n.stop}}({state:e,surfaceRef:s,applyState:r,updateHistoryState:b,focusInput:i,cloneState:o,logger:a,zoomFactor:c}),R=GL({state:()=>e,commandsController:f,clearPreferredColumn:m,resetTransactionGrouping:v,focusInput:i,logger:a}),L=kz({state:e,applyState:r,applyTransactionalState:g,isReadOnly:n,logger:a,focusInput:i,focusInputAfterPointerSelection:l,clearPreferredColumn:m,resetTransactionGrouping:v,surfaceRef:s,viewportRef:d,caretBox:()=>y(),preferredColumnX:()=>M(),setPreferredColumnX:x,zoomFactor:c,resolveSurfaceHitAtPoint:I,resolvePositionAtSurfacePoint:k,tableOps:C,imageOps:V,styleController:R,getForcePlainTextPaste:p,setForcePlainTextPaste:u,insertImageFromFile:h});return{selectedImageRun:()=>lL(e),selectedTextBoxRun:()=>CL(e),layoutOptionsOverlay:A,fr:T,resolveSurfaceHitAtPoint:I,resolvePositionAtSurfacePoint:k,tableOps:C,imageOps:V,textBoxOps:E,styleController:R,onEditorMouseDown:t=>{0===t.button&&(R.clearPendingCaretTextStyle(),t.preventDefault(),i())},tableResize:L.tableResize,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}}function Ez(t){if("main"!==(t.activeZone??"main"))return t;const e=ma(t.selection)?t:XT(t),{paragraph:a,index:n,offset:r}=jT(e),o=function(){const t=[ka("",{styleId:"footnoteText"})];return{id:ba("footnote"),blocks:t}}(),i=function(t){var e,a;const n=t.footnotes,r=(null==(e=null==n?void 0:n.settings)?void 0:e.numberFormat)??"decimal";let o=((null==(a=null==n?void 0:n.settings)?void 0:a.startAt)??1)-1;const i=new Set;for(const{run:l}of Gl(t)){const t=l.footnoteReference;t&&!t.customMark&&(i.has(t.footnoteId)||(i.add(t.footnoteId),o+=1))}return Xl(o+1,r)}(e.document),l=function(t,e){const a=wa(e,{styleId:"footnoteReference",superscript:!0}),n={footnoteId:t};return a.footnoteReference=n,a}(o.id,i),s=HT(a,r,[l]),d=ZT(e,ha(e).map((t,e)=>e===n?s:t),ga(Ve(s,r+i.length))),c=function(t){return t||{items:{}}}(d.document.footnotes),h=Yl({...d.document,footnotes:{...c,items:{...c.items,[o.id]:o}}}),p=o.blocks.flatMap(Ge).find(Boolean);return p?{...d,document:h,selection:ga(Ve(p,0)),activeZone:"footnote",activeFootnoteId:o.id}:{...d,document:h}}function Rz(t,e){const a=ha(t).map(t=>{const a=t.runs.filter(t=>{var a;return!((null==(a=t.revision)?void 0:a.id)===e&&"delete"===t.revision.type)}).map(t=>{var a;if((null==(a=t.revision)?void 0:a.id)===e&&"insert"===t.revision.type){const e={...t};return delete e.revision,e}return t});return a.length===t.runs.length&&a.every((e,a)=>e===t.runs[a])?t:RT(t,a)});return ZT(t,a,YT(a,va(t)))}function Lz(t,e){const a=ha(t).map(t=>{const a=t.runs.filter(t=>{var a;return!((null==(a=t.revision)?void 0:a.id)===e&&"insert"===t.revision.type)}).map(t=>{var a;if((null==(a=t.revision)?void 0:a.id)===e&&"delete"===t.revision.type){const e={...t};return delete e.revision,e}return t});return a.length===t.runs.length&&a.every((e,a)=>e===t.runs[a])?t:RT(t,a)});return ZT(t,a,YT(a,va(t)))}function zz(t){var e,a,n;const r=va(t),o=ha(t);if(r.isCollapsed){const t=o[r.startIndex];return t?(null==(e=PT(t,r.startParagraphOffset))?void 0:e.href)??null:null}const i=o.slice(r.startIndex,r.endIndex+1).flatMap((t,e)=>{const a=r.startIndex+e;return WT(t,a===r.startIndex?r.startParagraphOffset:0,a===r.endIndex?r.endParagraphOffset:ke(t))}).filter(t=>t.text.length>0&&!t.image);if(0===i.length)return null;const l=null==(n=null==(a=i[0])?void 0:a.styles)?void 0:n.link;return l&&i.every(t=>{var e;return(null==(e=t.styles)?void 0:e.link)===l})?l:null}function Nz(t){const e=va(t),a=ha(t).map((t,a)=>{if(a<e.startIndex||a>e.endIndex)return TT(t);if(!t.list)return TT(t);const n=t.list.level??0;return n<=0?qT(t):NT(t,n-1)});return ZT(t,a,YT(a,e))}function qz(t){const{state:e,logger:a,applyState:n,applyTransactionalState:r,applySelectionAwareTextCommand:o,applySelectionAwareParagraphCommand:i,applyTableAwareParagraphEdit:l,focusInput:s,clearPreferredColumn:d,resetTransactionGrouping:c,toolbarStyleState:h,selectionCollapsed:p,selectedImageRun:u}=t,f=()=>(()=>{const t=va(e);return ha(e).slice(t.startIndex,t.endIndex+1)})().some(t=>Boolean(t.list)),g=()=>{const t=e.selection.focus.paragraphId;return ha(e).find(e=>e.id===t)??null},m=()=>{const t=e.selection,a=sa(e),n=_e(e.document,t.anchor.paragraphId,a),r=_e(e.document,t.focus.paragraphId,a);return n&&r&&n.blockIndex===r.blockIndex?` [table b${n.blockIndex} r${n.rowIndex}:c${n.cellIndex}→r${r.rowIndex}:c${r.cellIndex}]`:""},v=(t,e)=>{d(),c(),i(a=>fC(a,t,e)),s()},b=()=>"main"===(e.activeZone??"main"),y=t=>{const a=zz(e);p()&&!a||(d(),c(),r(e=>function(t,e){const a=va(t);if(!a.isCollapsed)return lC(t,"link",e);const n=ha(t)[a.startIndex];if(!n)return t;const r=PT(n,a.startParagraphOffset);if(!r)return t;const o=lC(YC(t,{anchor:Ve(n,r.startOffset),focus:Ve(n,r.endOffset)}),"link",e),i=ha(o)[a.startIndex];return i?{...o,selection:{anchor:Ve(i,r.startOffset),focus:Ve(i,r.endOffset)}}:o}(e,t),{mergeKey:"link"}),s())};return{applyBooleanStyleCommand:t=>{if(p())return;const n=e.selection;a.info(`toggleStyle:${t} at ${n.anchor.paragraphId}:${n.anchor.runId}[${n.anchor.offset}..${n.focus.offset}]${m()}`),d(),c(),o(e=>iC(e,t)),s()},applyValueStyleCommand:(t,n)=>{if(p())return;const r=e.selection;a.info(`setStyle:${t}=${JSON.stringify(n)} at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}..${r.focus.offset}]${m()}`),d(),c(),o(e=>lC(e,t,n)),s()},applyChangeTextCaseCommand:t=>{p()||(d(),c(),o(e=>cC(e,t)),s())},applyClearFormattingCommand:()=>{p()||(d(),c(),o(t=>function(t){const e=va(t);if(e.isCollapsed)return t;const a=ha(t).map((t,a)=>a<e.startIndex||a>e.endIndex?t:JT(t,a===e.startIndex?e.startParagraphOffset:0,a===e.endIndex?e.endParagraphOffset:ke(t),t=>{var e;const a=null==(e=t.styles)?void 0:e.link,n=null!=a&&""!==a?{link:a}:{};return{...t,styles:n}}));return ZT(t,a,YT(a,e))}(t)),s())},applyParagraphStyleCommand:v,toggleParagraphFlagCommand:t=>{const e=!h()[t];v(t,!!e||null)},applyParagraphListCommand:t=>{d(),c(),i(e=>function(t,e){const a=va(t),n=ha(t),r=a.startIndex,o=a.endIndex,i=n.slice(r,o+1),l=i.length>0&&i.every(t=>{var a;return(null==(a=t.list)?void 0:a.kind)===e}),s=n.map((t,a)=>{var n,i,s;if(a<r||a>o)return TT(t);const d=TT(t);return l?(delete d.list,d):(d.list={kind:e,level:(null==(n=t.list)?void 0:n.level)??0,format:null==(i=t.list)?void 0:i.format,startAt:null==(s=t.list)?void 0:s.startAt},d)});return ZT(t,s,YT(s,a))}(e,t)),s()},handleListFormatChange:t=>{d(),c(),i(e=>function(t,e){const a=va(t),n=ha(t).map((t,n)=>n<a.startIndex||n>a.endIndex?TT(t):t.list?{...TT(t),list:{...t.list,format:e||void 0}}:TT(t));return ZT(t,n,YT(n,a))}(e,t)),s()},handleListStartAtChange:t=>{d(),c(),i(e=>function(t,e){const a=va(t),n=ha(t).map((t,n)=>n<a.startIndex||n>a.endIndex?TT(t):t.list?{...TT(t),list:{...t.list,startAt:null!==e?e:void 0}}:TT(t));return ZT(t,n,YT(n,a))}(e,t)),s()},applyInsertSectionBreakCommand:t=>{d(),c(),n(function(t,e){const a=ma(t.selection)?t:XT(t),{paragraph:n,offset:r}=jT(a),o=Be(a.document),i=sa(a);if("main"!==da(a))return t;const l=o[i];if(!l)return t;const s=l.blocks.findIndex(t=>"paragraph"===t.type&&t.id===n.id);if(-1===s)return t;const d=l.blocks.slice(0,s),c=l.blocks.slice(s+1),h=RT(n,WT(n,0,r),OT(n,r)),p=WT(n,r,ke(n)),u=p.length>0?zT(n,p.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Sa("");return t.style=n.style?{...n.style}:void 0,t.list=n.list?{...n.list}:void 0,t})(),f={id:`section:${Math.random().toString(36).slice(2,9)}`,blocks:[u,...c],pageSettings:{...l.pageSettings},header:l.header?VT(l.header):void 0,footer:l.footer?VT(l.footer):void 0,breakType:e},g={...l,blocks:[...d,h]},m=[...o.slice(0,i),g,f,...o.slice(i+1)];return{...a,document:{...a.document,sections:m},activeSectionIndex:i+1,selection:KT(Ve(u,0))}}(e,t)),s()},applyInsertPageBreakCommand:()=>{d(),c(),r(t=>l(t,t=>uC(t))),s()},canInsertFootnoteCommand:b,applyInsertFootnoteCommand:()=>{b()&&(d(),c(),r(t=>Ez(t)),s())},handleStyleChange:t=>{d(),c(),i(e=>function(t,e){return fC(t,"styleId",e)}(e,t||null)),s()},applyUpdateSectionSettingsCommand:(t,a)=>{d(),c(),n(function(t,e,a){var n;const r=Be(t.document);if(e<0||e>=r.length)return t;const o=[...r];return o[e]={...o[e],...a,pageSettings:{...o[e].pageSettings,...a.pageSettings??{},margins:{...o[e].pageSettings.margins,...(null==(n=a.pageSettings)?void 0:n.margins)??{}}}},{...t,document:{...t.document,sections:o}}}(e,t,a)),s()},applyToggleTrackChangesCommand:()=>{d(),c(),n(function(t){return{...t,trackChangesEnabled:!t.trackChangesEnabled}}(e)),s()},applyToggleShowMarginsCommand:()=>{n({...e,showMargins:!e.showMargins}),s()},applyToggleShowParagraphMarksCommand:()=>{n({...e,showParagraphMarks:!e.showParagraphMarks}),s()},applyAcceptRevisionsCommand:()=>{d(),c(),n(function(t){var e;const a=va(t),n=ha(t),r=new Set;for(let i=a.startIndex;i<=a.endIndex;i+=1){const t=n[i],o=WT(t,i===a.startIndex?a.startParagraphOffset:0,i===a.endIndex?a.endParagraphOffset:ke(t));for(const a of o)(null==(e=a.revision)?void 0:e.id)&&r.add(a.revision.id)}let o=t;for(const i of r)o=Rz(o,i);return o}(e)),s()},applyRejectRevisionsCommand:()=>{d(),c(),n(function(t){var e;const a=va(t),n=ha(t),r=new Set;for(let i=a.startIndex;i<=a.endIndex;i+=1){const t=n[i],o=WT(t,i===a.startIndex?a.startParagraphOffset:0,i===a.endIndex?a.endParagraphOffset:ke(t));for(const a of o)(null==(e=a.revision)?void 0:e.id)&&r.add(a.revision.id)}let o=t;for(const i of r)o=Lz(o,i);return o}(e)),s()},applyLinkCommand:y,promptForLink:()=>{const a=zz(e)??"";p()&&!a||t.openLinkDialog(a)},removeLinkCommand:()=>{y(null)},applyImageAltCommand:t=>{u()&&(d(),c(),r(e=>function(t,e){const a=lL(t);if(!(null==a?void 0:a.run.image))return t;const n=ha(t).map((t,n)=>n!==a.paragraphIndex?TT(t):{...TT(t),runs:t.runs.map(t=>t.id===a.run.id&&t.image?{...t,image:{...t.image,alt:e??void 0}}:IT(t))});return ZT(t,n,YT(n,va(t)))}(e,t),{mergeKey:"imageAlt"}),s())},promptForImageAlt:()=>{var e;const a=u();if(!a)return;const n=(null==(e=a.run.image)?void 0:e.alt)??"";t.openImageAltDialog(n)},applyImageCaptionCommand:e=>{u()&&(d(),c(),r(a=>hL(a,e,t.imageCaptionLabel()),{mergeKey:"imageCaption"}),s())},promptForImageCaption:()=>{u()&&t.openImageCaptionDialog(cL(e)??"")},handleListTab:t=>!_e(e.document,e.selection.focus.paragraphId,sa(e))&&(!!f()&&(d(),c(),i(e=>"indent"===t?function(t){const e=va(t),a=ha(t).map((t,a)=>a<e.startIndex||a>e.endIndex?TT(t):t.list?NT(t,(t.list.level??0)+1):TT(t));return ZT(t,a,YT(a,e))}(e):Nz(e)),s(),!0)),handleListEnter:()=>{const t=g();return!!(null==t?void 0:t.list)&&(d(),c(),p()&&0===Ce(t).length?i(t=>function(t){const e=va(t),a=ha(t).map((t,a)=>a<e.startIndex||a>e.endIndex?TT(t):qT(t));return ZT(t,a,YT(a,e))}(t)):r(t=>l(t,t=>function(t){const e=ma(t.selection)?t:XT(t),{paragraph:a,index:n,offset:r}=jT(e),o=RT(a,WT(a,0,r),OT(a,r)),i=WT(a,r,ke(a)),l=i.length>0?zT(a,i.map(t=>({text:t.text,styles:t.styles}))):(()=>{const t=Sa("");return t.style=a.style?{...a.style}:void 0,t.list=CT(a.list),t})(),s=ha(e);return ZT(e,[...kT(s.slice(0,n)),o,l,...kT(s.slice(n+1))],KT(Ve(l,0)))}(t)),{mergeKey:"splitListItem"}),s(),!0)},handleListBoundaryBackspace:t=>{const a=g();if(!(null==a?void 0:a.list)||!p())return!1;return 0===Ee(a,e.selection.focus)&&(d(),c(),i(t=>Nz(t)),t.currentTarget.value="",s(),!0)}}}class Oz{constructor(){a(this,"bindings",new Map)}register(t){this.bindings.set(t.id,t)}unregister(t){this.bindings.delete(t)}getBindings(){return Array.from(this.bindings.values())}execute(t,e,a){var n;const r=t.ctrlKey||t.metaKey,o=t.key.toLowerCase();for(const i of this.bindings.values())if(i.key.toLowerCase()===o&&Boolean(i.ctrlOrMeta)===r&&Boolean(i.shift)===t.shiftKey&&Boolean(i.alt)===t.altKey){if(i.command&&a){if((null==(n=a.canExecuteCommand)?void 0:n.call(a,i.command))??!0)return a.executeCommand(i.command),t.preventDefault(),!0}if(!1!==i.execute(e,t))return t.preventDefault(),!0}return!1}}const Pz=[{id:"selectAll",command:"selectAll",key:"a",ctrlOrMeta:!0,execute:t=>{const e=t.state(),a=ha(e);if(0===a.length)return!1;const n=a[0],r=a[a.length-1];return t.clearPreferredColumn(),t.applyState(YC(e,{anchor:Ve(n,0),focus:Ve(r,Ce(r).length)})),t.focusInput(),!0}},{id:"editImageAlt",command:"editImageAlt",key:"a",ctrlOrMeta:!0,alt:!0,execute:t=>!!t.selectedImageRun()&&(t.commandsController.promptForImageAlt(),!0)},{id:"insertFootnote",command:"insertFootnote",key:"f",ctrlOrMeta:!0,alt:!0,execute:t=>(t.commandsController.applyInsertFootnoteCommand(),!0)},{id:"pastePlainText",command:"pastePlainText",key:"v",ctrlOrMeta:!0,shift:!0,execute:t=>(t.setForcePlainTextPaste(!0),t.focusInput(),!0)},{id:"bold",command:"bold",key:"b",ctrlOrMeta:!0,execute:t=>(t.commandsController.applyBooleanStyleCommand("bold"),!0)},{id:"italic",command:"italic",key:"i",ctrlOrMeta:!0,execute:t=>(t.commandsController.applyBooleanStyleCommand("italic"),!0)},{id:"underline",command:"underline",key:"u",ctrlOrMeta:!0,execute:t=>(t.commandsController.applyBooleanStyleCommand("underline"),!0)},{id:"link",command:"link",key:"k",ctrlOrMeta:!0,execute:t=>(t.commandsController.promptForLink(),!0)},{id:"orderedList",command:"orderedList",key:"7",ctrlOrMeta:!0,shift:!0,execute:t=>(t.commandsController.applyParagraphListCommand("ordered"),!0)},{id:"bulletList",command:"bulletList",key:"8",ctrlOrMeta:!0,shift:!0,execute:t=>(t.commandsController.applyParagraphListCommand("bullet"),!0)},{id:"find",command:"find",key:"f",ctrlOrMeta:!0,execute:t=>(t.toggleFindReplace(!0),!0)},{id:"replace",command:"replace",key:"h",ctrlOrMeta:!0,execute:t=>(t.toggleReplace(!0),!0)},{id:"undo",command:"undo",key:"z",ctrlOrMeta:!0,execute:t=>(t.performUndo(),!0)},{id:"redo",command:"redo",key:"z",ctrlOrMeta:!0,shift:!0,execute:t=>(t.performRedo(),!0)},{id:"redoAlternative",command:"redo",key:"y",ctrlOrMeta:!0,execute:t=>(t.performRedo(),!0)},{id:"pageBreak",command:"pageBreak",key:"Enter",ctrlOrMeta:!0,execute:t=>(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>uC(t))),t.focusInput(),!0)},{id:"lineBreak",command:"lineBreak",key:"Enter",shift:!0,execute:t=>(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>aC(t,"\n"))),t.focusInput(),!0)},{id:"splitBlock",command:"splitBlock",key:"Enter",execute:t=>(t.commandsController.handleListEnter()||(t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>pC(t))),t.focusInput()),!0)}];function Wz(t){const e=new Oz;Pz.forEach(t=>e.register(t));return{handleKeyDown:a=>{const n=t.state();if(t.isReadOnly()){const t=a.key,e=t.toLowerCase(),n="ArrowLeft"===t||"ArrowRight"===t||"ArrowUp"===t||"ArrowDown"===t||"Home"===t||"End"===t||"PageUp"===t||"PageDown"===t,r="Shift"===t||"Control"===t||"Meta"===t||"Alt"===t,o=(a.ctrlKey||a.metaKey)&&("a"===e||"c"===e);return void(n||r||o||a.preventDefault())}const r=t.executeCommand?{executeCommand:(e,a)=>{var n;return null==(n=t.executeCommand)?void 0:n.call(t,e,a)},canExecuteCommand:(e,a)=>{var n;return null==(n=t.canExecuteCommand)?void 0:n.call(t,e,a)}}:void 0;if(!e.execute(a,t,r)){if((a.ctrlKey||a.metaKey)&&!a.altKey){if(("ArrowLeft"===a.key||"ArrowRight"===a.key)&&(a.preventDefault(),t.resetTransactionGrouping(),t.moveSelectionByWord("ArrowLeft"===a.key?"left":"right",a.shiftKey)))return void t.focusInput();if("Backspace"===a.key||"Delete"===a.key){if(a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),!ma(n.selection))return t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>rC(t))),a.currentTarget.value="",void t.focusInput();const e=ha(n),r=e.findIndex(t=>t.id===n.selection.focus.paragraphId),o=e[r];if(!o)return a.currentTarget.value="",void t.focusInput();if("Backspace"===a.key&&o.list){if(0===Ee(o,n.selection.focus))return t.applySelectionAwareParagraphCommand(t=>Nz(t)),a.currentTarget.value="",void t.focusInput()}const i=n.selection.focus.offset,l=Ce(o),s=wz(l,i);return"Backspace"===a.key?0===i||s.start===i?t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>rC(t))):t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(YC(e,{anchor:Ve(o,s.start),focus:Ve(o,i)}),t=>rC(t))):i>=l.length?t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>oC(t))):s.end>i?t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(YC(e,{anchor:Ve(o,i),focus:Ve(o,s.end)}),t=>rC(t))):t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>oC(t))),a.currentTarget.value="",void t.focusInput()}}if("Home"===a.key||"End"===a.key){a.preventDefault(),t.resetTransactionGrouping();const e="Home"===a.key?"start":"end";return a.ctrlKey||a.metaKey?t.moveSelectionToDocumentBoundary(e,a.shiftKey):t.moveSelectionToParagraphBoundary(e,a.shiftKey),void t.focusInput()}if(!a.altKey||a.ctrlKey||a.metaKey||"ArrowUp"!==a.key&&"ArrowDown"!==a.key||(a.preventDefault(),t.resetTransactionGrouping(),t.clearPreferredColumn(),!t.moveSelectedImageByParagraph("ArrowUp"===a.key?-1:1)))switch(a.key){case"Backspace":return t.commandsController.handleListBoundaryBackspace(a)?void a.preventDefault():(a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>rC(t))),a.currentTarget.value="",void t.focusInput());case"Delete":return a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applyTransactionalState(e=>t.applyTableAwareParagraphEdit(e,t=>oC(t))),a.currentTarget.value="",void t.focusInput();case"Tab":{if(t.commandsController.handleListTab(a.shiftKey?"outdent":"indent"))return void a.preventDefault();const e=t.resolveAdjacentTableCellPosition(n.document,n.selection.focus.paragraphId,a.shiftKey?-1:1);if(e)return a.preventDefault(),t.clearPreferredColumn(),t.resetTransactionGrouping(),t.applySelectionPreservingStructure({anchor:e,focus:e}),void t.focusInput();break}case"ArrowLeft":return a.preventDefault(),t.resetTransactionGrouping(),a.shiftKey?(t.clearPreferredColumn(),t.applyState(jC(n,-1))):(t.clearPreferredColumn(),t.applyState(QC(n))),void t.focusInput();case"ArrowRight":return a.preventDefault(),t.resetTransactionGrouping(),a.shiftKey?(t.clearPreferredColumn(),t.applyState(function(t){return jC(t,1)}(n))):(t.clearPreferredColumn(),t.applyState(_C(n))),void t.focusInput();case"ArrowUp":return a.preventDefault(),t.resetTransactionGrouping(),void(a.shiftKey?t.moveVerticalSelection(-1,!0)||(t.applyState(function(t){return XC(t,-1)}(n)),t.focusInput()):t.moveVerticalByBlock(-1)||(t.applyState(function(t){return KC(t,-1)}(n)),t.focusInput()));case"ArrowDown":return a.preventDefault(),t.resetTransactionGrouping(),void(a.shiftKey?t.moveVerticalSelection(1,!0)||(t.applyState(function(t){return XC(t,1)}(n)),t.focusInput()):t.moveVerticalByBlock(1)||(t.applyState(function(t){return KC(t,1)}(n)),t.focusInput()));default:return}}},registry:e}}const Hz=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];const Uz=t=>Math.round(t/In*Mn);function Fz(t,e=3){var a;const n=[];for(const r of Je(t.document)){const t=on(null==(a=r.style)?void 0:a.styleId);if(null===t||t>e)continue;const o=Ce(r).trim();o&&n.push({id:r.id,level:t,text:o})}return n}function Bz(t){const e=xa(t.text??"");return{...e,...t,id:e.id}}function Gz(t,e){const a=Sa("");return a.runs=t,e&&(a.style=e),a}function Zz(t,e,a){const n=void 0!==e?String(e):"";return Gz([Bz({text:`${t.text}\t${n}`})],{tabs:[{position:a,type:"right",leader:"dot"}],spacingAfter:Uz(40),indentLeft:Uz(397*(t.level-1))})}function Dz(t){const{width:e,margins:a}=t.pageSettings,n=Math.max(0,e-a.left-a.right);return Math.round(n*wn*100)/100}function Kz(t,e,a,n){const r=Be(t.document),o=r[e];if(!o)return t;const i=[...r];return i[e]={...o,blocks:a},{...t,document:{...t.document,sections:i},selection:KT(Ve(n,0))}}function jz(t,e=()=>{},a=3){if("main"!==da(t))return t;const n=sa(t),r=Be(t.document)[n];if(!r)return t;const o=function(t,e,a){const n=t.map(t=>Zz(t,e(t.id),a));return[Gz([Bz({text:"",fieldChar:{kind:"begin"}}),Bz({text:"",fieldInstruction:' TOC \\o "1-3" \\h \\z \\u '}),Bz({text:"",fieldChar:{kind:"separate"}})]),...n,Gz([Bz({text:"",fieldChar:{kind:"end"}})])]}(Fz(t,a),e,Dz(r)),i=ua(t,t.selection.focus),l=r.blocks.findIndex(t=>t.id===i.paragraphId||"paragraph"!==t.type&&Ge(t).some(t=>t.id===i.paragraphId)),s=-1===l?r.blocks.length:l+1;return Kz(t,n,[...r.blocks.slice(0,s),...o,...r.blocks.slice(s)],o[0])}function Xz(t,e=()=>{},a=3){const n=sa(t),r=Be(t.document)[n];if(!r)return t;const o=function(t){var e,a,n;let r=0,o="",i=-1,l=-1,s=!1;for(let d=0;d<t.length;d+=1){const c=t[d];if("paragraph"===c.type)for(const t of c.runs)if("begin"===(null==(e=t.fieldChar)?void 0:e.kind))r+=1,1===r&&(l=d,o="",s=!1,i=-1);else if(1===r&&void 0!==t.fieldInstruction)o+=t.fieldInstruction,/\bTOC\b/i.test(o)&&(s=!0);else if("separate"===(null==(a=t.fieldChar)?void 0:a.kind))1===r&&(i=d);else if("end"===(null==(n=t.fieldChar)?void 0:n.kind)){if(1===r&&s)return{startBlockIndex:i>=0?i:l,endBlockIndex:d};r=Math.max(0,r-1)}}return null}(r.blocks);if(!o)return t;const i=Fz(t,a).map(t=>Zz(t,e(t.id),Dz(r)));return Kz(t,n,[...r.blocks.slice(0,o.startBlockIndex+1),...i,...r.blocks.slice(o.endBlockIndex)],i[0]??r.blocks[o.startBlockIndex])}function Jz(t){return null!=t&&""!==t?Number(t):null}function Yz({gate:t,style:e,selection:a,history:n,formatting:r,link:o,command:i,valueCommand:l,actionCommand:s}){const d=e.state;return{selectAll:i("selectAll",r.selectAll),insertFootnote:i("insertFootnote",r.insertFootnote),pastePlainText:i("pastePlainText",r.pastePlainText),bold:i("bold",r.bold,()=>({isActive:Boolean(d().bold)})),italic:i("italic",r.italic,()=>({isActive:Boolean(d().italic)})),underline:i("underline",r.underline,()=>({isActive:Boolean(d().underline)})),strike:i("strike",r.strike,()=>({isActive:Boolean(d().strike)})),superscript:i("superscript",r.superscript,()=>({isActive:Boolean(d().superscript)})),subscript:i("subscript",r.subscript,()=>({isActive:Boolean(d().subscript)})),link:i("link",()=>(o.prompt(),!0),()=>({isEnabled:t.isCommandEnabled("link")&&o.canPrompt(),isActive:Boolean(d().link)})),alignLeft:i("alignLeft",r.alignLeft,()=>({isActive:"left"===d().align})),alignCenter:i("alignCenter",r.alignCenter,()=>({isActive:"center"===d().align})),alignRight:i("alignRight",r.alignRight,()=>({isActive:"right"===d().align})),alignJustify:i("alignJustify",r.alignJustify,()=>({isActive:"justify"===d().align})),orderedList:i("orderedList",r.orderedList,()=>({isActive:"ordered"===d().listKind})),bulletList:i("bulletList",r.bulletList,()=>({isActive:"bullet"===d().listKind})),find:i("find",r.find),replace:i("replace",r.replace),toggleTrackChanges:i("toggleTrackChanges",r.toggleTrackChanges),acceptRevisions:i("acceptRevisions",r.acceptRevisions),rejectRevisions:i("rejectRevisions",r.rejectRevisions),toggleShowMargins:i("toggleShowMargins",r.toggleShowMargins),toggleShowParagraphMarks:i("toggleShowParagraphMarks",r.toggleShowParagraphMarks),togglePreciseFonts:i("togglePreciseFonts",r.togglePreciseFonts,()=>(Ro(),{isActive:Lo()})),undo:i("undo",n.undo,()=>({isEnabled:t.isCommandEnabled("undo")&&n.canUndo()})),redo:i("redo",n.redo,()=>({isEnabled:t.isCommandEnabled("redo")&&n.canRedo()})),pageBreak:i("pageBreak",r.pageBreak),lineBreak:i("lineBreak",r.lineBreak),splitBlock:i("splitBlock",r.splitBlock),setFontFamily:l("setFontFamily",t=>r.setFontFamily(t||null),()=>d().fontFamily),setFontSize:l("setFontSize",t=>{const e=t&&"object"==typeof t&&"size"in t?t.size:t;return r.setFontSize(null!=e&&""!==e?AM(e):null),!0},()=>SM(d().fontSize)),increaseFontSize:i("increaseFontSize",r.increaseFontSize),decreaseFontSize:i("decreaseFontSize",r.decreaseFontSize),changeTextCase:s("changeTextCase",t=>{r.changeTextCase(t??"sentence")},()=>({isEnabled:t.isCommandEnabled("changeTextCase")&&!a.isCollapsed()})),clearFormatting:i("clearFormatting",r.clearFormatting),setColor:l("setColor",t=>r.setColor(t??null),()=>d().color||null),setHighlight:l("setHighlight",t=>r.setHighlight(t??null),()=>d().highlight||null),setTextShading:l("setTextShading",t=>r.setTextShading(t??null),()=>d().textShading||null),setStyleId:l("setStyleId",t=>r.setStyleId(String(t)),()=>d().styleId||"normal"),setUnderlineStyle:l("setUnderlineStyle",t=>(r.setUnderlineStyle(t||null),!0),()=>d().underlineStyle)}}function Qz({gate:t,style:e,document:a,link:n,image:r,browser:o,actionCommand:i}){const l=e.state;return{documentStyles:i("documentStyles",()=>{},()=>({isEnabled:!0,value:a.documentStyles()})),print:i("print",()=>o.print(),()=>({isEnabled:!0})),copy:i("copy",()=>o.copy(),()=>({isEnabled:!0})),exportDocx:i("exportDocx",()=>a.exportDocx()),exportPdf:i("exportPdf",()=>a.exportPdf()),importDocument:i("importDocument",()=>a.importDocument()),insertImage:i("insertImage",()=>a.insertImage()),insertShape:i("insertShape",t=>a.insertShape(String(t))),unlink:i("unlink",()=>n.remove(),()=>({isEnabled:t.isCommandEnabled("unlink")&&Boolean(l().link),isActive:Boolean(l().link)})),editImageAlt:i("editImageAlt",()=>r.promptAlt(),()=>({isEnabled:r.isSelected(),isActive:r.isSelected()})),insertImageCaption:i("insertImageCaption",()=>r.promptCaption(),()=>({isEnabled:r.isSelected(),isActive:r.isSelected()}))}}function _z({style:t,paragraph:e,section:a,valueCommand:n,actionCommand:r}){const o=t.state;return{outdent:r("outdent",()=>e.outdent()),indent:r("indent",()=>e.indent()),togglePageBreakBefore:r("togglePageBreakBefore",()=>e.togglePageBreakBefore(),()=>({isActive:Boolean(o().pageBreakBefore)})),toggleKeepWithNext:r("toggleKeepWithNext",()=>e.toggleKeepWithNext(),()=>({isActive:Boolean(o().keepWithNext)})),setSpacingAfter:n("setSpacingAfter",t=>(e.setSpacingAfter(Jz(t)),!0),()=>o().spacingAfter),setSpacingBefore:n("setSpacingBefore",t=>(e.setSpacingBefore(Jz(t)),!0),()=>o().spacingBefore),setIndentLeft:n("setIndentLeft",t=>(e.setIndentLeft(Jz(t)),!0),()=>o().indentLeft),setIndentRight:n("setIndentRight",t=>(e.setIndentRight(Jz(t)),!0),()=>o().indentRight),setIndentFirstLine:n("setIndentFirstLine",t=>(e.setIndentFirstLine(Jz(t)),!0),()=>o().indentFirstLine),setIndentHanging:n("setIndentHanging",t=>(e.setIndentHanging(Jz(t)),!0),()=>o().indentHanging),setSpecialIndent:r("setSpecialIndent",t=>{const a=t??{};e.setSpecialIndent(a.kind??"none",Jz(a.value))},()=>{const t=Number(o().indentFirstLine),e=Number(o().indentHanging),a=Number.isFinite(e)&&e>0?"hanging":Number.isFinite(t)&&t>0?"firstLine":"none";return{isActive:"none"!==a,value:a}}),setParagraphShading:n("setParagraphShading",t=>(e.setShading(t??null),!0),()=>o().shading||"#ffffff"),applyParagraphBorders:r("applyParagraphBorders",()=>e.applyBorders()),setLineHeight:n("setLineHeight",t=>(e.setLineHeight(Jz(t)),!0),()=>o().lineHeight),setListFormat:r("setListFormat",t=>e.setListFormat(String(t))),setListStartAt:r("setListStartAt",t=>e.setListStartAt(Jz(t))),toggleOrientation:r("toggleOrientation",()=>a.toggleOrientation(),()=>({isActive:a.isLandscape()})),setOrientation:r("setOrientation",t=>a.setOrientation(t)),sectionBreakNextPage:r("sectionBreakNextPage",()=>a.breakNextPage()),sectionBreakContinuous:r("sectionBreakContinuous",()=>a.breakContinuous()),setPageMargins:r("setPageMargins",t=>{a.setPageMargins(t??{})},()=>({value:a.getMargins()}))}}function $z({gate:t,table:e,actionCommand:a}){return{tableContext:a("tableContext",()=>{},()=>({isEnabled:e.insideTable(),isActive:e.insideTable(),value:e.selectionLabel()})),tableMerge:a("tableMerge",()=>e.merge(),()=>({isEnabled:t.isCommandEnabled("tableMerge")&&e.canMerge()})),tableSplit:a("tableSplit",()=>e.split(),()=>({isEnabled:t.isCommandEnabled("tableSplit")&&e.canSplit()})),tableInsertColumnBefore:a("tableInsertColumnBefore",()=>e.insertColumnBefore(),()=>({isEnabled:t.isCommandEnabled("tableInsertColumnBefore")&&e.canEditColumn()})),tableInsertColumnAfter:a("tableInsertColumnAfter",()=>e.insertColumnAfter(),()=>({isEnabled:t.isCommandEnabled("tableInsertColumnAfter")&&e.canEditColumn()})),tableDeleteColumn:a("tableDeleteColumn",()=>e.deleteColumn(),()=>({isEnabled:t.isCommandEnabled("tableDeleteColumn")&&e.canEditColumn()})),tableInsertRowBefore:a("tableInsertRowBefore",()=>e.insertRowBefore(),()=>({isEnabled:t.isCommandEnabled("tableInsertRowBefore")&&e.canEditRow()})),tableInsertRowAfter:a("tableInsertRowAfter",()=>e.insertRowAfter(),()=>({isEnabled:t.isCommandEnabled("tableInsertRowAfter")&&e.canEditRow()})),tableDeleteRow:a("tableDeleteRow",()=>e.deleteRow(),()=>({isEnabled:t.isCommandEnabled("tableDeleteRow")&&e.canEditRow()})),tableCellShading:a("tableCellShading",t=>e.cellShading(t??null)),tableCellBorders:a("tableCellBorders",()=>e.cellBorders()),tableCellNoBorders:a("tableCellNoBorders",()=>e.cellNoBorders()),tableWidth100:a("tableWidth100",()=>e.width100()),tableAlignLeft:a("tableAlignLeft",()=>e.alignLeft()),tableAlignCenter:a("tableAlignCenter",()=>e.alignCenter()),tableAlignRight:a("tableAlignRight",()=>e.alignRight()),tableSetCellWidth:a("tableSetCellWidth",t=>e.setCellWidth(String(t))),insertTable:a("insertTable",t=>{const{rows:a,cols:n,columns:r}=t??{},o=n??r;a&&o&&e.insert(a,o)})}}function tN(t){const e=e=>{const a=Number(t.styleController.toolbarStyleState().fontSize),n=Number.isFinite(a)&&a>0?xM(a):11,r="increase"===e?function(t){for(const e of MM)if(e>t+1e-6)return e;return Math.round(t)+10}(n):function(t){for(let e=MM.length-1;e>=0;e-=1){const a=MM[e];if(a<t-1e-6)return a}return Math.max(1,Math.round(t)-1)}(n);return t.styleController.applyToolbarValueStyleCommand("fontSize",wM(r)),!0},a=t=>{const e=is(t.document),a=new Map;for(const n of e.pages)for(const t of n.blocks){const e=t.paragraphId;e&&!a.has(e)&&a.set(e,n.index+1)}return t=>a.get(t)},n={isLandscape:()=>{var e,a;const n=sa(t.state()),r=(null==(e=t.state().document.sections)?void 0:e[n])??t.state().document;return"landscape"===(null==(a=null==r?void 0:r.pageSettings)?void 0:a.orientation)},setOrientation:e=>{var a;const n=sa(t.state()),r=(null==(a=t.state().document.sections)?void 0:a[n])??t.state().document;r&&t.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...r.pageSettings,orientation:e}})},toggleOrientation:()=>{var e,a;const r=sa(t.state()),o=(null==(e=t.state().document.sections)?void 0:e[r])??t.state().document;if(!o)return;const i=(null==(a=o.pageSettings)?void 0:a.orientation)??"portrait";n.setOrientation("portrait"===i?"landscape":"portrait")},breakNextPage:()=>t.commandsController.applyInsertSectionBreakCommand("nextPage"),breakContinuous:()=>t.commandsController.applyInsertSectionBreakCommand("continuous"),getMargins:()=>{var e,a;const n=sa(t.state()),r=(null==(e=t.state().document.sections)?void 0:e[n])??t.state().document;return null==(a=null==r?void 0:r.pageSettings)?void 0:a.margins},setPageMargins:e=>{var a;const n=sa(t.state()),r=(null==(a=t.state().document.sections)?void 0:a[n])??t.state().document;(null==r?void 0:r.pageSettings)&&t.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...r.pageSettings,margins:{...r.pageSettings.margins,...e}}})}};return function(t){const e=(a=t.gate.isCommandEnabled,(t,e,n)=>({execute:e,refresh:()=>({isEnabled:a(t),...null==n?void 0:n()})}));var a;const n=function(t){return(e,a,n)=>({execute:a,refresh:()=>({isEnabled:t(e),value:n()})})}(t.gate.isCommandEnabled),r=function(t){return(e,a,n)=>({execute:t=>(a(t),!0),refresh:()=>({isEnabled:t(e),...null==n?void 0:n()})})}(t.gate.isCommandEnabled);return{name:"Essentials",commands:{...Yz({gate:t.gate,style:t.style,selection:t.selection,history:t.history,formatting:t.formatting,link:t.link,command:e,valueCommand:n,actionCommand:r}),...Qz({gate:t.gate,style:t.style,document:t.document,link:t.link,image:t.image,browser:t.browser,actionCommand:r}),..._z({style:t.style,paragraph:t.paragraph,section:t.section,valueCommand:n,actionCommand:r}),...$z({gate:t.gate,table:t.table,actionCommand:r})}}}({gate:{isCommandEnabled:e=>!t.isReadOnly()&&("insertFootnote"!==e||t.commandsController.canInsertFootnoteCommand())},style:{state:()=>t.styleController.toolbarStyleState()},selection:{isCollapsed:()=>ma(t.state().selection)},history:{canUndo:()=>t.undoStack().length>0,canRedo:()=>t.redoStack().length>0,undo:()=>(t.historyActions.performUndo(),!0),redo:()=>(t.historyActions.performRedo(),!0)},formatting:{selectAll:()=>{const e=Je(t.state().document);if(0===e.length)return!1;const a=e[0],n=e[e.length-1];return t.applyState({...t.state(),selection:{anchor:Ve(a,0),focus:Ve(n,Ce(n).length)}}),t.focusInput(),!0},insertFootnote:()=>(t.commandsController.applyInsertFootnoteCommand(),!0),insertTableOfContents:()=>(t.applyTransactionalState(t=>jz(t,a(t))),t.focusInput(),!0),updateTableOfContents:()=>(t.applyTransactionalState(t=>Xz(t,a(t))),t.focusInput(),!0),pastePlainText:()=>(t.forcePlainTextPaste.set(!0),t.focusInput(),!0),bold:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("bold"),!0),italic:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("italic"),!0),underline:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("underline"),!0),strike:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("strike"),!0),superscript:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("superscript"),!0),subscript:()=>(t.keyboardCommandsController.applyBooleanStyleCommand("subscript"),!0),alignLeft:()=>(t.commandsController.applyParagraphStyleCommand("align","left"),!0),alignCenter:()=>(t.commandsController.applyParagraphStyleCommand("align","center"),!0),alignRight:()=>(t.commandsController.applyParagraphStyleCommand("align","right"),!0),alignJustify:()=>(t.commandsController.applyParagraphStyleCommand("align","justify"),!0),orderedList:()=>(t.commandsController.applyParagraphListCommand("ordered"),!0),bulletList:()=>(t.commandsController.applyParagraphListCommand("bullet"),!0),find:()=>(t.findReplace.setIsOpen(!0),!0),replace:()=>(t.findReplace.setIsOpen(!0),!0),toggleTrackChanges:()=>(t.commandsController.applyToggleTrackChangesCommand(),!0),acceptRevisions:()=>(t.commandsController.applyAcceptRevisionsCommand(),!0),rejectRevisions:()=>(t.commandsController.applyRejectRevisionsCommand(),!0),toggleShowMargins:()=>(t.commandsController.applyToggleShowMarginsCommand(),!0),toggleShowParagraphMarks:()=>(t.commandsController.applyToggleShowParagraphMarksCommand(),!0),togglePreciseFonts:()=>(wc(),!0),pageBreak:()=>(t.applyTransactionalState(e=>t.tableOps.applyTableAwareParagraphEdit(e,t=>uC(t))),t.focusInput(),!0),lineBreak:()=>(t.applyTransactionalState(e=>t.tableOps.applyTableAwareParagraphEdit(e,t=>aC(t,"\n"))),t.focusInput(),!0),splitBlock:()=>(t.commandsController.handleListEnter()||(t.applyTransactionalState(e=>t.tableOps.applyTableAwareParagraphEdit(e,t=>pC(t))),t.focusInput()),!0),setFontFamily:e=>(t.styleController.applyToolbarValueStyleCommand("fontFamily",e),!0),setFontSize:e=>(t.styleController.applyToolbarValueStyleCommand("fontSize",e),!0),increaseFontSize:()=>e("increase"),decreaseFontSize:()=>e("decrease"),changeTextCase:e=>(t.commandsController.applyChangeTextCaseCommand(e),!0),clearFormatting:()=>ma(t.state().selection)?(t.styleController.clearPendingCaretTextStyle(),t.focusInput(),!0):(t.commandsController.applyClearFormattingCommand(),!0),setColor:e=>(t.styleController.applyToolbarValueStyleCommand("color",e),!0),setHighlight:e=>(t.styleController.applyToolbarValueStyleCommand("highlight",e),!0),setTextShading:e=>(t.styleController.applyToolbarValueStyleCommand("shading",e),!0),setStyleId:e=>(t.commandsController.handleStyleChange(e),!0),setUnderlineStyle:e=>t.styleController.applyToolbarValueStyleCommand("underlineStyle",e)},document:{documentStyles:()=>{var e;return Object.values((null==(e=t.state().document)?void 0:e.styles)??{}).map(t=>{var e,a,n;return{id:t.id,name:t.name,fontFamily:(null==(a=null==(e=t.textStyle)?void 0:e.fontFamily)?void 0:a.trim())||void 0,fontSize:"number"==typeof(null==(n=t.textStyle)?void 0:n.fontSize)?t.textStyle.fontSize:void 0}})},exportDocx:()=>{t.docIO.handleExportDocx()},exportPdf:()=>{t.docIO.handleExportPdf()},importDocument:()=>{var e;return null==(e=t.importInputRef())?void 0:e.click()},insertImage:()=>{var e;return null==(e=t.imageInputRef())?void 0:e.click()},insertShape:e=>t.applyTransactionalState(t=>function(t,e){const a=ma(t.selection)?t:XT(t),{paragraph:n,index:r,offset:o}=jT(a),i={width:150,height:100,blocks:[Sa("")],shape:{preset:e,fill:"#4472C4",borderColor:"#2F528F",borderWidthPt:1},floating:nL(void 0,"front")},l=HT(n,o,[wa("",OT(n,o),void 0,i)]);return ZT(a,ha(a).map((t,e)=>e===r?l:TT(t)),KT(Ve(l,o+1)))}(t,e))},link:{prompt:()=>t.commandsController.promptForLink(),remove:()=>t.commandsController.removeLinkCommand(),canPrompt:()=>!ma(t.state().selection)||Boolean(t.styleController.toolbarStyleState().link)},image:{promptAlt:()=>t.commandsController.promptForImageAlt(),promptCaption:()=>t.commandsController.promptForImageCaption(),isSelected:()=>Boolean(t.selectedImageRun())},browser:{print:()=>window.print(),copy:()=>{document.execCommand("copy")}},paragraph:{togglePageBreakBefore:()=>t.commandsController.toggleParagraphFlagCommand("pageBreakBefore"),toggleKeepWithNext:()=>t.commandsController.toggleParagraphFlagCommand("keepWithNext"),setSpacingAfter:e=>t.commandsController.applyParagraphStyleCommand("spacingAfter",e),setSpacingBefore:e=>t.commandsController.applyParagraphStyleCommand("spacingBefore",e),setIndentLeft:e=>t.commandsController.applyParagraphStyleCommand("indentLeft",e),setIndentRight:e=>t.commandsController.applyParagraphStyleCommand("indentRight",e),setIndentFirstLine:e=>t.commandsController.applyParagraphStyleCommand("indentFirstLine",e),setIndentHanging:e=>t.commandsController.applyParagraphStyleCommand("indentHanging",e),setSpecialIndent:(e,a)=>{const n=a??48;t.applyTransactionalState(t=>{let a=fC(t,"indentFirstLine",null);return a=fC(a,"indentHanging",null),"firstLine"===e?a=fC(a,"indentFirstLine",n):"hanging"===e&&(a=fC(a,"indentHanging",n)),a},{mergeKey:"specialIndent"}),t.focusInput()},setShading:e=>t.commandsController.applyParagraphStyleCommand("shading",e),applyBorders:()=>{const e={width:1,type:"solid",color:"#000000"};t.applyTransactionalState(t=>{let a=fC(t,"borderTop",e);return a=fC(a,"borderRight",e),a=fC(a,"borderBottom",e),a=fC(a,"borderLeft",e),a},{mergeKey:"paraBorders"}),t.focusInput()},setLineHeight:e=>t.commandsController.applyParagraphStyleCommand("lineHeight",e),setListFormat:e=>t.commandsController.handleListFormatChange(e),setListStartAt:e=>t.commandsController.handleListStartAtChange(e),outdent:()=>{t.commandsController.handleListTab("outdent")},indent:()=>{t.commandsController.handleListTab("indent")}},section:n,table:(()=>{const e=(e,a)=>{t.applyTransactionalState(e,{mergeKey:a}),t.focusInput()};return{insideTable:()=>Boolean(_e(t.state().document,t.state().selection.focus.paragraphId,sa(t.state()))),selectionLabel:()=>{if(va(t.state()).isCollapsed)return null;const e=sa(t.state()),a=_e(t.state().document,t.state().selection.anchor.paragraphId,e),n=_e(t.state().document,t.state().selection.focus.paragraphId,e);if(!a||!n||a.blockIndex!==n.blockIndex||a.rowIndex===n.rowIndex&&a.cellIndex===n.cellIndex)return null;const r=t.selectionBoxes().length;return 0===r?null:`Table selection: ${r} cell${1===r?"":"s"}`},canMerge:()=>t.tableOps.canMergeSelectedTable(t.state()),canSplit:()=>t.tableOps.canSplitSelectedTable(t.state()),canEditColumn:()=>t.tableOps.canEditSelectedTableColumn(t.state()),canEditRow:()=>t.tableOps.canEditSelectedTableRow(t.state()),merge:()=>e(e=>t.tableOps.mergeSelectedTable(e),"mergeTable"),split:()=>e(e=>t.tableOps.splitSelectedTable(e),"splitTable"),insertColumnBefore:()=>e(e=>t.tableOps.insertSelectedTableColumn(e,-1),"insertTableColumn"),insertColumnAfter:()=>e(e=>t.tableOps.insertSelectedTableColumn(e,1),"insertTableColumn"),deleteColumn:()=>e(e=>t.tableOps.deleteSelectedTableColumn(e),"deleteTableColumn"),insertRowBefore:()=>e(e=>t.tableOps.insertSelectedTableRow(e,-1),"insertTableRow"),insertRowAfter:()=>e(e=>t.tableOps.insertSelectedTableRow(e,1),"insertTableRow"),deleteRow:()=>e(e=>t.tableOps.deleteSelectedTableRow(e),"deleteTableRow"),cellShading:t=>e(e=>wC(e,"shading",t||null),"tableShading"),cellBorders:()=>e(t=>SC(t,{width:1,type:"solid",color:"#64748b"}),"tableBorders"),cellNoBorders:()=>e(t=>SC(t,{width:0,type:"none",color:"transparent"}),"tableBorders"),width100:()=>e(t=>AC(t,"width","100%"),"tableWidth"),alignLeft:()=>e(t=>wC(t,"horizontalAlign","left"),"tableAlign"),alignCenter:()=>e(t=>wC(t,"horizontalAlign","center"),"tableAlign"),alignRight:()=>e(t=>wC(t,"horizontalAlign","right"),"tableAlign"),setCellWidth:t=>e(e=>function(t,e){return wC(t,"width",e)}(e,t),"tableCellWidth"),insert:(e,a)=>t.tableOps.insertTableCommand(e,a)}})()})}const eN=[{id:"file_new",path:"File/New",labelKey:"menu.file.new",shortcut:"Ctrl+N",hidden:!0,icon:"file-plus"},{id:"file_import",path:"File/Import",labelKey:"toolbar.import",shortcut:"Ctrl+O",command:"importDocument",icon:"upload"},{id:"file_save",path:"File/Save",labelKey:"generic.save",shortcut:"Ctrl+S",hidden:!0,icon:"save"},{id:"file_export",path:"File/Export",labelKey:"menu.file.export",icon:"download"},{id:"file_export_pdf",path:"File/Export/PDF",command:"exportPdf",icon:"file-down"},{id:"file_export_docx",path:"File/Export/DOCX",command:"exportDocx",icon:"file-text"},{id:"file_export_html",path:"File/Export/HTML",hidden:!0},{id:"file_export_md",path:"File/Export/MD",hidden:!0},{id:"file_print",path:"File/Print",labelKey:"menu.file.print",shortcut:"Ctrl+P",command:"print",icon:"printer"},{id:"edit_undo",path:"Edit/Undo",labelKey:"toolbar.undo",shortcut:"Ctrl+Z",command:"undo",icon:"undo-2"},{id:"edit_redo",path:"Edit/Redo",labelKey:"toolbar.redo",shortcut:"Ctrl+Y",command:"redo",icon:"redo-2"},{id:"edit_cut",path:"Edit/Cut",labelKey:"menu.edit.cut",shortcut:"Ctrl+X",hidden:!0},{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",hidden:!0},{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:"view_outline",path:"View/Show Outline",labelKey:"menu.view.outline",hidden:!0},{id:"view_ruler",path:"View/Show Ruler",hidden:!0},{id:"view_margins",path:"View/Show Margins",labelKey:"menu.view.margins",command:"toggleShowMargins",icon:t=>t.commands.state("toggleShowMargins").isActive?"check-square":"square"},{id:"view_paragraph_marks",path:"View/Show Paragraph Marks",labelKey:"menu.view.paragraphMarks",command:"toggleShowParagraphMarks",icon:t=>t.commands.state("toggleShowParagraphMarks").isActive?"check-square":"square"},{id:"view_precise_fonts",path:"View/Precise Fonts",labelKey:"menu.view.preciseFonts",command:"togglePreciseFonts",icon:t=>t.commands.state("togglePreciseFonts").isActive?"check-square":"square"},{id:"view_fullscreen",path:"View/Full Screen",labelKey:"menu.view.fullscreen",hidden:!0},{id:"view_zoom",path:"View/Zoom",labelKey:"status.zoom",hidden:!0},{id:"view_zoom_50",path:"View/Zoom/50%",hidden:!0},{id:"view_zoom_75",path:"View/Zoom/75%",hidden:!0},{id:"view_zoom_100",path:"View/Zoom/100%",hidden:!0},{id:"view_zoom_125",path:"View/Zoom/125%",hidden:!0},{id:"view_zoom_150",path:"View/Zoom/150%",hidden:!0},{id:"view_zoom_200",path:"View/Zoom/200%",hidden:!0},{id:"insert_image",path:"Insert/Image",labelKey:"toolbar.image",command:"insertImage",icon:"image"},{id:"insert_image_caption",path:"Insert/Image Caption",labelKey:"toolbar.imageCaption",command:"insertImageCaption",icon:"subtitles"},{id:"insert_table",path:"Insert/Table",labelKey:"toolbar.table",command:{name:"insertTable",payload:{rows:3,cols:3}},icon:"table"},{id:"insert_link",path:"Insert/Link",labelKey:"toolbar.link",command:"link",icon:"link"},{id:"insert_footnote",path:"Insert/Footnote",labelKey:"toolbar.footnote",shortcut:"Ctrl+Alt+F",command:"insertFootnote",icon:"footnote"},{id:"insert_toc",path:"Insert/Table of Contents",labelKey:"menu.insert.toc",command:"insertTableOfContents",icon:"list"},{id:"insert_toc_update",path:"Insert/Update Table of Contents",labelKey:"menu.insert.updateToc",command:"updateTableOfContents",icon:"refresh-cw"},{id:"insert_hr",path:"Insert/Horizontal Rule",hidden:!0},{id:"insert_pageBreak",path:"Insert/Page Break",labelKey:"metric.pageBreak",command:"pageBreak",icon:"file-minus"},{id:"insert_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:t=>t.commands.state("toggleOrientation").isActive?"":"check"},{id:"layout_orientation_landscape",path:"Layout/Orientation/Landscape",labelKey:"section.landscape",command:{name:"setOrientation",payload:"landscape"},icon:t=>t.commands.state("toggleOrientation").isActive?"check":""},{id:"tools_wordcount",path:"Tools/Word count",labelKey:"menu.tools.wordcount",hidden:!0},{id:"tools_spelling",hidden:!0,path:"Tools/Spelling"},{id:"tools_preferences",path:"Tools/Preferences",hidden:!0},{id:"help_shortcuts",path:"Help/Keyboard shortcuts",labelKey:"menu.help.shortcuts",hidden:!0},{id:"help_about",path:"Help/About",labelKey:"menu.help.about",hidden:!0}];function aN(t){const e=tN(t.essentials),{runtimePlugins:a,toolbarRegistry:n,menuRegistry:r,dispose:o}=function(t){var e,a;const n=[t.essentialsPlugin,...t.externalPlugins??[]],r=[],o=[],i=fM(),l=new gM;for(const s of Ex(t.t))i.register(s);for(const s of eN)l.register(s);for(const s of n){for(const t of s.toolbar??[]){const e={type:"button",id:t.id,testId:t.id,command:t.command,iconName:t.icon,tab:t.tab??"plugins",group:t.group??"general",row:t.row??1,ribbonSize:t.ribbonSize,order:t.order};i.register(e),r.push(t.id)}for(const t of s.menubar??[])l.register({id:t.id,path:t.path,command:t.command,icon:t.icon,shortcut:t.shortcut}),o.push(t.id)}return null==(e=t.customizeToolbar)||e.call(t,i),null==(a=t.customizeMenubar)||a.call(t,l),{runtimePlugins:n,toolbarRegistry:i,menuRegistry:l,dispose:()=>{for(const t of r)i.remove(t);for(const t of o)l.unregister(t)}}}({essentialsPlugin:e,externalPlugins:t.externalPlugins,t:t.t,customizeToolbar:t.customizeToolbar,customizeMenubar:t.customizeMenubar}),i=function(t){const[e,a]=y(!1),[n,r]=y(new Ua({doc:t.initialDocument}));let o=!1;const i=t=>{var e;const a=jt(t),r=n().commands.get(a);if(!r)return{isEnabled:!1,isActive:!1,value:void 0};const o=(null==(e=r.refresh)?void 0:e.call(r))??{isEnabled:!0};return{isEnabled:!1!==o.isEnabled,isActive:Boolean(o.isActive),value:o.value}};return{runtimeReady:e,runtimeEditor:n,commandStateOf:i,toolbarHost:()=>({commands:{execute:(t,e)=>{const a=Xt(t,e);return n().commands.execute(a.name,a.payload)},canExecute:(t,e)=>{const a=Xt(t,e);return n().commands.canExecute(a.name,a.payload)},state:i},focusEditor:t.focusEditor}),initialize:async()=>{var e,i;try{const e=await Ua.create({doc:t.initialDocument,plugins:t.runtimePlugins});if(o)return void(await e.destroy());const i=n();r(e),await i.destroy(),a(!0),requestAnimationFrame(()=>{var a,n;null==(a=t.onSettled)||a.call(t),null==(n=t.onReady)||n.call(t,e)})}catch(l){t.logger.error("runtime:init failed",l),null==(e=t.onError)||e.call(t,l),null==(i=t.onSettled)||i.call(t)}},dispose:async()=>{o=!0,await n().destroy()}}}({initialDocument:t.initialDocument,runtimePlugins:a,focusEditor:t.focusEditor,logger:t.logger,onReady:t.onReady,onSettled:t.onSettled,onError:t.onError});return I(()=>{i.initialize()}),T(()=>{i.dispose(),o()}),{toolbarRegistry:n,menuRegistry:r,runtimeReady:i.runtimeReady,runtimeEditor:i.runtimeEditor,commandStateOf:i.commandStateOf,toolbarHost:i.toolbarHost}}function nN(t){const{document:e,interaction:a,runtimeClient:n}=t,{commandsController:r,keyboardCommandsController:o}=function(t){const e=qz({state:t.state,logger:t.logger,applyState:t.applyState,applyTransactionalState:t.applyTransactionalState,applySelectionAwareTextCommand:t.tableOps.applySelectionAwareTextCommand,applySelectionAwareParagraphCommand:t.tableOps.applySelectionAwareParagraphCommand,applyTableAwareParagraphEdit:t.tableOps.applyTableAwareParagraphEdit,focusInput:t.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,toolbarStyleState:t.toolbarStyleState,selectionCollapsed:()=>ma(t.state.selection),selectedImageRun:t.selectedImageRun,openLinkDialog:e=>t.setLinkDialog({isOpen:!0,initialHref:e}),openImageAltDialog:e=>t.setImageAltDialog({isOpen:!0,initialAlt:e}),openImageCaptionDialog:e=>t.setImageCaptionDialog({isOpen:!0,initialCaption:e}),imageCaptionLabel:()=>t.locale().startsWith("en")?"Figure":"Figura"});return{commandsController:e,keyboardCommandsController:{...e,applyBooleanStyleCommand:e=>t.applyBooleanStyleCommand(e)}}}({state:t.state,logger:t.logger,applyState:t.applyState,applyTransactionalState:e.applyTransactionalState,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:t.focusInput,selectedImageRun:a.selectedImageRun,tableOps:a.tableOps,toolbarStyleState:a.styleController.toolbarStyleState,applyBooleanStyleCommand:t=>a.styleController.applyToolbarBooleanStyleCommand(t),locale:t.locale,setLinkDialog:t.setLinkDialog,setImageAltDialog:t.setImageAltDialog,setImageCaptionDialog:t.setImageCaptionDialog}),{runtimeReady:i,runtimeEditor:l,commandStateOf:s,toolbarHost:d,toolbarRegistry:c,menuRegistry:h}=aN({essentials:{state:()=>t.state,isReadOnly:t.isReadOnly,forcePlainTextPaste:{get:t.getForcePlainTextPaste,set:t.setForcePlainTextPaste},undoStack:e.undoStack,redoStack:e.redoStack,commandsController:r,keyboardCommandsController:o,historyActions:e.historyActions,styleController:a.styleController,tableOps:a.tableOps,docIO:e.docIO,importInputRef:t.importInputRef,imageInputRef:t.imageInputRef,selectedImageRun:a.selectedImageRun,selectionBoxes:e.selectionBoxes,focusInput:t.focusInput,applyState:t.applyState,applyTransactionalState:e.applyTransactionalState,findReplace:{setIsOpen:a.fr.setIsOpen}},externalPlugins:t.runtimeOptions().plugins,t:t.translator,customizeToolbar:t.runtimeOptions().customizeToolbar,customizeMenubar:t.runtimeOptions().customizeMenubar,initialDocument:t.getStateSnapshot().document,focusEditor:t.focusInput,logger:t.logger,onReady:e=>{var a,r;n.resolveReady(e),null==(r=(a=t.runtimeOptions()).onReady)||r.call(a,n)},onSettled:()=>{t.setInitialLoading(!1)},onError:t=>n.rejectReady(t)});!function(t,e){const a=()=>e.cloneState(e.getStateSnapshot());t.connectHost({getRuntimeEditor:()=>e.runtimeReady()?e.runtimeEditor():null,getState:()=>a(),getDocument:()=>a().document,setDocument:t=>{e.applyState(Ra(t)),e.resetEditorChromeState(),e.focusInput()},resetDocument:()=>{e.applyState(za()),e.resetEditorChromeState(),e.focusInput()},saveDocument:async()=>{await e.getPersistence().saveDocument(a().document)},getSelection:()=>a().selection,setSelection:t=>{e.applyState({...a(),selection:t}),e.focusInput()},focus:()=>e.focusInput(),blur:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e.setFocused(!1)},clearHistory:()=>e.clearHistory(),importDocx:t=>e.docIO.handleImportFile(t),exportDocx:()=>e.docIO.handleExportDocx(),exportPdf:()=>e.docIO.handleExportPdf()})}(n,{runtimeReady:i,runtimeEditor:l,getStateSnapshot:t.getStateSnapshot,cloneState:t.cloneState,applyState:t.applyState,resetEditorChromeState:e.resetEditorChromeState,focusInput:t.focusInput,setFocused:t.setFocused,clearHistory:e.clearHistory,getPersistence:()=>t.documentOptions().persistence??e.fallbackPersistence,docIO:e.docIO}),x(()=>{if(!i())return;t.state.document,t.state.selection,t.state.activeSectionIndex,t.state.activeZone;const e=t.cloneState(t.getStateSnapshot());l().dispatch(()=>e)});const{handleKeyDown:p}=function(t){const{state:e,isReadOnly:a,logger:n,focusInput:r,clearPreferredColumn:o,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,setForcePlainTextPaste:d,selectedImageRun:c,commandsController:h,tableOps:p,navigation:u,historyActions:f,styleController:g,findReplace:m,runtimeEditor:v}=t,{handleKeyDown:b}=Wz({state:e,isReadOnly:a,clearPreferredColumn:o,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,applyTableAwareParagraphEdit:p.applyTableAwareParagraphEdit,applySelectionAwareParagraphCommand:p.applySelectionAwareParagraphCommand,focusInput:r,commandsController:h,selectedImageRun:c,setForcePlainTextPaste:d,moveSelectionByWord:u.moveSelectionByWord,moveSelectionToDocumentBoundary:u.moveSelectionToDocumentBoundary,moveSelectionToParagraphBoundary:u.moveSelectionToParagraphBoundary,moveSelectedImageByParagraph:f.moveSelectedImageByParagraph,performUndo:f.performUndo,performRedo:f.performRedo,moveVerticalSelection:u.moveVerticalSelection,moveVerticalByBlock:u.moveVerticalByBlock,resolveAdjacentTableCellPosition:p.resolveAdjacentTableCellPosition,applySelectionPreservingStructure:f.applySelectionPreservingStructure,toggleFindReplace:t=>{m.setIsOpen(t??!m.isOpen())},toggleReplace:t=>{m.setIsOpen(t??!m.isOpen())},executeCommand:(t,e)=>v().commands.execute(t,e),canExecuteCommand:t=>v().commands.canExecute(t)});return{handleKeyDown:t=>{Hz.includes(t.key)&&g.clearPendingCaretTextStyle();const a=[t.ctrlKey?"Ctrl":null,t.metaKey?"Meta":null,t.altKey?"Alt":null,t.shiftKey?"Shift":null].filter(Boolean).join("+"),r=a?`${a}+${t.key}`:t.key,o=e().selection;n.debug(`key:down ${r} at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}]`),Vi("input-to-layout"),b(t),Ei("input-to-layout")}}}({state:()=>t.state,isReadOnly:t.isReadOnly,logger:t.logger,focusInput:t.focusInput,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyState:t.applyState,applyTransactionalState:e.applyTransactionalState,setForcePlainTextPaste:t.setForcePlainTextPaste,selectedImageRun:a.selectedImageRun,commandsController:o,tableOps:a.tableOps,navigation:a.navigation,historyActions:e.historyActions,styleController:a.styleController,findReplace:a.fr,runtimeEditor:l});return{commandsController:r,runtimeReady:i,runtimeEditor:l,commandStateOf:s,toolbarHost:d,toolbarRegistry:c,menuRegistry:h,handleKeyDown:p}}var rN=ut('<div class="oasis-editor-shell oasis-editor-app">');const oN=Object.freeze(Object.defineProperty({__proto__:null,OasisEditorApp:function(t={}){var e;const a=(null==(e=t.runtime)?void 0:e.client)??Jt(),n=()=>t.ui??{},r=()=>t.document??{};fT();const o=Ot(()=>n().locale??"pt-BR"),i=bo("app"),{state:l,commitState:s,getStateSnapshot:d}=function(t){const e=t.initialState?Px(t.initialState):t.initialDocument?Ra(t.initialDocument):za();let a=e;const[n,r]=y(e);return{state:new Proxy({},{get(t,e){const a=n();if(null!==a&&("object"==typeof a||"function"==typeof a))return Reflect.get(a,e)},has(t,e){const a=n();return null!==a&&("object"==typeof a||"function"==typeof a)&&Reflect.has(a,e)},ownKeys(t){const e=n();return null===e||"object"!=typeof e&&"function"!=typeof e?[]:Reflect.ownKeys(e)},getOwnPropertyDescriptor(t,e){const a=n();return null===a||"object"!=typeof a&&"function"!=typeof a?{configurable:!0,enumerable:!0}:{...Reflect.getOwnPropertyDescriptor(a,e),configurable:!0,enumerable:!0}}}),setStateSignal:r,commitState:t=>{a=t,r(t)},getStateSnapshot:()=>a}}({initialDocument:r().initialDocument,initialState:r().initialState}),c=t=>{s(t)},h=Px;let p=!1;const{showChrome:u,showTitleBar:f,showMenubar:g,showToolbar:m,showOutline:v,toolbarView:b,toolbarLayout:x,isReadOnly:S,useComposedShell:A,loadingOptions:C,loadingLabel:k,shellComponent:V}=function(t){const{ui:e,documentOptions:a}=t,n=()=>{const t=e().loading;return"object"==typeof t&&null!==t?t:void 0};return{showChrome:()=>e().showChrome??!0,showTitleBar:()=>e().showTitleBar??!0,showMenubar:()=>e().showMenubar??!0,showToolbar:()=>e().showToolbar??!0,showOutline:()=>e().showOutline??!0,toolbarView:()=>{var t;return(null==(t=e().toolbar)?void 0:t.view)??"ribbon"},toolbarLayout:()=>{var t;return(null==(t=e().toolbar)?void 0:t.layout)??"overflow"},isReadOnly:()=>a().readOnly??!1,useComposedShell:()=>"docs"===e().uiVariant||"document"!==(e().shell??"document"),loadingOptions:n,loadingLabel:()=>{var t;return(null==(t=n())?void 0:t.label)??"Loading oasis-editor..."},shellComponent:()=>{const t=e().shell??"document";return"inline"===t?Uy:"balloon"===t?Gy:Py}}}({ui:n,documentOptions:r}),E=function(){const[t,e]=y(!1);let a,n,r,o,i;return{focused:t,setFocused:e,focusInput:()=>{e(!0),queueMicrotask(()=>{null==r||r.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})},focusInputAfterPointerSelection:()=>{e(!0),queueMicrotask(()=>{requestAnimationFrame(()=>{null==r||r.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})})},get viewportRef(){return a},set viewportRef(t){a=t},get surfaceRef(){return n},set surfaceRef(t){n=t},get textareaRef(){return r},set textareaRef(t){r=t},get importInputRef(){return o},set importInputRef(t){o=t},get imageInputRef(){return i},set imageInputRef(t){i=t}}}(),R=E.focused,L=E.setFocused,z=E.focusInput,N=E.focusInputAfterPointerSelection,[q,O]=y(!1!==n().loading),P=function(t=100){const[e,a]=y(py(t)),n=w(()=>e()/100);return{zoomPercent:e,setZoomPercent:t=>a(py(t)),adjustZoom:t=>a(e=>py(e+t)),zoomFactor:n}}(),{linkDialog:W,setLinkDialog:H,imageAltDialog:U,setImageAltDialog:F,imageCaptionDialog:B,setImageCaptionDialog:G,contextMenu:Z,setContextMenu:K,fontDialog:j,setFontDialog:X,paragraphDialog:J,setParagraphDialog:Y,tablePropertiesDialog:Q,setTablePropertiesDialog:_}=function(){const[t,e]=y({isOpen:!1,initialHref:""}),[a,n]=y({isOpen:!1,initialAlt:""}),[r,o]=y({isOpen:!1,initialCaption:""}),[i,l]=y({isOpen:!1,x:0,y:0}),[s,d]=y({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}}),[c,h]=y({isOpen:!1,initial:{align:"",indentLeft:"",indentRight:"",indentFirstLine:"",indentHanging:"",spacingBefore:"",spacingAfter:"",lineHeight:"",shading:"",borderStyle:"",borderWidth:"",borderColor:"",borderSideTop:!1,borderSideRight:!1,borderSideBottom:!1,borderSideLeft:!1}}),[p,u]=y({isOpen:!1,initial:{activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingSummary:"",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,shading:"",altTitle:"",altDescription:""}});return{linkDialog:t,setLinkDialog:e,imageAltDialog:a,setImageAltDialog:n,imageCaptionDialog:r,setImageCaptionDialog:o,contextMenu:i,setContextMenu:l,fontDialog:s,setFontDialog:d,paragraphDialog:c,setParagraphDialog:h,tablePropertiesDialog:p,setTablePropertiesDialog:u}}(),[$,tt]=y(!1),et=()=>E.viewportRef,nt=()=>E.surfaceRef,rt=TL({documentOptions:r,logger:i,runtimeClient:a,state:l,commitState:s,getStateSnapshot:d,applyState:c,cloneState:h,isReadOnly:S,focusInput:z,surfaceRef:nt,viewportRef:et,zoomFactor:P.zoomFactor,getImageOps:()=>It.imageOps}),{docIO:ot,measuredBlockHeights:it,measuredParagraphLayouts:lt,inputBox:st,selectionBoxes:dt,commentHighlights:ht,selectedImageBox:pt,selectedTextBoxBox:ut,caretBox:ft,preferredColumnX:gt,setPreferredColumnX:mt,clearPreferredColumn:vt,onCleanupHook:bt,persistenceStatus:yt,applyTransactionalState:xt,resetTransactionGrouping:wt,updateHistoryState:At}=rt,It=Vz({state:l,logger:i,isReadOnly:S,applyState:c,cloneState:h,focusInput:z,focusInputAfterPointerSelection:N,surfaceRef:nt,viewportRef:et,zoomFactor:P.zoomFactor,insertImageFromFile:ot.insertImageFromFile,getForcePlainTextPaste:()=>p,setForcePlainTextPaste:t=>{p=t},getCommandsController:()=>Qt.commandsController,applyTransactionalState:xt,clearPreferredColumn:vt,resetTransactionGrouping:wt,updateHistoryState:At,caretBox:ft,preferredColumnX:gt,setPreferredColumnX:mt,measuredBlockHeights:it,measuredParagraphLayouts:lt}),{selectedImageRun:Tt,layoutOptionsOverlay:Ct,fr:kt,resolveSurfaceHitAtPoint:Vt,resolvePositionAtSurfacePoint:Et,tableOps:Rt,imageOps:Lt,textBoxOps:zt,styleController:Nt,onEditorMouseDown:qt,tableResize:Pt,tableDrag:Wt,revisionController:Ut,textDrag:Ft,surfaceEventsWithTextDrag:Bt,textInput:Gt,navigation:Zt,handleCopy:Kt,handleCut:jt,handlePaste:Xt,handleDrop:Yt}=It,Qt=nN({document:rt,interaction:It,state:l,logger:i,isReadOnly:S,focusInput:z,applyState:c,getStateSnapshot:d,cloneState:h,setFocused:L,setInitialLoading:O,getForcePlainTextPaste:()=>p,setForcePlainTextPaste:t=>{p=t},locale:()=>n().locale??"pt-BR",translator:o,runtimeClient:a,runtimeOptions:()=>t.runtime??{},documentOptions:r,importInputRef:()=>E.importInputRef,imageInputRef:()=>E.imageInputRef,setLinkDialog:H,setImageAltDialog:F,setImageCaptionDialog:G}),{commandsController:_t,runtimeReady:$t,runtimeEditor:te,commandStateOf:ee,toolbarHost:ae,toolbarRegistry:ne,menuRegistry:re,handleKeyDown:oe}=Qt,{computeFontFamilyOptions:ie,computeFontSizeOptions:le,applyFontDialogValues:se,applyParagraphDialogValues:de,applyTablePropertiesDialogValues:ce,buildContextMenuItems:he,handleEditorContextMenu:pe,closeContextMenu:ue}=ek({state:()=>l,selection:()=>l.selection,toolbarStyleState:Nt.toolbarStyleState,isReadOnly:S,t:o,logger:i,setFontDialog:X,setParagraphDialog:Y,setTablePropertiesDialog:_,setContextMenu:K,clearPreferredColumn:vt,resetTransactionGrouping:wt,applyTransactionalState:xt,applyTableAwareParagraphEdit:Rt.applyTableAwareParagraphEdit,focusInput:z,promptForLink:_t.promptForLink,tableOps:Rt}),{layout:fe,overlays:ge,refs:me,surfaceHandlers:ve,inputHandlers:be,fileHandlers:ye}=function(t){const{layout:e,overlays:a,refs:n,surface:r,input:o,files:i}=t,l={onImportInputChange:t=>{var e;return i.handleImportFile((null==(e=t.currentTarget.files)?void 0:e[0])??null)},onImageInputChange:t=>{var e;return i.handleInsertImage((null==(e=t.currentTarget.files)?void 0:e[0])??null)}};return{layout:{viewportHeight:e.viewportHeight,class:e.className,style:e.style,zoomPercent:e.zoomPercent,setZoomPercent:e.setZoomPercent,zoomFactor:e.zoomFactor},overlays:{selectionBoxes:a.selectionBoxes,commentHighlights:a.commentHighlights,selectedImageBox:a.selectedImageBox,selectedTextBoxBox:a.selectedTextBoxBox,layoutOptions:a.layoutOptions,caretBox:a.caretBox,inputBox:a.inputBox,hoveredRevision:a.hoveredRevision,focused:a.focused,showCaret:a.showCaret,importProgress:a.importProgress},refs:{onViewportRef:t=>{n.focusController.viewportRef=t},onSurfaceRef:t=>{n.focusController.surfaceRef=t},onTextareaRef:t=>{n.focusController.textareaRef=t},onImportInputRef:t=>{n.focusController.importInputRef=t},onImageInputRef:t=>{n.focusController.imageInputRef=t}},surfaceHandlers:{onDragOver:t=>t.preventDefault(),onDrop:r.handleDrop,onEditorMouseDown:r.onEditorMouseDown,onSurfaceMouseDown:r.surfaceEvents.handleSurfaceMouseDown,onSurfaceClick:r.surfaceEvents.handleSurfaceClick,onSurfaceMouseMove:r.tableResize.handleMouseMove,onSurfaceDblClick:r.surfaceEvents.handleSurfaceDblClick,onParagraphMouseDown:r.surfaceEvents.handleParagraphMouseDown,onImageMouseDown:r.handleImageMouseDown,onImageResizeHandleMouseDown:r.handleImageResizeHandleMouseDown,onTextBoxResizeHandleMouseDown:r.handleTextBoxResizeHandleMouseDown,onImageRotateHandleMouseDown:r.handleImageRotateHandleMouseDown,onTextBoxRotateHandleMouseDown:r.handleTextBoxRotateHandleMouseDown,onTableDragHandleMouseDown:r.tableDrag.handleMouseDown,onRevisionMouseEnter:r.revisionController.handleRevisionMouseEnter,onRevisionMouseLeave:r.revisionController.handleRevisionMouseLeave,onEditorContextMenu:t=>r.handleEditorContextMenu(t)},inputHandlers:{onInputBlur:()=>o.setFocused(!1),onInputFocus:()=>o.setFocused(!0),onCompositionEnd:o.textInput.handleCompositionEnd,onCompositionStart:o.textInput.handleCompositionStart,onCopy:o.handleCopy,onCut:o.handleCut,onInput:o.textInput.handleTextInput,onKeyDown:o.handleKeyDown,onPaste:o.handlePaste},fileHandlers:l}}({layout:{viewportHeight:n().viewportHeight,className:n().class,style:n().style,zoomPercent:P.zoomPercent,setZoomPercent:P.setZoomPercent,zoomFactor:P.zoomFactor},overlays:{selectionBoxes:dt,commentHighlights:ht,selectedImageBox:pt,selectedTextBoxBox:ut,layoutOptions:Ct,caretBox:ft,inputBox:st,hoveredRevision:Ut.hoveredRevision,focused:R,showCaret:()=>function(t,e){if(!e.visible||!ma(t.selection))return!1;const a=sa(t),n=_e(t.document,t.selection.anchor.paragraphId,a),r=_e(t.document,t.selection.focus.paragraphId,a);return!(n&&r&&n.blockIndex===r.blockIndex&&(n.rowIndex!==r.rowIndex||n.cellIndex!==r.cellIndex))}(l,ft()),importProgress:ot.importProgress},refs:{focusController:E},files:{handleImportFile:ot.handleImportFile,handleInsertImage:ot.handleInsertImage},surface:{surfaceEvents:Bt,tableResize:Pt,tableDrag:Wt,revisionController:Ut,handleDrop:Yt,onEditorMouseDown:qt,handleImageMouseDown:Lt.handleImageMouseDown,handleImageResizeHandleMouseDown:Lt.handleImageResizeHandleMouseDown,handleTextBoxResizeHandleMouseDown:zt.handleTextBoxResizeHandleMouseDown,handleImageRotateHandleMouseDown:Lt.handleImageRotateHandleMouseDown,handleTextBoxRotateHandleMouseDown:zt.handleTextBoxRotateHandleMouseDown,handleEditorContextMenu:pe},input:{textInput:Gt,setFocused:L,handleCopy:Kt,handleCut:jt,handlePaste:Xt,handleKeyDown:oe}});return I(()=>{!function(t=document.body){lT||(iT({icons:oT,nameAttr:"data-lucide",root:t}),lT=new MutationObserver(e=>{let a=!1;for(const t of e)if(t.addedNodes.length>0||"attributes"===t.type){a=!0;break}a&&lT&&(lT.disconnect(),iT({icons:oT,nameAttr:"data-lucide",root:t}),lT.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-lucide"]}))}),lT.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-lucide"]}))}(),function(){if(!Ci&&window.PerformanceObserver)try{Ci=new PerformanceObserver(t=>{for(const e of t.getEntries())Ti.push({duration:Math.round(100*e.duration)/100,startTime:Math.round(e.startTime)})}),Ci.observe({type:"longtask",buffered:!0})}catch{}}(),window.__OASIS_PERF_REPORT=()=>{const t=Ii.filter(t=>t.name.startsWith("layout:")).map(t=>t.duration),e=Ii.filter(t=>"input-to-layout"===t.name).map(t=>t.duration),a=Ii.filter(t=>"input:text"===t.name).map(t=>t.duration),n=Ni(t),r=Ni(e),o=Ni(a),i=Ni(Ti.map(t=>t.duration));console.group("%c[perf] Summary","color: #f59e0b; font-weight: bold;"),console.info(`input:text → p50=${o.p50}ms p95=${o.p95}ms p99=${o.p99}ms max=${o.max}ms (n=${o.count})`),console.info(`input-to-layout → p50=${r.p50}ms p95=${r.p95}ms p99=${r.p99}ms max=${r.max}ms (n=${r.count})`),console.info(`layout:sync → p50=${n.p50}ms p95=${n.p95}ms p99=${n.p99}ms max=${n.max}ms (n=${n.count})`),console.info(`longtasks → p50=${i.p50}ms p95=${i.p95}ms p99=${i.p99}ms max=${i.max}ms (n=${i.count})`),console.groupEnd()},window.__OASIS_DOM_STATS=()=>{const t=(e=(null==Li?void 0:Li())??null)?{totalNodes:e.querySelectorAll("*").length,pages:e.querySelectorAll('[data-renderer="canvas"][data-page-index]').length,blocks:0,paragraphs:0,lines:0,charSpans:0,segmentSpans:0,runSpans:0}:{totalNodes:0,pages:0,blocks:0,paragraphs:0,lines:0,charSpans:0,segmentSpans:0,runSpans:0};var e;return console.info("%c[perf] DOM stats","color: #f59e0b; font-weight: bold;",t),t},Li=()=>nt()??null,Sc(),"1"!==dc(lc)&&vc()&&tt(!0)}),T(()=>{bt(),Bt.stopDragging(),Ft.stopDrag(),Lt.stopImageDrag(),Lt.stopImageResize(),zt.stopTextBoxResize(),null==lT||lT.disconnect(),lT=null}),D(Ht,{translator:o,get children(){var t=rN();return Mt(t,"--oasis-editor-gutter-x","34px"),St(t,D(at,{get when(){return ct(()=>!(A()||!u()))()&&m()},get children(){return D(ic,{host:ae,registry:ne,get view(){return b()},get layout(){return x()}})}}),null),St(t,D(kV,{dialogs:{linkDialog:W,setLinkDialog:H,imageAltDialog:U,setImageAltDialog:F,imageCaptionDialog:B,setImageCaptionDialog:G,contextMenu:Z,setContextMenu:K,fontDialog:j,setFontDialog:X,paragraphDialog:J,setParagraphDialog:Y,tablePropertiesDialog:Q,setTablePropertiesDialog:_},findReplace:kt,fontFamilyOptions:ie,fontSizeOptions:le,contextMenuItems:he,focusInput:z,get applyLinkCommand(){return _t.applyLinkCommand},get applyImageAltCommand(){return _t.applyImageAltCommand},get applyImageCaptionCommand(){return _t.applyImageCaptionCommand},applyFontDialogValues:se,applyParagraphDialogValues:de,applyTablePropertiesDialogValues:ce,closeContextMenu:ue}),null),St(t,D(EV,{useComposedShell:A,shellComponent:V,runtime:{state:()=>l,toolbarHost:ae,runtimeEditor:te,persistenceStatus:yt,toolbarRegistry:ne,menuRegistry:re,showFloatingTableToolbar:()=>!S()&&null!==ee("tableContext").value},chrome:{showChrome:u,showTitleBar:f,showMenubar:g,showToolbar:m,showOutline:v,toolbarView:b,toolbarLayout:x},view:{isReadOnly:S,viewportHeight:()=>n().viewportHeight,measuredBlockHeights:it,measuredParagraphLayouts:lt,layout:fe,overlays:ge,refs:me,surfaceHandlers:ve,inputHandlers:be,fileHandlers:ye}}),null),St(t,D(ik,{state:l,get surfaceRef(){return nt()},tableResize:Pt,imageOps:Lt,tableDrag:Wt,textDrag:Ft}),null),St(t,D(at,{get when(){return q()||!$t()},get children(){return D(Dt,{get label(){return k()},get class(){var t;return null==(t=C())?void 0:t.class},get style(){var t;return null==(t=C())?void 0:t.style}})}}),null),St(t,D(LV,{get isOpen(){return ct(()=>!(!$()||q()))()&&$t()},onClose:()=>tt(!1)}),null),M(e=>{var a=!!A(),n=!!S();return a!==e.e&&t.classList.toggle("oasis-editor-docs",e.e=a),n!==e.t&&t.classList.toggle("oasis-editor-read-only",e.t=n),e},{e:void 0,t:void 0}),t}})}},Symbol.toStringTag,{value:"Module"}));t.BalloonShell=Gy,t.Button=function(t){const[e,a]=Q(t,["type","variant","size","icon","iconPosition","fullWidth","class","classList","children"]),n=()=>e.iconPosition??"start";return r=_y(),o=r.firstChild,xt(r,Y({get type(){return e.type??"button"},get class(){return`oasis-editor-ui-button ${e.class??""}`},get classList(){return{[`oasis-editor-ui-button-${e.variant??"secondary"}`]:!0,[`oasis-editor-ui-button-${e.size??"md"}`]:!0,"oasis-editor-ui-button-full":e.fullWidth,...e.classList}}},a),!1,!0),St(r,D(at,{get when(){return ct(()=>!!e.icon)()&&"start"===n()},get children(){return D(Da,{get name(){return e.icon}})}}),o),St(o,()=>e.children),St(r,D(at,{get when(){return ct(()=>!!e.icon)()&&"end"===n()},get children(){return D(Da,{get name(){return e.icon}})}}),null),r;var r,o},t.Checkbox=function(t){const e=$(),[a,n]=Q(t,["label","description","error","onChange","class","id"]),r=()=>a.id??e,o=()=>`${r()}-description`,i=()=>`${r()}-error`;return l=oM(),s=l.firstChild,d=s.nextSibling,c=d.firstChild,s.addEventListener("change",t=>{var e;return null==(e=a.onChange)?void 0:e.call(a,t.currentTarget.checked)}),xt(s,Y({get id(){return r()},get"aria-invalid"(){return a.error?"true":void 0},get"aria-describedby"(){return[a.description?o():null,a.error?i():null].filter(Boolean).join(" ")}},n),!1,!1),St(c,()=>a.label),St(d,D(at,{get when(){return a.description},get children(){var t=nM();return St(t,()=>a.description),M(()=>gt(t,"id",o())),t}}),null),St(d,D(at,{get when(){return a.error},get children(){var t=rM();return St(t,()=>a.error),M(()=>gt(t,"id",i())),t}}),null),M(t=>{var e=`oasis-editor-ui-checkbox ${a.class??""}`,n=r();return e!==t.e&&mt(l,t.e=e),n!==t.t&>(l,"for",t.t=n),t},{e:void 0,t:void 0}),l;var l,s,d,c},t.ColorPicker=Cd,t.CommandRegistry=qa,t.DEFAULT_PALETTE=Nd,t.Dialog=Ky,t.DialogFooter=function(t){const[e,a]=Q(t,["align","class","classList","children"]);return xt(n=hM(),Y({get class(){return`oasis-editor-ui-dialog-footer ${e.class??""}`},get classList(){return{[`oasis-editor-ui-dialog-footer-${e.align??"end"}`]:!0,...e.classList}}},a),!1,!0),St(n,()=>e.children),n;var n},t.DocumentShell=Py,t.Editor=Ua,t.FloatingActionButton=My,t.GridPicker=zd,t.IconButton=Cy,t.InlineShell=Uy,t.Menu=dd,t.MenuRegistry=gM,t.OASIS_BUILTIN_COMMANDS=["selectAll","insertFootnote","insertTableOfContents","updateTableOfContents","pastePlainText","bold","italic","underline","strike","superscript","subscript","link","unlink","alignLeft","alignCenter","alignRight","alignJustify","orderedList","bulletList","find","replace","toggleTrackChanges","acceptRevisions","rejectRevisions","toggleShowMargins","toggleShowParagraphMarks","togglePreciseFonts","undo","redo","pageBreak","lineBreak","splitBlock","setFontFamily","setFontSize","increaseFontSize","decreaseFontSize","changeTextCase","clearFormatting","setColor","setHighlight","setTextShading","setStyleId","setUnderlineStyle","documentStyles","print","copy","exportDocx","exportPdf","importDocument","insertImage","editImageAlt","insertImageCaption","outdent","indent","togglePageBreakBefore","toggleKeepWithNext","setSpacingAfter","setSpacingBefore","setIndentLeft","setIndentRight","setIndentFirstLine","setIndentHanging","setSpecialIndent","setParagraphShading","applyParagraphBorders","setLineHeight","setListFormat","setListStartAt","toggleOrientation","setOrientation","sectionBreakNextPage","sectionBreakContinuous","setPageMargins","tableContext","tableMerge","tableSplit","tableInsertColumnBefore","tableInsertColumnAfter","tableDeleteColumn","tableInsertRowBefore","tableInsertRowAfter","tableDeleteRow","tableCellShading","tableCellBorders","tableCellNoBorders","tableWidth100","tableAlignLeft","tableAlignCenter","tableAlignRight","tableSetCellWidth","insertTable"],t.OASIS_MENU_ITEMS={fileNew:"file_new",fileImport:"file_import",fileSave:"file_save",fileExport:"file_export",fileExportPdf:"file_export_pdf",fileExportDocx:"file_export_docx",filePrint:"file_print",editUndo:"edit_undo",editRedo:"edit_redo",editCopy:"edit_copy",editFind:"edit_find",editSelectAll:"edit_selectAll",viewMargins:"view_margins",viewParagraphMarks:"view_paragraph_marks",viewPreciseFonts:"view_precise_fonts",insertImage:"insert_image",insertImageCaption:"insert_image_caption",insertTable:"insert_table",insertLink:"insert_link",insertFootnote:"insert_footnote",insertPageBreak:"insert_pageBreak",formatText:"format_text",formatTextBold:"format_text_bold",formatTextItalic:"format_text_italic",formatTextUnderline:"format_text_underline",formatTextStrike:"format_text_strike",formatAlign:"format_align",formatAlignLeft:"format_align_left",formatAlignCenter:"format_align_center",formatAlignRight:"format_align_right",formatAlignJustify:"format_align_justify",formatLists:"format_lists",formatListsBullet:"format_lists_bullet",formatListsNumbered:"format_lists_numbered"},t.OASIS_TOOLBAR_ITEMS={fileDropdown:"editor-toolbar-file-dropdown",exportDocx:"editor-toolbar-export-docx",exportPdf:"editor-toolbar-export-pdf",importDocument:"editor-toolbar-import-document",undo:"editor-toolbar-undo",redo:"editor-toolbar-redo",style:"editor-toolbar-style",fontFamily:"editor-toolbar-font-family",fontSize:"editor-toolbar-font-size",color:"editor-toolbar-color",highlight:"editor-toolbar-highlight",textShading:"editor-toolbar-text-shading",bold:"editor-toolbar-bold",italic:"editor-toolbar-italic",underlineControl:"editor-toolbar-underline-control",strike:"editor-toolbar-strike",superscript:"editor-toolbar-superscript",subscript:"editor-toolbar-subscript",insertImage:"editor-toolbar-insert-image",insertTable:"editor-toolbar-insert-table",link:"editor-toolbar-link",unlink:"editor-toolbar-unlink",footnote:"editor-toolbar-footnote",imageAlt:"editor-toolbar-image-alt",imageCaption:"editor-toolbar-image-caption",alignLeft:"editor-toolbar-align-left",alignCenter:"editor-toolbar-align-center",alignRight:"editor-toolbar-align-right",alignJustify:"editor-toolbar-align-justify",bulletList:"editor-toolbar-list-bullet",orderedList:"editor-toolbar-list-ordered",outdent:"editor-toolbar-list-outdent",indent:"editor-toolbar-list-indent",listOptions:"editor-toolbar-list-options",specialIndent:"editor-toolbar-special-indent",lineSpacing:"editor-toolbar-line-spacing-control",metrics:"editor-toolbar-metrics",table:"editor-toolbar-table",margins:"editor-toolbar-margins",section:"editor-toolbar-section"},t.OasisEditorAppLazy=Kt,t.OasisEditorContainer=Yt,t.OasisEditorLoading=Dt,t.PluginCollection=Na,t.Popover=ad,t.RIBBON_TABS=Bd,t.Select=hd,t.SelectField=function(t){const e=$(),[a,n]=Q(t,["label","description","error","options","onChange","class","id"]),r=()=>a.id??e,o=()=>`${r()}-description`,i=()=>`${r()}-error`;return l=dM(),s=l.firstChild,St(l,D(at,{get when(){return a.label},get children(){var t=iM();return St(t,()=>a.label),t}}),s),s.addEventListener("change",t=>{var e;return null==(e=a.onChange)?void 0:e.call(a,t.currentTarget.value)}),xt(s,Y({get id(){return r()},get"aria-invalid"(){return a.error?"true":void 0},get"aria-describedby"(){return[a.description?o():null,a.error?i():null].filter(Boolean).join(" ")}},n),!1,!0),St(s,D(tt,{get each(){return a.options},children:t=>{return St(e=cM(),()=>t.label),M(()=>e.disabled=t.disabled),M(()=>e.value=t.value),e;var e}})),St(l,D(at,{get when(){return a.description},get children(){var t=lM();return St(t,()=>a.description),M(()=>gt(t,"id",o())),t}}),null),St(l,D(at,{get when(){return a.error},get children(){var t=sM();return St(t,()=>a.error),M(()=>gt(t,"id",i())),t}}),null),M(t=>{var e=`oasis-editor-ui-field ${a.class??""}`,n=r();return e!==t.e&&mt(l,t.e=e),n!==t.t&>(l,"for",t.t=n),t},{e:void 0,t:void 0}),l;var l,s},t.Separator=ud,t.SidePanel=Sy,t.SidePanelBody=Iy,t.SidePanelFooter=function(t){const[e,a]=Q(t,["class","children"]);return xt(n=wy(),Y({get class(){return`oasis-editor-plugin-side-panel-footer ${e.class??""}`}},a),!1,!0),St(n,()=>e.children),n;var n},t.SidePanelHeader=Ay,t.SplitButton=gd,t.Tabs=Qy,t.TextField=function(t){const e=$(),[a,n]=Q(t,["label","description","error","onChange","class","id"]),r=()=>a.id??e,o=()=>`${r()}-description`,i=()=>`${r()}-error`;return l=aM(),s=l.firstChild,St(l,D(at,{get when(){return a.label},get children(){var t=$y();return St(t,()=>a.label),t}}),s),s.$$input=t=>{var e;return null==(e=a.onChange)?void 0:e.call(a,t.currentTarget.value)},xt(s,Y({get id(){return r()},get"aria-invalid"(){return a.error?"true":void 0},get"aria-describedby"(){return[a.description?o():null,a.error?i():null].filter(Boolean).join(" ")}},n),!1,!1),St(l,D(at,{get when(){return a.description},get children(){var t=tM();return St(t,()=>a.description),M(()=>gt(t,"id",o())),t}}),null),St(l,D(at,{get when(){return a.error},get children(){var t=eM();return St(t,()=>a.error),M(()=>gt(t,"id",i())),t}}),null),M(t=>{var e=`oasis-editor-ui-field ${a.class??""}`,n=r();return e!==t.e&&mt(l,t.e=e),n!==t.t&>(l,"for",t.t=n),t},{e:void 0,t:void 0}),l;var l,s},t.Toolbar=ic,t.ToolbarButton=$s,t.ToolbarColorPicker=Cd,t.ToolbarGridPicker=zd,t.ToolbarMenu=dd,t.ToolbarSelect=hd,t.ToolbarSeparator=ud,t.ToolbarSplitButton=gd,t.buildRibbonTabDefinitions=Dd,t.commandRefName=jt,t.createDefaultToolbarPreset=Ex,t.createEditorCommandBus=function(t){return{execute(e,a){const n=Xt(e,a);return t.commands.execute(n.name,n.payload)},canExecute(e,a){const n=Xt(e,a);return t.commands.canExecute(n.name,n.payload)},state(e){const a=Xt(e);return t.commands.state(a.name,a.payload)}}},t.createOasisEditor=function(t,e={}){const a=Jt(),n=pt(()=>Kt({...e,runtime:{...e.runtime,client:a}}),t);return a.setDispose(()=>{n(),t.innerHTML=""}),a},t.createOasisEditorContainer=function(t,e={}){const a=Jt(),n=pt(()=>Yt({...e,runtime:{...e.runtime,client:a}}),t);return a.setDispose(()=>{n(),t.innerHTML=""}),a},t.createToolbarRegistry=fM,t.mount=function(t,e={}){const a=Jt(),n=pt(()=>D(Kt,Y(e,{get runtime(){return{...e.runtime,client:a}}})),t);return a.setDispose(()=>{n(),t.innerHTML=""}),Object.assign(a,{unmount:()=>a.dispose()})},t.registerToolbarRenderer=function(t,e){Ud.set(t,e)},t.resolveCommandRef=Xt,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|