documint 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +24 -3
- package/dist/index.js +35 -35
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import{useEffect as B2,useEffectEvent as
|
|
2
|
-
`);return{id:
|
|
3
|
-
`);return{align:$.align??[],id:
|
|
4
|
-
`;case"image":return M.alt??"";case"inlineCode":return M.code;case"link":return
|
|
5
|
-
`);case"table":return M.rows.map((
|
|
1
|
+
import{useEffect as B2,useEffectEvent as F2,useLayoutEffect as OV,useMemo as $1,useRef as L1,useState as H$}from"react";function H2($){let M=N0($.children);return{children:$.children,id:q0($.path,"paragraph",M),plainText:M,type:"paragraph"}}function r($){return H2({children:j$(void 0,$.text)})}function s4($){let M=N0($.children);return{children:$.children,depth:$.depth,id:q0($.path,"heading",`${$.depth}:${M}`),plainText:M,type:"heading"}}function M1($){return s4({children:j$(void 0,$.text),depth:$.depth})}function H0($){let M=$.marks??[];return{id:q0($.path,"text",`${$.text}:${M.join(",")}`),marks:M,text:$.text,type:"text"}}function P2($={}){return{id:q0($.path,"break","break"),type:"break"}}function S1($){return{code:$.code,id:q0($.path,"inlineCode",$.code),type:"inlineCode"}}function u1($){return{children:$.children,id:q0($.path,"link",`${$.url}:${N0($.children)}`),title:$.title??null,type:"link",url:$.url}}function o4($){let M=$.alt??null,J=$.width??null;return{alt:M,id:q0($.path,"image",`${$.url}:${J??""}:${M??""}`),title:$.title??null,type:"image",url:$.url,width:J}}function n4($){return{id:q0($.path,"unsupported",$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}function d0($){let M=h1($.children);return{checked:$.checked??null,children:$.children,id:q0($.path,"listItem",M),plainText:M,spread:$.spread??!1,type:"listItem"}}function P1($){let M=$.items.map((J)=>J.plainText).join(`
|
|
2
|
+
`);return{id:q0($.path,"list",`${String($.ordered)}:${M}`),items:$.items,ordered:$.ordered,plainText:M,spread:$.spread??!1,start:$.start??null,type:"list"}}function P0($){let M=h1($.children);return{children:$.children,id:q0($.path,"blockquote",M),plainText:M,type:"blockquote"}}function P8($){return{id:q0($.path,"code",`${$.language??""}:${$.source}`),language:$.language??null,meta:$.meta??null,plainText:$.source,source:$.source,type:"code"}}function J1($){let M=N0($.children);return{children:$.children,id:q0($.path,"tableCell",M),plainText:M}}function v1($){return{cells:$.cells,id:q0($.path,"tableRow",String($.cells.length))}}function z1($){let M=$.rows.map((J)=>J.cells.map((Z)=>Z.plainText).join(" | ")).join(`
|
|
3
|
+
`);return{align:$.align??[],id:q0($.path,"table",M),plainText:M,rows:$.rows,type:"table"}}function t4(){return{id:"",plainText:"",type:"thematicBreak"}}function e4($){return{id:q0($.path,"unsupported",$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}function C$($){return{attributes:$.attributes,body:$.body,id:q0($.path,"directive",`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"}}function C0($,M){return $.type==="heading"?s4({children:M,depth:$.depth}):H2({children:M})}function E0($,M){return d0({checked:$.checked,children:M,spread:$.spread})}function $0($,M,J={}){return P1({items:M,ordered:J.ordered??$.ordered,spread:J.spread??$.spread,start:J.start??$.start})}function S0($,M){return z1({align:$.align,rows:M})}function $5($,M){return P8({language:$.language,meta:$.meta,source:M})}function M5($,M){return e4({originalType:$.originalType,source:M})}function j$($,M){return M.length>0?[H0({path:$?`${$}.children.0`:void 0,text:M})]:[]}function q0($,M,J){return $?Y0(M,$,J):""}function g1($,M=[],J){return{blocks:$.map((Z,X)=>z8(Z,X)),comments:M,frontMatter:J}}function I1($,M,J,Z){let X=Z.map((Q,K)=>z8(Q,M+K)),D=$.blocks.slice(M+J),Y=Z.length===J?D:D.map((Q,K)=>z8(Q,M+X.length+K));return{blocks:[...$.blocks.slice(0,M),...X,...Y],comments:$.comments,frontMatter:$.frontMatter}}function L$($,M,J,Z){return{blocks:$.blocks,comments:[...$.comments.slice(0,M),...Z,...$.comments.slice(M+J)],frontMatter:$.frontMatter}}function N0($){return $.map((M)=>{switch(M.type){case"break":return`
|
|
4
|
+
`;case"image":return M.alt??"";case"inlineCode":return M.code;case"link":return N0(M.children);case"text":return M.text;case"unsupported":return M.source}}).join("")}function h1($){return $.map((M)=>{switch(M.type){case"blockquote":case"listItem":return h1(M.children);case"code":return M.source;case"directive":return M.body;case"heading":case"paragraph":return N0(M.children);case"list":return M.items.map((J)=>J.plainText).join(`
|
|
5
|
+
`);case"table":return M.rows.map((J)=>J.cells.map((Z)=>Z.plainText).join(" | ")).join(`
|
|
6
6
|
`);case"thematicBreak":return"";case"unsupported":return M.source}}).join(`
|
|
7
|
-
`).trim()}function
|
|
8
|
-
`);return{id:
|
|
9
|
-
`);return{align:$.align,id:X0("table",M,J),plainText:J,rows:Z,type:"table"}}case"thematicBreak":return{id:X0("thematicBreak",M,"thematic-break"),plainText:"",type:"thematicBreak"};case"unsupported":return{id:X0("unsupported",M,$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}}function QJ($,M){return{cells:$.cells.map((Z,J)=>{let X=Z.children.map((Q,K)=>Z5(Q,`${M}.cells.${J}.children.${K}`)),Y=A0(X);return{children:X,id:X0("tableCell",`${M}.cells.${J}`,Y),plainText:Y}}),id:X0("tableRow",M,String($.cells.length))}}function Z5($,M){switch($.type){case"break":return{id:X0("break",M,"break"),type:"break"};case"image":return{alt:$.alt,id:X0("image",M,`${$.url}:${$.width??""}:${$.alt??""}`),title:$.title,type:"image",url:$.url,width:$.width};case"inlineCode":return{code:$.code,id:X0("inlineCode",M,$.code),type:"inlineCode"};case"link":{let Z=$.children.map((X,Y)=>Z5(X,`${M}.children.${Y}`)),J=A0(Z);return{children:Z,id:X0("link",M,`${$.url}:${J}`),title:$.title,type:"link",url:$.url}}case"text":return{id:X0("text",M,`${$.text}:${$.marks.join(",")}`),marks:$.marks,text:$.text,type:"text"};case"unsupported":return{id:X0("unsupported",M,$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}}function H2($){return $.map((M)=>{switch(M.type){case"blockquote":return{...M,children:H2(M.children)};case"heading":case"paragraph":return R0(M,P8(M.children));case"list":return{...M,items:M.items.map((Z)=>({...Z,children:H2(Z.children)}))};case"listItem":return{...M,children:H2(M.children)};case"table":return h0(M,M.rows.map((Z)=>({...Z,cells:Z.cells.map((J)=>({...J,children:P8(J.children)}))})));default:return M}})}function P8($){let M=[...$];for(let Z=M.length-1;Z>=0;Z-=1){let J=M[Z];if(J.type==="text"){let X=J.text.replace(/[ \t]+$/u,"");if(X.length===J.text.length)return M;if(X.length===0){M.splice(Z,1);continue}return M[Z]={...J,text:X},M}if(J.type==="link"){let X=P8(J.children);if(X.length===J.children.length&&X.every((Y,Q)=>Y===J.children[Q]))return M;if(X.length===0){M.splice(Z,1);continue}return M[Z]={...J,children:X},M}return M}return M}function X0($,M,Z){let J=2166136261;for(let X of`${$}:${M}:${Z}`)J^=X.charCodeAt(0),J=Math.imul(J,16777619);return`${$}-${(J>>>0).toString(36)}`}function P2($,M){z8($.blocks,M,y$(),W$())}function T$($,M){z8($,M,y$(),W$())}function z8($,M,Z,J){for(let[X,Y]of $.entries()){if(Z.stopped)return;let Q=`${J.pathPrefix}.${X}`,K={blockAncestors:J.blockAncestors,depth:J.depth,parentBlock:J.parentBlock,path:Q},q=M.enterBlock?.(Y,K);if(I1(q,Z))return;if(q!=="skip")switch(Y.type){case"list":z$(Y.items,Y,M,Z,J,Q);break;case"blockquote":case"listItem":z$(Y.children,Y,M,Z,J,Q);break;case"heading":case"paragraph":T8(Y.children,M,Z,{block:Y,blockAncestors:[...J.blockAncestors,Y],inlineAncestors:[],parentInline:null,pathPrefix:`${Q}.children`});break;case"table":qJ(Y,M,Z,{blockAncestors:[...J.blockAncestors,Y],pathPrefix:Q});break;case"code":case"directive":case"thematicBreak":case"unsupported":break}if(Z.stopped)return;if(I1(M.leaveBlock?.(Y,K),Z))return}}function T8($,M,Z,J){for(let[X,Y]of $.entries()){if(Z.stopped)return;let Q=`${J.pathPrefix}.${X}`,K={block:J.block,blockAncestors:J.blockAncestors,inlineAncestors:J.inlineAncestors,parentInline:J.parentInline,path:Q},q=M.enterInline?.(Y,K);if(I1(q,Z))return;if(q!=="skip"){if(Y.type==="link")KJ(Y.children,Y,M,Z,J,Q)}if(Z.stopped)return;if(I1(M.leaveInline?.(Y,K),Z))return}}function y$(){return{stopped:!1}}function W$(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function z$($,M,Z,J,X,Y){z8($,Z,J,{blockAncestors:[...X.blockAncestors,M],depth:X.depth+1,parentBlock:M,pathPrefix:`${Y}.children`})}function KJ($,M,Z,J,X,Y){T8($,Z,J,{block:X.block,blockAncestors:X.blockAncestors,inlineAncestors:[...X.inlineAncestors,M],parentInline:M,pathPrefix:`${Y}.children`})}function qJ($,M,Z,J){for(let[X,Y]of $.rows.entries())for(let[Q,K]of Y.cells.entries()){if(Z.stopped)return;let q=`${J.pathPrefix}.rows.${X}.cells.${Q}`,U={blockAncestors:J.blockAncestors,cellIndex:Q,path:q,row:Y,rowIndex:X,table:$},N=M.enterTableCell?.(K,U);if(I1(N,Z))return;if(N!=="skip")T8(K.children,M,Z,{block:$,blockAncestors:J.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${q}.children`});if(Z.stopped)return;if(I1(M.leaveTableCell?.(K,U),Z))return}}function I1($,M){if($!=="stop")return!1;return M.stopped=!0,!0}var y8="text";function W8($){return $==="text"||$==="code"||$==="tableCell"}function V8($){return $===y8?void 0:$}function w$($){switch($){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function J5($){let M=[];return P2($,{enterBlock(Z){switch(Z.type){case"heading":case"paragraph":M.push({containerKind:"text",containerOrdinal:M.length,id:Z.id,text:A0(Z.children)});break;case"code":M.push({containerKind:"code",containerOrdinal:M.length,id:Z.id,text:Z.source});break}},enterTableCell(Z){M.push({containerKind:"tableCell",containerOrdinal:M.length,id:Z.id,text:A0(Z.children)})}}),M}function w8($,M,Z){return{prefix:$.slice(Math.max(0,M-V$),M),suffix:$.slice(Z,Math.min($.length,Z+V$))}}function z2($,M,Z){let J=L0(M,0,$.text.length),X=L0(Z,J,$.text.length),{prefix:Y,suffix:Q}=w8($.text,J,X);return{kind:V8($.containerKind),prefix:Y||void 0,suffix:Q||void 0}}function T2($,M,Z){let J=L0(M,0,$.text.length),X=L0(Z,J,$.text.length);return $.text.slice(J,X)}function g0($,M){if(M.length===0)return[];let Z=[],J=0;while(J<=$.length){let X=$.indexOf(M,J);if(X===-1)break;Z.push(X),J=X+Math.max(1,M.length)}return Z}function p1($,M,Z){if(M.length===0||Z.length===0)return[];let J=[];for(let X of g0($,M)){let Y=X+M.length,Q=$.indexOf(Z,Y);if(Q!==-1)J.push({startOffset:Y,endOffset:Q})}return J}function O8($,M,Z){if(!M)return!1;return $.slice(Math.max(0,Z-M.length),Z)===M}function E8($,M,Z){if(!M)return!1;return $.slice(Z,Z+M.length)===M}var V$=24;function L0($,M,Z){return Math.min(Math.max($,M),Z)}var O$=48,E$=64,UJ=32;function y2($,M){let Z=$.anchor.kind??y8,J=J5(M).filter((Q)=>Q.containerKind===Z),X=NJ($,J);if(X.length>0)return C$($,X,null);let Y=AJ($,J);if(Y.length>0)return C$($,Y,"repaired");return{match:null,repair:null,status:"stale"}}function NJ($,M){let Z=[],J=$.quote;if(J.length===0)return Z;for(let X of M)for(let Y of g0(X.text,J))Z.push({container:X,endOffset:Y+J.length,score:_J($,X,Y),startOffset:Y});return Z.sort((X,Y)=>Y.score-X.score),Z}function AJ($,M){let Z=[];for(let J of M)Z.push(...GJ($,J));return Z.sort((J,X)=>X.score-J.score),Z}function GJ($,M){let Z=[],J=$.quote.length,X=M.text,Y=$.anchor.prefix??"",Q=$.anchor.suffix??"";if(Y.length>0&&Q.length>0){for(let K of p1(X,Y,Q))Z.push({container:M,endOffset:K.endOffset,score:C8($,M,K.startOffset,K.endOffset,J),startOffset:K.startOffset});return Z}if(Y.length>0){for(let K of g0(X,Y)){let q=K+Y.length,U=L0(q+J,q,X.length);Z.push({container:M,endOffset:U,score:C8($,M,q,U,J),startOffset:q})}return Z}if(Q.length>0)for(let K of g0(X,Q)){let q=K,U=L0(q-J,0,q);Z.push({container:M,endOffset:q,score:C8($,M,U,q,J),startOffset:U})}return Z}function C$($,M,Z){let[J,X]=M;if(!J)return{match:null,repair:null,status:"stale"};if(X&&J.score===X.score)return{match:null,repair:null,status:"ambiguous"};let Y=z2(J.container,J.startOffset,J.endOffset),Q=T2(J.container,J.startOffset,J.endOffset),K=Z??(Q===$.quote&&(Y.prefix??"")===($.anchor.prefix??"")&&(Y.suffix??"")===($.anchor.suffix??"")?"matched":"repaired");return{match:BJ(J.container,J.startOffset,J.endOffset),repair:{anchor:Y,quote:Q},status:K}}function BJ($,M,Z){return{containerId:$.id,containerKind:$.containerKind,containerOrdinal:$.containerOrdinal,endOffset:Z,startOffset:M}}function _J($,M,Z){let J=0;if(O8(M.text,$.anchor.prefix,Z))J+=O$;if(E8(M.text,$.anchor.suffix,Z+$.quote.length))J+=O$;return J}function C8($,M,Z,J,X){let Y=0;if(O8(M.text,$.anchor.prefix,Z))Y+=E$;if(E8(M.text,$.anchor.suffix,J))Y+=E$;if(Y+=Math.max(0,UJ-Math.abs(X-(J-Z))),$.quote.length>0){let Q=M.text.slice(Z,J);if(Q.length>0)Y+=FJ($.quote,Q),Y+=bJ($.quote,Q)}return Y}function FJ($,M){let Z=0;while(Z<$.length&&Z<M.length&&$[Z]===M[Z])Z+=1;return Z}function bJ($,M){let Z=0;while(Z<$.length&&Z<M.length&&$[$.length-1-Z]===M[M.length-1-Z])Z+=1;return Z}function j8($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$,Z=HJ(M.anchor),J=typeof M.quote==="string"?M.quote:null,X=Array.isArray(M.comments)?M.comments.flatMap((Y)=>{let Q=DJ(Y);return Q?[Q]:[]}):[];if(!Z||!J||X.length===0)return null;return{quote:J,anchor:Z,comments:X,resolvedAt:typeof M.resolvedAt==="string"?M.resolvedAt:void 0}}function DJ($){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 HJ($){if(!$||typeof $!=="object"||Array.isArray($))return null;let{kind:M,prefix:Z,suffix:J}=$;if("kind"in $&&!W8(M)||"prefix"in $&&typeof Z!=="string"||"suffix"in $&&typeof J!=="string")return null;return{kind:W8(M)?V8(M):void 0,prefix:typeof Z==="string"?Z:void 0,suffix:typeof J==="string"?J:void 0}}function R8($){let M=$.createdAt??new Date().toISOString();return{comments:[j$({body:$.body,updatedAt:M})],quote:$.quote,anchor:$.anchor}}function L8($,M){let Z=j$(M);return{...$,comments:[...$.comments,Z]}}function k8($,M,Z,J=new Date().toISOString()){let X=Z.trim();if(X.length===0)return $;let Y=!1,Q=$.comments.map((K,q)=>{if(q!==M||K.body===X)return K;return Y=!0,{...K,body:X,updatedAt:J}});if(!Y)return $;return{...$,comments:Q}}function f8($,M){let Z=$.comments.filter((J,X)=>X!==M);if(Z.length===$.comments.length)return $;if(Z.length===0)return null;return{...$,comments:Z}}function m8($,M,Z=new Date().toISOString()){if(Z1($)===M)return $;return{...$,resolvedAt:M?Z:void 0}}function Z1($){return $.resolvedAt!=null}function S8($){return $.filter((M)=>Z1(M)).length}function u8($){if($.comments.length===0)return null;return $.comments.reduce((M,Z)=>Z.updatedAt>M?Z.updatedAt:M,$.comments[0].updatedAt)}function j$($){let M=$.updatedAt??new Date().toISOString();return{body:$.body,updatedAt:M}}function R$($){let M=new Set;return P2($,{enterInline(Z){if(Z.type==="image")M.add(Z.url)}}),[...M]}function l1($,M){let Z=null;return PJ($,{enterBlock(J){if(J.id===M)return Z=J,"stop"}}),Z}function PJ($,M){if(Array.isArray($)){T$($,M);return}P2($,M)}function T1(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function L$($,M,Z){return W2($.preparedText,M,Z,256)}function k$($,M,Z){return W2($.measuredLines,M,Z,512)}function f$($,M,Z){return W2($.lineBoundaries,M,Z,1024)}function m$($,M,Z){return W2($.measuredContainerHeights,M,Z,1024)}function S$($,M){let Z=$.graphemeWidths.get(M);if(Z)return Z;let J=new Map;return W2($.graphemeWidths,M,J,64),J}function u$($,M,Z){return $.viewportPlans.get(M)?.get(Z)??null}function v$($,M,Z,J){let X=$.viewportPlans.get(M)??new Map;return X.set(Z,J),$.viewportPlans.set(M,X),J}function W2($,M,Z,J){if($.has(M))$.delete(M);if($.set(M,Z),$.size>J){let X=$.keys().next().value;if(X!==void 0)$.delete(X)}return Z}var zJ=["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"],TJ=["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 yJ($){if($<=255)return zJ[$];if(1424<=$&&$<=1524)return"R";if(1536<=$&&$<=1791)return TJ[$&255];if(1792<=$&&$<=2220)return"AL";return"L"}function WJ($){let M=$.length;if(M===0)return null;let Z=Array(M),J=0;for(let U=0;U<M;U++){let N=yJ($.charCodeAt(U));if(N==="R"||N==="AL"||N==="AN")J++;Z[U]=N}if(J===0)return null;let X=M/J<0.3?0:1,Y=new Int8Array(M);for(let U=0;U<M;U++)Y[U]=X;let Q=X&1?"R":"L",K=Q,q=K;for(let U=0;U<M;U++)if(Z[U]==="NSM")Z[U]=q;else q=Z[U];q=K;for(let U=0;U<M;U++){let N=Z[U];if(N==="EN")Z[U]=q==="AL"?"AN":"EN";else if(N==="R"||N==="L"||N==="AL")q=N}for(let U=0;U<M;U++)if(Z[U]==="AL")Z[U]="R";for(let U=1;U<M-1;U++){if(Z[U]==="ES"&&Z[U-1]==="EN"&&Z[U+1]==="EN")Z[U]="EN";if(Z[U]==="CS"&&(Z[U-1]==="EN"||Z[U-1]==="AN")&&Z[U+1]===Z[U-1])Z[U]=Z[U-1]}for(let U=0;U<M;U++){if(Z[U]!=="EN")continue;let N;for(N=U-1;N>=0&&Z[N]==="ET";N--)Z[N]="EN";for(N=U+1;N<M&&Z[N]==="ET";N++)Z[N]="EN"}for(let U=0;U<M;U++){let N=Z[U];if(N==="WS"||N==="ES"||N==="ET"||N==="CS")Z[U]="ON"}q=K;for(let U=0;U<M;U++){let N=Z[U];if(N==="EN")Z[U]=q==="L"?"L":"EN";else if(N==="R"||N==="L")q=N}for(let U=0;U<M;U++){if(Z[U]!=="ON")continue;let N=U+1;while(N<M&&Z[N]==="ON")N++;let A=U>0?Z[U-1]:K,G=N<M?Z[N]:K,B=A!=="L"?"R":"L";if(B===(G!=="L"?"R":"L"))for(let _=U;_<N;_++)Z[_]=B;U=N-1}for(let U=0;U<M;U++)if(Z[U]==="ON")Z[U]=Q;for(let U=0;U<M;U++){let N=Z[U];if((Y[U]&1)===0){if(N==="R")Y[U]++;else if(N==="AN"||N==="EN")Y[U]+=2}else if(N==="L"||N==="AN"||N==="EN")Y[U]++}return Y}function h$($,M){let Z=WJ($);if(Z===null)return null;let J=new Int8Array(M.length);for(let X=0;X<M.length;X++)J[X]=Z[M[X]];return J}var VJ=/[ \t\n\r\f]+/g,wJ=/[\t\n\r\f]| {2,}|^ | $/;function OJ($){let M=$??"normal";return M==="pre-wrap"?{mode:M,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:M,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function EJ($){if(!wJ.test($))return $;let M=$.replace(VJ," ");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 CJ($){if(!/[\r\f]/.test($))return $.replace(/\r\n/g,`
|
|
7
|
+
`).trim()}function z8($,M){return J5($,`root.${M}`)}function J5($,M){switch($.type){case"blockquote":{let J=$.children.map((X,D)=>J5(X,`${M}.children.${D}`)),Z=h1(J);return{children:J,id:Y0("blockquote",M,Z),plainText:Z,type:"blockquote"}}case"code":return{id:Y0("code",M,`${$.language??""}:${$.source}`),language:$.language,meta:$.meta,plainText:$.source,source:$.source,type:"code"};case"directive":return{attributes:$.attributes,body:$.body,id:Y0("directive",M,`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"};case"heading":{let J=$.children.map((X,D)=>Z5(X,`${M}.children.${D}`)),Z=N0(J);return{children:J,depth:$.depth,id:Y0("heading",M,`${$.depth}:${Z}`),plainText:Z,type:"heading"}}case"list":{let J=$.items.map((X,D)=>J5(X,`${M}.children.${D}`)),Z=J.map((X)=>X.plainText).join(`
|
|
8
|
+
`);return{id:Y0("list",M,`${String($.ordered)}:${Z}`),items:J,ordered:$.ordered,plainText:Z,spread:$.spread,start:$.start,type:"list"}}case"listItem":{let J=$.children.map((X,D)=>J5(X,`${M}.children.${D}`)),Z=h1(J);return{checked:$.checked,children:J,id:Y0("listItem",M,Z),plainText:Z,spread:$.spread,type:"listItem"}}case"paragraph":{let J=$.children.map((X,D)=>Z5(X,`${M}.children.${D}`)),Z=N0(J);return{children:J,id:Y0("paragraph",M,Z),plainText:Z,type:"paragraph"}}case"table":{let J=$.rows.map((X,D)=>EZ(X,`${M}.rows.${D}`)),Z=J.map((X)=>X.cells.map((D)=>D.plainText).join(" | ")).join(`
|
|
9
|
+
`);return{align:$.align,id:Y0("table",M,Z),plainText:Z,rows:J,type:"table"}}case"thematicBreak":return{id:Y0("thematicBreak",M,"thematic-break"),plainText:"",type:"thematicBreak"};case"unsupported":return{id:Y0("unsupported",M,$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}}function EZ($,M){return{cells:$.cells.map((J,Z)=>{let X=J.children.map((Y,Q)=>Z5(Y,`${M}.cells.${Z}.children.${Q}`)),D=N0(X);return{children:X,id:Y0("tableCell",`${M}.cells.${Z}`,D),plainText:D}}),id:Y0("tableRow",M,String($.cells.length))}}function Z5($,M){switch($.type){case"break":return{id:Y0("break",M,"break"),type:"break"};case"image":return{alt:$.alt,id:Y0("image",M,`${$.url}:${$.width??""}:${$.alt??""}`),title:$.title,type:"image",url:$.url,width:$.width};case"inlineCode":return{code:$.code,id:Y0("inlineCode",M,$.code),type:"inlineCode"};case"link":{let J=$.children.map((X,D)=>Z5(X,`${M}.children.${D}`)),Z=N0(J);return{children:J,id:Y0("link",M,`${$.url}:${Z}`),title:$.title,type:"link",url:$.url}}case"text":return{id:Y0("text",M,`${$.text}:${$.marks.join(",")}`),marks:$.marks,text:$.text,type:"text"};case"unsupported":return{id:Y0("unsupported",M,$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}}function z2($){return $.map((M)=>{switch(M.type){case"blockquote":return{...M,children:z2(M.children)};case"heading":case"paragraph":return C0(M,W8(M.children));case"list":return{...M,items:M.items.map((J)=>({...J,children:z2(J.children)}))};case"listItem":return{...M,children:z2(M.children)};case"table":return S0(M,M.rows.map((J)=>({...J,cells:J.cells.map((Z)=>({...Z,children:W8(Z.children)}))})));default:return M}})}function W8($){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=W8(Z.children);if(X.length===Z.children.length&&X.every((D,Y)=>D===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 Y0($,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){E8($.blocks,M,f$(),m$())}function k$($,M){E8($,M,f$(),m$())}function E8($,M,J,Z){for(let[X,D]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?.(D,Q);if(p1(K,J))return;if(K!=="skip")switch(D.type){case"list":R$(D.items,D,M,J,Z,Y);break;case"blockquote":case"listItem":R$(D.children,D,M,J,Z,Y);break;case"heading":case"paragraph":T8(D.children,M,J,{block:D,blockAncestors:[...Z.blockAncestors,D],inlineAncestors:[],parentInline:null,pathPrefix:`${Y}.children`});break;case"table":yZ(D,M,J,{blockAncestors:[...Z.blockAncestors,D],pathPrefix:Y});break;case"code":case"directive":case"thematicBreak":case"unsupported":break}if(J.stopped)return;if(p1(M.leaveBlock?.(D,Q),J))return}}function T8($,M,J,Z){for(let[X,D]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?.(D,Q);if(p1(K,J))return;if(K!=="skip"){if(D.type==="link")TZ(D.children,D,M,J,Z,Y)}if(J.stopped)return;if(p1(M.leaveInline?.(D,Q),J))return}}function f$(){return{stopped:!1}}function m$(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function R$($,M,J,Z,X,D){E8($,J,Z,{blockAncestors:[...X.blockAncestors,M],depth:X.depth+1,parentBlock:M,pathPrefix:`${D}.children`})}function TZ($,M,J,Z,X,D){T8($,J,Z,{block:X.block,blockAncestors:X.blockAncestors,inlineAncestors:[...X.inlineAncestors,M],parentInline:M,pathPrefix:`${D}.children`})}function yZ($,M,J,Z){for(let[X,D]of $.rows.entries())for(let[Y,Q]of D.cells.entries()){if(J.stopped)return;let K=`${Z.pathPrefix}.rows.${X}.cells.${Y}`,q={blockAncestors:Z.blockAncestors,cellIndex:Y,path:K,row:D,rowIndex:X,table:$},U=M.enterTableCell?.(Q,q);if(p1(U,J))return;if(U!=="skip")T8(Q.children,M,J,{block:$,blockAncestors:Z.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${K}.children`});if(J.stopped)return;if(p1(M.leaveTableCell?.(Q,q),J))return}}function p1($,M){if($!=="stop")return!1;return M.stopped=!0,!0}var y8="text";function w8($){return $==="text"||$==="code"||$==="tableCell"}function O8($){return $===y8?void 0:$}function u$($){switch($){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function X5($){let M=[];return W2($,{enterBlock(J){switch(J.type){case"heading":case"paragraph":M.push({containerKind:"text",containerOrdinal:M.length,id:J.id,text:N0(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:N0(J.children)})}}),M}function C8($,M,J){return{prefix:$.slice(Math.max(0,M-S$),M),suffix:$.slice(J,Math.min($.length,J+S$))}}function E2($,M,J){let Z=j0(M,0,$.text.length),X=j0(J,Z,$.text.length),{prefix:D,suffix:Y}=C8($.text,Z,X);return{kind:O8($.containerKind),prefix:D||void 0,suffix:Y||void 0}}function T2($,M,J){let Z=j0(M,0,$.text.length),X=j0(J,Z,$.text.length);return $.text.slice(Z,X)}function u0($,M){if(M.length===0)return[];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}function l1($,M,J){if(M.length===0||J.length===0)return[];let Z=[];for(let X of u0($,M)){let D=X+M.length,Y=$.indexOf(J,D);if(Y!==-1)Z.push({startOffset:D,endOffset:Y})}return Z}function j8($,M,J){if(!M)return!1;return $.slice(Math.max(0,J-M.length),J)===M}function L8($,M,J){if(!M)return!1;return $.slice(J,J+M.length)===M}var S$=24;function j0($,M,J){return Math.min(Math.max($,M),J)}var v$=48,h$=64,wZ=32;function y2($,M){let J=$.anchor.kind??y8,Z=X5(M).filter((Y)=>Y.containerKind===J),X=OZ($,Z);if(X.length>0)return g$($,X,null);let D=CZ($,Z);if(D.length>0)return g$($,D,"repaired");return{match:null,repair:null,status:"stale"}}function OZ($,M){let J=[],Z=$.quote;if(Z.length===0)return J;for(let X of M)for(let D of u0(X.text,Z))J.push({container:X,endOffset:D+Z.length,score:RZ($,X,D),startOffset:D});return J.sort((X,D)=>D.score-X.score),J}function CZ($,M){let J=[];for(let Z of M)J.push(...jZ($,Z));return J.sort((Z,X)=>X.score-Z.score),J}function jZ($,M){let J=[],Z=$.quote.length,X=M.text,D=$.anchor.prefix??"",Y=$.anchor.suffix??"";if(D.length>0&&Y.length>0){for(let Q of l1(X,D,Y))J.push({container:M,endOffset:Q.endOffset,score:R8($,M,Q.startOffset,Q.endOffset,Z),startOffset:Q.startOffset});return J}if(D.length>0){for(let Q of u0(X,D)){let K=Q+D.length,q=j0(K+Z,K,X.length);J.push({container:M,endOffset:q,score:R8($,M,K,q,Z),startOffset:K})}return J}if(Y.length>0)for(let Q of u0(X,Y)){let K=Q,q=j0(K-Z,0,K);J.push({container:M,endOffset:K,score:R8($,M,q,K,Z),startOffset:q})}return J}function g$($,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 D=E2(Z.container,Z.startOffset,Z.endOffset),Y=T2(Z.container,Z.startOffset,Z.endOffset),Q=J??(Y===$.quote&&(D.prefix??"")===($.anchor.prefix??"")&&(D.suffix??"")===($.anchor.suffix??"")?"matched":"repaired");return{match:LZ(Z.container,Z.startOffset,Z.endOffset),repair:{anchor:D,quote:Y},status:Q}}function LZ($,M,J){return{containerId:$.id,containerKind:$.containerKind,containerOrdinal:$.containerOrdinal,endOffset:J,startOffset:M}}function RZ($,M,J){let Z=0;if(j8(M.text,$.anchor.prefix,J))Z+=v$;if(L8(M.text,$.anchor.suffix,J+$.quote.length))Z+=v$;return Z}function R8($,M,J,Z,X){let D=0;if(j8(M.text,$.anchor.prefix,J))D+=h$;if(L8(M.text,$.anchor.suffix,Z))D+=h$;if(D+=Math.max(0,wZ-Math.abs(X-(Z-J))),$.quote.length>0){let Y=M.text.slice(J,Z);if(Y.length>0)D+=kZ($.quote,Y),D+=fZ($.quote,Y)}return D}function kZ($,M){let J=0;while(J<$.length&&J<M.length&&$[J]===M[J])J+=1;return J}function fZ($,M){let J=0;while(J<$.length&&J<M.length&&$[$.length-1-J]===M[M.length-1-J])J+=1;return J}function k8($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$,J=SZ(M.anchor),Z=typeof M.quote==="string"?M.quote:null,X=Array.isArray(M.comments)?M.comments.flatMap((D)=>{let Y=mZ(D);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 mZ($){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 SZ($){if(!$||typeof $!=="object"||Array.isArray($))return null;let{kind:M,prefix:J,suffix:Z}=$;if("kind"in $&&!w8(M)||"prefix"in $&&typeof J!=="string"||"suffix"in $&&typeof Z!=="string")return null;return{kind:w8(M)?O8(M):void 0,prefix:typeof J==="string"?J:void 0,suffix:typeof Z==="string"?Z:void 0}}function f8($){let M=$.createdAt??new Date().toISOString();return{comments:[I$({body:$.body,updatedAt:M})],quote:$.quote,anchor:$.anchor}}function m8($,M){let J=I$(M);return{...$,comments:[...$.comments,J]}}function S8($,M,J,Z=new Date().toISOString()){let X=J.trim();if(X.length===0)return $;let D=!1,Y=$.comments.map((Q,K)=>{if(K!==M||Q.body===X)return Q;return D=!0,{...Q,body:X,updatedAt:Z}});if(!D)return $;return{...$,comments:Y}}function u8($,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 v8($,M,J=new Date().toISOString()){if(Z1($)===M)return $;return{...$,resolvedAt:M?J:void 0}}function Z1($){return $.resolvedAt!=null}function h8($){return $.filter((M)=>Z1(M)).length}function g8($){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}}function p$($){let M=new Set;return W2($,{enterInline(J){if(J.type==="image")M.add(J.url)}}),[...M]}function r1($,M){let J=null;return uZ($,{enterBlock(Z){if(Z.id===M)return J=Z,"stop"}}),J}function uZ($,M){if(Array.isArray($)){k$($,M);return}W2($,M)}function W1(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function l$($,M,J){return w2($.preparedText,M,J,256)}function r$($,M,J){return w2($.measuredLines,M,J,512)}function c$($,M,J){return w2($.lineBoundaries,M,J,1024)}function x$($,M,J){return w2($.measuredContainerHeights,M,J,1024)}function d$($,M){let J=$.graphemeWidths.get(M);if(J)return J;let Z=new Map;return w2($.graphemeWidths,M,Z,64),Z}function a$($,M,J){return $.viewportPlans.get(M)?.get(J)??null}function i$($,M,J,Z){let X=$.viewportPlans.get(M)??new Map;return X.set(J,Z),$.viewportPlans.set(M,X),Z}function w2($,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 vZ=["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"],hZ=["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 gZ($){if($<=255)return vZ[$];if(1424<=$&&$<=1524)return"R";if(1536<=$&&$<=1791)return hZ[$&255];if(1792<=$&&$<=2220)return"AL";return"L"}function IZ($){let M=$.length;if(M===0)return null;let J=Array(M),Z=0;for(let q=0;q<M;q++){let U=gZ($.charCodeAt(q));if(U==="R"||U==="AL"||U==="AN")Z++;J[q]=U}if(Z===0)return null;let X=M/Z<0.3?0:1,D=new Int8Array(M);for(let q=0;q<M;q++)D[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 U=J[q];if(U==="EN")J[q]=K==="AL"?"AN":"EN";else if(U==="R"||U==="L"||U==="AL")K=U}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 U;for(U=q-1;U>=0&&J[U]==="ET";U--)J[U]="EN";for(U=q+1;U<M&&J[U]==="ET";U++)J[U]="EN"}for(let q=0;q<M;q++){let U=J[q];if(U==="WS"||U==="ES"||U==="ET"||U==="CS")J[q]="ON"}K=Q;for(let q=0;q<M;q++){let U=J[q];if(U==="EN")J[q]=K==="L"?"L":"EN";else if(U==="R"||U==="L")K=U}for(let q=0;q<M;q++){if(J[q]!=="ON")continue;let U=q+1;while(U<M&&J[U]==="ON")U++;let N=q>0?J[q-1]:Q,A=U<M?J[U]:Q,V=N!=="L"?"R":"L";if(V===(A!=="L"?"R":"L"))for(let G=q;G<U;G++)J[G]=V;q=U-1}for(let q=0;q<M;q++)if(J[q]==="ON")J[q]=Y;for(let q=0;q<M;q++){let U=J[q];if((D[q]&1)===0){if(U==="R")D[q]++;else if(U==="AN"||U==="EN")D[q]+=2}else if(U==="L"||U==="AN"||U==="EN")D[q]++}return D}function s$($,M){let J=IZ($);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 pZ=/[ \t\n\r\f]+/g,lZ=/[\t\n\r\f]| {2,}|^ | $/;function rZ($){let M=$??"normal";return M==="pre-wrap"?{mode:M,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:M,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function cZ($){if(!lZ.test($))return $;let M=$.replace(pZ," ");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 xZ($){if(!/[\r\f]/.test($))return $.replace(/\r\n/g,`
|
|
10
10
|
`);return $.replace(/\r\n/g,`
|
|
11
11
|
`).replace(/[\r\f]/g,`
|
|
12
|
-
`)}var
|
|
13
|
-
`)return"hard-break"}if($===" ")return"space";if($===" "||$===" "||$===""||$==="\uFEFF")return"glue";if($==="")return"zero-width-break";if($==="")return"soft-hyphen";return"text"}function i0($){return $.length===1?$[0]:$.join("")}function cJ($,M,Z,J){let X=[],Y=null,Q=[],K=Z,q=!1,U=0;for(let N of $){let A=rJ(N,J),G=A==="text"&&M;if(Y!==null&&A===Y&&G===q){Q.push(N),U+=N.length;continue}if(Y!==null)X.push({text:i0(Q),isWordLike:q,kind:Y,start:K});Y=A,Q=[N],K=Z+U,q=G,U+=N.length}if(Y!==null)X.push({text:i0(Q),isWordLike:q,kind:Y,start:K});return X}function g8($){return $==="space"||$==="preserved-space"||$==="zero-width-break"||$==="hard-break"}var xJ=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function dJ($,M){let Z=$.texts[M];if(Z.startsWith("www."))return!0;return xJ.test(Z)&&M+1<$.len&&$.kinds[M+1]==="text"&&$.texts[M+1]==="//"}function aJ($){return $.includes("?")&&($.includes("://")||$.startsWith("www."))}function iJ($){let M=$.texts.slice(),Z=$.isWordLike.slice(),J=$.kinds.slice(),X=$.starts.slice();for(let Q=0;Q<$.len;Q++){if(J[Q]!=="text"||!dJ($,Q))continue;let K=[M[Q]],q=Q+1;while(q<$.len&&!g8(J[q])){K.push(M[q]),Z[Q]=!0;let U=M[q].includes("?");if(J[q]="text",M[q]="",q++,U)break}M[Q]=i0(K)}let Y=0;for(let Q=0;Q<M.length;Q++){let K=M[Q];if(K.length===0)continue;if(Y!==Q)M[Y]=K,Z[Y]=Z[Q],J[Y]=J[Q],X[Y]=X[Q];Y++}return M.length=Y,Z.length=Y,J.length=Y,X.length=Y,{len:Y,texts:M,isWordLike:Z,kinds:J,starts:X}}function sJ($){let M=[],Z=[],J=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y];if(M.push(Q),Z.push($.isWordLike[Y]),J.push($.kinds[Y]),X.push($.starts[Y]),!aJ(Q))continue;let K=Y+1;if(K>=$.len||g8($.kinds[K]))continue;let q=[],U=$.starts[K],N=K;while(N<$.len&&!g8($.kinds[N]))q.push($.texts[N]),N++;if(q.length>0)M.push(i0(q)),Z.push(!0),J.push("text"),X.push(U),Y=N-1}return{len:M.length,texts:M,isWordLike:Z,kinds:J,starts:X}}var oJ=new Set([":","-","/","×",",",".","+","–","—"]),g$=/^[A-Za-z0-9_]+[,:;]*$/,I$=/[,:;]+$/;function l$($){for(let M of $)if(p$.test(M))return!0;return!1}function I8($){if($.length===0)return!1;for(let M of $){if(p$.test(M)||oJ.has(M))continue;return!1}return!0}function nJ($){let M=[],Z=[],J=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y],K=$.kinds[Y];if(K==="text"&&I8(Q)&&l$(Q)){let q=[Q],U=Y+1;while(U<$.len&&$.kinds[U]==="text"&&I8($.texts[U]))q.push($.texts[U]),U++;M.push(i0(q)),Z.push(!0),J.push("text"),X.push($.starts[Y]),Y=U-1;continue}M.push(Q),Z.push($.isWordLike[Y]),J.push(K),X.push($.starts[Y])}return{len:M.length,texts:M,isWordLike:Z,kinds:J,starts:X}}function tJ($){let M=[],Z=[],J=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y],K=$.kinds[Y],q=$.isWordLike[Y];if(K==="text"&&q&&g$.test(Q)){let U=[Q],N=I$.test(Q),A=Y+1;while(N&&A<$.len&&$.kinds[A]==="text"&&$.isWordLike[A]&&g$.test($.texts[A])){let G=$.texts[A];U.push(G),N=I$.test(G),A++}M.push(i0(U)),Z.push(!0),J.push("text"),X.push($.starts[Y]),Y=A-1;continue}M.push(Q),Z.push(q),J.push(K),X.push($.starts[Y])}return{len:M.length,texts:M,isWordLike:Z,kinds:J,starts:X}}function eJ($){let M=[],Z=[],J=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y];if($.kinds[Y]==="text"&&Q.includes("-")){let K=Q.split("-"),q=K.length>1;for(let U=0;U<K.length;U++){let N=K[U];if(!q)break;if(N.length===0||!l$(N)||!I8(N))q=!1}if(q){let U=0;for(let N=0;N<K.length;N++){let A=K[N],G=N<K.length-1?`${A}-`:A;M.push(G),Z.push(!0),J.push("text"),X.push($.starts[Y]+U),U+=G.length}continue}}M.push(Q),Z.push($.isWordLike[Y]),J.push($.kinds[Y]),X.push($.starts[Y])}return{len:M.length,texts:M,isWordLike:Z,kinds:J,starts:X}}function $X($){let M=[],Z=[],J=[],X=[],Y=0;while(Y<$.len){let Q=[$.texts[Y]],K=$.isWordLike[Y],q=$.kinds[Y],U=$.starts[Y];if(q==="glue"){let N=[Q[0]],A=U;Y++;while(Y<$.len&&$.kinds[Y]==="glue")N.push($.texts[Y]),Y++;let G=i0(N);if(Y<$.len&&$.kinds[Y]==="text")Q[0]=G,Q.push($.texts[Y]),K=$.isWordLike[Y],q="text",U=A,Y++;else{M.push(G),Z.push(!1),J.push("glue"),X.push(A);continue}}else Y++;if(q==="text")while(Y<$.len&&$.kinds[Y]==="glue"){let N=[];while(Y<$.len&&$.kinds[Y]==="glue")N.push($.texts[Y]),Y++;let A=i0(N);if(Y<$.len&&$.kinds[Y]==="text"){Q.push(A,$.texts[Y]),K=K||$.isWordLike[Y],Y++;continue}Q.push(A)}M.push(i0(Q)),Z.push(K),J.push(q),X.push(U)}return{len:M.length,texts:M,isWordLike:Z,kinds:J,starts:X}}function MX($){let M=$.texts.slice(),Z=$.isWordLike.slice(),J=$.kinds.slice(),X=$.starts.slice();for(let Y=0;Y<M.length-1;Y++){if(J[Y]!=="text"||J[Y+1]!=="text")continue;if(!a0(M[Y])||!a0(M[Y+1]))continue;let Q=hJ(M[Y]);if(Q===null)continue;M[Y]=Q.head,M[Y+1]=Q.tail+M[Y+1],X[Y+1]=X[Y]+Q.head.length}return{len:M.length,texts:M,isWordLike:Z,kinds:J,starts:X}}function ZX($,M,Z){let J=RJ(),X=0,Y=[],Q=[],K=[],q=[];for(let G of J.segment($))for(let B of cJ(G.segment,G.isWordLike??!1,G.index,Z)){let F=B.kind==="text";if(M.carryCJKAfterClosingQuote&&F&&X>0&&K[X-1]==="text"&&a0(B.text)&&a0(Y[X-1])&&c8(Y[X-1]))Y[X-1]+=B.text,Q[X-1]=Q[X-1]||B.isWordLike;else if(F&&X>0&&K[X-1]==="text"&&uJ(B.text)&&a0(Y[X-1]))Y[X-1]+=B.text,Q[X-1]=Q[X-1]||B.isWordLike;else if(F&&X>0&&K[X-1]==="text"&&pJ(Y[X-1]))Y[X-1]+=B.text,Q[X-1]=Q[X-1]||B.isWordLike;else if(F&&X>0&&K[X-1]==="text"&&B.isWordLike&&h8(B.text)&&IJ(Y[X-1]))Y[X-1]+=B.text,Q[X-1]=!0;else if(F&&!B.isWordLike&&X>0&&K[X-1]==="text"&&B.text.length===1&&B.text!=="-"&&B.text!=="—"&&gJ(Y[X-1],B.text))Y[X-1]+=B.text;else if(F&&!B.isWordLike&&X>0&&K[X-1]==="text"&&(SJ(B.text)||B.text==="-"&&Q[X-1]))Y[X-1]+=B.text;else Y[X]=B.text,Q[X]=B.isWordLike,K[X]=B.kind,q[X]=B.start,X++}for(let G=1;G<X;G++)if(K[G]==="text"&&!Q[G]&&r8(Y[G])&&K[G-1]==="text")Y[G-1]+=Y[G],Q[G-1]=Q[G-1]||Q[G],Y[G]="";for(let G=X-2;G>=0;G--)if(K[G]==="text"&&!Q[G]&&vJ(Y[G])){let B=G+1;while(B<X&&Y[B]==="")B++;if(B<X&&K[B]==="text")Y[B]=Y[G]+Y[B],q[B]=q[G],Y[G]=""}let U=0;for(let G=0;G<X;G++){let B=Y[G];if(B.length===0)continue;if(U!==G)Y[U]=B,Q[U]=Q[G],K[U]=K[G],q[U]=q[G];U++}Y.length=U,Q.length=U,K.length=U,q.length=U;let N=$X({len:U,texts:Y,isWordLike:Q,kinds:K,starts:q}),A=MX(tJ(eJ(nJ(sJ(iJ(N))))));for(let G=0;G<A.len-1;G++){let B=lJ(A.texts[G]);if(B===null)continue;if(A.kinds[G]!=="space"&&A.kinds[G]!=="preserved-space"||A.kinds[G+1]!=="text"||!h8(A.texts[G+1]))continue;A.texts[G]=B.space,A.isWordLike[G]=!1,A.kinds[G]=A.kinds[G]==="preserved-space"?"preserved-space":"space",A.texts[G+1]=B.marks+A.texts[G+1],A.starts[G+1]=A.starts[G]+B.space.length}return A}function JX($,M){if($.len===0)return[];if(!M.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len}];let Z=[],J=0;for(let X=0;X<$.len;X++){if($.kinds[X]!=="hard-break")continue;Z.push({startSegmentIndex:J,endSegmentIndex:X,consumedEndSegmentIndex:X+1}),J=X+1}if(J<$.len)Z.push({startSegmentIndex:J,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len});return Z}function r$($,M,Z="normal"){let J=OJ(Z),X=J.mode==="pre-wrap"?CJ($):EJ($);if(X.length===0)return{normalized:X,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let Y=ZX(X,M,J);return{normalized:X,chunks:JX(Y,J),...Y}}var c1=null,c$=new Map,x1=null,XX=/\p{Emoji_Presentation}/u,YX=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,x8=null,x$=new Map;function d8(){if(c1!==null)return c1;if(typeof OffscreenCanvas<"u")return c1=new OffscreenCanvas(1,1).getContext("2d"),c1;if(typeof document<"u")return c1=document.createElement("canvas").getContext("2d"),c1;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function QX($){let M=c$.get($);if(!M)M=new Map,c$.set($,M);return M}function J1($,M){let Z=M.get($);if(Z===void 0)Z={width:d8().measureText($).width,containsCJK:a0($)},M.set($,Z);return Z}function d1(){if(x1!==null)return x1;if(typeof navigator>"u")return x1={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},x1;let $=navigator.userAgent,Z=navigator.vendor==="Apple Computer, Inc."&&$.includes("Safari/")&&!$.includes("Chrome/")&&!$.includes("Chromium/")&&!$.includes("CriOS/")&&!$.includes("FxiOS/")&&!$.includes("EdgiOS/"),J=$.includes("Chrome/")||$.includes("Chromium/")||$.includes("CriOS/")||$.includes("Edg/");return x1={lineFitEpsilon:Z?0.015625:0.005,carryCJKAfterClosingQuote:J,preferPrefixWidthsForBreakableRuns:Z,preferEarlySoftHyphenBreak:Z},x1}function KX($){let M=$.match(/(\d+(?:\.\d+)?)\s*px/);return M?parseFloat(M[1]):16}function a8(){if(x8===null)x8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return x8}function qX($){return XX.test($)||$.includes("️")}function d$($){return YX.test($)}function UX($,M){let Z=x$.get($);if(Z!==void 0)return Z;let J=d8();J.font=$;let X=J.measureText("\uD83D\uDE00").width;if(Z=0,X>M+0.5&&typeof document<"u"&&document.body!==null){let Y=document.createElement("span");Y.style.font=$,Y.style.display="inline-block",Y.style.visibility="hidden",Y.style.position="absolute",Y.textContent="\uD83D\uDE00",document.body.appendChild(Y);let Q=Y.getBoundingClientRect().width;if(document.body.removeChild(Y),X-Q>0.5)Z=X-Q}return x$.set($,Z),Z}function NX($){let M=0,Z=a8();for(let J of Z.segment($))if(qX(J.segment))M++;return M}function AX($,M){if(M.emojiCount===void 0)M.emojiCount=NX($);return M.emojiCount}function X1($,M,Z){if(Z===0)return M.width;return M.width-AX($,M)*Z}function a$($,M,Z,J){if(M.graphemeWidths!==void 0)return M.graphemeWidths;let X=[],Y=a8();for(let Q of Y.segment($)){let K=J1(Q.segment,Z);X.push(X1(Q.segment,K,J))}return M.graphemeWidths=X.length>1?X:null,M.graphemeWidths}function i$($,M,Z,J){if(M.graphemePrefixWidths!==void 0)return M.graphemePrefixWidths;let X=[],Y=a8(),Q="";for(let K of Y.segment($)){Q+=K.segment;let q=J1(Q,Z);X.push(X1(Q,q,J))}return M.graphemePrefixWidths=X.length>1?X:null,M.graphemePrefixWidths}function s$($,M){let Z=d8();Z.font=$;let J=QX($),X=KX($),Y=M?UX($,X):0;return{cache:J,fontSize:X,emojiCorrection:Y}}function Y5($){return $==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen"}function GX($,M){while(M<$.widths.length){let Z=$.kinds[M];if(Z!=="space"&&Z!=="zero-width-break"&&Z!=="soft-hyphen")break;M++}return M}function BX($,M){if(M<=0)return 0;let Z=$%M;if(Math.abs(Z)<=0.000001)return M;return M-Z}function o$($,M,Z,J){if(!J||M===null)return $[Z];return M[Z]-(Z>0?M[Z-1]:0)}function _X($,M,Z,J,X,Y){let Q=0,K=M;while(Q<$.length){let q=Y?M+$[Q]:K+$[Q];if((Q+1<$.length?q+X:q)>Z+J)break;K=q,Q++}return{fitCount:Q,fittedWidth:K}}function FX($,M,Z){let{widths:J,kinds:X,breakableWidths:Y,breakablePrefixWidths:Q}=$;if(J.length===0)return 0;let K=d1(),q=K.lineFitEpsilon,U=0,N=0,A=!1,G=0,B=0,F=0,_=0,D=-1,T=0;function O(){D=-1,T=0}function y(W=F,b=_,z=N){U++,Z?.({startSegmentIndex:G,startGraphemeIndex:B,endSegmentIndex:W,endGraphemeIndex:b,width:z}),N=0,A=!1,O()}function R(W,b){A=!0,G=W,B=0,F=W+1,_=0,N=b}function C(W,b,z){A=!0,G=W,B=b,F=W,_=b+1,N=z}function m(W,b){if(!A){R(W,b);return}N+=b,F=W+1,_=0}function H(W,b){if(!Y5(X[W]))return;D=W+1,T=N-b}function P(W){E(W,0)}function E(W,b){let z=Y[W],u=Q[W]??null;for(let v=b;v<z.length;v++){let l=o$(z,u,v,K.preferPrefixWidthsForBreakableRuns);if(!A){C(W,v,l);continue}if(N+l>M+q)y(),C(W,v,l);else N+=l,F=W,_=v+1}if(A&&F===W&&_===z.length)F=W+1,_=0}let j=0;while(j<J.length){if(!A){if(j=GX($,j),j>=J.length)break}let W=J[j],b=X[j];if(!A){if(W>M&&Y[j]!==null)P(j);else R(j,W);H(j,W),j++;continue}if(N+W>M+q){if(Y5(b)){m(j,W),y(j+1,0,N-W),j++;continue}if(D>=0){if(F>D||F===D&&_>0){y();continue}y(D,0,T);continue}if(W>M&&Y[j]!==null){y(),P(j),j++;continue}y();continue}m(j,W),H(j,W),j++}if(A)y();return U}function n$($,M,Z){if($.simpleLineWalkFastPath)return FX($,M,Z);let{widths:J,lineEndFitAdvances:X,lineEndPaintAdvances:Y,kinds:Q,breakableWidths:K,breakablePrefixWidths:q,discretionaryHyphenWidth:U,tabStopAdvance:N,chunks:A}=$;if(J.length===0||A.length===0)return 0;let G=d1(),B=G.lineFitEpsilon,F=0,_=0,D=!1,T=0,O=0,y=0,R=0,C=-1,m=0,H=0,P=null;function E(){C=-1,m=0,H=0,P=null}function j(V=y,L=R,f=_){F++,Z?.({startSegmentIndex:T,startGraphemeIndex:O,endSegmentIndex:V,endGraphemeIndex:L,width:f}),_=0,D=!1,E()}function W(V,L){D=!0,T=V,O=0,y=V+1,R=0,_=L}function b(V,L,f){D=!0,T=V,O=L,y=V,R=L+1,_=f}function z(V,L){if(!D){W(V,L);return}_+=L,y=V+1,R=0}function u(V,L){if(!Y5(Q[V]))return;let f=Q[V]==="tab"?0:X[V],x=Q[V]==="tab"?L:Y[V];C=V+1,m=_-L+f,H=_-L+x,P=Q[V]}function v(V){l(V,0)}function l(V,L){let f=K[V],x=q[V]??null;for(let h=L;h<f.length;h++){let Q0=o$(f,x,h,G.preferPrefixWidthsForBreakableRuns);if(!D){b(V,h,Q0);continue}if(_+Q0>M+B)j(),b(V,h,Q0);else _+=Q0,y=V,R=h+1}if(D&&y===V&&R===f.length)y=V+1,R=0}function g(V){if(P!=="soft-hyphen")return!1;let L=K[V];if(L===null)return!1;let f=G.preferPrefixWidthsForBreakableRuns?q[V]??L:L,x=f!==L,{fitCount:h,fittedWidth:Q0}=_X(f,_,M,B,U,x);if(h===0)return!1;if(_=Q0,y=V,R=h,E(),h===L.length)return y=V+1,R=0,!0;return j(V,h,Q0+U),l(V,h),!0}function w(V){F++,Z?.({startSegmentIndex:V.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:V.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),E()}for(let V=0;V<A.length;V++){let L=A[V];if(L.startSegmentIndex===L.endSegmentIndex){w(L);continue}D=!1,_=0,T=L.startSegmentIndex,O=0,y=L.startSegmentIndex,R=0,E();let f=L.startSegmentIndex;while(f<L.endSegmentIndex){let x=Q[f],h=x==="tab"?BX(_,N):J[f];if(x==="soft-hyphen"){if(D)y=f+1,R=0,C=f+1,m=_+U,H=_+U,P=x;f++;continue}if(!D){if(h>M&&K[f]!==null)v(f);else W(f,h);u(f,h),f++;continue}if(_+h>M+B){let b0=_+(x==="tab"?0:X[f]),e0=_+(x==="tab"?h:Y[f]);if(P==="soft-hyphen"&&G.preferEarlySoftHyphenBreak&&m<=M+B){j(C,0,H);continue}if(P==="soft-hyphen"&&g(f)){f++;continue}if(Y5(x)&&b0<=M+B){z(f,h),j(f+1,0,e0),f++;continue}if(C>=0&&m<=M+B){if(y>C||y===C&&R>0){j();continue}let L1=C;j(L1,0,H),f=L1;continue}if(h>M&&K[f]!==null){j(),v(f),f++;continue}j();continue}z(f,h),u(f,h),f++}if(D){let x=C===L.consumedEndSegmentIndex?H:_;j(L.consumedEndSegmentIndex,0,x)}}return F}var i8=null,t$=new WeakMap;function $9(){if(i8===null)i8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return i8}function bX($){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 DX($,M,Z){let J=$9(),X=d1(),{cache:Y,emojiCorrection:Q}=s$(M,d$($.normalized)),K=X1("-",J1("-",Y),Q),U=X1(" ",J1(" ",Y),Q)*8;if($.len===0)return bX(Z);let N=[],A=[],G=[],B=[],F=$.chunks.length<=1,_=Z?[]:null,D=[],T=[],O=Z?[]:null,y=Array.from({length:$.len}),R=Array.from({length:$.len});function C(P,E,j,W,b,z,u,v){if(b!=="text"&&b!=="space"&&b!=="zero-width-break")F=!1;if(N.push(E),A.push(j),G.push(W),B.push(b),_?.push(z),D.push(u),T.push(v),O!==null)O.push(P)}for(let P=0;P<$.len;P++){y[P]=N.length;let E=$.texts[P],j=$.isWordLike[P],W=$.kinds[P],b=$.starts[P];if(W==="soft-hyphen"){C(E,0,K,K,W,b,null,null),R[P]=N.length;continue}if(W==="hard-break"){C(E,0,0,0,W,b,null,null),R[P]=N.length;continue}if(W==="tab"){C(E,0,0,0,W,b,null,null),R[P]=N.length;continue}let z=J1(E,Y);if(W==="text"&&z.containsCJK){let g="",w=0;for(let V of J.segment(E)){let L=V.segment;if(g.length===0){g=L,w=V.index;continue}if(V2.has(g)||p8.has(L)||r1.has(L)||X.carryCJKAfterClosingQuote&&a0(L)&&c8(g)){g+=L;continue}let f=J1(g,Y),x=X1(g,f,Q);C(g,x,x,x,"text",b+w,null,null),g=L,w=V.index}if(g.length>0){let V=J1(g,Y),L=X1(g,V,Q);C(g,L,L,L,"text",b+w,null,null)}R[P]=N.length;continue}let u=X1(E,z,Q),v=W==="space"||W==="preserved-space"||W==="zero-width-break"?0:u,l=W==="space"||W==="zero-width-break"?0:u;if(j&&E.length>1){let g=a$(E,z,Y,Q),w=X.preferPrefixWidthsForBreakableRuns?i$(E,z,Y,Q):null;C(E,u,v,l,W,b,g,w)}else C(E,u,v,l,W,b,null,null);R[P]=N.length}let m=HX($.chunks,y,R),H=_===null?null:h$($.normalized,_);if(O!==null)return{widths:N,lineEndFitAdvances:A,lineEndPaintAdvances:G,kinds:B,simpleLineWalkFastPath:F,segLevels:H,breakableWidths:D,breakablePrefixWidths:T,discretionaryHyphenWidth:K,tabStopAdvance:U,chunks:m,segments:O};return{widths:N,lineEndFitAdvances:A,lineEndPaintAdvances:G,kinds:B,simpleLineWalkFastPath:F,segLevels:H,breakableWidths:D,breakablePrefixWidths:T,discretionaryHyphenWidth:K,tabStopAdvance:U,chunks:m}}function HX($,M,Z){let J=[];for(let X=0;X<$.length;X++){let Y=$[X],Q=Y.startSegmentIndex<M.length?M[Y.startSegmentIndex]:Z[Z.length-1]??0,K=Y.endSegmentIndex<M.length?M[Y.endSegmentIndex]:Z[Z.length-1]??0,q=Y.consumedEndSegmentIndex<M.length?M[Y.consumedEndSegmentIndex]:Z[Z.length-1]??0;J.push({startSegmentIndex:Q,endSegmentIndex:K,consumedEndSegmentIndex:q})}return J}function PX($,M,Z,J){let X=r$($,d1(),J?.whiteSpace);return DX(X,M,Z)}function M9($,M,Z){return PX($,M,!0,Z)}function zX($){return $}function e$($,M,Z){let J=Z.get($);if(J!==void 0)return J;J=[];let X=$9();for(let Y of X.segment(M[$]))J.push(Y.segment);return Z.set($,J),J}function TX($){let M=t$.get($);if(M!==void 0)return M;return M=new Map,t$.set($,M),M}function yX($,M,Z,J){return J>0&&$[J-1]==="soft-hyphen"&&!(M===J&&Z>0)}function WX($,M,Z,J,X,Y,Q){let K="",q=yX(M,J,X,Y);for(let U=J;U<Y;U++){if(M[U]==="soft-hyphen"||M[U]==="hard-break")continue;if(U===J&&X>0)K+=e$(U,$,Z).slice(X).join("");else K+=$[U]}if(Q>0){if(q)K+="-";K+=e$(Y,$,Z).slice(J===Y?X:0,Q).join("")}else if(q)K+="-";return K}function VX($,M,Z,J,X,Y,Q){return{text:WX($.segments,$.kinds,M,J,X,Y,Q),width:Z,start:{segmentIndex:J,graphemeIndex:X},end:{segmentIndex:Y,graphemeIndex:Q}}}function wX($,M,Z){return VX($,M,Z.width,Z.startSegmentIndex,Z.startGraphemeIndex,Z.endSegmentIndex,Z.endGraphemeIndex)}function Z9($,M,Z){let J=[];if($.widths.length===0)return{lineCount:0,height:0,lines:J};let X=TX($),Y=n$(zX($),M,(Q)=>{J.push(wX($,X,Q))});return{lineCount:Y,height:Y*Z,lines:J}}function s8($,M,Z){let J=$.image?M.images.get($.image.url)??null:null,X=$.image?.width??null,Y=Math.min(Z,X??240),Q=Math.max(120,Math.round(Y*0.5625));if(!J||J.intrinsicWidth<=0||J.intrinsicHeight<=0)return{height:Q,width:Y};let K=Math.min(Z,X??J.intrinsicWidth),q=Math.min(1,K/J.intrinsicWidth);return{height:Math.max(48,Math.round(J.intrinsicHeight*q)),width:Math.max(48,Math.round(J.intrinsicWidth*q))}}function J9($,M){if(!$.image)return`${$.kind}:missing-image`;let Z=M.images.get($.image.url);return`${$.kind}:${$.image.url}:${$.image.width??0}:${Z?.status??"loading"}:${Z?.intrinsicWidth??0}:${Z?.intrinsicHeight??0}`}var X9=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],Q5;function a1($){if($?.type==="heading"){let{fontSize:M}=K9($.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 y1($,M){if($?.type==="heading")return K9($.depth).lineHeight;if($?.type==="code")return 22;return M}function K9($){return X9[$-1]??X9.at(-1)}function i1($,M,Z,J,X,Y,Q){let K=`${q5(M,Q)}:${X}:${Y}:${Z}`,q=$.measuredLines.get(K);if(q)return q;let U=EX($,M,Z,J,X,Y,Q);return k$($,K,U)}function K5($,M,Z,J,X,Y,Q,K){let q=`${q5(M,K)}:${Z}:${J}:${Y}:${Q}`,U=$.lineBoundaries.get(q);if(U)return U;let N=U9();if(!N)return Q9(X);let A=[{left:0,offset:0}],G=0,B=M.inlines.filter((F)=>F.end>Z&&F.start<J);if(B.length===0)return Q9(X);for(let F of B){let _=Math.max(Z,F.start),D=Math.min(J,F.end),T=M.text.slice(_,D),O=_-Z;if(F.kind==="image"){let y=s8(F,K,Q).width;G+=y,O+=T.length,A.push({left:G,offset:O});continue}N.font=q9(Y,F.marks);for(let y of Array.from(T))G+=N9($,N,y),O+=y.length,A.push({left:G,offset:O})}return f$($,q,A)}function OX($,M,Z,J){let X=`${Z}::${J}::${M}`,Y=$.preparedText.get(X);if(Y)return Y;let Q=M9(M,Z,{whiteSpace:J});return L$($,X,Q)}function EX($,M,Z,J,X,Y,Q){let K=M.text;if(K.length===0)return[{end:0,height:Y,start:0,text:"",width:0}];if(kX(M))return jX($,M,Z,X,Y,Q);try{let q=OX($,K,Z,vX(J));return Z9(q,X,Y).lines.map((N)=>({end:Y9(q.segments,N.end),height:Y,start:Y9(q.segments,N.start),text:N.text,width:N.width}))}catch{return CX(K,X,Y)}}function Y9($,M){let Z=0;for(let Y=0;Y<M.segmentIndex;Y+=1)Z+=$[Y]?.length??0;let J=$[M.segmentIndex]??"",X=Array.from(J);for(let Y=0;Y<M.graphemeIndex;Y+=1)Z+=X[Y]?.length??0;return Z}function Q9($){let M=[{left:0,offset:0}],Z=0,J=0;for(let X of Array.from($))Z+=9,J+=X.length,M.push({left:Z,offset:J});return M}function CX($,M,Z){let J=Math.max(1,Math.floor(M/9)),X=hX($,J),Y=0;return X.map((Q)=>{let K=Y,q=K+Q.length;return Y=q,{end:q,height:Z,start:K,text:Q,width:Q.length*9}})}function jX($,M,Z,J,X,Y){let Q=LX($,U9(),M,Z,J,X,Y);if(Q.length===0)return[{end:0,height:X,start:0,text:"",width:0}];return RX(Q,M.text,J,X)}function RX($,M,Z,J){let X=[],Y=0;while(Y<$.length){let Q=$[Y].start;if($[Y].text===`
|
|
14
|
-
`){X.push({end:
|
|
15
|
-
`)break;let
|
|
16
|
-
`){let
|
|
17
|
-
`?
|
|
18
|
-
`?0:
|
|
19
|
-
`),J=[];for(let X of Z){if(X.length===0){J.push("");continue}let Y=X;while(Y.length>M){let Q=Y.slice(0,M),K=Q.lastIndexOf(" ");if(K<=0){J.push(Q),Y=Y.slice(M);continue}J.push(Q.slice(0,K)),Y=Y.slice(K+1)}J.push(Y)}return J}var w2=10,s1=8,o8=120;function A9($,M,Z,J,X,Y,Q,K,q,U){let N=Math.max(1,...Y.rows.map((_)=>_.cells.length)),G=Math.max(o8,q.width-Q-q.paddingX)/N,B=gX(J),F=K;for(let _=0;_<Y.rows.length;_+=1){let D=IX(B.get(_)??[],X,Y,G,w2,q.lineHeight,U),T=Math.max(q.lineHeight+s1*2,...D.map((O)=>O.measuredLines.reduce((y,R)=>y+R.height,0)+s1*2));for(let O of D){let y=Q+O.cellIndex*G,R=F+s1;for(let C of O.measuredLines){let m={blockId:O.container.blockId,boundaries:K5(X,O.container,C.start,C.end,C.text,O.font,G-w2*2,U),regionId:O.container.id,end:C.end,font:O.font,height:C.height,left:y+w2,start:C.start,text:C.text,top:R,width:C.width};$.push(m),n8(M,m),R+=C.height}Z.set(O.container.id,{bottom:F+T,left:y,right:y+G,top:F})}lX(M,Y.id,F,F+T),F+=T}return F+q.blockGap}function gX($){let M=new Map;for(let Z of $){let J=pX(Z.path);if(!J)continue;let X=M.get(J.rowIndex)??[];X.push({cellIndex:J.cellIndex,container:Z}),M.set(J.rowIndex,X)}return M}function IX($,M,Z,J,X,Y,Q){return[...$].sort((K,q)=>K.cellIndex-q.cellIndex).map(({cellIndex:K,container:q})=>{let U=a1(Z),N=y1(Z,Y),A=i1(M,q,U,Z,Math.max(40,J-X*2),N,Q);return{cellIndex:K,container:q,font:U,lineHeight:N,measuredLines:A}})}function pX($){let M=/\.rows\.(\d+)\.cells\.(\d+)$/.exec($);if(!M)return null;return{cellIndex:Number(M[2]),rowIndex:Number(M[1])}}function lX($,M,Z,J){let X=$.get(M);$.set(M,{bottom:X?Math.max(X.bottom,J):J,top:X?Math.min(X.top,Z):Z})}var rX={blockGap:16,charWidth:9,indentWidth:24,lineHeight:24,paddingX:16,paddingY:12},cX=24,xX=16,dX=6,aX=10,iX=4;function U5($){let M=Math.max(12,Math.floor($.width/9)),Z=Math.max(1,Math.ceil($.text.length/M));return{estimatedHeight:Z*24,lineCount:Z,width:$.width}}function N5($,M,Z=T1(),J=null){let X=J??{images:new Map},Y={...rX,...M},Q=[],K=new Map,q=new Map($.regions.map((_)=>[_.id,{textLength:_.text.length}])),U=new Map($.blocks.map((_)=>[_.id,_.depth])),N=new Map($.blocks.map((_)=>[_.id,_])),A=E2($.document.blocks),G=new Map,B=Y.paddingY;for(let _=0;_<$.regions.length;_+=1){let D=$.regions[_],T=U.get(D.blockId)??0,O=Y.paddingX+T*Y.indentWidth,y=Math.max(40,Y.width-O-Y.paddingX),R=A.get(D.blockId)??null;if(R?.type==="table"){let H=N.get(D.blockId)?.regionIds??[],P=$.regions.slice(_,_+H.length);B=A9(Q,G,K,P,Z,R,O,B,Y,X),_+=P.length-1;continue}B=sX(Q,G,K,D,Z,R,O,B,y,Y,X);let C=G5(N,A,$.regions,_,Y.blockGap);B+=C;let m=G.get(D.blockId);if(m)m.bottom=Math.max(m.bottom,B)}return{blocks:$.blocks.map((_)=>{let D=G.get(_.id),T=D?.top??Y.paddingY;return{bottom:D?.bottom??T+Y.lineHeight/2,depth:_.depth,id:_.id,top:T,type:_.type}}),regionBounds:nX(Q,K),regionLineIndices:oX(Q),regionMetrics:q,height:Math.max(B,Y.paddingY),lines:Q,options:Y,width:Y.width}}function sX($,M,Z,J,X,Y,Q,K,q,U,N){let A=a1(Y),G=y1(Y,U.lineHeight),B=i1(X,J,A,Y,q,G,N),F=K;for(let _ of B){let D={blockId:J.blockId,boundaries:K5(X,J,_.start,_.end,_.text,A,q,N),regionId:J.id,end:_.end,font:A,height:_.height,left:Q,start:_.start,text:_.text,top:F,width:_.width};$.push(D),n8(M,D),F+=_.height}return tX($,J.id,Z),F}function oX($){let M=[...$].sort((J,X)=>J.top-X.top||J.left-X.left),Z=new Map;$.length=0,$.push(...M);for(let[J,X]of $.entries()){let Y=Z.get(X.regionId)??[];Y.push(J),Z.set(X.regionId,Y)}return Z}function nX($,M){let Z=new Map(M);for(let J of $){let X=Z.get(J.regionId),Y={bottom:J.top+J.height,left:J.left,right:J.left+J.width,top:J.top};Z.set(J.regionId,X?{bottom:Math.max(X.bottom,Y.bottom),left:Math.min(X.left,Y.left),right:Math.max(X.right,Y.right),top:Math.min(X.top,Y.top)}:Y)}return Z}function tX($,M,Z){let J=$.filter((X)=>X.regionId===M);if(J.length===0)return;Z.set(M,{bottom:Math.max(...J.map((X)=>X.top+X.height)),left:Math.min(...J.map((X)=>X.left)),right:Math.max(...J.map((X)=>X.left+X.width)),top:Math.min(...J.map((X)=>X.top))})}function n8($,M){let Z=$.get(M.blockId),J=M.top+M.height;$.set(M.blockId,{bottom:Z?Math.max(Z.bottom,J):J,top:Z?Math.min(Z.top,M.top):M.top})}function b9($,M){let Z=0,J=$.lines.length-1;while(Z<=J){let X=Z+J>>1,Y=$.lines[X];if(M<Y.top){J=X-1;continue}if(M>=Y.top+Y.height){Z=X+1;continue}return{index:X,line:Y}}return null}function t8($,M){let Z=[...$.regionBounds.entries()].find(([,Y])=>{return M.x>=Y.left&&M.x<=Y.right&&M.y>=Y.top&&M.y<=Y.bottom});if(Z)return A5($,Z[0],M.y);let J=b9($,M.y);if(!J)return null;let X=eX($,M.y,J.index);if(X.length===1)return X[0]??null;return X.find((Y)=>{let Q=$.regionBounds.get(Y.line.regionId);return Q?M.x>=Q.left&&M.x<=Q.right:!1})??[...X].sort((Y,Q)=>{let K=$.regionBounds.get(Y.line.regionId),q=$.regionBounds.get(Q.line.regionId),U=G9(M.x,K),N=G9(M.x,q);return U-N})[0]??null}function e8($,M,Z){if($.lines.length===0)return{endIndex:0,startIndex:0};let J=M+Z,X=B9($,M),Y=B9($,J);if(X>0){let Q=$.lines[X-1];if(Q.top+Q.height>M)X-=1}if(Y<$.lines.length){if($.lines[Y].top<J)Y+=1}return{endIndex:Y,startIndex:X}}function I0($,M,Z){if(!$.regionMetrics.get(Z.regionId))return null;let X=s0($,Z.regionId,Z.offset);if(!X)return null;return{blockId:X.blockId,regionId:X.regionId,height:X.height,left:p0(X,Z.offset-X.start),offset:Z.offset,top:X.top}}function s0($,M,Z){return O2($,M,Z)?.line??null}function A5($,M,Z){let J=$.regionLineIndices.get(M);if(!J||J.length===0)return null;let X=J[0],Y=Number.POSITIVE_INFINITY;for(let Q of J){let K=$.lines[Q],q=Z<K.top?K.top-Z:Z>K.top+K.height?Z-(K.top+K.height):0;if(q<Y)Y=q,X=Q;if(q===0)break}return{index:X,line:$.lines[X]}}function O2($,M,Z){let J=$.regionLineIndices.get(M);if(!J||J.length===0)return null;let X=0,Y=J.length-1;while(X<=Y){let N=X+Y>>1,A=J[N],G=$.lines[A];if(Z<G.start){Y=N-1;continue}if(Z>G.end){X=N+1;continue}return{index:A,line:G}}let Q=J[0],K=J[J.length-1],q=$.lines[Q],U=$.lines[K];if(Z<=q.start)return{index:Q,line:q};if(Z>=U.end)return{index:K,line:U};return null}function eX($,M,Z){let J=[];for(let X=Z;X>=0;X-=1){let Y=$.lines[X];if(M<Y.top||M>=Y.top+Y.height)break;J.unshift({index:X,line:Y})}for(let X=Z+1;X<$.lines.length;X+=1){let Y=$.lines[X];if(M<Y.top||M>=Y.top+Y.height)break;J.push({index:X,line:Y})}return J}function G9($,M){if(!M)return Number.POSITIVE_INFINITY;if($<M.left)return M.left-$;if($>M.right)return $-M.right;return 0}function p0($,M){return $.left+$Y($.boundaries,M)}function E2($){let M=new Map,Z=(J)=>{for(let X of J)if(M.set(X.id,X),X.type==="blockquote"||X.type==="listItem")Z(X.children);else if(X.type==="list")Z(X.items)};return Z($),M}function $Y($,M){for(let J of $)if(J.offset===M)return J.left;return $.filter((J)=>J.offset<=M).at(-1)?.left??0}function B9($,M){let Z=0,J=$.lines.length;while(Z<J){let X=Z+J>>1,Y=$.lines[X];if(Y.top+Y.height<=M)Z=X+1;else J=X}return Z}function D9($,M){if($.length===0)return 0;for(let Z=1;Z<$.length;Z+=1){let J=$[Z-1],X=$[Z],Y=J.left+(X.left-J.left)/2;if(M<=Y)return J.offset;if(M<=X.left)return X.offset}return $.at(-1)?.offset??0}function G5($,M,Z,J,X){let Y=Z[J],Q=Z[J+1];if(!Y||!Q)return X;if(_9($,Y.blockId,Q.blockId,"list"))return dX;if(_9($,Y.blockId,Q.blockId,"blockquote"))return aX;if(Y.blockId===Q.blockId)return iX;return X+MY(M.get(Y.blockId))}function MY($){if($?.type!=="heading")return 0;if($.depth===1)return cX;return $.depth===2?xX:0}function _9($,M,Z,J){let X=F9($,M,J),Y=F9($,Z,J);for(let Q of X)if(Y.has(Q))return!0;return!1}function F9($,M,Z){let J=new Set,X=$.get(M)??null;while(X){if(X.type===Z)J.add(X.id);X=X.parentBlockId?$.get(X.parentBlockId)??null:null}return J}function $6($,M,Z,J=[],X=T1(),Y=null){let Q=Y??{images:new Map},K=E2($.document.blocks),q=new Map($.blocks.map((y)=>[y.id,y])),U=new Set(J),N=Math.max(0,Z.top-Z.overscan),A=Z.top+Z.height+Z.overscan,G=QY(X,$,K,q,M,Q),B=H9(G,N),F=H9(G,A);if(B>0){let y=G.entries[B-1];if(y&&y.bottom>N)B-=1}if(F<G.entries.length){let y=G.entries[F];if(y&&y.top<A)F+=1}for(let y of U){let R=G.containerIndices.get(y);if(R===void 0)continue;B=Math.min(B,R),F=Math.max(F,R+1)}if(!Number.isFinite(B)||!Number.isFinite(F))return{estimateRegionBounds:G.estimateRegionBounds,layout:N5({...$,regions:[]},M,X,Q),totalHeight:G.totalHeight,viewport:Z};let _=XY($,q,G.containerIndices,B,F),D=G.entries[_.startIndex]?.top??M.paddingY??0,T=N5({...$,regions:$.regions.slice(_.startIndex,_.endIndex)},M,X,Q),O=JY(T,D,G.totalHeight);return ZY(X,$,O,M,Q),{estimateRegionBounds:G.estimateRegionBounds,layout:O,totalHeight:G.totalHeight,viewport:Z}}function ZY($,M,Z,J,X){for(let[Y,Q]of Z.regionBounds){let K=Q.bottom-Q.top,q=M.regionIndex.get(Y);m$($,P9(q??{path:Y,inlines:[],text:""},J,X),K)}}function JY($,M,Z){return{...$,blocks:$.blocks.map((J)=>({...J,bottom:J.bottom+M,top:J.top+M})),regionBounds:new Map([...$.regionBounds.entries()].map(([J,X])=>[J,{bottom:X.bottom+M,left:X.left,right:X.right,top:X.top+M}])),height:Z,lines:$.lines.map((J)=>({...J,top:J.top+M}))}}function XY($,M,Z,J,X){let Y=J,Q=X;for(let K=J;K<X;K+=1){let q=$.regions[K],U=M.get(q.blockId);if(!U)continue;if(U.type==="table"){let N=Z.get(U.regionIds[0]??""),A=Z.get(U.regionIds[U.regionIds.length-1]??"");if(N!==void 0)Y=Math.min(Y,N);if(A!==void 0)Q=Math.max(Q,A+1)}}return{endIndex:Q,startIndex:Y}}function YY($,M,Z,J,X,Y){let Q=P9(M,X,Y),K=$.measuredContainerHeights.get(Q);if(K!==void 0)return K;let q=X.paddingX??0,U=X.indentWidth??24,N=y1(Z,X.lineHeight??24),A=q+J*U,G=Math.max(40,X.width-A-q);if(M.inlines.some((_)=>_.kind==="image")){let _=a1(Z);return i1($,M,_,Z,G,N,Y).reduce((D,T)=>D+T.height,0)}let B=U5({text:M.text,width:G});return Math.max(N,B.lineCount*N)}function QY($,M,Z,J,X,Y){let Q=NY(M,X,Y),K=u$($,M,Q);if(K)return K;let q=X.paddingY??0,U=[],N=new Map;for(let A=0;A<M.regions.length;A+=1){let G=M.regions[A],B=Z.get(G.blockId)??null;if(B?.type==="table"){let T=KY({block:B,blockMap:Z,containerIndices:N,entries:U,index:A,options:X,runtimeBlocks:J,totalHeight:q,regions:M.regions});if(T){A=T.nextIndex-1,q=T.totalHeight;continue}}let F=YY($,G,B,J.get(G.blockId)?.depth??0,X,Y),_=q,D=_+F;U.push({bottom:D,top:_}),N.set(G.id,A),q=D+G5(J,Z,M.regions,A,X.blockGap??16)}return v$($,M,Q,{containerIndices:N,entries:U,estimateRegionBounds(A){let G=N.get(A);return G===void 0?null:U[G]??null},totalHeight:q})}function KY({block:$,blockMap:M,containerIndices:Z,entries:J,index:X,options:Y,runtimeBlocks:Q,totalHeight:K,regions:q}){let U=Q.get($.id),N=U?.regionIds??[];if(N.length===0)return null;let A=q.slice(X,X+N.length);if(A.length===0||A[0]?.blockId!==$.id)return null;let G=Y.paddingX??0,B=Y.indentWidth??24,F=U?.depth??0,_=G+F*B,D=Math.max(o8,Y.width-_-G),T=Math.max(1,...$.rows.map((H)=>H.cells.length)),O=D/T,y=Math.max(40,O-w2*2),R=y1($,Y.lineHeight??24),C=qY(A,X),m=K;for(let H=0;H<$.rows.length;H+=1){let P=C.get(H)??[],E=Math.max(R+s1*2,...P.map(({region:W})=>UY(W,y,R)+s1*2)),j=m+E;for(let{index:W,region:b}of P)J[W]={bottom:j,top:m},Z.set(b.id,W);m=j}for(let H=X;H<X+A.length;H+=1){let P=q[H];if(!P||J[H])continue;J[H]={bottom:m,top:m},Z.set(P.id,H)}return{nextIndex:X+A.length,totalHeight:m+G5(Q,M,q,X+A.length-1,Y.blockGap??16)}}function qY($,M){let Z=new Map;for(let[J,X]of $.entries()){let Y=X.tableCellPosition?.rowIndex;if(Y===void 0)continue;let Q=Z.get(Y)??[];Q.push({index:M+J,region:X}),Z.set(Y,Q)}return Z}function UY($,M,Z){let J=U5({text:$.text,width:M});return Math.max(Z,J.lineCount*Z)}function NY($,M,Z){return[M.width,M.paddingX??0,M.paddingY??0,M.indentWidth??24,M.lineHeight??24,M.blockGap??16,AY($,Z)].join(":")}function H9($,M){let Z=0,J=$.entries.length;while(Z<J){let X=Z+J>>1;if($.entries[X].bottom<=M)Z=X+1;else J=X}return Z}function P9($,M,Z){return`${q5($,Z)}:${M.width}:${M.paddingX??0}:${M.indentWidth??24}:${M.lineHeight??24}`}function AY($,M){return $.regions.flatMap((Z)=>Z.inlines.filter((J)=>J.kind==="image"&&J.image).map((J)=>{let X=J.image?M.images.get(J.image.url):null;return`${J.image?.url??""}:${J.image?.width??0}:${X?.status??"loading"}:${X?.intrinsicWidth??0}:${X?.intrinsicHeight??0}`})).join("|")}var B5=null;function GY($){let M=/(\d+(?:\.\d+)?)\s*px/.exec($);return M?Number.parseFloat(M[1]):16}function Y1($){B5??=new Map;let M=B5.get($);if(M)return M;let Z=y9(),J=Math.max(12,Math.round(GY($)));if(!Z){let G={ascent:Math.round(J*0.8),descent:Math.max(2,J-Math.round(J*0.8)),emHeight:J};return B5.set($,G),G}Z.font=$;let X=Z.measureText("Hg"),Y=Math.round(X.actualBoundingBoxAscent||0),Q=Math.round(X.actualBoundingBoxDescent||0),K=Y+Q,q=Math.max(J,K),U=K>0?Y:Math.round(q*0.8),N=K>0?Q:Math.max(2,q-U),A={ascent:U,descent:N,emHeight:q};return B5.set($,A),A}function BY($,M){let{emHeight:Z}=Y1(M);return Math.max(0,Math.floor(($-Z)/2))}function z9($,M){let{ascent:Z}=Y1(M);return BY($,M)+Z}var _5;function T9($,M){let Z=y9();if(!Z||$.length===0)return 0;return Z.font=M,Z.measureText($).width}function y9(){if(_5!==void 0)return _5;return _5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,_5}var _Y=18,FY=14,bY=22;function w0($,M,Z){let J=HY($,Z);if(!J)return null;return W9($,M,J,Z.x)}function M6($,M,Z){let J=$.lines[$.lines.length-1];if(!J||Z.y<=J.top+J.height)return null;return W9($,M,J,Z.x)}function W9($,M,Z,J){let X=$.regionMetrics.get(Z.regionId);if(!X)return null;let Y=Math.max(0,J-K1(M,Z)-Z.left),Q=D9(Z.boundaries,Y),K=Math.min(X.textLength,Z.start+Q);return{regionId:Z.regionId,offset:K,left:p0(Z,Q),top:Z.top,height:Z.height}}function Z6($,M,Z,J){let X=K6(M,J.regionId);if(!X)return null;let Y=w0($,M,Z);if(Y)return{regionId:Y.regionId,offset:Y.offset};let Q=Z.y<zY($);return{regionId:J.regionId,offset:Q?0:X.text.length}}function J6($,M,Z){let J=w0($,M,Z);if(!J)return null;let X=K6(M,J.regionId);if(!X||X.text.length===0)return null;let Y=J.offset<X.text.length&&/\w/.test(X.text[J.offset]??"")?J.offset:J.offset>0&&/\w/.test(X.text[J.offset-1]??"")?J.offset-1:J.offset,Q=TY(X.text,Y);if(Q.start===Q.end)return null;return{anchor:{regionId:J.regionId,offset:Q.start},focus:{regionId:J.regionId,offset:Q.end}}}function V9($,M,Z){let J=PY($,Z);if(!J||J.start!==0)return null;let X=o1(M,J.blockId,"listItem");if(!X)return null;if(j2(M,X.id)?.kind!=="task")return null;let Q=C2(J),K=Q.left-4,q=Q.left+Q.size+4,U=Q.top-4,N=Q.top+Q.size+4;return Z.x>=K&&Z.x<=q&&Z.y>=U&&Z.y<=N?{listItemId:X.id}:null}function w9($,M,Z){let J=w0($,M,Z);if(!J)return null;let X=K6(M,J.regionId);if(!X)return null;let Y=X.inlines.find((K)=>K.link&&J.offset>=K.start&&J.offset<K.end);if(!Y?.link)return null;let Q=Q6($,M,J.regionId,Y.start);if(!Q)return null;return{anchorBottom:Q.anchorBottom,anchorLeft:Q.anchorLeft,endOffset:Y.end,regionId:J.regionId,startOffset:Y.start,title:Y.link.title,url:Y.link.url}}function X6($,M,Z,J){let X=V9($,M,Z);if(X)return{kind:"task-toggle",listItemId:X.listItemId};let Y=w0($,M,Z);if(!Y)return null;let Q=O9(Y.regionId,Y.offset,J),K=Q!==null?E9(Q,$,M,J):null,q=w9($,M,Z);if(q)return{anchorBottom:K?.anchorBottom??q.anchorBottom,anchorLeft:K?.anchorLeft??q.anchorLeft,endOffset:q.endOffset,kind:"link",commentThreadIndex:Q,regionId:q.regionId,startOffset:q.startOffset,title:q.title,url:q.url};return{anchorBottom:K?.anchorBottom??Y.top+Y.height,anchorLeft:K?.anchorLeft??Y.left,kind:"text",commentThreadIndex:Q}}function Y6($,M,Z,J){let X=M.documentIndex.regionIndex.get(Z.regionId);if(!X)return null;let Y=O9(Z.regionId,Z.offset,J),Q=Y!==null?E9(Y,$,M,J):null,K=X.inlines.find((q)=>Z.offset>=q.start&&Z.offset<=q.end)??null;if(K?.link){let q=Q6($,M,Z.regionId,K.start);if(!q)return null;return{anchorBottom:Q?.anchorBottom??q.anchorBottom,anchorLeft:Q?.anchorLeft??q.anchorLeft,commentThreadIndex:Y,endOffset:K.end,kind:"link",regionId:Z.regionId,startOffset:K.start,title:K.link.title,url:K.link.url}}if(Q)return{anchorBottom:Q.anchorBottom,anchorLeft:Q.anchorLeft,commentThreadIndex:Y,kind:"text"};return null}function l0($,M,Z){let J=s0(M,Z.regionId,Z.offset);if(!J)return Z.left;return Z.left+K1($,J)+DY($,J,Z.offset)}function Q1($,M,Z){return p0(M,Z)+K1($,M)}function K1($,M){let Z=o1($,M.blockId,"listItem");if(!Z)return 0;return j2($,Z.id)?.kind==="task"?bY:_Y}function C2($){return{left:$.left,size:FY,top:$.top+3}}function o1($,M,Z){let J=$.documentIndex.blockIndex.get(M)??null;while(J){if(J.type===Z)return J;let X=J.parentBlockId;J=X?$.documentIndex.blockIndex.get(X)??null:null}return null}function j2($,M){return $.documentIndex.listItemMarkers.get(M)??null}function O9($,M,Z){for(let J of Z)if(J.regionId===$&&M>=J.startOffset&&M<=J.endOffset)return J.threadIndex;return null}function E9($,M,Z,J){let X=J.find((Y)=>Y.threadIndex===$);if(!X)return null;return Q6(M,Z,X.regionId,X.startOffset)}function Q6($,M,Z,J){let X=s0($,Z,J);if(!X)return null;return{anchorBottom:X.top+X.height,anchorLeft:p0(X,J)+K1(M,X)}}function DY($,M,Z){if(Z<=M.end)return 0;let J=$.documentIndex.regionIndex.get(M.regionId);if(!J)return 0;let X=J.text.slice(M.end,Z);if(!/^[ \t]+$/u.test(X))return 0;return T9(X,M.font)}function HY($,M){for(let[J,X]of $.regionBounds)if(M.x>=X.left&&M.x<=X.right&&M.y>=X.top&&M.y<=X.bottom)return A5($,J,M.y)?.line??null;let Z=t8($,M)?.line??null;if(Z)return Z;for(let J of $.blocks)if(M.y>=J.top&&M.y<=J.bottom){for(let X=$.lines.length-1;X>=0;X--)if($.lines[X].blockId===J.id)return $.lines[X]}return null}function PY($,M){return $.lines.find((Z)=>M.y>=Z.top-4&&M.y<=Z.top+Z.height+4)??$.lines.filter((Z)=>Math.abs(M.y-(Z.top+Z.height/2))<=10).sort((Z,J)=>Math.abs(M.y-(Z.top+Z.height/2))-Math.abs(M.y-(J.top+J.height/2)))[0]??null}function K6($,M){return $.documentIndex.regionIndex.get(M)??null}function zY($){return $.lines[0]?.top??0}function TY($,M){let Z=M,J=M;while(Z>0&&/\w/.test($[Z-1]??""))Z-=1;while(J<$.length&&/\w/.test($[J]??""))J+=1;return{end:J,start:Z}}function q6($,M,Z,J=null){let X={height:M.height,overscan:Math.max(160,M.height),top:M.top},Y=$6($.documentIndex,M,X,[$.selection.anchor.regionId,$.selection.focus.regionId],Z,J);return{blockMap:E2($.documentIndex.document.blocks),estimateRegionBounds:Y.estimateRegionBounds,regionBounds:new Map(Y.layout.regionBounds),layout:Y.layout,paintHeight:Math.max(240,X.height+X.overscan*2),paintTop:Math.max(0,X.top-X.overscan),totalHeight:Y.totalHeight,viewport:{height:X.height,top:X.top}}}function F5($,M,Z){return w0(M.layout,$,Z)??M6(M.layout,$,Z)}function R2($,M,Z,J){return Z6(M.layout,$,Z,J)}function U6($,M,Z){return J6(M.layout,$,Z)}function N6($,M,Z,J){return X6(M.layout,$,Z,J)}function A6($,M,Z,J){return Y6(M.layout,$,Z,J)}function G6($,M,Z){return I0(M.layout,$.documentIndex,Z)}function o0($,M,Z){let J=I0(M.layout,$.documentIndex,Z);if(!J)return null;return{...J,left:l0($,M.layout,J)}}function C9($,M,Z,J,X){let Y=J-Z,Q=X-Y;if(J<=$)return{end:M+Q,start:$+Q};if(Z>=M)return{end:M,start:$};let K=Math.max(0,Math.min(Z,M)-$),q=Math.max(0,M-Math.max(J,$)),U=$<Z?$:Z;return{end:U+K+X+q,start:U}}function _6($,M,Z){let J=Z.trim();if(J.length===0||M.startOffset===M.endOffset)return null;let X=$.regionIndex.get(M.regionId)??null,Y=X?B6($,X):null;if(!Y)return null;return R8({anchor:z2(Y,M.startOffset,M.endOffset),body:J,quote:T2(Y,M.startOffset,M.endOffset)})}function k0($){let M="documentIndex"in $?$.documentIndex:$,Z=b5(M),J=M.document.comments,X=[...J],Y=[];for(let[Q,K]of J.entries()){let q=y2(K,M.document);if(!q.match)continue;let N=Z.findBySemanticMatch(q.match.containerId,q.match.containerOrdinal)?.runtimeContainer??null;if(!N)continue;if(q.repair)X[Q]={...K,anchor:q.repair.anchor,quote:q.repair.quote};Y.push({endOffset:q.match.endOffset,resolution:q,regionId:N.id,resolved:K.resolvedAt!=null,startOffset:q.match.startOffset,threadIndex:Q})}return{liveRanges:Y,threads:X}}function F6($,M,Z,J,X,Y){if($.document.comments.length===0)return M.document.comments;let Q=$.commentContainerIndex.get(Z.semanticRegionId)??[],K=new Set(Q);if(Q.length===0)return M.document.comments;let q=k0($),U=new Map(q.liveRanges.map((B)=>[B.threadIndex,B])),N=B6($,Z),A=n1(M,Z.path),G=A?B6(M,A):null;if(!N||!G)return M.document.comments;return M.document.comments.map((B,F)=>{if(!K.has(F))return B;let _=U.get(F),D=_?.resolution.match??null;if(!_||!D||D.containerId!==N.id)return B;let T=C9(D.startOffset,D.endOffset,J,X,Y.length);return{...B,anchor:z2(G,T.start,T.end),quote:T2(G,T.start,T.end)}})}function B6($,M){let Z=yY($,M);if(!Z)return null;return{containerKind:Z,containerOrdinal:-1,id:M.semanticRegionId,text:M.text}}function yY($,M){if($.tableCellIndex.has(M.id))return"tableCell";return w$(M.blockType)}function D5($,M){if(M.length===0)return[];let Z=b5($),J=Z.list();return M.map((X)=>({...X,cursorPoint:WY(X,J,Z),viewport:null}))}function WY($,M,Z){if(!$.cursor)return null;let J=VY(M,$.cursor),X=wY(J,$.cursor);if(X.length!==1)return null;let Y=X[0],Q=Z.resolveRuntimeContainer(Y.container.id);if(!Q)return null;return{offset:Math.max(0,Math.min(Y.offset,Q.text.length)),regionId:Q.id}}function VY($,M){return M.kind?$.filter((Z)=>Z.containerKind===M.kind):$}function wY($,M){if(M.prefix&&M.suffix)return OY($,M.prefix,M.suffix);if(M.prefix)return j9($,M.prefix,"after");if(M.suffix)return j9($,M.suffix,"before");return[]}function j9($,M,Z){let J=[];for(let X of $)for(let Y of g0(X.text,M))J.push({container:X,offset:Z==="after"?Y+M.length:Y});return J}function OY($,M,Z){let J=[];for(let X of $)for(let Y of p1(X.text,M,Z))J.push({container:X,offset:Y.startOffset});return J}var EY=48;function L2($,M,Z){let J="documentIndex"in $?$.documentIndex:$;if(Z.length===0)return[];return Z.map((X)=>({...X,viewport:CY(J,M,X)}))}function CY($,M,Z){if(!Z.cursorPoint)return{status:"unresolved"};let J=I0(M.layout,$,Z.cursorPoint),X=J?{bottom:J.top+J.height,top:J.top}:M.estimateRegionBounds(Z.cursorPoint.regionId);if(!X)return{status:"unresolved"};return{scrollTop:RY(M,X),status:jY(M,X)}}function jY($,M){let Z=$.viewport.top,J=Z+$.viewport.height;if(M.bottom<Z)return"above";if(M.top>J)return"below";return"visible"}function RY($,M){let Z=Math.max(0,$.totalHeight-$.viewport.height),J=M.top-Math.min(EY,$.viewport.height/4);return Math.max(0,Math.min(Z,J))}function b5($){let M=J5($.document),Z=new Map(M.map((X)=>[X.id,X])),J=new Map($.regions.map((X)=>[X.semanticRegionId,X]));return{findBySemanticMatch(X,Y){let Q=Z.get(X)??M[Y]??null;if(!Q)return null;return{runtimeContainer:J.get(Q.id)??null,semanticContainer:Q}},list(X){return X?M.filter((Y)=>Y.containerKind===X):M},resolveRuntimeContainer(X){return J.get(X)??null}}}var k2="",R9=1e6;function f2($,M,Z){return`${$}:${M}:${Z}`}function K0($){let M=[];for(let Z of $){let J=M.at(-1);if(J?.type==="text"&&Z.type==="text"&&J.marks.join(",")===Z.marks.join(",")){M[M.length-1]=z0({marks:J.marks,path:J.id,text:J.text+Z.text});continue}M.push(Z)}return M}function t1($){let M=aY($),Z=D6(M.blocks.map((J,X)=>S2(J,X)));return H6(M,Z)}function S2($,M){let Z=[],J=[],X=[],Y=0;function Q(q,U,N,A,G=null){if(J.length>0)X.push(`
|
|
20
|
-
`),
|
|
21
|
-
${M.text}`:M.text}function
|
|
22
|
-
`)}function
|
|
23
|
-
`});break;case"image":X({id:
|
|
24
|
-
`.slice(M,Z);case"image":return k2.slice(M,Z);case"inlineCode":return $.code.slice(M,Z);case"link":return z6($.children,M,Z);case"text":return $.text.slice(M,Z);case"unsupported":return $.source.slice(M,Z)}}function y6($,M,Z,J){let X=nY($.children,M,Z,J);if(X===null)return null;let Y=K0(S9($.children,M,Z,J,X,`${$.path}.children`));return Y.length>0?q1($,Y,M,Z):null}function W6($,M,Z){let J=0,X=null,Y=(Q)=>{for(let K of Q){let q=H0(K),U=J,N=U+q;if(J=N,Z<=U||M>=N)continue;if(K.type==="text"){let A=Math.max(M,U);if(Math.min(Z,N)>A)X=X===null?new Set(K.marks):new Set(K.marks.filter((B)=>X?.has(B)));continue}if(K.type==="link"){let A=J;J=U,Y(K.children),J=A}}};return Y($.children),X?[...X]:[]}function nY($,M,Z,J){let X=0,Y=!1,Q=!0,K=(q)=>{for(let U of q){let N=H0(U),A=X,G=A+N;if(X=G,Z<=A||M>=G)continue;if(U.type==="text"){let B=Math.max(M,A);if(Math.min(Z,G)>B)Y=!0,Q&&=U.marks.includes(J);continue}if(U.type==="link"){let B=X;X=A,K(U.children),X=B}}};return K($),Y?Q:null}function S9($,M,Z,J,X,Y){let Q=[],K=0;for(let[q,U]of $.entries()){let N=K,A=H0(U),G=N+A,B=`${Y}.${q}`;if(K=G,Z<=N||M>=G){Q.push(U);continue}if(U.type==="text"){Q.push(...tY(U,Math.max(0,M-N),Math.min(A,Z-N),J,X,B));continue}if(U.type==="link"){let F=K0(S9(U.children,Math.max(0,M-N),Math.min(A,Z-N),J,X,`${B}.children`));if(F.length>0)Q.push({...U,children:F});continue}Q.push(U)}return Q}function tY($,M,Z,J,X,Y){let Q=$.text.slice(0,M),K=$.text.slice(M,Z),q=$.text.slice(Z),U=X?$.marks.filter((N)=>N!==J):eY($.marks,J);return[W1(Q,$.marks,`${Y}.before`),W1(K,U,`${Y}.selected`),W1(q,$.marks,`${Y}.after`)].filter(Boolean)}function eY($,M){return $.includes(M)?$:[...$,M].sort()}function V6($,M,Z){let J=K0($Q($.children,M,Z,`${$.path}.children`));return J.length>0?q1($,J,M,Z):null}function $Q($,M,Z,J){let X=v9($,M,Z);if(X)return u9($,M,Z,X.code,J,!1);let Y=z6($,M,Z);if(Y.length===0)return $;return u9($,M,Z,Y,J,!0)}function v9($,M,Z){let J=0;for(let X of $){let Y=H0(X),Q=J,K=Q+Y;if(J=K,M===Q&&Z===K&&X.type==="inlineCode")return X;if(X.type==="link"){let q=v9(X.children,Math.max(0,M-Q),Math.min(Y,Z-Q));if(q)return q}}return null}function u9($,M,Z,J,X,Y){let Q=[],K=0,q=!1;for(let[U,N]of $.entries()){let A=`${X}.${U}`,G=H0(N),B=K,F=B+G;if(K=F,Z<=B||M>=F){Q.push(N);continue}if(!q){Q.push(...z5(N,Math.max(0,M-B),A));let _=Y?T6(J,`${X}.selected`):W1(J,[],`${X}.selected`);if(_)Q.push(_);q=!0}Q.push(...T5(N,Math.min(G,Z-B),A))}return Q}function y5($,M,Z,J,X){return v2($,M,Z,J,(Y,Q,K)=>h9(Y,Q,K,X))}function h9($,M,Z,J){let X=K0(MQ($.children,M,Z,J,`${$.path}.children`)??[]);return X.length>0?q1($,X,M,Z):null}function MQ($,M,Z,J,X){let Y=[],Q=0,K=!1;for(let[q,U]of $.entries()){let N=`${X}.${q}`,A=H0(U),G=Q,B=G+A;if(Q=B,!K&&U.type==="link"&&M===G&&Z===B){if(J===null)Y.push(...U.children);else Y.push(S1({children:U.children,path:N,title:U.title,url:J}));K=!0;continue}Y.push(U)}return K?Y:null}function w6($,M,Z){let J=K0(ZQ($.children,M,Z,`${$.path}.children`));return q1($,J,M+1,M+1)}function ZQ($,M,Z,J){let X=[],Y=0,Q=!1;for(let[K,q]of $.entries()){let U=`${J}.${K}`,N=H0(q),A=Y,G=A+N;if(Y=G,Z<=A||M>=G){X.push(q);continue}if(!Q)X.push(...z5(q,Math.max(0,M-A),U)),X.push(D2({path:`${J}.selected`})),Q=!0;X.push(...T5(q,Math.min(N,Z-A),U))}if(!Q)X.push(D2({path:`${J}.selected`}));return X}function $0($,M,Z=0){return{childIndices:M,kind:"descendant-primary-region",offset:Z,rootIndex:$}}function t($,M=0){return{kind:"root-primary-region",offset:M,rootIndex:$}}function U1($,M,Z,J=0){return{cellIndex:Z,kind:"table-cell",offset:J,rootIndex:$,rowIndex:M}}function n0($,M){return $.regionIndex.get(M)??null}function n1($,M){return $.regionPathIndex.get(M)??null}function $2($,M,Z,J){let X=$.tableCellRegionIndex.get(f2(M,Z,J));return X?$.regionIndex.get(X)??null:null}function JQ($){return $.anchor.regionId===$.focus.regionId&&$.anchor.offset===$.focus.offset}function s($,M){let Z="documentIndex"in $?$.documentIndex:$,J="documentIndex"in $?$.selection:M,X=JQ(J),Y=g9(Z,J.anchor),Q=g9(Z,J.focus);if(Y<=Q)return{collapsed:X,end:J.focus,start:J.anchor};return{collapsed:X,end:J.anchor,start:J.focus}}function h2($,M){if(!M)return null;if("kind"in M){if(M.kind==="root-primary-region"){let J=$.document.blocks[M.rootIndex],X=J?O6($,J):null;return X?W5(X.id,V5(X.text,M.offset)):null}if(M.kind==="descendant-primary-region"){let J=$.document.blocks[M.rootIndex],X=J?XQ(J,M.childIndices):null,Y=X?O6($,X):null;return Y?W5(Y.id,V5(Y.text,M.offset)):null}if(M.kind==="table-cell"){let J=$.document.blocks[M.rootIndex];if(!J||J.type!=="table")return null;let X=$2($,J.id,M.rowIndex,M.cellIndex);return X?W5(X.id,V5(X.text,M.offset)):null}let Z=n1($,M.path);if(!Z)return null;if(M.kind==="region-path")return W5(Z.id,V5(Z.text,M.offset));return{anchor:{regionId:Z.id,offset:Math.max(0,Math.min(M.startOffset,Z.text.length))},focus:{regionId:Z.id,offset:Math.max(0,Math.min(M.endOffset,Z.text.length))}}}return M}function g9($,M){let Z=$.regionOrderIndex.get(M.regionId);if(Z===void 0)throw Error(`Unknown canvas region: ${M.regionId}`);return Z*R9+M.offset}function W5($,M){let Z={offset:M,regionId:$};return{anchor:Z,focus:Z}}function V5($,M){return M==="end"?$.length:Math.max(0,Math.min(M,$.length))}function XQ($,M){let Z=$;for(let J of M){if(!Z)return null;let X=I9(Z);if(!X)return null;Z=X[J]??null}return Z}function O6($,M){let Z=$.blockIndex.get(M.id);if(!Z)return null;let J=Z.regionIds[0];if(J)return $.regionIndex.get(J)??null;let X=I9(M);if(!X)return null;for(let Y of X){let Q=O6($,Y);if(Q)return Q}return null}function I9($){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,Z=M?$.documentIndex.blockIndex.get(M.blockId)??null:null,J=$.selection.anchor.offset,X=M?.inlines.find((Y)=>J>Y.start&&J<Y.end)??M?.inlines.find((Y)=>Y.end===J)??M?.inlines.find((Y)=>Y.start===J)??null;return{block:Z?{blockId:Z.id,depth:Z.depth,nodeType:Z.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 w5($){let M=s($.documentIndex,$.selection);if(M.start.regionId!==M.end.regionId||M.start.offset===M.end.offset)return[];let Z=$.documentIndex.regionIndex.get(M.start.regionId);if(!Z)return[];let J=l1($.documentIndex.document.blocks,Z.blockId);if(!J)return[];let X=P5(J,Z.path,Z.semanticRegionId);return X?W6(X,M.start.offset,M.end.offset):[]}function O5($,M,Z,J=null){return M2($,M,1,[Z],J)}function M2($,M,Z,J,X=null){return{document:g1($.document,M,Z,J),selection:X}}function E5($,M,Z,J=null){return I2($,M,()=>Z,J)}function I2($,M,Z,J=null){let X=$.blockIndex.get(M);if(!X)return null;let Y=$.document.blocks[X.rootIndex];if(!Y)return null;let Q=p9(Y,M,Z);return Q?M2($,X.rootIndex,1,[Q],J):null}function p9($,M,Z){if($.id===M)return Z($);switch($.type){case"blockquote":{let J=E6($.children,M,Z);return J?T0({children:J}):null}case"listItem":{let J=E6($.children,M,Z);return J?V0($,J):null}case"list":{let J=E6($.items,M,Z);return J?o($,J):null}default:return null}}function E6($,M,Z){let J=!1,X=$.map((Y)=>{let Q=p9(Y,M,Z);if(!Q)return Y;return J=!0,Q});return J?X:null}function j5($,M,Z){let J=s($,M);if(J.start.regionId===J.end.regionId)return YQ($,J,Z);return UQ($,J,Z)}function YQ($,M,Z){let J=n0($,M.start.regionId);if(!J)throw Error(`Unknown region: ${M.start.regionId}`);let X=I2($,J.blockId,(U)=>QQ(U,J,M.start.offset,M.end.offset,Z));if(!X)throw Error(`Failed to replace block for canvas region: ${J.id}`);let Y=e1($,X.document,J.rootIndex,1),Q=$.document.comments.length===0?Y:i9($,Y,J,M.start.offset,M.end.offset,Z),K=n1(Q,J.path);if(!K)throw Error(`Failed to remap region after replacement: ${J.path}`);let q=M.start.offset+Z.length;return{documentIndex:Q,selection:s9(K.id,q)}}function QQ($,M,Z,J,X){switch($.type){case"heading":case"paragraph":return KQ($,M,Z,J,X);case"code":return e4($,l9(M,Z,J,X));case"table":return qQ($,M,Z,J,X);case"unsupported":return $5($,l9(M,Z,J,X));default:throw Error(`Canvas text replacement is not supported for block type: ${$.type}`)}}function KQ($,M,Z,J,X){let Y=l2(M.inlines,Z,J,X),Q=R5(Y);return R0($,Q)}function qQ($,M,Z,J,X){let Y=M.tableCellPosition?.rowIndex,Q=M.tableCellPosition?.cellIndex;if(Y===void 0||Q===void 0)throw Error(`Unable to resolve table cell position for region: ${M.id}`);let K=l2(M.inlines,Z,J,X),q=R5(K),U=$.rows.map((N,A)=>{if(A!==Y)return N;let G=N.cells.map((B,F)=>{if(F!==Q)return B;return M1({children:q})});return{...N,cells:G}});return h0($,U)}function l9($,M,Z,J){return l2($.inlines,M,Z,J).map((X)=>X.text).join("")}function p2($){return $!==null&&($.type==="heading"||$.type==="paragraph")}function UQ($,M,Z){let J=n0($,M.start.regionId),X=n0($,M.end.regionId);if(!J||!X)throw Error("Unknown cross-region selection endpoints.");let Y=$.document.blocks[J.rootIndex],Q=$.document.blocks[X.rootIndex];if(!Y||!Q)throw Error("Unknown root blocks for cross-region selection.");let K=x9(Y,J,M.start.offset),q=d9(Q,X,M.end.offset),U=NQ(K,q,Z),N=U.blocks.length>0?U.blocks:[p({text:""})],A=J.rootIndex,G=X.rootIndex-J.rootIndex+1,B=g1($.document,A,G,N),F=e1($,B,A,G),_=$.document.comments.length===0?F:i9($,F,J,M.start.offset,J.text.length,p2(K)?Z:""),D=_.roots[A+U.caretLocalIndex]?.regions[0]??null;return{documentIndex:_,selection:s9(D?.id??J.id,D?U.caretOffset:0)}}function NQ($,M,Z){if(p2($)&&p2(M))return{blocks:[AQ($,M,Z)],caretLocalIndex:0,caretOffset:$.plainText.length+Z.length};if(p2($)){let Y=[Z.length>0?GQ($,Z):$];if(M)Y.push(M);return{blocks:Y,caretLocalIndex:0,caretOffset:$.plainText.length+Z.length}}if(p2(M)){let X=Z.length>0?BQ(M,Z):M,Y=[];if($)Y.push($);let Q=Y.length;return Y.push(X),{blocks:Y,caretLocalIndex:Q,caretOffset:Z.length}}let J=[];if($)J.push($);if(Z.length>0){let X=J.length;if(J.push(p({text:Z})),M)J.push(M);return{blocks:J,caretLocalIndex:X,caretOffset:Z.length}}if(M){let X=J.length;return J.push(M),{blocks:J,caretLocalIndex:X,caretOffset:0}}return{blocks:J,caretLocalIndex:0,caretOffset:0}}function AQ($,M,Z){let J=Z.length>0?[z0({text:Z})]:[];return R0($,K0([...$.children,...J,...M.children]))}function GQ($,M){return R0($,K0([...$.children,z0({text:M})]))}function BQ($,M){return R0($,K0([z0({text:M}),...$.children]))}function x9($,M,Z){if($.type==="table")return null;if($.id===M.blockId)return _Q($,M,Z);return a9($,(J)=>bQ(J,M,Z))}function d9($,M,Z){if($.type==="table")return null;if($.id===M.blockId)return FQ($,M,Z);return a9($,(J)=>DQ(J,M,Z))}function _Q($,M,Z){if(Z===0)return null;switch($.type){case"heading":case"paragraph":{let J=l2(M.inlines,Z,M.text.length,"");return R0($,R5(J))}case"code":return e4($,M.text.slice(0,Z));case"unsupported":return $5($,M.text.slice(0,Z));default:return null}}function FQ($,M,Z){if(Z===M.text.length)return null;switch($.type){case"heading":case"paragraph":{let J=l2(M.inlines,0,Z,"");return R0($,R5(J))}case"code":return e4($,M.text.slice(Z));case"unsupported":return $5($,M.text.slice(Z));default:return null}}function a9($,M){switch($.type){case"blockquote":{let Z=M($.children);return Z.length===0?null:T0({children:Z})}case"list":{let Z=M($.items);return Z.length===0?null:o($,Z)}case"listItem":{let Z=M($.children);return Z.length===0?null:V0($,Z)}default:return null}}function bQ($,M,Z){let J=$.findIndex((Q)=>C5(Q,M));if(J===-1)return[];let X=$.slice(0,J),Y=x9($[J],M,Z);return Y?[...X,Y]:X}function DQ($,M,Z){let J=$.findIndex((Q)=>C5(Q,M));if(J===-1)return[];let X=$.slice(J+1),Y=d9($[J],M,Z);return Y?[Y,...X]:X}function C5($,M){if($.id===M.blockId)return!0;switch($.type){case"blockquote":case"listItem":return $.children.some((Z)=>C5(Z,M));case"list":return $.items.some((Z)=>C5(Z,M));default:return!1}}function i9($,M,Z,J,X,Y){let Q=F6($,M,Z,J,X,Y);return Q===M.document.comments?M:u2(M,{...M.document,comments:Q})}function s9($,M){return{anchor:{regionId:$,offset:M},focus:{regionId:$,offset:M}}}function l2($,M,Z,J){let Y=HQ($,M,Z,{didInsert:!1,generatedRunCount:0,replacementText:J});return WQ(VQ(Y))}function R5($){let M=[];for(let Z=0;Z<$.length;Z+=1){let J=$[Z];if(J.link){let Y=[],Q=J.link;while(Z<$.length&&j6($[Z].link,Q)){let K=c9($[Z]);if(K)Y.push(K);Z+=1}if(Z-=1,Y.length>0)M.push(S1({children:K0(Y),title:Q.title,url:Q.url}));continue}let X=c9(J);if(X)M.push(X)}return K0(M)}function HQ($,M,Z,J){let X=[];for(let[Y,Q]of $.entries()){if(!J.didInsert&&M===Z&&M===Q.start)C6(X,J,r9($[Y-1]??null,Q));if(Z<=Q.start||M>=Q.end){X.push(L5(Q));continue}let K=Math.max(0,M-Q.start),q=Math.min(Q.text.length,Z-Q.start),U=!J.didInsert&&J.replacementText.length>0?J.replacementText:"",N=PQ(Q,K,q,U,J);if(K!==q||U.length>0)J.didInsert=!0;X.push(...N)}if(!J.didInsert)C6(X,J,r9($.at(-1)??null,null));return X}function PQ($,M,Z,J,X){switch($.kind){case"text":case"inlineCode":case"unsupported":return zQ($,M,Z,J);case"break":return TQ($,M,Z,J,X);case"image":return yQ($,M,Z,J)}}function zQ($,M,Z,J){let X=$.text.slice(0,M)+J+$.text.slice(Z);return X.length>0?[{...L5($),text:X}]:[]}function TQ($,M,Z,J,X){if(M===Z)return[L5($)];let Y=[];if(J.length>0)C6(Y,X,$.link);return Y}function yQ($,M,Z,J){if(M===0&&Z===$.text.length)return J.length>0?[o9(J,$.link,0)]:[];return[L5($)]}function C6($,M,Z){if(M.replacementText.length===0){M.didInsert=!0;return}$.push(o9(M.replacementText,Z,M.generatedRunCount)),M.generatedRunCount+=1,M.didInsert=!0}function o9($,M,Z){return{id:`generated:${Z}`,image:null,inlineCode:!1,kind:"text",link:M,marks:[],originalType:null,text:$}}function r9($,M){return $?.link&&M?.link&&j6($.link,M.link)?$.link:null}function L5($){return{id:$.id,image:$.image,inlineCode:$.inlineCode,kind:$.kind,link:$.link,marks:$.marks,originalType:$.originalType,text:$.text}}function WQ($){let M=[],Z=0;for(let J of $){let X=Z,Y=X+J.text.length;M.push({...J,end:Y,start:X}),Z=Y}return M}function VQ($){let M=[];for(let Z of $){let J=M.at(-1);if(J&&wQ(J,Z)){M[M.length-1]={...J,text:J.text+Z.text};continue}M.push(Z)}return M}function wQ($,M){return $.kind===M.kind&&$.inlineCode===M.inlineCode&&j6($.link,M.link)&&EQ($.image,M.image)&&$.originalType===M.originalType&&$.marks.join(",")===M.marks.join(",")}function c9($){switch($.kind){case"break":return D2();case"image":return $.image?OQ($.image):null;case"inlineCode":return m1({code:$.text});case"text":return $.text.length>0?z0({marks:$.marks,text:$.text}):null;case"unsupported":return o4({originalType:$.originalType??"unsupported",source:$.text})}}function OQ($){return s4({alt:$.alt,title:$.title,url:$.url,width:$.width})}function j6($,M){return $?.url===M?.url&&$?.title===M?.title}function EQ($,M){return $?.url===M?.url&&$?.title===M?.title&&$?.alt===M?.alt&&$?.width===M?.width}function n9($,M){switch(M.kind){case"replace-block":return E5($,M.blockId,M.block,M.selection??null);case"replace-root":return O5($,M.rootIndex,M.block,M.selection??null);case"replace-root-range":return M2($,M.rootIndex,M.count,M.replacements,M.selection??null);case"replace-selection":{let Z=j5($,M.selection,M.text);return{document:Z.documentIndex.document,documentIndex:Z.documentIndex,selection:Z.selection}}}return null}var R6=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function r2($){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 k6($,M){let Z=M??jQ();return $.animations.some((J)=>Z-J.startedAt<r2(J))}function e9($,M){return f6($,M,"inserted-text-highlight",(Z)=>Z.regionPath)}function $7($,M){return N7($,M,"active-block-flash",(Z)=>Z.blockPath)}function M7($,M){return f6($,M,"deleted-text-fade",(Z)=>Z.regionPath)}function Z7($,M){return f6($,M,"punctuation-pulse",(Z)=>Z.regionPath)}function J7($,M){return N7($,M,"list-marker-pop",(Z)=>Z.blockPath)}function X7($,M,Z){let J=new Set([$,M]);for(let X of Z){if(X.endOffset<=$||X.startOffset>=M)continue;J.add(Math.max($,X.startOffset)),J.add(Math.min(M,X.endOffset))}return[...J].sort((X,Y)=>X-Y)}function Y7($,M,Z){return $.find((J)=>J.startOffset<Z&&J.endOffset>M)??null}function Q7($,M,Z){if(!M)return $;return x2(Z.insertHighlightText,$,M.progress)}function K7($,M){return x2($,"rgba(0, 0, 0, 0)",M.progress)}function f5($,M){return x2($,"rgba(0, 0, 0, 0)",M.progress)}function q7($,M){return x2(M.insertHighlightText,"rgba(0, 0, 0, 0)",$.progress)}function U7($){let M=Math.min(1,$.progress*2);return 0.1+0.9*CQ(M)}function c2($,M,Z){let J=Math.max(0,M.progress*2-1);return x2(Z.insertHighlightText,$,J)}function f6($,M,Z,J){let X=new Map;for(let Y of $.animations){if(Y.kind!==Z)continue;let Q=r2(Y),K=M-Y.startedAt;if(K>=Q)continue;let q={...Y,progress:Math.max(0,Math.min(1,K/Q))},U=J(Y),N=X.get(U);if(N)N.push(q);else X.set(U,[q])}return X}function N7($,M,Z,J){let X=new Map;for(let Y of $.animations){if(Y.kind!==Z)continue;let Q=r2(Y),K=M-Y.startedAt;if(K>=Q)continue;X.set(J(Y),{...Y,progress:Math.max(0,Math.min(1,K/Q))})}return X}function CQ($){return 1-(1-$)*(1-$)*(1-$)}function x2($,M,Z){let J=t9($),X=t9(M);return`rgba(${L6(k5(J[0],X[0],Z))}, ${L6(k5(J[1],X[1],Z))}, ${L6(k5(J[2],X[2],Z))}, ${k5(J[3],X[3],Z)})`}function jQ(){return typeof performance<"u"?performance.now():Date.now()}function t9($){let M=R6.get($);if(M)return M;let Z=RQ($)??LQ($)??kQ($)??R6.get("rgba(0, 0, 0, 0)");return R6.set($,Z),Z}function RQ($){let M=$.trim();if(!M.startsWith("#"))return null;let Z=M.slice(1);if(Z.length===3)return[Number.parseInt(`${Z[0]}${Z[0]}`,16),Number.parseInt(`${Z[1]}${Z[1]}`,16),Number.parseInt(`${Z[2]}${Z[2]}`,16),1];if(Z.length===6)return[Number.parseInt(Z.slice(0,2),16),Number.parseInt(Z.slice(2,4),16),Number.parseInt(Z.slice(4,6),16),1];return null}function LQ($){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 kQ($){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 k5($,M,Z){return $+(M-$)*Z}function L6($){return Math.round($)}function m5($,M,Z=N1()){if(M<=0)return $;let J=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!J)return $;let X=$.selection.focus.offset,Y=Math.max(0,X-M);if(X<=Y)return $;return d2($,{endOffset:X,kind:"inserted-text-highlight",regionPath:J.path,startOffset:Y,startedAt:Z})}function m6($,M,Z=N1()){if(M.text.length===0)return $;return d2($,{kind:"deleted-text-fade",regionPath:M.regionPath,startOffset:M.startOffset,startedAt:Z,text:M.text})}function S6($,M,Z=N1()){return d2($,{blockPath:M,kind:"active-block-flash",startedAt:Z})}function u6($,M=N1()){let Z=$.documentIndex.regionIndex.get($.selection.focus.regionId),J=$.selection.focus.offset-1;if(!Z||J<0||Z.text[J]!==".")return $;return d2($,{kind:"punctuation-pulse",offset:J,regionPath:Z.path,startedAt:M})}function v6($,M,Z=N1()){return d2($,{blockPath:M,kind:"list-marker-pop",startedAt:Z})}function d2($,M){let Z=S5($.animations,M.startedAt);return{...$,animations:[...Z,M]}}function S5($,M){return $.filter((Z)=>Z.startedAt+r2(Z)>M)}function N1(){return typeof performance<"u"?performance.now():Date.now()}function A7($){let M=$.documentIndex.regionIndex.get($.selection.focus.regionId);return(M?$.documentIndex.blockIndex.get(M.blockId)??null:null)?.path??""}function u5($,M){let Z=Math.max(-1/0,...$.animations.map((J)=>J.startedAt));return M.animations.some((J)=>J.startedAt>Z)}function a2($){let M=t1($),Z=B7(M);return{animations:[],documentIndex:M,future:[],history:[],selection:{anchor:Z,focus:Z}}}function i2($){let M=k0($.documentIndex);return h1(H2($.documentIndex.document.blocks),M.threads)}function a($,M){if(!M)return null;switch(M.kind){case"keep-state":return $;case"set-selection":return Z0($,M.selection);default:{let Z=n9($.documentIndex,M);if(!Z)return null;let J=fQ($,Z.document,Z.documentIndex??null),X=h2(J.documentIndex,Z.selection)??$.selection,Y=_7($,J,X);return Z0(J,X,Y)}}}function Z0($,M,Z){let J="regionId"in M?{anchor:v5($.documentIndex,M),focus:v5($.documentIndex,M)}:{anchor:v5($.documentIndex,M.anchor),focus:v5($.documentIndex,M.focus)},X={...$,selection:J};return Z??_7($,X)?S6(X,A7(X)):X}function O0($,M,Z,J){let X={regionId:M,offset:Z};return Z0($,J?{anchor:$.selection.anchor,focus:X}:X)}function fQ($,M,Z=null){let J=Z??t1(M);return{animations:S5($.animations,N1()),documentIndex:J,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:mQ(J)}}function h6($){let M=$.history.at(-1);if(!M)return $;let Z=t1(M.document);return{animations:[],documentIndex:Z,future:[{document:$.documentIndex.document,selection:$.selection},...$.future],history:$.history.slice(0,-1),selection:M.selection}}function g6($){let M=$.future[0];if(!M)return $;let Z=t1(M.document);return{animations:[],documentIndex:Z,future:$.future.slice(1),history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:M.selection}}function h5($,M,Z,J){let X=P$($.documentIndex.document,M,Z,J),Y=u2($.documentIndex,X);return{animations:S5($.animations,N1()),documentIndex:Y,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:$.selection}}function mQ($){let M=B7($);return{anchor:M,focus:M}}function B7($){return $.regions[0]?{regionId:$.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function v5($,M){let Z=n0($,M.regionId);if(!Z)return M;return{regionId:Z.id,offset:Math.max(0,Math.min(M.offset,Z.text.length))}}function _7($,M,Z){let J=G7($.documentIndex,$.selection),X=G7(M.documentIndex,Z??M.selection);return X!==null&&X!==J}function G7($,M){let Z=$.regionIndex.get(M.focus.regionId),J=Z?$.blockIndex.get(Z.blockId)??null:null;if(!Z||!J?.path)return null;return J.type==="table"?`cell:${Z.path}`:`block:${J.path}`}function n2($,M){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return{kind:"unsupported"};if(Z.blockType==="code"){let K=$.blockIndex.get(Z.blockId);return K?{kind:"code",region:Z,rootIndex:K.rootIndex}:{kind:"unsupported"}}let J=A1($,Z.id);if(J)return{kind:"tableCell",...J};let X=c0($,M);if(X)return{kind:"listItem",...X};let Y=Z2($,M);if(Y)return{kind:"blockquoteTextBlock",...Y};let Q=r0($,M);if(Q)return{kind:"rootTextBlock",...Q};return{kind:"unsupported"}}function t2($,M){let Z=$.blockIndex.get(M);if(!Z)throw Error(`Unknown root block: ${M}`);return Z.rootIndex}function g5($,M,Z){let J=M?$.blockIndex.get(M)??null:null;while(J){if(J.type===Z)return J;let X=J.parentBlockId;J=X?$.blockIndex.get(X)??null:null}return null}function s2($){let M=$.split("."),Z=[];for(let J=0;J<M.length-1;J+=1)if(M[J]==="children"){let X=Number(M[J+1]);if(Number.isInteger(X))Z.push(X)}return Z}function r0($,M){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let J=$.blockIndex.get(Z.blockId);if(!J)return null;let X=J.rootIndex,Y=$.document.blocks[X];if(!Y||Y.type!=="heading"&&Y.type!=="paragraph")return null;return{block:Y,region:Z,rootIndex:X}}function F7($,M){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let J=$.blockIndex.get(Z.blockId),X=g5($,J?.id??null,"blockquote");if(!X)return null;let Y=X.rootIndex,Q=$.document.blocks[Y];return Q?.type==="blockquote"?{quote:Q,rootIndex:Y}:null}function Z2($,M){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let J=$.blockIndex.get(Z.blockId),X=g5($,J?.id??null,"blockquote");if(!J||!X||J.parentBlockId!==X.id)return null;let Y=X.rootIndex,Q=$.document.blocks[Y];if(!Q||Q.type!=="blockquote")return null;let K=Q.children.findIndex((U)=>U.id===J.id),q=Q.children[K];if(!q||q.type!=="heading"&&q.type!=="paragraph")return null;return{block:q,blockChildIndices:s2(J.path),childIndex:K,region:Z,quote:Q,rootIndex:Y}}function o2($,M){return l1($.document.blocks,M)}function c0($,M){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let J=$.blockIndex.get(Z.blockId),X=g5($,J?.id??null,"listItem"),Y=g5($,J?.id??null,"list");if(!J||!X||!Y)return null;let Q=o2($,Y.id);if(!Q||Q.type!=="list")return null;let K=Q.items.findIndex((F)=>F.id===X.id),q=Q.items[K];if(!q)return null;let U=Y.parentBlockId?$.blockIndex.get(Y.parentBlockId)??null:null,N=U?.parentBlockId?$.blockIndex.get(U.parentBlockId)??null:null,A=U?.type==="listItem"?o2($,U.id):null,G=N?.type==="list"?o2($,N.id):null,B=G?.type==="list"&&A?G.items.findIndex((F)=>F.id===A.id):-1;return{region:Z,item:q,itemChildIndices:s2(X.path),itemIndex:K,list:Q,listChildIndices:s2(Y.path),parentItem:A?.type==="listItem"?A:null,parentItemChildIndices:U?.type==="listItem"?s2(U.path):null,parentItemIndex:B>=0?B:null,parentList:G?.type==="list"?G:null,parentListChildIndices:N?.type==="list"?s2(N.path):null,rootIndex:Y.rootIndex}}function A1($,M){let Z=$.regionIndex.get(M);if(!Z)return null;let J=$.tableCellIndex.get(Z.id),X=$.blockIndex.get(Z.blockId),Y=X?.type==="table"?$.document.blocks[X.rootIndex]:null;if(!J||!X||!Y||Y.type!=="table")return null;return{cellIndex:J.cellIndex,rootIndex:X.rootIndex,rowIndex:J.rowIndex,table:Y}}function e2($,M,Z){return d0({checked:M,children:[p({text:$})],spread:Z})}function J2($,M){let Z=$.children[0];if(!Z||Z.type!=="paragraph")return null;return V0($,[p({text:M}),...$.children.slice(1)])}function b7($,M){return M.reduce((Z,J)=>`${Z}.children.${J}`,`root.${$}`)}function D7($,M,Z){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let X=s($,M),Y=X.start.regionId===X.end.regionId&&X.start.regionId===J.id?J.text.slice(0,X.start.offset)+Z+J.text.slice(X.end.offset):Z;return SQ($,M,J.id,Y)??vQ($,M,J.id,Y)??uQ($,M,J.id,Y)??hQ($,M,J.id,Y)??pQ($,J.blockId,J.rootIndex,Y)??{kind:"replace-selection",selection:M,text:Z}}function SQ($,M,Z,J){let X=c0($,M),Y=cQ(J);if(!X||!Y||X.region.id!==Z)return null;let Q=J2(X.item,Y.text);if(!Q)return null;return{kind:"replace-block",block:o(X.list,X.list.items.map((K,q)=>q===X.itemIndex?Q:K),{ordered:Y.ordered,start:Y.ordered?1:null}),blockId:X.list.id,selection:$0(X.rootIndex,[...X.listChildIndices,X.itemIndex,0])}}function uQ($,M,Z,J){if(!p6($,M,Z))return null;if(/^\s*([-+*])\s\[( |x|X)\]\s$/.exec(J)){let Q=J.toLowerCase().includes("[x]");return I6($,M,{checked:Q,ordered:!1,start:null})}if(/^\s*[-+*]\s$/.test(J))return I6($,M,{checked:null,ordered:!1,start:null});let Y=/^\s*(\d+)\.\s$/.exec(J);if(Y)return I6($,M,{checked:null,ordered:!0,start:Number(Y[1])});return null}function vQ($,M,Z,J){let X=r0($,M),Y=xQ(J);if(!X||X.region.id!==Z||X.block.type!=="heading"||!Y)return null;return{kind:"replace-root",block:$1({depth:Y.depth,text:Y.text}),rootIndex:X.rootIndex,selection:t(X.rootIndex)}}function hQ($,M,Z,J){return gQ($,M,Z,J)??IQ($,M,Z,J)}function gQ($,M,Z,J){if(!p6($,M,Z))return null;let X=/^(#{1,6})\s$/.exec(J);if(!X)return null;return lQ($,M,X[1].length)}function IQ($,M,Z,J){if(!p6($,M,Z)||!/^>\s$/.test(J))return null;return rQ($,M)}function pQ($,M,Z,J){if(!/^(?:(?:-\s?){3}|(?:\*\s?){3}|(?:_\s?){3})$/.test(J))return null;return{kind:"replace-root-range",count:1,replacements:[n4(),p({text:""})],rootIndex:t2($,M),selection:t(Z+1)}}function I6($,M,Z){let J=t2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:P1({items:[d0({checked:Z.checked,children:[p({text:""})],spread:!1})],ordered:Z.ordered,spread:!1,start:Z.start}),rootIndex:J,selection:$0(J,[0,0])}}function lQ($,M,Z){let J=t2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:$1({depth:Z,text:""}),rootIndex:J,selection:t(J)}}function rQ($,M){let Z=t2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:T0({children:[p({text:""})]}),rootIndex:Z,selection:$0(Z,[0])}}function p6($,M,Z){let J=r0($,M);return J?.region.id===Z&&J.block.type==="paragraph"}function cQ($){let M=/^[-+*]\s(.+)$/.exec($);if(M)return{ordered:!1,text:M[1]};let Z=/^\d+\.\s(.+)$/.exec($);if(Z)return{ordered:!0,text:Z[1]};return null}function xQ($){let M=/^(#{1,6})\s(.+)$/.exec($);return M?{depth:M[1].length,text:M[2]}:null}function H7($,M){let Z=s($,M);if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let J=c0($,M);if(!J)return null;let X=J.region.text,Y=J.item,Q=typeof Y.checked==="boolean"?!1:Y.checked;if(Z.start.offset===0){let A=e2("",Q,Y.spread);return{kind:"replace-block",block:o(J.list,[...J.list.items.slice(0,J.itemIndex),A,Y,...J.list.items.slice(J.itemIndex+1)]),blockId:J.list.id,listItemInsertedPath:I5(A,J.rootIndex,[...J.listChildIndices,J.itemIndex]),selection:$0(J.rootIndex,[...J.listChildIndices,J.itemIndex,0])}}if(Z.start.offset===X.length){let A=e2("",Q,Y.spread);return{kind:"replace-block",block:o(J.list,[...J.list.items.slice(0,J.itemIndex+1),A,...J.list.items.slice(J.itemIndex+1)]),blockId:J.list.id,listItemInsertedPath:I5(A,J.rootIndex,[...J.listChildIndices,J.itemIndex+1]),selection:$0(J.rootIndex,[...J.listChildIndices,J.itemIndex+1,0])}}let K=X.slice(0,Z.start.offset),q=X.slice(Z.start.offset),U=e2(q,Q,Y.spread),N=V0(Y,[p({text:K})]);return{kind:"replace-block",block:o(J.list,[...J.list.items.slice(0,J.itemIndex),N,U,...J.list.items.slice(J.itemIndex+1)]),blockId:J.list.id,listItemInsertedPath:I5(U,J.rootIndex,[...J.listChildIndices,J.itemIndex+1]),selection:$0(J.rootIndex,[...J.listChildIndices,J.itemIndex+1,0])}}function P7($,M){let Z=s($,M),J=c0($,M);if(!J||Z.start.regionId!==Z.end.regionId)return null;if(Z.start.offset!==0||J.region.text.length!==0)return H7($,M);if(J.parentItem&&J.parentItemIndex!==null&&J.parentItemChildIndices&&J.parentList&&J.parentListChildIndices)return dQ(J);let X=J.list.items.slice(0,J.itemIndex),Y=J.list.items.slice(J.itemIndex+1),Q=[];if(X.length>0)Q.push(o(J.list,X));if(Q.push(p({text:""})),Y.length>0)Q.push(o(J.list,Y));return{kind:"replace-root-range",count:1,replacements:Q,rootIndex:J.rootIndex,selection:t(J.rootIndex+(X.length>0?1:0))}}function z7($,M){let Z=c0($,M);if(!Z)return null;if(typeof Z.item.checked==="boolean"){let J=d0({checked:null,children:Z.item.children,spread:Z.item.spread});return{kind:"replace-block",block:o(Z.list,Z.list.items.map((X,Y)=>Y===Z.itemIndex?J:X)),blockId:Z.list.id}}if(Z.itemIndex>0){let J=Z.list.items[Z.itemIndex-1];if(!J)return null;if(Z.item.plainText.length===0)return{kind:"replace-block",block:o(Z.list,Z.list.items.filter((Y,Q)=>Q!==Z.itemIndex)),blockId:Z.list.id,selection:$0(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex-1,0],"end")};let X=J2(J,`${J.plainText}${Z.item.plainText}`);if(!X)return null;return{kind:"replace-block",block:o(Z.list,Z.list.items.flatMap((Y,Q)=>{if(Q===Z.itemIndex-1)return[X];if(Q===Z.itemIndex)return[];return[Y]})),blockId:Z.list.id,selection:$0(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex-1,0],"end")}}return{kind:"replace-root-range",count:1,replacements:[p({text:Z.item.plainText})],rootIndex:Z.rootIndex,selection:t(Z.rootIndex)}}function T7($,M){let Z=c0($,M);if(!Z||Z.itemIndex===0)return null;let J=Z.list.items[Z.itemIndex-1];if(!J)return null;let X=aQ(J,Z.item,Z);return{kind:"replace-block",block:o(Z.list,Z.list.items.flatMap((Y,Q)=>{if(Q===Z.itemIndex-1)return[X.item];if(Q===Z.itemIndex)return[];return[Y]})),blockId:Z.list.id,selection:$0(Z.rootIndex,X.regionChildIndices)}}function y7($,M){let Z=c0($,M);if(!Z||!Z.parentItem||Z.parentItemIndex===null||!Z.parentItemChildIndices||!Z.parentList||!Z.parentListChildIndices)return null;let J=Z.list.items.filter((Q,K)=>K!==Z.itemIndex),X=Z.parentItem.children.flatMap((Q)=>{if(Q.type!=="list"||Q.id!==Z.list.id)return[Q];if(J.length===0)return[];return[o(Z.list,J)]}),Y=V0(Z.parentItem,X);return{kind:"replace-block",block:o(Z.parentList,[...Z.parentList.items.slice(0,Z.parentItemIndex),Y,Z.item,...Z.parentList.items.slice(Z.parentItemIndex+1)]),blockId:Z.parentList.id,selection:$0(Z.rootIndex,[...Z.parentListChildIndices,Z.parentItemIndex+1,0])}}function l6($,M,Z){let J=c0($,M);if(!J)return null;let X=J.itemIndex+Z;if(X<0||X>=J.list.items.length)return null;let Y=[...J.list.items],[Q]=Y.splice(J.itemIndex,1);if(!Q)return null;return Y.splice(X,0,Q),{kind:"replace-block",block:o(J.list,Y),blockId:J.list.id,selection:$0(J.rootIndex,[...J.listChildIndices,X,0])}}function dQ($){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let M=$.list.items.filter((Q,K)=>K!==$.itemIndex),Z=$.parentItem.children.flatMap((Q)=>{if(Q.type!=="list"||Q.id!==$.list.id)return[Q];if(M.length===0)return[];return[o($.list,M)]}),J=V0($.parentItem,Z),X=typeof $.parentItem.checked==="boolean"?!1:$.parentItem.checked,Y=e2("",X,$.parentItem.spread);return{kind:"replace-block",block:o($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),J,Y,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,listItemInsertedPath:I5(Y,$.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1]),selection:$0($.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1,0])}}function I5($,M,Z){return typeof $.checked==="boolean"?void 0:b7(M,Z)}function aQ($,M,Z){let J=$.children.findIndex((Y)=>Y.type==="list"&&Y.ordered===Z.list.ordered&&Y.start===Z.list.start);if(J>=0){let Y=$.children[J];if(!Y||Y.type!=="list")return{item:$,regionChildIndices:[...Z.listChildIndices,Z.itemIndex-1,0]};return{item:V0($,$.children.map((Q,K)=>K===J?o(Y,[...Y.items,M]):Q)),regionChildIndices:[...Z.listChildIndices,Z.itemIndex-1,J,Y.items.length,0]}}let X=P1({items:[M],ordered:Z.list.ordered,spread:Z.list.spread,start:Z.list.start});return{item:V0($,[...$.children,X]),regionChildIndices:[...Z.listChildIndices,Z.itemIndex-1,$.children.length,0,0]}}function p5($,M){let Z=s($,M);if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let J=r0($,M);if(!J)return iQ($,M);let X=J.region.text.slice(0,Z.start.offset),Y=J.region.text.slice(Z.start.offset),Q=Z.start.offset===0&&J.region.text.length>0?J.rootIndex:J.rootIndex+1;if(J.block.type==="paragraph")return{kind:"replace-root-range",count:1,replacements:Z.start.offset===0?[p({text:""}),J.block]:Z.start.offset===J.region.text.length?[J.block,p({text:""})]:[p({text:X}),p({text:Y})],rootIndex:J.rootIndex,selection:t(Q)};return{kind:"replace-root-range",count:1,replacements:Z.start.offset===0?[p({text:""}),J.block]:Z.start.offset===J.region.text.length?[J.block,p({text:""})]:[$1({depth:J.block.depth,text:X}),p({text:Y})],rootIndex:J.rootIndex,selection:t(Q)}}function iQ($,M){let Z=s($,M);if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let J=Z2($,M);if(!J)return null;let X=J.region.text,Y=X.slice(0,Z.start.offset),Q=X.slice(Z.start.offset),K=J.block.type==="heading"?$K(J.block,Y,Q,J.blockChildIndices,Z.start.offset,X.length):eQ(J.block,Y,Q,J.blockChildIndices,Z.start.offset,X.length);return{kind:"replace-root",block:T0({children:[...J.quote.children.slice(0,J.childIndex),...K.blocks,...J.quote.children.slice(J.childIndex+1)]}),rootIndex:J.rootIndex,selection:$0(J.rootIndex,K.focusChildIndices)}}function W7($,M){let Z=s($,M);if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==0||Z.end.offset!==0)return null;let J=Z2($,M);if(!J||J.region.text.length!==0||J.block.type!=="paragraph")return null;let X=J.quote.children.slice(0,J.childIndex),Y=J.quote.children.slice(J.childIndex+1),Q=[];if(X.length>0)Q.push(T0({children:X}));if(Q.push(p({text:""})),Y.length>0)Q.push(T0({children:Y}));return{kind:"replace-root-range",count:1,replacements:Q,rootIndex:J.rootIndex,selection:t(J.rootIndex+(X.length>0?1:0))}}function V7($,M){let Z=s($,M);if(Z.start.regionId!==Z.end.regionId||Z.start.regionId!==M.anchor.regionId)return null;let J=$.regionIndex.get(Z.start.regionId);if(!J||J.blockType!=="code")return null;return{kind:"replace-selection",selection:M,text:`
|
|
25
|
-
`}}function w7($,M){let Z=s($,M);if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==0||Z.end.offset!==0)return null;let J=r0($,M),X=J?nQ(J):null;if(X)return X;if(J&&J.rootIndex>0){let q=$.document.blocks[J.rootIndex-1],U=$.document.blocks[J.rootIndex+1];if(q){if(J.block.plainText.length===0){let N=sQ(J,q,U);if(N)return N;return{kind:"replace-root-range",count:1,replacements:[],rootIndex:J.rootIndex,selection:q.type==="paragraph"||q.type==="heading"?t(J.rootIndex-1,"end"):q.type==="list"?$0(J.rootIndex-1,[q.items.length-1,0],"end"):q.type==="blockquote"?$0(J.rootIndex-1,[q.children.length-1],"end"):t(J.rootIndex-1,"end")}}if(q.type==="paragraph")return{kind:"replace-root-range",count:2,replacements:[p({text:`${q.plainText}${J.block.plainText}`})],rootIndex:J.rootIndex-1,selection:t(J.rootIndex-1,"end")};if(q.type==="heading")return{kind:"replace-root-range",count:2,replacements:[$1({depth:q.depth,text:`${q.plainText}${J.block.plainText}`})],rootIndex:J.rootIndex-1,selection:t(J.rootIndex-1,"end")};if(q.type==="list"){let N=q.items.length-1,A=q.items[N];if(A){let G=J2(A,`${A.plainText}${J.block.plainText}`);if(G)return{kind:"replace-root-range",count:2,replacements:[o(q,q.items.map((B,F)=>F===N?G:B))],rootIndex:J.rootIndex-1,selection:$0(J.rootIndex-1,[N,0],"end")}}}}}let Y=tQ($,M);if(Y)return Y;let Q=F7($,M);if(!Q)return null;let K=Z2($,M);return{kind:"replace-root-range",count:1,replacements:Q.quote.children,rootIndex:Q.rootIndex,selection:t(K?Q.rootIndex+K.childIndex:Q.rootIndex)}}function r6($,M,Z){let J=r0($,M);if(!J||J.block.type!=="heading")return null;let X=Math.max(1,Math.min(6,J.block.depth+Z));if(X===J.block.depth)return{kind:"keep-state"};return{kind:"replace-root",block:$1({depth:X,text:J.block.plainText}),rootIndex:J.rootIndex,selection:t(J.rootIndex,M.focus.offset)}}function sQ($,M,Z){if($.block.type!=="paragraph"||$.block.plainText.length!==0||M.type!=="list"||Z?.type!=="list"||!oQ(M,Z))return null;let J=M.items.length-1;return{kind:"replace-root-range",count:3,replacements:[o(M,[...M.items,...Z.items])],rootIndex:$.rootIndex-1,selection:$0($.rootIndex-1,[J,0],"end")}}function oQ($,M){return $.ordered===M.ordered&&$.start===M.start}function nQ($){if($.block.type!=="heading")return null;return{kind:"replace-root",block:p({text:$.block.plainText}),rootIndex:$.rootIndex,selection:t($.rootIndex)}}function tQ($,M){let Z=s($,M);if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==0||Z.end.offset!==0)return null;let J=Z2($,M);if(!J||J.block.type!=="paragraph"||J.region.text.length!==0)return null;if(J.quote.children.length===1)return{kind:"replace-root-range",count:1,replacements:[p({text:""})],rootIndex:J.rootIndex,selection:t(J.rootIndex)};let X=Math.max(0,J.childIndex-1),Y=J.childIndex>0?"end":0;return{kind:"replace-root",block:T0({children:J.quote.children.filter((Q,K)=>K!==J.childIndex)}),rootIndex:J.rootIndex,selection:$0(J.rootIndex,[X],Y)}}function eQ($,M,Z,J,X,Y){return{blocks:X===0?[p({text:""}),$]:X===Y?[$,p({text:""})]:[p({text:M}),p({text:Z})],focusChildIndices:X===0?J:[...J.slice(0,-1),J.at(-1)+1]}}function $K($,M,Z,J,X,Y){return{blocks:X===0?[p({text:""}),$]:X===Y?[$,p({text:""})]:[$1({depth:$.depth,text:M}),p({text:Z})],focusChildIndices:X===0?J:[...J.slice(0,-1),J.at(-1)+1]}}function O7($,M,Z){let J=r0($,M),X=Math.max(2,Z);if(!J||J.block.type!=="paragraph"||J.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:z1({rows:Array.from({length:2},()=>x6(X))}),rootIndex:J.rootIndex,selection:U1(J.rootIndex,0,0)}}function c6($,M,Z){let J=A1($,M.focus.regionId);if(!J)return null;let X=Z<0?XK(J.table,J.rowIndex,J.cellIndex):YK(J.table,J.rowIndex,J.cellIndex);if(!X)return Z>0&&QK(J.table,J.rowIndex,J.cellIndex)?MK(J):{kind:"keep-state"};let Y=J.table.rows[X.rowIndex]?.cells[X.cellIndex];if(!Y)return{kind:"keep-state"};return{kind:"set-selection",selection:JK($,M,J.table,X.rowIndex,X.cellIndex,Math.min(M.focus.offset,Y.plainText.length))}}function E7($,M){let Z=H5($,M.focus.regionId);if(!Z||Z.kind!=="tableCell")return null;let J=Math.min(M.anchor.offset,M.focus.offset),X=Math.max(M.anchor.offset,M.focus.offset),Y=w6(Z,J,X);return{kind:"replace-block",block:Y.block,blockId:Y.blockId,selection:Y.selection}}function C7($,M,Z){let J=A1($,M.focus.regionId);if(!J)return null;let X=Z==="left"?J.cellIndex:J.cellIndex+1;return X2(J,z1({align:m7(J.table.align,X,0,[null]),rows:J.table.rows.map((Y)=>u1({cells:ZK(Y.cells,X,0,[f7()])}))}),U1(J.rootIndex,J.rowIndex,X))}function j7($,M){let Z=A1($,M.focus.regionId);if(!Z)return null;let J=Math.max(0,...Z.table.rows.map((X)=>X.cells.length));if(J<=1)return null;return X2(Z,z1({align:m7(Z.table.align,Z.cellIndex,1,[]),rows:Z.table.rows.map((X)=>u1({cells:X.cells.filter((Y,Q)=>Q!==Z.cellIndex)}))}),U1(Z.rootIndex,Z.rowIndex,Math.min(Z.cellIndex,J-2)))}function R7($,M,Z){let J=A1($,M.focus.regionId);if(!J)return null;let X=Z==="above"?J.rowIndex:J.rowIndex+1,Y=Math.max(1,...J.table.rows.map((Q)=>Q.cells.length));return X2(J,h0(J.table,[...J.table.rows.slice(0,X),x6(Y),...J.table.rows.slice(X)]),U1(J.rootIndex,X,Math.min(J.cellIndex,Y-1)))}function L7($,M){let Z=A1($,M.focus.regionId);if(!Z||Z.table.rows.length<=1)return null;let J=Z.table.rows.filter((Q,K)=>K!==Z.rowIndex),X=Math.min(Z.rowIndex,J.length-1),Y=J[X]?.cells.length??1;return X2(Z,h0(Z.table,J),U1(Z.rootIndex,X,Math.min(Z.cellIndex,Y-1)))}function k7($,M){let Z=A1($,M.focus.regionId);if(!Z)return null;return X2(Z,p({text:""}),t(Z.rootIndex))}function x6($){return u1({cells:Array.from({length:$},()=>f7())})}function f7(){return M1({children:[]})}function MK($){let M=$.table.rows.length,Z=Math.max(1,...$.table.rows.map((J)=>J.cells.length));return X2($,h0($.table,[...$.table.rows,x6(Z)]),U1($.rootIndex,M,0))}function X2($,M,Z){return{kind:"replace-block",block:M,blockId:$.table.id,selection:Z}}function ZK($,M,Z,J){return[...$.slice(0,M),...J,...$.slice(M+Z)]}function m7($,M,Z,J){return[...$.slice(0,M),...J,...$.slice(M+Z)]}function JK($,M,Z,J,X,Y){let Q=$2($,Z.id,J,X);if(!Q)return M;return{anchor:{regionId:Q.id,offset:Y},focus:{regionId:Q.id,offset:Y}}}function XK($,M,Z){if(Z>0)return{cellIndex:Z-1,rowIndex:M};if(M>0){let J=$.rows[M-1];if(!J||J.cells.length===0)return null;return{cellIndex:J.cells.length-1,rowIndex:M-1}}return null}function YK($,M,Z){let J=$.rows[M];if(!J)return null;if(Z+1<J.cells.length)return{cellIndex:Z+1,rowIndex:M};let X=$.rows[M+1];if(!X||X.cells.length===0)return null;return{cellIndex:0,rowIndex:M+1}}function QK($,M,Z){let J=$.rows[M];return Boolean(J&&M===$.rows.length-1&&Z===J.cells.length-1)}function Y2($,M){let Z=D7($.documentIndex,$.selection,M),J=a($,Z);if(!J)return null;if(Z?.kind==="replace-selection"&&M.length>0)J=m5(J,M.length);if(M===".")J=u6(J);return J}function $4($){switch(n2($.documentIndex,$.selection).kind){case"code":return a($,V7($.documentIndex,$.selection));case"tableCell":return a($,E7($.documentIndex,$.selection));case"listItem":{let Z=P7($.documentIndex,$.selection);return UK({state:a($,Z)??a($,p5($.documentIndex,$.selection)),action:Z})}case"blockquoteTextBlock":return a($,W7($.documentIndex,$.selection))??a($,p5($.documentIndex,$.selection));case"rootTextBlock":return a($,p5($.documentIndex,$.selection));case"unsupported":return null}}function l5($){if(u7($))return M4($);let M=NK($);if(M)return M;let Z=s($.documentIndex,$.selection);if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==0||Z.end.offset!==0)return null;switch(n2($.documentIndex,$.selection).kind){case"listItem":return a($,z7($.documentIndex,$.selection));case"blockquoteTextBlock":case"rootTextBlock":return a($,w7($.documentIndex,$.selection));default:return null}}function r5($){if(u7($))return M4($);return AK($)}function d6($,M){return a($,{kind:"replace-selection",selection:$.selection,text:M})}function c5($,M){let Z=d6($,M);return M.length>0?m5(Z,M.length):Z}function M4($){return d6($,"")}function a6($){let M=$.documentIndex.regions,Z=M[0],J=M.at(-1);if(!Z||!J)return $;return Z0($,{anchor:{regionId:Z.id,offset:0},focus:{regionId:J.id,offset:J.text.length}})}function i6($){switch(n2($.documentIndex,$.selection).kind){case"tableCell":return a($,c6($.documentIndex,$.selection,1));case"rootTextBlock":return a($,r6($.documentIndex,$.selection,1));case"listItem":return KK($);default:return null}}function s6($){switch(n2($.documentIndex,$.selection).kind){case"tableCell":return a($,c6($.documentIndex,$.selection,-1));case"rootTextBlock":return a($,r6($.documentIndex,$.selection,-1));case"listItem":return qK($);default:return null}}function KK($){return a($,T7($.documentIndex,$.selection))}function qK($){return a($,y7($.documentIndex,$.selection))}function o6($){return a($,l6($.documentIndex,$.selection,-1))}function n6($){return a($,l6($.documentIndex,$.selection,1))}function t6($,M){return a($,O7($.documentIndex,$.selection,M))}function e6($,M){return a($,C7($.documentIndex,$.selection,M))}function $3($){return a($,j7($.documentIndex,$.selection))}function M3($,M){return a($,R7($.documentIndex,$.selection,M))}function Z3($){return a($,L7($.documentIndex,$.selection))}function J3($){return a($,k7($.documentIndex,$.selection))}function x5($,M){return S7($,(Z,J,X)=>y6(Z,J,X,M))}function X3($){return S7($,(M,Z,J)=>V6(M,Z,J))}function Z4($){return x5($,"bold")}function J4($){return x5($,"italic")}function X4($){return x5($,"strikethrough")}function Y4($){return x5($,"underline")}function Y3($,M,Z,J,X){return a($,y5($.documentIndex,M,Z,J,X))}function Q3($,M,Z,J){return a($,y5($.documentIndex,M,Z,J,null))}function K3($,M){let Z=o2($.documentIndex,M);if(!Z||Z.type!=="listItem"||typeof Z.checked!=="boolean")return null;return a($,{kind:"replace-block",block:{...Z,checked:!Z.checked},blockId:M})}function d5($){return h6($)}function a5($){return g6($)}function q3($,M,Z){let J=_6($.documentIndex,M,Z);if(!J)return null;return h5($,$.documentIndex.document.comments.length,0,[J])}function U3($,M,Z){return Q4($,M,(J)=>L8(J,{body:Z.trim()}))}function N3($,M,Z,J){return Q4($,M,(X)=>k8(X,Z,J))}function A3($,M,Z){return Q4($,M,(J)=>f8(J,Z))}function G3($,M){return Q4($,M,()=>null)}function B3($,M,Z){return Q4($,M,(J)=>m8(J,Z))}function Q4($,M,Z){let X=k0($.documentIndex).threads[M];if(!X)return null;let Y=Z(X);if(Y===X)return null;return h5($,M,1,Y?[Y]:[])}function UK($){if(!$.state||!$.action||$.action.kind!=="replace-block"||!$.action.listItemInsertedPath)return $.state;return v6($.state,$.action.listItemInsertedPath)}function S7($,M){let Z=s($.documentIndex,$.selection);if(Z.start.regionId!==Z.end.regionId||Z.start.offset===Z.end.offset)return null;return a($,v2($.documentIndex,Z.start.regionId,Z.start.offset,Z.end.offset,M))}function u7($){let M=s($.documentIndex,$.selection);return M.start.regionId!==M.end.regionId||M.start.offset!==M.end.offset}function NK($){return v7($,"backward")}function AK($){return v7($,"forward")}function v7($,M){if($.selection.anchor.regionId!==$.selection.focus.regionId||$.selection.anchor.offset!==$.selection.focus.offset)return null;let Z=n0($.documentIndex,$.selection.focus.regionId);if(!Z)return null;if(M==="forward"&&$.selection.focus.offset>=Z.text.length)return null;let J=M==="backward"?_K(Z.text,$.selection.focus.offset):$.selection.focus.offset,X=M==="backward"?$.selection.focus.offset:FK(Z.text,$.selection.focus.offset);if(J===X)return null;let Y=d6(Z0($,{anchor:{regionId:Z.id,offset:J},focus:{regionId:Z.id,offset:X}}),"");return GK($,Y,J,X)}function GK($,M,Z,J){let X=BK($,Z,J);return X?m6(M,X):M}function BK($,M,Z){let J=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!J)return null;let X=J.text.slice(M,Z);if(X.length===0)return null;if(!J.inlines.find((Q)=>Q.start<=M&&Q.end>=Z&&Q.kind==="text"&&Q.link===null&&Q.marks.length===0))return null;return{regionPath:J.path,startOffset:M,text:X}}function _K($,M){let Z=Array.from($.slice(0,M));if(Z.length===0)return 0;return M-Z.at(-1).length}function FK($,M){let Z=Array.from($.slice(M))[0];return Z?M+Z.length:$.length}var h7=1;function g7($,M,Z){let J=$.documentIndex.regionOrderIndex.get($.selection.focus.regionId);if(J===void 0)return $;let X=$.documentIndex.regions[J],Y=$.selection.focus.offset+M;if(Y>=0&&Y<=X.text.length)return O0($,X.id,Y,Z);if(M<0){let K=$.documentIndex.regions[J-1];if(!K)return $;return O0($,K.id,K.text.length,Z)}let Q=$.documentIndex.regions[J+1];if(!Q)return $;return O0($,Q.id,0,Z)}function I7($,M,Z,J,X){let Y=O2(M,Z.regionId,Z.offset);if(!Y)return $;let Q=M.lines[Y.index+J];if(!Q)return $;let K=w0(M,$,{x:l0($,M,Z)+h7,y:Q.top+Q.height/2});if(!K)return $;return O0($,K.regionId,K.offset,X)}function p7($,M,Z,J){let X=r7($,M);if(!X)return $;return O0($,X.regionId,Z==="Home"?X.start:X.end,J)}function l7($,M,Z,J,X){let Y=r7($,M);if(!Y)return $;let K=Math.max(1,Math.floor(480/M.options.lineHeight)),q=O2(M,Y.regionId,$.selection.focus.offset),U=q?M.lines[q.index+J*K]:null;if(!U)return $;let N=w0(M,$,{x:l0($,M,Z)+h7,y:U.top+U.height/2});if(!N)return $;return O0($,N.regionId,N.offset,X)}function r7($,M){return s0(M,$.selection.focus.regionId,$.selection.focus.offset)}var bK=1;function c7($,M,Z,J,X){let Y=$.documentIndex.regionIndex.get($.selection.focus.regionId)??null;if(!Y)return null;let Q=$.documentIndex.tableCellIndex.get(Y.id)??null,K=$.documentIndex.blockIndex.get(Y.blockId)??null;if(!Q||K?.type!=="table")return null;let q=DK($,K.id,Q.rowIndex+J,Q.cellIndex)??HK($,K.id,J);if(!q)return $;let U=M.regionBounds.get(Y.id),N=M.regionBounds.get(q.id);if(!U||!N)return $;let A=N.top+PK(Z.top+Z.height/2-U.top,0,Math.max(0,N.bottom-N.top-1)),G=w0(M,$,{x:l0($,M,Z)+bK,y:A});if(!G)return $;return O0($,G.regionId,G.offset,X)}function DK($,M,Z,J){return $2($.documentIndex,M,Z,J)}function HK($,M,Z){let J=$.documentIndex.blockIndex.get(M),X=$.documentIndex.regions,Y=J?$.documentIndex.roots[J.rootIndex]?.regionRange:void 0;if(!Y)return null;return Z<0?X[Y.start-1]??null:X[Y.end]??null}function PK($,M,Z){return Math.max(M,Math.min(Z,$))}function _3($,M,Z=!1){return g7($,M,Z)}function F3($,M,Z,J=!1){return zK($,M,Z,J)}function b3($,M,Z,J=!1){return TK($,M,Z,J)}function D3($,M,Z,J=!1){return p7($,M,Z,J)}function H3($,M,Z=!1){return yK($,M,Z)}function zK($,M,Z,J){let X=x7($,M);if(!X)return $;return c7($,M,X,Z,J)??I7($,M,X,Z,J)}function TK($,M,Z,J){let X=x7($,M);if(!X)return $;return l7($,M,X,Z,J)}function yK($,M,Z){let J=$.documentIndex.regions,X=M==="start"?J[0]:J.at(-1);if(!X)return $;return O0($,X.id,M==="start"?0:X.text.length,Z)}function x7($,M){return I0(M,$.documentIndex,{regionId:$.selection.focus.regionId,offset:$.selection.focus.offset})}function a7($,M,Z,J,X,Y,Q){let K=Z.image?J.images.get(Z.image.url):null,q=wK(Z,J,Q),U=OK(M,Y,Q,q);if($.fillStyle=X.imageSurfaceBackground,$.fillRect(U.left,U.top,U.width,U.height),K?.status==="loaded"&&K.source)$.drawImage(K.source,U.left,U.top,U.width,U.height);else WK($,X,{...U,status:K?.status==="error"?"error":"loading"});$.strokeStyle=X.imageSurfaceBorder,$.strokeRect(U.left,U.top,U.width,U.height)}function WK($,M,Z){let J=Z.status==="loading"?"Loading image":"Image unavailable",X=EK(Z),Y=Z.top+Z.height/2+X.size*0.9;if($.save(),$.beginPath(),$.rect(Z.left,Z.top,Z.width,Z.height),$.clip(),Z.status==="loading")VK($,M,Z);$.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(J,Z.left+Z.width/2,Y),$.restore()}function VK($,M,Z){let J=Math.max(48,Math.round(Z.width*0.22)),X=Z.width+J*2,Y=performance.now()%1800/1800,Q=Z.left-J+X*Y,K=$.createLinearGradient(Q,Z.top,Q+J,Z.top);K.addColorStop(0,"rgba(255,255,255,0)"),K.addColorStop(0.5,M.imageLoadingOverlay),K.addColorStop(1,"rgba(255,255,255,0)"),$.fillStyle=K,$.fillRect(Z.left,Z.top,Z.width,Z.height)}function wK($,M,Z){if(!$.image)return d7(Z);let J=M.images.get($.image.url);if(!J||J.intrinsicWidth<=0||J.intrinsicHeight<=0)return d7(Z);return Math.max(48,Math.round(Z*(J.intrinsicHeight/J.intrinsicWidth)))}function OK($,M,Z,J){return{height:J,left:M,top:$.top+Math.max(0,Math.floor(($.height-J)/2)),width:Z}}function EK($){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 d7($){return Math.max(48,Math.round($*0.5625))}var i7=2,s7=8,CK=3,jK=1.5,RK=2,Q2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function o7($,M,Z,J,X,Y,Q=null){if(!Z||M.start!==0)return;if(Q){let K=U7(Q),q=SK(Z,M,J,X,$);$.save(),$.translate(q.x,q.y),$.scale(K,K),$.translate(-q.x,-q.y)}if(Z.kind==="task")LK($,M,Z.checked,Y,Q);else if($.fillStyle=Q?c2(Y.listMarkerText,Q,Y):Y.listMarkerText,Z.kind==="ordered")mK($,Z.label,J,X);else $.fillText(Z.label,M.left-i7,X);if(Q)$.restore()}function LK($,M,Z,J,X=null){let Y=C2(M);if(kK($,Y,Z,J,X),!Z)return;fK($,Y,J,X)}function kK($,M,Z,J,X=null){let Y=Z?J.checkboxCheckedFill:J.checkboxUncheckedFill,Q=Z?J.checkboxCheckedStroke:J.checkboxUncheckedStroke;$.fillStyle=X?c2(Y,X,J):Y,$.strokeStyle=X?c2(Q,X,J):Q,$.beginPath(),$.lineWidth=jK,$.roundRect(M.left,M.top,M.size,M.size,CK),$.fill(),$.stroke()}function fK($,M,Z,J=null){$.strokeStyle=J?c2(Z.checkboxCheckmark,J,Z):Z.checkboxCheckmark,$.lineWidth=RK,$.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 mK($,M,Z,J){let X=$.textAlign;$.textAlign="right",$.fillText(M,Z-s7,J),$.textAlign=X}function SK($,M,Z,J,X){if($.kind==="task"){let K=C2(M);return{x:K.left+K.size/2,y:K.top+K.size/2}}let Y=X.measureText($.label),Q=J-(Y.actualBoundingBoxAscent-Y.actualBoundingBoxDescent)/2;if($.kind==="ordered")return{x:Z-s7-Y.width/2,y:Q};return{x:M.left-i7+Y.width/2,y:Q}}var uK=80;function t7({context:$,containerBounds:M,isHeaderRow:Z,lineHeight:J,theme:X}){let Y=$M(M,J);$.fillStyle=Z?X.tableHeaderBackground:X.tableBodyBackground,$.fillRect(Y.left,Y.top,Y.width,Y.height),MM($,Y,X)}function e7({activeBlockFlashes:$,activeBlockId:M,activeRegionId:Z,context:J,editorState:X,endIndex:Y,layout:Q,regionBounds:K,startIndex:q,theme:U,verticalBleed:N}){if(!M||!Z)return;let A=X.documentIndex.blockIndex.get(M)??null;if(A?.type!=="table")return;if((X.documentIndex.regionIndex.get(Z)??null)?.blockId!==M)return;let B=K.get(Z)??null,F=Q.regionLineIndices.get(Z)??null;if(!B||!F||F.length===0)return;let _=Q.lines[F[0]]??null;if(!_)return;let D=$M(B,_.height);if(D.width===0)return;let T=n7({context:J,endIndex:Y,fillStyle:U.activeBlockBackground,layout:Q,left:D.left,lineIndices:F,startIndex:q,verticalBleed:N,width:D.width}),O=A.path?$.get(A.path)??null:null;if(O)n7({context:J,endIndex:Y,fillStyle:f5(U.activeBlockFlash,O),layout:Q,left:D.left,lineIndices:F,startIndex:q,verticalBleed:N,width:D.width});if(!T)return;MM(J,D,U)}function n7({context:$,endIndex:M,fillStyle:Z,layout:J,left:X,lineIndices:Y,startIndex:Q,verticalBleed:K,width:q}){$.fillStyle=Z;let U=!1;for(let N of Y){if(N<Q)continue;if(N>=M)break;let A=J.lines[N];$.fillRect(X,A.top-K,q,A.height),U=!0}return U}function $M($,M){return{height:Math.max($.bottom-$.top,M),left:$.left,top:$.top,width:Math.max($.right-$.left,uK)}}function MM($,M,Z){$.strokeStyle=Z.tableBorder,$.strokeRect(M.left,M.top,M.width,M.height)}var P3=2,vK=3,hK=12,gK=6,IK=3,pK=1,lK=2,rK=2,cK=8,xK=12,dK=28,aK=4,iK=5,sK=2,oK=3,nK=6,ZM=3,tK=12,eK=10,$q=2,Mq=2,Zq=1,Jq=2,z3=2,JM=1.25,Xq=5,Yq=1,XM=4,Qq=4,Kq=1.5;function qq({activeBlockId:$,activeRegionId:M,activeThreadIndex:Z,containerLineBounds:J,context:X,devicePixelRatio:Y,editorState:Q,height:K,layout:q,liveCommentRanges:U,normalizedSelection:N,now:A=fq(),resources:G,runtimeBlockMap:B,theme:F,viewportTop:_,width:D}){X.save(),X.scale(Y,Y),X.clearRect(0,0,D,K),X.fillStyle=F.background,X.fillRect(0,0,D,K),X.textBaseline="alphabetic",X.translate(0,-_);let T=Uq(Q,N),{endIndex:O,startIndex:y}=e8(q,_,K),R=$7(Q,A),C=M7(Q,A),m=e9(Q,A),H=J7(Q,A),P=Z7(Q,A),E=Aq(q,Q,$,y,O),j=Nq(q,Q,B,y,O,D);for(let W=y;W<O;W+=1){let b=q.lines[W];Fq({containerLineBounds:J,context:X,editorState:Q,line:b,runtimeBlockMap:B,theme:F,width:D})}e7({activeBlockFlashes:R,activeBlockId:$,activeRegionId:M,context:X,editorState:Q,endIndex:O,layout:q,regionBounds:J,startIndex:y,theme:F,verticalBleed:P3});for(let W=y;W<O;W+=1){let b=q.lines[W];bq({activeBlockId:$,activeBlockFlashes:R,activeDeletedTextFades:C,activeThreadIndex:Z,activeInsertedTextHighlights:m,activeListMarkerPops:H,activePunctuationPulses:P,context:X,editorState:Q,line:b,liveCommentRanges:U,normalizedSelection:N,resources:G,runtimeBlockMap:B,selectionRegionOrderRange:T,theme:F,width:D})}Gq(X,j,F),Bq(X,E,F),X.restore()}function Uq($,M){let Z=$.documentIndex.regionOrderIndex,J=Z.get(M.start.regionId),X=Z.get(M.end.regionId);return J===void 0||X===void 0?null:{end:X,start:J}}function Nq($,M,Z,J,X,Y){let Q=new Map;for(let K=J;K<X;K+=1){let q=$.lines[K],U=Z.get(q.blockId);if(U?.type!=="heading"||U.depth!==1&&U.depth!==2)continue;let N=Q.get(U.id),A={bottom:q.top+q.height,left:q.left+K1(M,q),right:Y-$.options.paddingX};Q.set(U.id,N?{bottom:Math.max(N.bottom,A.bottom),left:N.left,right:N.right}:A)}return Q}function Aq($,M,Z,J,X){let Y=new Map;for(let Q=J;Q<X;Q+=1){let K=$.lines[Q],q=o1(M,K.blockId,"blockquote");if(!q)continue;let U=Y.get(q.id),N={bottom:K.top+K.height,isActive:K.blockId===Z,left:$.options.paddingX+(q.depth+1)*$.options.indentWidth-10,top:K.top};Y.set(q.id,U?{bottom:Math.max(U.bottom,N.bottom),isActive:U.isActive||N.isActive,left:U.left,top:Math.min(U.top,N.top)}:N)}return Y}function Gq($,M,Z){$.fillStyle=Z.headingRule;for(let J of M.values())$.fillRect(J.left,J.bottom+Xq,Math.max(z3,J.right-J.left),Yq)}function Bq($,M,Z){for(let J of M.values())$.fillStyle=J.isActive?Z.blockquoteRuleActive:Z.blockquoteRule,$.fillRect(J.left,J.top+vK,IK,Math.max(hK,J.bottom-J.top-gK))}function _q({context:$,devicePixelRatio:M,editorState:Z,height:J,layout:X,normalizedSelection:Y,presence:Q,showCaret:K,theme:q,viewportTop:U,width:N}){$.save(),$.scale(M,M),$.clearRect(0,0,N,J);let A=Y.start.regionId===Y.end.regionId&&Y.start.offset!==Y.end.offset,G=K&&!A;if($.translate(0,-U),G)YM($,Z,X,{color:q.caret,offset:Z.selection.focus.offset,regionId:Z.selection.focus.regionId});if(Q)for(let B of Q){if(!B.cursorPoint)continue;YM($,Z,X,{color:B.color??q.leafAccent,offset:B.cursorPoint.offset,regionId:B.cursorPoint.regionId})}$.restore()}function YM($,M,Z,J){let X=I0(Z,M.documentIndex,{regionId:J.regionId,offset:J.offset});if(!X)return;let Y=l0(M,Z,X),Q=Vq(Z,X);$.fillStyle=J.color,$.fillRect(Y,Q.top,lK,Q.height)}function Fq({containerLineBounds:$,context:M,editorState:Z,line:J,runtimeBlockMap:X,theme:Y,width:Q}){let K=X.get(J.blockId)??null,q=$.get(J.regionId)??null,U=Z.documentIndex.tableCellIndex.get(J.regionId)??null;Dq(M,J,K,q,U,Y,Q)}function bq({activeBlockId:$,activeBlockFlashes:M,activeDeletedTextFades:Z,activeThreadIndex:J,activeInsertedTextHighlights:X,activeListMarkerPops:Y,activePunctuationPulses:Q,context:K,editorState:q,line:U,liveCommentRanges:N,normalizedSelection:A,resources:G,runtimeBlockMap:B,selectionRegionOrderRange:F,theme:_,width:D}){let T=B.get(U.blockId)??null,O=q.documentIndex.blockIndex.get(U.blockId)?.path??null,y=q.documentIndex.regionIndex.get(U.regionId)??null,R=y?.path??"",C=o1(q,U.blockId,"listItem"),m=C?j2(q,C.id):null,H=C?Y.get(C.path)??null:null,P=U.left+K1(q,U),E=Eq(U),j=T?.type==="code"?_.codeText:Rq(T,_);K.font=U.font,Hq(K,U,T,O,$,M,_,D),Pq(K,q,U,A,F,_),zq(K,q,U,N,J,_),o7(K,U,m,P,E,_,H),Tq(K,U,y,P,E,X.get(R)??[],j,G,_),yq(K,U,y,P,E,Z.get(R)??[],j),Wq(K,U,y,P,E,Q.get(R)??[],_)}function Dq($,M,Z,J,X,Y,Q){if(!J||M.start!==0)return;if(Z?.type==="code"){let K=Math.max(0,M.left-xK);$.fillStyle=Y.codeBackground,$.fillRect(K,J.top-aK,Math.max(J.right-M.left+dK,Q-K),J.bottom-J.top+cK);return}if(Z?.type!=="table")return;t7({context:$,containerBounds:J,isHeaderRow:X?.rowIndex===0,lineHeight:M.height,theme:Y})}function Hq($,M,Z,J,X,Y,Q,K){if(M.blockId!==X||Z?.type==="table")return;let q=J?Y.get(J)??null:null;if($.fillStyle=Q.activeBlockBackground,$.fillRect(0,M.top-P3,K,M.height),!q)return;$.fillStyle=f5(Q.activeBlockFlash,q),$.fillRect(0,M.top-P3,K,M.height)}function Pq($,M,Z,J,X,Y){if(!X)return;let Q=M.documentIndex.regionOrderIndex.get(Z.regionId);if(Q===void 0||Q<X.start||Q>X.end)return;let K=Q===X.start?Math.max(Z.start,J.start.offset):Z.start,q=Q===X.end?Math.min(Z.end,J.end.offset):Z.end;if(q<=K)return;$.fillStyle=Y.selectionBackground,$.fillRect(Q1(M,Z,K-Z.start),Z.top+Zq,Math.max(Mq,Q1(M,Z,q-Z.start)-Q1(M,Z,K-Z.start)),Z.height-Jq)}function zq($,M,Z,J,X,Y){for(let Q of J){if(Q.regionId!==Z.regionId)continue;let K=Math.max(Q.startOffset,Z.start),q=Math.min(Q.endOffset,Z.end);if(q<=K)continue;$.fillStyle=kq(Q,X,Y),$.fillRect(Q1(M,Z,K-Z.start),Z.top+Z.height-iK,Math.max(sK,Q1(M,Z,q-Z.start)-Q1(M,Z,K-Z.start)),oK)}}function Tq($,M,Z,J,X,Y,Q,K,q){if(!Z){$.fillStyle=Q,$.fillText(M.text,J,X);return}let U=Z.inlines.filter((N)=>N.end>M.start&&N.start<M.end);if(U.length===0){$.fillStyle=Q,$.fillText(M.text,J,X);return}for(let N of U){let A=Math.max(M.start,N.start),G=Math.min(M.end,N.end);if(Z.text.slice(A,G).length===0)continue;let{left:F,right:_}=y3(M,J,A,G),D=Lq(M.font,N.marks);if($.font=D,N.kind==="image"){let T=Math.max(24,_-F);a7($,M,N,K,q,F,T);continue}if(N.kind==="inlineCode"){let T=Cq(M,D),O=jq(M,D);$.fillStyle=q.inlineCodeBackground,$.fillRect(F-ZM,T,Math.max(eK,_-F+ZM*2),O),QM($,M,Z.text,J,X,A,G,q.inlineCodeText,Y,q,{strikethrough:!1,underline:!1});continue}QM($,M,Z.text,J,X,A,G,N.link?q.linkText:Q,Y,q,{strikethrough:N.marks.includes("strikethrough"),underline:N.marks.includes("underline")||Boolean(N.link)})}}function QM($,M,Z,J,X,Y,Q,K,q,U,N){let A=X7(Y,Q,q);for(let G=0;G<A.length-1;G+=1){let B=A[G],F=A[G+1];if(F<=B)continue;let _=Z.slice(B,F);if(_.length===0)continue;let{left:D,right:T}=y3(M,J,B,F),O=Y7(q,B,F),y=Q7(K,O,U);if($.fillStyle=y,$.fillText(_,D,X),N.strikethrough)$.fillRect(D,Oq(X,M.height,$.font),Math.max(z3,T-D),JM);if(N.underline)$.fillRect(D,wq(X,M.height,$.font),Math.max(z3,T-D),JM)}}function yq($,M,Z,J,X,Y,Q){if(!Z||Y.length===0)return;for(let K of Y){if(K.startOffset<M.start||K.startOffset>M.end)continue;let q=J+(p0(M,K.startOffset-M.start)-M.left);$.fillStyle=K7(Q,K),$.fillText(K.text,q,X)}}function Wq($,M,Z,J,X,Y,Q){if(!Z||Y.length===0)return;for(let K of Y){if(K.offset<M.start||K.offset>=M.end)continue;let{left:q,right:U}=y3(M,J,K.offset,K.offset+1),N=Math.max(XM,(U-q)/2+XM+Qq*K.progress),{ascent:A,descent:G}=Y1(M.font),B=X-Math.max(1,A*0.42)+Math.max(0.5,G*0.15);$.strokeStyle=q7(K,Q),$.lineWidth=Kq,$.beginPath(),$.arc((q+U)/2,B,N,0,Math.PI*2),$.stroke()}}function Vq($,M){let Z=s0($,M.regionId,M.offset),J=Z?.font??'16px "Iowan Old Style", "Palatino Linotype", serif',{ascent:X,descent:Y}=Y1(J),Q=Math.max(1,X+Y),K=Math.min(M.height-rK,Q),q=Z?Math.max(Z.top,Z.top+T3(Z.height,J)-pK):M.top+Math.max(0,Math.floor((M.height-K)/2));return{height:K,top:q}}function wq($,M,Z){let{descent:J}=Y1(Z),X=Math.max(1,Math.round(Math.max(2,J)*0.35)),Y=$+J-X,Q=$-i5(M,Z);return Math.min(Q+M-4,Y)}function Oq($,M,Z){let{ascent:J}=Y1(Z),X=$-i5(M,Z);return Math.max(X+2,$-Math.round(J*0.32))}function Eq($){return $.top+i5($.height,$.font)}function i5($,M){return z9($,M)}function Cq($,M){let Z=T3($.height,M);return $.top+Z+$q}function jq($,M){let Z=T3($.height,M);return Math.max(tK,$.height-Z-nK)}function T3($,M){let{ascent:Z}=Y1(M);return i5($,M)-Z}function Rq($,M){switch($?.type){case"heading":return M.headingText;case"blockquote":return M.blockquoteText;case"table":return M.headingText;default:return M.paragraphText}}function y3($,M,Z,J){return{left:M+(p0($,Z-$.start)-$.left),right:M+(p0($,J-$.start)-$.left)}}function Lq($,M){let Z=[];if(M.includes("italic"))Z.push("italic");if(M.includes("bold"))Z.push("700");return Z.length>0?`${Z.join(" ")} ${$}`:$}function kq($,M,Z){if($.resolved)return $.threadIndex===M?Z.commentHighlightResolvedActive:Z.commentHighlightResolved;return $.threadIndex===M?Z.commentHighlightActive:Z.commentHighlight}function fq(){return typeof performance<"u"?performance.now():Date.now()}function W3($,M,Z,J){qq({activeBlockId:J.activeBlockId,activeRegionId:J.activeRegionId,activeThreadIndex:J.activeThreadIndex,containerLineBounds:M.regionBounds,context:Z,devicePixelRatio:J.devicePixelRatio,editorState:$,height:J.height,layout:M.layout,liveCommentRanges:J.liveCommentRanges,normalizedSelection:J.normalizedSelection,now:J.now,resources:J.resources??{images:new Map},runtimeBlockMap:M.blockMap,theme:J.theme,viewportTop:M.paintTop,width:J.width})}function V3($,M,Z,J){_q({context:Z,devicePixelRatio:J.devicePixelRatio,editorState:$,height:J.height,layout:M.layout,normalizedSelection:J.normalizedSelection,presence:J.presence,showCaret:J.showCaret,theme:J.theme,viewportTop:M.paintTop,width:J.width})}import{forwardRef as hq,createElement as gq}from"react";var s5=(...$)=>$.filter((M,Z,J)=>{return Boolean(M)&&M.trim()!==""&&J.indexOf(M)===Z}).join(" ").trim();var KM=($)=>$.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var qM=($)=>$.replace(/^([A-Z])|[\s-_]+(\w)/g,(M,Z,J)=>J?J.toUpperCase():Z.toLowerCase());var w3=($)=>{let M=qM($);return M.charAt(0).toUpperCase()+M.slice(1)};import{forwardRef as vq,createElement as AM}from"react";var o5={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 UM=($)=>{for(let M in $)if(M.startsWith("aria-")||M==="role"||M==="title")return!0;return!1};import{createContext as mq,useContext as Sq,useMemo as RD,createElement as LD}from"react";var uq=mq({});var NM=()=>Sq(uq);var GM=vq(({color:$,size:M,strokeWidth:Z,absoluteStrokeWidth:J,className:X="",children:Y,iconNode:Q,...K},q)=>{let{size:U=24,strokeWidth:N=2,absoluteStrokeWidth:A=!1,color:G="currentColor",className:B=""}=NM()??{},F=J??A?Number(Z??N)*24/Number(M??U):Z??N;return AM("svg",{ref:q,...o5,width:M??U??o5.width,height:M??U??o5.height,stroke:$??G,strokeWidth:F,className:s5("lucide",B,X),...!Y&&!UM(K)&&{"aria-hidden":"true"},...K},[...Q.map(([_,D])=>AM(_,D)),...Array.isArray(Y)?Y:[Y]])});var S=($,M)=>{let Z=hq(({className:J,...X},Y)=>gq(GM,{ref:Y,iconNode:M,className:s5(`lucide-${KM(w3($))}`,`lucide-${$}`,J),...X}));return Z.displayName=w3($),Z};var Iq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],G1=S("columns-2",Iq);var pq=[["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"}]],B1=S("rows-3",pq);var lq=[["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"}]],_1=S("send-horizontal",lq);var rq=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],K4=S("arrow-down",rq);var cq=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],q4=S("arrow-up",cq);var xq=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],U4=S("bold",xq);var dq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],V1=S("check",dq);var aq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],N4=S("chevron-down",aq);var iq=[["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"}]],A4=S("heading-1",iq);var sq=[["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"}]],G4=S("heading-2",sq);var oq=[["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"}]],B4=S("heading-3",oq);var nq=[["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"}]],_4=S("heading-4",nq);var tq=[["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=S("heading-5",tq);var eq=[["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"}]],b4=S("heading-6",eq);var $U=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],D4=S("heading",$U);var MU=[["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=S("italic",MU);var ZU=[["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=S("list-ordered",ZU);var JU=[["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"}]],z4=S("list-todo",JU);var XU=[["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=S("list",XU);var YU=[["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=S("message-square-plus",YU);var QU=[["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"}]],w1=S("pencil",QU);var KU=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],K2=S("plus",KU);var qU=[["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"}]],W4=S("strikethrough",qU);var UU=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],F1=S("table-2",UU);var NU=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],V4=S("text-quote",NU);var AU=[["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"}]],E0=S("trash-2",AU);var GU=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],w4=S("underline",GU);var BU=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],O4=S("x",BU);import{jsxDEV as O1}from"react/jsx-dev-runtime";function BM({insetX:$,insetY:M,onSelect:Z,presence:J}){if(!J)return null;return O1("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${$}px`,top:`${M}px`},children:J.map((X)=>O1(_U,{onSelect:()=>Z(X),presence:X},X.id,!1,void 0,this))},void 0,!1,void 0,this)}function _U({onSelect:$,presence:M}){let Z=M.viewport,J=FU(M),X=Z?.status==="above"?q4:K4,Y=Z!==null&&Z.status!=="unresolved",Q=Z?.status==="above"||Z?.status==="below";return O1("button",{"aria-label":bU(M),className:"documint-presence-indicator","data-status":Z?.status??"unresolved",disabled:!Y,onClick:Y?$:void 0,style:{"--documint-presence-color":M.color??"var(--documint-leaf-accent)"},type:"button",children:[O1("span",{className:"documint-presence-indicator-avatar",children:M.avatarUrl?O1("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:M.avatarUrl},void 0,!1,void 0,this):J},void 0,!1,void 0,this),Q?O1("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:O1(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 FU($){return _M($).charAt(0).toLocaleUpperCase()}function bU($){let M=_M($),Z=$.viewport?.status??"unresolved";if(Z==="above")return`${M} above viewport`;if(Z==="below")return`${M} below viewport`;if(Z==="unresolved")return`${M} unresolved`;return`${M} in viewport`}function _M($){return($.fullName??$.username).trim()||"Presence"}var i=`
|
|
26
|
-
`,
|
|
27
|
-
|
|
28
|
-
`,NN="-",AN=".",GN="***",BN=" ",u3=3,_N=5,FN=4,vM=2,bN=2,DN=1,HN=/([\\`*_[\]])/g,PN=/([\\)&])/g,zN=/(["\\])/g;function J8($,M={}){if($.blocks.length===0&&$.comments.length===0)return"";let Z=$.blocks.map((X)=>X8(X,0,M));if($.comments.length>0)Z.push(hN($.comments));let J=Z.join(R4);return J.endsWith(i)?J:`${J}${i}`}function X8($,M,Z){let J=D1(M);switch($.type){case"blockquote":return TN($,M,Z);case"code":return yN($,M);case"directive":return gN($,M);case"heading":return gM($,M);case"list":return WN($,M,Z);case"listItem":return IM($,M,!1,1,Z);case"paragraph":return`${J}${v3(L4($.children))}`;case"table":return wN($,M,Z);case"thematicBreak":return`${J}${GN}`;case"unsupported":return M===0?$.source:rM($.source,M)}}function TN($,M,Z){let J=$.children.map((Y)=>X8(Y,0,Z)).join(R4),X=D1(M);return J.split(i).map((Y)=>`${X}${q2}${Y.length>0?` ${Y}`:""}`).join(i)}function yN($,M){let Z=[$.language??"",$.meta??""].filter(Boolean).join(" ").trim(),J=D1(M),X=`${J}${C4}${Z?Z:""}`,Y=$.source.length>0?$.source.split(i).map((Q)=>`${J}${Q}`).join(i):J;return`${X}${i}${Y}${i}${J}${C4}`}function gM($,M){let Z=v3(L4($.children)),J=`${D1(M)}${"#".repeat($.depth)}`;return Z.length>0?`${J} ${Z}`:J}function WN($,M,Z){let J=$.start??1;return $.items.map((X)=>IM(X,M,$.ordered,J,Z)).join($.spread?R4:i)}function IM($,M,Z,J,X){let Y=Z?`${J}${AN}`:NN,Q=$.checked===null?"":`[${$.checked?"x":" "}] `,K=`${D1(M)}${Y} ${Q}`,q=M+Y.length+1,U=$.children;if(U.length===0)return Q.length>0?K:K.trimEnd();let[N,...A]=U,G=VN(N,K,Q.length>0,X),B=A.map((F)=>X8(F,q,X)).join($.spread?R4:i);if(!B)return G;return`${G}${$.spread?R4:i}${B}`}function VN($,M,Z,J){switch($.type){case"paragraph":{let X=v3(L4($.children));if(X.length===0)return Z?M:M.trimEnd();return`${M}${X}`}case"heading":return`${M}${gM($,0)}`;case"directive":case"unsupported":{let X=$.type==="directive"?h3($):$.source,[Y,...Q]=X.split(i);return[M+Y,...Q.map((K)=>`${D1(M.length)}${K}`)].join(i)}default:{let X=M.length;return`${M.trimEnd()}${i}${X8($,X,J)}`}}}function wN($,M,Z){let J=$.rows.map((N)=>N.cells.map((A)=>L4(A.children))),X=Math.max(1,...J.map((N)=>N.length)),Y=J[0]??[],Q=Array.from({length:X},(N,A)=>Math.max(u3,jN($.align[A]),...Z.padTableColumns?J.map((G)=>G[A]?.length??0):[Y[A]?.length??0])),K=ON(Q,$.align,M),q=hM(Y,Q,$.align,M,Z),U=J.slice(1).map((N)=>hM(N,Q,$.align,M,Z));return[q??EN(Q,M),K,...U].join(i)}function hM($,M,Z,J,X){let Y=M.map((Q,K)=>{let q=$[K]??"";if(!X.padTableColumns)return q;return RN(q,Q,Z[K])});return`${" ".repeat(J)}| ${Y.join(" | ")} |`}function ON($,M,Z){let J=$.map((X,Y)=>CN(M[Y],X));return`${" ".repeat(Z)}| ${J.join(" | ")} |`}function EN($,M){return`${D1(M)}| ${$.map((Z)=>"".padEnd(Z," ")).join(" | ")} |`}function CN($,M){let Z=Math.max(u3,M-($==="center"?bN:$?DN:0));switch($){case"center":return`:${"-".repeat(Math.max(1,Z))}:`;case"left":return`:${"-".repeat(Math.max(vM,Z))}`;case"right":return`${"-".repeat(Math.max(vM,Z))}:`;default:return"-".repeat(Z)}}function jN($){return $==="center"?_N:$?FN:u3}function RN($,M,Z){if(Z==="right")return $.padStart(M," ");return $.padEnd(M," ")}function L4($){return kN($).map((M)=>LN(M)).join("")}function v3($){return $.replace(/^ +/gm,(M)=>BN.repeat(M.length))}function LN($){switch($.type){case"break":return i;case"image":return IN($);case"inlineCode":return SN($.code);case"link":return pN($);case"text":return mN(pM($.text),$.marks);case"unsupported":return $.source}}function kN($){let M=[];for(let Z of $){let J=M.at(-1);if(J?.type==="text"&&Z.type==="text"&&fN(J.marks,Z.marks)){M[M.length-1]={...J,text:J.text+Z.text};continue}M.push(Z)}return M}function fN($,M){return $.length===M.length&&$.every((Z,J)=>Z===M[J])}function mN($,M){return M.reduce((Z,J)=>{switch(J){case"bold":return`**${Z}**`;case"italic":return`*${Z}*`;case"strikethrough":return`~~${Z}~~`;case"underline":return`${b1}${Z}${E4}`}},$)}function SN($){let M=0,Z=0;for(let Q of $){if(Q==="`"){if(Z+=1,Z>M)M=Z;continue}Z=0}let J=M>0?M+1:1,X="`".repeat(J),Y=$.startsWith("`")||$.endsWith("`")?` ${$} `:$;return`${X}${Y}${X}`}function pM($){return $.replace(HN,"\\$1")}function uN($){return $.replace(PN,"\\$1")}function vN($){return $?` "${$.replace(zN,"\\$1")}"`:""}function hN($){return h3({attributes:"",body:JSON.stringify($,null,2),name:t5})}function gN($,M){let Z=h3($);return M===0?Z:rM(Z,M)}function h3($){let M=$.attributes?`{${$.attributes}}`:"";return`:::${$.name}${M}${i}${$.body}${i}${n5}`}function IN($){let M=pM($.alt??""),Z=lM($.url,$.title),J=$.width?`{width=${$.width}}`:"";return`![${M}]${Z}${J}`}function pN($){return`[${L4($.children)}]${lM($.url,$.title)}`}function lM($,M){return`(${uN($)}${vN(M)})`}function D1($){return" ".repeat($)}function rM($,M){let Z=D1(M);return $.split(i).map((J)=>`${Z}${J}`).join(i)}import{createContext as lN,useContext as rN}from"react";import{createPortal as cN}from"react-dom";import{jsxDEV as dM}from"react/jsx-dev-runtime";var cM=lN(void 0);function xM({children:$,themeStyles:M}){return dM(cM.Provider,{value:M,children:$},void 0,!1,void 0,this)}function Y8({children:$}){let M=rN(cM);if(typeof document>"u")return null;return cN(dM("div",{className:"documint-overlay",style:{display:"contents",...M},children:$},void 0,!1,void 0,this),document.body)}import{useEffect as Q8,useRef as XZ,useState as E1}from"react";import{forwardRef as dN,useCallback as A2,useEffect as aN,useImperativeHandle as iN,useLayoutEffect as sN,useMemo as oN,useRef as sM,useState as g3}from"react";var xN=["box-sizing","width","height","overflow-x","overflow-y","border-top-width","border-right-width","border-bottom-width","border-left-width","border-style","padding-top","padding-right","padding-bottom","padding-left","font-style","font-variant","font-weight","font-stretch","font-size","font-size-adjust","line-height","font-family","text-align","text-transform","text-indent","text-decoration","letter-spacing","word-spacing","tab-size"];function aM($,M,{topGap:Z=8}={}){if(!$.isConnected)return null;let J=getComputedStyle($),X=document.createElement("div");for(let U of xN)X.style.setProperty(U,J.getPropertyValue(U));Object.assign(X.style,{position:"absolute",top:"0",left:"0",visibility:"hidden",whiteSpace:"pre-wrap",wordWrap:"break-word",width:`${$.clientWidth}px`}),X.textContent=$.value.slice(0,M);let Y=document.createElement("span");Y.textContent=$.value.slice(M)||".",X.appendChild(Y),document.body.appendChild(X);let Q=$.getBoundingClientRect(),K=parseFloat(J.lineHeight)||Y.offsetHeight,q={left:Q.left+Y.offsetLeft+parseFloat(J.borderLeftWidth)-$.scrollLeft,top:Q.top+Y.offsetTop+parseFloat(J.borderTopWidth)+K+Z-$.scrollTop};return document.body.removeChild(X),q}import{jsxDEV as y0,Fragment as YA}from"react/jsx-dev-runtime";var nN=240,tN="documint-leaf-menu-item documint-completion-item",k4=dN(function({actions:M,completionSources:Z,onChange:J,placeholder:X,readOnly:Y=!1,rows:Q=3,value:K},q){let U=sM(null);iN(q,()=>U.current,[]);let N=oN(()=>ZA(Z),[Z]),[A,G]=g3(null),[B,F]=g3(0),[_,D]=g3(null),T=A2((H,P)=>{if(!N.length){G(null);return}let E=JA(H,P,N);if(!E){G(null);return}G(E),F(0)},[N]),O=A2((H)=>{let P=H.currentTarget.value,E=H.currentTarget.selectionEnd??P.length;J(P),T(P,E)},[J,T]),y=A2((H)=>{let P=H.currentTarget;T(P.value,P.selectionEnd??P.value.length)},[T]),R=A2(()=>{G(null)},[]),C=A2((H)=>{if(!U.current||!A)return;let E=`${A.trigger}${H.label} `,j=K.slice(0,A.triggerStart),W=K.slice(A.caret),b=j+E+W,z=A.triggerStart+E.length;J(b),G(null),requestAnimationFrame(()=>{let u=U.current;if(!u)return;u.focus(),u.setSelectionRange(z,z)})},[A,J,K]),m=A2((H)=>{if(A&&A.matches.length>0){if(H.key==="ArrowDown"){H.preventDefault(),H.stopPropagation(),F((P)=>(P+1)%A.matches.length);return}if(H.key==="ArrowUp"){H.preventDefault(),H.stopPropagation(),F((P)=>(P-1+A.matches.length)%A.matches.length);return}if(H.key==="Enter"||H.key==="Tab"){H.preventDefault(),H.stopPropagation();let P=A.matches[B];if(P)C(P);return}if(H.key==="Escape"){H.preventDefault(),H.stopPropagation(),G(null);return}}if(H.key==="Escape"&&M.kind==="edit")H.preventDefault(),M.onCancel()},[M,A,B,C]);return sN(()=>{if(!A){D(null);return}let H=()=>{let P=U.current;if(!P)return;D(aM(P,A.triggerStart))};return H(),window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),()=>{window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H)}},[A]),y0("div",{className:"documint-leaf-input-field",children:[y0("textarea",{className:"documint-leaf-input",onBlur:R,onChange:O,onKeyDown:m,onSelect:y,placeholder:X,readOnly:Y,ref:U,rows:Q,value:K},void 0,!1,void 0,this),eN(M),A&&_&&A.matches.length>0?y0(Y8,{children:y0($A,{activeIndex:B,left:_.left,matches:A.matches,onHover:F,onSelect:C,top:_.top},void 0,!1,void 0,this)},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)});function eN($){if($.kind==="edit")return y0(YA,{children:[y0(I3,{className:"documint-leaf-input-cancel",icon:O4,label:"Cancel editing",onClick:$.onCancel},void 0,!1,void 0,this),y0(I3,{className:"documint-leaf-input-save",disabled:$.saveDisabled??!1,icon:V1,label:"Save",onClick:$.onSave},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return y0(I3,{className:"documint-leaf-input-submit",disabled:$.submitDisabled??!1,icon:_1,iconSize:15,label:$.submitLabel,onClick:$.onSubmit},void 0,!1,void 0,this)}function I3({className:$,disabled:M=!1,icon:Z,iconSize:J=14,label:X,onClick:Y}){return y0("button",{"aria-label":X,className:`documint-leaf-action ${$}`,disabled:M,onClick:Y,title:X,type:"button",children:y0(Z,{size:J,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function $A({activeIndex:$,left:M,matches:Z,onHover:J,onSelect:X,top:Y}){let Q=sM(null);return aN(()=>{let K=Q.current;if(!K)return;let q=K.children[$];if(q instanceof HTMLElement)q.scrollIntoView({block:"nearest"})},[$]),y0("div",{className:"documint-leaf-menu documint-completion-popover",ref:Q,role:"listbox",style:{position:"fixed",left:M,top:Y,maxHeight:nN,overflowY:"auto"},children:Z.map((K,q)=>{let U=q===$;return y0("button",{"aria-selected":U,className:`${tN}${U?" is-active":""}`,onPointerDown:MA,onPointerEnter:()=>J(q),onClick:()=>X(K),role:"option",type:"button",children:y0("span",{children:K.label},void 0,!1,void 0,this)},K.label,!1,void 0,this)})},void 0,!1,void 0,this)}function MA($){$.preventDefault()}function ZA($){if(!$?.length)return[];return $.map((M)=>({trigger:M.trigger,items:[...M.items].sort((Z,J)=>Z.label.localeCompare(J.label,void 0,{sensitivity:"base"}))}))}function JA($,M,Z){for(let J=M-1;J>=0;J-=1){let X=$[J];if(iM(X))return null;let Y=Z.find((K)=>K.trigger===X);if(!Y)continue;if(J>0&&!iM($[J-1]))return null;let Q=$.slice(J+1,M);return{trigger:Y.trigger,query:Q,triggerStart:J,caret:M,matches:XA(Y.items,Q)}}return null}function iM($){return $===void 0||$===" "||$===`
|
|
29
|
-
`||$==="\t"}function
|
|
30
|
-
`||$==="\t"}import{Children as oM,isValidElement as nM,useEffect as NA,useRef as AA,useState as GA}from"react";import{jsxDEV as Y0}from"react/jsx-dev-runtime";var r3=($)=>{$.preventDefault()},c3=($)=>$.isPrimary&&$.button===0;function BA({children:$}){return Y0("div",{className:"documint-leaf-toolbar",children:oM.map($,_A)},void 0,!1,void 0,this)}function _A($){if(!nM($))return null;if($.type===eM){let M=$.props;return Y0(tM,{children:Y0(FA,{...M},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if($.type===$Z){let{className:M}=$.props;return Y0("div",{className:f4("documint-leaf-toolbar-divider",M)},void 0,!1,void 0,this)}if($.type===MZ){let M=$.props;return Y0(bA,{...M},void 0,!1,void 0,this)}return null}function FA({active:$=!1,className:M,disabled:Z=!1,icon:J,label:X,onClick:Y}){return Y0("button",{"aria-label":X,className:f4("documint-leaf-toolbar-button",$?"active":null,M),disabled:Z,onPointerDown:(Q)=>{if(r3(Q),!Z&&c3(Q))Y()},title:X,type:"button",children:Y0(J,{size:15,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function bA({children:$,className:M,icon:Z,label:J,onSelect:X}){let Y=AA(null),[Q,K]=GA(!1);return NA(()=>{if(!Q)return;let q=(U)=>{if(Y.current&&U.target instanceof Node&&!Y.current.contains(U.target))K(!1)};return window.addEventListener("pointerdown",q),()=>{window.removeEventListener("pointerdown",q)}},[Q]),Y0(tM,{children:Y0("div",{className:"documint-leaf-toolbar-menu-shell",ref:Y,children:[Y0(DA,{className:M,icon:Z,isOpen:Q,label:J,onClick:()=>K((q)=>!q)},void 0,!1,void 0,this),Q?Y0("div",{className:"documint-leaf-menu",role:"menu",children:oM.map($,(q)=>HA(q,(U)=>{K(!1),X(U)}))},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function DA({className:$,icon:M,isOpen:Z,label:J,onClick:X}){return Y0("button",{"aria-expanded":Z,"aria-haspopup":"menu","aria-label":J,className:f4("documint-leaf-toolbar-button",Z?"active":null,$),onPointerDown:(Y)=>{if(r3(Y),c3(Y))X()},title:J,type:"button",children:[Y0(M,{size:15,strokeWidth:2.2},void 0,!1,void 0,this),Y0(N4,{className:f4("documint-leaf-toolbar-menu-chevron",Z?"is-open":null),size:13,strokeWidth:2.2},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function HA($,M){if(!nM($))return null;if($.type===JZ){let{className:Q}=$.props;return Y0("div",{className:f4("documint-leaf-menu-divider",Q),role:"separator"},void 0,!1,void 0,this)}if($.type!==ZZ)return null;let{disabled:Z=!1,icon:J,text:X,value:Y}=$.props;return Y0("button",{className:"documint-leaf-menu-item",disabled:Z,onPointerDown:(Q)=>{if(r3(Q),!Z&&c3(Q))M(Y)},role:"menuitem",type:"button",children:[Y0(J,{size:15,strokeWidth:2.2},void 0,!1,void 0,this),Y0("span",{children:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function f4(...$){return $.filter(Boolean).join(" ")}function tM({children:$}){return Y0("div",{className:"documint-leaf-toolbar-group",children:$},void 0,!1,void 0,this)}function eM($){return null}function $Z($){return null}function MZ($){return null}function ZZ($){return null}function JZ($){return null}var d=Object.assign(BA,{Button:eM,Divider:$Z,Menu:MZ,MenuDivider:JZ,MenuItem:ZZ});import{jsxDEV as r,Fragment as yA}from"react/jsx-dev-runtime";var PA=!1,zA=220,C1=()=>{};function x3($){let M=$.mode==="create",Z=$.mode==="create"?$:null,J=$.mode==="thread"?$:null,X=$.canEdit,Y=$.link,Q=J?.thread??null,K=Q?.comments??[],q=K[0]??null,U=Q?Z1(Q):!1,N=J?.animateInitialComment??!1,[A,G]=E1(null),[B,F]=E1(""),[_,D]=E1(""),[T,O]=E1(""),[y,R]=E1(!N),[C,m]=E1(PA),[H,P]=E1(!1),E=XZ(null),j=XZ(null),W=$.mentionSources,b=Q?u8(Q):null,z=b?YZ(b):"",u=X&&!U,v=u&&B.trim().length>0,l=u&&_.trim().length>0,g=X&&T.trim().length>0,w=M||H,V=!M||C,L=!M&&Boolean(Q),f=Boolean(q),x=M?C:!0,h=J?.onDeleteComment??C1,Q0=J?.onDeleteThread??C1,b0=J?.onToggleResolved??C1,e0=Z?.activeMarks??[],L1=Z?.onToggleBold??C1,g4=Z?.onToggleItalic??C1,B8=Z?.onToggleStrikethrough??C1,I4=Z?.onToggleUnderline??C1,p4=X?M?"Add a comment":"Reply to this comment":"Comment editing is disabled",S0=M?T:_;Q8(()=>{if(A!==null&&(A<0||A>=K.length))G(null),F("")},[K.length,A]),Q8(()=>{if(!f||!N){R(!0);return}R(!1);let W0=requestAnimationFrame(()=>{R(!0)});return()=>{cancelAnimationFrame(W0)}},[N,q,f]),Q8(()=>{if(!J||!N){P(!1);return}P(!0);let W0=window.setTimeout(()=>{P(!1)},zA);return()=>{window.clearTimeout(W0)}},[N,J]),Q8(()=>{if(!M||!C||!X)return;let W0=requestAnimationFrame(()=>{j.current?.focus()});return()=>{cancelAnimationFrame(W0)}},[X,M,C]);let P0=()=>{G(null),F("")},l4=(W0,c4)=>{if(!L||!u)return;G(W0),F(c4)},_8=(W0)=>{if(!J)return;J.onEditComment(W0,B),P0()},r4=()=>{if(!J)return;J.onReply(_),D("")},k1=()=>{if(!Z||!g)return;Z.onCreateThread(T),O("")},e=w?`documint-comment-leaf documint-comment-leaf-create${x?" is-expanded":""}`:"documint-comment-leaf",n=L||f||V?r(TA,{canCreate:g,canEdit:X,canMutateThread:u,canReply:l,canSaveEditedComment:v,comments:K,composerRef:j,editDraft:B,editingCommentIndex:A,isComposerVisible:V,isInitialCommentVisible:y,isResolved:U,link:Y,mentionSources:W,mode:$.mode,onBeginEditingComment:l4,onCancelEditing:P0,onChangeCreateDraft:O,onChangeEditDraft:F,onChangeReplyDraft:D,onDeleteComment:h,onDeleteThread:Q0,onSubmitCreate:k1,onSubmitEditedComment:_8,onSubmitReply:r4,onToggleResolved:b0,rootComment:q,showRootComment:f,showThreadChrome:L,threadAge:z,composerPlaceholder:p4,composerValue:S0},void 0,!1,void 0,this):null;return r("div",{className:e,ref:E,children:r("div",{className:w?"documint-comment-leaf-create-shell":void 0,children:[w?r(d,{children:[r(d.Button,{className:"documint-comment-leaf-create-button",icon:y4,label:"Add comment",onClick:()=>m(!0)},void 0,!1,void 0,this),r(d.Divider,{className:"documint-comment-leaf-create-divider"},void 0,!1,void 0,this),r(d.Button,{active:e0.includes("bold"),className:"documint-comment-leaf-create-mark",icon:U4,label:"Bold",onClick:L1},void 0,!1,void 0,this),r(d.Button,{active:e0.includes("italic"),className:"documint-comment-leaf-create-mark",icon:H4,label:"Italic",onClick:g4},void 0,!1,void 0,this),r(d.Button,{active:e0.includes("underline"),className:"documint-comment-leaf-create-mark",icon:w4,label:"Underline",onClick:I4},void 0,!1,void 0,this),r(d.Button,{active:e0.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:W4,label:"Strikethrough",onClick:B8},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,r("div",{className:w?"documint-comment-leaf-create-content":void 0,children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function TA({canCreate:$,canEdit:M,canMutateThread:Z,canReply:J,canSaveEditedComment:X,comments:Y,composerRef:Q,editDraft:K,editingCommentIndex:q,isComposerVisible:U,isInitialCommentVisible:N,isResolved:A,link:G,mentionSources:B,mode:F,onBeginEditingComment:_,onCancelEditing:D,onChangeCreateDraft:T,onChangeEditDraft:O,onChangeReplyDraft:y,onDeleteComment:R,onDeleteThread:C,onSubmitCreate:m,onSubmitEditedComment:H,onSubmitReply:P,onToggleResolved:E,rootComment:j,showRootComment:W,showThreadChrome:b,threadAge:z,composerPlaceholder:u,composerValue:v}){return r(yA,{children:[b?r("div",{className:"documint-comment-leaf-header",children:[r("span",{className:"documint-comment-leaf-age",children:z},void 0,!1,void 0,this),r("div",{className:"documint-comment-leaf-actions",children:[r("button",{className:"documint-leaf-action","aria-label":A?"Reopen comment":"Resolve comment",disabled:!M,onClick:E,title:A?"Reopen comment":"Resolve comment",type:"button",children:r(V1,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),r("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!M,onClick:C,title:"Delete comment thread",type:"button",children:r(E0,{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,b&&G?r("div",{className:"documint-comment-leaf-link",children:[G.title?r("div",{className:"documint-link-leaf-title",children:G.title},void 0,!1,void 0,this):null,r("div",{className:"documint-link-leaf-url",children:G.url},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,r("div",{className:`documint-comment-thread${W?"":" is-empty"}`,children:[r("article",{className:W?`documint-comment-message documint-comment-message-root${N?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:j?r(l3,{completionSources:B,onEdit:()=>_(0,j.body),value:j.body},void 0,!1,void 0,this):null},void 0,!1,void 0,this),Y.slice(1).map((l,g)=>{let w=g+1,V=q===w;return r("article",{className:"documint-comment-message",children:[!V?r("div",{className:"documint-comment-message-meta",children:[r("span",{children:YZ(l.updatedAt)},void 0,!1,void 0,this),Z?r("div",{className:"documint-comment-leaf-actions",children:[r("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!Z,onClick:()=>{_(w,l.body)},title:"Edit comment",type:"button",children:r(w1,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),r("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!Z,onClick:()=>R(w),title:"Delete comment",type:"button",children:r(E0,{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,V?r(k4,{actions:{kind:"edit",onCancel:D,onSave:()=>H(w),saveDisabled:!X},completionSources:B,onChange:O,readOnly:!M,rows:3,value:K},void 0,!1,void 0,this):r(l3,{completionSources:B,onEdit:()=>_(w,l.body),value:l.body},void 0,!1,void 0,this)]},`${l.updatedAt}:${w}`,!0,void 0,this)})]},void 0,!0,void 0,this),r("div",{className:`documint-comment-reply${b?"":" is-standalone"}${U?" is-visible":""}`,children:r(k4,{actions:F==="create"?{kind:"compose",onSubmit:m,submitDisabled:!$,submitLabel:"Create comment"}:{kind:"compose",onSubmit:P,submitDisabled:!J,submitLabel:"Reply"},completionSources:B,onChange:F==="create"?T:y,placeholder:u,readOnly:!M,ref:Q,rows:3,value:v},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function YZ($){let M=new Date($);if(Number.isNaN(M.getTime()))return $;let Z=M.getTime()-Date.now(),J=60000,X=60*J,Y=24*X,Q=7*Y,K=30*Y,q=365*Y,U=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(Z)<J)return"just now";if(Math.abs(Z)<X)return U.format(Math.round(Z/J),"minute");if(Math.abs(Z)<Y)return U.format(Math.round(Z/X),"hour");if(Math.abs(Z)<Q)return U.format(Math.round(Z/Y),"day");if(Math.abs(Z)<q)return U.format(Math.round(Z/K),"month");return U.format(Math.round(Z/q),"year")}import{jsxDEV as m0}from"react/jsx-dev-runtime";var WA=[{icon:A4,label:"Heading 1",text:"# "},{icon:G4,label:"Heading 2",text:"## "},{icon:B4,label:"Heading 3",text:"### "},{icon:_4,label:"Heading 4",text:"#### "},{icon:F4,label:"Heading 5",text:"##### "},{icon:b4,label:"Heading 6",text:"###### "}],VA=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function QZ({onInsert:$,onInsertTable:M}){return m0(d,{children:[m0(d.Button,{icon:T4,label:"Insert bulleted list",onClick:()=>$("- ")},void 0,!1,void 0,this),m0(d.Button,{icon:P4,label:"Insert numbered list",onClick:()=>$("1. ")},void 0,!1,void 0,this),m0(d.Button,{icon:z4,label:"Insert task list",onClick:()=>$("- [ ] ")},void 0,!1,void 0,this),m0(d.Divider,{},void 0,!1,void 0,this),m0(d.Menu,{icon:D4,label:"Insert heading",onSelect:$,children:WA.map(({icon:Z,label:J,text:X})=>m0(d.MenuItem,{icon:Z,text:J,value:X},X,!1,void 0,this))},void 0,!1,void 0,this),m0(d.Menu,{icon:F1,label:"Insert table",onSelect:(Z)=>M(Number(Z)),children:VA.map(({columns:Z,text:J})=>m0(d.MenuItem,{icon:F1,text:J,value:String(Z)},Z,!1,void 0,this))},void 0,!1,void 0,this),m0(d.Divider,{},void 0,!1,void 0,this),m0(d.Button,{icon:V4,label:"Insert blockquote",onClick:()=>$("> ")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as K8}from"react/jsx-dev-runtime";function KZ({anchor:$,children:M,status:Z="default"}){let J=!$.isSelection;return K8(Y8,{children:K8("div",{className:"documint-leaf-anchor","data-selection":$.isSelection?"true":"false",onPointerEnter:$.onPointerEnter,onPointerLeave:$.onPointerLeave,style:{left:`${$.left}px`,top:`${$.top}px`},children:[J?K8("div",{className:"documint-leaf-bridge"},void 0,!1,void 0,this):null,K8("div",{className:"documint-leaf-shell","data-status":Z,children:M},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{useEffect as qZ,useRef as wA,useState as UZ}from"react";import{jsxDEV as C0}from"react/jsx-dev-runtime";function NZ({canEdit:$,onDelete:M,onSave:Z,title:J,url:X}){let[Y,Q]=UZ(X),[K,q]=UZ(!1),U=wA(null),N=OA(),A=Y.trim(),G=$&&A.length>0,B=$&&!K,F=`${N}click to open`,_=`documint-link-leaf-row${K?" is-editing":""}`;return qZ(()=>{if(K)return;Q(X)},[K,X]),qZ(()=>{if(!K)return;U.current?.focus()},[K]),C0("div",{className:"documint-link-leaf",children:[J?C0("div",{className:"documint-link-leaf-title",children:J},void 0,!1,void 0,this):null,C0("div",{className:_,children:[K?C0(k4,{actions:{kind:"edit",onCancel:()=>{Q(X),q(!1)},onSave:()=>{Z(A),q(!1)},saveDisabled:!G},onChange:Q,readOnly:!$,ref:U,rows:3,value:Y},void 0,!1,void 0,this):C0("div",{className:"documint-link-leaf-url",children:X},void 0,!1,void 0,this),B?C0("div",{className:"documint-link-leaf-actions",children:[C0("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!$)return;Q(X),q(!0)},title:"Edit link",type:"button",children:C0(w1,{size:14,strokeWidth:2.2},void 0,!1,void 0,this)},void 0,!1,void 0,this),C0("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:M,title:"Remove link",type:"button",children:C0(E0,{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),C0("div",{className:"documint-link-leaf-divider"},void 0,!1,void 0,this),C0("div",{className:"documint-link-leaf-hint",children:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function OA(){if(typeof navigator>"u")return"Ctrl+";let $=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test($)?"CMD+":"CTRL+"}import{jsxDEV as j0}from"react/jsx-dev-runtime";var EA=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],CA=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],d3={text:"Delete column",value:"delete"},a3={text:"Delete row",value:"delete"},AZ={text:"Delete table",value:"delete"};function GZ({canDeleteColumn:$,canDeleteRow:M,onDeleteColumn:Z,onDeleteRow:J,onDeleteTable:X,onInsertColumn:Y,onInsertRow:Q}){return j0(d,{children:[j0(d.Menu,{icon:G1,label:"Column actions",onSelect:(K)=>{if(K===d3.value){Z();return}Y(K)},children:[EA.map(({text:K,value:q})=>j0(d.MenuItem,{icon:K2,text:K,value:q},q,!1,void 0,this)),j0(d.MenuDivider,{},void 0,!1,void 0,this),j0(d.MenuItem,{disabled:!$,icon:E0,text:d3.text,value:d3.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j0(d.Menu,{icon:B1,label:"Row actions",onSelect:(K)=>{if(K===a3.value){J();return}Q(K)},children:[CA.map(({text:K,value:q})=>j0(d.MenuItem,{icon:K2,text:K,value:q},q,!1,void 0,this)),j0(d.MenuDivider,{},void 0,!1,void 0,this),j0(d.MenuItem,{disabled:!M,icon:E0,text:a3.text,value:a3.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j0(d.Divider,{},void 0,!1,void 0,this),j0(d.Menu,{icon:F1,label:"Table actions",onSelect:()=>X(),children:j0(d.MenuItem,{icon:E0,text:AZ.text,value:AZ.value},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as BZ,useEffectEvent as _Z,useLayoutEffect as jA,useMemo as RA,useRef as i3,useState as LA}from"react";function q8($,M){if(!$||$.kind==="task-toggle")return null;if($.commentThreadIndex!==null){let Z=M[$.commentThreadIndex]??null;if(!Z)return null;return{kind:"comment",left:$.anchorLeft,link:$.kind==="link"?{title:$.title,url:$.url}:null,thread:Z,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 kA=600,fA=530,G2=24;function bZ({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:Z,editorState:J,editorViewportState:X,getScrollTop:Y,layoutWidth:Q,onVisibilityChange:K,scrollContentHeight:q,scrollTo:U,viewportHeight:N}){let A=RA(()=>s(J),[J]),[G,B]=LA(null),F=A.start.regionId===A.end.regionId&&A.start.offset===A.end.offset,_=i3(!0),D=i3(0),T=i3(null),O=_Z(()=>{K()}),y=_Z(()=>{D.current=typeof performance<"u"?performance.now():Date.now(),_.current=!0,O()});return jA(()=>{let R=mA({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:Z,normalizedSelection:A,state:J,viewport:X.get()});B((C)=>hA(C,R)?C:R)},[$,M,Z,J,X]),BZ(()=>{let R=J.selection.focus,C={layoutWidth:Q,offset:R.offset,regionId:R.regionId,scrollContentHeight:q,viewportHeight:N};if(gA(T.current,C))return;let m=G6(J,X.get(),R);if(!m)return;let H=Y(),P=H+G2,E=H+N-G2;if(m.top<P){let j=U(Math.max(0,m.top-G2));if(FZ(m,j,N,G2))T.current=C;return}if(m.top+m.height>E){let j=U(Math.max(0,m.top+m.height-N+G2));if(FZ(m,j,N,G2))T.current=C;return}T.current=C},[J,J.selection.focus.offset,J.selection.focus.regionId,X,Q,q,U,N]),BZ(()=>{if(_.current=!0,O(),!F||typeof window>"u")return;let R=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-D.current<kA){if(!_.current)_.current=!0,O();return}_.current=!_.current,O()},fA);return()=>{window.clearInterval(R)}},[F]),{leaf:G,isVisible:()=>_.current,markActivity:y}}function mA({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:Z,normalizedSelection:J,state:X,viewport:Y}){if(!Y)return null;let Q=X.selection.focus;if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let K=$?vA(X,Y):null;if(K)return K;let q=M?SA(X,Y):null;if(q)return q;return q8(A6(X,Y,Q,Z.liveRanges),Z.threads)}function SA($,M){let Z=$.selection.focus,J=$.documentIndex.regionIndex.get(Z.regionId),X=J?$.documentIndex.tableCellIndex.get(J.id)??null:null;if(!J||!X)return null;let Y=$.documentIndex.blockIndex.get(J.blockId),Q=Y?.type==="table"?$.documentIndex.document.blocks[Y.rootIndex]:null;if(!Y||!Q||Q.type!=="table")return null;let K=o0($,M,Z),q=uA(M,J.id),U=Math.max(1,...Q.rows.map((N)=>N.cells.length));return K&&q!==null?{cellIndex:X.cellIndex,columnCount:U,kind:"table",left:q,rowCount:Q.rows.length,rowIndex:X.rowIndex,top:K.top+K.height}:null}function uA($,M){let Z=$.layout.lines.find((J)=>J.regionId===M);return Z?Z.left:null}function vA($,M){let Z=$.selection.focus,J=$.documentIndex.regionIndex.get(Z.regionId);if(!J||J.blockType!=="paragraph"||J.text.length>0)return null;if(Z.offset!==0)return null;let X=$.documentIndex.blockIndex.get(J.blockId);if(!X||X.parentBlockId!==null)return null;let Y=o0($,M,Z);return Y?{kind:"insertion",left:Y.left,top:Y.top+Y.height}:null}function hA($,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}}function gA($,M){return $?.layoutWidth===M.layoutWidth&&$.regionId===M.regionId&&$.offset===M.offset&&$.scrollContentHeight===M.scrollContentHeight&&$.viewportHeight===M.viewportHeight}function FZ($,M,Z,J){return $.top>=M+J&&$.top+$.height<=M+Z-J}import{useEffect as IA,useEffectEvent as pA,useMemo as s3,useRef as lA,useState as rA}from"react";function DZ($){let M=s3(()=>cA($),[$]),Z=s3(()=>M.join(`
|
|
31
|
-
`),[M]),[
|
|
32
|
-
`).split(/(\n)/),l=
|
|
33
|
-
`?$4(l):Y2(l,g);if(!w)continue;l=w}return l===b?null:l}),O=G0((b,z,u)=>{let v=b.selection.focus,l={regionId:v.regionId,offset:Math.max(0,v.offset-z)},g=Z0(b,{anchor:l,focus:v});return c5(g,u)}),y=G0((b)=>{if(U.current)return;let z=q(),u=YG(b.inputType);if(b.inputType==="insertText"){if(!b.data)return;b.preventDefault(),A(T(z,b.data));return}if(b.inputType==="insertReplacementText"){if(!b.data)return;b.preventDefault();let v=b.target,l=v?.selectionStart??0,g=v?.selectionEnd??l,w=Math.max(0,g-l);A(O(z,w,b.data));return}if(XG(b.inputType)){b.preventDefault(),A($4(z));return}if(u==="backward"){b.preventDefault(),A(l5(z));return}if(u==="forward"){b.preventDefault(),A(r5(z));return}if(b.inputType==="historyUndo"){b.preventDefault(),A(d5(z)),F();return}if(b.inputType==="historyRedo"){b.preventDefault(),A(a5(z)),F();return}}),R=G0((b)=>{if(U.current)return;let z=q(),u=b.currentTarget.value;if(EZ(u,$$(z)).length===0){S4(b.currentTarget,z);return}A(T(z,u))}),C=G0((b)=>{let z=KG(q(),J.get(),b.nativeEvent,Y);if(!z)return;b.preventDefault(),A(z)}),m=G0((b)=>{let z=n3(q());if(!z)return;b.preventDefault(),b.clipboardData.setData("text/plain",z)}),H=G0((b)=>{let z=q(),u=n3(z);if(!u)return;b.preventDefault(),b.clipboardData.setData("text/plain",u),A(M4(z))}),P=G0((b)=>{let z=b.clipboardData.getData("text/plain");if(z.length===0)return;b.preventDefault(),A(c5(q(),z))}),E=G0(()=>{Q();let b=X.current;if(b)S4(b,q())}),j=G0((b)=>{if(Q(),b.target.matches(":focus-visible"))D()});e3(()=>{let b=X.current;if(!b)return;S4(b,M)},[M,X]),$G(()=>{_(M.selection.focus)},[M,_]),e3(()=>{let b=X.current;if(!b)return;let z=(u)=>y(u);return b.addEventListener("beforeinput",z),()=>b.removeEventListener("beforeinput",z)},[X,y]);let W={onCopy:m,onCut:H,onPaste:P,...K?{}:{onKeyDown:C}};return{canvasHandlers:{...W,onFocus:j},focus:D,inputHandlers:{...W,onFocus:E,onInput:R}}}var jZ="";function JG(){let[$,M]=MG(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return e3(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let Z=window.matchMedia("(pointer: coarse)"),J=(X)=>M(X.matches);return Z.addEventListener?.("change",J),()=>Z.removeEventListener?.("change",J)},[]),$}function XG($){return $==="insertLineBreak"||$==="insertParagraph"}function YG($){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 QG($){return $.replaceAll(jZ,"")}function $$($,M=ZG){let{anchor:Z,focus:J}=$.selection;if(Z.regionId!==J.regionId||Z.offset!==J.offset)return"";let X=$.documentIndex.regionIndex.get(J.regionId);if(!X)return"";return X.text.slice(Math.max(0,J.offset-M),J.offset)}function EZ($,M){let Z=QG($);return Z.startsWith(M)?Z.slice(M.length):Z}function S4($,M){let Z=$$(M),J=`${jZ}${Z}`;$.value=J,$.setSelectionRange(J.length,J.length)}function KG($,M,Z,J){if(Z.key==="Delete")return r5($);let X=zZ(Z,J);if(X){if(X==="moveToLineStart"||X==="moveToLineEnd")return D3($,M.layout,X==="moveToLineStart"?"Home":"End",Z.shiftKey);if(X==="moveToDocumentStart"||X==="moveToDocumentEnd")return H3($,X==="moveToDocumentStart"?"start":"end",Z.shiftKey);switch(X){case"insertLineBreak":return $4($);case"deleteBackward":return l5($);case"indent":return i6($);case"dedent":return s6($);case"moveListItemUp":return o6($);case"moveListItemDown":return n6($);case"toggleBold":return Z4($);case"toggleItalic":return J4($);case"toggleStrikethrough":return X4($);case"toggleUnderline":return Y4($);case"toggleInlineCode":return X3($);case"undo":return d5($);case"redo":return a5($);case"selectAll":return a6($)}}if(Z.key==="ArrowLeft"||Z.key==="ArrowRight")return _3($,Z.key==="ArrowLeft"?-1:1,Z.shiftKey);if(Z.key==="ArrowUp"||Z.key==="ArrowDown")return F3($,M.layout,Z.key==="ArrowUp"?-1:1,Z.shiftKey);if(Z.key==="PageUp"||Z.key==="PageDown")return b3($,M.layout,Z.key==="PageUp"?-1:1,Z.shiftKey);if(Z.key.length===1&&!Z.altKey&&!Z.ctrlKey&&!Z.metaKey)return Y2($,Z.key);return null}import{useEffectEvent as M$,useLayoutEffect as qG,useMemo as UG,useState as NG}from"react";function RZ({editorState:$,editorStateRef:M,editorViewportState:Z,onViewportScroll:J,scrollContainerRef:X,scheduleOverlayRender:Y,userPresence:Q}){let K=UG(()=>{if(!Q||Q.length===0)return;return D5($.documentIndex,Q)},[$.documentIndex,Q]),[q,U]=NG(void 0),N=M$(()=>{if(K===void 0){if(q!==void 0)U(void 0)}else U(L2(M.current??$,Z.get(),K));Y()}),A=M$((B)=>{if(K===void 0){if(q!==void 0)U(void 0);return}let F=L2(M.current??$,B,K);if(AG(q,F))return;U(F)});qG(()=>{N()},[K]);let G=M$((B)=>{if(!B.viewport||B.viewport.status==="unresolved")return;let F=X.current;if(!F)return;F.scrollTop=B.viewport.scrollTop,J(F)});return{presence:q,scrollToPresence:G,refreshPresence:A}}function AG($,M){if($===M)return!0;if($===void 0||M===void 0||$.length!==M.length)return!1;return $.every((Z,J)=>{let X=M[J];return Z.id===X.id&&GG(Z.viewport,X.viewport)})}function GG($,M){if($===M)return!0;if($===null||M===null)return!1;if($.status==="unresolved")return M.status==="unresolved";if(M.status==="unresolved")return!1;return $.status===M.status&&$.scrollTop===M.scrollTop}import{useEffect as BG,useEffectEvent as j1,useRef as u4}from"react";function LZ({editorStateRef:$,renderContent:M,renderOverlay:Z,renderViewport:J}){let X=u4(null),Y=u4(!1),Q=u4(!1),K=u4(!1),q=u4(!1),U=j1(()=>{if(typeof window>"u"){J();return}Y.current=!0,B()}),N=j1(()=>{if(typeof window>"u"){M(),Z();return}Q.current=!0,B()}),A=j1(()=>{if(typeof window>"u"){M();return}K.current=!0,B()}),G=j1(()=>{if(typeof window>"u"){Z();return}q.current=!0,B()}),B=j1(()=>{if(typeof window>"u"||X.current!==null)return;X.current=window.requestAnimationFrame(()=>{F()})}),F=j1(()=>{X.current=null;let D=Y.current,T=Q.current,O=K.current,y=q.current;if(Y.current=!1,Q.current=!1,K.current=!1,q.current=!1,D){J(),_();return}if(T){M(),Z(),_();return}if(O)M(),_();if(y)Z()}),_=j1(()=>{let D=$.current;if(!D||!k6(D,performance.now()))return;K.current=!0,B()});return BG(()=>{return()=>{if(typeof window>"u"||X.current===null)return;window.cancelAnimationFrame(X.current),X.current=null}},[]),{scheduleContentPaint:A,scheduleFullPaint:N,scheduleFullRender:U,scheduleOverlayPaint:G}}import{useEffectEvent as Z$,useLayoutEffect as kZ,useMemo as J$,useRef as X$,useState as fZ}from"react";function mZ({applyNextState:$,autoScrollDuringDrag:M,canShowSelectionLeaf:Z,editorState:J,editorStateRef:X,editorViewportState:Y,focusInput:Q,onActivity:K,resolvePoint:q,threads:U}){let N=J$(()=>s(J),[J]),A=J$(()=>t3(J),[J]),G=J$(()=>w5(J),[J]),[B,F]=fZ(null),[_,D]=fZ(null),T=X$(null),O=X$(null),y=X$(null);kZ(()=>{let P=_G(J,Y.get(),N);F((E)=>PG(E,P)?E:P)},[J,Y,N.end.offset,N.end.regionId,N.start.offset,N.start.regionId]),kZ(()=>{let P=bG({canShowSelectionLeaf:Z,currentLeaf:_,activeMarks:G,handles:B,selectionRange:A,threads:U});D((E)=>HG(E,P)?E:P)},[G,Z,B,_,A,U]);let R=Z$((P,E=!0)=>{D((j)=>j?.kind==="create"?{animateInitialComment:E,kind:"thread",left:j.left,threadIndex:P,top:j.top}:j)}),C=Z$((P)=>{if(P&&y.current===P.pointerId&&P.currentTarget.hasPointerCapture(P.pointerId))P.currentTarget.releasePointerCapture(P.pointerId);T.current=null,O.current=null,y.current=null}),m=Z$((P)=>{let E=X.current,j=O.current,W=q(P);if(!W||!E||!j||y.current!==P.pointerId)return;let b=R2(E,Y.get(),W,j);if(!b)return;P.preventDefault(),P.stopPropagation(),K(),M(P),$(Z0(E,{anchor:j,focus:b}))}),H=(P)=>({onPointerCancel:(E)=>{C(E)},onPointerDown:(E)=>{let j=X.current??J,W=TG(N,P),b=P==="start"?N.start:N.end;if(!B)return;E.preventDefault(),E.stopPropagation(),y.current=E.pointerId,O.current=W,T.current=P,E.currentTarget.setPointerCapture(E.pointerId),K(),Q(),$(Z0(j,{anchor:W,focus:b}))},onPointerMove:(E)=>{if(T.current!==P)return;m(E)},onPointerUp:(E)=>{if(T.current===P)m(E);C(E)}});return{endHandleProps:H("end"),handles:B,leaf:_,promoteLeafToThread:R,startHandleProps:H("start")}}function _G($,M,Z){if(Z.collapsed)return null;let J=o0($,M,Z.start),X=o0($,M,Z.end);if(!J||!X)return null;return{end:{left:X.left,top:X.top+X.height},start:{left:J.left,top:J.top}}}function FG($,M,Z){return{activeMarks:Z,kind:"create",left:M.start.left,selection:$,top:M.end.top}}function bG({activeMarks:$,canShowSelectionLeaf:M,currentLeaf:Z,handles:J,selectionRange:X,threads:Y}){if(!M||!X||!J)return null;if(Z?.kind==="thread")return Y[Z.threadIndex]?Z:null;return FG(X,J,$)}function DG($,M){return $?.kind==="create"&&$.left===M.left&&$.selection.regionId===M.selection.regionId&&$.selection.startOffset===M.selection.startOffset&&$.selection.endOffset===M.selection.endOffset&&zG($.activeMarks,M.activeMarks)&&$.top===M.top}function HG($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;if($.kind==="create"&&M.kind==="create")return DG($,M);return $.kind==="thread"&&M.kind==="thread"&&$.animateInitialComment===M.animateInitialComment&&$.left===M.left&&$.threadIndex===M.threadIndex&&$.top===M.top}function PG($,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 zG($,M){return $.length===M.length&&$.every((Z,J)=>Z===M[J])}function TG($,M){return M==="start"?$.end:$.start}import{useEffect as yG,useMemo as vZ,useState as WG}from"react";var v4={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)"},h4={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)"},SZ={...v4,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)"},uZ={...h4,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 hZ($){let M=vZ(()=>wG($),[$]),[Z,J]=WG(M.light),X=vZ(()=>OG(Z),[Z]);return yG(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){J(M.light);return}let Y=window.matchMedia("(prefers-color-scheme: dark)"),Q=()=>{J(Y.matches?M.dark:M.light)};if(Q(),typeof Y.addEventListener==="function")return Y.addEventListener("change",Q),()=>{Y.removeEventListener("change",Q)};return Y.addListener(Q),()=>{Y.removeListener(Q)}},[M]),{theme:Z,themeStyles:X}}function VG($){return"light"in $&&"dark"in $}function wG($){if(!$)return{dark:h4,light:v4};if(VG($))return $;return{dark:$,light:$}}function OG($){return{"--documint-background":$.background,"--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-mention-bg":$.mentionBackground??void 0,"--documint-mention-text":$.mentionText??void 0,"--documint-selection-handle-bg":$.selectionHandleBackground,"--documint-selection-handle-border":$.selectionHandleBorder}}import{useEffect as jG,useEffectEvent as x0,useRef as Y$,useState as U8}from"react";import{useMemo as EG}from"react";function gZ($){return EG(()=>CG({current:null},$),[$])}function CG($,M){return{peek(){return $.current},get(){let Z=$.current;if(Z!==null)return Z;let J=M();return $.current=J,J},invalidate(){$.current=null}}}function IZ($,M){let Z=M.getBoundingClientRect();return{x:$.clientX-Z.left+M.scrollLeft,y:$.clientY-Z.top+M.scrollTop}}function pZ({editorState:$,editorStateRef:M,renderResources:Z,theme:J}){let X=Y$(T1()),Y=Y$(null),Q=Y$({height:240,top:0}),[K,q]=U8(0),[U,N]=U8(240),[A,G]=U8(0),[B,F]=U8(240),_=RG(K),D=x0(()=>{let b=M.current??$,z=Q.current;return q6(b,{height:z.height,paddingX:J.paddingX,paddingY:J.paddingY,top:z.top,width:_},X.current,Z)}),T=gZ(D),O=x0((b)=>{F((z)=>{let u=kG(b,Q.current.height);return z===u?z:u})}),y=x0((b)=>{Q.current={...Q.current,top:b},G((z)=>z===b?z:b),T.invalidate()}),R=x0((b)=>{let z=LG(b),u=z.top!==Q.current.top;if(Q.current=z,G((v)=>v===z.top?v:z.top),u)T.invalidate()}),C=x0((b)=>{let z=Y.current;if(!z)return y(b),b;z.scrollTop=b;let u=z.scrollTop;return y(u),u}),m=x0(()=>{return Y.current?.scrollTop??Q.current.top}),H=x0((b,z)=>{let u=b!==null&&b.documentIndex!==z.documentIndex,v=T.peek();if(!(!u||!v||v.layout.regionLineIndices.has(z.selection.focus.regionId)))T.invalidate()}),P=x0(()=>{return T.invalidate(),T.get()}),E=x0((b)=>{let z=Y.current;return z?IZ(b,z):null}),j=x0((b)=>{wZ(Y.current,b)});return jG(()=>{let b=Y.current;if(!b||typeof ResizeObserver>"u")return;let z=new ResizeObserver((u)=>{let v=u[0];if(!v)return;let l=Math.max(0,Math.floor(v.contentRect.width)),g=lZ(b);Q.current={...Q.current,height:g},q((w)=>w===l?w:l),N((w)=>w===g?w:g)});return z.observe(b),()=>z.disconnect()},[Y]),{actions:{autoScrollDuringDrag:j,getScrollTop:m,observePreparedViewport:O,observeScrollContainer:R,prepareNextPaint:P,reconcileEditorState:H,resolvePoint:E,scrollTo:C},props:{getScrollContainer:(b)=>({onScroll:(z)=>{R(z.currentTarget),b?.onScroll?.(z)},ref:Y}),scrollContent:{style:{height:`${B}px`}}},refs:{scrollContainer:Y},state:{layoutWidth:_,preparedViewport:T,scrollContentHeight:B,surfaceWidth:K,viewportHeight:U,viewportTop:A}}}function RG($){return Math.max(240,Math.floor($||480))}function lZ($){return Math.max(240,$.clientHeight)}function LG($){return{height:lZ($),top:$.scrollTop}}function kG($,M){return Math.max(M,Math.ceil($.totalHeight+24))}function fG(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function Q$($,{paintHeight:M,paintTop:Z,width:J}){if(!$)return null;let X=Math.max(240,Math.ceil(M)),Y=fG();$.width=Math.ceil(J*Y),$.height=Math.ceil(X*Y),$.style.width=`${J}px`,$.style.height=`${X}px`,$.style.transform=`translateY(${Z}px)`;let Q=$.getContext("2d");if(!Q)return null;return{context:Q,devicePixelRatio:Y,height:X,width:J}}function K$($,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}function rZ($,M){if(!M?.length||!$?.length)return;let Z=new Map($.map((X)=>[X.id,X])),J=[];for(let X of M){let Y=Z.get(X.userId);if(!Y)continue;J.push({...Y,color:X.color,cursor:X.cursor})}return J.length===0?void 0:J}function xZ($,M){if(!$)return{didReconcile:!1,state:M};let Z=mG($,M)??rG($,M);return Z?{didReconcile:!0,state:Z}:{didReconcile:!1,state:M}}function mG($,M){let Z=SG($,M);return Z?Z0(M,Z,!1):null}function SG($,M){if(N$($.selection.anchor,$.selection.focus)){let Y=q$($,M,$.selection.focus,"neutral");return Y?{anchor:Y,focus:Y}:null}let Z=pG($),J=q$($,M,$.selection.anchor,Z.anchor),X=q$($,M,$.selection.focus,Z.focus);return J&&X?{anchor:J,focus:X}:null}function q$($,M,Z,J){let X=$.documentIndex.regionIndex.get(Z.regionId);if(!X)return null;let Y=U$(X,M);if(!Y)return null;return{offset:vG(X.text,Y.text,Z.offset,J),regionId:Y.id}}function U$($,M){let Z=M.documentIndex.regionIndex.get($.id);if(Z)return Z;if($.text.length===0)return null;let J=uG($,M);if(J)return J;return M.documentIndex.regionPathIndex.get($.path)??null}function uG($,M){let Z=null;for(let J of M.documentIndex.regions){if(J.blockType!==$.blockType||J.text!==$.text)continue;if(Z)return null;Z=J}return Z}function vG($,M,Z,J){let X=L0(Z,0,$.length),{prefix:Y,suffix:Q}=w8($,X,X),K=hG(M,Y,Q);if(K!==null)return K;let q=gG(M,Y),U=IG(M,Q);if(J==="before-suffix")return U??q??L0(Z,0,M.length);return q??U??L0(Z,0,M.length)}function hG($,M,Z){let J=p1($,M,Z).filter((X)=>X.startOffset===X.endOffset);return J.length===1?J[0].startOffset:null}function gG($,M){let Z=g0($,M);return Z.length===1?Z[0]+M.length:null}function IG($,M){let Z=g0($,M);return Z.length===1?Z[0]:null}function pG($){let{anchor:M,focus:Z}=$.selection;if(N$(M,Z))return{anchor:"neutral",focus:"neutral"};return lG($,M,Z)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function lG($,M,Z){let J=$.documentIndex.regionOrderIndex.get(M.regionId),X=$.documentIndex.regionOrderIndex.get(Z.regionId);if(J===void 0||X===void 0)return 0;return J===X?M.offset-Z.offset:J-X}function rG($,M){if(!N$($.selection.anchor,$.selection.focus))return null;let Z=cG($);if(!Z)return null;let J=xG($,M,Z);if(J===null)return null;return dG(M,J)}function cG($){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 xG($,M,Z){let J=cZ($,Z.rootIndex,"before"),X=cZ($,Z.rootIndex,"after"),Y=J?U$(J,M):null,Q=X?U$(X,M):null;if(Y&&Q)return Y.rootIndex<Q.rootIndex?Q.rootIndex:null;if(Y)return Y.rootIndex+1;if(Q)return Q.rootIndex;return null}function dG($,M){let Z=g1($.documentIndex.document,M,0,[p({text:""})]),J={...$,documentIndex:e1($.documentIndex,Z,M,0)},X=h2(J.documentIndex,t(M));return X?Z0(J,X,!1):null}function cZ($,M,Z){let J=Z==="before"?-1:1;for(let X=M+J;X>=0&&X<$.documentIndex.roots.length;X+=J){let Y=aG($,X,Z);if(Y)return Y}return null}function aG($,M,Z){let J=$.documentIndex.roots[M]?.regions??[],X=Z==="before"?J.length-1:0,Y=Z==="before"?-1:1;for(let Q=X;Q>=0&&Q<J.length;Q+=Y){let K=J[Q];if(K&&K.text.length>0)return K}return null}function N$($,M){return $.regionId===M.regionId&&$.offset===M.offset}import{jsxDEV as c,Fragment as MB}from"react/jsx-dev-runtime";function A8({blocks:$}){return c(MB,{children:$.map((M)=>iG(M))},void 0,!1,void 0,this)}function iG($){switch($.type){case"blockquote":return c("blockquote",{className:"preview-block preview-block-blockquote",children:c(A8,{blocks:$.children},void 0,!1,void 0,this)},$.id,!1,void 0,this);case"code":return c("div",{className:"preview-block preview-block-code",children:[c("div",{className:"preview-rich-header",children:nG($.language,$.meta)},void 0,!1,void 0,this),c("pre",{children:c("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 c(M,{className:"preview-block preview-block-heading",children:N8($.children)},$.id,!1,void 0,this)}case"list":return $.ordered?c("ol",{className:"preview-block preview-block-list",start:$.start??1,children:$.items.map((M)=>A$(M))},$.id,!1,void 0,this):c("ul",{className:"preview-block preview-block-list",children:$.items.map((M)=>A$(M))},$.id,!1,void 0,this);case"listItem":return A$($);case"paragraph":return c("p",{className:"preview-block preview-block-paragraph",children:N8($.children)},$.id,!1,void 0,this);case"table":return c("div",{className:"preview-block preview-block-table",children:[c("div",{className:"preview-rich-header",children:tG($.rows.length,$.rows[0]?.cells.length??0,$.align.filter((M)=>M!==null).length)},void 0,!1,void 0,this),c("div",{className:"preview-table-scroll",children:c("table",{children:c("tbody",{children:$.rows.map((M)=>c("tr",{children:M.cells.map((Z)=>c("td",{children:N8(Z.children)},Z.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 c("hr",{className:"preview-block preview-block-rule"},$.id,!1,void 0,this);case"directive":return c("pre",{className:`preview-block preview-block-directive preview-block-directive-${$.name}`,children:$.body},$.id,!1,void 0,this);case"unsupported":return c("pre",{className:"preview-block preview-block-unsupported",children:$.source},$.id,!1,void 0,this)}}function A$($){return c("li",{className:"preview-block preview-block-list-item",children:c(A8,{blocks:$.children},void 0,!1,void 0,this)},$.id,!1,void 0,this)}function N8($){return $.map((M)=>{switch(M.type){case"break":return c("br",{},M.id,!1,void 0,this);case"image":return c("span",{className:"preview-inline preview-inline-image",children:[c("img",{alt:M.alt??"",src:M.url,title:M.title??""},void 0,!1,void 0,this),c("span",{children:[c("strong",{children:eG(M.alt)},void 0,!1,void 0,this),c("small",{children:$B(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 c("code",{className:"preview-inline preview-inline-code",children:M.code},M.id,!1,void 0,this);case"link":return sG(M);case"text":return c("span",{className:"preview-inline",children:oG(M.text,M.marks)},M.id,!1,void 0,this);case"unsupported":return c("span",{className:"preview-inline preview-inline-unsupported",children:M.source},M.id,!1,void 0,this)}})}function sG($){return c("a",{className:"preview-inline preview-inline-link",href:$.url,children:N8($.children)},$.id,!1,void 0,this)}function oG($,M){let Z=$;for(let J of M)switch(J){case"strikethrough":Z=c("del",{children:Z},void 0,!1,void 0,this);break;case"italic":Z=c("em",{children:Z},void 0,!1,void 0,this);break;case"bold":Z=c("strong",{children:Z},void 0,!1,void 0,this);break;case"underline":Z=c("ins",{children:Z},void 0,!1,void 0,this);break}return Z}function nG($,M){return[$??"plain text",M].filter(Boolean).join(" • ")}function tG($,M,Z){let J=Z>0?`${Z} aligned ${Z===1?"column":"columns"}`:"no alignment";return`${$} ${$===1?"row":"rows"} • ${M} ${M===1?"column":"columns"} • ${J}`}function eG($){return $?.trim()?$:"Untitled image"}function $B($,M){return M?.trim()?`${M} • ${$}`:$}var dZ=`/* Base Documint host and SSR-fallback styles. */
|
|
12
|
+
`)}var I8=null,dZ;function aZ(){if(I8===null)I8=new Intl.Segmenter(dZ,{granularity:"word"});return I8}var iZ=/\p{Script=Arabic}/u,D5=/\p{M}/u,t$=/\p{Nd}/u;function p8($){return iZ.test($)}function a0($){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 c8=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),O2=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),x8=new Set(["'","’"]),c1=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),sZ=new Set([":",".","،","؛"]),oZ=new Set(["၏"]),nZ=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function tZ($){if(d8($))return!0;let M=!1;for(let J of $){if(c1.has(J)){M=!0;continue}if(M&&D5.test(J))continue;return!1}return M}function eZ($){for(let M of $)if(!c8.has(M)&&!c1.has(M))return!1;return $.length>0}function $X($){if(d8($))return!0;for(let M of $)if(!O2.has(M)&&!x8.has(M)&&!D5.test(M))return!1;return $.length>0}function d8($){let M=!1;for(let J of $){if(J==="\\"||D5.test(J))continue;if(O2.has(J)||c1.has(J)||x8.has(J)){M=!0;continue}return!1}return M}function MX($){let M=Array.from($),J=M.length;while(J>0){let Z=M[J-1];if(D5.test(Z)){J--;continue}if(O2.has(Z)||x8.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 JX($,M){if($.length===0)return!1;for(let J of $)if(J!==M)return!1;return!0}function ZX($){if(!p8($)||$.length===0)return!1;return sZ.has($[$.length-1])}function XX($){if($.length===0)return!1;return oZ.has($[$.length-1])}function DX($){if($.length<2||$[0]!==" ")return null;let M=$.slice(1);if(/^\p{M}+$/u.test(M))return{space:" ",marks:M};return null}function a8($){for(let M=$.length-1;M>=0;M--){let J=$[M];if(nZ.has(J))return!0;if(!c1.has(J))return!1}return!1}function YX($,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 i0($){return $.length===1?$[0]:$.join("")}function QX($,M,J,Z){let X=[],D=null,Y=[],Q=J,K=!1,q=0;for(let U of $){let N=YX(U,Z),A=N==="text"&&M;if(D!==null&&N===D&&A===K){Y.push(U),q+=U.length;continue}if(D!==null)X.push({text:i0(Y),isWordLike:K,kind:D,start:Q});D=N,Y=[U],Q=J+q,K=A,q+=U.length}if(D!==null)X.push({text:i0(Y),isWordLike:K,kind:D,start:Q});return X}function l8($){return $==="space"||$==="preserved-space"||$==="zero-width-break"||$==="hard-break"}var KX=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function qX($,M){let J=$.texts[M];if(J.startsWith("www."))return!0;return KX.test(J)&&M+1<$.len&&$.kinds[M+1]==="text"&&$.texts[M+1]==="//"}function UX($){return $.includes("?")&&($.includes("://")||$.startsWith("www."))}function NX($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let Y=0;Y<$.len;Y++){if(Z[Y]!=="text"||!qX($,Y))continue;let Q=[M[Y]],K=Y+1;while(K<$.len&&!l8(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]=i0(Q)}let D=0;for(let Y=0;Y<M.length;Y++){let Q=M[Y];if(Q.length===0)continue;if(D!==Y)M[D]=Q,J[D]=J[Y],Z[D]=Z[Y],X[D]=X[Y];D++}return M.length=D,J.length=D,Z.length=D,X.length=D,{len:D,texts:M,isWordLike:J,kinds:Z,starts:X}}function AX($){let M=[],J=[],Z=[],X=[];for(let D=0;D<$.len;D++){let Y=$.texts[D];if(M.push(Y),J.push($.isWordLike[D]),Z.push($.kinds[D]),X.push($.starts[D]),!UX(Y))continue;let Q=D+1;if(Q>=$.len||l8($.kinds[Q]))continue;let K=[],q=$.starts[Q],U=Q;while(U<$.len&&!l8($.kinds[U]))K.push($.texts[U]),U++;if(K.length>0)M.push(i0(K)),J.push(!0),Z.push("text"),X.push(q),D=U-1}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}var VX=new Set([":","-","/","×",",",".","+","–","—"]),o$=/^[A-Za-z0-9_]+[,:;]*$/,n$=/[,:;]+$/;function e$($){for(let M of $)if(t$.test(M))return!0;return!1}function r8($){if($.length===0)return!1;for(let M of $){if(t$.test(M)||VX.has(M))continue;return!1}return!0}function GX($){let M=[],J=[],Z=[],X=[];for(let D=0;D<$.len;D++){let Y=$.texts[D],Q=$.kinds[D];if(Q==="text"&&r8(Y)&&e$(Y)){let K=[Y],q=D+1;while(q<$.len&&$.kinds[q]==="text"&&r8($.texts[q]))K.push($.texts[q]),q++;M.push(i0(K)),J.push(!0),Z.push("text"),X.push($.starts[D]),D=q-1;continue}M.push(Y),J.push($.isWordLike[D]),Z.push(Q),X.push($.starts[D])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function BX($){let M=[],J=[],Z=[],X=[];for(let D=0;D<$.len;D++){let Y=$.texts[D],Q=$.kinds[D],K=$.isWordLike[D];if(Q==="text"&&K&&o$.test(Y)){let q=[Y],U=n$.test(Y),N=D+1;while(U&&N<$.len&&$.kinds[N]==="text"&&$.isWordLike[N]&&o$.test($.texts[N])){let A=$.texts[N];q.push(A),U=n$.test(A),N++}M.push(i0(q)),J.push(!0),Z.push("text"),X.push($.starts[D]),D=N-1;continue}M.push(Y),J.push(K),Z.push(Q),X.push($.starts[D])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function FX($){let M=[],J=[],Z=[],X=[];for(let D=0;D<$.len;D++){let Y=$.texts[D];if($.kinds[D]==="text"&&Y.includes("-")){let Q=Y.split("-"),K=Q.length>1;for(let q=0;q<Q.length;q++){let U=Q[q];if(!K)break;if(U.length===0||!e$(U)||!r8(U))K=!1}if(K){let q=0;for(let U=0;U<Q.length;U++){let N=Q[U],A=U<Q.length-1?`${N}-`:N;M.push(A),J.push(!0),Z.push("text"),X.push($.starts[D]+q),q+=A.length}continue}}M.push(Y),J.push($.isWordLike[D]),Z.push($.kinds[D]),X.push($.starts[D])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function _X($){let M=[],J=[],Z=[],X=[],D=0;while(D<$.len){let Y=[$.texts[D]],Q=$.isWordLike[D],K=$.kinds[D],q=$.starts[D];if(K==="glue"){let U=[Y[0]],N=q;D++;while(D<$.len&&$.kinds[D]==="glue")U.push($.texts[D]),D++;let A=i0(U);if(D<$.len&&$.kinds[D]==="text")Y[0]=A,Y.push($.texts[D]),Q=$.isWordLike[D],K="text",q=N,D++;else{M.push(A),J.push(!1),Z.push("glue"),X.push(N);continue}}else D++;if(K==="text")while(D<$.len&&$.kinds[D]==="glue"){let U=[];while(D<$.len&&$.kinds[D]==="glue")U.push($.texts[D]),D++;let N=i0(U);if(D<$.len&&$.kinds[D]==="text"){Y.push(N,$.texts[D]),Q=Q||$.isWordLike[D],D++;continue}Y.push(N)}M.push(i0(Y)),J.push(Q),Z.push(K),X.push(q)}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function bX($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let D=0;D<M.length-1;D++){if(Z[D]!=="text"||Z[D+1]!=="text")continue;if(!a0(M[D])||!a0(M[D+1]))continue;let Y=MX(M[D]);if(Y===null)continue;M[D]=Y.head,M[D+1]=Y.tail+M[D+1],X[D+1]=X[D]+Y.head.length}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function HX($,M,J){let Z=aZ(),X=0,D=[],Y=[],Q=[],K=[];for(let A of Z.segment($))for(let V of QX(A.segment,A.isWordLike??!1,A.index,J)){let B=V.kind==="text";if(M.carryCJKAfterClosingQuote&&B&&X>0&&Q[X-1]==="text"&&a0(V.text)&&a0(D[X-1])&&a8(D[X-1]))D[X-1]+=V.text,Y[X-1]=Y[X-1]||V.isWordLike;else if(B&&X>0&&Q[X-1]==="text"&&eZ(V.text)&&a0(D[X-1]))D[X-1]+=V.text,Y[X-1]=Y[X-1]||V.isWordLike;else if(B&&X>0&&Q[X-1]==="text"&&XX(D[X-1]))D[X-1]+=V.text,Y[X-1]=Y[X-1]||V.isWordLike;else if(B&&X>0&&Q[X-1]==="text"&&V.isWordLike&&p8(V.text)&&ZX(D[X-1]))D[X-1]+=V.text,Y[X-1]=!0;else if(B&&!V.isWordLike&&X>0&&Q[X-1]==="text"&&V.text.length===1&&V.text!=="-"&&V.text!=="—"&&JX(D[X-1],V.text))D[X-1]+=V.text;else if(B&&!V.isWordLike&&X>0&&Q[X-1]==="text"&&(tZ(V.text)||V.text==="-"&&Y[X-1]))D[X-1]+=V.text;else D[X]=V.text,Y[X]=V.isWordLike,Q[X]=V.kind,K[X]=V.start,X++}for(let A=1;A<X;A++)if(Q[A]==="text"&&!Y[A]&&d8(D[A])&&Q[A-1]==="text")D[A-1]+=D[A],Y[A-1]=Y[A-1]||Y[A],D[A]="";for(let A=X-2;A>=0;A--)if(Q[A]==="text"&&!Y[A]&&$X(D[A])){let V=A+1;while(V<X&&D[V]==="")V++;if(V<X&&Q[V]==="text")D[V]=D[A]+D[V],K[V]=K[A],D[A]=""}let q=0;for(let A=0;A<X;A++){let V=D[A];if(V.length===0)continue;if(q!==A)D[q]=V,Y[q]=Y[A],Q[q]=Q[A],K[q]=K[A];q++}D.length=q,Y.length=q,Q.length=q,K.length=q;let U=_X({len:q,texts:D,isWordLike:Y,kinds:Q,starts:K}),N=bX(BX(FX(GX(AX(NX(U))))));for(let A=0;A<N.len-1;A++){let V=DX(N.texts[A]);if(V===null)continue;if(N.kinds[A]!=="space"&&N.kinds[A]!=="preserved-space"||N.kinds[A+1]!=="text"||!p8(N.texts[A+1]))continue;N.texts[A]=V.space,N.isWordLike[A]=!1,N.kinds[A]=N.kinds[A]==="preserved-space"?"preserved-space":"space",N.texts[A+1]=V.marks+N.texts[A+1],N.starts[A+1]=N.starts[A]+V.space.length}return N}function PX($,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 $9($,M,J="normal"){let Z=rZ(J),X=Z.mode==="pre-wrap"?xZ($):cZ($);if(X.length===0)return{normalized:X,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let D=HX(X,M,Z);return{normalized:X,chunks:PX(D,Z),...D}}var x1=null,M9=new Map,d1=null,zX=/\p{Emoji_Presentation}/u,WX=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,i8=null,J9=new Map;function s8(){if(x1!==null)return x1;if(typeof OffscreenCanvas<"u")return x1=new OffscreenCanvas(1,1).getContext("2d"),x1;if(typeof document<"u")return x1=document.createElement("canvas").getContext("2d"),x1;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function EX($){let M=M9.get($);if(!M)M=new Map,M9.set($,M);return M}function X1($,M){let J=M.get($);if(J===void 0)J={width:s8().measureText($).width,containsCJK:a0($)},M.set($,J);return J}function a1(){if(d1!==null)return d1;if(typeof navigator>"u")return d1={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},d1;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 d1={lineFitEpsilon:J?0.015625:0.005,carryCJKAfterClosingQuote:Z,preferPrefixWidthsForBreakableRuns:J,preferEarlySoftHyphenBreak:J},d1}function TX($){let M=$.match(/(\d+(?:\.\d+)?)\s*px/);return M?parseFloat(M[1]):16}function o8(){if(i8===null)i8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return i8}function yX($){return zX.test($)||$.includes("️")}function Z9($){return WX.test($)}function wX($,M){let J=J9.get($);if(J!==void 0)return J;let Z=s8();Z.font=$;let X=Z.measureText("\uD83D\uDE00").width;if(J=0,X>M+0.5&&typeof document<"u"&&document.body!==null){let D=document.createElement("span");D.style.font=$,D.style.display="inline-block",D.style.visibility="hidden",D.style.position="absolute",D.textContent="\uD83D\uDE00",document.body.appendChild(D);let Y=D.getBoundingClientRect().width;if(document.body.removeChild(D),X-Y>0.5)J=X-Y}return J9.set($,J),J}function OX($){let M=0,J=o8();for(let Z of J.segment($))if(yX(Z.segment))M++;return M}function CX($,M){if(M.emojiCount===void 0)M.emojiCount=OX($);return M.emojiCount}function D1($,M,J){if(J===0)return M.width;return M.width-CX($,M)*J}function X9($,M,J,Z){if(M.graphemeWidths!==void 0)return M.graphemeWidths;let X=[],D=o8();for(let Y of D.segment($)){let Q=X1(Y.segment,J);X.push(D1(Y.segment,Q,Z))}return M.graphemeWidths=X.length>1?X:null,M.graphemeWidths}function D9($,M,J,Z){if(M.graphemePrefixWidths!==void 0)return M.graphemePrefixWidths;let X=[],D=o8(),Y="";for(let Q of D.segment($)){Y+=Q.segment;let K=X1(Y,J);X.push(D1(Y,K,Z))}return M.graphemePrefixWidths=X.length>1?X:null,M.graphemePrefixWidths}function Y9($,M){let J=s8();J.font=$;let Z=EX($),X=TX($),D=M?wX($,X):0;return{cache:Z,fontSize:X,emojiCorrection:D}}function Y5($){return $==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen"}function jX($,M){while(M<$.widths.length){let J=$.kinds[M];if(J!=="space"&&J!=="zero-width-break"&&J!=="soft-hyphen")break;M++}return M}function LX($,M){if(M<=0)return 0;let J=$%M;if(Math.abs(J)<=0.000001)return M;return M-J}function Q9($,M,J,Z){if(!Z||M===null)return $[J];return M[J]-(J>0?M[J-1]:0)}function RX($,M,J,Z,X,D){let Y=0,Q=M;while(Y<$.length){let K=D?M+$[Y]:Q+$[Y];if((Y+1<$.length?K+X:K)>J+Z)break;Q=K,Y++}return{fitCount:Y,fittedWidth:Q}}function kX($,M,J){let{widths:Z,kinds:X,breakableWidths:D,breakablePrefixWidths:Y}=$;if(Z.length===0)return 0;let Q=a1(),K=Q.lineFitEpsilon,q=0,U=0,N=!1,A=0,V=0,B=0,G=0,b=-1,P=0;function y(){b=-1,P=0}function z(W=B,F=G,H=U){q++,J?.({startSegmentIndex:A,startGraphemeIndex:V,endSegmentIndex:W,endGraphemeIndex:F,width:H}),U=0,N=!1,y()}function L(W,F){N=!0,A=W,V=0,B=W+1,G=0,U=F}function R(W,F,H){N=!0,A=W,V=F,B=W,G=F+1,U=H}function m(W,F){if(!N){L(W,F);return}U+=F,B=W+1,G=0}function E(W,F){if(!Y5(X[W]))return;b=W+1,P=U-F}function _(W){j(W,0)}function j(W,F){let H=D[W],v=Y[W]??null;for(let h=F;h<H.length;h++){let l=Q9(H,v,h,Q.preferPrefixWidthsForBreakableRuns);if(!N){R(W,h,l);continue}if(U+l>M+K)z(),R(W,h,l);else U+=l,B=W,G=h+1}if(N&&B===W&&G===H.length)B=W+1,G=0}let C=0;while(C<Z.length){if(!N){if(C=jX($,C),C>=Z.length)break}let W=Z[C],F=X[C];if(!N){if(W>M&&D[C]!==null)_(C);else L(C,W);E(C,W),C++;continue}if(U+W>M+K){if(Y5(F)){m(C,W),z(C+1,0,U-W),C++;continue}if(b>=0){if(B>b||B===b&&G>0){z();continue}z(b,0,P);continue}if(W>M&&D[C]!==null){z(),_(C),C++;continue}z();continue}m(C,W),E(C,W),C++}if(N)z();return q}function K9($,M,J){if($.simpleLineWalkFastPath)return kX($,M,J);let{widths:Z,lineEndFitAdvances:X,lineEndPaintAdvances:D,kinds:Y,breakableWidths:Q,breakablePrefixWidths:K,discretionaryHyphenWidth:q,tabStopAdvance:U,chunks:N}=$;if(Z.length===0||N.length===0)return 0;let A=a1(),V=A.lineFitEpsilon,B=0,G=0,b=!1,P=0,y=0,z=0,L=0,R=-1,m=0,E=0,_=null;function j(){R=-1,m=0,E=0,_=null}function C(T=z,k=L,f=G){B++,J?.({startSegmentIndex:P,startGraphemeIndex:y,endSegmentIndex:T,endGraphemeIndex:k,width:f}),G=0,b=!1,j()}function W(T,k){b=!0,P=T,y=0,z=T+1,L=0,G=k}function F(T,k,f){b=!0,P=T,y=k,z=T,L=k+1,G=f}function H(T,k){if(!b){W(T,k);return}G+=k,z=T+1,L=0}function v(T,k){if(!Y5(Y[T]))return;let f=Y[T]==="tab"?0:X[T],d=Y[T]==="tab"?k:D[T];R=T+1,m=G-k+f,E=G-k+d,_=Y[T]}function h(T){l(T,0)}function l(T,k){let f=Q[T],d=K[T]??null;for(let I=k;I<f.length;I++){let U0=Q9(f,d,I,A.preferPrefixWidthsForBreakableRuns);if(!b){F(T,I,U0);continue}if(G+U0>M+V)C(),F(T,I,U0);else G+=U0,z=T,L=I+1}if(b&&z===T&&L===f.length)z=T+1,L=0}function p(T){if(_!=="soft-hyphen")return!1;let k=Q[T];if(k===null)return!1;let f=A.preferPrefixWidthsForBreakableRuns?K[T]??k:k,d=f!==k,{fitCount:I,fittedWidth:U0}=RX(f,G,M,V,q,d);if(I===0)return!1;if(G=U0,z=T,L=I,j(),I===k.length)return z=T+1,L=0,!0;return C(T,I,U0+q),l(T,I),!0}function O(T){B++,J?.({startSegmentIndex:T.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:T.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),j()}for(let T=0;T<N.length;T++){let k=N[T];if(k.startSegmentIndex===k.endSegmentIndex){O(k);continue}b=!1,G=0,P=k.startSegmentIndex,y=0,z=k.startSegmentIndex,L=0,j();let f=k.startSegmentIndex;while(f<k.endSegmentIndex){let d=Y[f],I=d==="tab"?LX(G,U):Z[f];if(d==="soft-hyphen"){if(b)z=f+1,L=0,R=f+1,m=G+q,E=G+q,_=d;f++;continue}if(!b){if(I>M&&Q[f]!==null)h(f);else W(f,I);v(f,I),f++;continue}if(G+I>M+V){let z0=G+(d==="tab"?0:X[f]),_0=G+(d==="tab"?I:D[f]);if(_==="soft-hyphen"&&A.preferEarlySoftHyphenBreak&&m<=M+V){C(R,0,E);continue}if(_==="soft-hyphen"&&p(f)){f++;continue}if(Y5(d)&&z0<=M+V){H(f,I),C(f+1,0,_0),f++;continue}if(R>=0&&m<=M+V){if(z>R||z===R&&L>0){C();continue}let R1=R;C(R1,0,E),f=R1;continue}if(I>M&&Q[f]!==null){C(),h(f),f++;continue}C();continue}H(f,I),v(f,I),f++}if(b){let d=R===k.consumedEndSegmentIndex?E:G;C(k.consumedEndSegmentIndex,0,d)}}return B}var n8=null,q9=new WeakMap;function N9(){if(n8===null)n8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return n8}function fX($){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 mX($,M,J){let Z=N9(),X=a1(),{cache:D,emojiCorrection:Y}=Y9(M,Z9($.normalized)),Q=D1("-",X1("-",D),Y),q=D1(" ",X1(" ",D),Y)*8;if($.len===0)return fX(J);let U=[],N=[],A=[],V=[],B=$.chunks.length<=1,G=J?[]:null,b=[],P=[],y=J?[]:null,z=Array.from({length:$.len}),L=Array.from({length:$.len});function R(_,j,C,W,F,H,v,h){if(F!=="text"&&F!=="space"&&F!=="zero-width-break")B=!1;if(U.push(j),N.push(C),A.push(W),V.push(F),G?.push(H),b.push(v),P.push(h),y!==null)y.push(_)}for(let _=0;_<$.len;_++){z[_]=U.length;let j=$.texts[_],C=$.isWordLike[_],W=$.kinds[_],F=$.starts[_];if(W==="soft-hyphen"){R(j,0,Q,Q,W,F,null,null),L[_]=U.length;continue}if(W==="hard-break"){R(j,0,0,0,W,F,null,null),L[_]=U.length;continue}if(W==="tab"){R(j,0,0,0,W,F,null,null),L[_]=U.length;continue}let H=X1(j,D);if(W==="text"&&H.containsCJK){let p="",O=0;for(let T of Z.segment(j)){let k=T.segment;if(p.length===0){p=k,O=T.index;continue}if(O2.has(p)||c8.has(k)||c1.has(k)||X.carryCJKAfterClosingQuote&&a0(k)&&a8(p)){p+=k;continue}let f=X1(p,D),d=D1(p,f,Y);R(p,d,d,d,"text",F+O,null,null),p=k,O=T.index}if(p.length>0){let T=X1(p,D),k=D1(p,T,Y);R(p,k,k,k,"text",F+O,null,null)}L[_]=U.length;continue}let v=D1(j,H,Y),h=W==="space"||W==="preserved-space"||W==="zero-width-break"?0:v,l=W==="space"||W==="zero-width-break"?0:v;if(C&&j.length>1){let p=X9(j,H,D,Y),O=X.preferPrefixWidthsForBreakableRuns?D9(j,H,D,Y):null;R(j,v,h,l,W,F,p,O)}else R(j,v,h,l,W,F,null,null);L[_]=U.length}let m=SX($.chunks,z,L),E=G===null?null:s$($.normalized,G);if(y!==null)return{widths:U,lineEndFitAdvances:N,lineEndPaintAdvances:A,kinds:V,simpleLineWalkFastPath:B,segLevels:E,breakableWidths:b,breakablePrefixWidths:P,discretionaryHyphenWidth:Q,tabStopAdvance:q,chunks:m,segments:y};return{widths:U,lineEndFitAdvances:N,lineEndPaintAdvances:A,kinds:V,simpleLineWalkFastPath:B,segLevels:E,breakableWidths:b,breakablePrefixWidths:P,discretionaryHyphenWidth:Q,tabStopAdvance:q,chunks:m}}function SX($,M,J){let Z=[];for(let X=0;X<$.length;X++){let D=$[X],Y=D.startSegmentIndex<M.length?M[D.startSegmentIndex]:J[J.length-1]??0,Q=D.endSegmentIndex<M.length?M[D.endSegmentIndex]:J[J.length-1]??0,K=D.consumedEndSegmentIndex<M.length?M[D.consumedEndSegmentIndex]:J[J.length-1]??0;Z.push({startSegmentIndex:Y,endSegmentIndex:Q,consumedEndSegmentIndex:K})}return Z}function uX($,M,J,Z){let X=$9($,a1(),Z?.whiteSpace);return mX(X,M,J)}function A9($,M,J){return uX($,M,!0,J)}function vX($){return $}function U9($,M,J){let Z=J.get($);if(Z!==void 0)return Z;Z=[];let X=N9();for(let D of X.segment(M[$]))Z.push(D.segment);return J.set($,Z),Z}function hX($){let M=q9.get($);if(M!==void 0)return M;return M=new Map,q9.set($,M),M}function gX($,M,J,Z){return Z>0&&$[Z-1]==="soft-hyphen"&&!(M===Z&&J>0)}function IX($,M,J,Z,X,D,Y){let Q="",K=gX(M,Z,X,D);for(let q=Z;q<D;q++){if(M[q]==="soft-hyphen"||M[q]==="hard-break")continue;if(q===Z&&X>0)Q+=U9(q,$,J).slice(X).join("");else Q+=$[q]}if(Y>0){if(K)Q+="-";Q+=U9(D,$,J).slice(Z===D?X:0,Y).join("")}else if(K)Q+="-";return Q}function pX($,M,J,Z,X,D,Y){return{text:IX($.segments,$.kinds,M,Z,X,D,Y),width:J,start:{segmentIndex:Z,graphemeIndex:X},end:{segmentIndex:D,graphemeIndex:Y}}}function lX($,M,J){return pX($,M,J.width,J.startSegmentIndex,J.startGraphemeIndex,J.endSegmentIndex,J.endGraphemeIndex)}function V9($,M,J){let Z=[];if($.widths.length===0)return{lineCount:0,height:0,lines:Z};let X=hX($),D=K9(vX($),M,(Y)=>{Z.push(lX($,X,Y))});return{lineCount:D,height:D*J,lines:Z}}function t8($,M,J){let Z=$.image?M.images.get($.image.url)??null:null,X=$.image?.width??null,D=Math.min(J,X??240),Y=Math.max(120,Math.round(D*0.5625));if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return{height:Y,width:D};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 G9($,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 B9=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],Q5;function i1($){if($?.type==="heading"){let{fontSize:M}=b9($.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 E1($,M){if($?.type==="heading")return b9($.depth).lineHeight;if($?.type==="code")return 22;return M}function b9($){return B9[$-1]??B9.at(-1)}function s1($,M,J,Z,X,D,Y){let Q=`${q5(M,Y)}:${X}:${D}:${J}`,K=$.measuredLines.get(Q);if(K)return K;let q=cX($,M,J,Z,X,D,Y);return r$($,Q,q)}function K5($,M,J,Z,X,D,Y,Q){let K=`${q5(M,Q)}:${J}:${Z}:${D}:${Y}`,q=$.lineBoundaries.get(K);if(q)return q;let U=P9();if(!U)return _9(X);let N=[{left:0,offset:0}],A=0,V=M.inlines.filter((B)=>B.end>J&&B.start<Z);if(V.length===0)return _9(X);for(let B of V){let G=Math.max(J,B.start),b=Math.min(Z,B.end),P=M.text.slice(G,b),y=G-J;if(B.kind==="image"){let z=t8(B,Q,Y).width;A+=z,y+=P.length,N.push({left:A,offset:y});continue}U.font=H9(D,B.marks);for(let z of Array.from(P))A+=z9($,U,z),y+=z.length,N.push({left:A,offset:y})}return c$($,K,N)}function rX($,M,J,Z){let X=`${J}::${Z}::${M}`,D=$.preparedText.get(X);if(D)return D;let Y=A9(M,J,{whiteSpace:Z});return l$($,X,Y)}function cX($,M,J,Z,X,D,Y){let Q=M.text;if(Q.length===0)return[{end:0,height:D,start:0,text:"",width:0}];if(sX(M))return dX($,M,J,X,D,Y);try{let K=rX($,Q,J,$D(Z));return V9(K,X,D).lines.map((U)=>({end:F9(K.segments,U.end),height:D,start:F9(K.segments,U.start),text:U.text,width:U.width}))}catch{return xX(Q,X,D)}}function F9($,M){let J=0;for(let D=0;D<M.segmentIndex;D+=1)J+=$[D]?.length??0;let Z=$[M.segmentIndex]??"",X=Array.from(Z);for(let D=0;D<M.graphemeIndex;D+=1)J+=X[D]?.length??0;return J}function _9($){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 xX($,M,J){let Z=Math.max(1,Math.floor(M/9)),X=MD($,Z),D=0;return X.map((Y)=>{let Q=D,K=Q+Y.length;return D=K,{end:K,height:J,start:Q,text:Y,width:Y.length*9}})}function dX($,M,J,Z,X,D){let Y=iX($,P9(),M,J,Z,X,D);if(Y.length===0)return[{end:0,height:X,start:0,text:"",width:0}];return aX(Y,M.text,Z,X)}function aX($,M,J,Z){let X=[],D=0;while(D<$.length){let Y=$[D].start;if($[D].text===`
|
|
14
|
+
`){X.push({end:Y,height:Z,start:Y,text:"",width:0}),D+=1;continue}let Q=0,K=0,q=D,U=-1,N=Z;while(q<$.length){let V=$[q];if(V.text===`
|
|
15
|
+
`)break;let B=Q+V.width;if(B>J&&q>D)break;if(Q=B,N=Math.max(N,V.height),V.breakable)U=q,K=Q;q+=1}if(q===$.length||$[q]?.text===`
|
|
16
|
+
`){let V=$[q-1]?.end??Y;X.push({end:V,height:N,start:Y,text:M.slice(Y,V),width:Q}),D=q<$.length&&$[q]?.text===`
|
|
17
|
+
`?q+1:q;continue}if(U>=D){let V=$[U].end;X.push({end:V,height:N,start:Y,text:M.slice(Y,V),width:K}),D=U+1;continue}let A=$[Math.max(D,q-1)].end;X.push({end:A,height:N,start:Y,text:M.slice(Y,A),width:Q}),D=Math.max(D+1,q)}return X}function iX($,M,J,Z,X,D,Y){let Q=[];for(let K of J.inlines){if(K.kind==="image"){let U=t8(K,Y,X);Q.push({breakable:!0,end:K.end,height:U.height,start:K.start,text:K.text,width:U.width});continue}if(M)M.font=H9(Z,K.marks);let q=K.start;for(let U of Array.from(K.text)){let N=q,A=N+U.length;Q.push({breakable:/\s/.test(U),end:A,height:D,start:N,text:U,width:U===`
|
|
18
|
+
`?0:z9($,M,U)}),q=A}}return Q}function sX($){return $.inlines.some((M)=>M.kind==="image"||eX(M))}function q5($,M){return[$.path,tX($.text),oX($,M)].join(":")}function oX($,M){return $.inlines.map((J)=>`${J.start}-${J.end}:${nX(J,M)}`).join("|")}function nX($,M){if($.kind==="image"&&$.image)return G9($,M);return`${$.kind}:${$.inlineCode?1:0}:${$.marks.join(",")}:${$.link?.url??""}`}function tX($){let M=2166136261;for(let J of $)M^=J.charCodeAt(0),M=Math.imul(M,16777619);return(M>>>0).toString(36)}function eX($){return $.marks.includes("italic")||$.marks.includes("bold")}function H9($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function P9(){if(Q5!==void 0)return Q5;return Q5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,Q5}function z9($,M,J){if(!M)return 9;let Z=M.font,X=d$($,Z),D=X.get(J);if(D!==void 0)return D;let Y=M.measureText(J).width;return X.set(J,Y),Y}function $D($){return $?.type==="code"?"pre-wrap":"normal"}function MD($,M){if($.length===0)return[""];let J=$.split(`
|
|
19
|
+
`),Z=[];for(let X of J){if(X.length===0){Z.push("");continue}let D=X;while(D.length>M){let Y=D.slice(0,M),Q=Y.lastIndexOf(" ");if(Q<=0){Z.push(Y),D=D.slice(M);continue}Z.push(Y.slice(0,Q)),D=D.slice(Q+1)}Z.push(D)}return Z}var C2=10,o1=8,e8=120;function W9($,M,J,Z,X,D,Y,Q,K,q){let U=Math.max(1,...D.rows.map((G)=>G.cells.length)),A=Math.max(e8,K.width-Y-K.paddingX)/U,V=JD(Z),B=Q;for(let G=0;G<D.rows.length;G+=1){let b=ZD(V.get(G)??[],X,D,A,C2,K.lineHeight,q),P=Math.max(K.lineHeight+o1*2,...b.map((y)=>y.measuredLines.reduce((z,L)=>z+L.height,0)+o1*2));for(let y of b){let z=Y+y.cellIndex*A,L=B+o1;for(let R of y.measuredLines){let m={blockId:y.container.blockId,boundaries:K5(X,y.container,R.start,R.end,R.text,y.font,A-C2*2,q),regionId:y.container.id,end:R.end,font:y.font,height:R.height,left:z+C2,start:R.start,text:R.text,top:L,width:R.width};$.push(m),$6(M,m),L+=R.height}J.set(y.container.id,{bottom:B+P,left:z,right:z+A,top:B})}DD(M,D.id,B,B+P),B+=P}return B+K.blockGap}function JD($){let M=new Map;for(let J of $){let Z=XD(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 ZD($,M,J,Z,X,D,Y){return[...$].sort((Q,K)=>Q.cellIndex-K.cellIndex).map(({cellIndex:Q,container:K})=>{let q=i1(J),U=E1(J,D),N=s1(M,K,q,J,Math.max(40,Z-X*2),U,Y);return{cellIndex:Q,container:K,font:q,lineHeight:U,measuredLines:N}})}function XD($){let M=/\.rows\.(\d+)\.cells\.(\d+)$/.exec($);if(!M)return null;return{cellIndex:Number(M[2]),rowIndex:Number(M[1])}}function DD($,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 YD={blockGap:16,charWidth:9,indentWidth:24,lineHeight:24,paddingX:16,paddingY:12},QD=24,KD=16,qD=6,UD=10,ND=4;function U5($){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 N5($,M,J=W1(),Z=null){let X=Z??{images:new Map},D={...YD,...M},Y=[],Q=new Map,K=new Map($.regions.map((G)=>[G.id,{textLength:G.text.length}])),q=new Map($.blocks.map((G)=>[G.id,G.depth])),U=new Map($.blocks.map((G)=>[G.id,G])),N=L2($.document.blocks),A=new Map,V=D.paddingY;for(let G=0;G<$.regions.length;G+=1){let b=$.regions[G],P=q.get(b.blockId)??0,y=D.paddingX+P*D.indentWidth,z=Math.max(40,D.width-y-D.paddingX),L=N.get(b.blockId)??null;if(L?.type==="table"){let E=U.get(b.blockId)?.regionIds??[],_=$.regions.slice(G,G+E.length);V=W9(Y,A,Q,_,J,L,y,V,D,X),G+=_.length-1;continue}V=AD(Y,A,Q,b,J,L,y,V,z,D,X);let R=V5(U,N,$.regions,G,D.blockGap);V+=R;let m=A.get(b.blockId);if(m)m.bottom=Math.max(m.bottom,V)}return{blocks:$.blocks.map((G)=>{let b=A.get(G.id),P=b?.top??D.paddingY;return{bottom:b?.bottom??P+D.lineHeight/2,depth:G.depth,id:G.id,top:P,type:G.type}}),regionBounds:GD(Y,Q),regionLineIndices:VD(Y),regionMetrics:K,height:Math.max(V,D.paddingY),lines:Y,options:D,width:D.width}}function AD($,M,J,Z,X,D,Y,Q,K,q,U){let N=i1(D),A=E1(D,q.lineHeight),V=s1(X,Z,N,D,K,A,U),B=Q;for(let G of V){let b={blockId:Z.blockId,boundaries:K5(X,Z,G.start,G.end,G.text,N,K,U),regionId:Z.id,end:G.end,font:N,height:G.height,left:Y,start:G.start,text:G.text,top:B,width:G.width};$.push(b),$6(M,b),B+=G.height}return BD($,Z.id,J),B}function VD($){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 D=J.get(X.regionId)??[];D.push(Z),J.set(X.regionId,D)}return J}function GD($,M){let J=new Map(M);for(let Z of $){let X=J.get(Z.regionId),D={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,D.bottom),left:Math.min(X.left,D.left),right:Math.max(X.right,D.right),top:Math.min(X.top,D.top)}:D)}return J}function BD($,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 $6($,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 X=J+Z>>1,D=$.lines[X];if(M<D.top){Z=X-1;continue}if(M>=D.top+D.height){J=X+1;continue}return{index:X,line:D}}return null}function M6($,M){let J=[...$.regionBounds.entries()].find(([,D])=>{return M.x>=D.left&&M.x<=D.right&&M.y>=D.top&&M.y<=D.bottom});if(J)return A5($,J[0],M.y);let Z=O9($,M.y);if(!Z)return null;let X=FD($,M.y,Z.index);if(X.length===1)return X[0]??null;return X.find((D)=>{let Y=$.regionBounds.get(D.line.regionId);return Y?M.x>=Y.left&&M.x<=Y.right:!1})??[...X].sort((D,Y)=>{let Q=$.regionBounds.get(D.line.regionId),K=$.regionBounds.get(Y.line.regionId),q=E9(M.x,Q),U=E9(M.x,K);return q-U})[0]??null}function J6($,M,J){if($.lines.length===0)return{endIndex:0,startIndex:0};let Z=M+J,X=T9($,M),D=T9($,Z);if(X>0){let Y=$.lines[X-1];if(Y.top+Y.height>M)X-=1}if(D<$.lines.length){if($.lines[D].top<Z)D+=1}return{endIndex:D,startIndex:X}}function v0($,M,J){if(!$.regionMetrics.get(J.regionId))return null;let X=s0($,J.regionId,J.offset);if(!X)return null;return{blockId:X.blockId,regionId:X.regionId,height:X.height,left:h0(X,J.offset-X.start),offset:J.offset,top:X.top}}function s0($,M,J){return j2($,M,J)?.line??null}function A5($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=Z[0],D=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<D)D=K,X=Y;if(K===0)break}return{index:X,line:$.lines[X]}}function j2($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=0,D=Z.length-1;while(X<=D){let U=X+D>>1,N=Z[U],A=$.lines[N];if(J<A.start){D=U-1;continue}if(J>A.end){X=U+1;continue}return{index:N,line:A}}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 FD($,M,J){let Z=[];for(let X=J;X>=0;X-=1){let D=$.lines[X];if(M<D.top||M>=D.top+D.height)break;Z.unshift({index:X,line:D})}for(let X=J+1;X<$.lines.length;X+=1){let D=$.lines[X];if(M<D.top||M>=D.top+D.height)break;Z.push({index:X,line:D})}return Z}function E9($,M){if(!M)return Number.POSITIVE_INFINITY;if($<M.left)return M.left-$;if($>M.right)return $-M.right;return 0}function h0($,M){return $.left+_D($.boundaries,M)}function L2($){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 _D($,M){for(let Z of $)if(Z.offset===M)return Z.left;return $.filter((Z)=>Z.offset<=M).at(-1)?.left??0}function T9($,M){let J=0,Z=$.lines.length;while(J<Z){let X=J+Z>>1,D=$.lines[X];if(D.top+D.height<=M)J=X+1;else Z=X}return J}function C9($,M){if($.length===0)return 0;for(let J=1;J<$.length;J+=1){let Z=$[J-1],X=$[J],D=Z.left+(X.left-Z.left)/2;if(M<=D)return Z.offset;if(M<=X.left)return X.offset}return $.at(-1)?.offset??0}function V5($,M,J,Z,X){let D=J[Z],Y=J[Z+1];if(!D||!Y)return X;if(y9($,D.blockId,Y.blockId,"list"))return qD;if(y9($,D.blockId,Y.blockId,"blockquote"))return UD;if(D.blockId===Y.blockId)return ND;return X+bD(M.get(D.blockId))}function bD($){if($?.type!=="heading")return 0;if($.depth===1)return QD;return $.depth===2?KD:0}function y9($,M,J,Z){let X=w9($,M,Z),D=w9($,J,Z);for(let Y of X)if(D.has(Y))return!0;return!1}function w9($,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 Z6($,M,J,Z=[],X=W1(),D=null){let Y=D??{images:new Map},Q=L2($.document.blocks),K=new Map($.blocks.map((z)=>[z.id,z])),q=new Set(Z),U=Math.max(0,J.top-J.overscan),N=J.top+J.height+J.overscan,A=ED(X,$,Q,K,M,Y),V=j9(A,U),B=j9(A,N);if(V>0){let z=A.entries[V-1];if(z&&z.bottom>U)V-=1}if(B<A.entries.length){let z=A.entries[B];if(z&&z.top<N)B+=1}for(let z of q){let L=A.containerIndices.get(z);if(L===void 0)continue;V=Math.min(V,L),B=Math.max(B,L+1)}if(!Number.isFinite(V)||!Number.isFinite(B))return{estimateRegionBounds:A.estimateRegionBounds,layout:N5({...$,regions:[]},M,X,Y),totalHeight:A.totalHeight,viewport:J};let G=zD($,K,A.containerIndices,V,B),b=A.entries[G.startIndex]?.top??M.paddingY??0,P=N5({...$,regions:$.regions.slice(G.startIndex,G.endIndex)},M,X,Y),y=PD(P,b,A.totalHeight);return HD(X,$,y,M,Y),{estimateRegionBounds:A.estimateRegionBounds,layout:y,totalHeight:A.totalHeight,viewport:J}}function HD($,M,J,Z,X){for(let[D,Y]of J.regionBounds){let Q=Y.bottom-Y.top,K=M.regionIndex.get(D);x$($,L9(K??{path:D,inlines:[],text:""},Z,X),Q)}}function PD($,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 zD($,M,J,Z,X){let D=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 U=J.get(q.regionIds[0]??""),N=J.get(q.regionIds[q.regionIds.length-1]??"");if(U!==void 0)D=Math.min(D,U);if(N!==void 0)Y=Math.max(Y,N+1)}}return{endIndex:Y,startIndex:D}}function WD($,M,J,Z,X,D){let Y=L9(M,X,D),Q=$.measuredContainerHeights.get(Y);if(Q!==void 0)return Q;let K=X.paddingX??0,q=X.indentWidth??24,U=E1(J,X.lineHeight??24),N=K+Z*q,A=Math.max(40,X.width-N-K);if(M.inlines.some((G)=>G.kind==="image")){let G=i1(J);return s1($,M,G,J,A,U,D).reduce((b,P)=>b+P.height,0)}let V=U5({text:M.text,width:A});return Math.max(U,V.lineCount*U)}function ED($,M,J,Z,X,D){let Y=OD(M,X,D),Q=a$($,M,Y);if(Q)return Q;let K=X.paddingY??0,q=[],U=new Map;for(let N=0;N<M.regions.length;N+=1){let A=M.regions[N],V=J.get(A.blockId)??null;if(V?.type==="table"){let P=TD({block:V,blockMap:J,containerIndices:U,entries:q,index:N,options:X,runtimeBlocks:Z,totalHeight:K,regions:M.regions});if(P){N=P.nextIndex-1,K=P.totalHeight;continue}}let B=WD($,A,V,Z.get(A.blockId)?.depth??0,X,D),G=K,b=G+B;q.push({bottom:b,top:G}),U.set(A.id,N),K=b+V5(Z,J,M.regions,N,X.blockGap??16)}return i$($,M,Y,{containerIndices:U,entries:q,estimateRegionBounds(N){let A=U.get(N);return A===void 0?null:q[A]??null},totalHeight:K})}function TD({block:$,blockMap:M,containerIndices:J,entries:Z,index:X,options:D,runtimeBlocks:Y,totalHeight:Q,regions:K}){let q=Y.get($.id),U=q?.regionIds??[];if(U.length===0)return null;let N=K.slice(X,X+U.length);if(N.length===0||N[0]?.blockId!==$.id)return null;let A=D.paddingX??0,V=D.indentWidth??24,B=q?.depth??0,G=A+B*V,b=Math.max(e8,D.width-G-A),P=Math.max(1,...$.rows.map((E)=>E.cells.length)),y=b/P,z=Math.max(40,y-C2*2),L=E1($,D.lineHeight??24),R=yD(N,X),m=Q;for(let E=0;E<$.rows.length;E+=1){let _=R.get(E)??[],j=Math.max(L+o1*2,..._.map(({region:W})=>wD(W,z,L)+o1*2)),C=m+j;for(let{index:W,region:F}of _)Z[W]={bottom:C,top:m},J.set(F.id,W);m=C}for(let E=X;E<X+N.length;E+=1){let _=K[E];if(!_||Z[E])continue;Z[E]={bottom:m,top:m},J.set(_.id,E)}return{nextIndex:X+N.length,totalHeight:m+V5(Y,M,K,X+N.length-1,D.blockGap??16)}}function yD($,M){let J=new Map;for(let[Z,X]of $.entries()){let D=X.tableCellPosition?.rowIndex;if(D===void 0)continue;let Y=J.get(D)??[];Y.push({index:M+Z,region:X}),J.set(D,Y)}return J}function wD($,M,J){let Z=U5({text:$.text,width:M});return Math.max(J,Z.lineCount*J)}function OD($,M,J){return[M.width,M.paddingX??0,M.paddingY??0,M.indentWidth??24,M.lineHeight??24,M.blockGap??16,CD($,J)].join(":")}function j9($,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 L9($,M,J){return`${q5($,J)}:${M.width}:${M.paddingX??0}:${M.indentWidth??24}:${M.lineHeight??24}`}function CD($,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 G5=null;function jD($){let M=/(\d+(?:\.\d+)?)\s*px/.exec($);return M?Number.parseFloat(M[1]):16}function Y1($){G5??=new Map;let M=G5.get($);if(M)return M;let J=f9(),Z=Math.max(12,Math.round(jD($)));if(!J){let A={ascent:Math.round(Z*0.8),descent:Math.max(2,Z-Math.round(Z*0.8)),emHeight:Z};return G5.set($,A),A}J.font=$;let X=J.measureText("Hg"),D=Math.round(X.actualBoundingBoxAscent||0),Y=Math.round(X.actualBoundingBoxDescent||0),Q=D+Y,K=Math.max(Z,Q),q=Q>0?D:Math.round(K*0.8),U=Q>0?Y:Math.max(2,K-q),N={ascent:q,descent:U,emHeight:K};return G5.set($,N),N}function LD($,M){let{emHeight:J}=Y1(M);return Math.max(0,Math.floor(($-J)/2))}function R9($,M){let{ascent:J}=Y1(M);return LD($,M)+J}var B5;function k9($,M){let J=f9();if(!J||$.length===0)return 0;return J.font=M,J.measureText($).width}function f9(){if(B5!==void 0)return B5;return B5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,B5}var RD=18,kD=14,fD=22;function T0($,M,J){let Z=SD($,J);if(!Z)return null;return m9($,M,Z,J.x)}function X6($,M,J){let Z=$.lines[$.lines.length-1];if(!Z||J.y<=Z.top+Z.height)return null;return m9($,M,Z,J.x)}function m9($,M,J,Z){let X=$.regionMetrics.get(J.regionId);if(!X)return null;let D=Math.max(0,Z-K1(M,J)-J.left),Y=C9(J.boundaries,D),Q=Math.min(X.textLength,J.start+Y);return{regionId:J.regionId,offset:Q,left:h0(J,Y),top:J.top,height:J.height}}function D6($,M,J,Z){let X=U6(M,Z.regionId);if(!X)return null;let D=T0($,M,J);if(D)return{regionId:D.regionId,offset:D.offset};let Y=J.y<vD($);return{regionId:Z.regionId,offset:Y?0:X.text.length}}function Y6($,M,J){let Z=T0($,M,J);if(!Z)return null;let X=U6(M,Z.regionId);if(!X||X.text.length===0)return null;let D=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=hD(X.text,D);if(Y.start===Y.end)return null;return{anchor:{regionId:Z.regionId,offset:Y.start},focus:{regionId:Z.regionId,offset:Y.end}}}function S9($,M,J){let Z=uD($,J);if(!Z||Z.start!==0)return null;let X=n1(M,Z.blockId,"listItem");if(!X)return null;if(k2(M,X.id)?.kind!=="task")return null;let Y=R2(Z),Q=Y.left-4,K=Y.left+Y.size+4,q=Y.top-4,U=Y.top+Y.size+4;return J.x>=Q&&J.x<=K&&J.y>=q&&J.y<=U?{listItemId:X.id}:null}function u9($,M,J){let Z=T0($,M,J);if(!Z)return null;let X=U6(M,Z.regionId);if(!X)return null;let D=X.inlines.find((Q)=>Q.link&&Z.offset>=Q.start&&Z.offset<Q.end);if(!D?.link)return null;let Y=q6($,M,Z.regionId,D.start);if(!Y)return null;return{anchorBottom:Y.anchorBottom,anchorLeft:Y.anchorLeft,endOffset:D.end,regionId:Z.regionId,startOffset:D.start,title:D.link.title,url:D.link.url}}function Q6($,M,J,Z){let X=S9($,M,J);if(X)return{kind:"task-toggle",listItemId:X.listItemId};let D=T0($,M,J);if(!D)return null;let Y=v9(D.regionId,D.offset,Z),Q=Y!==null?h9(Y,$,M,Z):null,K=u9($,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??D.top+D.height,anchorLeft:Q?.anchorLeft??D.left,kind:"text",commentThreadIndex:Y}}function K6($,M,J,Z){let X=M.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let D=v9(J.regionId,J.offset,Z),Y=D!==null?h9(D,$,M,Z):null,Q=X.inlines.find((K)=>J.offset>=K.start&&J.offset<=K.end)??null;if(Q?.link){let K=q6($,M,J.regionId,Q.start);if(!K)return null;return{anchorBottom:Y?.anchorBottom??K.anchorBottom,anchorLeft:Y?.anchorLeft??K.anchorLeft,commentThreadIndex:D,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:D,kind:"text"};return null}function g0($,M,J){let Z=s0(M,J.regionId,J.offset);if(!Z)return J.left;return J.left+K1($,Z)+mD($,Z,J.offset)}function Q1($,M,J){return h0(M,J)+K1($,M)}function K1($,M){let J=n1($,M.blockId,"listItem");if(!J)return 0;return k2($,J.id)?.kind==="task"?fD:RD}function R2($){return{left:$.left,size:kD,top:$.top+3}}function n1($,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 k2($,M){return $.documentIndex.listItemMarkers.get(M)??null}function v9($,M,J){for(let Z of J)if(Z.regionId===$&&M>=Z.startOffset&&M<=Z.endOffset)return Z.threadIndex;return null}function h9($,M,J,Z){let X=Z.find((D)=>D.threadIndex===$);if(!X)return null;return q6(M,J,X.regionId,X.startOffset)}function q6($,M,J,Z){let X=s0($,J,Z);if(!X)return null;return{anchorBottom:X.top+X.height,anchorLeft:h0(X,Z)+K1(M,X)}}function mD($,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 k9(X,M.font)}function SD($,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 A5($,Z,M.y)?.line??null;let J=M6($,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 uD($,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 U6($,M){return $.documentIndex.regionIndex.get(M)??null}function vD($){return $.lines[0]?.top??0}function hD($,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},D=Z6($.documentIndex,M,X,[$.selection.anchor.regionId,$.selection.focus.regionId],J,Z);return{blockMap:L2($.documentIndex.document.blocks),estimateRegionBounds:D.estimateRegionBounds,regionBounds:new Map(D.layout.regionBounds),layout:D.layout,paintHeight:Math.max(240,X.height+X.overscan*2),paintTop:Math.max(0,X.top-X.overscan),totalHeight:D.totalHeight,viewport:{height:X.height,top:X.top}}}function F5($,M,J){return T0(M.layout,$,J)??X6(M.layout,$,J)}function f2($,M,J,Z){return D6(M.layout,$,J,Z)}function A6($,M,J){return Y6(M.layout,$,J)}function V6($,M,J,Z){return Q6(M.layout,$,J,Z)}function G6($,M,J,Z){return K6(M.layout,$,J,Z)}function B6($,M,J){return v0(M.layout,$.documentIndex,J)}function o0($,M,J){let Z=v0(M.layout,$.documentIndex,J);if(!Z)return null;return{...Z,left:g0($,M.layout,Z)}}function g9($,M,J,Z,X){let D=Z-J,Y=X-D;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 _6($,M,J){let Z=J.trim();if(Z.length===0||M.startOffset===M.endOffset)return null;let X=$.regionIndex.get(M.regionId)??null,D=X?F6($,X):null;if(!D)return null;return f8({anchor:E2(D,M.startOffset,M.endOffset),body:Z,quote:T2(D,M.startOffset,M.endOffset)})}function L0($){let M="documentIndex"in $?$.documentIndex:$,J=_5(M),Z=M.document.comments,X=[...Z],D=[];for(let[Y,Q]of Z.entries()){let K=y2(Q,M.document);if(!K.match)continue;let U=J.findBySemanticMatch(K.match.containerId,K.match.containerOrdinal)?.runtimeContainer??null;if(!U)continue;if(K.repair)X[Y]={...Q,anchor:K.repair.anchor,quote:K.repair.quote};D.push({endOffset:K.match.endOffset,resolution:K,regionId:U.id,resolved:Q.resolvedAt!=null,startOffset:K.match.startOffset,threadIndex:Y})}return{liveRanges:D,threads:X}}function b6($,M,J,Z,X,D){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=L0($),q=new Map(K.liveRanges.map((V)=>[V.threadIndex,V])),U=F6($,J),N=t1(M,J.path),A=N?F6(M,N):null;if(!U||!A)return M.document.comments;return M.document.comments.map((V,B)=>{if(!Q.has(B))return V;let G=q.get(B),b=G?.resolution.match??null;if(!G||!b||b.containerId!==U.id)return V;let P=g9(b.startOffset,b.endOffset,Z,X,D.length);return{...V,anchor:E2(A,P.start,P.end),quote:T2(A,P.start,P.end)}})}function F6($,M){let J=gD($,M);if(!J)return null;return{containerKind:J,containerOrdinal:-1,id:M.semanticRegionId,text:M.text}}function gD($,M){if($.tableCellIndex.has(M.id))return"tableCell";return u$(M.blockType)}function b5($,M){if(M.length===0)return[];let J=_5($),Z=J.list();return M.map((X)=>({...X,cursorPoint:ID(X,Z,J),viewport:null}))}function ID($,M,J){if(!$.cursor)return null;let Z=pD(M,$.cursor),X=lD(Z,$.cursor);if(X.length!==1)return null;let D=X[0],Y=J.resolveRuntimeContainer(D.container.id);if(!Y)return null;return{offset:Math.max(0,Math.min(D.offset,Y.text.length)),regionId:Y.id}}function pD($,M){return M.kind?$.filter((J)=>J.containerKind===M.kind):$}function lD($,M){if(M.prefix&&M.suffix)return rD($,M.prefix,M.suffix);if(M.prefix)return I9($,M.prefix,"after");if(M.suffix)return I9($,M.suffix,"before");return[]}function I9($,M,J){let Z=[];for(let X of $)for(let D of u0(X.text,M))Z.push({container:X,offset:J==="after"?D+M.length:D});return Z}function rD($,M,J){let Z=[];for(let X of $)for(let D of l1(X.text,M,J))Z.push({container:X,offset:D.startOffset});return Z}var cD=48;function m2($,M,J){let Z="documentIndex"in $?$.documentIndex:$;if(J.length===0)return[];return J.map((X)=>({...X,viewport:xD(Z,M,X)}))}function xD($,M,J){if(!J.cursorPoint)return{status:"unresolved"};let Z=v0(M.layout,$,J.cursorPoint),X=Z?{bottom:Z.top+Z.height,top:Z.top}:M.estimateRegionBounds(J.cursorPoint.regionId);if(!X)return{status:"unresolved"};return{scrollTop:aD(M,X),status:dD(M,X)}}function dD($,M){let J=$.viewport.top,Z=J+$.viewport.height;if(M.bottom<J)return"above";if(M.top>Z)return"below";return"visible"}function aD($,M){let J=Math.max(0,$.totalHeight-$.viewport.height),Z=M.top-Math.min(cD,$.viewport.height/4);return Math.max(0,Math.min(J,Z))}function _5($){let M=X5($.document),J=new Map(M.map((X)=>[X.id,X])),Z=new Map($.regions.map((X)=>[X.semanticRegionId,X]));return{findBySemanticMatch(X,D){let Y=J.get(X)??M[D]??null;if(!Y)return null;return{runtimeContainer:Z.get(Y.id)??null,semanticContainer:Y}},list(X){return X?M.filter((D)=>D.containerKind===X):M},resolveRuntimeContainer(X){return Z.get(X)??null}}}var S2="",p9=1e6;function u2($,M,J){return`${$}:${M}:${J}`}function Q0($){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]=H0({marks:Z.marks,path:Z.id,text:Z.text+J.text});continue}M.push(J)}return M}function e1($){let M=UY($),J=P6(M.blocks.map((Z,X)=>h2(Z,X)));return z6(M,J)}function h2($,M){let J=[],Z=[],X=[],D=0;function Y(K,q,U,N,A=null){if(Z.length>0)X.push(`
|
|
20
|
+
`),D+=1;let V=U.map((b)=>b.text).join(""),B=D,G=B+V.length;X.push(V),D=G,Z.push({blockId:K.id,blockType:K.type,end:G,id:`${K.id}:${q}`,path:q,rootIndex:M,inlines:U,semanticRegionId:N,start:B,tableCellPosition:A,text:V})}function Q(K,q,U,N){let A={childBlockIds:[],depth:U,end:D,id:K.id,parentBlockId:N,path:q,regionIds:[],rootIndex:M,start:D,type:K.type};switch(J.push(A),K.type){case"blockquote":case"listItem":for(let[V,B]of K.children.entries())A.childBlockIds.push(B.id),Q(B,`${q}.children.${V}`,U+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),A.regionIds.push(Z.at(-1).id);break}case"heading":case"paragraph":Y(K,`${q}.children`,H6(K.children),K.id),A.regionIds.push(Z.at(-1).id);break;case"list":for(let[V,B]of K.items.entries())A.childBlockIds.push(B.id),Q(B,`${q}.children.${V}`,U+1,K.id);break;case"table":for(let[V,B]of K.rows.entries())for(let[G,b]of B.cells.entries())Y(K,`${q}.rows.${V}.cells.${G}`,H6(b.children),b.id,{cellIndex:G,rowIndex:V}),A.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),A.regionIds.push(Z.at(-1).id);break}A.end=D}return Q($,`root.${M}`,0,null),{blockRange:{end:J.length,start:0},blocks:J,end:D,length:D,regionRange:Z.length>0?{end:Z.length,start:0}:void 0,regions:Z,rootIndex:M,start:0,text:X.join("")}}function P6($,M=null){let J=[],Z=0,X=0,D=0,Y=!1;for(let[Q,K]of $.entries()){if(K.regions.length>0&&Y)D+=1;let q={...K,blockRange:{end:Z+K.blocks.length,start:Z},end:D+K.length,regionRange:K.regions.length>0?{end:X+K.regions.length,start:X}:void 0,start:D},U=M?.[Q];if(J.push(sD(U,K,q)?U:l9(K,q)),Z=q.blockRange.end,X=q.regionRange?.end??X,K.regions.length>0)D=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 iD($,M,K)}let D=X===Z,Y=[...$.roots.slice(0,J),...M.blocks.slice(J,J+X).map((K,q)=>h2(K,J+q)),...D?$.roots.slice(J+Z):M.blocks.slice(J+X).map((K,q)=>h2(K,J+X+q))],Q=P6(Y,$.roots);return z6(M,Q,$)}function iD($,M,J){let Z=$.roots.length,X=h2(J,Z),D=$.roots.some((U)=>U.regions.length>0),Y=X.regions.length>0&&D?$.length+1:$.length,Q=l9(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:$Y($.blockIndex,Q.blocks),blocks:K,commentContainerIndex:M.comments===$.document.comments?$.commentContainerIndex:r9(M),document:M,engine:"canvas",length:Q.end,listItemMarkers:M.blocks===$.document.blocks?$.listItemMarkers:YY($.listItemMarkers,J),regionIndex:MY($.regionIndex,Q.regions),regionOrderIndex:JY($.regionOrderIndex,Q.regions,$.regions.length),regionPathIndex:ZY($.regionPathIndex,Q.regions),regions:q,roots:[...$.roots,Q],tableCellIndex:XY($.tableCellIndex,Q.regions),tableCellRegionIndex:DY($.tableCellRegionIndex,Q.regions),text:QY($.text,Q)}}function g2($,M){if(M.blocks!==$.document.blocks)throw Error("Editor model document replacement requires preserving root blocks.");return z6(M,$.roots,$)}function z6($,M,J=null){let Z=M.flatMap((U)=>U.blocks),X=M.flatMap((U)=>U.regions),{regionIndex:D,regionOrderIndex:Y,regionPathIndex:Q,tableCellIndex:K,tableCellRegionIndex:q}=eD(X);return{blockIndex:tD(Z),blocks:Z,commentContainerIndex:$.comments===J?.document.comments?J.commentContainerIndex:r9($),document:$,engine:"canvas",length:M.at(-1)?.end??0,listItemMarkers:$.blocks===J?.document.blocks?J.listItemMarkers:qY($.blocks),regionIndex:D,regionOrderIndex:Y,regionPathIndex:Q,regions:X,roots:M,tableCellIndex:K,tableCellRegionIndex:q,text:KY(M)}}function l9($,M){let J=M.start-$.start;return{...M,blocks:J===0?$.blocks:oD($.blocks,J),regions:J===0?$.regions:nD($.regions,J)}}function sD($,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 oD($,M){return $.map((J)=>({...J,end:J.end+M,start:J.start+M}))}function nD($,M){return $.map((J)=>({...J,end:J.end+M,start:J.start+M}))}function tD($){let M=new Map;for(let J of $)M.set(J.id,J);return M}function eD($){let M=new Map,J=new Map,Z=new Map,X=new Map,D=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),D.set(u2(Q.blockId,Q.tableCellPosition.rowIndex,Q.tableCellPosition.cellIndex),Q.id)}return{regionIndex:M,regionOrderIndex:J,regionPathIndex:Z,tableCellIndex:X,tableCellRegionIndex:D}}function $Y($,M){let J=new Map($);for(let Z of M)J.set(Z.id,Z);return J}function MY($,M){let J=new Map($);for(let Z of M)J.set(Z.id,Z);return J}function JY($,M,J){let Z=new Map($);for(let[X,D]of M.entries())Z.set(D.id,J+X);return Z}function ZY($,M){let J=new Map($);for(let Z of M)J.set(Z.path,Z);return J}function XY($,M){let J=new Map($);for(let Z of M)if(Z.tableCellPosition)J.set(Z.id,Z.tableCellPosition);return J}function DY($,M){let J=new Map($);for(let Z of M){if(!Z.tableCellPosition)continue;J.set(u2(Z.blockId,Z.tableCellPosition.rowIndex,Z.tableCellPosition.cellIndex),Z.id)}return J}function YY($,M){let J=new Map($);return v2(J,[M]),J}function QY($,M){if(M.regions.length===0)return $;return $.length>0?`${$}
|
|
21
|
+
${M.text}`:M.text}function KY($){return $.filter((M)=>M.regions.length>0).map((M)=>M.text).join(`
|
|
22
|
+
`)}function r9($){let M=new Map;for(let[J,Z]of $.comments.entries()){let X=y2(Z,$).match?.containerId??null;if(!X)continue;let D=M.get(X)??[];D.push(J),M.set(X,D)}return M}function qY($){let M=new Map;return v2(M,$),M}function v2($,M,J=null){for(let Z of M){if(Z.type==="list"){for(let[X,D]of Z.items.entries())v2($,[D],{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:"•"});v2($,Z.children,J)}if(Z.type==="blockquote")v2($,Z.children,J)}}function UY($){if($.blocks.length>0)return $;return g1([r({text:""})],$.comments,$.frontMatter)}function H6($,M=null){let J=[],Z=0,X=(D)=>{let Y=Z,Q=Y+D.text.length;J.push({...D,end:Q,start:Y}),Z=Q};for(let D of $)switch(D.type){case"break":X({id:D.id,image:null,inlineCode:!1,kind:"break",link:M,marks:[],originalType:null,text:`
|
|
23
|
+
`});break;case"image":X({id:D.id,image:{alt:D.alt,title:D.title,url:D.url,width:D.width},inlineCode:!1,kind:"image",link:M,marks:[],originalType:null,text:NY(D.alt)});break;case"inlineCode":X({id:D.id,image:null,inlineCode:!0,kind:"inlineCode",link:M,marks:[],originalType:null,text:D.code});break;case"link":for(let Y of H6(D.children,{title:D.title,url:D.url}))X(Y);break;case"text":X({id:D.id,image:null,inlineCode:!1,kind:"text",link:M,marks:D.marks,originalType:null,text:D.text});break;case"unsupported":X({id:D.id,image:null,inlineCode:!1,kind:"unsupported",link:M,marks:[],originalType:D.originalType,text:D.source});break}return J}function NY($){return S2}function H5($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=r1($.document.blocks,J.blockId);if(!Z)return null;return P5(Z,J.path,J.semanticRegionId)}function x9($,M,J,Z,X){if(J>=Z)return null;let D=H5($,M);return D?X(D,J,Z):null}function I2($,M,J,Z,X){let D=x9($,M,J,Z,X);return D?{kind:"replace-block",block:D.block,blockId:D.blockId,selection:D.selection}:null}function P5($,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 D of X.cells)if(D.id===J)return{block:$,blockPath:Z[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:D,children:D.children,kind:"tableCell",path:Z[1]};return null}function q1($,M,J,Z){switch($.kind){case"inlineBlock":return{block:C0($.block,M),blockId:$.block.id,selection:c9(`${$.path}.children`,J,Z)};case"tableCell":{let X=J1({children:M,path:$.path}),D=$.block.rows.map((Y)=>({...Y,cells:Y.cells.map((Q)=>Q.id===$.cell.id?X:Q)}));return{block:S0($.block,D),blockId:$.block.id,selection:c9($.path,J,Z)}}}}function c9($,M,J){return{endOffset:J,kind:"region-range-path",path:$,startOffset:M}}function b0($){switch($.type){case"break":return 1;case"image":return S2.length;case"inlineCode":return $.code.length;case"link":return N0($.children).length;case"text":return $.text.length;case"unsupported":return $.source.length}}function z5($,M,J){if(M<=0)return[];return W6($,0,M,`${J}.before`)}function W5($,M,J){let Z=b0($);if(M>=Z)return[];return W6($,M,Z,`${J}.after`)}function W6($,M,J,Z){if(M>=J)return[];switch($.type){case"text":return Q0([T1($.text.slice(M,J),$.marks,Z)].filter(Boolean));case"inlineCode":return[T6($.code.slice(M,J),Z)];case"link":{let X=Q0(AY($.children,M,J,`${Z}.children`));return X.length>0?[{...$,children:X}]:[]}default:return[]}}function E6($,M,J){let Z=0,X="";for(let D of $){let Y=b0(D),Q=Z,K=Q+Y;if(Z=K,J<=Q||M>=K)continue;X+=VY(D,Math.max(0,M-Q),Math.min(Y,J-Q))}return X}function T1($,M,J){if($.length===0)return null;return H0({marks:M,path:J,text:$})}function T6($,M){return S1({code:$,path:M})}function AY($,M,J,Z){let X=[],D=0;for(let[Y,Q]of $.entries()){let K=b0(Q),q=D,U=q+K;if(D=U,J<=q||M>=U)continue;X.push(...W6(Q,Math.max(0,M-q),Math.min(K,J-q),`${Z}.${Y}`))}return X}function VY($,M,J){if(M>=J)return"";switch($.type){case"break":return`
|
|
24
|
+
`.slice(M,J);case"image":return S2.slice(M,J);case"inlineCode":return $.code.slice(M,J);case"link":return E6($.children,M,J);case"text":return $.text.slice(M,J);case"unsupported":return $.source.slice(M,J)}}function y6($,M,J,Z){let X=GY($.children,M,J,Z);if(X===null)return null;let D=Q0(d9($.children,M,J,Z,X,`${$.path}.children`));return D.length>0?q1($,D,M,J):null}function w6($,M,J){let Z=0,X=null,D=(Y)=>{for(let Q of Y){let K=b0(Q),q=Z,U=q+K;if(Z=U,J<=q||M>=U)continue;if(Q.type==="text"){let N=Math.max(M,q);if(Math.min(J,U)>N)X=X===null?new Set(Q.marks):new Set(Q.marks.filter((V)=>X?.has(V)));continue}if(Q.type==="link"){let N=Z;Z=q,D(Q.children),Z=N}}};return D($.children),X?[...X]:[]}function GY($,M,J,Z){let X=0,D=!1,Y=!0,Q=(K)=>{for(let q of K){let U=b0(q),N=X,A=N+U;if(X=A,J<=N||M>=A)continue;if(q.type==="text"){let V=Math.max(M,N);if(Math.min(J,A)>V)D=!0,Y&&=q.marks.includes(Z);continue}if(q.type==="link"){let V=X;X=N,Q(q.children),X=V}}};return Q($),D?Y:null}function d9($,M,J,Z,X,D){let Y=[],Q=0;for(let[K,q]of $.entries()){let U=Q,N=b0(q),A=U+N,V=`${D}.${K}`;if(Q=A,J<=U||M>=A){Y.push(q);continue}if(q.type==="text"){Y.push(...BY(q,Math.max(0,M-U),Math.min(N,J-U),Z,X,V));continue}if(q.type==="link"){let B=Q0(d9(q.children,Math.max(0,M-U),Math.min(N,J-U),Z,X,`${V}.children`));if(B.length>0)Y.push({...q,children:B});continue}Y.push(q)}return Y}function BY($,M,J,Z,X,D){let Y=$.text.slice(0,M),Q=$.text.slice(M,J),K=$.text.slice(J),q=X?$.marks.filter((U)=>U!==Z):FY($.marks,Z);return[T1(Y,$.marks,`${D}.before`),T1(Q,q,`${D}.selected`),T1(K,$.marks,`${D}.after`)].filter(Boolean)}function FY($,M){return $.includes(M)?$:[...$,M].sort()}function O6($,M,J){let Z=Q0(_Y($.children,M,J,`${$.path}.children`));return Z.length>0?q1($,Z,M,J):null}function _Y($,M,J,Z){let X=i9($,M,J);if(X)return a9($,M,J,X.code,Z,!1);let D=E6($,M,J);if(D.length===0)return $;return a9($,M,J,D,Z,!0)}function i9($,M,J){let Z=0;for(let X of $){let D=b0(X),Y=Z,Q=Y+D;if(Z=Q,M===Y&&J===Q&&X.type==="inlineCode")return X;if(X.type==="link"){let K=i9(X.children,Math.max(0,M-Y),Math.min(D,J-Y));if(K)return K}}return null}function a9($,M,J,Z,X,D){let Y=[],Q=0,K=!1;for(let[q,U]of $.entries()){let N=`${X}.${q}`,A=b0(U),V=Q,B=V+A;if(Q=B,J<=V||M>=B){Y.push(U);continue}if(!K){Y.push(...z5(U,Math.max(0,M-V),N));let G=D?T6(Z,`${X}.selected`):T1(Z,[],`${X}.selected`);if(G)Y.push(G);K=!0}Y.push(...W5(U,Math.min(A,J-V),N))}return Y}function E5($,M,J,Z,X){return I2($,M,J,Z,(D,Y,Q)=>s9(D,Y,Q,X))}function s9($,M,J,Z){let X=Q0(bY($.children,M,J,Z,`${$.path}.children`)??[]);return X.length>0?q1($,X,M,J):null}function bY($,M,J,Z,X){let D=[],Y=0,Q=!1;for(let[K,q]of $.entries()){let U=`${X}.${K}`,N=b0(q),A=Y,V=A+N;if(Y=V,!Q&&q.type==="link"&&M===A&&J===V){if(Z===null)D.push(...q.children);else D.push(u1({children:q.children,path:U,title:q.title,url:Z}));Q=!0;continue}D.push(q)}return Q?D:null}function C6($,M,J){let Z=Q0(HY($.children,M,J,`${$.path}.children`));return q1($,Z,M+1,M+1)}function HY($,M,J,Z){let X=[],D=0,Y=!1;for(let[Q,K]of $.entries()){let q=`${Z}.${Q}`,U=b0(K),N=D,A=N+U;if(D=A,J<=N||M>=A){X.push(K);continue}if(!Y)X.push(...z5(K,Math.max(0,M-N),q)),X.push(P2({path:`${Z}.selected`})),Y=!0;X.push(...W5(K,Math.min(U,J-N),q))}if(!Y)X.push(P2({path:`${Z}.selected`}));return X}function X0($,M,J=0){return{childIndices:M,kind:"descendant-primary-region",offset:J,rootIndex:$}}function M0($,M=0){return{kind:"root-primary-region",offset:M,rootIndex:$}}function U1($,M,J,Z=0){return{cellIndex:J,kind:"table-cell",offset:Z,rootIndex:$,rowIndex:M}}function n0($,M){return $.regionIndex.get(M)??null}function t1($,M){return $.regionPathIndex.get(M)??null}function M2($,M,J,Z){let X=$.tableCellRegionIndex.get(u2(M,J,Z));return X?$.regionIndex.get(X)??null:null}function PY($){return $.anchor.regionId===$.focus.regionId&&$.anchor.offset===$.focus.offset}function n($,M){let J="documentIndex"in $?$.documentIndex:$,Z="documentIndex"in $?$.selection:M,X=PY(Z),D=o9(J,Z.anchor),Y=o9(J,Z.focus);if(D<=Y)return{collapsed:X,end:Z.focus,start:Z.anchor};return{collapsed:X,end:Z.anchor,start:Z.focus}}function p2($,M){if(!M)return null;if("kind"in M){if(M.kind==="root-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?j6($,Z):null;return X?T5(X.id,y5(X.text,M.offset)):null}if(M.kind==="descendant-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?zY(Z,M.childIndices):null,D=X?j6($,X):null;return D?T5(D.id,y5(D.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?T5(X.id,y5(X.text,M.offset)):null}let J=t1($,M.path);if(!J)return null;if(M.kind==="region-path")return T5(J.id,y5(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 o9($,M){let J=$.regionOrderIndex.get(M.regionId);if(J===void 0)throw Error(`Unknown canvas region: ${M.regionId}`);return J*p9+M.offset}function T5($,M){let J={offset:M,regionId:$};return{anchor:J,focus:J}}function y5($,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=n9(J);if(!X)return null;J=X[Z]??null}return J}function j6($,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=n9(M);if(!X)return null;for(let D of X){let Y=j6($,D);if(Y)return Y}return null}function n9($){switch($.type){case"list":return $.items;case"blockquote":case"listItem":return $.children;default:return null}}function l2($){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((D)=>Z>D.start&&Z<D.end)??M?.inlines.find((D)=>D.end===Z)??M?.inlines.find((D)=>D.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 w5($){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=r1($.documentIndex.document.blocks,J.blockId);if(!Z)return[];let X=P5(Z,J.path,J.semanticRegionId);return X?w6(X,M.start.offset,M.end.offset):[]}function O5($,M,J,Z=null){return J2($,M,1,[J],Z)}function J2($,M,J,Z,X=null){return{document:I1($.document,M,J,Z),selection:X}}function C5($,M,J,Z=null){return r2($,M,()=>J,Z)}function r2($,M,J,Z=null){let X=$.blockIndex.get(M);if(!X)return null;let D=$.document.blocks[X.rootIndex];if(!D)return null;let Y=t9(D,M,J);return Y?J2($,X.rootIndex,1,[Y],Z):null}function t9($,M,J){if($.id===M)return J($);switch($.type){case"blockquote":{let Z=L6($.children,M,J);return Z?P0({children:Z}):null}case"listItem":{let Z=L6($.children,M,J);return Z?E0($,Z):null}case"list":{let Z=L6($.items,M,J);return Z?$0($,Z):null}default:return null}}function L6($,M,J){let Z=!1,X=$.map((D)=>{let Y=t9(D,M,J);if(!Y)return D;return Z=!0,Y});return Z?X:null}function L5($,M,J){let Z=n($,M);if(Z.start.regionId===Z.end.regionId)return WY($,Z,J);return wY($,Z,J)}function WY($,M,J){let Z=n0($,M.start.regionId);if(!Z)throw Error(`Unknown region: ${M.start.regionId}`);let X=r2($,Z.blockId,(q)=>EY(q,Z,M.start.offset,M.end.offset,J));if(!X)throw Error(`Failed to replace block for canvas region: ${Z.id}`);let D=$2($,X.document,Z.rootIndex,1),Y=$.document.comments.length===0?D:D7($,D,Z,M.start.offset,M.end.offset,J),Q=t1(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:Y7(Q.id,K)}}function EY($,M,J,Z,X){switch($.type){case"heading":case"paragraph":return TY($,M,J,Z,X);case"code":return $5($,e9(M,J,Z,X));case"table":return yY($,M,J,Z,X);case"unsupported":return M5($,e9(M,J,Z,X));default:throw Error(`Canvas text replacement is not supported for block type: ${$.type}`)}}function TY($,M,J,Z,X){let D=x2(M.inlines,J,Z,X),Y=R5(D);return C0($,Y)}function yY($,M,J,Z,X){let D=M.tableCellPosition?.rowIndex,Y=M.tableCellPosition?.cellIndex;if(D===void 0||Y===void 0)throw Error(`Unable to resolve table cell position for region: ${M.id}`);let Q=x2(M.inlines,J,Z,X),K=R5(Q),q=$.rows.map((U,N)=>{if(N!==D)return U;let A=U.cells.map((V,B)=>{if(B!==Y)return V;return J1({children:K})});return{...U,cells:A}});return S0($,q)}function e9($,M,J,Z){return x2($.inlines,M,J,Z).map((X)=>X.text).join("")}function c2($){return $!==null&&($.type==="heading"||$.type==="paragraph")}function wY($,M,J){let Z=n0($,M.start.regionId),X=n0($,M.end.regionId);if(!Z||!X)throw Error("Unknown cross-region selection endpoints.");let D=$.document.blocks[Z.rootIndex],Y=$.document.blocks[X.rootIndex];if(!D||!Y)throw Error("Unknown root blocks for cross-region selection.");let Q=J7(D,Z,M.start.offset),K=Z7(Y,X,M.end.offset),q=OY(Q,K,J),U=q.blocks.length>0?q.blocks:[r({text:""})],N=Z.rootIndex,A=X.rootIndex-Z.rootIndex+1,V=I1($.document,N,A,U),B=$2($,V,N,A),G=$.document.comments.length===0?B:D7($,B,Z,M.start.offset,Z.text.length,c2(Q)?J:""),b=G.roots[N+q.caretLocalIndex]?.regions[0]??null;return{documentIndex:G,selection:Y7(b?.id??Z.id,b?q.caretOffset:0)}}function OY($,M,J){if(c2($)&&c2(M))return{blocks:[CY($,M,J)],caretLocalIndex:0,caretOffset:$.plainText.length+J.length};if(c2($)){let D=[J.length>0?jY($,J):$];if(M)D.push(M);return{blocks:D,caretLocalIndex:0,caretOffset:$.plainText.length+J.length}}if(c2(M)){let X=J.length>0?LY(M,J):M,D=[];if($)D.push($);let Y=D.length;return D.push(X),{blocks:D,caretLocalIndex:Y,caretOffset:J.length}}let Z=[];if($)Z.push($);if(J.length>0){let X=Z.length;if(Z.push(r({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 CY($,M,J){let Z=J.length>0?[H0({text:J})]:[];return C0($,Q0([...$.children,...Z,...M.children]))}function jY($,M){return C0($,Q0([...$.children,H0({text:M})]))}function LY($,M){return C0($,Q0([H0({text:M}),...$.children]))}function J7($,M,J){if($.type==="table")return null;if($.id===M.blockId)return RY($,M,J);return X7($,(Z)=>fY(Z,M,J))}function Z7($,M,J){if($.type==="table")return null;if($.id===M.blockId)return kY($,M,J);return X7($,(Z)=>mY(Z,M,J))}function RY($,M,J){if(J===0)return null;switch($.type){case"heading":case"paragraph":{let Z=x2(M.inlines,J,M.text.length,"");return C0($,R5(Z))}case"code":return $5($,M.text.slice(0,J));case"unsupported":return M5($,M.text.slice(0,J));default:return null}}function kY($,M,J){if(J===M.text.length)return null;switch($.type){case"heading":case"paragraph":{let Z=x2(M.inlines,0,J,"");return C0($,R5(Z))}case"code":return $5($,M.text.slice(J));case"unsupported":return M5($,M.text.slice(J));default:return null}}function X7($,M){switch($.type){case"blockquote":{let J=M($.children);return J.length===0?null:P0({children:J})}case"list":{let J=M($.items);return J.length===0?null:$0($,J)}case"listItem":{let J=M($.children);return J.length===0?null:E0($,J)}default:return null}}function fY($,M,J){let Z=$.findIndex((Y)=>j5(Y,M));if(Z===-1)return[];let X=$.slice(0,Z),D=J7($[Z],M,J);return D?[...X,D]:X}function mY($,M,J){let Z=$.findIndex((Y)=>j5(Y,M));if(Z===-1)return[];let X=$.slice(Z+1),D=Z7($[Z],M,J);return D?[D,...X]:X}function j5($,M){if($.id===M.blockId)return!0;switch($.type){case"blockquote":case"listItem":return $.children.some((J)=>j5(J,M));case"list":return $.items.some((J)=>j5(J,M));default:return!1}}function D7($,M,J,Z,X,D){let Y=b6($,M,J,Z,X,D);return Y===M.document.comments?M:g2(M,{...M.document,comments:Y})}function Y7($,M){return{anchor:{regionId:$,offset:M},focus:{regionId:$,offset:M}}}function x2($,M,J,Z){let D=SY($,M,J,{didInsert:!1,generatedRunCount:0,replacementText:Z});return IY(pY(D))}function R5($){let M=[];for(let J=0;J<$.length;J+=1){let Z=$[J];if(Z.link){let D=[],Y=Z.link;while(J<$.length&&k6($[J].link,Y)){let Q=M7($[J]);if(Q)D.push(Q);J+=1}if(J-=1,D.length>0)M.push(u1({children:Q0(D),title:Y.title,url:Y.url}));continue}let X=M7(Z);if(X)M.push(X)}return Q0(M)}function SY($,M,J,Z){let X=[];for(let[D,Y]of $.entries()){if(!Z.didInsert&&M===J&&M===Y.start)R6(X,Z,$7($[D-1]??null,Y));if(J<=Y.start||M>=Y.end){X.push(k5(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:"",U=uY(Y,Q,K,q,Z);if(Q!==K||q.length>0)Z.didInsert=!0;X.push(...U)}if(!Z.didInsert)R6(X,Z,$7($.at(-1)??null,null));return X}function uY($,M,J,Z,X){switch($.kind){case"text":case"inlineCode":case"unsupported":return vY($,M,J,Z);case"break":return hY($,M,J,Z,X);case"image":return gY($,M,J,Z)}}function vY($,M,J,Z){let X=$.text.slice(0,M)+Z+$.text.slice(J);return X.length>0?[{...k5($),text:X}]:[]}function hY($,M,J,Z,X){if(M===J)return[k5($)];let D=[];if(Z.length>0)R6(D,X,$.link);return D}function gY($,M,J,Z){if(M===0&&J===$.text.length)return Z.length>0?[Q7(Z,$.link,0)]:[];return[k5($)]}function R6($,M,J){if(M.replacementText.length===0){M.didInsert=!0;return}$.push(Q7(M.replacementText,J,M.generatedRunCount)),M.generatedRunCount+=1,M.didInsert=!0}function Q7($,M,J){return{id:`generated:${J}`,image:null,inlineCode:!1,kind:"text",link:M,marks:[],originalType:null,text:$}}function $7($,M){return $?.link&&M?.link&&k6($.link,M.link)?$.link:null}function k5($){return{id:$.id,image:$.image,inlineCode:$.inlineCode,kind:$.kind,link:$.link,marks:$.marks,originalType:$.originalType,text:$.text}}function IY($){let M=[],J=0;for(let Z of $){let X=J,D=X+Z.text.length;M.push({...Z,end:D,start:X}),J=D}return M}function pY($){let M=[];for(let J of $){let Z=M.at(-1);if(Z&&lY(Z,J)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function lY($,M){return $.kind===M.kind&&$.inlineCode===M.inlineCode&&k6($.link,M.link)&&cY($.image,M.image)&&$.originalType===M.originalType&&$.marks.join(",")===M.marks.join(",")}function M7($){switch($.kind){case"break":return P2();case"image":return $.image?rY($.image):null;case"inlineCode":return S1({code:$.text});case"text":return $.text.length>0?H0({marks:$.marks,text:$.text}):null;case"unsupported":return n4({originalType:$.originalType??"unsupported",source:$.text})}}function rY($){return o4({alt:$.alt,title:$.title,url:$.url,width:$.width})}function k6($,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 K7($,M){switch(M.kind){case"replace-block":return C5($,M.blockId,M.block,M.selection??null);case"replace-root":return O5($,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=L5($,M.selection,M.text);return{document:J.documentIndex.document,documentIndex:J.documentIndex,selection:J.selection}}}return null}var f6=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function d2($){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 S6($,M){let J=M??dY();return $.animations.some((Z)=>J-Z.startedAt<d2(Z))}function U7($,M){return u6($,M,"inserted-text-highlight",(J)=>J.regionPath)}function N7($,M){return z7($,M,"active-block-flash",(J)=>J.blockPath)}function A7($,M){return u6($,M,"deleted-text-fade",(J)=>J.regionPath)}function V7($,M){return u6($,M,"punctuation-pulse",(J)=>J.regionPath)}function G7($,M){return z7($,M,"list-marker-pop",(J)=>J.blockPath)}function B7($,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,D)=>X-D)}function F7($,M,J){return $.find((Z)=>Z.startOffset<J&&Z.endOffset>M)??null}function _7($,M,J){if(!M)return $;return i2(J.insertHighlightText,$,M.progress)}function b7($,M){return i2($,"rgba(0, 0, 0, 0)",M.progress)}function m5($,M){return i2($,"rgba(0, 0, 0, 0)",M.progress)}function H7($,M){return i2(M.insertHighlightText,"rgba(0, 0, 0, 0)",$.progress)}function P7($){let M=Math.min(1,$.progress*2);return 0.1+0.9*xY(M)}function a2($,M,J){let Z=Math.max(0,M.progress*2-1);return i2(J.insertHighlightText,$,Z)}function u6($,M,J,Z){let X=new Map;for(let D of $.animations){if(D.kind!==J)continue;let Y=d2(D),Q=M-D.startedAt;if(Q>=Y)continue;let K={...D,progress:Math.max(0,Math.min(1,Q/Y))},q=Z(D),U=X.get(q);if(U)U.push(K);else X.set(q,[K])}return X}function z7($,M,J,Z){let X=new Map;for(let D of $.animations){if(D.kind!==J)continue;let Y=d2(D),Q=M-D.startedAt;if(Q>=Y)continue;X.set(Z(D),{...D,progress:Math.max(0,Math.min(1,Q/Y))})}return X}function xY($){return 1-(1-$)*(1-$)*(1-$)}function i2($,M,J){let Z=q7($),X=q7(M);return`rgba(${m6(f5(Z[0],X[0],J))}, ${m6(f5(Z[1],X[1],J))}, ${m6(f5(Z[2],X[2],J))}, ${f5(Z[3],X[3],J)})`}function dY(){return typeof performance<"u"?performance.now():Date.now()}function q7($){let M=f6.get($);if(M)return M;let J=aY($)??iY($)??sY($)??f6.get("rgba(0, 0, 0, 0)");return f6.set($,J),J}function aY($){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 iY($){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 sY($){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 f5($,M,J){return $+(M-$)*J}function m6($){return Math.round($)}function S5($,M,J=N1()){if(M<=0)return $;let Z=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Z)return $;let X=$.selection.focus.offset,D=Math.max(0,X-M);if(X<=D)return $;return s2($,{endOffset:X,kind:"inserted-text-highlight",regionPath:Z.path,startOffset:D,startedAt:J})}function v6($,M,J=N1()){if(M.text.length===0)return $;return s2($,{kind:"deleted-text-fade",regionPath:M.regionPath,startOffset:M.startOffset,startedAt:J,text:M.text})}function h6($,M,J=N1()){return s2($,{blockPath:M,kind:"active-block-flash",startedAt:J})}function g6($,M=N1()){let J=$.documentIndex.regionIndex.get($.selection.focus.regionId),Z=$.selection.focus.offset-1;if(!J||Z<0||J.text[Z]!==".")return $;return s2($,{kind:"punctuation-pulse",offset:Z,regionPath:J.path,startedAt:M})}function I6($,M,J=N1()){return s2($,{blockPath:M,kind:"list-marker-pop",startedAt:J})}function s2($,M){let J=u5($.animations,M.startedAt);return{...$,animations:[...J,M]}}function u5($,M){return $.filter((J)=>J.startedAt+d2(J)>M)}function N1(){return typeof performance<"u"?performance.now():Date.now()}function W7($){let M=$.documentIndex.regionIndex.get($.selection.focus.regionId);return(M?$.documentIndex.blockIndex.get(M.blockId)??null:null)?.path??""}function v5($,M){let J=Math.max(-1/0,...$.animations.map((Z)=>Z.startedAt));return M.animations.some((Z)=>Z.startedAt>J)}function o2($){let M=e1($),J=T7(M);return{animations:[],documentIndex:M,future:[],history:[],selection:{anchor:J,focus:J}}}function I0($){let M=L0($.documentIndex);return g1(z2($.documentIndex.document.blocks),M.threads,$.documentIndex.document.frontMatter)}function s($,M){if(!M)return null;switch(M.kind){case"keep-state":return $;case"set-selection":return D0($,M.selection);default:{let J=K7($.documentIndex,M);if(!J)return null;let Z=oY($,J.document,J.documentIndex??null),X=p2(Z.documentIndex,J.selection)??$.selection,D=y7($,Z,X);return D0(Z,X,D)}}}function D0($,M,J){let Z="regionId"in M?{anchor:h5($.documentIndex,M),focus:h5($.documentIndex,M)}:{anchor:h5($.documentIndex,M.anchor),focus:h5($.documentIndex,M.focus)},X={...$,selection:Z};return J??y7($,X)?h6(X,W7(X)):X}function y0($,M,J,Z){let X={regionId:M,offset:J};return D0($,Z?{anchor:$.selection.anchor,focus:X}:X)}function oY($,M,J=null){let Z=J??e1(M);return{animations:u5($.animations,N1()),documentIndex:Z,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:nY(Z)}}function p6($){let M=$.history.at(-1);if(!M)return $;let J=e1(M.document);return{animations:[],documentIndex:J,future:[{document:$.documentIndex.document,selection:$.selection},...$.future],history:$.history.slice(0,-1),selection:M.selection}}function l6($){let M=$.future[0];if(!M)return $;let J=e1(M.document);return{animations:[],documentIndex:J,future:$.future.slice(1),history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:M.selection}}function g5($,M,J,Z){let X=L$($.documentIndex.document,M,J,Z),D=g2($.documentIndex,X);return{animations:u5($.animations,N1()),documentIndex:D,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:$.selection}}function nY($){let M=T7($);return{anchor:M,focus:M}}function T7($){return $.regions[0]?{regionId:$.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function h5($,M){let J=n0($,M.regionId);if(!J)return M;return{regionId:J.id,offset:Math.max(0,Math.min(M.offset,J.text.length))}}function y7($,M,J){let Z=E7($.documentIndex,$.selection),X=E7(M.documentIndex,J??M.selection);return X!==null&&X!==Z}function E7($,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 e2($,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=A1($,J.id);if(Z)return{kind:"tableCell",...Z};let X=l0($,M);if(X)return{kind:"listItem",...X};let D=Z2($,M);if(D)return{kind:"blockquoteTextBlock",...D};let Y=p0($,M);if(Y)return{kind:"rootTextBlock",...Y};return{kind:"unsupported"}}function $4($,M){let J=$.blockIndex.get(M);if(!J)throw Error(`Unknown root block: ${M}`);return J.rootIndex}function I5($,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 n2($){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 p0($,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,D=$.document.blocks[X];if(!D||D.type!=="heading"&&D.type!=="paragraph")return null;return{block:D,region:J,rootIndex:X}}function w7($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=I5($,Z?.id??null,"blockquote");if(!X)return null;let D=X.rootIndex,Y=$.document.blocks[D];return Y?.type==="blockquote"?{quote:Y,rootIndex:D}:null}function Z2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=I5($,Z?.id??null,"blockquote");if(!Z||!X||Z.parentBlockId!==X.id)return null;let D=X.rootIndex,Y=$.document.blocks[D];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:n2(Z.path),childIndex:Q,region:J,quote:Y,rootIndex:D}}function t2($,M){return r1($.document.blocks,M)}function l0($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=I5($,Z?.id??null,"listItem"),D=I5($,Z?.id??null,"list");if(!Z||!X||!D)return null;let Y=t2($,D.id);if(!Y||Y.type!=="list")return null;let Q=Y.items.findIndex((B)=>B.id===X.id),K=Y.items[Q];if(!K)return null;let q=D.parentBlockId?$.blockIndex.get(D.parentBlockId)??null:null,U=q?.parentBlockId?$.blockIndex.get(q.parentBlockId)??null:null,N=q?.type==="listItem"?t2($,q.id):null,A=U?.type==="list"?t2($,U.id):null,V=A?.type==="list"&&N?A.items.findIndex((B)=>B.id===N.id):-1;return{region:J,item:K,itemChildIndices:n2(X.path),itemIndex:Q,list:Y,listChildIndices:n2(D.path),parentItem:N?.type==="listItem"?N:null,parentItemChildIndices:q?.type==="listItem"?n2(q.path):null,parentItemIndex:V>=0?V:null,parentList:A?.type==="list"?A:null,parentListChildIndices:U?.type==="list"?n2(U.path):null,rootIndex:D.rootIndex}}function A1($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=$.tableCellIndex.get(J.id),X=$.blockIndex.get(J.blockId),D=X?.type==="table"?$.document.blocks[X.rootIndex]:null;if(!Z||!X||!D||D.type!=="table")return null;return{cellIndex:Z.cellIndex,rootIndex:X.rootIndex,rowIndex:Z.rowIndex,table:D}}function M4($,M,J){return d0({checked:M,children:[r({text:$})],spread:J})}function X2($,M){let J=$.children[0];if(!J||J.type!=="paragraph")return null;return E0($,[r({text:M}),...$.children.slice(1)])}function O7($,M){return M.reduce((J,Z)=>`${J}.children.${Z}`,`root.${$}`)}function C7($,M,J){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let X=n($,M),D=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 tY($,M,Z.id,D)??$Q($,M,Z.id,D)??eY($,M,Z.id,D)??MQ($,M,Z.id,D)??XQ($,Z.blockId,Z.rootIndex,D)??{kind:"replace-selection",selection:M,text:J}}function tY($,M,J,Z){let X=l0($,M),D=QQ(Z);if(!X||!D||X.region.id!==J)return null;let Y=X2(X.item,D.text);if(!Y)return null;return{kind:"replace-block",block:$0(X.list,X.list.items.map((Q,K)=>K===X.itemIndex?Y:Q),{ordered:D.ordered,start:D.ordered?1:null}),blockId:X.list.id,selection:X0(X.rootIndex,[...X.listChildIndices,X.itemIndex,0])}}function eY($,M,J,Z){if(!c6($,M,J))return null;if(/^\s*([-+*])\s\[( |x|X)\]\s$/.exec(Z)){let Y=Z.toLowerCase().includes("[x]");return r6($,M,{checked:Y,ordered:!1,start:null})}if(/^\s*[-+*]\s$/.test(Z))return r6($,M,{checked:null,ordered:!1,start:null});let D=/^\s*(\d+)\.\s$/.exec(Z);if(D)return r6($,M,{checked:null,ordered:!0,start:Number(D[1])});return null}function $Q($,M,J,Z){let X=p0($,M),D=KQ(Z);if(!X||X.region.id!==J||X.block.type!=="heading"||!D)return null;return{kind:"replace-root",block:M1({depth:D.depth,text:D.text}),rootIndex:X.rootIndex,selection:M0(X.rootIndex)}}function MQ($,M,J,Z){return JQ($,M,J,Z)??ZQ($,M,J,Z)}function JQ($,M,J,Z){if(!c6($,M,J))return null;let X=/^(#{1,6})\s$/.exec(Z);if(!X)return null;return DQ($,M,X[1].length)}function ZQ($,M,J,Z){if(!c6($,M,J)||!/^>\s$/.test(Z))return null;return YQ($,M)}function XQ($,M,J,Z){if(!/^(?:(?:-\s?){3}|(?:\*\s?){3}|(?:_\s?){3})$/.test(Z))return null;return{kind:"replace-root-range",count:1,replacements:[t4(),r({text:""})],rootIndex:$4($,M),selection:M0(J+1)}}function r6($,M,J){let Z=$4($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:P1({items:[d0({checked:J.checked,children:[r({text:""})],spread:!1})],ordered:J.ordered,spread:!1,start:J.start}),rootIndex:Z,selection:X0(Z,[0,0])}}function DQ($,M,J){let Z=$4($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:M1({depth:J,text:""}),rootIndex:Z,selection:M0(Z)}}function YQ($,M){let J=$4($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"replace-root",block:P0({children:[r({text:""})]}),rootIndex:J,selection:X0(J,[0])}}function c6($,M,J){let Z=p0($,M);return Z?.region.id===J&&Z.block.type==="paragraph"}function QQ($){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 KQ($){let M=/^(#{1,6})\s(.+)$/.exec($);return M?{depth:M[1].length,text:M[2]}:null}function j7($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=l0($,M);if(!Z)return null;let X=Z.region.text,D=Z.item,Y=typeof D.checked==="boolean"?!1:D.checked;if(J.start.offset===0){let N=M4("",Y,D.spread);return{kind:"replace-block",block:$0(Z.list,[...Z.list.items.slice(0,Z.itemIndex),N,D,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:p5(N,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex]),selection:X0(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex,0])}}if(J.start.offset===X.length){let N=M4("",Y,D.spread);return{kind:"replace-block",block:$0(Z.list,[...Z.list.items.slice(0,Z.itemIndex+1),N,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:p5(N,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1]),selection:X0(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1,0])}}let Q=X.slice(0,J.start.offset),K=X.slice(J.start.offset),q=M4(K,Y,D.spread),U=E0(D,[r({text:Q})]);return{kind:"replace-block",block:$0(Z.list,[...Z.list.items.slice(0,Z.itemIndex),U,q,...Z.list.items.slice(Z.itemIndex+1)]),blockId:Z.list.id,listItemInsertedPath:p5(q,Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1]),selection:X0(Z.rootIndex,[...Z.listChildIndices,Z.itemIndex+1,0])}}function L7($,M){let J=n($,M),Z=l0($,M);if(!Z||J.start.regionId!==J.end.regionId)return null;if(J.start.offset!==0||Z.region.text.length!==0)return j7($,M);if(Z.parentItem&&Z.parentItemIndex!==null&&Z.parentItemChildIndices&&Z.parentList&&Z.parentListChildIndices)return qQ(Z);let X=Z.list.items.slice(0,Z.itemIndex),D=Z.list.items.slice(Z.itemIndex+1),Y=[];if(X.length>0)Y.push($0(Z.list,X));if(Y.push(r({text:""})),D.length>0)Y.push($0(Z.list,D));return{kind:"replace-root-range",count:1,replacements:Y,rootIndex:Z.rootIndex,selection:M0(Z.rootIndex+(X.length>0?1:0))}}function R7($,M){let J=l0($,M);if(!J)return null;if(typeof J.item.checked==="boolean"){let Z=d0({checked:null,children:J.item.children,spread:J.item.spread});return{kind:"replace-block",block:$0(J.list,J.list.items.map((X,D)=>D===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:$0(J.list,J.list.items.filter((D,Y)=>Y!==J.itemIndex)),blockId:J.list.id,selection:X0(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:$0(J.list,J.list.items.flatMap((D,Y)=>{if(Y===J.itemIndex-1)return[X];if(Y===J.itemIndex)return[];return[D]})),blockId:J.list.id,selection:X0(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:M0(J.rootIndex)}}function k7($,M){let J=l0($,M);if(!J||J.itemIndex===0)return null;let Z=J.list.items[J.itemIndex-1];if(!Z)return null;let X=UQ(Z,J.item,J);return{kind:"replace-block",block:$0(J.list,J.list.items.flatMap((D,Y)=>{if(Y===J.itemIndex-1)return[X.item];if(Y===J.itemIndex)return[];return[D]})),blockId:J.list.id,selection:X0(J.rootIndex,X.regionChildIndices)}}function f7($,M){let J=l0($,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[$0(J.list,Z)]}),D=E0(J.parentItem,X);return{kind:"replace-block",block:$0(J.parentList,[...J.parentList.items.slice(0,J.parentItemIndex),D,J.item,...J.parentList.items.slice(J.parentItemIndex+1)]),blockId:J.parentList.id,selection:X0(J.rootIndex,[...J.parentListChildIndices,J.parentItemIndex+1,0])}}function x6($,M,J){let Z=l0($,M);if(!Z)return null;let X=Z.itemIndex+J;if(X<0||X>=Z.list.items.length)return null;let D=[...Z.list.items],[Y]=D.splice(Z.itemIndex,1);if(!Y)return null;return D.splice(X,0,Y),{kind:"replace-block",block:$0(Z.list,D),blockId:Z.list.id,selection:X0(Z.rootIndex,[...Z.listChildIndices,X,0])}}function qQ($){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[$0($.list,M)]}),Z=E0($.parentItem,J),X=typeof $.parentItem.checked==="boolean"?!1:$.parentItem.checked,D=M4("",X,$.parentItem.spread);return{kind:"replace-block",block:$0($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),Z,D,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,listItemInsertedPath:p5(D,$.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1]),selection:X0($.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1,0])}}function p5($,M,J){return typeof $.checked==="boolean"?void 0:O7(M,J)}function UQ($,M,J){let Z=$.children.findIndex((D)=>D.type==="list"&&D.ordered===J.list.ordered&&D.start===J.list.start);if(Z>=0){let D=$.children[Z];if(!D||D.type!=="list")return{item:$,regionChildIndices:[...J.listChildIndices,J.itemIndex-1,0]};return{item:E0($,$.children.map((Y,Q)=>Q===Z?$0(D,[...D.items,M]):Y)),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,Z,D.items.length,0]}}let X=P1({items:[M],ordered:J.list.ordered,spread:J.list.spread,start:J.list.start});return{item:E0($,[...$.children,X]),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,$.children.length,0,0]}}function l5($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let Z=p0($,M);if(!Z)return NQ($,M);let X=Z.region.text.slice(0,J.start.offset),D=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?[r({text:""}),Z.block]:J.start.offset===Z.region.text.length?[Z.block,r({text:""})]:[r({text:X}),r({text:D})],rootIndex:Z.rootIndex,selection:M0(Y)};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:""})]:[M1({depth:Z.block.depth,text:X}),r({text:D})],rootIndex:Z.rootIndex,selection:M0(Y)}}function NQ($,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,D=X.slice(0,J.start.offset),Y=X.slice(J.start.offset),Q=Z.block.type==="heading"?_Q(Z.block,D,Y,Z.blockChildIndices,J.start.offset,X.length):FQ(Z.block,D,Y,Z.blockChildIndices,J.start.offset,X.length);return{kind:"replace-root",block:P0({children:[...Z.quote.children.slice(0,Z.childIndex),...Q.blocks,...Z.quote.children.slice(Z.childIndex+1)]}),rootIndex:Z.rootIndex,selection:X0(Z.rootIndex,Q.focusChildIndices)}}function m7($,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),D=Z.quote.children.slice(Z.childIndex+1),Y=[];if(X.length>0)Y.push(P0({children:X}));if(Y.push(r({text:""})),D.length>0)Y.push(P0({children:D}));return{kind:"replace-root-range",count:1,replacements:Y,rootIndex:Z.rootIndex,selection:M0(Z.rootIndex+(X.length>0?1:0))}}function S7($,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 u7($,M){let J=n($,M);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=p0($,M),X=Z?GQ(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 U=AQ(Z,K,q);if(U)return U;return{kind:"replace-root-range",count:1,replacements:[],rootIndex:Z.rootIndex,selection:K.type==="paragraph"||K.type==="heading"?M0(Z.rootIndex-1,"end"):K.type==="list"?X0(Z.rootIndex-1,[K.items.length-1,0],"end"):K.type==="blockquote"?X0(Z.rootIndex-1,[K.children.length-1],"end"):M0(Z.rootIndex-1,"end")}}if(K.type==="paragraph")return{kind:"replace-root-range",count:2,replacements:[r({text:`${K.plainText}${Z.block.plainText}`})],rootIndex:Z.rootIndex-1,selection:M0(Z.rootIndex-1,"end")};if(K.type==="heading")return{kind:"replace-root-range",count:2,replacements:[M1({depth:K.depth,text:`${K.plainText}${Z.block.plainText}`})],rootIndex:Z.rootIndex-1,selection:M0(Z.rootIndex-1,"end")};if(K.type==="list"){let U=K.items.length-1,N=K.items[U];if(N){let A=X2(N,`${N.plainText}${Z.block.plainText}`);if(A)return{kind:"replace-root-range",count:2,replacements:[$0(K,K.items.map((V,B)=>B===U?A:V))],rootIndex:Z.rootIndex-1,selection:X0(Z.rootIndex-1,[U,0],"end")}}}}}let D=BQ($,M);if(D)return D;let Y=w7($,M);if(!Y)return null;let Q=Z2($,M);return{kind:"replace-root-range",count:1,replacements:Y.quote.children,rootIndex:Y.rootIndex,selection:M0(Q?Y.rootIndex+Q.childIndex:Y.rootIndex)}}function d6($,M,J){let Z=p0($,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:M1({depth:X,text:Z.block.plainText}),rootIndex:Z.rootIndex,selection:M0(Z.rootIndex,M.focus.offset)}}function AQ($,M,J){if($.block.type!=="paragraph"||$.block.plainText.length!==0||M.type!=="list"||J?.type!=="list"||!VQ(M,J))return null;let Z=M.items.length-1;return{kind:"replace-root-range",count:3,replacements:[$0(M,[...M.items,...J.items])],rootIndex:$.rootIndex-1,selection:X0($.rootIndex-1,[Z,0],"end")}}function VQ($,M){return $.ordered===M.ordered&&$.start===M.start}function GQ($){if($.block.type!=="heading")return null;return{kind:"replace-root",block:r({text:$.block.plainText}),rootIndex:$.rootIndex,selection:M0($.rootIndex)}}function BQ($,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:[r({text:""})],rootIndex:Z.rootIndex,selection:M0(Z.rootIndex)};let X=Math.max(0,Z.childIndex-1),D=Z.childIndex>0?"end":0;return{kind:"replace-root",block:P0({children:Z.quote.children.filter((Y,Q)=>Q!==Z.childIndex)}),rootIndex:Z.rootIndex,selection:X0(Z.rootIndex,[X],D)}}function FQ($,M,J,Z,X,D){return{blocks:X===0?[r({text:""}),$]:X===D?[$,r({text:""})]:[r({text:M}),r({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function _Q($,M,J,Z,X,D){return{blocks:X===0?[r({text:""}),$]:X===D?[$,r({text:""})]:[M1({depth:$.depth,text:M}),r({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function v7($,M,J){let Z=p0($,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:z1({rows:Array.from({length:2},()=>i6(X))}),rootIndex:Z.rootIndex,selection:U1(Z.rootIndex,0,0)}}function a6($,M,J){let Z=A1($,M.focus.regionId);if(!Z)return null;let X=J<0?zQ(Z.table,Z.rowIndex,Z.cellIndex):WQ(Z.table,Z.rowIndex,Z.cellIndex);if(!X)return J>0&&EQ(Z.table,Z.rowIndex,Z.cellIndex)?bQ(Z):{kind:"keep-state"};let D=Z.table.rows[X.rowIndex]?.cells[X.cellIndex];if(!D)return{kind:"keep-state"};return{kind:"set-selection",selection:PQ($,M,Z.table,X.rowIndex,X.cellIndex,Math.min(M.focus.offset,D.plainText.length))}}function h7($,M){let J=H5($,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),D=C6(J,Z,X);return{kind:"replace-block",block:D.block,blockId:D.blockId,selection:D.selection}}function g7($,M,J){let Z=A1($,M.focus.regionId);if(!Z)return null;let X=J==="left"?Z.cellIndex:Z.cellIndex+1;return D2(Z,z1({align:x7(Z.table.align,X,0,[null]),rows:Z.table.rows.map((D)=>v1({cells:HQ(D.cells,X,0,[c7()])}))}),U1(Z.rootIndex,Z.rowIndex,X))}function I7($,M){let J=A1($,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 D2(J,z1({align:x7(J.table.align,J.cellIndex,1,[]),rows:J.table.rows.map((X)=>v1({cells:X.cells.filter((D,Y)=>Y!==J.cellIndex)}))}),U1(J.rootIndex,J.rowIndex,Math.min(J.cellIndex,Z-2)))}function p7($,M,J){let Z=A1($,M.focus.regionId);if(!Z)return null;let X=J==="above"?Z.rowIndex:Z.rowIndex+1,D=Math.max(1,...Z.table.rows.map((Y)=>Y.cells.length));return D2(Z,S0(Z.table,[...Z.table.rows.slice(0,X),i6(D),...Z.table.rows.slice(X)]),U1(Z.rootIndex,X,Math.min(Z.cellIndex,D-1)))}function l7($,M){let J=A1($,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),D=Z[X]?.cells.length??1;return D2(J,S0(J.table,Z),U1(J.rootIndex,X,Math.min(J.cellIndex,D-1)))}function r7($,M){let J=A1($,M.focus.regionId);if(!J)return null;return D2(J,r({text:""}),M0(J.rootIndex))}function i6($){return v1({cells:Array.from({length:$},()=>c7())})}function c7(){return J1({children:[]})}function bQ($){let M=$.table.rows.length,J=Math.max(1,...$.table.rows.map((Z)=>Z.cells.length));return D2($,S0($.table,[...$.table.rows,i6(J)]),U1($.rootIndex,M,0))}function D2($,M,J){return{kind:"replace-block",block:M,blockId:$.table.id,selection:J}}function HQ($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function x7($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function PQ($,M,J,Z,X,D){let Y=M2($,J.id,Z,X);if(!Y)return M;return{anchor:{regionId:Y.id,offset:D},focus:{regionId:Y.id,offset:D}}}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 WQ($,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 EQ($,M,J){let Z=$.rows[M];return Boolean(Z&&M===$.rows.length-1&&J===Z.cells.length-1)}function Y2($,M){let J=C7($.documentIndex,$.selection,M),Z=s($,J);if(!Z)return null;if(J?.kind==="replace-selection"&&M.length>0)Z=S5(Z,M.length);if(M===".")Z=g6(Z);return Z}function J4($){switch(e2($.documentIndex,$.selection).kind){case"code":return s($,S7($.documentIndex,$.selection));case"tableCell":return s($,h7($.documentIndex,$.selection));case"listItem":{let J=L7($.documentIndex,$.selection);return wQ({state:s($,J)??s($,l5($.documentIndex,$.selection)),action:J})}case"blockquoteTextBlock":return s($,m7($.documentIndex,$.selection))??s($,l5($.documentIndex,$.selection));case"rootTextBlock":return s($,l5($.documentIndex,$.selection));case"unsupported":return null}}function r5($){if(a7($))return Z4($);let M=OQ($);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(e2($.documentIndex,$.selection).kind){case"listItem":return s($,R7($.documentIndex,$.selection));case"blockquoteTextBlock":case"rootTextBlock":return s($,u7($.documentIndex,$.selection));default:return null}}function c5($){if(a7($))return Z4($);return CQ($)}function s6($,M){return s($,{kind:"replace-selection",selection:$.selection,text:M})}function x5($,M){let J=s6($,M);return M.length>0?S5(J,M.length):J}function Z4($){return s6($,"")}function o6($){let M=$.documentIndex.regions,J=M[0],Z=M.at(-1);if(!J||!Z)return $;return D0($,{anchor:{regionId:J.id,offset:0},focus:{regionId:Z.id,offset:Z.text.length}})}function n6($){switch(e2($.documentIndex,$.selection).kind){case"tableCell":return s($,a6($.documentIndex,$.selection,1));case"rootTextBlock":return s($,d6($.documentIndex,$.selection,1));case"listItem":return TQ($);default:return null}}function t6($){switch(e2($.documentIndex,$.selection).kind){case"tableCell":return s($,a6($.documentIndex,$.selection,-1));case"rootTextBlock":return s($,d6($.documentIndex,$.selection,-1));case"listItem":return yQ($);default:return null}}function TQ($){return s($,k7($.documentIndex,$.selection))}function yQ($){return s($,f7($.documentIndex,$.selection))}function e6($){return s($,x6($.documentIndex,$.selection,-1))}function $3($){return s($,x6($.documentIndex,$.selection,1))}function M3($,M){return s($,v7($.documentIndex,$.selection,M))}function J3($,M){return s($,g7($.documentIndex,$.selection,M))}function Z3($){return s($,I7($.documentIndex,$.selection))}function X3($,M){return s($,p7($.documentIndex,$.selection,M))}function D3($){return s($,l7($.documentIndex,$.selection))}function Y3($){return s($,r7($.documentIndex,$.selection))}function d5($,M){return d7($,(J,Z,X)=>y6(J,Z,X,M))}function Q3($){return d7($,(M,J,Z)=>O6(M,J,Z))}function X4($){return d5($,"bold")}function D4($){return d5($,"italic")}function Y4($){return d5($,"strikethrough")}function Q4($){return d5($,"underline")}function K3($,M,J,Z,X){return s($,E5($.documentIndex,M,J,Z,X))}function q3($,M,J,Z){return s($,E5($.documentIndex,M,J,Z,null))}function U3($,M){let J=t2($.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 a5($){return p6($)}function i5($){return l6($)}function N3($,M,J){let Z=_6($.documentIndex,M,J);if(!Z)return null;return g5($,$.documentIndex.document.comments.length,0,[Z])}function A3($,M,J){return K4($,M,(Z)=>m8(Z,{body:J.trim()}))}function V3($,M,J,Z){return K4($,M,(X)=>S8(X,J,Z))}function G3($,M,J){return K4($,M,(Z)=>u8(Z,J))}function B3($,M){return K4($,M,()=>null)}function F3($,M,J){return K4($,M,(Z)=>v8(Z,J))}function K4($,M,J){let X=L0($.documentIndex).threads[M];if(!X)return null;let D=J(X);if(D===X)return null;return g5($,M,1,D?[D]:[])}function wQ($){if(!$.state||!$.action||$.action.kind!=="replace-block"||!$.action.listItemInsertedPath)return $.state;return I6($.state,$.action.listItemInsertedPath)}function d7($,M){let J=n($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset===J.end.offset)return null;return s($,I2($.documentIndex,J.start.regionId,J.start.offset,J.end.offset,M))}function a7($){let M=n($.documentIndex,$.selection);return M.start.regionId!==M.end.regionId||M.start.offset!==M.end.offset}function OQ($){return i7($,"backward")}function CQ($){return i7($,"forward")}function i7($,M){if($.selection.anchor.regionId!==$.selection.focus.regionId||$.selection.anchor.offset!==$.selection.focus.offset)return null;let J=n0($.documentIndex,$.selection.focus.regionId);if(!J)return null;if(M==="forward"&&$.selection.focus.offset>=J.text.length)return null;let Z=M==="backward"?RQ(J.text,$.selection.focus.offset):$.selection.focus.offset,X=M==="backward"?$.selection.focus.offset:kQ(J.text,$.selection.focus.offset);if(Z===X)return null;let D=s6(D0($,{anchor:{regionId:J.id,offset:Z},focus:{regionId:J.id,offset:X}}),"");return jQ($,D,Z,X)}function jQ($,M,J,Z){let X=LQ($,J,Z);return X?v6(M,X):M}function LQ($,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 RQ($,M){let J=Array.from($.slice(0,M));if(J.length===0)return 0;return M-J.at(-1).length}function kQ($,M){let J=Array.from($.slice(M))[0];return J?M+J.length:$.length}var s7=1;function o7($,M,J){let Z=$.documentIndex.regionOrderIndex.get($.selection.focus.regionId);if(Z===void 0)return $;let X=$.documentIndex.regions[Z],D=$.selection.focus.offset+M;if(D>=0&&D<=X.text.length)return y0($,X.id,D,J);if(M<0){let Q=$.documentIndex.regions[Z-1];if(!Q)return $;return y0($,Q.id,Q.text.length,J)}let Y=$.documentIndex.regions[Z+1];if(!Y)return $;return y0($,Y.id,0,J)}function n7($,M,J,Z,X){let D=j2(M,J.regionId,J.offset);if(!D)return $;let Y=M.lines[D.index+Z];if(!Y)return $;let Q=T0(M,$,{x:g0($,M,J)+s7,y:Y.top+Y.height/2});if(!Q)return $;return y0($,Q.regionId,Q.offset,X)}function t7($,M,J,Z){let X=$M($,M);if(!X)return $;return y0($,X.regionId,J==="Home"?X.start:X.end,Z)}function e7($,M,J,Z,X){let D=$M($,M);if(!D)return $;let Q=Math.max(1,Math.floor(480/M.options.lineHeight)),K=j2(M,D.regionId,$.selection.focus.offset),q=K?M.lines[K.index+Z*Q]:null;if(!q)return $;let U=T0(M,$,{x:g0($,M,J)+s7,y:q.top+q.height/2});if(!U)return $;return y0($,U.regionId,U.offset,X)}function $M($,M){return s0(M,$.selection.focus.regionId,$.selection.focus.offset)}var fQ=1;function MM($,M,J,Z,X){let D=$.documentIndex.regionIndex.get($.selection.focus.regionId)??null;if(!D)return null;let Y=$.documentIndex.tableCellIndex.get(D.id)??null,Q=$.documentIndex.blockIndex.get(D.blockId)??null;if(!Y||Q?.type!=="table")return null;let K=mQ($,Q.id,Y.rowIndex+Z,Y.cellIndex)??SQ($,Q.id,Z);if(!K)return $;let q=M.regionBounds.get(D.id),U=M.regionBounds.get(K.id);if(!q||!U)return $;let N=U.top+uQ(J.top+J.height/2-q.top,0,Math.max(0,U.bottom-U.top-1)),A=T0(M,$,{x:g0($,M,J)+fQ,y:N});if(!A)return $;return y0($,A.regionId,A.offset,X)}function mQ($,M,J,Z){return M2($.documentIndex,M,J,Z)}function SQ($,M,J){let Z=$.documentIndex.blockIndex.get(M),X=$.documentIndex.regions,D=Z?$.documentIndex.roots[Z.rootIndex]?.regionRange:void 0;if(!D)return null;return J<0?X[D.start-1]??null:X[D.end]??null}function uQ($,M,J){return Math.max(M,Math.min(J,$))}function _3($,M,J=!1){return o7($,M,J)}function b3($,M,J,Z=!1){return vQ($,M,J,Z)}function H3($,M,J,Z=!1){return hQ($,M,J,Z)}function P3($,M,J,Z=!1){return t7($,M,J,Z)}function z3($,M,J=!1){return gQ($,M,J)}function vQ($,M,J,Z){let X=JM($,M);if(!X)return $;return MM($,M,X,J,Z)??n7($,M,X,J,Z)}function hQ($,M,J,Z){let X=JM($,M);if(!X)return $;return e7($,M,X,J,Z)}function gQ($,M,J){let Z=$.documentIndex.regions,X=M==="start"?Z[0]:Z.at(-1);if(!X)return $;return y0($,X.id,M==="start"?0:X.text.length,J)}function JM($,M){return v0(M,$.documentIndex,{regionId:$.selection.focus.regionId,offset:$.selection.focus.offset})}function XM($,M,J,Z,X,D,Y){let Q=J.image?Z.images.get(J.image.url):null,K=lQ(J,Z,Y),q=rQ(M,D,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 IQ($,X,{...q,status:Q?.status==="error"?"error":"loading"});$.strokeStyle=X.imageSurfaceBorder,$.strokeRect(q.left,q.top,q.width,q.height)}function IQ($,M,J){let Z=J.status==="loading"?"Loading image":"Image unavailable",X=cQ(J),D=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")pQ($,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,D),$.restore()}function pQ($,M,J){let Z=Math.max(48,Math.round(J.width*0.22)),X=J.width+Z*2,D=performance.now()%1800/1800,Y=J.left-Z+X*D,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 lQ($,M,J){if(!$.image)return ZM(J);let Z=M.images.get($.image.url);if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return ZM(J);return Math.max(48,Math.round(J*(Z.intrinsicHeight/Z.intrinsicWidth)))}function rQ($,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 ZM($){return Math.max(48,Math.round($*0.5625))}var DM=2,YM=8,xQ=3,dQ=1.5,aQ=2,Q2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function QM($,M,J,Z,X,D,Y=null){if(!J||M.start!==0)return;if(Y){let Q=P7(Y),K=tQ(J,M,Z,X,$);$.save(),$.translate(K.x,K.y),$.scale(Q,Q),$.translate(-K.x,-K.y)}if(J.kind==="task")iQ($,M,J.checked,D,Y);else if($.fillStyle=Y?a2(D.listMarkerText,Y,D):D.listMarkerText,J.kind==="ordered")nQ($,J.label,Z,X);else $.fillText(J.label,M.left-DM,X);if(Y)$.restore()}function iQ($,M,J,Z,X=null){let D=R2(M);if(sQ($,D,J,Z,X),!J)return;oQ($,D,Z,X)}function sQ($,M,J,Z,X=null){let D=J?Z.checkboxCheckedFill:Z.checkboxUncheckedFill,Y=J?Z.checkboxCheckedStroke:Z.checkboxUncheckedStroke;$.fillStyle=X?a2(D,X,Z):D,$.strokeStyle=X?a2(Y,X,Z):Y,$.beginPath(),$.lineWidth=dQ,$.roundRect(M.left,M.top,M.size,M.size,xQ),$.fill(),$.stroke()}function oQ($,M,J,Z=null){$.strokeStyle=Z?a2(J.checkboxCheckmark,Z,J):J.checkboxCheckmark,$.lineWidth=aQ,$.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 nQ($,M,J,Z){let X=$.textAlign;$.textAlign="right",$.fillText(M,J-YM,Z),$.textAlign=X}function tQ($,M,J,Z,X){if($.kind==="task"){let Q=R2(M);return{x:Q.left+Q.size/2,y:Q.top+Q.size/2}}let D=X.measureText($.label),Y=Z-(D.actualBoundingBoxAscent-D.actualBoundingBoxDescent)/2;if($.kind==="ordered")return{x:J-YM-D.width/2,y:Y};return{x:M.left-DM+D.width/2,y:Y}}var eQ=80;function qM({context:$,containerBounds:M,isHeaderRow:J,lineHeight:Z,theme:X}){let D=NM(M,Z);$.fillStyle=J?X.tableHeaderBackground:X.tableBodyBackground,$.fillRect(D.left,D.top,D.width,D.height),AM($,D,X)}function UM({activeBlockFlashes:$,activeBlockId:M,activeRegionId:J,context:Z,editorState:X,endIndex:D,layout:Y,regionBounds:Q,startIndex:K,theme:q,verticalBleed:U}){if(!M||!J)return;let N=X.documentIndex.blockIndex.get(M)??null;if(N?.type!=="table")return;if((X.documentIndex.regionIndex.get(J)??null)?.blockId!==M)return;let V=Q.get(J)??null,B=Y.regionLineIndices.get(J)??null;if(!V||!B||B.length===0)return;let G=Y.lines[B[0]]??null;if(!G)return;let b=NM(V,G.height);if(b.width===0)return;let P=KM({context:Z,endIndex:D,fillStyle:q.activeBlockBackground,layout:Y,left:b.left,lineIndices:B,startIndex:K,verticalBleed:U,width:b.width}),y=N.path?$.get(N.path)??null:null;if(y)KM({context:Z,endIndex:D,fillStyle:m5(q.activeBlockFlash,y),layout:Y,left:b.left,lineIndices:B,startIndex:K,verticalBleed:U,width:b.width});if(!P)return;AM(Z,b,q)}function KM({context:$,endIndex:M,fillStyle:J,layout:Z,left:X,lineIndices:D,startIndex:Y,verticalBleed:Q,width:K}){$.fillStyle=J;let q=!1;for(let U of D){if(U<Y)continue;if(U>=M)break;let N=Z.lines[U];$.fillRect(X,N.top-Q,K,N.height),q=!0}return q}function NM($,M){return{height:Math.max($.bottom-$.top,M),left:$.left,top:$.top,width:Math.max($.right-$.left,eQ)}}function AM($,M,J){$.strokeStyle=J.tableBorder,$.strokeRect(M.left,M.top,M.width,M.height)}var W3=2,$K=3,MK=12,JK=6,ZK=3,XK=1,DK=2,YK=2,QK=8,KK=12,qK=28,UK=4,NK=5,AK=2,VK=3,GK=6,VM=3,BK=12,FK=10,_K=2,bK=2,HK=1,PK=2,E3=2,GM=1.25,zK=5,WK=1,BM=4,EK=4,TK=1.5;function yK({activeBlockId:$,activeRegionId:M,activeThreadIndex:J,containerLineBounds:Z,context:X,devicePixelRatio:D,editorState:Y,height:Q,layout:K,liveCommentRanges:q,normalizedSelection:U,now:N=oK(),resources:A,runtimeBlockMap:V,theme:B,viewportTop:G,width:b}){X.save(),X.scale(D,D),X.clearRect(0,0,b,Q),X.fillStyle=B.background,X.fillRect(0,0,b,Q),X.textBaseline="alphabetic",X.translate(0,-G);let P=wK(Y,U),{endIndex:y,startIndex:z}=J6(K,G,Q),L=N7(Y,N),R=A7(Y,N),m=U7(Y,N),E=G7(Y,N),_=V7(Y,N),j=CK(K,Y,$,z,y),C=OK(K,Y,V,z,y,b);for(let W=z;W<y;W+=1){let F=K.lines[W];kK({containerLineBounds:Z,context:X,editorState:Y,line:F,runtimeBlockMap:V,theme:B,width:b})}UM({activeBlockFlashes:L,activeBlockId:$,activeRegionId:M,context:X,editorState:Y,endIndex:y,layout:K,regionBounds:Z,startIndex:z,theme:B,verticalBleed:W3});for(let W=z;W<y;W+=1){let F=K.lines[W];fK({activeBlockId:$,activeBlockFlashes:L,activeDeletedTextFades:R,activeThreadIndex:J,activeInsertedTextHighlights:m,activeListMarkerPops:E,activePunctuationPulses:_,context:X,editorState:Y,line:F,liveCommentRanges:q,normalizedSelection:U,resources:A,runtimeBlockMap:V,selectionRegionOrderRange:P,theme:B,width:b})}jK(X,C,B),LK(X,j,B),X.restore()}function wK($,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 OK($,M,J,Z,X,D){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 U=Y.get(q.id),N={bottom:K.top+K.height,left:K.left+K1(M,K),right:D-$.options.paddingX};Y.set(q.id,U?{bottom:Math.max(U.bottom,N.bottom),left:U.left,right:U.right}:N)}return Y}function CK($,M,J,Z,X){let D=new Map;for(let Y=Z;Y<X;Y+=1){let Q=$.lines[Y],K=n1(M,Q.blockId,"blockquote");if(!K)continue;let q=D.get(K.id),U={bottom:Q.top+Q.height,isActive:Q.blockId===J,left:$.options.paddingX+(K.depth+1)*$.options.indentWidth-10,top:Q.top};D.set(K.id,q?{bottom:Math.max(q.bottom,U.bottom),isActive:q.isActive||U.isActive,left:q.left,top:Math.min(q.top,U.top)}:U)}return D}function jK($,M,J){$.fillStyle=J.headingRule;for(let Z of M.values())$.fillRect(Z.left,Z.bottom+zK,Math.max(E3,Z.right-Z.left),WK)}function LK($,M,J){for(let Z of M.values())$.fillStyle=Z.isActive?J.blockquoteRuleActive:J.blockquoteRule,$.fillRect(Z.left,Z.top+$K,ZK,Math.max(MK,Z.bottom-Z.top-JK))}function RK({context:$,devicePixelRatio:M,editorState:J,height:Z,layout:X,normalizedSelection:D,presence:Y,showCaret:Q,theme:K,viewportTop:q,width:U}){$.save(),$.scale(M,M),$.clearRect(0,0,U,Z);let N=D.start.regionId===D.end.regionId&&D.start.offset!==D.end.offset,A=Q&&!N;if($.translate(0,-q),A)FM($,J,X,{color:K.caret,offset:J.selection.focus.offset,regionId:J.selection.focus.regionId});if(Y)for(let V of Y){if(!V.cursorPoint)continue;FM($,J,X,{color:V.color??K.leafAccent,offset:V.cursorPoint.offset,regionId:V.cursorPoint.regionId})}$.restore()}function FM($,M,J,Z){let X=v0(J,M.documentIndex,{regionId:Z.regionId,offset:Z.offset});if(!X)return;let D=g0(M,J,X),Y=pK(J,X);$.fillStyle=Z.color,$.fillRect(D,Y.top,DK,Y.height)}function kK({containerLineBounds:$,context:M,editorState:J,line:Z,runtimeBlockMap:X,theme:D,width:Y}){let Q=X.get(Z.blockId)??null,K=$.get(Z.regionId)??null,q=J.documentIndex.tableCellIndex.get(Z.regionId)??null;mK(M,Z,Q,K,q,D,Y)}function fK({activeBlockId:$,activeBlockFlashes:M,activeDeletedTextFades:J,activeThreadIndex:Z,activeInsertedTextHighlights:X,activeListMarkerPops:D,activePunctuationPulses:Y,context:Q,editorState:K,line:q,liveCommentRanges:U,normalizedSelection:N,resources:A,runtimeBlockMap:V,selectionRegionOrderRange:B,theme:G,width:b}){let P=V.get(q.blockId)??null,y=K.documentIndex.blockIndex.get(q.blockId)?.path??null,z=K.documentIndex.regionIndex.get(q.regionId)??null,L=z?.path??"",R=n1(K,q.blockId,"listItem"),m=R?k2(K,R.id):null,E=R?D.get(R.path)??null:null,_=q.left+K1(K,q),j=cK(q),C=P?.type==="code"?G.codeText:aK(P,G);Q.font=q.font,SK(Q,q,P,y,$,M,G,b),uK(Q,K,q,N,B,G),vK(Q,K,q,U,Z,G),QM(Q,q,m,_,j,G,E),hK(Q,q,z,_,j,X.get(L)??[],C,A,G),gK(Q,q,z,_,j,J.get(L)??[],C),IK(Q,q,z,_,j,Y.get(L)??[],G)}function mK($,M,J,Z,X,D,Y){if(!Z||M.start!==0)return;if(J?.type==="code"){let Q=Math.max(0,M.left-KK);$.fillStyle=D.codeBackground,$.fillRect(Q,Z.top-UK,Math.max(Z.right-M.left+qK,Y-Q),Z.bottom-Z.top+QK);return}if(J?.type!=="table")return;qM({context:$,containerBounds:Z,isHeaderRow:X?.rowIndex===0,lineHeight:M.height,theme:D})}function SK($,M,J,Z,X,D,Y,Q){if(M.blockId!==X||J?.type==="table")return;let K=Z?D.get(Z)??null:null;if($.fillStyle=Y.activeBlockBackground,$.fillRect(0,M.top-W3,Q,M.height),!K)return;$.fillStyle=m5(Y.activeBlockFlash,K),$.fillRect(0,M.top-W3,Q,M.height)}function uK($,M,J,Z,X,D){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=D.selectionBackground,$.fillRect(Q1(M,J,Q-J.start),J.top+HK,Math.max(bK,Q1(M,J,K-J.start)-Q1(M,J,Q-J.start)),J.height-PK)}function vK($,M,J,Z,X,D){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=sK(Y,X,D),$.fillRect(Q1(M,J,Q-J.start),J.top+J.height-NK,Math.max(AK,Q1(M,J,K-J.start)-Q1(M,J,Q-J.start)),VK)}}function hK($,M,J,Z,X,D,Y,Q,K){if(!J){$.fillStyle=Y,$.fillText(M.text,Z,X);return}let q=J.inlines.filter((U)=>U.end>M.start&&U.start<M.end);if(q.length===0){$.fillStyle=Y,$.fillText(M.text,Z,X);return}for(let U of q){let N=Math.max(M.start,U.start),A=Math.min(M.end,U.end);if(J.text.slice(N,A).length===0)continue;let{left:B,right:G}=y3(M,Z,N,A),b=iK(M.font,U.marks);if($.font=b,U.kind==="image"){let P=Math.max(24,G-B);XM($,M,U,Q,K,B,P);continue}if(U.kind==="inlineCode"){let P=xK(M,b),y=dK(M,b);$.fillStyle=K.inlineCodeBackground,$.fillRect(B-VM,P,Math.max(FK,G-B+VM*2),y),_M($,M,J.text,Z,X,N,A,K.inlineCodeText,D,K,{strikethrough:!1,underline:!1});continue}_M($,M,J.text,Z,X,N,A,U.link?K.linkText:Y,D,K,{strikethrough:U.marks.includes("strikethrough"),underline:U.marks.includes("underline")||Boolean(U.link)})}}function _M($,M,J,Z,X,D,Y,Q,K,q,U){let N=B7(D,Y,K);for(let A=0;A<N.length-1;A+=1){let V=N[A],B=N[A+1];if(B<=V)continue;let G=J.slice(V,B);if(G.length===0)continue;let{left:b,right:P}=y3(M,Z,V,B),y=F7(K,V,B),z=_7(Q,y,q);if($.fillStyle=z,$.fillText(G,b,X),U.strikethrough)$.fillRect(b,rK(X,M.height,$.font),Math.max(E3,P-b),GM);if(U.underline)$.fillRect(b,lK(X,M.height,$.font),Math.max(E3,P-b),GM)}}function gK($,M,J,Z,X,D,Y){if(!J||D.length===0)return;for(let Q of D){if(Q.startOffset<M.start||Q.startOffset>M.end)continue;let K=Z+(h0(M,Q.startOffset-M.start)-M.left);$.fillStyle=b7(Y,Q),$.fillText(Q.text,K,X)}}function IK($,M,J,Z,X,D,Y){if(!J||D.length===0)return;for(let Q of D){if(Q.offset<M.start||Q.offset>=M.end)continue;let{left:K,right:q}=y3(M,Z,Q.offset,Q.offset+1),U=Math.max(BM,(q-K)/2+BM+EK*Q.progress),{ascent:N,descent:A}=Y1(M.font),V=X-Math.max(1,N*0.42)+Math.max(0.5,A*0.15);$.strokeStyle=H7(Q,Y),$.lineWidth=TK,$.beginPath(),$.arc((K+q)/2,V,U,0,Math.PI*2),$.stroke()}}function pK($,M){let J=s0($,M.regionId,M.offset),Z=J?.font??'16px "Iowan Old Style", "Palatino Linotype", serif',{ascent:X,descent:D}=Y1(Z),Y=Math.max(1,X+D),Q=Math.min(M.height-YK,Y),K=J?Math.max(J.top,J.top+T3(J.height,Z)-XK):M.top+Math.max(0,Math.floor((M.height-Q)/2));return{height:Q,top:K}}function lK($,M,J){let{descent:Z}=Y1(J),X=Math.max(1,Math.round(Math.max(2,Z)*0.35)),D=$+Z-X,Y=$-s5(M,J);return Math.min(Y+M-4,D)}function rK($,M,J){let{ascent:Z}=Y1(J),X=$-s5(M,J);return Math.max(X+2,$-Math.round(Z*0.32))}function cK($){return $.top+s5($.height,$.font)}function s5($,M){return R9($,M)}function xK($,M){let J=T3($.height,M);return $.top+J+_K}function dK($,M){let J=T3($.height,M);return Math.max(BK,$.height-J-GK)}function T3($,M){let{ascent:J}=Y1(M);return s5($,M)-J}function aK($,M){switch($?.type){case"heading":return M.headingText;case"blockquote":return M.blockquoteText;case"table":return M.headingText;default:return M.paragraphText}}function y3($,M,J,Z){return{left:M+(h0($,J-$.start)-$.left),right:M+(h0($,Z-$.start)-$.left)}}function iK($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function sK($,M,J){if($.resolved)return $.threadIndex===M?J.commentHighlightResolvedActive:J.commentHighlightResolved;return $.threadIndex===M?J.commentHighlightActive:J.commentHighlight}function oK(){return typeof performance<"u"?performance.now():Date.now()}function w3($,M,J,Z){yK({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 O3($,M,J,Z){RK({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 Mq,createElement as Jq}from"react";var o5=(...$)=>$.filter((M,J,Z)=>{return Boolean(M)&&M.trim()!==""&&Z.indexOf(M)===J}).join(" ").trim();var bM=($)=>$.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var HM=($)=>$.replace(/^([A-Z])|[\s-_]+(\w)/g,(M,J,Z)=>Z?Z.toUpperCase():J.toLowerCase());var C3=($)=>{let M=HM($);return M.charAt(0).toUpperCase()+M.slice(1)};import{forwardRef as $q,createElement as WM}from"react";var n5={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 PM=($)=>{for(let M in $)if(M.startsWith("aria-")||M==="role"||M==="title")return!0;return!1};import{createContext as nK,useContext as tK,useMemo as t_,createElement as e_}from"react";var eK=nK({});var zM=()=>tK(eK);var EM=$q(({color:$,size:M,strokeWidth:J,absoluteStrokeWidth:Z,className:X="",children:D,iconNode:Y,...Q},K)=>{let{size:q=24,strokeWidth:U=2,absoluteStrokeWidth:N=!1,color:A="currentColor",className:V=""}=zM()??{},B=Z??N?Number(J??U)*24/Number(M??q):J??U;return WM("svg",{ref:K,...n5,width:M??q??n5.width,height:M??q??n5.height,stroke:$??A,strokeWidth:B,className:o5("lucide",V,X),...!D&&!PM(Q)&&{"aria-hidden":"true"},...Q},[...Y.map(([G,b])=>WM(G,b)),...Array.isArray(D)?D:[D]])});var u=($,M)=>{let J=Mq(({className:Z,...X},D)=>Jq(EM,{ref:D,iconNode:M,className:o5(`lucide-${bM(C3($))}`,`lucide-${$}`,Z),...X}));return J.displayName=C3($),J};var Zq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],V1=u("columns-2",Zq);var Xq=[["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"}]],G1=u("rows-3",Xq);var Dq=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],B1=u("send-horizontal",Dq);var Yq=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],q4=u("arrow-down",Yq);var Qq=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],U4=u("arrow-up",Qq);var Kq=[["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"}]],N4=u("bold",Kq);var qq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],y1=u("check",qq);var Uq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],A4=u("chevron-down",Uq);var Nq=[["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"}]],V4=u("heading-1",Nq);var Aq=[["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"}]],G4=u("heading-2",Aq);var Vq=[["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"}]],B4=u("heading-3",Vq);var Gq=[["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"}]],F4=u("heading-4",Gq);var Bq=[["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"}]],_4=u("heading-5",Bq);var Fq=[["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"}]],b4=u("heading-6",Fq);var _q=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],H4=u("heading",_q);var bq=[["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"}]],P4=u("italic",bq);var Hq=[["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"}]],z4=u("list-ordered",Hq);var Pq=[["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=u("list-todo",Pq);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"}]],E4=u("list",zq);var Wq=[["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"}]],T4=u("message-square-plus",Wq);var Eq=[["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"}]],w1=u("pencil",Eq);var Tq=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],K2=u("plus",Tq);var yq=[["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"}]],y4=u("strikethrough",yq);var wq=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],F1=u("table-2",wq);var Oq=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],w4=u("text-quote",Oq);var Cq=[["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"}]],w0=u("trash-2",Cq);var jq=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],O4=u("underline",jq);var Lq=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],C4=u("x",Lq);import{jsx as q2,jsxs as mq}from"react/jsx-runtime";function TM({insetX:$,insetY:M,onSelect:J,presence:Z}){if(!Z)return null;return q2("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${$}px`,top:`${M}px`},children:Z.map((X)=>q2(Rq,{onSelect:()=>J(X),presence:X},X.id))})}function Rq({onSelect:$,presence:M}){let J=M.viewport,Z=kq(M),X=J?.status==="above"?U4:q4,D=J!==null&&J.status!=="unresolved",Y=J?.status==="above"||J?.status==="below";return mq("button",{"aria-label":fq(M),className:"documint-presence-indicator","data-status":J?.status??"unresolved",disabled:!D,onClick:D?$:void 0,style:{"--documint-presence-color":M.color??"var(--documint-leaf-accent)"},type:"button",children:[q2("span",{className:"documint-presence-indicator-avatar",children:M.avatarUrl?q2("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:M.avatarUrl}):Z}),Y?q2("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:q2(X,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3})}):null]})}function kq($){return yM($).charAt(0).toLocaleUpperCase()}function fq($){let M=yM($),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 yM($){return($.fullName??$.username).trim()||"Presence"}var o=`
|
|
26
|
+
`,_1="<ins>",j4="</ins>",U2=">",L4="```",t5=":::",j3=/^:::([A-Za-z][-\w]*)(.*)$/,e5="documint-comments";var $8="`",f3="\\",R3="![",k3="[",jM="(",wM=")",LM=" ",RM=":",Sq=/[A-Za-z]/,uq=/[-A-Za-z0-9_]/,vq=/^\{width=([1-9]\d*)\}/,hq=/\\([\\`*_[\]{}()#+\-.!~|])/g,kM=/\\(.)/g,gq=[{delimiter:"**",mark:"bold"},{delimiter:"~~",mark:"strikethrough"},{delimiter:"*",mark:"italic"}];function N2($,M=[]){return m3($,0,$.length,M)}function m3($,M,J,Z){let X=[],D=M,Y=M;while(D<J){let Q=Iq($,D,J,Z);if(Q){OM(X,$.slice(Y,D),Z),X.push(...Q.nodes),D=Q.end,Y=D;continue}if($[D]===f3){D+=Math.min(2,J-D);continue}D+=1}return OM(X,$.slice(Y,J),Z),pq(X)}function Iq($,M,J,Z){switch($[M]){case RM:return tq($,M,J);case"<":return oq($,M,J,Z);case $8:return dq($,M,J);case"!":return aq($,M,J);case k3:return iq($,M,J,Z);case"*":case"~":return rq($,M,J,Z);default:return null}}function OM($,M,J){if(M.length===0)return;$.push(H0({marks:J,text:vM(M)}))}function S3($,M){return n4({originalType:$,source:M})}function pq($){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]=H0({marks:Z.marks,text:Z.text+J.text});continue}M.push(J)}return M}function lq($,M,J){for(let Z of gq){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 rq($,M,J,Z){let X=lq($,M,J);if(!X)return null;return{end:X.end,nodes:m3($,X.contentStart,X.contentEnd,[...Z,X.mark])}}function cq($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function xq($,M,J){if($[M]!==$8)return null;let Z=1;while(M+Z<J&&$[M+Z]===$8)Z+=1;let X=$8.repeat(Z),D=$.indexOf(X,M+Z);if(D<0||D>=J)return null;return{end:D+Z,value:$.slice(M+Z,D)}}function dq($,M,J){let Z=xq($,M,J);if(!Z)return null;return{end:Z.end,nodes:[S1({code:Z.value})]}}function aq($,M,J){if(!$.startsWith(R3,M))return null;let Z=mM($,M+1,J);if(Z<0||$[Z+1]!==jM)return null;let X=fM($,Z+1,J);if(!X)return null;let D=sq($,X.end,J);return{end:D?.end??X.end,nodes:[o4({alt:vM($.slice(M+R3.length,Z)),title:X.title,url:X.url,width:D?.width??null})]}}function iq($,M,J,Z){if($[M]!==k3||$.startsWith(R3,M-1))return null;let X=mM($,M,J);if(X<0||$[X+1]!==jM)return null;let D=fM($,X+1,J);if(!D)return null;return{end:D.end,nodes:[u1({children:N2($.slice(M+k3.length,X),Z),title:D.title,url:D.url})]}}function fM($,M,J){let Z=L3($,M+1,J),X=Z;while(X<J&&$[X]!==wM&&$[X]!==LM){if($[X]===f3){X+=2;continue}X+=1}if(X===Z)return null;let D=eq($.slice(Z,X));Z=L3($,X,J);let Y=null;if(Z<J&&$[Z]==='"'){let Q=uM($,'"',Z+1,J);if(Q<0)return null;Y=$.slice(Z+1,Q).replace(kM,"$1"),Z=L3($,Q+1,J)}if($[Z]!==wM)return null;return{end:Z+1,title:Y,url:D}}function sq($,M,J){let Z=vq.exec($.slice(M,J));if(!Z)return null;return{end:M+Z[0].length,width:Number(Z[1])}}function oq($,M,J,Z){if(!$.startsWith(_1,M))return nq($,M,J);let X=$.indexOf(j4,M+_1.length);if(X<0||X>=J)return{end:M+_1.length,nodes:[S3("html",_1)]};return{end:X+j4.length,nodes:m3($,M+_1.length,X,[...Z,"underline"])}}function nq($,M,J){if($[M]!=="<")return null;let Z=$.indexOf(">",M+1);if(Z<0||Z>=J)return null;return{end:Z+1,nodes:[S3("html",$.slice(M,Z+1))]}}function tq($,M,J){if($[M]!==RM||!Sq.test($[M+1]??""))return null;let Z=M+2;while(Z<J&&uq.test($[Z]??""))Z+=1;let X=CM($,Z,J,"[","]"),Y=CM($,X?.end??Z,J,"{","}")?.end??X?.end??Z;return{end:Y,nodes:[S3("textDirective",$.slice(M,Y))]}}function CM($,M,J,Z,X){if($[M]!==Z)return null;let D=SM($,X,M+1,J);if(D<0)return null;return{end:D+1}}function mM($,M,J){return SM($,"]",M+1,J)}function SM($,M,J,Z){return uM($,M,J,Z)}function uM($,M,J,Z){for(let X=J;X<Z;X+=1){if($[X]===f3){X+=1;continue}if($[X]===M)return X}return-1}function L3($,M,J){while(M<J&&$[M]===LM)M+=1;return M}function vM($){return $.replace(hq,"$1")}function eq($){return $.replace(kM,"$1")}var $U=/^:?-+:?$/;function IM($,M){let J=gM($),Z=$.lines[$.index+1]??"",X=u3(J,M),D=u3(Z,M);if(!hM(X)||!v3(D))return null;let Y=[M8(X)],Q=MU(D);$.index+=2;while($.index<$.lines.length){let K=gM($),q=u3(K,M);if(JU(K)||!hM(q))break;Y.push(M8(q)),$.index+=1}return z1({align:Q,rows:Y.map((K)=>v1({cells:K.map((q)=>J1({children:N2(q)}))}))})}function hM($){let M=$.trim();return/\|/.test($)&&M.startsWith("|")&&M.endsWith("|")}function v3($){let M=M8($);return M.length>0&&M.every((J)=>$U.test(J.trim()))}function MU($){return M8($).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 M8($){return $.trim().slice(1,-1).split("|").map((J)=>J.trim())}function gM($){return $.lines[$.index]??""}function JU($){return $.trim()===""}function u3($,M){return $.slice(M)}var ZU=3,XU=/^\d+\.$/,DU=/^\[( |x|X)\](?:\s|$)/,pM=/^```([^\s`]*)?(?:\s+(.*))?$/,lM=/^::(?!:)[A-Za-z][-\w]*/,rM=/^(#{1,6})\s+(.*)$/,YU=/\s+#+\s*$/u,QU=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,KU=/^(\*\s*){3,}$/,qU=/^(-\s*){3,}$/,UU=/^(_\s*){3,}$/;function Z8($,M,J){let Z=[];while($.index<$.lines.length){let X=B0($);if($.index===$.lines.length-1&&X==="")break;if(R4(X)){$.index+=1;continue}if(A2(X)>M+ZU)break;let Y=NU($,M,J);if(!Y)break;Z.push(Y)}return Z}function NU($,M,J){return AU($,M,J)??VU($,M)??GU($,M)??FU($,M)??_U($,M)??bU($,M)??IM($,M)??HU($,M,J)??PU($,M)??zU($,M)}function AU($,M,J){let Z=B0($);if(!EU(Z,M))return null;let X=[];while($.index<$.lines.length){let D=B0($),Y=A2(D);if(R4(D)){X.push(""),$.index+=1;continue}if(Y<M)break;let Q=R0(D,M);if(!Q.startsWith(U2))break;let K=Q.slice(1);if(K.startsWith(" "))K=K.slice(1);X.push(K),$.index+=1}return P0({children:Z8({index:0,lines:X},0,J)})}function VU($,M){let J=B0($),Z=R0(J,M),X=pM.exec(Z);if(!X)return null;$.index+=1;let D=[];while($.index<$.lines.length){let Y=B0($),Q=R0(Y,M);if(Q.trim()===L4){$.index+=1;break}D.push(Q),$.index+=1}return P8({language:X[1]?X[1]:null,meta:X[2]?X[2]:null,source:D.join(o)})}function GU($,M){let J=B0($),Z=R0(J,M),X=j3.exec(Z);if(!X)return null;let D=X[1],Y=[];$.index+=1;while($.index<$.lines.length){let Q=B0($),K=R0(Q,M);if($.index+=1,K.trim()===t5)break;Y.push(K)}return C$({attributes:BU(X[2]??""),body:Y.join(o),name:D})}function BU($){let M=$.trim();if(M.startsWith("{")&&M.endsWith("}"))return M.slice(1,-1);return M}function FU($,M){let J=B0($),Z=R0(J,M);if(!lM.test(Z))return null;return $.index+=1,e4({originalType:"leafDirective",source:Z})}function _U($,M){let J=B0($),Z=rM.exec(R0(J,M));if(!Z)return null;return $.index+=1,s4({children:N2(Z[2].replace(YU,"")),depth:Z[1].length})}function bU($,M){let J=R0(B0($),M).trim();if(!cM(J))return null;return $.index+=1,t4()}function HU($,M,J){let Z=J8(B0($),M);if(!Z)return null;let X=[],D=!1;while($.index<$.lines.length){let Y=B0($),Q=J8(Y,M);if(!Q||Q.ordered!==Z.ordered)break;$.index+=1;let K=[Q.content],q=!1;while($.index<$.lines.length){let U=B0($),N=A2(U);if(R4(U)){let A=wU($.lines,$.index+1);if(A<0||A2($.lines[A]??"")<=M)break;q=!0,K.push(""),$.index+=1;continue}if(N<Q.contentIndent)break;if(N===M&&J8(U,M))break;K.push(TU(U,Q.contentIndent)),$.index+=1}D||=q,X.push(d0({checked:Q.checked,children:WU(K,J),spread:q}))}return P1({items:X,ordered:Z.ordered,spread:D,start:Z.ordered&&J.preserveOrderedListStart?Z.start??1:null})}function PU($,M){let J=R0(B0($),M).trim();if(!xM(J))return null;return $.index+=1,e4({originalType:"html",source:J})}function zU($,M){let J=[];while($.index<$.lines.length){let Z=B0($),X=A2(Z);if(R4(Z))break;if(X<M)break;let D=R0(Z,M);if(J.length>0&&yU(Z,D,M))break;J.push(D),$.index+=1}return H2({children:N2(J.join(o))})}function WU($,M){let J=Z8({index:0,lines:$},0,M);if(J.length>0)return J;return[H2({children:[]})]}function J8($,M){let J=QU.exec($);if(!J||J[1].length!==M)return null;let Z=J[2],X=XU.test(Z),D=X?Number(Z.slice(0,-1)):null,Y=J[3]??"",Q=null;if(DU.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:D}}function EU($,M){return R0($,M).startsWith(U2)}function R0($,M){return $.slice(M)}function TU($,M){let J=A2($);if(J>=M)return $.slice(M);return $.trim()===""?"":$.slice(Math.min(J,M))}function cM($){return KU.test($)||qU.test($)||UU.test($)}function xM($){return $.startsWith("<")&&$.endsWith(">")}function A2($){let M=0;while(M<$.length&&$[M]===" ")M+=1;return M}function yU($,M,J){return M.startsWith(U2)||pM.test(M)||j3.test(M)||lM.test(M)||rM.test(M)||cM(M.trim())||v3(M)||J8($,J)!==null||xM(M.trim())}function B0($){return $.lines[$.index]??""}function R4($){return $.trim()===""}function wU($,M){for(let J=M;J<$.length;J+=1)if(!R4($[J]??""))return J;return-1}function aM($){let M=$.at(-1),J=M&&dM(M)?M:null;return{blocks:$.filter((X)=>!dM(X)),comments:J?OU(J.body):[]}}function OU($){let M;try{M=JSON.parse($)}catch{return[]}if(!Array.isArray(M))return[];return M.flatMap((J)=>{let Z=k8(J);return Z?[Z]:[]})}function dM($){return $.type==="directive"&&$.name===e5}var iM="---";function h3($,M={}){let Z={index:0,lines:$.replace(/\r\n/g,o).split(o)},X=CU(Z),D=Z8(Z,0,M),{comments:Y,blocks:Q}=aM(D);return g1(Q,Y,X)}function CU($){if($.lines[0]!==iM)return;for(let M=1;M<$.lines.length;M+=1)if($.lines[M]===iM){let J=$.lines.slice(0,M+1).join(o);return $.index=M+1,J}return}var k4=`
|
|
27
|
+
|
|
28
|
+
`,jU="-",LU=".",RU="***",kU=" ",g3=3,fU=5,mU=4,sM=2,SU=2,uU=1,vU=/([\\`*_[\]])/g,hU=/([\\)&])/g,gU=/(["\\])/g;function X8($,M={}){if($.blocks.length===0&&$.comments.length===0&&$.frontMatter===void 0)return"";let J=$.blocks.map((X)=>D8(X,0,M));if($.comments.length>0)J.push(ZN($.comments));if($.frontMatter!==void 0)J.unshift($.frontMatter);let Z=J.join(k4);return Z.endsWith(o)?Z:`${Z}${o}`}function D8($,M,J){let Z=b1(M);switch($.type){case"blockquote":return IU($,M,J);case"code":return pU($,M);case"directive":return XN($,M);case"heading":return nM($,M);case"list":return lU($,M,J);case"listItem":return tM($,M,!1,1,J);case"paragraph":return`${Z}${I3(f4($.children))}`;case"table":return cU($,M,J);case"thematicBreak":return`${Z}${RU}`;case"unsupported":return M===0?$.source:MJ($.source,M)}}function IU($,M,J){let Z=$.children.map((D)=>D8(D,0,J)).join(k4),X=b1(M);return Z.split(o).map((D)=>`${X}${U2}${D.length>0?` ${D}`:""}`).join(o)}function pU($,M){let J=[$.language??"",$.meta??""].filter(Boolean).join(" ").trim(),Z=b1(M),X=`${Z}${L4}${J?J:""}`,D=$.source.length>0?$.source.split(o).map((Y)=>`${Z}${Y}`).join(o):Z;return`${X}${o}${D}${o}${Z}${L4}`}function nM($,M){let J=I3(f4($.children)),Z=`${b1(M)}${"#".repeat($.depth)}`;return J.length>0?`${Z} ${J}`:Z}function lU($,M,J){let Z=$.start??1;return $.items.map((X)=>tM(X,M,$.ordered,Z,J)).join($.spread?k4:o)}function tM($,M,J,Z,X){let D=J?`${Z}${LU}`:jU,Y=$.checked===null?"":`[${$.checked?"x":" "}] `,Q=`${b1(M)}${D} ${Y}`,K=M+D.length+1,q=$.children;if(q.length===0)return Y.length>0?Q:Q.trimEnd();let[U,...N]=q,A=rU(U,Q,Y.length>0,X),V=N.map((B)=>D8(B,K,X)).join($.spread?k4:o);if(!V)return A;return`${A}${$.spread?k4:o}${V}`}function rU($,M,J,Z){switch($.type){case"paragraph":{let X=I3(f4($.children));if(X.length===0)return J?M:M.trimEnd();return`${M}${X}`}case"heading":return`${M}${nM($,0)}`;case"directive":case"unsupported":{let X=$.type==="directive"?p3($):$.source,[D,...Y]=X.split(o);return[M+D,...Y.map((Q)=>`${b1(M.length)}${Q}`)].join(o)}default:{let X=M.length;return`${M.trimEnd()}${o}${D8($,X,Z)}`}}}function cU($,M,J){let Z=$.rows.map((U)=>U.cells.map((N)=>f4(N.children))),X=Math.max(1,...Z.map((U)=>U.length)),D=Z[0]??[],Y=Array.from({length:X},(U,N)=>Math.max(g3,iU($.align[N]),...J.padTableColumns?Z.map((A)=>A[N]?.length??0):[D[N]?.length??0])),Q=xU(Y,$.align,M),K=oM(D,Y,$.align,M,J),q=Z.slice(1).map((U)=>oM(U,Y,$.align,M,J));return[K??dU(Y,M),Q,...q].join(o)}function oM($,M,J,Z,X){let D=M.map((Y,Q)=>{let K=$[Q]??"";if(!X.padTableColumns)return K;return sU(K,Y,J[Q])});return`${" ".repeat(Z)}| ${D.join(" | ")} |`}function xU($,M,J){let Z=$.map((X,D)=>aU(M[D],X));return`${" ".repeat(J)}| ${Z.join(" | ")} |`}function dU($,M){return`${b1(M)}| ${$.map((J)=>"".padEnd(J," ")).join(" | ")} |`}function aU($,M){let J=Math.max(g3,M-($==="center"?SU:$?uU:0));switch($){case"center":return`:${"-".repeat(Math.max(1,J))}:`;case"left":return`:${"-".repeat(Math.max(sM,J))}`;case"right":return`${"-".repeat(Math.max(sM,J))}:`;default:return"-".repeat(J)}}function iU($){return $==="center"?fU:$?mU:g3}function sU($,M,J){if(J==="right")return $.padStart(M," ");return $.padEnd(M," ")}function f4($){return nU($).map((M)=>oU(M)).join("")}function I3($){return $.replace(/^ +/gm,(M)=>kU.repeat(M.length))}function oU($){switch($.type){case"break":return o;case"image":return DN($);case"inlineCode":return $N($.code);case"link":return YN($);case"text":return eU(eM($.text),$.marks);case"unsupported":return $.source}}function nU($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&tU(Z.marks,J.marks)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function tU($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function eU($,M){return M.reduce((J,Z)=>{switch(Z){case"bold":return`**${J}**`;case"italic":return`*${J}*`;case"strikethrough":return`~~${J}~~`;case"underline":return`${_1}${J}${j4}`}},$)}function $N($){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),D=$.startsWith("`")||$.endsWith("`")?` ${$} `:$;return`${X}${D}${X}`}function eM($){return $.replace(vU,"\\$1")}function MN($){return $.replace(hU,"\\$1")}function JN($){return $?` "${$.replace(gU,"\\$1")}"`:""}function ZN($){return p3({attributes:"",body:JSON.stringify($,null,2),name:e5})}function XN($,M){let J=p3($);return M===0?J:MJ(J,M)}function p3($){let M=$.attributes?`{${$.attributes}}`:"";return`:::${$.name}${M}${o}${$.body}${o}${t5}`}function DN($){let M=eM($.alt??""),J=$J($.url,$.title),Z=$.width?`{width=${$.width}}`:"";return`![${M}]${J}${Z}`}function YN($){return`[${f4($.children)}]${$J($.url,$.title)}`}function $J($,M){return`(${MN($)}${JN(M)})`}function b1($){return" ".repeat($)}function MJ($,M){let J=b1(M);return $.split(o).map((Z)=>`${J}${Z}`).join(o)}import{createContext as QN,useContext as KN}from"react";import{createPortal as qN}from"react-dom";import{jsx as XJ}from"react/jsx-runtime";var JJ=QN(void 0);function ZJ({children:$,themeStyles:M}){return XJ(JJ.Provider,{value:M,children:$})}function Y8({children:$}){let M=KN(JJ);if(typeof document>"u")return null;return qN(XJ("div",{className:"documint-overlay",style:{display:"contents",...M},children:$}),document.body)}import{useEffect as Q8,useRef as bJ,useState as O1}from"react";import{forwardRef as NN,useCallback as V2,useEffect as AN,useImperativeHandle as VN,useLayoutEffect as GN,useMemo as BN,useRef as QJ,useState as l3}from"react";var UN=["box-sizing","width","height","overflow-x","overflow-y","border-top-width","border-right-width","border-bottom-width","border-left-width","border-style","padding-top","padding-right","padding-bottom","padding-left","font-style","font-variant","font-weight","font-stretch","font-size","font-size-adjust","line-height","font-family","text-align","text-transform","text-indent","text-decoration","letter-spacing","word-spacing","tab-size"];function DJ($,M,{topGap:J=8}={}){if(!$.isConnected)return null;let Z=getComputedStyle($),X=document.createElement("div");for(let q of UN)X.style.setProperty(q,Z.getPropertyValue(q));Object.assign(X.style,{position:"absolute",top:"0",left:"0",visibility:"hidden",whiteSpace:"pre-wrap",wordWrap:"break-word",width:`${$.clientWidth}px`}),X.textContent=$.value.slice(0,M);let D=document.createElement("span");D.textContent=$.value.slice(M)||".",X.appendChild(D),document.body.appendChild(X);let Y=$.getBoundingClientRect(),Q=parseFloat(Z.lineHeight)||D.offsetHeight,K={left:Y.left+D.offsetLeft+parseFloat(Z.borderLeftWidth)-$.scrollLeft,top:Y.top+D.offsetTop+parseFloat(Z.borderTopWidth)+Q+J-$.scrollTop};return document.body.removeChild(X),K}import{jsx as k0,jsxs as KJ,Fragment as TN}from"react/jsx-runtime";var FN=240,_N="documint-leaf-menu-item documint-completion-item",m4=NN(function({actions:M,completionSources:J,onChange:Z,placeholder:X,readOnly:D=!1,rows:Y=3,value:Q},K){let q=QJ(null);VN(K,()=>q.current,[]);let U=BN(()=>zN(J),[J]),[N,A]=l3(null),[V,B]=l3(0),[G,b]=l3(null),P=V2((E,_)=>{if(!U.length){A(null);return}let j=WN(E,_,U);if(!j){A(null);return}A(j),B(0)},[U]),y=V2((E)=>{let _=E.currentTarget.value,j=E.currentTarget.selectionEnd??_.length;Z(_),P(_,j)},[Z,P]),z=V2((E)=>{let _=E.currentTarget;P(_.value,_.selectionEnd??_.value.length)},[P]),L=V2(()=>{A(null)},[]),R=V2((E)=>{if(!q.current||!N)return;let j=`${N.trigger}${E.label} `,C=Q.slice(0,N.triggerStart),W=Q.slice(N.caret),F=C+j+W,H=N.triggerStart+j.length;Z(F),A(null),requestAnimationFrame(()=>{let v=q.current;if(!v)return;v.focus(),v.setSelectionRange(H,H)})},[N,Z,Q]),m=V2((E)=>{if(N&&N.matches.length>0){if(E.key==="ArrowDown"){E.preventDefault(),E.stopPropagation(),B((_)=>(_+1)%N.matches.length);return}if(E.key==="ArrowUp"){E.preventDefault(),E.stopPropagation(),B((_)=>(_-1+N.matches.length)%N.matches.length);return}if(E.key==="Enter"||E.key==="Tab"){E.preventDefault(),E.stopPropagation();let _=N.matches[V];if(_)R(_);return}if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),A(null);return}}if(E.key==="Escape"&&M.kind==="edit")E.preventDefault(),M.onCancel()},[M,N,V,R]);return GN(()=>{if(!N){b(null);return}let E=()=>{let _=q.current;if(!_)return;b(DJ(_,N.triggerStart))};return E(),window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[N]),KJ("div",{className:"documint-leaf-input-field",children:[k0("textarea",{className:"documint-leaf-input",onBlur:L,onChange:y,onKeyDown:m,onSelect:z,placeholder:X,readOnly:D,ref:q,rows:Y,value:Q}),bN(M),N&&G&&N.matches.length>0?k0(Y8,{children:k0(HN,{activeIndex:V,left:G.left,matches:N.matches,onHover:B,onSelect:R,top:G.top})}):null]})});function bN($){if($.kind==="edit")return KJ(TN,{children:[k0(r3,{className:"documint-leaf-input-cancel",icon:C4,label:"Cancel editing",onClick:$.onCancel}),k0(r3,{className:"documint-leaf-input-save",disabled:$.saveDisabled??!1,icon:y1,label:"Save",onClick:$.onSave})]});return k0(r3,{className:"documint-leaf-input-submit",disabled:$.submitDisabled??!1,icon:B1,iconSize:15,label:$.submitLabel,onClick:$.onSubmit})}function r3({className:$,disabled:M=!1,icon:J,iconSize:Z=14,label:X,onClick:D}){return k0("button",{"aria-label":X,className:`documint-leaf-action ${$}`,disabled:M,onClick:D,title:X,type:"button",children:k0(J,{size:Z,strokeWidth:2.2})})}function HN({activeIndex:$,left:M,matches:J,onHover:Z,onSelect:X,top:D}){let Y=QJ(null);return AN(()=>{let Q=Y.current;if(!Q)return;let K=Q.children[$];if(K instanceof HTMLElement)K.scrollIntoView({block:"nearest"})},[$]),k0("div",{className:"documint-leaf-menu documint-completion-popover",ref:Y,role:"listbox",style:{position:"fixed",left:M,top:D,maxHeight:FN,overflowY:"auto"},children:J.map((Q,K)=>{let q=K===$;return k0("button",{"aria-selected":q,className:`${_N}${q?" is-active":""}`,onPointerDown:PN,onPointerEnter:()=>Z(K),onClick:()=>X(Q),role:"option",type:"button",children:k0("span",{children:Q.label})},Q.label)})})}function PN($){$.preventDefault()}function zN($){if(!$?.length)return[];return $.map((M)=>({trigger:M.trigger,items:[...M.items].sort((J,Z)=>J.label.localeCompare(Z.label,void 0,{sensitivity:"base"}))}))}function WN($,M,J){for(let Z=M-1;Z>=0;Z-=1){let X=$[Z];if(YJ(X))return null;let D=J.find((Q)=>Q.trigger===X);if(!D)continue;if(Z>0&&!YJ($[Z-1]))return null;let Y=$.slice(Z+1,M);return{trigger:D.trigger,query:Y,triggerStart:Z,caret:M,matches:EN(D.items,Y)}}return null}function YJ($){return $===void 0||$===" "||$===`
|
|
29
|
+
`||$==="\t"}function EN($,M){if(!M)return $;let J=M.toLowerCase();return $.filter((Z)=>Z.label.toLowerCase().includes(J))}import{Fragment as wN}from"react";function c3($,M){if(!M?.length||!M.some((Y)=>$.includes(Y.trigger)))return[{kind:"text",text:$}];let J=new Map;for(let Y of M){let Q=[...Y.items].sort((K,q)=>q.label.length-K.label.length);J.set(Y.trigger,Q)}let Z=[],X=0,D=0;while(X<$.length){let Y=$[X],Q=J.get(Y);if(Q!==void 0&&(X===0||yN($[X-1]))){let q=Q.find((U)=>$.startsWith(U.label,X+1));if(q){if(X>D)Z.push({kind:"text",text:$.slice(D,X)});Z.push({kind:"token",trigger:Y,label:q.label,id:q.id}),X+=1+q.label.length,D=X;continue}}X+=1}if(D<$.length)Z.push({kind:"text",text:$.slice(D)});return Z}function x3($,M){let J=[],Z=new Set;for(let X of c3($,M)){if(X.kind!=="token"||X.trigger!=="@"||!X.id)continue;if(Z.has(X.id))continue;Z.add(X.id),J.push(X.id)}return J}function yN($){return $===void 0||$===" "||$===`
|
|
30
|
+
`||$==="\t"}import{jsx as qJ,jsxs as CN}from"react/jsx-runtime";function d3({value:$,completionSources:M,onEdit:J}){return qJ("p",{onDoubleClick:J,children:ON($,M)})}function ON($,M){let J=c3($,M);if(J.length===1&&J[0].kind==="text")return $;return J.map((Z,X)=>Z.kind==="token"?CN("span",{className:"documint-mention",children:[Z.trigger,Z.label]},X):qJ(wN,{children:Z.text},X))}import{Children as UJ,isValidElement as NJ,useEffect as jN,useRef as LN,useState as RN}from"react";import{jsx as A0,jsxs as s3}from"react/jsx-runtime";var a3=($)=>{$.preventDefault()},i3=($)=>$.isPrimary&&$.button===0;function kN({children:$}){return A0("div",{className:"documint-leaf-toolbar",children:UJ.map($,fN)})}function fN($){if(!NJ($))return null;if($.type===VJ){let M=$.props;return A0(AJ,{children:A0(mN,{...M})})}if($.type===GJ){let{className:M}=$.props;return A0("div",{className:S4("documint-leaf-toolbar-divider",M)})}if($.type===BJ){let M=$.props;return A0(SN,{...M})}return null}function mN({active:$=!1,className:M,disabled:J=!1,icon:Z,label:X,onClick:D}){return A0("button",{"aria-label":X,className:S4("documint-leaf-toolbar-button",$?"active":null,M),disabled:J,onPointerDown:(Y)=>{if(a3(Y),!J&&i3(Y))D()},title:X,type:"button",children:A0(Z,{size:15,strokeWidth:2.2})})}function SN({children:$,className:M,icon:J,label:Z,onSelect:X}){let D=LN(null),[Y,Q]=RN(!1);return jN(()=>{if(!Y)return;let K=(q)=>{if(D.current&&q.target instanceof Node&&!D.current.contains(q.target))Q(!1)};return window.addEventListener("pointerdown",K),()=>{window.removeEventListener("pointerdown",K)}},[Y]),A0(AJ,{children:s3("div",{className:"documint-leaf-toolbar-menu-shell",ref:D,children:[A0(uN,{className:M,icon:J,isOpen:Y,label:Z,onClick:()=>Q((K)=>!K)}),Y?A0("div",{className:"documint-leaf-menu",role:"menu",children:UJ.map($,(K)=>vN(K,(q)=>{Q(!1),X(q)}))}):null]})})}function uN({className:$,icon:M,isOpen:J,label:Z,onClick:X}){return s3("button",{"aria-expanded":J,"aria-haspopup":"menu","aria-label":Z,className:S4("documint-leaf-toolbar-button",J?"active":null,$),onPointerDown:(D)=>{if(a3(D),i3(D))X()},title:Z,type:"button",children:[A0(M,{size:15,strokeWidth:2.2}),A0(A4,{className:S4("documint-leaf-toolbar-menu-chevron",J?"is-open":null),size:13,strokeWidth:2.2})]})}function vN($,M){if(!NJ($))return null;if($.type===_J){let{className:Y}=$.props;return A0("div",{className:S4("documint-leaf-menu-divider",Y),role:"separator"})}if($.type!==FJ)return null;let{disabled:J=!1,icon:Z,text:X,value:D}=$.props;return s3("button",{className:"documint-leaf-menu-item",disabled:J,onPointerDown:(Y)=>{if(a3(Y),!J&&i3(Y))M(D)},role:"menuitem",type:"button",children:[A0(Z,{size:15,strokeWidth:2.2}),A0("span",{children:X})]})}function S4(...$){return $.filter(Boolean).join(" ")}function AJ({children:$}){return A0("div",{className:"documint-leaf-toolbar-group",children:$})}function VJ($){return null}function GJ($){return null}function BJ($){return null}function FJ($){return null}function _J($){return null}var c=Object.assign(kN,{Button:VJ,Divider:GJ,Menu:BJ,MenuDivider:_J,MenuItem:FJ});import{jsx as t,jsxs as r0,Fragment as pN}from"react/jsx-runtime";var hN=!1,gN=220,C1=()=>{};function o3($){let M=$.mode==="create",J=$.mode==="create"?$:null,Z=$.mode==="thread"?$:null,X=$.canEdit,D=$.link,Y=Z?.thread??null,Q=Y?.comments??[],K=Q[0]??null,q=Y?Z1(Y):!1,U=Z?.animateInitialComment??!1,[N,A]=O1(null),[V,B]=O1(""),[G,b]=O1(""),[P,y]=O1(""),[z,L]=O1(!U),[R,m]=O1(hN),[E,_]=O1(!1),j=bJ(null),C=bJ(null),W=$.mentionSources,F=Y?g8(Y):null,H=F?HJ(F):"",v=X&&!q,h=v&&V.trim().length>0,l=v&&G.trim().length>0,p=X&&P.trim().length>0,O=M||E,T=!M||R,k=!M&&Boolean(Y),f=Boolean(K),d=M?R:!0,I=Z?.onDeleteComment??C1,U0=Z?.onDeleteThread??C1,z0=Z?.onToggleResolved??C1,_0=J?.activeMarks??[],R1=J?.onToggleBold??C1,F8=J?.onToggleItalic??C1,p4=J?.onToggleStrikethrough??C1,_8=J?.onToggleUnderline??C1,l4=X?M?"Add a comment":"Reply to this comment":"Comment editing is disabled",r4=M?P:G;Q8(()=>{if(N!==null&&(N<0||N>=Q.length))A(null),B("")},[Q.length,N]),Q8(()=>{if(!f||!U){L(!0);return}L(!1);let a=requestAnimationFrame(()=>{L(!0)});return()=>{cancelAnimationFrame(a)}},[U,K,f]),Q8(()=>{if(!Z||!U){_(!1);return}_(!0);let a=window.setTimeout(()=>{_(!1)},gN);return()=>{window.clearTimeout(a)}},[U,Z]),Q8(()=>{if(!M||!R||!X)return;let a=requestAnimationFrame(()=>{C.current?.focus()});return()=>{cancelAnimationFrame(a)}},[X,M,R]);let O0=()=>{A(null),B("")},W0=(a,_2)=>{if(!k||!v)return;A(a),B(_2)},k1=(a)=>{if(!Z)return;Z.onEditComment(a,V),O0()},b8=()=>{if(!Z)return;Z.onReply(G),b("")},c4=()=>{if(!J||!p)return;J.onCreateThread(P),y("")},f1=O?`documint-comment-leaf documint-comment-leaf-create${d?" is-expanded":""}`:"documint-comment-leaf",x4=k||f||T?t(IN,{canCreate:p,canEdit:X,canMutateThread:v,canReply:l,canSaveEditedComment:h,comments:Q,composerRef:C,editDraft:V,editingCommentIndex:N,isComposerVisible:T,isInitialCommentVisible:z,isResolved:q,link:D,mentionSources:W,mode:$.mode,onBeginEditingComment:W0,onCancelEditing:O0,onChangeCreateDraft:y,onChangeEditDraft:B,onChangeReplyDraft:b,onDeleteComment:I,onDeleteThread:U0,onSubmitCreate:c4,onSubmitEditedComment:k1,onSubmitReply:b8,onToggleResolved:z0,rootComment:K,showRootComment:f,showThreadChrome:k,threadAge:H,composerPlaceholder:l4,composerValue:r4}):null;return t("div",{className:f1,ref:j,children:r0("div",{className:O?"documint-comment-leaf-create-shell":void 0,children:[O?r0(c,{children:[t(c.Button,{className:"documint-comment-leaf-create-button",icon:T4,label:"Add comment",onClick:()=>m(!0)}),t(c.Divider,{className:"documint-comment-leaf-create-divider"}),t(c.Button,{active:_0.includes("bold"),className:"documint-comment-leaf-create-mark",icon:N4,label:"Bold",onClick:R1}),t(c.Button,{active:_0.includes("italic"),className:"documint-comment-leaf-create-mark",icon:P4,label:"Italic",onClick:F8}),t(c.Button,{active:_0.includes("underline"),className:"documint-comment-leaf-create-mark",icon:O4,label:"Underline",onClick:_8}),t(c.Button,{active:_0.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:y4,label:"Strikethrough",onClick:p4})]}):null,t("div",{className:O?"documint-comment-leaf-create-content":void 0,children:x4})]})})}function IN({canCreate:$,canEdit:M,canMutateThread:J,canReply:Z,canSaveEditedComment:X,comments:D,composerRef:Y,editDraft:Q,editingCommentIndex:K,isComposerVisible:q,isInitialCommentVisible:U,isResolved:N,link:A,mentionSources:V,mode:B,onBeginEditingComment:G,onCancelEditing:b,onChangeCreateDraft:P,onChangeEditDraft:y,onChangeReplyDraft:z,onDeleteComment:L,onDeleteThread:R,onSubmitCreate:m,onSubmitEditedComment:E,onSubmitReply:_,onToggleResolved:j,rootComment:C,showRootComment:W,showThreadChrome:F,threadAge:H,composerPlaceholder:v,composerValue:h}){return r0(pN,{children:[F?r0("div",{className:"documint-comment-leaf-header",children:[t("span",{className:"documint-comment-leaf-age",children:H}),r0("div",{className:"documint-comment-leaf-actions",children:[t("button",{className:"documint-leaf-action","aria-label":N?"Reopen comment":"Resolve comment",disabled:!M,onClick:j,title:N?"Reopen comment":"Resolve comment",type:"button",children:t(y1,{size:14,strokeWidth:2.2})}),t("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:t(w0,{size:14,strokeWidth:2.2})})]})]}):null,F&&A?r0("div",{className:"documint-comment-leaf-link",children:[A.title?t("div",{className:"documint-link-leaf-title",children:A.title}):null,t("div",{className:"documint-link-leaf-url",children:A.url})]}):null,r0("div",{className:`documint-comment-thread${W?"":" is-empty"}`,children:[t("article",{className:W?`documint-comment-message documint-comment-message-root${U?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:C?t(d3,{completionSources:V,onEdit:()=>G(0,C.body),value:C.body}):null}),D.slice(1).map((l,p)=>{let O=p+1,T=K===O;return r0("article",{className:"documint-comment-message",children:[!T?r0("div",{className:"documint-comment-message-meta",children:[t("span",{children:HJ(l.updatedAt)}),J?r0("div",{className:"documint-comment-leaf-actions",children:[t("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!J,onClick:()=>{G(O,l.body)},title:"Edit comment",type:"button",children:t(w1,{size:14,strokeWidth:2.2})}),t("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!J,onClick:()=>L(O),title:"Delete comment",type:"button",children:t(w0,{size:14,strokeWidth:2.2})})]}):null]}):null,T?t(m4,{actions:{kind:"edit",onCancel:b,onSave:()=>E(O),saveDisabled:!X},completionSources:V,onChange:y,readOnly:!M,rows:3,value:Q}):t(d3,{completionSources:V,onEdit:()=>G(O,l.body),value:l.body})]},`${l.updatedAt}:${O}`)})]}),t("div",{className:`documint-comment-reply${F?"":" is-standalone"}${q?" is-visible":""}`,children:t(m4,{actions:B==="create"?{kind:"compose",onSubmit:m,submitDisabled:!$,submitLabel:"Create comment"}:{kind:"compose",onSubmit:_,submitDisabled:!Z,submitLabel:"Reply"},completionSources:V,onChange:B==="create"?P:z,placeholder:v,readOnly:!M,ref:Y,rows:3,value:h})})]})}function HJ($){let M=new Date($);if(Number.isNaN(M.getTime()))return $;let J=M.getTime()-Date.now(),Z=60000,X=60*Z,D=24*X,Y=7*D,Q=30*D,K=365*D,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)<D)return q.format(Math.round(J/X),"hour");if(Math.abs(J)<Y)return q.format(Math.round(J/D),"day");if(Math.abs(J)<K)return q.format(Math.round(J/Q),"month");return q.format(Math.round(J/K),"year")}import{jsx as c0,jsxs as cN}from"react/jsx-runtime";var lN=[{icon:V4,label:"Heading 1",text:"# "},{icon:G4,label:"Heading 2",text:"## "},{icon:B4,label:"Heading 3",text:"### "},{icon:F4,label:"Heading 4",text:"#### "},{icon:_4,label:"Heading 5",text:"##### "},{icon:b4,label:"Heading 6",text:"###### "}],rN=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function PJ({onInsert:$,onInsertTable:M}){return cN(c,{children:[c0(c.Button,{icon:E4,label:"Insert bulleted list",onClick:()=>$("- ")}),c0(c.Button,{icon:z4,label:"Insert numbered list",onClick:()=>$("1. ")}),c0(c.Button,{icon:W4,label:"Insert task list",onClick:()=>$("- [ ] ")}),c0(c.Divider,{}),c0(c.Menu,{icon:H4,label:"Insert heading",onSelect:$,children:lN.map(({icon:J,label:Z,text:X})=>c0(c.MenuItem,{icon:J,text:Z,value:X},X))}),c0(c.Menu,{icon:F1,label:"Insert table",onSelect:(J)=>M(Number(J)),children:rN.map(({columns:J,text:Z})=>c0(c.MenuItem,{icon:F1,text:Z,value:String(J)},J))}),c0(c.Divider,{}),c0(c.Button,{icon:w4,label:"Insert blockquote",onClick:()=>$("> ")})]})}import{jsx as n3,jsxs as xN}from"react/jsx-runtime";function zJ({anchor:$,children:M,status:J="default"}){let Z=!$.isSelection;return n3(Y8,{children:xN("div",{className:"documint-leaf-anchor","data-selection":$.isSelection?"true":"false",onPointerEnter:$.onPointerEnter,onPointerLeave:$.onPointerLeave,style:{left:`${$.left}px`,top:`${$.top}px`},children:[Z?n3("div",{className:"documint-leaf-bridge"}):null,n3("div",{className:"documint-leaf-shell","data-status":J,children:M})]})})}import{useEffect as WJ,useRef as dN,useState as EJ}from"react";import{jsx as t0,jsxs as t3}from"react/jsx-runtime";function TJ({canEdit:$,onDelete:M,onSave:J,title:Z,url:X}){let[D,Y]=EJ(X),[Q,K]=EJ(!1),q=dN(null),U=aN(),N=D.trim(),A=$&&N.length>0,V=$&&!Q,B=`${U}click to open`,G=`documint-link-leaf-row${Q?" is-editing":""}`;return WJ(()=>{if(Q)return;Y(X)},[Q,X]),WJ(()=>{if(!Q)return;q.current?.focus()},[Q]),t3("div",{className:"documint-link-leaf",children:[Z?t0("div",{className:"documint-link-leaf-title",children:Z}):null,t3("div",{className:G,children:[Q?t0(m4,{actions:{kind:"edit",onCancel:()=>{Y(X),K(!1)},onSave:()=>{J(N),K(!1)},saveDisabled:!A},onChange:Y,readOnly:!$,ref:q,rows:3,value:D}):t0("div",{className:"documint-link-leaf-url",children:X}),V?t3("div",{className:"documint-link-leaf-actions",children:[t0("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!$)return;Y(X),K(!0)},title:"Edit link",type:"button",children:t0(w1,{size:14,strokeWidth:2.2})}),t0("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:M,title:"Remove link",type:"button",children:t0(w0,{size:14,strokeWidth:2.2})})]}):null]}),t0("div",{className:"documint-link-leaf-divider"}),t0("div",{className:"documint-link-leaf-hint",children:B})]})}function aN(){if(typeof navigator>"u")return"Ctrl+";let $=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test($)?"CMD+":"CTRL+"}import{jsx as e0,jsxs as M$}from"react/jsx-runtime";var iN=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],sN=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],e3={text:"Delete column",value:"delete"},$$={text:"Delete row",value:"delete"},yJ={text:"Delete table",value:"delete"};function wJ({canDeleteColumn:$,canDeleteRow:M,onDeleteColumn:J,onDeleteRow:Z,onDeleteTable:X,onInsertColumn:D,onInsertRow:Y}){return M$(c,{children:[M$(c.Menu,{icon:V1,label:"Column actions",onSelect:(Q)=>{if(Q===e3.value){J();return}D(Q)},children:[iN.map(({text:Q,value:K})=>e0(c.MenuItem,{icon:K2,text:Q,value:K},K)),e0(c.MenuDivider,{}),e0(c.MenuItem,{disabled:!$,icon:w0,text:e3.text,value:e3.value})]}),M$(c.Menu,{icon:G1,label:"Row actions",onSelect:(Q)=>{if(Q===$$.value){Z();return}Y(Q)},children:[sN.map(({text:Q,value:K})=>e0(c.MenuItem,{icon:K2,text:Q,value:K},K)),e0(c.MenuDivider,{}),e0(c.MenuItem,{disabled:!M,icon:w0,text:$$.text,value:$$.value})]}),e0(c.Divider,{}),e0(c.Menu,{icon:F1,label:"Table actions",onSelect:()=>X(),children:e0(c.MenuItem,{icon:w0,text:yJ.text,value:yJ.value})})]})}import{useEffect as OJ,useEffectEvent as CJ,useLayoutEffect as oN,useMemo as nN,useRef as J$,useState as tN}from"react";function K8($,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 eN=600,$A=530,G2=24;function LJ({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,editorState:Z,editorViewportState:X,getScrollTop:D,layoutWidth:Y,onVisibilityChange:Q,scrollContentHeight:K,scrollTo:q,viewportHeight:U}){let N=nN(()=>n(Z),[Z]),[A,V]=tN(null),B=N.start.regionId===N.end.regionId&&N.start.offset===N.end.offset,G=J$(!0),b=J$(0),P=J$(null),y=CJ(()=>{Q()}),z=CJ(()=>{b.current=typeof performance<"u"?performance.now():Date.now(),G.current=!0,y()});return oN(()=>{let L=MA({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:N,state:Z,viewport:X.get()});V((R)=>DA(R,L)?R:L)},[$,M,J,Z,X]),OJ(()=>{let L=Z.selection.focus,R={layoutWidth:Y,offset:L.offset,regionId:L.regionId,scrollContentHeight:K,viewportHeight:U};if(YA(P.current,R))return;let m=B6(Z,X.get(),L);if(!m)return;let E=D(),_=E+G2,j=E+U-G2;if(m.top<_){let C=q(Math.max(0,m.top-G2));if(jJ(m,C,U,G2))P.current=R;return}if(m.top+m.height>j){let C=q(Math.max(0,m.top+m.height-U+G2));if(jJ(m,C,U,G2))P.current=R;return}P.current=R},[Z,Z.selection.focus.offset,Z.selection.focus.regionId,X,Y,K,q,U]),OJ(()=>{if(G.current=!0,y(),!B||typeof window>"u")return;let L=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-b.current<eN){if(!G.current)G.current=!0,y();return}G.current=!G.current,y()},$A);return()=>{window.clearInterval(L)}},[B]),{leaf:A,isVisible:()=>G.current,markActivity:z}}function MA({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:Z,state:X,viewport:D}){if(!D)return null;let Y=X.selection.focus;if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let Q=$?XA(X,D):null;if(Q)return Q;let K=M?JA(X,D):null;if(K)return K;return K8(G6(X,D,Y,J.liveRanges),J.threads)}function JA($,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 D=$.documentIndex.blockIndex.get(Z.blockId),Y=D?.type==="table"?$.documentIndex.document.blocks[D.rootIndex]:null;if(!D||!Y||Y.type!=="table")return null;let Q=o0($,M,J),K=ZA(M,Z.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 ZA($,M){let J=$.layout.lines.find((Z)=>Z.regionId===M);return J?J.left:null}function XA($,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 D=o0($,M,J);return D?{kind:"insertion",left:D.left,top:D.top+D.height}:null}function DA($,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}}function YA($,M){return $?.layoutWidth===M.layoutWidth&&$.regionId===M.regionId&&$.offset===M.offset&&$.scrollContentHeight===M.scrollContentHeight&&$.viewportHeight===M.viewportHeight}function jJ($,M,J,Z){return $.top>=M+Z&&$.top+$.height<=M+J-Z}import{useEffect as QA,useEffectEvent as KA,useMemo as Z$,useRef as qA,useState as UA}from"react";function RJ($){let M=Z$(()=>NA($),[$]),J=Z$(()=>M.join(`
|
|
31
|
+
`),[M]),[Z,X]=UA(new Map),D=qA(new Map),Y=KA((Q,K)=>{if(typeof Image>"u")return;let q=new Set(Q),U=D.current;X((N)=>VA(N,q,U));for(let N of Q){if(AA(Z,U,N))continue;GA(N,U,X,K)}});return QA(()=>{let Q=!0;return Y(M,()=>Q),()=>{Q=!1}},[J]),Z$(()=>Z.size===0?null:{images:Z},[Z])}function NA($){return[...p$($)].sort()}function AA($,M,J){return $.get(J)?.status==="loaded"||M.has(J)}function VA($,M,J){let Z=!1,X=new Map($);for(let D of X.keys())if(!M.has(D))X.delete(D),J.delete(D),Z=!0;return Z?X:$}function GA($,M,J,Z){let X=new Image;X.decoding="async",X.crossOrigin="anonymous",M.set($,X),J((D)=>{let Y=new Map(D);return Y.set($,BA()),Y}),X.onload=()=>{if(M.delete($),!Z())return;J((D)=>{let Y=new Map(D);return Y.set($,FA(X)),Y})},X.onerror=()=>{if(M.delete($),!Z())return;J((D)=>{let Y=new Map(D);return Y.set($,_A()),Y})},X.src=$}function BA(){return{intrinsicHeight:0,intrinsicWidth:0,source:null,status:"loading"}}function FA($){return{intrinsicHeight:$.naturalHeight,intrinsicWidth:$.naturalWidth,source:$,status:"loaded"}}function _A(){return{intrinsicHeight:0,intrinsicWidth:0,source:null,status:"error"}}import{useEffect as kJ,useEffectEvent as F0,useRef as u4,useState as bA}from"react";var HA=48;function fJ({applyNextState:$,autoScrollDuringDrag:M,canvasRef:J,commentState:Z,editorStateRef:X,editorViewportState:D,focusInput:Y,onActivity:Q,readCurrentState:K,resolvePoint:q}){let[U,N]=bA(null),A=u4(null),V=u4(!1),B=u4(null),G=u4(null),b=u4(null),P=K8(U,Z.threads),y=U?.kind==="task-toggle"||P?.kind==="link"?"pointer":"text";kJ(()=>{if(U&&U.kind!=="task-toggle"&&!P)N(null)},[U,P]),kJ(()=>()=>{if(A.current!==null)window.clearTimeout(A.current)},[]);let z=F0(()=>{if(A.current!==null)window.clearTimeout(A.current),A.current=null}),L=F0(()=>{z(),A.current=window.setTimeout(()=>{if(A.current=null,!V.current)N(null)},HA)}),R=F0(()=>{if(!V.current)z(),N(null)}),m=F0((O)=>{if(!O){R();return}if(O.kind==="task-toggle"){z(),N((T)=>T?.kind==="task-toggle"&&T.listItemId===O.listItemId?T:O);return}if(O.commentThreadIndex!==null){if(!(Z.threads[O.commentThreadIndex]??null)){R();return}z();let k=O.commentThreadIndex;N((f)=>f?.kind!=="task-toggle"&&f?.commentThreadIndex===k?f:O);return}if(O.kind!=="link"){R();return}z(),N((T)=>T?.kind==="link"&&T.title===O.title&&T.url===O.url&&T.startOffset===O.startOffset&&T.endOffset===O.endOffset?T:O)}),E=F0((O)=>{let T=X.current;if(!T)return null;let k=q(O);if(!k)return null;return V6(T,D.get(),k,Z.liveRanges)}),_=F0((O)=>{let T=J.current;if(T&&B.current===O)T.releasePointerCapture(O)}),j=F0(()=>{B.current=null,G.current=null}),C=F0((O)=>{_(O.pointerId),j()}),W=F0((O)=>{if(b.current=O.pointerType,O.pointerType==="touch")return;let T=J.current,k=K(),f=q(O);if(!f)return;if(E(O)?.kind==="task-toggle")return;let I=F5(k,D.get(),f);if(!T||!I)return;B.current=O.pointerId,G.current={offset:I.offset,regionId:I.regionId},Q(),T.setPointerCapture(O.pointerId),$(D0(k,{offset:I.offset,regionId:I.regionId})),Y({offset:I.offset,regionId:I.regionId})}),F=F0((O)=>{let T=G.current,k=K(),f=q(O);if(!f)return;if(B.current!==O.pointerId||!T){m(E(O));return}let d=f2(k,D.get(),f,T);if(!d)return;Q(),M(O),$(D0(k,{anchor:T,focus:d}))}),H=F0(()=>{if(!V.current)L()}),v=F0((O)=>{let T=b.current==="touch";b.current=null;let k=E(O);if(k?.kind==="task-toggle"){let U0=K(),z0=U3(U0,k.listItemId);if(z0)O.preventDefault(),O.stopPropagation(),Q(),$(z0);return}if(k?.kind==="link"&&(O.metaKey||O.ctrlKey)){O.preventDefault(),O.stopPropagation(),O.currentTarget.ownerDocument.defaultView?.open(k.url,"_blank","noopener,noreferrer");return}if(!T){Y();return}let f=K(),d=q(O),I=d?F5(f,D.get(),d):null;if(I)Q(),$(D0(f,{offset:I.offset,regionId:I.regionId})),Y({offset:I.offset,regionId:I.regionId});else Y()}),h=F0((O)=>{let T=K(),k=q(O),f=E(O);if(!k||f?.kind==="task-toggle")return;let d=A6(T,D.get(),k);if(!d)return;O.preventDefault(),O.stopPropagation(),Q(),$(D0(T,d)),Y()}),l=F0(()=>{V.current=!0,z()}),p=F0(()=>{V.current=!1,L()});return{canvasHandlers:{onClick:v,onDoubleClick:h,onPointerCancel:C,onPointerDown:W,onPointerLeave:H,onPointerMove:F,onPointerUp:C},cursor:y,leaf:P,leafHandlers:{onPointerEnter:l,onPointerLeave:p}}}import{useEffect as Q$,useEffectEvent as V0,useLayoutEffect as zA,useRef as IJ,useState as WA}from"react";import{useEffect as yL1}from"react";var X$=[{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 mJ($,M=X$){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 hJ($){let M=$.documentIndex.regions.find((D)=>D.id===$.selection.anchor.regionId),J=$.documentIndex.regions.find((D)=>D.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 D$($){let M=Y$($);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 Y$($){let M=PA($);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 SJ=28,uJ=18;function gJ($,M){if(!$)return;let J=$.getBoundingClientRect();if(M.clientY<J.top+SJ){$.scrollTop=Math.max(0,$.scrollTop-uJ);return}if(M.clientY>J.bottom-SJ)$.scrollTop+=uJ}function PA($){let M=vJ($.documentIndex.regions,$.selection.anchor.regionId,$.selection.anchor.offset),J=vJ($.documentIndex.regions,$.selection.focus.regionId,$.selection.focus.offset);return M<=J?{end:$.selection.focus,start:$.selection.anchor}:{end:$.selection.anchor,start:$.selection.focus}}function vJ($,M,J){let Z=$.findIndex((X)=>X.id===M);if(Z===-1)return-1;return Z*1e6+J}var EA=1024,pJ=16;function cJ({applyNextState:$,editorState:M,editorStateRef:J,editorViewportState:Z,inputRef:X,keybindings:D,onActivity:Y}){let Q=TA(),K=()=>J.current??M,q=IJ(!1),U=IJ(!1),N=V0((F)=>{if(!F)return;Y(),$(F)}),A=V0(()=>{let F=X.current;if(!F)return;if(typeof document>"u")return;let H=document.execCommand;if(typeof H!=="function")return;try{q.current=!0,H.call(document,"insertText",!1,""),H.call(document,"delete")}catch{}finally{q.current=!1,v4(F,K())}}),V=V0(()=>{if(U.current)return;U.current=!0,A()}),B=V0(()=>{A()}),G=V0((F)=>{if(!Q)return;let H=X.current;if(!H)return;let v=Z.get(),h=o0(K(),v,F);if(!h)return;H.style.top=`${h.top}px`,H.style.left=`${h.left}px`,H.style.height=`${h.height}px`}),b=V0((F)=>{let H=X.current;if(!H)return;G(F??K().selection.focus),H.focus({preventScroll:!Q}),v4(H,K()),V()}),P=V0((F,H)=>{let h=rJ(H,q8(F)).replace(/\r\n/g,`
|
|
32
|
+
`).split(/(\n)/),l=F;for(let p of h){if(p.length===0)continue;let O=p===`
|
|
33
|
+
`?J4(l):Y2(l,p);if(!O)continue;l=O}return l===F?null:l}),y=V0((F,H,v)=>{let h=F.selection.focus,l={regionId:h.regionId,offset:Math.max(0,h.offset-H)},p=D0(F,{anchor:l,focus:h});return x5(p,v)}),z=V0((F)=>{if(q.current)return;let H=K(),v=OA(F.inputType);if(F.inputType==="insertText"){if(!F.data)return;F.preventDefault();let h=lJ(F.target);if(h>0){N(y(H,h,F.data));return}let l=wA(H,F.data);if(l>0){let p=F.data.slice(l);if(p.length>0)N(P(H,p));return}N(P(H,F.data));return}if(F.inputType==="insertReplacementText"){if(!F.data)return;F.preventDefault();let h=lJ(F.target);N(y(H,h,F.data));return}if(yA(F.inputType)){F.preventDefault(),N(J4(H));return}if(v==="backward"){F.preventDefault(),N(r5(H));return}if(v==="forward"){F.preventDefault(),N(c5(H));return}if(F.inputType==="historyUndo"){F.preventDefault(),N(a5(H)),B();return}if(F.inputType==="historyRedo"){F.preventDefault(),N(i5(H)),B();return}}),L=V0((F)=>{let H=K(),v=F.currentTarget.value,h=q8(H);if(q.current)return;if(rJ(v,h).length===0){v4(F.currentTarget,H);return}N(P(H,v))}),R=V0((F)=>{let H=jA(K(),Z.get(),F.nativeEvent,D);if(!H)return;F.preventDefault(),N(H)}),m=V0((F)=>{let H=D$(K());if(!H)return;F.preventDefault(),F.clipboardData.setData("text/plain",H)}),E=V0((F)=>{let H=K(),v=D$(H);if(!v)return;F.preventDefault(),F.clipboardData.setData("text/plain",v),N(Z4(H))}),_=V0((F)=>{let H=F.clipboardData.getData("text/plain");if(H.length===0)return;F.preventDefault(),N(x5(K(),H))}),j=V0(()=>{Y();let F=X.current;if(F)v4(F,K())}),C=V0((F)=>{if(Y(),F.target.matches(":focus-visible"))b()});Q$(()=>{let F=X.current;if(!F)return;v4(F,M)},[M,X]),zA(()=>{G(M.selection.focus)},[M,G]),Q$(()=>{let F=X.current;if(!F)return;let H=(v)=>z(v);return F.addEventListener("beforeinput",H),()=>F.removeEventListener("beforeinput",H)},[X,z]);let W={onCopy:m,onCut:E,onPaste:_,...Q?{}:{onKeyDown:R}};return{canvasHandlers:{...W,onFocus:C},focus:b,inputHandlers:{...W,onFocus:j,onInput:L}}}var xJ="";function TA(){let[$,M]=WA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return Q$(()=>{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 yA($){return $==="insertLineBreak"||$==="insertParagraph"}function lJ($){let M=$,J=M?.selectionStart??0,Z=M?.selectionEnd??J;return Math.max(0,Z-J)}function wA($,M){if(M.length<pJ)return 0;let J=q8($,M.length),Z=Math.min(J.length,M.length);for(let X=Z;X>=pJ;X--)if(J.endsWith(M.slice(0,X)))return X;return 0}function OA($){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 CA($){return $.replaceAll(xJ,"")}function q8($,M=EA){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 rJ($,M){let J=CA($);return J.startsWith(M)?J.slice(M.length):J}function v4($,M){let J=q8(M),Z=`${xJ}${J}`;$.value=Z,$.setSelectionRange(Z.length,Z.length)}function jA($,M,J,Z){if(J.key==="Delete")return c5($);let X=mJ(J,Z);if(X){if(X==="moveToLineStart"||X==="moveToLineEnd")return P3($,M.layout,X==="moveToLineStart"?"Home":"End",J.shiftKey);if(X==="moveToDocumentStart"||X==="moveToDocumentEnd")return z3($,X==="moveToDocumentStart"?"start":"end",J.shiftKey);switch(X){case"insertLineBreak":return J4($);case"deleteBackward":return r5($);case"indent":return n6($);case"dedent":return t6($);case"moveListItemUp":return e6($);case"moveListItemDown":return $3($);case"toggleBold":return X4($);case"toggleItalic":return D4($);case"toggleStrikethrough":return Y4($);case"toggleUnderline":return Q4($);case"toggleInlineCode":return Q3($);case"undo":return a5($);case"redo":return i5($);case"selectAll":return o6($)}}if(J.key==="ArrowLeft"||J.key==="ArrowRight")return _3($,J.key==="ArrowLeft"?-1:1,J.shiftKey);if(J.key==="ArrowUp"||J.key==="ArrowDown")return b3($,M.layout,J.key==="ArrowUp"?-1:1,J.shiftKey);if(J.key==="PageUp"||J.key==="PageDown")return H3($,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{useEffectEvent as K$,useLayoutEffect as LA,useMemo as RA,useState as kA}from"react";function dJ({editorState:$,editorStateRef:M,editorViewportState:J,onViewportScroll:Z,scrollContainerRef:X,scheduleOverlayRender:D,userPresence:Y}){let Q=RA(()=>{if(!Y||Y.length===0)return;return b5($.documentIndex,Y)},[$.documentIndex,Y]),[K,q]=kA(void 0),U=K$(()=>{if(Q===void 0){if(K!==void 0)q(void 0)}else q(m2(M.current??$,J.get(),Q));D()}),N=K$((V)=>{if(Q===void 0){if(K!==void 0)q(void 0);return}let B=m2(M.current??$,V,Q);if(fA(K,B))return;q(B)});LA(()=>{U()},[Q]);let A=K$((V)=>{if(!V.viewport||V.viewport.status==="unresolved")return;let B=X.current;if(!B)return;B.scrollTop=V.viewport.scrollTop,Z(B)});return{presence:K,scrollToPresence:A,refreshPresence:N}}function fA($,M){if($===M)return!0;if($===void 0||M===void 0||$.length!==M.length)return!1;return $.every((J,Z)=>{let X=M[Z];return J.id===X.id&&mA(J.viewport,X.viewport)})}function mA($,M){if($===M)return!0;if($===null||M===null)return!1;if($.status==="unresolved")return M.status==="unresolved";if(M.status==="unresolved")return!1;return $.status===M.status&&$.scrollTop===M.scrollTop}import{useEffect as SA,useEffectEvent as j1,useRef as h4}from"react";function aJ({editorStateRef:$,renderContent:M,renderOverlay:J,renderViewport:Z}){let X=h4(null),D=h4(!1),Y=h4(!1),Q=h4(!1),K=h4(!1),q=j1(()=>{if(typeof window>"u"){Z();return}D.current=!0,V()}),U=j1(()=>{if(typeof window>"u"){M(),J();return}Y.current=!0,V()}),N=j1(()=>{if(typeof window>"u"){M();return}Q.current=!0,V()}),A=j1(()=>{if(typeof window>"u"){J();return}K.current=!0,V()}),V=j1(()=>{if(typeof window>"u"||X.current!==null)return;X.current=window.requestAnimationFrame(()=>{B()})}),B=j1(()=>{X.current=null;let b=D.current,P=Y.current,y=Q.current,z=K.current;if(D.current=!1,Y.current=!1,Q.current=!1,K.current=!1,b){Z(),G();return}if(P){M(),J(),G();return}if(y)M(),G();if(z)J()}),G=j1(()=>{let b=$.current;if(!b||!S6(b,performance.now()))return;Q.current=!0,V()});return SA(()=>{return()=>{if(typeof window>"u"||X.current===null)return;window.cancelAnimationFrame(X.current),X.current=null}},[]),{scheduleContentPaint:N,scheduleFullPaint:U,scheduleFullRender:q,scheduleOverlayPaint:A}}import{useEffectEvent as q$,useLayoutEffect as iJ,useMemo as U$,useRef as N$,useState as sJ}from"react";function oJ({applyNextState:$,autoScrollDuringDrag:M,canShowSelectionLeaf:J,editorState:Z,editorStateRef:X,editorViewportState:D,focusInput:Y,onActivity:Q,resolvePoint:K,threads:q}){let U=U$(()=>n(Z),[Z]),N=U$(()=>Y$(Z),[Z]),A=U$(()=>w5(Z),[Z]),[V,B]=sJ(null),[G,b]=sJ(null),P=N$(null),y=N$(null),z=N$(null);iJ(()=>{let _=uA(Z,D.get(),U);B((j)=>pA(j,_)?j:_)},[Z,D,U.end.offset,U.end.regionId,U.start.offset,U.start.regionId]),iJ(()=>{let _=hA({canShowSelectionLeaf:J,currentLeaf:G,activeMarks:A,handles:V,selectionRange:N,threads:q});b((j)=>IA(j,_)?j:_)},[A,J,V,G,N,q]);let L=q$((_,j=!0)=>{b((C)=>C?.kind==="create"?{animateInitialComment:j,kind:"thread",left:C.left,threadIndex:_,top:C.top}:C)}),R=q$((_)=>{if(_&&z.current===_.pointerId&&_.currentTarget.hasPointerCapture(_.pointerId))_.currentTarget.releasePointerCapture(_.pointerId);P.current=null,y.current=null,z.current=null}),m=q$((_)=>{let j=X.current,C=y.current,W=K(_);if(!W||!j||!C||z.current!==_.pointerId)return;let F=f2(j,D.get(),W,C);if(!F)return;_.preventDefault(),_.stopPropagation(),Q(),M(_),$(D0(j,{anchor:C,focus:F}))}),E=(_)=>({onPointerCancel:(j)=>{R(j)},onPointerDown:(j)=>{let C=X.current??Z,W=rA(U,_),F=_==="start"?U.start:U.end;if(!V)return;j.preventDefault(),j.stopPropagation(),z.current=j.pointerId,y.current=W,P.current=_,j.currentTarget.setPointerCapture(j.pointerId),Q(),Y(),$(D0(C,{anchor:W,focus:F}))},onPointerMove:(j)=>{if(P.current!==_)return;m(j)},onPointerUp:(j)=>{if(P.current===_)m(j);R(j)}});return{endHandleProps:E("end"),handles:V,leaf:G,promoteLeafToThread:L,startHandleProps:E("start")}}function uA($,M,J){if(J.collapsed)return null;let Z=o0($,M,J.start),X=o0($,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 vA($,M,J){return{activeMarks:J,kind:"create",left:M.start.left,selection:$,top:M.end.top}}function hA({activeMarks:$,canShowSelectionLeaf:M,currentLeaf:J,handles:Z,selectionRange:X,threads:D}){if(!M||!X||!Z)return null;if(J?.kind==="thread")return D[J.threadIndex]?J:null;return vA(X,Z,$)}function gA($,M){return $?.kind==="create"&&$.left===M.left&&$.selection.regionId===M.selection.regionId&&$.selection.startOffset===M.selection.startOffset&&$.selection.endOffset===M.selection.endOffset&&lA($.activeMarks,M.activeMarks)&&$.top===M.top}function IA($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;if($.kind==="create"&&M.kind==="create")return gA($,M);return $.kind==="thread"&&M.kind==="thread"&&$.animateInitialComment===M.animateInitialComment&&$.left===M.left&&$.threadIndex===M.threadIndex&&$.top===M.top}function pA($,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 lA($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function rA($,M){return M==="start"?$.end:$.start}import{useEffect as cA,useMemo as eJ,useState as xA}from"react";var g4={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)"},I4={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)"},nJ={...g4,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)"},tJ={...I4,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 $Z($){let M=eJ(()=>aA($),[$]),[J,Z]=xA(M.light),X=eJ(()=>iA(J),[J]);return cA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){Z(M.light);return}let D=window.matchMedia("(prefers-color-scheme: dark)"),Y=()=>{Z(D.matches?M.dark:M.light)};if(Y(),typeof D.addEventListener==="function")return D.addEventListener("change",Y),()=>{D.removeEventListener("change",Y)};return D.addListener(Y),()=>{D.removeListener(Y)}},[M]),{theme:J,themeStyles:X}}function dA($){return"light"in $&&"dark"in $}function aA($){if(!$)return{dark:I4,light:g4};if(dA($))return $;return{dark:$,light:$}}function iA($){return{"--documint-background":$.background,"--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-mention-bg":$.mentionBackground??void 0,"--documint-mention-text":$.mentionText??void 0,"--documint-selection-handle-bg":$.selectionHandleBackground,"--documint-selection-handle-border":$.selectionHandleBorder}}import{useEffect as nA,useEffectEvent as x0,useRef as A$,useState as U8}from"react";import{useMemo as sA}from"react";function MZ($){return sA(()=>oA({current:null},$),[$])}function oA($,M){return{peek(){return $.current},get(){let J=$.current;if(J!==null)return J;let Z=M();return $.current=Z,Z},invalidate(){$.current=null}}}function JZ($,M){let J=M.getBoundingClientRect();return{x:$.clientX-J.left+M.scrollLeft,y:$.clientY-J.top+M.scrollTop}}function ZZ({editorState:$,editorStateRef:M,renderResources:J,theme:Z}){let X=A$(W1()),D=A$(null),Y=A$({height:240,top:0}),[Q,K]=U8(0),[q,U]=U8(240),[N,A]=U8(0),[V,B]=U8(240),G=tA(Q),b=x0(()=>{let F=M.current??$,H=Y.current;return N6(F,{height:H.height,paddingX:Z.paddingX,paddingY:Z.paddingY,top:H.top,width:G},X.current,J)}),P=MZ(b),y=x0((F)=>{B((H)=>{let v=$V(F,Y.current.height);return H===v?H:v})}),z=x0((F)=>{Y.current={...Y.current,top:F},A((H)=>H===F?H:F),P.invalidate()}),L=x0((F)=>{let H=eA(F),v=H.top!==Y.current.top;if(Y.current=H,A((h)=>h===H.top?h:H.top),v)P.invalidate()}),R=x0((F)=>{let H=D.current;if(!H)return z(F),F;H.scrollTop=F;let v=H.scrollTop;return z(v),v}),m=x0(()=>{return D.current?.scrollTop??Y.current.top}),E=x0((F,H)=>{let v=F!==null&&F.documentIndex!==H.documentIndex,h=P.peek();if(!(!v||!h||h.layout.regionLineIndices.has(H.selection.focus.regionId)))P.invalidate()}),_=x0(()=>{return P.invalidate(),P.get()}),j=x0((F)=>{let H=D.current;return H?JZ(F,H):null}),C=x0((F)=>{gJ(D.current,F)});return nA(()=>{let F=D.current;if(!F||typeof ResizeObserver>"u")return;let H=new ResizeObserver((v)=>{let h=v[0];if(!h)return;let l=Math.max(0,Math.floor(h.contentRect.width)),p=XZ(F);Y.current={...Y.current,height:p},K((O)=>O===l?O:l),U((O)=>O===p?O:p)});return H.observe(F),()=>H.disconnect()},[D]),{actions:{autoScrollDuringDrag:C,getScrollTop:m,observePreparedViewport:y,observeScrollContainer:L,prepareNextPaint:_,reconcileEditorState:E,resolvePoint:j,scrollTo:R},props:{getScrollContainer:(F)=>({onScroll:(H)=>{L(H.currentTarget),F?.onScroll?.(H)},ref:D}),scrollContent:{style:{height:`${V}px`}}},refs:{scrollContainer:D},state:{layoutWidth:G,preparedViewport:P,scrollContentHeight:V,surfaceWidth:Q,viewportHeight:q,viewportTop:N}}}function tA($){return Math.max(240,Math.floor($||480))}function XZ($){return Math.max(240,$.clientHeight)}function eA($){return{height:XZ($),top:$.scrollTop}}function $V($,M){return Math.max(M,Math.ceil($.totalHeight+24))}function MV(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function V$($,{paintHeight:M,paintTop:J,width:Z}){if(!$)return null;let X=Math.max(240,Math.ceil(M)),D=MV();$.width=Math.ceil(Z*D),$.height=Math.ceil(X*D),$.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:D,height:X,width:Z}}function G$($,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}function DZ($,M){if(!M?.length||!$?.length)return;let J=new Map($.map((X)=>[X.id,X])),Z=[];for(let X of M){let D=J.get(X.userId);if(!D)continue;Z.push({...D,color:X.color,cursor:X.cursor})}return Z.length===0?void 0:Z}function QZ($,M){if(!$)return{didReconcile:!1,state:M};let J=JV($,M)??NV($,M);return J?{didReconcile:!0,state:J}:{didReconcile:!1,state:M}}function JV($,M){let J=ZV($,M);return J?D0(M,J,!1):null}function ZV($,M){if(_$($.selection.anchor,$.selection.focus)){let D=B$($,M,$.selection.focus,"neutral");return D?{anchor:D,focus:D}:null}let J=qV($),Z=B$($,M,$.selection.anchor,J.anchor),X=B$($,M,$.selection.focus,J.focus);return Z&&X?{anchor:Z,focus:X}:null}function B$($,M,J,Z){let X=$.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let D=F$(X,M);if(!D)return null;return{offset:DV(X.text,D.text,J.offset,Z),regionId:D.id}}function F$($,M){let J=M.documentIndex.regionIndex.get($.id);if(J)return J;if($.text.length===0)return null;let Z=XV($,M);if(Z)return Z;return M.documentIndex.regionPathIndex.get($.path)??null}function XV($,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 DV($,M,J,Z){let X=j0(J,0,$.length),{prefix:D,suffix:Y}=C8($,X,X),Q=YV(M,D,Y);if(Q!==null)return Q;let K=QV(M,D),q=KV(M,Y);if(Z==="before-suffix")return q??K??j0(J,0,M.length);return K??q??j0(J,0,M.length)}function YV($,M,J){let Z=l1($,M,J).filter((X)=>X.startOffset===X.endOffset);return Z.length===1?Z[0].startOffset:null}function QV($,M){let J=u0($,M);return J.length===1?J[0]+M.length:null}function KV($,M){let J=u0($,M);return J.length===1?J[0]:null}function qV($){let{anchor:M,focus:J}=$.selection;if(_$(M,J))return{anchor:"neutral",focus:"neutral"};return UV($,M,J)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function UV($,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 NV($,M){if(!_$($.selection.anchor,$.selection.focus))return null;let J=AV($);if(!J)return null;let Z=VV($,M,J);if(Z===null)return null;return GV(M,Z)}function AV($){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 VV($,M,J){let Z=YZ($,J.rootIndex,"before"),X=YZ($,J.rootIndex,"after"),D=Z?F$(Z,M):null,Y=X?F$(X,M):null;if(D&&Y)return D.rootIndex<Y.rootIndex?Y.rootIndex:null;if(D)return D.rootIndex+1;if(Y)return Y.rootIndex;return null}function GV($,M){let J=I1($.documentIndex.document,M,0,[r({text:""})]),Z={...$,documentIndex:$2($.documentIndex,J,M,0)},X=p2(Z.documentIndex,M0(M));return X?D0(Z,X,!1):null}function YZ($,M,J){let Z=J==="before"?-1:1;for(let X=M+Z;X>=0&&X<$.documentIndex.roots.length;X+=Z){let D=BV($,X,J);if(D)return D}return null}function BV($,M,J){let Z=$.documentIndex.roots[M]?.regions??[],X=J==="before"?Z.length-1:0,D=J==="before"?-1:1;for(let Y=X;Y>=0&&Y<Z.length;Y+=D){let Q=Z[Y];if(Q&&Q.text.length>0)return Q}return null}function _$($,M){return $.regionId===M.regionId&&$.offset===M.offset}import{jsx as x,jsxs as A8,Fragment as EV}from"react/jsx-runtime";function V8({blocks:$}){return x(EV,{children:$.map((M)=>FV(M))})}function FV($){switch($.type){case"blockquote":return x("blockquote",{className:"preview-block preview-block-blockquote",children:x(V8,{blocks:$.children})},$.id);case"code":return A8("div",{className:"preview-block preview-block-code",children:[x("div",{className:"preview-rich-header",children:HV($.language,$.meta)}),x("pre",{children:x("code",{children:$.source||" "})})]},$.id);case"heading":{let M=`h${$.depth}`;return x(M,{className:"preview-block preview-block-heading",children:N8($.children)},$.id)}case"list":return $.ordered?x("ol",{className:"preview-block preview-block-list",start:$.start??1,children:$.items.map((M)=>b$(M))},$.id):x("ul",{className:"preview-block preview-block-list",children:$.items.map((M)=>b$(M))},$.id);case"listItem":return b$($);case"paragraph":return x("p",{className:"preview-block preview-block-paragraph",children:N8($.children)},$.id);case"table":return A8("div",{className:"preview-block preview-block-table",children:[x("div",{className:"preview-rich-header",children:PV($.rows.length,$.rows[0]?.cells.length??0,$.align.filter((M)=>M!==null).length)}),x("div",{className:"preview-table-scroll",children:x("table",{children:x("tbody",{children:$.rows.map((M)=>x("tr",{children:M.cells.map((J)=>x("td",{children:N8(J.children)},J.id))},M.id))})})})]},$.id);case"thematicBreak":return x("hr",{className:"preview-block preview-block-rule"},$.id);case"directive":return x("pre",{className:`preview-block preview-block-directive preview-block-directive-${$.name}`,children:$.body},$.id);case"unsupported":return x("pre",{className:"preview-block preview-block-unsupported",children:$.source},$.id)}}function b$($){return x("li",{className:"preview-block preview-block-list-item",children:x(V8,{blocks:$.children})},$.id)}function N8($){return $.map((M)=>{switch(M.type){case"break":return x("br",{},M.id);case"image":return A8("span",{className:"preview-inline preview-inline-image",children:[x("img",{alt:M.alt??"",src:M.url,title:M.title??""}),A8("span",{children:[x("strong",{children:zV(M.alt)}),x("small",{children:WV(M.url,M.title)})]})]},M.id);case"inlineCode":return x("code",{className:"preview-inline preview-inline-code",children:M.code},M.id);case"link":return _V(M);case"text":return x("span",{className:"preview-inline",children:bV(M.text,M.marks)},M.id);case"unsupported":return x("span",{className:"preview-inline preview-inline-unsupported",children:M.source},M.id)}})}function _V($){return x("a",{className:"preview-inline preview-inline-link",href:$.url,children:N8($.children)},$.id)}function bV($,M){let J=$;for(let Z of M)switch(Z){case"strikethrough":J=x("del",{children:J});break;case"italic":J=x("em",{children:J});break;case"bold":J=x("strong",{children:J});break;case"underline":J=x("ins",{children:J});break}return J}function HV($,M){return[$??"plain text",M].filter(Boolean).join(" • ")}function PV($,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 zV($){return $?.trim()?$:"Untitled image"}function WV($,M){return M?.trim()?`${M} • ${$}`:$}var KZ=`/* Base Documint host and SSR-fallback styles. */
|
|
34
34
|
|
|
35
35
|
.documint {
|
|
36
36
|
display: grid;
|
|
@@ -373,7 +373,7 @@ ${M.text}`:M.text}function xY($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
373
373
|
white-space: nowrap;
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
|
-
`;var
|
|
376
|
+
`;var qZ=`/* Leaf overlay styles, ordered outer → inner:
|
|
377
377
|
1. Anchor — viewport positioning + hover bridge
|
|
378
378
|
2. Shell — bordered container (with state and content variants)
|
|
379
379
|
3. Menu — shared dropdown surface (toolbar menus, completion popover)
|
|
@@ -883,7 +883,7 @@ ${M.text}`:M.text}function xY($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
883
883
|
font-weight: 500;
|
|
884
884
|
white-space: nowrap;
|
|
885
885
|
}
|
|
886
|
-
`;var
|
|
886
|
+
`;var UZ=`/* Toolbar-specific styles (button, group, divider, and the menu trigger
|
|
887
887
|
shell + chevron). The menu container/item/divider styles themselves
|
|
888
888
|
live one level up in \`overlays/leaves/styles.css\` as \`.documint-leaf-menu*\`
|
|
889
889
|
so they can be shared by the toolbar's nested menu and other surfaces
|
|
@@ -965,6 +965,6 @@ ${M.text}`:M.text}function xY($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
965
965
|
transform: rotate(180deg);
|
|
966
966
|
}
|
|
967
967
|
}
|
|
968
|
-
`;var
|
|
969
|
-
${
|
|
970
|
-
${
|
|
968
|
+
`;var NZ=`${KZ}
|
|
969
|
+
${qZ}
|
|
970
|
+
${UZ}`;import{jsx as K0,jsxs as B8,Fragment as jV}from"react/jsx-runtime";var CV=2,AZ={activeBlockType:null,activeCommentThreadIndex:null,activeSpanKind:null,canonicalContent:"",characterCount:0,commentThreadCount:0,layoutWidth:0,resolvedCommentCount:0,selectionFrom:0,selectionTo:0};function GZ({className:$,content:M,keybindings:J,onCommentChanged:Z,onContentChanged:X,onStateChanged:D,presence:Y,theme:Q,users:K}){let q=L1(null),U=L1(null),N=L1(null),A=L1(null),V=L1(M),B=L1(""),G=L1(AZ),[b,P]=H$(!1),{theme:y,themeStyles:z}=$Z(Q),[L,R]=H$(AZ),m=$1(()=>h3(M),[M]),E=$1(()=>X8(m),[m]),[_,j]=H$(()=>o2(m)),C=RJ(_.documentIndex.document),W=$1(()=>[...C?.images.values()??[]].some((w)=>w.status==="loading"),[C]);A.current=_,B.current||=E;let F=ZZ({editorState:_,editorStateRef:A,renderResources:C,theme:y}),{actions:H,props:v,refs:h,state:l}=F,{autoScrollDuringDrag:p,getScrollTop:O,observePreparedViewport:T,observeScrollContainer:k,prepareNextPaint:f,reconcileEditorState:d,resolvePoint:I,scrollTo:U0}=H,{layoutWidth:z0,preparedViewport:_0,scrollContentHeight:R1,surfaceWidth:F8,viewportHeight:p4,viewportTop:_8}=l,{scrollContainer:l4}=h,r4=$1(()=>l2(_),[_]),O0=$1(()=>L0(_),[_]),W0=$1(()=>n(_),[_]),k1=$1(()=>{if(!K?.length)return;return[{trigger:"@",items:K.map((w)=>({label:w.fullName??w.username,id:w.id}))}]},[K]),b8=$1(()=>DZ(K,Y),[K,Y]),c4=$1(()=>VZ(_,O0.liveRanges),[O0.liveRanges,_]),f1=Boolean(X),J0=()=>A.current??_,x4=F2((w,S)=>{let g=l2(w),i=L0(w),e=hJ(w),Z0={activeBlockType:g.block?.nodeType??null,activeCommentThreadIndex:VZ(w,i.liveRanges),activeSpanKind:g.span.kind==="none"?null:g.span.kind,canonicalContent:S,characterCount:S.length,commentThreadCount:i.threads.length,layoutWidth:z0,resolvedCommentCount:h8(i.threads),selectionFrom:e.start,selectionTo:e.end};if(R((i4)=>G$(i4,Z0)?i4:Z0),!G$(G.current,Z0))G.current=Z0,D?.(Z0)}),a=F2((w)=>{if(!w)return;let S=A.current??_,g=S.documentIndex!==w.documentIndex,i=v5(S,w);if(A.current=w,j(w),d(S,w),i)H8();if(!g)return;let e=I0(w),Z0=X8(e);B.current=Z0,V.current=Z0,X?.(Z0,e)}),_2=(w)=>{Z?.(w)},P$=(w)=>{let S=I0(J0()).comments[w],g=S?.comments.at(-1);if(!S||!g)return;_2({kind:"added",comment:g,mentionedUserIds:x3(g.body,k1),thread:S,threadIndex:w})},BZ=(w,S,g)=>{let i=I0(J0()).comments[w],e=i?.comments[S];if(!i||!e)return;_2({kind:"edited",comment:e,previousBody:g,mentionedUserIds:x3(e.body,k1),thread:i,threadIndex:w})},z$=(w,S,g)=>{_2({kind:"deleted",comment:g,thread:S,threadIndex:w})},W$=F2((w=_0.peek())=>{if(!w)return;let S=V$(q.current,{paintHeight:w.paintHeight,paintTop:w.paintTop,width:z0});if(!S)return;let{context:g,devicePixelRatio:i,height:e,width:Z0}=S;w3(_,w,g,{activeBlockId:r4.block?.blockId??null,activeRegionId:_.selection.focus.regionId,activeThreadIndex:w$??c4,devicePixelRatio:i,height:e,liveCommentRanges:O0.liveRanges,normalizedSelection:W0,now:performance.now(),resources:C,theme:y,width:Z0})}),E$=F2((w=_0.peek())=>{if(!w)return;let S=V$(U.current,{paintHeight:w.paintHeight,paintTop:w.paintTop,width:z0});if(!S)return;let{context:g,devicePixelRatio:i,height:e,width:Z0}=S;O3(_,w,g,{devicePixelRatio:i,height:e,normalizedSelection:W0,presence:a4.presence,showCaret:W0.start.regionId!==W0.end.regionId||W0.start.offset!==W0.end.offset||b2.isVisible(),theme:y,width:Z0})}),FZ=F2(()=>{let w=f();T(w),a4.refreshPresence(w),W$(w),E$(w)}),{scheduleContentPaint:H8,scheduleFullPaint:T$,scheduleFullRender:m1,scheduleOverlayPaint:y$}=aJ({editorStateRef:A,renderContent:W$,renderOverlay:E$,renderViewport:FZ}),_Z=v.getScrollContainer({onScroll:()=>m1()}),b2=LJ({canShowInsertionLeaf:Boolean(X),canShowTableLeaf:Boolean(X),commentState:O0,editorState:_,editorViewportState:_0,getScrollTop:O,layoutWidth:z0,onVisibilityChange:y$,scrollContentHeight:R1,scrollTo:U0,viewportHeight:p4}),d4=cJ({applyNextState:a,editorState:_,editorStateRef:A,editorViewportState:_0,inputRef:N,keybindings:J,onActivity:b2.markActivity}),H1=fJ({applyNextState:a,autoScrollDuringDrag:p,canvasRef:q,commentState:O0,editorStateRef:A,editorViewportState:_0,focusInput:d4.focus,onActivity:b2.markActivity,readCurrentState:J0,resolvePoint:I}),w$=H1.leaf?.kind==="comment"?H1.leaf.threadIndex:null,bZ=F2((w)=>{k(w),m1()}),a4=dJ({editorState:_,editorStateRef:A,editorViewportState:_0,onViewportScroll:bZ,scrollContainerRef:l4,scheduleOverlayRender:y$,userPresence:b8}),f0=oJ({applyNextState:a,autoScrollDuringDrag:p,canShowSelectionLeaf:f1,editorState:_,editorStateRef:A,editorViewportState:_0,focusInput:d4.focus,onActivity:b2.markActivity,resolvePoint:I,threads:O0.threads});B2(()=>{m1()},[_.documentIndex,z0,y,C,m1,p4]),B2(()=>{T$()},[W0.end.offset,W0.end.regionId,W0.start.offset,W0.start.regionId,T$,r4.block?.blockId]),B2(()=>{H8()},[c4,O0.liveRanges,w$,H8]),B2(()=>{if(!W)return;let w=null,S=window,g=()=>{m1(),w=S.requestAnimationFrame(g)};return w=S.requestAnimationFrame(g),()=>{if(w!==null)S.cancelAnimationFrame(w)}},[W,m1]);let HZ=()=>{let w=H1.leaf,S=w??f0.leaf??b2.leaf,g=!w&&Boolean(f0.leaf),i=l4.current?.getBoundingClientRect()??null,e=S?.kind==="thread"?{...S,thread:O0.threads[S.threadIndex]??null}:null,Z0=S?.kind==="comment"?{animateInitialComment:!1,link:S.link,thread:S.thread,threadIndex:S.threadIndex}:e?.thread?{animateInitialComment:e.animateInitialComment??!1,link:null,thread:e.thread,threadIndex:e.threadIndex}:null,i4=Z0?.thread&&Z1(Z0.thread)?"resolved":"default";return{annotationThreadLeaf:Z0,visibleLeaf:S,visibleLeafAnchor:S?{isSelection:g,left:(i?.left??0)+S.left,onPointerEnter:w?H1.leafHandlers.onPointerEnter:void 0,onPointerLeave:w?H1.leafHandlers.onPointerLeave:void 0,top:(i?.top??0)+S.top-_8+(g?CV:0)}:void 0,visibleLeafStatus:i4}},{annotationThreadLeaf:m0,visibleLeaf:G0,visibleLeafAnchor:O$,visibleLeafStatus:PZ}=HZ(),zZ=(()=>{if(!G0)return null;switch(G0.kind){case"insertion":return K0(PJ,{onInsert:(w)=>{a(Y2(J0(),w))},onInsertTable:(w)=>{a(M3(J0(),w))}});case"table":return K0(wJ,{canDeleteColumn:G0.columnCount>1,canDeleteRow:G0.rowCount>1,onDeleteColumn:()=>{a(Z3(J0()))},onDeleteRow:()=>{a(D3(J0()))},onDeleteTable:()=>{a(Y3(J0()))},onInsertColumn:(w)=>{a(J3(J0(),w))},onInsertRow:(w)=>{a(X3(J0(),w))}});case"link":return K0(TJ,{canEdit:f1,onDelete:()=>{let w=q3(J0(),G0.regionId,G0.startOffset,G0.endOffset);if(w)a(w)},onSave:(w)=>{let S=K3(J0(),G0.regionId,G0.startOffset,G0.endOffset,w);if(S)a(S)},title:G0.title,url:G0.url});case"create":return K0(o3,{activeMarks:G0.activeMarks,canEdit:f1,link:null,mode:"create",mentionSources:k1,onCreateThread:(w)=>{let S=J0(),g=I0(S).comments.length,i=N3(S,G0.selection,w.trim());if(!i)return;a(i),f0.promoteLeafToThread(g,!0),P$(g)},onToggleBold:()=>{a(X4(J0()))},onToggleItalic:()=>{a(D4(J0()))},onToggleStrikethrough:()=>{a(Y4(J0()))},onToggleUnderline:()=>{a(Q4(J0()))}});default:return m0?K0(o3,{animateInitialComment:m0.animateInitialComment,canEdit:f1,link:m0.link,mode:"thread",mentionSources:k1,onDeleteComment:(w)=>{let{threadIndex:S}=m0,g=J0(),i=I0(g).comments[S],e=i?.comments[w],Z0=G3(g,S,w);if(!Z0)return;if(a(Z0),i&&e)z$(S,i,e)},onDeleteThread:()=>{let{threadIndex:w}=m0,S=J0(),g=I0(S).comments[w],i=B3(S,w);if(!i)return;if(a(i),g)for(let e of g.comments)z$(w,g,e)},onEditComment:(w,S)=>{let{threadIndex:g}=m0,i=J0(),e=I0(i).comments[g]?.comments[w]?.body,Z0=V3(i,g,w,S);if(!Z0)return;if(a(Z0),e!==void 0)BZ(g,w,e)},onReply:(w)=>{let{threadIndex:S}=m0,g=A3(J0(),S,w);if(!g)return;a(g),P$(S)},onToggleResolved:()=>{a(F3(J0(),m0.threadIndex,!Z1(m0.thread)))},thread:m0.thread}):null}})();B2(()=>{P(!0)},[]),B2(()=>{x4(_,B.current||E)},[E,_,x4,F8]),OV(()=>{if(M===V.current)return;let w=A.current,S=QZ(w,o2(m)),g=S.state,i=S.didReconcile?O():0;A.current=g,j(g),V.current=M,B.current=E,U0(i)},[E,M,m,O,U0]);let WZ=$?`documint ${$}`:"documint";return K0(ZJ,{themeStyles:z,children:B8("section",{className:WZ,"data-active-block":L.activeBlockType??"","data-active-comment-thread":L.activeCommentThreadIndex??"","data-active-span":L.activeSpanKind??"",style:{...z,height:"100%",minHeight:0},children:[K0("style",{children:NZ}),B8("div",{..._Z,className:"documint-scroll-container",style:{height:"100%",minHeight:0},children:[K0("textarea",{...d4.inputHandlers,ref:N,autoCapitalize:"sentences",className:"documint-input",spellCheck:!1,tabIndex:-1}),K0(TM,{insetX:y.paddingX,insetY:y.paddingY,onSelect:a4.scrollToPresence,presence:a4.presence}),B8("div",{...v.scrollContent,className:"documint-scroll-content",children:[K0("canvas",{...d4.canvasHandlers,...H1.canvasHandlers,"aria-label":"Documint editor",className:"documint-content-canvas",style:{cursor:H1.cursor},ref:q,tabIndex:0}),K0("canvas",{"aria-hidden":"true",className:"documint-overlay-canvas",ref:U}),f0.handles?B8(jV,{children:[K0("div",{"aria-hidden":"true",className:"documint-selection-handle documint-selection-handle-start",style:{left:`${f0.handles.start.left}px`,top:`${f0.handles.start.top}px`},...f0.startHandleProps,children:K0("span",{className:"documint-selection-handle-knob"})}),K0("div",{"aria-hidden":"true",className:"documint-selection-handle documint-selection-handle-end",style:{left:`${f0.handles.end.left}px`,top:`${f0.handles.end.top}px`},...f0.endHandleProps,children:K0("span",{className:"documint-selection-handle-knob"})})]}):null,G0&&O$?K0(zJ,{anchor:O$,status:PZ,children:zZ}):null]}),!b?K0("div",{className:"documint-fallback",children:K0(V8,{blocks:m.blocks})}):null]})]})})}function VZ($,M){let J=new Map($.documentIndex.regions.map((K,q)=>[K.id,q])),Z=G8(J,$.selection.anchor.regionId,$.selection.anchor.offset),X=G8(J,$.selection.focus.regionId,$.selection.focus.offset),[D,Y]=Z<=X?[Z,X]:[X,Z],Q=Z===X;for(let K of M){let q=G8(J,K.regionId,K.startOffset),U=G8(J,K.regionId,K.endOffset);if(Q){if(D>=q&&D<=U)return K.threadIndex;continue}if(Math.max(D,q)<Math.min(Y,U))return K.threadIndex}return null}function G8($,M,J){return($.get(M)??-1)*1e6+J}export{nJ as mintTheme,tJ as midnightTheme,g4 as lightTheme,X$ as defaultKeybindings,I4 as darkTheme,GZ as Documint};
|