documint 0.0.6 → 0.0.8
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 +7 -6
- package/dist/index.js +38 -35
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
import{useEffect as
|
|
2
|
-
`);return{id:
|
|
3
|
-
`);return{align:$.align??[],id:
|
|
4
|
-
`;case"image":return
|
|
5
|
-
`);case"table":return
|
|
6
|
-
`);case"
|
|
7
|
-
`).trim()}function
|
|
8
|
-
`);return{id:
|
|
9
|
-
`);return{align:$.align,id:Z0("table",M,Z),plainText:Z,rows:J,type:"table"}}case"thematicBreak":return{id:Z0("thematicBreak",M,"thematic-break"),plainText:"",type:"thematicBreak"};case"unsupported":return{id:Z0("unsupported",M,$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"unsupported"}}}function dZ($,M){return{cells:$.cells.map((J,Z)=>{let X=J.children.map((Q,K)=>e4(Q,`${M}.cells.${Z}.children.${K}`)),Y=q0(X);return{children:X,id:Z0("tableCell",`${M}.cells.${Z}`,Y),plainText:Y}}),id:Z0("tableRow",M,String($.cells.length))}}function e4($,M){switch($.type){case"break":return{id:Z0("break",M,"break"),type:"break"};case"image":return{alt:$.alt,id:Z0("image",M,`${$.url}:${$.width??""}:${$.alt??""}`),title:$.title,type:"image",url:$.url,width:$.width};case"inlineCode":return{code:$.code,id:Z0("inlineCode",M,$.code),type:"inlineCode"};case"link":{let J=$.children.map((X,Y)=>e4(X,`${M}.children.${Y}`)),Z=q0(J);return{children:J,id:Z0("link",M,`${$.url}:${Z}`),title:$.title,type:"link",url:$.url}}case"text":return{id:Z0("text",M,`${$.text}:${$.marks.join(",")}`),marks:$.marks,text:$.text,type:"text"};case"unsupported":return{id:Z0("unsupported",M,$.source),originalType:$.originalType,source:$.source,type:"unsupported"}}}function P2($){return $.map((M)=>{switch(M.type){case"blockquote":return{...M,children:P2(M.children)};case"heading":case"paragraph":return T0(M,H8(M.children));case"list":return{...M,items:M.items.map((J)=>({...J,children:P2(J.children)}))};case"listItem":return{...M,children:P2(M.children)};case"table":return u0(M,M.rows.map((J)=>({...J,cells:J.cells.map((Z)=>({...Z,children:H8(Z.children)}))})));default:return M}})}function H8($){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=H8(Z.children);if(X.length===Z.children.length&&X.every((Y,Q)=>Y===Z.children[Q]))return M;if(X.length===0){M.splice(J,1);continue}return M[J]={...Z,children:X},M}return M}return M}function Z0($,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 z8($,M){E8($.blocks,M,F9(),H9())}function rZ($,M){E8($,M,F9(),H9())}function x1($,M){let J=null,Z={enterBlock(X){if(X.id===M)return J=X,"stop"}};if(Array.isArray($))rZ($,Z);else z8($,Z);return J}function E8($,M,J,Z){for(let[X,Y]of $.entries()){if(J.stopped)return;let Q=`${Z.pathPrefix}.${X}`,K={blockAncestors:Z.blockAncestors,depth:Z.depth,parentBlock:Z.parentBlock,path:Q},q=M.enterBlock?.(Y,K);if(r1(q,J))return;if(q!=="skip")switch(Y.type){case"list":_9(Y.items,Y,M,J,Z,Q);break;case"blockquote":case"listItem":_9(Y.children,Y,M,J,Z,Q);break;case"heading":case"paragraph":W8(Y.children,M,J,{block:Y,blockAncestors:[...Z.blockAncestors,Y],inlineAncestors:[],parentInline:null,pathPrefix:`${Q}.children`});break;case"table":cZ(Y,M,J,{blockAncestors:[...Z.blockAncestors,Y],pathPrefix:Q});break;case"code":case"directive":case"thematicBreak":case"unsupported":break}if(J.stopped)return;if(r1(M.leaveBlock?.(Y,K),J))return}}function W8($,M,J,Z){for(let[X,Y]of $.entries()){if(J.stopped)return;let Q=`${Z.pathPrefix}.${X}`,K={block:Z.block,blockAncestors:Z.blockAncestors,inlineAncestors:Z.inlineAncestors,parentInline:Z.parentInline,path:Q},q=M.enterInline?.(Y,K);if(r1(q,J))return;if(q!=="skip"){if(Y.type==="link")xZ(Y.children,Y,M,J,Z,Q)}if(J.stopped)return;if(r1(M.leaveInline?.(Y,K),J))return}}function F9(){return{stopped:!1}}function H9(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function _9($,M,J,Z,X,Y){E8($,J,Z,{blockAncestors:[...X.blockAncestors,M],depth:X.depth+1,parentBlock:M,pathPrefix:`${Y}.children`})}function xZ($,M,J,Z,X,Y){W8($,J,Z,{block:X.block,blockAncestors:X.blockAncestors,inlineAncestors:[...X.inlineAncestors,M],parentInline:M,pathPrefix:`${Y}.children`})}function cZ($,M,J,Z){for(let[X,Y]of $.rows.entries())for(let[Q,K]of Y.cells.entries()){if(J.stopped)return;let q=`${Z.pathPrefix}.rows.${X}.cells.${Q}`,D={blockAncestors:Z.blockAncestors,cellIndex:Q,path:q,row:Y,rowIndex:X,table:$},A=M.enterTableCell?.(K,D);if(r1(A,J))return;if(A!=="skip")W8(K.children,M,J,{block:$,blockAncestors:Z.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${q}.children`});if(J.stopped)return;if(r1(M.leaveTableCell?.(K,D),J))return}}function r1($,M){if($!=="stop")return!1;return M.stopped=!0,!0}var B8="text";function P8($){return $==="text"||$==="code"||$==="tableCell"}function y8($){return $===B8?void 0:$}function E9($){switch($){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function $5($){let M=[];return z8($,{enterBlock(J){switch(J.type){case"heading":case"paragraph":M.push({containerKind:"text",containerOrdinal:M.length,id:J.id,text:q0(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:q0(J.children)})}}),M}function b8($,M,J){return{prefix:$.slice(Math.max(0,M-z9),M),suffix:$.slice(J,Math.min($.length,J+z9))}}function y2($,M,J){let Z=O0(M,0,$.text.length),X=O0(J,Z,$.text.length),{prefix:Y,suffix:Q}=b8($.text,Z,X);return{kind:y8($.containerKind),prefix:Y||void 0,suffix:Q||void 0}}function b2($,M,J){let Z=O0(M,0,$.text.length),X=O0(J,Z,$.text.length);return $.text.slice(Z,X)}function v0($,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 c1($,M,J){if(M.length===0||J.length===0)return[];let Z=[];for(let X of v0($,M)){let Y=X+M.length,Q=$.indexOf(J,Y);if(Q!==-1)Z.push({startOffset:Y,endOffset:Q})}return Z}function w8($,M,J){if(!M)return!1;return $.slice(Math.max(0,J-M.length),J)===M}function T8($,M,J){if(!M)return!1;return $.slice(J,J+M.length)===M}var z9=24;function O0($,M,J){return Math.min(Math.max($,M),J)}var W9=48,B9=64,aZ=32;function w2($,M){let J=$.anchor.kind??B8,Z=$5(M).filter((Q)=>Q.containerKind===J),X=sZ($,Z);if(X.length>0)return P9($,X,null);let Y=iZ($,Z);if(Y.length>0)return P9($,Y,"repaired");return{match:null,repair:null,status:"stale"}}function sZ($,M){let J=[],Z=$.quote;if(Z.length===0)return J;for(let X of M)for(let Y of v0(X.text,Z))J.push({container:X,endOffset:Y+Z.length,score:tZ($,X,Y),startOffset:Y});return J.sort((X,Y)=>Y.score-X.score),J}function iZ($,M){let J=[];for(let Z of M)J.push(...oZ($,Z));return J.sort((Z,X)=>X.score-Z.score),J}function oZ($,M){let J=[],Z=$.quote.length,X=M.text,Y=$.anchor.prefix??"",Q=$.anchor.suffix??"";if(Y.length>0&&Q.length>0){for(let K of c1(X,Y,Q))J.push({container:M,endOffset:K.endOffset,score:O8($,M,K.startOffset,K.endOffset,Z),startOffset:K.startOffset});return J}if(Y.length>0){for(let K of v0(X,Y)){let q=K+Y.length,D=O0(q+Z,q,X.length);J.push({container:M,endOffset:D,score:O8($,M,q,D,Z),startOffset:q})}return J}if(Q.length>0)for(let K of v0(X,Q)){let q=K,D=O0(q-Z,0,q);J.push({container:M,endOffset:q,score:O8($,M,D,q,Z),startOffset:D})}return J}function P9($,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 Y=y2(Z.container,Z.startOffset,Z.endOffset),Q=b2(Z.container,Z.startOffset,Z.endOffset),K=J??(Q===$.quote&&(Y.prefix??"")===($.anchor.prefix??"")&&(Y.suffix??"")===($.anchor.suffix??"")?"matched":"repaired");return{match:nZ(Z.container,Z.startOffset,Z.endOffset),repair:{anchor:Y,quote:Q},status:K}}function nZ($,M,J){return{containerId:$.id,containerKind:$.containerKind,containerOrdinal:$.containerOrdinal,endOffset:J,startOffset:M}}function tZ($,M,J){let Z=0;if(w8(M.text,$.anchor.prefix,J))Z+=W9;if(T8(M.text,$.anchor.suffix,J+$.quote.length))Z+=W9;return Z}function O8($,M,J,Z,X){let Y=0;if(w8(M.text,$.anchor.prefix,J))Y+=B9;if(T8(M.text,$.anchor.suffix,Z))Y+=B9;if(Y+=Math.max(0,aZ-Math.abs(X-(Z-J))),$.quote.length>0){let Q=M.text.slice(J,Z);if(Q.length>0)Y+=eZ($.quote,Q),Y+=$X($.quote,Q)}return Y}function eZ($,M){let J=0;while(J<$.length&&J<M.length&&$[J]===M[J])J+=1;return J}function $X($,M){let J=0;while(J<$.length&&J<M.length&&$[$.length-1-J]===M[M.length-1-J])J+=1;return J}function j8($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$,J=JX(M.anchor),Z=typeof M.quote==="string"?M.quote:null,X=Array.isArray(M.comments)?M.comments.flatMap((Y)=>{let Q=MX(Y);return Q?[Q]:[]}):[];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 MX($){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 JX($){if(!$||typeof $!=="object"||Array.isArray($))return null;let{kind:M,prefix:J,suffix:Z}=$;if("kind"in $&&!P8(M)||"prefix"in $&&typeof J!=="string"||"suffix"in $&&typeof Z!=="string")return null;return{kind:P8(M)?y8(M):void 0,prefix:typeof J==="string"?J:void 0,suffix:typeof Z==="string"?Z:void 0}}function L8($){let M=$.createdAt??new Date().toISOString();return{comments:[y9({body:$.body,updatedAt:M})],quote:$.quote,anchor:$.anchor}}function C8($,M){let J=y9(M);return{...$,comments:[...$.comments,J]}}function R8($,M,J,Z=new Date().toISOString()){let X=J.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:Z}});if(!Y)return $;return{...$,comments:Q}}function f8($,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 m8($,M,J=new Date().toISOString()){if(J1($)===M)return $;return{...$,resolvedAt:M?J:void 0}}function J1($){return $.resolvedAt!=null}function S8($){return $.filter((M)=>J1(M)).length}function k8($){if($.comments.length===0)return null;return $.comments.reduce((M,J)=>J.updatedAt>M?J.updatedAt:M,$.comments[0].updatedAt)}function y9($){let M=$.updatedAt??new Date().toISOString();return{body:$.body,updatedAt:M}}var ZX=240,XX=0.5625,YX=120,b9=48;function M5($,M,J){let Z=$.image?M.images.get($.image.url)??null:null,X=$.image?.width??null,Y=Math.min(J,X??ZX),Q=Math.max(YX,Math.round(Y*XX));if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return{height:Q,width:Y};let K=Math.min(J,X??Z.intrinsicWidth),q=Math.min(1,K/Z.intrinsicWidth);return{height:Math.max(b9,Math.round(Z.intrinsicHeight*q)),width:Math.max(b9,Math.round(Z.intrinsicWidth*q))}}function J5($,M,J,Z){let X=$.documentIndex.regionIndex.get($.selection.anchor.regionId);if(!Z.image||!X)return null;let Y=j0(M.layout,X.id,Z.start);if(!Y)return null;let Q=Y.left+h0($,Y),K=Q+W0(Y,Z.start-Y.start)-Y.left,q=Q+W0(Y,Z.end-Y.start)-Y.left,{height:D}=M5(Z,J,Y.width),A=Y.top+Math.max(0,Math.floor((Y.height-D)/2));return{left:K,top:A,width:q-K,height:D}}function w9($,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}`}function B1(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function T9($,M,J){return T2($.preparedText,M,J,256)}function O9($,M,J){return T2($.measuredLines,M,J,512)}function j9($,M,J){return T2($.lineBoundaries,M,J,1024)}function L9($,M,J){return T2($.measuredContainerHeights,M,J,1024)}function C9($,M){let J=$.graphemeWidths.get(M);if(J)return J;let Z=new Map;return T2($.graphemeWidths,M,Z,64),Z}function R9($,M,J){return $.viewportPlans.get(M)?.get(J)??null}function f9($,M,J,Z){let X=$.viewportPlans.get(M)??new Map;return X.set(J,Z),$.viewportPlans.set(M,X),Z}function T2($,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 QX=["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"],KX=["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 DX($){if($<=255)return QX[$];if(1424<=$&&$<=1524)return"R";if(1536<=$&&$<=1791)return KX[$&255];if(1792<=$&&$<=2220)return"AL";return"L"}function qX($){let M=$.length;if(M===0)return null;let J=Array(M),Z=0;for(let D=0;D<M;D++){let A=DX($.charCodeAt(D));if(A==="R"||A==="AL"||A==="AN")Z++;J[D]=A}if(Z===0)return null;let X=M/Z<0.3?0:1,Y=new Int8Array(M);for(let D=0;D<M;D++)Y[D]=X;let Q=X&1?"R":"L",K=Q,q=K;for(let D=0;D<M;D++)if(J[D]==="NSM")J[D]=q;else q=J[D];q=K;for(let D=0;D<M;D++){let A=J[D];if(A==="EN")J[D]=q==="AL"?"AN":"EN";else if(A==="R"||A==="L"||A==="AL")q=A}for(let D=0;D<M;D++)if(J[D]==="AL")J[D]="R";for(let D=1;D<M-1;D++){if(J[D]==="ES"&&J[D-1]==="EN"&&J[D+1]==="EN")J[D]="EN";if(J[D]==="CS"&&(J[D-1]==="EN"||J[D-1]==="AN")&&J[D+1]===J[D-1])J[D]=J[D-1]}for(let D=0;D<M;D++){if(J[D]!=="EN")continue;let A;for(A=D-1;A>=0&&J[A]==="ET";A--)J[A]="EN";for(A=D+1;A<M&&J[A]==="ET";A++)J[A]="EN"}for(let D=0;D<M;D++){let A=J[D];if(A==="WS"||A==="ES"||A==="ET"||A==="CS")J[D]="ON"}q=K;for(let D=0;D<M;D++){let A=J[D];if(A==="EN")J[D]=q==="L"?"L":"EN";else if(A==="R"||A==="L")q=A}for(let D=0;D<M;D++){if(J[D]!=="ON")continue;let A=D+1;while(A<M&&J[A]==="ON")A++;let V=D>0?J[D-1]:K,U=A<M?J[A]:K,G=V!=="L"?"R":"L";if(G===(U!=="L"?"R":"L"))for(let N=D;N<A;N++)J[N]=G;D=A-1}for(let D=0;D<M;D++)if(J[D]==="ON")J[D]=Q;for(let D=0;D<M;D++){let A=J[D];if((Y[D]&1)===0){if(A==="R")Y[D]++;else if(A==="AN"||A==="EN")Y[D]+=2}else if(A==="L"||A==="AN"||A==="EN")Y[D]++}return Y}function m9($,M){let J=qX($);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 AX=/[ \t\n\r\f]+/g,UX=/[\t\n\r\f]| {2,}|^ | $/;function VX($){let M=$??"normal";return M==="pre-wrap"?{mode:M,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:M,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function GX($){if(!UX.test($))return $;let M=$.replace(AX," ");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 NX($){if(!/[\r\f]/.test($))return $.replace(/\r\n/g,`
|
|
1
|
+
import{useEffect as h2,useEffectEvent as k2,useLayoutEffect as pA,useMemo as M1,useRef as r1,useState as k9}from"react";function x0($){let Y=X0($.children);return{children:$.children,id:U0($.path,"paragraph",Y),plainText:Y,type:"paragraph"}}function i($){return x0({children:r9(void 0,$.text)})}function H5($){let Y=X0($.children);return{children:$.children,depth:$.depth,id:U0($.path,"heading",`${$.depth}:${Y}`),plainText:Y,type:"heading"}}function t1($){return H5({children:r9(void 0,$.text),depth:$.depth})}function q1($){let Y=$.marks??[];return{id:U0($.path,"text",`${$.text}:${Y.join(",")}`),marks:Y,text:$.text,type:"text"}}function l0($={}){return{id:U0($.path,"lineBreak","lineBreak"),type:"lineBreak"}}function e1($){return{code:$.code,id:U0($.path,"code",$.code),type:"code"}}function $2($){return{children:$.children,id:U0($.path,"link",`${$.url}:${X0($.children)}`),title:$.title??null,type:"link",url:$.url}}function j1($){let Y=$.alt??null,X=$.width??null;return{alt:Y,id:U0($.path,"image",`${$.url}:${X??""}:${Y??""}`),title:$.title??null,type:"image",url:$.url,width:X}}function z5($){return{id:U0($.path,"raw",$.source),originalType:$.originalType,source:$.source,type:"raw"}}function w1($){let Y=C1($.children);return{checked:$.checked??null,children:$.children,id:U0($.path,"listItem",Y),plainText:Y,spread:$.spread??!1,type:"listItem"}}function O1($){let Y=$.items.map((X)=>X.plainText).join(`
|
|
2
|
+
`);return{id:U0($.path,"list",`${String($.ordered)}:${Y}`),items:$.items,ordered:$.ordered,plainText:Y,spread:$.spread??!1,start:$.start??null,type:"list"}}function R0($){let Y=C1($.children);return{children:$.children,id:U0($.path,"blockquote",Y),plainText:Y,type:"blockquote"}}function t6($){return{id:U0($.path,"code",`${$.language??""}:${$.source}`),language:$.language??null,meta:$.meta??null,plainText:$.source,source:$.source,type:"code"}}function D1($){let Y=X0($.children);return{children:$.children,id:U0($.path,"tableCell",Y),plainText:Y}}function Y2($){return{cells:$.cells,id:U0($.path,"tableRow",String($.cells.length))}}function B1($){let Y=$.rows.map((X)=>X.cells.map((Z)=>Z.plainText).join(" | ")).join(`
|
|
3
|
+
`);return{align:$.align??[],id:U0($.path,"table",Y),plainText:Y,rows:$.rows,type:"table"}}function F5(){return{id:"",plainText:"",type:"divider"}}function e6($){return{id:U0($.path,"raw",$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"raw"}}function a9($){return{attributes:$.attributes,body:$.body,id:U0($.path,"directive",`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"}}function Z0($){let Y=[];for(let X of $){let Z=Y.at(-1);if(Z?.type==="text"&&X.type==="text"&&Z.marks.join(",")===X.marks.join(",")){Y[Y.length-1]=q1({marks:Z.marks,path:Z.id,text:Z.text+X.text});continue}Y.push(X)}return Y}function O0($,Y){return $.type==="heading"?H5({children:Y,depth:$.depth}):x0({children:Y})}function d0($,Y){return w1({checked:$.checked,children:Y,spread:$.spread})}function M0($,Y,X={}){return O1({items:Y,ordered:X.ordered??$.ordered,spread:X.spread??$.spread,start:X.start??$.start})}function B0($,Y){return B1({align:$.align,rows:Y})}function g2($,Y){return t6({language:$.language,meta:$.meta,source:Y})}function I2($,Y){return e6({originalType:$.originalType,source:Y})}function r9($,Y){return Y.length>0?[q1({path:$?`${$}.children.0`:void 0,text:Y})]:[]}function U0($,Y,X){return $?J0(Y,$,X):""}function $8($,Y){Y8($.blocks,Y,i9(),o9())}function NK($,Y){Y8($,Y,i9(),o9())}function c0($,Y){let X=null,Z={enterBlock(J){if(J.id===Y)return X=J,"stop"}};if(Array.isArray($))NK($,Z);else $8($,Z);return X}function Y8($,Y,X,Z){for(let[J,K]of $.entries()){if(X.stopped)return;let Q=`${Z.pathPrefix}.${J}`,M={blockAncestors:Z.blockAncestors,depth:Z.depth,parentBlock:Z.parentBlock,path:Q},D=Y.enterBlock?.(K,M);if(X2(D,X))return;if(D!=="skip")switch(K.type){case"list":s9(K.items,K,Y,X,Z,Q);break;case"blockquote":case"listItem":s9(K.children,K,Y,X,Z,Q);break;case"heading":case"paragraph":X8(K.children,Y,X,{block:K,blockAncestors:[...Z.blockAncestors,K],inlineAncestors:[],parentInline:null,pathPrefix:`${Q}.children`});break;case"table":_K(K,Y,X,{blockAncestors:[...Z.blockAncestors,K],pathPrefix:Q});break;case"code":case"directive":case"divider":case"raw":break}if(X.stopped)return;if(X2(Y.leaveBlock?.(K,M),X))return}}function X8($,Y,X,Z){for(let[J,K]of $.entries()){if(X.stopped)return;let Q=`${Z.pathPrefix}.${J}`,M={block:Z.block,blockAncestors:Z.blockAncestors,inlineAncestors:Z.inlineAncestors,parentInline:Z.parentInline,path:Q},D=Y.enterInline?.(K,M);if(X2(D,X))return;if(D!=="skip"){if(K.type==="link")AK(K.children,K,Y,X,Z,Q)}if(X.stopped)return;if(X2(Y.leaveInline?.(K,M),X))return}}function i9(){return{stopped:!1}}function o9(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function s9($,Y,X,Z,J,K){Y8($,X,Z,{blockAncestors:[...J.blockAncestors,Y],depth:J.depth+1,parentBlock:Y,pathPrefix:`${K}.children`})}function AK($,Y,X,Z,J,K){X8($,X,Z,{block:J.block,blockAncestors:J.blockAncestors,inlineAncestors:[...J.inlineAncestors,Y],parentInline:Y,pathPrefix:`${K}.children`})}function _K($,Y,X,Z){for(let[J,K]of $.rows.entries())for(let[Q,M]of K.cells.entries()){if(X.stopped)return;let D=`${Z.pathPrefix}.rows.${J}.cells.${Q}`,q={blockAncestors:Z.blockAncestors,cellIndex:Q,path:D,row:K,rowIndex:J,table:$},U=Y.enterTableCell?.(M,q);if(X2(U,X))return;if(U!=="skip")X8(M.children,Y,X,{block:$,blockAncestors:Z.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${D}.children`});if(X.stopped)return;if(X2(Y.leaveTableCell?.(M,q),X))return}}function X2($,Y){if($!=="stop")return!1;return Y.stopped=!0,!0}function Z2($,Y,X="root",Z=null){let J=!1,K=[];for(let[Q,M]of $.entries()){let D=`${X}.${Q}`,q=Y(M,{parent:Z,path:D,recurse:()=>HK(M,Y,`${D}.children`)});if(q===null){J=!0;continue}if(Array.isArray(q)){J=!0,K.push(...q);continue}if(q!==M)J=!0;K.push(q)}return J?K:$}function HK($,Y,X){switch($.type){case"blockquote":case"listItem":{let Z=Z2($.children,Y,X,$);return Z===$.children?$:{...$,children:Z}}case"list":{let Z=Z2($.items,Y,X,$);return Z===$.items?$:{...$,items:Z}}default:return $}}function J2($,Y=[],X){return{blocks:$.map((Z,J)=>J8(Z,J)),comments:Y,frontMatter:X}}function L1($,Y,X,Z){let J=Z.map((M,D)=>J8(M,Y+D)),K=$.blocks.slice(Y+X),Q=Z.length===X?K:K.map((M,D)=>J8(M,Y+J.length+D));return{blocks:[...$.blocks.slice(0,Y),...J,...Q],comments:$.comments,frontMatter:$.frontMatter}}function t9($,Y,X,Z){return{blocks:$.blocks,comments:[...$.comments.slice(0,Y),...Z,...$.comments.slice(Y+X)],frontMatter:$.frontMatter}}function e9($,Y,X,Z){if(Z!==void 0)return n9($,Z,Y,X);for(let J=0;J<$.blocks.length;J+=1){let K=n9($,J,Y,X);if(K)return K}return null}function n9($,Y,X,Z){let J=$.blocks[Y];if(!J)return null;let K=$7(J,X,Z);return K?L1($,Y,1,[K]):null}function $7($,Y,X){if($.id===Y)return X($);switch($.type){case"blockquote":{let Z=Z8($.children,Y,X);return Z?R0({children:Z}):null}case"listItem":{let Z=Z8($.children,Y,X);return Z?d0($,Z):null}case"list":{let Z=Z8($.items,Y,X);return Z?M0($,Z):null}default:return null}}function Z8($,Y,X){let Z=!1,J=$.map((K)=>{let Q=$7(K,Y,X);if(!Q)return K;return Z=!0,Q});return Z?J:null}function X0($){return $.map((Y)=>{switch(Y.type){case"lineBreak":return`
|
|
4
|
+
`;case"image":return Y.alt??"";case"code":return Y.code;case"link":return X0(Y.children);case"text":return Y.text;case"raw":return Y.source}}).join("")}function C1($){return $.map((Y)=>{switch(Y.type){case"blockquote":case"listItem":return C1(Y.children);case"code":return Y.source;case"directive":return Y.body;case"heading":case"paragraph":return X0(Y.children);case"list":return Y.items.map((X)=>X.plainText).join(`
|
|
5
|
+
`);case"table":return Y.rows.map((X)=>X.cells.map((Z)=>Z.plainText).join(" | ")).join(`
|
|
6
|
+
`);case"divider":return"";case"raw":return Y.source}}).join(`
|
|
7
|
+
`).trim()}function Q8($){return $.every((Y)=>Y.type==="text"&&Y.marks.length===0)}function P5($){if($.length!==1)return!1;let Y=$[0];return Y.type==="paragraph"&&Q8(Y.children)}function Y7($){switch($.kind){case"text":return $.text;case"inlines":return X0($.inlines);case"blocks":return C1($.blocks)}}function _0($){switch($.type){case"blockquote":case"listItem":return $.children;case"list":return $.items;default:return null}}function R1($,Y){if(Y.length===0)return null;switch($.type){case"blockquote":return R0({children:Y});case"list":return M0($,Y);case"listItem":return d0($,Y);default:return null}}function J8($,Y){return E5($,`root.${Y}`)}function E5($,Y){switch($.type){case"blockquote":{let X=$.children.map((J,K)=>E5(J,`${Y}.children.${K}`)),Z=C1(X);return{children:X,id:J0("blockquote",Y,Z),plainText:Z,type:"blockquote"}}case"code":return{id:J0("code",Y,`${$.language??""}:${$.source}`),language:$.language,meta:$.meta,plainText:$.source,source:$.source,type:"code"};case"directive":return{attributes:$.attributes,body:$.body,id:J0("directive",Y,`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"};case"heading":{let X=$.children.map((J,K)=>W5(J,`${Y}.children.${K}`)),Z=X0(X);return{children:X,depth:$.depth,id:J0("heading",Y,`${$.depth}:${Z}`),plainText:Z,type:"heading"}}case"list":{let X=$.items.map((J,K)=>E5(J,`${Y}.children.${K}`)),Z=X.map((J)=>J.plainText).join(`
|
|
8
|
+
`);return{id:J0("list",Y,`${String($.ordered)}:${Z}`),items:X,ordered:$.ordered,plainText:Z,spread:$.spread,start:$.start,type:"list"}}case"listItem":{let X=$.children.map((J,K)=>E5(J,`${Y}.children.${K}`)),Z=C1(X);return{checked:$.checked,children:X,id:J0("listItem",Y,Z),plainText:Z,spread:$.spread,type:"listItem"}}case"paragraph":{let X=$.children.map((J,K)=>W5(J,`${Y}.children.${K}`)),Z=X0(X);return{children:X,id:J0("paragraph",Y,Z),plainText:Z,type:"paragraph"}}case"table":{let X=$.rows.map((J,K)=>zK(J,`${Y}.rows.${K}`)),Z=X.map((J)=>J.cells.map((K)=>K.plainText).join(" | ")).join(`
|
|
9
|
+
`);return{align:$.align,id:J0("table",Y,Z),plainText:Z,rows:X,type:"table"}}case"divider":return{id:J0("divider",Y,"divider"),plainText:"",type:"divider"};case"raw":return{id:J0("raw",Y,$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"raw"}}}function zK($,Y){return{cells:$.cells.map((X,Z)=>{let J=X.children.map((Q,M)=>W5(Q,`${Y}.cells.${Z}.children.${M}`)),K=X0(J);return{children:J,id:J0("tableCell",`${Y}.cells.${Z}`,K),plainText:K}}),id:J0("tableRow",Y,String($.cells.length))}}function W5($,Y){switch($.type){case"lineBreak":return{id:J0("lineBreak",Y,"lineBreak"),type:"lineBreak"};case"image":return{alt:$.alt,id:J0("image",Y,`${$.url}:${$.width??""}:${$.alt??""}`),title:$.title,type:"image",url:$.url,width:$.width};case"code":return{code:$.code,id:J0("code",Y,$.code),type:"code"};case"link":{let X=$.children.map((J,K)=>W5(J,`${Y}.children.${K}`)),Z=X0(X);return{children:X,id:J0("link",Y,`${$.url}:${Z}`),title:$.title,type:"link",url:$.url}}case"text":return{id:J0("text",Y,`${$.text}:${$.marks.join(",")}`),marks:$.marks,text:$.text,type:"text"};case"raw":return{id:J0("raw",Y,$.source),originalType:$.originalType,source:$.source,type:"raw"}}}function X7($){return Z2($,(Y,{recurse:X})=>{switch(Y.type){case"blockquote":case"list":case"listItem":return X();case"heading":case"paragraph":return O0(Y,K8(Y.children));case"table":return B0(Y,Y.rows.map((Z)=>({...Z,cells:Z.cells.map((J)=>({...J,children:K8(J.children)}))})));default:return Y}})}function K8($){let Y=null,X=()=>Y??=[...$];for(let Z=$.length-1;Z>=0;Z-=1){let J=$[Z];if(J.type==="text"){let K=J.text.replace(/[ \t]+$/u,"");if(K.length===J.text.length)return Y??$;let Q=X();if(K.length===0){Q.splice(Z,1);continue}return Q[Z]={...J,text:K},Q}if(J.type==="link"){let K=K8(J.children);if(K===J.children)return Y??$;let Q=X();if(K.length===0){Q.splice(Z,1);continue}return Q[Z]={...J,children:K},Q}return Y??$}return Y??$}function J0($,Y,X){let Z=2166136261;for(let J of`${$}:${Y}:${X}`)Z^=J.charCodeAt(0),Z=Math.imul(Z,16777619);return`${$}-${(Z>>>0).toString(36)}`}var M8="text";function q8($){return $==="text"||$==="code"||$==="tableCell"}function D8($){return $===M8?void 0:$}function J7($){switch($){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function y5($){let Y=[];return $8($,{enterBlock(X){switch(X.type){case"heading":case"paragraph":Y.push({containerKind:"text",containerOrdinal:Y.length,id:X.id,text:X0(X.children)});break;case"code":Y.push({containerKind:"code",containerOrdinal:Y.length,id:X.id,text:X.source});break}},enterTableCell(X){Y.push({containerKind:"tableCell",containerOrdinal:Y.length,id:X.id,text:X0(X.children)})}}),Y}function U8($,Y,X){return{prefix:$.slice(Math.max(0,Y-Z7),Y),suffix:$.slice(X,Math.min($.length,X+Z7))}}function p2($,Y,X){let Z=b0(Y,0,$.text.length),J=b0(X,Z,$.text.length),{prefix:K,suffix:Q}=U8($.text,Z,J);return{kind:D8($.containerKind),prefix:K||void 0,suffix:Q||void 0}}function x2($,Y,X){let Z=b0(Y,0,$.text.length),J=b0(X,Z,$.text.length);return $.text.slice(Z,J)}function a0($,Y){if(Y.length===0)return[];let X=[],Z=0;while(Z<=$.length){let J=$.indexOf(Y,Z);if(J===-1)break;X.push(J),Z=J+Math.max(1,Y.length)}return X}function K2($,Y,X){if(Y.length===0||X.length===0)return[];let Z=[];for(let J of a0($,Y)){let K=J+Y.length,Q=$.indexOf(X,K);if(Q!==-1)Z.push({startOffset:K,endOffset:Q})}return Z}function G8($,Y,X){if(!Y)return!1;return $.slice(Math.max(0,X-Y.length),X)===Y}function V8($,Y,X){if(!Y)return!1;return $.slice(X,X+Y.length)===Y}var Z7=24;function b0($,Y,X){return Math.min(Math.max($,Y),X)}var K7=48,Q7=64,FK=32;function l2($,Y){let X=$.anchor.kind??M8,Z=y5(Y).filter((Q)=>Q.containerKind===X),J=EK($,Z);if(J.length>0)return M7($,J,null);let K=WK($,Z);if(K.length>0)return M7($,K,"repaired");return{match:null,repair:null,status:"stale"}}function EK($,Y){let X=[],Z=$.quote;if(Z.length===0)return X;for(let J of Y)for(let K of a0(J.text,Z))X.push({container:J,endOffset:K+Z.length,score:TK($,J,K),startOffset:K});return X.sort((J,K)=>K.score-J.score),X}function WK($,Y){let X=[];for(let Z of Y)X.push(...PK($,Z));return X.sort((Z,J)=>J.score-Z.score),X}function PK($,Y){let X=[],Z=$.quote.length,J=Y.text,K=$.anchor.prefix??"",Q=$.anchor.suffix??"";if(K.length>0&&Q.length>0){for(let M of K2(J,K,Q))X.push({container:Y,endOffset:M.endOffset,score:N8($,Y,M.startOffset,M.endOffset,Z),startOffset:M.startOffset});return X}if(K.length>0){for(let M of a0(J,K)){let D=M+K.length,q=b0(D+Z,D,J.length);X.push({container:Y,endOffset:q,score:N8($,Y,D,q,Z),startOffset:D})}return X}if(Q.length>0)for(let M of a0(J,Q)){let D=M,q=b0(D-Z,0,D);X.push({container:Y,endOffset:D,score:N8($,Y,q,D,Z),startOffset:q})}return X}function M7($,Y,X){let[Z,J]=Y;if(!Z)return{match:null,repair:null,status:"stale"};if(J&&Z.score===J.score)return{match:null,repair:null,status:"ambiguous"};let K=p2(Z.container,Z.startOffset,Z.endOffset),Q=x2(Z.container,Z.startOffset,Z.endOffset),M=X??(Q===$.quote&&(K.prefix??"")===($.anchor.prefix??"")&&(K.suffix??"")===($.anchor.suffix??"")?"matched":"repaired");return{match:yK(Z.container,Z.startOffset,Z.endOffset),repair:{anchor:K,quote:Q},status:M}}function yK($,Y,X){return{containerId:$.id,containerKind:$.containerKind,containerOrdinal:$.containerOrdinal,endOffset:X,startOffset:Y}}function TK($,Y,X){let Z=0;if(G8(Y.text,$.anchor.prefix,X))Z+=K7;if(V8(Y.text,$.anchor.suffix,X+$.quote.length))Z+=K7;return Z}function N8($,Y,X,Z,J){let K=0;if(G8(Y.text,$.anchor.prefix,X))K+=Q7;if(V8(Y.text,$.anchor.suffix,Z))K+=Q7;if(K+=Math.max(0,FK-Math.abs(J-(Z-X))),$.quote.length>0){let Q=Y.text.slice(X,Z);if(Q.length>0)K+=jK($.quote,Q),K+=wK($.quote,Q)}return K}function jK($,Y){let X=0;while(X<$.length&&X<Y.length&&$[X]===Y[X])X+=1;return X}function wK($,Y){let X=0;while(X<$.length&&X<Y.length&&$[$.length-1-X]===Y[Y.length-1-X])X+=1;return X}function A8($){if(!$||typeof $!=="object"||Array.isArray($))return null;let Y=$,X=BK(Y.anchor),Z=typeof Y.quote==="string"?Y.quote:null,J=Array.isArray(Y.comments)?Y.comments.flatMap((K)=>{let Q=OK(K);return Q?[Q]:[]}):[];if(!X||!Z||J.length===0)return null;return{quote:Z,anchor:X,comments:J,resolvedAt:typeof Y.resolvedAt==="string"?Y.resolvedAt:void 0}}function OK($){if(!$||typeof $!=="object"||Array.isArray($))return null;let Y=$;if(typeof Y.body!=="string"||typeof Y.updatedAt!=="string")return null;return{body:Y.body,updatedAt:Y.updatedAt}}function BK($){if(!$||typeof $!=="object"||Array.isArray($))return null;let{kind:Y,prefix:X,suffix:Z}=$;if("kind"in $&&!q8(Y)||"prefix"in $&&typeof X!=="string"||"suffix"in $&&typeof Z!=="string")return null;return{kind:q8(Y)?D8(Y):void 0,prefix:typeof X==="string"?X:void 0,suffix:typeof Z==="string"?Z:void 0}}function _8($){let Y=$.createdAt??new Date().toISOString();return{comments:[q7({body:$.body,updatedAt:Y})],quote:$.quote,anchor:$.anchor}}function H8($,Y){let X=q7(Y);return{...$,comments:[...$.comments,X]}}function z8($,Y,X,Z=new Date().toISOString()){let J=X.trim();if(J.length===0)return $;let K=!1,Q=$.comments.map((M,D)=>{if(D!==Y||M.body===J)return M;return K=!0,{...M,body:J,updatedAt:Z}});if(!K)return $;return{...$,comments:Q}}function F8($,Y){let X=$.comments.filter((Z,J)=>J!==Y);if(X.length===$.comments.length)return $;if(X.length===0)return null;return{...$,comments:X}}function E8($,Y,X=new Date().toISOString()){if(U1($)===Y)return $;return{...$,resolvedAt:Y?X:void 0}}function U1($){return $.resolvedAt!=null}function W8($){return $.filter((Y)=>U1(Y)).length}function P8($){if($.comments.length===0)return null;return $.comments.reduce((Y,X)=>X.updatedAt>Y?X.updatedAt:Y,$.comments[0].updatedAt)}function q7($){let Y=$.updatedAt??new Date().toISOString();return{body:$.body,updatedAt:Y}}function D7($,Y,X,Z,J){let K=Z-X,Q=J-K;if(Z<=$)return{end:Y+Q,start:$+Q};if(X>=Y)return{end:Y,start:$};let M=Math.max(0,Math.min(X,Y)-$),D=Math.max(0,Y-Math.max(Z,$)),q=$<X?$:X;return{end:q+M+J+D,start:q}}function T8($,Y,X){let Z=X.trim();if(Z.length===0||Y.startOffset===Y.endOffset)return null;let J=$.regionIndex.get(Y.regionId)??null,K=J?y8($,J):null;if(!K)return null;return _8({anchor:p2(K,Y.startOffset,Y.endOffset),body:Z,quote:x2(K,Y.startOffset,Y.endOffset)})}function S0($){let Y="documentIndex"in $?$.documentIndex:$,X=T5(Y),Z=Y.document.comments,J=[...Z],K=[];for(let[Q,M]of Z.entries()){let D=l2(M,Y.document);if(!D.match)continue;let U=X.findBySemanticMatch(D.match.containerId,D.match.containerOrdinal)?.runtimeContainer??null;if(!U)continue;if(D.repair)J[Q]={...M,anchor:D.repair.anchor,quote:D.repair.quote};K.push({endOffset:D.match.endOffset,resolution:D,regionId:U.id,resolved:M.resolvedAt!=null,startOffset:D.match.startOffset,threadIndex:Q})}return{liveRanges:K,threads:J}}function j8($,Y,X,Z,J,K){if($.document.comments.length===0)return Y.document.comments;let Q=$.commentContainerIndex.get(X.semanticRegionId)??[],M=new Set(Q);if(Q.length===0)return Y.document.comments;let D=S0($),q=new Map(D.liveRanges.map((N)=>[N.threadIndex,N])),U=y8($,X),V=Q2(Y,X.path),G=V?y8(Y,V):null;if(!U||!G)return Y.document.comments;return Y.document.comments.map((N,A)=>{if(!M.has(A))return N;let _=q.get(A),z=_?.resolution.match??null;if(!_||!z||z.containerId!==U.id)return N;let F=D7(z.startOffset,z.endOffset,Z,J,K.length);return{...N,anchor:p2(G,F.start,F.end),quote:x2(G,F.start,F.end)}})}function y8($,Y){let X=CK($,Y);if(!X)return null;return{containerKind:X,containerOrdinal:-1,id:Y.semanticRegionId,text:Y.text}}function CK($,Y){if($.tableCellIndex.has(Y.id))return"tableCell";return J7(Y.blockType)}function j5($,Y){if(Y.length===0)return[];let X=T5($),Z=X.list();return Y.map((J)=>({...J,cursorPoint:LK(J,Z,X),viewport:null}))}function LK($,Y,X){if(!$.cursor)return null;let Z=RK(Y,$.cursor),J=bK(Z,$.cursor);if(J.length!==1)return null;let K=J[0],Q=X.resolveRuntimeContainer(K.container.id);if(!Q)return null;return{offset:Math.max(0,Math.min(K.offset,Q.text.length)),regionId:Q.id}}function RK($,Y){return Y.kind?$.filter((X)=>X.containerKind===Y.kind):$}function bK($,Y){if(Y.prefix&&Y.suffix)return SK($,Y.prefix,Y.suffix);if(Y.prefix)return U7($,Y.prefix,"after");if(Y.suffix)return U7($,Y.suffix,"before");return[]}function U7($,Y,X){let Z=[];for(let J of $)for(let K of a0(J.text,Y))Z.push({container:J,offset:X==="after"?K+Y.length:K});return Z}function SK($,Y,X){let Z=[];for(let J of $)for(let K of K2(J.text,Y,X))Z.push({container:J,offset:K.startOffset});return Z}var vK=48;function d2($,Y,X){let Z="documentIndex"in $?$.documentIndex:$;if(X.length===0)return[];return X.map((J)=>({...J,viewport:fK(Z,Y,J)}))}function fK($,Y,X){if(!X.cursorPoint)return{status:"unresolved"};let Z=v0(Y.layout,$,X.cursorPoint),J=Z?{bottom:Z.top+Z.height,top:Z.top}:Y.estimateRegionBounds(X.cursorPoint.regionId);if(!J)return{status:"unresolved"};return{scrollTop:hK(Y,J),status:mK(Y,J)}}function mK($,Y){let X=$.viewport.top,Z=X+$.viewport.height;if(Y.bottom<X)return"above";if(Y.top>Z)return"below";return"visible"}function hK($,Y){let X=Math.max(0,$.totalHeight-$.viewport.height),Z=Y.top-Math.min(vK,$.viewport.height/4);return Math.max(0,Math.min(X,Z))}function T5($){let Y=y5($.document),X=new Map(Y.map((J)=>[J.id,J])),Z=new Map($.regions.map((J)=>[J.semanticRegionId,J]));return{findBySemanticMatch(J,K){let Q=X.get(J)??Y[K]??null;if(!Q)return null;return{runtimeContainer:Z.get(Q.id)??null,semanticContainer:Q}},list(J){return J?Y.filter((K)=>K.containerKind===J):Y},resolveRuntimeContainer(J){return Z.get(J)??null}}}var c2="",G7=1e6;function a2($,Y,X){return`${$}:${Y}:${X}`}function M2($){let Y=XQ($),X=O8(Y.blocks.map((Z,J)=>s2(Z,J)));return B8(Y,X)}function s2($,Y){let X=[],Z=[],J=[],K=new Set,Q=0;function M(q,U,V,G,N=null){if(Z.length>0)J.push(`
|
|
10
|
+
`),Q+=1;let A=V.map((F)=>F.text).join(""),_=Q,z=_+A.length;J.push(A),Q=z;for(let F of V)if(F.image)K.add(F.image.url);Z.push({blockId:q.id,blockType:q.type,end:z,id:`${q.id}:${U}`,path:U,rootIndex:Y,inlines:V,semanticRegionId:G,start:_,tableCellPosition:N,text:A})}function D(q,U,V,G){let N={childBlockIds:[],depth:V,end:Q,id:q.id,parentBlockId:G,path:U,regionIds:[],rootIndex:Y,start:Q,type:q.type};switch(X.push(N),q.type){case"blockquote":case"listItem":for(let[A,_]of q.children.entries())N.childBlockIds.push(_.id),D(_,`${U}.children.${A}`,V+1,q.id);break;case"code":{M(q,`${U}.source`,[{end:q.source.length,id:`${q.id}:code`,image:null,inlineCode:!1,kind:"text",link:null,marks:[],originalType:null,start:0,text:q.source}],q.id),N.regionIds.push(Z.at(-1).id);break}case"heading":case"paragraph":M(q,`${U}.children`,w8(q.children),q.id),N.regionIds.push(Z.at(-1).id);break;case"list":for(let[A,_]of q.items.entries())N.childBlockIds.push(_.id),D(_,`${U}.children.${A}`,V+1,q.id);break;case"table":for(let[A,_]of q.rows.entries())for(let[z,F]of _.cells.entries())M(q,`${U}.rows.${A}.cells.${z}`,w8(F.children),F.id,{cellIndex:z,rowIndex:A}),N.regionIds.push(Z.at(-1).id);break;case"divider":break;case"directive":break;case"raw":M(q,`${U}.source`,[{end:q.source.length,id:`${q.id}:raw`,image:null,inlineCode:!1,kind:"raw",link:null,marks:[],originalType:q.originalType,start:0,text:q.source}],q.id),N.regionIds.push(Z.at(-1).id);break}N.end=Q}return D($,`root.${Y}`,0,null),{blockRange:{end:X.length,start:0},blocks:X,end:Q,imageUrls:K,length:Q,regionRange:Z.length>0?{end:Z.length,start:0}:void 0,regions:Z,rootIndex:Y,start:0,text:J.join("")}}function O8($,Y=null){let X=[],Z=0,J=0,K=0,Q=!1;for(let[M,D]of $.entries()){if(D.regions.length>0&&Q)K+=1;let q={...D,blockRange:{end:Z+D.blocks.length,start:Z},end:K+D.length,regionRange:D.regions.length>0?{end:J+D.regions.length,start:J}:void 0,start:K},U=Y?.[M];if(X.push(uK(U,D,q)?U:V7(D,q)),Z=q.blockRange.end,J=q.regionRange?.end??J,D.regions.length>0)K=q.end,Q=!0}return X}function q2($,Y,X,Z){let J=Y.blocks.length-($.roots.length-Z);if(J<0)throw Error("Editor model splice received an invalid replacement count.");if(X===$.roots.length&&J===1){let D=Y.blocks[X];if(D)return kK($,Y,D)}let K=J===Z,Q=[...$.roots.slice(0,X),...Y.blocks.slice(X,X+J).map((D,q)=>s2(D,X+q)),...K?$.roots.slice(X+Z):Y.blocks.slice(X+J).map((D,q)=>s2(D,X+J+q))],M=O8(Q,$.roots);return B8(Y,M,$)}function kK($,Y,X){let Z=$.roots.length,J=s2(X,Z),K=$.roots.some((U)=>U.regions.length>0),Q=J.regions.length>0&&K?$.length+1:$.length,M=V7(J,{...J,blockRange:{end:$.blocks.length+J.blocks.length,start:$.blocks.length},end:Q+J.length,regionRange:J.regions.length>0?{end:$.regions.length+J.regions.length,start:$.regions.length}:void 0,start:Q}),D=[...$.blocks,...M.blocks],q=[...$.regions,...M.regions];return{blockIndex:lK($.blockIndex,M.blocks),blocks:D,commentContainerIndex:Y.comments===$.document.comments?$.commentContainerIndex:N7(Y),document:Y,engine:"canvas",imageUrls:eK($.imageUrls,M.imageUrls),length:M.end,listItemMarkers:Y.blocks===$.document.blocks?$.listItemMarkers:iK($.listItemMarkers,X),regionIndex:dK($.regionIndex,M.regions),regionOrderIndex:cK($.regionOrderIndex,M.regions,$.regions.length),regionPathIndex:aK($.regionPathIndex,M.regions),regions:q,roots:[...$.roots,M],tableCellIndex:rK($.tableCellIndex,M.regions),tableCellRegionIndex:sK($.tableCellRegionIndex,M.regions),text:oK($.text,M)}}function w5($,Y){if(Y.blocks!==$.document.blocks)throw Error("Editor model document replacement requires preserving root blocks.");return B8(Y,$.roots,$)}function O5($,Y,X){let Z=$.blockIndex.get(Y);if(!Z)return null;return e9($.document,Y,X,Z.rootIndex)}function B8($,Y,X=null){let Z=Y.flatMap((U)=>U.blocks),J=Y.flatMap((U)=>U.regions),{regionIndex:K,regionOrderIndex:Q,regionPathIndex:M,tableCellIndex:D,tableCellRegionIndex:q}=xK(J);return{blockIndex:pK(Z),blocks:Z,commentContainerIndex:$.comments===X?.document.comments?X.commentContainerIndex:N7($),document:$,engine:"canvas",imageUrls:tK(Y,X?.imageUrls),length:Y.at(-1)?.end??0,listItemMarkers:$.blocks===X?.document.blocks?X.listItemMarkers:YQ($.blocks),regionIndex:K,regionOrderIndex:Q,regionPathIndex:M,regions:J,roots:Y,tableCellIndex:D,tableCellRegionIndex:q,text:nK(Y)}}function V7($,Y){let X=Y.start-$.start;return{...Y,blocks:X===0?$.blocks:gK($.blocks,X),regions:X===0?$.regions:IK($.regions,X)}}function uK($,Y,X){return Boolean($&&Y===$&&$.start===X.start&&$.end===X.end&&$.blockRange.start===X.blockRange.start&&$.blockRange.end===X.blockRange.end&&$.regionRange?.start===X.regionRange?.start&&$.regionRange?.end===X.regionRange?.end)}function gK($,Y){return $.map((X)=>({...X,end:X.end+Y,start:X.start+Y}))}function IK($,Y){return $.map((X)=>({...X,end:X.end+Y,start:X.start+Y}))}function pK($){let Y=new Map;for(let X of $)Y.set(X.id,X);return Y}function xK($){let Y=new Map,X=new Map,Z=new Map,J=new Map,K=new Map;for(let[Q,M]of $.entries()){if(Y.set(M.id,M),X.set(M.id,Q),Z.set(M.path,M),!M.tableCellPosition)continue;J.set(M.id,M.tableCellPosition),K.set(a2(M.blockId,M.tableCellPosition.rowIndex,M.tableCellPosition.cellIndex),M.id)}return{regionIndex:Y,regionOrderIndex:X,regionPathIndex:Z,tableCellIndex:J,tableCellRegionIndex:K}}function lK($,Y){let X=new Map($);for(let Z of Y)X.set(Z.id,Z);return X}function dK($,Y){let X=new Map($);for(let Z of Y)X.set(Z.id,Z);return X}function cK($,Y,X){let Z=new Map($);for(let[J,K]of Y.entries())Z.set(K.id,X+J);return Z}function aK($,Y){let X=new Map($);for(let Z of Y)X.set(Z.path,Z);return X}function rK($,Y){let X=new Map($);for(let Z of Y)if(Z.tableCellPosition)X.set(Z.id,Z.tableCellPosition);return X}function sK($,Y){let X=new Map($);for(let Z of Y){if(!Z.tableCellPosition)continue;X.set(a2(Z.blockId,Z.tableCellPosition.rowIndex,Z.tableCellPosition.cellIndex),Z.id)}return X}function iK($,Y){let X=new Map($);return r2(X,[Y]),X}function oK($,Y){if(Y.regions.length===0)return $;return $.length>0?`${$}
|
|
11
|
+
${Y.text}`:Y.text}function nK($){return $.filter((Y)=>Y.regions.length>0).map((Y)=>Y.text).join(`
|
|
12
|
+
`)}function tK($,Y){let X=new Set;for(let Z of $)for(let J of Z.imageUrls)X.add(J);return Y&&$Q(Y,X)?Y:X}function eK($,Y){if(Y.size===0)return $;let X=null;for(let Z of Y){if($.has(Z))continue;X??=new Set($),X.add(Z)}return X??$}function $Q($,Y){if($.size!==Y.size)return!1;for(let X of $)if(!Y.has(X))return!1;return!0}function N7($){let Y=new Map;for(let[X,Z]of $.comments.entries()){let J=l2(Z,$).match?.containerId??null;if(!J)continue;let K=Y.get(J)??[];K.push(X),Y.set(J,K)}return Y}function YQ($){let Y=new Map;return r2(Y,$),Y}function r2($,Y,X=null){for(let Z of Y){if(Z.type==="list"){for(let[J,K]of Z.items.entries())r2($,[K],{index:J,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(X?.ordered)$.set(Z.id,{kind:"ordered",label:`${(X.start??1)+X.index}.`});else $.set(Z.id,{kind:"bullet",label:"•"});r2($,Z.children,X)}if(Z.type==="blockquote")r2($,Z.children,X)}}function XQ($){if($.blocks.length>0)return $;return J2([i({text:""})],$.comments,$.frontMatter)}function w8($,Y=null){let X=[],Z=0,J=(K)=>{let Q=Z,M=Q+K.text.length;X.push({...K,end:M,start:Q}),Z=M};for(let K of $)switch(K.type){case"lineBreak":J({id:K.id,image:null,inlineCode:!1,kind:"lineBreak",link:Y,marks:[],originalType:null,text:`
|
|
13
|
+
`});break;case"image":J({id:K.id,image:{alt:K.alt,title:K.title,url:K.url,width:K.width},inlineCode:!1,kind:"image",link:Y,marks:[],originalType:null,text:ZQ(K.alt)});break;case"code":J({id:K.id,image:null,inlineCode:!0,kind:"code",link:Y,marks:[],originalType:null,text:K.code});break;case"link":for(let Q of w8(K.children,{title:K.title,url:K.url}))J(Q);break;case"text":J({id:K.id,image:null,inlineCode:!1,kind:"text",link:Y,marks:K.marks,originalType:null,text:K.text});break;case"raw":J({id:K.id,image:null,inlineCode:!1,kind:"raw",link:Y,marks:[],originalType:K.originalType,text:K.source});break}return X}function ZQ($){return c2}function W0($){switch($.type){case"lineBreak":return 1;case"image":return c2.length;case"code":return $.code.length;case"link":return X0($.children).length;case"text":return $.text.length;case"raw":return $.source.length}}function i2($,Y,X,Z,J){let K=[],Q=0,M=!1;for(let[D,q]of $.entries()){let U=`${Z}.${D}`,V=W0(q),G=Q,N=G+V;if(Q=N,X<=G||Y>=N){K.push(q);continue}if(!M)K.push(...JQ(q,Math.max(0,Y-G),U)),K.push(...J),M=!0;K.push(...KQ(q,Math.min(V,X-G),U))}if(!M)K.push(...J);return Z0(K)}function JQ($,Y,X){if(Y<=0)return[];return C8($,0,Y,`${X}.before`)}function KQ($,Y,X){let Z=W0($);if(Y>=Z)return[];return C8($,Y,Z,`${X}.after`)}function C8($,Y,X,Z){if(Y>=X)return[];switch($.type){case"text":return Z0([b1($.text.slice(Y,X),$.marks,Z)].filter(Boolean));case"code":return[R8($.code.slice(Y,X),Z)];case"link":{let J=Z0(QQ($.children,Y,X,`${Z}.children`));return J.length>0?[{...$,children:J}]:[]}default:return[]}}function L8($,Y,X){let Z=0,J="";for(let K of $){let Q=W0(K),M=Z,D=M+Q;if(Z=D,X<=M||Y>=D)continue;J+=MQ(K,Math.max(0,Y-M),Math.min(Q,X-M))}return J}function b1($,Y,X){if($.length===0)return null;return q1({marks:Y,path:X,text:$})}function R8($,Y){return e1({code:$,path:Y})}function QQ($,Y,X,Z){let J=[],K=0;for(let[Q,M]of $.entries()){let D=W0(M),q=K,U=q+D;if(K=U,X<=q||Y>=U)continue;J.push(...C8(M,Math.max(0,Y-q),Math.min(D,X-q),`${Z}.${Q}`))}return J}function MQ($,Y,X){if(Y>=X)return"";switch($.type){case"lineBreak":return`
|
|
14
|
+
`.slice(Y,X);case"image":return c2.slice(Y,X);case"code":return $.code.slice(Y,X);case"link":return L8($.children,Y,X);case"text":return $.text.slice(Y,X);case"raw":return $.source.slice(Y,X)}}function b8($,Y,X,Z){let J=qQ($.children,Y,X,Z);if(J===null)return null;let K=Z0(A7($.children,Y,X,Z,J,`${$.path}.children`));return K.length>0?S1($,K,Y,X):null}function S8($,Y,X){let Z=0,J=null,K=(Q)=>{for(let M of Q){let D=W0(M),q=Z,U=q+D;if(Z=U,X<=q||Y>=U)continue;if(M.type==="text"){let V=Math.max(Y,q);if(Math.min(X,U)>V)J=J===null?new Set(M.marks):new Set(M.marks.filter((N)=>J?.has(N)));continue}if(M.type==="link"){let V=Z;Z=q,K(M.children),Z=V}}};return K($.children),J?[...J]:[]}function qQ($,Y,X,Z){let J=0,K=!1,Q=!0,M=(D)=>{for(let q of D){let U=W0(q),V=J,G=V+U;if(J=G,X<=V||Y>=G)continue;if(q.type==="text"){let N=Math.max(Y,V);if(Math.min(X,G)>N)K=!0,Q&&=q.marks.includes(Z);continue}if(q.type==="link"){let N=J;J=V,M(q.children),J=N}}};return M($),K?Q:null}function A7($,Y,X,Z,J,K){let Q=[],M=0;for(let[D,q]of $.entries()){let U=M,V=W0(q),G=U+V,N=`${K}.${D}`;if(M=G,X<=U||Y>=G){Q.push(q);continue}if(q.type==="text"){Q.push(...DQ(q,Math.max(0,Y-U),Math.min(V,X-U),Z,J,N));continue}if(q.type==="link"){let A=Z0(A7(q.children,Math.max(0,Y-U),Math.min(V,X-U),Z,J,`${N}.children`));if(A.length>0)Q.push({...q,children:A});continue}Q.push(q)}return Q}function DQ($,Y,X,Z,J,K){let Q=$.text.slice(0,Y),M=$.text.slice(Y,X),D=$.text.slice(X),q=J?$.marks.filter((U)=>U!==Z):UQ($.marks,Z);return[b1(Q,$.marks,`${K}.before`),b1(M,q,`${K}.selected`),b1(D,$.marks,`${K}.after`)].filter(Boolean)}function UQ($,Y){return $.includes(Y)?$:[...$,Y].sort()}function v8($,Y,X){let Z=GQ($.children,Y,X,`${$.path}.children`);return Z.length>0?S1($,Z,Y,X):null}function GQ($,Y,X,Z){let J=_7($,Y,X);if(J){let Q=b1(J.code,[],`${Z}.selected`);return i2($,Y,X,Z,Q?[Q]:[])}let K=L8($,Y,X);if(K.length===0)return $;return i2($,Y,X,Z,[R8(K,`${Z}.selected`)])}function _7($,Y,X){let Z=0;for(let J of $){let K=W0(J),Q=Z,M=Q+K;if(Z=M,Y===Q&&X===M&&J.type==="code")return J;if(J.type==="link"){let D=_7(J.children,Math.max(0,Y-Q),Math.min(K,X-Q));if(D)return D}}return null}function B5($,Y,X,Z,J){return C5($,Y,X,Z,(K,Q,M)=>H7(K,Q,M,J))}function H7($,Y,X,Z){let J=Z0(VQ($.children,Y,X,Z,`${$.path}.children`)??[]);return J.length>0?S1($,J,Y,X):null}function VQ($,Y,X,Z,J){let K=[],Q=0,M=!1;for(let[D,q]of $.entries()){let U=`${J}.${D}`,V=W0(q),G=Q,N=G+V;if(Q=N,!M&&q.type==="link"&&Y===G&&X===N){if(Z===null)K.push(...q.children);else K.push($2({children:q.children,path:U,title:q.title,url:Z}));M=!0;continue}K.push(q)}return M?K:null}function D2($,Y){let X=$.regionIndex.get(Y);if(!X)return null;let Z=c0($.document.blocks,X.blockId);if(!Z)return null;return f8(Z,X.path,X.semanticRegionId)}function NQ($,Y,X,Z,J){if(X>=Z)return null;let K=D2($,Y);return K?J(K,X,Z):null}function C5($,Y,X,Z,J){let K=NQ($,Y,X,Z,J);return K?{kind:"replace-block",block:K.block,blockId:K.blockId,selection:K.selection}:null}function f8($,Y,X){if($.type==="heading"||$.type==="paragraph")return{block:$,children:$.children,kind:"inlineBlock",path:Y.replace(/\.children$/,"")};if($.type!=="table")return null;let Z=/^(.*\.rows\.\d+\.cells\.\d+)$/.exec(Y);if(!Z)return null;for(let J of $.rows)for(let K of J.cells)if(K.id===X)return{block:$,blockPath:Z[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:K,children:K.children,kind:"tableCell",path:Z[1]};return null}function m8($,Y,X){let Z=W7($,Y);if(!Z)return null;return{kind:"replace-block",...o2(Z.inlineRegion,Z.startOffset,Z.endOffset,X)}}function F7($,Y,X){let Z=W7($,Y);if(!Z)return null;return{kind:"replace-block",...E7(Z.inlineRegion,Z.startOffset,Z.endOffset,X)}}function E7($,Y,X,Z){let J=`${$.path}.children`,K=i2($.children,Y,X,J,Z),Q=Z.reduce((D,q)=>D+W0(q),0),M=Y+Q;return S1($,K,M,M)}function o2($,Y,X,Z){let J=Z(`${$.path}.children.selected`);return E7($,Y,X,[J])}function W7($,Y){let X=D2($,Y.focus.regionId);if(!X)return null;return{inlineRegion:X,startOffset:Math.min(Y.anchor.offset,Y.focus.offset),endOffset:Math.max(Y.anchor.offset,Y.focus.offset)}}function S1($,Y,X,Z){switch($.kind){case"inlineBlock":return{block:O0($.block,Y),blockId:$.block.id,selection:z7(`${$.path}.children`,X,Z)};case"tableCell":{let J=D1({children:Y,path:$.path}),K=$.block.rows.map((Q)=>({...Q,cells:Q.cells.map((M)=>M.id===$.cell.id?J:M)}));return{block:B0($.block,K),blockId:$.block.id,selection:z7($.path,X,Z)}}}}function z7($,Y,X){return{endOffset:X,kind:"region-range-path",path:$,startOffset:Y}}function H0($,Y,X=0){return{childIndices:Y,kind:"descendant-primary-region",offset:X,rootIndex:$}}function $0($,Y=0){return{kind:"root-primary-region",offset:Y,rootIndex:$}}function h8($,Y=0){return{kind:"region",offset:Y,regionId:$}}function v1($,Y,X,Z=0){return{cellIndex:X,kind:"table-cell",offset:Z,rootIndex:$,rowIndex:Y}}function P0($,Y){return $.regionIndex.get(Y)??null}function Q2($,Y){return $.regionPathIndex.get(Y)??null}function V2($,Y,X,Z){let J=$.tableCellRegionIndex.get(a2(Y,X,Z));return J?$.regionIndex.get(J)??null:null}function f1($,Y){let X=$.regionOrderIndex.get(Y);if(X===void 0||X===0)return null;return $.regions[X-1]??null}function n2($,Y){let X=$.regionOrderIndex.get(Y);if(X===void 0)return null;return $.regions[X+1]??null}function r0($){return $.regionIds.length===0&&!G1($)}function G1($){return $.type==="blockquote"||$.type==="list"||$.type==="listItem"}function k8($,Y){return y7($.blocks,Y,-1)}function t2($,Y){return y7($.blocks,Y,1)}function y7($,Y,X){let Z=$.findIndex((J)=>J.id===Y);if(Z===-1)return null;for(let J=Z+X;J>=0&&J<$.length;J+=X){let K=$[J];if(G1(K))continue;return K}return null}function u8($,Y){return $.roots[Y]?.regions[0]??null}function AQ($){return $.anchor.regionId===$.focus.regionId&&$.anchor.offset===$.focus.offset}function Y0($,Y){let X="documentIndex"in $?$.documentIndex:$,Z="documentIndex"in $?$.selection:Y,J=AQ(Z),K=P7(X,Z.anchor),Q=P7(X,Z.focus);if(K<=Q)return{collapsed:J,end:Z.focus,start:Z.anchor};return{collapsed:J,end:Z.anchor,start:Z.focus}}function e2($,Y){if(!Y)return null;if(Y.kind==="root-primary-region"){let Z=$.document.blocks[Y.rootIndex],J=Z?L5($,Z):null;return J?U2(J.id,G2(J.text,Y.offset)):null}if(Y.kind==="descendant-primary-region"){let Z=$.document.blocks[Y.rootIndex],J=Z?_Q(Z,Y.childIndices):null,K=J?L5($,J):null;return K?U2(K.id,G2(K.text,Y.offset)):null}if(Y.kind==="region"){let Z=P0($,Y.regionId);return Z?U2(Z.id,G2(Z.text,Y.offset)):null}if(Y.kind==="block-primary-region"){let Z=c0($.document,Y.blockId),J=Z?L5($,Z):null;return J?U2(J.id,G2(J.text,Y.offset)):null}if(Y.kind==="table-cell"){let Z=$.document.blocks[Y.rootIndex];if(!Z||Z.type!=="table")return null;let J=V2($,Z.id,Y.rowIndex,Y.cellIndex);return J?U2(J.id,G2(J.text,Y.offset)):null}let X=Q2($,Y.path);if(!X)return null;if(Y.kind==="region-path")return U2(X.id,G2(X.text,Y.offset));return{anchor:{regionId:X.id,offset:Math.max(0,Math.min(Y.startOffset,X.text.length))},focus:{regionId:X.id,offset:Math.max(0,Math.min(Y.endOffset,X.text.length))}}}function U2($,Y){let X={offset:Y,regionId:$};return{anchor:X,focus:X}}function P7($,Y){let X=$.regionOrderIndex.get(Y.regionId);if(X===void 0)throw Error(`Unknown canvas region: ${Y.regionId}`);return X*G7+Y.offset}function G2($,Y){return Y==="end"?$.length:Math.max(0,Math.min(Y,$.length))}function _Q($,Y){let X=$;for(let Z of Y){if(!X)return null;let J=_0(X);if(!J)return null;X=J[Z]??null}return X}function L5($,Y){let X=$.blockIndex.get(Y.id);if(!X)return null;let Z=X.regionIds[0];if(Z)return $.regionIndex.get(Z)??null;let J=_0(Y);if(!J)return null;for(let K of J){let Q=L5($,K);if(Q)return Q}return null}function $4($){let Y=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null,X=Y?$.documentIndex.blockIndex.get(Y.blockId)??null:null,Z=T7($);return{block:X?{blockId:X.id,depth:X.depth,nodeType:X.type,text:Y?.text??""}:null,span:Z?.link?{kind:"link",url:Z.link.url}:Z&&Z.marks.length>0?{kind:"marks",marks:Z.marks}:{kind:"none"}}}function R5($){let Y=T7($);return Y?.kind==="image"?Y:null}function b5($){let Y=Y0($.documentIndex,$.selection);if(Y.start.regionId!==Y.end.regionId||Y.start.offset===Y.end.offset)return[];let X=$.documentIndex.regionIndex.get(Y.start.regionId);if(!X)return[];let Z=c0($.documentIndex.document.blocks,X.blockId);if(!Z)return[];let J=f8(Z,X.path,X.semanticRegionId);return J?S8(J,Y.start.offset,Y.end.offset):[]}function T7($){let Y=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null;if(!Y)return null;let X=$.selection.anchor.offset;return Y.inlines.find((Z)=>X>Z.start&&X<Z.end)??Y.inlines.find((Z)=>Z.end===X)??Y.inlines.find((Z)=>Z.start===X)??null}var v5="rgba(0, 0, 0, 0)";function N2($,Y,X){let Z=j7($),J=j7(Y);return`rgba(${I8(S5(Z[0],J[0],X))}, ${I8(S5(Z[1],J[1],X))}, ${I8(S5(Z[2],J[2],X))}, ${S5(Z[3],J[3],X)})`}var g8=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function j7($){let Y=g8.get($);if(Y)return Y;let X=HQ($)??zQ($)??FQ($)??g8.get("rgba(0, 0, 0, 0)");return g8.set($,X),X}function HQ($){let Y=$.trim();if(!Y.startsWith("#"))return null;let X=Y.slice(1);if(X.length===3)return[Number.parseInt(`${X[0]}${X[0]}`,16),Number.parseInt(`${X[1]}${X[1]}`,16),Number.parseInt(`${X[2]}${X[2]}`,16),1];if(X.length===6)return[Number.parseInt(X.slice(0,2),16),Number.parseInt(X.slice(2,4),16),Number.parseInt(X.slice(4,6),16),1];return null}function zQ($){let Y=/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!Y)return null;return[Number(Y[1]),Number(Y[2]),Number(Y[3]),1]}function FQ($){let Y=/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!Y)return null;return[Number(Y[1]),Number(Y[2]),Number(Y[3]),Number(Y[4])]}function S5($,Y,X){return $+(Y-$)*X}function I8($){return Math.round($)}var EQ=300,WQ=180,PQ=1000,yQ=500,TQ=140,jQ=0.1,wQ=0.9,OQ=2,BQ=2;function Y4($){switch($.kind){case"active-block-flash":return EQ;case"deleted-text-fade":return WQ;case"inserted-text-highlight":return PQ;case"list-marker-pop":return yQ;case"punctuation-pulse":return TQ}}function p8($,Y){let X=Y??LQ();return $.animations.some((Z)=>X-Z.startedAt<Y4(Z))}function w7($,Y){return x8($,Y,"inserted-text-highlight",(X)=>X.regionPath)}function O7($,Y){return h7($,Y,"active-block-flash",(X)=>X.blockPath)}function B7($,Y){return x8($,Y,"deleted-text-fade",(X)=>X.regionPath)}function C7($,Y){return x8($,Y,"punctuation-pulse",(X)=>X.regionPath)}function L7($,Y){return h7($,Y,"list-marker-pop",(X)=>X.blockPath)}function R7($,Y,X){let Z=new Set([$,Y]);for(let J of X){if(J.endOffset<=$||J.startOffset>=Y)continue;Z.add(Math.max($,J.startOffset)),Z.add(Math.min(Y,J.endOffset))}return[...Z].sort((J,K)=>J-K)}function b7($,Y,X){return $.find((Z)=>Z.startOffset<X&&Z.endOffset>Y)??null}function S7($,Y,X){if(!Y)return $;return N2(X.insertHighlightText,$,Y.progress)}function v7($,Y){return N2($,v5,Y.progress)}function f5($,Y){return N2($,v5,Y.progress)}function f7($,Y){return N2(Y.insertHighlightText,v5,$.progress)}function m7($){let Y=Math.min(1,$.progress*OQ);return jQ+wQ*CQ(Y)}function X4($,Y,X){let Z=Math.max(0,Y.progress*BQ-1);return N2(X.insertHighlightText,$,Z)}function x8($,Y,X,Z){let J=new Map;for(let K of $.animations){if(K.kind!==X)continue;let Q=Y4(K),M=Y-K.startedAt;if(M>=Q)continue;let D={...K,progress:Math.max(0,Math.min(1,M/Q))},q=Z(K),U=J.get(q);if(U)U.push(D);else J.set(q,[D])}return J}function h7($,Y,X,Z){let J=new Map;for(let K of $.animations){if(K.kind!==X)continue;let Q=Y4(K),M=Y-K.startedAt;if(M>=Q)continue;J.set(Z(K),{...K,progress:Math.max(0,Math.min(1,M/Q))})}return J}function CQ($){return 1-(1-$)*(1-$)*(1-$)}function LQ(){return typeof performance<"u"?performance.now():Date.now()}function m5($,Y,X=m1()){if(Y<=0)return $;let Z=k5($);if(!Z)return $;let J=$.selection.focus.offset,K=Math.max(0,J-Y);if(J<=K)return $;return Z4($,{endOffset:J,kind:"inserted-text-highlight",regionPath:Z.path,startOffset:K,startedAt:X})}function k7($,Y,X,Z){let J=k5($);if(!J)return Y;let K=J.text.slice(X,Z);if(K.length===0)return Y;if(!J.inlines.some((M)=>M.start<=X&&M.end>=Z&&M.kind==="text"&&M.link===null&&M.marks.length===0))return Y;return Z4(Y,{kind:"deleted-text-fade",regionPath:J.path,startOffset:X,startedAt:m1(),text:K})}function u7($,Y=m1()){let X=k5($),Z=$.selection.focus.offset-1;if(!X||Z<0||X.text[Z]!==".")return $;return Z4($,{kind:"punctuation-pulse",offset:Z,regionPath:X.path,startedAt:Y})}function g7($,Y,X=m1()){return Z4($,{blockPath:Y,kind:"list-marker-pop",startedAt:X})}function I7($,Y,X=m1()){return Z4($,{blockPath:Y,kind:"active-block-flash",startedAt:X})}function l8($,Y){return $.filter((X)=>X.startedAt+Y4(X)>Y)}function m1(){return typeof performance<"u"?performance.now():Date.now()}function h5($,Y){let X=Math.max(-1/0,...$.animations.map((Z)=>Z.startedAt));return Y.animations.some((Z)=>Z.startedAt>X)}function p7($){let Y=k5($);return(Y?$.documentIndex.blockIndex.get(Y.blockId)??null:null)?.path??""}function k5($){return $.documentIndex.regionIndex.get($.selection.focus.regionId)??null}function Z4($,Y){let X=l8($.animations,Y.startedAt);return{...$,animations:[...X,Y]}}function A2($,Y,X,Z){return c8(_2($.inlines,Y,X,Z))}function _2($,Y,X,Z){let K=RQ($,Y,X,{didInsert:!1,generatedRunCount:0,replacementText:Z});return mQ(hQ(K))}function c8($){let Y=[];for(let X=0;X<$.length;X+=1){let Z=$[X];if(Z.link){let K=[],Q=Z.link;while(X<$.length&&a8($[X].link,Q)){let M=l7($[X]);if(M)K.push(M);X+=1}if(X-=1,K.length>0)Y.push($2({children:Z0(K),title:Q.title,url:Q.url}));continue}let J=l7(Z);if(J)Y.push(J)}return Z0(Y)}function RQ($,Y,X,Z){let J=[];for(let[K,Q]of $.entries()){if(!Z.didInsert&&Y===X&&Y===Q.start)d8(J,Z,x7($[K-1]??null,Q));if(X<=Q.start||Y>=Q.end){J.push(u5(Q));continue}let M=Math.max(0,Y-Q.start),D=Math.min(Q.text.length,X-Q.start),q=!Z.didInsert&&Z.replacementText.length>0?Z.replacementText:"",U=bQ(Q,M,D,q,Z);if(M!==D||q.length>0)Z.didInsert=!0;J.push(...U)}if(!Z.didInsert)d8(J,Z,x7($.at(-1)??null,null));return J}function bQ($,Y,X,Z,J){switch($.kind){case"text":case"code":case"raw":return SQ($,Y,X,Z);case"lineBreak":return vQ($,Y,X,Z,J);case"image":return fQ($,Y,X,Z)}}function SQ($,Y,X,Z){let J=$.text.slice(0,Y)+Z+$.text.slice(X);return J.length>0?[{...u5($),text:J}]:[]}function vQ($,Y,X,Z,J){if(Y===X)return[u5($)];let K=[];if(Z.length>0)d8(K,J,$.link);return K}function fQ($,Y,X,Z){if(Y===0&&X===$.text.length)return Z.length>0?[d7(Z,$.link,0)]:[];return[u5($)]}function d8($,Y,X){if(Y.replacementText.length===0){Y.didInsert=!0;return}$.push(d7(Y.replacementText,X,Y.generatedRunCount)),Y.generatedRunCount+=1,Y.didInsert=!0}function d7($,Y,X){return{id:`generated:${X}`,image:null,inlineCode:!1,kind:"text",link:Y,marks:[],originalType:null,text:$}}function x7($,Y){return $?.link&&Y?.link&&a8($.link,Y.link)?$.link:null}function u5($){return{id:$.id,image:$.image,inlineCode:$.inlineCode,kind:$.kind,link:$.link,marks:$.marks,originalType:$.originalType,text:$.text}}function mQ($){let Y=[],X=0;for(let Z of $){let J=X,K=J+Z.text.length;Y.push({...Z,end:K,start:J}),X=K}return Y}function hQ($){let Y=[];for(let X of $){let Z=Y.at(-1);if(Z&&kQ(Z,X)){Y[Y.length-1]={...Z,text:Z.text+X.text};continue}Y.push(X)}return Y}function kQ($,Y){return $.kind===Y.kind&&$.inlineCode===Y.inlineCode&&a8($.link,Y.link)&&gQ($.image,Y.image)&&$.originalType===Y.originalType&&$.marks.join(",")===Y.marks.join(",")}function l7($){switch($.kind){case"lineBreak":return l0();case"image":return $.image?uQ($.image):null;case"code":return e1({code:$.text});case"text":return $.text.length>0?q1({marks:$.marks,text:$.text}):null;case"raw":return z5({originalType:$.originalType??"raw",source:$.text})}}function uQ($){return j1({alt:$.alt,title:$.title,url:$.url,width:$.width})}function a8($,Y){return $?.url===Y?.url&&$?.title===Y?.title}function gQ($,Y){return $?.url===Y?.url&&$?.title===Y?.title&&$?.alt===Y?.alt&&$?.width===Y?.width}function s7($,Y,X){let Z=[],J=0,K={childIndices:[],offset:0},Q="",M=$!==null;if($)Z.push($),K=c7($);let D=0;if($&&Y.length>0){let q=Y[0];if(g5($)&&q.type==="paragraph"){let U=r8($,$.children,q.children);Z[Z.length-1]=U,K={childIndices:[],offset:U.plainText.length},D=1,Q=q.plainText}else if(a7($,q)){let U=r7($,q);Z[Z.length-1]=U,K=i7(U),D=1}}for(let q=D;q<Y.length;q+=1){let U=Y[q];Z.push(U),J=Z.length-1,K=c7(U)}if(X){let q=Z.length-1,U=Z[q]??null,V=D>=Y.length&&$!==null,G=null;if(U){if(!V&&U.type==="paragraph"&&g5(X)){if(G=r8(X,U.children,X.children),$===null&&Y.length===1)M=!0,Q=U.plainText}else if(V&&g5(U)&&g5(X))G=r8(U,U.children,X.children);else if(a7(U,X))G=r7(U,X),K={childIndices:[_0(U).length-1],offset:"end"}}else if($===null&&Y.length===0)M=!0;if(G)Z[q]=G;else Z.push(X)}return{blocks:Z,caretLocalIndex:J,caretChildIndices:K.childIndices,caretOffset:K.offset,startRegionInsertedText:Q,startRegionPreservedAtRoot0:M}}function J4($,Y,X){if($.type==="table")return null;if($.id===Y.blockId)return IQ($,Y,X);return o7($,(Z)=>xQ(Z,Y,X))}function K4($,Y,X){if($.type==="table")return null;if($.id===Y.blockId)return pQ($,Y,X);return o7($,(Z)=>lQ(Z,Y,X))}function h1($,Y){if($.id===Y.blockId)return!0;let X=_0($);return X!==null&&X.some((Z)=>h1(Z,Y))}function c7($){return _0($)?i7($):{childIndices:[],offset:$.plainText.length}}function i7($){return{childIndices:[_0($).length-1],offset:"end"}}function r8($,Y,X){return O0($,Z0([...Y,...X]))}function g5($){return $!==null&&($.type==="heading"||$.type==="paragraph")}function a7($,Y){return $.type===Y.type&&_0($)!==null}function r7($,Y){let X=_0($),Z=_0(Y);return R1($,[...X,...Z])}function IQ($,Y,X){if(X===0)return null;switch($.type){case"heading":case"paragraph":return O0($,A2(Y,X,Y.text.length,""));case"code":return g2($,Y.text.slice(0,X));case"raw":return I2($,Y.text.slice(0,X));default:return null}}function pQ($,Y,X){if(X===Y.text.length)return null;switch($.type){case"heading":case"paragraph":return O0($,A2(Y,0,X,""));case"code":return g2($,Y.text.slice(X));case"raw":return I2($,Y.text.slice(X));default:return null}}function o7($,Y){let X=_0($);return X?R1($,Y(X)):null}function xQ($,Y,X){let Z=$.findIndex((Q)=>h1(Q,Y));if(Z===-1)return[];let J=$.slice(0,Z),K=J4($[Z],Y,X);return K?[...J,K]:J}function lQ($,Y,X){let Z=$.findIndex((Q)=>h1(Q,Y));if(Z===-1)return[];let J=$.slice(Z+1),K=K4($[Z],Y,X);return K?[K,...J]:J}function t7($,Y,X){let Z=Y0($,Y);if(Z.start.regionId===Z.end.regionId)return dQ($,Z,X);let J=X.length>0?[i({text:X})]:[];return s8($,Y,J)}function s8($,Y,X){let Z=Y0($,Y),J=P0($,Z.start.regionId),K=P0($,Z.end.regionId);if(!J||!K)throw Error("Unknown selection endpoints.");let Q=$.document.blocks[J.rootIndex],M=$.document.blocks[K.rootIndex];if(!Q||!M)throw Error("Unknown root blocks for selection.");let D=J4(Q,J,Z.start.offset),q=K4(M,K,Z.end.offset),U=s7(D,X,q),V=U.blocks.length>0?U.blocks:[i({text:""})],G=J.rootIndex,N=K.rootIndex-J.rootIndex+1,A=L1($.document,G,N,V),_=q2($,A,G,N),z=J===K?Z.end.offset:J.text.length;return{documentIndex:U.startRegionPreservedAtRoot0?e7($,_,J,Z.start.offset,z,U.startRegionInsertedText):_,selection:H0(G+U.caretLocalIndex,U.caretChildIndices,U.caretOffset)}}function dQ($,Y,X){let Z=P0($,Y.start.regionId);if(!Z)throw Error(`Unknown region: ${Y.start.regionId}`);let J=O5($,Z.blockId,(D)=>cQ(D,Z,Y.start.offset,Y.end.offset,X));if(!J)throw Error(`Failed to replace block for region: ${Z.id}`);let K=q2($,J,Z.rootIndex,1),Q=e7($,K,Z,Y.start.offset,Y.end.offset,X),M=Q2(Q,Z.path);if(!M)throw Error(`Failed to remap region after replacement: ${Z.path}`);return{documentIndex:Q,selection:h8(M.id,Y.start.offset+X.length)}}function cQ($,Y,X,Z,J){switch($.type){case"heading":case"paragraph":return O0($,A2(Y,X,Z,J));case"code":return g2($,n7(Y,X,Z,J));case"table":return aQ($,Y,X,Z,J);case"raw":return I2($,n7(Y,X,Z,J));default:throw Error(`Region text replacement is not supported for block type: ${$.type}`)}}function aQ($,Y,X,Z,J){let K=Y.tableCellPosition?.rowIndex,Q=Y.tableCellPosition?.cellIndex;if(K===void 0||Q===void 0)throw Error(`Unable to resolve table cell position for region: ${Y.id}`);let M=A2(Y,X,Z,J),D=$.rows.map((q,U)=>{if(U!==K)return q;let V=q.cells.map((G,N)=>N===Q?D1({children:M}):G);return{...q,cells:V}});return B0($,D)}function n7($,Y,X,Z){return _2($.inlines,Y,X,Z).map((J)=>J.text).join("")}function e7($,Y,X,Z,J,K){if($.document.comments.length===0)return Y;let Q=j8($,Y,X,Z,J,K);return Q===Y.document.comments?Y:w5(Y,{...Y.document,comments:Q})}function M4($){let Y=M2($),X=Z$(Y);return{animations:[],documentIndex:Y,future:[],history:[],selection:{anchor:X,focus:X}}}function s0($){let Y=S0($.documentIndex);return J2(X7($.documentIndex.document.blocks),Y.threads,$.documentIndex.document.frontMatter)}function f0($,Y){if(!Y)return null;switch(Y.kind){case"keep-state":return $;case"set-selection":return K0($,Y.selection);case"replace-block":{let X=O5($.documentIndex,Y.blockId,()=>Y.block);return X?Q4($,M2(X),Y.selection??null):null}case"splice-blocks":{let X=L1($.documentIndex.document,Y.rootIndex,Y.count??1,Y.blocks);return Q4($,M2(X),Y.selection??null)}case"splice-text":{let X=t7($.documentIndex,Y.selection,Y.text);return Q4($,X.documentIndex,X.selection)}case"splice-fragment":{let X=s8($.documentIndex,Y.selection,Y.blocks);return Q4($,X.documentIndex,X.selection)}case"splice-comments":{let X=t9($.documentIndex.document,Y.index,Y.count,Y.threads);return Q4($,w5($.documentIndex,X),null)}}}function Q4($,Y,X){let Z=rQ($,Y),J=e2(Z.documentIndex,X)??$.selection,K=J$($,Z,J);return K0(Z,J,K)}function K0($,Y,X){let Z="regionId"in Y?{anchor:I5($.documentIndex,Y),focus:I5($.documentIndex,Y)}:{anchor:I5($.documentIndex,Y.anchor),focus:I5($.documentIndex,Y.focus)},J={...$,selection:Z};return X??J$($,J)?I7(J,p7(J)):J}function y0($,Y,X,Z){let J={regionId:Y,offset:X};return K0($,Z?{anchor:$.selection.anchor,focus:J}:J)}function rQ($,Y){let X=Z$(Y);return{animations:l8($.animations,m1()),documentIndex:Y,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:{anchor:X,focus:X}}}function i8($){let Y=$.history.at(-1);if(!Y)return $;return X$(Y,{future:[Y$($),...$.future],history:$.history.slice(0,-1)})}function o8($){let Y=$.future[0];if(!Y)return $;return X$(Y,{future:$.future.slice(1),history:[...$.history,Y$($)]})}function Y$($){return{document:$.documentIndex.document,selection:$.selection}}function X$($,Y){return{animations:[],documentIndex:M2($.document),future:Y.future,history:Y.history,selection:$.selection}}function Z$($){return $.regions[0]?{regionId:$.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function I5($,Y){let X=P0($,Y.regionId);if(!X)return Y;return{regionId:X.id,offset:Math.max(0,Math.min(Y.offset,X.text.length))}}function J$($,Y,X){let Z=$$($.documentIndex,$.selection),J=$$(Y.documentIndex,X??Y.selection);return J!==null&&J!==Z}function $$($,Y){let X=$.regionIndex.get(Y.focus.regionId),Z=X?$.blockIndex.get(X.blockId)??null:null;if(!X||!Z?.path)return null;return Z.type==="table"?`cell:${X.path}`:`block:${Z.path}`}function U4($,Y){let X=$.regionIndex.get(Y.anchor.regionId);if(!X)return{kind:"unsupported"};if(X.blockType==="code"){let M=$.blockIndex.get(X.blockId);return M?{kind:"code",region:X,rootIndex:M.rootIndex,...D4($,X,Y)}:{kind:"unsupported"}}let Z=t8($,X.id);if(Z)return{kind:"tableCell",...Z,...D4($,X,Y)};let J=z2($,Y);if(J)return{kind:"listItem",...J};let K=sQ($,Y);if(K)return{kind:"blockquoteTextBlock",...K};let Q=H2($,Y);if(Q)return{kind:"rootTextBlock",...Q};return{kind:"unsupported"}}function K$($,Y,X){let Z=U4($,Y),J=Z.kind==="unsupported"?!1:X==="backward"?Z.atStart:Z.atEnd;switch(Z.kind){case"rootTextBlock":return{...Z,kind:"rootTextBlock",direction:X,atBoundary:J,previousRoot:$.document.blocks[Z.rootIndex-1]??null,nextRoot:$.document.blocks[Z.rootIndex+1]??null};case"listItem":return{...Z,kind:"listItem",direction:X,atBoundary:J,previousItem:Z.list.items[Z.itemIndex-1]??null,nextItem:Z.list.items[Z.itemIndex+1]??null,previousRoot:$.document.blocks[Z.rootIndex-1]??null,nextRoot:$.document.blocks[Z.rootIndex+1]??null};case"blockquoteTextBlock":return{...Z,kind:"blockquoteTextBlock",direction:X,atBoundary:J,previousSibling:Z.quote.children[Z.childIndex-1]??null,nextSibling:Z.quote.children[Z.childIndex+1]??null};default:return{kind:"unsupported",direction:X,atBoundary:!1}}}function n8($,Y,X){let Z=Y?$.blockIndex.get(Y)??null:null;while(Z){if(Z.type===X)return Z;let J=Z.parentBlockId;Z=J?$.blockIndex.get(J)??null:null}return null}function V1($){let Y=$.split("."),X=[];for(let Z=0;Z<Y.length-1;Z+=1)if(Y[Z]==="children"){let J=Number(Y[Z+1]);if(Number.isInteger(J))X.push(J)}return X}function H2($,Y){let X=$.regionIndex.get(Y.anchor.regionId);if(!X)return null;let Z=$.blockIndex.get(X.blockId);if(!Z)return null;let J=Z.rootIndex,K=$.document.blocks[J];if(!K||K.type!=="heading"&&K.type!=="paragraph")return null;return{...D4($,X,Y),block:K,region:X,rootIndex:J}}function sQ($,Y){let X=$.regionIndex.get(Y.anchor.regionId);if(!X)return null;let Z=$.blockIndex.get(X.blockId),J=n8($,Z?.id??null,"blockquote");if(!Z||!J||Z.parentBlockId!==J.id)return null;let K=J.rootIndex,Q=$.document.blocks[K];if(!Q||Q.type!=="blockquote")return null;let M=Q.children.findIndex((q)=>q.id===Z.id),D=Q.children[M];if(!D||D.type!=="heading"&&D.type!=="paragraph")return null;return{...D4($,X,Y),block:D,blockChildIndices:V1(Z.path),childIndex:M,region:X,quote:Q,rootIndex:K}}function q4($,Y){return c0($.document.blocks,Y)}function z2($,Y){let X=$.regionIndex.get(Y.anchor.regionId);if(!X)return null;let Z=$.blockIndex.get(X.blockId),J=n8($,Z?.id??null,"listItem"),K=n8($,Z?.id??null,"list");if(!Z||!J||!K)return null;let Q=q4($,K.id);if(!Q||Q.type!=="list")return null;let M=Q.items.findIndex((A)=>A.id===J.id),D=Q.items[M];if(!D)return null;let q=K.parentBlockId?$.blockIndex.get(K.parentBlockId)??null:null,U=q?.parentBlockId?$.blockIndex.get(q.parentBlockId)??null:null,V=q?.type==="listItem"?q4($,q.id):null,G=U?.type==="list"?q4($,U.id):null,N=G?.type==="list"&&V?G.items.findIndex((A)=>A.id===V.id):-1;return{...D4($,X,Y),region:X,item:D,itemChildIndices:V1(J.path),itemIndex:M,list:Q,listChildIndices:V1(K.path),parentItem:V?.type==="listItem"?V:null,parentItemChildIndices:q?.type==="listItem"?V1(q.path):null,parentItemIndex:N>=0?N:null,parentList:G?.type==="list"?G:null,parentListChildIndices:U?.type==="list"?V1(U.path):null,rootIndex:K.rootIndex}}function t8($,Y){let X=$.regionIndex.get(Y);if(!X)return null;let Z=$.tableCellIndex.get(X.id),J=$.blockIndex.get(X.blockId),K=J?.type==="table"?$.document.blocks[J.rootIndex]:null;if(!Z||!J||!K||K.type!=="table")return null;return{cellIndex:Z.cellIndex,region:X,rootIndex:J.rootIndex,rowIndex:Z.rowIndex,table:K}}function D4($,Y,X){let Z=Y0($,X),J=Z.start.regionId===Y.id?Z.start.offset:X.anchor.offset;return{atEnd:J===Y.text.length,atStart:J===0,empty:Y.text.length===0,offset:J}}function G4($,Y,X){return w1({checked:Y,children:[i({text:$})],spread:X})}function Q$($,Y){let X=$.children[0];if(!X||X.type!=="paragraph")return null;return d0($,[i({text:Y}),...$.children.slice(1)])}function M$($,Y){return Y.reduce((X,Z)=>`${X}.children.${Z}`,`root.${$}`)}function q$($,Y){if($.selection.anchor.regionId!==$.selection.focus.regionId||$.selection.anchor.offset!==$.selection.focus.offset)return null;let X=P0($.documentIndex,$.selection.focus.regionId);if(!X)return null;if(Y==="forward"&&$.selection.focus.offset>=X.text.length)return null;let Z=Y==="backward"?iQ(X.text,$.selection.focus.offset):$.selection.focus.offset,J=Y==="backward"?$.selection.focus.offset:oQ(X.text,$.selection.focus.offset);if(Z===J)return null;return{kind:"splice-text",selection:{anchor:{regionId:X.id,offset:Z},focus:{regionId:X.id,offset:J}},text:""}}function iQ($,Y){let X=Array.from($.slice(0,Y));if(X.length===0)return 0;return Y-X.at(-1).length}function oQ($,Y){let X=Array.from($.slice(Y))[0];return X?Y+X.length:$.length}function D$($,Y,X){if(Y.anchor.regionId!==Y.focus.regionId)return null;let Z=$.regionIndex.get(Y.anchor.regionId);if(!Z)return null;let J=tQ($,Y,Z);if(!J)return null;let{start:K,end:Q}=nQ($,Y);return eQ(Z,X,K,Q,J)}function nQ($,Y){if(Y.anchor.offset===Y.focus.offset)return{start:Y.anchor.offset,end:Y.anchor.offset};let X=Y0($,Y);return{start:X.start.offset,end:X.end.offset}}function tQ($,Y,X){switch(X.blockType){case"heading":{let Z=H2($,Y);return Z?.block.type==="heading"?{kind:"heading",rootIndex:Z.rootIndex}:null}case"paragraph":{let Z=z2($,Y);if(Z)return{kind:"list-item",item:Z};let J=H2($,Y);return J?.block.type==="paragraph"?{kind:"root-paragraph",rootIndex:J.rootIndex}:null}default:return null}}function eQ($,Y,X,Z,J){if(J.kind==="root-paragraph"&&!$M($,Y,Z))return null;let K=$.text.slice(0,X)+Y+$.text.slice(Z);switch(J.kind){case"root-paragraph":return e8(YM,K,J);case"heading":return e8(XM,K,J);case"list-item":return e8(ZM,K,J.item)}}function $M($,Y,X){let Z=X<$.text.length?$.text:Y;return Z.length>0&&/\s/.test(Z[Z.length-1])}function e8($,Y,X){for(let{pattern:Z,apply:J}of $){let K=Z.exec(Y);if(K)return J(K,X)}return null}var YM=[{pattern:F2(/\[[ xX]?\]/,{allowIndent:!0}),apply:($,{rootIndex:Y})=>$3(Y,{checked:$[1].toLowerCase().includes("x"),ordered:!1,start:null})},{pattern:F2(/[-+*]/,{allowIndent:!0}),apply:($,{rootIndex:Y})=>$3(Y,{checked:null,ordered:!1,start:null})},{pattern:F2(/\d+\./,{allowIndent:!0}),apply:($,{rootIndex:Y})=>$3(Y,{checked:null,ordered:!0,start:Number($[1].slice(0,-1))})},{pattern:F2(/#{1,6}/,{allowIndent:!1}),apply:($,{rootIndex:Y})=>({kind:"splice-blocks",blocks:[t1({depth:$[1].length,text:""})],rootIndex:Y,selection:$0(Y)})},{pattern:F2(/>/,{allowIndent:!1}),apply:($,{rootIndex:Y})=>({kind:"splice-blocks",blocks:[R0({children:[i({text:""})]})],rootIndex:Y,selection:H0(Y,[0])})},{pattern:F2(/---/,{allowIndent:!1}),apply:($,{rootIndex:Y})=>({kind:"splice-blocks",blocks:[F5(),i({text:""})],rootIndex:Y,selection:$0(Y+1)})}],XM=[{pattern:p5(/#{1,6}/),apply:($,{rootIndex:Y})=>({kind:"splice-blocks",blocks:[t1({depth:$[1].length,text:$[2]})],rootIndex:Y,selection:$0(Y)})}],ZM=[{pattern:p5(/\d+\./),apply:($,Y)=>Y3($,Y,{ordered:!0,start:1,checked:Y.item.checked})},{pattern:p5(/\[[ xX]?\]/),apply:($,Y)=>Y3($,Y,{ordered:!1,start:null,checked:$[1].toLowerCase().includes("x")})},{pattern:p5(/[-+*]/),apply:($,Y)=>Y3($,Y,{ordered:!1,start:null,checked:null})}];function F2($,Y){let X=Y.allowIndent?"\\s*":"";return new RegExp(`^${X}(${$.source})\\s$`)}function p5($){return new RegExp(`^\\s*(${$.source})\\s(.+)$`)}function $3($,Y){return{kind:"splice-blocks",blocks:[O1({items:[w1({checked:Y.checked,children:[i({text:""})],spread:!1})],ordered:Y.ordered,spread:!1,start:Y.start})],rootIndex:$,selection:H0($,[0,0])}}function Y3($,Y,X){let Z=Q$(Y.item,$[2]);if(!Z)return null;return{kind:"replace-block",block:M0(Y.list,Y.list.items.map((J,K)=>K===Y.itemIndex?{...Z,checked:X.checked}:J),{ordered:X.ordered,start:X.start}),blockId:Y.list.id,selection:H0(Y.rootIndex,[...Y.listChildIndices,Y.itemIndex,0])}}function U$($,Y,X){return D$($,Y,X)??{kind:"splice-text",selection:Y,text:X}}function G$($,Y){let X=$.region.text.length,Z=$.region.text.slice(0,Y),J=$.region.text.slice(Y),K=Y===0&&X>0?$.rootIndex:$.rootIndex+1;return{kind:"splice-blocks",blocks:A$($.block,Z,J,Y,X),rootIndex:$.rootIndex,selection:$0(K)}}function V$($,Y){let X=$.region.text,Z=X.slice(0,Y),J=X.slice(Y),K=A$($.block,Z,J,Y,X.length),Q=Y===0?$.blockChildIndices:[...$.blockChildIndices.slice(0,-1),$.blockChildIndices.at(-1)+1];return{kind:"splice-blocks",blocks:[R0({children:[...$.quote.children.slice(0,$.childIndex),...K,...$.quote.children.slice($.childIndex+1)]})],rootIndex:$.rootIndex,selection:H0($.rootIndex,Q)}}function N$($,Y){if(Y!==0||$.region.text.length!==0||$.block.type!=="paragraph")return null;let X=$.quote.children.slice(0,$.childIndex),Z=$.quote.children.slice($.childIndex+1),J=[];if(X.length>0)J.push(R0({children:X}));if(J.push(i({text:""})),Z.length>0)J.push(R0({children:Z}));return{kind:"splice-blocks",blocks:J,rootIndex:$.rootIndex,selection:$0($.rootIndex+(X.length>0?1:0))}}function X3($,Y,X){if($.block.type!=="heading")return null;let Z=Math.max(1,Math.min(6,$.block.depth+Y));if(Z===$.block.depth)return{kind:"keep-state"};return{kind:"splice-blocks",blocks:[t1({depth:Z,text:$.block.plainText})],rootIndex:$.rootIndex,selection:$0($.rootIndex,X)}}function A$($,Y,X,Z,J){if(Z===0)return[i({text:""}),$];if(Z===J)return[$,i({text:""})];return[$.type==="heading"?t1({depth:$.depth,text:Y}):i({text:Y}),i({text:X})]}function V4($,Y,X,Z=0){return H0($,[...Y,X,0],Z)}function Z3($,Y){let X=$.region.text,Z=$.item,J=typeof Z.checked==="boolean"?!1:Z.checked;if(Y===0){let q=G4("",J,Z.spread);return{kind:"replace-block",block:M0($.list,[...$.list.items.slice(0,$.itemIndex),q,Z,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:x5(q,$.rootIndex,[...$.listChildIndices,$.itemIndex]),selection:V4($.rootIndex,$.listChildIndices,$.itemIndex)}}if(Y===X.length){let q=G4("",J,Z.spread);return{kind:"replace-block",block:M0($.list,[...$.list.items.slice(0,$.itemIndex+1),q,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:x5(q,$.rootIndex,[...$.listChildIndices,$.itemIndex+1]),selection:V4($.rootIndex,$.listChildIndices,$.itemIndex+1)}}let K=X.slice(0,Y),Q=X.slice(Y),M=G4(Q,J,Z.spread),D=d0(Z,[i({text:K})]);return{kind:"replace-block",block:M0($.list,[...$.list.items.slice(0,$.itemIndex),D,M,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:x5(M,$.rootIndex,[...$.listChildIndices,$.itemIndex+1]),selection:V4($.rootIndex,$.listChildIndices,$.itemIndex+1)}}function _$($,Y){if(Y!==0||$.region.text.length!==0)return Z3($,Y);if($.parentItem&&$.parentItemIndex!==null&&$.parentItemChildIndices&&$.parentList&&$.parentListChildIndices)return JM($);let X=$.list.items.slice(0,$.itemIndex),Z=$.list.items.slice($.itemIndex+1),J=[];if(X.length>0)J.push(M0($.list,X));if(J.push(i({text:""})),Z.length>0)J.push(M0($.list,Z));return{kind:"splice-blocks",blocks:J,rootIndex:$.rootIndex,selection:$0($.rootIndex+(X.length>0?1:0))}}function H$($){if($.itemIndex===0)return null;let Y=$.list.items[$.itemIndex-1];if(!Y)return null;let X=KM(Y,$.item,$);return{kind:"replace-block",block:M0($.list,$.list.items.flatMap((Z,J)=>{if(J===$.itemIndex-1)return[X.item];if(J===$.itemIndex)return[];return[Z]})),blockId:$.list.id,selection:H0($.rootIndex,X.regionChildIndices)}}function z$($){return F$($,()=>({insertedItem:$.item}))}function J3($,Y){let X=$.itemIndex+Y;if(X<0||X>=$.list.items.length)return null;let Z=[...$.list.items],[J]=Z.splice($.itemIndex,1);if(!J)return null;return Z.splice(X,0,J),{kind:"replace-block",block:M0($.list,Z),blockId:$.list.id,selection:V4($.rootIndex,$.listChildIndices,X)}}function JM($){return F$($,(Y)=>{let X=typeof Y.checked==="boolean"?!1:Y.checked;return{insertedItem:G4("",X,Y.spread),trackInsertedPath:!0}})}function F$($,Y){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let X=$.list.items.filter((D,q)=>q!==$.itemIndex),Z=$.parentItem.children.flatMap((D)=>{if(D.type!=="list"||D.id!==$.list.id)return[D];if(X.length===0)return[];return[M0($.list,X)]}),J=d0($.parentItem,Z),{insertedItem:K,trackInsertedPath:Q=!1}=Y($.parentItem),M=Q?x5(K,$.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1]):void 0;return{kind:"replace-block",block:M0($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),J,K,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,listItemInsertedPath:M,selection:V4($.rootIndex,$.parentListChildIndices,$.parentItemIndex+1)}}function x5($,Y,X){return typeof $.checked==="boolean"?void 0:M$(Y,X)}function KM($,Y,X){let Z=$.children.findIndex((K)=>K.type==="list"&&K.ordered===X.list.ordered&&K.start===X.list.start);if(Z>=0){let K=$.children[Z];if(!K||K.type!=="list")return{item:$,regionChildIndices:[...X.listChildIndices,X.itemIndex-1,0]};return{item:d0($,$.children.map((Q,M)=>M===Z?M0(K,[...K.items,Y]):Q)),regionChildIndices:[...X.listChildIndices,X.itemIndex-1,Z,K.items.length,0]}}let J=O1({items:[Y],ordered:X.list.ordered,spread:X.list.spread,start:X.list.start});return{item:d0($,[...$.children,J]),regionChildIndices:[...X.listChildIndices,X.itemIndex-1,$.children.length,0,0]}}function E$($,Y,X){let Z=H2($,Y),J=Math.max(2,X);if(!Z||Z.block.type!=="paragraph"||Z.block.plainText.length>0||Y.anchor.regionId!==Y.focus.regionId||Y.anchor.offset!==0||Y.focus.offset!==0)return null;return{kind:"splice-blocks",blocks:[B1({rows:Array.from({length:2},()=>Q3(J))})],rootIndex:Z.rootIndex,selection:v1(Z.rootIndex,0,0)}}function K3($,Y,X,Z){let J=Z<0?DM(X.table,X.rowIndex,X.cellIndex):UM(X.table,X.rowIndex,X.cellIndex);if(!J)return Z>0&&GM(X.table,X.rowIndex,X.cellIndex)?QM(X):{kind:"keep-state"};let K=X.table.rows[J.rowIndex]?.cells[J.cellIndex];if(!K)return{kind:"keep-state"};return{kind:"set-selection",selection:qM($,Y,X.table,J.rowIndex,J.cellIndex,Math.min(Y.focus.offset,K.plainText.length))}}function W$($,Y){let X=D2($,Y.focus.regionId);if(!X||X.kind!=="tableCell")return null;let Z=Math.min(Y.anchor.offset,Y.focus.offset),J=Math.max(Y.anchor.offset,Y.focus.offset),K=o2(X,Z,J,(Q)=>l0({path:Q}));return{kind:"replace-block",block:K.block,blockId:K.blockId,selection:K.selection}}function P$($,Y){let X=Y==="left"?$.cellIndex:$.cellIndex+1;return E2($,B1({align:B$($.table.align,X,0,[null]),rows:$.table.rows.map((Z)=>Y2({cells:MM(Z.cells,X,0,[O$()])}))}),v1($.rootIndex,$.rowIndex,X))}function y$($){let Y=Math.max(0,...$.table.rows.map((X)=>X.cells.length));if(Y<=1)return null;return E2($,B1({align:B$($.table.align,$.cellIndex,1,[]),rows:$.table.rows.map((X)=>Y2({cells:X.cells.filter((Z,J)=>J!==$.cellIndex)}))}),v1($.rootIndex,$.rowIndex,Math.min($.cellIndex,Y-2)))}function T$($,Y){let X=Y==="above"?$.rowIndex:$.rowIndex+1,Z=Math.max(1,...$.table.rows.map((J)=>J.cells.length));return E2($,B0($.table,[...$.table.rows.slice(0,X),Q3(Z),...$.table.rows.slice(X)]),v1($.rootIndex,X,Math.min($.cellIndex,Z-1)))}function j$($){if($.table.rows.length<=1)return null;let Y=$.table.rows.filter((J,K)=>K!==$.rowIndex),X=Math.min($.rowIndex,Y.length-1),Z=Y[X]?.cells.length??1;return E2($,B0($.table,Y),v1($.rootIndex,X,Math.min($.cellIndex,Z-1)))}function w$($){return E2($,i({text:""}),$0($.rootIndex))}function Q3($){return Y2({cells:Array.from({length:$},()=>O$())})}function O$(){return D1({children:[]})}function QM($){let Y=$.table.rows.length,X=Math.max(1,...$.table.rows.map((Z)=>Z.cells.length));return E2($,B0($.table,[...$.table.rows,Q3(X)]),v1($.rootIndex,Y,0))}function E2($,Y,X){return{kind:"replace-block",block:Y,blockId:$.table.id,selection:X}}function MM($,Y,X,Z){return[...$.slice(0,Y),...Z,...$.slice(Y+X)]}function B$($,Y,X,Z){return[...$.slice(0,Y),...Z,...$.slice(Y+X)]}function qM($,Y,X,Z,J,K){let Q=V2($,X.id,Z,J);if(!Q)return Y;return{anchor:{regionId:Q.id,offset:K},focus:{regionId:Q.id,offset:K}}}function DM($,Y,X){if(X>0)return{cellIndex:X-1,rowIndex:Y};if(Y>0){let Z=$.rows[Y-1];if(!Z||Z.cells.length===0)return null;return{cellIndex:Z.cells.length-1,rowIndex:Y-1}}return null}function UM($,Y,X){let Z=$.rows[Y];if(!Z)return null;if(X+1<Z.cells.length)return{cellIndex:X+1,rowIndex:Y};let J=$.rows[Y+1];if(!J||J.cells.length===0)return null;return{cellIndex:0,rowIndex:Y+1}}function GM($,Y,X){let Z=$.rows[Y];return Boolean(Z&&Y===$.rows.length-1&&X===Z.cells.length-1)}function C$($,Y,X){switch(X.kind){case"code":return{kind:"splice-text",selection:Y,text:`
|
|
15
|
+
`};case"tableCell":return W$($,Y);case"listItem":return _$(X,X.offset)??Z3(X,X.offset);case"blockquoteTextBlock":return N$(X,X.offset)??V$(X,X.offset);case"rootTextBlock":return G$(X,X.offset);case"unsupported":return null}}function R$($,Y){let X=Y0($,Y);if(X.collapsed)return null;let Z=P0($,X.start.regionId),J=P0($,X.end.regionId);if(!Z||!J)return null;let K=$.document.blocks[Z.rootIndex],Q=$.document.blocks[J.rootIndex];if(!K||!Q)return null;if(Z===J)return{kind:"single-region",normalized:X,region:Z,root:K,wholeRegion:X.start.offset===0&&X.end.offset===Z.text.length};return{kind:"multi-region",normalized:X,startRegion:Z,endRegion:J,sameRoot:Z.rootIndex===J.rootIndex,startRoot:K,endRoot:Q}}function l5($,Y){let X=Y0($,Y),Z=P0($,X.start.regionId),J=P0($,X.end.regionId);if(!Z||!J)return null;let K=L$(Z)||L$(J);return{normalized:X,sameRegion:Z===J,startRegion:Z,endRegion:J,structuralBlocked:K,prefersVerbatimFallback:Z.blockType==="code"||J.blockType==="code"}}function L$($){return $.blockType==="table"||$.blockType==="code"}function M3($,Y){let X=R$($,Y);if(!X)return null;switch(X.kind){case"single-region":if(!X.wholeRegion||X.region.blockType==="table"){let J=NM(X.region,X.normalized.start.offset,X.normalized.end.offset);return VM(J)}let Z=S$(X.root,X.region);return Z?b$([Z]):null;case"multi-region":{let J=X.sameRoot?AM($,X.startRoot,X.startRegion,X.normalized.start.offset,X.endRegion,X.normalized.end.offset):zM($,X.startRegion,X.normalized.start.offset,X.endRegion,X.normalized.end.offset);return J.length>0?b$(J):null}}}function VM($){if($.length===0)return null;if(Q8($))return{kind:"text",text:X0($)};return{kind:"inlines",inlines:$}}function b$($){if(P5($))return{kind:"text",text:$[0].plainText};return{kind:"blocks",blocks:$}}function S$($,Y){if($.id===Y.blockId)return $;let X=_0($);if(!X)return null;let Z=X.find((K)=>h1(K,Y)),J=Z?S$(Z,Y):null;return J?R1($,[J]):null}function NM($,Y,X){let Z=_2($.inlines,X,$.text.length,""),J=_2(Z,0,Y,"");return c8(J)}function AM($,Y,X,Z,J,K){if(Y.type==="table")return HM($,Y,X,Z,J,K);let Q=v$(Y,X,Z,J,K);return Q?[Q]:[]}function _M($,Y,X,Z,J){let K=$.roots[Y.rootIndex],Q=K?.regions[0],M=K?.regions.at(-1);return Y===Q&&Z===M&&X===0&&J===M.text.length}function HM($,Y,X,Z,J,K){if(_M($,X,Z,J,K))return[Y];let Q=X.tableCellPosition?.rowIndex,M=X.tableCellPosition?.cellIndex,D=J.tableCellPosition?.rowIndex,q=J.tableCellPosition?.cellIndex;if(Q===void 0||M===void 0||D===void 0||q===void 0)return[];if(Q!==0||M!==0||Z!==0)return[];let U=Y.rows[D];if(!U)return[];let V=U.cells.length-1;if(q!==V||K!==J.text.length)return[];return[B0(Y,Y.rows.slice(0,D+1))]}function v$($,Y,X,Z,J){let K=_0($);if(!K)return null;let Q=K.findIndex((D)=>h1(D,Y)),M=K.findIndex((D)=>h1(D,Z));if(Q===-1||M===-1)return null;if(Q===M){let D=v$(K[Q],Y,X,Z,J);return D?R1($,[D]):null}return R1($,f$(K,Q,Y,X,M,Z,J))}function zM($,Y,X,Z,J){return f$($.document.blocks,Y.rootIndex,Y,X,Z.rootIndex,Z,J)}function f$($,Y,X,Z,J,K,Q){let M=K4($[Y],X,Z),D=$.slice(Y+1,J),q=J4($[J],K,Q);return[M,...D,q].filter((U)=>U!==null)}function q3($,Y){let X=l5($.documentIndex,$.selection);if(!X)return null;switch(Y.kind){case"text":return Y.text.length>0?f0($,{kind:"splice-text",selection:$.selection,text:Y.text}):null;case"inlines":{if(Y.inlines.length===0)return null;if(X.sameRegion){let Z=F7($.documentIndex,$.selection,Y.inlines);if(Z)return f0($,Z)}if(X.structuralBlocked)return null;return f0($,{kind:"splice-fragment",blocks:[x0({children:Y.inlines})],selection:$.selection})}case"blocks":if(Y.blocks.length===0||X.structuralBlocked)return null;return f0($,{kind:"splice-fragment",blocks:Y.blocks,selection:$.selection})}}function m$($,Y,X,Z){let J=Z==="backward"?k8($,Y.blockId):t2($,Y.blockId);if(J&&r0(J))return FM(Y,J,Z);let K=Z==="backward"?f1($,Y.id):n2($,Y.id);if(!K)return null;if(X)return WM($,Y,K,Z);let Q=Z==="backward"?Y:K,M=Z==="backward"?K:Y;if(!EM(M))return null;return PM($,Q,M)}function FM($,Y,X){if(Y.parentBlockId!==null)return null;let Z=X==="backward"?$.rootIndex-1:$.rootIndex,J=X==="backward"?0:"end";return{kind:"splice-blocks",rootIndex:Y.rootIndex,count:1,blocks:[],selection:c5($,Z,J)}}function EM($){return $.blockType==="paragraph"||$.blockType==="heading"}function WM($,Y,X,Z){let J=$.document.blocks[Y.rootIndex];if(!J)return null;let K=d5(J,Y,X.blockId,void 0),Q=Z==="backward"?X.text.length:0,D=Y.rootIndex===X.rootIndex?TM(K,X.rootIndex,X.blockId,Q):jM(X,Y.rootIndex,K.length,Q);if(!D)return null;return{kind:"splice-blocks",rootIndex:Y.rootIndex,count:1,blocks:K,selection:D}}function PM($,Y,X){let Z=c0($.document,X.blockId),J=c0($.document,Y.blockId);if(!Z||Z.type!=="paragraph"&&Z.type!=="heading")return null;let K=X.text.length,Q=yM(Z,J),M=c5(X,X.rootIndex,K);if(Y.rootIndex===X.rootIndex){let _=$.document.blocks[Y.rootIndex];if(!_)return null;let z=d5(_,Y,X.blockId,Q);return{kind:"splice-blocks",rootIndex:Y.rootIndex,count:1,blocks:z,selection:M}}let D=$.document.blocks[X.rootIndex],q=$.document.blocks[Y.rootIndex];if(!D||!q)return null;let U=d5(D,Y,X.blockId,Q);if(U.length!==1)return null;let V=U[0],G=d5(q,Y,X.blockId,void 0),N=Math.min(X.rootIndex,Y.rootIndex),A=X.rootIndex<Y.rootIndex?[V,...G]:[...G,V];return{kind:"splice-blocks",rootIndex:N,count:2,blocks:A,selection:M}}function c5($,Y,X=0){let Z=V1($.path);if(Z.length===0)return $0(Y,X);return H0(Y,Z,X)}function yM($,Y){let X=Y&&(Y.type==="paragraph"||Y.type==="heading")?Y.children:[];return O0($,Z0([...$.children,...X]))}function TM($,Y,X,Z){for(let J=0;J<$.length;J+=1){let K=$[J],Q=D3(K,X);if(Q){if(Q.length===0)return $0(Y+J,Z);return H0(Y+J,Q,Z)}}return null}function jM($,Y,X,Z){let J=V1($.path),K=X-1,Q=$.rootIndex<Y?$.rootIndex:$.rootIndex+K;if(J.length===0)return $0(Q,Z);return H0(Q,J,Z)}function D3($,Y){if($.id===Y)return[];switch($.type){case"list":for(let X=0;X<$.items.length;X+=1){let Z=D3($.items[X],Y);if(Z)return[X,...Z]}return null;case"listItem":case"blockquote":for(let X=0;X<$.children.length;X+=1){let Z=D3($.children[X],Y);if(Z)return[X,...Z]}return null;default:return null}}function d5($,Y,X,Z){return Z2([$],(J,{parent:K,recurse:Q})=>{if(J.type==="listItem"){let D=J.children[0];if(D&&D.id===Y.blockId)return wM(J)}if(J.id===Y.blockId&&K?.type!=="listItem")return[];if(J.id===X&&Z!==void 0)return Z;let M=Q();if(M.type==="listItem"){let D=M.children[0];if(!D||D.type!=="paragraph"&&D.type!=="heading")return[]}return M})}function wM($){if($.type==="listItem")return $.children.filter((Y)=>Y.type==="list").flatMap((Y)=>Y.items);return[]}function h$($,Y){let X=u8($,Y.rootIndex);if(!X||X.id!==Y.id)return null;let Z=$.document.blocks[Y.rootIndex];if(!Z)return null;let J=OM(Z);if(!J)return null;return{kind:"splice-blocks",rootIndex:Y.rootIndex,count:1,blocks:J,selection:$0(Y.rootIndex)}}function OM($){switch($.type){case"heading":return[x0({children:$.children})];case"blockquote":return[...$.children];case"list":return k$($.items);default:return null}}function k$($){return $.flatMap((Y)=>{let X=[BM(Y)];for(let Z of Y.children)if(Z.type==="list")X.push(...k$(Z.items));return X})}function BM($){let Y=$.children[0];if(Y&&(Y.type==="paragraph"||Y.type==="heading"))return x0({children:Y.children});return i({text:""})}function u$($,Y){if(Y.kind==="unsupported"||!Y.atBoundary)return null;if(Y.direction==="backward"){let X=CM(Y,$);if(X)return X}return m$($,Y.region,Y.empty,Y.direction)}function CM($,Y){let X=h$(Y,$.region);if(X)return X;if($.kind==="rootTextBlock"){let Z=LM($,Y);if(Z)return Z}return null}function LM($,Y){if($.block.type!=="paragraph"||$.block.plainText.length!==0)return null;let X=Y.document.blocks[$.rootIndex-1],Z=Y.document.blocks[$.rootIndex+1];if(!X||X.type!=="list"||!Z||Z.type!=="list"||!RM(X,Z))return null;let J=f1(Y,$.region.id),K=J?c5(J,$.rootIndex-1,"end"):$0($.rootIndex-1,"end");return{kind:"splice-blocks",count:3,blocks:[M0(X,[...X.items,...Z.items])],rootIndex:$.rootIndex-1,selection:K}}function RM($,Y){return $.ordered===Y.ordered&&$.start===Y.start}var N4=Q0(($,Y)=>U$($.documentIndex,$.selection,Y),{animate:($,Y,X,Z)=>{if(X.kind!=="splice-text")return;if(Z===".")return u7(Y);return m5(Y,Z.length)}}),a5=Q0(($,Y)=>C$($.documentIndex,$.selection,Y),{context:U4,animate:($,Y,X)=>{if(X.kind!=="replace-block"||!X.listItemInsertedPath)return;return g7(Y,X.listItemInsertedPath)}}),g$=Q0(($)=>m8($.documentIndex,$.selection,(Y)=>l0({path:Y}))??{kind:"splice-text",selection:$.selection,text:`
|
|
16
|
+
`}),r5=Q0(($,Y)=>({kind:"splice-text",selection:$.selection,text:Y}),{animate:($,Y,X,Z)=>{if(Z.length>0)return m5(Y,Z.length)}}),U3=($)=>r5($,""),G3=GY(VY,($)=>_Y($,"backward"),($)=>NY($,"backward")),V3=GY(VY,($)=>_Y($,"forward"),($)=>NY($,"forward")),N3=($)=>M3($.documentIndex,$.selection);function I$($,Y,X){let Z=q3($,Y);if(Z){let J=bM(Y);return J>0?m5(Z,J):Z}if(Y.kind==="text")return null;return SM($,Y,X)}function bM($){switch($.kind){case"text":return $.text.length;case"inlines":return X0($.inlines).length;case"blocks":return $.blocks.length===1&&$.blocks[0].type==="paragraph"?$.blocks[0].plainText.length:0}}function SM($,Y,X){let Z=l5($.documentIndex,$.selection);if(!Z)return null;let J=Z.prefersVerbatimFallback&&X&&X.length>0?X:Y7(Y);return J.length>0?r5($,J):null}function p$($,Y,X){return y0($,Y,X,!0)}function x$($){let Y=$.documentIndex.regions,X=Y[0],Z=Y.at(-1);if(!X||!Z)return $;return K0($,{anchor:{regionId:X.id,offset:0},focus:{regionId:Z.id,offset:Z.text.length}})}var s5=($)=>t5($,"bold"),i5=($)=>t5($,"italic"),o5=($)=>t5($,"strikethrough"),n5=($)=>t5($,"underline"),l$=($)=>AY($,v8),d$=Q0(($,Y,X,Z,J)=>B5($.documentIndex,Y,X,Z,J)),c$=Q0(($,Y,X,Z)=>B5($.documentIndex,Y,X,Z,null)),a$=Q0(($,Y,X)=>m8($.documentIndex,$.selection,(Z)=>j1({alt:X??null,path:Z,url:Y}))),r$=Q0(($,Y,X,Z)=>{let J=D2($.documentIndex,Y);if(!J)return null;let{image:K}=X,Q=o2(J,X.start,X.end,(M)=>j1({alt:K.alt,path:M,title:K.title,url:K.url,width:Z}));return{kind:"replace-block",block:Q.block,blockId:Q.blockId}}),A3=($)=>i8($),_3=($)=>o8($),s$=Q0(($,Y)=>{switch(Y.kind){case"tableCell":return K3($.documentIndex,$.selection,Y,1);case"rootTextBlock":return X3(Y,1,$.selection.focus.offset);case"listItem":return H$(Y);default:return null}},{context:U4}),i$=Q0(($,Y)=>{switch(Y.kind){case"tableCell":return K3($.documentIndex,$.selection,Y,-1);case"rootTextBlock":return X3(Y,-1,$.selection.focus.offset);case"listItem":return z$(Y);default:return null}},{context:U4}),o$=Q0(($,Y)=>J3(Y,-1),{context:z2}),n$=Q0(($,Y)=>J3(Y,1),{context:z2}),t$=Q0(($,Y)=>{let X=q4($.documentIndex,Y);if(!X||X.type!=="listItem"||typeof X.checked!=="boolean")return null;return{kind:"replace-block",block:{...X,checked:!X.checked},blockId:Y}}),e$=Q0(($,Y)=>E$($.documentIndex,$.selection,Y)),$Y=Q0(($,Y,X)=>P$(Y,X),{context:A4}),YY=Q0(($,Y)=>y$(Y),{context:A4}),XY=Q0(($,Y,X)=>T$(Y,X),{context:A4}),ZY=Q0(($,Y)=>j$(Y),{context:A4}),JY=Q0(($,Y)=>w$(Y),{context:A4}),KY=Q0(($,Y,X)=>{let Z=T8($.documentIndex,Y,X);if(!Z)return null;return{kind:"splice-comments",count:0,index:$.documentIndex.document.comments.length,threads:[Z]}}),QY=($,Y,X)=>_4($,Y,(Z)=>H8(Z,{body:X.trim()})),MY=($,Y,X,Z)=>_4($,Y,(J)=>z8(J,X,Z)),qY=($,Y,X)=>_4($,Y,(Z)=>F8(Z,X)),DY=($,Y)=>_4($,Y,()=>null),UY=($,Y,X)=>_4($,Y,(Z)=>E8(Z,X));function Q0($,Y){return(X,...Z)=>{let J=[];if(Y?.context){let M=Y.context(X.documentIndex,X.selection);if(!M)return null;J.push(M)}let K=$(X,...J,...Z);if(!K)return null;let Q=f0(X,K);return Y?.animate?.(X,Q,K,...Z)??Q}}function GY(...$){return(Y,...X)=>{for(let Z of $){let J=Z(Y,...X);if(J)return J}return null}}function A4($,Y){return t8($,Y.focus.regionId)}function VY($){return vM($)?U3($):null}function NY($,Y){let X=K$($.documentIndex,$.selection,Y);return f0($,u$($.documentIndex,X))}function t5($,Y){return AY($,(X,Z,J)=>b8(X,Z,J,Y))}function AY($,Y){let X=Y0($.documentIndex,$.selection);if(X.start.regionId!==X.end.regionId||X.start.offset===X.end.offset)return null;return f0($,C5($.documentIndex,X.start.regionId,X.start.offset,X.end.offset,Y))}function vM($){let Y=Y0($.documentIndex,$.selection);return Y.start.regionId!==Y.end.regionId||Y.start.offset!==Y.end.offset}function _Y($,Y){let X=q$($,Y);if(!X)return null;let Z=f0($,X);if(!Z)return null;return k7($,Z,X.selection.anchor.offset,X.selection.focus.offset)}function _4($,Y,X){let J=S0($.documentIndex).threads[Y];if(!J)return null;let K=X(J);if(K===J)return null;return f0($,{kind:"splice-comments",count:1,index:Y,threads:K?[K]:[]})}function k1(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function HY($,Y,X){return H4($.preparedText,Y,X,256)}function zY($,Y,X){return H4($.measuredLines,Y,X,512)}function FY($,Y,X){return H4($.lineBoundaries,Y,X,1024)}function EY($,Y,X){return H4($.measuredContainerHeights,Y,X,1024)}function WY($,Y){let X=$.graphemeWidths.get(Y);if(X)return X;let Z=new Map;return H4($.graphemeWidths,Y,Z,64),Z}function PY($,Y,X){return $.viewportPlans.get(Y)?.get(X)??null}function yY($,Y,X,Z){let J=$.viewportPlans.get(Y)??new Map;return J.set(X,Z),$.viewportPlans.set(Y,J),Z}function H4($,Y,X,Z){if($.has(Y))$.delete(Y);if($.set(Y,X),$.size>Z){let J=$.keys().next().value;if(J!==void 0)$.delete(J)}return X}var e5={blockGap:16,charWidth:9,indentWidth:24,lineHeight:24,paddingX:16,paddingY:12};function $6($,Y,X,Z,J){if(TY($,X,Z,"list"))return 6;if(TY($,X,Z,"blockquote"))return 10;if(X===Z)return 4;return J+fM(Y.get(X))}function fM($){if($?.type!=="heading")return 0;if($.depth===1)return 24;return $.depth===2?16:0}function TY($,Y,X,Z){let J=jY($,Y,Z),K=jY($,X,Z);for(let Q of J)if(K.has(Q))return!0;return!1}function jY($,Y,X){let Z=new Set,J=$.get(Y)??null;while(J){if(J.type===X)Z.add(J.id);J=J.parentBlockId?$.get(J.parentBlockId)??null:null}return Z}var mM=["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"],hM=["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 kM($){if($<=255)return mM[$];if(1424<=$&&$<=1524)return"R";if(1536<=$&&$<=1791)return hM[$&255];if(1792<=$&&$<=2220)return"AL";return"L"}function uM($){let Y=$.length;if(Y===0)return null;let X=Array(Y),Z=0;for(let q=0;q<Y;q++){let U=kM($.charCodeAt(q));if(U==="R"||U==="AL"||U==="AN")Z++;X[q]=U}if(Z===0)return null;let J=Y/Z<0.3?0:1,K=new Int8Array(Y);for(let q=0;q<Y;q++)K[q]=J;let Q=J&1?"R":"L",M=Q,D=M;for(let q=0;q<Y;q++)if(X[q]==="NSM")X[q]=D;else D=X[q];D=M;for(let q=0;q<Y;q++){let U=X[q];if(U==="EN")X[q]=D==="AL"?"AN":"EN";else if(U==="R"||U==="L"||U==="AL")D=U}for(let q=0;q<Y;q++)if(X[q]==="AL")X[q]="R";for(let q=1;q<Y-1;q++){if(X[q]==="ES"&&X[q-1]==="EN"&&X[q+1]==="EN")X[q]="EN";if(X[q]==="CS"&&(X[q-1]==="EN"||X[q-1]==="AN")&&X[q+1]===X[q-1])X[q]=X[q-1]}for(let q=0;q<Y;q++){if(X[q]!=="EN")continue;let U;for(U=q-1;U>=0&&X[U]==="ET";U--)X[U]="EN";for(U=q+1;U<Y&&X[U]==="ET";U++)X[U]="EN"}for(let q=0;q<Y;q++){let U=X[q];if(U==="WS"||U==="ES"||U==="ET"||U==="CS")X[q]="ON"}D=M;for(let q=0;q<Y;q++){let U=X[q];if(U==="EN")X[q]=D==="L"?"L":"EN";else if(U==="R"||U==="L")D=U}for(let q=0;q<Y;q++){if(X[q]!=="ON")continue;let U=q+1;while(U<Y&&X[U]==="ON")U++;let V=q>0?X[q-1]:M,G=U<Y?X[U]:M,N=V!=="L"?"R":"L";if(N===(G!=="L"?"R":"L"))for(let _=q;_<U;_++)X[_]=N;q=U-1}for(let q=0;q<Y;q++)if(X[q]==="ON")X[q]=Q;for(let q=0;q<Y;q++){let U=X[q];if((K[q]&1)===0){if(U==="R")K[q]++;else if(U==="AN"||U==="EN")K[q]+=2}else if(U==="L"||U==="AN"||U==="EN")K[q]++}return K}function wY($,Y){let X=uM($);if(X===null)return null;let Z=new Int8Array(Y.length);for(let J=0;J<Y.length;J++)Z[J]=X[Y[J]];return Z}var gM=/[ \t\n\r\f]+/g,IM=/[\t\n\r\f]| {2,}|^ | $/;function pM($){let Y=$??"normal";return Y==="pre-wrap"?{mode:Y,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:Y,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function xM($){if(!IM.test($))return $;let Y=$.replace(gM," ");if(Y.charCodeAt(0)===32)Y=Y.slice(1);if(Y.length>0&&Y.charCodeAt(Y.length-1)===32)Y=Y.slice(0,-1);return Y}function lM($){if(!/[\r\f]/.test($))return $.replace(/\r\n/g,`
|
|
10
17
|
`);return $.replace(/\r\n/g,`
|
|
11
18
|
`).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 CX($,M,J,Z){let X=[],Y=null,Q=[],K=J,q=!1,D=0;for(let A of $){let V=LX(A,Z),U=V==="text"&&M;if(Y!==null&&V===Y&&U===q){Q.push(A),D+=A.length;continue}if(Y!==null)X.push({text:i0(Q),isWordLike:q,kind:Y,start:K});Y=V,Q=[A],K=J+D,q=U,D+=A.length}if(Y!==null)X.push({text:i0(Q),isWordLike:q,kind:Y,start:K});return X}function h8($){return $==="space"||$==="preserved-space"||$==="zero-width-break"||$==="hard-break"}var RX=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function fX($,M){let J=$.texts[M];if(J.startsWith("www."))return!0;return RX.test(J)&&M+1<$.len&&$.kinds[M+1]==="text"&&$.texts[M+1]==="//"}function mX($){return $.includes("?")&&($.includes("://")||$.startsWith("www."))}function SX($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let Q=0;Q<$.len;Q++){if(Z[Q]!=="text"||!fX($,Q))continue;let K=[M[Q]],q=Q+1;while(q<$.len&&!h8(Z[q])){K.push(M[q]),J[Q]=!0;let D=M[q].includes("?");if(Z[q]="text",M[q]="",q++,D)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,J[Y]=J[Q],Z[Y]=Z[Q],X[Y]=X[Q];Y++}return M.length=Y,J.length=Y,Z.length=Y,X.length=Y,{len:Y,texts:M,isWordLike:J,kinds:Z,starts:X}}function kX($){let M=[],J=[],Z=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y];if(M.push(Q),J.push($.isWordLike[Y]),Z.push($.kinds[Y]),X.push($.starts[Y]),!mX(Q))continue;let K=Y+1;if(K>=$.len||h8($.kinds[K]))continue;let q=[],D=$.starts[K],A=K;while(A<$.len&&!h8($.kinds[A]))q.push($.texts[A]),A++;if(q.length>0)M.push(i0(q)),J.push(!0),Z.push("text"),X.push(D),Y=A-1}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}var uX=new Set([":","-","/","×",",",".","+","–","—"]),S9=/^[A-Za-z0-9_]+[,:;]*$/,k9=/[,:;]+$/;function v9($){for(let M of $)if(u9.test(M))return!0;return!1}function g8($){if($.length===0)return!1;for(let M of $){if(u9.test(M)||uX.has(M))continue;return!1}return!0}function vX($){let M=[],J=[],Z=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y],K=$.kinds[Y];if(K==="text"&&g8(Q)&&v9(Q)){let q=[Q],D=Y+1;while(D<$.len&&$.kinds[D]==="text"&&g8($.texts[D]))q.push($.texts[D]),D++;M.push(i0(q)),J.push(!0),Z.push("text"),X.push($.starts[Y]),Y=D-1;continue}M.push(Q),J.push($.isWordLike[Y]),Z.push(K),X.push($.starts[Y])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function hX($){let M=[],J=[],Z=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y],K=$.kinds[Y],q=$.isWordLike[Y];if(K==="text"&&q&&S9.test(Q)){let D=[Q],A=k9.test(Q),V=Y+1;while(A&&V<$.len&&$.kinds[V]==="text"&&$.isWordLike[V]&&S9.test($.texts[V])){let U=$.texts[V];D.push(U),A=k9.test(U),V++}M.push(i0(D)),J.push(!0),Z.push("text"),X.push($.starts[Y]),Y=V-1;continue}M.push(Q),J.push(q),Z.push(K),X.push($.starts[Y])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function gX($){let M=[],J=[],Z=[],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 D=0;D<K.length;D++){let A=K[D];if(!q)break;if(A.length===0||!v9(A)||!g8(A))q=!1}if(q){let D=0;for(let A=0;A<K.length;A++){let V=K[A],U=A<K.length-1?`${V}-`:V;M.push(U),J.push(!0),Z.push("text"),X.push($.starts[Y]+D),D+=U.length}continue}}M.push(Q),J.push($.isWordLike[Y]),Z.push($.kinds[Y]),X.push($.starts[Y])}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function IX($){let M=[],J=[],Z=[],X=[],Y=0;while(Y<$.len){let Q=[$.texts[Y]],K=$.isWordLike[Y],q=$.kinds[Y],D=$.starts[Y];if(q==="glue"){let A=[Q[0]],V=D;Y++;while(Y<$.len&&$.kinds[Y]==="glue")A.push($.texts[Y]),Y++;let U=i0(A);if(Y<$.len&&$.kinds[Y]==="text")Q[0]=U,Q.push($.texts[Y]),K=$.isWordLike[Y],q="text",D=V,Y++;else{M.push(U),J.push(!1),Z.push("glue"),X.push(V);continue}}else Y++;if(q==="text")while(Y<$.len&&$.kinds[Y]==="glue"){let A=[];while(Y<$.len&&$.kinds[Y]==="glue")A.push($.texts[Y]),Y++;let V=i0(A);if(Y<$.len&&$.kinds[Y]==="text"){Q.push(V,$.texts[Y]),K=K||$.isWordLike[Y],Y++;continue}Q.push(V)}M.push(i0(Q)),J.push(K),Z.push(q),X.push(D)}return{len:M.length,texts:M,isWordLike:J,kinds:Z,starts:X}}function pX($){let M=$.texts.slice(),J=$.isWordLike.slice(),Z=$.kinds.slice(),X=$.starts.slice();for(let Y=0;Y<M.length-1;Y++){if(Z[Y]!=="text"||Z[Y+1]!=="text")continue;if(!s0(M[Y])||!s0(M[Y+1]))continue;let Q=bX(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:J,kinds:Z,starts:X}}function lX($,M,J){let Z=FX(),X=0,Y=[],Q=[],K=[],q=[];for(let U of Z.segment($))for(let G of CX(U.segment,U.isWordLike??!1,U.index,J)){let _=G.kind==="text";if(M.carryCJKAfterClosingQuote&&_&&X>0&&K[X-1]==="text"&&s0(G.text)&&s0(Y[X-1])&&d8(Y[X-1]))Y[X-1]+=G.text,Q[X-1]=Q[X-1]||G.isWordLike;else if(_&&X>0&&K[X-1]==="text"&&PX(G.text)&&s0(Y[X-1]))Y[X-1]+=G.text,Q[X-1]=Q[X-1]||G.isWordLike;else if(_&&X>0&&K[X-1]==="text"&&OX(Y[X-1]))Y[X-1]+=G.text,Q[X-1]=Q[X-1]||G.isWordLike;else if(_&&X>0&&K[X-1]==="text"&&G.isWordLike&&v8(G.text)&&TX(Y[X-1]))Y[X-1]+=G.text,Q[X-1]=!0;else if(_&&!G.isWordLike&&X>0&&K[X-1]==="text"&&G.text.length===1&&G.text!=="-"&&G.text!=="—"&&wX(Y[X-1],G.text))Y[X-1]+=G.text;else if(_&&!G.isWordLike&&X>0&&K[X-1]==="text"&&(BX(G.text)||G.text==="-"&&Q[X-1]))Y[X-1]+=G.text;else Y[X]=G.text,Q[X]=G.isWordLike,K[X]=G.kind,q[X]=G.start,X++}for(let U=1;U<X;U++)if(K[U]==="text"&&!Q[U]&&l8(Y[U])&&K[U-1]==="text")Y[U-1]+=Y[U],Q[U-1]=Q[U-1]||Q[U],Y[U]="";for(let U=X-2;U>=0;U--)if(K[U]==="text"&&!Q[U]&&yX(Y[U])){let G=U+1;while(G<X&&Y[G]==="")G++;if(G<X&&K[G]==="text")Y[G]=Y[U]+Y[G],q[G]=q[U],Y[U]=""}let D=0;for(let U=0;U<X;U++){let G=Y[U];if(G.length===0)continue;if(D!==U)Y[D]=G,Q[D]=Q[U],K[D]=K[U],q[D]=q[U];D++}Y.length=D,Q.length=D,K.length=D,q.length=D;let A=IX({len:D,texts:Y,isWordLike:Q,kinds:K,starts:q}),V=pX(hX(gX(vX(kX(SX(A))))));for(let U=0;U<V.len-1;U++){let G=jX(V.texts[U]);if(G===null)continue;if(V.kinds[U]!=="space"&&V.kinds[U]!=="preserved-space"||V.kinds[U+1]!=="text"||!v8(V.texts[U+1]))continue;V.texts[U]=G.space,V.isWordLike[U]=!1,V.kinds[U]=V.kinds[U]==="preserved-space"?"preserved-space":"space",V.texts[U+1]=G.marks+V.texts[U+1],V.starts[U+1]=V.starts[U]+G.space.length}return V}function dX($,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 h9($,M,J="normal"){let Z=VX(J),X=Z.mode==="pre-wrap"?NX($):GX($);if(X.length===0)return{normalized:X,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let Y=lX(X,M,Z);return{normalized:X,chunks:dX(Y,Z),...Y}}var s1=null,g9=new Map,i1=null,rX=/\p{Emoji_Presentation}/u,xX=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,r8=null,I9=new Map;function x8(){if(s1!==null)return s1;if(typeof OffscreenCanvas<"u")return s1=new OffscreenCanvas(1,1).getContext("2d"),s1;if(typeof document<"u")return s1=document.createElement("canvas").getContext("2d"),s1;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function cX($){let M=g9.get($);if(!M)M=new Map,g9.set($,M);return M}function Z1($,M){let J=M.get($);if(J===void 0)J={width:x8().measureText($).width,containsCJK:s0($)},M.set($,J);return J}function o1(){if(i1!==null)return i1;if(typeof navigator>"u")return i1={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},i1;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 i1={lineFitEpsilon:J?0.015625:0.005,carryCJKAfterClosingQuote:Z,preferPrefixWidthsForBreakableRuns:J,preferEarlySoftHyphenBreak:J},i1}function aX($){let M=$.match(/(\d+(?:\.\d+)?)\s*px/);return M?parseFloat(M[1]):16}function c8(){if(r8===null)r8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return r8}function sX($){return rX.test($)||$.includes("️")}function p9($){return xX.test($)}function iX($,M){let J=I9.get($);if(J!==void 0)return J;let Z=x8();Z.font=$;let X=Z.measureText("\uD83D\uDE00").width;if(J=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)J=X-Q}return I9.set($,J),J}function oX($){let M=0,J=c8();for(let Z of J.segment($))if(sX(Z.segment))M++;return M}function nX($,M){if(M.emojiCount===void 0)M.emojiCount=oX($);return M.emojiCount}function X1($,M,J){if(J===0)return M.width;return M.width-nX($,M)*J}function l9($,M,J,Z){if(M.graphemeWidths!==void 0)return M.graphemeWidths;let X=[],Y=c8();for(let Q of Y.segment($)){let K=Z1(Q.segment,J);X.push(X1(Q.segment,K,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=[],Y=c8(),Q="";for(let K of Y.segment($)){Q+=K.segment;let q=Z1(Q,J);X.push(X1(Q,q,Z))}return M.graphemePrefixWidths=X.length>1?X:null,M.graphemePrefixWidths}function r9($,M){let J=x8();J.font=$;let Z=cX($),X=aX($),Y=M?iX($,X):0;return{cache:Z,fontSize:X,emojiCorrection:Y}}function X5($){return $==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen"}function tX($,M){while(M<$.widths.length){let J=$.kinds[M];if(J!=="space"&&J!=="zero-width-break"&&J!=="soft-hyphen")break;M++}return M}function eX($,M){if(M<=0)return 0;let J=$%M;if(Math.abs(J)<=0.000001)return M;return M-J}function x9($,M,J,Z){if(!Z||M===null)return $[J];return M[J]-(J>0?M[J-1]:0)}function $Y($,M,J,Z,X,Y){let Q=0,K=M;while(Q<$.length){let q=Y?M+$[Q]:K+$[Q];if((Q+1<$.length?q+X:q)>J+Z)break;K=q,Q++}return{fitCount:Q,fittedWidth:K}}function MY($,M,J){let{widths:Z,kinds:X,breakableWidths:Y,breakablePrefixWidths:Q}=$;if(Z.length===0)return 0;let K=o1(),q=K.lineFitEpsilon,D=0,A=0,V=!1,U=0,G=0,_=0,N=0,H=-1,E=0;function L(){H=-1,E=0}function W(P=_,y=N,F=A){D++,J?.({startSegmentIndex:U,startGraphemeIndex:G,endSegmentIndex:P,endGraphemeIndex:y,width:F}),A=0,V=!1,L()}function R(P,y){V=!0,U=P,G=0,_=P+1,N=0,A=y}function f(P,y,F){V=!0,U=P,G=y,_=P,N=y+1,A=F}function I(P,y){if(!V){R(P,y);return}A+=y,_=P+1,N=0}function B(P,y){if(!X5(X[P]))return;H=P+1,E=A-y}function b(P){z(P,0)}function z(P,y){let F=Y[P],C=Q[P]??null;for(let v=y;v<F.length;v++){let h=x9(F,C,v,K.preferPrefixWidthsForBreakableRuns);if(!V){f(P,v,h);continue}if(A+h>M+q)W(),f(P,v,h);else A+=h,_=P,N=v+1}if(V&&_===P&&N===F.length)_=P+1,N=0}let T=0;while(T<Z.length){if(!V){if(T=tX($,T),T>=Z.length)break}let P=Z[T],y=X[T];if(!V){if(P>M&&Y[T]!==null)b(T);else R(T,P);B(T,P),T++;continue}if(A+P>M+q){if(X5(y)){I(T,P),W(T+1,0,A-P),T++;continue}if(H>=0){if(_>H||_===H&&N>0){W();continue}W(H,0,E);continue}if(P>M&&Y[T]!==null){W(),b(T),T++;continue}W();continue}I(T,P),B(T,P),T++}if(V)W();return D}function c9($,M,J){if($.simpleLineWalkFastPath)return MY($,M,J);let{widths:Z,lineEndFitAdvances:X,lineEndPaintAdvances:Y,kinds:Q,breakableWidths:K,breakablePrefixWidths:q,discretionaryHyphenWidth:D,tabStopAdvance:A,chunks:V}=$;if(Z.length===0||V.length===0)return 0;let U=o1(),G=U.lineFitEpsilon,_=0,N=0,H=!1,E=0,L=0,W=0,R=0,f=-1,I=0,B=0,b=null;function z(){f=-1,I=0,B=0,b=null}function T(w=W,m=R,S=N){_++,J?.({startSegmentIndex:E,startGraphemeIndex:L,endSegmentIndex:w,endGraphemeIndex:m,width:S}),N=0,H=!1,z()}function P(w,m){H=!0,E=w,L=0,W=w+1,R=0,N=m}function y(w,m,S){H=!0,E=w,L=m,W=w,R=m+1,N=S}function F(w,m){if(!H){P(w,m);return}N+=m,W=w+1,R=0}function C(w,m){if(!X5(Q[w]))return;let S=Q[w]==="tab"?0:X[w],c=Q[w]==="tab"?m:Y[w];f=w+1,I=N-m+S,B=N-m+c,b=Q[w]}function v(w){h(w,0)}function h(w,m){let S=K[w],c=q[w]??null;for(let l=m;l<S.length;l++){let F0=x9(S,c,l,U.preferPrefixWidthsForBreakableRuns);if(!H){y(w,l,F0);continue}if(N+F0>M+G)T(),y(w,l,F0);else N+=F0,W=w,R=l+1}if(H&&W===w&&R===S.length)W=w+1,R=0}function g(w){if(b!=="soft-hyphen")return!1;let m=K[w];if(m===null)return!1;let S=U.preferPrefixWidthsForBreakableRuns?q[w]??m:m,c=S!==m,{fitCount:l,fittedWidth:F0}=$Y(S,N,M,G,D,c);if(l===0)return!1;if(N=F0,W=w,R=l,z(),l===m.length)return W=w+1,R=0,!0;return T(w,l,F0+D),h(w,l),!0}function O(w){_++,J?.({startSegmentIndex:w.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:w.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),z()}for(let w=0;w<V.length;w++){let m=V[w];if(m.startSegmentIndex===m.endSegmentIndex){O(m);continue}H=!1,N=0,E=m.startSegmentIndex,L=0,W=m.startSegmentIndex,R=0,z();let S=m.startSegmentIndex;while(S<m.endSegmentIndex){let c=Q[S],l=c==="tab"?eX(N,A):Z[S];if(c==="soft-hyphen"){if(H)W=S+1,R=0,f=S+1,I=N+D,B=N+D,b=c;S++;continue}if(!H){if(l>M&&K[S]!==null)v(S);else P(S,l);C(S,l),S++;continue}if(N+l>M+G){let x0=N+(c==="tab"?0:X[S]),f0=N+(c==="tab"?l:Y[S]);if(b==="soft-hyphen"&&U.preferEarlySoftHyphenBreak&&I<=M+G){T(f,0,B);continue}if(b==="soft-hyphen"&&g(S)){S++;continue}if(X5(c)&&x0<=M+G){F(S,l),T(S+1,0,f0),S++;continue}if(f>=0&&I<=M+G){if(W>f||W===f&&R>0){T();continue}let m0=f;T(m0,0,B),S=m0;continue}if(l>M&&K[S]!==null){T(),v(S),S++;continue}T();continue}F(S,l),C(S,l),S++}if(H){let c=f===m.consumedEndSegmentIndex?B:N;T(m.consumedEndSegmentIndex,0,c)}}return _}var a8=null,a9=new WeakMap;function i9(){if(a8===null)a8=new Intl.Segmenter(void 0,{granularity:"grapheme"});return a8}function JY($){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 ZY($,M,J){let Z=i9(),X=o1(),{cache:Y,emojiCorrection:Q}=r9(M,p9($.normalized)),K=X1("-",Z1("-",Y),Q),D=X1(" ",Z1(" ",Y),Q)*8;if($.len===0)return JY(J);let A=[],V=[],U=[],G=[],_=$.chunks.length<=1,N=J?[]:null,H=[],E=[],L=J?[]:null,W=Array.from({length:$.len}),R=Array.from({length:$.len});function f(b,z,T,P,y,F,C,v){if(y!=="text"&&y!=="space"&&y!=="zero-width-break")_=!1;if(A.push(z),V.push(T),U.push(P),G.push(y),N?.push(F),H.push(C),E.push(v),L!==null)L.push(b)}for(let b=0;b<$.len;b++){W[b]=A.length;let z=$.texts[b],T=$.isWordLike[b],P=$.kinds[b],y=$.starts[b];if(P==="soft-hyphen"){f(z,0,K,K,P,y,null,null),R[b]=A.length;continue}if(P==="hard-break"){f(z,0,0,0,P,y,null,null),R[b]=A.length;continue}if(P==="tab"){f(z,0,0,0,P,y,null,null),R[b]=A.length;continue}let F=Z1(z,Y);if(P==="text"&&F.containsCJK){let g="",O=0;for(let w of Z.segment(z)){let m=w.segment;if(g.length===0){g=m,O=w.index;continue}if(O2.has(g)||I8.has(m)||a1.has(m)||X.carryCJKAfterClosingQuote&&s0(m)&&d8(g)){g+=m;continue}let S=Z1(g,Y),c=X1(g,S,Q);f(g,c,c,c,"text",y+O,null,null),g=m,O=w.index}if(g.length>0){let w=Z1(g,Y),m=X1(g,w,Q);f(g,m,m,m,"text",y+O,null,null)}R[b]=A.length;continue}let C=X1(z,F,Q),v=P==="space"||P==="preserved-space"||P==="zero-width-break"?0:C,h=P==="space"||P==="zero-width-break"?0:C;if(T&&z.length>1){let g=l9(z,F,Y,Q),O=X.preferPrefixWidthsForBreakableRuns?d9(z,F,Y,Q):null;f(z,C,v,h,P,y,g,O)}else f(z,C,v,h,P,y,null,null);R[b]=A.length}let I=XY($.chunks,W,R),B=N===null?null:m9($.normalized,N);if(L!==null)return{widths:A,lineEndFitAdvances:V,lineEndPaintAdvances:U,kinds:G,simpleLineWalkFastPath:_,segLevels:B,breakableWidths:H,breakablePrefixWidths:E,discretionaryHyphenWidth:K,tabStopAdvance:D,chunks:I,segments:L};return{widths:A,lineEndFitAdvances:V,lineEndPaintAdvances:U,kinds:G,simpleLineWalkFastPath:_,segLevels:B,breakableWidths:H,breakablePrefixWidths:E,discretionaryHyphenWidth:K,tabStopAdvance:D,chunks:I}}function XY($,M,J){let Z=[];for(let X=0;X<$.length;X++){let Y=$[X],Q=Y.startSegmentIndex<M.length?M[Y.startSegmentIndex]:J[J.length-1]??0,K=Y.endSegmentIndex<M.length?M[Y.endSegmentIndex]:J[J.length-1]??0,q=Y.consumedEndSegmentIndex<M.length?M[Y.consumedEndSegmentIndex]:J[J.length-1]??0;Z.push({startSegmentIndex:Q,endSegmentIndex:K,consumedEndSegmentIndex:q})}return Z}function YY($,M,J,Z){let X=h9($,o1(),Z?.whiteSpace);return ZY(X,M,J)}function o9($,M,J){return YY($,M,!0,J)}function QY($){return $}function s9($,M,J){let Z=J.get($);if(Z!==void 0)return Z;Z=[];let X=i9();for(let Y of X.segment(M[$]))Z.push(Y.segment);return J.set($,Z),Z}function KY($){let M=a9.get($);if(M!==void 0)return M;return M=new Map,a9.set($,M),M}function DY($,M,J,Z){return Z>0&&$[Z-1]==="soft-hyphen"&&!(M===Z&&J>0)}function qY($,M,J,Z,X,Y,Q){let K="",q=DY(M,Z,X,Y);for(let D=Z;D<Y;D++){if(M[D]==="soft-hyphen"||M[D]==="hard-break")continue;if(D===Z&&X>0)K+=s9(D,$,J).slice(X).join("");else K+=$[D]}if(Q>0){if(q)K+="-";K+=s9(Y,$,J).slice(Z===Y?X:0,Q).join("")}else if(q)K+="-";return K}function AY($,M,J,Z,X,Y,Q){return{text:qY($.segments,$.kinds,M,Z,X,Y,Q),width:J,start:{segmentIndex:Z,graphemeIndex:X},end:{segmentIndex:Y,graphemeIndex:Q}}}function UY($,M,J){return AY($,M,J.width,J.startSegmentIndex,J.startGraphemeIndex,J.endSegmentIndex,J.endGraphemeIndex)}function n9($,M,J){let Z=[];if($.widths.length===0)return{lineCount:0,height:0,lines:Z};let X=KY($),Y=c9(QY($),M,(Q)=>{Z.push(UY($,X,Q))});return{lineCount:Y,height:Y*J,lines:Z}}var t9=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],Y5;function n1($){if($?.type==="heading"){let{fontSize:M}=M$($.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 P1($,M){if($?.type==="heading")return M$($.depth).lineHeight;if($?.type==="code")return 22;return M}function M$($){return t9[$-1]??t9.at(-1)}function t1($,M,J,Z,X,Y,Q){let K=`${K5(M,Q)}:${X}:${Y}:${J}`,q=$.measuredLines.get(K);if(q)return q;let D=GY($,M,J,Z,X,Y,Q);return O9($,K,D)}function Q5($,M,J,Z,X,Y,Q,K){let q=`${K5(M,K)}:${J}:${Z}:${Y}:${Q}`,D=$.lineBoundaries.get(q);if(D)return D;let A=Z$();if(!A)return $$(X);let V=[{left:0,offset:0}],U=0,G=M.inlines.filter((_)=>_.end>J&&_.start<Z);if(G.length===0)return $$(X);for(let _ of G){let N=Math.max(J,_.start),H=Math.min(Z,_.end),E=M.text.slice(N,H),L=N-J;if(_.kind==="image"){let W=M5(_,K,Q).width;U+=W,L+=E.length,V.push({left:U,offset:L});continue}A.font=J$(Y,_.marks);for(let W of Array.from(E))U+=X$($,A,W),L+=W.length,V.push({left:U,offset:L})}return j9($,q,V)}function VY($,M,J,Z){let X=`${J}::${Z}::${M}`,Y=$.preparedText.get(X);if(Y)return Y;let Q=o9(M,J,{whiteSpace:Z});return T9($,X,Q)}function GY($,M,J,Z,X,Y,Q){let K=M.text;if(K.length===0)return[{end:0,height:Y,start:0,text:"",width:0}];if(zY(M))return _Y($,M,J,X,Y,Q);try{let q=VY($,K,J,yY(Z));return n9(q,X,Y).lines.map((A)=>({end:e9(q.segments,A.end),height:Y,start:e9(q.segments,A.start),text:A.text,width:A.width}))}catch{return NY(K,X,Y)}}function e9($,M){let J=0;for(let Y=0;Y<M.segmentIndex;Y+=1)J+=$[Y]?.length??0;let Z=$[M.segmentIndex]??"",X=Array.from(Z);for(let Y=0;Y<M.graphemeIndex;Y+=1)J+=X[Y]?.length??0;return J}function $$($){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 NY($,M,J){let Z=Math.max(1,Math.floor(M/9)),X=bY($,Z),Y=0;return X.map((Q)=>{let K=Y,q=K+Q.length;return Y=q,{end:q,height:J,start:K,text:Q,width:Q.length*9}})}function _Y($,M,J,Z,X,Y){let Q=HY($,Z$(),M,J,Z,X,Y);if(Q.length===0)return[{end:0,height:X,start:0,text:"",width:0}];return FY(Q,M.text,Z,X)}function FY($,M,J,Z){let X=[],Y=0;while(Y<$.length){let Q=$[Y].start;if($[Y].text===`
|
|
14
|
-
`){
|
|
15
|
-
`)break;let _=
|
|
16
|
-
`){let
|
|
17
|
-
`?
|
|
18
|
-
|
|
19
|
-
`),Z=[];for(let X of J){if(X.length===0){Z.push("");continue}let Y=X;while(Y.length>M){let Q=Y.slice(0,M),K=Q.lastIndexOf(" ");if(K<=0){Z.push(Q),Y=Y.slice(M);continue}Z.push(Q.slice(0,K)),Y=Y.slice(K+1)}Z.push(Y)}return Z}var j2=10,e1=8,s8=120;function Y$($,M,J,Z,X,Y,Q,K,q,D){let A=Math.max(1,...Y.rows.map((N)=>N.cells.length)),U=Math.max(s8,q.width-Q-q.paddingX)/A,G=wY(Z),_=K;for(let N=0;N<Y.rows.length;N+=1){let H=TY(G.get(N)??[],X,Y,U,j2,q.lineHeight,D),E=Math.max(q.lineHeight+e1*2,...H.map((L)=>L.measuredLines.reduce((W,R)=>W+R.height,0)+e1*2));for(let L of H){let W=Q+L.cellIndex*U,R=_+e1;for(let f of L.measuredLines){let I={blockId:L.container.blockId,boundaries:Q5(X,L.container,f.start,f.end,f.text,L.font,U-j2*2,D),regionId:L.container.id,end:f.end,font:L.font,height:f.height,left:W+j2,start:f.start,text:f.text,top:R,width:f.width};$.push(I),i8(M,I),R+=f.height}J.set(L.container.id,{bottom:_+E,left:W,right:W+U,top:_})}jY(M,Y.id,_,_+E),_+=E}return _+q.blockGap}function wY($){let M=new Map;for(let J of $){let Z=OY(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 TY($,M,J,Z,X,Y,Q){return[...$].sort((K,q)=>K.cellIndex-q.cellIndex).map(({cellIndex:K,container:q})=>{let D=n1(J),A=P1(J,Y),V=t1(M,q,D,J,Math.max(40,Z-X*2),A,Q);return{cellIndex:K,container:q,font:D,lineHeight:A,measuredLines:V}})}function OY($){let M=/\.rows\.(\d+)\.cells\.(\d+)$/.exec($);if(!M)return null;return{cellIndex:Number(M[2]),rowIndex:Number(M[1])}}function jY($,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 LY={blockGap:16,charWidth:9,indentWidth:24,lineHeight:24,paddingX:16,paddingY:12},CY=24,RY=16,fY=6,mY=10,SY=4;function D5($){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 q5($,M,J=B1(),Z=null){let X=Z??{images:new Map},Y={...LY,...M},Q=[],K=new Map,q=new Map($.regions.map((N)=>[N.id,{textLength:N.text.length}])),D=new Map($.blocks.map((N)=>[N.id,N.depth])),A=new Map($.blocks.map((N)=>[N.id,N])),V=C2($.document.blocks),U=new Map,G=Y.paddingY;for(let N=0;N<$.regions.length;N+=1){let H=$.regions[N],E=D.get(H.blockId)??0,L=Y.paddingX+E*Y.indentWidth,W=Math.max(40,Y.width-L-Y.paddingX),R=V.get(H.blockId)??null;if(R?.type==="table"){let B=A.get(H.blockId)?.regionIds??[],b=$.regions.slice(N,N+B.length);G=Y$(Q,U,K,b,J,R,L,G,Y,X),N+=b.length-1;continue}G=kY(Q,U,K,H,J,R,L,G,W,Y,X);let f=U5(A,V,$.regions,N,Y.blockGap);G+=f;let I=U.get(H.blockId);if(I)I.bottom=Math.max(I.bottom,G)}return{blocks:$.blocks.map((N)=>{let H=U.get(N.id),E=H?.top??Y.paddingY;return{bottom:H?.bottom??E+Y.lineHeight/2,depth:N.depth,id:N.id,top:E,type:N.type}}),regionBounds:vY(Q,K),regionLineIndices:uY(Q),regionMetrics:q,height:Math.max(G,Y.paddingY),lines:Q,options:Y,width:Y.width}}function kY($,M,J,Z,X,Y,Q,K,q,D,A){let V=n1(Y),U=P1(Y,D.lineHeight),G=t1(X,Z,V,Y,q,U,A),_=K;for(let N of G){let H={blockId:Z.blockId,boundaries:Q5(X,Z,N.start,N.end,N.text,V,q,A),regionId:Z.id,end:N.end,font:V,height:N.height,left:Q,start:N.start,text:N.text,top:_,width:N.width};$.push(H),i8(M,H),_+=N.height}return hY($,Z.id,J),_}function uY($){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 Y=J.get(X.regionId)??[];Y.push(Z),J.set(X.regionId,Y)}return J}function vY($,M){let J=new Map(M);for(let Z of $){let X=J.get(Z.regionId),Y={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,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 J}function hY($,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 i8($,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 A$($,M){let J=0,Z=$.lines.length-1;while(J<=Z){let X=J+Z>>1,Y=$.lines[X];if(M<Y.top){Z=X-1;continue}if(M>=Y.top+Y.height){J=X+1;continue}return{index:X,line:Y}}return null}function o8($,M){let J=[...$.regionBounds.entries()].find(([,Y])=>{return M.x>=Y.left&&M.x<=Y.right&&M.y>=Y.top&&M.y<=Y.bottom});if(J)return A5($,J[0],M.y);let Z=A$($,M.y);if(!Z)return null;let X=gY($,M.y,Z.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),D=Q$(M.x,K),A=Q$(M.x,q);return D-A})[0]??null}function n8($,M,J){if($.lines.length===0)return{endIndex:0,startIndex:0};let Z=M+J,X=K$($,M),Y=K$($,Z);if(X>0){let Q=$.lines[X-1];if(Q.top+Q.height>M)X-=1}if(Y<$.lines.length){if($.lines[Y].top<Z)Y+=1}return{endIndex:Y,startIndex:X}}function g0($,M,J){if(!$.regionMetrics.get(J.regionId))return null;let X=j0($,J.regionId,J.offset);if(!X)return null;return{blockId:X.blockId,regionId:X.regionId,height:X.height,left:W0(X,J.offset-X.start),offset:J.offset,top:X.top}}function j0($,M,J){return L2($,M,J)?.line??null}function A5($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=Z[0],Y=Number.POSITIVE_INFINITY;for(let Q of Z){let K=$.lines[Q],q=J<K.top?K.top-J:J>K.top+K.height?J-(K.top+K.height):0;if(q<Y)Y=q,X=Q;if(q===0)break}return{index:X,line:$.lines[X]}}function L2($,M,J){let Z=$.regionLineIndices.get(M);if(!Z||Z.length===0)return null;let X=0,Y=Z.length-1;while(X<=Y){let A=X+Y>>1,V=Z[A],U=$.lines[V];if(J<U.start){Y=A-1;continue}if(J>U.end){X=A+1;continue}return{index:V,line:U}}let Q=Z[0],K=Z[Z.length-1],q=$.lines[Q],D=$.lines[K];if(J<=q.start)return{index:Q,line:q};if(J>=D.end)return{index:K,line:D};return null}function gY($,M,J){let Z=[];for(let X=J;X>=0;X-=1){let Y=$.lines[X];if(M<Y.top||M>=Y.top+Y.height)break;Z.unshift({index:X,line:Y})}for(let X=J+1;X<$.lines.length;X+=1){let Y=$.lines[X];if(M<Y.top||M>=Y.top+Y.height)break;Z.push({index:X,line:Y})}return Z}function Q$($,M){if(!M)return Number.POSITIVE_INFINITY;if($<M.left)return M.left-$;if($>M.right)return $-M.right;return 0}function W0($,M){return $.left+IY($.boundaries,M)}function C2($){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 IY($,M){for(let Z of $)if(Z.offset===M)return Z.left;return $.filter((Z)=>Z.offset<=M).at(-1)?.left??0}function K$($,M){let J=0,Z=$.lines.length;while(J<Z){let X=J+Z>>1,Y=$.lines[X];if(Y.top+Y.height<=M)J=X+1;else Z=X}return J}function U$($,M){if($.length===0)return 0;for(let J=1;J<$.length;J+=1){let Z=$[J-1],X=$[J],Y=Z.left+(X.left-Z.left)/2;if(M<=Y)return Z.offset;if(M<=X.left)return X.offset}return $.at(-1)?.offset??0}function U5($,M,J,Z,X){let Y=J[Z],Q=J[Z+1];if(!Y||!Q)return X;if(D$($,Y.blockId,Q.blockId,"list"))return fY;if(D$($,Y.blockId,Q.blockId,"blockquote"))return mY;if(Y.blockId===Q.blockId)return SY;return X+pY(M.get(Y.blockId))}function pY($){if($?.type!=="heading")return 0;if($.depth===1)return CY;return $.depth===2?RY:0}function D$($,M,J,Z){let X=q$($,M,Z),Y=q$($,J,Z);for(let Q of X)if(Y.has(Q))return!0;return!1}function q$($,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 t8($,M,J,Z=[],X=B1(),Y=null){let Q=Y??{images:new Map},K=C2($.document.blocks),q=new Map($.blocks.map((W)=>[W.id,W])),D=new Set(Z),A=Math.max(0,J.top-J.overscan),V=J.top+J.height+J.overscan,U=cY(X,$,K,q,M,Q),G=V$(U,A),_=V$(U,V);if(G>0){let W=U.entries[G-1];if(W&&W.bottom>A)G-=1}if(_<U.entries.length){let W=U.entries[_];if(W&&W.top<V)_+=1}for(let W of D){let R=U.containerIndices.get(W);if(R===void 0)continue;G=Math.min(G,R),_=Math.max(_,R+1)}if(!Number.isFinite(G)||!Number.isFinite(_))return{estimateRegionBounds:U.estimateRegionBounds,layout:q5({...$,regions:[]},M,X,Q),totalHeight:U.totalHeight,viewport:J};let N=rY($,q,U.containerIndices,G,_),H=U.entries[N.startIndex]?.top??M.paddingY??0,E=q5({...$,regions:$.regions.slice(N.startIndex,N.endIndex)},M,X,Q),L=dY(E,H,U.totalHeight);return lY(X,$,L,M,Q),{estimateRegionBounds:U.estimateRegionBounds,layout:L,totalHeight:U.totalHeight,viewport:J}}function lY($,M,J,Z,X){for(let[Y,Q]of J.regionBounds){let K=Q.bottom-Q.top,q=M.regionIndex.get(Y);L9($,G$(q??{path:Y,inlines:[],text:""},Z,X),K)}}function dY($,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 rY($,M,J,Z,X){let Y=Z,Q=X;for(let K=Z;K<X;K+=1){let q=$.regions[K],D=M.get(q.blockId);if(!D)continue;if(D.type==="table"){let A=J.get(D.regionIds[0]??""),V=J.get(D.regionIds[D.regionIds.length-1]??"");if(A!==void 0)Y=Math.min(Y,A);if(V!==void 0)Q=Math.max(Q,V+1)}}return{endIndex:Q,startIndex:Y}}function xY($,M,J,Z,X,Y){let Q=G$(M,X,Y),K=$.measuredContainerHeights.get(Q);if(K!==void 0)return K;let q=X.paddingX??0,D=X.indentWidth??24,A=P1(J,X.lineHeight??24),V=q+Z*D,U=Math.max(40,X.width-V-q);if(M.inlines.some((N)=>N.kind==="image")){let N=n1(J);return t1($,M,N,J,U,A,Y).reduce((H,E)=>H+E.height,0)}let G=D5({text:M.text,width:U});return Math.max(A,G.lineCount*A)}function cY($,M,J,Z,X,Y){let Q=oY(M,X,Y),K=R9($,M,Q);if(K)return K;let q=X.paddingY??0,D=[],A=new Map;for(let V=0;V<M.regions.length;V+=1){let U=M.regions[V],G=J.get(U.blockId)??null;if(G?.type==="table"){let E=aY({block:G,blockMap:J,containerIndices:A,entries:D,index:V,options:X,runtimeBlocks:Z,totalHeight:q,regions:M.regions});if(E){V=E.nextIndex-1,q=E.totalHeight;continue}}let _=xY($,U,G,Z.get(U.blockId)?.depth??0,X,Y),N=q,H=N+_;D.push({bottom:H,top:N}),A.set(U.id,V),q=H+U5(Z,J,M.regions,V,X.blockGap??16)}return f9($,M,Q,{containerIndices:A,entries:D,estimateRegionBounds(V){let U=A.get(V);return U===void 0?null:D[U]??null},totalHeight:q})}function aY({block:$,blockMap:M,containerIndices:J,entries:Z,index:X,options:Y,runtimeBlocks:Q,totalHeight:K,regions:q}){let D=Q.get($.id),A=D?.regionIds??[];if(A.length===0)return null;let V=q.slice(X,X+A.length);if(V.length===0||V[0]?.blockId!==$.id)return null;let U=Y.paddingX??0,G=Y.indentWidth??24,_=D?.depth??0,N=U+_*G,H=Math.max(s8,Y.width-N-U),E=Math.max(1,...$.rows.map((B)=>B.cells.length)),L=H/E,W=Math.max(40,L-j2*2),R=P1($,Y.lineHeight??24),f=sY(V,X),I=K;for(let B=0;B<$.rows.length;B+=1){let b=f.get(B)??[],z=Math.max(R+e1*2,...b.map(({region:P})=>iY(P,W,R)+e1*2)),T=I+z;for(let{index:P,region:y}of b)Z[P]={bottom:T,top:I},J.set(y.id,P);I=T}for(let B=X;B<X+V.length;B+=1){let b=q[B];if(!b||Z[B])continue;Z[B]={bottom:I,top:I},J.set(b.id,B)}return{nextIndex:X+V.length,totalHeight:I+U5(Q,M,q,X+V.length-1,Y.blockGap??16)}}function sY($,M){let J=new Map;for(let[Z,X]of $.entries()){let Y=X.tableCellPosition?.rowIndex;if(Y===void 0)continue;let Q=J.get(Y)??[];Q.push({index:M+Z,region:X}),J.set(Y,Q)}return J}function iY($,M,J){let Z=D5({text:$.text,width:M});return Math.max(J,Z.lineCount*J)}function oY($,M,J){return[M.width,M.paddingX??0,M.paddingY??0,M.indentWidth??24,M.lineHeight??24,M.blockGap??16,nY($,J)].join(":")}function V$($,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 G$($,M,J){return`${K5($,J)}:${M.width}:${M.paddingX??0}:${M.indentWidth??24}:${M.lineHeight??24}`}function nY($,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 V5=null;function tY($){let M=/(\d+(?:\.\d+)?)\s*px/.exec($);return M?Number.parseFloat(M[1]):16}function Y1($){V5??=new Map;let M=V5.get($);if(M)return M;let J=F$(),Z=Math.max(12,Math.round(tY($)));if(!J){let U={ascent:Math.round(Z*0.8),descent:Math.max(2,Z-Math.round(Z*0.8)),emHeight:Z};return V5.set($,U),U}J.font=$;let X=J.measureText("Hg"),Y=Math.round(X.actualBoundingBoxAscent||0),Q=Math.round(X.actualBoundingBoxDescent||0),K=Y+Q,q=Math.max(Z,K),D=K>0?Y:Math.round(q*0.8),A=K>0?Q:Math.max(2,q-D),V={ascent:D,descent:A,emHeight:q};return V5.set($,V),V}function eY($,M){let{emHeight:J}=Y1(M);return Math.max(0,Math.floor(($-J)/2))}function N$($,M){let{ascent:J}=Y1(M);return eY($,M)+J}var G5;function _$($,M){let J=F$();if(!J||$.length===0)return 0;return J.font=M,J.measureText($).width}function F$(){if(G5!==void 0)return G5;return G5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,G5}var $Q=18,MQ=14,JQ=22;function y0($,M,J){let Z=XQ($,J);if(!Z)return null;return H$($,M,Z,J.x)}function e8($,M,J){let Z=$.lines[$.lines.length-1];if(!Z||J.y<=Z.top+Z.height)return null;return H$($,M,Z,J.x)}function H$($,M,J,Z){let X=$.regionMetrics.get(J.regionId);if(!X)return null;let Y=Math.max(0,Z-h0(M,J)-J.left),Q=U$(J.boundaries,Y),K=Math.min(X.textLength,J.start+Q);return{regionId:J.regionId,offset:K,left:W0(J,Q),top:J.top,height:J.height}}function $6($,M,J,Z){let X=Y6(M,Z.regionId);if(!X)return null;let Y=y0($,M,J);if(Y)return{regionId:Y.regionId,offset:Y.offset};let Q=J.y<QQ($);return{regionId:Z.regionId,offset:Q?0:X.text.length}}function M6($,M,J){let Z=y0($,M,J);if(!Z)return null;let X=Y6(M,Z.regionId);if(!X||X.text.length===0)return null;let Y=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,Q=KQ(X.text,Y);if(Q.start===Q.end)return null;return{anchor:{regionId:Z.regionId,offset:Q.start},focus:{regionId:Z.regionId,offset:Q.end}}}function z$($,M,J){let Z=YQ($,J);if(!Z||Z.start!==0)return null;let X=$2(M,Z.blockId,"listItem");if(!X)return null;if(f2(M,X.id)?.kind!=="task")return null;let Q=R2(Z),K=Q.left-4,q=Q.left+Q.size+4,D=Q.top-4,A=Q.top+Q.size+4;return J.x>=K&&J.x<=q&&J.y>=D&&J.y<=A?{listItemId:X.id}:null}function E$($,M,J){let Z=y0($,M,J);if(!Z)return null;let X=Y6(M,Z.regionId);if(!X)return null;let Y=X.inlines.find((K)=>K.link&&Z.offset>=K.start&&Z.offset<K.end);if(!Y?.link)return null;let Q=X6($,M,Z.regionId,Y.start);if(!Q)return null;return{anchorBottom:Q.anchorBottom,anchorLeft:Q.anchorLeft,endOffset:Y.end,regionId:Z.regionId,startOffset:Y.start,title:Y.link.title,url:Y.link.url}}function J6($,M,J,Z){let X=z$($,M,J);if(X)return{kind:"task-toggle",listItemId:X.listItemId};let Y=y0($,M,J);if(!Y)return null;let Q=W$(Y.regionId,Y.offset,Z),K=Q!==null?B$(Q,$,M,Z):null,q=E$($,M,J);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 Z6($,M,J,Z){let X=M.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let Y=W$(J.regionId,J.offset,Z),Q=Y!==null?B$(Y,$,M,Z):null,K=X.inlines.find((q)=>J.offset>=q.start&&J.offset<=q.end)??null;if(K?.link){let q=X6($,M,J.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:J.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 I0($,M,J){let Z=j0(M,J.regionId,J.offset);if(!Z)return J.left;return J.left+h0($,Z)+ZQ($,Z,J.offset)}function Q1($,M,J){return W0(M,J)+h0($,M)}function h0($,M){let J=$2($,M.blockId,"listItem");if(!J)return 0;return f2($,J.id)?.kind==="task"?JQ:$Q}function R2($){return{left:$.left,size:MQ,top:$.top+3}}function $2($,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 f2($,M){return $.documentIndex.listItemMarkers.get(M)??null}function W$($,M,J){for(let Z of J)if(Z.regionId===$&&M>=Z.startOffset&&M<=Z.endOffset)return Z.threadIndex;return null}function B$($,M,J,Z){let X=Z.find((Y)=>Y.threadIndex===$);if(!X)return null;return X6(M,J,X.regionId,X.startOffset)}function X6($,M,J,Z){let X=j0($,J,Z);if(!X)return null;return{anchorBottom:X.top+X.height,anchorLeft:W0(X,Z)+h0(M,X)}}function ZQ($,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 _$(X,M.font)}function XQ($,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=o8($,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 YQ($,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 Y6($,M){return $.documentIndex.regionIndex.get(M)??null}function QQ($){return $.lines[0]?.top??0}function KQ($,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 Q6($,M,J,Z=null){let X={height:M.height,overscan:Math.max(160,M.height),top:M.top},Y=t8($.documentIndex,M,X,[$.selection.anchor.regionId,$.selection.focus.regionId],J,Z);return{blockMap:C2($.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 N5($,M,J){return y0(M.layout,$,J)??e8(M.layout,$,J)}function m2($,M,J,Z){return $6(M.layout,$,J,Z)}function K6($,M,J){return M6(M.layout,$,J)}function D6($,M,J,Z){return J6(M.layout,$,J,Z)}function q6($,M,J,Z){return Z6(M.layout,$,J,Z)}function A6($,M,J){return g0(M.layout,$.documentIndex,J)}function o0($,M,J){let Z=g0(M.layout,$.documentIndex,J);if(!Z)return null;return{...Z,left:I0($,M.layout,Z)}}function P$($,M,J,Z,X){let Y=Z-J,Q=X-Y;if(Z<=$)return{end:M+Q,start:$+Q};if(J>=M)return{end:M,start:$};let K=Math.max(0,Math.min(J,M)-$),q=Math.max(0,M-Math.max(Z,$)),D=$<J?$:J;return{end:D+K+X+q,start:D}}function V6($,M,J){let Z=J.trim();if(Z.length===0||M.startOffset===M.endOffset)return null;let X=$.regionIndex.get(M.regionId)??null,Y=X?U6($,X):null;if(!Y)return null;return L8({anchor:y2(Y,M.startOffset,M.endOffset),body:Z,quote:b2(Y,M.startOffset,M.endOffset)})}function L0($){let M="documentIndex"in $?$.documentIndex:$,J=_5(M),Z=M.document.comments,X=[...Z],Y=[];for(let[Q,K]of Z.entries()){let q=w2(K,M.document);if(!q.match)continue;let A=J.findBySemanticMatch(q.match.containerId,q.match.containerOrdinal)?.runtimeContainer??null;if(!A)continue;if(q.repair)X[Q]={...K,anchor:q.repair.anchor,quote:q.repair.quote};Y.push({endOffset:q.match.endOffset,resolution:q,regionId:A.id,resolved:K.resolvedAt!=null,startOffset:q.match.startOffset,threadIndex:Q})}return{liveRanges:Y,threads:X}}function G6($,M,J,Z,X,Y){if($.document.comments.length===0)return M.document.comments;let Q=$.commentContainerIndex.get(J.semanticRegionId)??[],K=new Set(Q);if(Q.length===0)return M.document.comments;let q=L0($),D=new Map(q.liveRanges.map((G)=>[G.threadIndex,G])),A=U6($,J),V=M2(M,J.path),U=V?U6(M,V):null;if(!A||!U)return M.document.comments;return M.document.comments.map((G,_)=>{if(!K.has(_))return G;let N=D.get(_),H=N?.resolution.match??null;if(!N||!H||H.containerId!==A.id)return G;let E=P$(H.startOffset,H.endOffset,Z,X,Y.length);return{...G,anchor:y2(U,E.start,E.end),quote:b2(U,E.start,E.end)}})}function U6($,M){let J=DQ($,M);if(!J)return null;return{containerKind:J,containerOrdinal:-1,id:M.semanticRegionId,text:M.text}}function DQ($,M){if($.tableCellIndex.has(M.id))return"tableCell";return E9(M.blockType)}function F5($,M){if(M.length===0)return[];let J=_5($),Z=J.list();return M.map((X)=>({...X,cursorPoint:qQ(X,Z,J),viewport:null}))}function qQ($,M,J){if(!$.cursor)return null;let Z=AQ(M,$.cursor),X=UQ(Z,$.cursor);if(X.length!==1)return null;let Y=X[0],Q=J.resolveRuntimeContainer(Y.container.id);if(!Q)return null;return{offset:Math.max(0,Math.min(Y.offset,Q.text.length)),regionId:Q.id}}function AQ($,M){return M.kind?$.filter((J)=>J.containerKind===M.kind):$}function UQ($,M){if(M.prefix&&M.suffix)return VQ($,M.prefix,M.suffix);if(M.prefix)return y$($,M.prefix,"after");if(M.suffix)return y$($,M.suffix,"before");return[]}function y$($,M,J){let Z=[];for(let X of $)for(let Y of v0(X.text,M))Z.push({container:X,offset:J==="after"?Y+M.length:Y});return Z}function VQ($,M,J){let Z=[];for(let X of $)for(let Y of c1(X.text,M,J))Z.push({container:X,offset:Y.startOffset});return Z}var GQ=48;function S2($,M,J){let Z="documentIndex"in $?$.documentIndex:$;if(J.length===0)return[];return J.map((X)=>({...X,viewport:NQ(Z,M,X)}))}function NQ($,M,J){if(!J.cursorPoint)return{status:"unresolved"};let Z=g0(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:FQ(M,X),status:_Q(M,X)}}function _Q($,M){let J=$.viewport.top,Z=J+$.viewport.height;if(M.bottom<J)return"above";if(M.top>Z)return"below";return"visible"}function FQ($,M){let J=Math.max(0,$.totalHeight-$.viewport.height),Z=M.top-Math.min(GQ,$.viewport.height/4);return Math.max(0,Math.min(J,Z))}function _5($){let M=$5($.document),J=new Map(M.map((X)=>[X.id,X])),Z=new Map($.regions.map((X)=>[X.semanticRegionId,X]));return{findBySemanticMatch(X,Y){let Q=J.get(X)??M[Y]??null;if(!Q)return null;return{runtimeContainer:Z.get(Q.id)??null,semanticContainer:Q}},list(X){return X?M.filter((Y)=>Y.containerKind===X):M},resolveRuntimeContainer(X){return Z.get(X)??null}}}var k2="",b$=1e6;function u2($,M,J){return`${$}:${M}:${J}`}function J2($){let M=uQ($),J=_6(M.blocks.map((Z,X)=>h2(Z,X)));return F6(M,J)}function h2($,M){let J=[],Z=[],X=[],Y=new Set,Q=0;function K(D,A,V,U,G=null){if(Z.length>0)X.push(`
|
|
20
|
-
`),
|
|
21
|
-
${M.text}`:M.text}function RQ($){return $.filter((M)=>M.regions.length>0).map((M)=>M.text).join(`
|
|
22
|
-
`)}function fQ($,M){let J=new Set;for(let Z of $)for(let X of Z.imageUrls)J.add(X);return M&&SQ(M,J)?M:J}function mQ($,M){if(M.size===0)return $;let J=null;for(let Z of M){if($.has(Z))continue;J??=new Set($),J.add(Z)}return J??$}function SQ($,M){if($.size!==M.size)return!1;for(let J of $)if(!M.has(J))return!1;return!0}function T$($){let M=new Map;for(let[J,Z]of $.comments.entries()){let X=w2(Z,$).match?.containerId??null;if(!X)continue;let Y=M.get(X)??[];Y.push(J),M.set(X,Y)}return M}function kQ($){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,Y]of Z.items.entries())v2($,[Y],{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 uQ($){if($.blocks.length>0)return $;return d1([d({text:""})],$.comments,$.frontMatter)}function N6($,M=null){let J=[],Z=0,X=(Y)=>{let Q=Z,K=Q+Y.text.length;J.push({...Y,end:K,start:Q}),Z=K};for(let Y of $)switch(Y.type){case"break":X({id:Y.id,image:null,inlineCode:!1,kind:"break",link:M,marks:[],originalType:null,text:`
|
|
23
|
-
|
|
24
|
-
`.slice(M,J);case"image":return k2.slice(M,J);case"inlineCode":return $.code.slice(M,J);case"link":return z6($.children,M,J);case"text":return $.text.slice(M,J);case"unsupported":return $.source.slice(M,J)}}function W6($,M,J,Z){let X=lQ($.children,M,J,Z);if(X===null)return null;let Y=D0(O$($.children,M,J,Z,X,`${$.path}.children`));return Y.length>0?b1($,Y,M,J):null}function B6($,M,J){let Z=0,X=null,Y=(Q)=>{for(let K of Q){let q=b0(K),D=Z,A=D+q;if(Z=A,J<=D||M>=A)continue;if(K.type==="text"){let V=Math.max(M,D);if(Math.min(J,A)>V)X=X===null?new Set(K.marks):new Set(K.marks.filter((G)=>X?.has(G)));continue}if(K.type==="link"){let V=Z;Z=D,Y(K.children),Z=V}}};return Y($.children),X?[...X]:[]}function lQ($,M,J,Z){let X=0,Y=!1,Q=!0,K=(q)=>{for(let D of q){let A=b0(D),V=X,U=V+A;if(X=U,J<=V||M>=U)continue;if(D.type==="text"){let G=Math.max(M,V);if(Math.min(J,U)>G)Y=!0,Q&&=D.marks.includes(Z);continue}if(D.type==="link"){let G=X;X=V,K(D.children),X=G}}};return K($),Y?Q:null}function O$($,M,J,Z,X,Y){let Q=[],K=0;for(let[q,D]of $.entries()){let A=K,V=b0(D),U=A+V,G=`${Y}.${q}`;if(K=U,J<=A||M>=U){Q.push(D);continue}if(D.type==="text"){Q.push(...dQ(D,Math.max(0,M-A),Math.min(V,J-A),Z,X,G));continue}if(D.type==="link"){let _=D0(O$(D.children,Math.max(0,M-A),Math.min(V,J-A),Z,X,`${G}.children`));if(_.length>0)Q.push({...D,children:_});continue}Q.push(D)}return Q}function dQ($,M,J,Z,X,Y){let Q=$.text.slice(0,M),K=$.text.slice(M,J),q=$.text.slice(J),D=X?$.marks.filter((A)=>A!==Z):rQ($.marks,Z);return[y1(Q,$.marks,`${Y}.before`),y1(K,D,`${Y}.selected`),y1(q,$.marks,`${Y}.after`)].filter(Boolean)}function rQ($,M){return $.includes(M)?$:[...$,M].sort()}function P6($,M,J){let Z=xQ($.children,M,J,`${$.path}.children`);return Z.length>0?b1($,Z,M,J):null}function xQ($,M,J,Z){let X=j$($,M,J);if(X)return g2($,M,J,Z,y1(X.code,[],`${Z}.selected`));let Y=z6($,M,J);if(Y.length===0)return $;return g2($,M,J,Z,E6(Y,`${Z}.selected`))}function j$($,M,J){let Z=0;for(let X of $){let Y=b0(X),Q=Z,K=Q+Y;if(Z=K,M===Q&&J===K&&X.type==="inlineCode")return X;if(X.type==="link"){let q=j$(X.children,Math.max(0,M-Q),Math.min(Y,J-Q));if(q)return q}}return null}function y6($,M,J,Z,X){return E5($,M,J,Z,(Y,Q,K)=>L$(Y,Q,K,X))}function L$($,M,J,Z){let X=D0(cQ($.children,M,J,Z,`${$.path}.children`)??[]);return X.length>0?b1($,X,M,J):null}function cQ($,M,J,Z,X){let Y=[],Q=0,K=!1;for(let[q,D]of $.entries()){let A=`${X}.${q}`,V=b0(D),U=Q,G=U+V;if(Q=G,!K&&D.type==="link"&&M===U&&J===G){if(Z===null)Y.push(...D.children);else Y.push(I1({children:D.children,path:A,title:D.title,url:Z}));K=!0;continue}Y.push(D)}return K?Y:null}function X2($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=x1($.document.blocks,J.blockId);if(!Z)return null;return b6(Z,J.path,J.semanticRegionId)}function aQ($,M,J,Z,X){if(J>=Z)return null;let Y=X2($,M);return Y?X(Y,J,Z):null}function E5($,M,J,Z,X){let Y=aQ($,M,J,Z,X);return Y?{kind:"replace-block",block:Y.block,blockId:Y.blockId,selection:Y.selection}:null}function b6($,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 Y of X.cells)if(Y.id===J)return{block:$,blockPath:Z[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:Y,children:Y.children,kind:"tableCell",path:Z[1]};return null}function R$($,M,J){let Z=X2($,M.focus.regionId);if(!Z)return null;let X=Math.min(M.anchor.offset,M.focus.offset),Y=Math.max(M.anchor.offset,M.focus.offset);return{kind:"replace-block",...I2(Z,X,Y,J)}}function I2($,M,J,Z){let X=`${$.path}.children`,Y=Z(`${X}.selected`),Q=g2($.children,M,J,X,Y);return b1($,Q,M+1,M+1)}function b1($,M,J,Z){switch($.kind){case"inlineBlock":return{block:T0($.block,M),blockId:$.block.id,selection:C$(`${$.path}.children`,J,Z)};case"tableCell":{let X=M1({children:M,path:$.path}),Y=$.block.rows.map((Q)=>({...Q,cells:Q.cells.map((K)=>K.id===$.cell.id?X:K)}));return{block:u0($.block,Y),blockId:$.block.id,selection:C$($.path,J,Z)}}}}function C$($,M,J){return{endOffset:J,kind:"region-range-path",path:$,startOffset:M}}function G0($,M,J=0){return{childIndices:M,kind:"descendant-primary-region",offset:J,rootIndex:$}}function $0($,M=0){return{kind:"root-primary-region",offset:M,rootIndex:$}}function T1($,M,J,Z=0){return{cellIndex:J,kind:"table-cell",offset:Z,rootIndex:$,rowIndex:M}}function K1($,M){return $.regionIndex.get(M)??null}function M2($,M){return $.regionPathIndex.get(M)??null}function Y2($,M,J,Z){let X=$.tableCellRegionIndex.get(u2(M,J,Z));return X?$.regionIndex.get(X)??null:null}function sQ($){return $.anchor.regionId===$.focus.regionId&&$.anchor.offset===$.focus.offset}function Y0($,M){let J="documentIndex"in $?$.documentIndex:$,Z="documentIndex"in $?$.selection:M,X=sQ(Z),Y=f$(J,Z.anchor),Q=f$(J,Z.focus);if(Y<=Q)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?w6($,Z):null;return X?w1(X.id,W5(X.text,M.offset)):null}if(M.kind==="descendant-primary-region"){let Z=$.document.blocks[M.rootIndex],X=Z?iQ(Z,M.childIndices):null,Y=X?w6($,X):null;return Y?w1(Y.id,W5(Y.text,M.offset)):null}if(M.kind==="table-cell"){let Z=$.document.blocks[M.rootIndex];if(!Z||Z.type!=="table")return null;let X=Y2($,Z.id,M.rowIndex,M.cellIndex);return X?w1(X.id,W5(X.text,M.offset)):null}let J=M2($,M.path);if(!J)return null;if(M.kind==="region-path")return w1(J.id,W5(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 f$($,M){let J=$.regionOrderIndex.get(M.regionId);if(J===void 0)throw Error(`Unknown canvas region: ${M.regionId}`);return J*b$+M.offset}function w1($,M){let J={offset:M,regionId:$};return{anchor:J,focus:J}}function W5($,M){return M==="end"?$.length:Math.max(0,Math.min(M,$.length))}function iQ($,M){let J=$;for(let Z of M){if(!J)return null;let X=m$(J);if(!X)return null;J=X[Z]??null}return J}function w6($,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=m$(M);if(!X)return null;for(let Y of X){let Q=w6($,Y);if(Q)return Q}return null}function m$($){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((Y)=>Z>Y.start&&Z<Y.end)??M?.inlines.find((Y)=>Y.end===Z)??M?.inlines.find((Y)=>Y.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 B5($){let M=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null,J=$.selection.anchor.offset,Z=M?.inlines.find((X)=>J>X.start&&J<X.end)??M?.inlines.find((X)=>X.end===J)??M?.inlines.find((X)=>X.start===J)??null;return Z?.kind==="image"?Z:null}function P5($){let M=Y0($.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=x1($.documentIndex.document.blocks,J.blockId);if(!Z)return[];let X=b6(Z,J.path,J.semanticRegionId);return X?B6(X,M.start.offset,M.end.offset):[]}var T6=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 j6($,M){let J=M??nQ();return $.animations.some((Z)=>J-Z.startedAt<d2(Z))}function k$($,M){return L6($,M,"inserted-text-highlight",(J)=>J.regionPath)}function u$($,M){return c$($,M,"active-block-flash",(J)=>J.blockPath)}function v$($,M){return L6($,M,"deleted-text-fade",(J)=>J.regionPath)}function h$($,M){return L6($,M,"punctuation-pulse",(J)=>J.regionPath)}function g$($,M){return c$($,M,"list-marker-pop",(J)=>J.blockPath)}function I$($,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,Y)=>X-Y)}function p$($,M,J){return $.find((Z)=>Z.startOffset<J&&Z.endOffset>M)??null}function l$($,M,J){if(!M)return $;return x2(J.insertHighlightText,$,M.progress)}function d$($,M){return x2($,"rgba(0, 0, 0, 0)",M.progress)}function b5($,M){return x2($,"rgba(0, 0, 0, 0)",M.progress)}function r$($,M){return x2(M.insertHighlightText,"rgba(0, 0, 0, 0)",$.progress)}function x$($){let M=Math.min(1,$.progress*2);return 0.1+0.9*oQ(M)}function r2($,M,J){let Z=Math.max(0,M.progress*2-1);return x2(J.insertHighlightText,$,Z)}function L6($,M,J,Z){let X=new Map;for(let Y of $.animations){if(Y.kind!==J)continue;let Q=d2(Y),K=M-Y.startedAt;if(K>=Q)continue;let q={...Y,progress:Math.max(0,Math.min(1,K/Q))},D=Z(Y),A=X.get(D);if(A)A.push(q);else X.set(D,[q])}return X}function c$($,M,J,Z){let X=new Map;for(let Y of $.animations){if(Y.kind!==J)continue;let Q=d2(Y),K=M-Y.startedAt;if(K>=Q)continue;X.set(Z(Y),{...Y,progress:Math.max(0,Math.min(1,K/Q))})}return X}function oQ($){return 1-(1-$)*(1-$)*(1-$)}function x2($,M,J){let Z=S$($),X=S$(M);return`rgba(${O6(y5(Z[0],X[0],J))}, ${O6(y5(Z[1],X[1],J))}, ${O6(y5(Z[2],X[2],J))}, ${y5(Z[3],X[3],J)})`}function nQ(){return typeof performance<"u"?performance.now():Date.now()}function S$($){let M=T6.get($);if(M)return M;let J=tQ($)??eQ($)??$K($)??T6.get("rgba(0, 0, 0, 0)");return T6.set($,J),J}function tQ($){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 eQ($){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 $K($){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 y5($,M,J){return $+(M-$)*J}function O6($){return Math.round($)}function C6($,M,J=O1()){if(M<=0)return $;let Z=T5($);if(!Z)return $;let X=$.selection.focus.offset,Y=Math.max(0,X-M);if(X<=Y)return $;return c2($,{endOffset:X,kind:"inserted-text-highlight",regionPath:Z.path,startOffset:Y,startedAt:J})}function a$($,M,J,Z){let X=T5($);if(!X)return M;let Y=X.text.slice(J,Z);if(Y.length===0)return M;if(!X.inlines.some((K)=>K.start<=J&&K.end>=Z&&K.kind==="text"&&K.link===null&&K.marks.length===0))return M;return c2(M,{kind:"deleted-text-fade",regionPath:X.path,startOffset:J,startedAt:O1(),text:Y})}function s$($,M=O1()){let J=T5($),Z=$.selection.focus.offset-1;if(!J||Z<0||J.text[Z]!==".")return $;return c2($,{kind:"punctuation-pulse",offset:Z,regionPath:J.path,startedAt:M})}function i$($,M,J=O1()){return c2($,{blockPath:M,kind:"list-marker-pop",startedAt:J})}function o$($,M,J=O1()){return c2($,{blockPath:M,kind:"active-block-flash",startedAt:J})}function R6($,M){return $.filter((J)=>J.startedAt+d2(J)>M)}function O1(){return typeof performance<"u"?performance.now():Date.now()}function w5($,M){let J=Math.max(-1/0,...$.animations.map((Z)=>Z.startedAt));return M.animations.some((Z)=>Z.startedAt>J)}function n$($){let M=T5($);return(M?$.documentIndex.blockIndex.get(M.blockId)??null:null)?.path??""}function T5($){return $.documentIndex.regionIndex.get($.selection.focus.regionId)??null}function c2($,M){let J=R6($.animations,M.startedAt);return{...$,animations:[...J,M]}}function a2($,M,J,Z){return MK(m6($.inlines,M,J,Z))}function m6($,M,J,Z){let Y=JK($,M,J,{didInsert:!1,generatedRunCount:0,replacementText:Z});return KK(DK(Y))}function MK($){let M=[];for(let J=0;J<$.length;J+=1){let Z=$[J];if(Z.link){let Y=[],Q=Z.link;while(J<$.length&&S6($[J].link,Q)){let K=e$($[J]);if(K)Y.push(K);J+=1}if(J-=1,Y.length>0)M.push(I1({children:D0(Y),title:Q.title,url:Q.url}));continue}let X=e$(Z);if(X)M.push(X)}return D0(M)}function JK($,M,J,Z){let X=[];for(let[Y,Q]of $.entries()){if(!Z.didInsert&&M===J&&M===Q.start)f6(X,Z,t$($[Y-1]??null,Q));if(J<=Q.start||M>=Q.end){X.push(O5(Q));continue}let K=Math.max(0,M-Q.start),q=Math.min(Q.text.length,J-Q.start),D=!Z.didInsert&&Z.replacementText.length>0?Z.replacementText:"",A=ZK(Q,K,q,D,Z);if(K!==q||D.length>0)Z.didInsert=!0;X.push(...A)}if(!Z.didInsert)f6(X,Z,t$($.at(-1)??null,null));return X}function ZK($,M,J,Z,X){switch($.kind){case"text":case"inlineCode":case"unsupported":return XK($,M,J,Z);case"break":return YK($,M,J,Z,X);case"image":return QK($,M,J,Z)}}function XK($,M,J,Z){let X=$.text.slice(0,M)+Z+$.text.slice(J);return X.length>0?[{...O5($),text:X}]:[]}function YK($,M,J,Z,X){if(M===J)return[O5($)];let Y=[];if(Z.length>0)f6(Y,X,$.link);return Y}function QK($,M,J,Z){if(M===0&&J===$.text.length)return Z.length>0?[$7(Z,$.link,0)]:[];return[O5($)]}function f6($,M,J){if(M.replacementText.length===0){M.didInsert=!0;return}$.push($7(M.replacementText,J,M.generatedRunCount)),M.generatedRunCount+=1,M.didInsert=!0}function $7($,M,J){return{id:`generated:${J}`,image:null,inlineCode:!1,kind:"text",link:M,marks:[],originalType:null,text:$}}function t$($,M){return $?.link&&M?.link&&S6($.link,M.link)?$.link:null}function O5($){return{id:$.id,image:$.image,inlineCode:$.inlineCode,kind:$.kind,link:$.link,marks:$.marks,originalType:$.originalType,text:$.text}}function KK($){let M=[],J=0;for(let Z of $){let X=J,Y=X+Z.text.length;M.push({...Z,end:Y,start:X}),J=Y}return M}function DK($){let M=[];for(let J of $){let Z=M.at(-1);if(Z&&qK(Z,J)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function qK($,M){return $.kind===M.kind&&$.inlineCode===M.inlineCode&&S6($.link,M.link)&&UK($.image,M.image)&&$.originalType===M.originalType&&$.marks.join(",")===M.marks.join(",")}function e$($){switch($.kind){case"break":return c4();case"image":return $.image?AK($.image):null;case"inlineCode":return g1({code:$.text});case"text":return $.text.length>0?E0({marks:$.marks,text:$.text}):null;case"unsupported":return a4({originalType:$.originalType??"unsupported",source:$.text})}}function AK($){return H1({alt:$.alt,title:$.title,url:$.url,width:$.width})}function S6($,M){return $?.url===M?.url&&$?.title===M?.title}function UK($,M){return $?.url===M?.url&&$?.title===M?.title&&$?.alt===M?.alt&&$?.width===M?.width}function J7($,M,J){let Z=Y0($,M);if(Z.start.regionId===Z.end.regionId)return VK($,Z,J);return FK($,Z,J)}function VK($,M,J){let Z=K1($,M.start.regionId);if(!Z)throw Error(`Unknown region: ${M.start.regionId}`);let X=z5($,Z.blockId,(D)=>GK(D,Z,M.start.offset,M.end.offset,J));if(!X)throw Error(`Failed to replace block for canvas region: ${Z.id}`);let Y=Z2($,X,Z.rootIndex,1),Q=Q7($,Y,Z,M.start.offset,M.end.offset,J),K=M2(Q,Z.path);if(!K)throw Error(`Failed to remap region after replacement: ${Z.path}`);let q=M.start.offset+J.length;return{documentIndex:Q,selection:w1(K.id,q)}}function GK($,M,J,Z,X){switch($.type){case"heading":case"paragraph":return NK($,M,J,Z,X);case"code":return o4($,M7(M,J,Z,X));case"table":return _K($,M,J,Z,X);case"unsupported":return n4($,M7(M,J,Z,X));default:throw Error(`Canvas text replacement is not supported for block type: ${$.type}`)}}function NK($,M,J,Z,X){return T0($,a2(M,J,Z,X))}function _K($,M,J,Z,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=a2(M,J,Z,X),q=$.rows.map((D,A)=>{if(A!==Y)return D;let V=D.cells.map((U,G)=>{if(G!==Q)return U;return M1({children:K})});return{...D,cells:V}});return u0($,q)}function M7($,M,J,Z){return m6($.inlines,M,J,Z).map((X)=>X.text).join("")}function s2($){return $!==null&&($.type==="heading"||$.type==="paragraph")}function FK($,M,J){let Z=K1($,M.start.regionId),X=K1($,M.end.regionId);if(!Z||!X)throw Error("Unknown cross-region selection endpoints.");let Y=$.document.blocks[Z.rootIndex],Q=$.document.blocks[X.rootIndex];if(!Y||!Q)throw Error("Unknown root blocks for cross-region selection.");let K=Z7(Y,Z,M.start.offset),q=X7(Q,X,M.end.offset),D=HK(K,q,J),A=D.blocks.length>0?D.blocks:[d({text:""})],V=Z.rootIndex,U=X.rootIndex-Z.rootIndex+1,G=W1($.document,V,U,A),_=Z2($,G,V,U),N=Q7($,_,Z,M.start.offset,Z.text.length,s2(K)?J:""),H=N.roots[V+D.caretLocalIndex]?.regions[0]??null;return{documentIndex:N,selection:w1(H?.id??Z.id,H?D.caretOffset:0)}}function HK($,M,J){if(s2($)&&s2(M))return{blocks:[zK($,M,J)],caretLocalIndex:0,caretOffset:$.plainText.length+J.length};if(s2($)){let Y=[J.length>0?EK($,J):$];if(M)Y.push(M);return{blocks:Y,caretLocalIndex:0,caretOffset:$.plainText.length+J.length}}if(s2(M)){let X=J.length>0?WK(M,J):M,Y=[];if($)Y.push($);let Q=Y.length;return Y.push(X),{blocks:Y,caretLocalIndex:Q,caretOffset:J.length}}let Z=[];if($)Z.push($);if(J.length>0){let X=Z.length;if(Z.push(d({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 zK($,M,J){let Z=J.length>0?[E0({text:J})]:[];return T0($,D0([...$.children,...Z,...M.children]))}function EK($,M){return T0($,D0([...$.children,E0({text:M})]))}function WK($,M){return T0($,D0([E0({text:M}),...$.children]))}function Z7($,M,J){if($.type==="table")return null;if($.id===M.blockId)return BK($,M,J);return Y7($,(Z)=>yK(Z,M,J))}function X7($,M,J){if($.type==="table")return null;if($.id===M.blockId)return PK($,M,J);return Y7($,(Z)=>bK(Z,M,J))}function BK($,M,J){if(J===0)return null;switch($.type){case"heading":case"paragraph":return T0($,a2(M,J,M.text.length,""));case"code":return o4($,M.text.slice(0,J));case"unsupported":return n4($,M.text.slice(0,J));default:return null}}function PK($,M,J){if(J===M.text.length)return null;switch($.type){case"heading":case"paragraph":return T0($,a2(M,0,J,""));case"code":return o4($,M.text.slice(J));case"unsupported":return n4($,M.text.slice(J));default:return null}}function Y7($,M){switch($.type){case"blockquote":{let J=M($.children);return J.length===0?null:H0({children:J})}case"list":{let J=M($.items);return J.length===0?null:e($,J)}case"listItem":{let J=M($.children);return J.length===0?null:P0($,J)}default:return null}}function yK($,M,J){let Z=$.findIndex((Q)=>j5(Q,M));if(Z===-1)return[];let X=$.slice(0,Z),Y=Z7($[Z],M,J);return Y?[...X,Y]:X}function bK($,M,J){let Z=$.findIndex((Q)=>j5(Q,M));if(Z===-1)return[];let X=$.slice(Z+1),Y=X7($[Z],M,J);return Y?[Y,...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 Q7($,M,J,Z,X,Y){if($.document.comments.length===0)return M;let Q=G6($,M,J,Z,X,Y);return Q===M.document.comments?M:H5(M,{...M.document,comments:Q})}function i2($){let M=J2($),J=A7(M);return{animations:[],documentIndex:M,future:[],history:[],selection:{anchor:J,focus:J}}}function p0($){let M=L0($.documentIndex);return d1(P2($.documentIndex.document.blocks),M.threads,$.documentIndex.document.frontMatter)}function o($,M){if(!M)return null;switch(M.kind){case"keep-state":return $;case"set-selection":return X0($,M.selection);case"replace-block":{let J=z5($.documentIndex,M.blockId,()=>M.block);return J?L5($,J2(J),M.selection??null):null}case"splice-blocks":{let J=W1($.documentIndex.document,M.rootIndex,M.count??1,M.blocks);return L5($,J2(J),M.selection??null)}case"splice-text":{let J=J7($.documentIndex,M.selection,M.text);return L5($,J.documentIndex,J.selection)}case"splice-comments":{let J=V9($.documentIndex.document,M.index,M.count,M.threads);return L5($,H5($.documentIndex,J),null)}}}function L5($,M,J){let Z=wK($,M),X=p2(Z.documentIndex,J)??$.selection,Y=U7($,Z,X);return X0(Z,X,Y)}function X0($,M,J){let Z="regionId"in M?{anchor:C5($.documentIndex,M),focus:C5($.documentIndex,M)}:{anchor:C5($.documentIndex,M.anchor),focus:C5($.documentIndex,M.focus)},X={...$,selection:Z};return J??U7($,X)?o$(X,n$(X)):X}function z0($,M,J,Z){let X={regionId:M,offset:J};return X0($,Z?{anchor:$.selection.anchor,focus:X}:X)}function wK($,M){let J=A7(M);return{animations:R6($.animations,O1()),documentIndex:M,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:{anchor:J,focus:J}}}function k6($){let M=$.history.at(-1);if(!M)return $;return q7(M,{future:[D7($),...$.future],history:$.history.slice(0,-1)})}function u6($){let M=$.future[0];if(!M)return $;return q7(M,{future:$.future.slice(1),history:[...$.history,D7($)]})}function D7($){return{document:$.documentIndex.document,selection:$.selection}}function q7($,M){return{animations:[],documentIndex:J2($.document),future:M.future,history:M.history,selection:$.selection}}function A7($){return $.regions[0]?{regionId:$.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function C5($,M){let J=K1($,M.regionId);if(!J)return M;return{regionId:J.id,offset:Math.max(0,Math.min(M.offset,J.text.length))}}function U7($,M,J){let Z=K7($.documentIndex,$.selection),X=K7(M.documentIndex,J??M.selection);return X!==null&&X!==Z}function K7($,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 t2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return{kind:"unsupported"};if(J.blockType==="code"){let K=$.blockIndex.get(J.blockId);return K?{kind:"code",region:J,rootIndex:K.rootIndex}:{kind:"unsupported"}}let Z=h6($,J.id);if(Z)return{kind:"tableCell",...Z};let X=K2($,M);if(X)return{kind:"listItem",...X};let Y=TK($,M);if(Y)return{kind:"blockquoteTextBlock",...Y};let Q=Q2($,M);if(Q)return{kind:"rootTextBlock",...Q};return{kind:"unsupported"}}function e2($,M){let J=$.blockIndex.get(M);if(!J)throw Error(`Unknown root block: ${M}`);return J.rootIndex}function v6($,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 o2($){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 Q2($,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,Y=$.document.blocks[X];if(!Y||Y.type!=="heading"&&Y.type!=="paragraph")return null;return{block:Y,region:J,rootIndex:X}}function TK($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=v6($,Z?.id??null,"blockquote");if(!Z||!X||Z.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((D)=>D.id===Z.id),q=Q.children[K];if(!q||q.type!=="heading"&&q.type!=="paragraph")return null;return{block:q,blockChildIndices:o2(Z.path),childIndex:K,region:J,quote:Q,rootIndex:Y}}function n2($,M){return x1($.document.blocks,M)}function K2($,M){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let Z=$.blockIndex.get(J.blockId),X=v6($,Z?.id??null,"listItem"),Y=v6($,Z?.id??null,"list");if(!Z||!X||!Y)return null;let Q=n2($,Y.id);if(!Q||Q.type!=="list")return null;let K=Q.items.findIndex((_)=>_.id===X.id),q=Q.items[K];if(!q)return null;let D=Y.parentBlockId?$.blockIndex.get(Y.parentBlockId)??null:null,A=D?.parentBlockId?$.blockIndex.get(D.parentBlockId)??null:null,V=D?.type==="listItem"?n2($,D.id):null,U=A?.type==="list"?n2($,A.id):null,G=U?.type==="list"&&V?U.items.findIndex((_)=>_.id===V.id):-1;return{region:J,item:q,itemChildIndices:o2(X.path),itemIndex:K,list:Q,listChildIndices:o2(Y.path),parentItem:V?.type==="listItem"?V:null,parentItemChildIndices:D?.type==="listItem"?o2(D.path):null,parentItemIndex:G>=0?G:null,parentList:U?.type==="list"?U:null,parentListChildIndices:A?.type==="list"?o2(A.path):null,rootIndex:Y.rootIndex}}function h6($,M){let J=$.regionIndex.get(M);if(!J)return null;let Z=$.tableCellIndex.get(J.id),X=$.blockIndex.get(J.blockId),Y=X?.type==="table"?$.document.blocks[X.rootIndex]:null;if(!Z||!X||!Y||Y.type!=="table")return null;return{cellIndex:Z.cellIndex,rootIndex:X.rootIndex,rowIndex:Z.rowIndex,table:Y}}function $4($,M,J){return a0({checked:M,children:[d({text:$})],spread:J})}function D2($,M){let J=$.children[0];if(!J||J.type!=="paragraph")return null;return P0($,[d({text:M}),...$.children.slice(1)])}function V7($,M){return M.reduce((J,Z)=>`${J}.children.${Z}`,`root.${$}`)}function G7($,M){if($.selection.anchor.regionId!==$.selection.focus.regionId||$.selection.anchor.offset!==$.selection.focus.offset)return null;let J=K1($.documentIndex,$.selection.focus.regionId);if(!J)return null;if(M==="forward"&&$.selection.focus.offset>=J.text.length)return null;let Z=M==="backward"?OK(J.text,$.selection.focus.offset):$.selection.focus.offset,X=M==="backward"?$.selection.focus.offset:jK(J.text,$.selection.focus.offset);if(Z===X)return null;return{action:{kind:"splice-text",selection:{anchor:{regionId:J.id,offset:Z},focus:{regionId:J.id,offset:X}},text:""},startOffset:Z,endOffset:X}}function OK($,M){let J=Array.from($.slice(0,M));if(J.length===0)return 0;return M-J.at(-1).length}function jK($,M){let J=Array.from($.slice(M))[0];return J?M+J.length:$.length}function N7($,M,J){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let X=Y0($,M),Y=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 LK($,M,Z.id,Y)??RK($,M,Z.id,Y)??CK($,M,Z.id,Y)??fK($,M,Z.id,Y)??kK($,Z.blockId,Z.rootIndex,Y)??{kind:"splice-text",selection:M,text:J}}function LK($,M,J,Z){let X=K2($,M),Y=hK(Z);if(!X||!Y||X.region.id!==J)return null;let Q=D2(X.item,Y.text);if(!Q)return null;return{kind:"replace-block",block:e(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:G0(X.rootIndex,[...X.listChildIndices,X.itemIndex,0])}}function CK($,M,J,Z){if(!I6($,M,J))return null;if(/^\s*([-+*])\s\[( |x|X)\]\s$/.exec(Z)){let Q=Z.toLowerCase().includes("[x]");return g6($,M,{checked:Q,ordered:!1,start:null})}if(/^\s*[-+*]\s$/.test(Z))return g6($,M,{checked:null,ordered:!1,start:null});let Y=/^\s*(\d+)\.\s$/.exec(Z);if(Y)return g6($,M,{checked:null,ordered:!0,start:Number(Y[1])});return null}function RK($,M,J,Z){let X=Q2($,M),Y=gK(Z);if(!X||X.region.id!==J||X.block.type!=="heading"||!Y)return null;return{kind:"splice-blocks",blocks:[$1({depth:Y.depth,text:Y.text})],rootIndex:X.rootIndex,selection:$0(X.rootIndex)}}function fK($,M,J,Z){return mK($,M,J,Z)??SK($,M,J,Z)}function mK($,M,J,Z){if(!I6($,M,J))return null;let X=/^(#{1,6})\s$/.exec(Z);if(!X)return null;return uK($,M,X[1].length)}function SK($,M,J,Z){if(!I6($,M,J)||!/^>\s$/.test(Z))return null;return vK($,M)}function kK($,M,J,Z){if(!/^(?:(?:-\s?){3}|(?:\*\s?){3}|(?:_\s?){3})$/.test(Z))return null;return{kind:"splice-blocks",blocks:[s4(),d({text:""})],rootIndex:e2($,M),selection:$0(J+1)}}function g6($,M,J){let Z=e2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"splice-blocks",blocks:[z1({items:[a0({checked:J.checked,children:[d({text:""})],spread:!1})],ordered:J.ordered,spread:!1,start:J.start})],rootIndex:Z,selection:G0(Z,[0,0])}}function uK($,M,J){let Z=e2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"splice-blocks",blocks:[$1({depth:J,text:""})],rootIndex:Z,selection:$0(Z)}}function vK($,M){let J=e2($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"splice-blocks",blocks:[H0({children:[d({text:""})]})],rootIndex:J,selection:G0(J,[0])}}function I6($,M,J){let Z=Q2($,M);return Z?.region.id===J&&Z.block.type==="paragraph"}function hK($){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 gK($){let M=/^(#{1,6})\s(.+)$/.exec($);return M?{depth:M[1].length,text:M[2]}:null}function D1($,M,J,Z=0){return G0($,[...M,J,0],Z)}function p6($,M){let J=$.region.text,Z=$.item,X=typeof Z.checked==="boolean"?!1:Z.checked;if(M===0){let D=$4("",X,Z.spread);return{kind:"replace-block",block:e($.list,[...$.list.items.slice(0,$.itemIndex),D,Z,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:R5(D,$.rootIndex,[...$.listChildIndices,$.itemIndex]),selection:D1($.rootIndex,$.listChildIndices,$.itemIndex)}}if(M===J.length){let D=$4("",X,Z.spread);return{kind:"replace-block",block:e($.list,[...$.list.items.slice(0,$.itemIndex+1),D,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:R5(D,$.rootIndex,[...$.listChildIndices,$.itemIndex+1]),selection:D1($.rootIndex,$.listChildIndices,$.itemIndex+1)}}let Y=J.slice(0,M),Q=J.slice(M),K=$4(Q,X,Z.spread),q=P0(Z,[d({text:Y})]);return{kind:"replace-block",block:e($.list,[...$.list.items.slice(0,$.itemIndex),q,K,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:R5(K,$.rootIndex,[...$.listChildIndices,$.itemIndex+1]),selection:D1($.rootIndex,$.listChildIndices,$.itemIndex+1)}}function _7($,M){if(M!==0||$.region.text.length!==0)return p6($,M);if($.parentItem&&$.parentItemIndex!==null&&$.parentItemChildIndices&&$.parentList&&$.parentListChildIndices)return IK($);let J=$.list.items.slice(0,$.itemIndex),Z=$.list.items.slice($.itemIndex+1),X=[];if(J.length>0)X.push(e($.list,J));if(X.push(d({text:""})),Z.length>0)X.push(e($.list,Z));return{kind:"splice-blocks",blocks:X,rootIndex:$.rootIndex,selection:$0($.rootIndex+(J.length>0?1:0))}}function F7($){if(typeof $.item.checked==="boolean"){let M=a0({checked:null,children:$.item.children,spread:$.item.spread});return{kind:"replace-block",block:e($.list,$.list.items.map((J,Z)=>Z===$.itemIndex?M:J)),blockId:$.list.id}}if($.itemIndex>0){let M=$.list.items[$.itemIndex-1];if(!M)return null;if($.item.plainText.length===0)return{kind:"replace-block",block:e($.list,$.list.items.filter((Z,X)=>X!==$.itemIndex)),blockId:$.list.id,selection:D1($.rootIndex,$.listChildIndices,$.itemIndex-1,"end")};let J=D2(M,`${M.plainText}${$.item.plainText}`);if(!J)return null;return{kind:"replace-block",block:e($.list,$.list.items.flatMap((Z,X)=>{if(X===$.itemIndex-1)return[J];if(X===$.itemIndex)return[];return[Z]})),blockId:$.list.id,selection:D1($.rootIndex,$.listChildIndices,$.itemIndex-1,M.plainText.length)}}return{kind:"splice-blocks",blocks:[d({text:$.item.plainText})],rootIndex:$.rootIndex,selection:$0($.rootIndex)}}function H7($){if($.itemIndex===0)return null;let M=$.list.items[$.itemIndex-1];if(!M)return null;let J=pK(M,$.item,$);return{kind:"replace-block",block:e($.list,$.list.items.flatMap((Z,X)=>{if(X===$.itemIndex-1)return[J.item];if(X===$.itemIndex)return[];return[Z]})),blockId:$.list.id,selection:G0($.rootIndex,J.regionChildIndices)}}function z7($){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let M=$.list.items.filter((X,Y)=>Y!==$.itemIndex),J=$.parentItem.children.flatMap((X)=>{if(X.type!=="list"||X.id!==$.list.id)return[X];if(M.length===0)return[];return[e($.list,M)]}),Z=P0($.parentItem,J);return{kind:"replace-block",block:e($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),Z,$.item,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,selection:D1($.rootIndex,$.parentListChildIndices,$.parentItemIndex+1)}}function l6($,M){let J=$.itemIndex+M;if(J<0||J>=$.list.items.length)return null;let Z=[...$.list.items],[X]=Z.splice($.itemIndex,1);if(!X)return null;return Z.splice(J,0,X),{kind:"replace-block",block:e($.list,Z),blockId:$.list.id,selection:D1($.rootIndex,$.listChildIndices,J)}}function IK($){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let M=$.list.items.filter((Q,K)=>K!==$.itemIndex),J=$.parentItem.children.flatMap((Q)=>{if(Q.type!=="list"||Q.id!==$.list.id)return[Q];if(M.length===0)return[];return[e($.list,M)]}),Z=P0($.parentItem,J),X=typeof $.parentItem.checked==="boolean"?!1:$.parentItem.checked,Y=$4("",X,$.parentItem.spread);return{kind:"replace-block",block:e($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),Z,Y,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,listItemInsertedPath:R5(Y,$.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1]),selection:D1($.rootIndex,$.parentListChildIndices,$.parentItemIndex+1)}}function R5($,M,J){return typeof $.checked==="boolean"?void 0:V7(M,J)}function pK($,M,J){let Z=$.children.findIndex((Y)=>Y.type==="list"&&Y.ordered===J.list.ordered&&Y.start===J.list.start);if(Z>=0){let Y=$.children[Z];if(!Y||Y.type!=="list")return{item:$,regionChildIndices:[...J.listChildIndices,J.itemIndex-1,0]};return{item:P0($,$.children.map((Q,K)=>K===Z?e(Y,[...Y.items,M]):Q)),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,Z,Y.items.length,0]}}let X=z1({items:[M],ordered:J.list.ordered,spread:J.list.spread,start:J.list.start});return{item:P0($,[...$.children,X]),regionChildIndices:[...J.listChildIndices,J.itemIndex-1,$.children.length,0,0]}}function E7($,M){let J=$.region.text.length,Z=$.region.text.slice(0,M),X=$.region.text.slice(M),Y=M===0&&J>0?$.rootIndex:$.rootIndex+1;if($.block.type==="paragraph")return{kind:"splice-blocks",blocks:M===0?[d({text:""}),$.block]:M===J?[$.block,d({text:""})]:[d({text:Z}),d({text:X})],rootIndex:$.rootIndex,selection:$0(Y)};return{kind:"splice-blocks",blocks:M===0?[d({text:""}),$.block]:M===J?[$.block,d({text:""})]:[$1({depth:$.block.depth,text:Z}),d({text:X})],rootIndex:$.rootIndex,selection:$0(Y)}}function W7($,M){let J=$.region.text,Z=J.slice(0,M),X=J.slice(M),Y=$.block.type==="heading"?sK($.block,Z,X,$.blockChildIndices,M,J.length):aK($.block,Z,X,$.blockChildIndices,M,J.length);return{kind:"splice-blocks",blocks:[H0({children:[...$.quote.children.slice(0,$.childIndex),...Y.blocks,...$.quote.children.slice($.childIndex+1)]})],rootIndex:$.rootIndex,selection:G0($.rootIndex,Y.focusChildIndices)}}function B7($,M){if(M!==0||$.region.text.length!==0||$.block.type!=="paragraph")return null;let J=$.quote.children.slice(0,$.childIndex),Z=$.quote.children.slice($.childIndex+1),X=[];if(J.length>0)X.push(H0({children:J}));if(X.push(d({text:""})),Z.length>0)X.push(H0({children:Z}));return{kind:"splice-blocks",blocks:X,rootIndex:$.rootIndex,selection:$0($.rootIndex+(J.length>0?1:0))}}function P7($,M){let J=rK($);if(J)return J;if($.rootIndex===0)return null;let Z=M.document.blocks[$.rootIndex-1],X=M.document.blocks[$.rootIndex+1];if(!Z)return null;if($.block.plainText.length===0){let Y=lK($,Z,X);if(Y)return Y;return{kind:"splice-blocks",blocks:[],rootIndex:$.rootIndex,selection:Z.type==="paragraph"||Z.type==="heading"?$0($.rootIndex-1,"end"):Z.type==="list"?G0($.rootIndex-1,[Z.items.length-1,0],"end"):Z.type==="blockquote"?G0($.rootIndex-1,[Z.children.length-1],"end"):$0($.rootIndex-1,"end")}}if(Z.type==="paragraph")return{kind:"splice-blocks",count:2,blocks:[d({text:`${Z.plainText}${$.block.plainText}`})],rootIndex:$.rootIndex-1,selection:$0($.rootIndex-1,Z.plainText.length)};if(Z.type==="heading")return{kind:"splice-blocks",count:2,blocks:[$1({depth:Z.depth,text:`${Z.plainText}${$.block.plainText}`})],rootIndex:$.rootIndex-1,selection:$0($.rootIndex-1,Z.plainText.length)};if(Z.type==="list"){let Y=Z.items.length-1,Q=Z.items[Y];if(Q){let K=D2(Q,`${Q.plainText}${$.block.plainText}`);if(K)return{kind:"splice-blocks",count:2,blocks:[e(Z,Z.items.map((q,D)=>D===Y?K:q))],rootIndex:$.rootIndex-1,selection:G0($.rootIndex-1,[Y,0],Q.plainText.length)}}}return null}function y7($){if($.region.text.length===0)return cK($);if($.childIndex>0)return xK($);return{kind:"splice-blocks",blocks:$.quote.children,rootIndex:$.rootIndex,selection:$0($.rootIndex)}}function d6($,M,J){if($.block.type!=="heading")return null;let Z=Math.max(1,Math.min(6,$.block.depth+M));if(Z===$.block.depth)return{kind:"keep-state"};return{kind:"splice-blocks",blocks:[$1({depth:Z,text:$.block.plainText})],rootIndex:$.rootIndex,selection:$0($.rootIndex,J)}}function lK($,M,J){if($.block.type!=="paragraph"||$.block.plainText.length!==0||M.type!=="list"||J?.type!=="list"||!dK(M,J))return null;let Z=M.items.length-1;return{kind:"splice-blocks",count:3,blocks:[e(M,[...M.items,...J.items])],rootIndex:$.rootIndex-1,selection:G0($.rootIndex-1,[Z,0],"end")}}function dK($,M){return $.ordered===M.ordered&&$.start===M.start}function rK($){if($.block.type!=="heading")return null;return{kind:"splice-blocks",blocks:[d({text:$.block.plainText})],rootIndex:$.rootIndex,selection:$0($.rootIndex)}}function xK($){let J=$.quote.children[$.childIndex-1].plainText,Z=$.block.plainText,X=$.quote.children.filter((Y,Q)=>Q!==$.childIndex).map((Y,Q)=>Q===$.childIndex-1?d({text:`${J}${Z}`}):Y);return{kind:"splice-blocks",blocks:[H0({children:X})],rootIndex:$.rootIndex,selection:G0($.rootIndex,[$.childIndex-1],J.length)}}function cK($){if($.quote.children.length===1)return{kind:"splice-blocks",blocks:[d({text:""})],rootIndex:$.rootIndex,selection:$0($.rootIndex)};let M=Math.max(0,$.childIndex-1),J=$.childIndex>0?"end":0;return{kind:"splice-blocks",blocks:[H0({children:$.quote.children.filter((Z,X)=>X!==$.childIndex)})],rootIndex:$.rootIndex,selection:G0($.rootIndex,[M],J)}}function aK($,M,J,Z,X,Y){return{blocks:X===0?[d({text:""}),$]:X===Y?[$,d({text:""})]:[d({text:M}),d({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function sK($,M,J,Z,X,Y){return{blocks:X===0?[d({text:""}),$]:X===Y?[$,d({text:""})]:[$1({depth:$.depth,text:M}),d({text:J})],focusChildIndices:X===0?Z:[...Z.slice(0,-1),Z.at(-1)+1]}}function b7($,M,J){let Z=Q2($,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:"splice-blocks",blocks:[E1({rows:Array.from({length:2},()=>x6(X))})],rootIndex:Z.rootIndex,selection:T1(Z.rootIndex,0,0)}}function r6($,M,J,Z){let X=Z<0?tK(J.table,J.rowIndex,J.cellIndex):eK(J.table,J.rowIndex,J.cellIndex);if(!X)return Z>0&&$D(J.table,J.rowIndex,J.cellIndex)?iK(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:nK($,M,J.table,X.rowIndex,X.cellIndex,Math.min(M.focus.offset,Y.plainText.length))}}function w7($,M){let J=X2($,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),Y=I2(J,Z,X,(Q)=>c4({path:Q}));return{kind:"replace-block",block:Y.block,blockId:Y.blockId,selection:Y.selection}}function T7($,M){let J=M==="left"?$.cellIndex:$.cellIndex+1;return q2($,E1({align:f7($.table.align,J,0,[null]),rows:$.table.rows.map((Z)=>p1({cells:oK(Z.cells,J,0,[R7()])}))}),T1($.rootIndex,$.rowIndex,J))}function O7($){let M=Math.max(0,...$.table.rows.map((J)=>J.cells.length));if(M<=1)return null;return q2($,E1({align:f7($.table.align,$.cellIndex,1,[]),rows:$.table.rows.map((J)=>p1({cells:J.cells.filter((Z,X)=>X!==$.cellIndex)}))}),T1($.rootIndex,$.rowIndex,Math.min($.cellIndex,M-2)))}function j7($,M){let J=M==="above"?$.rowIndex:$.rowIndex+1,Z=Math.max(1,...$.table.rows.map((X)=>X.cells.length));return q2($,u0($.table,[...$.table.rows.slice(0,J),x6(Z),...$.table.rows.slice(J)]),T1($.rootIndex,J,Math.min($.cellIndex,Z-1)))}function L7($){if($.table.rows.length<=1)return null;let M=$.table.rows.filter((X,Y)=>Y!==$.rowIndex),J=Math.min($.rowIndex,M.length-1),Z=M[J]?.cells.length??1;return q2($,u0($.table,M),T1($.rootIndex,J,Math.min($.cellIndex,Z-1)))}function C7($){return q2($,d({text:""}),$0($.rootIndex))}function x6($){return p1({cells:Array.from({length:$},()=>R7())})}function R7(){return M1({children:[]})}function iK($){let M=$.table.rows.length,J=Math.max(1,...$.table.rows.map((Z)=>Z.cells.length));return q2($,u0($.table,[...$.table.rows,x6(J)]),T1($.rootIndex,M,0))}function q2($,M,J){return{kind:"replace-block",block:M,blockId:$.table.id,selection:J}}function oK($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function f7($,M,J,Z){return[...$.slice(0,M),...Z,...$.slice(M+J)]}function nK($,M,J,Z,X,Y){let Q=Y2($,J.id,Z,X);if(!Q)return M;return{anchor:{regionId:Q.id,offset:Y},focus:{regionId:Q.id,offset:Y}}}function tK($,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 eK($,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 $D($,M,J){let Z=$.rows[M];return Boolean(Z&&M===$.rows.length-1&&J===Z.cells.length-1)}function M4($,M){let J=N7($.documentIndex,$.selection,M),Z=o($,J);if(!Z)return null;if(J?.kind==="splice-text"&&M.length>0)Z=C6(Z,M.length);if(M===".")Z=s$(Z);return Z}function f5($){let M=t2($.documentIndex,$.selection),J=Y0($.documentIndex,$.selection).start.offset;switch(M.kind){case"code":return o($,{kind:"splice-text",selection:$.selection,text:`
|
|
25
|
-
`});case"tableCell":return o($,w7($.documentIndex,$.selection));case"listItem":{let Z=_7(M,J);return MD({state:o($,Z)??o($,p6(M,J)),action:Z})}case"blockquoteTextBlock":return o($,B7(M,J))??o($,W7(M,J));case"rootTextBlock":return o($,E7(M,J));case"unsupported":return null}}function m5($,M){let J=o($,{kind:"splice-text",selection:$.selection,text:M});return M.length>0?C6(J,M.length):J}function S5($){return m5($,"")}function c6($){if(YM($))return S5($);let M=QM($,"backward");if(M)return M;let J=Y0($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset!==0||J.end.offset!==0)return null;let Z=t2($.documentIndex,$.selection);switch(Z.kind){case"listItem":return o($,F7(Z));case"blockquoteTextBlock":return o($,y7(Z));case"rootTextBlock":return o($,P7(Z,$.documentIndex));default:return null}}function a6($){if(YM($))return S5($);return QM($,"forward")}function m7($,M,J){return z0($,M,J,!0)}function S7($){let M=$.documentIndex.regions,J=M[0],Z=M.at(-1);if(!J||!Z)return $;return X0($,{anchor:{regionId:J.id,offset:0},focus:{regionId:Z.id,offset:Z.text.length}})}function k7($){let M=t2($.documentIndex,$.selection);switch(M.kind){case"tableCell":return o($,r6($.documentIndex,$.selection,M,1));case"rootTextBlock":return o($,d6(M,1,$.selection.focus.offset));case"listItem":return o($,H7(M));default:return null}}function u7($){let M=t2($.documentIndex,$.selection);switch(M.kind){case"tableCell":return o($,r6($.documentIndex,$.selection,M,-1));case"rootTextBlock":return o($,d6(M,-1,$.selection.focus.offset));case"listItem":return o($,z7(M));default:return null}}var v7=j1(K2,($,M)=>l6(M,-1)),h7=j1(K2,($,M)=>l6(M,1));function g7($,M){let J=n2($.documentIndex,M);if(!J||J.type!=="listItem"||typeof J.checked!=="boolean")return null;return o($,{kind:"replace-block",block:{...J,checked:!J.checked},blockId:M})}function I7($,M){return o($,b7($.documentIndex,$.selection,M))}var p7=j1(J4,($,M,J)=>T7(M,J)),l7=j1(J4,($,M)=>O7(M)),d7=j1(J4,($,M,J)=>j7(M,J)),r7=j1(J4,($,M)=>L7(M)),x7=j1(J4,($,M)=>C7(M));function k5($){return g5($,"bold")}function u5($){return g5($,"italic")}function v5($){return g5($,"strikethrough")}function h5($){return g5($,"underline")}function c7($){return ZM($,P6)}function a7($,M,J,Z,X){return XM($,M,J,Z,X)}function s7($,M,J,Z){return XM($,M,J,Z,null)}function i7($,M,J){return o($,R$($.documentIndex,$.selection,(Z)=>H1({alt:J??null,path:Z,url:M})))}function o7($,M,J,Z){let X=X2($.documentIndex,M);if(!X)return null;let{image:Y}=J,Q=I2(X,J.start,J.end,(K)=>H1({alt:Y.alt,path:K,title:Y.title,url:Y.url,width:Z}));return o($,{kind:"replace-block",block:Q.block,blockId:Q.blockId})}function n7($,M,J){let Z=V6($.documentIndex,M,J);if(!Z)return null;return KM($,$.documentIndex.document.comments.length,0,[Z])}function t7($,M,J){return Z4($,M,(Z)=>C8(Z,{body:J.trim()}))}function e7($,M,J,Z){return Z4($,M,(X)=>R8(X,J,Z))}function $M($,M,J){return Z4($,M,(Z)=>f8(Z,J))}function MM($,M){return Z4($,M,()=>null)}function JM($,M,J){return Z4($,M,(Z)=>m8(Z,J))}function s6($){return k6($)}function i6($){return u6($)}function j1($,M){return(J,...Z)=>{let X=$(J.documentIndex,J.selection);return X?o(J,M(J,X,...Z)):null}}function J4($,M){return h6($,M.focus.regionId)}function MD($){if(!$.state||!$.action||$.action.kind!=="replace-block"||!$.action.listItemInsertedPath)return $.state;return i$($.state,$.action.listItemInsertedPath)}function g5($,M){return ZM($,(J,Z,X)=>W6(J,Z,X,M))}function ZM($,M){let J=Y0($.documentIndex,$.selection);if(J.start.regionId!==J.end.regionId||J.start.offset===J.end.offset)return null;return o($,E5($.documentIndex,J.start.regionId,J.start.offset,J.end.offset,M))}function XM($,M,J,Z,X){return o($,y6($.documentIndex,M,J,Z,X))}function YM($){let M=Y0($.documentIndex,$.selection);return M.start.regionId!==M.end.regionId||M.start.offset!==M.end.offset}function QM($,M){let J=G7($,M);if(!J)return null;let Z=o($,J.action);if(!Z)return null;return a$($,Z,J.startOffset,J.endOffset)}function Z4($,M,J){let X=L0($.documentIndex).threads[M];if(!X)return null;let Y=J(X);if(Y===X)return null;return KM($,M,1,Y?[Y]:[])}function KM($,M,J,Z){return o($,{kind:"splice-comments",count:J,index:M,threads:Z})}var DM=1;function qM($,M,J){let Z=$.documentIndex.regionOrderIndex.get($.selection.focus.regionId);if(Z===void 0)return $;let X=$.documentIndex.regions[Z],Y=$.selection.focus.offset+M;if(Y>=0&&Y<=X.text.length)return z0($,X.id,Y,J);if(M<0){let K=$.documentIndex.regions[Z-1];if(!K)return $;return z0($,K.id,K.text.length,J)}let Q=$.documentIndex.regions[Z+1];if(!Q)return $;return z0($,Q.id,0,J)}function AM($,M,J,Z,X){let Y=L2(M,J.regionId,J.offset);if(!Y)return $;let Q=M.lines[Y.index+Z];if(!Q)return $;let K=y0(M,$,{x:I0($,M,J)+DM,y:Q.top+Q.height/2});if(!K)return $;return z0($,K.regionId,K.offset,X)}function UM($,M,J,Z){let X=GM($,M);if(!X)return $;return z0($,X.regionId,J==="Home"?X.start:X.end,Z)}function VM($,M,J,Z,X){let Y=GM($,M);if(!Y)return $;let K=Math.max(1,Math.floor(480/M.options.lineHeight)),q=L2(M,Y.regionId,$.selection.focus.offset),D=q?M.lines[q.index+Z*K]:null;if(!D)return $;let A=y0(M,$,{x:I0($,M,J)+DM,y:D.top+D.height/2});if(!A)return $;return z0($,A.regionId,A.offset,X)}function GM($,M){return j0(M,$.selection.focus.regionId,$.selection.focus.offset)}var JD=1;function NM($,M,J,Z,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=ZD($,K.id,Q.rowIndex+Z,Q.cellIndex)??XD($,K.id,Z);if(!q)return $;let D=M.regionBounds.get(Y.id),A=M.regionBounds.get(q.id);if(!D||!A)return $;let V=A.top+YD(J.top+J.height/2-D.top,0,Math.max(0,A.bottom-A.top-1)),U=y0(M,$,{x:I0($,M,J)+JD,y:V});if(!U)return $;return z0($,U.regionId,U.offset,X)}function ZD($,M,J,Z){return Y2($.documentIndex,M,J,Z)}function XD($,M,J){let Z=$.documentIndex.blockIndex.get(M),X=$.documentIndex.regions,Y=Z?$.documentIndex.roots[Z.rootIndex]?.regionRange:void 0;if(!Y)return null;return J<0?X[Y.start-1]??null:X[Y.end]??null}function YD($,M,J){return Math.max(M,Math.min(J,$))}function o6($,M,J=!1){return qM($,M,J)}function n6($,M,J,Z=!1){return QD($,M,J,Z)}function t6($,M,J,Z=!1){return KD($,M,J,Z)}function e6($,M,J,Z=!1){return UM($,M,J,Z)}function $3($,M,J=!1){return DD($,M,J)}function QD($,M,J,Z){let X=_M($,M);if(!X)return $;return NM($,M,X,J,Z)??AM($,M,X,J,Z)}function KD($,M,J,Z){let X=_M($,M);if(!X)return $;return VM($,M,X,J,Z)}function DD($,M,J){let Z=$.documentIndex.regions,X=M==="start"?Z[0]:Z.at(-1);if(!X)return $;return z0($,X.id,M==="start"?0:X.text.length,J)}function _M($,M){return g0(M,$.documentIndex,{regionId:$.selection.focus.regionId,offset:$.selection.focus.offset})}function HM($,M,J,Z,X,Y,Q){let K=J.image?Z.images.get(J.image.url):null,q=UD(J,Z,Q),D=VD(M,Y,Q,q);if($.fillStyle=X.imageSurfaceBackground,$.fillRect(D.left,D.top,D.width,D.height),K?.status==="loaded"&&K.source)$.drawImage(K.source,D.left,D.top,D.width,D.height);else qD($,X,{...D,status:K?.status==="error"?"error":"loading"});$.strokeStyle=X.imageSurfaceBorder,$.strokeRect(D.left,D.top,D.width,D.height)}function qD($,M,J){let Z=J.status==="loading"?"Loading image":"Image unavailable",X=GD(J),Y=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")AD($,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,Y),$.restore()}function AD($,M,J){let Z=Math.max(48,Math.round(J.width*0.22)),X=J.width+Z*2,Y=performance.now()%1800/1800,Q=J.left-Z+X*Y,K=$.createLinearGradient(Q,J.top,Q+Z,J.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(J.left,J.top,J.width,J.height)}function UD($,M,J){if(!$.image)return FM(J);let Z=M.images.get($.image.url);if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return FM(J);return Math.max(48,Math.round(J*(Z.intrinsicHeight/Z.intrinsicWidth)))}function VD($,M,J,Z){return{height:Z,left:M,top:$.top+Math.max(0,Math.floor(($.height-Z)/2)),width:J}}function GD($){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 FM($){return Math.max(48,Math.round($*0.5625))}var zM=2,EM=8,ND=3,_D=1.5,FD=2,A2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function WM($,M,J,Z,X,Y,Q=null){if(!J||M.start!==0)return;if(Q){let K=x$(Q),q=BD(J,M,Z,X,$);$.save(),$.translate(q.x,q.y),$.scale(K,K),$.translate(-q.x,-q.y)}if(J.kind==="task")HD($,M,J.checked,Y,Q);else if($.fillStyle=Q?r2(Y.listMarkerText,Q,Y):Y.listMarkerText,J.kind==="ordered")WD($,J.label,Z,X);else $.fillText(J.label,M.left-zM,X);if(Q)$.restore()}function HD($,M,J,Z,X=null){let Y=R2(M);if(zD($,Y,J,Z,X),!J)return;ED($,Y,Z,X)}function zD($,M,J,Z,X=null){let Y=J?Z.checkboxCheckedFill:Z.checkboxUncheckedFill,Q=J?Z.checkboxCheckedStroke:Z.checkboxUncheckedStroke;$.fillStyle=X?r2(Y,X,Z):Y,$.strokeStyle=X?r2(Q,X,Z):Q,$.beginPath(),$.lineWidth=_D,$.roundRect(M.left,M.top,M.size,M.size,ND),$.fill(),$.stroke()}function ED($,M,J,Z=null){$.strokeStyle=Z?r2(J.checkboxCheckmark,Z,J):J.checkboxCheckmark,$.lineWidth=FD,$.beginPath(),$.moveTo(M.left+A2.start.x,M.top+A2.start.y),$.lineTo(M.left+A2.elbow.x,M.top+A2.elbow.y),$.lineTo(M.left+A2.end.x,M.top+A2.end.y),$.stroke()}function WD($,M,J,Z){let X=$.textAlign;$.textAlign="right",$.fillText(M,J-EM,Z),$.textAlign=X}function BD($,M,J,Z,X){if($.kind==="task"){let K=R2(M);return{x:K.left+K.size/2,y:K.top+K.size/2}}let Y=X.measureText($.label),Q=Z-(Y.actualBoundingBoxAscent-Y.actualBoundingBoxDescent)/2;if($.kind==="ordered")return{x:J-EM-Y.width/2,y:Q};return{x:M.left-zM+Y.width/2,y:Q}}var PD=80;function PM({context:$,containerBounds:M,isHeaderRow:J,lineHeight:Z,theme:X}){let Y=bM(M,Z);$.fillStyle=J?X.tableHeaderBackground:X.tableBodyBackground,$.fillRect(Y.left,Y.top,Y.width,Y.height),wM($,Y,X)}function yM({activeBlockFlashes:$,activeBlockId:M,activeRegionId:J,context:Z,editorState:X,endIndex:Y,layout:Q,regionBounds:K,startIndex:q,theme:D,verticalBleed:A}){if(!M||!J)return;let V=X.documentIndex.blockIndex.get(M)??null;if(V?.type!=="table")return;if((X.documentIndex.regionIndex.get(J)??null)?.blockId!==M)return;let G=K.get(J)??null,_=Q.regionLineIndices.get(J)??null;if(!G||!_||_.length===0)return;let N=Q.lines[_[0]]??null;if(!N)return;let H=bM(G,N.height);if(H.width===0)return;let E=BM({context:Z,endIndex:Y,fillStyle:D.activeBlockBackground,layout:Q,left:H.left,lineIndices:_,startIndex:q,verticalBleed:A,width:H.width}),L=V.path?$.get(V.path)??null:null;if(L)BM({context:Z,endIndex:Y,fillStyle:b5(D.activeBlockFlash,L),layout:Q,left:H.left,lineIndices:_,startIndex:q,verticalBleed:A,width:H.width});if(!E)return;wM(Z,H,D)}function BM({context:$,endIndex:M,fillStyle:J,layout:Z,left:X,lineIndices:Y,startIndex:Q,verticalBleed:K,width:q}){$.fillStyle=J;let D=!1;for(let A of Y){if(A<Q)continue;if(A>=M)break;let V=Z.lines[A];$.fillRect(X,V.top-K,q,V.height),D=!0}return D}function bM($,M){return{height:Math.max($.bottom-$.top,M),left:$.left,top:$.top,width:Math.max($.right-$.left,PD)}}function wM($,M,J){$.strokeStyle=J.tableBorder,$.strokeRect(M.left,M.top,M.width,M.height)}var M3=2,yD=3,bD=12,wD=6,TD=3,OD=1,jD=2,LD=2,CD=8,RD=12,fD=28,mD=4,SD=5,kD=2,uD=3,vD=6,TM=3,hD=12,gD=10,ID=2,pD=2,lD=1,dD=2,J3=2,OM=1.25,rD=5,xD=1,jM=4,cD=4,aD=1.5;function sD({activeBlockId:$,activeRegionId:M,activeThreadIndex:J,containerLineBounds:Z,context:X,devicePixelRatio:Y,editorState:Q,height:K,layout:q,liveCommentRanges:D,normalizedSelection:A,now:V=Eq(),resources:U,runtimeBlockMap:G,theme:_,viewportTop:N,width:H}){X.save(),X.scale(Y,Y),X.clearRect(0,0,H,K),X.fillStyle=_.background,X.fillRect(0,0,H,K),X.textBaseline="alphabetic",X.translate(0,-N);let E=iD(Q,A),{endIndex:L,startIndex:W}=n8(q,N,K),R=u$(Q,V),f=v$(Q,V),I=k$(Q,V),B=g$(Q,V),b=h$(Q,V),z=nD(q,Q,$,W,L),T=oD(q,Q,G,W,L,H);for(let P=W;P<L;P+=1){let y=q.lines[P];Mq({containerLineBounds:Z,context:X,editorState:Q,line:y,runtimeBlockMap:G,theme:_,width:H})}yM({activeBlockFlashes:R,activeBlockId:$,activeRegionId:M,context:X,editorState:Q,endIndex:L,layout:q,regionBounds:Z,startIndex:W,theme:_,verticalBleed:M3});for(let P=W;P<L;P+=1){let y=q.lines[P];Jq({activeBlockId:$,activeBlockFlashes:R,activeDeletedTextFades:f,activeThreadIndex:J,activeInsertedTextHighlights:I,activeListMarkerPops:B,activePunctuationPulses:b,context:X,editorState:Q,line:y,liveCommentRanges:D,normalizedSelection:A,resources:U,runtimeBlockMap:G,selectionRegionOrderRange:E,theme:_,width:H})}tD(X,T,_),eD(X,z,_),X.restore()}function iD($,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 oD($,M,J,Z,X,Y){let Q=new Map;for(let K=Z;K<X;K+=1){let q=$.lines[K],D=J.get(q.blockId);if(D?.type!=="heading"||D.depth!==1&&D.depth!==2)continue;let A=Q.get(D.id),V={bottom:q.top+q.height,left:q.left+h0(M,q),right:Y-$.options.paddingX};Q.set(D.id,A?{bottom:Math.max(A.bottom,V.bottom),left:A.left,right:A.right}:V)}return Q}function nD($,M,J,Z,X){let Y=new Map;for(let Q=Z;Q<X;Q+=1){let K=$.lines[Q],q=$2(M,K.blockId,"blockquote");if(!q)continue;let D=Y.get(q.id),A={bottom:K.top+K.height,isActive:K.blockId===J,left:$.options.paddingX+(q.depth+1)*$.options.indentWidth-10,top:K.top};Y.set(q.id,D?{bottom:Math.max(D.bottom,A.bottom),isActive:D.isActive||A.isActive,left:D.left,top:Math.min(D.top,A.top)}:A)}return Y}function tD($,M,J){$.fillStyle=J.headingRule;for(let Z of M.values())$.fillRect(Z.left,Z.bottom+rD,Math.max(J3,Z.right-Z.left),xD)}function eD($,M,J){for(let Z of M.values())$.fillStyle=Z.isActive?J.blockquoteRuleActive:J.blockquoteRule,$.fillRect(Z.left,Z.top+yD,TD,Math.max(bD,Z.bottom-Z.top-wD))}function $q({context:$,devicePixelRatio:M,editorState:J,height:Z,layout:X,normalizedSelection:Y,presence:Q,showCaret:K,theme:q,viewportTop:D,width:A}){$.save(),$.scale(M,M),$.clearRect(0,0,A,Z);let V=Y.start.regionId===Y.end.regionId&&Y.start.offset!==Y.end.offset,U=K&&!V;if($.translate(0,-D),U)LM($,J,X,{color:q.caret,offset:J.selection.focus.offset,regionId:J.selection.focus.regionId});if(Q)for(let G of Q){if(!G.cursorPoint)continue;LM($,J,X,{color:G.color??q.leafAccent,offset:G.cursorPoint.offset,regionId:G.cursorPoint.regionId})}$.restore()}function LM($,M,J,Z){let X=g0(J,M.documentIndex,{regionId:Z.regionId,offset:Z.offset});if(!X)return;let Y=I0(M,J,X),Q=Aq(J,X);$.fillStyle=Z.color,$.fillRect(Y,Q.top,jD,Q.height)}function Mq({containerLineBounds:$,context:M,editorState:J,line:Z,runtimeBlockMap:X,theme:Y,width:Q}){let K=X.get(Z.blockId)??null,q=$.get(Z.regionId)??null,D=J.documentIndex.tableCellIndex.get(Z.regionId)??null;Zq(M,Z,K,q,D,Y,Q)}function Jq({activeBlockId:$,activeBlockFlashes:M,activeDeletedTextFades:J,activeThreadIndex:Z,activeInsertedTextHighlights:X,activeListMarkerPops:Y,activePunctuationPulses:Q,context:K,editorState:q,line:D,liveCommentRanges:A,normalizedSelection:V,resources:U,runtimeBlockMap:G,selectionRegionOrderRange:_,theme:N,width:H}){let E=G.get(D.blockId)??null,L=q.documentIndex.blockIndex.get(D.blockId)?.path??null,W=q.documentIndex.regionIndex.get(D.regionId)??null,R=W?.path??"",f=$2(q,D.blockId,"listItem"),I=f?f2(q,f.id):null,B=f?Y.get(f.path)??null:null,b=D.left+h0(q,D),z=Gq(D),T=E?.type==="code"?N.codeText:Fq(E,N);K.font=D.font,Xq(K,D,E,L,$,M,N,H),Yq(K,q,D,V,_,N),Qq(K,q,D,A,Z,N),WM(K,D,I,b,z,N,B),Kq(K,D,W,b,z,X.get(R)??[],T,U,N),Dq(K,D,W,b,z,J.get(R)??[],T),qq(K,D,W,b,z,Q.get(R)??[],N)}function Zq($,M,J,Z,X,Y,Q){if(!Z||M.start!==0)return;if(J?.type==="code"){let K=Math.max(0,M.left-RD);$.fillStyle=Y.codeBackground,$.fillRect(K,Z.top-mD,Math.max(Z.right-M.left+fD,Q-K),Z.bottom-Z.top+CD);return}if(J?.type!=="table")return;PM({context:$,containerBounds:Z,isHeaderRow:X?.rowIndex===0,lineHeight:M.height,theme:Y})}function Xq($,M,J,Z,X,Y,Q,K){if(M.blockId!==X||J?.type==="table")return;let q=Z?Y.get(Z)??null:null;if($.fillStyle=Q.activeBlockBackground,$.fillRect(0,M.top-M3,K,M.height),!q)return;$.fillStyle=b5(Q.activeBlockFlash,q),$.fillRect(0,M.top-M3,K,M.height)}function Yq($,M,J,Z,X,Y){if(!X)return;let Q=M.documentIndex.regionOrderIndex.get(J.regionId);if(Q===void 0||Q<X.start||Q>X.end)return;let K=Q===X.start?Math.max(J.start,Z.start.offset):J.start,q=Q===X.end?Math.min(J.end,Z.end.offset):J.end;if(q<=K)return;$.fillStyle=Y.selectionBackground,$.fillRect(Q1(M,J,K-J.start),J.top+lD,Math.max(pD,Q1(M,J,q-J.start)-Q1(M,J,K-J.start)),J.height-dD)}function Qq($,M,J,Z,X,Y){for(let Q of Z){if(Q.regionId!==J.regionId)continue;let K=Math.max(Q.startOffset,J.start),q=Math.min(Q.endOffset,J.end);if(q<=K)continue;$.fillStyle=zq(Q,X,Y),$.fillRect(Q1(M,J,K-J.start),J.top+J.height-SD,Math.max(kD,Q1(M,J,q-J.start)-Q1(M,J,K-J.start)),uD)}}function Kq($,M,J,Z,X,Y,Q,K,q){if(!J){$.fillStyle=Q,$.fillText(M.text,Z,X);return}let D=J.inlines.filter((A)=>A.end>M.start&&A.start<M.end);if(D.length===0){$.fillStyle=Q,$.fillText(M.text,Z,X);return}for(let A of D){let V=Math.max(M.start,A.start),U=Math.min(M.end,A.end);if(J.text.slice(V,U).length===0)continue;let{left:_,right:N}=X3(M,Z,V,U),H=Hq(M.font,A.marks);if($.font=H,A.kind==="image"){let E=Math.max(24,N-_);HM($,M,A,K,q,_,E);continue}if(A.kind==="inlineCode"){let E=Nq(M,H),L=_q(M,H);$.fillStyle=q.inlineCodeBackground,$.fillRect(_-TM,E,Math.max(gD,N-_+TM*2),L),CM($,M,J.text,Z,X,V,U,q.inlineCodeText,Y,q,{strikethrough:!1,underline:!1});continue}CM($,M,J.text,Z,X,V,U,A.link?q.linkText:Q,Y,q,{strikethrough:A.marks.includes("strikethrough"),underline:A.marks.includes("underline")||Boolean(A.link)})}}function CM($,M,J,Z,X,Y,Q,K,q,D,A){let V=I$(Y,Q,q);for(let U=0;U<V.length-1;U+=1){let G=V[U],_=V[U+1];if(_<=G)continue;let N=J.slice(G,_);if(N.length===0)continue;let{left:H,right:E}=X3(M,Z,G,_),L=p$(q,G,_),W=l$(K,L,D);if($.fillStyle=W,$.fillText(N,H,X),A.strikethrough)$.fillRect(H,Vq(X,M.height,$.font),Math.max(J3,E-H),OM);if(A.underline)$.fillRect(H,Uq(X,M.height,$.font),Math.max(J3,E-H),OM)}}function Dq($,M,J,Z,X,Y,Q){if(!J||Y.length===0)return;for(let K of Y){if(K.startOffset<M.start||K.startOffset>M.end)continue;let q=Z+(W0(M,K.startOffset-M.start)-M.left);$.fillStyle=d$(Q,K),$.fillText(K.text,q,X)}}function qq($,M,J,Z,X,Y,Q){if(!J||Y.length===0)return;for(let K of Y){if(K.offset<M.start||K.offset>=M.end)continue;let{left:q,right:D}=X3(M,Z,K.offset,K.offset+1),A=Math.max(jM,(D-q)/2+jM+cD*K.progress),{ascent:V,descent:U}=Y1(M.font),G=X-Math.max(1,V*0.42)+Math.max(0.5,U*0.15);$.strokeStyle=r$(K,Q),$.lineWidth=aD,$.beginPath(),$.arc((q+D)/2,G,A,0,Math.PI*2),$.stroke()}}function Aq($,M){let J=j0($,M.regionId,M.offset),Z=J?.font??'16px "Iowan Old Style", "Palatino Linotype", serif',{ascent:X,descent:Y}=Y1(Z),Q=Math.max(1,X+Y),K=Math.min(M.height-LD,Q),q=J?Math.max(J.top,J.top+Z3(J.height,Z)-OD):M.top+Math.max(0,Math.floor((M.height-K)/2));return{height:K,top:q}}function Uq($,M,J){let{descent:Z}=Y1(J),X=Math.max(1,Math.round(Math.max(2,Z)*0.35)),Y=$+Z-X,Q=$-I5(M,J);return Math.min(Q+M-4,Y)}function Vq($,M,J){let{ascent:Z}=Y1(J),X=$-I5(M,J);return Math.max(X+2,$-Math.round(Z*0.32))}function Gq($){return $.top+I5($.height,$.font)}function I5($,M){return N$($,M)}function Nq($,M){let J=Z3($.height,M);return $.top+J+ID}function _q($,M){let J=Z3($.height,M);return Math.max(hD,$.height-J-vD)}function Z3($,M){let{ascent:J}=Y1(M);return I5($,M)-J}function Fq($,M){switch($?.type){case"heading":return M.headingText;case"blockquote":return M.blockquoteText;case"table":return M.headingText;default:return M.paragraphText}}function X3($,M,J,Z){return{left:M+(W0($,J-$.start)-$.left),right:M+(W0($,Z-$.start)-$.left)}}function Hq($,M){let J=[];if(M.includes("italic"))J.push("italic");if(M.includes("bold"))J.push("700");return J.length>0?`${J.join(" ")} ${$}`:$}function zq($,M,J){if($.resolved)return $.threadIndex===M?J.commentHighlightResolvedActive:J.commentHighlightResolved;return $.threadIndex===M?J.commentHighlightActive:J.commentHighlight}function Eq(){return typeof performance<"u"?performance.now():Date.now()}function Y3($,M,J,Z){sD({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 Q3($,M,J,Z){$q({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 bq,createElement as wq}from"react";var p5=(...$)=>$.filter((M,J,Z)=>{return Boolean(M)&&M.trim()!==""&&Z.indexOf(M)===J}).join(" ").trim();var RM=($)=>$.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var fM=($)=>$.replace(/^([A-Z])|[\s-_]+(\w)/g,(M,J,Z)=>Z?Z.toUpperCase():J.toLowerCase());var K3=($)=>{let M=fM($);return M.charAt(0).toUpperCase()+M.slice(1)};import{forwardRef as yq,createElement as kM}from"react";var l5={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var mM=($)=>{for(let M in $)if(M.startsWith("aria-")||M==="role"||M==="title")return!0;return!1};import{createContext as Wq,useContext as Bq,useMemo as eH,createElement as $z}from"react";var Pq=Wq({});var SM=()=>Bq(Pq);var uM=yq(({color:$,size:M,strokeWidth:J,absoluteStrokeWidth:Z,className:X="",children:Y,iconNode:Q,...K},q)=>{let{size:D=24,strokeWidth:A=2,absoluteStrokeWidth:V=!1,color:U="currentColor",className:G=""}=SM()??{},_=Z??V?Number(J??A)*24/Number(M??D):J??A;return kM("svg",{ref:q,...l5,width:M??D??l5.width,height:M??D??l5.height,stroke:$??U,strokeWidth:_,className:p5("lucide",G,X),...!Y&&!mM(K)&&{"aria-hidden":"true"},...K},[...Q.map(([N,H])=>kM(N,H)),...Array.isArray(Y)?Y:[Y]])});var u=($,M)=>{let J=bq(({className:Z,...X},Y)=>wq(uM,{ref:Y,iconNode:M,className:p5(`lucide-${RM(K3($))}`,`lucide-${$}`,Z),...X}));return J.displayName=K3($),J};var Tq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],q1=u("columns-2",Tq);var Oq=[["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"}]],A1=u("rows-3",Oq);var jq=[["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"}]],U1=u("send-horizontal",jq);var Lq=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],X4=u("arrow-down",Lq);var Cq=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Y4=u("arrow-up",Cq);var Rq=[["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"}]],Q4=u("bold",Rq);var fq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],L1=u("check",fq);var mq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],K4=u("chevron-down",mq);var Sq=[["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"}]],D4=u("heading-1",Sq);var kq=[["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"}]],q4=u("heading-2",kq);var uq=[["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"}]],A4=u("heading-3",uq);var vq=[["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"}]],U4=u("heading-4",vq);var hq=[["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"}]],V4=u("heading-5",hq);var gq=[["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"}]],G4=u("heading-6",gq);var Iq=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],N4=u("heading",Iq);var pq=[["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"}]],_4=u("italic",pq);var lq=[["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"}]],F4=u("list-ordered",lq);var dq=[["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"}]],H4=u("list-todo",dq);var rq=[["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"}]],z4=u("list",rq);var xq=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],E4=u("message-square-plus",xq);var cq=[["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"}]],C1=u("pencil",cq);var aq=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],U2=u("plus",aq);var sq=[["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=u("strikethrough",sq);var iq=[["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"}]],V1=u("table-2",iq);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"}]],B4=u("text-quote",oq);var nq=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],w0=u("trash-2",nq);var tq=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],P4=u("underline",tq);var eq=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],y4=u("x",eq);import{jsx as V2,jsxs as ZA}from"react/jsx-runtime";function vM({insetX:$,insetY:M,onSelect:J,presence:Z}){if(!Z)return null;return V2("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${$}px`,top:`${M}px`},children:Z.map((X)=>V2($A,{onSelect:()=>J(X),presence:X},X.id))})}function $A({onSelect:$,presence:M}){let J=M.viewport,Z=MA(M),X=J?.status==="above"?Y4:X4,Y=J!==null&&J.status!=="unresolved",Q=J?.status==="above"||J?.status==="below";return ZA("button",{"aria-label":JA(M),className:"documint-presence-indicator","data-status":J?.status??"unresolved",disabled:!Y,onClick:Y?$:void 0,style:{"--documint-presence-color":M.color??"var(--documint-leaf-accent)"},type:"button",children:[V2("span",{className:"documint-presence-indicator-avatar",children:M.avatarUrl?V2("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:M.avatarUrl}):Z}),Q?V2("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:V2(X,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3})}):null]})}function MA($){return hM($).charAt(0).toLocaleUpperCase()}function JA($){let M=hM($),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 hM($){return($.fullName??$.username).trim()||"Presence"}var i=`
|
|
26
|
-
`,G1="<ins>",b4="</ins>",G2=">",w4="```",d5=":::",D3=/^:::([A-Za-z][-\w]*)(.*)$/,r5="documint-comments";var x5="`",V3="\\",A3="![",U3="[",lM="(",gM=")",dM=" ",rM=":",XA=/[A-Za-z]/,YA=/[-A-Za-z0-9_]/,QA=/^\{width=([1-9]\d*)\}/,KA=/\\([\\`*_[\]{}()#+\-.!~|])/g,xM=/\\(.)/g,DA=[{delimiter:"**",mark:"bold"},{delimiter:"~~",mark:"strikethrough"},{delimiter:"*",mark:"italic"}];function N2($,M=[]){return G3($,0,$.length,M)}function G3($,M,J,Z){let X=[],Y=M,Q=M;while(Y<J){let K=qA($,Y,J,Z);if(K){IM(X,$.slice(Q,Y),Z),X.push(...K.nodes),Y=K.end,Q=Y;continue}if($[Y]===V3){Y+=Math.min(2,J-Y);continue}Y+=1}return IM(X,$.slice(Q,J),Z),AA(X)}function qA($,M,J,Z){switch($[M]){case rM:return BA($,M,J);case"<":return EA($,M,J,Z);case x5:return _A($,M,J);case"!":return FA($,M,J);case U3:return HA($,M,J,Z);case"*":case"~":return VA($,M,J,Z);default:return null}}function IM($,M,J){if(M.length===0)return;$.push(E0({marks:J,text:oM(M)}))}function N3($,M){return a4({originalType:$,source:M})}function AA($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&GA(Z.marks,J.marks)){M[M.length-1]=E0({marks:Z.marks,text:Z.text+J.text});continue}M.push(J)}return M}function UA($,M,J){for(let Z of DA){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 VA($,M,J,Z){let X=UA($,M,J);if(!X)return null;return{end:X.end,nodes:G3($,X.contentStart,X.contentEnd,[...Z,X.mark])}}function GA($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function NA($,M,J){if($[M]!==x5)return null;let Z=1;while(M+Z<J&&$[M+Z]===x5)Z+=1;let X=x5.repeat(Z),Y=$.indexOf(X,M+Z);if(Y<0||Y>=J)return null;return{end:Y+Z,value:$.slice(M+Z,Y)}}function _A($,M,J){let Z=NA($,M,J);if(!Z)return null;return{end:Z.end,nodes:[g1({code:Z.value})]}}function FA($,M,J){if(!$.startsWith(A3,M))return null;let Z=aM($,M+1,J);if(Z<0||$[Z+1]!==lM)return null;let X=cM($,Z+1,J);if(!X)return null;let Y=zA($,X.end,J);return{end:Y?.end??X.end,nodes:[H1({alt:oM($.slice(M+A3.length,Z)),title:X.title,url:X.url,width:Y?.width??null})]}}function HA($,M,J,Z){if($[M]!==U3||$.startsWith(A3,M-1))return null;let X=aM($,M,J);if(X<0||$[X+1]!==lM)return null;let Y=cM($,X+1,J);if(!Y)return null;return{end:Y.end,nodes:[I1({children:N2($.slice(M+U3.length,X),Z),title:Y.title,url:Y.url})]}}function cM($,M,J){let Z=q3($,M+1,J),X=Z;while(X<J&&$[X]!==gM&&$[X]!==dM){if($[X]===V3){X+=2;continue}X+=1}if(X===Z)return null;let Y=PA($.slice(Z,X));Z=q3($,X,J);let Q=null;if(Z<J&&$[Z]==='"'){let K=iM($,'"',Z+1,J);if(K<0)return null;Q=$.slice(Z+1,K).replace(xM,"$1"),Z=q3($,K+1,J)}if($[Z]!==gM)return null;return{end:Z+1,title:Q,url:Y}}function zA($,M,J){let Z=QA.exec($.slice(M,J));if(!Z)return null;return{end:M+Z[0].length,width:Number(Z[1])}}function EA($,M,J,Z){if(!$.startsWith(G1,M))return WA($,M,J);let X=$.indexOf(b4,M+G1.length);if(X<0||X>=J)return{end:M+G1.length,nodes:[N3("html",G1)]};return{end:X+b4.length,nodes:G3($,M+G1.length,X,[...Z,"underline"])}}function WA($,M,J){if($[M]!=="<")return null;let Z=$.indexOf(">",M+1);if(Z<0||Z>=J)return null;return{end:Z+1,nodes:[N3("html",$.slice(M,Z+1))]}}function BA($,M,J){if($[M]!==rM||!XA.test($[M+1]??""))return null;let Z=M+2;while(Z<J&&YA.test($[Z]??""))Z+=1;let X=pM($,Z,J,"[","]"),Q=pM($,X?.end??Z,J,"{","}")?.end??X?.end??Z;return{end:Q,nodes:[N3("textDirective",$.slice(M,Q))]}}function pM($,M,J,Z,X){if($[M]!==Z)return null;let Y=sM($,X,M+1,J);if(Y<0)return null;return{end:Y+1}}function aM($,M,J){return sM($,"]",M+1,J)}function sM($,M,J,Z){return iM($,M,J,Z)}function iM($,M,J,Z){for(let X=J;X<Z;X+=1){if($[X]===V3){X+=1;continue}if($[X]===M)return X}return-1}function q3($,M,J){while(M<J&&$[M]===dM)M+=1;return M}function oM($){return $.replace(KA,"$1")}function PA($){return $.replace(xM,"$1")}var yA=/^:?-+:?$/;function eM($,M){let J=tM($),Z=$.lines[$.index+1]??"",X=_3(J,M),Y=_3(Z,M);if(!nM(X)||!F3(Y))return null;let Q=[c5(X)],K=bA(Y);$.index+=2;while($.index<$.lines.length){let q=tM($),D=_3(q,M);if(wA(q)||!nM(D))break;Q.push(c5(D)),$.index+=1}return E1({align:K,rows:Q.map((q)=>p1({cells:q.map((D)=>M1({children:N2(D)}))}))})}function nM($){let M=$.trim();return/\|/.test($)&&M.startsWith("|")&&M.endsWith("|")}function F3($){let M=c5($);return M.length>0&&M.every((J)=>yA.test(J.trim()))}function bA($){return c5($).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 c5($){return $.trim().slice(1,-1).split("|").map((J)=>J.trim())}function tM($){return $.lines[$.index]??""}function wA($){return $.trim()===""}function _3($,M){return $.slice(M)}var TA=3,OA=/^\d+\.$/,jA=/^\[( |x|X)\](?:\s|$)/,$J=/^```([^\s`]*)?(?:\s+(.*))?$/,MJ=/^::(?!:)[A-Za-z][-\w]*/,JJ=/^(#{1,6})\s+(.*)$/,LA=/\s+#+\s*$/u,CA=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,RA=/^(\*\s*){3,}$/,fA=/^(-\s*){3,}$/,mA=/^(_\s*){3,}$/;function s5($,M,J){let Z=[];while($.index<$.lines.length){let X=N0($);if($.index===$.lines.length-1&&X==="")break;if(T4(X)){$.index+=1;continue}if(_2(X)>M+TA)break;let Q=SA($,M,J);if(!Q)break;Z.push(Q)}return Z}function SA($,M,J){return kA($,M,J)??uA($,M)??vA($,M)??gA($,M)??IA($,M)??pA($,M)??eM($,M)??lA($,M,J)??dA($,M)??rA($,M)}function kA($,M,J){let Z=N0($);if(!cA(Z,M))return null;let X=[];while($.index<$.lines.length){let Y=N0($),Q=_2(Y);if(T4(Y)){X.push(""),$.index+=1;continue}if(Q<M)break;let K=C0(Y,M);if(!K.startsWith(G2))break;let q=K.slice(1);if(q.startsWith(" "))q=q.slice(1);X.push(q),$.index+=1}return H0({children:s5({index:0,lines:X},0,J)})}function uA($,M){let J=N0($),Z=C0(J,M),X=$J.exec(Z);if(!X)return null;$.index+=1;let Y=[];while($.index<$.lines.length){let Q=N0($),K=C0(Q,M);if(K.trim()===w4){$.index+=1;break}Y.push(K),$.index+=1}return N8({language:X[1]?X[1]:null,meta:X[2]?X[2]:null,source:Y.join(i)})}function vA($,M){let J=N0($),Z=C0(J,M),X=D3.exec(Z);if(!X)return null;let Y=X[1],Q=[];$.index+=1;while($.index<$.lines.length){let K=N0($),q=C0(K,M);if($.index+=1,q.trim()===d5)break;Q.push(q)}return q9({attributes:hA(X[2]??""),body:Q.join(i),name:Y})}function hA($){let M=$.trim();if(M.startsWith("{")&&M.endsWith("}"))return M.slice(1,-1);return M}function gA($,M){let J=N0($),Z=C0(J,M);if(!MJ.test(Z))return null;return $.index+=1,i4({originalType:"leafDirective",source:Z})}function IA($,M){let J=N0($),Z=JJ.exec(C0(J,M));if(!Z)return null;return $.index+=1,x4({children:N2(Z[2].replace(LA,"")),depth:Z[1].length})}function pA($,M){let J=C0(N0($),M).trim();if(!ZJ(J))return null;return $.index+=1,s4()}function lA($,M,J){let Z=a5(N0($),M);if(!Z)return null;let X=[],Y=!1;while($.index<$.lines.length){let Q=N0($),K=a5(Q,M);if(!K||K.ordered!==Z.ordered)break;$.index+=1;let q=[K.content],D=!1;while($.index<$.lines.length){let A=N0($),V=_2(A);if(T4(A)){let U=iA($.lines,$.index+1);if(U<0||_2($.lines[U]??"")<=M)break;D=!0,q.push(""),$.index+=1;continue}if(V<K.contentIndent)break;if(V===M&&a5(A,M))break;q.push(aA(A,K.contentIndent)),$.index+=1}Y||=D,X.push(a0({checked:K.checked,children:xA(q,J),spread:D}))}return z1({items:X,ordered:Z.ordered,spread:Y,start:Z.ordered&&J.preserveOrderedListStart?Z.start??1:null})}function dA($,M){let J=C0(N0($),M).trim();if(!XJ(J))return null;return $.index+=1,i4({originalType:"html",source:J})}function rA($,M){let J=[];while($.index<$.lines.length){let Z=N0($),X=_2(Z);if(T4(Z))break;if(X<M)break;let Y=C0(Z,M);if(J.length>0&&sA(Z,Y,M))break;J.push(Y),$.index+=1}return B2({children:N2(J.join(i))})}function xA($,M){let J=s5({index:0,lines:$},0,M);if(J.length>0)return J;return[B2({children:[]})]}function a5($,M){let J=CA.exec($);if(!J||J[1].length!==M)return null;let Z=J[2],X=OA.test(Z),Y=X?Number(Z.slice(0,-1)):null,Q=J[3]??"",K=null;if(jA.test(Q)){if(K=Q[1]==="x"||Q[1]==="X",Q=Q.slice(3),Q.startsWith(" "))Q=Q.slice(1)}let q=Q.length>0?J[0].length-J[1].length-J[2].length-Q.length:J[0].length-J[1].length-J[2].length;return{checked:K,content:Q,contentIndent:M+J[2].length+q,ordered:X,start:Y}}function cA($,M){return C0($,M).startsWith(G2)}function C0($,M){return $.slice(M)}function aA($,M){let J=_2($);if(J>=M)return $.slice(M);return $.trim()===""?"":$.slice(Math.min(J,M))}function ZJ($){return RA.test($)||fA.test($)||mA.test($)}function XJ($){return $.startsWith("<")&&$.endsWith(">")}function _2($){let M=0;while(M<$.length&&$[M]===" ")M+=1;return M}function sA($,M,J){return M.startsWith(G2)||$J.test(M)||D3.test(M)||MJ.test(M)||JJ.test(M)||ZJ(M.trim())||F3(M)||a5($,J)!==null||XJ(M.trim())}function N0($){return $.lines[$.index]??""}function T4($){return $.trim()===""}function iA($,M){for(let J=M;J<$.length;J+=1)if(!T4($[J]??""))return J;return-1}function QJ($){let M=$.at(-1),J=M&&YJ(M)?M:null;return{blocks:$.filter((X)=>!YJ(X)),comments:J?oA(J.body):[]}}function oA($){let M;try{M=JSON.parse($)}catch{return[]}if(!Array.isArray(M))return[];return M.flatMap((J)=>{let Z=j8(J);return Z?[Z]:[]})}function YJ($){return $.type==="directive"&&$.name===r5}var KJ="---";function H3($,M={}){let Z={index:0,lines:$.replace(/\r\n/g,i).split(i)},X=nA(Z),Y=s5(Z,0,M),{comments:Q,blocks:K}=QJ(Y);return d1(K,Q,X)}function nA($){if($.lines[0]!==KJ)return;for(let M=1;M<$.lines.length;M+=1)if($.lines[M]===KJ){let J=$.lines.slice(0,M+1).join(i);return $.index=M+1,J}return}var O4=`
|
|
27
|
-
|
|
28
|
-
`,tA="-",eA=".",$U="***",MU=" ",z3=3,JU=5,ZU=4,DJ=2,XU=2,YU=1,QU=/([\\`*_[\]])/g,KU=/([\\)&])/g,DU=/(["\\])/g;function i5($,M={}){if($.blocks.length===0&&$.comments.length===0&&$.frontMatter===void 0)return"";let J=$.blocks.map((X)=>o5(X,0,M));if($.comments.length>0)J.push(TU($.comments));if($.frontMatter!==void 0)J.unshift($.frontMatter);let Z=J.join(O4);return Z.endsWith(i)?Z:`${Z}${i}`}function o5($,M,J){let Z=N1(M);switch($.type){case"blockquote":return qU($,M,J);case"code":return AU($,M);case"directive":return OU($,M);case"heading":return AJ($,M);case"list":return UU($,M,J);case"listItem":return UJ($,M,!1,1,J);case"paragraph":return`${Z}${E3(j4($.children))}`;case"table":return GU($,M,J);case"thematicBreak":return`${Z}${$U}`;case"unsupported":return M===0?$.source:NJ($.source,M)}}function qU($,M,J){let Z=$.children.map((Y)=>o5(Y,0,J)).join(O4),X=N1(M);return Z.split(i).map((Y)=>`${X}${G2}${Y.length>0?` ${Y}`:""}`).join(i)}function AU($,M){let J=[$.language??"",$.meta??""].filter(Boolean).join(" ").trim(),Z=N1(M),X=`${Z}${w4}${J?J:""}`,Y=$.source.length>0?$.source.split(i).map((Q)=>`${Z}${Q}`).join(i):Z;return`${X}${i}${Y}${i}${Z}${w4}`}function AJ($,M){let J=E3(j4($.children)),Z=`${N1(M)}${"#".repeat($.depth)}`;return J.length>0?`${Z} ${J}`:Z}function UU($,M,J){let Z=$.start??1;return $.items.map((X)=>UJ(X,M,$.ordered,Z,J)).join($.spread?O4:i)}function UJ($,M,J,Z,X){let Y=J?`${Z}${eA}`:tA,Q=$.checked===null?"":`[${$.checked?"x":" "}] `,K=`${N1(M)}${Y} ${Q}`,q=M+Y.length+1,D=$.children;if(D.length===0)return Q.length>0?K:K.trimEnd();let[A,...V]=D,U=VU(A,K,Q.length>0,X),G=V.map((_)=>o5(_,q,X)).join($.spread?O4:i);if(!G)return U;return`${U}${$.spread?O4:i}${G}`}function VU($,M,J,Z){switch($.type){case"paragraph":{let X=E3(j4($.children));if(X.length===0)return J?M:M.trimEnd();return`${M}${X}`}case"heading":return`${M}${AJ($,0)}`;case"directive":case"unsupported":{let X=$.type==="directive"?W3($):$.source,[Y,...Q]=X.split(i);return[M+Y,...Q.map((K)=>`${N1(M.length)}${K}`)].join(i)}default:{let X=M.length;return`${M.trimEnd()}${i}${o5($,X,Z)}`}}}function GU($,M,J){let Z=$.rows.map((A)=>A.cells.map((V)=>j4(V.children))),X=Math.max(1,...Z.map((A)=>A.length)),Y=Z[0]??[],Q=Array.from({length:X},(A,V)=>Math.max(z3,HU($.align[V]),...J.padTableColumns?Z.map((U)=>U[V]?.length??0):[Y[V]?.length??0])),K=NU(Q,$.align,M),q=qJ(Y,Q,$.align,M,J),D=Z.slice(1).map((A)=>qJ(A,Q,$.align,M,J));return[q??_U(Q,M),K,...D].join(i)}function qJ($,M,J,Z,X){let Y=M.map((Q,K)=>{let q=$[K]??"";if(!X.padTableColumns)return q;return zU(q,Q,J[K])});return`${" ".repeat(Z)}| ${Y.join(" | ")} |`}function NU($,M,J){let Z=$.map((X,Y)=>FU(M[Y],X));return`${" ".repeat(J)}| ${Z.join(" | ")} |`}function _U($,M){return`${N1(M)}| ${$.map((J)=>"".padEnd(J," ")).join(" | ")} |`}function FU($,M){let J=Math.max(z3,M-($==="center"?XU:$?YU:0));switch($){case"center":return`:${"-".repeat(Math.max(1,J))}:`;case"left":return`:${"-".repeat(Math.max(DJ,J))}`;case"right":return`${"-".repeat(Math.max(DJ,J))}:`;default:return"-".repeat(J)}}function HU($){return $==="center"?JU:$?ZU:z3}function zU($,M,J){if(J==="right")return $.padStart(M," ");return $.padEnd(M," ")}function j4($){return WU($).map((M)=>EU(M)).join("")}function E3($){return $.replace(/^ +/gm,(M)=>MU.repeat(M.length))}function EU($){switch($.type){case"break":return i;case"image":return jU($);case"inlineCode":return yU($.code);case"link":return LU($);case"text":return PU(VJ($.text),$.marks);case"unsupported":return $.source}}function WU($){let M=[];for(let J of $){let Z=M.at(-1);if(Z?.type==="text"&&J.type==="text"&&BU(Z.marks,J.marks)){M[M.length-1]={...Z,text:Z.text+J.text};continue}M.push(J)}return M}function BU($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function PU($,M){return M.reduce((J,Z)=>{switch(Z){case"bold":return`**${J}**`;case"italic":return`*${J}*`;case"strikethrough":return`~~${J}~~`;case"underline":return`${G1}${J}${b4}`}},$)}function yU($){let M=0,J=0;for(let Q of $){if(Q==="`"){if(J+=1,J>M)M=J;continue}J=0}let Z=M>0?M+1:1,X="`".repeat(Z),Y=$.startsWith("`")||$.endsWith("`")?` ${$} `:$;return`${X}${Y}${X}`}function VJ($){return $.replace(QU,"\\$1")}function bU($){return $.replace(KU,"\\$1")}function wU($){return $?` "${$.replace(DU,"\\$1")}"`:""}function TU($){return W3({attributes:"",body:JSON.stringify($,null,2),name:r5})}function OU($,M){let J=W3($);return M===0?J:NJ(J,M)}function W3($){let M=$.attributes?`{${$.attributes}}`:"";return`:::${$.name}${M}${i}${$.body}${i}${d5}`}function jU($){let M=VJ($.alt??""),J=GJ($.url,$.title),Z=$.width?`{width=${$.width}}`:"";return`![${M}]${J}${Z}`}function LU($){return`[${j4($.children)}]${GJ($.url,$.title)}`}function GJ($,M){return`(${bU($)}${wU(M)})`}function N1($){return" ".repeat($)}function NJ($,M){let J=N1(M);return $.split(i).map((Z)=>`${J}${Z}`).join(i)}import{createContext as CU,useContext as RU}from"react";import{createPortal as fU}from"react-dom";import{jsx as HJ}from"react/jsx-runtime";var _J=CU(void 0);function FJ({children:$,themeStyles:M}){return HJ(_J.Provider,{value:M,children:$})}function n5({children:$}){let M=RU(_J);if(typeof document>"u")return null;return fU(HJ("div",{className:"documint-overlay",style:{display:"contents",...M},children:$}),document.body)}import{useEffect as t5,useRef as RJ,useState as R1}from"react";import{forwardRef as SU,useCallback as F2,useEffect as kU,useImperativeHandle as uU,useLayoutEffect as vU,useMemo as hU,useRef as WJ,useState as B3}from"react";var mU=["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 zJ($,M,{topGap:J=8}={}){if(!$.isConnected)return null;let Z=getComputedStyle($),X=document.createElement("div");for(let D of mU)X.style.setProperty(D,Z.getPropertyValue(D));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(Z.lineHeight)||Y.offsetHeight,q={left:Q.left+Y.offsetLeft+parseFloat(Z.borderLeftWidth)-$.scrollLeft,top:Q.top+Y.offsetTop+parseFloat(Z.borderTopWidth)+K+J-$.scrollTop};return document.body.removeChild(X),q}import{jsx as R0,jsxs as BJ,Fragment as aU}from"react/jsx-runtime";var gU=240,IU="documint-leaf-menu-item documint-completion-item",L4=SU(function({actions:M,completionSources:J,onChange:Z,placeholder:X,readOnly:Y=!1,rows:Q=3,value:K},q){let D=WJ(null);uU(q,()=>D.current,[]);let A=hU(()=>rU(J),[J]),[V,U]=B3(null),[G,_]=B3(0),[N,H]=B3(null),E=F2((B,b)=>{if(!A.length){U(null);return}let z=xU(B,b,A);if(!z){U(null);return}U(z),_(0)},[A]),L=F2((B)=>{let b=B.currentTarget.value,z=B.currentTarget.selectionEnd??b.length;Z(b),E(b,z)},[Z,E]),W=F2((B)=>{let b=B.currentTarget;E(b.value,b.selectionEnd??b.value.length)},[E]),R=F2(()=>{U(null)},[]),f=F2((B)=>{if(!D.current||!V)return;let z=`${V.trigger}${B.label} `,T=K.slice(0,V.triggerStart),P=K.slice(V.caret),y=T+z+P,F=V.triggerStart+z.length;Z(y),U(null),requestAnimationFrame(()=>{let C=D.current;if(!C)return;C.focus(),C.setSelectionRange(F,F)})},[V,Z,K]),I=F2((B)=>{if(V&&V.matches.length>0){if(B.key==="ArrowDown"){B.preventDefault(),B.stopPropagation(),_((b)=>(b+1)%V.matches.length);return}if(B.key==="ArrowUp"){B.preventDefault(),B.stopPropagation(),_((b)=>(b-1+V.matches.length)%V.matches.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),B.stopPropagation();let b=V.matches[G];if(b)f(b);return}if(B.key==="Escape"){B.preventDefault(),B.stopPropagation(),U(null);return}}if(B.key==="Escape"&&M.kind==="edit")B.preventDefault(),M.onCancel()},[M,V,G,f]);return vU(()=>{if(!V){H(null);return}let B=()=>{let b=D.current;if(!b)return;H(zJ(b,V.triggerStart))};return B(),window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)}},[V]),BJ("div",{className:"documint-leaf-input-field",children:[R0("textarea",{className:"documint-leaf-input",onBlur:R,onChange:L,onKeyDown:I,onSelect:W,placeholder:X,readOnly:Y,ref:D,rows:Q,value:K}),pU(M),V&&N&&V.matches.length>0?R0(n5,{children:R0(lU,{activeIndex:G,left:N.left,matches:V.matches,onHover:_,onSelect:f,top:N.top})}):null]})});function pU($){if($.kind==="edit")return BJ(aU,{children:[R0(P3,{className:"documint-leaf-input-cancel",icon:y4,label:"Cancel editing",onClick:$.onCancel}),R0(P3,{className:"documint-leaf-input-save",disabled:$.saveDisabled??!1,icon:L1,label:"Save",onClick:$.onSave})]});return R0(P3,{className:"documint-leaf-input-submit",disabled:$.submitDisabled??!1,icon:U1,iconSize:15,label:$.submitLabel,onClick:$.onSubmit})}function P3({className:$,disabled:M=!1,icon:J,iconSize:Z=14,label:X,onClick:Y}){return R0("button",{"aria-label":X,className:`documint-leaf-action ${$}`,disabled:M,onClick:Y,title:X,type:"button",children:R0(J,{size:Z,strokeWidth:2.2})})}function lU({activeIndex:$,left:M,matches:J,onHover:Z,onSelect:X,top:Y}){let Q=WJ(null);return kU(()=>{let K=Q.current;if(!K)return;let q=K.children[$];if(q instanceof HTMLElement)q.scrollIntoView({block:"nearest"})},[$]),R0("div",{className:"documint-leaf-menu documint-completion-popover",ref:Q,role:"listbox",style:{position:"fixed",left:M,top:Y,maxHeight:gU,overflowY:"auto"},children:J.map((K,q)=>{let D=q===$;return R0("button",{"aria-selected":D,className:`${IU}${D?" is-active":""}`,onPointerDown:dU,onPointerEnter:()=>Z(q),onClick:()=>X(K),role:"option",type:"button",children:R0("span",{children:K.label})},K.label)})})}function dU($){$.preventDefault()}function rU($){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 xU($,M,J){for(let Z=M-1;Z>=0;Z-=1){let X=$[Z];if(EJ(X))return null;let Y=J.find((K)=>K.trigger===X);if(!Y)continue;if(Z>0&&!EJ($[Z-1]))return null;let Q=$.slice(Z+1,M);return{trigger:Y.trigger,query:Q,triggerStart:Z,caret:M,matches:cU(Y.items,Q)}}return null}function EJ($){return $===void 0||$===" "||$===`
|
|
29
|
-
`||$==="\t"}function cU($,M){if(!M)return $;let J=M.toLowerCase();return $.filter((Z)=>Z.label.toLowerCase().includes(J))}import{Fragment as iU}from"react";function y3($,M){if(!M?.length||!M.some((Q)=>$.includes(Q.trigger)))return[{kind:"text",text:$}];let J=new Map;for(let Q of M){let K=[...Q.items].sort((q,D)=>D.label.length-q.label.length);J.set(Q.trigger,K)}let Z=[],X=0,Y=0;while(X<$.length){let Q=$[X],K=J.get(Q);if(K!==void 0&&(X===0||sU($[X-1]))){let D=K.find((A)=>$.startsWith(A.label,X+1));if(D){if(X>Y)Z.push({kind:"text",text:$.slice(Y,X)});Z.push({kind:"token",trigger:Q,label:D.label,id:D.id}),X+=1+D.label.length,Y=X;continue}}X+=1}if(Y<$.length)Z.push({kind:"text",text:$.slice(Y)});return Z}function b3($,M){let J=[],Z=new Set;for(let X of y3($,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 sU($){return $===void 0||$===" "||$===`
|
|
30
|
-
`||$==="\t"}import{jsx as PJ,jsxs as nU}from"react/jsx-runtime";function w3({value:$,completionSources:M,onEdit:J}){return PJ("p",{onDoubleClick:J,children:oU($,M)})}function oU($,M){let J=y3($,M);if(J.length===1&&J[0].kind==="text")return $;return J.map((Z,X)=>Z.kind==="token"?nU("span",{className:"documint-mention",children:[Z.trigger,Z.label]},X):PJ(iU,{children:Z.text},X))}import{Children as yJ,isValidElement as bJ,useEffect as tU,useRef as eU,useState as $V}from"react";import{jsx as A0,jsxs as j3}from"react/jsx-runtime";var T3=($)=>{$.preventDefault()},O3=($)=>$.isPrimary&&$.button===0;function MV({children:$}){return A0("div",{className:"documint-leaf-toolbar",children:yJ.map($,JV)})}function JV($){if(!bJ($))return null;if($.type===TJ){let M=$.props;return A0(wJ,{children:A0(ZV,{...M})})}if($.type===OJ){let{className:M}=$.props;return A0("div",{className:C4("documint-leaf-toolbar-divider",M)})}if($.type===jJ){let M=$.props;return A0(XV,{...M})}return null}function ZV({active:$=!1,className:M,disabled:J=!1,icon:Z,label:X,onClick:Y}){return A0("button",{"aria-label":X,className:C4("documint-leaf-toolbar-button",$?"active":null,M),disabled:J,onPointerDown:(Q)=>{if(T3(Q),!J&&O3(Q))Y()},title:X,type:"button",children:A0(Z,{size:15,strokeWidth:2.2})})}function XV({children:$,className:M,icon:J,label:Z,onSelect:X}){let Y=eU(null),[Q,K]=$V(!1);return tU(()=>{if(!Q)return;let q=(D)=>{if(Y.current&&D.target instanceof Node&&!Y.current.contains(D.target))K(!1)};return window.addEventListener("pointerdown",q),()=>{window.removeEventListener("pointerdown",q)}},[Q]),A0(wJ,{children:j3("div",{className:"documint-leaf-toolbar-menu-shell",ref:Y,children:[A0(YV,{className:M,icon:J,isOpen:Q,label:Z,onClick:()=>K((q)=>!q)}),Q?A0("div",{className:"documint-leaf-menu",role:"menu",children:yJ.map($,(q)=>QV(q,(D)=>{K(!1),X(D)}))}):null]})})}function YV({className:$,icon:M,isOpen:J,label:Z,onClick:X}){return j3("button",{"aria-expanded":J,"aria-haspopup":"menu","aria-label":Z,className:C4("documint-leaf-toolbar-button",J?"active":null,$),onPointerDown:(Y)=>{if(T3(Y),O3(Y))X()},title:Z,type:"button",children:[A0(M,{size:15,strokeWidth:2.2}),A0(K4,{className:C4("documint-leaf-toolbar-menu-chevron",J?"is-open":null),size:13,strokeWidth:2.2})]})}function QV($,M){if(!bJ($))return null;if($.type===CJ){let{className:Q}=$.props;return A0("div",{className:C4("documint-leaf-menu-divider",Q),role:"separator"})}if($.type!==LJ)return null;let{disabled:J=!1,icon:Z,text:X,value:Y}=$.props;return j3("button",{className:"documint-leaf-menu-item",disabled:J,onPointerDown:(Q)=>{if(T3(Q),!J&&O3(Q))M(Y)},role:"menuitem",type:"button",children:[A0(Z,{size:15,strokeWidth:2.2}),A0("span",{children:X})]})}function C4(...$){return $.filter(Boolean).join(" ")}function wJ({children:$}){return A0("div",{className:"documint-leaf-toolbar-group",children:$})}function TJ($){return null}function OJ($){return null}function jJ($){return null}function LJ($){return null}function CJ($){return null}var r=Object.assign(MV,{Button:TJ,Divider:OJ,Menu:jJ,MenuDivider:CJ,MenuItem:LJ});import{jsx as n,jsxs as l0,Fragment as AV}from"react/jsx-runtime";var KV=!1,DV=220,f1=()=>{};function L3($){let M=$.mode==="create",J=$.mode==="create"?$:null,Z=$.mode==="thread"?$:null,X=$.canEdit,Y=$.link,Q=Z?.thread??null,K=Q?.comments??[],q=K[0]??null,D=Q?J1(Q):!1,A=Z?.animateInitialComment??!1,[V,U]=R1(null),[G,_]=R1(""),[N,H]=R1(""),[E,L]=R1(""),[W,R]=R1(!A),[f,I]=R1(KV),[B,b]=R1(!1),z=RJ(null),T=RJ(null),P=$.mentionSources,y=Q?k8(Q):null,F=y?fJ(y):"",C=X&&!D,v=C&&G.trim().length>0,h=C&&N.trim().length>0,g=X&&E.trim().length>0,O=M||B,w=!M||f,m=!M&&Boolean(Q),S=Boolean(q),c=M?f:!0,l=Z?.onDeleteComment??f1,F0=Z?.onDeleteThread??f1,x0=Z?.onToggleResolved??f1,f0=J?.activeMarks??[],m0=J?.onToggleBold??f1,c0=J?.onToggleItalic??f1,K8=J?.onToggleStrikethrough??f1,D8=J?.onToggleUnderline??f1,h4=X?M?"Add a comment":"Reply to this comment":"Comment editing is disabled",q8=M?E:N;t5(()=>{if(V!==null&&(V<0||V>=K.length))U(null),_("")},[K.length,V]),t5(()=>{if(!S||!A){R(!0);return}R(!1);let a=requestAnimationFrame(()=>{R(!0)});return()=>{cancelAnimationFrame(a)}},[A,q,S]),t5(()=>{if(!Z||!A){b(!1);return}b(!0);let a=window.setTimeout(()=>{b(!1)},DV);return()=>{window.clearTimeout(a)}},[A,Z]),t5(()=>{if(!M||!f||!X)return;let a=requestAnimationFrame(()=>{T.current?.focus()});return()=>{cancelAnimationFrame(a)}},[X,M,f]);let W2=()=>{U(null),_("")},g4=(a,I4)=>{if(!m||!C)return;U(a),_(I4)},S0=(a)=>{if(!Z)return;Z.onEditComment(a,G),W2()},B0=()=>{if(!Z)return;Z.onReply(N),H("")},k1=()=>{if(!J||!g)return;J.onCreateThread(E),L("")},A8=O?`documint-comment-leaf documint-comment-leaf-create${c?" is-expanded":""}`:"documint-comment-leaf",u1=m||S||w?n(qV,{canCreate:g,canEdit:X,canMutateThread:C,canReply:h,canSaveEditedComment:v,comments:K,composerRef:T,editDraft:G,editingCommentIndex:V,isComposerVisible:w,isInitialCommentVisible:W,isResolved:D,link:Y,mentionSources:P,mode:$.mode,onBeginEditingComment:g4,onCancelEditing:W2,onChangeCreateDraft:L,onChangeEditDraft:_,onChangeReplyDraft:H,onDeleteComment:l,onDeleteThread:F0,onSubmitCreate:k1,onSubmitEditedComment:S0,onSubmitReply:B0,onToggleResolved:x0,rootComment:q,showRootComment:S,showThreadChrome:m,threadAge:F,composerPlaceholder:h4,composerValue:q8}):null;return n("div",{className:A8,ref:z,children:l0("div",{className:O?"documint-comment-leaf-create-shell":void 0,children:[O?l0(r,{children:[n(r.Button,{className:"documint-comment-leaf-create-button",icon:E4,label:"Add comment",onClick:()=>I(!0)}),n(r.Divider,{className:"documint-comment-leaf-create-divider"}),n(r.Button,{active:f0.includes("bold"),className:"documint-comment-leaf-create-mark",icon:Q4,label:"Bold",onClick:m0}),n(r.Button,{active:f0.includes("italic"),className:"documint-comment-leaf-create-mark",icon:_4,label:"Italic",onClick:c0}),n(r.Button,{active:f0.includes("underline"),className:"documint-comment-leaf-create-mark",icon:P4,label:"Underline",onClick:D8}),n(r.Button,{active:f0.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:W4,label:"Strikethrough",onClick:K8})]}):null,n("div",{className:O?"documint-comment-leaf-create-content":void 0,children:u1})]})})}function qV({canCreate:$,canEdit:M,canMutateThread:J,canReply:Z,canSaveEditedComment:X,comments:Y,composerRef:Q,editDraft:K,editingCommentIndex:q,isComposerVisible:D,isInitialCommentVisible:A,isResolved:V,link:U,mentionSources:G,mode:_,onBeginEditingComment:N,onCancelEditing:H,onChangeCreateDraft:E,onChangeEditDraft:L,onChangeReplyDraft:W,onDeleteComment:R,onDeleteThread:f,onSubmitCreate:I,onSubmitEditedComment:B,onSubmitReply:b,onToggleResolved:z,rootComment:T,showRootComment:P,showThreadChrome:y,threadAge:F,composerPlaceholder:C,composerValue:v}){return l0(AV,{children:[y?l0("div",{className:"documint-comment-leaf-header",children:[n("span",{className:"documint-comment-leaf-age",children:F}),l0("div",{className:"documint-comment-leaf-actions",children:[n("button",{className:"documint-leaf-action","aria-label":V?"Reopen comment":"Resolve comment",disabled:!M,onClick:z,title:V?"Reopen comment":"Resolve comment",type:"button",children:n(L1,{size:14,strokeWidth:2.2})}),n("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!M,onClick:f,title:"Delete comment thread",type:"button",children:n(w0,{size:14,strokeWidth:2.2})})]})]}):null,y&&U?l0("div",{className:"documint-comment-leaf-link",children:[U.title?n("div",{className:"documint-link-leaf-title",children:U.title}):null,n("div",{className:"documint-link-leaf-url",children:U.url})]}):null,l0("div",{className:`documint-comment-thread${P?"":" is-empty"}`,children:[n("article",{className:P?`documint-comment-message documint-comment-message-root${A?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:T?n(w3,{completionSources:G,onEdit:()=>N(0,T.body),value:T.body}):null}),Y.slice(1).map((h,g)=>{let O=g+1,w=q===O;return l0("article",{className:"documint-comment-message",children:[!w?l0("div",{className:"documint-comment-message-meta",children:[n("span",{children:fJ(h.updatedAt)}),J?l0("div",{className:"documint-comment-leaf-actions",children:[n("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!J,onClick:()=>{N(O,h.body)},title:"Edit comment",type:"button",children:n(C1,{size:14,strokeWidth:2.2})}),n("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!J,onClick:()=>R(O),title:"Delete comment",type:"button",children:n(w0,{size:14,strokeWidth:2.2})})]}):null]}):null,w?n(L4,{actions:{kind:"edit",onCancel:H,onSave:()=>B(O),saveDisabled:!X},completionSources:G,onChange:L,readOnly:!M,rows:3,value:K}):n(w3,{completionSources:G,onEdit:()=>N(O,h.body),value:h.body})]},`${h.updatedAt}:${O}`)})]}),n("div",{className:`documint-comment-reply${y?"":" is-standalone"}${D?" is-visible":""}`,children:n(L4,{actions:_==="create"?{kind:"compose",onSubmit:I,submitDisabled:!$,submitLabel:"Create comment"}:{kind:"compose",onSubmit:b,submitDisabled:!Z,submitLabel:"Reply"},completionSources:G,onChange:_==="create"?E:W,placeholder:C,readOnly:!M,ref:Q,rows:3,value:v})})]})}function fJ($){let M=new Date($);if(Number.isNaN(M.getTime()))return $;let J=M.getTime()-Date.now(),Z=60000,X=60*Z,Y=24*X,Q=7*Y,K=30*Y,q=365*Y,D=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(J)<Z)return"just now";if(Math.abs(J)<X)return D.format(Math.round(J/Z),"minute");if(Math.abs(J)<Y)return D.format(Math.round(J/X),"hour");if(Math.abs(J)<Q)return D.format(Math.round(J/Y),"day");if(Math.abs(J)<q)return D.format(Math.round(J/K),"month");return D.format(Math.round(J/q),"year")}import{jsx as d0,jsxs as GV}from"react/jsx-runtime";var UV=[{icon:D4,label:"Heading 1",text:"# "},{icon:q4,label:"Heading 2",text:"## "},{icon:A4,label:"Heading 3",text:"### "},{icon:U4,label:"Heading 4",text:"#### "},{icon:V4,label:"Heading 5",text:"##### "},{icon:G4,label:"Heading 6",text:"###### "}],VV=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function mJ({onInsert:$,onInsertTable:M}){return GV(r,{children:[d0(r.Button,{icon:z4,label:"Insert bulleted list",onClick:()=>$("- ")}),d0(r.Button,{icon:F4,label:"Insert numbered list",onClick:()=>$("1. ")}),d0(r.Button,{icon:H4,label:"Insert task list",onClick:()=>$("- [ ] ")}),d0(r.Divider,{}),d0(r.Menu,{icon:N4,label:"Insert heading",onSelect:$,children:UV.map(({icon:J,label:Z,text:X})=>d0(r.MenuItem,{icon:J,text:Z,value:X},X))}),d0(r.Menu,{icon:V1,label:"Insert table",onSelect:(J)=>M(Number(J)),children:VV.map(({columns:J,text:Z})=>d0(r.MenuItem,{icon:V1,text:Z,value:String(J)},J))}),d0(r.Divider,{}),d0(r.Button,{icon:B4,label:"Insert blockquote",onClick:()=>$("> ")})]})}import{jsx as C3,jsxs as NV}from"react/jsx-runtime";function SJ({anchor:$,children:M,status:J="default"}){let Z=!$.isSelection;return C3(n5,{children:NV("div",{className:"documint-leaf-anchor","data-selection":$.isSelection?"true":"false",onPointerEnter:$.onPointerEnter,onPointerLeave:$.onPointerLeave,style:{left:`${$.left}px`,top:`${$.top}px`},children:[Z?C3("div",{className:"documint-leaf-bridge"}):null,C3("div",{className:"documint-leaf-shell","data-status":J,children:M})]})})}import{useEffect as kJ,useRef as _V,useState as uJ}from"react";import{jsx as n0,jsxs as R3}from"react/jsx-runtime";function vJ({canEdit:$,onDelete:M,onSave:J,title:Z,url:X}){let[Y,Q]=uJ(X),[K,q]=uJ(!1),D=_V(null),A=FV(),V=Y.trim(),U=$&&V.length>0,G=$&&!K,_=`${A}click to open`,N=`documint-link-leaf-row${K?" is-editing":""}`;return kJ(()=>{if(K)return;Q(X)},[K,X]),kJ(()=>{if(!K)return;D.current?.focus()},[K]),R3("div",{className:"documint-link-leaf",children:[Z?n0("div",{className:"documint-link-leaf-title",children:Z}):null,R3("div",{className:N,children:[K?n0(L4,{actions:{kind:"edit",onCancel:()=>{Q(X),q(!1)},onSave:()=>{J(V),q(!1)},saveDisabled:!U},onChange:Q,readOnly:!$,ref:D,rows:3,value:Y}):n0("div",{className:"documint-link-leaf-url",children:X}),G?R3("div",{className:"documint-link-leaf-actions",children:[n0("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!$)return;Q(X),q(!0)},title:"Edit link",type:"button",children:n0(C1,{size:14,strokeWidth:2.2})}),n0("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:M,title:"Remove link",type:"button",children:n0(w0,{size:14,strokeWidth:2.2})})]}):null]}),n0("div",{className:"documint-link-leaf-divider"}),n0("div",{className:"documint-link-leaf-hint",children:_})]})}function FV(){if(typeof navigator>"u")return"Ctrl+";let $=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test($)?"CMD+":"CTRL+"}import{jsx as t0,jsxs as S3}from"react/jsx-runtime";var HV=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],zV=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],f3={text:"Delete column",value:"delete"},m3={text:"Delete row",value:"delete"},hJ={text:"Delete table",value:"delete"};function gJ({canDeleteColumn:$,canDeleteRow:M,onDeleteColumn:J,onDeleteRow:Z,onDeleteTable:X,onInsertColumn:Y,onInsertRow:Q}){return S3(r,{children:[S3(r.Menu,{icon:q1,label:"Column actions",onSelect:(K)=>{if(K===f3.value){J();return}Y(K)},children:[HV.map(({text:K,value:q})=>t0(r.MenuItem,{icon:U2,text:K,value:q},q)),t0(r.MenuDivider,{}),t0(r.MenuItem,{disabled:!$,icon:w0,text:f3.text,value:f3.value})]}),S3(r.Menu,{icon:A1,label:"Row actions",onSelect:(K)=>{if(K===m3.value){Z();return}Q(K)},children:[zV.map(({text:K,value:q})=>t0(r.MenuItem,{icon:U2,text:K,value:q},q)),t0(r.MenuDivider,{}),t0(r.MenuItem,{disabled:!M,icon:w0,text:m3.text,value:m3.value})]}),t0(r.Divider,{}),t0(r.Menu,{icon:V1,label:"Table actions",onSelect:()=>X(),children:t0(r.MenuItem,{icon:w0,text:hJ.text,value:hJ.value})})]})}import{useEffect as IJ,useEffectEvent as pJ,useLayoutEffect as lJ,useMemo as EV,useRef as k3,useState as dJ}from"react";function e5($,M){if(!$||$.kind==="task-toggle")return null;if($.commentThreadIndex!==null){let J=M[$.commentThreadIndex]??null;if(!J)return null;return{kind:"comment",left:$.anchorLeft,link:$.kind==="link"?{title:$.title,url:$.url}:null,thread:J,threadIndex:$.commentThreadIndex,top:$.anchorBottom}}if($.kind!=="link")return null;return{endOffset:$.endOffset,kind:"link",left:$.anchorLeft,regionId:$.regionId,startOffset:$.startOffset,title:$.title,top:$.anchorBottom,url:$.url}}var WV=600,BV=530,H2=24;function xJ({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,editorState:Z,editorViewportState:X,getScrollTop:Y,layoutWidth:Q,onVisibilityChange:K,resources:q,scrollContentHeight:D,scrollTo:A,viewportHeight:V}){let U=EV(()=>Y0(Z),[Z]),[G,_]=dJ(null),[N,H]=dJ(null),E=U.start.regionId===U.end.regionId&&U.start.offset===U.end.offset,L=k3(!0),W=k3(0),R=k3(null),f=pJ(()=>{K()}),I=pJ(()=>{W.current=typeof performance<"u"?performance.now():Date.now(),L.current=!0,f()});return lJ(()=>{let B=PV({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:U,state:Z,viewport:X.get()});_((b)=>TV(b,B)?b:B)},[$,M,J,Z,X]),lJ(()=>{let B=q?jV(Z,X.get(),U,q):null;H((b)=>LV(b,B)?b:B)},[Z,X,U,q]),IJ(()=>{let B=Z.selection.focus,b={layoutWidth:Q,offset:B.offset,regionId:B.regionId,scrollContentHeight:D,viewportHeight:V};if(OV(R.current,b))return;let z=A6(Z,X.get(),B);if(!z)return;let T=Y(),P=T+H2,y=T+V-H2;if(z.top<P){let F=A(Math.max(0,z.top-H2));if(rJ(z,F,V,H2))R.current=b;return}if(z.top+z.height>y){let F=A(Math.max(0,z.top+z.height-V+H2));if(rJ(z,F,V,H2))R.current=b;return}R.current=b},[Z,Z.selection.focus.offset,Z.selection.focus.regionId,X,Q,D,A,V]),IJ(()=>{if(L.current=!0,f(),!E||typeof window>"u")return;let B=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-W.current<WV){if(!L.current)L.current=!0,f();return}L.current=!L.current,f()},BV);return()=>{window.clearInterval(B)}},[E]),{imageAtCursor:N,leaf:G,isVisible:()=>L.current,markActivity:I}}function PV({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:J,normalizedSelection:Z,state:X,viewport:Y}){if(!Y)return null;let Q=X.selection.focus;if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let K=$?wV(X,Y):null;if(K)return K;let q=M?yV(X,Y):null;if(q)return q;return e5(q6(X,Y,Q,J.liveRanges),J.threads)}function yV($,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 Y=$.documentIndex.blockIndex.get(Z.blockId),Q=Y?.type==="table"?$.documentIndex.document.blocks[Y.rootIndex]:null;if(!Y||!Q||Q.type!=="table")return null;let K=o0($,M,J),q=bV(M,Z.id),D=Math.max(1,...Q.rows.map((A)=>A.cells.length));return K&&q!==null?{cellIndex:X.cellIndex,columnCount:D,kind:"table",left:q,rowCount:Q.rows.length,rowIndex:X.rowIndex,top:K.top+K.height}:null}function bV($,M){let J=$.layout.lines.find((Z)=>Z.regionId===M);return J?J.left:null}function wV($,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 Y=o0($,M,J);return Y?{kind:"insertion",left:Y.left,top:Y.top+Y.height}:null}function TV($,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 OV($,M){return $?.layoutWidth===M.layoutWidth&&$.regionId===M.regionId&&$.offset===M.offset&&$.scrollContentHeight===M.scrollContentHeight&&$.viewportHeight===M.viewportHeight}function rJ($,M,J,Z){return $.top>=M+Z&&$.top+$.height<=M+J-Z}function jV($,M,J,Z){if(!M)return null;if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let X=B5($);if(!X)return null;let Y=J5($,M,Z,X),Q=X.image?Z.images.get(X.image.url)?.intrinsicWidth??null:null,K=$.selection.anchor.regionId;return Y?{bounds:Y,maxWidth:Q,regionId:K,run:X}:null}function LV($,M){if($===M)return!0;if(!$||!M)return!1;return $.regionId===M.regionId&&$.maxWidth===M.maxWidth&&$.bounds.left===M.bounds.left&&$.bounds.top===M.bounds.top&&$.bounds.width===M.bounds.width&&$.bounds.height===M.bounds.height}import{useMemo as u3,useRef as R4,useEffectEvent as v3}from"react";var CV=48;function cJ($,M,J){let Z=R4(null),X=R4(null),Y=R4(null),Q=R4(null),K=R4(1),q=v3((G,_)=>{if(!$)return;G.preventDefault(),G.stopPropagation(),G.currentTarget.setPointerCapture(G.pointerId),Q.current=G.pointerId,Z.current=G.clientX,X.current=G.clientY,Y.current=$.run.image?.width??$.bounds.width,K.current=_}),D=v3((G)=>{if(Q.current!==G.pointerId||Z.current===null||X.current===null||Y.current===null||!$?.run.image)return;let _=G.clientX-Z.current,N=G.clientY-X.current,H=Math.min($.maxWidth??1/0,Math.max(CV,Math.round(Y.current+K.current*(_+N)))),E=o7(M,$.regionId,$.run,H);if(E)J(E)}),A=v3((G)=>{if(G.currentTarget.hasPointerCapture(G.pointerId))G.currentTarget.releasePointerCapture(G.pointerId);Q.current=null,Z.current=null,X.current=null,Y.current=null}),V=u3(()=>({onPointerDown:(G)=>q(G,-1),onPointerMove:D,onPointerUp:A,onPointerCancel:A}),[]),U=u3(()=>({onPointerDown:(G)=>q(G,1),onPointerMove:D,onPointerUp:A,onPointerCancel:A}),[]);return u3(()=>{if(!$)return null;let{bounds:G}=$;return{start:{left:G.left,top:G.top,props:V},end:{left:G.left+G.width,top:G.top+G.height,props:U}}},[$])}import{useEffect as aJ,useEffectEvent as sJ,useMemo as iJ,useRef as RV,useState as fV}from"react";function oJ($,M){let[J,Z]=fV(new Map),X=sJ((q)=>{if(typeof Image>"u")return;let D=[...J.keys()].filter((A)=>!q.has(A));if(D.length>0)Z((A)=>{let V=new Map(A);for(let U of D)V.delete(U);return V});for(let A of q){let V=J.get(A)?.status;if(V==="loaded"||V==="loading")continue;Z((U)=>h3(U,A,f4("loading"))),mV(A,M).then((U)=>{Z((G)=>{if(!G.has(A))return U?.close(),G;return h3(G,A,U?f4("loaded",U):f4("error"))})})}});aJ(()=>{X($)},[$]);let Y=RV(new Map);aJ(()=>{for(let[q,D]of Y.current)if(!J.has(q))D.source?.close();Y.current=J},[J]);let Q=sJ(async(q)=>{if(!M?.writeFile)return null;try{let D=await M.writeFile(q),A=await createImageBitmap(q).catch(()=>null);return Z((V)=>h3(V,D,A?f4("loaded",A):f4("error"))),D}catch{return null}}),K=iJ(()=>J.size===0?null:{images:J},[J]);return iJ(()=>({resources:K,persistImage:Q}),[K,Q])}async function mV($,M){if(/^(https?:|data:|blob:)/i.test($))return SV($);if(!M?.readFile)return null;try{let J=await M.readFile($);return J?await createImageBitmap(J):null}catch{return null}}function SV($){return new Promise((M)=>{let J=new Image;J.decoding="async",J.crossOrigin="anonymous",J.onload=async()=>{try{M(await createImageBitmap(J))}catch{M(null)}},J.onerror=()=>M(null),J.src=$})}function h3($,M,J){let Z=new Map($);return Z.set(M,J),Z}function f4($,M){return{intrinsicHeight:M?.height??0,intrinsicWidth:M?.width??0,source:M??null,status:$}}import{useEffect as nJ,useEffectEvent as _0,useRef as m4,useState as kV}from"react";var uV=48;function tJ({applyNextState:$,autoScrollDuringDrag:M,canvasRef:J,commentState:Z,editorStateRef:X,editorViewportState:Y,focusInput:Q,onActivity:K,readCurrentState:q,resolvePoint:D}){let[A,V]=kV(null),U=m4(null),G=m4(!1),_=m4(null),N=m4(null),H=m4(null),E=e5(A,Z.threads),L=A?.kind==="task-toggle"||E?.kind==="link"?"pointer":"text";nJ(()=>{if(A&&A.kind!=="task-toggle"&&!E)V(null)},[A,E]),nJ(()=>()=>{if(U.current!==null)window.clearTimeout(U.current)},[]);let W=_0(()=>{if(U.current!==null)window.clearTimeout(U.current),U.current=null}),R=_0(()=>{W(),U.current=window.setTimeout(()=>{if(U.current=null,!G.current)V(null)},uV)}),f=_0(()=>{if(!G.current)W(),V(null)}),I=_0((O)=>{if(!O){f();return}if(O.kind==="task-toggle"){W(),V((w)=>w?.kind==="task-toggle"&&w.listItemId===O.listItemId?w:O);return}if(O.commentThreadIndex!==null){if(!(Z.threads[O.commentThreadIndex]??null)){f();return}W();let m=O.commentThreadIndex;V((S)=>S?.kind!=="task-toggle"&&S?.commentThreadIndex===m?S:O);return}if(O.kind!=="link"){f();return}W(),V((w)=>w?.kind==="link"&&w.title===O.title&&w.url===O.url&&w.startOffset===O.startOffset&&w.endOffset===O.endOffset?w:O)}),B=_0((O)=>{let w=X.current;if(!w)return null;let m=D(O);if(!m)return null;return D6(w,Y.get(),m,Z.liveRanges)}),b=_0((O)=>{let w=J.current;if(w&&_.current===O)w.releasePointerCapture(O)}),z=_0(()=>{_.current=null,N.current=null}),T=_0((O)=>{b(O.pointerId),z()}),P=_0((O)=>{if(H.current=O.pointerType,O.pointerType==="touch")return;let w=J.current,m=q(),S=D(O);if(!S)return;if(B(O)?.kind==="task-toggle")return;let l=N5(m,Y.get(),S);if(!w||!l)return;if(_.current=O.pointerId,K(),w.setPointerCapture(O.pointerId),O.shiftKey)N.current=m.selection.anchor,$(m7(m,l.regionId,l.offset));else N.current={offset:l.offset,regionId:l.regionId},$(X0(m,{offset:l.offset,regionId:l.regionId}));Q({offset:l.offset,regionId:l.regionId})}),y=_0((O)=>{let w=N.current,m=q(),S=D(O);if(!S)return;if(_.current!==O.pointerId||!w){I(B(O));return}let c=m2(m,Y.get(),S,w);if(!c)return;K(),M(O),$(X0(m,{anchor:w,focus:c}))}),F=_0(()=>{if(!G.current)R()}),C=_0((O)=>{let w=H.current==="touch";H.current=null;let m=B(O);if(m?.kind==="task-toggle"){let F0=q(),x0=g7(F0,m.listItemId);if(x0)O.preventDefault(),O.stopPropagation(),K(),$(x0);return}if(m?.kind==="link"&&(O.metaKey||O.ctrlKey)){O.preventDefault(),O.stopPropagation(),O.currentTarget.ownerDocument.defaultView?.open(m.url,"_blank","noopener,noreferrer");return}if(!w){Q();return}let S=q(),c=D(O),l=c?N5(S,Y.get(),c):null;if(l)K(),$(X0(S,{offset:l.offset,regionId:l.regionId})),Q({offset:l.offset,regionId:l.regionId});else Q()}),v=_0((O)=>{let w=q(),m=D(O),S=B(O);if(!m||S?.kind==="task-toggle")return;let c=K6(w,Y.get(),m);if(!c)return;O.preventDefault(),O.stopPropagation(),K(),$(X0(w,c)),Q()}),h=_0(()=>{G.current=!0,W()}),g=_0(()=>{G.current=!1,R()});return{canvasHandlers:{onClick:C,onDoubleClick:v,onPointerCancel:T,onPointerDown:P,onPointerLeave:F,onPointerMove:y,onPointerUp:T},cursor:L,leaf:E,leafHandlers:{onPointerEnter:h,onPointerLeave:g}}}import{useEffect as l3,useEffectEvent as U0,useLayoutEffect as hV,useRef as YZ,useState as gV}from"react";import{useEffect as jC1}from"react";var g3=[{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:"toggleCode"},{key:"i",modKey:!0,command:"toggleItalic"},{key:"u",modKey:!0,command:"toggleUnderline"},{key:"y",modKey:!0,command:"redo"},{key:"z",modKey:!0,command:"undo"},{key:"z",modKey:!0,shiftKey:!0,command:"redo"}];function eJ($,M=g3){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 ZZ($){let M=$.documentIndex.regions.find((Y)=>Y.id===$.selection.anchor.regionId),J=$.documentIndex.regions.find((Y)=>Y.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 I3($){let M=p3($);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 p3($){let M=vV($);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 $Z=28,MZ=18;function XZ($,M){if(!$)return;let J=$.getBoundingClientRect();if(M.clientY<J.top+$Z){$.scrollTop=Math.max(0,$.scrollTop-MZ);return}if(M.clientY>J.bottom-$Z)$.scrollTop+=MZ}function vV($){let M=JZ($.documentIndex.regions,$.selection.anchor.regionId,$.selection.anchor.offset),J=JZ($.documentIndex.regions,$.selection.focus.regionId,$.selection.focus.offset);return M<=J?{end:$.selection.focus,start:$.selection.anchor}:{end:$.selection.anchor,start:$.selection.focus}}function JZ($,M,J){let Z=$.findIndex((X)=>X.id===M);if(Z===-1)return-1;return Z*1e6+J}var IV=1024,QZ=16;function qZ({applyNextState:$,editorState:M,editorStateRef:J,editorViewportState:Z,inputRef:X,keybindings:Y,onActivity:Q,onImagePaste:K}){let q=pV(),D=()=>J.current??M,A=YZ(!1),V=YZ(!1),U=U0((F)=>{if(!F)return;Q(),$(F)}),G=U0(()=>{let F=X.current;if(!F)return;if(typeof document>"u")return;let C=document.execCommand;if(typeof C!=="function")return;try{A.current=!0,C.call(document,"insertText",!1,""),C.call(document,"delete")}catch{}finally{A.current=!1,S4(F,D())}}),_=U0(()=>{if(V.current)return;V.current=!0,G()}),N=U0(()=>{G()}),H=U0((F)=>{if(!q)return;let C=X.current;if(!C)return;let v=Z.get(),h=o0(D(),v,F);if(!h)return;C.style.top=`${h.top}px`,C.style.left=`${h.left}px`,C.style.height=`${h.height}px`}),E=U0((F)=>{let C=X.current;if(!C)return;H(F??D().selection.focus),C.focus({preventScroll:!q}),S4(C,D()),_()}),L=U0((F,C)=>{let h=DZ(C,$8(F)).replace(/\r\n/g,`
|
|
31
|
-
`).split(/(\n)/),g=F;for(let O of h){if(O.length===0)continue;let w=O===`
|
|
32
|
-
`?f5(g):M4(g,O);if(!w)continue;g=w}return g===F?null:g}),W=U0((F,C,v)=>{let h=F.selection.focus,g={regionId:h.regionId,offset:Math.max(0,h.offset-C)},O=X0(F,{anchor:g,focus:h});return m5(O,v)}),R=U0((F)=>{if(A.current)return;let C=D(),v=rV(F.inputType);if(F.inputType==="insertText"){if(!F.data)return;F.preventDefault();let h=KZ(F.target);if(h>0){U(W(C,h,F.data));return}let g=dV(C,F.data);if(g>0){let O=F.data.slice(g);if(O.length>0)U(L(C,O));return}U(L(C,F.data));return}if(F.inputType==="insertReplacementText"){if(!F.data)return;F.preventDefault();let h=KZ(F.target);U(W(C,h,F.data));return}if(lV(F.inputType)){F.preventDefault(),U(f5(C));return}if(v==="backward"){F.preventDefault(),U(c6(C));return}if(v==="forward"){F.preventDefault(),U(a6(C));return}if(F.inputType==="historyUndo"){F.preventDefault(),U(s6(C)),N();return}if(F.inputType==="historyRedo"){F.preventDefault(),U(i6(C)),N();return}}),f=U0((F)=>{let C=D(),v=F.currentTarget.value,h=$8(C);if(A.current)return;if(DZ(v,h).length===0){S4(F.currentTarget,C);return}U(L(C,v))}),I=U0((F)=>{let C=cV(D(),Z.get(),F.nativeEvent,Y);if(!C)return;F.preventDefault(),U(C)}),B=U0((F)=>{let C=I3(D());if(!C)return;F.preventDefault(),F.clipboardData.setData("text/plain",C)}),b=U0((F)=>{let C=D(),v=I3(C);if(!v)return;F.preventDefault(),F.clipboardData.setData("text/plain",v),U(S5(C))}),z=U0(async(F)=>{let v=(K?[...F.clipboardData.items].find((g)=>g.kind==="file"&&g.type.startsWith("image/")):void 0)?.getAsFile()??null;if(v&&K){F.preventDefault();let g=await K(v);if(g)U(i7(D(),g));return}let h=F.clipboardData.getData("text/plain");if(h.length===0)return;F.preventDefault(),U(m5(D(),h))}),T=U0(()=>{Q();let F=X.current;if(F)S4(F,D())}),P=U0((F)=>{if(Q(),F.target.matches(":focus-visible"))E()});l3(()=>{let F=X.current;if(!F)return;S4(F,M)},[M,X]),hV(()=>{H(M.selection.focus)},[M,H]),l3(()=>{let F=X.current;if(!F)return;let C=(v)=>R(v);return F.addEventListener("beforeinput",C),()=>F.removeEventListener("beforeinput",C)},[X,R]);let y={onCopy:B,onCut:b,onPaste:z,...q?{}:{onKeyDown:I}};return{canvasHandlers:{...y,onFocus:P},focus:E,inputHandlers:{...y,onFocus:T,onInput:f}}}var AZ="";function pV(){let[$,M]=gV(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return l3(()=>{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 lV($){return $==="insertLineBreak"||$==="insertParagraph"}function KZ($){let M=$,J=M?.selectionStart??0,Z=M?.selectionEnd??J;return Math.max(0,Z-J)}function dV($,M){if(M.length<QZ)return 0;let J=$8($,M.length),Z=Math.min(J.length,M.length);for(let X=Z;X>=QZ;X--)if(J.endsWith(M.slice(0,X)))return X;return 0}function rV($){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 xV($){return $.replaceAll(AZ,"")}function $8($,M=IV){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 DZ($,M){let J=xV($);return J.startsWith(M)?J.slice(M.length):J}function S4($,M){let J=$8(M),Z=`${AZ}${J}`;$.value=Z,$.setSelectionRange(Z.length,Z.length)}function cV($,M,J,Z){if(J.key==="Delete")return a6($);let X=eJ(J,Z);if(X){if(X==="moveToLineStart"||X==="moveToLineEnd")return e6($,M.layout,X==="moveToLineStart"?"Home":"End",J.shiftKey);if(X==="moveToDocumentStart"||X==="moveToDocumentEnd")return $3($,X==="moveToDocumentStart"?"start":"end",J.shiftKey);switch(X){case"insertLineBreak":return f5($);case"deleteBackward":return c6($);case"indent":return k7($);case"dedent":return u7($);case"moveListItemUp":return v7($);case"moveListItemDown":return h7($);case"toggleBold":return k5($);case"toggleItalic":return u5($);case"toggleStrikethrough":return v5($);case"toggleUnderline":return h5($);case"toggleCode":return c7($);case"undo":return s6($);case"redo":return i6($);case"selectAll":return S7($)}}if(J.key==="ArrowLeft"||J.key==="ArrowRight")return o6($,J.key==="ArrowLeft"?-1:1,J.shiftKey);if(J.key==="ArrowUp"||J.key==="ArrowDown")return n6($,M.layout,J.key==="ArrowUp"?-1:1,J.shiftKey);if(J.key==="PageUp"||J.key==="PageDown")return t6($,M.layout,J.key==="PageUp"?-1:1,J.shiftKey);if(J.key.length===1&&!J.altKey&&!J.ctrlKey&&!J.metaKey)return M4($,J.key);return null}import{useEffectEvent as d3,useLayoutEffect as aV,useMemo as sV,useState as iV}from"react";function UZ({editorState:$,editorStateRef:M,editorViewportState:J,onViewportScroll:Z,scrollContainerRef:X,scheduleOverlayRender:Y,userPresence:Q}){let K=sV(()=>{if(!Q||Q.length===0)return;return F5($.documentIndex,Q)},[$.documentIndex,Q]),[q,D]=iV(void 0),A=d3(()=>{if(K===void 0){if(q!==void 0)D(void 0)}else D(S2(M.current??$,J.get(),K));Y()}),V=d3((G)=>{if(K===void 0){if(q!==void 0)D(void 0);return}let _=S2(M.current??$,G,K);if(oV(q,_))return;D(_)});aV(()=>{A()},[K]);let U=d3((G)=>{if(!G.viewport||G.viewport.status==="unresolved")return;let _=X.current;if(!_)return;_.scrollTop=G.viewport.scrollTop,Z(_)});return{presence:q,scrollToPresence:U,refreshPresence:V}}function oV($,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&&nV(J.viewport,X.viewport)})}function nV($,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 tV,useEffectEvent as m1,useRef as k4}from"react";function VZ({editorStateRef:$,renderContent:M,renderOverlay:J,renderViewport:Z}){let X=k4(null),Y=k4(!1),Q=k4(!1),K=k4(!1),q=k4(!1),D=m1(()=>{if(typeof window>"u"){Z();return}Y.current=!0,G()}),A=m1(()=>{if(typeof window>"u"){M(),J();return}Q.current=!0,G()}),V=m1(()=>{if(typeof window>"u"){M();return}K.current=!0,G()}),U=m1(()=>{if(typeof window>"u"){J();return}q.current=!0,G()}),G=m1(()=>{if(typeof window>"u"||X.current!==null)return;X.current=window.requestAnimationFrame(()=>{_()})}),_=m1(()=>{X.current=null;let H=Y.current,E=Q.current,L=K.current,W=q.current;if(Y.current=!1,Q.current=!1,K.current=!1,q.current=!1,H){Z(),N();return}if(E){M(),J(),N();return}if(L)M(),N();if(W)J()}),N=m1(()=>{let H=$.current;if(!H||!j6(H,performance.now()))return;K.current=!0,G()});return tV(()=>{return()=>{if(typeof window>"u"||X.current===null)return;window.cancelAnimationFrame(X.current),X.current=null}},[]),{scheduleContentPaint:V,scheduleFullPaint:A,scheduleFullRender:D,scheduleOverlayPaint:U}}import{useEffectEvent as r3,useLayoutEffect as GZ,useMemo as x3,useRef as c3,useState as NZ}from"react";function _Z({applyNextState:$,autoScrollDuringDrag:M,canShowSelectionLeaf:J,editorState:Z,editorStateRef:X,editorViewportState:Y,focusInput:Q,onActivity:K,resolvePoint:q,threads:D}){let A=x3(()=>Y0(Z),[Z]),V=x3(()=>p3(Z),[Z]),U=x3(()=>P5(Z),[Z]),[G,_]=NZ(null),[N,H]=NZ(null),E=c3(null),L=c3(null),W=c3(null);GZ(()=>{let z=eV(Z,Y.get(),A);_((T)=>XG(T,z)?T:z)},[Z,Y,A.end.offset,A.end.regionId,A.start.offset,A.start.regionId]),GZ(()=>{let z=MG({canShowSelectionLeaf:J,currentLeaf:N,activeMarks:U,handles:G,selectionRange:V,threads:D});H((T)=>ZG(T,z)?T:z)},[U,J,G,N,V,D]);let R=r3((z,T=!0)=>{H((P)=>P?.kind==="create"?{animateInitialComment:T,kind:"thread",left:P.left,threadIndex:z,top:P.top}:P)}),f=r3((z)=>{if(z&&W.current===z.pointerId&&z.currentTarget.hasPointerCapture(z.pointerId))z.currentTarget.releasePointerCapture(z.pointerId);E.current=null,L.current=null,W.current=null}),I=r3((z)=>{let T=X.current,P=L.current,y=q(z);if(!y||!T||!P||W.current!==z.pointerId)return;let F=m2(T,Y.get(),y,P);if(!F)return;z.preventDefault(),z.stopPropagation(),K(),M(z),$(X0(T,{anchor:P,focus:F}))}),B=(z)=>({onPointerCancel:(T)=>{f(T)},onPointerDown:(T)=>{let P=X.current??Z,y=QG(A,z),F=z==="start"?A.start:A.end;if(!G)return;T.preventDefault(),T.stopPropagation(),W.current=T.pointerId,L.current=y,E.current=z,T.currentTarget.setPointerCapture(T.pointerId),K(),Q(),$(X0(P,{anchor:y,focus:F}))},onPointerMove:(T)=>{if(E.current!==z)return;I(T)},onPointerUp:(T)=>{if(E.current===z)I(T);f(T)}});return{handle:G?{start:{...G.start,props:B("start")},end:{...G.end,props:B("end")}}:null,leaf:N,promoteLeafToThread:R}}function eV($,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 $G($,M,J){return{activeMarks:J,kind:"create",left:M.start.left,selection:$,top:M.end.top}}function MG({activeMarks:$,canShowSelectionLeaf:M,currentLeaf:J,handles:Z,selectionRange:X,threads:Y}){if(!M||!X||!Z)return null;if(J?.kind==="thread")return Y[J.threadIndex]?J:null;return $G(X,Z,$)}function JG($,M){return $?.kind==="create"&&$.left===M.left&&$.selection.regionId===M.selection.regionId&&$.selection.startOffset===M.selection.startOffset&&$.selection.endOffset===M.selection.endOffset&&YG($.activeMarks,M.activeMarks)&&$.top===M.top}function ZG($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;if($.kind==="create"&&M.kind==="create")return JG($,M);return $.kind==="thread"&&M.kind==="thread"&&$.animateInitialComment===M.animateInitialComment&&$.left===M.left&&$.threadIndex===M.threadIndex&&$.top===M.top}function XG($,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 YG($,M){return $.length===M.length&&$.every((J,Z)=>J===M[Z])}function QG($,M){return M==="start"?$.end:$.start}import{useEffect as KG,useMemo as zZ,useState as DG}from"react";var u4={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)"},v4={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)"},FZ={...u4,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)"},HZ={...v4,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 EZ($){let M=zZ(()=>AG($),[$]),[J,Z]=DG(M.light),X=zZ(()=>UG(J),[J]);return KG(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){Z(M.light);return}let Y=window.matchMedia("(prefers-color-scheme: dark)"),Q=()=>{Z(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:J,themeStyles:X}}function qG($){return"light"in $&&"dark"in $}function AG($){if(!$)return{dark:v4,light:u4};if(qG($))return $;return{dark:$,light:$}}function UG($){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 NG,useEffectEvent as r0,useRef as a3,useState as M8}from"react";import{useMemo as VG}from"react";function WZ($){return VG(()=>GG({current:null},$),[$])}function GG($,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 BZ($,M){let J=M.getBoundingClientRect();return{x:$.clientX-J.left+M.scrollLeft,y:$.clientY-J.top+M.scrollTop}}function PZ({editorState:$,editorStateRef:M,renderResources:J,theme:Z}){let X=a3(B1()),Y=a3(null),Q=a3({height:240,top:0}),[K,q]=M8(0),[D,A]=M8(240),[V,U]=M8(0),[G,_]=M8(240),N=_G(K),H=r0(()=>{let y=M.current??$,F=Q.current;return Q6(y,{height:F.height,paddingX:Z.paddingX,paddingY:Z.paddingY,top:F.top,width:N},X.current,J)}),E=WZ(H),L=r0((y)=>{_((F)=>{let C=HG(y,Q.current.height);return F===C?F:C})}),W=r0((y)=>{Q.current={...Q.current,top:y},U((F)=>F===y?F:y),E.invalidate()}),R=r0((y)=>{let F=FG(y),C=F.top!==Q.current.top;if(Q.current=F,U((v)=>v===F.top?v:F.top),C)E.invalidate()}),f=r0((y)=>{let F=Y.current;if(!F)return W(y),y;F.scrollTop=y;let C=F.scrollTop;return W(C),C}),I=r0(()=>{return Y.current?.scrollTop??Q.current.top}),B=r0((y,F)=>{let C=y!==null&&y.documentIndex!==F.documentIndex,v=E.peek();if(!(!C||!v||v.layout.regionLineIndices.has(F.selection.focus.regionId)))E.invalidate()}),b=r0(()=>{return E.invalidate(),E.get()}),z=r0((y)=>{let F=Y.current;return F?BZ(y,F):null}),T=r0((y)=>{XZ(Y.current,y)});return NG(()=>{let y=Y.current;if(!y||typeof ResizeObserver>"u")return;let F=new ResizeObserver((C)=>{let v=C[0];if(!v)return;let h=Math.max(0,Math.floor(v.contentRect.width)),g=yZ(y);Q.current={...Q.current,height:g},q((O)=>O===h?O:h),A((O)=>O===g?O:g)});return F.observe(y),()=>F.disconnect()},[Y]),{actions:{autoScrollDuringDrag:T,getScrollTop:I,observePreparedViewport:L,observeScrollContainer:R,prepareNextPaint:b,reconcileEditorState:B,resolvePoint:z,scrollTo:f},props:{getScrollContainer:(y)=>({onScroll:(F)=>{R(F.currentTarget),y?.onScroll?.(F)},ref:Y}),scrollContent:{style:{height:`${G}px`}}},refs:{scrollContainer:Y},state:{layoutWidth:N,preparedViewport:E,scrollContentHeight:G,surfaceWidth:K,viewportHeight:D,viewportTop:V}}}function _G($){return Math.max(240,Math.floor($||480))}function yZ($){return Math.max(240,$.clientHeight)}function FG($){return{height:yZ($),top:$.scrollTop}}function HG($,M){return Math.max(M,Math.ceil($.totalHeight+24))}function zG(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function s3($,{paintHeight:M,paintTop:J,width:Z}){if(!$)return null;let X=Math.max(240,Math.ceil(M)),Y=zG();$.width=Math.ceil(Z*Y),$.height=Math.ceil(X*Y),$.style.width=`${Z}px`,$.style.height=`${X}px`,$.style.transform=`translateY(${J}px)`;let Q=$.getContext("2d");if(!Q)return null;return{context:Q,devicePixelRatio:Y,height:X,width:Z}}function i3($,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 bZ($,M){if(!M?.length||!$?.length)return;let J=new Map($.map((X)=>[X.id,X])),Z=[];for(let X of M){let Y=J.get(X.userId);if(!Y)continue;Z.push({...Y,color:X.color,cursor:X.cursor})}return Z.length===0?void 0:Z}function TZ($,M){if(!$)return{didReconcile:!1,state:M};let J=EG($,M)??jG($,M);return J?{didReconcile:!0,state:J}:{didReconcile:!1,state:M}}function EG($,M){let J=WG($,M);return J?X0(M,J,!1):null}function WG($,M){if(t3($.selection.anchor,$.selection.focus)){let Y=o3($,M,$.selection.focus,"neutral");return Y?{anchor:Y,focus:Y}:null}let J=TG($),Z=o3($,M,$.selection.anchor,J.anchor),X=o3($,M,$.selection.focus,J.focus);return Z&&X?{anchor:Z,focus:X}:null}function o3($,M,J,Z){let X=$.documentIndex.regionIndex.get(J.regionId);if(!X)return null;let Y=n3(X,M);if(!Y)return null;return{offset:PG(X.text,Y.text,J.offset,Z),regionId:Y.id}}function n3($,M){let J=M.documentIndex.regionIndex.get($.id);if(J)return J;if($.text.length===0)return null;let Z=BG($,M);if(Z)return Z;return M.documentIndex.regionPathIndex.get($.path)??null}function BG($,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 PG($,M,J,Z){let X=O0(J,0,$.length),{prefix:Y,suffix:Q}=b8($,X,X),K=yG(M,Y,Q);if(K!==null)return K;let q=bG(M,Y),D=wG(M,Q);if(Z==="before-suffix")return D??q??O0(J,0,M.length);return q??D??O0(J,0,M.length)}function yG($,M,J){let Z=c1($,M,J).filter((X)=>X.startOffset===X.endOffset);return Z.length===1?Z[0].startOffset:null}function bG($,M){let J=v0($,M);return J.length===1?J[0]+M.length:null}function wG($,M){let J=v0($,M);return J.length===1?J[0]:null}function TG($){let{anchor:M,focus:J}=$.selection;if(t3(M,J))return{anchor:"neutral",focus:"neutral"};return OG($,M,J)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function OG($,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 jG($,M){if(!t3($.selection.anchor,$.selection.focus))return null;let J=LG($);if(!J)return null;let Z=CG($,M,J);if(Z===null)return null;return RG(M,Z)}function LG($){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 CG($,M,J){let Z=wZ($,J.rootIndex,"before"),X=wZ($,J.rootIndex,"after"),Y=Z?n3(Z,M):null,Q=X?n3(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 RG($,M){let J=W1($.documentIndex.document,M,0,[d({text:""})]),Z={...$,documentIndex:Z2($.documentIndex,J,M,0)},X=p2(Z.documentIndex,$0(M));return X?X0(Z,X,!1):null}function wZ($,M,J){let Z=J==="before"?-1:1;for(let X=M+Z;X>=0&&X<$.documentIndex.roots.length;X+=Z){let Y=fG($,X,J);if(Y)return Y}return null}function fG($,M,J){let Z=$.documentIndex.roots[M]?.regions??[],X=J==="before"?Z.length-1:0,Y=J==="before"?-1:1;for(let Q=X;Q>=0&&Q<Z.length;Q+=Y){let K=Z[Q];if(K&&K.text.length>0)return K}return null}function t3($,M){return $.regionId===M.regionId&&$.offset===M.offset}import{jsx as x,jsxs as Z8,Fragment as IG}from"react/jsx-runtime";function X8({blocks:$}){return x(IG,{children:$.map((M)=>mG(M))})}function mG($){switch($.type){case"blockquote":return x("blockquote",{className:"preview-block preview-block-blockquote",children:x(X8,{blocks:$.children})},$.id);case"code":return Z8("div",{className:"preview-block preview-block-code",children:[x("div",{className:"preview-rich-header",children:uG($.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:J8($.children)},$.id)}case"list":return $.ordered?x("ol",{className:"preview-block preview-block-list",start:$.start??1,children:$.items.map((M)=>e3(M))},$.id):x("ul",{className:"preview-block preview-block-list",children:$.items.map((M)=>e3(M))},$.id);case"listItem":return e3($);case"paragraph":return x("p",{className:"preview-block preview-block-paragraph",children:J8($.children)},$.id);case"table":return Z8("div",{className:"preview-block preview-block-table",children:[x("div",{className:"preview-rich-header",children:vG($.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:J8(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 e3($){return x("li",{className:"preview-block preview-block-list-item",children:x(X8,{blocks:$.children})},$.id)}function J8($){return $.map((M)=>{switch(M.type){case"break":return x("br",{},M.id);case"image":return Z8("span",{className:"preview-inline preview-inline-image",children:[x("img",{alt:M.alt??"",src:M.url,title:M.title??""}),Z8("span",{children:[x("strong",{children:hG(M.alt)}),x("small",{children:gG(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 SG(M);case"text":return x("span",{className:"preview-inline",children:kG(M.text,M.marks)},M.id);case"unsupported":return x("span",{className:"preview-inline preview-inline-unsupported",children:M.source},M.id)}})}function SG($){return x("a",{className:"preview-inline preview-inline-link",href:$.url,children:J8($.children)},$.id)}function kG($,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 uG($,M){return[$??"plain text",M].filter(Boolean).join(" • ")}function vG($,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 hG($){return $?.trim()?$:"Untitled image"}function gG($,M){return M?.trim()?`${M} • ${$}`:$}var OZ=`/* Base Documint host and SSR-fallback styles. */
|
|
19
|
+
`)}var H3=null,dM;function cM(){if(H3===null)H3=new Intl.Segmenter(dM,{granularity:"word"});return H3}var aM=/\p{Script=Arabic}/u,Y6=/\p{M}/u,CY=/\p{Nd}/u;function z3($){return aM.test($)}function $1($){for(let Y of $){let X=Y.codePointAt(0);if(X>=19968&&X<=40959||X>=13312&&X<=19903||X>=131072&&X<=173791||X>=173824&&X<=177983||X>=177984&&X<=178207||X>=178208&&X<=183983||X>=183984&&X<=191471||X>=196608&&X<=201551||X>=63744&&X<=64255||X>=194560&&X<=195103||X>=12288&&X<=12351||X>=12352&&X<=12447||X>=12448&&X<=12543||X>=44032&&X<=55215||X>=65280&&X<=65519)return!0}return!1}var W3=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),z4=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),P3=new Set(["'","’"]),W2=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),rM=new Set([":",".","،","؛"]),sM=new Set(["၏"]),iM=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function oM($){if(y3($))return!0;let Y=!1;for(let X of $){if(W2.has(X)){Y=!0;continue}if(Y&&Y6.test(X))continue;return!1}return Y}function nM($){for(let Y of $)if(!W3.has(Y)&&!W2.has(Y))return!1;return $.length>0}function tM($){if(y3($))return!0;for(let Y of $)if(!z4.has(Y)&&!P3.has(Y)&&!Y6.test(Y))return!1;return $.length>0}function y3($){let Y=!1;for(let X of $){if(X==="\\"||Y6.test(X))continue;if(z4.has(X)||W2.has(X)||P3.has(X)){Y=!0;continue}return!1}return Y}function eM($){let Y=Array.from($),X=Y.length;while(X>0){let Z=Y[X-1];if(Y6.test(Z)){X--;continue}if(z4.has(Z)||P3.has(Z)){X--;continue}break}if(X<=0||X===Y.length)return null;return{head:Y.slice(0,X).join(""),tail:Y.slice(X).join("")}}function $q($,Y){if($.length===0)return!1;for(let X of $)if(X!==Y)return!1;return!0}function Yq($){if(!z3($)||$.length===0)return!1;return rM.has($[$.length-1])}function Xq($){if($.length===0)return!1;return sM.has($[$.length-1])}function Zq($){if($.length<2||$[0]!==" ")return null;let Y=$.slice(1);if(/^\p{M}+$/u.test(Y))return{space:" ",marks:Y};return null}function T3($){for(let Y=$.length-1;Y>=0;Y--){let X=$[Y];if(iM.has(X))return!0;if(!W2.has(X))return!1}return!1}function Jq($,Y){if(Y.preserveOrdinarySpaces||Y.preserveHardBreaks){if($===" ")return"preserved-space";if($==="\t")return"tab";if(Y.preserveHardBreaks&&$===`
|
|
20
|
+
`)return"hard-break"}if($===" ")return"space";if($===" "||$===" "||$===""||$==="\uFEFF")return"glue";if($==="")return"zero-width-break";if($==="")return"soft-hyphen";return"text"}function Y1($){return $.length===1?$[0]:$.join("")}function Kq($,Y,X,Z){let J=[],K=null,Q=[],M=X,D=!1,q=0;for(let U of $){let V=Jq(U,Z),G=V==="text"&&Y;if(K!==null&&V===K&&G===D){Q.push(U),q+=U.length;continue}if(K!==null)J.push({text:Y1(Q),isWordLike:D,kind:K,start:M});K=V,Q=[U],M=X+q,D=G,q+=U.length}if(K!==null)J.push({text:Y1(Q),isWordLike:D,kind:K,start:M});return J}function F3($){return $==="space"||$==="preserved-space"||$==="zero-width-break"||$==="hard-break"}var Qq=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function Mq($,Y){let X=$.texts[Y];if(X.startsWith("www."))return!0;return Qq.test(X)&&Y+1<$.len&&$.kinds[Y+1]==="text"&&$.texts[Y+1]==="//"}function qq($){return $.includes("?")&&($.includes("://")||$.startsWith("www."))}function Dq($){let Y=$.texts.slice(),X=$.isWordLike.slice(),Z=$.kinds.slice(),J=$.starts.slice();for(let Q=0;Q<$.len;Q++){if(Z[Q]!=="text"||!Mq($,Q))continue;let M=[Y[Q]],D=Q+1;while(D<$.len&&!F3(Z[D])){M.push(Y[D]),X[Q]=!0;let q=Y[D].includes("?");if(Z[D]="text",Y[D]="",D++,q)break}Y[Q]=Y1(M)}let K=0;for(let Q=0;Q<Y.length;Q++){let M=Y[Q];if(M.length===0)continue;if(K!==Q)Y[K]=M,X[K]=X[Q],Z[K]=Z[Q],J[K]=J[Q];K++}return Y.length=K,X.length=K,Z.length=K,J.length=K,{len:K,texts:Y,isWordLike:X,kinds:Z,starts:J}}function Uq($){let Y=[],X=[],Z=[],J=[];for(let K=0;K<$.len;K++){let Q=$.texts[K];if(Y.push(Q),X.push($.isWordLike[K]),Z.push($.kinds[K]),J.push($.starts[K]),!qq(Q))continue;let M=K+1;if(M>=$.len||F3($.kinds[M]))continue;let D=[],q=$.starts[M],U=M;while(U<$.len&&!F3($.kinds[U]))D.push($.texts[U]),U++;if(D.length>0)Y.push(Y1(D)),X.push(!0),Z.push("text"),J.push(q),K=U-1}return{len:Y.length,texts:Y,isWordLike:X,kinds:Z,starts:J}}var Gq=new Set([":","-","/","×",",",".","+","–","—"]),OY=/^[A-Za-z0-9_]+[,:;]*$/,BY=/[,:;]+$/;function LY($){for(let Y of $)if(CY.test(Y))return!0;return!1}function E3($){if($.length===0)return!1;for(let Y of $){if(CY.test(Y)||Gq.has(Y))continue;return!1}return!0}function Vq($){let Y=[],X=[],Z=[],J=[];for(let K=0;K<$.len;K++){let Q=$.texts[K],M=$.kinds[K];if(M==="text"&&E3(Q)&&LY(Q)){let D=[Q],q=K+1;while(q<$.len&&$.kinds[q]==="text"&&E3($.texts[q]))D.push($.texts[q]),q++;Y.push(Y1(D)),X.push(!0),Z.push("text"),J.push($.starts[K]),K=q-1;continue}Y.push(Q),X.push($.isWordLike[K]),Z.push(M),J.push($.starts[K])}return{len:Y.length,texts:Y,isWordLike:X,kinds:Z,starts:J}}function Nq($){let Y=[],X=[],Z=[],J=[];for(let K=0;K<$.len;K++){let Q=$.texts[K],M=$.kinds[K],D=$.isWordLike[K];if(M==="text"&&D&&OY.test(Q)){let q=[Q],U=BY.test(Q),V=K+1;while(U&&V<$.len&&$.kinds[V]==="text"&&$.isWordLike[V]&&OY.test($.texts[V])){let G=$.texts[V];q.push(G),U=BY.test(G),V++}Y.push(Y1(q)),X.push(!0),Z.push("text"),J.push($.starts[K]),K=V-1;continue}Y.push(Q),X.push(D),Z.push(M),J.push($.starts[K])}return{len:Y.length,texts:Y,isWordLike:X,kinds:Z,starts:J}}function Aq($){let Y=[],X=[],Z=[],J=[];for(let K=0;K<$.len;K++){let Q=$.texts[K];if($.kinds[K]==="text"&&Q.includes("-")){let M=Q.split("-"),D=M.length>1;for(let q=0;q<M.length;q++){let U=M[q];if(!D)break;if(U.length===0||!LY(U)||!E3(U))D=!1}if(D){let q=0;for(let U=0;U<M.length;U++){let V=M[U],G=U<M.length-1?`${V}-`:V;Y.push(G),X.push(!0),Z.push("text"),J.push($.starts[K]+q),q+=G.length}continue}}Y.push(Q),X.push($.isWordLike[K]),Z.push($.kinds[K]),J.push($.starts[K])}return{len:Y.length,texts:Y,isWordLike:X,kinds:Z,starts:J}}function _q($){let Y=[],X=[],Z=[],J=[],K=0;while(K<$.len){let Q=[$.texts[K]],M=$.isWordLike[K],D=$.kinds[K],q=$.starts[K];if(D==="glue"){let U=[Q[0]],V=q;K++;while(K<$.len&&$.kinds[K]==="glue")U.push($.texts[K]),K++;let G=Y1(U);if(K<$.len&&$.kinds[K]==="text")Q[0]=G,Q.push($.texts[K]),M=$.isWordLike[K],D="text",q=V,K++;else{Y.push(G),X.push(!1),Z.push("glue"),J.push(V);continue}}else K++;if(D==="text")while(K<$.len&&$.kinds[K]==="glue"){let U=[];while(K<$.len&&$.kinds[K]==="glue")U.push($.texts[K]),K++;let V=Y1(U);if(K<$.len&&$.kinds[K]==="text"){Q.push(V,$.texts[K]),M=M||$.isWordLike[K],K++;continue}Q.push(V)}Y.push(Y1(Q)),X.push(M),Z.push(D),J.push(q)}return{len:Y.length,texts:Y,isWordLike:X,kinds:Z,starts:J}}function Hq($){let Y=$.texts.slice(),X=$.isWordLike.slice(),Z=$.kinds.slice(),J=$.starts.slice();for(let K=0;K<Y.length-1;K++){if(Z[K]!=="text"||Z[K+1]!=="text")continue;if(!$1(Y[K])||!$1(Y[K+1]))continue;let Q=eM(Y[K]);if(Q===null)continue;Y[K]=Q.head,Y[K+1]=Q.tail+Y[K+1],J[K+1]=J[K]+Q.head.length}return{len:Y.length,texts:Y,isWordLike:X,kinds:Z,starts:J}}function zq($,Y,X){let Z=cM(),J=0,K=[],Q=[],M=[],D=[];for(let G of Z.segment($))for(let N of Kq(G.segment,G.isWordLike??!1,G.index,X)){let A=N.kind==="text";if(Y.carryCJKAfterClosingQuote&&A&&J>0&&M[J-1]==="text"&&$1(N.text)&&$1(K[J-1])&&T3(K[J-1]))K[J-1]+=N.text,Q[J-1]=Q[J-1]||N.isWordLike;else if(A&&J>0&&M[J-1]==="text"&&nM(N.text)&&$1(K[J-1]))K[J-1]+=N.text,Q[J-1]=Q[J-1]||N.isWordLike;else if(A&&J>0&&M[J-1]==="text"&&Xq(K[J-1]))K[J-1]+=N.text,Q[J-1]=Q[J-1]||N.isWordLike;else if(A&&J>0&&M[J-1]==="text"&&N.isWordLike&&z3(N.text)&&Yq(K[J-1]))K[J-1]+=N.text,Q[J-1]=!0;else if(A&&!N.isWordLike&&J>0&&M[J-1]==="text"&&N.text.length===1&&N.text!=="-"&&N.text!=="—"&&$q(K[J-1],N.text))K[J-1]+=N.text;else if(A&&!N.isWordLike&&J>0&&M[J-1]==="text"&&(oM(N.text)||N.text==="-"&&Q[J-1]))K[J-1]+=N.text;else K[J]=N.text,Q[J]=N.isWordLike,M[J]=N.kind,D[J]=N.start,J++}for(let G=1;G<J;G++)if(M[G]==="text"&&!Q[G]&&y3(K[G])&&M[G-1]==="text")K[G-1]+=K[G],Q[G-1]=Q[G-1]||Q[G],K[G]="";for(let G=J-2;G>=0;G--)if(M[G]==="text"&&!Q[G]&&tM(K[G])){let N=G+1;while(N<J&&K[N]==="")N++;if(N<J&&M[N]==="text")K[N]=K[G]+K[N],D[N]=D[G],K[G]=""}let q=0;for(let G=0;G<J;G++){let N=K[G];if(N.length===0)continue;if(q!==G)K[q]=N,Q[q]=Q[G],M[q]=M[G],D[q]=D[G];q++}K.length=q,Q.length=q,M.length=q,D.length=q;let U=_q({len:q,texts:K,isWordLike:Q,kinds:M,starts:D}),V=Hq(Nq(Aq(Vq(Uq(Dq(U))))));for(let G=0;G<V.len-1;G++){let N=Zq(V.texts[G]);if(N===null)continue;if(V.kinds[G]!=="space"&&V.kinds[G]!=="preserved-space"||V.kinds[G+1]!=="text"||!z3(V.texts[G+1]))continue;V.texts[G]=N.space,V.isWordLike[G]=!1,V.kinds[G]=V.kinds[G]==="preserved-space"?"preserved-space":"space",V.texts[G+1]=N.marks+V.texts[G+1],V.starts[G+1]=V.starts[G]+N.space.length}return V}function Fq($,Y){if($.len===0)return[];if(!Y.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len}];let X=[],Z=0;for(let J=0;J<$.len;J++){if($.kinds[J]!=="hard-break")continue;X.push({startSegmentIndex:Z,endSegmentIndex:J,consumedEndSegmentIndex:J+1}),Z=J+1}if(Z<$.len)X.push({startSegmentIndex:Z,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len});return X}function RY($,Y,X="normal"){let Z=pM(X),J=Z.mode==="pre-wrap"?lM($):xM($);if(J.length===0)return{normalized:J,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let K=zq(J,Y,Z);return{normalized:J,chunks:Fq(K,Z),...K}}var P2=null,bY=new Map,y2=null,Eq=/\p{Emoji_Presentation}/u,Wq=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,j3=null,SY=new Map;function w3(){if(P2!==null)return P2;if(typeof OffscreenCanvas<"u")return P2=new OffscreenCanvas(1,1).getContext("2d"),P2;if(typeof document<"u")return P2=document.createElement("canvas").getContext("2d"),P2;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function Pq($){let Y=bY.get($);if(!Y)Y=new Map,bY.set($,Y);return Y}function N1($,Y){let X=Y.get($);if(X===void 0)X={width:w3().measureText($).width,containsCJK:$1($)},Y.set($,X);return X}function T2(){if(y2!==null)return y2;if(typeof navigator>"u")return y2={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},y2;let $=navigator.userAgent,X=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 y2={lineFitEpsilon:X?0.015625:0.005,carryCJKAfterClosingQuote:Z,preferPrefixWidthsForBreakableRuns:X,preferEarlySoftHyphenBreak:X},y2}function yq($){let Y=$.match(/(\d+(?:\.\d+)?)\s*px/);return Y?parseFloat(Y[1]):16}function O3(){if(j3===null)j3=new Intl.Segmenter(void 0,{granularity:"grapheme"});return j3}function Tq($){return Eq.test($)||$.includes("️")}function vY($){return Wq.test($)}function jq($,Y){let X=SY.get($);if(X!==void 0)return X;let Z=w3();Z.font=$;let J=Z.measureText("\uD83D\uDE00").width;if(X=0,J>Y+0.5&&typeof document<"u"&&document.body!==null){let K=document.createElement("span");K.style.font=$,K.style.display="inline-block",K.style.visibility="hidden",K.style.position="absolute",K.textContent="\uD83D\uDE00",document.body.appendChild(K);let Q=K.getBoundingClientRect().width;if(document.body.removeChild(K),J-Q>0.5)X=J-Q}return SY.set($,X),X}function wq($){let Y=0,X=O3();for(let Z of X.segment($))if(Tq(Z.segment))Y++;return Y}function Oq($,Y){if(Y.emojiCount===void 0)Y.emojiCount=wq($);return Y.emojiCount}function A1($,Y,X){if(X===0)return Y.width;return Y.width-Oq($,Y)*X}function fY($,Y,X,Z){if(Y.graphemeWidths!==void 0)return Y.graphemeWidths;let J=[],K=O3();for(let Q of K.segment($)){let M=N1(Q.segment,X);J.push(A1(Q.segment,M,Z))}return Y.graphemeWidths=J.length>1?J:null,Y.graphemeWidths}function mY($,Y,X,Z){if(Y.graphemePrefixWidths!==void 0)return Y.graphemePrefixWidths;let J=[],K=O3(),Q="";for(let M of K.segment($)){Q+=M.segment;let D=N1(Q,X);J.push(A1(Q,D,Z))}return Y.graphemePrefixWidths=J.length>1?J:null,Y.graphemePrefixWidths}function hY($,Y){let X=w3();X.font=$;let Z=Pq($),J=yq($),K=Y?jq($,J):0;return{cache:Z,fontSize:J,emojiCorrection:K}}function X6($){return $==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen"}function Bq($,Y){while(Y<$.widths.length){let X=$.kinds[Y];if(X!=="space"&&X!=="zero-width-break"&&X!=="soft-hyphen")break;Y++}return Y}function Cq($,Y){if(Y<=0)return 0;let X=$%Y;if(Math.abs(X)<=0.000001)return Y;return Y-X}function kY($,Y,X,Z){if(!Z||Y===null)return $[X];return Y[X]-(X>0?Y[X-1]:0)}function Lq($,Y,X,Z,J,K){let Q=0,M=Y;while(Q<$.length){let D=K?Y+$[Q]:M+$[Q];if((Q+1<$.length?D+J:D)>X+Z)break;M=D,Q++}return{fitCount:Q,fittedWidth:M}}function Rq($,Y,X){let{widths:Z,kinds:J,breakableWidths:K,breakablePrefixWidths:Q}=$;if(Z.length===0)return 0;let M=T2(),D=M.lineFitEpsilon,q=0,U=0,V=!1,G=0,N=0,A=0,_=0,z=-1,F=0;function B(){z=-1,F=0}function W(C=A,T=_,H=U){q++,X?.({startSegmentIndex:G,startGraphemeIndex:N,endSegmentIndex:C,endGraphemeIndex:T,width:H}),U=0,V=!1,B()}function S(C,T){V=!0,G=C,N=0,A=C+1,_=0,U=T}function b(C,T,H){V=!0,G=C,N=T,A=C,_=T+1,U=H}function k(C,T){if(!V){S(C,T);return}U+=T,A=C+1,_=0}function P(C,T){if(!X6(J[C]))return;z=C+1,F=U-T}function y(C){E(C,0)}function E(C,T){let H=K[C],R=Q[C]??null;for(let u=T;u<H.length;u++){let g=kY(H,R,u,M.preferPrefixWidthsForBreakableRuns);if(!V){b(C,u,g);continue}if(U+g>Y+D)W(),b(C,u,g);else U+=g,A=C,_=u+1}if(V&&A===C&&_===H.length)A=C+1,_=0}let w=0;while(w<Z.length){if(!V){if(w=Bq($,w),w>=Z.length)break}let C=Z[w],T=J[w];if(!V){if(C>Y&&K[w]!==null)y(w);else S(w,C);P(w,C),w++;continue}if(U+C>Y+D){if(X6(T)){k(w,C),W(w+1,0,U-C),w++;continue}if(z>=0){if(A>z||A===z&&_>0){W();continue}W(z,0,F);continue}if(C>Y&&K[w]!==null){W(),y(w),w++;continue}W();continue}k(w,C),P(w,C),w++}if(V)W();return q}function uY($,Y,X){if($.simpleLineWalkFastPath)return Rq($,Y,X);let{widths:Z,lineEndFitAdvances:J,lineEndPaintAdvances:K,kinds:Q,breakableWidths:M,breakablePrefixWidths:D,discretionaryHyphenWidth:q,tabStopAdvance:U,chunks:V}=$;if(Z.length===0||V.length===0)return 0;let G=T2(),N=G.lineFitEpsilon,A=0,_=0,z=!1,F=0,B=0,W=0,S=0,b=-1,k=0,P=0,y=null;function E(){b=-1,k=0,P=0,y=null}function w(O=W,v=S,f=_){A++,X?.({startSegmentIndex:F,startGraphemeIndex:B,endSegmentIndex:O,endGraphemeIndex:v,width:f}),_=0,z=!1,E()}function C(O,v){z=!0,F=O,B=0,W=O+1,S=0,_=v}function T(O,v,f){z=!0,F=O,B=v,W=O,S=v+1,_=f}function H(O,v){if(!z){C(O,v);return}_+=v,W=O+1,S=0}function R(O,v){if(!X6(Q[O]))return;let f=Q[O]==="tab"?0:J[O],a=Q[O]==="tab"?v:K[O];b=O+1,k=_-v+f,P=_-v+a,y=Q[O]}function u(O){g(O,0)}function g(O,v){let f=M[O],a=D[O]??null;for(let x=v;x<f.length;x++){let E0=kY(f,a,x,G.preferPrefixWidthsForBreakableRuns);if(!z){T(O,x,E0);continue}if(_+E0>Y+N)w(),T(O,x,E0);else _+=E0,W=O,S=x+1}if(z&&W===O&&S===f.length)W=O+1,S=0}function I(O){if(y!=="soft-hyphen")return!1;let v=M[O];if(v===null)return!1;let f=G.preferPrefixWidthsForBreakableRuns?D[O]??v:v,a=f!==v,{fitCount:x,fittedWidth:E0}=Lq(f,_,Y,N,q,a);if(x===0)return!1;if(_=E0,W=O,S=x,E(),x===v.length)return W=O+1,S=0,!0;return w(O,x,E0+q),g(O,x),!0}function j(O){A++,X?.({startSegmentIndex:O.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:O.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),E()}for(let O=0;O<V.length;O++){let v=V[O];if(v.startSegmentIndex===v.endSegmentIndex){j(v);continue}z=!1,_=0,F=v.startSegmentIndex,B=0,W=v.startSegmentIndex,S=0,E();let f=v.startSegmentIndex;while(f<v.endSegmentIndex){let a=Q[f],x=a==="tab"?Cq(_,U):Z[f];if(a==="soft-hyphen"){if(z)W=f+1,S=0,b=f+1,k=_+q,P=_+q,y=a;f++;continue}if(!z){if(x>Y&&M[f]!==null)u(f);else C(f,x);R(f,x),f++;continue}if(_+x>Y+N){let t0=_+(a==="tab"?0:J[f]),u0=_+(a==="tab"?x:K[f]);if(y==="soft-hyphen"&&G.preferEarlySoftHyphenBreak&&k<=Y+N){w(b,0,P);continue}if(y==="soft-hyphen"&&I(f)){f++;continue}if(X6(a)&&t0<=Y+N){H(f,x),w(f+1,0,u0),f++;continue}if(b>=0&&k<=Y+N){if(W>b||W===b&&S>0){w();continue}let g0=b;w(g0,0,P),f=g0;continue}if(x>Y&&M[f]!==null){w(),u(f),f++;continue}w();continue}H(f,x),R(f,x),f++}if(z){let a=b===v.consumedEndSegmentIndex?P:_;w(v.consumedEndSegmentIndex,0,a)}}return A}var B3=null,gY=new WeakMap;function pY(){if(B3===null)B3=new Intl.Segmenter(void 0,{granularity:"grapheme"});return B3}function bq($){if($)return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]};return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function Sq($,Y,X){let Z=pY(),J=T2(),{cache:K,emojiCorrection:Q}=hY(Y,vY($.normalized)),M=A1("-",N1("-",K),Q),q=A1(" ",N1(" ",K),Q)*8;if($.len===0)return bq(X);let U=[],V=[],G=[],N=[],A=$.chunks.length<=1,_=X?[]:null,z=[],F=[],B=X?[]:null,W=Array.from({length:$.len}),S=Array.from({length:$.len});function b(y,E,w,C,T,H,R,u){if(T!=="text"&&T!=="space"&&T!=="zero-width-break")A=!1;if(U.push(E),V.push(w),G.push(C),N.push(T),_?.push(H),z.push(R),F.push(u),B!==null)B.push(y)}for(let y=0;y<$.len;y++){W[y]=U.length;let E=$.texts[y],w=$.isWordLike[y],C=$.kinds[y],T=$.starts[y];if(C==="soft-hyphen"){b(E,0,M,M,C,T,null,null),S[y]=U.length;continue}if(C==="hard-break"){b(E,0,0,0,C,T,null,null),S[y]=U.length;continue}if(C==="tab"){b(E,0,0,0,C,T,null,null),S[y]=U.length;continue}let H=N1(E,K);if(C==="text"&&H.containsCJK){let I="",j=0;for(let O of Z.segment(E)){let v=O.segment;if(I.length===0){I=v,j=O.index;continue}if(z4.has(I)||W3.has(v)||W2.has(v)||J.carryCJKAfterClosingQuote&&$1(v)&&T3(I)){I+=v;continue}let f=N1(I,K),a=A1(I,f,Q);b(I,a,a,a,"text",T+j,null,null),I=v,j=O.index}if(I.length>0){let O=N1(I,K),v=A1(I,O,Q);b(I,v,v,v,"text",T+j,null,null)}S[y]=U.length;continue}let R=A1(E,H,Q),u=C==="space"||C==="preserved-space"||C==="zero-width-break"?0:R,g=C==="space"||C==="zero-width-break"?0:R;if(w&&E.length>1){let I=fY(E,H,K,Q),j=J.preferPrefixWidthsForBreakableRuns?mY(E,H,K,Q):null;b(E,R,u,g,C,T,I,j)}else b(E,R,u,g,C,T,null,null);S[y]=U.length}let k=vq($.chunks,W,S),P=_===null?null:wY($.normalized,_);if(B!==null)return{widths:U,lineEndFitAdvances:V,lineEndPaintAdvances:G,kinds:N,simpleLineWalkFastPath:A,segLevels:P,breakableWidths:z,breakablePrefixWidths:F,discretionaryHyphenWidth:M,tabStopAdvance:q,chunks:k,segments:B};return{widths:U,lineEndFitAdvances:V,lineEndPaintAdvances:G,kinds:N,simpleLineWalkFastPath:A,segLevels:P,breakableWidths:z,breakablePrefixWidths:F,discretionaryHyphenWidth:M,tabStopAdvance:q,chunks:k}}function vq($,Y,X){let Z=[];for(let J=0;J<$.length;J++){let K=$[J],Q=K.startSegmentIndex<Y.length?Y[K.startSegmentIndex]:X[X.length-1]??0,M=K.endSegmentIndex<Y.length?Y[K.endSegmentIndex]:X[X.length-1]??0,D=K.consumedEndSegmentIndex<Y.length?Y[K.consumedEndSegmentIndex]:X[X.length-1]??0;Z.push({startSegmentIndex:Q,endSegmentIndex:M,consumedEndSegmentIndex:D})}return Z}function fq($,Y,X,Z){let J=RY($,T2(),Z?.whiteSpace);return Sq(J,Y,X)}function xY($,Y,X){return fq($,Y,!0,X)}function mq($){return $}function IY($,Y,X){let Z=X.get($);if(Z!==void 0)return Z;Z=[];let J=pY();for(let K of J.segment(Y[$]))Z.push(K.segment);return X.set($,Z),Z}function hq($){let Y=gY.get($);if(Y!==void 0)return Y;return Y=new Map,gY.set($,Y),Y}function kq($,Y,X,Z){return Z>0&&$[Z-1]==="soft-hyphen"&&!(Y===Z&&X>0)}function uq($,Y,X,Z,J,K,Q){let M="",D=kq(Y,Z,J,K);for(let q=Z;q<K;q++){if(Y[q]==="soft-hyphen"||Y[q]==="hard-break")continue;if(q===Z&&J>0)M+=IY(q,$,X).slice(J).join("");else M+=$[q]}if(Q>0){if(D)M+="-";M+=IY(K,$,X).slice(Z===K?J:0,Q).join("")}else if(D)M+="-";return M}function gq($,Y,X,Z,J,K,Q){return{text:uq($.segments,$.kinds,Y,Z,J,K,Q),width:X,start:{segmentIndex:Z,graphemeIndex:J},end:{segmentIndex:K,graphemeIndex:Q}}}function Iq($,Y,X){return gq($,Y,X.width,X.startSegmentIndex,X.startGraphemeIndex,X.endSegmentIndex,X.endGraphemeIndex)}function lY($,Y,X){let Z=[];if($.widths.length===0)return{lineCount:0,height:0,lines:Z};let J=hq($),K=uY(mq($),Y,(Q)=>{Z.push(Iq($,J,Q))});return{lineCount:K,height:K*X,lines:Z}}function F4($,Y,X){let Z=$.image?Y.images.get($.image.url)??null:null,J=$.image?.width??null,K=Math.min(X,J??240),Q=Math.max(120,Math.round(K*0.5625));if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return{height:Q,width:K};let M=Math.min(X,J??Z.intrinsicWidth),D=Math.min(1,M/Z.intrinsicWidth);return{height:Math.max(48,Math.round(Z.intrinsicHeight*D)),width:Math.max(48,Math.round(Z.intrinsicWidth*D))}}function dY($,Y){if(!$.image)return`${$.kind}:missing-image`;let X=Y.images.get($.image.url);return`${$.kind}:${$.image.url}:${$.image.width??0}:${X?.status??"loading"}:${X?.intrinsicWidth??0}:${X?.intrinsicHeight??0}`}var cY=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],Z6;function j2($){if($?.type==="heading"){let{fontSize:Y}=iY($.depth);return`700 ${Y}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 _1($,Y){if($?.type==="heading")return iY($.depth).lineHeight;if($?.type==="code")return 22;return Y}function iY($){return cY[$-1]??cY.at(-1)}function w2($,Y,X,Z,J,K,Q){let M=`${K6(Y,Q)}:${J}:${K}:${X}`,D=$.measuredLines.get(M);if(D)return D;let q=xq($,Y,X,Z,J,K,Q);return zY($,M,q)}function J6($,Y,X,Z,J,K,Q,M){let D=`${K6(Y,M)}:${X}:${Z}:${K}:${Q}`,q=$.lineBoundaries.get(D);if(q)return q;let U=nY();if(!U)return rY(J);let V=[{left:0,offset:0}],G=0,N=Y.inlines.filter((A)=>A.end>X&&A.start<Z);if(N.length===0)return rY(J);for(let A of N){let _=Math.max(X,A.start),z=Math.min(Z,A.end),F=Y.text.slice(_,z),B=_-X;if(A.kind==="image"){let W=F4(A,M,Q).width;G+=W,B+=F.length,V.push({left:G,offset:B});continue}U.font=oY(K,A.marks);for(let W of Array.from(F))G+=tY($,U,W),B+=W.length,V.push({left:G,offset:B})}return FY($,D,V)}function pq($,Y,X,Z){let J=`${X}::${Z}::${Y}`,K=$.preparedText.get(J);if(K)return K;let Q=xY(Y,X,{whiteSpace:Z});return HY($,J,Q)}function xq($,Y,X,Z,J,K,Q){let M=Y.text;if(M.length===0)return[{end:0,height:K,start:0,text:"",width:0}];if(rq(Y))return dq($,Y,X,J,K,Q);try{let D=pq($,M,X,tq(Z));return lY(D,J,K).lines.map((U)=>({end:aY(D.segments,U.end),height:K,start:aY(D.segments,U.start),text:U.text,width:U.width}))}catch{return lq(M,J,K)}}function aY($,Y){let X=0;for(let K=0;K<Y.segmentIndex;K+=1)X+=$[K]?.length??0;let Z=$[Y.segmentIndex]??"",J=Array.from(Z);for(let K=0;K<Y.graphemeIndex;K+=1)X+=J[K]?.length??0;return X}function rY($){let Y=[{left:0,offset:0}],X=0,Z=0;for(let J of Array.from($))X+=9,Z+=J.length,Y.push({left:X,offset:Z});return Y}function lq($,Y,X){let Z=Math.max(1,Math.floor(Y/9)),J=eq($,Z),K=0;return J.map((Q)=>{let M=K,D=M+Q.length;return K=D,{end:D,height:X,start:M,text:Q,width:Q.length*9}})}function dq($,Y,X,Z,J,K){let Q=aq($,nY(),Y,X,Z,J,K);if(Q.length===0)return[{end:0,height:J,start:0,text:"",width:0}];return cq(Q,Y.text,Z,J)}function cq($,Y,X,Z){let J=[],K=0;while(K<$.length){let M=$[K].start;if($[K].text===`
|
|
21
|
+
`){J.push({end:M,height:Z,start:M,text:"",width:0}),K+=1;continue}let D=0,q=0,U=K,V=-1,G=Z;while(U<$.length){let A=$[U];if(A.text===`
|
|
22
|
+
`)break;let _=D+A.width;if(_>X&&U>K)break;if(D=_,G=Math.max(G,A.height),A.breakable)V=U,q=D;U+=1}if(U===$.length||$[U]?.text===`
|
|
23
|
+
`){let A=$[U-1]?.end??M;J.push({end:A,height:G,start:M,text:Y.slice(M,A),width:D}),K=U<$.length&&$[U]?.text===`
|
|
24
|
+
`?U+1:U;continue}if(V>=K){let A=$[V].end;J.push({end:A,height:G,start:M,text:Y.slice(M,A),width:q}),K=V+1;continue}let N=$[Math.max(K,U-1)].end;J.push({end:N,height:G,start:M,text:Y.slice(M,N),width:D}),K=Math.max(K+1,U)}let Q=$.at(-1);if(Q?.text===`
|
|
25
|
+
`)J.push({end:Q.end,height:Z,start:Q.end,text:"",width:0});return J}function aq($,Y,X,Z,J,K,Q){let M=[];for(let D of X.inlines){if(D.kind==="image"){let U=F4(D,Q,J);M.push({breakable:!0,end:D.end,height:U.height,start:D.start,text:D.text,width:U.width});continue}if(Y)Y.font=oY(Z,D.marks);let q=D.start;for(let U of Array.from(D.text)){let V=q,G=V+U.length;M.push({breakable:/\s/.test(U),end:G,height:K,start:V,text:U,width:U===`
|
|
26
|
+
`?0:tY($,Y,U)}),q=G}}return M}function rq($){return $.inlines.some((Y)=>Y.kind==="image"||Y.kind==="lineBreak"||nq(Y))}var sY=new WeakMap;function K6($,Y){let X=sY.get($.inlines);if(X&&X.path===$.path&&X.text===$.text)return X.identity;let Z=[$.path,oq($.text),sq($,Y)].join(":");if(!$.inlines.some((J)=>J.kind==="image"))sY.set($.inlines,{identity:Z,path:$.path,text:$.text});return Z}function sq($,Y){return $.inlines.map((X)=>`${X.start}-${X.end}:${iq(X,Y)}`).join("|")}function iq($,Y){if($.kind==="image"&&$.image)return dY($,Y);return`${$.kind}:${$.inlineCode?1:0}:${$.marks.join(",")}:${$.link?.url??""}`}function oq($){let Y=2166136261;for(let X of $)Y^=X.charCodeAt(0),Y=Math.imul(Y,16777619);return(Y>>>0).toString(36)}function nq($){return $.marks.includes("italic")||$.marks.includes("bold")}function oY($,Y){let X=[];if(Y.includes("italic"))X.push("italic");if(Y.includes("bold"))X.push("700");return X.length>0?`${X.join(" ")} ${$}`:$}function nY(){if(Z6!==void 0)return Z6;return Z6=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,Z6}function tY($,Y,X){if(!Y)return 9;let Z=Y.font,J=WY($,Z),K=J.get(X);if(K!==void 0)return K;let Q=Y.measureText(X).width;return J.set(X,Q),Q}function tq($){return $?.type==="code"?"pre-wrap":"normal"}function eq($,Y){if($.length===0)return[""];let X=$.split(`
|
|
27
|
+
`),Z=[];for(let J of X){if(J.length===0){Z.push("");continue}let K=J;while(K.length>Y){let Q=K.slice(0,Y),M=Q.lastIndexOf(" ");if(M<=0){Z.push(Q),K=K.slice(Y);continue}Z.push(Q.slice(0,M)),K=K.slice(M+1)}Z.push(K)}return Z}var E4=10,O2=8,C3=120;function eY($,Y,X,Z,J,K,Q,M,D,q){let U=Math.max(1,...K.rows.map((_)=>_.cells.length)),G=Math.max(C3,D.width-Q-D.paddingX)/U,N=$D(Z),A=M;for(let _=0;_<K.rows.length;_+=1){let z=YD(N.get(_)??[],J,K,G,E4,D.lineHeight,q),F=Math.max(D.lineHeight+O2*2,...z.map((B)=>B.measuredLines.reduce((W,S)=>W+S.height,0)+O2*2));for(let B of z){let W=Q+B.cellIndex*G,S=A+O2;for(let b of B.measuredLines){let k={blockId:B.container.blockId,boundaries:J6(J,B.container,b.start,b.end,b.text,B.font,G-E4*2,q),regionId:B.container.id,end:b.end,font:B.font,height:b.height,left:W+E4,start:b.start,text:b.text,top:S,width:b.width};$.push(k),L3(Y,k),S+=b.height}X.set(B.container.id,{bottom:A+F,left:W,right:W+G,top:A})}XD(Y,K.id,A,A+F),A+=F}return A}function $D($){let Y=new Map;for(let X of $){let Z=X.tableCellPosition;if(!Z)continue;let J=Y.get(Z.rowIndex)??[];J.push({cellIndex:Z.cellIndex,container:X}),Y.set(Z.rowIndex,J)}return Y}function YD($,Y,X,Z,J,K,Q){return[...$].sort((M,D)=>M.cellIndex-D.cellIndex).map(({cellIndex:M,container:D})=>{let q=j2(X),U=_1(X,K),V=w2(Y,D,q,X,Math.max(40,Z-J*2),U,Q);return{cellIndex:M,container:D,font:q,lineHeight:U,measuredLines:V}})}function XD($,Y,X,Z){let J=$.get(Y);$.set(Y,{bottom:J?Math.max(J.bottom,Z):Z,top:J?Math.min(J.top,X):X})}function Q6($){let Y=$.charWidth??e5.charWidth,X=$.lineHeight??e5.lineHeight,Z=Math.max(12,Math.floor($.width/Y)),J=$.text.split(`
|
|
28
|
+
`).reduce((K,Q)=>K+Math.max(1,Math.ceil(Q.length/Z)),0);return{estimatedHeight:J*X,lineCount:J,width:$.width}}function M6($,Y,X=k1(),Z=null){let J=Z??{images:new Map},K={...e5,...Y},Q=[],M=new Map,D=new Map($.regions.map((z)=>[z.id,{textLength:z.text.length}])),q=$.blockIndex,U=W4($.document.blocks),V=new Map,G=new Set($.regions.map((z)=>z.id)),N=K.paddingY,A=null;for(let z of $.blocks){let F=U.get(z.id)??null;if(!F||G1(F))continue;let B=r0(z),W=z.regionIds.filter((P)=>G.has(P));if(!B&&W.length===0)continue;if(A!==null){N+=$6(q,U,A,z.id,K.blockGap);let P=$.blockIndex.get(A);if(P&&!r0(P)){let y=V.get(A);if(y)y.bottom=Math.max(y.bottom,N)}}let S=z.depth,b=K.paddingX+S*K.indentWidth,k=Math.max(40,K.width-b-K.paddingX);if(B)N=ZD(V,z.id,N,K);else if(F.type==="table"){let P=W.map((y)=>$.regionIndex.get(y)).filter((y)=>y!==void 0);N=eY(Q,V,M,P,X,F,b,N,K,J)}else for(let P of W){let y=$.regionIndex.get(P);if(!y)continue;N=JD(Q,V,M,y,X,F,b,N,k,K,J)}A=z.id}let _=[];for(let z of $.blocks){let F=U.get(z.id);if(!F||G1(F))continue;let B=V.get(z.id);if(!B)continue;_.push({bottom:B.bottom,depth:z.depth,id:z.id,top:B.top,type:z.type})}return{blocks:_,regionBounds:M,regionLineIndices:KD(Q),regionMetrics:D,height:Math.max(N,K.paddingY),lines:Q,options:K,width:K.width}}function ZD($,Y,X,Z){let J=Z.lineHeight;return $.set(Y,{top:X,bottom:X+J}),X+J}function JD($,Y,X,Z,J,K,Q,M,D,q,U){let V=j2(K),G=_1(K,q.lineHeight),N=w2(J,Z,V,K,D,G,U),A=M;for(let _ of N){let z={blockId:Z.blockId,boundaries:J6(J,Z,_.start,_.end,_.text,V,D,U),regionId:Z.id,end:_.end,font:V,height:_.height,left:Q,start:_.start,text:_.text,top:A,width:_.width};$.push(z),L3(Y,z),QD(X,z),A+=_.height}return A}function KD($){let Y=[...$].sort((Z,J)=>Z.top-J.top||Z.left-J.left),X=new Map;$.length=0,$.push(...Y);for(let[Z,J]of $.entries()){let K=X.get(J.regionId)??[];K.push(Z),X.set(J.regionId,K)}return X}function QD($,Y){let X=$.get(Y.regionId),Z=Y.left+Y.width,J=Y.top+Y.height;$.set(Y.regionId,X?{bottom:Math.max(X.bottom,J),left:Math.min(X.left,Y.left),right:Math.max(X.right,Z),top:Math.min(X.top,Y.top)}:{bottom:J,left:Y.left,right:Z,top:Y.top})}function L3($,Y){let X=$.get(Y.blockId),Z=Y.top+Y.height;$.set(Y.blockId,{bottom:X?Math.max(X.bottom,Z):Z,top:X?Math.min(X.top,Y.top):Y.top})}function W4($){let Y=new Map,X=(Z)=>{for(let J of Z)if(Y.set(J.id,J),J.type==="blockquote"||J.type==="listItem")X(J.children);else if(J.type==="list")X(J.items)};return X($),Y}var q6=null;function MD($){let Y=/(\d+(?:\.\d+)?)\s*px/.exec($);return Y?Number.parseFloat(Y[1]):16}function H1($){q6??=new Map;let Y=q6.get($);if(Y)return Y;let X=YX(),Z=Math.max(12,Math.round(MD($)));if(!X){let G={ascent:Math.round(Z*0.8),descent:Math.max(2,Z-Math.round(Z*0.8)),emHeight:Z};return q6.set($,G),G}X.font=$;let J=X.measureText("Hg"),K=Math.round(J.actualBoundingBoxAscent||0),Q=Math.round(J.actualBoundingBoxDescent||0),M=K+Q,D=Math.max(Z,M),q=M>0?K:Math.round(D*0.8),U=M>0?Q:Math.max(2,D-q),V={ascent:q,descent:U,emHeight:D};return q6.set($,V),V}function P4($,Y){let{emHeight:X}=H1(Y);return Math.max(0,Math.floor(($-X)/2))}function y4($,Y){let{ascent:X}=H1(Y);return P4($,Y)+X}var D6;function $X($,Y){let X=YX();if(!X||$.length===0)return 0;return X.font=Y,X.measureText($).width}function YX(){if(D6!==void 0)return D6;return D6=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,D6}function R3($,Y){let X=0,Z=$.lines.length-1;while(X<=Z){let J=X+Z>>1,K=$.lines[J];if(Y<K.top){Z=J-1;continue}if(Y>=K.top+K.height){X=J+1;continue}return{index:J,line:K}}return null}function U6($,Y){let X=[...$.regionBounds.entries()].find(([,K])=>{return Y.x>=K.left&&Y.x<=K.right&&Y.y>=K.top&&Y.y<=K.bottom});if(X)return T4($,X[0],Y.y);let Z=R3($,Y.y);if(!Z)return null;let J=qD($,Y.y,Z.index);if(J.length===1)return J[0]??null;return J.find((K)=>{let Q=$.regionBounds.get(K.line.regionId);return Q?Y.x>=Q.left&&Y.x<=Q.right:!1})??[...J].sort((K,Q)=>{let M=$.regionBounds.get(K.line.regionId),D=$.regionBounds.get(Q.line.regionId),q=ZX(Y.x,M),U=ZX(Y.x,D);return q-U})[0]??null}function G6($,Y,X){if($.blocks.length===0)return{endIndex:0,startIndex:0};let Z=Y+X,J=XX($,Y),K=XX($,Z);if(J>0){if($.blocks[J-1].bottom>Y)J-=1}if(K<$.blocks.length){if($.blocks[K].top<Z)K+=1}return{endIndex:K,startIndex:J}}function XX($,Y){let X=0,Z=$.blocks.length;while(X<Z){let J=X+Z>>1;if($.blocks[J].bottom<=Y)X=J+1;else Z=J}return X}function V6($,Y,X){if($.lines.length===0)return{endIndex:0,startIndex:0};let Z=Y+X,J=JX($,Y),K=JX($,Z);if(J>0){let Q=$.lines[J-1];if(Q.top+Q.height>Y)J-=1}if(K<$.lines.length){if($.lines[K].top<Z)K+=1}return{endIndex:K,startIndex:J}}function C0($,Y,X){return B2($,Y,X)?.line??null}function T4($,Y,X){let Z=$.regionLineIndices.get(Y);if(!Z||Z.length===0)return null;let J=Z[0],K=Number.POSITIVE_INFINITY;for(let Q of Z){let M=$.lines[Q],D=X<M.top?M.top-X:X>M.top+M.height?X-(M.top+M.height):0;if(D<K)K=D,J=Q;if(D===0)break}return{index:J,line:$.lines[J]}}function B2($,Y,X){let Z=$.regionLineIndices.get(Y);if(!Z||Z.length===0)return null;let J=0,K=Z.length-1;while(J<=K){let U=J+K>>1,V=Z[U],G=$.lines[V];if(X<G.start){K=U-1;continue}if(X>G.end){J=U+1;continue}return{index:V,line:G}}let Q=Z[0],M=Z[Z.length-1],D=$.lines[Q],q=$.lines[M];if(X<=D.start)return{index:Q,line:D};if(X>=q.end)return{index:M,line:q};return null}function qD($,Y,X){let Z=[];for(let J=X;J>=0;J-=1){let K=$.lines[J];if(Y<K.top||Y>=K.top+K.height)break;Z.unshift({index:J,line:K})}for(let J=X+1;J<$.lines.length;J+=1){let K=$.lines[J];if(Y<K.top||Y>=K.top+K.height)break;Z.push({index:J,line:K})}return Z}function ZX($,Y){if(!Y)return Number.POSITIVE_INFINITY;if($<Y.left)return Y.left-$;if($>Y.right)return $-Y.right;return 0}function G0($,Y){return $.left+DD($.boundaries,Y)}function DD($,Y){for(let Z of $)if(Z.offset===Y)return Z.left;return $.filter((Z)=>Z.offset<=Y).at(-1)?.left??0}function JX($,Y){let X=0,Z=$.lines.length;while(X<Z){let J=X+Z>>1,K=$.lines[J];if(K.top+K.height<=Y)X=J+1;else Z=J}return X}function b3($,Y){if($.length===0)return 0;for(let X=1;X<$.length;X+=1){let Z=$[X-1],J=$[X],K=Z.left+(J.left-Z.left)/2;if(Y<=K)return Z.offset;if(Y<=J.left)return J.offset}return $.at(-1)?.offset??0}var UD=18,GD=14,VD=22;function X1($,Y,X){return G0(Y,X)+T0($,Y)}function T0($,Y){let X=Z1($,Y.blockId,"listItem");if(!X)return 0;return g1($,X.id)?.kind==="task"?VD:UD}function u1($){return{left:$.left,size:GD,top:$.top+3}}function Z1($,Y,X){let Z=$.documentIndex.blockIndex.get(Y)??null;while(Z){if(Z.type===X)return Z;let J=Z.parentBlockId;Z=J?$.documentIndex.blockIndex.get(J)??null:null}return null}function g1($,Y){return $.documentIndex.listItemMarkers.get(Y)??null}function v0($,Y,X){if(!$.regionMetrics.get(X.regionId))return null;let J=C0($,X.regionId,X.offset);if(!J)return null;return{blockId:J.blockId,regionId:J.regionId,height:J.height,left:G0(J,X.offset-J.start),offset:X.offset,top:J.top}}function m0($,Y,X){let Z=C0(Y,X.regionId,X.offset);if(!Z)return X.left;return X.left+T0($,Z)+ND($,Z,X.offset)}function ND($,Y,X){if(X<=Y.end)return 0;let Z=$.documentIndex.regionIndex.get(Y.regionId);if(!Z)return 0;let J=Z.text.slice(Y.end,X);if(!/^[ \t]+$/u.test(J))return 0;return $X(J,Y.font)}function j0($,Y,X){let Z=AD($,Y,X);if(!Z)return null;let J=Z.snapToLineStart?Z.line.left:X.x;return KX($,Y,Z.line,J)}function N6($,Y,X){let Z=$.lines[$.lines.length-1];if(!Z||X.y<=Z.top+Z.height)return null;return KX($,Y,Z,X.x)}function A6($,Y,X,Z){let J=QX(Y,Z.regionId);if(!J)return null;let K=j0($,Y,X);if(K)return{regionId:K.regionId,offset:K.offset};let Q=X.y<_D($);return{regionId:Z.regionId,offset:Q?0:J.text.length}}function _6($,Y,X){let Z=j0($,Y,X);if(!Z)return null;let J=QX(Y,Z.regionId);if(!J||J.text.length===0)return null;let K=Z.offset<J.text.length&&/\w/.test(J.text[Z.offset]??"")?Z.offset:Z.offset>0&&/\w/.test(J.text[Z.offset-1]??"")?Z.offset-1:Z.offset,Q=HD(J.text,K);if(Q.start===Q.end)return null;return{anchor:{regionId:Z.regionId,offset:Q.start},focus:{regionId:Z.regionId,offset:Q.end}}}function KX($,Y,X,Z){let J=$.regionMetrics.get(X.regionId);if(!J)return null;let K=Math.max(0,Z-T0(Y,X)-X.left),Q=b3(X.boundaries,K),M=Math.min(J.textLength,X.start+Q);return{regionId:X.regionId,offset:M,left:G0(X,Q),top:X.top,height:X.height}}function AD($,Y,X){for(let[J,K]of $.regionBounds)if(X.x>=K.left&&X.x<=K.right&&X.y>=K.top&&X.y<=K.bottom){let Q=T4($,J,X.y)?.line??null;return Q?{line:Q}:null}let Z=U6($,X)?.line??null;if(Z)return{line:Z};for(let J of $.blocks){if(X.y<J.top||X.y>J.bottom)continue;for(let Q=$.lines.length-1;Q>=0;Q--)if($.lines[Q].blockId===J.id)return{line:$.lines[Q]};let K=Y.documentIndex.blockIndex.get(J.id);if(K&&r0(K)){let Q=t2(Y.documentIndex,J.id);if(Q){let M=$.lines.find((D)=>D.blockId===Q.id);if(M)return{line:M,snapToLineStart:!0}}}}return null}function QX($,Y){return $.documentIndex.regionIndex.get(Y)??null}function _D($){return $.lines[0]?.top??0}function HD($,Y){let X=Y,Z=Y;while(X>0&&/\w/.test($[X-1]??""))X-=1;while(Z<$.length&&/\w/.test($[Z]??""))Z+=1;return{end:Z,start:X}}function S3($,Y,X){let Z=zD($,X);if(!Z||Z.start!==0)return null;let J=Z1(Y,Z.blockId,"listItem");if(!J)return null;if(g1(Y,J.id)?.kind!=="task")return null;let Q=u1(Z),M=Q.left-4,D=Q.left+Q.size+4,q=Q.top-4,U=Q.top+Q.size+4;return X.x>=M&&X.x<=D&&X.y>=q&&X.y<=U?{listItemId:J.id}:null}function v3($,Y,X){let Z=j0($,Y,X);if(!Z)return null;let J=FD(Y,Z.regionId);if(!J)return null;let K=J.inlines.find((M)=>M.link&&Z.offset>=M.start&&Z.offset<M.end);if(!K?.link)return null;let Q=f3($,Y,Z.regionId,K.start);if(!Q)return null;return{anchorBottom:Q.anchorBottom,anchorLeft:Q.anchorLeft,endOffset:K.end,regionId:Z.regionId,startOffset:K.start,title:K.link.title,url:K.link.url}}function H6($,Y,X,Z){let J=S3($,Y,X);if(J)return{kind:"task-toggle",listItemId:J.listItemId};let K=j0($,Y,X);if(!K)return null;let Q=MX(K.regionId,K.offset,Z),M=Q!==null?qX(Q,$,Y,Z):null,D=v3($,Y,X);if(D)return{anchorBottom:M?.anchorBottom??D.anchorBottom,anchorLeft:M?.anchorLeft??D.anchorLeft,endOffset:D.endOffset,kind:"link",commentThreadIndex:Q,regionId:D.regionId,startOffset:D.startOffset,title:D.title,url:D.url};return{anchorBottom:M?.anchorBottom??K.top+K.height,anchorLeft:M?.anchorLeft??K.left,kind:"text",commentThreadIndex:Q}}function z6($,Y,X,Z){let J=Y.documentIndex.regionIndex.get(X.regionId);if(!J)return null;let K=MX(X.regionId,X.offset,Z),Q=K!==null?qX(K,$,Y,Z):null,M=J.inlines.find((D)=>X.offset>=D.start&&X.offset<=D.end)??null;if(M?.link){let D=f3($,Y,X.regionId,M.start);if(!D)return null;return{anchorBottom:Q?.anchorBottom??D.anchorBottom,anchorLeft:Q?.anchorLeft??D.anchorLeft,commentThreadIndex:K,endOffset:M.end,kind:"link",regionId:X.regionId,startOffset:M.start,title:M.link.title,url:M.link.url}}if(Q)return{anchorBottom:Q.anchorBottom,anchorLeft:Q.anchorLeft,commentThreadIndex:K,kind:"text"};return null}function j4($,Y,X,Z){let J=$.documentIndex.regionIndex.get($.selection.anchor.regionId);if(!Z.image||!J)return null;let K=C0(Y.layout,J.id,Z.start);if(!K)return null;let Q=K.left+T0($,K),M=Q+G0(K,Z.start-K.start)-K.left,D=Q+G0(K,Z.end-K.start)-K.left,{height:q}=F4(Z,X,K.width),U=K.top+Math.max(0,Math.floor((K.height-q)/2));return{left:M,top:U,width:D-M,height:q}}function MX($,Y,X){for(let Z of X)if(Z.regionId===$&&Y>=Z.startOffset&&Y<=Z.endOffset)return Z.threadIndex;return null}function qX($,Y,X,Z){let J=Z.find((K)=>K.threadIndex===$);if(!J)return null;return f3(Y,X,J.regionId,J.startOffset)}function f3($,Y,X,Z){let J=C0($,X,Z);if(!J)return null;return{anchorBottom:J.top+J.height,anchorLeft:G0(J,Z)+T0(Y,J)}}function zD($,Y){return $.lines.find((X)=>Y.y>=X.top-4&&Y.y<=X.top+X.height+4)??$.lines.filter((X)=>Math.abs(Y.y-(X.top+X.height/2))<=10).sort((X,Z)=>Math.abs(Y.y-(X.top+X.height/2))-Math.abs(Y.y-(Z.top+Z.height/2)))[0]??null}function FD($,Y){return $.documentIndex.regionIndex.get(Y)??null}function DX($,Y,X,Z,J,K){let Q=m3(Y,J,K),M=$.measuredContainerHeights.get(Q);if(M!==void 0)return M;let D=J.paddingX??0,q=J.indentWidth??24,U=_1(X,J.lineHeight??24),V=D+Z*q,G=Math.max(40,J.width-V-D);if(Y.inlines.some((_)=>_.kind==="image")){let _=j2(X);return w2($,Y,_,X,G,U,K).reduce((z,F)=>z+F.height,0)}let N=Q6({charWidth:J.charWidth,lineHeight:U,text:Y.text,width:G});return Math.max(U,N.lineCount*U)}function UX($,Y,X,Z){let J=Q6({charWidth:Z,lineHeight:X,text:$.text,width:Y});return Math.max(X,J.lineCount*X)}function m3($,Y,X){return`${K6($,X)}:${Y.width}:${Y.paddingX??0}:${Y.indentWidth??24}:${Y.lineHeight??24}`}function h3($,Y){let X=0,Z=$.entries.length;while(X<Z){let J=X+Z>>1;if($.entries[J].bottom<=Y)X=J+1;else Z=J}return X}function GX($,Y,X,Z,J){let K=Z,Q=J;for(let M=Z;M<J;M+=1){let D=$.regions[M],q=Y.get(D.blockId);if(!q)continue;if(q.type==="table"){let U=X.get(q.regionIds[0]??""),V=X.get(q.regionIds[q.regionIds.length-1]??"");if(U!==void 0)K=Math.min(K,U);if(V!==void 0)Q=Math.max(Q,V+1)}}return{endIndex:Q,startIndex:K}}function VX($,Y,X){return{...$,blocks:$.blocks.map((Z)=>({...Z,bottom:Z.bottom+Y,top:Z.top+Y})),regionBounds:new Map([...$.regionBounds.entries()].map(([Z,J])=>[Z,{bottom:J.bottom+Y,left:J.left,right:J.right,top:J.top+Y}])),height:X,lines:$.lines.map((Z)=>({...Z,top:Z.top+Y}))}}function NX($,Y,X,Z,J){for(let[K,Q]of X.regionBounds){let M=Q.bottom-Q.top,D=Y.regionIndex.get(K);EY($,m3(D??{path:K,inlines:[],text:""},Z,J),M)}}function k3($,Y,X,Z=[],J=k1(),K=null){let Q=K??{images:new Map},M=W4($.document.blocks),D=$.blockIndex,q=new Set(Z),U=Math.max(0,X.top-X.overscan),V=X.top+X.height+X.overscan,G=WD(J,$,M,D,Y,Q),N=h3(G,U),A=h3(G,V);if(N>0){let W=G.entries[N-1];if(W&&W.bottom>U)N-=1}if(A<G.entries.length){let W=G.entries[A];if(W&&W.top<V)A+=1}for(let W of q){let S=G.containerIndices.get(W);if(S===void 0)continue;N=Math.min(N,S),A=Math.max(A,S+1)}if(!Number.isFinite(N)||!Number.isFinite(A))return{estimateRegionBounds:G.estimateRegionBounds,layout:M6({...$,regions:[]},Y,J,Q),totalHeight:G.totalHeight,viewport:X};let _=GX($,D,G.containerIndices,N,A),z=G.entries[_.startIndex]?.top??Y.paddingY??0,F=M6({...$,regions:$.regions.slice(_.startIndex,_.endIndex)},Y,J,Q),B=VX(F,z,G.totalHeight);return NX(J,$,B,Y,Q),{estimateRegionBounds:G.estimateRegionBounds,layout:B,totalHeight:G.totalHeight,viewport:X}}function WD($,Y,X,Z,J,K){let Q=TD(Y,J,K),M=PY($,Y,Q);if(M)return M;let D=J.blockGap??16,q=J.lineHeight??24,U=J.paddingY??0,V=[],G=new Map,N=0,A=null;for(let _ of Y.blocks){let z=X.get(_.id)??null;if(!z||G1(z))continue;let F=r0(_);if(!F&&_.regionIds.length===0)continue;if(A!==null)U+=$6(Z,X,A,_.id,D);if(F)U+=q;else if(z.type==="table"){let B=PD({block:z,containerIndices:G,entries:V,index:N,options:J,runtimeBlocks:Z,totalHeight:U,regions:Y.regions});if(B)N=B.nextIndex,U=B.totalHeight}else for(let B of _.regionIds){let W=Y.regions[N];if(!W){N+=1;continue}let S=DX($,W,z,_.depth,J,K),b=U,k=b+S;V[N]={bottom:k,top:b},G.set(W.id,N),U=k,N+=1}A=_.id}return yY($,Y,Q,{containerIndices:G,entries:V,estimateRegionBounds(_){let z=G.get(_);return z===void 0?null:V[z]??null},totalHeight:U})}function PD({block:$,containerIndices:Y,entries:X,index:Z,options:J,runtimeBlocks:K,totalHeight:Q,regions:M}){let D=K.get($.id),q=D?.regionIds??[];if(q.length===0)return null;let U=M.slice(Z,Z+q.length);if(U.length===0||U[0]?.blockId!==$.id)return null;let V=J.paddingX??0,G=J.indentWidth??24,N=D?.depth??0,A=V+N*G,_=Math.max(C3,J.width-A-V),z=Math.max(1,...$.rows.map((k)=>k.cells.length)),F=_/z,B=Math.max(40,F-E4*2),W=_1($,J.lineHeight??24),S=yD(U,Z),b=Q;for(let k=0;k<$.rows.length;k+=1){let P=S.get(k)??[],y=Math.max(W+O2*2,...P.map(({region:w})=>UX(w,B,W,J.charWidth)+O2*2)),E=b+y;for(let{index:w,region:C}of P)X[w]={bottom:E,top:b},Y.set(C.id,w);b=E}for(let k=Z;k<Z+U.length;k+=1){let P=M[k];if(!P||X[k])continue;X[k]={bottom:b,top:b},Y.set(P.id,k)}return{nextIndex:Z+U.length,totalHeight:b}}function yD($,Y){let X=new Map;for(let[Z,J]of $.entries()){let K=J.tableCellPosition?.rowIndex;if(K===void 0)continue;let Q=X.get(K)??[];Q.push({index:Y+Z,region:J}),X.set(K,Q)}return X}function TD($,Y,X){return[Y.width,Y.paddingX??0,Y.paddingY??0,Y.indentWidth??24,Y.lineHeight??24,Y.blockGap??16,jD($,X)].join(":")}function jD($,Y){if($.imageUrls.size===0)return"";return $.regions.flatMap((X)=>X.inlines.filter((Z)=>Z.kind==="image"&&Z.image).map((Z)=>{let J=Z.image?Y.images.get(Z.image.url):null;return`${Z.image?.url??""}:${Z.image?.width??0}:${J?.status??"loading"}:${J?.intrinsicWidth??0}:${J?.intrinsicHeight??0}`})).join("|")}function u3($,Y,X,Z=null){let J={height:Y.height,overscan:Math.max(160,Y.height),top:Y.top},K=k3($.documentIndex,Y,J,[$.selection.anchor.regionId,$.selection.focus.regionId],X,Z);return{blockMap:W4($.documentIndex.document.blocks),estimateRegionBounds:K.estimateRegionBounds,regionBounds:new Map(K.layout.regionBounds),layout:K.layout,paintHeight:Math.max(240,J.height+J.overscan*2),paintTop:Math.max(0,J.top-J.overscan),totalHeight:K.totalHeight,viewport:{height:J.height,top:J.top}}}function F6($,Y,X){return j0(Y.layout,$,X)??N6(Y.layout,$,X)}function w4($,Y,X,Z){return A6(Y.layout,$,X,Z)}function g3($,Y,X){return _6(Y.layout,$,X)}function I3($,Y,X,Z){return H6(Y.layout,$,X,Z)}function p3($,Y,X,Z){return z6(Y.layout,$,X,Z)}function x3($,Y,X){return v0(Y.layout,$.documentIndex,X)}function J1($,Y,X){let Z=v0(Y.layout,$.documentIndex,X);if(!Z)return null;return{...Z,left:m0($,Y.layout,Z)}}var AX=1;function _X($,Y,X){let Z=$.documentIndex.regionOrderIndex.get($.selection.focus.regionId);if(Z===void 0)return $;let J=$.documentIndex.regions[Z],K=$.selection.focus.offset+Y;if(K>=0&&K<=J.text.length)return y0($,J.id,K,X);if(Y<0){let M=f1($.documentIndex,J.id);if(!M)return $;return y0($,M.id,M.text.length,X)}let Q=n2($.documentIndex,J.id);if(!Q)return $;return y0($,Q.id,0,X)}function HX($,Y,X,Z,J){let K=B2(Y,X.regionId,X.offset);if(!K)return $;let Q=Y.lines[K.index+Z];if(!Q)return $;let M=j0(Y,$,{x:m0($,Y,X)+AX,y:Q.top+Q.height/2});if(!M)return $;return y0($,M.regionId,M.offset,J)}function zX($,Y,X,Z){let J=EX($,Y);if(!J)return $;return y0($,J.regionId,X==="Home"?J.start:J.end,Z)}function FX($,Y,X,Z,J){let K=EX($,Y);if(!K)return $;let M=Math.max(1,Math.floor(480/Y.options.lineHeight)),D=B2(Y,K.regionId,$.selection.focus.offset),q=D?Y.lines[D.index+Z*M]:null;if(!q)return $;let U=j0(Y,$,{x:m0($,Y,X)+AX,y:q.top+q.height/2});if(!U)return $;return y0($,U.regionId,U.offset,J)}function EX($,Y){return C0(Y,$.selection.focus.regionId,$.selection.focus.offset)}var wD=1;function WX($,Y,X,Z,J){let K=$.documentIndex.regionIndex.get($.selection.focus.regionId)??null;if(!K)return null;let Q=$.documentIndex.tableCellIndex.get(K.id)??null,M=$.documentIndex.blockIndex.get(K.blockId)??null;if(!Q||M?.type!=="table")return null;let D=OD($,M.id,Q.rowIndex+Z,Q.cellIndex)??BD($,M.id,Z);if(!D)return $;let q=Y.regionBounds.get(K.id),U=Y.regionBounds.get(D.id);if(!q||!U)return $;let V=U.top+CD(X.top+X.height/2-q.top,0,Math.max(0,U.bottom-U.top-1)),G=j0(Y,$,{x:m0($,Y,X)+wD,y:V});if(!G)return $;return y0($,G.regionId,G.offset,J)}function OD($,Y,X,Z){return V2($.documentIndex,Y,X,Z)}function BD($,Y,X){let Z=$.documentIndex.blockIndex.get(Y),J=$.documentIndex.regions,K=Z?$.documentIndex.roots[Z.rootIndex]?.regionRange:void 0;if(!K)return null;return X<0?J[K.start-1]??null:J[K.end]??null}function CD($,Y,X){return Math.max(Y,Math.min(X,$))}function l3($,Y,X=!1){return _X($,Y,X)}function d3($,Y,X,Z=!1){return LD($,Y,X,Z)}function c3($,Y,X,Z=!1){return RD($,Y,X,Z)}function a3($,Y,X,Z=!1){return zX($,Y,X,Z)}function r3($,Y,X=!1){return bD($,Y,X)}function LD($,Y,X,Z){let J=PX($,Y);if(!J)return $;return WX($,Y,J,X,Z)??HX($,Y,J,X,Z)}function RD($,Y,X,Z){let J=PX($,Y);if(!J)return $;return FX($,Y,J,X,Z)}function bD($,Y,X){let Z=$.documentIndex.regions,J=Y==="start"?Z[0]:Z.at(-1);if(!J)return $;return y0($,J.id,Y==="start"?0:J.text.length,X)}function PX($,Y){return v0(Y,$.documentIndex,{regionId:$.selection.focus.regionId,offset:$.selection.focus.offset})}var SD=80;function TX({context:$,containerBounds:Y,isHeaderRow:X,lineHeight:Z,theme:J}){let K=wX(Y,Z);$.fillStyle=X?J.tableHeaderBackground:J.tableBodyBackground,$.fillRect(K.left,K.top,K.width,K.height),OX($,K,J)}function jX({activeBlockFlashes:$,activeBlockId:Y,activeRegionId:X,context:Z,editorState:J,endIndex:K,layout:Q,regionBounds:M,startIndex:D,theme:q,verticalBleed:U}){if(!Y||!X)return;let V=J.documentIndex.blockIndex.get(Y)??null;if(V?.type!=="table")return;if((J.documentIndex.regionIndex.get(X)??null)?.blockId!==Y)return;let N=M.get(X)??null,A=Q.regionLineIndices.get(X)??null;if(!N||!A||A.length===0)return;let _=Q.lines[A[0]]??null;if(!_)return;let z=wX(N,_.height);if(z.width===0)return;let F=yX({context:Z,endIndex:K,fillStyle:q.activeBlockBackground,layout:Q,left:z.left,lineIndices:A,startIndex:D,verticalBleed:U,width:z.width}),B=V.path?$.get(V.path)??null:null;if(B)yX({context:Z,endIndex:K,fillStyle:f5(q.activeBlockFlash,B),layout:Q,left:z.left,lineIndices:A,startIndex:D,verticalBleed:U,width:z.width});if(!F)return;OX(Z,z,q)}function yX({context:$,endIndex:Y,fillStyle:X,layout:Z,left:J,lineIndices:K,startIndex:Q,verticalBleed:M,width:D}){$.fillStyle=X;let q=!1;for(let U of K){if(U<Q)continue;if(U>=Y)break;let V=Z.lines[U];$.fillRect(J,V.top-M,D,V.height),q=!0}return q}function wX($,Y){return{height:Math.max($.bottom-$.top,Y),left:$.left,top:$.top,width:Math.max($.right-$.left,SD)}}function OX($,Y,X){$.strokeStyle=X.tableBorder,$.strokeRect(Y.left,Y.top,Y.width,Y.height)}var E6=2,vD=3,fD=12,mD=6,hD=3,kD=8,uD=12,gD=28,ID=4,BX=1,pD=5,xD=2,lD=1;function CX($,Y,X,Z,J,K,Q){if(!Z||Y.start!==0)return;if(X?.type==="code"){let M=Math.max(0,Y.left-uD);$.fillStyle=K.codeBackground,$.fillRect(M,Z.top-ID,Math.max(Z.right-Y.left+gD,Q-M),Z.bottom-Z.top+kD);return}if(X?.type!=="table")return;TX({context:$,containerBounds:Z,isHeaderRow:J?.rowIndex===0,lineHeight:Y.height,theme:K})}function LX($,Y,X,Z,J,K,Q,M){if(Y.blockId!==J||X?.type==="table")return;let D=Z?K.get(Z)??null:null;if($.fillStyle=Q.activeBlockBackground,$.fillRect(0,Y.top-E6,M,Y.height),!D)return;$.fillStyle=f5(Q.activeBlockFlash,D),$.fillRect(0,Y.top-E6,M,Y.height)}function RX($,Y,X,Z,J,K){let Q=new Map;for(let M=Z;M<J;M+=1){let D=$.lines[M],q=X.get(D.blockId);if(q?.type!=="heading"||q.depth!==1&&q.depth!==2)continue;let U=Q.get(q.id),V={bottom:D.top+D.height,left:D.left+T0(Y,D),right:K-$.options.paddingX};Q.set(q.id,U?{bottom:Math.max(U.bottom,V.bottom),left:U.left,right:U.right}:V)}return Q}function bX($,Y,X,Z,J,K){for(let Q=X;Q<Z;Q+=1){let M=Y.blocks[Q];if(M.type==="divider"){let D=Y.options.paddingX+M.depth*Y.options.indentWidth,q=K-Y.options.paddingX,U=Math.round(M.top+(M.bottom-M.top-BX)/2);vX($,{color:J.dividerRule??J.headingRule,left:D,right:q,thickness:BX,top:U})}}}function SX($,Y,X){for(let Z of Y.values())vX($,{color:X.headingRule,left:Z.left,minimumWidth:xD,right:Z.right,thickness:lD,top:Z.bottom+pD})}function vX($,Y){$.fillStyle=Y.color,$.fillRect(Y.left,Y.top,Math.max(Y.minimumWidth??0,Y.right-Y.left),Y.thickness)}function fX($,Y,X,Z,J){let K=new Map;for(let Q=Z;Q<J;Q+=1){let M=$.lines[Q],D=Z1(Y,M.blockId,"blockquote");if(!D)continue;let q=K.get(D.id),U={bottom:M.top+M.height,isActive:M.blockId===X,left:$.options.paddingX+(D.depth+1)*$.options.indentWidth-10,top:M.top};K.set(D.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 K}function mX($,Y,X){for(let Z of Y.values())$.fillStyle=Z.isActive?X.blockquoteRuleActive:X.blockquoteRule,$.fillRect(Z.left,Z.top+vD,hD,Math.max(fD,Z.bottom-Z.top-mD))}var dD=1,cD=2,aD=2;function s3({context:$,devicePixelRatio:Y,editorState:X,height:Z,layout:J,normalizedSelection:K,presence:Q,showCaret:M,theme:D,viewportTop:q,width:U}){$.save(),$.scale(Y,Y),$.clearRect(0,0,U,Z);let V=K.start.regionId===K.end.regionId&&K.start.offset!==K.end.offset,G=M&&!V;if($.translate(0,-q),G)hX($,X,J,{color:D.caret,offset:X.selection.focus.offset,regionId:X.selection.focus.regionId});if(Q)for(let N of Q){if(!N.cursorPoint)continue;hX($,X,J,{color:N.color??D.leafAccent,offset:N.cursorPoint.offset,regionId:N.cursorPoint.regionId})}$.restore()}function hX($,Y,X,Z){let J=v0(X,Y.documentIndex,{regionId:Z.regionId,offset:Z.offset});if(!J)return;let K=m0(Y,X,J),Q=rD(X,J);$.fillStyle=Z.color,$.fillRect(K,Q.top,cD,Q.height)}function rD($,Y){let X=C0($,Y.regionId,Y.offset),Z=X?.font??'16px "Iowan Old Style", "Palatino Linotype", serif',{ascent:J,descent:K}=H1(Z),Q=Math.max(1,J+K),M=Math.min(Y.height-aD,Q),D=X?Math.max(X.top,X.top+P4(X.height,Z)-dD):Y.top+Math.max(0,Math.floor((Y.height-M)/2));return{height:M,top:D}}var kX=2,uX=8,sD=3,iD=1.5,oD=2,C2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function gX($,Y,X,Z,J,K,Q=null){if(!X||Y.start!==0)return;if(Q){let M=m7(Q),D=YU(X,Y,Z,J,$);$.save(),$.translate(D.x,D.y),$.scale(M,M),$.translate(-D.x,-D.y)}if(X.kind==="task")nD($,Y,X.checked,K,Q);else if($.fillStyle=Q?X4(K.listMarkerText,Q,K):K.listMarkerText,X.kind==="ordered")$U($,X.label,Z,J);else $.fillText(X.label,Y.left-kX,J);if(Q)$.restore()}function nD($,Y,X,Z,J=null){let K=u1(Y);if(tD($,K,X,Z,J),!X)return;eD($,K,Z,J)}function tD($,Y,X,Z,J=null){let K=X?Z.checkboxCheckedFill:Z.checkboxUncheckedFill,Q=X?Z.checkboxCheckedStroke:Z.checkboxUncheckedStroke;$.fillStyle=J?X4(K,J,Z):K,$.strokeStyle=J?X4(Q,J,Z):Q,$.beginPath(),$.lineWidth=iD,$.roundRect(Y.left,Y.top,Y.size,Y.size,sD),$.fill(),$.stroke()}function eD($,Y,X,Z=null){$.strokeStyle=Z?X4(X.checkboxCheckmark,Z,X):X.checkboxCheckmark,$.lineWidth=oD,$.beginPath(),$.moveTo(Y.left+C2.start.x,Y.top+C2.start.y),$.lineTo(Y.left+C2.elbow.x,Y.top+C2.elbow.y),$.lineTo(Y.left+C2.end.x,Y.top+C2.end.y),$.stroke()}function $U($,Y,X,Z){let J=$.textAlign;$.textAlign="right",$.fillText(Y,X-uX,Z),$.textAlign=J}function YU($,Y,X,Z,J){if($.kind==="task"){let M=u1(Y);return{x:M.left+M.size/2,y:M.top+M.size/2}}let K=J.measureText($.label),Q=Z-(K.actualBoundingBoxAscent-K.actualBoundingBoxDescent)/2;if($.kind==="ordered")return{x:X-uX-K.width/2,y:Q};return{x:Y.left-kX+K.width/2,y:Q}}var XU=2,ZU=1,JU=2,KU=5,QU=2,MU=3;function IX($,Y){let X=$.documentIndex.regionOrderIndex,Z=X.get(Y.start.regionId),J=X.get(Y.end.regionId);return Z===void 0||J===void 0?null:{end:J,start:Z}}function pX($,Y,X,Z,J,K){if(!J)return;let Q=Y.documentIndex.regionOrderIndex.get(X.regionId);if(Q===void 0||Q<J.start||Q>J.end)return;let M=Q===J.start?Math.max(X.start,Z.start.offset):X.start,D=Q===J.end?Math.min(X.end,Z.end.offset):X.end;if(D<=M)return;$.fillStyle=K.selectionBackground,$.fillRect(X1(Y,X,M-X.start),X.top+ZU,Math.max(XU,X1(Y,X,D-X.start)-X1(Y,X,M-X.start)),X.height-JU)}function xX($,Y,X,Z,J,K){for(let Q of Z){if(Q.regionId!==X.regionId)continue;let M=Math.max(Q.startOffset,X.start),D=Math.min(Q.endOffset,X.end);if(D<=M)continue;$.fillStyle=qU(Q,J,K),$.fillRect(X1(Y,X,M-X.start),X.top+X.height-KU,Math.max(QU,X1(Y,X,D-X.start)-X1(Y,X,M-X.start)),MU)}}function qU($,Y,X){if($.resolved)return $.threadIndex===Y?X.commentHighlightResolvedActive:X.commentHighlightResolved;return $.threadIndex===Y?X.commentHighlightActive:X.commentHighlight}function dX($,Y,X,Z,J,K,Q){let M=X.image?Z.images.get(X.image.url):null,D=GU(X,Z,Q),q=VU(Y,K,Q,D);if($.fillStyle=J.imageSurfaceBackground,$.fillRect(q.left,q.top,q.width,q.height),M?.status==="loaded"&&M.source)$.drawImage(M.source,q.left,q.top,q.width,q.height);else DU($,J,{...q,status:M?.status==="error"?"error":"loading"});$.strokeStyle=J.imageSurfaceBorder,$.strokeRect(q.left,q.top,q.width,q.height)}function DU($,Y,X){let Z=X.status==="loading"?"Loading image":"Image unavailable",J=NU(X),K=X.top+X.height/2+J.size*0.9;if($.save(),$.beginPath(),$.rect(X.left,X.top,X.width,X.height),$.clip(),X.status==="loading")UU($,Y,X);$.strokeStyle=Y.imagePlaceholderIcon,$.lineWidth=1.5,$.strokeRect(J.left,J.top,J.size,J.size),$.beginPath(),$.arc(J.left+J.size*0.28,J.top+J.size*0.3,J.size*0.1,0,Math.PI*2),$.moveTo(J.left+J.size*0.12,J.top+J.size*0.82),$.lineTo(J.left+J.size*0.42,J.top+J.size*0.5),$.lineTo(J.left+J.size*0.58,J.top+J.size*0.66),$.lineTo(J.left+J.size*0.78,J.top+J.size*0.38),$.lineTo(J.left+J.size*0.88,J.top+J.size*0.82),$.stroke(),$.font='500 12px "Iowan Old Style", "Palatino Linotype", serif',$.fillStyle=Y.imagePlaceholderText,$.textAlign="center",$.textBaseline="middle",$.fillText(Z,X.left+X.width/2,K),$.restore()}function UU($,Y,X){let Z=Math.max(48,Math.round(X.width*0.22)),J=X.width+Z*2,K=performance.now()%1800/1800,Q=X.left-Z+J*K,M=$.createLinearGradient(Q,X.top,Q+Z,X.top);M.addColorStop(0,"rgba(255,255,255,0)"),M.addColorStop(0.5,Y.imageLoadingOverlay),M.addColorStop(1,"rgba(255,255,255,0)"),$.fillStyle=M,$.fillRect(X.left,X.top,X.width,X.height)}function GU($,Y,X){if(!$.image)return lX(X);let Z=Y.images.get($.image.url);if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return lX(X);return Math.max(48,Math.round(X*(Z.intrinsicHeight/Z.intrinsicWidth)))}function VU($,Y,X,Z){return{height:Z,left:Y,top:$.top+Math.max(0,Math.floor(($.height-Z)/2)),width:X}}function NU($){let Y=Math.max(18,Math.min(34,Math.round(Math.min($.width,$.height)*0.18)));return{left:$.left+Math.max(12,Math.round(($.width-Y)/2)),size:Y,top:$.top+Math.max(12,Math.round($.height/2-Y*0.95))}}function lX($){return Math.max(48,Math.round($*0.5625))}var AU=6,cX=3,_U=12,HU=10,zU=2,aX=4,FU=4,EU=1.5,rX=2,sX=1.25;function oX($,Y,X,Z,J,K,Q,M,D){if(!X){$.fillStyle=Q,$.fillText(Y.text,Z,J);return}let q=X.inlines.filter((U)=>U.end>Y.start&&U.start<Y.end);if(q.length===0){$.fillStyle=Q,$.fillText(Y.text,Z,J);return}for(let U of q){let V=Math.max(Y.start,U.start),G=Math.min(Y.end,U.end);if(X.text.slice(V,G).length===0)continue;let{left:A,right:_}=i3(Y,Z,V,G),z=TU(Y.font,U.marks);if($.font=z,U.kind==="image"){let F=Math.max(24,_-A);dX($,Y,U,M,D,A,F);continue}if(U.kind==="code"){WU($,Y,z,D,A,_),iX($,Y,X.text,Z,J,V,G,D.inlineCodeText,K,D,{strikethrough:!1,underline:!1});continue}iX($,Y,X.text,Z,J,V,G,U.link?D.linkText:Q,K,D,{strikethrough:U.marks.includes("strikethrough"),underline:U.marks.includes("underline")||Boolean(U.link)})}}function iX($,Y,X,Z,J,K,Q,M,D,q,U){let V=R7(K,Q,D);for(let G=0;G<V.length-1;G+=1){let N=V[G],A=V[G+1];if(A<=N)continue;let _=X.slice(N,A);if(_.length===0)continue;let{left:z,right:F}=i3(Y,Z,N,A),B=b7(D,N,A),W=S7(M,B,q);if($.fillStyle=W,$.fillText(_,z,J),U.strikethrough)$.fillRect(z,PU(J,Y.height,$.font),Math.max(rX,F-z),sX);if(U.underline)$.fillRect(z,yU(J,Y.height,$.font),Math.max(rX,F-z),sX)}}function nX($,Y,X,Z,J,K,Q){if(!X||K.length===0)return;for(let M of K){if(M.startOffset<Y.start||M.startOffset>Y.end)continue;let D=Z+(G0(Y,M.startOffset-Y.start)-Y.left);$.fillStyle=v7(Q,M),$.fillText(M.text,D,J)}}function tX($,Y,X,Z,J,K,Q){if(!X||K.length===0)return;for(let M of K){if(M.offset<Y.start||M.offset>=Y.end)continue;let{left:D,right:q}=i3(Y,Z,M.offset,M.offset+1),U=Math.max(aX,(q-D)/2+aX+FU*M.progress),{ascent:V,descent:G}=H1(Y.font),N=J-Math.max(1,V*0.42)+Math.max(0.5,G*0.15);$.strokeStyle=f7(M,Q),$.lineWidth=EU,$.beginPath(),$.arc((D+q)/2,N,U,0,Math.PI*2),$.stroke()}}function WU($,Y,X,Z,J,K){let Q=P4(Y.height,X),M=Y.top+Q+zU,D=Math.max(_U,Y.height-Q-AU);$.fillStyle=Z.inlineCodeBackground,$.fillRect(J-cX,M,Math.max(HU,K-J+cX*2),D)}function PU($,Y,X){let{ascent:Z}=H1(X),J=$-y4(Y,X);return Math.max(J+2,$-Math.round(Z*0.32))}function yU($,Y,X){let{descent:Z}=H1(X),J=Math.max(1,Math.round(Math.max(2,Z)*0.35)),K=$+Z-J,Q=$-y4(Y,X);return Math.min(Q+Y-4,K)}function TU($,Y){let X=[];if(Y.includes("italic"))X.push("italic");if(Y.includes("bold"))X.push("700");return X.length>0?`${X.join(" ")} ${$}`:$}function i3($,Y,X,Z){return{left:Y+(G0($,X-$.start)-$.left),right:Y+(G0($,Z-$.start)-$.left)}}function o3($,Y,X,Z){jU({activeBlockId:Z.activeBlockId,activeRegionId:Z.activeRegionId,activeThreadIndex:Z.activeThreadIndex,containerLineBounds:Y.regionBounds,context:X,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:Y.layout,liveCommentRanges:Z.liveCommentRanges,normalizedSelection:Z.normalizedSelection,now:Z.now,resources:Z.resources??{images:new Map},runtimeBlockMap:Y.blockMap,theme:Z.theme,viewportTop:Y.paintTop,width:Z.width})}function n3($,Y,X,Z){s3({context:X,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:Y.layout,normalizedSelection:Z.normalizedSelection,presence:Z.presence,showCaret:Z.showCaret,theme:Z.theme,viewportTop:Y.paintTop,width:Z.width})}function jU({activeBlockId:$,activeRegionId:Y,activeThreadIndex:X,containerLineBounds:Z,context:J,devicePixelRatio:K,editorState:Q,height:M,layout:D,liveCommentRanges:q,normalizedSelection:U,now:V=CU(),resources:G,runtimeBlockMap:N,theme:A,viewportTop:_,width:z}){J.save(),J.scale(K,K),J.clearRect(0,0,z,M),J.fillStyle=A.background,J.fillRect(0,0,z,M),J.textBaseline="alphabetic",J.translate(0,-_);let{endIndex:F,startIndex:B}=V6(D,_,M),W=IX(Q,U),S=O7(Q,V),b=B7(Q,V),k=w7(Q,V),P=L7(Q,V),y=C7(Q,V),E=fX(D,Q,$,B,F),w=RX(D,Q,N,B,F,z);for(let T=B;T<F;T+=1){let H=D.lines[T];CX(J,H,N.get(H.blockId)??null,Z.get(H.regionId)??null,Q.documentIndex.tableCellIndex.get(H.regionId)??null,A,z)}let C=G6(D,_,M);bX(J,D,C.startIndex,C.endIndex,A,z),jX({activeBlockFlashes:S,activeBlockId:$,activeRegionId:Y,context:J,editorState:Q,endIndex:F,layout:D,regionBounds:Z,startIndex:B,theme:A,verticalBleed:E6});for(let T=B;T<F;T+=1){let H=D.lines[T];wU({activeBlockId:$,activeBlockFlashes:S,activeDeletedTextFades:b,activeInsertedTextHighlights:k,activeListMarkerPops:P,activePunctuationPulses:y,activeThreadIndex:X,context:J,editorState:Q,line:H,liveCommentRanges:q,normalizedSelection:U,resources:G,runtimeBlockMap:N,selectionRegionOrderRange:W,theme:A,width:z})}SX(J,w,A),mX(J,E,A),J.restore()}function wU({activeBlockId:$,activeBlockFlashes:Y,activeDeletedTextFades:X,activeInsertedTextHighlights:Z,activeListMarkerPops:J,activePunctuationPulses:K,activeThreadIndex:Q,context:M,editorState:D,line:q,liveCommentRanges:U,normalizedSelection:V,resources:G,runtimeBlockMap:N,selectionRegionOrderRange:A,theme:_,width:z}){let F=N.get(q.blockId)??null,B=D.documentIndex.blockIndex.get(q.blockId)?.path??null,W=D.documentIndex.regionIndex.get(q.regionId)??null,S=W?.path??"",b=Z1(D,q.blockId,"listItem"),k=b?g1(D,b.id):null,P=b?J.get(b.path)??null:null,y=q.left+T0(D,q),E=OU(q),w=F?.type==="code"?_.codeText:BU(F,_);M.font=q.font,LX(M,q,F,B,$,Y,_,z),pX(M,D,q,V,A,_),xX(M,D,q,U,Q,_),gX(M,q,k,y,E,_,P),oX(M,q,W,y,E,Z.get(S)??[],w,G,_),nX(M,q,W,y,E,X.get(S)??[],w),tX(M,q,W,y,E,K.get(S)??[],_)}function OU($){return $.top+y4($.height,$.font)}function BU($,Y){switch($?.type){case"heading":return Y.headingText;case"blockquote":return Y.blockquoteText;case"table":return Y.headingText;default:return Y.paragraphText}}function CU(){return typeof performance<"u"?performance.now():Date.now()}import{forwardRef as vU,createElement as fU}from"react";var W6=(...$)=>$.filter((Y,X,Z)=>{return Boolean(Y)&&Y.trim()!==""&&Z.indexOf(Y)===X}).join(" ").trim();var eX=($)=>$.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var $Z=($)=>$.replace(/^([A-Z])|[\s-_]+(\w)/g,(Y,X,Z)=>Z?Z.toUpperCase():X.toLowerCase());var t3=($)=>{let Y=$Z($);return Y.charAt(0).toUpperCase()+Y.slice(1)};import{forwardRef as SU,createElement as ZZ}from"react";var P6={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 YZ=($)=>{for(let Y in $)if(Y.startsWith("aria-")||Y==="role"||Y==="title")return!0;return!1};import{createContext as LU,useContext as RU,useMemo as uW,createElement as gW}from"react";var bU=LU({});var XZ=()=>RU(bU);var JZ=SU(({color:$,size:Y,strokeWidth:X,absoluteStrokeWidth:Z,className:J="",children:K,iconNode:Q,...M},D)=>{let{size:q=24,strokeWidth:U=2,absoluteStrokeWidth:V=!1,color:G="currentColor",className:N=""}=XZ()??{},A=Z??V?Number(X??U)*24/Number(Y??q):X??U;return ZZ("svg",{ref:D,...P6,width:Y??q??P6.width,height:Y??q??P6.height,stroke:$??G,strokeWidth:A,className:W6("lucide",N,J),...!K&&!YZ(M)&&{"aria-hidden":"true"},...M},[...Q.map(([_,z])=>ZZ(_,z)),...Array.isArray(K)?K:[K]])});var m=($,Y)=>{let X=vU(({className:Z,...J},K)=>fU(JZ,{ref:K,iconNode:Y,className:W6(`lucide-${eX(t3($))}`,`lucide-${$}`,Z),...J}));return X.displayName=t3($),X};var mU=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],z1=m("columns-2",mU);var hU=[["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"}]],F1=m("rows-3",hU);var kU=[["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"}]],E1=m("send-horizontal",kU);var uU=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],O4=m("arrow-down",uU);var gU=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],B4=m("arrow-up",gU);var IU=[["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"}]],C4=m("bold",IU);var pU=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],I1=m("check",pU);var xU=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],L4=m("chevron-down",xU);var lU=[["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"}]],R4=m("heading-1",lU);var dU=[["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"}]],b4=m("heading-2",dU);var cU=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],S4=m("heading-3",cU);var aU=[["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"}]],v4=m("heading-4",aU);var rU=[["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=m("heading-5",rU);var sU=[["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"}]],m4=m("heading-6",sU);var iU=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],h4=m("heading",iU);var oU=[["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"}]],k4=m("italic",oU);var nU=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],u4=m("list-ordered",nU);var tU=[["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"}]],g4=m("list-todo",tU);var eU=[["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"}]],I4=m("list",eU);var $G=[["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"}]],p4=m("message-square-plus",$G);var YG=[["path",{d:"M5 12h14",key:"1ays0h"}]],x4=m("minus",YG);var XG=[["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"}]],p1=m("pencil",XG);var ZG=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],L2=m("plus",ZG);var JG=[["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"}]],l4=m("strikethrough",JG);var KG=[["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"}]],W1=m("table-2",KG);var QG=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],d4=m("text-quote",QG);var MG=[["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"}]],L0=m("trash-2",MG);var qG=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],c4=m("underline",qG);var DG=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],a4=m("x",DG);import{jsx as R2,jsxs as NG}from"react/jsx-runtime";function KZ({insetX:$,insetY:Y,onSelect:X,presence:Z}){if(!Z)return null;return R2("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${$}px`,top:`${Y}px`},children:Z.map((J)=>R2(UG,{onSelect:()=>X(J),presence:J},J.id))})}function UG({onSelect:$,presence:Y}){let X=Y.viewport,Z=GG(Y),J=X?.status==="above"?B4:O4,K=X!==null&&X.status!=="unresolved",Q=X?.status==="above"||X?.status==="below";return NG("button",{"aria-label":VG(Y),className:"documint-presence-indicator","data-status":X?.status??"unresolved",disabled:!K,onClick:K?$:void 0,style:{"--documint-presence-color":Y.color??"var(--documint-leaf-accent)"},type:"button",children:[R2("span",{className:"documint-presence-indicator-avatar",children:Y.avatarUrl?R2("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:Y.avatarUrl}):Z}),Q?R2("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:R2(J,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3})}):null]})}function GG($){return QZ($).charAt(0).toLocaleUpperCase()}function VG($){let Y=QZ($),X=$.viewport?.status??"unresolved";if(X==="above")return`${Y} above viewport`;if(X==="below")return`${Y} below viewport`;if(X==="unresolved")return`${Y} unresolved`;return`${Y} in viewport`}function QZ($){return($.fullName??$.username).trim()||"Presence"}var l=`
|
|
29
|
+
`,b2="<ins>",r4="</ins>",S2=">",s4="```",y6=":::",T6="documint-comments";var o4="\\",w6="`",GZ=":",i4=" ",$9="![",Y9="[",VZ="(",MZ=")",qZ=/[\p{L}\p{N}]/u,AG=/[A-Za-z]/,_G=/[-A-Za-z0-9_]/,j6=/\{width=([1-9]\d*)\}/y,HG=/\\([\\`*_[\]{}()#+\-.!~|])/g,NZ=/\\(.)/g,AZ=[{delimiter:"**",mark:"bold",requireWordBoundary:!1},{delimiter:"~~",mark:"strikethrough",requireWordBoundary:!1},{delimiter:"*",mark:"italic",requireWordBoundary:!1},{delimiter:"_",mark:"italic",requireWordBoundary:!0}],zG=new Set(AZ.map(($)=>$.delimiter[0]));function n4($){return O6($,0,$.length,[])}function O6($,Y,X,Z){let J=[],K=Y,Q=Y;while(K<X){let M=FG($,K,X,Z);if(M){let D=Math.max(Q,K-(M.trimLeading??0));DZ(J,$.slice(Q,D),Z),J.push(...M.nodes),K=M.end,Q=K;continue}if($[K]===o4){K+=Math.min(2,X-K);continue}K+=1}return DZ(J,$.slice(Q,X),Z),Z0(J)}function FG($,Y,X,Z){let J=$[Y];switch(J){case GZ:return EG($,Y,X);case"<":return TG($,Y,X)??WG($,Y,X,Z)??PG($,Y,X);case o4:return jG($,Y,X);case l:return wG($,Y);case w6:return OG($,Y,X);case"!":return BG($,Y,X);case Y9:return CG($,Y,X,Z)}if(J!==void 0&&zG.has(J))return RG($,Y,X,Z);return null}function EG($,Y,X){if($[Y]!==GZ||!AG.test($[Y+1]??""))return null;let Z=Y+2;while(Z<X&&_G.test($[Z]??""))Z+=1;let J=UZ($,Z,X,"[","]"),Q=UZ($,J?.end??Z,X,"{","}")?.end??J?.end??Z;return{end:Q,nodes:[FZ("textDirective",$.slice(Y,Q))]}}function WG($,Y,X,Z){if(!$.startsWith(b2,Y))return null;let J=$.indexOf(r4,Y+b2.length);if(J<0||J>=X)return null;return{end:J+r4.length,nodes:O6($,Y+b2.length,J,[...Z,"underline"])}}function PG($,Y,X){if($[Y]!=="<")return null;let Z=$.indexOf(">",Y+1);if(Z<0||Z>=X)return null;return{end:Z+1,nodes:[FZ("html",$.slice(Y,Z+1))]}}var yG=/^<br\s*\/?>/i;function TG($,Y,X){if($[Y]!=="<")return null;let Z=yG.exec($.slice(Y,X));if(!Z)return null;let J=Y+Z[0].length;return{end:$[J]===l?J+1:J,nodes:[l0()]}}function jG($,Y,X){if($[Y]!==o4||$[Y+1]!==l||Y+1>=X)return null;return{end:Y+2,nodes:[l0()]}}function wG($,Y){if($[Y]!==l||$[Y-1]!==i4||$[Y-2]!==i4)return null;let X=0;while($[Y-1-X]===i4)X+=1;return{end:Y+1,nodes:[l0()],trimLeading:X}}function OG($,Y,X){if($[Y]!==w6)return null;let Z=1;while(Y+Z<X&&$[Y+Z]===w6)Z+=1;let J=w6.repeat(Z),K=$.indexOf(J,Y+Z);if(K<0||K>=X)return null;return{end:K+Z,nodes:[e1({code:$.slice(Y+Z,K)})]}}function BG($,Y,X){if(!$.startsWith($9,Y))return null;let Z=HZ($,Y+1,X);if(Z<0||$[Z+1]!==VZ)return null;let J=_Z($,Z+1,X);if(!J)return null;let K=LG($,J.end,X);return{end:K?.end??J.end,nodes:[j1({alt:zZ($.slice(Y+$9.length,Z)),title:J.title,url:J.url,width:K?.width??null})]}}function CG($,Y,X,Z){if($[Y]!==Y9||$.startsWith($9,Y-1))return null;let J=HZ($,Y,X);if(J<0||$[J+1]!==VZ)return null;let K=_Z($,J+1,X);if(!K)return null;return{end:K.end,nodes:[$2({children:O6($,Y+Y9.length,J,Z),title:K.title,url:K.url})]}}function _Z($,Y,X){let Z=e3($,Y+1,X),J=Z;while(J<X&&$[J]!==MZ&&$[J]!==i4){if($[J]===o4){J+=2;continue}J+=1}if(J===Z)return null;let K=bG($.slice(Z,J));Z=e3($,J,X);let Q=null;if(Z<X&&$[Z]==='"'){let M=B6($,'"',Z+1,X);if(M<0)return null;Q=$.slice(Z+1,M).replace(NZ,"$1"),Z=e3($,M+1,X)}if($[Z]!==MZ)return null;return{end:Z+1,title:Q,url:K}}function LG($,Y,X){j6.lastIndex=Y;let Z=j6.exec($);if(!Z||j6.lastIndex>X)return null;return{end:j6.lastIndex,width:Number(Z[1])}}function RG($,Y,X,Z){for(let J of AZ){if(!$.startsWith(J.delimiter,Y))continue;let K=B6($,J.delimiter,Y+J.delimiter.length,X);if(K<0)continue;if(J.requireWordBoundary){let M=Y>0?$[Y-1]:"",D=$[K+J.delimiter.length]??"";if(qZ.test(M)||qZ.test(D))continue}let Q=Y+J.delimiter.length;return{end:K+J.delimiter.length,nodes:O6($,Q,K,[...Z,J.mark])}}return null}function DZ($,Y,X){if(Y.length===0)return;$.push(q1({marks:X,text:zZ(Y)}))}function UZ($,Y,X,Z,J){if($[Y]!==Z)return null;let K=B6($,J,Y+1,X);if(K<0)return null;return{end:K+1}}function HZ($,Y,X){return B6($,"]",Y+1,X)}function B6($,Y,X,Z){for(let J=X;J<Z;J+=1){if($[J]===o4){J+=1;continue}if($.startsWith(Y,J))return J}return-1}function e3($,Y,X){while(Y<X&&$[Y]===i4)Y+=1;return Y}function zZ($){return $.replace(HG,"$1")}function bG($){return $.replace(NZ,"$1")}function FZ($,Y){return z5({originalType:$,source:Y})}var SG=/^:?-+:?$/;function WZ($,Y){let X=q0($),Z=Z9($,1),J=z0(X,Y),K=z0(Z,Y);if(!EZ(J)||!X9(K))return null;let Q=[C6(J)],M=vG(K);$.index+=2;while($.index<$.lines.length){let D=q0($),q=z0(D,Y);if(P1(D)||!EZ(q))break;Q.push(C6(q)),$.index+=1}return B1({align:M,rows:Q.map((D)=>Y2({cells:D.map((q)=>D1({children:n4(q)}))}))})}function X9($){let Y=C6($);return Y.length>0&&Y.every((X)=>SG.test(X.trim()))}function EZ($){let Y=$.trim();return Y.startsWith("|")&&Y.endsWith("|")}function vG($){return C6($).map((Y)=>{let X=Y.trim();if(X.startsWith(":")&&X.endsWith(":"))return"center";if(X.startsWith(":"))return"left";if(X.endsWith(":"))return"right";return null})}function C6($){let Y=$.trim();if(!Y.startsWith("|")||!Y.endsWith("|"))return[];return Y.slice(1,-1).split("|").map((X)=>X.trim())}var fG=3,PZ=/^(#{1,6})\s+(.*)$/,mG=/\s+#+\s*$/u,hG=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,kG=/^\d+\.$/,uG=/^\[( |x|X)\](?:\s|$)/,yZ=/^```([^\s`]*)?(?:\s+(.*))?$/,TZ=/^:::([A-Za-z][-\w]*)(.*)$/,gG=[/^(\*\s*){3,}$/,/^(-\s*){3,}$/,/^(_\s*){3,}$/];function R6($,Y,X){let Z=[];while($.index<$.lines.length){let J=q0($);if($.index===$.lines.length-1&&J==="")break;if(P1(J)){$.index+=1;continue}if(v2(J)>Y+fG)break;let K=IG($,Y,X);if(!K)break;Z.push(K)}return Z}function IG($,Y,X){return pG($,Y,X)??xG($,Y)??lG($,Y)??cG($,Y)??aG($,Y)??WZ($,Y)??rG($,Y,X)??iG($,Y)??oG($,Y)}function pG($,Y,X){let Z=q0($);if(!z0(Z,Y).startsWith(S2))return null;let J=[];while($.index<$.lines.length){let K=q0($),Q=v2(K);if(P1(K)){J.push(""),$.index+=1;continue}if(Q<Y)break;let M=z0(K,Y);if(!M.startsWith(S2))break;let D=M.slice(1);if(D.startsWith(" "))D=D.slice(1);J.push(D),$.index+=1}return R0({children:R6({index:0,lines:J},0,X)})}function xG($,Y){let X=q0($),Z=z0(X,Y),J=yZ.exec(Z);if(!J)return null;$.index+=1;let K=[];while($.index<$.lines.length){let Q=q0($),M=z0(Q,Y);if(M.trim()===s4){$.index+=1;break}K.push(M),$.index+=1}return t6({language:J[1]?J[1]:null,meta:J[2]?J[2]:null,source:K.join(l)})}function lG($,Y){let X=q0($),Z=z0(X,Y),J=TZ.exec(Z);if(!J)return null;let K=J[1],Q=[];$.index+=1;while($.index<$.lines.length){let M=q0($),D=z0(M,Y);if(D.trim()===y6){$.index+=1;break}Q.push(D),$.index+=1}return a9({attributes:dG(J[2]??""),body:Q.join(l),name:K})}function dG($){let Y=$.trim();if(Y.startsWith("{")&&Y.endsWith("}"))return Y.slice(1,-1);return Y}function cG($,Y){let X=q0($),Z=PZ.exec(z0(X,Y));if(!Z)return null;return $.index+=1,H5({children:n4(Z[2].replace(mG,"")),depth:Z[1].length})}function aG($,Y){let X=z0(q0($),Y).trim();if(!jZ(X))return null;return $.index+=1,F5()}function rG($,Y,X){let Z=L6(q0($),Y);if(!Z)return null;let J=[],K=!1;while($.index<$.lines.length){let Q=q0($),M=L6(Q,Y);if(!M||M.ordered!==Z.ordered)break;$.index+=1;let D=[M.content],q=!1;while($.index<$.lines.length){let U=q0($),V=v2(U);if(P1(U)){let G=eG($.lines,$.index+1);if(G<0||v2($.lines[G]??"")<=Y)break;q=!0,D.push(""),$.index+=1;continue}if(V<M.contentIndent)break;if(V===Y&&L6(U,Y))break;D.push(tG(U,M.contentIndent)),$.index+=1}K||=q,J.push(w1({checked:M.checked,children:sG(D,X),spread:q}))}return O1({items:J,ordered:Z.ordered,spread:K,start:Z.ordered&&X.preserveOrderedListStart?Z.start??1:null})}function L6($,Y){let X=hG.exec($);if(!X||X[1].length!==Y)return null;let Z=X[2],J=kG.test(Z),K=J?Number(Z.slice(0,-1)):null,Q=X[3]??"",M=null;if(uG.test(Q)){if(M=Q[1]==="x"||Q[1]==="X",Q=Q.slice(3),Q.startsWith(" "))Q=Q.slice(1)}let D=X[0].length-X[1].length-X[2].length-Q.length;return{checked:M,content:Q,contentIndent:Y+X[2].length+D,ordered:J,start:K}}function sG($,Y){let X=R6({index:0,lines:$},0,Y);if(X.length>0)return X;return[x0({children:[]})]}function iG($,Y){let X=z0(q0($),Y).trim();if(!wZ(X))return null;return $.index+=1,e6({originalType:"html",source:X})}function oG($,Y){let X=[];while($.index<$.lines.length){let Z=q0($),J=v2(Z);if(P1(Z))break;if(J<Y)break;let K=z0(Z,Y);if(X.length>0&&nG(Z,K,Y))break;X.push(K),$.index+=1}return x0({children:n4(X.join(l))})}function nG($,Y,X){let Z=Y.trim();return Y.startsWith(S2)||yZ.test(Y)||TZ.test(Y)||PZ.test(Y)||jZ(Z)||X9(Y)||L6($,X)!==null||wZ(Z)}function v2($){let Y=0;while(Y<$.length&&$[Y]===" ")Y+=1;return Y}function tG($,Y){let X=v2($);if(X>=Y)return $.slice(Y);return $.trim()===""?"":$.slice(Math.min(X,Y))}function eG($,Y){for(let X=Y;X<$.length;X+=1)if(!P1($[X]??""))return X;return-1}function jZ($){return gG.some((Y)=>Y.test($))}function wZ($){return $.startsWith("<")&&$.endsWith(">")}function BZ($){let Y=$.at(-1),X=Y&&OZ(Y)?Y:null;return{blocks:$.filter((J)=>!OZ(J)),comments:X?$V(X.body):[]}}function $V($){let Y;try{Y=JSON.parse($)}catch{return[]}if(!Array.isArray(Y))return[];return Y.flatMap((X)=>{let Z=A8(X);return Z?[Z]:[]})}function OZ($){return $.type==="directive"&&$.name===T6}var CZ="---";function t4($,Y={}){let Z={index:0,lines:$.replace(/\r\n/g,l).split(l)},J=YV(Z),K=R6(Z,0,Y),{comments:Q,blocks:M}=BZ(K);return J2(M,Q,J)}function YV($){if($.lines[0]!==CZ)return;for(let Y=1;Y<$.lines.length;Y+=1)if($.lines[Y]===CZ){let X=$.lines.slice(0,Y+1).join(l);return $.index=Y+1,X}return}function q0($){return Z9($,0)}function Z9($,Y){return $.lines[$.index+Y]??""}function P1($){return $.trim()===""}function z0($,Y){return $.slice(Y)}var XV=/([\\`*_[\]])/g,ZV=/([\\)&])/g,JV=/(["\\])/g;function i0($){return Z0($).map((Y)=>KV(Y)).join("")}function KV($){switch($.type){case"lineBreak":return"<br>";case"image":return qV($);case"code":return MV($.code);case"link":return DV($);case"text":return QV(RZ($.text),$.marks);case"raw":return $.source}}function QV($,Y){return Y.reduce((X,Z)=>{switch(Z){case"bold":return`**${X}**`;case"italic":return`*${X}*`;case"strikethrough":return`~~${X}~~`;case"underline":return`${b2}${X}${r4}`}},$)}function MV($){let Y=0,X=0;for(let Q of $){if(Q==="`"){if(X+=1,X>Y)Y=X;continue}X=0}let Z=Y>0?Y+1:1,J="`".repeat(Z),K=$.startsWith("`")||$.endsWith("`")?` ${$} `:$;return`${J}${K}${J}`}function qV($){let Y=RZ($.alt??""),X=LZ($.url,$.title),Z=$.width?`{width=${$.width}}`:"";return`![${Y}]${X}${Z}`}function DV($){return`[${i0($.children)}]${LZ($.url,$.title)}`}function LZ($,Y){return`(${UV($)}${GV(Y)})`}function RZ($){return $.replace(XV,"\\$1")}function UV($){return $.replace(ZV,"\\$1")}function GV($){return $?` "${$.replace(JV,"\\$1")}"`:""}var SZ=3;function vZ($,Y,X){let Z=$.rows.map((U)=>U.cells.map((V)=>i0(V.children))),J=Math.max(1,...Z.map((U)=>U.length)),K=Z[0]??[],Q=Array.from({length:J},(U,V)=>Math.max(_V($.align[V]),...X.padTableColumns?Z.map((G)=>G[V]?.length??0):[K[V]?.length??0])),M=VV(Q,$.align,Y),D=bZ(K,Q,$.align,Y,X),q=Z.slice(1).map((U)=>bZ(U,Q,$.align,Y,X));return[D??NV(Q,Y),M,...q].join(l)}function bZ($,Y,X,Z,J){let K=Y.map((Q,M)=>{let D=$[M]??"";if(!J.padTableColumns)return D;return HV(D,Q,X[M])});return`${" ".repeat(Z)}| ${K.join(" | ")} |`}function VV($,Y,X){let Z=$.map((J,K)=>AV(Y[K],J));return`${" ".repeat(X)}| ${Z.join(" | ")} |`}function NV($,Y){return`${" ".repeat(Y)}| ${$.map((X)=>"".padEnd(X," ")).join(" | ")} |`}function AV($,Y){let X=fZ($),Z=Math.max(SZ,Y-X),J="-".repeat(Z);switch($){case"center":return`:${J}:`;case"left":return`:${J}`;case"right":return`${J}:`;default:return J}}function _V($){return SZ+fZ($)}function fZ($){if($==="center")return 2;return $?1:0}function HV($,Y,X){if(X==="right")return $.padStart(Y," ");return $.padEnd(Y," ")}var x1=`
|
|
30
|
+
|
|
31
|
+
`,zV="-",FV=".",EV="---",WV=" ";function e4($,Y={}){return $.map((X)=>b6(X,0,Y)).join(x1)}function b6($,Y,X){let Z=l1(Y);switch($.type){case"blockquote":return PV($,Y,X);case"code":return yV($,Y);case"directive":return TV($,Y);case"heading":return mZ($,Y);case"list":return jV($,Y,X);case"listItem":return hZ($,Y,!1,1,X);case"paragraph":return`${Z}${J9(i0($.children))}`;case"table":return vZ($,Y,X);case"divider":return`${Z}${EV}`;case"raw":return Y===0?$.source:kZ($.source,Y)}}function PV($,Y,X){let Z=$.children.map((K)=>b6(K,0,X)).join(x1),J=l1(Y);return Z.split(l).map((K)=>`${J}${S2}${K.length>0?` ${K}`:""}`).join(l)}function yV($,Y){let X=[$.language??"",$.meta??""].filter(Boolean).join(" ").trim(),Z=l1(Y),J=`${Z}${s4}${X?X:""}`,K=$.source.length>0?$.source.split(l).map((Q)=>`${Z}${Q}`).join(l):Z;return`${J}${l}${K}${l}${Z}${s4}`}function TV($,Y){let X=S6($);return Y===0?X:kZ(X,Y)}function S6($){let Y=$.attributes?`{${$.attributes}}`:"";return`:::${$.name}${Y}${l}${$.body}${l}${y6}`}function mZ($,Y){let X=J9(i0($.children)),Z=`${l1(Y)}${"#".repeat($.depth)}`;return X.length>0?`${Z} ${X}`:Z}function jV($,Y,X){let Z=$.start??1;return $.items.map((J)=>hZ(J,Y,$.ordered,Z,X)).join($.spread?x1:l)}function hZ($,Y,X,Z,J){let K=X?`${Z}${FV}`:zV,Q=$.checked===null?"":`[${$.checked?"x":" "}] `,M=`${l1(Y)}${K} ${Q}`,D=Y+K.length+1,q=$.children;if(q.length===0)return Q.length>0?M:M.trimEnd();let[U,...V]=q,G=wV(U,M,Q.length>0,J),N=V.map((A)=>b6(A,D,J)).join($.spread?x1:l);if(!N)return G;return`${G}${$.spread?x1:l}${N}`}function wV($,Y,X,Z){switch($.type){case"paragraph":{let J=J9(i0($.children));if(J.length===0)return X?Y:Y.trimEnd();return`${Y}${J}`}case"heading":return`${Y}${mZ($,0)}`;case"directive":case"raw":{let J=$.type==="directive"?S6($):$.source,[K,...Q]=J.split(l);return[Y+K,...Q.map((M)=>`${l1(Y.length)}${M}`)].join(l)}default:{let J=Y.length;return`${Y.trimEnd()}${l}${b6($,J,Z)}`}}}function J9($){return $.replace(/^ +/gm,(Y)=>WV.repeat(Y.length))}function l1($){return" ".repeat($)}function kZ($,Y){let X=l1(Y);return $.split(l).map((Z)=>`${X}${Z}`).join(l)}function v6($,Y={}){if($.blocks.length===0&&$.comments.length===0&&$.frontMatter===void 0)return"";let X=[];if($.frontMatter!==void 0)X.push($.frontMatter);if($.blocks.length>0)X.push(e4($.blocks,Y));if($.comments.length>0)X.push(OV($.comments));let Z=X.join(x1);return Z.endsWith(l)?Z:`${Z}${l}`}function OV($){return S6({attributes:"",body:JSON.stringify($,null,2),name:T6})}function K9($){if($.length===0)return{kind:"text",text:""};let{blocks:Y}=t4($);if(P5(Y))return{kind:"text",text:Y[0]?.plainText??""};if(Y.length===1&&Y[0]?.type==="paragraph")return{kind:"inlines",inlines:Y[0].children};return{kind:"blocks",blocks:Y}}function f6($){switch($.kind){case"text":return $.text;case"inlines":return i0($.inlines);case"blocks":return e4($.blocks)}}import{createContext as BV,useContext as CV}from"react";import{createPortal as LV}from"react-dom";import{jsx as IZ}from"react/jsx-runtime";var uZ=BV(void 0);function gZ({children:$,themeStyles:Y}){return IZ(uZ.Provider,{value:Y,children:$})}function m6({children:$}){let Y=CV(uZ);if(typeof document>"u")return null;return LV(IZ("div",{className:"documint-overlay",style:{display:"contents",...Y},children:$}),document.body)}import{useEffect as h6,useRef as $J,useState as d1}from"react";import{forwardRef as bV,useCallback as f2,useEffect as SV,useImperativeHandle as vV,useLayoutEffect as fV,useMemo as mV,useRef as lZ,useState as Q9}from"react";var RV=["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 pZ($,Y,{topGap:X=8}={}){if(!$.isConnected)return null;let Z=getComputedStyle($),J=document.createElement("div");for(let q of RV)J.style.setProperty(q,Z.getPropertyValue(q));Object.assign(J.style,{position:"absolute",top:"0",left:"0",visibility:"hidden",whiteSpace:"pre-wrap",wordWrap:"break-word",width:`${$.clientWidth}px`}),J.textContent=$.value.slice(0,Y);let K=document.createElement("span");K.textContent=$.value.slice(Y)||".",J.appendChild(K),document.body.appendChild(J);let Q=$.getBoundingClientRect(),M=parseFloat(Z.lineHeight)||K.offsetHeight,D={left:Q.left+K.offsetLeft+parseFloat(Z.borderLeftWidth)-$.scrollLeft,top:Q.top+K.offsetTop+parseFloat(Z.borderTopWidth)+M+X-$.scrollTop};return document.body.removeChild(J),D}import{jsx as h0,jsxs as dZ,Fragment as dV}from"react/jsx-runtime";var hV=240,kV="documint-leaf-menu-item documint-completion-item",$5=bV(function({actions:Y,completionSources:X,onChange:Z,placeholder:J,readOnly:K=!1,rows:Q=3,value:M},D){let q=lZ(null);vV(D,()=>q.current,[]);let U=mV(()=>pV(X),[X]),[V,G]=Q9(null),[N,A]=Q9(0),[_,z]=Q9(null),F=f2((P,y)=>{if(!U.length){G(null);return}let E=xV(P,y,U);if(!E){G(null);return}G(E),A(0)},[U]),B=f2((P)=>{let y=P.currentTarget.value,E=P.currentTarget.selectionEnd??y.length;Z(y),F(y,E)},[Z,F]),W=f2((P)=>{let y=P.currentTarget;F(y.value,y.selectionEnd??y.value.length)},[F]),S=f2(()=>{G(null)},[]),b=f2((P)=>{if(!q.current||!V)return;let E=`${V.trigger}${P.label} `,w=M.slice(0,V.triggerStart),C=M.slice(V.caret),T=w+E+C,H=V.triggerStart+E.length;Z(T),G(null),requestAnimationFrame(()=>{let R=q.current;if(!R)return;R.focus(),R.setSelectionRange(H,H)})},[V,Z,M]),k=f2((P)=>{if(V&&V.matches.length>0){if(P.key==="ArrowDown"){P.preventDefault(),P.stopPropagation(),A((y)=>(y+1)%V.matches.length);return}if(P.key==="ArrowUp"){P.preventDefault(),P.stopPropagation(),A((y)=>(y-1+V.matches.length)%V.matches.length);return}if(P.key==="Enter"||P.key==="Tab"){P.preventDefault(),P.stopPropagation();let y=V.matches[N];if(y)b(y);return}if(P.key==="Escape"){P.preventDefault(),P.stopPropagation(),G(null);return}}if(P.key==="Escape"&&Y.kind==="edit")P.preventDefault(),Y.onCancel()},[Y,V,N,b]);return fV(()=>{if(!V){z(null);return}let P=()=>{let y=q.current;if(!y)return;z(pZ(y,V.triggerStart))};return P(),window.addEventListener("scroll",P,!0),window.addEventListener("resize",P),()=>{window.removeEventListener("scroll",P,!0),window.removeEventListener("resize",P)}},[V]),dZ("div",{className:"documint-leaf-input-field",children:[h0("textarea",{className:"documint-leaf-input",onBlur:S,onChange:B,onKeyDown:k,onSelect:W,placeholder:J,readOnly:K,ref:q,rows:Q,value:M}),uV(Y),V&&_&&V.matches.length>0?h0(m6,{children:h0(gV,{activeIndex:N,left:_.left,matches:V.matches,onHover:A,onSelect:b,top:_.top})}):null]})});function uV($){if($.kind==="edit")return dZ(dV,{children:[h0(M9,{className:"documint-leaf-input-cancel",icon:a4,label:"Cancel editing",onClick:$.onCancel}),h0(M9,{className:"documint-leaf-input-save",disabled:$.saveDisabled??!1,icon:I1,label:"Save",onClick:$.onSave})]});return h0(M9,{className:"documint-leaf-input-submit",disabled:$.submitDisabled??!1,icon:E1,iconSize:15,label:$.submitLabel,onClick:$.onSubmit})}function M9({className:$,disabled:Y=!1,icon:X,iconSize:Z=14,label:J,onClick:K}){return h0("button",{"aria-label":J,className:`documint-leaf-action ${$}`,disabled:Y,onClick:K,title:J,type:"button",children:h0(X,{size:Z,strokeWidth:2.2})})}function gV({activeIndex:$,left:Y,matches:X,onHover:Z,onSelect:J,top:K}){let Q=lZ(null);return SV(()=>{let M=Q.current;if(!M)return;let D=M.children[$];if(D instanceof HTMLElement)D.scrollIntoView({block:"nearest"})},[$]),h0("div",{className:"documint-leaf-menu documint-completion-popover",ref:Q,role:"listbox",style:{position:"fixed",left:Y,top:K,maxHeight:hV,overflowY:"auto"},children:X.map((M,D)=>{let q=D===$;return h0("button",{"aria-selected":q,className:`${kV}${q?" is-active":""}`,onPointerDown:IV,onPointerEnter:()=>Z(D),onClick:()=>J(M),role:"option",type:"button",children:h0("span",{children:M.label})},M.label)})})}function IV($){$.preventDefault()}function pV($){if(!$?.length)return[];return $.map((Y)=>({trigger:Y.trigger,items:[...Y.items].sort((X,Z)=>X.label.localeCompare(Z.label,void 0,{sensitivity:"base"}))}))}function xV($,Y,X){for(let Z=Y-1;Z>=0;Z-=1){let J=$[Z];if(xZ(J))return null;let K=X.find((M)=>M.trigger===J);if(!K)continue;if(Z>0&&!xZ($[Z-1]))return null;let Q=$.slice(Z+1,Y);return{trigger:K.trigger,query:Q,triggerStart:Z,caret:Y,matches:lV(K.items,Q)}}return null}function xZ($){return $===void 0||$===" "||$===`
|
|
32
|
+
`||$==="\t"}function lV($,Y){if(!Y)return $;let X=Y.toLowerCase();return $.filter((Z)=>Z.label.toLowerCase().includes(X))}import{Fragment as aV}from"react";function q9($,Y){if(!Y?.length||!Y.some((Q)=>$.includes(Q.trigger)))return[{kind:"text",text:$}];let X=new Map;for(let Q of Y){let M=[...Q.items].sort((D,q)=>q.label.length-D.label.length);X.set(Q.trigger,M)}let Z=[],J=0,K=0;while(J<$.length){let Q=$[J],M=X.get(Q);if(M!==void 0&&(J===0||cV($[J-1]))){let q=M.find((U)=>$.startsWith(U.label,J+1));if(q){if(J>K)Z.push({kind:"text",text:$.slice(K,J)});Z.push({kind:"token",trigger:Q,label:q.label,id:q.id}),J+=1+q.label.length,K=J;continue}}J+=1}if(K<$.length)Z.push({kind:"text",text:$.slice(K)});return Z}function D9($,Y){let X=[],Z=new Set;for(let J of q9($,Y)){if(J.kind!=="token"||J.trigger!=="@"||!J.id)continue;if(Z.has(J.id))continue;Z.add(J.id),X.push(J.id)}return X}function cV($){return $===void 0||$===" "||$===`
|
|
33
|
+
`||$==="\t"}import{jsx as cZ,jsxs as sV}from"react/jsx-runtime";function U9({value:$,completionSources:Y,onEdit:X}){return cZ("p",{onDoubleClick:X,children:rV($,Y)})}function rV($,Y){let X=q9($,Y);if(X.length===1&&X[0].kind==="text")return $;return X.map((Z,J)=>Z.kind==="token"?sV("span",{className:"documint-mention",children:[Z.trigger,Z.label]},J):cZ(aV,{children:Z.text},J))}import{Children as aZ,isValidElement as rZ,useEffect as iV,useRef as oV,useState as nV}from"react";import{jsx as V0,jsxs as N9}from"react/jsx-runtime";var G9=($)=>{$.preventDefault()},V9=($)=>$.isPrimary&&$.button===0;function tV({children:$}){return V0("div",{className:"documint-leaf-toolbar",children:aZ.map($,eV)})}function eV($){if(!rZ($))return null;if($.type===iZ){let Y=$.props;return V0(sZ,{children:V0($N,{...Y})})}if($.type===oZ){let{className:Y}=$.props;return V0("div",{className:Y5("documint-leaf-toolbar-divider",Y)})}if($.type===nZ){let Y=$.props;return V0(YN,{...Y})}return null}function $N({active:$=!1,className:Y,disabled:X=!1,icon:Z,label:J,onClick:K}){return V0("button",{"aria-label":J,className:Y5("documint-leaf-toolbar-button",$?"active":null,Y),disabled:X,onPointerDown:(Q)=>{if(G9(Q),!X&&V9(Q))K()},title:J,type:"button",children:V0(Z,{size:15,strokeWidth:2.2})})}function YN({children:$,className:Y,icon:X,label:Z,onSelect:J}){let K=oV(null),[Q,M]=nV(!1);return iV(()=>{if(!Q)return;let D=(q)=>{if(K.current&&q.target instanceof Node&&!K.current.contains(q.target))M(!1)};return window.addEventListener("pointerdown",D),()=>{window.removeEventListener("pointerdown",D)}},[Q]),V0(sZ,{children:N9("div",{className:"documint-leaf-toolbar-menu-shell",ref:K,children:[V0(XN,{className:Y,icon:X,isOpen:Q,label:Z,onClick:()=>M((D)=>!D)}),Q?V0("div",{className:"documint-leaf-menu",role:"menu",children:aZ.map($,(D)=>ZN(D,(q)=>{M(!1),J(q)}))}):null]})})}function XN({className:$,icon:Y,isOpen:X,label:Z,onClick:J}){return N9("button",{"aria-expanded":X,"aria-haspopup":"menu","aria-label":Z,className:Y5("documint-leaf-toolbar-button",X?"active":null,$),onPointerDown:(K)=>{if(G9(K),V9(K))J()},title:Z,type:"button",children:[V0(Y,{size:15,strokeWidth:2.2}),V0(L4,{className:Y5("documint-leaf-toolbar-menu-chevron",X?"is-open":null),size:13,strokeWidth:2.2})]})}function ZN($,Y){if(!rZ($))return null;if($.type===eZ){let{className:Q}=$.props;return V0("div",{className:Y5("documint-leaf-menu-divider",Q),role:"separator"})}if($.type!==tZ)return null;let{disabled:X=!1,icon:Z,text:J,value:K}=$.props;return N9("button",{className:"documint-leaf-menu-item",disabled:X,onPointerDown:(Q)=>{if(G9(Q),!X&&V9(Q))Y(K)},role:"menuitem",type:"button",children:[V0(Z,{size:15,strokeWidth:2.2}),V0("span",{children:J})]})}function Y5(...$){return $.filter(Boolean).join(" ")}function sZ({children:$}){return V0("div",{className:"documint-leaf-toolbar-group",children:$})}function iZ($){return null}function oZ($){return null}function nZ($){return null}function tZ($){return null}function eZ($){return null}var d=Object.assign(tV,{Button:iZ,Divider:oZ,Menu:nZ,MenuDivider:eZ,MenuItem:tZ});import{jsx as o,jsxs as o0,Fragment as MN}from"react/jsx-runtime";var JN=!1,KN=220,c1=()=>{};function A9($){let Y=$.mode==="create",X=$.mode==="create"?$:null,Z=$.mode==="thread"?$:null,J=$.canEdit,K=$.link,Q=Z?.thread??null,M=Q?.comments??[],D=M[0]??null,q=Q?U1(Q):!1,U=Z?.animateInitialComment??!1,[V,G]=d1(null),[N,A]=d1(""),[_,z]=d1(""),[F,B]=d1(""),[W,S]=d1(!U),[b,k]=d1(JN),[P,y]=d1(!1),E=$J(null),w=$J(null),C=$.mentionSources,T=Q?P8(Q):null,H=T?YJ(T):"",R=J&&!q,u=R&&N.trim().length>0,g=R&&_.trim().length>0,I=J&&F.trim().length>0,j=Y||P,O=!Y||b,v=!Y&&Boolean(Q),f=Boolean(D),a=Y?b:!0,x=Z?.onDeleteComment??c1,E0=Z?.onDeleteThread??c1,t0=Z?.onToggleResolved??c1,u0=X?.activeMarks??[],g0=X?.onToggleBold??c1,e0=X?.onToggleItalic??c1,c6=X?.onToggleStrikethrough??c1,a6=X?.onToggleUnderline??c1,D5=J?Y?"Add a comment":"Reply to this comment":"Comment editing is disabled",r6=Y?F:_;h6(()=>{if(V!==null&&(V<0||V>=M.length))G(null),A("")},[M.length,V]),h6(()=>{if(!f||!U){S(!0);return}S(!1);let r=requestAnimationFrame(()=>{S(!0)});return()=>{cancelAnimationFrame(r)}},[U,D,f]),h6(()=>{if(!Z||!U){y(!1);return}y(!0);let r=window.setTimeout(()=>{y(!1)},KN);return()=>{window.clearTimeout(r)}},[U,Z]),h6(()=>{if(!Y||!b||!J)return;let r=requestAnimationFrame(()=>{w.current?.focus()});return()=>{cancelAnimationFrame(r)}},[J,Y,b]);let u2=()=>{G(null),A("")},U5=(r,G5)=>{if(!v||!R)return;G(r),A(G5)},I0=(r)=>{if(!Z)return;Z.onEditComment(r,N),u2()},w0=()=>{if(!Z)return;Z.onReply(_),z("")},s1=()=>{if(!X||!I)return;X.onCreateThread(F),B("")},s6=j?`documint-comment-leaf documint-comment-leaf-create${a?" is-expanded":""}`:"documint-comment-leaf",i1=v||f||O?o(QN,{canCreate:I,canEdit:J,canMutateThread:R,canReply:g,canSaveEditedComment:u,comments:M,composerRef:w,editDraft:N,editingCommentIndex:V,isComposerVisible:O,isInitialCommentVisible:W,isResolved:q,link:K,mentionSources:C,mode:$.mode,onBeginEditingComment:U5,onCancelEditing:u2,onChangeCreateDraft:B,onChangeEditDraft:A,onChangeReplyDraft:z,onDeleteComment:x,onDeleteThread:E0,onSubmitCreate:s1,onSubmitEditedComment:I0,onSubmitReply:w0,onToggleResolved:t0,rootComment:D,showRootComment:f,showThreadChrome:v,threadAge:H,composerPlaceholder:D5,composerValue:r6}):null;return o("div",{className:s6,ref:E,children:o0("div",{className:j?"documint-comment-leaf-create-shell":void 0,children:[j?o0(d,{children:[o(d.Button,{className:"documint-comment-leaf-create-button",icon:p4,label:"Add comment",onClick:()=>k(!0)}),o(d.Divider,{className:"documint-comment-leaf-create-divider"}),o(d.Button,{active:u0.includes("bold"),className:"documint-comment-leaf-create-mark",icon:C4,label:"Bold",onClick:g0}),o(d.Button,{active:u0.includes("italic"),className:"documint-comment-leaf-create-mark",icon:k4,label:"Italic",onClick:e0}),o(d.Button,{active:u0.includes("underline"),className:"documint-comment-leaf-create-mark",icon:c4,label:"Underline",onClick:a6}),o(d.Button,{active:u0.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:l4,label:"Strikethrough",onClick:c6})]}):null,o("div",{className:j?"documint-comment-leaf-create-content":void 0,children:i1})]})})}function QN({canCreate:$,canEdit:Y,canMutateThread:X,canReply:Z,canSaveEditedComment:J,comments:K,composerRef:Q,editDraft:M,editingCommentIndex:D,isComposerVisible:q,isInitialCommentVisible:U,isResolved:V,link:G,mentionSources:N,mode:A,onBeginEditingComment:_,onCancelEditing:z,onChangeCreateDraft:F,onChangeEditDraft:B,onChangeReplyDraft:W,onDeleteComment:S,onDeleteThread:b,onSubmitCreate:k,onSubmitEditedComment:P,onSubmitReply:y,onToggleResolved:E,rootComment:w,showRootComment:C,showThreadChrome:T,threadAge:H,composerPlaceholder:R,composerValue:u}){return o0(MN,{children:[T?o0("div",{className:"documint-comment-leaf-header",children:[o("span",{className:"documint-comment-leaf-age",children:H}),o0("div",{className:"documint-comment-leaf-actions",children:[o("button",{className:"documint-leaf-action","aria-label":V?"Reopen comment":"Resolve comment",disabled:!Y,onClick:E,title:V?"Reopen comment":"Resolve comment",type:"button",children:o(I1,{size:14,strokeWidth:2.2})}),o("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!Y,onClick:b,title:"Delete comment thread",type:"button",children:o(L0,{size:14,strokeWidth:2.2})})]})]}):null,T&&G?o0("div",{className:"documint-comment-leaf-link",children:[G.title?o("div",{className:"documint-link-leaf-title",children:G.title}):null,o("div",{className:"documint-link-leaf-url",children:G.url})]}):null,o0("div",{className:`documint-comment-thread${C?"":" is-empty"}`,children:[o("article",{className:C?`documint-comment-message documint-comment-message-root${U?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:w?o(U9,{completionSources:N,onEdit:()=>_(0,w.body),value:w.body}):null}),K.slice(1).map((g,I)=>{let j=I+1,O=D===j;return o0("article",{className:"documint-comment-message",children:[!O?o0("div",{className:"documint-comment-message-meta",children:[o("span",{children:YJ(g.updatedAt)}),X?o0("div",{className:"documint-comment-leaf-actions",children:[o("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!X,onClick:()=>{_(j,g.body)},title:"Edit comment",type:"button",children:o(p1,{size:14,strokeWidth:2.2})}),o("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!X,onClick:()=>S(j),title:"Delete comment",type:"button",children:o(L0,{size:14,strokeWidth:2.2})})]}):null]}):null,O?o($5,{actions:{kind:"edit",onCancel:z,onSave:()=>P(j),saveDisabled:!J},completionSources:N,onChange:B,readOnly:!Y,rows:3,value:M}):o(U9,{completionSources:N,onEdit:()=>_(j,g.body),value:g.body})]},`${g.updatedAt}:${j}`)})]}),o("div",{className:`documint-comment-reply${T?"":" is-standalone"}${q?" is-visible":""}`,children:o($5,{actions:A==="create"?{kind:"compose",onSubmit:k,submitDisabled:!$,submitLabel:"Create comment"}:{kind:"compose",onSubmit:y,submitDisabled:!Z,submitLabel:"Reply"},completionSources:N,onChange:A==="create"?F:W,placeholder:R,readOnly:!Y,ref:Q,rows:3,value:u})})]})}function YJ($){let Y=new Date($);if(Number.isNaN(Y.getTime()))return $;let X=Y.getTime()-Date.now(),Z=60000,J=60*Z,K=24*J,Q=7*K,M=30*K,D=365*K,q=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(X)<Z)return"just now";if(Math.abs(X)<J)return q.format(Math.round(X/Z),"minute");if(Math.abs(X)<K)return q.format(Math.round(X/J),"hour");if(Math.abs(X)<Q)return q.format(Math.round(X/K),"day");if(Math.abs(X)<D)return q.format(Math.round(X/M),"month");return q.format(Math.round(X/D),"year")}import{jsx as k0,jsxs as UN}from"react/jsx-runtime";var qN=[{icon:R4,label:"Heading 1",text:"# "},{icon:b4,label:"Heading 2",text:"## "},{icon:S4,label:"Heading 3",text:"### "},{icon:v4,label:"Heading 4",text:"#### "},{icon:f4,label:"Heading 5",text:"##### "},{icon:m4,label:"Heading 6",text:"###### "}],DN=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function XJ({onInsert:$,onInsertTable:Y}){return UN(d,{children:[k0(d.Button,{icon:I4,label:"Insert bulleted list",onClick:()=>$("- ")}),k0(d.Button,{icon:u4,label:"Insert numbered list",onClick:()=>$("1. ")}),k0(d.Button,{icon:g4,label:"Insert task list",onClick:()=>$("- [ ] ")}),k0(d.Divider,{}),k0(d.Menu,{icon:h4,label:"Insert heading",onSelect:$,children:qN.map(({icon:X,label:Z,text:J})=>k0(d.MenuItem,{icon:X,text:Z,value:J},J))}),k0(d.Menu,{icon:W1,label:"Insert table",onSelect:(X)=>Y(Number(X)),children:DN.map(({columns:X,text:Z})=>k0(d.MenuItem,{icon:W1,text:Z,value:String(X)},X))}),k0(d.Divider,{}),k0(d.Button,{icon:d4,label:"Insert blockquote",onClick:()=>$("> ")}),k0(d.Button,{icon:x4,label:"Insert divider",onClick:()=>$("--- ")})]})}import{jsx as _9,jsxs as GN}from"react/jsx-runtime";function ZJ({anchor:$,children:Y,status:X="default"}){let Z=!$.isSelection;return _9(m6,{children:GN("div",{className:"documint-leaf-anchor","data-selection":$.isSelection?"true":"false",onPointerEnter:$.onPointerEnter,onPointerLeave:$.onPointerLeave,style:{left:`${$.left}px`,top:`${$.top}px`},children:[Z?_9("div",{className:"documint-leaf-bridge"}):null,_9("div",{className:"documint-leaf-shell","data-status":X,children:Y})]})})}import{useEffect as JJ,useRef as VN,useState as KJ}from"react";import{jsx as K1,jsxs as H9}from"react/jsx-runtime";function QJ({canEdit:$,onDelete:Y,onSave:X,title:Z,url:J}){let[K,Q]=KJ(J),[M,D]=KJ(!1),q=VN(null),U=NN(),V=K.trim(),G=$&&V.length>0,N=$&&!M,A=`${U}click to open`,_=`documint-link-leaf-row${M?" is-editing":""}`;return JJ(()=>{if(M)return;Q(J)},[M,J]),JJ(()=>{if(!M)return;q.current?.focus()},[M]),H9("div",{className:"documint-link-leaf",children:[Z?K1("div",{className:"documint-link-leaf-title",children:Z}):null,H9("div",{className:_,children:[M?K1($5,{actions:{kind:"edit",onCancel:()=>{Q(J),D(!1)},onSave:()=>{X(V),D(!1)},saveDisabled:!G},onChange:Q,readOnly:!$,ref:q,rows:3,value:K}):K1("div",{className:"documint-link-leaf-url",children:J}),N?H9("div",{className:"documint-link-leaf-actions",children:[K1("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!$)return;Q(J),D(!0)},title:"Edit link",type:"button",children:K1(p1,{size:14,strokeWidth:2.2})}),K1("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:Y,title:"Remove link",type:"button",children:K1(L0,{size:14,strokeWidth:2.2})})]}):null]}),K1("div",{className:"documint-link-leaf-divider"}),K1("div",{className:"documint-link-leaf-hint",children:A})]})}function NN(){if(typeof navigator>"u")return"Ctrl+";let $=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test($)?"CMD+":"CTRL+"}import{jsx as Q1,jsxs as E9}from"react/jsx-runtime";var AN=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],_N=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],z9={text:"Delete column",value:"delete"},F9={text:"Delete row",value:"delete"},MJ={text:"Delete table",value:"delete"};function qJ({canDeleteColumn:$,canDeleteRow:Y,onDeleteColumn:X,onDeleteRow:Z,onDeleteTable:J,onInsertColumn:K,onInsertRow:Q}){return E9(d,{children:[E9(d.Menu,{icon:z1,label:"Column actions",onSelect:(M)=>{if(M===z9.value){X();return}K(M)},children:[AN.map(({text:M,value:D})=>Q1(d.MenuItem,{icon:L2,text:M,value:D},D)),Q1(d.MenuDivider,{}),Q1(d.MenuItem,{disabled:!$,icon:L0,text:z9.text,value:z9.value})]}),E9(d.Menu,{icon:F1,label:"Row actions",onSelect:(M)=>{if(M===F9.value){Z();return}Q(M)},children:[_N.map(({text:M,value:D})=>Q1(d.MenuItem,{icon:L2,text:M,value:D},D)),Q1(d.MenuDivider,{}),Q1(d.MenuItem,{disabled:!Y,icon:L0,text:F9.text,value:F9.value})]}),Q1(d.Divider,{}),Q1(d.Menu,{icon:W1,label:"Table actions",onSelect:()=>J(),children:Q1(d.MenuItem,{icon:L0,text:MJ.text,value:MJ.value})})]})}import{useEffect as DJ,useEffectEvent as UJ,useLayoutEffect as GJ,useMemo as HN,useRef as W9,useState as VJ}from"react";function k6($,Y){if(!$||$.kind==="task-toggle")return null;if($.commentThreadIndex!==null){let X=Y[$.commentThreadIndex]??null;if(!X)return null;return{kind:"comment",left:$.anchorLeft,link:$.kind==="link"?{title:$.title,url:$.url}:null,thread:X,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 zN=600,FN=530,m2=24;function AJ({canShowInsertionLeaf:$,canShowTableLeaf:Y,commentState:X,editorState:Z,editorViewportState:J,getScrollTop:K,layoutWidth:Q,onVisibilityChange:M,resources:D,scrollContentHeight:q,scrollTo:U,viewportHeight:V}){let G=HN(()=>Y0(Z),[Z]),[N,A]=VJ(null),[_,z]=VJ(null),F=G.start.regionId===G.end.regionId&&G.start.offset===G.end.offset,B=W9(!0),W=W9(0),S=W9(null),b=UJ(()=>{M()}),k=UJ(()=>{W.current=typeof performance<"u"?performance.now():Date.now(),B.current=!0,b()});return GJ(()=>{let P=EN({canShowInsertionLeaf:$,canShowTableLeaf:Y,commentState:X,normalizedSelection:G,state:Z,viewport:J.get()});A((y)=>TN(y,P)?y:P)},[$,Y,X,Z,J]),GJ(()=>{let P=D?wN(Z,J.get(),G,D):null;z((y)=>ON(y,P)?y:P)},[Z,J,G,D]),DJ(()=>{let P=Z.selection.focus,y={layoutWidth:Q,offset:P.offset,regionId:P.regionId,scrollContentHeight:q,viewportHeight:V};if(jN(S.current,y))return;let E=x3(Z,J.get(),P);if(!E)return;let w=K(),C=w+m2,T=w+V-m2;if(E.top<C){let H=U(Math.max(0,E.top-m2));if(NJ(E,H,V,m2))S.current=y;return}if(E.top+E.height>T){let H=U(Math.max(0,E.top+E.height-V+m2));if(NJ(E,H,V,m2))S.current=y;return}S.current=y},[Z,Z.selection.focus.offset,Z.selection.focus.regionId,J,Q,q,U,V]),DJ(()=>{if(B.current=!0,b(),!F||typeof window>"u")return;let P=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-W.current<zN){if(!B.current)B.current=!0,b();return}B.current=!B.current,b()},FN);return()=>{window.clearInterval(P)}},[F]),{imageAtCursor:_,leaf:N,isVisible:()=>B.current,markActivity:k}}function EN({canShowInsertionLeaf:$,canShowTableLeaf:Y,commentState:X,normalizedSelection:Z,state:J,viewport:K}){if(!K)return null;let Q=J.selection.focus;if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let M=$?yN(J,K):null;if(M)return M;let D=Y?WN(J,K):null;if(D)return D;return k6(p3(J,K,Q,X.liveRanges),X.threads)}function WN($,Y){let X=$.selection.focus,Z=$.documentIndex.regionIndex.get(X.regionId),J=Z?$.documentIndex.tableCellIndex.get(Z.id)??null:null;if(!Z||!J)return null;let K=$.documentIndex.blockIndex.get(Z.blockId),Q=K?.type==="table"?$.documentIndex.document.blocks[K.rootIndex]:null;if(!K||!Q||Q.type!=="table")return null;let M=J1($,Y,X),D=PN(Y,Z.id),q=Math.max(1,...Q.rows.map((U)=>U.cells.length));return M&&D!==null?{cellIndex:J.cellIndex,columnCount:q,kind:"table",left:D,rowCount:Q.rows.length,rowIndex:J.rowIndex,top:M.top+M.height}:null}function PN($,Y){let X=$.layout.lines.find((Z)=>Z.regionId===Y);return X?X.left:null}function yN($,Y){let X=$.selection.focus,Z=$.documentIndex.regionIndex.get(X.regionId);if(!Z||Z.blockType!=="paragraph"||Z.text.length>0)return null;if(X.offset!==0)return null;let J=$.documentIndex.blockIndex.get(Z.blockId);if(!J||J.parentBlockId!==null)return null;let K=J1($,Y,X);return K?{kind:"insertion",left:K.left,top:K.top+K.height}:null}function TN($,Y){if($===Y)return!0;if(!$||!Y||$.kind!==Y.kind)return!1;switch($.kind){case"comment":return Y.kind==="comment"&&$.left===Y.left&&$.link?.title===Y.link?.title&&$.link?.url===Y.link?.url&&$.thread===Y.thread&&$.threadIndex===Y.threadIndex&&$.top===Y.top;case"insertion":return Y.kind==="insertion"&&$.left===Y.left&&$.top===Y.top;case"link":return Y.kind==="link"&&$.endOffset===Y.endOffset&&$.left===Y.left&&$.regionId===Y.regionId&&$.startOffset===Y.startOffset&&$.title===Y.title&&$.top===Y.top&&$.url===Y.url;case"table":return Y.kind==="table"&&$.cellIndex===Y.cellIndex&&$.columnCount===Y.columnCount&&$.left===Y.left&&$.rowCount===Y.rowCount&&$.rowIndex===Y.rowIndex&&$.top===Y.top}}function jN($,Y){return $?.layoutWidth===Y.layoutWidth&&$.regionId===Y.regionId&&$.offset===Y.offset&&$.scrollContentHeight===Y.scrollContentHeight&&$.viewportHeight===Y.viewportHeight}function NJ($,Y,X,Z){return $.top>=Y+Z&&$.top+$.height<=Y+X-Z}function wN($,Y,X,Z){if(!Y)return null;if(X.start.regionId!==X.end.regionId||X.start.offset!==X.end.offset)return null;let J=R5($);if(!J)return null;let K=j4($,Y,Z,J),Q=J.image?Z.images.get(J.image.url)?.intrinsicWidth??null:null,M=$.selection.anchor.regionId;return K?{bounds:K,maxWidth:Q,regionId:M,run:J}:null}function ON($,Y){if($===Y)return!0;if(!$||!Y)return!1;return $.regionId===Y.regionId&&$.maxWidth===Y.maxWidth&&$.bounds.left===Y.bounds.left&&$.bounds.top===Y.bounds.top&&$.bounds.width===Y.bounds.width&&$.bounds.height===Y.bounds.height}import{useMemo as P9,useRef as X5,useEffectEvent as y9}from"react";var BN=48;function _J($,Y,X){let Z=X5(null),J=X5(null),K=X5(null),Q=X5(null),M=X5(1),D=y9((N,A)=>{if(!$)return;N.preventDefault(),N.stopPropagation(),N.currentTarget.setPointerCapture(N.pointerId),Q.current=N.pointerId,Z.current=N.clientX,J.current=N.clientY,K.current=$.run.image?.width??$.bounds.width,M.current=A}),q=y9((N)=>{if(Q.current!==N.pointerId||Z.current===null||J.current===null||K.current===null||!$?.run.image)return;let A=N.clientX-Z.current,_=N.clientY-J.current,z=Math.min($.maxWidth??1/0,Math.max(BN,Math.round(K.current+M.current*(A+_)))),F=r$(Y,$.regionId,$.run,z);if(F)X(F)}),U=y9((N)=>{if(N.currentTarget.hasPointerCapture(N.pointerId))N.currentTarget.releasePointerCapture(N.pointerId);Q.current=null,Z.current=null,J.current=null,K.current=null}),V=P9(()=>({onPointerDown:(N)=>D(N,-1),onPointerMove:q,onPointerUp:U,onPointerCancel:U}),[]),G=P9(()=>({onPointerDown:(N)=>D(N,1),onPointerMove:q,onPointerUp:U,onPointerCancel:U}),[]);return P9(()=>{if(!$)return null;let{bounds:N}=$;return{start:{left:N.left,top:N.top,props:V},end:{left:N.left+N.width,top:N.top+N.height,props:G}}},[$])}import{useEffect as HJ,useEffectEvent as zJ,useMemo as FJ,useRef as CN,useState as LN}from"react";function EJ($,Y){let[X,Z]=LN(new Map),J=zJ((D)=>{if(typeof Image>"u")return;let q=[...X.keys()].filter((U)=>!D.has(U));if(q.length>0)Z((U)=>{let V=new Map(U);for(let G of q)V.delete(G);return V});for(let U of D){let V=X.get(U)?.status;if(V==="loaded"||V==="loading")continue;Z((G)=>T9(G,U,Z5("loading"))),RN(U,Y).then((G)=>{Z((N)=>{if(!N.has(U))return G?.close(),N;return T9(N,U,G?Z5("loaded",G):Z5("error"))})})}});HJ(()=>{J($)},[$]);let K=CN(new Map);HJ(()=>{for(let[D,q]of K.current)if(!X.has(D))q.source?.close();K.current=X},[X]);let Q=zJ(async(D)=>{if(!Y?.writeFile)return null;try{let q=await Y.writeFile(D),U=await createImageBitmap(D).catch(()=>null);return Z((V)=>T9(V,q,U?Z5("loaded",U):Z5("error"))),q}catch{return null}}),M=FJ(()=>X.size===0?null:{images:X},[X]);return FJ(()=>({resources:M,persistImage:Q}),[M,Q])}async function RN($,Y){if(/^(https?:|data:|blob:)/i.test($))return bN($);if(!Y?.readFile)return null;try{let X=await Y.readFile($);return X?await createImageBitmap(X):null}catch{return null}}function bN($){return new Promise((Y)=>{let X=new Image;X.decoding="async",X.crossOrigin="anonymous",X.onload=async()=>{try{Y(await createImageBitmap(X))}catch{Y(null)}},X.onerror=()=>Y(null),X.src=$})}function T9($,Y,X){let Z=new Map($);return Z.set(Y,X),Z}function Z5($,Y){return{intrinsicHeight:Y?.height??0,intrinsicWidth:Y?.width??0,source:Y??null,status:$}}import{useEffect as WJ,useEffectEvent as F0,useRef as J5,useState as SN}from"react";var vN=48;function PJ({applyNextState:$,autoScrollDuringDrag:Y,canvasRef:X,commentState:Z,editorStateRef:J,editorViewportState:K,focusInput:Q,onActivity:M,readCurrentState:D,resolvePoint:q}){let[U,V]=SN(null),G=J5(null),N=J5(!1),A=J5(null),_=J5(null),z=J5(null),F=k6(U,Z.threads),B=U?.kind==="task-toggle"||F?.kind==="link"?"pointer":"text";WJ(()=>{if(U&&U.kind!=="task-toggle"&&!F)V(null)},[U,F]),WJ(()=>()=>{if(G.current!==null)window.clearTimeout(G.current)},[]);let W=F0(()=>{if(G.current!==null)window.clearTimeout(G.current),G.current=null}),S=F0(()=>{W(),G.current=window.setTimeout(()=>{if(G.current=null,!N.current)V(null)},vN)}),b=F0(()=>{if(!N.current)W(),V(null)}),k=F0((j)=>{if(!j){b();return}if(j.kind==="task-toggle"){W(),V((O)=>O?.kind==="task-toggle"&&O.listItemId===j.listItemId?O:j);return}if(j.commentThreadIndex!==null){if(!(Z.threads[j.commentThreadIndex]??null)){b();return}W();let v=j.commentThreadIndex;V((f)=>f?.kind!=="task-toggle"&&f?.commentThreadIndex===v?f:j);return}if(j.kind!=="link"){b();return}W(),V((O)=>O?.kind==="link"&&O.title===j.title&&O.url===j.url&&O.startOffset===j.startOffset&&O.endOffset===j.endOffset?O:j)}),P=F0((j)=>{let O=J.current;if(!O)return null;let v=q(j);if(!v)return null;return I3(O,K.get(),v,Z.liveRanges)}),y=F0((j)=>{let O=X.current;if(O&&A.current===j)O.releasePointerCapture(j)}),E=F0(()=>{A.current=null,_.current=null}),w=F0((j)=>{y(j.pointerId),E()}),C=F0((j)=>{if(z.current=j.pointerType,j.pointerType==="touch")return;let O=X.current,v=D(),f=q(j);if(!f)return;if(P(j)?.kind==="task-toggle")return;let x=F6(v,K.get(),f);if(!O||!x)return;if(A.current=j.pointerId,M(),O.setPointerCapture(j.pointerId),j.shiftKey)_.current=v.selection.anchor,$(p$(v,x.regionId,x.offset));else _.current={offset:x.offset,regionId:x.regionId},$(K0(v,{offset:x.offset,regionId:x.regionId}));Q({offset:x.offset,regionId:x.regionId})}),T=F0((j)=>{let O=_.current,v=D(),f=q(j);if(!f)return;if(A.current!==j.pointerId||!O){k(P(j));return}let a=w4(v,K.get(),f,O);if(!a)return;M(),Y(j),$(K0(v,{anchor:O,focus:a}))}),H=F0(()=>{if(!N.current)S()}),R=F0((j)=>{let O=z.current==="touch";z.current=null;let v=P(j);if(v?.kind==="task-toggle"){let E0=D(),t0=t$(E0,v.listItemId);if(t0)j.preventDefault(),j.stopPropagation(),M(),$(t0);return}if(v?.kind==="link"&&(j.metaKey||j.ctrlKey)){j.preventDefault(),j.stopPropagation(),j.currentTarget.ownerDocument.defaultView?.open(v.url,"_blank","noopener,noreferrer");return}if(!O){Q();return}let f=D(),a=q(j),x=a?F6(f,K.get(),a):null;if(x)M(),$(K0(f,{offset:x.offset,regionId:x.regionId})),Q({offset:x.offset,regionId:x.regionId});else Q()}),u=F0((j)=>{let O=D(),v=q(j),f=P(j);if(!v||f?.kind==="task-toggle")return;let a=g3(O,K.get(),v);if(!a)return;j.preventDefault(),j.stopPropagation(),M(),$(K0(O,a)),Q()}),g=F0(()=>{N.current=!0,W()}),I=F0(()=>{N.current=!1,S()});return{canvasHandlers:{onClick:R,onDoubleClick:u,onPointerCancel:w,onPointerDown:C,onPointerLeave:H,onPointerMove:T,onPointerUp:w},cursor:B,leaf:F,leafHandlers:{onPointerEnter:g,onPointerLeave:I}}}import{useEffect as w9,useEffectEvent as N0,useLayoutEffect as fN,useRef as TJ,useState as mN}from"react";import{useEffect as Sv1}from"react";var j9=[{key:"Backspace",command:"deleteBackward"},{key:"Enter",shiftKey:!0,command:"insertSoftLineBreak"},{key:"Enter",command:"insertLineBreak"},{key:"Home",command:"moveToLineStart"},{key:"End",command:"moveToLineEnd"},{key:"Tab",command:"indent"},{key:"Tab",shiftKey:!0,command:"dedent"},{key:"ArrowLeft",modKey:!0,shiftKey:"any",command:"moveToLineStart"},{key:"ArrowRight",modKey:!0,shiftKey:"any",command:"moveToLineEnd"},{key:"ArrowUp",modKey:!0,shiftKey:"any",command:"moveToDocumentStart"},{key:"ArrowDown",modKey:!0,shiftKey:"any",command:"moveToDocumentEnd"},{key:"ArrowUp",altKey:!0,shiftKey:!0,command:"moveListItemUp"},{key:"ArrowDown",altKey:!0,shiftKey:!0,command:"moveListItemDown"},{key:"a",modKey:!0,command:"selectAll"},{key:"b",modKey:!0,command:"toggleBold"},{key:"e",modKey:!0,command:"toggleCode"},{key:"i",modKey:!0,command:"toggleItalic"},{key:"u",modKey:!0,command:"toggleUnderline"},{key:"y",modKey:!0,command:"redo"},{key:"z",modKey:!0,command:"undo"},{key:"z",modKey:!0,shiftKey:!0,command:"redo"}];function yJ($,Y=j9){return Y.find((X)=>{let Z=X.shiftKey==="any"?!0:(X.shiftKey??!1)===($.shiftKey??!1);return X.key.toLowerCase()===$.key.toLowerCase()&&(X.altKey??!1)===($.altKey??!1)&&Z&&(X.modKey??!1)===Boolean($.metaKey||$.ctrlKey)})?.command??null}var hN=1024,jJ=16;function BJ({applyNextState:$,editorState:Y,editorStateRef:X,editorViewportState:Z,inputRef:J,keybindings:K,onActivity:Q,onImagePaste:M}){let D=kN(),q=()=>X.current??Y,U=TJ(!1),V=TJ(!1),G=N0((H)=>{if(!H)return;Q(),$(H)}),N=N0(()=>{let H=J.current;if(!H)return;if(typeof document>"u")return;let R=document.execCommand;if(typeof R!=="function")return;try{U.current=!0,R.call(document,"insertText",!1,""),R.call(document,"delete")}catch{}finally{U.current=!1,K5(H,q())}}),A=N0(()=>{if(V.current)return;V.current=!0,N()}),_=N0(()=>{N()}),z=N0((H)=>{if(!D)return;let R=J.current;if(!R)return;let u=Z.get(),g=J1(q(),u,H);if(!g)return;R.style.top=`${g.top}px`,R.style.left=`${g.left}px`,R.style.height=`${g.height}px`}),F=N0((H)=>{let R=J.current;if(!R)return;z(H??q().selection.focus),R.focus({preventScroll:!D}),K5(R,q()),A()}),B=N0((H,R)=>{let g=OJ(R,u6(H)).replace(/\r\n/g,`
|
|
34
|
+
`).split(/(\n)/),I=H;for(let j of g){if(j.length===0)continue;let O=j===`
|
|
35
|
+
`?a5(I):N4(I,j);if(!O)continue;I=O}return I===H?null:I}),W=N0((H,R,u)=>{let g=H.selection.focus,I={regionId:g.regionId,offset:Math.max(0,g.offset-R)},j=K0(H,{anchor:I,focus:g});return r5(j,u)}),S=N0((H)=>{if(U.current)return;let R=q(),u=IN(H.inputType);if(H.inputType==="insertText"){if(!H.data)return;H.preventDefault();let g=wJ(H.target);if(g>0){G(W(R,g,H.data));return}let I=gN(R,H.data);if(I>0){let j=H.data.slice(I);if(j.length>0)G(B(R,j));return}G(B(R,H.data));return}if(H.inputType==="insertReplacementText"){if(!H.data)return;H.preventDefault();let g=wJ(H.target);G(W(R,g,H.data));return}if(uN(H.inputType)){H.preventDefault(),G(a5(R));return}if(u==="backward"){H.preventDefault(),G(G3(R));return}if(u==="forward"){H.preventDefault(),G(V3(R));return}if(H.inputType==="historyUndo"){H.preventDefault(),G(A3(R)),_();return}if(H.inputType==="historyRedo"){H.preventDefault(),G(_3(R)),_();return}}),b=N0((H)=>{let R=q(),u=H.currentTarget.value,g=u6(R);if(U.current)return;if(OJ(u,g).length===0){K5(H.currentTarget,R);return}G(B(R,u))}),k=N0((H)=>{let R=xN(q(),Z.get(),H.nativeEvent,K);if(!R)return;H.preventDefault(),G(R)}),P=N0((H)=>{let R=N3(q());if(!R)return;H.preventDefault(),H.clipboardData.setData("text/plain",f6(R))}),y=N0((H)=>{let R=q(),u=N3(R);if(!u)return;H.preventDefault(),H.clipboardData.setData("text/plain",f6(u)),G(U3(R))}),E=N0(async(H)=>{let u=(M?[...H.clipboardData.items].find((j)=>j.kind==="file"&&j.type.startsWith("image/")):void 0)?.getAsFile()??null;if(u&&M){H.preventDefault();let j=await M(u);if(j)G(a$(q(),j));return}let g=H.clipboardData.getData("text/plain");if(g.length===0)return;H.preventDefault();let I=K9(g);G(I$(q(),I,g))}),w=N0(()=>{Q();let H=J.current;if(H)K5(H,q())}),C=N0((H)=>{if(Q(),H.target.matches(":focus-visible"))F()});w9(()=>{let H=J.current;if(!H)return;K5(H,Y)},[Y,J]),fN(()=>{z(Y.selection.focus)},[Y,z]),w9(()=>{let H=J.current;if(!H)return;let R=(u)=>S(u);return H.addEventListener("beforeinput",R),()=>H.removeEventListener("beforeinput",R)},[J,S]);let T={onCopy:P,onCut:y,onPaste:E,...D?{}:{onKeyDown:k}};return{canvasHandlers:{...T,onFocus:C},focus:F,inputHandlers:{...T,onFocus:w,onInput:b}}}var CJ="";function kN(){let[$,Y]=mN(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return w9(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let X=window.matchMedia("(pointer: coarse)"),Z=(J)=>Y(J.matches);return X.addEventListener?.("change",Z),()=>X.removeEventListener?.("change",Z)},[]),$}function uN($){return $==="insertLineBreak"||$==="insertParagraph"}function wJ($){let Y=$,X=Y?.selectionStart??0,Z=Y?.selectionEnd??X;return Math.max(0,Z-X)}function gN($,Y){if(Y.length<jJ)return 0;let X=u6($,Y.length),Z=Math.min(X.length,Y.length);for(let J=Z;J>=jJ;J--)if(X.endsWith(Y.slice(0,J)))return J;return 0}function IN($){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 pN($){return $.replaceAll(CJ,"")}function u6($,Y=hN){let{anchor:X,focus:Z}=$.selection;if(X.regionId!==Z.regionId||X.offset!==Z.offset)return"";let J=$.documentIndex.regionIndex.get(Z.regionId);if(!J)return"";return J.text.slice(Math.max(0,Z.offset-Y),Z.offset)}function OJ($,Y){let X=pN($);return X.startsWith(Y)?X.slice(Y.length):X}function K5($,Y){let X=u6(Y),Z=`${CJ}${X}`;$.value=Z,$.setSelectionRange(Z.length,Z.length)}function xN($,Y,X,Z){if(X.key==="Delete")return V3($);let J=yJ(X,Z);if(J){if(J==="moveToLineStart"||J==="moveToLineEnd")return a3($,Y.layout,J==="moveToLineStart"?"Home":"End",X.shiftKey);if(J==="moveToDocumentStart"||J==="moveToDocumentEnd")return r3($,J==="moveToDocumentStart"?"start":"end",X.shiftKey);switch(J){case"insertLineBreak":return a5($);case"insertSoftLineBreak":return g$($);case"deleteBackward":return G3($);case"indent":return s$($);case"dedent":return i$($);case"moveListItemUp":return o$($);case"moveListItemDown":return n$($);case"toggleBold":return s5($);case"toggleItalic":return i5($);case"toggleStrikethrough":return o5($);case"toggleUnderline":return n5($);case"toggleCode":return l$($);case"undo":return A3($);case"redo":return _3($);case"selectAll":return x$($)}}if(X.key==="ArrowLeft"||X.key==="ArrowRight")return l3($,X.key==="ArrowLeft"?-1:1,X.shiftKey);if(X.key==="ArrowUp"||X.key==="ArrowDown")return d3($,Y.layout,X.key==="ArrowUp"?-1:1,X.shiftKey);if(X.key==="PageUp"||X.key==="PageDown")return c3($,Y.layout,X.key==="PageUp"?-1:1,X.shiftKey);if(X.key.length===1&&!X.altKey&&!X.ctrlKey&&!X.metaKey)return N4($,X.key);return null}import{useEffectEvent as O9,useLayoutEffect as lN,useMemo as dN,useState as cN}from"react";function LJ({editorState:$,editorStateRef:Y,editorViewportState:X,onViewportScroll:Z,scrollContainerRef:J,scheduleOverlayRender:K,userPresence:Q}){let M=dN(()=>{if(!Q||Q.length===0)return;return j5($.documentIndex,Q)},[$.documentIndex,Q]),[D,q]=cN(void 0),U=O9(()=>{if(M===void 0){if(D!==void 0)q(void 0)}else q(d2(Y.current??$,X.get(),M));K()}),V=O9((N)=>{if(M===void 0){if(D!==void 0)q(void 0);return}let A=d2(Y.current??$,N,M);if(aN(D,A))return;q(A)});lN(()=>{U()},[M]);let G=O9((N)=>{if(!N.viewport||N.viewport.status==="unresolved")return;let A=J.current;if(!A)return;A.scrollTop=N.viewport.scrollTop,Z(A)});return{presence:D,scrollToPresence:G,refreshPresence:V}}function aN($,Y){if($===Y)return!0;if($===void 0||Y===void 0||$.length!==Y.length)return!1;return $.every((X,Z)=>{let J=Y[Z];return X.id===J.id&&rN(X.viewport,J.viewport)})}function rN($,Y){if($===Y)return!0;if($===null||Y===null)return!1;if($.status==="unresolved")return Y.status==="unresolved";if(Y.status==="unresolved")return!1;return $.status===Y.status&&$.scrollTop===Y.scrollTop}import{useEffect as sN,useEffectEvent as a1,useRef as Q5}from"react";function RJ({editorStateRef:$,renderContent:Y,renderOverlay:X,renderViewport:Z}){let J=Q5(null),K=Q5(!1),Q=Q5(!1),M=Q5(!1),D=Q5(!1),q=a1(()=>{if(typeof window>"u"){Z();return}K.current=!0,N()}),U=a1(()=>{if(typeof window>"u"){Y(),X();return}Q.current=!0,N()}),V=a1(()=>{if(typeof window>"u"){Y();return}M.current=!0,N()}),G=a1(()=>{if(typeof window>"u"){X();return}D.current=!0,N()}),N=a1(()=>{if(typeof window>"u"||J.current!==null)return;J.current=window.requestAnimationFrame(()=>{A()})}),A=a1(()=>{J.current=null;let z=K.current,F=Q.current,B=M.current,W=D.current;if(K.current=!1,Q.current=!1,M.current=!1,D.current=!1,z){Z(),_();return}if(F){Y(),X(),_();return}if(B)Y(),_();if(W)X()}),_=a1(()=>{let z=$.current;if(!z||!p8(z,performance.now()))return;M.current=!0,N()});return sN(()=>{return()=>{if(typeof window>"u"||J.current===null)return;window.cancelAnimationFrame(J.current),J.current=null}},[]),{scheduleContentPaint:V,scheduleFullPaint:U,scheduleFullRender:q,scheduleOverlayPaint:G}}import{useEffectEvent as B9,useLayoutEffect as kJ,useMemo as C9,useRef as L9,useState as uJ}from"react";function fJ($){let Y=$.documentIndex.regions.find((K)=>K.id===$.selection.anchor.regionId),X=$.documentIndex.regions.find((K)=>K.id===$.selection.focus.regionId),Z=(Y?.start??0)+$.selection.anchor.offset,J=(X?.start??0)+$.selection.focus.offset;return{end:Math.max(Z,J),start:Math.min(Z,J)}}function mJ($){let Y=iN($);if(Y.start.regionId!==Y.end.regionId||Y.start.offset===Y.end.offset)return null;return{endOffset:Y.end.offset,regionId:Y.start.regionId,startOffset:Y.start.offset}}var bJ=28,SJ=18;function hJ($,Y){if(!$)return;let X=$.getBoundingClientRect();if(Y.clientY<X.top+bJ){$.scrollTop=Math.max(0,$.scrollTop-SJ);return}if(Y.clientY>X.bottom-bJ)$.scrollTop+=SJ}function iN($){let Y=vJ($.documentIndex.regions,$.selection.anchor.regionId,$.selection.anchor.offset),X=vJ($.documentIndex.regions,$.selection.focus.regionId,$.selection.focus.offset);return Y<=X?{end:$.selection.focus,start:$.selection.anchor}:{end:$.selection.anchor,start:$.selection.focus}}function vJ($,Y,X){let Z=$.findIndex((J)=>J.id===Y);if(Z===-1)return-1;return Z*1e6+X}function gJ({applyNextState:$,autoScrollDuringDrag:Y,canShowSelectionLeaf:X,editorState:Z,editorStateRef:J,editorViewportState:K,focusInput:Q,onActivity:M,resolvePoint:D,threads:q}){let U=C9(()=>Y0(Z),[Z]),V=C9(()=>mJ(Z),[Z]),G=C9(()=>b5(Z),[Z]),[N,A]=uJ(null),[_,z]=uJ(null),F=L9(null),B=L9(null),W=L9(null);kJ(()=>{let E=oN(Z,K.get(),U);A((w)=>YA(w,E)?w:E)},[Z,K,U.end.offset,U.end.regionId,U.start.offset,U.start.regionId]),kJ(()=>{let E=tN({canShowSelectionLeaf:X,currentLeaf:_,activeMarks:G,handles:N,selectionRange:V,threads:q});z((w)=>$A(w,E)?w:E)},[G,X,N,_,V,q]);let S=B9((E,w=!0)=>{z((C)=>C?.kind==="create"?{animateInitialComment:w,kind:"thread",left:C.left,threadIndex:E,top:C.top}:C)}),b=B9((E)=>{if(E&&W.current===E.pointerId&&E.currentTarget.hasPointerCapture(E.pointerId))E.currentTarget.releasePointerCapture(E.pointerId);F.current=null,B.current=null,W.current=null}),k=B9((E)=>{let w=J.current,C=B.current,T=D(E);if(!T||!w||!C||W.current!==E.pointerId)return;let H=w4(w,K.get(),T,C);if(!H)return;E.preventDefault(),E.stopPropagation(),M(),Y(E),$(K0(w,{anchor:C,focus:H}))}),P=(E)=>({onPointerCancel:(w)=>{b(w)},onPointerDown:(w)=>{let C=J.current??Z,T=ZA(U,E),H=E==="start"?U.start:U.end;if(!N)return;w.preventDefault(),w.stopPropagation(),W.current=w.pointerId,B.current=T,F.current=E,w.currentTarget.setPointerCapture(w.pointerId),M(),Q(),$(K0(C,{anchor:T,focus:H}))},onPointerMove:(w)=>{if(F.current!==E)return;k(w)},onPointerUp:(w)=>{if(F.current===E)k(w);b(w)}});return{handle:N?{start:{...N.start,props:P("start")},end:{...N.end,props:P("end")}}:null,leaf:_,promoteLeafToThread:S}}function oN($,Y,X){if(X.collapsed)return null;let Z=J1($,Y,X.start),J=J1($,Y,X.end);if(!Z||!J)return null;return{end:{left:J.left,top:J.top+J.height},start:{left:Z.left,top:Z.top}}}function nN($,Y,X){return{activeMarks:X,kind:"create",left:Y.start.left,selection:$,top:Y.end.top}}function tN({activeMarks:$,canShowSelectionLeaf:Y,currentLeaf:X,handles:Z,selectionRange:J,threads:K}){if(!Y||!J||!Z)return null;if(X?.kind==="thread")return K[X.threadIndex]?X:null;return nN(J,Z,$)}function eN($,Y){return $?.kind==="create"&&$.left===Y.left&&$.selection.regionId===Y.selection.regionId&&$.selection.startOffset===Y.selection.startOffset&&$.selection.endOffset===Y.selection.endOffset&&XA($.activeMarks,Y.activeMarks)&&$.top===Y.top}function $A($,Y){if($===Y)return!0;if(!$||!Y||$.kind!==Y.kind)return!1;if($.kind==="create"&&Y.kind==="create")return eN($,Y);return $.kind==="thread"&&Y.kind==="thread"&&$.animateInitialComment===Y.animateInitialComment&&$.left===Y.left&&$.threadIndex===Y.threadIndex&&$.top===Y.top}function YA($,Y){if($===Y)return!0;if(!$||!Y)return!1;return $.start.left===Y.start.left&&$.start.top===Y.start.top&&$.end.left===Y.end.left&&$.end.top===Y.end.top}function XA($,Y){return $.length===Y.length&&$.every((X,Z)=>X===Y[Z])}function ZA($,Y){return Y==="start"?$.end:$.start}import{useEffect as JA,useMemo as xJ,useState as KA}from"react";var M5={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)"},q5={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)"},IJ={...M5,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)"},pJ={...q5,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 lJ($){let Y=xJ(()=>MA($),[$]),[X,Z]=KA(Y.light),J=xJ(()=>qA(X),[X]);return JA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){Z(Y.light);return}let K=window.matchMedia("(prefers-color-scheme: dark)"),Q=()=>{Z(K.matches?Y.dark:Y.light)};if(Q(),typeof K.addEventListener==="function")return K.addEventListener("change",Q),()=>{K.removeEventListener("change",Q)};return K.addListener(Q),()=>{K.removeListener(Q)}},[Y]),{theme:X,themeStyles:J}}function QA($){return"light"in $&&"dark"in $}function MA($){if(!$)return{dark:q5,light:M5};if(QA($))return $;return{dark:$,light:$}}function qA($){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 GA,useEffectEvent as n0,useRef as R9,useState as g6}from"react";import{useMemo as DA}from"react";function dJ($){return DA(()=>UA({current:null},$),[$])}function UA($,Y){return{peek(){return $.current},get(){let X=$.current;if(X!==null)return X;let Z=Y();return $.current=Z,Z},invalidate(){$.current=null}}}function cJ($,Y){let X=Y.getBoundingClientRect();return{x:$.clientX-X.left+Y.scrollLeft,y:$.clientY-X.top+Y.scrollTop}}function aJ({editorState:$,editorStateRef:Y,renderResources:X,theme:Z}){let J=R9(k1()),K=R9(null),Q=R9({height:240,top:0}),[M,D]=g6(0),[q,U]=g6(240),[V,G]=g6(0),[N,A]=g6(240),_=VA(M),z=n0(()=>{let T=Y.current??$,H=Q.current;return u3(T,{height:H.height,paddingX:Z.paddingX,paddingY:Z.paddingY,top:H.top,width:_},J.current,X)}),F=dJ(z),B=n0((T)=>{A((H)=>{let R=AA(T,Q.current.height);return H===R?H:R})}),W=n0((T)=>{Q.current={...Q.current,top:T},G((H)=>H===T?H:T),F.invalidate()}),S=n0((T)=>{let H=NA(T),R=H.top!==Q.current.top;if(Q.current=H,G((u)=>u===H.top?u:H.top),R)F.invalidate()}),b=n0((T)=>{let H=K.current;if(!H)return W(T),T;H.scrollTop=T;let R=H.scrollTop;return W(R),R}),k=n0(()=>{return K.current?.scrollTop??Q.current.top}),P=n0((T,H)=>{let R=T!==null&&T.documentIndex!==H.documentIndex,u=F.peek();if(!(!R||!u||u.layout.regionLineIndices.has(H.selection.focus.regionId)))F.invalidate()}),y=n0(()=>{return F.invalidate(),F.get()}),E=n0((T)=>{let H=K.current;return H?cJ(T,H):null}),w=n0((T)=>{hJ(K.current,T)});return GA(()=>{let T=K.current;if(!T||typeof ResizeObserver>"u")return;let H=new ResizeObserver((R)=>{let u=R[0];if(!u)return;let g=Math.max(0,Math.floor(u.contentRect.width)),I=rJ(T);Q.current={...Q.current,height:I},D((j)=>j===g?j:g),U((j)=>j===I?j:I)});return H.observe(T),()=>H.disconnect()},[K]),{actions:{autoScrollDuringDrag:w,getScrollTop:k,observePreparedViewport:B,observeScrollContainer:S,prepareNextPaint:y,reconcileEditorState:P,resolvePoint:E,scrollTo:b},props:{getScrollContainer:(T)=>({onScroll:(H)=>{S(H.currentTarget),T?.onScroll?.(H)},ref:K}),scrollContent:{style:{height:`${N}px`}}},refs:{scrollContainer:K},state:{layoutWidth:_,preparedViewport:F,scrollContentHeight:N,surfaceWidth:M,viewportHeight:q,viewportTop:V}}}function VA($){return Math.max(240,Math.floor($||480))}function rJ($){return Math.max(240,$.clientHeight)}function NA($){return{height:rJ($),top:$.scrollTop}}function AA($,Y){return Math.max(Y,Math.ceil($.totalHeight+24))}function _A(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function b9($,{paintHeight:Y,paintTop:X,width:Z}){if(!$)return null;let J=Math.max(240,Math.ceil(Y)),K=_A();$.width=Math.ceil(Z*K),$.height=Math.ceil(J*K),$.style.width=`${Z}px`,$.style.height=`${J}px`,$.style.transform=`translateY(${X}px)`;let Q=$.getContext("2d");if(!Q)return null;return{context:Q,devicePixelRatio:K,height:J,width:Z}}function S9($,Y){return $.activeBlockType===Y.activeBlockType&&$.activeCommentThreadIndex===Y.activeCommentThreadIndex&&$.activeSpanKind===Y.activeSpanKind&&$.canonicalContent===Y.canonicalContent&&$.characterCount===Y.characterCount&&$.commentThreadCount===Y.commentThreadCount&&$.layoutWidth===Y.layoutWidth&&$.resolvedCommentCount===Y.resolvedCommentCount&&$.selectionFrom===Y.selectionFrom&&$.selectionTo===Y.selectionTo}function sJ($,Y){if(!Y?.length||!$?.length)return;let X=new Map($.map((J)=>[J.id,J])),Z=[];for(let J of Y){let K=X.get(J.userId);if(!K)continue;Z.push({...K,color:J.color,cursor:J.cursor})}return Z.length===0?void 0:Z}function oJ($,Y){if(!$)return{didReconcile:!1,state:Y};let X=HA($,Y)??wA($,Y);return X?{didReconcile:!0,state:X}:{didReconcile:!1,state:Y}}function HA($,Y){let X=zA($,Y);return X?K0(Y,X,!1):null}function zA($,Y){if(m9($.selection.anchor,$.selection.focus)){let K=v9($,Y,$.selection.focus,"neutral");return K?{anchor:K,focus:K}:null}let X=TA($),Z=v9($,Y,$.selection.anchor,X.anchor),J=v9($,Y,$.selection.focus,X.focus);return Z&&J?{anchor:Z,focus:J}:null}function v9($,Y,X,Z){let J=$.documentIndex.regionIndex.get(X.regionId);if(!J)return null;let K=f9(J,Y);if(!K)return null;return{offset:EA(J.text,K.text,X.offset,Z),regionId:K.id}}function f9($,Y){let X=Y.documentIndex.regionIndex.get($.id);if(X)return X;if($.text.length===0)return null;let Z=FA($,Y);if(Z)return Z;return Y.documentIndex.regionPathIndex.get($.path)??null}function FA($,Y){let X=null;for(let Z of Y.documentIndex.regions){if(Z.blockType!==$.blockType||Z.text!==$.text)continue;if(X)return null;X=Z}return X}function EA($,Y,X,Z){let J=b0(X,0,$.length),{prefix:K,suffix:Q}=U8($,J,J),M=WA(Y,K,Q);if(M!==null)return M;let D=PA(Y,K),q=yA(Y,Q);if(Z==="before-suffix")return q??D??b0(X,0,Y.length);return D??q??b0(X,0,Y.length)}function WA($,Y,X){let Z=K2($,Y,X).filter((J)=>J.startOffset===J.endOffset);return Z.length===1?Z[0].startOffset:null}function PA($,Y){let X=a0($,Y);return X.length===1?X[0]+Y.length:null}function yA($,Y){let X=a0($,Y);return X.length===1?X[0]:null}function TA($){let{anchor:Y,focus:X}=$.selection;if(m9(Y,X))return{anchor:"neutral",focus:"neutral"};return jA($,Y,X)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function jA($,Y,X){let Z=$.documentIndex.regionOrderIndex.get(Y.regionId),J=$.documentIndex.regionOrderIndex.get(X.regionId);if(Z===void 0||J===void 0)return 0;return Z===J?Y.offset-X.offset:Z-J}function wA($,Y){if(!m9($.selection.anchor,$.selection.focus))return null;let X=OA($);if(!X)return null;let Z=BA($,Y,X);if(Z===null)return null;return CA(Y,Z)}function OA($){let Y=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Y||Y.blockType!=="paragraph"||Y.text.length>0)return null;return $.documentIndex.blockIndex.get(Y.blockId)?.parentBlockId===null?Y:null}function BA($,Y,X){let Z=iJ($,X.rootIndex,"before"),J=iJ($,X.rootIndex,"after"),K=Z?f9(Z,Y):null,Q=J?f9(J,Y):null;if(K&&Q)return K.rootIndex<Q.rootIndex?Q.rootIndex:null;if(K)return K.rootIndex+1;if(Q)return Q.rootIndex;return null}function CA($,Y){let X=L1($.documentIndex.document,Y,0,[i({text:""})]),Z={...$,documentIndex:q2($.documentIndex,X,Y,0)},J=e2(Z.documentIndex,$0(Y));return J?K0(Z,J,!1):null}function iJ($,Y,X){let Z=X==="before"?-1:1;for(let J=Y+Z;J>=0&&J<$.documentIndex.roots.length;J+=Z){let K=LA($,J,X);if(K)return K}return null}function LA($,Y,X){let Z=$.documentIndex.roots[Y]?.regions??[],J=X==="before"?Z.length-1:0,K=X==="before"?-1:1;for(let Q=J;Q>=0&&Q<Z.length;Q+=K){let M=Z[Q];if(M&&M.text.length>0)return M}return null}function m9($,Y){return $.regionId===Y.regionId&&$.offset===Y.offset}import{jsx as c,jsxs as p6,Fragment as kA}from"react/jsx-runtime";function x6({blocks:$}){return c(kA,{children:$.map((Y)=>RA(Y))})}function RA($){switch($.type){case"blockquote":return c("blockquote",{className:"preview-block preview-block-blockquote",children:c(x6,{blocks:$.children})},$.id);case"code":return p6("div",{className:"preview-block preview-block-code",children:[c("div",{className:"preview-rich-header",children:vA($.language,$.meta)}),c("pre",{children:c("code",{children:$.source||" "})})]},$.id);case"heading":{let Y=`h${$.depth}`;return c(Y,{className:"preview-block preview-block-heading",children:I6($.children)},$.id)}case"list":return $.ordered?c("ol",{className:"preview-block preview-block-list",start:$.start??1,children:$.items.map((Y)=>h9(Y))},$.id):c("ul",{className:"preview-block preview-block-list",children:$.items.map((Y)=>h9(Y))},$.id);case"listItem":return h9($);case"paragraph":return c("p",{className:"preview-block preview-block-paragraph",children:I6($.children)},$.id);case"table":return p6("div",{className:"preview-block preview-block-table",children:[c("div",{className:"preview-rich-header",children:fA($.rows.length,$.rows[0]?.cells.length??0,$.align.filter((Y)=>Y!==null).length)}),c("div",{className:"preview-table-scroll",children:c("table",{children:c("tbody",{children:$.rows.map((Y)=>c("tr",{children:Y.cells.map((X)=>c("td",{children:I6(X.children)},X.id))},Y.id))})})})]},$.id);case"divider":return c("hr",{className:"preview-block preview-block-rule"},$.id);case"directive":return c("pre",{className:`preview-block preview-block-directive preview-block-directive-${$.name}`,children:$.body},$.id);case"raw":return c("pre",{className:"preview-block preview-block-unsupported",children:$.source},$.id)}}function h9($){return c("li",{className:"preview-block preview-block-list-item",children:c(x6,{blocks:$.children})},$.id)}function I6($){return $.map((Y)=>{switch(Y.type){case"lineBreak":return c("br",{},Y.id);case"image":return p6("span",{className:"preview-inline preview-inline-image",children:[c("img",{alt:Y.alt??"",src:Y.url,title:Y.title??""}),p6("span",{children:[c("strong",{children:mA(Y.alt)}),c("small",{children:hA(Y.url,Y.title)})]})]},Y.id);case"code":return c("code",{className:"preview-inline preview-inline-code",children:Y.code},Y.id);case"link":return bA(Y);case"text":return c("span",{className:"preview-inline",children:SA(Y.text,Y.marks)},Y.id);case"raw":return c("span",{className:"preview-inline preview-inline-unsupported",children:Y.source},Y.id)}})}function bA($){return c("a",{className:"preview-inline preview-inline-link",href:$.url,children:I6($.children)},$.id)}function SA($,Y){let X=$;for(let Z of Y)switch(Z){case"strikethrough":X=c("del",{children:X});break;case"italic":X=c("em",{children:X});break;case"bold":X=c("strong",{children:X});break;case"underline":X=c("ins",{children:X});break}return X}function vA($,Y){return[$??"plain text",Y].filter(Boolean).join(" • ")}function fA($,Y,X){let Z=X>0?`${X} aligned ${X===1?"column":"columns"}`:"no alignment";return`${$} ${$===1?"row":"rows"} • ${Y} ${Y===1?"column":"columns"} • ${Z}`}function mA($){return $?.trim()?$:"Untitled image"}function hA($,Y){return Y?.trim()?`${Y} • ${$}`:$}var nJ=`/* Base Documint host and SSR-fallback styles. */
|
|
33
36
|
|
|
34
37
|
.documint {
|
|
35
38
|
display: grid;
|
|
@@ -365,7 +368,7 @@ ${M.text}`:M.text}function RQ($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
365
368
|
white-space: nowrap;
|
|
366
369
|
}
|
|
367
370
|
}
|
|
368
|
-
`;var
|
|
371
|
+
`;var tJ=`/* Leaf overlay styles, ordered outer → inner:
|
|
369
372
|
1. Anchor — viewport positioning + hover bridge
|
|
370
373
|
2. Shell — bordered container (with state and content variants)
|
|
371
374
|
3. Menu — shared dropdown surface (toolbar menus, completion popover)
|
|
@@ -875,7 +878,7 @@ ${M.text}`:M.text}function RQ($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
875
878
|
font-weight: 500;
|
|
876
879
|
white-space: nowrap;
|
|
877
880
|
}
|
|
878
|
-
`;var
|
|
881
|
+
`;var eJ=`/* Toolbar-specific styles (button, group, divider, and the menu trigger
|
|
879
882
|
shell + chevron). The menu container/item/divider styles themselves
|
|
880
883
|
live one level up in \`overlays/leaves/styles.css\` as \`.documint-leaf-menu*\`
|
|
881
884
|
so they can be shared by the toolbar's nested menu and other surfaces
|
|
@@ -957,6 +960,6 @@ ${M.text}`:M.text}function RQ($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
957
960
|
transform: rotate(180deg);
|
|
958
961
|
}
|
|
959
962
|
}
|
|
960
|
-
`;var
|
|
961
|
-
${
|
|
962
|
-
${
|
|
963
|
+
`;var $K=`${nJ}
|
|
964
|
+
${tJ}
|
|
965
|
+
${eJ}`;import{jsx as D0,jsxs as d6,Fragment as lA}from"react/jsx-runtime";var xA=2,YK={activeBlockType:null,activeCommentThreadIndex:null,activeSpanKind:null,canonicalContent:"",characterCount:0,commentThreadCount:0,layoutWidth:0,resolvedCommentCount:0,selectionFrom:0,selectionTo:0};function ZK({className:$,content:Y,keybindings:X,onCommentChanged:Z,onContentChanged:J,onStateChanged:K,presence:Q,storage:M,theme:D,users:q}){let U=r1(null),V=r1(null),G=r1(null),N=r1(null),A=r1(Y),_=r1(""),z=r1(YK),[F,B]=k9(!1),{theme:W,themeStyles:S}=lJ(D),[b,k]=k9(YK),P=M1(()=>t4(Y),[Y]),y=M1(()=>v6(P),[P]),[E,w]=k9(()=>M4(P)),C=EJ(E.documentIndex.imageUrls,M),T=C.resources,H=M1(()=>[...T?.images.values()??[]].some((L)=>L.status==="loading"),[T]);N.current=E,_.current||=y;let R=aJ({editorState:E,editorStateRef:N,renderResources:T,theme:W}),{actions:u,props:g,refs:I,state:j}=R,{autoScrollDuringDrag:O,getScrollTop:v,observePreparedViewport:f,observeScrollContainer:a,prepareNextPaint:x,reconcileEditorState:E0,resolvePoint:t0,scrollTo:u0}=u,{layoutWidth:g0,preparedViewport:e0,scrollContentHeight:c6,surfaceWidth:a6,viewportHeight:D5,viewportTop:r6}=j,{scrollContainer:u2}=I,U5=M1(()=>$4(E),[E]),I0=M1(()=>S0(E),[E]),w0=M1(()=>Y0(E),[E]),s1=M1(()=>{if(!q?.length)return;return[{trigger:"@",items:q.map((L)=>({label:L.fullName??L.username,id:L.id}))}]},[q]),s6=M1(()=>sJ(q,Q),[q,Q]),i6=M1(()=>XK(E,I0.liveRanges),[I0.liveRanges,E]),i1=Boolean(J),r=()=>N.current??E,G5=k2((L,h)=>{let p=$4(L),s=S0(L),n=fJ(L),e={activeBlockType:p.block?.nodeType??null,activeCommentThreadIndex:XK(L,s.liveRanges),activeSpanKind:p.span.kind==="none"?null:p.span.kind,canonicalContent:h,characterCount:h.length,commentThreadCount:s.threads.length,layoutWidth:g0,resolvedCommentCount:W8(s.threads),selectionFrom:n.start,selectionTo:n.end};if(k((_5)=>S9(_5,e)?_5:e),!S9(z.current,e))z.current=e,K?.(e)}),t=k2((L)=>{if(!L)return;let h=N.current??E,p=h.documentIndex!==L.documentIndex,s=h5(h,L);if(N.current=L,w(L),E0(h,L),s)n6();if(!p)return;let n=s0(L),e=v6(n);_.current=e,A.current=e,J?.(e,n)}),o6=(L)=>{Z?.(L)},u9=(L)=>{let h=s0(r()).comments[L],p=h?.comments.at(-1);if(!h||!p)return;o6({kind:"added",comment:p,mentionedUserIds:D9(p.body,s1),thread:h,threadIndex:L})},JK=(L,h,p)=>{let s=s0(r()).comments[L],n=s?.comments[h];if(!s||!n)return;o6({kind:"edited",comment:n,previousBody:p,mentionedUserIds:D9(n.body,s1),thread:s,threadIndex:L})},g9=(L,h,p)=>{o6({kind:"deleted",comment:p,thread:h,threadIndex:L})},I9=k2((L=e0.peek())=>{if(!L)return;let h=b9(U.current,{paintHeight:L.paintHeight,paintTop:L.paintTop,width:g0});if(!h)return;let{context:p,devicePixelRatio:s,height:n,width:e}=h;o3(E,L,p,{activeBlockId:U5.block?.blockId??null,activeRegionId:E.selection.focus.regionId,activeThreadIndex:d9??i6,devicePixelRatio:s,height:n,liveCommentRanges:I0.liveRanges,normalizedSelection:w0,now:performance.now(),resources:T,theme:W,width:e})}),p9=k2((L=e0.peek())=>{if(!L)return;let h=b9(V.current,{paintHeight:L.paintHeight,paintTop:L.paintTop,width:g0});if(!h)return;let{context:p,devicePixelRatio:s,height:n,width:e}=h;n3(E,L,p,{devicePixelRatio:s,height:n,normalizedSelection:w0,presence:N5.presence,showCaret:w0.start.regionId!==w0.end.regionId||w0.start.offset!==w0.end.offset||n1.isVisible(),theme:W,width:e})}),KK=k2(()=>{let L=x();f(L),N5.refreshPresence(L),I9(L),p9(L)}),{scheduleContentPaint:n6,scheduleFullPaint:x9,scheduleFullRender:o1,scheduleOverlayPaint:l9}=RJ({editorStateRef:N,renderContent:I9,renderOverlay:p9,renderViewport:KK}),QK=g.getScrollContainer({onScroll:()=>o1()}),n1=AJ({canShowInsertionLeaf:Boolean(J),canShowTableLeaf:Boolean(J),commentState:I0,editorState:E,editorViewportState:e0,getScrollTop:v,layoutWidth:g0,onVisibilityChange:l9,resources:T,scrollContentHeight:c6,scrollTo:u0,viewportHeight:D5}),MK=_J(n1.imageAtCursor,E,t),V5=BJ({applyNextState:t,editorState:E,editorStateRef:N,editorViewportState:e0,inputRef:G,keybindings:X,onActivity:n1.markActivity,onImagePaste:C.persistImage}),y1=PJ({applyNextState:t,autoScrollDuringDrag:O,canvasRef:U,commentState:I0,editorStateRef:N,editorViewportState:e0,focusInput:V5.focus,onActivity:n1.markActivity,readCurrentState:r,resolvePoint:t0}),d9=y1.leaf?.kind==="comment"?y1.leaf.threadIndex:null,qK=k2((L)=>{a(L),o1()}),N5=LJ({editorState:E,editorStateRef:N,editorViewportState:e0,onViewportScroll:qK,scrollContainerRef:u2,scheduleOverlayRender:l9,userPresence:s6}),A5=gJ({applyNextState:t,autoScrollDuringDrag:O,canShowSelectionLeaf:i1,editorState:E,editorStateRef:N,editorViewportState:e0,focusInput:V5.focus,onActivity:n1.markActivity,resolvePoint:t0,threads:I0.threads}),T1=A5.handle??MK;h2(()=>{o1()},[E.documentIndex,g0,W,T,o1,D5]),h2(()=>{x9()},[w0.end.offset,w0.end.regionId,w0.start.offset,w0.start.regionId,x9,U5.block?.blockId]),h2(()=>{n6()},[i6,I0.liveRanges,d9,n6]),h2(()=>{if(!H)return;let L=null,h=window,p=()=>{o1(),L=h.requestAnimationFrame(p)};return L=h.requestAnimationFrame(p),()=>{if(L!==null)h.cancelAnimationFrame(L)}},[H,o1]);let DK=()=>{let L=y1.leaf,h=L??A5.leaf??n1.leaf,p=!L&&Boolean(A5.leaf),s=u2.current?.getBoundingClientRect()??null,n=h?.kind==="thread"?{...h,thread:I0.threads[h.threadIndex]??null}:null,e=h?.kind==="comment"?{animateInitialComment:!1,link:h.link,thread:h.thread,threadIndex:h.threadIndex}:n?.thread?{animateInitialComment:n.animateInitialComment??!1,link:null,thread:n.thread,threadIndex:n.threadIndex}:null,_5=e?.thread&&U1(e.thread)?"resolved":"default";return{annotationThreadLeaf:e,visibleLeaf:h,visibleLeafAnchor:h?{isSelection:p,left:(s?.left??0)+h.left,onPointerEnter:L?y1.leafHandlers.onPointerEnter:void 0,onPointerLeave:L?y1.leafHandlers.onPointerLeave:void 0,top:(s?.top??0)+h.top-r6+(p?xA:0)}:void 0,visibleLeafStatus:_5}},{annotationThreadLeaf:p0,visibleLeaf:A0,visibleLeafAnchor:c9,visibleLeafStatus:UK}=DK(),GK=(()=>{if(!A0)return null;switch(A0.kind){case"insertion":return D0(XJ,{onInsert:(L)=>{t(N4(r(),L))},onInsertTable:(L)=>{t(e$(r(),L))}});case"table":return D0(qJ,{canDeleteColumn:A0.columnCount>1,canDeleteRow:A0.rowCount>1,onDeleteColumn:()=>{t(YY(r()))},onDeleteRow:()=>{t(ZY(r()))},onDeleteTable:()=>{t(JY(r()))},onInsertColumn:(L)=>{t($Y(r(),L))},onInsertRow:(L)=>{t(XY(r(),L))}});case"link":return D0(QJ,{canEdit:i1,onDelete:()=>{let L=c$(r(),A0.regionId,A0.startOffset,A0.endOffset);if(L)t(L)},onSave:(L)=>{let h=d$(r(),A0.regionId,A0.startOffset,A0.endOffset,L);if(h)t(h)},title:A0.title,url:A0.url});case"create":return D0(A9,{activeMarks:A0.activeMarks,canEdit:i1,link:null,mode:"create",mentionSources:s1,onCreateThread:(L)=>{let h=r(),p=s0(h).comments.length,s=KY(h,A0.selection,L.trim());if(!s)return;t(s),A5.promoteLeafToThread(p,!0),u9(p)},onToggleBold:()=>{t(s5(r()))},onToggleItalic:()=>{t(i5(r()))},onToggleStrikethrough:()=>{t(o5(r()))},onToggleUnderline:()=>{t(n5(r()))}});default:return p0?D0(A9,{animateInitialComment:p0.animateInitialComment,canEdit:i1,link:p0.link,mode:"thread",mentionSources:s1,onDeleteComment:(L)=>{let{threadIndex:h}=p0,p=r(),s=s0(p).comments[h],n=s?.comments[L],e=qY(p,h,L);if(!e)return;if(t(e),s&&n)g9(h,s,n)},onDeleteThread:()=>{let{threadIndex:L}=p0,h=r(),p=s0(h).comments[L],s=DY(h,L);if(!s)return;if(t(s),p)for(let n of p.comments)g9(L,p,n)},onEditComment:(L,h)=>{let{threadIndex:p}=p0,s=r(),n=s0(s).comments[p]?.comments[L]?.body,e=MY(s,p,L,h);if(!e)return;if(t(e),n!==void 0)JK(p,L,n)},onReply:(L)=>{let{threadIndex:h}=p0,p=QY(r(),h,L);if(!p)return;t(p),u9(h)},onToggleResolved:()=>{t(UY(r(),p0.threadIndex,!U1(p0.thread)))},thread:p0.thread}):null}})();h2(()=>{B(!0)},[]),h2(()=>{G5(E,_.current||y)},[y,E,G5,a6]),pA(()=>{if(Y===A.current)return;let L=N.current,h=oJ(L,M4(P)),p=h.state,s=h.didReconcile?v():0;N.current=p,w(p),A.current=Y,_.current=y,u0(s)},[y,Y,P,v,u0]);let VK=$?`documint ${$}`:"documint";return D0(gZ,{themeStyles:S,children:d6("section",{className:VK,"data-active-block":b.activeBlockType??"","data-active-comment-thread":b.activeCommentThreadIndex??"","data-active-span":b.activeSpanKind??"",style:{...S,height:"100%",minHeight:0},children:[D0("style",{children:$K}),d6("div",{...QK,className:"documint-scroll-container",style:{height:"100%",minHeight:0},children:[D0("textarea",{...V5.inputHandlers,ref:G,autoCapitalize:"sentences",className:"documint-input",spellCheck:!1,tabIndex:-1}),D0(KZ,{insetX:W.paddingX,insetY:W.paddingY,onSelect:N5.scrollToPresence,presence:N5.presence}),d6("div",{...g.scrollContent,className:"documint-scroll-content",children:[D0("canvas",{...V5.canvasHandlers,...y1.canvasHandlers,"aria-label":"Documint editor",className:"documint-content-canvas",style:{cursor:y1.cursor},ref:U,tabIndex:0}),D0("canvas",{"aria-hidden":"true",className:"documint-overlay-canvas",ref:V}),T1&&d6(lA,{children:[D0("div",{"aria-hidden":"true",className:"documint-resize-handle",style:{left:`${T1.start.left}px`,top:`${T1.start.top}px`},...T1.start.props,children:D0("span",{className:"documint-resize-handle-knob"})}),D0("div",{"aria-hidden":"true",className:"documint-resize-handle",style:{left:`${T1.end.left}px`,top:`${T1.end.top}px`},...T1.end.props,children:D0("span",{className:"documint-resize-handle-knob"})})]}),A0&&c9?D0(ZJ,{anchor:c9,status:UK,children:GK}):null]}),!F?D0("div",{className:"documint-fallback",children:D0(x6,{blocks:P.blocks})}):null]})]})})}function XK($,Y){let X=new Map($.documentIndex.regions.map((D,q)=>[D.id,q])),Z=l6(X,$.selection.anchor.regionId,$.selection.anchor.offset),J=l6(X,$.selection.focus.regionId,$.selection.focus.offset),[K,Q]=Z<=J?[Z,J]:[J,Z],M=Z===J;for(let D of Y){let q=l6(X,D.regionId,D.startOffset),U=l6(X,D.regionId,D.endOffset);if(M){if(K>=q&&K<=U)return D.threadIndex;continue}if(Math.max(K,q)<Math.min(Q,U))return D.threadIndex}return null}function l6($,Y,X){return($.get(Y)??-1)*1e6+X}export{IJ as mintTheme,pJ as midnightTheme,M5 as lightTheme,j9 as defaultKeybindings,q5 as darkTheme,ZK as Documint};
|