finch-markdown-editor 0.2.9 → 0.2.10

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.
@@ -37,7 +37,7 @@
37
37
  </span>`)}function t4({textContent:i,classes:e}){return Z(e)?`<span class="${e.join(" ")}">${QQ(i)}</span>`:QQ(i)}var i4=[{type:"table",location:"bottom-right"},{type:"table",location:"right"},{type:"table",location:"bottom"}];function n4({row:i,col:e},t){let n=[{type:"header",location:"col",index:e},{type:"border",location:"top",index:i}],r=[{type:"border",location:"col",index:e+1},{type:"border",location:"row",index:i+1}],o=[{type:"header",location:"row",index:i},{type:"border",location:"left",index:i}];return[...t.top?n:[],...r,...t.left?o:[]]}function r4({location:i,type:e},t){return e==="header"?{location:i,type:e,index:t[i]}:i==="top"?{location:i,type:e,index:t.row}:i==="left"?{location:i,type:e,index:t.col}:{location:i,type:e,index:t[i]+1}}function Rm(i,e){return i?.type!==e?.type||i?.location!==e?.location?!1:i?.type==="table"||e?.type==="table"?!0:i?.index===e?.index}var Nh=class i{state;extraTags;style(e){return D1(this.state,Z(this.extraTags)?[...e,...this.extraTags]:e)}static of(e,t){return new i(e,t)}constructor(e,t){this.state=e,this.extraTags=t}};function aP(i){return uf(i).type==="None"}function cP(i){return!aP(i)}function PQ(i){return cP(i)?uf(i).getRangeAt(0).startOffset:void 0}function o4(i){return cP(i)?uf(i).getRangeAt(0).startContainer:void 0}function s4(i){uf(i).empty()}function uf(i){return i.getSelection()}var Am=class i{#e;get table(){return P(this.#e)}set table(e){Y(this.#e,e)}#i;get _selection(){return P(this.#i)}set _selection(e){Y(this.#i,e)}#t;get selectionChanged(){return P(this.#t)}set selectionChanged(e){Y(this.#t,e,!0)}#n;get activeCell(){return P(this.#n)}set activeCell(e){Y(this.#n,e)}#r;get anchorCell(){return P(this.#r)}set anchorCell(e){Y(this.#r,e)}#l;get outlinedSection(){return P(this.#l)}set outlinedSection(e){Y(this.#l,e)}#o;get rootEditor(){return P(this.#o)}set rootEditor(e){Y(this.#o,e)}#s;get extensions(){return P(this.#s)}set extensions(e){Y(this.#s,e)}#a;get markdownConfig(){return P(this.#a)}set markdownConfig(e){Y(this.#a,e)}#h;get globalKeyBindings(){return P(this.#h)}set globalKeyBindings(e){Y(this.#h,e)}#c;get selectionType(){return P(this.#c)}set selectionType(e){Y(this.#c,e)}#u;get lineWrapping(){return P(this.#u)}set lineWrapping(e){Y(this.#u,e)}#d;get wrapperElement(){return P(this.#d)}set wrapperElement(e){Y(this.#d,e)}#O;get tableElement(){return P(this.#O)}set tableElement(e){Y(this.#O,e)}#f;get scrollElement(){return P(this.#f)}set scrollElement(e){Y(this.#f,e)}#b;get menuRootElement(){return P(this.#b)}set menuRootElement(e){Y(this.#b,e)}#S;get headerCellHighlighter(){return P(this.#S)}set headerCellHighlighter(e){Y(this.#S,e)}#x;get dataCellHighlighter(){return P(this.#x)}set dataCellHighlighter(e){Y(this.#x,e)}#m;get onUndo(){return P(this.#m)}set onUndo(e){Y(this.#m,e)}#p;get onRedo(){return P(this.#p)}set onRedo(e){Y(this.#p,e)}#g;get onNavigate(){return P(this.#g)}set onNavigate(e){Y(this.#g,e)}#v;get onDelete(){return P(this.#v)}set onDelete(e){Y(this.#v,e)}#w;get activeTable(){return P(this.#w)}set activeTable(e){Y(this.#w,e)}#y;get hoveredCell(){return P(this.#y)}set hoveredCell(e){Y(this.#y,e)}#Q;get activeHandle(){return P(this.#Q)}set activeHandle(e){Y(this.#Q,e)}#k;get menu(){return P(this.#k)}set menu(e){Y(this.#k,e)}#P;get move(){return P(this.#P)}set move(e){Y(this.#P,e)}#$;get outline(){return P(this.#$)}set outline(e){Y(this.#$,e)}#C;get resize(){return P(this.#C)}set resize(e){Y(this.#C,e)}#T;get interactive(){return P(this.#T)}set interactive(e){Y(this.#T,e)}#R;get pointerDown(){return P(this.#R)}set pointerDown(e){Y(this.#R,e)}static of(e){return new i(e)}focusTable(){this.activeTable=!0,this.tableElement.focus({preventScroll:!0}),this.selectionValue="hidden",s4(this.document)}scrollToCell(e){requestAnimationFrame(()=>{Bh(this.tableElement,e)?.scrollIntoView({inline:"nearest",block:"nearest"})})}scrollToFirstCell(e,t){requestAnimationFrame(()=>{Bh(this.tableElement,{...this.table.firstCellLocation,[e]:t})?.scrollIntoView({inline:"nearest",block:"nearest"})})}get document(){return this.rootEditor.dom.ownerDocument}get window(){return this.document.defaultView??window}get rootScrollElement(){return this.rootEditor.scrollDOM}get scrollOffsetX(){return this.rootScrollElement.scrollLeft+this.scrollElement.scrollLeft}get scrollOffsetY(){return this.rootScrollElement.scrollTop+this.scrollElement.scrollTop}deleteTable(){this.onDelete()}navigate(e){this.onNavigate(e)}undo(){this.onUndo()}redo(){this.onRedo()}get selection(){return this._selection}get selectionValue(){return this._selection.value}set selectionValue(e){hf(this._selection.value,e)||(this._selection.value=e,this.selectionChanged=!0)}highlighter({row:e}){return e===this.table.firstRowIndex?this.headerCellHighlighter:this.dataCellHighlighter}cellHandleState(e,t){return t.type==="border"||this.activeHandle?.state=="active"?Rm(this.activeHandle?.handle,t)?this.activeHandle?.state:void 0:Rm(this.activeHandle?.handle,t)||e[t.location]===this.activeCell?.[t.location]?"hover":void 0}constructor({table:e,selection:t,scrollElement:n,rootEditor:r,menuRootElement:o,extensions:s,markdownConfig:l,globalKeyBindings:a,selectionType:c,lineWrapping:h,onUndo:f,onRedo:u,onNavigate:d,onDelete:O}){this.#e=G(e),this.#i=G(t),this.#t=fe(!1);let m=this.selection.isCell()?this.selection.cell:void 0;this.#n=fe(m),this.#r=fe(m),this.#l=fe(Z(m)?Ke.ofCell(m):void 0),this.#o=G(r),this.#s=G(s),this.#a=G(l),this.#h=G(a),this.#c=G(c),this.#u=G(h),this.#d=fe(void 0),this.#O=fe(void 0),this.#f=G(n),this.#b=G(o),this.#S=G(()=>Nh.of(this.rootEditor.state,[g.heading])),this.#x=G(()=>Nh.of(this.rootEditor.state)),this.#m=G(f),this.#p=G(u),this.#g=G(d),this.#v=G(O),this.#w=fe(!1),this.#y=fe(void 0),this.#Q=fe(void 0),this.#k=fe(void 0),this.#P=fe(void 0),this.#$=fe(void 0),this.#C=fe(void 0),this.#T=G(()=>I(this.move)&&I(this.resize)&&I(this.menu)&&I(this.outline)),this.#R=fe(!1);let p=G(()=>{if(nf(this.window)){if(Z(this.menu))return"default";if(Z(this.activeHandle)){let{type:b,location:S}=this.activeHandle.handle;if(b==="table"){if(S==="right")return"col-resize";if(S==="bottom-right")return"nwse-resize";if(S==="bottom")return"row-resize"}else{if(b==="border")return S==="top"?"row-resize":S==="left"?"col-resize":`${S}-resize`;if(b==="header")return this.pointerDown?"grabbing":this.activeHandle.state==="hover"?"pointer":void 0}}else{if(this.outline?.outlined??!1)return"cell";if(Z(this.hoveredCell))return"text"}}});og([()=>this.selectionValue],()=>{if(this.selectionChanged){this.selectionChanged=!1;return}this.selection.isCell()?(this.activeCell=this.selection.cell,this.anchorCell=this.selection.cell,this.outlinedSection=Ke.ofCell(this.selection.cell)):this.selection.isHidden()?(this.focusTable(),this.activeCell=void 0,this.anchorCell=void 0,this.outlinedSection=void 0):(this.activeTable=!1,this.activeCell=void 0,this.anchorCell=void 0,this.outlinedSection=void 0)}),sf(()=>{this.document.body.style.cursor=P(p)??""})}};function hP({tableState:i,event:e}){if(I(i.outlinedSection))return;e?.preventDefault();let t=gQ(i.outlinedSection.rowRange,i.table.rowRange),n=gQ(i.outlinedSection.colRange,i.table.colRange),r=n&&!t&&ir(i.outlinedSection.rowRange).every(l=>i.table.hasEmptyRowAt(l)),o=t&&!n&&ir(i.outlinedSection.colRange).every(l=>i.table.hasEmptyColAt(l)),s=t&&n&&ir(i.outlinedSection.colRange).every(l=>i.table.hasEmptyColAt(l));if(r){i.table.removeRowsAt({row:i.outlinedSection.startRow,count:i.outlinedSection.rowCount});let l=i.table.hasRowAt(i.outlinedSection.startRow)?i.outlinedSection.startRow:i.table.lastRowIndex,a={row:l,col:i.table.lastColIndex};i.outlinedSection=Ke.of({row:{start:l,endExclusive:l+1},col:i.table.colRange}),i.activeCell=a,i.anchorCell=a}else if(o){i.table.removeColsAt({col:i.outlinedSection.startCol,count:i.outlinedSection.colCount});let l=i.table.hasColAt(i.outlinedSection.startCol)?i.outlinedSection.startCol:i.table.lastColIndex,a={row:i.table.lastRowIndex,col:l};i.outlinedSection=Ke.of({row:i.table.rowRange,col:{start:l,endExclusive:l+1}}),i.activeCell=a,i.anchorCell=a}else s?i.deleteTable():i.table.clearSection(i.outlinedSection)}function fP(i){dP(i,"copy")}function uP(i){dP(i,"cut")}function sg({event:i,tableState:e}){if(I(e.outlinedSection))return;let t=i.clipboardData.getData("text/plain"),n=Gl.maybeOf(V.of(t.split(/\r\n|\n|\r/)));Z(n)?(i.preventDefault(),i.stopPropagation(),$Q(n,e)):e.selection.isCell()||(i.preventDefault(),i.stopPropagation(),$Q(l4(t),e))}function $Q(i,e){let{startRow:t,startCol:n,rowCount:r,colCount:o}=e.outlinedSection,s=Jy(r/i.rowCount),l=Jy(o/i.colCount);i.tile({rowRepeat:Pt(s-1,{min:0}),colRepeat:Pt(l-1,{min:0})}),e.table.merge(i,{row:t,col:n}),e.outlinedSection=Ke.of({row:{start:t,endExclusive:t+i.rowCount},col:{start:n,endExclusive:n+i.colCount}}),I(e.anchorCell)&&(e.anchorCell=e.activeCell);let a=e.anchorCell.row<=e.activeCell.row,c=e.anchorCell.col<=e.activeCell.col;e.anchorCell=e.outlinedSection.cornerCellAt(`${a?"top":"bottom"}-${c?"left":"right"}`),e.activeCell=e.outlinedSection.cornerCellAt(`${a?"bottom":"top"}-${c?"right":"left"}`),e.focusTable()}function l4(i){let{text:e}=IQ([[kt(i)]],["none"]);return Gl.of(e)}function dP({event:i,tableState:e},t){if(I(e.outlinedSection)||e.selection.isCell())return;i.preventDefault(),i.stopPropagation();let n=e.table.sliceSectionAt(e.outlinedSection);i.clipboardData?.setData("text/plain",n.text.toString()),t==="cut"&&hP({tableState:e})}function a4(i){i.pointerDown=!0}function c4(i){i.pointerDown=!1}function h4(i){i.pointerDown=!1}function f4(i,e){e.selection.isCell()||fP({tableState:e,event:i})}function u4(i,e){e.selection.isCell()||uP({tableState:e,event:i})}function d4(i,e){e.selection.isCell()||sg({tableState:e,event:i})}var lg="CellView";function OP(i){return Gk(i,{component:lg})}function O4(i){return Uk(i,{component:lg})}var tr="\0";function pP(i,e,{trim:t}){let n=oP(i),{from:r,to:o}=rP(i),s=e.toString(),l=V.of(`${s.slice(0,r)}${tr}${s.slice(r,o)}${tr}${s.slice(o)}`.split(`
38
38
  `)),a=Dm(l,{trim:t}).toString(),c=a.indexOf(tr),h=a.lastIndexOf(tr)-1;return n?{anchor:c,head:h}:{head:c,anchor:h}}function CQ(i,e){let t=oP(i),{from:n,to:r}=rP(i),o=e.toString(),s=V.of(`${o.slice(0,n)}${tr}${o.slice(n,r)}${tr}${o.slice(r)}`.split(`
39
39
  `)),l=Wh(s).toString(),a=l.indexOf(tr),c=l.lastIndexOf(tr)-1;return t?{anchor:a,head:c}:{head:a,anchor:c}}function p4(i){if(I(i.tableElement)||aP(i.document))return;let e=o4(i.document);if(I(e)||!Bk(i.tableElement,e))return;let t=ra(e);if(I(t))return;let n=ff(t);i.selection.isCell()&&co(i.selection.cell,n)||(i.activeTable=!1,i.selectionValue={cell:n,section:m4(i.document,e)},i.activeCell=n,i.anchorCell=n,i.outlinedSection=Ke.ofCell(n))}function m4(i,e){let t=OP(e),n=bq({ancestor:t,descendent:e,getText:l=>mq(l)?`
40
- `:l.textContent??""})??"",r=(e.textContent??"").slice(0,PQ(i)),o=kt(`${n}${r}`),s=n.length+PQ(i);return pP({anchor:s,head:s},o,{trim:!1})}function g4(i,e){var t=eg(),n=ze(t);lo(n,()=>e.children),z(i,t)}function b4(i,e){cr(e,!0),af(()=>{let t=jk(g4,{target:e.to,context:Qz(),props:{children:e.children}});return()=>{Vk(t)}}),hr()}wz();var S4=oe('<div class="tbl-blocking-overlay" aria-hidden="true"></div>');function x4(i){var e=S4();z(i,e)}function Uh(i,e){let t=e.devicePixelRatio;return bL(i*t)/t}function v4({x:i,y:e},t){return{x:Uh(i,t),y:Uh(e,t)}}var w4=oe('<th class="tbl-cell tbl-header-cell"><!></th>'),y4=oe('<td class="tbl-cell tbl-data-cell"><!></td>');function Q4(i,e){cr(e,!0);let t=G(()=>kQ(Z(e.movement)?e.movement.border:{top:e.position.top,right:!0,bottom:!0,left:e.position.left})),n=G(()=>kQ(e.outline)),r=G(()=>{if(I(e.movement?.translate))return;let{x:c,y:h}=e.movement.state==="moving"?v4(e.movement.translate,e.win):e.movement.translate;return`translate3d(${c}px, ${h}px, 0px)`});var o=eg(),s=ze(o);{var l=c=>{var h=w4();let f;var u=mi(h);lo(u,()=>e.children),Qt(d=>{Ce(h,"align",e.alignment==="none"?void 0:e.alignment),Ce(h,"data-component",Fl),Ce(h,"data-row",e.location.row),Ce(h,"data-col",e.location.col),Ce(h,"data-border",P(t)),Ce(h,"data-outline",P(n)),Ce(h,"data-selected",d),Ce(h,"data-state",e.movement?.state),f=Vh(h,"",f,{transform:P(r)})},[()=>no(e.selected)]),z(c,h)},a=c=>{var h=y4();let f;var u=mi(h);lo(u,()=>e.children),Qt(d=>{Ce(h,"align",e.alignment==="none"?void 0:e.alignment),Ce(h,"data-component",Fl),Ce(h,"data-row",e.location.row),Ce(h,"data-col",e.location.col),Ce(h,"data-border",P(t)),Ce(h,"data-outline",P(n)),Ce(h,"data-selected",d),Ce(h,"data-state",e.movement?.state),f=Vh(h,"",f,{transform:P(r)})},[()=>no(e.selected)]),z(c,h)};Ot(s,c=>{e.position.top?c(l):c(a,!1)})}z(i,o),hr()}function mP(i){return Z(Ul(i.dom).activeElement?.closest(".cm-panels"))}function TQ(i){return i.trim().split(/\s+/)}function k4({doc:i,selection:e,parent:t,extensions:n,markdownConfig:r,selectionType:o,lineWrapping:s,globalKeyBindings:l,rootEditor:a,highlighter:c,onChange:h,eventHandlers:f}){return new C({doc:i,selection:e,parent:t,extensions:[n,vt.lowest([C.editorAttributes.of(u=>{let d=new Set(TQ(a.themeClasses)),O=new Set(TQ(u.themeClasses));return{class:[...d.difference(O)].join(" ")}}),Yt.of([...l.map(u=>({...u,run:Z(u.run)?()=>u.run(a):void 0,shift:Z(u.shift)?()=>u.shift(a):void 0}))]),o==="codemirror"?Wb():[],qo(c),Dr({extensions:[WQ,r.extensions??[]],addKeymap:!1,completeHTMLTags:r.completeHTMLTags,pasteURLAsLink:r.pasteURLAsLink,htmlTagLanguage:r.htmlTagLanguage}),C.domEventObservers(f),s==="wrap"?C.lineWrapping:[]])],dispatchTransactions:(u,d)=>{d.update(u),u.forEach(h)}})}var P4=oe('<div class="tbl-cell-editor"></div>');function $4(i,e){cr(e,!0);let t=ym(e,"text",15),n=ym(e,"selection",15),r,o,s=!1,l=!1;function a(h){let{docChanged:f,newDoc:u,selection:d}=h;if(s)return;let O=Z(d);if(f||O){if(f){let m=Dm(u,{trim:!0});m.eq(t())||(t(m),l=!0)}if(O){let{head:m,anchor:p}=d.main,b=pP({head:m,anchor:p},u,{trim:!0});nP(b,n())||(n(b),l=!0)}}}og([()=>t(),()=>n()],()=>{if(l){l=!1;return}s=!0,o.dispatch({changes:o.state.changes({from:0,to:o.state.doc.length,insert:Wh(t())}),selection:CQ(n(),t())}),s=!1},{lazy:!0}),af(()=>(o=k4({doc:Wh(t()),selection:CQ(n(),t()),parent:r,selectionType:e.selectionType,lineWrapping:e.lineWrapping,extensions:e.extensions,markdownConfig:e.markdownConfig,globalKeyBindings:e.globalKeyBindings,rootEditor:e.rootEditor,highlighter:e.highlighter,onChange:a,eventHandlers:{beforeinput:e.onbeforeinput,dragstart:e.ondragstart,keydown:(h,{state:f})=>e.onkeydown(h,f),paste:e.onpaste}}),mP(o)||o.focus(),()=>o.destroy()));var c=P4();Ih(c,h=>r=h,()=>r),z(i,c),hr()}var Gh=class i{event;tableState;position;static navigate(e){new i(e)[`navigate${e.key}`]()}navigateTab(){this.moveRight({createRow:!0,position:"end"})}navigateShiftTab(){this.moveLeft({createRow:!0,position:"end"})}navigateEnter(){this.moveDown({createRow:!0,position:"end"})}navigateArrowLeft(){this.position.left&&this.moveLeft({createRow:!1,position:"end"})}navigateArrowUp(){this.position.top&&this.moveUp({createRow:!1,position:"end"})}navigateArrowRight(){this.position.right&&this.moveRight({createRow:!1,position:"start"})}navigateArrowDown(){this.position.bottom&&this.moveDown({createRow:!1,position:"end"})}navigateShiftArrowLeft(){if(!(!this.position.left||I(this.tableState.outlinedSection)||I(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),I(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.endCol===this.tableState.anchorCell.col){if(this.tableState.outlinedSection.startCol===this.tableState.table.firstColIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandLeft()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractLeft();this.tableState.activeCell=iP(this.tableState.activeCell)}}navigateShiftArrowUp(){if(!(!this.position.top||I(this.tableState.outlinedSection)||I(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),I(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.endRow===this.tableState.anchorCell.row){if(this.tableState.outlinedSection.startRow===this.tableState.table.firstRowIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandUp()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractUp();this.tableState.activeCell=Jk(this.tableState.activeCell)}}navigateShiftArrowRight(){if(!(!this.position.right||I(this.tableState.outlinedSection)||I(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),I(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.startCol===this.tableState.anchorCell.col){if(this.tableState.outlinedSection.endCol===this.tableState.table.lastColIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandRight()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractRight();this.tableState.activeCell=eP(this.tableState.activeCell)}}navigateShiftArrowDown(){if(!(!this.position.bottom||I(this.tableState.outlinedSection)||I(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),I(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.startRow===this.tableState.anchorCell.row){if(this.tableState.outlinedSection.endRow===this.tableState.table.lastRowIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandDown()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractDown();this.tableState.activeCell=tP(this.tableState.activeCell)}}moveLeft({createRow:e,position:t}){if(!I(this.tableState.activeCell)){if(this.event.preventDefault(),co(this.tableState.activeCell,this.tableState.table.firstCellLocation)){if(!e){this.tableState.navigate("before");return}this.tableState.table.prependEmptyRows(1),this.tableState.activeCell={row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col}}this.moveTo(this.tableState.activeCell.col===this.tableState.table.firstColIndex?{row:this.tableState.activeCell.row-1,col:this.tableState.table.lastColIndex}:{row:this.tableState.activeCell.row,col:this.tableState.activeCell.col-1},t)}}moveUp({createRow:e,position:t}){if(!I(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.firstRowIndex){if(!e){this.tableState.navigate("before");return}this.tableState.table.prependEmptyRows(1),this.tableState.activeCell={row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col}}this.moveTo({row:this.tableState.activeCell.row-1,col:this.tableState.activeCell.col},t)}}moveRight({createRow:e,position:t}){if(!I(this.tableState.activeCell)){if(this.event.preventDefault(),co(this.tableState.activeCell,this.tableState.table.lastCellLocation)){if(!e){this.tableState.navigate("after");return}this.tableState.table.appendEmptyRows(1)}this.moveTo(this.tableState.activeCell.col===this.tableState.table.lastColIndex?{row:this.tableState.activeCell.row+1,col:this.tableState.table.firstColIndex}:{row:this.tableState.activeCell.row,col:this.tableState.activeCell.col+1},t)}}moveDown({createRow:e,position:t}){if(!I(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.lastRowIndex){if(!e){this.tableState.navigate("after");return}this.tableState.table.appendEmptyRows(1)}this.moveTo({row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col},t)}}moveTo(e,t){if(this.tableState.activeCell=e,this.tableState.anchorCell=e,this.tableState.outlinedSection=Ke.ofCell(e),this.tableState.selection.isCell()){let n=t==="start"?0:this.tableState.table.cellAt(e).length;this.tableState.selectionValue={cell:e,section:{anchor:n,head:n}}}}constructor({event:e,tableState:t,position:n}){this.event=e,this.tableState=t,this.position=n}},Se={alt:"Alt",arrowDown:"ArrowDown",arrowLeft:"ArrowLeft",arrowRight:"ArrowRight",arrowUp:"ArrowUp",backspace:"Backspace",c:"c",delete:"Delete",enter:"Enter",escape:"Escape",shift:"Shift",tab:"Tab",v:"v",x:"x"},C4=[Se.arrowDown,Se.arrowLeft,Se.arrowRight,Se.arrowUp,Se.enter,Se.tab,`${Se.shift}${Se.arrowDown}`,`${Se.shift}${Se.arrowLeft}`,`${Se.shift}${Se.arrowRight}`,`${Se.shift}${Se.arrowUp}`,`${Se.shift}${Se.tab}`],RQ=new Set(C4);function gP({key:i,shiftKey:e,altKey:t,metaKey:n,ctrlKey:r}){if(!(t||n||r))return e?RQ.has(`${Se.shift}${i}`)?`${Se.shift}${i}`:void 0:RQ.has(i)?i:void 0}function T4(i,e){i.inputType==="historyUndo"?(e.undo(),i.preventDefault()):i.inputType==="historyRedo"&&(e.redo(),i.preventDefault())}function R4(i){i.preventDefault()}function A4(i,e,t){let n=gP(i);if(I(n))return;let r=e.selection.main.head,o=e.doc.lineAt(r).number,s=0,l=e.doc.length,a=1,c=e.doc.lines,h={top:o===a,right:r===l,bottom:o===c,left:r===s};Gh.navigate({tableState:t,key:n,event:i,position:h})}function X4(i,e){sg({tableState:e,event:i})}var E4=oe('<div class="tbl-cell-view" contenteditable="" tabindex="-1"><!></div>');function _4(i,e){cr(e,!0);var t=E4(),n=mi(t);lo(n,()=>e.children),Qt(r=>{Ce(t,"data-component",lg),Ce(t,"data-hidden",r)},[()=>no(e.hidden)]),z(i,t),hr()}var bP="Handle";function ag(i){if(!Fk(i,{component:bP}))return;let{type:e,location:t}=tg(i).dataset;if(e==="table")return{type:e,location:t};{let n=ff(ra(i));return r4({location:t,type:e},n)}}var Z4=Si('<svg class="tbl-handle-grip" width="15" height="3" fill="currentColor" viewBox="0 0 15 3" xmlns="http://www.w3.org/2000/svg"><circle cx="1.5" cy="1.5" r="1.5"></circle><circle cx="7.5" cy="1.5" r="1.5"></circle><circle cx="13.5" cy="1.5" r="1.5"></circle></svg>'),M4=Si('<svg class="tbl-handle-grip" width="3" height="15" fill="currentColor" viewBox="0 0 3 15" xmlns="http://www.w3.org/2000/svg"><circle cy="1.5" cx="1.5" r="1.5"></circle><circle cy="7.5" cx="1.5" r="1.5"></circle><circle cy="13.5" cx="1.5" r="1.5"></circle></svg>'),L4=oe('<div class="tbl-handle" role="button" aria-hidden="true"><!></div>');function AQ(i,e){cr(e,!0);let t=ym(e,"toggle",3,!1),n={table:{right:"vertical",bottom:"horizontal"},header:{row:"vertical",col:"horizontal"}},r=G(()=>n[e.of.type]?.[e.of.location]);var o=L4();Vh(o,"",{},{opacity:"var(--tbl-handle-opacity, 0)"});var s=mi(o);{var l=c=>{var h=Z4();z(c,h)},a=c=>{var h=M4();z(c,h)};Ot(s,c=>{P(r)==="horizontal"?c(l):P(r)==="vertical"&&c(a,1)})}Qt((c,h,f)=>{Ce(o,"data-component",bP),Ce(o,"data-type",e.of.type),Ce(o,"data-location",e.of.location),Ce(o,"data-active",c),Ce(o,"data-hover",h),Ce(o,"data-toggle",f)},[()=>no(e.state==="active"),()=>no(e.state==="hover"),()=>no(t())]),z(i,o),hr()}var z4=oe('<div class="tbl-menu"><!></div>');function q4(i,e){cr(e,!0);let t,n=fe(void 0);af(()=>{e.translate(t).then(l=>Y(n,l,!0))});var r=z4();let o;var s=mi(r);lo(s,()=>e.children),Ih(r,l=>t=l,()=>t),Qt(l=>o=Vh(r,"",o,l),[()=>({visibility:Z(P(n))?void 0:"hidden",transform:Z(P(n))?`translate3d(${P(n).x}px, ${P(n).y}px, 0px)`:void 0})]),z(i,r),hr()}var W4=oe('<div class="tbl-menu-item" role="menuitem" tabindex="-1"><!></div>');function Kt(i,e){var t=W4(),n=mi(t);lo(n,()=>e.children),Wl("click",t,function(...r){e.onclick?.apply(this,r)}),z(i,t)}Dk(["click"]);function Jt(i,e){switch(i.action){case"add":return e.menu.clickAdd(i.direction);case"align":return e.menu.clickAlign(i.alignment);case"clear":return e.menu.clickClear();case"duplicate":return e.menu.clickDuplicate();case"move":return e.menu.clickMove(i.direction);case"remove":return e.menu.clickRemove();case"sort":return e.menu.clickSort(i.direction)}}var D4=Si('<path d="M294.6 454.6L214.6 534.6C202.1 547.1 181.8 547.1 169.3 534.6L89.3 454.6C76.8 442.1 76.8 421.8 89.3 409.3C101.8 396.8 122.1 396.8 134.6 409.3L160 434.7L160 128C160 110.3 174.3 96 192 96C209.7 96 224 110.3 224 128L224 434.7L249.4 409.3C261.9 396.8 282.2 396.8 294.7 409.3C307.2 421.8 307.2 442.1 294.7 454.6zM476.6 113.7C527.3 215 553.9 268.4 556.6 273.7C564.5 289.5 558.1 308.7 542.3 316.6C526.5 324.5 507.3 318.1 499.4 302.3L492.2 288L403.8 288L396.6 302.3C388.7 318.1 369.5 324.5 353.7 316.6C337.9 308.7 331.5 289.5 339.4 273.7C342.1 268.4 368.7 215 419.4 113.7C424.8 102.9 435.9 96 448 96C460.1 96 471.2 102.8 476.6 113.7zM448 199.6L427.8 240L468.2 240L448 199.6zM352 384C352 366.3 366.3 352 384 352L512 352C524.9 352 536.6 359.8 541.6 371.8C546.6 383.8 543.8 397.5 534.7 406.7L461.3 480L512 480C529.7 480 544 494.3 544 512C544 529.7 529.7 544 512 544L384 544C371.1 544 359.4 536.2 354.4 524.2C349.4 512.2 352.2 498.5 361.3 489.3L434.7 415.9L384 415.9C366.3 415.9 352 401.6 352 383.9z"></path>'),j4=Si('<path d="M294.6 454.6L214.6 534.6C202.1 547.1 181.8 547.1 169.3 534.6L89.3 454.6C76.8 442.1 76.8 421.8 89.3 409.3C101.8 396.8 122.1 396.8 134.6 409.3L160 434.7L160 128C160 110.3 174.3 96 192 96C209.7 96 224 110.3 224 128L224 434.7L249.4 409.3C261.9 396.8 282.2 396.8 294.7 409.3C307.2 421.8 307.2 442.1 294.7 454.6zM352 128C352 110.3 366.3 96 384 96L512 96C524.9 96 536.6 103.8 541.6 115.8C546.6 127.8 543.8 141.5 534.7 150.7L461.3 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L384 288C371.1 288 359.4 280.2 354.4 268.2C349.4 256.2 352.2 242.5 361.3 233.3L434.8 160L384 160C366.3 160 352 145.7 352 128zM476.6 337.7L556.6 497.7C564.5 513.5 558.1 532.7 542.3 540.6C526.5 548.5 507.3 542.1 499.4 526.3L492.2 512L403.8 512L396.6 526.3C388.7 542.1 369.5 548.5 353.7 540.6C337.9 532.7 331.5 513.5 339.4 497.7L419.4 337.7C424.8 326.9 435.9 320 448 320C460.1 320 471.2 326.8 476.6 337.7zM448 423.6L427.8 464L468.2 464L448 423.6z"></path>'),V4=Si('<path d="M384 128C384 145.7 369.7 160 352 160L128 160C110.3 160 96 145.7 96 128C96 110.3 110.3 96 128 96L352 96C369.7 96 384 110.3 384 128zM384 384C384 401.7 369.7 416 352 416L128 416C110.3 416 96 401.7 96 384C96 366.3 110.3 352 128 352L352 352C369.7 352 384 366.3 384 384zM96 256C96 238.3 110.3 224 128 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L128 288C110.3 288 96 273.7 96 256zM544 512C544 529.7 529.7 544 512 544L128 544C110.3 544 96 529.7 96 512C96 494.3 110.3 480 128 480L512 480C529.7 480 544 494.3 544 512z"></path>'),I4=Si('<path d="M448 128C448 110.3 433.7 96 416 96L224 96C206.3 96 192 110.3 192 128C192 145.7 206.3 160 224 160L416 160C433.7 160 448 145.7 448 128zM544 256C544 238.3 529.7 224 512 224L128 224C110.3 224 96 238.3 96 256C96 273.7 110.3 288 128 288L512 288C529.7 288 544 273.7 544 256zM96 512C96 529.7 110.3 544 128 544L512 544C529.7 544 544 529.7 544 512C544 494.3 529.7 480 512 480L128 480C110.3 480 96 494.3 96 512zM448 384C448 366.3 433.7 352 416 352L224 352C206.3 352 192 366.3 192 384C192 401.7 206.3 416 224 416L416 416C433.7 416 448 401.7 448 384z"></path>'),Y4=Si('<path d="M544 128C544 145.7 529.7 160 512 160L288 160C270.3 160 256 145.7 256 128C256 110.3 270.3 96 288 96L512 96C529.7 96 544 110.3 544 128zM544 384C544 401.7 529.7 416 512 416L288 416C270.3 416 256 401.7 256 384C256 366.3 270.3 352 288 352L512 352C529.7 352 544 366.3 544 384zM96 256C96 238.3 110.3 224 128 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L128 288C110.3 288 96 273.7 96 256zM544 512C544 529.7 529.7 544 512 544L128 544C110.3 544 96 529.7 96 512C96 494.3 110.3 480 128 480L512 480C529.7 480 544 494.3 544 512z"></path>'),B4=Si('<path d="M342.6 81.4C330.1 68.9 309.8 68.9 297.3 81.4L137.3 241.4C124.8 253.9 124.8 274.2 137.3 286.7C149.8 299.2 170.1 299.2 182.6 286.7L288 181.3L288 552C288 569.7 302.3 584 320 584C337.7 584 352 569.7 352 552L352 181.3L457.4 286.7C469.9 299.2 490.2 299.2 502.7 286.7C515.2 274.2 515.2 253.9 502.7 241.4L342.7 81.4z"></path>'),N4=Si('<path d="M566.6 342.6C579.1 330.1 579.1 309.8 566.6 297.3L406.6 137.3C394.1 124.8 373.8 124.8 361.3 137.3C348.8 149.8 348.8 170.1 361.3 182.6L466.7 288L96 288C78.3 288 64 302.3 64 320C64 337.7 78.3 352 96 352L466.7 352L361.3 457.4C348.8 469.9 348.8 490.2 361.3 502.7C373.8 515.2 394.1 515.2 406.6 502.7L566.6 342.7z"></path>'),U4=Si('<path d="M297.4 566.6C309.9 579.1 330.2 579.1 342.7 566.6L502.7 406.6C515.2 394.1 515.2 373.8 502.7 361.3C490.2 348.8 469.9 348.8 457.4 361.3L352 466.7L352 96C352 78.3 337.7 64 320 64C302.3 64 288 78.3 288 96L288 466.7L182.6 361.3C170.1 348.8 149.8 348.8 137.3 361.3C124.8 373.8 124.8 394.1 137.3 406.6L297.3 566.6z"></path>'),G4=Si('<path d="M73.4 297.4C60.9 309.9 60.9 330.2 73.4 342.7L233.4 502.7C245.9 515.2 266.2 515.2 278.7 502.7C291.2 490.2 291.2 469.9 278.7 457.4L173.3 352L544 352C561.7 352 576 337.7 576 320C576 302.3 561.7 288 544 288L173.3 288L278.7 182.6C291.2 170.1 291.2 149.8 278.7 137.3C266.2 124.8 245.9 124.8 233.4 137.3L73.4 297.3z"></path>'),F4=Si('<path d="M262.2 48C248.9 48 236.9 56.3 232.2 68.8L216 112L120 112C106.7 112 96 122.7 96 136C96 149.3 106.7 160 120 160L520 160C533.3 160 544 149.3 544 136C544 122.7 533.3 112 520 112L424 112L407.8 68.8C403.1 56.3 391.2 48 377.8 48L262.2 48zM128 208L128 512C128 547.3 156.7 576 192 576L448 576C483.3 576 512 547.3 512 512L512 208L464 208L464 512C464 520.8 456.8 528 448 528L192 528C183.2 528 176 520.8 176 512L176 208L128 208zM288 280C288 266.7 277.3 256 264 256C250.7 256 240 266.7 240 280L240 456C240 469.3 250.7 480 264 480C277.3 480 288 469.3 288 456L288 280zM400 280C400 266.7 389.3 256 376 256C362.7 256 352 266.7 352 280L352 456C352 469.3 362.7 480 376 480C389.3 480 400 469.3 400 456L400 280z"></path>'),H4=oe('<div class="tbl-menu-item-icon"><svg xmlns="http://www.w3.org/2000/svg" height="14" width="14" viewBox="0 0 640 640" fill="currentColor"><!></svg></div>');function ei(i,e){var t=H4(),n=mi(t),r=mi(n);{var o=S=>{var x=D4();z(S,x)},s=S=>{var x=j4();z(S,x)},l=S=>{},a=S=>{var x=V4();z(S,x)},c=S=>{var x=I4();z(S,x)},h=S=>{var x=Y4();z(S,x)},f=S=>{var x=B4();z(S,x)},u=S=>{var x=N4();z(S,x)},d=S=>{var x=U4();z(S,x)},O=S=>{var x=G4();z(S,x)},m=S=>{},p=S=>{},b=S=>{var x=F4();z(S,x)};Ot(r,S=>{e.name==="sort-ascending"?S(o):e.name==="sort-descending"?S(s,1):e.name==="align-none"?S(l,2):e.name==="align-left"?S(a,3):e.name==="align-center"?S(c,4):e.name==="align-right"?S(h,5):e.name==="move-up"?S(f,6):e.name==="move-right"?S(u,7):e.name==="move-down"?S(d,8):e.name==="move-left"?S(O,9):e.name==="duplicate"?S(m,10):e.name==="clear"?S(p,11):e.name==="remove"&&S(b,12)})}z(i,t)}var K4=oe('<div class="tbl-menu-item-text"><!></div>');function ti(i,e){var t=K4(),n=mi(t);lo(n,()=>e.children),z(i,t)}var J4=oe('<div class="tbl-menu-separator"></div>');function Rh(i){var e=J4();z(i,e)}var e3=oe('<div class="tbl-select-all-overlay" aria-hidden="true"></div>');function t3(i){var e=e3();z(i,e)}var i3=new Set([Se.c,Se.v,Se.x]);function n3(i,e){return i3.has(i.key)&&i[jL(e)]}var r3=[Se.backspace,Se.delete],o3=new Set(r3);function s3({key:i}){return o3.has(i)?i:void 0}function l3(i){return/^F\d+$/.test(i)}var a3=new Set([Se.alt,Se.escape,Se.enter,Se.shift]);function c3({metaKey:i,ctrlKey:e,key:t}){return!e&&!i&&!a3.has(t)&&!l3(t)}function h3(i,e){e.selection.isCell()||fP({tableState:e,event:i})}function f3(i,e){e.selection.isCell()||uP({tableState:e,event:i})}function u3(i,e){e.selection.isCell()||sg({tableState:e,event:i})}function d3(i,e){if(Z(i.target)&&Z(OP(i.target))){i.preventDefault();return}if(!e.interactive||e.selection.isCell())return;let t=gP(i);if(Z(t)){Gh.navigate({tableState:e,key:t,event:i,position:{left:!0,top:!0,right:!0,bottom:!0}});return}let n=s3(i);if(Z(n)){hP({tableState:e,event:i});return}if(e.activeTable&&Z(e.activeCell)&&c3(i)){e.activeTable=!1,e.anchorCell=e.activeCell;let r=e.table.cellAt(e.activeCell).length;e.selectionValue={cell:e.activeCell,section:{head:r,anchor:r}},e.outlinedSection=Ke.ofCell(e.activeCell);return}n3(i,e.window)||tc(e.rootEditor,i,"editor")&&i.preventDefault()}function cg(i){return i.buttons===1}function SP(i,e){return e.setPointerCapture(i.pointerId),()=>e.releasePointerCapture(i.pointerId)}var Fh=class i{offset;maxScroll;boundaryElement;scrollElement;scroll;handle;xAmount;yAmount;updatePosition(e,t){let n=this.boundaryElement.x.getBoundingClientRect();e<n.left+this.offset?this.xAmount=-Pt(this.offset+(n.left-e),{max:this.maxScroll}):e>n.right-this.offset?this.xAmount=Pt(this.offset-(n.right-e),{max:this.maxScroll}):this.xAmount=0;let r=this.boundaryElement.y.getBoundingClientRect();t<r.top+this.offset?this.yAmount=-Pt(this.offset+(r.top-t),{max:this.maxScroll}):t>r.bottom-this.offset?this.yAmount=Pt(this.offset-(r.bottom-t),{max:this.maxScroll}):this.yAmount=0,I(this.handle)&&(this.xAmount!==0||this.yAmount!==0)&&this.scroll()}destroy(){Z(this.handle)&&cancelAnimationFrame(this.handle)}scrollInternal(){if(this.xAmount===0&&this.yAmount===0){this.scroll();return}this.scrollElement.x.scrollBy({left:this.xAmount}),this.scrollElement.y.scrollBy({top:this.yAmount}),this.scroll()}static of(e){return new i(e)}constructor({offset:e,maxScroll:t,boundaryElement:n,scrollElement:r}){let o=this.scrollInternal.bind(this);this.scroll=()=>{this.handle=requestAnimationFrame(o)},this.xAmount=0,this.yAmount=0,this.offset=e??0,this.maxScroll=t,this.boundaryElement=n,this.scrollElement=r}},Hh=class i{start;size;get mid(){return this.start+this.size/2}get end(){return this.start+this.size}static of(e){return new i(e)}constructor({start:e,size:t}){this.start=e,this.size=t}},Kh;(i=>{function e(t,n){return Xm.of(t,n)}i.of=e})(Kh||(Kh={}));var Xm=class i{rows;cols;rowsOrCols(e){return e==="row"?this.rows:this.cols}rowAt(e){return this.rows[e]}colAt(e){return this.cols[e]}rowOrColAt(e,t){return e==="row"?this.rowAt(t):this.colAt(t)}get firstRow(){return this.rows[this.firstRowIndex]}get firstCol(){return this.cols[this.firstColIndex]}firstRowOrCol(e){return e==="row"?this.firstRow:this.firstCol}get lastRow(){return this.rows[this.lastRowIndex]}get lastCol(){return this.cols[this.lastColIndex]}lastRowOrCol(e){return e==="row"?this.lastRow:this.lastCol}firstRowIndex=0;firstColIndex=0;firstRowOrColIndex(e){return 0}get lastRowIndex(){return this.rowCount-1}get lastColIndex(){return this.colCount-1}lastRowOrColIndex(e){return e==="row"?this.lastRowIndex:this.lastColIndex}get rowCount(){return this.rows.length}get colCount(){return this.cols.length}get minRowSize(){return qh(...this.rows.map(e=>e.size))}get minColSize(){return qh(...this.cols.map(e=>e.size))}moveRowOrColAt(e,{fromIndex:t,toIndex:n}){if(t===n)return;let r=this.rowsOrCols(e),o=r[t];if(t<n){for(let s of ir({start:t,endExclusive:n}))r[s]=r[s+1],r[s].start-=o.size;o.start=r[n].start+r[n].size}else{for(let s of ir({start:t,endExclusive:n}))r[s]=r[s-1],r[s].start+=o.size;o.start=r[n].start-o.size}r[n]=o}lastCellBeforePosition(e){let t=this.rows.map(r=>r.start).findLastIndex(r=>r<e.y),n=this.cols.map(r=>r.start).findLastIndex(r=>r<e.x);return{row:t===-1?0:t,col:n===-1?0:n}}static of(e,t){return new i(e,t)}constructor(e,t){let n=[...e.querySelectorAll("tr:first-child > th")],r=[...e.querySelectorAll("tr > th:first-child,tr > td:first-child")];this.rows=r.map((o,s)=>{let{top:l,height:a}=XQ(o,t),c=0;return Hh.of({start:l+c,size:a-c})}),this.cols=n.map((o,s)=>{let{left:l,width:a}=XQ(o,t),c=s===0?1:0;return Hh.of({start:l+c,size:a-c})})}};function XQ(i,e){let{top:t,left:n,width:r,height:o}=i.getBoundingClientRect();return{top:t+e.y,left:n+e.x,width:r,height:o}}var Jh=class i{tableState;tableMeasurement;autoScroller;shouldAutoScroll;removeEventListeners;currentCell;start(){this.tableState.activeCell=this.currentCell,this.tableState.anchorCell=this.currentCell,this.tableState.outlinedSection=Ke.ofCell(this.currentCell),this.tableState.outline={outlined:!1},this.removeEventListeners=ao(qe(this.tableState.window,"pointermove",e=>this.drag(e)),qe(this.tableState.window,"pointerup",()=>this.end()),qe(this.tableState.window,"pointerleave",()=>this.end()))}resizeAndContinue(e){e.preventDefault(),I(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.currentCell),this.expandOrContract(this.currentCell),this.tableState.outline={outlined:!0},this.removeEventListeners=ao(qe(this.tableState.window,"pointermove",t=>this.drag(t)),qe(this.tableState.window,"pointerup",()=>this.end()),qe(this.tableState.window,"pointerleave",()=>this.end()))}drag(e){if(!cg(e)){this.end();return}e.preventDefault(),this.shouldAutoScroll()&&this.autoScroller.updatePosition(e.clientX,e.clientY);let t=this.tableMeasurement.lastCellBeforePosition({x:e.clientX+this.tableState.scrollOffsetX,y:e.clientY+this.tableState.scrollOffsetY});co(t,this.currentCell)||(this.currentCell=t,this.tableState.outline={outlined:!0},this.expandOrContract(t))}end(){this.removeEventListeners?.(),this.autoScroller.destroy(),this.tableState.outline=void 0}expandOrContract(e){this.tableState.focusTable();let[t,n]=e.row<=this.tableState.anchorCell.row?[e.row,this.tableState.anchorCell.row]:[this.tableState.anchorCell.row,e.row],[r,o]=e.col<=this.tableState.anchorCell.col?[e.col,this.tableState.anchorCell.col]:[this.tableState.anchorCell.col,e.col];this.tableState.outlinedSection=Ke.of({row:{start:t,endExclusive:n+1},col:{start:r,endExclusive:o+1}}),this.tableState.activeCell=e}static startOutline(e){new i(e).start()}static resizeAndContinueOutline(e){new i(e).resizeAndContinue(e.event)}constructor({tableState:e,cellLocation:t}){this.tableState=e,this.currentCell=t,this.autoScroller=Fh.of({offset:10,maxScroll:32,boundaryElement:{x:e.scrollElement,y:e.rootScrollElement},scrollElement:{x:e.scrollElement,y:e.rootScrollElement}}),this.shouldAutoScroll=wq({delayMillis:500}),this.tableMeasurement=Kh.of(e.tableElement,{x:e.scrollOffsetX,y:e.scrollOffsetY})}};function O3(i,e){nf(e.window)&&(e.hoveredCell=i)}function p3(i){nf(i.window)&&(i.hoveredCell=void 0)}function m3(i,e,t){if(!(!t.interactive||!cg(i)))if(i.shiftKey){if(t.selection.isCell()&&co(e,t.selection.cell))return;Jh.resizeAndContinueOutline({event:i,tableState:t,cellLocation:e})}else Jh.startOutline({event:i,tableState:t,cellLocation:e})}var g3=new Intl.Collator(navigator.language,{numeric:!0,sensitivity:"base"});function EQ(i,e){return g3.compare(i,e)}function b3({metaKey:i,shiftKey:e,altKey:t,ctrlKey:n,key:r}){return r===Se.escape&&!e&&!t&&!i&&!n}var Em=class i{tableState;handle;point;removeEventListeners;get rowOrCol(){return this.handle.location}get index(){return this.handle.index}open(){let e=this.tableState.document.body;this.removeEventListeners=ao(qe(e,"pointerdown",s=>{s.preventDefault(),(I(s.target)||!Bk(this.tableState.menuRootElement,s.target))&&this.close()}),qe(e,"wheel",s=>s.preventDefault(),{passive:!1}),qe(e,"keydown",s=>{s.preventDefault(),b3(s)&&this.close()})),this.tableState.focusTable(),this.tableState.activeHandle={state:"active",handle:this.handle},this.tableState.outlinedSection=Ke.of(this.rowOrCol==="row"?{row:{start:this.index,endExclusive:this.index+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:this.index,endExclusive:this.index+1}});let t=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=t,this.tableState.anchorCell=t;let n=this.index!==this.tableState.table.firstRowOrColIndex(this.rowOrCol),r=this.index!==this.tableState.table.lastRowOrColIndex(this.rowOrCol),o=!1;n?o=r?!0:"backward":r&&(o="forward"),this.tableState.menu={type:this.rowOrCol,capabilities:{addable:!0,alignable:this.rowOrCol==="col",clearable:!0,duplicatable:!0,moveable:o,removable:!this.tableState.table.hasSingleRowOrCol(this.rowOrCol),sortable:this.rowOrCol==="col"},clickAdd:s=>this.clickAdd(s),clickAlign:s=>this.clickAlign(s),clickClear:()=>this.clickClear(),clickDuplicate:()=>this.clickDuplicate(),clickMove:s=>this.clickMove(s),clickRemove:()=>this.clickRemove(),clickSort:s=>this.clickSort(s),computeTranslation:s=>this.computeTranslation(s)}}close(){this.removeEventListeners?.(),this.tableState.menu=void 0,this.tableState.activeHandle=void 0}async computeTranslation(e){let t=await Uy({getBoundingClientRect:()=>({x:this.point.x,y:this.point.y,top:this.point.y,right:this.point.x,bottom:this.point.y,left:this.point.x,width:0,height:0})},e,{middleware:[By({allowedPlacements:this.rowOrCol==="row"?["right-start","right-end"]:["right-start","right"]}),Ny({crossAxis:!0})]}),n=gs(e);return{x:Uh(t.x,n),y:Uh(t.y,n)}}clickAdd(e){if(this.tableState.table.addEmptyRowsOrColsAt(this.rowOrCol,{index:e==="before"?this.index:this.index+1,count:1}),e==="after"){this.tableState.outlinedSection=this.tableState.outlinedSection?.shift(this.rowOrCol,"forward");let t=cm(this.rowOrCol,this.tableState.activeCell,"forward");this.tableState.activeCell=t,this.tableState.anchorCell=t}this.close()}clickAlign(e){this.tableState.table.setAlignmentAt(this.index,e),this.close()}clickClear(){this.tableState.table.clearRowOrCol(this.rowOrCol,this.index),this.close()}clickDuplicate(){this.tableState.table.duplicateRowOrColAt(this.rowOrCol,this.index),this.close()}clickMove(e){this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:e==="backward"?this.index-1:this.index+1}),this.tableState.outlinedSection=this.tableState.outlinedSection?.shift(this.rowOrCol,e);let t=cm(this.rowOrCol,this.tableState.activeCell,e);this.tableState.activeCell=t,this.tableState.anchorCell=t,this.close()}clickRemove(){if(this.tableState.table.removeRowsOrColsAt(this.rowOrCol,{index:this.index,count:1}),!this.tableState.table.hasRowOrColAt(this.rowOrCol,this.index)){this.tableState.outlinedSection=this.tableState.outlinedSection?.shift(this.rowOrCol,"backward");let e=cm(this.rowOrCol,this.tableState.activeCell,"backward");this.tableState.activeCell=e,this.tableState.anchorCell=e}this.close()}clickSort(e){this.tableState.table.sortByColAt(this.index,e==="ascending"?(t,n)=>EQ(t.toString(),n.toString()):(t,n)=>EQ(n.toString(),t.toString())),this.close()}static showMenu(e){new i(e).open()}constructor({tableState:e,handle:t,point:n}){this.tableState=e,this.handle=t,this.point=n}},_m=class i{coordinate;initialIndex;size;initialPosition;minBound;maxBound;scrollOffsetX;scrollOffsetY;subject;rowOrCol;tableMeasurement;currentIndex;currentPosition;dragged;start(){return{cellMovement:e=>this.cellMovement(e)}}drag(e){this.currentPosition=e[this.coordinate];let{currentIndex:t,move:n}=this.calculateDrag();return this.currentIndex=t,this.initialIndex!==this.currentIndex&&(this.dragged=!0),Z(n)&&this.tableMeasurement.moveRowOrColAt(this.rowOrCol,n),{cellMovement:r=>this.cellMovement(r)}}end(){return this.initialIndex===this.currentIndex?{moved:!1,dragged:this.dragged}:{moved:!0,toIndex:this.currentIndex}}cellMovement(e){return{border:this.cellBorder(e),state:this.cellState(e),translate:this.cellTranslate(e)}}cellBorder(e){let t=this.isRowOrColExposed(e[this.rowOrCol]),n=this.subject.containsCell(e);return this.rowOrCol==="row"?{top:t,right:!0,bottom:!n||e.row===this.tableMeasurement.lastRowIndex,left:this.tableMeasurement.firstColIndex===e.col}:{top:this.tableMeasurement.firstRowIndex===e.row,right:!n||e.col===this.tableMeasurement.lastColIndex,bottom:!0,left:t}}cellState(e){return this.subject.containsCell(e)?"moving":"shiftable"}cellTranslate(e){let t=this.rowOrColTranslate(e[this.rowOrCol]);return this.rowOrCol==="row"?{x:0,y:t}:{x:t,y:0}}isRowOrColExposed(e){let t=this.reorderIndex(e),n=t===this.tableMeasurement.firstRowOrColIndex(this.rowOrCol),r=t===this.currentIndex+1;return n||r}get rowOrColShift(){if(this.currentIndex!==this.initialIndex)return this.currentIndex<this.initialIndex?{direction:"forwards",range:{start:this.currentIndex,endExclusive:this.initialIndex},indexDiff:1,positionDiff:this.size-1}:{direction:"backwards",range:{start:this.initialIndex+1,endExclusive:this.currentIndex+1},indexDiff:-1,positionDiff:1-this.size}}rowOrColTranslate(e){if(e===this.initialIndex)return Pt(this.currentPosition-this.initialPosition,{min:this.minBound,max:this.maxBound});let t=this.rowOrColShift;return I(t)?0:er(e,t.range)?t.positionDiff:0}reorderIndex(e){let t=this.rowOrColShift;return I(t)?e:e===this.initialIndex?this.currentIndex:er(e,t.range)?e+t.indexDiff:e}calculateDrag(){let e=this.tableMeasurement.rowsOrCols(this.rowOrCol),t={name:"current",index:this.currentIndex,mid:e[this.currentIndex].mid},n=this.currentIndex!==this.tableMeasurement.firstRowOrColIndex(this.rowOrCol)?{name:"left",index:this.currentIndex-1,mid:e[this.currentIndex-1].start+e[this.currentIndex].size/2}:void 0,r=this.currentIndex!==this.tableMeasurement.lastRowOrColIndex(this.rowOrCol)?{name:"right",index:this.currentIndex+1,mid:e[this.currentIndex].start+e[this.currentIndex+1].size+e[this.currentIndex].size/2}:void 0,o=dL(OL([t,n,r]),(s,l)=>hm(this.currentPosition-s.mid)-hm(this.currentPosition-l.mid));return o.name==="current"?{currentIndex:this.currentIndex,move:void 0}:{currentIndex:o.index,move:{fromIndex:this.currentIndex,toIndex:o.index}}}static of(e){return new i(e)}constructor({rowOrCol:e,index:t,position:n,subject:r,tableElement:o,scrollOffsetX:s,scrollOffsetY:l}){this.scrollOffsetX=s,this.scrollOffsetY=l;let a=Kh.of(o,{x:this.scrollOffsetX(),y:this.scrollOffsetY()});this.rowOrCol=e,this.coordinate=e==="row"?"y":"x",this.initialIndex=t,this.initialPosition=n[this.coordinate],this.minBound=a.firstRowOrCol(this.rowOrCol).start-a.rowOrColAt(this.rowOrCol,t).start,this.maxBound=a.lastRowOrCol(this.rowOrCol).end-a.rowOrColAt(this.rowOrCol,t).end,this.size=a.rowOrColAt(this.rowOrCol,t).size,this.subject=r,this.dragged=!1,this.tableMeasurement=a,this.currentIndex=t,this.currentPosition=n[this.coordinate]}},Zm=class i{tableState;rowOrCol;index;onClick;moveTracker;subject;autoScroller;removeEventListeners;start(e){e.preventDefault();let t=this.moveTracker.start();this.tableState.outlinedSection=this.subject,this.tableState.move=t,this.tableState.activeHandle={state:"active",handle:{type:"header",index:this.index,location:this.rowOrCol}};let n=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=n,this.tableState.anchorCell=n,this.tableState.focusTable();let r=tg(e.target);this.removeEventListeners=ao(SP(e,r),qe(r,"pointermove",o=>this.drag(o)),qe(r,"pointerup",()=>this.end()))}drag(e){e.preventDefault(),this.autoScroller.updatePosition(e.clientX,e.clientY),this.tableState.move=this.moveTracker.drag({x:e.clientX+this.tableState.scrollOffsetX,y:e.clientY+this.tableState.scrollOffsetY})}end(){this.removeEventListeners?.(),this.autoScroller.destroy();let e=this.moveTracker.end();if(e.moved){this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:e.toIndex}),this.tableState.outlinedSection=Ke.of(this.rowOrCol==="row"?{row:{start:e.toIndex,endExclusive:e.toIndex+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:e.toIndex,endExclusive:e.toIndex+1}});let t=this.rowOrCol==="row"?{row:e.toIndex,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:e.toIndex};this.tableState.activeCell=t,this.tableState.anchorCell=t}this.tableState.move=void 0,this.tableState.activeHandle=void 0,!e.moved&&!e.dragged&&this.onClick()}static startMove(e){new i(e).start(e.event)}constructor({event:e,tableState:t,rowOrCol:n,index:r,onClick:o}){this.tableState=t,this.rowOrCol=n,this.index=r,this.subject=Ke.of(n==="row"?{row:{start:r,endExclusive:r+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:r,endExclusive:r+1}}),this.onClick=o,this.autoScroller=Fh.of({offset:16,maxScroll:32,boundaryElement:{x:t.scrollElement,y:t.rootScrollElement},scrollElement:{x:t.scrollElement,y:t.rootScrollElement}}),this.moveTracker=_m.of({subject:this.subject,rowOrCol:n,index:r,position:{x:e.clientX+t.scrollOffsetX,y:e.clientY+t.scrollOffsetY},tableElement:t.tableElement,scrollOffsetX:()=>this.tableState.scrollOffsetX,scrollOffsetY:()=>this.tableState.scrollOffsetY})}};function S3(i){return i==="row"?"y":"x"}var Mm=class i{tableState;type;initialHandle;initialRowOrColCount;initialPosition;initialOutlinedSection;initialActiveCell;initialAnchorCell;cellSizePixels;dragThresholdPixels;dragged;start(){return{activeHandle:{state:"active",handle:this.initialHandle}}}drag(e){return this.dragged=!0,this.calculateDrag(e)}end(){return this.dragged?{activeHandle:void 0}:this.calculateClick()}calculateClick(){if(this.type!=="table")return this.calculateClickRowOrCol(this.type);if(this.initialHandle.location==="right")return this.calculateClickRowOrCol("col");if(this.initialHandle.location==="bottom")return this.calculateClickRowOrCol("row");let e=this.calculateClickRowOrCol("row"),t=this.calculateClickRowOrCol("col");return{operation:{row:e.operation.row,col:t.operation.col},activeHandle:e.activeHandle,activeCell:Z(e.activeCell)&&Z(t.activeCell)?{row:e.activeCell.row,col:t.activeCell.col}:void 0,anchorCell:Z(e.anchorCell)&&Z(t.anchorCell)?{row:e.anchorCell.row,col:t.anchorCell.col}:void 0,outlinedSection:Z(e.outlinedSection)&&Z(t.outlinedSection)?Ke.of({row:e.outlinedSection.row,col:t.outlinedSection.col}):void 0}}calculateClickRowOrCol(e){let t=this.type==="table"?this.tableState.table.lastRowOrColIndex(e)+1:this.initialHandle.index;return{operation:{[e]:{action:"add",index:t,count:1}},activeHandle:this.type==="table"?void 0:{state:"hover",handle:{type:"border",location:this.handleLocationAt(t),index:t}},...this.calculateCellMovement(e,1)}}calculateDrag(e){if(this.type!=="table")return this.calculateDragRowOrCol(this.type,e);if(this.initialHandle.location==="right")return this.calculateDragRowOrCol("col",e);if(this.initialHandle.location==="bottom")return this.calculateDragRowOrCol("row",e);let t=this.calculateDragRowOrCol("row",e),n=this.calculateDragRowOrCol("col",e);if(I(t)&&I(n))return;let r=t??this.calculateCellMovement("row",this.rowOrColDiff("row")),o=n??this.calculateCellMovement("col",this.rowOrColDiff("col"));return{operation:{row:t?.operation.row,col:n?.operation.col},activeHandle:t?.activeHandle??n?.activeHandle,activeCell:Z(r.activeCell)&&Z(o.activeCell)?{row:r.activeCell.row,col:o.activeCell.col}:void 0,anchorCell:Z(r.anchorCell)&&Z(o.anchorCell)?{row:r.anchorCell.row,col:o.anchorCell.col}:void 0,outlinedSection:Z(r.outlinedSection)&&Z(o.outlinedSection)?Ke.of({row:r.outlinedSection.row,col:o.outlinedSection.col}):void 0}}calculateDragRowOrCol(e,t){let n=S3(e),r=t.position[n]-this.initialPosition[n],o=SL(r/this.cellSizePixels[e]),s=r%this.cellSizePixels[e]>=this.dragThresholdPixels[e]?1:0,l=this.tableState.table.rowOrColCount(e)-this.initialRowOrColCount[e],a=o+s-l,c=this.type==="table"?this.tableState.table.lastRowOrColIndex(e)+1:this.initialHandle.index+l;if(a!==0)return a>0?this.calculateDragRowOrColMore({rowOrCol:e,start:c,length:a}):this.calculateDragRowOrColLess({rowOrCol:e,start:c,length:qh(-a,c,this.tableState.table.lastRowOrColIndex(e))})}calculateDragRowOrColLess({rowOrCol:e,start:t,length:n}){let r=0;for(let s of ir({start:t-1,endExclusive:t-n-1})){if(!this.tableState.table.hasEmptyRowOrColAt(e,s))break;r++}if(r===0)return;let o=t-(r-1)-1;return{operation:{[e]:{action:"remove",index:t-r,count:r}},activeHandle:this.type==="table"?{state:"active",handle:this.initialHandle}:{state:"active",handle:{type:"border",location:this.handleLocationAt(o),index:o}},...this.calculateCellMovement(e,this.rowOrColDiff(e)-r)}}calculateDragRowOrColMore({rowOrCol:e,start:t,length:n}){return{operation:{[e]:{action:"add",index:t,count:n}},activeHandle:{state:"active",handle:this.type==="table"?this.initialHandle:{type:"border",location:this.handleLocationAt(t+n),index:t+n}},...this.calculateCellMovement(e,this.rowOrColDiff(e)+n)}}calculateCellMovement(e,t){let n=this.type==="table"?this.initialRowOrColCount[e]:this.initialHandle.index;if(t>=0)return{outlinedSection:this.initialOutlinedSection?.addForwardsByRowOrCol(e,{start:n,count:t}),activeCell:Z(this.initialActiveCell)?wQ(e,this.initialActiveCell,{start:n,count:t}):void 0,anchorCell:Z(this.initialAnchorCell)?wQ(e,this.initialAnchorCell,{start:n,count:t}):void 0};{let r=-t,o=this.initialOutlinedSection?.subtractBackwardsByRowOrCol(e,{start:n,count:r,min:this.tableState.table.firstRowOrColIndex(e)}),s=Z(o)?{min:o.startRowOrCol(e),max:o.endRowOrCol(e)}:void 0,l=Z(this.initialActiveCell)?yQ(e,this.initialActiveCell,{start:n,count:r,boundary:s}):void 0,a=Z(this.initialAnchorCell)?yQ(e,this.initialAnchorCell,{start:n,count:r,boundary:s}):void 0;return{outlinedSection:o,activeCell:l,anchorCell:a}}}rowOrColDiff(e){return this.tableState.table.rowOrColCount(e)-this.initialRowOrColCount[e]}handleLocationAt(e){if(this.type!=="table")return this.type==="row"&&e===this.tableState.table.firstRowIndex?"top":this.type==="col"&&e===this.tableState.table.firstColIndex?"left":this.type}handleToType(e){return e.type==="table"?"table":e.location==="top"?"row":e.location==="left"?"col":e.location}static of(e){return new i(e)}constructor({tableState:e,handle:t,position:n,cellSizePixels:r,dragThresholdPixels:o}){this.tableState=e,this.type=this.handleToType(t),this.initialHandle=t,this.initialPosition=n,this.initialRowOrColCount={row:e.table.rowCount,col:e.table.colCount},this.initialActiveCell=e.activeCell,this.initialAnchorCell=e.anchorCell,this.initialOutlinedSection=e.outlinedSection,this.cellSizePixels=r,this.dragThresholdPixels=o,this.dragged=!1}};function x3(i){let e=Bh(i.tableElement,i.table.firstCellLocation),t=O4(e),{minWidth:n}=getComputedStyle(e),{lineHeight:r,paddingTop:o,paddingBottom:s}=getComputedStyle(t),l=parseFloat(n)+1,a=parseFloat(r)+parseFloat(o)+parseFloat(s)+1;return{width:l,height:a}}var Lm=class i{tableState;resizeTracker;removeEventListeners;start(e){e.preventDefault();let t=this.resizeTracker.start();this.tableState.resize={},this.tableState.activeHandle=t.activeHandle,this.tableState.focusTable(),this.removeEventListeners=ao(SP(e,this.tableState.tableElement),qe(this.tableState.tableElement,"pointermove",n=>this.drag(n)),qe(this.tableState.tableElement,"pointerup",()=>this.end()))}drag(e){e.preventDefault();let t=this.resizeTracker.drag({position:{x:e.clientX,y:e.clientY}});Z(t)&&(this.resizeTable(t.operation),this.tableState.activeHandle=t.activeHandle,this.tableState.activeCell=t.activeCell,this.tableState.anchorCell=t.anchorCell,this.tableState.outlinedSection=t.outlinedSection)}end(){this.removeEventListeners?.();let e=this.resizeTracker.end();"operation"in e&&(this.resizeTable(e.operation),this.tableState.activeCell=e.activeCell,this.tableState.anchorCell=e.anchorCell,this.tableState.outlinedSection=e.outlinedSection),this.tableState.activeHandle=e.activeHandle,this.tableState.resize=void 0}resizeTable({row:e,col:t}){if(Z(e)){let{action:n,index:r,count:o}=e;n==="add"?this.tableState.table.addEmptyRowsAt({row:r,count:o}):this.tableState.table.removeRowsAt({row:r,count:o})}if(Z(t)){let{action:n,index:r,count:o}=t;n==="add"?this.tableState.table.addEmptyColsAt({col:r,count:o}):this.tableState.table.removeColsAt({col:r,count:o})}}static startResize(e){new i(e).start(e.event)}constructor({event:e,tableState:t,handle:n}){this.tableState=t;let{width:r,height:o}=x3(t);this.resizeTracker=Mm.of({tableState:this.tableState,handle:n,position:{x:e.clientX,y:e.clientY},cellSizePixels:{row:o,col:r},dragThresholdPixels:{row:o/2,col:r/2}})}};function v3(i,e){e.interactive&&(e.activeHandle={state:"hover",handle:i})}function w3(i){i.interactive&&(i.activeHandle=void 0)}function y3(i,e,t){if(t.interactive){if(!cg(i)){i.preventDefault();return}e.type==="table"||e.type==="border"?Lm.startResize({event:i,handle:e,tableState:t}):e.type==="header"&&Zm.startMove({event:i,rowOrCol:e.location,index:e.index,tableState:t,onClick:()=>Em.showMenu({handle:e,point:{x:i.clientX,y:i.clientY},tableState:t})})}}function Q3(i,e){let t=i.target;if(I(t))return;let n=ag(t);if(Z(n)){v3(n,e);return}let r=ra(t);if(Z(r)){O3(ff(r),e);return}}function k3(i,e){let t=i.target;if(I(t))return;let n=ag(t);if(Z(n)){w3(e);return}let r=ra(t);if(Z(r)){p3(e);return}}function P3(i,e){let t=i.target;if(I(t))return;let n=ag(t);if(Z(n)){y3(i,n,e);return}let r=ra(t);if(Z(r)){m3(i,ff(r),e);return}i.preventDefault()}function $3(i){i.preventDefault()}var C3=oe("<!> <!> <!>",1),T3=oe('<tr class="tbl-table-row"></tr>'),R3=oe('<tbody class="tbl-table-body"></tbody>'),A3=oe("<!> <!>",1),X3=oe("<!> <!>",1),E3=oe("<!> <!> <!>",1),_3=oe("<!> <!>",1),Z3=oe("<!> <!>",1),M3=oe("<!> <!>",1),L3=oe("<!> <!>",1),z3=oe("<!> <!> <!> <!> <!>",1),q3=oe("<!> <!>",1),W3=oe("<!> <!>",1),D3=oe("<!> <!> <!>",1),j3=oe("<!> <!>",1),V3=oe("<!> <!>",1),I3=oe("<!> <!> <!>",1),Y3=oe("<!> <!>",1),B3=oe("<!> <!>",1),N3=oe("<!> <!>",1),U3=oe("<!> <!> <!> <!> <!> <!> <!>",1),G3=oe('<div class="tbl-table-wrapper"><table class="tbl-table" role="grid" tabindex="-1"><thead class="tbl-table-head"><!></thead><!></table> <!> <!> <!> <!></div>');function F3(i,e){cr(e,!0);let t=Am.of({table:()=>e.table,selection:()=>e.selection,scrollElement:()=>e.scrollElement,rootEditor:()=>e.rootEditor,menuRootElement:()=>e.menuRootElement,extensions:()=>e.extensions,markdownConfig:()=>e.markdownConfig,globalKeyBindings:()=>e.globalKeyBindings,selectionType:()=>e.selectionType,lineWrapping:()=>e.lineWrapping,onUndo:()=>e.onUndo,onRedo:()=>e.onRedo,onNavigate:()=>e.onNavigate,onDelete:()=>e.onDelete});af(()=>ao(qe(t.document,"selectionchange",()=>p4(t)),qe(t.document.body,"pointerdown",()=>a4(t),{capture:!0,passive:!0}),qe(t.document.body,"pointerup",()=>c4(t),{capture:!0,passive:!0}),qe(t.document.body,"pointerleave",()=>h4(t),{capture:!0,passive:!0}),qe(t.document.body,"copy",w=>f4(w,t)),qe(t.document.body,"cut",w=>u4(w,t)),qe(t.document.body,"paste",w=>d4(w,t))));var n=G3(),r=mi(n);{let w=(y,k=JQ)=>{var v=T3();$h(v,20,()=>t.table.colIndices,$=>$,($,L)=>{let A=G(()=>({row:k(),col:L})),q=G(()=>({top:k()===t.table.firstRowIndex,left:L===t.table.firstColIndex})),M=G(()=>t.selection.isCell()&&co(P(A),t.selection.cell));{let H=G(()=>t.outlinedSection?.containsOnEdge(P(A))??{top:!1,right:!1,bottom:!1,left:!1}),F=G(()=>t.move?.cellMovement(P(A)));Q4($,{get location(){return P(A)},get alignment(){return t.table.alignments[L]},get selected(){return P(M)},get position(){return P(q)},get outline(){return P(H)},get movement(){return P(F)},get win(){return t.window},children:(se,Ze)=>{var We=C3(),ye=ze(We);$h(ye,16,()=>n4(P(A),P(q)),Qe=>Qe,(Qe,Je)=>{{let bt=G(()=>t.cellHandleState(P(A),Je)),Et=G(()=>Z(t.resize));AQ(Qe,{get of(){return Je},get state(){return P(bt)},get toggle(){return P(Et)}})}});var Me=te(ye,2);_4(Me,{get hidden(){return P(M)},children:(Qe,Je)=>{var bt=eg(),Et=ze(bt);cq(Et,()=>Jq(t.table.cellAt(P(A)),t.highlighter(P(A)))),z(Qe,bt)},$$slots:{default:!0}});var st=te(Me,2);{var Dt=Qe=>{var Je=()=>t.table.cellAt(P(A)),bt=pe=>t.table.setCellAt(P(A),pe),Et=()=>t.selection.cellSection,K=pe=>{t.selectionValue={cell:P(A),section:pe}};{let pe=G(()=>t.highlighter(P(A)));$4(Qe,{get text(){return Je()},set text(me){bt(me)},get selection(){return Et()},set selection(me){K(me)},get selectionType(){return t.selectionType},get lineWrapping(){return t.lineWrapping},get extensions(){return t.extensions},get markdownConfig(){return t.markdownConfig},get rootEditor(){return t.rootEditor},get globalKeyBindings(){return t.globalKeyBindings},get highlighter(){return P(pe)},onbeforeinput:me=>T4(me,t),ondragstart:me=>R4(me),onkeydown:(me,Re)=>A4(me,Re,t),onpaste:me=>X4(me,t)})}};Ot(st,Qe=>{P(M)&&Qe(Dt)})}z(se,We)},$$slots:{default:!0}})}}),z(y,v)};var o=mi(r),s=mi(o);w(s,()=>t.table.headerRowIndex);var l=te(o);{var a=y=>{var k=R3();$h(k,20,()=>t.table.dataRowIndices,v=>v,(v,$)=>{w(v,()=>$)}),z(y,k)},c=G(()=>t.table.hasDataRows());Ot(l,y=>{P(c)&&y(a)})}Ih(r,y=>t.tableElement=y,()=>t?.tableElement)}var h=te(r,2);{var f=w=>{let y=G(()=>t.menu.type==="row"?"row":"column");b4(w,{get to(){return t.menuRootElement},children:(k,v)=>{q4(k,{translate:$=>t.menu.computeTranslation($),children:($,L)=>{let A=G(()=>{let{addable:K,alignable:pe,clearable:me,duplicatable:Re,moveable:Be,removable:Ne,sortable:$t}=t.menu.capabilities;return{addable:K,alignable:pe,clearable:me,duplicatable:Re,moveable:Be,removable:Ne,sortable:$t}});var q=U3(),M=ze(q);{var H=K=>{var pe=E3(),me=ze(pe);Kt(me,{onclick:()=>Jt({action:"sort",direction:"ascending"},t),children:(Ne,$t)=>{var ue=A3(),ge=ze(ue);ei(ge,{name:"sort-ascending"});var De=te(ge,2);ti(De,{children:(ke,lt)=>{var Ae=Ht();Qt(()=>xn(Ae,`Sort by ${P(y)??""} (A-Z)`)),z(ke,Ae)}}),z(Ne,ue)}});var Re=te(me,2);Kt(Re,{onclick:()=>Jt({action:"sort",direction:"descending"},t),children:(Ne,$t)=>{var ue=X3(),ge=ze(ue);ei(ge,{name:"sort-descending"});var De=te(ge,2);ti(De,{children:(ke,lt)=>{var Ae=Ht();Qt(()=>xn(Ae,`Sort by ${P(y)??""} (Z-A)`)),z(ke,Ae)}}),z(Ne,ue)}});var Be=te(Re,2);Rh(Be),z(K,pe)};Ot(M,K=>{P(A).sortable&&K(H)})}var F=te(M,2);{var se=K=>{var pe=z3(),me=ze(pe);Kt(me,{onclick:()=>Jt({action:"align",alignment:"none"},t),children:(ue,ge)=>{var De=_3(),ke=ze(De);ei(ke,{name:"align-none"});var lt=te(ke,2);ti(lt,{children:(Ae,xi)=>{var Hi=Ht("Align none");z(Ae,Hi)}}),z(ue,De)}});var Re=te(me,2);Kt(Re,{onclick:()=>Jt({action:"align",alignment:"left"},t),children:(ue,ge)=>{var De=Z3(),ke=ze(De);ei(ke,{name:"align-left"});var lt=te(ke,2);ti(lt,{children:(Ae,xi)=>{var Hi=Ht("Align left");z(Ae,Hi)}}),z(ue,De)}});var Be=te(Re,2);Kt(Be,{onclick:()=>Jt({action:"align",alignment:"center"},t),children:(ue,ge)=>{var De=M3(),ke=ze(De);ei(ke,{name:"align-center"});var lt=te(ke,2);ti(lt,{children:(Ae,xi)=>{var Hi=Ht("Align center");z(Ae,Hi)}}),z(ue,De)}});var Ne=te(Be,2);Kt(Ne,{onclick:()=>Jt({action:"align",alignment:"right"},t),children:(ue,ge)=>{var De=L3(),ke=ze(De);ei(ke,{name:"align-right"});var lt=te(ke,2);ti(lt,{children:(Ae,xi)=>{var Hi=Ht("Align right");z(Ae,Hi)}}),z(ue,De)}});var $t=te(Ne,2);Rh($t),z(K,pe)};Ot(F,K=>{P(A).alignable&&K(se)})}var Ze=te(F,2);{var We=K=>{var pe=D3(),me=ze(pe);Kt(me,{onclick:()=>Jt({action:"add",direction:"before"},t),children:(Ne,$t)=>{var ue=q3(),ge=ze(ue);ei(ge,{name:"add-before"});var De=te(ge,2);ti(De,{children:(ke,lt)=>{var Ae=Ht();Qt(()=>xn(Ae,`Add ${P(y)??""} ${P(y)==="row"?"above":"before"}`)),z(ke,Ae)}}),z(Ne,ue)}});var Re=te(me,2);Kt(Re,{onclick:()=>Jt({action:"add",direction:"after"},t),children:(Ne,$t)=>{var ue=W3(),ge=ze(ue);ei(ge,{name:"add-after"});var De=te(ge,2);ti(De,{children:(ke,lt)=>{var Ae=Ht();Qt(()=>xn(Ae,`Add ${P(y)??""} ${P(y)==="row"?"below":"after"}`)),z(ke,Ae)}}),z(Ne,ue)}});var Be=te(Re,2);Rh(Be),z(K,pe)};Ot(Ze,K=>{P(A).addable&&K(We)})}var ye=te(Ze,2);{var Me=K=>{var pe=I3(),me=ze(pe);{var Re=ue=>{Kt(ue,{onclick:()=>Jt({action:"move",direction:"backward"},t),children:(ge,De)=>{var ke=j3(),lt=ze(ke);{let xi=G(()=>`move-${P(y)==="row"?"up":"left"}`);ei(lt,{get name(){return P(xi)}})}var Ae=te(lt,2);ti(Ae,{children:(xi,Hi)=>{var xs=Ht();Qt(()=>xn(xs,`Move ${P(y)??""} ${P(y)==="row"?"up":"left"}`)),z(xi,xs)}}),z(ge,ke)}})};Ot(me,ue=>{(P(A).moveable==="backward"||P(A).moveable===!0)&&ue(Re)})}var Be=te(me,2);{var Ne=ue=>{Kt(ue,{onclick:()=>Jt({action:"move",direction:"forward"},t),children:(ge,De)=>{var ke=V3(),lt=ze(ke);{let xi=G(()=>`move-${P(y)==="row"?"down":"right"}`);ei(lt,{get name(){return P(xi)}})}var Ae=te(lt,2);ti(Ae,{children:(xi,Hi)=>{var xs=Ht();Qt(()=>xn(xs,`Move ${P(y)??""} ${P(y)==="row"?"down":"right"}`)),z(xi,xs)}}),z(ge,ke)}})};Ot(Be,ue=>{(P(A).moveable==="forward"||P(A).moveable===!0)&&ue(Ne)})}var $t=te(Be,2);Rh($t),z(K,pe)};Ot(ye,K=>{P(A).moveable!==!1&&K(Me)})}var st=te(ye,2);{var Dt=K=>{Kt(K,{onclick:()=>Jt({action:"duplicate"},t),children:(pe,me)=>{var Re=Y3(),Be=ze(Re);ei(Be,{name:"duplicate"});var Ne=te(Be,2);ti(Ne,{children:($t,ue)=>{var ge=Ht();Qt(()=>xn(ge,`Duplicate ${P(y)??""}`)),z($t,ge)}}),z(pe,Re)}})};Ot(st,K=>{P(A).duplicatable&&K(Dt)})}var Qe=te(st,2);{var Je=K=>{Kt(K,{onclick:()=>Jt({action:"clear"},t),children:(pe,me)=>{var Re=B3(),Be=ze(Re);ei(Be,{name:"clear"});var Ne=te(Be,2);ti(Ne,{children:($t,ue)=>{var ge=Ht();Qt(()=>xn(ge,`Clear ${P(y)??""}`)),z($t,ge)}}),z(pe,Re)}})};Ot(Qe,K=>{P(A).clearable&&K(Je)})}var bt=te(Qe,2);{var Et=K=>{Kt(K,{onclick:()=>Jt({action:"remove"},t),children:(pe,me)=>{var Re=N3(),Be=ze(Re);ei(Be,{name:"remove"});var Ne=te(Be,2);ti(Ne,{children:($t,ue)=>{var ge=Ht();Qt(()=>xn(ge,`Delete ${P(y)??""}`)),z($t,ge)}}),z(pe,Re)}})};Ot(bt,K=>{P(A).removable&&K(Et)})}z($,q)},$$slots:{default:!0}})},$$slots:{default:!0}})},u=G(()=>Z(t.menu));Ot(h,w=>{P(u)&&w(f)})}var d=te(h,2);$h(d,16,()=>i4,w=>w,(w,y)=>{{let k=G(()=>Rm(t.activeHandle?.handle,y)?t.activeHandle.state:void 0);AQ(w,{get of(){return y},get state(){return P(k)}})}});var O=te(d,2);{var m=w=>{x4(w)},p=G(()=>!t.interactive&&I(t.outline));Ot(O,w=>{P(p)&&w(m)})}var b=te(O,2);{var S=w=>{t3(w)},x=G(()=>t.selection.isAll());Ot(b,w=>{P(x)&&w(S)})}Ih(n,w=>t.wrapperElement=w,()=>t?.wrapperElement),Qt(w=>Ce(n,"data-select-all",w),[()=>no(t.selection.isAll())]),Wl("mouseover",n,w=>Q3(w,t)),Wl("mouseout",n,w=>k3(w,t)),Wl("pointerdown",n,w=>P3(w,t)),kh("dragover",n,w=>$3(w)),Wl("keydown",r,w=>d3(w,t)),kh("copy",r,w=>h3(w,t)),kh("cut",r,w=>f3(w,t)),kh("paste",r,w=>u3(w,t)),z(i,n),hr()}Dk(["mouseover","mouseout","pointerdown","keydown"]);var zm=class i extends Le{tableDescription;widgetElement;height;destroyWidgetElement;get estimatedHeight(){return this.height}coordsAt(e,t,n){let r=this.tableDescription.table.closestCellAtPosition(t),o=Bh(e,r);if(I(o))return null;let s=o.getBoundingClientRect();return{top:s.top,right:s.right,bottom:s.bottom,left:s.left}}toDOM(e){if(Z(this.widgetElement))return this.widgetElement;let{widgetElement:t,destroyWidgetElement:n}=this.create(e);return this.widgetElement=t,this.destroyWidgetElement=n,e.requestMeasure({read:()=>{this.height=t.getBoundingClientRect().height}}),t}destroy(e){this.destroyWidgetElement?.(),this.destroyWidgetElement=void 0,this.widgetElement=void 0,this.height=pQ}create(e){let t=Ul(e.dom).createElement("div");t.className="tbl-table-widget",t.tabIndex=-1,t.addEventListener("pointerdown",d=>{d?.target===t&&d.preventDefault()});let n=this.tableDescription,r=Bz(()=>{sf(()=>{let d=!n.table.text.eq(n.editorTableText),O=!hf(n.selection.value,n.editorSelectionValue);if(!d&&!O)return;let m;if(n.selection.isCell()){let{from:b}=n.table.cellSpan(n.selection.cell);m={anchor:n.from+b+n.selection.cellSection.anchor,head:n.from+b+n.selection.cellSection.head}}else n.selection.isAll()?m={anchor:n.from,head:n.to}:n.selection.isHidden()&&(m={anchor:n.from+1,head:n.from+1});let p=d?{from:n.from,to:n.to,insert:n.table.text}:void 0;n.markSynchronized(),e.dispatch({annotations:or("table.edit"),changes:p,selection:m})})}),{extensions:o,markdownConfig:s,globalKeyBindings:l,selectionType:a,lineWrapping:c}=wP(e.state),h=jk(F3,{target:t,props:{table:n.table,selection:n.selection,scrollElement:t,rootEditor:e,extensions:o,markdownConfig:s,globalKeyBindings:l,selectionType:a,lineWrapping:c,menuRootElement:Is(e,sP).dom,onUndo:()=>yc(e),onRedo:()=>il(e),onNavigate:d=>{e.dispatch({annotations:or("table.navigate"),selection:{anchor:d==="before"?n.from-1:n.to+1}}),e.focus()},onDelete:()=>{e.dispatch({annotations:or("table.delete"),changes:{from:n.from,to:n.to},selection:e.state.selection}),e.focus()}}}),f=()=>{Vk(h)},u=xq(t,({height:d})=>{this.height=d});return{widgetElement:t,destroyWidgetElement:ao(r,f,u)}}static of(e,t){return new i(e,t)}constructor(e,t){super(),this.tableDescription=e;let n=aW(t);if(Z(n)){let{widgetElement:r,destroyWidgetElement:o}=this.create(n);this.widgetElement=r,this.destroyWidgetElement=o,this.height=Sq(n,r)}else this.widgetElement=void 0,this.destroyWidgetElement=void 0,this.height=pQ}};function H3(i,e){return{widget:zm.of(i,e),block:!0,inclusive:!0}}function K3(i,e){return R.replace(H3(i,e))}function J3(i,e){let t=new Ue;for(let n of i)t.add(n.from,n.to,K3(n,e));return t.finish()}function eW(i){return xP(i)}function tW(i,e){return xP(i,e)}function xP(i,e=[]){let t=[];sL(B(i),o=>{DQ(o)&&t.push({from:i.doc.lineAt(o.from).from,to:i.doc.lineAt(o.to).to})});let n=[],r=[];for(let o of t){if(mL(e,o,GQ)){n.push(o);continue}let s=iW(o,i);tf(s)?n.push(o):r.push(...s)}return{spans:n,formatting:r,complete:P1(i)}}function iW(i,e){return[...nW(i,e),...rW(i,e)]}function nW(i,{doc:e,lineBreak:t}){return Hl({doc:e,lineBreak:t,span:i}).changes}function rW({from:i,to:e},{doc:t}){let n=t.slice(i,e),{text:r}=fm(n);return n.eq(r)?[]:[{from:i,to:e,insert:r}]}var oW={create(i){return Ah(i)},update(i,e){if(Eq(e))return Ah(e.state);if(!e.docChanged&&I(e.selection)&&i.complete)return i;let{tables:t,formatting:n,decorations:r}=i;if(!e.docChanged&&i.complete)return{tables:_Q(t,e),formatting:n,decorations:r.map(e.changes),complete:!0};if(Xq(e)||sW(e,t))return Ah(e.state);let o=_Q(t,e).map(c=>c.span),{complete:s,spans:l,formatting:a}=tW(e.state,o);return Kn(o,l,GQ)?{complete:s,tables:t,formatting:a,decorations:r.map(e.changes)}:Ah(e.state)},provide(i){return C.decorations.from(i,e=>e.decorations)}},vP=le.define(oW);function Ah(i){let{spans:e,formatting:t,complete:n}=eW(i),{doc:r,selection:o}=i,s=e.map(l=>$m.of({span:l,doc:r,selection:o}));return{complete:n,tables:s,formatting:t,decorations:J3(s,i)}}function sW(i,e){return!rg(i)&&e.some(t=>i.changes.touchesRange(t.from,t.to)!==!1)}function _Q(i,e){return hL(i,t=>t.applyTransaction(e))}var lW={create(){return{view:void 0}},update(i){return i}},hg=le.define(lW);function wP(i){return i.facet(um)}function lr(i){return i.field(vP)}function aW(i){return i.field(hg).view}function cW(i){let{handlePosition:e,selectionType:t,lineWrapping:n}=wP(i);return{...nf(window)?{"data-tbl-hoverable":""}:{},"data-tbl-theme-mode":i.facet(C.darkTheme)?"dark":"light","data-tbl-handle-position":e,"data-tbl-selection-type":t,"data-tbl-line-wrapping":n}}var hW=["undo","redo","select.undo","select.redo"];function fW(i){return hW.some(e=>i.isUserEvent(e))}function uW(i){return yP(i,"select.search")}function dW(i){return yP(i,"select")}function OW(i){return i.isUserEvent("delete.forward")}function pW(i){return i.isUserEvent("delete.backward")}function yP(i,e){return i.annotation(Pe.userEvent)===e}var mW=({state:i,view:e,transactions:t})=>{e.hasFocus||lr(i).tables.some(n=>n.containsSelection())||t.some(n=>fW(n)||uW(n)&&!mP(e))&&e.focus()},QP=D.define(),gW=new Map(Hk.map(i=>[i,QP.of(i)]));function kP(i){return gW.get(i)}var bW=(i,e)=>!e||!lr(i).tables.some(t=>t.containsSelection())?null:kP("table.focus"),SW=i=>{let{selection:e,startState:t,docChanged:n}=i;if(I(e)||n||!dW(i)||!Zh(e)||!Zh(t.selection))return i;let r=t.selection.main,o=e.main;for(let s of lr(t).tables){let l=s.from===o.head,a=s.to===o.head,c=s.from===r.head+1&&s.to===o.head-1,h=s.from===o.head+1&&s.to===r.head-1,f;if(l?f=s.table.firstCellSpan.from:c?f=s.table.firstCellSpan.to:(a||h)&&(f=s.table.lastCellSpan.to),Z(f))return[i,{annotation:or("table.navigate"),selection:VM({pos:s.from+f})}]}return i},xW=i=>{let{selection:e,startState:t}=i;if(I(e)||!Zh(e))return i;let n=t.selection.main;if(OW(i)){for(let r of lr(t).tables)if(n.head===r.from-1){let o=r.table.firstCellSpan.from;return[{selection:{anchor:r.from+o,head:r.from+o}}]}return i}else if(pW(i)){for(let r of lr(t).tables)if(n.head===r.to+1){let o=r.table.lastCellSpan.to;return[{selection:{anchor:r.from+o,head:r.from+o}}]}return i}else return i};function vW(i){return cS(i)>0||hS(i)>0}var wW=({state:i,docChanged:e,selectionSet:t,transactions:n,view:r})=>{if(!e&&!t&&vW(i)||n.some(a=>rg(a)))return;let{formatting:o}=lr(i);if(tf(o))return;let s=et.of(o,i.doc.length,i.lineBreak),l=i.selection.map(s);r.dispatch({annotations:or("table.format"),changes:s,selection:l})},yW=i=>{if(!i.docChanged||rg(i))return i;let e=i.changes,{tables:t}=lr(i.startState),n=[];for(let s of t)if(e.touchesRange(s.from-1,s.from)!==!1||e.touchesRange(s.to,s.to+1)!==!1){let l={from:e.mapPos(s.from,1),to:e.mapPos(s.to)};if(l.from>=l.to)continue;n.push(Hl({doc:i.newDoc,lineBreak:i.startState.lineBreak,span:l}).changes)}if(tf(n))return i;let r=et.of(n,i.changes.newLength,i.startState.lineBreak),o=i.newSelection.map(r);return[i,{annotation:or("table.correct"),changes:r,selection:o,sequential:!0}]};function QW(i,{anchor:e,head:t,goalColumn:n,bidiLevel:r}={}){return Q.range(e??i.anchor,t??i.head,n??i.goalColumn,r??i.bidiLevel??void 0)}var kW=i=>{let{selection:e,startState:t,docChanged:n}=i;if(I(e)||n||Zh(e))return i;let r=e.ranges.map(o=>{if(o.empty)return o;let s=lr(t).tables,l=ZQ(o.anchor,s),a=ZQ(o.head,s);return Z(l)||Z(a)?QW(o,{anchor:l,head:a}):o});return Kn(e.ranges,r,(o,s)=>o===s)?i:[i,{annotations:or("table.select"),selection:Q.create(r,e.mainIndex)}]};function ZQ(i,e){for(let t of e){let n=t.from,r=t.to,o=t.from+1,s=t.to-1;if(i===n||i===o)return n-1;if(i===r||i===s)return r+1}}var PW={"& .cm-tooltip.cm-tooltip-autocomplete:has(.cm-completionIcon-table)":{border:"1px solid var(--tbl-theme-menu-border-color)","box-shadow":"2px 2px 0 0 rgb(0 0 0 / 10%)","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)"},"& .cm-tooltip.cm-tooltip-autocomplete > ul:has(.cm-completionIcon-table)":{"min-width":"auto",display:"flex","flex-direction":"column","justify-content":"center",padding:"0.25em 0","line-height":1,"font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)",background:"var(--tbl-theme-menu-background)"},"& .cm-tooltip.cm-tooltip-autocomplete ul li[aria-selected]:has(.cm-completionIcon-table)":{color:"var(--tbl-theme-menu-hover-text-color)","&::before":{background:"var(--tbl-theme-menu-hover-background)"}},"& .cm-tooltip.cm-tooltip-autocomplete ul li:not([aria-selected]):has(.cm-completionIcon-table)":{color:"var(--tbl-theme-menu-text-color)"},"& .cm-tooltip.cm-tooltip-autocomplete ul li:not([aria-selected]):has(.cm-completionIcon-table), & .cm-tooltip.cm-tooltip-autocomplete ul li[aria-selected]:has(.cm-completionIcon-table)":{position:"relative",padding:"0.5em 0.75em",background:"var(--tbl-theme-menu-background)",display:"flex",gap:"0.75em","align-items":"center","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)","line-height":1,"&::before":{position:"absolute",height:"100%",width:"calc(100% - 0.5em)",left:"0.25em",top:0,content:'""',"pointer-events":"none"}},"& .cm-completionIcon.cm-completionIcon-table":{opacity:1,"mask-image":`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='14' width='12.25' viewBox='0 0 448 512'%3E%3C!--!Font Awesome Free v7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2026 Fonticons, Inc.--%3E%3Cpath d='M384 96l-128 0 0 128 128 0 0-128zm64 128l0 192c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96C0 60.7 28.7 32 64 32l320 0c35.3 0 64 28.7 64 64l0 128zM64 288l0 128 128 0 0-128-128 0zm128-64l0-128-128 0 0 128 128 0zm64 64l0 128 128 0 0-128-128 0z'/%3E%3C/svg%3E")`,"mask-position":"center","mask-repeat":"no-repeat",padding:0,background:"currentColor",position:"relative",width:"1em",height:"1em","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)","line-height":1},"& :has(.cm-completionIcon.cm-completionIcon-table) .cm-completionLabel":{position:"relative"}},$W={'&[data-tbl-handle-position="inside"] .tbl-table-widget':{"padding-left":"6px","margin-left":0},".tbl-table-widget":{contain:"paint","padding-top":"16px","padding-right":"16px","padding-bottom":"16px","padding-left":"16px","margin-left":"-10px","overflow-x":"auto","overflow-y":"hidden","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}},"&.cm-editor .cm-content div.tbl-table-widget::selection, & .cm-content div.tbl-table-widget ::selection, & .cm-content div.tbl-table-widget:focus::selection, & .cm-content div.tbl-table-widget :focus::selection":{"background-color":"transparent !important","caret-color":"transparent !important"}},CW={".cm-tooltip.tbl-menu-tooltip":{border:"none","user-select":"none","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}}},TW={".tbl-blocking-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"transparent",width:"100%",height:"100%"}},RW={"& .cm-content div.tbl-table-widget .tbl-cell-editor ::selection, & .cm-content div.tbl-table-widget .tbl-cell-editor :focus::selection":{"background-color":"Highlight !important","caret-color":"initial !important"},"&[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content":{"caret-color":"transparent !important"},"&[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content ::selection, &[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content :focus::selection":{"background-color":"transparent !important","caret-color":"transparent !important"},"&[data-tbl-line-wrapping='wrap'] .tbl-cell-editor .cm-editor .cm-content":{"word-break":"normal","overflow-wrap":"break-word"},".tbl-cell-editor":{height:"100%"},".tbl-cell-editor .cm-editor":{margin:0,padding:0,outline:"none",height:"100%",background:"unset",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-scroller":{margin:0,padding:0,overflow:"hidden","line-height":1.5,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-content":{margin:0,padding:"7px 9px","line-height":1.5,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-line":{margin:0,padding:"0 1px","line-height":1.5,"touch-action":"none","font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"}},AW={".tbl-cell":{"box-sizing":"content-box",position:"relative","vertical-align":"top","background-color":"var(--tbl-row-background)",padding:0,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)","min-width":"calc(4ch + 20px)",height:"inherit","user-select":"none",border:"none","scroll-margin-right":"1px","scroll-margin-left":"1px","&:first-child":{"scroll-margin-left":"16px"},"&:last-child":{"scroll-margin-right":"16px"},'&[align="left"]':{"text-align":"left"},'&[align="center"]':{"text-align":"center"},'&[align="right"]':{"text-align":"right"},'&[data-border~="top"]':{"border-top":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="right"]':{"border-right":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="bottom"]':{"border-bottom":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="left"]':{"border-left":"1px solid var(--tbl-theme-border-color)"},'&[data-state="moving"]':{"z-index":200,"background-color":"color-mix(in srgb, var(--tbl-row-background), transparent 15%)"},'&[data-state="shiftable"]':{transform:"translate3d(0, 0, 0)",transition:"transform 150ms ease"},"&[data-outline]":{"&::after":{display:"block",position:"absolute",top:"-1px",left:"-1px",border:"none",width:"calc(100% + 2px)",height:"calc(100% + 2px)","pointer-events":"none",content:'""'},'&[data-outline~="top"]::after':{"border-top":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="right"]::after':{"border-right":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="bottom"]::after':{"border-bottom":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="left"]::after':{"border-left":"2px solid var(--tbl-theme-outline-color)"}}},".tbl-header-cell:not([align])":{"text-align":"var(--tbl-style-default-header-alignment)"}},XW={'&[data-tbl-line-wrapping="wrap"] .tbl-cell-view':{"word-break":"normal","overflow-wrap":"break-word"},'&[data-tbl-line-wrapping="nowrap"] .tbl-cell-view':{"white-space":"pre"},".tbl-cell-view":{margin:0,outline:"none",padding:"7px 10px",height:"100%","line-height":1.5,"white-space-collapse":"break-spaces","font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)","&[data-hidden]":{display:"none"}},".tbl-cell-view [data-br]":{"white-space":"pre"}},EW={".tbl-handle":{display:"flex",position:"absolute","justify-content":"center","align-items":"center","z-index":200,transition:"opacity 150ms ease 50ms","touch-action":"none"},".tbl-handle[data-hover], .tbl-handle[data-active]":{"--tbl-handle-opacity":1},'&:not([data-tbl-hoverable]) .tbl-handle[data-type="border"], &:not([data-tbl-hoverable]) .tbl-handle[data-type="table"]':{display:"none"},'.tbl-handle[data-type="border"]':{"background-color":"var(--tbl-theme-border-hover-color)"},'.tbl-handle[data-type="border"][data-active]':{"background-color":"var(--tbl-theme-border-active-color)"},'.tbl-handle[data-type="border"][data-toggle]':{transition:"none"},'.tbl-handle[data-type="border"][data-location="top"]':{top:"-1px",left:"-1px",width:"calc(100% + 2px)",height:"2px"},'.tbl-handle[data-type="border"][data-location="left"]':{top:"-1px",left:"-1px",width:"2px",height:"calc(100% + 2px)"},'.tbl-handle[data-type="border"][data-location="col"]':{top:"-1px",right:"-2px",width:"3px",height:"calc(100% + 2px)"},'.tbl-handle[data-type="border"][data-location="row"]':{bottom:"-2px",left:"-1px",width:"calc(100% + 2px)",height:"3px"},'.tbl-handle[data-type="table"]':{"box-sizing":"content-box",color:"var(--tbl-theme-border-hover-color)","background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)"},'.tbl-handle[data-type="table"][data-location="right"]':{top:0,left:"100%",width:"15px",height:"calc(100% - 2px)",border:"1px solid var(--tbl-theme-border-color)","border-left":"none","&::before":{position:"absolute",top:"-1px",left:"-2px",width:"2px",height:"calc(100% + 2px)",content:'""'},"&::after":{position:"absolute","z-index":366,top:"-1px",left:0,content:'""',width:"calc(100% + 1px)",height:"calc(100% + 2px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom-right"]':{left:"calc(100% - 1px)",top:"calc(100% - 1px)","z-index":250,width:"15px",height:"15px",border:"1px solid var(--tbl-theme-border-color)","border-top-style":"dashed","border-left-style":"dashed","&::after":{position:"absolute","z-index":366,top:"-1px",left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 2px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom"]':{top:"100%",left:"0",width:"calc(100% - 2px)",height:"15px",border:"1px solid var(--tbl-theme-border-color)","border-top":"none","&::before":{position:"absolute",top:"-2px",left:"-1px",width:"calc(100% + 2px)",height:"2px",content:'""'},"&::after":{position:"absolute","z-index":366,top:0,left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 1px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="bottom"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"--tbl-handle-opacity":1},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"]':{"border-bottom":"none"},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="bottom"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"border-right":"none"},'.tbl-handle[data-type="table"][data-active], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)",color:"var(--tbl-theme-border-active-color)"},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"]':{"box-sizing":"content-box",transition:"none","z-index":300,color:"var(--tbl-theme-border-hover-color)",border:"1px solid transparent","&:hover":{"border-color":"var(--tbl-theme-border-color)","background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)"},"&[data-active]":{"background-color":"var(--tbl-theme-outline-color)","border-color":"var(--tbl-theme-outline-color)",color:"#ffffff"}},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"][data-location="row"]':{top:"-1px",left:"-17px",width:"15px",height:"100%","border-right":"none"},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"][data-location="col"]':{top:"-17px",left:"-1px",width:"100%",height:"15px","border-bottom":"none","&:hover::after":{position:"absolute","z-index":366,top:"-1px",left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 1px)","background-color":"var(--tbl-overlay)"}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"]':{transition:"none","z-index":300,color:"var(--tbl-theme-border-hover-color)","&:hover":{color:"var(--tbl-theme-border-active-color)"},"&[data-active]":{color:"var(--tbl-theme-outline-color)"}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"][data-location="row"]':{top:"calc(50% - 13px)",left:"-1px",width:"3px",height:"26px","border-top":"4px solid var(--tbl-row-background)","border-bottom":"4px solid var(--tbl-row-background)","background-color":"var(--tbl-row-background)","&:hover::after, &[data-active]::after":{position:"absolute",top:"-6px",left:0,"box-sizing":"content-box","border-top":"2px solid transparent","border-bottom":"2px solid transparent",width:"calc(100% + 6px)",height:"calc(100% + 8px)",content:'""'}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"][data-location="col"]':{top:"-1px",left:"calc(50% - 11.5px)",width:"23px",height:"3px","border-right":"4px solid var(--tbl-row-background)","border-left":"4px solid var(--tbl-row-background)","background-color":"var(--tbl-row-background)","&:hover::after, &[data-active]::after":{position:"absolute",top:0,left:"-6px","box-sizing":"content-box","border-right":"2px solid transparent","border-left":"2px solid transparent",width:"calc(100% + 8px)",height:"calc(100% + 6px)",content:'""'}},".tbl-handle-grip":{"pointer-events":"none","z-index":333}},_W={".tbl-menu-item-icon":{"z-index":200,width:"1em",height:"1em","pointer-events":"none","font-size":"var(--tbl-style-menu-font-size)"}},ZW={".tbl-menu-item-text":{"z-index":200,"pointer-events":"none","user-select":"none","font-size":"var(--tbl-style-menu-font-size)"}},MW={".tbl-menu-item":{display:"flex",position:"relative","align-items":"center",gap:"0.75em",padding:"0.5em 0.75em",color:"var(--tbl-theme-menu-text-color)","user-select":"none","line-height":1,"font-size":"var(--tbl-style-menu-font-size)","&:active":{cursor:"pointer",color:"var(--tbl-theme-menu-hover-text-color)","&::after":{"background-color":"var(--tbl-theme-menu-hover-background)"}},"&::after":{position:"absolute",left:"0.25em",width:"calc(100% - 0.5em)",height:"100%",content:'""'}},"&[data-tbl-hoverable] .tbl-menu-item:hover":{cursor:"pointer",color:"var(--tbl-theme-menu-hover-text-color)","&::after":{"background-color":"var(--tbl-theme-menu-hover-background)"}}},LW={".tbl-menu-separator":{margin:"0.25em 0.5em","background-color":"var(--tbl-theme-menu-border-color)",height:"1px","font-size":"var(--tbl-style-menu-font-size)"}},zW={".tbl-menu":{position:"absolute",top:0,left:0,"z-index":900,"box-shadow":"2px 2px 0 0 rgb(0 0 0 / 10%)",border:"1px solid var(--tbl-theme-menu-border-color)","background-color":"var(--tbl-theme-menu-background)",padding:"0.25em 0",width:"max-content","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)"}},qW={".tbl-select-all-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"var(--tbl-overlay)",width:"100%",height:"100%","pointer-events":"none"}},WW={"& .tbl-table-wrapper[data-select-all]":{"--tbl-select-all-overlay":"var(--tbl-theme-select-all-blur-overlay)"},"&.cm-focused .tbl-table-wrapper[data-select-all]":{"--tbl-select-all-overlay":"var(--tbl-theme-select-all-focus-overlay)"},".tbl-table-wrapper":{"--tbl-overlay":"var(--tbl-select-all-overlay, transparent)",position:"relative",width:"fit-content","white-space-collapse":"collapse","touch-action":"none"},".tbl-table":{"border-collapse":"separate","border-spacing":0,overflow:"visible","touch-action":"none","&:focus-visible":{outline:"none"}},".tbl-table-head, .tbl-table-body":{height:"100%"},".tbl-table-row":{height:0},"@supports (-moz-appearance: none) /* TableTheme */":{".tbl-table-row":{height:"fit-content"}},".tbl-table-head .tbl-table-row":{"--tbl-row-background":"var(--tbl-theme-header-row-background)"},".tbl-table-body .tbl-table-row:nth-child(2n + 1)":{"--tbl-row-background":"var(--tbl-theme-even-row-background)"},".tbl-table-body .tbl-table-row:nth-child(2n)":{"--tbl-row-background":"var(--tbl-theme-odd-row-background)"}},DW={...PW,...CW,...$W,...WW,...TW,...AW,...RW,...XW,...EW,...zW,...MW,..._W,...ZW,...LW,...qW},jW=i=>{let e=i.effects.find(t=>t.is(QP))?.value;return Z(e)?{annotations:or(e)}:null},VW=i=>{let e=i.annotation(ng);return Z(e)?[kP(Cq(e))]:[]},qm=class i{static of(e){return e.state.field(hg).view=e,new i}constructor(){}};function IW(i){return[um.of(i),vP,hg,ce.define(e=>qm.of(e)),C.editorAttributes.compute([um,C.darkTheme],cW),C.baseTheme(DW),C.theme("light"in i.theme?{':where(:root:has(&[data-tbl-theme-mode="light"]))':i.theme.light.props,':where(:root:has(&[data-tbl-theme-mode="dark"]))':i.theme.dark.props}:{":where(:root:has(&))":i.theme.props}),C.theme({":where(:root:has(&))":i.style.props}),jd.of(VW),yr.of(sP),J.transactionExtender.of(jW),J.transactionFilter.of(yW),J.transactionFilter.of(xW),J.transactionFilter.of(SW),J.transactionFilter.of(kW),C.updateListener.of(wW),C.updateListener.of(mW),C.clipboardInputFilter.of(WL),C.focusChangeEffect.of(bW)]}function PP(i){return IW(zQ(i))}function YW(i,e){if(!I(i))for(let t of i)e(t)}function BW(i,e){I(i)||e(i)}function $P(i,e,t){if(!Number.isInteger(i)||i<=0)throw new Error(t);if(!Number.isInteger(e)||e<=0)throw new Error(t)}function NW({pos:i,doc:e,lineBreak:t,rows:n,cols:r}){let[o,...s]=Jn(`${"| ".repeat(r)}|`,{count:n}),l=`${"| - ".repeat(r)}|`,{before:a,after:c}=Hl({doc:e,lineBreak:t,span:{from:i-1,to:i}}),h=`${a?.insert??""}${[o,l,...s].join(t)}${c?.insert??""}`;return{label:`${n}\xD7${r} table`,type:"table",apply:(f,u)=>{f.dispatch({annotations:hl.of(u),changes:{from:i-1,to:i,insert:h},selection:{anchor:i+1+(a?.count??0)}})}}}var UW=[{rows:2,cols:2},{rows:3,cols:3},{rows:4,cols:4}];function GW(i){let e=i?.options??UW;return({state:t,pos:n})=>{let r=t.doc.lineAt(n);if(n!==r.from+1||r.length!==1||r.text.slice(0,1)!=="|")return null;let{doc:o,lineBreak:s}=t;return{from:n,options:e.map(({rows:l,cols:a})=>NW({pos:n,doc:o,lineBreak:s,rows:l,cols:a}))}}}function CP(i){return YW(i?.options,({rows:e,cols:t})=>{$P(e,t,"options[].{ rows, cols } must be positive integers")}),GW(i)}var FW={rows:2,cols:2};function HW(i){let{rows:e,cols:t}=i?.size??FW;return({state:n,dispatch:r})=>{let{anchor:o,head:s}=n.selection.main,{from:l,to:a}=o<=s?{from:o,to:s}:{from:s,to:o},{before:c,after:h}=Hl({doc:n.doc,lineBreak:n.lineBreak,span:{from:l,to:a}}),[f,...u]=Jn(`${"| ".repeat(t)}|`,{count:e}),d=`${"| - ".repeat(t)}|`,O=`${c?.insert??""}${[f,d,...u].join(n.lineBreak)}${h?.insert??""}`;return r(n.update({changes:{from:l,to:a,insert:O},selection:{anchor:l+2+(c?.count??0)}})),!0}}function TP(i){return BW(i?.size,({rows:e,cols:t})=>{$P(e,t,"size.{rows, cols} must be positive integers")}),HW(i)}var uo=16,KW="50rem",JW="88%",fg="0px",eD=[i1(),n1(),Ib(),lS(),q1(),Vb(),J.allowMultipleSelections.of(!0),A1(),qo(j1,{fallback:!0}),B1(),ax(),xO(),Bb(),Nb(),Yb(),IS(),Yt.of([...fx,...Bd,...tO,...Id,...M1,...vO,...gx])],Cg=[1.4,1.2,1.15,1.1,1.04,1],GP=1.6,FP=12/uo,df=1.3,Of=1.5,HP=13/uo,tD=12/uo,RP=22/uo;function oa(i){return`${i/HP}em`}var gf={compact:1.7,writing:2},AP=new So;function XP(i){let e=i?gf.writing:gf.compact;return C.theme({"&":{"--md-line-ratio":String(e),"--md-line-pad-y":i?"4px":"2px"}})}function fo(i){return`${i/FP}em`}function EP(i){let e=Cg[i-1]??1;return fo(e*GP)}var pg="\u037Cx";function iD(){let i={};return Cg.forEach((e,t)=>{i[`.cm-line.cm-md-h${t+1}`]={fontSize:`${e}em`,fontWeight:"700",lineHeight:`${GP} !important`},i[`.cm-line.cm-md-h${t+1} .${pg}`]={fontFamily:"inherit"},i[`.cm-lineNumbers .cm-gutterElement.cm-gutter-h${t+1}`]={lineHeight:`calc(${EP(t+1)} + 2 * var(--md-line-pad-y, 2px))`},i[`.cm-ai-gutter .cm-gutterElement.cm-gutter-h${t+1}`]={"--md-gutter-line-height":EP(t+1)}}),i}var nD=C.theme({"&":{height:"100%",color:"var(--text)",backgroundColor:"var(--card)",fontSize:`${uo}px`},".cm-foldGutter":{display:"none !important"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"var(--md-editor-font-family, var(--finch-font-mono))",overflowX:"hidden",overflowY:"auto"},".cm-content":{padding:"48px 0",caretColor:"var(--text)",minHeight:"100%",minWidth:"0",position:"relative"},".cm-content:not(.tbl-table-widget .cm-content)":{boxSizing:"border-box",paddingInline:fg,width:`calc(${KW} + 2 * ${fg})`,maxWidth:`calc(${JW} + 2 * ${fg})`,marginInline:"auto",flexGrow:"0",flexShrink:"1"},".cm-content:not(.tbl-table-widget .cm-content)::before":{content:'""',position:"absolute",top:"0",bottom:"0",left:"-100%",right:"-100%"},".cm-line:not(.tbl-table-widget .cm-line)":{boxSizing:"border-box",position:"relative",width:"100%",paddingTop:"var(--md-line-pad-y, 2px)",paddingBottom:"var(--md-line-pad-y, 2px)",lineHeight:`calc(var(--md-line-ratio, ${gf.compact}) * 1em)`},".cm-content > .cm-line:has(+ .tbl-table-widget)":{height:"0 !important",minHeight:"0 !important",paddingTop:"0 !important",paddingBottom:"0 !important",lineHeight:"0 !important",overflow:"hidden"},".cm-content > .tbl-table-widget":{boxSizing:"border-box",width:"auto !important",maxWidth:"100% !important",marginInline:"auto !important",padding:"12px 16px 12px 6px !important"},".tbl-table-widget .tbl-table-wrapper":{maxWidth:"100%"},".tbl-table-widget .tbl-table":{width:"auto !important",maxWidth:"100%"},".tbl-cell-editor .cm-editor .cm-line":{fontSize:"0.9rem",fontFamily:"var(--md-editor-font-family, var(--finch-font-mono))"},".tbl-cell-view":{fontSize:"0.9rem",fontFamily:"var(--md-editor-font-family, var(--finch-font-mono))"},".tbl-table-widget .tbl-cell[data-selected]":{backgroundColor:"color-mix(in srgb, var(--accent) 15%, var(--tbl-row-background))"},".tbl-table-widget .tbl-cell[data-outline]::after":{backgroundColor:"color-mix(in srgb, var(--accent) 7%, transparent)"},...iD(),".cm-md-bullet":{display:"inline-block",color:"var(--accent)",fontWeight:"700",textAlign:"center",fontFamily:"monospace"},[`.${pg}`]:{fontFamily:"monospace"},".tbl-cell-view .cm-md-delimiter":{display:"none"},".tbl-cell-view .cm-md-strong":{fontWeight:"700"},".tbl-cell-view .cm-md-emphasis":{fontStyle:"italic"},".tbl-table-widget .tbl-table-head .tbl-cell-view, .tbl-table-widget .tbl-table-head .tbl-cell-editor .cm-content":{color:"var(--accent)"},".cm-md-inline-code":{padding:"0.08em 0.32em",borderRadius:"5px",color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--text) 9%, transparent)",fontFamily:"var(--finch-font-mono)",fontSize:"0.8em",position:"relative",top:"-0.1em"},".cm-md-mark":{backgroundColor:"color-mix(in srgb, #ffd60a 40%, transparent)",borderRadius:"3px",padding:"0 0.12em",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone"},".cm-md-image-wrapper":{boxSizing:"border-box",display:"inline-flex",flexDirection:"column",maxWidth:"100%",margin:"4px 2px",lineHeight:"1.4",verticalAlign:"bottom",outline:"none"},".cm-editor:has(.cm-md-image-selected) .cm-cursor":{display:"none !important"},".cm-md-image-wrapper.cm-md-image-selected img":{outline:"2px solid var(--accent)",outlineOffset:"2px",borderRadius:"10px"},".cm-md-image-frame":{position:"relative",display:"inline-block",width:"fit-content",maxWidth:"100%",alignSelf:"flex-start",lineHeight:"0"},".cm-md-image-wrapper img":{display:"block",maxHeight:"80vh",maxWidth:"100%",width:"auto",height:"auto",borderRadius:"8px",cursor:"zoom-in"},".cm-md-image-resize-handle":{position:"absolute",right:"6px",bottom:"6px",width:"12px",height:"12px",boxSizing:"border-box",borderRight:"1.75px solid var(--accent)",borderBottom:"1.75px solid var(--accent)",borderRadius:"0 0 4px 0",cursor:"nwse-resize",touchAction:"none",opacity:"0",pointerEvents:"none",transition:"opacity 120ms ease"},".cm-md-image-selected .cm-md-image-resize-handle, .cm-md-image-resizing .cm-md-image-resize-handle":{opacity:"1",pointerEvents:"auto"},".cm-md-image-resizing":{userSelect:"none"},".cm-md-image-caption":{display:"block",marginTop:"6px",fontSize:"0.82em",lineHeight:"1.4",color:"color-mix(in srgb, var(--muted) 80%, transparent)",outline:"none",cursor:"text",whiteSpace:"pre-wrap",wordBreak:"break-word"},".cm-md-image-caption:empty::before":{content:"attr(data-placeholder)",color:"color-mix(in srgb, var(--muted) 80%, transparent)"},".cm-md-image-caption:not(:empty)":{color:"var(--text)"},".cm-md-link":{color:"var(--accent) !important",textDecoration:"underline",textDecorationColor:"color-mix(in srgb, var(--accent) 55%, transparent)",textUnderlineOffset:"0.16em",cursor:"pointer"},".cm-md-link:hover":{textDecorationColor:"var(--accent)"},".cm-line.cm-md-quote":{borderLeft:"2px solid var(--border)",paddingLeft:"8px"},[`.cm-line.cm-md-quote .${pg}`]:{fontFamily:"inherit"},".cm-line.cm-md-list-line":{paddingLeft:"2ch"},".cm-line.cm-md-code-line":{color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--text) 8%, transparent)",lineHeight:oa(df)+" !important",fontFamily:"var(--finch-font-mono)",paddingTop:"0 !important",paddingBottom:"0 !important",width:"calc(49rem) !important",paddingInline:"24px","--cm-ai-hint-inline-offset":"26px",fontSize:`${HP}em !important`,marginInline:"9.5px"},".cm-line.cm-md-code-line span":{fontSize:oa(tD)+" !important"},".cm-line.cm-md-code-open":{borderRadius:"8px 8px 0 0",height:oa(RP),paddingTop:"2px",paddingInline:"12px",lineHeight:oa(Of)+" !important"},".cm-line.cm-md-code-close":{borderRadius:"0 0 8px 8px",height:oa(RP),paddingInline:"12px"},".cm-md-code-fence-empty":{opacity:"0"},".cm-md-code-copy":{float:"right",height:"16px",margin:"3px -9px",padding:"0 4px",border:"0px",borderRadius:"6px",color:"var(--muted)",backgroundColor:"color-mix(in srgb, var(--card) 88%, transparent)",font:"10px var(--finch-font-mono)",cursor:"pointer"},".cm-md-code-copy:hover":{color:"var(--text)",backgroundColor:"var(--card)"},".cm-md-hr":{display:"inline-block",width:"100%",height:"1px",verticalAlign:"middle",backgroundColor:"var(--border)",cursor:"text"},".cm-line.cm-md-gap":{},".cm-line.cm-md-gap-heading":{},".cm-selectionMatch":{backgroundColor:"transparent !important"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--text)"},".cm-gutters":{color:"var(--muted)",backgroundColor:"var(--card)",borderRight:"0px",fontSize:`${12/uo}em`,"--md-gutter-line-height":`calc(var(--md-line-ratio, ${gf.compact}) * 1em / ${FP})`},".cm-content .cm-widgetBuffer":{verticalAlign:"top"},".cm-gutterElement":{padding:"0px 8px 0 10px"},".cm-lineNumbers .cm-gutterElement":{padding:"0 5px 0 8px",lineHeight:"calc(var(--md-gutter-line-height, 32px) + 2 * var(--md-line-pad-y, 2px))",color:"color-mix(in srgb, var(--muted) 35%, transparent)",fontFamily:"var(--finch-font-mono)",fontSize:"inherit"},".cm-lineNumbers .cm-gutterElement.cm-gutter-code-line":{lineHeight:fo(df)},".cm-lineNumbers .cm-gutterElement.cm-gutter-code-open":{lineHeight:fo(Of)},".cm-gutters .cm-ai-gutter":{width:"22px"},".cm-ai-gutter .cm-gutterElement":{position:"relative",padding:"0","--md-ai-row-height":"calc(var(--md-gutter-line-height, 32px) + 2 * var(--md-line-pad-y, 2px))",color:"var(--accent)"},".cm-ai-gutter .cm-gutterElement.cm-gutter-code-line":{"--md-gutter-line-height":fo(df),"--md-ai-row-height":fo(df)},".cm-ai-gutter .cm-gutterElement.cm-gutter-code-open":{"--md-gutter-line-height":fo(Of),"--md-ai-row-height":fo(Of)},".cm-ai-working-mark":{position:"absolute",inset:"0"},".cm-ai-working-spinner":{position:"absolute",top:"0",left:"0",right:"0",height:"var(--md-ai-row-height, 32px)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},".cm-ai-working-spinner:hover svg":{animation:"none"},".cm-ai-working-spinner:focus-visible":{outline:"1px solid var(--accent)",outlineOffset:"-1px",borderRadius:"3px"},".cm-ai-gutter svg":{width:"13px",height:"13px",animation:"cm-ai-spin 1s linear infinite"},".cm-ai-added-line":{position:"absolute",top:"0",left:"0",right:"0",height:"var(--md-ai-row-height, 32px)",display:"flex",justifyContent:"center"},".cm-ai-added-dot":{width:"6px",height:"6px",marginTop:"calc((var(--md-ai-row-height, 32px) - 6px) / 2 - 1px)",borderRadius:"50%",backgroundColor:"#35a854",boxShadow:"0 0 0 2px color-mix(in srgb, #35a854 16%, transparent)"},".cm-ai-working-rail":{position:"absolute",top:"0",bottom:"0",left:"50%",width:"1.5px",marginLeft:"-0.75px",borderRadius:"1px",backgroundColor:"var(--accent)",opacity:"0.45"},".cm-ai-working-rail.cm-ai-working-rail-below":{top:"calc(var(--md-ai-row-height, 32px) / 2 + 6.5px)"},".cm-ai-working-corner":{position:"absolute",top:"0",left:"50%",width:"6px",height:"calc(var(--md-ai-row-height, 32px) / 2)",marginLeft:"-0.75px",borderLeft:"1.5px solid var(--accent)",borderBottom:"1.5px solid var(--accent)",borderBottomLeftRadius:"5px",opacity:"0.45"},".cm-ai-hint-line::after":{content:'var(--cm-ai-hint, "")',color:"var(--muted)",opacity:"0.5",pointerEvents:"none",userSelect:"none",position:"absolute",top:"0",bottom:"0",left:"var(--cm-ai-hint-inline-offset, 10px)",display:"flex",alignItems:"center",whiteSpace:"nowrap",wordBreak:"keep-all",overflowWrap:"normal"},".cm-ai-hint-code-line::after":{content:'var(--cm-ai-hint-code, "")'},".cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--text) 7%, transparent)",boxShadow:["-25vw 0 color-mix(in srgb, var(--text) 7%, transparent)","25vw 0 color-mix(in srgb, var(--text) 7%, transparent)"].join(", ")},".cm-activeLineGutter":{color:"var(--text) !important",backgroundColor:"color-mix(in srgb, var(--text) 7%, transparent)"},".cm-line:not(.cm-activeLine)":{opacity:"var(--md-focus-opacity, 1)"},".tbl-table-widget .tbl-cell":{opacity:"var(--md-focus-opacity, 1)"},".tbl-table-widget .tbl-cell[data-selected], .tbl-table-widget .tbl-cell[data-selected] .cm-line":{opacity:"1"},"& .cm-content ::selection, & .cm-content::selection":{backgroundColor:"color-mix(in srgb, var(--accent) 34%, transparent)"},"& .cm-content ::-moz-selection, & .cm-content::-moz-selection":{backgroundColor:"color-mix(in srgb, var(--accent) 34%, transparent)"},".cm-panels":{color:"var(--text)",backgroundColor:"var(--card)",borderTop:"none"},".cm-panel.cm-search":{padding:"6px 30px 7px 8px",fontSize:"12px",color:"var(--text)",backgroundColor:"var(--card)",borderBottom:"1px solid var(--border)",boxShadow:"0 2px 10px rgba(0,0,0,.14)"},".cm-panel.cm-search .cm-textfield":{width:"140px",marginRight:"6px",padding:"3px 7px",border:"1px solid var(--border)",borderRadius:"6px",backgroundColor:"var(--bg)",color:"var(--text)",fontFamily:"var(--finch-font-mono, monospace)",fontSize:"12px",outline:"none",transition:"border-color .12s ease, box-shadow .12s ease"},".cm-panel.cm-search .cm-textfield:focus":{borderColor:"var(--accent)",boxShadow:"0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent)"},".cm-panel.cm-search .cm-textfield::placeholder":{color:"color-mix(in srgb, var(--muted) 65%, transparent)"},".cm-panel.cm-search .cm-button":{marginRight:"4px",padding:"3px 9px",border:"1px solid var(--border)",borderRadius:"6px",backgroundImage:"none",backgroundColor:"color-mix(in srgb, var(--text) 4%, transparent)",color:"var(--text)",fontSize:"12px",fontWeight:"500",cursor:"pointer",transition:"background-color .12s ease, border-color .12s ease"},".cm-panel.cm-search .cm-button:hover":{backgroundImage:"none",backgroundColor:"color-mix(in srgb, var(--text) 9%, transparent)",borderColor:"color-mix(in srgb, var(--text) 22%, transparent)"},".cm-panel.cm-search .cm-button:active":{backgroundImage:"none",backgroundColor:"color-mix(in srgb, var(--accent) 18%, transparent)",borderColor:"var(--accent)"},".cm-panel.cm-search label":{display:"inline-flex",alignItems:"center",gap:"4px",marginRight:"10px",color:"var(--muted)",fontSize:"11.5px",whiteSpace:"nowrap",cursor:"pointer"},".cm-panel.cm-search input[type=checkbox]":{width:"13px",height:"13px",margin:"0",accentColor:"var(--accent)",cursor:"pointer"},".cm-panel.cm-search [name=close]":{position:"absolute",top:"5px",right:"6px",width:"20px",height:"20px",lineHeight:"1",padding:"0",border:"1px solid transparent",borderRadius:"5px",backgroundColor:"transparent",color:"var(--muted)",fontSize:"15px",cursor:"pointer"},".cm-panel.cm-search [name=close]:hover":{color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--text) 8%, transparent)",borderColor:"var(--border)"},".cm-editor .cm-content .cm-searchMatch":{backgroundColor:"color-mix(in srgb, var(--accent) 26%, transparent)",outline:"1px solid color-mix(in srgb, var(--accent) 38%, transparent)",borderRadius:"2px"},".cm-editor .cm-content .cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"color-mix(in srgb, var(--accent) 48%, transparent)",outline:"1px solid var(--accent)"},".cm-tooltip":{color:"var(--text)",backgroundColor:"var(--card)",border:"1px solid var(--border)"},".cm-tooltip.cm-tooltip-autocomplete":{borderRadius:"10px",padding:"5px",boxShadow:"0 2px 8px rgba(0,0,0,.12)",overflow:"hidden"},".cm-tooltip.cm-tooltip-autocomplete > ul":{minWidth:"188px",fontFamily:"var(--finch-font-body, system-ui)",fontSize:"13px"},".cm-tooltip.cm-tooltip-autocomplete > ul > li":{display:"flex",alignItems:"center",gap:"0",padding:"4px 7px",borderRadius:"6px"},".cm-tooltip-autocomplete > ul > li[aria-selected]":{color:"var(--text)",backgroundColor:"var(--finch-bg-active, color-mix(in srgb, var(--text) 10%, transparent))"},".cm-tooltip-autocomplete .cm-completionLabel":{flex:"1"},".cm-tooltip-autocomplete .cm-completionDetail":{marginLeft:"auto",color:"var(--muted)",fontStyle:"normal",fontSize:"0.86em"},".cm-tooltip-autocomplete .cm-md-completion-icon":{flex:"none",width:"16px",height:"16px",paddingRight:"8px",boxSizing:"content-box",color:"var(--muted)",opacity:"0.82"}}),rD=[dt.of({name:"JavaScript",alias:["js","mjs","cjs"],extensions:["js","mjs","cjs"],support:zr()}),dt.of({name:"JSX",alias:["jsx"],extensions:["jsx"],support:zr({jsx:!0})}),dt.of({name:"TypeScript",alias:["ts"],extensions:["ts"],support:zr({typescript:!0})}),dt.of({name:"TSX",alias:["tsx"],extensions:["tsx"],support:zr({jsx:!0,typescript:!0})}),dt.of({name:"JSON",alias:["json","json5"],extensions:["json"],support:Sw()}),dt.of({name:"CSS",alias:["css"],extensions:["css"],support:oh()}),dt.of({name:"HTML",alias:["html","htm","xml","svg"],extensions:["html"],support:lh()}),dt.of({name:"Python",alias:["python","py"],extensions:["py"],support:zw()}),dt.of({name:"SQL",alias:["sql"],extensions:["sql"],support:ey()}),dt.of({name:"YAML",alias:["yaml","yml"],extensions:["yaml","yml"],support:py()}),dt.of({name:"Shell",alias:["bash","sh","shell","zsh","console"],extensions:["sh"],support:new Ie(pc.define(xy))})],_P=Mo.define([{tag:g.heading,color:"var(--accent)",fontWeight:"700"},{tag:g.strong,color:"var(--text)",fontWeight:"700"},{tag:g.emphasis,fontStyle:"italic"},{tag:g.strikethrough,color:"var(--muted)",textDecoration:"line-through"},{tag:g.monospace,color:"var(--muted)"},{tag:g.link,color:"var(--accent)"},{tag:g.url,color:"var(--muted)",textDecoration:"underline"},{tag:g.quote,color:"var(--muted)"},{tag:g.meta,color:"var(--muted)"},{tag:g.keyword,color:"#c678dd"},{tag:[g.name,g.deleted,g.character,g.propertyName,g.macroName],color:"#e06c75"},{tag:[g.function(g.variableName),g.labelName],color:"#61afef"},{tag:[g.color,g.constant(g.name),g.standard(g.name),g.bool],color:"#d19a66"},{tag:[g.definition(g.name),g.separator],color:"var(--text)"},{tag:[g.typeName,g.className,g.number,g.changed,g.annotation,g.modifier,g.self,g.namespace],color:"#e5c07b"},{tag:[g.operator,g.operatorKeyword,g.escape,g.regexp,g.special(g.string)],color:"#56b6c2"},{tag:g.string,color:"#98c379"},{tag:g.comment,color:"var(--muted)",fontStyle:"italic"},{tag:g.invalid,color:"#fff",backgroundColor:"#e06c75"}]),mg=/^(#{1,6})(?:\s|$)/;function ZP(i){let e=new Ue,t=i.state.doc;for(let n=1;n<=t.lines;n++){let r=t.line(n),o=r.text,s=mg.exec(o),l=o.trim().length===0,a;if(s)a=`cm-md-h${s[1].length}`;else if(l&&n<t.lines){let c=t.line(n+1).text;c.trim().length>0&&(a=mg.test(c)?"cm-md-gap-heading":"cm-md-gap")}a&&e.add(r.from,r.from,R.line({class:a}))}return e.finish()}var oD=ce.fromClass(class{decorations;constructor(i){this.decorations=ZP(i)}update(i){(i.docChanged||i.viewportChanged)&&(this.decorations=ZP(i.view))}},{decorations:i=>i.decorations}),MP=/`([^`\n]+)`/g,LP=/==(?=\S)(.+?)(?<=\S)==/g,Oo=/^\s*```+\s*([^\s`]*)?\s*$/;function KP(i,e){let t=!1;for(let n=1;n<e;n++)Oo.test(i.line(n).text)&&(t=!t);return t}var JP=/^\s{0,3}(?:(?:-\s*){3,}|(?:\*\s*){3,}|(?:_\s*){3,})$/,sD=/^(\s*)([-+*])(?=\s+)/,lD=/^(\s*>\s?)/,ri=R.replace({}),aD=R.mark({class:"cm-md-inline-code"}),cD=R.mark({class:"cm-md-mark"});function ug(i){let e=i.trim();return/^https?:\/\//i.test(e)?e:null}function dg(i){return R.mark({class:"cm-md-link",attributes:{"data-md-href":i,role:"link",title:i}})}var pf=48;function Tg(i){let e=/^(.*)\|(\d+)(?:x\d+)?$/.exec(i);if(!e)return{caption:i,width:null};let t=Number(e[2]);return{caption:e[1],width:Number.isFinite(t)&&t>0?Math.round(t):null}}function la(i,e){i.style.width=e?`${e}px`:"auto",i.style.height="auto"}function hD(i,e){if(typeof ResizeObserver>"u")return;let t=0,n=0,r=new ResizeObserver(o=>{let s=o[0]?.contentRect;if(s&&!(Math.abs(s.width-t)<2&&Math.abs(s.height-n)<2)){t=s.width,n=s.height;try{i.requestMeasure()}catch{}}});r.observe(e),e.__finchImageResizeObserver=r}function fD(i,e,t,n){let r;try{r=i.contentDOM.querySelectorAll("img[data-md-image-src]")}catch{return null}for(let o of r){if(o.dataset.mdImageSrc!==e)continue;let s=o.closest(".cm-md-image-wrapper");if(!(s&&(s.dataset.mdAlt!==t||(s.dataset.mdWidth??"")!==(n==null?"":String(n))))&&!(!o.complete||o.naturalWidth===0)&&!o.__finchImageClaimed)return o.__finchImageClaimed=!0,queueMicrotask(()=>{delete o.__finchImageClaimed}),o.remove(),o}return null}var gg=class extends Le{constructor(t,n,r){super();this.src=t;this.alt=n;this.width=r}src;alt;width;captionEl=null;eq(t){return t.src===this.src&&t.alt===this.alt&&t.width===this.width}ignoreEvent(t){return!!(this.captionEl&&t.target instanceof Node&&this.captionEl.contains(t.target))}toDOM(t){let n=document.createElement("span");n.className="cm-md-image-wrapper",n.tabIndex=-1,n.setAttribute("aria-selected","false"),n.addEventListener("keydown",c=>{if(c.key==="Backspace"||c.key==="Delete"){c.preventDefault(),c.stopPropagation(),bg(t);return}c.key!=="ArrowLeft"&&c.key!=="ArrowRight"||(c.preventDefault(),c.stopPropagation(),OD(t,n,c.key==="ArrowLeft"?-1:1))}),n.dataset.mdSrc=this.src,n.dataset.mdAlt=this.alt,this.width!=null&&(n.dataset.mdWidth=String(this.width));let r=document.createElement("span");r.className="cm-md-image-frame";let o=fD(t,this.src,this.alt,this.width)??document.createElement("img");o.dataset.mdImageSrc||(o.src=this.src,o.dataset.mdImageSrc=this.src),o.alt=this.alt,o.title=this.alt||this.src,la(o,this.width),r.appendChild(o);let s=document.createElement("span");s.className="cm-md-image-resize-handle",s.setAttribute("role","separator"),s.setAttribute("aria-label","Resize image width"),s.title="\u62D6\u52A8\u8C03\u6574\u56FE\u7247\u5BBD\u5EA6",s.addEventListener("pointerdown",c=>{uD(t,n,o,s,c,this.width)}),r.appendChild(s),n.appendChild(r);let l=document.createElement("span");l.className="cm-md-image-caption",l.contentEditable="plaintext-only",l.contentEditable!=="plaintext-only"&&(l.contentEditable="true"),l.spellcheck=!1,l.dataset.placeholder="\u6DFB\u52A0\u56FE\u7247\u8BF4\u660E\u2026",l.textContent=this.alt,l.addEventListener("paste",c=>{c.preventDefault();let h=c.clipboardData?.getData("text/plain")??"";document.execCommand("insertText",!1,h.replace(/[\r\n]+/g," "))});let a=0;return l.addEventListener("compositionend",()=>{a=Date.now()}),l.addEventListener("keydown",c=>{if(c.stopPropagation(),c.key==="Enter"){if(c.isComposing||c.keyCode===229||Date.now()-a<100)return;c.preventDefault(),l.blur()}else c.key==="Escape"&&(c.preventDefault(),l.textContent=this.alt,l.blur())}),l.addEventListener("input",()=>{l.textContent||l.replaceChildren()}),l.addEventListener("blur",()=>pD(t,n,this.alt,l.textContent??"")),n.appendChild(l),this.captionEl=l,hD(t,n),n}destroy(t){let n=t.__finchImageResizeObserver;n&&(n.disconnect(),delete t.__finchImageResizeObserver)}updateDOM(t,n,r){if(r.src!==this.src||r.alt!==this.alt)return!1;let o=t.querySelector("img[data-md-image-src]");if(!o)return!1;if(la(o,this.width),r.width!==this.width)try{n.requestMeasure()}catch{}return this.captionEl=t.querySelector(".cm-md-image-caption"),!0}};function sa(i,e){let t=null;return B(i).iterate({enter:n=>{if(n.name==="Image")return!t&&e(n.from,n.to)&&(t={from:n.from,to:n.to}),!1}}),t}function wf(i){return Math.min(i.from+1,i.to)}function bf(i){let e=i.selection.main;return e.empty?sa(i,(t,n)=>t<e.head&&e.head<n):null}function yf(i,e){let t=i.selection.main;return t.empty&&t.head===wf(e)}function Ss(i,e){let t=e.parentNode;if(!t)return null;let n=Array.prototype.indexOf.call(t.childNodes,e);if(n<0)return null;try{let r=i.posAtDOM(t,n),o=i.posAtDOM(t,n+1),s=Math.min(r,o),l=Math.max(r,o);return sa(i.state,(a,c)=>a===s&&c===l)??sa(i.state,a=>a===r)??sa(i.state,(a,c)=>c===o)??bf(i.state)}catch{return bf(i.state)}}function uD(i,e,t,n,r,o){if(r.button!==0)return;r.preventDefault(),r.stopPropagation();let s=Ss(i,e);s&&!yf(i.state,s)&&i.dispatch({selection:{anchor:wf(s)}});let l=r.clientX,a=t.getBoundingClientRect().width,c=e.closest(".cm-line")?.getBoundingClientRect().width??a,h=Math.max(pf,Math.floor(c)),f=Math.max(pf,Math.round(a));e.classList.add("cm-md-image-resizing"),n.setPointerCapture(r.pointerId);let u=()=>{e.classList.remove("cm-md-image-resizing"),n.removeEventListener("pointermove",d),n.removeEventListener("pointerup",O),n.removeEventListener("pointercancel",m),n.hasPointerCapture(r.pointerId)&&n.releasePointerCapture(r.pointerId)},d=p=>{if(p.pointerId!==r.pointerId)return;p.preventDefault();let b=Math.round(a+p.clientX-l);f=Math.max(pf,Math.min(h,b)),la(t,f),n.setAttribute("aria-valuenow",String(f))},O=p=>{p.pointerId===r.pointerId&&(p.preventDefault(),u(),mD(i,e,f))},m=p=>{p.pointerId===r.pointerId&&(u(),la(t,o))};n.addEventListener("pointermove",d),n.addEventListener("pointerup",O),n.addEventListener("pointercancel",m)}function dD(i){!i.isConnected||!i.classList.contains("cm-md-image-selected")||i.focus({preventScroll:!0})}function OD(i,e,t){let n=Ss(i,e);n&&(i.dispatch({selection:{anchor:t<0?n.from:n.to},scrollIntoView:!0}),i.focus())}function Sf(i,e){let t=i.state.selection.main;if(!t.empty)return!1;let n=sa(i.state,e>0?r=>r===t.head:(r,o)=>o===t.head);return n?(i.dispatch({selection:{anchor:wf(n)},scrollIntoView:!0}),!0):!1}function pD(i,e,t,n){if(n===t)return;let r=Ss(i,e);if(!r)return;let o=i.state.sliceDoc(r.from,r.to),s=/^!\[([^\]]*)\](\([^)]*\))/.exec(o);if(!s)return;let l=Tg(s[1]),a=l.width?`|${l.width}`:"";i.dispatch({changes:{from:r.from,to:r.to,insert:`![${n}${a}]${s[2]}`}})}function mD(i,e,t){let n=Ss(i,e);if(!n)return;let r=i.state.sliceDoc(n.from,n.to),o=/^!\[([^\]]*)\](\([^)]*\))/.exec(r);if(!o)return;let s=Tg(o[1]),l=Math.max(pf,Math.round(t));s.width!==l&&i.dispatch({changes:{from:n.from,to:n.to,insert:`![${s.caption}|${l}]${o[2]}`}})}function zP(i){let e=[];return B(i).iterate({enter:t=>{if(t.name!=="Image")return;let n=t.node.getChild("URL");if(!n)return!1;let r=i.sliceDoc(t.from,t.to),o=/^!\[([^\]]*)\]/.exec(r)?.[1]??"",s=Tg(o),l=i.sliceDoc(n.from,n.to).trim();if(!l)return!1;let a={from:t.from,to:t.to};return e.push(R.replace({widget:new gg(l,s.caption,s.width)}).range(a.from,a.to)),!1}}),R.set(e,!0)}var Rg=le.define({create:zP,update(i,e){return e.docChanged?zP(e.state):i},provide:i=>C.decorations.from(i)}),gD=ce.fromClass(class{constructor(i){this.sync(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&this.sync(i.view)}docViewUpdate(i){this.sync(i)}heal(i){for(let e of i.contentDOM.querySelectorAll(".cm-md-image-wrapper")){let t=e.querySelector(".cm-md-image-frame");if(!t||t.querySelector("img[data-md-image-src]"))continue;let n=e.dataset.mdSrc;if(!n)continue;let r=document.createElement("img");r.src=n,r.dataset.mdImageSrc=n,r.alt=e.dataset.mdAlt??"",r.title=r.alt||n;let o=e.dataset.mdWidth;la(r,o?Number(o):null),t.insertBefore(r,t.firstChild)}}sync(i){this.heal(i);let e=bf(i.state),t=e&&yf(i.state,e)?e:null;for(let n of i.contentDOM.querySelectorAll(".cm-md-image-wrapper")){let r=t?Ss(i,n):null,o=!!t&&!!r&&r.from===t.from&&r.to===t.to;n.classList.contains("cm-md-image-selected")!==o&&(n.classList.toggle("cm-md-image-selected",o),n.setAttribute("aria-selected",o?"true":"false"),o&&dD(n))}}}),bD=C.atomicRanges.of(i=>i.state.field(Rg));function SD(i){let e=[],t=[],n=B(i.state);return n.iterate({enter:r=>{r.name==="URL"&&t.push({from:r.from,to:r.to})}}),n.iterate({enter:r=>{if(r.name==="Table"||r.name==="Image")return!1;if(r.name==="Link"){let o=r.node.getChild("URL"),s=r.node.getChildren("LinkMark");if(!o||s.length<4||bs(i,r.from,r.to))return!1;let l=ug(i.state.sliceDoc(o.from,o.to)),a=s[0],c=s[1];return!l||a.to>=c.from||(e.push(ri.range(a.from,a.to)),e.push(dg(l).range(a.to,c.from)),e.push(ri.range(c.from,r.to))),!1}if(r.name==="Autolink"){let o=r.node.getChild("URL"),s=r.node.getChildren("LinkMark");if(!o||s.length<2||bs(i,r.from,r.to))return!1;let l=ug(i.state.sliceDoc(o.from,o.to));return l&&(e.push(ri.range(s[0].from,s[0].to)),e.push(dg(l).range(o.from,o.to)),e.push(ri.range(s[s.length-1].from,s[s.length-1].to))),!1}if(r.name==="URL"){if(bs(i,r.from,r.to))return;let o=ug(i.state.sliceDoc(r.from,r.to));o&&e.push(dg(o).range(r.from,r.to))}}}),{decorations:e,urlRanges:t}}function xD(i){let e=[];return B(i.state).iterate({enter:t=>{if(t.name==="Table"||t.name==="Image")return!1;let n=t.name==="Strikethrough"?"StrikethroughMark":t.name==="Emphasis"||t.name==="StrongEmphasis"?"EmphasisMark":void 0;if(n){if(bs(i,t.from,t.to))return!1;for(let r of t.node.getChildren(n))e.push(ri.range(r.from,r.to))}}}),e}function Og(i,e,t){return t.some(n=>i<n.to&&e>n.from)}function e$(i){return i.button!==0||!(i.target instanceof Element)?null:i.target.closest(".cm-md-link[data-md-href]")}function vD(i){return e$(i)?(i.preventDefault(),i.stopPropagation(),!0):!1}function wD(i,e){let t=e$(i)?.dataset.mdHref;return t?(i.preventDefault(),i.stopPropagation(),e?.(t),!0):!1}function t$(i){return i.button!==0||!(i.target instanceof Element)?null:i.target.closest(".cm-md-image-wrapper img[data-md-image-src]")}function yD(i){return t$(i)?(i.preventDefault(),i.stopPropagation(),!0):!1}function QD(i,e){let t=e.closest(".cm-md-image-wrapper");return t?Ss(i,t):null}function kD(i,e,t){let n=t$(e),r=n?.dataset.mdImageSrc;if(!n||!r)return!1;e.preventDefault(),e.stopPropagation();let o=QD(i,n);return o&&yf(i.state,o)?(t?.(r),!0):(o&&i.dispatch({selection:{anchor:wf(o)},scrollIntoView:!0}),!0)}function bg(i){if(!i.state.selection.main.empty)return!1;let t=bf(i.state);return!t||!yf(i.state,t)?!1:(i.dispatch({changes:{from:t.from,to:t.to},selection:{anchor:t.from}}),i.focus(),!0)}var aa=class extends He{constructor(t){super();this.elementClass=t}elementClass},PD=new aa("cm-gutter-code-line"),$D=new aa("cm-gutter-code-line cm-gutter-code-open"),CD=Cg.map((i,e)=>new aa(`cm-gutter-h${e+1}`));function qP(i){let e=new Ue,t=!1;for(let n=1;n<=i.lines;n++){let r=i.line(n),o=Oo.test(r.text);if(o||t){let s=o&&!t;e.add(r.from,r.from,s?$D:PD)}else{let s=mg.exec(r.text);s&&e.add(r.from,r.from,CD[s[1].length-1])}o&&(t=!t)}return e.finish()}var WP=le.define({create:i=>qP(i.doc),update:(i,e)=>e.docChanged?qP(e.state.doc):i}),TD=[WP,Co.from(WP)];function Ag(){let i=document.createElement("span");return i.className="cm-ai-working-mark",i}function i$(i){let e=document.createElement("span");return e.className=i?`cm-ai-working-rail ${i}`:"cm-ai-working-rail",e}var xf=class extends He{constructor(t){super();this.hasMore=t}hasMore;elementClass="cm-ai-working cm-ai-working-start";toDOM(){let t=Ag(),n=document.createElement("span");n.className="cm-ai-working-spinner",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.setAttribute("aria-label","Stop rewrite"),n.title="Stop rewrite";let r=s=>{n.innerHTML=s?'<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10" stroke-opacity="0.25"/><path d="M12 2a10 10 0 0 1 10 10"/></svg>'};r(!1),n.addEventListener("mouseenter",()=>r(!0)),n.addEventListener("mouseleave",()=>r(!1));let o=s=>{s.preventDefault(),s.stopPropagation(),n.dispatchEvent(new CustomEvent("finch:aiWorkingCancel",{bubbles:!0}))};return n.addEventListener("click",o),n.addEventListener("keydown",s=>{(s.key==="Enter"||s.key===" ")&&o(s)}),t.appendChild(n),this.hasMore&&t.appendChild(i$("cm-ai-working-rail-below")),t}},Sg=class extends He{elementClass="cm-ai-working cm-ai-working-line";toDOM(){let e=Ag();return e.appendChild(i$()),e}},xg=class extends He{elementClass="cm-ai-working cm-ai-working-end";toDOM(){let e=Ag(),t=document.createElement("span");return t.className="cm-ai-working-corner",e.appendChild(t),e}},n$=new xf(!1),RD=new xf(!0),AD=new Sg,XD=new xg,vg=D.define();function ED(i,e){if(!e)return U.empty;let t=new Ue,n=Math.max(1,Math.min(e.fromLine,i.lines)),r=Math.max(n,Math.min(e.toLine,i.lines));for(let o=n;o<=r;o++){let s=o===n?r>n?RD:n$:o===r?XD:AD;t.add(i.line(o).from,i.line(o).from,s)}return t.finish()}var r$=le.define({create:()=>U.empty,update:(i,e)=>{let t=i.map(e.changes);for(let n of e.effects)n.is(vg)&&(t=ED(e.state.doc,n.value));return t}}),wg=class extends He{elementClass="cm-ai-added-line";toDOM(){let e=document.createElement("span");return e.className="cm-ai-added-dot",e}},_D=new wg,o$=D.define(),s$=le.define({create:()=>U.empty,update:(i,e)=>{let t=i.map(e.changes);for(let n of e.effects){if(!n.is(o$))continue;let r=new Ue;for(let o of n.value)o>=1&&o<=e.state.doc.lines&&r.add(e.state.doc.line(o).from,e.state.doc.line(o).from,_D);t=r.finish()}if(e.selection){let n=e.state.doc.lineAt(e.selection.main.head).from;t=t.update({filter:r=>r!==n})}return t}}),ZD=Bs({class:"cm-ai-gutter",markers:i=>U.join([i.state.field(r$),i.state.field(s$)]),initialSpacer:()=>n$}),MD=R.line({class:"cm-ai-hint-line"}),LD=R.line({class:"cm-ai-hint-line cm-ai-hint-code-line"});function l$(i){let e=i.selection.main;if(!e.empty)return null;let t=i.doc.lineAt(e.head);return t.text.trim()?null:t.number}var zD=ce.fromClass(class{decorations;constructor(i){this.decorations=this.build(i)}update(i){(i.docChanged||i.selectionSet||i.focusChanged||i.viewportChanged)&&(this.decorations=this.build(i.view))}build(i){if(!i.hasFocus)return R.none;let e=l$(i.state);if(e==null)return R.none;let t=i.state.doc.line(e),n=KP(i.state.doc,e)?LD:MD;return R.set([n.range(t.from)])}},{decorations:i=>i.decorations}),yg=class extends Le{eq(){return!0}toDOM(){let e=document.createElement("span");return e.className="cm-md-bullet",e.textContent="\u2022",e.setAttribute("aria-hidden","true"),e}},Qg=class extends Le{constructor(t){super();this.position=t}position;eq(t){return t.position===this.position}toDOM(t){let n=document.createElement("span");return n.className="cm-md-hr",n.title="\u70B9\u51FB\u7F16\u8F91\u5206\u9694\u7EBF",n.addEventListener("mousedown",r=>r.preventDefault()),n.addEventListener("click",()=>{t.dispatch({selection:{anchor:this.position}}),t.focus()}),n}},kg=class extends Le{constructor(t,n){super();this.language=t;this.code=n}language;code;eq(t){return t.language===this.language&&t.code===this.code}toDOM(){if(!this.language){let n=document.createElement("span");return n.className="cm-md-code-fence-empty",n.textContent="\u200B",n}let t=document.createElement("button");return t.type="button",t.className="cm-md-code-copy",t.textContent=this.language.toUpperCase(),t.title="\u590D\u5236\u4EE3\u7801\u5757",t.addEventListener("mousedown",n=>n.preventDefault()),t.addEventListener("click",async n=>{n.preventDefault(),n.stopPropagation();let r=t.textContent||this.language.toUpperCase();try{await navigator.clipboard.writeText(this.code),t.textContent="\u5DF2\u590D\u5236"}catch{t.textContent="\u590D\u5236\u5931\u8D25"}window.setTimeout(()=>{t.textContent=r},1200)}),t}};function DP(i,e,t){return i.state.selection.ranges.some(n=>n.empty?n.head>=e&&n.head<=t:n.from<=t&&n.to>=e)}function bs(i,e,t){let n=i.state.doc.lineAt(e);return i.state.selection.ranges.some(r=>r.empty?r.head>=n.from&&r.head<=n.to&&r.head>=e-1&&r.head<=t+1:r.from<=n.to&&r.to>=n.from&&r.from<=t+1&&r.to>=e-1)}function qD(i){let e=i.state.doc,t=new Map,n=0,r="";for(let o=1;o<=e.lines;o++){let s=e.line(o),l=Oo.exec(s.text);if(!n){if(!l)continue;n=o,r=l[1]||"";continue}if(l){let a=Array.from({length:o-n-1},(f,u)=>e.line(n+u+1).text).join(`
40
+ `:l.textContent??""})??"",r=(e.textContent??"").slice(0,PQ(i)),o=kt(`${n}${r}`),s=n.length+PQ(i);return pP({anchor:s,head:s},o,{trim:!1})}function g4(i,e){var t=eg(),n=ze(t);lo(n,()=>e.children),z(i,t)}function b4(i,e){cr(e,!0),af(()=>{let t=jk(g4,{target:e.to,context:Qz(),props:{children:e.children}});return()=>{Vk(t)}}),hr()}wz();var S4=oe('<div class="tbl-blocking-overlay" aria-hidden="true"></div>');function x4(i){var e=S4();z(i,e)}function Uh(i,e){let t=e.devicePixelRatio;return bL(i*t)/t}function v4({x:i,y:e},t){return{x:Uh(i,t),y:Uh(e,t)}}var w4=oe('<th class="tbl-cell tbl-header-cell"><!></th>'),y4=oe('<td class="tbl-cell tbl-data-cell"><!></td>');function Q4(i,e){cr(e,!0);let t=G(()=>kQ(Z(e.movement)?e.movement.border:{top:e.position.top,right:!0,bottom:!0,left:e.position.left})),n=G(()=>kQ(e.outline)),r=G(()=>{if(I(e.movement?.translate))return;let{x:c,y:h}=e.movement.state==="moving"?v4(e.movement.translate,e.win):e.movement.translate;return`translate3d(${c}px, ${h}px, 0px)`});var o=eg(),s=ze(o);{var l=c=>{var h=w4();let f;var u=mi(h);lo(u,()=>e.children),Qt(d=>{Ce(h,"align",e.alignment==="none"?void 0:e.alignment),Ce(h,"data-component",Fl),Ce(h,"data-row",e.location.row),Ce(h,"data-col",e.location.col),Ce(h,"data-border",P(t)),Ce(h,"data-outline",P(n)),Ce(h,"data-selected",d),Ce(h,"data-state",e.movement?.state),f=Vh(h,"",f,{transform:P(r)})},[()=>no(e.selected)]),z(c,h)},a=c=>{var h=y4();let f;var u=mi(h);lo(u,()=>e.children),Qt(d=>{Ce(h,"align",e.alignment==="none"?void 0:e.alignment),Ce(h,"data-component",Fl),Ce(h,"data-row",e.location.row),Ce(h,"data-col",e.location.col),Ce(h,"data-border",P(t)),Ce(h,"data-outline",P(n)),Ce(h,"data-selected",d),Ce(h,"data-state",e.movement?.state),f=Vh(h,"",f,{transform:P(r)})},[()=>no(e.selected)]),z(c,h)};Ot(s,c=>{e.position.top?c(l):c(a,!1)})}z(i,o),hr()}function mP(i){return Z(Ul(i.dom).activeElement?.closest(".cm-panels"))}function TQ(i){return i.trim().split(/\s+/)}function k4({doc:i,selection:e,parent:t,extensions:n,markdownConfig:r,selectionType:o,lineWrapping:s,globalKeyBindings:l,rootEditor:a,highlighter:c,onChange:h,eventHandlers:f}){return new C({doc:i,selection:e,parent:t,extensions:[n,vt.lowest([C.editorAttributes.of(u=>{let d=new Set(TQ(a.themeClasses)),O=new Set(TQ(u.themeClasses));return{class:[...d.difference(O)].join(" ")}}),Yt.of([...l.map(u=>({...u,run:Z(u.run)?()=>u.run(a):void 0,shift:Z(u.shift)?()=>u.shift(a):void 0}))]),o==="codemirror"?Wb():[],qo(c),Dr({extensions:[WQ,r.extensions??[]],addKeymap:!1,completeHTMLTags:r.completeHTMLTags,pasteURLAsLink:r.pasteURLAsLink,htmlTagLanguage:r.htmlTagLanguage}),C.domEventObservers(f),s==="wrap"?C.lineWrapping:[]])],dispatchTransactions:(u,d)=>{d.update(u),u.forEach(h)}})}var P4=oe('<div class="tbl-cell-editor"></div>');function $4(i,e){cr(e,!0);let t=ym(e,"text",15),n=ym(e,"selection",15),r,o,s=!1,l=!1;function a(h){let{docChanged:f,newDoc:u,selection:d}=h;if(s)return;let O=Z(d);if(f||O){if(f){let m=Dm(u,{trim:!0});m.eq(t())||(t(m),l=!0)}if(O){let{head:m,anchor:p}=d.main,b=pP({head:m,anchor:p},u,{trim:!0});nP(b,n())||(n(b),l=!0)}}}og([()=>t(),()=>n()],()=>{if(l){l=!1;return}s=!0,o.dispatch({changes:o.state.changes({from:0,to:o.state.doc.length,insert:Wh(t())}),selection:CQ(n(),t())}),s=!1},{lazy:!0}),af(()=>(o=k4({doc:Wh(t()),selection:CQ(n(),t()),parent:r,selectionType:e.selectionType,lineWrapping:e.lineWrapping,extensions:e.extensions,markdownConfig:e.markdownConfig,globalKeyBindings:e.globalKeyBindings,rootEditor:e.rootEditor,highlighter:e.highlighter,onChange:a,eventHandlers:{beforeinput:e.onbeforeinput,dragstart:e.ondragstart,keydown:(h,{state:f})=>e.onkeydown(h,f),paste:e.onpaste}}),mP(o)||o.focus(),()=>o.destroy()));var c=P4();Ih(c,h=>r=h,()=>r),z(i,c),hr()}var Gh=class i{event;tableState;position;static navigate(e){new i(e)[`navigate${e.key}`]()}navigateTab(){this.moveRight({createRow:!0,position:"end"})}navigateShiftTab(){this.moveLeft({createRow:!0,position:"end"})}navigateEnter(){this.moveDown({createRow:!0,position:"end"})}navigateArrowLeft(){this.position.left&&this.moveLeft({createRow:!1,position:"end"})}navigateArrowUp(){this.position.top&&this.moveUp({createRow:!1,position:"end"})}navigateArrowRight(){this.position.right&&this.moveRight({createRow:!1,position:"start"})}navigateArrowDown(){this.position.bottom&&this.moveDown({createRow:!1,position:"end"})}navigateShiftArrowLeft(){if(!(!this.position.left||I(this.tableState.outlinedSection)||I(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),I(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.endCol===this.tableState.anchorCell.col){if(this.tableState.outlinedSection.startCol===this.tableState.table.firstColIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandLeft()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractLeft();this.tableState.activeCell=iP(this.tableState.activeCell)}}navigateShiftArrowUp(){if(!(!this.position.top||I(this.tableState.outlinedSection)||I(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),I(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.endRow===this.tableState.anchorCell.row){if(this.tableState.outlinedSection.startRow===this.tableState.table.firstRowIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandUp()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractUp();this.tableState.activeCell=Jk(this.tableState.activeCell)}}navigateShiftArrowRight(){if(!(!this.position.right||I(this.tableState.outlinedSection)||I(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),I(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.startCol===this.tableState.anchorCell.col){if(this.tableState.outlinedSection.endCol===this.tableState.table.lastColIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandRight()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractRight();this.tableState.activeCell=eP(this.tableState.activeCell)}}navigateShiftArrowDown(){if(!(!this.position.bottom||I(this.tableState.outlinedSection)||I(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),I(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.startRow===this.tableState.anchorCell.row){if(this.tableState.outlinedSection.endRow===this.tableState.table.lastRowIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandDown()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractDown();this.tableState.activeCell=tP(this.tableState.activeCell)}}moveLeft({createRow:e,position:t}){if(!I(this.tableState.activeCell)){if(this.event.preventDefault(),co(this.tableState.activeCell,this.tableState.table.firstCellLocation)){if(!e){this.tableState.navigate("before");return}this.tableState.table.prependEmptyRows(1),this.tableState.activeCell={row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col}}this.moveTo(this.tableState.activeCell.col===this.tableState.table.firstColIndex?{row:this.tableState.activeCell.row-1,col:this.tableState.table.lastColIndex}:{row:this.tableState.activeCell.row,col:this.tableState.activeCell.col-1},t)}}moveUp({createRow:e,position:t}){if(!I(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.firstRowIndex){if(!e){this.tableState.navigate("before");return}this.tableState.table.prependEmptyRows(1),this.tableState.activeCell={row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col}}this.moveTo({row:this.tableState.activeCell.row-1,col:this.tableState.activeCell.col},t)}}moveRight({createRow:e,position:t}){if(!I(this.tableState.activeCell)){if(this.event.preventDefault(),co(this.tableState.activeCell,this.tableState.table.lastCellLocation)){if(!e){this.tableState.navigate("after");return}this.tableState.table.appendEmptyRows(1)}this.moveTo(this.tableState.activeCell.col===this.tableState.table.lastColIndex?{row:this.tableState.activeCell.row+1,col:this.tableState.table.firstColIndex}:{row:this.tableState.activeCell.row,col:this.tableState.activeCell.col+1},t)}}moveDown({createRow:e,position:t}){if(!I(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.lastRowIndex){if(!e){this.tableState.navigate("after");return}this.tableState.table.appendEmptyRows(1)}this.moveTo({row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col},t)}}moveTo(e,t){if(this.tableState.activeCell=e,this.tableState.anchorCell=e,this.tableState.outlinedSection=Ke.ofCell(e),this.tableState.selection.isCell()){let n=t==="start"?0:this.tableState.table.cellAt(e).length;this.tableState.selectionValue={cell:e,section:{anchor:n,head:n}}}}constructor({event:e,tableState:t,position:n}){this.event=e,this.tableState=t,this.position=n}},Se={alt:"Alt",arrowDown:"ArrowDown",arrowLeft:"ArrowLeft",arrowRight:"ArrowRight",arrowUp:"ArrowUp",backspace:"Backspace",c:"c",delete:"Delete",enter:"Enter",escape:"Escape",shift:"Shift",tab:"Tab",v:"v",x:"x"},C4=[Se.arrowDown,Se.arrowLeft,Se.arrowRight,Se.arrowUp,Se.enter,Se.tab,`${Se.shift}${Se.arrowDown}`,`${Se.shift}${Se.arrowLeft}`,`${Se.shift}${Se.arrowRight}`,`${Se.shift}${Se.arrowUp}`,`${Se.shift}${Se.tab}`],RQ=new Set(C4);function gP({key:i,shiftKey:e,altKey:t,metaKey:n,ctrlKey:r}){if(!(t||n||r))return e?RQ.has(`${Se.shift}${i}`)?`${Se.shift}${i}`:void 0:RQ.has(i)?i:void 0}function T4(i,e){i.inputType==="historyUndo"?(e.undo(),i.preventDefault()):i.inputType==="historyRedo"&&(e.redo(),i.preventDefault())}function R4(i){i.preventDefault()}function A4(i,e,t){let n=gP(i);if(I(n))return;let r=e.selection.main.head,o=e.doc.lineAt(r).number,s=0,l=e.doc.length,a=1,c=e.doc.lines,h={top:o===a,right:r===l,bottom:o===c,left:r===s};Gh.navigate({tableState:t,key:n,event:i,position:h})}function X4(i,e){sg({tableState:e,event:i})}var E4=oe('<div class="tbl-cell-view" contenteditable="" tabindex="-1"><!></div>');function _4(i,e){cr(e,!0);var t=E4(),n=mi(t);lo(n,()=>e.children),Qt(r=>{Ce(t,"data-component",lg),Ce(t,"data-hidden",r)},[()=>no(e.hidden)]),z(i,t),hr()}var bP="Handle";function ag(i){if(!Fk(i,{component:bP}))return;let{type:e,location:t}=tg(i).dataset;if(e==="table")return{type:e,location:t};{let n=ff(ra(i));return r4({location:t,type:e},n)}}var Z4=Si('<svg class="tbl-handle-grip" width="15" height="3" fill="currentColor" viewBox="0 0 15 3" xmlns="http://www.w3.org/2000/svg"><circle cx="1.5" cy="1.5" r="1.5"></circle><circle cx="7.5" cy="1.5" r="1.5"></circle><circle cx="13.5" cy="1.5" r="1.5"></circle></svg>'),M4=Si('<svg class="tbl-handle-grip" width="3" height="15" fill="currentColor" viewBox="0 0 3 15" xmlns="http://www.w3.org/2000/svg"><circle cy="1.5" cx="1.5" r="1.5"></circle><circle cy="7.5" cx="1.5" r="1.5"></circle><circle cy="13.5" cx="1.5" r="1.5"></circle></svg>'),L4=oe('<div class="tbl-handle" role="button" aria-hidden="true"><!></div>');function AQ(i,e){cr(e,!0);let t=ym(e,"toggle",3,!1),n={table:{right:"vertical",bottom:"horizontal"},header:{row:"vertical",col:"horizontal"}},r=G(()=>n[e.of.type]?.[e.of.location]);var o=L4();Vh(o,"",{},{opacity:"var(--tbl-handle-opacity, 0)"});var s=mi(o);{var l=c=>{var h=Z4();z(c,h)},a=c=>{var h=M4();z(c,h)};Ot(s,c=>{P(r)==="horizontal"?c(l):P(r)==="vertical"&&c(a,1)})}Qt((c,h,f)=>{Ce(o,"data-component",bP),Ce(o,"data-type",e.of.type),Ce(o,"data-location",e.of.location),Ce(o,"data-active",c),Ce(o,"data-hover",h),Ce(o,"data-toggle",f)},[()=>no(e.state==="active"),()=>no(e.state==="hover"),()=>no(t())]),z(i,o),hr()}var z4=oe('<div class="tbl-menu"><!></div>');function q4(i,e){cr(e,!0);let t,n=fe(void 0);af(()=>{e.translate(t).then(l=>Y(n,l,!0))});var r=z4();let o;var s=mi(r);lo(s,()=>e.children),Ih(r,l=>t=l,()=>t),Qt(l=>o=Vh(r,"",o,l),[()=>({visibility:Z(P(n))?void 0:"hidden",transform:Z(P(n))?`translate3d(${P(n).x}px, ${P(n).y}px, 0px)`:void 0})]),z(i,r),hr()}var W4=oe('<div class="tbl-menu-item" role="menuitem" tabindex="-1"><!></div>');function Kt(i,e){var t=W4(),n=mi(t);lo(n,()=>e.children),Wl("click",t,function(...r){e.onclick?.apply(this,r)}),z(i,t)}Dk(["click"]);function Jt(i,e){switch(i.action){case"add":return e.menu.clickAdd(i.direction);case"align":return e.menu.clickAlign(i.alignment);case"clear":return e.menu.clickClear();case"duplicate":return e.menu.clickDuplicate();case"move":return e.menu.clickMove(i.direction);case"remove":return e.menu.clickRemove();case"sort":return e.menu.clickSort(i.direction)}}var D4=Si('<path d="M294.6 454.6L214.6 534.6C202.1 547.1 181.8 547.1 169.3 534.6L89.3 454.6C76.8 442.1 76.8 421.8 89.3 409.3C101.8 396.8 122.1 396.8 134.6 409.3L160 434.7L160 128C160 110.3 174.3 96 192 96C209.7 96 224 110.3 224 128L224 434.7L249.4 409.3C261.9 396.8 282.2 396.8 294.7 409.3C307.2 421.8 307.2 442.1 294.7 454.6zM476.6 113.7C527.3 215 553.9 268.4 556.6 273.7C564.5 289.5 558.1 308.7 542.3 316.6C526.5 324.5 507.3 318.1 499.4 302.3L492.2 288L403.8 288L396.6 302.3C388.7 318.1 369.5 324.5 353.7 316.6C337.9 308.7 331.5 289.5 339.4 273.7C342.1 268.4 368.7 215 419.4 113.7C424.8 102.9 435.9 96 448 96C460.1 96 471.2 102.8 476.6 113.7zM448 199.6L427.8 240L468.2 240L448 199.6zM352 384C352 366.3 366.3 352 384 352L512 352C524.9 352 536.6 359.8 541.6 371.8C546.6 383.8 543.8 397.5 534.7 406.7L461.3 480L512 480C529.7 480 544 494.3 544 512C544 529.7 529.7 544 512 544L384 544C371.1 544 359.4 536.2 354.4 524.2C349.4 512.2 352.2 498.5 361.3 489.3L434.7 415.9L384 415.9C366.3 415.9 352 401.6 352 383.9z"></path>'),j4=Si('<path d="M294.6 454.6L214.6 534.6C202.1 547.1 181.8 547.1 169.3 534.6L89.3 454.6C76.8 442.1 76.8 421.8 89.3 409.3C101.8 396.8 122.1 396.8 134.6 409.3L160 434.7L160 128C160 110.3 174.3 96 192 96C209.7 96 224 110.3 224 128L224 434.7L249.4 409.3C261.9 396.8 282.2 396.8 294.7 409.3C307.2 421.8 307.2 442.1 294.7 454.6zM352 128C352 110.3 366.3 96 384 96L512 96C524.9 96 536.6 103.8 541.6 115.8C546.6 127.8 543.8 141.5 534.7 150.7L461.3 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L384 288C371.1 288 359.4 280.2 354.4 268.2C349.4 256.2 352.2 242.5 361.3 233.3L434.8 160L384 160C366.3 160 352 145.7 352 128zM476.6 337.7L556.6 497.7C564.5 513.5 558.1 532.7 542.3 540.6C526.5 548.5 507.3 542.1 499.4 526.3L492.2 512L403.8 512L396.6 526.3C388.7 542.1 369.5 548.5 353.7 540.6C337.9 532.7 331.5 513.5 339.4 497.7L419.4 337.7C424.8 326.9 435.9 320 448 320C460.1 320 471.2 326.8 476.6 337.7zM448 423.6L427.8 464L468.2 464L448 423.6z"></path>'),V4=Si('<path d="M384 128C384 145.7 369.7 160 352 160L128 160C110.3 160 96 145.7 96 128C96 110.3 110.3 96 128 96L352 96C369.7 96 384 110.3 384 128zM384 384C384 401.7 369.7 416 352 416L128 416C110.3 416 96 401.7 96 384C96 366.3 110.3 352 128 352L352 352C369.7 352 384 366.3 384 384zM96 256C96 238.3 110.3 224 128 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L128 288C110.3 288 96 273.7 96 256zM544 512C544 529.7 529.7 544 512 544L128 544C110.3 544 96 529.7 96 512C96 494.3 110.3 480 128 480L512 480C529.7 480 544 494.3 544 512z"></path>'),I4=Si('<path d="M448 128C448 110.3 433.7 96 416 96L224 96C206.3 96 192 110.3 192 128C192 145.7 206.3 160 224 160L416 160C433.7 160 448 145.7 448 128zM544 256C544 238.3 529.7 224 512 224L128 224C110.3 224 96 238.3 96 256C96 273.7 110.3 288 128 288L512 288C529.7 288 544 273.7 544 256zM96 512C96 529.7 110.3 544 128 544L512 544C529.7 544 544 529.7 544 512C544 494.3 529.7 480 512 480L128 480C110.3 480 96 494.3 96 512zM448 384C448 366.3 433.7 352 416 352L224 352C206.3 352 192 366.3 192 384C192 401.7 206.3 416 224 416L416 416C433.7 416 448 401.7 448 384z"></path>'),Y4=Si('<path d="M544 128C544 145.7 529.7 160 512 160L288 160C270.3 160 256 145.7 256 128C256 110.3 270.3 96 288 96L512 96C529.7 96 544 110.3 544 128zM544 384C544 401.7 529.7 416 512 416L288 416C270.3 416 256 401.7 256 384C256 366.3 270.3 352 288 352L512 352C529.7 352 544 366.3 544 384zM96 256C96 238.3 110.3 224 128 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L128 288C110.3 288 96 273.7 96 256zM544 512C544 529.7 529.7 544 512 544L128 544C110.3 544 96 529.7 96 512C96 494.3 110.3 480 128 480L512 480C529.7 480 544 494.3 544 512z"></path>'),B4=Si('<path d="M342.6 81.4C330.1 68.9 309.8 68.9 297.3 81.4L137.3 241.4C124.8 253.9 124.8 274.2 137.3 286.7C149.8 299.2 170.1 299.2 182.6 286.7L288 181.3L288 552C288 569.7 302.3 584 320 584C337.7 584 352 569.7 352 552L352 181.3L457.4 286.7C469.9 299.2 490.2 299.2 502.7 286.7C515.2 274.2 515.2 253.9 502.7 241.4L342.7 81.4z"></path>'),N4=Si('<path d="M566.6 342.6C579.1 330.1 579.1 309.8 566.6 297.3L406.6 137.3C394.1 124.8 373.8 124.8 361.3 137.3C348.8 149.8 348.8 170.1 361.3 182.6L466.7 288L96 288C78.3 288 64 302.3 64 320C64 337.7 78.3 352 96 352L466.7 352L361.3 457.4C348.8 469.9 348.8 490.2 361.3 502.7C373.8 515.2 394.1 515.2 406.6 502.7L566.6 342.7z"></path>'),U4=Si('<path d="M297.4 566.6C309.9 579.1 330.2 579.1 342.7 566.6L502.7 406.6C515.2 394.1 515.2 373.8 502.7 361.3C490.2 348.8 469.9 348.8 457.4 361.3L352 466.7L352 96C352 78.3 337.7 64 320 64C302.3 64 288 78.3 288 96L288 466.7L182.6 361.3C170.1 348.8 149.8 348.8 137.3 361.3C124.8 373.8 124.8 394.1 137.3 406.6L297.3 566.6z"></path>'),G4=Si('<path d="M73.4 297.4C60.9 309.9 60.9 330.2 73.4 342.7L233.4 502.7C245.9 515.2 266.2 515.2 278.7 502.7C291.2 490.2 291.2 469.9 278.7 457.4L173.3 352L544 352C561.7 352 576 337.7 576 320C576 302.3 561.7 288 544 288L173.3 288L278.7 182.6C291.2 170.1 291.2 149.8 278.7 137.3C266.2 124.8 245.9 124.8 233.4 137.3L73.4 297.3z"></path>'),F4=Si('<path d="M262.2 48C248.9 48 236.9 56.3 232.2 68.8L216 112L120 112C106.7 112 96 122.7 96 136C96 149.3 106.7 160 120 160L520 160C533.3 160 544 149.3 544 136C544 122.7 533.3 112 520 112L424 112L407.8 68.8C403.1 56.3 391.2 48 377.8 48L262.2 48zM128 208L128 512C128 547.3 156.7 576 192 576L448 576C483.3 576 512 547.3 512 512L512 208L464 208L464 512C464 520.8 456.8 528 448 528L192 528C183.2 528 176 520.8 176 512L176 208L128 208zM288 280C288 266.7 277.3 256 264 256C250.7 256 240 266.7 240 280L240 456C240 469.3 250.7 480 264 480C277.3 480 288 469.3 288 456L288 280zM400 280C400 266.7 389.3 256 376 256C362.7 256 352 266.7 352 280L352 456C352 469.3 362.7 480 376 480C389.3 480 400 469.3 400 456L400 280z"></path>'),H4=oe('<div class="tbl-menu-item-icon"><svg xmlns="http://www.w3.org/2000/svg" height="14" width="14" viewBox="0 0 640 640" fill="currentColor"><!></svg></div>');function ei(i,e){var t=H4(),n=mi(t),r=mi(n);{var o=S=>{var x=D4();z(S,x)},s=S=>{var x=j4();z(S,x)},l=S=>{},a=S=>{var x=V4();z(S,x)},c=S=>{var x=I4();z(S,x)},h=S=>{var x=Y4();z(S,x)},f=S=>{var x=B4();z(S,x)},u=S=>{var x=N4();z(S,x)},d=S=>{var x=U4();z(S,x)},O=S=>{var x=G4();z(S,x)},m=S=>{},p=S=>{},b=S=>{var x=F4();z(S,x)};Ot(r,S=>{e.name==="sort-ascending"?S(o):e.name==="sort-descending"?S(s,1):e.name==="align-none"?S(l,2):e.name==="align-left"?S(a,3):e.name==="align-center"?S(c,4):e.name==="align-right"?S(h,5):e.name==="move-up"?S(f,6):e.name==="move-right"?S(u,7):e.name==="move-down"?S(d,8):e.name==="move-left"?S(O,9):e.name==="duplicate"?S(m,10):e.name==="clear"?S(p,11):e.name==="remove"&&S(b,12)})}z(i,t)}var K4=oe('<div class="tbl-menu-item-text"><!></div>');function ti(i,e){var t=K4(),n=mi(t);lo(n,()=>e.children),z(i,t)}var J4=oe('<div class="tbl-menu-separator"></div>');function Rh(i){var e=J4();z(i,e)}var e3=oe('<div class="tbl-select-all-overlay" aria-hidden="true"></div>');function t3(i){var e=e3();z(i,e)}var i3=new Set([Se.c,Se.v,Se.x]);function n3(i,e){return i3.has(i.key)&&i[jL(e)]}var r3=[Se.backspace,Se.delete],o3=new Set(r3);function s3({key:i}){return o3.has(i)?i:void 0}function l3(i){return/^F\d+$/.test(i)}var a3=new Set([Se.alt,Se.escape,Se.enter,Se.shift]);function c3({metaKey:i,ctrlKey:e,key:t}){return!e&&!i&&!a3.has(t)&&!l3(t)}function h3(i,e){e.selection.isCell()||fP({tableState:e,event:i})}function f3(i,e){e.selection.isCell()||uP({tableState:e,event:i})}function u3(i,e){e.selection.isCell()||sg({tableState:e,event:i})}function d3(i,e){if(Z(i.target)&&Z(OP(i.target))){i.preventDefault();return}if(!e.interactive||e.selection.isCell())return;let t=gP(i);if(Z(t)){Gh.navigate({tableState:e,key:t,event:i,position:{left:!0,top:!0,right:!0,bottom:!0}});return}let n=s3(i);if(Z(n)){hP({tableState:e,event:i});return}if(e.activeTable&&Z(e.activeCell)&&c3(i)){e.activeTable=!1,e.anchorCell=e.activeCell;let r=e.table.cellAt(e.activeCell).length;e.selectionValue={cell:e.activeCell,section:{head:r,anchor:r}},e.outlinedSection=Ke.ofCell(e.activeCell);return}n3(i,e.window)||tc(e.rootEditor,i,"editor")&&i.preventDefault()}function cg(i){return i.buttons===1}function SP(i,e){return e.setPointerCapture(i.pointerId),()=>e.releasePointerCapture(i.pointerId)}var Fh=class i{offset;maxScroll;boundaryElement;scrollElement;scroll;handle;xAmount;yAmount;updatePosition(e,t){let n=this.boundaryElement.x.getBoundingClientRect();e<n.left+this.offset?this.xAmount=-Pt(this.offset+(n.left-e),{max:this.maxScroll}):e>n.right-this.offset?this.xAmount=Pt(this.offset-(n.right-e),{max:this.maxScroll}):this.xAmount=0;let r=this.boundaryElement.y.getBoundingClientRect();t<r.top+this.offset?this.yAmount=-Pt(this.offset+(r.top-t),{max:this.maxScroll}):t>r.bottom-this.offset?this.yAmount=Pt(this.offset-(r.bottom-t),{max:this.maxScroll}):this.yAmount=0,I(this.handle)&&(this.xAmount!==0||this.yAmount!==0)&&this.scroll()}destroy(){Z(this.handle)&&cancelAnimationFrame(this.handle)}scrollInternal(){if(this.xAmount===0&&this.yAmount===0){this.scroll();return}this.scrollElement.x.scrollBy({left:this.xAmount}),this.scrollElement.y.scrollBy({top:this.yAmount}),this.scroll()}static of(e){return new i(e)}constructor({offset:e,maxScroll:t,boundaryElement:n,scrollElement:r}){let o=this.scrollInternal.bind(this);this.scroll=()=>{this.handle=requestAnimationFrame(o)},this.xAmount=0,this.yAmount=0,this.offset=e??0,this.maxScroll=t,this.boundaryElement=n,this.scrollElement=r}},Hh=class i{start;size;get mid(){return this.start+this.size/2}get end(){return this.start+this.size}static of(e){return new i(e)}constructor({start:e,size:t}){this.start=e,this.size=t}},Kh;(i=>{function e(t,n){return Xm.of(t,n)}i.of=e})(Kh||(Kh={}));var Xm=class i{rows;cols;rowsOrCols(e){return e==="row"?this.rows:this.cols}rowAt(e){return this.rows[e]}colAt(e){return this.cols[e]}rowOrColAt(e,t){return e==="row"?this.rowAt(t):this.colAt(t)}get firstRow(){return this.rows[this.firstRowIndex]}get firstCol(){return this.cols[this.firstColIndex]}firstRowOrCol(e){return e==="row"?this.firstRow:this.firstCol}get lastRow(){return this.rows[this.lastRowIndex]}get lastCol(){return this.cols[this.lastColIndex]}lastRowOrCol(e){return e==="row"?this.lastRow:this.lastCol}firstRowIndex=0;firstColIndex=0;firstRowOrColIndex(e){return 0}get lastRowIndex(){return this.rowCount-1}get lastColIndex(){return this.colCount-1}lastRowOrColIndex(e){return e==="row"?this.lastRowIndex:this.lastColIndex}get rowCount(){return this.rows.length}get colCount(){return this.cols.length}get minRowSize(){return qh(...this.rows.map(e=>e.size))}get minColSize(){return qh(...this.cols.map(e=>e.size))}moveRowOrColAt(e,{fromIndex:t,toIndex:n}){if(t===n)return;let r=this.rowsOrCols(e),o=r[t];if(t<n){for(let s of ir({start:t,endExclusive:n}))r[s]=r[s+1],r[s].start-=o.size;o.start=r[n].start+r[n].size}else{for(let s of ir({start:t,endExclusive:n}))r[s]=r[s-1],r[s].start+=o.size;o.start=r[n].start-o.size}r[n]=o}lastCellBeforePosition(e){let t=this.rows.map(r=>r.start).findLastIndex(r=>r<e.y),n=this.cols.map(r=>r.start).findLastIndex(r=>r<e.x);return{row:t===-1?0:t,col:n===-1?0:n}}static of(e,t){return new i(e,t)}constructor(e,t){let n=[...e.querySelectorAll("tr:first-child > th")],r=[...e.querySelectorAll("tr > th:first-child,tr > td:first-child")];this.rows=r.map((o,s)=>{let{top:l,height:a}=XQ(o,t),c=0;return Hh.of({start:l+c,size:a-c})}),this.cols=n.map((o,s)=>{let{left:l,width:a}=XQ(o,t),c=s===0?1:0;return Hh.of({start:l+c,size:a-c})})}};function XQ(i,e){let{top:t,left:n,width:r,height:o}=i.getBoundingClientRect();return{top:t+e.y,left:n+e.x,width:r,height:o}}var Jh=class i{tableState;tableMeasurement;autoScroller;shouldAutoScroll;removeEventListeners;currentCell;start(){this.tableState.activeCell=this.currentCell,this.tableState.anchorCell=this.currentCell,this.tableState.outlinedSection=Ke.ofCell(this.currentCell),this.tableState.outline={outlined:!1},this.removeEventListeners=ao(qe(this.tableState.window,"pointermove",e=>this.drag(e)),qe(this.tableState.window,"pointerup",()=>this.end()),qe(this.tableState.window,"pointerleave",()=>this.end()))}resizeAndContinue(e){e.preventDefault(),I(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.currentCell),this.expandOrContract(this.currentCell),this.tableState.outline={outlined:!0},this.removeEventListeners=ao(qe(this.tableState.window,"pointermove",t=>this.drag(t)),qe(this.tableState.window,"pointerup",()=>this.end()),qe(this.tableState.window,"pointerleave",()=>this.end()))}drag(e){if(!cg(e)){this.end();return}e.preventDefault(),this.shouldAutoScroll()&&this.autoScroller.updatePosition(e.clientX,e.clientY);let t=this.tableMeasurement.lastCellBeforePosition({x:e.clientX+this.tableState.scrollOffsetX,y:e.clientY+this.tableState.scrollOffsetY});co(t,this.currentCell)||(this.currentCell=t,this.tableState.outline={outlined:!0},this.expandOrContract(t))}end(){this.removeEventListeners?.(),this.autoScroller.destroy(),this.tableState.outline=void 0}expandOrContract(e){this.tableState.focusTable();let[t,n]=e.row<=this.tableState.anchorCell.row?[e.row,this.tableState.anchorCell.row]:[this.tableState.anchorCell.row,e.row],[r,o]=e.col<=this.tableState.anchorCell.col?[e.col,this.tableState.anchorCell.col]:[this.tableState.anchorCell.col,e.col];this.tableState.outlinedSection=Ke.of({row:{start:t,endExclusive:n+1},col:{start:r,endExclusive:o+1}}),this.tableState.activeCell=e}static startOutline(e){new i(e).start()}static resizeAndContinueOutline(e){new i(e).resizeAndContinue(e.event)}constructor({tableState:e,cellLocation:t}){this.tableState=e,this.currentCell=t,this.autoScroller=Fh.of({offset:10,maxScroll:32,boundaryElement:{x:e.scrollElement,y:e.rootScrollElement},scrollElement:{x:e.scrollElement,y:e.rootScrollElement}}),this.shouldAutoScroll=wq({delayMillis:500}),this.tableMeasurement=Kh.of(e.tableElement,{x:e.scrollOffsetX,y:e.scrollOffsetY})}};function O3(i,e){nf(e.window)&&(e.hoveredCell=i)}function p3(i){nf(i.window)&&(i.hoveredCell=void 0)}function m3(i,e,t){if(!(!t.interactive||!cg(i)))if(i.shiftKey){if(t.selection.isCell()&&co(e,t.selection.cell))return;Jh.resizeAndContinueOutline({event:i,tableState:t,cellLocation:e})}else Jh.startOutline({event:i,tableState:t,cellLocation:e})}var g3=new Intl.Collator(navigator.language,{numeric:!0,sensitivity:"base"});function EQ(i,e){return g3.compare(i,e)}function b3({metaKey:i,shiftKey:e,altKey:t,ctrlKey:n,key:r}){return r===Se.escape&&!e&&!t&&!i&&!n}var Em=class i{tableState;handle;point;removeEventListeners;get rowOrCol(){return this.handle.location}get index(){return this.handle.index}open(){let e=this.tableState.document.body;this.removeEventListeners=ao(qe(e,"pointerdown",s=>{s.preventDefault(),(I(s.target)||!Bk(this.tableState.menuRootElement,s.target))&&this.close()}),qe(e,"wheel",s=>s.preventDefault(),{passive:!1}),qe(e,"keydown",s=>{s.preventDefault(),b3(s)&&this.close()})),this.tableState.focusTable(),this.tableState.activeHandle={state:"active",handle:this.handle},this.tableState.outlinedSection=Ke.of(this.rowOrCol==="row"?{row:{start:this.index,endExclusive:this.index+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:this.index,endExclusive:this.index+1}});let t=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=t,this.tableState.anchorCell=t;let n=this.index!==this.tableState.table.firstRowOrColIndex(this.rowOrCol),r=this.index!==this.tableState.table.lastRowOrColIndex(this.rowOrCol),o=!1;n?o=r?!0:"backward":r&&(o="forward"),this.tableState.menu={type:this.rowOrCol,capabilities:{addable:!0,alignable:this.rowOrCol==="col",clearable:!0,duplicatable:!0,moveable:o,removable:!this.tableState.table.hasSingleRowOrCol(this.rowOrCol),sortable:this.rowOrCol==="col"},clickAdd:s=>this.clickAdd(s),clickAlign:s=>this.clickAlign(s),clickClear:()=>this.clickClear(),clickDuplicate:()=>this.clickDuplicate(),clickMove:s=>this.clickMove(s),clickRemove:()=>this.clickRemove(),clickSort:s=>this.clickSort(s),computeTranslation:s=>this.computeTranslation(s)}}close(){this.removeEventListeners?.(),this.tableState.menu=void 0,this.tableState.activeHandle=void 0}async computeTranslation(e){let t=await Uy({getBoundingClientRect:()=>({x:this.point.x,y:this.point.y,top:this.point.y,right:this.point.x,bottom:this.point.y,left:this.point.x,width:0,height:0})},e,{middleware:[By({allowedPlacements:this.rowOrCol==="row"?["right-start","right-end"]:["right-start","right"]}),Ny({crossAxis:!0})]}),n=gs(e);return{x:Uh(t.x,n),y:Uh(t.y,n)}}clickAdd(e){if(this.tableState.table.addEmptyRowsOrColsAt(this.rowOrCol,{index:e==="before"?this.index:this.index+1,count:1}),e==="after"){this.tableState.outlinedSection=this.tableState.outlinedSection?.shift(this.rowOrCol,"forward");let t=cm(this.rowOrCol,this.tableState.activeCell,"forward");this.tableState.activeCell=t,this.tableState.anchorCell=t}this.close()}clickAlign(e){this.tableState.table.setAlignmentAt(this.index,e),this.close()}clickClear(){this.tableState.table.clearRowOrCol(this.rowOrCol,this.index),this.close()}clickDuplicate(){this.tableState.table.duplicateRowOrColAt(this.rowOrCol,this.index),this.close()}clickMove(e){this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:e==="backward"?this.index-1:this.index+1}),this.tableState.outlinedSection=this.tableState.outlinedSection?.shift(this.rowOrCol,e);let t=cm(this.rowOrCol,this.tableState.activeCell,e);this.tableState.activeCell=t,this.tableState.anchorCell=t,this.close()}clickRemove(){if(this.tableState.table.removeRowsOrColsAt(this.rowOrCol,{index:this.index,count:1}),!this.tableState.table.hasRowOrColAt(this.rowOrCol,this.index)){this.tableState.outlinedSection=this.tableState.outlinedSection?.shift(this.rowOrCol,"backward");let e=cm(this.rowOrCol,this.tableState.activeCell,"backward");this.tableState.activeCell=e,this.tableState.anchorCell=e}this.close()}clickSort(e){this.tableState.table.sortByColAt(this.index,e==="ascending"?(t,n)=>EQ(t.toString(),n.toString()):(t,n)=>EQ(n.toString(),t.toString())),this.close()}static showMenu(e){new i(e).open()}constructor({tableState:e,handle:t,point:n}){this.tableState=e,this.handle=t,this.point=n}},_m=class i{coordinate;initialIndex;size;initialPosition;minBound;maxBound;scrollOffsetX;scrollOffsetY;subject;rowOrCol;tableMeasurement;currentIndex;currentPosition;dragged;start(){return{cellMovement:e=>this.cellMovement(e)}}drag(e){this.currentPosition=e[this.coordinate];let{currentIndex:t,move:n}=this.calculateDrag();return this.currentIndex=t,this.initialIndex!==this.currentIndex&&(this.dragged=!0),Z(n)&&this.tableMeasurement.moveRowOrColAt(this.rowOrCol,n),{cellMovement:r=>this.cellMovement(r)}}end(){return this.initialIndex===this.currentIndex?{moved:!1,dragged:this.dragged}:{moved:!0,toIndex:this.currentIndex}}cellMovement(e){return{border:this.cellBorder(e),state:this.cellState(e),translate:this.cellTranslate(e)}}cellBorder(e){let t=this.isRowOrColExposed(e[this.rowOrCol]),n=this.subject.containsCell(e);return this.rowOrCol==="row"?{top:t,right:!0,bottom:!n||e.row===this.tableMeasurement.lastRowIndex,left:this.tableMeasurement.firstColIndex===e.col}:{top:this.tableMeasurement.firstRowIndex===e.row,right:!n||e.col===this.tableMeasurement.lastColIndex,bottom:!0,left:t}}cellState(e){return this.subject.containsCell(e)?"moving":"shiftable"}cellTranslate(e){let t=this.rowOrColTranslate(e[this.rowOrCol]);return this.rowOrCol==="row"?{x:0,y:t}:{x:t,y:0}}isRowOrColExposed(e){let t=this.reorderIndex(e),n=t===this.tableMeasurement.firstRowOrColIndex(this.rowOrCol),r=t===this.currentIndex+1;return n||r}get rowOrColShift(){if(this.currentIndex!==this.initialIndex)return this.currentIndex<this.initialIndex?{direction:"forwards",range:{start:this.currentIndex,endExclusive:this.initialIndex},indexDiff:1,positionDiff:this.size-1}:{direction:"backwards",range:{start:this.initialIndex+1,endExclusive:this.currentIndex+1},indexDiff:-1,positionDiff:1-this.size}}rowOrColTranslate(e){if(e===this.initialIndex)return Pt(this.currentPosition-this.initialPosition,{min:this.minBound,max:this.maxBound});let t=this.rowOrColShift;return I(t)?0:er(e,t.range)?t.positionDiff:0}reorderIndex(e){let t=this.rowOrColShift;return I(t)?e:e===this.initialIndex?this.currentIndex:er(e,t.range)?e+t.indexDiff:e}calculateDrag(){let e=this.tableMeasurement.rowsOrCols(this.rowOrCol),t={name:"current",index:this.currentIndex,mid:e[this.currentIndex].mid},n=this.currentIndex!==this.tableMeasurement.firstRowOrColIndex(this.rowOrCol)?{name:"left",index:this.currentIndex-1,mid:e[this.currentIndex-1].start+e[this.currentIndex].size/2}:void 0,r=this.currentIndex!==this.tableMeasurement.lastRowOrColIndex(this.rowOrCol)?{name:"right",index:this.currentIndex+1,mid:e[this.currentIndex].start+e[this.currentIndex+1].size+e[this.currentIndex].size/2}:void 0,o=dL(OL([t,n,r]),(s,l)=>hm(this.currentPosition-s.mid)-hm(this.currentPosition-l.mid));return o.name==="current"?{currentIndex:this.currentIndex,move:void 0}:{currentIndex:o.index,move:{fromIndex:this.currentIndex,toIndex:o.index}}}static of(e){return new i(e)}constructor({rowOrCol:e,index:t,position:n,subject:r,tableElement:o,scrollOffsetX:s,scrollOffsetY:l}){this.scrollOffsetX=s,this.scrollOffsetY=l;let a=Kh.of(o,{x:this.scrollOffsetX(),y:this.scrollOffsetY()});this.rowOrCol=e,this.coordinate=e==="row"?"y":"x",this.initialIndex=t,this.initialPosition=n[this.coordinate],this.minBound=a.firstRowOrCol(this.rowOrCol).start-a.rowOrColAt(this.rowOrCol,t).start,this.maxBound=a.lastRowOrCol(this.rowOrCol).end-a.rowOrColAt(this.rowOrCol,t).end,this.size=a.rowOrColAt(this.rowOrCol,t).size,this.subject=r,this.dragged=!1,this.tableMeasurement=a,this.currentIndex=t,this.currentPosition=n[this.coordinate]}},Zm=class i{tableState;rowOrCol;index;onClick;moveTracker;subject;autoScroller;removeEventListeners;start(e){e.preventDefault();let t=this.moveTracker.start();this.tableState.outlinedSection=this.subject,this.tableState.move=t,this.tableState.activeHandle={state:"active",handle:{type:"header",index:this.index,location:this.rowOrCol}};let n=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=n,this.tableState.anchorCell=n,this.tableState.focusTable();let r=tg(e.target);this.removeEventListeners=ao(SP(e,r),qe(r,"pointermove",o=>this.drag(o)),qe(r,"pointerup",()=>this.end()))}drag(e){e.preventDefault(),this.autoScroller.updatePosition(e.clientX,e.clientY),this.tableState.move=this.moveTracker.drag({x:e.clientX+this.tableState.scrollOffsetX,y:e.clientY+this.tableState.scrollOffsetY})}end(){this.removeEventListeners?.(),this.autoScroller.destroy();let e=this.moveTracker.end();if(e.moved){this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:e.toIndex}),this.tableState.outlinedSection=Ke.of(this.rowOrCol==="row"?{row:{start:e.toIndex,endExclusive:e.toIndex+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:e.toIndex,endExclusive:e.toIndex+1}});let t=this.rowOrCol==="row"?{row:e.toIndex,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:e.toIndex};this.tableState.activeCell=t,this.tableState.anchorCell=t}this.tableState.move=void 0,this.tableState.activeHandle=void 0,!e.moved&&!e.dragged&&this.onClick()}static startMove(e){new i(e).start(e.event)}constructor({event:e,tableState:t,rowOrCol:n,index:r,onClick:o}){this.tableState=t,this.rowOrCol=n,this.index=r,this.subject=Ke.of(n==="row"?{row:{start:r,endExclusive:r+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:r,endExclusive:r+1}}),this.onClick=o,this.autoScroller=Fh.of({offset:16,maxScroll:32,boundaryElement:{x:t.scrollElement,y:t.rootScrollElement},scrollElement:{x:t.scrollElement,y:t.rootScrollElement}}),this.moveTracker=_m.of({subject:this.subject,rowOrCol:n,index:r,position:{x:e.clientX+t.scrollOffsetX,y:e.clientY+t.scrollOffsetY},tableElement:t.tableElement,scrollOffsetX:()=>this.tableState.scrollOffsetX,scrollOffsetY:()=>this.tableState.scrollOffsetY})}};function S3(i){return i==="row"?"y":"x"}var Mm=class i{tableState;type;initialHandle;initialRowOrColCount;initialPosition;initialOutlinedSection;initialActiveCell;initialAnchorCell;cellSizePixels;dragThresholdPixels;dragged;start(){return{activeHandle:{state:"active",handle:this.initialHandle}}}drag(e){return this.dragged=!0,this.calculateDrag(e)}end(){return this.dragged?{activeHandle:void 0}:this.calculateClick()}calculateClick(){if(this.type!=="table")return this.calculateClickRowOrCol(this.type);if(this.initialHandle.location==="right")return this.calculateClickRowOrCol("col");if(this.initialHandle.location==="bottom")return this.calculateClickRowOrCol("row");let e=this.calculateClickRowOrCol("row"),t=this.calculateClickRowOrCol("col");return{operation:{row:e.operation.row,col:t.operation.col},activeHandle:e.activeHandle,activeCell:Z(e.activeCell)&&Z(t.activeCell)?{row:e.activeCell.row,col:t.activeCell.col}:void 0,anchorCell:Z(e.anchorCell)&&Z(t.anchorCell)?{row:e.anchorCell.row,col:t.anchorCell.col}:void 0,outlinedSection:Z(e.outlinedSection)&&Z(t.outlinedSection)?Ke.of({row:e.outlinedSection.row,col:t.outlinedSection.col}):void 0}}calculateClickRowOrCol(e){let t=this.type==="table"?this.tableState.table.lastRowOrColIndex(e)+1:this.initialHandle.index;return{operation:{[e]:{action:"add",index:t,count:1}},activeHandle:this.type==="table"?void 0:{state:"hover",handle:{type:"border",location:this.handleLocationAt(t),index:t}},...this.calculateCellMovement(e,1)}}calculateDrag(e){if(this.type!=="table")return this.calculateDragRowOrCol(this.type,e);if(this.initialHandle.location==="right")return this.calculateDragRowOrCol("col",e);if(this.initialHandle.location==="bottom")return this.calculateDragRowOrCol("row",e);let t=this.calculateDragRowOrCol("row",e),n=this.calculateDragRowOrCol("col",e);if(I(t)&&I(n))return;let r=t??this.calculateCellMovement("row",this.rowOrColDiff("row")),o=n??this.calculateCellMovement("col",this.rowOrColDiff("col"));return{operation:{row:t?.operation.row,col:n?.operation.col},activeHandle:t?.activeHandle??n?.activeHandle,activeCell:Z(r.activeCell)&&Z(o.activeCell)?{row:r.activeCell.row,col:o.activeCell.col}:void 0,anchorCell:Z(r.anchorCell)&&Z(o.anchorCell)?{row:r.anchorCell.row,col:o.anchorCell.col}:void 0,outlinedSection:Z(r.outlinedSection)&&Z(o.outlinedSection)?Ke.of({row:r.outlinedSection.row,col:o.outlinedSection.col}):void 0}}calculateDragRowOrCol(e,t){let n=S3(e),r=t.position[n]-this.initialPosition[n],o=SL(r/this.cellSizePixels[e]),s=r%this.cellSizePixels[e]>=this.dragThresholdPixels[e]?1:0,l=this.tableState.table.rowOrColCount(e)-this.initialRowOrColCount[e],a=o+s-l,c=this.type==="table"?this.tableState.table.lastRowOrColIndex(e)+1:this.initialHandle.index+l;if(a!==0)return a>0?this.calculateDragRowOrColMore({rowOrCol:e,start:c,length:a}):this.calculateDragRowOrColLess({rowOrCol:e,start:c,length:qh(-a,c,this.tableState.table.lastRowOrColIndex(e))})}calculateDragRowOrColLess({rowOrCol:e,start:t,length:n}){let r=0;for(let s of ir({start:t-1,endExclusive:t-n-1})){if(!this.tableState.table.hasEmptyRowOrColAt(e,s))break;r++}if(r===0)return;let o=t-(r-1)-1;return{operation:{[e]:{action:"remove",index:t-r,count:r}},activeHandle:this.type==="table"?{state:"active",handle:this.initialHandle}:{state:"active",handle:{type:"border",location:this.handleLocationAt(o),index:o}},...this.calculateCellMovement(e,this.rowOrColDiff(e)-r)}}calculateDragRowOrColMore({rowOrCol:e,start:t,length:n}){return{operation:{[e]:{action:"add",index:t,count:n}},activeHandle:{state:"active",handle:this.type==="table"?this.initialHandle:{type:"border",location:this.handleLocationAt(t+n),index:t+n}},...this.calculateCellMovement(e,this.rowOrColDiff(e)+n)}}calculateCellMovement(e,t){let n=this.type==="table"?this.initialRowOrColCount[e]:this.initialHandle.index;if(t>=0)return{outlinedSection:this.initialOutlinedSection?.addForwardsByRowOrCol(e,{start:n,count:t}),activeCell:Z(this.initialActiveCell)?wQ(e,this.initialActiveCell,{start:n,count:t}):void 0,anchorCell:Z(this.initialAnchorCell)?wQ(e,this.initialAnchorCell,{start:n,count:t}):void 0};{let r=-t,o=this.initialOutlinedSection?.subtractBackwardsByRowOrCol(e,{start:n,count:r,min:this.tableState.table.firstRowOrColIndex(e)}),s=Z(o)?{min:o.startRowOrCol(e),max:o.endRowOrCol(e)}:void 0,l=Z(this.initialActiveCell)?yQ(e,this.initialActiveCell,{start:n,count:r,boundary:s}):void 0,a=Z(this.initialAnchorCell)?yQ(e,this.initialAnchorCell,{start:n,count:r,boundary:s}):void 0;return{outlinedSection:o,activeCell:l,anchorCell:a}}}rowOrColDiff(e){return this.tableState.table.rowOrColCount(e)-this.initialRowOrColCount[e]}handleLocationAt(e){if(this.type!=="table")return this.type==="row"&&e===this.tableState.table.firstRowIndex?"top":this.type==="col"&&e===this.tableState.table.firstColIndex?"left":this.type}handleToType(e){return e.type==="table"?"table":e.location==="top"?"row":e.location==="left"?"col":e.location}static of(e){return new i(e)}constructor({tableState:e,handle:t,position:n,cellSizePixels:r,dragThresholdPixels:o}){this.tableState=e,this.type=this.handleToType(t),this.initialHandle=t,this.initialPosition=n,this.initialRowOrColCount={row:e.table.rowCount,col:e.table.colCount},this.initialActiveCell=e.activeCell,this.initialAnchorCell=e.anchorCell,this.initialOutlinedSection=e.outlinedSection,this.cellSizePixels=r,this.dragThresholdPixels=o,this.dragged=!1}};function x3(i){let e=Bh(i.tableElement,i.table.firstCellLocation),t=O4(e),{minWidth:n}=getComputedStyle(e),{lineHeight:r,paddingTop:o,paddingBottom:s}=getComputedStyle(t),l=parseFloat(n)+1,a=parseFloat(r)+parseFloat(o)+parseFloat(s)+1;return{width:l,height:a}}var Lm=class i{tableState;resizeTracker;removeEventListeners;start(e){e.preventDefault();let t=this.resizeTracker.start();this.tableState.resize={},this.tableState.activeHandle=t.activeHandle,this.tableState.focusTable(),this.removeEventListeners=ao(SP(e,this.tableState.tableElement),qe(this.tableState.tableElement,"pointermove",n=>this.drag(n)),qe(this.tableState.tableElement,"pointerup",()=>this.end()))}drag(e){e.preventDefault();let t=this.resizeTracker.drag({position:{x:e.clientX,y:e.clientY}});Z(t)&&(this.resizeTable(t.operation),this.tableState.activeHandle=t.activeHandle,this.tableState.activeCell=t.activeCell,this.tableState.anchorCell=t.anchorCell,this.tableState.outlinedSection=t.outlinedSection)}end(){this.removeEventListeners?.();let e=this.resizeTracker.end();"operation"in e&&(this.resizeTable(e.operation),this.tableState.activeCell=e.activeCell,this.tableState.anchorCell=e.anchorCell,this.tableState.outlinedSection=e.outlinedSection),this.tableState.activeHandle=e.activeHandle,this.tableState.resize=void 0}resizeTable({row:e,col:t}){if(Z(e)){let{action:n,index:r,count:o}=e;n==="add"?this.tableState.table.addEmptyRowsAt({row:r,count:o}):this.tableState.table.removeRowsAt({row:r,count:o})}if(Z(t)){let{action:n,index:r,count:o}=t;n==="add"?this.tableState.table.addEmptyColsAt({col:r,count:o}):this.tableState.table.removeColsAt({col:r,count:o})}}static startResize(e){new i(e).start(e.event)}constructor({event:e,tableState:t,handle:n}){this.tableState=t;let{width:r,height:o}=x3(t);this.resizeTracker=Mm.of({tableState:this.tableState,handle:n,position:{x:e.clientX,y:e.clientY},cellSizePixels:{row:o,col:r},dragThresholdPixels:{row:o/2,col:r/2}})}};function v3(i,e){e.interactive&&(e.activeHandle={state:"hover",handle:i})}function w3(i){i.interactive&&(i.activeHandle=void 0)}function y3(i,e,t){if(t.interactive){if(!cg(i)){i.preventDefault();return}e.type==="table"||e.type==="border"?Lm.startResize({event:i,handle:e,tableState:t}):e.type==="header"&&Zm.startMove({event:i,rowOrCol:e.location,index:e.index,tableState:t,onClick:()=>Em.showMenu({handle:e,point:{x:i.clientX,y:i.clientY},tableState:t})})}}function Q3(i,e){let t=i.target;if(I(t))return;let n=ag(t);if(Z(n)){v3(n,e);return}let r=ra(t);if(Z(r)){O3(ff(r),e);return}}function k3(i,e){let t=i.target;if(I(t))return;let n=ag(t);if(Z(n)){w3(e);return}let r=ra(t);if(Z(r)){p3(e);return}}function P3(i,e){let t=i.target;if(I(t))return;let n=ag(t);if(Z(n)){y3(i,n,e);return}let r=ra(t);if(Z(r)){m3(i,ff(r),e);return}i.preventDefault()}function $3(i){i.preventDefault()}var C3=oe("<!> <!> <!>",1),T3=oe('<tr class="tbl-table-row"></tr>'),R3=oe('<tbody class="tbl-table-body"></tbody>'),A3=oe("<!> <!>",1),X3=oe("<!> <!>",1),E3=oe("<!> <!> <!>",1),_3=oe("<!> <!>",1),Z3=oe("<!> <!>",1),M3=oe("<!> <!>",1),L3=oe("<!> <!>",1),z3=oe("<!> <!> <!> <!> <!>",1),q3=oe("<!> <!>",1),W3=oe("<!> <!>",1),D3=oe("<!> <!> <!>",1),j3=oe("<!> <!>",1),V3=oe("<!> <!>",1),I3=oe("<!> <!> <!>",1),Y3=oe("<!> <!>",1),B3=oe("<!> <!>",1),N3=oe("<!> <!>",1),U3=oe("<!> <!> <!> <!> <!> <!> <!>",1),G3=oe('<div class="tbl-table-wrapper"><table class="tbl-table" role="grid" tabindex="-1"><thead class="tbl-table-head"><!></thead><!></table> <!> <!> <!> <!></div>');function F3(i,e){cr(e,!0);let t=Am.of({table:()=>e.table,selection:()=>e.selection,scrollElement:()=>e.scrollElement,rootEditor:()=>e.rootEditor,menuRootElement:()=>e.menuRootElement,extensions:()=>e.extensions,markdownConfig:()=>e.markdownConfig,globalKeyBindings:()=>e.globalKeyBindings,selectionType:()=>e.selectionType,lineWrapping:()=>e.lineWrapping,onUndo:()=>e.onUndo,onRedo:()=>e.onRedo,onNavigate:()=>e.onNavigate,onDelete:()=>e.onDelete});af(()=>ao(qe(t.document,"selectionchange",()=>p4(t)),qe(t.document.body,"pointerdown",()=>a4(t),{capture:!0,passive:!0}),qe(t.document.body,"pointerup",()=>c4(t),{capture:!0,passive:!0}),qe(t.document.body,"pointerleave",()=>h4(t),{capture:!0,passive:!0}),qe(t.document.body,"copy",w=>f4(w,t)),qe(t.document.body,"cut",w=>u4(w,t)),qe(t.document.body,"paste",w=>d4(w,t))));var n=G3(),r=mi(n);{let w=(y,k=JQ)=>{var v=T3();$h(v,20,()=>t.table.colIndices,$=>$,($,L)=>{let A=G(()=>({row:k(),col:L})),q=G(()=>({top:k()===t.table.firstRowIndex,left:L===t.table.firstColIndex})),M=G(()=>t.selection.isCell()&&co(P(A),t.selection.cell));{let H=G(()=>t.outlinedSection?.containsOnEdge(P(A))??{top:!1,right:!1,bottom:!1,left:!1}),F=G(()=>t.move?.cellMovement(P(A)));Q4($,{get location(){return P(A)},get alignment(){return t.table.alignments[L]},get selected(){return P(M)},get position(){return P(q)},get outline(){return P(H)},get movement(){return P(F)},get win(){return t.window},children:(se,Ze)=>{var We=C3(),ye=ze(We);$h(ye,16,()=>n4(P(A),P(q)),Qe=>Qe,(Qe,Je)=>{{let bt=G(()=>t.cellHandleState(P(A),Je)),Et=G(()=>Z(t.resize));AQ(Qe,{get of(){return Je},get state(){return P(bt)},get toggle(){return P(Et)}})}});var Me=te(ye,2);_4(Me,{get hidden(){return P(M)},children:(Qe,Je)=>{var bt=eg(),Et=ze(bt);cq(Et,()=>Jq(t.table.cellAt(P(A)),t.highlighter(P(A)))),z(Qe,bt)},$$slots:{default:!0}});var st=te(Me,2);{var Dt=Qe=>{var Je=()=>t.table.cellAt(P(A)),bt=pe=>t.table.setCellAt(P(A),pe),Et=()=>t.selection.cellSection,K=pe=>{t.selectionValue={cell:P(A),section:pe}};{let pe=G(()=>t.highlighter(P(A)));$4(Qe,{get text(){return Je()},set text(me){bt(me)},get selection(){return Et()},set selection(me){K(me)},get selectionType(){return t.selectionType},get lineWrapping(){return t.lineWrapping},get extensions(){return t.extensions},get markdownConfig(){return t.markdownConfig},get rootEditor(){return t.rootEditor},get globalKeyBindings(){return t.globalKeyBindings},get highlighter(){return P(pe)},onbeforeinput:me=>T4(me,t),ondragstart:me=>R4(me),onkeydown:(me,Re)=>A4(me,Re,t),onpaste:me=>X4(me,t)})}};Ot(st,Qe=>{P(M)&&Qe(Dt)})}z(se,We)},$$slots:{default:!0}})}}),z(y,v)};var o=mi(r),s=mi(o);w(s,()=>t.table.headerRowIndex);var l=te(o);{var a=y=>{var k=R3();$h(k,20,()=>t.table.dataRowIndices,v=>v,(v,$)=>{w(v,()=>$)}),z(y,k)},c=G(()=>t.table.hasDataRows());Ot(l,y=>{P(c)&&y(a)})}Ih(r,y=>t.tableElement=y,()=>t?.tableElement)}var h=te(r,2);{var f=w=>{let y=G(()=>t.menu.type==="row"?"row":"column");b4(w,{get to(){return t.menuRootElement},children:(k,v)=>{q4(k,{translate:$=>t.menu.computeTranslation($),children:($,L)=>{let A=G(()=>{let{addable:K,alignable:pe,clearable:me,duplicatable:Re,moveable:Be,removable:Ne,sortable:$t}=t.menu.capabilities;return{addable:K,alignable:pe,clearable:me,duplicatable:Re,moveable:Be,removable:Ne,sortable:$t}});var q=U3(),M=ze(q);{var H=K=>{var pe=E3(),me=ze(pe);Kt(me,{onclick:()=>Jt({action:"sort",direction:"ascending"},t),children:(Ne,$t)=>{var ue=A3(),ge=ze(ue);ei(ge,{name:"sort-ascending"});var De=te(ge,2);ti(De,{children:(ke,lt)=>{var Ae=Ht();Qt(()=>xn(Ae,`Sort by ${P(y)??""} (A-Z)`)),z(ke,Ae)}}),z(Ne,ue)}});var Re=te(me,2);Kt(Re,{onclick:()=>Jt({action:"sort",direction:"descending"},t),children:(Ne,$t)=>{var ue=X3(),ge=ze(ue);ei(ge,{name:"sort-descending"});var De=te(ge,2);ti(De,{children:(ke,lt)=>{var Ae=Ht();Qt(()=>xn(Ae,`Sort by ${P(y)??""} (Z-A)`)),z(ke,Ae)}}),z(Ne,ue)}});var Be=te(Re,2);Rh(Be),z(K,pe)};Ot(M,K=>{P(A).sortable&&K(H)})}var F=te(M,2);{var se=K=>{var pe=z3(),me=ze(pe);Kt(me,{onclick:()=>Jt({action:"align",alignment:"none"},t),children:(ue,ge)=>{var De=_3(),ke=ze(De);ei(ke,{name:"align-none"});var lt=te(ke,2);ti(lt,{children:(Ae,xi)=>{var Hi=Ht("Align none");z(Ae,Hi)}}),z(ue,De)}});var Re=te(me,2);Kt(Re,{onclick:()=>Jt({action:"align",alignment:"left"},t),children:(ue,ge)=>{var De=Z3(),ke=ze(De);ei(ke,{name:"align-left"});var lt=te(ke,2);ti(lt,{children:(Ae,xi)=>{var Hi=Ht("Align left");z(Ae,Hi)}}),z(ue,De)}});var Be=te(Re,2);Kt(Be,{onclick:()=>Jt({action:"align",alignment:"center"},t),children:(ue,ge)=>{var De=M3(),ke=ze(De);ei(ke,{name:"align-center"});var lt=te(ke,2);ti(lt,{children:(Ae,xi)=>{var Hi=Ht("Align center");z(Ae,Hi)}}),z(ue,De)}});var Ne=te(Be,2);Kt(Ne,{onclick:()=>Jt({action:"align",alignment:"right"},t),children:(ue,ge)=>{var De=L3(),ke=ze(De);ei(ke,{name:"align-right"});var lt=te(ke,2);ti(lt,{children:(Ae,xi)=>{var Hi=Ht("Align right");z(Ae,Hi)}}),z(ue,De)}});var $t=te(Ne,2);Rh($t),z(K,pe)};Ot(F,K=>{P(A).alignable&&K(se)})}var Ze=te(F,2);{var We=K=>{var pe=D3(),me=ze(pe);Kt(me,{onclick:()=>Jt({action:"add",direction:"before"},t),children:(Ne,$t)=>{var ue=q3(),ge=ze(ue);ei(ge,{name:"add-before"});var De=te(ge,2);ti(De,{children:(ke,lt)=>{var Ae=Ht();Qt(()=>xn(Ae,`Add ${P(y)??""} ${P(y)==="row"?"above":"before"}`)),z(ke,Ae)}}),z(Ne,ue)}});var Re=te(me,2);Kt(Re,{onclick:()=>Jt({action:"add",direction:"after"},t),children:(Ne,$t)=>{var ue=W3(),ge=ze(ue);ei(ge,{name:"add-after"});var De=te(ge,2);ti(De,{children:(ke,lt)=>{var Ae=Ht();Qt(()=>xn(Ae,`Add ${P(y)??""} ${P(y)==="row"?"below":"after"}`)),z(ke,Ae)}}),z(Ne,ue)}});var Be=te(Re,2);Rh(Be),z(K,pe)};Ot(Ze,K=>{P(A).addable&&K(We)})}var ye=te(Ze,2);{var Me=K=>{var pe=I3(),me=ze(pe);{var Re=ue=>{Kt(ue,{onclick:()=>Jt({action:"move",direction:"backward"},t),children:(ge,De)=>{var ke=j3(),lt=ze(ke);{let xi=G(()=>`move-${P(y)==="row"?"up":"left"}`);ei(lt,{get name(){return P(xi)}})}var Ae=te(lt,2);ti(Ae,{children:(xi,Hi)=>{var xs=Ht();Qt(()=>xn(xs,`Move ${P(y)??""} ${P(y)==="row"?"up":"left"}`)),z(xi,xs)}}),z(ge,ke)}})};Ot(me,ue=>{(P(A).moveable==="backward"||P(A).moveable===!0)&&ue(Re)})}var Be=te(me,2);{var Ne=ue=>{Kt(ue,{onclick:()=>Jt({action:"move",direction:"forward"},t),children:(ge,De)=>{var ke=V3(),lt=ze(ke);{let xi=G(()=>`move-${P(y)==="row"?"down":"right"}`);ei(lt,{get name(){return P(xi)}})}var Ae=te(lt,2);ti(Ae,{children:(xi,Hi)=>{var xs=Ht();Qt(()=>xn(xs,`Move ${P(y)??""} ${P(y)==="row"?"down":"right"}`)),z(xi,xs)}}),z(ge,ke)}})};Ot(Be,ue=>{(P(A).moveable==="forward"||P(A).moveable===!0)&&ue(Ne)})}var $t=te(Be,2);Rh($t),z(K,pe)};Ot(ye,K=>{P(A).moveable!==!1&&K(Me)})}var st=te(ye,2);{var Dt=K=>{Kt(K,{onclick:()=>Jt({action:"duplicate"},t),children:(pe,me)=>{var Re=Y3(),Be=ze(Re);ei(Be,{name:"duplicate"});var Ne=te(Be,2);ti(Ne,{children:($t,ue)=>{var ge=Ht();Qt(()=>xn(ge,`Duplicate ${P(y)??""}`)),z($t,ge)}}),z(pe,Re)}})};Ot(st,K=>{P(A).duplicatable&&K(Dt)})}var Qe=te(st,2);{var Je=K=>{Kt(K,{onclick:()=>Jt({action:"clear"},t),children:(pe,me)=>{var Re=B3(),Be=ze(Re);ei(Be,{name:"clear"});var Ne=te(Be,2);ti(Ne,{children:($t,ue)=>{var ge=Ht();Qt(()=>xn(ge,`Clear ${P(y)??""}`)),z($t,ge)}}),z(pe,Re)}})};Ot(Qe,K=>{P(A).clearable&&K(Je)})}var bt=te(Qe,2);{var Et=K=>{Kt(K,{onclick:()=>Jt({action:"remove"},t),children:(pe,me)=>{var Re=N3(),Be=ze(Re);ei(Be,{name:"remove"});var Ne=te(Be,2);ti(Ne,{children:($t,ue)=>{var ge=Ht();Qt(()=>xn(ge,`Delete ${P(y)??""}`)),z($t,ge)}}),z(pe,Re)}})};Ot(bt,K=>{P(A).removable&&K(Et)})}z($,q)},$$slots:{default:!0}})},$$slots:{default:!0}})},u=G(()=>Z(t.menu));Ot(h,w=>{P(u)&&w(f)})}var d=te(h,2);$h(d,16,()=>i4,w=>w,(w,y)=>{{let k=G(()=>Rm(t.activeHandle?.handle,y)?t.activeHandle.state:void 0);AQ(w,{get of(){return y},get state(){return P(k)}})}});var O=te(d,2);{var m=w=>{x4(w)},p=G(()=>!t.interactive&&I(t.outline));Ot(O,w=>{P(p)&&w(m)})}var b=te(O,2);{var S=w=>{t3(w)},x=G(()=>t.selection.isAll());Ot(b,w=>{P(x)&&w(S)})}Ih(n,w=>t.wrapperElement=w,()=>t?.wrapperElement),Qt(w=>Ce(n,"data-select-all",w),[()=>no(t.selection.isAll())]),Wl("mouseover",n,w=>Q3(w,t)),Wl("mouseout",n,w=>k3(w,t)),Wl("pointerdown",n,w=>P3(w,t)),kh("dragover",n,w=>$3(w)),Wl("keydown",r,w=>d3(w,t)),kh("copy",r,w=>h3(w,t)),kh("cut",r,w=>f3(w,t)),kh("paste",r,w=>u3(w,t)),z(i,n),hr()}Dk(["mouseover","mouseout","pointerdown","keydown"]);var zm=class i extends Le{tableDescription;widgetElement;height;destroyWidgetElement;get estimatedHeight(){return this.height}coordsAt(e,t,n){let r=this.tableDescription.table.closestCellAtPosition(t),o=Bh(e,r);if(I(o))return null;let s=o.getBoundingClientRect();return{top:s.top,right:s.right,bottom:s.bottom,left:s.left}}toDOM(e){if(Z(this.widgetElement))return this.widgetElement;let{widgetElement:t,destroyWidgetElement:n}=this.create(e);return this.widgetElement=t,this.destroyWidgetElement=n,e.requestMeasure({read:()=>{this.height=t.getBoundingClientRect().height}}),t}destroy(e){this.destroyWidgetElement?.(),this.destroyWidgetElement=void 0,this.widgetElement=void 0,this.height=pQ}create(e){let t=Ul(e.dom).createElement("div");t.className="tbl-table-widget",t.tabIndex=-1,t.addEventListener("pointerdown",d=>{d?.target===t&&d.preventDefault()});let n=this.tableDescription,r=Bz(()=>{sf(()=>{let d=!n.table.text.eq(n.editorTableText),O=!hf(n.selection.value,n.editorSelectionValue);if(!d&&!O)return;let m;if(n.selection.isCell()){let{from:b}=n.table.cellSpan(n.selection.cell);m={anchor:n.from+b+n.selection.cellSection.anchor,head:n.from+b+n.selection.cellSection.head}}else n.selection.isAll()?m={anchor:n.from,head:n.to}:n.selection.isHidden()&&(m={anchor:n.from+1,head:n.from+1});let p=d?{from:n.from,to:n.to,insert:n.table.text}:void 0;n.markSynchronized(),e.dispatch({annotations:or("table.edit"),changes:p,selection:m})})}),{extensions:o,markdownConfig:s,globalKeyBindings:l,selectionType:a,lineWrapping:c}=wP(e.state),h=jk(F3,{target:t,props:{table:n.table,selection:n.selection,scrollElement:t,rootEditor:e,extensions:o,markdownConfig:s,globalKeyBindings:l,selectionType:a,lineWrapping:c,menuRootElement:Is(e,sP).dom,onUndo:()=>yc(e),onRedo:()=>il(e),onNavigate:d=>{e.dispatch({annotations:or("table.navigate"),selection:{anchor:d==="before"?n.from-1:n.to+1}}),e.focus()},onDelete:()=>{e.dispatch({annotations:or("table.delete"),changes:{from:n.from,to:n.to},selection:e.state.selection}),e.focus()}}}),f=()=>{Vk(h)},u=xq(t,({height:d})=>{this.height=d});return{widgetElement:t,destroyWidgetElement:ao(r,f,u)}}static of(e,t){return new i(e,t)}constructor(e,t){super(),this.tableDescription=e;let n=aW(t);if(Z(n)){let{widgetElement:r,destroyWidgetElement:o}=this.create(n);this.widgetElement=r,this.destroyWidgetElement=o,this.height=Sq(n,r)}else this.widgetElement=void 0,this.destroyWidgetElement=void 0,this.height=pQ}};function H3(i,e){return{widget:zm.of(i,e),block:!0,inclusive:!0}}function K3(i,e){return R.replace(H3(i,e))}function J3(i,e){let t=new Ue;for(let n of i)t.add(n.from,n.to,K3(n,e));return t.finish()}function eW(i){return xP(i)}function tW(i,e){return xP(i,e)}function xP(i,e=[]){let t=[];sL(B(i),o=>{DQ(o)&&t.push({from:i.doc.lineAt(o.from).from,to:i.doc.lineAt(o.to).to})});let n=[],r=[];for(let o of t){if(mL(e,o,GQ)){n.push(o);continue}let s=iW(o,i);tf(s)?n.push(o):r.push(...s)}return{spans:n,formatting:r,complete:P1(i)}}function iW(i,e){return[...nW(i,e),...rW(i,e)]}function nW(i,{doc:e,lineBreak:t}){return Hl({doc:e,lineBreak:t,span:i}).changes}function rW({from:i,to:e},{doc:t}){let n=t.slice(i,e),{text:r}=fm(n);return n.eq(r)?[]:[{from:i,to:e,insert:r}]}var oW={create(i){return Ah(i)},update(i,e){if(Eq(e))return Ah(e.state);if(!e.docChanged&&I(e.selection)&&i.complete)return i;let{tables:t,formatting:n,decorations:r}=i;if(!e.docChanged&&i.complete)return{tables:_Q(t,e),formatting:n,decorations:r.map(e.changes),complete:!0};if(Xq(e)||sW(e,t))return Ah(e.state);let o=_Q(t,e).map(c=>c.span),{complete:s,spans:l,formatting:a}=tW(e.state,o);return Kn(o,l,GQ)?{complete:s,tables:t,formatting:a,decorations:r.map(e.changes)}:Ah(e.state)},provide(i){return C.decorations.from(i,e=>e.decorations)}},vP=le.define(oW);function Ah(i){let{spans:e,formatting:t,complete:n}=eW(i),{doc:r,selection:o}=i,s=e.map(l=>$m.of({span:l,doc:r,selection:o}));return{complete:n,tables:s,formatting:t,decorations:J3(s,i)}}function sW(i,e){return!rg(i)&&e.some(t=>i.changes.touchesRange(t.from,t.to)!==!1)}function _Q(i,e){return hL(i,t=>t.applyTransaction(e))}var lW={create(){return{view:void 0}},update(i){return i}},hg=le.define(lW);function wP(i){return i.facet(um)}function lr(i){return i.field(vP)}function aW(i){return i.field(hg).view}function cW(i){let{handlePosition:e,selectionType:t,lineWrapping:n}=wP(i);return{...nf(window)?{"data-tbl-hoverable":""}:{},"data-tbl-theme-mode":i.facet(C.darkTheme)?"dark":"light","data-tbl-handle-position":e,"data-tbl-selection-type":t,"data-tbl-line-wrapping":n}}var hW=["undo","redo","select.undo","select.redo"];function fW(i){return hW.some(e=>i.isUserEvent(e))}function uW(i){return yP(i,"select.search")}function dW(i){return yP(i,"select")}function OW(i){return i.isUserEvent("delete.forward")}function pW(i){return i.isUserEvent("delete.backward")}function yP(i,e){return i.annotation(Pe.userEvent)===e}var mW=({state:i,view:e,transactions:t})=>{e.hasFocus||lr(i).tables.some(n=>n.containsSelection())||t.some(n=>fW(n)||uW(n)&&!mP(e))&&e.focus()},QP=D.define(),gW=new Map(Hk.map(i=>[i,QP.of(i)]));function kP(i){return gW.get(i)}var bW=(i,e)=>!e||!lr(i).tables.some(t=>t.containsSelection())?null:kP("table.focus"),SW=i=>{let{selection:e,startState:t,docChanged:n}=i;if(I(e)||n||!dW(i)||!Zh(e)||!Zh(t.selection))return i;let r=t.selection.main,o=e.main;for(let s of lr(t).tables){let l=s.from===o.head,a=s.to===o.head,c=s.from===r.head+1&&s.to===o.head-1,h=s.from===o.head+1&&s.to===r.head-1,f;if(l?f=s.table.firstCellSpan.from:c?f=s.table.firstCellSpan.to:(a||h)&&(f=s.table.lastCellSpan.to),Z(f))return[i,{annotation:or("table.navigate"),selection:VM({pos:s.from+f})}]}return i},xW=i=>{let{selection:e,startState:t}=i;if(I(e)||!Zh(e))return i;let n=t.selection.main;if(OW(i)){for(let r of lr(t).tables)if(n.head===r.from-1){let o=r.table.firstCellSpan.from;return[{selection:{anchor:r.from+o,head:r.from+o}}]}return i}else if(pW(i)){for(let r of lr(t).tables)if(n.head===r.to+1){let o=r.table.lastCellSpan.to;return[{selection:{anchor:r.from+o,head:r.from+o}}]}return i}else return i};function vW(i){return cS(i)>0||hS(i)>0}var wW=({state:i,docChanged:e,selectionSet:t,transactions:n,view:r})=>{if(!e&&!t&&vW(i)||n.some(a=>rg(a)))return;let{formatting:o}=lr(i);if(tf(o))return;let s=et.of(o,i.doc.length,i.lineBreak),l=i.selection.map(s);r.dispatch({annotations:or("table.format"),changes:s,selection:l})},yW=i=>{if(!i.docChanged||rg(i))return i;let e=i.changes,{tables:t}=lr(i.startState),n=[];for(let s of t)if(e.touchesRange(s.from-1,s.from)!==!1||e.touchesRange(s.to,s.to+1)!==!1){let l={from:e.mapPos(s.from,1),to:e.mapPos(s.to)};if(l.from>=l.to)continue;n.push(Hl({doc:i.newDoc,lineBreak:i.startState.lineBreak,span:l}).changes)}if(tf(n))return i;let r=et.of(n,i.changes.newLength,i.startState.lineBreak),o=i.newSelection.map(r);return[i,{annotation:or("table.correct"),changes:r,selection:o,sequential:!0}]};function QW(i,{anchor:e,head:t,goalColumn:n,bidiLevel:r}={}){return Q.range(e??i.anchor,t??i.head,n??i.goalColumn,r??i.bidiLevel??void 0)}var kW=i=>{let{selection:e,startState:t,docChanged:n}=i;if(I(e)||n||Zh(e))return i;let r=e.ranges.map(o=>{if(o.empty)return o;let s=lr(t).tables,l=ZQ(o.anchor,s),a=ZQ(o.head,s);return Z(l)||Z(a)?QW(o,{anchor:l,head:a}):o});return Kn(e.ranges,r,(o,s)=>o===s)?i:[i,{annotations:or("table.select"),selection:Q.create(r,e.mainIndex)}]};function ZQ(i,e){for(let t of e){let n=t.from,r=t.to,o=t.from+1,s=t.to-1;if(i===n||i===o)return n-1;if(i===r||i===s)return r+1}}var PW={"& .cm-tooltip.cm-tooltip-autocomplete:has(.cm-completionIcon-table)":{border:"1px solid var(--tbl-theme-menu-border-color)","box-shadow":"2px 2px 0 0 rgb(0 0 0 / 10%)","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)"},"& .cm-tooltip.cm-tooltip-autocomplete > ul:has(.cm-completionIcon-table)":{"min-width":"auto",display:"flex","flex-direction":"column","justify-content":"center",padding:"0.25em 0","line-height":1,"font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)",background:"var(--tbl-theme-menu-background)"},"& .cm-tooltip.cm-tooltip-autocomplete ul li[aria-selected]:has(.cm-completionIcon-table)":{color:"var(--tbl-theme-menu-hover-text-color)","&::before":{background:"var(--tbl-theme-menu-hover-background)"}},"& .cm-tooltip.cm-tooltip-autocomplete ul li:not([aria-selected]):has(.cm-completionIcon-table)":{color:"var(--tbl-theme-menu-text-color)"},"& .cm-tooltip.cm-tooltip-autocomplete ul li:not([aria-selected]):has(.cm-completionIcon-table), & .cm-tooltip.cm-tooltip-autocomplete ul li[aria-selected]:has(.cm-completionIcon-table)":{position:"relative",padding:"0.5em 0.75em",background:"var(--tbl-theme-menu-background)",display:"flex",gap:"0.75em","align-items":"center","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)","line-height":1,"&::before":{position:"absolute",height:"100%",width:"calc(100% - 0.5em)",left:"0.25em",top:0,content:'""',"pointer-events":"none"}},"& .cm-completionIcon.cm-completionIcon-table":{opacity:1,"mask-image":`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='14' width='12.25' viewBox='0 0 448 512'%3E%3C!--!Font Awesome Free v7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2026 Fonticons, Inc.--%3E%3Cpath d='M384 96l-128 0 0 128 128 0 0-128zm64 128l0 192c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96C0 60.7 28.7 32 64 32l320 0c35.3 0 64 28.7 64 64l0 128zM64 288l0 128 128 0 0-128-128 0zm128-64l0-128-128 0 0 128 128 0zm64 64l0 128 128 0 0-128-128 0z'/%3E%3C/svg%3E")`,"mask-position":"center","mask-repeat":"no-repeat",padding:0,background:"currentColor",position:"relative",width:"1em",height:"1em","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)","line-height":1},"& :has(.cm-completionIcon.cm-completionIcon-table) .cm-completionLabel":{position:"relative"}},$W={'&[data-tbl-handle-position="inside"] .tbl-table-widget':{"padding-left":"6px","margin-left":0},".tbl-table-widget":{contain:"paint","padding-top":"16px","padding-right":"16px","padding-bottom":"16px","padding-left":"16px","margin-left":"-10px","overflow-x":"auto","overflow-y":"hidden","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}},"&.cm-editor .cm-content div.tbl-table-widget::selection, & .cm-content div.tbl-table-widget ::selection, & .cm-content div.tbl-table-widget:focus::selection, & .cm-content div.tbl-table-widget :focus::selection":{"background-color":"transparent !important","caret-color":"transparent !important"}},CW={".cm-tooltip.tbl-menu-tooltip":{border:"none","user-select":"none","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}}},TW={".tbl-blocking-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"transparent",width:"100%",height:"100%"}},RW={"& .cm-content div.tbl-table-widget .tbl-cell-editor ::selection, & .cm-content div.tbl-table-widget .tbl-cell-editor :focus::selection":{"background-color":"Highlight !important","caret-color":"initial !important"},"&[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content":{"caret-color":"transparent !important"},"&[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content ::selection, &[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content :focus::selection":{"background-color":"transparent !important","caret-color":"transparent !important"},"&[data-tbl-line-wrapping='wrap'] .tbl-cell-editor .cm-editor .cm-content":{"word-break":"normal","overflow-wrap":"break-word"},".tbl-cell-editor":{height:"100%"},".tbl-cell-editor .cm-editor":{margin:0,padding:0,outline:"none",height:"100%",background:"unset",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-scroller":{margin:0,padding:0,overflow:"hidden","line-height":1.5,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-content":{margin:0,padding:"7px 9px","line-height":1.5,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-line":{margin:0,padding:"0 1px","line-height":1.5,"touch-action":"none","font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"}},AW={".tbl-cell":{"box-sizing":"content-box",position:"relative","vertical-align":"top","background-color":"var(--tbl-row-background)",padding:0,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)","min-width":"calc(4ch + 20px)",height:"inherit","user-select":"none",border:"none","scroll-margin-right":"1px","scroll-margin-left":"1px","&:first-child":{"scroll-margin-left":"16px"},"&:last-child":{"scroll-margin-right":"16px"},'&[align="left"]':{"text-align":"left"},'&[align="center"]':{"text-align":"center"},'&[align="right"]':{"text-align":"right"},'&[data-border~="top"]':{"border-top":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="right"]':{"border-right":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="bottom"]':{"border-bottom":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="left"]':{"border-left":"1px solid var(--tbl-theme-border-color)"},'&[data-state="moving"]':{"z-index":200,"background-color":"color-mix(in srgb, var(--tbl-row-background), transparent 15%)"},'&[data-state="shiftable"]':{transform:"translate3d(0, 0, 0)",transition:"transform 150ms ease"},"&[data-outline]":{"&::after":{display:"block",position:"absolute",top:"-1px",left:"-1px",border:"none",width:"calc(100% + 2px)",height:"calc(100% + 2px)","pointer-events":"none",content:'""'},'&[data-outline~="top"]::after':{"border-top":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="right"]::after':{"border-right":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="bottom"]::after':{"border-bottom":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="left"]::after':{"border-left":"2px solid var(--tbl-theme-outline-color)"}}},".tbl-header-cell:not([align])":{"text-align":"var(--tbl-style-default-header-alignment)"}},XW={'&[data-tbl-line-wrapping="wrap"] .tbl-cell-view':{"word-break":"normal","overflow-wrap":"break-word"},'&[data-tbl-line-wrapping="nowrap"] .tbl-cell-view':{"white-space":"pre"},".tbl-cell-view":{margin:0,outline:"none",padding:"7px 10px",height:"100%","line-height":1.5,"white-space-collapse":"break-spaces","font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)","&[data-hidden]":{display:"none"}},".tbl-cell-view [data-br]":{"white-space":"pre"}},EW={".tbl-handle":{display:"flex",position:"absolute","justify-content":"center","align-items":"center","z-index":200,transition:"opacity 150ms ease 50ms","touch-action":"none"},".tbl-handle[data-hover], .tbl-handle[data-active]":{"--tbl-handle-opacity":1},'&:not([data-tbl-hoverable]) .tbl-handle[data-type="border"], &:not([data-tbl-hoverable]) .tbl-handle[data-type="table"]':{display:"none"},'.tbl-handle[data-type="border"]':{"background-color":"var(--tbl-theme-border-hover-color)"},'.tbl-handle[data-type="border"][data-active]':{"background-color":"var(--tbl-theme-border-active-color)"},'.tbl-handle[data-type="border"][data-toggle]':{transition:"none"},'.tbl-handle[data-type="border"][data-location="top"]':{top:"-1px",left:"-1px",width:"calc(100% + 2px)",height:"2px"},'.tbl-handle[data-type="border"][data-location="left"]':{top:"-1px",left:"-1px",width:"2px",height:"calc(100% + 2px)"},'.tbl-handle[data-type="border"][data-location="col"]':{top:"-1px",right:"-2px",width:"3px",height:"calc(100% + 2px)"},'.tbl-handle[data-type="border"][data-location="row"]':{bottom:"-2px",left:"-1px",width:"calc(100% + 2px)",height:"3px"},'.tbl-handle[data-type="table"]':{"box-sizing":"content-box",color:"var(--tbl-theme-border-hover-color)","background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)"},'.tbl-handle[data-type="table"][data-location="right"]':{top:0,left:"100%",width:"15px",height:"calc(100% - 2px)",border:"1px solid var(--tbl-theme-border-color)","border-left":"none","&::before":{position:"absolute",top:"-1px",left:"-2px",width:"2px",height:"calc(100% + 2px)",content:'""'},"&::after":{position:"absolute","z-index":366,top:"-1px",left:0,content:'""',width:"calc(100% + 1px)",height:"calc(100% + 2px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom-right"]':{left:"calc(100% - 1px)",top:"calc(100% - 1px)","z-index":250,width:"15px",height:"15px",border:"1px solid var(--tbl-theme-border-color)","border-top-style":"dashed","border-left-style":"dashed","&::after":{position:"absolute","z-index":366,top:"-1px",left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 2px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom"]':{top:"100%",left:"0",width:"calc(100% - 2px)",height:"15px",border:"1px solid var(--tbl-theme-border-color)","border-top":"none","&::before":{position:"absolute",top:"-2px",left:"-1px",width:"calc(100% + 2px)",height:"2px",content:'""'},"&::after":{position:"absolute","z-index":366,top:0,left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 1px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="bottom"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"--tbl-handle-opacity":1},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"]':{"border-bottom":"none"},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="bottom"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"border-right":"none"},'.tbl-handle[data-type="table"][data-active], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)",color:"var(--tbl-theme-border-active-color)"},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"]':{"box-sizing":"content-box",transition:"none","z-index":300,color:"var(--tbl-theme-border-hover-color)",border:"1px solid transparent","&:hover":{"border-color":"var(--tbl-theme-border-color)","background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)"},"&[data-active]":{"background-color":"var(--tbl-theme-outline-color)","border-color":"var(--tbl-theme-outline-color)",color:"#ffffff"}},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"][data-location="row"]':{top:"-1px",left:"-17px",width:"15px",height:"100%","border-right":"none"},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"][data-location="col"]':{top:"-17px",left:"-1px",width:"100%",height:"15px","border-bottom":"none","&:hover::after":{position:"absolute","z-index":366,top:"-1px",left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 1px)","background-color":"var(--tbl-overlay)"}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"]':{transition:"none","z-index":300,color:"var(--tbl-theme-border-hover-color)","&:hover":{color:"var(--tbl-theme-border-active-color)"},"&[data-active]":{color:"var(--tbl-theme-outline-color)"}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"][data-location="row"]':{top:"calc(50% - 13px)",left:"-1px",width:"3px",height:"26px","border-top":"4px solid var(--tbl-row-background)","border-bottom":"4px solid var(--tbl-row-background)","background-color":"var(--tbl-row-background)","&:hover::after, &[data-active]::after":{position:"absolute",top:"-6px",left:0,"box-sizing":"content-box","border-top":"2px solid transparent","border-bottom":"2px solid transparent",width:"calc(100% + 6px)",height:"calc(100% + 8px)",content:'""'}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"][data-location="col"]':{top:"-1px",left:"calc(50% - 11.5px)",width:"23px",height:"3px","border-right":"4px solid var(--tbl-row-background)","border-left":"4px solid var(--tbl-row-background)","background-color":"var(--tbl-row-background)","&:hover::after, &[data-active]::after":{position:"absolute",top:0,left:"-6px","box-sizing":"content-box","border-right":"2px solid transparent","border-left":"2px solid transparent",width:"calc(100% + 8px)",height:"calc(100% + 6px)",content:'""'}},".tbl-handle-grip":{"pointer-events":"none","z-index":333}},_W={".tbl-menu-item-icon":{"z-index":200,width:"1em",height:"1em","pointer-events":"none","font-size":"var(--tbl-style-menu-font-size)"}},ZW={".tbl-menu-item-text":{"z-index":200,"pointer-events":"none","user-select":"none","font-size":"var(--tbl-style-menu-font-size)"}},MW={".tbl-menu-item":{display:"flex",position:"relative","align-items":"center",gap:"0.75em",padding:"0.5em 0.75em",color:"var(--tbl-theme-menu-text-color)","user-select":"none","line-height":1,"font-size":"var(--tbl-style-menu-font-size)","&:active":{cursor:"pointer",color:"var(--tbl-theme-menu-hover-text-color)","&::after":{"background-color":"var(--tbl-theme-menu-hover-background)"}},"&::after":{position:"absolute",left:"0.25em",width:"calc(100% - 0.5em)",height:"100%",content:'""'}},"&[data-tbl-hoverable] .tbl-menu-item:hover":{cursor:"pointer",color:"var(--tbl-theme-menu-hover-text-color)","&::after":{"background-color":"var(--tbl-theme-menu-hover-background)"}}},LW={".tbl-menu-separator":{margin:"0.25em 0.5em","background-color":"var(--tbl-theme-menu-border-color)",height:"1px","font-size":"var(--tbl-style-menu-font-size)"}},zW={".tbl-menu":{position:"absolute",top:0,left:0,"z-index":900,"box-shadow":"2px 2px 0 0 rgb(0 0 0 / 10%)",border:"1px solid var(--tbl-theme-menu-border-color)","background-color":"var(--tbl-theme-menu-background)",padding:"0.25em 0",width:"max-content","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)"}},qW={".tbl-select-all-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"var(--tbl-overlay)",width:"100%",height:"100%","pointer-events":"none"}},WW={"& .tbl-table-wrapper[data-select-all]":{"--tbl-select-all-overlay":"var(--tbl-theme-select-all-blur-overlay)"},"&.cm-focused .tbl-table-wrapper[data-select-all]":{"--tbl-select-all-overlay":"var(--tbl-theme-select-all-focus-overlay)"},".tbl-table-wrapper":{"--tbl-overlay":"var(--tbl-select-all-overlay, transparent)",position:"relative",width:"fit-content","white-space-collapse":"collapse","touch-action":"none"},".tbl-table":{"border-collapse":"separate","border-spacing":0,overflow:"visible","touch-action":"none","&:focus-visible":{outline:"none"}},".tbl-table-head, .tbl-table-body":{height:"100%"},".tbl-table-row":{height:0},"@supports (-moz-appearance: none) /* TableTheme */":{".tbl-table-row":{height:"fit-content"}},".tbl-table-head .tbl-table-row":{"--tbl-row-background":"var(--tbl-theme-header-row-background)"},".tbl-table-body .tbl-table-row:nth-child(2n + 1)":{"--tbl-row-background":"var(--tbl-theme-even-row-background)"},".tbl-table-body .tbl-table-row:nth-child(2n)":{"--tbl-row-background":"var(--tbl-theme-odd-row-background)"}},DW={...PW,...CW,...$W,...WW,...TW,...AW,...RW,...XW,...EW,...zW,...MW,..._W,...ZW,...LW,...qW},jW=i=>{let e=i.effects.find(t=>t.is(QP))?.value;return Z(e)?{annotations:or(e)}:null},VW=i=>{let e=i.annotation(ng);return Z(e)?[kP(Cq(e))]:[]},qm=class i{static of(e){return e.state.field(hg).view=e,new i}constructor(){}};function IW(i){return[um.of(i),vP,hg,ce.define(e=>qm.of(e)),C.editorAttributes.compute([um,C.darkTheme],cW),C.baseTheme(DW),C.theme("light"in i.theme?{':where(:root:has(&[data-tbl-theme-mode="light"]))':i.theme.light.props,':where(:root:has(&[data-tbl-theme-mode="dark"]))':i.theme.dark.props}:{":where(:root:has(&))":i.theme.props}),C.theme({":where(:root:has(&))":i.style.props}),jd.of(VW),yr.of(sP),J.transactionExtender.of(jW),J.transactionFilter.of(yW),J.transactionFilter.of(xW),J.transactionFilter.of(SW),J.transactionFilter.of(kW),C.updateListener.of(wW),C.updateListener.of(mW),C.clipboardInputFilter.of(WL),C.focusChangeEffect.of(bW)]}function PP(i){return IW(zQ(i))}function YW(i,e){if(!I(i))for(let t of i)e(t)}function BW(i,e){I(i)||e(i)}function $P(i,e,t){if(!Number.isInteger(i)||i<=0)throw new Error(t);if(!Number.isInteger(e)||e<=0)throw new Error(t)}function NW({pos:i,doc:e,lineBreak:t,rows:n,cols:r}){let[o,...s]=Jn(`${"| ".repeat(r)}|`,{count:n}),l=`${"| - ".repeat(r)}|`,{before:a,after:c}=Hl({doc:e,lineBreak:t,span:{from:i-1,to:i}}),h=`${a?.insert??""}${[o,l,...s].join(t)}${c?.insert??""}`;return{label:`${n}\xD7${r} table`,type:"table",apply:(f,u)=>{f.dispatch({annotations:hl.of(u),changes:{from:i-1,to:i,insert:h},selection:{anchor:i+1+(a?.count??0)}})}}}var UW=[{rows:2,cols:2},{rows:3,cols:3},{rows:4,cols:4}];function GW(i){let e=i?.options??UW;return({state:t,pos:n})=>{let r=t.doc.lineAt(n);if(n!==r.from+1||r.length!==1||r.text.slice(0,1)!=="|")return null;let{doc:o,lineBreak:s}=t;return{from:n,options:e.map(({rows:l,cols:a})=>NW({pos:n,doc:o,lineBreak:s,rows:l,cols:a}))}}}function CP(i){return YW(i?.options,({rows:e,cols:t})=>{$P(e,t,"options[].{ rows, cols } must be positive integers")}),GW(i)}var FW={rows:2,cols:2};function HW(i){let{rows:e,cols:t}=i?.size??FW;return({state:n,dispatch:r})=>{let{anchor:o,head:s}=n.selection.main,{from:l,to:a}=o<=s?{from:o,to:s}:{from:s,to:o},{before:c,after:h}=Hl({doc:n.doc,lineBreak:n.lineBreak,span:{from:l,to:a}}),[f,...u]=Jn(`${"| ".repeat(t)}|`,{count:e}),d=`${"| - ".repeat(t)}|`,O=`${c?.insert??""}${[f,d,...u].join(n.lineBreak)}${h?.insert??""}`;return r(n.update({changes:{from:l,to:a,insert:O},selection:{anchor:l+2+(c?.count??0)}})),!0}}function TP(i){return BW(i?.size,({rows:e,cols:t})=>{$P(e,t,"size.{rows, cols} must be positive integers")}),HW(i)}var uo=16,KW="50rem",JW="88%",fg="0px",eD=[i1(),n1(),Ib(),lS(),q1(),Vb(),J.allowMultipleSelections.of(!0),A1(),qo(j1,{fallback:!0}),B1(),ax(),xO(),Bb(),Nb(),Yb(),IS(),Yt.of([...fx,...Bd,...tO,...Id,...M1,...vO,...gx])],Cg=[1.4,1.2,1.15,1.1,1.04,1],GP=1.6,FP=12/uo,df=1.3,Of=1.5,HP=13/uo,tD=12/uo,RP=22/uo;function oa(i){return`${i/HP}em`}var gf={compact:1.7,writing:2},AP=new So;function XP(i){let e=i?gf.writing:gf.compact;return C.theme({"&":{"--md-line-ratio":String(e),"--md-line-pad-y":i?"4px":"2px"}})}function fo(i){return`${i/FP}em`}function EP(i){let e=Cg[i-1]??1;return fo(e*GP)}var pg="\u037Cx";function iD(){let i={};return Cg.forEach((e,t)=>{i[`.cm-line.cm-md-h${t+1}`]={fontSize:`${e}em`,fontWeight:"700",lineHeight:`${GP} !important`},i[`.cm-line.cm-md-h${t+1} .${pg}`]={fontFamily:"inherit"},i[`.cm-lineNumbers .cm-gutterElement.cm-gutter-h${t+1}`]={lineHeight:`calc(${EP(t+1)} + 2 * var(--md-line-pad-y, 2px))`},i[`.cm-ai-gutter .cm-gutterElement.cm-gutter-h${t+1}`]={"--md-gutter-line-height":EP(t+1)}}),i}var nD=C.theme({"&":{height:"100%",color:"var(--text)",backgroundColor:"var(--card)",fontSize:`${uo}px`},".cm-foldGutter":{display:"none !important"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"var(--md-editor-font-family, var(--finch-font-mono))",overflowX:"hidden",overflowY:"auto"},".cm-content":{padding:"48px 0",caretColor:"var(--text)",minHeight:"100%",minWidth:"0",position:"relative"},".cm-content:not(.tbl-table-widget .cm-content)":{boxSizing:"border-box",paddingInline:fg,width:`calc(${KW} + 2 * ${fg})`,maxWidth:`calc(${JW} + 2 * ${fg})`,marginInline:"auto",flexGrow:"0",flexShrink:"1"},".cm-content:not(.tbl-table-widget .cm-content)::before":{content:'""',position:"absolute",top:"0",bottom:"0",left:"-100%",right:"-100%"},".cm-line:not(.tbl-table-widget .cm-line)":{boxSizing:"border-box",position:"relative",width:"100%",paddingTop:"var(--md-line-pad-y, 2px)",paddingBottom:"var(--md-line-pad-y, 2px)",lineHeight:`calc(var(--md-line-ratio, ${gf.compact}) * 1em)`},".cm-content > .cm-line:has(+ .tbl-table-widget)":{height:"0 !important",minHeight:"0 !important",paddingTop:"0 !important",paddingBottom:"0 !important",lineHeight:"0 !important",overflow:"hidden"},".cm-content > .tbl-table-widget":{boxSizing:"border-box",width:"auto !important",maxWidth:"100% !important",marginInline:"auto !important",padding:"12px 16px 12px 6px !important"},".tbl-table-widget .tbl-table-wrapper":{maxWidth:"100%"},".tbl-table-widget .tbl-table":{width:"auto !important",maxWidth:"100%"},".tbl-cell-editor .cm-editor .cm-line":{fontSize:"0.9rem",fontFamily:"var(--md-editor-font-family, var(--finch-font-mono))"},".tbl-cell-view":{fontSize:"0.9rem",fontFamily:"var(--md-editor-font-family, var(--finch-font-mono))"},".tbl-table-widget .tbl-cell[data-selected]":{backgroundColor:"color-mix(in srgb, var(--accent) 15%, var(--tbl-row-background))"},".tbl-table-widget .tbl-cell[data-outline]::after":{backgroundColor:"color-mix(in srgb, var(--accent) 7%, transparent)"},...iD(),".cm-md-bullet":{display:"inline-block",color:"var(--accent)",fontWeight:"700",textAlign:"center",fontFamily:"monospace"},[`.${pg}`]:{fontFamily:"monospace"},".tbl-cell-view .cm-md-delimiter":{display:"none"},".tbl-cell-view .cm-md-strong":{fontWeight:"700"},".tbl-cell-view .cm-md-emphasis":{fontStyle:"italic"},".tbl-table-widget .tbl-table-head .tbl-cell-view, .tbl-table-widget .tbl-table-head .tbl-cell-editor .cm-content":{color:"var(--accent)"},".cm-md-inline-code":{padding:"0.08em 0.32em",borderRadius:"5px",color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--text) 9%, transparent)",fontFamily:"var(--finch-font-mono)",fontSize:"0.8em",position:"relative",top:"-0.1em"},".cm-md-mark":{backgroundColor:"color-mix(in srgb, #ffd60a 40%, transparent)",borderRadius:"3px",padding:"0 0.12em",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone"},".cm-md-image-wrapper":{boxSizing:"border-box",display:"inline-flex",flexDirection:"column",maxWidth:"100%",margin:"4px 2px",lineHeight:"1.4",verticalAlign:"bottom",outline:"none"},".cm-editor:has(.cm-md-image-selected) .cm-cursor":{display:"none !important"},".cm-md-image-wrapper.cm-md-image-selected img":{outline:"2px solid var(--accent)",outlineOffset:"2px",borderRadius:"10px"},".cm-md-image-frame":{position:"relative",display:"inline-block",width:"fit-content",maxWidth:"100%",alignSelf:"flex-start",lineHeight:"0"},".cm-md-image-wrapper img":{display:"block",maxHeight:"80vh",maxWidth:"100%",width:"auto",height:"auto",borderRadius:"8px",cursor:"zoom-in"},".cm-md-image-resize-handle":{position:"absolute",right:"6px",bottom:"6px",width:"12px",height:"12px",boxSizing:"border-box",borderRight:"1.75px solid var(--accent)",borderBottom:"1.75px solid var(--accent)",borderRadius:"0 0 4px 0",cursor:"nwse-resize",touchAction:"none",opacity:"0",pointerEvents:"none",transition:"opacity 120ms ease"},".cm-md-image-selected .cm-md-image-resize-handle, .cm-md-image-resizing .cm-md-image-resize-handle":{opacity:"1",pointerEvents:"auto"},".cm-md-image-resizing":{userSelect:"none"},".cm-md-image-caption":{display:"block",marginTop:"6px",fontSize:"0.82em",lineHeight:"1.4",color:"color-mix(in srgb, var(--muted) 80%, transparent)",outline:"none",cursor:"text",whiteSpace:"pre-wrap",wordBreak:"break-word"},".cm-md-image-caption:empty::before":{content:"attr(data-placeholder)",color:"color-mix(in srgb, var(--muted) 80%, transparent)"},".cm-md-image-caption:not(:empty)":{color:"var(--text)"},".cm-md-link":{color:"var(--accent) !important",textDecoration:"underline",textDecorationColor:"color-mix(in srgb, var(--accent) 55%, transparent)",textUnderlineOffset:"0.16em",cursor:"pointer"},".cm-md-link:hover":{textDecorationColor:"var(--accent)"},".cm-line.cm-md-quote":{borderLeft:"2px solid var(--border)",paddingLeft:"8px"},[`.cm-line.cm-md-quote .${pg}`]:{fontFamily:"inherit"},".cm-line.cm-md-list-line":{paddingLeft:"2ch"},".cm-line.cm-md-code-line":{color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--text) 8%, transparent)",lineHeight:oa(df)+" !important",fontFamily:"var(--finch-font-mono)",paddingTop:"0 !important",paddingBottom:"0 !important",width:"99% !important",paddingInline:"24px","--cm-ai-hint-inline-offset":"26px",fontSize:`${HP}em !important`,marginInline:"auto"},".cm-line.cm-md-code-line span":{fontSize:oa(tD)+" !important"},".cm-line.cm-md-code-open":{borderRadius:"8px 8px 0 0",height:oa(RP),paddingTop:"2px",paddingInline:"12px",lineHeight:oa(Of)+" !important"},".cm-line.cm-md-code-close":{borderRadius:"0 0 8px 8px",height:oa(RP),paddingInline:"12px"},".cm-md-code-fence-empty":{opacity:"0"},".cm-md-code-copy":{float:"right",height:"16px",margin:"3px -9px",padding:"0 4px",border:"0px",borderRadius:"6px",color:"var(--muted)",backgroundColor:"color-mix(in srgb, var(--card) 88%, transparent)",font:"10px var(--finch-font-mono)",cursor:"pointer"},".cm-md-code-copy:hover":{color:"var(--text)",backgroundColor:"var(--card)"},".cm-md-hr":{display:"inline-block",width:"100%",height:"1px",verticalAlign:"middle",backgroundColor:"var(--border)",cursor:"text"},".cm-line.cm-md-gap":{},".cm-line.cm-md-gap-heading":{},".cm-selectionMatch":{backgroundColor:"transparent !important"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--text)"},".cm-gutters":{color:"var(--muted)",backgroundColor:"var(--card)",borderRight:"0px",fontSize:`${12/uo}em`,"--md-gutter-line-height":`calc(var(--md-line-ratio, ${gf.compact}) * 1em / ${FP})`},".cm-content .cm-widgetBuffer":{verticalAlign:"top"},".cm-gutterElement":{padding:"0px 8px 0 10px"},".cm-lineNumbers .cm-gutterElement":{padding:"0 5px 0 8px",lineHeight:"calc(var(--md-gutter-line-height, 32px) + 2 * var(--md-line-pad-y, 2px))",color:"color-mix(in srgb, var(--muted) 35%, transparent)",fontFamily:"var(--finch-font-mono)",fontSize:"inherit"},".cm-lineNumbers .cm-gutterElement.cm-gutter-code-line":{lineHeight:fo(df)},".cm-lineNumbers .cm-gutterElement.cm-gutter-code-open":{lineHeight:fo(Of)},".cm-gutters .cm-ai-gutter":{width:"22px"},".cm-ai-gutter .cm-gutterElement":{position:"relative",padding:"0","--md-ai-row-height":"calc(var(--md-gutter-line-height, 32px) + 2 * var(--md-line-pad-y, 2px))",color:"var(--accent)"},".cm-ai-gutter .cm-gutterElement.cm-gutter-code-line":{"--md-gutter-line-height":fo(df),"--md-ai-row-height":fo(df)},".cm-ai-gutter .cm-gutterElement.cm-gutter-code-open":{"--md-gutter-line-height":fo(Of),"--md-ai-row-height":fo(Of)},".cm-ai-working-mark":{position:"absolute",inset:"0"},".cm-ai-working-spinner":{position:"absolute",top:"0",left:"0",right:"0",height:"var(--md-ai-row-height, 32px)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},".cm-ai-working-spinner:hover svg":{animation:"none"},".cm-ai-working-spinner:focus-visible":{outline:"1px solid var(--accent)",outlineOffset:"-1px",borderRadius:"3px"},".cm-ai-gutter svg":{width:"13px",height:"13px",animation:"cm-ai-spin 1s linear infinite"},".cm-ai-added-line":{position:"absolute",top:"0",left:"0",right:"0",height:"var(--md-ai-row-height, 32px)",display:"flex",justifyContent:"center"},".cm-ai-added-dot":{width:"6px",height:"6px",marginTop:"calc((var(--md-ai-row-height, 32px) - 6px) / 2 - 1px)",borderRadius:"50%",backgroundColor:"#35a854",boxShadow:"0 0 0 2px color-mix(in srgb, #35a854 16%, transparent)"},".cm-ai-working-rail":{position:"absolute",top:"0",bottom:"0",left:"50%",width:"1.5px",marginLeft:"-0.75px",borderRadius:"1px",backgroundColor:"var(--accent)",opacity:"0.45"},".cm-ai-working-rail.cm-ai-working-rail-below":{top:"calc(var(--md-ai-row-height, 32px) / 2 + 6.5px)"},".cm-ai-working-corner":{position:"absolute",top:"0",left:"50%",width:"6px",height:"calc(var(--md-ai-row-height, 32px) / 2)",marginLeft:"-0.75px",borderLeft:"1.5px solid var(--accent)",borderBottom:"1.5px solid var(--accent)",borderBottomLeftRadius:"5px",opacity:"0.45"},".cm-ai-hint-line::after":{content:'var(--cm-ai-hint, "")',color:"var(--muted)",opacity:"0.5",pointerEvents:"none",userSelect:"none",position:"absolute",top:"0",bottom:"0",left:"var(--cm-ai-hint-inline-offset, 10px)",display:"flex",alignItems:"center",whiteSpace:"nowrap",wordBreak:"keep-all",overflowWrap:"normal"},".cm-ai-hint-code-line::after":{content:'var(--cm-ai-hint-code, "")'},".cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--text) 7%, transparent)",boxShadow:["-25vw 0 color-mix(in srgb, var(--text) 7%, transparent)","25vw 0 color-mix(in srgb, var(--text) 7%, transparent)"].join(", ")},".cm-activeLineGutter":{color:"var(--text) !important",backgroundColor:"color-mix(in srgb, var(--text) 7%, transparent)"},".cm-line:not(.cm-activeLine)":{opacity:"var(--md-focus-opacity, 1)"},".tbl-table-widget .tbl-cell":{opacity:"var(--md-focus-opacity, 1)"},".tbl-table-widget .tbl-cell[data-selected], .tbl-table-widget .tbl-cell[data-selected] .cm-line":{opacity:"1"},"& .cm-content ::selection, & .cm-content::selection":{backgroundColor:"color-mix(in srgb, var(--accent) 34%, transparent)"},"& .cm-content ::-moz-selection, & .cm-content::-moz-selection":{backgroundColor:"color-mix(in srgb, var(--accent) 34%, transparent)"},".cm-panels":{color:"var(--text)",backgroundColor:"var(--card)",borderTop:"none"},".cm-panel.cm-search":{padding:"6px 30px 7px 8px",fontSize:"12px",color:"var(--text)",backgroundColor:"var(--card)",borderBottom:"1px solid var(--border)",boxShadow:"0 2px 10px rgba(0,0,0,.14)"},".cm-panel.cm-search .cm-textfield":{width:"140px",marginRight:"6px",padding:"3px 7px",border:"1px solid var(--border)",borderRadius:"6px",backgroundColor:"var(--bg)",color:"var(--text)",fontFamily:"var(--finch-font-mono, monospace)",fontSize:"12px",outline:"none",transition:"border-color .12s ease, box-shadow .12s ease"},".cm-panel.cm-search .cm-textfield:focus":{borderColor:"var(--accent)",boxShadow:"0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent)"},".cm-panel.cm-search .cm-textfield::placeholder":{color:"color-mix(in srgb, var(--muted) 65%, transparent)"},".cm-panel.cm-search .cm-button":{marginRight:"4px",padding:"3px 9px",border:"1px solid var(--border)",borderRadius:"6px",backgroundImage:"none",backgroundColor:"color-mix(in srgb, var(--text) 4%, transparent)",color:"var(--text)",fontSize:"12px",fontWeight:"500",cursor:"pointer",transition:"background-color .12s ease, border-color .12s ease"},".cm-panel.cm-search .cm-button:hover":{backgroundImage:"none",backgroundColor:"color-mix(in srgb, var(--text) 9%, transparent)",borderColor:"color-mix(in srgb, var(--text) 22%, transparent)"},".cm-panel.cm-search .cm-button:active":{backgroundImage:"none",backgroundColor:"color-mix(in srgb, var(--accent) 18%, transparent)",borderColor:"var(--accent)"},".cm-panel.cm-search label":{display:"inline-flex",alignItems:"center",gap:"4px",marginRight:"10px",color:"var(--muted)",fontSize:"11.5px",whiteSpace:"nowrap",cursor:"pointer"},".cm-panel.cm-search input[type=checkbox]":{width:"13px",height:"13px",margin:"0",accentColor:"var(--accent)",cursor:"pointer"},".cm-panel.cm-search [name=close]":{position:"absolute",top:"5px",right:"6px",width:"20px",height:"20px",lineHeight:"1",padding:"0",border:"1px solid transparent",borderRadius:"5px",backgroundColor:"transparent",color:"var(--muted)",fontSize:"15px",cursor:"pointer"},".cm-panel.cm-search [name=close]:hover":{color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--text) 8%, transparent)",borderColor:"var(--border)"},".cm-editor .cm-content .cm-searchMatch":{backgroundColor:"color-mix(in srgb, var(--accent) 26%, transparent)",outline:"1px solid color-mix(in srgb, var(--accent) 38%, transparent)",borderRadius:"2px"},".cm-editor .cm-content .cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"color-mix(in srgb, var(--accent) 48%, transparent)",outline:"1px solid var(--accent)"},".cm-tooltip":{color:"var(--text)",backgroundColor:"var(--card)",border:"1px solid var(--border)"},".cm-tooltip.cm-tooltip-autocomplete":{borderRadius:"10px",padding:"5px",boxShadow:"0 2px 8px rgba(0,0,0,.12)",overflow:"hidden"},".cm-tooltip.cm-tooltip-autocomplete > ul":{minWidth:"188px",fontFamily:"var(--finch-font-body, system-ui)",fontSize:"13px"},".cm-tooltip.cm-tooltip-autocomplete > ul > li":{display:"flex",alignItems:"center",gap:"0",padding:"4px 7px",borderRadius:"6px"},".cm-tooltip-autocomplete > ul > li[aria-selected]":{color:"var(--text)",backgroundColor:"var(--finch-bg-active, color-mix(in srgb, var(--text) 10%, transparent))"},".cm-tooltip-autocomplete .cm-completionLabel":{flex:"1"},".cm-tooltip-autocomplete .cm-completionDetail":{marginLeft:"auto",color:"var(--muted)",fontStyle:"normal",fontSize:"0.86em"},".cm-tooltip-autocomplete .cm-md-completion-icon":{flex:"none",width:"16px",height:"16px",paddingRight:"8px",boxSizing:"content-box",color:"var(--muted)",opacity:"0.82"}}),rD=[dt.of({name:"JavaScript",alias:["js","mjs","cjs"],extensions:["js","mjs","cjs"],support:zr()}),dt.of({name:"JSX",alias:["jsx"],extensions:["jsx"],support:zr({jsx:!0})}),dt.of({name:"TypeScript",alias:["ts"],extensions:["ts"],support:zr({typescript:!0})}),dt.of({name:"TSX",alias:["tsx"],extensions:["tsx"],support:zr({jsx:!0,typescript:!0})}),dt.of({name:"JSON",alias:["json","json5"],extensions:["json"],support:Sw()}),dt.of({name:"CSS",alias:["css"],extensions:["css"],support:oh()}),dt.of({name:"HTML",alias:["html","htm","xml","svg"],extensions:["html"],support:lh()}),dt.of({name:"Python",alias:["python","py"],extensions:["py"],support:zw()}),dt.of({name:"SQL",alias:["sql"],extensions:["sql"],support:ey()}),dt.of({name:"YAML",alias:["yaml","yml"],extensions:["yaml","yml"],support:py()}),dt.of({name:"Shell",alias:["bash","sh","shell","zsh","console"],extensions:["sh"],support:new Ie(pc.define(xy))})],_P=Mo.define([{tag:g.heading,color:"var(--accent)",fontWeight:"700"},{tag:g.strong,color:"var(--text)",fontWeight:"700"},{tag:g.emphasis,fontStyle:"italic"},{tag:g.strikethrough,color:"var(--muted)",textDecoration:"line-through"},{tag:g.monospace,color:"var(--muted)"},{tag:g.link,color:"var(--accent)"},{tag:g.url,color:"var(--muted)",textDecoration:"underline"},{tag:g.quote,color:"var(--muted)"},{tag:g.meta,color:"var(--muted)"},{tag:g.keyword,color:"#c678dd"},{tag:[g.name,g.deleted,g.character,g.propertyName,g.macroName],color:"#e06c75"},{tag:[g.function(g.variableName),g.labelName],color:"#61afef"},{tag:[g.color,g.constant(g.name),g.standard(g.name),g.bool],color:"#d19a66"},{tag:[g.definition(g.name),g.separator],color:"var(--text)"},{tag:[g.typeName,g.className,g.number,g.changed,g.annotation,g.modifier,g.self,g.namespace],color:"#e5c07b"},{tag:[g.operator,g.operatorKeyword,g.escape,g.regexp,g.special(g.string)],color:"#56b6c2"},{tag:g.string,color:"#98c379"},{tag:g.comment,color:"var(--muted)",fontStyle:"italic"},{tag:g.invalid,color:"#fff",backgroundColor:"#e06c75"}]),mg=/^(#{1,6})(?:\s|$)/;function ZP(i){let e=new Ue,t=i.state.doc;for(let n=1;n<=t.lines;n++){let r=t.line(n),o=r.text,s=mg.exec(o),l=o.trim().length===0,a;if(s)a=`cm-md-h${s[1].length}`;else if(l&&n<t.lines){let c=t.line(n+1).text;c.trim().length>0&&(a=mg.test(c)?"cm-md-gap-heading":"cm-md-gap")}a&&e.add(r.from,r.from,R.line({class:a}))}return e.finish()}var oD=ce.fromClass(class{decorations;constructor(i){this.decorations=ZP(i)}update(i){(i.docChanged||i.viewportChanged)&&(this.decorations=ZP(i.view))}},{decorations:i=>i.decorations}),MP=/`([^`\n]+)`/g,LP=/==(?=\S)(.+?)(?<=\S)==/g,Oo=/^\s*```+\s*([^\s`]*)?\s*$/;function KP(i,e){let t=!1;for(let n=1;n<e;n++)Oo.test(i.line(n).text)&&(t=!t);return t}var JP=/^\s{0,3}(?:(?:-\s*){3,}|(?:\*\s*){3,}|(?:_\s*){3,})$/,sD=/^(\s*)([-+*])(?=\s+)/,lD=/^(\s*>\s?)/,ri=R.replace({}),aD=R.mark({class:"cm-md-inline-code"}),cD=R.mark({class:"cm-md-mark"});function ug(i){let e=i.trim();return/^https?:\/\//i.test(e)?e:null}function dg(i){return R.mark({class:"cm-md-link",attributes:{"data-md-href":i,role:"link",title:i}})}var pf=48;function Tg(i){let e=/^(.*)\|(\d+)(?:x\d+)?$/.exec(i);if(!e)return{caption:i,width:null};let t=Number(e[2]);return{caption:e[1],width:Number.isFinite(t)&&t>0?Math.round(t):null}}function la(i,e){i.style.width=e?`${e}px`:"auto",i.style.height="auto"}function hD(i,e){if(typeof ResizeObserver>"u")return;let t=0,n=0,r=new ResizeObserver(o=>{let s=o[0]?.contentRect;if(s&&!(Math.abs(s.width-t)<2&&Math.abs(s.height-n)<2)){t=s.width,n=s.height;try{i.requestMeasure()}catch{}}});r.observe(e),e.__finchImageResizeObserver=r}function fD(i,e,t,n){let r;try{r=i.contentDOM.querySelectorAll("img[data-md-image-src]")}catch{return null}for(let o of r){if(o.dataset.mdImageSrc!==e)continue;let s=o.closest(".cm-md-image-wrapper");if(!(s&&(s.dataset.mdAlt!==t||(s.dataset.mdWidth??"")!==(n==null?"":String(n))))&&!(!o.complete||o.naturalWidth===0)&&!o.__finchImageClaimed)return o.__finchImageClaimed=!0,queueMicrotask(()=>{delete o.__finchImageClaimed}),o.remove(),o}return null}var gg=class extends Le{constructor(t,n,r){super();this.src=t;this.alt=n;this.width=r}src;alt;width;captionEl=null;eq(t){return t.src===this.src&&t.alt===this.alt&&t.width===this.width}ignoreEvent(t){return!!(this.captionEl&&t.target instanceof Node&&this.captionEl.contains(t.target))}toDOM(t){let n=document.createElement("span");n.className="cm-md-image-wrapper",n.tabIndex=-1,n.setAttribute("aria-selected","false"),n.addEventListener("keydown",c=>{if(c.key==="Backspace"||c.key==="Delete"){c.preventDefault(),c.stopPropagation(),bg(t);return}c.key!=="ArrowLeft"&&c.key!=="ArrowRight"||(c.preventDefault(),c.stopPropagation(),OD(t,n,c.key==="ArrowLeft"?-1:1))}),n.dataset.mdSrc=this.src,n.dataset.mdAlt=this.alt,this.width!=null&&(n.dataset.mdWidth=String(this.width));let r=document.createElement("span");r.className="cm-md-image-frame";let o=fD(t,this.src,this.alt,this.width)??document.createElement("img");o.dataset.mdImageSrc||(o.src=this.src,o.dataset.mdImageSrc=this.src),o.alt=this.alt,o.title=this.alt||this.src,la(o,this.width),r.appendChild(o);let s=document.createElement("span");s.className="cm-md-image-resize-handle",s.setAttribute("role","separator"),s.setAttribute("aria-label","Resize image width"),s.title="\u62D6\u52A8\u8C03\u6574\u56FE\u7247\u5BBD\u5EA6",s.addEventListener("pointerdown",c=>{uD(t,n,o,s,c,this.width)}),r.appendChild(s),n.appendChild(r);let l=document.createElement("span");l.className="cm-md-image-caption",l.contentEditable="plaintext-only",l.contentEditable!=="plaintext-only"&&(l.contentEditable="true"),l.spellcheck=!1,l.dataset.placeholder="\u6DFB\u52A0\u56FE\u7247\u8BF4\u660E\u2026",l.textContent=this.alt,l.addEventListener("paste",c=>{c.preventDefault();let h=c.clipboardData?.getData("text/plain")??"";document.execCommand("insertText",!1,h.replace(/[\r\n]+/g," "))});let a=0;return l.addEventListener("compositionend",()=>{a=Date.now()}),l.addEventListener("keydown",c=>{if(c.stopPropagation(),c.key==="Enter"){if(c.isComposing||c.keyCode===229||Date.now()-a<100)return;c.preventDefault(),l.blur()}else c.key==="Escape"&&(c.preventDefault(),l.textContent=this.alt,l.blur())}),l.addEventListener("input",()=>{l.textContent||l.replaceChildren()}),l.addEventListener("blur",()=>pD(t,n,this.alt,l.textContent??"")),n.appendChild(l),this.captionEl=l,hD(t,n),n}destroy(t){let n=t.__finchImageResizeObserver;n&&(n.disconnect(),delete t.__finchImageResizeObserver)}updateDOM(t,n,r){if(r.src!==this.src||r.alt!==this.alt)return!1;let o=t.querySelector("img[data-md-image-src]");if(!o)return!1;if(la(o,this.width),r.width!==this.width)try{n.requestMeasure()}catch{}return this.captionEl=t.querySelector(".cm-md-image-caption"),!0}};function sa(i,e){let t=null;return B(i).iterate({enter:n=>{if(n.name==="Image")return!t&&e(n.from,n.to)&&(t={from:n.from,to:n.to}),!1}}),t}function wf(i){return Math.min(i.from+1,i.to)}function bf(i){let e=i.selection.main;return e.empty?sa(i,(t,n)=>t<e.head&&e.head<n):null}function yf(i,e){let t=i.selection.main;return t.empty&&t.head===wf(e)}function Ss(i,e){let t=e.parentNode;if(!t)return null;let n=Array.prototype.indexOf.call(t.childNodes,e);if(n<0)return null;try{let r=i.posAtDOM(t,n),o=i.posAtDOM(t,n+1),s=Math.min(r,o),l=Math.max(r,o);return sa(i.state,(a,c)=>a===s&&c===l)??sa(i.state,a=>a===r)??sa(i.state,(a,c)=>c===o)??bf(i.state)}catch{return bf(i.state)}}function uD(i,e,t,n,r,o){if(r.button!==0)return;r.preventDefault(),r.stopPropagation();let s=Ss(i,e);s&&!yf(i.state,s)&&i.dispatch({selection:{anchor:wf(s)}});let l=r.clientX,a=t.getBoundingClientRect().width,c=e.closest(".cm-line")?.getBoundingClientRect().width??a,h=Math.max(pf,Math.floor(c)),f=Math.max(pf,Math.round(a));e.classList.add("cm-md-image-resizing"),n.setPointerCapture(r.pointerId);let u=()=>{e.classList.remove("cm-md-image-resizing"),n.removeEventListener("pointermove",d),n.removeEventListener("pointerup",O),n.removeEventListener("pointercancel",m),n.hasPointerCapture(r.pointerId)&&n.releasePointerCapture(r.pointerId)},d=p=>{if(p.pointerId!==r.pointerId)return;p.preventDefault();let b=Math.round(a+p.clientX-l);f=Math.max(pf,Math.min(h,b)),la(t,f),n.setAttribute("aria-valuenow",String(f))},O=p=>{p.pointerId===r.pointerId&&(p.preventDefault(),u(),mD(i,e,f))},m=p=>{p.pointerId===r.pointerId&&(u(),la(t,o))};n.addEventListener("pointermove",d),n.addEventListener("pointerup",O),n.addEventListener("pointercancel",m)}function dD(i){!i.isConnected||!i.classList.contains("cm-md-image-selected")||i.focus({preventScroll:!0})}function OD(i,e,t){let n=Ss(i,e);n&&(i.dispatch({selection:{anchor:t<0?n.from:n.to},scrollIntoView:!0}),i.focus())}function Sf(i,e){let t=i.state.selection.main;if(!t.empty)return!1;let n=sa(i.state,e>0?r=>r===t.head:(r,o)=>o===t.head);return n?(i.dispatch({selection:{anchor:wf(n)},scrollIntoView:!0}),!0):!1}function pD(i,e,t,n){if(n===t)return;let r=Ss(i,e);if(!r)return;let o=i.state.sliceDoc(r.from,r.to),s=/^!\[([^\]]*)\](\([^)]*\))/.exec(o);if(!s)return;let l=Tg(s[1]),a=l.width?`|${l.width}`:"";i.dispatch({changes:{from:r.from,to:r.to,insert:`![${n}${a}]${s[2]}`}})}function mD(i,e,t){let n=Ss(i,e);if(!n)return;let r=i.state.sliceDoc(n.from,n.to),o=/^!\[([^\]]*)\](\([^)]*\))/.exec(r);if(!o)return;let s=Tg(o[1]),l=Math.max(pf,Math.round(t));s.width!==l&&i.dispatch({changes:{from:n.from,to:n.to,insert:`![${s.caption}|${l}]${o[2]}`}})}function zP(i){let e=[];return B(i).iterate({enter:t=>{if(t.name!=="Image")return;let n=t.node.getChild("URL");if(!n)return!1;let r=i.sliceDoc(t.from,t.to),o=/^!\[([^\]]*)\]/.exec(r)?.[1]??"",s=Tg(o),l=i.sliceDoc(n.from,n.to).trim();if(!l)return!1;let a={from:t.from,to:t.to};return e.push(R.replace({widget:new gg(l,s.caption,s.width)}).range(a.from,a.to)),!1}}),R.set(e,!0)}var Rg=le.define({create:zP,update(i,e){return e.docChanged?zP(e.state):i},provide:i=>C.decorations.from(i)}),gD=ce.fromClass(class{constructor(i){this.sync(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&this.sync(i.view)}docViewUpdate(i){this.sync(i)}heal(i){for(let e of i.contentDOM.querySelectorAll(".cm-md-image-wrapper")){let t=e.querySelector(".cm-md-image-frame");if(!t||t.querySelector("img[data-md-image-src]"))continue;let n=e.dataset.mdSrc;if(!n)continue;let r=document.createElement("img");r.src=n,r.dataset.mdImageSrc=n,r.alt=e.dataset.mdAlt??"",r.title=r.alt||n;let o=e.dataset.mdWidth;la(r,o?Number(o):null),t.insertBefore(r,t.firstChild)}}sync(i){this.heal(i);let e=bf(i.state),t=e&&yf(i.state,e)?e:null;for(let n of i.contentDOM.querySelectorAll(".cm-md-image-wrapper")){let r=t?Ss(i,n):null,o=!!t&&!!r&&r.from===t.from&&r.to===t.to;n.classList.contains("cm-md-image-selected")!==o&&(n.classList.toggle("cm-md-image-selected",o),n.setAttribute("aria-selected",o?"true":"false"),o&&dD(n))}}}),bD=C.atomicRanges.of(i=>i.state.field(Rg));function SD(i){let e=[],t=[],n=B(i.state);return n.iterate({enter:r=>{r.name==="URL"&&t.push({from:r.from,to:r.to})}}),n.iterate({enter:r=>{if(r.name==="Table"||r.name==="Image")return!1;if(r.name==="Link"){let o=r.node.getChild("URL"),s=r.node.getChildren("LinkMark");if(!o||s.length<4||bs(i,r.from,r.to))return!1;let l=ug(i.state.sliceDoc(o.from,o.to)),a=s[0],c=s[1];return!l||a.to>=c.from||(e.push(ri.range(a.from,a.to)),e.push(dg(l).range(a.to,c.from)),e.push(ri.range(c.from,r.to))),!1}if(r.name==="Autolink"){let o=r.node.getChild("URL"),s=r.node.getChildren("LinkMark");if(!o||s.length<2||bs(i,r.from,r.to))return!1;let l=ug(i.state.sliceDoc(o.from,o.to));return l&&(e.push(ri.range(s[0].from,s[0].to)),e.push(dg(l).range(o.from,o.to)),e.push(ri.range(s[s.length-1].from,s[s.length-1].to))),!1}if(r.name==="URL"){if(bs(i,r.from,r.to))return;let o=ug(i.state.sliceDoc(r.from,r.to));o&&e.push(dg(o).range(r.from,r.to))}}}),{decorations:e,urlRanges:t}}function xD(i){let e=[];return B(i.state).iterate({enter:t=>{if(t.name==="Table"||t.name==="Image")return!1;let n=t.name==="Strikethrough"?"StrikethroughMark":t.name==="Emphasis"||t.name==="StrongEmphasis"?"EmphasisMark":void 0;if(n){if(bs(i,t.from,t.to))return!1;for(let r of t.node.getChildren(n))e.push(ri.range(r.from,r.to))}}}),e}function Og(i,e,t){return t.some(n=>i<n.to&&e>n.from)}function e$(i){return i.button!==0||!(i.target instanceof Element)?null:i.target.closest(".cm-md-link[data-md-href]")}function vD(i){return e$(i)?(i.preventDefault(),i.stopPropagation(),!0):!1}function wD(i,e){let t=e$(i)?.dataset.mdHref;return t?(i.preventDefault(),i.stopPropagation(),e?.(t),!0):!1}function t$(i){return i.button!==0||!(i.target instanceof Element)?null:i.target.closest(".cm-md-image-wrapper img[data-md-image-src]")}function yD(i){return t$(i)?(i.preventDefault(),i.stopPropagation(),!0):!1}function QD(i,e){let t=e.closest(".cm-md-image-wrapper");return t?Ss(i,t):null}function kD(i,e,t){let n=t$(e),r=n?.dataset.mdImageSrc;if(!n||!r)return!1;e.preventDefault(),e.stopPropagation();let o=QD(i,n);return o&&yf(i.state,o)?(t?.(r),!0):(o&&i.dispatch({selection:{anchor:wf(o)},scrollIntoView:!0}),!0)}function bg(i){if(!i.state.selection.main.empty)return!1;let t=bf(i.state);return!t||!yf(i.state,t)?!1:(i.dispatch({changes:{from:t.from,to:t.to},selection:{anchor:t.from}}),i.focus(),!0)}var aa=class extends He{constructor(t){super();this.elementClass=t}elementClass},PD=new aa("cm-gutter-code-line"),$D=new aa("cm-gutter-code-line cm-gutter-code-open"),CD=Cg.map((i,e)=>new aa(`cm-gutter-h${e+1}`));function qP(i){let e=new Ue,t=!1;for(let n=1;n<=i.lines;n++){let r=i.line(n),o=Oo.test(r.text);if(o||t){let s=o&&!t;e.add(r.from,r.from,s?$D:PD)}else{let s=mg.exec(r.text);s&&e.add(r.from,r.from,CD[s[1].length-1])}o&&(t=!t)}return e.finish()}var WP=le.define({create:i=>qP(i.doc),update:(i,e)=>e.docChanged?qP(e.state.doc):i}),TD=[WP,Co.from(WP)];function Ag(){let i=document.createElement("span");return i.className="cm-ai-working-mark",i}function i$(i){let e=document.createElement("span");return e.className=i?`cm-ai-working-rail ${i}`:"cm-ai-working-rail",e}var xf=class extends He{constructor(t){super();this.hasMore=t}hasMore;elementClass="cm-ai-working cm-ai-working-start";toDOM(){let t=Ag(),n=document.createElement("span");n.className="cm-ai-working-spinner",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.setAttribute("aria-label","Stop rewrite"),n.title="Stop rewrite";let r=s=>{n.innerHTML=s?'<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10" stroke-opacity="0.25"/><path d="M12 2a10 10 0 0 1 10 10"/></svg>'};r(!1),n.addEventListener("mouseenter",()=>r(!0)),n.addEventListener("mouseleave",()=>r(!1));let o=s=>{s.preventDefault(),s.stopPropagation(),n.dispatchEvent(new CustomEvent("finch:aiWorkingCancel",{bubbles:!0}))};return n.addEventListener("click",o),n.addEventListener("keydown",s=>{(s.key==="Enter"||s.key===" ")&&o(s)}),t.appendChild(n),this.hasMore&&t.appendChild(i$("cm-ai-working-rail-below")),t}},Sg=class extends He{elementClass="cm-ai-working cm-ai-working-line";toDOM(){let e=Ag();return e.appendChild(i$()),e}},xg=class extends He{elementClass="cm-ai-working cm-ai-working-end";toDOM(){let e=Ag(),t=document.createElement("span");return t.className="cm-ai-working-corner",e.appendChild(t),e}},n$=new xf(!1),RD=new xf(!0),AD=new Sg,XD=new xg,vg=D.define();function ED(i,e){if(!e)return U.empty;let t=new Ue,n=Math.max(1,Math.min(e.fromLine,i.lines)),r=Math.max(n,Math.min(e.toLine,i.lines));for(let o=n;o<=r;o++){let s=o===n?r>n?RD:n$:o===r?XD:AD;t.add(i.line(o).from,i.line(o).from,s)}return t.finish()}var r$=le.define({create:()=>U.empty,update:(i,e)=>{let t=i.map(e.changes);for(let n of e.effects)n.is(vg)&&(t=ED(e.state.doc,n.value));return t}}),wg=class extends He{elementClass="cm-ai-added-line";toDOM(){let e=document.createElement("span");return e.className="cm-ai-added-dot",e}},_D=new wg,o$=D.define(),s$=le.define({create:()=>U.empty,update:(i,e)=>{let t=i.map(e.changes);for(let n of e.effects){if(!n.is(o$))continue;let r=new Ue;for(let o of n.value)o>=1&&o<=e.state.doc.lines&&r.add(e.state.doc.line(o).from,e.state.doc.line(o).from,_D);t=r.finish()}if(e.selection){let n=e.state.doc.lineAt(e.selection.main.head).from;t=t.update({filter:r=>r!==n})}return t}}),ZD=Bs({class:"cm-ai-gutter",markers:i=>U.join([i.state.field(r$),i.state.field(s$)]),initialSpacer:()=>n$}),MD=R.line({class:"cm-ai-hint-line"}),LD=R.line({class:"cm-ai-hint-line cm-ai-hint-code-line"});function l$(i){let e=i.selection.main;if(!e.empty)return null;let t=i.doc.lineAt(e.head);return t.text.trim()?null:t.number}var zD=ce.fromClass(class{decorations;constructor(i){this.decorations=this.build(i)}update(i){(i.docChanged||i.selectionSet||i.focusChanged||i.viewportChanged)&&(this.decorations=this.build(i.view))}build(i){if(!i.hasFocus)return R.none;let e=l$(i.state);if(e==null)return R.none;let t=i.state.doc.line(e),n=KP(i.state.doc,e)?LD:MD;return R.set([n.range(t.from)])}},{decorations:i=>i.decorations}),yg=class extends Le{eq(){return!0}toDOM(){let e=document.createElement("span");return e.className="cm-md-bullet",e.textContent="\u2022",e.setAttribute("aria-hidden","true"),e}},Qg=class extends Le{constructor(t){super();this.position=t}position;eq(t){return t.position===this.position}toDOM(t){let n=document.createElement("span");return n.className="cm-md-hr",n.title="\u70B9\u51FB\u7F16\u8F91\u5206\u9694\u7EBF",n.addEventListener("mousedown",r=>r.preventDefault()),n.addEventListener("click",()=>{t.dispatch({selection:{anchor:this.position}}),t.focus()}),n}},kg=class extends Le{constructor(t,n){super();this.language=t;this.code=n}language;code;eq(t){return t.language===this.language&&t.code===this.code}toDOM(){if(!this.language){let n=document.createElement("span");return n.className="cm-md-code-fence-empty",n.textContent="\u200B",n}let t=document.createElement("button");return t.type="button",t.className="cm-md-code-copy",t.textContent=this.language.toUpperCase(),t.title="\u590D\u5236\u4EE3\u7801\u5757",t.addEventListener("mousedown",n=>n.preventDefault()),t.addEventListener("click",async n=>{n.preventDefault(),n.stopPropagation();let r=t.textContent||this.language.toUpperCase();try{await navigator.clipboard.writeText(this.code),t.textContent="\u5DF2\u590D\u5236"}catch{t.textContent="\u590D\u5236\u5931\u8D25"}window.setTimeout(()=>{t.textContent=r},1200)}),t}};function DP(i,e,t){return i.state.selection.ranges.some(n=>n.empty?n.head>=e&&n.head<=t:n.from<=t&&n.to>=e)}function bs(i,e,t){let n=i.state.doc.lineAt(e);return i.state.selection.ranges.some(r=>r.empty?r.head>=n.from&&r.head<=n.to&&r.head>=e-1&&r.head<=t+1:r.from<=n.to&&r.to>=n.from&&r.from<=t+1&&r.to>=e-1)}function qD(i){let e=i.state.doc,t=new Map,n=0,r="";for(let o=1;o<=e.lines;o++){let s=e.line(o),l=Oo.exec(s.text);if(!n){if(!l)continue;n=o,r=l[1]||"";continue}if(l){let a=Array.from({length:o-n-1},(f,u)=>e.line(n+u+1).text).join(`
41
41
  `),c=e.line(n).from,h=s.to;t.set(n,{role:"open",language:r,code:a,blockFrom:c,blockTo:h});for(let f=n+1;f<o;f++)t.set(f,{role:"body",language:r,code:a,blockFrom:c,blockTo:h});t.set(o,{role:"close",language:r,code:a,blockFrom:c,blockTo:h}),n=0,r=""}}if(n){let o=Array.from({length:e.lines-n},(a,c)=>e.line(n+c+1).text).join(`
42
42
  `),s=e.line(n).from,l=e.length;t.set(n,{role:"open",language:r,code:o,blockFrom:s,blockTo:l});for(let a=n+1;a<=e.lines;a++)t.set(a,{role:"body",language:r,code:o,blockFrom:s,blockTo:l})}return t}function WD(i){let e=new Set;return B(i.state).iterate({enter:t=>{if(t.name==="Table"){let n=i.state.doc.lineAt(t.from).number,r=i.state.doc.lineAt(t.to).number;for(let o=n;o<=r;o++)e.add(o);return!1}}}),e}function DD(i){let e=null,t=o=>{e||!o?.between||o.between(0,i.state.doc.length,(s,l,a)=>{if(a?.widget?.tableDescription)return e=a.widget,!1})};for(let o of i.state.facet(C.decorations))if(t(typeof o=="function"?o(i):o),e)break;if(!e)return!1;let n=Object.getPrototypeOf(e);if(!n||n.__finchTableHardened)return!0;n.__finchTableHardened=!0;let r=n.destroy;return n.destroy=function(o){o?.isConnected||r?.call(this,o)},n.updateDOM=function(o,s,l){if(!o?.querySelector(".tbl-table-wrapper"))return!1;if(l===this)return this.widgetElement=o,!0;let a=this.tableDescription,c=l?.tableDescription;return!a||!c||a.from!==c.from||a.to!==c.to||!a.table?.text?.eq?.(c.table?.text)?!1:(this.widgetElement=o,this.destroyWidgetElement=l.destroyWidgetElement,this.height=l.height,l.destroyWidgetElement=void 0,l.widgetElement=void 0,!0)},!0}var jD=ce.fromClass(class{done=!1;constructor(i){this.attempt(i)}update(i){!this.done&&(i.docChanged||i.viewportChanged)&&this.attempt(i.view)}attempt(i){try{this.done=DD(i)}catch{}}});function VD(i){let e=[];return B(i.state).iterate({enter:t=>{if(t.name==="Table")return e.push({from:t.from,to:t.to}),!1}}),e}var mf="data-md-table-placeholder";function ID(i){let e=i.dom.querySelector(".cm-content");if(!e)return()=>{};let t=[],n=()=>{let s=Array.from(i.dom.querySelectorAll(".tbl-table-widget"));s.forEach((l,a)=>{let c=l.querySelector(".tbl-table-wrapper:not(["+mf+"] *)"),h=l.querySelector(`[${mf}]`);if(c){h&&h.remove(),t[a]=c.outerHTML;return}if(h)return;let f=t[a];if(!f)return;let u=document.createElement("div");u.setAttribute(mf,"true"),u.setAttribute("aria-hidden","true"),u.style.pointerEvents="none",u.innerHTML=f,l.appendChild(u)}),s.length<t.length&&(t=t.slice(0,s.length))},r=0,o=new MutationObserver(()=>{r||(r=window.requestAnimationFrame(()=>{r=0,n()}))});return o.observe(e,{childList:!0,subtree:!0}),n(),()=>{o.disconnect(),r&&window.cancelAnimationFrame(r)}}var jP=0;function VP(i){if(!Array.from(i.dom.querySelectorAll(".tbl-table-widget")).some(o=>!o.querySelector(`.tbl-table-wrapper:not([${mf}] *)`)))return;let n=Date.now();if(n-jP<1e3)return;jP=n;let r=VD(i);r.length&&i.dispatch({changes:r.map(({from:o,to:s})=>({from:o,to:s,insert:i.state.doc.sliceString(o,s)})),selection:i.state.selection,scrollIntoView:!1,annotations:[Pe.addToHistory.of(!1)]})}function IP(i,e=!0){let t=[],n=i.state.doc,r=qD(i),o=WD(i),s=e?SD(i):{decorations:[],urlRanges:[]};t.push(...s.decorations,...xD(i));for(let l=1;l<=n.lines;l++){let a=n.line(l);if(o.has(l))continue;let c=DP(i,a.from,a.to),h=r.get(l);if(h){let m=DP(i,h.blockFrom,h.blockTo),p=h.role==="open"?" cm-md-code-open":h.role==="close"?" cm-md-code-close":"";if(t.push(R.line({class:`cm-md-code-line${p}`}).range(a.from)),!m&&h.role!=="body"){let b=new kg(h.role==="open"?h.language:"",h.code);t.push(ri.range(a.from,a.to)),t.push(R.widget({widget:b,side:-1}).range(a.from))}continue}let f=lD.exec(a.text);if(f&&(t.push(R.line({class:"cm-md-quote"}).range(a.from)),c||t.push(ri.range(a.from,a.from+f[0].length))),!c&&JP.test(a.text)){t.push(ri.range(a.from,a.to)),t.push(R.widget({widget:new Qg(a.from),side:-1}).range(a.from));continue}if(c$.test(a.text)&&t.push(R.line({class:"cm-md-list-line"}).range(a.from)),!c){let m=sD.exec(a.text);if(m){let b=a.from+m[1].length;t.push(R.replace({widget:new yg}).range(b,b+1))}let p=/^(#{1,6}\s+)/.exec(a.text);p&&t.push(ri.range(a.from,a.from+p[0].length))}MP.lastIndex=0;let u=[],d;for(;d=MP.exec(a.text);){let m=a.from+d.index,p=m+d[0].length;Og(m,p,s.urlRanges)||(u.push({from:m,to:p}),t.push(aD.range(m+1,p-1)),bs(i,m,p)||(t.push(ri.range(m,m+1)),t.push(ri.range(p-1,p))))}LP.lastIndex=0;let O;for(;O=LP.exec(a.text);){let m=a.from+O.index,p=m+O[0].length;Og(m,p,u)||Og(m,p,s.urlRanges)||(t.push(cD.range(m+2,p-2)),bs(i,m,p)||(t.push(ri.range(m,m+2)),t.push(ri.range(p-2,p))))}}return R.set(YD(i,t),!0)}function YD(i,e){let t=[],n=i.state.field(Rg,!1);return!n||(n.between(0,i.state.doc.length,(r,o)=>{t.push({from:r,to:o})}),!t.length)?e:e.filter(r=>!t.some(o=>r.from>=o.from&&r.to<=o.to))}function BD(i){return ce.fromClass(class{decorations;constructor(e){this.decorations=IP(e,i)}update(e){(e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=IP(e.view,i))}},{decorations:e=>e.decorations})}var ND=BD(!0);function a$(i,e,t,n){let r=n??i.state.selection.main;if(!t){let l=new FileReader;l.onload=()=>{let a=typeof l.result=="string"?l.result:"";if(!a)return;let c=`![Pasted image](${a})`;i.dispatch({changes:{from:r.from,to:r.to,insert:c},selection:{anchor:r.from+c.length}}),i.focus()},l.readAsDataURL(e);return}let o=`![Uploading image\u2026](pasting:${Math.random().toString(36).slice(2)})`;i.dispatch({changes:{from:r.from,to:r.to,insert:o},selection:{anchor:r.from+o.length}}),i.focus();let s=l=>{let c=i.state.doc.toString().indexOf(o);c<0||i.dispatch({changes:{from:c,to:c+o.length,insert:l}})};t(e).then(l=>s(`![Pasted image](${l})`),()=>s(""))}function UD(i,e,t){let n=e.clipboardData?.items;if(!n)return!1;for(let r=0;r<n.length;r++){let o=n[r];if(o.kind==="file"&&o.type.indexOf("image/")===0){let s=o.getAsFile();if(s)return e.preventDefault(),a$(i,s,t),!0}}return!1}function GD(i,e,t){let n=e.dataTransfer?.files;if(!n)return!1;let r=Array.from(n).filter(l=>l.type.indexOf("image/")===0);if(!r.length)return!1;e.preventDefault();let s=i.posAtCoords({x:e.clientX,y:e.clientY})??i.state.selection.main.from;return a$(i,r[0],t,{from:s,to:s}),!0}var c$=/^\s*(?:[-+*]|\d+[.)])\s+/;function YP(i){let e=i.state.doc.lineAt(i.state.selection.main.head);return c$.test(e.text)}var FD=/^\s*(?:#{1,6}|>|[-+*]|\d+[.)]|`{1,}|\*\*|__|~~|_)\s*$/;function HD(i){return Oo.test(i)||JP.test(i)||FD.test(i)}function vf(i,e){let t=i.state.selection.main;if(!t.empty)return!1;let n=i.coordsAtPos(t.head),r=i.moveVertically(t,e>0),o=i.coordsAtPos(r.head);if(!n||!o||r.head===t.head)return!1;let l=Array.from(i.dom.querySelectorAll(".tbl-table-widget")).map(a=>({widget:a,rect:a.getBoundingClientRect()})).filter(({rect:a})=>e>0?a.top>=n.bottom-1&&a.top<=o.top+1:a.bottom<=n.top+1&&a.bottom>=o.bottom-1).sort((a,c)=>e>0?a.rect.top-c.rect.top:c.rect.bottom-a.rect.bottom)[0]?.widget;return l?(window.requestAnimationFrame(()=>{let a=l.querySelectorAll(".tbl-cell");if(!a.length)return;let c=a[e>0?0:a.length-1];KD(c,e<0)}),!0):!1}function KD(i,e){let t=i.ownerDocument,n=t.createTreeWalker(i,NodeFilter.SHOW_TEXT),r=[];for(;n.nextNode();)r.push(n.currentNode);let o=e?r[r.length-1]:r[0],s=t.createRange();o?s.setStart(o,e?o.textContent?.length??0:0):s.selectNodeContents(i),s.collapse(!0);let l=t.getSelection();l?.removeAllRanges(),l?.addRange(s);let a=c=>{let h=i.querySelector(".tbl-cell-editor .cm-content");if(h){h.focus({preventScroll:!0});return}c>0&&window.requestAnimationFrame(()=>a(c-1))};window.requestAnimationFrame(()=>a(8))}function BP(i,e){let t=i.state.selection.main;if(!t.empty)return!1;let n=i.state.doc,r=n.lineAt(t.head),o=r.number+e;if(o<1||o>n.lines)return!1;let s=n.line(o);if(!HD(s.text))return!1;let l=i.moveVertically(t,e>0),a=n.lineAt(l.head).number;if(a===o)return!1;let c=e>0?a>o:a<o,h=l.head===t.head;if(!c&&!h)return!1;let f=t.head-r.from;return i.dispatch({selection:{anchor:s.from+Math.min(f,s.length)},scrollIntoView:!0}),!0}function JD(i){let e=i.state.selection.main;if(!e.empty)return!1;let t=i.state.doc.lineAt(e.head),n=t.text.slice(0,e.head-t.from),r=t.text.slice(e.head-t.from);if(!/^\s*``$/.test(n)||r.trim()!=="")return!1;let o=0;for(let a=1;a<t.number;a++)Oo.test(i.state.doc.line(a).text)&&o++;if(o%2!==0)return!1;let l=`${/^\s*/.exec(n)?.[0]??""}\`\`\``;return i.dispatch({changes:{from:e.head,insert:`\`
43
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "finch-markdown-editor",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "A Markdown editor and WeChat Official Account style preview, with selection-based AI edits and AI-generated custom styles.",
5
5
  "author": {
6
6
  "name": "PuterJam",