documint 0.0.1
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/README.md +65 -0
- package/dist/index.d.ts +222 -0
- package/dist/index.js +898 -0
- package/package.json +47 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,898 @@
|
|
|
1
|
+
import{useEffect as S0,useEffectEvent as G1,useLayoutEffect as DG,useMemo as u0,useRef as z1,useState as b$}from"react";function W2($){let M=B1($.children);return{children:$.children,id:q1($.path,"paragraph",M),plainText:M,type:"paragraph"}}function r($){return W2({children:m$(void 0,$.text)})}function j4($){let M=B1($.children);return{children:$.children,depth:$.depth,id:q1($.path,"heading",`${$.depth}:${M}`),plainText:M,type:"heading"}}function J0($){return j4({children:m$(void 0,$.text),depth:$.depth})}function I1($){let M=$.marks??[];return{id:q1($.path,"text",`${$.text}:${M.join(",")}`),marks:M,text:$.text,type:"text"}}function z2($={}){return{id:q1($.path,"break","break"),type:"break"}}function v0($){return{code:$.code,id:q1($.path,"inlineCode",$.code),type:"inlineCode"}}function g0($){return{children:$.children,id:q1($.path,"link",`${$.url}:${B1($.children)}`),title:$.title??null,type:"link",url:$.url}}function L4($){let M=$.alt??null,J=$.width??null;return{alt:M,id:q1($.path,"image",`${$.url}:${J??""}:${M??""}`),title:$.title??null,type:"image",url:$.url,width:J}}function k4($){return{id:q1($.path,"unsupported",$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}function s1($){let M=p0($.children);return{checked:$.checked??null,children:$.children,id:q1($.path,"listItem",M),plainText:M,spread:$.spread??!1,type:"listItem"}}function z0($){let M=$.items.map((J)=>J.plainText).join(`
|
|
2
|
+
`);return{id:q1($.path,"list",`${String($.ordered)}:${M}`),items:$.items,ordered:$.ordered,plainText:M,spread:$.spread??!1,start:$.start??null,type:"list"}}function j1($){let M=p0($.children);return{children:$.children,id:q1($.path,"blockquote",M),plainText:M,type:"blockquote"}}function s5($){return{id:q1($.path,"code",`${$.language??""}:${$.source}`),language:$.language??null,meta:$.meta??null,plainText:$.source,source:$.source,type:"code"}}function Z0($){let M=B1($.children);return{children:$.children,id:q1($.path,"tableCell",M),plainText:M}}function I0($){return{cells:$.cells,id:q1($.path,"tableRow",String($.cells.length))}}function V0($){let M=$.rows.map((J)=>J.cells.map((Z)=>Z.plainText).join(" | ")).join(`
|
|
3
|
+
`);return{align:$.align??[],id:q1($.path,"table",M),plainText:M,rows:$.rows,type:"table"}}function f4(){return{id:"",plainText:"",type:"thematicBreak"}}function S4($){return{id:q1($.path,"unsupported",$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}function f$($){return{attributes:$.attributes,body:$.body,id:q1($.path,"directive",`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"}}function h0($,M){return $.type==="heading"?j4({children:M,depth:$.depth}):W2({children:M})}function h1($,M){return s1({checked:$.checked,children:M,spread:$.spread})}function J1($,M,J={}){return z0({items:M,ordered:J.ordered??$.ordered,spread:J.spread??$.spread,start:J.start??$.start})}function p1($,M){return V0({align:$.align,rows:M})}function S$($,M){return s5({language:$.language,meta:$.meta,source:M})}function u$($,M){return S4({originalType:$.originalType,source:M})}function m$($,M){return M.length>0?[I1({path:$?`${$}.children.0`:void 0,text:M})]:[]}function q1($,M,J){return $?Y1(M,$,J):""}function l0($,M=[]){return{blocks:$.map((J,Z)=>i5(J,Z)),comments:M}}function v4($,M,J,Z){let A=Z.map((Y,Q)=>i5(Y,M+Q)),X=$.blocks.slice(M+J),N=Z.length===J?X:X.map((Y,Q)=>i5(Y,M+A.length+Q));return{blocks:[...$.blocks.slice(0,M),...A,...N],comments:$.comments}}function v$($,M,J,Z){return{blocks:$.blocks,comments:[...$.comments.slice(0,M),...Z,...$.comments.slice(M+J)]}}function B1($){return $.map((M)=>{switch(M.type){case"break":return`
|
|
4
|
+
`;case"image":return M.alt??"";case"inlineCode":return M.code;case"link":return B1(M.children);case"text":return M.text;case"unsupported":return M.source}}).join("")}function p0($){return $.map((M)=>{switch(M.type){case"blockquote":case"listItem":return p0(M.children);case"code":return M.source;case"directive":return M.body;case"heading":case"paragraph":return B1(M.children);case"list":return M.items.map((J)=>J.plainText).join(`
|
|
5
|
+
`);case"table":return M.rows.map((J)=>J.cells.map((Z)=>Z.plainText).join(" | ")).join(`
|
|
6
|
+
`);case"thematicBreak":return"";case"unsupported":return M.source}}).join(`
|
|
7
|
+
`).trim()}function i5($,M){return u4($,`root.${M}`)}function u4($,M){switch($.type){case"blockquote":{let J=$.children.map((A,X)=>u4(A,`${M}.children.${X}`)),Z=p0(J);return{children:J,id:Y1("blockquote",M,Z),plainText:Z,type:"blockquote"}}case"code":return{id:Y1("code",M,`${$.language??""}:${$.source}`),language:$.language,meta:$.meta,plainText:$.source,source:$.source,type:"code"};case"directive":return{attributes:$.attributes,body:$.body,id:Y1("directive",M,`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"};case"heading":{let J=$.children.map((A,X)=>m4(A,`${M}.children.${X}`)),Z=B1(J);return{children:J,depth:$.depth,id:Y1("heading",M,`${$.depth}:${Z}`),plainText:Z,type:"heading"}}case"list":{let J=$.items.map((A,X)=>u4(A,`${M}.children.${X}`)),Z=J.map((A)=>A.plainText).join(`
|
|
8
|
+
`);return{id:Y1("list",M,`${String($.ordered)}:${Z}`),items:J,ordered:$.ordered,plainText:Z,spread:$.spread,start:$.start,type:"list"}}case"listItem":{let J=$.children.map((A,X)=>u4(A,`${M}.children.${X}`)),Z=p0(J);return{checked:$.checked,children:J,id:Y1("listItem",M,Z),plainText:Z,spread:$.spread,type:"listItem"}}case"paragraph":{let J=$.children.map((A,X)=>m4(A,`${M}.children.${X}`)),Z=B1(J);return{children:J,id:Y1("paragraph",M,Z),plainText:Z,type:"paragraph"}}case"table":{let J=$.rows.map((A,X)=>aJ(A,`${M}.rows.${X}`)),Z=J.map((A)=>A.cells.map((X)=>X.plainText).join(" | ")).join(`
|
|
9
|
+
`);return{align:$.align,id:Y1("table",M,Z),plainText:Z,rows:J,type:"table"}}case"thematicBreak":return{id:Y1("thematicBreak",M,"thematic-break"),plainText:"",type:"thematicBreak"};case"unsupported":return{id:Y1("unsupported",M,$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}}function aJ($,M){return{cells:$.cells.map((J,Z)=>{let A=J.children.map((N,Y)=>m4(N,`${M}.cells.${Z}.children.${Y}`)),X=B1(A);return{children:A,id:Y1("tableCell",`${M}.cells.${Z}`,X),plainText:X}}),id:Y1("tableRow",M,String($.cells.length))}}function m4($,M){switch($.type){case"break":return{id:Y1("break",M,"break"),type:"break"};case"image":return{alt:$.alt,id:Y1("image",M,`${$.url}:${$.width??""}:${$.alt??""}`),title:$.title,type:"image",url:$.url,width:$.width};case"inlineCode":return{code:$.code,id:Y1("inlineCode",M,$.code),type:"inlineCode"};case"link":{let J=$.children.map((A,X)=>m4(A,`${M}.children.${X}`)),Z=B1(J);return{children:J,id:Y1("link",M,`${$.url}:${Z}`),title:$.title,type:"link",url:$.url}}case"text":return{id:Y1("text",M,`${$.text}:${$.marks.join(",")}`),marks:$.marks,text:$.text,type:"text"};case"unsupported":return{id:Y1("unsupported",M,$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}}function V2($){return $.map((M)=>{switch(M.type){case"blockquote":return{...M,children:V2(M.children)};case"heading":case"paragraph":return h0(M,o5(M.children));case"list":return{...M,items:M.items.map((J)=>({...J,children:V2(J.children)}))};case"listItem":return{...M,children:V2(M.children)};case"table":return p1(M,M.rows.map((J)=>({...J,cells:J.cells.map((Z)=>({...Z,children:o5(Z.children)}))})));default:return M}})}function o5($){let M=[...$];for(let J=M.length-1;J>=0;J-=1){let Z=M[J];if(Z.type==="text"){let A=Z.text.replace(/[ \t]+$/u,"");if(A.length===Z.text.length)return M;if(A.length===0){M.splice(J,1);continue}return M[J]={...Z,text:A},M}if(Z.type==="link"){let A=o5(Z.children);if(A.length===Z.children.length&&A.every((X,N)=>X===Z.children[N]))return M;if(A.length===0){M.splice(J,1);continue}return M[J]={...Z,children:A},M}return M}return M}function Y1($,M,J){let Z=2166136261;for(let A of`${$}:${M}:${J}`)Z^=A.charCodeAt(0),Z=Math.imul(Z,16777619);return`${$}-${(Z>>>0).toString(36)}`}function y2($,M){n5($.blocks,M,h$(),p$())}function I$($,M){n5($,M,h$(),p$())}function n5($,M,J,Z){for(let[A,X]of $.entries()){if(J.stopped)return;let N=`${Z.pathPrefix}.${A}`,Y={blockAncestors:Z.blockAncestors,depth:Z.depth,parentBlock:Z.parentBlock,path:N},Q=M.enterBlock?.(X,Y);if(x0(Q,J))return;if(Q!=="skip")switch(X.type){case"list":g$(X.items,X,M,J,Z,N);break;case"blockquote":case"listItem":g$(X.children,X,M,J,Z,N);break;case"heading":case"paragraph":t5(X.children,M,J,{block:X,blockAncestors:[...Z.blockAncestors,X],inlineAncestors:[],parentInline:null,pathPrefix:`${N}.children`});break;case"table":iJ(X,M,J,{blockAncestors:[...Z.blockAncestors,X],pathPrefix:N});break;case"code":case"directive":case"thematicBreak":case"unsupported":break}if(J.stopped)return;if(x0(M.leaveBlock?.(X,Y),J))return}}function t5($,M,J,Z){for(let[A,X]of $.entries()){if(J.stopped)return;let N=`${Z.pathPrefix}.${A}`,Y={block:Z.block,blockAncestors:Z.blockAncestors,inlineAncestors:Z.inlineAncestors,parentInline:Z.parentInline,path:N},Q=M.enterInline?.(X,Y);if(x0(Q,J))return;if(Q!=="skip"){if(X.type==="link")sJ(X.children,X,M,J,Z,N)}if(J.stopped)return;if(x0(M.leaveInline?.(X,Y),J))return}}function h$(){return{stopped:!1}}function p$(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function g$($,M,J,Z,A,X){n5($,J,Z,{blockAncestors:[...A.blockAncestors,M],depth:A.depth+1,parentBlock:M,pathPrefix:`${X}.children`})}function sJ($,M,J,Z,A,X){t5($,J,Z,{block:A.block,blockAncestors:A.blockAncestors,inlineAncestors:[...A.inlineAncestors,M],parentInline:M,pathPrefix:`${X}.children`})}function iJ($,M,J,Z){for(let[A,X]of $.rows.entries())for(let[N,Y]of X.cells.entries()){if(J.stopped)return;let Q=`${Z.pathPrefix}.rows.${A}.cells.${N}`,K={blockAncestors:Z.blockAncestors,cellIndex:N,path:Q,row:X,rowIndex:A,table:$},q=M.enterTableCell?.(Y,K);if(x0(q,J))return;if(q!=="skip")t5(Y.children,M,J,{block:$,blockAncestors:Z.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${Q}.children`});if(J.stopped)return;if(x0(M.leaveTableCell?.(Y,K),J))return}}function x0($,M){if($!=="stop")return!1;return M.stopped=!0,!0}var e5="text";function $6($){return $==="text"||$==="code"||$==="tableCell"}function g4($){return $===e5?void 0:$}function I4($){let M=[];return y2($,{enterBlock(J){switch(J.type){case"heading":case"paragraph":M.push({containerKind:"text",containerOrdinal:M.length,id:J.id,text:B1(J.children)});break;case"code":M.push({containerKind:"code",containerOrdinal:M.length,id:J.id,text:J.source});break}},enterTableCell(J){M.push({containerKind:"tableCell",containerOrdinal:M.length,id:J.id,text:B1(J.children)})}}),M}function l$($){let M=new Set;return y2($,{enterInline(J){if(J.type==="image")M.add(J.url)}}),[...M]}function r0($,M){let J=null;return oJ($,{enterBlock(Z){if(Z.id===M)return J=Z,"stop"}}),J}function oJ($,M){if(Array.isArray($)){I$($,M);return}y2($,M)}var x$=24;function b2($,M,J){let Z=c0(M,0,$.text.length),A=c0(J,Z,$.text.length);return{kind:g4($.containerKind),prefix:$.text.slice(Math.max(0,Z-x$),Z)||void 0,suffix:$.text.slice(A,A+x$)||void 0}}function O2($,M,J){let Z=c0(M,0,$.text.length),A=c0(J,Z,$.text.length);return $.text.slice(Z,A)}var r$=48,c$=64,nJ=32;function C2($,M){let J=$.anchor.kind??e5,Z=I4(M).filter((N)=>N.containerKind===J),A=tJ($,Z);if(A.length>0)return d$($,A,null);let X=eJ($,Z);if(X.length>0)return d$($,X,"repaired");return{match:null,repair:null,status:"stale"}}function tJ($,M){let J=[],Z=$.quote;if(Z.length===0)return J;for(let A of M){let X=0;while(X<=A.text.length){let N=A.text.indexOf(Z,X);if(N===-1)break;J.push({container:A,endOffset:N+Z.length,score:JZ($,A,N),startOffset:N}),X=N+Math.max(1,Z.length)}}return J.sort((A,X)=>X.score-A.score),J}function eJ($,M){let J=[];for(let Z of M)J.push(...$Z($,Z));return J.sort((Z,A)=>A.score-Z.score),J}function $Z($,M){let J=[],Z=$.quote.length,A=M.text,X=$.anchor.prefix??"",N=$.anchor.suffix??"";if(X.length>0&&N.length>0){let Y=0;while(Y<=A.length){let Q=A.indexOf(X,Y);if(Q===-1)break;let K=Q+X.length,q=A.indexOf(N,K);if(q!==-1&&q>=K)J.push({container:M,endOffset:q,score:M6($,M,K,q,Z),startOffset:K});Y=Q+Math.max(1,X.length)}return J}if(X.length>0){let Y=0;while(Y<=A.length){let Q=A.indexOf(X,Y);if(Q===-1)break;let K=Q+X.length,q=c0(K+Z,K,A.length);J.push({container:M,endOffset:q,score:M6($,M,K,q,Z),startOffset:K}),Y=Q+Math.max(1,X.length)}return J}if(N.length>0){let Y=0;while(Y<=A.length){let Q=A.indexOf(N,Y);if(Q===-1)break;let K=Q,q=c0(K-Z,0,K);J.push({container:M,endOffset:K,score:M6($,M,q,K,Z),startOffset:q}),Y=Q+Math.max(1,N.length)}}return J}function d$($,M,J){let[Z,A]=M;if(!Z)return{match:null,repair:null,status:"stale"};if(A&&Z.score===A.score)return{match:null,repair:null,status:"ambiguous"};let X=b2(Z.container,Z.startOffset,Z.endOffset),N=O2(Z.container,Z.startOffset,Z.endOffset),Y=J??(N===$.quote&&(X.prefix??"")===($.anchor.prefix??"")&&(X.suffix??"")===($.anchor.suffix??"")?"matched":"repaired");return{match:MZ(Z.container,Z.startOffset,Z.endOffset),repair:{anchor:X,quote:N},status:Y}}function MZ($,M,J){return{containerId:$.id,containerKind:$.containerKind,containerOrdinal:$.containerOrdinal,endOffset:J,startOffset:M}}function JZ($,M,J){let Z=0;if(a$(M.text,$.anchor.prefix,J))Z+=r$;if(s$(M.text,$.anchor.suffix,J+$.quote.length))Z+=r$;return Z}function M6($,M,J,Z,A){let X=0;if(a$(M.text,$.anchor.prefix,J))X+=c$;if(s$(M.text,$.anchor.suffix,Z))X+=c$;if(X+=Math.max(0,nJ-Math.abs(A-(Z-J))),$.quote.length>0){let N=M.text.slice(J,Z);if(N.length>0)X+=ZZ($.quote,N),X+=AZ($.quote,N)}return X}function a$($,M,J){if(!M)return!1;return $.slice(Math.max(0,J-M.length),J)===M}function s$($,M,J){if(!M)return!1;return $.slice(J,J+M.length)===M}function ZZ($,M){let J=0;while(J<$.length&&J<M.length&&$[J]===M[J])J+=1;return J}function AZ($,M){let J=0;while(J<$.length&&J<M.length&&$[$.length-1-J]===M[M.length-1-J])J+=1;return J}function c0($,M,J){return Math.min(Math.max($,M),J)}function J6($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$,J=NZ(M.anchor),Z=typeof M.quote==="string"?M.quote:null,A=Array.isArray(M.comments)?M.comments.flatMap((X)=>{let N=XZ(X);return N?[N]:[]}):[];if(!J||!Z||A.length===0)return null;return{quote:Z,anchor:J,comments:A,resolvedAt:typeof M.resolvedAt==="string"?M.resolvedAt:void 0}}function XZ($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$;if(typeof M.body!=="string"||typeof M.updatedAt!=="string")return null;return{body:M.body,updatedAt:M.updatedAt}}function NZ($){if(!$||typeof $!=="object"||Array.isArray($))return null;let{kind:M,prefix:J,suffix:Z}=$;if("kind"in $&&!$6(M)||"prefix"in $&&typeof J!=="string"||"suffix"in $&&typeof Z!=="string")return null;return{kind:$6(M)?g4(M):void 0,prefix:typeof J==="string"?J:void 0,suffix:typeof Z==="string"?Z:void 0}}function Z6($){let M=$.createdAt??new Date().toISOString();return{comments:[i$({body:$.body,updatedAt:M})],quote:$.quote,anchor:$.anchor}}function A6($,M){let J=i$(M);return{...$,comments:[...$.comments,J]}}function X6($,M,J,Z=new Date().toISOString()){let A=J.trim();if(A.length===0)return $;let X=!1,N=$.comments.map((Y,Q)=>{if(Q!==M||Y.body===A)return Y;return X=!0,{...Y,body:A,updatedAt:Z}});if(!X)return $;return{...$,comments:N}}function N6($,M){let J=$.comments.filter((Z,A)=>A!==M);if(J.length===$.comments.length)return $;if(J.length===0)return null;return{...$,comments:J}}function Y6($,M,J=new Date().toISOString()){if(A0($)===M)return $;return{...$,resolvedAt:M?J:void 0}}function A0($){return $.resolvedAt!=null}function Q6($){return $.filter((M)=>A0(M)).length}function K6($){if($.comments.length===0)return null;return $.comments.reduce((M,J)=>J.updatedAt>M?J.updatedAt:M,$.comments[0].updatedAt)}function i$($){let M=$.updatedAt??new Date().toISOString();return{body:$.body,updatedAt:M}}import{forwardRef as UZ,createElement as GZ}from"react";var h4=(...$)=>$.filter((M,J,Z)=>{return Boolean(M)&&M.trim()!==""&&Z.indexOf(M)===J}).join(" ").trim();var o$=($)=>$.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var n$=($)=>$.replace(/^([A-Z])|[\s-_]+(\w)/g,(M,J,Z)=>Z?Z.toUpperCase():J.toLowerCase());var q6=($)=>{let M=n$($);return M.charAt(0).toUpperCase()+M.slice(1)};import{forwardRef as qZ,createElement as $M}from"react";var p4={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 t$=($)=>{for(let M in $)if(M.startsWith("aria-")||M==="role"||M==="title")return!0;return!1};import{createContext as YZ,useContext as QZ,useMemo as ZB,createElement as AB}from"react";var KZ=YZ({});var e$=()=>QZ(KZ);var MM=qZ(({color:$,size:M,strokeWidth:J,absoluteStrokeWidth:Z,className:A="",children:X,iconNode:N,...Y},Q)=>{let{size:K=24,strokeWidth:q=2,absoluteStrokeWidth:U=!1,color:G="currentColor",className:B=""}=e$()??{},F=Z??U?Number(J??q)*24/Number(M??K):J??q;return $M("svg",{ref:Q,...p4,width:M??K??p4.width,height:M??K??p4.height,stroke:$??G,strokeWidth:F,className:h4("lucide",B,A),...!X&&!t$(Y)&&{"aria-hidden":"true"},...Y},[...N.map(([_,D])=>$M(_,D)),...Array.isArray(X)?X:[X]])});var S=($,M)=>{let J=UZ(({className:Z,...A},X)=>GZ(MM,{ref:X,iconNode:M,className:h4(`lucide-${o$(q6($))}`,`lucide-${$}`,Z),...A}));return J.displayName=q6($),J};var BZ=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],X0=S("columns-2",BZ);var FZ=[["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"}]],N0=S("rows-3",FZ);var _Z=[["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"}]],Y0=S("send-horizontal",_Z);var DZ=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],R2=S("arrow-down",DZ);var HZ=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],w2=S("arrow-up",HZ);var TZ=[["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"}]],E2=S("bold",TZ);var PZ=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],y0=S("check",PZ);var WZ=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],j2=S("chevron-down",WZ);var zZ=[["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"}]],L2=S("heading-1",zZ);var VZ=[["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"}]],k2=S("heading-2",VZ);var yZ=[["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"}]],f2=S("heading-3",yZ);var bZ=[["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"}]],S2=S("heading-4",bZ);var OZ=[["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"}]],u2=S("heading-5",OZ);var CZ=[["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"}]],m2=S("heading-6",CZ);var RZ=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],v2=S("heading",RZ);var wZ=[["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"}]],g2=S("italic",wZ);var EZ=[["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"}]],I2=S("list-ordered",EZ);var jZ=[["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"}]],h2=S("list-todo",jZ);var LZ=[["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"}]],p2=S("list",LZ);var kZ=[["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"}]],l2=S("message-square-plus",kZ);var fZ=[["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"}]],b0=S("pencil",fZ);var SZ=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],d0=S("plus",SZ);var uZ=[["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"}]],x2=S("strikethrough",uZ);var mZ=[["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"}]],Q0=S("table-2",mZ);var vZ=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],r2=S("text-quote",vZ);var gZ=[["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"}]],y1=S("trash-2",gZ);var IZ=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],c2=S("underline",IZ);var hZ=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],d2=S("x",hZ);import{jsxDEV as O0}from"react/jsx-dev-runtime";function JM({insetX:$,insetY:M,onSelect:J,presence:Z}){if(Z.length===0)return null;return O0("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${$}px`,top:`${M}px`},children:Z.map((A,X)=>O0(pZ,{onSelect:()=>J(A),presence:A},rZ(A,X),!1,void 0,this))},void 0,!1,void 0,this)}function pZ({onSelect:$,presence:M}){let J=M.viewport,Z=lZ(M),A=J?.status==="above"?w2:R2,X=J!==null&&J.scrollTop!==null,N=J?.status==="above"||J?.status==="below";return O0("button",{"aria-label":xZ(M),className:"documint-presence-indicator","data-status":J?.status??"unresolved",disabled:!X,onClick:X?$:void 0,style:{"--documint-presence-color":M.color??"var(--documint-leaf-accent)"},type:"button",children:[O0("span",{className:"documint-presence-indicator-avatar",children:M.imageUrl?O0("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:M.imageUrl},void 0,!1,void 0,this):Z},void 0,!1,void 0,this),N?O0("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:O0(A,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3},void 0,!1,void 0,this)},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}function lZ($){return ZM($).charAt(0).toLocaleUpperCase()}function xZ($){let M=ZM($),J=$.viewport?.status??"unresolved";if(J==="above")return`${M} above viewport`;if(J==="below")return`${M} below viewport`;if(J==="unresolved")return`${M} unresolved`;return`${M} in viewport`}function ZM($){return $.name.trim()||"Presence"}function rZ($,M){return[M,$.name,$.imageUrl??"",$.color??"",$.cursor?.kind??"",$.cursor?.prefix??"",$.cursor?.suffix??""].join(":")}var i=`
|
|
10
|
+
`,K0="<ins>",a2="</ins>",a0=">",s2="```",l4=":::",U6=/^:::([A-Za-z][-\w]*)(.*)$/,x4="documint-comments";var r4="`",_6="\\",B6="![",F6="[",YM="(",AM=")",QM=" ",KM=":",cZ=/[A-Za-z]/,dZ=/[-A-Za-z0-9_]/,aZ=/^\{width=([1-9]\d*)\}/,sZ=/\\([\\`*_[\]{}()#+\-.!~|])/g,qM=/\\(.)/g,iZ=[{delimiter:"**",mark:"bold"},{delimiter:"~~",mark:"strikethrough"},{delimiter:"*",mark:"italic"}];function s0($,M=[]){return D6($,0,$.length,M)}function D6($,M,J,Z){let A=[],X=M,N=M;while(X<J){let Y=oZ($,X,J,Z);if(Y){XM(A,$.slice(N,X),Z),A.push(...Y.nodes),X=Y.end,N=X;continue}if($[X]===_6){X+=Math.min(2,J-X);continue}X+=1}return XM(A,$.slice(N,J),Z),nZ(A)}function oZ($,M,J,Z){switch($[M]){case KM:return QA($,M,J);case"<":return NA($,M,J,Z);case r4:return JA($,M,J);case"!":return ZA($,M,J);case F6:return AA($,M,J,Z);case"*":case"~":return eZ($,M,J,Z);default:return null}}function XM($,M,J){if(M.length===0)return;$.push(I1({marks:J,text:_M(M)}))}function H6($,M){return k4({originalType:$,source:M})}function nZ($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&$A(Z.marks,J.marks)){M[M.length-1]=I1({marks:Z.marks,text:Z.text+J.text});continue}M.push(J)}return M}function tZ($,M,J){for(let Z of iZ){if(!$.startsWith(Z.delimiter,M))continue;let A=$.indexOf(Z.delimiter,M+Z.delimiter.length);if(A<0||A>=J)continue;return{contentEnd:A,contentStart:M+Z.delimiter.length,end:A+Z.delimiter.length,mark:Z.mark}}return null}function eZ($,M,J,Z){let A=tZ($,M,J);if(!A)return null;return{end:A.end,nodes:D6($,A.contentStart,A.contentEnd,[...Z,A.mark])}}function $A($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function MA($,M,J){if($[M]!==r4)return null;let Z=1;while(M+Z<J&&$[M+Z]===r4)Z+=1;let A=r4.repeat(Z),X=$.indexOf(A,M+Z);if(X<0||X>=J)return null;return{end:X+Z,value:$.slice(M+Z,X)}}function JA($,M,J){let Z=MA($,M,J);if(!Z)return null;return{end:Z.end,nodes:[v0({code:Z.value})]}}function ZA($,M,J){if(!$.startsWith(B6,M))return null;let Z=GM($,M+1,J);if(Z<0||$[Z+1]!==YM)return null;let A=UM($,Z+1,J);if(!A)return null;let X=XA($,A.end,J);return{end:X?.end??A.end,nodes:[L4({alt:_M($.slice(M+B6.length,Z)),title:A.title,url:A.url,width:X?.width??null})]}}function AA($,M,J,Z){if($[M]!==F6||$.startsWith(B6,M-1))return null;let A=GM($,M,J);if(A<0||$[A+1]!==YM)return null;let X=UM($,A+1,J);if(!X)return null;return{end:X.end,nodes:[g0({children:s0($.slice(M+F6.length,A),Z),title:X.title,url:X.url})]}}function UM($,M,J){let Z=G6($,M+1,J),A=Z;while(A<J&&$[A]!==AM&&$[A]!==QM){if($[A]===_6){A+=2;continue}A+=1}if(A===Z)return null;let X=KA($.slice(Z,A));Z=G6($,A,J);let N=null;if(Z<J&&$[Z]==='"'){let Y=FM($,'"',Z+1,J);if(Y<0)return null;N=$.slice(Z+1,Y).replace(qM,"$1"),Z=G6($,Y+1,J)}if($[Z]!==AM)return null;return{end:Z+1,title:N,url:X}}function XA($,M,J){let Z=aZ.exec($.slice(M,J));if(!Z)return null;return{end:M+Z[0].length,width:Number(Z[1])}}function NA($,M,J,Z){if(!$.startsWith(K0,M))return YA($,M,J);let A=$.indexOf(a2,M+K0.length);if(A<0||A>=J)return{end:M+K0.length,nodes:[H6("html",K0)]};return{end:A+a2.length,nodes:D6($,M+K0.length,A,[...Z,"underline"])}}function YA($,M,J){if($[M]!=="<")return null;let Z=$.indexOf(">",M+1);if(Z<0||Z>=J)return null;return{end:Z+1,nodes:[H6("html",$.slice(M,Z+1))]}}function QA($,M,J){if($[M]!==KM||!cZ.test($[M+1]??""))return null;let Z=M+2;while(Z<J&&dZ.test($[Z]??""))Z+=1;let A=NM($,Z,J,"[","]"),N=NM($,A?.end??Z,J,"{","}")?.end??A?.end??Z;return{end:N,nodes:[H6("textDirective",$.slice(M,N))]}}function NM($,M,J,Z,A){if($[M]!==Z)return null;let X=BM($,A,M+1,J);if(X<0)return null;return{end:X+1}}function GM($,M,J){return BM($,"]",M+1,J)}function BM($,M,J,Z){return FM($,M,J,Z)}function FM($,M,J,Z){for(let A=J;A<Z;A+=1){if($[A]===_6){A+=1;continue}if($[A]===M)return A}return-1}function G6($,M,J){while(M<J&&$[M]===QM)M+=1;return M}function _M($){return $.replace(sZ,"$1")}function KA($){return $.replace(qM,"$1")}var qA=/^:?-+:?$/;function TM($,M){let J=HM($),Z=$.lines[$.index+1]??"",A=T6(J,M),X=T6(Z,M);if(!DM(A)||!P6(X))return null;let N=[c4(A)],Y=UA(X);$.index+=2;while($.index<$.lines.length){let Q=HM($),K=T6(Q,M);if(GA(Q)||!DM(K))break;N.push(c4(K)),$.index+=1}return V0({align:Y,rows:N.map((Q)=>I0({cells:Q.map((K)=>Z0({children:s0(K)}))}))})}function DM($){let M=$.trim();return/\|/.test($)&&M.startsWith("|")&&M.endsWith("|")}function P6($){let M=c4($);return M.length>0&&M.every((J)=>qA.test(J.trim()))}function UA($){return c4($).map((M)=>{let J=M.trim();if(J.startsWith(":")&&J.endsWith(":"))return"center";if(J.startsWith(":"))return"left";if(J.endsWith(":"))return"right";return null})}function c4($){return $.trim().slice(1,-1).split("|").map((J)=>J.trim())}function HM($){return $.lines[$.index]??""}function GA($){return $.trim()===""}function T6($,M){return $.slice(M)}var BA=3,FA=/^\d+\.$/,_A=/^\[( |x|X)\](?:\s|$)/,PM=/^```([^\s`]*)?(?:\s+(.*))?$/,WM=/^::(?!:)[A-Za-z][-\w]*/,zM=/^(#{1,6})\s+(.*)$/,DA=/\s+#+\s*$/u,HA=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,TA=/^(\*\s*){3,}$/,PA=/^(-\s*){3,}$/,WA=/^(_\s*){3,}$/;function a4($,M,J){let Z=[];while($.index<$.lines.length){let A=H1($);if($.index===$.lines.length-1&&A==="")break;if(i2(A)){$.index+=1;continue}if(i0(A)>M+BA)break;let N=zA($,M,J);if(!N)break;Z.push(N)}return Z}function zA($,M,J){return VA($,M,J)??yA($,M)??bA($,M)??CA($,M)??RA($,M)??wA($,M)??TM($,M)??EA($,M,J)??jA($,M)??LA($,M)}function VA($,M,J){let Z=H1($);if(!fA(Z,M))return null;let A=[];while($.index<$.lines.length){let X=H1($),N=i0(X);if(i2(X)){A.push(""),$.index+=1;continue}if(N<M)break;let Y=L1(X,M);if(!Y.startsWith(a0))break;let Q=Y.slice(1);if(Q.startsWith(" "))Q=Q.slice(1);A.push(Q),$.index+=1}return j1({children:a4({index:0,lines:A},0,J)})}function yA($,M){let J=H1($),Z=L1(J,M),A=PM.exec(Z);if(!A)return null;$.index+=1;let X=[];while($.index<$.lines.length){let N=H1($),Y=L1(N,M);if(Y.trim()===s2){$.index+=1;break}X.push(Y),$.index+=1}return s5({language:A[1]?A[1]:null,meta:A[2]?A[2]:null,source:X.join(i)})}function bA($,M){let J=H1($),Z=L1(J,M),A=U6.exec(Z);if(!A)return null;let X=A[1],N=[];$.index+=1;while($.index<$.lines.length){let Y=H1($),Q=L1(Y,M);if($.index+=1,Q.trim()===l4)break;N.push(Q)}return f$({attributes:OA(A[2]??""),body:N.join(i),name:X})}function OA($){let M=$.trim();if(M.startsWith("{")&&M.endsWith("}"))return M.slice(1,-1);return M}function CA($,M){let J=H1($),Z=L1(J,M);if(!WM.test(Z))return null;return $.index+=1,S4({originalType:"leafDirective",source:Z})}function RA($,M){let J=H1($),Z=zM.exec(L1(J,M));if(!Z)return null;return $.index+=1,j4({children:s0(Z[2].replace(DA,"")),depth:Z[1].length})}function wA($,M){let J=L1(H1($),M).trim();if(!VM(J))return null;return $.index+=1,f4()}function EA($,M,J){let Z=d4(H1($),M);if(!Z)return null;let A=[],X=!1;while($.index<$.lines.length){let N=H1($),Y=d4(N,M);if(!Y||Y.ordered!==Z.ordered)break;$.index+=1;let Q=[Y.content],K=!1;while($.index<$.lines.length){let q=H1($),U=i0(q);if(i2(q)){let G=mA($.lines,$.index+1);if(G<0||i0($.lines[G]??"")<=M)break;K=!0,Q.push(""),$.index+=1;continue}if(U<Y.contentIndent)break;if(U===M&&d4(q,M))break;Q.push(SA(q,Y.contentIndent)),$.index+=1}X||=K,A.push(s1({checked:Y.checked,children:kA(Q,J),spread:K}))}return z0({items:A,ordered:Z.ordered,spread:X,start:Z.ordered&&J.preserveOrderedListStart?Z.start??1:null})}function jA($,M){let J=L1(H1($),M).trim();if(!yM(J))return null;return $.index+=1,S4({originalType:"html",source:J})}function LA($,M){let J=[];while($.index<$.lines.length){let Z=H1($),A=i0(Z);if(i2(Z))break;if(A<M)break;let X=L1(Z,M);if(J.length>0&&uA(Z,X,M))break;J.push(X),$.index+=1}return W2({children:s0(J.join(i))})}function kA($,M){let J=a4({index:0,lines:$},0,M);if(J.length>0)return J;return[W2({children:[]})]}function d4($,M){let J=HA.exec($);if(!J||J[1].length!==M)return null;let Z=J[2],A=FA.test(Z),X=A?Number(Z.slice(0,-1)):null,N=J[3]??"",Y=null;if(_A.test(N)){if(Y=N[1]==="x"||N[1]==="X",N=N.slice(3),N.startsWith(" "))N=N.slice(1)}let Q=N.length>0?J[0].length-J[1].length-J[2].length-N.length:J[0].length-J[1].length-J[2].length;return{checked:Y,content:N,contentIndent:M+J[2].length+Q,ordered:A,start:X}}function fA($,M){return L1($,M).startsWith(a0)}function L1($,M){return $.slice(M)}function SA($,M){let J=i0($);if(J>=M)return $.slice(M);return $.trim()===""?"":$.slice(Math.min(J,M))}function VM($){return TA.test($)||PA.test($)||WA.test($)}function yM($){return $.startsWith("<")&&$.endsWith(">")}function i0($){let M=0;while(M<$.length&&$[M]===" ")M+=1;return M}function uA($,M,J){return M.startsWith(a0)||PM.test(M)||U6.test(M)||WM.test(M)||zM.test(M)||VM(M.trim())||P6(M)||d4($,J)!==null||yM(M.trim())}function H1($){return $.lines[$.index]??""}function i2($){return $.trim()===""}function mA($,M){for(let J=M;J<$.length;J+=1)if(!i2($[J]??""))return J;return-1}function OM($){let M=$.at(-1),J=M&&bM(M)?M:null;return{blocks:$.filter((A)=>!bM(A)),comments:J?vA(J.body):[]}}function vA($){let M;try{M=JSON.parse($)}catch{return[]}if(!Array.isArray(M))return[];return M.flatMap((J)=>{let Z=J6(J);return Z?[Z]:[]})}function bM($){return $.type==="directive"&&$.name===x4}function W6($,M={}){let Z={index:0,lines:$.replace(/\r\n/g,i).split(i)},A=a4(Z,0,M),{comments:X,blocks:N}=OM(A);return l0(N,X)}var o2=`
|
|
11
|
+
|
|
12
|
+
`,gA="-",IA=".",hA="***",pA=" ",z6=3,lA=5,xA=4,CM=2,rA=2,cA=1,dA=/([\\`*_[\]])/g,aA=/([\\)&])/g,sA=/(["\\])/g;function s4($,M={}){if($.blocks.length===0&&$.comments.length===0)return"";let J=$.blocks.map((A)=>i4(A,0,M));if($.comments.length>0)J.push(GX($.comments));let Z=J.join(o2);return Z.endsWith(i)?Z:`${Z}${i}`}function i4($,M,J){let Z=q0(M);switch($.type){case"blockquote":return iA($,M,J);case"code":return oA($,M);case"directive":return BX($,M);case"heading":return wM($,M);case"list":return nA($,M,J);case"listItem":return EM($,M,!1,1,J);case"paragraph":return`${Z}${V6(n2($.children))}`;case"table":return eA($,M,J);case"thematicBreak":return`${Z}${hA}`;case"unsupported":return M===0?$.source:kM($.source,M)}}function iA($,M,J){let Z=$.children.map((X)=>i4(X,0,J)).join(o2),A=q0(M);return Z.split(i).map((X)=>`${A}${a0}${X.length>0?` ${X}`:""}`).join(i)}function oA($,M){let J=[$.language??"",$.meta??""].filter(Boolean).join(" ").trim(),Z=q0(M),A=`${Z}${s2}${J?J:""}`,X=$.source.length>0?$.source.split(i).map((N)=>`${Z}${N}`).join(i):Z;return`${A}${i}${X}${i}${Z}${s2}`}function wM($,M){let J=V6(n2($.children)),Z=`${q0(M)}${"#".repeat($.depth)}`;return J.length>0?`${Z} ${J}`:Z}function nA($,M,J){let Z=$.start??1;return $.items.map((A)=>EM(A,M,$.ordered,Z,J)).join($.spread?o2:i)}function EM($,M,J,Z,A){let X=J?`${Z}${IA}`:gA,N=$.checked===null?"":`[${$.checked?"x":" "}] `,Y=`${q0(M)}${X} ${N}`,Q=M+X.length+1,K=$.children;if(K.length===0)return N.length>0?Y:Y.trimEnd();let[q,...U]=K,G=tA(q,Y,N.length>0,A),B=U.map((F)=>i4(F,Q,A)).join($.spread?o2:i);if(!B)return G;return`${G}${$.spread?o2:i}${B}`}function tA($,M,J,Z){switch($.type){case"paragraph":{let A=V6(n2($.children));if(A.length===0)return J?M:M.trimEnd();return`${M}${A}`}case"heading":return`${M}${wM($,0)}`;case"directive":case"unsupported":{let A=$.type==="directive"?y6($):$.source,[X,...N]=A.split(i);return[M+X,...N.map((Y)=>`${q0(M.length)}${Y}`)].join(i)}default:{let A=M.length;return`${M.trimEnd()}${i}${i4($,A,Z)}`}}}function eA($,M,J){let Z=$.rows.map((q)=>q.cells.map((U)=>n2(U.children))),A=Math.max(1,...Z.map((q)=>q.length)),X=Z[0]??[],N=Array.from({length:A},(q,U)=>Math.max(z6,ZX($.align[U]),...J.padTableColumns?Z.map((G)=>G[U]?.length??0):[X[U]?.length??0])),Y=$X(N,$.align,M),Q=RM(X,N,$.align,M,J),K=Z.slice(1).map((q)=>RM(q,N,$.align,M,J));return[Q??MX(N,M),Y,...K].join(i)}function RM($,M,J,Z,A){let X=M.map((N,Y)=>{let Q=$[Y]??"";if(!A.padTableColumns)return Q;return AX(Q,N,J[Y])});return`${" ".repeat(Z)}| ${X.join(" | ")} |`}function $X($,M,J){let Z=$.map((A,X)=>JX(M[X],A));return`${" ".repeat(J)}| ${Z.join(" | ")} |`}function MX($,M){return`${q0(M)}| ${$.map((J)=>"".padEnd(J," ")).join(" | ")} |`}function JX($,M){let J=Math.max(z6,M-($==="center"?rA:$?cA:0));switch($){case"center":return`:${"-".repeat(Math.max(1,J))}:`;case"left":return`:${"-".repeat(Math.max(CM,J))}`;case"right":return`${"-".repeat(Math.max(CM,J))}:`;default:return"-".repeat(J)}}function ZX($){return $==="center"?lA:$?xA:z6}function AX($,M,J){if(J==="right")return $.padStart(M," ");return $.padEnd(M," ")}function n2($){return NX($).map((M)=>XX(M)).join("")}function V6($){return $.replace(/^ +/gm,(M)=>pA.repeat(M.length))}function XX($){switch($.type){case"break":return i;case"image":return FX($);case"inlineCode":return KX($.code);case"link":return _X($);case"text":return QX(jM($.text),$.marks);case"unsupported":return $.source}}function NX($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&YX(Z.marks,J.marks)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function YX($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function QX($,M){return M.reduce((J,Z)=>{switch(Z){case"bold":return`**${J}**`;case"italic":return`*${J}*`;case"strikethrough":return`~~${J}~~`;case"underline":return`${K0}${J}${a2}`}},$)}function KX($){let M=0,J=0;for(let N of $){if(N==="`"){if(J+=1,J>M)M=J;continue}J=0}let Z=M>0?M+1:1,A="`".repeat(Z),X=$.startsWith("`")||$.endsWith("`")?` ${$} `:$;return`${A}${X}${A}`}function jM($){return $.replace(dA,"\\$1")}function qX($){return $.replace(aA,"\\$1")}function UX($){return $?` "${$.replace(sA,"\\$1")}"`:""}function GX($){return y6({attributes:"",body:JSON.stringify($,null,2),name:x4})}function BX($,M){let J=y6($);return M===0?J:kM(J,M)}function y6($){let M=$.attributes?`{${$.attributes}}`:"";return`:::${$.name}${M}${i}${$.body}${i}${l4}`}function FX($){let M=jM($.alt??""),J=LM($.url,$.title),Z=$.width?`{width=${$.width}}`:"";return`![${M}]${J}${Z}`}function _X($){return`[${n2($.children)}]${LM($.url,$.title)}`}function LM($,M){return`(${qX($)}${UX(M)})`}function q0($){return" ".repeat($)}function kM($,M){let J=q0(M);return $.split(i).map((Z)=>`${J}${Z}`).join(i)}import{useEffect as n4,useRef as CX,useState as C0}from"react";import{forwardRef as DX}from"react";import{jsxDEV as o0}from"react/jsx-dev-runtime";var o4=DX(function({className:M,onCancel:J,onChange:Z,onSave:A,placeholder:X,readOnly:N=!1,rows:Y=3,saveDisabled:Q=!1,value:K},q){return o0("div",{className:"documint-edit-input-field",children:[o0("textarea",{className:M??"documint-comment-input",onChange:(U)=>Z(U.currentTarget.value),onKeyDown:(U)=>{if(U.key!=="Escape")return;U.preventDefault(),J()},placeholder:X,readOnly:N,ref:q,rows:Y,value:K},void 0,!1,void 0,this),o0("button",{className:"documint-leaf-action documint-edit-input-cancel","aria-label":"Cancel editing",onClick:J,title:"Cancel editing",type:"button",children:o0(d2,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),o0("button",{className:"documint-leaf-action documint-edit-input-save","aria-label":"Save",disabled:Q,onClick:A,title:"Save",type:"button",children:o0(y0,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});import{Children as fM,isValidElement as SM,useEffect as HX,useRef as TX,useState as PX}from"react";import{jsxDEV as Q1}from"react/jsx-dev-runtime";var b6=($)=>{$.preventDefault()},O6=($)=>$.isPrimary&&$.button===0;function WX({children:$}){return Q1("div",{className:"documint-leaf-toolbar",children:fM.map($,zX)},void 0,!1,void 0,this)}function zX($){if(!SM($))return null;if($.type===mM){let M=$.props;return Q1(uM,{children:Q1(VX,{...M},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if($.type===vM){let{className:M}=$.props;return Q1("div",{className:t2("documint-leaf-toolbar-divider",M)},void 0,!1,void 0,this)}if($.type===gM){let M=$.props;return Q1(yX,{...M},void 0,!1,void 0,this)}return null}function VX({active:$=!1,className:M,disabled:J=!1,icon:Z,label:A,onClick:X}){return Q1("button",{"aria-label":A,className:t2("documint-leaf-toolbar-button",$?"active":null,M),disabled:J,onPointerDown:(N)=>{if(b6(N),!J&&O6(N))X()},title:A,type:"button",children:Q1(Z,{size:15,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function yX({children:$,className:M,icon:J,label:Z,onSelect:A}){let X=TX(null),[N,Y]=PX(!1);return HX(()=>{if(!N)return;let Q=(K)=>{if(X.current&&K.target instanceof Node&&!X.current.contains(K.target))Y(!1)};return window.addEventListener("pointerdown",Q),()=>{window.removeEventListener("pointerdown",Q)}},[N]),Q1(uM,{children:Q1("div",{className:"documint-leaf-toolbar-menu-shell",ref:X,children:[Q1(bX,{className:M,icon:J,isOpen:N,label:Z,onClick:()=>Y((Q)=>!Q)},void 0,!1,void 0,this),N?Q1("div",{className:"documint-leaf-toolbar-menu",role:"menu",children:fM.map($,(Q)=>OX(Q,(K)=>{Y(!1),A(K)}))},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function bX({className:$,icon:M,isOpen:J,label:Z,onClick:A}){return Q1("button",{"aria-expanded":J,"aria-haspopup":"menu","aria-label":Z,className:t2("documint-leaf-toolbar-button",J?"active":null,$),onPointerDown:(X)=>{if(b6(X),O6(X))A()},title:Z,type:"button",children:[Q1(M,{size:15,strokeWidth:2.2},void 0,!1,void 0,this),Q1(j2,{className:t2("documint-leaf-toolbar-menu-chevron",J?"is-open":null),size:13,strokeWidth:2.2},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function OX($,M){if(!SM($))return null;if($.type===hM){let{className:N}=$.props;return Q1("div",{className:t2("documint-leaf-toolbar-menu-divider",N),role:"separator"},void 0,!1,void 0,this)}if($.type!==IM)return null;let{disabled:J=!1,icon:Z,text:A,value:X}=$.props;return Q1("button",{className:"documint-leaf-toolbar-menu-item",disabled:J,onPointerDown:(N)=>{if(b6(N),!J&&O6(N))M(X)},role:"menuitem",type:"button",children:[Q1(Z,{size:15,strokeWidth:2.2},void 0,!1,void 0,this),Q1("span",{children:A},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function t2(...$){return $.filter(Boolean).join(" ")}function uM({children:$}){return Q1("div",{className:"documint-leaf-toolbar-group",children:$},void 0,!1,void 0,this)}function mM($){return null}function vM($){return null}function gM($){return null}function IM($){return null}function hM($){return null}var d=Object.assign(WX,{Button:mM,Divider:vM,Menu:gM,MenuDivider:hM,MenuItem:IM});import{jsxDEV as h,Fragment as jX}from"react/jsx-dev-runtime";var RX=!1,wX=220,R0=()=>{};function C6($){let M=$.mode==="create",J=$.mode==="create"?$:null,Z=$.mode==="thread"?$:null,A=$.canEdit,X=$.link,N=Z?.thread??null,Y=N?.comments??[],Q=Y[0]??null,K=N?A0(N):!1,q=Z?.animateInitialComment??!1,[U,G]=C0(null),[B,F]=C0(""),[_,D]=C0(""),[y,b]=C0(""),[O,k]=C0(!q),[j,R]=C0(RX),[w,L]=C0(!1),V=CX(null),T=N?K6(N):null,P=T?pM(T):"",E=A&&!K,W=E&&B.trim().length>0,z=E&&_.trim().length>0,u=A&&y.trim().length>0,p=M||w,I=!M||j,e=!M&&Boolean(N),f=Boolean(Q),m=M?j:!0,v=Z?.onDeleteComment??R0,Z1=Z?.onDeleteThread??R0,o=Z?.onToggleResolved??R0,_1=J?.activeMarks??[],T2=J?.onToggleBold??R0,$0=J?.onToggleItalic??R0,R1=J?.onToggleStrikethrough??R0,M0=J?.onToggleUnderline??R0,K1=A?M?"Add a comment":"Reply to this comment":"Comment editing is disabled",C4=M?y:_;n4(()=>{if(U!==null&&(U<0||U>=Y.length))G(null),F("")},[Y.length,U]),n4(()=>{if(!f||!q){k(!0);return}k(!1);let P1=requestAnimationFrame(()=>{k(!0)});return()=>{cancelAnimationFrame(P1)}},[q,Q,f]),n4(()=>{if(!Z||!q){L(!1);return}L(!0);let P1=window.setTimeout(()=>{L(!1)},wX);return()=>{window.clearTimeout(P1)}},[q,Z]),n4(()=>{if(!M||!j||!A)return;let P1=requestAnimationFrame(()=>{V.current?.querySelector(".documint-comment-reply-field textarea")?.focus()});return()=>{cancelAnimationFrame(P1)}},[A,M,j]);let R4=()=>{G(null),F("")},m0=(P1,n)=>{if(!e||!E)return;G(P1),F(n)},c5=(P1)=>{if(!Z)return;Z.onEditComment(P1,B),R4()},d1=()=>{if(!Z)return;Z.onReply(_),D("")},w4=()=>{if(!J||!u)return;J.onCreateThread(y),b("")},m1=p?`documint-comment-leaf documint-comment-leaf-create${m?" is-expanded":""}`:"documint-comment-leaf",E4=e||f||I?h(EX,{canCreate:u,canEdit:A,canMutateThread:E,canReply:z,canSaveEditedComment:W,commentAgeFormatter:pM,comments:Y,editDraft:B,editingCommentIndex:U,isComposerVisible:I,isInitialCommentVisible:O,isResolved:K,link:X,mode:$.mode,onBeginEditingComment:m0,onCancelEditing:R4,onChangeCreateDraft:b,onChangeEditDraft:F,onChangeReplyDraft:D,onDeleteComment:v,onDeleteThread:Z1,onSubmitCreate:w4,onSubmitEditedComment:c5,onSubmitReply:d1,onToggleResolved:o,rootComment:Q,showRootComment:f,showThreadChrome:e,threadAge:P,composerPlaceholder:K1,composerValue:C4},void 0,!1,void 0,this):null;return h("div",{className:m1,ref:V,children:h("div",{className:p?"documint-comment-leaf-create-shell":void 0,children:[p?h(d,{children:[h(d.Button,{className:"documint-comment-leaf-create-button",icon:l2,label:"Add comment",onClick:()=>R(!0)},void 0,!1,void 0,this),h(d.Divider,{className:"documint-comment-leaf-create-divider"},void 0,!1,void 0,this),h(d.Button,{active:_1.includes("bold"),className:"documint-comment-leaf-create-mark",icon:E2,label:"Bold",onClick:T2},void 0,!1,void 0,this),h(d.Button,{active:_1.includes("italic"),className:"documint-comment-leaf-create-mark",icon:g2,label:"Italic",onClick:$0},void 0,!1,void 0,this),h(d.Button,{active:_1.includes("underline"),className:"documint-comment-leaf-create-mark",icon:c2,label:"Underline",onClick:M0},void 0,!1,void 0,this),h(d.Button,{active:_1.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:x2,label:"Strikethrough",onClick:R1},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,h("div",{className:p?"documint-comment-leaf-create-content":void 0,children:E4},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function EX({canCreate:$,canEdit:M,canMutateThread:J,canReply:Z,canSaveEditedComment:A,commentAgeFormatter:X,comments:N,editDraft:Y,editingCommentIndex:Q,isComposerVisible:K,isInitialCommentVisible:q,isResolved:U,link:G,mode:B,onBeginEditingComment:F,onCancelEditing:_,onChangeCreateDraft:D,onChangeEditDraft:y,onChangeReplyDraft:b,onDeleteComment:O,onDeleteThread:k,onSubmitCreate:j,onSubmitEditedComment:R,onSubmitReply:w,onToggleResolved:L,rootComment:V,showRootComment:T,showThreadChrome:P,threadAge:E,composerPlaceholder:W,composerValue:z}){return h(jX,{children:[P?h("div",{className:"documint-comment-leaf-header",children:[h("span",{className:"documint-comment-leaf-age",children:E},void 0,!1,void 0,this),h("div",{className:"documint-comment-leaf-actions",children:[h("button",{className:"documint-leaf-action","aria-label":U?"Reopen comment":"Resolve comment",disabled:!M,onClick:L,title:U?"Reopen comment":"Resolve comment",type:"button",children:h(y0,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),h("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!M,onClick:k,title:"Delete comment thread",type:"button",children:h(y1,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):null,P&&G?h("div",{className:"documint-comment-leaf-link",children:[G.title?h("div",{className:"documint-link-leaf-title",children:G.title},void 0,!1,void 0,this):null,h("div",{className:"documint-link-leaf-url",children:G.url},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,h("div",{className:`documint-comment-thread${T?"":" is-empty"}`,children:[h("article",{className:T?`documint-comment-message documint-comment-message-root${q?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:V?h("p",{onDoubleClick:()=>{F(0,V.body)},children:V.body},void 0,!1,void 0,this):null},void 0,!1,void 0,this),N.slice(1).map((u,p)=>{let I=p+1,e=Q===I;return h("article",{className:"documint-comment-message",children:[!e?h("div",{className:"documint-comment-message-meta",children:[h("span",{children:X(u.updatedAt)},void 0,!1,void 0,this),J?h("div",{className:"documint-comment-leaf-actions",children:[h("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!J,onClick:()=>{F(I,u.body)},title:"Edit comment",type:"button",children:h(b0,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),h("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!J,onClick:()=>O(I),title:"Delete comment",type:"button",children:h(y1,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this):null,e?h(o4,{className:"documint-comment-input",onCancel:_,onChange:y,onSave:()=>R(I),readOnly:!M,rows:3,saveDisabled:!A,value:Y},void 0,!1,void 0,this):h("p",{onDoubleClick:()=>{F(I,u.body)},children:u.body},void 0,!1,void 0,this)]},`${u.updatedAt}:${I}`,!0,void 0,this)})]},void 0,!0,void 0,this),h("div",{className:`documint-comment-reply${P?"":" is-standalone"}${K?" is-visible":""}`,children:h("div",{className:"documint-comment-reply-field",children:[h("textarea",{className:"documint-comment-input",onChange:(u)=>B==="create"?D(u.currentTarget.value):b(u.currentTarget.value),placeholder:W,readOnly:!M,rows:3,value:z},void 0,!1,void 0,this),h("button",{className:"documint-leaf-action documint-comment-reply-submit","aria-label":B==="create"?"Create comment":"Reply",disabled:B==="create"?!$:!Z,onClick:B==="create"?j:w,title:B==="create"?"Create comment":"Reply",type:"button",children:h(Y0,{size:15,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function pM($){let M=new Date($);if(Number.isNaN(M.getTime()))return $;let J=M.getTime()-Date.now(),Z=60000,A=60*Z,X=24*A,N=7*X,Y=30*X,Q=365*X,K=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(J)<Z)return"just now";if(Math.abs(J)<A)return K.format(Math.round(J/Z),"minute");if(Math.abs(J)<X)return K.format(Math.round(J/A),"hour");if(Math.abs(J)<N)return K.format(Math.round(J/X),"day");if(Math.abs(J)<Q)return K.format(Math.round(J/Y),"month");return K.format(Math.round(J/Q),"year")}import{jsxDEV as k1}from"react/jsx-dev-runtime";var LX=[{icon:L2,label:"Heading 1",text:"# "},{icon:k2,label:"Heading 2",text:"## "},{icon:f2,label:"Heading 3",text:"### "},{icon:S2,label:"Heading 4",text:"#### "},{icon:u2,label:"Heading 5",text:"##### "},{icon:m2,label:"Heading 6",text:"###### "}],kX=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function lM({onInsert:$,onInsertTable:M}){return k1(d,{children:[k1(d.Button,{icon:p2,label:"Insert bulleted list",onClick:()=>$("- ")},void 0,!1,void 0,this),k1(d.Button,{icon:I2,label:"Insert numbered list",onClick:()=>$("1. ")},void 0,!1,void 0,this),k1(d.Button,{icon:h2,label:"Insert task list",onClick:()=>$("- [ ] ")},void 0,!1,void 0,this),k1(d.Divider,{},void 0,!1,void 0,this),k1(d.Menu,{icon:v2,label:"Insert heading",onSelect:$,children:LX.map(({icon:J,label:Z,text:A})=>k1(d.MenuItem,{icon:J,text:Z,value:A},A,!1,void 0,this))},void 0,!1,void 0,this),k1(d.Menu,{icon:Q0,label:"Insert table",onSelect:(J)=>M(Number(J)),children:kX.map(({columns:J,text:Z})=>k1(d.MenuItem,{icon:Q0,text:Z,value:String(J)},J,!1,void 0,this))},void 0,!1,void 0,this),k1(d.Divider,{},void 0,!1,void 0,this),k1(d.Button,{icon:r2,label:"Insert blockquote",onClick:()=>$("> ")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{createPortal as fX}from"react-dom";import{jsxDEV as R6}from"react/jsx-dev-runtime";function xM({anchor:$,children:M,className:J,status:Z="default"}){if(typeof document>"u")return null;let A=$.container??document.body,X=!$.isSelection,N=J?`documint-leaf-shell ${J}`:"documint-leaf-shell";return fX(R6("div",{className:"documint-leaf-anchor","data-selection":$.isSelection?"true":"false",onPointerEnter:$.onPointerEnter,onPointerLeave:$.onPointerLeave,style:{left:`${$.left}px`,top:`${$.top}px`},children:[X?R6("div",{className:"documint-leaf-bridge"},void 0,!1,void 0,this):null,R6("div",{className:N,"data-status":Z,children:M},void 0,!1,void 0,this)]},void 0,!0,void 0,this),A)}import{useEffect as rM,useRef as SX,useState as cM}from"react";import{jsxDEV as b1}from"react/jsx-dev-runtime";function dM({canEdit:$,onDelete:M,onSave:J,title:Z,url:A}){let[X,N]=cM(A),[Y,Q]=cM(!1),K=SX(null),q=uX(),U=X.trim(),G=$&&U.length>0,B=$&&!Y,F=`${q}click to open`,_=`documint-link-leaf-row${Y?" is-editing":""}`;return rM(()=>{if(Y)return;N(A)},[Y,A]),rM(()=>{if(!Y)return;K.current?.focus()},[Y]),b1("div",{className:"documint-link-leaf",children:[Z?b1("div",{className:"documint-link-leaf-title",children:Z},void 0,!1,void 0,this):null,b1("div",{className:_,children:[Y?b1(o4,{className:"documint-comment-input documint-link-leaf-input",onCancel:()=>{N(A),Q(!1)},onChange:N,onSave:()=>{J(U),Q(!1)},readOnly:!$,ref:K,rows:3,saveDisabled:!G,value:X},void 0,!1,void 0,this):b1("div",{className:"documint-link-leaf-url",children:A},void 0,!1,void 0,this),B?b1("div",{className:"documint-link-leaf-actions",children:[b1("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!$)return;N(A),Q(!0)},title:"Edit link",type:"button",children:b1(b0,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),b1("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:M,title:"Remove link",type:"button",children:b1(y1,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this),b1("div",{className:"documint-link-leaf-divider"},void 0,!1,void 0,this),b1("div",{className:"documint-link-leaf-hint",children:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function uX(){if(typeof navigator>"u")return"Ctrl+";let $=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test($)?"CMD+":"CTRL+"}import{jsxDEV as O1}from"react/jsx-dev-runtime";var mX=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],vX=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],w6={text:"Delete column",value:"delete"},E6={text:"Delete row",value:"delete"},aM={text:"Delete table",value:"delete"};function sM({canDeleteColumn:$,canDeleteRow:M,onDeleteColumn:J,onDeleteRow:Z,onDeleteTable:A,onInsertColumn:X,onInsertRow:N}){return O1(d,{children:[O1(d.Menu,{icon:X0,label:"Column actions",onSelect:(Y)=>{if(Y===w6.value){J();return}X(Y)},children:[mX.map(({text:Y,value:Q})=>O1(d.MenuItem,{icon:d0,text:Y,value:Q},Q,!1,void 0,this)),O1(d.MenuDivider,{},void 0,!1,void 0,this),O1(d.MenuItem,{disabled:!$,icon:y1,text:w6.text,value:w6.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),O1(d.Menu,{icon:N0,label:"Row actions",onSelect:(Y)=>{if(Y===E6.value){Z();return}N(Y)},children:[vX.map(({text:Y,value:Q})=>O1(d.MenuItem,{icon:d0,text:Y,value:Q},Q,!1,void 0,this)),O1(d.MenuDivider,{},void 0,!1,void 0,this),O1(d.MenuItem,{disabled:!M,icon:y1,text:E6.text,value:E6.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),O1(d.Divider,{},void 0,!1,void 0,this),O1(d.Menu,{icon:Q0,label:"Table actions",onSelect:()=>A(),children:O1(d.MenuItem,{icon:y1,text:aM.text,value:aM.value},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as gX,useEffectEvent as iM,useLayoutEffect as IX,useMemo as hX,useRef as oM,useState as pX}from"react";function t4($,M){if(!$||$.kind==="task-toggle")return null;if($.commentThreadIndex!==null){let J=M[$.commentThreadIndex]??null;if(!J)return null;return{kind:"comment",left:$.anchorLeft,link:$.kind==="link"?{title:$.title,url:$.url}:null,thread:J,threadIndex:$.commentThreadIndex,top:$.anchorBottom}}if($.kind!=="link")return null;return{endOffset:$.endOffset,kind:"link",left:$.anchorLeft,regionId:$.regionId,startOffset:$.startOffset,title:$.title,top:$.anchorBottom,url:$.url}}var lX=600,xX=530;function nM({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,editor:Z,editorState:A,editorViewportState:X,onVisibilityChange:N}){let Y=hX(()=>Z.normalizeSelection(A),[Z,A]),[Q,K]=pX(null),q=Y.start.regionId===Y.end.regionId&&Y.start.offset===Y.end.offset,U=oM(!0),G=oM(0),B=iM(()=>{N()}),F=iM(()=>{G.current=typeof performance<"u"?performance.now():Date.now(),U.current=!0,B()});return IX(()=>{let _=rX({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,editor:Z,normalizedSelection:Y,state:A,viewport:X.get()});K((D)=>sX(D,_)?D:_)},[$,M,J,Z,A,X,Y.end.offset,Y.end.regionId,Y.start.offset,Y.start.regionId]),gX(()=>{if(U.current=!0,B(),!q||typeof window>"u")return;let _=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-G.current<lX){if(!U.current)U.current=!0,B();return}U.current=!U.current,B()},xX);return()=>{window.clearInterval(_)}},[q]),{leaf:Q,isVisible:()=>U.current,markActivity:F}}function rX({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,editor:Z,normalizedSelection:A,state:X,viewport:N}){if(!N)return null;let Y=X.selection.focus;if(A.start.regionId!==A.end.regionId||A.start.offset!==A.end.offset)return null;let Q=$?aX(Z,X,N):null;if(Q)return Q;let K=M?cX(Z,X,N):null;if(K)return K;return t4(Z.resolveTargetAtSelection(X,N,Y,J.liveRanges),J.threads)}function cX($,M,J){let Z=M.selection.focus,A=M.documentIndex.regionIndex.get(Z.regionId),X=A?M.documentIndex.tableCellIndex.get(A.id)??null:null;if(!A||!X)return null;let N=M.documentIndex.blockIndex.get(A.blockId),Y=N?.type==="table"?M.documentIndex.document.blocks[N.rootIndex]:null;if(!N||!Y||Y.type!=="table")return null;let Q=$.measureVisualCaretTarget(M,J,Z),K=dX(J,A.id),q=Math.max(1,...Y.rows.map((U)=>U.cells.length));return Q&&K!==null?{cellIndex:X.cellIndex,columnCount:q,kind:"table",left:K,rowCount:Y.rows.length,rowIndex:X.rowIndex,top:Q.top+Q.height}:null}function dX($,M){let J=$.layout.lines.find((Z)=>Z.regionId===M);return J?J.left:null}function aX($,M,J){let Z=M.selection.focus,A=M.documentIndex.regionIndex.get(Z.regionId);if(!A||A.blockType!=="paragraph"||A.text.length>0)return null;if(Z.offset!==0)return null;let X=M.documentIndex.blockIndex.get(A.blockId);if(!X||X.parentBlockId!==null)return null;let N=$.measureVisualCaretTarget(M,J,Z);return N?{kind:"insertion",left:N.left,top:N.top+N.height}:null}function sX($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;switch($.kind){case"comment":return M.kind==="comment"&&$.left===M.left&&$.link?.title===M.link?.title&&$.link?.url===M.link?.url&&$.thread===M.thread&&$.threadIndex===M.threadIndex&&$.top===M.top;case"insertion":return M.kind==="insertion"&&$.left===M.left&&$.top===M.top;case"link":return M.kind==="link"&&$.endOffset===M.endOffset&&$.left===M.left&&$.regionId===M.regionId&&$.startOffset===M.startOffset&&$.title===M.title&&$.top===M.top&&$.url===M.url;case"table":return M.kind==="table"&&$.cellIndex===M.cellIndex&&$.columnCount===M.columnCount&&$.left===M.left&&$.rowCount===M.rowCount&&$.rowIndex===M.rowIndex&&$.top===M.top}}import{useEffect as eq,useMemo as N$,useRef as l7,useState as $U}from"react";var e2="",tM=1e6;function $4($,M,J){return`${$}:${M}:${J}`}function T1($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&Z.marks.join(",")===J.marks.join(",")){M[M.length-1]=I1({marks:Z.marks,path:Z.id,text:Z.text+J.text});continue}M.push(J)}return M}function n0($){let M=UN($),J=L6(M.blocks.map((Z,A)=>J4(Z,A)));return k6(M,J)}function J4($,M){let J=[],Z=[],A=[],X=0;function N(Q,K,q,U,G=null){if(Z.length>0)A.push(`
|
|
13
|
+
`),X+=1;let B=q.map((D)=>D.text).join(""),F=X,_=F+B.length;A.push(B),X=_,Z.push({blockId:Q.id,blockType:Q.type,end:_,id:`${Q.id}:${K}`,path:K,rootIndex:M,inlines:q,semanticRegionId:U,start:F,tableCellPosition:G,text:B})}function Y(Q,K,q,U){let G={childBlockIds:[],depth:q,end:X,id:Q.id,parentBlockId:U,path:K,regionIds:[],rootIndex:M,start:X,type:Q.type};switch(J.push(G),Q.type){case"blockquote":case"listItem":for(let[B,F]of Q.children.entries())G.childBlockIds.push(F.id),Y(F,`${K}.children.${B}`,q+1,Q.id);break;case"code":{N(Q,`${K}.source`,[{end:Q.source.length,id:`${Q.id}:code`,image:null,inlineCode:!1,kind:"text",link:null,marks:[],originalType:null,start:0,text:Q.source}],Q.id),G.regionIds.push(Z.at(-1).id);break}case"heading":case"paragraph":N(Q,`${K}.children`,j6(Q.children),Q.id),G.regionIds.push(Z.at(-1).id);break;case"list":for(let[B,F]of Q.items.entries())G.childBlockIds.push(F.id),Y(F,`${K}.children.${B}`,q+1,Q.id);break;case"table":for(let[B,F]of Q.rows.entries())for(let[_,D]of F.cells.entries())N(Q,`${K}.rows.${B}.cells.${_}`,j6(D.children),D.id,{cellIndex:_,rowIndex:B}),G.regionIds.push(Z.at(-1).id);break;case"thematicBreak":break;case"directive":break;case"unsupported":N(Q,`${K}.source`,[{end:Q.source.length,id:`${Q.id}:unsupported`,image:null,inlineCode:!1,kind:"unsupported",link:null,marks:[],originalType:Q.originalType,start:0,text:Q.source}],Q.id),G.regionIds.push(Z.at(-1).id);break}G.end=X}return Y($,`root.${M}`,0,null),{blockRange:{end:J.length,start:0},blocks:J,end:X,length:X,regionRange:Z.length>0?{end:Z.length,start:0}:void 0,regions:Z,rootIndex:M,start:0,text:A.join("")}}function L6($,M=null){let J=[],Z=0,A=0,X=0,N=!1;for(let[Y,Q]of $.entries()){if(Q.regions.length>0&&N)X+=1;let K={...Q,blockRange:{end:Z+Q.blocks.length,start:Z},end:X+Q.length,regionRange:Q.regions.length>0?{end:A+Q.regions.length,start:A}:void 0,start:X},q=M?.[Y];if(J.push(oX(q,Q,K)?q:eM(Q,K)),Z=K.blockRange.end,A=K.regionRange?.end??A,Q.regions.length>0)X=K.end,N=!0}return J}function Z4($,M,J,Z){let A=M.blocks.length-($.roots.length-Z);if(A<0)throw Error("Editor model splice received an invalid replacement count.");if(J===$.roots.length&&A===1){let Q=M.blocks[J];if(Q)return iX($,M,Q)}let X=A===Z,N=[...$.roots.slice(0,J),...M.blocks.slice(J,J+A).map((Q,K)=>J4(Q,J+K)),...X?$.roots.slice(J+Z):M.blocks.slice(J+A).map((Q,K)=>J4(Q,J+A+K))],Y=L6(N,$.roots);return k6(M,Y,$)}function iX($,M,J){let Z=$.roots.length,A=J4(J,Z),X=$.roots.some((q)=>q.regions.length>0),N=A.regions.length>0&&X?$.length+1:$.length,Y=eM(A,{...A,blockRange:{end:$.blocks.length+A.blocks.length,start:$.blocks.length},end:N+A.length,regionRange:A.regions.length>0?{end:$.regions.length+A.regions.length,start:$.regions.length}:void 0,start:N}),Q=[...$.blocks,...Y.blocks],K=[...$.regions,...Y.regions];return{blockIndex:MN($.blockIndex,Y.blocks),blocks:Q,commentContainerIndex:M.comments===$.document.comments?$.commentContainerIndex:$3(M),document:M,engine:"canvas",length:Y.end,listItemMarkers:M.blocks===$.document.blocks?$.listItemMarkers:YN($.listItemMarkers,J),regionIndex:JN($.regionIndex,Y.regions),regionOrderIndex:ZN($.regionOrderIndex,Y.regions,$.regions.length),regionPathIndex:AN($.regionPathIndex,Y.regions),regions:K,roots:[...$.roots,Y],tableCellIndex:XN($.tableCellIndex,Y.regions),tableCellRegionIndex:NN($.tableCellRegionIndex,Y.regions),text:QN($.text,Y)}}function A4($,M){if(M.blocks!==$.document.blocks)throw Error("Editor model document replacement requires preserving root blocks.");return k6(M,$.roots,$)}function k6($,M,J=null){let Z=M.flatMap((q)=>q.blocks),A=M.flatMap((q)=>q.regions),{regionIndex:X,regionOrderIndex:N,regionPathIndex:Y,tableCellIndex:Q,tableCellRegionIndex:K}=$N(A);return{blockIndex:eX(Z),blocks:Z,commentContainerIndex:$.comments===J?.document.comments?J.commentContainerIndex:$3($),document:$,engine:"canvas",length:M.at(-1)?.end??0,listItemMarkers:$.blocks===J?.document.blocks?J.listItemMarkers:qN($.blocks),regionIndex:X,regionOrderIndex:N,regionPathIndex:Y,regions:A,roots:M,tableCellIndex:Q,tableCellRegionIndex:K,text:KN(M)}}function eM($,M){let J=M.start-$.start;return{...M,blocks:J===0?$.blocks:nX($.blocks,J),regions:J===0?$.regions:tX($.regions,J)}}function oX($,M,J){return Boolean($&&M===$&&$.start===J.start&&$.end===J.end&&$.blockRange.start===J.blockRange.start&&$.blockRange.end===J.blockRange.end&&$.regionRange?.start===J.regionRange?.start&&$.regionRange?.end===J.regionRange?.end)}function nX($,M){return $.map((J)=>({...J,end:J.end+M,start:J.start+M}))}function tX($,M){return $.map((J)=>({...J,end:J.end+M,start:J.start+M}))}function eX($){let M=new Map;for(let J of $)M.set(J.id,J);return M}function $N($){let M=new Map,J=new Map,Z=new Map,A=new Map,X=new Map;for(let[N,Y]of $.entries()){if(M.set(Y.id,Y),J.set(Y.id,N),Z.set(Y.path,Y),!Y.tableCellPosition)continue;A.set(Y.id,Y.tableCellPosition),X.set($4(Y.blockId,Y.tableCellPosition.rowIndex,Y.tableCellPosition.cellIndex),Y.id)}return{regionIndex:M,regionOrderIndex:J,regionPathIndex:Z,tableCellIndex:A,tableCellRegionIndex:X}}function MN($,M){let J=new Map($);for(let Z of M)J.set(Z.id,Z);return J}function JN($,M){let J=new Map($);for(let Z of M)J.set(Z.id,Z);return J}function ZN($,M,J){let Z=new Map($);for(let[A,X]of M.entries())Z.set(X.id,J+A);return Z}function AN($,M){let J=new Map($);for(let Z of M)J.set(Z.path,Z);return J}function XN($,M){let J=new Map($);for(let Z of M)if(Z.tableCellPosition)J.set(Z.id,Z.tableCellPosition);return J}function NN($,M){let J=new Map($);for(let Z of M){if(!Z.tableCellPosition)continue;J.set($4(Z.blockId,Z.tableCellPosition.rowIndex,Z.tableCellPosition.cellIndex),Z.id)}return J}function YN($,M){let J=new Map($);return M4(J,[M]),J}function QN($,M){if(M.regions.length===0)return $;return $.length>0?`${$}
|
|
14
|
+
${M.text}`:M.text}function KN($){return $.filter((M)=>M.regions.length>0).map((M)=>M.text).join(`
|
|
15
|
+
`)}function $3($){let M=new Map;for(let[J,Z]of $.comments.entries()){let A=C2(Z,$).match?.containerId??null;if(!A)continue;let X=M.get(A)??[];X.push(J),M.set(A,X)}return M}function qN($){let M=new Map;return M4(M,$),M}function M4($,M,J=null){for(let Z of M){if(Z.type==="list"){for(let[A,X]of Z.items.entries())M4($,[X],{index:A,ordered:Z.ordered,start:Z.start});continue}if(Z.type==="listItem"){if(typeof Z.checked==="boolean")$.set(Z.id,{checked:Z.checked,kind:"task"});else if(J?.ordered)$.set(Z.id,{kind:"ordered",label:`${(J.start??1)+J.index}.`});else $.set(Z.id,{kind:"bullet",label:"•"});M4($,Z.children,J)}if(Z.type==="blockquote")M4($,Z.children,J)}}function UN($){if($.blocks.length>0)return $;return l0([r({text:""})],$.comments)}function j6($,M=null){let J=[],Z=0,A=(X)=>{let N=Z,Y=N+X.text.length;J.push({...X,end:Y,start:N}),Z=Y};for(let X of $)switch(X.type){case"break":A({id:X.id,image:null,inlineCode:!1,kind:"break",link:M,marks:[],originalType:null,text:`
|
|
16
|
+
`});break;case"image":A({id:X.id,image:{alt:X.alt,title:X.title,url:X.url,width:X.width},inlineCode:!1,kind:"image",link:M,marks:[],originalType:null,text:GN(X.alt)});break;case"inlineCode":A({id:X.id,image:null,inlineCode:!0,kind:"inlineCode",link:M,marks:[],originalType:null,text:X.code});break;case"link":for(let N of j6(X.children,{title:X.title,url:X.url}))A(N);break;case"text":A({id:X.id,image:null,inlineCode:!1,kind:"text",link:M,marks:X.marks,originalType:null,text:X.text});break;case"unsupported":A({id:X.id,image:null,inlineCode:!1,kind:"unsupported",link:M,marks:[],originalType:X.originalType,text:X.source});break}return J}function GN($){return e2}function A1($,M,J=0){return{childIndices:M,kind:"descendant-primary-region",offset:J,rootIndex:$}}function $1($,M=0){return{kind:"root-primary-region",offset:M,rootIndex:$}}function G0($,M,J,Z=0){return{cellIndex:J,kind:"table-cell",offset:Z,rootIndex:$,rowIndex:M}}function w0($,M){return $.regionIndex.get(M)??null}function t0($,M){return $.regionPathIndex.get(M)??null}function e0($,M,J,Z){let A=$.tableCellRegionIndex.get($4(M,J,Z));return A?$.regionIndex.get(A)??null:null}function X1($,M){let J=M3($,M.anchor),Z=M3($,M.focus);if(J<=Z)return{end:M.focus,start:M.anchor};return{end:M.anchor,start:M.focus}}function X4($,M){if(!M)return null;if("kind"in M){if(M.kind==="root-primary-region"){let Z=$.document.blocks[M.rootIndex],A=Z?f6($,Z):null;return A?e4(A.id,$5(A.text,M.offset)):null}if(M.kind==="descendant-primary-region"){let Z=$.document.blocks[M.rootIndex],A=Z?BN(Z,M.childIndices):null,X=A?f6($,A):null;return X?e4(X.id,$5(X.text,M.offset)):null}if(M.kind==="table-cell"){let Z=$.document.blocks[M.rootIndex];if(!Z||Z.type!=="table")return null;let A=e0($,Z.id,M.rowIndex,M.cellIndex);return A?e4(A.id,$5(A.text,M.offset)):null}let J=t0($,M.path);if(!J)return null;if(M.kind==="region-path")return e4(J.id,$5(J.text,M.offset));return{anchor:{regionId:J.id,offset:Math.max(0,Math.min(M.startOffset,J.text.length))},focus:{regionId:J.id,offset:Math.max(0,Math.min(M.endOffset,J.text.length))}}}return M}function M3($,M){let J=$.regionOrderIndex.get(M.regionId);if(J===void 0)throw Error(`Unknown canvas region: ${M.regionId}`);return J*tM+M.offset}function e4($,M){let J={offset:M,regionId:$};return{anchor:J,focus:J}}function $5($,M){return M==="end"?$.length:Math.max(0,Math.min(M,$.length))}function BN($,M){let J=$;for(let Z of M){if(!J)return null;let A=J3(J);if(!A)return null;J=A[Z]??null}return J}function f6($,M){let J=$.blockIndex.get(M.id);if(!J)return null;let Z=J.regionIds[0];if(Z)return $.regionIndex.get(Z)??null;let A=J3(M);if(!A)return null;for(let X of A){let N=f6($,X);if(N)return N}return null}function J3($){switch($.type){case"list":return $.items;case"blockquote":case"listItem":return $.children;default:return null}}function N4($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=r0($.document.blocks,J.blockId);if(!Z)return null;return Y4(Z,J.path,J.semanticRegionId)}function S6($,M,J,Z,A){if(J>=Z)return null;let X=N4($,M);return X?A(X,J,Z):null}function $2($,M,J,Z,A){let X=S6($,M,J,Z,A);return X?{kind:"replace-block",block:X.block,blockId:X.blockId,selection:X.selection}:null}function Y4($,M,J){if($.type==="heading"||$.type==="paragraph")return{block:$,children:$.children,kind:"inlineBlock",path:M.replace(/\.children$/,"")};if($.type!=="table")return null;let Z=/^(.*\.rows\.\d+\.cells\.\d+)$/.exec(M);if(!Z)return null;for(let A of $.rows)for(let X of A.cells)if(X.id===J)return{block:$,blockPath:Z[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:X,children:X.children,kind:"tableCell",path:Z[1]};return null}function B0($,M,J,Z){switch($.kind){case"inlineBlock":return{block:h0($.block,M),blockId:$.block.id,selection:Z3(`${$.path}.children`,J,Z)};case"tableCell":{let A=Z0({children:M,path:$.path}),X=$.block.rows.map((N)=>({...N,cells:N.cells.map((Y)=>Y.id===$.cell.id?A:Y)}));return{block:p1($.block,X),blockId:$.block.id,selection:Z3($.path,J,Z)}}}}function Z3($,M,J){return{endOffset:J,kind:"region-range-path",path:$,startOffset:M}}function W1($){switch($.type){case"break":return 1;case"image":return e2.length;case"inlineCode":return $.code.length;case"link":return B1($.children).length;case"text":return $.text.length;case"unsupported":return $.source.length}}function M5($,M,J){if(M<=0)return[];return u6($,0,M,`${J}.before`)}function J5($,M,J){let Z=W1($);if(M>=Z)return[];return u6($,M,Z,`${J}.after`)}function u6($,M,J,Z){if(M>=J)return[];switch($.type){case"text":return T1([E0($.text.slice(M,J),$.marks,Z)].filter(Boolean));case"inlineCode":return[v6($.code.slice(M,J),Z)];case"link":{let A=T1(FN($.children,M,J,`${Z}.children`));return A.length>0?[{...$,children:A}]:[]}default:return[]}}function m6($,M,J){let Z=0,A="";for(let X of $){let N=W1(X),Y=Z,Q=Y+N;if(Z=Q,J<=Y||M>=Q)continue;A+=_N(X,Math.max(0,M-Y),Math.min(N,J-Y))}return A}function E0($,M,J){if($.length===0)return null;return I1({marks:M,path:J,text:$})}function v6($,M){return v0({code:$,path:M})}function FN($,M,J,Z){let A=[],X=0;for(let[N,Y]of $.entries()){let Q=W1(Y),K=X,q=K+Q;if(X=q,J<=K||M>=q)continue;A.push(...u6(Y,Math.max(0,M-K),Math.min(Q,J-K),`${Z}.${N}`))}return A}function _N($,M,J){if(M>=J)return"";switch($.type){case"break":return`
|
|
17
|
+
`.slice(M,J);case"image":return e2.slice(M,J);case"inlineCode":return $.code.slice(M,J);case"link":return m6($.children,M,J);case"text":return $.text.slice(M,J);case"unsupported":return $.source.slice(M,J)}}function Z5($,M,J,Z){let A=DN($.children,M,J,Z);if(A===null)return null;let X=T1(A3($.children,M,J,Z,A,`${$.path}.children`));return X.length>0?B0($,X,M,J):null}function A5($,M,J){let Z=0,A=null,X=(N)=>{for(let Y of N){let Q=W1(Y),K=Z,q=K+Q;if(Z=q,J<=K||M>=q)continue;if(Y.type==="text"){let U=Math.max(M,K);if(Math.min(J,q)>U)A=A===null?new Set(Y.marks):new Set(Y.marks.filter((B)=>A?.has(B)));continue}if(Y.type==="link"){let U=Z;Z=K,X(Y.children),Z=U}}};return X($.children),A?[...A]:[]}function DN($,M,J,Z){let A=0,X=!1,N=!0,Y=(Q)=>{for(let K of Q){let q=W1(K),U=A,G=U+q;if(A=G,J<=U||M>=G)continue;if(K.type==="text"){let B=Math.max(M,U);if(Math.min(J,G)>B)X=!0,N&&=K.marks.includes(Z);continue}if(K.type==="link"){let B=A;A=U,Y(K.children),A=B}}};return Y($),X?N:null}function A3($,M,J,Z,A,X){let N=[],Y=0;for(let[Q,K]of $.entries()){let q=Y,U=W1(K),G=q+U,B=`${X}.${Q}`;if(Y=G,J<=q||M>=G){N.push(K);continue}if(K.type==="text"){N.push(...HN(K,Math.max(0,M-q),Math.min(U,J-q),Z,A,B));continue}if(K.type==="link"){let F=T1(A3(K.children,Math.max(0,M-q),Math.min(U,J-q),Z,A,`${B}.children`));if(F.length>0)N.push({...K,children:F});continue}N.push(K)}return N}function HN($,M,J,Z,A,X){let N=$.text.slice(0,M),Y=$.text.slice(M,J),Q=$.text.slice(J),K=A?$.marks.filter((q)=>q!==Z):TN($.marks,Z);return[E0(N,$.marks,`${X}.before`),E0(Y,K,`${X}.selected`),E0(Q,$.marks,`${X}.after`)].filter(Boolean)}function TN($,M){return $.includes(M)?$:[...$,M].sort()}function X5($,M,J){let Z=T1(PN($.children,M,J,`${$.path}.children`));return Z.length>0?B0($,Z,M,J):null}function PN($,M,J,Z){let A=N3($,M,J);if(A)return X3($,M,J,A.code,Z,!1);let X=m6($,M,J);if(X.length===0)return $;return X3($,M,J,X,Z,!0)}function N3($,M,J){let Z=0;for(let A of $){let X=W1(A),N=Z,Y=N+X;if(Z=Y,M===N&&J===Y&&A.type==="inlineCode")return A;if(A.type==="link"){let Q=N3(A.children,Math.max(0,M-N),Math.min(X,J-N));if(Q)return Q}}return null}function X3($,M,J,Z,A,X){let N=[],Y=0,Q=!1;for(let[K,q]of $.entries()){let U=`${A}.${K}`,G=W1(q),B=Y,F=B+G;if(Y=F,J<=B||M>=F){N.push(q);continue}if(!Q){N.push(...M5(q,Math.max(0,M-B),U));let _=X?v6(Z,`${A}.selected`):E0(Z,[],`${A}.selected`);if(_)N.push(_);Q=!0}N.push(...J5(q,Math.min(G,J-B),U))}return N}function Q4($,M,J,Z,A){return $2($,M,J,Z,(X,N,Y)=>g6(X,N,Y,A))}function g6($,M,J,Z){let A=T1(WN($.children,M,J,Z,`${$.path}.children`)??[]);return A.length>0?B0($,A,M,J):null}function WN($,M,J,Z,A){let X=[],N=0,Y=!1;for(let[Q,K]of $.entries()){let q=`${A}.${Q}`,U=W1(K),G=N,B=G+U;if(N=B,!Y&&K.type==="link"&&M===G&&J===B){if(Z===null)X.push(...K.children);else X.push(g0({children:K.children,path:q,title:K.title,url:Z}));Y=!0;continue}X.push(K)}return Y?X:null}function N5($,M,J){let Z=T1(zN($.children,M,J,`${$.path}.children`));return B0($,Z,M+1,M+1)}function zN($,M,J,Z){let A=[],X=0,N=!1;for(let[Y,Q]of $.entries()){let K=`${Z}.${Y}`,q=W1(Q),U=X,G=U+q;if(X=G,J<=U||M>=G){A.push(Q);continue}if(!N)A.push(...M5(Q,Math.max(0,M-U),K)),A.push(z2({path:`${Z}.selected`})),N=!0;A.push(...J5(Q,Math.min(q,J-U),K))}if(!N)A.push(z2({path:`${Z}.selected`}));return A}function Z2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return{kind:"unsupported"};if(J.blockType==="code"){let Y=$.blockIndex.get(J.blockId);return Y?{kind:"code",region:J,rootIndex:Y.rootIndex}:{kind:"unsupported"}}let Z=i1($,J.id);if(Z)return{kind:"tableCell",...Z};let A=S1($,M);if(A)return{kind:"listItem",...A};let X=j0($,M);if(X)return{kind:"blockquoteTextBlock",...X};let N=f1($,M);if(N)return{kind:"rootTextBlock",...N};return{kind:"unsupported"}}function A2($,M){let J=$.blockIndex.get(M);if(!J)throw Error(`Unknown root block: ${M}`);return J.rootIndex}function K4($,M,J){let Z=M?$.blockIndex.get(M)??null:null;while(Z){if(Z.type===J)return Z;let A=Z.parentBlockId;Z=A?$.blockIndex.get(A)??null:null}return null}function M2($){let M=$.split("."),J=[];for(let Z=0;Z<M.length-1;Z+=1)if(M[Z]==="children"){let A=Number(M[Z+1]);if(Number.isInteger(A))J.push(A)}return J}function f1($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId);if(!Z)return null;let A=Z.rootIndex,X=$.document.blocks[A];if(!X||X.type!=="heading"&&X.type!=="paragraph")return null;return{block:X,region:J,rootIndex:A}}function I6($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),A=K4($,Z?.id??null,"blockquote");if(!A)return null;let X=A.rootIndex,N=$.document.blocks[X];return N?.type==="blockquote"?{quote:N,rootIndex:X}:null}function j0($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),A=K4($,Z?.id??null,"blockquote");if(!Z||!A||Z.parentBlockId!==A.id)return null;let X=A.rootIndex,N=$.document.blocks[X];if(!N||N.type!=="blockquote")return null;let Y=N.children.findIndex((K)=>K.id===Z.id),Q=N.children[Y];if(!Q||Q.type!=="heading"&&Q.type!=="paragraph")return null;return{block:Q,blockChildIndices:M2(Z.path),childIndex:Y,region:J,quote:N,rootIndex:X}}function J2($,M){return r0($.document.blocks,M)}function S1($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),A=K4($,Z?.id??null,"listItem"),X=K4($,Z?.id??null,"list");if(!Z||!A||!X)return null;let N=J2($,X.id);if(!N||N.type!=="list")return null;let Y=N.items.findIndex((F)=>F.id===A.id),Q=N.items[Y];if(!Q)return null;let K=X.parentBlockId?$.blockIndex.get(X.parentBlockId)??null:null,q=K?.parentBlockId?$.blockIndex.get(K.parentBlockId)??null:null,U=K?.type==="listItem"?J2($,K.id):null,G=q?.type==="list"?J2($,q.id):null,B=G?.type==="list"&&U?G.items.findIndex((F)=>F.id===U.id):-1;return{region:J,item:Q,itemChildIndices:M2(A.path),itemIndex:Y,list:N,listChildIndices:M2(X.path),parentItem:U?.type==="listItem"?U:null,parentItemChildIndices:K?.type==="listItem"?M2(K.path):null,parentItemIndex:B>=0?B:null,parentList:G?.type==="list"?G:null,parentListChildIndices:q?.type==="list"?M2(q.path):null,rootIndex:X.rootIndex}}function i1($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=$.tableCellIndex.get(J.id),A=$.blockIndex.get(J.blockId),X=A?.type==="table"?$.document.blocks[A.rootIndex]:null;if(!Z||!A||!X||X.type!=="table")return null;return{cellIndex:Z.cellIndex,rootIndex:A.rootIndex,rowIndex:Z.rowIndex,table:X}}function X2($,M,J){return s1({checked:M,children:[r({text:$})],spread:J})}function L0($,M){let J=$.children[0];if(!J||J.type!=="paragraph")return null;return h1($,[r({text:M}),...$.children.slice(1)])}function h6($,M){return M.reduce((J,Z)=>`${J}.children.${Z}`,`root.${$}`)}function q4($,M){let J=X1($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=f1($,M);if(!Z)return Y3($,M);let A=Z.region.text.slice(0,J.start.offset),X=Z.region.text.slice(J.start.offset),N=J.start.offset===0&&Z.region.text.length>0?Z.rootIndex:Z.rootIndex+1;if(Z.block.type==="paragraph")return{kind:"replace-root-range",count:1,replacements:J.start.offset===0?[r({text:""}),Z.block]:J.start.offset===Z.region.text.length?[Z.block,r({text:""})]:[r({text:A}),r({text:X})],rootIndex:Z.rootIndex,selection:$1(N)};return{kind:"replace-root-range",count:1,replacements:J.start.offset===0?[r({text:""}),Z.block]:J.start.offset===Z.region.text.length?[Z.block,r({text:""})]:[J0({depth:Z.block.depth,text:A}),r({text:X})],rootIndex:Z.rootIndex,selection:$1(N)}}function Y3($,M){let J=X1($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=j0($,M);if(!Z)return null;let A=Z.region.text,X=A.slice(0,J.start.offset),N=A.slice(J.start.offset),Y=Z.block.type==="heading"?RN(Z.block,X,N,Z.blockChildIndices,J.start.offset,A.length):CN(Z.block,X,N,Z.blockChildIndices,J.start.offset,A.length);return{kind:"replace-root",block:j1({children:[...Z.quote.children.slice(0,Z.childIndex),...Y.blocks,...Z.quote.children.slice(Z.childIndex+1)]}),rootIndex:Z.rootIndex,selection:A1(Z.rootIndex,Y.focusChildIndices)}}function p6($,M){let J=X1($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=j0($,M);if(!Z||Z.region.text.length!==0||Z.block.type!=="paragraph")return null;let A=Z.quote.children.slice(0,Z.childIndex),X=Z.quote.children.slice(Z.childIndex+1),N=[];if(A.length>0)N.push(j1({children:A}));if(N.push(r({text:""})),X.length>0)N.push(j1({children:X}));return{kind:"replace-root-range",count:1,replacements:N,rootIndex:Z.rootIndex,selection:$1(Z.rootIndex+(A.length>0?1:0))}}function l6($,M){let J=X1($,M);if(J.start.regionId!==J.end.regionId||J.start.regionId!==M.anchor.regionId)return null;let Z=$.regionIndex.get(J.start.regionId);if(!Z||Z.blockType!=="code")return null;return{kind:"replace-selection-text",selection:M,text:`
|
|
18
|
+
`}}function x6($,M){let J=X1($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=f1($,M),A=Z?bN(Z):null;if(A)return A;if(Z&&Z.rootIndex>0){let Q=$.document.blocks[Z.rootIndex-1],K=$.document.blocks[Z.rootIndex+1];if(Q){if(Z.block.plainText.length===0){let q=VN(Z,Q,K);if(q)return q;return{kind:"replace-root-range",count:1,replacements:[],rootIndex:Z.rootIndex,selection:Q.type==="paragraph"||Q.type==="heading"?$1(Z.rootIndex-1,"end"):Q.type==="list"?A1(Z.rootIndex-1,[Q.items.length-1,0],"end"):Q.type==="blockquote"?A1(Z.rootIndex-1,[Q.children.length-1],"end"):$1(Z.rootIndex-1,"end")}}if(Q.type==="paragraph")return{kind:"replace-root-range",count:2,replacements:[r({text:`${Q.plainText}${Z.block.plainText}`})],rootIndex:Z.rootIndex-1,selection:$1(Z.rootIndex-1,"end")};if(Q.type==="heading")return{kind:"replace-root-range",count:2,replacements:[J0({depth:Q.depth,text:`${Q.plainText}${Z.block.plainText}`})],rootIndex:Z.rootIndex-1,selection:$1(Z.rootIndex-1,"end")};if(Q.type==="list"){let q=Q.items.length-1,U=Q.items[q];if(U){let G=L0(U,`${U.plainText}${Z.block.plainText}`);if(G)return{kind:"replace-root-range",count:2,replacements:[J1(Q,Q.items.map((B,F)=>F===q?G:B))],rootIndex:Z.rootIndex-1,selection:A1(Z.rootIndex-1,[q,0],"end")}}}}}let X=ON($,M);if(X)return X;let N=I6($,M);if(!N)return null;let Y=j0($,M);return{kind:"replace-root-range",count:1,replacements:N.quote.children,rootIndex:N.rootIndex,selection:$1(Y?N.rootIndex+Y.childIndex:N.rootIndex)}}function Y5($,M,J){let Z=f1($,M);if(!Z||Z.block.type!=="heading")return null;let A=Math.max(1,Math.min(6,Z.block.depth+J));if(A===Z.block.depth)return{kind:"keep-state"};return{kind:"replace-root",block:J0({depth:A,text:Z.block.plainText}),rootIndex:Z.rootIndex,selection:$1(Z.rootIndex,M.focus.offset)}}function VN($,M,J){if($.block.type!=="paragraph"||$.block.plainText.length!==0||M.type!=="list"||J?.type!=="list"||!yN(M,J))return null;let Z=M.items.length-1;return{kind:"replace-root-range",count:3,replacements:[J1(M,[...M.items,...J.items])],rootIndex:$.rootIndex-1,selection:A1($.rootIndex-1,[Z,0],"end")}}function yN($,M){return $.ordered===M.ordered&&$.start===M.start}function bN($){if($.block.type!=="heading")return null;return{kind:"replace-root",block:r({text:$.block.plainText}),rootIndex:$.rootIndex,selection:$1($.rootIndex)}}function ON($,M){let J=X1($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=j0($,M);if(!Z||Z.block.type!=="paragraph"||Z.region.text.length!==0)return null;if(Z.quote.children.length===1)return{kind:"replace-root-range",count:1,replacements:[r({text:""})],rootIndex:Z.rootIndex,selection:$1(Z.rootIndex)};let A=Math.max(0,Z.childIndex-1),X=Z.childIndex>0?"end":0;return{kind:"replace-root",block:j1({children:Z.quote.children.filter((N,Y)=>Y!==Z.childIndex)}),rootIndex:Z.rootIndex,selection:A1(Z.rootIndex,[A],X)}}function CN($,M,J,Z,A,X){return{blocks:A===0?[r({text:""}),$]:A===X?[$,r({text:""})]:[r({text:M}),r({text:J})],focusChildIndices:A===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function RN($,M,J,Z,A,X){return{blocks:A===0?[r({text:""}),$]:A===X?[$,r({text:""})]:[J0({depth:$.depth,text:M}),r({text:J})],focusChildIndices:A===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function c6($,M,J){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let A=X1($,M),X=A.start.regionId===A.end.regionId&&A.start.regionId===Z.id?Z.text.slice(0,A.start.offset)+J+Z.text.slice(A.end.offset):J;return wN($,M,Z.id,X)??jN($,M,Z.id,X)??EN($,M,Z.id,X)??LN($,M,Z.id,X)??SN($,Z.blockId,Z.rootIndex,X)??{kind:"replace-selection-text",selection:M,text:J}}function wN($,M,J,Z){let A=S1($,M),X=vN(Z);if(!A||!X||A.region.id!==J)return null;let N=L0(A.item,X.text);if(!N)return null;return{kind:"replace-block",block:J1(A.list,A.list.items.map((Y,Q)=>Q===A.itemIndex?N:Y),{ordered:X.ordered,start:X.ordered?1:null}),blockId:A.list.id,selection:A1(A.rootIndex,[...A.listChildIndices,A.itemIndex,0])}}function EN($,M,J,Z){if(!d6($,M,J))return null;if(/^\s*([-+*])\s\[( |x|X)\]\s$/.exec(Z)){let N=Z.toLowerCase().includes("[x]");return r6($,M,{checked:N,ordered:!1,start:null})}if(/^\s*[-+*]\s$/.test(Z))return r6($,M,{checked:null,ordered:!1,start:null});let X=/^\s*(\d+)\.\s$/.exec(Z);if(X)return r6($,M,{checked:null,ordered:!0,start:Number(X[1])});return null}function jN($,M,J,Z){let A=f1($,M),X=gN(Z);if(!A||A.region.id!==J||A.block.type!=="heading"||!X)return null;return{kind:"replace-root",block:J0({depth:X.depth,text:X.text}),rootIndex:A.rootIndex,selection:$1(A.rootIndex)}}function LN($,M,J,Z){return kN($,M,J,Z)??fN($,M,J,Z)}function kN($,M,J,Z){if(!d6($,M,J))return null;let A=/^(#{1,6})\s$/.exec(Z);if(!A)return null;return uN($,M,A[1].length)}function fN($,M,J,Z){if(!d6($,M,J)||!/^>\s$/.test(Z))return null;return mN($,M)}function SN($,M,J,Z){if(!/^(?:(?:-\s?){3}|(?:\*\s?){3}|(?:_\s?){3})$/.test(Z))return null;return{kind:"replace-root-range",count:1,replacements:[f4(),r({text:""})],rootIndex:A2($,M),selection:$1(J+1)}}function r6($,M,J){let Z=A2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:z0({items:[s1({checked:J.checked,children:[r({text:""})],spread:!1})],ordered:J.ordered,spread:!1,start:J.start}),rootIndex:Z,selection:A1(Z,[0,0])}}function uN($,M,J){let Z=A2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:J0({depth:J,text:""}),rootIndex:Z,selection:$1(Z)}}function mN($,M){let J=A2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:j1({children:[r({text:""})]}),rootIndex:J,selection:A1(J,[0])}}function d6($,M,J){let Z=f1($,M);return Z?.region.id===J&&Z.block.type==="paragraph"}function vN($){let M=/^[-+*]\s(.+)$/.exec($);if(M)return{ordered:!1,text:M[1]};let J=/^\d+\.\s(.+)$/.exec($);if(J)return{ordered:!0,text:J[1]};return null}function gN($){let M=/^(#{1,6})\s(.+)$/.exec($);return M?{depth:M[1].length,text:M[2]}:null}function a6($,M){let J=X1($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=S1($,M);if(!Z)return null;let A=Z.region.text,X=Z.item,N=typeof X.checked==="boolean"?!1:X.checked;if(J.start.offset===0){let U=X2("",N,X.spread);return{kind:"replace-block",block:J1(Z.list,[...Z.list.items.slice(0,Z.itemIndex),U,X,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:Q5(U,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex]),selection:A1(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex,0])}}if(J.start.offset===A.length){let U=X2("",N,X.spread);return{kind:"replace-block",block:J1(Z.list,[...Z.list.items.slice(0,Z.itemIndex+1),U,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:Q5(U,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1]),selection:A1(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1,0])}}let Y=A.slice(0,J.start.offset),Q=A.slice(J.start.offset),K=X2(Q,N,X.spread),q=h1(X,[r({text:Y})]);return{kind:"replace-block",block:J1(Z.list,[...Z.list.items.slice(0,Z.itemIndex),q,K,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:Q5(K,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1]),selection:A1(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1,0])}}function s6($,M){let J=X1($,M),Z=S1($,M);if(!Z||J.start.regionId!==J.end.regionId)return null;if(J.start.offset!==0||Z.region.text.length!==0)return a6($,M);if(Z.parentItem&&Z.parentItemIndex!==null&&Z.parentItemChildIndices&&Z.parentList&&Z.parentListChildIndices)return IN(Z);let A=Z.list.items.slice(0,Z.itemIndex),X=Z.list.items.slice(Z.itemIndex+1),N=[];if(A.length>0)N.push(J1(Z.list,A));if(N.push(r({text:""})),X.length>0)N.push(J1(Z.list,X));return{kind:"replace-root-range",count:1,replacements:N,rootIndex:Z.rootIndex,selection:$1(Z.rootIndex+(A.length>0?1:0))}}function i6($,M){let J=S1($,M);if(!J)return null;if(typeof J.item.checked==="boolean"){let Z=s1({checked:null,children:J.item.children,spread:J.item.spread});return{kind:"replace-block",block:J1(J.list,J.list.items.map((A,X)=>X===J.itemIndex?Z:A)),blockId:J.list.id}}if(J.itemIndex>0){let Z=J.list.items[J.itemIndex-1];if(!Z)return null;if(J.item.plainText.length===0)return{kind:"replace-block",block:J1(J.list,J.list.items.filter((X,N)=>N!==J.itemIndex)),blockId:J.list.id,selection:A1(J.rootIndex,[...J.listChildIndices,J.itemIndex-1,0],"end")};let A=L0(Z,`${Z.plainText}${J.item.plainText}`);if(!A)return null;return{kind:"replace-block",block:J1(J.list,J.list.items.flatMap((X,N)=>{if(N===J.itemIndex-1)return[A];if(N===J.itemIndex)return[];return[X]})),blockId:J.list.id,selection:A1(J.rootIndex,[...J.listChildIndices,J.itemIndex-1,0],"end")}}return{kind:"replace-root-range",count:1,replacements:[r({text:J.item.plainText})],rootIndex:J.rootIndex,selection:$1(J.rootIndex)}}function o6($,M){let J=S1($,M);if(!J||J.itemIndex===0)return null;let Z=J.list.items[J.itemIndex-1];if(!Z)return null;let A=hN(Z,J.item,J);return{kind:"replace-block",block:J1(J.list,J.list.items.flatMap((X,N)=>{if(N===J.itemIndex-1)return[A.item];if(N===J.itemIndex)return[];return[X]})),blockId:J.list.id,selection:A1(J.rootIndex,A.regionChildIndices)}}function n6($,M){let J=S1($,M);if(!J||!J.parentItem||J.parentItemIndex===null||!J.parentItemChildIndices||!J.parentList||!J.parentListChildIndices)return null;let Z=J.list.items.filter((N,Y)=>Y!==J.itemIndex),A=J.parentItem.children.flatMap((N)=>{if(N.type!=="list"||N.id!==J.list.id)return[N];if(Z.length===0)return[];return[J1(J.list,Z)]}),X=h1(J.parentItem,A);return{kind:"replace-block",block:J1(J.parentList,[...J.parentList.items.slice(0,J.parentItemIndex),X,J.item,...J.parentList.items.slice(J.parentItemIndex+1)]),blockId:J.parentList.id,selection:A1(J.rootIndex,[...J.parentListChildIndices,J.parentItemIndex+1,0])}}function K5($,M,J){let Z=S1($,M);if(!Z)return null;let A=Z.itemIndex+J;if(A<0||A>=Z.list.items.length)return null;let X=[...Z.list.items],[N]=X.splice(Z.itemIndex,1);if(!N)return null;return X.splice(A,0,N),{kind:"replace-block",block:J1(Z.list,X),blockId:Z.list.id,selection:A1(Z.rootIndex,[...Z.listChildIndices,A,0])}}function IN($){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let M=$.list.items.filter((N,Y)=>Y!==$.itemIndex),J=$.parentItem.children.flatMap((N)=>{if(N.type!=="list"||N.id!==$.list.id)return[N];if(M.length===0)return[];return[J1($.list,M)]}),Z=h1($.parentItem,J),A=typeof $.parentItem.checked==="boolean"?!1:$.parentItem.checked,X=X2("",A,$.parentItem.spread);return{kind:"replace-block",block:J1($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),Z,X,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,listItemInsertedPath:Q5(X,$.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1]),selection:A1($.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1,0])}}function Q5($,M,J){return typeof $.checked==="boolean"?void 0:h6(M,J)}function hN($,M,J){let Z=$.children.findIndex((X)=>X.type==="list"&&X.ordered===J.list.ordered&&X.start===J.list.start);if(Z>=0){let X=$.children[Z];if(!X||X.type!=="list")return{item:$,regionChildIndices:[...J.listChildIndices,J.itemIndex-1,0]};return{item:h1($,$.children.map((N,Y)=>Y===Z?J1(X,[...X.items,M]):N)),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,Z,X.items.length,0]}}let A=z0({items:[M],ordered:J.list.ordered,spread:J.list.spread,start:J.list.start});return{item:h1($,[...$.children,A]),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,$.children.length,0,0]}}function t6($,M,J){let Z=f1($,M),A=Math.max(2,J);if(!Z||Z.block.type!=="paragraph"||Z.block.plainText.length>0||M.anchor.regionId!==M.focus.regionId||M.anchor.offset!==0||M.focus.offset!==0)return null;return{kind:"replace-root",block:V0({rows:Array.from({length:2},()=>X8(A))}),rootIndex:Z.rootIndex,selection:G0(Z.rootIndex,0,0)}}function q5($,M,J){let Z=i1($,M.focus.regionId);if(!Z)return null;let A=J<0?rN(Z.table,Z.rowIndex,Z.cellIndex):cN(Z.table,Z.rowIndex,Z.cellIndex);if(!A)return J>0&&dN(Z.table,Z.rowIndex,Z.cellIndex)?pN(Z):{kind:"keep-state"};let X=Z.table.rows[A.rowIndex]?.cells[A.cellIndex];if(!X)return{kind:"keep-state"};return{kind:"set-selection",selection:xN($,M,Z.table,A.rowIndex,A.cellIndex,Math.min(M.focus.offset,X.plainText.length))}}function e6($,M){let J=N4($,M.focus.regionId);if(!J||J.kind!=="tableCell")return null;let Z=Math.min(M.anchor.offset,M.focus.offset),A=Math.max(M.anchor.offset,M.focus.offset),X=N5(J,Z,A);return{kind:"replace-block",block:X.block,blockId:X.blockId,selection:X.selection}}function $8($,M,J){let Z=i1($,M.focus.regionId);if(!Z)return null;let A=J==="left"?Z.cellIndex:Z.cellIndex+1;return N2(Z,V0({align:K3(Z.table.align,A,0,[null]),rows:Z.table.rows.map((X)=>I0({cells:lN(X.cells,A,0,[Q3()])}))}),G0(Z.rootIndex,Z.rowIndex,A))}function M8($,M){let J=i1($,M.focus.regionId);if(!J)return null;let Z=Math.max(0,...J.table.rows.map((A)=>A.cells.length));if(Z<=1)return null;return N2(J,V0({align:K3(J.table.align,J.cellIndex,1,[]),rows:J.table.rows.map((A)=>I0({cells:A.cells.filter((X,N)=>N!==J.cellIndex)}))}),G0(J.rootIndex,J.rowIndex,Math.min(J.cellIndex,Z-2)))}function J8($,M,J){let Z=i1($,M.focus.regionId);if(!Z)return null;let A=J==="above"?Z.rowIndex:Z.rowIndex+1,X=Math.max(1,...Z.table.rows.map((N)=>N.cells.length));return N2(Z,p1(Z.table,[...Z.table.rows.slice(0,A),X8(X),...Z.table.rows.slice(A)]),G0(Z.rootIndex,A,Math.min(Z.cellIndex,X-1)))}function Z8($,M){let J=i1($,M.focus.regionId);if(!J||J.table.rows.length<=1)return null;let Z=J.table.rows.filter((N,Y)=>Y!==J.rowIndex),A=Math.min(J.rowIndex,Z.length-1),X=Z[A]?.cells.length??1;return N2(J,p1(J.table,Z),G0(J.rootIndex,A,Math.min(J.cellIndex,X-1)))}function A8($,M){let J=i1($,M.focus.regionId);if(!J)return null;return N2(J,r({text:""}),$1(J.rootIndex))}function X8($){return I0({cells:Array.from({length:$},()=>Q3())})}function Q3(){return Z0({children:[]})}function pN($){let M=$.table.rows.length,J=Math.max(1,...$.table.rows.map((Z)=>Z.cells.length));return N2($,p1($.table,[...$.table.rows,X8(J)]),G0($.rootIndex,M,0))}function N2($,M,J){return{kind:"replace-block",block:M,blockId:$.table.id,selection:J}}function lN($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function K3($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function xN($,M,J,Z,A,X){let N=e0($,J.id,Z,A);if(!N)return M;return{anchor:{regionId:N.id,offset:X},focus:{regionId:N.id,offset:X}}}function rN($,M,J){if(J>0)return{cellIndex:J-1,rowIndex:M};if(M>0){let Z=$.rows[M-1];if(!Z||Z.cells.length===0)return null;return{cellIndex:Z.cells.length-1,rowIndex:M-1}}return null}function cN($,M,J){let Z=$.rows[M];if(!Z)return null;if(J+1<Z.cells.length)return{cellIndex:J+1,rowIndex:M};let A=$.rows[M+1];if(!A||A.cells.length===0)return null;return{cellIndex:0,rowIndex:M+1}}function dN($,M,J){let Z=$.rows[M];return Boolean(Z&&M===$.rows.length-1&&J===Z.cells.length-1)}function U5($,M,J,Z=null){return Y2($,M,1,[J],Z)}function Y2($,M,J,Z,A=null){return{document:v4($.document,M,J,Z),selection:A}}function G5($,M,J,Z=null){return U4($,M,()=>J,Z)}function U4($,M,J,Z=null){let A=$.blockIndex.get(M);if(!A)return null;let X=$.document.blocks[A.rootIndex];if(!X)return null;let N=q3(X,M,J);return N?Y2($,A.rootIndex,1,[N],Z):null}function q3($,M,J){if($.id===M)return J($);switch($.type){case"blockquote":{let Z=N8($.children,M,J);return Z?j1({children:Z}):null}case"listItem":{let Z=N8($.children,M,J);return Z?h1($,Z):null}case"list":{let Z=N8($.items,M,J);return Z?J1($,Z):null}default:return null}}function N8($,M,J){let Z=!1,A=$.map((X)=>{let N=q3(X,M,J);if(!N)return X;return Z=!0,N});return Z?A:null}function B5($,M,J,Z){let X=aN($,M,J,{didInsert:!1,generatedRunCount:0,replacementText:Z});return tN(eN(X))}function Q8($){let M=[];for(let J=0;J<$.length;J+=1){let Z=$[J];if(Z.link){let X=[],N=Z.link;while(J<$.length&&K8($[J].link,N)){let Y=G3($[J]);if(Y)X.push(Y);J+=1}if(J-=1,X.length>0)M.push(g0({children:T1(X),title:N.title,url:N.url}));continue}let A=G3(Z);if(A)M.push(A)}return T1(M)}function aN($,M,J,Z){let A=[];for(let[X,N]of $.entries()){if(!Z.didInsert&&M===J&&M===N.start)Y8(A,Z,U3($[X-1]??null,N));if(J<=N.start||M>=N.end){A.push(F5(N));continue}let Y=Math.max(0,M-N.start),Q=Math.min(N.text.length,J-N.start),K=!Z.didInsert&&Z.replacementText.length>0?Z.replacementText:"",q=sN(N,Y,Q,K,Z);if(Y!==Q||K.length>0)Z.didInsert=!0;A.push(...q)}if(!Z.didInsert)Y8(A,Z,U3($.at(-1)??null,null));return A}function sN($,M,J,Z,A){switch($.kind){case"text":case"inlineCode":case"unsupported":return iN($,M,J,Z);case"break":return oN($,M,J,Z,A);case"image":return nN($,M,J,Z)}}function iN($,M,J,Z){let A=$.text.slice(0,M)+Z+$.text.slice(J);return A.length>0?[{...F5($),text:A}]:[]}function oN($,M,J,Z,A){if(M===J)return[F5($)];let X=[];if(Z.length>0)Y8(X,A,$.link);return X}function nN($,M,J,Z){if(M===0&&J===$.text.length)return Z.length>0?[B3(Z,$.link,0)]:[];return[F5($)]}function Y8($,M,J){if(M.replacementText.length===0){M.didInsert=!0;return}$.push(B3(M.replacementText,J,M.generatedRunCount)),M.generatedRunCount+=1,M.didInsert=!0}function B3($,M,J){return{id:`generated:${J}`,image:null,inlineCode:!1,kind:"text",link:M,marks:[],originalType:null,text:$}}function U3($,M){return $?.link&&M?.link&&K8($.link,M.link)?$.link:null}function F5($){return{id:$.id,image:$.image,inlineCode:$.inlineCode,kind:$.kind,link:$.link,marks:$.marks,originalType:$.originalType,text:$.text}}function tN($){let M=[],J=0;for(let Z of $){let A=J,X=A+Z.text.length;M.push({...Z,end:X,start:A}),J=X}return M}function eN($){let M=[];for(let J of $){let Z=M.at(-1);if(Z&&$Y(Z,J)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function $Y($,M){return $.kind===M.kind&&$.inlineCode===M.inlineCode&&K8($.link,M.link)&&JY($.image,M.image)&&$.originalType===M.originalType&&$.marks.join(",")===M.marks.join(",")}function G3($){switch($.kind){case"break":return z2();case"image":return $.image?MY($.image):null;case"inlineCode":return v0({code:$.text});case"text":return $.text.length>0?I1({marks:$.marks,text:$.text}):null;case"unsupported":return k4({originalType:$.originalType??"unsupported",source:$.text})}}function MY($){return L4({alt:$.alt,title:$.title,url:$.url,width:$.width})}function K8($,M){return $?.url===M?.url&&$?.title===M?.title}function JY($,M){return $?.url===M?.url&&$?.title===M?.title&&$?.alt===M?.alt&&$?.width===M?.width}function _5($,M,J){let Z=X1($,M);if(Z.start.regionId!==Z.end.regionId)throw Error("Cross-region text replacement is not supported yet.");let A=w0($,Z.start.regionId);if(!A)throw Error(`Unknown region: ${Z.start.regionId}`);let X=U4($,A.blockId,(U)=>AY(U,A,Z.start.offset,Z.end.offset,J));if(!X)throw Error(`Failed to replace block for canvas region: ${A.id}`);let N=X.document,Y=Z4($,N,A.rootIndex,1),Q=$.document.comments.length===0?Y:ZY($,Y,A,Z.start.offset,Z.end.offset,J),K=t0(Q,A.path);if(!K)throw Error(`Failed to remap region after replacement: ${A.path}`);let q=Z.start.offset+J.length;return{documentIndex:Q,selection:{anchor:{regionId:K.id,offset:q},focus:{regionId:K.id,offset:q}}}}function ZY($,M,J,Z,A,X){let N=q8($,M,J,Z,A,X);return N===M.document.comments?M:A4(M,{...M.document,comments:N})}function AY($,M,J,Z,A){switch($.type){case"heading":return F3($,M,J,Z,A);case"paragraph":return F3($,M,J,Z,A);case"code":return S$($,_3(M,J,Z,A));case"table":return XY($,M,J,Z,A);case"unsupported":return u$($,_3(M,J,Z,A));default:throw Error(`Canvas text replacement is not supported for block type: ${$.type}`)}}function XY($,M,J,Z,A){let X=M.tableCellPosition?.rowIndex,N=M.tableCellPosition?.cellIndex;if(X===void 0||N===void 0)throw Error(`Unable to resolve table cell position for region: ${M.id}`);let Y=B5(M.inlines,J,Z,A),Q=Q8(Y),K=$.rows.map((q,U)=>{if(U!==X)return q;let G=q.cells.map((B,F)=>{if(F!==N)return B;return Z0({children:Q})});return{...q,cells:G}});return p1($,K)}function F3($,M,J,Z,A){let X=B5(M.inlines,J,Z,A),N=Q8(X);return h0($,N)}function _3($,M,J,Z){return B5($.inlines,M,J,Z).map((A)=>A.text).join("")}function D3($,M){switch(M.kind){case"replace-block":return G5($,M.blockId,M.block,M.selection??null);case"replace-root":return U5($,M.rootIndex,M.block,M.selection??null);case"replace-root-range":return Y2($,M.rootIndex,M.count,M.replacements,M.selection??null);case"replace-selection-text":{let J=_5($,M.selection,M.text);return{document:J.documentIndex.document,documentIndex:J.documentIndex,selection:J.selection}}}return null}var U8=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function G4($){switch($.kind){case"active-block-flash":return 300;case"deleted-text-fade":return 180;case"inserted-text-highlight":return 1000;case"list-marker-pop":return 500;case"punctuation-pulse":return 140}}function T3($,M){let J=M??YY();return $.animations.some((Z)=>J-Z.startedAt<G4(Z))}function P3($,M){return B8($,M,"inserted-text-highlight",(J)=>J.regionPath)}function W3($,M){return j3($,M,"active-block-flash",(J)=>J.blockPath)}function z3($,M){return B8($,M,"deleted-text-fade",(J)=>J.regionPath)}function V3($,M){return B8($,M,"punctuation-pulse",(J)=>J.regionPath)}function y3($,M){return j3($,M,"list-marker-pop",(J)=>J.blockPath)}function b3($,M,J){let Z=new Set([$,M]);for(let A of J){if(A.endOffset<=$||A.startOffset>=M)continue;Z.add(Math.max($,A.startOffset)),Z.add(Math.min(M,A.endOffset))}return[...Z].sort((A,X)=>A-X)}function O3($,M,J){return $.find((Z)=>Z.startOffset<J&&Z.endOffset>M)??null}function C3($,M,J){if(!M)return $;return F4(J.insertHighlightText,$,M.progress)}function R3($,M){return F4($,"rgba(0, 0, 0, 0)",M.progress)}function H5($,M){return F4($,"rgba(0, 0, 0, 0)",M.progress)}function w3($,M){return F4(M.insertHighlightText,"rgba(0, 0, 0, 0)",$.progress)}function E3($){let M=Math.min(1,$.progress*2);return 0.1+0.9*NY(M)}function B4($,M,J){let Z=Math.max(0,M.progress*2-1);return F4(J.insertHighlightText,$,Z)}function B8($,M,J,Z){let A=new Map;for(let X of $.animations){if(X.kind!==J)continue;let N=G4(X),Y=M-X.startedAt;if(Y>=N)continue;let Q={...X,progress:Math.max(0,Math.min(1,Y/N))},K=Z(X),q=A.get(K);if(q)q.push(Q);else A.set(K,[Q])}return A}function j3($,M,J,Z){let A=new Map;for(let X of $.animations){if(X.kind!==J)continue;let N=G4(X),Y=M-X.startedAt;if(Y>=N)continue;A.set(Z(X),{...X,progress:Math.max(0,Math.min(1,Y/N))})}return A}function NY($){return 1-(1-$)*(1-$)*(1-$)}function F4($,M,J){let Z=H3($),A=H3(M);return`rgba(${G8(D5(Z[0],A[0],J))}, ${G8(D5(Z[1],A[1],J))}, ${G8(D5(Z[2],A[2],J))}, ${D5(Z[3],A[3],J)})`}function YY(){return typeof performance<"u"?performance.now():Date.now()}function H3($){let M=U8.get($);if(M)return M;let J=QY($)??KY($)??qY($)??U8.get("rgba(0, 0, 0, 0)");return U8.set($,J),J}function QY($){let M=$.trim();if(!M.startsWith("#"))return null;let J=M.slice(1);if(J.length===3)return[Number.parseInt(`${J[0]}${J[0]}`,16),Number.parseInt(`${J[1]}${J[1]}`,16),Number.parseInt(`${J[2]}${J[2]}`,16),1];if(J.length===6)return[Number.parseInt(J.slice(0,2),16),Number.parseInt(J.slice(2,4),16),Number.parseInt(J.slice(4,6),16),1];return null}function KY($){let M=/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!M)return null;return[Number(M[1]),Number(M[2]),Number(M[3]),1]}function qY($){let M=/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!M)return null;return[Number(M[1]),Number(M[2]),Number(M[3]),Number(M[4])]}function D5($,M,J){return $+(M-$)*J}function G8($){return Math.round($)}function T5($,M,J=F0()){if(M<=0)return $;let Z=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Z)return $;let A=$.selection.focus.offset,X=Math.max(0,A-M);if(A<=X)return $;return _4($,{endOffset:A,kind:"inserted-text-highlight",regionPath:Z.path,startOffset:X,startedAt:J})}function F8($,M,J=F0()){if(M.text.length===0)return $;return _4($,{kind:"deleted-text-fade",regionPath:M.regionPath,startOffset:M.startOffset,startedAt:J,text:M.text})}function _8($,M,J=F0()){return _4($,{blockPath:M,kind:"active-block-flash",startedAt:J})}function D8($,M=F0()){let J=$.documentIndex.regionIndex.get($.selection.focus.regionId),Z=$.selection.focus.offset-1;if(!J||Z<0||J.text[Z]!==".")return $;return _4($,{kind:"punctuation-pulse",offset:Z,regionPath:J.path,startedAt:M})}function H8($,M,J=F0()){return _4($,{blockPath:M,kind:"list-marker-pop",startedAt:J})}function _4($,M){let J=P5($.animations,M.startedAt);return{...$,animations:[...J,M]}}function P5($,M){return $.filter((J)=>J.startedAt+G4(J)>M)}function F0(){return typeof performance<"u"?performance.now():Date.now()}function L3($){let M=$.documentIndex.regionIndex.get($.selection.focus.regionId);return(M?$.documentIndex.blockIndex.get(M.blockId)??null:null)?.path??""}function T8($){let M=n0($),J=f3(M);return{animations:[],future:[],history:[],documentIndex:M,selection:{anchor:J,focus:J}}}function P8($){let M=U0($.documentIndex);return l0(V2($.documentIndex.document.blocks),M.threads)}function U1($,M,J){let Z="regionId"in M?{anchor:W5($.documentIndex,M),focus:W5($.documentIndex,M)}:{anchor:W5($.documentIndex,M.anchor),focus:W5($.documentIndex,M.focus)},A={...$,selection:Z};return J??S3($,A)?_8(A,L3(A)):A}function UY($,M,J=null){let Z=J??n0(M);return{animations:P5($.animations,F0()),future:[],documentIndex:Z,history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:GY(Z)}}function s($,M){if(!M)return null;switch(M.kind){case"keep-state":return $;case"set-selection":return U1($,M.selection);default:{let J=D3($.documentIndex,M);if(!J)return null;let Z=UY($,J.document,J.documentIndex??null),A=X4(Z.documentIndex,J.selection)??$.selection,X=S3($,Z,A);return U1(Z,A,X)}}}function z5($,M,J,Z){let A=v$($.documentIndex.document,M,J,Z),X=A4($.documentIndex,A);return{animations:P5($.animations,F0()),documentIndex:X,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:$.selection}}function W8($){let M=$.history.at(-1);if(!M)return $;let J=n0(M.document);return{animations:[],documentIndex:J,future:[{document:$.documentIndex.document,selection:$.selection},...$.future],history:$.history.slice(0,-1),selection:M.selection}}function z8($){let M=$.future[0];if(!M)return $;let J=n0(M.document);return{animations:[],documentIndex:J,future:$.future.slice(1),history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:M.selection}}function GY($){let M=f3($);return{anchor:M,focus:M}}function f3($){return $.regions[0]?{regionId:$.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function W5($,M){let J=w0($,M.regionId);if(!J)return M;return{regionId:J.id,offset:Math.max(0,Math.min(M.offset,J.text.length))}}function S3($,M,J){let Z=k3($.documentIndex,$.selection),A=k3(M.documentIndex,J??M.selection);return A!==null&&A!==Z}function k3($,M){let J=$.regionIndex.get(M.focus.regionId),Z=J?$.blockIndex.get(J.blockId)??null:null;if(!J||!Z?.path)return null;return Z.type==="table"?`cell:${J.path}`:`block:${Z.path}`}function u3($,M){let J=c6($.documentIndex,$.selection,M),Z=s($,J);if(!Z)return null;if(J?.kind==="replace-selection-text"&&M.length>0)Z=T5(Z,M.length);if(M===".")Z=D8(Z);return Z}function m3($){switch(Z2($.documentIndex,$.selection).kind){case"code":return s($,l6($.documentIndex,$.selection));case"tableCell":return s($,e6($.documentIndex,$.selection));case"listItem":{let J=s6($.documentIndex,$.selection);return _Y({state:s($,J)??s($,q4($.documentIndex,$.selection)),transaction:J})}case"blockquoteTextBlock":return s($,p6($.documentIndex,$.selection))??s($,q4($.documentIndex,$.selection));case"rootTextBlock":return s($,q4($.documentIndex,$.selection));case"unsupported":return null}}function v3($){if(Y9($))return V5($);let M=DY($);if(M)return M;let J=X1($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;switch(Z2($.documentIndex,$.selection).kind){case"listItem":return s($,i6($.documentIndex,$.selection));case"blockquoteTextBlock":case"rootTextBlock":return s($,x6($.documentIndex,$.selection));default:return null}}function g3($){if(Y9($))return V5($);return HY($)}function V8($,M){return s($,{kind:"replace-selection-text",selection:$.selection,text:M})}function I3($,M){let J=V8($,M);return M.length>0?T5(J,M.length):J}function V5($){return V8($,"")}function h3($){switch(Z2($.documentIndex,$.selection).kind){case"tableCell":return s($,q5($.documentIndex,$.selection,1));case"rootTextBlock":return s($,Y5($.documentIndex,$.selection,1));case"listItem":return BY($);default:return null}}function p3($){switch(Z2($.documentIndex,$.selection).kind){case"tableCell":return s($,q5($.documentIndex,$.selection,-1));case"rootTextBlock":return s($,Y5($.documentIndex,$.selection,-1));case"listItem":return FY($);default:return null}}function BY($){return s($,o6($.documentIndex,$.selection))}function FY($){return s($,n6($.documentIndex,$.selection))}function l3($){return s($,K5($.documentIndex,$.selection,-1))}function x3($){return s($,K5($.documentIndex,$.selection,1))}function r3($,M){return s($,t6($.documentIndex,$.selection,M))}function c3($,M){return s($,$8($.documentIndex,$.selection,M))}function d3($){return s($,M8($.documentIndex,$.selection))}function a3($,M){return s($,J8($.documentIndex,$.selection,M))}function s3($){return s($,Z8($.documentIndex,$.selection))}function i3($){return s($,A8($.documentIndex,$.selection))}function y5($,M){return N9($,(J,Z,A)=>Z5(J,Z,A,M))}function o3($){return N9($,(M,J,Z)=>X5(M,J,Z))}function n3($){return y5($,"bold")}function t3($){return y5($,"italic")}function e3($){return y5($,"strikethrough")}function $9($){return y5($,"underline")}function M9($,M,J,Z,A){return s($,Q4($.documentIndex,M,J,Z,A))}function J9($,M,J,Z){return s($,Q4($.documentIndex,M,J,Z,null))}function Z9($,M){let J=J2($.documentIndex,M);if(!J||J.type!=="listItem"||typeof J.checked!=="boolean")return null;return s($,{kind:"replace-block",block:{...J,checked:!J.checked},blockId:M})}function A9($){return W8($)}function X9($){return z8($)}function _Y($){if(!$.state||!$.transaction||$.transaction.kind!=="replace-block"||!$.transaction.listItemInsertedPath)return $.state;return H8($.state,$.transaction.listItemInsertedPath)}function N9($,M){let J=X1($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset===J.end.offset)return null;return s($,$2($.documentIndex,J.start.regionId,J.start.offset,J.end.offset,M))}function Y9($){let M=X1($.documentIndex,$.selection);return M.start.regionId===M.end.regionId&&M.start.offset!==M.end.offset}function DY($){return Q9($,"backward")}function HY($){return Q9($,"forward")}function Q9($,M){if($.selection.anchor.regionId!==$.selection.focus.regionId||$.selection.anchor.offset!==$.selection.focus.offset)return null;let J=w0($.documentIndex,$.selection.focus.regionId);if(!J)return null;if(M==="forward"&&$.selection.focus.offset>=J.text.length)return null;let Z=M==="backward"?WY(J.text,$.selection.focus.offset):$.selection.focus.offset,A=M==="backward"?$.selection.focus.offset:zY(J.text,$.selection.focus.offset);if(Z===A)return null;let X=V8(U1($,{anchor:{regionId:J.id,offset:Z},focus:{regionId:J.id,offset:A}}),"");return TY($,X,Z,A)}function TY($,M,J,Z){let A=PY($,J,Z);return A?F8(M,A):M}function PY($,M,J){let Z=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Z)return null;let A=Z.text.slice(M,J);if(A.length===0)return null;if(!Z.inlines.find((N)=>N.start<=M&&N.end>=J&&N.kind==="text"&&N.link===null&&N.marks.length===0))return null;return{regionPath:Z.path,startOffset:M,text:A}}function WY($,M){let J=Array.from($.slice(0,M));if(J.length===0)return 0;return M-J.at(-1).length}function zY($,M){let J=Array.from($.slice(M))[0];return J?M+J.length:$.length}function b8($,M,J){let Z=J.trim();if(Z.length===0||M.startOffset===M.endOffset)return null;let A=$.regionIndex.get(M.regionId)??null,X=A?y8($,A):null;if(!X)return null;return Z6({anchor:b2(X,M.startOffset,M.endOffset),body:Z,quote:O2(X,M.startOffset,M.endOffset)})}function U0($){let M=b5($),J=$.document.comments,Z=[...J],A=[];for(let[X,N]of J.entries()){let Y=C2(N,$.document);if(!Y.match)continue;let K=M.findBySemanticMatch(Y.match.containerId,Y.match.containerOrdinal)?.runtimeContainer??null;if(!K)continue;if(Y.repair)Z[X]={...N,anchor:Y.repair.anchor,quote:Y.repair.quote};A.push({endOffset:Y.match.endOffset,resolution:Y,regionId:K.id,resolved:N.resolvedAt!=null,startOffset:Y.match.startOffset,threadIndex:X})}return{liveRanges:A,threads:Z}}function q8($,M,J,Z,A,X){if($.document.comments.length===0)return M.document.comments;let N=$.commentContainerIndex.get(J.semanticRegionId)??[],Y=new Set(N);if(N.length===0)return M.document.comments;let Q=U0($),K=new Map(Q.liveRanges.map((B)=>[B.threadIndex,B])),q=y8($,J),U=t0(M,J.path),G=U?y8(M,U):null;if(!q||!G)return M.document.comments;return M.document.comments.map((B,F)=>{if(!Y.has(F))return B;let _=K.get(F),D=_?.resolution.match??null;if(!_||!D||D.containerId!==q.id)return B;let y=yY(D.startOffset,D.endOffset,Z,A,X.length);if(!y)return B;return{...B,anchor:b2(G,y.start,y.end),quote:O2(G,y.start,y.end)}})}function y8($,M){let J=VY($,M);if(!J)return null;return{containerKind:J,containerOrdinal:-1,id:M.semanticRegionId,text:M.text}}function VY($,M){if($.tableCellIndex.has(M.id))return"tableCell";switch(M.blockType){case"code":return"code";case"heading":case"paragraph":return"text";default:return null}}function yY($,M,J,Z,A){let X=Z-J,N=A-X;if(Z<=$)return{end:M+N,start:$+N};if(J>=M)return{end:M,start:$};let Y=Math.max(0,Math.min(J,M)-$),Q=Math.max(0,M-Math.max(Z,$)),K=$<J?$:J;return{end:K+Y+A+Q,start:K}}function O8($,M){if(M.length===0)return[];let J=b5($),Z=J.list();return M.map((A)=>({...A,cursorPoint:bY(A,Z,J),viewport:null}))}function bY($,M,J){if(!$.cursor)return null;let Z=OY(M,$.cursor),A=CY(Z,$.cursor);if(A.length!==1)return null;let X=A[0],N=J.resolveRuntimeContainer(X.container.id);if(!N)return null;return{offset:Math.max(0,Math.min(X.offset,N.text.length)),regionId:N.id}}function OY($,M){return M.kind?$.filter((J)=>J.containerKind===M.kind):$}function CY($,M){if(M.prefix&&M.suffix)return RY($,M.prefix,M.suffix);if(M.prefix)return K9($,M.prefix,"after");if(M.suffix)return K9($,M.suffix,"before");return[]}function K9($,M,J){if(M.length===0)return[];let Z=[];for(let A of $)for(let X of q9(A.text,M))Z.push({container:A,offset:J==="after"?X+M.length:X});return Z}function RY($,M,J){if(M.length===0||J.length===0)return[];let Z=[];for(let A of $)for(let X of q9(A.text,M)){let N=X+M.length;if(A.text.indexOf(J,N)!==-1)Z.push({container:A,offset:N})}return Z}function q9($,M){let J=[],Z=0;while(Z<=$.length){let A=$.indexOf(M,Z);if(A===-1)break;J.push(A),Z=A+Math.max(1,M.length)}return J}var l1={images:new Map};function Q2(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function U9($,M,J){return D4($.preparedText,M,J,256)}function G9($,M,J){return D4($.measuredLines,M,J,512)}function B9($,M,J){return D4($.lineBoundaries,M,J,1024)}function F9($,M,J){return D4($.measuredContainerHeights,M,J,1024)}function _9($,M){let J=$.graphemeWidths.get(M);if(J)return J;let Z=new Map;return D4($.graphemeWidths,M,Z,64),Z}function D9($,M,J){return $.viewportPlans.get(M)?.get(J)??null}function H9($,M,J,Z){let A=$.viewportPlans.get(M)??new Map;return A.set(J,Z),$.viewportPlans.set(M,A),Z}function D4($,M,J,Z){if($.has(M))$.delete(M);if($.set(M,J),$.size>Z){let A=$.keys().next().value;if(A!==void 0)$.delete(A)}return J}var wY=["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","ON","CS","ON","CS","ON","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ON","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","ON","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"],EY=["AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","CS","AL","ON","ON","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","ON","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL"];function jY($){if($<=255)return wY[$];if(1424<=$&&$<=1524)return"R";if(1536<=$&&$<=1791)return EY[$&255];if(1792<=$&&$<=2220)return"AL";return"L"}function LY($){let M=$.length;if(M===0)return null;let J=Array(M),Z=0;for(let K=0;K<M;K++){let q=jY($.charCodeAt(K));if(q==="R"||q==="AL"||q==="AN")Z++;J[K]=q}if(Z===0)return null;let A=M/Z<0.3?0:1,X=new Int8Array(M);for(let K=0;K<M;K++)X[K]=A;let N=A&1?"R":"L",Y=N,Q=Y;for(let K=0;K<M;K++)if(J[K]==="NSM")J[K]=Q;else Q=J[K];Q=Y;for(let K=0;K<M;K++){let q=J[K];if(q==="EN")J[K]=Q==="AL"?"AN":"EN";else if(q==="R"||q==="L"||q==="AL")Q=q}for(let K=0;K<M;K++)if(J[K]==="AL")J[K]="R";for(let K=1;K<M-1;K++){if(J[K]==="ES"&&J[K-1]==="EN"&&J[K+1]==="EN")J[K]="EN";if(J[K]==="CS"&&(J[K-1]==="EN"||J[K-1]==="AN")&&J[K+1]===J[K-1])J[K]=J[K-1]}for(let K=0;K<M;K++){if(J[K]!=="EN")continue;let q;for(q=K-1;q>=0&&J[q]==="ET";q--)J[q]="EN";for(q=K+1;q<M&&J[q]==="ET";q++)J[q]="EN"}for(let K=0;K<M;K++){let q=J[K];if(q==="WS"||q==="ES"||q==="ET"||q==="CS")J[K]="ON"}Q=Y;for(let K=0;K<M;K++){let q=J[K];if(q==="EN")J[K]=Q==="L"?"L":"EN";else if(q==="R"||q==="L")Q=q}for(let K=0;K<M;K++){if(J[K]!=="ON")continue;let q=K+1;while(q<M&&J[q]==="ON")q++;let U=K>0?J[K-1]:Y,G=q<M?J[q]:Y,B=U!=="L"?"R":"L";if(B===(G!=="L"?"R":"L"))for(let _=K;_<q;_++)J[_]=B;K=q-1}for(let K=0;K<M;K++)if(J[K]==="ON")J[K]=N;for(let K=0;K<M;K++){let q=J[K];if((X[K]&1)===0){if(q==="R")X[K]++;else if(q==="AN"||q==="EN")X[K]+=2}else if(q==="L"||q==="AN"||q==="EN")X[K]++}return X}function T9($,M){let J=LY($);if(J===null)return null;let Z=new Int8Array(M.length);for(let A=0;A<M.length;A++)Z[A]=J[M[A]];return Z}var kY=/[ \t\n\r\f]+/g,fY=/[\t\n\r\f]| {2,}|^ | $/;function SY($){let M=$??"normal";return M==="pre-wrap"?{mode:M,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:M,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function uY($){if(!fY.test($))return $;let M=$.replace(kY," ");if(M.charCodeAt(0)===32)M=M.slice(1);if(M.length>0&&M.charCodeAt(M.length-1)===32)M=M.slice(0,-1);return M}function mY($){if(!/[\r\f]/.test($))return $.replace(/\r\n/g,`
|
|
19
|
+
`);return $.replace(/\r\n/g,`
|
|
20
|
+
`).replace(/[\r\f]/g,`
|
|
21
|
+
`)}var C8=null,vY;function gY(){if(C8===null)C8=new Intl.Segmenter(vY,{granularity:"word"});return C8}var IY=/\p{Script=Arabic}/u,O5=/\p{M}/u,z9=/\p{Nd}/u;function R8($){return IY.test($)}function o1($){for(let M of $){let J=M.codePointAt(0);if(J>=19968&&J<=40959||J>=13312&&J<=19903||J>=131072&&J<=173791||J>=173824&&J<=177983||J>=177984&&J<=178207||J>=178208&&J<=183983||J>=183984&&J<=191471||J>=196608&&J<=201551||J>=63744&&J<=64255||J>=194560&&J<=195103||J>=12288&&J<=12351||J>=12352&&J<=12447||J>=12448&&J<=12543||J>=44032&&J<=55215||J>=65280&&J<=65519)return!0}return!1}var j8=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),H4=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),L8=new Set(["'","’"]),K2=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),hY=new Set([":",".","،","؛"]),pY=new Set(["၏"]),lY=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function xY($){if(k8($))return!0;let M=!1;for(let J of $){if(K2.has(J)){M=!0;continue}if(M&&O5.test(J))continue;return!1}return M}function rY($){for(let M of $)if(!j8.has(M)&&!K2.has(M))return!1;return $.length>0}function cY($){if(k8($))return!0;for(let M of $)if(!H4.has(M)&&!L8.has(M)&&!O5.test(M))return!1;return $.length>0}function k8($){let M=!1;for(let J of $){if(J==="\\"||O5.test(J))continue;if(H4.has(J)||K2.has(J)||L8.has(J)){M=!0;continue}return!1}return M}function dY($){let M=Array.from($),J=M.length;while(J>0){let Z=M[J-1];if(O5.test(Z)){J--;continue}if(H4.has(Z)||L8.has(Z)){J--;continue}break}if(J<=0||J===M.length)return null;return{head:M.slice(0,J).join(""),tail:M.slice(J).join("")}}function aY($,M){if($.length===0)return!1;for(let J of $)if(J!==M)return!1;return!0}function sY($){if(!R8($)||$.length===0)return!1;return hY.has($[$.length-1])}function iY($){if($.length===0)return!1;return pY.has($[$.length-1])}function oY($){if($.length<2||$[0]!==" ")return null;let M=$.slice(1);if(/^\p{M}+$/u.test(M))return{space:" ",marks:M};return null}function f8($){for(let M=$.length-1;M>=0;M--){let J=$[M];if(lY.has(J))return!0;if(!K2.has(J))return!1}return!1}function nY($,M){if(M.preserveOrdinarySpaces||M.preserveHardBreaks){if($===" ")return"preserved-space";if($==="\t")return"tab";if(M.preserveHardBreaks&&$===`
|
|
22
|
+
`)return"hard-break"}if($===" ")return"space";if($===" "||$===" "||$===""||$==="\uFEFF")return"glue";if($==="")return"zero-width-break";if($==="")return"soft-hyphen";return"text"}function n1($){return $.length===1?$[0]:$.join("")}function tY($,M,J,Z){let A=[],X=null,N=[],Y=J,Q=!1,K=0;for(let q of $){let U=nY(q,Z),G=U==="text"&&M;if(X!==null&&U===X&&G===Q){N.push(q),K+=q.length;continue}if(X!==null)A.push({text:n1(N),isWordLike:Q,kind:X,start:Y});X=U,N=[q],Y=J+K,Q=G,K+=q.length}if(X!==null)A.push({text:n1(N),isWordLike:Q,kind:X,start:Y});return A}function w8($){return $==="space"||$==="preserved-space"||$==="zero-width-break"||$==="hard-break"}var eY=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function $Q($,M){let J=$.texts[M];if(J.startsWith("www."))return!0;return eY.test(J)&&M+1<$.len&&$.kinds[M+1]==="text"&&$.texts[M+1]==="//"}function MQ($){return $.includes("?")&&($.includes("://")||$.startsWith("www."))}function JQ($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),A=$.starts.slice();for(let N=0;N<$.len;N++){if(Z[N]!=="text"||!$Q($,N))continue;let Y=[M[N]],Q=N+1;while(Q<$.len&&!w8(Z[Q])){Y.push(M[Q]),J[N]=!0;let K=M[Q].includes("?");if(Z[Q]="text",M[Q]="",Q++,K)break}M[N]=n1(Y)}let X=0;for(let N=0;N<M.length;N++){let Y=M[N];if(Y.length===0)continue;if(X!==N)M[X]=Y,J[X]=J[N],Z[X]=Z[N],A[X]=A[N];X++}return M.length=X,J.length=X,Z.length=X,A.length=X,{len:X,texts:M,isWordLike:J,kinds:Z,starts:A}}function ZQ($){let M=[],J=[],Z=[],A=[];for(let X=0;X<$.len;X++){let N=$.texts[X];if(M.push(N),J.push($.isWordLike[X]),Z.push($.kinds[X]),A.push($.starts[X]),!MQ(N))continue;let Y=X+1;if(Y>=$.len||w8($.kinds[Y]))continue;let Q=[],K=$.starts[Y],q=Y;while(q<$.len&&!w8($.kinds[q]))Q.push($.texts[q]),q++;if(Q.length>0)M.push(n1(Q)),J.push(!0),Z.push("text"),A.push(K),X=q-1}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:A}}var AQ=new Set([":","-","/","×",",",".","+","–","—"]),P9=/^[A-Za-z0-9_]+[,:;]*$/,W9=/[,:;]+$/;function V9($){for(let M of $)if(z9.test(M))return!0;return!1}function E8($){if($.length===0)return!1;for(let M of $){if(z9.test(M)||AQ.has(M))continue;return!1}return!0}function XQ($){let M=[],J=[],Z=[],A=[];for(let X=0;X<$.len;X++){let N=$.texts[X],Y=$.kinds[X];if(Y==="text"&&E8(N)&&V9(N)){let Q=[N],K=X+1;while(K<$.len&&$.kinds[K]==="text"&&E8($.texts[K]))Q.push($.texts[K]),K++;M.push(n1(Q)),J.push(!0),Z.push("text"),A.push($.starts[X]),X=K-1;continue}M.push(N),J.push($.isWordLike[X]),Z.push(Y),A.push($.starts[X])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:A}}function NQ($){let M=[],J=[],Z=[],A=[];for(let X=0;X<$.len;X++){let N=$.texts[X],Y=$.kinds[X],Q=$.isWordLike[X];if(Y==="text"&&Q&&P9.test(N)){let K=[N],q=W9.test(N),U=X+1;while(q&&U<$.len&&$.kinds[U]==="text"&&$.isWordLike[U]&&P9.test($.texts[U])){let G=$.texts[U];K.push(G),q=W9.test(G),U++}M.push(n1(K)),J.push(!0),Z.push("text"),A.push($.starts[X]),X=U-1;continue}M.push(N),J.push(Q),Z.push(Y),A.push($.starts[X])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:A}}function YQ($){let M=[],J=[],Z=[],A=[];for(let X=0;X<$.len;X++){let N=$.texts[X];if($.kinds[X]==="text"&&N.includes("-")){let Y=N.split("-"),Q=Y.length>1;for(let K=0;K<Y.length;K++){let q=Y[K];if(!Q)break;if(q.length===0||!V9(q)||!E8(q))Q=!1}if(Q){let K=0;for(let q=0;q<Y.length;q++){let U=Y[q],G=q<Y.length-1?`${U}-`:U;M.push(G),J.push(!0),Z.push("text"),A.push($.starts[X]+K),K+=G.length}continue}}M.push(N),J.push($.isWordLike[X]),Z.push($.kinds[X]),A.push($.starts[X])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:A}}function QQ($){let M=[],J=[],Z=[],A=[],X=0;while(X<$.len){let N=[$.texts[X]],Y=$.isWordLike[X],Q=$.kinds[X],K=$.starts[X];if(Q==="glue"){let q=[N[0]],U=K;X++;while(X<$.len&&$.kinds[X]==="glue")q.push($.texts[X]),X++;let G=n1(q);if(X<$.len&&$.kinds[X]==="text")N[0]=G,N.push($.texts[X]),Y=$.isWordLike[X],Q="text",K=U,X++;else{M.push(G),J.push(!1),Z.push("glue"),A.push(U);continue}}else X++;if(Q==="text")while(X<$.len&&$.kinds[X]==="glue"){let q=[];while(X<$.len&&$.kinds[X]==="glue")q.push($.texts[X]),X++;let U=n1(q);if(X<$.len&&$.kinds[X]==="text"){N.push(U,$.texts[X]),Y=Y||$.isWordLike[X],X++;continue}N.push(U)}M.push(n1(N)),J.push(Y),Z.push(Q),A.push(K)}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:A}}function KQ($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),A=$.starts.slice();for(let X=0;X<M.length-1;X++){if(Z[X]!=="text"||Z[X+1]!=="text")continue;if(!o1(M[X])||!o1(M[X+1]))continue;let N=dY(M[X]);if(N===null)continue;M[X]=N.head,M[X+1]=N.tail+M[X+1],A[X+1]=A[X]+N.head.length}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:A}}function qQ($,M,J){let Z=gY(),A=0,X=[],N=[],Y=[],Q=[];for(let G of Z.segment($))for(let B of tY(G.segment,G.isWordLike??!1,G.index,J)){let F=B.kind==="text";if(M.carryCJKAfterClosingQuote&&F&&A>0&&Y[A-1]==="text"&&o1(B.text)&&o1(X[A-1])&&f8(X[A-1]))X[A-1]+=B.text,N[A-1]=N[A-1]||B.isWordLike;else if(F&&A>0&&Y[A-1]==="text"&&rY(B.text)&&o1(X[A-1]))X[A-1]+=B.text,N[A-1]=N[A-1]||B.isWordLike;else if(F&&A>0&&Y[A-1]==="text"&&iY(X[A-1]))X[A-1]+=B.text,N[A-1]=N[A-1]||B.isWordLike;else if(F&&A>0&&Y[A-1]==="text"&&B.isWordLike&&R8(B.text)&&sY(X[A-1]))X[A-1]+=B.text,N[A-1]=!0;else if(F&&!B.isWordLike&&A>0&&Y[A-1]==="text"&&B.text.length===1&&B.text!=="-"&&B.text!=="—"&&aY(X[A-1],B.text))X[A-1]+=B.text;else if(F&&!B.isWordLike&&A>0&&Y[A-1]==="text"&&(xY(B.text)||B.text==="-"&&N[A-1]))X[A-1]+=B.text;else X[A]=B.text,N[A]=B.isWordLike,Y[A]=B.kind,Q[A]=B.start,A++}for(let G=1;G<A;G++)if(Y[G]==="text"&&!N[G]&&k8(X[G])&&Y[G-1]==="text")X[G-1]+=X[G],N[G-1]=N[G-1]||N[G],X[G]="";for(let G=A-2;G>=0;G--)if(Y[G]==="text"&&!N[G]&&cY(X[G])){let B=G+1;while(B<A&&X[B]==="")B++;if(B<A&&Y[B]==="text")X[B]=X[G]+X[B],Q[B]=Q[G],X[G]=""}let K=0;for(let G=0;G<A;G++){let B=X[G];if(B.length===0)continue;if(K!==G)X[K]=B,N[K]=N[G],Y[K]=Y[G],Q[K]=Q[G];K++}X.length=K,N.length=K,Y.length=K,Q.length=K;let q=QQ({len:K,texts:X,isWordLike:N,kinds:Y,starts:Q}),U=KQ(NQ(YQ(XQ(ZQ(JQ(q))))));for(let G=0;G<U.len-1;G++){let B=oY(U.texts[G]);if(B===null)continue;if(U.kinds[G]!=="space"&&U.kinds[G]!=="preserved-space"||U.kinds[G+1]!=="text"||!R8(U.texts[G+1]))continue;U.texts[G]=B.space,U.isWordLike[G]=!1,U.kinds[G]=U.kinds[G]==="preserved-space"?"preserved-space":"space",U.texts[G+1]=B.marks+U.texts[G+1],U.starts[G+1]=U.starts[G]+B.space.length}return U}function UQ($,M){if($.len===0)return[];if(!M.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len}];let J=[],Z=0;for(let A=0;A<$.len;A++){if($.kinds[A]!=="hard-break")continue;J.push({startSegmentIndex:Z,endSegmentIndex:A,consumedEndSegmentIndex:A+1}),Z=A+1}if(Z<$.len)J.push({startSegmentIndex:Z,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len});return J}function y9($,M,J="normal"){let Z=SY(J),A=Z.mode==="pre-wrap"?mY($):uY($);if(A.length===0)return{normalized:A,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let X=qQ(A,M,Z);return{normalized:A,chunks:UQ(X,Z),...X}}var q2=null,b9=new Map,U2=null,GQ=/\p{Emoji_Presentation}/u,BQ=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,S8=null,O9=new Map;function u8(){if(q2!==null)return q2;if(typeof OffscreenCanvas<"u")return q2=new OffscreenCanvas(1,1).getContext("2d"),q2;if(typeof document<"u")return q2=document.createElement("canvas").getContext("2d"),q2;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function FQ($){let M=b9.get($);if(!M)M=new Map,b9.set($,M);return M}function _0($,M){let J=M.get($);if(J===void 0)J={width:u8().measureText($).width,containsCJK:o1($)},M.set($,J);return J}function G2(){if(U2!==null)return U2;if(typeof navigator>"u")return U2={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},U2;let $=navigator.userAgent,J=navigator.vendor==="Apple Computer, Inc."&&$.includes("Safari/")&&!$.includes("Chrome/")&&!$.includes("Chromium/")&&!$.includes("CriOS/")&&!$.includes("FxiOS/")&&!$.includes("EdgiOS/"),Z=$.includes("Chrome/")||$.includes("Chromium/")||$.includes("CriOS/")||$.includes("Edg/");return U2={lineFitEpsilon:J?0.015625:0.005,carryCJKAfterClosingQuote:Z,preferPrefixWidthsForBreakableRuns:J,preferEarlySoftHyphenBreak:J},U2}function _Q($){let M=$.match(/(\d+(?:\.\d+)?)\s*px/);return M?parseFloat(M[1]):16}function m8(){if(S8===null)S8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return S8}function DQ($){return GQ.test($)||$.includes("️")}function C9($){return BQ.test($)}function HQ($,M){let J=O9.get($);if(J!==void 0)return J;let Z=u8();Z.font=$;let A=Z.measureText("\uD83D\uDE00").width;if(J=0,A>M+0.5&&typeof document<"u"&&document.body!==null){let X=document.createElement("span");X.style.font=$,X.style.display="inline-block",X.style.visibility="hidden",X.style.position="absolute",X.textContent="\uD83D\uDE00",document.body.appendChild(X);let N=X.getBoundingClientRect().width;if(document.body.removeChild(X),A-N>0.5)J=A-N}return O9.set($,J),J}function TQ($){let M=0,J=m8();for(let Z of J.segment($))if(DQ(Z.segment))M++;return M}function PQ($,M){if(M.emojiCount===void 0)M.emojiCount=TQ($);return M.emojiCount}function D0($,M,J){if(J===0)return M.width;return M.width-PQ($,M)*J}function R9($,M,J,Z){if(M.graphemeWidths!==void 0)return M.graphemeWidths;let A=[],X=m8();for(let N of X.segment($)){let Y=_0(N.segment,J);A.push(D0(N.segment,Y,Z))}return M.graphemeWidths=A.length>1?A:null,M.graphemeWidths}function w9($,M,J,Z){if(M.graphemePrefixWidths!==void 0)return M.graphemePrefixWidths;let A=[],X=m8(),N="";for(let Y of X.segment($)){N+=Y.segment;let Q=_0(N,J);A.push(D0(N,Q,Z))}return M.graphemePrefixWidths=A.length>1?A:null,M.graphemePrefixWidths}function E9($,M){let J=u8();J.font=$;let Z=FQ($),A=_Q($),X=M?HQ($,A):0;return{cache:Z,fontSize:A,emojiCorrection:X}}function C5($){return $==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen"}function WQ($,M){while(M<$.widths.length){let J=$.kinds[M];if(J!=="space"&&J!=="zero-width-break"&&J!=="soft-hyphen")break;M++}return M}function zQ($,M){if(M<=0)return 0;let J=$%M;if(Math.abs(J)<=0.000001)return M;return M-J}function j9($,M,J,Z){if(!Z||M===null)return $[J];return M[J]-(J>0?M[J-1]:0)}function VQ($,M,J,Z,A,X){let N=0,Y=M;while(N<$.length){let Q=X?M+$[N]:Y+$[N];if((N+1<$.length?Q+A:Q)>J+Z)break;Y=Q,N++}return{fitCount:N,fittedWidth:Y}}function yQ($,M,J){let{widths:Z,kinds:A,breakableWidths:X,breakablePrefixWidths:N}=$;if(Z.length===0)return 0;let Y=G2(),Q=Y.lineFitEpsilon,K=0,q=0,U=!1,G=0,B=0,F=0,_=0,D=-1,y=0;function b(){D=-1,y=0}function O(P=F,E=_,W=q){K++,J?.({startSegmentIndex:G,startGraphemeIndex:B,endSegmentIndex:P,endGraphemeIndex:E,width:W}),q=0,U=!1,b()}function k(P,E){U=!0,G=P,B=0,F=P+1,_=0,q=E}function j(P,E,W){U=!0,G=P,B=E,F=P,_=E+1,q=W}function R(P,E){if(!U){k(P,E);return}q+=E,F=P+1,_=0}function w(P,E){if(!C5(A[P]))return;D=P+1,y=q-E}function L(P){V(P,0)}function V(P,E){let W=X[P],z=N[P]??null;for(let u=E;u<W.length;u++){let p=j9(W,z,u,Y.preferPrefixWidthsForBreakableRuns);if(!U){j(P,u,p);continue}if(q+p>M+Q)O(),j(P,u,p);else q+=p,F=P,_=u+1}if(U&&F===P&&_===W.length)F=P+1,_=0}let T=0;while(T<Z.length){if(!U){if(T=WQ($,T),T>=Z.length)break}let P=Z[T],E=A[T];if(!U){if(P>M&&X[T]!==null)L(T);else k(T,P);w(T,P),T++;continue}if(q+P>M+Q){if(C5(E)){R(T,P),O(T+1,0,q-P),T++;continue}if(D>=0){if(F>D||F===D&&_>0){O();continue}O(D,0,y);continue}if(P>M&&X[T]!==null){O(),L(T),T++;continue}O();continue}R(T,P),w(T,P),T++}if(U)O();return K}function L9($,M,J){if($.simpleLineWalkFastPath)return yQ($,M,J);let{widths:Z,lineEndFitAdvances:A,lineEndPaintAdvances:X,kinds:N,breakableWidths:Y,breakablePrefixWidths:Q,discretionaryHyphenWidth:K,tabStopAdvance:q,chunks:U}=$;if(Z.length===0||U.length===0)return 0;let G=G2(),B=G.lineFitEpsilon,F=0,_=0,D=!1,y=0,b=0,O=0,k=0,j=-1,R=0,w=0,L=null;function V(){j=-1,R=0,w=0,L=null}function T(f=O,m=k,v=_){F++,J?.({startSegmentIndex:y,startGraphemeIndex:b,endSegmentIndex:f,endGraphemeIndex:m,width:v}),_=0,D=!1,V()}function P(f,m){D=!0,y=f,b=0,O=f+1,k=0,_=m}function E(f,m,v){D=!0,y=f,b=m,O=f,k=m+1,_=v}function W(f,m){if(!D){P(f,m);return}_+=m,O=f+1,k=0}function z(f,m){if(!C5(N[f]))return;let v=N[f]==="tab"?0:A[f],Z1=N[f]==="tab"?m:X[f];j=f+1,R=_-m+v,w=_-m+Z1,L=N[f]}function u(f){p(f,0)}function p(f,m){let v=Y[f],Z1=Q[f]??null;for(let o=m;o<v.length;o++){let _1=j9(v,Z1,o,G.preferPrefixWidthsForBreakableRuns);if(!D){E(f,o,_1);continue}if(_+_1>M+B)T(),E(f,o,_1);else _+=_1,O=f,k=o+1}if(D&&O===f&&k===v.length)O=f+1,k=0}function I(f){if(L!=="soft-hyphen")return!1;let m=Y[f];if(m===null)return!1;let v=G.preferPrefixWidthsForBreakableRuns?Q[f]??m:m,Z1=v!==m,{fitCount:o,fittedWidth:_1}=VQ(v,_,M,B,K,Z1);if(o===0)return!1;if(_=_1,O=f,k=o,V(),o===m.length)return O=f+1,k=0,!0;return T(f,o,_1+K),p(f,o),!0}function e(f){F++,J?.({startSegmentIndex:f.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:f.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),V()}for(let f=0;f<U.length;f++){let m=U[f];if(m.startSegmentIndex===m.endSegmentIndex){e(m);continue}D=!1,_=0,y=m.startSegmentIndex,b=0,O=m.startSegmentIndex,k=0,V();let v=m.startSegmentIndex;while(v<m.endSegmentIndex){let Z1=N[v],o=Z1==="tab"?zQ(_,q):Z[v];if(Z1==="soft-hyphen"){if(D)O=v+1,k=0,j=v+1,R=_+K,w=_+K,L=Z1;v++;continue}if(!D){if(o>M&&Y[v]!==null)u(v);else P(v,o);z(v,o),v++;continue}if(_+o>M+B){let T2=_+(Z1==="tab"?0:A[v]),$0=_+(Z1==="tab"?o:X[v]);if(L==="soft-hyphen"&&G.preferEarlySoftHyphenBreak&&R<=M+B){T(j,0,w);continue}if(L==="soft-hyphen"&&I(v)){v++;continue}if(C5(Z1)&&T2<=M+B){W(v,o),T(v+1,0,$0),v++;continue}if(j>=0&&R<=M+B){if(O>j||O===j&&k>0){T();continue}let R1=j;T(R1,0,w),v=R1;continue}if(o>M&&Y[v]!==null){T(),u(v),v++;continue}T();continue}W(v,o),z(v,o),v++}if(D){let Z1=j===m.consumedEndSegmentIndex?w:_;T(m.consumedEndSegmentIndex,0,Z1)}}return F}var v8=null,k9=new WeakMap;function S9(){if(v8===null)v8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return v8}function bQ($){if($)return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]};return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function OQ($,M,J){let Z=S9(),A=G2(),{cache:X,emojiCorrection:N}=E9(M,C9($.normalized)),Y=D0("-",_0("-",X),N),K=D0(" ",_0(" ",X),N)*8;if($.len===0)return bQ(J);let q=[],U=[],G=[],B=[],F=$.chunks.length<=1,_=J?[]:null,D=[],y=[],b=J?[]:null,O=Array.from({length:$.len}),k=Array.from({length:$.len});function j(L,V,T,P,E,W,z,u){if(E!=="text"&&E!=="space"&&E!=="zero-width-break")F=!1;if(q.push(V),U.push(T),G.push(P),B.push(E),_?.push(W),D.push(z),y.push(u),b!==null)b.push(L)}for(let L=0;L<$.len;L++){O[L]=q.length;let V=$.texts[L],T=$.isWordLike[L],P=$.kinds[L],E=$.starts[L];if(P==="soft-hyphen"){j(V,0,Y,Y,P,E,null,null),k[L]=q.length;continue}if(P==="hard-break"){j(V,0,0,0,P,E,null,null),k[L]=q.length;continue}if(P==="tab"){j(V,0,0,0,P,E,null,null),k[L]=q.length;continue}let W=_0(V,X);if(P==="text"&&W.containsCJK){let I="",e=0;for(let f of Z.segment(V)){let m=f.segment;if(I.length===0){I=m,e=f.index;continue}if(H4.has(I)||j8.has(m)||K2.has(m)||A.carryCJKAfterClosingQuote&&o1(m)&&f8(I)){I+=m;continue}let v=_0(I,X),Z1=D0(I,v,N);j(I,Z1,Z1,Z1,"text",E+e,null,null),I=m,e=f.index}if(I.length>0){let f=_0(I,X),m=D0(I,f,N);j(I,m,m,m,"text",E+e,null,null)}k[L]=q.length;continue}let z=D0(V,W,N),u=P==="space"||P==="preserved-space"||P==="zero-width-break"?0:z,p=P==="space"||P==="zero-width-break"?0:z;if(T&&V.length>1){let I=R9(V,W,X,N),e=A.preferPrefixWidthsForBreakableRuns?w9(V,W,X,N):null;j(V,z,u,p,P,E,I,e)}else j(V,z,u,p,P,E,null,null);k[L]=q.length}let R=CQ($.chunks,O,k),w=_===null?null:T9($.normalized,_);if(b!==null)return{widths:q,lineEndFitAdvances:U,lineEndPaintAdvances:G,kinds:B,simpleLineWalkFastPath:F,segLevels:w,breakableWidths:D,breakablePrefixWidths:y,discretionaryHyphenWidth:Y,tabStopAdvance:K,chunks:R,segments:b};return{widths:q,lineEndFitAdvances:U,lineEndPaintAdvances:G,kinds:B,simpleLineWalkFastPath:F,segLevels:w,breakableWidths:D,breakablePrefixWidths:y,discretionaryHyphenWidth:Y,tabStopAdvance:K,chunks:R}}function CQ($,M,J){let Z=[];for(let A=0;A<$.length;A++){let X=$[A],N=X.startSegmentIndex<M.length?M[X.startSegmentIndex]:J[J.length-1]??0,Y=X.endSegmentIndex<M.length?M[X.endSegmentIndex]:J[J.length-1]??0,Q=X.consumedEndSegmentIndex<M.length?M[X.consumedEndSegmentIndex]:J[J.length-1]??0;Z.push({startSegmentIndex:N,endSegmentIndex:Y,consumedEndSegmentIndex:Q})}return Z}function RQ($,M,J,Z){let A=y9($,G2(),Z?.whiteSpace);return OQ(A,M,J)}function u9($,M,J){return RQ($,M,!0,J)}function wQ($){return $}function f9($,M,J){let Z=J.get($);if(Z!==void 0)return Z;Z=[];let A=S9();for(let X of A.segment(M[$]))Z.push(X.segment);return J.set($,Z),Z}function EQ($){let M=k9.get($);if(M!==void 0)return M;return M=new Map,k9.set($,M),M}function jQ($,M,J,Z){return Z>0&&$[Z-1]==="soft-hyphen"&&!(M===Z&&J>0)}function LQ($,M,J,Z,A,X,N){let Y="",Q=jQ(M,Z,A,X);for(let K=Z;K<X;K++){if(M[K]==="soft-hyphen"||M[K]==="hard-break")continue;if(K===Z&&A>0)Y+=f9(K,$,J).slice(A).join("");else Y+=$[K]}if(N>0){if(Q)Y+="-";Y+=f9(X,$,J).slice(Z===X?A:0,N).join("")}else if(Q)Y+="-";return Y}function kQ($,M,J,Z,A,X,N){return{text:LQ($.segments,$.kinds,M,Z,A,X,N),width:J,start:{segmentIndex:Z,graphemeIndex:A},end:{segmentIndex:X,graphemeIndex:N}}}function fQ($,M,J){return kQ($,M,J.width,J.startSegmentIndex,J.startGraphemeIndex,J.endSegmentIndex,J.endGraphemeIndex)}function m9($,M,J){let Z=[];if($.widths.length===0)return{lineCount:0,height:0,lines:Z};let A=EQ($),X=L9(wQ($),M,(N)=>{Z.push(fQ($,A,N))});return{lineCount:X,height:X*J,lines:Z}}function g8($,M,J){let Z=$.image?M.images.get($.image.url)??null:null,A=$.image?.width??null,X=Math.min(J,A??240),N=Math.max(120,Math.round(X*0.5625));if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return{height:N,width:X};let Y=Math.min(J,A??Z.intrinsicWidth),Q=Math.min(1,Y/Z.intrinsicWidth);return{height:Math.max(48,Math.round(Z.intrinsicHeight*Q)),width:Math.max(48,Math.round(Z.intrinsicWidth*Q))}}function v9($,M){if(!$.image)return`${$.kind}:missing-image`;let J=M.images.get($.image.url);return`${$.kind}:${$.image.url}:${$.image.width??0}:${J?.status??"loading"}:${J?.intrinsicWidth??0}:${J?.intrinsicHeight??0}`}var g9=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],R5;function B2($){if($?.type==="heading"){let{fontSize:M}=p9($.depth);return`700 ${M}px "Iowan Old Style", "Palatino Linotype", serif`}switch($?.type){case"code":return"15px ui-monospace, SFMono-Regular, Menlo, monospace";default:return'16px "Iowan Old Style", "Palatino Linotype", serif'}}function k0($,M){if($?.type==="heading")return p9($.depth).lineHeight;if($?.type==="code")return 22;return M}function p9($){return g9[$-1]??g9.at(-1)}function F2($,M,J,Z,A,X,N){let Y=`${E5(M,N)}:${A}:${X}:${J}`,Q=$.measuredLines.get(Y);if(Q)return Q;let K=uQ($,M,J,Z,A,X,N);return G9($,Y,K)}function w5($,M,J,Z,A,X,N,Y){let Q=`${E5(M,Y)}:${J}:${Z}:${X}:${N}`,K=$.lineBoundaries.get(Q);if(K)return K;let q=x9();if(!q)return h9(A);let U=[{left:0,offset:0}],G=0,B=M.inlines.filter((F)=>F.end>J&&F.start<Z);if(B.length===0)return h9(A);for(let F of B){let _=Math.max(J,F.start),D=Math.min(Z,F.end),y=M.text.slice(_,D),b=_-J;if(F.kind==="image"){let O=g8(F,Y,N).width;G+=O,b+=y.length,U.push({left:G,offset:b});continue}q.font=l9(X,F.marks);for(let O of Array.from(y))G+=r9($,q,O),b+=O.length,U.push({left:G,offset:b})}return B9($,Q,U)}function SQ($,M,J,Z){let A=`${J}::${Z}::${M}`,X=$.preparedText.get(A);if(X)return X;let N=u9(M,J,{whiteSpace:Z});return U9($,A,N)}function uQ($,M,J,Z,A,X,N){let Y=M.text;if(Y.length===0)return[{end:0,height:X,start:0,text:"",width:0}];if(hQ(M))return vQ($,M,J,A,X,N);try{let Q=SQ($,Y,J,cQ(Z));return m9(Q,A,X).lines.map((q)=>({end:I9(Q.segments,q.end),height:X,start:I9(Q.segments,q.start),text:q.text,width:q.width}))}catch{return mQ(Y,A,X)}}function I9($,M){let J=0;for(let X=0;X<M.segmentIndex;X+=1)J+=$[X]?.length??0;let Z=$[M.segmentIndex]??"",A=Array.from(Z);for(let X=0;X<M.graphemeIndex;X+=1)J+=A[X]?.length??0;return J}function h9($){let M=[{left:0,offset:0}],J=0,Z=0;for(let A of Array.from($))J+=9,Z+=A.length,M.push({left:J,offset:Z});return M}function mQ($,M,J){let Z=Math.max(1,Math.floor(M/9)),A=dQ($,Z),X=0;return A.map((N)=>{let Y=X,Q=Y+N.length;return X=Q,{end:Q,height:J,start:Y,text:N,width:N.length*9}})}function vQ($,M,J,Z,A,X){let N=IQ($,x9(),M,J,Z,A,X);if(N.length===0)return[{end:0,height:A,start:0,text:"",width:0}];return gQ(N,M.text,Z,A)}function gQ($,M,J,Z){let A=[],X=0;while(X<$.length){let N=$[X].start;if($[X].text===`
|
|
23
|
+
`){A.push({end:N,height:Z,start:N,text:"",width:0}),X+=1;continue}let Y=0,Q=0,K=X,q=-1,U=Z;while(K<$.length){let B=$[K];if(B.text===`
|
|
24
|
+
`)break;let F=Y+B.width;if(F>J&&K>X)break;if(Y=F,U=Math.max(U,B.height),B.breakable)q=K,Q=Y;K+=1}if(K===$.length||$[K]?.text===`
|
|
25
|
+
`){let B=$[K-1]?.end??N;A.push({end:B,height:U,start:N,text:M.slice(N,B),width:Y}),X=K<$.length&&$[K]?.text===`
|
|
26
|
+
`?K+1:K;continue}if(q>=X){let B=$[q].end;A.push({end:B,height:U,start:N,text:M.slice(N,B),width:Q}),X=q+1;continue}let G=$[Math.max(X,K-1)].end;A.push({end:G,height:U,start:N,text:M.slice(N,G),width:Y}),X=Math.max(X+1,K)}return A}function IQ($,M,J,Z,A,X,N){let Y=[];for(let Q of J.inlines){if(Q.kind==="image"){let q=g8(Q,N,A);Y.push({breakable:!0,end:Q.end,height:q.height,start:Q.start,text:Q.text,width:q.width});continue}if(M)M.font=l9(Z,Q.marks);let K=Q.start;for(let q of Array.from(Q.text)){let U=K,G=U+q.length;Y.push({breakable:/\s/.test(q),end:G,height:X,start:U,text:q,width:q===`
|
|
27
|
+
`?0:r9($,M,q)}),K=G}}return Y}function hQ($){return $.inlines.some((M)=>M.kind==="image"||rQ(M))}function E5($,M){return[$.path,xQ($.text),pQ($,M)].join(":")}function pQ($,M){return $.inlines.map((J)=>`${J.start}-${J.end}:${lQ(J,M)}`).join("|")}function lQ($,M){if($.kind==="image"&&$.image)return v9($,M);return`${$.kind}:${$.inlineCode?1:0}:${$.marks.join(",")}:${$.link?.url??""}`}function xQ($){let M=2166136261;for(let J of $)M^=J.charCodeAt(0),M=Math.imul(M,16777619);return(M>>>0).toString(36)}function rQ($){return $.marks.includes("italic")||$.marks.includes("bold")}function l9($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function x9(){if(R5!==void 0)return R5;return R5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,R5}function r9($,M,J){if(!M)return 9;let Z=M.font,A=_9($,Z),X=A.get(J);if(X!==void 0)return X;let N=M.measureText(J).width;return A.set(J,N),N}function cQ($){return $?.type==="code"?"pre-wrap":"normal"}function dQ($,M){if($.length===0)return[""];let J=$.split(`
|
|
28
|
+
`),Z=[];for(let A of J){if(A.length===0){Z.push("");continue}let X=A;while(X.length>M){let N=X.slice(0,M),Y=N.lastIndexOf(" ");if(Y<=0){Z.push(N),X=X.slice(M);continue}Z.push(N.slice(0,Y)),X=X.slice(Y+1)}Z.push(X)}return Z}var T4=10,_2=8,I8=120;function c9($,M,J,Z,A,X,N,Y,Q,K){let q=Math.max(1,...X.rows.map((_)=>_.cells.length)),G=Math.max(I8,Q.width-N-Q.paddingX)/q,B=aQ(Z),F=Y;for(let _=0;_<X.rows.length;_+=1){let D=sQ(B.get(_)??[],A,X,G,T4,Q.lineHeight,K),y=Math.max(Q.lineHeight+_2*2,...D.map((b)=>b.measuredLines.reduce((O,k)=>O+k.height,0)+_2*2));for(let b of D){let O=N+b.cellIndex*G,k=F+_2;for(let j of b.measuredLines){let R={blockId:b.container.blockId,boundaries:w5(A,b.container,j.start,j.end,j.text,b.font,G-T4*2,K),regionId:b.container.id,end:j.end,font:b.font,height:j.height,left:O+T4,start:j.start,text:j.text,top:k,width:j.width};$.push(R),h8(M,R),k+=j.height}J.set(b.container.id,{bottom:F+y,left:O,right:O+G,top:F})}oQ(M,X.id,F,F+y),F+=y}return F+Q.blockGap}function aQ($){let M=new Map;for(let J of $){let Z=iQ(J.path);if(!Z)continue;let A=M.get(Z.rowIndex)??[];A.push({cellIndex:Z.cellIndex,container:J}),M.set(Z.rowIndex,A)}return M}function sQ($,M,J,Z,A,X,N){return[...$].sort((Y,Q)=>Y.cellIndex-Q.cellIndex).map(({cellIndex:Y,container:Q})=>{let K=B2(J),q=k0(J,X),U=F2(M,Q,K,J,Math.max(40,Z-A*2),q,N);return{cellIndex:Y,container:Q,font:K,lineHeight:q,measuredLines:U}})}function iQ($){let M=/\.rows\.(\d+)\.cells\.(\d+)$/.exec($);if(!M)return null;return{cellIndex:Number(M[2]),rowIndex:Number(M[1])}}function oQ($,M,J,Z){let A=$.get(M);$.set(M,{bottom:A?Math.max(A.bottom,Z):Z,top:A?Math.min(A.top,J):J})}var nQ={blockGap:16,charWidth:9,indentWidth:24,lineHeight:24,paddingX:16,paddingY:12},tQ=24,eQ=16,$K=6,MK=10,JK=4;function j5($){let M=Math.max(12,Math.floor($.width/9)),J=Math.max(1,Math.ceil($.text.length/M));return{estimatedHeight:J*24,lineCount:J,width:$.width}}function L5($,M,J=Q2(),Z=l1){let A={...nQ,...M},X=[],N=new Map,Y=new Map($.regions.map((F)=>[F.id,{textLength:F.text.length}])),Q=new Map($.blocks.map((F)=>[F.id,F.depth])),K=new Map($.blocks.map((F)=>[F.id,F])),q=x8($.document.blocks),U=new Map,G=A.paddingY;for(let F=0;F<$.regions.length;F+=1){let _=$.regions[F],D=Q.get(_.blockId)??0,y=A.paddingX+D*A.indentWidth,b=Math.max(40,A.width-y-A.paddingX),O=q.get(_.blockId)??null;if(O?.type==="table"){let R=K.get(_.blockId)?.regionIds??[],w=$.regions.slice(F,F+R.length);G=c9(X,U,N,w,J,O,y,G,A,Z),F+=w.length-1;continue}G=ZK(X,U,N,_,J,O,y,G,b,A,Z);let k=f5(K,q,$.regions,F,A.blockGap);G+=k;let j=U.get(_.blockId);if(j)j.bottom=Math.max(j.bottom,G)}return{blocks:$.blocks.map((F)=>{let _=U.get(F.id),D=_?.top??A.paddingY;return{bottom:_?.bottom??D+A.lineHeight/2,depth:F.depth,id:F.id,top:D,type:F.type}}),regionBounds:XK(X,N),regionLineIndices:AK(X),regionMetrics:Y,height:Math.max(G,A.paddingY),lines:X,options:A,width:A.width}}function ZK($,M,J,Z,A,X,N,Y,Q,K,q){let U=B2(X),G=k0(X,K.lineHeight),B=F2(A,Z,U,X,Q,G,q),F=Y;for(let _ of B){let D={blockId:Z.blockId,boundaries:w5(A,Z,_.start,_.end,_.text,U,Q,q),regionId:Z.id,end:_.end,font:U,height:_.height,left:N,start:_.start,text:_.text,top:F,width:_.width};$.push(D),h8(M,D),F+=_.height}return NK($,Z.id,J),F}function AK($){let M=[...$].sort((Z,A)=>Z.top-A.top||Z.left-A.left),J=new Map;$.length=0,$.push(...M);for(let[Z,A]of $.entries()){let X=J.get(A.regionId)??[];X.push(Z),J.set(A.regionId,X)}return J}function XK($,M){let J=new Map(M);for(let Z of $){let A=J.get(Z.regionId),X={bottom:Z.top+Z.height,left:Z.left,right:Z.left+Z.width,top:Z.top};J.set(Z.regionId,A?{bottom:Math.max(A.bottom,X.bottom),left:Math.min(A.left,X.left),right:Math.max(A.right,X.right),top:Math.min(A.top,X.top)}:X)}return J}function NK($,M,J){let Z=$.filter((A)=>A.regionId===M);if(Z.length===0)return;J.set(M,{bottom:Math.max(...Z.map((A)=>A.top+A.height)),left:Math.min(...Z.map((A)=>A.left)),right:Math.max(...Z.map((A)=>A.left+A.width)),top:Math.min(...Z.map((A)=>A.top))})}function h8($,M){let J=$.get(M.blockId),Z=M.top+M.height;$.set(M.blockId,{bottom:J?Math.max(J.bottom,Z):Z,top:J?Math.min(J.top,M.top):M.top})}function o9($,M){let J=0,Z=$.lines.length-1;while(J<=Z){let A=J+Z>>1,X=$.lines[A];if(M<X.top){Z=A-1;continue}if(M>=X.top+X.height){J=A+1;continue}return{index:A,line:X}}return null}function p8($,M){let J=[...$.regionBounds.entries()].find(([,X])=>{return M.x>=X.left&&M.x<=X.right&&M.y>=X.top&&M.y<=X.bottom});if(J)return k5($,J[0],M.y);let Z=o9($,M.y);if(!Z)return null;let A=YK($,M.y,Z.index);if(A.length===1)return A[0]??null;return A.find((X)=>{let N=$.regionBounds.get(X.line.regionId);return N?M.x>=N.left&&M.x<=N.right:!1})??[...A].sort((X,N)=>{let Y=$.regionBounds.get(X.line.regionId),Q=$.regionBounds.get(N.line.regionId),K=d9(M.x,Y),q=d9(M.x,Q);return K-q})[0]??null}function l8($,M,J){if($.lines.length===0)return{endIndex:0,startIndex:0};let Z=M+J,A=a9($,M),X=a9($,Z);if(A>0){let N=$.lines[A-1];if(N.top+N.height>M)A-=1}if(X<$.lines.length){if($.lines[X].top<Z)X+=1}return{endIndex:X,startIndex:A}}function x1($,M,J){if(!$.regionMetrics.get(J.regionId))return null;let A=t1($,J.regionId,J.offset);if(!A)return null;return{blockId:A.blockId,regionId:A.regionId,height:A.height,left:r1(A,J.offset-A.start),offset:J.offset,top:A.top}}function t1($,M,J){return P4($,M,J)?.line??null}function k5($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let A=Z[0],X=Number.POSITIVE_INFINITY;for(let N of Z){let Y=$.lines[N],Q=J<Y.top?Y.top-J:J>Y.top+Y.height?J-(Y.top+Y.height):0;if(Q<X)X=Q,A=N;if(Q===0)break}return{index:A,line:$.lines[A]}}function P4($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let A=0,X=Z.length-1;while(A<=X){let q=A+X>>1,U=Z[q],G=$.lines[U];if(J<G.start){X=q-1;continue}if(J>G.end){A=q+1;continue}return{index:U,line:G}}let N=Z[0],Y=Z[Z.length-1],Q=$.lines[N],K=$.lines[Y];if(J<=Q.start)return{index:N,line:Q};if(J>=K.end)return{index:Y,line:K};return null}function YK($,M,J){let Z=[];for(let A=J;A>=0;A-=1){let X=$.lines[A];if(M<X.top||M>=X.top+X.height)break;Z.unshift({index:A,line:X})}for(let A=J+1;A<$.lines.length;A+=1){let X=$.lines[A];if(M<X.top||M>=X.top+X.height)break;Z.push({index:A,line:X})}return Z}function d9($,M){if(!M)return Number.POSITIVE_INFINITY;if($<M.left)return M.left-$;if($>M.right)return $-M.right;return 0}function r1($,M){return $.left+QK($.boundaries,M)}function x8($){let M=new Map,J=(Z)=>{for(let A of Z)if(M.set(A.id,A),A.type==="blockquote"||A.type==="listItem")J(A.children);else if(A.type==="list")J(A.items)};return J($),M}function QK($,M){for(let Z of $)if(Z.offset===M)return Z.left;return $.filter((Z)=>Z.offset<=M).at(-1)?.left??0}function a9($,M){let J=0,Z=$.lines.length;while(J<Z){let A=J+Z>>1,X=$.lines[A];if(X.top+X.height<=M)J=A+1;else Z=A}return J}function n9($,M){if($.length===0)return 0;for(let J=1;J<$.length;J+=1){let Z=$[J-1],A=$[J],X=Z.left+(A.left-Z.left)/2;if(M<=X)return Z.offset;if(M<=A.left)return A.offset}return $.at(-1)?.offset??0}function f5($,M,J,Z,A){let X=J[Z],N=J[Z+1];if(!X||!N)return A;if(s9($,X.blockId,N.blockId,"list"))return $K;if(s9($,X.blockId,N.blockId,"blockquote"))return MK;if(X.blockId===N.blockId)return JK;return A+KK(M.get(X.blockId))}function KK($){if($?.type!=="heading")return 0;if($.depth===1)return tQ;return $.depth===2?eQ:0}function s9($,M,J,Z){let A=i9($,M,Z),X=i9($,J,Z);for(let N of A)if(X.has(N))return!0;return!1}function i9($,M,J){let Z=new Set,A=$.get(M)??null;while(A){if(A.type===J)Z.add(A.id);A=A.parentBlockId?$.get(A.parentBlockId)??null:null}return Z}function r8($,M,J,Z=[],A=Q2(),X=l1){let N=x8($.document.blocks),Y=new Map($.blocks.map((b)=>[b.id,b])),Q=new Set(Z),K=Math.max(0,J.top-J.overscan),q=J.top+J.height+J.overscan,U=FK(A,$,N,Y,M,X),G=t9(U,K),B=t9(U,q);if(G>0){let b=U.entries[G-1];if(b&&b.bottom>K)G-=1}if(B<U.entries.length){let b=U.entries[B];if(b&&b.top<q)B+=1}for(let b of Q){let O=U.containerIndices.get(b);if(O===void 0)continue;G=Math.min(G,O),B=Math.max(B,O+1)}if(!Number.isFinite(G)||!Number.isFinite(B))return{estimateRegionBounds:U.estimateRegionBounds,layout:L5({...$,regions:[]},M,A,X),totalHeight:U.totalHeight,viewport:J};let F=GK($,Y,U.containerIndices,G,B),_=U.entries[F.startIndex]?.top??M.paddingY??0,D=L5({...$,regions:$.regions.slice(F.startIndex,F.endIndex)},M,A,X),y=UK(D,_,U.totalHeight);return qK(A,$,y,M,X),{estimateRegionBounds:U.estimateRegionBounds,layout:y,totalHeight:U.totalHeight,viewport:J}}function qK($,M,J,Z,A){for(let[X,N]of J.regionBounds){let Y=N.bottom-N.top,Q=M.regionIndex.get(X);F9($,e9(Q??{path:X,inlines:[],text:""},Z,A),Y)}}function UK($,M,J){return{...$,blocks:$.blocks.map((Z)=>({...Z,bottom:Z.bottom+M,top:Z.top+M})),regionBounds:new Map([...$.regionBounds.entries()].map(([Z,A])=>[Z,{bottom:A.bottom+M,left:A.left,right:A.right,top:A.top+M}])),height:J,lines:$.lines.map((Z)=>({...Z,top:Z.top+M}))}}function GK($,M,J,Z,A){let X=Z,N=A;for(let Y=Z;Y<A;Y+=1){let Q=$.regions[Y],K=M.get(Q.blockId);if(!K)continue;if(K.type==="table"){let q=J.get(K.regionIds[0]??""),U=J.get(K.regionIds[K.regionIds.length-1]??"");if(q!==void 0)X=Math.min(X,q);if(U!==void 0)N=Math.max(N,U+1)}}return{endIndex:N,startIndex:X}}function BK($,M,J,Z,A,X){let N=e9(M,A,X),Y=$.measuredContainerHeights.get(N);if(Y!==void 0)return Y;let Q=A.paddingX??0,K=A.indentWidth??24,q=k0(J,A.lineHeight??24),U=Q+Z*K,G=Math.max(40,A.width-U-Q);if(M.inlines.some((_)=>_.kind==="image")){let _=B2(J);return F2($,M,_,J,G,q,X).reduce((D,y)=>D+y.height,0)}let B=j5({text:M.text,width:G});return Math.max(q,B.lineCount*q)}function FK($,M,J,Z,A,X){let N=TK(M,A,X),Y=D9($,M,N);if(Y)return Y;let Q=A.paddingY??0,K=[],q=new Map;for(let U=0;U<M.regions.length;U+=1){let G=M.regions[U],B=J.get(G.blockId)??null;if(B?.type==="table"){let y=_K({block:B,blockMap:J,containerIndices:q,entries:K,index:U,options:A,runtimeBlocks:Z,totalHeight:Q,regions:M.regions});if(y){U=y.nextIndex-1,Q=y.totalHeight;continue}}let F=BK($,G,B,Z.get(G.blockId)?.depth??0,A,X),_=Q,D=_+F;K.push({bottom:D,top:_}),q.set(G.id,U),Q=D+f5(Z,J,M.regions,U,A.blockGap??16)}return H9($,M,N,{containerIndices:q,entries:K,estimateRegionBounds(U){let G=q.get(U);return G===void 0?null:K[G]??null},totalHeight:Q})}function _K({block:$,blockMap:M,containerIndices:J,entries:Z,index:A,options:X,runtimeBlocks:N,totalHeight:Y,regions:Q}){let K=N.get($.id),q=K?.regionIds??[];if(q.length===0)return null;let U=Q.slice(A,A+q.length);if(U.length===0||U[0]?.blockId!==$.id)return null;let G=X.paddingX??0,B=X.indentWidth??24,F=K?.depth??0,_=G+F*B,D=Math.max(I8,X.width-_-G),y=Math.max(1,...$.rows.map((w)=>w.cells.length)),b=D/y,O=Math.max(40,b-T4*2),k=k0($,X.lineHeight??24),j=DK(U,A),R=Y;for(let w=0;w<$.rows.length;w+=1){let L=j.get(w)??[],V=Math.max(k+_2*2,...L.map(({region:P})=>HK(P,O,k)+_2*2)),T=R+V;for(let{index:P,region:E}of L)Z[P]={bottom:T,top:R},J.set(E.id,P);R=T}for(let w=A;w<A+U.length;w+=1){let L=Q[w];if(!L||Z[w])continue;Z[w]={bottom:R,top:R},J.set(L.id,w)}return{nextIndex:A+U.length,totalHeight:R+f5(N,M,Q,A+U.length-1,X.blockGap??16)}}function DK($,M){let J=new Map;for(let[Z,A]of $.entries()){let X=A.tableCellPosition?.rowIndex;if(X===void 0)continue;let N=J.get(X)??[];N.push({index:M+Z,region:A}),J.set(X,N)}return J}function HK($,M,J){let Z=j5({text:$.text,width:M});return Math.max(J,Z.lineCount*J)}function TK($,M,J){return[M.width,M.paddingX??0,M.paddingY??0,M.indentWidth??24,M.lineHeight??24,M.blockGap??16,PK($,J)].join(":")}function t9($,M){let J=0,Z=$.entries.length;while(J<Z){let A=J+Z>>1;if($.entries[A].bottom<=M)J=A+1;else Z=A}return J}function e9($,M,J){return`${E5($,J)}:${M.width}:${M.paddingX??0}:${M.indentWidth??24}:${M.lineHeight??24}`}function PK($,M){return $.regions.flatMap((J)=>J.inlines.filter((Z)=>Z.kind==="image"&&Z.image).map((Z)=>{let A=Z.image?M.images.get(Z.image.url):null;return`${Z.image?.url??""}:${Z.image?.width??0}:${A?.status??"loading"}:${A?.intrinsicWidth??0}:${A?.intrinsicHeight??0}`})).join("|")}var S5=null;function WK($){let M=/(\d+(?:\.\d+)?)\s*px/.exec($);return M?Number.parseFloat(M[1]):16}function H0($){S5??=new Map;let M=S5.get($);if(M)return M;let J=J7(),Z=Math.max(12,Math.round(WK($)));if(!J){let G={ascent:Math.round(Z*0.8),descent:Math.max(2,Z-Math.round(Z*0.8)),emHeight:Z};return S5.set($,G),G}J.font=$;let A=J.measureText("Hg"),X=Math.round(A.actualBoundingBoxAscent||0),N=Math.round(A.actualBoundingBoxDescent||0),Y=X+N,Q=Math.max(Z,Y),K=Y>0?X:Math.round(Q*0.8),q=Y>0?N:Math.max(2,Q-K),U={ascent:K,descent:q,emHeight:Q};return S5.set($,U),U}function zK($,M){let{emHeight:J}=H0(M);return Math.max(0,Math.floor(($-J)/2))}function $7($,M){let{ascent:J}=H0(M);return zK($,M)+J}var u5;function M7($,M){let J=J7();if(!J||$.length===0)return 0;return J.font=M,J.measureText($).width}function J7(){if(u5!==void 0)return u5;return u5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,u5}var VK=18,yK=14,bK=22;function C1($,M,J){let Z=RK($,J);if(!Z)return null;return Z7($,M,Z,J.x)}function c8($,M,J){let Z=$.lines[$.lines.length-1];if(!Z||J.y<=Z.top+Z.height)return null;return Z7($,M,Z,J.x)}function Z7($,M,J,Z){let A=$.regionMetrics.get(J.regionId);if(!A)return null;let X=Math.max(0,Z-P0(M,J)-J.left),N=n9(J.boundaries,X),Y=Math.min(A.textLength,J.start+N);return{regionId:J.regionId,offset:Y,left:r1(J,N),top:J.top,height:J.height}}function d8($,M,J,Z){let A=C1($,M,J),X=n8(M,Z.regionId);if(!X)return null;if(!A)return{regionId:Z.regionId,offset:J.y<EK($)?0:X.text.length};if(A.regionId===Z.regionId)return{regionId:A.regionId,offset:A.offset};return{regionId:Z.regionId,offset:OK(M,A,Z)?0:X.text.length}}function a8($,M,J){let Z=C1($,M,J);if(!Z)return null;let A=n8(M,Z.regionId);if(!A||A.text.length===0)return null;let X=Z.offset<A.text.length&&/\w/.test(A.text[Z.offset]??"")?Z.offset:Z.offset>0&&/\w/.test(A.text[Z.offset-1]??"")?Z.offset-1:Z.offset,N=jK(A.text,X);if(N.start===N.end)return null;return{anchor:{regionId:Z.regionId,offset:N.start},focus:{regionId:Z.regionId,offset:N.end}}}function A7($,M,J){let Z=wK($,J);if(!Z||Z.start!==0)return null;let A=D2(M,Z.blockId,"listItem");if(!A)return null;if(z4(M,A.id)?.kind!=="task")return null;let N=W4(Z),Y=N.left-4,Q=N.left+N.size+4,K=N.top-4,q=N.top+N.size+4;return J.x>=Y&&J.x<=Q&&J.y>=K&&J.y<=q?{listItemId:A.id}:null}function X7($,M,J){let Z=C1($,M,J);if(!Z)return null;let A=n8(M,Z.regionId);if(!A)return null;let X=A.inlines.find((Y)=>Y.link&&Z.offset>=Y.start&&Z.offset<Y.end);if(!X?.link)return null;let N=o8($,M,Z.regionId,X.start);if(!N)return null;return{anchorBottom:N.anchorBottom,anchorLeft:N.anchorLeft,endOffset:X.end,regionId:Z.regionId,startOffset:X.start,title:X.link.title,url:X.link.url}}function s8($,M,J,Z){let A=A7($,M,J);if(A)return{kind:"task-toggle",listItemId:A.listItemId};let X=C1($,M,J);if(!X)return null;let N=N7(X.regionId,X.offset,Z),Y=N!==null?Y7(N,$,M,Z):null,Q=X7($,M,J);if(Q)return{anchorBottom:Y?.anchorBottom??Q.anchorBottom,anchorLeft:Y?.anchorLeft??Q.anchorLeft,endOffset:Q.endOffset,kind:"link",commentThreadIndex:N,regionId:Q.regionId,startOffset:Q.startOffset,title:Q.title,url:Q.url};return{anchorBottom:Y?.anchorBottom??X.top+X.height,anchorLeft:Y?.anchorLeft??X.left,kind:"text",commentThreadIndex:N}}function i8($,M,J,Z){let A=M.documentIndex.regionIndex.get(J.regionId);if(!A)return null;let X=N7(J.regionId,J.offset,Z),N=X!==null?Y7(X,$,M,Z):null,Y=A.inlines.find((Q)=>J.offset>=Q.start&&J.offset<=Q.end)??null;if(Y?.link){let Q=o8($,M,J.regionId,Y.start);if(!Q)return null;return{anchorBottom:N?.anchorBottom??Q.anchorBottom,anchorLeft:N?.anchorLeft??Q.anchorLeft,commentThreadIndex:X,endOffset:Y.end,kind:"link",regionId:J.regionId,startOffset:Y.start,title:Y.link.title,url:Y.link.url}}if(N)return{anchorBottom:N.anchorBottom,anchorLeft:N.anchorLeft,commentThreadIndex:X,kind:"text"};return null}function c1($,M,J){let Z=t1(M,J.regionId,J.offset);if(!Z)return J.left;return J.left+P0($,Z)+CK($,Z,J.offset)}function T0($,M,J){return r1(M,J)+P0($,M)}function P0($,M){let J=D2($,M.blockId,"listItem");if(!J)return 0;return z4($,J.id)?.kind==="task"?bK:VK}function W4($){return{left:$.left,size:yK,top:$.top+3}}function D2($,M,J){let Z=$.documentIndex.blockIndex.get(M)??null;while(Z){if(Z.type===J)return Z;let A=Z.parentBlockId;Z=A?$.documentIndex.blockIndex.get(A)??null:null}return null}function z4($,M){return $.documentIndex.listItemMarkers.get(M)??null}function N7($,M,J){for(let Z of J)if(Z.regionId===$&&M>=Z.startOffset&&M<=Z.endOffset)return Z.threadIndex;return null}function Y7($,M,J,Z){let A=Z.find((X)=>X.threadIndex===$);if(!A)return null;return o8(M,J,A.regionId,A.startOffset)}function OK($,M,J){let Z=$.documentIndex.regionOrderIndex.get(M.regionId),A=$.documentIndex.regionOrderIndex.get(J.regionId);if(Z===void 0||A===void 0)return!1;if(Z!==A)return Z<A;return M.offset<J.offset}function o8($,M,J,Z){let A=t1($,J,Z);if(!A)return null;return{anchorBottom:A.top+A.height,anchorLeft:r1(A,Z)+P0(M,A)}}function CK($,M,J){if(J<=M.end)return 0;let Z=$.documentIndex.regionIndex.get(M.regionId);if(!Z)return 0;let A=Z.text.slice(M.end,J);if(!/^[ \t]+$/u.test(A))return 0;return M7(A,M.font)}function RK($,M){for(let[Z,A]of $.regionBounds)if(M.x>=A.left&&M.x<=A.right&&M.y>=A.top&&M.y<=A.bottom)return k5($,Z,M.y)?.line??null;let J=p8($,M)?.line??null;if(J)return J;for(let Z of $.blocks)if(M.y>=Z.top&&M.y<=Z.bottom){for(let A=$.lines.length-1;A>=0;A--)if($.lines[A].blockId===Z.id)return $.lines[A]}return null}function wK($,M){return $.lines.find((J)=>M.y>=J.top-4&&M.y<=J.top+J.height+4)??$.lines.filter((J)=>Math.abs(M.y-(J.top+J.height/2))<=10).sort((J,Z)=>Math.abs(M.y-(J.top+J.height/2))-Math.abs(M.y-(Z.top+Z.height/2)))[0]??null}function n8($,M){return $.documentIndex.regionIndex.get(M)??null}function EK($){return $.lines[0]?.top??0}function jK($,M){let J=M,Z=M;while(J>0&&/\w/.test($[J-1]??""))J-=1;while(Z<$.length&&/\w/.test($[Z]??""))Z+=1;return{end:Z,start:J}}var LK=48;function t8($,M,J){if(J.length===0)return[];return J.map((Z)=>({...Z,viewport:kK($,M,Z)}))}function kK($,M,J){if(!J.cursorPoint)return Q7();let Z=x1(M.layout,$,J.cursorPoint),A=Z?{bottom:Z.top+Z.height,top:Z.top}:M.estimateRegionBounds(J.cursorPoint.regionId);if(!A)return Q7();return{scrollTop:SK(M,A),status:fK(M,A)}}function fK($,M){let J=$.viewport.top,Z=J+$.viewport.height;if(M.bottom<J)return"above";if(M.top>Z)return"below";return"visible"}function SK($,M){let J=Math.max(0,$.totalHeight-$.viewport.height),Z=M.top-Math.min(LK,$.viewport.height/4);return Math.max(0,Math.min(J,Z))}function Q7(){return{scrollTop:null,status:"unresolved"}}function b5($){let M=I4($.document),J=new Map(M.map((A)=>[A.id,A])),Z=new Map($.regions.map((A)=>[A.semanticRegionId,A]));return{findBySemanticMatch(A,X){let N=J.get(A)??M[X]??null;if(!N)return null;return{runtimeContainer:Z.get(N.id)??null,semanticContainer:N}},list(A){return A?M.filter((X)=>X.containerKind===A):M},resolveRuntimeContainer(A){return Z.get(A)??null}}}function K7($){let M=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null,J=M?$.documentIndex.blockIndex.get(M.blockId)??null:null,Z=$.selection.anchor.offset,A=M?.inlines.find((X)=>Z>X.start&&Z<X.end)??M?.inlines.find((X)=>X.end===Z)??M?.inlines.find((X)=>X.start===Z)??null;return{activeBlock:J?{blockId:J.id,depth:J.depth,nodeType:J.type,text:M?.text??""}:null,activeSpan:A?.link?{kind:"link",url:A.link.url}:A&&A.marks.length>0?{kind:"marks",marks:A.marks}:{kind:"none"}}}var q7=1;function e8($,M,J){let Z=$.documentIndex.regionOrderIndex.get($.selection.focus.regionId);if(Z===void 0)return $;let A=$.documentIndex.regions[Z],X=$.selection.focus.offset+M;if(X>=0&&X<=A.text.length)return m5($,A.id,X,J);if(M<0){let Y=$.documentIndex.regions[Z-1];if(!Y)return $;return m5($,Y.id,Y.text.length,J)}let N=$.documentIndex.regions[Z+1];if(!N)return $;return m5($,N.id,0,J)}function U7($,M){return e8($,M,!0)}function G7($,M,J,Z){let A=P4(M,J.regionId,J.offset);if(!A)return $;let X=M.lines[A.index+Z];if(!X)return $;let N=C1(M,$,{x:c1($,M,J)+q7,y:X.top+X.height/2});if(!N)return $;return U1($,{regionId:N.regionId,offset:N.offset})}function $$($,M,J,Z){let A=_7($,M);if(!A)return $;return m5($,A.regionId,J==="Home"?A.start:A.end,Z)}function B7($,M,J){return $$($,M,J,!0)}function F7($,M,J,Z){let A=_7($,M);if(!A)return $;let N=Math.max(1,Math.floor(480/M.options.lineHeight)),Y=P4(M,A.regionId,$.selection.focus.offset),Q=Y?M.lines[Y.index+Z*N]:null;if(!Q)return $;let K=C1(M,$,{x:c1($,M,J)+q7,y:Q.top+Q.height/2});if(!K)return $;return U1($,{regionId:K.regionId,offset:K.offset})}function _7($,M){return t1(M,$.selection.focus.regionId,$.selection.focus.offset)}function m5($,M,J,Z){if(Z)return U1($,{anchor:$.selection.anchor,focus:{regionId:M,offset:J}});return U1($,{regionId:M,offset:J})}var uK=1;function D7($,M,J,Z){let A=$.documentIndex.regionIndex.get($.selection.focus.regionId)??null;if(!A)return null;let X=$.documentIndex.tableCellIndex.get(A.id)??null,N=$.documentIndex.blockIndex.get(A.blockId)??null;if(!X||N?.type!=="table")return null;let Y=mK($,N.id,X.rowIndex+Z,X.cellIndex)??vK($,N.id,Z);if(!Y)return $;let Q=M.regionBounds.get(A.id),K=M.regionBounds.get(Y.id);if(!Q||!K)return $;let q=K.top+gK(J.top+J.height/2-Q.top,0,Math.max(0,K.bottom-K.top-1)),U=C1(M,$,{x:c1($,M,J)+uK,y:q});if(!U)return $;return U1($,{regionId:U.regionId,offset:U.offset})}function mK($,M,J,Z){return e0($.documentIndex,M,J,Z)}function vK($,M,J){let Z=$.documentIndex.blockIndex.get(M),A=$.documentIndex.regions,X=Z?$.documentIndex.roots[Z.rootIndex]?.regionRange:void 0;if(!X)return null;return J<0?A[X.start-1]??null:A[X.end]??null}function gK($,M,J){return Math.max(M,Math.min(J,$))}function H7($,M){return e8($,M,!1)}function T7($,M){return U7($,M)}function P7($,M,J){let Z=y7($,M);if(!Z)return $;return D7($,M,Z,J)??G7($,M,Z,J)}function W7($,M,J){return $$($,M,J,!1)}function z7($,M,J){return B7($,M,J)}function V7($,M,J){let Z=y7($,M);if(!Z)return $;return F7($,M,Z,J)}function y7($,M){return x1(M,$.documentIndex,{regionId:$.selection.focus.regionId,offset:$.selection.focus.offset})}function O7($,M,J,Z,A,X,N){let Y=J.image?Z.images.get(J.image.url):null,Q=pK(J,Z,N),K=lK(M,X,N,Q);if($.fillStyle=A.imageSurfaceBackground,$.fillRect(K.left,K.top,K.width,K.height),Y?.status==="loaded"&&Y.source)$.drawImage(Y.source,K.left,K.top,K.width,K.height);else IK($,A,{...K,status:Y?.status==="error"?"error":"loading"});$.strokeStyle=A.imageSurfaceBorder,$.strokeRect(K.left,K.top,K.width,K.height)}function IK($,M,J){let Z=J.status==="loading"?"Loading image":"Image unavailable",A=xK(J),X=J.top+J.height/2+A.size*0.9;if($.save(),$.beginPath(),$.rect(J.left,J.top,J.width,J.height),$.clip(),J.status==="loading")hK($,M,J);$.strokeStyle=M.imagePlaceholderIcon,$.lineWidth=1.5,$.strokeRect(A.left,A.top,A.size,A.size),$.beginPath(),$.arc(A.left+A.size*0.28,A.top+A.size*0.3,A.size*0.1,0,Math.PI*2),$.moveTo(A.left+A.size*0.12,A.top+A.size*0.82),$.lineTo(A.left+A.size*0.42,A.top+A.size*0.5),$.lineTo(A.left+A.size*0.58,A.top+A.size*0.66),$.lineTo(A.left+A.size*0.78,A.top+A.size*0.38),$.lineTo(A.left+A.size*0.88,A.top+A.size*0.82),$.stroke(),$.font='500 12px "Iowan Old Style", "Palatino Linotype", serif',$.fillStyle=M.imagePlaceholderText,$.textAlign="center",$.textBaseline="middle",$.fillText(Z,J.left+J.width/2,X),$.restore()}function hK($,M,J){let Z=Math.max(48,Math.round(J.width*0.22)),A=J.width+Z*2,X=performance.now()%1800/1800,N=J.left-Z+A*X,Y=$.createLinearGradient(N,J.top,N+Z,J.top);Y.addColorStop(0,"rgba(255,255,255,0)"),Y.addColorStop(0.5,M.imageLoadingOverlay),Y.addColorStop(1,"rgba(255,255,255,0)"),$.fillStyle=Y,$.fillRect(J.left,J.top,J.width,J.height)}function pK($,M,J){if(!$.image)return b7(J);let Z=M.images.get($.image.url);if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return b7(J);return Math.max(48,Math.round(J*(Z.intrinsicHeight/Z.intrinsicWidth)))}function lK($,M,J,Z){return{height:Z,left:M,top:$.top+Math.max(0,Math.floor(($.height-Z)/2)),width:J}}function xK($){let M=Math.max(18,Math.min(34,Math.round(Math.min($.width,$.height)*0.18)));return{left:$.left+Math.max(12,Math.round(($.width-M)/2)),size:M,top:$.top+Math.max(12,Math.round($.height/2-M*0.95))}}function b7($){return Math.max(48,Math.round($*0.5625))}var C7=2,R7=8,rK=3,cK=1.5,dK=2,H2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function w7($,M,J,Z,A,X,N=null){if(!J||M.start!==0)return;if(N){let Y=E3(N),Q=nK(J,M,Z,A,$);$.save(),$.translate(Q.x,Q.y),$.scale(Y,Y),$.translate(-Q.x,-Q.y)}if(J.kind==="task")aK($,M,J.checked,X,N);else if($.fillStyle=N?B4(X.listMarkerText,N,X):X.listMarkerText,J.kind==="ordered")oK($,J.label,Z,A);else $.fillText(J.label,M.left-C7,A);if(N)$.restore()}function aK($,M,J,Z,A=null){let X=W4(M);if(sK($,X,J,Z,A),!J)return;iK($,X,Z,A)}function sK($,M,J,Z,A=null){let X=J?Z.checkboxCheckedFill:Z.checkboxUncheckedFill,N=J?Z.checkboxCheckedStroke:Z.checkboxUncheckedStroke;$.fillStyle=A?B4(X,A,Z):X,$.strokeStyle=A?B4(N,A,Z):N,$.beginPath(),$.lineWidth=cK,$.roundRect(M.left,M.top,M.size,M.size,rK),$.fill(),$.stroke()}function iK($,M,J,Z=null){$.strokeStyle=Z?B4(J.checkboxCheckmark,Z,J):J.checkboxCheckmark,$.lineWidth=dK,$.beginPath(),$.moveTo(M.left+H2.start.x,M.top+H2.start.y),$.lineTo(M.left+H2.elbow.x,M.top+H2.elbow.y),$.lineTo(M.left+H2.end.x,M.top+H2.end.y),$.stroke()}function oK($,M,J,Z){let A=$.textAlign;$.textAlign="right",$.fillText(M,J-R7,Z),$.textAlign=A}function nK($,M,J,Z,A){if($.kind==="task"){let Y=W4(M);return{x:Y.left+Y.size/2,y:Y.top+Y.size/2}}let X=A.measureText($.label),N=Z-(X.actualBoundingBoxAscent-X.actualBoundingBoxDescent)/2;if($.kind==="ordered")return{x:J-R7-X.width/2,y:N};return{x:M.left-C7+X.width/2,y:N}}var tK=80;function j7({context:$,containerBounds:M,isHeaderRow:J,lineHeight:Z,theme:A}){let X=k7(M,Z);$.fillStyle=J?A.tableHeaderBackground:A.tableBodyBackground,$.fillRect(X.left,X.top,X.width,X.height),f7($,X,A)}function L7({activeBlockFlashes:$,activeBlockId:M,activeRegionId:J,context:Z,editorState:A,endIndex:X,layout:N,regionBounds:Y,startIndex:Q,theme:K,verticalBleed:q}){if(!M||!J)return;let U=A.documentIndex.blockIndex.get(M)??null;if(U?.type!=="table")return;if((A.documentIndex.regionIndex.get(J)??null)?.blockId!==M)return;let B=Y.get(J)??null,F=N.regionLineIndices.get(J)??null;if(!B||!F||F.length===0)return;let _=N.lines[F[0]]??null;if(!_)return;let D=k7(B,_.height);if(D.width===0)return;let y=E7({context:Z,endIndex:X,fillStyle:K.activeBlockBackground,layout:N,left:D.left,lineIndices:F,startIndex:Q,verticalBleed:q,width:D.width}),b=U.path?$.get(U.path)??null:null;if(b)E7({context:Z,endIndex:X,fillStyle:H5(K.activeBlockFlash,b),layout:N,left:D.left,lineIndices:F,startIndex:Q,verticalBleed:q,width:D.width});if(!y)return;f7(Z,D,K)}function E7({context:$,endIndex:M,fillStyle:J,layout:Z,left:A,lineIndices:X,startIndex:N,verticalBleed:Y,width:Q}){$.fillStyle=J;let K=!1;for(let q of X){if(q<N)continue;if(q>=M)break;let U=Z.lines[q];$.fillRect(A,U.top-Y,Q,U.height),K=!0}return K}function k7($,M){return{height:Math.max($.bottom-$.top,M),left:$.left,top:$.top,width:Math.max($.right-$.left,tK)}}function f7($,M,J){$.strokeStyle=J.tableBorder,$.strokeRect(M.left,M.top,M.width,M.height)}var M$=2,eK=3,$q=12,Mq=6,Jq=3,Zq=1,Aq=2,Xq=2,Nq=8,Yq=12,Qq=28,Kq=4,qq=5,Uq=2,Gq=3,Bq=6,S7=3,Fq=12,_q=10,Dq=2,Hq=2,Tq=1,Pq=2,J$=2,u7=1.25,Wq=5,zq=1,m7=4,Vq=4,yq=1.5;function I7({activeBlockId:$,activeRegionId:M,activeThreadIndex:J,containerLineBounds:Z,context:A,devicePixelRatio:X,editorState:N,height:Y,layout:Q,liveCommentRanges:K,normalizedSelection:q,now:U=dq(),resources:G,runtimeBlockMap:B,theme:F,viewportTop:_,width:D}){A.save(),A.scale(X,X),A.clearRect(0,0,D,Y),A.fillStyle=F.background,A.fillRect(0,0,D,Y),A.textBaseline="alphabetic",A.translate(0,-_);let y=q.start.regionId===q.end.regionId&&q.start.offset!==q.end.offset?q.start.regionId:null,{endIndex:b,startIndex:O}=l8(Q,_,Y),k=W3(N,U),j=z3(N,U),R=P3(N,U),w=y3(N,U),L=V3(N,U),V=Oq(Q,N,$,O,b),T=bq(Q,N,B,O,b,D);for(let P=O;P<b;P+=1){let E=Q.lines[P];wq({containerLineBounds:Z,context:A,editorState:N,line:E,runtimeBlockMap:B,theme:F,width:D})}L7({activeBlockFlashes:k,activeBlockId:$,activeRegionId:M,context:A,editorState:N,endIndex:b,layout:Q,regionBounds:Z,startIndex:O,theme:F,verticalBleed:M$});for(let P=O;P<b;P+=1){let E=Q.lines[P];Eq({activeBlockId:$,activeBlockFlashes:k,activeDeletedTextFades:j,activeThreadIndex:J,activeInsertedTextHighlights:R,activeListMarkerPops:w,activePunctuationPulses:L,context:A,editorState:N,line:E,liveCommentRanges:K,normalizedSelection:q,resources:G,runtimeBlockMap:B,selectedContainerId:y,theme:F,width:D})}Cq(A,T,F),Rq(A,V,F),A.restore()}function bq($,M,J,Z,A,X){let N=new Map;for(let Y=Z;Y<A;Y+=1){let Q=$.lines[Y],K=J.get(Q.blockId);if(K?.type!=="heading"||K.depth!==1&&K.depth!==2)continue;let q=N.get(K.id),U={bottom:Q.top+Q.height,left:Q.left+P0(M,Q),right:X-$.options.paddingX};N.set(K.id,q?{bottom:Math.max(q.bottom,U.bottom),left:q.left,right:q.right}:U)}return N}function Oq($,M,J,Z,A){let X=new Map;for(let N=Z;N<A;N+=1){let Y=$.lines[N],Q=D2(M,Y.blockId,"blockquote");if(!Q)continue;let K=X.get(Q.id),q={bottom:Y.top+Y.height,isActive:Y.blockId===J,left:$.options.paddingX+(Q.depth+1)*$.options.indentWidth-10,top:Y.top};X.set(Q.id,K?{bottom:Math.max(K.bottom,q.bottom),isActive:K.isActive||q.isActive,left:K.left,top:Math.min(K.top,q.top)}:q)}return X}function Cq($,M,J){$.fillStyle=J.headingRule;for(let Z of M.values())$.fillRect(Z.left,Z.bottom+Wq,Math.max(J$,Z.right-Z.left),zq)}function Rq($,M,J){for(let Z of M.values())$.fillStyle=Z.isActive?J.blockquoteRuleActive:J.blockquoteRule,$.fillRect(Z.left,Z.top+eK,Jq,Math.max($q,Z.bottom-Z.top-Mq))}function h7({context:$,devicePixelRatio:M,editorState:J,height:Z,layout:A,normalizedSelection:X,presence:N,showCaret:Y,theme:Q,viewportTop:K,width:q}){$.save(),$.scale(M,M),$.clearRect(0,0,q,Z);let U=X.start.regionId===X.end.regionId&&X.start.offset!==X.end.offset,G=Y&&!U;if($.translate(0,-K),G)v7($,J,A,{color:Q.caret,offset:J.selection.focus.offset,regionId:J.selection.focus.regionId});if(N)for(let B of N){if(!B.cursorPoint)continue;v7($,J,A,{color:B.color??Q.leafAccent,offset:B.cursorPoint.offset,regionId:B.cursorPoint.regionId})}$.restore()}function v7($,M,J,Z){let A=x1(J,M.documentIndex,{regionId:Z.regionId,offset:Z.offset});if(!A)return;let X=c1(M,J,A),N=vq(J,A);$.fillStyle=Z.color,$.fillRect(X,N.top,Aq,N.height)}function wq({containerLineBounds:$,context:M,editorState:J,line:Z,runtimeBlockMap:A,theme:X,width:N}){let Y=A.get(Z.blockId)??null,Q=$.get(Z.regionId)??null,K=J.documentIndex.tableCellIndex.get(Z.regionId)??null;jq(M,Z,Y,Q,K,X,N)}function Eq({activeBlockId:$,activeBlockFlashes:M,activeDeletedTextFades:J,activeThreadIndex:Z,activeInsertedTextHighlights:A,activeListMarkerPops:X,activePunctuationPulses:N,context:Y,editorState:Q,line:K,liveCommentRanges:q,normalizedSelection:U,resources:G,runtimeBlockMap:B,selectedContainerId:F,theme:_,width:D}){let y=B.get(K.blockId)??null,b=Q.documentIndex.blockIndex.get(K.blockId)?.path??null,O=Q.documentIndex.regionIndex.get(K.regionId)??null,k=O?.path??"",j=D2(Q,K.blockId,"listItem"),R=j?z4(Q,j.id):null,w=j?X.get(j.path)??null:null,L=K.left+P0(Q,K),V=hq(K),T=y?.type==="code"?_.codeText:xq(y,_);Y.font=K.font,Lq(Y,K,y,b,$,M,_,D),kq(Y,Q,K,U,F,_),fq(Y,Q,K,q,Z,_),w7(Y,K,R,L,V,_,w),Sq(Y,K,O,L,V,A.get(k)??[],T,G,_),uq(Y,K,O,L,V,J.get(k)??[],T),mq(Y,K,O,L,V,N.get(k)??[],_)}function jq($,M,J,Z,A,X,N){if(!Z||M.start!==0)return;if(J?.type==="code"){let Y=Math.max(0,M.left-Yq);$.fillStyle=X.codeBackground,$.fillRect(Y,Z.top-Kq,Math.max(Z.right-M.left+Qq,N-Y),Z.bottom-Z.top+Nq);return}if(J?.type!=="table")return;j7({context:$,containerBounds:Z,isHeaderRow:A?.rowIndex===0,lineHeight:M.height,theme:X})}function Lq($,M,J,Z,A,X,N,Y){if(M.blockId!==A||J?.type==="table")return;let Q=Z?X.get(Z)??null:null;if($.fillStyle=N.activeBlockBackground,$.fillRect(0,M.top-M$,Y,M.height),!Q)return;$.fillStyle=H5(N.activeBlockFlash,Q),$.fillRect(0,M.top-M$,Y,M.height)}function kq($,M,J,Z,A,X){if(!A||J.regionId!==A)return;let N=Math.max(J.start,Z.start.offset),Y=Math.min(J.end,Z.end.offset);if(Y<=N)return;$.fillStyle=X.selectionBackground,$.fillRect(T0(M,J,N-J.start),J.top+Tq,Math.max(Hq,T0(M,J,Y-J.start)-T0(M,J,N-J.start)),J.height-Pq)}function fq($,M,J,Z,A,X){for(let N of Z){if(N.regionId!==J.regionId)continue;let Y=Math.max(N.startOffset,J.start),Q=Math.min(N.endOffset,J.end);if(Q<=Y)continue;$.fillStyle=cq(N,A,X),$.fillRect(T0(M,J,Y-J.start),J.top+J.height-qq,Math.max(Uq,T0(M,J,Q-J.start)-T0(M,J,Y-J.start)),Gq)}}function Sq($,M,J,Z,A,X,N,Y,Q){if(!J){$.fillStyle=N,$.fillText(M.text,Z,A);return}let K=J.inlines.filter((q)=>q.end>M.start&&q.start<M.end);if(K.length===0){$.fillStyle=N,$.fillText(M.text,Z,A);return}for(let q of K){let U=Math.max(M.start,q.start),G=Math.min(M.end,q.end);if(J.text.slice(U,G).length===0)continue;let{left:F,right:_}=A$(M,Z,U,G),D=rq(M.font,q.marks);if($.font=D,q.kind==="image"){let y=Math.max(24,_-F);O7($,M,q,Y,Q,F,y);continue}if(q.kind==="inlineCode"){let y=pq(M,D),b=lq(M,D);$.fillStyle=Q.inlineCodeBackground,$.fillRect(F-S7,y,Math.max(_q,_-F+S7*2),b),g7($,M,J.text,Z,A,U,G,Q.inlineCodeText,X,Q,{strikethrough:!1,underline:!1});continue}g7($,M,J.text,Z,A,U,G,q.link?Q.linkText:N,X,Q,{strikethrough:q.marks.includes("strikethrough"),underline:q.marks.includes("underline")||Boolean(q.link)})}}function g7($,M,J,Z,A,X,N,Y,Q,K,q){let U=b3(X,N,Q);for(let G=0;G<U.length-1;G+=1){let B=U[G],F=U[G+1];if(F<=B)continue;let _=J.slice(B,F);if(_.length===0)continue;let{left:D,right:y}=A$(M,Z,B,F),b=O3(Q,B,F),O=C3(Y,b,K);if($.fillStyle=O,$.fillText(_,D,A),q.strikethrough)$.fillRect(D,Iq(A,M.height,$.font),Math.max(J$,y-D),u7);if(q.underline)$.fillRect(D,gq(A,M.height,$.font),Math.max(J$,y-D),u7)}}function uq($,M,J,Z,A,X,N){if(!J||X.length===0)return;for(let Y of X){if(Y.startOffset<M.start||Y.startOffset>M.end)continue;let Q=Z+(r1(M,Y.startOffset-M.start)-M.left);$.fillStyle=R3(N,Y),$.fillText(Y.text,Q,A)}}function mq($,M,J,Z,A,X,N){if(!J||X.length===0)return;for(let Y of X){if(Y.offset<M.start||Y.offset>=M.end)continue;let{left:Q,right:K}=A$(M,Z,Y.offset,Y.offset+1),q=Math.max(m7,(K-Q)/2+m7+Vq*Y.progress),{ascent:U,descent:G}=H0(M.font),B=A-Math.max(1,U*0.42)+Math.max(0.5,G*0.15);$.strokeStyle=w3(Y,N),$.lineWidth=yq,$.beginPath(),$.arc((Q+K)/2,B,q,0,Math.PI*2),$.stroke()}}function vq($,M){let J=t1($,M.regionId,M.offset),Z=J?.font??'16px "Iowan Old Style", "Palatino Linotype", serif',{ascent:A,descent:X}=H0(Z),N=Math.max(1,A+X),Y=Math.min(M.height-Xq,N),Q=J?Math.max(J.top,J.top+Z$(J.height,Z)-Zq):M.top+Math.max(0,Math.floor((M.height-Y)/2));return{height:Y,top:Q}}function gq($,M,J){let{descent:Z}=H0(J),A=Math.max(1,Math.round(Math.max(2,Z)*0.35)),X=$+Z-A,N=$-v5(M,J);return Math.min(N+M-4,X)}function Iq($,M,J){let{ascent:Z}=H0(J),A=$-v5(M,J);return Math.max(A+2,$-Math.round(Z*0.32))}function hq($){return $.top+v5($.height,$.font)}function v5($,M){return $7($,M)}function pq($,M){let J=Z$($.height,M);return $.top+J+Dq}function lq($,M){let J=Z$($.height,M);return Math.max(Fq,$.height-J-Bq)}function Z$($,M){let{ascent:J}=H0(M);return v5($,M)-J}function xq($,M){switch($?.type){case"heading":return M.headingText;case"blockquote":return M.blockquoteText;case"table":return M.headingText;default:return M.paragraphText}}function A$($,M,J,Z){return{left:M+(r1($,J-$.start)-$.left),right:M+(r1($,Z-$.start)-$.left)}}function rq($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function cq($,M,J){if($.resolved)return $.threadIndex===M?J.commentHighlightResolvedActive:J.commentHighlightResolved;return $.threadIndex===M?J.commentHighlightActive:J.commentHighlight}function dq(){return typeof performance<"u"?performance.now():Date.now()}function X$(){return aq(Q2())}function aq($){return{getDocument(J){return P8(J)},createState(J){return T8(J)},getCommentState(J){return U0(J.documentIndex)},getPreviewState(J){return K7(J)},resolvePresenceCursors:O8,resolvePresenceViewport(J,Z,A){return t8(J.documentIndex,Z,A)},getSelectionMarks(J){let Z=X1(J.documentIndex,J.selection);if(Z.start.regionId!==Z.end.regionId||Z.start.offset===Z.end.offset)return[];let A=J.documentIndex.regionIndex.get(Z.start.regionId);if(!A)return[];let X=r0(J.documentIndex.document.blocks,A.blockId);if(!X)return[];let N=Y4(X,A.path,A.semanticRegionId);return N?A5(N,Z.start.offset,Z.end.offset):[]},hasRunningAnimations(J,Z){return T3(J,Z)},normalizeSelection(J){return X1(J.documentIndex,J.selection)},createCommentThread(J,Z,A){let X=b8(J.documentIndex,Z,A);if(!X)return null;return e1(J,z5(J,J.documentIndex.document.comments.length,0,[X]),!0)},replyToCommentThread(J,Z,A){return V4(J,Z,(X)=>A6(X,{body:A.trim()}))},editComment(J,Z,A,X){return V4(J,Z,(N)=>X6(N,A,X))},deleteComment(J,Z,A){return V4(J,Z,(X)=>N6(X,A))},deleteCommentThread(J,Z){return V4(J,Z,()=>null)},markCommentThreadAsResolved(J,Z,A){return V4(J,Z,(X)=>Y6(X,A))},insertText:M1(u3),insertLineBreak:M1(m3),deleteBackward:M1(v3),deleteForward:M1(g3),deleteSelection:p7(V5),replaceSelection:p7(I3),toggleBold:M1(n3),toggleItalic:M1(t3),toggleStrikethrough:M1(e3),toggleUnderline:M1($9),toggleInlineCode:M1(o3),indent:M1(h3),dedent:M1(p3),moveListItemUp:M1(l3),moveListItemDown:M1(x3),toggleTaskItem:M1(Z9),undo:M1(A9),redo:M1(X9),insertTable:M1(r3),insertTableColumn:M1(c3),deleteTableColumn:M1(d3),insertTableRow:M1(a3),deleteTableRow:M1(s3),deleteTable:M1(i3),updateLink:M1(M9),removeLink:M1(J9),setSelection(J,Z){return e1(J,U1(J,Z),!1)},moveCaretHorizontally(J,Z,A=!1){return e1(J,A?T7(J,Z):H7(J,Z),!1)},moveCaretVertically(J,Z,A){return e1(J,P7(J,Z,A),!1)},moveCaretByViewport(J,Z,A){return e1(J,V7(J,Z,A),!1)},moveCaretToLineBoundary(J,Z,A,X=!1){return e1(J,X?z7(J,Z,A):W7(J,Z,A),!1)},prepareViewport(J,Z,A=l1){let X={height:Z.height,overscan:Math.max(160,Z.height),top:Z.top},N=r8(J.documentIndex,Z,X,[J.selection.anchor.regionId,J.selection.focus.regionId],$,A);return{blockMap:sq(J.documentIndex.document.blocks),estimateRegionBounds:N.estimateRegionBounds,regionBounds:iq(N.layout),layout:N.layout,paintHeight:Math.max(240,X.height+X.overscan*2),paintTop:Math.max(0,X.top-X.overscan),totalHeight:N.totalHeight,viewport:{height:X.height,top:X.top}}},resolveSelectionHit(J,Z,A){return C1(Z.layout,J,A)??c8(Z.layout,J,A)},resolveDragFocus(J,Z,A,X){return d8(Z.layout,J,A,X)},resolveWordSelection(J,Z,A){return a8(Z.layout,J,A)},resolveHoverTarget(J,Z,A,X){return s8(Z.layout,J,A,X)},resolveTargetAtSelection(J,Z,A,X){return i8(Z.layout,J,A,X)},measureCaretTarget(J,Z,A){return x1(Z.layout,J.documentIndex,A)},measureVisualCaretTarget(J,Z,A){let X=x1(Z.layout,J.documentIndex,A);if(!X)return null;return{...X,left:c1(J,Z.layout,X)}},paintContent(J,Z,A,X){I7({activeBlockId:X.activeBlockId,activeRegionId:X.activeRegionId,activeThreadIndex:X.activeThreadIndex,containerLineBounds:Z.regionBounds,context:A,devicePixelRatio:X.devicePixelRatio,editorState:J,height:X.height,layout:Z.layout,liveCommentRanges:X.liveCommentRanges,normalizedSelection:X.normalizedSelection,now:X.now,resources:X.resources??l1,runtimeBlockMap:Z.blockMap,theme:X.theme,viewportTop:Z.paintTop,width:X.width})},paintOverlay(J,Z,A,X){h7({context:A,devicePixelRatio:X.devicePixelRatio,editorState:J,height:X.height,layout:Z.layout,normalizedSelection:X.normalizedSelection,presence:X.presence,showCaret:X.showCaret,theme:X.theme,viewportTop:Z.paintTop,width:X.width})}}}function sq($){let M=new Map,J=(Z)=>{for(let A of Z)if(M.set(A.id,A),A.type==="blockquote"||A.type==="listItem")J(A.children);else if(A.type==="list")J(A.items)};return J($),M}function iq($){return new Map($.regionBounds)}function oq($,M,J=!1){return{animationStarted:J,documentChanged:M,state:$}}function e1($,M,J){return oq(M,J,tq($,M))}function nq($,M,J){if(!M)return null;return e1($,M,J)}function tq($,M){let J=Math.max(-1/0,...$.animations.map((Z)=>Z.startedAt));return M.animations.some((Z)=>Z.startedAt>J)}function V4($,M,J){let A=U0($.documentIndex).threads[M];if(!A)return null;let X=J(A);if(X===A)return null;return e1($,z5($,M,1,X?[X]:[]),!0)}function p7($){return(M,...J)=>e1(M,$(M,...J),!0)}function M1($){return(M,...J)=>nq(M,$(M,...J),!0)}function x7($){let M=N$(()=>MU($),[$]),J=N$(()=>M.join(`
|
|
29
|
+
`),[M]),[Z,A]=$U(new Map),X=l7(Z),N=l7(new Map);return X.current=Z,eq(()=>{if(typeof Image>"u")return;let Y=!0,Q=new Set(M),K=N.current;A((q)=>ZU(q,Q,K));for(let q of M){if(JU(X.current,K,q))continue;AU(q,K,A,()=>Y)}return()=>{Y=!1}},[J]),N$(()=>Z.size===0?l1:{images:Z},[Z])}function MU($){return[...l$($)].sort()}function JU($,M,J){return $.get(J)?.status==="loaded"||M.has(J)}function ZU($,M,J){let Z=!1,A=new Map($);for(let X of A.keys())if(!M.has(X))A.delete(X),J.delete(X),Z=!0;return Z?A:$}function AU($,M,J,Z){let A=new Image;A.decoding="async",A.crossOrigin="anonymous",M.set($,A),J((X)=>{let N=new Map(X);return N.set($,XU()),N}),A.onload=()=>{if(M.delete($),!Z())return;J((X)=>{let N=new Map(X);return N.set($,NU(A)),N})},A.onerror=()=>{if(M.delete($),!Z())return;J((X)=>{let N=new Map(X);return N.set($,YU()),N})},A.src=$}function XU(){return{intrinsicHeight:0,intrinsicWidth:0,source:null,status:"loading"}}function NU($){return{intrinsicHeight:$.naturalHeight,intrinsicWidth:$.naturalWidth,source:$,status:"loaded"}}function YU(){return{intrinsicHeight:0,intrinsicWidth:0,source:null,status:"error"}}import{useRef as QU}from"react";function r7(){let $=QU(null);if(!$.current)$.current=X$();return $.current}import{useEffect as c7,useEffectEvent as u1,useRef as d7,useState as KU}from"react";var qU=48;function a7({commentState:$,editor:M,editorStateRef:J,editorViewportState:Z,resolveDocumentPoint:A}){let[X,N]=KU(null),Y=d7(null),Q=d7(!1),K=t4(X,$.threads),q=X?.kind==="task-toggle"||K?.kind==="link"?"pointer":"text";c7(()=>{if(X&&X.kind!=="task-toggle"&&!K)N(null)},[X,K]);let U=u1(()=>{if(Y.current!==null)window.clearTimeout(Y.current),Y.current=null}),G=u1(()=>{U(),Y.current=window.setTimeout(()=>{if(Y.current=null,!Q.current)N(null)},qU)}),B=u1(()=>{U(),N(null)}),F=u1(()=>{if(!Q.current)B()});c7(()=>()=>{if(Y.current!==null)window.clearTimeout(Y.current)},[]);let _=u1((R)=>{let w=J.current;if(!w)return null;let L=A(R);if(!L)return null;return M.resolveHoverTarget(w,Z.get(),L,$.liveRanges)}),D=u1((R)=>{if(!R){F();return}if(R.kind==="task-toggle"){U(),N((w)=>w?.kind==="task-toggle"&&w.listItemId===R.listItemId?w:R);return}if(R.commentThreadIndex!==null){if(!($.threads[R.commentThreadIndex]??null)){F();return}U();let L=R.commentThreadIndex;N((V)=>V?.kind!=="task-toggle"&&V?.commentThreadIndex===L?V:R);return}if(R.kind!=="link"){F();return}U(),N((w)=>w?.kind==="link"&&w.title===R.title&&w.url===R.url&&w.startOffset===R.startOffset&&w.endOffset===R.endOffset?w:R)}),y=u1((R)=>{D(_(R))}),b=u1(()=>{if(!Q.current)G()}),O=u1(()=>{Q.current=!0,U()}),k=u1(()=>{Q.current=!1,G()});return{canvasHandlers:{onClick:u1((R)=>{let w=_(R);if(!w||w.kind!=="link"||!R.metaKey&&!R.ctrlKey)return!1;return R.preventDefault(),R.stopPropagation(),R.currentTarget.ownerDocument.defaultView?.open(w.url,"_blank","noopener,noreferrer"),!0}),onPointerLeave:b,onPointerMove:y},cursor:q,leaf:K,leafHandlers:{onPointerEnter:O,onPointerLeave:k},resolveTarget:_}}import{useEffect as U$,useEffectEvent as F1,useLayoutEffect as GU,useRef as e7,useState as BU}from"react";var Y$=[{key:"Backspace",command:"deleteBackward"},{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",altKey:!0,shiftKey:!0,command:"moveListItemUp"},{key:"ArrowDown",altKey:!0,shiftKey:!0,command:"moveListItemDown"},{key:"b",modKey:!0,command:"toggleBold"},{key:"e",modKey:!0,command:"toggleInlineCode"},{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 s7($,M=Y$){return M.find((J)=>{let Z=J.shiftKey==="any"?!0:(J.shiftKey??!1)===($.shiftKey??!1);return J.key.toLowerCase()===$.key.toLowerCase()&&(J.altKey??!1)===($.altKey??!1)&&Z&&(J.modKey??!1)===Boolean($.metaKey||$.ctrlKey)})?.command??null}function t7($){let M=$.documentIndex.regions.find((X)=>X.id===$.selection.anchor.regionId),J=$.documentIndex.regions.find((X)=>X.id===$.selection.focus.regionId),Z=(M?.start??0)+$.selection.anchor.offset,A=(J?.start??0)+$.selection.focus.offset;return{end:Math.max(Z,A),start:Math.min(Z,A)}}function Q$($){let M=K$($);if(!M)return"";let J=$.documentIndex.regions.find((Z)=>Z.id===M.regionId);if(!J)return"";return J.text.slice(M.startOffset,M.endOffset)}function K$($){let M=UU($);if(M.start.regionId!==M.end.regionId||M.start.offset===M.end.offset)return null;return{endOffset:M.end.offset,regionId:M.start.regionId,startOffset:M.start.offset}}var i7=28,o7=18;function q$($,M){if(!$)return;let J=$.getBoundingClientRect();if(M.clientY<J.top+i7){$.scrollTop=Math.max(0,$.scrollTop-o7);return}if(M.clientY>J.bottom-i7)$.scrollTop+=o7}function UU($){let M=n7($.documentIndex.regions,$.selection.anchor.regionId,$.selection.anchor.offset),J=n7($.documentIndex.regions,$.selection.focus.regionId,$.selection.focus.offset);return M<=J?{end:$.selection.focus,start:$.selection.anchor}:{end:$.selection.anchor,start:$.selection.focus}}function n7($,M,J){let Z=$.findIndex((A)=>A.id===M);if(Z===-1)return-1;return Z*1e6+J}var FU=64;function MJ({editor:$,editorState:M,editorStateRef:J,editorViewportState:Z,inputRef:A,keybindings:X,onActivity:N,onEditorStateChange:Y}){let Q=_U(),K=()=>J.current??M,q=e7(!1),U=e7(!1),G=F1((W)=>{if(!W)return;N(),Y(W)}),B=F1(()=>{let W=A.current;if(!W)return;if(typeof document>"u")return;let z=document.execCommand;if(typeof z!=="function")return;try{q.current=!0,z.call(document,"insertText",!1,""),z.call(document,"delete")}catch{}finally{q.current=!1,y4(W,K())}}),F=F1(()=>{if(U.current)return;U.current=!0,B()}),_=F1(()=>{B()}),D=F1((W)=>{if(!Q)return;let z=A.current;if(!z)return;let u=Z.get(),p=$.measureVisualCaretTarget(K(),u,W);if(!p)return;z.style.top=`${p.top}px`,z.style.left=`${p.left}px`,z.style.height=`${p.height}px`}),y=F1((W)=>{let z=A.current;if(!z)return;D(W??K().selection.focus),z.focus({preventScroll:!Q}),y4(z,K()),F()}),b=F1((W,z)=>{let p=$J(z,G$(W)).replace(/\r\n/g,`
|
|
30
|
+
`).split(/(\n)/),I=W,e=!1,f=!1;for(let m of p){if(m.length===0)continue;let v=m===`
|
|
31
|
+
`?$.insertLineBreak(I):$.insertText(I,m);if(!v)continue;I=v.state,e||=v.animationStarted,f||=v.documentChanged}return I===W?null:{animationStarted:e,documentChanged:f,state:I}}),O=F1((W,z,u)=>{let p=W.selection.focus,I={regionId:p.regionId,offset:Math.max(0,p.offset-z)},e=$.setSelection(W,{anchor:I,focus:p}).state;return $.replaceSelection(e,u)}),k=F1((W)=>{if(q.current)return;let z=K(),u=HU(W.inputType);if(W.inputType==="insertText"){if(!W.data)return;W.preventDefault(),G(b(z,W.data));return}if(W.inputType==="insertReplacementText"){if(!W.data)return;W.preventDefault();let p=W.target,I=p?.selectionStart??0,e=p?.selectionEnd??I,f=Math.max(0,e-I);G(O(z,f,W.data));return}if(DU(W.inputType)){W.preventDefault(),G($.insertLineBreak(z));return}if(u==="backward"){W.preventDefault(),G($.deleteBackward(z));return}if(u==="forward"){W.preventDefault(),G($.deleteForward(z));return}if(W.inputType==="historyUndo"){W.preventDefault(),G($.undo(z)),_();return}if(W.inputType==="historyRedo"){W.preventDefault(),G($.redo(z)),_();return}}),j=F1((W)=>{if(q.current)return;let z=K(),u=W.currentTarget.value;if($J(u,G$(z)).length===0){y4(W.currentTarget,z);return}G(b(z,u))}),R=F1((W)=>{let z=PU($,K(),Z.get(),W.nativeEvent,X);if(!z)return;W.preventDefault(),G(z)}),w=F1((W)=>{let z=Q$(K());if(!z)return;W.preventDefault(),W.clipboardData.setData("text/plain",z)}),L=F1((W)=>{let z=K(),u=Q$(z);if(!u)return;W.preventDefault(),W.clipboardData.setData("text/plain",u),G($.deleteSelection(z))}),V=F1((W)=>{let z=W.clipboardData.getData("text/plain");if(z.length===0)return;W.preventDefault(),G($.replaceSelection(K(),z))}),T=F1(()=>{N();let W=A.current;if(W)y4(W,K())}),P=F1(()=>{N(),y()});U$(()=>{let W=A.current;if(!W)return;y4(W,M)},[M,A]),GU(()=>{D(M.selection.focus)},[M,D]),U$(()=>{let W=A.current;if(!W)return;let z=(u)=>k(u);return W.addEventListener("beforeinput",z),()=>W.removeEventListener("beforeinput",z)},[A,k]);let E={onCopy:w,onCut:L,onPaste:V,...Q?{}:{onKeyDown:R}};return{canvasHandlers:{...E,onFocus:P},focus:y,inputHandlers:{...E,onFocus:T,onInput:j}}}var JJ="";function _U(){let[$,M]=BU(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return U$(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let J=window.matchMedia("(pointer: coarse)"),Z=(A)=>M(A.matches);return J.addEventListener?.("change",Z),()=>J.removeEventListener?.("change",Z)},[]),$}function DU($){return $==="insertLineBreak"||$==="insertParagraph"}function HU($){switch($){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 TU($){return $.replaceAll(JJ,"")}function G$($,M=FU){let{anchor:J,focus:Z}=$.selection;if(J.regionId!==Z.regionId||J.offset!==Z.offset)return"";let A=$.documentIndex.regionIndex.get(Z.regionId);if(!A)return"";return A.text.slice(Math.max(0,Z.offset-M),Z.offset)}function $J($,M){let J=TU($);return J.startsWith(M)?J.slice(M.length):J}function y4($,M){let J=G$(M),Z=`${JJ}${J}`;$.value=Z,$.setSelectionRange(Z.length,Z.length)}function PU($,M,J,Z,A){if(Z.key==="Delete")return $.deleteForward(M);let X=s7(Z,A);if(X){if(X==="moveToLineStart"||X==="moveToLineEnd")return $.moveCaretToLineBoundary(M,J.layout,X==="moveToLineStart"?"Home":"End",Z.shiftKey);switch(X){case"insertLineBreak":return $.insertLineBreak(M);case"deleteBackward":return $.deleteBackward(M);case"indent":return $.indent(M);case"dedent":return $.dedent(M);case"moveListItemUp":return $.moveListItemUp(M);case"moveListItemDown":return $.moveListItemDown(M);case"toggleBold":return $.toggleBold(M);case"toggleItalic":return $.toggleItalic(M);case"toggleStrikethrough":return $.toggleStrikethrough(M);case"toggleUnderline":return $.toggleUnderline(M);case"toggleInlineCode":return $.toggleInlineCode(M);case"undo":return $.undo(M);case"redo":return $.redo(M)}}if(Z.key==="ArrowLeft"||Z.key==="ArrowRight")return $.moveCaretHorizontally(M,Z.key==="ArrowLeft"?-1:1,Z.shiftKey);if(Z.key==="ArrowUp"||Z.key==="ArrowDown")return $.moveCaretVertically(M,J.layout,Z.key==="ArrowUp"?-1:1);if(Z.key==="PageUp"||Z.key==="PageDown")return $.moveCaretByViewport(M,J.layout,Z.key==="PageUp"?-1:1);if(Z.key.length===1&&!Z.altKey&&!Z.ctrlKey&&!Z.metaKey)return $.insertText(M,Z.key);return null}import{useEffect as WU,useEffectEvent as B$,useLayoutEffect as zU,useMemo as VU,useRef as ZJ,useState as yU}from"react";var bU=[];function AJ({editor:$,editorState:M,editorStateRef:J,editorViewportState:Z,onViewportScroll:A,presence:X,scrollContainerRef:N,scheduleOverlayRender:Y}){let Q=VU(()=>{if(!X||X.length===0)return bU;return $.resolvePresenceCursors(M.documentIndex,X)},[$,M.documentIndex,X]),[K,q]=yU([]),U=ZJ(Q),G=ZJ(K);U.current=Q,G.current=K;let B=B$((D)=>{if(OU(G.current,D))return;G.current=D,q(D)}),F=B$((D)=>{let y=U.current;if(y.length===0){B([]);return}B($.resolvePresenceViewport(J.current??M,D,y))});WU(()=>{Y()},[Q,Y]),zU(()=>{if(Q.length===0){B([]);return}F(Z.get())},[Z,F,Q,B]);let _=B$((D)=>{if(!D.viewport||D.viewport.scrollTop===null)return;let y=N.current;if(!y)return;y.scrollTop=D.viewport.scrollTop,A(y)});return{canvasPresence:Q.length===0?void 0:Q,presenceOverlayProps:{onSelect:_,presence:K},refreshViewportPresence:F}}function OU($,M){if($.length!==M.length)return!1;return $.every((J,Z)=>{let A=M[Z];return A!==void 0&&J.color===A.color&&J.imageUrl===A.imageUrl&&J.name===A.name&&J.viewport?.scrollTop===A.viewport?.scrollTop&&J.viewport?.status===A.viewport?.status})}import{useEffect as CU,useEffectEvent as g5,useRef as I5}from"react";function XJ({hasRunningAnimations:$,renderContent:M,renderOverlay:J,renderViewport:Z}){let A=I5(null),X=I5(!1),N=I5(!1),Y=I5(!1),Q=g5(()=>{if(typeof window>"u"||A.current!==null)return;A.current=window.requestAnimationFrame(()=>{q()})}),K=g5(()=>{if(!$?.())return;N.current=!0,Q()}),q=g5(()=>{A.current=null;let G=X.current,B=N.current,F=Y.current;if(X.current=!1,N.current=!1,Y.current=!1,G){Z(),K();return}if(B){if(M(),F)J();K();return}if(F)J()}),U=g5((G)=>{if(typeof window>"u")switch(G){case"viewport":Z();return;case"content":M();return;case"overlay":J();return}switch(G){case"viewport":X.current=!0;break;case"content":N.current=!0;break;case"overlay":Y.current=!0;break}Q()});return CU(()=>{return()=>{if(typeof window>"u"||A.current===null)return;window.cancelAnimationFrame(A.current),A.current=null}},[]),{scheduleRender:U}}import{useEffectEvent as F$,useLayoutEffect as NJ,useMemo as _$,useRef as D$,useState as YJ}from"react";function h5($,M){let J=M.getBoundingClientRect();return{x:$.clientX-J.left+M.scrollLeft,y:$.clientY-J.top+M.scrollTop}}function QJ({autoScrollContainer:$,canShowSelectionLeaf:M,canvasRef:J,threads:Z,editor:A,editorState:X,editorStateRef:N,scrollContainerRef:Y,editorViewportState:Q,onActivity:K,onEditorStateChange:q}){let U=_$(()=>A.normalizeSelection(X),[A,X]),G=_$(()=>K$(X),[X]),B=_$(()=>A.getSelectionMarks(X),[A,X]),[F,_]=YJ(null),[D,y]=YJ(null),b=D$(null),O=D$(null),k=D$(null);NJ(()=>{let V=RU(A,X,Q.get(),U);_((T)=>kU(T,V)?T:V)},[A,X,Q,U.end.offset,U.end.regionId,U.start.offset,U.start.regionId]),NJ(()=>{let V=EU({canShowSelectionLeaf:M,currentLeaf:D,activeMarks:B,handles:F,selectionRange:G,threads:Z});y((T)=>LU(T,V)?T:V)},[B,M,F,D,G,Z]);let j=F$((V,T=!0)=>{y((P)=>P?.kind==="create"?{animateInitialComment:T,kind:"thread",left:P.left,threadIndex:V,top:P.top}:P)}),R=F$((V)=>{if(V&&k.current===V.pointerId&&V.currentTarget.hasPointerCapture(V.pointerId))V.currentTarget.releasePointerCapture(V.pointerId);b.current=null,O.current=null,k.current=null}),w=F$((V)=>{let T=Y.current,P=N.current,E=O.current;if(!T||!P||!E||k.current!==V.pointerId)return;let W=h5(V,T),z=A.resolveDragFocus(P,Q.get(),W,E);if(!z)return;V.preventDefault(),V.stopPropagation(),K(),$(V),q(A.setSelection(P,{anchor:E,focus:z}))}),L=(V)=>({onPointerCancel:(T)=>{R(T)},onPointerDown:(T)=>{let P=N.current??X,E=SU(U,V),W=V==="start"?U.start:U.end;if(!F)return;T.preventDefault(),T.stopPropagation(),k.current=T.pointerId,O.current=E,b.current=V,T.currentTarget.setPointerCapture(T.pointerId),K(),J.current?.focus({preventScroll:!0}),q(A.setSelection(P,{anchor:E,focus:W}))},onPointerMove:(T)=>{if(b.current!==V)return;w(T)},onPointerUp:(T)=>{if(b.current===V)w(T);R(T)}});return{endHandleProps:L("end"),handles:F,leaf:D,promoteLeafToThread:j,startHandleProps:L("start")}}function RU($,M,J,Z){if(Z.start.regionId!==Z.end.regionId||Z.start.offset===Z.end.offset)return null;let A=$.measureVisualCaretTarget(M,J,Z.start),X=$.measureVisualCaretTarget(M,J,Z.end);if(!A||!X)return null;return{end:{left:X.left,top:X.top+X.height},start:{left:A.left,top:A.top}}}function wU($,M,J){return{activeMarks:J,kind:"create",left:M.start.left,selection:$,top:M.end.top}}function EU({activeMarks:$,canShowSelectionLeaf:M,currentLeaf:J,handles:Z,selectionRange:A,threads:X}){if(!M||!A||!Z)return null;if(J?.kind==="thread")return X[J.threadIndex]?J:null;return wU(A,Z,$)}function jU($,M){return $?.kind==="create"&&$.left===M.left&&$.selection.regionId===M.selection.regionId&&$.selection.startOffset===M.selection.startOffset&&$.selection.endOffset===M.selection.endOffset&&fU($.activeMarks,M.activeMarks)&&$.top===M.top}function LU($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;if($.kind==="create"&&M.kind==="create")return jU($,M);return $.kind==="thread"&&M.kind==="thread"&&$.animateInitialComment===M.animateInitialComment&&$.left===M.left&&$.threadIndex===M.threadIndex&&$.top===M.top}function kU($,M){if($===M)return!0;if(!$||!M)return!1;return $.start.left===M.start.left&&$.start.top===M.start.top&&$.end.left===M.end.left&&$.end.top===M.end.top}function fU($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function SU($,M){return M==="start"?$.end:$.start}import{useEffect as uU,useMemo as UJ,useState as mU}from"react";var b4={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)"},O4={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)"},KJ={...b4,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)"},qJ={...O4,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 GJ($){let M=UJ(()=>gU($),[$]),[J,Z]=mU(M.light),A=UJ(()=>IU(J),[J]);return uU(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){Z(M.light);return}let X=window.matchMedia("(prefers-color-scheme: dark)"),N=()=>{Z(X.matches?M.dark:M.light)};if(N(),typeof X.addEventListener==="function")return X.addEventListener("change",N),()=>{X.removeEventListener("change",N)};return X.addListener(N),()=>{X.removeListener(N)}},[M]),{theme:J,themeStyles:A}}function vU($){return"light"in $&&"dark"in $}function gU($){if(!$)return{dark:O4,light:b4};if(vU($))return $;return{dark:$,light:$}}function IU($){return{"--documint-leaf-button-bg":$.leafButtonBackground,"--documint-leaf-button-border":$.leafButtonBorder,"--documint-leaf-button-text":$.leafButtonText,"--documint-leaf-accent":$.leafAccent,"--documint-leaf-bg":$.leafBackground,"--documint-leaf-border":$.leafBorder,"--documint-leaf-font-family":'"Avenir Next", "Segoe UI", sans-serif',"--documint-leaf-shadow":$.leafShadow??void 0,"--documint-leaf-secondary-text":$.leafSecondaryText,"--documint-leaf-resolved-bg":$.leafResolvedBackground,"--documint-leaf-resolved-border":$.leafResolvedBorder,"--documint-leaf-text":$.leafText,"--documint-selection-handle-bg":$.selectionHandleBackground,"--documint-selection-handle-border":$.selectionHandleBorder}}import{useEffect as lU,useEffectEvent as f0,useRef as FJ,useState as p5}from"react";import{useMemo as hU}from"react";function BJ($){return hU(()=>pU({current:null},$),[$])}function pU($,M){return{get current(){return $.current},get(){let J=$.current;if(J!==null)return J;let Z=M();return $.current=Z,Z},invalidate(){$.current=null}}}function _J({editor:$,editorState:M,editorStateRef:J,renderResources:Z,theme:A}){let X=FJ(null),N=FJ({height:240,top:0}),[Y,Q]=p5(0),[K,q]=p5(240),[U,G]=p5(0),[B,F]=p5(240),_=xU(Y),D=f0(()=>{let V=J.current??M,T=N.current;return $.prepareViewport(V,{height:T.height,paddingX:A.paddingX,paddingY:A.paddingY,top:T.top,width:_},Z)}),y=BJ(D),b=f0((V)=>{F((T)=>{let P=cU(V,N.current.height);return T===P?T:P})}),O=f0((V)=>{let T=rU(V);N.current=T,G((P)=>P===T.top?P:T.top)}),k=f0((V)=>{N.current={...N.current,top:V},G((T)=>T===V?T:V),y.invalidate()}),j=f0((V)=>{let T=X.current;if(!T)return k(V),V;T.scrollTop=V;let P=T.scrollTop;return k(P),P}),R=f0(()=>{return X.current?.scrollTop??N.current.top}),w=f0((V)=>{let T=X.current;return T?h5(V,T):null}),L=(V)=>({onScroll:(T)=>{O(T.currentTarget),V?.onScroll?.(T)},ref:X});return lU(()=>{let V=X.current;if(!V||typeof ResizeObserver>"u")return;let T=new ResizeObserver((P)=>{let E=P[0];if(!E)return;let W=Math.max(0,Math.floor(E.contentRect.width)),z=DJ(V);N.current={...N.current,height:z},Q((u)=>u===W?u:W),q((u)=>u===z?u:z)});return T.observe(V),()=>{T.disconnect()}},[X]),{actions:{getScrollTop:R,observePreparedViewport:b,observeScrollContainer:O,resolvePointerPoint:w,scrollTo:j},props:{getScrollContainer:L,scrollContent:{style:{height:`${B}px`}}},refs:{scrollContainer:X},state:{layoutWidth:_,preparedViewport:y,scrollContentHeight:B,surfaceWidth:Y,viewportHeight:K,viewportTop:U}}}function xU($){return Math.max(240,Math.floor($||480))}function DJ($){return Math.max(240,$.clientHeight)}function rU($){return{height:DJ($),top:$.scrollTop}}function cU($,M){return Math.max(M,Math.ceil($.totalHeight+24))}function dU(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function H$($,{paintHeight:M,paintTop:J,width:Z}){if(!$)return null;let A=Math.max(240,Math.ceil(M)),X=dU();$.width=Math.ceil(Z*X),$.height=Math.ceil(A*X),$.style.width=`${Z}px`,$.style.height=`${A}px`,$.style.transform=`translateY(${J}px)`;let N=$.getContext("2d");if(!N)return null;return{context:N,devicePixelRatio:X,height:A,width:Z}}function T$($,M){return $.activeBlockType===M.activeBlockType&&$.activeCommentThreadIndex===M.activeCommentThreadIndex&&$.activeSpanKind===M.activeSpanKind&&$.canonicalContent===M.canonicalContent&&$.characterCount===M.characterCount&&$.commentThreadCount===M.commentThreadCount&&$.docChangeCount===M.docChangeCount&&$.lastTransactionMs===M.lastTransactionMs&&$.layoutWidth===M.layoutWidth&&$.lineCount===M.lineCount&&$.resolvedCommentCount===M.resolvedCommentCount&&$.selectionFrom===M.selectionFrom&&$.selectionTo===M.selectionTo&&$.transactionCount===M.transactionCount}var HJ=24;function WJ($,M){if(!$)return TJ(M);let J=sU($,M)??oU($,M);return J?aU(J):TJ(M)}function aU($){return{didReconcile:!0,state:$}}function TJ($){return{didReconcile:!1,state:$}}function sU($,M){let J=iU($,M);return J?U1(M,J,!1):null}function iU($,M){if(V$($.selection.anchor,$.selection.focus)){let X=P$($,M,$.selection.focus,"neutral");return X?{anchor:X,focus:X}:null}let J=NG($),Z=P$($,M,$.selection.anchor,J.anchor),A=P$($,M,$.selection.focus,J.focus);return Z&&A?{anchor:Z,focus:A}:null}function P$($,M,J,Z){let A=$.documentIndex.regionIndex.get(J.regionId);if(!A)return null;let X=z$(A,M);if(!X)return null;return{offset:JG(A.text,X.text,J.offset,Z),regionId:X.id}}function z$($,M){let J=M.documentIndex.regionIndex.get($.id);if(J)return J;if($.text.length===0)return null;let Z=MG($,M);if(Z)return Z;let A=M.documentIndex.regionPathIndex.get($.path);if(A)return A;return null}function oU($,M){if(!V$($.selection.anchor,$.selection.focus))return null;let J=nU($);if(!J)return null;let Z=eU($,M,J);if(Z===null)return null;return tU(M,Z)}function nU($){let M=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!M||M.blockType!=="paragraph"||M.text.length>0)return null;return $.documentIndex.blockIndex.get(M.blockId)?.parentBlockId===null?M:null}function tU($,M){let J=v4($.documentIndex.document,M,0,[r({text:""})]),Z={...$,documentIndex:Z4($.documentIndex,J,M,0)},A=X4(Z.documentIndex,$1(M));return A?U1(Z,A,!1):null}function eU($,M,J){let Z=PJ($,J.rootIndex,"before"),A=PJ($,J.rootIndex,"after"),X=Z?z$(Z,M):null,N=A?z$(A,M):null;if(X&&N)return X.rootIndex<N.rootIndex?N.rootIndex:null;if(X)return X.rootIndex+1;if(N)return N.rootIndex;return null}function PJ($,M,J){let Z=J==="before"?-1:1;for(let A=M+Z;A>=0&&A<$.documentIndex.roots.length;A+=Z){let X=$G($,A,J);if(!X)continue;return X}return null}function $G($,M,J){let Z=$.documentIndex.roots[M]?.regions??[],A=J==="before"?Z.length-1:0,X=J==="before"?-1:1;for(let N=A;N>=0&&N<Z.length;N+=X){let Y=Z[N];if(Y&&Y.text.length>0)return Y}return null}function MG($,M){let J=null;for(let Z of M.documentIndex.regions){if(Z.blockType!==$.blockType||Z.text!==$.text)continue;if(J)return null;J=Z}return J}function JG($,M,J,Z){let A=W$(J,0,$.length),X=$.slice(Math.max(0,A-HJ),A),N=$.slice(A,Math.min($.length,A+HJ)),Y=ZG(M,X,N);if(Y!==null)return Y;let Q=AG(M,X),K=XG(M,N);if(Z==="before-suffix")return K??Q??W$(J,0,M.length);return Q??K??W$(J,0,M.length)}function ZG($,M,J){if(M.length===0||J.length===0)return null;let Z=null,A=0;while(A<=$.length){let X=$.indexOf(M,A);if(X===-1)break;let N=X+M.length;if($.startsWith(J,N)){if(Z!==null)return null;Z=N}A=X+Math.max(1,M.length)}return Z}function AG($,M){if(M.length===0)return null;let J=zJ($,M);return J===null?null:J+M.length}function XG($,M){return M.length===0?null:zJ($,M)}function zJ($,M){let J=null,Z=0;while(Z<=$.length){let A=$.indexOf(M,Z);if(A===-1)break;if(J!==null)return null;J=A,Z=A+Math.max(1,M.length)}return J}function NG($){let{anchor:M,focus:J}=$.selection;if(V$(M,J))return{anchor:"neutral",focus:"neutral"};return YG($,M,J)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function YG($,M,J){let Z=$.documentIndex.regionOrderIndex.get(M.regionId),A=$.documentIndex.regionOrderIndex.get(J.regionId);if(Z===void 0||A===void 0)return 0;return Z===A?M.offset-J.offset:Z-A}function V$($,M){return $.regionId===M.regionId&&$.offset===M.offset}function W$($,M,J){return Math.max(M,Math.min($,J))}import{jsxDEV as l,Fragment as _G}from"react/jsx-dev-runtime";function x5({blocks:$}){return l(_G,{children:$.map((M)=>QG(M))},void 0,!1,void 0,this)}function QG($){switch($.type){case"blockquote":return l("blockquote",{className:"preview-block preview-block-blockquote",children:l(x5,{blocks:$.children},void 0,!1,void 0,this)},$.id,!1,void 0,this);case"code":return l("div",{className:"preview-block preview-block-code",children:[l("div",{className:"preview-rich-header",children:UG($.language,$.meta)},void 0,!1,void 0,this),l("pre",{children:l("code",{children:$.source||" "},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},$.id,!0,void 0,this);case"heading":{let M=`h${$.depth}`;return l(M,{className:"preview-block preview-block-heading",children:l5($.children)},$.id,!1,void 0,this)}case"list":return $.ordered?l("ol",{className:"preview-block preview-block-list",start:$.start??1,children:$.items.map((M)=>y$(M))},$.id,!1,void 0,this):l("ul",{className:"preview-block preview-block-list",children:$.items.map((M)=>y$(M))},$.id,!1,void 0,this);case"listItem":return y$($);case"paragraph":return l("p",{className:"preview-block preview-block-paragraph",children:l5($.children)},$.id,!1,void 0,this);case"table":return l("div",{className:"preview-block preview-block-table",children:[l("div",{className:"preview-rich-header",children:GG($.rows.length,$.rows[0]?.cells.length??0,$.align.filter((M)=>M!==null).length)},void 0,!1,void 0,this),l("div",{className:"preview-table-scroll",children:l("table",{children:l("tbody",{children:$.rows.map((M)=>l("tr",{children:M.cells.map((J)=>l("td",{children:l5(J.children)},J.id,!1,void 0,this))},M.id,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},$.id,!0,void 0,this);case"thematicBreak":return l("hr",{className:"preview-block preview-block-rule"},$.id,!1,void 0,this);case"directive":return l("pre",{className:`preview-block preview-block-directive preview-block-directive-${$.name}`,children:$.body},$.id,!1,void 0,this);case"unsupported":return l("pre",{className:"preview-block preview-block-unsupported",children:$.source},$.id,!1,void 0,this)}}function y$($){return l("li",{className:"preview-block preview-block-list-item",children:l(x5,{blocks:$.children},void 0,!1,void 0,this)},$.id,!1,void 0,this)}function l5($){return $.map((M)=>{switch(M.type){case"break":return l("br",{},M.id,!1,void 0,this);case"image":return l("span",{className:"preview-inline preview-inline-image",children:[l("img",{alt:M.alt??"",src:M.url,title:M.title??""},void 0,!1,void 0,this),l("span",{children:[l("strong",{children:BG(M.alt)},void 0,!1,void 0,this),l("small",{children:FG(M.url,M.title)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},M.id,!0,void 0,this);case"inlineCode":return l("code",{className:"preview-inline preview-inline-code",children:M.code},M.id,!1,void 0,this);case"link":return KG(M);case"text":return l("span",{className:"preview-inline",children:qG(M.text,M.marks)},M.id,!1,void 0,this);case"unsupported":return l("span",{className:"preview-inline preview-inline-unsupported",children:M.source},M.id,!1,void 0,this)}})}function KG($){return l("a",{className:"preview-inline preview-inline-link",href:$.url,children:l5($.children)},$.id,!1,void 0,this)}function qG($,M){let J=$;for(let Z of M)switch(Z){case"strikethrough":J=l("del",{children:J},void 0,!1,void 0,this);break;case"italic":J=l("em",{children:J},void 0,!1,void 0,this);break;case"bold":J=l("strong",{children:J},void 0,!1,void 0,this);break;case"underline":J=l("ins",{children:J},void 0,!1,void 0,this);break}return J}function UG($,M){return[$??"plain text",M].filter(Boolean).join(" • ")}function GG($,M,J){let Z=J>0?`${J} aligned ${J===1?"column":"columns"}`:"no alignment";return`${$} ${$===1?"row":"rows"} • ${M} ${M===1?"column":"columns"} • ${Z}`}function BG($){return $?.trim()?$:"Untitled image"}function FG($,M){return M?.trim()?`${M} • ${$}`:$}var VJ=`
|
|
32
|
+
:where(.documint-leaf-toolbar) {
|
|
33
|
+
--documint-leaf-toolbar-button-active-bg:
|
|
34
|
+
color-mix(in srgb, var(--documint-leaf-accent) 16%, var(--documint-leaf-bg));
|
|
35
|
+
--documint-leaf-toolbar-divider-color:
|
|
36
|
+
color-mix(in srgb, var(--documint-leaf-border) 72%, transparent);
|
|
37
|
+
--documint-leaf-toolbar-menu-border-color:
|
|
38
|
+
color-mix(in srgb, var(--documint-leaf-border) 88%, transparent);
|
|
39
|
+
--documint-leaf-toolbar-menu-hover-bg:
|
|
40
|
+
color-mix(in srgb, var(--documint-leaf-accent) 12%, var(--documint-leaf-bg));
|
|
41
|
+
--documint-leaf-toolbar-shadow-fallback:
|
|
42
|
+
0 14px 40px color-mix(in srgb, var(--documint-leaf-text) 16%, transparent);
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: 0.52rem;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:where(.documint-leaf-toolbar-group) {
|
|
49
|
+
display: inline-flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
gap: 0.38rem;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:where(.documint-leaf-toolbar-divider) {
|
|
55
|
+
width: 1px;
|
|
56
|
+
height: 1.15rem;
|
|
57
|
+
background: var(--documint-leaf-toolbar-divider-color);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
:where(.documint-leaf-toolbar-button),
|
|
61
|
+
:where(.documint-leaf-toolbar-menu-item) {
|
|
62
|
+
appearance: none;
|
|
63
|
+
display: inline-flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
gap: 0.36rem;
|
|
66
|
+
border: 0;
|
|
67
|
+
background: transparent;
|
|
68
|
+
color: var(--documint-leaf-button-text);
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
font: inherit;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:where(.documint-leaf-toolbar-button) {
|
|
74
|
+
justify-content: center;
|
|
75
|
+
min-width: 1.45rem;
|
|
76
|
+
height: 1.45rem;
|
|
77
|
+
padding: 0 0.12rem;
|
|
78
|
+
border-radius: 0.38rem;
|
|
79
|
+
line-height: 0;
|
|
80
|
+
transition:
|
|
81
|
+
background-color 120ms ease,
|
|
82
|
+
color 120ms ease;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
:where(.documint-leaf-toolbar-menu-shell .documint-leaf-toolbar-button) {
|
|
86
|
+
gap: 0.18rem;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
:where(.documint-leaf-toolbar-button:hover) {
|
|
90
|
+
background: var(--documint-leaf-toolbar-button-active-bg);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
:where(.documint-leaf-toolbar-button:disabled) {
|
|
94
|
+
opacity: 0.42;
|
|
95
|
+
cursor: default;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:where(.documint-leaf-toolbar-button:disabled:hover) {
|
|
99
|
+
background: transparent;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:where(.documint-leaf-toolbar-button.active) {
|
|
103
|
+
background: var(--documint-leaf-toolbar-button-active-bg);
|
|
104
|
+
color: var(--documint-leaf-text);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:where(.documint-leaf-toolbar-menu-shell) {
|
|
108
|
+
position: relative;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
:where(.documint-leaf-toolbar-menu-chevron) {
|
|
112
|
+
transition: transform 140ms ease;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:where(.documint-leaf-toolbar-menu-chevron.is-open) {
|
|
116
|
+
transform: rotate(180deg);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
:where(.documint-leaf-toolbar-menu) {
|
|
120
|
+
position: absolute;
|
|
121
|
+
top: calc(100% + 0.55rem);
|
|
122
|
+
left: 0;
|
|
123
|
+
display: grid;
|
|
124
|
+
gap: 0.2rem;
|
|
125
|
+
min-width: 10.5rem;
|
|
126
|
+
padding: 0.35rem;
|
|
127
|
+
border: 1px solid var(--documint-leaf-toolbar-menu-border-color);
|
|
128
|
+
border-radius: 0.8rem;
|
|
129
|
+
background: var(--documint-leaf-bg);
|
|
130
|
+
box-shadow: var(--documint-leaf-shadow, var(--documint-leaf-toolbar-shadow-fallback));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
:where(.documint-leaf-toolbar-menu-item) {
|
|
134
|
+
width: 100%;
|
|
135
|
+
padding: 0.45rem 0.55rem;
|
|
136
|
+
border-radius: 0.55rem;
|
|
137
|
+
line-height: 1.2;
|
|
138
|
+
text-align: left;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
:where(.documint-leaf-toolbar-menu-item:hover) {
|
|
142
|
+
background: var(--documint-leaf-toolbar-menu-hover-bg);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
:where(.documint-leaf-toolbar-menu-item:disabled) {
|
|
146
|
+
opacity: 0.42;
|
|
147
|
+
cursor: default;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
:where(.documint-leaf-toolbar-menu-item:disabled:hover) {
|
|
151
|
+
background: transparent;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
:where(.documint-leaf-toolbar-menu-divider) {
|
|
155
|
+
height: 1px;
|
|
156
|
+
margin: 0.15rem 0.2rem;
|
|
157
|
+
background: var(--documint-leaf-toolbar-divider-color);
|
|
158
|
+
}
|
|
159
|
+
`;var yJ=`
|
|
160
|
+
:where(.documint-leaf-shell) {
|
|
161
|
+
--documint-leaf-divider-color:
|
|
162
|
+
color-mix(in srgb, var(--documint-leaf-border) 60%, transparent);
|
|
163
|
+
--documint-leaf-shadow-fallback:
|
|
164
|
+
0 14px 40px color-mix(in srgb, var(--documint-leaf-text) 16%, transparent);
|
|
165
|
+
padding: 0.8rem;
|
|
166
|
+
border: 1px solid var(--documint-leaf-border);
|
|
167
|
+
border-radius: 0.95rem;
|
|
168
|
+
background: var(--documint-leaf-bg);
|
|
169
|
+
box-shadow: var(--documint-leaf-shadow, var(--documint-leaf-shadow-fallback));
|
|
170
|
+
color: var(--documint-leaf-text);
|
|
171
|
+
font-family: var(--documint-leaf-font-family, "Avenir Next", "Segoe UI", sans-serif);
|
|
172
|
+
font-size: 0.84rem;
|
|
173
|
+
line-height: 1.45;
|
|
174
|
+
pointer-events: auto;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
:where(.documint-leaf-shell:has(> .documint-leaf-toolbar)),
|
|
178
|
+
:where(.documint-leaf-shell:has(> .documint-comment-leaf-create)) {
|
|
179
|
+
width: auto;
|
|
180
|
+
padding: 0.38rem 0.58rem;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
:where(.documint-leaf-shell:has(> .documint-comment-leaf-create.is-expanded)) {
|
|
184
|
+
padding: 0.8rem;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
:where(.documint-leaf-shell[data-status="resolved"]) {
|
|
188
|
+
border-color: var(--documint-leaf-resolved-border);
|
|
189
|
+
background: var(--documint-leaf-resolved-bg);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
:where(.documint-leaf-shell p) {
|
|
193
|
+
margin: 0;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
:where(.documint-comment-leaf:not(.documint-comment-leaf-create)),
|
|
197
|
+
:where(.documint-comment-leaf-create.is-expanded) {
|
|
198
|
+
width: var(--documint-leaf-width, min(18rem, calc(100vw - 4rem)));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
:where(.documint-link-leaf) {
|
|
202
|
+
width: min(16rem, calc(100vw - 4rem));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
${VJ}
|
|
206
|
+
|
|
207
|
+
:where(.documint-leaf-anchor) {
|
|
208
|
+
--documint-leaf-anchor-bridge-height: 12px;
|
|
209
|
+
position: fixed;
|
|
210
|
+
z-index: 1000;
|
|
211
|
+
padding-top: var(--documint-leaf-anchor-bridge-height);
|
|
212
|
+
margin-top: calc(var(--documint-leaf-anchor-bridge-height) * -1);
|
|
213
|
+
pointer-events: auto;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
:where(.documint-leaf-anchor[data-selection="true"]) {
|
|
217
|
+
--documint-leaf-anchor-bridge-height: 0px;
|
|
218
|
+
padding-top: 0;
|
|
219
|
+
margin-top: 14px;
|
|
220
|
+
pointer-events: none;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
:where(.documint-leaf-bridge) {
|
|
224
|
+
width: 100%;
|
|
225
|
+
height: var(--documint-leaf-anchor-bridge-height);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
:where(.documint-link-leaf) {
|
|
229
|
+
display: grid;
|
|
230
|
+
gap: 0.3rem;
|
|
231
|
+
min-width: 0;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
:where(.documint-link-leaf-row) {
|
|
235
|
+
display: grid;
|
|
236
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
237
|
+
align-items: flex-start;
|
|
238
|
+
gap: 0.6rem;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
:where(.documint-link-leaf-row.is-editing) {
|
|
242
|
+
grid-template-columns: minmax(0, 1fr);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
:where(.documint-link-leaf-actions) {
|
|
246
|
+
display: inline-flex;
|
|
247
|
+
align-items: center;
|
|
248
|
+
gap: 0.5rem;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
:where(.documint-link-leaf-divider) {
|
|
252
|
+
margin: 0.2rem 0;
|
|
253
|
+
border-top: 1px solid var(--documint-leaf-divider-color);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
:where(.documint-link-leaf-hint) {
|
|
257
|
+
color: var(--documint-leaf-secondary-text);
|
|
258
|
+
font-size: 0.74rem;
|
|
259
|
+
font-style: italic;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
:where(.documint-link-leaf-title) {
|
|
263
|
+
color: var(--documint-leaf-text);
|
|
264
|
+
font-size: 0.78rem;
|
|
265
|
+
font-weight: 600;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
:where(.documint-link-leaf-url) {
|
|
269
|
+
min-width: 0;
|
|
270
|
+
color: var(--documint-leaf-secondary-text);
|
|
271
|
+
font-size: 0.76rem;
|
|
272
|
+
line-height: 1.4;
|
|
273
|
+
overflow-wrap: anywhere;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
:where(.documint-link-leaf-input) {
|
|
277
|
+
min-height: auto;
|
|
278
|
+
padding-right: 0.75rem;
|
|
279
|
+
padding-bottom: 2.1rem;
|
|
280
|
+
overflow-wrap: anywhere;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
:where(.documint-comment-leaf-header),
|
|
284
|
+
:where(.documint-comment-leaf-actions),
|
|
285
|
+
:where(.documint-comment-message-meta) {
|
|
286
|
+
display: flex;
|
|
287
|
+
align-items: center;
|
|
288
|
+
justify-content: space-between;
|
|
289
|
+
gap: 0.5rem;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
:where(.documint-comment-leaf-header) {
|
|
293
|
+
margin-bottom: 0.7rem;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
:where(.documint-comment-leaf-link) {
|
|
297
|
+
display: grid;
|
|
298
|
+
gap: 0.3rem;
|
|
299
|
+
margin-bottom: 0.8rem;
|
|
300
|
+
padding-bottom: 0.8rem;
|
|
301
|
+
border-bottom: 1px solid var(--documint-leaf-divider-color);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
:where(.documint-comment-leaf-create) {
|
|
305
|
+
--documint-comment-create-scale-duration: 180ms;
|
|
306
|
+
--documint-comment-create-fade-duration: 120ms;
|
|
307
|
+
height: auto;
|
|
308
|
+
padding: 0;
|
|
309
|
+
overflow: visible;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
:where(.documint-comment-leaf-create-shell) {
|
|
313
|
+
position: relative;
|
|
314
|
+
display: grid;
|
|
315
|
+
width: max-content;
|
|
316
|
+
height: 100%;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
:where(.documint-comment-leaf-create-shell > .documint-leaf-toolbar) {
|
|
320
|
+
position: relative;
|
|
321
|
+
z-index: 0;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
:where(.documint-comment-leaf-create.is-expanded .documint-comment-leaf-create-shell) {
|
|
325
|
+
width: 100%;
|
|
326
|
+
min-height: 5.5rem;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
:where(.documint-comment-leaf-create.is-expanded .documint-comment-leaf-create-shell > .documint-leaf-toolbar) {
|
|
330
|
+
position: absolute;
|
|
331
|
+
inset: 0;
|
|
332
|
+
pointer-events: none;
|
|
333
|
+
z-index: 1;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
:where(.documint-comment-leaf-create-button) {
|
|
337
|
+
width: 1.7rem;
|
|
338
|
+
height: 1.7rem;
|
|
339
|
+
padding: 0;
|
|
340
|
+
line-height: 0;
|
|
341
|
+
position: relative;
|
|
342
|
+
z-index: 0;
|
|
343
|
+
display: inline-flex;
|
|
344
|
+
opacity: 1;
|
|
345
|
+
transform: scale(1);
|
|
346
|
+
transition:
|
|
347
|
+
opacity var(--documint-comment-create-fade-duration) ease,
|
|
348
|
+
transform var(--documint-comment-create-scale-duration) ease;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
:where(.documint-comment-leaf-create-divider) {
|
|
352
|
+
opacity: 1;
|
|
353
|
+
transition: opacity var(--documint-comment-create-fade-duration) ease;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
:where(.documint-comment-leaf-create-mark) {
|
|
357
|
+
opacity: 1;
|
|
358
|
+
transition:
|
|
359
|
+
opacity var(--documint-comment-create-fade-duration) ease,
|
|
360
|
+
transform var(--documint-comment-create-scale-duration) ease;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
:where(.documint-comment-leaf-create.is-expanded .documint-comment-leaf-create-button),
|
|
364
|
+
:where(.documint-comment-leaf-create.is-expanded .documint-comment-leaf-create-mark) {
|
|
365
|
+
opacity: 0;
|
|
366
|
+
transform: scale(0.72);
|
|
367
|
+
pointer-events: none;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
:where(.documint-comment-leaf-create.is-expanded .documint-comment-leaf-create-divider) {
|
|
371
|
+
opacity: 0;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
:where(.documint-comment-leaf-create-content) {
|
|
375
|
+
position: absolute;
|
|
376
|
+
top: 0;
|
|
377
|
+
left: 0;
|
|
378
|
+
right: 0;
|
|
379
|
+
opacity: 0;
|
|
380
|
+
transform: scale(0);
|
|
381
|
+
transform-origin: top left;
|
|
382
|
+
transition:
|
|
383
|
+
opacity var(--documint-comment-create-fade-duration) ease,
|
|
384
|
+
transform var(--documint-comment-create-scale-duration) ease;
|
|
385
|
+
pointer-events: none;
|
|
386
|
+
z-index: 1;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
:where(.documint-comment-leaf-create.is-expanded .documint-comment-leaf-create-content) {
|
|
390
|
+
position: relative;
|
|
391
|
+
opacity: 1;
|
|
392
|
+
transform: scale(1);
|
|
393
|
+
pointer-events: auto;
|
|
394
|
+
z-index: 0;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
:where(.documint-comment-leaf-age) {
|
|
398
|
+
color: var(--documint-leaf-secondary-text);
|
|
399
|
+
font-size: 0.76rem;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
:where(.documint-comment-thread) {
|
|
403
|
+
display: grid;
|
|
404
|
+
gap: 0.75rem;
|
|
405
|
+
max-height: 16rem;
|
|
406
|
+
margin-bottom: 0.8rem;
|
|
407
|
+
overflow: auto;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
:where(.documint-comment-thread.is-empty) {
|
|
411
|
+
max-height: 0;
|
|
412
|
+
margin-bottom: 0;
|
|
413
|
+
overflow: hidden;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
:where(.documint-comment-message) {
|
|
417
|
+
display: grid;
|
|
418
|
+
gap: 0.55rem;
|
|
419
|
+
padding-bottom: 0.75rem;
|
|
420
|
+
border-bottom: 1px solid var(--documint-leaf-divider-color);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
:where(.documint-comment-message-root) {
|
|
424
|
+
transform: translateY(-8px) scaleY(0);
|
|
425
|
+
transform-origin: top left;
|
|
426
|
+
opacity: 0;
|
|
427
|
+
transition:
|
|
428
|
+
opacity 140ms ease,
|
|
429
|
+
transform 180ms ease;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
:where(.documint-comment-message-root.is-visible) {
|
|
433
|
+
transform: translateY(0) scaleY(1);
|
|
434
|
+
opacity: 1;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
:where(.documint-comment-message-root.is-hidden) {
|
|
438
|
+
max-height: 0;
|
|
439
|
+
padding-bottom: 0;
|
|
440
|
+
border-bottom: 0;
|
|
441
|
+
overflow: hidden;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
:where(.documint-comment-message:last-child) {
|
|
445
|
+
padding-bottom: 0;
|
|
446
|
+
border-bottom: 0;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
:where(.documint-comment-reply) {
|
|
450
|
+
position: relative;
|
|
451
|
+
display: block;
|
|
452
|
+
padding-top: 0.85rem;
|
|
453
|
+
border-top: 1px solid var(--documint-leaf-divider-color);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
:where(.documint-comment-reply.is-standalone) {
|
|
457
|
+
padding-top: 0;
|
|
458
|
+
border-top: 0;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
:where(.documint-comment-reply.is-standalone:not(.is-visible)) {
|
|
462
|
+
max-height: 0;
|
|
463
|
+
overflow: hidden;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
:where(.documint-leaf-shell[data-status="resolved"] .documint-comment-reply) {
|
|
467
|
+
border-top-color: color-mix(in srgb, var(--documint-leaf-resolved-border) 72%, transparent);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
:where(.documint-comment-message-meta span) {
|
|
471
|
+
color: var(--documint-leaf-secondary-text);
|
|
472
|
+
font-size: 0.74rem;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
:where(.documint-comment-actions) {
|
|
476
|
+
display: flex;
|
|
477
|
+
gap: 0.4rem;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
:where(.documint-leaf-action) {
|
|
481
|
+
appearance: none;
|
|
482
|
+
display: inline-flex;
|
|
483
|
+
align-items: center;
|
|
484
|
+
justify-content: center;
|
|
485
|
+
width: auto;
|
|
486
|
+
height: auto;
|
|
487
|
+
padding: 0;
|
|
488
|
+
border: 0;
|
|
489
|
+
border-radius: 0;
|
|
490
|
+
background: transparent;
|
|
491
|
+
color: var(--documint-leaf-button-text);
|
|
492
|
+
cursor: pointer;
|
|
493
|
+
font: inherit;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
:where(.documint-leaf-action-text) {
|
|
497
|
+
padding: 0.35rem 0.62rem;
|
|
498
|
+
border: 1px solid var(--documint-leaf-button-border);
|
|
499
|
+
border-radius: 999px;
|
|
500
|
+
background: var(--documint-leaf-button-bg);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
:where(.documint-leaf-action:not(.documint-leaf-action-text)) {
|
|
504
|
+
line-height: 0;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
:where(.documint-leaf-action:disabled) {
|
|
508
|
+
opacity: 0.45;
|
|
509
|
+
cursor: default;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
:where(.documint-leaf-action-danger) {
|
|
513
|
+
color: var(--documint-leaf-accent);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
:where(.documint-comment-input) {
|
|
517
|
+
box-sizing: border-box;
|
|
518
|
+
width: 100%;
|
|
519
|
+
min-height: 4.6rem;
|
|
520
|
+
padding: 0.65rem 3.2rem 0.75rem 0.75rem;
|
|
521
|
+
border: 1px solid var(--documint-leaf-border);
|
|
522
|
+
border-radius: 0.75rem;
|
|
523
|
+
background: var(--documint-leaf-button-bg);
|
|
524
|
+
color: var(--documint-leaf-text);
|
|
525
|
+
font: inherit;
|
|
526
|
+
resize: none;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
:where(.documint-leaf-shell[data-status="resolved"] .documint-comment-input) {
|
|
530
|
+
border-color: var(--documint-leaf-resolved-border);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
:where(.documint-comment-input::placeholder) {
|
|
534
|
+
color: var(--documint-leaf-secondary-text);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
:where(.documint-edit-input-field) {
|
|
538
|
+
position: relative;
|
|
539
|
+
width: 100%;
|
|
540
|
+
min-width: 0;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
:where(.documint-link-leaf-row > .documint-edit-input-field) {
|
|
544
|
+
width: 100%;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
:where(.documint-edit-input-cancel) {
|
|
548
|
+
position: absolute;
|
|
549
|
+
right: 0.7rem;
|
|
550
|
+
top: 0.7rem;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
:where(.documint-edit-input-save) {
|
|
554
|
+
position: absolute;
|
|
555
|
+
right: 0.7rem;
|
|
556
|
+
bottom: calc(0.7rem + 3px);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
:where(.documint-comment-reply-field) {
|
|
560
|
+
position: relative;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
:where(.documint-comment-reply-submit) {
|
|
564
|
+
position: absolute;
|
|
565
|
+
right: 0.7rem;
|
|
566
|
+
bottom: calc(0.7rem + 3px);
|
|
567
|
+
}
|
|
568
|
+
`;var bJ=`
|
|
569
|
+
:where(.documint) {
|
|
570
|
+
display: grid;
|
|
571
|
+
min-width: 0;
|
|
572
|
+
min-height: 0;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
:where(.documint-scroll-container) {
|
|
576
|
+
position: relative;
|
|
577
|
+
display: block;
|
|
578
|
+
width: 100%;
|
|
579
|
+
min-width: 0;
|
|
580
|
+
min-height: 0;
|
|
581
|
+
overflow: auto;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
:where(.documint-input) {
|
|
585
|
+
/* The bridge must look like a real focused input to iOS so Safari
|
|
586
|
+
shifts the page above the virtual keyboard. Empirically:
|
|
587
|
+
- opacity must be greater than 0
|
|
588
|
+
- the bounding rect must be at least 2x2 pixels (1x1 is skipped)
|
|
589
|
+
- pointer-events must not be none
|
|
590
|
+
Any of those signals "not a real user input" and iOS won't shift.
|
|
591
|
+
We hide the element from the user via transparent colors while
|
|
592
|
+
keeping those signals correct. JS sizes/positions it at the caret
|
|
593
|
+
at focus time. */
|
|
594
|
+
position: absolute;
|
|
595
|
+
top: 0;
|
|
596
|
+
left: 0;
|
|
597
|
+
width: 2px;
|
|
598
|
+
height: 2px;
|
|
599
|
+
padding: 0;
|
|
600
|
+
border: 0;
|
|
601
|
+
margin: 0;
|
|
602
|
+
color: transparent;
|
|
603
|
+
background: transparent;
|
|
604
|
+
caret-color: transparent;
|
|
605
|
+
outline: none;
|
|
606
|
+
resize: none;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
:where(.documint-scroll-content) {
|
|
610
|
+
position: relative;
|
|
611
|
+
min-height: 100%;
|
|
612
|
+
overflow: hidden;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
:where(.documint-content-canvas) {
|
|
616
|
+
position: absolute;
|
|
617
|
+
inset: 0 auto auto 0;
|
|
618
|
+
display: block;
|
|
619
|
+
width: 100%;
|
|
620
|
+
outline: none;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
:where(.documint-overlay-canvas) {
|
|
624
|
+
position: absolute;
|
|
625
|
+
inset: 0 auto auto 0;
|
|
626
|
+
display: block;
|
|
627
|
+
width: 100%;
|
|
628
|
+
pointer-events: none;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
:where(.documint-presence-indicators) {
|
|
632
|
+
position: sticky;
|
|
633
|
+
z-index: 5;
|
|
634
|
+
display: flex;
|
|
635
|
+
flex-direction: column;
|
|
636
|
+
align-items: flex-end;
|
|
637
|
+
gap: 0.45rem;
|
|
638
|
+
height: 0;
|
|
639
|
+
pointer-events: none;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.documint-presence-indicator {
|
|
643
|
+
--documint-presence-indicator-size: 1.45rem;
|
|
644
|
+
display: inline-flex;
|
|
645
|
+
flex-direction: row-reverse;
|
|
646
|
+
align-items: center;
|
|
647
|
+
min-width: var(--documint-presence-indicator-size);
|
|
648
|
+
height: var(--documint-presence-indicator-size);
|
|
649
|
+
padding: 0;
|
|
650
|
+
border: 1px solid var(--documint-leaf-border);
|
|
651
|
+
border-radius: 999px;
|
|
652
|
+
background: var(--documint-leaf-bg);
|
|
653
|
+
box-shadow: var(
|
|
654
|
+
--documint-leaf-shadow,
|
|
655
|
+
0 14px 40px color-mix(in srgb, var(--documint-leaf-text) 16%, transparent)
|
|
656
|
+
);
|
|
657
|
+
color: var(--documint-leaf-text);
|
|
658
|
+
cursor: pointer;
|
|
659
|
+
font-family: var(--documint-leaf-font-family, "Avenir Next", "Segoe UI", sans-serif);
|
|
660
|
+
font-size: 0.66rem;
|
|
661
|
+
font-weight: 700;
|
|
662
|
+
line-height: 1;
|
|
663
|
+
pointer-events: auto;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
:where(.documint-presence-indicator:disabled) {
|
|
667
|
+
cursor: default;
|
|
668
|
+
opacity: 0.72;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
:where(.documint-presence-indicator-avatar) {
|
|
672
|
+
display: inline-grid;
|
|
673
|
+
place-items: center;
|
|
674
|
+
width: var(--documint-presence-indicator-size);
|
|
675
|
+
height: var(--documint-presence-indicator-size);
|
|
676
|
+
overflow: hidden;
|
|
677
|
+
border-radius: 999px;
|
|
678
|
+
background: var(--documint-presence-color);
|
|
679
|
+
color: white;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
:where(.documint-presence-indicator-image) {
|
|
683
|
+
display: block;
|
|
684
|
+
width: calc(100% - 2px);
|
|
685
|
+
height: calc(100% - 2px);
|
|
686
|
+
border-radius: inherit;
|
|
687
|
+
object-fit: cover;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
:where(.documint-presence-indicator-direction) {
|
|
691
|
+
display: inline-flex;
|
|
692
|
+
align-items: center;
|
|
693
|
+
height: 100%;
|
|
694
|
+
padding: 0 0.42rem 0 0.36rem;
|
|
695
|
+
color: var(--documint-leaf-text);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
:where(.documint-presence-indicator-arrow) {
|
|
699
|
+
display: block;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
:where(.documint-selection-handle) {
|
|
703
|
+
position: absolute;
|
|
704
|
+
z-index: 4;
|
|
705
|
+
width: 1.2rem;
|
|
706
|
+
height: 1.2rem;
|
|
707
|
+
margin: 0;
|
|
708
|
+
padding: 0;
|
|
709
|
+
border: 0;
|
|
710
|
+
background: transparent;
|
|
711
|
+
pointer-events: auto;
|
|
712
|
+
touch-action: none;
|
|
713
|
+
cursor: grab;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
:where(.documint-selection-handle:active) {
|
|
717
|
+
cursor: grabbing;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
:where(.documint-selection-handle-start) {
|
|
721
|
+
transform: translate(-70%, -82%);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
:where(.documint-selection-handle-end) {
|
|
725
|
+
transform: translate(-30%, -39%);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
:where(.documint-selection-handle-knob) {
|
|
729
|
+
position: absolute;
|
|
730
|
+
inset: 0;
|
|
731
|
+
display: block;
|
|
732
|
+
border: 2px solid var(--documint-selection-handle-border);
|
|
733
|
+
border-radius: 999px;
|
|
734
|
+
background: var(--documint-selection-handle-bg);
|
|
735
|
+
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
:where(.documint-fallback) {
|
|
739
|
+
max-width: 100%;
|
|
740
|
+
color: #0f172a;
|
|
741
|
+
line-height: 1.65;
|
|
742
|
+
white-space: normal;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
:where(.documint-fallback p) {
|
|
746
|
+
margin: 0 0 0.9rem;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
:where(.documint-fallback h1),
|
|
750
|
+
:where(.documint-fallback h2),
|
|
751
|
+
:where(.documint-fallback h3),
|
|
752
|
+
:where(.documint-fallback h4),
|
|
753
|
+
:where(.documint-fallback h5),
|
|
754
|
+
:where(.documint-fallback h6) {
|
|
755
|
+
margin: 0 0 0.85rem;
|
|
756
|
+
line-height: 1.15;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
:where(.documint-fallback h1) {
|
|
760
|
+
font-size: 2rem;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
:where(.documint-fallback h2) {
|
|
764
|
+
font-size: 1.55rem;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
:where(.documint-fallback h3) {
|
|
768
|
+
font-size: 1.25rem;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
:where(.documint-fallback ul),
|
|
772
|
+
:where(.documint-fallback ol) {
|
|
773
|
+
margin: 0 0 1rem;
|
|
774
|
+
padding-left: 1.4rem;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
:where(.documint-fallback li > p) {
|
|
778
|
+
margin: 0;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
:where(.documint-fallback blockquote) {
|
|
782
|
+
margin: 0 0 1rem;
|
|
783
|
+
padding-left: 1rem;
|
|
784
|
+
border-left: 3px solid rgba(14, 116, 144, 0.3);
|
|
785
|
+
color: #334155;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
:where(.documint-fallback pre) {
|
|
789
|
+
margin: 0 0 1rem;
|
|
790
|
+
padding: 0.9rem 1rem;
|
|
791
|
+
overflow: auto;
|
|
792
|
+
border-radius: 0.85rem;
|
|
793
|
+
background: #0f172a;
|
|
794
|
+
color: #e2e8f0;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
:where(.documint-fallback table) {
|
|
798
|
+
width: 100%;
|
|
799
|
+
margin: 0 0 1rem;
|
|
800
|
+
border-collapse: collapse;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
:where(.documint-fallback td) {
|
|
804
|
+
padding: 0.45rem 0.55rem;
|
|
805
|
+
border: 1px solid rgba(148, 163, 184, 0.35);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
:where(.documint-fallback a) {
|
|
809
|
+
color: #0369a1;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
:where(.preview-rich-header) {
|
|
813
|
+
margin: 0 0 0.35rem;
|
|
814
|
+
color: #9fb3c8;
|
|
815
|
+
font-family: "Avenir Next", "Segoe UI", sans-serif;
|
|
816
|
+
font-size: 0.74rem;
|
|
817
|
+
font-weight: 700;
|
|
818
|
+
letter-spacing: 0.08em;
|
|
819
|
+
text-transform: uppercase;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
:where(.preview-block-code) {
|
|
823
|
+
margin: 0 0 1rem;
|
|
824
|
+
padding: 0.75rem;
|
|
825
|
+
border-radius: 0.9rem;
|
|
826
|
+
background: linear-gradient(180deg, #132033, #0f172a);
|
|
827
|
+
color: #e2e8f0;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
:where(.preview-block-code pre) {
|
|
831
|
+
margin: 0;
|
|
832
|
+
padding: 0.9rem 1rem;
|
|
833
|
+
overflow: auto;
|
|
834
|
+
border-radius: 0.75rem;
|
|
835
|
+
background: rgba(15, 23, 42, 0.72);
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
:where(.preview-block-table) {
|
|
839
|
+
margin: 0 0 1rem;
|
|
840
|
+
padding: 0.75rem;
|
|
841
|
+
border: 1px solid rgba(14, 116, 144, 0.18);
|
|
842
|
+
border-radius: 0.9rem;
|
|
843
|
+
background: rgba(248, 250, 252, 0.96);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
:where(.preview-table-scroll) {
|
|
847
|
+
overflow-x: auto;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
:where(.preview-table-scroll table) {
|
|
851
|
+
min-width: max-content;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
:where(.preview-inline-image) {
|
|
855
|
+
display: inline-flex;
|
|
856
|
+
align-items: center;
|
|
857
|
+
gap: 0.65rem;
|
|
858
|
+
max-width: min(100%, 34rem);
|
|
859
|
+
margin: 0 0.15rem;
|
|
860
|
+
padding: 0.35rem 0.55rem;
|
|
861
|
+
border: 1px solid rgba(14, 116, 144, 0.16);
|
|
862
|
+
border-radius: 999px;
|
|
863
|
+
background: rgba(240, 249, 255, 0.95);
|
|
864
|
+
vertical-align: middle;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
:where(.preview-inline-image img) {
|
|
868
|
+
flex: none;
|
|
869
|
+
width: 2.4rem;
|
|
870
|
+
height: 2.4rem;
|
|
871
|
+
object-fit: cover;
|
|
872
|
+
border-radius: 0.65rem;
|
|
873
|
+
background: rgba(148, 163, 184, 0.18);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
:where(.preview-inline-image > span) {
|
|
877
|
+
display: grid;
|
|
878
|
+
min-width: 0;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
:where(.preview-inline-image strong) {
|
|
882
|
+
color: #0f172a;
|
|
883
|
+
font-family: "Avenir Next", "Segoe UI", sans-serif;
|
|
884
|
+
font-size: 0.88rem;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
:where(.preview-inline-image small) {
|
|
888
|
+
overflow: hidden;
|
|
889
|
+
color: #475569;
|
|
890
|
+
font-family: "Avenir Next", "Segoe UI", sans-serif;
|
|
891
|
+
font-size: 0.75rem;
|
|
892
|
+
text-overflow: ellipsis;
|
|
893
|
+
white-space: nowrap;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
${yJ}
|
|
897
|
+
`;import{jsxDEV as N1,Fragment as zG}from"react/jsx-dev-runtime";var HG={docChangeCount:0,lastTransactionMs:0,transactionCount:0},TG=2,OJ={activeBlockType:null,activeCommentThreadIndex:null,activeSpanKind:null,canonicalContent:"",characterCount:0,commentThreadCount:0,docChangeCount:0,lastTransactionMs:0,layoutWidth:0,lineCount:0,resolvedCommentCount:0,selectionFrom:0,selectionTo:0,transactionCount:0};function wJ({className:$,content:M,keybindings:J,onContentChange:Z,onStateChange:A,presence:X,theme:N}){let Y=r7(),Q=z1(null),K=z1(null),q=z1(null),U=z1(null),G=z1(null),B=z1(HG),F=z1(null),_=z1(null),D=z1(null),y=z1(!1),b=z1(M),O=z1(""),k=z1(OJ),j=z1(null),[R,w]=b$(!1),{theme:L,themeStyles:V}=GJ(N),[T,P]=b$(OJ),E=u0(()=>W6(M),[M]),W=u0(()=>s4(E),[E]),[z,u]=b$(()=>Y.createState(E)),p=x7(z.documentIndex.document),I=u0(()=>[...p.images.values()].some((H)=>H.status==="loading"),[p]);G.current=z,O.current||=W;let e=_J({editor:Y,editorState:z,editorStateRef:G,renderResources:p,theme:L}),{actions:f,props:m,refs:v,state:Z1}=e,{getScrollTop:o,observePreparedViewport:_1,observeScrollContainer:T2,resolvePointerPoint:$0,scrollTo:R1}=f,{layoutWidth:M0,preparedViewport:K1,scrollContentHeight:C4,surfaceWidth:R4,viewportHeight:m0,viewportTop:c5}=Z1,{scrollContainer:d1}=v,w4=u0(()=>Y.getPreviewState(z),[Y,z]),m1=u0(()=>Y.getCommentState(z),[Y,z]),w1=u0(()=>Y.normalizeSelection(z),[Y,z]),E4=u0(()=>RJ(z,m1.liveRanges),[m1.liveRanges,z]),P1=Boolean(Z),n=()=>G.current??z,O$=G1((H,C)=>{let g=Y.getPreviewState(H),c=Y.getCommentState(H),x=t7(H),a={activeBlockType:g.activeBlock?.nodeType??null,activeCommentThreadIndex:RJ(H,c.liveRanges),activeSpanKind:g.activeSpan.kind==="none"?null:g.activeSpan.kind,canonicalContent:C,characterCount:C.length,commentThreadCount:c.threads.length,docChangeCount:B.current.docChangeCount,lastTransactionMs:B.current.lastTransactionMs,layoutWidth:M0,lineCount:PG(C),resolvedCommentCount:Q6(c.threads),selectionFrom:x.start,selectionTo:x.end,transactionCount:B.current.transactionCount};if(P((W0)=>T$(W0,a)?W0:a),!T$(k.current,a))k.current=a,A?.(a)}),t=G1((H)=>{if(!H)return;let C=performance.now();G.current=H.state,u(H.state),B.current={docChangeCount:B.current.docChangeCount+(H.documentChanged?1:0),lastTransactionMs:performance.now()-C,transactionCount:B.current.transactionCount+1};let g=K1.current;if(!(!H.documentChanged||!g||g.layout.regionLineIndices.has(H.state.selection.focus.regionId)))K1.invalidate();if(H.animationStarted)V1("viewport");if(!H.documentChanged)return;let x=Y.getDocument(H.state),a=s4(x);O.current=a,b.current=a,Z?.(a,x)}),C$=G1((H=K1.current)=>{if(!H)return;let C=H$(K.current,{paintHeight:H.paintHeight,paintTop:H.paintTop,width:M0});if(!C)return;let{context:g,devicePixelRatio:c,height:x,width:a}=C;Y.paintContent(z,H,g,{activeBlockId:w4.activeBlock?.blockId??null,activeRegionId:z.selection.focus.regionId,activeThreadIndex:w$??E4,devicePixelRatio:c,height:x,liveCommentRanges:m1.liveRanges,normalizedSelection:w1,now:performance.now(),resources:p,theme:L,width:a})}),R$=G1((H=K1.current)=>{if(!H)return;let C=H$(q.current,{paintHeight:H.paintHeight,paintTop:H.paintTop,width:M0});if(!C)return;let{context:g,devicePixelRatio:c,height:x,width:a}=C;Y.paintOverlay(z,H,g,{devicePixelRatio:c,height:x,normalizedSelection:w1,presence:d5.canvasPresence,showCaret:w1.start.regionId!==w1.end.regionId||w1.start.offset!==w1.end.offset||a1.isVisible(),theme:L,width:a})}),EJ=G1(()=>{K1.invalidate();let H=K1.get();_1(H),d5.refreshViewportPresence(H),C$(H),R$(H)}),{scheduleRender:V1}=XJ({hasRunningAnimations:()=>Y.hasRunningAnimations(G.current??z,performance.now()),renderContent:C$,renderOverlay:R$,renderViewport:EJ}),jJ=m.getScrollContainer({onScroll:()=>V1("viewport")}),a1=nM({canShowInsertionLeaf:Boolean(Z),canShowTableLeaf:Boolean(Z),commentState:m1,editor:Y,editorState:z,editorViewportState:K1,onVisibilityChange:()=>V1("overlay")}),E1=a7({commentState:m1,editor:Y,editorStateRef:G,editorViewportState:K1,resolveDocumentPoint:$0}),w$=E1.leaf?.kind==="comment"?E1.leaf.threadIndex:null,LJ=G1((H)=>{T2(H),V1("viewport")}),d5=AJ({editor:Y,editorState:z,editorStateRef:G,editorViewportState:K1,onViewportScroll:LJ,presence:X,scrollContainerRef:d1,scheduleOverlayRender:()=>V1("overlay")}),E$=G1((H,C)=>{if(H.scrollHeight<=H.clientHeight||C.deltaY===0)return;let g=24,c=C.deltaMode===1?g:C.deltaMode===2?H.clientHeight:1,x=Math.max(0,Math.min(H.scrollHeight-H.clientHeight,H.scrollTop+C.deltaY*c));if(x===H.scrollTop)return;C.preventDefault(),R1(x),V1("viewport")}),P2=MJ({editor:Y,editorState:z,editorStateRef:G,editorViewportState:K1,inputRef:U,keybindings:J,onActivity:a1.markActivity,onEditorStateChange:t}),v1=QJ({autoScrollContainer:(H)=>{q$(d1.current,H)},canShowSelectionLeaf:P1,canvasRef:K,threads:m1.threads,editor:Y,editorState:z,editorStateRef:G,scrollContainerRef:d1,editorViewportState:K1,onActivity:a1.markActivity,onEditorStateChange:t}),kJ=G1(()=>{K.current?.focus({preventScroll:!0})}),j$=G1((H)=>{let C=K.current;if(C&&F.current===H)C.releasePointerCapture(H)}),L$=G1(()=>{F.current=null,_.current=null}),fJ=G1((H)=>{j$(H.pointerId),L$(),D.current=null,y.current=!1}),SJ=G1((H)=>{let C=K.current,g=n(),c=$0(H);if(!c)return;let x=E1.resolveTarget(H);if(x?.kind==="task-toggle"){H.preventDefault(),H.stopPropagation(),D.current=x.listItemId,a1.markActivity(),kJ();return}let a=Y.resolveSelectionHit(g,K1.get(),c);if(!C||!a)return;F.current=H.pointerId,_.current={offset:a.offset,regionId:a.regionId},a1.markActivity(),C.setPointerCapture(H.pointerId),t(Y.setSelection(g,{offset:a.offset,regionId:a.regionId})),P2.focus({offset:a.offset,regionId:a.regionId})}),uJ=G1(()=>{E1.canvasHandlers.onPointerLeave(),y.current=!1}),mJ=G1((H)=>{let C=_.current,g=n(),c=$0(H);if(!c)return;if(E1.canvasHandlers.onPointerMove(H),F.current!==H.pointerId||!C)return;let x=Y.resolveDragFocus(g,K1.get(),c,C);if(!x)return;a1.markActivity(),q$(d1.current,H),t(Y.setSelection(g,{anchor:C,focus:x}))}),vJ=G1((H)=>{let C=n();if(j$(H.pointerId),D.current){let g=Y.toggleTaskItem(C,D.current);if(D.current=null,g)y.current=!0,H.preventDefault(),H.stopPropagation(),a1.markActivity(),t(g)}L$()}),gJ=G1((H)=>{if(y.current){y.current=!1,D.current=null,H.preventDefault(),H.stopPropagation();return}if(E1.canvasHandlers.onClick(H))return;D.current=null,P2.focus()}),IJ=G1((H)=>{let C=n(),g=$0(H),c=E1.resolveTarget(H);if(!g||c?.kind==="task-toggle")return;let x=Y.resolveWordSelection(C,K1.get(),g);if(!x)return;H.preventDefault(),H.stopPropagation(),a1.markActivity(),t(Y.setSelection(C,x)),P2.focus()});S0(()=>{w(!0)},[]),DG(()=>{if(M===b.current)return;let H=G.current,C=WJ(H,Y.createState(E)),g=C.state,c=C.didReconcile?o():0;G.current=g,u(g),b.current=M,O.current=W,R1(c)},[W,M,E,Y,o,R1]),S0(()=>{O$(z,O.current||W)},[W,z,O$,R4]),S0(()=>{let H=d1.current,C=z.selection.focus;if(!H)return;let g={layoutWidth:M0,offset:C.offset,regionId:C.regionId,scrollContentHeight:C4,viewportHeight:m0};if(WG(j.current,g))return;let c=24,x=Y.measureCaretTarget(z,K1.get(),C);if(!x)return;let a=m0,W0=H.scrollTop,cJ=W0+c,dJ=W0+a-c;if(x.top<cJ){let a5=R1(Math.max(0,x.top-c));if(CJ(x,a5,a,c))j.current=g;return}if(x.top+x.height>dJ){let a5=R1(Math.max(0,x.top+x.height-a+c));if(CJ(x,a5,a,c))j.current=g;return}j.current=g},[Y,z,z.selection.focus.offset,z.selection.focus.regionId,K1,M0,C4,R1,m0]),S0(()=>{V1("viewport")},[m1.liveRanges,z,M0,w1.end.regionId,w1.end.offset,w1.start.regionId,w1.start.offset,w4.activeBlock?.blockId,L,p,E4,V1,m0]),S0(()=>{if(!I)return;let H=null,C=window,g=()=>{V1("viewport"),H=C.requestAnimationFrame(g)};return H=C.requestAnimationFrame(g),()=>{if(H!==null)C.cancelAnimationFrame(H)}},[I,V1]),S0(()=>{V1("content")},[w$,V1]),S0(()=>{let H=d1.current;if(!H)return;let C=(g)=>{E$(H,g)};return H.addEventListener("wheel",C,{passive:!1}),()=>{H.removeEventListener("wheel",C)}},[E$]);let hJ=$?`documint ${$}`:"documint",pJ=()=>{let H=E1.leaf,C=H??v1.leaf??a1.leaf,g=!H&&Boolean(v1.leaf),c=d1.current?.getBoundingClientRect()??null,x=C?.kind==="thread"?{...C,thread:m1.threads[C.threadIndex]??null}:null,a=C?.kind==="comment"?{animateInitialComment:!1,link:C.link,thread:C.thread,threadIndex:C.threadIndex}:x?.thread?{animateInitialComment:x.animateInitialComment??!1,link:null,thread:x.thread,threadIndex:x.threadIndex}:null,W0=a?.thread&&A0(a.thread)?"resolved":"default";return{annotationThreadLeaf:a,visibleLeaf:C,visibleLeafAnchor:C?{container:Q.current,isSelection:g,left:(c?.left??0)+C.left,onPointerEnter:H?E1.leafHandlers.onPointerEnter:void 0,onPointerLeave:H?E1.leafHandlers.onPointerLeave:void 0,top:(c?.top??0)+C.top-c5+(g?TG:0)}:void 0,visibleLeafClassName:C?.kind==="link"?"documint-link-leaf":void 0,visibleLeafStatus:W0}},{annotationThreadLeaf:g1,visibleLeaf:D1,visibleLeafAnchor:k$,visibleLeafClassName:lJ,visibleLeafStatus:xJ}=pJ(),rJ=(()=>{if(!D1)return null;switch(D1.kind){case"insertion":return N1(lM,{onInsert:(H)=>{t(Y.insertText(n(),H))},onInsertTable:(H)=>{t(Y.insertTable(n(),H))}},void 0,!1,void 0,this);case"table":return N1(sM,{canDeleteColumn:D1.columnCount>1,canDeleteRow:D1.rowCount>1,onDeleteColumn:()=>{t(Y.deleteTableColumn(n()))},onDeleteRow:()=>{t(Y.deleteTableRow(n()))},onDeleteTable:()=>{t(Y.deleteTable(n()))},onInsertColumn:(H)=>{t(Y.insertTableColumn(n(),H))},onInsertRow:(H)=>{t(Y.insertTableRow(n(),H))}},void 0,!1,void 0,this);case"link":return N1(dM,{canEdit:P1,onDelete:()=>{let H=Y.removeLink(n(),D1.regionId,D1.startOffset,D1.endOffset);if(H)t(H)},onSave:(H)=>{let C=Y.updateLink(n(),D1.regionId,D1.startOffset,D1.endOffset,H);if(C)t(C)},title:D1.title,url:D1.url},void 0,!1,void 0,this);case"create":return N1(C6,{activeMarks:D1.activeMarks,canEdit:P1,link:null,mode:"create",onCreateThread:(H)=>{let C=n(),g=Y.getDocument(C).comments.length,c=Y.createCommentThread(C,D1.selection,H.trim());if(!c)return;t(c),v1.promoteLeafToThread(g,!0)},onToggleBold:()=>{t(Y.toggleBold(n()))},onToggleItalic:()=>{t(Y.toggleItalic(n()))},onToggleStrikethrough:()=>{t(Y.toggleStrikethrough(n()))},onToggleUnderline:()=>{t(Y.toggleUnderline(n()))}},void 0,!1,void 0,this);default:return g1?N1(C6,{animateInitialComment:g1.animateInitialComment,canEdit:P1,link:g1.link,mode:"thread",onDeleteComment:(H)=>{t(Y.deleteComment(n(),g1.threadIndex,H))},onDeleteThread:()=>{t(Y.deleteCommentThread(n(),g1.threadIndex))},onEditComment:(H,C)=>{t(Y.editComment(n(),g1.threadIndex,H,C))},onReply:(H)=>{t(Y.replyToCommentThread(n(),g1.threadIndex,H))},onToggleResolved:()=>{t(Y.markCommentThreadAsResolved(n(),g1.threadIndex,!A0(g1.thread)))},thread:g1.thread},void 0,!1,void 0,this):null}})();return N1("section",{className:hJ,"data-active-block":T.activeBlockType??"","data-active-comment-thread":T.activeCommentThreadIndex??"","data-active-span":T.activeSpanKind??"",ref:Q,style:{...V,height:"100%",minHeight:0},children:[N1("style",{children:bJ},void 0,!1,void 0,this),N1("div",{...jJ,className:"documint-scroll-container",style:{height:"100%",minHeight:0},children:[N1("textarea",{...P2.inputHandlers,ref:U,autoCapitalize:"sentences",className:"documint-input",spellCheck:!1,tabIndex:-1},void 0,!1,void 0,this),N1(JM,{insetX:L.paddingX,insetY:L.paddingY,...d5.presenceOverlayProps},void 0,!1,void 0,this),N1("div",{...m.scrollContent,className:"documint-scroll-content",children:[N1("canvas",{...P2.canvasHandlers,"aria-label":"Documint editor",className:"documint-content-canvas",style:{cursor:E1.cursor},onPointerCancel:fJ,onPointerDown:SJ,onPointerLeave:uJ,onPointerMove:mJ,onPointerUp:vJ,onClick:gJ,onDoubleClick:IJ,ref:K,tabIndex:0},void 0,!1,void 0,this),N1("canvas",{"aria-hidden":"true",className:"documint-overlay-canvas",ref:q},void 0,!1,void 0,this),v1.handles?N1(zG,{children:[N1("div",{"aria-hidden":"true",className:"documint-selection-handle documint-selection-handle-start",style:{left:`${v1.handles.start.left}px`,top:`${v1.handles.start.top}px`},...v1.startHandleProps,children:N1("span",{className:"documint-selection-handle-knob"},void 0,!1,void 0,this)},void 0,!1,void 0,this),N1("div",{"aria-hidden":"true",className:"documint-selection-handle documint-selection-handle-end",style:{left:`${v1.handles.end.left}px`,top:`${v1.handles.end.top}px`},...v1.endHandleProps,children:N1("span",{className:"documint-selection-handle-knob"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,D1&&k$?N1(xM,{anchor:k$,className:lJ,status:xJ,children:rJ},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),!R?N1("div",{className:"documint-fallback",children:N1(x5,{blocks:E.blocks},void 0,!1,void 0,this)},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function PG($){return $.length===0?0:$.split(`
|
|
898
|
+
`).length}function WG($,M){return $?.layoutWidth===M.layoutWidth&&$.regionId===M.regionId&&$.offset===M.offset&&$.scrollContentHeight===M.scrollContentHeight&&$.viewportHeight===M.viewportHeight}function CJ($,M,J,Z){return $.top>=M+Z&&$.top+$.height<=M+J-Z}function RJ($,M){let J=new Map($.documentIndex.regions.map((Q,K)=>[Q.id,K])),Z=r5(J,$.selection.anchor.regionId,$.selection.anchor.offset),A=r5(J,$.selection.focus.regionId,$.selection.focus.offset),[X,N]=Z<=A?[Z,A]:[A,Z],Y=Z===A;for(let Q of M){let K=r5(J,Q.regionId,Q.startOffset),q=r5(J,Q.regionId,Q.endOffset);if(Y){if(X>=K&&X<=q)return Q.threadIndex;continue}if(Math.max(X,K)<Math.min(N,q))return Q.threadIndex}return null}function r5($,M,J){return($.get(M)??-1)*1e6+J}export{KJ as mintTheme,qJ as midnightTheme,b4 as lightTheme,Y$ as defaultKeybindings,O4 as darkTheme,wJ as Documint};
|