documint 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +20 -29
- package/dist/index.js +32 -33
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import{useEffect as
|
|
2
|
-
`);return{id:
|
|
3
|
-
`);return{align:$.align??[],id:
|
|
4
|
-
`;case"image":return M.alt??"";case"inlineCode":return M.code;case"link":return
|
|
1
|
+
import{useEffect as k0,useEffectEvent as B1,useLayoutEffect as vG,useMemo as f0,useRef as y1,useState as MM}from"react";function _2($){let M=F1($.children);return{children:$.children,id:G1($.path,"paragraph",M),plainText:M,type:"paragraph"}}function I($){return _2({children:NM(void 0,$.text)})}function h4($){let M=F1($.children);return{children:$.children,depth:$.depth,id:G1($.path,"heading",`${$.depth}:${M}`),plainText:M,type:"heading"}}function Z0($){return h4({children:NM(void 0,$.text),depth:$.depth})}function W1($){let M=$.marks??[];return{id:G1($.path,"text",`${$.text}:${M.join(",")}`),marks:M,text:$.text,type:"text"}}function H2($={}){return{id:G1($.path,"break","break"),type:"break"}}function S0($){return{code:$.code,id:G1($.path,"inlineCode",$.code),type:"inlineCode"}}function m0($){return{children:$.children,id:G1($.path,"link",`${$.url}:${F1($.children)}`),title:$.title??null,type:"link",url:$.url}}function I4($){let M=$.alt??null,J=$.width??null;return{alt:M,id:G1($.path,"image",`${$.url}:${J??""}:${M??""}`),title:$.title??null,type:"image",url:$.url,width:J}}function p4($){return{id:G1($.path,"unsupported",$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}function n1($){let M=g0($.children);return{checked:$.checked??null,children:$.children,id:G1($.path,"listItem",M),plainText:M,spread:$.spread??!1,type:"listItem"}}function y0($){let M=$.items.map((J)=>J.plainText).join(`
|
|
2
|
+
`);return{id:G1($.path,"list",`${String($.ordered)}:${M}`),items:$.items,ordered:$.ordered,plainText:M,spread:$.spread??!1,start:$.start??null,type:"list"}}function T1($){let M=g0($.children);return{children:$.children,id:G1($.path,"blockquote",M),plainText:M,type:"blockquote"}}function N6($){return{id:G1($.path,"code",`${$.language??""}:${$.source}`),language:$.language??null,meta:$.meta??null,plainText:$.source,source:$.source,type:"code"}}function X0($){let M=F1($.children);return{children:$.children,id:G1($.path,"tableCell",M),plainText:M}}function v0($){return{cells:$.cells,id:G1($.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:G1($.path,"table",M),plainText:M,rows:$.rows,type:"table"}}function l4(){return{id:"",plainText:"",type:"thematicBreak"}}function r4($){return{id:G1($.path,"unsupported",$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}function qM($){return{attributes:$.attributes,body:$.body,id:G1($.path,"directive",`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"}}function k1($,M){return $.type==="heading"?h4({children:M,depth:$.depth}):_2({children:M})}function b1($,M){return n1({checked:$.checked,children:M,spread:$.spread})}function $1($,M,J={}){return y0({items:M,ordered:J.ordered??$.ordered,spread:J.spread??$.spread,start:J.start??$.start})}function r1($,M){return V0({align:$.align,rows:M})}function c4($,M){return N6({language:$.language,meta:$.meta,source:M})}function x4($,M){return r4({originalType:$.originalType,source:M})}function NM($,M){return M.length>0?[W1({path:$?`${$}.children.0`:void 0,text:M})]:[]}function G1($,M,J){return $?Q1(M,$,J):""}function h0($,M=[]){return{blocks:$.map((J,Z)=>U6(J,Z)),comments:M}}function I0($,M,J,Z){let X=Z.map((Q,K)=>U6(Q,M+K)),A=$.blocks.slice(M+J),Y=Z.length===J?A:A.map((Q,K)=>U6(Q,M+X.length+K));return{blocks:[...$.blocks.slice(0,M),...X,...Y],comments:$.comments}}function UM($,M,J,Z){return{blocks:$.blocks,comments:[...$.comments.slice(0,M),...Z,...$.comments.slice(M+J)]}}function F1($){return $.map((M)=>{switch(M.type){case"break":return`
|
|
4
|
+
`;case"image":return M.alt??"";case"inlineCode":return M.code;case"link":return F1(M.children);case"text":return M.text;case"unsupported":return M.source}}).join("")}function g0($){return $.map((M)=>{switch(M.type){case"blockquote":case"listItem":return g0(M.children);case"code":return M.source;case"directive":return M.body;case"heading":case"paragraph":return F1(M.children);case"list":return M.items.map((J)=>J.plainText).join(`
|
|
5
5
|
`);case"table":return M.rows.map((J)=>J.cells.map((Z)=>Z.plainText).join(" | ")).join(`
|
|
6
6
|
`);case"thematicBreak":return"";case"unsupported":return M.source}}).join(`
|
|
7
|
-
`).trim()}function
|
|
8
|
-
`);return{id:
|
|
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,`
|
|
7
|
+
`).trim()}function U6($,M){return d4($,`root.${M}`)}function d4($,M){switch($.type){case"blockquote":{let J=$.children.map((X,A)=>d4(X,`${M}.children.${A}`)),Z=g0(J);return{children:J,id:Q1("blockquote",M,Z),plainText:Z,type:"blockquote"}}case"code":return{id:Q1("code",M,`${$.language??""}:${$.source}`),language:$.language,meta:$.meta,plainText:$.source,source:$.source,type:"code"};case"directive":return{attributes:$.attributes,body:$.body,id:Q1("directive",M,`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"};case"heading":{let J=$.children.map((X,A)=>a4(X,`${M}.children.${A}`)),Z=F1(J);return{children:J,depth:$.depth,id:Q1("heading",M,`${$.depth}:${Z}`),plainText:Z,type:"heading"}}case"list":{let J=$.items.map((X,A)=>d4(X,`${M}.children.${A}`)),Z=J.map((X)=>X.plainText).join(`
|
|
8
|
+
`);return{id:Q1("list",M,`${String($.ordered)}:${Z}`),items:J,ordered:$.ordered,plainText:Z,spread:$.spread,start:$.start,type:"list"}}case"listItem":{let J=$.children.map((X,A)=>d4(X,`${M}.children.${A}`)),Z=g0(J);return{checked:$.checked,children:J,id:Q1("listItem",M,Z),plainText:Z,spread:$.spread,type:"listItem"}}case"paragraph":{let J=$.children.map((X,A)=>a4(X,`${M}.children.${A}`)),Z=F1(J);return{children:J,id:Q1("paragraph",M,Z),plainText:Z,type:"paragraph"}}case"table":{let J=$.rows.map((X,A)=>AZ(X,`${M}.rows.${A}`)),Z=J.map((X)=>X.cells.map((A)=>A.plainText).join(" | ")).join(`
|
|
9
|
+
`);return{align:$.align,id:Q1("table",M,Z),plainText:Z,rows:J,type:"table"}}case"thematicBreak":return{id:Q1("thematicBreak",M,"thematic-break"),plainText:"",type:"thematicBreak"};case"unsupported":return{id:Q1("unsupported",M,$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}}function AZ($,M){return{cells:$.cells.map((J,Z)=>{let X=J.children.map((Y,Q)=>a4(Y,`${M}.cells.${Z}.children.${Q}`)),A=F1(X);return{children:X,id:Q1("tableCell",`${M}.cells.${Z}`,A),plainText:A}}),id:Q1("tableRow",M,String($.cells.length))}}function a4($,M){switch($.type){case"break":return{id:Q1("break",M,"break"),type:"break"};case"image":return{alt:$.alt,id:Q1("image",M,`${$.url}:${$.width??""}:${$.alt??""}`),title:$.title,type:"image",url:$.url,width:$.width};case"inlineCode":return{code:$.code,id:Q1("inlineCode",M,$.code),type:"inlineCode"};case"link":{let J=$.children.map((X,A)=>a4(X,`${M}.children.${A}`)),Z=F1(J);return{children:J,id:Q1("link",M,`${$.url}:${Z}`),title:$.title,type:"link",url:$.url}}case"text":return{id:Q1("text",M,`${$.text}:${$.marks.join(",")}`),marks:$.marks,text:$.text,type:"text"};case"unsupported":return{id:Q1("unsupported",M,$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}}function P2($){return $.map((M)=>{switch(M.type){case"blockquote":return{...M,children:P2(M.children)};case"heading":case"paragraph":return k1(M,G6(M.children));case"list":return{...M,items:M.items.map((J)=>({...J,children:P2(J.children)}))};case"listItem":return{...M,children:P2(M.children)};case"table":return r1(M,M.rows.map((J)=>({...J,cells:J.cells.map((Z)=>({...Z,children:G6(Z.children)}))})));default:return M}})}function G6($){let M=[...$];for(let J=M.length-1;J>=0;J-=1){let Z=M[J];if(Z.type==="text"){let X=Z.text.replace(/[ \t]+$/u,"");if(X.length===Z.text.length)return M;if(X.length===0){M.splice(J,1);continue}return M[J]={...Z,text:X},M}if(Z.type==="link"){let X=G6(Z.children);if(X.length===Z.children.length&&X.every((A,Y)=>A===Z.children[Y]))return M;if(X.length===0){M.splice(J,1);continue}return M[J]={...Z,children:X},M}return M}return M}function Q1($,M,J){let Z=2166136261;for(let X of`${$}:${M}:${J}`)Z^=X.charCodeAt(0),Z=Math.imul(Z,16777619);return`${$}-${(Z>>>0).toString(36)}`}function W2($,M){B6($.blocks,M,FM(),DM())}function BM($,M){B6($,M,FM(),DM())}function B6($,M,J,Z){for(let[X,A]of $.entries()){if(J.stopped)return;let Y=`${Z.pathPrefix}.${X}`,Q={blockAncestors:Z.blockAncestors,depth:Z.depth,parentBlock:Z.parentBlock,path:Y},K=M.enterBlock?.(A,Q);if(p0(K,J))return;if(K!=="skip")switch(A.type){case"list":GM(A.items,A,M,J,Z,Y);break;case"blockquote":case"listItem":GM(A.children,A,M,J,Z,Y);break;case"heading":case"paragraph":F6(A.children,M,J,{block:A,blockAncestors:[...Z.blockAncestors,A],inlineAncestors:[],parentInline:null,pathPrefix:`${Y}.children`});break;case"table":QZ(A,M,J,{blockAncestors:[...Z.blockAncestors,A],pathPrefix:Y});break;case"code":case"directive":case"thematicBreak":case"unsupported":break}if(J.stopped)return;if(p0(M.leaveBlock?.(A,Q),J))return}}function F6($,M,J,Z){for(let[X,A]of $.entries()){if(J.stopped)return;let Y=`${Z.pathPrefix}.${X}`,Q={block:Z.block,blockAncestors:Z.blockAncestors,inlineAncestors:Z.inlineAncestors,parentInline:Z.parentInline,path:Y},K=M.enterInline?.(A,Q);if(p0(K,J))return;if(K!=="skip"){if(A.type==="link")YZ(A.children,A,M,J,Z,Y)}if(J.stopped)return;if(p0(M.leaveInline?.(A,Q),J))return}}function FM(){return{stopped:!1}}function DM(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function GM($,M,J,Z,X,A){B6($,J,Z,{blockAncestors:[...X.blockAncestors,M],depth:X.depth+1,parentBlock:M,pathPrefix:`${A}.children`})}function YZ($,M,J,Z,X,A){F6($,J,Z,{block:X.block,blockAncestors:X.blockAncestors,inlineAncestors:[...X.inlineAncestors,M],parentInline:M,pathPrefix:`${A}.children`})}function QZ($,M,J,Z){for(let[X,A]of $.rows.entries())for(let[Y,Q]of A.cells.entries()){if(J.stopped)return;let K=`${Z.pathPrefix}.rows.${X}.cells.${Y}`,q={blockAncestors:Z.blockAncestors,cellIndex:Y,path:K,row:A,rowIndex:X,table:$},N=M.enterTableCell?.(Q,q);if(p0(N,J))return;if(N!=="skip")F6(Q.children,M,J,{block:$,blockAncestors:Z.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${K}.children`});if(J.stopped)return;if(p0(M.leaveTableCell?.(Q,q),J))return}}function p0($,M){if($!=="stop")return!1;return M.stopped=!0,!0}var D6="text";function _6($){return $==="text"||$==="code"||$==="tableCell"}function s4($){return $===D6?void 0:$}function i4($){let M=[];return W2($,{enterBlock(J){switch(J.type){case"heading":case"paragraph":M.push({containerKind:"text",containerOrdinal:M.length,id:J.id,text:F1(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:F1(J.children)})}}),M}function _M($){let M=new Set;return W2($,{enterInline(J){if(J.type==="image")M.add(J.url)}}),[...M]}function l0($,M){let J=null;return KZ($,{enterBlock(Z){if(Z.id===M)return J=Z,"stop"}}),J}function KZ($,M){if(Array.isArray($)){BM($,M);return}W2($,M)}var HM=24;function T2($,M,J){let Z=r0(M,0,$.text.length),X=r0(J,Z,$.text.length);return{kind:s4($.containerKind),prefix:$.text.slice(Math.max(0,Z-HM),Z)||void 0,suffix:$.text.slice(X,X+HM)||void 0}}function y2($,M,J){let Z=r0(M,0,$.text.length),X=r0(J,Z,$.text.length);return $.text.slice(Z,X)}var PM=48,WM=64,qZ=32;function V2($,M){let J=$.anchor.kind??D6,Z=i4(M).filter((Y)=>Y.containerKind===J),X=NZ($,Z);if(X.length>0)return TM($,X,null);let A=UZ($,Z);if(A.length>0)return TM($,A,"repaired");return{match:null,repair:null,status:"stale"}}function NZ($,M){let J=[],Z=$.quote;if(Z.length===0)return J;for(let X of M){let A=0;while(A<=X.text.length){let Y=X.text.indexOf(Z,A);if(Y===-1)break;J.push({container:X,endOffset:Y+Z.length,score:FZ($,X,Y),startOffset:Y}),A=Y+Math.max(1,Z.length)}}return J.sort((X,A)=>A.score-X.score),J}function UZ($,M){let J=[];for(let Z of M)J.push(...GZ($,Z));return J.sort((Z,X)=>X.score-Z.score),J}function GZ($,M){let J=[],Z=$.quote.length,X=M.text,A=$.anchor.prefix??"",Y=$.anchor.suffix??"";if(A.length>0&&Y.length>0){let Q=0;while(Q<=X.length){let K=X.indexOf(A,Q);if(K===-1)break;let q=K+A.length,N=X.indexOf(Y,q);if(N!==-1&&N>=q)J.push({container:M,endOffset:N,score:H6($,M,q,N,Z),startOffset:q});Q=K+Math.max(1,A.length)}return J}if(A.length>0){let Q=0;while(Q<=X.length){let K=X.indexOf(A,Q);if(K===-1)break;let q=K+A.length,N=r0(q+Z,q,X.length);J.push({container:M,endOffset:N,score:H6($,M,q,N,Z),startOffset:q}),Q=K+Math.max(1,A.length)}return J}if(Y.length>0){let Q=0;while(Q<=X.length){let K=X.indexOf(Y,Q);if(K===-1)break;let q=K,N=r0(q-Z,0,q);J.push({container:M,endOffset:q,score:H6($,M,N,q,Z),startOffset:N}),Q=K+Math.max(1,Y.length)}}return J}function TM($,M,J){let[Z,X]=M;if(!Z)return{match:null,repair:null,status:"stale"};if(X&&Z.score===X.score)return{match:null,repair:null,status:"ambiguous"};let A=T2(Z.container,Z.startOffset,Z.endOffset),Y=y2(Z.container,Z.startOffset,Z.endOffset),Q=J??(Y===$.quote&&(A.prefix??"")===($.anchor.prefix??"")&&(A.suffix??"")===($.anchor.suffix??"")?"matched":"repaired");return{match:BZ(Z.container,Z.startOffset,Z.endOffset),repair:{anchor:A,quote:Y},status:Q}}function BZ($,M,J){return{containerId:$.id,containerKind:$.containerKind,containerOrdinal:$.containerOrdinal,endOffset:J,startOffset:M}}function FZ($,M,J){let Z=0;if(yM(M.text,$.anchor.prefix,J))Z+=PM;if(VM(M.text,$.anchor.suffix,J+$.quote.length))Z+=PM;return Z}function H6($,M,J,Z,X){let A=0;if(yM(M.text,$.anchor.prefix,J))A+=WM;if(VM(M.text,$.anchor.suffix,Z))A+=WM;if(A+=Math.max(0,qZ-Math.abs(X-(Z-J))),$.quote.length>0){let Y=M.text.slice(J,Z);if(Y.length>0)A+=DZ($.quote,Y),A+=_Z($.quote,Y)}return A}function yM($,M,J){if(!M)return!1;return $.slice(Math.max(0,J-M.length),J)===M}function VM($,M,J){if(!M)return!1;return $.slice(J,J+M.length)===M}function DZ($,M){let J=0;while(J<$.length&&J<M.length&&$[J]===M[J])J+=1;return J}function _Z($,M){let J=0;while(J<$.length&&J<M.length&&$[$.length-1-J]===M[M.length-1-J])J+=1;return J}function r0($,M,J){return Math.min(Math.max($,M),J)}function P6($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$,J=PZ(M.anchor),Z=typeof M.quote==="string"?M.quote:null,X=Array.isArray(M.comments)?M.comments.flatMap((A)=>{let Y=HZ(A);return Y?[Y]:[]}):[];if(!J||!Z||X.length===0)return null;return{quote:Z,anchor:J,comments:X,resolvedAt:typeof M.resolvedAt==="string"?M.resolvedAt:void 0}}function HZ($){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 PZ($){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)?s4(M):void 0,prefix:typeof J==="string"?J:void 0,suffix:typeof Z==="string"?Z:void 0}}function W6($){let M=$.createdAt??new Date().toISOString();return{comments:[zM({body:$.body,updatedAt:M})],quote:$.quote,anchor:$.anchor}}function T6($,M){let J=zM(M);return{...$,comments:[...$.comments,J]}}function y6($,M,J,Z=new Date().toISOString()){let X=J.trim();if(X.length===0)return $;let A=!1,Y=$.comments.map((Q,K)=>{if(K!==M||Q.body===X)return Q;return A=!0,{...Q,body:X,updatedAt:Z}});if(!A)return $;return{...$,comments:Y}}function V6($,M){let J=$.comments.filter((Z,X)=>X!==M);if(J.length===$.comments.length)return $;if(J.length===0)return null;return{...$,comments:J}}function z6($,M,J=new Date().toISOString()){if(A0($)===M)return $;return{...$,resolvedAt:M?J:void 0}}function A0($){return $.resolvedAt!=null}function O6($){return $.filter((M)=>A0(M)).length}function b6($){if($.comments.length===0)return null;return $.comments.reduce((M,J)=>J.updatedAt>M?J.updatedAt:M,$.comments[0].updatedAt)}function zM($){let M=$.updatedAt??new Date().toISOString();return{body:$.body,updatedAt:M}}function z0(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function OM($,M,J){return z2($.preparedText,M,J,256)}function bM($,M,J){return z2($.measuredLines,M,J,512)}function CM($,M,J){return z2($.lineBoundaries,M,J,1024)}function EM($,M,J){return z2($.measuredContainerHeights,M,J,1024)}function wM($,M){let J=$.graphemeWidths.get(M);if(J)return J;let Z=new Map;return z2($.graphemeWidths,M,Z,64),Z}function jM($,M,J){return $.viewportPlans.get(M)?.get(J)??null}function RM($,M,J,Z){let X=$.viewportPlans.get(M)??new Map;return X.set(J,Z),$.viewportPlans.set(M,X),Z}function z2($,M,J,Z){if($.has(M))$.delete(M);if($.set(M,J),$.size>Z){let X=$.keys().next().value;if(X!==void 0)$.delete(X)}return J}var WZ=["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"],TZ=["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 yZ($){if($<=255)return WZ[$];if(1424<=$&&$<=1524)return"R";if(1536<=$&&$<=1791)return TZ[$&255];if(1792<=$&&$<=2220)return"AL";return"L"}function VZ($){let M=$.length;if(M===0)return null;let J=Array(M),Z=0;for(let q=0;q<M;q++){let N=yZ($.charCodeAt(q));if(N==="R"||N==="AL"||N==="AN")Z++;J[q]=N}if(Z===0)return null;let X=M/Z<0.3?0:1,A=new Int8Array(M);for(let q=0;q<M;q++)A[q]=X;let Y=X&1?"R":"L",Q=Y,K=Q;for(let q=0;q<M;q++)if(J[q]==="NSM")J[q]=K;else K=J[q];K=Q;for(let q=0;q<M;q++){let N=J[q];if(N==="EN")J[q]=K==="AL"?"AN":"EN";else if(N==="R"||N==="L"||N==="AL")K=N}for(let q=0;q<M;q++)if(J[q]==="AL")J[q]="R";for(let q=1;q<M-1;q++){if(J[q]==="ES"&&J[q-1]==="EN"&&J[q+1]==="EN")J[q]="EN";if(J[q]==="CS"&&(J[q-1]==="EN"||J[q-1]==="AN")&&J[q+1]===J[q-1])J[q]=J[q-1]}for(let q=0;q<M;q++){if(J[q]!=="EN")continue;let N;for(N=q-1;N>=0&&J[N]==="ET";N--)J[N]="EN";for(N=q+1;N<M&&J[N]==="ET";N++)J[N]="EN"}for(let q=0;q<M;q++){let N=J[q];if(N==="WS"||N==="ES"||N==="ET"||N==="CS")J[q]="ON"}K=Q;for(let q=0;q<M;q++){let N=J[q];if(N==="EN")J[q]=K==="L"?"L":"EN";else if(N==="R"||N==="L")K=N}for(let q=0;q<M;q++){if(J[q]!=="ON")continue;let N=q+1;while(N<M&&J[N]==="ON")N++;let U=q>0?J[q-1]:Q,G=N<M?J[N]:Q,B=U!=="L"?"R":"L";if(B===(G!=="L"?"R":"L"))for(let F=q;F<N;F++)J[F]=B;q=N-1}for(let q=0;q<M;q++)if(J[q]==="ON")J[q]=Y;for(let q=0;q<M;q++){let N=J[q];if((A[q]&1)===0){if(N==="R")A[q]++;else if(N==="AN"||N==="EN")A[q]+=2}else if(N==="L"||N==="AN"||N==="EN")A[q]++}return A}function LM($,M){let J=VZ($);if(J===null)return null;let Z=new Int8Array(M.length);for(let X=0;X<M.length;X++)Z[X]=J[M[X]];return Z}var zZ=/[ \t\n\r\f]+/g,OZ=/[\t\n\r\f]| {2,}|^ | $/;function bZ($){let M=$??"normal";return M==="pre-wrap"?{mode:M,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:M,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function CZ($){if(!OZ.test($))return $;let M=$.replace(zZ," ");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 EZ($){if(!/[\r\f]/.test($))return $.replace(/\r\n/g,`
|
|
19
10
|
`);return $.replace(/\r\n/g,`
|
|
20
11
|
`).replace(/[\r\f]/g,`
|
|
21
|
-
`)}var
|
|
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
|
-
`){
|
|
24
|
-
`)break;let
|
|
25
|
-
`){let B=$[
|
|
26
|
-
`?
|
|
27
|
-
`?0:
|
|
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
|
-
`),
|
|
30
|
-
|
|
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=`
|
|
12
|
+
`)}var C6=null,wZ;function jZ(){if(C6===null)C6=new Intl.Segmenter(wZ,{granularity:"word"});return C6}var RZ=/\p{Script=Arabic}/u,o4=/\p{M}/u,uM=/\p{Nd}/u;function E6($){return RZ.test($)}function t1($){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 R6=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),O2=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),L6=new Set(["'","’"]),c0=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),LZ=new Set([":",".","،","؛"]),kZ=new Set(["၏"]),fZ=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function uZ($){if(k6($))return!0;let M=!1;for(let J of $){if(c0.has(J)){M=!0;continue}if(M&&o4.test(J))continue;return!1}return M}function SZ($){for(let M of $)if(!R6.has(M)&&!c0.has(M))return!1;return $.length>0}function mZ($){if(k6($))return!0;for(let M of $)if(!O2.has(M)&&!L6.has(M)&&!o4.test(M))return!1;return $.length>0}function k6($){let M=!1;for(let J of $){if(J==="\\"||o4.test(J))continue;if(O2.has(J)||c0.has(J)||L6.has(J)){M=!0;continue}return!1}return M}function vZ($){let M=Array.from($),J=M.length;while(J>0){let Z=M[J-1];if(o4.test(Z)){J--;continue}if(O2.has(Z)||L6.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 gZ($,M){if($.length===0)return!1;for(let J of $)if(J!==M)return!1;return!0}function hZ($){if(!E6($)||$.length===0)return!1;return LZ.has($[$.length-1])}function IZ($){if($.length===0)return!1;return kZ.has($[$.length-1])}function pZ($){if($.length<2||$[0]!==" ")return null;let M=$.slice(1);if(/^\p{M}+$/u.test(M))return{space:" ",marks:M};return null}function f6($){for(let M=$.length-1;M>=0;M--){let J=$[M];if(fZ.has(J))return!0;if(!c0.has(J))return!1}return!1}function lZ($,M){if(M.preserveOrdinarySpaces||M.preserveHardBreaks){if($===" ")return"preserved-space";if($==="\t")return"tab";if(M.preserveHardBreaks&&$===`
|
|
13
|
+
`)return"hard-break"}if($===" ")return"space";if($===" "||$===" "||$===""||$==="\uFEFF")return"glue";if($==="")return"zero-width-break";if($==="")return"soft-hyphen";return"text"}function e1($){return $.length===1?$[0]:$.join("")}function rZ($,M,J,Z){let X=[],A=null,Y=[],Q=J,K=!1,q=0;for(let N of $){let U=lZ(N,Z),G=U==="text"&&M;if(A!==null&&U===A&&G===K){Y.push(N),q+=N.length;continue}if(A!==null)X.push({text:e1(Y),isWordLike:K,kind:A,start:Q});A=U,Y=[N],Q=J+q,K=G,q+=N.length}if(A!==null)X.push({text:e1(Y),isWordLike:K,kind:A,start:Q});return X}function w6($){return $==="space"||$==="preserved-space"||$==="zero-width-break"||$==="hard-break"}var cZ=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function xZ($,M){let J=$.texts[M];if(J.startsWith("www."))return!0;return cZ.test(J)&&M+1<$.len&&$.kinds[M+1]==="text"&&$.texts[M+1]==="//"}function dZ($){return $.includes("?")&&($.includes("://")||$.startsWith("www."))}function aZ($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let Y=0;Y<$.len;Y++){if(Z[Y]!=="text"||!xZ($,Y))continue;let Q=[M[Y]],K=Y+1;while(K<$.len&&!w6(Z[K])){Q.push(M[K]),J[Y]=!0;let q=M[K].includes("?");if(Z[K]="text",M[K]="",K++,q)break}M[Y]=e1(Q)}let A=0;for(let Y=0;Y<M.length;Y++){let Q=M[Y];if(Q.length===0)continue;if(A!==Y)M[A]=Q,J[A]=J[Y],Z[A]=Z[Y],X[A]=X[Y];A++}return M.length=A,J.length=A,Z.length=A,X.length=A,{len:A,texts:M,isWordLike:J,kinds:Z,starts:X}}function sZ($){let M=[],J=[],Z=[],X=[];for(let A=0;A<$.len;A++){let Y=$.texts[A];if(M.push(Y),J.push($.isWordLike[A]),Z.push($.kinds[A]),X.push($.starts[A]),!dZ(Y))continue;let Q=A+1;if(Q>=$.len||w6($.kinds[Q]))continue;let K=[],q=$.starts[Q],N=Q;while(N<$.len&&!w6($.kinds[N]))K.push($.texts[N]),N++;if(K.length>0)M.push(e1(K)),J.push(!0),Z.push("text"),X.push(q),A=N-1}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}var iZ=new Set([":","-","/","×",",",".","+","–","—"]),kM=/^[A-Za-z0-9_]+[,:;]*$/,fM=/[,:;]+$/;function SM($){for(let M of $)if(uM.test(M))return!0;return!1}function j6($){if($.length===0)return!1;for(let M of $){if(uM.test(M)||iZ.has(M))continue;return!1}return!0}function oZ($){let M=[],J=[],Z=[],X=[];for(let A=0;A<$.len;A++){let Y=$.texts[A],Q=$.kinds[A];if(Q==="text"&&j6(Y)&&SM(Y)){let K=[Y],q=A+1;while(q<$.len&&$.kinds[q]==="text"&&j6($.texts[q]))K.push($.texts[q]),q++;M.push(e1(K)),J.push(!0),Z.push("text"),X.push($.starts[A]),A=q-1;continue}M.push(Y),J.push($.isWordLike[A]),Z.push(Q),X.push($.starts[A])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function nZ($){let M=[],J=[],Z=[],X=[];for(let A=0;A<$.len;A++){let Y=$.texts[A],Q=$.kinds[A],K=$.isWordLike[A];if(Q==="text"&&K&&kM.test(Y)){let q=[Y],N=fM.test(Y),U=A+1;while(N&&U<$.len&&$.kinds[U]==="text"&&$.isWordLike[U]&&kM.test($.texts[U])){let G=$.texts[U];q.push(G),N=fM.test(G),U++}M.push(e1(q)),J.push(!0),Z.push("text"),X.push($.starts[A]),A=U-1;continue}M.push(Y),J.push(K),Z.push(Q),X.push($.starts[A])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function tZ($){let M=[],J=[],Z=[],X=[];for(let A=0;A<$.len;A++){let Y=$.texts[A];if($.kinds[A]==="text"&&Y.includes("-")){let Q=Y.split("-"),K=Q.length>1;for(let q=0;q<Q.length;q++){let N=Q[q];if(!K)break;if(N.length===0||!SM(N)||!j6(N))K=!1}if(K){let q=0;for(let N=0;N<Q.length;N++){let U=Q[N],G=N<Q.length-1?`${U}-`:U;M.push(G),J.push(!0),Z.push("text"),X.push($.starts[A]+q),q+=G.length}continue}}M.push(Y),J.push($.isWordLike[A]),Z.push($.kinds[A]),X.push($.starts[A])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function eZ($){let M=[],J=[],Z=[],X=[],A=0;while(A<$.len){let Y=[$.texts[A]],Q=$.isWordLike[A],K=$.kinds[A],q=$.starts[A];if(K==="glue"){let N=[Y[0]],U=q;A++;while(A<$.len&&$.kinds[A]==="glue")N.push($.texts[A]),A++;let G=e1(N);if(A<$.len&&$.kinds[A]==="text")Y[0]=G,Y.push($.texts[A]),Q=$.isWordLike[A],K="text",q=U,A++;else{M.push(G),J.push(!1),Z.push("glue"),X.push(U);continue}}else A++;if(K==="text")while(A<$.len&&$.kinds[A]==="glue"){let N=[];while(A<$.len&&$.kinds[A]==="glue")N.push($.texts[A]),A++;let U=e1(N);if(A<$.len&&$.kinds[A]==="text"){Y.push(U,$.texts[A]),Q=Q||$.isWordLike[A],A++;continue}Y.push(U)}M.push(e1(Y)),J.push(Q),Z.push(K),X.push(q)}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function $X($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let A=0;A<M.length-1;A++){if(Z[A]!=="text"||Z[A+1]!=="text")continue;if(!t1(M[A])||!t1(M[A+1]))continue;let Y=vZ(M[A]);if(Y===null)continue;M[A]=Y.head,M[A+1]=Y.tail+M[A+1],X[A+1]=X[A]+Y.head.length}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function MX($,M,J){let Z=jZ(),X=0,A=[],Y=[],Q=[],K=[];for(let G of Z.segment($))for(let B of rZ(G.segment,G.isWordLike??!1,G.index,J)){let D=B.kind==="text";if(M.carryCJKAfterClosingQuote&&D&&X>0&&Q[X-1]==="text"&&t1(B.text)&&t1(A[X-1])&&f6(A[X-1]))A[X-1]+=B.text,Y[X-1]=Y[X-1]||B.isWordLike;else if(D&&X>0&&Q[X-1]==="text"&&SZ(B.text)&&t1(A[X-1]))A[X-1]+=B.text,Y[X-1]=Y[X-1]||B.isWordLike;else if(D&&X>0&&Q[X-1]==="text"&&IZ(A[X-1]))A[X-1]+=B.text,Y[X-1]=Y[X-1]||B.isWordLike;else if(D&&X>0&&Q[X-1]==="text"&&B.isWordLike&&E6(B.text)&&hZ(A[X-1]))A[X-1]+=B.text,Y[X-1]=!0;else if(D&&!B.isWordLike&&X>0&&Q[X-1]==="text"&&B.text.length===1&&B.text!=="-"&&B.text!=="—"&&gZ(A[X-1],B.text))A[X-1]+=B.text;else if(D&&!B.isWordLike&&X>0&&Q[X-1]==="text"&&(uZ(B.text)||B.text==="-"&&Y[X-1]))A[X-1]+=B.text;else A[X]=B.text,Y[X]=B.isWordLike,Q[X]=B.kind,K[X]=B.start,X++}for(let G=1;G<X;G++)if(Q[G]==="text"&&!Y[G]&&k6(A[G])&&Q[G-1]==="text")A[G-1]+=A[G],Y[G-1]=Y[G-1]||Y[G],A[G]="";for(let G=X-2;G>=0;G--)if(Q[G]==="text"&&!Y[G]&&mZ(A[G])){let B=G+1;while(B<X&&A[B]==="")B++;if(B<X&&Q[B]==="text")A[B]=A[G]+A[B],K[B]=K[G],A[G]=""}let q=0;for(let G=0;G<X;G++){let B=A[G];if(B.length===0)continue;if(q!==G)A[q]=B,Y[q]=Y[G],Q[q]=Q[G],K[q]=K[G];q++}A.length=q,Y.length=q,Q.length=q,K.length=q;let N=eZ({len:q,texts:A,isWordLike:Y,kinds:Q,starts:K}),U=$X(nZ(tZ(oZ(sZ(aZ(N))))));for(let G=0;G<U.len-1;G++){let B=pZ(U.texts[G]);if(B===null)continue;if(U.kinds[G]!=="space"&&U.kinds[G]!=="preserved-space"||U.kinds[G+1]!=="text"||!E6(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 JX($,M){if($.len===0)return[];if(!M.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len}];let J=[],Z=0;for(let X=0;X<$.len;X++){if($.kinds[X]!=="hard-break")continue;J.push({startSegmentIndex:Z,endSegmentIndex:X,consumedEndSegmentIndex:X+1}),Z=X+1}if(Z<$.len)J.push({startSegmentIndex:Z,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len});return J}function mM($,M,J="normal"){let Z=bZ(J),X=Z.mode==="pre-wrap"?EZ($):CZ($);if(X.length===0)return{normalized:X,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let A=MX(X,M,Z);return{normalized:X,chunks:JX(A,Z),...A}}var x0=null,vM=new Map,d0=null,ZX=/\p{Emoji_Presentation}/u,XX=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,u6=null,gM=new Map;function S6(){if(x0!==null)return x0;if(typeof OffscreenCanvas<"u")return x0=new OffscreenCanvas(1,1).getContext("2d"),x0;if(typeof document<"u")return x0=document.createElement("canvas").getContext("2d"),x0;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function AX($){let M=vM.get($);if(!M)M=new Map,vM.set($,M);return M}function Y0($,M){let J=M.get($);if(J===void 0)J={width:S6().measureText($).width,containsCJK:t1($)},M.set($,J);return J}function a0(){if(d0!==null)return d0;if(typeof navigator>"u")return d0={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},d0;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 d0={lineFitEpsilon:J?0.015625:0.005,carryCJKAfterClosingQuote:Z,preferPrefixWidthsForBreakableRuns:J,preferEarlySoftHyphenBreak:J},d0}function YX($){let M=$.match(/(\d+(?:\.\d+)?)\s*px/);return M?parseFloat(M[1]):16}function m6(){if(u6===null)u6=new Intl.Segmenter(void 0,{granularity:"grapheme"});return u6}function QX($){return ZX.test($)||$.includes("️")}function hM($){return XX.test($)}function KX($,M){let J=gM.get($);if(J!==void 0)return J;let Z=S6();Z.font=$;let X=Z.measureText("\uD83D\uDE00").width;if(J=0,X>M+0.5&&typeof document<"u"&&document.body!==null){let A=document.createElement("span");A.style.font=$,A.style.display="inline-block",A.style.visibility="hidden",A.style.position="absolute",A.textContent="\uD83D\uDE00",document.body.appendChild(A);let Y=A.getBoundingClientRect().width;if(document.body.removeChild(A),X-Y>0.5)J=X-Y}return gM.set($,J),J}function qX($){let M=0,J=m6();for(let Z of J.segment($))if(QX(Z.segment))M++;return M}function NX($,M){if(M.emojiCount===void 0)M.emojiCount=qX($);return M.emojiCount}function Q0($,M,J){if(J===0)return M.width;return M.width-NX($,M)*J}function IM($,M,J,Z){if(M.graphemeWidths!==void 0)return M.graphemeWidths;let X=[],A=m6();for(let Y of A.segment($)){let Q=Y0(Y.segment,J);X.push(Q0(Y.segment,Q,Z))}return M.graphemeWidths=X.length>1?X:null,M.graphemeWidths}function pM($,M,J,Z){if(M.graphemePrefixWidths!==void 0)return M.graphemePrefixWidths;let X=[],A=m6(),Y="";for(let Q of A.segment($)){Y+=Q.segment;let K=Y0(Y,J);X.push(Q0(Y,K,Z))}return M.graphemePrefixWidths=X.length>1?X:null,M.graphemePrefixWidths}function lM($,M){let J=S6();J.font=$;let Z=AX($),X=YX($),A=M?KX($,X):0;return{cache:Z,fontSize:X,emojiCorrection:A}}function n4($){return $==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen"}function UX($,M){while(M<$.widths.length){let J=$.kinds[M];if(J!=="space"&&J!=="zero-width-break"&&J!=="soft-hyphen")break;M++}return M}function GX($,M){if(M<=0)return 0;let J=$%M;if(Math.abs(J)<=0.000001)return M;return M-J}function rM($,M,J,Z){if(!Z||M===null)return $[J];return M[J]-(J>0?M[J-1]:0)}function BX($,M,J,Z,X,A){let Y=0,Q=M;while(Y<$.length){let K=A?M+$[Y]:Q+$[Y];if((Y+1<$.length?K+X:K)>J+Z)break;Q=K,Y++}return{fitCount:Y,fittedWidth:Q}}function FX($,M,J){let{widths:Z,kinds:X,breakableWidths:A,breakablePrefixWidths:Y}=$;if(Z.length===0)return 0;let Q=a0(),K=Q.lineFitEpsilon,q=0,N=0,U=!1,G=0,B=0,D=0,F=0,H=-1,b=0;function E(){H=-1,b=0}function V(W=D,_=F,C=N){q++,J?.({startSegmentIndex:G,startGraphemeIndex:B,endSegmentIndex:W,endGraphemeIndex:_,width:C}),N=0,U=!1,E()}function R(W,_){U=!0,G=W,B=0,D=W+1,F=0,N=_}function O(W,_,C){U=!0,G=W,B=_,D=W,F=_+1,N=C}function j(W,_){if(!U){R(W,_);return}N+=_,D=W+1,F=0}function f(W,_){if(!n4(X[W]))return;H=W+1,b=N-_}function z(W){y(W,0)}function y(W,_){let C=A[W],g=Y[W]??null;for(let u=_;u<C.length;u++){let d=rM(C,g,u,Q.preferPrefixWidthsForBreakableRuns);if(!U){O(W,u,d);continue}if(N+d>M+K)V(),O(W,u,d);else N+=d,D=W,F=u+1}if(U&&D===W&&F===C.length)D=W+1,F=0}let T=0;while(T<Z.length){if(!U){if(T=UX($,T),T>=Z.length)break}let W=Z[T],_=X[T];if(!U){if(W>M&&A[T]!==null)z(T);else R(T,W);f(T,W),T++;continue}if(N+W>M+K){if(n4(_)){j(T,W),V(T+1,0,N-W),T++;continue}if(H>=0){if(D>H||D===H&&F>0){V();continue}V(H,0,b);continue}if(W>M&&A[T]!==null){V(),z(T),T++;continue}V();continue}j(T,W),f(T,W),T++}if(U)V();return q}function cM($,M,J){if($.simpleLineWalkFastPath)return FX($,M,J);let{widths:Z,lineEndFitAdvances:X,lineEndPaintAdvances:A,kinds:Y,breakableWidths:Q,breakablePrefixWidths:K,discretionaryHyphenWidth:q,tabStopAdvance:N,chunks:U}=$;if(Z.length===0||U.length===0)return 0;let G=a0(),B=G.lineFitEpsilon,D=0,F=0,H=!1,b=0,E=0,V=0,R=0,O=-1,j=0,f=0,z=null;function y(){O=-1,j=0,f=0,z=null}function T(k=V,S=R,m=F){D++,J?.({startSegmentIndex:b,startGraphemeIndex:E,endSegmentIndex:k,endGraphemeIndex:S,width:m}),F=0,H=!1,y()}function W(k,S){H=!0,b=k,E=0,V=k+1,R=0,F=S}function _(k,S,m){H=!0,b=k,E=S,V=k,R=S+1,F=m}function C(k,S){if(!H){W(k,S);return}F+=S,V=k+1,R=0}function g(k,S){if(!n4(Y[k]))return;let m=Y[k]==="tab"?0:X[k],Z1=Y[k]==="tab"?S:A[k];O=k+1,j=F-S+m,f=F-S+Z1,z=Y[k]}function u(k){d(k,0)}function d(k,S){let m=Q[k],Z1=K[k]??null;for(let t=S;t<m.length;t++){let N1=rM(m,Z1,t,G.preferPrefixWidthsForBreakableRuns);if(!H){_(k,t,N1);continue}if(F+N1>M+B)T(),_(k,t,N1);else F+=N1,V=k,R=t+1}if(H&&V===k&&R===m.length)V=k+1,R=0}function p(k){if(z!=="soft-hyphen")return!1;let S=Q[k];if(S===null)return!1;let m=G.preferPrefixWidthsForBreakableRuns?K[k]??S:S,Z1=m!==S,{fitCount:t,fittedWidth:N1}=BX(m,F,M,B,q,Z1);if(t===0)return!1;if(F=N1,V=k,R=t,y(),t===S.length)return V=k+1,R=0,!0;return T(k,t,N1+q),d(k,t),!0}function J1(k){D++,J?.({startSegmentIndex:k.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:k.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),y()}for(let k=0;k<U.length;k++){let S=U[k];if(S.startSegmentIndex===S.endSegmentIndex){J1(S);continue}H=!1,F=0,b=S.startSegmentIndex,E=0,V=S.startSegmentIndex,R=0,y();let m=S.startSegmentIndex;while(m<S.endSegmentIndex){let Z1=Y[m],t=Z1==="tab"?GX(F,N):Z[m];if(Z1==="soft-hyphen"){if(H)V=m+1,R=0,O=m+1,j=F+q,f=F+q,z=Z1;m++;continue}if(!H){if(t>M&&Q[m]!==null)u(m);else W(m,t);g(m,t),m++;continue}if(F+t>M+B){let v1=F+(Z1==="tab"?0:X[m]),g1=F+(Z1==="tab"?t:A[m]);if(z==="soft-hyphen"&&G.preferEarlySoftHyphenBreak&&j<=M+B){T(O,0,f);continue}if(z==="soft-hyphen"&&p(m)){m++;continue}if(n4(Z1)&&v1<=M+B){C(m,t),T(m+1,0,g1),m++;continue}if(O>=0&&j<=M+B){if(V>O||V===O&&R>0){T();continue}let A1=O;T(A1,0,f),m=A1;continue}if(t>M&&Q[m]!==null){T(),u(m),m++;continue}T();continue}C(m,t),g(m,t),m++}if(H){let Z1=O===S.consumedEndSegmentIndex?f:F;T(S.consumedEndSegmentIndex,0,Z1)}}return D}var v6=null,xM=new WeakMap;function aM(){if(v6===null)v6=new Intl.Segmenter(void 0,{granularity:"grapheme"});return v6}function DX($){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 _X($,M,J){let Z=aM(),X=a0(),{cache:A,emojiCorrection:Y}=lM(M,hM($.normalized)),Q=Q0("-",Y0("-",A),Y),q=Q0(" ",Y0(" ",A),Y)*8;if($.len===0)return DX(J);let N=[],U=[],G=[],B=[],D=$.chunks.length<=1,F=J?[]:null,H=[],b=[],E=J?[]:null,V=Array.from({length:$.len}),R=Array.from({length:$.len});function O(z,y,T,W,_,C,g,u){if(_!=="text"&&_!=="space"&&_!=="zero-width-break")D=!1;if(N.push(y),U.push(T),G.push(W),B.push(_),F?.push(C),H.push(g),b.push(u),E!==null)E.push(z)}for(let z=0;z<$.len;z++){V[z]=N.length;let y=$.texts[z],T=$.isWordLike[z],W=$.kinds[z],_=$.starts[z];if(W==="soft-hyphen"){O(y,0,Q,Q,W,_,null,null),R[z]=N.length;continue}if(W==="hard-break"){O(y,0,0,0,W,_,null,null),R[z]=N.length;continue}if(W==="tab"){O(y,0,0,0,W,_,null,null),R[z]=N.length;continue}let C=Y0(y,A);if(W==="text"&&C.containsCJK){let p="",J1=0;for(let k of Z.segment(y)){let S=k.segment;if(p.length===0){p=S,J1=k.index;continue}if(O2.has(p)||R6.has(S)||c0.has(S)||X.carryCJKAfterClosingQuote&&t1(S)&&f6(p)){p+=S;continue}let m=Y0(p,A),Z1=Q0(p,m,Y);O(p,Z1,Z1,Z1,"text",_+J1,null,null),p=S,J1=k.index}if(p.length>0){let k=Y0(p,A),S=Q0(p,k,Y);O(p,S,S,S,"text",_+J1,null,null)}R[z]=N.length;continue}let g=Q0(y,C,Y),u=W==="space"||W==="preserved-space"||W==="zero-width-break"?0:g,d=W==="space"||W==="zero-width-break"?0:g;if(T&&y.length>1){let p=IM(y,C,A,Y),J1=X.preferPrefixWidthsForBreakableRuns?pM(y,C,A,Y):null;O(y,g,u,d,W,_,p,J1)}else O(y,g,u,d,W,_,null,null);R[z]=N.length}let j=HX($.chunks,V,R),f=F===null?null:LM($.normalized,F);if(E!==null)return{widths:N,lineEndFitAdvances:U,lineEndPaintAdvances:G,kinds:B,simpleLineWalkFastPath:D,segLevels:f,breakableWidths:H,breakablePrefixWidths:b,discretionaryHyphenWidth:Q,tabStopAdvance:q,chunks:j,segments:E};return{widths:N,lineEndFitAdvances:U,lineEndPaintAdvances:G,kinds:B,simpleLineWalkFastPath:D,segLevels:f,breakableWidths:H,breakablePrefixWidths:b,discretionaryHyphenWidth:Q,tabStopAdvance:q,chunks:j}}function HX($,M,J){let Z=[];for(let X=0;X<$.length;X++){let A=$[X],Y=A.startSegmentIndex<M.length?M[A.startSegmentIndex]:J[J.length-1]??0,Q=A.endSegmentIndex<M.length?M[A.endSegmentIndex]:J[J.length-1]??0,K=A.consumedEndSegmentIndex<M.length?M[A.consumedEndSegmentIndex]:J[J.length-1]??0;Z.push({startSegmentIndex:Y,endSegmentIndex:Q,consumedEndSegmentIndex:K})}return Z}function PX($,M,J,Z){let X=mM($,a0(),Z?.whiteSpace);return _X(X,M,J)}function sM($,M,J){return PX($,M,!0,J)}function WX($){return $}function dM($,M,J){let Z=J.get($);if(Z!==void 0)return Z;Z=[];let X=aM();for(let A of X.segment(M[$]))Z.push(A.segment);return J.set($,Z),Z}function TX($){let M=xM.get($);if(M!==void 0)return M;return M=new Map,xM.set($,M),M}function yX($,M,J,Z){return Z>0&&$[Z-1]==="soft-hyphen"&&!(M===Z&&J>0)}function VX($,M,J,Z,X,A,Y){let Q="",K=yX(M,Z,X,A);for(let q=Z;q<A;q++){if(M[q]==="soft-hyphen"||M[q]==="hard-break")continue;if(q===Z&&X>0)Q+=dM(q,$,J).slice(X).join("");else Q+=$[q]}if(Y>0){if(K)Q+="-";Q+=dM(A,$,J).slice(Z===A?X:0,Y).join("")}else if(K)Q+="-";return Q}function zX($,M,J,Z,X,A,Y){return{text:VX($.segments,$.kinds,M,Z,X,A,Y),width:J,start:{segmentIndex:Z,graphemeIndex:X},end:{segmentIndex:A,graphemeIndex:Y}}}function OX($,M,J){return zX($,M,J.width,J.startSegmentIndex,J.startGraphemeIndex,J.endSegmentIndex,J.endGraphemeIndex)}function iM($,M,J){let Z=[];if($.widths.length===0)return{lineCount:0,height:0,lines:Z};let X=TX($),A=cM(WX($),M,(Y)=>{Z.push(OX($,X,Y))});return{lineCount:A,height:A*J,lines:Z}}function g6($,M,J){let Z=$.image?M.images.get($.image.url)??null:null,X=$.image?.width??null,A=Math.min(J,X??240),Y=Math.max(120,Math.round(A*0.5625));if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return{height:Y,width:A};let Q=Math.min(J,X??Z.intrinsicWidth),K=Math.min(1,Q/Z.intrinsicWidth);return{height:Math.max(48,Math.round(Z.intrinsicHeight*K)),width:Math.max(48,Math.round(Z.intrinsicWidth*K))}}function oM($,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 nM=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],t4;function s0($){if($?.type==="heading"){let{fontSize:M}=$3($.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 O0($,M){if($?.type==="heading")return $3($.depth).lineHeight;if($?.type==="code")return 22;return M}function $3($){return nM[$-1]??nM.at(-1)}function i0($,M,J,Z,X,A,Y){let Q=`${$5(M,Y)}:${X}:${A}:${J}`,K=$.measuredLines.get(Q);if(K)return K;let q=CX($,M,J,Z,X,A,Y);return bM($,Q,q)}function e4($,M,J,Z,X,A,Y,Q){let K=`${$5(M,Q)}:${J}:${Z}:${A}:${Y}`,q=$.lineBoundaries.get(K);if(q)return q;let N=J3();if(!N)return eM(X);let U=[{left:0,offset:0}],G=0,B=M.inlines.filter((D)=>D.end>J&&D.start<Z);if(B.length===0)return eM(X);for(let D of B){let F=Math.max(J,D.start),H=Math.min(Z,D.end),b=M.text.slice(F,H),E=F-J;if(D.kind==="image"){let V=g6(D,Q,Y).width;G+=V,E+=b.length,U.push({left:G,offset:E});continue}N.font=M3(A,D.marks);for(let V of Array.from(b))G+=Z3($,N,V),E+=V.length,U.push({left:G,offset:E})}return CM($,K,U)}function bX($,M,J,Z){let X=`${J}::${Z}::${M}`,A=$.preparedText.get(X);if(A)return A;let Y=sM(M,J,{whiteSpace:Z});return OM($,X,Y)}function CX($,M,J,Z,X,A,Y){let Q=M.text;if(Q.length===0)return[{end:0,height:A,start:0,text:"",width:0}];if(LX(M))return wX($,M,J,X,A,Y);try{let K=bX($,Q,J,mX(Z));return iM(K,X,A).lines.map((N)=>({end:tM(K.segments,N.end),height:A,start:tM(K.segments,N.start),text:N.text,width:N.width}))}catch{return EX(Q,X,A)}}function tM($,M){let J=0;for(let A=0;A<M.segmentIndex;A+=1)J+=$[A]?.length??0;let Z=$[M.segmentIndex]??"",X=Array.from(Z);for(let A=0;A<M.graphemeIndex;A+=1)J+=X[A]?.length??0;return J}function eM($){let M=[{left:0,offset:0}],J=0,Z=0;for(let X of Array.from($))J+=9,Z+=X.length,M.push({left:J,offset:Z});return M}function EX($,M,J){let Z=Math.max(1,Math.floor(M/9)),X=vX($,Z),A=0;return X.map((Y)=>{let Q=A,K=Q+Y.length;return A=K,{end:K,height:J,start:Q,text:Y,width:Y.length*9}})}function wX($,M,J,Z,X,A){let Y=RX($,J3(),M,J,Z,X,A);if(Y.length===0)return[{end:0,height:X,start:0,text:"",width:0}];return jX(Y,M.text,Z,X)}function jX($,M,J,Z){let X=[],A=0;while(A<$.length){let Y=$[A].start;if($[A].text===`
|
|
14
|
+
`){X.push({end:Y,height:Z,start:Y,text:"",width:0}),A+=1;continue}let Q=0,K=0,q=A,N=-1,U=Z;while(q<$.length){let B=$[q];if(B.text===`
|
|
15
|
+
`)break;let D=Q+B.width;if(D>J&&q>A)break;if(Q=D,U=Math.max(U,B.height),B.breakable)N=q,K=Q;q+=1}if(q===$.length||$[q]?.text===`
|
|
16
|
+
`){let B=$[q-1]?.end??Y;X.push({end:B,height:U,start:Y,text:M.slice(Y,B),width:Q}),A=q<$.length&&$[q]?.text===`
|
|
17
|
+
`?q+1:q;continue}if(N>=A){let B=$[N].end;X.push({end:B,height:U,start:Y,text:M.slice(Y,B),width:K}),A=N+1;continue}let G=$[Math.max(A,q-1)].end;X.push({end:G,height:U,start:Y,text:M.slice(Y,G),width:Q}),A=Math.max(A+1,q)}return X}function RX($,M,J,Z,X,A,Y){let Q=[];for(let K of J.inlines){if(K.kind==="image"){let N=g6(K,Y,X);Q.push({breakable:!0,end:K.end,height:N.height,start:K.start,text:K.text,width:N.width});continue}if(M)M.font=M3(Z,K.marks);let q=K.start;for(let N of Array.from(K.text)){let U=q,G=U+N.length;Q.push({breakable:/\s/.test(N),end:G,height:A,start:U,text:N,width:N===`
|
|
18
|
+
`?0:Z3($,M,N)}),q=G}}return Q}function LX($){return $.inlines.some((M)=>M.kind==="image"||SX(M))}function $5($,M){return[$.path,uX($.text),kX($,M)].join(":")}function kX($,M){return $.inlines.map((J)=>`${J.start}-${J.end}:${fX(J,M)}`).join("|")}function fX($,M){if($.kind==="image"&&$.image)return oM($,M);return`${$.kind}:${$.inlineCode?1:0}:${$.marks.join(",")}:${$.link?.url??""}`}function uX($){let M=2166136261;for(let J of $)M^=J.charCodeAt(0),M=Math.imul(M,16777619);return(M>>>0).toString(36)}function SX($){return $.marks.includes("italic")||$.marks.includes("bold")}function M3($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function J3(){if(t4!==void 0)return t4;return t4=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,t4}function Z3($,M,J){if(!M)return 9;let Z=M.font,X=wM($,Z),A=X.get(J);if(A!==void 0)return A;let Y=M.measureText(J).width;return X.set(J,Y),Y}function mX($){return $?.type==="code"?"pre-wrap":"normal"}function vX($,M){if($.length===0)return[""];let J=$.split(`
|
|
19
|
+
`),Z=[];for(let X of J){if(X.length===0){Z.push("");continue}let A=X;while(A.length>M){let Y=A.slice(0,M),Q=Y.lastIndexOf(" ");if(Q<=0){Z.push(Y),A=A.slice(M);continue}Z.push(Y.slice(0,Q)),A=A.slice(Q+1)}Z.push(A)}return Z}var b2=10,o0=8,h6=120;function X3($,M,J,Z,X,A,Y,Q,K,q){let N=Math.max(1,...A.rows.map((F)=>F.cells.length)),G=Math.max(h6,K.width-Y-K.paddingX)/N,B=gX(Z),D=Q;for(let F=0;F<A.rows.length;F+=1){let H=hX(B.get(F)??[],X,A,G,b2,K.lineHeight,q),b=Math.max(K.lineHeight+o0*2,...H.map((E)=>E.measuredLines.reduce((V,R)=>V+R.height,0)+o0*2));for(let E of H){let V=Y+E.cellIndex*G,R=D+o0;for(let O of E.measuredLines){let j={blockId:E.container.blockId,boundaries:e4(X,E.container,O.start,O.end,O.text,E.font,G-b2*2,q),regionId:E.container.id,end:O.end,font:E.font,height:O.height,left:V+b2,start:O.start,text:O.text,top:R,width:O.width};$.push(j),I6(M,j),R+=O.height}J.set(E.container.id,{bottom:D+b,left:V,right:V+G,top:D})}pX(M,A.id,D,D+b),D+=b}return D+K.blockGap}function gX($){let M=new Map;for(let J of $){let Z=IX(J.path);if(!Z)continue;let X=M.get(Z.rowIndex)??[];X.push({cellIndex:Z.cellIndex,container:J}),M.set(Z.rowIndex,X)}return M}function hX($,M,J,Z,X,A,Y){return[...$].sort((Q,K)=>Q.cellIndex-K.cellIndex).map(({cellIndex:Q,container:K})=>{let q=s0(J),N=O0(J,A),U=i0(M,K,q,J,Math.max(40,Z-X*2),N,Y);return{cellIndex:Q,container:K,font:q,lineHeight:N,measuredLines:U}})}function IX($){let M=/\.rows\.(\d+)\.cells\.(\d+)$/.exec($);if(!M)return null;return{cellIndex:Number(M[2]),rowIndex:Number(M[1])}}function pX($,M,J,Z){let X=$.get(M);$.set(M,{bottom:X?Math.max(X.bottom,Z):Z,top:X?Math.min(X.top,J):J})}var lX={blockGap:16,charWidth:9,indentWidth:24,lineHeight:24,paddingX:16,paddingY:12},rX=24,cX=16,xX=6,dX=10,aX=4;function M5($){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 J5($,M,J=z0(),Z=null){let X=Z??{images:new Map},A={...lX,...M},Y=[],Q=new Map,K=new Map($.regions.map((F)=>[F.id,{textLength:F.text.length}])),q=new Map($.blocks.map((F)=>[F.id,F.depth])),N=new Map($.blocks.map((F)=>[F.id,F])),U=E2($.document.blocks),G=new Map,B=A.paddingY;for(let F=0;F<$.regions.length;F+=1){let H=$.regions[F],b=q.get(H.blockId)??0,E=A.paddingX+b*A.indentWidth,V=Math.max(40,A.width-E-A.paddingX),R=U.get(H.blockId)??null;if(R?.type==="table"){let f=N.get(H.blockId)?.regionIds??[],z=$.regions.slice(F,F+f.length);B=X3(Y,G,Q,z,J,R,E,B,A,X),F+=z.length-1;continue}B=sX(Y,G,Q,H,J,R,E,B,V,A,X);let O=X5(N,U,$.regions,F,A.blockGap);B+=O;let j=G.get(H.blockId);if(j)j.bottom=Math.max(j.bottom,B)}return{blocks:$.blocks.map((F)=>{let H=G.get(F.id),b=H?.top??A.paddingY;return{bottom:H?.bottom??b+A.lineHeight/2,depth:F.depth,id:F.id,top:b,type:F.type}}),regionBounds:oX(Y,Q),regionLineIndices:iX(Y),regionMetrics:K,height:Math.max(B,A.paddingY),lines:Y,options:A,width:A.width}}function sX($,M,J,Z,X,A,Y,Q,K,q,N){let U=s0(A),G=O0(A,q.lineHeight),B=i0(X,Z,U,A,K,G,N),D=Q;for(let F of B){let H={blockId:Z.blockId,boundaries:e4(X,Z,F.start,F.end,F.text,U,K,N),regionId:Z.id,end:F.end,font:U,height:F.height,left:Y,start:F.start,text:F.text,top:D,width:F.width};$.push(H),I6(M,H),D+=F.height}return nX($,Z.id,J),D}function iX($){let M=[...$].sort((Z,X)=>Z.top-X.top||Z.left-X.left),J=new Map;$.length=0,$.push(...M);for(let[Z,X]of $.entries()){let A=J.get(X.regionId)??[];A.push(Z),J.set(X.regionId,A)}return J}function oX($,M){let J=new Map(M);for(let Z of $){let X=J.get(Z.regionId),A={bottom:Z.top+Z.height,left:Z.left,right:Z.left+Z.width,top:Z.top};J.set(Z.regionId,X?{bottom:Math.max(X.bottom,A.bottom),left:Math.min(X.left,A.left),right:Math.max(X.right,A.right),top:Math.min(X.top,A.top)}:A)}return J}function nX($,M,J){let Z=$.filter((X)=>X.regionId===M);if(Z.length===0)return;J.set(M,{bottom:Math.max(...Z.map((X)=>X.top+X.height)),left:Math.min(...Z.map((X)=>X.left)),right:Math.max(...Z.map((X)=>X.left+X.width)),top:Math.min(...Z.map((X)=>X.top))})}function I6($,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 q3($,M){let J=0,Z=$.lines.length-1;while(J<=Z){let X=J+Z>>1,A=$.lines[X];if(M<A.top){Z=X-1;continue}if(M>=A.top+A.height){J=X+1;continue}return{index:X,line:A}}return null}function p6($,M){let J=[...$.regionBounds.entries()].find(([,A])=>{return M.x>=A.left&&M.x<=A.right&&M.y>=A.top&&M.y<=A.bottom});if(J)return Z5($,J[0],M.y);let Z=q3($,M.y);if(!Z)return null;let X=tX($,M.y,Z.index);if(X.length===1)return X[0]??null;return X.find((A)=>{let Y=$.regionBounds.get(A.line.regionId);return Y?M.x>=Y.left&&M.x<=Y.right:!1})??[...X].sort((A,Y)=>{let Q=$.regionBounds.get(A.line.regionId),K=$.regionBounds.get(Y.line.regionId),q=A3(M.x,Q),N=A3(M.x,K);return q-N})[0]??null}function l6($,M,J){if($.lines.length===0)return{endIndex:0,startIndex:0};let Z=M+J,X=Y3($,M),A=Y3($,Z);if(X>0){let Y=$.lines[X-1];if(Y.top+Y.height>M)X-=1}if(A<$.lines.length){if($.lines[A].top<Z)A+=1}return{endIndex:A,startIndex:X}}function c1($,M,J){if(!$.regionMetrics.get(J.regionId))return null;let X=$0($,J.regionId,J.offset);if(!X)return null;return{blockId:X.blockId,regionId:X.regionId,height:X.height,left:x1(X,J.offset-X.start),offset:J.offset,top:X.top}}function $0($,M,J){return C2($,M,J)?.line??null}function Z5($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=Z[0],A=Number.POSITIVE_INFINITY;for(let Y of Z){let Q=$.lines[Y],K=J<Q.top?Q.top-J:J>Q.top+Q.height?J-(Q.top+Q.height):0;if(K<A)A=K,X=Y;if(K===0)break}return{index:X,line:$.lines[X]}}function C2($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=0,A=Z.length-1;while(X<=A){let N=X+A>>1,U=Z[N],G=$.lines[U];if(J<G.start){A=N-1;continue}if(J>G.end){X=N+1;continue}return{index:U,line:G}}let Y=Z[0],Q=Z[Z.length-1],K=$.lines[Y],q=$.lines[Q];if(J<=K.start)return{index:Y,line:K};if(J>=q.end)return{index:Q,line:q};return null}function tX($,M,J){let Z=[];for(let X=J;X>=0;X-=1){let A=$.lines[X];if(M<A.top||M>=A.top+A.height)break;Z.unshift({index:X,line:A})}for(let X=J+1;X<$.lines.length;X+=1){let A=$.lines[X];if(M<A.top||M>=A.top+A.height)break;Z.push({index:X,line:A})}return Z}function A3($,M){if(!M)return Number.POSITIVE_INFINITY;if($<M.left)return M.left-$;if($>M.right)return $-M.right;return 0}function x1($,M){return $.left+eX($.boundaries,M)}function E2($){let M=new Map,J=(Z)=>{for(let X of Z)if(M.set(X.id,X),X.type==="blockquote"||X.type==="listItem")J(X.children);else if(X.type==="list")J(X.items)};return J($),M}function eX($,M){for(let Z of $)if(Z.offset===M)return Z.left;return $.filter((Z)=>Z.offset<=M).at(-1)?.left??0}function Y3($,M){let J=0,Z=$.lines.length;while(J<Z){let X=J+Z>>1,A=$.lines[X];if(A.top+A.height<=M)J=X+1;else Z=X}return J}function N3($,M){if($.length===0)return 0;for(let J=1;J<$.length;J+=1){let Z=$[J-1],X=$[J],A=Z.left+(X.left-Z.left)/2;if(M<=A)return Z.offset;if(M<=X.left)return X.offset}return $.at(-1)?.offset??0}function X5($,M,J,Z,X){let A=J[Z],Y=J[Z+1];if(!A||!Y)return X;if(Q3($,A.blockId,Y.blockId,"list"))return xX;if(Q3($,A.blockId,Y.blockId,"blockquote"))return dX;if(A.blockId===Y.blockId)return aX;return X+$A(M.get(A.blockId))}function $A($){if($?.type!=="heading")return 0;if($.depth===1)return rX;return $.depth===2?cX:0}function Q3($,M,J,Z){let X=K3($,M,Z),A=K3($,J,Z);for(let Y of X)if(A.has(Y))return!0;return!1}function K3($,M,J){let Z=new Set,X=$.get(M)??null;while(X){if(X.type===J)Z.add(X.id);X=X.parentBlockId?$.get(X.parentBlockId)??null:null}return Z}function r6($,M,J,Z=[],X=z0(),A=null){let Y=A??{images:new Map},Q=E2($.document.blocks),K=new Map($.blocks.map((V)=>[V.id,V])),q=new Set(Z),N=Math.max(0,J.top-J.overscan),U=J.top+J.height+J.overscan,G=AA(X,$,Q,K,M,Y),B=U3(G,N),D=U3(G,U);if(B>0){let V=G.entries[B-1];if(V&&V.bottom>N)B-=1}if(D<G.entries.length){let V=G.entries[D];if(V&&V.top<U)D+=1}for(let V of q){let R=G.containerIndices.get(V);if(R===void 0)continue;B=Math.min(B,R),D=Math.max(D,R+1)}if(!Number.isFinite(B)||!Number.isFinite(D))return{estimateRegionBounds:G.estimateRegionBounds,layout:J5({...$,regions:[]},M,X,Y),totalHeight:G.totalHeight,viewport:J};let F=ZA($,K,G.containerIndices,B,D),H=G.entries[F.startIndex]?.top??M.paddingY??0,b=J5({...$,regions:$.regions.slice(F.startIndex,F.endIndex)},M,X,Y),E=JA(b,H,G.totalHeight);return MA(X,$,E,M,Y),{estimateRegionBounds:G.estimateRegionBounds,layout:E,totalHeight:G.totalHeight,viewport:J}}function MA($,M,J,Z,X){for(let[A,Y]of J.regionBounds){let Q=Y.bottom-Y.top,K=M.regionIndex.get(A);EM($,G3(K??{path:A,inlines:[],text:""},Z,X),Q)}}function JA($,M,J){return{...$,blocks:$.blocks.map((Z)=>({...Z,bottom:Z.bottom+M,top:Z.top+M})),regionBounds:new Map([...$.regionBounds.entries()].map(([Z,X])=>[Z,{bottom:X.bottom+M,left:X.left,right:X.right,top:X.top+M}])),height:J,lines:$.lines.map((Z)=>({...Z,top:Z.top+M}))}}function ZA($,M,J,Z,X){let A=Z,Y=X;for(let Q=Z;Q<X;Q+=1){let K=$.regions[Q],q=M.get(K.blockId);if(!q)continue;if(q.type==="table"){let N=J.get(q.regionIds[0]??""),U=J.get(q.regionIds[q.regionIds.length-1]??"");if(N!==void 0)A=Math.min(A,N);if(U!==void 0)Y=Math.max(Y,U+1)}}return{endIndex:Y,startIndex:A}}function XA($,M,J,Z,X,A){let Y=G3(M,X,A),Q=$.measuredContainerHeights.get(Y);if(Q!==void 0)return Q;let K=X.paddingX??0,q=X.indentWidth??24,N=O0(J,X.lineHeight??24),U=K+Z*q,G=Math.max(40,X.width-U-K);if(M.inlines.some((F)=>F.kind==="image")){let F=s0(J);return i0($,M,F,J,G,N,A).reduce((H,b)=>H+b.height,0)}let B=M5({text:M.text,width:G});return Math.max(N,B.lineCount*N)}function AA($,M,J,Z,X,A){let Y=qA(M,X,A),Q=jM($,M,Y);if(Q)return Q;let K=X.paddingY??0,q=[],N=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 b=YA({block:B,blockMap:J,containerIndices:N,entries:q,index:U,options:X,runtimeBlocks:Z,totalHeight:K,regions:M.regions});if(b){U=b.nextIndex-1,K=b.totalHeight;continue}}let D=XA($,G,B,Z.get(G.blockId)?.depth??0,X,A),F=K,H=F+D;q.push({bottom:H,top:F}),N.set(G.id,U),K=H+X5(Z,J,M.regions,U,X.blockGap??16)}return RM($,M,Y,{containerIndices:N,entries:q,estimateRegionBounds(U){let G=N.get(U);return G===void 0?null:q[G]??null},totalHeight:K})}function YA({block:$,blockMap:M,containerIndices:J,entries:Z,index:X,options:A,runtimeBlocks:Y,totalHeight:Q,regions:K}){let q=Y.get($.id),N=q?.regionIds??[];if(N.length===0)return null;let U=K.slice(X,X+N.length);if(U.length===0||U[0]?.blockId!==$.id)return null;let G=A.paddingX??0,B=A.indentWidth??24,D=q?.depth??0,F=G+D*B,H=Math.max(h6,A.width-F-G),b=Math.max(1,...$.rows.map((f)=>f.cells.length)),E=H/b,V=Math.max(40,E-b2*2),R=O0($,A.lineHeight??24),O=QA(U,X),j=Q;for(let f=0;f<$.rows.length;f+=1){let z=O.get(f)??[],y=Math.max(R+o0*2,...z.map(({region:W})=>KA(W,V,R)+o0*2)),T=j+y;for(let{index:W,region:_}of z)Z[W]={bottom:T,top:j},J.set(_.id,W);j=T}for(let f=X;f<X+U.length;f+=1){let z=K[f];if(!z||Z[f])continue;Z[f]={bottom:j,top:j},J.set(z.id,f)}return{nextIndex:X+U.length,totalHeight:j+X5(Y,M,K,X+U.length-1,A.blockGap??16)}}function QA($,M){let J=new Map;for(let[Z,X]of $.entries()){let A=X.tableCellPosition?.rowIndex;if(A===void 0)continue;let Y=J.get(A)??[];Y.push({index:M+Z,region:X}),J.set(A,Y)}return J}function KA($,M,J){let Z=M5({text:$.text,width:M});return Math.max(J,Z.lineCount*J)}function qA($,M,J){return[M.width,M.paddingX??0,M.paddingY??0,M.indentWidth??24,M.lineHeight??24,M.blockGap??16,NA($,J)].join(":")}function U3($,M){let J=0,Z=$.entries.length;while(J<Z){let X=J+Z>>1;if($.entries[X].bottom<=M)J=X+1;else Z=X}return J}function G3($,M,J){return`${$5($,J)}:${M.width}:${M.paddingX??0}:${M.indentWidth??24}:${M.lineHeight??24}`}function NA($,M){return $.regions.flatMap((J)=>J.inlines.filter((Z)=>Z.kind==="image"&&Z.image).map((Z)=>{let X=Z.image?M.images.get(Z.image.url):null;return`${Z.image?.url??""}:${Z.image?.width??0}:${X?.status??"loading"}:${X?.intrinsicWidth??0}:${X?.intrinsicHeight??0}`})).join("|")}var A5=null;function UA($){let M=/(\d+(?:\.\d+)?)\s*px/.exec($);return M?Number.parseFloat(M[1]):16}function K0($){A5??=new Map;let M=A5.get($);if(M)return M;let J=D3(),Z=Math.max(12,Math.round(UA($)));if(!J){let G={ascent:Math.round(Z*0.8),descent:Math.max(2,Z-Math.round(Z*0.8)),emHeight:Z};return A5.set($,G),G}J.font=$;let X=J.measureText("Hg"),A=Math.round(X.actualBoundingBoxAscent||0),Y=Math.round(X.actualBoundingBoxDescent||0),Q=A+Y,K=Math.max(Z,Q),q=Q>0?A:Math.round(K*0.8),N=Q>0?Y:Math.max(2,K-q),U={ascent:q,descent:N,emHeight:K};return A5.set($,U),U}function GA($,M){let{emHeight:J}=K0(M);return Math.max(0,Math.floor(($-J)/2))}function B3($,M){let{ascent:J}=K0(M);return GA($,M)+J}var Y5;function F3($,M){let J=D3();if(!J||$.length===0)return 0;return J.font=M,J.measureText($).width}function D3(){if(Y5!==void 0)return Y5;return Y5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,Y5}var BA=18,FA=14,DA=22;function C1($,M,J){let Z=HA($,J);if(!Z)return null;return _3($,M,Z,J.x)}function c6($,M,J){let Z=$.lines[$.lines.length-1];if(!Z||J.y<=Z.top+Z.height)return null;return _3($,M,Z,J.x)}function _3($,M,J,Z){let X=$.regionMetrics.get(J.regionId);if(!X)return null;let A=Math.max(0,Z-N0(M,J)-J.left),Y=N3(J.boundaries,A),Q=Math.min(X.textLength,J.start+Y);return{regionId:J.regionId,offset:Q,left:x1(J,Y),top:J.top,height:J.height}}function x6($,M,J,Z){let X=o6(M,Z.regionId);if(!X)return null;let A=C1($,M,J);if(A)return{regionId:A.regionId,offset:A.offset};let Y=J.y<WA($);return{regionId:Z.regionId,offset:Y?0:X.text.length}}function d6($,M,J){let Z=C1($,M,J);if(!Z)return null;let X=o6(M,Z.regionId);if(!X||X.text.length===0)return null;let A=Z.offset<X.text.length&&/\w/.test(X.text[Z.offset]??"")?Z.offset:Z.offset>0&&/\w/.test(X.text[Z.offset-1]??"")?Z.offset-1:Z.offset,Y=TA(X.text,A);if(Y.start===Y.end)return null;return{anchor:{regionId:Z.regionId,offset:Y.start},focus:{regionId:Z.regionId,offset:Y.end}}}function H3($,M,J){let Z=PA($,J);if(!Z||Z.start!==0)return null;let X=n0(M,Z.blockId,"listItem");if(!X)return null;if(j2(M,X.id)?.kind!=="task")return null;let Y=w2(Z),Q=Y.left-4,K=Y.left+Y.size+4,q=Y.top-4,N=Y.top+Y.size+4;return J.x>=Q&&J.x<=K&&J.y>=q&&J.y<=N?{listItemId:X.id}:null}function P3($,M,J){let Z=C1($,M,J);if(!Z)return null;let X=o6(M,Z.regionId);if(!X)return null;let A=X.inlines.find((Q)=>Q.link&&Z.offset>=Q.start&&Z.offset<Q.end);if(!A?.link)return null;let Y=i6($,M,Z.regionId,A.start);if(!Y)return null;return{anchorBottom:Y.anchorBottom,anchorLeft:Y.anchorLeft,endOffset:A.end,regionId:Z.regionId,startOffset:A.start,title:A.link.title,url:A.link.url}}function a6($,M,J,Z){let X=H3($,M,J);if(X)return{kind:"task-toggle",listItemId:X.listItemId};let A=C1($,M,J);if(!A)return null;let Y=W3(A.regionId,A.offset,Z),Q=Y!==null?T3(Y,$,M,Z):null,K=P3($,M,J);if(K)return{anchorBottom:Q?.anchorBottom??K.anchorBottom,anchorLeft:Q?.anchorLeft??K.anchorLeft,endOffset:K.endOffset,kind:"link",commentThreadIndex:Y,regionId:K.regionId,startOffset:K.startOffset,title:K.title,url:K.url};return{anchorBottom:Q?.anchorBottom??A.top+A.height,anchorLeft:Q?.anchorLeft??A.left,kind:"text",commentThreadIndex:Y}}function s6($,M,J,Z){let X=M.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let A=W3(J.regionId,J.offset,Z),Y=A!==null?T3(A,$,M,Z):null,Q=X.inlines.find((K)=>J.offset>=K.start&&J.offset<=K.end)??null;if(Q?.link){let K=i6($,M,J.regionId,Q.start);if(!K)return null;return{anchorBottom:Y?.anchorBottom??K.anchorBottom,anchorLeft:Y?.anchorLeft??K.anchorLeft,commentThreadIndex:A,endOffset:Q.end,kind:"link",regionId:J.regionId,startOffset:Q.start,title:Q.link.title,url:Q.link.url}}if(Y)return{anchorBottom:Y.anchorBottom,anchorLeft:Y.anchorLeft,commentThreadIndex:A,kind:"text"};return null}function d1($,M,J){let Z=$0(M,J.regionId,J.offset);if(!Z)return J.left;return J.left+N0($,Z)+_A($,Z,J.offset)}function q0($,M,J){return x1(M,J)+N0($,M)}function N0($,M){let J=n0($,M.blockId,"listItem");if(!J)return 0;return j2($,J.id)?.kind==="task"?DA:BA}function w2($){return{left:$.left,size:FA,top:$.top+3}}function n0($,M,J){let Z=$.documentIndex.blockIndex.get(M)??null;while(Z){if(Z.type===J)return Z;let X=Z.parentBlockId;Z=X?$.documentIndex.blockIndex.get(X)??null:null}return null}function j2($,M){return $.documentIndex.listItemMarkers.get(M)??null}function W3($,M,J){for(let Z of J)if(Z.regionId===$&&M>=Z.startOffset&&M<=Z.endOffset)return Z.threadIndex;return null}function T3($,M,J,Z){let X=Z.find((A)=>A.threadIndex===$);if(!X)return null;return i6(M,J,X.regionId,X.startOffset)}function i6($,M,J,Z){let X=$0($,J,Z);if(!X)return null;return{anchorBottom:X.top+X.height,anchorLeft:x1(X,Z)+N0(M,X)}}function _A($,M,J){if(J<=M.end)return 0;let Z=$.documentIndex.regionIndex.get(M.regionId);if(!Z)return 0;let X=Z.text.slice(M.end,J);if(!/^[ \t]+$/u.test(X))return 0;return F3(X,M.font)}function HA($,M){for(let[Z,X]of $.regionBounds)if(M.x>=X.left&&M.x<=X.right&&M.y>=X.top&&M.y<=X.bottom)return Z5($,Z,M.y)?.line??null;let J=p6($,M)?.line??null;if(J)return J;for(let Z of $.blocks)if(M.y>=Z.top&&M.y<=Z.bottom){for(let X=$.lines.length-1;X>=0;X--)if($.lines[X].blockId===Z.id)return $.lines[X]}return null}function PA($,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 o6($,M){return $.documentIndex.regionIndex.get(M)??null}function WA($){return $.lines[0]?.top??0}function TA($,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}}function n6($,M,J,Z=null){let X={height:M.height,overscan:Math.max(160,M.height),top:M.top},A=r6($.documentIndex,M,X,[$.selection.anchor.regionId,$.selection.focus.regionId],J,Z);return{blockMap:E2($.documentIndex.document.blocks),estimateRegionBounds:A.estimateRegionBounds,regionBounds:new Map(A.layout.regionBounds),layout:A.layout,paintHeight:Math.max(240,X.height+X.overscan*2),paintTop:Math.max(0,X.top-X.overscan),totalHeight:A.totalHeight,viewport:{height:X.height,top:X.top}}}function t6($,M,J){return C1(M.layout,$,J)??c6(M.layout,$,J)}function R2($,M,J,Z){return x6(M.layout,$,J,Z)}function e6($,M,J){return d6(M.layout,$,J)}function $8($,M,J,Z){return a6(M.layout,$,J,Z)}function M8($,M,J,Z){return s6(M.layout,$,J,Z)}function J8($,M,J){return c1(M.layout,$.documentIndex,J)}function M0($,M,J){let Z=c1(M.layout,$.documentIndex,J);if(!Z)return null;return{...Z,left:d1($,M.layout,Z)}}function X8($,M,J){let Z=J.trim();if(Z.length===0||M.startOffset===M.endOffset)return null;let X=$.regionIndex.get(M.regionId)??null,A=X?Z8($,X):null;if(!A)return null;return W6({anchor:T2(A,M.startOffset,M.endOffset),body:Z,quote:y2(A,M.startOffset,M.endOffset)})}function f1($){let M="documentIndex"in $?$.documentIndex:$,J=Q5(M),Z=M.document.comments,X=[...Z],A=[];for(let[Y,Q]of Z.entries()){let K=V2(Q,M.document);if(!K.match)continue;let N=J.findBySemanticMatch(K.match.containerId,K.match.containerOrdinal)?.runtimeContainer??null;if(!N)continue;if(K.repair)X[Y]={...Q,anchor:K.repair.anchor,quote:K.repair.quote};A.push({endOffset:K.match.endOffset,resolution:K,regionId:N.id,resolved:Q.resolvedAt!=null,startOffset:K.match.startOffset,threadIndex:Y})}return{liveRanges:A,threads:X}}function A8($,M,J,Z,X,A){if($.document.comments.length===0)return M.document.comments;let Y=$.commentContainerIndex.get(J.semanticRegionId)??[],Q=new Set(Y);if(Y.length===0)return M.document.comments;let K=f1($),q=new Map(K.liveRanges.map((B)=>[B.threadIndex,B])),N=Z8($,J),U=t0(M,J.path),G=U?Z8(M,U):null;if(!N||!G)return M.document.comments;return M.document.comments.map((B,D)=>{if(!Q.has(D))return B;let F=q.get(D),H=F?.resolution.match??null;if(!F||!H||H.containerId!==N.id)return B;let b=VA(H.startOffset,H.endOffset,Z,X,A.length);if(!b)return B;return{...B,anchor:T2(G,b.start,b.end),quote:y2(G,b.start,b.end)}})}function Z8($,M){let J=yA($,M);if(!J)return null;return{containerKind:J,containerOrdinal:-1,id:M.semanticRegionId,text:M.text}}function yA($,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 VA($,M,J,Z,X){let A=Z-J,Y=X-A;if(Z<=$)return{end:M+Y,start:$+Y};if(J>=M)return{end:M,start:$};let Q=Math.max(0,Math.min(J,M)-$),K=Math.max(0,M-Math.max(Z,$)),q=$<J?$:J;return{end:q+Q+X+K,start:q}}function K5($,M){if(M.length===0)return[];let J=Q5($),Z=J.list();return M.map((X)=>({...X,cursorPoint:zA(X,Z,J),viewport:null}))}function zA($,M,J){if(!$.cursor)return null;let Z=OA(M,$.cursor),X=bA(Z,$.cursor);if(X.length!==1)return null;let A=X[0],Y=J.resolveRuntimeContainer(A.container.id);if(!Y)return null;return{offset:Math.max(0,Math.min(A.offset,Y.text.length)),regionId:Y.id}}function OA($,M){return M.kind?$.filter((J)=>J.containerKind===M.kind):$}function bA($,M){if(M.prefix&&M.suffix)return CA($,M.prefix,M.suffix);if(M.prefix)return y3($,M.prefix,"after");if(M.suffix)return y3($,M.suffix,"before");return[]}function y3($,M,J){if(M.length===0)return[];let Z=[];for(let X of $)for(let A of V3(X.text,M))Z.push({container:X,offset:J==="after"?A+M.length:A});return Z}function CA($,M,J){if(M.length===0||J.length===0)return[];let Z=[];for(let X of $)for(let A of V3(X.text,M)){let Y=A+M.length;if(X.text.indexOf(J,Y)!==-1)Z.push({container:X,offset:Y})}return Z}function V3($,M){let J=[],Z=0;while(Z<=$.length){let X=$.indexOf(M,Z);if(X===-1)break;J.push(X),Z=X+Math.max(1,M.length)}return J}var EA=48;function q5($,M,J){let Z="documentIndex"in $?$.documentIndex:$;if(J.length===0)return[];return J.map((X)=>({...X,viewport:wA(Z,M,X)}))}function wA($,M,J){if(!J.cursorPoint)return z3();let Z=c1(M.layout,$,J.cursorPoint),X=Z?{bottom:Z.top+Z.height,top:Z.top}:M.estimateRegionBounds(J.cursorPoint.regionId);if(!X)return z3();return{scrollTop:RA(M,X),status:jA(M,X)}}function jA($,M){let J=$.viewport.top,Z=J+$.viewport.height;if(M.bottom<J)return"above";if(M.top>Z)return"below";return"visible"}function RA($,M){let J=Math.max(0,$.totalHeight-$.viewport.height),Z=M.top-Math.min(EA,$.viewport.height/4);return Math.max(0,Math.min(J,Z))}function z3(){return{scrollTop:null,status:"unresolved"}}function Q5($){let M=i4($.document),J=new Map(M.map((X)=>[X.id,X])),Z=new Map($.regions.map((X)=>[X.semanticRegionId,X]));return{findBySemanticMatch(X,A){let Y=J.get(X)??M[A]??null;if(!Y)return null;return{runtimeContainer:Z.get(Y.id)??null,semanticContainer:Y}},list(X){return X?M.filter((A)=>A.containerKind===X):M},resolveRuntimeContainer(X){return Z.get(X)??null}}}var L2="",O3=1e6;function k2($,M,J){return`${$}:${M}:${J}`}function U1($){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]=W1({marks:Z.marks,path:Z.id,text:Z.text+J.text});continue}M.push(J)}return M}function e0($){let M=aA($),J=Q8(M.blocks.map((Z,X)=>u2(Z,X)));return K8(M,J)}function u2($,M){let J=[],Z=[],X=[],A=0;function Y(K,q,N,U,G=null){if(Z.length>0)X.push(`
|
|
20
|
+
`),A+=1;let B=N.map((H)=>H.text).join(""),D=A,F=D+B.length;X.push(B),A=F,Z.push({blockId:K.id,blockType:K.type,end:F,id:`${K.id}:${q}`,path:q,rootIndex:M,inlines:N,semanticRegionId:U,start:D,tableCellPosition:G,text:B})}function Q(K,q,N,U){let G={childBlockIds:[],depth:N,end:A,id:K.id,parentBlockId:U,path:q,regionIds:[],rootIndex:M,start:A,type:K.type};switch(J.push(G),K.type){case"blockquote":case"listItem":for(let[B,D]of K.children.entries())G.childBlockIds.push(D.id),Q(D,`${q}.children.${B}`,N+1,K.id);break;case"code":{Y(K,`${q}.source`,[{end:K.source.length,id:`${K.id}:code`,image:null,inlineCode:!1,kind:"text",link:null,marks:[],originalType:null,start:0,text:K.source}],K.id),G.regionIds.push(Z.at(-1).id);break}case"heading":case"paragraph":Y(K,`${q}.children`,Y8(K.children),K.id),G.regionIds.push(Z.at(-1).id);break;case"list":for(let[B,D]of K.items.entries())G.childBlockIds.push(D.id),Q(D,`${q}.children.${B}`,N+1,K.id);break;case"table":for(let[B,D]of K.rows.entries())for(let[F,H]of D.cells.entries())Y(K,`${q}.rows.${B}.cells.${F}`,Y8(H.children),H.id,{cellIndex:F,rowIndex:B}),G.regionIds.push(Z.at(-1).id);break;case"thematicBreak":break;case"directive":break;case"unsupported":Y(K,`${q}.source`,[{end:K.source.length,id:`${K.id}:unsupported`,image:null,inlineCode:!1,kind:"unsupported",link:null,marks:[],originalType:K.originalType,start:0,text:K.source}],K.id),G.regionIds.push(Z.at(-1).id);break}G.end=A}return Q($,`root.${M}`,0,null),{blockRange:{end:J.length,start:0},blocks:J,end:A,length:A,regionRange:Z.length>0?{end:Z.length,start:0}:void 0,regions:Z,rootIndex:M,start:0,text:X.join("")}}function Q8($,M=null){let J=[],Z=0,X=0,A=0,Y=!1;for(let[Q,K]of $.entries()){if(K.regions.length>0&&Y)A+=1;let q={...K,blockRange:{end:Z+K.blocks.length,start:Z},end:A+K.length,regionRange:K.regions.length>0?{end:X+K.regions.length,start:X}:void 0,start:A},N=M?.[Q];if(J.push(kA(N,K,q)?N:b3(K,q)),Z=q.blockRange.end,X=q.regionRange?.end??X,K.regions.length>0)A=q.end,Y=!0}return J}function $2($,M,J,Z){let X=M.blocks.length-($.roots.length-Z);if(X<0)throw Error("Editor model splice received an invalid replacement count.");if(J===$.roots.length&&X===1){let K=M.blocks[J];if(K)return LA($,M,K)}let A=X===Z,Y=[...$.roots.slice(0,J),...M.blocks.slice(J,J+X).map((K,q)=>u2(K,J+q)),...A?$.roots.slice(J+Z):M.blocks.slice(J+X).map((K,q)=>u2(K,J+X+q))],Q=Q8(Y,$.roots);return K8(M,Q,$)}function LA($,M,J){let Z=$.roots.length,X=u2(J,Z),A=$.roots.some((N)=>N.regions.length>0),Y=X.regions.length>0&&A?$.length+1:$.length,Q=b3(X,{...X,blockRange:{end:$.blocks.length+X.blocks.length,start:$.blocks.length},end:Y+X.length,regionRange:X.regions.length>0?{end:$.regions.length+X.regions.length,start:$.regions.length}:void 0,start:Y}),K=[...$.blocks,...Q.blocks],q=[...$.regions,...Q.regions];return{blockIndex:vA($.blockIndex,Q.blocks),blocks:K,commentContainerIndex:M.comments===$.document.comments?$.commentContainerIndex:C3(M),document:M,engine:"canvas",length:Q.end,listItemMarkers:M.blocks===$.document.blocks?$.listItemMarkers:rA($.listItemMarkers,J),regionIndex:gA($.regionIndex,Q.regions),regionOrderIndex:hA($.regionOrderIndex,Q.regions,$.regions.length),regionPathIndex:IA($.regionPathIndex,Q.regions),regions:q,roots:[...$.roots,Q],tableCellIndex:pA($.tableCellIndex,Q.regions),tableCellRegionIndex:lA($.tableCellRegionIndex,Q.regions),text:cA($.text,Q)}}function S2($,M){if(M.blocks!==$.document.blocks)throw Error("Editor model document replacement requires preserving root blocks.");return K8(M,$.roots,$)}function K8($,M,J=null){let Z=M.flatMap((N)=>N.blocks),X=M.flatMap((N)=>N.regions),{regionIndex:A,regionOrderIndex:Y,regionPathIndex:Q,tableCellIndex:K,tableCellRegionIndex:q}=mA(X);return{blockIndex:SA(Z),blocks:Z,commentContainerIndex:$.comments===J?.document.comments?J.commentContainerIndex:C3($),document:$,engine:"canvas",length:M.at(-1)?.end??0,listItemMarkers:$.blocks===J?.document.blocks?J.listItemMarkers:dA($.blocks),regionIndex:A,regionOrderIndex:Y,regionPathIndex:Q,regions:X,roots:M,tableCellIndex:K,tableCellRegionIndex:q,text:xA(M)}}function b3($,M){let J=M.start-$.start;return{...M,blocks:J===0?$.blocks:fA($.blocks,J),regions:J===0?$.regions:uA($.regions,J)}}function kA($,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 fA($,M){return $.map((J)=>({...J,end:J.end+M,start:J.start+M}))}function uA($,M){return $.map((J)=>({...J,end:J.end+M,start:J.start+M}))}function SA($){let M=new Map;for(let J of $)M.set(J.id,J);return M}function mA($){let M=new Map,J=new Map,Z=new Map,X=new Map,A=new Map;for(let[Y,Q]of $.entries()){if(M.set(Q.id,Q),J.set(Q.id,Y),Z.set(Q.path,Q),!Q.tableCellPosition)continue;X.set(Q.id,Q.tableCellPosition),A.set(k2(Q.blockId,Q.tableCellPosition.rowIndex,Q.tableCellPosition.cellIndex),Q.id)}return{regionIndex:M,regionOrderIndex:J,regionPathIndex:Z,tableCellIndex:X,tableCellRegionIndex:A}}function vA($,M){let J=new Map($);for(let Z of M)J.set(Z.id,Z);return J}function gA($,M){let J=new Map($);for(let Z of M)J.set(Z.id,Z);return J}function hA($,M,J){let Z=new Map($);for(let[X,A]of M.entries())Z.set(A.id,J+X);return Z}function IA($,M){let J=new Map($);for(let Z of M)J.set(Z.path,Z);return J}function pA($,M){let J=new Map($);for(let Z of M)if(Z.tableCellPosition)J.set(Z.id,Z.tableCellPosition);return J}function lA($,M){let J=new Map($);for(let Z of M){if(!Z.tableCellPosition)continue;J.set(k2(Z.blockId,Z.tableCellPosition.rowIndex,Z.tableCellPosition.cellIndex),Z.id)}return J}function rA($,M){let J=new Map($);return f2(J,[M]),J}function cA($,M){if(M.regions.length===0)return $;return $.length>0?`${$}
|
|
21
|
+
${M.text}`:M.text}function xA($){return $.filter((M)=>M.regions.length>0).map((M)=>M.text).join(`
|
|
22
|
+
`)}function C3($){let M=new Map;for(let[J,Z]of $.comments.entries()){let X=V2(Z,$).match?.containerId??null;if(!X)continue;let A=M.get(X)??[];A.push(J),M.set(X,A)}return M}function dA($){let M=new Map;return f2(M,$),M}function f2($,M,J=null){for(let Z of M){if(Z.type==="list"){for(let[X,A]of Z.items.entries())f2($,[A],{index:X,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:"•"});f2($,Z.children,J)}if(Z.type==="blockquote")f2($,Z.children,J)}}function aA($){if($.blocks.length>0)return $;return h0([I({text:""})],$.comments)}function Y8($,M=null){let J=[],Z=0,X=(A)=>{let Y=Z,Q=Y+A.text.length;J.push({...A,end:Q,start:Y}),Z=Q};for(let A of $)switch(A.type){case"break":X({id:A.id,image:null,inlineCode:!1,kind:"break",link:M,marks:[],originalType:null,text:`
|
|
23
|
+
`});break;case"image":X({id:A.id,image:{alt:A.alt,title:A.title,url:A.url,width:A.width},inlineCode:!1,kind:"image",link:M,marks:[],originalType:null,text:sA(A.alt)});break;case"inlineCode":X({id:A.id,image:null,inlineCode:!0,kind:"inlineCode",link:M,marks:[],originalType:null,text:A.code});break;case"link":for(let Y of Y8(A.children,{title:A.title,url:A.url}))X(Y);break;case"text":X({id:A.id,image:null,inlineCode:!1,kind:"text",link:M,marks:A.marks,originalType:null,text:A.text});break;case"unsupported":X({id:A.id,image:null,inlineCode:!1,kind:"unsupported",link:M,marks:[],originalType:A.originalType,text:A.source});break}return J}function sA($){return L2}function N5($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=l0($.document.blocks,J.blockId);if(!Z)return null;return U5(Z,J.path,J.semanticRegionId)}function w3($,M,J,Z,X){if(J>=Z)return null;let A=N5($,M);return A?X(A,J,Z):null}function m2($,M,J,Z,X){let A=w3($,M,J,Z,X);return A?{kind:"replace-block",block:A.block,blockId:A.blockId,selection:A.selection}:null}function U5($,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 X of $.rows)for(let A of X.cells)if(A.id===J)return{block:$,blockPath:Z[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:A,children:A.children,kind:"tableCell",path:Z[1]};return null}function U0($,M,J,Z){switch($.kind){case"inlineBlock":return{block:k1($.block,M),blockId:$.block.id,selection:E3(`${$.path}.children`,J,Z)};case"tableCell":{let X=X0({children:M,path:$.path}),A=$.block.rows.map((Y)=>({...Y,cells:Y.cells.map((Q)=>Q.id===$.cell.id?X:Q)}));return{block:r1($.block,A),blockId:$.block.id,selection:E3($.path,J,Z)}}}}function E3($,M,J){return{endOffset:J,kind:"region-range-path",path:$,startOffset:M}}function P1($){switch($.type){case"break":return 1;case"image":return L2.length;case"inlineCode":return $.code.length;case"link":return F1($.children).length;case"text":return $.text.length;case"unsupported":return $.source.length}}function G5($,M,J){if(M<=0)return[];return q8($,0,M,`${J}.before`)}function B5($,M,J){let Z=P1($);if(M>=Z)return[];return q8($,M,Z,`${J}.after`)}function q8($,M,J,Z){if(M>=J)return[];switch($.type){case"text":return U1([b0($.text.slice(M,J),$.marks,Z)].filter(Boolean));case"inlineCode":return[U8($.code.slice(M,J),Z)];case"link":{let X=U1(iA($.children,M,J,`${Z}.children`));return X.length>0?[{...$,children:X}]:[]}default:return[]}}function N8($,M,J){let Z=0,X="";for(let A of $){let Y=P1(A),Q=Z,K=Q+Y;if(Z=K,J<=Q||M>=K)continue;X+=oA(A,Math.max(0,M-Q),Math.min(Y,J-Q))}return X}function b0($,M,J){if($.length===0)return null;return W1({marks:M,path:J,text:$})}function U8($,M){return S0({code:$,path:M})}function iA($,M,J,Z){let X=[],A=0;for(let[Y,Q]of $.entries()){let K=P1(Q),q=A,N=q+K;if(A=N,J<=q||M>=N)continue;X.push(...q8(Q,Math.max(0,M-q),Math.min(K,J-q),`${Z}.${Y}`))}return X}function oA($,M,J){if(M>=J)return"";switch($.type){case"break":return`
|
|
24
|
+
`.slice(M,J);case"image":return L2.slice(M,J);case"inlineCode":return $.code.slice(M,J);case"link":return N8($.children,M,J);case"text":return $.text.slice(M,J);case"unsupported":return $.source.slice(M,J)}}function G8($,M,J,Z){let X=nA($.children,M,J,Z);if(X===null)return null;let A=U1(j3($.children,M,J,Z,X,`${$.path}.children`));return A.length>0?U0($,A,M,J):null}function B8($,M,J){let Z=0,X=null,A=(Y)=>{for(let Q of Y){let K=P1(Q),q=Z,N=q+K;if(Z=N,J<=q||M>=N)continue;if(Q.type==="text"){let U=Math.max(M,q);if(Math.min(J,N)>U)X=X===null?new Set(Q.marks):new Set(Q.marks.filter((B)=>X?.has(B)));continue}if(Q.type==="link"){let U=Z;Z=q,A(Q.children),Z=U}}};return A($.children),X?[...X]:[]}function nA($,M,J,Z){let X=0,A=!1,Y=!0,Q=(K)=>{for(let q of K){let N=P1(q),U=X,G=U+N;if(X=G,J<=U||M>=G)continue;if(q.type==="text"){let B=Math.max(M,U);if(Math.min(J,G)>B)A=!0,Y&&=q.marks.includes(Z);continue}if(q.type==="link"){let B=X;X=U,Q(q.children),X=B}}};return Q($),A?Y:null}function j3($,M,J,Z,X,A){let Y=[],Q=0;for(let[K,q]of $.entries()){let N=Q,U=P1(q),G=N+U,B=`${A}.${K}`;if(Q=G,J<=N||M>=G){Y.push(q);continue}if(q.type==="text"){Y.push(...tA(q,Math.max(0,M-N),Math.min(U,J-N),Z,X,B));continue}if(q.type==="link"){let D=U1(j3(q.children,Math.max(0,M-N),Math.min(U,J-N),Z,X,`${B}.children`));if(D.length>0)Y.push({...q,children:D});continue}Y.push(q)}return Y}function tA($,M,J,Z,X,A){let Y=$.text.slice(0,M),Q=$.text.slice(M,J),K=$.text.slice(J),q=X?$.marks.filter((N)=>N!==Z):eA($.marks,Z);return[b0(Y,$.marks,`${A}.before`),b0(Q,q,`${A}.selected`),b0(K,$.marks,`${A}.after`)].filter(Boolean)}function eA($,M){return $.includes(M)?$:[...$,M].sort()}function F8($,M,J){let Z=U1($Y($.children,M,J,`${$.path}.children`));return Z.length>0?U0($,Z,M,J):null}function $Y($,M,J,Z){let X=L3($,M,J);if(X)return R3($,M,J,X.code,Z,!1);let A=N8($,M,J);if(A.length===0)return $;return R3($,M,J,A,Z,!0)}function L3($,M,J){let Z=0;for(let X of $){let A=P1(X),Y=Z,Q=Y+A;if(Z=Q,M===Y&&J===Q&&X.type==="inlineCode")return X;if(X.type==="link"){let K=L3(X.children,Math.max(0,M-Y),Math.min(A,J-Y));if(K)return K}}return null}function R3($,M,J,Z,X,A){let Y=[],Q=0,K=!1;for(let[q,N]of $.entries()){let U=`${X}.${q}`,G=P1(N),B=Q,D=B+G;if(Q=D,J<=B||M>=D){Y.push(N);continue}if(!K){Y.push(...G5(N,Math.max(0,M-B),U));let F=A?U8(Z,`${X}.selected`):b0(Z,[],`${X}.selected`);if(F)Y.push(F);K=!0}Y.push(...B5(N,Math.min(G,J-B),U))}return Y}function F5($,M,J,Z,X){return m2($,M,J,Z,(A,Y,Q)=>k3(A,Y,Q,X))}function k3($,M,J,Z){let X=U1(MY($.children,M,J,Z,`${$.path}.children`)??[]);return X.length>0?U0($,X,M,J):null}function MY($,M,J,Z,X){let A=[],Y=0,Q=!1;for(let[K,q]of $.entries()){let N=`${X}.${K}`,U=P1(q),G=Y,B=G+U;if(Y=B,!Q&&q.type==="link"&&M===G&&J===B){if(Z===null)A.push(...q.children);else A.push(m0({children:q.children,path:N,title:q.title,url:Z}));Q=!0;continue}A.push(q)}return Q?A:null}function D8($,M,J){let Z=U1(JY($.children,M,J,`${$.path}.children`));return U0($,Z,M+1,M+1)}function JY($,M,J,Z){let X=[],A=0,Y=!1;for(let[Q,K]of $.entries()){let q=`${Z}.${Q}`,N=P1(K),U=A,G=U+N;if(A=G,J<=U||M>=G){X.push(K);continue}if(!Y)X.push(...G5(K,Math.max(0,M-U),q)),X.push(H2({path:`${Z}.selected`})),Y=!0;X.push(...B5(K,Math.min(N,J-U),q))}if(!Y)X.push(H2({path:`${Z}.selected`}));return X}function X1($,M,J=0){return{childIndices:M,kind:"descendant-primary-region",offset:J,rootIndex:$}}function M1($,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 J0($,M){return $.regionIndex.get(M)??null}function t0($,M){return $.regionPathIndex.get(M)??null}function M2($,M,J,Z){let X=$.tableCellRegionIndex.get(k2(M,J,Z));return X?$.regionIndex.get(X)??null:null}function H8($){return $.anchor.regionId===$.focus.regionId&&$.anchor.offset===$.focus.offset}function n($,M){let J="documentIndex"in $?$.documentIndex:$,Z="documentIndex"in $?$.selection:M,X=f3(J,Z.anchor),A=f3(J,Z.focus);if(X<=A)return{end:Z.focus,start:Z.anchor};return{end:Z.anchor,start:Z.focus}}function v2($,M){if(!M)return null;if("kind"in M){if(M.kind==="root-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?_8($,Z):null;return X?D5(X.id,_5(X.text,M.offset)):null}if(M.kind==="descendant-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?ZY(Z,M.childIndices):null,A=X?_8($,X):null;return A?D5(A.id,_5(A.text,M.offset)):null}if(M.kind==="table-cell"){let Z=$.document.blocks[M.rootIndex];if(!Z||Z.type!=="table")return null;let X=M2($,Z.id,M.rowIndex,M.cellIndex);return X?D5(X.id,_5(X.text,M.offset)):null}let J=t0($,M.path);if(!J)return null;if(M.kind==="region-path")return D5(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 f3($,M){let J=$.regionOrderIndex.get(M.regionId);if(J===void 0)throw Error(`Unknown canvas region: ${M.regionId}`);return J*O3+M.offset}function D5($,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 ZY($,M){let J=$;for(let Z of M){if(!J)return null;let X=u3(J);if(!X)return null;J=X[Z]??null}return J}function _8($,M){let J=$.blockIndex.get(M.id);if(!J)return null;let Z=J.regionIds[0];if(Z)return $.regionIndex.get(Z)??null;let X=u3(M);if(!X)return null;for(let A of X){let Y=_8($,A);if(Y)return Y}return null}function u3($){switch($.type){case"list":return $.items;case"blockquote":case"listItem":return $.children;default:return null}}function g2($){let M=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null,J=M?$.documentIndex.blockIndex.get(M.blockId)??null:null,Z=$.selection.anchor.offset,X=M?.inlines.find((A)=>Z>A.start&&Z<A.end)??M?.inlines.find((A)=>A.end===Z)??M?.inlines.find((A)=>A.start===Z)??null;return{block:J?{blockId:J.id,depth:J.depth,nodeType:J.type,text:M?.text??""}:null,span:X?.link?{kind:"link",url:X.link.url}:X&&X.marks.length>0?{kind:"marks",marks:X.marks}:{kind:"none"}}}function H5($){let M=n($.documentIndex,$.selection);if(M.start.regionId!==M.end.regionId||M.start.offset===M.end.offset)return[];let J=$.documentIndex.regionIndex.get(M.start.regionId);if(!J)return[];let Z=l0($.documentIndex.document.blocks,J.blockId);if(!Z)return[];let X=U5(Z,J.path,J.semanticRegionId);return X?B8(X,M.start.offset,M.end.offset):[]}function P5($,M,J,Z=null){return J2($,M,1,[J],Z)}function J2($,M,J,Z,X=null){return{document:I0($.document,M,J,Z),selection:X}}function W5($,M,J,Z=null){return h2($,M,()=>J,Z)}function h2($,M,J,Z=null){let X=$.blockIndex.get(M);if(!X)return null;let A=$.document.blocks[X.rootIndex];if(!A)return null;let Y=S3(A,M,J);return Y?J2($,X.rootIndex,1,[Y],Z):null}function S3($,M,J){if($.id===M)return J($);switch($.type){case"blockquote":{let Z=P8($.children,M,J);return Z?T1({children:Z}):null}case"listItem":{let Z=P8($.children,M,J);return Z?b1($,Z):null}case"list":{let Z=P8($.items,M,J);return Z?$1($,Z):null}default:return null}}function P8($,M,J){let Z=!1,X=$.map((A)=>{let Y=S3(A,M,J);if(!Y)return A;return Z=!0,Y});return Z?X:null}function y5($,M,J){let Z=n($,M);if(Z.start.regionId===Z.end.regionId)return XY($,Z,J);return KY($,Z,J)}function XY($,M,J){let Z=J0($,M.start.regionId);if(!Z)throw Error(`Unknown region: ${M.start.regionId}`);let X=h2($,Z.blockId,(q)=>AY(q,Z,M.start.offset,M.end.offset,J));if(!X)throw Error(`Failed to replace block for canvas region: ${Z.id}`);let A=$2($,X.document,Z.rootIndex,1),Y=$.document.comments.length===0?A:l3($,A,Z,M.start.offset,M.end.offset,J),Q=t0(Y,Z.path);if(!Q)throw Error(`Failed to remap region after replacement: ${Z.path}`);let K=M.start.offset+J.length;return{documentIndex:Y,selection:r3(Q.id,K)}}function AY($,M,J,Z,X){switch($.type){case"heading":case"paragraph":return YY($,M,J,Z,X);case"code":return c4($,m3(M,J,Z,X));case"table":return QY($,M,J,Z,X);case"unsupported":return x4($,m3(M,J,Z,X));default:throw Error(`Canvas text replacement is not supported for block type: ${$.type}`)}}function YY($,M,J,Z,X){let A=p2(M.inlines,J,Z,X),Y=V5(A);return k1($,Y)}function QY($,M,J,Z,X){let A=M.tableCellPosition?.rowIndex,Y=M.tableCellPosition?.cellIndex;if(A===void 0||Y===void 0)throw Error(`Unable to resolve table cell position for region: ${M.id}`);let Q=p2(M.inlines,J,Z,X),K=V5(Q),q=$.rows.map((N,U)=>{if(U!==A)return N;let G=N.cells.map((B,D)=>{if(D!==Y)return B;return X0({children:K})});return{...N,cells:G}});return r1($,q)}function m3($,M,J,Z){return p2($.inlines,M,J,Z).map((X)=>X.text).join("")}function I2($){return $!==null&&($.type==="heading"||$.type==="paragraph")}function KY($,M,J){let Z=J0($,M.start.regionId),X=J0($,M.end.regionId);if(!Z||!X)throw Error("Unknown cross-region selection endpoints.");let A=$.document.blocks[Z.rootIndex],Y=$.document.blocks[X.rootIndex];if(!A||!Y)throw Error("Unknown root blocks for cross-region selection.");let Q=h3(A,Z,M.start.offset),K=I3(Y,X,M.end.offset),q=qY(Q,K,J),N=q.blocks.length>0?q.blocks:[I({text:""})],U=Z.rootIndex,G=X.rootIndex-Z.rootIndex+1,B=I0($.document,U,G,N),D=$2($,B,U,G),F=$.document.comments.length===0?D:l3($,D,Z,M.start.offset,Z.text.length,I2(Q)?J:""),H=F.roots[U+q.caretLocalIndex]?.regions[0]??null;return{documentIndex:F,selection:r3(H?.id??Z.id,H?q.caretOffset:0)}}function qY($,M,J){if(I2($)&&I2(M))return{blocks:[NY($,M,J)],caretLocalIndex:0,caretOffset:$.plainText.length+J.length};if(I2($)){let A=[J.length>0?UY($,J):$];if(M)A.push(M);return{blocks:A,caretLocalIndex:0,caretOffset:$.plainText.length+J.length}}if(I2(M)){let X=J.length>0?GY(M,J):M,A=[];if($)A.push($);let Y=A.length;return A.push(X),{blocks:A,caretLocalIndex:Y,caretOffset:J.length}}let Z=[];if($)Z.push($);if(J.length>0){let X=Z.length;if(Z.push(I({text:J})),M)Z.push(M);return{blocks:Z,caretLocalIndex:X,caretOffset:J.length}}if(M){let X=Z.length;return Z.push(M),{blocks:Z,caretLocalIndex:X,caretOffset:0}}return{blocks:Z,caretLocalIndex:0,caretOffset:0}}function NY($,M,J){let Z=J.length>0?[W1({text:J})]:[];return k1($,U1([...$.children,...Z,...M.children]))}function UY($,M){return k1($,U1([...$.children,W1({text:M})]))}function GY($,M){return k1($,U1([W1({text:M}),...$.children]))}function h3($,M,J){if($.type==="table")return null;if($.id===M.blockId)return BY($,M,J);return p3($,(Z)=>DY(Z,M,J))}function I3($,M,J){if($.type==="table")return null;if($.id===M.blockId)return FY($,M,J);return p3($,(Z)=>_Y(Z,M,J))}function BY($,M,J){if(J===0)return null;switch($.type){case"heading":case"paragraph":{let Z=p2(M.inlines,J,M.text.length,"");return k1($,V5(Z))}case"code":return c4($,M.text.slice(0,J));case"unsupported":return x4($,M.text.slice(0,J));default:return null}}function FY($,M,J){if(J===M.text.length)return null;switch($.type){case"heading":case"paragraph":{let Z=p2(M.inlines,0,J,"");return k1($,V5(Z))}case"code":return c4($,M.text.slice(J));case"unsupported":return x4($,M.text.slice(J));default:return null}}function p3($,M){switch($.type){case"blockquote":{let J=M($.children);return J.length===0?null:T1({children:J})}case"list":{let J=M($.items);return J.length===0?null:$1($,J)}case"listItem":{let J=M($.children);return J.length===0?null:b1($,J)}default:return null}}function DY($,M,J){let Z=$.findIndex((Y)=>T5(Y,M));if(Z===-1)return[];let X=$.slice(0,Z),A=h3($[Z],M,J);return A?[...X,A]:X}function _Y($,M,J){let Z=$.findIndex((Y)=>T5(Y,M));if(Z===-1)return[];let X=$.slice(Z+1),A=I3($[Z],M,J);return A?[A,...X]:X}function T5($,M){if($.id===M.blockId)return!0;switch($.type){case"blockquote":case"listItem":return $.children.some((J)=>T5(J,M));case"list":return $.items.some((J)=>T5(J,M));default:return!1}}function l3($,M,J,Z,X,A){let Y=A8($,M,J,Z,X,A);return Y===M.document.comments?M:S2(M,{...M.document,comments:Y})}function r3($,M){return{anchor:{regionId:$,offset:M},focus:{regionId:$,offset:M}}}function p2($,M,J,Z){let A=HY($,M,J,{didInsert:!1,generatedRunCount:0,replacementText:Z});return VY(zY(A))}function V5($){let M=[];for(let J=0;J<$.length;J+=1){let Z=$[J];if(Z.link){let A=[],Y=Z.link;while(J<$.length&&T8($[J].link,Y)){let Q=g3($[J]);if(Q)A.push(Q);J+=1}if(J-=1,A.length>0)M.push(m0({children:U1(A),title:Y.title,url:Y.url}));continue}let X=g3(Z);if(X)M.push(X)}return U1(M)}function HY($,M,J,Z){let X=[];for(let[A,Y]of $.entries()){if(!Z.didInsert&&M===J&&M===Y.start)W8(X,Z,v3($[A-1]??null,Y));if(J<=Y.start||M>=Y.end){X.push(z5(Y));continue}let Q=Math.max(0,M-Y.start),K=Math.min(Y.text.length,J-Y.start),q=!Z.didInsert&&Z.replacementText.length>0?Z.replacementText:"",N=PY(Y,Q,K,q,Z);if(Q!==K||q.length>0)Z.didInsert=!0;X.push(...N)}if(!Z.didInsert)W8(X,Z,v3($.at(-1)??null,null));return X}function PY($,M,J,Z,X){switch($.kind){case"text":case"inlineCode":case"unsupported":return WY($,M,J,Z);case"break":return TY($,M,J,Z,X);case"image":return yY($,M,J,Z)}}function WY($,M,J,Z){let X=$.text.slice(0,M)+Z+$.text.slice(J);return X.length>0?[{...z5($),text:X}]:[]}function TY($,M,J,Z,X){if(M===J)return[z5($)];let A=[];if(Z.length>0)W8(A,X,$.link);return A}function yY($,M,J,Z){if(M===0&&J===$.text.length)return Z.length>0?[c3(Z,$.link,0)]:[];return[z5($)]}function W8($,M,J){if(M.replacementText.length===0){M.didInsert=!0;return}$.push(c3(M.replacementText,J,M.generatedRunCount)),M.generatedRunCount+=1,M.didInsert=!0}function c3($,M,J){return{id:`generated:${J}`,image:null,inlineCode:!1,kind:"text",link:M,marks:[],originalType:null,text:$}}function v3($,M){return $?.link&&M?.link&&T8($.link,M.link)?$.link:null}function z5($){return{id:$.id,image:$.image,inlineCode:$.inlineCode,kind:$.kind,link:$.link,marks:$.marks,originalType:$.originalType,text:$.text}}function VY($){let M=[],J=0;for(let Z of $){let X=J,A=X+Z.text.length;M.push({...Z,end:A,start:X}),J=A}return M}function zY($){let M=[];for(let J of $){let Z=M.at(-1);if(Z&&OY(Z,J)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function OY($,M){return $.kind===M.kind&&$.inlineCode===M.inlineCode&&T8($.link,M.link)&&CY($.image,M.image)&&$.originalType===M.originalType&&$.marks.join(",")===M.marks.join(",")}function g3($){switch($.kind){case"break":return H2();case"image":return $.image?bY($.image):null;case"inlineCode":return S0({code:$.text});case"text":return $.text.length>0?W1({marks:$.marks,text:$.text}):null;case"unsupported":return p4({originalType:$.originalType??"unsupported",source:$.text})}}function bY($){return I4({alt:$.alt,title:$.title,url:$.url,width:$.width})}function T8($,M){return $?.url===M?.url&&$?.title===M?.title}function CY($,M){return $?.url===M?.url&&$?.title===M?.title&&$?.alt===M?.alt&&$?.width===M?.width}function x3($,M){switch(M.kind){case"replace-block":return W5($,M.blockId,M.block,M.selection??null);case"replace-root":return P5($,M.rootIndex,M.block,M.selection??null);case"replace-root-range":return J2($,M.rootIndex,M.count,M.replacements,M.selection??null);case"replace-selection":{let J=y5($,M.selection,M.text);return{document:J.documentIndex.document,documentIndex:J.documentIndex,selection:J.selection}}}return null}var y8=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function l2($){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 z8($,M){let J=M??wY();return $.animations.some((Z)=>J-Z.startedAt<l2(Z))}function a3($,M){return O8($,M,"inserted-text-highlight",(J)=>J.regionPath)}function s3($,M){return X9($,M,"active-block-flash",(J)=>J.blockPath)}function i3($,M){return O8($,M,"deleted-text-fade",(J)=>J.regionPath)}function o3($,M){return O8($,M,"punctuation-pulse",(J)=>J.regionPath)}function n3($,M){return X9($,M,"list-marker-pop",(J)=>J.blockPath)}function t3($,M,J){let Z=new Set([$,M]);for(let X of J){if(X.endOffset<=$||X.startOffset>=M)continue;Z.add(Math.max($,X.startOffset)),Z.add(Math.min(M,X.endOffset))}return[...Z].sort((X,A)=>X-A)}function e3($,M,J){return $.find((Z)=>Z.startOffset<J&&Z.endOffset>M)??null}function $9($,M,J){if(!M)return $;return c2(J.insertHighlightText,$,M.progress)}function M9($,M){return c2($,"rgba(0, 0, 0, 0)",M.progress)}function b5($,M){return c2($,"rgba(0, 0, 0, 0)",M.progress)}function J9($,M){return c2(M.insertHighlightText,"rgba(0, 0, 0, 0)",$.progress)}function Z9($){let M=Math.min(1,$.progress*2);return 0.1+0.9*EY(M)}function r2($,M,J){let Z=Math.max(0,M.progress*2-1);return c2(J.insertHighlightText,$,Z)}function O8($,M,J,Z){let X=new Map;for(let A of $.animations){if(A.kind!==J)continue;let Y=l2(A),Q=M-A.startedAt;if(Q>=Y)continue;let K={...A,progress:Math.max(0,Math.min(1,Q/Y))},q=Z(A),N=X.get(q);if(N)N.push(K);else X.set(q,[K])}return X}function X9($,M,J,Z){let X=new Map;for(let A of $.animations){if(A.kind!==J)continue;let Y=l2(A),Q=M-A.startedAt;if(Q>=Y)continue;X.set(Z(A),{...A,progress:Math.max(0,Math.min(1,Q/Y))})}return X}function EY($){return 1-(1-$)*(1-$)*(1-$)}function c2($,M,J){let Z=d3($),X=d3(M);return`rgba(${V8(O5(Z[0],X[0],J))}, ${V8(O5(Z[1],X[1],J))}, ${V8(O5(Z[2],X[2],J))}, ${O5(Z[3],X[3],J)})`}function wY(){return typeof performance<"u"?performance.now():Date.now()}function d3($){let M=y8.get($);if(M)return M;let J=jY($)??RY($)??LY($)??y8.get("rgba(0, 0, 0, 0)");return y8.set($,J),J}function jY($){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 RY($){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 LY($){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 O5($,M,J){return $+(M-$)*J}function V8($){return Math.round($)}function C5($,M,J=B0()){if(M<=0)return $;let Z=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Z)return $;let X=$.selection.focus.offset,A=Math.max(0,X-M);if(X<=A)return $;return x2($,{endOffset:X,kind:"inserted-text-highlight",regionPath:Z.path,startOffset:A,startedAt:J})}function b8($,M,J=B0()){if(M.text.length===0)return $;return x2($,{kind:"deleted-text-fade",regionPath:M.regionPath,startOffset:M.startOffset,startedAt:J,text:M.text})}function C8($,M,J=B0()){return x2($,{blockPath:M,kind:"active-block-flash",startedAt:J})}function E8($,M=B0()){let J=$.documentIndex.regionIndex.get($.selection.focus.regionId),Z=$.selection.focus.offset-1;if(!J||Z<0||J.text[Z]!==".")return $;return x2($,{kind:"punctuation-pulse",offset:Z,regionPath:J.path,startedAt:M})}function w8($,M,J=B0()){return x2($,{blockPath:M,kind:"list-marker-pop",startedAt:J})}function x2($,M){let J=E5($.animations,M.startedAt);return{...$,animations:[...J,M]}}function E5($,M){return $.filter((J)=>J.startedAt+l2(J)>M)}function B0(){return typeof performance<"u"?performance.now():Date.now()}function A9($){let M=$.documentIndex.regionIndex.get($.selection.focus.regionId);return(M?$.documentIndex.blockIndex.get(M.blockId)??null:null)?.path??""}function w5($,M){let J=Math.max(-1/0,...$.animations.map((Z)=>Z.startedAt));return M.animations.some((Z)=>Z.startedAt>J)}function d2($){let M=e0($),J=Q9(M);return{animations:[],documentIndex:M,future:[],history:[],selection:{anchor:J,focus:J}}}function a2($){let M=f1($.documentIndex);return h0(P2($.documentIndex.document.blocks),M.threads)}function a($,M){if(!M)return null;switch(M.kind){case"keep-state":return $;case"set-selection":return K1($,M.selection);default:{let J=x3($.documentIndex,M);if(!J)return null;let Z=kY($,J.document,J.documentIndex??null),X=v2(Z.documentIndex,J.selection)??$.selection,A=K9($,Z,X);return K1(Z,X,A)}}}function K1($,M,J){let Z="regionId"in M?{anchor:j5($.documentIndex,M),focus:j5($.documentIndex,M)}:{anchor:j5($.documentIndex,M.anchor),focus:j5($.documentIndex,M.focus)},X={...$,selection:Z};return J??K9($,X)?C8(X,A9(X)):X}function E1($,M,J,Z){let X={regionId:M,offset:J};return K1($,Z?{anchor:$.selection.anchor,focus:X}:X)}function kY($,M,J=null){let Z=J??e0(M);return{animations:E5($.animations,B0()),documentIndex:Z,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:fY(Z)}}function j8($){let M=$.history.at(-1);if(!M)return $;let J=e0(M.document);return{animations:[],documentIndex:J,future:[{document:$.documentIndex.document,selection:$.selection},...$.future],history:$.history.slice(0,-1),selection:M.selection}}function R8($){let M=$.future[0];if(!M)return $;let J=e0(M.document);return{animations:[],documentIndex:J,future:$.future.slice(1),history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:M.selection}}function R5($,M,J,Z){let X=UM($.documentIndex.document,M,J,Z),A=S2($.documentIndex,X);return{animations:E5($.animations,B0()),documentIndex:A,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:$.selection}}function fY($){let M=Q9($);return{anchor:M,focus:M}}function Q9($){return $.regions[0]?{regionId:$.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function j5($,M){let J=J0($,M.regionId);if(!J)return M;return{regionId:J.id,offset:Math.max(0,Math.min(M.offset,J.text.length))}}function K9($,M,J){let Z=Y9($.documentIndex,$.selection),X=Y9(M.documentIndex,J??M.selection);return X!==null&&X!==Z}function Y9($,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 o2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return{kind:"unsupported"};if(J.blockType==="code"){let Q=$.blockIndex.get(J.blockId);return Q?{kind:"code",region:J,rootIndex:Q.rootIndex}:{kind:"unsupported"}}let Z=F0($,J.id);if(Z)return{kind:"tableCell",...Z};let X=s1($,M);if(X)return{kind:"listItem",...X};let A=Z2($,M);if(A)return{kind:"blockquoteTextBlock",...A};let Y=a1($,M);if(Y)return{kind:"rootTextBlock",...Y};return{kind:"unsupported"}}function n2($,M){let J=$.blockIndex.get(M);if(!J)throw Error(`Unknown root block: ${M}`);return J.rootIndex}function L5($,M,J){let Z=M?$.blockIndex.get(M)??null:null;while(Z){if(Z.type===J)return Z;let X=Z.parentBlockId;Z=X?$.blockIndex.get(X)??null:null}return null}function s2($){let M=$.split("."),J=[];for(let Z=0;Z<M.length-1;Z+=1)if(M[Z]==="children"){let X=Number(M[Z+1]);if(Number.isInteger(X))J.push(X)}return J}function a1($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId);if(!Z)return null;let X=Z.rootIndex,A=$.document.blocks[X];if(!A||A.type!=="heading"&&A.type!=="paragraph")return null;return{block:A,region:J,rootIndex:X}}function q9($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=L5($,Z?.id??null,"blockquote");if(!X)return null;let A=X.rootIndex,Y=$.document.blocks[A];return Y?.type==="blockquote"?{quote:Y,rootIndex:A}:null}function Z2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=L5($,Z?.id??null,"blockquote");if(!Z||!X||Z.parentBlockId!==X.id)return null;let A=X.rootIndex,Y=$.document.blocks[A];if(!Y||Y.type!=="blockquote")return null;let Q=Y.children.findIndex((q)=>q.id===Z.id),K=Y.children[Q];if(!K||K.type!=="heading"&&K.type!=="paragraph")return null;return{block:K,blockChildIndices:s2(Z.path),childIndex:Q,region:J,quote:Y,rootIndex:A}}function i2($,M){return l0($.document.blocks,M)}function s1($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=L5($,Z?.id??null,"listItem"),A=L5($,Z?.id??null,"list");if(!Z||!X||!A)return null;let Y=i2($,A.id);if(!Y||Y.type!=="list")return null;let Q=Y.items.findIndex((D)=>D.id===X.id),K=Y.items[Q];if(!K)return null;let q=A.parentBlockId?$.blockIndex.get(A.parentBlockId)??null:null,N=q?.parentBlockId?$.blockIndex.get(q.parentBlockId)??null:null,U=q?.type==="listItem"?i2($,q.id):null,G=N?.type==="list"?i2($,N.id):null,B=G?.type==="list"&&U?G.items.findIndex((D)=>D.id===U.id):-1;return{region:J,item:K,itemChildIndices:s2(X.path),itemIndex:Q,list:Y,listChildIndices:s2(A.path),parentItem:U?.type==="listItem"?U:null,parentItemChildIndices:q?.type==="listItem"?s2(q.path):null,parentItemIndex:B>=0?B:null,parentList:G?.type==="list"?G:null,parentListChildIndices:N?.type==="list"?s2(N.path):null,rootIndex:A.rootIndex}}function F0($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=$.tableCellIndex.get(J.id),X=$.blockIndex.get(J.blockId),A=X?.type==="table"?$.document.blocks[X.rootIndex]:null;if(!Z||!X||!A||A.type!=="table")return null;return{cellIndex:Z.cellIndex,rootIndex:X.rootIndex,rowIndex:Z.rowIndex,table:A}}function t2($,M,J){return n1({checked:M,children:[I({text:$})],spread:J})}function X2($,M){let J=$.children[0];if(!J||J.type!=="paragraph")return null;return b1($,[I({text:M}),...$.children.slice(1)])}function N9($,M){return M.reduce((J,Z)=>`${J}.children.${Z}`,`root.${$}`)}function U9($,M,J){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let X=n($,M),A=X.start.regionId===X.end.regionId&&X.start.regionId===Z.id?Z.text.slice(0,X.start.offset)+J+Z.text.slice(X.end.offset):J;return uY($,M,Z.id,A)??mY($,M,Z.id,A)??SY($,M,Z.id,A)??vY($,M,Z.id,A)??IY($,Z.blockId,Z.rootIndex,A)??{kind:"replace-selection",selection:M,text:J}}function uY($,M,J,Z){let X=s1($,M),A=rY(Z);if(!X||!A||X.region.id!==J)return null;let Y=X2(X.item,A.text);if(!Y)return null;return{kind:"replace-block",block:$1(X.list,X.list.items.map((Q,K)=>K===X.itemIndex?Y:Q),{ordered:A.ordered,start:A.ordered?1:null}),blockId:X.list.id,selection:X1(X.rootIndex,[...X.listChildIndices,X.itemIndex,0])}}function SY($,M,J,Z){if(!k8($,M,J))return null;if(/^\s*([-+*])\s\[( |x|X)\]\s$/.exec(Z)){let Y=Z.toLowerCase().includes("[x]");return L8($,M,{checked:Y,ordered:!1,start:null})}if(/^\s*[-+*]\s$/.test(Z))return L8($,M,{checked:null,ordered:!1,start:null});let A=/^\s*(\d+)\.\s$/.exec(Z);if(A)return L8($,M,{checked:null,ordered:!0,start:Number(A[1])});return null}function mY($,M,J,Z){let X=a1($,M),A=cY(Z);if(!X||X.region.id!==J||X.block.type!=="heading"||!A)return null;return{kind:"replace-root",block:Z0({depth:A.depth,text:A.text}),rootIndex:X.rootIndex,selection:M1(X.rootIndex)}}function vY($,M,J,Z){return gY($,M,J,Z)??hY($,M,J,Z)}function gY($,M,J,Z){if(!k8($,M,J))return null;let X=/^(#{1,6})\s$/.exec(Z);if(!X)return null;return pY($,M,X[1].length)}function hY($,M,J,Z){if(!k8($,M,J)||!/^>\s$/.test(Z))return null;return lY($,M)}function IY($,M,J,Z){if(!/^(?:(?:-\s?){3}|(?:\*\s?){3}|(?:_\s?){3})$/.test(Z))return null;return{kind:"replace-root-range",count:1,replacements:[l4(),I({text:""})],rootIndex:n2($,M),selection:M1(J+1)}}function L8($,M,J){let Z=n2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:y0({items:[n1({checked:J.checked,children:[I({text:""})],spread:!1})],ordered:J.ordered,spread:!1,start:J.start}),rootIndex:Z,selection:X1(Z,[0,0])}}function pY($,M,J){let Z=n2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:Z0({depth:J,text:""}),rootIndex:Z,selection:M1(Z)}}function lY($,M){let J=n2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:T1({children:[I({text:""})]}),rootIndex:J,selection:X1(J,[0])}}function k8($,M,J){let Z=a1($,M);return Z?.region.id===J&&Z.block.type==="paragraph"}function rY($){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 cY($){let M=/^(#{1,6})\s(.+)$/.exec($);return M?{depth:M[1].length,text:M[2]}:null}function G9($,M){let J=n($,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 X=Z.region.text,A=Z.item,Y=typeof A.checked==="boolean"?!1:A.checked;if(J.start.offset===0){let U=t2("",Y,A.spread);return{kind:"replace-block",block:$1(Z.list,[...Z.list.items.slice(0,Z.itemIndex),U,A,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:k5(U,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex]),selection:X1(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex,0])}}if(J.start.offset===X.length){let U=t2("",Y,A.spread);return{kind:"replace-block",block:$1(Z.list,[...Z.list.items.slice(0,Z.itemIndex+1),U,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:k5(U,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1]),selection:X1(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1,0])}}let Q=X.slice(0,J.start.offset),K=X.slice(J.start.offset),q=t2(K,Y,A.spread),N=b1(A,[I({text:Q})]);return{kind:"replace-block",block:$1(Z.list,[...Z.list.items.slice(0,Z.itemIndex),N,q,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:k5(q,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1]),selection:X1(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1,0])}}function B9($,M){let J=n($,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 G9($,M);if(Z.parentItem&&Z.parentItemIndex!==null&&Z.parentItemChildIndices&&Z.parentList&&Z.parentListChildIndices)return xY(Z);let X=Z.list.items.slice(0,Z.itemIndex),A=Z.list.items.slice(Z.itemIndex+1),Y=[];if(X.length>0)Y.push($1(Z.list,X));if(Y.push(I({text:""})),A.length>0)Y.push($1(Z.list,A));return{kind:"replace-root-range",count:1,replacements:Y,rootIndex:Z.rootIndex,selection:M1(Z.rootIndex+(X.length>0?1:0))}}function F9($,M){let J=s1($,M);if(!J)return null;if(typeof J.item.checked==="boolean"){let Z=n1({checked:null,children:J.item.children,spread:J.item.spread});return{kind:"replace-block",block:$1(J.list,J.list.items.map((X,A)=>A===J.itemIndex?Z:X)),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:$1(J.list,J.list.items.filter((A,Y)=>Y!==J.itemIndex)),blockId:J.list.id,selection:X1(J.rootIndex,[...J.listChildIndices,J.itemIndex-1,0],"end")};let X=X2(Z,`${Z.plainText}${J.item.plainText}`);if(!X)return null;return{kind:"replace-block",block:$1(J.list,J.list.items.flatMap((A,Y)=>{if(Y===J.itemIndex-1)return[X];if(Y===J.itemIndex)return[];return[A]})),blockId:J.list.id,selection:X1(J.rootIndex,[...J.listChildIndices,J.itemIndex-1,0],"end")}}return{kind:"replace-root-range",count:1,replacements:[I({text:J.item.plainText})],rootIndex:J.rootIndex,selection:M1(J.rootIndex)}}function D9($,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 X=dY(Z,J.item,J);return{kind:"replace-block",block:$1(J.list,J.list.items.flatMap((A,Y)=>{if(Y===J.itemIndex-1)return[X.item];if(Y===J.itemIndex)return[];return[A]})),blockId:J.list.id,selection:X1(J.rootIndex,X.regionChildIndices)}}function _9($,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((Y,Q)=>Q!==J.itemIndex),X=J.parentItem.children.flatMap((Y)=>{if(Y.type!=="list"||Y.id!==J.list.id)return[Y];if(Z.length===0)return[];return[$1(J.list,Z)]}),A=b1(J.parentItem,X);return{kind:"replace-block",block:$1(J.parentList,[...J.parentList.items.slice(0,J.parentItemIndex),A,J.item,...J.parentList.items.slice(J.parentItemIndex+1)]),blockId:J.parentList.id,selection:X1(J.rootIndex,[...J.parentListChildIndices,J.parentItemIndex+1,0])}}function f8($,M,J){let Z=s1($,M);if(!Z)return null;let X=Z.itemIndex+J;if(X<0||X>=Z.list.items.length)return null;let A=[...Z.list.items],[Y]=A.splice(Z.itemIndex,1);if(!Y)return null;return A.splice(X,0,Y),{kind:"replace-block",block:$1(Z.list,A),blockId:Z.list.id,selection:X1(Z.rootIndex,[...Z.listChildIndices,X,0])}}function xY($){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let M=$.list.items.filter((Y,Q)=>Q!==$.itemIndex),J=$.parentItem.children.flatMap((Y)=>{if(Y.type!=="list"||Y.id!==$.list.id)return[Y];if(M.length===0)return[];return[$1($.list,M)]}),Z=b1($.parentItem,J),X=typeof $.parentItem.checked==="boolean"?!1:$.parentItem.checked,A=t2("",X,$.parentItem.spread);return{kind:"replace-block",block:$1($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),Z,A,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,listItemInsertedPath:k5(A,$.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1]),selection:X1($.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1,0])}}function k5($,M,J){return typeof $.checked==="boolean"?void 0:N9(M,J)}function dY($,M,J){let Z=$.children.findIndex((A)=>A.type==="list"&&A.ordered===J.list.ordered&&A.start===J.list.start);if(Z>=0){let A=$.children[Z];if(!A||A.type!=="list")return{item:$,regionChildIndices:[...J.listChildIndices,J.itemIndex-1,0]};return{item:b1($,$.children.map((Y,Q)=>Q===Z?$1(A,[...A.items,M]):Y)),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,Z,A.items.length,0]}}let X=y0({items:[M],ordered:J.list.ordered,spread:J.list.spread,start:J.list.start});return{item:b1($,[...$.children,X]),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,$.children.length,0,0]}}function f5($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=a1($,M);if(!Z)return aY($,M);let X=Z.region.text.slice(0,J.start.offset),A=Z.region.text.slice(J.start.offset),Y=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?[I({text:""}),Z.block]:J.start.offset===Z.region.text.length?[Z.block,I({text:""})]:[I({text:X}),I({text:A})],rootIndex:Z.rootIndex,selection:M1(Y)};return{kind:"replace-root-range",count:1,replacements:J.start.offset===0?[I({text:""}),Z.block]:J.start.offset===Z.region.text.length?[Z.block,I({text:""})]:[Z0({depth:Z.block.depth,text:X}),I({text:A})],rootIndex:Z.rootIndex,selection:M1(Y)}}function aY($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=Z2($,M);if(!Z)return null;let X=Z.region.text,A=X.slice(0,J.start.offset),Y=X.slice(J.start.offset),Q=Z.block.type==="heading"?eY(Z.block,A,Y,Z.blockChildIndices,J.start.offset,X.length):tY(Z.block,A,Y,Z.blockChildIndices,J.start.offset,X.length);return{kind:"replace-root",block:T1({children:[...Z.quote.children.slice(0,Z.childIndex),...Q.blocks,...Z.quote.children.slice(Z.childIndex+1)]}),rootIndex:Z.rootIndex,selection:X1(Z.rootIndex,Q.focusChildIndices)}}function H9($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=Z2($,M);if(!Z||Z.region.text.length!==0||Z.block.type!=="paragraph")return null;let X=Z.quote.children.slice(0,Z.childIndex),A=Z.quote.children.slice(Z.childIndex+1),Y=[];if(X.length>0)Y.push(T1({children:X}));if(Y.push(I({text:""})),A.length>0)Y.push(T1({children:A}));return{kind:"replace-root-range",count:1,replacements:Y,rootIndex:Z.rootIndex,selection:M1(Z.rootIndex+(X.length>0?1:0))}}function P9($,M){let J=n($,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",selection:M,text:`
|
|
25
|
+
`}}function W9($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=a1($,M),X=Z?oY(Z):null;if(X)return X;if(Z&&Z.rootIndex>0){let K=$.document.blocks[Z.rootIndex-1],q=$.document.blocks[Z.rootIndex+1];if(K){if(Z.block.plainText.length===0){let N=sY(Z,K,q);if(N)return N;return{kind:"replace-root-range",count:1,replacements:[],rootIndex:Z.rootIndex,selection:K.type==="paragraph"||K.type==="heading"?M1(Z.rootIndex-1,"end"):K.type==="list"?X1(Z.rootIndex-1,[K.items.length-1,0],"end"):K.type==="blockquote"?X1(Z.rootIndex-1,[K.children.length-1],"end"):M1(Z.rootIndex-1,"end")}}if(K.type==="paragraph")return{kind:"replace-root-range",count:2,replacements:[I({text:`${K.plainText}${Z.block.plainText}`})],rootIndex:Z.rootIndex-1,selection:M1(Z.rootIndex-1,"end")};if(K.type==="heading")return{kind:"replace-root-range",count:2,replacements:[Z0({depth:K.depth,text:`${K.plainText}${Z.block.plainText}`})],rootIndex:Z.rootIndex-1,selection:M1(Z.rootIndex-1,"end")};if(K.type==="list"){let N=K.items.length-1,U=K.items[N];if(U){let G=X2(U,`${U.plainText}${Z.block.plainText}`);if(G)return{kind:"replace-root-range",count:2,replacements:[$1(K,K.items.map((B,D)=>D===N?G:B))],rootIndex:Z.rootIndex-1,selection:X1(Z.rootIndex-1,[N,0],"end")}}}}}let A=nY($,M);if(A)return A;let Y=q9($,M);if(!Y)return null;let Q=Z2($,M);return{kind:"replace-root-range",count:1,replacements:Y.quote.children,rootIndex:Y.rootIndex,selection:M1(Q?Y.rootIndex+Q.childIndex:Y.rootIndex)}}function u8($,M,J){let Z=a1($,M);if(!Z||Z.block.type!=="heading")return null;let X=Math.max(1,Math.min(6,Z.block.depth+J));if(X===Z.block.depth)return{kind:"keep-state"};return{kind:"replace-root",block:Z0({depth:X,text:Z.block.plainText}),rootIndex:Z.rootIndex,selection:M1(Z.rootIndex,M.focus.offset)}}function sY($,M,J){if($.block.type!=="paragraph"||$.block.plainText.length!==0||M.type!=="list"||J?.type!=="list"||!iY(M,J))return null;let Z=M.items.length-1;return{kind:"replace-root-range",count:3,replacements:[$1(M,[...M.items,...J.items])],rootIndex:$.rootIndex-1,selection:X1($.rootIndex-1,[Z,0],"end")}}function iY($,M){return $.ordered===M.ordered&&$.start===M.start}function oY($){if($.block.type!=="heading")return null;return{kind:"replace-root",block:I({text:$.block.plainText}),rootIndex:$.rootIndex,selection:M1($.rootIndex)}}function nY($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=Z2($,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:[I({text:""})],rootIndex:Z.rootIndex,selection:M1(Z.rootIndex)};let X=Math.max(0,Z.childIndex-1),A=Z.childIndex>0?"end":0;return{kind:"replace-root",block:T1({children:Z.quote.children.filter((Y,Q)=>Q!==Z.childIndex)}),rootIndex:Z.rootIndex,selection:X1(Z.rootIndex,[X],A)}}function tY($,M,J,Z,X,A){return{blocks:X===0?[I({text:""}),$]:X===A?[$,I({text:""})]:[I({text:M}),I({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function eY($,M,J,Z,X,A){return{blocks:X===0?[I({text:""}),$]:X===A?[$,I({text:""})]:[Z0({depth:$.depth,text:M}),I({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function T9($,M,J){let Z=a1($,M),X=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},()=>m8(X))}),rootIndex:Z.rootIndex,selection:G0(Z.rootIndex,0,0)}}function S8($,M,J){let Z=F0($,M.focus.regionId);if(!Z)return null;let X=J<0?ZQ(Z.table,Z.rowIndex,Z.cellIndex):XQ(Z.table,Z.rowIndex,Z.cellIndex);if(!X)return J>0&&AQ(Z.table,Z.rowIndex,Z.cellIndex)?$Q(Z):{kind:"keep-state"};let A=Z.table.rows[X.rowIndex]?.cells[X.cellIndex];if(!A)return{kind:"keep-state"};return{kind:"set-selection",selection:JQ($,M,Z.table,X.rowIndex,X.cellIndex,Math.min(M.focus.offset,A.plainText.length))}}function y9($,M){let J=N5($,M.focus.regionId);if(!J||J.kind!=="tableCell")return null;let Z=Math.min(M.anchor.offset,M.focus.offset),X=Math.max(M.anchor.offset,M.focus.offset),A=D8(J,Z,X);return{kind:"replace-block",block:A.block,blockId:A.blockId,selection:A.selection}}function V9($,M,J){let Z=F0($,M.focus.regionId);if(!Z)return null;let X=J==="left"?Z.cellIndex:Z.cellIndex+1;return A2(Z,V0({align:w9(Z.table.align,X,0,[null]),rows:Z.table.rows.map((A)=>v0({cells:MQ(A.cells,X,0,[E9()])}))}),G0(Z.rootIndex,Z.rowIndex,X))}function z9($,M){let J=F0($,M.focus.regionId);if(!J)return null;let Z=Math.max(0,...J.table.rows.map((X)=>X.cells.length));if(Z<=1)return null;return A2(J,V0({align:w9(J.table.align,J.cellIndex,1,[]),rows:J.table.rows.map((X)=>v0({cells:X.cells.filter((A,Y)=>Y!==J.cellIndex)}))}),G0(J.rootIndex,J.rowIndex,Math.min(J.cellIndex,Z-2)))}function O9($,M,J){let Z=F0($,M.focus.regionId);if(!Z)return null;let X=J==="above"?Z.rowIndex:Z.rowIndex+1,A=Math.max(1,...Z.table.rows.map((Y)=>Y.cells.length));return A2(Z,r1(Z.table,[...Z.table.rows.slice(0,X),m8(A),...Z.table.rows.slice(X)]),G0(Z.rootIndex,X,Math.min(Z.cellIndex,A-1)))}function b9($,M){let J=F0($,M.focus.regionId);if(!J||J.table.rows.length<=1)return null;let Z=J.table.rows.filter((Y,Q)=>Q!==J.rowIndex),X=Math.min(J.rowIndex,Z.length-1),A=Z[X]?.cells.length??1;return A2(J,r1(J.table,Z),G0(J.rootIndex,X,Math.min(J.cellIndex,A-1)))}function C9($,M){let J=F0($,M.focus.regionId);if(!J)return null;return A2(J,I({text:""}),M1(J.rootIndex))}function m8($){return v0({cells:Array.from({length:$},()=>E9())})}function E9(){return X0({children:[]})}function $Q($){let M=$.table.rows.length,J=Math.max(1,...$.table.rows.map((Z)=>Z.cells.length));return A2($,r1($.table,[...$.table.rows,m8(J)]),G0($.rootIndex,M,0))}function A2($,M,J){return{kind:"replace-block",block:M,blockId:$.table.id,selection:J}}function MQ($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function w9($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function JQ($,M,J,Z,X,A){let Y=M2($,J.id,Z,X);if(!Y)return M;return{anchor:{regionId:Y.id,offset:A},focus:{regionId:Y.id,offset:A}}}function ZQ($,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 XQ($,M,J){let Z=$.rows[M];if(!Z)return null;if(J+1<Z.cells.length)return{cellIndex:J+1,rowIndex:M};let X=$.rows[M+1];if(!X||X.cells.length===0)return null;return{cellIndex:0,rowIndex:M+1}}function AQ($,M,J){let Z=$.rows[M];return Boolean(Z&&M===$.rows.length-1&&J===Z.cells.length-1)}function Y2($,M){let J=U9($.documentIndex,$.selection,M),Z=a($,J);if(!Z)return null;if(J?.kind==="replace-selection"&&M.length>0)Z=C5(Z,M.length);if(M===".")Z=E8(Z);return Z}function e2($){switch(o2($.documentIndex,$.selection).kind){case"code":return a($,P9($.documentIndex,$.selection));case"tableCell":return a($,y9($.documentIndex,$.selection));case"listItem":{let J=B9($.documentIndex,$.selection);return KQ({state:a($,J)??a($,f5($.documentIndex,$.selection)),action:J})}case"blockquoteTextBlock":return a($,H9($.documentIndex,$.selection))??a($,f5($.documentIndex,$.selection));case"rootTextBlock":return a($,f5($.documentIndex,$.selection));case"unsupported":return null}}function u5($){if(R9($))return $4($);let M=qQ($);if(M)return M;let J=n($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;switch(o2($.documentIndex,$.selection).kind){case"listItem":return a($,F9($.documentIndex,$.selection));case"blockquoteTextBlock":case"rootTextBlock":return a($,W9($.documentIndex,$.selection));default:return null}}function S5($){if(R9($))return $4($);return NQ($)}function v8($,M){return a($,{kind:"replace-selection",selection:$.selection,text:M})}function m5($,M){let J=v8($,M);return M.length>0?C5(J,M.length):J}function $4($){return v8($,"")}function g8($){let M=$.documentIndex.regions,J=M[0],Z=M.at(-1);if(!J||!Z)return $;return K1($,{anchor:{regionId:J.id,offset:0},focus:{regionId:Z.id,offset:Z.text.length}})}function h8($){switch(o2($.documentIndex,$.selection).kind){case"tableCell":return a($,S8($.documentIndex,$.selection,1));case"rootTextBlock":return a($,u8($.documentIndex,$.selection,1));case"listItem":return YQ($);default:return null}}function I8($){switch(o2($.documentIndex,$.selection).kind){case"tableCell":return a($,S8($.documentIndex,$.selection,-1));case"rootTextBlock":return a($,u8($.documentIndex,$.selection,-1));case"listItem":return QQ($);default:return null}}function YQ($){return a($,D9($.documentIndex,$.selection))}function QQ($){return a($,_9($.documentIndex,$.selection))}function p8($){return a($,f8($.documentIndex,$.selection,-1))}function l8($){return a($,f8($.documentIndex,$.selection,1))}function r8($,M){return a($,T9($.documentIndex,$.selection,M))}function c8($,M){return a($,V9($.documentIndex,$.selection,M))}function x8($){return a($,z9($.documentIndex,$.selection))}function d8($,M){return a($,O9($.documentIndex,$.selection,M))}function a8($){return a($,b9($.documentIndex,$.selection))}function s8($){return a($,C9($.documentIndex,$.selection))}function v5($,M){return j9($,(J,Z,X)=>G8(J,Z,X,M))}function i8($){return j9($,(M,J,Z)=>F8(M,J,Z))}function M4($){return v5($,"bold")}function J4($){return v5($,"italic")}function Z4($){return v5($,"strikethrough")}function X4($){return v5($,"underline")}function o8($,M,J,Z,X){return a($,F5($.documentIndex,M,J,Z,X))}function n8($,M,J,Z){return a($,F5($.documentIndex,M,J,Z,null))}function t8($,M){let J=i2($.documentIndex,M);if(!J||J.type!=="listItem"||typeof J.checked!=="boolean")return null;return a($,{kind:"replace-block",block:{...J,checked:!J.checked},blockId:M})}function g5($){return j8($)}function h5($){return R8($)}function e8($,M,J){let Z=X8($.documentIndex,M,J);if(!Z)return null;return R5($,$.documentIndex.document.comments.length,0,[Z])}function $$($,M,J){return A4($,M,(Z)=>T6(Z,{body:J.trim()}))}function M$($,M,J,Z){return A4($,M,(X)=>y6(X,J,Z))}function J$($,M,J){return A4($,M,(Z)=>V6(Z,J))}function Z$($,M){return A4($,M,()=>null)}function X$($,M,J){return A4($,M,(Z)=>z6(Z,J))}function A4($,M,J){let X=f1($.documentIndex).threads[M];if(!X)return null;let A=J(X);if(A===X)return null;return R5($,M,1,A?[A]:[])}function KQ($){if(!$.state||!$.action||$.action.kind!=="replace-block"||!$.action.listItemInsertedPath)return $.state;return w8($.state,$.action.listItemInsertedPath)}function j9($,M){let J=n($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset===J.end.offset)return null;return a($,m2($.documentIndex,J.start.regionId,J.start.offset,J.end.offset,M))}function R9($){let M=n($.documentIndex,$.selection);return M.start.regionId!==M.end.regionId||M.start.offset!==M.end.offset}function qQ($){return L9($,"backward")}function NQ($){return L9($,"forward")}function L9($,M){if($.selection.anchor.regionId!==$.selection.focus.regionId||$.selection.anchor.offset!==$.selection.focus.offset)return null;let J=J0($.documentIndex,$.selection.focus.regionId);if(!J)return null;if(M==="forward"&&$.selection.focus.offset>=J.text.length)return null;let Z=M==="backward"?BQ(J.text,$.selection.focus.offset):$.selection.focus.offset,X=M==="backward"?$.selection.focus.offset:FQ(J.text,$.selection.focus.offset);if(Z===X)return null;let A=v8(K1($,{anchor:{regionId:J.id,offset:Z},focus:{regionId:J.id,offset:X}}),"");return UQ($,A,Z,X)}function UQ($,M,J,Z){let X=GQ($,J,Z);return X?b8(M,X):M}function GQ($,M,J){let Z=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Z)return null;let X=Z.text.slice(M,J);if(X.length===0)return null;if(!Z.inlines.find((Y)=>Y.start<=M&&Y.end>=J&&Y.kind==="text"&&Y.link===null&&Y.marks.length===0))return null;return{regionPath:Z.path,startOffset:M,text:X}}function BQ($,M){let J=Array.from($.slice(0,M));if(J.length===0)return 0;return M-J.at(-1).length}function FQ($,M){let J=Array.from($.slice(M))[0];return J?M+J.length:$.length}var k9=1;function f9($,M,J){let Z=$.documentIndex.regionOrderIndex.get($.selection.focus.regionId);if(Z===void 0)return $;let X=$.documentIndex.regions[Z],A=$.selection.focus.offset+M;if(A>=0&&A<=X.text.length)return E1($,X.id,A,J);if(M<0){let Q=$.documentIndex.regions[Z-1];if(!Q)return $;return E1($,Q.id,Q.text.length,J)}let Y=$.documentIndex.regions[Z+1];if(!Y)return $;return E1($,Y.id,0,J)}function u9($,M,J,Z,X){let A=C2(M,J.regionId,J.offset);if(!A)return $;let Y=M.lines[A.index+Z];if(!Y)return $;let Q=C1(M,$,{x:d1($,M,J)+k9,y:Y.top+Y.height/2});if(!Q)return $;return E1($,Q.regionId,Q.offset,X)}function S9($,M,J,Z){let X=v9($,M);if(!X)return $;return E1($,X.regionId,J==="Home"?X.start:X.end,Z)}function m9($,M,J,Z,X){let A=v9($,M);if(!A)return $;let Q=Math.max(1,Math.floor(480/M.options.lineHeight)),K=C2(M,A.regionId,$.selection.focus.offset),q=K?M.lines[K.index+Z*Q]:null;if(!q)return $;let N=C1(M,$,{x:d1($,M,J)+k9,y:q.top+q.height/2});if(!N)return $;return E1($,N.regionId,N.offset,X)}function v9($,M){return $0(M,$.selection.focus.regionId,$.selection.focus.offset)}var DQ=1;function g9($,M,J,Z,X){let A=$.documentIndex.regionIndex.get($.selection.focus.regionId)??null;if(!A)return null;let Y=$.documentIndex.tableCellIndex.get(A.id)??null,Q=$.documentIndex.blockIndex.get(A.blockId)??null;if(!Y||Q?.type!=="table")return null;let K=_Q($,Q.id,Y.rowIndex+Z,Y.cellIndex)??HQ($,Q.id,Z);if(!K)return $;let q=M.regionBounds.get(A.id),N=M.regionBounds.get(K.id);if(!q||!N)return $;let U=N.top+PQ(J.top+J.height/2-q.top,0,Math.max(0,N.bottom-N.top-1)),G=C1(M,$,{x:d1($,M,J)+DQ,y:U});if(!G)return $;return E1($,G.regionId,G.offset,X)}function _Q($,M,J,Z){return M2($.documentIndex,M,J,Z)}function HQ($,M,J){let Z=$.documentIndex.blockIndex.get(M),X=$.documentIndex.regions,A=Z?$.documentIndex.roots[Z.rootIndex]?.regionRange:void 0;if(!A)return null;return J<0?X[A.start-1]??null:X[A.end]??null}function PQ($,M,J){return Math.max(M,Math.min(J,$))}function A$($,M,J=!1){return f9($,M,J)}function Y$($,M,J,Z=!1){return WQ($,M,J,Z)}function Q$($,M,J,Z=!1){return TQ($,M,J,Z)}function K$($,M,J,Z=!1){return S9($,M,J,Z)}function q$($,M,J=!1){return yQ($,M,J)}function WQ($,M,J,Z){let X=h9($,M);if(!X)return $;return g9($,M,X,J,Z)??u9($,M,X,J,Z)}function TQ($,M,J,Z){let X=h9($,M);if(!X)return $;return m9($,M,X,J,Z)}function yQ($,M,J){let Z=$.documentIndex.regions,X=M==="start"?Z[0]:Z.at(-1);if(!X)return $;return E1($,X.id,M==="start"?0:X.text.length,J)}function h9($,M){return c1(M,$.documentIndex,{regionId:$.selection.focus.regionId,offset:$.selection.focus.offset})}function p9($,M,J,Z,X,A,Y){let Q=J.image?Z.images.get(J.image.url):null,K=OQ(J,Z,Y),q=bQ(M,A,Y,K);if($.fillStyle=X.imageSurfaceBackground,$.fillRect(q.left,q.top,q.width,q.height),Q?.status==="loaded"&&Q.source)$.drawImage(Q.source,q.left,q.top,q.width,q.height);else VQ($,X,{...q,status:Q?.status==="error"?"error":"loading"});$.strokeStyle=X.imageSurfaceBorder,$.strokeRect(q.left,q.top,q.width,q.height)}function VQ($,M,J){let Z=J.status==="loading"?"Loading image":"Image unavailable",X=CQ(J),A=J.top+J.height/2+X.size*0.9;if($.save(),$.beginPath(),$.rect(J.left,J.top,J.width,J.height),$.clip(),J.status==="loading")zQ($,M,J);$.strokeStyle=M.imagePlaceholderIcon,$.lineWidth=1.5,$.strokeRect(X.left,X.top,X.size,X.size),$.beginPath(),$.arc(X.left+X.size*0.28,X.top+X.size*0.3,X.size*0.1,0,Math.PI*2),$.moveTo(X.left+X.size*0.12,X.top+X.size*0.82),$.lineTo(X.left+X.size*0.42,X.top+X.size*0.5),$.lineTo(X.left+X.size*0.58,X.top+X.size*0.66),$.lineTo(X.left+X.size*0.78,X.top+X.size*0.38),$.lineTo(X.left+X.size*0.88,X.top+X.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,A),$.restore()}function zQ($,M,J){let Z=Math.max(48,Math.round(J.width*0.22)),X=J.width+Z*2,A=performance.now()%1800/1800,Y=J.left-Z+X*A,Q=$.createLinearGradient(Y,J.top,Y+Z,J.top);Q.addColorStop(0,"rgba(255,255,255,0)"),Q.addColorStop(0.5,M.imageLoadingOverlay),Q.addColorStop(1,"rgba(255,255,255,0)"),$.fillStyle=Q,$.fillRect(J.left,J.top,J.width,J.height)}function OQ($,M,J){if(!$.image)return I9(J);let Z=M.images.get($.image.url);if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return I9(J);return Math.max(48,Math.round(J*(Z.intrinsicHeight/Z.intrinsicWidth)))}function bQ($,M,J,Z){return{height:Z,left:M,top:$.top+Math.max(0,Math.floor(($.height-Z)/2)),width:J}}function CQ($){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 I9($){return Math.max(48,Math.round($*0.5625))}var l9=2,r9=8,EQ=3,wQ=1.5,jQ=2,Q2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function c9($,M,J,Z,X,A,Y=null){if(!J||M.start!==0)return;if(Y){let Q=Z9(Y),K=uQ(J,M,Z,X,$);$.save(),$.translate(K.x,K.y),$.scale(Q,Q),$.translate(-K.x,-K.y)}if(J.kind==="task")RQ($,M,J.checked,A,Y);else if($.fillStyle=Y?r2(A.listMarkerText,Y,A):A.listMarkerText,J.kind==="ordered")fQ($,J.label,Z,X);else $.fillText(J.label,M.left-l9,X);if(Y)$.restore()}function RQ($,M,J,Z,X=null){let A=w2(M);if(LQ($,A,J,Z,X),!J)return;kQ($,A,Z,X)}function LQ($,M,J,Z,X=null){let A=J?Z.checkboxCheckedFill:Z.checkboxUncheckedFill,Y=J?Z.checkboxCheckedStroke:Z.checkboxUncheckedStroke;$.fillStyle=X?r2(A,X,Z):A,$.strokeStyle=X?r2(Y,X,Z):Y,$.beginPath(),$.lineWidth=wQ,$.roundRect(M.left,M.top,M.size,M.size,EQ),$.fill(),$.stroke()}function kQ($,M,J,Z=null){$.strokeStyle=Z?r2(J.checkboxCheckmark,Z,J):J.checkboxCheckmark,$.lineWidth=jQ,$.beginPath(),$.moveTo(M.left+Q2.start.x,M.top+Q2.start.y),$.lineTo(M.left+Q2.elbow.x,M.top+Q2.elbow.y),$.lineTo(M.left+Q2.end.x,M.top+Q2.end.y),$.stroke()}function fQ($,M,J,Z){let X=$.textAlign;$.textAlign="right",$.fillText(M,J-r9,Z),$.textAlign=X}function uQ($,M,J,Z,X){if($.kind==="task"){let Q=w2(M);return{x:Q.left+Q.size/2,y:Q.top+Q.size/2}}let A=X.measureText($.label),Y=Z-(A.actualBoundingBoxAscent-A.actualBoundingBoxDescent)/2;if($.kind==="ordered")return{x:J-r9-A.width/2,y:Y};return{x:M.left-l9+A.width/2,y:Y}}var SQ=80;function d9({context:$,containerBounds:M,isHeaderRow:J,lineHeight:Z,theme:X}){let A=s9(M,Z);$.fillStyle=J?X.tableHeaderBackground:X.tableBodyBackground,$.fillRect(A.left,A.top,A.width,A.height),i9($,A,X)}function a9({activeBlockFlashes:$,activeBlockId:M,activeRegionId:J,context:Z,editorState:X,endIndex:A,layout:Y,regionBounds:Q,startIndex:K,theme:q,verticalBleed:N}){if(!M||!J)return;let U=X.documentIndex.blockIndex.get(M)??null;if(U?.type!=="table")return;if((X.documentIndex.regionIndex.get(J)??null)?.blockId!==M)return;let B=Q.get(J)??null,D=Y.regionLineIndices.get(J)??null;if(!B||!D||D.length===0)return;let F=Y.lines[D[0]]??null;if(!F)return;let H=s9(B,F.height);if(H.width===0)return;let b=x9({context:Z,endIndex:A,fillStyle:q.activeBlockBackground,layout:Y,left:H.left,lineIndices:D,startIndex:K,verticalBleed:N,width:H.width}),E=U.path?$.get(U.path)??null:null;if(E)x9({context:Z,endIndex:A,fillStyle:b5(q.activeBlockFlash,E),layout:Y,left:H.left,lineIndices:D,startIndex:K,verticalBleed:N,width:H.width});if(!b)return;i9(Z,H,q)}function x9({context:$,endIndex:M,fillStyle:J,layout:Z,left:X,lineIndices:A,startIndex:Y,verticalBleed:Q,width:K}){$.fillStyle=J;let q=!1;for(let N of A){if(N<Y)continue;if(N>=M)break;let U=Z.lines[N];$.fillRect(X,U.top-Q,K,U.height),q=!0}return q}function s9($,M){return{height:Math.max($.bottom-$.top,M),left:$.left,top:$.top,width:Math.max($.right-$.left,SQ)}}function i9($,M,J){$.strokeStyle=J.tableBorder,$.strokeRect(M.left,M.top,M.width,M.height)}var N$=2,mQ=3,vQ=12,gQ=6,hQ=3,IQ=1,pQ=2,lQ=2,rQ=8,cQ=12,xQ=28,dQ=4,aQ=5,sQ=2,iQ=3,oQ=6,o9=3,nQ=12,tQ=10,eQ=2,$K=2,MK=1,JK=2,U$=2,n9=1.25,ZK=5,XK=1,t9=4,AK=4,YK=1.5;function QK({activeBlockId:$,activeRegionId:M,activeThreadIndex:J,containerLineBounds:Z,context:X,devicePixelRatio:A,editorState:Y,height:Q,layout:K,liveCommentRanges:q,normalizedSelection:N,now:U=kK(),resources:G,runtimeBlockMap:B,theme:D,viewportTop:F,width:H}){X.save(),X.scale(A,A),X.clearRect(0,0,H,Q),X.fillStyle=D.background,X.fillRect(0,0,H,Q),X.textBaseline="alphabetic",X.translate(0,-F);let b=KK(Y,N),{endIndex:E,startIndex:V}=l6(K,F,Q),R=s3(Y,U),O=i3(Y,U),j=a3(Y,U),f=n3(Y,U),z=o3(Y,U),y=NK(K,Y,$,V,E),T=qK(K,Y,B,V,E,H);for(let W=V;W<E;W+=1){let _=K.lines[W];FK({containerLineBounds:Z,context:X,editorState:Y,line:_,runtimeBlockMap:B,theme:D,width:H})}a9({activeBlockFlashes:R,activeBlockId:$,activeRegionId:M,context:X,editorState:Y,endIndex:E,layout:K,regionBounds:Z,startIndex:V,theme:D,verticalBleed:N$});for(let W=V;W<E;W+=1){let _=K.lines[W];DK({activeBlockId:$,activeBlockFlashes:R,activeDeletedTextFades:O,activeThreadIndex:J,activeInsertedTextHighlights:j,activeListMarkerPops:f,activePunctuationPulses:z,context:X,editorState:Y,line:_,liveCommentRanges:q,normalizedSelection:N,resources:G,runtimeBlockMap:B,selectionRegionOrderRange:b,theme:D,width:H})}UK(X,T,D),GK(X,y,D),X.restore()}function KK($,M){let J=$.documentIndex.regionOrderIndex,Z=J.get(M.start.regionId),X=J.get(M.end.regionId);return Z===void 0||X===void 0?null:{end:X,start:Z}}function qK($,M,J,Z,X,A){let Y=new Map;for(let Q=Z;Q<X;Q+=1){let K=$.lines[Q],q=J.get(K.blockId);if(q?.type!=="heading"||q.depth!==1&&q.depth!==2)continue;let N=Y.get(q.id),U={bottom:K.top+K.height,left:K.left+N0(M,K),right:A-$.options.paddingX};Y.set(q.id,N?{bottom:Math.max(N.bottom,U.bottom),left:N.left,right:N.right}:U)}return Y}function NK($,M,J,Z,X){let A=new Map;for(let Y=Z;Y<X;Y+=1){let Q=$.lines[Y],K=n0(M,Q.blockId,"blockquote");if(!K)continue;let q=A.get(K.id),N={bottom:Q.top+Q.height,isActive:Q.blockId===J,left:$.options.paddingX+(K.depth+1)*$.options.indentWidth-10,top:Q.top};A.set(K.id,q?{bottom:Math.max(q.bottom,N.bottom),isActive:q.isActive||N.isActive,left:q.left,top:Math.min(q.top,N.top)}:N)}return A}function UK($,M,J){$.fillStyle=J.headingRule;for(let Z of M.values())$.fillRect(Z.left,Z.bottom+ZK,Math.max(U$,Z.right-Z.left),XK)}function GK($,M,J){for(let Z of M.values())$.fillStyle=Z.isActive?J.blockquoteRuleActive:J.blockquoteRule,$.fillRect(Z.left,Z.top+mQ,hQ,Math.max(vQ,Z.bottom-Z.top-gQ))}function BK({context:$,devicePixelRatio:M,editorState:J,height:Z,layout:X,normalizedSelection:A,presence:Y,showCaret:Q,theme:K,viewportTop:q,width:N}){$.save(),$.scale(M,M),$.clearRect(0,0,N,Z);let U=A.start.regionId===A.end.regionId&&A.start.offset!==A.end.offset,G=Q&&!U;if($.translate(0,-q),G)e9($,J,X,{color:K.caret,offset:J.selection.focus.offset,regionId:J.selection.focus.regionId});if(Y)for(let B of Y){if(!B.cursorPoint)continue;e9($,J,X,{color:B.color??K.leafAccent,offset:B.cursorPoint.offset,regionId:B.cursorPoint.regionId})}$.restore()}function e9($,M,J,Z){let X=c1(J,M.documentIndex,{regionId:Z.regionId,offset:Z.offset});if(!X)return;let A=d1(M,J,X),Y=zK(J,X);$.fillStyle=Z.color,$.fillRect(A,Y.top,pQ,Y.height)}function FK({containerLineBounds:$,context:M,editorState:J,line:Z,runtimeBlockMap:X,theme:A,width:Y}){let Q=X.get(Z.blockId)??null,K=$.get(Z.regionId)??null,q=J.documentIndex.tableCellIndex.get(Z.regionId)??null;_K(M,Z,Q,K,q,A,Y)}function DK({activeBlockId:$,activeBlockFlashes:M,activeDeletedTextFades:J,activeThreadIndex:Z,activeInsertedTextHighlights:X,activeListMarkerPops:A,activePunctuationPulses:Y,context:Q,editorState:K,line:q,liveCommentRanges:N,normalizedSelection:U,resources:G,runtimeBlockMap:B,selectionRegionOrderRange:D,theme:F,width:H}){let b=B.get(q.blockId)??null,E=K.documentIndex.blockIndex.get(q.blockId)?.path??null,V=K.documentIndex.regionIndex.get(q.regionId)??null,R=V?.path??"",O=n0(K,q.blockId,"listItem"),j=O?j2(K,O.id):null,f=O?A.get(O.path)??null:null,z=q.left+N0(K,q),y=CK(q),T=b?.type==="code"?F.codeText:jK(b,F);Q.font=q.font,HK(Q,q,b,E,$,M,F,H),PK(Q,K,q,U,D,F),WK(Q,K,q,N,Z,F),c9(Q,q,j,z,y,F,f),TK(Q,q,V,z,y,X.get(R)??[],T,G,F),yK(Q,q,V,z,y,J.get(R)??[],T),VK(Q,q,V,z,y,Y.get(R)??[],F)}function _K($,M,J,Z,X,A,Y){if(!Z||M.start!==0)return;if(J?.type==="code"){let Q=Math.max(0,M.left-cQ);$.fillStyle=A.codeBackground,$.fillRect(Q,Z.top-dQ,Math.max(Z.right-M.left+xQ,Y-Q),Z.bottom-Z.top+rQ);return}if(J?.type!=="table")return;d9({context:$,containerBounds:Z,isHeaderRow:X?.rowIndex===0,lineHeight:M.height,theme:A})}function HK($,M,J,Z,X,A,Y,Q){if(M.blockId!==X||J?.type==="table")return;let K=Z?A.get(Z)??null:null;if($.fillStyle=Y.activeBlockBackground,$.fillRect(0,M.top-N$,Q,M.height),!K)return;$.fillStyle=b5(Y.activeBlockFlash,K),$.fillRect(0,M.top-N$,Q,M.height)}function PK($,M,J,Z,X,A){if(!X)return;let Y=M.documentIndex.regionOrderIndex.get(J.regionId);if(Y===void 0||Y<X.start||Y>X.end)return;let Q=Y===X.start?Math.max(J.start,Z.start.offset):J.start,K=Y===X.end?Math.min(J.end,Z.end.offset):J.end;if(K<=Q)return;$.fillStyle=A.selectionBackground,$.fillRect(q0(M,J,Q-J.start),J.top+MK,Math.max($K,q0(M,J,K-J.start)-q0(M,J,Q-J.start)),J.height-JK)}function WK($,M,J,Z,X,A){for(let Y of Z){if(Y.regionId!==J.regionId)continue;let Q=Math.max(Y.startOffset,J.start),K=Math.min(Y.endOffset,J.end);if(K<=Q)continue;$.fillStyle=LK(Y,X,A),$.fillRect(q0(M,J,Q-J.start),J.top+J.height-aQ,Math.max(sQ,q0(M,J,K-J.start)-q0(M,J,Q-J.start)),iQ)}}function TK($,M,J,Z,X,A,Y,Q,K){if(!J){$.fillStyle=Y,$.fillText(M.text,Z,X);return}let q=J.inlines.filter((N)=>N.end>M.start&&N.start<M.end);if(q.length===0){$.fillStyle=Y,$.fillText(M.text,Z,X);return}for(let N of q){let U=Math.max(M.start,N.start),G=Math.min(M.end,N.end);if(J.text.slice(U,G).length===0)continue;let{left:D,right:F}=B$(M,Z,U,G),H=RK(M.font,N.marks);if($.font=H,N.kind==="image"){let b=Math.max(24,F-D);p9($,M,N,Q,K,D,b);continue}if(N.kind==="inlineCode"){let b=EK(M,H),E=wK(M,H);$.fillStyle=K.inlineCodeBackground,$.fillRect(D-o9,b,Math.max(tQ,F-D+o9*2),E),$7($,M,J.text,Z,X,U,G,K.inlineCodeText,A,K,{strikethrough:!1,underline:!1});continue}$7($,M,J.text,Z,X,U,G,N.link?K.linkText:Y,A,K,{strikethrough:N.marks.includes("strikethrough"),underline:N.marks.includes("underline")||Boolean(N.link)})}}function $7($,M,J,Z,X,A,Y,Q,K,q,N){let U=t3(A,Y,K);for(let G=0;G<U.length-1;G+=1){let B=U[G],D=U[G+1];if(D<=B)continue;let F=J.slice(B,D);if(F.length===0)continue;let{left:H,right:b}=B$(M,Z,B,D),E=e3(K,B,D),V=$9(Q,E,q);if($.fillStyle=V,$.fillText(F,H,X),N.strikethrough)$.fillRect(H,bK(X,M.height,$.font),Math.max(U$,b-H),n9);if(N.underline)$.fillRect(H,OK(X,M.height,$.font),Math.max(U$,b-H),n9)}}function yK($,M,J,Z,X,A,Y){if(!J||A.length===0)return;for(let Q of A){if(Q.startOffset<M.start||Q.startOffset>M.end)continue;let K=Z+(x1(M,Q.startOffset-M.start)-M.left);$.fillStyle=M9(Y,Q),$.fillText(Q.text,K,X)}}function VK($,M,J,Z,X,A,Y){if(!J||A.length===0)return;for(let Q of A){if(Q.offset<M.start||Q.offset>=M.end)continue;let{left:K,right:q}=B$(M,Z,Q.offset,Q.offset+1),N=Math.max(t9,(q-K)/2+t9+AK*Q.progress),{ascent:U,descent:G}=K0(M.font),B=X-Math.max(1,U*0.42)+Math.max(0.5,G*0.15);$.strokeStyle=J9(Q,Y),$.lineWidth=YK,$.beginPath(),$.arc((K+q)/2,B,N,0,Math.PI*2),$.stroke()}}function zK($,M){let J=$0($,M.regionId,M.offset),Z=J?.font??'16px "Iowan Old Style", "Palatino Linotype", serif',{ascent:X,descent:A}=K0(Z),Y=Math.max(1,X+A),Q=Math.min(M.height-lQ,Y),K=J?Math.max(J.top,J.top+G$(J.height,Z)-IQ):M.top+Math.max(0,Math.floor((M.height-Q)/2));return{height:Q,top:K}}function OK($,M,J){let{descent:Z}=K0(J),X=Math.max(1,Math.round(Math.max(2,Z)*0.35)),A=$+Z-X,Y=$-I5(M,J);return Math.min(Y+M-4,A)}function bK($,M,J){let{ascent:Z}=K0(J),X=$-I5(M,J);return Math.max(X+2,$-Math.round(Z*0.32))}function CK($){return $.top+I5($.height,$.font)}function I5($,M){return B3($,M)}function EK($,M){let J=G$($.height,M);return $.top+J+eQ}function wK($,M){let J=G$($.height,M);return Math.max(nQ,$.height-J-oQ)}function G$($,M){let{ascent:J}=K0(M);return I5($,M)-J}function jK($,M){switch($?.type){case"heading":return M.headingText;case"blockquote":return M.blockquoteText;case"table":return M.headingText;default:return M.paragraphText}}function B$($,M,J,Z){return{left:M+(x1($,J-$.start)-$.left),right:M+(x1($,Z-$.start)-$.left)}}function RK($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function LK($,M,J){if($.resolved)return $.threadIndex===M?J.commentHighlightResolvedActive:J.commentHighlightResolved;return $.threadIndex===M?J.commentHighlightActive:J.commentHighlight}function kK(){return typeof performance<"u"?performance.now():Date.now()}function F$($,M,J,Z){QK({activeBlockId:Z.activeBlockId,activeRegionId:Z.activeRegionId,activeThreadIndex:Z.activeThreadIndex,containerLineBounds:M.regionBounds,context:J,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:M.layout,liveCommentRanges:Z.liveCommentRanges,normalizedSelection:Z.normalizedSelection,now:Z.now,resources:Z.resources??{images:new Map},runtimeBlockMap:M.blockMap,theme:Z.theme,viewportTop:M.paintTop,width:Z.width})}function D$($,M,J,Z){BK({context:J,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:M.layout,normalizedSelection:Z.normalizedSelection,presence:Z.presence,showCaret:Z.showCaret,theme:Z.theme,viewportTop:M.paintTop,width:Z.width})}import{forwardRef as vK,createElement as gK}from"react";var p5=(...$)=>$.filter((M,J,Z)=>{return Boolean(M)&&M.trim()!==""&&Z.indexOf(M)===J}).join(" ").trim();var M7=($)=>$.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var J7=($)=>$.replace(/^([A-Z])|[\s-_]+(\w)/g,(M,J,Z)=>Z?Z.toUpperCase():J.toLowerCase());var _$=($)=>{let M=J7($);return M.charAt(0).toUpperCase()+M.slice(1)};import{forwardRef as mK,createElement as A7}from"react";var l5={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 Z7=($)=>{for(let M in $)if(M.startsWith("aria-")||M==="role"||M==="title")return!0;return!1};import{createContext as fK,useContext as uK,useMemo as YH,createElement as QH}from"react";var SK=fK({});var X7=()=>uK(SK);var Y7=mK(({color:$,size:M,strokeWidth:J,absoluteStrokeWidth:Z,className:X="",children:A,iconNode:Y,...Q},K)=>{let{size:q=24,strokeWidth:N=2,absoluteStrokeWidth:U=!1,color:G="currentColor",className:B=""}=X7()??{},D=Z??U?Number(J??N)*24/Number(M??q):J??N;return A7("svg",{ref:K,...l5,width:M??q??l5.width,height:M??q??l5.height,stroke:$??G,strokeWidth:D,className:p5("lucide",B,X),...!A&&!Z7(Q)&&{"aria-hidden":"true"},...Q},[...Y.map(([F,H])=>A7(F,H)),...Array.isArray(A)?A:[A]])});var L=($,M)=>{let J=vK(({className:Z,...X},A)=>gK(Y7,{ref:A,iconNode:M,className:p5(`lucide-${M7(_$($))}`,`lucide-${$}`,Z),...X}));return J.displayName=_$($),J};var hK=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],D0=L("columns-2",hK);var IK=[["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"}]],_0=L("rows-3",IK);var pK=[["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"}]],H0=L("send-horizontal",pK);var lK=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Y4=L("arrow-down",lK);var rK=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Q4=L("arrow-up",rK);var cK=[["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"}]],K4=L("bold",cK);var xK=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],C0=L("check",xK);var dK=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],q4=L("chevron-down",dK);var aK=[["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"}]],N4=L("heading-1",aK);var sK=[["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"}]],U4=L("heading-2",sK);var iK=[["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"}]],G4=L("heading-3",iK);var oK=[["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"}]],B4=L("heading-4",oK);var nK=[["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"}]],F4=L("heading-5",nK);var tK=[["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"}]],D4=L("heading-6",tK);var eK=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],_4=L("heading",eK);var $q=[["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"}]],H4=L("italic",$q);var Mq=[["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"}]],P4=L("list-ordered",Mq);var Jq=[["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"}]],W4=L("list-todo",Jq);var Zq=[["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"}]],T4=L("list",Zq);var Xq=[["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"}]],y4=L("message-square-plus",Xq);var Aq=[["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"}]],E0=L("pencil",Aq);var Yq=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],K2=L("plus",Yq);var Qq=[["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"}]],V4=L("strikethrough",Qq);var Kq=[["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"}]],P0=L("table-2",Kq);var qq=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],z4=L("text-quote",qq);var Nq=[["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"}]],w1=L("trash-2",Nq);var Uq=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],O4=L("underline",Uq);var Gq=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],b4=L("x",Gq);import{jsxDEV as w0}from"react/jsx-dev-runtime";function Q7({insetX:$,insetY:M,onSelect:J,presence:Z}){if(Z.length===0)return null;return w0("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${$}px`,top:`${M}px`},children:Z.map((X,A)=>w0(Bq,{onSelect:()=>J(X),presence:X},_q(X,A),!1,void 0,this))},void 0,!1,void 0,this)}function Bq({onSelect:$,presence:M}){let J=M.viewport,Z=Fq(M),X=J?.status==="above"?Q4:Y4,A=J!==null&&J.scrollTop!==null,Y=J?.status==="above"||J?.status==="below";return w0("button",{"aria-label":Dq(M),className:"documint-presence-indicator","data-status":J?.status??"unresolved",disabled:!A,onClick:A?$:void 0,style:{"--documint-presence-color":M.color??"var(--documint-leaf-accent)"},type:"button",children:[w0("span",{className:"documint-presence-indicator-avatar",children:M.imageUrl?w0("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),Y?w0("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:w0(X,{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 Fq($){return K7($).charAt(0).toLocaleUpperCase()}function Dq($){let M=K7($),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 K7($){return $.name.trim()||"Presence"}function _q($,M){return[M,$.name,$.imageUrl??"",$.color??"",$.cursor?.kind??"",$.cursor?.prefix??"",$.cursor?.suffix??""].join(":")}var s=`
|
|
26
|
+
`,W0="<ins>",C4="</ins>",q2=">",E4="```",r5=":::",H$=/^:::([A-Za-z][-\w]*)(.*)$/,c5="documint-comments";var x5="`",y$="\\",W$="![",T$="[",G7="(",q7=")",B7=" ",F7=":",Hq=/[A-Za-z]/,Pq=/[-A-Za-z0-9_]/,Wq=/^\{width=([1-9]\d*)\}/,Tq=/\\([\\`*_[\]{}()#+\-.!~|])/g,D7=/\\(.)/g,yq=[{delimiter:"**",mark:"bold"},{delimiter:"~~",mark:"strikethrough"},{delimiter:"*",mark:"italic"}];function N2($,M=[]){return V$($,0,$.length,M)}function V$($,M,J,Z){let X=[],A=M,Y=M;while(A<J){let Q=Vq($,A,J,Z);if(Q){N7(X,$.slice(Y,A),Z),X.push(...Q.nodes),A=Q.end,Y=A;continue}if($[A]===y$){A+=Math.min(2,J-A);continue}A+=1}return N7(X,$.slice(Y,J),Z),zq(X)}function Vq($,M,J,Z){switch($[M]){case F7:return uq($,M,J);case"<":return kq($,M,J,Z);case x5:return wq($,M,J);case"!":return jq($,M,J);case T$:return Rq($,M,J,Z);case"*":case"~":return bq($,M,J,Z);default:return null}}function N7($,M,J){if(M.length===0)return;$.push(W1({marks:J,text:T7(M)}))}function z$($,M){return p4({originalType:$,source:M})}function zq($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&Cq(Z.marks,J.marks)){M[M.length-1]=W1({marks:Z.marks,text:Z.text+J.text});continue}M.push(J)}return M}function Oq($,M,J){for(let Z of yq){if(!$.startsWith(Z.delimiter,M))continue;let X=$.indexOf(Z.delimiter,M+Z.delimiter.length);if(X<0||X>=J)continue;return{contentEnd:X,contentStart:M+Z.delimiter.length,end:X+Z.delimiter.length,mark:Z.mark}}return null}function bq($,M,J,Z){let X=Oq($,M,J);if(!X)return null;return{end:X.end,nodes:V$($,X.contentStart,X.contentEnd,[...Z,X.mark])}}function Cq($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function Eq($,M,J){if($[M]!==x5)return null;let Z=1;while(M+Z<J&&$[M+Z]===x5)Z+=1;let X=x5.repeat(Z),A=$.indexOf(X,M+Z);if(A<0||A>=J)return null;return{end:A+Z,value:$.slice(M+Z,A)}}function wq($,M,J){let Z=Eq($,M,J);if(!Z)return null;return{end:Z.end,nodes:[S0({code:Z.value})]}}function jq($,M,J){if(!$.startsWith(W$,M))return null;let Z=H7($,M+1,J);if(Z<0||$[Z+1]!==G7)return null;let X=_7($,Z+1,J);if(!X)return null;let A=Lq($,X.end,J);return{end:A?.end??X.end,nodes:[I4({alt:T7($.slice(M+W$.length,Z)),title:X.title,url:X.url,width:A?.width??null})]}}function Rq($,M,J,Z){if($[M]!==T$||$.startsWith(W$,M-1))return null;let X=H7($,M,J);if(X<0||$[X+1]!==G7)return null;let A=_7($,X+1,J);if(!A)return null;return{end:A.end,nodes:[m0({children:N2($.slice(M+T$.length,X),Z),title:A.title,url:A.url})]}}function _7($,M,J){let Z=P$($,M+1,J),X=Z;while(X<J&&$[X]!==q7&&$[X]!==B7){if($[X]===y$){X+=2;continue}X+=1}if(X===Z)return null;let A=Sq($.slice(Z,X));Z=P$($,X,J);let Y=null;if(Z<J&&$[Z]==='"'){let Q=W7($,'"',Z+1,J);if(Q<0)return null;Y=$.slice(Z+1,Q).replace(D7,"$1"),Z=P$($,Q+1,J)}if($[Z]!==q7)return null;return{end:Z+1,title:Y,url:A}}function Lq($,M,J){let Z=Wq.exec($.slice(M,J));if(!Z)return null;return{end:M+Z[0].length,width:Number(Z[1])}}function kq($,M,J,Z){if(!$.startsWith(W0,M))return fq($,M,J);let X=$.indexOf(C4,M+W0.length);if(X<0||X>=J)return{end:M+W0.length,nodes:[z$("html",W0)]};return{end:X+C4.length,nodes:V$($,M+W0.length,X,[...Z,"underline"])}}function fq($,M,J){if($[M]!=="<")return null;let Z=$.indexOf(">",M+1);if(Z<0||Z>=J)return null;return{end:Z+1,nodes:[z$("html",$.slice(M,Z+1))]}}function uq($,M,J){if($[M]!==F7||!Hq.test($[M+1]??""))return null;let Z=M+2;while(Z<J&&Pq.test($[Z]??""))Z+=1;let X=U7($,Z,J,"[","]"),Y=U7($,X?.end??Z,J,"{","}")?.end??X?.end??Z;return{end:Y,nodes:[z$("textDirective",$.slice(M,Y))]}}function U7($,M,J,Z,X){if($[M]!==Z)return null;let A=P7($,X,M+1,J);if(A<0)return null;return{end:A+1}}function H7($,M,J){return P7($,"]",M+1,J)}function P7($,M,J,Z){return W7($,M,J,Z)}function W7($,M,J,Z){for(let X=J;X<Z;X+=1){if($[X]===y$){X+=1;continue}if($[X]===M)return X}return-1}function P$($,M,J){while(M<J&&$[M]===B7)M+=1;return M}function T7($){return $.replace(Tq,"$1")}function Sq($){return $.replace(D7,"$1")}var mq=/^:?-+:?$/;function z7($,M){let J=V7($),Z=$.lines[$.index+1]??"",X=O$(J,M),A=O$(Z,M);if(!y7(X)||!b$(A))return null;let Y=[d5(X)],Q=vq(A);$.index+=2;while($.index<$.lines.length){let K=V7($),q=O$(K,M);if(gq(K)||!y7(q))break;Y.push(d5(q)),$.index+=1}return V0({align:Q,rows:Y.map((K)=>v0({cells:K.map((q)=>X0({children:N2(q)}))}))})}function y7($){let M=$.trim();return/\|/.test($)&&M.startsWith("|")&&M.endsWith("|")}function b$($){let M=d5($);return M.length>0&&M.every((J)=>mq.test(J.trim()))}function vq($){return d5($).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 d5($){return $.trim().slice(1,-1).split("|").map((J)=>J.trim())}function V7($){return $.lines[$.index]??""}function gq($){return $.trim()===""}function O$($,M){return $.slice(M)}var hq=3,Iq=/^\d+\.$/,pq=/^\[( |x|X)\](?:\s|$)/,O7=/^```([^\s`]*)?(?:\s+(.*))?$/,b7=/^::(?!:)[A-Za-z][-\w]*/,C7=/^(#{1,6})\s+(.*)$/,lq=/\s+#+\s*$/u,rq=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,cq=/^(\*\s*){3,}$/,xq=/^(-\s*){3,}$/,dq=/^(_\s*){3,}$/;function s5($,M,J){let Z=[];while($.index<$.lines.length){let X=H1($);if($.index===$.lines.length-1&&X==="")break;if(w4(X)){$.index+=1;continue}if(U2(X)>M+hq)break;let Y=aq($,M,J);if(!Y)break;Z.push(Y)}return Z}function aq($,M,J){return sq($,M,J)??iq($,M)??oq($,M)??tq($,M)??eq($,M)??$N($,M)??z7($,M)??MN($,M,J)??JN($,M)??ZN($,M)}function sq($,M,J){let Z=H1($);if(!AN(Z,M))return null;let X=[];while($.index<$.lines.length){let A=H1($),Y=U2(A);if(w4(A)){X.push(""),$.index+=1;continue}if(Y<M)break;let Q=u1(A,M);if(!Q.startsWith(q2))break;let K=Q.slice(1);if(K.startsWith(" "))K=K.slice(1);X.push(K),$.index+=1}return T1({children:s5({index:0,lines:X},0,J)})}function iq($,M){let J=H1($),Z=u1(J,M),X=O7.exec(Z);if(!X)return null;$.index+=1;let A=[];while($.index<$.lines.length){let Y=H1($),Q=u1(Y,M);if(Q.trim()===E4){$.index+=1;break}A.push(Q),$.index+=1}return N6({language:X[1]?X[1]:null,meta:X[2]?X[2]:null,source:A.join(s)})}function oq($,M){let J=H1($),Z=u1(J,M),X=H$.exec(Z);if(!X)return null;let A=X[1],Y=[];$.index+=1;while($.index<$.lines.length){let Q=H1($),K=u1(Q,M);if($.index+=1,K.trim()===r5)break;Y.push(K)}return qM({attributes:nq(X[2]??""),body:Y.join(s),name:A})}function nq($){let M=$.trim();if(M.startsWith("{")&&M.endsWith("}"))return M.slice(1,-1);return M}function tq($,M){let J=H1($),Z=u1(J,M);if(!b7.test(Z))return null;return $.index+=1,r4({originalType:"leafDirective",source:Z})}function eq($,M){let J=H1($),Z=C7.exec(u1(J,M));if(!Z)return null;return $.index+=1,h4({children:N2(Z[2].replace(lq,"")),depth:Z[1].length})}function $N($,M){let J=u1(H1($),M).trim();if(!E7(J))return null;return $.index+=1,l4()}function MN($,M,J){let Z=a5(H1($),M);if(!Z)return null;let X=[],A=!1;while($.index<$.lines.length){let Y=H1($),Q=a5(Y,M);if(!Q||Q.ordered!==Z.ordered)break;$.index+=1;let K=[Q.content],q=!1;while($.index<$.lines.length){let N=H1($),U=U2(N);if(w4(N)){let G=KN($.lines,$.index+1);if(G<0||U2($.lines[G]??"")<=M)break;q=!0,K.push(""),$.index+=1;continue}if(U<Q.contentIndent)break;if(U===M&&a5(N,M))break;K.push(YN(N,Q.contentIndent)),$.index+=1}A||=q,X.push(n1({checked:Q.checked,children:XN(K,J),spread:q}))}return y0({items:X,ordered:Z.ordered,spread:A,start:Z.ordered&&J.preserveOrderedListStart?Z.start??1:null})}function JN($,M){let J=u1(H1($),M).trim();if(!w7(J))return null;return $.index+=1,r4({originalType:"html",source:J})}function ZN($,M){let J=[];while($.index<$.lines.length){let Z=H1($),X=U2(Z);if(w4(Z))break;if(X<M)break;let A=u1(Z,M);if(J.length>0&&QN(Z,A,M))break;J.push(A),$.index+=1}return _2({children:N2(J.join(s))})}function XN($,M){let J=s5({index:0,lines:$},0,M);if(J.length>0)return J;return[_2({children:[]})]}function a5($,M){let J=rq.exec($);if(!J||J[1].length!==M)return null;let Z=J[2],X=Iq.test(Z),A=X?Number(Z.slice(0,-1)):null,Y=J[3]??"",Q=null;if(pq.test(Y)){if(Q=Y[1]==="x"||Y[1]==="X",Y=Y.slice(3),Y.startsWith(" "))Y=Y.slice(1)}let K=Y.length>0?J[0].length-J[1].length-J[2].length-Y.length:J[0].length-J[1].length-J[2].length;return{checked:Q,content:Y,contentIndent:M+J[2].length+K,ordered:X,start:A}}function AN($,M){return u1($,M).startsWith(q2)}function u1($,M){return $.slice(M)}function YN($,M){let J=U2($);if(J>=M)return $.slice(M);return $.trim()===""?"":$.slice(Math.min(J,M))}function E7($){return cq.test($)||xq.test($)||dq.test($)}function w7($){return $.startsWith("<")&&$.endsWith(">")}function U2($){let M=0;while(M<$.length&&$[M]===" ")M+=1;return M}function QN($,M,J){return M.startsWith(q2)||O7.test(M)||H$.test(M)||b7.test(M)||C7.test(M)||E7(M.trim())||b$(M)||a5($,J)!==null||w7(M.trim())}function H1($){return $.lines[$.index]??""}function w4($){return $.trim()===""}function KN($,M){for(let J=M;J<$.length;J+=1)if(!w4($[J]??""))return J;return-1}function R7($){let M=$.at(-1),J=M&&j7(M)?M:null;return{blocks:$.filter((X)=>!j7(X)),comments:J?qN(J.body):[]}}function qN($){let M;try{M=JSON.parse($)}catch{return[]}if(!Array.isArray(M))return[];return M.flatMap((J)=>{let Z=P6(J);return Z?[Z]:[]})}function j7($){return $.type==="directive"&&$.name===c5}function C$($,M={}){let Z={index:0,lines:$.replace(/\r\n/g,s).split(s)},X=s5(Z,0,M),{comments:A,blocks:Y}=R7(X);return h0(Y,A)}var j4=`
|
|
27
|
+
|
|
28
|
+
`,NN="-",UN=".",GN="***",BN=" ",E$=3,FN=5,DN=4,L7=2,_N=2,HN=1,PN=/([\\`*_[\]])/g,WN=/([\\)&])/g,TN=/(["\\])/g;function i5($,M={}){if($.blocks.length===0&&$.comments.length===0)return"";let J=$.blocks.map((X)=>o5(X,0,M));if($.comments.length>0)J.push(gN($.comments));let Z=J.join(j4);return Z.endsWith(s)?Z:`${Z}${s}`}function o5($,M,J){let Z=T0(M);switch($.type){case"blockquote":return yN($,M,J);case"code":return VN($,M);case"directive":return hN($,M);case"heading":return f7($,M);case"list":return zN($,M,J);case"listItem":return u7($,M,!1,1,J);case"paragraph":return`${Z}${w$(R4($.children))}`;case"table":return bN($,M,J);case"thematicBreak":return`${Z}${GN}`;case"unsupported":return M===0?$.source:v7($.source,M)}}function yN($,M,J){let Z=$.children.map((A)=>o5(A,0,J)).join(j4),X=T0(M);return Z.split(s).map((A)=>`${X}${q2}${A.length>0?` ${A}`:""}`).join(s)}function VN($,M){let J=[$.language??"",$.meta??""].filter(Boolean).join(" ").trim(),Z=T0(M),X=`${Z}${E4}${J?J:""}`,A=$.source.length>0?$.source.split(s).map((Y)=>`${Z}${Y}`).join(s):Z;return`${X}${s}${A}${s}${Z}${E4}`}function f7($,M){let J=w$(R4($.children)),Z=`${T0(M)}${"#".repeat($.depth)}`;return J.length>0?`${Z} ${J}`:Z}function zN($,M,J){let Z=$.start??1;return $.items.map((X)=>u7(X,M,$.ordered,Z,J)).join($.spread?j4:s)}function u7($,M,J,Z,X){let A=J?`${Z}${UN}`:NN,Y=$.checked===null?"":`[${$.checked?"x":" "}] `,Q=`${T0(M)}${A} ${Y}`,K=M+A.length+1,q=$.children;if(q.length===0)return Y.length>0?Q:Q.trimEnd();let[N,...U]=q,G=ON(N,Q,Y.length>0,X),B=U.map((D)=>o5(D,K,X)).join($.spread?j4:s);if(!B)return G;return`${G}${$.spread?j4:s}${B}`}function ON($,M,J,Z){switch($.type){case"paragraph":{let X=w$(R4($.children));if(X.length===0)return J?M:M.trimEnd();return`${M}${X}`}case"heading":return`${M}${f7($,0)}`;case"directive":case"unsupported":{let X=$.type==="directive"?j$($):$.source,[A,...Y]=X.split(s);return[M+A,...Y.map((Q)=>`${T0(M.length)}${Q}`)].join(s)}default:{let X=M.length;return`${M.trimEnd()}${s}${o5($,X,Z)}`}}}function bN($,M,J){let Z=$.rows.map((N)=>N.cells.map((U)=>R4(U.children))),X=Math.max(1,...Z.map((N)=>N.length)),A=Z[0]??[],Y=Array.from({length:X},(N,U)=>Math.max(E$,jN($.align[U]),...J.padTableColumns?Z.map((G)=>G[U]?.length??0):[A[U]?.length??0])),Q=CN(Y,$.align,M),K=k7(A,Y,$.align,M,J),q=Z.slice(1).map((N)=>k7(N,Y,$.align,M,J));return[K??EN(Y,M),Q,...q].join(s)}function k7($,M,J,Z,X){let A=M.map((Y,Q)=>{let K=$[Q]??"";if(!X.padTableColumns)return K;return RN(K,Y,J[Q])});return`${" ".repeat(Z)}| ${A.join(" | ")} |`}function CN($,M,J){let Z=$.map((X,A)=>wN(M[A],X));return`${" ".repeat(J)}| ${Z.join(" | ")} |`}function EN($,M){return`${T0(M)}| ${$.map((J)=>"".padEnd(J," ")).join(" | ")} |`}function wN($,M){let J=Math.max(E$,M-($==="center"?_N:$?HN:0));switch($){case"center":return`:${"-".repeat(Math.max(1,J))}:`;case"left":return`:${"-".repeat(Math.max(L7,J))}`;case"right":return`${"-".repeat(Math.max(L7,J))}:`;default:return"-".repeat(J)}}function jN($){return $==="center"?FN:$?DN:E$}function RN($,M,J){if(J==="right")return $.padStart(M," ");return $.padEnd(M," ")}function R4($){return kN($).map((M)=>LN(M)).join("")}function w$($){return $.replace(/^ +/gm,(M)=>BN.repeat(M.length))}function LN($){switch($.type){case"break":return s;case"image":return IN($);case"inlineCode":return SN($.code);case"link":return pN($);case"text":return uN(S7($.text),$.marks);case"unsupported":return $.source}}function kN($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&fN(Z.marks,J.marks)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function fN($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function uN($,M){return M.reduce((J,Z)=>{switch(Z){case"bold":return`**${J}**`;case"italic":return`*${J}*`;case"strikethrough":return`~~${J}~~`;case"underline":return`${W0}${J}${C4}`}},$)}function SN($){let M=0,J=0;for(let Y of $){if(Y==="`"){if(J+=1,J>M)M=J;continue}J=0}let Z=M>0?M+1:1,X="`".repeat(Z),A=$.startsWith("`")||$.endsWith("`")?` ${$} `:$;return`${X}${A}${X}`}function S7($){return $.replace(PN,"\\$1")}function mN($){return $.replace(WN,"\\$1")}function vN($){return $?` "${$.replace(TN,"\\$1")}"`:""}function gN($){return j$({attributes:"",body:JSON.stringify($,null,2),name:c5})}function hN($,M){let J=j$($);return M===0?J:v7(J,M)}function j$($){let M=$.attributes?`{${$.attributes}}`:"";return`:::${$.name}${M}${s}${$.body}${s}${r5}`}function IN($){let M=S7($.alt??""),J=m7($.url,$.title),Z=$.width?`{width=${$.width}}`:"";return`![${M}]${J}${Z}`}function pN($){return`[${R4($.children)}]${m7($.url,$.title)}`}function m7($,M){return`(${mN($)}${vN(M)})`}function T0($){return" ".repeat($)}function v7($,M){let J=T0(M);return $.split(s).map((Z)=>`${J}${Z}`).join(s)}import{useEffect as t5,useRef as tN,useState as j0}from"react";import{forwardRef as lN}from"react";import{jsxDEV as G2}from"react/jsx-dev-runtime";var n5=lN(function({className:M,onCancel:J,onChange:Z,onSave:X,placeholder:A,readOnly:Y=!1,rows:Q=3,saveDisabled:K=!1,value:q},N){return G2("div",{className:"documint-edit-input-field",children:[G2("textarea",{className:M??"documint-comment-input",onChange:(U)=>Z(U.currentTarget.value),onKeyDown:(U)=>{if(U.key!=="Escape")return;U.preventDefault(),J()},placeholder:A,readOnly:Y,ref:N,rows:Q,value:q},void 0,!1,void 0,this),G2("button",{className:"documint-leaf-action documint-edit-input-cancel","aria-label":"Cancel editing",onClick:J,title:"Cancel editing",type:"button",children:G2(b4,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),G2("button",{className:"documint-leaf-action documint-edit-input-save","aria-label":"Save",disabled:K,onClick:X,title:"Save",type:"button",children:G2(C0,{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 g7,isValidElement as h7,useEffect as rN,useRef as cN,useState as xN}from"react";import{jsxDEV as q1}from"react/jsx-dev-runtime";var R$=($)=>{$.preventDefault()},L$=($)=>$.isPrimary&&$.button===0;function dN({children:$}){return q1("div",{className:"documint-leaf-toolbar",children:g7.map($,aN)},void 0,!1,void 0,this)}function aN($){if(!h7($))return null;if($.type===p7){let M=$.props;return q1(I7,{children:q1(sN,{...M},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if($.type===l7){let{className:M}=$.props;return q1("div",{className:L4("documint-leaf-toolbar-divider",M)},void 0,!1,void 0,this)}if($.type===r7){let M=$.props;return q1(iN,{...M},void 0,!1,void 0,this)}return null}function sN({active:$=!1,className:M,disabled:J=!1,icon:Z,label:X,onClick:A}){return q1("button",{"aria-label":X,className:L4("documint-leaf-toolbar-button",$?"active":null,M),disabled:J,onPointerDown:(Y)=>{if(R$(Y),!J&&L$(Y))A()},title:X,type:"button",children:q1(Z,{size:15,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function iN({children:$,className:M,icon:J,label:Z,onSelect:X}){let A=cN(null),[Y,Q]=xN(!1);return rN(()=>{if(!Y)return;let K=(q)=>{if(A.current&&q.target instanceof Node&&!A.current.contains(q.target))Q(!1)};return window.addEventListener("pointerdown",K),()=>{window.removeEventListener("pointerdown",K)}},[Y]),q1(I7,{children:q1("div",{className:"documint-leaf-toolbar-menu-shell",ref:A,children:[q1(oN,{className:M,icon:J,isOpen:Y,label:Z,onClick:()=>Q((K)=>!K)},void 0,!1,void 0,this),Y?q1("div",{className:"documint-leaf-toolbar-menu",role:"menu",children:g7.map($,(K)=>nN(K,(q)=>{Q(!1),X(q)}))},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function oN({className:$,icon:M,isOpen:J,label:Z,onClick:X}){return q1("button",{"aria-expanded":J,"aria-haspopup":"menu","aria-label":Z,className:L4("documint-leaf-toolbar-button",J?"active":null,$),onPointerDown:(A)=>{if(R$(A),L$(A))X()},title:Z,type:"button",children:[q1(M,{size:15,strokeWidth:2.2},void 0,!1,void 0,this),q1(q4,{className:L4("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 nN($,M){if(!h7($))return null;if($.type===x7){let{className:Y}=$.props;return q1("div",{className:L4("documint-leaf-toolbar-menu-divider",Y),role:"separator"},void 0,!1,void 0,this)}if($.type!==c7)return null;let{disabled:J=!1,icon:Z,text:X,value:A}=$.props;return q1("button",{className:"documint-leaf-toolbar-menu-item",disabled:J,onPointerDown:(Y)=>{if(R$(Y),!J&&L$(Y))M(A)},role:"menuitem",type:"button",children:[q1(Z,{size:15,strokeWidth:2.2},void 0,!1,void 0,this),q1("span",{children:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function L4(...$){return $.filter(Boolean).join(" ")}function I7({children:$}){return q1("div",{className:"documint-leaf-toolbar-group",children:$},void 0,!1,void 0,this)}function p7($){return null}function l7($){return null}function r7($){return null}function c7($){return null}function x7($){return null}var x=Object.assign(dN,{Button:p7,Divider:l7,Menu:r7,MenuDivider:x7,MenuItem:c7});import{jsxDEV as h,Fragment as JU}from"react/jsx-dev-runtime";var eN=!1,$U=220,R0=()=>{};function k$($){let M=$.mode==="create",J=$.mode==="create"?$:null,Z=$.mode==="thread"?$:null,X=$.canEdit,A=$.link,Y=Z?.thread??null,Q=Y?.comments??[],K=Q[0]??null,q=Y?A0(Y):!1,N=Z?.animateInitialComment??!1,[U,G]=j0(null),[B,D]=j0(""),[F,H]=j0(""),[b,E]=j0(""),[V,R]=j0(!N),[O,j]=j0(eN),[f,z]=j0(!1),y=tN(null),T=Y?b6(Y):null,W=T?d7(T):"",_=X&&!q,C=_&&B.trim().length>0,g=_&&F.trim().length>0,u=X&&b.trim().length>0,d=M||f,p=!M||O,J1=!M&&Boolean(Y),k=Boolean(K),S=M?O:!0,m=Z?.onDeleteComment??R0,Z1=Z?.onDeleteThread??R0,t=Z?.onToggleResolved??R0,N1=J?.activeMarks??[],v1=J?.onToggleBold??R0,g1=J?.onToggleItalic??R0,A1=J?.onToggleStrikethrough??R0,S4=J?.onToggleUnderline??R0,Q6=X?M?"Add a comment":"Reply to this comment":"Comment editing is disabled",u0=M?b:F;t5(()=>{if(U!==null&&(U<0||U>=Q.length))G(null),D("")},[Q.length,U]),t5(()=>{if(!k||!N){R(!0);return}R(!1);let z1=requestAnimationFrame(()=>{R(!0)});return()=>{cancelAnimationFrame(z1)}},[N,K,k]),t5(()=>{if(!Z||!N){z(!1);return}z(!0);let z1=window.setTimeout(()=>{z(!1)},$U);return()=>{window.clearTimeout(z1)}},[N,Z]),t5(()=>{if(!M||!O||!X)return;let z1=requestAnimationFrame(()=>{y.current?.querySelector(".documint-comment-reply-field textarea")?.focus()});return()=>{cancelAnimationFrame(z1)}},[X,M,O]);let m4=()=>{G(null),D("")},i1=(z1,i)=>{if(!J1||!_)return;G(z1),D(i)},v4=(z1)=>{if(!Z)return;Z.onEditComment(z1,B),m4()},h1=()=>{if(!Z)return;Z.onReply(F),H("")},V1=()=>{if(!J||!u)return;J.onCreateThread(b),E("")},g4=d?`documint-comment-leaf documint-comment-leaf-create${S?" is-expanded":""}`:"documint-comment-leaf",e=J1||k||p?h(MU,{canCreate:u,canEdit:X,canMutateThread:_,canReply:g,canSaveEditedComment:C,commentAgeFormatter:d7,comments:Q,editDraft:B,editingCommentIndex:U,isComposerVisible:p,isInitialCommentVisible:V,isResolved:q,link:A,mode:$.mode,onBeginEditingComment:i1,onCancelEditing:m4,onChangeCreateDraft:E,onChangeEditDraft:D,onChangeReplyDraft:H,onDeleteComment:m,onDeleteThread:Z1,onSubmitCreate:V1,onSubmitEditedComment:v4,onSubmitReply:h1,onToggleResolved:t,rootComment:K,showRootComment:k,showThreadChrome:J1,threadAge:W,composerPlaceholder:Q6,composerValue:u0},void 0,!1,void 0,this):null;return h("div",{className:g4,ref:y,children:h("div",{className:d?"documint-comment-leaf-create-shell":void 0,children:[d?h(x,{children:[h(x.Button,{className:"documint-comment-leaf-create-button",icon:y4,label:"Add comment",onClick:()=>j(!0)},void 0,!1,void 0,this),h(x.Divider,{className:"documint-comment-leaf-create-divider"},void 0,!1,void 0,this),h(x.Button,{active:N1.includes("bold"),className:"documint-comment-leaf-create-mark",icon:K4,label:"Bold",onClick:v1},void 0,!1,void 0,this),h(x.Button,{active:N1.includes("italic"),className:"documint-comment-leaf-create-mark",icon:H4,label:"Italic",onClick:g1},void 0,!1,void 0,this),h(x.Button,{active:N1.includes("underline"),className:"documint-comment-leaf-create-mark",icon:O4,label:"Underline",onClick:S4},void 0,!1,void 0,this),h(x.Button,{active:N1.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:V4,label:"Strikethrough",onClick:A1},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,h("div",{className:d?"documint-comment-leaf-create-content":void 0,children:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function MU({canCreate:$,canEdit:M,canMutateThread:J,canReply:Z,canSaveEditedComment:X,commentAgeFormatter:A,comments:Y,editDraft:Q,editingCommentIndex:K,isComposerVisible:q,isInitialCommentVisible:N,isResolved:U,link:G,mode:B,onBeginEditingComment:D,onCancelEditing:F,onChangeCreateDraft:H,onChangeEditDraft:b,onChangeReplyDraft:E,onDeleteComment:V,onDeleteThread:R,onSubmitCreate:O,onSubmitEditedComment:j,onSubmitReply:f,onToggleResolved:z,rootComment:y,showRootComment:T,showThreadChrome:W,threadAge:_,composerPlaceholder:C,composerValue:g}){return h(JU,{children:[W?h("div",{className:"documint-comment-leaf-header",children:[h("span",{className:"documint-comment-leaf-age",children:_},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:z,title:U?"Reopen comment":"Resolve comment",type:"button",children:h(C0,{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:R,title:"Delete comment thread",type:"button",children:h(w1,{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,W&&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${N?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:y?h("p",{onDoubleClick:()=>{D(0,y.body)},children:y.body},void 0,!1,void 0,this):null},void 0,!1,void 0,this),Y.slice(1).map((u,d)=>{let p=d+1,J1=K===p;return h("article",{className:"documint-comment-message",children:[!J1?h("div",{className:"documint-comment-message-meta",children:[h("span",{children:A(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:()=>{D(p,u.body)},title:"Edit comment",type:"button",children:h(E0,{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:()=>V(p),title:"Delete comment",type:"button",children:h(w1,{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,J1?h(n5,{className:"documint-comment-input",onCancel:F,onChange:b,onSave:()=>j(p),readOnly:!M,rows:3,saveDisabled:!X,value:Q},void 0,!1,void 0,this):h("p",{onDoubleClick:()=>{D(p,u.body)},children:u.body},void 0,!1,void 0,this)]},`${u.updatedAt}:${p}`,!0,void 0,this)})]},void 0,!0,void 0,this),h("div",{className:`documint-comment-reply${W?"":" is-standalone"}${q?" is-visible":""}`,children:h("div",{className:"documint-comment-reply-field",children:[h("textarea",{className:"documint-comment-input",onChange:(u)=>B==="create"?H(u.currentTarget.value):E(u.currentTarget.value),placeholder:C,readOnly:!M,rows:3,value:g},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"?O:f,title:B==="create"?"Create comment":"Reply",type:"button",children:h(H0,{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 d7($){let M=new Date($);if(Number.isNaN(M.getTime()))return $;let J=M.getTime()-Date.now(),Z=60000,X=60*Z,A=24*X,Y=7*A,Q=30*A,K=365*A,q=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(J)<Z)return"just now";if(Math.abs(J)<X)return q.format(Math.round(J/Z),"minute");if(Math.abs(J)<A)return q.format(Math.round(J/X),"hour");if(Math.abs(J)<Y)return q.format(Math.round(J/A),"day");if(Math.abs(J)<K)return q.format(Math.round(J/Q),"month");return q.format(Math.round(J/K),"year")}import{jsxDEV as S1}from"react/jsx-dev-runtime";var ZU=[{icon:N4,label:"Heading 1",text:"# "},{icon:U4,label:"Heading 2",text:"## "},{icon:G4,label:"Heading 3",text:"### "},{icon:B4,label:"Heading 4",text:"#### "},{icon:F4,label:"Heading 5",text:"##### "},{icon:D4,label:"Heading 6",text:"###### "}],XU=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function a7({onInsert:$,onInsertTable:M}){return S1(x,{children:[S1(x.Button,{icon:T4,label:"Insert bulleted list",onClick:()=>$("- ")},void 0,!1,void 0,this),S1(x.Button,{icon:P4,label:"Insert numbered list",onClick:()=>$("1. ")},void 0,!1,void 0,this),S1(x.Button,{icon:W4,label:"Insert task list",onClick:()=>$("- [ ] ")},void 0,!1,void 0,this),S1(x.Divider,{},void 0,!1,void 0,this),S1(x.Menu,{icon:_4,label:"Insert heading",onSelect:$,children:ZU.map(({icon:J,label:Z,text:X})=>S1(x.MenuItem,{icon:J,text:Z,value:X},X,!1,void 0,this))},void 0,!1,void 0,this),S1(x.Menu,{icon:P0,label:"Insert table",onSelect:(J)=>M(Number(J)),children:XU.map(({columns:J,text:Z})=>S1(x.MenuItem,{icon:P0,text:Z,value:String(J)},J,!1,void 0,this))},void 0,!1,void 0,this),S1(x.Divider,{},void 0,!1,void 0,this),S1(x.Button,{icon:z4,label:"Insert blockquote",onClick:()=>$("> ")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{createPortal as AU}from"react-dom";import{jsxDEV as f$}from"react/jsx-dev-runtime";function s7({anchor:$,children:M,className:J,status:Z="default"}){if(typeof document>"u")return null;let X=$.container??document.body,A=!$.isSelection,Y=J?`documint-leaf-shell ${J}`:"documint-leaf-shell";return AU(f$("div",{className:"documint-leaf-anchor","data-selection":$.isSelection?"true":"false",onPointerEnter:$.onPointerEnter,onPointerLeave:$.onPointerLeave,style:{left:`${$.left}px`,top:`${$.top}px`},children:[A?f$("div",{className:"documint-leaf-bridge"},void 0,!1,void 0,this):null,f$("div",{className:Y,"data-status":Z,children:M},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X)}import{useEffect as i7,useRef as YU,useState as o7}from"react";import{jsxDEV as j1}from"react/jsx-dev-runtime";function n7({canEdit:$,onDelete:M,onSave:J,title:Z,url:X}){let[A,Y]=o7(X),[Q,K]=o7(!1),q=YU(null),N=QU(),U=A.trim(),G=$&&U.length>0,B=$&&!Q,D=`${N}click to open`,F=`documint-link-leaf-row${Q?" is-editing":""}`;return i7(()=>{if(Q)return;Y(X)},[Q,X]),i7(()=>{if(!Q)return;q.current?.focus()},[Q]),j1("div",{className:"documint-link-leaf",children:[Z?j1("div",{className:"documint-link-leaf-title",children:Z},void 0,!1,void 0,this):null,j1("div",{className:F,children:[Q?j1(n5,{className:"documint-comment-input documint-link-leaf-input",onCancel:()=>{Y(X),K(!1)},onChange:Y,onSave:()=>{J(U),K(!1)},readOnly:!$,ref:q,rows:3,saveDisabled:!G,value:A},void 0,!1,void 0,this):j1("div",{className:"documint-link-leaf-url",children:X},void 0,!1,void 0,this),B?j1("div",{className:"documint-link-leaf-actions",children:[j1("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!$)return;Y(X),K(!0)},title:"Edit link",type:"button",children:j1(E0,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),j1("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:M,title:"Remove link",type:"button",children:j1(w1,{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),j1("div",{className:"documint-link-leaf-divider"},void 0,!1,void 0,this),j1("div",{className:"documint-link-leaf-hint",children:D},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function QU(){if(typeof navigator>"u")return"Ctrl+";let $=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test($)?"CMD+":"CTRL+"}import{jsxDEV as R1}from"react/jsx-dev-runtime";var KU=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],qU=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],u$={text:"Delete column",value:"delete"},S$={text:"Delete row",value:"delete"},t7={text:"Delete table",value:"delete"};function e7({canDeleteColumn:$,canDeleteRow:M,onDeleteColumn:J,onDeleteRow:Z,onDeleteTable:X,onInsertColumn:A,onInsertRow:Y}){return R1(x,{children:[R1(x.Menu,{icon:D0,label:"Column actions",onSelect:(Q)=>{if(Q===u$.value){J();return}A(Q)},children:[KU.map(({text:Q,value:K})=>R1(x.MenuItem,{icon:K2,text:Q,value:K},K,!1,void 0,this)),R1(x.MenuDivider,{},void 0,!1,void 0,this),R1(x.MenuItem,{disabled:!$,icon:w1,text:u$.text,value:u$.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R1(x.Menu,{icon:_0,label:"Row actions",onSelect:(Q)=>{if(Q===S$.value){Z();return}Y(Q)},children:[qU.map(({text:Q,value:K})=>R1(x.MenuItem,{icon:K2,text:Q,value:K},K,!1,void 0,this)),R1(x.MenuDivider,{},void 0,!1,void 0,this),R1(x.MenuItem,{disabled:!M,icon:w1,text:S$.text,value:S$.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R1(x.Divider,{},void 0,!1,void 0,this),R1(x.Menu,{icon:P0,label:"Table actions",onSelect:()=>X(),children:R1(x.MenuItem,{icon:w1,text:t7.text,value:t7.value},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as NU,useEffectEvent as $J,useLayoutEffect as UU,useMemo as GU,useRef as MJ,useState as BU}from"react";function e5($,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 FU=600,DU=530;function JJ({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,editorState:Z,editorViewportState:X,onVisibilityChange:A}){let Y=GU(()=>n(Z),[Z]),[Q,K]=BU(null),q=Y.start.regionId===Y.end.regionId&&Y.start.offset===Y.end.offset,N=MJ(!0),U=MJ(0),G=$J(()=>{A()}),B=$J(()=>{U.current=typeof performance<"u"?performance.now():Date.now(),N.current=!0,G()});return UU(()=>{let D=_U({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:Y,state:Z,viewport:X.get()});K((F)=>TU(F,D)?F:D)},[$,M,J,Z,X,Y.end.offset,Y.end.regionId,Y.start.offset,Y.start.regionId]),NU(()=>{if(N.current=!0,G(),!q||typeof window>"u")return;let D=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-U.current<FU){if(!N.current)N.current=!0,G();return}N.current=!N.current,G()},DU);return()=>{window.clearInterval(D)}},[q]),{leaf:Q,isVisible:()=>N.current,markActivity:B}}function _U({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:Z,state:X,viewport:A}){if(!A)return null;let Y=X.selection.focus;if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let Q=$?WU(X,A):null;if(Q)return Q;let K=M?HU(X,A):null;if(K)return K;return e5(M8(X,A,Y,J.liveRanges),J.threads)}function HU($,M){let J=$.selection.focus,Z=$.documentIndex.regionIndex.get(J.regionId),X=Z?$.documentIndex.tableCellIndex.get(Z.id)??null:null;if(!Z||!X)return null;let A=$.documentIndex.blockIndex.get(Z.blockId),Y=A?.type==="table"?$.documentIndex.document.blocks[A.rootIndex]:null;if(!A||!Y||Y.type!=="table")return null;let Q=M0($,M,J),K=PU(M,Z.id),q=Math.max(1,...Y.rows.map((N)=>N.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 PU($,M){let J=$.layout.lines.find((Z)=>Z.regionId===M);return J?J.left:null}function WU($,M){let J=$.selection.focus,Z=$.documentIndex.regionIndex.get(J.regionId);if(!Z||Z.blockType!=="paragraph"||Z.text.length>0)return null;if(J.offset!==0)return null;let X=$.documentIndex.blockIndex.get(Z.blockId);if(!X||X.parentBlockId!==null)return null;let A=M0($,M,J);return A?{kind:"insertion",left:A.left,top:A.top+A.height}:null}function TU($,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 yU,useMemo as m$,useRef as ZJ,useState as VU}from"react";function XJ($){let M=m$(()=>zU($),[$]),J=m$(()=>M.join(`
|
|
29
|
+
`),[M]),[Z,X]=VU(new Map),A=ZJ(Z),Y=ZJ(new Map);return A.current=Z,yU(()=>{if(typeof Image>"u")return;let Q=!0,K=new Set(M),q=Y.current;X((N)=>bU(N,K,q));for(let N of M){if(OU(A.current,q,N))continue;CU(N,q,X,()=>Q)}return()=>{Q=!1}},[J]),m$(()=>Z.size===0?null:{images:Z},[Z])}function zU($){return[..._M($)].sort()}function OU($,M,J){return $.get(J)?.status==="loaded"||M.has(J)}function bU($,M,J){let Z=!1,X=new Map($);for(let A of X.keys())if(!M.has(A))X.delete(A),J.delete(A),Z=!0;return Z?X:$}function CU($,M,J,Z){let X=new Image;X.decoding="async",X.crossOrigin="anonymous",M.set($,X),J((A)=>{let Y=new Map(A);return Y.set($,EU()),Y}),X.onload=()=>{if(M.delete($),!Z())return;J((A)=>{let Y=new Map(A);return Y.set($,wU(X)),Y})},X.onerror=()=>{if(M.delete($),!Z())return;J((A)=>{let Y=new Map(A);return Y.set($,jU()),Y})},X.src=$}function EU(){return{intrinsicHeight:0,intrinsicWidth:0,source:null,status:"loading"}}function wU($){return{intrinsicHeight:$.naturalHeight,intrinsicWidth:$.naturalWidth,source:$,status:"loaded"}}function jU(){return{intrinsicHeight:0,intrinsicWidth:0,source:null,status:"error"}}import{useEffect as AJ,useEffectEvent as m1,useRef as YJ,useState as RU}from"react";var LU=48;function QJ({commentState:$,editorStateRef:M,editorViewportState:J,resolveDocumentPoint:Z}){let[X,A]=RU(null),Y=YJ(null),Q=YJ(!1),K=e5(X,$.threads),q=X?.kind==="task-toggle"||K?.kind==="link"?"pointer":"text";AJ(()=>{if(X&&X.kind!=="task-toggle"&&!K)A(null)},[X,K]);let N=m1(()=>{if(Y.current!==null)window.clearTimeout(Y.current),Y.current=null}),U=m1(()=>{N(),Y.current=window.setTimeout(()=>{if(Y.current=null,!Q.current)A(null)},LU)}),G=m1(()=>{N(),A(null)}),B=m1(()=>{if(!Q.current)G()});AJ(()=>()=>{if(Y.current!==null)window.clearTimeout(Y.current)},[]);let D=m1((O)=>{let j=M.current;if(!j)return null;let f=Z(O);if(!f)return null;return $8(j,J.get(),f,$.liveRanges)}),F=m1((O)=>{if(!O){B();return}if(O.kind==="task-toggle"){N(),A((j)=>j?.kind==="task-toggle"&&j.listItemId===O.listItemId?j:O);return}if(O.commentThreadIndex!==null){if(!($.threads[O.commentThreadIndex]??null)){B();return}N();let f=O.commentThreadIndex;A((z)=>z?.kind!=="task-toggle"&&z?.commentThreadIndex===f?z:O);return}if(O.kind!=="link"){B();return}N(),A((j)=>j?.kind==="link"&&j.title===O.title&&j.url===O.url&&j.startOffset===O.startOffset&&j.endOffset===O.endOffset?j:O)}),H=m1((O)=>{F(D(O))}),b=m1(()=>{if(!Q.current)U()}),E=m1(()=>{Q.current=!0,N()}),V=m1(()=>{Q.current=!1,U()});return{canvasHandlers:{onClick:m1((O)=>{let j=D(O);if(!j||j.kind!=="link"||!O.metaKey&&!O.ctrlKey)return!1;return O.preventDefault(),O.stopPropagation(),O.currentTarget.ownerDocument.defaultView?.open(j.url,"_blank","noopener,noreferrer"),!0}),onPointerLeave:b,onPointerMove:H},cursor:q,leaf:K,leafHandlers:{onPointerEnter:E,onPointerLeave:V},resolveTarget:D}}import{useEffect as p$,useEffectEvent as D1,useLayoutEffect as fU,useRef as BJ,useState as uU}from"react";var v$=[{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",modKey:!0,shiftKey:"any",command:"moveToDocumentStart"},{key:"ArrowDown",modKey:!0,shiftKey:"any",command:"moveToDocumentEnd"},{key:"ArrowUp",altKey:!0,shiftKey:!0,command:"moveListItemUp"},{key:"ArrowDown",altKey:!0,shiftKey:!0,command:"moveListItemDown"},{key:"a",modKey:!0,command:"selectAll"},{key:"b",modKey:!0,command:"toggleBold"},{key:"e",modKey:!0,command:"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 KJ($,M=v$){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 GJ($){let M=$.documentIndex.regions.find((A)=>A.id===$.selection.anchor.regionId),J=$.documentIndex.regions.find((A)=>A.id===$.selection.focus.regionId),Z=(M?.start??0)+$.selection.anchor.offset,X=(J?.start??0)+$.selection.focus.offset;return{end:Math.max(Z,X),start:Math.min(Z,X)}}function g$($){let M=h$($);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 h$($){let M=kU($);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 qJ=28,NJ=18;function I$($,M){if(!$)return;let J=$.getBoundingClientRect();if(M.clientY<J.top+qJ){$.scrollTop=Math.max(0,$.scrollTop-NJ);return}if(M.clientY>J.bottom-qJ)$.scrollTop+=NJ}function kU($){let M=UJ($.documentIndex.regions,$.selection.anchor.regionId,$.selection.anchor.offset),J=UJ($.documentIndex.regions,$.selection.focus.regionId,$.selection.focus.offset);return M<=J?{end:$.selection.focus,start:$.selection.anchor}:{end:$.selection.anchor,start:$.selection.focus}}function UJ($,M,J){let Z=$.findIndex((X)=>X.id===M);if(Z===-1)return-1;return Z*1e6+J}var SU=64;function DJ({editorState:$,editorStateRef:M,editorViewportState:J,inputRef:Z,keybindings:X,onActivity:A,onEditorStateChange:Y}){let Q=mU(),K=()=>M.current??$,q=BJ(!1),N=BJ(!1),U=D1((_)=>{if(!_)return;A(),Y(_)}),G=D1(()=>{let _=Z.current;if(!_)return;if(typeof document>"u")return;let C=document.execCommand;if(typeof C!=="function")return;try{q.current=!0,C.call(document,"insertText",!1,""),C.call(document,"delete")}catch{}finally{q.current=!1,k4(_,K())}}),B=D1(()=>{if(N.current)return;N.current=!0,G()}),D=D1(()=>{G()}),F=D1((_)=>{if(!Q)return;let C=Z.current;if(!C)return;let g=J.get(),u=M0(K(),g,_);if(!u)return;C.style.top=`${u.top}px`,C.style.left=`${u.left}px`,C.style.height=`${u.height}px`}),H=D1((_)=>{let C=Z.current;if(!C)return;F(_??K().selection.focus),C.focus({preventScroll:!Q}),k4(C,K()),B()}),b=D1((_,C)=>{let u=FJ(C,l$(_)).replace(/\r\n/g,`
|
|
30
|
+
`).split(/(\n)/),d=_;for(let p of u){if(p.length===0)continue;let J1=p===`
|
|
31
|
+
`?e2(d):Y2(d,p);if(!J1)continue;d=J1}return d===_?null:d}),E=D1((_,C,g)=>{let u=_.selection.focus,d={regionId:u.regionId,offset:Math.max(0,u.offset-C)},p=K1(_,{anchor:d,focus:u});return m5(p,g)}),V=D1((_)=>{if(q.current)return;let C=K(),g=gU(_.inputType);if(_.inputType==="insertText"){if(!_.data)return;_.preventDefault(),U(b(C,_.data));return}if(_.inputType==="insertReplacementText"){if(!_.data)return;_.preventDefault();let u=_.target,d=u?.selectionStart??0,p=u?.selectionEnd??d,J1=Math.max(0,p-d);U(E(C,J1,_.data));return}if(vU(_.inputType)){_.preventDefault(),U(e2(C));return}if(g==="backward"){_.preventDefault(),U(u5(C));return}if(g==="forward"){_.preventDefault(),U(S5(C));return}if(_.inputType==="historyUndo"){_.preventDefault(),U(g5(C)),D();return}if(_.inputType==="historyRedo"){_.preventDefault(),U(h5(C)),D();return}}),R=D1((_)=>{if(q.current)return;let C=K(),g=_.currentTarget.value;if(FJ(g,l$(C)).length===0){k4(_.currentTarget,C);return}U(b(C,g))}),O=D1((_)=>{let C=IU(K(),J.get(),_.nativeEvent,X);if(!C)return;_.preventDefault(),U(C)}),j=D1((_)=>{let C=g$(K());if(!C)return;_.preventDefault(),_.clipboardData.setData("text/plain",C)}),f=D1((_)=>{let C=K(),g=g$(C);if(!g)return;_.preventDefault(),_.clipboardData.setData("text/plain",g),U($4(C))}),z=D1((_)=>{let C=_.clipboardData.getData("text/plain");if(C.length===0)return;_.preventDefault(),U(m5(K(),C))}),y=D1(()=>{A();let _=Z.current;if(_)k4(_,K())}),T=D1(()=>{A(),H()});p$(()=>{let _=Z.current;if(!_)return;k4(_,$)},[$,Z]),fU(()=>{F($.selection.focus)},[$,F]),p$(()=>{let _=Z.current;if(!_)return;let C=(g)=>V(g);return _.addEventListener("beforeinput",C),()=>_.removeEventListener("beforeinput",C)},[Z,V]);let W={onCopy:j,onCut:f,onPaste:z,...Q?{}:{onKeyDown:O}};return{canvasHandlers:{...W,onFocus:T},focus:H,inputHandlers:{...W,onFocus:y,onInput:R}}}var _J="";function mU(){let[$,M]=uU(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return p$(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let J=window.matchMedia("(pointer: coarse)"),Z=(X)=>M(X.matches);return J.addEventListener?.("change",Z),()=>J.removeEventListener?.("change",Z)},[]),$}function vU($){return $==="insertLineBreak"||$==="insertParagraph"}function gU($){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 hU($){return $.replaceAll(_J,"")}function l$($,M=SU){let{anchor:J,focus:Z}=$.selection;if(J.regionId!==Z.regionId||J.offset!==Z.offset)return"";let X=$.documentIndex.regionIndex.get(Z.regionId);if(!X)return"";return X.text.slice(Math.max(0,Z.offset-M),Z.offset)}function FJ($,M){let J=hU($);return J.startsWith(M)?J.slice(M.length):J}function k4($,M){let J=l$(M),Z=`${_J}${J}`;$.value=Z,$.setSelectionRange(Z.length,Z.length)}function IU($,M,J,Z){if(J.key==="Delete")return S5($);let X=KJ(J,Z);if(X){if(X==="moveToLineStart"||X==="moveToLineEnd")return K$($,M.layout,X==="moveToLineStart"?"Home":"End",J.shiftKey);if(X==="moveToDocumentStart"||X==="moveToDocumentEnd")return q$($,X==="moveToDocumentStart"?"start":"end",J.shiftKey);switch(X){case"insertLineBreak":return e2($);case"deleteBackward":return u5($);case"indent":return h8($);case"dedent":return I8($);case"moveListItemUp":return p8($);case"moveListItemDown":return l8($);case"toggleBold":return M4($);case"toggleItalic":return J4($);case"toggleStrikethrough":return Z4($);case"toggleUnderline":return X4($);case"toggleInlineCode":return i8($);case"undo":return g5($);case"redo":return h5($);case"selectAll":return g8($)}}if(J.key==="ArrowLeft"||J.key==="ArrowRight")return A$($,J.key==="ArrowLeft"?-1:1,J.shiftKey);if(J.key==="ArrowUp"||J.key==="ArrowDown")return Y$($,M.layout,J.key==="ArrowUp"?-1:1,J.shiftKey);if(J.key==="PageUp"||J.key==="PageDown")return Q$($,M.layout,J.key==="PageUp"?-1:1,J.shiftKey);if(J.key.length===1&&!J.altKey&&!J.ctrlKey&&!J.metaKey)return Y2($,J.key);return null}import{useEffect as pU,useEffectEvent as r$,useLayoutEffect as lU,useMemo as rU,useRef as HJ,useState as cU}from"react";var xU=[];function PJ({editorState:$,editorStateRef:M,editorViewportState:J,onViewportScroll:Z,presence:X,scrollContainerRef:A,scheduleOverlayRender:Y}){let Q=rU(()=>{if(!X||X.length===0)return xU;return K5($.documentIndex,X)},[$.documentIndex,X]),[K,q]=cU([]),N=HJ(Q),U=HJ(K);N.current=Q,U.current=K;let G=r$((F)=>{if(dU(U.current,F))return;U.current=F,q(F)}),B=r$((F)=>{let H=N.current;if(H.length===0){G([]);return}G(q5(M.current??$,F,H))});pU(()=>{Y()},[Q,Y]),lU(()=>{if(Q.length===0){G([]);return}B(J.get())},[J,B,Q,G]);let D=r$((F)=>{if(!F.viewport||F.viewport.scrollTop===null)return;let H=A.current;if(!H)return;H.scrollTop=F.viewport.scrollTop,Z(H)});return{canvasPresence:Q.length===0?void 0:Q,presenceOverlayProps:{onSelect:D,presence:K},refreshViewportPresence:B}}function dU($,M){if($.length!==M.length)return!1;return $.every((J,Z)=>{let X=M[Z];return X!==void 0&&J.color===X.color&&J.imageUrl===X.imageUrl&&J.name===X.name&&J.viewport?.scrollTop===X.viewport?.scrollTop&&J.viewport?.status===X.viewport?.status})}import{useEffect as aU,useEffectEvent as $6,useRef as M6}from"react";function WJ({hasRunningAnimations:$,renderContent:M,renderOverlay:J,renderViewport:Z}){let X=M6(null),A=M6(!1),Y=M6(!1),Q=M6(!1),K=$6(()=>{if(typeof window>"u"||X.current!==null)return;X.current=window.requestAnimationFrame(()=>{N()})}),q=$6(()=>{if(!$?.())return;Y.current=!0,K()}),N=$6(()=>{X.current=null;let G=A.current,B=Y.current,D=Q.current;if(A.current=!1,Y.current=!1,Q.current=!1,G){Z(),q();return}if(B){if(M(),D)J();q();return}if(D)J()}),U=$6((G)=>{if(typeof window>"u")switch(G){case"viewport":Z();return;case"content":M();return;case"overlay":J();return}switch(G){case"viewport":A.current=!0;break;case"content":Y.current=!0;break;case"overlay":Q.current=!0;break}K()});return aU(()=>{return()=>{if(typeof window>"u"||X.current===null)return;window.cancelAnimationFrame(X.current),X.current=null}},[]),{scheduleRender:U}}import{useEffectEvent as c$,useLayoutEffect as TJ,useMemo as x$,useRef as d$,useState as yJ}from"react";function J6($,M){let J=M.getBoundingClientRect();return{x:$.clientX-J.left+M.scrollLeft,y:$.clientY-J.top+M.scrollTop}}function VJ({autoScrollContainer:$,canShowSelectionLeaf:M,canvasRef:J,threads:Z,editorState:X,editorStateRef:A,scrollContainerRef:Y,editorViewportState:Q,onActivity:K,onEditorStateChange:q}){let N=x$(()=>n(X),[X]),U=x$(()=>h$(X),[X]),G=x$(()=>H5(X),[X]),[B,D]=yJ(null),[F,H]=yJ(null),b=d$(null),E=d$(null),V=d$(null);TJ(()=>{let z=sU(X,Q.get(),N);D((y)=>eU(y,z)?y:z)},[X,Q,N.end.offset,N.end.regionId,N.start.offset,N.start.regionId]),TJ(()=>{let z=oU({canShowSelectionLeaf:M,currentLeaf:F,activeMarks:G,handles:B,selectionRange:U,threads:Z});H((y)=>tU(y,z)?y:z)},[G,M,B,F,U,Z]);let R=c$((z,y=!0)=>{H((T)=>T?.kind==="create"?{animateInitialComment:y,kind:"thread",left:T.left,threadIndex:z,top:T.top}:T)}),O=c$((z)=>{if(z&&V.current===z.pointerId&&z.currentTarget.hasPointerCapture(z.pointerId))z.currentTarget.releasePointerCapture(z.pointerId);b.current=null,E.current=null,V.current=null}),j=c$((z)=>{let y=Y.current,T=A.current,W=E.current;if(!y||!T||!W||V.current!==z.pointerId)return;let _=J6(z,y),C=R2(T,Q.get(),_,W);if(!C)return;z.preventDefault(),z.stopPropagation(),K(),$(z),q(K1(T,{anchor:W,focus:C}))}),f=(z)=>({onPointerCancel:(y)=>{O(y)},onPointerDown:(y)=>{let T=A.current??X,W=MG(N,z),_=z==="start"?N.start:N.end;if(!B)return;y.preventDefault(),y.stopPropagation(),V.current=y.pointerId,E.current=W,b.current=z,y.currentTarget.setPointerCapture(y.pointerId),K(),J.current?.focus({preventScroll:!0}),q(K1(T,{anchor:W,focus:_}))},onPointerMove:(y)=>{if(b.current!==z)return;j(y)},onPointerUp:(y)=>{if(b.current===z)j(y);O(y)}});return{endHandleProps:f("end"),handles:B,leaf:F,promoteLeafToThread:R,startHandleProps:f("start")}}function sU($,M,J){if(H8($.selection))return null;let Z=M0($,M,J.start),X=M0($,M,J.end);if(!Z||!X)return null;return{end:{left:X.left,top:X.top+X.height},start:{left:Z.left,top:Z.top}}}function iU($,M,J){return{activeMarks:J,kind:"create",left:M.start.left,selection:$,top:M.end.top}}function oU({activeMarks:$,canShowSelectionLeaf:M,currentLeaf:J,handles:Z,selectionRange:X,threads:A}){if(!M||!X||!Z)return null;if(J?.kind==="thread")return A[J.threadIndex]?J:null;return iU(X,Z,$)}function nU($,M){return $?.kind==="create"&&$.left===M.left&&$.selection.regionId===M.selection.regionId&&$.selection.startOffset===M.selection.startOffset&&$.selection.endOffset===M.selection.endOffset&&$G($.activeMarks,M.activeMarks)&&$.top===M.top}function tU($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;if($.kind==="create"&&M.kind==="create")return nU($,M);return $.kind==="thread"&&M.kind==="thread"&&$.animateInitialComment===M.animateInitialComment&&$.left===M.left&&$.threadIndex===M.threadIndex&&$.top===M.top}function eU($,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 $G($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function MG($,M){return M==="start"?$.end:$.start}import{useEffect as JG,useMemo as bJ,useState as ZG}from"react";var f4={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)"},u4={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)"},zJ={...f4,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)"},OJ={...u4,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 CJ($){let M=bJ(()=>AG($),[$]),[J,Z]=ZG(M.light),X=bJ(()=>YG(J),[J]);return JG(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){Z(M.light);return}let A=window.matchMedia("(prefers-color-scheme: dark)"),Y=()=>{Z(A.matches?M.dark:M.light)};if(Y(),typeof A.addEventListener==="function")return A.addEventListener("change",Y),()=>{A.removeEventListener("change",Y)};return A.addListener(Y),()=>{A.removeListener(Y)}},[M]),{theme:J,themeStyles:X}}function XG($){return"light"in $&&"dark"in $}function AG($){if(!$)return{dark:u4,light:f4};if(XG($))return $;return{dark:$,light:$}}function YG($){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 qG,useEffectEvent as L0,useRef as a$,useState as Z6}from"react";import{useMemo as QG}from"react";function EJ($){return QG(()=>KG({current:null},$),[$])}function KG($,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 wJ({editorState:$,editorStateRef:M,renderResources:J,theme:Z}){let X=a$(z0()),A=a$(null),Y=a$({height:240,top:0}),[Q,K]=Z6(0),[q,N]=Z6(240),[U,G]=Z6(0),[B,D]=Z6(240),F=NG(Q),H=L0(()=>{let y=M.current??$,T=Y.current;return n6(y,{height:T.height,paddingX:Z.paddingX,paddingY:Z.paddingY,top:T.top,width:F},X.current,J)}),b=EJ(H),E=L0((y)=>{D((T)=>{let W=GG(y,Y.current.height);return T===W?T:W})}),V=L0((y)=>{let T=UG(y);Y.current=T,G((W)=>W===T.top?W:T.top)}),R=L0((y)=>{Y.current={...Y.current,top:y},G((T)=>T===y?T:y),b.invalidate()}),O=L0((y)=>{let T=A.current;if(!T)return R(y),y;T.scrollTop=y;let W=T.scrollTop;return R(W),W}),j=L0(()=>{return A.current?.scrollTop??Y.current.top}),f=L0((y)=>{let T=A.current;return T?J6(y,T):null}),z=(y)=>({onScroll:(T)=>{V(T.currentTarget),y?.onScroll?.(T)},ref:A});return qG(()=>{let y=A.current;if(!y||typeof ResizeObserver>"u")return;let T=new ResizeObserver((W)=>{let _=W[0];if(!_)return;let C=Math.max(0,Math.floor(_.contentRect.width)),g=jJ(y);Y.current={...Y.current,height:g},K((u)=>u===C?u:C),N((u)=>u===g?u:g)});return T.observe(y),()=>{T.disconnect()}},[A]),{actions:{getScrollTop:j,observePreparedViewport:E,observeScrollContainer:V,resolvePointerPoint:f,scrollTo:O},props:{getScrollContainer:z,scrollContent:{style:{height:`${B}px`}}},refs:{scrollContainer:A},state:{layoutWidth:F,preparedViewport:b,scrollContentHeight:B,surfaceWidth:Q,viewportHeight:q,viewportTop:U}}}function NG($){return Math.max(240,Math.floor($||480))}function jJ($){return Math.max(240,$.clientHeight)}function UG($){return{height:jJ($),top:$.scrollTop}}function GG($,M){return Math.max(M,Math.ceil($.totalHeight+24))}function BG(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function s$($,{paintHeight:M,paintTop:J,width:Z}){if(!$)return null;let X=Math.max(240,Math.ceil(M)),A=BG();$.width=Math.ceil(Z*A),$.height=Math.ceil(X*A),$.style.width=`${Z}px`,$.style.height=`${X}px`,$.style.transform=`translateY(${J}px)`;let Y=$.getContext("2d");if(!Y)return null;return{context:Y,devicePixelRatio:A,height:X,width:Z}}function i$($,M){return $.activeBlockType===M.activeBlockType&&$.activeCommentThreadIndex===M.activeCommentThreadIndex&&$.activeSpanKind===M.activeSpanKind&&$.canonicalContent===M.canonicalContent&&$.characterCount===M.characterCount&&$.commentThreadCount===M.commentThreadCount&&$.layoutWidth===M.layoutWidth&&$.resolvedCommentCount===M.resolvedCommentCount&&$.selectionFrom===M.selectionFrom&&$.selectionTo===M.selectionTo}var RJ=24;function fJ($,M){if(!$)return LJ(M);let J=DG($,M)??HG($,M);return J?FG(J):LJ(M)}function FG($){return{didReconcile:!0,state:$}}function LJ($){return{didReconcile:!1,state:$}}function DG($,M){let J=_G($,M);return J?K1(M,J,!1):null}function _G($,M){if(e$($.selection.anchor,$.selection.focus)){let A=o$($,M,$.selection.focus,"neutral");return A?{anchor:A,focus:A}:null}let J=EG($),Z=o$($,M,$.selection.anchor,J.anchor),X=o$($,M,$.selection.focus,J.focus);return Z&&X?{anchor:Z,focus:X}:null}function o$($,M,J,Z){let X=$.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let A=t$(X,M);if(!A)return null;return{offset:zG(X.text,A.text,J.offset,Z),regionId:A.id}}function t$($,M){let J=M.documentIndex.regionIndex.get($.id);if(J)return J;if($.text.length===0)return null;let Z=VG($,M);if(Z)return Z;let X=M.documentIndex.regionPathIndex.get($.path);if(X)return X;return null}function HG($,M){if(!e$($.selection.anchor,$.selection.focus))return null;let J=PG($);if(!J)return null;let Z=TG($,M,J);if(Z===null)return null;return WG(M,Z)}function PG($){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 WG($,M){let J=I0($.documentIndex.document,M,0,[I({text:""})]),Z={...$,documentIndex:$2($.documentIndex,J,M,0)},X=v2(Z.documentIndex,M1(M));return X?K1(Z,X,!1):null}function TG($,M,J){let Z=kJ($,J.rootIndex,"before"),X=kJ($,J.rootIndex,"after"),A=Z?t$(Z,M):null,Y=X?t$(X,M):null;if(A&&Y)return A.rootIndex<Y.rootIndex?Y.rootIndex:null;if(A)return A.rootIndex+1;if(Y)return Y.rootIndex;return null}function kJ($,M,J){let Z=J==="before"?-1:1;for(let X=M+Z;X>=0&&X<$.documentIndex.roots.length;X+=Z){let A=yG($,X,J);if(!A)continue;return A}return null}function yG($,M,J){let Z=$.documentIndex.roots[M]?.regions??[],X=J==="before"?Z.length-1:0,A=J==="before"?-1:1;for(let Y=X;Y>=0&&Y<Z.length;Y+=A){let Q=Z[Y];if(Q&&Q.text.length>0)return Q}return null}function VG($,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 zG($,M,J,Z){let X=n$(J,0,$.length),A=$.slice(Math.max(0,X-RJ),X),Y=$.slice(X,Math.min($.length,X+RJ)),Q=OG(M,A,Y);if(Q!==null)return Q;let K=bG(M,A),q=CG(M,Y);if(Z==="before-suffix")return q??K??n$(J,0,M.length);return K??q??n$(J,0,M.length)}function OG($,M,J){if(M.length===0||J.length===0)return null;let Z=null,X=0;while(X<=$.length){let A=$.indexOf(M,X);if(A===-1)break;let Y=A+M.length;if($.startsWith(J,Y)){if(Z!==null)return null;Z=Y}X=A+Math.max(1,M.length)}return Z}function bG($,M){if(M.length===0)return null;let J=uJ($,M);return J===null?null:J+M.length}function CG($,M){return M.length===0?null:uJ($,M)}function uJ($,M){let J=null,Z=0;while(Z<=$.length){let X=$.indexOf(M,Z);if(X===-1)break;if(J!==null)return null;J=X,Z=X+Math.max(1,M.length)}return J}function EG($){let{anchor:M,focus:J}=$.selection;if(e$(M,J))return{anchor:"neutral",focus:"neutral"};return wG($,M,J)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function wG($,M,J){let Z=$.documentIndex.regionOrderIndex.get(M.regionId),X=$.documentIndex.regionOrderIndex.get(J.regionId);if(Z===void 0||X===void 0)return 0;return Z===X?M.offset-J.offset:Z-X}function e$($,M){return $.regionId===M.regionId&&$.offset===M.offset}function n$($,M,J){return Math.max(M,Math.min($,J))}import{jsxDEV as l,Fragment as mG}from"react/jsx-dev-runtime";function A6({blocks:$}){return l(mG,{children:$.map((M)=>jG(M))},void 0,!1,void 0,this)}function jG($){switch($.type){case"blockquote":return l("blockquote",{className:"preview-block preview-block-blockquote",children:l(A6,{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:kG($.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:X6($.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)=>$M(M))},$.id,!1,void 0,this):l("ul",{className:"preview-block preview-block-list",children:$.items.map((M)=>$M(M))},$.id,!1,void 0,this);case"listItem":return $M($);case"paragraph":return l("p",{className:"preview-block preview-block-paragraph",children:X6($.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:fG($.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:X6(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 $M($){return l("li",{className:"preview-block preview-block-list-item",children:l(A6,{blocks:$.children},void 0,!1,void 0,this)},$.id,!1,void 0,this)}function X6($){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:uG(M.alt)},void 0,!1,void 0,this),l("small",{children:SG(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 RG(M);case"text":return l("span",{className:"preview-inline",children:LG(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 RG($){return l("a",{className:"preview-inline preview-inline-link",href:$.url,children:X6($.children)},$.id,!1,void 0,this)}function LG($,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 kG($,M){return[$??"plain text",M].filter(Boolean).join(" • ")}function fG($,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 uG($){return $?.trim()?$:"Untitled image"}function SG($,M){return M?.trim()?`${M} • ${$}`:$}var SJ=`
|
|
32
32
|
:where(.documint-leaf-toolbar) {
|
|
33
33
|
--documint-leaf-toolbar-button-active-bg:
|
|
34
34
|
color-mix(in srgb, var(--documint-leaf-accent) 16%, var(--documint-leaf-bg));
|
|
@@ -156,7 +156,7 @@ ${M.text}`:M.text}function KN($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
156
156
|
margin: 0.15rem 0.2rem;
|
|
157
157
|
background: var(--documint-leaf-toolbar-divider-color);
|
|
158
158
|
}
|
|
159
|
-
`;var
|
|
159
|
+
`;var mJ=`
|
|
160
160
|
:where(.documint-leaf-shell) {
|
|
161
161
|
--documint-leaf-divider-color:
|
|
162
162
|
color-mix(in srgb, var(--documint-leaf-border) 60%, transparent);
|
|
@@ -202,7 +202,7 @@ ${M.text}`:M.text}function KN($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
202
202
|
width: min(16rem, calc(100vw - 4rem));
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
${
|
|
205
|
+
${SJ}
|
|
206
206
|
|
|
207
207
|
:where(.documint-leaf-anchor) {
|
|
208
208
|
--documint-leaf-anchor-bridge-height: 12px;
|
|
@@ -565,7 +565,7 @@ ${VJ}
|
|
|
565
565
|
right: 0.7rem;
|
|
566
566
|
bottom: calc(0.7rem + 3px);
|
|
567
567
|
}
|
|
568
|
-
`;var
|
|
568
|
+
`;var vJ=`
|
|
569
569
|
:where(.documint) {
|
|
570
570
|
display: grid;
|
|
571
571
|
min-width: 0;
|
|
@@ -893,6 +893,5 @@ ${VJ}
|
|
|
893
893
|
white-space: nowrap;
|
|
894
894
|
}
|
|
895
895
|
|
|
896
|
-
${
|
|
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};
|
|
896
|
+
${mJ}
|
|
897
|
+
`;import{jsxDEV as Y1,Fragment as IG}from"react/jsx-dev-runtime";var gG=2,gJ={activeBlockType:null,activeCommentThreadIndex:null,activeSpanKind:null,canonicalContent:"",characterCount:0,commentThreadCount:0,layoutWidth:0,resolvedCommentCount:0,selectionFrom:0,selectionTo:0};function pJ({className:$,content:M,keybindings:J,onContentChange:Z,onStateChange:X,presence:A,theme:Y}){let Q=y1(null),K=y1(null),q=y1(null),N=y1(null),U=y1(null),G=y1(null),B=y1(null),D=y1(null),F=y1(!1),H=y1(M),b=y1(""),E=y1(gJ),V=y1(null),[R,O]=MM(!1),{theme:j,themeStyles:f}=CJ(Y),[z,y]=MM(gJ),T=f0(()=>C$(M),[M]),W=f0(()=>i5(T),[T]),[_,C]=MM(()=>d2(T)),g=XJ(_.documentIndex.document),u=f0(()=>[...g?.images.values()??[]].some((P)=>P.status==="loading"),[g]);U.current=_,b.current||=W;let d=wJ({editorState:_,editorStateRef:U,renderResources:g,theme:j}),{actions:p,props:J1,refs:k,state:S}=d,{getScrollTop:m,observePreparedViewport:Z1,observeScrollContainer:t,resolvePointerPoint:N1,scrollTo:v1}=p,{layoutWidth:g1,preparedViewport:A1,scrollContentHeight:S4,surfaceWidth:Q6,viewportHeight:u0,viewportTop:m4}=S,{scrollContainer:i1}=k,v4=f0(()=>g2(_),[_]),h1=f0(()=>f1(_),[_]),V1=f0(()=>n(_),[_]),g4=f0(()=>IJ(_,h1.liveRanges),[h1.liveRanges,_]),B2=Boolean(Z),e=()=>U.current??_,z1=B1((P,w)=>{let v=g2(P),c=f1(P),r=GJ(P),o={activeBlockType:v.block?.nodeType??null,activeCommentThreadIndex:IJ(P,c.liveRanges),activeSpanKind:v.span.kind==="none"?null:v.span.kind,canonicalContent:w,characterCount:w.length,commentThreadCount:c.threads.length,layoutWidth:g1,resolvedCommentCount:O6(c.threads),selectionFrom:r.start,selectionTo:r.end};if(y((l1)=>i$(l1,o)?l1:o),!i$(E.current,o))E.current=o,X?.(o)}),i=B1((P)=>{if(!P)return;let w=U.current??_,v=w.documentIndex!==P.documentIndex,c=w5(w,P);U.current=P,C(P);let r=A1.current;if(!(!v||!r||r.layout.regionLineIndices.has(P.selection.focus.regionId)))A1.invalidate();if(c)O1("viewport");if(!v)return;let l1=a2(P),D2=i5(l1);b.current=D2,H.current=D2,Z?.(D2,l1)}),JM=B1((P=A1.current)=>{if(!P)return;let w=s$(K.current,{paintHeight:P.paintHeight,paintTop:P.paintTop,width:g1});if(!w)return;let{context:v,devicePixelRatio:c,height:r,width:o}=w;F$(_,P,v,{activeBlockId:v4.block?.blockId??null,activeRegionId:_.selection.focus.regionId,activeThreadIndex:XM??g4,devicePixelRatio:c,height:r,liveCommentRanges:h1.liveRanges,normalizedSelection:V1,now:performance.now(),resources:g,theme:j,width:o})}),ZM=B1((P=A1.current)=>{if(!P)return;let w=s$(q.current,{paintHeight:P.paintHeight,paintTop:P.paintTop,width:g1});if(!w)return;let{context:v,devicePixelRatio:c,height:r,width:o}=w;D$(_,P,v,{devicePixelRatio:c,height:r,normalizedSelection:V1,presence:K6.canvasPresence,showCaret:V1.start.regionId!==V1.end.regionId||V1.start.offset!==V1.end.offset||o1.isVisible(),theme:j,width:o})}),lJ=B1(()=>{A1.invalidate();let P=A1.get();Z1(P),K6.refreshViewportPresence(P),JM(P),ZM(P)}),{scheduleRender:O1}=WJ({hasRunningAnimations:()=>z8(U.current??_,performance.now()),renderContent:JM,renderOverlay:ZM,renderViewport:lJ}),rJ=J1.getScrollContainer({onScroll:()=>O1("viewport")}),o1=JJ({canShowInsertionLeaf:Boolean(Z),canShowTableLeaf:Boolean(Z),commentState:h1,editorState:_,editorViewportState:A1,onVisibilityChange:()=>O1("overlay")}),L1=QJ({commentState:h1,editorStateRef:U,editorViewportState:A1,resolveDocumentPoint:N1}),XM=L1.leaf?.kind==="comment"?L1.leaf.threadIndex:null,cJ=B1((P)=>{t(P),O1("viewport")}),K6=PJ({editorState:_,editorStateRef:U,editorViewportState:A1,onViewportScroll:cJ,presence:A,scrollContainerRef:i1,scheduleOverlayRender:()=>O1("overlay")}),AM=B1((P,w)=>{if(P.scrollHeight<=P.clientHeight||w.deltaY===0)return;let v=24,c=w.deltaMode===1?v:w.deltaMode===2?P.clientHeight:1,r=Math.max(0,Math.min(P.scrollHeight-P.clientHeight,P.scrollTop+w.deltaY*c));if(r===P.scrollTop)return;w.preventDefault(),v1(r),O1("viewport")}),F2=DJ({editorState:_,editorStateRef:U,editorViewportState:A1,inputRef:N,keybindings:J,onActivity:o1.markActivity,onEditorStateChange:i}),I1=VJ({autoScrollContainer:(P)=>{I$(i1.current,P)},canShowSelectionLeaf:B2,canvasRef:K,threads:h1.threads,editorState:_,editorStateRef:U,scrollContainerRef:i1,editorViewportState:A1,onActivity:o1.markActivity,onEditorStateChange:i}),xJ=B1(()=>{K.current?.focus({preventScroll:!0})}),YM=B1((P)=>{let w=K.current;if(w&&G.current===P)w.releasePointerCapture(P)}),QM=B1(()=>{G.current=null,B.current=null}),dJ=B1((P)=>{YM(P.pointerId),QM(),D.current=null,F.current=!1}),aJ=B1((P)=>{let w=K.current,v=e(),c=N1(P);if(!c)return;let r=L1.resolveTarget(P);if(r?.kind==="task-toggle"){P.preventDefault(),P.stopPropagation(),D.current=r.listItemId,o1.markActivity(),xJ();return}let o=t6(v,A1.get(),c);if(!w||!o)return;G.current=P.pointerId,B.current={offset:o.offset,regionId:o.regionId},o1.markActivity(),w.setPointerCapture(P.pointerId),i(K1(v,{offset:o.offset,regionId:o.regionId})),F2.focus({offset:o.offset,regionId:o.regionId})}),sJ=B1(()=>{L1.canvasHandlers.onPointerLeave(),F.current=!1}),iJ=B1((P)=>{let w=B.current,v=e(),c=N1(P);if(!c)return;if(L1.canvasHandlers.onPointerMove(P),G.current!==P.pointerId||!w)return;let r=R2(v,A1.get(),c,w);if(!r)return;o1.markActivity(),I$(i1.current,P),i(K1(v,{anchor:w,focus:r}))}),oJ=B1((P)=>{let w=e();if(YM(P.pointerId),D.current){let v=t8(w,D.current);if(D.current=null,v)F.current=!0,P.preventDefault(),P.stopPropagation(),o1.markActivity(),i(v)}QM()}),nJ=B1((P)=>{if(F.current){F.current=!1,D.current=null,P.preventDefault(),P.stopPropagation();return}if(L1.canvasHandlers.onClick(P))return;D.current=null,F2.focus()}),tJ=B1((P)=>{let w=e(),v=N1(P),c=L1.resolveTarget(P);if(!v||c?.kind==="task-toggle")return;let r=e6(w,A1.get(),v);if(!r)return;P.preventDefault(),P.stopPropagation(),o1.markActivity(),i(K1(w,r)),F2.focus()});k0(()=>{O(!0)},[]),vG(()=>{if(M===H.current)return;let P=U.current,w=fJ(P,d2(T)),v=w.state,c=w.didReconcile?m():0;U.current=v,C(v),H.current=M,b.current=W,v1(c)},[W,M,T,m,v1]),k0(()=>{z1(_,b.current||W)},[W,_,z1,Q6]),k0(()=>{let P=i1.current,w=_.selection.focus;if(!P)return;let v={layoutWidth:g1,offset:w.offset,regionId:w.regionId,scrollContentHeight:S4,viewportHeight:u0};if(hG(V.current,v))return;let c=24,r=J8(_,A1.get(),w);if(!r)return;let o=u0,l1=P.scrollTop,D2=l1+c,XZ=l1+o-c;if(r.top<D2){let q6=v1(Math.max(0,r.top-c));if(hJ(r,q6,o,c))V.current=v;return}if(r.top+r.height>XZ){let q6=v1(Math.max(0,r.top+r.height-o+c));if(hJ(r,q6,o,c))V.current=v;return}V.current=v},[_,_.selection.focus.offset,_.selection.focus.regionId,A1,g1,S4,v1,u0]),k0(()=>{O1("viewport")},[h1.liveRanges,_,g1,V1.end.regionId,V1.end.offset,V1.start.regionId,V1.start.offset,v4.block?.blockId,j,g,g4,O1,u0]),k0(()=>{if(!u)return;let P=null,w=window,v=()=>{O1("viewport"),P=w.requestAnimationFrame(v)};return P=w.requestAnimationFrame(v),()=>{if(P!==null)w.cancelAnimationFrame(P)}},[u,O1]),k0(()=>{O1("content")},[XM,O1]),k0(()=>{let P=i1.current;if(!P)return;let w=(v)=>{AM(P,v)};return P.addEventListener("wheel",w,{passive:!1}),()=>{P.removeEventListener("wheel",w)}},[AM]);let eJ=$?`documint ${$}`:"documint",$Z=()=>{let P=L1.leaf,w=P??I1.leaf??o1.leaf,v=!P&&Boolean(I1.leaf),c=i1.current?.getBoundingClientRect()??null,r=w?.kind==="thread"?{...w,thread:h1.threads[w.threadIndex]??null}:null,o=w?.kind==="comment"?{animateInitialComment:!1,link:w.link,thread:w.thread,threadIndex:w.threadIndex}:r?.thread?{animateInitialComment:r.animateInitialComment??!1,link:null,thread:r.thread,threadIndex:r.threadIndex}:null,l1=o?.thread&&A0(o.thread)?"resolved":"default";return{annotationThreadLeaf:o,visibleLeaf:w,visibleLeafAnchor:w?{container:Q.current,isSelection:v,left:(c?.left??0)+w.left,onPointerEnter:P?L1.leafHandlers.onPointerEnter:void 0,onPointerLeave:P?L1.leafHandlers.onPointerLeave:void 0,top:(c?.top??0)+w.top-m4+(v?gG:0)}:void 0,visibleLeafClassName:w?.kind==="link"?"documint-link-leaf":void 0,visibleLeafStatus:l1}},{annotationThreadLeaf:p1,visibleLeaf:_1,visibleLeafAnchor:KM,visibleLeafClassName:MZ,visibleLeafStatus:JZ}=$Z(),ZZ=(()=>{if(!_1)return null;switch(_1.kind){case"insertion":return Y1(a7,{onInsert:(P)=>{i(Y2(e(),P))},onInsertTable:(P)=>{i(r8(e(),P))}},void 0,!1,void 0,this);case"table":return Y1(e7,{canDeleteColumn:_1.columnCount>1,canDeleteRow:_1.rowCount>1,onDeleteColumn:()=>{i(x8(e()))},onDeleteRow:()=>{i(a8(e()))},onDeleteTable:()=>{i(s8(e()))},onInsertColumn:(P)=>{i(c8(e(),P))},onInsertRow:(P)=>{i(d8(e(),P))}},void 0,!1,void 0,this);case"link":return Y1(n7,{canEdit:B2,onDelete:()=>{let P=n8(e(),_1.regionId,_1.startOffset,_1.endOffset);if(P)i(P)},onSave:(P)=>{let w=o8(e(),_1.regionId,_1.startOffset,_1.endOffset,P);if(w)i(w)},title:_1.title,url:_1.url},void 0,!1,void 0,this);case"create":return Y1(k$,{activeMarks:_1.activeMarks,canEdit:B2,link:null,mode:"create",onCreateThread:(P)=>{let w=e(),v=a2(w).comments.length,c=e8(w,_1.selection,P.trim());if(!c)return;i(c),I1.promoteLeafToThread(v,!0)},onToggleBold:()=>{i(M4(e()))},onToggleItalic:()=>{i(J4(e()))},onToggleStrikethrough:()=>{i(Z4(e()))},onToggleUnderline:()=>{i(X4(e()))}},void 0,!1,void 0,this);default:return p1?Y1(k$,{animateInitialComment:p1.animateInitialComment,canEdit:B2,link:p1.link,mode:"thread",onDeleteComment:(P)=>{i(J$(e(),p1.threadIndex,P))},onDeleteThread:()=>{i(Z$(e(),p1.threadIndex))},onEditComment:(P,w)=>{i(M$(e(),p1.threadIndex,P,w))},onReply:(P)=>{i($$(e(),p1.threadIndex,P))},onToggleResolved:()=>{i(X$(e(),p1.threadIndex,!A0(p1.thread)))},thread:p1.thread},void 0,!1,void 0,this):null}})();return Y1("section",{className:eJ,"data-active-block":z.activeBlockType??"","data-active-comment-thread":z.activeCommentThreadIndex??"","data-active-span":z.activeSpanKind??"",ref:Q,style:{...f,height:"100%",minHeight:0},children:[Y1("style",{children:vJ},void 0,!1,void 0,this),Y1("div",{...rJ,className:"documint-scroll-container",style:{height:"100%",minHeight:0},children:[Y1("textarea",{...F2.inputHandlers,ref:N,autoCapitalize:"sentences",className:"documint-input",spellCheck:!1,tabIndex:-1},void 0,!1,void 0,this),Y1(Q7,{insetX:j.paddingX,insetY:j.paddingY,...K6.presenceOverlayProps},void 0,!1,void 0,this),Y1("div",{...J1.scrollContent,className:"documint-scroll-content",children:[Y1("canvas",{...F2.canvasHandlers,"aria-label":"Documint editor",className:"documint-content-canvas",style:{cursor:L1.cursor},onPointerCancel:dJ,onPointerDown:aJ,onPointerLeave:sJ,onPointerMove:iJ,onPointerUp:oJ,onClick:nJ,onDoubleClick:tJ,ref:K,tabIndex:0},void 0,!1,void 0,this),Y1("canvas",{"aria-hidden":"true",className:"documint-overlay-canvas",ref:q},void 0,!1,void 0,this),I1.handles?Y1(IG,{children:[Y1("div",{"aria-hidden":"true",className:"documint-selection-handle documint-selection-handle-start",style:{left:`${I1.handles.start.left}px`,top:`${I1.handles.start.top}px`},...I1.startHandleProps,children:Y1("span",{className:"documint-selection-handle-knob"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y1("div",{"aria-hidden":"true",className:"documint-selection-handle documint-selection-handle-end",style:{left:`${I1.handles.end.left}px`,top:`${I1.handles.end.top}px`},...I1.endHandleProps,children:Y1("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,_1&&KM?Y1(s7,{anchor:KM,className:MZ,status:JZ,children:ZZ},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),!R?Y1("div",{className:"documint-fallback",children:Y1(A6,{blocks:T.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 hG($,M){return $?.layoutWidth===M.layoutWidth&&$.regionId===M.regionId&&$.offset===M.offset&&$.scrollContentHeight===M.scrollContentHeight&&$.viewportHeight===M.viewportHeight}function hJ($,M,J,Z){return $.top>=M+Z&&$.top+$.height<=M+J-Z}function IJ($,M){let J=new Map($.documentIndex.regions.map((K,q)=>[K.id,q])),Z=Y6(J,$.selection.anchor.regionId,$.selection.anchor.offset),X=Y6(J,$.selection.focus.regionId,$.selection.focus.offset),[A,Y]=Z<=X?[Z,X]:[X,Z],Q=Z===X;for(let K of M){let q=Y6(J,K.regionId,K.startOffset),N=Y6(J,K.regionId,K.endOffset);if(Q){if(A>=q&&A<=N)return K.threadIndex;continue}if(Math.max(A,q)<Math.min(Y,N))return K.threadIndex}return null}function Y6($,M,J){return($.get(M)??-1)*1e6+J}export{zJ as mintTheme,OJ as midnightTheme,f4 as lightTheme,v$ as defaultKeybindings,u4 as darkTheme,pJ as Documint};
|