documint 0.0.13 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,39 +1,40 @@
1
- import{useEffect as i2,useEffectEvent as k1,useLayoutEffect as SZ,useMemo as o2,useRef as n2,useState as BS}from"react";var X0={id:""};function t0(N){let F=Y0(N);return{children:N,...X0,plainText:F,type:"paragraph"}}function e(N){return t0(D9(N))}function LF(N){let F=Y0(N.children);return{children:N.children,depth:N.depth,...X0,plainText:F,type:"heading"}}function X2(N){return LF({children:D9(N.text),depth:N.depth})}function O0(N,F=[]){return{marks:F,...X0,text:N,type:"text"}}function e0(){return{...X0,type:"lineBreak"}}function _1(N){return{code:N,...X0,type:"code"}}function u1(N){return{children:N.children,...X0,title:N.title??null,type:"link",url:N.url}}function z1(N){let F=N.alt??null,M=N.width??null;return{alt:F,...X0,title:N.title??null,type:"image",url:N.url,width:M}}function Q2(N){return{name:N.name,...X0,type:"mention",userId:N.userId}}function TF(N){return{originalType:N.originalType,...X0,source:N.source,type:"raw"}}function I1(N){let F=l1(N.children);return{checked:N.checked??null,children:N.children,...X0,plainText:F,spread:N.spread??!1,type:"listItem"}}function p1(N){let F=N.items.map((M)=>M.plainText).join(`
2
- `);return{items:N.items,...X0,ordered:N.ordered,plainText:F,spread:N.spread??!1,start:N.start??null,type:"list"}}function x0(N){let F=l1(N);return{children:N,...X0,plainText:F,type:"blockquote"}}function v3(N){return{language:N.language??null,meta:N.meta??null,...X0,plainText:N.source,source:N.source,type:"code"}}function H1(N){let F=Y0(N);return{children:N,...X0,plainText:F}}function J2(N){return{cells:N,...X0}}function x1(N){let F=N.rows.map((M)=>M.cells.map((A)=>A.plainText).join(" | ")).join(`
3
- `);return{align:N.align??[],plainText:F,...X0,rows:N.rows,type:"table"}}function wF(){return{plainText:"",...X0,type:"divider"}}function h3(N){return{originalType:N.originalType,...X0,plainText:N.source,source:N.source,type:"raw"}}function A9(N){return{attributes:N.attributes,body:N.body,...X0,name:N.name,plainText:N.body,type:"directive"}}function G0(N){let F=[];for(let M of N){let A=F.at(-1);if(A?.type==="text"&&M.type==="text"&&A.marks.join(",")===M.marks.join(",")){F[F.length-1]=O0(A.text+M.text,A.marks);continue}F.push(M)}return F}function w0(N,F){return N.type==="heading"?LF({children:F,depth:N.depth}):t0(F)}function N1(N,F){return I1({checked:N.checked,children:F,spread:N.spread})}function q0(N,F,M={}){return p1({items:F,ordered:M.ordered??N.ordered,spread:M.spread??N.spread,start:M.start??N.start})}function g0(N,F){return x1({align:N.align,rows:F})}function MN(N,F){return v3({language:N.language,meta:N.meta,source:F})}function AN(N,F){return h3({originalType:N.originalType,source:F})}function D9(N){return N.length>0?[O0(N)]:[]}function k3(N,F){m3(N.blocks,F,$9(),Z9())}function sZ(N,F){m3(N,F,$9(),Z9())}function Z1(N,F){let M=null,A={enterBlock(D){if(D.id===F)return M=D,"stop"}};if(Array.isArray(N))sZ(N,A);else k3(N,A);return M}function m3(N,F,M,A){for(let[D,E]of N.entries()){if(M.stopped)return;let $=`${A.pathPrefix}.${D}`,Z={blockAncestors:A.blockAncestors,depth:A.depth,parentBlock:A.parentBlock,path:$},Y=F.enterBlock?.(E,Z);if(q2(Y,M))return;if(Y!=="skip")switch(E.type){case"list":E9(E.items,E,F,M,A,$);break;case"blockquote":case"listItem":E9(E.children,E,F,M,A,$);break;case"heading":case"paragraph":g3(E.children,F,M,{block:E,blockAncestors:[...A.blockAncestors,E],inlineAncestors:[],parentInline:null,pathPrefix:`${$}.children`});break;case"table":oZ(E,F,M,{blockAncestors:[...A.blockAncestors,E],pathPrefix:$});break;case"code":case"directive":case"divider":case"raw":break}if(M.stopped)return;if(q2(F.leaveBlock?.(E,Z),M))return}}function g3(N,F,M,A){for(let[D,E]of N.entries()){if(M.stopped)return;let $=`${A.pathPrefix}.${D}`,Z={block:A.block,blockAncestors:A.blockAncestors,inlineAncestors:A.inlineAncestors,parentInline:A.parentInline,path:$},Y=F.enterInline?.(E,Z);if(q2(Y,M))return;if(Y!=="skip"){if(E.type==="link")iZ(E.children,E,F,M,A,$)}if(M.stopped)return;if(q2(F.leaveInline?.(E,Z),M))return}}function $9(){return{stopped:!1}}function Z9(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function E9(N,F,M,A,D,E){m3(N,M,A,{blockAncestors:[...D.blockAncestors,F],depth:D.depth+1,parentBlock:F,pathPrefix:`${E}.children`})}function iZ(N,F,M,A,D,E){g3(N,M,A,{block:D.block,blockAncestors:D.blockAncestors,inlineAncestors:[...D.inlineAncestors,F],parentInline:F,pathPrefix:`${E}.children`})}function oZ(N,F,M,A){for(let[D,E]of N.rows.entries())for(let[$,Z]of E.cells.entries()){if(M.stopped)return;let Y=`${A.pathPrefix}.rows.${D}.cells.${$}`,X={blockAncestors:A.blockAncestors,cellIndex:$,path:Y,row:E,rowIndex:D,table:N},Q=F.enterTableCell?.(Z,X);if(q2(Q,M))return;if(Q!=="skip")g3(Z.children,F,M,{block:N,blockAncestors:A.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${Y}.children`});if(M.stopped)return;if(q2(F.leaveTableCell?.(Z,X),M))return}}function q2(N,F){if(N!=="stop")return!1;return F.stopped=!0,!0}function U2(N,F,M="root",A=null){let D=!1,E=[];for(let[$,Z]of N.entries()){let Y=`${M}.${$}`,X=F(Z,{parent:A,path:Y,recurse:()=>nZ(Z,F,`${Y}.children`)});if(X===null){D=!0;continue}if(Array.isArray(X)){D=!0,E.push(...X);continue}if(X!==Z)D=!0;E.push(X)}return D?E:N}function nZ(N,F,M){switch(N.type){case"blockquote":case"listItem":{let A=U2(N.children,F,M,N);return A===N.children?N:{...N,children:A}}case"list":{let A=U2(N.items,F,M,N);return A===N.items?N:{...N,items:A}}default:return N}}function V2(N,F=[],M){return{blocks:N.map((A,D)=>I3(A,D)),comments:F,frontMatter:M}}function d1(N,F,M,A){let D=A.map((Z,Y)=>I3(Z,F+Y)),E=N.blocks.slice(F+M),$=A.length===M?E:E.map((Z,Y)=>I3(Z,F+D.length+Y));return{blocks:[...N.blocks.slice(0,F),...D,...$],comments:N.comments,frontMatter:N.frontMatter}}function X9(N,F,M,A){return{blocks:N.blocks,comments:[...N.comments.slice(0,F),...A,...N.comments.slice(F+M)],frontMatter:N.frontMatter}}function Q9(N,F,M,A){if(A!==void 0)return Y9(N,A,F,M);for(let D=0;D<N.blocks.length;D+=1){let E=Y9(N,D,F,M);if(E)return E}return null}function Y9(N,F,M,A){let D=N.blocks[F];if(!D)return null;let E=J9(D,M,A);return E?d1(N,F,1,[E]):null}function J9(N,F,M){if(N.id===F)return M(N);switch(N.type){case"blockquote":{let A=u3(N.children,F,M);return A?x0(A):null}case"listItem":{let A=u3(N.children,F,M);return A?N1(N,A):null}case"list":{let A=u3(N.items,F,M);return A?q0(N,A):null}default:return null}}function u3(N,F,M){let A=!1,D=N.map((E)=>{let $=J9(E,F,M);if(!$)return E;return A=!0,$});return A?D:null}function Y0(N){return N.map((F)=>{switch(F.type){case"lineBreak":return`
4
- `;case"image":return F.alt??"";case"mention":return`@${F.name}`;case"code":return F.code;case"link":return Y0(F.children);case"text":return F.text;case"raw":return F.source}}).join("")}function l1(N){return N.map((F)=>{switch(F.type){case"blockquote":case"listItem":return l1(F.children);case"code":return F.source;case"directive":return F.body;case"heading":case"paragraph":return Y0(F.children);case"list":return F.items.map((M)=>M.plainText).join(`
5
- `);case"table":return F.rows.map((M)=>M.cells.map((A)=>A.plainText).join(" | ")).join(`
1
+ import{useEffect as UN,useEffectEvent as r1,useLayoutEffect as mZ,useMemo as lF,useRef as KN,useState as dH}from"react";var U0={id:""};function $1(N){let F=J0(N);return{children:N,...U0,plainText:F,type:"paragraph"}}function F0(N){return $1(FM(N))}function rF(N){let F=J0(N.children);return{children:N.children,depth:N.depth,...U0,plainText:F,type:"heading"}}function T2(N){return rF({children:FM(N.text),depth:N.depth})}function u0(N,F=[]){return{marks:F,...U0,text:N,type:"text"}}function y1(){return{...U0,type:"lineBreak"}}function O1(N){return{code:N,...U0,type:"code"}}function o1(N){return{children:N.children,...U0,title:N.title??null,type:"link",url:N.url}}function w1(N){let F=N.alt??null,A=N.width??null;return{alt:F,...U0,title:N.title??null,type:"image",url:N.url,width:A}}function C2(N){return{name:N.name,...U0,type:"mention",userId:N.userId}}function cF(N){return{originalType:N.originalType,...U0,source:N.source,type:"raw"}}function n1(N){let F=N2(N.children);return{checked:N.checked??null,children:N.children,...U0,plainText:F,spread:N.spread??!1,type:"listItem"}}function t1(N){let F=N.items.map((A)=>A.plainText).join(`
2
+ `);return{items:N.items,...U0,ordered:N.ordered,plainText:F,spread:N.spread??!1,start:N.start??null,type:"list"}}function d0(N){let F=N2(N);return{children:N,...U0,plainText:F,type:"blockquote"}}function Y4(N){return{language:N.language??null,meta:N.meta??null,...U0,plainText:N.source,source:N.source,type:"code"}}function L1(N){let F=J0(N);return{children:N,...U0,plainText:F}}function j2(N){return{cells:N,...U0}}function e1(N){let F=N.rows.map((A)=>A.cells.map((M)=>M.plainText).join(" | ")).join(`
3
+ `);return{align:N.align??[],plainText:F,...U0,rows:N.rows,type:"table"}}function sF(){return{plainText:"",...U0,type:"divider"}}function X4(N){return{originalType:N.originalType,...U0,plainText:N.source,source:N.source,type:"raw"}}function NM(N){return{attributes:N.attributes,body:N.body,...U0,name:N.name,plainText:N.body,type:"directive"}}function W0(N){let F=[];for(let A of N){let M=F.at(-1);if(M?.type==="text"&&A.type==="text"&&M.marks.join(",")===A.marks.join(",")){F[F.length-1]=u0(M.text+A.text,M.marks);continue}F.push(A)}return F}function k0(N,F){return N.type==="heading"?rF({children:F,depth:N.depth}):$1(F)}function Z1(N,F){return n1({checked:N.checked,children:F,spread:N.spread})}function H0(N,F,A={}){return t1({items:F,ordered:A.ordered??N.ordered,spread:A.spread??N.spread,start:A.start??N.start})}function a0(N,F){return e1({align:N.align,rows:F})}function HN(N,F){return Y4({language:N.language,meta:N.meta,source:F})}function _N(N,F){return X4({originalType:N.originalType,source:F})}function FM(N){return N.length>0?[u0(N)]:[]}function R2(N){return b2("root",N)}function b2(N,F){return`${N}.${F}`}function r0(N){return`${N}.children`}function Q4(N){return`${N}.source`}function Y1(N,F){return b2(r0(N),F)}function iF(N,F){return Y1(N,F)}function S4(N,F){return b2(N,F)}function f2(N,F){return`${N}.rows.${F}`}function F2(N,F){return`${N}.cells.${F}`}function AM(N,F){return S4(r0(N),F)}function J4(N,F){V4(N.blocks,F,EM(),XY())}function YY(N,F,A={}){V4(N,F,EM(),$M(A.pathPrefix??"root",A.startIndex??0))}function o0(N,F){let A=null,M={enterBlock(D){if(D.id===F)return A=D,"stop"}};if(Array.isArray(N))YY(N,M);else J4(N,M);return A}function V4(N,F,A,M){for(let[D,E]of N.entries()){if(A.stopped)return;let $=b2(M.pathPrefix,M.startIndex+D),y={blockAncestors:M.blockAncestors,depth:M.depth,parentBlock:M.parentBlock,path:$},Z=F.enterBlock?.(E,y);if(T1(Z,A))return;if(Z!=="skip")switch(E.type){case"list":MM(E.items,E,F,A,M,$);break;case"blockquote":case"listItem":MM(E.children,E,F,A,M,$);break;case"heading":case"paragraph":yM(E.children,F,A,{block:E,blockAncestors:[...M.blockAncestors,E],container:E,kind:"block",path:r0($)});break;case"table":SY(E,F,A,{blockAncestors:[...M.blockAncestors,E],pathPrefix:$});break;case"code":case"directive":case"divider":case"raw":break}if(A.stopped)return;if(T1(F.leaveBlock?.(E,y),A))return}}function DM(N,F,A,M){for(let[D,E]of N.entries()){if(A.stopped)return;let $=S4(M.pathPrefix,D),y={block:M.block,blockAncestors:M.blockAncestors,inlineAncestors:M.inlineAncestors,parentInline:M.parentInline,path:$},Z=F.enterInline?.(E,y);if(T1(Z,A))return;if(Z!=="skip"){if(E.type==="link")QY(E.children,E,F,A,M,$)}if(A.stopped)return;if(T1(F.leaveInline?.(E,y),A))return}}function EM(){return{stopped:!1}}function XY(){return $M("root",0)}function $M(N,F){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:N,startIndex:F}}function MM(N,F,A,M,D,E){V4(N,A,M,{blockAncestors:[...D.blockAncestors,F],depth:D.depth+1,parentBlock:F,pathPrefix:r0(E),startIndex:0})}function QY(N,F,A,M,D,E){DM(N,A,M,{block:D.block,blockAncestors:D.blockAncestors,inlineAncestors:[...D.inlineAncestors,F],parentInline:F,pathPrefix:r0(E)})}function SY(N,F,A,M){for(let[D,E]of N.rows.entries())for(let[$,y]of E.cells.entries()){if(A.stopped)return;let Z=F2(f2(M.pathPrefix,D),$),Y={blockAncestors:M.blockAncestors,cellIndex:$,path:Z,row:E,rowIndex:D,table:N},X=F.enterTableCell?.(y,Y);if(T1(X,A))return;if(X!=="skip")yM(y.children,F,A,{block:N,blockAncestors:M.blockAncestors,container:y,kind:"tableCell",path:Z});if(A.stopped)return;if(T1(F.leaveTableCell?.(y,Y),A))return}}function yM(N,F,A,M){let D=F.enterInlineContainer?.(N,M);if(T1(D,A)||D==="skip")return;if(VY(N,F,A,M),A.stopped)return;DM(N,F,A,{block:M.block,blockAncestors:M.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:JY(M)})}function JY(N){return N.kind==="tableCell"?r0(N.path):N.path}function VY(N,F,A,M){if(!F.enterPlainText)return;let D=0;for(let E of N){if(A.stopped)return;if(E.type==="text"){let $=D,y=$+E.text.length;if(E.marks.length===0&&T1(F.enterPlainText(E.text,{...M,endOffset:y,startOffset:$}),A))return;D=y;continue}D+=ZM(E)}}function ZM(N){switch(N.type){case"lineBreak":return 1;case"image":case"mention":return 1;case"code":return N.code.length;case"raw":return N.source.length;case"text":return N.text.length;case"link":return N.children.reduce((F,A)=>F+ZM(A),0)}}function T1(N,F){if(N!=="stop")return!1;return F.stopped=!0,!0}function u2(N,F,A="root",M=null){let D=!1,E=[];for(let[$,y]of N.entries()){let Z=b2(A,$),Y=F(y,{parent:M,path:Z,recurse:()=>qY(y,F,r0(Z))});if(Y===null){D=!0;continue}if(Array.isArray(Y)){D=!0,E.push(...Y);continue}if(Y!==y)D=!0;E.push(Y)}return D?E:N}function qY(N,F,A){switch(N.type){case"blockquote":case"listItem":{let M=u2(N.children,F,A,N);return M===N.children?N:{...N,children:M}}case"list":{let M=u2(N.items,F,A,N);return M===N.items?N:{...N,items:M}}default:return N}}function v2(N,F=[],A){return{blocks:N.map((M,D)=>U4(M,D)),comments:QM(F),frontMatter:A}}function A2(N,F,A,M){let D=M.map((y,Z)=>U4(y,F+Z)),E=N.blocks.slice(F+A),$=M.length===A?E:E.map((y,Z)=>U4(y,F+D.length+Z));return{blocks:[...N.blocks.slice(0,F),...D,...$],comments:N.comments,frontMatter:N.frontMatter}}function XM(N,F,A,M){return{blocks:N.blocks,comments:[...N.comments.slice(0,F),...QM(M,F),...N.comments.slice(F+A)],frontMatter:N.frontMatter}}function QM(N,F=0){return N.map((A,M)=>{if(A.id)return A;let D=A.comments[0];return{...A,id:y0("commentThread",`comments.${F+M}`,`${A.anchor.kind??""}:${A.anchor.prefix??""}:${A.anchor.suffix??""}:${A.quote}:${D?.body??""}:${D?.updatedAt??""}`)}})}function SM(N,F,A,M){if(M!==void 0)return YM(N,M,F,A);for(let D=0;D<N.blocks.length;D+=1){let E=YM(N,D,F,A);if(E)return E}return null}function YM(N,F,A,M){let D=N.blocks[F];if(!D)return null;let E=JM(D,A,M);return E?A2(N,F,1,[E]):null}function JM(N,F,A){if(N.id===F)return A(N);switch(N.type){case"blockquote":{let M=q4(N.children,F,A);return M?d0(M):null}case"listItem":{let M=q4(N.children,F,A);return M?Z1(N,M):null}case"list":{let M=q4(N.items,F,A);return M?H0(N,M):null}default:return null}}function q4(N,F,A){let M=!1,D=N.map((E)=>{let $=JM(E,F,A);if(!$)return E;return M=!0,$});return M?D:null}function J0(N){return N.map((F)=>{switch(F.type){case"lineBreak":return`
4
+ `;case"image":return F.alt??"";case"mention":return`@${F.name}`;case"code":return F.code;case"link":return J0(F.children);case"text":return F.text;case"raw":return F.source}}).join("")}function N2(N){return N.map((F)=>{switch(F.type){case"blockquote":case"listItem":return N2(F.children);case"code":return F.source;case"directive":return F.body;case"heading":case"paragraph":return J0(F.children);case"list":return F.items.map((A)=>A.plainText).join(`
5
+ `);case"table":return F.rows.map((A)=>A.cells.map((M)=>M.plainText).join(" | ")).join(`
6
6
  `);case"divider":return"";case"raw":return F.source}}).join(`
7
- `).trim()}function x3(N){return N.every((F)=>F.type==="text"&&F.marks.length===0)}function RF(N){if(N.length!==1)return!1;let F=N[0];return F.type==="paragraph"&&x3(F.children)}function bF(N){switch(N.kind){case"text":return N.text;case"inlines":return Y0(N.inlines);case"blocks":return l1(N.blocks)}}function _0(N){switch(N.type){case"blockquote":case"listItem":return N.children;case"list":return N.items;default:return null}}function B1(N,F){if(F.length===0)return null;switch(N.type){case"blockquote":return x0(F);case"list":return q0(N,F);case"listItem":return N1(N,F);default:return null}}function I3(N,F){return jF(N,`root.${F}`)}function jF(N,F){switch(N.type){case"blockquote":{let M=N.children.map((D,E)=>jF(D,`${F}.children.${E}`)),A=l1(M);return{children:M,id:Q0("blockquote",F,A),plainText:A,type:"blockquote"}}case"code":return{id:Q0("code",F,`${N.language??""}:${N.source}`),language:N.language,meta:N.meta,plainText:N.source,source:N.source,type:"code"};case"directive":return{attributes:N.attributes,body:N.body,id:Q0("directive",F,`${N.name}{${N.attributes}}:${N.body}`),name:N.name,plainText:N.body,type:"directive"};case"heading":{let M=N.children.map((D,E)=>CF(D,`${F}.children.${E}`)),A=Y0(M);return{children:M,depth:N.depth,id:Q0("heading",F,`${N.depth}:${A}`),plainText:A,type:"heading"}}case"list":{let M=N.items.map((D,E)=>jF(D,`${F}.children.${E}`)),A=M.map((D)=>D.plainText).join(`
8
- `);return{id:Q0("list",F,`${String(N.ordered)}:${A}`),items:M,ordered:N.ordered,plainText:A,spread:N.spread,start:N.start,type:"list"}}case"listItem":{let M=N.children.map((D,E)=>jF(D,`${F}.children.${E}`)),A=l1(M);return{checked:N.checked,children:M,id:Q0("listItem",F,A),plainText:A,spread:N.spread,type:"listItem"}}case"paragraph":{let M=N.children.map((D,E)=>CF(D,`${F}.children.${E}`)),A=Y0(M);return{children:M,id:Q0("paragraph",F,A),plainText:A,type:"paragraph"}}case"table":{let M=N.rows.map((D,E)=>tZ(D,`${F}.rows.${E}`)),A=M.map((D)=>D.cells.map((E)=>E.plainText).join(" | ")).join(`
9
- `);return{align:N.align,id:Q0("table",F,A),plainText:A,rows:M,type:"table"}}case"divider":return{id:Q0("divider",F,"divider"),plainText:"",type:"divider"};case"raw":return{id:Q0("raw",F,N.source),originalType:N.originalType,plainText:N.source,source:N.source,type:"raw"}}}function tZ(N,F){return{cells:N.cells.map((M,A)=>{let D=M.children.map(($,Z)=>CF($,`${F}.cells.${A}.children.${Z}`)),E=Y0(D);return{children:D,id:Q0("tableCell",`${F}.cells.${A}`,E),plainText:E}}),id:Q0("tableRow",F,String(N.cells.length))}}function CF(N,F){switch(N.type){case"lineBreak":return{id:Q0("lineBreak",F,"lineBreak"),type:"lineBreak"};case"image":return{alt:N.alt,id:Q0("image",F,`${N.url}:${N.width??""}:${N.alt??""}`),title:N.title,type:"image",url:N.url,width:N.width};case"mention":return{id:Q0("mention",F,`${N.userId}:${N.name}`),name:N.name,type:"mention",userId:N.userId};case"code":return{code:N.code,id:Q0("code",F,N.code),type:"code"};case"link":{let M=N.children.map((D,E)=>CF(D,`${F}.children.${E}`)),A=Y0(M);return{children:M,id:Q0("link",F,`${N.url}:${A}`),title:N.title,type:"link",url:N.url}}case"text":return{id:Q0("text",F,`${N.text}:${N.marks.join(",")}`),marks:N.marks,text:N.text,type:"text"};case"raw":return{id:Q0("raw",F,N.source),originalType:N.originalType,source:N.source,type:"raw"}}}function q9(N){return U2(N,(F,{recurse:M})=>{switch(F.type){case"blockquote":case"list":case"listItem":return M();case"heading":case"paragraph":return w0(F,p3(F.children));case"table":return g0(F,F.rows.map((A)=>({...A,cells:A.cells.map((D)=>({...D,children:p3(D.children)}))})));default:return F}})}function p3(N){let F=null,M=()=>F??=[...N];for(let A=N.length-1;A>=0;A-=1){let D=N[A];if(D.type==="text"){let E=D.text.replace(/[ \t]+$/u,"");if(E.length===D.text.length)return F??N;let $=M();if(E.length===0){$.splice(A,1);continue}return $[A]={...D,text:E},$}if(D.type==="link"){let E=p3(D.children);if(E===D.children)return F??N;let $=M();if(E.length===0){$.splice(A,1);continue}return $[A]={...D,children:E},$}return F??N}return F??N}function Q0(N,F,M){let A=2166136261;for(let D of`${N}:${F}:${M}`)A^=D.charCodeAt(0),A=Math.imul(A,16777619);return`${N}-${(A>>>0).toString(36)}`}var l3="text";function d3(N){return N==="text"||N==="code"||N==="tableCell"}function a3(N){return N===l3?void 0:N}function V9(N){switch(N){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function fF(N){let F=[];return k3(N,{enterBlock(M){switch(M.type){case"heading":case"paragraph":F.push({containerKind:"text",containerOrdinal:F.length,id:M.id,text:Y0(M.children)});break;case"code":F.push({containerKind:"code",containerOrdinal:F.length,id:M.id,text:M.source});break}},enterTableCell(M){F.push({containerKind:"tableCell",containerOrdinal:F.length,id:M.id,text:Y0(M.children)})}}),F}function r3(N,F,M){return{prefix:N.slice(Math.max(0,F-U9),F),suffix:N.slice(M,Math.min(N.length,M+U9))}}function DN(N,F,M){let A=l0(F,0,N.text.length),D=l0(M,A,N.text.length),{prefix:E,suffix:$}=r3(N.text,A,D);return{kind:a3(N.containerKind),prefix:E||void 0,suffix:$||void 0}}function EN(N,F,M){let A=l0(F,0,N.text.length),D=l0(M,A,N.text.length);return N.text.slice(A,D)}function F1(N,F){if(F.length===0)return[];let M=[],A=0;while(A<=N.length){let D=N.indexOf(F,A);if(D===-1)break;M.push(D),A=D+Math.max(1,F.length)}return M}function K2(N,F,M){if(F.length===0||M.length===0)return[];let A=[];for(let D of F1(N,F)){let E=D+F.length,$=N.indexOf(M,E);if($!==-1)A.push({startOffset:E,endOffset:$})}return A}function c3(N,F,M){if(!F)return!1;return N.slice(Math.max(0,M-F.length),M)===F}function s3(N,F,M){if(!F)return!1;return N.slice(M,M+F.length)===F}var U9=24;function l0(N,F,M){return Math.min(Math.max(N,F),M)}var K9=48,G9=64,eZ=32;function $N(N,F){let M=N.anchor.kind??l3,A=fF(F).filter(($)=>$.containerKind===M),D=NY(N,A);if(D.length>0)return y9(N,D,null);let E=FY(N,A);if(E.length>0)return y9(N,E,"repaired");return{match:null,repair:null,status:"stale"}}function NY(N,F){let M=[],A=N.quote;if(A.length===0)return M;for(let D of F)for(let E of F1(D.text,A))M.push({container:D,endOffset:E+A.length,score:DY(N,D,E),startOffset:E});return M.sort((D,E)=>E.score-D.score),M}function FY(N,F){let M=[];for(let A of F)M.push(...MY(N,A));return M.sort((A,D)=>D.score-A.score),M}function MY(N,F){let M=[],A=N.quote.length,D=F.text,E=N.anchor.prefix??"",$=N.anchor.suffix??"";if(E.length>0&&$.length>0){for(let Z of K2(D,E,$))M.push({container:F,endOffset:Z.endOffset,score:i3(N,F,Z.startOffset,Z.endOffset,A),startOffset:Z.startOffset});return M}if(E.length>0){for(let Z of F1(D,E)){let Y=Z+E.length,X=l0(Y+A,Y,D.length);M.push({container:F,endOffset:X,score:i3(N,F,Y,X,A),startOffset:Y})}return M}if($.length>0)for(let Z of F1(D,$)){let Y=Z,X=l0(Y-A,0,Y);M.push({container:F,endOffset:Y,score:i3(N,F,X,Y,A),startOffset:X})}return M}function y9(N,F,M){let[A,D]=F;if(!A)return{match:null,repair:null,status:"stale"};if(D&&A.score===D.score)return{match:null,repair:null,status:"ambiguous"};let E=DN(A.container,A.startOffset,A.endOffset),$=EN(A.container,A.startOffset,A.endOffset),Z=M??($===N.quote&&(E.prefix??"")===(N.anchor.prefix??"")&&(E.suffix??"")===(N.anchor.suffix??"")?"matched":"repaired");return{match:AY(A.container,A.startOffset,A.endOffset),repair:{anchor:E,quote:$},status:Z}}function AY(N,F,M){return{containerId:N.id,containerKind:N.containerKind,containerOrdinal:N.containerOrdinal,endOffset:M,startOffset:F}}function DY(N,F,M){let A=0;if(c3(F.text,N.anchor.prefix,M))A+=K9;if(s3(F.text,N.anchor.suffix,M+N.quote.length))A+=K9;return A}function i3(N,F,M,A,D){let E=0;if(c3(F.text,N.anchor.prefix,M))E+=G9;if(s3(F.text,N.anchor.suffix,A))E+=G9;if(E+=Math.max(0,eZ-Math.abs(D-(A-M))),N.quote.length>0){let $=F.text.slice(M,A);if($.length>0)E+=EY(N.quote,$),E+=$Y(N.quote,$)}return E}function EY(N,F){let M=0;while(M<N.length&&M<F.length&&N[M]===F[M])M+=1;return M}function $Y(N,F){let M=0;while(M<N.length&&M<F.length&&N[N.length-1-M]===F[F.length-1-M])M+=1;return M}function o3(N){if(!N||typeof N!=="object"||Array.isArray(N))return null;let F=N,M=YY(F.anchor),A=typeof F.quote==="string"?F.quote:null,D=Array.isArray(F.comments)?F.comments.flatMap((E)=>{let $=ZY(E);return $?[$]:[]}):[];if(!M||!A||D.length===0)return null;return{quote:A,anchor:M,comments:D,resolvedAt:typeof F.resolvedAt==="string"?F.resolvedAt:void 0}}function ZY(N){if(!N||typeof N!=="object"||Array.isArray(N))return null;let F=N;if(typeof F.body!=="string"||typeof F.updatedAt!=="string")return null;return{body:F.body,updatedAt:F.updatedAt}}function YY(N){if(!N||typeof N!=="object"||Array.isArray(N))return null;let{kind:F,prefix:M,suffix:A}=N;if("kind"in N&&!d3(F)||"prefix"in N&&typeof M!=="string"||"suffix"in N&&typeof A!=="string")return null;return{kind:d3(F)?a3(F):void 0,prefix:typeof M==="string"?M:void 0,suffix:typeof A==="string"?A:void 0}}function n3(N){let F=N.createdAt??new Date().toISOString();return{comments:[S9({body:N.body,updatedAt:F})],quote:N.quote,anchor:N.anchor}}function t3(N,F){let M=S9(F);return{...N,comments:[...N.comments,M]}}function e3(N,F,M,A=new Date().toISOString()){let D=M.trim();if(D.length===0)return N;let E=!1,$=N.comments.map((Z,Y)=>{if(Y!==F||Z.body===D)return Z;return E=!0,{...Z,body:D,updatedAt:A}});if(!E)return N;return{...N,comments:$}}function N4(N,F){let M=N.comments.filter((A,D)=>D!==F);if(M.length===N.comments.length)return N;if(M.length===0)return null;return{...N,comments:M}}function F4(N,F,M=new Date().toISOString()){if(W1(N)===F)return N;return{...N,resolvedAt:F?M:void 0}}function W1(N){return N.resolvedAt!=null}function M4(N){if(N.comments.length===0)return null;return N.comments.reduce((F,M)=>M.updatedAt>F?M.updatedAt:F,N.comments[0].updatedAt)}function S9(N){let F=N.updatedAt??new Date().toISOString();return{body:N.body,updatedAt:F}}function _9(N,F,M,A,D){let E=A-M,$=D-E;if(A<=N)return{end:F+$,start:N+$};if(M>=F)return{end:F,start:N};let Z=Math.max(0,Math.min(M,F)-N),Y=Math.max(0,F-Math.max(A,N)),X=N<M?N:M;return{end:X+Z+D+Y,start:X}}function D4(N,F,M){let A=M.trim();if(A.length===0||F.startOffset===F.endOffset)return null;let D=N.regionIndex.get(F.regionId)??null,E=D?A4(N,D):null;if(!E)return null;return n3({anchor:DN(E,F.startOffset,F.endOffset),body:A,quote:EN(E,F.startOffset,F.endOffset)})}function j0(N){let F="documentIndex"in N?N.documentIndex:N,M=vF(F),A=F.document.comments,D=[...A],E=[];for(let[$,Z]of A.entries()){let Y=$N(Z,F.document);if(!Y.match)continue;let Q=M.findBySemanticMatch(Y.match.containerId,Y.match.containerOrdinal)?.runtimeContainer??null;if(!Q)continue;if(Y.repair)D[$]={...Z,anchor:Y.repair.anchor,quote:Y.repair.quote};E.push({endOffset:Y.match.endOffset,resolution:Y,regionId:Q.id,resolved:Z.resolvedAt!=null,startOffset:Y.match.startOffset,threadIndex:$})}return{liveRanges:E,threads:D}}function E4(N,F,M,A,D,E){if(N.document.comments.length===0)return F.document.comments;let $=N.commentContainerIndex.get(M.semanticRegionId)??[],Z=new Set($);if($.length===0)return F.document.comments;let Y=j0(N),X=new Map(Y.liveRanges.map((U)=>[U.threadIndex,U])),Q=A4(N,M),J=G2(F,M.path),q=J?A4(F,J):null;if(!Q||!q)return F.document.comments;return F.document.comments.map((U,V)=>{if(!Z.has(V))return U;let y=X.get(V),G=y?.resolution.match??null;if(!y||!G||G.containerId!==Q.id)return U;let K=_9(G.startOffset,G.endOffset,A,D,E.length);return{...U,anchor:DN(q,K.start,K.end),quote:EN(q,K.start,K.end)}})}function A4(N,F){let M=XY(N,F);if(!M)return null;return{containerKind:M,containerOrdinal:-1,id:F.semanticRegionId,text:F.text}}function XY(N,F){if(N.tableCellIndex.has(F.id))return"tableCell";return V9(F.blockType)}function hF(N,F){if(F.length===0)return[];let M=vF(N),A=M.list();return F.map((D)=>({...D,cursorPoint:QY(D,A,M),viewport:null}))}function QY(N,F,M){if(!N.cursor)return null;let A=JY(F,N.cursor),D=qY(A,N.cursor);if(D.length!==1)return null;let E=D[0],$=M.resolveRuntimeContainer(E.container.id);if(!$)return null;return{offset:Math.max(0,Math.min(E.offset,$.text.length)),regionId:$.id}}function JY(N,F){return F.kind?N.filter((M)=>M.containerKind===F.kind):N}function qY(N,F){if(F.prefix&&F.suffix)return UY(N,F.prefix,F.suffix);if(F.prefix)return z9(N,F.prefix,"after");if(F.suffix)return z9(N,F.suffix,"before");return[]}function z9(N,F,M){let A=[];for(let D of N)for(let E of F1(D.text,F))A.push({container:D,offset:M==="after"?E+F.length:E});return A}function UY(N,F,M){let A=[];for(let D of N)for(let E of K2(D.text,F,M))A.push({container:D,offset:E.startOffset});return A}var VY=48;function kF(N,F,M){let A="documentIndex"in N?N.documentIndex:N;if(M.length===0)return[];return M.map((D)=>({...D,viewport:KY(A,F,D)}))}function mF(N,F,M){let A="documentIndex"in N?N.documentIndex:N,D=H9(A,F,M);if(!D)return"unresolved";return B9(F,D)}function KY(N,F,M){if(!M.cursorPoint)return{status:"unresolved"};let A=H9(N,F,M.cursorPoint);if(!A)return{status:"unresolved"};return{scrollTop:GY(F,A),status:B9(F,A)}}function H9(N,F,M){let A=d0(F.layout,N,M);if(A)return{bottom:A.top+A.height,top:A.top};return F.estimateRegionBounds(M.regionId)}function B9(N,F){let M=N.viewport.top,A=M+N.viewport.height;if(F.bottom<M)return"above";if(F.top>A)return"below";return"visible"}function GY(N,F){let M=Math.max(0,N.totalHeight-N.viewport.height),A=F.top-Math.min(VY,N.viewport.height/4);return Math.max(0,Math.min(M,A))}function vF(N){let F=fF(N.document),M=new Map(F.map((D)=>[D.id,D])),A=new Map(N.regions.map((D)=>[D.semanticRegionId,D]));return{findBySemanticMatch(D,E){let $=M.get(D)??F[E]??null;if(!$)return null;return{runtimeContainer:A.get($.id)??null,semanticContainer:$}},list(D){return D?F.filter((E)=>E.containerKind===D):F},resolveRuntimeContainer(D){return A.get(D)??null}}}var y2="",W9=1e6;function ZN(N,F,M){return`${N}:${F}:${M}`}function S2(N){let F=kY(N),M=Z4(F.blocks.map((A,D)=>XN(A,D)));return Y4(F,M)}function XN(N,F){let M=[],A=[],D=[],E=new Set,$=0;function Z(X,Q,J,q,U=null){if(A.length>0)D.push(`
10
- `),$+=1;let V=J.map((K)=>K.text).join(""),y=$,G=y+V.length;D.push(V),$=G;for(let K of J)if(K.image)E.add(K.image.url);A.push({blockId:X.id,blockType:X.type,end:G,id:`${X.id}:${Q}`,path:Q,rootIndex:F,inlines:J,semanticRegionId:q,start:y,tableCellPosition:U,text:V})}function Y(X,Q,J,q){let U={childBlockIds:[],depth:J,end:$,id:X.id,parentBlockId:q,path:Q,regionIds:[],rootIndex:F,start:$,type:X.type};switch(M.push(U),X.type){case"blockquote":case"listItem":for(let[V,y]of X.children.entries())U.childBlockIds.push(y.id),Y(y,`${Q}.children.${V}`,J+1,X.id);break;case"code":{Z(X,`${Q}.source`,[{end:X.source.length,id:`${X.id}:code`,image:null,inlineCode:!1,kind:"text",link:null,marks:[],mention:null,originalType:null,start:0,text:X.source}],X.id),U.regionIds.push(A.at(-1).id);break}case"heading":case"paragraph":Z(X,`${Q}.children`,$4(X.children),X.id),U.regionIds.push(A.at(-1).id);break;case"list":for(let[V,y]of X.items.entries())U.childBlockIds.push(y.id),Y(y,`${Q}.children.${V}`,J+1,X.id);break;case"table":for(let[V,y]of X.rows.entries())for(let[G,K]of y.cells.entries())Z(X,`${Q}.rows.${V}.cells.${G}`,$4(K.children),K.id,{cellIndex:G,rowIndex:V}),U.regionIds.push(A.at(-1).id);break;case"divider":break;case"directive":break;case"raw":Z(X,`${Q}.source`,[{end:X.source.length,id:`${X.id}:raw`,image:null,inlineCode:!1,kind:"raw",link:null,marks:[],mention:null,originalType:X.originalType,start:0,text:X.source}],X.id),U.regionIds.push(A.at(-1).id);break}U.end=$}return Y(N,`root.${F}`,0,null),{blockRange:{end:M.length,start:0},blocks:M,end:$,imageUrls:E,length:$,regionRange:A.length>0?{end:A.length,start:0}:void 0,regions:A,rootIndex:F,start:0,text:D.join("")}}function Z4(N,F=null){let M=[],A=0,D=0,E=0,$=!1;for(let[Z,Y]of N.entries()){if(Y.regions.length>0&&$)E+=1;let X={...Y,blockRange:{end:A+Y.blocks.length,start:A},end:E+Y.length,regionRange:Y.regions.length>0?{end:D+Y.regions.length,start:D}:void 0,start:E},Q=F?.[Z];if(M.push(SY(Q,Y,X)?Q:P9(Y,X)),A=X.blockRange.end,D=X.regionRange?.end??D,Y.regions.length>0)E=X.end,$=!0}return M}function _2(N,F,M,A){let D=F.blocks.length-(N.roots.length-A);if(D<0)throw Error("Editor model splice received an invalid replacement count.");if(M===N.roots.length&&D===1){let Y=F.blocks[M];if(Y)return yY(N,F,Y)}let E=D===A,$=[...N.roots.slice(0,M),...F.blocks.slice(M,M+D).map((Y,X)=>XN(Y,M+X)),...E?N.roots.slice(M+A):F.blocks.slice(M+D).map((Y,X)=>XN(Y,M+D+X))],Z=Z4($,N.roots);return Y4(F,Z,N)}function yY(N,F,M){let A=N.roots.length,D=XN(M,A),E=N.roots.some((Q)=>Q.regions.length>0),$=D.regions.length>0&&E?N.length+1:N.length,Z=P9(D,{...D,blockRange:{end:N.blocks.length+D.blocks.length,start:N.blocks.length},end:$+D.length,regionRange:D.regions.length>0?{end:N.regions.length+D.regions.length,start:N.regions.length}:void 0,start:$}),Y=[...N.blocks,...Z.blocks],X=[...N.regions,...Z.regions];return{blockIndex:WY(N.blockIndex,Z.blocks),blocks:Y,commentContainerIndex:F.comments===N.document.comments?N.commentContainerIndex:O9(F),document:F,engine:"canvas",imageUrls:fY(N.imageUrls,Z.imageUrls),length:Z.end,listItemMarkers:F.blocks===N.document.blocks?N.listItemMarkers:jY(N.listItemMarkers,M),regionIndex:PY(N.regionIndex,Z.regions),regionOrderIndex:OY(N.regionOrderIndex,Z.regions,N.regions.length),regionPathIndex:LY(N.regionPathIndex,Z.regions),regions:X,roots:[...N.roots,Z],tableCellIndex:TY(N.tableCellIndex,Z.regions),tableCellRegionIndex:wY(N.tableCellRegionIndex,Z.regions),text:CY(N.text,Z)}}function gF(N,F){if(F.blocks!==N.document.blocks)throw Error("Editor model document replacement requires preserving root blocks.");return Y4(F,N.roots,N)}function uF(N,F,M){let A=N.blockIndex.get(F);if(!A)return null;return Q9(N.document,F,M,A.rootIndex)}function Y4(N,F,M=null){let A=F.flatMap((Q)=>Q.blocks),D=F.flatMap((Q)=>Q.regions),{regionIndex:E,regionOrderIndex:$,regionPathIndex:Z,tableCellIndex:Y,tableCellRegionIndex:X}=BY(D);return{blockIndex:HY(A),blocks:A,commentContainerIndex:N.comments===M?.document.comments?M.commentContainerIndex:O9(N),document:N,engine:"canvas",imageUrls:bY(F,M?.imageUrls),length:F.at(-1)?.end??0,listItemMarkers:N.blocks===M?.document.blocks?M.listItemMarkers:hY(N.blocks),regionIndex:E,regionOrderIndex:$,regionPathIndex:Z,regions:D,roots:F,tableCellIndex:Y,tableCellRegionIndex:X,text:RY(F)}}function P9(N,F){let M=F.start-N.start;return{...F,blocks:M===0?N.blocks:_Y(N.blocks,M),regions:M===0?N.regions:zY(N.regions,M)}}function SY(N,F,M){return Boolean(N&&F===N&&N.start===M.start&&N.end===M.end&&N.blockRange.start===M.blockRange.start&&N.blockRange.end===M.blockRange.end&&N.regionRange?.start===M.regionRange?.start&&N.regionRange?.end===M.regionRange?.end)}function _Y(N,F){return N.map((M)=>({...M,end:M.end+F,start:M.start+F}))}function zY(N,F){return N.map((M)=>({...M,end:M.end+F,start:M.start+F}))}function HY(N){let F=new Map;for(let M of N)F.set(M.id,M);return F}function BY(N){let F=new Map,M=new Map,A=new Map,D=new Map,E=new Map;for(let[$,Z]of N.entries()){if(F.set(Z.id,Z),M.set(Z.id,$),A.set(Z.path,Z),!Z.tableCellPosition)continue;D.set(Z.id,Z.tableCellPosition),E.set(ZN(Z.blockId,Z.tableCellPosition.rowIndex,Z.tableCellPosition.cellIndex),Z.id)}return{regionIndex:F,regionOrderIndex:M,regionPathIndex:A,tableCellIndex:D,tableCellRegionIndex:E}}function WY(N,F){let M=new Map(N);for(let A of F)M.set(A.id,A);return M}function PY(N,F){let M=new Map(N);for(let A of F)M.set(A.id,A);return M}function OY(N,F,M){let A=new Map(N);for(let[D,E]of F.entries())A.set(E.id,M+D);return A}function LY(N,F){let M=new Map(N);for(let A of F)M.set(A.path,A);return M}function TY(N,F){let M=new Map(N);for(let A of F)if(A.tableCellPosition)M.set(A.id,A.tableCellPosition);return M}function wY(N,F){let M=new Map(N);for(let A of F){if(!A.tableCellPosition)continue;M.set(ZN(A.blockId,A.tableCellPosition.rowIndex,A.tableCellPosition.cellIndex),A.id)}return M}function jY(N,F){let M=new Map(N);return YN(M,[F]),M}function CY(N,F){if(F.regions.length===0)return N;return N.length>0?`${N}
11
- ${F.text}`:F.text}function RY(N){return N.filter((F)=>F.regions.length>0).map((F)=>F.text).join(`
12
- `)}function bY(N,F){let M=new Set;for(let A of N)for(let D of A.imageUrls)M.add(D);return F&&vY(F,M)?F:M}function fY(N,F){if(F.size===0)return N;let M=null;for(let A of F){if(N.has(A))continue;M??=new Set(N),M.add(A)}return M??N}function vY(N,F){if(N.size!==F.size)return!1;for(let M of N)if(!F.has(M))return!1;return!0}function O9(N){let F=new Map;for(let[M,A]of N.comments.entries()){let D=$N(A,N).match?.containerId??null;if(!D)continue;let E=F.get(D)??[];E.push(M),F.set(D,E)}return F}function hY(N){let F=new Map;return YN(F,N),F}function YN(N,F,M=null){for(let A of F){if(A.type==="list"){for(let[D,E]of A.items.entries())YN(N,[E],{index:D,ordered:A.ordered,start:A.start});continue}if(A.type==="listItem"){if(typeof A.checked==="boolean")N.set(A.id,{checked:A.checked,kind:"task"});else if(M?.ordered)N.set(A.id,{kind:"ordered",label:`${(M.start??1)+M.index}.`});else N.set(A.id,{kind:"bullet",label:"•"});YN(N,A.children,M)}if(A.type==="blockquote")YN(N,A.children,M)}}function kY(N){if(N.blocks.length>0)return N;return V2([e("")],N.comments,N.frontMatter)}function $4(N,F=null){let M=[],A=0,D=(E)=>{let $=A,Z=$+E.text.length;M.push({...E,end:Z,start:$}),A=Z};for(let E of N)switch(E.type){case"lineBreak":D({id:E.id,image:null,inlineCode:!1,kind:"lineBreak",link:F,marks:[],mention:null,originalType:null,text:`
13
- `});break;case"image":D({id:E.id,image:{alt:E.alt,title:E.title,url:E.url,width:E.width},inlineCode:!1,kind:"image",link:F,marks:[],mention:null,originalType:null,text:y2});break;case"mention":D({id:E.id,image:null,inlineCode:!1,kind:"mention",link:F,marks:[],mention:{name:E.name,userId:E.userId},originalType:null,text:y2});break;case"code":D({id:E.id,image:null,inlineCode:!0,kind:"code",link:F,marks:[],mention:null,originalType:null,text:E.code});break;case"link":for(let $ of $4(E.children,{title:E.title,url:E.url}))D($);break;case"text":D({id:E.id,image:null,inlineCode:!1,kind:"text",link:F,marks:E.marks,mention:null,originalType:null,text:E.text});break;case"raw":D({id:E.id,image:null,inlineCode:!1,kind:"raw",link:F,marks:[],mention:null,originalType:E.originalType,text:E.source});break}return M}function C0(N){switch(N.type){case"lineBreak":return 1;case"image":case"mention":return y2.length;case"code":return N.code.length;case"link":return Y0(N.children).length;case"text":return N.text.length;case"raw":return N.source.length}}function R0(N,F,M,A){let D=IF(N.children,F,M,A),E=A.reduce((Z,Y)=>Z+C0(Y),0),$=F+E;return QN(N,D,$,$)}function QN(N,F,M,A){switch(N.kind){case"inlineBlock":return{block:w0(N.block,F),blockId:N.block.id,selection:L9(`${N.path}.children`,M,A)};case"tableCell":{let D=H1(F),E=N.block.rows.map(($)=>({...$,cells:$.cells.map((Z)=>Z.id===N.cell.id?D:Z)}));return{block:g0(N.block,E),blockId:N.block.id,selection:L9(N.path,M,A)}}}}function L9(N,F,M){return{endOffset:M,kind:"region-range-path",path:N,startOffset:F}}function IF(N,F,M,A){let D=[],E=0,$=!1;for(let Z of N){let Y=C0(Z),X=E,Q=X+Y;if(E=Q,M<=X||F>=Q){D.push(Z);continue}if(!$)D.push(...mY(Z,Math.max(0,F-X))),D.push(...A),$=!0;D.push(...gY(Z,Math.min(Y,M-X)))}if(!$)D.push(...A);return G0(D)}function mY(N,F){if(F<=0)return[];return X4(N,0,F)}function gY(N,F){let M=C0(N);if(F>=M)return[];return X4(N,F,M)}function X4(N,F,M){if(F>=M)return[];switch(N.type){case"text":{let A=N.text.slice(F,M);return A.length>0?[O0(A,N.marks)]:[]}case"code":return[_1(N.code.slice(F,M))];case"link":{let A=G0(J4(N.children,F,M));return A.length>0?[{...N,children:A}]:[]}default:return[]}}function Q4(N,F,M){let A=0,D="";for(let E of N){let $=C0(E),Z=A,Y=Z+$;if(A=Y,M<=Z||F>=Y)continue;D+=uY(E,Math.max(0,F-Z),Math.min($,M-Z))}return D}function J4(N,F,M){let A=[],D=0;for(let E of N){let $=C0(E),Z=D,Y=Z+$;if(D=Y,M<=Z||F>=Y)continue;A.push(...X4(E,Math.max(0,F-Z),Math.min($,M-Z)))}return A}function uY(N,F,M){if(F>=M)return"";switch(N.type){case"lineBreak":return`
14
- `.slice(F,M);case"image":case"mention":return y2.slice(F,M);case"code":return N.code.slice(F,M);case"link":return Q4(N.children,F,M);case"text":return N.text.slice(F,M);case"raw":return N.source.slice(F,M)}}function q4(N,F,M,A){let D=IY(N.children,F,M,A);if(D===null)return null;let E=G0(T9(N.children,F,M,A,D));return E.length>0?QN(N,E,F,M):null}function U4(N,F,M){let A=0,D=null,E=($)=>{for(let Z of $){let Y=C0(Z),X=A,Q=X+Y;if(A=Q,M<=X||F>=Q)continue;if(Z.type==="text"){let J=Math.max(F,X);if(Math.min(M,Q)>J)D=D===null?new Set(Z.marks):new Set(Z.marks.filter((U)=>D?.has(U)));continue}if(Z.type==="link"){let J=A;A=X,E(Z.children),A=J}}};return E(N.children),D?[...D]:[]}function IY(N,F,M,A){let D=0,E=!1,$=!0,Z=(Y)=>{for(let X of Y){let Q=C0(X),J=D,q=J+Q;if(D=q,M<=J||F>=q)continue;if(X.type==="text"){let U=Math.max(F,J);if(Math.min(M,q)>U)E=!0,$&&=X.marks.includes(A);continue}if(X.type==="link"){let U=D;D=J,Z(X.children),D=U}}};return Z(N),E?$:null}function T9(N,F,M,A,D){let E=[],$=0;for(let Z of N){let Y=$,X=C0(Z),Q=Y+X;if($=Q,M<=Y||F>=Q){E.push(Z);continue}if(Z.type==="text"){E.push(...pY(Z,Math.max(0,F-Y),Math.min(X,M-Y),A,D));continue}if(Z.type==="link"){let J=G0(T9(Z.children,Math.max(0,F-Y),Math.min(X,M-Y),A,D));if(J.length>0)E.push({...Z,children:J});continue}E.push(Z)}return E}function pY(N,F,M,A,D){let E=N.text.slice(0,F),$=N.text.slice(F,M),Z=N.text.slice(M),Y=D?N.marks.filter((J)=>J!==A):xY(N.marks,A),X=[],Q=(J,q)=>{if(J.length>0)X.push(O0(J,q))};return Q(E,N.marks),Q($,Y),Q(Z,N.marks),X}function xY(N,F){return N.includes(F)?N:[...N,F].sort()}function K4(N,F,M){return w9(N,{endOffset:M,regionId:N.selection.focus.regionId,startOffset:F})}function w9(N,F){return k9(N.documentIndex,F.regionId,F.startOffset,F.endOffset,{allowCollapsed:!0})}function pF(N,F){let M=w9(N,F);return M?j9(N,M):null}function j9(N,F){let M=b9(N.documentIndex,F.region.id);return M?{...F,inlineContainer:M}:null}function Y1(N){let F=E0(N);if(F.start.regionId!==F.end.regionId)return null;let M=K4(N,F.start.offset,F.end.offset);return M?j9(N,M):null}function xF(N){return C9(N.documentIndex,N.selection)}function C9(N,F){let M=N.regionIndex.get(F.anchor.regionId);if(!M)return{kind:"unsupported"};if(M.blockType==="code"){let Z=N.blockIndex.get(M.blockId);return Z?{kind:"code",region:M,rootIndex:Z.rootIndex,selection:F,...qN(N,M,F)}:{kind:"unsupported"}}let A=f9(N,M.id,F);if(A)return{kind:"tableCell",...A,...qN(N,M,F)};let D=lF(N,F);if(D)return{kind:"listItem",...D};let E=lY(N,F);if(E)return{kind:"blockquoteTextBlock",...E};let $=z2(N,F);if($)return{kind:"rootTextBlock",...$};return{kind:"unsupported"}}function R9(N,F){let{documentIndex:M,selection:A}=N,D=C9(M,A),E=D.kind==="unsupported"?!1:F==="backward"?D.atStart:D.atEnd;switch(D.kind){case"rootTextBlock":return{...D,kind:"rootTextBlock",direction:F,atBoundary:E,previousRoot:M.document.blocks[D.rootIndex-1]??null,nextRoot:M.document.blocks[D.rootIndex+1]??null};case"listItem":return{...D,kind:"listItem",direction:F,atBoundary:E,previousItem:D.list.items[D.itemIndex-1]??null,nextItem:D.list.items[D.itemIndex+1]??null,previousRoot:M.document.blocks[D.rootIndex-1]??null,nextRoot:M.document.blocks[D.rootIndex+1]??null};case"blockquoteTextBlock":return{...D,kind:"blockquoteTextBlock",direction:F,atBoundary:E,previousSibling:D.quote.children[D.childIndex-1]??null,nextSibling:D.quote.children[D.childIndex+1]??null};default:return{kind:"unsupported",direction:F,atBoundary:!1}}}function b9(N,F){let M=N.regionIndex.get(F);if(!M)return null;let A=Z1(N.document.blocks,M.blockId);if(!A)return null;return G4(A,M.path,M.semanticRegionId)}function G4(N,F,M){if(N.type==="heading"||N.type==="paragraph")return{block:N,children:N.children,kind:"inlineBlock",path:F.replace(/\.children$/,"")};if(N.type!=="table")return null;let A=/^(.*\.rows\.\d+\.cells\.\d+)$/.exec(F);if(!A)return null;for(let D of N.rows)for(let E of D.cells)if(E.id===M)return{block:N,blockPath:A[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:E,children:E.children,kind:"tableCell",path:A[1]};return null}function V4(N,F,M){let A=F?N.blockIndex.get(F)??null:null;while(A){if(A.type===M)return A;let D=A.parentBlockId;A=D?N.blockIndex.get(D)??null:null}return null}function P1(N){let F=N.split("."),M=[];for(let A=0;A<F.length-1;A+=1)if(F[A]==="children"){let D=Number(F[A+1]);if(Number.isInteger(D))M.push(D)}return M}function z2(N,F){let M=N.regionIndex.get(F.anchor.regionId);if(!M)return null;let A=N.blockIndex.get(M.blockId);if(!A)return null;let D=A.rootIndex,E=N.document.blocks[D];if(!E||E.type!=="heading"&&E.type!=="paragraph")return null;return{...qN(N,M,F),block:E,region:M,rootIndex:D}}function lY(N,F){let M=N.regionIndex.get(F.anchor.regionId);if(!M)return null;let A=N.blockIndex.get(M.blockId),D=V4(N,A?.id??null,"blockquote");if(!A||!D||A.parentBlockId!==D.id)return null;let E=D.rootIndex,$=N.document.blocks[E];if(!$||$.type!=="blockquote")return null;let Z=$.children.findIndex((X)=>X.id===A.id),Y=$.children[Z];if(!Y||Y.type!=="heading"&&Y.type!=="paragraph")return null;return{...qN(N,M,F),block:Y,blockChildIndices:P1(A.path),childIndex:Z,region:M,quote:$,rootIndex:E}}function JN(N,F){return Z1(N.document.blocks,F)}function y4(N){return lF(N.documentIndex,N.selection)}function lF(N,F){let M=N.regionIndex.get(F.anchor.regionId);if(!M)return null;let A=N.blockIndex.get(M.blockId),D=V4(N,A?.id??null,"listItem"),E=V4(N,A?.id??null,"list");if(!A||!D||!E)return null;let $=JN(N,E.id);if(!$||$.type!=="list")return null;let Z=$.items.findIndex((V)=>V.id===D.id),Y=$.items[Z];if(!Y)return null;let X=E.parentBlockId?N.blockIndex.get(E.parentBlockId)??null:null,Q=X?.parentBlockId?N.blockIndex.get(X.parentBlockId)??null:null,J=X?.type==="listItem"?JN(N,X.id):null,q=Q?.type==="list"?JN(N,Q.id):null,U=q?.type==="list"&&J?q.items.findIndex((V)=>V.id===J.id):-1;return{...qN(N,M,F),region:M,item:Y,itemChildIndices:P1(D.path),itemIndex:Z,list:$,listChildIndices:P1(E.path),parentItem:J?.type==="listItem"?J:null,parentItemChildIndices:X?.type==="listItem"?P1(X.path):null,parentItemIndex:U>=0?U:null,parentList:q?.type==="list"?q:null,parentListChildIndices:Q?.type==="list"?P1(Q.path):null,rootIndex:E.rootIndex}}function H2(N){return f9(N.documentIndex,N.selection.focus.regionId,N.selection)}function f9(N,F,M){let A=N.regionIndex.get(F);if(!A)return null;let D=N.tableCellIndex.get(A.id),E=N.blockIndex.get(A.blockId),$=E?.type==="table"?N.document.blocks[E.rootIndex]:null,Z=b9(N,A.id);if(!D||!E||!$||$.type!=="table"||!Z||Z.kind!=="tableCell")return null;return{cellIndex:D.cellIndex,documentIndex:N,inlineContainer:Z,region:A,rootIndex:E.rootIndex,rowIndex:D.rowIndex,selection:M,table:$}}function qN(N,F,M){let A=E0(N,M),D=A.start.regionId===F.id?A.start.offset:M.anchor.offset;return{atEnd:D===F.text.length,atStart:D===0,empty:F.text.length===0,offset:D}}function UN(N,F,M){return I1({checked:F,children:[e(N)],spread:M})}function v9(N,F){let M=N.children[0];if(!M||M.type!=="paragraph")return null;return N1(N,[e(F),...N.children.slice(1)])}function h9(N,F){return F.reduce((M,A)=>`${M}.children.${A}`,`root.${N}`)}function H0(N,F,M=0){return{childIndices:F,kind:"descendant-primary-region",offset:M,rootIndex:N}}function A0(N,F=0){return{kind:"root-primary-region",offset:F,rootIndex:N}}function S4(N,F=0){return{kind:"region",offset:F,regionId:N}}function a1(N,F,M,A=0){return{cellIndex:M,kind:"table-cell",offset:A,rootIndex:N,rowIndex:F}}function U0(N,F){return N.regionIndex.get(F)??null}function k9(N,F,M,A,D={}){let E=U0(N,F);if(!E||M>A)return null;let $=m9(M,E.text.length),Z=m9(A,E.text.length);if($===Z&&D.allowCollapsed!==!0)return null;return{endOffset:Z,region:E,selection:{anchor:{regionId:F,offset:$},focus:{regionId:F,offset:Z}},startOffset:$}}function G2(N,F){return N.regionPathIndex.get(F)??null}function P2(N,F,M,A){let D=N.tableCellRegionIndex.get(ZN(F,M,A));return D?N.regionIndex.get(D)??null:null}function m9(N,F){return Math.max(0,Math.min(N,F))}function r1(N,F){let M=N.regionOrderIndex.get(F);if(M===void 0||M===0)return null;return N.regions[M-1]??null}function VN(N,F){let M=N.regionOrderIndex.get(F);if(M===void 0)return null;return N.regions[M+1]??null}function M1(N){return N.regionIds.length===0&&!O1(N)}function O1(N){return N.type==="blockquote"||N.type==="list"||N.type==="listItem"}function _4(N,F){return u9(N.blocks,F,-1)}function KN(N,F){return u9(N.blocks,F,1)}function u9(N,F,M){let A=N.findIndex((D)=>D.id===F);if(A===-1)return null;for(let D=A+M;D>=0&&D<N.length;D+=M){let E=N[D];if(O1(E))continue;return E}return null}function z4(N,F){return N.roots[F]?.regions[0]??null}function aF(N){return N.anchor.regionId===N.focus.regionId&&N.anchor.offset===N.focus.offset}function E0(N,F){let M="documentIndex"in N?N.documentIndex:N,A="documentIndex"in N?N.selection:F,D=aF(A),E=g9(M,A.anchor),$=g9(M,A.focus);if(E<=$)return{collapsed:D,end:A.focus,start:A.anchor};return{collapsed:D,end:A.anchor,start:A.focus}}function GN(N,F){if(!F)return null;if(F.kind==="root-primary-region"){let A=N.document.blocks[F.rootIndex],D=A?dF(N,A):null;return D?B2(D.id,W2(D.text,F.offset)):null}if(F.kind==="descendant-primary-region"){let A=N.document.blocks[F.rootIndex],D=A?dY(A,F.childIndices):null,E=D?dF(N,D):null;return E?B2(E.id,W2(E.text,F.offset)):null}if(F.kind==="region"){let A=U0(N,F.regionId);return A?B2(A.id,W2(A.text,F.offset)):null}if(F.kind==="block-primary-region"){let A=Z1(N.document,F.blockId),D=A?dF(N,A):null;return D?B2(D.id,W2(D.text,F.offset)):null}if(F.kind==="table-cell"){let A=N.document.blocks[F.rootIndex];if(!A||A.type!=="table")return null;let D=P2(N,A.id,F.rowIndex,F.cellIndex);return D?B2(D.id,W2(D.text,F.offset)):null}let M=G2(N,F.path);if(!M)return null;if(F.kind==="region-path")return B2(M.id,W2(M.text,F.offset));return{anchor:{regionId:M.id,offset:Math.max(0,Math.min(F.startOffset,M.text.length))},focus:{regionId:M.id,offset:Math.max(0,Math.min(F.endOffset,M.text.length))}}}function B2(N,F){let M={offset:F,regionId:N};return{anchor:M,focus:M}}function g9(N,F){let M=N.regionOrderIndex.get(F.regionId);if(M===void 0)throw Error(`Unknown canvas region: ${F.regionId}`);return M*W9+F.offset}function W2(N,F){return F==="end"?N.length:Math.max(0,Math.min(F,N.length))}function dY(N,F){let M=N;for(let A of F){if(!M)return null;let D=_0(M);if(!D)return null;M=D[A]??null}return M}function dF(N,F){let M=N.blockIndex.get(F.id);if(!M)return null;let A=M.regionIds[0];if(A)return N.regionIndex.get(A)??null;let D=_0(F);if(!D)return null;for(let E of D){let $=dF(N,E);if($)return $}return null}function rF(N){if(!aF(N.selection))return null;let F=N.documentIndex.regionIndex.get(N.selection.focus.regionId);return F?{offset:N.selection.focus.offset,regionId:F.id,text:F.text}:null}function cF(N){let F=N.documentIndex.regionIndex.get(N.selection.anchor.regionId)??null,M=F?N.documentIndex.blockIndex.get(F.blockId)??null:null,A=I9(N);return{block:M?{blockId:M.id,depth:M.depth,nodeType:M.type,text:F?.text??""}:null,span:A?.link?{kind:"link",url:A.link.url}:A&&A.marks.length>0?{kind:"marks",marks:A.marks}:{kind:"none"}}}function sF(N){let F=I9(N);return F?.kind==="image"?F:null}function yN(N){let F=E0(N.documentIndex,N.selection);if(F.start.regionId!==F.end.regionId||F.start.offset===F.end.offset)return null;return{endOffset:F.end.offset,regionId:F.start.regionId,startOffset:F.start.offset}}function iF(N){let F=yN(N);if(!F)return[];let M=N.documentIndex.regionIndex.get(F.regionId);if(!M)return[];let A=Z1(N.documentIndex.document.blocks,M.blockId);if(!A)return[];let D=G4(A,M.path,M.semanticRegionId);return D?U4(D,F.startOffset,F.endOffset):[]}function I9(N){let F=N.documentIndex.regionIndex.get(N.selection.anchor.regionId)??null;if(!F)return null;let M=N.selection.anchor.offset;return F.inlines.find((A)=>M>A.start&&M<A.end)??F.inlines.find((A)=>A.end===M)??F.inlines.find((A)=>A.start===M)??null}var nF="rgba(0, 0, 0, 0)";function O2(N,F,M){let A=p9(N),D=p9(F);return`rgba(${B4(oF(A[0],D[0],M))}, ${B4(oF(A[1],D[1],M))}, ${B4(oF(A[2],D[2],M))}, ${oF(A[3],D[3],M)})`}var H4=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function p9(N){let F=H4.get(N);if(F)return F;let M=aY(N)??rY(N)??cY(N)??H4.get("rgba(0, 0, 0, 0)");return H4.set(N,M),M}function aY(N){let F=N.trim();if(!F.startsWith("#"))return null;let M=F.slice(1);if(M.length===3)return[Number.parseInt(`${M[0]}${M[0]}`,16),Number.parseInt(`${M[1]}${M[1]}`,16),Number.parseInt(`${M[2]}${M[2]}`,16),1];if(M.length===6)return[Number.parseInt(M.slice(0,2),16),Number.parseInt(M.slice(2,4),16),Number.parseInt(M.slice(4,6),16),1];return null}function rY(N){let F=/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec(N.trim());if(!F)return null;return[Number(F[1]),Number(F[2]),Number(F[3]),1]}function cY(N){let F=/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec(N.trim());if(!F)return null;return[Number(F[1]),Number(F[2]),Number(F[3]),Number(F[4])]}function oF(N,F,M){return N+(F-N)*M}function B4(N){return Math.round(N)}var sY=300,iY=180,oY=1000,nY=500,tY=140,eY=0.1,NX=0.9,FX=2,MX=2;function SN(N){switch(N.kind){case"active-block-flash":return sY;case"text-fade":return iY;case"text-highlight":return oY;case"block-pulse":return nY;case"text-pulse":return tY}}function W4(N,F){let M=F??DX();return N.animations.some((A)=>M-A.startedAt<SN(A))}function x9(N,F){return P4(N,F,"text-highlight",(M)=>M.regionPath)}function l9(N,F){return e9(N,F,"active-block-flash",(M)=>M.blockPath)}function d9(N,F){return P4(N,F,"text-fade",(M)=>M.regionPath)}function a9(N,F){return P4(N,F,"text-pulse",(M)=>M.regionPath)}function r9(N,F){return e9(N,F,"block-pulse",(M)=>M.blockPath)}function c9(N,F,M){let A=new Set([N,F]);for(let D of M){if(D.endOffset<=N||D.startOffset>=F)continue;A.add(Math.max(N,D.startOffset)),A.add(Math.min(F,D.endOffset))}return[...A].sort((D,E)=>D-E)}function s9(N,F,M){return N.find((A)=>A.startOffset<M&&A.endOffset>F)??null}function i9(N,F,M){if(!F)return N;return O2(M.insertHighlightText,N,F.progress)}function o9(N,F){return O2(N,nF,F.progress)}function tF(N,F){return O2(N,nF,F.progress)}function n9(N,F){return O2(F.insertHighlightText,nF,N.progress)}function t9(N){let F=Math.min(1,N.progress*FX);return eY+NX*AX(F)}function _N(N,F,M){let A=Math.max(0,F.progress*MX-1);return O2(M.insertHighlightText,N,A)}function P4(N,F,M,A){let D=new Map;for(let E of N.animations){if(E.kind!==M)continue;let $=SN(E),Z=F-E.startedAt;if(Z>=$)continue;let Y={...E,progress:Math.max(0,Math.min(1,Z/$))},X=A(E),Q=D.get(X);if(Q)Q.push(Y);else D.set(X,[Y])}return D}function e9(N,F,M,A){let D=new Map;for(let E of N.animations){if(E.kind!==M)continue;let $=SN(E),Z=F-E.startedAt;if(Z>=$)continue;D.set(A(E),{...E,progress:Math.max(0,Math.min(1,Z/$))})}return D}function AX(N){return 1-(1-N)*(1-N)*(1-N)}function DX(){return typeof performance<"u"?performance.now():Date.now()}function N7(N,F,M=N6()){if(!F)return N;switch(F.kind){case"text-highlight":return F.endOffset>F.startOffset?eF(N,{...F,startedAt:M}):N;case"text-fade":return F.text.length>0?eF(N,{...F,startedAt:M}):N;case"text-pulse":case"block-pulse":return eF(N,{...F,startedAt:M})}}function F7(N,F,M=N6()){return eF(N,{blockPath:F,kind:"active-block-flash",startedAt:M})}function O4(N,F){return N.filter((M)=>M.startedAt+SN(M)>F)}function N6(){return typeof performance<"u"?performance.now():Date.now()}function M7(N){let F=EX(N);return(F?N.documentIndex.blockIndex.get(F.blockId)??null:null)?.path??""}function EX(N){return N.documentIndex.regionIndex.get(N.selection.focus.regionId)??null}function eF(N,F){let M=O4(N.animations,F.startedAt);return{...N,animations:[...M,F]}}function L2(N,F,M,A){return T4(T2(N.inlines,F,M,A))}function T2(N,F,M,A){let E=$X(N,F,M,{didInsert:!1,generatedInlineCount:0,replacementText:A});return JX(qX(E))}function T4(N){let F=[];for(let M=0;M<N.length;M+=1){let A=N[M];if(A.link){let E=[],$=A.link;while(M<N.length&&w4(N[M].link,$)){let Z=D7(N[M]);if(Z)E.push(Z);M+=1}if(M-=1,E.length>0)F.push(u1({children:G0(E),title:$.title,url:$.url}));continue}let D=D7(A);if(D)F.push(D)}return G0(F)}function $X(N,F,M,A){let D=[];for(let[E,$]of N.entries()){if(!A.didInsert&&F===M&&F===$.start)L4(D,A,A7(N[E-1]??null,$));if(M<=$.start||F>=$.end){D.push(F6($));continue}let Z=Math.max(0,F-$.start),Y=Math.min($.text.length,M-$.start),X=!A.didInsert&&A.replacementText.length>0?A.replacementText:"",Q=ZX($,Z,Y,X,A);if(Z!==Y||X.length>0)A.didInsert=!0;D.push(...Q)}if(!A.didInsert)L4(D,A,A7(N.at(-1)??null,null));return D}function ZX(N,F,M,A,D){switch(N.kind){case"text":case"code":case"raw":return YX(N,F,M,A);case"lineBreak":return XX(N,F,M,A,D);case"image":case"mention":return QX(N,F,M,A)}}function YX(N,F,M,A){let D=N.text.slice(0,F)+A+N.text.slice(M);return D.length>0?[{...F6(N),text:D}]:[]}function XX(N,F,M,A,D){if(F===M)return[F6(N)];let E=[];if(A.length>0)L4(E,D,N.link);return E}function QX(N,F,M,A){if(F===0&&M===N.text.length)return A.length>0?[E7(A,N.link,0)]:[];return[F6(N)]}function L4(N,F,M){if(F.replacementText.length===0){F.didInsert=!0;return}N.push(E7(F.replacementText,M,F.generatedInlineCount)),F.generatedInlineCount+=1,F.didInsert=!0}function E7(N,F,M){return{id:`generated:${M}`,image:null,inlineCode:!1,kind:"text",link:F,marks:[],mention:null,originalType:null,text:N}}function A7(N,F){return N?.link&&F?.link&&w4(N.link,F.link)?N.link:null}function F6(N){return{id:N.id,image:N.image,inlineCode:N.inlineCode,kind:N.kind,link:N.link,marks:N.marks,mention:N.mention,originalType:N.originalType,text:N.text}}function JX(N){let F=[],M=0;for(let A of N){let D=M,E=D+A.text.length;F.push({...A,end:E,start:D}),M=E}return F}function qX(N){let F=[];for(let M of N){let A=F.at(-1);if(A&&UX(A,M)){F[F.length-1]={...A,text:A.text+M.text};continue}F.push(M)}return F}function UX(N,F){return N.kind===F.kind&&N.inlineCode===F.inlineCode&&w4(N.link,F.link)&&GX(N.image,F.image)&&yX(N.mention,F.mention)&&N.originalType===F.originalType&&N.marks.join(",")===F.marks.join(",")}function D7(N){switch(N.kind){case"lineBreak":return e0();case"image":return N.image?VX(N.image):null;case"mention":return N.mention?KX(N.mention):null;case"code":return _1(N.text);case"text":return N.text.length>0?O0(N.text,N.marks):null;case"raw":return TF({originalType:N.originalType??"raw",source:N.text})}}function VX(N){return z1({alt:N.alt,title:N.title,url:N.url,width:N.width})}function KX(N){return Q2({name:N.name,userId:N.userId})}function w4(N,F){return N?.url===F?.url&&N?.title===F?.title}function GX(N,F){return N?.url===F?.url&&N?.title===F?.title&&N?.alt===F?.alt&&N?.width===F?.width}function yX(N,F){return N?.userId===F?.userId&&N?.name===F?.name}function zN(N,F,M){if(N.type==="table")return null;if(N.id===F.blockId)return SX(N,F,M);return $7(N,(A)=>zX(A,F,M))}function HN(N,F,M){if(N.type==="table")return null;if(N.id===F.blockId)return _X(N,F,M);return $7(N,(A)=>HX(A,F,M))}function c1(N,F){if(N.id===F.blockId)return!0;let M=_0(N);return M!==null&&M.some((A)=>c1(A,F))}function SX(N,F,M){if(M===0)return null;switch(N.type){case"heading":case"paragraph":return w0(N,L2(F,M,F.text.length,""));case"code":return MN(N,F.text.slice(0,M));case"raw":return AN(N,F.text.slice(0,M));default:return null}}function _X(N,F,M){if(M===F.text.length)return null;switch(N.type){case"heading":case"paragraph":return w0(N,L2(F,0,M,""));case"code":return MN(N,F.text.slice(M));case"raw":return AN(N,F.text.slice(M));default:return null}}function $7(N,F){let M=_0(N);return M?B1(N,F(M)):null}function zX(N,F,M){let A=N.findIndex(($)=>c1($,F));if(A===-1)return[];let D=N.slice(0,A),E=zN(N[A],F,M);return E?[...D,E]:D}function HX(N,F,M){let A=N.findIndex(($)=>c1($,F));if(A===-1)return[];let D=N.slice(A+1),E=HN(N[A],F,M);return E?[E,...D]:D}function Q7(N,F,M){let A=[],D=0,E={childIndices:[],offset:0},$="",Z=N!==null;if(N)A.push(N),E=Z7(N);let Y=0;if(N&&F.length>0){let X=F[0];if(M6(N)&&X.type==="paragraph"){let Q=j4(N,N.children,X.children);A[A.length-1]=Q,E={childIndices:[],offset:Q.plainText.length},Y=1,$=X.plainText}else if(Y7(N,X)){let Q=X7(N,X);A[A.length-1]=Q,E=J7(Q),Y=1}}for(let X=Y;X<F.length;X+=1){let Q=F[X];A.push(Q),D=A.length-1,E=Z7(Q)}if(M){let X=A.length-1,Q=A[X]??null,J=Y>=F.length&&N!==null,q=null;if(Q){if(!J&&Q.type==="paragraph"&&M6(M)){if(q=j4(M,Q.children,M.children),N===null&&F.length===1)Z=!0,$=Q.plainText}else if(J&&M6(Q)&&M6(M))q=j4(Q,Q.children,M.children);else if(Y7(Q,M))q=X7(Q,M),E={childIndices:[_0(Q).length-1],offset:"end"}}else if(N===null&&F.length===0)Z=!0;if(q)A[X]=q;else A.push(M)}return{blocks:A,caretLocalIndex:D,caretChildIndices:E.childIndices,caretOffset:E.offset,startRegionInsertedText:$,startRegionPreservedAtRoot0:Z}}function Z7(N){return _0(N)?J7(N):{childIndices:[],offset:N.plainText.length}}function J7(N){return{childIndices:[_0(N).length-1],offset:"end"}}function j4(N,F,M){return w0(N,G0([...F,...M]))}function M6(N){return N!==null&&(N.type==="heading"||N.type==="paragraph")}function Y7(N,F){return N.type===F.type&&_0(N)!==null}function X7(N,F){let M=_0(N),A=_0(F);return B1(N,[...M,...A])}function U7(N,F,M){let A=E0(N,F);if(A.start.regionId===A.end.regionId)return BX(N,A,M);let D=M.length>0?[e(M)]:[];return C4(N,F,D)}function C4(N,F,M){let A=E0(N,F),D=U0(N,A.start.regionId),E=U0(N,A.end.regionId);if(!D||!E)throw Error("Unknown selection endpoints.");let $=N.document.blocks[D.rootIndex],Z=N.document.blocks[E.rootIndex];if(!$||!Z)throw Error("Unknown root blocks for selection.");let Y=zN($,D,A.start.offset),X=HN(Z,E,A.end.offset),Q=Q7(Y,M,X),J=Q.blocks.length>0?Q.blocks:[e("")],q=D.rootIndex,U=E.rootIndex-D.rootIndex+1,V=d1(N.document,q,U,J),y=_2(N,V,q,U),G=D===E?A.end.offset:D.text.length;return{documentIndex:Q.startRegionPreservedAtRoot0?V7(N,y,D,A.start.offset,G,Q.startRegionInsertedText):y,selection:H0(q+Q.caretLocalIndex,Q.caretChildIndices,Q.caretOffset)}}function BX(N,F,M){let A=U0(N,F.start.regionId);if(!A)throw Error(`Unknown region: ${F.start.regionId}`);let D=uF(N,A.blockId,(Y)=>WX(Y,A,F.start.offset,F.end.offset,M));if(!D)throw Error(`Failed to replace block for region: ${A.id}`);let E=_2(N,D,A.rootIndex,1),$=V7(N,E,A,F.start.offset,F.end.offset,M),Z=G2($,A.path);if(!Z)throw Error(`Failed to remap region after replacement: ${A.path}`);return{documentIndex:$,selection:S4(Z.id,F.start.offset+M.length)}}function WX(N,F,M,A,D){switch(N.type){case"heading":case"paragraph":return w0(N,L2(F,M,A,D));case"code":return MN(N,q7(F,M,A,D));case"table":return PX(N,F,M,A,D);case"raw":return AN(N,q7(F,M,A,D));default:throw Error(`Region text replacement is not supported for block type: ${N.type}`)}}function PX(N,F,M,A,D){let E=F.tableCellPosition?.rowIndex,$=F.tableCellPosition?.cellIndex;if(E===void 0||$===void 0)throw Error(`Unable to resolve table cell position for region: ${F.id}`);let Z=L2(F,M,A,D),Y=N.rows.map((X,Q)=>{if(Q!==E)return X;let J=X.cells.map((q,U)=>U===$?H1(Z):q);return{...X,cells:J}});return g0(N,Y)}function q7(N,F,M,A){return T2(N.inlines,F,M,A).map((D)=>D.text).join("")}function V7(N,F,M,A,D,E){if(N.document.comments.length===0)return F;let $=E4(N,F,M,A,D,E);return $===F.document.comments?F:gF(F,{...F.document,comments:$})}function w2(N){let F=S2(N),M=S7(F);return{animations:[],documentIndex:F,future:[],history:[],selection:{anchor:M,focus:M}}}function A1(N){let F=j0(N.documentIndex);return V2(q9(N.documentIndex.document.blocks),F.threads,N.documentIndex.document.frontMatter)}function WN(N,F){if(!F)return null;let M=OX(N,F);return M?N7(M,F.animation):null}function OX(N,F){switch(F.kind){case"keep-state":return N;case"set-selection":return y0(N,F.selection);case"replace-block":{let M=uF(N.documentIndex,F.blockId,()=>F.block);return M?BN(N,S2(M),F.selection??null):null}case"splice-blocks":{let M=d1(N.documentIndex.document,F.rootIndex,F.count??1,F.blocks);return BN(N,S2(M),F.selection??null)}case"splice-text":{let M=U7(N.documentIndex,F.range??N.selection,F.text);return BN(N,M.documentIndex,F.selection??M.selection)}case"splice-fragment":{let M=C4(N.documentIndex,N.selection,F.blocks);return BN(N,M.documentIndex,M.selection)}case"splice-comments":{let M=X9(N.documentIndex.document,F.index,F.count,F.threads);return BN(N,gF(N.documentIndex,M),null)}}}function BN(N,F,M){let A=LX(N,F),D=GN(A.documentIndex,M)??N.selection,E=_7(N,A,D);return y0(A,D,E)}function y0(N,F,M){let A="regionId"in F?{anchor:A6(N.documentIndex,F),focus:A6(N.documentIndex,F)}:{anchor:A6(N.documentIndex,F.anchor),focus:A6(N.documentIndex,F.focus)},D={...N,selection:A};return M??_7(N,D)?F7(D,M7(D)):D}function b0(N,F,M,A){let D={regionId:F,offset:M};return y0(N,A?{anchor:N.selection.anchor,focus:D}:D)}function LX(N,F){let M=S7(F);return{animations:O4(N.animations,N6()),documentIndex:F,future:[],history:[...N.history,{document:N.documentIndex.document,selection:N.selection}],selection:{anchor:M,focus:M}}}function R4(N){let F=N.history.at(-1);if(!F)return N;return y7(F,{future:[G7(N),...N.future],history:N.history.slice(0,-1)})}function b4(N){let F=N.future[0];if(!F)return N;return y7(F,{future:N.future.slice(1),history:[...N.history,G7(N)]})}function G7(N){return{document:N.documentIndex.document,selection:N.selection}}function y7(N,F){return{animations:[],documentIndex:S2(N.document),future:F.future,history:F.history,selection:N.selection}}function S7(N){return N.regions[0]?{regionId:N.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function A6(N,F){let M=U0(N,F.regionId);if(!M)return F;return{regionId:M.id,offset:Math.max(0,Math.min(F.offset,M.text.length))}}function _7(N,F,M){let A=K7(N.documentIndex,N.selection),D=K7(F.documentIndex,M??F.selection);return D!==null&&D!==A}function K7(N,F){let M=N.regionIndex.get(F.focus.regionId),A=M?N.blockIndex.get(M.blockId)??null:null;if(!M||!A?.path)return null;return A.type==="table"?`cell:${M.path}`:`block:${A.path}`}function f4(N,F,M){if(F===M)return null;let A=TX(N.children,F,M);return A!==N.children&&A.length>0?QN(N,A,F,M):null}function TX(N,F,M){let A=z7(N,F,M);if(A){let E=A.code.length>0?[O0(A.code,[])]:[];return IF(N,F,M,E)}let D=Q4(N,F,M);if(D.length===0)return N;return IF(N,F,M,[_1(D)])}function z7(N,F,M){let A=0;for(let D of N){let E=C0(D),$=A,Z=$+E;if(A=Z,F===$&&M===Z&&D.type==="code")return D;if(D.type==="link"){let Y=z7(D.children,Math.max(0,F-$),Math.min(E,M-$));if(Y)return Y}}return null}function v4(N,F,M){let{image:A}=F,D=R0(N,F.start,F.end,[z1({alt:A.alt,title:A.title,url:A.url,width:M})]);return{kind:"replace-block",block:D.block,blockId:D.blockId}}function h4(N,F,M,A){let D=J4(N.children,F,M);if(D.length===0)return null;return R0(N,F,M,[u1({children:D,title:null,url:A})])}function k4(N,F,M,A){let D=H7(N.children,F,M);if(!D)return null;return R0(N,F,M,[u1({children:D.children,title:D.title,url:A})])}function m4(N,F,M){let A=H7(N.children,F,M);if(!A)return null;return R0(N,F,M,A.children)}function H7(N,F,M){let A=0;for(let D of N){let E=C0(D);if(D.type==="link"&&A===F&&A+E===M)return D;A+=E}return null}function g4(N,F,M,A=""){return{kind:"replace-block",...R0(N.inlineContainer,N.startOffset,N.endOffset,[Q2({name:M,userId:F}),...A.length>0?[O0(A)]:[]])}}function j2(N,F){let M=F(N.inlineContainer,N.startOffset,N.endOffset);return M?{kind:"replace-block",block:M.block,blockId:M.blockId,selection:M.selection}:null}function u4(N,F){return{kind:"replace-block",...R0(N.inlineContainer,N.startOffset,N.endOffset,[F])}}function B7(N,F){return{kind:"replace-block",...R0(N.inlineContainer,N.startOffset,N.endOffset,F)}}var D6;function X1(N){if(N.length===0)return[];let F=CX();if(!F)return Array.from(N);return Array.from(F.segment(N),(M)=>M.segment)}function wX(N,F){let M=X1(N.slice(0,F));if(M.length===0)return 0;return F-M.at(-1).length}function jX(N,F){let M=X1(N.slice(F))[0];return M?F+M.length:N.length}function PN(N,F,M){return M<0?wX(N,F):jX(N,F)}function CX(){if(D6!==void 0)return D6;let N=Intl.Segmenter;return D6=typeof N==="function"?new N(void 0,{granularity:"grapheme"}):null,D6}function C2(N){return RX.test(N)}var RX=/[\uFE0F\u{1F1E6}-\u{1F1FF}\p{Extended_Pictographic}]/u;function W7(N,F,M){if(M===".")return bX(N,F);return s1(N,F,M)}function s1(N,F,M){if(M.length===0||C2(M))return;let A=O7(N,F);if(!A)return;return I4(A.region,A.normalized.start.offset,M)}function I4(N,F,M){if(M.length===0||C2(M))return;return{endOffset:F+M.length,kind:"text-highlight",regionPath:N.path,startOffset:F}}function P7(N,F,M){let A=N.text.slice(F,M);if(A.length===0||C2(A))return;return N.inlines.some((E)=>E.start<=F&&E.end>=M&&E.kind==="text"&&E.link===null&&E.marks.length===0)?{kind:"text-fade",regionPath:N.path,startOffset:F,text:A}:void 0}function bX(N,F){let M=O7(N,F);if(!M)return;return{kind:"text-pulse",offset:M.normalized.start.offset,regionPath:M.region.path}}function O7(N,F){let M=E0(N,F);if(M.start.regionId!==M.end.regionId)return null;let A=U0(N,M.start.regionId);return A?{normalized:M,region:A}:null}function L7(N,F){if(N.selection.anchor.regionId!==N.selection.focus.regionId||N.selection.anchor.offset!==N.selection.focus.offset)return null;let M=U0(N.documentIndex,N.selection.focus.regionId);if(!M)return null;if(F==="forward"&&N.selection.focus.offset>=M.text.length)return null;let A=F==="backward"?PN(M.text,N.selection.focus.offset,-1):N.selection.focus.offset,D=F==="backward"?N.selection.focus.offset:PN(M.text,N.selection.focus.offset,1);if(A===D)return null;return{animation:P7(M,A,D),kind:"splice-text",range:{anchor:{regionId:M.id,offset:A},focus:{regionId:M.id,offset:D}},text:""}}var fX={"(":")","[":"]","{":"}"};function T7(N,F,M){if(M.length!==1)return null;let A=fX[M];if(!A||!aF(F))return null;let D=N.regionIndex.get(F.focus.regionId);if(!D)return null;let E=`${M}${A}`;return{animation:s1(N,F,E),kind:"splice-text",selection:{kind:"region-path",offset:F.focus.offset+M.length,path:D.path},text:E}}function w7(N,F,M){if(F.anchor.regionId!==F.focus.regionId)return null;let A=N.regionIndex.get(F.anchor.regionId);if(!A)return null;let D=hX(N,F,A);if(!D)return null;let{start:E,end:$}=vX(N,F);return kX(A,M,E,$,D)}function vX(N,F){if(F.anchor.offset===F.focus.offset)return{start:F.anchor.offset,end:F.anchor.offset};let M=E0(N,F);return{start:M.start.offset,end:M.end.offset}}function hX(N,F,M){switch(M.blockType){case"heading":{let A=z2(N,F);return A?.block.type==="heading"?{kind:"heading",rootIndex:A.rootIndex}:null}case"paragraph":{let A=lF(N,F);if(A)return{kind:"list-item",item:A};let D=z2(N,F);return D?.block.type==="paragraph"?{kind:"root-paragraph",rootIndex:D.rootIndex}:null}default:return null}}function kX(N,F,M,A,D){if(D.kind==="root-paragraph"&&!mX(N,F,A))return null;let E=N.text.slice(0,M)+F+N.text.slice(A);switch(D.kind){case"root-paragraph":return p4(gX,E,D);case"heading":return p4(uX,E,D);case"list-item":return p4(IX,E,D.item)}}function mX(N,F,M){let A=M<N.text.length?N.text:F;return A.length>0&&/\s/.test(A[A.length-1])}function p4(N,F,M){for(let{pattern:A,apply:D}of N){let E=A.exec(F);if(E)return D(E,M)}return null}var gX=[{pattern:R2(/(?:[-+*]\s+)?\[[ xX]?\]/,{allowIndent:!0}),apply:(N,{rootIndex:F})=>x4(F,{checked:N[1].toLowerCase().includes("x"),ordered:!1,start:null})},{pattern:R2(/[-+*]/,{allowIndent:!0}),apply:(N,{rootIndex:F})=>x4(F,{checked:null,ordered:!1,start:null})},{pattern:R2(/\d+\./,{allowIndent:!0}),apply:(N,{rootIndex:F})=>x4(F,{checked:null,ordered:!0,start:Number(N[1].slice(0,-1))})},{pattern:R2(/#{1,6}/,{allowIndent:!1}),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[X2({depth:N[1].length,text:""})],rootIndex:F,selection:A0(F)})},{pattern:R2(/>/,{allowIndent:!1}),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[x0([e("")])],rootIndex:F,selection:H0(F,[0])})},{pattern:R2(/---/,{allowIndent:!1}),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[wF(),e("")],rootIndex:F,selection:A0(F+1)})}],uX=[{pattern:E6(/#{1,6}/),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[X2({depth:N[1].length,text:N[2]})],rootIndex:F,selection:A0(F)})}],IX=[{pattern:E6(/\d+\./),apply:(N,F)=>l4(N,F,{ordered:!0,start:1,checked:F.item.checked})},{pattern:E6(/\[[ xX]?\]/),apply:(N,F)=>l4(N,F,{ordered:!1,start:null,checked:N[1].toLowerCase().includes("x")})},{pattern:E6(/[-+*]/),apply:(N,F)=>l4(N,F,{ordered:!1,start:null,checked:null})}];function R2(N,F){let M=F.allowIndent?"\\s*":"";return new RegExp(`^${M}(${N.source})\\s$`)}function E6(N){return new RegExp(`^\\s*(${N.source})\\s(.+)$`)}function x4(N,F){return{kind:"splice-blocks",blocks:[p1({items:[I1({checked:F.checked,children:[e("")],spread:!1})],ordered:F.ordered,spread:!1,start:F.start})],rootIndex:N,selection:H0(N,[0,0])}}function l4(N,F,M){let A=v9(F.item,N[2]);if(!A)return null;return{kind:"replace-block",block:q0(F.list,F.list.items.map((D,E)=>E===F.itemIndex?{...A,checked:M.checked}:D),{ordered:M.ordered,start:M.start}),blockId:F.list.id,selection:H0(F.rootIndex,[...F.listChildIndices,F.itemIndex,0])}}function j7(N,F,M){return T7(N,F,M)??w7(N,F,M)??{animation:W7(N,F,M),kind:"splice-text",text:M}}function C7(N,F){let M=N.region.text.length,A=N.region.text.slice(0,F),D=N.region.text.slice(F),E=F===0&&M>0?N.rootIndex:N.rootIndex+1;return{kind:"splice-blocks",blocks:f7(N.block,A,D,F,M),rootIndex:N.rootIndex,selection:A0(E)}}function R7(N,F){let M=N.region.text,A=M.slice(0,F),D=M.slice(F),E=f7(N.block,A,D,F,M.length),$=F===0?N.blockChildIndices:[...N.blockChildIndices.slice(0,-1),N.blockChildIndices.at(-1)+1];return{kind:"splice-blocks",blocks:[x0([...N.quote.children.slice(0,N.childIndex),...E,...N.quote.children.slice(N.childIndex+1)])],rootIndex:N.rootIndex,selection:H0(N.rootIndex,$)}}function b7(N,F){if(F!==0||N.region.text.length!==0||N.block.type!=="paragraph")return null;let M=N.quote.children.slice(0,N.childIndex),A=N.quote.children.slice(N.childIndex+1),D=[];if(M.length>0)D.push(x0(M));if(D.push(e("")),A.length>0)D.push(x0(A));return{kind:"splice-blocks",blocks:D,rootIndex:N.rootIndex,selection:A0(N.rootIndex+(M.length>0?1:0))}}function d4(N,F){if(N.block.type!=="heading")return null;let M=Math.max(1,Math.min(6,N.block.depth+F));if(M===N.block.depth)return{kind:"keep-state"};return{kind:"splice-blocks",blocks:[X2({depth:M,text:N.block.plainText})],rootIndex:N.rootIndex,selection:A0(N.rootIndex,N.offset)}}function f7(N,F,M,A,D){if(A===0)return[e(""),N];if(A===D)return[N,e("")];return[N.type==="heading"?X2({depth:N.depth,text:F}):e(F),e(M)]}function ON(N,F,M,A=0){return H0(N,[...F,M,0],A)}function a4(N,F){let M=N.region.text,A=N.item,D=typeof A.checked==="boolean"?!1:A.checked;if(F===0){let X=UN("",D,A.spread);return{kind:"replace-block",block:q0(N.list,[...N.list.items.slice(0,N.itemIndex),X,A,...N.list.items.slice(N.itemIndex+1)]),blockId:N.list.id,animation:Z6($6(X,N.rootIndex,[...N.listChildIndices,N.itemIndex])),selection:ON(N.rootIndex,N.listChildIndices,N.itemIndex)}}if(F===M.length){let X=UN("",D,A.spread);return{kind:"replace-block",block:q0(N.list,[...N.list.items.slice(0,N.itemIndex+1),X,...N.list.items.slice(N.itemIndex+1)]),blockId:N.list.id,animation:Z6($6(X,N.rootIndex,[...N.listChildIndices,N.itemIndex+1])),selection:ON(N.rootIndex,N.listChildIndices,N.itemIndex+1)}}let E=M.slice(0,F),$=M.slice(F),Z=UN($,D,A.spread),Y=N1(A,[e(E)]);return{kind:"replace-block",block:q0(N.list,[...N.list.items.slice(0,N.itemIndex),Y,Z,...N.list.items.slice(N.itemIndex+1)]),blockId:N.list.id,animation:Z6($6(Z,N.rootIndex,[...N.listChildIndices,N.itemIndex+1])),selection:ON(N.rootIndex,N.listChildIndices,N.itemIndex+1)}}function v7(N,F){if(F!==0||N.region.text.length!==0)return a4(N,F);if(N.parentItem&&N.parentItemIndex!==null&&N.parentItemChildIndices&&N.parentList&&N.parentListChildIndices)return pX(N);let M=N.list.items.slice(0,N.itemIndex),A=N.list.items.slice(N.itemIndex+1),D=[];if(M.length>0)D.push(q0(N.list,M));if(D.push(e("")),A.length>0)D.push(q0(N.list,A));return{kind:"splice-blocks",blocks:D,rootIndex:N.rootIndex,selection:A0(N.rootIndex+(M.length>0?1:0))}}function h7(N){if(N.itemIndex===0)return null;let F=N.list.items[N.itemIndex-1];if(!F)return null;let M=xX(F,N.item,N);return{kind:"replace-block",block:q0(N.list,N.list.items.flatMap((A,D)=>{if(D===N.itemIndex-1)return[M.item];if(D===N.itemIndex)return[];return[A]})),blockId:N.list.id,selection:H0(N.rootIndex,M.regionChildIndices)}}function k7(N){return m7(N,()=>({insertedItem:N.item}))}function r4(N,F){let M=N.itemIndex+F;if(M<0||M>=N.list.items.length)return null;let A=[...N.list.items],[D]=A.splice(N.itemIndex,1);if(!D)return null;return A.splice(M,0,D),{kind:"replace-block",block:q0(N.list,A),blockId:N.list.id,selection:ON(N.rootIndex,N.listChildIndices,M)}}function pX(N){return m7(N,(F)=>{let M=typeof F.checked==="boolean"?!1:F.checked;return{insertedItem:UN("",M,F.spread),trackInsertedPath:!0}})}function m7(N,F){if(!N.parentItem||N.parentItemIndex===null||!N.parentItemChildIndices||!N.parentList||!N.parentListChildIndices)return null;let M=N.list.items.filter((Y,X)=>X!==N.itemIndex),A=N.parentItem.children.flatMap((Y)=>{if(Y.type!=="list"||Y.id!==N.list.id)return[Y];if(M.length===0)return[];return[q0(N.list,M)]}),D=N1(N.parentItem,A),{insertedItem:E,trackInsertedPath:$=!1}=F(N.parentItem),Z=$?$6(E,N.rootIndex,[...N.parentListChildIndices,N.parentItemIndex+1]):void 0;return{kind:"replace-block",block:q0(N.parentList,[...N.parentList.items.slice(0,N.parentItemIndex),D,E,...N.parentList.items.slice(N.parentItemIndex+1)]),blockId:N.parentList.id,animation:Z6(Z),selection:ON(N.rootIndex,N.parentListChildIndices,N.parentItemIndex+1)}}function $6(N,F,M){return typeof N.checked==="boolean"?void 0:h9(F,M)}function Z6(N){return N?{blockPath:N,kind:"block-pulse"}:void 0}function xX(N,F,M){let A=N.children.findIndex((E)=>E.type==="list"&&E.ordered===M.list.ordered&&E.start===M.list.start);if(A>=0){let E=N.children[A];if(!E||E.type!=="list")return{item:N,regionChildIndices:[...M.listChildIndices,M.itemIndex-1,0]};return{item:N1(N,N.children.map(($,Z)=>Z===A?q0(E,[...E.items,F]):$)),regionChildIndices:[...M.listChildIndices,M.itemIndex-1,A,E.items.length,0]}}let D=p1({items:[F],ordered:M.list.ordered,spread:M.list.spread,start:M.list.start});return{item:N1(N,[...N.children,D]),regionChildIndices:[...M.listChildIndices,M.itemIndex-1,N.children.length,0,0]}}function g7(N,F,M){let A=z2(N,F),D=Math.max(2,M);if(!A||A.block.type!=="paragraph"||A.block.plainText.length>0||F.anchor.regionId!==F.focus.regionId||F.anchor.offset!==0||F.focus.offset!==0)return null;return{kind:"splice-blocks",blocks:[x1({rows:Array.from({length:2},()=>s4(D))})],rootIndex:A.rootIndex,selection:a1(A.rootIndex,0,0)}}function c4(N,F){let M=F<0?rX(N.table,N.rowIndex,N.cellIndex):cX(N.table,N.rowIndex,N.cellIndex);if(!M)return F>0&&sX(N.table,N.rowIndex,N.cellIndex)?lX(N):{kind:"keep-state"};let A=N.table.rows[M.rowIndex]?.cells[M.cellIndex];if(!A)return{kind:"keep-state"};return{kind:"set-selection",selection:aX(N.documentIndex,N.selection,N.table,M.rowIndex,M.cellIndex,Math.min(N.selection.focus.offset,A.plainText.length))}}function u7(N){let F=Math.min(N.selection.anchor.offset,N.selection.focus.offset),M=Math.max(N.selection.anchor.offset,N.selection.focus.offset),A=R0(N.inlineContainer,F,M,[e0()]);return{kind:"replace-block",block:A.block,blockId:A.blockId,selection:A.selection}}function I7(N,F){let M=F==="left"?N.cellIndex:N.cellIndex+1;return b2(N,x1({align:r7(N.table.align,M,0,[null]),rows:N.table.rows.map((A)=>J2(dX(A.cells,M,0,[a7()])))}),a1(N.rootIndex,N.rowIndex,M))}function p7(N){let F=Math.max(0,...N.table.rows.map((M)=>M.cells.length));if(F<=1)return null;return b2(N,x1({align:r7(N.table.align,N.cellIndex,1,[]),rows:N.table.rows.map((M)=>J2(M.cells.filter((A,D)=>D!==N.cellIndex)))}),a1(N.rootIndex,N.rowIndex,Math.min(N.cellIndex,F-2)))}function x7(N,F){let M=F==="above"?N.rowIndex:N.rowIndex+1,A=Math.max(1,...N.table.rows.map((D)=>D.cells.length));return b2(N,g0(N.table,[...N.table.rows.slice(0,M),s4(A),...N.table.rows.slice(M)]),a1(N.rootIndex,M,Math.min(N.cellIndex,A-1)))}function l7(N){if(N.table.rows.length<=1)return null;let F=N.table.rows.filter((D,E)=>E!==N.rowIndex),M=Math.min(N.rowIndex,F.length-1),A=F[M]?.cells.length??1;return b2(N,g0(N.table,F),a1(N.rootIndex,M,Math.min(N.cellIndex,A-1)))}function d7(N){return b2(N,e(""),A0(N.rootIndex))}function s4(N){return J2(Array.from({length:N},()=>a7()))}function a7(){return H1([])}function lX(N){let F=N.table.rows.length,M=Math.max(1,...N.table.rows.map((A)=>A.cells.length));return b2(N,g0(N.table,[...N.table.rows,s4(M)]),a1(N.rootIndex,F,0))}function b2(N,F,M){return{kind:"replace-block",block:F,blockId:N.table.id,selection:M}}function dX(N,F,M,A){return[...N.slice(0,F),...A,...N.slice(F+M)]}function r7(N,F,M,A){return[...N.slice(0,F),...A,...N.slice(F+M)]}function aX(N,F,M,A,D,E){let $=P2(N,M.id,A,D);if(!$)return F;return{anchor:{regionId:$.id,offset:E},focus:{regionId:$.id,offset:E}}}function rX(N,F,M){if(M>0)return{cellIndex:M-1,rowIndex:F};if(F>0){let A=N.rows[F-1];if(!A||A.cells.length===0)return null;return{cellIndex:A.cells.length-1,rowIndex:F-1}}return null}function cX(N,F,M){let A=N.rows[F];if(!A)return null;if(M+1<A.cells.length)return{cellIndex:M+1,rowIndex:F};let D=N.rows[F+1];if(!D||D.cells.length===0)return null;return{cellIndex:0,rowIndex:F+1}}function sX(N,F,M){let A=N.rows[F];return Boolean(A&&F===N.rows.length-1&&M===A.cells.length-1)}function c7(N){switch(N.kind){case"code":return{kind:"splice-text",text:`
15
- `};case"tableCell":return u7(N);case"listItem":return v7(N,N.offset)??a4(N,N.offset);case"blockquoteTextBlock":return b7(N,N.offset)??R7(N,N.offset);case"rootTextBlock":return C7(N,N.offset);case"unsupported":return null}}function s7(N,F){let M=E0(N,F);if(M.collapsed)return null;let A=U0(N,M.start.regionId),D=U0(N,M.end.regionId);if(!A||!D)return null;let E=N.document.blocks[A.rootIndex],$=N.document.blocks[D.rootIndex];if(!E||!$)return null;if(A===D)return{kind:"single-region",normalized:M,region:A,root:E,wholeRegion:M.start.offset===0&&M.end.offset===A.text.length};return{kind:"multi-region",normalized:M,startRegion:A,endRegion:D,sameRoot:A.rootIndex===D.rootIndex,startRoot:E,endRoot:$}}function i4(N,F){let M=s7(N,F);if(!M)return null;switch(M.kind){case"single-region":if(!M.wholeRegion||M.region.blockType==="table"){let D=oX(M.region,M.normalized.start.offset,M.normalized.end.offset);return iX(D)}let A=o7(M.root,M.region);return A?i7([A]):null;case"multi-region":{let D=M.sameRoot?nX(N,M.startRoot,M.startRegion,M.normalized.start.offset,M.endRegion,M.normalized.end.offset):NQ(N,M.startRegion,M.normalized.start.offset,M.endRegion,M.normalized.end.offset);return D.length>0?i7(D):null}}}function iX(N){if(N.length===0)return null;if(x3(N))return{kind:"text",text:Y0(N)};return{kind:"inlines",inlines:N}}function i7(N){if(RF(N))return{kind:"text",text:N[0].plainText};return{kind:"blocks",blocks:N}}function o7(N,F){if(N.id===F.blockId)return N;let M=_0(N);if(!M)return null;let A=M.find((E)=>c1(E,F)),D=A?o7(A,F):null;return D?B1(N,[D]):null}function oX(N,F,M){let A=T2(N.inlines,M,N.text.length,""),D=T2(A,0,F,"");return T4(D)}function nX(N,F,M,A,D,E){if(F.type==="table")return eX(N,F,M,A,D,E);let $=n7(F,M,A,D,E);return $?[$]:[]}function tX(N,F,M,A,D){let E=N.roots[F.rootIndex],$=E?.regions[0],Z=E?.regions.at(-1);return F===$&&A===Z&&M===0&&D===Z.text.length}function eX(N,F,M,A,D,E){if(tX(N,M,A,D,E))return[F];let $=M.tableCellPosition?.rowIndex,Z=M.tableCellPosition?.cellIndex,Y=D.tableCellPosition?.rowIndex,X=D.tableCellPosition?.cellIndex;if($===void 0||Z===void 0||Y===void 0||X===void 0)return[];if($!==0||Z!==0||A!==0)return[];let Q=F.rows[Y];if(!Q)return[];let J=Q.cells.length-1;if(X!==J||E!==D.text.length)return[];return[g0(F,F.rows.slice(0,Y+1))]}function n7(N,F,M,A,D){let E=_0(N);if(!E)return null;let $=E.findIndex((Y)=>c1(Y,F)),Z=E.findIndex((Y)=>c1(Y,A));if($===-1||Z===-1)return null;if($===Z){let Y=n7(E[$],F,M,A,D);return Y?B1(N,[Y]):null}return B1(N,t7(E,$,F,M,Z,A,D))}function NQ(N,F,M,A,D){return t7(N.document.blocks,F.rootIndex,F,M,A.rootIndex,A,D)}function t7(N,F,M,A,D,E,$){let Z=HN(N[F],M,A),Y=N.slice(F+1,D),X=zN(N[D],E,$);return[Z,...Y,X].filter((Q)=>Q!==null)}function o4(N,F,M){let A=$Q(N.documentIndex,N.selection);if(!A)return null;return{destination:A,documentIndex:N.documentIndex,inlineContext:A.sameRegion?Y1(N):null,selection:N.selection}}function n4(N,F,M){let A=FQ(N,F)??MQ(N,F,M);return A?EQ(N,A,F):null}function FQ(N,F){switch(F.kind){case"text":return F.text.length>0?{kind:"splice-text",text:F.text}:null;case"inlines":{if(F.inlines.length===0)return null;if(N.destination.sameRegion){let M=N.inlineContext?B7(N.inlineContext,F.inlines):null;if(M)return M}if(N.destination.structuralBlocked)return null;return{kind:"splice-fragment",blocks:[t0(F.inlines)]}}case"blocks":if(F.blocks.length===0||N.destination.structuralBlocked)return null;return{kind:"splice-fragment",blocks:F.blocks}}}function MQ(N,F,M){if(F.kind==="text")return null;let A=N.destination.prefersVerbatimFallback&&M&&M.length>0?M:bF(F);return A.length>0?{kind:"splice-text",text:A}:null}function AQ(N,F){if(N.kind==="splice-text")return N.text;if(N.kind==="replace-block"||N.kind==="splice-fragment")return DQ(F);return""}function DQ(N){switch(N.kind){case"text":return N.text;case"inlines":return Y0(N.inlines);case"blocks":return N.blocks.length===1&&N.blocks[0].type==="paragraph"?N.blocks[0].plainText:""}}function EQ(N,F,M){let A=s1(N.documentIndex,N.selection,AQ(F,M));return A?{...F,animation:A}:F}function $Q(N,F){let M=E0(N,F),A=U0(N,M.start.regionId),D=U0(N,M.end.regionId);if(!A||!D)return null;let E=e7(A)||e7(D);return{prefersVerbatimFallback:A.blockType==="code"||D.blockType==="code",sameRegion:A===D,structuralBlocked:E}}function e7(N){return N.blockType==="table"||N.blockType==="code"}function NM(N,F,M){return{animation:s1(N,F,M),kind:"splice-text",text:M}}function FM(N,F){return{animation:I4(N.region,N.startOffset,F),kind:"splice-text",range:N.selection,text:F}}function MM(N,F,M,A){let D=A==="backward"?_4(N,F.blockId):KN(N,F.blockId);if(D&&M1(D))return ZQ(F,D,A);let E=A==="backward"?r1(N,F.id):VN(N,F.id);if(!E)return null;if(M)return XQ(N,F,E,A);let $=A==="backward"?F:E,Z=A==="backward"?E:F;if(!YQ(Z))return null;return QQ(N,$,Z)}function ZQ(N,F,M){if(F.parentBlockId!==null)return null;let A=M==="backward"?N.rootIndex-1:N.rootIndex,D=M==="backward"?0:"end";return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:[],selection:X6(N,A,D)}}function YQ(N){return N.blockType==="paragraph"||N.blockType==="heading"}function XQ(N,F,M,A){let D=N.document.blocks[F.rootIndex];if(!D)return null;let E=Y6(D,F,M.blockId,void 0),$=A==="backward"?M.text.length:0,Y=F.rootIndex===M.rootIndex?qQ(E,M.rootIndex,M.blockId,$):UQ(M,F.rootIndex,E.length,$);if(!Y)return null;return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:E,selection:Y}}function QQ(N,F,M){let A=Z1(N.document,M.blockId),D=Z1(N.document,F.blockId);if(!A||A.type!=="paragraph"&&A.type!=="heading")return null;let E=M.text.length,$=JQ(A,D),Z=X6(M,M.rootIndex,E);if(F.rootIndex===M.rootIndex){let y=N.document.blocks[F.rootIndex];if(!y)return null;let G=Y6(y,F,M.blockId,$);return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:G,selection:Z}}let Y=N.document.blocks[M.rootIndex],X=N.document.blocks[F.rootIndex];if(!Y||!X)return null;let Q=Y6(Y,F,M.blockId,$);if(Q.length!==1)return null;let J=Q[0],q=Y6(X,F,M.blockId,void 0),U=Math.min(M.rootIndex,F.rootIndex),V=M.rootIndex<F.rootIndex?[J,...q]:[...q,J];return{kind:"splice-blocks",rootIndex:U,count:2,blocks:V,selection:Z}}function X6(N,F,M=0){let A=P1(N.path);if(A.length===0)return A0(F,M);return H0(F,A,M)}function JQ(N,F){let M=F&&(F.type==="paragraph"||F.type==="heading")?F.children:[];return w0(N,G0([...N.children,...M]))}function qQ(N,F,M,A){for(let D=0;D<N.length;D+=1){let E=N[D],$=t4(E,M);if($){if($.length===0)return A0(F+D,A);return H0(F+D,$,A)}}return null}function UQ(N,F,M,A){let D=P1(N.path),E=M-1,$=N.rootIndex<F?N.rootIndex:N.rootIndex+E;if(D.length===0)return A0($,A);return H0($,D,A)}function t4(N,F){if(N.id===F)return[];switch(N.type){case"list":for(let M=0;M<N.items.length;M+=1){let A=t4(N.items[M],F);if(A)return[M,...A]}return null;case"listItem":case"blockquote":for(let M=0;M<N.children.length;M+=1){let A=t4(N.children[M],F);if(A)return[M,...A]}return null;default:return null}}function Y6(N,F,M,A){return U2([N],(D,{parent:E,recurse:$})=>{if(D.type==="listItem"){let Y=D.children[0];if(Y&&Y.id===F.blockId)return VQ(D)}if(D.id===F.blockId&&E?.type!=="listItem")return[];if(D.id===M&&A!==void 0)return A;let Z=$();if(Z.type==="listItem"){let Y=Z.children[0];if(!Y||Y.type!=="paragraph"&&Y.type!=="heading")return[]}return Z})}function VQ(N){if(N.type==="listItem")return N.children.filter((F)=>F.type==="list").flatMap((F)=>F.items);return[]}function AM(N,F){let M=z4(N,F.rootIndex);if(!M||M.id!==F.id)return null;let A=N.document.blocks[F.rootIndex];if(!A)return null;let D=KQ(A);if(!D)return null;return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:D,selection:A0(F.rootIndex)}}function KQ(N){switch(N.type){case"heading":return[t0(N.children)];case"blockquote":return[...N.children];case"list":return DM(N.items);default:return null}}function DM(N){return N.flatMap((F)=>{let M=[GQ(F)];for(let A of F.children)if(A.type==="list")M.push(...DM(A.items));return M})}function GQ(N){let F=N.children[0];if(F&&(F.type==="paragraph"||F.type==="heading"))return t0(F.children);return e("")}function EM(N,F){if(F.kind==="unsupported"||!F.atBoundary)return null;if(F.direction==="backward"){let M=yQ(F,N);if(M)return M}return MM(N,F.region,F.empty,F.direction)}function yQ(N,F){let M=AM(F,N.region);if(M)return M;if(N.kind==="rootTextBlock"){let A=SQ(N,F);if(A)return A}return null}function SQ(N,F){if(N.block.type!=="paragraph"||N.block.plainText.length!==0)return null;let M=F.document.blocks[N.rootIndex-1],A=F.document.blocks[N.rootIndex+1];if(!M||M.type!=="list"||!A||A.type!=="list"||!_Q(M,A))return null;let D=r1(F,N.region.id),E=D?X6(D,N.rootIndex-1,"end"):A0(N.rootIndex-1,"end");return{kind:"splice-blocks",count:3,blocks:[q0(M,[...M.items,...A.items])],rootIndex:N.rootIndex-1,selection:E}}function _Q(N,F){return N.ordered===F.ordered&&N.start===F.start}var LN=F0((N,F)=>j7(N.documentIndex,N.selection,F)),Q6=F0(c7,{context:xF}),$M=F0((N)=>WQ(N)??{kind:"splice-text",text:`
16
- `}),zQ=F0((N,F)=>NM(N.documentIndex,N.selection,F)),J6=F0((N,F,M,A)=>FM(N,A),{context:(N,F,M)=>K4(N,F,M)}),e4=(N)=>zQ(N,""),N8=fM(vM,(N)=>kM(N,"backward"),(N)=>hM(N,"backward")),F8=fM(vM,(N)=>kM(N,"forward"),(N)=>hM(N,"forward")),TN=(N)=>i4(N.documentIndex,N.selection),HQ=F0(n4,{context:o4});function ZM(N,F,M){return HQ(N,F,M)}function YM(N){let F=N.documentIndex.regions,M=F[0],A=F.at(-1);if(!M||!A)return N;return y0(N,{anchor:{regionId:M.id,offset:0},focus:{regionId:A.id,offset:A.text.length}})}var q6=G6("bold"),U6=G6("italic"),V6=G6("strikethrough"),K6=G6("underline"),XM=F0((N)=>j2(N,f4),{context:Y1}),QM=F0((N,F,M)=>j2(N,(A,D,E)=>k4(A,D,E,M)),{context:pF}),JM=F0((N,F)=>j2(N,m4),{context:pF}),qM=F0((N,F)=>j2(N,(M,A,D)=>h4(M,A,D,F)),{context:Y1}),UM=F0((N,F,M)=>u4(N,z1({alt:M??null,url:F})),{context:Y1}),VM=F0((N,F,M,A,D="")=>g4(N,M,A,D),{context:pF}),KM=F0((N,F,M)=>v4(N.inlineContainer,F,M),{context:Y1}),M8=(N)=>R4(N),A8=(N)=>b4(N),GM=F0((N)=>{switch(N.kind){case"tableCell":return c4(N,1);case"rootTextBlock":return d4(N,1);case"listItem":return h7(N);default:return null}},{context:xF}),yM=F0((N)=>{switch(N.kind){case"tableCell":return c4(N,-1);case"rootTextBlock":return d4(N,-1);case"listItem":return k7(N);default:return null}},{context:xF}),SM=F0((N)=>r4(N,-1),{context:y4}),_M=F0((N)=>r4(N,1),{context:y4}),zM=F0((N,F)=>{let M=JN(N.documentIndex,F);if(!M||M.type!=="listItem"||typeof M.checked!=="boolean")return null;return{kind:"replace-block",block:{...M,checked:!M.checked},blockId:F}}),HM=F0((N,F)=>g7(N.documentIndex,N.selection,F)),BM=F0((N,F)=>I7(N,F),{context:H2}),WM=F0(p7,{context:H2}),PM=F0((N,F)=>x7(N,F),{context:H2}),OM=F0(l7,{context:H2}),LM=F0(d7,{context:H2}),TM=F0((N,F,M)=>{let A=D4(N.documentIndex,F,M);if(!A)return null;return{kind:"splice-comments",count:0,index:N.documentIndex.document.comments.length,threads:[A]}}),wM=(N,F,M)=>wN(N,F,(A)=>t3(A,{body:M.trim()})),jM=(N,F,M,A)=>wN(N,F,(D)=>e3(D,M,A)),CM=(N,F,M)=>wN(N,F,(A)=>N4(A,M)),RM=(N,F)=>wN(N,F,()=>null),bM=(N,F,M)=>wN(N,F,(A)=>F4(A,M));function F0(N,F){return(M,...A)=>{let D=F&&"context"in F?BQ(N,F,M,A):N(M,...A);if(!D)return null;return WN(M,D)}}function BQ(N,F,M,A){let D=F.context(M,...A);return D?N(D,...A):null}function fM(...N){return(F,...M)=>{for(let A of N){let D=A(F,...M);if(D)return D}return null}}function vM(N){return PQ(N)?e4(N):null}function hM(N,F){let M=R9(N,F);return WN(N,EM(N.documentIndex,M))}function WQ(N){let F=Y1(N);return F?u4(F,e0()):null}function G6(N){return F0((F)=>j2(F,(M,A,D)=>q4(M,A,D,N)),{context:Y1})}function PQ(N){let F=E0(N.documentIndex,N.selection);return F.start.regionId!==F.end.regionId||F.start.offset!==F.end.offset}function kM(N,F){let M=L7(N,F);return WN(N,M)}function wN(N,F,M){let D=j0(N.documentIndex).threads[F];if(!D)return null;let E=M(D);if(E===D)return null;return WN(N,{kind:"splice-comments",count:1,index:F,threads:E?[E]:[]})}function i1(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function mM(N,F,M){return jN(N.preparedText,F,M,256)}function gM(N,F,M){return jN(N.measuredLines,F,M,512)}function uM(N,F,M){return jN(N.lineBoundaries,F,M,1024)}function IM(N,F,M){return jN(N.measuredContainerHeights,F,M,1024)}function pM(N,F){let M=N.graphemeWidths.get(F);if(M)return M;let A=new Map;return jN(N.graphemeWidths,F,A,64),A}function xM(N,F,M){return N.viewportPlans.get(F)?.get(M)??null}function lM(N,F,M,A){let D=N.viewportPlans.get(F)??new Map;return D.set(M,A),N.viewportPlans.set(F,D),A}function jN(N,F,M,A){if(N.has(F))N.delete(F);if(N.set(F,M),N.size>A){let D=N.keys().next().value;if(D!==void 0)N.delete(D)}return M}var y6={blockGap:16,charWidth:9,indentWidth:12,lineHeight:24,paddingX:16,paddingY:12};function S6(N){return{...y6,...N}}function _6(N,F,M,A,D){if(dM(N,M,A,"list"))return 6;if(dM(N,M,A,"blockquote"))return 10;if(M===A)return 4;return D+OQ(F.get(M))}function OQ(N){if(N?.type!=="heading")return 0;if(N.depth===1)return 24;return N.depth===2?16:0}function dM(N,F,M,A){let D=aM(N,F,A),E=aM(N,M,A);for(let $ of D)if(E.has($))return!0;return!1}function aM(N,F,M){let A=new Set,D=N.get(F)??null;while(D){if(D.type===M)A.add(D.id);D=D.parentBlockId?N.get(D.parentBlockId)??null:null}return A}var rM=18,cM=14;var sM=22;function f2(N,F,M){let A=N.get(M)??null;while(A){if(A.type==="listItem")return F.get(A.id)?.kind==="task"?22:18;A=A.parentBlockId?N.get(A.parentBlockId)??null:null}return 0}var iM=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","BN","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],D8=[[697,698,"ON"],[706,719,"ON"],[722,735,"ON"],[741,749,"ON"],[751,767,"ON"],[768,879,"NSM"],[884,885,"ON"],[894,894,"ON"],[900,901,"ON"],[903,903,"ON"],[1014,1014,"ON"],[1155,1161,"NSM"],[1418,1418,"ON"],[1421,1422,"ON"],[1423,1423,"ET"],[1424,1424,"R"],[1425,1469,"NSM"],[1470,1470,"R"],[1471,1471,"NSM"],[1472,1472,"R"],[1473,1474,"NSM"],[1475,1475,"R"],[1476,1477,"NSM"],[1478,1478,"R"],[1479,1479,"NSM"],[1480,1535,"R"],[1536,1541,"AN"],[1542,1543,"ON"],[1544,1544,"AL"],[1545,1546,"ET"],[1547,1547,"AL"],[1548,1548,"CS"],[1549,1549,"AL"],[1550,1551,"ON"],[1552,1562,"NSM"],[1563,1610,"AL"],[1611,1631,"NSM"],[1632,1641,"AN"],[1642,1642,"ET"],[1643,1644,"AN"],[1645,1647,"AL"],[1648,1648,"NSM"],[1649,1749,"AL"],[1750,1756,"NSM"],[1757,1757,"AN"],[1758,1758,"ON"],[1759,1764,"NSM"],[1765,1766,"AL"],[1767,1768,"NSM"],[1769,1769,"ON"],[1770,1773,"NSM"],[1774,1775,"AL"],[1776,1785,"EN"],[1786,1808,"AL"],[1809,1809,"NSM"],[1810,1839,"AL"],[1840,1866,"NSM"],[1867,1957,"AL"],[1958,1968,"NSM"],[1969,1983,"AL"],[1984,2026,"R"],[2027,2035,"NSM"],[2036,2037,"R"],[2038,2041,"ON"],[2042,2044,"R"],[2045,2045,"NSM"],[2046,2069,"R"],[2070,2073,"NSM"],[2074,2074,"R"],[2075,2083,"NSM"],[2084,2084,"R"],[2085,2087,"NSM"],[2088,2088,"R"],[2089,2093,"NSM"],[2094,2136,"R"],[2137,2139,"NSM"],[2140,2143,"R"],[2144,2191,"AL"],[2192,2193,"AN"],[2194,2198,"AL"],[2199,2207,"NSM"],[2208,2249,"AL"],[2250,2273,"NSM"],[2274,2274,"AN"],[2275,2306,"NSM"],[2362,2362,"NSM"],[2364,2364,"NSM"],[2369,2376,"NSM"],[2381,2381,"NSM"],[2385,2391,"NSM"],[2402,2403,"NSM"],[2433,2433,"NSM"],[2492,2492,"NSM"],[2497,2500,"NSM"],[2509,2509,"NSM"],[2530,2531,"NSM"],[2546,2547,"ET"],[2555,2555,"ET"],[2558,2558,"NSM"],[2561,2562,"NSM"],[2620,2620,"NSM"],[2625,2626,"NSM"],[2631,2632,"NSM"],[2635,2637,"NSM"],[2641,2641,"NSM"],[2672,2673,"NSM"],[2677,2677,"NSM"],[2689,2690,"NSM"],[2748,2748,"NSM"],[2753,2757,"NSM"],[2759,2760,"NSM"],[2765,2765,"NSM"],[2786,2787,"NSM"],[2801,2801,"ET"],[2810,2815,"NSM"],[2817,2817,"NSM"],[2876,2876,"NSM"],[2879,2879,"NSM"],[2881,2884,"NSM"],[2893,2893,"NSM"],[2901,2902,"NSM"],[2914,2915,"NSM"],[2946,2946,"NSM"],[3008,3008,"NSM"],[3021,3021,"NSM"],[3059,3064,"ON"],[3065,3065,"ET"],[3066,3066,"ON"],[3072,3072,"NSM"],[3076,3076,"NSM"],[3132,3132,"NSM"],[3134,3136,"NSM"],[3142,3144,"NSM"],[3146,3149,"NSM"],[3157,3158,"NSM"],[3170,3171,"NSM"],[3192,3198,"ON"],[3201,3201,"NSM"],[3260,3260,"NSM"],[3276,3277,"NSM"],[3298,3299,"NSM"],[3328,3329,"NSM"],[3387,3388,"NSM"],[3393,3396,"NSM"],[3405,3405,"NSM"],[3426,3427,"NSM"],[3457,3457,"NSM"],[3530,3530,"NSM"],[3538,3540,"NSM"],[3542,3542,"NSM"],[3633,3633,"NSM"],[3636,3642,"NSM"],[3647,3647,"ET"],[3655,3662,"NSM"],[3761,3761,"NSM"],[3764,3772,"NSM"],[3784,3790,"NSM"],[3864,3865,"NSM"],[3893,3893,"NSM"],[3895,3895,"NSM"],[3897,3897,"NSM"],[3898,3901,"ON"],[3953,3966,"NSM"],[3968,3972,"NSM"],[3974,3975,"NSM"],[3981,3991,"NSM"],[3993,4028,"NSM"],[4038,4038,"NSM"],[4141,4144,"NSM"],[4146,4151,"NSM"],[4153,4154,"NSM"],[4157,4158,"NSM"],[4184,4185,"NSM"],[4190,4192,"NSM"],[4209,4212,"NSM"],[4226,4226,"NSM"],[4229,4230,"NSM"],[4237,4237,"NSM"],[4253,4253,"NSM"],[4957,4959,"NSM"],[5008,5017,"ON"],[5120,5120,"ON"],[5760,5760,"WS"],[5787,5788,"ON"],[5906,5908,"NSM"],[5938,5939,"NSM"],[5970,5971,"NSM"],[6002,6003,"NSM"],[6068,6069,"NSM"],[6071,6077,"NSM"],[6086,6086,"NSM"],[6089,6099,"NSM"],[6107,6107,"ET"],[6109,6109,"NSM"],[6128,6137,"ON"],[6144,6154,"ON"],[6155,6157,"NSM"],[6158,6158,"BN"],[6159,6159,"NSM"],[6277,6278,"NSM"],[6313,6313,"NSM"],[6432,6434,"NSM"],[6439,6440,"NSM"],[6450,6450,"NSM"],[6457,6459,"NSM"],[6464,6464,"ON"],[6468,6469,"ON"],[6622,6655,"ON"],[6679,6680,"NSM"],[6683,6683,"NSM"],[6742,6742,"NSM"],[6744,6750,"NSM"],[6752,6752,"NSM"],[6754,6754,"NSM"],[6757,6764,"NSM"],[6771,6780,"NSM"],[6783,6783,"NSM"],[6832,6877,"NSM"],[6880,6891,"NSM"],[6912,6915,"NSM"],[6964,6964,"NSM"],[6966,6970,"NSM"],[6972,6972,"NSM"],[6978,6978,"NSM"],[7019,7027,"NSM"],[7040,7041,"NSM"],[7074,7077,"NSM"],[7080,7081,"NSM"],[7083,7085,"NSM"],[7142,7142,"NSM"],[7144,7145,"NSM"],[7149,7149,"NSM"],[7151,7153,"NSM"],[7212,7219,"NSM"],[7222,7223,"NSM"],[7376,7378,"NSM"],[7380,7392,"NSM"],[7394,7400,"NSM"],[7405,7405,"NSM"],[7412,7412,"NSM"],[7416,7417,"NSM"],[7616,7679,"NSM"],[8125,8125,"ON"],[8127,8129,"ON"],[8141,8143,"ON"],[8157,8159,"ON"],[8173,8175,"ON"],[8189,8190,"ON"],[8192,8202,"WS"],[8203,8205,"BN"],[8207,8207,"R"],[8208,8231,"ON"],[8232,8232,"WS"],[8233,8233,"B"],[8234,8238,"BN"],[8239,8239,"CS"],[8240,8244,"ET"],[8245,8259,"ON"],[8260,8260,"CS"],[8261,8286,"ON"],[8287,8287,"WS"],[8288,8303,"BN"],[8304,8304,"EN"],[8308,8313,"EN"],[8314,8315,"ES"],[8316,8318,"ON"],[8320,8329,"EN"],[8330,8331,"ES"],[8332,8334,"ON"],[8352,8399,"ET"],[8400,8432,"NSM"],[8448,8449,"ON"],[8451,8454,"ON"],[8456,8457,"ON"],[8468,8468,"ON"],[8470,8472,"ON"],[8478,8483,"ON"],[8485,8485,"ON"],[8487,8487,"ON"],[8489,8489,"ON"],[8494,8494,"ET"],[8506,8507,"ON"],[8512,8516,"ON"],[8522,8525,"ON"],[8528,8543,"ON"],[8585,8587,"ON"],[8592,8721,"ON"],[8722,8722,"ES"],[8723,8723,"ET"],[8724,9013,"ON"],[9083,9108,"ON"],[9110,9257,"ON"],[9280,9290,"ON"],[9312,9351,"ON"],[9352,9371,"EN"],[9450,9899,"ON"],[9901,10239,"ON"],[10496,11123,"ON"],[11126,11263,"ON"],[11493,11498,"ON"],[11503,11505,"NSM"],[11513,11519,"ON"],[11647,11647,"NSM"],[11744,11775,"NSM"],[11776,11869,"ON"],[11904,11929,"ON"],[11931,12019,"ON"],[12032,12245,"ON"],[12272,12287,"ON"],[12288,12288,"WS"],[12289,12292,"ON"],[12296,12320,"ON"],[12330,12333,"NSM"],[12336,12336,"ON"],[12342,12343,"ON"],[12349,12351,"ON"],[12441,12442,"NSM"],[12443,12444,"ON"],[12448,12448,"ON"],[12539,12539,"ON"],[12736,12773,"ON"],[12783,12783,"ON"],[12829,12830,"ON"],[12880,12895,"ON"],[12924,12926,"ON"],[12977,12991,"ON"],[13004,13007,"ON"],[13175,13178,"ON"],[13278,13279,"ON"],[13311,13311,"ON"],[19904,19967,"ON"],[42128,42182,"ON"],[42509,42511,"ON"],[42607,42610,"NSM"],[42611,42611,"ON"],[42612,42621,"NSM"],[42622,42623,"ON"],[42654,42655,"NSM"],[42736,42737,"NSM"],[42752,42785,"ON"],[42888,42888,"ON"],[43010,43010,"NSM"],[43014,43014,"NSM"],[43019,43019,"NSM"],[43045,43046,"NSM"],[43048,43051,"ON"],[43052,43052,"NSM"],[43064,43065,"ET"],[43124,43127,"ON"],[43204,43205,"NSM"],[43232,43249,"NSM"],[43263,43263,"NSM"],[43302,43309,"NSM"],[43335,43345,"NSM"],[43392,43394,"NSM"],[43443,43443,"NSM"],[43446,43449,"NSM"],[43452,43453,"NSM"],[43493,43493,"NSM"],[43561,43566,"NSM"],[43569,43570,"NSM"],[43573,43574,"NSM"],[43587,43587,"NSM"],[43596,43596,"NSM"],[43644,43644,"NSM"],[43696,43696,"NSM"],[43698,43700,"NSM"],[43703,43704,"NSM"],[43710,43711,"NSM"],[43713,43713,"NSM"],[43756,43757,"NSM"],[43766,43766,"NSM"],[43882,43883,"ON"],[44005,44005,"NSM"],[44008,44008,"NSM"],[44013,44013,"NSM"],[64285,64285,"R"],[64286,64286,"NSM"],[64287,64296,"R"],[64297,64297,"ES"],[64298,64335,"R"],[64336,64450,"AL"],[64451,64466,"ON"],[64467,64829,"AL"],[64830,64847,"ON"],[64848,64911,"AL"],[64912,64913,"ON"],[64914,64967,"AL"],[64968,64975,"ON"],[64976,65007,"BN"],[65008,65020,"AL"],[65021,65023,"ON"],[65024,65039,"NSM"],[65040,65049,"ON"],[65056,65071,"NSM"],[65072,65103,"ON"],[65104,65104,"CS"],[65105,65105,"ON"],[65106,65106,"CS"],[65108,65108,"ON"],[65109,65109,"CS"],[65110,65118,"ON"],[65119,65119,"ET"],[65120,65121,"ON"],[65122,65123,"ES"],[65124,65126,"ON"],[65128,65128,"ON"],[65129,65130,"ET"],[65131,65131,"ON"],[65136,65278,"AL"],[65279,65279,"BN"],[65281,65282,"ON"],[65283,65285,"ET"],[65286,65290,"ON"],[65291,65291,"ES"],[65292,65292,"CS"],[65293,65293,"ES"],[65294,65295,"CS"],[65296,65305,"EN"],[65306,65306,"CS"],[65307,65312,"ON"],[65339,65344,"ON"],[65371,65381,"ON"],[65504,65505,"ET"],[65506,65508,"ON"],[65509,65510,"ET"],[65512,65518,"ON"],[65520,65528,"BN"],[65529,65533,"ON"],[65534,65535,"BN"],[65793,65793,"ON"],[65856,65932,"ON"],[65936,65948,"ON"],[65952,65952,"ON"],[66045,66045,"NSM"],[66272,66272,"NSM"],[66273,66299,"EN"],[66422,66426,"NSM"],[67584,67870,"R"],[67871,67871,"ON"],[67872,68096,"R"],[68097,68099,"NSM"],[68100,68100,"R"],[68101,68102,"NSM"],[68103,68107,"R"],[68108,68111,"NSM"],[68112,68151,"R"],[68152,68154,"NSM"],[68155,68158,"R"],[68159,68159,"NSM"],[68160,68324,"R"],[68325,68326,"NSM"],[68327,68408,"R"],[68409,68415,"ON"],[68416,68863,"R"],[68864,68899,"AL"],[68900,68903,"NSM"],[68904,68911,"AL"],[68912,68921,"AN"],[68922,68927,"AL"],[68928,68937,"AN"],[68938,68968,"R"],[68969,68973,"NSM"],[68974,68974,"ON"],[68975,69215,"R"],[69216,69246,"AN"],[69247,69290,"R"],[69291,69292,"NSM"],[69293,69311,"R"],[69312,69327,"AL"],[69328,69336,"ON"],[69337,69369,"AL"],[69370,69375,"NSM"],[69376,69423,"R"],[69424,69445,"AL"],[69446,69456,"NSM"],[69457,69487,"AL"],[69488,69505,"R"],[69506,69509,"NSM"],[69510,69631,"R"],[69633,69633,"NSM"],[69688,69702,"NSM"],[69714,69733,"ON"],[69744,69744,"NSM"],[69747,69748,"NSM"],[69759,69761,"NSM"],[69811,69814,"NSM"],[69817,69818,"NSM"],[69826,69826,"NSM"],[69888,69890,"NSM"],[69927,69931,"NSM"],[69933,69940,"NSM"],[70003,70003,"NSM"],[70016,70017,"NSM"],[70070,70078,"NSM"],[70089,70092,"NSM"],[70095,70095,"NSM"],[70191,70193,"NSM"],[70196,70196,"NSM"],[70198,70199,"NSM"],[70206,70206,"NSM"],[70209,70209,"NSM"],[70367,70367,"NSM"],[70371,70378,"NSM"],[70400,70401,"NSM"],[70459,70460,"NSM"],[70464,70464,"NSM"],[70502,70508,"NSM"],[70512,70516,"NSM"],[70587,70592,"NSM"],[70606,70606,"NSM"],[70608,70608,"NSM"],[70610,70610,"NSM"],[70625,70626,"NSM"],[70712,70719,"NSM"],[70722,70724,"NSM"],[70726,70726,"NSM"],[70750,70750,"NSM"],[70835,70840,"NSM"],[70842,70842,"NSM"],[70847,70848,"NSM"],[70850,70851,"NSM"],[71090,71093,"NSM"],[71100,71101,"NSM"],[71103,71104,"NSM"],[71132,71133,"NSM"],[71219,71226,"NSM"],[71229,71229,"NSM"],[71231,71232,"NSM"],[71264,71276,"ON"],[71339,71339,"NSM"],[71341,71341,"NSM"],[71344,71349,"NSM"],[71351,71351,"NSM"],[71453,71453,"NSM"],[71455,71455,"NSM"],[71458,71461,"NSM"],[71463,71467,"NSM"],[71727,71735,"NSM"],[71737,71738,"NSM"],[71995,71996,"NSM"],[71998,71998,"NSM"],[72003,72003,"NSM"],[72148,72151,"NSM"],[72154,72155,"NSM"],[72160,72160,"NSM"],[72193,72198,"NSM"],[72201,72202,"NSM"],[72243,72248,"NSM"],[72251,72254,"NSM"],[72263,72263,"NSM"],[72273,72278,"NSM"],[72281,72283,"NSM"],[72330,72342,"NSM"],[72344,72345,"NSM"],[72544,72544,"NSM"],[72546,72548,"NSM"],[72550,72550,"NSM"],[72752,72758,"NSM"],[72760,72765,"NSM"],[72850,72871,"NSM"],[72874,72880,"NSM"],[72882,72883,"NSM"],[72885,72886,"NSM"],[73009,73014,"NSM"],[73018,73018,"NSM"],[73020,73021,"NSM"],[73023,73029,"NSM"],[73031,73031,"NSM"],[73104,73105,"NSM"],[73109,73109,"NSM"],[73111,73111,"NSM"],[73459,73460,"NSM"],[73472,73473,"NSM"],[73526,73530,"NSM"],[73536,73536,"NSM"],[73538,73538,"NSM"],[73562,73562,"NSM"],[73685,73692,"ON"],[73693,73696,"ET"],[73697,73713,"ON"],[78912,78912,"NSM"],[78919,78933,"NSM"],[90398,90409,"NSM"],[90413,90415,"NSM"],[92912,92916,"NSM"],[92976,92982,"NSM"],[94031,94031,"NSM"],[94095,94098,"NSM"],[94178,94178,"ON"],[94180,94180,"NSM"],[113821,113822,"NSM"],[113824,113827,"BN"],[117760,117973,"ON"],[118000,118009,"EN"],[118010,118012,"ON"],[118016,118451,"ON"],[118458,118480,"ON"],[118496,118512,"ON"],[118528,118573,"NSM"],[118576,118598,"NSM"],[119143,119145,"NSM"],[119155,119162,"BN"],[119163,119170,"NSM"],[119173,119179,"NSM"],[119210,119213,"NSM"],[119273,119274,"ON"],[119296,119361,"ON"],[119362,119364,"NSM"],[119365,119365,"ON"],[119552,119638,"ON"],[120513,120513,"ON"],[120539,120539,"ON"],[120571,120571,"ON"],[120597,120597,"ON"],[120629,120629,"ON"],[120655,120655,"ON"],[120687,120687,"ON"],[120713,120713,"ON"],[120745,120745,"ON"],[120771,120771,"ON"],[120782,120831,"EN"],[121344,121398,"NSM"],[121403,121452,"NSM"],[121461,121461,"NSM"],[121476,121476,"NSM"],[121499,121503,"NSM"],[121505,121519,"NSM"],[122880,122886,"NSM"],[122888,122904,"NSM"],[122907,122913,"NSM"],[122915,122916,"NSM"],[122918,122922,"NSM"],[123023,123023,"NSM"],[123184,123190,"NSM"],[123566,123566,"NSM"],[123628,123631,"NSM"],[123647,123647,"ET"],[124140,124143,"NSM"],[124398,124399,"NSM"],[124643,124643,"NSM"],[124646,124646,"NSM"],[124654,124655,"NSM"],[124661,124661,"NSM"],[124928,125135,"R"],[125136,125142,"NSM"],[125143,125251,"R"],[125252,125258,"NSM"],[125259,126063,"R"],[126064,126143,"AL"],[126144,126207,"R"],[126208,126287,"AL"],[126288,126463,"R"],[126464,126703,"AL"],[126704,126705,"ON"],[126706,126719,"AL"],[126720,126975,"R"],[126976,127019,"ON"],[127024,127123,"ON"],[127136,127150,"ON"],[127153,127167,"ON"],[127169,127183,"ON"],[127185,127221,"ON"],[127232,127242,"EN"],[127243,127247,"ON"],[127279,127279,"ON"],[127338,127343,"ON"],[127405,127405,"ON"],[127584,127589,"ON"],[127744,128728,"ON"],[128732,128748,"ON"],[128752,128764,"ON"],[128768,128985,"ON"],[128992,129003,"ON"],[129008,129008,"ON"],[129024,129035,"ON"],[129040,129095,"ON"],[129104,129113,"ON"],[129120,129159,"ON"],[129168,129197,"ON"],[129200,129211,"ON"],[129216,129217,"ON"],[129232,129240,"ON"],[129280,129623,"ON"],[129632,129645,"ON"],[129648,129660,"ON"],[129664,129674,"ON"],[129678,129734,"ON"],[129736,129736,"ON"],[129741,129756,"ON"],[129759,129770,"ON"],[129775,129784,"ON"],[129792,129938,"ON"],[129940,130031,"ON"],[130032,130041,"EN"],[130042,130042,"ON"],[131070,131071,"BN"],[196606,196607,"BN"],[262142,262143,"BN"],[327678,327679,"BN"],[393214,393215,"BN"],[458750,458751,"BN"],[524286,524287,"BN"],[589822,589823,"BN"],[655358,655359,"BN"],[720894,720895,"BN"],[786430,786431,"BN"],[851966,851967,"BN"],[917502,917759,"BN"],[917760,917999,"NSM"],[918000,921599,"BN"],[983038,983039,"BN"],[1048574,1048575,"BN"],[1114110,1114111,"BN"]];function LQ(N){if(N<=255)return iM[N];let F=0,M=D8.length-1;while(F<=M){let A=F+M>>1,D=D8[A];if(N<D[0]){M=A-1;continue}if(N>D[1]){F=A+1;continue}return D[2]}return"L"}function TQ(N){let F=N.length;if(F===0)return null;let M=Array(F),A=!1;for(let X=0;X<F;){let Q=N.charCodeAt(X),J=Q,q=1;if(Q>=55296&&Q<=56319&&X+1<F){let V=N.charCodeAt(X+1);if(V>=56320&&V<=57343)J=(Q-55296<<10)+(V-56320)+65536,q=2}let U=LQ(J);if(U==="R"||U==="AL"||U==="AN")A=!0;for(let V=0;V<q;V++)M[X+V]=U;X+=q}if(!A)return null;let D=0;for(let X=0;X<F;X++){let Q=M[X];if(Q==="L"){D=0;break}if(Q==="R"||Q==="AL"){D=1;break}}let E=new Int8Array(F);for(let X=0;X<F;X++)E[X]=D;let $=D&1?"R":"L",Z=$,Y=Z;for(let X=0;X<F;X++)if(M[X]==="NSM")M[X]=Y;else Y=M[X];Y=Z;for(let X=0;X<F;X++){let Q=M[X];if(Q==="EN")M[X]=Y==="AL"?"AN":"EN";else if(Q==="R"||Q==="L"||Q==="AL")Y=Q}for(let X=0;X<F;X++)if(M[X]==="AL")M[X]="R";for(let X=1;X<F-1;X++){if(M[X]==="ES"&&M[X-1]==="EN"&&M[X+1]==="EN")M[X]="EN";if(M[X]==="CS"&&(M[X-1]==="EN"||M[X-1]==="AN")&&M[X+1]===M[X-1])M[X]=M[X-1]}for(let X=0;X<F;X++){if(M[X]!=="EN")continue;let Q;for(Q=X-1;Q>=0&&M[Q]==="ET";Q--)M[Q]="EN";for(Q=X+1;Q<F&&M[Q]==="ET";Q++)M[Q]="EN"}for(let X=0;X<F;X++){let Q=M[X];if(Q==="WS"||Q==="ES"||Q==="ET"||Q==="CS")M[X]="ON"}Y=Z;for(let X=0;X<F;X++){let Q=M[X];if(Q==="EN")M[X]=Y==="L"?"L":"EN";else if(Q==="R"||Q==="L")Y=Q}for(let X=0;X<F;X++){if(M[X]!=="ON")continue;let Q=X+1;while(Q<F&&M[Q]==="ON")Q++;let J=X>0?M[X-1]:Z,q=Q<F?M[Q]:Z,U=J!=="L"?"R":"L";if(U===(q!=="L"?"R":"L"))for(let y=X;y<Q;y++)M[y]=U;X=Q-1}for(let X=0;X<F;X++)if(M[X]==="ON")M[X]=$;for(let X=0;X<F;X++){let Q=M[X];if((E[X]&1)===0){if(Q==="R")E[X]++;else if(Q==="AN"||Q==="EN")E[X]+=2}else if(Q==="L"||Q==="AN"||Q==="EN")E[X]++}return E}function oM(N,F){let M=TQ(N);if(M===null)return null;let A=new Int8Array(F.length);for(let D=0;D<F.length;D++)A[D]=M[F[D]];return A}var wQ=/[ \t\n\r\f]+/g,jQ=/[\t\n\r\f]| {2,}|^ | $/;function CQ(N){let F=N??"normal";return F==="pre-wrap"?{mode:F,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:F,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function RQ(N){if(!jQ.test(N))return N;let F=N.replace(wQ," ");if(F.charCodeAt(0)===32)F=F.slice(1);if(F.length>0&&F.charCodeAt(F.length-1)===32)F=F.slice(0,-1);return F}function bQ(N){if(!/[\r\f]/.test(N))return N;return N.replace(/\r\n/g,`
7
+ `).trim()}function z4(N){return N.every((F)=>F.type==="text"&&F.marks.length===0)}function tF(N){if(N.length!==1)return!1;let F=N[0];return F.type==="paragraph"&&z4(F.children)}function eF(N){switch(N.kind){case"text":return N.text;case"inlines":return J0(N.inlines);case"blocks":return N2(N.blocks)}}function C0(N){switch(N.type){case"blockquote":case"listItem":return N.children;case"list":return N.items;default:return null}}function C1(N,F){if(F.length===0)return null;switch(N.type){case"blockquote":return d0(F);case"list":return H0(N,F);case"listItem":return Z1(N,F);default:return null}}function U4(N,F){return oF(N,R2(F))}function oF(N,F){switch(N.type){case"blockquote":{let A=N.children.map((D,E)=>oF(D,Y1(F,E))),M=N2(A);return{children:A,id:y0("blockquote",F,M),plainText:M,type:"blockquote"}}case"code":return{id:y0("code",F,`${N.language??""}:${N.source}`),language:N.language,meta:N.meta,plainText:N.source,source:N.source,type:"code"};case"directive":return{attributes:N.attributes,body:N.body,id:y0("directive",F,`${N.name}{${N.attributes}}:${N.body}`),name:N.name,plainText:N.body,type:"directive"};case"heading":{let A=N.children.map((D,E)=>nF(D,iF(F,E))),M=J0(A);return{children:A,depth:N.depth,id:y0("heading",F,`${N.depth}:${M}`),plainText:M,type:"heading"}}case"list":{let A=N.items.map((D,E)=>oF(D,Y1(F,E))),M=A.map((D)=>D.plainText).join(`
8
+ `);return{id:y0("list",F,`${String(N.ordered)}:${M}`),items:A,ordered:N.ordered,plainText:M,spread:N.spread,start:N.start,type:"list"}}case"listItem":{let A=N.children.map((D,E)=>oF(D,Y1(F,E))),M=N2(A);return{checked:N.checked,children:A,id:y0("listItem",F,M),plainText:M,spread:N.spread,type:"listItem"}}case"paragraph":{let A=N.children.map((D,E)=>nF(D,iF(F,E))),M=J0(A);return{children:A,id:y0("paragraph",F,M),plainText:M,type:"paragraph"}}case"table":{let A=N.rows.map((D,E)=>UY(D,f2(F,E))),M=A.map((D)=>D.cells.map((E)=>E.plainText).join(" | ")).join(`
9
+ `);return{align:N.align,id:y0("table",F,M),plainText:M,rows:A,type:"table"}}case"divider":return{id:y0("divider",F,"divider"),plainText:"",type:"divider"};case"raw":return{id:y0("raw",F,N.source),originalType:N.originalType,plainText:N.source,source:N.source,type:"raw"}}}function UY(N,F){return{cells:N.cells.map((A,M)=>{let D=A.children.map(($,y)=>nF($,AM(F2(F,M),y))),E=J0(D);return{children:D,id:y0("tableCell",F2(F,M),E),plainText:E}}),id:y0("tableRow",F,String(N.cells.length))}}function nF(N,F){switch(N.type){case"lineBreak":return{id:y0("lineBreak",F,"lineBreak"),type:"lineBreak"};case"image":return{alt:N.alt,id:y0("image",F,`${N.url}:${N.width??""}:${N.alt??""}`),title:N.title,type:"image",url:N.url,width:N.width};case"mention":return{id:y0("mention",F,`${N.userId}:${N.name}`),name:N.name,type:"mention",userId:N.userId};case"code":return{code:N.code,id:y0("code",F,N.code),type:"code"};case"link":{let A=N.children.map((D,E)=>nF(D,iF(F,E))),M=J0(A);return{children:A,id:y0("link",F,`${N.url}:${M}`),title:N.title,type:"link",url:N.url}}case"text":return{id:y0("text",F,`${N.text}:${N.marks.join(",")}`),marks:N.marks,text:N.text,type:"text"};case"raw":return{id:y0("raw",F,N.source),originalType:N.originalType,source:N.source,type:"raw"}}}function VM(N){return u2(N,(F,{recurse:A})=>{switch(F.type){case"blockquote":case"list":case"listItem":return A();case"heading":case"paragraph":return k0(F,K4(F.children));case"table":return a0(F,F.rows.map((M)=>({...M,cells:M.cells.map((D)=>({...D,children:K4(D.children)}))})));default:return F}})}function K4(N){let F=null,A=()=>F??=[...N];for(let M=N.length-1;M>=0;M-=1){let D=N[M];if(D.type==="text"){let E=D.text.replace(/[ \t]+$/u,"");if(E.length===D.text.length)return F??N;let $=A();if(E.length===0){$.splice(M,1);continue}return $[M]={...D,text:E},$}if(D.type==="link"){let E=K4(D.children);if(E===D.children)return F??N;let $=A();if(E.length===0){$.splice(M,1);continue}return $[M]={...D,children:E},$}return F??N}return F??N}function y0(N,F,A){let M=2166136261;for(let D of`${N}:${F}:${A}`)M^=D.charCodeAt(0),M=Math.imul(M,16777619);return`${N}-${(M>>>0).toString(36)}`}var G4="text";function H4(N){return N==="text"||N==="code"||N==="tableCell"}function _4(N){return N===G4?void 0:N}function UM(N){switch(N){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function KM(N){return"threadId"in N}function N6(N){let F=[];return J4(N,{enterBlock(A){switch(A.type){case"heading":case"paragraph":F.push({containerKind:"text",containerOrdinal:F.length,id:A.id,text:J0(A.children)});break;case"code":F.push({containerKind:"code",containerOrdinal:F.length,id:A.id,text:A.source});break}},enterTableCell(A){F.push({containerKind:"tableCell",containerOrdinal:F.length,id:A.id,text:J0(A.children)})}}),F}function B4(N,F,A){return{prefix:N.slice(Math.max(0,F-qM),F),suffix:N.slice(A,Math.min(N.length,A+qM))}}function BN(N,F,A){let M=n0(F,0,N.text.length),D=n0(A,M,N.text.length),{prefix:E,suffix:$}=B4(N.text,M,D);return{kind:_4(N.containerKind),prefix:E||void 0,suffix:$||void 0}}function PN(N,F,A){let M=n0(F,0,N.text.length),D=n0(A,M,N.text.length);return N.text.slice(M,D)}function X1(N,F){if(F.length===0)return[];let A=[],M=0;while(M<=N.length){let D=N.indexOf(F,M);if(D===-1)break;A.push(D),M=D+Math.max(1,F.length)}return A}function m2(N,F,A){if(F.length===0||A.length===0)return[];let M=[];for(let D of X1(N,F)){let E=D+F.length,$=N.indexOf(A,E);if($!==-1)M.push({startOffset:E,endOffset:$})}return M}function P4(N,F,A){if(!F)return!1;return N.slice(Math.max(0,A-F.length),A)===F}function W4(N,F,A){if(!F)return!1;return N.slice(A,A+F.length)===F}var qM=24;function n0(N,F,A){return Math.min(Math.max(N,F),A)}var zM=48,GM=64,KY=32;function WN(N,F){let A=N.anchor.kind??G4,M=N6(F).filter(($)=>$.containerKind===A),D=zY(N,M);if(D.length>0)return HM(N,D,null);let E=GY(N,M);if(E.length>0)return HM(N,E,"repaired");return{match:null,repair:null,status:"stale"}}function zY(N,F){let A=[],M=N.quote;if(M.length===0)return A;for(let D of F)for(let E of X1(D.text,M))A.push({container:D,endOffset:E+M.length,score:BY(N,D,E),startOffset:E});return A.sort((D,E)=>E.score-D.score),A}function GY(N,F){let A=[];for(let M of F)A.push(...HY(N,M));return A.sort((M,D)=>D.score-M.score),A}function HY(N,F){let A=[],M=N.quote.length,D=F.text,E=N.anchor.prefix??"",$=N.anchor.suffix??"";if(E.length>0&&$.length>0){for(let y of m2(D,E,$))A.push({container:F,endOffset:y.endOffset,score:O4(N,F,y.startOffset,y.endOffset,M),startOffset:y.startOffset});return A}if(E.length>0){for(let y of X1(D,E)){let Z=y+E.length,Y=n0(Z+M,Z,D.length);A.push({container:F,endOffset:Y,score:O4(N,F,Z,Y,M),startOffset:Z})}return A}if($.length>0)for(let y of X1(D,$)){let Z=y,Y=n0(Z-M,0,Z);A.push({container:F,endOffset:Z,score:O4(N,F,Y,Z,M),startOffset:Y})}return A}function HM(N,F,A){let[M,D]=F;if(!M)return{match:null,repair:null,status:"stale"};if(D&&M.score===D.score)return{match:null,repair:null,status:"ambiguous"};let E=BN(M.container,M.startOffset,M.endOffset),$=PN(M.container,M.startOffset,M.endOffset),y=A??($===N.quote&&(E.prefix??"")===(N.anchor.prefix??"")&&(E.suffix??"")===(N.anchor.suffix??"")?"matched":"repaired");return{match:_Y(M.container,M.startOffset,M.endOffset),repair:{anchor:E,quote:$},status:y}}function _Y(N,F,A){return{containerId:N.id,containerKind:N.containerKind,containerOrdinal:N.containerOrdinal,endOffset:A,startOffset:F}}function BY(N,F,A){let M=0;if(P4(F.text,N.anchor.prefix,A))M+=zM;if(W4(F.text,N.anchor.suffix,A+N.quote.length))M+=zM;return M}function O4(N,F,A,M,D){let E=0;if(P4(F.text,N.anchor.prefix,A))E+=GM;if(W4(F.text,N.anchor.suffix,M))E+=GM;if(E+=Math.max(0,KY-Math.abs(D-(M-A))),N.quote.length>0){let $=F.text.slice(A,M);if($.length>0)E+=PY(N.quote,$),E+=WY(N.quote,$)}return E}function PY(N,F){let A=0;while(A<N.length&&A<F.length&&N[A]===F[A])A+=1;return A}function WY(N,F){let A=0;while(A<N.length&&A<F.length&&N[N.length-1-A]===F[F.length-1-A])A+=1;return A}function w4(N){if(!N||typeof N!=="object"||Array.isArray(N))return null;let F=N,A=wY(F.anchor),M=typeof F.quote==="string"?F.quote:null,D=Array.isArray(F.comments)?F.comments.flatMap((E)=>{let $=OY(E);return $?[$]:[]}):[];if(!A||!M||D.length===0)return null;return{id:"",quote:M,anchor:A,comments:D,resolvedAt:typeof F.resolvedAt==="string"?F.resolvedAt:void 0}}function OY(N){if(!N||typeof N!=="object"||Array.isArray(N))return null;let F=N;if(typeof F.body!=="string"||typeof F.updatedAt!=="string")return null;return{body:F.body,updatedAt:F.updatedAt}}function wY(N){if(!N||typeof N!=="object"||Array.isArray(N))return null;let{kind:F,prefix:A,suffix:M}=N;if("kind"in N&&!H4(F)||"prefix"in N&&typeof A!=="string"||"suffix"in N&&typeof M!=="string")return null;return{kind:H4(F)?_4(F):void 0,prefix:typeof A==="string"?A:void 0,suffix:typeof M==="string"?M:void 0}}function L4(N){let F=N.createdAt??new Date().toISOString(),A=_M({body:N.body,updatedAt:F});return{id:LY(N.anchor,N.quote,N.body,F),comments:[A],quote:N.quote,anchor:N.anchor}}function T4(N,F){let A=_M(F);return{...N,comments:[...N.comments,A]}}function C4(N,F,A,M=new Date().toISOString()){let D=A.trim();if(D.length===0)return N;let E=!1,$=N.comments.map((y,Z)=>{if(Z!==F||y.body===D)return y;return E=!0,{...y,body:D,updatedAt:M}});if(!E)return N;return{...N,comments:$}}function j4(N,F){let A=N.comments.filter((M,D)=>D!==F);if(A.length===N.comments.length)return N;if(A.length===0)return null;return{...N,comments:A}}function R4(N,F,A=new Date().toISOString()){if(j1(N)===F)return N;return{...N,resolvedAt:F?A:void 0}}function j1(N){return N.resolvedAt!=null}function b4(N){if(N.comments.length===0)return null;return N.comments.reduce((F,A)=>A.updatedAt>F?A.updatedAt:F,N.comments[0].updatedAt)}function LY(N,F,A,M,D="comments"){return y0("commentThread",D,`${N.kind??""}:${N.prefix??""}:${N.suffix??""}:${F}:${A}:${M}`)}function _M(N){let F=N.updatedAt??new Date().toISOString();return{body:N.body,updatedAt:F}}function M2(N,F){let A=N.regionOrderIndex.get(F);if(A===void 0||A===0)return null;return N.regions[A-1]??null}function ON(N,F){let A=N.regionOrderIndex.get(F);if(A===void 0)return null;return N.regions[A+1]??null}function Q1(N){return N.regionIds.length===0&&!R1(N)}function R1(N){return N.type==="blockquote"||N.type==="list"||N.type==="listItem"}function f4(N,F){return BM(N.blocks,F,-1)}function wN(N,F){return BM(N.blocks,F,1)}function u4(N,F){return N.roots[F]?.regions[0]??null}function BM(N,F,A){let M=N.findIndex((D)=>D.id===F);if(M===-1)return null;for(let D=M+A;D>=0&&D<N.length;D+=A){let E=N[D];if(!R1(E))return E}return null}function D2(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function PM(N,F,A){return LN(N.preparedText,F,A,256)}function WM(N,F,A){return LN(N.measuredLines,F,A,512)}function OM(N,F,A){return LN(N.lineBoundaries,F,A,1024)}function wM(N,F,A){return LN(N.measuredContainerHeights,F,A,1024)}function LM(N,F){let A=N.graphemeWidths.get(F);if(A)return A;let M=new Map;return LN(N.graphemeWidths,F,M,64),M}function TM(N,F,A){return N.viewportPlans.get(F)?.get(A)??null}function CM(N,F,A,M){let D=N.viewportPlans.get(F)??new Map;return D.set(A,M),N.viewportPlans.set(F,D),M}function LN(N,F,A,M){if(N.has(F))N.delete(F);if(N.set(F,A),N.size>M){let D=N.keys().next().value;if(D!==void 0)N.delete(D)}return A}var F6={blockGap:16,charWidth:9,indentWidth:12,lineHeight:24,paddingX:16,paddingY:12};function A6(N){return{...F6,...N}}function M6(N,F,A,M,D){if(jM(N,A,M,"list"))return 6;if(jM(N,A,M,"blockquote"))return 10;if(A===M)return 4;return D+TY(F.get(A))}function TY(N){if(N?.type!=="heading")return 0;if(N.depth===1)return 24;return N.depth===2?16:0}function jM(N,F,A,M){let D=RM(N,F,M),E=RM(N,A,M);for(let $ of D)if(E.has($))return!0;return!1}function RM(N,F,A){let M=new Set,D=N.get(F)??null;while(D){if(D.type===A)M.add(D.id);D=D.parentBlockId?N.get(D.parentBlockId)??null:null}return M}var bM=18,fM=14;var uM=22;function k2(N,F,A){let M=N.get(A)??null;while(M){if(M.type==="listItem")return F.get(M.id)?.kind==="task"?22:18;M=M.parentBlockId?N.get(M.parentBlockId)??null:null}return 0}var vM=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","BN","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],v4=[[697,698,"ON"],[706,719,"ON"],[722,735,"ON"],[741,749,"ON"],[751,767,"ON"],[768,879,"NSM"],[884,885,"ON"],[894,894,"ON"],[900,901,"ON"],[903,903,"ON"],[1014,1014,"ON"],[1155,1161,"NSM"],[1418,1418,"ON"],[1421,1422,"ON"],[1423,1423,"ET"],[1424,1424,"R"],[1425,1469,"NSM"],[1470,1470,"R"],[1471,1471,"NSM"],[1472,1472,"R"],[1473,1474,"NSM"],[1475,1475,"R"],[1476,1477,"NSM"],[1478,1478,"R"],[1479,1479,"NSM"],[1480,1535,"R"],[1536,1541,"AN"],[1542,1543,"ON"],[1544,1544,"AL"],[1545,1546,"ET"],[1547,1547,"AL"],[1548,1548,"CS"],[1549,1549,"AL"],[1550,1551,"ON"],[1552,1562,"NSM"],[1563,1610,"AL"],[1611,1631,"NSM"],[1632,1641,"AN"],[1642,1642,"ET"],[1643,1644,"AN"],[1645,1647,"AL"],[1648,1648,"NSM"],[1649,1749,"AL"],[1750,1756,"NSM"],[1757,1757,"AN"],[1758,1758,"ON"],[1759,1764,"NSM"],[1765,1766,"AL"],[1767,1768,"NSM"],[1769,1769,"ON"],[1770,1773,"NSM"],[1774,1775,"AL"],[1776,1785,"EN"],[1786,1808,"AL"],[1809,1809,"NSM"],[1810,1839,"AL"],[1840,1866,"NSM"],[1867,1957,"AL"],[1958,1968,"NSM"],[1969,1983,"AL"],[1984,2026,"R"],[2027,2035,"NSM"],[2036,2037,"R"],[2038,2041,"ON"],[2042,2044,"R"],[2045,2045,"NSM"],[2046,2069,"R"],[2070,2073,"NSM"],[2074,2074,"R"],[2075,2083,"NSM"],[2084,2084,"R"],[2085,2087,"NSM"],[2088,2088,"R"],[2089,2093,"NSM"],[2094,2136,"R"],[2137,2139,"NSM"],[2140,2143,"R"],[2144,2191,"AL"],[2192,2193,"AN"],[2194,2198,"AL"],[2199,2207,"NSM"],[2208,2249,"AL"],[2250,2273,"NSM"],[2274,2274,"AN"],[2275,2306,"NSM"],[2362,2362,"NSM"],[2364,2364,"NSM"],[2369,2376,"NSM"],[2381,2381,"NSM"],[2385,2391,"NSM"],[2402,2403,"NSM"],[2433,2433,"NSM"],[2492,2492,"NSM"],[2497,2500,"NSM"],[2509,2509,"NSM"],[2530,2531,"NSM"],[2546,2547,"ET"],[2555,2555,"ET"],[2558,2558,"NSM"],[2561,2562,"NSM"],[2620,2620,"NSM"],[2625,2626,"NSM"],[2631,2632,"NSM"],[2635,2637,"NSM"],[2641,2641,"NSM"],[2672,2673,"NSM"],[2677,2677,"NSM"],[2689,2690,"NSM"],[2748,2748,"NSM"],[2753,2757,"NSM"],[2759,2760,"NSM"],[2765,2765,"NSM"],[2786,2787,"NSM"],[2801,2801,"ET"],[2810,2815,"NSM"],[2817,2817,"NSM"],[2876,2876,"NSM"],[2879,2879,"NSM"],[2881,2884,"NSM"],[2893,2893,"NSM"],[2901,2902,"NSM"],[2914,2915,"NSM"],[2946,2946,"NSM"],[3008,3008,"NSM"],[3021,3021,"NSM"],[3059,3064,"ON"],[3065,3065,"ET"],[3066,3066,"ON"],[3072,3072,"NSM"],[3076,3076,"NSM"],[3132,3132,"NSM"],[3134,3136,"NSM"],[3142,3144,"NSM"],[3146,3149,"NSM"],[3157,3158,"NSM"],[3170,3171,"NSM"],[3192,3198,"ON"],[3201,3201,"NSM"],[3260,3260,"NSM"],[3276,3277,"NSM"],[3298,3299,"NSM"],[3328,3329,"NSM"],[3387,3388,"NSM"],[3393,3396,"NSM"],[3405,3405,"NSM"],[3426,3427,"NSM"],[3457,3457,"NSM"],[3530,3530,"NSM"],[3538,3540,"NSM"],[3542,3542,"NSM"],[3633,3633,"NSM"],[3636,3642,"NSM"],[3647,3647,"ET"],[3655,3662,"NSM"],[3761,3761,"NSM"],[3764,3772,"NSM"],[3784,3790,"NSM"],[3864,3865,"NSM"],[3893,3893,"NSM"],[3895,3895,"NSM"],[3897,3897,"NSM"],[3898,3901,"ON"],[3953,3966,"NSM"],[3968,3972,"NSM"],[3974,3975,"NSM"],[3981,3991,"NSM"],[3993,4028,"NSM"],[4038,4038,"NSM"],[4141,4144,"NSM"],[4146,4151,"NSM"],[4153,4154,"NSM"],[4157,4158,"NSM"],[4184,4185,"NSM"],[4190,4192,"NSM"],[4209,4212,"NSM"],[4226,4226,"NSM"],[4229,4230,"NSM"],[4237,4237,"NSM"],[4253,4253,"NSM"],[4957,4959,"NSM"],[5008,5017,"ON"],[5120,5120,"ON"],[5760,5760,"WS"],[5787,5788,"ON"],[5906,5908,"NSM"],[5938,5939,"NSM"],[5970,5971,"NSM"],[6002,6003,"NSM"],[6068,6069,"NSM"],[6071,6077,"NSM"],[6086,6086,"NSM"],[6089,6099,"NSM"],[6107,6107,"ET"],[6109,6109,"NSM"],[6128,6137,"ON"],[6144,6154,"ON"],[6155,6157,"NSM"],[6158,6158,"BN"],[6159,6159,"NSM"],[6277,6278,"NSM"],[6313,6313,"NSM"],[6432,6434,"NSM"],[6439,6440,"NSM"],[6450,6450,"NSM"],[6457,6459,"NSM"],[6464,6464,"ON"],[6468,6469,"ON"],[6622,6655,"ON"],[6679,6680,"NSM"],[6683,6683,"NSM"],[6742,6742,"NSM"],[6744,6750,"NSM"],[6752,6752,"NSM"],[6754,6754,"NSM"],[6757,6764,"NSM"],[6771,6780,"NSM"],[6783,6783,"NSM"],[6832,6877,"NSM"],[6880,6891,"NSM"],[6912,6915,"NSM"],[6964,6964,"NSM"],[6966,6970,"NSM"],[6972,6972,"NSM"],[6978,6978,"NSM"],[7019,7027,"NSM"],[7040,7041,"NSM"],[7074,7077,"NSM"],[7080,7081,"NSM"],[7083,7085,"NSM"],[7142,7142,"NSM"],[7144,7145,"NSM"],[7149,7149,"NSM"],[7151,7153,"NSM"],[7212,7219,"NSM"],[7222,7223,"NSM"],[7376,7378,"NSM"],[7380,7392,"NSM"],[7394,7400,"NSM"],[7405,7405,"NSM"],[7412,7412,"NSM"],[7416,7417,"NSM"],[7616,7679,"NSM"],[8125,8125,"ON"],[8127,8129,"ON"],[8141,8143,"ON"],[8157,8159,"ON"],[8173,8175,"ON"],[8189,8190,"ON"],[8192,8202,"WS"],[8203,8205,"BN"],[8207,8207,"R"],[8208,8231,"ON"],[8232,8232,"WS"],[8233,8233,"B"],[8234,8238,"BN"],[8239,8239,"CS"],[8240,8244,"ET"],[8245,8259,"ON"],[8260,8260,"CS"],[8261,8286,"ON"],[8287,8287,"WS"],[8288,8303,"BN"],[8304,8304,"EN"],[8308,8313,"EN"],[8314,8315,"ES"],[8316,8318,"ON"],[8320,8329,"EN"],[8330,8331,"ES"],[8332,8334,"ON"],[8352,8399,"ET"],[8400,8432,"NSM"],[8448,8449,"ON"],[8451,8454,"ON"],[8456,8457,"ON"],[8468,8468,"ON"],[8470,8472,"ON"],[8478,8483,"ON"],[8485,8485,"ON"],[8487,8487,"ON"],[8489,8489,"ON"],[8494,8494,"ET"],[8506,8507,"ON"],[8512,8516,"ON"],[8522,8525,"ON"],[8528,8543,"ON"],[8585,8587,"ON"],[8592,8721,"ON"],[8722,8722,"ES"],[8723,8723,"ET"],[8724,9013,"ON"],[9083,9108,"ON"],[9110,9257,"ON"],[9280,9290,"ON"],[9312,9351,"ON"],[9352,9371,"EN"],[9450,9899,"ON"],[9901,10239,"ON"],[10496,11123,"ON"],[11126,11263,"ON"],[11493,11498,"ON"],[11503,11505,"NSM"],[11513,11519,"ON"],[11647,11647,"NSM"],[11744,11775,"NSM"],[11776,11869,"ON"],[11904,11929,"ON"],[11931,12019,"ON"],[12032,12245,"ON"],[12272,12287,"ON"],[12288,12288,"WS"],[12289,12292,"ON"],[12296,12320,"ON"],[12330,12333,"NSM"],[12336,12336,"ON"],[12342,12343,"ON"],[12349,12351,"ON"],[12441,12442,"NSM"],[12443,12444,"ON"],[12448,12448,"ON"],[12539,12539,"ON"],[12736,12773,"ON"],[12783,12783,"ON"],[12829,12830,"ON"],[12880,12895,"ON"],[12924,12926,"ON"],[12977,12991,"ON"],[13004,13007,"ON"],[13175,13178,"ON"],[13278,13279,"ON"],[13311,13311,"ON"],[19904,19967,"ON"],[42128,42182,"ON"],[42509,42511,"ON"],[42607,42610,"NSM"],[42611,42611,"ON"],[42612,42621,"NSM"],[42622,42623,"ON"],[42654,42655,"NSM"],[42736,42737,"NSM"],[42752,42785,"ON"],[42888,42888,"ON"],[43010,43010,"NSM"],[43014,43014,"NSM"],[43019,43019,"NSM"],[43045,43046,"NSM"],[43048,43051,"ON"],[43052,43052,"NSM"],[43064,43065,"ET"],[43124,43127,"ON"],[43204,43205,"NSM"],[43232,43249,"NSM"],[43263,43263,"NSM"],[43302,43309,"NSM"],[43335,43345,"NSM"],[43392,43394,"NSM"],[43443,43443,"NSM"],[43446,43449,"NSM"],[43452,43453,"NSM"],[43493,43493,"NSM"],[43561,43566,"NSM"],[43569,43570,"NSM"],[43573,43574,"NSM"],[43587,43587,"NSM"],[43596,43596,"NSM"],[43644,43644,"NSM"],[43696,43696,"NSM"],[43698,43700,"NSM"],[43703,43704,"NSM"],[43710,43711,"NSM"],[43713,43713,"NSM"],[43756,43757,"NSM"],[43766,43766,"NSM"],[43882,43883,"ON"],[44005,44005,"NSM"],[44008,44008,"NSM"],[44013,44013,"NSM"],[64285,64285,"R"],[64286,64286,"NSM"],[64287,64296,"R"],[64297,64297,"ES"],[64298,64335,"R"],[64336,64450,"AL"],[64451,64466,"ON"],[64467,64829,"AL"],[64830,64847,"ON"],[64848,64911,"AL"],[64912,64913,"ON"],[64914,64967,"AL"],[64968,64975,"ON"],[64976,65007,"BN"],[65008,65020,"AL"],[65021,65023,"ON"],[65024,65039,"NSM"],[65040,65049,"ON"],[65056,65071,"NSM"],[65072,65103,"ON"],[65104,65104,"CS"],[65105,65105,"ON"],[65106,65106,"CS"],[65108,65108,"ON"],[65109,65109,"CS"],[65110,65118,"ON"],[65119,65119,"ET"],[65120,65121,"ON"],[65122,65123,"ES"],[65124,65126,"ON"],[65128,65128,"ON"],[65129,65130,"ET"],[65131,65131,"ON"],[65136,65278,"AL"],[65279,65279,"BN"],[65281,65282,"ON"],[65283,65285,"ET"],[65286,65290,"ON"],[65291,65291,"ES"],[65292,65292,"CS"],[65293,65293,"ES"],[65294,65295,"CS"],[65296,65305,"EN"],[65306,65306,"CS"],[65307,65312,"ON"],[65339,65344,"ON"],[65371,65381,"ON"],[65504,65505,"ET"],[65506,65508,"ON"],[65509,65510,"ET"],[65512,65518,"ON"],[65520,65528,"BN"],[65529,65533,"ON"],[65534,65535,"BN"],[65793,65793,"ON"],[65856,65932,"ON"],[65936,65948,"ON"],[65952,65952,"ON"],[66045,66045,"NSM"],[66272,66272,"NSM"],[66273,66299,"EN"],[66422,66426,"NSM"],[67584,67870,"R"],[67871,67871,"ON"],[67872,68096,"R"],[68097,68099,"NSM"],[68100,68100,"R"],[68101,68102,"NSM"],[68103,68107,"R"],[68108,68111,"NSM"],[68112,68151,"R"],[68152,68154,"NSM"],[68155,68158,"R"],[68159,68159,"NSM"],[68160,68324,"R"],[68325,68326,"NSM"],[68327,68408,"R"],[68409,68415,"ON"],[68416,68863,"R"],[68864,68899,"AL"],[68900,68903,"NSM"],[68904,68911,"AL"],[68912,68921,"AN"],[68922,68927,"AL"],[68928,68937,"AN"],[68938,68968,"R"],[68969,68973,"NSM"],[68974,68974,"ON"],[68975,69215,"R"],[69216,69246,"AN"],[69247,69290,"R"],[69291,69292,"NSM"],[69293,69311,"R"],[69312,69327,"AL"],[69328,69336,"ON"],[69337,69369,"AL"],[69370,69375,"NSM"],[69376,69423,"R"],[69424,69445,"AL"],[69446,69456,"NSM"],[69457,69487,"AL"],[69488,69505,"R"],[69506,69509,"NSM"],[69510,69631,"R"],[69633,69633,"NSM"],[69688,69702,"NSM"],[69714,69733,"ON"],[69744,69744,"NSM"],[69747,69748,"NSM"],[69759,69761,"NSM"],[69811,69814,"NSM"],[69817,69818,"NSM"],[69826,69826,"NSM"],[69888,69890,"NSM"],[69927,69931,"NSM"],[69933,69940,"NSM"],[70003,70003,"NSM"],[70016,70017,"NSM"],[70070,70078,"NSM"],[70089,70092,"NSM"],[70095,70095,"NSM"],[70191,70193,"NSM"],[70196,70196,"NSM"],[70198,70199,"NSM"],[70206,70206,"NSM"],[70209,70209,"NSM"],[70367,70367,"NSM"],[70371,70378,"NSM"],[70400,70401,"NSM"],[70459,70460,"NSM"],[70464,70464,"NSM"],[70502,70508,"NSM"],[70512,70516,"NSM"],[70587,70592,"NSM"],[70606,70606,"NSM"],[70608,70608,"NSM"],[70610,70610,"NSM"],[70625,70626,"NSM"],[70712,70719,"NSM"],[70722,70724,"NSM"],[70726,70726,"NSM"],[70750,70750,"NSM"],[70835,70840,"NSM"],[70842,70842,"NSM"],[70847,70848,"NSM"],[70850,70851,"NSM"],[71090,71093,"NSM"],[71100,71101,"NSM"],[71103,71104,"NSM"],[71132,71133,"NSM"],[71219,71226,"NSM"],[71229,71229,"NSM"],[71231,71232,"NSM"],[71264,71276,"ON"],[71339,71339,"NSM"],[71341,71341,"NSM"],[71344,71349,"NSM"],[71351,71351,"NSM"],[71453,71453,"NSM"],[71455,71455,"NSM"],[71458,71461,"NSM"],[71463,71467,"NSM"],[71727,71735,"NSM"],[71737,71738,"NSM"],[71995,71996,"NSM"],[71998,71998,"NSM"],[72003,72003,"NSM"],[72148,72151,"NSM"],[72154,72155,"NSM"],[72160,72160,"NSM"],[72193,72198,"NSM"],[72201,72202,"NSM"],[72243,72248,"NSM"],[72251,72254,"NSM"],[72263,72263,"NSM"],[72273,72278,"NSM"],[72281,72283,"NSM"],[72330,72342,"NSM"],[72344,72345,"NSM"],[72544,72544,"NSM"],[72546,72548,"NSM"],[72550,72550,"NSM"],[72752,72758,"NSM"],[72760,72765,"NSM"],[72850,72871,"NSM"],[72874,72880,"NSM"],[72882,72883,"NSM"],[72885,72886,"NSM"],[73009,73014,"NSM"],[73018,73018,"NSM"],[73020,73021,"NSM"],[73023,73029,"NSM"],[73031,73031,"NSM"],[73104,73105,"NSM"],[73109,73109,"NSM"],[73111,73111,"NSM"],[73459,73460,"NSM"],[73472,73473,"NSM"],[73526,73530,"NSM"],[73536,73536,"NSM"],[73538,73538,"NSM"],[73562,73562,"NSM"],[73685,73692,"ON"],[73693,73696,"ET"],[73697,73713,"ON"],[78912,78912,"NSM"],[78919,78933,"NSM"],[90398,90409,"NSM"],[90413,90415,"NSM"],[92912,92916,"NSM"],[92976,92982,"NSM"],[94031,94031,"NSM"],[94095,94098,"NSM"],[94178,94178,"ON"],[94180,94180,"NSM"],[113821,113822,"NSM"],[113824,113827,"BN"],[117760,117973,"ON"],[118000,118009,"EN"],[118010,118012,"ON"],[118016,118451,"ON"],[118458,118480,"ON"],[118496,118512,"ON"],[118528,118573,"NSM"],[118576,118598,"NSM"],[119143,119145,"NSM"],[119155,119162,"BN"],[119163,119170,"NSM"],[119173,119179,"NSM"],[119210,119213,"NSM"],[119273,119274,"ON"],[119296,119361,"ON"],[119362,119364,"NSM"],[119365,119365,"ON"],[119552,119638,"ON"],[120513,120513,"ON"],[120539,120539,"ON"],[120571,120571,"ON"],[120597,120597,"ON"],[120629,120629,"ON"],[120655,120655,"ON"],[120687,120687,"ON"],[120713,120713,"ON"],[120745,120745,"ON"],[120771,120771,"ON"],[120782,120831,"EN"],[121344,121398,"NSM"],[121403,121452,"NSM"],[121461,121461,"NSM"],[121476,121476,"NSM"],[121499,121503,"NSM"],[121505,121519,"NSM"],[122880,122886,"NSM"],[122888,122904,"NSM"],[122907,122913,"NSM"],[122915,122916,"NSM"],[122918,122922,"NSM"],[123023,123023,"NSM"],[123184,123190,"NSM"],[123566,123566,"NSM"],[123628,123631,"NSM"],[123647,123647,"ET"],[124140,124143,"NSM"],[124398,124399,"NSM"],[124643,124643,"NSM"],[124646,124646,"NSM"],[124654,124655,"NSM"],[124661,124661,"NSM"],[124928,125135,"R"],[125136,125142,"NSM"],[125143,125251,"R"],[125252,125258,"NSM"],[125259,126063,"R"],[126064,126143,"AL"],[126144,126207,"R"],[126208,126287,"AL"],[126288,126463,"R"],[126464,126703,"AL"],[126704,126705,"ON"],[126706,126719,"AL"],[126720,126975,"R"],[126976,127019,"ON"],[127024,127123,"ON"],[127136,127150,"ON"],[127153,127167,"ON"],[127169,127183,"ON"],[127185,127221,"ON"],[127232,127242,"EN"],[127243,127247,"ON"],[127279,127279,"ON"],[127338,127343,"ON"],[127405,127405,"ON"],[127584,127589,"ON"],[127744,128728,"ON"],[128732,128748,"ON"],[128752,128764,"ON"],[128768,128985,"ON"],[128992,129003,"ON"],[129008,129008,"ON"],[129024,129035,"ON"],[129040,129095,"ON"],[129104,129113,"ON"],[129120,129159,"ON"],[129168,129197,"ON"],[129200,129211,"ON"],[129216,129217,"ON"],[129232,129240,"ON"],[129280,129623,"ON"],[129632,129645,"ON"],[129648,129660,"ON"],[129664,129674,"ON"],[129678,129734,"ON"],[129736,129736,"ON"],[129741,129756,"ON"],[129759,129770,"ON"],[129775,129784,"ON"],[129792,129938,"ON"],[129940,130031,"ON"],[130032,130041,"EN"],[130042,130042,"ON"],[131070,131071,"BN"],[196606,196607,"BN"],[262142,262143,"BN"],[327678,327679,"BN"],[393214,393215,"BN"],[458750,458751,"BN"],[524286,524287,"BN"],[589822,589823,"BN"],[655358,655359,"BN"],[720894,720895,"BN"],[786430,786431,"BN"],[851966,851967,"BN"],[917502,917759,"BN"],[917760,917999,"NSM"],[918000,921599,"BN"],[983038,983039,"BN"],[1048574,1048575,"BN"],[1114110,1114111,"BN"]];function CY(N){if(N<=255)return vM[N];let F=0,A=v4.length-1;while(F<=A){let M=F+A>>1,D=v4[M];if(N<D[0]){A=M-1;continue}if(N>D[1]){F=M+1;continue}return D[2]}return"L"}function jY(N){let F=N.length;if(F===0)return null;let A=Array(F),M=!1;for(let Y=0;Y<F;){let X=N.charCodeAt(Y),Q=X,S=1;if(X>=55296&&X<=56319&&Y+1<F){let V=N.charCodeAt(Y+1);if(V>=56320&&V<=57343)Q=(X-55296<<10)+(V-56320)+65536,S=2}let J=CY(Q);if(J==="R"||J==="AL"||J==="AN")M=!0;for(let V=0;V<S;V++)A[Y+V]=J;Y+=S}if(!M)return null;let D=0;for(let Y=0;Y<F;Y++){let X=A[Y];if(X==="L"){D=0;break}if(X==="R"||X==="AL"){D=1;break}}let E=new Int8Array(F);for(let Y=0;Y<F;Y++)E[Y]=D;let $=D&1?"R":"L",y=$,Z=y;for(let Y=0;Y<F;Y++)if(A[Y]==="NSM")A[Y]=Z;else Z=A[Y];Z=y;for(let Y=0;Y<F;Y++){let X=A[Y];if(X==="EN")A[Y]=Z==="AL"?"AN":"EN";else if(X==="R"||X==="L"||X==="AL")Z=X}for(let Y=0;Y<F;Y++)if(A[Y]==="AL")A[Y]="R";for(let Y=1;Y<F-1;Y++){if(A[Y]==="ES"&&A[Y-1]==="EN"&&A[Y+1]==="EN")A[Y]="EN";if(A[Y]==="CS"&&(A[Y-1]==="EN"||A[Y-1]==="AN")&&A[Y+1]===A[Y-1])A[Y]=A[Y-1]}for(let Y=0;Y<F;Y++){if(A[Y]!=="EN")continue;let X;for(X=Y-1;X>=0&&A[X]==="ET";X--)A[X]="EN";for(X=Y+1;X<F&&A[X]==="ET";X++)A[X]="EN"}for(let Y=0;Y<F;Y++){let X=A[Y];if(X==="WS"||X==="ES"||X==="ET"||X==="CS")A[Y]="ON"}Z=y;for(let Y=0;Y<F;Y++){let X=A[Y];if(X==="EN")A[Y]=Z==="L"?"L":"EN";else if(X==="R"||X==="L")Z=X}for(let Y=0;Y<F;Y++){if(A[Y]!=="ON")continue;let X=Y+1;while(X<F&&A[X]==="ON")X++;let Q=Y>0?A[Y-1]:y,S=X<F?A[X]:y,J=Q!=="L"?"R":"L";if(J===(S!=="L"?"R":"L"))for(let K=Y;K<X;K++)A[K]=J;Y=X-1}for(let Y=0;Y<F;Y++)if(A[Y]==="ON")A[Y]=$;for(let Y=0;Y<F;Y++){let X=A[Y];if((E[Y]&1)===0){if(X==="R")E[Y]++;else if(X==="AN"||X==="EN")E[Y]+=2}else if(X==="L"||X==="AN"||X==="EN")E[Y]++}return E}function mM(N,F){let A=jY(N);if(A===null)return null;let M=new Int8Array(F.length);for(let D=0;D<F.length;D++)M[D]=A[F[D]];return M}var RY=/[ \t\n\r\f]+/g,bY=/[\t\n\r\f]| {2,}|^ | $/;function fY(N){let F=N??"normal";return F==="pre-wrap"?{mode:F,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:F,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function uY(N){if(!bY.test(N))return N;let F=N.replace(RY," ");if(F.charCodeAt(0)===32)F=F.slice(1);if(F.length>0&&F.charCodeAt(F.length-1)===32)F=F.slice(0,-1);return F}function vY(N){if(!/[\r\f]/.test(N))return N;return N.replace(/\r\n/g,`
17
10
  `).replace(/[\r\f]/g,`
18
- `)}var E8=null,fQ;function vQ(){if(E8===null)E8=new Intl.Segmenter(fQ,{granularity:"word"});return E8}var hQ=/\p{Script=Arabic}/u,z6=/\p{M}/u,DA=/\p{Nd}/u;function nM(N){return hQ.test(N)}function tM(N){return N>=19968&&N<=40959||N>=13312&&N<=19903||N>=131072&&N<=173791||N>=173824&&N<=177983||N>=177984&&N<=178207||N>=178208&&N<=183983||N>=183984&&N<=191471||N>=191472&&N<=192093||N>=194560&&N<=195103||N>=196608&&N<=201551||N>=201552&&N<=205743||N>=205744&&N<=210041||N>=63744&&N<=64255||N>=12288&&N<=12351||N>=12352&&N<=12447||N>=12448&&N<=12543||N>=12592&&N<=12687||N>=44032&&N<=55215||N>=65280&&N<=65519}function a0(N){for(let F=0;F<N.length;F++){let M=N.charCodeAt(F);if(M<12288)continue;if(M>=55296&&M<=56319&&F+1<N.length){let A=N.charCodeAt(F+1);if(A>=56320&&A<=57343){let D=(M-55296<<10)+(A-56320)+65536;if(tM(D))return!0;F++;continue}}if(tM(M))return!0}return!1}function kQ(N){let F=W6(N);return F!==null&&(B6.has(F)||L1.has(F))}var mQ=new Set([" "," ","⁠","\uFEFF"]);function gQ(N){return a0(N)}function uQ(N){let F=W6(N);return F!==null&&mQ.has(F)}function H6(N){return!kQ(N)&&!uQ(N)}var B6=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),RN=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),Z8=new Set(["'","’"]),L1=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),IQ=new Set([":",".","،","؛"]),pQ=new Set(["၏"]),xQ=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function lQ(N){if(Y8(N))return!0;let F=!1;for(let M of N){if(L1.has(M)){F=!0;continue}if(F&&z6.test(M))continue;return!1}return F}function dQ(N){for(let F of N)if(!B6.has(F)&&!L1.has(F))return!1;return N.length>0}function aQ(N){if(Y8(N))return!0;for(let F of N)if(!RN.has(F)&&!Z8.has(F)&&!z6.test(F))return!1;return N.length>0}function Y8(N){let F=!1;for(let M of N){if(M==="\\"||z6.test(M))continue;if(RN.has(M)||L1.has(M)||Z8.has(M)){F=!0;continue}return!1}return F}function EA(N,F){let M=F-1;if(M<=0)return Math.max(M,0);let A=N.charCodeAt(M);if(A<56320||A>57343)return M;let D=M-1;if(D<0)return M;let E=N.charCodeAt(D);return E>=55296&&E<=56319?D:M}function W6(N){if(N.length===0)return null;let F=EA(N,N.length);return N.slice(F)}function rQ(N){let F=Array.from(N),M=F.length;while(M>0){let A=F[M-1];if(z6.test(A)){M--;continue}if(RN.has(A)||Z8.has(A)){M--;continue}break}if(M<=0||M===F.length)return null;return{head:F.slice(0,M).join(""),tail:F.slice(M).join("")}}function cQ(N,F,M){return M==="text"&&!F&&N.length===1&&N!=="-"&&N!=="—"?N:null}function eM(N,F,M,A){let D=F[A],E=N[A];if(D==null)return E;let $=M[A];if(E.length===$)return E;let Z=D.repeat($);return N[A]=Z,Z}function NA(N,F){return N&&F!==null&&IQ.has(F)}function sQ(N){let F=W6(N);return F!==null&&pQ.has(F)}function iQ(N){if(N.length<2||N[0]!==" ")return null;let F=N.slice(1);if(/^\p{M}+$/u.test(F))return{space:" ",marks:F};return null}function P6(N){let F=N.length;while(F>0){let M=EA(N,F),A=N.slice(M,F);if(xQ.has(A))return!0;if(!L1.has(A))return!1;F=M}return!1}function oQ(N,F){if(F.preserveOrdinarySpaces||F.preserveHardBreaks){if(N===" ")return"preserved-space";if(N==="\t")return"tab";if(F.preserveHardBreaks&&N===`
19
- `)return"hard-break"}if(N===" ")return"space";if(N===" "||N===" "||N==="⁠"||N==="\uFEFF")return"glue";if(N==="​")return"zero-width-break";if(N==="­")return"soft-hyphen";return"text"}var nQ=/[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;function u0(N){return N.length===1?N[0]:N.join("")}function tQ(N,F){let M=[];for(let A=N.length-1;A>=0;A--)M.push(N[A]);return M.push(F),u0(M)}function eQ(N,F,M,A){if(!nQ.test(N))return[{text:N,isWordLike:F,kind:"text",start:M}];let D=[],E=null,$=[],Z=M,Y=!1,X=0;for(let Q of N){let J=oQ(Q,A),q=J==="text"&&F;if(E!==null&&J===E&&q===Y){$.push(Q),X+=Q.length;continue}if(E!==null)D.push({text:u0($),isWordLike:Y,kind:E,start:Z});E=J,$=[Q],Z=M+X,Y=q,X+=Q.length}if(E!==null)D.push({text:u0($),isWordLike:Y,kind:E,start:Z});return D}function $8(N){return N==="space"||N==="preserved-space"||N==="zero-width-break"||N==="hard-break"}var NJ=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function FJ(N,F){let M=N.texts[F];if(M.startsWith("www."))return!0;return NJ.test(M)&&F+1<N.len&&N.kinds[F+1]==="text"&&N.texts[F+1]==="//"}function MJ(N){return N.includes("?")&&(N.includes("://")||N.startsWith("www."))}function AJ(N){let F=N.texts.slice(),M=N.isWordLike.slice(),A=N.kinds.slice(),D=N.starts.slice();for(let $=0;$<N.len;$++){if(A[$]!=="text"||!FJ(N,$))continue;let Z=[F[$]],Y=$+1;while(Y<N.len&&!$8(A[Y])){Z.push(F[Y]),M[$]=!0;let X=F[Y].includes("?");if(A[Y]="text",F[Y]="",Y++,X)break}F[$]=u0(Z)}let E=0;for(let $=0;$<F.length;$++){let Z=F[$];if(Z.length===0)continue;if(E!==$)F[E]=Z,M[E]=M[$],A[E]=A[$],D[E]=D[$];E++}return F.length=E,M.length=E,A.length=E,D.length=E,{len:E,texts:F,isWordLike:M,kinds:A,starts:D}}function DJ(N){let F=[],M=[],A=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E];if(F.push($),M.push(N.isWordLike[E]),A.push(N.kinds[E]),D.push(N.starts[E]),!MJ($))continue;let Z=E+1;if(Z>=N.len||$8(N.kinds[Z]))continue;let Y=[],X=N.starts[Z],Q=Z;while(Q<N.len&&!$8(N.kinds[Q]))Y.push(N.texts[Q]),Q++;if(Y.length>0)F.push(u0(Y)),M.push(!0),A.push("text"),D.push(X),E=Q-1}return{len:F.length,texts:F,isWordLike:M,kinds:A,starts:D}}var EJ=new Set([":","-","/","×",",",".","+","–","—"]),FA=/^[A-Za-z0-9_]+[,:;]*$/,MA=/[,:;]+$/;function $A(N){for(let F of N)if(DA.test(F))return!0;return!1}function CN(N){if(N.length===0)return!1;for(let F of N){if(DA.test(F)||EJ.has(F))continue;return!1}return!0}function $J(N){let F=[],M=[],A=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E],Z=N.kinds[E];if(Z==="text"&&CN($)&&$A($)){let Y=[$],X=E+1;while(X<N.len&&N.kinds[X]==="text"&&CN(N.texts[X]))Y.push(N.texts[X]),X++;F.push(u0(Y)),M.push(!0),A.push("text"),D.push(N.starts[E]),E=X-1;continue}F.push($),M.push(N.isWordLike[E]),A.push(Z),D.push(N.starts[E])}return{len:F.length,texts:F,isWordLike:M,kinds:A,starts:D}}function ZJ(N){let F=[],M=[],A=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E],Z=N.kinds[E],Y=N.isWordLike[E];if(Z==="text"&&Y&&FA.test($)){let X=[$],Q=MA.test($),J=E+1;while(Q&&J<N.len&&N.kinds[J]==="text"&&N.isWordLike[J]&&FA.test(N.texts[J])){let q=N.texts[J];X.push(q),Q=MA.test(q),J++}F.push(u0(X)),M.push(!0),A.push("text"),D.push(N.starts[E]),E=J-1;continue}F.push($),M.push(Y),A.push(Z),D.push(N.starts[E])}return{len:F.length,texts:F,isWordLike:M,kinds:A,starts:D}}function YJ(N){let F=[],M=[],A=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E];if(N.kinds[E]==="text"&&$.includes("-")){let Z=$.split("-"),Y=Z.length>1;for(let X=0;X<Z.length;X++){let Q=Z[X];if(!Y)break;if(Q.length===0||!$A(Q)||!CN(Q))Y=!1}if(Y){let X=0;for(let Q=0;Q<Z.length;Q++){let J=Z[Q],q=Q<Z.length-1?`${J}-`:J;F.push(q),M.push(!0),A.push("text"),D.push(N.starts[E]+X),X+=q.length}continue}}F.push($),M.push(N.isWordLike[E]),A.push(N.kinds[E]),D.push(N.starts[E])}return{len:F.length,texts:F,isWordLike:M,kinds:A,starts:D}}function XJ(N){let F=[],M=[],A=[],D=[],E=0;while(E<N.len){let $=[N.texts[E]],Z=N.isWordLike[E],Y=N.kinds[E],X=N.starts[E];if(Y==="glue"){let Q=[$[0]],J=X;E++;while(E<N.len&&N.kinds[E]==="glue")Q.push(N.texts[E]),E++;let q=u0(Q);if(E<N.len&&N.kinds[E]==="text")$[0]=q,$.push(N.texts[E]),Z=N.isWordLike[E],Y="text",X=J,E++;else{F.push(q),M.push(!1),A.push("glue"),D.push(J);continue}}else E++;if(Y==="text")while(E<N.len&&N.kinds[E]==="glue"){let Q=[];while(E<N.len&&N.kinds[E]==="glue")Q.push(N.texts[E]),E++;let J=u0(Q);if(E<N.len&&N.kinds[E]==="text"){$.push(J,N.texts[E]),Z=Z||N.isWordLike[E],E++;continue}$.push(J)}F.push(u0($)),M.push(Z),A.push(Y),D.push(X)}return{len:F.length,texts:F,isWordLike:M,kinds:A,starts:D}}function QJ(N){let F=N.texts.slice(),M=N.isWordLike.slice(),A=N.kinds.slice(),D=N.starts.slice();for(let E=0;E<F.length-1;E++){if(A[E]!=="text"||A[E+1]!=="text")continue;if(!a0(F[E])||!a0(F[E+1]))continue;let $=rQ(F[E]);if($===null)continue;F[E]=$.head,F[E+1]=$.tail+F[E+1],D[E+1]=D[E]+$.head.length}return{len:F.length,texts:F,isWordLike:M,kinds:A,starts:D}}function AA(N,F,M){let A=vQ(),D=0,E=[],$=[],Z=[],Y=[],X=[],Q=[],J=[],q=[],U=[],V=[],y=[],G=[];for(let z of A.segment(N))for(let j of eQ(z.segment,z.isWordLike??!1,z.index,M)){let f=function(){if(Q[P]!==null)$[P]=[eM(E,Q,J,P)],Q[P]=null;$[P].push(j.text),Z[P]=Z[P]||j.isWordLike,q[P]=q[P]||W,U[P]=U[P]||O,V[P]=m,y[P]=d,G[P]=NA(U[P],v)},C=j.kind==="text",L=cQ(j.text,j.isWordLike,j.kind),W=a0(j.text),O=nM(j.text),v=W6(j.text),m=P6(j.text),d=sQ(j.text),P=D-1;if(F.carryCJKAfterClosingQuote&&C&&D>0&&Y[P]==="text"&&W&&q[P]&&V[P])f();else if(C&&D>0&&Y[P]==="text"&&dQ(j.text)&&q[P])f();else if(C&&D>0&&Y[P]==="text"&&y[P])f();else if(C&&D>0&&Y[P]==="text"&&j.isWordLike&&O&&G[P])f(),Z[P]=!0;else if(L!==null&&D>0&&Y[P]==="text"&&Q[P]===L)J[P]=(J[P]??1)+1;else if(C&&!j.isWordLike&&D>0&&Y[P]==="text"&&!q[P]&&(lQ(j.text)||j.text==="-"&&Z[P]))f();else E[D]=j.text,$[D]=[j.text],Z[D]=j.isWordLike,Y[D]=j.kind,X[D]=j.start,Q[D]=L,J[D]=L===null?0:1,q[D]=W,U[D]=O,V[D]=m,y[D]=d,G[D]=NA(O,v),D++}for(let z=0;z<D;z++){if(Q[z]!==null){E[z]=eM(E,Q,J,z);continue}E[z]=u0($[z])}for(let z=1;z<D;z++)if(Y[z]==="text"&&!Z[z]&&Y8(E[z])&&Y[z-1]==="text"&&!q[z-1])E[z-1]+=E[z],Z[z-1]=Z[z-1]||Z[z],E[z]="";let K=Array.from({length:D},()=>null),S=-1;for(let z=D-1;z>=0;z--){let j=E[z];if(j.length===0)continue;if(Y[z]==="text"&&!Z[z]&&aQ(j)&&S>=0&&Y[S]==="text"){let C=K[S]??[];C.push(j),K[S]=C,X[S]=X[z],E[z]="";continue}S=z}for(let z=0;z<D;z++){let j=K[z];if(j==null)continue;E[z]=tQ(j,E[z])}let _=0;for(let z=0;z<D;z++){let j=E[z];if(j.length===0)continue;if(_!==z)E[_]=j,Z[_]=Z[z],Y[_]=Y[z],X[_]=X[z];_++}E.length=_,Z.length=_,Y.length=_,X.length=_;let H=XJ({len:_,texts:E,isWordLike:Z,kinds:Y,starts:X}),B=QJ(ZJ(YJ($J(DJ(AJ(H))))));for(let z=0;z<B.len-1;z++){let j=iQ(B.texts[z]);if(j===null)continue;if(B.kinds[z]!=="space"&&B.kinds[z]!=="preserved-space"||B.kinds[z+1]!=="text"||!nM(B.texts[z+1]))continue;B.texts[z]=j.space,B.isWordLike[z]=!1,B.kinds[z]=B.kinds[z]==="preserved-space"?"preserved-space":"space",B.texts[z+1]=j.marks+B.texts[z+1],B.starts[z+1]=B.starts[z]+j.space.length}return B}function JJ(N,F){if(N.len===0)return[];if(!F.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:N.len,consumedEndSegmentIndex:N.len}];let M=[],A=0;for(let D=0;D<N.len;D++){if(N.kinds[D]!=="hard-break")continue;M.push({startSegmentIndex:A,endSegmentIndex:D,consumedEndSegmentIndex:D+1}),A=D+1}if(A<N.len)M.push({startSegmentIndex:A,endSegmentIndex:N.len,consumedEndSegmentIndex:N.len});return M}function qJ(N){if(N.len<=1)return N;let F=[],M=[],A=[],D=[],E=null,$=!1,Z=0,Y=!1,X=!1;function Q(){if(E===null)return;F.push(u0(E)),M.push($),A.push("text"),D.push(Z),E=null}for(let J=0;J<N.len;J++){let q=N.texts[J],U=N.kinds[J],V=N.isWordLike[J],y=N.starts[J];if(U==="text"){let G=gQ(q),K=H6(q);if(E!==null&&Y&&X){E.push(q),$=$||V,Y=Y||G,X=K;continue}Q(),E=[q],$=V,Z=y,Y=G,X=K;continue}Q(),F.push(q),M.push(V),A.push(U),D.push(y)}return Q(),{len:F.length,texts:F,isWordLike:M,kinds:A,starts:D}}function ZA(N,F,M="normal",A="normal"){let D=CQ(M),E=D.mode==="pre-wrap"?bQ(N):RQ(N);if(E.length===0)return{normalized:E,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let $=A==="keep-all"?qJ(AA(E,F,D)):AA(E,F,D);return{normalized:E,chunks:JJ($,D),...$}}var v2=null,YA=new Map,h2=null,UJ=96,VJ=/\p{Emoji_Presentation}/u,KJ=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,X8=null,XA=new Map;function Q8(){if(v2!==null)return v2;if(typeof OffscreenCanvas<"u")return v2=new OffscreenCanvas(1,1).getContext("2d"),v2;if(typeof document<"u")return v2=document.createElement("canvas").getContext("2d"),v2;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function GJ(N){let F=YA.get(N);if(!F)F=new Map,YA.set(N,F);return F}function Q1(N,F){let M=F.get(N);if(M===void 0)M={width:Q8().measureText(N).width,containsCJK:a0(N)},F.set(N,M);return M}function k2(){if(h2!==null)return h2;if(typeof navigator>"u")return h2={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},h2;let N=navigator.userAgent,M=navigator.vendor==="Apple Computer, Inc."&&N.includes("Safari/")&&!N.includes("Chrome/")&&!N.includes("Chromium/")&&!N.includes("CriOS/")&&!N.includes("FxiOS/")&&!N.includes("EdgiOS/"),A=N.includes("Chrome/")||N.includes("Chromium/")||N.includes("CriOS/")||N.includes("Edg/");return h2={lineFitEpsilon:M?0.015625:0.005,carryCJKAfterClosingQuote:A,preferPrefixWidthsForBreakableRuns:M,preferEarlySoftHyphenBreak:M},h2}function yJ(N){let F=N.match(/(\d+(?:\.\d+)?)\s*px/);return F?parseFloat(F[1]):16}function QA(){if(X8===null)X8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return X8}function SJ(N){return VJ.test(N)||N.includes("️")}function JA(N){return KJ.test(N)}function _J(N,F){let M=XA.get(N);if(M!==void 0)return M;let A=Q8();A.font=N;let D=A.measureText("\uD83D\uDE00").width;if(M=0,D>F+0.5&&typeof document<"u"&&document.body!==null){let E=document.createElement("span");E.style.font=N,E.style.display="inline-block",E.style.visibility="hidden",E.style.position="absolute",E.textContent="\uD83D\uDE00",document.body.appendChild(E);let $=E.getBoundingClientRect().width;if(document.body.removeChild(E),D-$>0.5)M=D-$}return XA.set(N,M),M}function zJ(N){let F=0,M=QA();for(let A of M.segment(N))if(SJ(A.segment))F++;return F}function HJ(N,F){if(F.emojiCount===void 0)F.emojiCount=zJ(N);return F.emojiCount}function T1(N,F,M){if(M===0)return F.width;return F.width-HJ(N,F)*M}function qA(N,F,M,A,D){if(F.breakableFitAdvances!==void 0&&F.breakableFitMode===D)return F.breakableFitAdvances;F.breakableFitMode=D;let E=QA(),$=[];for(let Q of E.segment(N))$.push(Q.segment);if($.length<=1)return F.breakableFitAdvances=null,F.breakableFitAdvances;if(D==="sum-graphemes"){let Q=[];for(let J of $){let q=Q1(J,M);Q.push(T1(J,q,A))}return F.breakableFitAdvances=Q,F.breakableFitAdvances}if(D==="pair-context"||$.length>UJ){let Q=[],J=null,q=0;for(let U of $){let V=Q1(U,M),y=T1(U,V,A);if(J===null)Q.push(y);else{let G=J+U,K=Q1(G,M);Q.push(T1(G,K,A)-q)}J=U,q=y}return F.breakableFitAdvances=Q,F.breakableFitAdvances}let Z=[],Y="",X=0;for(let Q of $){Y+=Q;let J=Q1(Y,M),q=T1(Y,J,A);Z.push(q-X),X=q}return F.breakableFitAdvances=Z,F.breakableFitAdvances}function UA(N,F){let M=Q8();M.font=N;let A=GJ(N),D=yJ(N),E=F?_J(N,D):0;return{cache:A,fontSize:D,emojiCorrection:E}}function BJ(N){return N==="space"||N==="zero-width-break"||N==="soft-hyphen"}function GA(N){return N==="space"||N==="preserved-space"||N==="tab"||N==="zero-width-break"||N==="soft-hyphen"}function yA(N,F,M=N.widths.length){while(F<M){let A=N.kinds[F];if(!BJ(A))break;F++}return F}function WJ(N,F){if(F<=0)return 0;let M=N%F;if(Math.abs(M)<=0.000001)return F;return F-M}function PJ(N,F,M){return N.letterSpacing!==0&&F&&N.spacingGraphemeCounts[M]>0?N.letterSpacing:0}function J8(N,F){return F===0?0:N+F}function OJ(N,F){return N.letterSpacing!==0&&N.spacingGraphemeCounts[F]>0?N.letterSpacing:0}function LJ(N,F,M,A,D){let E=F==="tab"?D+OJ(N,M):N.lineEndFitAdvances[M];return J8(A,E)}function VA(N,F,M,A){let D=F==="tab"?0:N.lineEndFitAdvances[M];return J8(A,D)}function KA(N,F,M,A,D){let E=F==="tab"?D:N.lineEndPaintAdvances[M];return J8(A,E)}function TJ(N,F,M){return N.letterSpacing!==0&&F?M+N.letterSpacing:M}function wJ(N,F){return N.letterSpacing===0?F:F+N.letterSpacing}function jJ(N,F,M,A,D,E){let $=0,Z=F;while($<N.length){let Y=Z+N[$]+E;if(($+1<N.length?Y+D:Y)>M+A)break;Z=Y,$++}return{fitCount:$,fittedWidth:Z}}function CJ(N,F,M){let{widths:A,kinds:D,breakableFitAdvances:E}=N;if(A.length===0)return 0;let Z=k2().lineFitEpsilon,Y=F+Z,X=0,Q=0,J=!1,q=0,U=0,V=0,y=0,G=-1,K=0;function S(){G=-1,K=0}function _(L=V,W=y,O=Q){X++,M?.(O,q,U,L,W),Q=0,J=!1,S()}function H(L,W){J=!0,q=L,U=0,V=L+1,y=0,Q=W}function B(L,W,O){J=!0,q=L,U=W,V=L,y=W+1,Q=O}function z(L,W){if(!J){H(L,W);return}Q+=W,V=L+1,y=0}function j(L,W){let O=E[L];for(let v=W;v<O.length;v++){let m=O[v];if(!J)B(L,v,m);else if(Q+m>Y)_(),B(L,v,m);else Q+=m,V=L,y=v+1}if(J&&V===L&&y===O.length)V=L+1,y=0}let C=0;while(C<A.length){if(!J){if(C=yA(N,C),C>=A.length)break}let L=A[C],W=D[C],O=GA(W);if(!J){if(L>Y&&E[C]!==null)j(C,0);else H(C,L);if(O)G=C+1,K=Q-L;C++;continue}if(Q+L>Y){if(O){z(C,L),_(C+1,0,Q-L),C++;continue}if(G>=0){if(V>G||V===G&&y>0){_();continue}_(G,0,K);continue}if(L>Y&&E[C]!==null){_(),j(C,0),C++;continue}_();continue}if(z(C,L),O)G=C+1,K=Q-L;C++}if(J)_();return X}function SA(N,F,M){if(N.simpleLineWalkFastPath)return CJ(N,F,M);let{widths:A,kinds:D,breakableFitAdvances:E,discretionaryHyphenWidth:$,chunks:Z}=N;if(A.length===0||Z.length===0)return 0;let Y=k2(),X=Y.lineFitEpsilon,Q=F+X,J=0,q=0,U=!1,V=0,y=0,G=0,K=0,S=-1,_=0,H=0,B=null;function z(){S=-1,_=0,H=0,B=null}function j(P=G,f=K,b=q){J++,M?.(b,V,y,P,f),q=0,U=!1,z()}function C(P,f){U=!0,V=P,y=0,G=P+1,K=0,q=f}function L(P,f,b){U=!0,V=P,y=f,G=P,K=f+1,q=b}function W(P,f){if(!U){C(P,f);return}q+=f,G=P+1,K=0}function O(P,f,b,u,o,R){if(!f)return;let k=VA(N,P,b,o),r=KA(N,P,b,o,u);S=b+1,_=q-R+k,H=q-R+r,B=P}function v(P,f){let b=E[P];for(let u=f;u<b.length;u++){let o=b[u];if(!U)L(P,u,o);else{let R=TJ(N,!0,o),k=q+R;if(wJ(N,k)>Q)j(),L(P,u,o);else q=k,G=P,K=u+1}}if(U&&G===P&&K===b.length)G=P+1,K=0}function m(P){if(B!=="soft-hyphen")return!1;let f=E[P];if(f==null)return!1;let{fitCount:b,fittedWidth:u}=jJ(f,q,F,X,$,N.letterSpacing);if(b===0)return!1;if(q=u,G=P,K=b,z(),b===f.length)return G=P+1,K=0,!0;return j(P,b,u+$),v(P,b),!0}function d(P){J++,M?.(0,P.startSegmentIndex,0,P.consumedEndSegmentIndex,0),z()}for(let P=0;P<Z.length;P++){let f=Z[P];if(f.startSegmentIndex===f.endSegmentIndex){d(f);continue}U=!1,q=0,V=f.startSegmentIndex,y=0,G=f.startSegmentIndex,K=0,z();let b=f.startSegmentIndex;while(b<f.endSegmentIndex){if(!U){if(b=yA(N,b,f.endSegmentIndex),b>=f.endSegmentIndex)break}let u=D[b],o=GA(u),R=PJ(N,U,b),k=u==="tab"?WJ(q+R,N.tabStopAdvance):A[b],r=R+k,D0=LJ(N,u,b,R,k);if(u==="soft-hyphen"){if(U)G=b+1,K=0,S=b+1,_=q+$,H=q+$,B=u;b++;continue}if(!U){if(D0>Q&&E[b]!==null)v(b,0);else C(b,k);O(u,o,b,k,R,r),b++;continue}if(q+D0>Q){let p=q+VA(N,u,b,R),s=q+KA(N,u,b,R,k);if(B==="soft-hyphen"&&Y.preferEarlySoftHyphenBreak&&_<=Q){j(S,0,H);continue}if(B==="soft-hyphen"&&m(b)){b++;continue}if(o&&p<=Q){W(b,r),j(b+1,0,s),b++;continue}if(S>=0&&_<=Q){if(G>S||G===S&&K>0){j();continue}let i=S;j(i,0,H),b=i;continue}if(D0>Q&&E[b]!==null){j(),v(b,0),b++;continue}j();continue}W(b,r),O(u,o,b,k,R,r),b++}if(U){let u=S===f.consumedEndSegmentIndex?H:q;j(f.consumedEndSegmentIndex,0,u)}}return J}var q8=null,_A=new WeakMap;function RJ(){if(q8===null)q8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return q8}function zA(N,F,M){let A=M.get(N);if(A!==void 0)return A;A=[];let D=RJ();for(let E of D.segment(F[N]))A.push(E.segment);return M.set(N,A),A}function bJ(N,F,M,A){return A>0&&N[A-1]==="soft-hyphen"&&!(F===A&&M>0)}function HA(N,F,M,A){for(let D=M;D<A;D++)N+=F[D];return N}function BA(N){let F=_A.get(N);if(F!==void 0)return F;return F=new Map,_A.set(N,F),F}function WA(N,F,M,A,D,E){let $="",Z=bJ(N.kinds,M,A,D);for(let Y=M;Y<D;Y++){if(N.kinds[Y]==="soft-hyphen"||N.kinds[Y]==="hard-break")continue;if(Y===M&&A>0){let X=zA(Y,N.segments,F);$=HA($,X,A,X.length)}else $+=N.segments[Y]}if(E>0){if(Z)$+="-";let Y=zA(D,N.segments,F);$=HA($,Y,M===D?A:0,E)}else if(Z)$+="-";return $}var U8=null;function OA(){if(U8===null)U8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return U8}function fJ(N){if(N)return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],letterSpacing:0,spacingGraphemeCounts:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]};return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],letterSpacing:0,spacingGraphemeCounts:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function vJ(N,F){let M=[],A=[],D=0,E=!1,$=!1,Z=!1;function Y(){if(A.length===0)return;M.push({text:A.length===1?A[0]:A.join(""),start:D}),A=[],E=!1,$=!1,Z=!1}function X(J,q,U){A=[J],D=q,E=U,$=P6(J),Z=RN.has(J)}function Q(J,q){A.push(J),E=E||q;let U=P6(J);if(J.length===1&&L1.has(J))$=$||U;else $=U;Z=!1}for(let J of OA().segment(N)){let q=J.segment,U=a0(q);if(A.length===0){X(q,J.index,U);continue}if(Z||B6.has(q)||L1.has(q)||F.carryCJKAfterClosingQuote&&U&&$){Q(q,U);continue}if(!E&&!U){Q(q,U);continue}Y(),X(q,J.index,U)}return Y(),M}function hJ(N){if(N.length<=1)return N;let F=[],M=[N[0].text],A=N[0].start,D=a0(N[0].text),E=H6(N[0].text);function $(){F.push({text:M.length===1?M[0]:M.join(""),start:A})}for(let Z=1;Z<N.length;Z++){let Y=N[Z],X=a0(Y.text),Q=H6(Y.text);if(D&&E){M.push(Y.text),D=D||X,E=Q;continue}$(),M=[Y.text],A=Y.start,D=X,E=Q}return $(),F}function PA(N,F){if(F==="zero-width-break"||F==="soft-hyphen"||F==="hard-break")return 0;if(F==="tab")return 1;let M=0,A=OA();for(let D of A.segment(N))M++;return M}function kJ(N,F,M){return F>1?N+(F-1)*M:N}function mJ(N,F,M,A,D){let E=k2(),{cache:$,emojiCorrection:Z}=UA(F,JA(N.normalized)),Y=T1("-",Q1("-",$),Z)+(D===0?0:D),Q=T1(" ",Q1(" ",$),Z)*8,J=D!==0;if(N.len===0)return fJ(M);let q=[],U=[],V=[],y=[],G=N.chunks.length<=1&&!J,K=M?[]:null,S=[],_=[],H=M?[]:null,B=Array.from({length:N.len});function z(W,O,v,m,d,P,f,b){if(d!=="text"&&d!=="space"&&d!=="zero-width-break")G=!1;if(q.push(O),U.push(v),V.push(m),y.push(d),K?.push(P),S.push(f),J)_.push(b);if(H!==null)H.push(W)}function j(W,O,v,m,d){let P=Q1(W,$),f=J?PA(W,O):0,b=kJ(T1(W,P,Z),f,D),u=O==="space"||O==="preserved-space"||O==="zero-width-break"?0:b,o=u===0?0:u+(f>0?D:0),R=O==="space"||O==="zero-width-break"?0:b;if(d&&m&&W.length>1){let k="sum-graphemes";if(D!==0)k="segment-prefixes";else if(CN(W))k="pair-context";else if(E.preferPrefixWidthsForBreakableRuns)k="segment-prefixes";let r=qA(W,P,$,Z,k);z(W,b,o,R,O,v,r,f);return}z(W,b,o,R,O,v,null,f)}for(let W=0;W<N.len;W++){B[W]=q.length;let O=N.texts[W],v=N.isWordLike[W],m=N.kinds[W],d=N.starts[W];if(m==="soft-hyphen"){z(O,0,Y,Y,m,d,null,0);continue}if(m==="hard-break"){z(O,0,0,0,m,d,null,0);continue}if(m==="tab"){z(O,0,0,0,m,d,null,J?PA(O,m):0);continue}let P=Q1(O,$);if(m==="text"&&P.containsCJK){let f=vJ(O,E),b=A==="keep-all"?hJ(f):f;for(let u=0;u<b.length;u++){let o=b[u];j(o.text,"text",d+o.start,v,A==="keep-all"||!a0(o.text))}continue}j(O,m,d,v,!0)}let C=gJ(N.chunks,B,q.length),L=K===null?null:oM(N.normalized,K);if(H!==null)return{widths:q,lineEndFitAdvances:U,lineEndPaintAdvances:V,kinds:y,simpleLineWalkFastPath:G,segLevels:L,breakableFitAdvances:S,letterSpacing:D,spacingGraphemeCounts:_,discretionaryHyphenWidth:Y,tabStopAdvance:Q,chunks:C,segments:H};return{widths:q,lineEndFitAdvances:U,lineEndPaintAdvances:V,kinds:y,simpleLineWalkFastPath:G,segLevels:L,breakableFitAdvances:S,letterSpacing:D,spacingGraphemeCounts:_,discretionaryHyphenWidth:Y,tabStopAdvance:Q,chunks:C}}function gJ(N,F,M){let A=[];for(let D=0;D<N.length;D++){let E=N[D],$=E.startSegmentIndex<F.length?F[E.startSegmentIndex]:M,Z=E.endSegmentIndex<F.length?F[E.endSegmentIndex]:M,Y=E.consumedEndSegmentIndex<F.length?F[E.consumedEndSegmentIndex]:M;A.push({startSegmentIndex:$,endSegmentIndex:Z,consumedEndSegmentIndex:Y})}return A}function uJ(N,F,M,A){let D=A?.wordBreak??"normal",E=A?.letterSpacing??0,$=ZA(N,k2(),A?.whiteSpace,D);return mJ($,F,M,D,E)}function LA(N,F,M){return uJ(N,F,!0,M)}function IJ(N){return N}function pJ(N,F,M,A,D,E,$){return{text:WA(N,F,A,D,E,$),width:M,start:{segmentIndex:A,graphemeIndex:D},end:{segmentIndex:E,graphemeIndex:$}}}function TA(N,F,M){let A=[];if(N.widths.length===0)return{lineCount:0,height:0,lines:A};let D=BA(N),E=SA(IJ(N),F,($,Z,Y,X,Q)=>{A.push(pJ(N,D,$,Z,Y,X,Q))});return{lineCount:E,height:E*M,lines:A}}function bN(N,F,M){let A=N.image?F.images.get(N.image.url)??null:null,D=N.image?.width??null,E=Math.min(M,D??240),$=Math.max(120,Math.round(E*0.5625));if(!A||A.intrinsicWidth<=0||A.intrinsicHeight<=0)return{height:$,width:E};let Z=Math.min(M,D??A.intrinsicWidth),Y=Math.min(1,Z/A.intrinsicWidth);return{height:Math.max(48,Math.round(A.intrinsicHeight*Y)),width:Math.max(48,Math.round(A.intrinsicWidth*Y))}}function wA(N,F){if(!N.image)return`${N.kind}:missing-image`;let M=F.images.get(N.image.url);return`${N.kind}:${N.image.url}:${N.image.width??0}:${M?.status??"loading"}:${M?.intrinsicWidth??0}:${M?.intrinsicHeight??0}`}var jA=4;function V8(N,F){if(!N)return Math.max(18,F.name.length*8+8);return Math.max(18,N.measureText(`@${F.name}`).width+8)}var CA=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],RA='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',O6;function m2(N){if(N?.type==="heading"){let{fontSize:F}=vA(N.depth);return`700 ${F}px ${RA}`}switch(N?.type){case"code":return"15px ui-monospace, SFMono-Regular, Menlo, monospace";default:return`16px ${RA}`}}function w1(N,F){if(N?.type==="heading")return vA(N.depth).lineHeight;if(N?.type==="code")return 22;return F}function vA(N){return CA[N-1]??CA.at(-1)}function g2(N,F,M,A,D,E,$){let Z=`${T6(F,$)}:${D}:${E}:${M}`,Y=N.measuredLines.get(Z);if(Y)return Y;let X=lJ(N,F,M,A,D,E,$);return gM(N,Z,X)}function L6(N,F,M,A,D,E,$,Z){let Y=`${T6(F,Z)}:${M}:${A}:${E}:${$}`,X=N.lineBoundaries.get(Y);if(X)return X;let Q=kA(),J=[{left:0,offset:0}],q=0,U=F.inlines.filter((V)=>V.end>M&&V.start<A);if(U.length===0)return dJ(D);for(let V of U){let y=Math.max(M,V.start),G=Math.min(A,V.end),K=F.text.slice(y,G),S=y-M;if(V.kind==="image"){let _=bN(V,Z,$).width;q+=_,S+=K.length,J.push({left:q,offset:S});continue}if(Q)Q.font=hA(E,V.marks);if(w6(V)){q+=V8(Q,V.mention),S+=K.length,J.push({left:q,offset:S});continue}for(let _ of X1(K))q+=mA(N,Q,_),S+=_.length,J.push({left:q,offset:S})}return uM(N,Y,J)}function xJ(N,F,M,A){let D=`${M}::${A}::${F}`,E=N.preparedText.get(D);if(E)return E;let $=LA(F,M,{whiteSpace:A});return mM(N,D,$)}function lJ(N,F,M,A,D,E,$){let Z=F.text;if(Z.length===0)return[{end:0,height:E,start:0,text:"",width:0}];if(iJ(F))return rJ(N,F,M,D,E,$);try{let Y=xJ(N,Z,M,Nq(A));return TA(Y,D,E).lines.map((Q)=>({end:bA(Y.segments,Q.end),height:E,start:bA(Y.segments,Q.start),text:Q.text,width:Q.width}))}catch{return aJ(Z,D,E)}}function bA(N,F){let M=0;for(let E=0;E<F.segmentIndex;E+=1)M+=N[E]?.length??0;let A=N[F.segmentIndex]??"",D=X1(A);for(let E=0;E<F.graphemeIndex;E+=1)M+=D[E]?.length??0;return M}function dJ(N){let F=[{left:0,offset:0}],M=0,A=0;for(let D of X1(N))M+=9,A+=D.length,F.push({left:M,offset:A});return F}function aJ(N,F,M){let A=Math.max(1,Math.floor(F/9)),D=Fq(N,A),E=0;return D.map(($)=>{let Z=E,Y=Z+$.length;return E=Y,{end:Y,height:M,start:Z,text:$,width:$.length*9}})}function rJ(N,F,M,A,D,E){let $=sJ(N,kA(),F,M,A,D,E);if($.length===0)return[{end:0,height:D,start:0,text:"",width:0}];return cJ($,F.text,A,D)}function cJ(N,F,M,A){let D=[],E=0;while(E<N.length){let Z=N[E].start;if(N[E].text===`
20
- `){D.push({end:Z,height:A,start:Z,text:"",width:0}),E+=1;continue}let Y=0,X=0,Q=E,J=-1,q=A;while(Q<N.length){let V=N[Q];if(V.text===`
21
- `)break;let y=Y+V.width;if(y>M&&Q>E)break;if(Y=y,q=Math.max(q,V.height),V.breakable)J=Q,X=Y;Q+=1}if(Q===N.length||N[Q]?.text===`
22
- `){let V=N[Q-1]?.end??Z;D.push({end:V,height:q,start:Z,text:F.slice(Z,V),width:Y}),E=Q<N.length&&N[Q]?.text===`
23
- `?Q+1:Q;continue}if(J>=E){let V=N[J].end;D.push({end:V,height:q,start:Z,text:F.slice(Z,V),width:X}),E=J+1;continue}let U=N[Math.max(E,Q-1)].end;D.push({end:U,height:q,start:Z,text:F.slice(Z,U),width:Y}),E=Math.max(E+1,Q)}let $=N.at(-1);if($?.text===`
24
- `)D.push({end:$.end,height:A,start:$.end,text:"",width:0});return D}function sJ(N,F,M,A,D,E,$){let Z=[];for(let Y of M.inlines){if(Y.kind==="image"){let Q=bN(Y,$,D);Z.push({breakable:!0,end:Y.end,height:Q.height,start:Y.start,text:Y.text,width:Q.width});continue}if(F)F.font=hA(A,Y.marks);if(w6(Y)){Z.push({breakable:!0,end:Y.end,height:E,start:Y.start,text:Y.text,width:V8(F,Y.mention)});continue}let X=Y.start;for(let Q of X1(Y.text)){let J=X,q=J+Q.length;Z.push({breakable:/\s/.test(Q),end:q,height:E,start:J,text:Q,width:Q===`
25
- `?0:mA(N,F,Q)}),X=q}}return Z}function iJ(N){return N.inlines.some((F)=>F.kind==="image"||w6(F)||F.kind==="lineBreak"||eJ(F)||C2(F.text))}var fA=new WeakMap;function T6(N,F){let M=fA.get(N.inlines);if(M&&M.path===N.path&&M.text===N.text)return M.identity;let A=[N.path,tJ(N.text),oJ(N,F)].join(":");if(!N.inlines.some((D)=>D.kind==="image"))fA.set(N.inlines,{identity:A,path:N.path,text:N.text});return A}function oJ(N,F){return N.inlines.map((M)=>`${M.start}-${M.end}:${nJ(M,F)}`).join("|")}function nJ(N,F){if(N.kind==="image"&&N.image)return wA(N,F);if(w6(N))return`${N.kind}:${N.mention.userId}:${N.mention.name}`;return`${N.kind}:${N.inlineCode?1:0}:${N.marks.join(",")}:${N.link?.url??""}`}function tJ(N){let F=2166136261;for(let M=0;M<N.length;M+=1)F^=N.charCodeAt(M),F=Math.imul(F,16777619);return(F>>>0).toString(36)}function eJ(N){return N.marks.includes("italic")||N.marks.includes("bold")}function w6(N){return Boolean(N.mention)}function hA(N,F){let M=[];if(F.includes("italic"))M.push("italic");if(F.includes("bold"))M.push("700");return M.length>0?`${M.join(" ")} ${N}`:N}function kA(){if(O6!==void 0)return O6;return O6=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,O6}function mA(N,F,M){if(!F)return 9;let A=F.font,D=pM(N,A),E=D.get(M);if(E!==void 0)return E;let $=F.measureText(M).width;return D.set(M,$),$}function Nq(N){return N?.type==="code"?"pre-wrap":"normal"}function Fq(N,F){if(N.length===0)return[""];let M=N.split(`
26
- `),A=[];for(let D of M){if(D.length===0){A.push("");continue}let E=D;while(E.length>F){let $=E.slice(0,F),Z=$.lastIndexOf(" ");if(Z<=0){A.push($),E=E.slice(F);continue}A.push($.slice(0,Z)),E=E.slice(Z+1)}A.push(E)}return A}var fN=10,u2=8,K8=120;function gA(N,F,M,A,D,E,$,Z,Y,X){let Q=Math.max(1,...E.rows.map((y)=>y.cells.length)),q=Math.max(K8,Y.width-$-Y.paddingX)/Q,U=Mq(A),V=Z;for(let y=0;y<E.rows.length;y+=1){let G=Aq(U.get(y)??[],D,E,q,fN,Y.lineHeight,X),K=Math.max(Y.lineHeight+u2*2,...G.map((S)=>S.measuredLines.reduce((_,H)=>_+H.height,0)+u2*2));for(let S of G){let _=$+S.cellIndex*q,H=V+u2;for(let B of S.measuredLines){let z={blockId:S.container.blockId,boundaries:L6(D,S.container,B.start,B.end,B.text,S.font,q-fN*2,X),regionId:S.container.id,end:B.end,font:S.font,height:B.height,left:_+fN,start:B.start,text:B.text,top:H,width:B.width};N.push(z),G8(F,z),H+=B.height}M.set(S.container.id,{bottom:V+K,left:_,right:_+q,top:V})}Dq(F,E.id,V,V+K),V+=K}return V}function Mq(N){let F=new Map;for(let M of N){let A=M.tableCellPosition;if(!A)continue;let D=F.get(A.rowIndex)??[];D.push({cellIndex:A.cellIndex,container:M}),F.set(A.rowIndex,D)}return F}function Aq(N,F,M,A,D,E,$){return[...N].sort((Z,Y)=>Z.cellIndex-Y.cellIndex).map(({cellIndex:Z,container:Y})=>{let X=m2(M),Q=w1(M,E),J=g2(F,Y,X,M,Math.max(40,A-D*2),Q,$);return{cellIndex:Z,container:Y,font:X,lineHeight:Q,measuredLines:J}})}function Dq(N,F,M,A){let D=N.get(F);N.set(F,{bottom:D?Math.max(D.bottom,A):A,top:D?Math.min(D.top,M):M})}function j6(N){let F=N.charWidth??y6.charWidth,M=N.lineHeight??y6.lineHeight,A=Math.max(12,Math.floor(N.width/F)),D=N.text.split(`
27
- `).reduce((E,$)=>E+Math.max(1,Math.ceil($.length/A)),0);return{estimatedHeight:D*M,lineCount:D,width:N.width}}function C6(N,F,M=i1(),A=null){let D=A??{images:new Map},E=S6(F),$=[],Z=new Map,Y=new Map(N.regions.map((G)=>[G.id,{textLength:G.text.length}])),X=N.blockIndex,Q=vN(N.document.blocks),J=new Map,q=new Set(N.regions.map((G)=>G.id)),U=E.paddingY,V=null;for(let G of N.blocks){let K=Q.get(G.id)??null;if(!K||O1(K))continue;let S=M1(G),_=G.regionIds.filter((C)=>q.has(C));if(!S&&_.length===0)continue;if(V!==null){if(U+=_6(X,Q,V.id,G.id,E.blockGap),!M1(V)){let C=J.get(V.id);if(C)C.bottom=Math.max(C.bottom,U)}}let H=G.depth,B=E.paddingX+H*E.indentWidth,z=f2(X,N.listItemMarkers,G.id),j=Math.max(40,E.width-B-E.paddingX-z);if(S){let C=U+E.lineHeight;J.set(G.id,{top:U,bottom:C}),U=C}else if(K.type==="table"){let C=_.map((L)=>N.regionIndex.get(L)).filter((L)=>L!==void 0);U=gA($,J,Z,C,M,K,B,U,E,D)}else for(let C of _){let L=N.regionIndex.get(C);if(!L)continue;U=Eq($,J,Z,L,M,K,B,U,j,E,D)}V=G}let y=[];for(let G of N.blocks){let K=Q.get(G.id);if(!K||O1(K))continue;let S=J.get(G.id);if(!S)continue;y.push({bottom:S.bottom,depth:G.depth,id:G.id,top:S.top,type:G.type})}return{blocks:y,regionBounds:Z,regionLineIndices:$q($),regionMetrics:Y,height:Math.max(U,E.paddingY),lines:$,options:E,width:E.width}}function Eq(N,F,M,A,D,E,$,Z,Y,X,Q){let J=m2(E),q=w1(E,X.lineHeight),U=g2(D,A,J,E,Y,q,Q),V=Z;for(let y of U){let G={blockId:A.blockId,boundaries:L6(D,A,y.start,y.end,y.text,J,Y,Q),regionId:A.id,end:y.end,font:J,height:y.height,left:$,start:y.start,text:y.text,top:V,width:y.width};N.push(G),G8(F,G),Zq(M,G),V+=y.height}return V}function $q(N){N.sort((M,A)=>M.top-A.top||M.left-A.left);let F=new Map;for(let M=0;M<N.length;M+=1){let A=N[M].regionId,D=F.get(A);if(D)D.push(M);else F.set(A,[M])}return F}function Zq(N,F){let M=N.get(F.regionId),A=F.left+F.width,D=F.top+F.height;N.set(F.regionId,M?{bottom:Math.max(M.bottom,D),left:Math.min(M.left,F.left),right:Math.max(M.right,A),top:Math.min(M.top,F.top)}:{bottom:D,left:F.left,right:A,top:F.top})}function G8(N,F){let M=N.get(F.blockId),A=F.top+F.height;N.set(F.blockId,{bottom:M?Math.max(M.bottom,A):A,top:M?Math.min(M.top,F.top):F.top})}function vN(N){let F=new Map,M=(A)=>{for(let D of A)if(F.set(D.id,D),D.type==="blockquote"||D.type==="listItem")M(D.children);else if(D.type==="list")M(D.items)};return M(N),F}var R6=null;function Yq(N){let F=/(\d+(?:\.\d+)?)\s*px/.exec(N);return F?Number.parseFloat(F[1]):16}function D1(N){R6??=new Map;let F=R6.get(N);if(F)return F;let M=IA(),A=Math.max(12,Math.round(Yq(N)));if(!M){let q={ascent:Math.round(A*0.8),descent:Math.max(2,A-Math.round(A*0.8)),emHeight:A};return R6.set(N,q),q}M.font=N;let D=M.measureText("Hg"),E=Math.round(D.actualBoundingBoxAscent||0),$=Math.round(D.actualBoundingBoxDescent||0),Z=E+$,Y=Math.max(A,Z),X=Z>0?E:Math.round(Y*0.8),Q=Z>0?$:Math.max(2,Y-X),J={ascent:X,descent:Q,emHeight:Y};return R6.set(N,J),J}function hN(N,F){let{emHeight:M}=D1(F);return Math.max(0,Math.floor((N-M)/2))}function o1(N,F){let{ascent:M}=D1(F);return hN(N,F)+M}var b6;function uA(N,F){let M=IA();if(!M||N.length===0)return 0;return M.font=F,M.measureText(N).width}function IA(){if(b6!==void 0)return b6;return b6=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,b6}function dA(N,F){let M=0,A=N.lines.length-1;while(M<=A){let D=M+A>>1,E=N.lines[D];if(F<E.top){A=D-1;continue}if(F>=E.top+E.height){M=D+1;continue}return{index:D,line:E}}return null}function f6(N,F){let M=[...N.regionBounds.entries()].find(([,E])=>{return F.x>=E.left&&F.x<=E.right&&F.y>=E.top&&F.y<=E.bottom});if(M)return kN(N,M[0],F.y);let A=dA(N,F.y);if(!A)return null;let D=Xq(N,F.y,A.index);if(D.length===1)return D[0]??null;return D.find((E)=>{let $=N.regionBounds.get(E.line.regionId);return $?F.x>=$.left&&F.x<=$.right:!1})??[...D].sort((E,$)=>{let Z=N.regionBounds.get(E.line.regionId),Y=N.regionBounds.get($.line.regionId),X=xA(F.x,Z),Q=xA(F.x,Y);return X-Q})[0]??null}function v6(N,F,M){if(N.blocks.length===0)return{endIndex:0,startIndex:0};let A=F+M,D=pA(N,F),E=pA(N,A);if(D>0){if(N.blocks[D-1].bottom>F)D-=1}if(E<N.blocks.length){if(N.blocks[E].top<A)E+=1}return{endIndex:E,startIndex:D}}function pA(N,F){let M=0,A=N.blocks.length;while(M<A){let D=M+A>>1;if(N.blocks[D].bottom<=F)M=D+1;else A=D}return M}function h6(N,F,M){if(N.lines.length===0)return{endIndex:0,startIndex:0};let A=F+M,D=lA(N,F),E=lA(N,A);if(D>0){let $=N.lines[D-1];if($.top+$.height>F)D-=1}if(E<N.lines.length){if(N.lines[E].top<A)E+=1}return{endIndex:E,startIndex:D}}function r0(N,F,M){return I2(N,F,M)?.line??null}function kN(N,F,M){let A=N.regionLineIndices.get(F);if(!A||A.length===0)return null;let D=A[0],E=Number.POSITIVE_INFINITY;for(let $ of A){let Z=N.lines[$],Y=M<Z.top?Z.top-M:M>Z.top+Z.height?M-(Z.top+Z.height):0;if(Y<E)E=Y,D=$;if(Y===0)break}return{index:D,line:N.lines[D]}}function I2(N,F,M){let A=N.regionLineIndices.get(F);if(!A||A.length===0)return null;let D=0,E=A.length-1;while(D<=E){let Q=D+E>>1,J=A[Q],q=N.lines[J];if(M<q.start){E=Q-1;continue}if(M>q.end){D=Q+1;continue}return{index:J,line:q}}let $=A[0],Z=A[A.length-1],Y=N.lines[$],X=N.lines[Z];if(M<=Y.start)return{index:$,line:Y};if(M>=X.end)return{index:Z,line:X};return null}function Xq(N,F,M){let A=[];for(let D=M;D>=0;D-=1){let E=N.lines[D];if(F<E.top||F>=E.top+E.height)break;A.unshift({index:D,line:E})}for(let D=M+1;D<N.lines.length;D+=1){let E=N.lines[D];if(F<E.top||F>=E.top+E.height)break;A.push({index:D,line:E})}return A}function xA(N,F){if(!F)return Number.POSITIVE_INFINITY;if(N<F.left)return F.left-N;if(N>F.right)return N-F.right;return 0}function B0(N,F){return N.left+Qq(N.boundaries,F)}function Qq(N,F){for(let A of N)if(A.offset===F)return A.left;return N.filter((A)=>A.offset<=F).at(-1)?.left??0}function lA(N,F){let M=0,A=N.lines.length;while(M<A){let D=M+A>>1,E=N.lines[D];if(E.top+E.height<=F)M=D+1;else A=D}return M}function y8(N,F){if(N.length===0)return 0;for(let M=1;M<N.length;M+=1){let A=N[M-1],D=N[M],E=A.left+(D.left-A.left)/2;if(F<=E)return A.offset;if(F<=D.left)return D.offset}return N.at(-1)?.offset??0}function J1(N,F,M){return B0(F,M)+f0(N,F)}function f0(N,F){let M=q1(N,F.blockId,"listItem");if(!M)return 0;return t1(N,M.id)?.kind==="task"?sM:rM}function n1(N){return{left:N.left,size:cM,top:N.top+3}}function q1(N,F,M){let A=N.documentIndex.blockIndex.get(F)??null;while(A){if(A.type===M)return A;let D=A.parentBlockId;A=D?N.documentIndex.blockIndex.get(D)??null:null}return null}function t1(N,F){return N.documentIndex.listItemMarkers.get(F)??null}function d0(N,F,M){if(!N.regionMetrics.get(M.regionId))return null;let D=r0(N,M.regionId,M.offset);if(!D)return null;return{blockId:D.blockId,regionId:D.regionId,height:D.height,left:B0(D,M.offset-D.start),offset:M.offset,top:D.top}}function c0(N,F,M){let A=r0(F,M.regionId,M.offset);if(!A)return M.left;return M.left+f0(N,A)+Jq(N,A,M.offset)}function Jq(N,F,M){if(M<=F.end)return 0;let A=N.documentIndex.regionIndex.get(F.regionId);if(!A)return 0;let D=A.text.slice(F.end,M);if(!/^[ \t]+$/u.test(D))return 0;return uA(D,F.font)}function L0(N,F,M){let A=qq(N,F,M);if(!A)return null;let D=A.snapToLineStart?A.line.left:M.x;return aA(N,F,A.line,D)}function m6(N,F,M){let A=N.lines[N.lines.length-1];if(!A||M.y<=A.top+A.height)return null;return aA(N,F,A,M.x)}function g6(N,F,M,A){let D=rA(F,A.regionId);if(!D)return null;let E=L0(N,F,M);if(E)return{regionId:E.regionId,offset:E.offset};let $=M.y<Uq(N);return{regionId:A.regionId,offset:$?0:D.text.length}}function u6(N,F,M){let A=L0(N,F,M);if(!A)return null;let D=rA(F,A.regionId);if(!D||D.text.length===0)return null;let E=Vq(D.text,Kq(D.text,A.offset));if(E.start===E.end)return null;return{anchor:{regionId:A.regionId,offset:E.start},focus:{regionId:A.regionId,offset:E.end}}}function aA(N,F,M,A){let D=N.regionMetrics.get(M.regionId);if(!D)return null;let E=Math.max(0,A-f0(F,M)-M.left),$=y8(M.boundaries,E),Z=Math.min(D.textLength,M.start+$);return{regionId:M.regionId,offset:Z,left:B0(M,$),top:M.top,height:M.height}}function qq(N,F,M){for(let[D,E]of N.regionBounds)if(M.x>=E.left&&M.x<=E.right&&M.y>=E.top&&M.y<=E.bottom){let $=kN(N,D,M.y)?.line??null;return $?{line:$}:null}let A=f6(N,M)?.line??null;if(A)return{line:A};for(let D of N.blocks){if(M.y<D.top||M.y>D.bottom)continue;for(let $=N.lines.length-1;$>=0;$--)if(N.lines[$].blockId===D.id)return{line:N.lines[$]};let E=F.documentIndex.blockIndex.get(D.id);if(E&&M1(E)){let $=KN(F.documentIndex,D.id);if($){let Z=N.lines.find((Y)=>Y.blockId===$.id);if(Z)return{line:Z,snapToLineStart:!0}}}}return null}function rA(N,F){return N.documentIndex.regionIndex.get(F)??null}function Uq(N){return N.lines[0]?.top??0}function Vq(N,F){let M=F,A=F;while(M>0&&k6(N[M-1]))M-=1;while(A<N.length&&k6(N[A]))A+=1;return{end:A,start:M}}function Kq(N,F){if(F<N.length&&k6(N[F]))return F;if(F>0&&k6(N[F-1]))return F-1;return F}function k6(N){return N!==void 0&&/\w/.test(N)}function S8(N,F,M){let A=Gq(N,M);if(!A||A.start!==0)return null;let D=q1(F,A.blockId,"listItem");if(!D)return null;if(t1(F,D.id)?.kind!=="task")return null;let $=n1(A),Z=$.left-4,Y=$.left+$.size+4,X=$.top-4,Q=$.top+$.size+4;return M.x>=Z&&M.x<=Y&&M.y>=X&&M.y<=Q?{listItemId:D.id}:null}function _8(N,F,M){let A=L0(N,F,M);if(!A)return null;let D=yq(F,A.regionId);if(!D)return null;let E=D.inlines.find(($)=>$.link&&A.offset>=$.start&&A.offset<$.end);if(!E?.link)return null;return{endOffset:E.end,regionId:A.regionId,startOffset:E.start,title:E.link.title,url:E.link.url}}function I6(N,F,M,A){let D=S8(N,F,M);if(D)return{kind:"task-toggle",listItemId:D.listItemId};let E=L0(N,F,M);if(!E)return null;let $=cA(E.regionId,E.offset,A),Z=_8(N,F,M);if(Z)return{endOffset:Z.endOffset,kind:"link",commentThreadIndex:$,regionId:Z.regionId,startOffset:Z.startOffset,title:Z.title,url:Z.url};return{kind:"text",commentThreadIndex:$}}function p6(N,F,M,A){let D=F.documentIndex.regionIndex.get(M.regionId);if(!D)return null;let E=cA(M.regionId,M.offset,A),$=D.inlines.find((Z)=>M.offset>=Z.start&&M.offset<=Z.end)??null;if($?.link)return{commentThreadIndex:E,endOffset:$.end,kind:"link",regionId:M.regionId,startOffset:$.start,title:$.link.title,url:$.link.url};if(E!==null)return{commentThreadIndex:E,kind:"text"};return null}function mN(N,F,M,A){let D=N.documentIndex.regionIndex.get(N.selection.anchor.regionId);if(!A.image||!D)return null;let E=r0(F.layout,D.id,A.start);if(!E)return null;let $=E.left+f0(N,E),Z=$+B0(E,A.start-E.start)-E.left,Y=$+B0(E,A.end-E.start)-E.left,{height:X}=bN(A,M,E.width),Q=E.top+Math.max(0,Math.floor((E.height-X)/2));return{left:Z,top:Q,width:Y-Z,height:X}}function cA(N,F,M){for(let A of M)if(A.regionId===N&&F>=A.startOffset&&F<=A.endOffset)return A.threadIndex;return null}function Gq(N,F){return N.lines.find((M)=>F.y>=M.top-4&&F.y<=M.top+M.height+4)??N.lines.filter((M)=>Math.abs(F.y-(M.top+M.height/2))<=10).sort((M,A)=>Math.abs(F.y-(M.top+M.height/2))-Math.abs(F.y-(A.top+A.height/2)))[0]??null}function yq(N,F){return N.documentIndex.regionIndex.get(F)??null}function sA(N,F,M,A,D,E,$){let Z=z8(F,D,E,$),Y=N.measuredContainerHeights.get(Z);if(Y!==void 0)return Y;let X=w1(M,E.lineHeight),Q=E.paddingX+A*E.indentWidth,J=Math.max(40,E.width-Q-E.paddingX-D);if(F.inlines.some((V)=>V.kind==="image"||V.kind==="mention")){let V=m2(M);return g2(N,F,V,M,J,X,$).reduce((y,G)=>y+G.height,0)}let q=j6({charWidth:E.charWidth,lineHeight:X,text:F.text,width:J});return Math.max(X,q.lineCount*X)}function iA(N,F,M,A){let D=j6({charWidth:A,lineHeight:M,text:N.text,width:F});return Math.max(M,D.lineCount*M)}function z8(N,F,M,A){return`${T6(N,A)}:${M.width}:${M.paddingX}:${M.indentWidth}:${M.lineHeight}:${F}`}function H8(N,F){let M=0,A=N.entries.length;while(M<A){let D=M+A>>1;if(N.entries[D].bottom<=F)M=D+1;else A=D}return M}function oA(N,F,M,A,D){let E=A,$=D;for(let Z=A;Z<D;Z+=1){let Y=N.regions[Z],X=F.get(Y.blockId);if(!X)continue;if(X.type==="table"){let Q=M.get(X.regionIds[0]??""),J=M.get(X.regionIds[X.regionIds.length-1]??"");if(Q!==void 0)E=Math.min(E,Q);if(J!==void 0)$=Math.max($,J+1)}}return{endIndex:$,startIndex:E}}function nA(N,F,M){return{...N,blocks:N.blocks.map((A)=>({...A,bottom:A.bottom+F,top:A.top+F})),regionBounds:new Map([...N.regionBounds.entries()].map(([A,D])=>[A,{bottom:D.bottom+F,left:D.left,right:D.right,top:D.top+F}])),height:M,lines:N.lines.map((A)=>({...A,top:A.top+F}))}}function tA(N,F,M,A,D){for(let[E,$]of M.regionBounds){let Z=$.bottom-$.top,Y=F.regionIndex.get(E),X=Y?f2(F.blockIndex,F.listItemMarkers,Y.blockId):0;IM(N,z8(Y??{path:E,inlines:[],text:""},X,A,D),Z)}}function B8(N,F,M,A=[],D=i1(),E=null){let $=S6(F),Z=E??{images:new Map},Y=vN(N.document.blocks),X=N.blockIndex,Q=new Set(A),J=Math.max(0,M.top-M.overscan),q=M.top+M.height+M.overscan,U=_q(D,N,Y,X,$,Z),V=H8(U,J),y=H8(U,q);if(V>0){let H=U.entries[V-1];if(H&&H.bottom>J)V-=1}if(y<U.entries.length){let H=U.entries[y];if(H&&H.top<q)y+=1}for(let H of Q){let B=U.containerIndices.get(H);if(B===void 0)continue;V=Math.min(V,B),y=Math.max(y,B+1)}if(!Number.isFinite(V)||!Number.isFinite(y))return{estimateRegionBounds:U.estimateRegionBounds,layout:C6({...N,regions:[]},$,D,Z),totalHeight:U.totalHeight,viewport:M};let G=oA(N,X,U.containerIndices,V,y),K=U.entries[G.startIndex]?.top??$.paddingY,S=C6({...N,regions:N.regions.slice(G.startIndex,G.endIndex)},$,D,Z),_=nA(S,K,U.totalHeight);return tA(D,N,_,$,Z),{estimateRegionBounds:U.estimateRegionBounds,layout:_,totalHeight:U.totalHeight,viewport:M}}function _q(N,F,M,A,D,E){let $=Bq(F,D,E),Z=xM(N,F,$);if(Z)return Z;let Y=D.paddingY,X=[],Q=new Map,J=0,q=null;for(let U of F.blocks){let V=M.get(U.id)??null;if(!V||O1(V))continue;let y=M1(U);if(!y&&U.regionIds.length===0)continue;if(q!==null)Y+=_6(A,M,q,U.id,D.blockGap);if(y)Y+=D.lineHeight;else if(V.type==="table"){let G=zq({block:V,containerIndices:Q,entries:X,index:J,options:D,runtimeBlocks:A,totalHeight:Y,regions:F.regions});if(G)J=G.nextIndex,Y=G.totalHeight}else{let G=f2(F.blockIndex,F.listItemMarkers,U.id);for(let K of U.regionIds){let S=F.regions[J];if(!S){J+=1;continue}let _=sA(N,S,V,U.depth,G,D,E),H=Y,B=H+_;X[J]={bottom:B,top:H},Q.set(S.id,J),Y=B,J+=1}}q=U.id}return lM(N,F,$,{containerIndices:Q,entries:X,estimateRegionBounds(U){let V=Q.get(U);return V===void 0?null:X[V]??null},totalHeight:Y})}function zq({block:N,containerIndices:F,entries:M,index:A,options:D,runtimeBlocks:E,totalHeight:$,regions:Z}){let Y=E.get(N.id),X=Y?.regionIds??[];if(X.length===0)return null;let Q=Z.slice(A,A+X.length);if(Q.length===0||Q[0]?.blockId!==N.id)return null;let J=Y?.depth??0,q=D.paddingX+J*D.indentWidth,U=Math.max(K8,D.width-q-D.paddingX),V=Math.max(1,...N.rows.map((H)=>H.cells.length)),y=U/V,G=Math.max(40,y-fN*2),K=w1(N,D.lineHeight),S=Hq(Q,A),_=$;for(let H=0;H<N.rows.length;H+=1){let B=S.get(H)??[],z=Math.max(K+u2*2,...B.map(({region:C})=>iA(C,G,K,D.charWidth)+u2*2)),j=_+z;for(let{index:C,region:L}of B)M[C]={bottom:j,top:_},F.set(L.id,C);_=j}for(let H=A;H<A+Q.length;H+=1){let B=Z[H];if(!B||M[H])continue;M[H]={bottom:_,top:_},F.set(B.id,H)}return{nextIndex:A+Q.length,totalHeight:_}}function Hq(N,F){let M=new Map;for(let[A,D]of N.entries()){let E=D.tableCellPosition?.rowIndex;if(E===void 0)continue;let $=M.get(E)??[];$.push({index:F+A,region:D}),M.set(E,$)}return M}function Bq(N,F,M){return[F.width,F.paddingX,F.paddingY,F.indentWidth,F.lineHeight,F.blockGap,Wq(N,M)].join(":")}function Wq(N,F){if(N.imageUrls.size===0)return"";return N.regions.flatMap((M)=>M.inlines.filter((A)=>A.kind==="image"&&A.image).map((A)=>{let D=A.image?F.images.get(A.image.url):null;return`${A.image?.url??""}:${A.image?.width??0}:${D?.status??"loading"}:${D?.intrinsicWidth??0}:${D?.intrinsicHeight??0}`})).join("|")}function W8(N,F,M,A=null){let D={height:F.height,overscan:Math.max(160,F.height),top:F.top},E=B8(N.documentIndex,F,D,[N.selection.anchor.regionId,N.selection.focus.regionId],M,A);return{blockMap:vN(N.documentIndex.document.blocks),estimateRegionBounds:E.estimateRegionBounds,regionBounds:new Map(E.layout.regionBounds),layout:E.layout,paintHeight:Math.max(240,D.height+D.overscan*2),paintTop:Math.max(0,D.top-D.overscan),totalHeight:E.totalHeight,viewport:{height:D.height,top:D.top}}}function x6(N,F,M){return L0(F.layout,N,M)??m6(F.layout,N,M)}function P8(N,F,M,A){return g6(F.layout,N,M,A)}function O8(N,F,M){return u6(F.layout,N,M)}function eA(N,F,M,A){return I6(F.layout,N,M,A)}function ND(N,F,M,A){return p6(F.layout,N,M,A)}function L8(N,F,M){return d0(F.layout,N.documentIndex,M)}function j1(N,F,M){let A=d0(F.layout,N.documentIndex,M);if(!A)return null;return{...A,left:c0(N,F.layout,A)}}var FD=1;function MD(N,F,M){let A=N.documentIndex.regionOrderIndex.get(N.selection.focus.regionId);if(A===void 0)return N;let D=N.documentIndex.regions[A],E=PN(D.text,N.selection.focus.offset,F);if(E!==N.selection.focus.offset)return b0(N,D.id,E,M);if(F<0){let Z=r1(N.documentIndex,D.id);if(!Z)return N;return b0(N,Z.id,Z.text.length,M)}let $=VN(N.documentIndex,D.id);if(!$)return N;return b0(N,$.id,0,M)}function AD(N,F,M,A,D){let E=I2(F,M.regionId,M.offset);if(!E)return N;let $=F.lines[E.index+A];if(!$)return N;let Z=L0(F,N,{x:c0(N,F,M)+FD,y:$.top+$.height/2});if(!Z)return N;return b0(N,Z.regionId,Z.offset,D)}function DD(N,F,M,A){let D=$D(N,F);if(!D)return N;return b0(N,D.regionId,M==="Home"?D.start:D.end,A)}function ED(N,F,M,A,D){let E=$D(N,F);if(!E)return N;let Z=Math.max(1,Math.floor(480/F.options.lineHeight)),Y=I2(F,E.regionId,N.selection.focus.offset),X=Y?F.lines[Y.index+A*Z]:null;if(!X)return N;let Q=L0(F,N,{x:c0(N,F,M)+FD,y:X.top+X.height/2});if(!Q)return N;return b0(N,Q.regionId,Q.offset,D)}function $D(N,F){return r0(F,N.selection.focus.regionId,N.selection.focus.offset)}var Pq=1;function ZD(N,F,M,A,D){let E=N.documentIndex.regionIndex.get(N.selection.focus.regionId)??null;if(!E)return null;let $=N.documentIndex.tableCellIndex.get(E.id)??null,Z=N.documentIndex.blockIndex.get(E.blockId)??null;if(!$||Z?.type!=="table")return null;let Y=Oq(N,Z.id,$.rowIndex+A,$.cellIndex)??Lq(N,Z.id,A);if(!Y)return N;let X=F.regionBounds.get(E.id),Q=F.regionBounds.get(Y.id);if(!X||!Q)return N;let J=Q.top+Tq(M.top+M.height/2-X.top,0,Math.max(0,Q.bottom-Q.top-1)),q=L0(F,N,{x:c0(N,F,M)+Pq,y:J});if(!q)return N;return b0(N,q.regionId,q.offset,D)}function Oq(N,F,M,A){return P2(N.documentIndex,F,M,A)}function Lq(N,F,M){let A=N.documentIndex.blockIndex.get(F),D=N.documentIndex.regions,E=A?N.documentIndex.roots[A.rootIndex]?.regionRange:void 0;if(!E)return null;return M<0?D[E.start-1]??null:D[E.end]??null}function Tq(N,F,M){return Math.max(F,Math.min(M,N))}function T8(N,F,M=!1){return MD(N,F,M)}function w8(N,F,M,A=!1){return wq(N,F,M,A)}function j8(N,F,M,A=!1){return jq(N,F,M,A)}function C8(N,F,M,A=!1){return DD(N,F,M,A)}function R8(N,F,M=!1){return Cq(N,F,M)}function b8(N,F,M){let A=x6(N,F,M);return A?y0(N,{offset:A.offset,regionId:A.regionId}):null}function f8(N,F,M){let A=x6(N,F,M);return A?b0(N,A.regionId,A.offset,!0):null}function gN(N,F,M,A){let D=P8(N,F,M,A);return D?y0(N,{anchor:A,focus:D}):null}function wq(N,F,M,A){let D=YD(N,F);if(!D)return N;return ZD(N,F,D,M,A)??AD(N,F,D,M,A)}function jq(N,F,M,A){let D=YD(N,F);if(!D)return N;return ED(N,F,D,M,A)}function Cq(N,F,M){let A=N.documentIndex.regions,D=F==="start"?A[0]:A.at(-1);if(!D)return N;return b0(N,D.id,F==="start"?0:D.text.length,M)}function YD(N,F){return d0(F,N.documentIndex,{regionId:N.selection.focus.regionId,offset:N.selection.focus.offset})}var Rq=80;function QD({context:N,containerBounds:F,isHeaderRow:M,lineHeight:A,theme:D}){let E=qD(F,A);N.fillStyle=M?D.tableHeaderBackground:D.tableBodyBackground,N.fillRect(E.left,E.top,E.width,E.height),UD(N,E,D)}function JD({activeBlockFlashes:N,activeBlockId:F,activeRegionId:M,context:A,editorState:D,endIndex:E,layout:$,regionBounds:Z,startIndex:Y,theme:X,verticalBleed:Q}){if(!F||!M)return;let J=D.documentIndex.blockIndex.get(F)??null;if(J?.type!=="table")return;if((D.documentIndex.regionIndex.get(M)??null)?.blockId!==F)return;let U=Z.get(M)??null,V=$.regionLineIndices.get(M)??null;if(!U||!V||V.length===0)return;let y=$.lines[V[0]]??null;if(!y)return;let G=qD(U,y.height);if(G.width===0)return;let K=XD({context:A,endIndex:E,fillStyle:X.activeBlockBackground,layout:$,left:G.left,lineIndices:V,startIndex:Y,verticalBleed:Q,width:G.width}),S=J.path?N.get(J.path)??null:null;if(S)XD({context:A,endIndex:E,fillStyle:tF(X.activeBlockFlash,S),layout:$,left:G.left,lineIndices:V,startIndex:Y,verticalBleed:Q,width:G.width});if(!K)return;UD(A,G,X)}function XD({context:N,endIndex:F,fillStyle:M,layout:A,left:D,lineIndices:E,startIndex:$,verticalBleed:Z,width:Y}){N.fillStyle=M;let X=!1;for(let Q of E){if(Q<$)continue;if(Q>=F)break;let J=A.lines[Q];N.fillRect(D,J.top-Z,Y,J.height),X=!0}return X}function qD(N,F){return{height:Math.max(N.bottom-N.top,F),left:N.left,top:N.top,width:Math.max(N.right-N.left,Rq)}}function UD(N,F,M){N.strokeStyle=M.tableBorder,N.strokeRect(F.left,F.top,F.width,F.height)}var l6=2,bq=3,fq=12,vq=6,hq=3,kq=8,mq=12,gq=28,uq=4,VD=1,Iq=5,pq=2,xq=1;function KD(N,F,M,A,D,E,$){if(!A||F.start!==0)return;if(M?.type==="code"){let Z=Math.max(0,F.left-mq);N.fillStyle=E.codeBackground,N.fillRect(Z,A.top-uq,Math.max(A.right-F.left+gq,$-Z),A.bottom-A.top+kq);return}if(M?.type!=="table")return;QD({context:N,containerBounds:A,isHeaderRow:D?.rowIndex===0,lineHeight:F.height,theme:E})}function GD(N,F,M,A,D,E,$,Z){if(F.blockId!==D||M?.type==="table")return;let Y=A?E.get(A)??null:null;if(N.fillStyle=$.activeBlockBackground,N.fillRect(0,F.top-l6,Z,F.height),!Y)return;N.fillStyle=tF($.activeBlockFlash,Y),N.fillRect(0,F.top-l6,Z,F.height)}function yD(N,F,M,A,D,E){let $=new Map;for(let Z=A;Z<D;Z+=1){let Y=N.lines[Z],X=M.get(Y.blockId);if(X?.type!=="heading"||X.depth!==1&&X.depth!==2)continue;let Q=$.get(X.id),J={bottom:Y.top+Y.height,left:Y.left+f0(F,Y),right:E-N.options.paddingX};$.set(X.id,Q?{bottom:Math.max(Q.bottom,J.bottom),left:Q.left,right:Q.right}:J)}return $}function SD(N,F,M,A,D,E){for(let $=M;$<A;$+=1){let Z=F.blocks[$];if(Z.type==="divider"){let Y=F.options.paddingX+Z.depth*F.options.indentWidth,X=E-F.options.paddingX,Q=Math.round(Z.top+(Z.bottom-Z.top-VD)/2);zD(N,{color:D.dividerRule??D.headingRule,left:Y,right:X,thickness:VD,top:Q})}}}function _D(N,F,M){for(let A of F.values())zD(N,{color:M.headingRule,left:A.left,minimumWidth:pq,right:A.right,thickness:xq,top:A.bottom+Iq})}function zD(N,F){N.fillStyle=F.color,N.fillRect(F.left,F.top,Math.max(F.minimumWidth??0,F.right-F.left),F.thickness)}function HD(N,F,M,A,D){let E=new Map;for(let $=A;$<D;$+=1){let Z=N.lines[$],Y=q1(F,Z.blockId,"blockquote");if(!Y)continue;let X=E.get(Y.id),Q={bottom:Z.top+Z.height,isActive:Z.blockId===M,left:N.options.paddingX+(Y.depth+1)*N.options.indentWidth-10,top:Z.top};E.set(Y.id,X?{bottom:Math.max(X.bottom,Q.bottom),isActive:X.isActive||Q.isActive,left:X.left,top:Math.min(X.top,Q.top)}:Q)}return E}function BD(N,F,M){for(let A of F.values())N.fillStyle=A.isActive?M.blockquoteRuleActive:M.blockquoteRule,N.fillRect(A.left,A.top+bq,hq,Math.max(fq,A.bottom-A.top-vq))}var lq=1,dq=2,aq=2;function v8({context:N,devicePixelRatio:F,editorState:M,height:A,layout:D,normalizedSelection:E,presence:$,showCaret:Z,theme:Y,viewportTop:X,width:Q}){N.save(),N.scale(F,F),N.clearRect(0,0,Q,A);let J=E.start.regionId===E.end.regionId&&E.start.offset!==E.end.offset,q=Z&&!J;if(N.translate(0,-X),q)WD(N,M,D,{color:Y.caret,offset:M.selection.focus.offset,regionId:M.selection.focus.regionId});if($)for(let U of $){if(!U.cursorPoint)continue;WD(N,M,D,{color:U.color??Y.leafAccent,offset:U.cursorPoint.offset,regionId:U.cursorPoint.regionId})}N.restore()}function WD(N,F,M,A){let D=d0(M,F.documentIndex,{regionId:A.regionId,offset:A.offset});if(!D)return;let E=c0(F,M,D),$=rq(M,D);N.fillStyle=A.color,N.fillRect(E,$.top,dq,$.height)}function rq(N,F){let M=r0(N,F.regionId,F.offset),A=M?.font??'16px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',{ascent:D,descent:E}=D1(A),$=Math.max(1,D+E),Z=Math.min(F.height-aq,$),Y=M?Math.max(M.top,M.top+hN(M.height,A)-lq):F.top+Math.max(0,Math.floor((F.height-Z)/2));return{height:Z,top:Y}}var PD=2,OD=8,cq=3,sq=1.5,iq=2,p2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function LD(N,F,M,A,D,E,$=null){if(!M||F.start!==0)return;if($){let Z=t9($),Y=NU(M,F,A,D,N);N.save(),N.translate(Y.x,Y.y),N.scale(Z,Z),N.translate(-Y.x,-Y.y)}if(M.kind==="task")oq(N,F,M.checked,E,$);else if(N.fillStyle=$?_N(E.listMarkerText,$,E):E.listMarkerText,M.kind==="ordered")eq(N,M.label,A,D);else N.fillText(M.label,F.left-PD,D);if($)N.restore()}function oq(N,F,M,A,D=null){let E=n1(F);if(nq(N,E,M,A,D),!M)return;tq(N,E,A,D)}function nq(N,F,M,A,D=null){let E=M?A.checkboxCheckedFill:A.checkboxUncheckedFill,$=M?A.checkboxCheckedStroke:A.checkboxUncheckedStroke;N.fillStyle=D?_N(E,D,A):E,N.strokeStyle=D?_N($,D,A):$,N.beginPath(),N.lineWidth=sq,N.roundRect(F.left,F.top,F.size,F.size,cq),N.fill(),N.stroke()}function tq(N,F,M,A=null){N.strokeStyle=A?_N(M.checkboxCheckmark,A,M):M.checkboxCheckmark,N.lineWidth=iq,N.beginPath(),N.moveTo(F.left+p2.start.x,F.top+p2.start.y),N.lineTo(F.left+p2.elbow.x,F.top+p2.elbow.y),N.lineTo(F.left+p2.end.x,F.top+p2.end.y),N.stroke()}function eq(N,F,M,A){let D=N.textAlign;N.textAlign="right",N.fillText(F,M-OD,A),N.textAlign=D}function NU(N,F,M,A,D){if(N.kind==="task"){let Z=n1(F);return{x:Z.left+Z.size/2,y:Z.top+Z.size/2}}let E=D.measureText(N.label),$=A-(E.actualBoundingBoxAscent-E.actualBoundingBoxDescent)/2;if(N.kind==="ordered")return{x:M-OD-E.width/2,y:$};return{x:F.left-PD+E.width/2,y:$}}var FU=2,MU=1,AU=2,DU=5,EU=2,$U=3;function TD(N,F){let M=N.documentIndex.regionOrderIndex,A=M.get(F.start.regionId),D=M.get(F.end.regionId);return A===void 0||D===void 0?null:{end:D,start:A}}function wD(N,F,M,A,D,E){if(!D)return;let $=F.documentIndex.regionOrderIndex.get(M.regionId);if($===void 0||$<D.start||$>D.end)return;let Z=$===D.start?Math.max(M.start,A.start.offset):M.start,Y=$===D.end?Math.min(M.end,A.end.offset):M.end;if(Y<=Z)return;N.fillStyle=E.selectionBackground,N.fillRect(J1(F,M,Z-M.start),M.top+MU,Math.max(FU,J1(F,M,Y-M.start)-J1(F,M,Z-M.start)),M.height-AU)}function jD(N,F,M,A,D,E){for(let $ of A){if($.regionId!==M.regionId)continue;let Z=Math.max($.startOffset,M.start),Y=Math.min($.endOffset,M.end);if(Y<=Z)continue;N.fillStyle=ZU($,D,E),N.fillRect(J1(F,M,Z-M.start),M.top+M.height-DU,Math.max(EU,J1(F,M,Y-M.start)-J1(F,M,Z-M.start)),$U)}}function ZU(N,F,M){if(N.resolved)return N.threadIndex===F?M.commentHighlightResolvedActive:M.commentHighlightResolved;return N.threadIndex===F?M.commentHighlightActive:M.commentHighlight}function CD(N,F){let M=[];if(F.includes("italic"))M.push("italic");if(F.includes("bold"))M.push("700");return M.length>0?`${M.join(" ")} ${N}`:N}function bD(N,F,M,A,D,E,$){let Z=M.image?A.images.get(M.image.url):null,Y=QU(M,A,$),X=JU(F,E,$,Y);if(N.fillStyle=D.imageSurfaceBackground,N.fillRect(X.left,X.top,X.width,X.height),Z?.status==="loaded"&&Z.source)N.drawImage(Z.source,X.left,X.top,X.width,X.height);else YU(N,D,{...X,status:Z?.status==="error"?"error":"loading"});N.strokeStyle=D.imageSurfaceBorder,N.strokeRect(X.left,X.top,X.width,X.height)}function YU(N,F,M){let A=M.status==="loading"?"Loading image":"Image unavailable",D=qU(M),E=M.top+M.height/2+D.size*0.9;if(N.save(),N.beginPath(),N.rect(M.left,M.top,M.width,M.height),N.clip(),M.status==="loading")XU(N,F,M);N.strokeStyle=F.imagePlaceholderIcon,N.lineWidth=1.5,N.strokeRect(D.left,D.top,D.size,D.size),N.beginPath(),N.arc(D.left+D.size*0.28,D.top+D.size*0.3,D.size*0.1,0,Math.PI*2),N.moveTo(D.left+D.size*0.12,D.top+D.size*0.82),N.lineTo(D.left+D.size*0.42,D.top+D.size*0.5),N.lineTo(D.left+D.size*0.58,D.top+D.size*0.66),N.lineTo(D.left+D.size*0.78,D.top+D.size*0.38),N.lineTo(D.left+D.size*0.88,D.top+D.size*0.82),N.stroke(),N.font='500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',N.fillStyle=F.imagePlaceholderText,N.textAlign="center",N.textBaseline="middle",N.fillText(A,M.left+M.width/2,E),N.restore()}function XU(N,F,M){let A=Math.max(48,Math.round(M.width*0.22)),D=M.width+A*2,E=performance.now()%1800/1800,$=M.left-A+D*E,Z=N.createLinearGradient($,M.top,$+A,M.top);Z.addColorStop(0,"rgba(255,255,255,0)"),Z.addColorStop(0.5,F.imageLoadingOverlay),Z.addColorStop(1,"rgba(255,255,255,0)"),N.fillStyle=Z,N.fillRect(M.left,M.top,M.width,M.height)}function QU(N,F,M){if(!N.image)return RD(M);let A=F.images.get(N.image.url);if(!A||A.intrinsicWidth<=0||A.intrinsicHeight<=0)return RD(M);return Math.max(48,Math.round(M*(A.intrinsicHeight/A.intrinsicWidth)))}function JU(N,F,M,A){return{height:A,left:F,top:N.top+Math.max(0,Math.floor((N.height-A)/2)),width:M}}function qU(N){let F=Math.max(18,Math.min(34,Math.round(Math.min(N.width,N.height)*0.18)));return{left:N.left+Math.max(12,Math.round((N.width-F)/2)),size:F,top:N.top+Math.max(12,Math.round(N.height/2-F*0.95))}}function RD(N){return Math.max(48,Math.round(N*0.5625))}var UU=5,fD=-1,vD=3,VU=1;function hD(N,F,M,A,D,E){if(!M.mention)return;let $=F.top+o1(F.height,N.font),Z=D1(N.font),Y=$-Z.ascent-vD+fD,X=Z.ascent+Z.descent+vD*2,Q=Math.max(0,E-D);N.fillStyle=A.mentionBackground??A.inlineCodeBackground,KU(N,D,Y,Q,X,UU),N.fillStyle=A.mentionText??A.linkText,N.fillText(`@${M.mention.name}`,D+jA,$+fD+VU)}function KU(N,F,M,A,D,E){let $=Math.min(E,A/2,D/2);N.beginPath(),N.roundRect(F,M,A,D,$),N.fill()}var GU=6,kD=3,yU=12,SU=10,_U=2,mD=4,zU=4,HU=1.5,gD=2,uD=1.25;function pD(N,F,M,A,D,E,$,Z,Y){if(!M){N.fillStyle=$,N.fillText(F.text,A,D);return}let X=M.inlines.filter((Q)=>Q.end>F.start&&Q.start<F.end);if(X.length===0){N.fillStyle=$,N.fillText(F.text,A,D);return}for(let Q of X){let J=Math.max(F.start,Q.start),q=Math.min(F.end,Q.end);if(M.text.slice(J,q).length===0)continue;let{left:V,right:y}=h8(F,A,J,q),G=CD(F.font,Q.marks);if(N.font=G,Q.kind==="image"){let K=Math.max(24,y-V);bD(N,F,Q,Z,Y,V,K);continue}if(Q.kind==="mention"){hD(N,F,Q,Y,V,y);continue}if(Q.kind==="code"){WU(N,F,G,Y,V,y),ID(N,F,M.text,A,D,J,q,Y.inlineCodeText,E,Y,{strikethrough:!1,underline:!1});continue}ID(N,F,M.text,A,D,J,q,Q.link?Y.linkText:$,E,Y,{strikethrough:Q.marks.includes("strikethrough"),underline:Q.marks.includes("underline")||Boolean(Q.link)})}}function ID(N,F,M,A,D,E,$,Z,Y,X,Q){let J=c9(E,$,Y).filter((q)=>BU(M,E,$,q));for(let q=0;q<J.length-1;q+=1){let U=J[q],V=J[q+1];if(V<=U)continue;let y=M.slice(U,V);if(y.length===0)continue;let{left:G,right:K}=h8(F,A,U,V),S=s9(Y,U,V),_=i9(Z,S,X);if(N.fillStyle=_,N.fillText(y,G,D),Q.strikethrough)N.fillRect(G,PU(D,F.height,N.font),Math.max(gD,K-G),uD);if(Q.underline)N.fillRect(G,OU(D,F.height,N.font),Math.max(gD,K-G),uD)}}function BU(N,F,M,A){if(A<=F||A>=M)return!0;let D=F;for(let E of X1(N.slice(F,M))){if(D+=E.length,D===A)return!0;if(D>A)return!1}return!1}function xD(N,F,M,A,D,E,$){if(!M||E.length===0)return;for(let Z of E){if(Z.startOffset<F.start||Z.startOffset>F.end)continue;let Y=A+(B0(F,Z.startOffset-F.start)-F.left);N.fillStyle=o9($,Z),N.fillText(Z.text,Y,D)}}function lD(N,F,M,A,D,E,$){if(!M||E.length===0)return;for(let Z of E){if(Z.offset<F.start||Z.offset>=F.end)continue;let{left:Y,right:X}=h8(F,A,Z.offset,Z.offset+1),Q=Math.max(mD,(X-Y)/2+mD+zU*Z.progress),{ascent:J,descent:q}=D1(F.font),U=D-Math.max(1,J*0.42)+Math.max(0.5,q*0.15);N.strokeStyle=n9(Z,$),N.lineWidth=HU,N.beginPath(),N.arc((Y+X)/2,U,Q,0,Math.PI*2),N.stroke()}}function WU(N,F,M,A,D,E){let $=hN(F.height,M),Z=F.top+$+_U,Y=Math.max(yU,F.height-$-GU);N.fillStyle=A.inlineCodeBackground,N.fillRect(D-kD,Z,Math.max(SU,E-D+kD*2),Y)}function PU(N,F,M){let{ascent:A}=D1(M),D=N-o1(F,M);return Math.max(D+2,N-Math.round(A*0.32))}function OU(N,F,M){let{descent:A}=D1(M),D=Math.max(1,Math.round(Math.max(2,A)*0.35)),E=N+A-D,$=N-o1(F,M);return Math.min($+F-4,E)}function h8(N,F,M,A){return{left:F+(B0(N,M-N.start)-N.left),right:F+(B0(N,A-N.start)-N.left)}}function k8(N,F,M,A){LU({activeBlockId:A.activeBlockId,activeRegionId:A.activeRegionId,activeThreadIndex:A.activeThreadIndex,containerLineBounds:F.regionBounds,context:M,devicePixelRatio:A.devicePixelRatio,editorState:N,height:A.height,layout:F.layout,liveCommentRanges:A.liveCommentRanges,normalizedSelection:A.normalizedSelection,now:A.now,resources:A.resources??{images:new Map},runtimeBlockMap:F.blockMap,theme:A.theme,viewportTop:F.paintTop,width:A.width})}function m8(N,F,M,A){v8({context:M,devicePixelRatio:A.devicePixelRatio,editorState:N,height:A.height,layout:F.layout,normalizedSelection:A.normalizedSelection,presence:A.presence,showCaret:A.showCaret,theme:A.theme,viewportTop:F.paintTop,width:A.width})}function LU({activeBlockId:N,activeRegionId:F,activeThreadIndex:M,containerLineBounds:A,context:D,devicePixelRatio:E,editorState:$,height:Z,layout:Y,liveCommentRanges:X,normalizedSelection:Q,now:J=CU(),resources:q,runtimeBlockMap:U,theme:V,viewportTop:y,width:G}){D.save(),D.scale(E,E),D.clearRect(0,0,G,Z),D.fillStyle=V.background,D.fillRect(0,0,G,Z),D.textBaseline="alphabetic",D.translate(0,-y);let{endIndex:K,startIndex:S}=h6(Y,y,Z),_=TD($,Q),H=l9($,J),B=d9($,J),z=x9($,J),j=r9($,J),C=a9($,J),L=HD(Y,$,N,S,K),W=yD(Y,$,U,S,K,G);for(let v=S;v<K;v+=1){let m=Y.lines[v];KD(D,m,U.get(m.blockId)??null,A.get(m.regionId)??null,$.documentIndex.tableCellIndex.get(m.regionId)??null,V,G)}let O=v6(Y,y,Z);SD(D,Y,O.startIndex,O.endIndex,V,G),JD({activeBlockFlashes:H,activeBlockId:N,activeRegionId:F,context:D,editorState:$,endIndex:K,layout:Y,regionBounds:A,startIndex:S,theme:V,verticalBleed:l6});for(let v=S;v<K;v+=1){let m=Y.lines[v];TU({activeBlockId:N,activeBlockFlashes:H,activeTextFades:B,activeTextHighlights:z,activeBlockPulses:j,activeTextPulses:C,activeThreadIndex:M,context:D,editorState:$,line:m,liveCommentRanges:X,normalizedSelection:Q,resources:q,runtimeBlockMap:U,selectionRegionOrderRange:_,theme:V,width:G})}_D(D,W,V),BD(D,L,V),D.restore()}function TU({activeBlockId:N,activeBlockFlashes:F,activeTextFades:M,activeTextHighlights:A,activeBlockPulses:D,activeTextPulses:E,activeThreadIndex:$,context:Z,editorState:Y,line:X,liveCommentRanges:Q,normalizedSelection:J,resources:q,runtimeBlockMap:U,selectionRegionOrderRange:V,theme:y,width:G}){let K=U.get(X.blockId)??null,S=Y.documentIndex.blockIndex.get(X.blockId)?.path??null,_=Y.documentIndex.regionIndex.get(X.regionId)??null,H=_?.path??"",B=q1(Y,X.blockId,"listItem"),z=B?t1(Y,B.id):null,j=B?D.get(B.path)??null:null,C=X.left+f0(Y,X),L=wU(X),W=K?.type==="code"?y.codeText:jU(K,y);Z.font=X.font,GD(Z,X,K,S,N,F,y,G),wD(Z,Y,X,J,V,y),jD(Z,Y,X,Q,$,y),LD(Z,X,z,C,L,y,j),pD(Z,X,_,C,L,A.get(H)??[],W,q,y),xD(Z,X,_,C,L,M.get(H)??[],W),lD(Z,X,_,C,L,E.get(H)??[],y)}function wU(N){return N.top+o1(N.height,N.font)}function jU(N,F){switch(N?.type){case"heading":return F.headingText;case"blockquote":return F.blockquoteText;case"table":return F.headingText;default:return F.paragraphText}}function CU(){return typeof performance<"u"?performance.now():Date.now()}function dD(N,F,M){return eA(N,F,M,j0(N).liveRanges)}function g8(N,F,M){return ND(N,F,M,j0(N).liveRanges)}import{forwardRef as hU,createElement as kU}from"react";var d6=(...N)=>N.filter((F,M,A)=>{return Boolean(F)&&F.trim()!==""&&A.indexOf(F)===M}).join(" ").trim();var aD=(N)=>N.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var rD=(N)=>N.replace(/^([A-Z])|[\s-_]+(\w)/g,(F,M,A)=>A?A.toUpperCase():M.toLowerCase());var u8=(N)=>{let F=rD(N);return F.charAt(0).toUpperCase()+F.slice(1)};import{forwardRef as vU,createElement as iD}from"react";var a6={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var cD=(N)=>{for(let F in N)if(F.startsWith("aria-")||F==="role"||F==="title")return!0;return!1};import{createContext as RU,useContext as bU,useMemo as KO,createElement as GO}from"react";var fU=RU({});var sD=()=>bU(fU);var oD=vU(({color:N,size:F,strokeWidth:M,absoluteStrokeWidth:A,className:D="",children:E,iconNode:$,...Z},Y)=>{let{size:X=24,strokeWidth:Q=2,absoluteStrokeWidth:J=!1,color:q="currentColor",className:U=""}=sD()??{},V=A??J?Number(M??Q)*24/Number(F??X):M??Q;return iD("svg",{ref:Y,...a6,width:F??X??a6.width,height:F??X??a6.height,stroke:N??q,strokeWidth:V,className:d6("lucide",U,D),...!E&&!cD(Z)&&{"aria-hidden":"true"},...Z},[...$.map(([y,G])=>iD(y,G)),...Array.isArray(E)?E:[E]])});var h=(N,F)=>{let M=hU(({className:A,...D},E)=>kU(oD,{ref:E,iconNode:F,className:d6(`lucide-${aD(u8(N))}`,`lucide-${N}`,A),...D}));return M.displayName=u8(N),M};var mU=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],C1=h("columns-2",mU);var gU=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],R1=h("rows-3",gU);var uU=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],b1=h("send-horizontal",uU);var IU=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],uN=h("arrow-down",IU);var pU=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],IN=h("arrow-up",pU);var xU=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],pN=h("bold",xU);var lU=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],e1=h("check",lU);var dU=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],xN=h("chevron-down",dU);var aU=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],lN=h("heading-1",aU);var rU=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],dN=h("heading-2",rU);var cU=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],aN=h("heading-3",cU);var sU=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],rN=h("heading-5",sU);var iU=[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]],cN=h("heading-4",iU);var oU=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]],sN=h("heading-6",oU);var nU=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],iN=h("heading",nU);var tU=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],oN=h("italic",tU);var eU=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],nN=h("list-ordered",eU);var NV=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],tN=h("list-todo",NV);var FV=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],eN=h("list",FV);var MV=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],NF=h("message-square-plus",MV);var AV=[["path",{d:"M5 12h14",key:"1ays0h"}]],FF=h("minus",AV);var DV=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],N2=h("pencil",DV);var EV=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],x2=h("plus",EV);var $V=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],MF=h("strikethrough",$V);var ZV=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],f1=h("table-2",ZV);var YV=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],AF=h("text-quote",YV);var XV=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],I0=h("trash-2",XV);var QV=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],DF=h("underline",QV);var JV=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],EF=h("x",JV);import{jsx as l2,jsxs as KV}from"react/jsx-runtime";function nD({insetX:N,insetY:F,onSelect:M,presence:A}){if(!A)return null;return l2("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${N}px`,top:`${F}px`},children:A.map((D)=>l2(qV,{onSelect:()=>M(D),presence:D},D.id))})}function qV({onSelect:N,presence:F}){let M=F.viewport,A=UV(F),D=M?.status==="above"?IN:uN,E=M!==null&&M.status!=="unresolved",$=M?.status==="above"||M?.status==="below";return KV("button",{"aria-label":VV(F),className:"documint-presence-indicator","data-status":M?.status??"unresolved",disabled:!E,onClick:E?N:void 0,style:{"--documint-presence-color":F.color??"var(--documint-leaf-accent)"},type:"button",children:[l2("span",{className:"documint-presence-indicator-avatar",children:F.avatarUrl?l2("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:F.avatarUrl}):A}),$?l2("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:l2(D,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3})}):null]})}function UV(N){return tD(N).charAt(0).toLocaleUpperCase()}function VV(N){let F=tD(N),M=N.viewport?.status??"unresolved";if(M==="above")return`${F} above viewport`;if(M==="below")return`${F} below viewport`;if(M==="unresolved")return`${F} unresolved`;return`${F} in viewport`}function tD(N){return(N.fullName??N.username).trim()||"Presence"}var a=`
28
- `,d2="<ins>",$F="</ins>",a2=">",ZF="```",r6=":::",c6="documint-comments";var XF="\\",i6="`",DE=":",YF=" ",p8="![",eD="@[",x8="[",l8="(",NE=")",FE=/[\p{L}\p{N}]/u,GV=/[A-Za-z]/,yV=/[-A-Za-z0-9_]/,s6=/\{width=([1-9]\d*)\}/y,SV=/\\([\\`*_[\]{}()#+\-.!~|@])/g,EE=/\\(.)/g,$E=[{delimiter:"**",mark:"bold",requireWordBoundary:!1},{delimiter:"~~",mark:"strikethrough",requireWordBoundary:!1},{delimiter:"*",mark:"italic",requireWordBoundary:!1},{delimiter:"_",mark:"italic",requireWordBoundary:!0}],_V=new Set($E.map((N)=>N.delimiter[0]));function QF(N){return o6(N,0,N.length,[])}function o6(N,F,M,A){let D=[],E=F,$=F;while(E<M){let Z=zV(N,E,M,A);if(Z){let Y=Math.max($,E-(Z.trimLeading??0));ME(D,N.slice($,Y),A),D.push(...Z.nodes),E=Z.end,$=E;continue}if(N[E]===XF){E+=Math.min(2,M-E);continue}E+=1}return ME(D,N.slice($,M),A),G0(D)}function zV(N,F,M,A){let D=N[F];switch(D){case DE:return HV(N,F,M);case"<":return OV(N,F,M)??BV(N,F,M,A)??WV(N,F,M);case XF:return LV(N,F,M);case a:return TV(N,F);case i6:return wV(N,F,M);case"!":return jV(N,F,M);case"@":return CV(N,F,M);case x8:return RV(N,F,M,A)}if(D!==void 0&&_V.has(D))return fV(N,F,M,A);return null}function HV(N,F,M){if(N[F]!==DE||!GV.test(N[F+1]??""))return null;let A=F+2;while(A<M&&yV.test(N[A]??""))A+=1;let D=AE(N,A,M,"[","]"),$=AE(N,D?.end??A,M,"{","}")?.end??D?.end??A;return{end:$,nodes:[ZE("textDirective",N.slice(F,$))]}}function BV(N,F,M,A){if(!N.startsWith(d2,F))return null;let D=N.indexOf($F,F+d2.length);if(D<0||D>=M)return null;return{end:D+$F.length,nodes:o6(N,F+d2.length,D,[...A,"underline"])}}function WV(N,F,M){if(N[F]!=="<")return null;let A=N.indexOf(">",F+1);if(A<0||A>=M)return null;return{end:A+1,nodes:[ZE("html",N.slice(F,A+1))]}}var PV=/^<br\s*\/?>/i;function OV(N,F,M){if(N[F]!=="<")return null;let A=PV.exec(N.slice(F,M));if(!A)return null;let D=F+A[0].length;return{end:N[D]===a?D+1:D,nodes:[e0()]}}function LV(N,F,M){if(N[F]!==XF||N[F+1]!==a||F+1>=M)return null;return{end:F+2,nodes:[e0()]}}function TV(N,F){if(N[F]!==a||N[F-1]!==YF||N[F-2]!==YF)return null;let M=0;while(N[F-1-M]===YF)M+=1;return{end:F+1,nodes:[e0()],trimLeading:M}}function wV(N,F,M){if(N[F]!==i6)return null;let A=1;while(F+A<M&&N[F+A]===i6)A+=1;let D=i6.repeat(A),E=N.indexOf(D,F+A);if(E<0||E>=M)return null;return{end:E+A,nodes:[_1(N.slice(F+A,E))]}}function jV(N,F,M){if(!N.startsWith(p8,F))return null;let A=a8(N,F+1,M);if(A<0||N[A+1]!==l8)return null;let D=d8(N,A+1,M);if(!D)return null;let E=bV(N,D.end,M);return{end:E?.end??D.end,nodes:[z1({alt:r8(N.slice(F+p8.length,A)),title:D.title,url:D.url,width:E?.width??null})]}}function CV(N,F,M){if(!N.startsWith(eD,F))return null;let A=a8(N,F+1,M);if(A<0||N[A+1]!==l8)return null;let D=d8(N,A+1,M);if(!D||D.title!==null)return null;return{end:D.end,nodes:[Q2({name:r8(N.slice(F+eD.length,A)),userId:D.url})]}}function RV(N,F,M,A){if(N[F]!==x8||N.startsWith(p8,F-1))return null;let D=a8(N,F,M);if(D<0||N[D+1]!==l8)return null;let E=d8(N,D+1,M);if(!E)return null;return{end:E.end,nodes:[u1({children:o6(N,F+x8.length,D,A),title:E.title,url:E.url})]}}function d8(N,F,M){let A=I8(N,F+1,M),D=A;while(D<M&&N[D]!==NE&&N[D]!==YF){if(N[D]===XF){D+=2;continue}D+=1}if(D===A)return null;let E=vV(N.slice(A,D));A=I8(N,D,M);let $=null;if(A<M&&N[A]==='"'){let Z=n6(N,'"',A+1,M);if(Z<0)return null;$=N.slice(A+1,Z).replace(EE,"$1"),A=I8(N,Z+1,M)}if(N[A]!==NE)return null;return{end:A+1,title:$,url:E}}function bV(N,F,M){s6.lastIndex=F;let A=s6.exec(N);if(!A||s6.lastIndex>M)return null;return{end:s6.lastIndex,width:Number(A[1])}}function fV(N,F,M,A){for(let D of $E){if(!N.startsWith(D.delimiter,F))continue;let E=n6(N,D.delimiter,F+D.delimiter.length,M);if(E<0)continue;if(D.requireWordBoundary){let Z=F>0?N[F-1]:"",Y=N[E+D.delimiter.length]??"";if(FE.test(Z)||FE.test(Y))continue}let $=F+D.delimiter.length;return{end:E+D.delimiter.length,nodes:o6(N,$,E,[...A,D.mark])}}return null}function ME(N,F,M){if(F.length===0)return;N.push(O0(r8(F),M))}function AE(N,F,M,A,D){if(N[F]!==A)return null;let E=n6(N,D,F+1,M);if(E<0)return null;return{end:E+1}}function a8(N,F,M){return n6(N,"]",F+1,M)}function n6(N,F,M,A){for(let D=M;D<A;D+=1){if(N[D]===XF){D+=1;continue}if(N.startsWith(F,D))return D}return-1}function I8(N,F,M){while(F<M&&N[F]===YF)F+=1;return F}function r8(N){return N.replace(SV,"$1")}function vV(N){return N.replace(EE,"$1")}function ZE(N,F){return TF({originalType:N,source:F})}var hV=/^:?-+:?$/;function XE(N,F){let M=V0(N),A=s8(N,1),D=W0(M,F),E=W0(A,F);if(!YE(D)||!c8(E))return null;let $=[t6(D)],Z=kV(E);N.index+=2;while(N.index<N.lines.length){let Y=V0(N),X=W0(Y,F);if(v1(Y)||!YE(X))break;$.push(t6(X)),N.index+=1}return x1({align:Z,rows:$.map((Y)=>J2(Y.map((X)=>H1(QF(X)))))})}function c8(N){let F=t6(N);return F.length>0&&F.every((M)=>hV.test(M.trim()))}function YE(N){let F=N.trim();return F.startsWith("|")&&F.endsWith("|")}function kV(N){return t6(N).map((F)=>{let M=F.trim();if(M.startsWith(":")&&M.endsWith(":"))return"center";if(M.startsWith(":"))return"left";if(M.endsWith(":"))return"right";return null})}function t6(N){let F=N.trim();if(!F.startsWith("|")||!F.endsWith("|"))return[];return F.slice(1,-1).split("|").map((M)=>M.trim())}var mV=3,QE=/^(#{1,6})\s+(.*)$/,gV=/\s+#+\s*$/u,uV=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,IV=/^\d+\.$/,pV=/^\[( |x|X)\](?:\s|$)/,JE=/^```([^\s`]*)?(?:\s+(.*))?$/,qE=/^:::([A-Za-z][-\w]*)(.*)$/,xV=[/^(\*\s*){3,}$/,/^(-\s*){3,}$/,/^(_\s*){3,}$/];function N3(N,F,M){let A=[];while(N.index<N.lines.length){let D=V0(N);if(N.index===N.lines.length-1&&D==="")break;if(v1(D)){N.index+=1;continue}if(r2(D)>F+mV)break;let E=lV(N,F,M);if(!E)break;A.push(E)}return A}function lV(N,F,M){return dV(N,F,M)??aV(N,F)??rV(N,F)??sV(N,F)??iV(N,F)??XE(N,F)??oV(N,F,M)??tV(N,F)??eV(N,F)}function dV(N,F,M){let A=V0(N);if(!W0(A,F).startsWith(a2))return null;let D=[];while(N.index<N.lines.length){let E=V0(N),$=r2(E);if(v1(E)){D.push(""),N.index+=1;continue}if($<F)break;let Z=W0(E,F);if(!Z.startsWith(a2))break;let Y=Z.slice(1);if(Y.startsWith(" "))Y=Y.slice(1);D.push(Y),N.index+=1}return x0(N3({index:0,lines:D},0,M))}function aV(N,F){let M=V0(N),A=W0(M,F),D=JE.exec(A);if(!D)return null;N.index+=1;let E=[];while(N.index<N.lines.length){let $=V0(N),Z=W0($,F);if(Z.trim()===ZF){N.index+=1;break}E.push(Z),N.index+=1}return v3({language:D[1]?D[1]:null,meta:D[2]?D[2]:null,source:E.join(a)})}function rV(N,F){let M=V0(N),A=W0(M,F),D=qE.exec(A);if(!D)return null;let E=D[1],$=[];N.index+=1;while(N.index<N.lines.length){let Z=V0(N),Y=W0(Z,F);if(Y.trim()===r6){N.index+=1;break}$.push(Y),N.index+=1}return A9({attributes:cV(D[2]??""),body:$.join(a),name:E})}function cV(N){let F=N.trim();if(F.startsWith("{")&&F.endsWith("}"))return F.slice(1,-1);return F}function sV(N,F){let M=V0(N),A=QE.exec(W0(M,F));if(!A)return null;return N.index+=1,LF({children:QF(A[2].replace(gV,"")),depth:A[1].length})}function iV(N,F){let M=W0(V0(N),F).trim();if(!UE(M))return null;return N.index+=1,wF()}function oV(N,F,M){let A=e6(V0(N),F);if(!A)return null;let D=[],E=!1;while(N.index<N.lines.length){let $=V0(N),Z=e6($,F);if(!Z||Z.ordered!==A.ordered)break;N.index+=1;let Y=[Z.content],X=!1;while(N.index<N.lines.length){let Q=V0(N),J=r2(Q);if(v1(Q)){let q=MK(N.lines,N.index+1);if(q<0||r2(N.lines[q]??"")<=F)break;X=!0,Y.push(""),N.index+=1;continue}if(J<Z.contentIndent)break;if(J===F&&e6(Q,F))break;Y.push(FK(Q,Z.contentIndent)),N.index+=1}E||=X,D.push(I1({checked:Z.checked,children:nV(Y,M),spread:X}))}return p1({items:D,ordered:A.ordered,spread:E,start:A.ordered&&M.preserveOrderedListStart?A.start??1:null})}function e6(N,F){let M=uV.exec(N);if(!M||M[1].length!==F)return null;let A=M[2],D=IV.test(A),E=D?Number(A.slice(0,-1)):null,$=M[3]??"",Z=null;if(pV.test($)){if(Z=$[1]==="x"||$[1]==="X",$=$.slice(3),$.startsWith(" "))$=$.slice(1)}let Y=M[0].length-M[1].length-M[2].length-$.length;return{checked:Z,content:$,contentIndent:F+M[2].length+Y,ordered:D,start:E}}function nV(N,F){let M=N3({index:0,lines:N},0,F);if(M.length>0)return M;return[t0([])]}function tV(N,F){let M=W0(V0(N),F).trim();if(!VE(M))return null;return N.index+=1,h3({originalType:"html",source:M})}function eV(N,F){let M=[];while(N.index<N.lines.length){let A=V0(N),D=r2(A);if(v1(A))break;if(D<F)break;let E=W0(A,F);if(M.length>0&&NK(A,E,F))break;M.push(E),N.index+=1}return t0(QF(M.join(a)))}function NK(N,F,M){let A=F.trim();return F.startsWith(a2)||JE.test(F)||qE.test(F)||QE.test(F)||UE(A)||c8(F)||e6(N,M)!==null||VE(A)}function r2(N){let F=0;while(F<N.length&&N[F]===" ")F+=1;return F}function FK(N,F){let M=r2(N);if(M>=F)return N.slice(F);return N.trim()===""?"":N.slice(Math.min(M,F))}function MK(N,F){for(let M=F;M<N.length;M+=1)if(!v1(N[M]??""))return M;return-1}function UE(N){return xV.some((F)=>F.test(N))}function VE(N){return N.startsWith("<")&&N.endsWith(">")}function GE(N){let F=N.at(-1),M=F&&KE(F)?F:null;return{blocks:N.filter((D)=>!KE(D)),comments:M?AK(M.body):[]}}function AK(N){let F;try{F=JSON.parse(N)}catch{return[]}if(!Array.isArray(F))return[];return F.flatMap((M)=>{let A=o3(M);return A?[A]:[]})}function KE(N){return N.type==="directive"&&N.name===c6}var yE="---";function JF(N,F={}){let A={index:0,lines:N.replace(/\r\n/g,a).split(a)},D=DK(A),E=N3(A,0,F),{comments:$,blocks:Z}=GE(E);return V2(Z,$,D)}function DK(N){if(N.lines[0]!==yE)return;for(let F=1;F<N.lines.length;F+=1)if(N.lines[F]===yE){let M=N.lines.slice(0,F+1).join(a);return N.index=F+1,M}return}function V0(N){return s8(N,0)}function s8(N,F){return N.lines[N.index+F]??""}function v1(N){return N.trim()===""}function W0(N,F){return N.slice(F)}var EK=/([\\`*_[\]])/g,$K=/([\\)&])/g,ZK=/(["\\])/g;function E1(N){let F=G0(N);return F.map((M,A)=>YK(M,F[A+1])).join("")}function YK(N,F){switch(N.type){case"lineBreak":return"<br>";case"image":return JK(N);case"mention":return qK(N);case"code":return QK(N.code);case"link":return UK(N);case"text":return XK(i8(N.text,F),N.marks);case"raw":return N.source}}function XK(N,F){return F.reduce((M,A)=>{switch(A){case"bold":return`**${M}**`;case"italic":return`*${M}*`;case"strikethrough":return`~~${M}~~`;case"underline":return`${d2}${M}${$F}`}},N)}function QK(N){let F=0,M=0;for(let $ of N){if($==="`"){if(M+=1,M>F)F=M;continue}M=0}let A=F>0?F+1:1,D="`".repeat(A),E=N.startsWith("`")||N.endsWith("`")?` ${N} `:N;return`${D}${E}${D}`}function JK(N){let F=i8(N.alt??""),M=SE(N.url,N.title),A=N.width?`{width=${N.width}}`:"";return`![${F}]${M}${A}`}function qK(N){return`@[${i8(N.name)}](${_E(N.userId)})`}function UK(N){return`[${E1(N.children)}]${SE(N.url,N.title)}`}function SE(N,F){return`(${_E(N)}${VK(F)})`}function i8(N,F){let M=N.replace(EK,"\\$1").replace(/@(?=\[)/g,"\\@");return F?.type==="link"&&M.endsWith("@")?`${M.slice(0,-1)}\\@`:M}function _E(N){return N.replace($K,"\\$1")}function VK(N){return N?` "${N.replace(ZK,"\\$1")}"`:""}var HE=3;function BE(N,F,M){let A=N.rows.map((Q)=>Q.cells.map((J)=>E1(J.children))),D=Math.max(1,...A.map((Q)=>Q.length)),E=A[0]??[],$=Array.from({length:D},(Q,J)=>Math.max(SK(N.align[J]),...M.padTableColumns?A.map((q)=>q[J]?.length??0):[E[J]?.length??0])),Z=KK($,N.align,F),Y=zE(E,$,N.align,F,M),X=A.slice(1).map((Q)=>zE(Q,$,N.align,F,M));return[Y??GK($,F),Z,...X].join(a)}function zE(N,F,M,A,D){let E=F.map(($,Z)=>{let Y=N[Z]??"";if(!D.padTableColumns)return Y;return _K(Y,$,M[Z])});return`${" ".repeat(A)}| ${E.join(" | ")} |`}function KK(N,F,M){let A=N.map((D,E)=>yK(F[E],D));return`${" ".repeat(M)}| ${A.join(" | ")} |`}function GK(N,F){return`${" ".repeat(F)}| ${N.map((M)=>"".padEnd(M," ")).join(" | ")} |`}function yK(N,F){let M=WE(N),A=Math.max(HE,F-M),D="-".repeat(A);switch(N){case"center":return`:${D}:`;case"left":return`:${D}`;case"right":return`${D}:`;default:return D}}function SK(N){return HE+WE(N)}function WE(N){if(N==="center")return 2;return N?1:0}function _K(N,F,M){if(M==="right")return N.padStart(F," ");return N.padEnd(F," ")}var F2=`
29
-
30
- `,zK="-",HK=".",BK="---",WK="&#x20;";function qF(N,F={}){return N.map((M)=>F3(M,0,F)).join(F2)}function F3(N,F,M){let A=M2(F);switch(N.type){case"blockquote":return PK(N,F,M);case"code":return OK(N,F);case"directive":return LK(N,F);case"heading":return PE(N,F);case"list":return TK(N,F,M);case"listItem":return OE(N,F,!1,1,M);case"paragraph":return`${A}${o8(E1(N.children))}`;case"table":return BE(N,F,M);case"divider":return`${A}${BK}`;case"raw":return F===0?N.source:LE(N.source,F)}}function PK(N,F,M){let A=N.children.map((E)=>F3(E,0,M)).join(F2),D=M2(F);return A.split(a).map((E)=>`${D}${a2}${E.length>0?` ${E}`:""}`).join(a)}function OK(N,F){let M=[N.language??"",N.meta??""].filter(Boolean).join(" ").trim(),A=M2(F),D=`${A}${ZF}${M?M:""}`,E=N.source.length>0?N.source.split(a).map(($)=>`${A}${$}`).join(a):A;return`${D}${a}${E}${a}${A}${ZF}`}function LK(N,F){let M=M3(N);return F===0?M:LE(M,F)}function M3(N){let F=N.attributes?`{${N.attributes}}`:"";return`:::${N.name}${F}${a}${N.body}${a}${r6}`}function PE(N,F){let M=o8(E1(N.children)),A=`${M2(F)}${"#".repeat(N.depth)}`;return M.length>0?`${A} ${M}`:A}function TK(N,F,M){let A=N.start??1;return N.items.map((D)=>OE(D,F,N.ordered,A,M)).join(N.spread?F2:a)}function OE(N,F,M,A,D){let E=M?`${A}${HK}`:zK,$=N.checked===null?"":`[${N.checked?"x":" "}] `,Z=`${M2(F)}${E} ${$}`,Y=F+E.length+1,X=N.children;if(X.length===0)return $.length>0?Z:Z.trimEnd();let[Q,...J]=X,q=wK(Q,Z,$.length>0,D),U=J.map((V)=>F3(V,Y,D)).join(N.spread?F2:a);if(!U)return q;return`${q}${N.spread?F2:a}${U}`}function wK(N,F,M,A){switch(N.type){case"paragraph":{let D=o8(E1(N.children));if(D.length===0)return M?F:F.trimEnd();return`${F}${D}`}case"heading":return`${F}${PE(N,0)}`;case"directive":case"raw":{let D=N.type==="directive"?M3(N):N.source,[E,...$]=D.split(a);return[F+E,...$.map((Z)=>`${M2(F.length)}${Z}`)].join(a)}default:{let D=F.length;return`${F.trimEnd()}${a}${F3(N,D,A)}`}}}function o8(N){return N.replace(/^ +/gm,(F)=>WK.repeat(F.length))}function M2(N){return" ".repeat(N)}function LE(N,F){let M=M2(F);return N.split(a).map((A)=>`${M}${A}`).join(a)}function A3(N,F={}){if(N.blocks.length===0&&N.comments.length===0&&N.frontMatter===void 0)return"";let M=[];if(N.frontMatter!==void 0)M.push(N.frontMatter);if(N.blocks.length>0)M.push(qF(N.blocks,F));if(N.comments.length>0)M.push(jK(N.comments));let A=M.join(F2);return A.endsWith(a)?A:`${A}${a}`}function jK(N){return M3({attributes:"",body:JSON.stringify(N,null,2),name:c6})}function n8(N){if(N.length===0)return{kind:"text",text:""};let{blocks:F}=JF(N);if(RF(F))return{kind:"text",text:F[0]?.plainText??""};if(F.length===1&&F[0]?.type==="paragraph")return{kind:"inlines",inlines:F[0].children};return{kind:"blocks",blocks:F}}function A2(N){switch(N.kind){case"text":return N.text;case"inlines":return E1(N.inlines);case"blocks":return qF(N.blocks)}}import{createContext as CK,useContext as RK}from"react";import{createPortal as bK}from"react-dom";import{jsx as CE}from"react/jsx-runtime";var TE=CK(void 0);function wE({children:N,themeStyles:F}){return CE(TE.Provider,{value:F,children:N})}function jE({children:N}){let F=RK(TE);if(typeof document>"u")return null;return bK(CE("div",{className:"documint-overlay",style:{display:"contents",...F},children:N}),document.body)}import{useEffect as Q3,useRef as M$,useState as D2}from"react";import{useEffect as fK,useRef as vK}from"react";import{jsx as t8,jsxs as gK}from"react/jsx-runtime";var hK="documint-leaf-menu-item documint-completion-item";function D3({activeIndex:N,matches:F,onHover:M,onSelect:A}){let D=vK(null);return fK(()=>{let E=D.current;if(!E)return;let $=E.children[N];if($ instanceof HTMLElement)$.scrollIntoView({block:"nearest"})},[N]),t8("div",{className:"documint-completion-leaf",ref:D,role:"listbox",children:F.map((E,$)=>{let Z=$===N;return gK("button",{"aria-selected":Z,className:`${hK}${Z?" is-active":""}`,onPointerDown:kK,onPointerEnter:()=>M($),onClick:()=>A(E),role:"option",type:"button",children:[E.icon?t8("span",{"aria-hidden":"true",className:"documint-completion-item-icon",children:E.icon}):null,t8("span",{children:E.label})]},mK(E))})})}function kK(N){N.preventDefault()}function mK(N){return N.id??`${N.kind??""}:${N.label}:${N.insertText??""}:${N.icon??""}`}import{useCallback as eK,useRef as NG}from"react";import{useCallback as UF,useEffect as dK,useEffectEvent as aK,useLayoutEffect as rK,useMemo as cK,useState as pE}from"react";import{useCallback as e8,useEffect as RE,useRef as bE,useState as fE}from"react";function E3({activeCompletion:N,contextKey:F,onAccept:M,onDismiss:A}){let[D,E]=fE(0),[$,Z]=fE(null),Y=bE(!1),X=bE(null),Q=N?F??IK(N):null,J=Q===$||Q===X.current?null:N,q=J?Math.min(D,Math.max(0,J.matches.length-1)):D;RE(()=>{E(0),X.current=null},[Q]),RE(()=>{if(!Q||$&&Q!==$)Z(null)},[Q,$]);let U=e8((K)=>{if(!J||!Q||X.current===Q)return;X.current=Q,Z(Q),M(K,J)},[Q,M,J]),V=e8((K)=>{if(!J||J.matches.length===0)return!1;if(K.key==="ArrowDown")return K.preventDefault(),K.stopPropagation(),E((S)=>(S+1)%J.matches.length),!0;if(K.key==="ArrowUp")return K.preventDefault(),K.stopPropagation(),E((S)=>(S-1+J.matches.length)%J.matches.length),!0;if(K.key==="Enter"||K.key==="Tab"){K.preventDefault(),K.stopPropagation(),Y.current=!0;let S=J.matches[q];if(S)U(S);return!0}if(K.key==="Escape")return K.preventDefault(),K.stopPropagation(),Z(Q),A?.(),!0;return!1},[U,Q,q,A,J]),y=e8((K)=>{if(Y.current&&vE(K.inputType))return Y.current=!1,K.preventDefault(),K.stopPropagation(),!0;if(!J||J.matches.length===0)return Y.current=!1,!1;if(uK(K.inputType))return K.preventDefault(),K.stopPropagation(),!0;if(!vE(K.inputType))return Y.current=!1,!1;K.preventDefault(),K.stopPropagation();let S=J.matches[q];if(S)U(S);return!0},[U,q,J]),G=J&&J.matches.length>0?{activeIndex:q,matches:J.matches,onHover:E,onSelect:U}:null;return{activeIndex:q,handleBeforeInput:y,handleKeyDown:V,leafProps:G}}function vE(N){return N==="insertLineBreak"||N==="insertParagraph"}function uK(N){return N==="insertReplacementText"}function IK(N){return[N.trigger,N.triggerStart,N.caret,N.query].join(":")}function hE(N){if(!N?.length)return[];return N.map((F)=>({trigger:F.trigger,items:[...F.items].sort((M,A)=>M.label.localeCompare(A.label,void 0,{sensitivity:"base"}))}))}function kE(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.trigger===F.trigger&&N.items.length===F.items.length&&N.items.every((M,A)=>mE(M,F.items[A]))}function mE(N,F){return N.id===F.id&&N.icon===F.icon&&N.insertText===F.insertText&&N.kind===F.kind&&N.label===F.label}function gE(N,F){return N.length===F.length&&N.every((M,A)=>mE(M,F[A]))}function Z3(N,F,M){for(let A=F-1;A>=0;A-=1){let D=N[A];if($3(D))return null;let E=M.find((Z)=>Z.trigger===D);if(!E)continue;if(A>0&&!$3(N[A-1]))return null;let $=N.slice(A+1,F);return{trigger:E.trigger,query:$,triggerStart:A,caret:F,matches:pK(E.items,$)}}return null}function pK(N,F){if(!F)return N.slice(0,50);let M=F.toLowerCase(),A=[];for(let D of N)if(D.label.toLowerCase().includes(M)){if(A.push(D),A.length>=50)break}return A}function uE(N,F,M){let A=N5(F,M),D=N.slice(0,F.triggerStart),E=N.slice(F.caret);return{caret:F.triggerStart+A.length,value:D+A+E}}function N5(N,F){return F.insertText??`${N.trigger}${F.label} `}function Y3(N,F){if(!F?.length||!F.some(($)=>N.includes($.trigger)))return[{kind:"text",text:N}];let M=new Map;for(let $ of F){let Z=[...$.items].sort((Y,X)=>X.label.length-Y.label.length);M.set($.trigger,Z)}let A=[],D=0,E=0;while(D<N.length){let $=N[D],Z=M.get($);if(Z!==void 0&&(D===0||$3(N[D-1]))){let X=Z.find((Q)=>{if(!N.startsWith(Q.label,D+1))return!1;return xK(N[D+1+Q.label.length])});if(X){if(D>E)A.push({kind:"text",text:N.slice(E,D)});A.push({kind:"token",trigger:$,label:X.label,id:X.id}),D+=1+X.label.length,E=D;continue}}D+=1}if(E<N.length)A.push({kind:"text",text:N.slice(E)});return A}function $3(N){return N===void 0||N===" "||N===`
31
- `||N==="\t"}function xK(N){return N===void 0||$3(N)||!/[\p{L}\p{N}_]/u.test(N)}var lK=["box-sizing","width","height","overflow-x","overflow-y","border-top-width","border-right-width","border-bottom-width","border-left-width","border-style","padding-top","padding-right","padding-bottom","padding-left","font-style","font-variant","font-weight","font-stretch","font-size","font-size-adjust","line-height","font-family","text-align","text-transform","text-indent","text-decoration","letter-spacing","word-spacing","tab-size"];function IE(N,F,{scrollX:M=window.scrollX,scrollY:A=window.scrollY}={}){if(!N.isConnected)return null;let D=getComputedStyle(N),E=document.createElement("div");for(let Q of lK)E.style.setProperty(Q,D.getPropertyValue(Q));Object.assign(E.style,{position:"absolute",top:"0",left:"0",visibility:"hidden",whiteSpace:"pre-wrap",wordWrap:"break-word",width:`${N.clientWidth}px`}),E.textContent=N.value.slice(0,F);let $=document.createElement("span");$.textContent=N.value.slice(F)||".",E.appendChild($),document.body.appendChild(E);let Z=N.getBoundingClientRect(),Y=parseFloat(D.lineHeight)||$.offsetHeight,X={anchorHeight:Y,left:M+Z.left+$.offsetLeft+parseFloat(D.borderLeftWidth)-N.scrollLeft,top:A+Z.top+$.offsetTop+parseFloat(D.borderTopWidth)+Y-N.scrollTop};return document.body.removeChild(E),X}function xE({completionSources:N,onChange:F,textareaRef:M,value:A}){let[D,E]=pE(null),[$,Z]=pE(null),Y=D?.triggerStart??null,X=cK(()=>hE(N),[N]),Q=UF((K,S)=>{if(!X.length){E(null);return}let _=Z3(K,S,X);if(!_){E(null);return}E(_)},[X]),J=UF((K)=>{let S=K.currentTarget.value,_=K.currentTarget.selectionEnd??S.length;F(S),Q(S,_)},[F,Q]),q=UF((K)=>{let S=K.currentTarget;Q(S.value,S.selectionEnd??S.value.length)},[Q]),U=UF(()=>{E(null)},[]),V=UF((K,S)=>{if(!M.current)return;let H=uE(A,S,sK(K));F(H.value),E(null),requestAnimationFrame(()=>{let B=M.current;if(!B)return;B.focus(),B.setSelectionRange(H.caret,H.caret)})},[F,M,A]),y=E3({activeCompletion:D,onAccept:V,onDismiss:U}),G=aK((K)=>{y.handleBeforeInput(K)});return dK(()=>{let K=M.current;if(!K)return;return K.addEventListener("beforeinput",G),()=>K.removeEventListener("beforeinput",G)},[M]),rK(()=>{if(Y===null){Z(null);return}let K=()=>{let S=M.current;if(!S)return;let _=IE(S,Y);Z(_?{anchorHeight:_.anchorHeight,bridge:!1,left:_.left,paddingY:4,top:_.top}:null)};return K(),window.addEventListener("scroll",K,!0),window.addEventListener("resize",K),()=>{window.removeEventListener("scroll",K,!0),window.removeEventListener("resize",K)}},[Y,M]),{activeCompletion:D,anchor:$,handleBlur:U,handleChange:J,handleKeyDown:y.handleKeyDown,handleSelect:q,leafProps:y.leafProps}}function sK(N){return N.kind==="mention"?{...N,insertText:`@${N.label} `}:N}import{useLayoutEffect as iK,useRef as oK,useState as nK}from"react";import{jsx as F5,jsxs as tK}from"react/jsx-runtime";var lE=12;function X3({anchor:N,children:F}){let M=oK(null),[A,D]=nK("below");return iK(()=>{let E=M.current;if(!E||typeof window>"u")return;let $=()=>{let Y=E.getBoundingClientRect().height,X=window.visualViewport,Q=X?.height??window.innerHeight,J=X?.offsetTop??0,q=N.top-window.scrollY-J,U=Q-q;D(Y+lE>U?"above":"below")};$();let Z=new ResizeObserver($);return Z.observe(E),window.visualViewport?.addEventListener("resize",$),window.addEventListener("resize",$),()=>{Z.disconnect(),window.visualViewport?.removeEventListener("resize",$),window.removeEventListener("resize",$)}},[N.top]),F5(jE,{children:tK("div",{className:"documint-leaf-anchor","data-bridge":N.bridge,"data-placement":A,onPointerEnter:N.onPointerEnter,onPointerLeave:N.onPointerLeave,style:{left:`${N.left}px`,top:`${N.top}px`,"--documint-leaf-anchor-height":`${N.anchorHeight}px`,"--documint-leaf-bridge-height":`${lE}px`,"--documint-leaf-padding-y":`${N.paddingY}px`},children:[N.bridge?F5("div",{className:"documint-leaf-bridge"}):null,F5("div",{className:"documint-leaf-shell",ref:M,children:F})]})})}import{jsx as h1,jsxs as dE,Fragment as MG}from"react/jsx-runtime";function VF({actions:N,autoFocus:F=!1,completionSources:M,onChange:A,placeholder:D,readOnly:E=!1,ref:$,rows:Z=3,saveOnEnter:Y=!1,value:X}){let Q=NG(null),J=$??Q,{activeCompletion:q,anchor:U,handleBlur:V,handleChange:y,handleKeyDown:G,handleSelect:K,leafProps:S}=xE({completionSources:M,onChange:A,textareaRef:J,value:X}),_=eK((H)=>{if(G(H))return;if(H.key==="Escape"&&N.kind==="edit")H.preventDefault(),N.onCancel();if(H.key==="Enter"&&Y){if(H.preventDefault(),N.kind==="edit"&&!N.saveDisabled)N.onSave();else if(N.kind==="compose"&&!N.submitDisabled)N.onSubmit()}},[N,G,Y]);return dE("div",{className:"documint-leaf-input-field",children:[h1("textarea",{autoFocus:F,className:"documint-leaf-input",onBlur:V,onChange:y,onKeyDown:_,onSelect:K,placeholder:D,readOnly:E,ref:J,rows:Z,value:X}),FG(N),q&&U&&S?h1(X3,{anchor:U,children:h1(D3,{...S})}):null]})}function FG(N){if(N.kind==="edit")return dE(MG,{children:[h1(M5,{className:"documint-leaf-input-cancel",icon:EF,label:"Cancel editing",onClick:N.onCancel}),h1(M5,{className:"documint-leaf-input-save",disabled:N.saveDisabled??!1,icon:e1,label:"Save",onClick:N.onSave})]});return h1(M5,{className:"documint-leaf-input-submit",disabled:N.submitDisabled??!1,icon:b1,iconSize:15,label:N.submitLabel,onClick:N.onSubmit})}function M5({className:N,disabled:F=!1,icon:M,iconSize:A=14,label:D,onClick:E}){return h1("button",{"aria-label":D,className:`documint-leaf-action ${N}`,disabled:F,onClick:E,title:D,children:h1(M,{size:A,strokeWidth:2.2})})}import{Fragment as aE}from"react";import{jsx as cE,jsxs as rE}from"react/jsx-runtime";function A5({value:N,completionSources:F,onEdit:M}){return cE("p",{onDoubleClick:M,children:AG(N,F)})}function AG(N,F){let M=Y3(N,F);if(M.length===1&&M[0].kind==="text")return N;return M.map((A,D)=>A.kind==="token"&&A.id?rE("span",{className:"documint-mention",children:[A.trigger,A.label]},D):A.kind==="token"?rE(aE,{children:[A.trigger,A.label]},D):cE(aE,{children:A.text},D))}import{Children as sE,isValidElement as iE,useEffect as DG,useRef as EG,useState as $G}from"react";import{jsx as S0,jsxs as $5}from"react/jsx-runtime";var D5=(N)=>{N.preventDefault()},E5=(N)=>N.isPrimary&&N.button===0;function ZG({children:N}){return S0("div",{className:"documint-leaf-toolbar",children:sE.map(N,YG)})}function YG(N){if(!iE(N))return null;if(N.type===nE){let F=N.props;return S0(oE,{children:S0(XG,{...F})})}if(N.type===tE){let{className:F}=N.props;return S0("div",{className:KF("documint-leaf-toolbar-divider",F)})}if(N.type===eE){let F=N.props;return S0(JG,{...F})}return null}function XG({active:N=!1,className:F,disabled:M=!1,icon:A,label:D,onClick:E}){return S0("button",{"aria-label":D,className:KF("documint-leaf-toolbar-button",N?"active":null,F),disabled:M,onPointerDown:($)=>{if(D5($),!M&&E5($))E()},title:D,type:"button",children:S0(QG,{icon:A})})}function QG({icon:N}){return S0(N,{size:15,strokeWidth:2.2})}function JG({children:N,className:F,icon:M,label:A,onSelect:D}){let E=EG(null),[$,Z]=$G(!1);return DG(()=>{if(!$)return;let Y=(X)=>{if(E.current&&X.target instanceof Node&&!E.current.contains(X.target))Z(!1)};return window.addEventListener("pointerdown",Y),()=>{window.removeEventListener("pointerdown",Y)}},[$]),S0(oE,{children:$5("div",{className:"documint-leaf-toolbar-menu-shell",ref:E,children:[S0(qG,{className:F,icon:M,isOpen:$,label:A,onClick:()=>Z((Y)=>!Y)}),$?S0("div",{className:"documint-leaf-menu",role:"menu",children:sE.map(N,(Y)=>UG(Y,(X)=>{Z(!1),D(X)}))}):null]})})}function qG({className:N,icon:F,isOpen:M,label:A,onClick:D}){return $5("button",{"aria-expanded":M,"aria-haspopup":"menu","aria-label":A,className:KF("documint-leaf-toolbar-button",M?"active":null,N),onPointerDown:(E)=>{if(D5(E),E5(E))D()},title:A,type:"button",children:[S0(F,{size:15,strokeWidth:2.2}),S0(xN,{className:KF("documint-leaf-toolbar-menu-chevron",M?"is-open":null),size:13,strokeWidth:2.2})]})}function UG(N,F){if(!iE(N))return null;if(N.type===F$){let{className:$}=N.props;return S0("div",{className:KF("documint-leaf-menu-divider",$),role:"separator"})}if(N.type!==N$)return null;let{disabled:M=!1,icon:A,text:D,value:E}=N.props;return $5("button",{className:"documint-leaf-menu-item",disabled:M,onPointerDown:($)=>{if(D5($),!M&&E5($))F(E)},role:"menuitem",type:"button",children:[S0(A,{size:15,strokeWidth:2.2}),S0("span",{children:D})]})}function KF(...N){return N.filter(Boolean).join(" ")}function oE({children:N}){return S0("div",{className:"documint-leaf-toolbar-group",children:N})}function nE(N){return null}function tE(N){return null}function eE(N){return null}function N$(N){return null}function F$(N){return null}var l=Object.assign(ZG,{Button:nE,Divider:tE,Menu:eE,MenuDivider:F$,MenuItem:N$});import{jsx as n,jsxs as $1,Fragment as yG}from"react/jsx-runtime";var VG=!1,KG=220,E2=()=>{};function Z5(N){let F=N.mode==="create",M=N.mode==="create"?N:null,A=N.mode==="thread"?N:null,D=N.canEdit,E=N.link,$=A?.thread??null,Z=$?.comments??[],Y=Z[0]??null,X=$?W1($):!1,Q=A?.animateInitialComment??!1,[J,q]=D2(null),[U,V]=D2(""),[y,G]=D2(""),[K,S]=D2(""),[_,H]=D2(!Q),[B,z]=D2(VG),[j,C]=D2(!1),L=M$(null),W=M$(null),O=N.completionSources,v=$?M4($):null,m=v?A$(v):"",d=D&&!X,P=d&&U.trim().length>0,f=d&&y.trim().length>0,b=D&&K.trim().length>0,u=F||j,o=!F||B,R=!F&&Boolean($),k=Boolean(Y),r=F?B:!0,D0=A?.onDeleteComment??E2,w=A?.onDeleteThread??E2,p=A?.onToggleResolved??E2,s=M?.activeMarks??[],i=M?.onToggleBold??E2,k0=M?.onToggleItalic??E2,z0=M?.onToggleStrikethrough??E2,t2=M?.onToggleUnderline??E2,e2=M?.actions??[],PF=D?F?"Add a comment":"Reply to this comment":"Comment editing is disabled",m0=F?K:y;Q3(()=>{if(J!==null&&(J<0||J>=Z.length))q(null),V("")},[Z.length,J]),Q3(()=>{if(!k||!Q){H(!0);return}H(!1);let K0=requestAnimationFrame(()=>{H(!0)});return()=>{cancelAnimationFrame(K0)}},[Q,Y,k]),Q3(()=>{if(!A||!Q){C(!1);return}C(!0);let K0=window.setTimeout(()=>{C(!1)},KG);return()=>{window.clearTimeout(K0)}},[Q,A]),Q3(()=>{if(!F||!B||!D)return;let K0=requestAnimationFrame(()=>{W.current?.focus()});return()=>{cancelAnimationFrame(K0)}},[D,F,B]);let p0=()=>{q(null),V("")},G1=(K0,NN)=>{if(!R||!d)return;q(K0),V(NN)},P3=(K0)=>{if(!A)return;A.onEditComment(K0,U),p0()},O3=()=>{if(!A)return;A.onReply(y),G("")},Y2=()=>{if(!M||!b)return;M.onCreateThread(K),S("")},L3=u?`documint-comment-leaf documint-comment-leaf-create${r?" is-expanded":""}`:"documint-comment-leaf",y1=R||k||o?n(GG,{canCreate:b,canEdit:D,canMutateThread:d,canReply:f,canSaveEditedComment:P,comments:Z,composerRef:W,editDraft:U,editingCommentIndex:J,isComposerVisible:o,isInitialCommentVisible:_,isResolved:X,link:E,completionSources:O,mode:N.mode,onBeginEditingComment:G1,onCancelEditing:p0,onChangeCreateDraft:S,onChangeEditDraft:V,onChangeReplyDraft:G,onDeleteComment:D0,onDeleteThread:w,onSubmitCreate:Y2,onSubmitEditedComment:P3,onSubmitReply:O3,onToggleResolved:p,rootComment:Y,showRootComment:k,showThreadChrome:R,threadAge:m,composerPlaceholder:PF,composerValue:m0}):null;return n("div",{className:L3,"data-resolved":X?"true":void 0,ref:L,children:$1("div",{className:u?"documint-comment-leaf-create-shell":void 0,children:[u?$1(l,{children:[n(l.Button,{className:"documint-comment-leaf-create-button",icon:NF,label:"Add comment",onClick:()=>z(!0)}),n(l.Divider,{}),n(l.Button,{active:s.includes("bold"),className:"documint-comment-leaf-create-mark",icon:pN,label:"Bold",onClick:i}),n(l.Button,{active:s.includes("italic"),className:"documint-comment-leaf-create-mark",icon:oN,label:"Italic",onClick:k0}),n(l.Button,{active:s.includes("underline"),className:"documint-comment-leaf-create-mark",icon:DF,label:"Underline",onClick:t2}),n(l.Button,{active:s.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:MF,label:"Strikethrough",onClick:z0}),e2.length>0?[n(l.Divider,{},"actions-divider"),...e2.map((K0,NN)=>{return n(l.Button,{className:"documint-comment-leaf-create-mark",icon:K0.icon,label:K0.label,onClick:()=>K0.onClick()},`${K0.label}:${NN}`)})]:null]}):null,n("div",{className:u?"documint-comment-leaf-create-content":void 0,children:y1})]})})}function GG({canCreate:N,canEdit:F,canMutateThread:M,canReply:A,canSaveEditedComment:D,comments:E,composerRef:$,editDraft:Z,editingCommentIndex:Y,isComposerVisible:X,isInitialCommentVisible:Q,isResolved:J,link:q,completionSources:U,mode:V,onBeginEditingComment:y,onCancelEditing:G,onChangeCreateDraft:K,onChangeEditDraft:S,onChangeReplyDraft:_,onDeleteComment:H,onDeleteThread:B,onSubmitCreate:z,onSubmitEditedComment:j,onSubmitReply:C,onToggleResolved:L,rootComment:W,showRootComment:O,showThreadChrome:v,threadAge:m,composerPlaceholder:d,composerValue:P}){return $1(yG,{children:[v?$1("div",{className:"documint-comment-leaf-header",children:[n("span",{className:"documint-comment-leaf-age",children:m}),$1("div",{className:"documint-comment-leaf-actions",children:[n("button",{className:"documint-leaf-action","aria-label":J?"Reopen comment":"Resolve comment",disabled:!F,onClick:L,title:J?"Reopen comment":"Resolve comment",type:"button",children:n(e1,{size:14,strokeWidth:2.2})}),n("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!F,onClick:B,title:"Delete comment thread",type:"button",children:n(I0,{size:14,strokeWidth:2.2})})]})]}):null,v&&q?$1("div",{className:"documint-comment-leaf-link",children:[q.title?n("div",{className:"documint-link-leaf-title",children:q.title}):null,n("div",{className:"documint-link-leaf-url",children:q.url})]}):null,$1("div",{className:`documint-comment-thread${O?"":" is-empty"}`,children:[n("article",{className:O?`documint-comment-message documint-comment-message-root${Q?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:W?n(A5,{completionSources:U,onEdit:()=>y(0,W.body),value:W.body}):null}),E.slice(1).map((f,b)=>{let u=b+1,o=Y===u;return $1("article",{className:"documint-comment-message",children:[!o?$1("div",{className:"documint-comment-message-meta",children:[n("span",{children:A$(f.updatedAt)}),M?$1("div",{className:"documint-comment-leaf-actions",children:[n("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!M,onClick:()=>{y(u,f.body)},title:"Edit comment",type:"button",children:n(N2,{size:14,strokeWidth:2.2})}),n("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!M,onClick:()=>H(u),title:"Delete comment",type:"button",children:n(I0,{size:14,strokeWidth:2.2})})]}):null]}):null,o?n(VF,{actions:{kind:"edit",onCancel:G,onSave:()=>j(u),saveDisabled:!D},completionSources:U,onChange:S,readOnly:!F,rows:3,value:Z}):n(A5,{completionSources:U,onEdit:()=>y(u,f.body),value:f.body})]},`${f.updatedAt}:${u}`)})]}),n("div",{className:`documint-comment-reply${v?"":" is-standalone"}${X?" is-visible":""}`,children:n(VF,{actions:V==="create"?{kind:"compose",onSubmit:z,submitDisabled:!N,submitLabel:"Create comment"}:{kind:"compose",onSubmit:C,submitDisabled:!A,submitLabel:"Reply"},completionSources:U,onChange:V==="create"?K:_,placeholder:d,readOnly:!F,ref:$,rows:3,value:P})})]})}function A$(N){let F=new Date(N);if(Number.isNaN(F.getTime()))return N;let M=F.getTime()-Date.now(),A=60000,D=60*A,E=24*D,$=7*E,Z=30*E,Y=365*E,X=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(M)<A)return"just now";if(Math.abs(M)<D)return X.format(Math.round(M/A),"minute");if(Math.abs(M)<E)return X.format(Math.round(M/D),"hour");if(Math.abs(M)<$)return X.format(Math.round(M/E),"day");if(Math.abs(M)<Y)return X.format(Math.round(M/Z),"month");return X.format(Math.round(M/Y),"year")}import{jsx as s0,jsxs as zG}from"react/jsx-runtime";var SG=[{icon:lN,label:"Heading 1",text:"# "},{icon:dN,label:"Heading 2",text:"## "},{icon:aN,label:"Heading 3",text:"### "},{icon:cN,label:"Heading 4",text:"#### "},{icon:rN,label:"Heading 5",text:"##### "},{icon:sN,label:"Heading 6",text:"###### "}],_G=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function D$({onInsert:N,onInsertTable:F}){return zG(l,{children:[s0(l.Button,{icon:eN,label:"Insert bulleted list",onClick:()=>N("- ")}),s0(l.Button,{icon:nN,label:"Insert numbered list",onClick:()=>N("1. ")}),s0(l.Button,{icon:tN,label:"Insert task list",onClick:()=>N("- [ ] ")}),s0(l.Divider,{}),s0(l.Menu,{icon:iN,label:"Insert heading",onSelect:N,children:SG.map(({icon:M,label:A,text:D})=>s0(l.MenuItem,{icon:M,text:A,value:D},D))}),s0(l.Menu,{icon:f1,label:"Insert table",onSelect:(M)=>F(Number(M)),children:_G.map(({columns:M,text:A})=>s0(l.MenuItem,{icon:f1,text:A,value:String(M)},M))}),s0(l.Divider,{}),s0(l.Button,{icon:AF,label:"Insert blockquote",onClick:()=>N("> ")}),s0(l.Button,{icon:FF,label:"Insert divider",onClick:()=>N("--- ")})]})}import{useState as E$}from"react";import{jsx as U1,jsxs as GF}from"react/jsx-runtime";function $$({title:N,url:F,canEdit:M,onSave:A,onDelete:D}){let[E,$]=E$(!1),[Z,Y]=E$(""),X=BG(F),Q=WG(F),J=M&&!E,q=M&&Z.trim().length>0,U=HG();return GF("div",{className:"documint-link-leaf",children:[N&&U1("div",{className:"documint-link-leaf-title",children:N}),GF("div",{className:"documint-link-leaf-row",children:[E?U1(VF,{actions:{kind:"edit",onCancel:()=>$(!1),onSave:()=>{A(encodeURI(Z.trim())),$(!1)},saveDisabled:!q},autoFocus:!0,onChange:Y,readOnly:!M,rows:3,saveOnEnter:!0,value:Z}):GF("div",{className:"documint-link-leaf-url-row",children:[Q&&U1("img",{alt:"","aria-hidden":"true",className:"documint-link-leaf-favicon",onError:(G)=>{G.currentTarget.hidden=!0},src:Q},Q),U1("div",{className:"documint-link-leaf-url",children:X})]}),J&&GF("div",{className:"documint-link-leaf-actions",children:[U1("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!M)return;Y(X),$(!0)},title:"Edit link",children:U1(N2,{size:14,strokeWidth:2.2})}),U1("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:D,title:"Remove link",children:U1(I0,{size:14,strokeWidth:2.2})})]})]}),U1("div",{className:"documint-link-leaf-divider"}),GF("div",{className:"documint-link-leaf-hint",children:[U,"click to open"]})]})}function HG(){if(typeof navigator>"u")return"Ctrl+";let N=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test(N)?"CMD+":"CTRL+"}function BG(N){try{return decodeURIComponent(N)}catch{return N}}function WG(N){try{let{hostname:F}=new URL(N);return`https://www.google.com/s2/favicons?domain=${F}&sz=32`}catch{return null}}import{jsx as V1,jsxs as Q5}from"react/jsx-runtime";var PG=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],OG=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],Y5={text:"Delete column",value:"delete"},X5={text:"Delete row",value:"delete"},Z$={text:"Delete table",value:"delete"};function Y$({canDeleteColumn:N,canDeleteRow:F,onDeleteColumn:M,onDeleteRow:A,onDeleteTable:D,onInsertColumn:E,onInsertRow:$}){return Q5(l,{children:[Q5(l.Menu,{icon:C1,label:"Column actions",onSelect:(Z)=>{if(Z===Y5.value){M();return}E(Z)},children:[PG.map(({text:Z,value:Y})=>V1(l.MenuItem,{icon:x2,text:Z,value:Y},Y)),V1(l.MenuDivider,{}),V1(l.MenuItem,{disabled:!N,icon:I0,text:Y5.text,value:Y5.value})]}),Q5(l.Menu,{icon:R1,label:"Row actions",onSelect:(Z)=>{if(Z===X5.value){A();return}$(Z)},children:[OG.map(({text:Z,value:Y})=>V1(l.MenuItem,{icon:x2,text:Z,value:Y},Y)),V1(l.MenuDivider,{}),V1(l.MenuItem,{disabled:!F,icon:I0,text:X5.text,value:X5.value})]}),V1(l.Divider,{}),V1(l.Menu,{icon:f1,label:"Table actions",onSelect:()=>D(),children:V1(l.MenuItem,{icon:I0,text:Z$.text,value:Z$.value})})]})}import{useEffect as C$,useEffectEvent as R$,useRef as b5}from"react";function $2(N,F){return Object.is(N,F)}function J5(N){return(F,M)=>{if(F===M)return!0;if(!F||!M)return!1;return q3(N(F),N(M))}}function J3(N){return(F,M)=>{if(F===M)return!0;if(F.length!==M.length)return!1;return F.every((A,D)=>N(A,M[D]))}}function X$(N,F){return N.regionId===F.regionId&&N.offset===F.offset}function Q$(N,F){return N.collapsed===F.collapsed&&X$(N.start,F.start)&&X$(N.end,F.end)}function J$(N,F){return LG(N.block,F.block)&&TG(N.span,F.span)}function q$(N,F){return wG(N.threads,F.threads)&&jG(N.liveRanges,F.liveRanges)}function q5(N,F){return q3(N,F)}function LG(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.blockId===F.blockId&&N.depth===F.depth&&N.nodeType===F.nodeType&&N.text===F.text}function TG(N,F){if(N===F)return!0;if(N.kind!==F.kind)return!1;switch(N.kind){case"link":return F.kind==="link"&&N.url===F.url;case"marks":return F.kind==="marks"&&q3(N.marks,F.marks);case"none":return!0}return!1}function wG(N,F){return q3(N,F)}function jG(N,F){if(N===F)return!0;if(N.length!==F.length)return!1;return N.every((M,A)=>{let D=F[A];return M.endOffset===D.endOffset&&M.regionId===D.regionId&&M.resolved===D.resolved&&M.startOffset===D.startOffset&&M.threadIndex===D.threadIndex})}function q3(N,F){if(N===F)return!0;if(N.length!==F.length)return!1;return N.every((M,A)=>Object.is(M,F[A]))}function U$(N,F,M){return CG(N,F,M)}function CG(N,F,M){return{previous:N,next:F,source:M==="external"?"external":"local",reason:M,documentChanged:N.documentIndex!==F.documentIndex,animationsChanged:N.animations!==F.animations&&F.animations.length>0}}function V$(N){let F=N,M=0,A=new Set,D=(E,$)=>{if(!E||E===F)return null;let Y=U$(F,E,$);F=E,M+=1;for(let X of A)X(Y);return Y};return{getVersion:()=>M,getState:()=>F,apply(E){return D(E,"command")},command(E,...$){return D(E(F,...$),"command")},replace(E,$="external"){return D(E,$)},subscribe(E){return A.add(E),()=>{A.delete(E)}},subscribeValue(E,$,Z=$2){let Y=E(F),X=(Q)=>{let J=E(Q.next);if(Z(Y,J))return;Y=J,$()};return A.add(X),()=>{A.delete(X)}}}}function K$(){let N=null,F=null,M=null,A=new Set,D=(E)=>{if(N=E,F===E)return;F=E;for(let $ of A)$()};return{get(){if(N)return N;if(!M)throw Error("Viewport resolver has not been registered.");return N=M(),N},invalidate(){N=null},peek(){return N},observeViewport(E){D(E)},peekPublishedViewport(){return F},setViewportResolver(E){M=E},subscribe(E){return A.add(E),()=>{A.delete(E)}}}}import{createContext as RG,useCallback as U5,useContext as bG,useSyncExternalStore as fG}from"react";import{jsx as vG}from"react/jsx-runtime";var G$=RG(null);function V5({children:N,store:F}){return vG(G$.Provider,{value:F,children:N})}function v0(){let N=bG(G$);if(!N)throw Error("Documint store is unavailable outside DocumintStoreProvider.");return N}function I(N){let F=v0().editor;return U5((...M)=>F.command(N,...M),[F,N])}function N0(N,...F){let M=v0(),A=U5((E)=>N.subscribe(M,E,...F),[M,N,...F]),D=U5(()=>N.read(M,...F),[M,N,...F]);return fG(A,D,D)}function y$(N,F){let M=rF(N);if(!M)return null;let A=Z3(M.text,M.offset,F??[]);return A?{...A,regionId:M.regionId}:null}function S$(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.regionId===F.regionId&&N.trigger===F.trigger&&N.query===F.query&&N.triggerStart===F.triggerStart&&N.caret===F.caret&&gE(N.matches,F.matches)}function _$(N,F){let M={endOffset:F.caret,regionId:F.regionId,startOffset:F.triggerStart};if(hG(N,F))return{kind:"mention",name:N.label,target:M,trailingText:" ",userId:N.id};return{endOffset:F.caret,kind:"text",startOffset:F.triggerStart,text:N5(F,N)}}function hG(N,F){return Boolean(N.id)&&(N.kind==="mention"||F.trigger==="@")}var z$=[["100","💯"],["airplane","✈️"],["alarm","⏰"],["angry","😠"],["astonished","😲"],["baby","👶"],["balloon","🎈"],["beer","🍺"],["birthday","🎂"],["blush","😊"],["bomb","💣"],["book","📚"],["boom","💥"],["broken_heart","💔"],["calendar","📅"],["camera","📷"],["cat","😺"],["check","✅"],["clap","👏"],["cold_sweat","😰"],["confetti_ball","🎊"],["confused","😕"],["cool","😎"],["cry","😢"],["disappointed","😞"],["dizzy","💫"],["dog","🐶"],["drooling","🤤"],["eggplant","🍆"],["eyes","👀"],["facepalm","🤦"],["fire","🔥"],["flushed","😳"],["ghost","👻"],["gift","🎁"],["grin","😁"],["grinning","😀"],["halo","😇"],["handshake","🤝"],["heart","❤️"],["heart_eyes","😍"],["hug","🤗"],["joy","😂"],["kiss","😘"],["laughing","😆"],["light_bulb","💡"],["loudspeaker","📢"],["love_letter","💌"],["melting","🫠"],["mind_blown","🤯"],["money_mouth","🤑"],["monocle","🧐"],["muscle","💪"],["nauseated","🤢"],["nerd","🤓"],["neutral","😐"],["ok_hand","👌"],["partying","🥳"],["pensive","😔"],["pizza","🍕"],["pleading","🥺"],["poop","💩"],["pray","🙏"],["raised_hands","🙌"],["relieved","😌"],["rocket","🚀"],["rofl","🤣"],["rolling_eyes","🙄"],["rose","🌹"],["scream","😱"],["see_no_evil","🙈"],["shushing","🤫"],["sleeping","😴"],["slightly_smiling","🙂"],["smile","😄"],["smiley","😃"],["smirk","😏"],["sob","😭"],["sparkles","✨"],["star","⭐"],["star_struck","🤩"],["sweat_smile","😅"],["tada","🎉"],["thinking","🤔"],["thumbs_down","👎"],["thumbs_up","👍"],["tired","😫"],["triumph","😤"],["unamused","😒"],["upside_down","🙃"],["warning","⚠️"],["wave","👋"],["weary","😩"],["wink","😉"],["woozy","🥴"],["writing","✍️"],["yawn","🥱"],["yum","😋"],["zany","🤪"],["zipper_mouth","🤐"]];var U3={trigger:":",items:z$.map(mG)};function mG(N){if(N.length!==2)throw Error("Emoji completion rows must be [label, value] tuples.");let[F,M]=N;return{label:F,icon:M,insertText:M}}function K5(N){if(!N?.length)return null;return{trigger:"@",items:N.map((F)=>({id:F.id,kind:"mention",label:F.fullName??F.username})).sort((F,M)=>F.label.localeCompare(M.label,void 0,{sensitivity:"base"}))}}function yF(N,F){return N.anchor.regionId===F.anchor.regionId&&N.anchor.offset===F.anchor.offset&&N.leftOverride===F.leftOverride&&N.paddingY===F.paddingY}function G5(N,F,M){if(!N||N.kind==="task-toggle")return null;if(N.commentThreadIndex!==null){let A=F[N.commentThreadIndex]??null,D=M.find((E)=>E.threadIndex===N.commentThreadIndex);if(!A||!D)return null;return{anchor:{regionId:D.regionId,offset:D.startOffset},animateInitialComment:!1,kind:"thread",link:N.kind==="link"?{title:N.title,url:N.url}:null,resolved:W1(A),thread:A,threadIndex:N.commentThreadIndex}}if(N.kind!=="link")return null;return{anchor:{regionId:N.regionId,offset:N.startOffset},endOffset:N.endOffset,kind:"link",regionId:N.regionId,startOffset:N.startOffset,title:N.title,url:N.url}}function h0(N,F,M=$2){return i0(N,(A,D,...E)=>F(A,...E),M)}function B$(N){let F=Object.entries(N),M=F.map(([,A])=>A);return h0(M,(A,...D)=>{let E={};for(let $=0;$<F.length;$++){let[Z]=F[$];E[Z]=D[$]}return E},gG)}function i0(N,F,M=$2){let A=new WeakMap,D=(E,...$)=>{let Z=N.map((J)=>J.read(E)),Y=A.get(E);if(Y&&H$(Y.depValues,Z)&&H$(Y.params,$))return Y.value;let X=F(E,$,...Z),Q=Y&&M(Y.value,X)?Y.value:X;return A.set(E,{depValues:Z,params:$,value:Q}),Q};return{read:D,subscribe(E,$,...Z){let Y=D(E,...Z),X=()=>{let J=D(E,...Z);if(M(Y,J))return;Y=J,$()},Q=N.map((J)=>J.subscribe(E,X));return()=>{for(let J of Q)J()}}}}function gG(N,F){if(N===F)return!0;let M=Object.keys(N),A=Object.keys(F);if(M.length!==A.length)return!1;return M.every((D)=>Object.is(N[D],F[D]))}function H$(N,F){return N.length===F.length&&N.every((M,A)=>Object.is(M,F[A]))}function y5({read:N,subscribe:F}){return{read:N,subscribe:F}}function V3(N,F=$2){return y5({read:(M)=>N(M.editor.getState()),subscribe:(M,A)=>M.editor.subscribeValue(N,A,F)})}var o0=y5({read:(N)=>N.viewport.peekPublishedViewport(),subscribe:(N,F)=>N.viewport.subscribe(F)});var uG=(N)=>N,J0=V3(uG),K3=V3((N)=>N.documentIndex),S5=V3((N)=>N.documentIndex.imageUrls);var IG=J5((N)=>[N.regionId,N.startOffset,N.endOffset]),pG=J5((N)=>[N.start.left,N.start.top,N.end.left,N.end.top]),c2=h0([J0],(N,F)=>j0(F),q$),_5=h0([c2],(N,F)=>F.threads,J3(Object.is)),W$=h0([c2],(N,F)=>F.liveRanges,Fy),n0=h0([J0],(N,F)=>E0(F),Q$),P$=h0([J0],(N,F)=>yN(F),IG),O$=h0([J0],(N,F)=>iF(F),q5),L$=h0([J0,n0,o0],(N,F,M,A)=>{if(!A)return null;return aG(F,A,M)},pG),z5=B$({handles:L$,marks:O$,normalized:n0,range:P$,viewport:o0}),H5=i0([P$,O$,L$,_5],(N,[F],M,A,D,E)=>{return sG({activeMarks:A,handles:D,promotedThread:F,selectionRange:M,threads:E})},iG),B5=i0([J0,n0,o0,_5,W$],(N,[F],M,A,D,E,$)=>{if(!D)return null;return oG({isEditable:F,liveRanges:$,normalizedSelection:A,state:M,threads:E,viewport:D})},Ny),W5=h0([J0,n0,o0],(N,F,M,A)=>{if(!A)return!0;let D=mF(F,A,M.end);return D!=="above"&&D!=="below"}),P5=h0([J0,n0,o0],(N,F,M,A)=>{if(!A)return null;return L8(F,A,M.end)},My),O5=i0([J0],(N,[F],M)=>{return y$(M,F)},S$),L5=i0([],(N,[F])=>{let M=K5(F);return M?[M,U3]:[U3]},xG);function xG(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.length===F.length&&N.every((M,A)=>kE(M,F[A]))}var T5=i0([J0,o0,_5,W$],(N,[F],M,A,D,E)=>{let $=F?.kind==="link"&&A?g8(M,A,{regionId:F.regionId,offset:Ay(F)}):F,Z=G5($,D,E);return{cursor:F?.kind==="task-toggle"||Z?.kind==="link"?"pointer":"text",leaf:Z}},Dy),w5=h0([J0],(N,F)=>cF(F),J$),j5=i0([J0,n0,o0],(N,[F],M,A,D)=>{if(!F||!D)return null;return lG(M,D,A,F)},dG);function lG(N,F,M,A){if(!M.collapsed)return null;let D=sF(N);if(!D)return null;let E=mN(N,F,A,D),$=D.image?A.images.get(D.image.url)?.intrinsicWidth??null:null;return E?{bounds:E,inline:D,maxWidth:$}:null}function dG(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.maxWidth===F.maxWidth&&N.bounds.left===F.bounds.left&&N.bounds.top===F.bounds.top&&N.bounds.width===F.bounds.width&&N.bounds.height===F.bounds.height}function aG(N,F,M){if(M.collapsed)return null;let A=j1(N,F,M.start),D=j1(N,F,M.end);if(!A||!D)return null;return{end:{left:D.left,top:D.top+D.height},start:{left:A.left,top:A.top}}}var rG=2;function cG(N,F,M){return{activeMarks:M,anchor:{regionId:N.regionId,offset:N.endOffset},kind:"annotation",leftOverride:F.start.left,paddingY:rG,selection:N}}function sG({activeMarks:N,handles:F,promotedThread:M,selectionRange:A,threads:D}){if(!A||!F)return null;if(M&&T$(M.selection,A)){let E=D[M.threadIndex];if(!E)return null;return{...M,kind:"thread",link:null,resolved:W1(E),thread:E}}return cG(A,F,N)}function T$(N,F){return N.endOffset===F.endOffset&&N.regionId===F.regionId&&N.startOffset===F.startOffset}function iG(N,F){if(N===F)return!0;if(!N||!F)return!1;if(N.kind!==F.kind)return!1;switch(N.kind){case"annotation":return F.kind==="annotation"&&yF(N,F)&&q5(N.activeMarks,F.activeMarks)&&T$(N.selection,F.selection);case"thread":return F.kind==="thread"&&y3(N,F)}}function oG({isEditable:N,liveRanges:F,normalizedSelection:M,state:A,threads:D,viewport:E}){let $=A.selection.focus;if(!M.collapsed)return null;let Z=N?eG(A):null;if(Z)return Z;let Y=N?nG(A,E):null;if(Y)return Y;return G5(g8(A,E,$),D,F)}function nG(N,F){let M=N.selection.focus,A=N.documentIndex.regionIndex.get(M.regionId),D=A?N.documentIndex.tableCellIndex.get(A.id)??null:null;if(!A||!D)return null;let E=N.documentIndex.blockIndex.get(A.blockId),$=E?.type==="table"?N.documentIndex.document.blocks[E.rootIndex]:null;if(!E||!$||$.type!=="table")return null;let Z=tG(F,A.id),Y=Math.max(1,...$.rows.map((X)=>X.cells.length));return Z!==null?{anchor:M,cellIndex:D.cellIndex,columnCount:Y,kind:"table",leftOverride:Z,rowCount:$.rows.length,rowIndex:D.rowIndex}:null}function tG(N,F){let M=N.layout.lines.find((A)=>A.regionId===F);return M?M.left:null}function eG(N){let F=N.selection.focus,M=N.documentIndex.regionIndex.get(F.regionId);if(!M||M.blockType!=="paragraph"||M.text.length>0)return null;if(F.offset!==0)return null;let A=N.documentIndex.blockIndex.get(M.blockId);if(!A||A.parentBlockId!==null)return null;return{anchor:F,kind:"insertion"}}function Ny(N,F){if(N===F)return!0;if(!N||!F)return!1;if(N.kind!==F.kind)return!1;switch(N.kind){case"thread":return F.kind==="thread"&&y3(N,F);case"insertion":return F.kind==="insertion"&&yF(N,F);case"link":return F.kind==="link"&&y3(N,F);case"table":return F.kind==="table"&&yF(N,F)&&N.cellIndex===F.cellIndex&&N.columnCount===F.columnCount&&N.rowCount===F.rowCount&&N.rowIndex===F.rowIndex}}function Fy(N,F){if(N===F)return!0;if(N.length!==F.length)return!1;return N.every((M,A)=>{let D=F[A];return M.endOffset===D.endOffset&&M.regionId===D.regionId&&M.resolved===D.resolved&&M.startOffset===D.startOffset&&M.threadIndex===D.threadIndex})}function My(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.blockId===F.blockId&&N.regionId===F.regionId&&N.height===F.height&&N.left===F.left&&N.offset===F.offset&&N.top===F.top}function Ay(N){return N.startOffset<N.endOffset?N.startOffset+1:N.startOffset}function Dy(N,F){return N.cursor===F.cursor&&Ey(N.leaf,F.leaf)}function Ey(N,F){if(N===F)return!0;if(!N||!F)return!1;return y3(N,F)}function y3(N,F){if(N.kind!==F.kind)return!1;if(!yF(N,F))return!1;switch(N.kind){case"thread":return F.kind==="thread"&&N.animateInitialComment===F.animateInitialComment&&N.link?.title===F.link?.title&&N.link?.url===F.link?.url&&N.resolved===F.resolved&&N.thread===F.thread&&N.threadIndex===F.threadIndex;case"link":return F.kind==="link"&&N.endOffset===F.endOffset&&N.regionId===F.regionId&&N.startOffset===F.startOffset&&N.title===F.title&&N.url===F.url}}var C5=h0([J0,c2],(N,F,M)=>$y(F,M.liveRanges));function $y(N,F){let M=new Map(N.documentIndex.regions.map((Y,X)=>[Y.id,X])),A=G3(M,N.selection.anchor.regionId,N.selection.anchor.offset),D=G3(M,N.selection.focus.regionId,N.selection.focus.offset),[E,$]=A<=D?[A,D]:[D,A],Z=A===D;for(let Y of F){let X=G3(M,Y.regionId,Y.startOffset),Q=G3(M,Y.regionId,Y.endOffset);if(Z){if(E>=X&&E<=Q)return Y.threadIndex;continue}if(Math.max(E,X)<Math.min($,Q))return Y.threadIndex}return null}function G3(N,F,M){return(N.get(F)??-1)*1e6+M}var Zy=i0([K3],(N,[F],M)=>{if(!F?.length)return;return hF(M,F)},w$),R5=i0([K3,o0],(N,[F],M,A)=>{let D=Zy.read(N,F);if(!D)return;return A?kF(M,A,D):D},w$);function w$(N,F){if(N===F)return!0;if(!N||!F)return!1;return Yy(N,F)}var Yy=J3((N,F)=>{return N.id===F.id&&N.username===F.username&&N.fullName===F.fullName&&N.avatarUrl===F.avatarUrl&&N.color===F.color&&Xy(N.cursorPoint,F.cursorPoint)&&Qy(N.viewport,F.viewport)});function Xy(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.offset===F.offset&&N.regionId===F.regionId}function Qy(N,F){if(N===F)return!0;if(!N||!F)return!1;if(N.status!==F.status)return!1;if(N.status==="unresolved")return!0;return F.status!=="unresolved"&&N.scrollTop===F.scrollTop}function j$(N){return{editor:V$(w2(N)),viewport:K$()}}var Jy=600,qy=530,s2=24;function f$({getScrollTop:N,isEditable:F,layoutWidth:M,onVisibilityChange:A,scrollContentHeight:D,scrollTo:E,viewportHeight:$}){let Z=N0(n0),Y=N0(B5,F),X=N0(W5),Q=N0(P5),J=Z.start.regionId===Z.end.regionId&&Z.start.offset===Z.end.offset,q=b5(!0),U=b5(0),V=b5(null),y=R$(()=>{A()}),G=R$(()=>{U.current=typeof performance<"u"?performance.now():Date.now(),q.current=!0,y()});return C$(()=>{let K=Z.end,S={layoutWidth:M,offset:K.offset,regionId:K.regionId,scrollContentHeight:D,viewportHeight:$};if(Uy(V.current,S))return;if(!Q)return;let _=N(),H=_+s2,B=_+$-s2;if(Q.top<H){let z=E(Math.max(0,Q.top-s2));if(b$(Q,z,$,s2))V.current=S;return}if(Q.top+Q.height>B){let z=E(Math.max(0,Q.top+Q.height-$+s2));if(b$(Q,z,$,s2))V.current=S;return}V.current=S},[Q,M,Z.end.offset,Z.end.regionId,D,$]),C$(()=>{if(q.current=!0,y(),!J||!X||typeof window>"u")return;let K=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-U.current<Jy){if(!q.current)q.current=!0,y();return}q.current=!q.current,y()},qy);return()=>{window.clearInterval(K)}},[J,X]),{caretInViewport:X,leaf:Y,isVisible:()=>q.current,markActivity:G}}function Uy(N,F){return N?.layoutWidth===F.layoutWidth&&N.regionId===F.regionId&&N.offset===F.offset&&N.scrollContentHeight===F.scrollContentHeight&&N.viewportHeight===F.viewportHeight}function b$(N,F,M,A){return N.top>=F+A&&N.top+N.height<=F+M-A}import{useCallback as Vy}from"react";function v$({completionSources:N,enabled:F,onMentionAccepted:M}){let A=N0(O5,F?N:void 0),D=I(VM),E=I(J6),$=Vy((X,Q)=>{let J=_$(X,Q);if(J.kind==="mention"){let q=D(J.target,J.userId,J.name,J.trailingText);if(q)M?.({target:J.target,transition:q,userId:J.userId});return}E(J.startOffset,J.endOffset,J.text)},[D,M,E]),Z=E3({activeCompletion:A,contextKey:A?Ky(A):null,onAccept:$}),Y=A&&Z.leafProps?{kind:"completion",anchor:{regionId:A.regionId,offset:A.triggerStart},...Z.leafProps}:null;return{handleBeforeInput:Z.handleBeforeInput,handleKeyDown:Z.handleKeyDown,leaf:Y}}function Ky(N){if(!("regionId"in N)||typeof N.regionId!=="string")return null;return[N.regionId,N.trigger,N.triggerStart,N.caret,N.query].join(":")}import{useMemo as f5,useRef as SF,useEffectEvent as v5}from"react";var Gy=48;function h$(N){let F=N0(j5,N),M=I(KM),A=SF(null),D=SF(null),E=SF(null),$=SF(null),Z=SF(1),Y=v5((U,V)=>{if(!F)return;U.preventDefault(),U.stopPropagation(),U.currentTarget.setPointerCapture(U.pointerId),$.current=U.pointerId,A.current=U.clientX,D.current=U.clientY,E.current=F.inline.image?.width??F.bounds.width,Z.current=V}),X=v5((U)=>{if($.current!==U.pointerId||A.current===null||D.current===null||E.current===null||!F?.inline.image)return;let V=U.clientX-A.current,y=U.clientY-D.current,G=Math.min(F.maxWidth??1/0,Math.max(Gy,Math.round(E.current+Z.current*(V+y)))),K={end:F.inline.end,image:F.inline.image,start:F.inline.start};M(K,G)}),Q=v5((U)=>{if(U.currentTarget.hasPointerCapture(U.pointerId))U.currentTarget.releasePointerCapture(U.pointerId);$.current=null,A.current=null,D.current=null,E.current=null}),J=f5(()=>({onPointerCancel:Q,onPointerDown:(U)=>Y(U,-1),onPointerMove:X,onPointerUp:Q}),[]),q=f5(()=>({onPointerCancel:Q,onPointerDown:(U)=>Y(U,1),onPointerMove:X,onPointerUp:Q}),[]);return f5(()=>{if(!F)return null;let{bounds:U}=F;return{start:{left:U.left,top:U.top,props:J},end:{left:U.left+U.width,props:q,top:U.top+U.height}}},[F])}import{useEffect as k$,useEffectEvent as m$,useMemo as g$,useRef as yy,useState as Sy}from"react";function u$(N){let F=N0(S5),[M,A]=Sy(new Map),D=m$((Y)=>{if(typeof createImageBitmap>"u")return;let X=zy(M,Y),Q=Hy(M,Y);if(X.length)A((J)=>{let q=new Map(J);for(let U of X)q.delete(U);return q});for(let J of Q)A((q)=>h5(q,J,_F("loading"))),_y(J,N).then((q)=>{A((U)=>{if(!U.has(J))return q?.close(),U;return h5(U,J,q?_F("loaded",q):_F("error"))})})});k$(()=>{D(F)},[F]);let E=yy(new Map);k$(()=>{for(let[Y,X]of E.current)if(!M.has(Y))X.source?.close();E.current=M},[M]);let $=m$(async(Y)=>{try{let X=await N.writeFile(Y),Q=await createImageBitmap(Y).catch(()=>null);return A((J)=>h5(J,X,Q?_F("loaded",Q):_F("error"))),X}catch{return null}}),Z=g$(()=>M.size===0?null:{images:M},[M]);return g$(()=>({resources:Z,persistImage:$}),[Z,$])}async function _y(N,F){try{let M=await F.readFile(N);return M?await createImageBitmap(M):null}catch{return null}}function zy(N,F){return[...N.keys()].filter((M)=>!F.has(M))}function Hy(N,F){return[...F].filter((M)=>{let A=N.get(M)?.status;return A!=="loaded"&&A!=="loading"})}function h5(N,F,M){let A=new Map(N);return A.set(F,M),A}function _F(N,F){return{intrinsicHeight:F?.height??0,intrinsicWidth:F?.width??0,source:F??null,status:N}}import{useEffect as I$,useEffectEvent as P0,useRef as zF,useState as By}from"react";var Wy=48;function p$({autoScrollDuringDrag:N,canvasRef:F,focusInput:M,onActivity:A,resolvePoint:D,storage:E}){let $=v0(),Z=I(y0),Y=I(b8),X=I(f8),Q=I(zM),J=I(gN),[q,U]=By(null),{cursor:V,leaf:y}=N0(T5,q),G=zF(null),K=zF(!1),S=zF(null),_=zF(null),H=zF(null);I$(()=>{if(q&&q.kind!=="task-toggle"&&!y)U(null)},[q,y]),I$(()=>()=>{if(G.current!==null)window.clearTimeout(G.current)},[]);let B=P0(()=>{if(G.current!==null)window.clearTimeout(G.current),G.current=null}),z=P0(()=>{B(),G.current=window.setTimeout(()=>{if(G.current=null,!K.current)U(null)},Wy)}),j=P0(()=>{if(!K.current)B(),U(null)}),C=P0((R)=>{if(!R){j();return}if(R.kind==="task-toggle"){B(),U((k)=>k?.kind==="task-toggle"&&k.listItemId===R.listItemId?k:R);return}if(R.commentThreadIndex!==null){B();let k=R.commentThreadIndex;U((r)=>r?.kind!=="task-toggle"&&r?.commentThreadIndex===k?r:R);return}if(R.kind!=="link"){j();return}B(),U((k)=>k?.kind==="link"&&k.title===R.title&&k.url===R.url&&k.startOffset===R.startOffset&&k.endOffset===R.endOffset?k:R)}),L=P0((R)=>{let k=D(R);if(!k)return null;let r=$.editor.getState();return dD(r,$.viewport.get(),k)}),W=P0((R)=>{let k=F.current;if(k&&S.current===R)k.releasePointerCapture(R)}),O=P0(()=>{S.current=null,_.current=null}),v=P0((R)=>{W(R.pointerId),O()}),m=P0((R)=>{if(H.current=R.pointerType,R.pointerType==="touch")return;let k=F.current,r=$.viewport.get(),D0=D(R);if(!D0)return;if(L(R)?.kind==="task-toggle")return;if(!k)return;let p=R.shiftKey?X(r,D0):Y(r,D0);if(!p)return;let s=p.next.selection.focus;S.current=R.pointerId,_.current=R.shiftKey?p.previous.selection.anchor:s,A(),k.setPointerCapture(R.pointerId),M(s)}),d=P0((R)=>{let k=_.current,r=D(R);if(!r)return;if(S.current!==R.pointerId||!k){C(L(R));return}if(!J($.viewport.get(),r,k))return;A(),N(R)}),P=P0(()=>{if(!K.current)z()}),f=P0((R)=>{let k=H.current==="touch";H.current=null;let r=L(R);if(r?.kind==="task-toggle"){if(Q(r.listItemId))R.preventDefault(),R.stopPropagation(),A();return}if(r?.kind==="link"&&(R.metaKey||R.ctrlKey)){R.preventDefault(),R.stopPropagation(),E.openFile(r.url);return}if(!k){M();return}let D0=D(R);if(D0){let w=Y($.viewport.get(),D0);if(!w){M();return}A(),M(w.next.selection.focus)}else M()}),b=P0((R)=>{let k=$.editor.getState(),r=D(R),D0=L(R);if(!r||D0?.kind==="task-toggle")return;let w=O8(k,$.viewport.get(),r);if(!w)return;R.preventDefault(),R.stopPropagation(),A(),Z(w),M()}),u=P0(()=>{K.current=!0,B()}),o=P0(()=>{K.current=!1,z()});return{canvasHandlers:{onClick:f,onDoubleClick:b,onPointerCancel:v,onPointerDown:m,onPointerLeave:P,onPointerMove:d,onPointerUp:v},cursor:V,leaf:y,leafHandlers:{onPointerEnter:u,onPointerLeave:o}}}import{useEffect as m5,useEffectEvent as T0,useLayoutEffect as Py,useRef as l$,useState as Oy}from"react";import{useEffect as XI1}from"react";var k5=[{key:"Backspace",command:"deleteBackward"},{key:"Enter",shiftKey:!0,command:"insertSoftLineBreak"},{key:"Enter",command:"insertLineBreak"},{key:"Home",command:"moveToLineStart"},{key:"End",command:"moveToLineEnd"},{key:"Tab",command:"indent"},{key:"Tab",shiftKey:!0,command:"dedent"},{key:"ArrowLeft",modKey:!0,shiftKey:"any",command:"moveToLineStart"},{key:"ArrowRight",modKey:!0,shiftKey:"any",command:"moveToLineEnd"},{key:"ArrowUp",modKey:!0,shiftKey:"any",command:"moveToDocumentStart"},{key:"ArrowDown",modKey:!0,shiftKey:"any",command:"moveToDocumentEnd"},{key:"ArrowUp",altKey:!0,shiftKey:!0,command:"moveListItemUp"},{key:"ArrowDown",altKey:!0,shiftKey:!0,command:"moveListItemDown"},{key:"a",modKey:!0,command:"selectAll"},{key:"b",modKey:!0,command:"toggleBold"},{key:"e",modKey:!0,command:"toggleCode"},{key:"i",modKey:!0,command:"toggleItalic"},{key:"u",modKey:!0,command:"toggleUnderline"},{key:"y",modKey:!0,command:"redo"},{key:"z",modKey:!0,command:"undo"},{key:"z",modKey:!0,shiftKey:!0,command:"redo"}];function x$(N,F=k5){return F.find((M)=>{let A=M.shiftKey==="any"?!0:(M.shiftKey??!1)===(N.shiftKey??!1);return M.key.toLowerCase()===N.key.toLowerCase()&&(M.altKey??!1)===(N.altKey??!1)&&A&&(M.modKey??!1)===Boolean(N.metaKey||N.ctrlKey)})?.command??null}var Ly=1024,d$=16;function r$({inputRef:N,keybindings:F,enableTouchKeyDown:M=!1,onActivity:A,onBeforeInput:D,onKeyDown:E,onImagePaste:$}){let Z=v0(),Y=N0(J0),X=Ty(),Q=()=>Z.editor.getState(),J=l$(!1),q=l$(!1),U=I(by),V=I(fy),y=I(Q6),G=I(N8),K=I(F8),S=I(M8),_=I(A8),H=I(vy),B=I(e4),z=I(UM),j=I(qM),C=I(ZM),L=T0((w,...p)=>{let s=w(...p);if(s)A();return s}),W=T0(()=>{let w=N.current;if(!w)return;if(typeof document>"u")return;let p=document.execCommand;if(typeof p!=="function")return;try{J.current=!0,p.call(document,"insertText",!1,"‌"),p.call(document,"delete")}catch{}finally{J.current=!1,HF(w,Q())}}),O=T0(()=>{if(q.current)return;q.current=!0,W()}),v=T0(()=>{W()}),m=T0((w)=>{let p=N.current;if(!p)return;let s=Z.viewport.get(),i=j1(Q(),s,w);if(!i)return;p.style.top=`${i.top}px`,p.style.left=`${i.left}px`,p.style.height=`${i.height}px`}),d=T0((w)=>{let p=N.current;if(!p)return;m(w??Q().selection.focus),p.focus({preventScroll:!X}),HF(p,Q()),O()}),P=T0((w)=>{if(J.current)return;if(D?.(w))return;let p=Q(),s=Cy(w.inputType);if(w.inputType==="insertText"){if(!w.data)return;w.preventDefault();let i=a$(w.target);if(i.charsToReplace>0){L(V,i.charsToReplace,i.trailingOffset,w.data);return}let k0=jy(p,w.data);if(k0>0){let z0=w.data.slice(k0);if(z0.length>0)L(U,z0);return}L(U,w.data);return}if(w.inputType==="insertReplacementText"){if(!w.data)return;w.preventDefault();let i=a$(w.target);L(V,i.charsToReplace,i.trailingOffset,w.data);return}if(wy(w.inputType)){w.preventDefault(),L(y);return}if(s==="backward"){w.preventDefault(),L(G);return}if(s==="forward"){w.preventDefault(),L(K);return}if(w.inputType==="historyUndo"){w.preventDefault(),L(S),v();return}if(w.inputType==="historyRedo"){w.preventDefault(),L(_),v();return}}),f=T0((w)=>{let p=Q(),s=w.currentTarget.value,i=S3(p);if(J.current)return;if(s$(s,i).length===0){HF(w.currentTarget,p);return}L(U,s)}),b=T0((w)=>{if(E?.(w))return;if(!L(H,Z.viewport.get(),w.nativeEvent,F))return;w.preventDefault()}),u=T0((w)=>{let p=TN(Q());if(!p)return;w.preventDefault(),w.clipboardData.setData("text/plain",A2(p))}),o=T0((w)=>{let p=Q(),s=TN(p);if(!s)return;w.preventDefault(),w.clipboardData.setData("text/plain",A2(s)),L(B)}),R=T0(async(w)=>{let s=($?[...w.clipboardData.items].find((z0)=>z0.kind==="file"&&z0.type.startsWith("image/")):void 0)?.getAsFile()??null;if(s&&$){w.preventDefault();let z0=await $(s);if(z0)L(z,z0);return}let i=w.clipboardData.getData("text/plain");if(i.length===0)return;if(/^https?:\/\//.test(i)){if(L(j,i)){w.preventDefault();return}}w.preventDefault();let k0=n8(i);L(C,k0,i)}),k=T0(()=>{A();let w=N.current;if(w)HF(w,Q())}),r=T0((w)=>{if(A(),w.target.matches(":focus-visible"))d()});m5(()=>{let w=N.current;if(!w)return;HF(w,Y)},[Y,N]),Py(()=>{m(Y.selection.focus)},[Y]),m5(()=>{let w=N.current;if(!w)return;let p=(s)=>P(s);return w.addEventListener("beforeinput",p),()=>w.removeEventListener("beforeinput",p)},[N]);let D0={onCopy:u,onCut:o,onPaste:R,...!X||M?{onKeyDown:b}:{}};return{canvasHandlers:{...D0,onFocus:r},focus:d,inputHandlers:{...D0,onFocus:k,onInput:f}}}var c$="​";function Ty(){let[N,F]=Oy(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return m5(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let M=window.matchMedia("(pointer: coarse)"),A=(D)=>F(D.matches);return M.addEventListener?.("change",A),()=>M.removeEventListener?.("change",A)},[]),N}function wy(N){return N==="insertLineBreak"||N==="insertParagraph"}function a$(N){let F=N,M=F?.selectionStart??0,A=F?.selectionEnd??M,D=F?.value.length??A;return{charsToReplace:Math.max(0,A-M),trailingOffset:Math.max(0,D-A)}}function jy(N,F){if(F.length<d$)return 0;let M=S3(N,F.length),A=Math.min(M.length,F.length);for(let D=A;D>=d$;D--)if(M.endsWith(F.slice(0,D)))return D;return 0}function Cy(N){switch(N){case"deleteContentBackward":case"deleteComposedCharacterBackward":case"deleteSoftLineBackward":case"deleteHardLineBackward":case"deleteWordBackward":return"backward";case"deleteContentForward":case"deleteSoftLineForward":case"deleteHardLineForward":case"deleteWordForward":return"forward";default:return null}}function Ry(N){return N.replaceAll(c$,"")}function S3(N,F=Ly){let{anchor:M,focus:A}=N.selection;if(M.regionId!==A.regionId||M.offset!==A.offset)return"";let D=N.documentIndex.regionIndex.get(A.regionId);if(!D)return"";return D.text.slice(Math.max(0,A.offset-F),A.offset)}function s$(N,F){let M=Ry(N);return M.startsWith(F)?M.slice(F.length):M}function HF(N,F){let M=S3(F),A=M.length>0?M:c$;N.value=A,N.setSelectionRange(A.length,A.length),N.scrollLeft=N.scrollWidth}function by(N,F){let A=s$(F,S3(N)).replace(/\r\n/g,`
32
- `).split(/(\n)/),D=N;for(let E of A){if(E.length===0)continue;let $=E===`
33
- `?Q6(D):LN(D,E);if(!$)continue;D=$}return D===N?null:D}function fy(N,F,M,A){let D=N.selection.focus,E=Math.max(0,D.offset-M),$=Math.max(0,E-F);return J6(N,$,E,A)}function vy(N,F,M,A){if(M.key==="Delete")return F8(N);let D=x$(M,A);if(D){if(D==="moveToLineStart"||D==="moveToLineEnd")return C8(N,F.layout,D==="moveToLineStart"?"Home":"End",M.shiftKey);if(D==="moveToDocumentStart"||D==="moveToDocumentEnd")return R8(N,D==="moveToDocumentStart"?"start":"end",M.shiftKey);switch(D){case"insertLineBreak":return Q6(N);case"insertSoftLineBreak":return $M(N);case"deleteBackward":return N8(N);case"indent":return GM(N);case"dedent":return yM(N);case"moveListItemUp":return SM(N);case"moveListItemDown":return _M(N);case"toggleBold":return q6(N);case"toggleItalic":return U6(N);case"toggleStrikethrough":return V6(N);case"toggleUnderline":return K6(N);case"toggleCode":return XM(N);case"undo":return M8(N);case"redo":return A8(N);case"selectAll":return YM(N)}}if(M.key==="ArrowLeft"||M.key==="ArrowRight")return T8(N,M.key==="ArrowLeft"?-1:1,M.shiftKey);if(M.key==="ArrowUp"||M.key==="ArrowDown")return w8(N,F.layout,M.key==="ArrowUp"?-1:1,M.shiftKey);if(M.key==="PageUp"||M.key==="PageDown")return j8(N,F.layout,M.key==="PageUp"?-1:1,M.shiftKey);if(M.key.length===1&&!M.altKey&&!M.ctrlKey&&!M.metaKey)return LN(N,M.key);return null}import{useEffect as hy,useEffectEvent as Z2,useRef as i$}from"react";function o$(){return{fullRender:!1,fullPaint:!1,contentPaint:!1,overlayPaint:!1}}function n$({renderContent:N,renderOverlay:F,renderViewport:M}){let A=v0(),D=i$(null),E=i$(o$()),$=Z2(()=>{if(typeof window>"u"){M();return}E.current.fullRender=!0,Q()}),Z=Z2(()=>{if(typeof window>"u"){N(),F();return}E.current.fullPaint=!0,Q()}),Y=Z2(()=>{if(typeof window>"u"){N();return}E.current.contentPaint=!0,Q()}),X=Z2(()=>{if(typeof window>"u"){F();return}E.current.overlayPaint=!0,Q()}),Q=Z2(()=>{if(typeof window>"u"||D.current!==null)return;D.current=window.requestAnimationFrame(()=>{J()})}),J=Z2(()=>{D.current=null;let U=E.current,V=U.fullRender,y=U.fullPaint,G=U.contentPaint,K=U.overlayPaint;if(E.current=o$(),V){M(),q();return}if(y){N(),F(),q();return}if(G)N(),q();if(K)F()}),q=Z2(()=>{if(!W4(A.editor.getState(),performance.now()))return;E.current.contentPaint=!0,Q()});return hy(()=>{return()=>{if(typeof window>"u"||D.current===null)return;window.cancelAnimationFrame(D.current),D.current=null}},[]),{scheduleContentPaint:Y,scheduleFullPaint:Z,scheduleFullRender:$,scheduleOverlayPaint:X}}import{useEffectEvent as g5,useRef as u5,useState as ky}from"react";function t$({autoScrollDuringDrag:N,isEditable:F,focusInput:M,onActivity:A,resolvePoint:D}){let[E,$]=ky(null),Z=N0(z5),Y=N0(H5,E),X=I(y0),Q=I(gN),J=u5(null),q=u5(null),U=u5(null),V=g5((_,H=!0)=>{if(Y?.kind!=="annotation")return;$({anchor:Y.anchor,animateInitialComment:H,leftOverride:Y.leftOverride,paddingY:Y.paddingY,selection:Y.selection,threadIndex:_})}),y=g5((_)=>{if(_&&U.current===_.pointerId&&_.currentTarget.hasPointerCapture(_.pointerId))_.currentTarget.releasePointerCapture(_.pointerId);J.current=null,q.current=null,U.current=null}),G=g5((_)=>{let H=q.current,B=D(_);if(!B||!H||U.current!==_.pointerId||!Z.viewport)return;if(!Q(Z.viewport,B,H))return;_.preventDefault(),_.stopPropagation(),A(),N(_)}),K=(_)=>({onPointerCancel:(H)=>{y(H)},onPointerDown:(H)=>{let B=my(Z.normalized,_),z=_==="start"?Z.normalized.start:Z.normalized.end;if(!Z.handles)return;H.preventDefault(),H.stopPropagation(),U.current=H.pointerId,q.current=B,J.current=_,H.currentTarget.setPointerCapture(H.pointerId),A(),M(),X({anchor:B,focus:z})},onPointerMove:(H)=>{if(J.current!==_)return;G(H)},onPointerUp:(H)=>{if(J.current===_)G(H);y(H)}});return{handle:Z.handles?{start:{...Z.handles.start,props:K("start")},end:{...Z.handles.end,props:K("end")}}:null,leaf:F?Y:null,promoteLeafToThread:V}}function my(N,F){return F==="start"?N.end:N.start}import{useEffect as gy,useMemo as FZ,useState as uy}from"react";var BF={activeBlockBackground:"#fff1c7",activeBlockFlash:"rgba(245, 158, 11, 0.28)",background:"#fcfbf7",blockquoteRule:"rgba(14, 116, 144, 0.2)",blockquoteRuleActive:"rgba(124, 45, 18, 0.36)",blockquoteText:"#334155",caret:"#111827",checkboxCheckmark:"#f8fafc",checkboxCheckedFill:"#0f766e",checkboxCheckedStroke:"#0f766e",checkboxUncheckedFill:"#fcfffe",checkboxUncheckedStroke:"#64748b",codeBackground:"#0f172a",codeText:"#e2e8f0",commentHighlight:"#d7e3fc",commentHighlightActive:"#f4d35e",commentHighlightResolved:"#cfe9d8",commentHighlightResolvedActive:"#8dc4a0",headingRule:"rgba(15, 23, 42, 0.18)",headingText:"#0f172a",imageLoadingOverlay:"rgba(255, 255, 255, 0.42)",imagePlaceholderIcon:"rgba(14, 116, 144, 0.42)",imagePlaceholderText:"rgba(15, 23, 42, 0.58)",imageSurfaceBackground:"rgba(240, 249, 255, 0.98)",imageSurfaceBorder:"rgba(14, 116, 144, 0.22)",inlineCodeBackground:"rgba(15, 23, 42, 0.08)",inlineCodeText:"#7c2d12",insertHighlightText:"#2563eb",leafAccent:"#1d4ed8",leafBackground:"#fcfbf7",leafBorder:"rgba(148, 163, 184, 0.55)",leafButtonBackground:"rgba(15, 23, 42, 0.08)",leafButtonBorder:"rgba(148, 163, 184, 0.55)",leafButtonText:"#1f2937",leafResolvedBackground:"#cfe9d8",leafResolvedBorder:"#8dc4a0",leafSecondaryText:"#334155",leafShadow:"0 14px 40px rgba(15, 23, 42, 0.16)",leafText:"#1f2937",linkText:"#1d4ed8",listMarkerText:"#1f2937",paddingX:16,paddingY:12,paragraphText:"#1f2937",selectionBackground:"rgba(125, 211, 252, 0.35)",selectionHandleBackground:"#fcfbf7",selectionHandleBorder:"#1d4ed8",tableBodyBackground:"rgba(248, 250, 252, 0.98)",tableBorder:"rgba(148, 163, 184, 0.55)",tableHeaderBackground:"rgba(226, 232, 240, 0.95)"},WF={activeBlockBackground:"rgba(125, 211, 252, 0.12)",activeBlockFlash:"rgba(226, 232, 240, 0.12)",background:"#0b1220",blockquoteRule:"rgba(103, 232, 249, 0.34)",blockquoteRuleActive:"rgba(125, 211, 252, 0.5)",blockquoteText:"#cbd5e1",caret:"#f8fafc",checkboxCheckmark:"#082f49",checkboxCheckedFill:"#67e8f9",checkboxCheckedStroke:"#67e8f9",checkboxUncheckedFill:"#0f172a",checkboxUncheckedStroke:"#64748b",codeBackground:"#020617",codeText:"#dbeafe",commentHighlight:"rgba(96, 165, 250, 0.34)",commentHighlightActive:"#facc15",commentHighlightResolved:"rgba(74, 222, 128, 0.24)",commentHighlightResolvedActive:"#4ade80",headingRule:"rgba(226, 232, 240, 0.22)",headingText:"#f8fafc",imageLoadingOverlay:"rgba(186, 230, 253, 0.18)",imagePlaceholderIcon:"rgba(125, 211, 252, 0.44)",imagePlaceholderText:"rgba(226, 232, 240, 0.62)",imageSurfaceBackground:"rgba(15, 23, 42, 0.92)",imageSurfaceBorder:"rgba(56, 189, 248, 0.28)",inlineCodeBackground:"rgba(148, 163, 184, 0.16)",inlineCodeText:"#fdba74",insertHighlightText:"#60a5fa",leafAccent:"#93c5fd",leafBackground:"#0b1220",leafBorder:"rgba(100, 116, 139, 0.7)",leafButtonBackground:"rgba(148, 163, 184, 0.16)",leafButtonBorder:"rgba(100, 116, 139, 0.7)",leafButtonText:"#dbe4f0",leafResolvedBackground:"rgba(74, 222, 128, 0.24)",leafResolvedBorder:"#4ade80",leafSecondaryText:"#cbd5e1",leafShadow:"0 18px 44px rgba(2, 6, 23, 0.42), 0 0 0 1px rgba(148, 163, 184, 0.06)",leafText:"#dbe4f0",linkText:"#93c5fd",listMarkerText:"#e2e8f0",paddingX:16,paddingY:12,paragraphText:"#dbe4f0",selectionBackground:"rgba(56, 189, 248, 0.28)",selectionHandleBackground:"#0b1220",selectionHandleBorder:"#93c5fd",tableBodyBackground:"rgba(15, 23, 42, 0.9)",tableBorder:"rgba(100, 116, 139, 0.7)",tableHeaderBackground:"rgba(30, 41, 59, 0.96)"},e$={...BF,activeBlockBackground:"rgba(16, 185, 129, 0.14)",activeBlockFlash:"rgba(16, 185, 129, 0.26)",background:"#f3fbf6",blockquoteRule:"rgba(5, 150, 105, 0.22)",blockquoteRuleActive:"rgba(6, 95, 70, 0.38)",blockquoteText:"#166534",caret:"#14532d",codeBackground:"#052e16",codeText:"#dcfce7",commentHighlight:"rgba(52, 211, 153, 0.26)",commentHighlightActive:"#10b981",commentHighlightResolved:"rgba(187, 247, 208, 0.96)",commentHighlightResolvedActive:"#059669",headingRule:"rgba(20, 83, 45, 0.18)",headingText:"#14532d",inlineCodeBackground:"rgba(20, 83, 45, 0.08)",inlineCodeText:"#166534",insertHighlightText:"#10b981",leafAccent:"#059669",leafBackground:"#f3fbf6",leafBorder:"rgba(22, 163, 74, 0.24)",leafButtonBackground:"rgba(20, 83, 45, 0.08)",leafButtonBorder:"rgba(22, 163, 74, 0.28)",leafButtonText:"#14532d",leafResolvedBackground:"#d1fae5",leafResolvedBorder:"#10b981",leafSecondaryText:"#166534",leafShadow:"0 14px 40px rgba(20, 83, 45, 0.14)",leafText:"#14532d",linkText:"#047857",paragraphText:"#14532d",selectionBackground:"rgba(52, 211, 153, 0.24)",selectionHandleBackground:"#f3fbf6",selectionHandleBorder:"#059669",tableBodyBackground:"rgba(243, 251, 246, 0.96)",tableBorder:"rgba(22, 163, 74, 0.24)",tableHeaderBackground:"rgba(220, 252, 231, 0.96)"},NZ={...WF,activeBlockBackground:"rgba(168, 85, 247, 0.16)",activeBlockFlash:"rgba(243, 232, 255, 0.13)",blockquoteRule:"rgba(196, 181, 253, 0.34)",blockquoteRuleActive:"rgba(216, 180, 254, 0.44)",caret:"#f5f3ff",codeBackground:"#1e1b4b",codeText:"#ede9fe",commentHighlight:"rgba(167, 139, 250, 0.28)",commentHighlightActive:"#c084fc",commentHighlightResolved:"rgba(45, 212, 191, 0.22)",commentHighlightResolvedActive:"#2dd4bf",headingRule:"rgba(233, 213, 255, 0.24)",headingText:"#f5f3ff",inlineCodeBackground:"rgba(196, 181, 253, 0.16)",inlineCodeText:"#f9a8d4",insertHighlightText:"#c084fc",leafAccent:"#d8b4fe",leafBackground:"#12091f",leafBorder:"rgba(139, 92, 246, 0.34)",leafButtonBackground:"rgba(196, 181, 253, 0.16)",leafButtonBorder:"rgba(139, 92, 246, 0.34)",leafButtonText:"#ede9fe",leafResolvedBackground:"rgba(45, 212, 191, 0.22)",leafResolvedBorder:"#2dd4bf",leafSecondaryText:"#ddd6fe",leafShadow:"0 20px 48px rgba(2, 6, 23, 0.48), 0 0 0 1px rgba(196, 181, 253, 0.08)",leafText:"#f5f3ff",linkText:"#d8b4fe",listMarkerText:"#ede9fe",paragraphText:"#ede9fe",selectionBackground:"rgba(167, 139, 250, 0.26)",selectionHandleBackground:"#12091f",selectionHandleBorder:"#d8b4fe",tableBodyBackground:"rgba(30, 27, 75, 0.88)",tableBorder:"rgba(139, 92, 246, 0.34)",tableHeaderBackground:"rgba(49, 46, 129, 0.94)"};function MZ(N){let F=FZ(()=>py(N),[N]),[M,A]=uy(F.light),D=FZ(()=>xy(M),[M]);return gy(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){A(F.light);return}let E=window.matchMedia("(prefers-color-scheme: dark)"),$=()=>{A(E.matches?F.dark:F.light)};if($(),typeof E.addEventListener==="function")return E.addEventListener("change",$),()=>{E.removeEventListener("change",$)};return E.addListener($),()=>{E.removeListener($)}},[F]),{theme:M,themeStyles:D}}function Iy(N){return"light"in N&&"dark"in N}function py(N){if(!N)return{dark:WF,light:BF};if(Iy(N))return N;return{dark:N,light:N}}function xy(N){return{"--documint-background":N.background,"--documint-leaf-button-bg":N.leafButtonBackground,"--documint-leaf-button-border":N.leafButtonBorder,"--documint-leaf-button-text":N.leafButtonText,"--documint-leaf-accent":N.leafAccent,"--documint-leaf-bg":N.leafBackground,"--documint-leaf-border":N.leafBorder,"--documint-leaf-font-family":'"Avenir Next", "Segoe UI", sans-serif',"--documint-leaf-shadow":N.leafShadow??void 0,"--documint-leaf-secondary-text":N.leafSecondaryText,"--documint-leaf-resolved-bg":N.leafResolvedBackground,"--documint-leaf-resolved-border":N.leafResolvedBorder,"--documint-leaf-text":N.leafText,"--documint-mention-bg":N.mentionBackground??void 0,"--documint-mention-text":N.mentionText??void 0,"--documint-selection-handle-bg":N.selectionHandleBackground,"--documint-selection-handle-border":N.selectionHandleBorder}}import{useEffect as ly,useEffectEvent as K1,useRef as I5,useState as _3}from"react";function AZ(N,F){let M=F.getBoundingClientRect();return{x:N.clientX-M.left+F.scrollLeft,y:N.clientY-M.top+F.scrollTop}}var DZ=28,EZ=18;function $Z({renderResources:N,theme:F}){let M=v0(),A=I5(i1()),D=I5(null),E=I5({height:240,top:0}),[$,Z]=_3(0),[Y,X]=_3(240),[Q,J]=_3(0),[q,U]=_3(240),V=dy($),y=()=>{let W=M.editor.getState(),O=E.current;return W8(W,{height:O.height,paddingX:F.paddingX,paddingY:F.paddingY,top:O.top,width:V},A.current,N)};M.viewport.setViewportResolver(y);let G=M.viewport,K=K1((W)=>{M.viewport.observeViewport(W),U((O)=>{let v=ry(W,E.current.height);return O===v?O:v})}),S=K1((W)=>{E.current={...E.current,top:W},J((O)=>O===W?O:W),G.invalidate()}),_=K1((W)=>{let O=ay(W),v=O.top!==E.current.top;if(E.current=O,J((m)=>m===O.top?m:O.top),v)G.invalidate()}),H=K1((W)=>{let O=D.current;if(!O)return S(W),W;O.scrollTop=W;let v=O.scrollTop;return S(v),v}),B=K1(()=>{return D.current?.scrollTop??E.current.top}),z=K1((W,O)=>{let v=W!==null&&W.documentIndex!==O.documentIndex,m=G.peek();if(!(!v||!m||m.layout.regionLineIndices.has(O.selection.focus.regionId)))G.invalidate()}),j=K1(()=>{G.invalidate()}),C=K1((W)=>{let O=D.current;return O?AZ(W,O):null}),L=K1((W)=>{let O=D.current;if(!O)return;let v=O.getBoundingClientRect();if(W.clientY<v.top+DZ){O.scrollTop=Math.max(0,O.scrollTop-EZ);return}if(W.clientY>v.bottom-DZ)O.scrollTop+=EZ});return ly(()=>{let W=D.current;if(!W||typeof ResizeObserver>"u")return;let O=new ResizeObserver((v)=>{let m=v[0];if(!m)return;let d=Math.max(0,Math.floor(m.contentRect.width)),P=ZZ(W);E.current={...E.current,height:P},Z((f)=>f===d?f:d),X((f)=>f===P?f:P)});return O.observe(W),()=>O.disconnect()},[D]),{actions:{autoScrollDuringDrag:L,getScrollTop:B,invalidateViewport:j,observeViewport:K,observeScrollContainer:_,reconcileEditorState:z,resolvePoint:C,scrollTo:H},props:{scrollContent:{style:{height:`${q}px`}}},refs:{scrollContainer:D},state:{layoutWidth:V,scrollContentHeight:q,viewportLayout:G,viewportHeight:Y,viewportTop:Q}}}function dy(N){return Math.max(240,Math.floor(N||480))}function ZZ(N){return Math.max(240,N.clientHeight)}function ay(N){return{height:ZZ(N),top:N.scrollTop}}function ry(N,F){return Math.max(F,Math.ceil(N.totalHeight+24))}function cy(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function p5(N,{paintHeight:F,paintTop:M,width:A}){if(!N)return null;let D=Math.max(240,Math.ceil(F)),E=cy();N.width=Math.ceil(A*E),N.height=Math.ceil(D*E),N.style.width=`${A}px`,N.style.height=`${D}px`,N.style.transform=`translateY(${M}px)`;let $=N.getContext("2d");if(!$)return null;return{context:$,devicePixelRatio:E,height:D,width:A}}function x5(N,F){let M=[],A=new Set;for(let D of Y3(N,F)){if(D.kind!=="token"||D.trigger!=="@"||!D.id)continue;if(A.has(D.id))continue;A.add(D.id),M.push(D.id)}return M}function YZ(N,F){if(!F?.length||!N?.length)return;let M=new Map(N.map((D)=>[D.id,D])),A=[];for(let D of F){let E=M.get(D.userId);if(!E)continue;A.push({...E,color:D.color,cursor:D.cursor})}return A.length===0?void 0:A}var XZ=/^(https?:|data:|blob:)/i;class l5{storage;view;constructor(N,F){this.storage=N;this.view=F}async readFile(N){if(XZ.test(N))try{let F=await fetch(N);return F.ok?F.blob():null}catch{return null}return this.storage?.readFile(N)??null}writeFile(N){if(!this.storage?.writeFile)throw Error("No storage configured");return this.storage.writeFile(N)}openFile(N){if(XZ.test(N))this.view?.open(N,"_blank","noopener,noreferrer");else this.storage?.openFile?.(N)}}function JZ(N,F){if(!N)return{didReconcile:!1,state:F};let M=sy(N,F)??AS(N,F);return M?{didReconcile:!0,state:M}:{didReconcile:!1,state:F}}function sy(N,F){let M=iy(N,F);return M?y0(F,M,!1):null}function iy(N,F){if(r5(N.selection.anchor,N.selection.focus)){let E=d5(N,F,N.selection.focus,"neutral");return E?{anchor:E,focus:E}:null}let M=FS(N),A=d5(N,F,N.selection.anchor,M.anchor),D=d5(N,F,N.selection.focus,M.focus);return A&&D?{anchor:A,focus:D}:null}function d5(N,F,M,A){let D=N.documentIndex.regionIndex.get(M.regionId);if(!D)return null;let E=a5(D,F);if(!E)return null;return{offset:ny(D.text,E.text,M.offset,A),regionId:E.id}}function a5(N,F){let M=F.documentIndex.regionIndex.get(N.id);if(M)return M;if(N.text.length===0)return null;let A=oy(N,F);if(A)return A;return F.documentIndex.regionPathIndex.get(N.path)??null}function oy(N,F){let M=null;for(let A of F.documentIndex.regions){if(A.blockType!==N.blockType||A.text!==N.text)continue;if(M)return null;M=A}return M}function ny(N,F,M,A){let D=l0(M,0,N.length),{prefix:E,suffix:$}=r3(N,D,D),Z=ty(F,E,$);if(Z!==null)return Z;let Y=ey(F,E),X=NS(F,$);if(A==="before-suffix")return X??Y??l0(M,0,F.length);return Y??X??l0(M,0,F.length)}function ty(N,F,M){let A=K2(N,F,M).filter((D)=>D.startOffset===D.endOffset);return A.length===1?A[0].startOffset:null}function ey(N,F){let M=F1(N,F);return M.length===1?M[0]+F.length:null}function NS(N,F){let M=F1(N,F);return M.length===1?M[0]:null}function FS(N){let{anchor:F,focus:M}=N.selection;if(r5(F,M))return{anchor:"neutral",focus:"neutral"};return MS(N,F,M)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function MS(N,F,M){let A=N.documentIndex.regionOrderIndex.get(F.regionId),D=N.documentIndex.regionOrderIndex.get(M.regionId);if(A===void 0||D===void 0)return 0;return A===D?F.offset-M.offset:A-D}function AS(N,F){if(!r5(N.selection.anchor,N.selection.focus))return null;let M=DS(N);if(!M)return null;let A=ES(N,F,M);if(A===null)return null;return $S(F,A)}function DS(N){let F=N.documentIndex.regionIndex.get(N.selection.focus.regionId);if(!F||F.blockType!=="paragraph"||F.text.length>0)return null;return N.documentIndex.blockIndex.get(F.blockId)?.parentBlockId===null?F:null}function ES(N,F,M){let A=QZ(N,M.rootIndex,"before"),D=QZ(N,M.rootIndex,"after"),E=A?a5(A,F):null,$=D?a5(D,F):null;if(E&&$)return E.rootIndex<$.rootIndex?$.rootIndex:null;if(E)return E.rootIndex+1;if($)return $.rootIndex;return null}function $S(N,F){let M=d1(N.documentIndex.document,F,0,[e("")]),A={...N,documentIndex:_2(N.documentIndex,M,F,0)},D=GN(A.documentIndex,A0(F));return D?y0(A,D,!1):null}function QZ(N,F,M){let A=M==="before"?-1:1;for(let D=F+A;D>=0&&D<N.documentIndex.roots.length;D+=A){let E=ZS(N,D,M);if(E)return E}return null}function ZS(N,F,M){let A=N.documentIndex.roots[F]?.regions??[],D=M==="before"?A.length-1:0,E=M==="before"?-1:1;for(let $=D;$>=0&&$<A.length;$+=E){let Z=A[$];if(Z&&Z.text.length>0)return Z}return null}function r5(N,F){return N.regionId===F.regionId&&N.offset===F.offset}function UZ(N,F){let M=N.previous.documentIndex.regionIndex.get(F.regionId);if(!M)return null;let A=N.next.documentIndex.regionPathIndex.get(M.path);if(!A)return null;let D=N.previous.documentIndex.document,E=N.next.documentIndex.document,$=D.blocks[M.rootIndex],Z=E.blocks[A.rootIndex];if(!$||!Z)return null;let Y=YS($,Z);if(!Y)return null;return{lineMarkdown:Y.lineMarkdown,lineNumber:XS(E,A.rootIndex)+Y.lineIndex}}function YS(N,F){let M=qZ(N),A=qZ(F),D=QS(M,A);if(D===null)return null;let E=A.lastIndexOf(`
34
- `,Math.max(0,D-1))+1,$=A.indexOf(`
35
- `,D);return{lineIndex:c5(A,E),lineMarkdown:A.slice(E,$===-1?A.length:$)}}function XS(N,F){let M=1;if(N.frontMatter!==void 0)M+=c5(N.frontMatter,N.frontMatter.length)+2;if(F>0){let A=A2({kind:"blocks",blocks:N.blocks.slice(0,F)});if(A.length>0)M+=c5(A,A.length)+2}return M}function qZ(N){return A2({kind:"blocks",blocks:[N]})}function QS(N,F){let M=Math.min(N.length,F.length);for(let A=0;A<M;A+=1)if(N[A]!==F[A])return A;return N.length===F.length?null:M}function c5(N,F){let M=0;for(let A=0;A<F;A+=1)if(N[A]===`
36
- `)M+=1;return M}import{jsx as c,jsxs as H3,Fragment as SS}from"react/jsx-runtime";function B3({blocks:N}){return c(SS,{children:N.map((F)=>JS(F))})}function JS(N){switch(N.type){case"blockquote":return c("blockquote",{className:"preview-block preview-block-blockquote",children:c(B3,{blocks:N.children})},N.id);case"code":return H3("div",{className:"preview-block preview-block-code",children:[c("div",{className:"preview-rich-header",children:VS(N.language,N.meta)}),c("pre",{children:c("code",{children:N.source||" "})})]},N.id);case"heading":{let F=`h${N.depth}`;return c(F,{className:"preview-block preview-block-heading",children:z3(N.children)},N.id)}case"list":return N.ordered?c("ol",{className:"preview-block preview-block-list",start:N.start??1,children:N.items.map((F)=>s5(F))},N.id):c("ul",{className:"preview-block preview-block-list",children:N.items.map((F)=>s5(F))},N.id);case"listItem":return s5(N);case"paragraph":return c("p",{className:"preview-block preview-block-paragraph",children:z3(N.children)},N.id);case"table":return H3("div",{className:"preview-block preview-block-table",children:[c("div",{className:"preview-rich-header",children:KS(N.rows.length,N.rows[0]?.cells.length??0,N.align.filter((F)=>F!==null).length)}),c("div",{className:"preview-table-scroll",children:c("table",{children:c("tbody",{children:N.rows.map((F)=>c("tr",{children:F.cells.map((M)=>c("td",{children:z3(M.children)},M.id))},F.id))})})})]},N.id);case"divider":return c("hr",{className:"preview-block preview-block-rule"},N.id);case"directive":return c("pre",{className:`preview-block preview-block-directive preview-block-directive-${N.name}`,children:N.body},N.id);case"raw":return c("pre",{className:"preview-block preview-block-unsupported",children:N.source},N.id)}}function s5(N){return c("li",{className:"preview-block preview-block-list-item",children:c(B3,{blocks:N.children})},N.id)}function z3(N){return N.map((F)=>{switch(F.type){case"lineBreak":return c("br",{},F.id);case"image":return H3("span",{className:"preview-inline preview-inline-image",children:[c("img",{alt:F.alt??"",src:F.url,title:F.title??""}),H3("span",{children:[c("strong",{children:GS(F.alt)}),c("small",{children:yS(F.url,F.title)})]})]},F.id);case"code":return c("code",{className:"preview-inline preview-inline-code",children:F.code},F.id);case"link":return qS(F);case"text":return c("span",{className:"preview-inline",children:US(F.text,F.marks)},F.id);case"raw":return c("span",{className:"preview-inline preview-inline-unsupported",children:F.source},F.id)}})}function qS(N){return c("a",{className:"preview-inline preview-inline-link",href:N.url,children:z3(N.children)},N.id)}function US(N,F){let M=N;for(let A of F)switch(A){case"strikethrough":M=c("del",{children:M});break;case"italic":M=c("em",{children:M});break;case"bold":M=c("strong",{children:M});break;case"underline":M=c("ins",{children:M});break}return M}function VS(N,F){return[N??"plain text",F].filter(Boolean).join(" • ")}function KS(N,F,M){let A=M>0?`${M} aligned ${M===1?"column":"columns"}`:"no alignment";return`${N} ${N===1?"row":"rows"} • ${F} ${F===1?"column":"columns"} • ${A}`}function GS(N){return N?.trim()?N:"Untitled image"}function yS(N,F){return F?.trim()?`${F} • ${N}`:N}var VZ=`/* Base Documint host and SSR-fallback styles. */
11
+ `)}var m4=null,mY;function kY(){if(m4===null)m4=new Intl.Segmenter(mY,{granularity:"word"});return m4}var gY=/\p{Script=Arabic}/u,E2=/\p{M}/u,g4=/\p{Nd}/u;function kM(N){return gY.test(N)}function gM(N){return N>=19968&&N<=40959||N>=13312&&N<=19903||N>=131072&&N<=173791||N>=173824&&N<=177983||N>=177984&&N<=178207||N>=178208&&N<=183983||N>=183984&&N<=191471||N>=191472&&N<=192093||N>=194560&&N<=195103||N>=196608&&N<=201551||N>=201552&&N<=205743||N>=205744&&N<=210041||N>=63744&&N<=64255||N>=12288&&N<=12351||N>=12352&&N<=12447||N>=12448&&N<=12543||N>=12592&&N<=12687||N>=44032&&N<=55215||N>=65280&&N<=65519}function c0(N){for(let F=0;F<N.length;F++){let A=N.charCodeAt(F);if(A<12288)continue;if(A>=55296&&A<=56319&&F+1<N.length){let M=N.charCodeAt(F+1);if(M>=56320&&M<=57343){let D=(A-55296<<10)+(M-56320)+65536;if(gM(D))return!0;F++;continue}}if(gM(A))return!0}return!1}function hY(N){let F=jN(N);return F!==null&&(D6.has(F)||b1.has(F))}var IY=new Set([" "," ","⁠","\uFEFF"]),pY=new Set(["-","‐","–","—"]);function xY(N){let F=jN(N);return F!==null&&IY.has(F)}function lY(N){let F=jN(N);return F!==null&&pY.has(F)}function h4(N,F){if(xY(N))return!1;if(!F)return!0;if(hY(N))return!1;if(lY(N))return!1;return!0}var D6=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),CN=new Set(['"',"(","[","{","¡","¿","“","‘","‚","„","«","‹","⸘","(","〔","〈","《","「","『","【","〖","〘","〚"]),I4=new Set(["'","’"]),b1=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),dY=new Set([":",".","،","؛"]),aY=new Set(["၏"]),rY=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function cY(N){if(p4(N))return!0;let F=!1;for(let A of N){if(b1.has(A)||$6(A)){F=!0;continue}if(F&&E2.test(A))continue;return!1}return F}function sY(N){for(let F of N)if(!D6.has(F)&&!b1.has(F))return!1;return N.length>0}function iY(N){if(p4(N))return!0;for(let F of N)if(!CN.has(F)&&!I4.has(F)&&!E2.test(F)&&!$6(F))return!1;return N.length>0}function p4(N){let F=!1;for(let A of N){if(A==="\\"||E2.test(A))continue;if(CN.has(A)||b1.has(A)||I4.has(A)){F=!0;continue}return!1}return F}function E6(N,F){let A=F-1;if(A<=0)return Math.max(A,0);let M=N.charCodeAt(A);if(M<56320||M>57343)return A;let D=A-1;if(D<0)return A;let E=N.charCodeAt(D);return E>=55296&&E<=56319?D:A}function jN(N){if(N.length===0)return null;let F=E6(N,N.length);return N.slice(F)}function oY(N){for(let F of N)if(!E2.test(F))return F;return null}function nY(N){for(let F=N.length;F>0;){let A=E6(N,F),M=N.slice(A,F);if(!E2.test(M))return M;F=A}return null}var tY=[36,37,43,43,92,92,162,165,176,177,1423,1423,1545,1547,1642,1642,2046,2047,2546,2547,2553,2555,2801,2801,3065,3065,3449,3449,3647,3647,6107,6107,8240,8247,8279,8279,8352,8399,8451,8451,8457,8457,8470,8470,8722,8723,43064,43064,65020,65020,65129,65130,65284,65285,65504,65505,65509,65510,73693,73696,123647,123647,126124,126124,126128,126128];function eY(N,F){for(let A=0;A<F.length;A+=2)if(N>=F[A]&&N<=F[A+1])return!0;return!1}function $6(N){let F=N.codePointAt(0);return F!==void 0&&eY(F,tY)}function NX(N){let F=nY(N);return F!==null&&$6(F)}function FX(N){let F=oY(N);return F!==null&&g4.test(F)}function AX(N){let F=Array.from(N),A=F.length;while(A>0){let M=F[A-1];if(E2.test(M)){A--;continue}if(CN.has(M)||I4.has(M)){A--;continue}break}if(A<=0||A===F.length)return null;return{head:F.slice(0,A).join(""),tail:F.slice(A).join("")}}function MX(N,F,A){return A==="text"&&!F&&N.length===1&&N!=="-"&&N!=="—"?N:null}function hM(N,F,A,M){let D=F[M],E=N[M];if(D==null)return E;let $=A[M];if(E.length===$)return E;let y=D.repeat($);return N[M]=y,y}function IM(N,F){return N&&F!==null&&dY.has(F)}function DX(N){let F=jN(N);return F!==null&&aY.has(F)}function EX(N){if(N.length<2||N[0]!==" ")return null;let F=N.slice(1);if(/^\p{M}+$/u.test(F))return{space:" ",marks:F};return null}function y6(N){let F=N.length;while(F>0){let A=E6(N,F),M=N.slice(A,F);if(rY.has(M))return!0;if(!b1.has(M))return!1;F=A}return!1}function $X(N,F){if(F.preserveOrdinarySpaces||F.preserveHardBreaks){if(N===" ")return"preserved-space";if(N==="\t")return"tab";if(F.preserveHardBreaks&&N===`
12
+ `)return"hard-break"}if(N===" ")return"space";if(N===" "||N===" "||N==="⁠"||N==="\uFEFF")return"glue";if(N==="​")return"zero-width-break";if(N==="­")return"soft-hyphen";return"text"}var yX=/[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;function t0(N){return N.length===1?N[0]:N.join("")}function ZX(N,F){let A=[];for(let M=N.length-1;M>=0;M--)A.push(N[M]);return A.push(F),t0(A)}function YX(N,F,A,M){if(!yX.test(N))return[{text:N,isWordLike:F,kind:"text",start:A}];let D=[],E=null,$=[],y=A,Z=!1,Y=0;for(let X of N){let Q=$X(X,M),S=Q==="text"&&F;if(E!==null&&Q===E&&S===Z){$.push(X),Y+=X.length;continue}if(E!==null)D.push({text:t0($),isWordLike:Z,kind:E,start:y});E=Q,$=[X],y=A+Y,Z=S,Y+=X.length}if(E!==null)D.push({text:t0($),isWordLike:Z,kind:E,start:y});return D}function k4(N){return N==="space"||N==="preserved-space"||N==="zero-width-break"||N==="hard-break"}var XX=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function QX(N,F){let A=N.texts[F];if(A.startsWith("www."))return!0;return XX.test(A)&&F+1<N.len&&N.kinds[F+1]==="text"&&N.texts[F+1]==="//"}function SX(N){return N.includes("?")&&(N.includes("://")||N.startsWith("www."))}function JX(N){let F=N.texts.slice(),A=N.isWordLike.slice(),M=N.kinds.slice(),D=N.starts.slice();for(let $=0;$<N.len;$++){if(M[$]!=="text"||!QX(N,$))continue;let y=[F[$]],Z=$+1;while(Z<N.len&&!k4(M[Z])){y.push(F[Z]),A[$]=!0;let Y=F[Z].includes("?");if(M[Z]="text",F[Z]="",Z++,Y)break}F[$]=t0(y)}let E=0;for(let $=0;$<F.length;$++){let y=F[$];if(y.length===0)continue;if(E!==$)F[E]=y,A[E]=A[$],M[E]=M[$],D[E]=D[$];E++}return F.length=E,A.length=E,M.length=E,D.length=E,{len:E,texts:F,isWordLike:A,kinds:M,starts:D}}function VX(N){let F=[],A=[],M=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E];if(F.push($),A.push(N.isWordLike[E]),M.push(N.kinds[E]),D.push(N.starts[E]),!SX($))continue;let y=E+1;if(y>=N.len||k4(N.kinds[y]))continue;let Z=[],Y=N.starts[y],X=y;while(X<N.len&&!k4(N.kinds[X]))Z.push(N.texts[X]),X++;if(Z.length>0)F.push(t0(Z)),A.push(!0),M.push("text"),D.push(Y),E=X-1}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}var qX=new Set([":","-","/","×",",",".","+","–","—"]),UX=new Set([".",",",":",";"]);function pM(N){for(let F=N.length;F>0;){let A=E6(N,F),M=N.slice(A,F);if(E2.test(M)){F=A;continue}return UX.has(M)||$6(M)}return!1}function KX(N,F){return F&&!c0(N)}function xM(N){for(let F of N)if(g4.test(F))return!0;return!1}function TN(N){if(N.length===0)return!1;for(let F of N){if(g4.test(F)||qX.has(F))continue;return!1}return!0}function zX(N){let F=[],A=[],M=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E],y=N.kinds[E];if(y==="text"&&TN($)&&xM($)){let Z=[$],Y=E+1;while(Y<N.len&&N.kinds[Y]==="text"&&TN(N.texts[Y]))Z.push(N.texts[Y]),Y++;F.push(t0(Z)),A.push(!0),M.push("text"),D.push(N.starts[E]),E=Y-1;continue}F.push($),A.push(N.isWordLike[E]),M.push(y),D.push(N.starts[E])}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function GX(N){let F=[],A=[],M=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E],y=N.kinds[E],Z=N.isWordLike[E];if(y==="text"&&pM($)&&(Z||NX($))&&!c0($)){let Y=[$],X=!0,Q=E+1;while(X&&Q<N.len&&N.kinds[Q]==="text"&&KX(N.texts[Q],N.isWordLike[Q])){let S=N.texts[Q];Y.push(S),X=pM(S),Q++}F.push(t0(Y)),A.push(!0),M.push("text"),D.push(N.starts[E]),E=Q-1;continue}F.push($),A.push(Z),M.push(y),D.push(N.starts[E])}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function HX(N){let F=[],A=[],M=[],D=[];for(let E=0;E<N.len;E++){let $=N.texts[E];if(N.kinds[E]==="text"&&$.includes("-")){let y=$.split("-"),Z=y.length>1;for(let Y=0;Y<y.length;Y++){let X=y[Y];if(!Z)break;if(X.length===0||!xM(X)||!TN(X))Z=!1}if(Z){let Y=0;for(let X=0;X<y.length;X++){let Q=y[X],S=X<y.length-1?`${Q}-`:Q;F.push(S),A.push(!0),M.push("text"),D.push(N.starts[E]+Y),Y+=S.length}continue}}F.push($),A.push(N.isWordLike[E]),M.push(N.kinds[E]),D.push(N.starts[E])}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function _X(N){let F=[],A=[],M=[],D=[],E=0;while(E<N.len){let $=[N.texts[E]],y=N.isWordLike[E],Z=N.kinds[E],Y=N.starts[E];if(Z==="glue"){let X=[$[0]],Q=Y;E++;while(E<N.len&&N.kinds[E]==="glue")X.push(N.texts[E]),E++;let S=t0(X);if(E<N.len&&N.kinds[E]==="text")$[0]=S,$.push(N.texts[E]),y=N.isWordLike[E],Z="text",Y=Q,E++;else{F.push(S),A.push(!1),M.push("glue"),D.push(Q);continue}}else E++;if(Z==="text")while(E<N.len&&N.kinds[E]==="glue"){let X=[];while(E<N.len&&N.kinds[E]==="glue")X.push(N.texts[E]),E++;let Q=t0(X);if(E<N.len&&N.kinds[E]==="text"){$.push(Q,N.texts[E]),y=y||N.isWordLike[E],E++;continue}$.push(Q)}F.push(t0($)),A.push(y),M.push(Z),D.push(Y)}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function BX(N){let F=N.texts.slice(),A=N.isWordLike.slice(),M=N.kinds.slice(),D=N.starts.slice();for(let E=0;E<F.length-1;E++){if(M[E]!=="text"||M[E+1]!=="text")continue;if(!c0(F[E])||!c0(F[E+1]))continue;let $=AX(F[E]);if($===null)continue;F[E]=$.head,F[E+1]=$.tail+F[E+1],D[E+1]=D[E]+$.head.length}return{len:F.length,texts:F,isWordLike:A,kinds:M,starts:D}}function PX(N,F,A){let M=kY(),D=0,E=[],$=[],y=[],Z=[],Y=[],X=[],Q=[],S=[],J=[],V=[],K=[],q=[];for(let _ of M.segment(N))for(let O of YX(_.segment,_.isWordLike??!1,_.index,A)){let R=function(){if(X[P]!==null)$[P]=[hM(E,X,Q,P)],X[P]=null;$[P].push(O.text),y[P]=y[P]||O.isWordLike,S[P]=S[P]||L,J[P]=J[P]||W,V[P]=g,K[P]=j,q[P]=IM(J[P],v)},w=O.kind==="text",b=MX(O.text,O.isWordLike,O.kind),L=c0(O.text),W=kM(O.text),v=jN(O.text),g=y6(O.text),j=DX(O.text),P=D-1;if(F.carryCJKAfterClosingQuote&&w&&D>0&&Z[P]==="text"&&L&&S[P]&&V[P])R();else if(w&&D>0&&Z[P]==="text"&&sY(O.text)&&S[P])R();else if(w&&D>0&&Z[P]==="text"&&K[P])R();else if(w&&D>0&&Z[P]==="text"&&O.isWordLike&&W&&q[P])R(),y[P]=!0;else if(b!==null&&D>0&&Z[P]==="text"&&X[P]===b)Q[P]=(Q[P]??1)+1;else if(w&&!O.isWordLike&&D>0&&Z[P]==="text"&&!S[P]&&(cY(O.text)||O.text==="-"&&y[P]))R();else E[D]=O.text,$[D]=[O.text],y[D]=O.isWordLike,Z[D]=O.kind,Y[D]=O.start,X[D]=b,Q[D]=b===null?0:1,S[D]=L,J[D]=W,V[D]=g,K[D]=j,q[D]=IM(W,v),D++}for(let _=0;_<D;_++){if(X[_]!==null){E[_]=hM(E,X,Q,_);continue}E[_]=t0($[_])}for(let _=1;_<D;_++)if(Z[_]==="text"&&!y[_]&&p4(E[_])&&Z[_-1]==="text"&&!S[_-1])E[_-1]+=E[_],y[_-1]=y[_-1]||y[_],E[_]="";let U=Array.from({length:D},()=>null),z=-1;for(let _=D-1;_>=0;_--){let O=E[_];if(O.length===0)continue;if(Z[_]==="text"&&!y[_]&&z>=0&&Z[z]==="text"&&(iY(O)||O==="-"&&FX(E[z]))){let w=U[z]??[];w.push(O),U[z]=w,Y[z]=Y[_],E[_]="";continue}z=_}for(let _=0;_<D;_++){let O=U[_];if(O==null)continue;E[_]=ZX(O,E[_])}let G=0;for(let _=0;_<D;_++){let O=E[_];if(O.length===0)continue;if(G!==_)E[G]=O,y[G]=y[_],Z[G]=Z[_],Y[G]=Y[_];G++}E.length=G,y.length=G,Z.length=G,Y.length=G;let H=_X({len:G,texts:E,isWordLike:y,kinds:Z,starts:Y}),B=BX(GX(HX(zX(VX(JX(H))))));for(let _=0;_<B.len-1;_++){let O=EX(B.texts[_]);if(O===null)continue;if(B.kinds[_]!=="space"&&B.kinds[_]!=="preserved-space"||B.kinds[_+1]!=="text"||!kM(B.texts[_+1]))continue;B.texts[_]=O.space,B.isWordLike[_]=!1,B.kinds[_]=B.kinds[_]==="preserved-space"?"preserved-space":"space",B.texts[_+1]=O.marks+B.texts[_+1],B.starts[_+1]=B.starts[_]+O.space.length}return B}function WX(N,F){if(N.len===0)return[];if(!F.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:N.len,consumedEndSegmentIndex:N.len}];let A=[],M=0;for(let D=0;D<N.len;D++){if(N.kinds[D]!=="hard-break")continue;A.push({startSegmentIndex:M,endSegmentIndex:D,consumedEndSegmentIndex:D+1}),M=D+1}if(M<N.len)A.push({startSegmentIndex:M,endSegmentIndex:N.len,consumedEndSegmentIndex:N.len});return A}function OX(N,F,A){if(F.len<=1)return F;let M=[],D=[],E=[],$=[],y=-1,Z=!1;function Y(S){M.push(F.texts[S]),D.push(F.isWordLike[S]),E.push("text"),$.push(F.starts[S])}function X(S,J){let V=!1;for(let U=S;U<J;U++)V=V||F.isWordLike[U];let K=F.starts[S],q=J<F.len?F.starts[J]:N.length;M.push(N.slice(K,q)),D.push(V),E.push("text"),$.push(K)}function Q(S){if(y<0)return;if(Z)if(y+1===S)Y(y);else X(y,S);else for(let J=y;J<S;J++)Y(J);y=-1,Z=!1}for(let S=0;S<F.len;S++){let J=F.texts[S],V=F.kinds[S];if(V==="text"){if(y>=0&&!h4(F.texts[S-1],A))Q(S);if(y<0)y=S;Z=Z||c0(J);continue}Q(S),M.push(J),D.push(F.isWordLike[S]),E.push(V),$.push(F.starts[S])}return Q(F.len),{len:M.length,texts:M,isWordLike:D,kinds:E,starts:$}}function lM(N,F,A="normal",M="normal"){let D=fY(A),E=D.mode==="pre-wrap"?vY(N):uY(N);if(E.length===0)return{normalized:E,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let $=PX(E,F,D),y=M==="keep-all"?OX(E,$,F.breakKeepAllAfterPunctuation):$;return{normalized:E,chunks:WX(y,D),...y}}var g2=null,dM=new Map,h2=null,wX=96,LX=/\p{Emoji_Presentation}/u,TX=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,x4=null,aM=new Map;function l4(){if(g2!==null)return g2;if(typeof OffscreenCanvas<"u")return g2=new OffscreenCanvas(1,1).getContext("2d"),g2;if(typeof document<"u")return g2=document.createElement("canvas").getContext("2d"),g2;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function CX(N){let F=dM.get(N);if(!F)F=new Map,dM.set(N,F);return F}function U1(N,F){let A=F.get(N);if(A===void 0)A={width:l4().measureText(N).width,containsCJK:c0(N)},F.set(N,A);return A}function u1(){if(h2!==null)return h2;if(typeof navigator>"u")return h2={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,breakKeepAllAfterPunctuation:!0,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},h2;let N=navigator.userAgent,A=navigator.vendor==="Apple Computer, Inc."&&N.includes("Safari/")&&!N.includes("Chrome/")&&!N.includes("Chromium/")&&!N.includes("CriOS/")&&!N.includes("FxiOS/")&&!N.includes("EdgiOS/"),M=N.includes("Chrome/")||N.includes("Chromium/")||N.includes("CriOS/")||N.includes("Edg/");return h2={lineFitEpsilon:A?0.015625:0.005,carryCJKAfterClosingQuote:M,breakKeepAllAfterPunctuation:!A,preferPrefixWidthsForBreakableRuns:A,preferEarlySoftHyphenBreak:A},h2}function jX(N){let F=N.match(/(\d+(?:\.\d+)?)\s*px/);return F?parseFloat(F[1]):16}function rM(){if(x4===null)x4=new Intl.Segmenter(void 0,{granularity:"grapheme"});return x4}function RX(N){return LX.test(N)||N.includes("️")}function cM(N){return TX.test(N)}function bX(N,F){let A=aM.get(N);if(A!==void 0)return A;let M=l4();M.font=N;let D=M.measureText("\uD83D\uDE00").width;if(A=0,D>F+0.5&&typeof document<"u"&&document.body!==null){let E=document.createElement("span");E.style.font=N,E.style.display="inline-block",E.style.visibility="hidden",E.style.position="absolute",E.textContent="\uD83D\uDE00",document.body.appendChild(E);let $=E.getBoundingClientRect().width;if(document.body.removeChild(E),D-$>0.5)A=D-$}return aM.set(N,A),A}function fX(N){let F=0,A=rM();for(let M of A.segment(N))if(RX(M.segment))F++;return F}function uX(N,F){if(F.emojiCount===void 0)F.emojiCount=fX(N);return F.emojiCount}function f1(N,F,A){if(A===0)return F.width;return F.width-uX(N,F)*A}function sM(N,F,A,M,D){if(F.breakableFitAdvances!==void 0&&F.breakableFitMode===D)return F.breakableFitAdvances;F.breakableFitMode=D;let E=rM(),$=[];for(let X of E.segment(N))$.push(X.segment);if($.length<=1)return F.breakableFitAdvances=null,F.breakableFitAdvances;if(D==="sum-graphemes"){let X=[];for(let Q of $){let S=U1(Q,A);X.push(f1(Q,S,M))}return F.breakableFitAdvances=X,F.breakableFitAdvances}if(D==="pair-context"||$.length>wX){let X=[],Q=null,S=0;for(let J of $){let V=U1(J,A),K=f1(J,V,M);if(Q===null)X.push(K);else{let q=Q+J,U=U1(q,A);X.push(f1(q,U,M)-S)}Q=J,S=K}return F.breakableFitAdvances=X,F.breakableFitAdvances}let y=[],Z="",Y=0;for(let X of $){Z+=X;let Q=U1(Z,A),S=f1(Z,Q,M);y.push(S-Y),Y=S}return F.breakableFitAdvances=y,F.breakableFitAdvances}function iM(N,F){let A=l4();A.font=N;let M=CX(N),D=jX(N),E=F?bX(N,D):0;return{cache:M,fontSize:D,emojiCorrection:E}}function vX(N){return N==="space"||N==="zero-width-break"||N==="soft-hyphen"}function X6(N){return N==="space"||N==="preserved-space"||N==="tab"||N==="zero-width-break"||N==="soft-hyphen"}function d4(N,F,A=N.widths.length){while(F<A){let M=N.kinds[F];if(!vX(M))break;F++}return F}function oM(N,F){if(F<=0)return 0;let A=N%F;if(Math.abs(A)<=0.000001)return F;return F-A}function nM(N,F,A){return N.letterSpacing!==0&&F&&N.spacingGraphemeCounts[A]>0?N.letterSpacing:0}function a4(N,F){return F===0?0:N+F}function mX(N,F){return N.letterSpacing!==0&&N.spacingGraphemeCounts[F]>0?N.letterSpacing:0}function tM(N,F,A,M,D){let E=F==="tab"?D+mX(N,A):N.lineEndFitAdvances[A];return a4(M,E)}function Z6(N,F,A,M){let D=F==="tab"?0:N.lineEndFitAdvances[A];return a4(M,D)}function Y6(N,F,A,M,D){let E=F==="tab"?D:N.lineEndPaintAdvances[A];return a4(M,E)}function eM(N,F,A){return N.letterSpacing!==0&&F?A+N.letterSpacing:A}function ND(N,F){return N.letterSpacing===0?F:F+N.letterSpacing}function kX(N,F,A,M,D){if(N.letterSpacing===0)return 0;if(D>0)return N.spacingGraphemeCounts[M]>0?N.letterSpacing:0;for(let E=M-1;E>=F;E--){let $=N.kinds[E];if($==="space"||$==="zero-width-break"||$==="hard-break")continue;if($==="soft-hyphen"){if(E===M-1)return 0;continue}if(E===F&&A>0)return N.letterSpacing;return N.spacingGraphemeCounts[E]>0?N.letterSpacing:0}return 0}function FD(N,F,A,M,D,E){return F+kX(N,A,M,D,E)}function gX(N,F){let A=0,M=N.chunks.length;while(A<M){let D=Math.floor((A+M)/2);if(F<N.chunks[D].consumedEndSegmentIndex)M=D;else A=D+1}return A<N.chunks.length?A:-1}function hX(N,F,A){let M=A.segmentIndex;if(A.graphemeIndex>0)return F;let D=N.chunks[F];if(D.startSegmentIndex===D.endSegmentIndex&&M===D.startSegmentIndex)return A.segmentIndex=M,A.graphemeIndex=0,F;if(M<D.startSegmentIndex)M=D.startSegmentIndex;if(M=d4(N,M,D.endSegmentIndex),M<D.endSegmentIndex)return A.segmentIndex=M,A.graphemeIndex=0,F;if(D.consumedEndSegmentIndex>=N.widths.length)return-1;return A.segmentIndex=D.consumedEndSegmentIndex,A.graphemeIndex=0,F+1}function AD(N,F){if(F.segmentIndex>=N.widths.length)return-1;let A=gX(N,F.segmentIndex);if(A<0)return-1;return hX(N,A,F)}function IX(N,F,A){let{widths:M,kinds:D,breakableFitAdvances:E}=N;if(M.length===0)return 0;let y=u1().lineFitEpsilon,Z=F+y,Y=0,X=0,Q=!1,S=0,J=0,V=0,K=0,q=-1,U=0;function z(){q=-1,U=0}function G(b=V,L=K,W=X){Y++,A?.(W,S,J,b,L),X=0,Q=!1,z()}function H(b,L){Q=!0,S=b,J=0,V=b+1,K=0,X=L}function B(b,L,W){Q=!0,S=b,J=L,V=b,K=L+1,X=W}function _(b,L){if(!Q){H(b,L);return}X+=L,V=b+1,K=0}function O(b,L){let W=E[b];for(let v=L;v<W.length;v++){let g=W[v];if(!Q)B(b,v,g);else if(X+g>Z)G(),B(b,v,g);else X+=g,V=b,K=v+1}if(Q&&V===b&&K===W.length)V=b+1,K=0}let w=0;while(w<M.length){if(!Q){if(w=d4(N,w),w>=M.length)break}let b=M[w],L=D[w],W=X6(L);if(!Q){if(b>Z&&E[w]!==null)O(w,0);else H(w,b);if(W)q=w+1,U=X-b;w++;continue}if(X+b>Z){if(W){_(w,b),G(w+1,0,X-b),w++;continue}if(q>=0){if(V>q||V===q&&K>0){G();continue}G(q,0,U);continue}if(b>Z&&E[w]!==null){G(),O(w,0),w++;continue}G();continue}if(_(w,b),W)q=w+1,U=X-b;w++}if(Q)G();return Y}function r4(N,F,A){if(N.simpleLineWalkFastPath)return IX(N,F,A);let{widths:M,kinds:D,breakableFitAdvances:E,discretionaryHyphenWidth:$,chunks:y}=N;if(M.length===0||y.length===0)return 0;let Z=u1(),Y=Z.lineFitEpsilon,X=F+Y,Q=0,S=0,J=!1,V=0,K=0,q=0,U=0,z=-1,G=0,H=0,B=null;function _(){z=-1,G=0,H=0,B=null}function O(){return B==="soft-hyphen"&&z===q&&U===0?H:S}function w(P=q,R=U,f){if(Q++,A!==void 0)A(FD(N,f??O(),V,K,P,R),V,K,P,R);S=0,J=!1,_()}function b(P,R){J=!0,V=P,K=0,q=P+1,U=0,S=R}function L(P,R,f){J=!0,V=P,K=R,q=P,U=R+1,S=f}function W(P,R){if(!J){b(P,R);return}S+=R,q=P+1,U=0}function v(P,R,f,m,x,r){if(!R)return;let i=Z6(N,P,f,x),B0=Y6(N,P,f,x,m);z=f+1,G=S-r+i,H=S-r+B0,B=P}function g(P,R){let f=E[P];for(let m=R;m<f.length;m++){let x=f[m];if(!J)L(P,m,x);else{let r=eM(N,!0,x),i=S+r;if(ND(N,i)>X)w(),L(P,m,x);else S=i,q=P,U=m+1}}if(J&&q===P&&U===f.length)q=P+1,U=0}function j(P){Q++,A?.(0,P.startSegmentIndex,0,P.consumedEndSegmentIndex,0),_()}for(let P=0;P<y.length;P++){let R=y[P];if(R.startSegmentIndex===R.endSegmentIndex){j(R);continue}J=!1,S=0,V=R.startSegmentIndex,K=0,q=R.startSegmentIndex,U=0,_();let f=R.startSegmentIndex;while(f<R.endSegmentIndex){if(!J){if(f=d4(N,f,R.endSegmentIndex),f>=R.endSegmentIndex)break}let m=D[f],x=X6(m),r=nM(N,J,f),i=m==="tab"?oM(S+r,N.tabStopAdvance):M[f],B0=r+i,Q0=tM(N,m,f,r,i);if(m==="soft-hyphen"){if(J)q=f+1,U=0,z=f+1,G=S+$,H=S+$,B=m;f++;continue}if(!J){if(Q0>X&&E[f]!==null)g(f,0);else b(f,i);v(m,x,f,i,r,B0),f++;continue}if(S+Q0>X){let l=S+Z6(N,m,f,r),o=S+Y6(N,m,f,r,i);if(B==="soft-hyphen"&&Z.preferEarlySoftHyphenBreak&&G<=X){w(z,0,H);continue}if(x&&l<=X){W(f,B0),w(f+1,0,o),f++;continue}if(z>=0&&G<=X){if(q>z||q===z&&U>0){w();continue}let a=z;w(a,0,H),f=a;continue}if(Q0>X&&E[f]!==null){w(),g(f,0),f++;continue}w();continue}W(f,B0),v(m,x,f,i,r,B0),f++}if(J){let m=z===R.consumedEndSegmentIndex?H:S;w(R.consumedEndSegmentIndex,0,m)}}return Q}function pX(N,F,A,M){let D=N.chunks[A];if(D.startSegmentIndex===D.endSegmentIndex)return F.segmentIndex=D.consumedEndSegmentIndex,F.graphemeIndex=0,0;let{widths:E,kinds:$,breakableFitAdvances:y,discretionaryHyphenWidth:Z}=N,Y=u1(),X=Y.lineFitEpsilon,Q=M+X,S=F.segmentIndex,J=F.graphemeIndex,V=0,K=!1,q=F.segmentIndex,U=F.graphemeIndex,z=-1,G=0,H=0,B=null;function _(){return B==="soft-hyphen"&&z===q&&U===0?H:V}function O(j=q,P=U,R=_()){if(!K)return null;return F.segmentIndex=j,F.graphemeIndex=P,FD(N,R,S,J,j,P)}function w(j,P){K=!0,q=j+1,U=0,V=P}function b(j,P,R){K=!0,q=j,U=P+1,V=R}function L(j,P){if(!K){w(j,P);return}V+=P,q=j+1,U=0}function W(j,P,R,f,m,x){if(!P)return;let r=Z6(N,j,R,m),i=Y6(N,j,R,m,f);z=R+1,G=V-x+r,H=V-x+i,B=j}function v(j,P){let R=y[j];for(let f=P;f<R.length;f++){let m=R[f];if(!K)b(j,f,m);else{let x=eM(N,!0,m),r=V+x;if(ND(N,r)>Q)return O();V=r,q=j,U=f+1}}if(K&&q===j&&U===R.length)q=j+1,U=0;return null}function g(){if(B!=="soft-hyphen"||z<0)return null;if(G<=Q)return O(z,0,H);return null}for(let j=F.segmentIndex;j<D.endSegmentIndex;j++){let P=$[j],R=X6(P),f=j===F.segmentIndex?F.graphemeIndex:0,m=nM(N,K,j),x=P==="tab"?oM(V+m,N.tabStopAdvance):E[j],r=m+x,i=tM(N,P,j,m,x);if(P==="soft-hyphen"&&f===0){if(K)q=j+1,U=0,z=j+1,G=V+Z,H=V+Z,B=P;continue}if(!K){if(f>0){let Q0=v(j,f);if(Q0!==null)return Q0}else if(i>Q&&y[j]!==null){let Q0=v(j,0);if(Q0!==null)return Q0}else w(j,x);W(P,R,j,x,m,r);continue}if(V+i>Q){let Q0=V+Z6(N,P,j,m),u=V+Y6(N,P,j,m,x);if(B==="soft-hyphen"&&Y.preferEarlySoftHyphenBreak&&G<=Q)return O(z,0,H);let l=g();if(l!==null)return l;if(R&&Q0<=Q)return L(j,r),O(j+1,0,u);if(z>=0&&G<=Q){if(q>z||q===z&&U>0)return O();return O(z,0,H)}if(i>Q&&y[j]!==null){let o=O();if(o!==null)return o;let a=v(j,0);if(a!==null)return a}return O()}L(j,r),W(P,R,j,x,m,r)}if(z===D.consumedEndSegmentIndex&&U===0)return O(D.consumedEndSegmentIndex,0,H);return O(D.consumedEndSegmentIndex,0,V)}function xX(N,F,A){let{widths:M,kinds:D,breakableFitAdvances:E}=N,y=u1().lineFitEpsilon,Z=A+y,Y=0,X=!1,Q=F.segmentIndex,S=F.graphemeIndex,J=-1,V=0;for(let K=F.segmentIndex;K<M.length;K++){let q=D[K],U=X6(q),z=K===F.segmentIndex?F.graphemeIndex:0,G=E[K],H=M[K];if(!X){if(z>0||H>Z&&G!==null){let B=G,_=B[z];X=!0,Y=_,Q=K,S=z+1;for(let O=z+1;O<B.length;O++){let w=B[O];if(Y+w>Z)return F.segmentIndex=Q,F.graphemeIndex=S,Y;Y+=w,Q=K,S=O+1}if(Q===K&&S===B.length)Q=K+1,S=0}else X=!0,Y=H,Q=K+1,S=0;if(U)J=K+1,V=Y-H;continue}if(Y+H>Z){if(U)return F.segmentIndex=K+1,F.graphemeIndex=0,Y;if(J>=0){if(Q>J||Q===J&&S>0)return F.segmentIndex=Q,F.graphemeIndex=S,Y;return F.segmentIndex=J,F.graphemeIndex=0,V}return F.segmentIndex=Q,F.graphemeIndex=S,Y}if(Y+=H,Q=K+1,S=0,U)J=K+1,V=Y-H}if(!X)return null;return F.segmentIndex=Q,F.graphemeIndex=S,Y}function MD(N,F,A,M){if(N.simpleLineWalkFastPath)return xX(N,F,M);return pX(N,F,A,M)}function Q6(N,F,A){let M=AD(N,F);if(M<0)return null;return MD(N,F,M,A)}var c4=null;function ED(){if(c4===null)c4=new Intl.Segmenter(void 0,{granularity:"grapheme"});return c4}function lX(N){if(N)return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],letterSpacing:0,spacingGraphemeCounts:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]};return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],letterSpacing:0,spacingGraphemeCounts:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function dX(N,F){let A=[],M=[],D=0,E=!1,$=!1,y=!1;function Z(){if(M.length===0)return;A.push({text:M.length===1?M[0]:M.join(""),start:D}),M=[],E=!1,$=!1,y=!1}function Y(Q,S,J){M=[Q],D=S,E=J,$=y6(Q),y=CN.has(Q)}function X(Q,S){M.push(Q),E=E||S;let J=y6(Q);if(Q.length===1&&b1.has(Q))$=$||J;else $=J;y=!1}for(let Q of ED().segment(N)){let S=Q.segment,J=c0(S);if(M.length===0){Y(S,Q.index,J);continue}if(y||D6.has(S)||b1.has(S)||F.carryCJKAfterClosingQuote&&J&&$){X(S,J);continue}if(!E&&!J){X(S,J);continue}Z(),Y(S,Q.index,J)}return Z(),A}function aX(N,F,A){if(F.length<=1)return F;let M=[],D=-1,E=!1;function $(Z,Y){let X=F[Z].start,Q=Y<F.length?F[Y].start:N.length;M.push({text:N.slice(X,Q),start:X})}function y(Z){if(D<0)return;if(E)if(D+1===Z)M.push(F[D]);else $(D,Z);else for(let Y=D;Y<Z;Y++)M.push(F[Y]);D=-1,E=!1}for(let Z=0;Z<F.length;Z++){let Y=F[Z];if(D>=0&&!h4(F[Z-1].text,A))y(Z);if(D<0)D=Z;E=E||c0(Y.text)}return y(F.length),M}function DD(N,F){if(F==="zero-width-break"||F==="soft-hyphen"||F==="hard-break")return 0;if(F==="tab")return 1;let A=0,M=ED();for(let D of M.segment(N))A++;return A}function rX(N,F,A){return F>1?N+(F-1)*A:N}function cX(N,F,A,M,D){let E=u1(),{cache:$,emojiCorrection:y}=iM(F,cM(N.normalized)),Z=f1("-",U1("-",$),y)+(D===0?0:D*2),X=f1(" ",U1(" ",$),y)*8,Q=D!==0;if(N.len===0)return lX(A);let S=[],J=[],V=[],K=[],q=N.chunks.length<=1&&!Q,U=A?[]:null,z=[],G=[],H=A?[]:null,B=Array.from({length:N.len});function _(L,W,v,g,j,P,R,f){if(j!=="text"&&j!=="space"&&j!=="zero-width-break")q=!1;if(S.push(W),J.push(v),V.push(g),K.push(j),U?.push(P),z.push(R),Q)G.push(f);if(H!==null)H.push(L)}function O(L,W,v,g,j){let P=U1(L,$),R=Q?DD(L,W):0,f=rX(f1(L,P,y),R,D),m=W==="space"||W==="preserved-space"||W==="zero-width-break"?0:f,x=m===0?0:m+(R>0?D:0),r=W==="space"||W==="zero-width-break"?0:f;if(j&&g&&L.length>1){let i="sum-graphemes";if(D!==0)i="segment-prefixes";else if(TN(L))i="pair-context";else if(E.preferPrefixWidthsForBreakableRuns)i="segment-prefixes";let B0=sM(L,P,$,y,i);_(L,f,x,r,W,v,B0,R);return}_(L,f,x,r,W,v,null,R)}for(let L=0;L<N.len;L++){B[L]=S.length;let W=N.texts[L],v=N.isWordLike[L],g=N.kinds[L],j=N.starts[L];if(g==="soft-hyphen"){_(W,0,Z,Z,g,j,null,0);continue}if(g==="hard-break"){_(W,0,0,0,g,j,null,0);continue}if(g==="tab"){_(W,0,0,0,g,j,null,Q?DD(W,g):0);continue}let P=U1(W,$);if(g==="text"&&P.containsCJK){let R=dX(W,E),f=M==="keep-all"?aX(W,R,E.breakKeepAllAfterPunctuation):R;for(let m=0;m<f.length;m++){let x=f[m];O(x.text,"text",j+x.start,v,M==="keep-all"||!c0(x.text))}continue}O(W,g,j,v,!0)}let w=sX(N.chunks,B,S.length),b=U===null?null:mM(N.normalized,U);if(H!==null)return{widths:S,lineEndFitAdvances:J,lineEndPaintAdvances:V,kinds:K,simpleLineWalkFastPath:q,segLevels:b,breakableFitAdvances:z,letterSpacing:D,spacingGraphemeCounts:G,discretionaryHyphenWidth:Z,tabStopAdvance:X,chunks:w,segments:H};return{widths:S,lineEndFitAdvances:J,lineEndPaintAdvances:V,kinds:K,simpleLineWalkFastPath:q,segLevels:b,breakableFitAdvances:z,letterSpacing:D,spacingGraphemeCounts:G,discretionaryHyphenWidth:Z,tabStopAdvance:X,chunks:w}}function sX(N,F,A){let M=[];for(let D=0;D<N.length;D++){let E=N[D],$=E.startSegmentIndex<F.length?F[E.startSegmentIndex]:A,y=E.endSegmentIndex<F.length?F[E.endSegmentIndex]:A,Z=E.consumedEndSegmentIndex<F.length?F[E.consumedEndSegmentIndex]:A;M.push({startSegmentIndex:$,endSegmentIndex:y,consumedEndSegmentIndex:Z})}return M}function iX(N,F,A,M){let D=M?.wordBreak??"normal",E=M?.letterSpacing??0,$=lM(N,u1(),M?.whiteSpace,D);return cX($,F,A,D,E)}function I2(N,F,A){return iX(N,F,!0,A)}function $D(N){return N}function oX(N,F,A,M,D){return{width:N,start:{segmentIndex:F,graphemeIndex:A},end:{segmentIndex:M,graphemeIndex:D}}}function yD(N,F,A){if(N.widths.length===0)return 0;return r4($D(N),F,(M,D,E,$,y)=>{A(oX(M,D,E,$,y))})}function s4(N){let F=0;return r4($D(N),Number.POSITIVE_INFINITY,(A)=>{if(A>F)F=A}),F}var nX=/[ \t\n\f\r]+/,ZD=/^[ \t\n\f\r]+/,YD=/[ \t\n\f\r]+$/,XD={segmentIndex:0,graphemeIndex:0},SD={itemIndex:0,segmentIndex:0,graphemeIndex:0};function tX(N){return N}function i4(N){return{segmentIndex:N.segmentIndex,graphemeIndex:N.graphemeIndex}}function QD(N){return N.segmentIndex===0&&N.graphemeIndex===0}function S6(N,F,A){let M=`${N}\x00${F}`,D=A.get(M);if(D!==void 0)return D;let E=F===0?void 0:{letterSpacing:F},$=s4(I2("A A",N,E)),y=s4(I2("AA",N,E)),Z=Math.max(0,$-y);return A.set(M,Z),Z}function eX(N){let F={segmentIndex:0,graphemeIndex:0},A=Q6(N,F,Number.POSITIVE_INFINITY);if(A===null)return null;return{endGraphemeIndex:F.graphemeIndex,endSegmentIndex:F.segmentIndex,width:A}}function NQ(N,F){return N===0&&F>0}function JD(N){let F=[],A=Array.from({length:N.length}),M=new Map,D=0;for(let E=0;E<N.length;E++){let $=N[E],y=$.letterSpacing??0,Z=ZD.test($.text),Y=YD.test($.text),X=$.text.replace(ZD,"").replace(YD,"");if(X.length===0){if(nX.test($.text)&&D===0)D=S6($.font,y,M);continue}let Q=D>0?D:Z?S6($.font,y,M):0,S=I2(X,$.font,y===0?void 0:{letterSpacing:y}),J=eX(S);if(J===null){D=Y?S6($.font,y,M):0;continue}let V={break:$.break??"normal",endGraphemeIndex:J.endGraphemeIndex,endSegmentIndex:J.endSegmentIndex,extraWidth:$.extraWidth??0,gapBefore:Q,naturalWidth:J.width,prepared:S,sourceItemIndex:E};F.push(V),A[E]=V,D=Y?S6($.font,y,M):0}return{items:F,itemsBySourceItemIndex:A}}function FQ(N,F,A,M){if(N.items.length===0||A.itemIndex>=N.items.length)return null;let D=Math.max(1,F),E=0,$=D,y=A.itemIndex;N:while(y<N.items.length){let Z=N.items[y];if(!QD(A)&&A.segmentIndex===Z.endSegmentIndex&&A.graphemeIndex===Z.endGraphemeIndex){y++,A.segmentIndex=0,A.graphemeIndex=0;continue}let Y=E===0?0:Z.gapBefore,X=QD(A);if(Z.break==="never"){if(!X){y++,A.segmentIndex=0,A.graphemeIndex=0;continue}let U=Z.naturalWidth+Z.extraWidth,z=Y+U;if(E>0&&z>$)break N;M?.(Z,Y,U,i4(XD),{segmentIndex:Z.endSegmentIndex,graphemeIndex:Z.endGraphemeIndex}),E+=z,$=Math.max(0,D-E),y++,A.segmentIndex=0,A.graphemeIndex=0;continue}let Q=Y+Z.extraWidth;if(E>0&&Q>=$)break N;if(X){let U=Q+Z.naturalWidth;if(U<=$){M?.(Z,Y,Z.naturalWidth+Z.extraWidth,i4(XD),{segmentIndex:Z.endSegmentIndex,graphemeIndex:Z.endGraphemeIndex}),E+=U,$=Math.max(0,D-E),y++,A.segmentIndex=0,A.graphemeIndex=0;continue}}let S=Math.max(1,$-Q),J={segmentIndex:A.segmentIndex,graphemeIndex:A.graphemeIndex},V=Q6(Z.prepared,J,S);if(V===null){y++,A.segmentIndex=0,A.graphemeIndex=0;continue}if(A.segmentIndex===J.segmentIndex&&A.graphemeIndex===J.graphemeIndex){y++,A.segmentIndex=0,A.graphemeIndex=0;continue}let K=V+Z.extraWidth,q=Y+K;if(E>0&&X&&q>$)break N;if(E>0&&X&&Y>0&&NQ(J.segmentIndex,J.graphemeIndex)){let U={segmentIndex:0,graphemeIndex:0};if(Q6(Z.prepared,U,Math.max(1,D-Z.extraWidth))!==null&&(U.segmentIndex>J.segmentIndex||U.segmentIndex===J.segmentIndex&&U.graphemeIndex>J.graphemeIndex))break N}if(M?.(Z,Y,K,i4(A),{segmentIndex:J.segmentIndex,graphemeIndex:J.graphemeIndex}),E+=q,$=Math.max(0,D-E),J.segmentIndex===Z.endSegmentIndex&&J.graphemeIndex===Z.endGraphemeIndex){y++,A.segmentIndex=0,A.graphemeIndex=0;continue}A.segmentIndex=J.segmentIndex,A.graphemeIndex=J.graphemeIndex;break}if(E===0)return null;return A.itemIndex=y,E}function AQ(N,F,A=SD){let M=tX(N),D={itemIndex:A.itemIndex,segmentIndex:A.segmentIndex,graphemeIndex:A.graphemeIndex},E=[],$=FQ(M,F,D,(y,Z,Y,X,Q)=>{E.push({itemIndex:y.sourceItemIndex,gapBefore:Z,occupiedWidth:Y,start:X,end:Q})});if($===null)return null;return{fragments:E,width:$,end:D}}function VD(N,F,A){let M=0,D=SD;while(!0){let E=AQ(N,F,D);if(E===null)return M;A(E),M++,D=E.end}}var J6;function p2(N){if(N.length===0)return[];let F=EQ();if(!F)return Array.from(N);return Array.from(F.segment(N),(A)=>A.segment)}function MQ(N,F){let A=p2(N.slice(0,F));if(A.length===0)return 0;return F-A.at(-1).length}function DQ(N,F){let A=p2(N.slice(F))[0];return A?F+A.length:N.length}function RN(N,F,A){return A<0?MQ(N,F):DQ(N,F)}function EQ(){if(J6!==void 0)return J6;let N=Intl.Segmenter;return J6=typeof N==="function"?new N(void 0,{granularity:"grapheme"}):null,J6}var qD="15px ui-monospace, SFMono-Regular, Menlo, monospace";function UD(N,F){return K1(N,F,!1)}function K1(N,F,A){let M=A?"15px ui-monospace, SFMono-Regular, Menlo, monospace":N,D=[];if(F.includes("italic"))D.push("italic");if(F.includes("bold"))D.push("700");return D.length>0?`${D.join(" ")} ${M}`:M}function bN(N,F,A){let M=N.image?F.images.get(N.image.url)??null:null,D=N.image?.width??null,E=Math.min(A,D??240),$=Math.max(120,Math.round(E*0.5625));if(!M||M.intrinsicWidth<=0||M.intrinsicHeight<=0)return{height:$,width:E};let y=Math.min(A,D??M.intrinsicWidth),Z=Math.min(1,y/M.intrinsicWidth);return{height:Math.max(48,Math.round(M.intrinsicHeight*Z)),width:Math.max(48,Math.round(M.intrinsicWidth*Z))}}function KD(N,F){if(!N.image)return`${N.kind}:missing-image`;let A=F.images.get(N.image.url);return`${N.kind}:${N.image.url}:${N.image.width??0}:${A?.status??"loading"}:${A?.intrinsicWidth??0}:${A?.intrinsicHeight??0}`}var V6=4;function o4(N,F){return Math.max(18,N.measureText(`@${F.name}`).width+8)}var zD=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],GD='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',$Q=32,n4;function x2(N){if(N?.type==="heading"){let{fontSize:F}=BD(N.depth);return`700 ${F}px ${GD}`}switch(N?.type){case"code":return qD;default:return`16px ${GD}`}}function v1(N,F){if(N?.type==="heading")return BD(N.depth).lineHeight;if(N?.type==="code")return 22;return F}function BD(N){return zD[N-1]??zD.at(-1)}function e4(N){return yQ(N)?N.split(""):p2(N)}function yQ(N){for(let F=0;F<N.length;F+=1)if(N.charCodeAt(F)>127)return!1;return!0}function l2(N,F,A,M,D,E,$){let y=`${U6(F,$)}:${D}:${E}:${A}`,Z=N.measuredLines.get(y);if(Z)return Z;let Y=YQ(N,F,A,M,D,E,$);return WM(N,y,Y)}function q6(N,F,A,M,D,E,$,y){let Z=`${U6(F,y)}:${A}:${M}:${E}:${$}`,Y=N.lineBoundaries.get(Z);if(Y)return Y;let X=WD(),Q=[{left:0,offset:0}],S=0,J=F.inlines.filter((V)=>V.end>A&&V.start<M);for(let V of J){let K=Math.max(A,V.start),q=Math.min(M,V.end),U=F.text.slice(K,q),z=K-A;if(V.kind==="image"){let G=bN(V,y,$).width;S+=G,z+=U.length,Q.push({left:S,offset:z});continue}if(X.font=K1(E,V.marks,V.inlineCode),K6(V)){S+=o4(X,V.mention),z+=U.length,Q.push({left:S,offset:z});continue}for(let G of OQ(N,X,U))S+=G.width,z+=G.length,Q.push({left:S,offset:z})}return OM(N,Z,Q)}function ZQ(N,F,A,M){let D=`${A}::${M}::${F}`,E=N.preparedText.get(D);if(E)return E;let $=I2(F,A,{whiteSpace:M});return PM(N,D,$)}function YQ(N,F,A,M,D,E,$){let y=F.text,Z=GQ(F);if(y.length===0)return[{end:0,height:E,start:0,text:"",width:0}];if(HQ(Z))return QQ(N,F,A,D,E,$);if(Z.hasRichInline)return SQ(F,A,D,E);let Y=ZQ(N,y,A,LQ(M,Z)),X=PD(Y.segments),Q=[];if(yD(Y,D,(S)=>{let J=X(S.start),V=XQ(y,J,X(S.end));Q.push({end:V,height:E,start:J,text:y.slice(J,V),width:S.width})}),Z.hasHardBreak&&y.endsWith(`
13
+ `))Q.push({end:y.length,height:E,start:y.length,text:"",width:0});return Q}function XQ(N,F,A){return A>F&&N[A-1]===`
14
+ `?A-1:A}function QQ(N,F,A,M,D,E){let $=zQ(N,WD(),F,A,M,D,E);if($.length===0)return[{end:0,height:D,start:0,text:"",width:0}];return KQ($,F.text,M,D)}function SQ(N,F,A,M){let{items:D,measurementItems:E}=JQ(N,F);if(D.length===0)return[{end:0,height:M,start:0,text:"",width:0}];let $=JD(D),y=$,Z=[];return VD($,A,(Y)=>{let X=VQ(y,E,Y.fragments);if(!X)return;Z.push({end:X.end,height:M,start:X.start,text:N.text.slice(X.start,X.end),width:Y.width})}),Z.length>0?Z:[{end:0,height:M,start:0,text:"",width:0}]}function JQ(N,F){let A=[],M=[];for(let D of N.inlines){if(D.kind==="mention"&&D.mention){A.push({break:"never",extraWidth:V6*2,font:K1(F,D.marks,D.inlineCode),text:`@${D.mention.name}`}),M.push({leadingTrimLength:0,run:D});continue}A.push({font:K1(F,D.marks,D.inlineCode),text:D.text}),M.push({leadingTrimLength:UQ(D.text),run:D})}return{items:A,measurementItems:M}}function VQ(N,F,A){let M=null,D=null;for(let E of A){let $=HD(N,F,E,"start"),y=HD(N,F,E,"end");if($===null||y===null)continue;M=M===null?$:Math.min(M,$),D=D===null?y:Math.max(D,y)}return M===null||D===null?null:{end:D,start:M}}function HD(N,F,A,M){let D=F[A.itemIndex],E=N.itemsBySourceItemIndex[A.itemIndex];if(!D||!E)return null;let{run:$}=D;if($.kind==="mention")return M==="start"?$.start:$.end;let y=M==="start"?A.start:A.end;return $.start+D.leadingTrimLength+PD(E.prepared.segments)(y)}function PD(N){let F=[],A=new Map,M=0;for(let D of N)F.push(M),M+=D.length;return(D)=>{let E=F[D.segmentIndex]??M;if(D.graphemeIndex===0)return E;let $=A.get(D.segmentIndex);if(!$)$=qQ(N[D.segmentIndex]??""),A.set(D.segmentIndex,$);return E+($[D.graphemeIndex]??0)}}function qQ(N){let F=[0],A=0;for(let M of e4(N))A+=M.length,F.push(A);return F}function UQ(N){return N.match(/^[ \t\n\f\r]+/)?.[0].length??0}function KQ(N,F,A,M){let D=[],E=0;while(E<N.length){let y=N[E].start;if(N[E].text===`
15
+ `){D.push({end:y,height:M,start:y,text:"",width:0}),E+=1;continue}let Z=0,Y=0,X=E,Q=-1,S=M;while(X<N.length){let V=N[X];if(V.text===`
16
+ `)break;let K=Z+V.width;if(K>A&&X>E)break;if(Z=K,S=Math.max(S,V.height),V.breakable)Q=X,Y=Z;X+=1}if(X===N.length||N[X]?.text===`
17
+ `){let V=N[X-1]?.end??y;D.push({end:V,height:S,start:y,text:F.slice(y,V),width:Z}),E=X<N.length&&N[X]?.text===`
18
+ `?X+1:X;continue}if(Q>=E){let V=N[Q].end;D.push({end:V,height:S,start:y,text:F.slice(y,V),width:Y}),E=Q+1;continue}let J=N[Math.max(E,X-1)].end;D.push({end:J,height:S,start:y,text:F.slice(y,J),width:Z}),E=Math.max(E+1,X)}let $=N.at(-1);if($?.text===`
19
+ `)D.push({end:$.end,height:M,start:$.end,text:"",width:0});return D}function zQ(N,F,A,M,D,E,$){let y=[];for(let Z of A.inlines){if(Z.kind==="image"){let X=bN(Z,$,D);y.push({breakable:!0,end:Z.end,height:X.height,start:Z.start,text:Z.text,width:X.width});continue}if(F.font=K1(M,Z.marks,Z.inlineCode),K6(Z)){y.push({breakable:!0,end:Z.end,height:E,start:Z.start,text:Z.text,width:o4(F,Z.mention)});continue}let Y=Z.start;for(let X of e4(Z.text)){let Q=Y,S=Q+X.length;y.push({breakable:/\s/.test(X),end:S,height:E,start:Q,text:X,width:X===`
20
+ `?0:t4(N,F,X)}),Y=S}}return y}function GQ(N){let F=!1,A=!1,M=!1;for(let D of N.inlines){if(D.kind==="image")A=!0;else if(D.kind==="lineBreak")F=!0;if(K6(D)||WQ(D))M=!0}return{hasHardBreak:F,hasImage:A,hasRichInline:M}}function HQ(N){return N.hasImage||N.hasHardBreak&&N.hasRichInline}var _D=new WeakMap;function U6(N,F){let A=_D.get(N.inlines);if(A&&A.path===N.path&&A.text===N.text)return A.identity;let M=[N.path,PQ(N.text),_Q(N,F)].join(":");if(!N.inlines.some((D)=>D.kind==="image"))_D.set(N.inlines,{identity:M,path:N.path,text:N.text});return M}function _Q(N,F){return N.inlines.map((A)=>`${A.start}-${A.end}:${BQ(A,F)}`).join("|")}function BQ(N,F){if(N.kind==="image"&&N.image)return KD(N,F);if(K6(N))return`${N.kind}:${N.mention.userId}:${N.mention.name}`;return`${N.kind}:${N.inlineCode?1:0}:${N.marks.join(",")}:${N.link?.url??""}`}function PQ(N){let F=2166136261;for(let A=0;A<N.length;A+=1)F^=N.charCodeAt(A),F=Math.imul(F,16777619);return(F>>>0).toString(36)}function WQ(N){return N.inlineCode||N.marks.includes("italic")||N.marks.includes("bold")}function K6(N){return Boolean(N.mention)}function WD(){if(n4!==void 0)return n4;let F=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d");if(!F)throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.");return n4=F,F}function t4(N,F,A){let M=F.font,D=LM(N,M),E=D.get(A);if(E!==void 0)return E;let $=F.measureText(A).width;return D.set(A,$),$}function OQ(N,F,A){let M=e4(A);if(M.length<=$Q){let y=[],Z=0,Y=0;for(let X of M){Z+=X.length;let Q=wQ(F,A,Z);y.push({length:X.length,width:Q-Y}),Y=Q}return y}let D=[],E=null,$=0;for(let y of M){let Z=t4(N,F,y);D.push({length:y.length,width:E===null?Z:t4(N,F,E+y)-$}),E=y,$=Z}return D}function wQ(N,F,A){return N.measureText(F.slice(0,A)).width}function LQ(N,F){return N?.type==="code"||F.hasHardBreak?"pre-wrap":"normal"}var fN=10,d2=8,N5=120;function OD(N,F,A,M,D,E,$,y,Z,Y){let X=Math.max(1,...E.rows.map((K)=>K.cells.length)),S=Math.max(N5,Z.width-$-Z.paddingX)/X,J=TQ(M),V=y;for(let K=0;K<E.rows.length;K+=1){let q=CQ(J.get(K)??[],D,E,S,fN,Z.lineHeight,Y),U=Math.max(Z.lineHeight+d2*2,...q.map((z)=>z.measuredLines.reduce((G,H)=>G+H.height,0)+d2*2));for(let z of q){let G=$+z.cellIndex*S,H=V+d2;for(let B of z.measuredLines){let _={blockId:z.container.blockId,boundaries:q6(D,z.container,B.start,B.end,B.text,z.font,S-fN*2,Y),regionId:z.container.id,end:B.end,font:z.font,height:B.height,left:G+fN,start:B.start,text:B.text,top:H,width:B.width};N.push(_),F5(F,_),H+=B.height}A.set(z.container.id,{bottom:V+U,left:G,right:G+S,top:V})}jQ(F,E.id,V,V+U),V+=U}return V}function TQ(N){let F=new Map;for(let A of N){let M=A.tableCellPosition;if(!M)continue;let D=F.get(M.rowIndex)??[];D.push({cellIndex:M.cellIndex,container:A}),F.set(M.rowIndex,D)}return F}function CQ(N,F,A,M,D,E,$){return[...N].sort((y,Z)=>y.cellIndex-Z.cellIndex).map(({cellIndex:y,container:Z})=>{let Y=x2(A),X=v1(A,E),Q=l2(F,Z,Y,A,Math.max(40,M-D*2),X,$);return{cellIndex:y,container:Z,font:Y,lineHeight:X,measuredLines:Q}})}function jQ(N,F,A,M){let D=N.get(F);N.set(F,{bottom:D?Math.max(D.bottom,M):M,top:D?Math.min(D.top,A):A})}function z6(N){let F=N.charWidth??F6.charWidth,A=N.lineHeight??F6.lineHeight,M=Math.max(12,Math.floor(N.width/F)),D=N.text.split(`
21
+ `).reduce((E,$)=>E+Math.max(1,Math.ceil($.length/M)),0);return{estimatedHeight:D*A,lineCount:D,width:N.width}}function G6(N,F,A=D2(),M=null){let D=M??{images:new Map},E=A6(F),$=[],y=new Map,Z=new Map(N.regions.map((q)=>[q.id,{textLength:q.text.length}])),Y=N.blockIndex,X=uN(N.document.blocks),Q=new Map,S=new Set(N.regions.map((q)=>q.id)),J=E.paddingY,V=null;for(let q of N.blocks){let U=X.get(q.id)??null;if(!U||R1(U))continue;let z=Q1(q),G=q.regionIds.filter((w)=>S.has(w));if(!z&&G.length===0)continue;if(V!==null){if(J+=M6(Y,X,V.id,q.id,E.blockGap),!Q1(V)){let w=Q.get(V.id);if(w)w.bottom=Math.max(w.bottom,J)}}let H=q.depth,B=E.paddingX+H*E.indentWidth,_=k2(Y,N.listItemMarkers,q.id),O=Math.max(40,E.width-B-E.paddingX-_);if(z){let w=J+E.lineHeight;Q.set(q.id,{top:J,bottom:w}),J=w}else if(U.type==="table"){let w=G.map((b)=>N.regionIndex.get(b)).filter((b)=>b!==void 0);J=OD($,Q,y,w,A,U,B,J,E,D)}else for(let w of G){let b=N.regionIndex.get(w);if(!b)continue;J=RQ($,Q,y,b,A,U,B,J,O,E,D)}V=q}let K=[];for(let q of N.blocks){let U=X.get(q.id);if(!U||R1(U))continue;let z=Q.get(q.id);if(!z)continue;K.push({bottom:z.bottom,depth:q.depth,id:q.id,top:z.top,type:q.type})}return{blocks:K,regionBounds:y,regionLineIndices:bQ($),regionMetrics:Z,height:Math.max(J,E.paddingY),lines:$,options:E,width:E.width}}function RQ(N,F,A,M,D,E,$,y,Z,Y,X){let Q=x2(E),S=v1(E,Y.lineHeight),J=l2(D,M,Q,E,Z,S,X),V=y;for(let K of J){let q={blockId:M.blockId,boundaries:q6(D,M,K.start,K.end,K.text,Q,Z,X),regionId:M.id,end:K.end,font:Q,height:K.height,left:$,start:K.start,text:K.text,top:V,width:K.width};N.push(q),F5(F,q),fQ(A,q),V+=K.height}return V}function bQ(N){N.sort((A,M)=>A.top-M.top||A.left-M.left);let F=new Map;for(let A=0;A<N.length;A+=1){let M=N[A].regionId,D=F.get(M);if(D)D.push(A);else F.set(M,[A])}return F}function fQ(N,F){let A=N.get(F.regionId),M=F.left+F.width,D=F.top+F.height;N.set(F.regionId,A?{bottom:Math.max(A.bottom,D),left:Math.min(A.left,F.left),right:Math.max(A.right,M),top:Math.min(A.top,F.top)}:{bottom:D,left:F.left,right:M,top:F.top})}function F5(N,F){let A=N.get(F.blockId),M=F.top+F.height;N.set(F.blockId,{bottom:A?Math.max(A.bottom,M):M,top:A?Math.min(A.top,F.top):F.top})}function uN(N){let F=new Map,A=(M)=>{for(let D of M)if(F.set(D.id,D),D.type==="blockquote"||D.type==="listItem")A(D.children);else if(D.type==="list")A(D.items)};return A(N),F}var A5=null;function uQ(N){let F=/(\d+(?:\.\d+)?)\s*px/.exec(N);return F?Number.parseFloat(F[1]):16}function e0(N){A5??=new Map;let F=A5.get(N);if(F)return F;let A=LD(),M=Math.max(12,Math.round(uQ(N)));A.font=N;let D=A.measureText("Hg"),E=Math.round(D.actualBoundingBoxAscent||0),$=Math.round(D.actualBoundingBoxDescent||0),y=E+$,Z=Math.max(M,y),Y=y>0?E:Math.round(Z*0.8),X=y>0?$:Math.max(2,Z-Y),Q={ascent:Y,descent:X,emHeight:Z};return A5.set(N,Q),Q}function M5(N,F){let{emHeight:A}=e0(F);return Math.max(0,Math.floor((N-A)/2))}function $2(N,F){let{ascent:A}=e0(F);return M5(N,F)+A}var H6;function wD(N,F){let A=LD();if(N.length===0)return 0;return A.font=F,A.measureText(N).width}function LD(){if(H6!==void 0)return H6;let F=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d");if(!F)throw Error("Canvas font metrics require OffscreenCanvas or a DOM canvas context.");return H6=F,H6}function RD(N,F){let A=0,M=N.lines.length-1;while(A<=M){let D=A+M>>1,E=N.lines[D];if(F<E.top){M=D-1;continue}if(F>=E.top+E.height){A=D+1;continue}return{index:D,line:E}}return null}function _6(N,F){let A=[...N.regionBounds.entries()].find(([,E])=>{return F.x>=E.left&&F.x<=E.right&&F.y>=E.top&&F.y<=E.bottom});if(A)return vN(N,A[0],F.y);let M=RD(N,F.y);if(!M)return null;let D=vQ(N,F.y,M.index);if(D.length===1)return D[0]??null;return D.find((E)=>{let $=N.regionBounds.get(E.line.regionId);return $?F.x>=$.left&&F.x<=$.right:!1})??[...D].sort((E,$)=>{let y=N.regionBounds.get(E.line.regionId),Z=N.regionBounds.get($.line.regionId),Y=CD(F.x,y),X=CD(F.x,Z);return Y-X})[0]??null}function B6(N,F,A){if(N.blocks.length===0)return{endIndex:0,startIndex:0};let M=F+A,D=TD(N,F),E=TD(N,M);if(D>0){if(N.blocks[D-1].bottom>F)D-=1}if(E<N.blocks.length){if(N.blocks[E].top<M)E+=1}return{endIndex:E,startIndex:D}}function TD(N,F){let A=0,M=N.blocks.length;while(A<M){let D=A+M>>1;if(N.blocks[D].bottom<=F)A=D+1;else M=D}return A}function m1(N,F,A){if(N.lines.length===0)return{endIndex:0,startIndex:0};let M=F+A,D=jD(N,F),E=jD(N,M);if(D>0){let $=N.lines[D-1];if($.top+$.height>F)D-=1}if(E<N.lines.length){if(N.lines[E].top<M)E+=1}return{endIndex:E,startIndex:D}}function N1(N,F,A){return a2(N,F,A)?.line??null}function vN(N,F,A){let M=N.regionLineIndices.get(F);if(!M||M.length===0)return null;let D=M[0],E=Number.POSITIVE_INFINITY;for(let $ of M){let y=N.lines[$],Z=A<y.top?y.top-A:A>y.top+y.height?A-(y.top+y.height):0;if(Z<E)E=Z,D=$;if(Z===0)break}return{index:D,line:N.lines[D]}}function a2(N,F,A){let M=N.regionLineIndices.get(F);if(!M||M.length===0)return null;let D=0,E=M.length-1;while(D<=E){let X=D+E>>1,Q=M[X],S=N.lines[Q];if(A<S.start){E=X-1;continue}if(A>S.end){D=X+1;continue}return{index:Q,line:S}}let $=M[0],y=M[M.length-1],Z=N.lines[$],Y=N.lines[y];if(A<=Z.start)return{index:$,line:Z};if(A>=Y.end)return{index:y,line:Y};return null}function vQ(N,F,A){let M=[];for(let D=A;D>=0;D-=1){let E=N.lines[D];if(F<E.top||F>=E.top+E.height)break;M.unshift({index:D,line:E})}for(let D=A+1;D<N.lines.length;D+=1){let E=N.lines[D];if(F<E.top||F>=E.top+E.height)break;M.push({index:D,line:E})}return M}function CD(N,F){if(!F)return Number.POSITIVE_INFINITY;if(N<F.left)return F.left-N;if(N>F.right)return N-F.right;return 0}function b0(N,F){return N.left+mQ(N.boundaries,F)}function mQ(N,F){for(let M of N)if(M.offset===F)return M.left;return N.filter((M)=>M.offset<=F).at(-1)?.left??0}function jD(N,F){let A=0,M=N.lines.length;while(A<M){let D=A+M>>1,E=N.lines[D];if(E.top+E.height<=F)A=D+1;else M=D}return A}function D5(N,F){if(N.length===0)return 0;for(let A=1;A<N.length;A+=1){let M=N[A-1],D=N[A],E=M.left+(D.left-M.left)/2;if(F<=E)return M.offset;if(F<=D.left)return D.offset}return N.at(-1)?.offset??0}function mN(N,F,A){return b0(F,A)+g0(N,F)}function g0(N,F){let A=z1(N,F.blockId,"listItem");if(!A)return 0;return Z2(N,A.id)?.kind==="task"?uM:bM}function y2(N){return{left:N.left,size:fM,top:N.top+3}}function z1(N,F,A){let M=N.documentIndex.blockIndex.get(F)??null;while(M){if(M.type===A)return M;let D=M.parentBlockId;M=D?N.documentIndex.blockIndex.get(D)??null:null}return null}function Z2(N,F){return N.documentIndex.listItemMarkers.get(F)??null}function F1(N,F,A){if(!N.regionMetrics.get(A.regionId))return null;let D=N1(N,A.regionId,A.offset);if(!D)return null;return{blockId:D.blockId,regionId:D.regionId,height:D.height,left:b0(D,A.offset-D.start),offset:A.offset,top:D.top}}function A1(N,F,A){let M=N1(F,A.regionId,A.offset);if(!M)return A.left;return A.left+g0(N,M)+kQ(N,M,A.offset)}function kQ(N,F,A){if(A<=F.end)return 0;let M=N.documentIndex.regionIndex.get(F.regionId);if(!M)return 0;let D=M.text.slice(F.end,A);if(!/^[ \t]+$/u.test(D))return 0;return wD(D,F.font)}var P6;function bD(N,F){if(N.length===0)return null;F=Math.max(0,Math.min(F,N.length));let A=gQ(),M=null;for(let D of A.segment(N)){let E=D.index,$=E+D.segment.length;if(!D.isWordLike){if(F<$)return F===E&&M?.end===F?M:null;continue}let y={end:$,start:E};if(F>=E&&F<$)return y;if(F===$){M=y;continue}if(F<E)return M;M=y}return M&&F===M.end?M:null}function gQ(){if(P6!==void 0)return P6;let N=Intl.Segmenter;if(typeof N!=="function")throw Error("Word selection requires Intl.Segmenter.");return P6=new N(void 0,{granularity:"word"}),P6}function v0(N,F,A){let M=hQ(N,F,A);if(!M)return null;let D=M.snapToLineStart?M.line.left:A.x;return fD(N,F,M.line,D)}function W6(N,F,A){let M=N.lines[N.lines.length-1];if(!M||A.y<=M.top+M.height)return null;return fD(N,F,M,A.x)}function O6(N,F,A,M){let D=uD(F,M.regionId);if(!D)return null;let E=v0(N,F,A);if(E)return{regionId:E.regionId,offset:E.offset};let $=A.y<IQ(N);return{regionId:M.regionId,offset:$?0:D.text.length}}function w6(N,F,A){let M=v0(N,F,A);if(!M)return null;let D=uD(F,M.regionId);if(!D||D.text.length===0)return null;let E=bD(D.text,M.offset);if(!E)return null;return{anchor:{regionId:M.regionId,offset:E.start},focus:{regionId:M.regionId,offset:E.end}}}function fD(N,F,A,M){let D=N.regionMetrics.get(A.regionId);if(!D)return null;let E=Math.max(0,M-g0(F,A)-A.left),$=D5(A.boundaries,E),y=Math.min(D.textLength,A.start+$);return{regionId:A.regionId,offset:y,left:b0(A,$),top:A.top,height:A.height}}function hQ(N,F,A){for(let[D,E]of N.regionBounds)if(A.x>=E.left&&A.x<=E.right&&A.y>=E.top&&A.y<=E.bottom){let $=vN(N,D,A.y)?.line??null;return $?{line:$}:null}let M=_6(N,A)?.line??null;if(M)return{line:M};for(let D of N.blocks){if(A.y<D.top||A.y>D.bottom)continue;for(let $=N.lines.length-1;$>=0;$--)if(N.lines[$].blockId===D.id)return{line:N.lines[$]};let E=F.documentIndex.blockIndex.get(D.id);if(E&&Q1(E)){let $=wN(F.documentIndex,D.id);if($){let y=N.lines.find((Z)=>Z.blockId===$.id);if(y)return{line:y,snapToLineStart:!0}}}}return null}function uD(N,F){return N.documentIndex.regionIndex.get(F)??null}function IQ(N){return N.lines[0]?.top??0}function G1(N,F){let A=N.viewport.top,M=A+N.viewport.height;if(F.bottom<A)return"above";if(F.top>M)return"below";return"visible"}function E5(N,F,A){let M=pQ(N,A);if(!M||M.start!==0)return null;let D=z1(F,M.blockId,"listItem");if(!D)return null;if(Z2(F,D.id)?.kind!=="task")return null;let $=y2(M),y=$.left-4,Z=$.left+$.size+4,Y=$.top-4,X=$.top+$.size+4;return A.x>=y&&A.x<=Z&&A.y>=Y&&A.y<=X?{listItemId:D.id}:null}function $5(N,F,A){let M=v0(N,F,A);if(!M)return null;let D=xQ(F,M.regionId);if(!D)return null;let E=D.inlines.find(($)=>$.link&&M.offset>=$.start&&M.offset<$.end);if(!E?.link)return null;return{endOffset:E.end,regionId:M.regionId,startOffset:E.start,title:E.link.title,url:E.link.url}}function L6(N,F,A,M){let D=E5(N,F,A);if(D)return{kind:"task-toggle",listItemId:D.listItemId};let E=v0(N,F,A);if(!E)return null;let $=vD(E.regionId,E.offset,M),y=$5(N,F,A);if(y)return{endOffset:y.endOffset,kind:"link",commentThreadIndex:$,regionId:y.regionId,startOffset:y.startOffset,title:y.title,url:y.url};return{kind:"text",commentThreadIndex:$}}function T6(N,F,A,M){let D=F.documentIndex.regionIndex.get(A.regionId);if(!D)return null;let E=vD(A.regionId,A.offset,M),$=D.inlines.find((y)=>A.offset>=y.start&&A.offset<=y.end)??null;if($?.link)return{commentThreadIndex:E,endOffset:$.end,kind:"link",regionId:A.regionId,startOffset:$.start,title:$.link.title,url:$.link.url};if(E!==null)return{commentThreadIndex:E,kind:"text"};return null}function kN(N,F,A,M){let D=N.documentIndex.regionIndex.get(N.selection.anchor.regionId);if(!M.image||!D)return null;let E=N1(F.layout,D.id,M.start);if(!E)return null;let $=E.left+g0(N,E),y=$+b0(E,M.start-E.start)-E.left,Z=$+b0(E,M.end-E.start)-E.left,{height:Y}=bN(M,A,E.width),X=E.top+Math.max(0,Math.floor((E.height-Y)/2));return{left:y,top:X,width:Z-y,height:Y}}function vD(N,F,A){for(let M of A)if(M.regionId===N&&F>=M.startOffset&&F<=M.endOffset)return M.threadIndex;return null}function pQ(N,F){return N.lines.find((A)=>F.y>=A.top-4&&F.y<=A.top+A.height+4)??N.lines.filter((A)=>Math.abs(F.y-(A.top+A.height/2))<=10).sort((A,M)=>Math.abs(F.y-(A.top+A.height/2))-Math.abs(F.y-(M.top+M.height/2)))[0]??null}function xQ(N,F){return N.documentIndex.regionIndex.get(F)??null}function mD(N,F,A,M,D,E,$){let y=y5(F,D,E,$),Z=N.measuredContainerHeights.get(y);if(Z!==void 0)return Z;let Y=v1(A,E.lineHeight),X=E.paddingX+M*E.indentWidth,Q=Math.max(40,E.width-X-E.paddingX-D);if(F.inlines.some((V)=>V.kind==="image"||V.kind==="mention")){let V=x2(A);return l2(N,F,V,A,Q,Y,$).reduce((K,q)=>K+q.height,0)}let S=z6({charWidth:E.charWidth,lineHeight:Y,text:F.text,width:Q});return Math.max(Y,S.lineCount*Y)}function kD(N,F,A,M){let D=z6({charWidth:M,lineHeight:A,text:N.text,width:F});return Math.max(A,D.lineCount*A)}function y5(N,F,A,M){return`${U6(N,M)}:${A.width}:${A.paddingX}:${A.indentWidth}:${A.lineHeight}:${F}`}function Z5(N,F){let A=0,M=N.entries.length;while(A<M){let D=A+M>>1;if(N.entries[D].bottom<=F)A=D+1;else M=D}return A}function gD(N,F,A,M,D){let E=M,$=D;for(let y=M;y<D;y+=1){let Z=N.regions[y],Y=F.get(Z.blockId);if(!Y)continue;if(Y.type==="table"){let X=A.get(Y.regionIds[0]??""),Q=A.get(Y.regionIds[Y.regionIds.length-1]??"");if(X!==void 0)E=Math.min(E,X);if(Q!==void 0)$=Math.max($,Q+1)}}return{endIndex:$,startIndex:E}}function hD(N,F,A){return{...N,blocks:N.blocks.map((M)=>({...M,bottom:M.bottom+F,top:M.top+F})),regionBounds:new Map([...N.regionBounds.entries()].map(([M,D])=>[M,{bottom:D.bottom+F,left:D.left,right:D.right,top:D.top+F}])),height:A,lines:N.lines.map((M)=>({...M,top:M.top+F}))}}function ID(N,F,A,M,D){for(let[E,$]of A.regionBounds){let y=$.bottom-$.top,Z=F.regionIndex.get(E),Y=Z?k2(F.blockIndex,F.listItemMarkers,Z.blockId):0;wM(N,y5(Z??{path:E,inlines:[],text:""},Y,M,D),y)}}function Y5(N,F,A,M=[],D=D2(),E=null){let $=A6(F),y=E??{images:new Map},Z=uN(N.document.blocks),Y=N.blockIndex,X=new Set(M),Q=Math.max(0,A.top-A.overscan),S=A.top+A.height+A.overscan,J=dQ(D,N,Z,Y,$,y),V=Z5(J,Q),K=Z5(J,S);if(V>0){let H=J.entries[V-1];if(H&&H.bottom>Q)V-=1}if(K<J.entries.length){let H=J.entries[K];if(H&&H.top<S)K+=1}for(let H of X){let B=J.containerIndices.get(H);if(B===void 0)continue;V=Math.min(V,B),K=Math.max(K,B+1)}if(!Number.isFinite(V)||!Number.isFinite(K))return{estimateRegionBounds:J.estimateRegionBounds,layout:G6({...N,regions:[]},$,D,y),totalHeight:J.totalHeight,viewport:A};let q=gD(N,Y,J.containerIndices,V,K),U=J.entries[q.startIndex]?.top??$.paddingY,z=G6({...N,regions:N.regions.slice(q.startIndex,q.endIndex)},$,D,y),G=hD(z,U,J.totalHeight);return ID(D,N,G,$,y),{estimateRegionBounds:J.estimateRegionBounds,layout:G,totalHeight:J.totalHeight,viewport:A}}function dQ(N,F,A,M,D,E){let $=cQ(F,D,E),y=TM(N,F,$);if(y)return y;let Z=D.paddingY,Y=[],X=new Map,Q=0,S=null;for(let J of F.blocks){let V=A.get(J.id)??null;if(!V||R1(V))continue;let K=Q1(J);if(!K&&J.regionIds.length===0)continue;if(S!==null)Z+=M6(M,A,S,J.id,D.blockGap);if(K)Z+=D.lineHeight;else if(V.type==="table"){let q=aQ({block:V,containerIndices:X,entries:Y,index:Q,options:D,runtimeBlocks:M,totalHeight:Z,regions:F.regions});if(q)Q=q.nextIndex,Z=q.totalHeight}else{let q=k2(F.blockIndex,F.listItemMarkers,J.id);for(let U of J.regionIds){let z=F.regions[Q];if(!z){Q+=1;continue}let G=mD(N,z,V,J.depth,q,D,E),H=Z,B=H+G;Y[Q]={bottom:B,top:H},X.set(z.id,Q),Z=B,Q+=1}}S=J.id}return CM(N,F,$,{containerIndices:X,entries:Y,estimateRegionBounds(J){let V=X.get(J);return V===void 0?null:Y[V]??null},totalHeight:Z})}function aQ({block:N,containerIndices:F,entries:A,index:M,options:D,runtimeBlocks:E,totalHeight:$,regions:y}){let Z=E.get(N.id),Y=Z?.regionIds??[];if(Y.length===0)return null;let X=y.slice(M,M+Y.length);if(X.length===0||X[0]?.blockId!==N.id)return null;let Q=Z?.depth??0,S=D.paddingX+Q*D.indentWidth,J=Math.max(N5,D.width-S-D.paddingX),V=Math.max(1,...N.rows.map((H)=>H.cells.length)),K=J/V,q=Math.max(40,K-fN*2),U=v1(N,D.lineHeight),z=rQ(X,M),G=$;for(let H=0;H<N.rows.length;H+=1){let B=z.get(H)??[],_=Math.max(U+d2*2,...B.map(({region:w})=>kD(w,q,U,D.charWidth)+d2*2)),O=G+_;for(let{index:w,region:b}of B)A[w]={bottom:O,top:G},F.set(b.id,w);G=O}for(let H=M;H<M+X.length;H+=1){let B=y[H];if(!B||A[H])continue;A[H]={bottom:G,top:G},F.set(B.id,H)}return{nextIndex:M+X.length,totalHeight:G}}function rQ(N,F){let A=new Map;for(let[M,D]of N.entries()){let E=D.tableCellPosition?.rowIndex;if(E===void 0)continue;let $=A.get(E)??[];$.push({index:F+M,region:D}),A.set(E,$)}return A}function cQ(N,F,A){return[F.width,F.paddingX,F.paddingY,F.indentWidth,F.lineHeight,F.blockGap,sQ(N,A)].join(":")}function sQ(N,F){if(N.imageUrls.size===0)return"";return N.regions.flatMap((A)=>A.inlines.filter((M)=>M.kind==="image"&&M.image).map((M)=>{let D=M.image?F.images.get(M.image.url):null;return`${M.image?.url??""}:${M.image?.width??0}:${D?.status??"loading"}:${D?.intrinsicWidth??0}:${D?.intrinsicHeight??0}`})).join("|")}function X5(N,F,A,M=null){let D={height:F.height,overscan:Math.max(160,F.height),top:F.top},E=Y5(N.documentIndex,F,D,[N.selection.anchor.regionId,N.selection.focus.regionId],A,M);return{blockMap:uN(N.documentIndex.document.blocks),estimateRegionBounds:E.estimateRegionBounds,regionBounds:new Map(E.layout.regionBounds),layout:E.layout,paintHeight:Math.max(240,D.height+D.overscan*2),paintTop:Math.max(0,D.top-D.overscan),totalHeight:E.totalHeight,viewport:{height:D.height,top:D.top}}}function C6(N,F,A){return v0(F.layout,N,A)??W6(F.layout,N,A)}function Q5(N,F,A,M){return O6(F.layout,N,A,M)}function S5(N,F,A){return w6(F.layout,N,A)}function pD(N,F,A,M){return L6(F.layout,N,A,M)}function xD(N,F,A,M){return T6(F.layout,N,A,M)}function J5(N,F,A){return F1(F.layout,N.documentIndex,A)}function k1(N,F,A){let M=F1(F.layout,N.documentIndex,A);if(!M)return null;return{...M,left:A1(N,F.layout,M)}}function lD(N,F,A,M,D){let E=M-A,$=D-E;if(M<=N)return{end:F+$,start:N+$};if(A>=F)return{end:F,start:N};let y=Math.max(0,Math.min(A,F)-N),Z=Math.max(0,F-Math.max(M,N)),Y=N<A?N:A;return{end:Y+y+D+Z,start:Y}}function q5(N,F,A){let M=A.trim();if(M.length===0||F.startOffset===F.endOffset)return null;let D=N.regionIndex.get(F.regionId)??null,E=D?V5(N,D):null;if(!E)return null;return L4({anchor:BN(E,F.startOffset,F.endOffset),body:M,quote:PN(E,F.startOffset,F.endOffset)})}function h0(N){let F="documentIndex"in N?N.documentIndex:N,A=R6(F),M=F.document.comments,D=[...M],E=[];for(let[$,y]of M.entries()){let Z=WN(y,F.document);if(!Z.match)continue;let X=A.findBySemanticMatch(Z.match.containerId,Z.match.containerOrdinal)?.runtimeContainer??null;if(!X)continue;if(Z.repair)D[$]={...y,anchor:Z.repair.anchor,quote:Z.repair.quote};E.push({endOffset:Z.match.endOffset,resolution:Z,regionId:X.id,resolved:y.resolvedAt!=null,startOffset:Z.match.startOffset,threadIndex:$})}return{liveRanges:E,threads:D}}function j6(N,F,A){if(F.length===0||A.size===0)return!1;let{endIndex:M,startIndex:D}=m1(N.layout,N.viewport.top,N.viewport.height);for(let E=D;E<M;E+=1){let $=N.layout.lines[E];if(!$)continue;if(G1(N,{bottom:$.top+$.height,top:$.top})!=="visible")continue;if(F.some((y)=>!y.resolved&&A.has(y.threadIndex)&&y.regionId===$.regionId&&y.endOffset>$.start&&y.startOffset<$.end))return!0}return!1}function U5(N,F,A,M,D,E){if(N.document.comments.length===0)return F.document.comments;let $=N.commentContainerIndex.get(A.semanticRegionId)??[],y=new Set($);if($.length===0)return F.document.comments;let Z=h0(N),Y=new Map(Z.liveRanges.map((J)=>[J.threadIndex,J])),X=V5(N,A),Q=r2(F,A.path),S=Q?V5(F,Q):null;if(!X||!S)return F.document.comments;return F.document.comments.map((J,V)=>{if(!y.has(V))return J;let K=Y.get(V),q=K?.resolution.match??null;if(!K||!q||q.containerId!==X.id)return J;let U=lD(q.startOffset,q.endOffset,M,D,E.length);return{...J,anchor:BN(S,U.start,U.end),quote:PN(S,U.start,U.end)}})}function V5(N,F){let A=iQ(N,F);if(!A)return null;return{containerKind:A,containerOrdinal:-1,id:F.semanticRegionId,text:F.text}}function iQ(N,F){if(N.tableCellIndex.has(F.id))return"tableCell";return UM(F.blockType)}function b6(N,F){if(F.length===0)return[];let A=R6(N),M=A.list();return F.map((D)=>({...D,...oQ(D,M,A,N),viewport:null}))}function oQ(N,F,A,M){if(!N.cursor)return{commentThreadIndex:null,cursorPoint:null};if(KM(N.cursor))return nQ(N.cursor,M);return{commentThreadIndex:null,cursorPoint:tQ(N.cursor,F,A)}}function nQ(N,F){let A=F.document.comments.findIndex((M)=>M.id===N.threadId);return{commentThreadIndex:A>=0?A:null,cursorPoint:null}}function tQ(N,F,A){let M=eQ(F,N),D=NS(M,N);if(D.length!==1)return null;let E=D[0],$=A.resolveRuntimeContainer(E.container.id);if(!$)return null;return{offset:Math.max(0,Math.min(E.offset,$.text.length)),regionId:$.id}}function eQ(N,F){return F.kind?N.filter((A)=>A.containerKind===F.kind):N}function NS(N,F){if(F.prefix&&F.suffix)return FS(N,F.prefix,F.suffix);if(F.prefix)return dD(N,F.prefix,"after");if(F.suffix)return dD(N,F.suffix,"before");return[]}function dD(N,F,A){let M=[];for(let D of N)for(let E of X1(D.text,F))M.push({container:D,offset:A==="after"?E+F.length:E});return M}function FS(N,F,A){let M=[];for(let D of N)for(let E of m2(D.text,F,A))M.push({container:D,offset:E.startOffset});return M}var AS=48;function f6(N,F,A){let M="documentIndex"in N?N.documentIndex:N;if(A.length===0)return[];return A.map((D)=>({...D,viewport:MS(M,F,D)}))}function u6(N,F,A){let M="documentIndex"in N?N.documentIndex:N,D=aD(M,F,A);if(!D)return"unresolved";return G1(F,D)}function MS(N,F,A){if(!A.cursorPoint)return{status:"unresolved"};let M=aD(N,F,A.cursorPoint);if(!M)return{status:"unresolved"};return{scrollTop:DS(F,M),status:G1(F,M)}}function aD(N,F,A){let M=F1(F.layout,N,A);if(M)return{bottom:M.top+M.height,top:M.top};return F.estimateRegionBounds(A.regionId)}function DS(N,F){let A=Math.max(0,N.totalHeight-N.viewport.height),M=F.top-Math.min(AS,N.viewport.height/4);return Math.max(0,Math.min(A,M))}function R6(N){let F=N6(N.document),A=new Map(F.map((D)=>[D.id,D])),M=new Map(N.regions.map((D)=>[D.semanticRegionId,D]));return{findBySemanticMatch(D,E){let $=A.get(D)??F[E]??null;if(!$)return null;return{runtimeContainer:M.get($.id)??null,semanticContainer:$}},list(D){return D?F.filter((E)=>E.containerKind===D):F},resolveRuntimeContainer(D){return M.get(D)??null}}}var Y2="",rD=1e6;function gN(N,F,A){return`${N}:${F}:${A}`}function c2(N){let F=WS(N),A=z5(F.blocks.map((M,D)=>IN(M,D)));return G5(F,A)}function IN(N,F){let A=[],M=[],D=[],E=new Set,$=0;function y(Y,X,Q,S,J=null){if(M.length>0)D.push(`
22
+ `),$+=1;let V=Q.map((U)=>U.text).join(""),K=$,q=K+V.length;D.push(V),$=q;for(let U of Q)if(U.image)E.add(U.image.url);M.push({blockId:Y.id,blockType:Y.type,end:q,id:`${Y.id}:${X}`,path:X,rootIndex:F,inlines:Q,semanticRegionId:S,start:K,tableCellPosition:J,text:V})}function Z(Y,X,Q,S){let J={childBlockIds:[],depth:Q,end:$,id:Y.id,parentBlockId:S,path:X,regionIds:[],rootIndex:F,start:$,type:Y.type};switch(A.push(J),Y.type){case"blockquote":case"listItem":for(let[V,K]of Y.children.entries())J.childBlockIds.push(K.id),Z(K,Y1(X,V),Q+1,Y.id);break;case"code":{y(Y,Q4(X),[{end:Y.source.length,id:`${Y.id}:code`,image:null,inlineCode:!1,kind:"text",link:null,marks:[],mention:null,originalType:null,start:0,text:Y.source}],Y.id),J.regionIds.push(M.at(-1).id);break}case"heading":case"paragraph":y(Y,r0(X),K5(Y.children),Y.id),J.regionIds.push(M.at(-1).id);break;case"list":for(let[V,K]of Y.items.entries())J.childBlockIds.push(K.id),Z(K,Y1(X,V),Q+1,Y.id);break;case"table":for(let[V,K]of Y.rows.entries())for(let[q,U]of K.cells.entries())y(Y,F2(f2(X,V),q),K5(U.children),U.id,{cellIndex:q,rowIndex:V}),J.regionIds.push(M.at(-1).id);break;case"divider":break;case"directive":break;case"raw":y(Y,Q4(X),[{end:Y.source.length,id:`${Y.id}:raw`,image:null,inlineCode:!1,kind:"raw",link:null,marks:[],mention:null,originalType:Y.originalType,start:0,text:Y.source}],Y.id),J.regionIds.push(M.at(-1).id);break}J.end=$}return Z(N,R2(F),0,null),{blockRange:{end:A.length,start:0},blocks:A,end:$,imageUrls:E,length:$,regionRange:M.length>0?{end:M.length,start:0}:void 0,regions:M,rootIndex:F,start:0,text:D.join("")}}function z5(N,F=null){let A=[],M=0,D=0,E=0,$=!1;for(let[y,Z]of N.entries()){if(Z.regions.length>0&&$)E+=1;let Y={...Z,blockRange:{end:M+Z.blocks.length,start:M},end:E+Z.length,regionRange:Z.regions.length>0?{end:D+Z.regions.length,start:D}:void 0,start:E},X=F?.[y];if(A.push($S(X,Z,Y)?X:cD(Z,Y)),M=Y.blockRange.end,D=Y.regionRange?.end??D,Z.regions.length>0)E=Y.end,$=!0}return A}function s2(N,F,A,M){let D=F.blocks.length-(N.roots.length-M);if(D<0)throw Error("Editor model splice received an invalid replacement count.");if(A===N.roots.length&&D===1){let Z=F.blocks[A];if(Z)return ES(N,F,Z)}let E=D===M,$=[...N.roots.slice(0,A),...F.blocks.slice(A,A+D).map((Z,Y)=>IN(Z,A+Y)),...E?N.roots.slice(A+M):F.blocks.slice(A+D).map((Z,Y)=>IN(Z,A+D+Y))],y=z5($,N.roots);return G5(F,y,N)}function ES(N,F,A){let M=N.roots.length,D=IN(A,M),E=N.roots.some((X)=>X.regions.length>0),$=D.regions.length>0&&E?N.length+1:N.length,y=cD(D,{...D,blockRange:{end:N.blocks.length+D.blocks.length,start:N.blocks.length},end:$+D.length,regionRange:D.regions.length>0?{end:N.regions.length+D.regions.length,start:N.regions.length}:void 0,start:$}),Z=[...N.blocks,...y.blocks],Y=[...N.regions,...y.regions];return{blockIndex:QS(N.blockIndex,y.blocks),blocks:Z,commentContainerIndex:F.comments===N.document.comments?N.commentContainerIndex:sD(F),document:F,engine:"canvas",imageUrls:_S(N.imageUrls,y.imageUrls),length:y.end,listItemMarkers:F.blocks===N.document.blocks?N.listItemMarkers:KS(N.listItemMarkers,A),regionIndex:SS(N.regionIndex,y.regions),regionOrderIndex:JS(N.regionOrderIndex,y.regions,N.regions.length),regionPathIndex:VS(N.regionPathIndex,y.regions),regions:Y,roots:[...N.roots,y],tableCellIndex:qS(N.tableCellIndex,y.regions),tableCellRegionIndex:US(N.tableCellRegionIndex,y.regions),text:zS(N.text,y)}}function v6(N,F){if(F.blocks!==N.document.blocks)throw Error("Editor model document replacement requires preserving root blocks.");return G5(F,N.roots,N)}function m6(N,F,A){let M=N.blockIndex.get(F);if(!M)return null;return SM(N.document,F,A,M.rootIndex)}function G5(N,F,A=null){let M=F.flatMap((X)=>X.blocks),D=F.flatMap((X)=>X.regions),{regionIndex:E,regionOrderIndex:$,regionPathIndex:y,tableCellIndex:Z,tableCellRegionIndex:Y}=XS(D);return{blockIndex:YS(M),blocks:M,commentContainerIndex:N.comments===A?.document.comments?A.commentContainerIndex:sD(N),document:N,engine:"canvas",imageUrls:HS(F,A?.imageUrls),length:F.at(-1)?.end??0,listItemMarkers:N.blocks===A?.document.blocks?A.listItemMarkers:PS(N.blocks),regionIndex:E,regionOrderIndex:$,regionPathIndex:y,regions:D,roots:F,tableCellIndex:Z,tableCellRegionIndex:Y,text:GS(F)}}function cD(N,F){let A=F.start-N.start;return{...F,blocks:A===0?N.blocks:yS(N.blocks,A),regions:A===0?N.regions:ZS(N.regions,A)}}function $S(N,F,A){return Boolean(N&&F===N&&N.start===A.start&&N.end===A.end&&N.blockRange.start===A.blockRange.start&&N.blockRange.end===A.blockRange.end&&N.regionRange?.start===A.regionRange?.start&&N.regionRange?.end===A.regionRange?.end)}function yS(N,F){return N.map((A)=>({...A,end:A.end+F,start:A.start+F}))}function ZS(N,F){return N.map((A)=>({...A,end:A.end+F,start:A.start+F}))}function YS(N){let F=new Map;for(let A of N)F.set(A.id,A);return F}function XS(N){let F=new Map,A=new Map,M=new Map,D=new Map,E=new Map;for(let[$,y]of N.entries()){if(F.set(y.id,y),A.set(y.id,$),M.set(y.path,y),!y.tableCellPosition)continue;D.set(y.id,y.tableCellPosition),E.set(gN(y.blockId,y.tableCellPosition.rowIndex,y.tableCellPosition.cellIndex),y.id)}return{regionIndex:F,regionOrderIndex:A,regionPathIndex:M,tableCellIndex:D,tableCellRegionIndex:E}}function QS(N,F){let A=new Map(N);for(let M of F)A.set(M.id,M);return A}function SS(N,F){let A=new Map(N);for(let M of F)A.set(M.id,M);return A}function JS(N,F,A){let M=new Map(N);for(let[D,E]of F.entries())M.set(E.id,A+D);return M}function VS(N,F){let A=new Map(N);for(let M of F)A.set(M.path,M);return A}function qS(N,F){let A=new Map(N);for(let M of F)if(M.tableCellPosition)A.set(M.id,M.tableCellPosition);return A}function US(N,F){let A=new Map(N);for(let M of F){if(!M.tableCellPosition)continue;A.set(gN(M.blockId,M.tableCellPosition.rowIndex,M.tableCellPosition.cellIndex),M.id)}return A}function KS(N,F){let A=new Map(N);return hN(A,[F]),A}function zS(N,F){if(F.regions.length===0)return N;return N.length>0?`${N}
23
+ ${F.text}`:F.text}function GS(N){return N.filter((F)=>F.regions.length>0).map((F)=>F.text).join(`
24
+ `)}function HS(N,F){let A=new Set;for(let M of N)for(let D of M.imageUrls)A.add(D);return F&&BS(F,A)?F:A}function _S(N,F){if(F.size===0)return N;let A=null;for(let M of F){if(N.has(M))continue;A??=new Set(N),A.add(M)}return A??N}function BS(N,F){if(N.size!==F.size)return!1;for(let A of N)if(!F.has(A))return!1;return!0}function sD(N){let F=new Map;for(let[A,M]of N.comments.entries()){let D=WN(M,N).match?.containerId??null;if(!D)continue;let E=F.get(D)??[];E.push(A),F.set(D,E)}return F}function PS(N){let F=new Map;return hN(F,N),F}function hN(N,F,A=null){for(let M of F){if(M.type==="list"){for(let[D,E]of M.items.entries())hN(N,[E],{index:D,ordered:M.ordered,start:M.start});continue}if(M.type==="listItem"){if(typeof M.checked==="boolean")N.set(M.id,{checked:M.checked,kind:"task"});else if(A?.ordered)N.set(M.id,{kind:"ordered",label:`${(A.start??1)+A.index}.`});else N.set(M.id,{kind:"bullet",label:"•"});hN(N,M.children,A)}if(M.type==="blockquote")hN(N,M.children,A)}}function WS(N){if(N.blocks.length>0)return N;return v2([F0("")],N.comments,N.frontMatter)}function K5(N,F=null){let A=[],M=0,D=(E)=>{let $=M,y=$+E.text.length;A.push({...E,end:y,start:$}),M=y};for(let E of N)switch(E.type){case"lineBreak":D({id:E.id,image:null,inlineCode:!1,kind:"lineBreak",link:F,marks:[],mention:null,originalType:null,text:`
25
+ `});break;case"image":D({id:E.id,image:{alt:E.alt,title:E.title,url:E.url,width:E.width},inlineCode:!1,kind:"image",link:F,marks:[],mention:null,originalType:null,text:Y2});break;case"mention":D({id:E.id,image:null,inlineCode:!1,kind:"mention",link:F,marks:[],mention:{name:E.name,userId:E.userId},originalType:null,text:Y2});break;case"code":D({id:E.id,image:null,inlineCode:!0,kind:"code",link:F,marks:[],mention:null,originalType:null,text:E.code});break;case"link":for(let $ of K5(E.children,{title:E.title,url:E.url}))D($);break;case"text":D({id:E.id,image:null,inlineCode:!1,kind:"text",link:F,marks:E.marks,mention:null,originalType:null,text:E.text});break;case"raw":D({id:E.id,image:null,inlineCode:!1,kind:"raw",link:F,marks:[],mention:null,originalType:E.originalType,text:E.source});break}return A}function j0(N,F,A=0){return{childIndices:F,kind:"descendant-primary-region",offset:A,rootIndex:N}}function $0(N,F=0){return{kind:"root-primary-region",offset:F,rootIndex:N}}function H5(N,F=0){return{kind:"region",offset:F,regionId:N}}function X2(N,F,A,M=0){return{cellIndex:A,kind:"table-cell",offset:M,rootIndex:N,rowIndex:F}}function r2(N,F){return N.regionPathIndex.get(F)??null}function n2(N,F,A,M){let D=N.tableCellRegionIndex.get(gN(F,A,M));return D?N.regionIndex.get(D)??null:null}function pN(N,F){if(!F)return null;if(F.kind==="root-primary-region"){let M=N.document.blocks[F.rootIndex],D=M?k6(N,M):null;return D?i2(D.id,o2(D.text,F.offset)):null}if(F.kind==="descendant-primary-region"){let M=N.document.blocks[F.rootIndex],D=M?OS(M,F.childIndices):null,E=D?k6(N,D):null;return E?i2(E.id,o2(E.text,F.offset)):null}if(F.kind==="region"){let M=N.regionIndex.get(F.regionId)??null;return M?i2(M.id,o2(M.text,F.offset)):null}if(F.kind==="block-primary-region"){let M=o0(N.document,F.blockId),D=M?k6(N,M):null;return D?i2(D.id,o2(D.text,F.offset)):null}if(F.kind==="table-cell"){let M=N.document.blocks[F.rootIndex];if(!M||M.type!=="table")return null;let D=n2(N,M.id,F.rowIndex,F.cellIndex);return D?i2(D.id,o2(D.text,F.offset)):null}let A=r2(N,F.path);if(!A)return null;if(F.kind==="region-path")return i2(A.id,o2(A.text,F.offset));return{anchor:{regionId:A.id,offset:Math.max(0,Math.min(F.startOffset,A.text.length))},focus:{regionId:A.id,offset:Math.max(0,Math.min(F.endOffset,A.text.length))}}}function i2(N,F){let A={offset:F,regionId:N};return{anchor:A,focus:A}}function o2(N,F){return F==="end"?N.length:Math.max(0,Math.min(F,N.length))}function OS(N,F){let A=N;for(let M of F){if(!A)return null;let D=C0(A);if(!D)return null;A=D[M]??null}return A}function k6(N,F){let A=N.blockIndex.get(F.id);if(!A)return null;let M=A.regionIds[0];if(M)return N.regionIndex.get(M)??null;let D=C0(F);if(!D)return null;for(let E of D){let $=k6(N,E);if($)return $}return null}function g6(N){if(!xN(N.selection))return null;let F=N.documentIndex.regionIndex.get(N.selection.focus.regionId);return F?{offset:N.selection.focus.offset,regionId:F.id,text:F.text}:null}function h6(N){let F=N.documentIndex.regionIndex.get(N.selection.anchor.regionId)??null,A=F?N.documentIndex.blockIndex.get(F.blockId)??null:null,M=iD(N);return{block:A?{blockId:A.id,depth:A.depth,nodeType:A.type,text:F?.text??""}:null,span:M?.link?{kind:"link",url:M.link.url}:M&&M.marks.length>0?{kind:"marks",marks:M.marks}:{kind:"none"}}}function I6(N){let F=iD(N);return F?.kind==="image"?F:null}function t2(N){let F=Z0(N.documentIndex,N.selection);if(F.start.regionId!==F.end.regionId||F.start.offset===F.end.offset)return null;return{endOffset:F.end.offset,regionId:F.start.regionId,startOffset:F.start.offset}}function iD(N){let F=N.documentIndex.regionIndex.get(N.selection.anchor.regionId)??null;if(!F)return null;let A=N.selection.anchor.offset;return F.inlines.find((M)=>A>M.start&&A<M.end)??F.inlines.find((M)=>M.end===A)??F.inlines.find((M)=>M.start===A)??null}function _5(N,F){let A=N.regionIndex.get(F);if(!A)return null;let M=o0(N.document.blocks,A.blockId);if(!M)return null;return B5(M,A.path,A.semanticRegionId)}function B5(N,F,A){if(N.type==="heading"||N.type==="paragraph")return{block:N,children:N.children,kind:"inlineBlock",path:F.replace(/\.children$/,"")};if(N.type!=="table")return null;let M=/^(.*\.rows\.\d+\.cells\.\d+)$/.exec(F);if(!M)return null;for(let D of N.rows)for(let E of D.cells)if(E.id===A)return{block:N,blockPath:M[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:E,children:E.children,kind:"tableCell",path:M[1]};return null}function O0(N){switch(N.type){case"lineBreak":return 1;case"image":case"mention":return Y2.length;case"code":return N.code.length;case"link":return J0(N.children).length;case"text":return N.text.length;case"raw":return N.source.length}}function x6(N){let F=t2(N);if(!F)return p6();let A=N.documentIndex.regionIndex.get(F.regionId);if(!A)return p6();let M=o0(N.documentIndex.document.blocks,A.blockId);if(!M)return p6();let D=B5(M,A.path,A.semanticRegionId);if(!D)return p6();return wS(D,F.startOffset,F.endOffset)}function wS(N,F,A){return{code:TS(N,F,A),marks:LS(N,F,A)}}function LS(N,F,A){let M=0,D=null,E=($)=>{for(let y of $){let Z=O0(y),Y=M,X=Y+Z;if(M=X,A<=Y||F>=X)continue;if(y.type==="text"){let Q=Math.max(F,Y);if(Math.min(A,X)>Q)D=D===null?new Set(y.marks):new Set(y.marks.filter((J)=>D?.has(J)));continue}if(y.type==="link"){let Q=M;M=Y,E(y.children),M=Q}}};return E(N.children),D?[...D]:[]}function TS(N,F,A){let M=oD(N.children,F,A);return M.hasCode&&M.allCode}function oD(N,F,A){let M={allCode:!0,hasCode:!1},D=0;for(let E of N){let $=O0(E),y=D,Z=y+$;if(D=Z,A<=y||F>=Z)continue;let Y=Math.max(F,y),X=Math.min(A,Z);if(X<=Y)continue;if(E.type==="code"){M.hasCode=!0;continue}if(E.type==="link"){let Q=oD(E.children,Y-y,X-y);M.hasCode||=Q.hasCode,M.allCode&&=Q.allCode;continue}M.allCode=!1}return M}function p6(){return{code:!1,marks:[]}}function w0(N,F){return N.regionIndex.get(F)??null}function eD(N,F,A,M,D={}){let E=w0(N,F);if(!E||A>M)return null;let $=nD(A,E.text.length),y=nD(M,E.text.length);if($===y&&D.allowCollapsed!==!0)return null;return{endOffset:y,region:E,selection:{anchor:{regionId:F,offset:$},focus:{regionId:F,offset:y}},startOffset:$}}function xN(N){return N.anchor.regionId===N.focus.regionId&&N.anchor.offset===N.focus.offset}function Z0(N,F){let A="documentIndex"in N?N.documentIndex:N,M="documentIndex"in N?N.selection:F,D=xN(M),E=tD(A,M.anchor),$=tD(A,M.focus);if(E<=$)return{collapsed:D,end:M.focus,start:M.anchor};return{collapsed:D,end:M.anchor,start:M.focus}}function nD(N,F){return Math.max(0,Math.min(N,F))}function tD(N,F){let A=N.regionOrderIndex.get(F.regionId);if(A===void 0)throw Error(`Unknown canvas region: ${F.regionId}`);return A*rD+F.offset}var d6="rgba(0, 0, 0, 0)";function Q2(N,F,A){let M=N9(N),D=N9(F);return`rgba(${W5(l6(M[0],D[0],A))}, ${W5(l6(M[1],D[1],A))}, ${W5(l6(M[2],D[2],A))}, ${l6(M[3],D[3],A)})`}var P5=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function N9(N){let F=P5.get(N);if(F)return F;let A=CS(N)??jS(N)??RS(N)??P5.get("rgba(0, 0, 0, 0)");return P5.set(N,A),A}function CS(N){let F=N.trim();if(!F.startsWith("#"))return null;let A=F.slice(1);if(A.length===3)return[Number.parseInt(`${A[0]}${A[0]}`,16),Number.parseInt(`${A[1]}${A[1]}`,16),Number.parseInt(`${A[2]}${A[2]}`,16),1];if(A.length===6)return[Number.parseInt(A.slice(0,2),16),Number.parseInt(A.slice(2,4),16),Number.parseInt(A.slice(4,6),16),1];return null}function jS(N){let F=/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec(N.trim());if(!F)return null;return[Number(F[1]),Number(F[2]),Number(F[3]),1]}function RS(N){let F=/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec(N.trim());if(!F)return null;return[Number(F[1]),Number(F[2]),Number(F[3]),Number(F[4])]}function l6(N,F,A){return N+(F-N)*A}function W5(N){return Math.round(N)}var bS=300,fS=180,uS=1000,vS=500,mS=140,kS=0.1,gS=0.9,hS=2,IS=2;function lN(N){switch(N.kind){case"active-block-flash":return bS;case"text-fade":return fS;case"text-highlight":return uS;case"block-pulse":return vS;case"text-pulse":return mS}}function O5(N,F){let A=F??xS();return N.animations.some((M)=>A-M.startedAt<lN(M))}function F9(N,F){return L5(N,F,"text-highlight",(A)=>A.regionPath)}function A9(N,F){return X9(N,F,"active-block-flash",(A)=>A.blockPath)}function M9(N,F){return L5(N,F,"text-fade",(A)=>A.regionPath)}function D9(N,F){return L5(N,F,"text-pulse",(A)=>A.regionPath)}function E9(N,F){return X9(N,F,"block-pulse",(A)=>A.blockPath)}function $9(N,F,A){let M=new Set([N,F]);for(let D of A){if(D.endOffset<=N||D.startOffset>=F)continue;M.add(Math.max(N,D.startOffset)),M.add(Math.min(F,D.endOffset))}return[...M].sort((D,E)=>D-E)}function w5(N,F,A){return N.find((M)=>M.startOffset<A&&M.endOffset>F)??null}function y9(N,F){return Q2(N,d6,F.progress)}function a6(N,F){return Q2(N,d6,F.progress)}function Z9(N,F){return Q2(F.insertHighlightText,d6,N.progress)}function Y9(N){let F=Math.min(1,N.progress*hS);return kS+gS*pS(F)}function dN(N,F,A){let M=Math.max(0,F.progress*IS-1);return Q2(A.insertHighlightText,N,M)}function L5(N,F,A,M){let D=new Map;for(let E of N.animations){if(E.kind!==A)continue;let $=lN(E),y=F-E.startedAt;if(y>=$)continue;let Z={...E,progress:Math.max(0,Math.min(1,y/$))},Y=M(E),X=D.get(Y);if(X)X.push(Z);else D.set(Y,[Z])}return D}function X9(N,F,A,M){let D=new Map;for(let E of N.animations){if(E.kind!==A)continue;let $=lN(E),y=F-E.startedAt;if(y>=$)continue;D.set(M(E),{...E,progress:Math.max(0,Math.min(1,y/$))})}return D}function pS(N){return 1-(1-N)*(1-N)*(1-N)}function xS(){return performance.now()}function Q9(N,F,A=c6()){if(!F)return N;switch(F.kind){case"text-highlight":return F.endOffset>F.startOffset?r6(N,{...F,startedAt:A}):N;case"text-fade":return F.text.length>0?r6(N,{...F,startedAt:A}):N;case"text-pulse":case"block-pulse":return r6(N,{...F,startedAt:A})}}function S9(N,F,A=c6()){return r6(N,{blockPath:F,kind:"active-block-flash",startedAt:A})}function T5(N,F){return N.filter((A)=>A.startedAt+lN(A)>F)}function c6(){return performance.now()}function J9(N){let F=lS(N);return(F?N.documentIndex.blockIndex.get(F.blockId)??null:null)?.path??""}function lS(N){return N.documentIndex.regionIndex.get(N.selection.focus.regionId)??null}function r6(N,F){let A=T5(N.animations,F.startedAt);return{...N,animations:[...A,F]}}function e2(N,F,A,M){return j5(NN(N.inlines,F,A,M))}function NN(N,F,A,M){let E=dS(N,F,A,{didInsert:!1,generatedInlineCount:0,replacementText:M});return iS(oS(E))}function j5(N){let F=[];for(let A=0;A<N.length;A+=1){let M=N[A];if(M.link){let E=[],$=M.link;while(A<N.length&&R5(N[A].link,$)){let y=q9(N[A]);if(y)E.push(y);A+=1}if(A-=1,E.length>0)F.push(o1({children:W0(E),title:$.title,url:$.url}));continue}let D=q9(M);if(D)F.push(D)}return W0(F)}function dS(N,F,A,M){let D=[];for(let[E,$]of N.entries()){if(!M.didInsert&&F===A&&F===$.start)C5(D,M,V9(N[E-1]??null,$));if(A<=$.start||F>=$.end){D.push(s6($));continue}let y=Math.max(0,F-$.start),Z=Math.min($.text.length,A-$.start),Y=!M.didInsert&&M.replacementText.length>0?M.replacementText:"",X=aS($,y,Z,Y,M);if(y!==Z||Y.length>0)M.didInsert=!0;D.push(...X)}if(!M.didInsert)C5(D,M,V9(N.at(-1)??null,null));return D}function aS(N,F,A,M,D){switch(N.kind){case"text":case"code":case"raw":return rS(N,F,A,M);case"lineBreak":return cS(N,F,A,M,D);case"image":case"mention":return sS(N,F,A,M)}}function rS(N,F,A,M){let D=N.text.slice(0,F)+M+N.text.slice(A);return D.length>0?[{...s6(N),text:D}]:[]}function cS(N,F,A,M,D){if(F===A)return[s6(N)];let E=[];if(M.length>0)C5(E,D,N.link);return E}function sS(N,F,A,M){if(F===0&&A===N.text.length)return M.length>0?[U9(M,N.link,0)]:[];return[s6(N)]}function C5(N,F,A){if(F.replacementText.length===0){F.didInsert=!0;return}N.push(U9(F.replacementText,A,F.generatedInlineCount)),F.generatedInlineCount+=1,F.didInsert=!0}function U9(N,F,A){return{id:`generated:${A}`,image:null,inlineCode:!1,kind:"text",link:F,marks:[],mention:null,originalType:null,text:N}}function V9(N,F){return N?.link&&F?.link&&R5(N.link,F.link)?N.link:null}function s6(N){return{id:N.id,image:N.image,inlineCode:N.inlineCode,kind:N.kind,link:N.link,marks:N.marks,mention:N.mention,originalType:N.originalType,text:N.text}}function iS(N){let F=[],A=0;for(let M of N){let D=A,E=D+M.text.length;F.push({...M,end:E,start:D}),A=E}return F}function oS(N){let F=[];for(let A of N){let M=F.at(-1);if(M&&nS(M,A)){F[F.length-1]={...M,text:M.text+A.text};continue}F.push(A)}return F}function nS(N,F){return N.kind===F.kind&&N.inlineCode===F.inlineCode&&R5(N.link,F.link)&&NJ(N.image,F.image)&&FJ(N.mention,F.mention)&&N.originalType===F.originalType&&N.marks.join(",")===F.marks.join(",")}function q9(N){switch(N.kind){case"lineBreak":return y1();case"image":return N.image?tS(N.image):null;case"mention":return N.mention?eS(N.mention):null;case"code":return O1(N.text);case"text":return N.text.length>0?u0(N.text,N.marks):null;case"raw":return cF({originalType:N.originalType??"raw",source:N.text})}}function tS(N){return w1({alt:N.alt,title:N.title,url:N.url,width:N.width})}function eS(N){return C2({name:N.name,userId:N.userId})}function R5(N,F){return N?.url===F?.url&&N?.title===F?.title}function NJ(N,F){return N?.url===F?.url&&N?.title===F?.title&&N?.alt===F?.alt&&N?.width===F?.width}function FJ(N,F){return N?.userId===F?.userId&&N?.name===F?.name}function aN(N,F,A){if(N.type==="table")return null;if(N.id===F.blockId)return AJ(N,F,A);return K9(N,(M)=>DJ(M,F,A))}function rN(N,F,A){if(N.type==="table")return null;if(N.id===F.blockId)return MJ(N,F,A);return K9(N,(M)=>EJ(M,F,A))}function S2(N,F){if(N.id===F.blockId)return!0;let A=C0(N);return A!==null&&A.some((M)=>S2(M,F))}function AJ(N,F,A){if(A===0)return null;switch(N.type){case"heading":case"paragraph":return k0(N,e2(F,A,F.text.length,""));case"code":return HN(N,F.text.slice(0,A));case"raw":return _N(N,F.text.slice(0,A));default:return null}}function MJ(N,F,A){if(A===F.text.length)return null;switch(N.type){case"heading":case"paragraph":return k0(N,e2(F,0,A,""));case"code":return HN(N,F.text.slice(A));case"raw":return _N(N,F.text.slice(A));default:return null}}function K9(N,F){let A=C0(N);return A?C1(N,F(A)):null}function DJ(N,F,A){let M=N.findIndex(($)=>S2($,F));if(M===-1)return[];let D=N.slice(0,M),E=aN(N[M],F,A);return E?[...D,E]:D}function EJ(N,F,A){let M=N.findIndex(($)=>S2($,F));if(M===-1)return[];let D=N.slice(M+1),E=rN(N[M],F,A);return E?[E,...D]:D}function _9(N,F,A){let M=[],D=0,E={childIndices:[],offset:0},$="",y=N!==null;if(N)M.push(N),E=z9(N);let Z=0;if(N&&F.length>0){let Y=F[0];if(i6(N)&&Y.type==="paragraph"){let X=b5(N,N.children,Y.children);M[M.length-1]=X,E={childIndices:[],offset:X.plainText.length},Z=1,$=Y.plainText}else if(G9(N,Y)){let X=H9(N,Y);M[M.length-1]=X,E=B9(X),Z=1}}for(let Y=Z;Y<F.length;Y+=1){let X=F[Y];M.push(X),D=M.length-1,E=z9(X)}if(A){let Y=M.length-1,X=M[Y]??null,Q=Z>=F.length&&N!==null,S=null;if(X){if(!Q&&X.type==="paragraph"&&i6(A)){if(S=b5(A,X.children,A.children),N===null&&F.length===1)y=!0,$=X.plainText}else if(Q&&i6(X)&&i6(A))S=b5(X,X.children,A.children);else if(G9(X,A))S=H9(X,A),E={childIndices:[C0(X).length-1],offset:"end"}}else if(N===null&&F.length===0)y=!0;if(S)M[Y]=S;else M.push(A)}return{blocks:M,caretLocalIndex:D,caretChildIndices:E.childIndices,caretOffset:E.offset,startRegionInsertedText:$,startRegionPreservedAtRoot0:y}}function z9(N){return C0(N)?B9(N):{childIndices:[],offset:N.plainText.length}}function B9(N){return{childIndices:[C0(N).length-1],offset:"end"}}function b5(N,F,A){return k0(N,W0([...F,...A]))}function i6(N){return N!==null&&(N.type==="heading"||N.type==="paragraph")}function G9(N,F){return N.type===F.type&&C0(N)!==null}function H9(N,F){let A=C0(N),M=C0(F);return C1(N,[...A,...M])}function W9(N,F,A){let M=Z0(N,F);if(M.start.regionId===M.end.regionId)return $J(N,M,A);let D=A.length>0?[F0(A)]:[];return f5(N,F,D)}function f5(N,F,A){let M=Z0(N,F),D=w0(N,M.start.regionId),E=w0(N,M.end.regionId);if(!D||!E)throw Error("Unknown selection endpoints.");let $=N.document.blocks[D.rootIndex],y=N.document.blocks[E.rootIndex];if(!$||!y)throw Error("Unknown root blocks for selection.");let Z=aN($,D,M.start.offset),Y=rN(y,E,M.end.offset),X=_9(Z,A,Y),Q=X.blocks.length>0?X.blocks:[F0("")],S=D.rootIndex,J=E.rootIndex-D.rootIndex+1,V=A2(N.document,S,J,Q),K=s2(N,V,S,J),q=D===E?M.end.offset:D.text.length;return{documentIndex:X.startRegionPreservedAtRoot0?O9(N,K,D,M.start.offset,q,X.startRegionInsertedText):K,selection:j0(S+X.caretLocalIndex,X.caretChildIndices,X.caretOffset)}}function $J(N,F,A){let M=w0(N,F.start.regionId);if(!M)throw Error(`Unknown region: ${F.start.regionId}`);let D=m6(N,M.blockId,(Z)=>yJ(Z,M,F.start.offset,F.end.offset,A));if(!D)throw Error(`Failed to replace block for region: ${M.id}`);let E=s2(N,D,M.rootIndex,1),$=O9(N,E,M,F.start.offset,F.end.offset,A),y=r2($,M.path);if(!y)throw Error(`Failed to remap region after replacement: ${M.path}`);return{documentIndex:$,selection:H5(y.id,F.start.offset+A.length)}}function yJ(N,F,A,M,D){switch(N.type){case"heading":case"paragraph":return k0(N,e2(F,A,M,D));case"code":return HN(N,P9(F,A,M,D));case"table":return ZJ(N,F,A,M,D);case"raw":return _N(N,P9(F,A,M,D));default:throw Error(`Region text replacement is not supported for block type: ${N.type}`)}}function ZJ(N,F,A,M,D){let E=F.tableCellPosition?.rowIndex,$=F.tableCellPosition?.cellIndex;if(E===void 0||$===void 0)throw Error(`Unable to resolve table cell position for region: ${F.id}`);let y=e2(F,A,M,D),Z=N.rows.map((Y,X)=>{if(X!==E)return Y;let Q=Y.cells.map((S,J)=>J===$?L1(y):S);return{...Y,cells:Q}});return a0(N,Z)}function P9(N,F,A,M){return NN(N.inlines,F,A,M).map((D)=>D.text).join("")}function O9(N,F,A,M,D,E){if(N.document.comments.length===0)return F;let $=U5(N,F,A,M,D,E);return $===F.document.comments?F:v6(F,{...F.document,comments:$})}function FN(N){let F=c2(N),A=C9(F);return{animations:[],documentIndex:F,future:[],history:[],selection:{anchor:A,focus:A}}}function S1(N){let F=h0(N.documentIndex);return v2(VM(N.documentIndex.document.blocks),F.threads,N.documentIndex.document.frontMatter)}function u5(N,F){if(!F)return null;let A=YJ(N,F);return A?Q9(A,F.animation):null}function YJ(N,F){switch(F.kind){case"keep-state":return N;case"set-selection":return L0(N,F.selection);case"replace-block":{let A=m6(N.documentIndex,F.blockId,()=>F.block);return A?cN(N,c2(A),F.selection??null):null}case"splice-blocks":{let A=A2(N.documentIndex.document,F.rootIndex,F.count??1,F.blocks);return cN(N,c2(A),F.selection??null)}case"splice-text":{let A=W9(N.documentIndex,F.range??N.selection,F.text);return cN(N,A.documentIndex,F.selection??A.selection)}case"splice-fragment":{let A=f5(N.documentIndex,N.selection,F.blocks);return cN(N,A.documentIndex,A.selection)}case"splice-comments":{let A=XM(N.documentIndex.document,F.index,F.count,F.threads);return cN(N,v6(N.documentIndex,A),null)}}}function cN(N,F,A){let M=XJ(N,F),D=pN(M.documentIndex,A)??N.selection,E=j9(N,M,D);return L0(M,D,E)}function L0(N,F,A){let M="regionId"in F?{anchor:o6(N.documentIndex,F),focus:o6(N.documentIndex,F)}:{anchor:o6(N.documentIndex,F.anchor),focus:o6(N.documentIndex,F.focus)},D={...N,selection:M};return A??j9(N,D)?S9(D,J9(D)):D}function I0(N,F,A,M){let D={regionId:F,offset:A};return L0(N,M?{anchor:N.selection.anchor,focus:D}:D)}function XJ(N,F){let A=C9(F);return{animations:T5(N.animations,c6()),documentIndex:F,future:[],history:[...N.history,{document:N.documentIndex.document,selection:N.selection}],selection:{anchor:A,focus:A}}}function v5(N){let F=N.history.at(-1);if(!F)return N;return T9(F,{future:[L9(N),...N.future],history:N.history.slice(0,-1)})}function m5(N){let F=N.future[0];if(!F)return N;return T9(F,{future:N.future.slice(1),history:[...N.history,L9(N)]})}function L9(N){return{document:N.documentIndex.document,selection:N.selection}}function T9(N,F){return{animations:[],documentIndex:c2(N.document),future:F.future,history:F.history,selection:N.selection}}function C9(N){return N.regions[0]?{regionId:N.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function o6(N,F){let A=w0(N,F.regionId);if(!A)return F;return{regionId:A.id,offset:Math.max(0,Math.min(F.offset,A.text.length))}}function j9(N,F,A){let M=w9(N.documentIndex,N.selection),D=w9(F.documentIndex,A??F.selection);return D!==null&&D!==M}function w9(N,F){let A=N.regionIndex.get(F.focus.regionId),M=A?N.blockIndex.get(A.blockId)??null:null;if(!A||!M?.path)return null;return M.type==="table"?`cell:${A.path}`:`block:${M.path}`}function g5(N,F,A){return R9(N,{endOffset:A,regionId:N.selection.focus.regionId,startOffset:F})}function R9(N,F){return eD(N.documentIndex,F.regionId,F.startOffset,F.endOffset,{allowCollapsed:!0})}function n6(N,F){let A=R9(N,F);return A?b9(N,A):null}function b9(N,F){let A=_5(N.documentIndex,F.region.id);return A?{...F,inlineContainer:A}:null}function H1(N){let F=Z0(N);if(F.start.regionId!==F.end.regionId)return null;let A=g5(N,F.start.offset,F.end.offset);return A?b9(N,A):null}function t6(N){return f9(N.documentIndex,N.selection)}function f9(N,F){let A=N.regionIndex.get(F.anchor.regionId);if(!A)return{kind:"unsupported"};if(A.blockType==="code"){let y=N.blockIndex.get(A.blockId);return y?{kind:"code",region:A,rootIndex:y.rootIndex,selection:F,...iN(N,A,F)}:{kind:"unsupported"}}let M=v9(N,A.id,F);if(M)return{kind:"tableCell",...M,...iN(N,A,F)};let D=e6(N,F);if(D)return{kind:"listItem",...D};let E=QJ(N,F);if(E)return{kind:"blockquoteTextBlock",...E};let $=AN(N,F);if($)return{kind:"rootTextBlock",...$};return{kind:"unsupported"}}function u9(N,F){let{documentIndex:A,selection:M}=N,D=f9(A,M),E=D.kind==="unsupported"?!1:F==="backward"?D.atStart:D.atEnd;switch(D.kind){case"rootTextBlock":return{...D,kind:"rootTextBlock",direction:F,atBoundary:E,previousRoot:A.document.blocks[D.rootIndex-1]??null,nextRoot:A.document.blocks[D.rootIndex+1]??null};case"listItem":return{...D,kind:"listItem",direction:F,atBoundary:E,previousItem:D.list.items[D.itemIndex-1]??null,nextItem:D.list.items[D.itemIndex+1]??null,previousRoot:A.document.blocks[D.rootIndex-1]??null,nextRoot:A.document.blocks[D.rootIndex+1]??null};case"blockquoteTextBlock":return{...D,kind:"blockquoteTextBlock",direction:F,atBoundary:E,previousSibling:D.quote.children[D.childIndex-1]??null,nextSibling:D.quote.children[D.childIndex+1]??null};default:return{kind:"unsupported",direction:F,atBoundary:!1}}}function k5(N,F,A){let M=F?N.blockIndex.get(F)??null:null;while(M){if(M.type===A)return M;let D=M.parentBlockId;M=D?N.blockIndex.get(D)??null:null}return null}function g1(N){let F=N.split("."),A=[];for(let M=0;M<F.length-1;M+=1)if(F[M]==="children"){let D=Number(F[M+1]);if(Number.isInteger(D))A.push(D)}return A}function AN(N,F){let A=N.regionIndex.get(F.anchor.regionId);if(!A)return null;let M=N.blockIndex.get(A.blockId);if(!M)return null;let D=M.rootIndex,E=N.document.blocks[D];if(!E||E.type!=="heading"&&E.type!=="paragraph")return null;return{...iN(N,A,F),block:E,region:A,rootIndex:D}}function QJ(N,F){let A=N.regionIndex.get(F.anchor.regionId);if(!A)return null;let M=N.blockIndex.get(A.blockId),D=k5(N,M?.id??null,"blockquote");if(!M||!D||M.parentBlockId!==D.id)return null;let E=D.rootIndex,$=N.document.blocks[E];if(!$||$.type!=="blockquote")return null;let y=$.children.findIndex((Y)=>Y.id===M.id),Z=$.children[y];if(!Z||Z.type!=="heading"&&Z.type!=="paragraph")return null;return{...iN(N,A,F),block:Z,blockChildIndices:g1(M.path),childIndex:y,region:A,quote:$,rootIndex:E}}function sN(N,F){return o0(N.document.blocks,F)}function h5(N){return e6(N.documentIndex,N.selection)}function e6(N,F){let A=N.regionIndex.get(F.anchor.regionId);if(!A)return null;let M=N.blockIndex.get(A.blockId),D=k5(N,M?.id??null,"listItem"),E=k5(N,M?.id??null,"list");if(!M||!D||!E)return null;let $=sN(N,E.id);if(!$||$.type!=="list")return null;let y=$.items.findIndex((V)=>V.id===D.id),Z=$.items[y];if(!Z)return null;let Y=E.parentBlockId?N.blockIndex.get(E.parentBlockId)??null:null,X=Y?.parentBlockId?N.blockIndex.get(Y.parentBlockId)??null:null,Q=Y?.type==="listItem"?sN(N,Y.id):null,S=X?.type==="list"?sN(N,X.id):null,J=S?.type==="list"&&Q?S.items.findIndex((V)=>V.id===Q.id):-1;return{...iN(N,A,F),region:A,item:Z,itemChildIndices:g1(D.path),itemIndex:y,list:$,listChildIndices:g1(E.path),parentItem:Q?.type==="listItem"?Q:null,parentItemChildIndices:Y?.type==="listItem"?g1(Y.path):null,parentItemIndex:J>=0?J:null,parentList:S?.type==="list"?S:null,parentListChildIndices:X?.type==="list"?g1(X.path):null,rootIndex:E.rootIndex}}function MN(N){return v9(N.documentIndex,N.selection.focus.regionId,N.selection)}function v9(N,F,A){let M=N.regionIndex.get(F);if(!M)return null;let D=N.tableCellIndex.get(M.id),E=N.blockIndex.get(M.blockId),$=E?.type==="table"?N.document.blocks[E.rootIndex]:null,y=_5(N,M.id);if(!D||!E||!$||$.type!=="table"||!y||y.kind!=="tableCell")return null;return{cellIndex:D.cellIndex,documentIndex:N,inlineContainer:y,region:M,rootIndex:E.rootIndex,rowIndex:D.rowIndex,selection:A,table:$}}function iN(N,F,A){let M=Z0(N,A),D=M.start.regionId===F.id?M.start.offset:A.anchor.offset;return{atEnd:D===F.text.length,atStart:D===0,empty:F.text.length===0,offset:D}}function oN(N,F,A){return n1({checked:F,children:[F0(N)],spread:A})}function m9(N,F){let A=N.children[0];if(!A||A.type!=="paragraph")return null;return Z1(N,[F0(F),...N.children.slice(1)])}function k9(N,F){return F.reduce(Y1,R2(N))}function p0(N,F,A,M){let D=N3(N.children,F,A,M),E=M.reduce((y,Z)=>y+O0(Z),0),$=F+E;return nN(N,D,$,$)}function nN(N,F,A,M){switch(N.kind){case"inlineBlock":return{block:k0(N.block,F),blockId:N.block.id,selection:g9(r0(N.path),A,M)};case"tableCell":{let D=L1(F),E=N.block.rows.map(($)=>({...$,cells:$.cells.map((y)=>y.id===N.cell.id?D:y)}));return{block:a0(N.block,E),blockId:N.block.id,selection:g9(N.path,A,M)}}}}function g9(N,F,A){return{endOffset:A,kind:"region-range-path",path:N,startOffset:F}}function N3(N,F,A,M){let D=[],E=0,$=!1;for(let y of N){let Z=O0(y),Y=E,X=Y+Z;if(E=X,A<=Y||F>=X){D.push(y);continue}if(!$)D.push(...SJ(y,Math.max(0,F-Y))),D.push(...M),$=!0;D.push(...JJ(y,Math.min(Z,A-Y)))}if(!$)D.push(...M);return W0(D)}function SJ(N,F){if(F<=0)return[];return I5(N,0,F)}function JJ(N,F){let A=O0(N);if(F>=A)return[];return I5(N,F,A)}function I5(N,F,A){if(F>=A)return[];switch(N.type){case"text":{let M=N.text.slice(F,A);return M.length>0?[u0(M,N.marks)]:[]}case"code":return[O1(N.code.slice(F,A))];case"link":{let M=W0(x5(N.children,F,A));return M.length>0?[{...N,children:M}]:[]}default:return[]}}function p5(N,F,A){let M=0,D="";for(let E of N){let $=O0(E),y=M,Z=y+$;if(M=Z,A<=y||F>=Z)continue;D+=VJ(E,Math.max(0,F-y),Math.min($,A-y))}return D}function x5(N,F,A){let M=[],D=0;for(let E of N){let $=O0(E),y=D,Z=y+$;if(D=Z,A<=y||F>=Z)continue;M.push(...I5(E,Math.max(0,F-y),Math.min($,A-y)))}return M}function VJ(N,F,A){if(F>=A)return"";switch(N.type){case"lineBreak":return`
26
+ `.slice(F,A);case"image":case"mention":return Y2.slice(F,A);case"code":return N.code.slice(F,A);case"link":return p5(N.children,F,A);case"text":return N.text.slice(F,A);case"raw":return N.source.slice(F,A)}}function l5(N,F,A,M){let D=qJ(N.children,F,A,M);if(D===null)return null;let E=W0(h9(N.children,F,A,M,D));return E.length>0?nN(N,E,F,A):null}function qJ(N,F,A,M){let D=0,E=!1,$=!0,y=(Z)=>{for(let Y of Z){let X=O0(Y),Q=D,S=Q+X;if(D=S,A<=Q||F>=S)continue;if(Y.type==="text"){let J=Math.max(F,Q);if(Math.min(A,S)>J)E=!0,$&&=Y.marks.includes(M);continue}if(Y.type==="link"){let J=D;D=Q,y(Y.children),D=J}}};return y(N),E?$:null}function h9(N,F,A,M,D){let E=[],$=0;for(let y of N){let Z=$,Y=O0(y),X=Z+Y;if($=X,A<=Z||F>=X){E.push(y);continue}if(y.type==="text"){E.push(...UJ(y,Math.max(0,F-Z),Math.min(Y,A-Z),M,D));continue}if(y.type==="link"){let Q=W0(h9(y.children,Math.max(0,F-Z),Math.min(Y,A-Z),M,D));if(Q.length>0)E.push({...y,children:Q});continue}E.push(y)}return E}function UJ(N,F,A,M,D){let E=N.text.slice(0,F),$=N.text.slice(F,A),y=N.text.slice(A),Z=D?N.marks.filter((Q)=>Q!==M):KJ(N.marks,M),Y=[],X=(Q,S)=>{if(Q.length>0)Y.push(u0(Q,S))};return X(E,N.marks),X($,Z),X(y,N.marks),Y}function KJ(N,F){return N.includes(F)?N:[...N,F].sort()}function d5(N,F,A){if(F===A)return null;let M=zJ(N.children,F,A);return M!==N.children&&M.length>0?nN(N,M,F,A):null}function zJ(N,F,A){let M=I9(N,F,A);if(M){let E=M.code.length>0?[u0(M.code,[])]:[];return N3(N,F,A,E)}let D=p5(N,F,A);if(D.length===0)return N;return N3(N,F,A,[O1(D)])}function I9(N,F,A){let M=0;for(let D of N){let E=O0(D),$=M,y=$+E;if(M=y,F===$&&A===y&&D.type==="code")return D;if(D.type==="link"){let Z=I9(D.children,Math.max(0,F-$),Math.min(E,A-$));if(Z)return Z}}return null}function a5(N,F,A){let{image:M}=F,D=p0(N,F.start,F.end,[w1({alt:M.alt,title:M.title,url:M.url,width:A})]);return{kind:"replace-block",block:D.block,blockId:D.blockId}}function r5(N,F,A,M){let D=x5(N.children,F,A);if(D.length===0)return null;return p0(N,F,A,[o1({children:D,title:null,url:M})])}function c5(N,F,A,M){let D=p9(N.children,F,A);if(!D)return null;return p0(N,F,A,[o1({children:D.children,title:D.title,url:M})])}function s5(N,F,A){let M=p9(N.children,F,A);if(!M)return null;return p0(N,F,A,M.children)}function p9(N,F,A){let M=0;for(let D of N){let E=O0(D);if(D.type==="link"&&M===F&&M+E===A)return D;M+=E}return null}function i5(N,F,A,M=""){return{kind:"replace-block",...p0(N.inlineContainer,N.startOffset,N.endOffset,[C2({name:A,userId:F}),...M.length>0?[u0(M)]:[]])}}function DN(N,F){let A=F(N.inlineContainer,N.startOffset,N.endOffset);return A?{kind:"replace-block",block:A.block,blockId:A.blockId,selection:A.selection}:null}function o5(N,F){return{kind:"replace-block",...p0(N.inlineContainer,N.startOffset,N.endOffset,[F])}}function x9(N,F){return{kind:"replace-block",...p0(N.inlineContainer,N.startOffset,N.endOffset,F)}}function F3(N){return GJ.test(N)}var GJ=/[\uFE0F\u{1F1E6}-\u{1F1FF}\p{Extended_Pictographic}]/u;function l9(N,F,A){if(A===".")return HJ(N,F);return J2(N,F,A)}function J2(N,F,A){if(A.length===0||F3(A))return;let M=a9(N,F);if(!M)return;return n5(M.region,M.normalized.start.offset,A)}function n5(N,F,A){if(A.length===0||F3(A))return;return{endOffset:F+A.length,kind:"text-highlight",regionPath:N.path,startOffset:F}}function d9(N,F,A){let M=N.text.slice(F,A);if(M.length===0||F3(M))return;return N.inlines.some((E)=>E.start<=F&&E.end>=A&&E.kind==="text"&&E.link===null&&E.marks.length===0)?{kind:"text-fade",regionPath:N.path,startOffset:F,text:M}:void 0}function HJ(N,F){let A=a9(N,F);if(!A)return;return{kind:"text-pulse",offset:A.normalized.start.offset,regionPath:A.region.path}}function a9(N,F){let A=Z0(N,F);if(A.start.regionId!==A.end.regionId)return null;let M=w0(N,A.start.regionId);return M?{normalized:A,region:M}:null}var _J={"(":")","[":"]","{":"}"};function r9(N,F,A){if(A.length!==1)return null;let M=_J[A];if(!M||!xN(F))return null;let D=N.regionIndex.get(F.focus.regionId);if(!D)return null;let E=`${A}${M}`;return{animation:J2(N,F,E),kind:"splice-text",selection:{kind:"region-path",offset:F.focus.offset+A.length,path:D.path},text:E}}function c9(N,F,A){if(F.anchor.regionId!==F.focus.regionId)return null;let M=N.regionIndex.get(F.anchor.regionId);if(!M)return null;let D=PJ(N,F,M);if(!D)return null;let{start:E,end:$}=BJ(N,F);return WJ(M,A,E,$,D)}function BJ(N,F){if(F.anchor.offset===F.focus.offset)return{start:F.anchor.offset,end:F.anchor.offset};let A=Z0(N,F);return{start:A.start.offset,end:A.end.offset}}function PJ(N,F,A){switch(A.blockType){case"heading":{let M=AN(N,F);return M?.block.type==="heading"?{kind:"heading",rootIndex:M.rootIndex}:null}case"paragraph":{let M=e6(N,F);if(M)return{kind:"list-item",item:M};let D=AN(N,F);return D?.block.type==="paragraph"?{kind:"root-paragraph",rootIndex:D.rootIndex}:null}default:return null}}function WJ(N,F,A,M,D){if(D.kind==="root-paragraph"&&!OJ(N,F,M))return null;let E=N.text.slice(0,A)+F+N.text.slice(M);switch(D.kind){case"root-paragraph":return t5(wJ,E,D);case"heading":return t5(LJ,E,D);case"list-item":return t5(TJ,E,D.item)}}function OJ(N,F,A){let M=A<N.text.length?N.text:F;return M.length>0&&/\s/.test(M[M.length-1])}function t5(N,F,A){for(let{pattern:M,apply:D}of N){let E=M.exec(F);if(E)return D(E,A)}return null}var wJ=[{pattern:EN(/(?:[-+*]\s+)?\[[ xX]?\]/,{allowIndent:!0}),apply:(N,{rootIndex:F})=>e5(F,{checked:N[1].toLowerCase().includes("x"),ordered:!1,start:null})},{pattern:EN(/[-+*]/,{allowIndent:!0}),apply:(N,{rootIndex:F})=>e5(F,{checked:null,ordered:!1,start:null})},{pattern:EN(/\d+\./,{allowIndent:!0}),apply:(N,{rootIndex:F})=>e5(F,{checked:null,ordered:!0,start:Number(N[1].slice(0,-1))})},{pattern:EN(/#{1,6}/,{allowIndent:!1}),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[T2({depth:N[1].length,text:""})],rootIndex:F,selection:$0(F)})},{pattern:EN(/>/,{allowIndent:!1}),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[d0([F0("")])],rootIndex:F,selection:j0(F,[0])})},{pattern:EN(/---/,{allowIndent:!1}),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[sF(),F0("")],rootIndex:F,selection:$0(F+1)})}],LJ=[{pattern:A3(/#{1,6}/),apply:(N,{rootIndex:F})=>({kind:"splice-blocks",blocks:[T2({depth:N[1].length,text:N[2]})],rootIndex:F,selection:$0(F)})}],TJ=[{pattern:A3(/\d+\./),apply:(N,F)=>N8(N,F,{ordered:!0,start:1,checked:F.item.checked})},{pattern:A3(/\[[ xX]?\]/),apply:(N,F)=>N8(N,F,{ordered:!1,start:null,checked:N[1].toLowerCase().includes("x")})},{pattern:A3(/[-+*]/),apply:(N,F)=>N8(N,F,{ordered:!1,start:null,checked:null})}];function EN(N,F){let A=F.allowIndent?"\\s*":"";return new RegExp(`^${A}(${N.source})\\s$`)}function A3(N){return new RegExp(`^\\s*(${N.source})\\s(.+)$`)}function e5(N,F){return{kind:"splice-blocks",blocks:[t1({items:[n1({checked:F.checked,children:[F0("")],spread:!1})],ordered:F.ordered,spread:!1,start:F.start})],rootIndex:N,selection:j0(N,[0,0])}}function N8(N,F,A){let M=m9(F.item,N[2]);if(!M)return null;return{kind:"replace-block",block:H0(F.list,F.list.items.map((D,E)=>E===F.itemIndex?{...M,checked:A.checked}:D),{ordered:A.ordered,start:A.start}),blockId:F.list.id,selection:j0(F.rootIndex,[...F.listChildIndices,F.itemIndex,0])}}function s9(N,F,A){return r9(N,F,A)??c9(N,F,A)??{animation:l9(N,F,A),kind:"splice-text",text:A}}function i9(N,F){let A=N.region.text.length,M=N.region.text.slice(0,F),D=N.region.text.slice(F),E=F===0&&A>0?N.rootIndex:N.rootIndex+1;return{kind:"splice-blocks",blocks:e9(N.block,M,D,F,A),rootIndex:N.rootIndex,selection:$0(E)}}function o9(N,F){let A=N.region.text,M=A.slice(0,F),D=A.slice(F),E=e9(N.block,M,D,F,A.length),$=F===0?N.blockChildIndices:[...N.blockChildIndices.slice(0,-1),N.blockChildIndices.at(-1)+1];return{kind:"splice-blocks",blocks:[d0([...N.quote.children.slice(0,N.childIndex),...E,...N.quote.children.slice(N.childIndex+1)])],rootIndex:N.rootIndex,selection:j0(N.rootIndex,$)}}function n9(N,F){if(F!==0||N.region.text.length!==0||N.block.type!=="paragraph")return null;let A=N.quote.children.slice(0,N.childIndex),M=N.quote.children.slice(N.childIndex+1),D=[];if(A.length>0)D.push(d0(A));if(D.push(F0("")),M.length>0)D.push(d0(M));return{kind:"splice-blocks",blocks:D,rootIndex:N.rootIndex,selection:$0(N.rootIndex+(A.length>0?1:0))}}function F8(N,F){if(N.block.type!=="heading")return null;let A=Math.max(1,Math.min(6,N.block.depth+F));if(A===N.block.depth)return{kind:"keep-state"};return{kind:"splice-blocks",blocks:[T2({depth:A,text:N.block.plainText})],rootIndex:N.rootIndex,selection:$0(N.rootIndex,N.offset)}}function t9(N){if(N.block.type!=="paragraph")return null;return{kind:"splice-blocks",blocks:[d0([N.block])],rootIndex:N.rootIndex,selection:j0(N.rootIndex,[0],N.offset)}}function e9(N,F,A,M,D){if(M===0)return[F0(""),N];if(M===D)return[N,F0("")];return[N.type==="heading"?T2({depth:N.depth,text:F}):F0(F),F0(A)]}function tN(N,F,A,M=0){return j0(N,[...F,A,0],M)}function A8(N,F){let A=N.region.text,M=N.item,D=typeof M.checked==="boolean"?!1:M.checked;if(F===0){let Y=oN("",D,M.spread);return{kind:"replace-block",block:H0(N.list,[...N.list.items.slice(0,N.itemIndex),Y,M,...N.list.items.slice(N.itemIndex+1)]),blockId:N.list.id,animation:D3(M3(Y,N.rootIndex,[...N.listChildIndices,N.itemIndex])),selection:tN(N.rootIndex,N.listChildIndices,N.itemIndex)}}if(F===A.length){let Y=oN("",D,M.spread);return{kind:"replace-block",block:H0(N.list,[...N.list.items.slice(0,N.itemIndex+1),Y,...N.list.items.slice(N.itemIndex+1)]),blockId:N.list.id,animation:D3(M3(Y,N.rootIndex,[...N.listChildIndices,N.itemIndex+1])),selection:tN(N.rootIndex,N.listChildIndices,N.itemIndex+1)}}let E=A.slice(0,F),$=A.slice(F),y=oN($,D,M.spread),Z=Z1(M,[F0(E)]);return{kind:"replace-block",block:H0(N.list,[...N.list.items.slice(0,N.itemIndex),Z,y,...N.list.items.slice(N.itemIndex+1)]),blockId:N.list.id,animation:D3(M3(y,N.rootIndex,[...N.listChildIndices,N.itemIndex+1])),selection:tN(N.rootIndex,N.listChildIndices,N.itemIndex+1)}}function N7(N,F){if(F!==0||N.region.text.length!==0)return A8(N,F);if(N.parentItem&&N.parentItemIndex!==null&&N.parentItemChildIndices&&N.parentList&&N.parentListChildIndices)return CJ(N);let A=N.list.items.slice(0,N.itemIndex),M=N.list.items.slice(N.itemIndex+1),D=[];if(A.length>0)D.push(H0(N.list,A));if(D.push(F0("")),M.length>0)D.push(H0(N.list,M));return{kind:"splice-blocks",blocks:D,rootIndex:N.rootIndex,selection:$0(N.rootIndex+(A.length>0?1:0))}}function F7(N){if(N.itemIndex===0)return null;let F=N.list.items[N.itemIndex-1];if(!F)return null;let A=jJ(F,N.item,N);return{kind:"replace-block",block:H0(N.list,N.list.items.flatMap((M,D)=>{if(D===N.itemIndex-1)return[A.item];if(D===N.itemIndex)return[];return[M]})),blockId:N.list.id,selection:j0(N.rootIndex,A.regionChildIndices)}}function A7(N){return M7(N,()=>({insertedItem:N.item}))}function M8(N,F){let A=N.itemIndex+F;if(A<0||A>=N.list.items.length)return null;let M=[...N.list.items],[D]=M.splice(N.itemIndex,1);if(!D)return null;return M.splice(A,0,D),{kind:"replace-block",block:H0(N.list,M),blockId:N.list.id,selection:tN(N.rootIndex,N.listChildIndices,A)}}function CJ(N){return M7(N,(F)=>{let A=typeof F.checked==="boolean"?!1:F.checked;return{insertedItem:oN("",A,F.spread),trackInsertedPath:!0}})}function M7(N,F){if(!N.parentItem||N.parentItemIndex===null||!N.parentItemChildIndices||!N.parentList||!N.parentListChildIndices)return null;let A=N.list.items.filter((Z,Y)=>Y!==N.itemIndex),M=N.parentItem.children.flatMap((Z)=>{if(Z.type!=="list"||Z.id!==N.list.id)return[Z];if(A.length===0)return[];return[H0(N.list,A)]}),D=Z1(N.parentItem,M),{insertedItem:E,trackInsertedPath:$=!1}=F(N.parentItem),y=$?M3(E,N.rootIndex,[...N.parentListChildIndices,N.parentItemIndex+1]):void 0;return{kind:"replace-block",block:H0(N.parentList,[...N.parentList.items.slice(0,N.parentItemIndex),D,E,...N.parentList.items.slice(N.parentItemIndex+1)]),blockId:N.parentList.id,animation:D3(y),selection:tN(N.rootIndex,N.parentListChildIndices,N.parentItemIndex+1)}}function M3(N,F,A){return typeof N.checked==="boolean"?void 0:k9(F,A)}function D3(N){return N?{blockPath:N,kind:"block-pulse"}:void 0}function jJ(N,F,A){let M=N.children.findIndex((E)=>E.type==="list"&&E.ordered===A.list.ordered&&E.start===A.list.start);if(M>=0){let E=N.children[M];if(!E||E.type!=="list")return{item:N,regionChildIndices:[...A.listChildIndices,A.itemIndex-1,0]};return{item:Z1(N,N.children.map(($,y)=>y===M?H0(E,[...E.items,F]):$)),regionChildIndices:[...A.listChildIndices,A.itemIndex-1,M,E.items.length,0]}}let D=t1({items:[F],ordered:A.list.ordered,spread:A.list.spread,start:A.list.start});return{item:Z1(N,[...N.children,D]),regionChildIndices:[...A.listChildIndices,A.itemIndex-1,N.children.length,0,0]}}function D7(N,F,A){let M=AN(N,F),D=Math.max(2,A);if(!M||M.block.type!=="paragraph"||M.block.plainText.length>0||F.anchor.regionId!==F.focus.regionId||F.anchor.offset!==0||F.focus.offset!==0)return null;return{kind:"splice-blocks",blocks:[e1({rows:Array.from({length:2},()=>E8(D))})],rootIndex:M.rootIndex,selection:X2(M.rootIndex,0,0)}}function D8(N,F){let A=F<0?uJ(N.table,N.rowIndex,N.cellIndex):vJ(N.table,N.rowIndex,N.cellIndex);if(!A)return F>0&&mJ(N.table,N.rowIndex,N.cellIndex)?RJ(N):{kind:"keep-state"};let M=N.table.rows[A.rowIndex]?.cells[A.cellIndex];if(!M)return{kind:"keep-state"};return{kind:"set-selection",selection:fJ(N.documentIndex,N.selection,N.table,A.rowIndex,A.cellIndex,Math.min(N.selection.focus.offset,M.plainText.length))}}function E7(N){let F=Math.min(N.selection.anchor.offset,N.selection.focus.offset),A=Math.max(N.selection.anchor.offset,N.selection.focus.offset),M=p0(N.inlineContainer,F,A,[y1()]);return{kind:"replace-block",block:M.block,blockId:M.blockId,selection:M.selection}}function $7(N,F){let A=F==="left"?N.cellIndex:N.cellIndex+1;return $N(N,e1({align:S7(N.table.align,A,0,[null]),rows:N.table.rows.map((M)=>j2(bJ(M.cells,A,0,[Q7()])))}),X2(N.rootIndex,N.rowIndex,A))}function y7(N){let F=Math.max(0,...N.table.rows.map((A)=>A.cells.length));if(F<=1)return null;return $N(N,e1({align:S7(N.table.align,N.cellIndex,1,[]),rows:N.table.rows.map((A)=>j2(A.cells.filter((M,D)=>D!==N.cellIndex)))}),X2(N.rootIndex,N.rowIndex,Math.min(N.cellIndex,F-2)))}function Z7(N,F){let A=F==="above"?N.rowIndex:N.rowIndex+1,M=Math.max(1,...N.table.rows.map((D)=>D.cells.length));return $N(N,a0(N.table,[...N.table.rows.slice(0,A),E8(M),...N.table.rows.slice(A)]),X2(N.rootIndex,A,Math.min(N.cellIndex,M-1)))}function Y7(N){if(N.table.rows.length<=1)return null;let F=N.table.rows.filter((D,E)=>E!==N.rowIndex),A=Math.min(N.rowIndex,F.length-1),M=F[A]?.cells.length??1;return $N(N,a0(N.table,F),X2(N.rootIndex,A,Math.min(N.cellIndex,M-1)))}function X7(N){return $N(N,F0(""),$0(N.rootIndex))}function E8(N){return j2(Array.from({length:N},()=>Q7()))}function Q7(){return L1([])}function RJ(N){let F=N.table.rows.length,A=Math.max(1,...N.table.rows.map((M)=>M.cells.length));return $N(N,a0(N.table,[...N.table.rows,E8(A)]),X2(N.rootIndex,F,0))}function $N(N,F,A){return{kind:"replace-block",block:F,blockId:N.table.id,selection:A}}function bJ(N,F,A,M){return[...N.slice(0,F),...M,...N.slice(F+A)]}function S7(N,F,A,M){return[...N.slice(0,F),...M,...N.slice(F+A)]}function fJ(N,F,A,M,D,E){let $=n2(N,A.id,M,D);if(!$)return F;return{anchor:{regionId:$.id,offset:E},focus:{regionId:$.id,offset:E}}}function uJ(N,F,A){if(A>0)return{cellIndex:A-1,rowIndex:F};if(F>0){let M=N.rows[F-1];if(!M||M.cells.length===0)return null;return{cellIndex:M.cells.length-1,rowIndex:F-1}}return null}function vJ(N,F,A){let M=N.rows[F];if(!M)return null;if(A+1<M.cells.length)return{cellIndex:A+1,rowIndex:F};let D=N.rows[F+1];if(!D||D.cells.length===0)return null;return{cellIndex:0,rowIndex:F+1}}function mJ(N,F,A){let M=N.rows[F];return Boolean(M&&F===N.rows.length-1&&A===M.cells.length-1)}function J7(N){switch(N.kind){case"code":return{kind:"splice-text",text:`
27
+ `};case"tableCell":return E7(N);case"listItem":return N7(N,N.offset)??A8(N,N.offset);case"blockquoteTextBlock":return n9(N,N.offset)??o9(N,N.offset);case"rootTextBlock":return i9(N,N.offset);case"unsupported":return null}}function V7(N,F){let A=Z0(N,F);if(A.collapsed)return null;let M=w0(N,A.start.regionId),D=w0(N,A.end.regionId);if(!M||!D)return null;let E=N.document.blocks[M.rootIndex],$=N.document.blocks[D.rootIndex];if(!E||!$)return null;if(M===D)return{kind:"single-region",normalized:A,region:M,root:E,wholeRegion:A.start.offset===0&&A.end.offset===M.text.length};return{kind:"multi-region",normalized:A,startRegion:M,endRegion:D,sameRoot:M.rootIndex===D.rootIndex,startRoot:E,endRoot:$}}function $8(N,F){let A=V7(N,F);if(!A)return null;switch(A.kind){case"single-region":if(!A.wholeRegion||A.region.blockType==="table"){let D=gJ(A.region,A.normalized.start.offset,A.normalized.end.offset);return kJ(D)}let M=U7(A.root,A.region);return M?q7([M]):null;case"multi-region":{let D=A.sameRoot?hJ(N,A.startRoot,A.startRegion,A.normalized.start.offset,A.endRegion,A.normalized.end.offset):xJ(N,A.startRegion,A.normalized.start.offset,A.endRegion,A.normalized.end.offset);return D.length>0?q7(D):null}}}function kJ(N){if(N.length===0)return null;if(z4(N))return{kind:"text",text:J0(N)};return{kind:"inlines",inlines:N}}function q7(N){if(tF(N))return{kind:"text",text:N[0].plainText};return{kind:"blocks",blocks:N}}function U7(N,F){if(N.id===F.blockId)return N;let A=C0(N);if(!A)return null;let M=A.find((E)=>S2(E,F)),D=M?U7(M,F):null;return D?C1(N,[D]):null}function gJ(N,F,A){let M=NN(N.inlines,A,N.text.length,""),D=NN(M,0,F,"");return j5(D)}function hJ(N,F,A,M,D,E){if(F.type==="table")return pJ(N,F,A,M,D,E);let $=K7(F,A,M,D,E);return $?[$]:[]}function IJ(N,F,A,M,D){let E=N.roots[F.rootIndex],$=E?.regions[0],y=E?.regions.at(-1);return F===$&&M===y&&A===0&&D===y.text.length}function pJ(N,F,A,M,D,E){if(IJ(N,A,M,D,E))return[F];let $=A.tableCellPosition?.rowIndex,y=A.tableCellPosition?.cellIndex,Z=D.tableCellPosition?.rowIndex,Y=D.tableCellPosition?.cellIndex;if($===void 0||y===void 0||Z===void 0||Y===void 0)return[];if($!==0||y!==0||M!==0)return[];let X=F.rows[Z];if(!X)return[];let Q=X.cells.length-1;if(Y!==Q||E!==D.text.length)return[];return[a0(F,F.rows.slice(0,Z+1))]}function K7(N,F,A,M,D){let E=C0(N);if(!E)return null;let $=E.findIndex((Z)=>S2(Z,F)),y=E.findIndex((Z)=>S2(Z,M));if($===-1||y===-1)return null;if($===y){let Z=K7(E[$],F,A,M,D);return Z?C1(N,[Z]):null}return C1(N,z7(E,$,F,A,y,M,D))}function xJ(N,F,A,M,D){return z7(N.document.blocks,F.rootIndex,F,A,M.rootIndex,M,D)}function z7(N,F,A,M,D,E,$){let y=rN(N[F],A,M),Z=N.slice(F+1,D),Y=aN(N[D],E,$);return[y,...Z,Y].filter((X)=>X!==null)}function y8(N,F,A){let M=sJ(N.documentIndex,N.selection);if(!M)return null;return{destination:M,documentIndex:N.documentIndex,inlineContext:M.sameRegion?H1(N):null,selection:N.selection}}function Z8(N,F,A){let M=lJ(N,F)??dJ(N,F,A);return M?cJ(N,M,F):null}function lJ(N,F){switch(F.kind){case"text":return F.text.length>0?{kind:"splice-text",text:F.text}:null;case"inlines":{if(F.inlines.length===0)return null;if(N.destination.sameRegion){let A=N.inlineContext?x9(N.inlineContext,F.inlines):null;if(A)return A}if(N.destination.structuralBlocked)return null;return{kind:"splice-fragment",blocks:[$1(F.inlines)]}}case"blocks":if(F.blocks.length===0||N.destination.structuralBlocked)return null;return{kind:"splice-fragment",blocks:F.blocks}}}function dJ(N,F,A){if(F.kind==="text")return null;let M=N.destination.prefersVerbatimFallback&&A&&A.length>0?A:eF(F);return M.length>0?{kind:"splice-text",text:M}:null}function aJ(N,F){if(N.kind==="splice-text")return N.text;if(N.kind==="replace-block"||N.kind==="splice-fragment")return rJ(F);return""}function rJ(N){switch(N.kind){case"text":return N.text;case"inlines":return J0(N.inlines);case"blocks":return N.blocks.length===1&&N.blocks[0].type==="paragraph"?N.blocks[0].plainText:""}}function cJ(N,F,A){let M=J2(N.documentIndex,N.selection,aJ(F,A));return M?{...F,animation:M}:F}function sJ(N,F){let A=Z0(N,F),M=w0(N,A.start.regionId),D=w0(N,A.end.regionId);if(!M||!D)return null;let E=G7(M)||G7(D);return{prefersVerbatimFallback:M.blockType==="code"||D.blockType==="code",sameRegion:M===D,structuralBlocked:E}}function G7(N){return N.blockType==="table"||N.blockType==="code"}function E3(N,F,A){return{animation:J2(N,F,A),kind:"splice-text",text:A}}function H7(N,F){return{animation:n5(N.region,N.startOffset,F),kind:"splice-text",range:N.selection,text:F}}function _7(N,F,A,M){let D=M==="backward"?f4(N,F.blockId):wN(N,F.blockId);if(D&&Q1(D))return iJ(F,D,M);let E=M==="backward"?M2(N,F.id):ON(N,F.id);if(!E)return null;if(A)return nJ(N,F,E,M);let $=M==="backward"?F:E,y=M==="backward"?E:F;if(!oJ(y))return null;return tJ(N,$,y)}function iJ(N,F,A){if(F.parentBlockId!==null)return null;let M=A==="backward"?N.rootIndex-1:N.rootIndex,D=A==="backward"?0:"end";return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:[],selection:y3(N,M,D)}}function oJ(N){return N.blockType==="paragraph"||N.blockType==="heading"}function nJ(N,F,A,M){let D=N.document.blocks[F.rootIndex];if(!D)return null;let E=$3(D,F,A.blockId,void 0),$=M==="backward"?A.text.length:0,Z=F.rootIndex===A.rootIndex?NV(E,A.rootIndex,A.blockId,$):FV(A,F.rootIndex,E.length,$);if(!Z)return null;return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:E,selection:Z}}function tJ(N,F,A){let M=o0(N.document,A.blockId),D=o0(N.document,F.blockId);if(!M||M.type!=="paragraph"&&M.type!=="heading")return null;let E=A.text.length,$=eJ(M,D),y=y3(A,A.rootIndex,E);if(F.rootIndex===A.rootIndex){let K=N.document.blocks[F.rootIndex];if(!K)return null;let q=$3(K,F,A.blockId,$);return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:q,selection:y}}let Z=N.document.blocks[A.rootIndex],Y=N.document.blocks[F.rootIndex];if(!Z||!Y)return null;let X=$3(Z,F,A.blockId,$);if(X.length!==1)return null;let Q=X[0],S=$3(Y,F,A.blockId,void 0),J=Math.min(A.rootIndex,F.rootIndex),V=A.rootIndex<F.rootIndex?[Q,...S]:[...S,Q];return{kind:"splice-blocks",rootIndex:J,count:2,blocks:V,selection:y}}function y3(N,F,A=0){let M=g1(N.path);if(M.length===0)return $0(F,A);return j0(F,M,A)}function eJ(N,F){let A=F&&(F.type==="paragraph"||F.type==="heading")?F.children:[];return k0(N,W0([...N.children,...A]))}function NV(N,F,A,M){for(let D=0;D<N.length;D+=1){let E=N[D],$=Y8(E,A);if($){if($.length===0)return $0(F+D,M);return j0(F+D,$,M)}}return null}function FV(N,F,A,M){let D=g1(N.path),E=A-1,$=N.rootIndex<F?N.rootIndex:N.rootIndex+E;if(D.length===0)return $0($,M);return j0($,D,M)}function Y8(N,F){if(N.id===F)return[];switch(N.type){case"list":for(let A=0;A<N.items.length;A+=1){let M=Y8(N.items[A],F);if(M)return[A,...M]}return null;case"listItem":case"blockquote":for(let A=0;A<N.children.length;A+=1){let M=Y8(N.children[A],F);if(M)return[A,...M]}return null;default:return null}}function $3(N,F,A,M){return u2([N],(D,{parent:E,recurse:$})=>{if(D.type==="listItem"){let Z=D.children[0];if(Z&&Z.id===F.blockId)return AV(D)}if(D.id===F.blockId&&E?.type!=="listItem")return[];if(D.id===A&&M!==void 0)return M;let y=$();if(y.type==="listItem"){let Z=y.children[0];if(!Z||Z.type!=="paragraph"&&Z.type!=="heading")return[]}return y})}function AV(N){if(N.type==="listItem")return N.children.filter((F)=>F.type==="list").flatMap((F)=>F.items);return[]}function B7(N,F){let A=u4(N,F.rootIndex);if(!A||A.id!==F.id)return null;let M=N.document.blocks[F.rootIndex];if(!M)return null;let D=MV(M);if(!D)return null;return{kind:"splice-blocks",rootIndex:F.rootIndex,count:1,blocks:D,selection:$0(F.rootIndex)}}function MV(N){switch(N.type){case"heading":return[$1(N.children)];case"blockquote":return[...N.children];case"list":return P7(N.items);default:return null}}function P7(N){return N.flatMap((F)=>{let A=[DV(F)];for(let M of F.children)if(M.type==="list")A.push(...P7(M.items));return A})}function DV(N){let F=N.children[0];if(F&&(F.type==="paragraph"||F.type==="heading"))return $1(F.children);return F0("")}function W7(N,F){if(N.selection.anchor.regionId!==N.selection.focus.regionId||N.selection.anchor.offset!==N.selection.focus.offset)return null;let A=w0(N.documentIndex,N.selection.focus.regionId);if(!A)return null;if(F==="forward"&&N.selection.focus.offset>=A.text.length)return null;let M=F==="backward"?RN(A.text,N.selection.focus.offset,-1):N.selection.focus.offset,D=F==="backward"?N.selection.focus.offset:RN(A.text,N.selection.focus.offset,1);if(M===D)return null;return{animation:F==="backward"&&(D===A.text.length||EV(A,D))?d9(A,M,D):void 0,kind:"splice-text",range:{anchor:{regionId:A.id,offset:M},focus:{regionId:A.id,offset:D}},text:""}}function EV(N,F){return N.inlines.some((A)=>A.kind==="lineBreak"&&A.start===F)}function X8(N,F){return yV(N)??W7(N,F)??$V(N.documentIndex,u9(N,F))}function $V(N,F){if(F.kind==="unsupported"||!F.atBoundary)return null;if(F.direction==="backward"){let A=ZV(F,N);if(A)return A}return _7(N,F.region,F.empty,F.direction)}function yV(N){let F=Z0(N.documentIndex,N.selection);if(F.start.regionId===F.end.regionId&&F.start.offset===F.end.offset)return null;return E3(N.documentIndex,N.selection,"")}function ZV(N,F){let A=B7(F,N.region);if(A)return A;if(N.kind==="rootTextBlock"){let M=YV(N,F);if(M)return M}return null}function YV(N,F){if(N.block.type!=="paragraph"||N.block.plainText.length!==0)return null;let A=F.document.blocks[N.rootIndex-1],M=F.document.blocks[N.rootIndex+1];if(!A||A.type!=="list"||!M||M.type!=="list"||!XV(A,M))return null;let D=M2(F,N.region.id),E=D?y3(D,N.rootIndex-1,"end"):$0(N.rootIndex-1,"end");return{kind:"splice-blocks",count:3,blocks:[H0(A,[...A.items,...M.items])],rootIndex:N.rootIndex-1,selection:E}}function XV(N,F){return N.ordered===F.ordered&&N.start===F.start}var eN=N0((N,F)=>s9(N.documentIndex,N.selection,F)),Z3=N0(J7,t6),O7=N0((N)=>VV(N)??{kind:"splice-text",text:`
28
+ `}),QV=N0((N,F)=>E3(N.documentIndex,N.selection,F)),Y3=N0((N,F,A,M)=>H7(N,M),(N,F,A)=>g5(N,F,A)),w7=(N)=>QV(N,""),Q8=N0((N)=>X8(N,"backward")),S8=N0((N)=>X8(N,"forward")),NF=(N)=>$8(N.documentIndex,N.selection),SV=N0(Z8,y8);function L7(N,F,A){return SV(N,F,A)}function T7(N){let F=N.documentIndex.regions,A=F[0],M=F.at(-1);if(!A||!M)return N;return L0(N,{anchor:{regionId:A.id,offset:0},focus:{regionId:M.id,offset:M.text.length}})}var X3=K3("bold"),Q3=K3("italic"),S3=K3("strikethrough"),J3=K3("underline"),V3=N0((N)=>DN(N,d5),H1),C7=N0((N,F,A)=>DN(N,(M,D,E)=>c5(M,D,E,A)),n6),j7=N0((N,F)=>DN(N,s5),n6),R7=N0((N,F)=>DN(N,(A,M,D)=>r5(A,M,D,F)),H1),b7=N0((N,F,A)=>o5(N,w1({alt:A??null,url:F})),H1),f7=N0((N,F,A,M,D="")=>i5(N,A,M,D),n6),u7=N0((N,F,A)=>a5(N.inlineContainer,F,A),H1),J8=(N)=>v5(N),V8=(N)=>m5(N),q3=N0((N)=>{switch(N.kind){case"tableCell":return D8(N,1);case"rootTextBlock":return F8(N,1)??t9(N);case"listItem":return F7(N);default:return null}},t6),U3=N0((N)=>{switch(N.kind){case"tableCell":return D8(N,-1);case"rootTextBlock":return F8(N,-1);case"listItem":return A7(N);default:return null}},t6),v7=N0((N)=>M8(N,-1),h5),m7=N0((N)=>M8(N,1),h5),k7=N0((N,F)=>{let A=sN(N.documentIndex,F);if(!A||A.type!=="listItem"||typeof A.checked!=="boolean")return null;return{kind:"replace-block",block:{...A,checked:!A.checked},blockId:F}}),g7=N0((N,F)=>D7(N.documentIndex,N.selection,F)),h7=N0((N,F)=>$7(N,F),MN),I7=N0(y7,MN),p7=N0((N,F)=>Z7(N,F),MN),x7=N0(Y7,MN),l7=N0(X7,MN),d7=N0((N,F,A)=>{let M=q5(N.documentIndex,F,A);if(!M)return null;return{kind:"splice-comments",count:0,index:N.documentIndex.document.comments.length,threads:[M]}}),a7=(N,F,A)=>FF(N,F,(M)=>T4(M,{body:A.trim()})),r7=(N,F,A,M)=>FF(N,F,(D)=>C4(D,A,M)),c7=(N,F,A)=>FF(N,F,(M)=>j4(M,A)),s7=(N,F)=>FF(N,F,()=>null),i7=(N,F,A)=>FF(N,F,(M)=>R4(M,A));function N0(N,F){return(A,...M)=>{let D=F?JV(N,F,A,M):N(A,...M);if(!D)return null;return u5(A,D)}}function JV(N,F,A,M){let D=F(A,...M);return D?N(D,...M):null}function VV(N){let F=H1(N);return F?o5(F,y1()):null}function K3(N){return N0((F)=>DN(F,(A,M,D)=>l5(A,M,D,N)),H1)}function FF(N,F,A){let D=h0(N.documentIndex).threads[F];if(!D)return null;let E=A(D);if(E===D)return null;return u5(N,{kind:"splice-comments",count:1,index:F,threads:E?[E]:[]})}var o7=1;function n7(N,F,A){let M=N.documentIndex.regionOrderIndex.get(N.selection.focus.regionId);if(M===void 0)return N;let D=N.documentIndex.regions[M],E=RN(D.text,N.selection.focus.offset,F);if(E!==N.selection.focus.offset)return I0(N,D.id,E,A);if(F<0){let y=M2(N.documentIndex,D.id);if(!y)return N;return I0(N,y.id,y.text.length,A)}let $=ON(N.documentIndex,D.id);if(!$)return N;return I0(N,$.id,0,A)}function t7(N,F,A,M,D){let E=a2(F,A.regionId,A.offset);if(!E)return N;let $=F.lines[E.index+M];if(!$)return N;let y=v0(F,N,{x:A1(N,F,A)+o7,y:$.top+$.height/2});if(!y)return N;return I0(N,y.regionId,y.offset,D)}function e7(N,F,A,M){let D=FE(N,F);if(!D)return N;return I0(N,D.regionId,A==="Home"?D.start:D.end,M)}function NE(N,F,A,M,D){let E=FE(N,F);if(!E)return N;let y=Math.max(1,Math.floor(480/F.options.lineHeight)),Z=a2(F,E.regionId,N.selection.focus.offset),Y=Z?F.lines[Z.index+M*y]:null;if(!Y)return N;let X=v0(F,N,{x:A1(N,F,A)+o7,y:Y.top+Y.height/2});if(!X)return N;return I0(N,X.regionId,X.offset,D)}function FE(N,F){return N1(F,N.selection.focus.regionId,N.selection.focus.offset)}var qV=1;function AE(N,F,A,M,D){let E=N.documentIndex.regionIndex.get(N.selection.focus.regionId)??null;if(!E)return null;let $=N.documentIndex.tableCellIndex.get(E.id)??null,y=N.documentIndex.blockIndex.get(E.blockId)??null;if(!$||y?.type!=="table")return null;let Z=UV(N,y.id,$.rowIndex+M,$.cellIndex)??KV(N,y.id,M);if(!Z)return N;let Y=F.regionBounds.get(E.id),X=F.regionBounds.get(Z.id);if(!Y||!X)return N;let Q=X.top+zV(A.top+A.height/2-Y.top,0,Math.max(0,X.bottom-X.top-1)),S=v0(F,N,{x:A1(N,F,A)+qV,y:Q});if(!S)return N;return I0(N,S.regionId,S.offset,D)}function UV(N,F,A,M){return n2(N.documentIndex,F,A,M)}function KV(N,F,A){let M=N.documentIndex.blockIndex.get(F),D=N.documentIndex.regions,E=M?N.documentIndex.roots[M.rootIndex]?.regionRange:void 0;if(!E)return null;return A<0?D[E.start-1]??null:D[E.end]??null}function zV(N,F,A){return Math.max(F,Math.min(A,N))}function q8(N,F,A=!1){return n7(N,F,A)}function U8(N,F,A,M=!1){return GV(N,F,A,M)}function K8(N,F,A,M=!1){return HV(N,F,A,M)}function z8(N,F,A,M=!1){return e7(N,F,A,M)}function G8(N,F,A=!1){return _V(N,F,A)}function H8(N,F,A){let M=C6(N,F,A);return M?L0(N,{offset:M.offset,regionId:M.regionId}):null}function _8(N,F,A){let M=C6(N,F,A);return M?I0(N,M.regionId,M.offset,!0):null}function AF(N,F,A,M){let D=Q5(N,F,A,M);return D?L0(N,{anchor:M,focus:D}):null}function GV(N,F,A,M){let D=ME(N,F);if(!D)return N;return AE(N,F,D,A,M)??t7(N,F,D,A,M)}function HV(N,F,A,M){let D=ME(N,F);if(!D)return N;return NE(N,F,D,A,M)}function _V(N,F,A){let M=N.documentIndex.regions,D=F==="start"?M[0]:M.at(-1);if(!D)return N;return I0(N,D.id,F==="start"?0:D.text.length,A)}function ME(N,F){return F1(F,N.documentIndex,{regionId:N.selection.focus.regionId,offset:N.selection.focus.offset})}var BV=80;function EE({context:N,containerBounds:F,isHeaderRow:A,lineHeight:M,theme:D}){let E=yE(F,M);N.fillStyle=A?D.tableHeaderBackground:D.tableBodyBackground,N.fillRect(E.left,E.top,E.width,E.height),ZE(N,E,D)}function $E({activeBlockFlashes:N,activeBlockId:F,activeRegionId:A,context:M,editorState:D,endIndex:E,layout:$,regionBounds:y,startIndex:Z,theme:Y,verticalBleed:X}){if(!F||!A)return;let Q=D.documentIndex.blockIndex.get(F)??null;if(Q?.type!=="table")return;if((D.documentIndex.regionIndex.get(A)??null)?.blockId!==F)return;let J=y.get(A)??null,V=$.regionLineIndices.get(A)??null;if(!J||!V||V.length===0)return;let K=$.lines[V[0]]??null;if(!K)return;let q=yE(J,K.height);if(q.width===0)return;let U=DE({context:M,endIndex:E,fillStyle:Y.activeBlockBackground,layout:$,left:q.left,lineIndices:V,startIndex:Z,verticalBleed:X,width:q.width}),z=Q.path?N.get(Q.path)??null:null;if(z)DE({context:M,endIndex:E,fillStyle:a6(Y.activeBlockFlash,z),layout:$,left:q.left,lineIndices:V,startIndex:Z,verticalBleed:X,width:q.width});if(!U)return;ZE(M,q,Y)}function DE({context:N,endIndex:F,fillStyle:A,layout:M,left:D,lineIndices:E,startIndex:$,verticalBleed:y,width:Z}){N.fillStyle=A;let Y=!1;for(let X of E){if(X<$)continue;if(X>=F)break;let Q=M.lines[X];N.fillRect(D,Q.top-y,Z,Q.height),Y=!0}return Y}function yE(N,F){return{height:Math.max(N.bottom-N.top,F),left:N.left,top:N.top,width:Math.max(N.right-N.left,BV)}}function ZE(N,F,A){N.strokeStyle=A.tableBorder,N.strokeRect(F.left,F.top,F.width,F.height)}var z3=2,PV=3,WV=12,OV=6,wV=3,LV=8,TV=12,CV=28,jV=4,YE=1,RV=5,bV=2,fV=1;function XE(N,F,A,M,D,E,$){if(!M||F.start!==0)return;if(A?.type==="code"){let y=Math.max(0,F.left-TV);N.fillStyle=E.codeBackground,N.fillRect(y,M.top-jV,Math.max(M.right-F.left+CV,$-y),M.bottom-M.top+LV);return}if(A?.type!=="table")return;EE({context:N,containerBounds:M,isHeaderRow:D?.rowIndex===0,lineHeight:F.height,theme:E})}function QE(N,F,A,M,D,E,$,y){if(F.blockId!==D||A?.type==="table")return;let Z=M?E.get(M)??null:null;if(N.fillStyle=$.activeBlockBackground,N.fillRect(0,F.top-z3,y,F.height),!Z)return;N.fillStyle=a6($.activeBlockFlash,Z),N.fillRect(0,F.top-z3,y,F.height)}function SE(N,F,A,M,D,E){let $=new Map;for(let y=M;y<D;y+=1){let Z=N.lines[y],Y=A.get(Z.blockId);if(Y?.type!=="heading"||Y.depth!==1&&Y.depth!==2)continue;let X=$.get(Y.id),Q={bottom:Z.top+Z.height,left:Z.left+g0(F,Z),right:E-N.options.paddingX};$.set(Y.id,X?{bottom:Math.max(X.bottom,Q.bottom),left:X.left,right:X.right}:Q)}return $}function JE(N,F,A,M,D,E){for(let $=A;$<M;$+=1){let y=F.blocks[$];if(y.type==="divider"){let Z=F.options.paddingX+y.depth*F.options.indentWidth,Y=E-F.options.paddingX,X=Math.round(y.top+(y.bottom-y.top-YE)/2);qE(N,{color:D.dividerRule??D.headingRule,left:Z,right:Y,thickness:YE,top:X})}}}function VE(N,F,A){for(let M of F.values())qE(N,{color:A.headingRule,left:M.left,minimumWidth:bV,right:M.right,thickness:fV,top:M.bottom+RV})}function qE(N,F){N.fillStyle=F.color,N.fillRect(F.left,F.top,Math.max(F.minimumWidth??0,F.right-F.left),F.thickness)}function UE(N,F,A,M,D){let E=new Map;for(let $=M;$<D;$+=1){let y=N.lines[$],Z=z1(F,y.blockId,"blockquote");if(!Z)continue;let Y=E.get(Z.id),X={bottom:y.top+y.height,isActive:y.blockId===A,left:N.options.paddingX+(Z.depth+1)*N.options.indentWidth-10,top:y.top};E.set(Z.id,Y?{bottom:Math.max(Y.bottom,X.bottom),isActive:Y.isActive||X.isActive,left:Y.left,top:Math.min(Y.top,X.top)}:X)}return E}function KE(N,F,A){for(let M of F.values())N.fillStyle=M.isActive?A.blockquoteRuleActive:A.blockquoteRule,N.fillRect(M.left,M.top+PV,wV,Math.max(WV,M.bottom-M.top-OV))}var uV=1,vV=2,mV=2;function B8({context:N,devicePixelRatio:F,editorState:A,height:M,layout:D,normalizedSelection:E,presence:$,showCaret:y,theme:Z,viewportTop:Y,width:X}){N.save(),N.scale(F,F),N.clearRect(0,0,X,M);let Q=E.start.regionId===E.end.regionId&&E.start.offset!==E.end.offset,S=y&&!Q;if(N.translate(0,-Y),S)zE(N,A,D,{color:Z.caret,offset:A.selection.focus.offset,regionId:A.selection.focus.regionId});if($)for(let J of $){if(!J.cursorPoint)continue;zE(N,A,D,{color:J.color??Z.leafAccent,offset:J.cursorPoint.offset,regionId:J.cursorPoint.regionId})}N.restore()}function zE(N,F,A,M){let D=F1(A,F.documentIndex,{regionId:M.regionId,offset:M.offset});if(!D)return;let E=A1(F,A,D),$=kV(A,D);N.fillStyle=M.color,N.fillRect(E,$.top,vV,$.height)}function kV(N,F){let A=N1(N,F.regionId,F.offset),M=A?.font??'16px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',{ascent:D,descent:E}=e0(M),$=Math.max(1,D+E),y=Math.min(F.height-mV,$),Z=A?Math.max(A.top,A.top+M5(A.height,M)-uV):F.top+Math.max(0,Math.floor((F.height-y)/2));return{height:y,top:Z}}var GE=2,HE=8,gV=3,hV=1.5,IV=2,yN={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function _E(N,F,A,M,D,E,$,y=null){if(!A||F.start!==0)return;if(y){let Z=Y9(y),Y=aV(A,F,M,D,N);N.save(),N.translate(Y.x,Y.y),N.scale(Z,Z),N.translate(-Y.x,-Y.y)}if(A.kind==="task")pV(N,F,A.checked,$,y);else{let Z=$.listMarkerText??E;if(N.fillStyle=y?dN(Z,y,$):Z,A.kind==="ordered")dV(N,A.label,M,D);else N.fillText(A.label,F.left-GE,D)}if(y)N.restore()}function pV(N,F,A,M,D=null){let E=y2(F);if(xV(N,E,A,M,D),!A)return;lV(N,E,M,D)}function xV(N,F,A,M,D=null){let E=A?M.checkboxCheckedFill:M.checkboxUncheckedFill,$=A?M.checkboxCheckedStroke:M.checkboxUncheckedStroke;N.fillStyle=D?dN(E,D,M):E,N.strokeStyle=D?dN($,D,M):$,N.beginPath(),N.lineWidth=hV,N.roundRect(F.left,F.top,F.size,F.size,gV),N.fill(),N.stroke()}function lV(N,F,A,M=null){N.strokeStyle=M?dN(A.checkboxCheckmark,M,A):A.checkboxCheckmark,N.lineWidth=IV,N.beginPath(),N.moveTo(F.left+yN.start.x,F.top+yN.start.y),N.lineTo(F.left+yN.elbow.x,F.top+yN.elbow.y),N.lineTo(F.left+yN.end.x,F.top+yN.end.y),N.stroke()}function dV(N,F,A,M){let D=N.textAlign;N.textAlign="right",N.fillText(F,A-HE,M),N.textAlign=D}function aV(N,F,A,M,D){if(N.kind==="task"){let y=y2(F);return{x:y.left+y.size/2,y:y.top+y.size/2}}let E=D.measureText(N.label),$=M-(E.actualBoundingBoxAscent-E.actualBoundingBoxDescent)/2;if(N.kind==="ordered")return{x:A-HE-E.width/2,y:$};return{x:F.left-GE+E.width/2,y:$}}var G3=0.42;function P8(N){let F=Math.max(0,N)%2200/2200;return(1+Math.cos(F*Math.PI*2))/2}function H3(N,F){let A=P8(N);return F+(1-F)*A}var rV=2,cV=1,sV=2,iV=5,oV=2,nV=3;function BE(N,F){let A=N.documentIndex.regionOrderIndex,M=A.get(F.start.regionId),D=A.get(F.end.regionId);return M===void 0||D===void 0?null:{end:D,start:M}}function PE(N,F,A,M,D,E){if(!D)return;let $=F.documentIndex.regionOrderIndex.get(A.regionId);if($===void 0||$<D.start||$>D.end)return;let y=$===D.start?Math.max(A.start,M.start.offset):A.start,Z=$===D.end?Math.min(A.end,M.end.offset):A.end;if(Z<=y)return;let{left:Y,width:X}=OE(F,A,y,Z,rV);N.fillStyle=E.selectionBackground,N.fillRect(Y,A.top+cV,X,A.height-sV)}function WE(N,F,A,M,D,E,$,y){for(let Z of M){if(Z.regionId!==A.regionId)continue;let Y=Math.max(Z.startOffset,A.start),X=Math.min(Z.endOffset,A.end);if(X<=Y)continue;N.fillStyle=tV(Z,D,E,y);let Q=!Z.resolved&&E.has(Z.threadIndex),{left:S,width:J}=OE(F,A,Y,X,oV);if(Q)N.save(),N.globalAlpha*=H3($,G3);if(N.fillRect(S,A.top+A.height-iV,J,nV),Q)N.restore()}}function OE(N,F,A,M,D){let E=mN(N,F,A-F.start),$=mN(N,F,M-F.start);return{left:E,width:Math.max(D,$-E)}}function tV(N,F,A,M){if(N.resolved)return N.threadIndex===F?M.commentHighlightResolvedActive:M.commentHighlightResolved;return N.threadIndex===F?M.commentHighlightActive:A.has(N.threadIndex)?A.get(N.threadIndex)??M.leafAccent:M.commentHighlight}function LE(N,F,A,M,D,E,$){let y=A.image?M.images.get(A.image.url):null,Z=Fq(A,M,$),Y=Aq(F,E,$,Z);if(N.fillStyle=D.imageSurfaceBackground,N.fillRect(Y.left,Y.top,Y.width,Y.height),y?.status==="loaded"&&y.source)N.drawImage(y.source,Y.left,Y.top,Y.width,Y.height);else eV(N,D,{...Y,status:y?.status==="error"?"error":"loading"});N.strokeStyle=D.imageSurfaceBorder,N.strokeRect(Y.left,Y.top,Y.width,Y.height)}function eV(N,F,A){let M=A.status==="loading"?"Loading image":"Image unavailable",D=Mq(A),E=A.top+A.height/2+D.size*0.9;if(N.save(),N.beginPath(),N.rect(A.left,A.top,A.width,A.height),N.clip(),A.status==="loading")Nq(N,F,A);N.strokeStyle=F.imagePlaceholderIcon,N.lineWidth=1.5,N.strokeRect(D.left,D.top,D.size,D.size),N.beginPath(),N.arc(D.left+D.size*0.28,D.top+D.size*0.3,D.size*0.1,0,Math.PI*2),N.moveTo(D.left+D.size*0.12,D.top+D.size*0.82),N.lineTo(D.left+D.size*0.42,D.top+D.size*0.5),N.lineTo(D.left+D.size*0.58,D.top+D.size*0.66),N.lineTo(D.left+D.size*0.78,D.top+D.size*0.38),N.lineTo(D.left+D.size*0.88,D.top+D.size*0.82),N.stroke(),N.font='500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',N.fillStyle=F.imagePlaceholderText,N.textAlign="center",N.textBaseline="middle",N.fillText(M,A.left+A.width/2,E),N.restore()}function Nq(N,F,A){let M=Math.max(48,Math.round(A.width*0.22)),D=A.width+M*2,E=performance.now()%1800/1800,$=A.left-M+D*E,y=N.createLinearGradient($,A.top,$+M,A.top);y.addColorStop(0,"rgba(255,255,255,0)"),y.addColorStop(0.5,F.imageLoadingOverlay),y.addColorStop(1,"rgba(255,255,255,0)"),N.fillStyle=y,N.fillRect(A.left,A.top,A.width,A.height)}function Fq(N,F,A){if(!N.image)return wE(A);let M=F.images.get(N.image.url);if(!M||M.intrinsicWidth<=0||M.intrinsicHeight<=0)return wE(A);return Math.max(48,Math.round(A*(M.intrinsicHeight/M.intrinsicWidth)))}function Aq(N,F,A,M){return{height:M,left:F,top:N.top+Math.max(0,Math.floor((N.height-M)/2)),width:A}}function Mq(N){let F=Math.max(18,Math.min(34,Math.round(Math.min(N.width,N.height)*0.18)));return{left:N.left+Math.max(12,Math.round((N.width-F)/2)),size:F,top:N.top+Math.max(12,Math.round(N.height/2-F*0.95))}}function wE(N){return Math.max(48,Math.round(N*0.5625))}var Dq=5,TE=-1,CE=3,Eq=1;function jE(N,F,A,M,D,E){if(!A.mention)return;let $=F.top+$2(F.height,N.font),y=e0(N.font),Z=$-y.ascent-CE+TE,Y=y.ascent+y.descent+CE*2,X=Math.max(0,E-D);N.fillStyle=M.mentionBackground??M.inlineCodeBackground,$q(N,D,Z,X,Y,Dq),N.fillStyle=M.mentionText??M.linkText,N.fillText(`@${A.mention.name}`,D+V6,$+TE+Eq)}function $q(N,F,A,M,D,E){let $=Math.min(E,M/2,D/2);N.beginPath(),N.roundRect(F,A,M,D,$),N.fill()}var RE=4,yq=4,Zq=1.5,W8={bottomPadding:1,cornerRadius:0,horizontalPadding:1,topPadding:2,verticalNudge:-1},Yq=0.72,bE=2,fE=1.25,Xq=0.02;function mE(N,F,A,M,D,E,$,y){if(!A){N.fillStyle=E,N.fillText(F.text,M,D);return}let Z=A.inlines.filter((Y)=>Y.end>F.start&&Y.start<F.end);if(Z.length===0){N.fillStyle=E,N.fillText(F.text,M,D);return}for(let Y of Z){let X=Math.max(F.start,Y.start),Q=Math.min(F.end,Y.end);if(A.text.slice(X,Q).length===0)continue;let{left:J,right:V}=V2(F,M,X,Q),K=K1(F.font,Y.marks,Y.inlineCode);if(N.font=K,Y.kind==="image"){let q=Math.max(24,V-J);LE(N,F,Y,$,y,J,q);continue}if(Y.kind==="mention"){jE(N,F,Y,y,J,V);continue}if(Y.kind==="code"){O8(N,J,V,D,y.inlineCodeBackground,W8),uE(N,F,A.text,M,D,X,Q,y.inlineCodeText,{strikethrough:!1,underline:!1});continue}uE(N,F,A.text,M,D,X,Q,Y.link?y.linkText:E,{strikethrough:Y.marks.includes("strikethrough"),underline:Y.marks.includes("underline")||Boolean(Y.link)})}}function uE(N,F,A,M,D,E,$,y,Z){let Y=A.slice(E,$);if(Y.length===0)return;let{left:X,right:Q}=V2(F,M,E,$);if(N.fillStyle=y,N.fillText(Y,X,D),Z.strikethrough)N.fillRect(X,Hq(D,F.height,N.font),Math.max(bE,Q-X),fE);if(Z.underline)N.fillRect(X,_q(D,F.height,N.font),Math.max(bE,Q-X),fE)}function w8(N,F,A,M,D,E,$,y,Z){if(!A||E.length===0)return;let Y=vE(E,F.start,F.end);if(Y.length===0)return;let X=A.inlines.filter((Q)=>Q.end>F.start&&Q.start<F.end);for(let Q of X){if(!Qq(Q))continue;let S=Math.max(F.start,Q.start),J=Math.min(F.end,Q.end),V=A.text.slice(S,J);if(V.length===0)continue;let K=vE(Y,S,J);if(K.length===0)continue;let q=Sq(S,J,K),{left:U}=V2(F,M,S,J);N.font=UD(F.font,Q.marks);for(let z=0;z<q.length-1;z+=1){let G=q[z],H=q[z+1],B=Jq(K,G,H);if(!B||H<=G)continue;let{left:_,right:O}=V2(F,M,G,H);Vq(N,{baseTextColor:Z,decoration:B,decorationAnimationTime:y,height:F.height,left:_,phase:$,right:O,text:V,textBaseline:D,textLeft:U,top:F.top})}}}function Qq(N){return N.kind!=="image"&&N.kind!=="mention"&&N.kind!=="code"&&!N.link}function vE(N,F,A){return N.filter((M)=>M.endOffset>F&&M.startOffset<A)}function Sq(N,F,A){if(A.length===0)return[N,F];let M=new Set([N,F]);for(let D of A){if(D.endOffset<=N||D.startOffset>=F)continue;M.add(Math.max(N,D.startOffset)),M.add(Math.min(F,D.endOffset))}return[...M].sort((D,E)=>D-E)}function Jq(N,F,A){return N.find((M)=>M.startOffset<A&&M.endOffset>F)??null}function Vq(N,{baseTextColor:F,decoration:A,decorationAnimationTime:M,height:D,left:E,phase:$,right:y,text:Z,textBaseline:Y,textLeft:X,top:Q}){if($==="background"){if(!A.backgroundColor)return;qq(N,{color:A.backgroundColor,decorationAnimationTime:M,left:E,pulse:A.pulse===!0,right:y,textBaseline:Y});return}if(!A.color)return;IE(N,{color:Uq(A,M,F),eraseExistingGlyphs:!0,height:D,left:E,text:Z,textBaseline:Y,textLeft:X,top:Q,width:Math.max(0,y-E)})}function qq(N,{color:F,decorationAnimationTime:A,left:M,pulse:D,right:E,textBaseline:$}){if(!D){O8(N,M,E,$,F,W8);return}N.save(),N.globalAlpha*=H3(A,G3),O8(N,M,E,$,F,W8),N.restore()}function Uq(N,F,A){if(!N.pulse||!N.backgroundColor)return N.color??A;let D=(1-P8(F))*Yq;return Q2(N.color??A,A,D)}function O8(N,F,A,M,D,E){let $=Kq(N,F,A,M,E);if(N.fillStyle=D,E.cornerRadius<=0){N.fillRect($.left,$.top,$.width,$.height);return}zq(N,$.left,$.top,$.width,$.height,E.cornerRadius)}function Kq(N,F,A,M,D){let E=e0(N.font),$=F-D.horizontalPadding,y=A+D.horizontalPadding;return{height:E.ascent+E.descent+D.topPadding+D.bottomPadding,left:$,top:M-E.ascent-D.topPadding+D.verticalNudge,width:Math.max(0,y-$)}}function zq(N,F,A,M,D,E){if(M<=0||D<=0)return;N.beginPath(),N.roundRect(F,A,M,D,Math.min(E,M/2,D/2)),N.fill()}function kE(N,F,A,M,D,E,$){if(!A||E.length===0)return;let y=A.inlines.filter((Z)=>Z.end>F.start&&Z.start<F.end);for(let Z of y){if(Z.kind==="image"||Z.kind==="mention")continue;let Y=Math.max(F.start,Z.start),X=Math.min(F.end,Z.end),Q=A.text.slice(Y,X);if(Q.length===0)continue;let S=$9(Y,X,E).filter((K)=>Gq(A.text,Y,X,K));if(S.length<=2){if(!w5(E,Y,X))continue}let{left:J}=V2(F,M,Y,X),V=K1(F.font,Z.marks,Z.inlineCode);N.font=V;for(let K=0;K<S.length-1;K+=1){let q=S[K],U=S[K+1],z=w5(E,q,U);if(!z||U<=q)continue;let G=1-z.progress;if(G<=Xq)continue;let{left:H,right:B}=V2(F,M,q,U);IE(N,{alpha:G,color:$.insertHighlightText,height:F.height,left:H,text:Q,textBaseline:D,textLeft:J,top:F.top,width:Math.max(0,B-H)})}}}function Gq(N,F,A,M){if(M<=F||M>=A)return!0;let D=F;for(let E of p2(N.slice(F,A))){if(D+=E.length,D===M)return!0;if(D>M)return!1}return!1}function gE(N,F,A,M,D,E,$){if(!A||E.length===0)return;for(let y of E){if(y.startOffset<F.start||y.startOffset>F.end)continue;let Z=M+(b0(F,y.startOffset-F.start)-F.left);N.fillStyle=y9($,y),N.fillText(y.text,Z,D)}}function hE(N,F,A,M,D,E,$){if(!A||E.length===0)return;for(let y of E){if(y.offset<F.start||y.offset>=F.end)continue;let{left:Z,right:Y}=V2(F,M,y.offset,y.offset+1),X=Math.max(RE,(Y-Z)/2+RE+yq*y.progress),{ascent:Q,descent:S}=e0(F.font),J=D-Math.max(1,Q*0.42)+Math.max(0.5,S*0.15);N.strokeStyle=Z9(y,$),N.lineWidth=Zq,N.beginPath(),N.arc((Z+Y)/2,J,X,0,Math.PI*2),N.stroke()}}function Hq(N,F,A){let{ascent:M}=e0(A),D=N-$2(F,A);return Math.max(D+2,N-Math.round(M*0.32))}function _q(N,F,A){let{descent:M}=e0(A),D=Math.max(1,Math.round(Math.max(2,M)*0.35)),E=N+M-D,$=N-$2(F,A);return Math.min($+F-4,E)}function V2(N,F,A,M){return{left:F+(b0(N,A-N.start)-N.left),right:F+(b0(N,M-N.start)-N.left)}}function IE(N,{alpha:F=1,color:A,eraseExistingGlyphs:M=!1,height:D,left:E,text:$,textBaseline:y,textLeft:Z,top:Y,width:X}){if(X<=0||F<=0)return;if(N.save(),N.beginPath(),N.rect(E,Y,X,D),N.clip(),M)N.globalCompositeOperation="destination-out",N.fillText($,Z,y);N.globalCompositeOperation="source-over",N.globalAlpha*=F,N.fillStyle=A,N.fillText($,Z,y),N.restore()}var pE=new Map,xE=new Map;function L8(N,F,A,M){Bq({activeBlockId:M.activeBlockId,activeRegionId:M.activeRegionId,activeThreadIndex:M.activeThreadIndex,contentPulseTime:M.contentPulseTime,containerLineBounds:F.regionBounds,context:A,devicePixelRatio:M.devicePixelRatio,editorState:N,height:M.height,layout:F.layout,liveCommentRanges:M.liveCommentRanges,normalizedSelection:M.normalizedSelection,presenceActiveThreadColors:M.presenceActiveThreadColors??xE,now:M.now,resources:M.resources??{images:new Map},runtimeBlockMap:F.blockMap,textDecorations:M.textDecorations??pE,theme:M.theme,viewportTop:F.paintTop,width:M.width})}function T8(N,F,A,M){B8({context:A,devicePixelRatio:M.devicePixelRatio,editorState:N,height:M.height,layout:F.layout,normalizedSelection:M.normalizedSelection,presence:M.presence,showCaret:M.showCaret,theme:M.theme,viewportTop:F.paintTop,width:M.width})}function Bq({activeBlockId:N,activeRegionId:F,activeThreadIndex:A,containerLineBounds:M,context:D,devicePixelRatio:E,editorState:$,height:y,layout:Z,liveCommentRanges:Y,normalizedSelection:X,now:Q=wq(),contentPulseTime:S=Q,presenceActiveThreadColors:J=xE,resources:V,runtimeBlockMap:K,textDecorations:q=pE,theme:U,viewportTop:z,width:G}){D.save(),D.scale(E,E),D.clearRect(0,0,G,y),D.fillStyle=U.background,D.fillRect(0,0,G,y),D.textBaseline="alphabetic",D.translate(0,-z);let{endIndex:H,startIndex:B}=m1(Z,z,y),_=BE($,X),O=A9($,Q),w=M9($,Q),b=F9($,Q),L=E9($,Q),W=D9($,Q),v=UE(Z,$,N,B,H),g=SE(Z,$,K,B,H,G);for(let P=B;P<H;P+=1){let R=Z.lines[P];XE(D,R,K.get(R.blockId)??null,M.get(R.regionId)??null,$.documentIndex.tableCellIndex.get(R.regionId)??null,U,G)}let j=B6(Z,z,y);JE(D,Z,j.startIndex,j.endIndex,U,G),$E({activeBlockFlashes:O,activeBlockId:N,activeRegionId:F,context:D,editorState:$,endIndex:H,layout:Z,regionBounds:M,startIndex:B,theme:U,verticalBleed:z3});for(let P=B;P<H;P+=1){let R=Z.lines[P];Pq({activeBlockId:N,activeBlockFlashes:O,contentPulseTime:S,activeTextFades:w,activeTextHighlights:b,activeBlockPulses:L,activeTextPulses:W,activeThreadIndex:A,context:D,editorState:$,line:R,liveCommentRanges:Y,normalizedSelection:X,presenceActiveThreadColors:J,resources:V,runtimeBlockMap:K,selectionRegionOrderRange:_,textDecorations:q,theme:U,width:G})}VE(D,g,U),KE(D,v,U),D.restore()}function Pq({activeBlockId:N,activeBlockFlashes:F,contentPulseTime:A,activeTextFades:M,activeTextHighlights:D,activeBlockPulses:E,activeTextPulses:$,activeThreadIndex:y,context:Z,editorState:Y,line:X,liveCommentRanges:Q,normalizedSelection:S,presenceActiveThreadColors:J,resources:V,runtimeBlockMap:K,selectionRegionOrderRange:q,textDecorations:U,theme:z,width:G}){let H=K.get(X.blockId)??null,B=Y.documentIndex.blockIndex.get(X.blockId)?.path??null,_=Y.documentIndex.regionIndex.get(X.regionId)??null,O=_?.path??"",w=z1(Y,X.blockId,"listItem"),b=w?Z2(Y,w.id):null,L=w?E.get(w.path)??null:null,W=X.left+g0(Y,X),v=Wq(X),g=H?.type==="code"?z.codeText:Oq(H,z);Z.font=X.font,QE(Z,X,H,B,N,F,z,G);let j=U.size>0?U.get(O):null;if(j)w8(Z,X,_,W,v,j,"background",A,g);if(PE(Z,Y,X,S,q,z),WE(Z,Y,X,Q,y,J,A,z),_E(Z,X,b,W,v,g,z,L),mE(Z,X,_,W,v,g,V,z),j)w8(Z,X,_,W,v,j,"overlay",A,g);kE(Z,X,_,W,v,D.get(O)??[],z),gE(Z,X,_,W,v,M.get(O)??[],g),hE(Z,X,_,W,v,$.get(O)??[],z)}function Wq(N){return N.top+$2(N.height,N.font)}function Oq(N,F){switch(N?.type){case"heading":return F.headingText;case"blockquote":return F.blockquoteText;case"table":return F.headingText;default:return F.paragraphText}}function wq(){return performance.now()}function C8(N,F,A){if(A.length===0)return F.size===0?null:new Map;let M=N.documentIndex,D=new Set(M.regions.map((y)=>y.path)),E=new Map([...F].filter(([y])=>D.has(y))),$=E.size!==F.size;for(let y of A){let Z=new Set(M.roots[y.rootIndex]?.regions.map((X)=>X.path)??[]);for(let X of Z)E.delete(X);let Y=Lq(y.ranges.flatMap((X)=>{let Q=M.regionPathIndex.get(X.path);if(!Q||Q.rootIndex!==y.rootIndex)return[];return[{...X.backgroundColor&&{backgroundColor:X.backgroundColor},...X.color&&{color:X.color},...X.backgroundColor&&X.pulse&&{pulse:!0},endOffset:X.endOffset,path:X.path,startOffset:X.startOffset}]}));for(let[X,Q]of Y)E.set(X,Q);if(!Tq(F,E,Z))$=!0}return $?E:null}function Lq(N){let F=new Map;for(let A of N){let M=F.get(A.path);if(M)M.push(A);else F.set(A.path,[A])}for(let A of F.values())A.sort((M,D)=>M.startOffset-D.startOffset);return F}function Tq(N,F,A){for(let M of A)if(!Cq(N.get(M)??[],F.get(M)??[]))return!1;return!0}function Cq(N,F){if(N.length!==F.length)return!1;return N.every((A,M)=>{let D=F[M];return A.color===D.color&&A.backgroundColor===D.backgroundColor&&Boolean(A.backgroundColor&&A.pulse)===Boolean(D.backgroundColor&&D.pulse)&&A.endOffset===D.endOffset&&A.startOffset===D.startOffset})}function j8(N,F,A){if(A.size===0)return!1;let{endIndex:M,startIndex:D}=m1(F.layout,F.viewport.top,F.viewport.height);for(let E=D;E<M;E+=1){let $=F.layout.lines[E];if(!$)continue;if(G1(F,{bottom:$.top+$.height,top:$.top})!=="visible")continue;let y=N.documentIndex.regionIndex.get($.regionId)?.path??null;if((y?A.get(y):null)?.some((Y)=>jq(Y,$)))return!0}return!1}function jq(N,F){return N.pulse===!0&&Boolean(N.backgroundColor)&&N.endOffset>F.start&&N.startOffset<F.end}function lE(N,F,A){return pD(N,F,A,h0(N).liveRanges)}function R8(N,F,A){return xD(N,F,A,h0(N).liveRanges)}import{forwardRef as vq,createElement as mq}from"react";var _3=(...N)=>N.filter((F,A,M)=>{return Boolean(F)&&F.trim()!==""&&M.indexOf(F)===A}).join(" ").trim();var dE=(N)=>N.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var aE=(N)=>N.replace(/^([A-Z])|[\s-_]+(\w)/g,(F,A,M)=>M?M.toUpperCase():A.toLowerCase());var b8=(N)=>{let F=aE(N);return F.charAt(0).toUpperCase()+F.slice(1)};import{forwardRef as uq,createElement as sE}from"react";var B3={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var rE=(N)=>{for(let F in N)if(F.startsWith("aria-")||F==="role"||F==="title")return!0;return!1};import{createContext as Rq,useContext as bq,useMemo as _T,createElement as BT}from"react";var fq=Rq({});var cE=()=>bq(fq);var iE=uq(({color:N,size:F,strokeWidth:A,absoluteStrokeWidth:M,className:D="",children:E,iconNode:$,...y},Z)=>{let{size:Y=24,strokeWidth:X=2,absoluteStrokeWidth:Q=!1,color:S="currentColor",className:J=""}=cE()??{},V=M??Q?Number(A??X)*24/Number(F??Y):A??X;return sE("svg",{ref:Z,...B3,width:F??Y??B3.width,height:F??Y??B3.height,stroke:N??S,strokeWidth:V,className:_3("lucide",J,D),...!E&&!rE(y)&&{"aria-hidden":"true"},...y},[...$.map(([K,q])=>sE(K,q)),...Array.isArray(E)?E:[E]])});var k=(N,F)=>{let A=vq(({className:M,...D},E)=>mq(iE,{ref:E,iconNode:F,className:_3(`lucide-${dE(b8(N))}`,`lucide-${N}`,M),...D}));return A.displayName=b8(N),A};var kq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],h1=k("columns-2",kq);var gq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],I1=k("rows-3",gq);var hq=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],p1=k("send-horizontal",hq);var Iq=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],MF=k("arrow-down",Iq);var pq=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],DF=k("arrow-up",pq);var xq=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],EF=k("bold",xq);var lq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],q2=k("check",lq);var dq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],$F=k("chevron-down",dq);var aq=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],yF=k("code",aq);var rq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],ZF=k("heading-1",rq);var cq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],YF=k("heading-2",cq);var sq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],XF=k("heading-3",sq);var iq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],QF=k("heading-5",iq);var oq=[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]],SF=k("heading-4",oq);var nq=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]],JF=k("heading-6",nq);var tq=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],VF=k("heading",tq);var eq=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],qF=k("italic",eq);var NU=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],UF=k("list-ordered",NU);var FU=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],KF=k("list-todo",FU);var AU=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],zF=k("list",AU);var MU=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],GF=k("message-square-plus",MU);var DU=[["path",{d:"M5 12h14",key:"1ays0h"}]],HF=k("minus",DU);var EU=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],U2=k("pencil",EU);var $U=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ZN=k("plus",$U);var yU=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],_F=k("strikethrough",yU);var ZU=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],x1=k("table-2",ZU);var YU=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],BF=k("text-quote",YU);var XU=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],s0=k("trash-2",XU);var QU=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],PF=k("underline",QU);var SU=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],WF=k("x",SU);import{jsx as YN,jsxs as UU}from"react/jsx-runtime";function oE({insetX:N,insetY:F,onSelect:A,presence:M}){if(!M)return null;return YN("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${N}px`,top:`${F}px`},children:M.map((D)=>YN(JU,{onSelect:()=>A(D),presence:D},D.id))})}function JU({onSelect:N,presence:F}){let A=F.viewport,M=VU(F),D=A?.status==="above"?DF:MF,E=A!==null&&A.status!=="unresolved",$=A?.status==="above"||A?.status==="below";return UU("button",{"aria-label":qU(F),className:"documint-presence-indicator","data-status":A?.status??"unresolved",disabled:!E,onClick:E?N:void 0,style:{"--documint-presence-color":F.color??"var(--documint-leaf-accent)"},type:"button",children:[YN("span",{className:"documint-presence-indicator-avatar",children:F.avatarUrl?YN("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:F.avatarUrl}):M}),$?YN("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:YN(D,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3})}):null]})}function VU(N){return nE(N).charAt(0).toLocaleUpperCase()}function qU(N){let F=nE(N),A=N.viewport?.status??"unresolved";if(A==="above")return`${F} above viewport`;if(A==="below")return`${F} below viewport`;if(A==="unresolved")return`${F} unresolved`;return`${F} in viewport`}function nE(N){return(N.fullName??N.username).trim()||"Presence"}var s=`
29
+ `,XN="<ins>",OF="</ins>",QN=">",wF="```",P3=":::",W3="documint-comments";var TF="\\",w3="`",M$=":",LF=" ",u8="![",tE="@[",v8="[",m8="(",eE=")",N$=/[\p{L}\p{N}]/u,KU=/[A-Za-z]/,zU=/[-A-Za-z0-9_]/,O3=/\{width=([1-9]\d*)\}/y,GU=/\\([\\`*_[\]{}()#+\-.!~|@])/g,D$=/\\(.)/g,E$=[{delimiter:"**",mark:"bold",requireWordBoundary:!1},{delimiter:"~~",mark:"strikethrough",requireWordBoundary:!1},{delimiter:"*",mark:"italic",requireWordBoundary:!1},{delimiter:"_",mark:"italic",requireWordBoundary:!0}],HU=new Set(E$.map((N)=>N.delimiter[0]));function CF(N){return L3(N,0,N.length,[])}function L3(N,F,A,M){let D=[],E=F,$=F;while(E<A){let y=_U(N,E,A,M);if(y){let Z=Math.max($,E-(y.trimLeading??0));F$(D,N.slice($,Z),M),D.push(...y.nodes),E=y.end,$=E;continue}if(N[E]===TF){E+=Math.min(2,A-E);continue}E+=1}return F$(D,N.slice($,A),M),W0(D)}function _U(N,F,A,M){let D=N[F];switch(D){case M$:return BU(N,F,A);case"<":return wU(N,F,A)??PU(N,F,A,M)??WU(N,F,A);case TF:return LU(N,F,A);case s:return TU(N,F);case w3:return CU(N,F,A);case"!":return jU(N,F,A);case"@":return RU(N,F,A);case v8:return bU(N,F,A,M)}if(D!==void 0&&HU.has(D))return uU(N,F,A,M);return null}function BU(N,F,A){if(N[F]!==M$||!KU.test(N[F+1]??""))return null;let M=F+2;while(M<A&&zU.test(N[M]??""))M+=1;let D=A$(N,M,A,"[","]"),$=A$(N,D?.end??M,A,"{","}")?.end??D?.end??M;return{end:$,nodes:[$$("textDirective",N.slice(F,$))]}}function PU(N,F,A,M){if(!N.startsWith(XN,F))return null;let D=N.indexOf(OF,F+XN.length);if(D<0||D>=A)return null;return{end:D+OF.length,nodes:L3(N,F+XN.length,D,[...M,"underline"])}}function WU(N,F,A){if(N[F]!=="<")return null;let M=N.indexOf(">",F+1);if(M<0||M>=A)return null;return{end:M+1,nodes:[$$("html",N.slice(F,M+1))]}}var OU=/^<br\s*\/?>/i;function wU(N,F,A){if(N[F]!=="<")return null;let M=OU.exec(N.slice(F,A));if(!M)return null;let D=F+M[0].length;return{end:N[D]===s?D+1:D,nodes:[y1()]}}function LU(N,F,A){if(N[F]!==TF||N[F+1]!==s||F+1>=A)return null;return{end:F+2,nodes:[y1()]}}function TU(N,F){if(N[F]!==s||N[F-1]!==LF||N[F-2]!==LF)return null;let A=0;while(N[F-1-A]===LF)A+=1;return{end:F+1,nodes:[y1()],trimLeading:A}}function CU(N,F,A){if(N[F]!==w3)return null;let M=1;while(F+M<A&&N[F+M]===w3)M+=1;let D=w3.repeat(M),E=N.indexOf(D,F+M);if(E<0||E>=A)return null;return{end:E+M,nodes:[O1(N.slice(F+M,E))]}}function jU(N,F,A){if(!N.startsWith(u8,F))return null;let M=g8(N,F+1,A);if(M<0||N[M+1]!==m8)return null;let D=k8(N,M+1,A);if(!D)return null;let E=fU(N,D.end,A);return{end:E?.end??D.end,nodes:[w1({alt:h8(N.slice(F+u8.length,M)),title:D.title,url:D.url,width:E?.width??null})]}}function RU(N,F,A){if(!N.startsWith(tE,F))return null;let M=g8(N,F+1,A);if(M<0||N[M+1]!==m8)return null;let D=k8(N,M+1,A);if(!D||D.title!==null)return null;return{end:D.end,nodes:[C2({name:h8(N.slice(F+tE.length,M)),userId:D.url})]}}function bU(N,F,A,M){if(N[F]!==v8||N.startsWith(u8,F-1))return null;let D=g8(N,F,A);if(D<0||N[D+1]!==m8)return null;let E=k8(N,D+1,A);if(!E)return null;return{end:E.end,nodes:[o1({children:L3(N,F+v8.length,D,M),title:E.title,url:E.url})]}}function k8(N,F,A){let M=f8(N,F+1,A),D=M;while(D<A&&N[D]!==eE&&N[D]!==LF){if(N[D]===TF){D+=2;continue}D+=1}if(D===M)return null;let E=vU(N.slice(M,D));M=f8(N,D,A);let $=null;if(M<A&&N[M]==='"'){let y=T3(N,'"',M+1,A);if(y<0)return null;$=N.slice(M+1,y).replace(D$,"$1"),M=f8(N,y+1,A)}if(N[M]!==eE)return null;return{end:M+1,title:$,url:E}}function fU(N,F,A){O3.lastIndex=F;let M=O3.exec(N);if(!M||O3.lastIndex>A)return null;return{end:O3.lastIndex,width:Number(M[1])}}function uU(N,F,A,M){for(let D of E$){if(!N.startsWith(D.delimiter,F))continue;let E=T3(N,D.delimiter,F+D.delimiter.length,A);if(E<0)continue;if(D.requireWordBoundary){let y=F>0?N[F-1]:"",Z=N[E+D.delimiter.length]??"";if(N$.test(y)||N$.test(Z))continue}let $=F+D.delimiter.length;return{end:E+D.delimiter.length,nodes:L3(N,$,E,[...M,D.mark])}}return null}function F$(N,F,A){if(F.length===0)return;N.push(u0(h8(F),A))}function A$(N,F,A,M,D){if(N[F]!==M)return null;let E=T3(N,D,F+1,A);if(E<0)return null;return{end:E+1}}function g8(N,F,A){return T3(N,"]",F+1,A)}function T3(N,F,A,M){for(let D=A;D<M;D+=1){if(N[D]===TF){D+=1;continue}if(N.startsWith(F,D))return D}return-1}function f8(N,F,A){while(F<A&&N[F]===LF)F+=1;return F}function h8(N){return N.replace(GU,"$1")}function vU(N){return N.replace(D$,"$1")}function $$(N,F){return cF({originalType:N,source:F})}var mU=/^:?-+:?$/;function Z$(N,F){let A=_0(N),M=p8(N,1),D=f0(A,F),E=f0(M,F);if(!y$(D)||!I8(E))return null;let $=[C3(D)],y=kU(E);N.index+=2;while(N.index<N.lines.length){let Z=_0(N),Y=f0(Z,F);if(l1(Z)||!y$(Y))break;$.push(C3(Y)),N.index+=1}return e1({align:y,rows:$.map((Z)=>j2(Z.map((Y)=>L1(CF(Y)))))})}function I8(N){let F=C3(N);return F.length>0&&F.every((A)=>mU.test(A.trim()))}function y$(N){let F=N.trim();return F.startsWith("|")&&F.endsWith("|")}function kU(N){return C3(N).map((F)=>{let A=F.trim();if(A.startsWith(":")&&A.endsWith(":"))return"center";if(A.startsWith(":"))return"left";if(A.endsWith(":"))return"right";return null})}function C3(N){let F=N.trim();if(!F.startsWith("|")||!F.endsWith("|"))return[];return F.slice(1,-1).split("|").map((A)=>A.trim())}var gU=3,Y$=/^(#{1,6})\s+(.*)$/,hU=/\s+#+\s*$/u,IU=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,pU=/^\d+\.$/,xU=/^\[( |x|X)\](?:\s|$)/,X$=/^```([^\s`]*)?(?:\s+(.*))?$/,Q$=/^:::([A-Za-z][-\w]*)(.*)$/,lU=[/^(\*\s*){3,}$/,/^(-\s*){3,}$/,/^(_\s*){3,}$/];function R3(N,F,A){let M=[];while(N.index<N.lines.length){let D=_0(N);if(N.index===N.lines.length-1&&D==="")break;if(l1(D)){N.index+=1;continue}if(SN(D)>F+gU)break;let E=dU(N,F,A);if(!E)break;M.push(E)}return M}function dU(N,F,A){return aU(N,F,A)??rU(N,F)??cU(N,F)??iU(N,F)??oU(N,F)??Z$(N,F)??nU(N,F,A)??eU(N,F)??NK(N,F)}function aU(N,F,A){let M=_0(N);if(!f0(M,F).startsWith(QN))return null;let D=[];while(N.index<N.lines.length){let E=_0(N),$=SN(E);if(l1(E)){D.push(""),N.index+=1;continue}if($<F)break;let y=f0(E,F);if(!y.startsWith(QN))break;let Z=y.slice(1);if(Z.startsWith(" "))Z=Z.slice(1);D.push(Z),N.index+=1}return d0(R3({index:0,lines:D},0,A))}function rU(N,F){let A=_0(N),M=f0(A,F),D=X$.exec(M);if(!D)return null;N.index+=1;let E=[];while(N.index<N.lines.length){let $=_0(N),y=f0($,F);if(y.trim()===wF){N.index+=1;break}E.push(y),N.index+=1}return Y4({language:D[1]?D[1]:null,meta:D[2]?D[2]:null,source:E.join(s)})}function cU(N,F){let A=_0(N),M=f0(A,F),D=Q$.exec(M);if(!D)return null;let E=D[1],$=[];N.index+=1;while(N.index<N.lines.length){let y=_0(N),Z=f0(y,F);if(Z.trim()===P3){N.index+=1;break}$.push(Z),N.index+=1}return NM({attributes:sU(D[2]??""),body:$.join(s),name:E})}function sU(N){let F=N.trim();if(F.startsWith("{")&&F.endsWith("}"))return F.slice(1,-1);return F}function iU(N,F){let A=_0(N),M=Y$.exec(f0(A,F));if(!M)return null;return N.index+=1,rF({children:CF(M[2].replace(hU,"")),depth:M[1].length})}function oU(N,F){let A=f0(_0(N),F).trim();if(!S$(A))return null;return N.index+=1,sF()}function nU(N,F,A){let M=j3(_0(N),F);if(!M)return null;let D=[],E=!1;while(N.index<N.lines.length){let $=_0(N),y=j3($,F);if(!y||y.ordered!==M.ordered)break;N.index+=1;let Z=[y.content],Y=!1;while(N.index<N.lines.length){let X=_0(N),Q=SN(X);if(l1(X)){let S=MK(N.lines,N.index+1);if(S<0||SN(N.lines[S]??"")<=F)break;Y=!0,Z.push(""),N.index+=1;continue}if(Q<y.contentIndent)break;if(Q===F&&j3(X,F))break;Z.push(AK(X,y.contentIndent)),N.index+=1}E||=Y,D.push(n1({checked:y.checked,children:tU(Z,A),spread:Y}))}return t1({items:D,ordered:M.ordered,spread:E,start:M.ordered&&A.preserveOrderedListStart?M.start??1:null})}function j3(N,F){let A=IU.exec(N);if(!A||A[1].length!==F)return null;let M=A[2],D=pU.test(M),E=D?Number(M.slice(0,-1)):null,$=A[3]??"",y=null;if(xU.test($)){if(y=$[1]==="x"||$[1]==="X",$=$.slice(3),$.startsWith(" "))$=$.slice(1)}let Z=A[0].length-A[1].length-A[2].length-$.length;return{checked:y,content:$,contentIndent:F+A[2].length+Z,ordered:D,start:E}}function tU(N,F){let A=R3({index:0,lines:N},0,F);if(A.length>0)return A;return[$1([])]}function eU(N,F){let A=f0(_0(N),F).trim();if(!J$(A))return null;return N.index+=1,X4({originalType:"html",source:A})}function NK(N,F){let A=[];while(N.index<N.lines.length){let M=_0(N),D=SN(M);if(l1(M))break;if(D<F)break;let E=f0(M,F);if(A.length>0&&FK(M,E,F))break;A.push(E),N.index+=1}return $1(CF(A.join(s)))}function FK(N,F,A){let M=F.trim();return F.startsWith(QN)||X$.test(F)||Q$.test(F)||Y$.test(F)||S$(M)||I8(F)||j3(N,A)!==null||J$(M)}function SN(N){let F=0;while(F<N.length&&N[F]===" ")F+=1;return F}function AK(N,F){let A=SN(N);if(A>=F)return N.slice(F);return N.trim()===""?"":N.slice(Math.min(A,F))}function MK(N,F){for(let A=F;A<N.length;A+=1)if(!l1(N[A]??""))return A;return-1}function S$(N){return lU.some((F)=>F.test(N))}function J$(N){return N.startsWith("<")&&N.endsWith(">")}function q$(N){let F=N.at(-1),A=F&&V$(F)?F:null;return{blocks:N.filter((D)=>!V$(D)),comments:A?DK(A.body):[]}}function DK(N){let F;try{F=JSON.parse(N)}catch{return[]}if(!Array.isArray(F))return[];return F.flatMap((A)=>{let M=w4(A);return M?[M]:[]})}function V$(N){return N.type==="directive"&&N.name===W3}var U$="---";function jF(N,F={}){let M={index:0,lines:N.replace(/\r\n/g,s).split(s)},D=EK(M),E=R3(M,0,F),{comments:$,blocks:y}=q$(E);return v2(y,$,D)}function EK(N){if(N.lines[0]!==U$)return;for(let F=1;F<N.lines.length;F+=1)if(N.lines[F]===U$){let A=N.lines.slice(0,F+1).join(s);return N.index=F+1,A}return}function _0(N){return p8(N,0)}function p8(N,F){return N.lines[N.index+F]??""}function l1(N){return N.trim()===""}function f0(N,F){return N.slice(F)}var $K=/([\\`*_[\]])/g,yK=/([\\)&])/g,ZK=/(["\\])/g;function J1(N){let F=W0(N);return F.map((A,M)=>YK(A,F[M+1])).join("")}function YK(N,F){switch(N.type){case"lineBreak":return"<br>";case"image":return SK(N);case"mention":return JK(N);case"code":return QK(N.code);case"link":return VK(N);case"text":return XK(x8(N.text,F),N.marks);case"raw":return N.source}}function XK(N,F){return F.reduce((A,M)=>{switch(M){case"bold":return`**${A}**`;case"italic":return`*${A}*`;case"strikethrough":return`~~${A}~~`;case"underline":return`${XN}${A}${OF}`}},N)}function QK(N){let F=0,A=0;for(let $ of N){if($==="`"){if(A+=1,A>F)F=A;continue}A=0}let M=F>0?F+1:1,D="`".repeat(M),E=N.startsWith("`")||N.endsWith("`")?` ${N} `:N;return`${D}${E}${D}`}function SK(N){let F=x8(N.alt??""),A=K$(N.url,N.title),M=N.width?`{width=${N.width}}`:"";return`![${F}]${A}${M}`}function JK(N){return`@[${x8(N.name)}](${z$(N.userId)})`}function VK(N){return`[${J1(N.children)}]${K$(N.url,N.title)}`}function K$(N,F){return`(${z$(N)}${qK(F)})`}function x8(N,F){let A=N.replace($K,"\\$1").replace(/@(?=\[)/g,"\\@");return F?.type==="link"&&A.endsWith("@")?`${A.slice(0,-1)}\\@`:A}function z$(N){return N.replace(yK,"\\$1")}function qK(N){return N?` "${N.replace(ZK,"\\$1")}"`:""}var H$=3;function _$(N,F,A){let M=N.rows.map((X)=>X.cells.map((Q)=>J1(Q.children))),D=Math.max(1,...M.map((X)=>X.length)),E=M[0]??[],$=Array.from({length:D},(X,Q)=>Math.max(GK(N.align[Q]),...A.padTableColumns?M.map((S)=>S[Q]?.length??0):[E[Q]?.length??0])),y=UK($,N.align,F),Z=G$(E,$,N.align,F,A),Y=M.slice(1).map((X)=>G$(X,$,N.align,F,A));return[Z??KK($,F),y,...Y].join(s)}function G$(N,F,A,M,D){let E=F.map(($,y)=>{let Z=N[y]??"";if(!D.padTableColumns)return Z;return HK(Z,$,A[y])});return`${" ".repeat(M)}| ${E.join(" | ")} |`}function UK(N,F,A){let M=N.map((D,E)=>zK(F[E],D));return`${" ".repeat(A)}| ${M.join(" | ")} |`}function KK(N,F){return`${" ".repeat(F)}| ${N.map((A)=>"".padEnd(A," ")).join(" | ")} |`}function zK(N,F){let A=B$(N),M=Math.max(H$,F-A),D="-".repeat(M);switch(N){case"center":return`:${D}:`;case"left":return`:${D}`;case"right":return`${D}:`;default:return D}}function GK(N){return H$+B$(N)}function B$(N){if(N==="center")return 2;return N?1:0}function HK(N,F,A){if(A==="right")return N.padStart(F," ");return N.padEnd(F," ")}var K2=`
30
+
31
+ `,_K="-",BK=".",PK="---",WK="&#x20;";function RF(N,F={}){return N.map((A)=>b3(A,0,F)).join(K2)}function b3(N,F,A){let M=z2(F);switch(N.type){case"blockquote":return OK(N,F,A);case"code":return wK(N,F);case"directive":return LK(N,F);case"heading":return P$(N,F);case"list":return TK(N,F,A);case"listItem":return W$(N,F,!1,1,A);case"paragraph":return`${M}${l8(J1(N.children))}`;case"table":return _$(N,F,A);case"divider":return`${M}${PK}`;case"raw":return F===0?N.source:O$(N.source,F)}}function OK(N,F,A){let M=N.children.map((E)=>b3(E,0,A)).join(K2),D=z2(F);return M.split(s).map((E)=>`${D}${QN}${E.length>0?` ${E}`:""}`).join(s)}function wK(N,F){let A=[N.language??"",N.meta??""].filter(Boolean).join(" ").trim(),M=z2(F),D=`${M}${wF}${A?A:""}`,E=N.source.length>0?N.source.split(s).map(($)=>`${M}${$}`).join(s):M;return`${D}${s}${E}${s}${M}${wF}`}function LK(N,F){let A=f3(N);return F===0?A:O$(A,F)}function f3(N){let F=N.attributes?`{${N.attributes}}`:"";return`:::${N.name}${F}${s}${N.body}${s}${P3}`}function P$(N,F){let A=l8(J1(N.children)),M=`${z2(F)}${"#".repeat(N.depth)}`;return A.length>0?`${M} ${A}`:M}function TK(N,F,A){let M=N.start??1;return N.items.map((D)=>W$(D,F,N.ordered,M,A)).join(N.spread?K2:s)}function W$(N,F,A,M,D){let E=A?`${M}${BK}`:_K,$=N.checked===null?"":`[${N.checked?"x":" "}] `,y=`${z2(F)}${E} ${$}`,Z=F+E.length+1,Y=N.children;if(Y.length===0)return $.length>0?y:y.trimEnd();let[X,...Q]=Y,S=CK(X,y,$.length>0,D),J=Q.map((V)=>b3(V,Z,D)).join(N.spread?K2:s);if(!J)return S;return`${S}${N.spread?K2:s}${J}`}function CK(N,F,A,M){switch(N.type){case"paragraph":{let D=l8(J1(N.children));if(D.length===0)return A?F:F.trimEnd();return`${F}${D}`}case"heading":return`${F}${P$(N,0)}`;case"directive":case"raw":{let D=N.type==="directive"?f3(N):N.source,[E,...$]=D.split(s);return[F+E,...$.map((y)=>`${z2(F.length)}${y}`)].join(s)}default:{let D=F.length;return`${F.trimEnd()}${s}${b3(N,D,M)}`}}}function l8(N){return N.replace(/^ +/gm,(F)=>WK.repeat(F.length))}function z2(N){return" ".repeat(N)}function O$(N,F){let A=z2(F);return N.split(s).map((M)=>`${A}${M}`).join(s)}function u3(N,F={}){if(N.blocks.length===0&&N.comments.length===0&&N.frontMatter===void 0)return"";let A=[];if(N.frontMatter!==void 0)A.push(N.frontMatter);if(N.blocks.length>0)A.push(RF(N.blocks,F));if(N.comments.length>0)A.push(jK(N.comments));let M=A.join(K2);return M.endsWith(s)?M:`${M}${s}`}function jK(N){return f3({attributes:"",body:JSON.stringify(N.map(RK),null,2),name:W3})}function RK({id:N,...F}){return F}function d8(N){if(N.length===0)return{kind:"text",text:""};let{blocks:F}=jF(N);if(tF(F))return{kind:"text",text:F[0]?.plainText??""};if(F.length===1&&F[0]?.type==="paragraph")return{kind:"inlines",inlines:F[0].children};return{kind:"blocks",blocks:F}}function G2(N){switch(N.kind){case"text":return N.text;case"inlines":return J1(N.inlines);case"blocks":return RF(N.blocks)}}import{createContext as bK,useContext as fK}from"react";import{createPortal as uK}from"react-dom";import{jsx as C$}from"react/jsx-runtime";var w$=bK(void 0);function L$({children:N,themeStyles:F}){return C$(w$.Provider,{value:F,children:N})}function T$({children:N}){let F=fK(w$);if(typeof document>"u")return null;return uK(C$("div",{className:"documint-overlay",style:{display:"contents",...F},children:N}),document.body)}import{useEffect as c3,useRef as Oy,useState as _2}from"react";function H2(N,F){return Object.is(N,F)}function a8(N){return(F,A)=>{if(F===A)return!0;if(!F||!A)return!1;return m3(N(F),N(A))}}function v3(N){return(F,A)=>{if(F===A)return!0;if(F.length!==A.length)return!1;return F.every((M,D)=>N(M,A[D]))}}function j$(N,F){return N.regionId===F.regionId&&N.offset===F.offset}function R$(N,F){return N.collapsed===F.collapsed&&j$(N.start,F.start)&&j$(N.end,F.end)}function b$(N,F){return vK(N.block,F.block)&&mK(N.span,F.span)}function f$(N,F){return kK(N.threads,F.threads)&&gK(N.liveRanges,F.liveRanges)}function u$(N,F){return m3(N,F)}function vK(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.blockId===F.blockId&&N.depth===F.depth&&N.nodeType===F.nodeType&&N.text===F.text}function mK(N,F){if(N===F)return!0;if(N.kind!==F.kind)return!1;switch(N.kind){case"link":return F.kind==="link"&&N.url===F.url;case"marks":return F.kind==="marks"&&m3(N.marks,F.marks);case"none":return!0}return!1}function kK(N,F){return m3(N,F)}function gK(N,F){if(N===F)return!0;if(N.length!==F.length)return!1;return N.every((A,M)=>{let D=F[M];return A.endOffset===D.endOffset&&A.regionId===D.regionId&&A.resolved===D.resolved&&A.startOffset===D.startOffset&&A.threadIndex===D.threadIndex})}function m3(N,F){if(N===F)return!0;if(N.length!==F.length)return!1;return N.every((A,M)=>Object.is(A,F[M]))}function v$(N,F,A){return hK(N,F,A)}function hK(N,F,A){let M=N.documentIndex!==F.documentIndex;return{previous:N,next:F,source:A==="external"?"external":"local",reason:A,documentChanged:M,changedRootIndexes:M?IK(N,F):[],animationsChanged:N.animations!==F.animations&&F.animations.length>0}}function IK(N,F){let A=N.documentIndex.document.blocks,M=F.documentIndex.document.blocks;if(A.length!==M.length)return M.map((D,E)=>E);return M.flatMap((D,E)=>D===A[E]?[]:[E])}function m$(N){let F=N,A=0,M=new Set,D=(E,$)=>{if(!E||E===F)return null;let Z=v$(F,E,$);F=E,A+=1;for(let Y of M)Y(Z);return Z};return{getVersion:()=>A,getState:()=>F,apply(E){return D(E,"command")},command(E,...$){return D(E(F,...$),"command")},replace(E,$="external"){return D(E,$)},subscribe(E){return M.add(E),()=>{M.delete(E)}},subscribeValue(E,$,y=H2){let Z=E(F),Y=(X)=>{let Q=E(X.next);if(y(Z,Q))return;Z=Q,$()};return M.add(Y),()=>{M.delete(Y)}}}}function k$(){let N=null,F=null,A=null,M=new Set,D=(E)=>{if(N=E,F===E)return;F=E;for(let $ of M)$()};return{get(){if(N)return N;if(!A)throw Error("Viewport resolver has not been registered.");return N=A(),N},invalidate(){N=null},peek(){return N},observeViewport(E){D(E)},peekPublishedViewport(){return F},setViewportResolver(E){A=E},subscribe(E){return M.add(E),()=>{M.delete(E)}}}}import{createContext as pK,useCallback as r8,useContext as xK,useSyncExternalStore as lK}from"react";import{jsx as dK}from"react/jsx-runtime";var g$=pK(null);function c8({children:N,store:F}){return dK(g$.Provider,{value:F,children:N})}function x0(){let N=xK(g$);if(!N)throw Error("Documint store is unavailable outside DocumintStoreProvider.");return N}function h(N){let F=x0().editor;return r8((...A)=>F.command(N,...A),[F,N])}function e(N,...F){let A=x0(),M=r8((E)=>N.subscribe(A,E,...F),[A,N,...F]),D=r8(()=>N.read(A,...F),[A,N,...F]);return lK(M,D,D)}function h$(N){if(!N?.length)return[];return N.map((F)=>({trigger:F.trigger,items:[...F.items].sort((A,M)=>A.label.localeCompare(M.label,void 0,{sensitivity:"base"}))}))}function I$(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.trigger===F.trigger&&N.items.length===F.items.length&&N.items.every((A,M)=>p$(A,F.items[M]))}function p$(N,F){return N.id===F.id&&N.icon===F.icon&&N.insertText===F.insertText&&N.kind===F.kind&&N.label===F.label}function x$(N,F){return N.length===F.length&&N.every((A,M)=>p$(A,F[M]))}function g3(N,F,A){for(let M=F-1;M>=0;M-=1){let D=N[M];if(k3(D))return null;let E=A.find((y)=>y.trigger===D);if(!E)continue;if(M>0&&!k3(N[M-1]))return null;let $=N.slice(M+1,F);return{trigger:E.trigger,query:$,triggerStart:M,caret:F,matches:aK(E.items,$)}}return null}function aK(N,F){if(!F)return N.slice(0,50);let A=F.toLowerCase(),M=[];for(let D of N)if(D.label.toLowerCase().includes(A)){if(M.push(D),M.length>=50)break}return M}function l$(N,F,A){let M=s8(F,A),D=N.slice(0,F.triggerStart),E=N.slice(F.caret);return{caret:F.triggerStart+M.length,value:D+M+E}}function s8(N,F){return F.insertText??`${N.trigger}${F.label} `}function h3(N,F){if(!F?.length||!F.some(($)=>N.includes($.trigger)))return[{kind:"text",text:N}];let A=new Map;for(let $ of F){let y=[...$.items].sort((Z,Y)=>Y.label.length-Z.label.length);A.set($.trigger,y)}let M=[],D=0,E=0;while(D<N.length){let $=N[D],y=A.get($);if(y!==void 0&&(D===0||k3(N[D-1]))){let Y=y.find((X)=>{if(!N.startsWith(X.label,D+1))return!1;return rK(N[D+1+X.label.length])});if(Y){if(D>E)M.push({kind:"text",text:N.slice(E,D)});M.push({kind:"token",trigger:$,label:Y.label,id:Y.id}),D+=1+Y.label.length,E=D;continue}}D+=1}if(E<N.length)M.push({kind:"text",text:N.slice(E)});return M}function k3(N){return N===void 0||N===" "||N===`
32
+ `||N==="\t"}function rK(N){return N===void 0||k3(N)||!/[\p{L}\p{N}_]/u.test(N)}function d$(N,F){let A=g6(N);if(!A)return null;let M=g3(A.text,A.offset,F??[]);return M?{...M,regionId:A.regionId}:null}function a$(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.regionId===F.regionId&&N.trigger===F.trigger&&N.query===F.query&&N.triggerStart===F.triggerStart&&N.caret===F.caret&&x$(N.matches,F.matches)}function r$(N,F){let A={endOffset:F.caret,regionId:F.regionId,startOffset:F.triggerStart};if(cK(N,F))return{kind:"mention",name:N.label,target:A,trailingText:" ",userId:N.id};return{endOffset:F.caret,kind:"text",startOffset:F.triggerStart,text:s8(F,N)}}function cK(N,F){return Boolean(N.id)&&(N.kind==="mention"||F.trigger==="@")}var c$=[["100","💯"],["airplane","✈️"],["alarm","⏰"],["angry","😠"],["astonished","😲"],["baby","👶"],["balloon","🎈"],["beer","🍺"],["birthday","🎂"],["blush","😊"],["bomb","💣"],["book","📚"],["boom","💥"],["broken_heart","💔"],["calendar","📅"],["camera","📷"],["cat","😺"],["check","✅"],["clap","👏"],["cold_sweat","😰"],["confetti_ball","🎊"],["confused","😕"],["cool","😎"],["cry","😢"],["disappointed","😞"],["dizzy","💫"],["dog","🐶"],["drooling","🤤"],["eggplant","🍆"],["eyes","👀"],["facepalm","🤦"],["fire","🔥"],["flushed","😳"],["ghost","👻"],["gift","🎁"],["grin","😁"],["grinning","😀"],["halo","😇"],["handshake","🤝"],["heart","❤️"],["heart_eyes","😍"],["hug","🤗"],["joy","😂"],["kiss","😘"],["laughing","😆"],["light_bulb","💡"],["loudspeaker","📢"],["love_letter","💌"],["melting","🫠"],["mind_blown","🤯"],["money_mouth","🤑"],["monocle","🧐"],["muscle","💪"],["nauseated","🤢"],["nerd","🤓"],["neutral","😐"],["ok_hand","👌"],["partying","🥳"],["pensive","😔"],["pizza","🍕"],["pleading","🥺"],["poop","💩"],["pray","🙏"],["raised_hands","🙌"],["relieved","😌"],["rocket","🚀"],["rofl","🤣"],["rolling_eyes","🙄"],["rose","🌹"],["scream","😱"],["see_no_evil","🙈"],["shushing","🤫"],["sleeping","😴"],["slightly_smiling","🙂"],["smile","😄"],["smiley","😃"],["smirk","😏"],["sob","😭"],["sparkles","✨"],["star","⭐"],["star_struck","🤩"],["sweat_smile","😅"],["tada","🎉"],["thinking","🤔"],["thumbs_down","👎"],["thumbs_up","👍"],["tired","😫"],["triumph","😤"],["unamused","😒"],["upside_down","🙃"],["warning","⚠️"],["wave","👋"],["weary","😩"],["wink","😉"],["woozy","🥴"],["writing","✍️"],["yawn","🥱"],["yum","😋"],["zany","🤪"],["zipper_mouth","🤐"]];var I3={trigger:":",items:c$.map(iK)};function iK(N){if(N.length!==2)throw Error("Emoji completion rows must be [label, value] tuples.");let[F,A]=N;return{label:F,icon:A,insertText:A}}function i8(N){if(!N?.length)return null;return{trigger:"@",items:N.map((F)=>({id:F.id,kind:"mention",label:F.fullName??F.username})).sort((F,A)=>F.label.localeCompare(A.label,void 0,{sensitivity:"base"}))}}function bF(N,F){return N.anchor.regionId===F.anchor.regionId&&N.anchor.offset===F.anchor.offset&&N.leftOverride===F.leftOverride&&N.paddingY===F.paddingY}function o8(N,F,A){if(!N||N.kind==="task-toggle")return null;if(N.commentThreadIndex!==null){let M=F[N.commentThreadIndex]??null,D=A.find((E)=>E.threadIndex===N.commentThreadIndex);if(!M||!D)return null;return{anchor:{regionId:D.regionId,offset:D.startOffset},animateInitialComment:!1,kind:"thread",link:N.kind==="link"?{title:N.title,url:N.url}:null,resolved:j1(M),thread:M,threadIndex:N.commentThreadIndex}}if(N.kind!=="link")return null;return{anchor:{regionId:N.regionId,offset:N.startOffset},endOffset:N.endOffset,kind:"link",regionId:N.regionId,startOffset:N.startOffset,title:N.title,url:N.url}}function l0(N,F,A=H2){return i0(N,(M,D,...E)=>F(M,...E),A)}function i$(N){let F=Object.entries(N),A=F.map(([,M])=>M);return l0(A,(M,...D)=>{let E={};for(let $=0;$<F.length;$++){let[y]=F[$];E[y]=D[$]}return E},oK)}function i0(N,F,A=H2){let M=new WeakMap,D=(E,...$)=>{let y=N.map((Q)=>Q.read(E)),Z=M.get(E);if(Z&&s$(Z.depValues,y)&&s$(Z.params,$))return Z.value;let Y=F(E,$,...y),X=Z&&A(Z.value,Y)?Z.value:Y;return M.set(E,{depValues:y,params:$,value:X}),X};return{read:D,subscribe(E,$,...y){let Z=D(E,...y),Y=()=>{let Q=D(E,...y);if(A(Z,Q))return;Z=Q,$()},X=N.map((Q)=>Q.subscribe(E,Y));return()=>{for(let Q of X)Q()}}}}function oK(N,F){if(N===F)return!0;let A=Object.keys(N),M=Object.keys(F);if(A.length!==M.length)return!1;return A.every((D)=>Object.is(N[D],F[D]))}function s$(N,F){return N.length===F.length&&N.every((A,M)=>Object.is(A,F[M]))}function n8({read:N,subscribe:F}){return{read:N,subscribe:F}}function p3(N,F=H2){return n8({read:(A)=>N(A.editor.getState()),subscribe:(A,M)=>A.editor.subscribeValue(N,M,F)})}var M1=n8({read:(N)=>N.viewport.peekPublishedViewport(),subscribe:(N,F)=>N.viewport.subscribe(F)});var nK=(N)=>N,K0=p3(nK),fF=p3((N)=>N.documentIndex),t8=p3((N)=>N.documentIndex.imageUrls);var tK=a8((N)=>[N.regionId,N.startOffset,N.endOffset]),eK=a8((N)=>[N.start.left,N.start.top,N.end.left,N.end.top]);function o$(N,F){return N.code===F.code&&u$(N.marks,F.marks)}var JN=l0([K0],(N,F)=>h0(F),f$),e8=l0([JN],(N,F)=>F.threads,v3(Object.is)),n$=l0([JN],(N,F)=>F.liveRanges,Jz),D1=l0([K0],(N,F)=>Z0(F),R$),t$=l0([K0],(N,F)=>t2(F),tK),e$=l0([K0],(N,F)=>x6(F),o$),Ny=l0([K0,D1,M1],(N,F,A,M)=>{if(!M)return null;return Mz(F,M,A)},eK),NA=i$({formatting:e$,handles:Ny,normalized:D1,range:t$,viewport:M1}),FA=i0([t$,e$,Ny,e8],(N,[F],A,M,D,E)=>{return $z({formatting:M,handles:D,promotedThread:F,selectionRange:A,threads:E})},yz),AA=i0([K0,D1,M1,e8,n$],(N,[F],A,M,D,E,$)=>{if(!D)return null;return Zz({isEditable:F,liveRanges:$,normalizedSelection:M,state:A,threads:E,viewport:D})},Sz),MA=l0([K0,D1,M1],(N,F,A,M)=>{if(!M)return!0;let D=u6(F,M,A.end);return D!=="above"&&D!=="below"}),DA=l0([K0,D1,M1],(N,F,A,M)=>{if(!M)return null;return J5(F,M,A.end)},Vz),EA=i0([K0],(N,[F],A)=>{return d$(A,F)},a$),$A=i0([],(N,[F])=>{let A=i8(F);return A?[A,I3]:[I3]},Nz);function Nz(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.length===F.length&&N.every((A,M)=>I$(A,F[M]))}var yA=i0([K0,M1,e8,n$],(N,[F],A,M,D,E)=>{let $=F?.kind==="link"&&M?R8(A,M,{regionId:F.regionId,offset:qz(F)}):F,y=o8($,D,E);return{cursor:F?.kind==="task-toggle"||y?.kind==="link"?"pointer":"text",leaf:y}},Uz),ZA=l0([K0],(N,F)=>h6(F),b$),YA=i0([K0,D1,M1],(N,[F],A,M,D)=>{if(!F||!D)return null;return Fz(A,D,M,F)},Az);function Fz(N,F,A,M){if(!A.collapsed)return null;let D=I6(N);if(!D)return null;let E=kN(N,F,M,D),$=D.image?M.images.get(D.image.url)?.intrinsicWidth??null:null;return E?{bounds:E,inline:D,maxWidth:$}:null}function Az(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.maxWidth===F.maxWidth&&N.bounds.left===F.bounds.left&&N.bounds.top===F.bounds.top&&N.bounds.width===F.bounds.width&&N.bounds.height===F.bounds.height}function Mz(N,F,A){if(A.collapsed)return null;let M=k1(N,F,A.start),D=k1(N,F,A.end);if(!M||!D)return null;return{end:{left:D.left,top:D.top+D.height},start:{left:M.left,top:M.top}}}var Dz=2;function Ez(N,F,A){return{formatting:A,anchor:{regionId:N.regionId,offset:N.endOffset},kind:"annotation",leftOverride:F.start.left,paddingY:Dz,selection:N}}function $z({formatting:N,handles:F,promotedThread:A,selectionRange:M,threads:D}){if(!M||!F)return null;if(A&&Fy(A.selection,M)){let E=D[A.threadIndex];if(!E)return null;return{...A,kind:"thread",link:null,resolved:j1(E),thread:E}}return Ez(M,F,N)}function Fy(N,F){return N.endOffset===F.endOffset&&N.regionId===F.regionId&&N.startOffset===F.startOffset}function yz(N,F){if(N===F)return!0;if(!N||!F)return!1;if(N.kind!==F.kind)return!1;switch(N.kind){case"annotation":return F.kind==="annotation"&&bF(N,F)&&o$(N.formatting,F.formatting)&&Fy(N.selection,F.selection);case"thread":return F.kind==="thread"&&l3(N,F)}}function Zz({isEditable:N,liveRanges:F,normalizedSelection:A,state:M,threads:D,viewport:E}){let $=M.selection.focus;if(!A.collapsed)return null;let y=N?Qz(M):null;if(y)return y;let Z=N?Yz(M,E):null;if(Z)return Z;return o8(R8(M,E,$),D,F)}function Yz(N,F){let A=N.selection.focus,M=N.documentIndex.regionIndex.get(A.regionId),D=M?N.documentIndex.tableCellIndex.get(M.id)??null:null;if(!M||!D)return null;let E=N.documentIndex.blockIndex.get(M.blockId),$=E?.type==="table"?N.documentIndex.document.blocks[E.rootIndex]:null;if(!E||!$||$.type!=="table")return null;let y=Xz(F,M.id),Z=Math.max(1,...$.rows.map((Y)=>Y.cells.length));return y!==null?{anchor:A,cellIndex:D.cellIndex,columnCount:Z,kind:"table",leftOverride:y,rowCount:$.rows.length,rowIndex:D.rowIndex}:null}function Xz(N,F){let A=N.layout.lines.find((M)=>M.regionId===F);return A?A.left:null}function Qz(N){let F=N.selection.focus,A=N.documentIndex.regionIndex.get(F.regionId);if(!A||A.blockType!=="paragraph"||A.text.length>0)return null;if(F.offset!==0)return null;let M=N.documentIndex.blockIndex.get(A.blockId);if(!M||M.parentBlockId!==null)return null;return{anchor:F,kind:"insertion"}}function Sz(N,F){if(N===F)return!0;if(!N||!F)return!1;if(N.kind!==F.kind)return!1;switch(N.kind){case"thread":return F.kind==="thread"&&l3(N,F);case"insertion":return F.kind==="insertion"&&bF(N,F);case"link":return F.kind==="link"&&l3(N,F);case"table":return F.kind==="table"&&bF(N,F)&&N.cellIndex===F.cellIndex&&N.columnCount===F.columnCount&&N.rowCount===F.rowCount&&N.rowIndex===F.rowIndex}}function Jz(N,F){if(N===F)return!0;if(N.length!==F.length)return!1;return N.every((A,M)=>{let D=F[M];return A.endOffset===D.endOffset&&A.regionId===D.regionId&&A.resolved===D.resolved&&A.startOffset===D.startOffset&&A.threadIndex===D.threadIndex})}function Vz(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.blockId===F.blockId&&N.regionId===F.regionId&&N.height===F.height&&N.left===F.left&&N.offset===F.offset&&N.top===F.top}function qz(N){return N.startOffset<N.endOffset?N.startOffset+1:N.startOffset}function Uz(N,F){return N.cursor===F.cursor&&Kz(N.leaf,F.leaf)}function Kz(N,F){if(N===F)return!0;if(!N||!F)return!1;return l3(N,F)}function l3(N,F){if(N.kind!==F.kind)return!1;if(!bF(N,F))return!1;switch(N.kind){case"thread":return F.kind==="thread"&&N.animateInitialComment===F.animateInitialComment&&N.link?.title===F.link?.title&&N.link?.url===F.link?.url&&N.resolved===F.resolved&&N.thread===F.thread&&N.threadIndex===F.threadIndex;case"link":return F.kind==="link"&&N.endOffset===F.endOffset&&N.regionId===F.regionId&&N.startOffset===F.startOffset&&N.title===F.title&&N.url===F.url}}var XA=l0([K0,JN],(N,F,A)=>zz(F,A.liveRanges));function zz(N,F){let A=new Map(N.documentIndex.regions.map((Z,Y)=>[Z.id,Y])),M=x3(A,N.selection.anchor.regionId,N.selection.anchor.offset),D=x3(A,N.selection.focus.regionId,N.selection.focus.offset),[E,$]=M<=D?[M,D]:[D,M],y=M===D;for(let Z of F){let Y=x3(A,Z.regionId,Z.startOffset),X=x3(A,Z.regionId,Z.endOffset);if(y){if(E>=Y&&E<=X)return Z.threadIndex;continue}if(Math.max(E,Y)<Math.min($,X))return Z.threadIndex}return null}function x3(N,F,A){return(N.get(F)??-1)*1e6+A}var Ay=i0([fF],(N,[F],A)=>{if(!F?.length)return;return b6(A,F)},My),QA=i0([fF,M1],(N,[F],A,M)=>{let D=Ay.read(N,F);if(!D)return;return M?f6(A,M,D):D},My),SA=i0([fF],(N,[F])=>{let A=Ay.read(N,F),M=new Map;for(let D of A??[])if(D.commentThreadIndex!=null&&!M.has(D.commentThreadIndex))M.set(D.commentThreadIndex,D.color??null);return M},Bz);function My(N,F){if(N===F)return!0;if(!N||!F)return!1;return Gz(N,F)}var Gz=v3((N,F)=>{return N.id===F.id&&N.username===F.username&&N.fullName===F.fullName&&N.avatarUrl===F.avatarUrl&&N.color===F.color&&N.commentThreadIndex===F.commentThreadIndex&&Hz(N.cursorPoint,F.cursorPoint)&&_z(N.viewport,F.viewport)});function Hz(N,F){if(N===F)return!0;if(!N||!F)return!1;return N.offset===F.offset&&N.regionId===F.regionId}function _z(N,F){if(N===F)return!0;if(!N||!F)return!1;if(N.status!==F.status)return!1;if(N.status==="unresolved")return!0;return F.status!=="unresolved"&&N.scrollTop===F.scrollTop}function Bz(N,F){if(N===F)return!0;if(N.size!==F.size)return!1;for(let[A,M]of N)if(F.get(A)!==M)return!1;return!0}function Dy(N){return{editor:m$(FN(N)),viewport:k$()}}import{useEffect as Pz,useRef as Wz}from"react";import{jsx as JA,jsxs as Tz}from"react/jsx-runtime";var Oz="documint-leaf-menu-item documint-completion-item";function d3({activeIndex:N,matches:F,onHover:A,onSelect:M}){let D=Wz(null);return Pz(()=>{let E=D.current;if(!E)return;let $=E.children[N];if($ instanceof HTMLElement){let y=$.getBoundingClientRect(),Z=E.getBoundingClientRect();if(y.top<Z.top)E.scrollTop-=Z.top-y.top;else if(y.bottom>Z.bottom)E.scrollTop+=y.bottom-Z.bottom}},[N]),JA("div",{className:"documint-completion-leaf",ref:D,role:"listbox",children:F.map((E,$)=>{let y=$===N;return Tz("button",{"aria-selected":y,className:`${Oz}${y?" is-active":""}`,onPointerDown:wz,onPointerEnter:()=>A($),onClick:()=>M(E),role:"option",type:"button",children:[E.icon?JA("span",{"aria-hidden":"true",className:"documint-completion-item-icon",children:E.icon}):null,JA("span",{children:E.label})]},Lz(E))})})}function wz(N){N.preventDefault()}function Lz(N){return N.id??`${N.kind??""}:${N.label}:${N.insertText??""}:${N.icon??""}`}import{useCallback as az,useRef as rz}from"react";import{useCallback as uF,useEffect as bz,useEffectEvent as fz,useLayoutEffect as uz,useMemo as vz,useState as Xy}from"react";import{useCallback as VA,useEffect as Ey,useRef as $y,useState as yy}from"react";function a3({activeCompletion:N,contextKey:F,onAccept:A,onDismiss:M}){let[D,E]=yy(0),[$,y]=yy(null),Z=$y(!1),Y=$y(null),X=N?F??jz(N):null,Q=X===$||X===Y.current?null:N,S=Q?Math.min(D,Math.max(0,Q.matches.length-1)):D;Ey(()=>{E(0),Y.current=null},[X]),Ey(()=>{if(!X||$&&X!==$)y(null)},[X,$]);let J=VA((U)=>{if(!Q||!X||Y.current===X)return;Y.current=X,y(X),A(U,Q)},[X,A,Q]),V=VA((U)=>{if(!Q||Q.matches.length===0)return!1;if(U.key==="ArrowDown")return U.preventDefault(),U.stopPropagation(),E((z)=>(z+1)%Q.matches.length),!0;if(U.key==="ArrowUp")return U.preventDefault(),U.stopPropagation(),E((z)=>(z-1+Q.matches.length)%Q.matches.length),!0;if(U.key==="Enter"||U.key==="Tab"){U.preventDefault(),U.stopPropagation(),Z.current=!0;let z=Q.matches[S];if(z)J(z);return!0}if(U.key==="Escape")return U.preventDefault(),U.stopPropagation(),y(X),M?.(),!0;return!1},[J,X,S,M,Q]),K=VA((U)=>{if(Z.current&&Zy(U.inputType))return Z.current=!1,U.preventDefault(),U.stopPropagation(),!0;if(!Q||Q.matches.length===0)return Z.current=!1,!1;if(Cz(U.inputType))return U.preventDefault(),U.stopPropagation(),!0;if(!Zy(U.inputType))return Z.current=!1,!1;U.preventDefault(),U.stopPropagation();let z=Q.matches[S];if(z)J(z);return!0},[J,S,Q]),q=Q&&Q.matches.length>0?{activeIndex:S,matches:Q.matches,onHover:E,onSelect:J}:null;return{activeIndex:S,handleBeforeInput:K,handleKeyDown:V,leafProps:q}}function Zy(N){return N==="insertLineBreak"||N==="insertParagraph"}function Cz(N){return N==="insertReplacementText"}function jz(N){return[N.trigger,N.triggerStart,N.caret,N.query].join(":")}var Rz=["box-sizing","width","height","overflow-x","overflow-y","border-top-width","border-right-width","border-bottom-width","border-left-width","border-style","padding-top","padding-right","padding-bottom","padding-left","font-style","font-variant","font-weight","font-stretch","font-size","font-size-adjust","line-height","font-family","text-align","text-transform","text-indent","text-decoration","letter-spacing","word-spacing","tab-size"];function Yy(N,F,{scrollX:A=window.scrollX,scrollY:M=window.scrollY}={}){if(!N.isConnected)return null;let D=getComputedStyle(N),E=document.createElement("div");for(let X of Rz)E.style.setProperty(X,D.getPropertyValue(X));Object.assign(E.style,{position:"absolute",top:"0",left:"0",visibility:"hidden",whiteSpace:"pre-wrap",wordWrap:"break-word",width:`${N.clientWidth}px`}),E.textContent=N.value.slice(0,F);let $=document.createElement("span");$.textContent=N.value.slice(F)||".",E.appendChild($),document.body.appendChild(E);let y=N.getBoundingClientRect(),Z=parseFloat(D.lineHeight)||$.offsetHeight,Y={anchorHeight:Z,left:A+y.left+$.offsetLeft+parseFloat(D.borderLeftWidth)-N.scrollLeft,top:M+y.top+$.offsetTop+parseFloat(D.borderTopWidth)+Z-N.scrollTop};return document.body.removeChild(E),Y}function Qy({completionSources:N,onChange:F,textareaRef:A,value:M}){let[D,E]=Xy(null),[$,y]=Xy(null),Z=D?.triggerStart??null,Y=vz(()=>h$(N),[N]),X=uF((U,z)=>{if(!Y.length){E(null);return}let G=g3(U,z,Y);if(!G){E(null);return}E(G)},[Y]),Q=uF((U)=>{let z=U.currentTarget.value,G=U.currentTarget.selectionEnd??z.length;F(z),X(z,G)},[F,X]),S=uF((U)=>{let z=U.currentTarget;X(z.value,z.selectionEnd??z.value.length)},[X]),J=uF(()=>{E(null)},[]),V=uF((U,z)=>{if(!A.current)return;let H=l$(M,z,mz(U));F(H.value),E(null),requestAnimationFrame(()=>{let B=A.current;if(!B)return;B.focus(),B.setSelectionRange(H.caret,H.caret)})},[F,A,M]),K=a3({activeCompletion:D,onAccept:V,onDismiss:J}),q=fz((U)=>{K.handleBeforeInput(U)});return bz(()=>{let U=A.current;if(!U)return;return U.addEventListener("beforeinput",q),()=>U.removeEventListener("beforeinput",q)},[A]),uz(()=>{if(Z===null){y(null);return}let U=()=>{let z=A.current;if(!z)return;let G=Yy(z,Z);y(G?{anchorHeight:G.anchorHeight,bridge:!1,left:G.left,paddingY:4,top:G.top}:null)};return U(),window.addEventListener("scroll",U,!0),window.addEventListener("resize",U),()=>{window.removeEventListener("scroll",U,!0),window.removeEventListener("resize",U)}},[Z,A]),{activeCompletion:D,anchor:$,handleBlur:J,handleChange:Q,handleKeyDown:K.handleKeyDown,handleSelect:S,leafProps:K.leafProps}}function mz(N){return N.kind==="mention"?{...N,insertText:`@${N.label} `}:N}import{useLayoutEffect as kz,useRef as gz,useState as hz}from"react";import{jsx as qA,jsxs as dz}from"react/jsx-runtime";var Sy=12,Iz={horizontalOffset:0,verticalPlacement:"below"};function r3({anchor:N,children:F}){let A=gz(null),[M,D]=hz(Iz);return kz(()=>{let E=A.current;if(!E||typeof window>"u")return;let $=()=>{let Z=E.getBoundingClientRect(),Y=pz(N,Z);D((X)=>lz(X,Y)?X:Y)};$();let y=new ResizeObserver($);return y.observe(E),window.visualViewport?.addEventListener("resize",$),window.addEventListener("resize",$),()=>{y.disconnect(),window.visualViewport?.removeEventListener("resize",$),window.removeEventListener("resize",$)}},[N.left,N.top]),qA(T$,{children:dz("div",{className:"documint-leaf-anchor","data-bridge":N.bridge,"data-placement":M.verticalPlacement,onPointerEnter:N.onPointerEnter,onPointerLeave:N.onPointerLeave,style:{left:`${N.left+M.horizontalOffset}px`,top:`${N.top}px`,"--documint-leaf-anchor-height":`${N.anchorHeight}px`,"--documint-leaf-bridge-height":`${Sy}px`,"--documint-leaf-padding-y":`${N.paddingY}px`},children:[N.bridge?qA("div",{className:"documint-leaf-bridge"}):null,qA("div",{className:"documint-leaf-shell",ref:A,children:F})]})})}function pz(N,F){let A=window.visualViewport,M=A?.width??window.innerWidth,D=A?.height??window.innerHeight,E=A?.offsetLeft??0,$=A?.offsetTop??0,y=N.left-window.scrollX-E,Z=N.top-window.scrollY-$,Y=D-Z;return{horizontalOffset:xz({anchorScreenLeft:y,shellWidth:F.width,visibleWidth:M}),verticalPlacement:F.height+Sy>Y?"above":"below"}}function xz({anchorScreenLeft:N,shellWidth:F,visibleWidth:A}){let M=A-N;if(F<=M)return 0;return Math.max(-N,Math.min(-F/2,A-N-F))}function lz(N,F){return N.horizontalOffset===F.horizontalOffset&&N.verticalPlacement===F.verticalPlacement}import{jsx as d1,jsxs as Jy,Fragment as sz}from"react/jsx-runtime";function vF({actions:N,autoFocus:F=!1,completionSources:A,onChange:M,placeholder:D,readOnly:E=!1,ref:$,rows:y=3,saveOnEnter:Z=!1,value:Y}){let X=rz(null),Q=$??X,{activeCompletion:S,anchor:J,handleBlur:V,handleChange:K,handleKeyDown:q,handleSelect:U,leafProps:z}=Qy({completionSources:A,onChange:M,textareaRef:Q,value:Y}),G=az((H)=>{if(q(H))return;if(H.key==="Escape"&&N.kind==="edit")H.preventDefault(),N.onCancel();if(H.key==="Enter"&&Z){if(H.preventDefault(),N.kind==="edit"&&!N.saveDisabled)N.onSave();else if(N.kind==="compose"&&!N.submitDisabled)N.onSubmit()}},[N,q,Z]);return Jy("div",{className:"documint-leaf-input-field",children:[d1("textarea",{autoFocus:F,className:"documint-leaf-input",onBlur:V,onChange:K,onKeyDown:G,onSelect:U,placeholder:D,readOnly:E,ref:Q,rows:y,value:Y}),cz(N),S&&J&&z?d1(r3,{anchor:J,children:d1(d3,{...z})}):null]})}function cz(N){if(N.kind==="edit")return Jy(sz,{children:[d1(UA,{className:"documint-leaf-input-cancel",icon:WF,label:"Cancel editing",onClick:N.onCancel}),d1(UA,{className:"documint-leaf-input-save",disabled:N.saveDisabled??!1,icon:q2,label:"Save",onClick:N.onSave})]});return d1(UA,{className:"documint-leaf-input-submit",disabled:N.submitDisabled??!1,icon:p1,iconSize:15,label:N.submitLabel,onClick:N.onSubmit})}function UA({className:N,disabled:F=!1,icon:A,iconSize:M=14,label:D,onClick:E}){return d1("button",{"aria-label":D,className:`documint-leaf-action ${N}`,disabled:F,onClick:E,title:D,children:d1(A,{size:M,strokeWidth:2.2})})}import{Fragment as Vy}from"react";import{jsx as Uy,jsxs as qy}from"react/jsx-runtime";function KA({value:N,completionSources:F,onEdit:A}){return Uy("p",{onDoubleClick:A,children:iz(N,F)})}function iz(N,F){let A=h3(N,F);if(A.length===1&&A[0].kind==="text")return N;return A.map((M,D)=>M.kind==="token"&&M.id?qy("span",{className:"documint-mention",children:[M.trigger,M.label]},D):M.kind==="token"?qy(Vy,{children:[M.trigger,M.label]},D):Uy(Vy,{children:M.text},D))}import{Children as Ky,isValidElement as zy,useEffect as oz,useRef as nz,useState as tz}from"react";import{jsx as T0,jsxs as HA}from"react/jsx-runtime";var zA=(N)=>{N.preventDefault()},GA=(N)=>N.isPrimary&&N.button===0;function ez({children:N}){return T0("div",{className:"documint-leaf-toolbar",children:Ky.map(N,NG)})}function NG(N){if(!zy(N))return null;if(N.type===Hy){let F=N.props;return T0(Gy,{children:T0(FG,{...F})})}if(N.type===_y){let{className:F}=N.props;return T0("div",{className:mF("documint-leaf-toolbar-divider",F)})}if(N.type===By){let F=N.props;return T0(MG,{...F})}return null}function FG({active:N=!1,className:F,disabled:A=!1,icon:M,label:D,onClick:E}){return T0("button",{"aria-label":D,className:mF("documint-leaf-toolbar-button",N?"active":null,F),disabled:A,onPointerDown:($)=>{if(zA($),!A&&GA($))E()},title:D,type:"button",children:T0(AG,{icon:M})})}function AG({icon:N}){return T0(N,{size:15,strokeWidth:2.2})}function MG({children:N,className:F,icon:A,label:M,onSelect:D}){let E=nz(null),[$,y]=tz(!1);return oz(()=>{if(!$)return;let Z=(Y)=>{if(E.current&&Y.target instanceof Node&&!E.current.contains(Y.target))y(!1)};return window.addEventListener("pointerdown",Z),()=>{window.removeEventListener("pointerdown",Z)}},[$]),T0(Gy,{children:HA("div",{className:"documint-leaf-toolbar-menu-shell",ref:E,children:[T0(DG,{className:F,icon:A,isOpen:$,label:M,onClick:()=>y((Z)=>!Z)}),$?T0("div",{className:"documint-leaf-menu",role:"menu",children:Ky.map(N,(Z)=>EG(Z,(Y)=>{y(!1),D(Y)}))}):null]})})}function DG({className:N,icon:F,isOpen:A,label:M,onClick:D}){return HA("button",{"aria-expanded":A,"aria-haspopup":"menu","aria-label":M,className:mF("documint-leaf-toolbar-button",A?"active":null,N),onPointerDown:(E)=>{if(zA(E),GA(E))D()},title:M,type:"button",children:[T0(F,{size:15,strokeWidth:2.2}),T0($F,{className:mF("documint-leaf-toolbar-menu-chevron",A?"is-open":null),size:13,strokeWidth:2.2})]})}function EG(N,F){if(!zy(N))return null;if(N.type===Wy){let{className:$}=N.props;return T0("div",{className:mF("documint-leaf-menu-divider",$),role:"separator"})}if(N.type!==Py)return null;let{disabled:A=!1,icon:M,text:D,value:E}=N.props;return HA("button",{className:"documint-leaf-menu-item",disabled:A,onPointerDown:($)=>{if(zA($),!A&&GA($))F(E)},role:"menuitem",type:"button",children:[T0(M,{size:15,strokeWidth:2.2}),T0("span",{children:D})]})}function mF(...N){return N.filter(Boolean).join(" ")}function Gy({children:N}){return T0("div",{className:"documint-leaf-toolbar-group",children:N})}function Hy(N){return null}function _y(N){return null}function By(N){return null}function Py(N){return null}function Wy(N){return null}var d=Object.assign(ez,{Button:Hy,Divider:_y,Menu:By,MenuDivider:Wy,MenuItem:Py});import{jsx as t,jsxs as V1,Fragment as XG}from"react/jsx-runtime";var $G=!1,yG=220,ZG={code:!1,marks:[]},_A=()=>{};function BA(N){let F=N.mode==="create",A=N.mode==="create"?N:null,M=N.mode==="thread"?N:null,D=N.canEdit,E=N.link,$=M?.thread??null,y=$?.comments??[],Z=y[0]??null,Y=$?j1($):!1,X=M?.animateInitialComment??!1,[Q,S]=_2(null),[J,V]=_2(""),[K,q]=_2(""),[U,z]=_2(""),[G,H]=_2(!X),[B,_]=_2($G),[O,w]=_2(!1),b=Oy(null),L=Oy(null),W=N.completionSources,v=$?b4($):null,g=v?wy(v):"",j=D&&!Y,P=j&&J.trim().length>0,R=j&&K.trim().length>0,f=D&&U.trim().length>0,m=F||O,x=!F||B,r=!F&&Boolean($),i=Boolean(Z),B0=F?B:!0,Q0=M?.onDeleteComment??_A,u=M?.onDeleteThread??_A,l=M?.onToggleResolved??_A,o=A?.formatting??ZG,a=o.code,V0=o.marks,P0=h(X3),T=h(V3),p=h(Q3),D0=h(S3),q0=h(J3),Y0=A?.actions??[],E0=D?F?"Add a comment":"Reply to this comment":"Comment editing is disabled",R0=F?U:K;c3(()=>{if(Q!==null&&(Q<0||Q>=y.length))S(null),V("")},[y.length,Q]),c3(()=>{if(!i||!X){H(!0);return}H(!1);let G0=requestAnimationFrame(()=>{H(!0)});return()=>{cancelAnimationFrame(G0)}},[X,Z,i]),c3(()=>{if(!M||!X){w(!1);return}w(!0);let G0=window.setTimeout(()=>{w(!1)},yG);return()=>{window.clearTimeout(G0)}},[X,M]),c3(()=>{if(!F||!B||!D)return;let G0=requestAnimationFrame(()=>{L.current?.focus()});return()=>{cancelAnimationFrame(G0)}},[D,F,B]);let q1=()=>{S(null),V("")},P2=(G0,O2)=>{if(!r||!j)return;S(G0),V(O2)},W2=(G0)=>{if(!M)return;M.onEditComment(G0,J),q1()},zN=()=>{if(!M)return;M.onReply(K),q("")},GN=()=>{if(!A||!f)return;A.onCreateThread(U),z("")},dF=m?`documint-comment-leaf documint-comment-leaf-create${B0?" is-expanded":""}`:"documint-comment-leaf",M4=r||i||x?t(YG,{canCreate:f,canEdit:D,canMutateThread:j,canReply:R,canSaveEditedComment:P,comments:y,composerRef:L,editDraft:J,editingCommentIndex:Q,isComposerVisible:x,isInitialCommentVisible:G,isResolved:Y,link:E,completionSources:W,mode:N.mode,onBeginEditingComment:P2,onCancelEditing:q1,onChangeCreateDraft:z,onChangeEditDraft:V,onChangeReplyDraft:q,onDeleteComment:Q0,onDeleteThread:u,onSubmitCreate:GN,onSubmitEditedComment:W2,onSubmitReply:zN,onToggleResolved:l,rootComment:Z,showRootComment:i,showThreadChrome:r,threadAge:g,composerPlaceholder:E0,composerValue:R0}):null;return t("div",{className:dF,"data-resolved":Y?"true":void 0,ref:b,children:V1("div",{className:m?"documint-comment-leaf-create-shell":void 0,children:[m?V1(d,{children:[t(d.Button,{className:"documint-comment-leaf-create-button",icon:GF,label:"Add comment",onClick:()=>_(!0)}),t(d.Divider,{}),t(d.Button,{active:V0.includes("bold"),className:"documint-comment-leaf-create-mark",disabled:a,icon:EF,label:"Bold",onClick:P0}),t(d.Button,{active:V0.includes("italic"),className:"documint-comment-leaf-create-mark",disabled:a,icon:qF,label:"Italic",onClick:p}),t(d.Button,{active:V0.includes("underline"),className:"documint-comment-leaf-create-mark",disabled:a,icon:PF,label:"Underline",onClick:q0}),t(d.Divider,{}),t(d.Button,{active:a,className:"documint-comment-leaf-create-mark",icon:yF,label:"Code",onClick:T}),t(d.Button,{active:V0.includes("strikethrough"),className:"documint-comment-leaf-create-mark",disabled:a,icon:_F,label:"Strikethrough",onClick:D0}),Y0.length>0?[t(d.Divider,{},"actions-divider"),...Y0.map((G0,O2)=>{return t(d.Button,{className:"documint-comment-leaf-create-mark",icon:G0.icon,label:G0.label,onClick:()=>G0.onClick()},`${G0.label}:${O2}`)})]:null]}):null,t("div",{className:m?"documint-comment-leaf-create-content":void 0,children:M4})]})})}function YG({canCreate:N,canEdit:F,canMutateThread:A,canReply:M,canSaveEditedComment:D,comments:E,composerRef:$,editDraft:y,editingCommentIndex:Z,isComposerVisible:Y,isInitialCommentVisible:X,isResolved:Q,link:S,completionSources:J,mode:V,onBeginEditingComment:K,onCancelEditing:q,onChangeCreateDraft:U,onChangeEditDraft:z,onChangeReplyDraft:G,onDeleteComment:H,onDeleteThread:B,onSubmitCreate:_,onSubmitEditedComment:O,onSubmitReply:w,onToggleResolved:b,rootComment:L,showRootComment:W,showThreadChrome:v,threadAge:g,composerPlaceholder:j,composerValue:P}){return V1(XG,{children:[v?V1("div",{className:"documint-comment-leaf-header",children:[t("span",{className:"documint-comment-leaf-age",children:g}),V1("div",{className:"documint-comment-leaf-actions",children:[t("button",{className:"documint-leaf-action","aria-label":Q?"Reopen comment":"Resolve comment",disabled:!F,onClick:b,title:Q?"Reopen comment":"Resolve comment",type:"button",children:t(q2,{size:14,strokeWidth:2.2})}),t("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!F,onClick:B,title:"Delete comment thread",type:"button",children:t(s0,{size:14,strokeWidth:2.2})})]})]}):null,v&&S?V1("div",{className:"documint-comment-leaf-link",children:[S.title?t("div",{className:"documint-link-leaf-title",children:S.title}):null,t("div",{className:"documint-link-leaf-url",children:S.url})]}):null,V1("div",{className:`documint-comment-thread${W?"":" is-empty"}`,children:[t("article",{className:W?`documint-comment-message documint-comment-message-root${X?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:L?t(KA,{completionSources:J,onEdit:()=>K(0,L.body),value:L.body}):null}),E.slice(1).map((R,f)=>{let m=f+1,x=Z===m;return V1("article",{className:"documint-comment-message",children:[!x?V1("div",{className:"documint-comment-message-meta",children:[t("span",{children:wy(R.updatedAt)}),A?V1("div",{className:"documint-comment-leaf-actions",children:[t("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!A,onClick:()=>{K(m,R.body)},title:"Edit comment",type:"button",children:t(U2,{size:14,strokeWidth:2.2})}),t("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!A,onClick:()=>H(m),title:"Delete comment",type:"button",children:t(s0,{size:14,strokeWidth:2.2})})]}):null]}):null,x?t(vF,{actions:{kind:"edit",onCancel:q,onSave:()=>O(m),saveDisabled:!D},completionSources:J,onChange:z,readOnly:!F,rows:3,value:y}):t(KA,{completionSources:J,onEdit:()=>K(m,R.body),value:R.body})]},`${R.updatedAt}:${m}`)})]}),t("div",{className:`documint-comment-reply${v?"":" is-standalone"}${Y?" is-visible":""}`,children:t(vF,{actions:V==="create"?{kind:"compose",onSubmit:_,submitDisabled:!N,submitLabel:"Create comment"}:{kind:"compose",onSubmit:w,submitDisabled:!M,submitLabel:"Reply"},completionSources:J,onChange:V==="create"?U:G,placeholder:j,readOnly:!F,ref:$,rows:3,value:P})})]})}function wy(N){let F=new Date(N);if(Number.isNaN(F.getTime()))return N;let A=F.getTime()-Date.now(),M=60000,D=60*M,E=24*D,$=7*E,y=30*E,Z=365*E,Y=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(A)<M)return"just now";if(Math.abs(A)<D)return Y.format(Math.round(A/M),"minute");if(Math.abs(A)<E)return Y.format(Math.round(A/D),"hour");if(Math.abs(A)<$)return Y.format(Math.round(A/E),"day");if(Math.abs(A)<Z)return Y.format(Math.round(A/y),"month");return Y.format(Math.round(A/Z),"year")}import{jsx as E1,jsxs as JG}from"react/jsx-runtime";var QG=[{icon:ZF,label:"Heading 1",text:"# "},{icon:YF,label:"Heading 2",text:"## "},{icon:XF,label:"Heading 3",text:"### "},{icon:SF,label:"Heading 4",text:"#### "},{icon:QF,label:"Heading 5",text:"##### "},{icon:JF,label:"Heading 6",text:"###### "}],SG=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function Ly({onInsert:N,onInsertTable:F}){return JG(d,{children:[E1(d.Button,{icon:zF,label:"Insert bulleted list",onClick:()=>N("- ")}),E1(d.Button,{icon:UF,label:"Insert numbered list",onClick:()=>N("1. ")}),E1(d.Button,{icon:KF,label:"Insert task list",onClick:()=>N("- [ ] ")}),E1(d.Divider,{}),E1(d.Menu,{icon:VF,label:"Insert heading",onSelect:N,children:QG.map(({icon:A,label:M,text:D})=>E1(d.MenuItem,{icon:A,text:M,value:D},D))}),E1(d.Menu,{icon:x1,label:"Insert table",onSelect:(A)=>F(Number(A)),children:SG.map(({columns:A,text:M})=>E1(d.MenuItem,{icon:x1,text:M,value:String(A)},A))}),E1(d.Divider,{}),E1(d.Button,{icon:BF,label:"Insert blockquote",onClick:()=>N("> ")}),E1(d.Button,{icon:HF,label:"Insert divider",onClick:()=>N("--- ")})]})}import{useState as Ty}from"react";import{jsx as _1,jsxs as kF}from"react/jsx-runtime";function Cy({title:N,url:F,canEdit:A,onSave:M,onDelete:D}){let[E,$]=Ty(!1),[y,Z]=Ty(""),Y=qG(F),X=UG(F),Q=A&&!E,S=A&&y.trim().length>0,J=VG();return kF("div",{className:"documint-link-leaf",children:[N&&_1("div",{className:"documint-link-leaf-title",children:N}),kF("div",{className:"documint-link-leaf-row",children:[E?_1(vF,{actions:{kind:"edit",onCancel:()=>$(!1),onSave:()=>{M(encodeURI(y.trim())),$(!1)},saveDisabled:!S},autoFocus:!0,onChange:Z,readOnly:!A,rows:3,saveOnEnter:!0,value:y}):kF("div",{className:"documint-link-leaf-url-row",children:[X&&_1("img",{alt:"","aria-hidden":"true",className:"documint-link-leaf-favicon",onError:(q)=>{q.currentTarget.hidden=!0},src:X},X),_1("div",{className:"documint-link-leaf-url",children:Y})]}),Q&&kF("div",{className:"documint-link-leaf-actions",children:[_1("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!A)return;Z(Y),$(!0)},title:"Edit link",children:_1(U2,{size:14,strokeWidth:2.2})}),_1("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:D,title:"Remove link",children:_1(s0,{size:14,strokeWidth:2.2})})]})]}),_1("div",{className:"documint-link-leaf-divider"}),kF("div",{className:"documint-link-leaf-hint",children:[J,"click to open"]})]})}function VG(){if(typeof navigator>"u")return"Ctrl+";let N=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test(N)?"CMD+":"CTRL+"}function qG(N){try{return decodeURIComponent(N)}catch{return N}}function UG(N){try{let{hostname:F}=new URL(N);return`https://www.google.com/s2/favicons?domain=${F}&sz=32`}catch{return null}}import{jsx as B1,jsxs as OA}from"react/jsx-runtime";var KG=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],zG=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],PA={text:"Delete column",value:"delete"},WA={text:"Delete row",value:"delete"},jy={text:"Delete table",value:"delete"};function Ry({canDeleteColumn:N,canDeleteRow:F,onDeleteColumn:A,onDeleteRow:M,onDeleteTable:D,onInsertColumn:E,onInsertRow:$}){return OA(d,{children:[OA(d.Menu,{icon:h1,label:"Column actions",onSelect:(y)=>{if(y===PA.value){A();return}E(y)},children:[KG.map(({text:y,value:Z})=>B1(d.MenuItem,{icon:ZN,text:y,value:Z},Z)),B1(d.MenuDivider,{}),B1(d.MenuItem,{disabled:!N,icon:s0,text:PA.text,value:PA.value})]}),OA(d.Menu,{icon:I1,label:"Row actions",onSelect:(y)=>{if(y===WA.value){M();return}$(y)},children:[zG.map(({text:y,value:Z})=>B1(d.MenuItem,{icon:ZN,text:y,value:Z},Z)),B1(d.MenuDivider,{}),B1(d.MenuItem,{disabled:!F,icon:s0,text:WA.text,value:WA.value})]}),B1(d.Divider,{}),B1(d.Menu,{icon:x1,label:"Table actions",onSelect:()=>D(),children:B1(d.MenuItem,{icon:s0,text:jy.text,value:jy.value})})]})}import{useEffect as GG,useEffectEvent as s3,useRef as wA,useState as HG}from"react";var _G=600;function by({onIdle:N}={}){let[F,A]=HG(null),M=wA(null),D=wA(performance.now()),E=wA(null),$=()=>{if(typeof window>"u"||E.current===null)return;window.clearTimeout(E.current),E.current=null},y=s3(()=>{let Q=M.current;if(Q!==null)D.current=performance.now()-(Q-D.current);E.current=null,M.current=null,A(null),N?.()}),Z=s3(()=>{let Q=performance.now();if(M.current===null)M.current=Q,A(Q);if($(),typeof window<"u")E.current=window.setTimeout(y,_G)}),Y=s3(()=>M.current!==null),X=s3((Q=performance.now())=>(M.current??Q)-D.current);return GG(()=>$,[]),{activeAt:F,resolveAnimationTime:X,isActive:Y,markActive:Z}}import{useEffect as fy,useEffectEvent as BG,useRef as uy}from"react";var PG=530,VN=24;function my({activeAt:N,getScrollTop:F,isEditable:A,layoutWidth:M,onVisibilityChange:D,scrollContentHeight:E,scrollTo:$,viewportHeight:y}){let Z=e(D1),Y=e(AA,A),X=e(MA),Q=e(DA),S=Z.start.regionId===Z.end.regionId&&Z.start.offset===Z.end.offset,J=uy(!0),V=uy(null),K=BG(()=>{D()});return fy(()=>{let q=Z.end,U={layoutWidth:M,offset:q.offset,regionId:q.regionId,scrollContentHeight:E,viewportHeight:y};if(WG(V.current,U))return;if(!Q)return;let z=F(),G=z+VN,H=z+y-VN;if(Q.top<G){let B=$(Math.max(0,Q.top-VN));if(vy(Q,B,y,VN))V.current=U;return}if(Q.top+Q.height>H){let B=$(Math.max(0,Q.top+Q.height-y+VN));if(vy(Q,B,y,VN))V.current=U;return}V.current=U},[Q,M,Z.end.offset,Z.end.regionId,E,y]),fy(()=>{if(J.current=!0,K(),!S||!X||N!==null||typeof window>"u")return;let q=window.setInterval(()=>{J.current=!J.current,K()},PG);return()=>{window.clearInterval(q)}},[S,X,N]),{caretInViewport:X,leaf:Y,isVisible:()=>J.current}}function WG(N,F){return N?.layoutWidth===F.layoutWidth&&N.regionId===F.regionId&&N.offset===F.offset&&N.scrollContentHeight===F.scrollContentHeight&&N.viewportHeight===F.viewportHeight}function vy(N,F,A,M){return N.top>=F+M&&N.top+N.height<=F+A-M}import{useCallback as OG}from"react";function ky({completionSources:N,enabled:F,onMentionAccepted:A}){let M=e(EA,F?N:void 0),D=h(f7),E=h(Y3),$=OG((Y,X)=>{let Q=r$(Y,X);if(Q.kind==="mention"){let S=D(Q.target,Q.userId,Q.name,Q.trailingText);if(S)A?.({target:Q.target,transition:S,userId:Q.userId});return}E(Q.startOffset,Q.endOffset,Q.text)},[D,A,E]),y=a3({activeCompletion:M,contextKey:M?wG(M):null,onAccept:$}),Z=M&&y.leafProps?{kind:"completion",anchor:{regionId:M.regionId,offset:M.triggerStart},...y.leafProps}:null;return{handleBeforeInput:y.handleBeforeInput,handleKeyDown:y.handleKeyDown,leaf:Z}}function wG(N){if(!("regionId"in N)||typeof N.regionId!=="string")return null;return[N.regionId,N.trigger,N.triggerStart,N.caret,N.query].join(":")}import{useMemo as LA,useRef as gF,useEffectEvent as TA}from"react";var LG=48;function gy(N){let F=e(YA,N),A=h(u7),M=gF(null),D=gF(null),E=gF(null),$=gF(null),y=gF(1),Z=TA((J,V)=>{if(!F)return;J.preventDefault(),J.stopPropagation(),J.currentTarget.setPointerCapture(J.pointerId),$.current=J.pointerId,M.current=J.clientX,D.current=J.clientY,E.current=F.inline.image?.width??F.bounds.width,y.current=V}),Y=TA((J)=>{if($.current!==J.pointerId||M.current===null||D.current===null||E.current===null||!F?.inline.image)return;let V=J.clientX-M.current,K=J.clientY-D.current,q=Math.min(F.maxWidth??1/0,Math.max(LG,Math.round(E.current+y.current*(V+K)))),U={end:F.inline.end,image:F.inline.image,start:F.inline.start};A(U,q)}),X=TA((J)=>{if(J.currentTarget.hasPointerCapture(J.pointerId))J.currentTarget.releasePointerCapture(J.pointerId);$.current=null,M.current=null,D.current=null,E.current=null}),Q=LA(()=>({onPointerCancel:X,onPointerDown:(J)=>Z(J,-1),onPointerMove:Y,onPointerUp:X}),[]),S=LA(()=>({onPointerCancel:X,onPointerDown:(J)=>Z(J,1),onPointerMove:Y,onPointerUp:X}),[]);return LA(()=>{if(!F)return null;let{bounds:J}=F;return{start:{left:J.left,top:J.top,props:Q},end:{left:J.left+J.width,props:S,top:J.top+J.height}}},[F])}import{useEffect as hy,useEffectEvent as Iy,useMemo as py,useRef as TG,useState as CG}from"react";function xy(N){let F=e(t8),[A,M]=CG(new Map),D=Iy((Z)=>{if(typeof createImageBitmap>"u")return;let Y=RG(A,Z),X=bG(A,Z);if(Y.length)M((Q)=>{let S=new Map(Q);for(let J of Y)S.delete(J);return S});for(let Q of X)M((S)=>CA(S,Q,hF("loading"))),jG(Q,N).then((S)=>{M((J)=>{if(!J.has(Q))return S?.close(),J;return CA(J,Q,S?hF("loaded",S):hF("error"))})})});hy(()=>{D(F)},[F]);let E=TG(new Map);hy(()=>{for(let[Z,Y]of E.current)if(!A.has(Z))Y.source?.close();E.current=A},[A]);let $=Iy(async(Z)=>{try{let Y=await N.writeFile(Z),X=await createImageBitmap(Z).catch(()=>null);return M((Q)=>CA(Q,Y,X?hF("loaded",X):hF("error"))),Y}catch{return null}}),y=py(()=>A.size===0?null:{images:A},[A]);return py(()=>({resources:y,persistImage:$}),[y,$])}async function jG(N,F){try{let A=await F.readFile(N);return A?await createImageBitmap(A):null}catch{return null}}function RG(N,F){return[...N.keys()].filter((A)=>!F.has(A))}function bG(N,F){return[...F].filter((A)=>{let M=N.get(A)?.status;return M!=="loaded"&&M!=="loading"})}function CA(N,F,A){let M=new Map(N);return M.set(F,A),M}function hF(N,F){return{intrinsicHeight:F?.height??0,intrinsicWidth:F?.width??0,source:F??null,status:N}}import{useEffect as ly,useEffectEvent as z0,useRef as a1,useState as fG}from"react";var uG=48,dy=44,ay=32,ry=1.6,vG=600,mG=24,kG=500;function gG(N,F){let A=F.x-N.x,M=F.y-N.y,D=Math.abs(A),E=Math.abs(M),$=F.time-N.time;if(D<dy||E>ay||D<E*ry||$>vG)return null;return A<0?"left":"right"}function cy({autoScrollDuringDrag:N,canvasRef:F,focusInput:A,isEditable:M,onActivity:D,resolvePoint:E,storage:$}){let y=x0(),Z=h(L0),Y=h(H8),X=h(_8),Q=h(q3),S=h(U3),J=h(k7),V=h(AF),[K,q]=fG(null),{cursor:U,leaf:z}=e(yA,K),G=a1(null),H=a1(!1),B=a1(null),_=a1(null),O=a1(null),w=a1(null),b=a1(new Set),L=a1(null);ly(()=>{if(K&&K.kind!=="task-toggle"&&!z)q(null)},[K,z]),ly(()=>()=>{if(G.current!==null)window.clearTimeout(G.current)},[]);let W=z0(()=>{if(G.current!==null)window.clearTimeout(G.current),G.current=null}),v=z0(()=>{W(),G.current=window.setTimeout(()=>{if(G.current=null,!H.current)q(null)},uG)}),g=z0(()=>{if(!H.current)W(),q(null)}),j=z0((T)=>{if(!T){g();return}if(T.kind==="task-toggle"){W(),q((p)=>p?.kind==="task-toggle"&&p.listItemId===T.listItemId?p:T);return}if(T.commentThreadIndex!==null){W();let p=T.commentThreadIndex;q((D0)=>D0?.kind!=="task-toggle"&&D0?.commentThreadIndex===p?D0:T);return}if(T.kind!=="link"){g();return}W(),q((p)=>p?.kind==="link"&&p.title===T.title&&p.url===T.url&&p.startOffset===T.startOffset&&p.endOffset===T.endOffset?p:T)}),P=z0((T)=>{let p=E(T);if(!p)return null;let D0=y.editor.getState();return lE(D0,y.viewport.get(),p)}),R=z0((T)=>{let p=F.current;if(p&&B.current===T)p.releasePointerCapture(T)}),f=z0(()=>{B.current=null,_.current=null}),m=z0(()=>{w.current=null}),x=z0((T)=>{L.current={expiresAt:T.timeStamp+kG,x:T.clientX,y:T.clientY}}),r=z0((T)=>{if(T.pointerType==="touch")b.current.delete(T.pointerId)}),i=z0((T)=>{R(T.pointerId),f(),m(),r(T)}),B0=z0((T)=>{if(O.current=T.pointerType,T.pointerType==="touch"){if(b.current.add(T.pointerId),b.current.size>1)m();else if(M&&T.isPrimary)w.current={pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,startedAt:T.timeStamp,swiping:!1};return}let p=F.current,D0=y.viewport.get(),q0=E(T);if(!q0)return;if(P(T)?.kind==="task-toggle")return;if(!p)return;let E0=T.shiftKey?X(D0,q0):Y(D0,q0);if(!E0)return;let R0=E0.next.selection.focus;B.current=T.pointerId,_.current=T.shiftKey?E0.previous.selection.anchor:R0,D(),p.setPointerCapture(T.pointerId),A(R0)}),Q0=z0((T)=>{let p=w.current;if(T.pointerType==="touch"&&p?.pointerId===T.pointerId){let E0=T.clientX-p.startX,R0=T.clientY-p.startY,q1=Math.abs(E0),P2=Math.abs(R0);if(q1>=dy&&P2<=ay&&q1>=P2*ry)p.swiping=!0,T.preventDefault();return}let D0=_.current,q0=E(T);if(!q0)return;if(B.current!==T.pointerId||!D0){j(P(T));return}if(!V(y.viewport.get(),q0,D0))return;D(),N(T)}),u=z0(()=>{if(!H.current)v()}),l=z0((T)=>{let p=w.current;if(T.pointerType==="touch"&&p?.pointerId===T.pointerId){let D0=b.current.size===1?gG({time:p.startedAt,x:p.startX,y:p.startY},{time:T.timeStamp,x:T.clientX,y:T.clientY}):null;if(D0)if(T.preventDefault(),x(T),D0==="right")Q();else S();else if(p.swiping)x(T)}i(T)}),o=z0((T)=>{let p=L.current;if(p){let E0=T.clientX-p.x,R0=T.clientY-p.y,q1=T.timeStamp<=p.expiresAt&&Math.hypot(E0,R0)<=mG;if(L.current=null,q1){O.current=null,T.preventDefault(),T.stopPropagation();return}}let D0=O.current==="touch";O.current=null;let q0=P(T);if(q0?.kind==="task-toggle"){if(J(q0.listItemId))T.preventDefault(),T.stopPropagation(),D();return}if(q0?.kind==="link"&&(T.metaKey||T.ctrlKey)){T.preventDefault(),T.stopPropagation(),$.openFile(q0.url);return}if(!D0){A();return}let Y0=E(T);if(Y0){let E0=Y(y.viewport.get(),Y0);if(!E0){A();return}D(),A(E0.next.selection.focus)}else A()}),a=z0((T)=>{let p=y.editor.getState(),D0=E(T),q0=P(T);if(!D0||q0?.kind==="task-toggle")return;let Y0=S5(p,y.viewport.get(),D0);if(!Y0)return;T.preventDefault(),T.stopPropagation(),D(),Z(Y0),A()}),V0=z0(()=>{H.current=!0,W()}),P0=z0(()=>{H.current=!1,v()});return{canvasHandlers:{onClick:o,onDoubleClick:a,onPointerCancel:i,onPointerDown:B0,onPointerLeave:u,onPointerMove:Q0,onPointerUp:l},cursor:U,leaf:z,leafHandlers:{onPointerEnter:V0,onPointerLeave:P0}}}import{useMemo as hG}from"react";function sy({presence:N,users:F}){let A=hG(()=>IG(F,N),[F,N]),M=e(SA,A),D=e(QA,A);return{activeCommentThreadColors:M,resolvedPresence:D}}function IG(N,F){if(!F?.length||!N?.length)return;let A=new Map(N.map((D)=>[D.id,D])),M=[];for(let D of F){let E=A.get(D.userId);if(!E)continue;M.push({...E,color:D.color,cursor:D.cursor})}return M.length===0?void 0:M}import{useEffect as RA,useEffectEvent as m0,useLayoutEffect as pG,useRef as oy,useState as xG}from"react";import{useEffect as _l1}from"react";var jA=[{key:"Backspace",command:"deleteBackward"},{key:"Enter",shiftKey:!0,command:"insertSoftLineBreak"},{key:"Enter",command:"insertLineBreak"},{key:"Home",command:"moveToLineStart"},{key:"End",command:"moveToLineEnd"},{key:"Tab",command:"indent"},{key:"Tab",shiftKey:!0,command:"dedent"},{key:"ArrowLeft",modKey:!0,shiftKey:"any",command:"moveToLineStart"},{key:"ArrowRight",modKey:!0,shiftKey:"any",command:"moveToLineEnd"},{key:"ArrowUp",modKey:!0,shiftKey:"any",command:"moveToDocumentStart"},{key:"ArrowDown",modKey:!0,shiftKey:"any",command:"moveToDocumentEnd"},{key:"ArrowUp",altKey:!0,shiftKey:!0,command:"moveListItemUp"},{key:"ArrowDown",altKey:!0,shiftKey:!0,command:"moveListItemDown"},{key:"a",modKey:!0,command:"selectAll"},{key:"b",modKey:!0,command:"toggleBold"},{key:"e",modKey:!0,command:"toggleCode"},{key:"i",modKey:!0,command:"toggleItalic"},{key:"u",modKey:!0,command:"toggleUnderline"},{key:"y",modKey:!0,command:"redo"},{key:"z",modKey:!0,command:"undo"},{key:"z",modKey:!0,shiftKey:!0,command:"redo"}];function iy(N,F=jA){return F.find((A)=>{let M=A.shiftKey==="any"?!0:(A.shiftKey??!1)===(N.shiftKey??!1);return A.key.toLowerCase()===N.key.toLowerCase()&&(A.altKey??!1)===(N.altKey??!1)&&M&&(A.modKey??!1)===Boolean(N.metaKey||N.ctrlKey)})?.command??null}var lG=1024,ny=16;function ey({inputRef:N,keybindings:F,enableTouchKeyDown:A=!1,onActivity:M,onBeforeInput:D,onKeyDown:E,onImagePaste:$}){let y=x0(),Z=e(K0),Y=dG(),X=()=>y.editor.getState(),Q=oy(!1),S=oy(!1),J=h(iG),V=h(oG),K=h(Z3),q=h(Q8),U=h(S8),z=h(J8),G=h(V8),H=h(nG),B=h(w7),_=h(b7),O=h(R7),w=h(L7),b=m0((u,...l)=>{let o=u(...l);if(o)M();return o}),L=m0(()=>{let u=N.current;if(!u)return;if(typeof document>"u")return;let l=document.execCommand;if(typeof l!=="function")return;try{Q.current=!0,l.call(document,"insertText",!1,"‌"),l.call(document,"delete")}catch{}finally{Q.current=!1,IF(u,X())}}),W=m0(()=>{if(S.current)return;S.current=!0,L()}),v=m0(()=>{L()}),g=m0((u)=>{let l=N.current;if(!l)return;let o=y.viewport.get(),a=k1(X(),o,u);if(!a)return;l.style.top=`${a.top}px`,l.style.left=`${a.left}px`,l.style.height=`${a.height}px`}),j=m0((u)=>{let l=N.current;if(!l)return;g(u??X().selection.focus),l.focus({preventScroll:!Y}),IF(l,X()),W()}),P=m0((u)=>{if(Q.current)return;if(D?.(u))return;let l=X(),o=cG(u.inputType);if(u.inputType==="insertText"){if(!u.data)return;u.preventDefault();let a=ty(u.target);if(a.charsToReplace>0){b(V,a.charsToReplace,a.trailingOffset,u.data);return}let V0=rG(l,u.data);if(V0>0){let P0=u.data.slice(V0);if(P0.length>0)b(J,P0);return}b(J,u.data);return}if(u.inputType==="insertReplacementText"){if(!u.data)return;u.preventDefault();let a=ty(u.target);b(V,a.charsToReplace,a.trailingOffset,u.data);return}if(aG(u.inputType)){u.preventDefault(),b(K);return}if(o==="backward"){u.preventDefault(),b(q);return}if(o==="forward"){u.preventDefault(),b(U);return}if(u.inputType==="historyUndo"){u.preventDefault(),b(z),v();return}if(u.inputType==="historyRedo"){u.preventDefault(),b(G),v();return}}),R=m0((u)=>{let l=X(),o=u.currentTarget.value,a=i3(l);if(Q.current)return;if(FZ(o,a).length===0){IF(u.currentTarget,l);return}b(J,o)}),f=m0((u)=>{if(E?.(u))return;if(!b(H,y.viewport.get(),u.nativeEvent,F))return;u.preventDefault()}),m=m0((u)=>{let l=NF(X());if(!l)return;u.preventDefault(),u.clipboardData.setData("text/plain",G2(l))}),x=m0((u)=>{let l=X(),o=NF(l);if(!o)return;u.preventDefault(),u.clipboardData.setData("text/plain",G2(o)),b(B)}),r=m0(async(u)=>{let o=($?[...u.clipboardData.items].find((P0)=>P0.kind==="file"&&P0.type.startsWith("image/")):void 0)?.getAsFile()??null;if(o&&$){u.preventDefault();let P0=await $(o);if(P0)b(_,P0);return}let a=u.clipboardData.getData("text/plain");if(a.length===0)return;if(/^https?:\/\//.test(a)){if(b(O,a)){u.preventDefault();return}}u.preventDefault();let V0=d8(a);b(w,V0,a)}),i=m0(()=>{M();let u=N.current;if(u)IF(u,X())}),B0=m0((u)=>{if(M(),u.target.matches(":focus-visible"))j()});RA(()=>{let u=N.current;if(!u)return;IF(u,Z)},[Z,N]),pG(()=>{g(Z.selection.focus)},[Z]),RA(()=>{let u=N.current;if(!u)return;let l=(o)=>P(o);return u.addEventListener("beforeinput",l),()=>u.removeEventListener("beforeinput",l)},[N]);let Q0={onCopy:m,onCut:x,onPaste:r,...!Y||A?{onKeyDown:f}:{}};return{canvasHandlers:{...Q0,onFocus:B0},focus:j,inputHandlers:{...Q0,onFocus:i,onInput:R}}}var NZ="​";function dG(){let[N,F]=xG(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return RA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let A=window.matchMedia("(pointer: coarse)"),M=(D)=>F(D.matches);return A.addEventListener?.("change",M),()=>A.removeEventListener?.("change",M)},[]),N}function aG(N){return N==="insertLineBreak"||N==="insertParagraph"}function ty(N){let F=N,A=F?.selectionStart??0,M=F?.selectionEnd??A,D=F?.value.length??M;return{charsToReplace:Math.max(0,M-A),trailingOffset:Math.max(0,D-M)}}function rG(N,F){if(F.length<ny)return 0;let A=i3(N,F.length),M=Math.min(A.length,F.length);for(let D=M;D>=ny;D--)if(A.endsWith(F.slice(0,D)))return D;return 0}function cG(N){switch(N){case"deleteContentBackward":case"deleteComposedCharacterBackward":case"deleteSoftLineBackward":case"deleteHardLineBackward":case"deleteWordBackward":return"backward";case"deleteContentForward":case"deleteSoftLineForward":case"deleteHardLineForward":case"deleteWordForward":return"forward";default:return null}}function sG(N){return N.replaceAll(NZ,"")}function i3(N,F=lG){let{anchor:A,focus:M}=N.selection;if(A.regionId!==M.regionId||A.offset!==M.offset)return"";let D=N.documentIndex.regionIndex.get(M.regionId);if(!D)return"";return D.text.slice(Math.max(0,M.offset-F),M.offset)}function FZ(N,F){let A=sG(N);return A.startsWith(F)?A.slice(F.length):A}function IF(N,F){let A=i3(F),M=A.length>0?A:NZ;N.value=M,N.setSelectionRange(M.length,M.length),N.scrollLeft=N.scrollWidth}function iG(N,F){let M=FZ(F,i3(N)).replace(/\r\n/g,`
33
+ `).split(/(\n)/),D=N;for(let E of M){if(E.length===0)continue;let $=E===`
34
+ `?Z3(D):eN(D,E);if(!$)continue;D=$}return D===N?null:D}function oG(N,F,A,M){let D=N.selection.focus,E=Math.max(0,D.offset-A),$=Math.max(0,E-F);return Y3(N,$,E,M)}function nG(N,F,A,M){if(A.key==="Delete")return S8(N);let D=iy(A,M);if(D){if(D==="moveToLineStart"||D==="moveToLineEnd")return z8(N,F.layout,D==="moveToLineStart"?"Home":"End",A.shiftKey);if(D==="moveToDocumentStart"||D==="moveToDocumentEnd")return G8(N,D==="moveToDocumentStart"?"start":"end",A.shiftKey);switch(D){case"insertLineBreak":return Z3(N);case"insertSoftLineBreak":return O7(N);case"deleteBackward":return Q8(N);case"indent":return q3(N);case"dedent":return U3(N);case"moveListItemUp":return v7(N);case"moveListItemDown":return m7(N);case"toggleBold":return X3(N);case"toggleItalic":return Q3(N);case"toggleStrikethrough":return S3(N);case"toggleUnderline":return J3(N);case"toggleCode":return V3(N);case"undo":return J8(N);case"redo":return V8(N);case"selectAll":return T7(N)}}if(A.key==="ArrowLeft"||A.key==="ArrowRight")return q8(N,A.key==="ArrowLeft"?-1:1,A.shiftKey);if(A.key==="ArrowUp"||A.key==="ArrowDown")return U8(N,F.layout,A.key==="ArrowUp"?-1:1,A.shiftKey);if(A.key==="PageUp"||A.key==="PageDown")return K8(N,F.layout,A.key==="PageUp"?-1:1,A.shiftKey);if(A.key.length===1&&!A.altKey&&!A.ctrlKey&&!A.metaKey)return eN(N,A.key);return null}import{useEffect as tG,useEffectEvent as B2,useRef as AZ}from"react";function MZ(){return{fullRender:!1,fullPaint:!1,contentPaint:!1,overlayPaint:!1}}function DZ({hasRunningOptionalContentAnimations:N,isActive:F,renderContent:A,renderOverlay:M,renderViewport:D}){let E=x0(),$=AZ(null),y=AZ(MZ()),Z=B2(()=>{if(typeof window>"u"){D();return}y.current.fullRender=!0,S()}),Y=B2(()=>{if(typeof window>"u"){A(),M();return}y.current.fullPaint=!0,S()}),X=B2(()=>{if(typeof window>"u"){A();return}y.current.contentPaint=!0,S()}),Q=B2(()=>{if(typeof window>"u"){M();return}y.current.overlayPaint=!0,S()}),S=B2(()=>{if(typeof window>"u"||$.current!==null)return;$.current=window.requestAnimationFrame(()=>{J()})}),J=B2(()=>{$.current=null;let K=y.current,q=K.fullRender,U=K.fullPaint,z=K.contentPaint,G=K.overlayPaint;if(y.current=MZ(),q){D(),V();return}if(U){A(),M(),V();return}if(z)A(),V();if(G)M()}),V=B2(()=>{if(O5(E.editor.getState(),performance.now())){y.current.contentPaint=!0,S();return}if(F?.()===!0||N?.()!==!0)return;y.current.contentPaint=!0,S()});return tG(()=>{return()=>{if(typeof window>"u"||$.current===null)return;window.cancelAnimationFrame($.current),$.current=null}},[]),{scheduleContentPaint:X,scheduleFullPaint:Y,scheduleFullRender:Z,scheduleOverlayPaint:Q}}import{useEffectEvent as bA,useRef as fA,useState as eG}from"react";function EZ({autoScrollDuringDrag:N,isEditable:F,focusInput:A,onActivity:M,resolvePoint:D}){let[E,$]=eG(null),y=e(NA),Z=e(FA,E),Y=h(L0),X=h(AF),Q=fA(null),S=fA(null),J=fA(null),V=bA((G,H=!0)=>{if(Z?.kind!=="annotation")return;$({anchor:Z.anchor,animateInitialComment:H,leftOverride:Z.leftOverride,paddingY:Z.paddingY,selection:Z.selection,threadIndex:G})}),K=bA((G)=>{if(G&&J.current===G.pointerId&&G.currentTarget.hasPointerCapture(G.pointerId))G.currentTarget.releasePointerCapture(G.pointerId);Q.current=null,S.current=null,J.current=null}),q=bA((G)=>{let H=S.current,B=D(G);if(!B||!H||J.current!==G.pointerId||!y.viewport)return;if(!X(y.viewport,B,H))return;G.preventDefault(),G.stopPropagation(),M(),N(G)}),U=(G)=>({onPointerCancel:(H)=>{K(H)},onPointerDown:(H)=>{let B=NH(y.normalized,G),_=G==="start"?y.normalized.start:y.normalized.end;if(!y.handles)return;H.preventDefault(),H.stopPropagation(),J.current=H.pointerId,S.current=B,Q.current=G,H.currentTarget.setPointerCapture(H.pointerId),M(),A(),Y({anchor:B,focus:_})},onPointerMove:(H)=>{if(Q.current!==G)return;q(H)},onPointerUp:(H)=>{if(Q.current===G)q(H);K(H)}});return{handle:y.handles?{start:{...y.handles.start,props:U("start")},end:{...y.handles.end,props:U("end")}}:null,leaf:F?Z:null,promoteLeafToThread:V}}function NH(N,F){return F==="start"?N.end:N.start}import{useEffect as FH,useMemo as ZZ,useState as AH}from"react";var pF={activeBlockBackground:"#fff1c7",activeBlockFlash:"rgba(245, 158, 11, 0.28)",background:"#fcfbf7",blockquoteRule:"rgba(14, 116, 144, 0.2)",blockquoteRuleActive:"rgba(124, 45, 18, 0.36)",blockquoteText:"#334155",caret:"#111827",checkboxCheckmark:"#f8fafc",checkboxCheckedFill:"#0f766e",checkboxCheckedStroke:"#0f766e",checkboxUncheckedFill:"#fcfffe",checkboxUncheckedStroke:"#64748b",codeBackground:"#0f172a",codeText:"#e2e8f0",commentHighlight:"#d7e3fc",commentHighlightActive:"#f4d35e",commentHighlightResolved:"#cfe9d8",commentHighlightResolvedActive:"#8dc4a0",headingRule:"rgba(15, 23, 42, 0.18)",headingText:"#0f172a",imageLoadingOverlay:"rgba(255, 255, 255, 0.42)",imagePlaceholderIcon:"rgba(14, 116, 144, 0.42)",imagePlaceholderText:"rgba(15, 23, 42, 0.58)",imageSurfaceBackground:"rgba(240, 249, 255, 0.98)",imageSurfaceBorder:"rgba(14, 116, 144, 0.22)",inlineCodeBackground:"rgba(15, 23, 42, 0.08)",inlineCodeText:"#7c2d12",insertHighlightText:"#2563eb",leafAccent:"#1d4ed8",leafBackground:"#fcfbf7",leafBorder:"rgba(148, 163, 184, 0.55)",leafButtonBackground:"rgba(15, 23, 42, 0.08)",leafButtonBorder:"rgba(148, 163, 184, 0.55)",leafButtonText:"#1f2937",leafResolvedBackground:"#cfe9d8",leafResolvedBorder:"#8dc4a0",leafSecondaryText:"#334155",leafShadow:"0 14px 40px rgba(15, 23, 42, 0.16)",leafText:"#1f2937",linkText:"#1d4ed8",paddingX:16,paddingY:12,paragraphText:"#1f2937",selectionBackground:"rgba(125, 211, 252, 0.35)",selectionHandleBackground:"#fcfbf7",selectionHandleBorder:"#1d4ed8",tableBodyBackground:"rgba(248, 250, 252, 0.98)",tableBorder:"rgba(148, 163, 184, 0.55)",tableHeaderBackground:"rgba(226, 232, 240, 0.95)"},xF={activeBlockBackground:"rgba(125, 211, 252, 0.12)",activeBlockFlash:"rgba(226, 232, 240, 0.12)",background:"#0b1220",blockquoteRule:"rgba(103, 232, 249, 0.34)",blockquoteRuleActive:"rgba(125, 211, 252, 0.5)",blockquoteText:"#cbd5e1",caret:"#f8fafc",checkboxCheckmark:"#082f49",checkboxCheckedFill:"#67e8f9",checkboxCheckedStroke:"#67e8f9",checkboxUncheckedFill:"#0f172a",checkboxUncheckedStroke:"#64748b",codeBackground:"#020617",codeText:"#dbeafe",commentHighlight:"rgba(96, 165, 250, 0.34)",commentHighlightActive:"#facc15",commentHighlightResolved:"rgba(74, 222, 128, 0.24)",commentHighlightResolvedActive:"#4ade80",headingRule:"rgba(226, 232, 240, 0.22)",headingText:"#f8fafc",imageLoadingOverlay:"rgba(186, 230, 253, 0.18)",imagePlaceholderIcon:"rgba(125, 211, 252, 0.44)",imagePlaceholderText:"rgba(226, 232, 240, 0.62)",imageSurfaceBackground:"rgba(15, 23, 42, 0.92)",imageSurfaceBorder:"rgba(56, 189, 248, 0.28)",inlineCodeBackground:"rgba(251, 191, 36, 0.16)",inlineCodeText:"#fdba74",insertHighlightText:"#60a5fa",leafAccent:"#93c5fd",leafBackground:"#0b1220",leafBorder:"rgba(100, 116, 139, 0.7)",leafButtonBackground:"rgba(148, 163, 184, 0.16)",leafButtonBorder:"rgba(100, 116, 139, 0.7)",leafButtonText:"#dbe4f0",leafResolvedBackground:"rgba(74, 222, 128, 0.24)",leafResolvedBorder:"#4ade80",leafSecondaryText:"#cbd5e1",leafShadow:"0 18px 44px rgba(2, 6, 23, 0.42), 0 0 0 1px rgba(148, 163, 184, 0.06)",leafText:"#dbe4f0",linkText:"#93c5fd",paddingX:16,paddingY:12,paragraphText:"#dbe4f0",selectionBackground:"rgba(56, 189, 248, 0.28)",selectionHandleBackground:"#0b1220",selectionHandleBorder:"#93c5fd",tableBodyBackground:"rgba(15, 23, 42, 0.9)",tableBorder:"rgba(100, 116, 139, 0.7)",tableHeaderBackground:"rgba(30, 41, 59, 0.96)"},$Z={...pF,activeBlockBackground:"rgba(16, 185, 129, 0.14)",activeBlockFlash:"rgba(16, 185, 129, 0.26)",background:"#f3fbf6",blockquoteRule:"rgba(5, 150, 105, 0.22)",blockquoteRuleActive:"rgba(6, 95, 70, 0.38)",blockquoteText:"#166534",caret:"#14532d",codeBackground:"#052e16",codeText:"#dcfce7",commentHighlight:"rgba(52, 211, 153, 0.26)",commentHighlightActive:"#10b981",commentHighlightResolved:"rgba(187, 247, 208, 0.96)",commentHighlightResolvedActive:"#059669",headingRule:"rgba(20, 83, 45, 0.18)",headingText:"#14532d",inlineCodeBackground:"rgba(20, 83, 45, 0.08)",inlineCodeText:"#166534",insertHighlightText:"#10b981",leafAccent:"#059669",leafBackground:"#f3fbf6",leafBorder:"rgba(22, 163, 74, 0.24)",leafButtonBackground:"rgba(20, 83, 45, 0.08)",leafButtonBorder:"rgba(22, 163, 74, 0.28)",leafButtonText:"#14532d",leafResolvedBackground:"#d1fae5",leafResolvedBorder:"#10b981",leafSecondaryText:"#166534",leafShadow:"0 14px 40px rgba(20, 83, 45, 0.14)",leafText:"#14532d",linkText:"#047857",paragraphText:"#14532d",selectionBackground:"rgba(52, 211, 153, 0.24)",selectionHandleBackground:"#f3fbf6",selectionHandleBorder:"#059669",tableBodyBackground:"rgba(243, 251, 246, 0.96)",tableBorder:"rgba(22, 163, 74, 0.24)",tableHeaderBackground:"rgba(220, 252, 231, 0.96)"},yZ={...xF,activeBlockBackground:"rgba(168, 85, 247, 0.16)",activeBlockFlash:"rgba(243, 232, 255, 0.13)",blockquoteRule:"rgba(196, 181, 253, 0.34)",blockquoteRuleActive:"rgba(216, 180, 254, 0.44)",caret:"#f5f3ff",codeBackground:"#1e1b4b",codeText:"#ede9fe",commentHighlight:"rgba(167, 139, 250, 0.28)",commentHighlightActive:"#c084fc",commentHighlightResolved:"rgba(45, 212, 191, 0.22)",commentHighlightResolvedActive:"#2dd4bf",headingRule:"rgba(233, 213, 255, 0.24)",headingText:"#f5f3ff",inlineCodeBackground:"rgba(196, 181, 253, 0.16)",inlineCodeText:"#f9a8d4",insertHighlightText:"#c084fc",leafAccent:"#d8b4fe",leafBackground:"#12091f",leafBorder:"rgba(139, 92, 246, 0.34)",leafButtonBackground:"rgba(196, 181, 253, 0.16)",leafButtonBorder:"rgba(139, 92, 246, 0.34)",leafButtonText:"#ede9fe",leafResolvedBackground:"rgba(45, 212, 191, 0.22)",leafResolvedBorder:"#2dd4bf",leafSecondaryText:"#ddd6fe",leafShadow:"0 20px 48px rgba(2, 6, 23, 0.48), 0 0 0 1px rgba(196, 181, 253, 0.08)",leafText:"#f5f3ff",linkText:"#d8b4fe",paragraphText:"#ede9fe",selectionBackground:"rgba(167, 139, 250, 0.26)",selectionHandleBackground:"#12091f",selectionHandleBorder:"#d8b4fe",tableBodyBackground:"rgba(30, 27, 75, 0.88)",tableBorder:"rgba(139, 92, 246, 0.34)",tableHeaderBackground:"rgba(49, 46, 129, 0.94)"};function YZ(N){let F=ZZ(()=>DH(N),[N]),[A,M]=AH(F.light),D=ZZ(()=>EH(A),[A]);return FH(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){M(F.light);return}let E=window.matchMedia("(prefers-color-scheme: dark)"),$=()=>{M(E.matches?F.dark:F.light)};if($(),typeof E.addEventListener==="function")return E.addEventListener("change",$),()=>{E.removeEventListener("change",$)};return E.addListener($),()=>{E.removeListener($)}},[F]),{theme:A,themeStyles:D}}function MH(N){return"light"in N&&"dark"in N}function DH(N){if(!N)return{dark:xF,light:pF};if(MH(N))return N;return{dark:N,light:N}}function EH(N){return{"--documint-background":N.background,"--documint-leaf-button-bg":N.leafButtonBackground,"--documint-leaf-button-border":N.leafButtonBorder,"--documint-leaf-button-text":N.leafButtonText,"--documint-leaf-accent":N.leafAccent,"--documint-leaf-bg":N.leafBackground,"--documint-leaf-border":N.leafBorder,"--documint-leaf-font-family":'"Avenir Next", "Segoe UI", sans-serif',"--documint-leaf-shadow":N.leafShadow??void 0,"--documint-leaf-secondary-text":N.leafSecondaryText,"--documint-leaf-resolved-bg":N.leafResolvedBackground,"--documint-leaf-resolved-border":N.leafResolvedBorder,"--documint-leaf-text":N.leafText,"--documint-mention-bg":N.mentionBackground??void 0,"--documint-mention-text":N.mentionText??void 0,"--documint-selection-handle-bg":N.selectionHandleBackground,"--documint-selection-handle-border":N.selectionHandleBorder}}import{useEffect as $H,useEffectEvent as P1,useRef as uA,useState as o3}from"react";function XZ(N,F){let A=F.getBoundingClientRect();return{x:N.clientX-A.left+F.scrollLeft,y:N.clientY-A.top+F.scrollTop}}var QZ=28,SZ=18;function JZ({renderResources:N,theme:F}){let A=x0(),M=uA(D2()),D=uA(null),E=uA({height:240,top:0}),[$,y]=o3(0),[Z,Y]=o3(240),[X,Q]=o3(0),[S,J]=o3(240),V=yH($),K=()=>{let L=A.editor.getState(),W=E.current;return X5(L,{height:W.height,paddingX:F.paddingX,paddingY:F.paddingY,top:W.top,width:V},M.current,N)};A.viewport.setViewportResolver(K);let q=A.viewport,U=P1((L)=>{A.viewport.observeViewport(L),J((W)=>{let v=YH(L,E.current.height);return W===v?W:v})}),z=P1((L)=>{E.current={...E.current,top:L},Q((W)=>W===L?W:L),q.invalidate()}),G=P1((L)=>{let W=ZH(L),v=W.top!==E.current.top;if(E.current=W,Q((g)=>g===W.top?g:W.top),v)q.invalidate()}),H=P1((L)=>{let W=D.current;if(!W)return z(L),L;W.scrollTop=L;let v=W.scrollTop;return z(v),v}),B=P1(()=>{return D.current?.scrollTop??E.current.top}),_=P1((L,W)=>{let v=L!==null&&L.documentIndex!==W.documentIndex,g=q.peek();if(!(!v||!g||g.layout.regionLineIndices.has(W.selection.focus.regionId)))q.invalidate()}),O=P1(()=>{q.invalidate()}),w=P1((L)=>{let W=D.current;return W?XZ(L,W):null}),b=P1((L)=>{let W=D.current;if(!W)return;let v=W.getBoundingClientRect();if(L.clientY<v.top+QZ){W.scrollTop=Math.max(0,W.scrollTop-SZ);return}if(L.clientY>v.bottom-QZ)W.scrollTop+=SZ});return $H(()=>{let L=D.current;if(!L||typeof ResizeObserver>"u")return;let W=new ResizeObserver((v)=>{let g=v[0];if(!g)return;let j=Math.max(0,Math.floor(g.contentRect.width)),P=VZ(L);E.current={...E.current,height:P},y((R)=>R===j?R:j),Y((R)=>R===P?R:P)});return W.observe(L),()=>W.disconnect()},[D]),{actions:{autoScrollDuringDrag:b,getScrollTop:B,invalidateViewport:O,observeViewport:U,observeScrollContainer:G,reconcileEditorState:_,resolvePoint:w,scrollTo:H},props:{scrollContent:{style:{height:`${S}px`}}},refs:{scrollContainer:D},state:{layoutWidth:V,scrollContentHeight:S,viewportLayout:q,viewportHeight:Z,viewportTop:X}}}function yH(N){return Math.max(240,Math.floor(N||480))}function VZ(N){return Math.max(240,N.clientHeight)}function ZH(N){return{height:VZ(N),top:N.scrollTop}}function YH(N,F){return Math.max(F,Math.ceil(N.totalHeight+24))}function XH(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function vA(N,{paintHeight:F,paintTop:A,width:M}){if(!N)return null;let D=Math.max(240,Math.ceil(F)),E=XH();N.width=Math.ceil(M*E),N.height=Math.ceil(D*E),N.style.width=`${M}px`,N.style.height=`${D}px`,N.style.transform=`translateY(${A}px)`;let $=N.getContext("2d");if(!$)return null;return{context:$,devicePixelRatio:E,height:D,width:M}}function mA(N,F){let A=[],M=new Set;for(let D of h3(N,F)){if(D.kind!=="token"||D.trigger!=="@"||!D.id)continue;if(M.has(D.id))continue;M.add(D.id),A.push(D.id)}return A}var qZ=/^(https?:|data:|blob:)/i;class kA{storage;view;constructor(N,F){this.storage=N;this.view=F}async readFile(N){if(qZ.test(N))try{let F=await fetch(N);return F.ok?F.blob():null}catch{return null}return this.storage?.readFile(N)??null}writeFile(N){if(!this.storage?.writeFile)throw Error("No storage configured");return this.storage.writeFile(N)}openFile(N){if(qZ.test(N))this.view?.open(N,"_blank","noopener,noreferrer");else this.storage?.openFile?.(N)}}function KZ(N,F){if(!N)return{didReconcile:!1,state:F};let A=QH(N,F)??HH(N,F);return A?{didReconcile:!0,state:A}:{didReconcile:!1,state:F}}function QH(N,F){let A=SH(N,F);return A?L0(F,A,!1):null}function SH(N,F){if(IA(N.selection.anchor,N.selection.focus)){let E=gA(N,F,N.selection.focus,"neutral");return E?{anchor:E,focus:E}:null}let A=zH(N),M=gA(N,F,N.selection.anchor,A.anchor),D=gA(N,F,N.selection.focus,A.focus);return M&&D?{anchor:M,focus:D}:null}function gA(N,F,A,M){let D=N.documentIndex.regionIndex.get(A.regionId);if(!D)return null;let E=hA(D,F);if(!E)return null;return{offset:VH(D.text,E.text,A.offset,M),regionId:E.id}}function hA(N,F){let A=F.documentIndex.regionIndex.get(N.id);if(A)return A;if(N.text.length===0)return null;let M=JH(N,F);if(M)return M;return F.documentIndex.regionPathIndex.get(N.path)??null}function JH(N,F){let A=null;for(let M of F.documentIndex.regions){if(M.blockType!==N.blockType||M.text!==N.text)continue;if(A)return null;A=M}return A}function VH(N,F,A,M){let D=n0(A,0,N.length),{prefix:E,suffix:$}=B4(N,D,D),y=qH(F,E,$);if(y!==null)return y;let Z=UH(F,E),Y=KH(F,$);if(M==="before-suffix")return Y??Z??n0(A,0,F.length);return Z??Y??n0(A,0,F.length)}function qH(N,F,A){let M=m2(N,F,A).filter((D)=>D.startOffset===D.endOffset);return M.length===1?M[0].startOffset:null}function UH(N,F){let A=X1(N,F);return A.length===1?A[0]+F.length:null}function KH(N,F){let A=X1(N,F);return A.length===1?A[0]:null}function zH(N){let{anchor:F,focus:A}=N.selection;if(IA(F,A))return{anchor:"neutral",focus:"neutral"};return GH(N,F,A)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function GH(N,F,A){let M=N.documentIndex.regionOrderIndex.get(F.regionId),D=N.documentIndex.regionOrderIndex.get(A.regionId);if(M===void 0||D===void 0)return 0;return M===D?F.offset-A.offset:M-D}function HH(N,F){if(!IA(N.selection.anchor,N.selection.focus))return null;let A=_H(N);if(!A)return null;let M=BH(N,F,A);if(M===null)return null;return PH(F,M)}function _H(N){let F=N.documentIndex.regionIndex.get(N.selection.focus.regionId);if(!F||F.blockType!=="paragraph"||F.text.length>0)return null;return N.documentIndex.blockIndex.get(F.blockId)?.parentBlockId===null?F:null}function BH(N,F,A){let M=UZ(N,A.rootIndex,"before"),D=UZ(N,A.rootIndex,"after"),E=M?hA(M,F):null,$=D?hA(D,F):null;if(E&&$)return E.rootIndex<$.rootIndex?$.rootIndex:null;if(E)return E.rootIndex+1;if($)return $.rootIndex;return null}function PH(N,F){let A=A2(N.documentIndex.document,F,0,[F0("")]),M={...N,documentIndex:s2(N.documentIndex,A,F,0)},D=pN(M.documentIndex,$0(F));return D?L0(M,D,!1):null}function UZ(N,F,A){let M=A==="before"?-1:1;for(let D=F+M;D>=0&&D<N.documentIndex.roots.length;D+=M){let E=WH(N,D,A);if(E)return E}return null}function WH(N,F,A){let M=N.documentIndex.roots[F]?.regions??[],D=A==="before"?M.length-1:0,E=A==="before"?-1:1;for(let $=D;$>=0&&$<M.length;$+=E){let y=M[$];if(y&&y.text.length>0)return y}return null}function IA(N,F){return N.regionId===F.regionId&&N.offset===F.offset}function GZ(N,F){let A=N.previous.documentIndex.regionIndex.get(F.regionId);if(!A)return null;let M=N.next.documentIndex.regionPathIndex.get(A.path);if(!M)return null;let D=N.previous.documentIndex.document,E=N.next.documentIndex.document,$=D.blocks[A.rootIndex],y=E.blocks[M.rootIndex];if(!$||!y)return null;let Z=OH($,y);if(!Z)return null;return{lineMarkdown:Z.lineMarkdown,lineNumber:wH(E,M.rootIndex)+Z.lineIndex}}function OH(N,F){let A=zZ(N),M=zZ(F),D=LH(A,M);if(D===null)return null;let E=M.lastIndexOf(`
35
+ `,Math.max(0,D-1))+1,$=M.indexOf(`
36
+ `,D);return{lineIndex:pA(M,E),lineMarkdown:M.slice(E,$===-1?M.length:$)}}function wH(N,F){let A=1;if(N.frontMatter!==void 0)A+=pA(N.frontMatter,N.frontMatter.length)+2;if(F>0){let M=G2({kind:"blocks",blocks:N.blocks.slice(0,F)});if(M.length>0)A+=pA(M,M.length)+2}return A}function zZ(N){return G2({kind:"blocks",blocks:[N]})}function LH(N,F){let A=Math.min(N.length,F.length);for(let M=0;M<A;M+=1)if(N[M]!==F[M])return M;return N.length===F.length?null:A}function pA(N,F){let A=0;for(let M=0;M<F;M+=1)if(N[M]===`
37
+ `)A+=1;return A}import{jsx as n,jsxs as t3,Fragment as vH}from"react/jsx-runtime";function e3({blocks:N}){return n(vH,{children:N.map((F)=>TH(F))})}function TH(N){switch(N.type){case"blockquote":return n("blockquote",{className:"preview-block preview-block-blockquote",children:n(e3,{blocks:N.children})},N.id);case"code":return t3("div",{className:"preview-block preview-block-code",children:[n("div",{className:"preview-rich-header",children:RH(N.language,N.meta)}),n("pre",{children:n("code",{children:N.source||" "})})]},N.id);case"heading":{let F=`h${N.depth}`;return n(F,{className:"preview-block preview-block-heading",children:n3(N.children)},N.id)}case"list":return N.ordered?n("ol",{className:"preview-block preview-block-list",start:N.start??1,children:N.items.map((F)=>xA(F))},N.id):n("ul",{className:"preview-block preview-block-list",children:N.items.map((F)=>xA(F))},N.id);case"listItem":return xA(N);case"paragraph":return n("p",{className:"preview-block preview-block-paragraph",children:n3(N.children)},N.id);case"table":return t3("div",{className:"preview-block preview-block-table",children:[n("div",{className:"preview-rich-header",children:bH(N.rows.length,N.rows[0]?.cells.length??0,N.align.filter((F)=>F!==null).length)}),n("div",{className:"preview-table-scroll",children:n("table",{children:n("tbody",{children:N.rows.map((F)=>n("tr",{children:F.cells.map((A)=>n("td",{children:n3(A.children)},A.id))},F.id))})})})]},N.id);case"divider":return n("hr",{className:"preview-block preview-block-rule"},N.id);case"directive":return n("pre",{className:`preview-block preview-block-directive preview-block-directive-${N.name}`,children:N.body},N.id);case"raw":return n("pre",{className:"preview-block preview-block-unsupported",children:N.source},N.id)}}function xA(N){return n("li",{className:"preview-block preview-block-list-item",children:n(e3,{blocks:N.children})},N.id)}function n3(N){return N.map((F)=>{switch(F.type){case"lineBreak":return n("br",{},F.id);case"image":return t3("span",{className:"preview-inline preview-inline-image",children:[n("img",{alt:F.alt??"",src:F.url,title:F.title??""}),t3("span",{children:[n("strong",{children:fH(F.alt)}),n("small",{children:uH(F.url,F.title)})]})]},F.id);case"code":return n("code",{className:"preview-inline preview-inline-code",children:F.code},F.id);case"link":return CH(F);case"text":return n("span",{className:"preview-inline",children:jH(F.text,F.marks)},F.id);case"raw":return n("span",{className:"preview-inline preview-inline-unsupported",children:F.source},F.id)}})}function CH(N){return n("a",{className:"preview-inline preview-inline-link",href:N.url,children:n3(N.children)},N.id)}function jH(N,F){let A=N;for(let M of F)switch(M){case"strikethrough":A=n("del",{children:A});break;case"italic":A=n("em",{children:A});break;case"bold":A=n("strong",{children:A});break;case"underline":A=n("ins",{children:A});break}return A}function RH(N,F){return[N??"plain text",F].filter(Boolean).join(" • ")}function bH(N,F,A){let M=A>0?`${A} aligned ${A===1?"column":"columns"}`:"no alignment";return`${N} ${N===1?"row":"rows"} • ${F} ${F===1?"column":"columns"} • ${M}`}function fH(N){return N?.trim()?N:"Untitled image"}function uH(N,F){return F?.trim()?`${F} • ${N}`:N}import{useEffect as dA,useEffectEvent as F4,useMemo as CZ,useRef as aA,useState as hH}from"react";function _Z(N,F){return(F??N.blocks.map((M,D)=>D)).flatMap((M)=>{let D=N.blocks[M];return D?[{block:D,rootIndex:M,sourceKey:PZ(D)}]:[]})}function BZ(N,F,A){return C8(N,F,A.flatMap((M)=>{let D=N.documentIndex.document.blocks[M.rootIndex];if(!D||PZ(D)!==M.sourceKey)return[];return[{ranges:M.ranges,rootIndex:M.rootIndex}]}))}var HZ=new WeakMap,mH=1;function PZ(N){let F=HZ.get(N);if(F===void 0)F=String(mH++),HZ.set(N,F);return F}function N4(N){return Boolean(N.backgroundColor||N.color)}function WZ(N){return N.filter(N4).map(({backgroundColor:F,pulse:A,color:M,pattern:D})=>({backgroundColor:F,...F&&A&&{pulse:!0},color:M,flags:D.flags.replace(/g|y/g,""),source:D.source}))}function OZ(N){return N.filter(N4).map(({backgroundColor:F,pulse:A,color:M,pattern:D})=>`${D.source}:${D.flags}:${M??""}:${F??""}:${F&&A?1:0}`).join("|")}var lA='function U(y,u){return`${y}.${u}`}function q(y){return`${y}.children`}function W(y,u){return U(y,u)}function J(y,u){return`${y}.rows.${u}`}function V(y,u){return`${y}.cells.${u}`}function j(y,u,D={}){E(y,u,z(),T(D.pathPrefix??"root",D.startIndex??0))}function E(y,u,D,A){for(let[R,S]of y.entries()){if(D.stopped)return;let $=U(A.pathPrefix,A.startIndex+R),m={blockAncestors:A.blockAncestors,depth:A.depth,parentBlock:A.parentBlock,path:$},g=u.enterBlock?.(S,m);if(K(g,D))return;if(g!=="skip")switch(S.type){case"list":Q(S.items,S,u,D,A,$);break;case"blockquote":case"listItem":Q(S.children,S,u,D,A,$);break;case"heading":case"paragraph":H(S.children,u,D,{block:S,blockAncestors:[...A.blockAncestors,S],container:S,kind:"block",path:q($)});break;case"table":O(S,u,D,{blockAncestors:[...A.blockAncestors,S],pathPrefix:$});break;case"code":case"directive":case"divider":case"raw":break}if(D.stopped)return;if(K(u.leaveBlock?.(S,m),D))return}}function M(y,u,D,A){for(let[R,S]of y.entries()){if(D.stopped)return;let $=W(A.pathPrefix,R),m={block:A.block,blockAncestors:A.blockAncestors,inlineAncestors:A.inlineAncestors,parentInline:A.parentInline,path:$},g=u.enterInline?.(S,m);if(K(g,D))return;if(g!=="skip"){if(S.type==="link")N(S.children,S,u,D,A,$)}if(D.stopped)return;if(K(u.leaveInline?.(S,m),D))return}}function z(){return{stopped:!1}}function T(y,u){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:y,startIndex:u}}function Q(y,u,D,A,R,S){E(y,D,A,{blockAncestors:[...R.blockAncestors,u],depth:R.depth+1,parentBlock:u,pathPrefix:q(S),startIndex:0})}function N(y,u,D,A,R,S){M(y,D,A,{block:R.block,blockAncestors:R.blockAncestors,inlineAncestors:[...R.inlineAncestors,u],parentInline:u,pathPrefix:q(S)})}function O(y,u,D,A){for(let[R,S]of y.rows.entries())for(let[$,m]of S.cells.entries()){if(D.stopped)return;let g=V(J(A.pathPrefix,R),$),Y={blockAncestors:A.blockAncestors,cellIndex:$,path:g,row:S,rowIndex:R,table:y},Z=u.enterTableCell?.(m,Y);if(K(Z,D))return;if(Z!=="skip")H(m.children,u,D,{block:y,blockAncestors:A.blockAncestors,container:m,kind:"tableCell",path:g});if(D.stopped)return;if(K(u.leaveTableCell?.(m,Y),D))return}}function H(y,u,D,A){let R=u.enterInlineContainer?.(y,A);if(K(R,D)||R==="skip")return;if(v(y,u,D,A),D.stopped)return;M(y,u,D,{block:A.block,blockAncestors:A.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:B(A)})}function B(y){return y.kind==="tableCell"?q(y.path):y.path}function v(y,u,D,A){if(!u.enterPlainText)return;let R=0;for(let S of y){if(D.stopped)return;if(S.type==="text"){let $=R,m=$+S.text.length;if(S.marks.length===0&&K(u.enterPlainText(S.text,{...A,endOffset:m,startOffset:$}),D))return;R=m;continue}R+=X(S)}}function X(y){switch(y.type){case"lineBreak":return 1;case"image":case"mention":return 1;case"code":return y.code.length;case"raw":return y.source.length;case"text":return y.text.length;case"link":return y.children.reduce((u,D)=>u+X(D),0)}}function K(y,u){if(y!=="stop")return!1;return u.stopped=!0,!0}function _(y){return Boolean(y.backgroundColor||y.color)}function w(y){return y.map(({backgroundColor:u,pulse:D,color:A,flags:R,source:S})=>({backgroundColor:u,...u&&D&&{pulse:!0},color:A,pattern:new RegExp(S,R.includes("g")?R:`${R}g`)}))}function C(y,u,D){if(D.length===0)return[];let A=f(D),R=[];return j([y],{enterPlainText(S,$){for(let m of b(S,A))R.push({...G(m),endOffset:$.startOffset+m.end,path:$.path,startOffset:$.startOffset+m.start})}},{startIndex:u}),R.sort((S,$)=>S.startOffset-$.startOffset)}function f(y){return y.filter(_).map(({backgroundColor:u,pulse:D,color:A,pattern:R})=>({regex:new RegExp(R.source,I(R.flags)),style:{backgroundColor:u,...u&&D&&{pulse:!0},color:A}}))}function I(y){return`${y.replace(/[gyd]/g,"")}g`}function b(y,u){let D=Array.from({length:y.length},()=>({}));for(let{regex:A,style:R}of u){A.lastIndex=0;let S;while((S=A.exec(y))!==null){let $=k(S);if(!$||$.end<=$.start){A.lastIndex=S.index+1;continue}for(let m=$.start;m<$.end;m+=1){let g=D[m];if(R.color&&!g.color)g.color=R.color;if(R.backgroundColor&&!g.backgroundColor){if(g.backgroundColor=R.backgroundColor,R.pulse)g.pulse=!0}}}}return x(D)}function k(y){if(y.length<=1)return{end:y.index+y[0].length,start:y.index};for(let u=1;u<y.length;u+=1){let D=y[u];if(!D)continue;let A=y[0].indexOf(D);if(A!==-1){let R=y.index+A;return{end:R+D.length,start:R}}}return null}function G(y){return{...y.backgroundColor&&{backgroundColor:y.backgroundColor},...y.color&&{color:y.color},...y.backgroundColor&&y.pulse&&{pulse:!0}}}function x(y){let u=[],D=-1,A=null;for(let R=0;R<y.length;R+=1){let S=p(y[R])?y[R]:null;if(S&&D===-1){D=R,A=S;continue}if(!r(S,A)&&D!==-1)u.push({...G(A),end:R,start:D}),D=S?R:-1,A=S}if(D!==-1)u.push({...G(A),end:y.length,start:D});return u}function p(y){return Boolean(y.backgroundColor||y.color)}function r(y,u){return(y?.color??null)===(u?.color??null)&&(y?.backgroundColor??null)===(u?.backgroundColor??null)&&Boolean(y?.backgroundColor&&y.pulse)===Boolean(u?.backgroundColor&&u.pulse)}var L=[],F="";self.addEventListener("message",(y)=>{let u=y.data;if(u.kind==="configure-decorations"){L=w(u.rules),F=u.rulesKey;return}if(u.kind!=="apply-decorations")return;try{if(u.rulesKey!==F)throw Error("Decoration worker rules are not configured.");let D=h(u.roots,L),A={kind:"decoration-result",requestId:u.requestId,roots:D,rulesKey:u.rulesKey};self.postMessage(A)}catch(D){let A={kind:"decoration-error",message:D instanceof Error?D.message:"Unknown decoration worker error.",requestId:u.requestId,rulesKey:u.rulesKey};self.postMessage(A)}});function h(y,u){return y.map((D)=>({ranges:C(D.block,D.rootIndex,u),rootIndex:D.rootIndex,sourceKey:D.sourceKey}))}\n';var kH=2000;class wZ extends Error{constructor(){super("Decoration worker disposed.");this.name="DecorationWorkerDisposedError"}}function LZ(N){return N instanceof Error&&N.name==="DecorationWorkerDisposedError"}function TZ(N={}){let F=(N.createWorker??gH)();if(!F)return null;let A=F,M=N.timeoutMs??kH,D=!1,E="",$=1,y=new Map;function Z(Y){if(D)return;D=!0,A.terminate();for(let[X,Q]of y)y.delete(X),clearTimeout(Q.timeoutId),Q.reject(Y)}return A.addEventListener("message",(Y)=>{let X=Y.data,Q=y.get(X.requestId);if(!Q)return;if(y.delete(X.requestId),clearTimeout(Q.timeoutId),X.kind==="decoration-error"){Q.reject(Error(X.message));return}Q.resolve({roots:X.roots,rulesKey:X.rulesKey})}),A.addEventListener("error",(Y)=>{Z(Error(Y.message||"Decoration worker failed."))}),{dispose(){Z(new wZ)},run(Y){if(D)return Promise.reject(Error("Decoration worker terminated."));let X=$++;if(E!==Y.rulesKey)A.postMessage({kind:"configure-decorations",rules:WZ(Y.rules),rulesKey:Y.rulesKey}),E=Y.rulesKey;let Q={kind:"apply-decorations",requestId:X,roots:Y.roots,rulesKey:Y.rulesKey};return new Promise((S,J)=>{let V=setTimeout(()=>{Z(Error("Decoration worker job timed out."))},M);y.set(X,{reject:J,resolve:S,timeoutId:V}),A.postMessage(Q)})}}}function gH(){if(typeof Worker>"u"||typeof Blob>"u"||typeof URL>"u"||lA.trim().length===0)return null;try{let N=new Blob([lA],{type:"application/javascript"}),F=URL.createObjectURL(N),A=new Worker(F,{type:"module"});return URL.revokeObjectURL(F),A}catch(N){return null}}var IH=220,jZ=[],qN=new Map;function RZ({contentDocument:N,decorations:F,store:A}){let M=aA(null),D=aA(null),E=aA(null),$=CZ(()=>{let q=F?.filter(N4)??jZ;return q.length===0?jZ:q},[F]),y=$.length>0,Z=CZ(()=>OZ($),[$]),[Y,X]=hH(()=>qN),Q=()=>{if(E.current!==null)clearTimeout(E.current),E.current=null;D.current=null},S=F4((q)=>{if(q.rulesKey!==Z||q.roots.length===0)return;X((U)=>{return BZ(A.editor.getState(),U,q.roots)??U})}),J=F4((q,U=!1)=>{if(U)Q();if(!y){X((B)=>B.size===0?B:qN);return}let z=A.editor.getState(),G=_Z(z.documentIndex.document,q);if(G.length===0){X((B)=>B.size===0?B:qN);return}let H=M.current??TZ();if(!H){X((B)=>B.size===0?B:qN);return}M.current=H,H.run({roots:G,rules:$,rulesKey:Z}).then(S).catch((B)=>{if(LZ(B))return;if(M.current===H)M.current=null;X((_)=>_.size===0?_:qN)})}),V=F4(()=>{let q=D.current;if(D.current=null,E.current=null,!q||q.size===0)return;J([...q])}),K=F4((q)=>{if(!y)return;if(!q.documentChanged||q.changedRootIndexes.length===0)return;let U=D.current??new Set;D.current=U;for(let z of q.changedRootIndexes)U.add(z);if(E.current!==null)clearTimeout(E.current);E.current=setTimeout(V,IH)});return dA(()=>{return()=>{Q(),M.current?.dispose(),M.current=null}},[]),dA(()=>{if(y)return;Q(),M.current?.dispose(),M.current=null,X((q)=>q.size===0?q:qN)},[y]),dA(()=>{if(!y)return;J(void 0,!0)},[N,Z,y]),{scheduleDecorationsForTransition:K,textDecorations:Y}}var bZ=`/* Base Documint host and SSR-fallback styles. */
37
38
 
38
39
  .documint {
39
40
  display: grid;
@@ -101,10 +102,9 @@ ${F.text}`:F.text}function RY(N){return N.filter((F)=>F.regions.length>0).map((F
101
102
  display: block;
102
103
  width: 100%;
103
104
  outline: none;
104
- /* Let the browser handle native pan (scrolling) on touch and eliminate the
105
- historical 300ms tap delay. Double-tap zoom is suppressed on the canvas
106
- (we want \`dblclick\` for word-select), but pinch-zoom and pan are kept. */
107
- touch-action: manipulation;
105
+ /* Let the browser keep vertical scrolling and pinch-zoom while exposing
106
+ horizontal swipes to the editor's touch gesture handling. */
107
+ touch-action: pan-y pinch-zoom;
108
108
  }
109
109
 
110
110
  .documint-overlay-canvas {
@@ -369,7 +369,7 @@ ${F.text}`:F.text}function RY(N){return N.filter((F)=>F.regions.length>0).map((F
369
369
  white-space: nowrap;
370
370
  }
371
371
  }
372
- `;var KZ=`/* Leaf overlay styles, ordered outer → inner:
372
+ `;var fZ=`/* Leaf overlay styles, ordered outer → inner:
373
373
  1. Anchor — viewport positioning + hover bridge
374
374
  2. Shell — bordered container (with state and content variants)
375
375
  3. Menu — shared dropdown surface (toolbar menus, completion popover)
@@ -967,7 +967,7 @@ ${F.text}`:F.text}function RY(N){return N.filter((F)=>F.regions.length>0).map((F
967
967
  font-weight: 500;
968
968
  white-space: nowrap;
969
969
  }
970
- `;var GZ=`/* Toolbar-specific styles (button, group, divider, and the menu trigger
970
+ `;var uZ=`/* Toolbar-specific styles (button, group, divider, and the menu trigger
971
971
  shell + chevron). The menu container/item/divider styles themselves
972
972
  live one level up in \`overlays/leaves/styles.css\` as \`.documint-leaf-menu*\`
973
973
  so they can be shared by the toolbar's nested menu and other surfaces
@@ -1055,6 +1055,6 @@ ${F.text}`:F.text}function RY(N){return N.filter((F)=>F.regions.length>0).map((F
1055
1055
  transform: rotate(180deg);
1056
1056
  }
1057
1057
  }
1058
- `;var yZ=`${VZ}
1059
- ${KZ}
1060
- ${GZ}`;import{jsx as $0,jsxs as W3,Fragment as OS}from"react/jsx-runtime";function _Z({content:N,...F}){let M=n2(null),A=o2(()=>JF(N),[N]);if(!M.current)M.current=j$(A);return $0(V5,{store:M.current,children:$0(WS,{content:N,...F,contentDocument:A})})}function WS({actions:N,className:F,content:M,keybindings:A,onCommentChanged:D,onContentChanged:E,onUserMentioned:$,presence:Z,storage:Y,theme:X,users:Q,contentDocument:J}){let q=n2(null),U=n2(null),V=n2(null),y=n2(M),G=n2(""),K=v0(),S=N0(J0),[_,H]=BS(!1),{theme:B,themeStyles:z}=MZ(X),j=o2(()=>A3(J),[J]),C=o2(()=>new l5(Y,typeof window<"u"?window:null),[Y]),L=u$(C),W=L.resources,O=o2(()=>[...W?.images.values()??[]].some((T)=>T.status==="loading"),[W]);G.current||=j;let v=$Z({renderResources:W,theme:B}),{actions:m,props:d,refs:P,state:f}=v,{autoScrollDuringDrag:b,getScrollTop:u,invalidateViewport:o,observeViewport:R,observeScrollContainer:k,reconcileEditorState:r,resolvePoint:D0,scrollTo:w}=m,{layoutWidth:p,scrollContentHeight:s,viewportLayout:i,viewportHeight:k0,viewportTop:z0}=f,{scrollContainer:t2}=P,e2=N0(w5),PF=N0(c2),m0=N0(n0),p0=Boolean(E),G1=N0(L5,Q),P3=o2(()=>{return p0?G1:void 0},[G1,p0]),O3=k1(({target:T,transition:g,userId:x})=>{let M0=UZ(g,T);if(!M0)return;let Z0={...M0,userId:x};$?.(Z0)}),Y2=v$({completionSources:P3,enabled:p0,onMentionAccepted:O3}),L3=o2(()=>YZ(Q,Z),[Q,Z]),T3=N0(C5),y1=()=>K.editor.getState(),K0=PS(N?.selection),NN=()=>{let T=TN(K.editor.getState());return T?bF(T):""},zZ=k1((T)=>{if(!T)return;if(T.source==="external")return;if(r(T.previous,T.next),T.animationsChanged)e5();if(!T.documentChanged)return;let g=A1(T.next),x=A3(g);G.current=x,y.current=x,E?.(x,g)});SZ(()=>{return K.editor.subscribe(zZ)},[K]);let HZ=I(LN),BZ=I(HM),WZ=I(WM),PZ=I(OM),OZ=I(LM),LZ=I(BM),TZ=I(PM),wZ=I(JM),jZ=I(QM),CZ=I(TM),RZ=I(q6),bZ=I(U6),fZ=I(V6),vZ=I(K6),hZ=I(CM),kZ=I(RM),mZ=I(jM),gZ=I(wM),uZ=I(bM),w3=(T)=>{D?.(T)},i5=(T)=>{let g=A1(y1()).comments[T],x=g?.comments.at(-1);if(!g||!x)return;w3({kind:"added",comment:x,mentionedUserIds:x5(x.body,G1),thread:g,threadIndex:T})},IZ=(T,g,x)=>{let M0=A1(y1()).comments[T],Z0=M0?.comments[g];if(!M0||!Z0)return;w3({kind:"edited",comment:Z0,previousBody:x,mentionedUserIds:x5(Z0.body,G1),thread:M0,threadIndex:T})},o5=(T,g,x)=>{w3({kind:"deleted",comment:x,thread:g,threadIndex:T})},n5=k1((T=i.peek())=>{if(!T)return;let g=p5(q.current,{paintHeight:T.paintHeight,paintTop:T.paintTop,width:p});if(!g)return;let{context:x,devicePixelRatio:M0,height:Z0,width:g1}=g;k8(S,T,x,{activeBlockId:e2.block?.blockId??null,activeRegionId:S.selection.focus.regionId,activeThreadIndex:M9??T3,devicePixelRatio:M0,height:Z0,liveCommentRanges:PF.liveRanges,normalizedSelection:m0,now:performance.now(),resources:W,theme:B,width:g1})}),t5=k1((T=i.peek())=>{if(!T)return;let g=p5(U.current,{paintHeight:T.paintHeight,paintTop:T.paintTop,width:p});if(!g)return;let{context:x,devicePixelRatio:M0,height:Z0,width:g1}=g;m8(S,T,x,{devicePixelRatio:M0,height:Z0,normalizedSelection:m0,presence:C3,showCaret:m0.start.regionId!==m0.end.regionId||m0.start.offset!==m0.end.offset||FN.isVisible(),theme:B,width:g1})}),pZ=k1(()=>{let T=i.get();R(T),n5(T),t5(T)}),{scheduleContentPaint:e5,scheduleFullPaint:xZ,scheduleFullRender:j3,scheduleOverlayPaint:N9}=n$({renderContent:n5,renderOverlay:t5,renderViewport:pZ}),F9=k1((T)=>{k(T),j3()}),lZ=k1((T)=>{F9(T.currentTarget)}),FN=f$({getScrollTop:u,isEditable:p0,layoutWidth:p,onVisibilityChange:N9,scrollContentHeight:s,scrollTo:w,viewportHeight:k0}),dZ=h$(W),OF=r$({enableTouchKeyDown:Y2.leaf!==null,inputRef:V,keybindings:A,onActivity:FN.markActivity,onBeforeInput:Y2.handleBeforeInput,onKeyDown:Y2.handleKeyDown,onImagePaste:L.persistImage}),S1=p$({autoScrollDuringDrag:b,canvasRef:q,focusInput:OF.focus,onActivity:FN.markActivity,resolvePoint:D0,storage:C}),M9=S1.leaf?.kind==="thread"?S1.leaf.threadIndex:null,C3=N0(R5,L3),aZ=k1((T)=>{if(!T.viewport||T.viewport.status==="unresolved")return;let g=t2.current;if(!g)return;g.scrollTop=T.viewport.scrollTop,F9(g)}),R3=t$({autoScrollDuringDrag:b,focusInput:OF.focus,isEditable:p0,onActivity:FN.markActivity,resolvePoint:D0}),m1=R3.handle??dZ;i2(()=>{o(),j3()},[S.documentIndex,p,B,W,k0]),i2(()=>{xZ()},[m0.end.offset,m0.end.regionId,m0.start.offset,m0.start.regionId,e2.block?.blockId]),i2(()=>{e5()},[T3,PF.liveRanges,M9]),i2(()=>{N9()},[C3]),i2(()=>{if(!O)return;let T=null,g=window,x=()=>{j3(),T=g.requestAnimationFrame(x)};return T=g.requestAnimationFrame(x),()=>{if(T!==null)g.cancelAnimationFrame(T)}},[O]);let t=R3.leaf??Y2.leaf??S1.leaf??FN.leaf,b3=(()=>{if(!t)return null;let T=j1(S,i.get(),t.anchor);if(!T)return null;let g=T.top+T.height,x=z0+k0;if(g<=z0||g>=x)return null;let M0=t2.current?.getBoundingClientRect(),Z0=typeof window<"u"?window.scrollX:0,g1=typeof window<"u"?window.scrollY:0,f3=t===S1.leaf;return{anchorHeight:T.height,bridge:f3,left:(M0?.left??0)+Z0+(t.leftOverride??T.left),onPointerEnter:f3?S1.leafHandlers.onPointerEnter:void 0,onPointerLeave:f3?S1.leafHandlers.onPointerLeave:void 0,paddingY:t.paddingY??0,top:(M0?.top??0)+g1+g-z0}})(),rZ=b3?(()=>{if(!t)return null;switch(t.kind){case"insertion":return $0(D$,{onInsert:(T)=>{HZ(T)},onInsertTable:(T)=>{BZ(T)}});case"table":return $0(Y$,{canDeleteColumn:t.columnCount>1,canDeleteRow:t.rowCount>1,onDeleteColumn:()=>{WZ()},onDeleteRow:()=>{PZ()},onDeleteTable:()=>{OZ()},onInsertColumn:(T)=>{LZ(T)},onInsertRow:(T)=>{TZ(T)}});case"link":return $0($$,{canEdit:p0,onDelete:()=>{wZ(t)},onSave:(T)=>{jZ(t,T)},title:t.title,url:t.url});case"annotation":{let T=K0.length>0?K0.map((g)=>({icon:g.icon,label:g.label,onClick:()=>{g.onClick(NN())}})):void 0;return $0(Z5,{activeMarks:t.activeMarks,canEdit:p0,link:null,mode:"create",completionSources:G1,onCreateThread:(g)=>{let x=y1(),M0=A1(x).comments.length;if(!CZ(t.selection,g.trim()))return;R3.promoteLeafToThread(M0,!0),i5(M0)},onToggleBold:()=>{RZ()},onToggleItalic:()=>{bZ()},onToggleStrikethrough:()=>{fZ()},onToggleUnderline:()=>{vZ()},actions:T})}case"thread":return $0(Z5,{animateInitialComment:t.animateInitialComment,canEdit:p0,link:t.link,mode:"thread",completionSources:G1,onDeleteComment:(T)=>{let{threadIndex:g}=t,x=y1(),M0=A1(x).comments[g],Z0=M0?.comments[T];if(!hZ(g,T))return;if(M0&&Z0)o5(g,M0,Z0)},onDeleteThread:()=>{let{threadIndex:T}=t,g=y1(),x=A1(g).comments[T];if(!kZ(T))return;if(x)for(let Z0 of x.comments)o5(T,x,Z0)},onEditComment:(T,g)=>{let{threadIndex:x}=t,M0=y1(),Z0=A1(M0).comments[x]?.comments[T]?.body;if(!mZ(x,T,g))return;if(Z0!==void 0)IZ(x,T,Z0)},onReply:(T)=>{let{threadIndex:g}=t;if(!gZ(g,T))return;i5(g)},onToggleResolved:()=>{uZ(t.threadIndex,!t.resolved)},thread:t.thread});case"completion":return $0(D3,{activeIndex:t.activeIndex,matches:t.matches,onHover:t.onHover,onSelect:t.onSelect})}})():null;i2(()=>{H(!0)},[]),SZ(()=>{if(M===y.current)return;let T=K.editor.getState(),g=JZ(T,w2(J)),x=g.state,M0=g.didReconcile?u():0;K.editor.replace(x,"external"),y.current=M,G.current=j,w(M0)},[j,M,J]);let cZ=F?`documint ${F}`:"documint";return $0(wE,{themeStyles:z,children:W3("section",{className:cZ,style:{...z,height:"100%",minHeight:0},children:[$0("style",{children:yZ}),W3("div",{ref:t2,onScroll:lZ,className:"documint-scroll-container",style:{height:"100%",minHeight:0},children:[$0("textarea",{...OF.inputHandlers,ref:V,autoCapitalize:"sentences",className:"documint-input",spellCheck:!1,tabIndex:-1,wrap:"off"}),$0(nD,{insetX:B.paddingX,insetY:B.paddingY,onSelect:aZ,presence:C3}),W3("div",{...d.scrollContent,className:"documint-scroll-content",children:[$0("canvas",{...OF.canvasHandlers,...S1.canvasHandlers,"aria-label":"Documint editor",className:"documint-content-canvas",style:{cursor:S1.cursor},ref:q,tabIndex:0}),$0("canvas",{"aria-hidden":"true",className:"documint-overlay-canvas",ref:U}),m1&&W3(OS,{children:[$0("div",{"aria-hidden":"true",className:"documint-resize-handle",style:{left:`${m1.start.left}px`,top:`${m1.start.top}px`},...m1.start.props,children:$0("span",{className:"documint-resize-handle-knob"})}),$0("div",{"aria-hidden":"true",className:"documint-resize-handle",style:{left:`${m1.end.left}px`,top:`${m1.end.top}px`},...m1.end.props,children:$0("span",{className:"documint-resize-handle-knob"})})]}),b3?$0(X3,{anchor:b3,children:rZ}):null]}),!_?$0("div",{className:"documint-fallback",children:$0(B3,{blocks:J.blocks})}):null]})]})})}function PS(N){if(!N)return[];return"onClick"in N?[N]:N}export{e$ as mintTheme,NZ as midnightTheme,BF as lightTheme,k5 as defaultKeybindings,WF as darkTheme,_Z as Documint};
1058
+ `;var vZ=`${bZ}
1059
+ ${fZ}
1060
+ ${uZ}`;import{jsx as X0,jsxs as A4,Fragment as cH}from"react/jsx-runtime";function kZ({content:N,...F}){let A=KN(null),M=lF(()=>jF(N),[N]);if(!A.current)A.current=Dy(M);return X0(c8,{store:A.current,children:X0(aH,{content:N,...F,contentDocument:M})})}function aH({actions:N,className:F,content:A,keybindings:M,decorations:D,onCommentChanged:E,onContentChanged:$,onUserMentioned:y,presence:Z,storage:Y,theme:X,users:Q,contentDocument:S}){let J=KN(null),V=KN(null),K=KN(null),q=KN(A),U=KN(""),z=x0(),G=e(K0),[H,B]=dH(!1),{theme:_,themeStyles:O}=YZ(X),w=lF(()=>u3(S),[S]),b=lF(()=>new kA(Y,typeof window<"u"?window:null),[Y]),L=xy(b),W=L.resources,v=lF(()=>[...W?.images.values()??[]].some((C)=>C.status==="loading"),[W]);U.current||=w;let g=JZ({renderResources:W,theme:_}),{actions:j,props:P,refs:R,state:f}=g,{autoScrollDuringDrag:m,getScrollTop:x,invalidateViewport:r,observeViewport:i,observeScrollContainer:B0,reconcileEditorState:Q0,resolvePoint:u,scrollTo:l}=j,{layoutWidth:o,scrollContentHeight:a,viewportLayout:V0,viewportHeight:P0,viewportTop:T}=f,{scrollContainer:p}=R,D0=e(ZA),q0=e(JN),Y0=e(D1),E0=Boolean($),R0=e($A,Q),q1=lF(()=>{return E0?R0:void 0},[R0,E0]),P2=r1(({target:C,transition:I,userId:c})=>{let A0=GZ(I,C);if(!A0)return;let S0={...A0,userId:c};y?.(S0)}),W2=ky({completionSources:q1,enabled:E0,onMentionAccepted:P2}),{activeCommentThreadColors:zN,resolvedPresence:GN}=sy({presence:Z,users:Q}),dF=e(XA),c1=()=>z.editor.getState(),{scheduleDecorationsForTransition:M4,textDecorations:G0}=RZ({contentDocument:S,decorations:D,store:z}),O2=rH(N?.selection),gZ=()=>{let C=NF(z.editor.getState());return C?eF(C):""},hZ=r1((C)=>{if(!C)return;if(C.source==="external")return;if(Q0(C.previous,C.next),C.animationsChanged)E4();if(!C.documentChanged)return;if(C.reason==="reconciliation")return;M4(C);let I=S1(C.next),c=u3(I);U.current=c,q.current=c,$?.(c,I)});mZ(()=>{return z.editor.subscribe(hZ)},[z]);let IZ=h(eN),pZ=h(g7),xZ=h(I7),lZ=h(x7),dZ=h(l7),aZ=h(h7),rZ=h(p7),cZ=h(j7),sZ=h(C7),iZ=h(d7),oZ=h(c7),nZ=h(s7),tZ=h(r7),eZ=h(a7),NY=h(i7),D4=(C)=>{E?.(C)},rA=(C)=>{let I=S1(c1()).comments[C],c=I?.comments.at(-1);if(!I||!c)return;D4({kind:"added",comment:c,mentionedUserIds:mA(c.body,R0),thread:I,threadId:I.id})},FY=(C,I,c)=>{let A0=S1(c1()).comments[C],S0=A0?.comments[I];if(!A0||!S0)return;D4({kind:"edited",comment:S0,previousBody:c,mentionedUserIds:mA(S0.body,R0),thread:A0,threadId:A0.id})},cA=(C,I)=>{D4({kind:"deleted",comment:I,thread:C,threadId:C.id})},w2=by({onIdle:()=>{E4()}}),sA=r1((C=V0.peek())=>{if(!C)return;let I=vA(J.current,{paintHeight:C.paintHeight,paintTop:C.paintTop,width:o});if(!I)return;let{context:c,devicePixelRatio:A0,height:S0,width:i1}=I,L2=performance.now();L8(G,C,c,{activeBlockId:D0.block?.blockId??null,activeRegionId:G.selection.focus.regionId,activeThreadIndex:eA??dF,contentPulseTime:w2.resolveAnimationTime(L2),devicePixelRatio:A0,height:S0,liveCommentRanges:q0.liveRanges,normalizedSelection:Y0,presenceActiveThreadColors:zN,now:L2,resources:W,textDecorations:G0,theme:_,width:i1})}),iA=r1((C=V0.peek())=>{if(!C)return;let I=vA(V.current,{paintHeight:C.paintHeight,paintTop:C.paintTop,width:o});if(!I)return;let{context:c,devicePixelRatio:A0,height:S0,width:i1}=I;T8(G,C,c,{devicePixelRatio:A0,height:S0,normalizedSelection:Y0,presence:GN,showCaret:Y0.start.regionId!==Y0.end.regionId||Y0.start.offset!==Y0.end.offset||tA.isVisible(),theme:_,width:i1})}),AY=r1(()=>{let C=V0.get();i(C),sA(C),iA(C)}),{scheduleContentPaint:E4,scheduleFullPaint:MY,scheduleFullRender:$4,scheduleOverlayPaint:oA}=DZ({hasRunningOptionalContentAnimations:()=>{let C=V0.peek();return C?j8(G,C,G0)||j6(C,q0.liveRanges,zN):!1},isActive:w2.isActive,renderContent:sA,renderOverlay:iA,renderViewport:AY}),nA=r1((C)=>{B0(C),$4()}),DY=r1((C)=>{nA(C.currentTarget)}),tA=my({activeAt:w2.activeAt,getScrollTop:x,isEditable:E0,layoutWidth:o,onVisibilityChange:oA,scrollContentHeight:a,scrollTo:l,viewportHeight:P0}),EY=gy(W),aF=ey({enableTouchKeyDown:W2.leaf!==null,inputRef:K,keybindings:M,onActivity:w2.markActive,onBeforeInput:W2.handleBeforeInput,onKeyDown:W2.handleKeyDown,onImagePaste:L.persistImage}),W1=cy({autoScrollDuringDrag:m,canvasRef:J,focusInput:aF.focus,isEditable:E0,onActivity:w2.markActive,resolvePoint:u,storage:b}),eA=W1.leaf?.kind==="thread"?W1.leaf.threadIndex:null,$Y=r1((C)=>{if(!C.viewport||C.viewport.status==="unresolved")return;let I=p.current;if(!I)return;I.scrollTop=C.viewport.scrollTop,nA(I)}),y4=EZ({autoScrollDuringDrag:m,focusInput:aF.focus,isEditable:E0,onActivity:w2.markActive,resolvePoint:u}),s1=y4.handle??EY;UN(()=>{r(),$4()},[G.documentIndex,o,_,W,P0]),UN(()=>{MY()},[Y0.end.offset,Y0.end.regionId,Y0.start.offset,Y0.start.regionId,D0.block?.blockId]),UN(()=>{E4()},[dF,q0.liveRanges,eA,zN,G0]),UN(()=>{oA()},[GN]),UN(()=>{if(!v)return;let C=null,I=window,c=()=>{$4(),C=I.requestAnimationFrame(c)};return C=I.requestAnimationFrame(c),()=>{if(C!==null)I.cancelAnimationFrame(C)}},[v]);let M0=y4.leaf??W2.leaf??W1.leaf??tA.leaf,Z4=(()=>{if(!M0)return null;let C=k1(G,V0.get(),M0.anchor);if(!C)return null;let I=C.top+C.height,c=T+P0;if(I<=T||I>=c)return null;let A0=p.current?.getBoundingClientRect(),S0=typeof window<"u"?window.scrollX:0,i1=typeof window<"u"?window.scrollY:0,L2=M0===W1.leaf;return{anchorHeight:C.height,bridge:L2,left:(A0?.left??0)+S0+(M0.leftOverride??C.left),onPointerEnter:L2?W1.leafHandlers.onPointerEnter:void 0,onPointerLeave:L2?W1.leafHandlers.onPointerLeave:void 0,paddingY:M0.paddingY??0,top:(A0?.top??0)+i1+I-T}})(),yY=Z4?(()=>{if(!M0)return null;switch(M0.kind){case"insertion":return X0(Ly,{onInsert:(C)=>{IZ(C)},onInsertTable:(C)=>{pZ(C)}});case"table":return X0(Ry,{canDeleteColumn:M0.columnCount>1,canDeleteRow:M0.rowCount>1,onDeleteColumn:()=>{xZ()},onDeleteRow:()=>{lZ()},onDeleteTable:()=>{dZ()},onInsertColumn:(C)=>{aZ(C)},onInsertRow:(C)=>{rZ(C)}});case"link":return X0(Cy,{canEdit:E0,onDelete:()=>{cZ(M0)},onSave:(C)=>{sZ(M0,C)},title:M0.title,url:M0.url});case"annotation":{let C=O2.length>0?O2.map((I)=>({icon:I.icon,label:I.label,onClick:()=>{I.onClick(gZ())}})):void 0;return X0(BA,{canEdit:E0,formatting:M0.formatting,link:null,mode:"create",completionSources:R0,onCreateThread:(I)=>{let c=c1(),A0=S1(c).comments.length;if(!iZ(M0.selection,I.trim()))return;y4.promoteLeafToThread(A0,!0),rA(A0)},actions:C})}case"thread":return X0(BA,{animateInitialComment:M0.animateInitialComment,canEdit:E0,link:M0.link,mode:"thread",completionSources:R0,onDeleteComment:(C)=>{let{threadIndex:I}=M0,c=c1(),A0=S1(c).comments[I],S0=A0?.comments[C];if(!oZ(I,C))return;if(A0&&S0)cA(A0,S0)},onDeleteThread:()=>{let{threadIndex:C}=M0,I=c1(),c=S1(I).comments[C];if(!nZ(C))return;if(c)for(let S0 of c.comments)cA(c,S0)},onEditComment:(C,I)=>{let{threadIndex:c}=M0,A0=c1(),S0=S1(A0).comments[c]?.comments[C]?.body;if(!tZ(c,C,I))return;if(S0!==void 0)FY(c,C,S0)},onReply:(C)=>{let{threadIndex:I}=M0;if(!eZ(I,C))return;rA(I)},onToggleResolved:()=>{NY(M0.threadIndex,!M0.resolved)},thread:M0.thread});case"completion":return X0(d3,{...M0})}})():null;UN(()=>{B(!0)},[]),mZ(()=>{if(A===q.current)return;let C=z.editor.getState(),I=KZ(C,FN(S)),c=I.state,A0=I.didReconcile?x():0;z.editor.replace(c,"external"),q.current=A,U.current=w,l(A0)},[w,A,S]);let ZY=F?`documint ${F}`:"documint";return X0(L$,{themeStyles:O,children:A4("section",{className:ZY,style:{...O,height:"100%",minHeight:0},children:[X0("style",{children:vZ}),A4("div",{ref:p,onScroll:DY,className:"documint-scroll-container",style:{height:"100%",minHeight:0},children:[X0("textarea",{...aF.inputHandlers,ref:K,autoCapitalize:"sentences",className:"documint-input",spellCheck:!1,tabIndex:-1,wrap:"off"}),X0(oE,{insetX:_.paddingX,insetY:_.paddingY,onSelect:$Y,presence:GN}),A4("div",{...P.scrollContent,className:"documint-scroll-content",children:[X0("canvas",{...aF.canvasHandlers,...W1.canvasHandlers,"aria-label":"Documint editor",className:"documint-content-canvas",style:{cursor:W1.cursor},ref:J,tabIndex:0}),X0("canvas",{"aria-hidden":"true",className:"documint-overlay-canvas",ref:V}),s1&&A4(cH,{children:[X0("div",{"aria-hidden":"true",className:"documint-resize-handle",style:{left:`${s1.start.left}px`,top:`${s1.start.top}px`},...s1.start.props,children:X0("span",{className:"documint-resize-handle-knob"})}),X0("div",{"aria-hidden":"true",className:"documint-resize-handle",style:{left:`${s1.end.left}px`,top:`${s1.end.top}px`},...s1.end.props,children:X0("span",{className:"documint-resize-handle-knob"})})]}),Z4?X0(r3,{anchor:Z4,children:yY}):null]}),!H?X0("div",{className:"documint-fallback",children:X0(e3,{blocks:S.blocks})}):null]})]})})}function rH(N){if(!N)return[];return"onClick"in N?[N]:N}export{$Z as mintTheme,yZ as midnightTheme,pF as lightTheme,jA as defaultKeybindings,xF as darkTheme,kZ as Documint};