@telepath-computer/television 1.4.27 → 1.4.29
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.
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
</span>`)}function xZ({textContent:i,classes:t}){return L(t)?`<span class="${t.join(" ")}">${ig(i)}</span>`:ig(i)}const yZ=[{type:"table",location:"bottom-right"},{type:"table",location:"right"},{type:"table",location:"bottom"}];function kZ({row:i,col:t},e){const n=[{type:"header",location:"col",index:t},{type:"border",location:"top",index:i}],r=[{type:"border",location:"col",index:t+1},{type:"border",location:"row",index:i+1}],s=[{type:"header",location:"row",index:i},{type:"border",location:"left",index:i}];return[...e.top?n:[],...r,...e.left?s:[]]}function QZ({location:i,type:t},e){return t==="header"?{location:i,type:t,index:e[i]}:i==="top"?{location:i,type:t,index:e.row}:i==="left"?{location:i,type:t,index:e.col}:{location:i,type:t,index:e[i]+1}}function kf(i,t){return(i==null?void 0:i.type)!==(t==null?void 0:t.type)||(i==null?void 0:i.location)!==(t==null?void 0:t.location)?!1:(i==null?void 0:i.type)==="table"||(t==null?void 0:t.type)==="table"?!0:(i==null?void 0:i.index)===(t==null?void 0:t.index)}class vc{constructor(t,e){C(this,"state");C(this,"extraTags");this.state=t,this.extraTags=e}style(t){return lQ(this.state,L(this.extraTags)?[...t,...this.extraTags]:t)}static of(t,e){return new vc(t,e)}}function sv(i){return rh(i).type==="None"}function ov(i){return!sv(i)}function rg(i){return ov(i)?rh(i).getRangeAt(0).startOffset:void 0}function $Z(i){return ov(i)?rh(i).getRangeAt(0).startContainer:void 0}function CZ(i){rh(i).empty()}function rh(i){return i.getSelection()}var Os,ps,ms,gs,bs,ws,Ss,vs,xs,ys,ks,Qs,$s,Cs,Ps,Ts,As,Rs,Zs,Xs,Es,Ls,Ms,zs,_s,Is,js,Ds,Ys,Ws,Vs;const sO=class sO{constructor({table:t,selection:e,scrollElement:n,rootEditor:r,menuRootElement:s,extensions:o,markdownConfig:l,globalKeyBindings:a,selectionType:c,lineWrapping:h,onUndo:u,onRedo:f,onNavigate:d,onDelete:O}){A(this,Os);A(this,ps);A(this,ms);A(this,gs);A(this,bs);A(this,ws);A(this,Ss);A(this,vs);A(this,xs);A(this,ys);A(this,ks);A(this,Qs);A(this,$s);A(this,Cs);A(this,Ps);A(this,Ts);A(this,As);A(this,Rs);A(this,Zs);A(this,Xs);A(this,Es);A(this,Ls);A(this,Ms);A(this,zs);A(this,_s);A(this,Is);A(this,js);A(this,Ds);A(this,Ys);A(this,Ws);A(this,Vs);R(this,Os,H(t)),R(this,ps,H(e)),R(this,ms,ct(!1));const p=this.selection.isCell()?this.selection.cell:void 0;R(this,gs,ct(p)),R(this,bs,ct(p)),R(this,ws,ct(L(p)?rt.ofCell(p):void 0)),R(this,Ss,H(r)),R(this,vs,H(o)),R(this,xs,H(l)),R(this,ys,H(a)),R(this,ks,H(c)),R(this,Qs,H(h)),R(this,$s,ct(void 0)),R(this,Cs,ct(void 0)),R(this,Ps,H(n)),R(this,Ts,H(s)),R(this,As,H(()=>vc.of(this.rootEditor.state,[v.heading]))),R(this,Rs,H(()=>vc.of(this.rootEditor.state))),R(this,Zs,H(u)),R(this,Xs,H(f)),R(this,Es,H(d)),R(this,Ls,H(O)),R(this,Ms,ct(!1)),R(this,zs,ct(void 0)),R(this,_s,ct(void 0)),R(this,Is,ct(void 0)),R(this,js,ct(void 0)),R(this,Ds,ct(void 0)),R(this,Ys,ct(void 0)),R(this,Ws,H(()=>V(this.move)&&V(this.resize)&&V(this.menu)&&V(this.outline))),R(this,Vs,ct(!1));const m=H(()=>{var g;if(Uc(this.window)){if(L(this.menu))return"default";if(L(this.activeHandle)){const{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(((g=this.outline)==null?void 0:g.outlined)??!1)return"cell";if(L(this.hoveredCell))return"text"}}});Dd([()=>this.selectionValue],()=>{if(this.selectionChanged){this.selectionChanged=!1;return}this.selection.isCell()?(this.activeCell=this.selection.cell,this.anchorCell=this.selection.cell,this.outlinedSection=rt.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)}),Kc(()=>{this.document.body.style.cursor=$(m)??""})}get table(){return $(w(this,Os))}set table(t){q(w(this,Os),t)}get _selection(){return $(w(this,ps))}set _selection(t){q(w(this,ps),t)}get selectionChanged(){return $(w(this,ms))}set selectionChanged(t){q(w(this,ms),t,!0)}get activeCell(){return $(w(this,gs))}set activeCell(t){q(w(this,gs),t)}get anchorCell(){return $(w(this,bs))}set anchorCell(t){q(w(this,bs),t)}get outlinedSection(){return $(w(this,ws))}set outlinedSection(t){q(w(this,ws),t)}get rootEditor(){return $(w(this,Ss))}set rootEditor(t){q(w(this,Ss),t)}get extensions(){return $(w(this,vs))}set extensions(t){q(w(this,vs),t)}get markdownConfig(){return $(w(this,xs))}set markdownConfig(t){q(w(this,xs),t)}get globalKeyBindings(){return $(w(this,ys))}set globalKeyBindings(t){q(w(this,ys),t)}get selectionType(){return $(w(this,ks))}set selectionType(t){q(w(this,ks),t)}get lineWrapping(){return $(w(this,Qs))}set lineWrapping(t){q(w(this,Qs),t)}get wrapperElement(){return $(w(this,$s))}set wrapperElement(t){q(w(this,$s),t)}get tableElement(){return $(w(this,Cs))}set tableElement(t){q(w(this,Cs),t)}get scrollElement(){return $(w(this,Ps))}set scrollElement(t){q(w(this,Ps),t)}get menuRootElement(){return $(w(this,Ts))}set menuRootElement(t){q(w(this,Ts),t)}get headerCellHighlighter(){return $(w(this,As))}set headerCellHighlighter(t){q(w(this,As),t)}get dataCellHighlighter(){return $(w(this,Rs))}set dataCellHighlighter(t){q(w(this,Rs),t)}get onUndo(){return $(w(this,Zs))}set onUndo(t){q(w(this,Zs),t)}get onRedo(){return $(w(this,Xs))}set onRedo(t){q(w(this,Xs),t)}get onNavigate(){return $(w(this,Es))}set onNavigate(t){q(w(this,Es),t)}get onDelete(){return $(w(this,Ls))}set onDelete(t){q(w(this,Ls),t)}get activeTable(){return $(w(this,Ms))}set activeTable(t){q(w(this,Ms),t)}get hoveredCell(){return $(w(this,zs))}set hoveredCell(t){q(w(this,zs),t)}get activeHandle(){return $(w(this,_s))}set activeHandle(t){q(w(this,_s),t)}get menu(){return $(w(this,Is))}set menu(t){q(w(this,Is),t)}get move(){return $(w(this,js))}set move(t){q(w(this,js),t)}get outline(){return $(w(this,Ds))}set outline(t){q(w(this,Ds),t)}get resize(){return $(w(this,Ys))}set resize(t){q(w(this,Ys),t)}get interactive(){return $(w(this,Ws))}set interactive(t){q(w(this,Ws),t)}get pointerDown(){return $(w(this,Vs))}set pointerDown(t){q(w(this,Vs),t)}static of(t){return new sO(t)}focusTable(){this.activeTable=!0,this.tableElement.focus({preventScroll:!0}),this.selectionValue="hidden",CZ(this.document)}scrollToCell(t){requestAnimationFrame(()=>{var e;(e=Sc(this.tableElement,t))==null||e.scrollIntoView({inline:"nearest",block:"nearest"})})}scrollToFirstCell(t,e){requestAnimationFrame(()=>{var n;(n=Sc(this.tableElement,{...this.table.firstCellLocation,[t]:e}))==null||n.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(t){this.onNavigate(t)}undo(){this.onUndo()}redo(){this.onRedo()}get selection(){return this._selection}get selectionValue(){return this._selection.value}set selectionValue(t){ih(this._selection.value,t)||(this._selection.value=t,this.selectionChanged=!0)}highlighter({row:t}){return t===this.table.firstRowIndex?this.headerCellHighlighter:this.dataCellHighlighter}cellHandleState(t,e){var n,r,s,o,l;return e.type==="border"||((n=this.activeHandle)==null?void 0:n.state)=="active"?kf((r=this.activeHandle)==null?void 0:r.handle,e)?(s=this.activeHandle)==null?void 0:s.state:void 0:kf((o=this.activeHandle)==null?void 0:o.handle,e)||t[e.location]===((l=this.activeCell)==null?void 0:l[e.location])?"hover":void 0}};Os=new WeakMap,ps=new WeakMap,ms=new WeakMap,gs=new WeakMap,bs=new WeakMap,ws=new WeakMap,Ss=new WeakMap,vs=new WeakMap,xs=new WeakMap,ys=new WeakMap,ks=new WeakMap,Qs=new WeakMap,$s=new WeakMap,Cs=new WeakMap,Ps=new WeakMap,Ts=new WeakMap,As=new WeakMap,Rs=new WeakMap,Zs=new WeakMap,Xs=new WeakMap,Es=new WeakMap,Ls=new WeakMap,Ms=new WeakMap,zs=new WeakMap,_s=new WeakMap,Is=new WeakMap,js=new WeakMap,Ds=new WeakMap,Ys=new WeakMap,Ws=new WeakMap,Vs=new WeakMap;let Qf=sO;function lv({tableState:i,event:t}){if(V(i.outlinedSection))return;t==null||t.preventDefault();const e=Um(i.outlinedSection.rowRange,i.table.rowRange),n=Um(i.outlinedSection.colRange,i.table.colRange),r=n&&!e&&Qn(i.outlinedSection.rowRange).every(l=>i.table.hasEmptyRowAt(l)),s=e&&!n&&Qn(i.outlinedSection.colRange).every(l=>i.table.hasEmptyColAt(l)),o=e&&n&&Qn(i.outlinedSection.colRange).every(l=>i.table.hasEmptyColAt(l));if(r){i.table.removeRowsAt({row:i.outlinedSection.startRow,count:i.outlinedSection.rowCount});const l=i.table.hasRowAt(i.outlinedSection.startRow)?i.outlinedSection.startRow:i.table.lastRowIndex,a={row:l,col:i.table.lastColIndex};i.outlinedSection=rt.of({row:{start:l,endExclusive:l+1},col:i.table.colRange}),i.activeCell=a,i.anchorCell=a}else if(s){i.table.removeColsAt({col:i.outlinedSection.startCol,count:i.outlinedSection.colCount});const l=i.table.hasColAt(i.outlinedSection.startCol)?i.outlinedSection.startCol:i.table.lastColIndex,a={row:i.table.lastRowIndex,col:l};i.outlinedSection=rt.of({row:i.table.rowRange,col:{start:l,endExclusive:l+1}}),i.activeCell=a,i.anchorCell=a}else o?i.deleteTable():i.table.clearSection(i.outlinedSection)}function av(i){hv(i,"copy")}function cv(i){hv(i,"cut")}function Yd({event:i,tableState:t}){if(V(t.outlinedSection))return;const e=i.clipboardData.getData("text/plain"),n=wl.maybeOf(B.of(e.split(/\r\n|\n|\r/)));L(n)?(i.preventDefault(),i.stopPropagation(),sg(n,t)):t.selection.isCell()||(i.preventDefault(),i.stopPropagation(),sg(PZ(e),t))}function sg(i,t){const{startRow:e,startCol:n,rowCount:r,colCount:s}=t.outlinedSection,o=Am(r/i.rowCount),l=Am(s/i.colCount);i.tile({rowRepeat:ce(o-1,{min:0}),colRepeat:ce(l-1,{min:0})}),t.table.merge(i,{row:e,col:n}),t.outlinedSection=rt.of({row:{start:e,endExclusive:e+i.rowCount},col:{start:n,endExclusive:n+i.colCount}}),V(t.anchorCell)&&(t.anchorCell=t.activeCell);const a=t.anchorCell.row<=t.activeCell.row,c=t.anchorCell.col<=t.activeCell.col;t.anchorCell=t.outlinedSection.cornerCellAt(`${a?"top":"bottom"}-${c?"left":"right"}`),t.activeCell=t.outlinedSection.cornerCellAt(`${a?"bottom":"top"}-${c?"right":"left"}`),t.focusTable()}function PZ(i){const{text:t}=I1([[le(i)]],["none"]);return wl.of(t)}function hv({event:i,tableState:t},e){var r;if(V(t.outlinedSection)||t.selection.isCell())return;i.preventDefault(),i.stopPropagation();const n=t.table.sliceSectionAt(t.outlinedSection);(r=i.clipboardData)==null||r.setData("text/plain",n.text.toString()),e==="cut"&&lv({tableState:t})}function TZ(i){i.pointerDown=!0}function AZ(i){i.pointerDown=!1}function RZ(i){i.pointerDown=!1}function ZZ(i,t){t.selection.isCell()||av({tableState:t,event:i})}function XZ(i,t){t.selection.isCell()||cv({tableState:t,event:i})}function EZ(i,t){t.selection.isCell()||Yd({tableState:t,event:i})}const Wd="CellView";function uv(i){return BS(i,{component:Wd})}function LZ(i){return VS(i,{component:Wd})}const kn="\0";function fv(i,t,{trim:e}){const n=iv(i),{from:r,to:s}=ev(i),o=t.toString(),l=B.of(`${o.slice(0,r)}${kn}${o.slice(r,s)}${kn}${o.slice(s)}`.split(`
|
|
63
63
|
`)),a=kd(l,{trim:e}).toString(),c=a.indexOf(kn),h=a.lastIndexOf(kn)-1;return n?{anchor:c,head:h}:{head:c,anchor:h}}function og(i,t){const e=iv(i),{from:n,to:r}=ev(i),s=t.toString(),o=B.of(`${s.slice(0,n)}${kn}${s.slice(n,r)}${kn}${s.slice(r)}`.split(`
|
|
64
64
|
`)),l=pc(o).toString(),a=l.indexOf(kn),c=l.lastIndexOf(kn)-1;return e?{anchor:a,head:c}:{head:a,anchor:c}}function MZ(i){if(V(i.tableElement)||sv(i.document))return;const t=$Z(i.document);if(V(t)||!YS(i.tableElement,t))return;const e=Wl(t);if(V(e))return;const n=nh(e);i.selection.isCell()&&Pr(i.selection.cell,n)||(i.activeTable=!1,i.selectionValue={cell:n,section:zZ(i.document,t)},i.activeCell=n,i.anchorCell=n,i.outlinedSection=rt.ofCell(n))}function zZ(i,t){const e=uv(t),n=j5({ancestor:e,descendent:t,getText:l=>_5(l)?`
|
|
65
|
-
`:l.textContent??""})??"",r=(t.textContent??"").slice(0,rg(i)),s=le(`${n}${r}`),o=n.length+rg(i);return fv({anchor:o,head:o},s,{trim:!1})}function _Z(i,t){var e=zd(),n=Xt(e);$r(n,()=>t.children),I(i,e)}function IZ(i,t){Dn(t,!0),th(()=>{const e=zS(_Z,{target:t.to,context:VR(),props:{children:t.children}});return()=>{_S(e)}}),Yn()}YR();var jZ=ot('<div class="tbl-blocking-overlay" aria-hidden="true"></div>');function DZ(i){var t=jZ();I(i,t)}function xc(i,t){const e=t.devicePixelRatio;return MA(i*e)/e}function YZ({x:i,y:t},e){return{x:xc(i,e),y:xc(t,e)}}var WZ=ot('<th class="tbl-cell tbl-header-cell"><!></th>'),VZ=ot('<td class="tbl-cell tbl-data-cell"><!></td>');function BZ(i,t){Dn(t,!0);const e=H(()=>ng(L(t.movement)?t.movement.border:{top:t.position.top,right:!0,bottom:!0,left:t.position.left})),n=H(()=>ng(t.outline)),r=H(()=>{var u;if(V((u=t.movement)==null?void 0:u.translate))return;const{x:c,y:h}=t.movement.state==="moving"?YZ(t.movement.translate,t.win):t.movement.translate;return`translate3d(${c}px, ${h}px, 0px)`});var s=zd(),o=Xt(s);{var l=c=>{var h=WZ();let u;var f=Ue(h);$r(f,()=>t.children),se(d=>{var O;$t(h,"align",t.alignment==="none"?void 0:t.alignment),$t(h,"data-component",Sl),$t(h,"data-row",t.location.row),$t(h,"data-col",t.location.col),$t(h,"data-border",$(e)),$t(h,"data-outline",$(n)),$t(h,"data-selected",d),$t(h,"data-state",(O=t.movement)==null?void 0:O.state),u=gc(h,"",u,{transform:$(r)})},[()=>gr(t.selected)]),I(c,h)},a=c=>{var h=VZ();let u;var f=Ue(h);$r(f,()=>t.children),se(d=>{var O;$t(h,"align",t.alignment==="none"?void 0:t.alignment),$t(h,"data-component",Sl),$t(h,"data-row",t.location.row),$t(h,"data-col",t.location.col),$t(h,"data-border",$(e)),$t(h,"data-outline",$(n)),$t(h,"data-selected",d),$t(h,"data-state",(O=t.movement)==null?void 0:O.state),u=gc(h,"",u,{transform:$(r)})},[()=>gr(t.selected)]),I(c,h)};Ft(o,c=>{t.position.top?c(l):c(a,!1)})}I(i,s),Yn()}function dv(i){var t;return L((t=bl(i.dom).activeElement)==null?void 0:t.closest(".cm-panels"))}function lg(i){return i.trim().split(/\s+/)}function qZ({doc:i,selection:t,parent:e,extensions:n,markdownConfig:r,selectionType:s,lineWrapping:o,globalKeyBindings:l,rootEditor:a,highlighter:c,onChange:h,eventHandlers:u}){return new z({doc:i,selection:t,parent:e,extensions:[n,hn.lowest([z.editorAttributes.of(f=>{const d=new Set(lg(a.themeClasses)),O=new Set(lg(f.themeClasses));return{class:[...d.difference(O)].join(" ")}}),Mn.of([...l.map(f=>({...f,run:L(f.run)?()=>f.run(a):void 0,shift:L(f.shift)?()=>f.shift(a):void 0}))]),s==="codemirror"?wk():[],b0(c),Ml({extensions:[E1,r.extensions??[]],addKeymap:!1,completeHTMLTags:r.completeHTMLTags,pasteURLAsLink:r.pasteURLAsLink,htmlTagLanguage:r.htmlTagLanguage}),z.domEventObservers(u),o==="wrap"?z.lineWrapping:[]])],dispatchTransactions:(f,d)=>{d.update(f),f.forEach(h)}})}var NZ=ot('<div class="tbl-cell-editor"></div>');function GZ(i,t){Dn(t,!0);let e=bf(t,"text",15),n=bf(t,"selection",15),r,s,o=!1,l=!1;function a(h){const{docChanged:u,newDoc:f,selection:d}=h;if(o)return;const O=L(d);if(u||O){if(u){const p=kd(f,{trim:!0});p.eq(e())||(e(p),l=!0)}if(O){const{head:p,anchor:m}=d.main,g=fv({head:p,anchor:m},f,{trim:!0});tv(g,n())||(n(g),l=!0)}}}Dd([()=>e(),()=>n()],()=>{if(l){l=!1;return}o=!0,s.dispatch({changes:s.state.changes({from:0,to:s.state.doc.length,insert:pc(e())}),selection:og(n(),e())}),o=!1},{lazy:!0}),th(()=>(s=qZ({doc:pc(e()),selection:og(n(),e()),parent:r,selectionType:t.selectionType,lineWrapping:t.lineWrapping,extensions:t.extensions,markdownConfig:t.markdownConfig,globalKeyBindings:t.globalKeyBindings,rootEditor:t.rootEditor,highlighter:t.highlighter,onChange:a,eventHandlers:{beforeinput:t.onbeforeinput,dragstart:t.ondragstart,keydown:(h,{state:u})=>t.onkeydown(h,u),paste:t.onpaste}}),dv(s)||s.focus(),()=>s.destroy()));var c=NZ();bc(c,h=>r=h,()=>r),I(i,c),Yn()}class sh{constructor({event:t,tableState:e,position:n}){C(this,"event");C(this,"tableState");C(this,"position");this.event=t,this.tableState=e,this.position=n}static navigate(t){new sh(t)[`navigate${t.key}`]()}navigateTab(){this.moveRight({createRow:!1,position:"end"})}navigateShiftTab(){this.moveLeft({createRow:!1,position:"end"})}navigateEnter(){this.moveDown({createRow:!1,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||V(this.tableState.outlinedSection)||V(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),V(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=JS(this.tableState.activeCell)}}navigateShiftArrowUp(){if(!(!this.position.top||V(this.tableState.outlinedSection)||V(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),V(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=HS(this.tableState.activeCell)}}navigateShiftArrowRight(){if(!(!this.position.right||V(this.tableState.outlinedSection)||V(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),V(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=FS(this.tableState.activeCell)}}navigateShiftArrowDown(){if(!(!this.position.bottom||V(this.tableState.outlinedSection)||V(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),V(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=KS(this.tableState.activeCell)}}moveLeft({createRow:t,position:e}){if(!V(this.tableState.activeCell)){if(this.event.preventDefault(),Pr(this.tableState.activeCell,this.tableState.table.firstCellLocation)){if(!t){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},e)}}moveUp({createRow:t,position:e}){if(!V(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.firstRowIndex){if(!t){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},e)}}moveRight({createRow:t,position:e}){if(!V(this.tableState.activeCell)){if(this.event.preventDefault(),Pr(this.tableState.activeCell,this.tableState.table.lastCellLocation)){if(!t){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},e)}}moveDown({createRow:t,position:e}){if(!V(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.lastRowIndex){if(!t){this.tableState.navigate("after");return}this.tableState.table.appendEmptyRows(1)}this.moveTo({row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col},e)}}moveTo(t,e){if(this.tableState.activeCell=t,this.tableState.anchorCell=t,this.tableState.outlinedSection=rt.ofCell(t),this.tableState.selection.isCell()){const n=e==="start"?0:this.tableState.table.cellAt(t).length;this.tableState.selectionValue={cell:t,section:{anchor:n,head:n}}}}}const bt={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"},UZ=[bt.arrowDown,bt.arrowLeft,bt.arrowRight,bt.arrowUp,bt.enter,bt.tab,`${bt.shift}${bt.arrowDown}`,`${bt.shift}${bt.arrowLeft}`,`${bt.shift}${bt.arrowRight}`,`${bt.shift}${bt.arrowUp}`,`${bt.shift}${bt.tab}`],ag=new Set(UZ);function Ov({key:i,shiftKey:t,altKey:e,metaKey:n,ctrlKey:r}){if(!(e||n||r))return t?ag.has(`${bt.shift}${i}`)?`${bt.shift}${i}`:void 0:ag.has(i)?i:void 0}function HZ(i,t){i.inputType==="historyUndo"?(t.undo(),i.preventDefault()):i.inputType==="historyRedo"&&(t.redo(),i.preventDefault())}function FZ(i){i.preventDefault()}function KZ(i,t,e){const n=Ov(i);if(V(n))return;const r=t.selection.main.head,s=t.doc.lineAt(r).number,o=0,l=t.doc.length,a=1,c=t.doc.lines,h={top:s===a,right:r===l,bottom:s===c,left:r===o};sh.navigate({tableState:e,key:n,event:i,position:h})}function JZ(i,t){Yd({tableState:t,event:i})}var tX=ot('<div class="tbl-cell-view" contenteditable="" tabindex="-1"><!></div>');function eX(i,t){Dn(t,!0);var e=tX(),n=Ue(e);$r(n,()=>t.children),se(r=>{$t(e,"data-component",Wd),$t(e,"data-hidden",r)},[()=>gr(t.hidden)]),I(i,e),Yn()}const pv="Handle";function Vd(i){if(!qS(i,{component:pv}))return;const{type:t,location:e}=_d(i).dataset;if(t==="table")return{type:t,location:e};{const n=nh(Wl(i));return QZ({location:e,type:t},n)}}var iX=ri('<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>'),nX=ri('<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>'),rX=ot('<div class="tbl-handle" role="button" aria-hidden="true"><!></div>');function cg(i,t){Dn(t,!0);let e=bf(t,"toggle",3,!1);const n={table:{right:"vertical",bottom:"horizontal"},header:{row:"vertical",col:"horizontal"}},r=H(()=>{var c;return(c=n[t.of.type])==null?void 0:c[t.of.location]});var s=rX();gc(s,"",{},{opacity:"var(--tbl-handle-opacity, 0)"});var o=Ue(s);{var l=c=>{var h=iX();I(c,h)},a=c=>{var h=nX();I(c,h)};Ft(o,c=>{$(r)==="horizontal"?c(l):$(r)==="vertical"&&c(a,1)})}se((c,h,u)=>{$t(s,"data-component",pv),$t(s,"data-type",t.of.type),$t(s,"data-location",t.of.location),$t(s,"data-active",c),$t(s,"data-hover",h),$t(s,"data-toggle",u)},[()=>gr(t.state==="active"),()=>gr(t.state==="hover"),()=>gr(e())]),I(i,s),Yn()}var sX=ot('<div class="tbl-menu"><!></div>');function oX(i,t){Dn(t,!0);let e,n=ct(void 0);th(()=>{t.translate(e).then(l=>q(n,l,!0))});var r=sX();let s;var o=Ue(r);$r(o,()=>t.children),bc(r,l=>e=l,()=>e),se(l=>s=gc(r,"",s,l),[()=>({visibility:L($(n))?void 0:"hidden",transform:L($(n))?`translate3d(${$(n).x}px, ${$(n).y}px, 0px)`:void 0})]),I(i,r),Yn()}var lX=ot('<div class="tbl-menu-item" role="menuitem" tabindex="-1"><!></div>');function Ae(i,t){var e=lX(),n=Ue(e);$r(n,()=>t.children),Mo("click",e,function(...r){var s;(s=t.onclick)==null||s.apply(this,r)}),I(i,e)}MS(["click"]);function Re(i,t){switch(i.action){case"add":return t.menu.clickAdd(i.direction);case"align":return t.menu.clickAlign(i.alignment);case"clear":return t.menu.clickClear();case"duplicate":return t.menu.clickDuplicate();case"move":return t.menu.clickMove(i.direction);case"remove":return t.menu.clickRemove();case"sort":return t.menu.clickSort(i.direction)}}var aX=ri('<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>'),cX=ri('<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>'),hX=ri('<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>'),uX=ri('<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>'),fX=ri('<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>'),dX=ri('<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>'),OX=ri('<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>'),pX=ri('<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>'),mX=ri('<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>'),gX=ri('<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>'),bX=ot('<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 Ze(i,t){var e=bX(),n=Ue(e),r=Ue(n);{var s=b=>{var S=aX();I(b,S)},o=b=>{var S=cX();I(b,S)},l=b=>{},a=b=>{var S=hX();I(b,S)},c=b=>{var S=uX();I(b,S)},h=b=>{var S=fX();I(b,S)},u=b=>{var S=dX();I(b,S)},f=b=>{var S=OX();I(b,S)},d=b=>{var S=pX();I(b,S)},O=b=>{var S=mX();I(b,S)},p=b=>{},m=b=>{},g=b=>{var S=gX();I(b,S)};Ft(r,b=>{t.name==="sort-ascending"?b(s):t.name==="sort-descending"?b(o,1):t.name==="align-none"?b(l,2):t.name==="align-left"?b(a,3):t.name==="align-center"?b(c,4):t.name==="align-right"?b(h,5):t.name==="move-up"?b(u,6):t.name==="move-right"?b(f,7):t.name==="move-down"?b(d,8):t.name==="move-left"?b(O,9):t.name==="duplicate"?b(p,10):t.name==="clear"?b(m,11):t.name==="remove"&&b(g,12)})}I(i,e)}var wX=ot('<div class="tbl-menu-item-text"><!></div>');function Xe(i,t){var e=wX(),n=Ue(e);$r(n,()=>t.children),I(i,e)}var SX=ot('<div class="tbl-menu-separator"></div>');function ga(i){var t=SX();I(i,t)}var vX=ot('<div class="tbl-select-all-overlay" aria-hidden="true"></div>');function xX(i){var t=vX();I(i,t)}const yX=new Set([bt.c,bt.v,bt.x]);function kX(i,t){return yX.has(i.key)&&i[lR(t)]}const QX=[bt.backspace,bt.delete],$X=new Set(QX);function CX({key:i}){return $X.has(i)?i:void 0}function PX(i){return/^F\d+$/.test(i)}const TX=new Set([bt.alt,bt.escape,bt.enter,bt.shift]);function AX({metaKey:i,ctrlKey:t,key:e}){return!t&&!i&&!TX.has(e)&&!PX(e)}function RX(i,t){t.selection.isCell()||av({tableState:t,event:i})}function ZX(i,t){t.selection.isCell()||cv({tableState:t,event:i})}function XX(i,t){t.selection.isCell()||Yd({tableState:t,event:i})}function EX(i,t){if(L(i.target)&&L(uv(i.target))){i.preventDefault();return}if(!t.interactive||t.selection.isCell())return;const e=Ov(i);if(L(e)){sh.navigate({tableState:t,key:e,event:i,position:{left:!0,top:!0,right:!0,bottom:!0}});return}const n=CX(i);if(L(n)){lv({tableState:t,event:i});return}if(t.activeTable&&L(t.activeCell)&&AX(i)){t.activeTable=!1,t.anchorCell=t.activeCell;const r=t.table.cellAt(t.activeCell).length;t.selectionValue={cell:t.activeCell,section:{head:r,anchor:r}},t.outlinedSection=rt.ofCell(t.activeCell);return}kX(i,t.window)||dk(t.rootEditor,i,"editor")&&i.preventDefault()}function Bd(i){return i.buttons===1}function mv(i,t){return t.setPointerCapture(i.pointerId),()=>t.releasePointerCapture(i.pointerId)}class oh{constructor({offset:t,maxScroll:e,boundaryElement:n,scrollElement:r}){C(this,"offset");C(this,"maxScroll");C(this,"boundaryElement");C(this,"scrollElement");C(this,"scroll");C(this,"handle");C(this,"xAmount");C(this,"yAmount");const s=this.scrollInternal.bind(this);this.scroll=()=>{this.handle=requestAnimationFrame(s)},this.xAmount=0,this.yAmount=0,this.offset=t??0,this.maxScroll=e,this.boundaryElement=n,this.scrollElement=r}updatePosition(t,e){const n=this.boundaryElement.x.getBoundingClientRect();t<n.left+this.offset?this.xAmount=-ce(this.offset+(n.left-t),{max:this.maxScroll}):t>n.right-this.offset?this.xAmount=ce(this.offset-(n.right-t),{max:this.maxScroll}):this.xAmount=0;const r=this.boundaryElement.y.getBoundingClientRect();e<r.top+this.offset?this.yAmount=-ce(this.offset+(r.top-e),{max:this.maxScroll}):e>r.bottom-this.offset?this.yAmount=ce(this.offset-(r.bottom-e),{max:this.maxScroll}):this.yAmount=0,V(this.handle)&&(this.xAmount!==0||this.yAmount!==0)&&this.scroll()}destroy(){L(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(t){return new oh(t)}}class yc{constructor({start:t,size:e}){C(this,"start");C(this,"size");this.start=t,this.size=e}get mid(){return this.start+this.size/2}get end(){return this.start+this.size}static of(t){return new yc(t)}}var kc;(i=>{function t(e,n){return qd.of(e,n)}i.of=t})(kc||(kc={}));class qd{constructor(t,e){C(this,"rows");C(this,"cols");C(this,"firstRowIndex",0);C(this,"firstColIndex",0);const n=[...t.querySelectorAll("tr:first-child > th")],r=[...t.querySelectorAll("tr > th:first-child,tr > td:first-child")];this.rows=r.map((s,o)=>{const{top:l,height:a}=hg(s,e),c=0;return yc.of({start:l+c,size:a-c})}),this.cols=n.map((s,o)=>{const{left:l,width:a}=hg(s,e),c=o===0?1:0;return yc.of({start:l+c,size:a-c})})}rowsOrCols(t){return t==="row"?this.rows:this.cols}rowAt(t){return this.rows[t]}colAt(t){return this.cols[t]}rowOrColAt(t,e){return t==="row"?this.rowAt(e):this.colAt(e)}get firstRow(){return this.rows[this.firstRowIndex]}get firstCol(){return this.cols[this.firstColIndex]}firstRowOrCol(t){return t==="row"?this.firstRow:this.firstCol}get lastRow(){return this.rows[this.lastRowIndex]}get lastCol(){return this.cols[this.lastColIndex]}lastRowOrCol(t){return t==="row"?this.lastRow:this.lastCol}firstRowOrColIndex(t){return 0}get lastRowIndex(){return this.rowCount-1}get lastColIndex(){return this.colCount-1}lastRowOrColIndex(t){return t==="row"?this.lastRowIndex:this.lastColIndex}get rowCount(){return this.rows.length}get colCount(){return this.cols.length}get minRowSize(){return Oc(...this.rows.map(t=>t.size))}get minColSize(){return Oc(...this.cols.map(t=>t.size))}moveRowOrColAt(t,{fromIndex:e,toIndex:n}){if(e===n)return;const r=this.rowsOrCols(t),s=r[e];if(e<n){for(const o of Qn({start:e,endExclusive:n}))r[o]=r[o+1],r[o].start-=s.size;s.start=r[n].start+r[n].size}else{for(const o of Qn({start:e,endExclusive:n}))r[o]=r[o-1],r[o].start+=s.size;s.start=r[n].start-s.size}r[n]=s}lastCellBeforePosition(t){const e=this.rows.map(r=>r.start).findLastIndex(r=>r<t.y),n=this.cols.map(r=>r.start).findLastIndex(r=>r<t.x);return{row:e===-1?0:e,col:n===-1?0:n}}static of(t,e){return new qd(t,e)}}function hg(i,t){const{top:e,left:n,width:r,height:s}=i.getBoundingClientRect();return{top:e+t.y,left:n+t.x,width:r,height:s}}class vl{constructor({tableState:t,cellLocation:e}){C(this,"tableState");C(this,"tableMeasurement");C(this,"autoScroller");C(this,"shouldAutoScroll");C(this,"removeEventListeners");C(this,"currentCell");this.tableState=t,this.currentCell=e,this.autoScroller=oh.of({offset:10,maxScroll:32,boundaryElement:{x:t.scrollElement,y:t.rootScrollElement},scrollElement:{x:t.scrollElement,y:t.rootScrollElement}}),this.shouldAutoScroll=V5({delayMillis:500}),this.tableMeasurement=kc.of(t.tableElement,{x:t.scrollOffsetX,y:t.scrollOffsetY})}start(){this.tableState.activeCell=this.currentCell,this.tableState.anchorCell=this.currentCell,this.tableState.outlinedSection=rt.ofCell(this.currentCell),this.tableState.outline={outlined:!1},this.removeEventListeners=Cr(Et(this.tableState.window,"pointermove",t=>this.drag(t)),Et(this.tableState.window,"pointerup",()=>this.end()),Et(this.tableState.window,"pointerleave",()=>this.end()))}resizeAndContinue(t){t.preventDefault(),V(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.currentCell),this.expandOrContract(this.currentCell),this.tableState.outline={outlined:!0},this.removeEventListeners=Cr(Et(this.tableState.window,"pointermove",e=>this.drag(e)),Et(this.tableState.window,"pointerup",()=>this.end()),Et(this.tableState.window,"pointerleave",()=>this.end()))}drag(t){if(!Bd(t)){this.end();return}t.preventDefault(),this.shouldAutoScroll()&&this.autoScroller.updatePosition(t.clientX,t.clientY);const e=this.tableMeasurement.lastCellBeforePosition({x:t.clientX+this.tableState.scrollOffsetX,y:t.clientY+this.tableState.scrollOffsetY});Pr(e,this.currentCell)||(this.currentCell=e,this.tableState.outline={outlined:!0},this.expandOrContract(e))}end(){var t;(t=this.removeEventListeners)==null||t.call(this),this.autoScroller.destroy(),this.tableState.outline=void 0}expandOrContract(t){this.tableState.focusTable();const[e,n]=t.row<=this.tableState.anchorCell.row?[t.row,this.tableState.anchorCell.row]:[this.tableState.anchorCell.row,t.row],[r,s]=t.col<=this.tableState.anchorCell.col?[t.col,this.tableState.anchorCell.col]:[this.tableState.anchorCell.col,t.col];this.tableState.outlinedSection=rt.of({row:{start:e,endExclusive:n+1},col:{start:r,endExclusive:s+1}}),this.tableState.activeCell=t}static startOutline(t){new vl(t).start()}static resizeAndContinueOutline(t){new vl(t).resizeAndContinue(t.event)}}function LX(i,t){Uc(t.window)&&(t.hoveredCell=i)}function MX(i){Uc(i.window)&&(i.hoveredCell=void 0)}function zX(i,t,e){if(!(!e.interactive||!Bd(i)))if(i.shiftKey){if(e.selection.isCell()&&Pr(t,e.selection.cell))return;vl.resizeAndContinueOutline({event:i,tableState:e,cellLocation:t})}else vl.startOutline({event:i,tableState:e,cellLocation:t})}const _X=new Intl.Collator(navigator.language,{numeric:!0,sensitivity:"base"});function ug(i,t){return _X.compare(i,t)}function IX({metaKey:i,shiftKey:t,altKey:e,ctrlKey:n,key:r}){return r===bt.escape&&!t&&!e&&!i&&!n}class Nd{constructor({tableState:t,handle:e,point:n}){C(this,"tableState");C(this,"handle");C(this,"point");C(this,"removeEventListeners");this.tableState=t,this.handle=e,this.point=n}get rowOrCol(){return this.handle.location}get index(){return this.handle.index}open(){const t=this.tableState.document.body;this.removeEventListeners=Cr(Et(t,"pointerdown",o=>{o.preventDefault(),(V(o.target)||!YS(this.tableState.menuRootElement,o.target))&&this.close()}),Et(t,"wheel",o=>o.preventDefault(),{passive:!1}),Et(t,"keydown",o=>{o.preventDefault(),IX(o)&&this.close()})),this.tableState.focusTable(),this.tableState.activeHandle={state:"active",handle:this.handle},this.tableState.outlinedSection=rt.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}});const e=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=e,this.tableState.anchorCell=e;const n=this.index!==this.tableState.table.firstRowOrColIndex(this.rowOrCol),r=this.index!==this.tableState.table.lastRowOrColIndex(this.rowOrCol);let s=!1;n?s=r?!0:"backward":r&&(s="forward"),this.tableState.menu={type:this.rowOrCol,capabilities:{addable:!0,alignable:this.rowOrCol==="col",clearable:!0,duplicatable:!0,moveable:s,removable:!this.tableState.table.hasSingleRowOrCol(this.rowOrCol),sortable:this.rowOrCol==="col"},clickAdd:o=>this.clickAdd(o),clickAlign:o=>this.clickAlign(o),clickClear:()=>this.clickClear(),clickDuplicate:()=>this.clickDuplicate(),clickMove:o=>this.clickMove(o),clickRemove:()=>this.clickRemove(),clickSort:o=>this.clickSort(o),computeTranslation:o=>this.computeTranslation(o)}}close(){var t;(t=this.removeEventListeners)==null||t.call(this),this.tableState.menu=void 0,this.tableState.activeHandle=void 0}async computeTranslation(t){const e=await JT({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})},t,{middleware:[FT({allowedPlacements:this.rowOrCol==="row"?["right-start","right-end"]:["right-start","right"]}),KT({crossAxis:!0})]}),n=wo(t);return{x:xc(e.x,n),y:xc(e.y,n)}}clickAdd(t){var e;if(this.tableState.table.addEmptyRowsOrColsAt(this.rowOrCol,{index:t==="before"?this.index:this.index+1,count:1}),t==="after"){this.tableState.outlinedSection=(e=this.tableState.outlinedSection)==null?void 0:e.shift(this.rowOrCol,"forward");const n=Fh(this.rowOrCol,this.tableState.activeCell,"forward");this.tableState.activeCell=n,this.tableState.anchorCell=n}this.close()}clickAlign(t){this.tableState.table.setAlignmentAt(this.index,t),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(t){var n;this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:t==="backward"?this.index-1:this.index+1}),this.tableState.outlinedSection=(n=this.tableState.outlinedSection)==null?void 0:n.shift(this.rowOrCol,t);const e=Fh(this.rowOrCol,this.tableState.activeCell,t);this.tableState.activeCell=e,this.tableState.anchorCell=e,this.close()}clickRemove(){var t;if(this.tableState.table.removeRowsOrColsAt(this.rowOrCol,{index:this.index,count:1}),!this.tableState.table.hasRowOrColAt(this.rowOrCol,this.index)){this.tableState.outlinedSection=(t=this.tableState.outlinedSection)==null?void 0:t.shift(this.rowOrCol,"backward");const e=Fh(this.rowOrCol,this.tableState.activeCell,"backward");this.tableState.activeCell=e,this.tableState.anchorCell=e}this.close()}clickSort(t){this.tableState.table.sortByColAt(this.index,t==="ascending"?(e,n)=>ug(e.toString(),n.toString()):(e,n)=>ug(n.toString(),e.toString())),this.close()}static showMenu(t){new Nd(t).open()}}class Gd{constructor({rowOrCol:t,index:e,position:n,subject:r,tableElement:s,scrollOffsetX:o,scrollOffsetY:l}){C(this,"coordinate");C(this,"initialIndex");C(this,"size");C(this,"initialPosition");C(this,"minBound");C(this,"maxBound");C(this,"scrollOffsetX");C(this,"scrollOffsetY");C(this,"subject");C(this,"rowOrCol");C(this,"tableMeasurement");C(this,"currentIndex");C(this,"currentPosition");C(this,"dragged");this.scrollOffsetX=o,this.scrollOffsetY=l;const a=kc.of(s,{x:this.scrollOffsetX(),y:this.scrollOffsetY()});this.rowOrCol=t,this.coordinate=t==="row"?"y":"x",this.initialIndex=e,this.initialPosition=n[this.coordinate],this.minBound=a.firstRowOrCol(this.rowOrCol).start-a.rowOrColAt(this.rowOrCol,e).start,this.maxBound=a.lastRowOrCol(this.rowOrCol).end-a.rowOrColAt(this.rowOrCol,e).end,this.size=a.rowOrColAt(this.rowOrCol,e).size,this.subject=r,this.dragged=!1,this.tableMeasurement=a,this.currentIndex=e,this.currentPosition=n[this.coordinate]}start(){return{cellMovement:t=>this.cellMovement(t)}}drag(t){this.currentPosition=t[this.coordinate];const{currentIndex:e,move:n}=this.calculateDrag();return this.currentIndex=e,this.initialIndex!==this.currentIndex&&(this.dragged=!0),L(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(t){return{border:this.cellBorder(t),state:this.cellState(t),translate:this.cellTranslate(t)}}cellBorder(t){const e=this.isRowOrColExposed(t[this.rowOrCol]),n=this.subject.containsCell(t);return this.rowOrCol==="row"?{top:e,right:!0,bottom:!n||t.row===this.tableMeasurement.lastRowIndex,left:this.tableMeasurement.firstColIndex===t.col}:{top:this.tableMeasurement.firstRowIndex===t.row,right:!n||t.col===this.tableMeasurement.lastColIndex,bottom:!0,left:e}}cellState(t){return this.subject.containsCell(t)?"moving":"shiftable"}cellTranslate(t){const e=this.rowOrColTranslate(t[this.rowOrCol]);return this.rowOrCol==="row"?{x:0,y:e}:{x:e,y:0}}isRowOrColExposed(t){const e=this.reorderIndex(t),n=e===this.tableMeasurement.firstRowOrColIndex(this.rowOrCol),r=e===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(t){if(t===this.initialIndex)return ce(this.currentPosition-this.initialPosition,{min:this.minBound,max:this.maxBound});const e=this.rowOrColShift;return V(e)?0:yn(t,e.range)?e.positionDiff:0}reorderIndex(t){const e=this.rowOrColShift;return V(e)?t:t===this.initialIndex?this.currentIndex:yn(t,e.range)?t+e.indexDiff:t}calculateDrag(){const t=this.tableMeasurement.rowsOrCols(this.rowOrCol),e={name:"current",index:this.currentIndex,mid:t[this.currentIndex].mid},n=this.currentIndex!==this.tableMeasurement.firstRowOrColIndex(this.rowOrCol)?{name:"left",index:this.currentIndex-1,mid:t[this.currentIndex-1].start+t[this.currentIndex].size/2}:void 0,r=this.currentIndex!==this.tableMeasurement.lastRowOrColIndex(this.rowOrCol)?{name:"right",index:this.currentIndex+1,mid:t[this.currentIndex].start+t[this.currentIndex+1].size+t[this.currentIndex].size/2}:void 0,s=RA(ZA([e,n,r]),(o,l)=>nf(this.currentPosition-o.mid)-nf(this.currentPosition-l.mid));return s.name==="current"?{currentIndex:this.currentIndex,move:void 0}:{currentIndex:s.index,move:{fromIndex:this.currentIndex,toIndex:s.index}}}static of(t){return new Gd(t)}}class Ud{constructor({event:t,tableState:e,rowOrCol:n,index:r,onClick:s}){C(this,"tableState");C(this,"rowOrCol");C(this,"index");C(this,"onClick");C(this,"moveTracker");C(this,"subject");C(this,"autoScroller");C(this,"removeEventListeners");this.tableState=e,this.rowOrCol=n,this.index=r,this.subject=rt.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=s,this.autoScroller=oh.of({offset:16,maxScroll:32,boundaryElement:{x:e.scrollElement,y:e.rootScrollElement},scrollElement:{x:e.scrollElement,y:e.rootScrollElement}}),this.moveTracker=Gd.of({subject:this.subject,rowOrCol:n,index:r,position:{x:t.clientX+e.scrollOffsetX,y:t.clientY+e.scrollOffsetY},tableElement:e.tableElement,scrollOffsetX:()=>this.tableState.scrollOffsetX,scrollOffsetY:()=>this.tableState.scrollOffsetY})}start(t){t.preventDefault();const e=this.moveTracker.start();this.tableState.outlinedSection=this.subject,this.tableState.move=e,this.tableState.activeHandle={state:"active",handle:{type:"header",index:this.index,location:this.rowOrCol}};const 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();const r=_d(t.target);this.removeEventListeners=Cr(mv(t,r),Et(r,"pointermove",s=>this.drag(s)),Et(r,"pointerup",()=>this.end()))}drag(t){t.preventDefault(),this.autoScroller.updatePosition(t.clientX,t.clientY),this.tableState.move=this.moveTracker.drag({x:t.clientX+this.tableState.scrollOffsetX,y:t.clientY+this.tableState.scrollOffsetY})}end(){var e;(e=this.removeEventListeners)==null||e.call(this),this.autoScroller.destroy();const t=this.moveTracker.end();if(t.moved){this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:t.toIndex}),this.tableState.outlinedSection=rt.of(this.rowOrCol==="row"?{row:{start:t.toIndex,endExclusive:t.toIndex+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:t.toIndex,endExclusive:t.toIndex+1}});const n=this.rowOrCol==="row"?{row:t.toIndex,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:t.toIndex};this.tableState.activeCell=n,this.tableState.anchorCell=n}this.tableState.move=void 0,this.tableState.activeHandle=void 0,!t.moved&&!t.dragged&&this.onClick()}static startMove(t){new Ud(t).start(t.event)}}function jX(i){return i==="row"?"y":"x"}class Hd{constructor({tableState:t,handle:e,position:n,cellSizePixels:r,dragThresholdPixels:s}){C(this,"tableState");C(this,"type");C(this,"initialHandle");C(this,"initialRowOrColCount");C(this,"initialPosition");C(this,"initialOutlinedSection");C(this,"initialActiveCell");C(this,"initialAnchorCell");C(this,"cellSizePixels");C(this,"dragThresholdPixels");C(this,"dragged");this.tableState=t,this.type=this.handleToType(e),this.initialHandle=e,this.initialPosition=n,this.initialRowOrColCount={row:t.table.rowCount,col:t.table.colCount},this.initialActiveCell=t.activeCell,this.initialAnchorCell=t.anchorCell,this.initialOutlinedSection=t.outlinedSection,this.cellSizePixels=r,this.dragThresholdPixels=s,this.dragged=!1}start(){return{activeHandle:{state:"active",handle:this.initialHandle}}}drag(t){return this.dragged=!0,this.calculateDrag(t)}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");const t=this.calculateClickRowOrCol("row"),e=this.calculateClickRowOrCol("col");return{operation:{row:t.operation.row,col:e.operation.col},activeHandle:t.activeHandle,activeCell:L(t.activeCell)&&L(e.activeCell)?{row:t.activeCell.row,col:e.activeCell.col}:void 0,anchorCell:L(t.anchorCell)&&L(e.anchorCell)?{row:t.anchorCell.row,col:e.anchorCell.col}:void 0,outlinedSection:L(t.outlinedSection)&&L(e.outlinedSection)?rt.of({row:t.outlinedSection.row,col:e.outlinedSection.col}):void 0}}calculateClickRowOrCol(t){const e=this.type==="table"?this.tableState.table.lastRowOrColIndex(t)+1:this.initialHandle.index;return{operation:{[t]:{action:"add",index:e,count:1}},activeHandle:this.type==="table"?void 0:{state:"hover",handle:{type:"border",location:this.handleLocationAt(e),index:e}},...this.calculateCellMovement(t,1)}}calculateDrag(t){if(this.type!=="table")return this.calculateDragRowOrCol(this.type,t);if(this.initialHandle.location==="right")return this.calculateDragRowOrCol("col",t);if(this.initialHandle.location==="bottom")return this.calculateDragRowOrCol("row",t);const e=this.calculateDragRowOrCol("row",t),n=this.calculateDragRowOrCol("col",t);if(V(e)&&V(n))return;const r=e??this.calculateCellMovement("row",this.rowOrColDiff("row")),s=n??this.calculateCellMovement("col",this.rowOrColDiff("col"));return{operation:{row:e==null?void 0:e.operation.row,col:n==null?void 0:n.operation.col},activeHandle:(e==null?void 0:e.activeHandle)??(n==null?void 0:n.activeHandle),activeCell:L(r.activeCell)&&L(s.activeCell)?{row:r.activeCell.row,col:s.activeCell.col}:void 0,anchorCell:L(r.anchorCell)&&L(s.anchorCell)?{row:r.anchorCell.row,col:s.anchorCell.col}:void 0,outlinedSection:L(r.outlinedSection)&&L(s.outlinedSection)?rt.of({row:r.outlinedSection.row,col:s.outlinedSection.col}):void 0}}calculateDragRowOrCol(t,e){const n=jX(t),r=e.position[n]-this.initialPosition[n],s=zA(r/this.cellSizePixels[t]),o=r%this.cellSizePixels[t]>=this.dragThresholdPixels[t]?1:0,l=this.tableState.table.rowOrColCount(t)-this.initialRowOrColCount[t],a=s+o-l,c=this.type==="table"?this.tableState.table.lastRowOrColIndex(t)+1:this.initialHandle.index+l;if(a!==0)return a>0?this.calculateDragRowOrColMore({rowOrCol:t,start:c,length:a}):this.calculateDragRowOrColLess({rowOrCol:t,start:c,length:Oc(-a,c,this.tableState.table.lastRowOrColIndex(t))})}calculateDragRowOrColLess({rowOrCol:t,start:e,length:n}){let r=0;for(const o of Qn({start:e-1,endExclusive:e-n-1})){if(!this.tableState.table.hasEmptyRowOrColAt(t,o))break;r++}if(r===0)return;const s=e-(r-1)-1;return{operation:{[t]:{action:"remove",index:e-r,count:r}},activeHandle:this.type==="table"?{state:"active",handle:this.initialHandle}:{state:"active",handle:{type:"border",location:this.handleLocationAt(s),index:s}},...this.calculateCellMovement(t,this.rowOrColDiff(t)-r)}}calculateDragRowOrColMore({rowOrCol:t,start:e,length:n}){return{operation:{[t]:{action:"add",index:e,count:n}},activeHandle:{state:"active",handle:this.type==="table"?this.initialHandle:{type:"border",location:this.handleLocationAt(e+n),index:e+n}},...this.calculateCellMovement(t,this.rowOrColDiff(t)+n)}}calculateCellMovement(t,e){var r,s;const n=this.type==="table"?this.initialRowOrColCount[t]:this.initialHandle.index;if(e>=0)return{outlinedSection:(r=this.initialOutlinedSection)==null?void 0:r.addForwardsByRowOrCol(t,{start:n,count:e}),activeCell:L(this.initialActiveCell)?tg(t,this.initialActiveCell,{start:n,count:e}):void 0,anchorCell:L(this.initialAnchorCell)?tg(t,this.initialAnchorCell,{start:n,count:e}):void 0};{const o=-e,l=(s=this.initialOutlinedSection)==null?void 0:s.subtractBackwardsByRowOrCol(t,{start:n,count:o,min:this.tableState.table.firstRowOrColIndex(t)}),a=L(l)?{min:l.startRowOrCol(t),max:l.endRowOrCol(t)}:void 0,c=L(this.initialActiveCell)?eg(t,this.initialActiveCell,{start:n,count:o,boundary:a}):void 0,h=L(this.initialAnchorCell)?eg(t,this.initialAnchorCell,{start:n,count:o,boundary:a}):void 0;return{outlinedSection:l,activeCell:c,anchorCell:h}}}rowOrColDiff(t){return this.tableState.table.rowOrColCount(t)-this.initialRowOrColCount[t]}handleLocationAt(t){if(this.type!=="table")return this.type==="row"&&t===this.tableState.table.firstRowIndex?"top":this.type==="col"&&t===this.tableState.table.firstColIndex?"left":this.type}handleToType(t){return t.type==="table"?"table":t.location==="top"?"row":t.location==="left"?"col":t.location}static of(t){return new Hd(t)}}function DX(i){const t=Sc(i.tableElement,i.table.firstCellLocation),e=LZ(t),{minWidth:n}=getComputedStyle(t),{lineHeight:r,paddingTop:s,paddingBottom:o}=getComputedStyle(e),l=parseFloat(n)+1,a=parseFloat(r)+parseFloat(s)+parseFloat(o)+1;return{width:l,height:a}}class Fd{constructor({event:t,tableState:e,handle:n}){C(this,"tableState");C(this,"resizeTracker");C(this,"removeEventListeners");this.tableState=e;const{width:r,height:s}=DX(e);this.resizeTracker=Hd.of({tableState:this.tableState,handle:n,position:{x:t.clientX,y:t.clientY},cellSizePixels:{row:s,col:r},dragThresholdPixels:{row:s/2,col:r/2}})}start(t){t.preventDefault();const e=this.resizeTracker.start();this.tableState.resize={},this.tableState.activeHandle=e.activeHandle,this.tableState.focusTable(),this.removeEventListeners=Cr(mv(t,this.tableState.tableElement),Et(this.tableState.tableElement,"pointermove",n=>this.drag(n)),Et(this.tableState.tableElement,"pointerup",()=>this.end()))}drag(t){t.preventDefault();const e=this.resizeTracker.drag({position:{x:t.clientX,y:t.clientY}});L(e)&&(this.resizeTable(e.operation),this.tableState.activeHandle=e.activeHandle,this.tableState.activeCell=e.activeCell,this.tableState.anchorCell=e.anchorCell,this.tableState.outlinedSection=e.outlinedSection)}end(){var e;(e=this.removeEventListeners)==null||e.call(this);const t=this.resizeTracker.end();"operation"in t&&(this.resizeTable(t.operation),this.tableState.activeCell=t.activeCell,this.tableState.anchorCell=t.anchorCell,this.tableState.outlinedSection=t.outlinedSection),this.tableState.activeHandle=t.activeHandle,this.tableState.resize=void 0}resizeTable({row:t,col:e}){if(L(t)){const{action:n,index:r,count:s}=t;n==="add"?this.tableState.table.addEmptyRowsAt({row:r,count:s}):this.tableState.table.removeRowsAt({row:r,count:s})}if(L(e)){const{action:n,index:r,count:s}=e;n==="add"?this.tableState.table.addEmptyColsAt({col:r,count:s}):this.tableState.table.removeColsAt({col:r,count:s})}}static startResize(t){new Fd(t).start(t.event)}}function YX(i,t){t.interactive&&(t.activeHandle={state:"hover",handle:i})}function WX(i){i.interactive&&(i.activeHandle=void 0)}function VX(i,t,e){if(e.interactive){if(!Bd(i)){i.preventDefault();return}t.type==="table"||t.type==="border"?Fd.startResize({event:i,handle:t,tableState:e}):t.type==="header"&&Ud.startMove({event:i,rowOrCol:t.location,index:t.index,tableState:e,onClick:()=>Nd.showMenu({handle:t,point:{x:i.clientX,y:i.clientY},tableState:e})})}}function BX(i,t){const e=i.target;if(V(e))return;const n=Vd(e);if(L(n)){YX(n,t);return}const r=Wl(e);if(L(r)){LX(nh(r),t);return}}function qX(i,t){const e=i.target;if(V(e))return;const n=Vd(e);if(L(n)){WX(t);return}const r=Wl(e);if(L(r)){MX(t);return}}function NX(i,t){const e=i.target;if(V(e))return;const n=Vd(e);if(L(n)){VX(i,n,t);return}const r=Wl(e);if(L(r)){zX(i,nh(r),t);return}i.preventDefault()}function GX(i){i.preventDefault()}var UX=ot("<!> <!> <!>",1),HX=ot('<tr class="tbl-table-row"></tr>'),FX=ot('<tbody class="tbl-table-body"></tbody>'),KX=ot("<!> <!>",1),JX=ot("<!> <!>",1),tE=ot("<!> <!> <!>",1),eE=ot("<!> <!>",1),iE=ot("<!> <!>",1),nE=ot("<!> <!>",1),rE=ot("<!> <!>",1),sE=ot("<!> <!> <!> <!> <!>",1),oE=ot("<!> <!>",1),lE=ot("<!> <!>",1),aE=ot("<!> <!> <!>",1),cE=ot("<!> <!>",1),hE=ot("<!> <!>",1),uE=ot("<!> <!> <!>",1),fE=ot("<!> <!>",1),dE=ot("<!> <!>",1),OE=ot("<!> <!>",1),pE=ot("<!> <!> <!> <!> <!> <!> <!>",1),mE=ot('<div class="tbl-table-wrapper"><table class="tbl-table" role="grid" tabindex="-1"><thead class="tbl-table-head"><!></thead><!></table> <!> <!> <!> <!></div>');function gE(i,t){Dn(t,!0);const e=Qf.of({table:()=>t.table,selection:()=>t.selection,scrollElement:()=>t.scrollElement,rootEditor:()=>t.rootEditor,menuRootElement:()=>t.menuRootElement,extensions:()=>t.extensions,markdownConfig:()=>t.markdownConfig,globalKeyBindings:()=>t.globalKeyBindings,selectionType:()=>t.selectionType,lineWrapping:()=>t.lineWrapping,onUndo:()=>t.onUndo,onRedo:()=>t.onRedo,onNavigate:()=>t.onNavigate,onDelete:()=>t.onDelete});th(()=>Cr(Et(e.document,"selectionchange",()=>MZ(e)),Et(e.document.body,"pointerdown",()=>TZ(e),{capture:!0,passive:!0}),Et(e.document.body,"pointerup",()=>AZ(e),{capture:!0,passive:!0}),Et(e.document.body,"pointerleave",()=>RZ(e),{capture:!0,passive:!0}),Et(e.document.body,"copy",x=>ZZ(x,e)),Et(e.document.body,"cut",x=>XZ(x,e)),Et(e.document.body,"paste",x=>EZ(x,e))));var n=mE(),r=Ue(n);{const x=(y,k=N1)=>{var Q=HX();Oa(Q,20,()=>e.table.colIndices,E=>E,(E,W)=>{const X=H(()=>({row:k(),col:W})),D=H(()=>({top:k()===e.table.firstRowIndex,left:W===e.table.firstColIndex})),_=H(()=>e.selection.isCell()&&Pr($(X),e.selection.cell));{let F=H(()=>{var U;return((U=e.outlinedSection)==null?void 0:U.containsOnEdge($(X)))??{top:!1,right:!1,bottom:!1,left:!1}}),G=H(()=>{var U;return(U=e.move)==null?void 0:U.cellMovement($(X))});BZ(E,{get location(){return $(X)},get alignment(){return e.table.alignments[W]},get selected(){return $(_)},get position(){return $(D)},get outline(){return $(F)},get movement(){return $(G)},get win(){return e.window},children:(U,Zt)=>{var zt=UX(),Bt=Xt(zt);Oa(Bt,16,()=>kZ($(X),$(D)),yt=>yt,(yt,Nt)=>{{let re=H(()=>e.cellHandleState($(X),Nt)),be=H(()=>L(e.resize));cg(yt,{get of(){return Nt},get state(){return $(re)},get toggle(){return $(be)}})}});var lt=et(Bt,2);eX(lt,{get hidden(){return $(_)},children:(yt,Nt)=>{var re=zd(),be=Xt(re);R5(be,()=>SZ(e.table.cellAt($(X)),e.highlighter($(X)))),I(yt,re)},$$slots:{default:!0}});var Dt=et(lt,2);{var $e=yt=>{var Nt=()=>e.table.cellAt($(X)),re=pt=>e.table.setCellAt($(X),pt),be=()=>e.selection.cellSection,tt=pt=>{e.selectionValue={cell:$(X),section:pt}};{let pt=H(()=>e.highlighter($(X)));GZ(yt,{get text(){return Nt()},set text(mt){re(mt)},get selection(){return be()},set selection(mt){tt(mt)},get selectionType(){return e.selectionType},get lineWrapping(){return e.lineWrapping},get extensions(){return e.extensions},get markdownConfig(){return e.markdownConfig},get rootEditor(){return e.rootEditor},get globalKeyBindings(){return e.globalKeyBindings},get highlighter(){return $(pt)},onbeforeinput:mt=>HZ(mt,e),ondragstart:mt=>FZ(mt),onkeydown:(mt,At)=>KZ(mt,At,e),onpaste:mt=>JZ(mt,e)})}};Ft(Dt,yt=>{$(_)&&yt($e)})}I(U,zt)},$$slots:{default:!0}})}}),I(y,Q)};var s=Ue(r),o=Ue(s);x(o,()=>e.table.headerRowIndex);var l=et(s);{var a=y=>{var k=FX();Oa(k,20,()=>e.table.dataRowIndices,Q=>Q,(Q,E)=>{x(Q,()=>E)}),I(y,k)},c=H(()=>e.table.hasDataRows());Ft(l,y=>{$(c)&&y(a)})}bc(r,y=>e.tableElement=y,()=>e==null?void 0:e.tableElement)}var h=et(r,2);{var u=x=>{const y=H(()=>e.menu.type==="row"?"row":"column");IZ(x,{get to(){return e.menuRootElement},children:(k,Q)=>{oX(k,{translate:E=>e.menu.computeTranslation(E),children:(E,W)=>{const X=H(()=>{const{addable:tt,alignable:pt,clearable:mt,duplicatable:At,moveable:Yt,removable:Wt,sortable:fe}=e.menu.capabilities;return{addable:tt,alignable:pt,clearable:mt,duplicatable:At,moveable:Yt,removable:Wt,sortable:fe}});var D=pE(),_=Xt(D);{var F=tt=>{var pt=tE(),mt=Xt(pt);Ae(mt,{onclick:()=>Re({action:"sort",direction:"ascending"},e),children:(Wt,fe)=>{var ut=KX(),gt=Xt(ut);Ze(gt,{name:"sort-ascending"});var _t=et(gt,2);Xe(_t,{children:(kt,Ut)=>{var Rt=Te();se(()=>Bi(Rt,`Sort by ${$(y)??""} (A-Z)`)),I(kt,Rt)}}),I(Wt,ut)}});var At=et(mt,2);Ae(At,{onclick:()=>Re({action:"sort",direction:"descending"},e),children:(Wt,fe)=>{var ut=JX(),gt=Xt(ut);Ze(gt,{name:"sort-descending"});var _t=et(gt,2);Xe(_t,{children:(kt,Ut)=>{var Rt=Te();se(()=>Bi(Rt,`Sort by ${$(y)??""} (Z-A)`)),I(kt,Rt)}}),I(Wt,ut)}});var Yt=et(At,2);ga(Yt),I(tt,pt)};Ft(_,tt=>{$(X).sortable&&tt(F)})}var G=et(_,2);{var U=tt=>{var pt=sE(),mt=Xt(pt);Ae(mt,{onclick:()=>Re({action:"align",alignment:"none"},e),children:(ut,gt)=>{var _t=eE(),kt=Xt(_t);Ze(kt,{name:"align-none"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,si)=>{var Wi=Te("Align none");I(Rt,Wi)}}),I(ut,_t)}});var At=et(mt,2);Ae(At,{onclick:()=>Re({action:"align",alignment:"left"},e),children:(ut,gt)=>{var _t=iE(),kt=Xt(_t);Ze(kt,{name:"align-left"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,si)=>{var Wi=Te("Align left");I(Rt,Wi)}}),I(ut,_t)}});var Yt=et(At,2);Ae(Yt,{onclick:()=>Re({action:"align",alignment:"center"},e),children:(ut,gt)=>{var _t=nE(),kt=Xt(_t);Ze(kt,{name:"align-center"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,si)=>{var Wi=Te("Align center");I(Rt,Wi)}}),I(ut,_t)}});var Wt=et(Yt,2);Ae(Wt,{onclick:()=>Re({action:"align",alignment:"right"},e),children:(ut,gt)=>{var _t=rE(),kt=Xt(_t);Ze(kt,{name:"align-right"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,si)=>{var Wi=Te("Align right");I(Rt,Wi)}}),I(ut,_t)}});var fe=et(Wt,2);ga(fe),I(tt,pt)};Ft(G,tt=>{$(X).alignable&&tt(U)})}var Zt=et(G,2);{var zt=tt=>{var pt=aE(),mt=Xt(pt);Ae(mt,{onclick:()=>Re({action:"add",direction:"before"},e),children:(Wt,fe)=>{var ut=oE(),gt=Xt(ut);Ze(gt,{name:"add-before"});var _t=et(gt,2);Xe(_t,{children:(kt,Ut)=>{var Rt=Te();se(()=>Bi(Rt,`Add ${$(y)??""} ${$(y)==="row"?"above":"before"}`)),I(kt,Rt)}}),I(Wt,ut)}});var At=et(mt,2);Ae(At,{onclick:()=>Re({action:"add",direction:"after"},e),children:(Wt,fe)=>{var ut=lE(),gt=Xt(ut);Ze(gt,{name:"add-after"});var _t=et(gt,2);Xe(_t,{children:(kt,Ut)=>{var Rt=Te();se(()=>Bi(Rt,`Add ${$(y)??""} ${$(y)==="row"?"below":"after"}`)),I(kt,Rt)}}),I(Wt,ut)}});var Yt=et(At,2);ga(Yt),I(tt,pt)};Ft(Zt,tt=>{$(X).addable&&tt(zt)})}var Bt=et(Zt,2);{var lt=tt=>{var pt=uE(),mt=Xt(pt);{var At=ut=>{Ae(ut,{onclick:()=>Re({action:"move",direction:"backward"},e),children:(gt,_t)=>{var kt=cE(),Ut=Xt(kt);{let si=H(()=>`move-${$(y)==="row"?"up":"left"}`);Ze(Ut,{get name(){return $(si)}})}var Rt=et(Ut,2);Xe(Rt,{children:(si,Wi)=>{var So=Te();se(()=>Bi(So,`Move ${$(y)??""} ${$(y)==="row"?"up":"left"}`)),I(si,So)}}),I(gt,kt)}})};Ft(mt,ut=>{($(X).moveable==="backward"||$(X).moveable===!0)&&ut(At)})}var Yt=et(mt,2);{var Wt=ut=>{Ae(ut,{onclick:()=>Re({action:"move",direction:"forward"},e),children:(gt,_t)=>{var kt=hE(),Ut=Xt(kt);{let si=H(()=>`move-${$(y)==="row"?"down":"right"}`);Ze(Ut,{get name(){return $(si)}})}var Rt=et(Ut,2);Xe(Rt,{children:(si,Wi)=>{var So=Te();se(()=>Bi(So,`Move ${$(y)??""} ${$(y)==="row"?"down":"right"}`)),I(si,So)}}),I(gt,kt)}})};Ft(Yt,ut=>{($(X).moveable==="forward"||$(X).moveable===!0)&&ut(Wt)})}var fe=et(Yt,2);ga(fe),I(tt,pt)};Ft(Bt,tt=>{$(X).moveable!==!1&&tt(lt)})}var Dt=et(Bt,2);{var $e=tt=>{Ae(tt,{onclick:()=>Re({action:"duplicate"},e),children:(pt,mt)=>{var At=fE(),Yt=Xt(At);Ze(Yt,{name:"duplicate"});var Wt=et(Yt,2);Xe(Wt,{children:(fe,ut)=>{var gt=Te();se(()=>Bi(gt,`Duplicate ${$(y)??""}`)),I(fe,gt)}}),I(pt,At)}})};Ft(Dt,tt=>{$(X).duplicatable&&tt($e)})}var yt=et(Dt,2);{var Nt=tt=>{Ae(tt,{onclick:()=>Re({action:"clear"},e),children:(pt,mt)=>{var At=dE(),Yt=Xt(At);Ze(Yt,{name:"clear"});var Wt=et(Yt,2);Xe(Wt,{children:(fe,ut)=>{var gt=Te();se(()=>Bi(gt,`Clear ${$(y)??""}`)),I(fe,gt)}}),I(pt,At)}})};Ft(yt,tt=>{$(X).clearable&&tt(Nt)})}var re=et(yt,2);{var be=tt=>{Ae(tt,{onclick:()=>Re({action:"remove"},e),children:(pt,mt)=>{var At=OE(),Yt=Xt(At);Ze(Yt,{name:"remove"});var Wt=et(Yt,2);Xe(Wt,{children:(fe,ut)=>{var gt=Te();se(()=>Bi(gt,`Delete ${$(y)??""}`)),I(fe,gt)}}),I(pt,At)}})};Ft(re,tt=>{$(X).removable&&tt(be)})}I(E,D)},$$slots:{default:!0}})},$$slots:{default:!0}})},f=H(()=>L(e.menu));Ft(h,x=>{$(f)&&x(u)})}var d=et(h,2);Oa(d,16,()=>yZ,x=>x,(x,y)=>{{let k=H(()=>{var Q;return kf((Q=e.activeHandle)==null?void 0:Q.handle,y)?e.activeHandle.state:void 0});cg(x,{get of(){return y},get state(){return $(k)}})}});var O=et(d,2);{var p=x=>{DZ(x)},m=H(()=>!e.interactive&&V(e.outline));Ft(O,x=>{$(m)&&x(p)})}var g=et(O,2);{var b=x=>{xX(x)},S=H(()=>e.selection.isAll());Ft(g,x=>{$(S)&&x(b)})}bc(n,x=>e.wrapperElement=x,()=>e==null?void 0:e.wrapperElement),se(x=>$t(n,"data-select-all",x),[()=>gr(e.selection.isAll())]),Mo("mouseover",n,x=>BX(x,e)),Mo("mouseout",n,x=>qX(x,e)),Mo("pointerdown",n,x=>NX(x,e)),fa("dragover",n,x=>GX(x)),Mo("keydown",r,x=>EX(x,e)),fa("copy",r,x=>RX(x,e)),fa("cut",r,x=>ZX(x,e)),fa("paste",r,x=>XX(x,e)),I(i,n),Yn()}MS(["mouseover","mouseout","pointerdown","keydown"]);class Kd extends Ln{constructor(e,n){super();C(this,"tableDescription");C(this,"widgetElement");C(this,"height");C(this,"destroyWidgetElement");this.tableDescription=e;const r=$E(n);if(L(r)){const{widgetElement:s,destroyWidgetElement:o}=this.create(r);this.widgetElement=s,this.destroyWidgetElement=o,this.height=D5(r,s)}else this.widgetElement=void 0,this.destroyWidgetElement=void 0,this.height=Nm}get estimatedHeight(){return this.height}coordsAt(e,n,r){const s=this.tableDescription.source.closestCell(n),o=Sc(e,s);if(V(o))return null;const l=o.getBoundingClientRect();return{top:l.top,right:l.right,bottom:l.bottom,left:l.left}}toDOM(e){if(L(this.widgetElement))return this.widgetElement;const{widgetElement:n,destroyWidgetElement:r}=this.create(e);return this.widgetElement=n,this.destroyWidgetElement=r,e.requestMeasure({read:()=>{this.height=n.getBoundingClientRect().height}}),n}destroy(e){var n;(n=this.destroyWidgetElement)==null||n.call(this),this.destroyWidgetElement=void 0,this.widgetElement=void 0,this.height=Nm}create(e){const n=bl(e.dom).createElement("div");n.className="tbl-table-widget",n.tabIndex=-1,n.addEventListener("pointerdown",O=>{(O==null?void 0:O.target)===n&&O.preventDefault()});const r=this.tableDescription,s=p5(()=>{Kc(()=>{const O=!r.table.text.eq(r.editorTableText),p=!ih(r.selection.value,r.editorSelectionValue);if(!O&&!p)return;const m=O?r.source.applyContent(r.table.text,r.editorTableText):void 0,g=O?new ro(m,r.table.colCount):r.source;let b;if(r.selection.isCell()){const{from:x}=g.cellSpan(r.selection.cell);b={anchor:r.from+x+r.selection.cellSection.anchor,head:r.from+x+r.selection.cellSection.head}}else r.selection.isAll()?b={anchor:r.from,head:r.to}:r.selection.isHidden()&&(b={anchor:r.from+1,head:r.from+1});const S=O?{from:r.from,to:r.to,insert:m}:void 0;r.markSynchronized(),e.dispatch({annotations:Gr("table.edit"),changes:S,selection:b})})}),{extensions:o,markdownConfig:l,globalKeyBindings:a,selectionType:c,lineWrapping:h}=wv(e.state),u=zS(gE,{target:n,props:{table:r.table,selection:r.selection,scrollElement:n,rootEditor:e,extensions:o,markdownConfig:l,globalKeyBindings:a,selectionType:c,lineWrapping:h,menuRootElement:Ck(e,nv).dom,onUndo:()=>id(e),onRedo:()=>Ka(e),onNavigate:O=>{e.dispatch({annotations:Gr("table.navigate"),selection:{anchor:O==="before"?Math.max(0,r.from-1):Math.min(e.state.doc.length,r.to+1)}}),e.focus()},onDelete:()=>{e.dispatch({annotations:Gr("table.delete"),changes:{from:r.from,to:r.to},selection:e.state.selection}),e.focus()}}}),f=()=>{_S(u)},d=Y5(n,({height:O})=>{this.height=O});return{widgetElement:n,destroyWidgetElement:Cr(s,f,d)}}static of(e,n){return new Kd(e,n)}}function bE(i,t){return{widget:Kd.of(i,t),block:!0,inclusive:!0}}function wE(i,t){return K.replace(bE(i,t))}function SE(i,t){const e=new qs;for(const n of i)e.add(n.from,n.to,wE(n,t));return e.finish()}function vE(i){return gv(i)}function xE(i,t){return gv(i,t)}function gv(i,t=[]){const e=[];return kA(St(i),n=>{L1(n)&&e.push({from:i.doc.lineAt(n.from).from,to:i.doc.lineAt(n.to).to})}),{spans:e,formatting:[],complete:Gk(i)}}const yE={create(i){return ba(i)},update(i,t){if(eZ(t))return ba(t.state);if(!t.docChanged&&V(t.selection)&&i.complete)return i;const{tables:e,formatting:n,decorations:r}=i;if(!t.docChanged&&i.complete)return{tables:fg(e,t),formatting:n,decorations:r.map(t.changes),complete:!0};if(tZ(t)||kE(t,e))return ba(t.state);const s=fg(e,t).map(c=>c.span),{complete:o,spans:l,formatting:a}=xE(t.state,s);return mn(s,l,aR)?{complete:o,tables:e,formatting:a,decorations:r.map(t.changes)}:ba(t.state)},provide(i){return z.decorations.from(i,t=>t.decorations)}},bv=mi.define(yE);function ba(i){const{spans:t,formatting:e,complete:n}=vE(i),{doc:r,selection:s}=i,o=t.map(l=>xf.of({span:l,doc:r,selection:s}));return{complete:n,tables:o,formatting:e,decorations:SE(o,i)}}function kE(i,t){return!GS(i)&&t.some(e=>i.changes.touchesRange(e.from,e.to)!==!1)}function fg(i,t){return PA(i,e=>e.applyTransaction(t))}const QE={create(){return{view:void 0}},update(i){return i}},Jd=mi.define(QE);function wv(i){return i.facet(rf)}function uo(i){return i.field(bv)}function $E(i){return i.field(Jd).view}function CE(i){const{handlePosition:t,selectionType:e,lineWrapping:n}=wv(i);return{...Uc(window)?{"data-tbl-hoverable":""}:{},"data-tbl-theme-mode":i.facet(z.darkTheme)?"dark":"light","data-tbl-handle-position":t,"data-tbl-selection-type":e,"data-tbl-line-wrapping":n}}const PE=["undo","redo","select.undo","select.redo"];function TE(i){return PE.some(t=>i.isUserEvent(t))}function AE(i){return Sv(i,"select.search")}function RE(i){return Sv(i,"select")}function ZE(i){return i.isUserEvent("delete.forward")}function XE(i){return i.isUserEvent("delete.backward")}function Sv(i,t){return i.annotation(Lt.userEvent)===t}const EE=({state:i,view:t,transactions:e})=>{t.hasFocus||uo(i).tables.some(n=>n.containsSelection())||e.some(n=>TE(n)||AE(n)&&!dv(t))&&t.focus()},vv=Pt.define(),LE=new Map(NS.map(i=>[i,vv.of(i)]));function xv(i){return LE.get(i)}const ME=(i,t)=>!t||!uo(i).tables.some(e=>e.containsSelection())?null:xv("table.focus"),zE=i=>{const{selection:t,startState:e,docChanged:n}=i;if(V(t)||n||!RE(i)||!hc(t)||!hc(e.selection))return i;const r=e.selection.main,s=t.main;for(const o of uo(e).tables){const l=o.from===s.head,a=o.to===s.head,c=o.from===r.head+1&&o.to===s.head-1,h=o.from===s.head+1&&o.to===r.head-1;let u;if(l?u=o.source.cellSpan(o.table.firstCellLocation).from:c?u=o.source.cellSpan(o.table.firstCellLocation).to:(a||h)&&(u=o.source.cellSpan(o.table.lastCellLocation).to),L(u))return[i,{annotation:Gr("table.navigate"),selection:oA({pos:o.from+u})}]}return i},_E=i=>{const{selection:t,startState:e}=i;if(V(t)||!hc(t))return i;const n=e.selection.main;if(ZE(i)){for(const r of uo(e).tables)if(n.head===r.from-1){const s=r.source.cellSpan(r.table.firstCellLocation).from;return[{selection:{anchor:r.from+s,head:r.from+s}}]}return i}else if(XE(i)){for(const r of uo(e).tables)if(n.head===r.to+1){const s=r.source.cellSpan(r.table.lastCellLocation).to;return[{selection:{anchor:r.from+s,head:r.from+s}}]}return i}else return i};function IE(i,{anchor:t,head:e,goalColumn:n,bidiLevel:r}={}){return P.range(t??i.anchor,e??i.head,n??i.goalColumn,r??i.bidiLevel??void 0)}const jE=i=>{const{selection:t,startState:e,docChanged:n}=i;if(V(t)||n||hc(t))return i;const r=t.ranges.map(s=>{if(s.empty)return s;const o=uo(e).tables,l=dg(s.anchor,o,e.doc.length),a=dg(s.head,o,e.doc.length);return L(l)||L(a)?IE(s,{anchor:l,head:a}):s});return mn(t.ranges,r,(s,o)=>s===o)?i:[i,{annotations:Gr("table.select"),selection:P.create(r,t.mainIndex)}]};function dg(i,t,e){for(const n of t){const r=n.from,s=n.to,o=n.from+1,l=n.to-1;if(i===r||i===o)return Math.max(0,r-1);if(i===s||i===l)return Math.min(e,s+1)}}const DE={"& .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"}},YE={'&[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"}},WE={".cm-tooltip.tbl-menu-tooltip":{border:"none","user-select":"none","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}}},VE={".tbl-blocking-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"transparent",width:"100%",height:"100%"}},BE={"& .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)"}},qE={".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)"}},NE={'&[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"}},GE={".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}},UE={".tbl-menu-item-icon":{"z-index":200,width:"1em",height:"1em","pointer-events":"none","font-size":"var(--tbl-style-menu-font-size)"}},HE={".tbl-menu-item-text":{"z-index":200,"pointer-events":"none","user-select":"none","font-size":"var(--tbl-style-menu-font-size)"}},FE={".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)"}}},KE={".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)"}},JE={".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)"}},tL={".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"}},eL={"& .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)"}},iL={...DE,...WE,...YE,...eL,...VE,...qE,...BE,...NE,...GE,...JE,...FE,...UE,...HE,...KE,...tL},nL=i=>{var e;const t=(e=i.effects.find(n=>n.is(vv)))==null?void 0:e.value;return L(t)?{annotations:Gr(t)}:null},rL=i=>{const t=i.annotation(jd);return L(t)?[xv(H5(t))]:[]};class tO{static of(t){return t.state.field(Jd).view=t,new tO}constructor(){}}function sL(i){return[rf.of(i),bv,Jd,Fe.define(t=>tO.of(t)),z.editorAttributes.compute([rf,z.darkTheme],CE),z.baseTheme(iL),z.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}),z.theme({":where(:root:has(&))":i.style.props}),v0.of(rL),n0.of(nv),J.transactionExtender.of(nL),J.transactionFilter.of(_E),J.transactionFilter.of(zE),J.transactionFilter.of(jE),z.updateListener.of(EE),z.clipboardInputFilter.of(sR),z.focusChangeEffect.of(ME)]}function oL(i){return sL(Z1(i))}const lL=new Set(["about:","blob:","chrome-extension:","chrome:","data:","devtools:","file:","filesystem:","javascript:","view-source:"]);function yv(i,t){try{const e=new URL(t),n=new URL(i,e);return n.protocol==="http:"||n.protocol==="https:"?{kind:"web",url:n.href}:lL.has(n.protocol)?{kind:"browser-local",url:n.href}:{kind:"application",url:n.href}}catch{return{kind:"invalid"}}}const kv="cm-md-mark",Qv="cm-md-inline-code",$f="cm-md-list-item",Cf="cm-md-list-bullet",$v="cm-md-blockquote-line",Cv="cm-md-fenced-line",Pv="cm-md-hr",Tv="cm-md-task-checkbox",Av="cm-md-heading-1",Rv="cm-md-heading-2",eO="cm-md-link",Zv="cm-md-tag",Xv="cm-md-list-indent-source",Og="1.2em",aL="0.62em",Ro=K.replace({}),qn=K.mark({class:kv}),cL=K.mark({class:Xv}),hL=K.mark({class:Qv}),uL=K.line({class:Cf}),fL=K.line({class:$v}),dL=K.line({class:Cv}),OL=K.line({class:Av}),pL=K.line({class:Rv}),mL=K.mark({class:Zv});class gL extends Ln{toDOM(){const t=document.createElement("hr");return t.className=Pv,t}eq(t){return!0}ignoreEvent(){return!0}}const bL=K.replace({widget:new gL});class wL extends Ln{constructor(e,n,r){super();C(this,"checked");C(this,"from");C(this,"to");this.checked=e,this.from=n,this.to=r}eq(e){return e.checked===this.checked&&e.from===this.from&&e.to===this.to}toDOM(e){const n=document.createElement("input");return n.type="checkbox",n.checked=this.checked,n.className=Tv,n.tabIndex=-1,n.addEventListener("mousedown",r=>{r.preventDefault()}),n.addEventListener("change",()=>{const r=this.checked?"[ ]":"[x]";e.dispatch({changes:{from:this.from,to:this.to,insert:r}})}),n}ignoreEvent(e){return e.type!=="click"&&e.type!=="change"&&e.type!=="mousedown"}}const SL=new Set(["EmphasisMark","LinkMark","URL"]),vL=new Set(["HeaderMark","QuoteMark"]),pg=/(^|\s)(#[\p{L}\p{N}_/-]+)/gu,xL=/[/.,;:!?]+$/u,yL=new RegExp("\\p{L}","u"),kL=new Set(["InlineCode","FencedCode","URL","Link"]);function QL(i,t,e,n,r,s){return vL.has(i)?{kind:"block",contextFrom:r,contextTo:s}:i==="CodeMark"?t==="InlineCode"&&e!==null&&n!==null?{kind:"inline",contextFrom:e,contextTo:n}:null:SL.has(i)?e===null||n===null?null:{kind:"inline",contextFrom:e,contextTo:n}:null}function gn(i,t,e,n){return i<=n&&t>=e}function $L(i,t,e,n){const r=i.doc.lineAt(n);return gn(t,e,r.from,r.to)}function CL(i,t,e,n){return t.kind==="inline"?!gn(e,n,t.contextFrom,t.contextTo):!$L(i,e,n,t.contextFrom)}function PL(i){let t=i.firstChild;for(;t;){if(t.name==="TaskMarker")return!0;if(t.name==="Task"){let e=t.firstChild;for(;e;){if(e.name==="TaskMarker")return!0;e=e.nextSibling}}t=t.nextSibling}return!1}function TL(i){let t=i.parent;for(;t;){if(t.name==="ListItem")return t;t=t.parent}return null}function Hn(i,t){let e=i.firstChild;for(;e;){if(e.name===t)return e;e=e.nextSibling}return null}function mg(i,t){const e=[];let n=t.firstChild;for(;n;)n.name==="CodeMark"&&e.push(n),n=n.nextSibling;if(e.length>=2)return{from:t.from,to:e[e.length-1].to,closed:!0};const r=i.doc.lineAt(t.from);return{from:r.from,to:r.to,closed:!1}}function Ev(i,t){let e=t.to;for(;e<i.doc.length&&i.doc.sliceString(e,e+1)===" ";)e+=1;return{from:t.from,to:e}}function Kh(i,t){return{from:i.doc.lineAt(t.from).from,to:Ev(i,t).to}}function Jh(i,t){return Ev(i,t)}function gg(i,t,e){const n=Hn(t,"ListMark"),r=n?i.doc.lineAt(n.from).from:e.from;let s=e.to;for(;s<i.doc.length&&i.doc.sliceString(s,s+1)===" ";)s+=1;return{from:r,to:s}}function tu(i,t,e){const n=i.doc.lineAt(t.from);n.from<t.from&&e.push(cL.range(n.from,t.from))}function AL(i,t,e){let n=0;for(let r=t;r<e;r+=1)n+=i.doc.sliceString(r,r+1)===" "?2:1;return n}function RL(i){return K.line({class:$f,attributes:{style:`--cm-md-list-indent: ${i.prefixRevealed?0:i.indentColumns};`}})}function bg(i,t,e,n,r){let s=t;for(;s<=e;){const o=i.doc.lineAt(s);if(r.push(n.range(o.from)),o.to>=e)break;s=o.to+1}}function ZL(i,t,e,n){const r=Hn(t,"ListMark"),s=i.doc.lineAt(r?r.from:t.from).from,o=r?AL(i,s,r.from):0;let l=t.from;for(;l<=t.to;){const a=i.doc.lineAt(l),c=a.from===s,h=/^\s/.test(a.text);if(c||h){const u=e.get(a.from),f={indentColumns:o,prefixRevealed:c&&n};u===void 0||o>u.indentColumns?e.set(a.from,f):o===u.indentColumns&&f.prefixRevealed&&e.set(a.from,{...u,prefixRevealed:!0})}if(a.to>=t.to)break;l=a.to+1}}function XL(i,t){let e=i.resolveInner(t,1);for(;e;){if(kL.has(e.name)||e.name.startsWith("Table"))return!0;e=e.parent}return!1}function EL(i,t){const e=/^( {0,3})(#{1,6})(?:\s|$)/.exec(i);if(!e)return!1;const n=e[1]??"",r=e[2]??"",s=n.length,o=s+r.length;return t>=s&&t<o}function LL(i,t,e){for(let n=1;n<=i.doc.lines;n+=1){const r=i.doc.line(n);pg.lastIndex=0;let s;for(;(s=pg.exec(r.text))!==null;){const o=s[1]??"",a=(s[2]??"").replace(xL,"");if(a.length<=1||!yL.test(a))continue;const c=r.from+s.index+o.length,h=c+a.length;EL(r.text,c-r.from)||XL(t,c)||e.push(mL.range(c,h))}}}function wg(i,t,e,n){const r=[],s=new Map,o=new Set,l=i.selection.main,a=n?Math.min(l.from,l.to):-1,c=n?Math.max(l.from,l.to):-1;e.iterate({from:0,to:i.doc.length,enter:h=>{var p,m;if(h.name==="Table"||h.name.startsWith("Table"))return!1;const u=h.node.parent,f=(u==null?void 0:u.name)??null;let d=h.to;(h.name==="HeaderMark"||h.name==="QuoteMark")&&i.doc.sliceString(d,d+1)===" "&&(d+=1);const O=QL(h.name,f,(u==null?void 0:u.from)??null,(u==null?void 0:u.to)??null,h.from,d);if(O){const g=CL(i,O,a,c)?Ro:qn;r.push(g.range(h.from,d))}if(h.name==="ListMark"){const g=h.node.parent;if(g&&g.name==="ListItem"){const b=PL(g),S=((p=g.parent)==null?void 0:p.name)==="OrderedList";if(!b&&!S){const x=Kh(i,h.node),y=Jh(i,h.node);gn(a,c,x.from,x.to)?(tu(i,h.node,r),r.push(qn.range(y.from,y.to))):r.push(Ro.range(x.from,x.to))}else if(S){const x=i.doc.lineAt(h.node.from),y=Kh(i,h.node);x.from<h.node.from&&(gn(a,c,y.from,y.to)?tu(i,h.node,r):r.push(Ro.range(x.from,h.node.from))),r.push(qn.range(h.node.from,h.node.to))}}}if(h.name==="InlineCode"){const g=h.node.firstChild,b=h.node.lastChild;g&&b&&g!==b&&g.name==="CodeMark"&&b.name==="CodeMark"&&g.to<b.from&&r.push(hL.range(g.to,b.from))}if(h.name==="ListItem"){const g=Hn(h.node,"ListMark"),b=Hn(h.node,"Task"),S=Hn(h.node,"TaskMarker")??(b?Hn(b,"TaskMarker"):null),x=S!==null,y=((m=h.node.parent)==null?void 0:m.name)==="OrderedList";let k=!1;if(g){const Q=S?gg(i,h.node,S):Kh(i,g);k=gn(a,c,Q.from,Q.to)}if(ZL(i,h.node,s,k),!x&&!y&&g&&!k){const Q=i.doc.lineAt(h.from);o.add(Q.from)}}else if(h.name==="Blockquote")bg(i,h.from,h.to,fL,r);else if(h.name==="ATXHeading1"){const g=i.doc.lineAt(h.from);r.push(OL.range(g.from))}else if(h.name==="ATXHeading2"){const g=i.doc.lineAt(h.from);r.push(pL.range(g.from))}else if(h.name==="FencedCode"){const g=mg(i,h.node);bg(i,g.from,g.to,dL,r)}if(h.name==="Link"){let g=null,b=null,S=null,x=h.node.firstChild;for(;x;)x.name==="LinkMark"?g===null?g=x:b=x:x.name==="URL"&&(S=x),x=x.nextSibling;if(g&&b&&S&&g.to<b.from){const y=i.doc.sliceString(S.from,S.to),k=K.mark({class:eO,tagName:"a",attributes:{"data-href":y}});r.push(k.range(g.to,b.from))}}if(h.name==="CodeMark"&&f==="FencedCode"){const g=h.node.parent;if(g){const b=mg(i,g);if(b.closed){const S=gn(a,c,b.from,b.to)?qn:Ro;r.push(S.range(h.from,h.to))}else r.push(qn.range(h.from,h.to))}}if(h.name==="HorizontalRule"){const g=i.doc.lineAt(h.from);g.to>g.from&&!gn(a,c,g.from,g.to)&&r.push(bL.range(g.from,g.to))}if(h.name==="TaskMarker"){const g=TL(h.node),b=g?Hn(g,"ListMark"):null,S=g?gg(i,g,h.node):{from:h.from,to:h.to};if(gn(a,c,S.from,S.to)){if(b){const y=Jh(i,b);tu(i,b,r),r.push(qn.range(y.from,y.to))}r.push(qn.range(h.from,h.to))}else{if(b){const E=Jh(i,b),W=i.doc.lineAt(b.from).from;r.push(Ro.range(W,E.to))}const y=i.doc.sliceString(h.from,h.to),k=y==="[x]"||y==="[X]",Q=K.replace({widget:new wL(k,h.from,h.to)});r.push(Q.range(h.from,h.to))}}}});for(const[h,u]of s)r.push(RL(u).range(h));for(const h of o)r.push(uL.range(h));return LL(i,e,r),K.set(r,!0)}const ML=Fe.fromClass(class{constructor(i){C(this,"decorations");this.decorations=wg(i.state,i.visibleRanges,St(i.state),i.hasFocus)}update(i){(i.docChanged||i.selectionSet||i.viewportChanged||i.focusChanged||St(i.state)!==St(i.startState))&&(this.decorations=wg(i.state,i.view.visibleRanges,St(i.state),i.view.hasFocus))}},{decorations:i=>i.decorations}),zL=z.theme({"&":{fontFamily:"var(--font-sans)",fontSize:"calc(var(--text-base) + 0.5px)",lineHeight:"1.5"},".cm-scroller":{fontFamily:"inherit",fontSize:"inherit",lineHeight:"inherit"},".cm-content":{fontFamily:"inherit",fontSize:"inherit",lineHeight:"inherit",padding:"1.5rem 1rem"},[`.${Xv}`]:{fontFamily:"var(--font-mono)"},[`.${kv}`]:{fontFamily:"var(--font-mono)",fontSize:"0.9em"},[`.${Av}`]:{fontSize:"1.3em"},[`.${Rv}`]:{fontSize:"1.1em"},[`.${Qv}`]:{fontFamily:"var(--font-mono)",fontSize:"0.92em",padding:"1px 4px",borderRadius:"3px"},[`.${Zv}`]:{borderRadius:"var(--radius-pill)",padding:"0 0.35em",fontWeight:"600",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone"},[`.${$f}`]:{paddingLeft:`calc(0.5rem + var(--cm-md-list-indent, 0) * ${aL})`},[`.${$f}.${Cf}`]:{borderLeft:`${Og} solid transparent`},[`.${Cf}::before`]:{content:"'•'",marginLeft:`calc(-1 * ${Og})`,fontFamily:"var(--font-mono)",fontSize:"0.9em",paddingRight:"0.5rem"},[`.${$v}`]:{borderLeft:"3px solid transparent",paddingLeft:"1rem",marginLeft:"0.25rem"},[`.${Cv}`]:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:"0.92em",paddingLeft:"0.75em"},[`.${Pv}`]:{display:"inline-block",verticalAlign:"middle",border:"none",borderTop:"1px solid transparent",margin:0,width:"100%"},[`.${Tv}`]:{margin:"0 0.4em 0 0",cursor:"default",verticalAlign:"middle"},[`a.${eO}`]:{textDecoration:"underline",textUnderlineOffset:"0.15em",cursor:"pointer"}}),_L=4;function Lv(i){return i instanceof Element?i.closest(`a.${eO}`):null}function IL(i){const t=i.getAttribute("data-href");if(t===null)return null;try{return new URL(t,window.document.baseURI).href}catch{return null}}function Mv(){return window.__televisionContentBridge}function jL(i){const t={type:"navigation-request",url:i},e=Mv();if(e){e.postToHost(t);return}window.parent.postMessage(t,"*")}function DL(i){const t=Mv();if(t!=null&&t.openApplicationLink){t.openApplicationLink(i);return}window.location.href=i}function YL(i,t){return Math.hypot(t.clientX-i.x,t.clientY-i.y)>_L}let zr=null;function Sg(i){const t=Lv(i.target);if(!t||i.altKey)return zr=null,!1;const e=zr;if(zr=null,!e||e.anchor!==t)return!1;if(i.preventDefault(),YL(e,i))return!0;const n=yv(e.url,window.document.baseURI);return n.kind==="application"?DL(n.url):n.kind==="web"&&e.openExternally?window.open(n.url,"_blank","noopener,noreferrer"):n.kind==="web"&&jL(n.url),!0}const Ea={mousedown(i){const t=Lv(i.target);if(zr=null,!t||i.button!==0&&i.button!==1||i.altKey)return!1;const e=IL(t);return e===null||i.button===1&&yv(e,window.document.baseURI).kind!=="application"?!1:(zr={anchor:t,url:e,openExternally:i.metaKey||i.ctrlKey,x:i.clientX,y:i.clientY},i.preventDefault(),!0)},click(i){return i.button!==0?!1:Sg(i)},auxclick(i){return i.button!==1?!1:Sg(i)}},WL=z.domEventHandlers(Ea),Pf=/^(\d+)([.)])(\s|$)/;function VL(i,t){const e=[];let n=[],r=0;const s=a=>{o&&t.some(c=>c.from<=a&&c.to>=r)&&e.push(...n),n=[]};let o=!1,l=1;for(let a=1;a<=i.doc.lines;a+=1){const c=i.doc.line(a),h=Pf.exec(c.text);h?(o||(o=!0,l=1,r=c.from),parseInt(h[1],10)!==l&&n.push({from:c.from,to:c.from+h[1].length,insert:String(l)}),l+=1):c.text===""&&(s(c.from-1),o=!1)}return s(i.doc.length),e}const vg=ei.define(),BL=J.transactionFilter.of(i=>{if(!i.docChanged||i.annotation(vg)||!i.isUserEvent("input")&&!i.isUserEvent("delete"))return i;const t=[];i.changes.iterChangedRanges((n,r,s,o)=>{const l=i.state.doc.lineAt(s),a=Pf.test(i.startState.doc.lineAt(n).text)&&!Pf.test(l.text);t.push({from:l.from,to:a&&l.number<i.state.doc.lines?i.state.doc.line(l.number+1).to:i.state.doc.lineAt(Math.max(s,o-1)).to})});const e=VL(i.state,t);return e.length===0?i:[i,{changes:Vt.of(e,i.state.doc.length),annotations:vg.of(!0),sequential:!0}]}),qL=/^(\s*)([-*]|\d+[.)])(\s\[[ xX]\])?\s$/,NL=i=>{const{state:t}=i,e=t.selection.main;if(e.from!==e.to)return!1;const n=t.doc.lineAt(e.from),r=n.text.slice(0,e.from-n.from);return qL.test(r)?(i.dispatch({changes:{from:e.from-1,to:e.from,insert:""},selection:{anchor:e.from-1},userEvent:"delete.backward",scrollIntoView:!0}),!0):!1},GL=hn.highest(Mn.of([{key:"Backspace",run:NL}])),UL=[ML,zL,BL,GL,WL];function HL(i){const t=i.textContent??"",e=[];fl.parser.parse(t).iterate({enter(n){if(n.name!=="Link")return;const r=n.node,s=r.getChild("LinkMark"),o=r.getChildren("LinkMark")[1],l=r.getChild("URL");!s||!o||!l||s.to>=o.from||e.push({from:n.from,to:n.to,labelFrom:s.to,labelTo:o.from,href:t.slice(l.from,l.to)})}});for(const n of e.reverse()){const r=(h,u)=>{var m;const f=i.ownerDocument.createRange(),d=i.ownerDocument.createTreeWalker(i,NodeFilter.SHOW_TEXT);let O=0,p=!1;for(let g=d.nextNode();g;g=d.nextNode()){const b=O+(((m=g.textContent)==null?void 0:m.length)??0);if(!p&&h<=b&&(f.setStart(g,h-O),p=!0),u<=b){f.setEnd(g,u-O);break}O=b}return f},s=i.ownerDocument.createElement("a");s.className="cm-md-link",s.dataset.href=n.href,s.append(r(n.labelFrom,n.labelTo).cloneContents());const o=i.ownerDocument.createElement("span");o.className="cm-md-table-link";const l=i.ownerDocument.createElement("span");l.hidden=!0,l.textContent=t.slice(n.from,n.labelFrom);const a=i.ownerDocument.createElement("span");a.hidden=!0,a.textContent=t.slice(n.labelTo,n.to),o.append(l,s,a);const c=r(n.from,n.to);c.deleteContents(),c.insertNode(o)}}const FL=Fe.fromClass(class{constructor(i){C(this,"observer");C(this,"rendered",new WeakMap);C(this,"view");C(this,"pointerdown",i=>{this.isTableLink(i)&&!i.altKey&&(i.button===0||i.button===1)&&i.stopPropagation()});C(this,"mousedown",i=>{this.isTableLink(i)&&(Ea.mousedown(i)||i.button===1&&!i.altKey)&&(i.preventDefault(),i.stopPropagation())});C(this,"click",i=>{this.isTableLink(i)&&Ea.click(i)&&i.stopPropagation()});C(this,"auxclick",i=>{this.isTableLink(i)&&Ea.auxclick(i)&&i.stopPropagation()});this.view=i,this.observer=new MutationObserver(()=>this.render()),this.observer.observe(i.dom,{childList:!0,characterData:!0,attributes:!0,attributeFilter:["data-hidden"],subtree:!0}),i.dom.addEventListener("pointerdown",this.pointerdown,!0),i.dom.addEventListener("mousedown",this.mousedown,!0),i.dom.addEventListener("click",this.click,!0),i.dom.addEventListener("auxclick",this.auxclick,!0),this.render()}render(){for(const i of this.view.dom.querySelectorAll(".tbl-cell-view:not(.cm-md-table-cell-view)")){const t=i.innerHTML;let e=this.rendered.get(i);if(!e||e.source!==t){const n=(e==null?void 0:e.display)??i.cloneNode(!1);if(n.classList.add("cm-md-table-cell-view"),n.style.display="",n.replaceChildren(...Array.from(i.childNodes,r=>r.cloneNode(!0))),HL(n),!n.querySelector("a.cm-md-link")){e==null||e.display.remove(),this.rendered.delete(i),i.style.display="";continue}i.style.display="none",e||i.after(n),e={display:n,source:t},this.rendered.set(i,e)}e.display.getAttribute("data-hidden")!==i.getAttribute("data-hidden")&&(i.hasAttribute("data-hidden")?e.display.setAttribute("data-hidden",i.getAttribute("data-hidden")??""):e.display.removeAttribute("data-hidden"))}}isTableLink(i){return i.target instanceof Element&&!!i.target.closest(".tbl-cell-view a.cm-md-link")}destroy(){this.observer.disconnect();for(const i of this.view.dom.querySelectorAll(".tbl-cell-view:not(.cm-md-table-cell-view)")){const t=this.rendered.get(i);t&&(t.display.remove(),i.style.display="")}this.view.dom.removeEventListener("pointerdown",this.pointerdown,!0),this.view.dom.removeEventListener("mousedown",this.mousedown,!0),this.view.dom.removeEventListener("click",this.click,!0),this.view.dom.removeEventListener("auxclick",this.auxclick,!0)}}),KL=500,xg=ei.define(),JL=Lc.define([{tag:v.heading,fontWeight:"600"},{tag:v.strong,fontWeight:"600"},{tag:v.emphasis,fontStyle:"italic"},{tag:v.strikethrough,textDecoration:"line-through"}]);function yg(i){const t=i.length;return({state:e,dispatch:n})=>{const r=e.changeByRange(s=>{if(s.empty)return{changes:{from:s.from,insert:i+i},range:P.cursor(s.from+t)};const o=e.sliceDoc(s.from,s.to);if(o.length>=t*2&&o.startsWith(i)&&o.endsWith(i))return{changes:[{from:s.from,to:s.from+t},{from:s.to-t,to:s.to}],range:P.range(s.from,s.to-t*2)};const l=s.from>=t&&e.sliceDoc(s.from-t,s.from)===i,a=s.to+t<=e.doc.length&&e.sliceDoc(s.to,s.to+t)===i;return l&&a?{changes:[{from:s.from-t,to:s.from},{from:s.to,to:s.to+t}],range:P.range(s.from-t,s.to-t)}:{changes:[{from:s.from,insert:i},{from:s.to,insert:i}],range:P.range(s.from+t,s.to+t)}});return n(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}const tM=hn.highest(Mn.of([{key:"Mod-b",run:yg("**")},{key:"Mod-i",run:yg("*")},{key:"Enter",run:d1({nonTightLists:!1})}])),eM=cc.default.with({"--tbl-style-font-family":"var(--font-sans)","--tbl-style-font-size":"inherit","--tbl-style-menu-font-family":"var(--font-sans)","--tbl-style-menu-font-size":"var(--text-sm, 0.875rem)","--tbl-style-default-header-alignment":"left"}),iM=oL({theme:pl.light,style:eM,selectionType:"native",handlePosition:"outside",lineWrapping:"wrap",extensions:[Mn.of(tw)],globalKeyBindings:[...$0]}),zv=[QQ(),Oo.of(" "),tM,Mn.of([...tw,...$0,$$]),Ml({extensions:[kw,Dc,{remove:["SetextHeading"]}]}),b0(JL),z.lineWrapping,UL,iM,FL];function nM(i){const{parent:t,ctx:e}=i,n=i.debounceMs??KL;let r=null,s=null,o=null;const l=f=>{h.state.doc.toString()!==f&&h.dispatch({changes:{from:0,to:h.state.doc.length,insert:f},annotations:[xg.of(!0),Lt.addToHistory.of(!1)]})},a=async()=>{o=null;const f=h.state.doc.toString();r=f;try{await e.updateContent(f),s=f}catch{const d=s??"";l(d),r=d}},c=z.updateListener.of(f=>{!f.docChanged||f.transactions.some(O=>O.annotation(xg))||(o!==null&&clearTimeout(o),o=setTimeout(()=>{a()},n))}),h=new z({parent:t,state:J.create({doc:"",extensions:[zv,c]})}),u=f=>{const d=f.content;r!==null&&d===r||(l(d),s=d)};return e.addEventListener("content-updated",u),{view:h,dispose(){o!==null&&(clearTimeout(o),o=null),e.removeEventListener("content-updated",u),h.destroy()}}}const rM=`# Heading 1
|
|
65
|
+
`:l.textContent??""})??"",r=(t.textContent??"").slice(0,rg(i)),s=le(`${n}${r}`),o=n.length+rg(i);return fv({anchor:o,head:o},s,{trim:!1})}function _Z(i,t){var e=zd(),n=Xt(e);$r(n,()=>t.children),I(i,e)}function IZ(i,t){Dn(t,!0),th(()=>{const e=zS(_Z,{target:t.to,context:VR(),props:{children:t.children}});return()=>{_S(e)}}),Yn()}YR();var jZ=ot('<div class="tbl-blocking-overlay" aria-hidden="true"></div>');function DZ(i){var t=jZ();I(i,t)}function xc(i,t){const e=t.devicePixelRatio;return MA(i*e)/e}function YZ({x:i,y:t},e){return{x:xc(i,e),y:xc(t,e)}}var WZ=ot('<th class="tbl-cell tbl-header-cell"><!></th>'),VZ=ot('<td class="tbl-cell tbl-data-cell"><!></td>');function BZ(i,t){Dn(t,!0);const e=H(()=>ng(L(t.movement)?t.movement.border:{top:t.position.top,right:!0,bottom:!0,left:t.position.left})),n=H(()=>ng(t.outline)),r=H(()=>{var u;if(V((u=t.movement)==null?void 0:u.translate))return;const{x:c,y:h}=t.movement.state==="moving"?YZ(t.movement.translate,t.win):t.movement.translate;return`translate3d(${c}px, ${h}px, 0px)`});var s=zd(),o=Xt(s);{var l=c=>{var h=WZ();let u;var f=Ue(h);$r(f,()=>t.children),se(d=>{var O;$t(h,"align",t.alignment==="none"?void 0:t.alignment),$t(h,"data-component",Sl),$t(h,"data-row",t.location.row),$t(h,"data-col",t.location.col),$t(h,"data-border",$(e)),$t(h,"data-outline",$(n)),$t(h,"data-selected",d),$t(h,"data-state",(O=t.movement)==null?void 0:O.state),u=gc(h,"",u,{transform:$(r)})},[()=>gr(t.selected)]),I(c,h)},a=c=>{var h=VZ();let u;var f=Ue(h);$r(f,()=>t.children),se(d=>{var O;$t(h,"align",t.alignment==="none"?void 0:t.alignment),$t(h,"data-component",Sl),$t(h,"data-row",t.location.row),$t(h,"data-col",t.location.col),$t(h,"data-border",$(e)),$t(h,"data-outline",$(n)),$t(h,"data-selected",d),$t(h,"data-state",(O=t.movement)==null?void 0:O.state),u=gc(h,"",u,{transform:$(r)})},[()=>gr(t.selected)]),I(c,h)};Ft(o,c=>{t.position.top?c(l):c(a,!1)})}I(i,s),Yn()}function dv(i){var t;return L((t=bl(i.dom).activeElement)==null?void 0:t.closest(".cm-panels"))}function lg(i){return i.trim().split(/\s+/)}function qZ({doc:i,selection:t,parent:e,extensions:n,markdownConfig:r,selectionType:s,lineWrapping:o,globalKeyBindings:l,rootEditor:a,highlighter:c,onChange:h,eventHandlers:u}){return new z({doc:i,selection:t,parent:e,extensions:[n,hn.lowest([z.editorAttributes.of(f=>{const d=new Set(lg(a.themeClasses)),O=new Set(lg(f.themeClasses));return{class:[...d.difference(O)].join(" ")}}),Mn.of([...l.map(f=>({...f,run:L(f.run)?()=>f.run(a):void 0,shift:L(f.shift)?()=>f.shift(a):void 0}))]),s==="codemirror"?wk():[],b0(c),Ml({extensions:[E1,r.extensions??[]],addKeymap:!1,completeHTMLTags:r.completeHTMLTags,pasteURLAsLink:r.pasteURLAsLink,htmlTagLanguage:r.htmlTagLanguage}),z.domEventObservers(u),o==="wrap"?z.lineWrapping:[]])],dispatchTransactions:(f,d)=>{d.update(f),f.forEach(h)}})}var NZ=ot('<div class="tbl-cell-editor"></div>');function GZ(i,t){Dn(t,!0);let e=bf(t,"text",15),n=bf(t,"selection",15),r,s,o=!1,l=!1;function a(h){const{docChanged:u,newDoc:f,selection:d}=h;if(o)return;const O=L(d);if(u||O){if(u){const p=kd(f,{trim:!0});p.eq(e())||(e(p),l=!0)}if(O){const{head:p,anchor:m}=d.main,g=fv({head:p,anchor:m},f,{trim:!0});tv(g,n())||(n(g),l=!0)}}}Dd([()=>e(),()=>n()],()=>{if(l){l=!1;return}o=!0,s.dispatch({changes:s.state.changes({from:0,to:s.state.doc.length,insert:pc(e())}),selection:og(n(),e())}),o=!1},{lazy:!0}),th(()=>(s=qZ({doc:pc(e()),selection:og(n(),e()),parent:r,selectionType:t.selectionType,lineWrapping:t.lineWrapping,extensions:t.extensions,markdownConfig:t.markdownConfig,globalKeyBindings:t.globalKeyBindings,rootEditor:t.rootEditor,highlighter:t.highlighter,onChange:a,eventHandlers:{beforeinput:t.onbeforeinput,dragstart:t.ondragstart,keydown:(h,{state:u})=>t.onkeydown(h,u),paste:t.onpaste}}),dv(s)||s.focus(),()=>s.destroy()));var c=NZ();bc(c,h=>r=h,()=>r),I(i,c),Yn()}class sh{constructor({event:t,tableState:e,position:n}){C(this,"event");C(this,"tableState");C(this,"position");this.event=t,this.tableState=e,this.position=n}static navigate(t){new sh(t)[`navigate${t.key}`]()}navigateTab(){this.moveRight({createRow:!1,position:"end"})}navigateShiftTab(){this.moveLeft({createRow:!1,position:"end"})}navigateEnter(){this.moveDown({createRow:!1,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||V(this.tableState.outlinedSection)||V(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),V(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=JS(this.tableState.activeCell)}}navigateShiftArrowUp(){if(!(!this.position.top||V(this.tableState.outlinedSection)||V(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),V(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=HS(this.tableState.activeCell)}}navigateShiftArrowRight(){if(!(!this.position.right||V(this.tableState.outlinedSection)||V(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),V(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=FS(this.tableState.activeCell)}}navigateShiftArrowDown(){if(!(!this.position.bottom||V(this.tableState.outlinedSection)||V(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),V(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=KS(this.tableState.activeCell)}}moveLeft({createRow:t,position:e}){if(!V(this.tableState.activeCell)){if(this.event.preventDefault(),Pr(this.tableState.activeCell,this.tableState.table.firstCellLocation)){if(!t){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},e)}}moveUp({createRow:t,position:e}){if(!V(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.firstRowIndex){if(!t){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},e)}}moveRight({createRow:t,position:e}){if(!V(this.tableState.activeCell)){if(this.event.preventDefault(),Pr(this.tableState.activeCell,this.tableState.table.lastCellLocation)){if(!t){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},e)}}moveDown({createRow:t,position:e}){if(!V(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.lastRowIndex){if(!t){this.tableState.navigate("after");return}this.tableState.table.appendEmptyRows(1)}this.moveTo({row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col},e)}}moveTo(t,e){if(this.tableState.activeCell=t,this.tableState.anchorCell=t,this.tableState.outlinedSection=rt.ofCell(t),this.tableState.selection.isCell()){const n=e==="start"?0:this.tableState.table.cellAt(t).length;this.tableState.selectionValue={cell:t,section:{anchor:n,head:n}}}}}const bt={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"},UZ=[bt.arrowDown,bt.arrowLeft,bt.arrowRight,bt.arrowUp,bt.enter,bt.tab,`${bt.shift}${bt.arrowDown}`,`${bt.shift}${bt.arrowLeft}`,`${bt.shift}${bt.arrowRight}`,`${bt.shift}${bt.arrowUp}`,`${bt.shift}${bt.tab}`],ag=new Set(UZ);function Ov({key:i,shiftKey:t,altKey:e,metaKey:n,ctrlKey:r}){if(!(e||n||r))return t?ag.has(`${bt.shift}${i}`)?`${bt.shift}${i}`:void 0:ag.has(i)?i:void 0}function HZ(i,t){i.inputType==="historyUndo"?(t.undo(),i.preventDefault()):i.inputType==="historyRedo"&&(t.redo(),i.preventDefault())}function FZ(i){i.preventDefault()}function KZ(i,t,e){const n=Ov(i);if(V(n))return;const r=t.selection.main.head,s=t.doc.lineAt(r).number,o=0,l=t.doc.length,a=1,c=t.doc.lines,h={top:s===a,right:r===l,bottom:s===c,left:r===o};sh.navigate({tableState:e,key:n,event:i,position:h})}function JZ(i,t){Yd({tableState:t,event:i})}var tX=ot('<div class="tbl-cell-view" contenteditable="" tabindex="-1"><!></div>');function eX(i,t){Dn(t,!0);var e=tX(),n=Ue(e);$r(n,()=>t.children),se(r=>{$t(e,"data-component",Wd),$t(e,"data-hidden",r)},[()=>gr(t.hidden)]),I(i,e),Yn()}const pv="Handle";function Vd(i){if(!qS(i,{component:pv}))return;const{type:t,location:e}=_d(i).dataset;if(t==="table")return{type:t,location:e};{const n=nh(Wl(i));return QZ({location:e,type:t},n)}}var iX=ri('<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>'),nX=ri('<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>'),rX=ot('<div class="tbl-handle" role="button" aria-hidden="true"><!></div>');function cg(i,t){Dn(t,!0);let e=bf(t,"toggle",3,!1);const n={table:{right:"vertical",bottom:"horizontal"},header:{row:"vertical",col:"horizontal"}},r=H(()=>{var c;return(c=n[t.of.type])==null?void 0:c[t.of.location]});var s=rX();gc(s,"",{},{opacity:"var(--tbl-handle-opacity, 0)"});var o=Ue(s);{var l=c=>{var h=iX();I(c,h)},a=c=>{var h=nX();I(c,h)};Ft(o,c=>{$(r)==="horizontal"?c(l):$(r)==="vertical"&&c(a,1)})}se((c,h,u)=>{$t(s,"data-component",pv),$t(s,"data-type",t.of.type),$t(s,"data-location",t.of.location),$t(s,"data-active",c),$t(s,"data-hover",h),$t(s,"data-toggle",u)},[()=>gr(t.state==="active"),()=>gr(t.state==="hover"),()=>gr(e())]),I(i,s),Yn()}var sX=ot('<div class="tbl-menu"><!></div>');function oX(i,t){Dn(t,!0);let e,n=ct(void 0);th(()=>{t.translate(e).then(l=>q(n,l,!0))});var r=sX();let s;var o=Ue(r);$r(o,()=>t.children),bc(r,l=>e=l,()=>e),se(l=>s=gc(r,"",s,l),[()=>({visibility:L($(n))?void 0:"hidden",transform:L($(n))?`translate3d(${$(n).x}px, ${$(n).y}px, 0px)`:void 0})]),I(i,r),Yn()}var lX=ot('<div class="tbl-menu-item" role="menuitem" tabindex="-1"><!></div>');function Ae(i,t){var e=lX(),n=Ue(e);$r(n,()=>t.children),Mo("click",e,function(...r){var s;(s=t.onclick)==null||s.apply(this,r)}),I(i,e)}MS(["click"]);function Re(i,t){switch(i.action){case"add":return t.menu.clickAdd(i.direction);case"align":return t.menu.clickAlign(i.alignment);case"clear":return t.menu.clickClear();case"duplicate":return t.menu.clickDuplicate();case"move":return t.menu.clickMove(i.direction);case"remove":return t.menu.clickRemove();case"sort":return t.menu.clickSort(i.direction)}}var aX=ri('<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>'),cX=ri('<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>'),hX=ri('<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>'),uX=ri('<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>'),fX=ri('<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>'),dX=ri('<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>'),OX=ri('<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>'),pX=ri('<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>'),mX=ri('<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>'),gX=ri('<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>'),bX=ot('<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 Ze(i,t){var e=bX(),n=Ue(e),r=Ue(n);{var s=b=>{var S=aX();I(b,S)},o=b=>{var S=cX();I(b,S)},l=b=>{},a=b=>{var S=hX();I(b,S)},c=b=>{var S=uX();I(b,S)},h=b=>{var S=fX();I(b,S)},u=b=>{var S=dX();I(b,S)},f=b=>{var S=OX();I(b,S)},d=b=>{var S=pX();I(b,S)},O=b=>{var S=mX();I(b,S)},p=b=>{},m=b=>{},g=b=>{var S=gX();I(b,S)};Ft(r,b=>{t.name==="sort-ascending"?b(s):t.name==="sort-descending"?b(o,1):t.name==="align-none"?b(l,2):t.name==="align-left"?b(a,3):t.name==="align-center"?b(c,4):t.name==="align-right"?b(h,5):t.name==="move-up"?b(u,6):t.name==="move-right"?b(f,7):t.name==="move-down"?b(d,8):t.name==="move-left"?b(O,9):t.name==="duplicate"?b(p,10):t.name==="clear"?b(m,11):t.name==="remove"&&b(g,12)})}I(i,e)}var wX=ot('<div class="tbl-menu-item-text"><!></div>');function Xe(i,t){var e=wX(),n=Ue(e);$r(n,()=>t.children),I(i,e)}var SX=ot('<div class="tbl-menu-separator"></div>');function ga(i){var t=SX();I(i,t)}var vX=ot('<div class="tbl-select-all-overlay" aria-hidden="true"></div>');function xX(i){var t=vX();I(i,t)}const yX=new Set([bt.c,bt.v,bt.x]);function kX(i,t){return yX.has(i.key)&&i[lR(t)]}const QX=[bt.backspace,bt.delete],$X=new Set(QX);function CX({key:i}){return $X.has(i)?i:void 0}function PX(i){return/^F\d+$/.test(i)}const TX=new Set([bt.alt,bt.escape,bt.enter,bt.shift]);function AX({metaKey:i,ctrlKey:t,key:e}){return!t&&!i&&!TX.has(e)&&!PX(e)}function RX(i,t){t.selection.isCell()||av({tableState:t,event:i})}function ZX(i,t){t.selection.isCell()||cv({tableState:t,event:i})}function XX(i,t){t.selection.isCell()||Yd({tableState:t,event:i})}function EX(i,t){if(L(i.target)&&L(uv(i.target))){i.preventDefault();return}if(!t.interactive||t.selection.isCell())return;const e=Ov(i);if(L(e)){sh.navigate({tableState:t,key:e,event:i,position:{left:!0,top:!0,right:!0,bottom:!0}});return}const n=CX(i);if(L(n)){lv({tableState:t,event:i});return}if(t.activeTable&&L(t.activeCell)&&AX(i)){t.activeTable=!1,t.anchorCell=t.activeCell;const r=t.table.cellAt(t.activeCell).length;t.selectionValue={cell:t.activeCell,section:{head:r,anchor:r}},t.outlinedSection=rt.ofCell(t.activeCell);return}kX(i,t.window)||dk(t.rootEditor,i,"editor")&&i.preventDefault()}function Bd(i){return i.buttons===1}function mv(i,t){return t.setPointerCapture(i.pointerId),()=>t.releasePointerCapture(i.pointerId)}class oh{constructor({offset:t,maxScroll:e,boundaryElement:n,scrollElement:r}){C(this,"offset");C(this,"maxScroll");C(this,"boundaryElement");C(this,"scrollElement");C(this,"scroll");C(this,"handle");C(this,"xAmount");C(this,"yAmount");const s=this.scrollInternal.bind(this);this.scroll=()=>{this.handle=requestAnimationFrame(s)},this.xAmount=0,this.yAmount=0,this.offset=t??0,this.maxScroll=e,this.boundaryElement=n,this.scrollElement=r}updatePosition(t,e){const n=this.boundaryElement.x.getBoundingClientRect();t<n.left+this.offset?this.xAmount=-ce(this.offset+(n.left-t),{max:this.maxScroll}):t>n.right-this.offset?this.xAmount=ce(this.offset-(n.right-t),{max:this.maxScroll}):this.xAmount=0;const r=this.boundaryElement.y.getBoundingClientRect();e<r.top+this.offset?this.yAmount=-ce(this.offset+(r.top-e),{max:this.maxScroll}):e>r.bottom-this.offset?this.yAmount=ce(this.offset-(r.bottom-e),{max:this.maxScroll}):this.yAmount=0,V(this.handle)&&(this.xAmount!==0||this.yAmount!==0)&&this.scroll()}destroy(){L(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(t){return new oh(t)}}class yc{constructor({start:t,size:e}){C(this,"start");C(this,"size");this.start=t,this.size=e}get mid(){return this.start+this.size/2}get end(){return this.start+this.size}static of(t){return new yc(t)}}var kc;(i=>{function t(e,n){return qd.of(e,n)}i.of=t})(kc||(kc={}));class qd{constructor(t,e){C(this,"rows");C(this,"cols");C(this,"firstRowIndex",0);C(this,"firstColIndex",0);const n=[...t.querySelectorAll("tr:first-child > th")],r=[...t.querySelectorAll("tr > th:first-child,tr > td:first-child")];this.rows=r.map((s,o)=>{const{top:l,height:a}=hg(s,e),c=0;return yc.of({start:l+c,size:a-c})}),this.cols=n.map((s,o)=>{const{left:l,width:a}=hg(s,e),c=o===0?1:0;return yc.of({start:l+c,size:a-c})})}rowsOrCols(t){return t==="row"?this.rows:this.cols}rowAt(t){return this.rows[t]}colAt(t){return this.cols[t]}rowOrColAt(t,e){return t==="row"?this.rowAt(e):this.colAt(e)}get firstRow(){return this.rows[this.firstRowIndex]}get firstCol(){return this.cols[this.firstColIndex]}firstRowOrCol(t){return t==="row"?this.firstRow:this.firstCol}get lastRow(){return this.rows[this.lastRowIndex]}get lastCol(){return this.cols[this.lastColIndex]}lastRowOrCol(t){return t==="row"?this.lastRow:this.lastCol}firstRowOrColIndex(t){return 0}get lastRowIndex(){return this.rowCount-1}get lastColIndex(){return this.colCount-1}lastRowOrColIndex(t){return t==="row"?this.lastRowIndex:this.lastColIndex}get rowCount(){return this.rows.length}get colCount(){return this.cols.length}get minRowSize(){return Oc(...this.rows.map(t=>t.size))}get minColSize(){return Oc(...this.cols.map(t=>t.size))}moveRowOrColAt(t,{fromIndex:e,toIndex:n}){if(e===n)return;const r=this.rowsOrCols(t),s=r[e];if(e<n){for(const o of Qn({start:e,endExclusive:n}))r[o]=r[o+1],r[o].start-=s.size;s.start=r[n].start+r[n].size}else{for(const o of Qn({start:e,endExclusive:n}))r[o]=r[o-1],r[o].start+=s.size;s.start=r[n].start-s.size}r[n]=s}lastCellBeforePosition(t){const e=this.rows.map(r=>r.start).findLastIndex(r=>r<t.y),n=this.cols.map(r=>r.start).findLastIndex(r=>r<t.x);return{row:e===-1?0:e,col:n===-1?0:n}}static of(t,e){return new qd(t,e)}}function hg(i,t){const{top:e,left:n,width:r,height:s}=i.getBoundingClientRect();return{top:e+t.y,left:n+t.x,width:r,height:s}}class vl{constructor({tableState:t,cellLocation:e}){C(this,"tableState");C(this,"tableMeasurement");C(this,"autoScroller");C(this,"shouldAutoScroll");C(this,"removeEventListeners");C(this,"currentCell");this.tableState=t,this.currentCell=e,this.autoScroller=oh.of({offset:10,maxScroll:32,boundaryElement:{x:t.scrollElement,y:t.rootScrollElement},scrollElement:{x:t.scrollElement,y:t.rootScrollElement}}),this.shouldAutoScroll=V5({delayMillis:500}),this.tableMeasurement=kc.of(t.tableElement,{x:t.scrollOffsetX,y:t.scrollOffsetY})}start(){this.tableState.activeCell=this.currentCell,this.tableState.anchorCell=this.currentCell,this.tableState.outlinedSection=rt.ofCell(this.currentCell),this.tableState.outline={outlined:!1},this.removeEventListeners=Cr(Et(this.tableState.window,"pointermove",t=>this.drag(t)),Et(this.tableState.window,"pointerup",()=>this.end()),Et(this.tableState.window,"pointerleave",()=>this.end()))}resizeAndContinue(t){t.preventDefault(),V(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.currentCell),this.expandOrContract(this.currentCell),this.tableState.outline={outlined:!0},this.removeEventListeners=Cr(Et(this.tableState.window,"pointermove",e=>this.drag(e)),Et(this.tableState.window,"pointerup",()=>this.end()),Et(this.tableState.window,"pointerleave",()=>this.end()))}drag(t){if(!Bd(t)){this.end();return}t.preventDefault(),this.shouldAutoScroll()&&this.autoScroller.updatePosition(t.clientX,t.clientY);const e=this.tableMeasurement.lastCellBeforePosition({x:t.clientX+this.tableState.scrollOffsetX,y:t.clientY+this.tableState.scrollOffsetY});Pr(e,this.currentCell)||(this.currentCell=e,this.tableState.outline={outlined:!0},this.expandOrContract(e))}end(){var t;(t=this.removeEventListeners)==null||t.call(this),this.autoScroller.destroy(),this.tableState.outline=void 0}expandOrContract(t){this.tableState.focusTable();const[e,n]=t.row<=this.tableState.anchorCell.row?[t.row,this.tableState.anchorCell.row]:[this.tableState.anchorCell.row,t.row],[r,s]=t.col<=this.tableState.anchorCell.col?[t.col,this.tableState.anchorCell.col]:[this.tableState.anchorCell.col,t.col];this.tableState.outlinedSection=rt.of({row:{start:e,endExclusive:n+1},col:{start:r,endExclusive:s+1}}),this.tableState.activeCell=t}static startOutline(t){new vl(t).start()}static resizeAndContinueOutline(t){new vl(t).resizeAndContinue(t.event)}}function LX(i,t){Uc(t.window)&&(t.hoveredCell=i)}function MX(i){Uc(i.window)&&(i.hoveredCell=void 0)}function zX(i,t,e){if(!(!e.interactive||!Bd(i)))if(i.shiftKey){if(e.selection.isCell()&&Pr(t,e.selection.cell))return;vl.resizeAndContinueOutline({event:i,tableState:e,cellLocation:t})}else vl.startOutline({event:i,tableState:e,cellLocation:t})}const _X=new Intl.Collator(navigator.language,{numeric:!0,sensitivity:"base"});function ug(i,t){return _X.compare(i,t)}function IX({metaKey:i,shiftKey:t,altKey:e,ctrlKey:n,key:r}){return r===bt.escape&&!t&&!e&&!i&&!n}class Nd{constructor({tableState:t,handle:e,point:n}){C(this,"tableState");C(this,"handle");C(this,"point");C(this,"removeEventListeners");this.tableState=t,this.handle=e,this.point=n}get rowOrCol(){return this.handle.location}get index(){return this.handle.index}open(){const t=this.tableState.document.body;this.removeEventListeners=Cr(Et(t,"pointerdown",o=>{o.preventDefault(),(V(o.target)||!YS(this.tableState.menuRootElement,o.target))&&this.close()}),Et(t,"wheel",o=>o.preventDefault(),{passive:!1}),Et(t,"keydown",o=>{o.preventDefault(),IX(o)&&this.close()})),this.tableState.focusTable(),this.tableState.activeHandle={state:"active",handle:this.handle},this.tableState.outlinedSection=rt.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}});const e=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=e,this.tableState.anchorCell=e;const n=this.index!==this.tableState.table.firstRowOrColIndex(this.rowOrCol),r=this.index!==this.tableState.table.lastRowOrColIndex(this.rowOrCol);let s=!1;n?s=r?!0:"backward":r&&(s="forward"),this.tableState.menu={type:this.rowOrCol,capabilities:{addable:!0,alignable:this.rowOrCol==="col",clearable:!0,duplicatable:!0,moveable:s,removable:!this.tableState.table.hasSingleRowOrCol(this.rowOrCol),sortable:this.rowOrCol==="col"},clickAdd:o=>this.clickAdd(o),clickAlign:o=>this.clickAlign(o),clickClear:()=>this.clickClear(),clickDuplicate:()=>this.clickDuplicate(),clickMove:o=>this.clickMove(o),clickRemove:()=>this.clickRemove(),clickSort:o=>this.clickSort(o),computeTranslation:o=>this.computeTranslation(o)}}close(){var t;(t=this.removeEventListeners)==null||t.call(this),this.tableState.menu=void 0,this.tableState.activeHandle=void 0}async computeTranslation(t){const e=await JT({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})},t,{middleware:[FT({allowedPlacements:this.rowOrCol==="row"?["right-start","right-end"]:["right-start","right"]}),KT({crossAxis:!0})]}),n=wo(t);return{x:xc(e.x,n),y:xc(e.y,n)}}clickAdd(t){var e;if(this.tableState.table.addEmptyRowsOrColsAt(this.rowOrCol,{index:t==="before"?this.index:this.index+1,count:1}),t==="after"){this.tableState.outlinedSection=(e=this.tableState.outlinedSection)==null?void 0:e.shift(this.rowOrCol,"forward");const n=Fh(this.rowOrCol,this.tableState.activeCell,"forward");this.tableState.activeCell=n,this.tableState.anchorCell=n}this.close()}clickAlign(t){this.tableState.table.setAlignmentAt(this.index,t),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(t){var n;this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:t==="backward"?this.index-1:this.index+1}),this.tableState.outlinedSection=(n=this.tableState.outlinedSection)==null?void 0:n.shift(this.rowOrCol,t);const e=Fh(this.rowOrCol,this.tableState.activeCell,t);this.tableState.activeCell=e,this.tableState.anchorCell=e,this.close()}clickRemove(){var t;if(this.tableState.table.removeRowsOrColsAt(this.rowOrCol,{index:this.index,count:1}),!this.tableState.table.hasRowOrColAt(this.rowOrCol,this.index)){this.tableState.outlinedSection=(t=this.tableState.outlinedSection)==null?void 0:t.shift(this.rowOrCol,"backward");const e=Fh(this.rowOrCol,this.tableState.activeCell,"backward");this.tableState.activeCell=e,this.tableState.anchorCell=e}this.close()}clickSort(t){this.tableState.table.sortByColAt(this.index,t==="ascending"?(e,n)=>ug(e.toString(),n.toString()):(e,n)=>ug(n.toString(),e.toString())),this.close()}static showMenu(t){new Nd(t).open()}}class Gd{constructor({rowOrCol:t,index:e,position:n,subject:r,tableElement:s,scrollOffsetX:o,scrollOffsetY:l}){C(this,"coordinate");C(this,"initialIndex");C(this,"size");C(this,"initialPosition");C(this,"minBound");C(this,"maxBound");C(this,"scrollOffsetX");C(this,"scrollOffsetY");C(this,"subject");C(this,"rowOrCol");C(this,"tableMeasurement");C(this,"currentIndex");C(this,"currentPosition");C(this,"dragged");this.scrollOffsetX=o,this.scrollOffsetY=l;const a=kc.of(s,{x:this.scrollOffsetX(),y:this.scrollOffsetY()});this.rowOrCol=t,this.coordinate=t==="row"?"y":"x",this.initialIndex=e,this.initialPosition=n[this.coordinate],this.minBound=a.firstRowOrCol(this.rowOrCol).start-a.rowOrColAt(this.rowOrCol,e).start,this.maxBound=a.lastRowOrCol(this.rowOrCol).end-a.rowOrColAt(this.rowOrCol,e).end,this.size=a.rowOrColAt(this.rowOrCol,e).size,this.subject=r,this.dragged=!1,this.tableMeasurement=a,this.currentIndex=e,this.currentPosition=n[this.coordinate]}start(){return{cellMovement:t=>this.cellMovement(t)}}drag(t){this.currentPosition=t[this.coordinate];const{currentIndex:e,move:n}=this.calculateDrag();return this.currentIndex=e,this.initialIndex!==this.currentIndex&&(this.dragged=!0),L(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(t){return{border:this.cellBorder(t),state:this.cellState(t),translate:this.cellTranslate(t)}}cellBorder(t){const e=this.isRowOrColExposed(t[this.rowOrCol]),n=this.subject.containsCell(t);return this.rowOrCol==="row"?{top:e,right:!0,bottom:!n||t.row===this.tableMeasurement.lastRowIndex,left:this.tableMeasurement.firstColIndex===t.col}:{top:this.tableMeasurement.firstRowIndex===t.row,right:!n||t.col===this.tableMeasurement.lastColIndex,bottom:!0,left:e}}cellState(t){return this.subject.containsCell(t)?"moving":"shiftable"}cellTranslate(t){const e=this.rowOrColTranslate(t[this.rowOrCol]);return this.rowOrCol==="row"?{x:0,y:e}:{x:e,y:0}}isRowOrColExposed(t){const e=this.reorderIndex(t),n=e===this.tableMeasurement.firstRowOrColIndex(this.rowOrCol),r=e===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(t){if(t===this.initialIndex)return ce(this.currentPosition-this.initialPosition,{min:this.minBound,max:this.maxBound});const e=this.rowOrColShift;return V(e)?0:yn(t,e.range)?e.positionDiff:0}reorderIndex(t){const e=this.rowOrColShift;return V(e)?t:t===this.initialIndex?this.currentIndex:yn(t,e.range)?t+e.indexDiff:t}calculateDrag(){const t=this.tableMeasurement.rowsOrCols(this.rowOrCol),e={name:"current",index:this.currentIndex,mid:t[this.currentIndex].mid},n=this.currentIndex!==this.tableMeasurement.firstRowOrColIndex(this.rowOrCol)?{name:"left",index:this.currentIndex-1,mid:t[this.currentIndex-1].start+t[this.currentIndex].size/2}:void 0,r=this.currentIndex!==this.tableMeasurement.lastRowOrColIndex(this.rowOrCol)?{name:"right",index:this.currentIndex+1,mid:t[this.currentIndex].start+t[this.currentIndex+1].size+t[this.currentIndex].size/2}:void 0,s=RA(ZA([e,n,r]),(o,l)=>nf(this.currentPosition-o.mid)-nf(this.currentPosition-l.mid));return s.name==="current"?{currentIndex:this.currentIndex,move:void 0}:{currentIndex:s.index,move:{fromIndex:this.currentIndex,toIndex:s.index}}}static of(t){return new Gd(t)}}class Ud{constructor({event:t,tableState:e,rowOrCol:n,index:r,onClick:s}){C(this,"tableState");C(this,"rowOrCol");C(this,"index");C(this,"onClick");C(this,"moveTracker");C(this,"subject");C(this,"autoScroller");C(this,"removeEventListeners");this.tableState=e,this.rowOrCol=n,this.index=r,this.subject=rt.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=s,this.autoScroller=oh.of({offset:16,maxScroll:32,boundaryElement:{x:e.scrollElement,y:e.rootScrollElement},scrollElement:{x:e.scrollElement,y:e.rootScrollElement}}),this.moveTracker=Gd.of({subject:this.subject,rowOrCol:n,index:r,position:{x:t.clientX+e.scrollOffsetX,y:t.clientY+e.scrollOffsetY},tableElement:e.tableElement,scrollOffsetX:()=>this.tableState.scrollOffsetX,scrollOffsetY:()=>this.tableState.scrollOffsetY})}start(t){t.preventDefault();const e=this.moveTracker.start();this.tableState.outlinedSection=this.subject,this.tableState.move=e,this.tableState.activeHandle={state:"active",handle:{type:"header",index:this.index,location:this.rowOrCol}};const 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();const r=_d(t.target);this.removeEventListeners=Cr(mv(t,r),Et(r,"pointermove",s=>this.drag(s)),Et(r,"pointerup",()=>this.end()))}drag(t){t.preventDefault(),this.autoScroller.updatePosition(t.clientX,t.clientY),this.tableState.move=this.moveTracker.drag({x:t.clientX+this.tableState.scrollOffsetX,y:t.clientY+this.tableState.scrollOffsetY})}end(){var e;(e=this.removeEventListeners)==null||e.call(this),this.autoScroller.destroy();const t=this.moveTracker.end();if(t.moved){this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:t.toIndex}),this.tableState.outlinedSection=rt.of(this.rowOrCol==="row"?{row:{start:t.toIndex,endExclusive:t.toIndex+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:t.toIndex,endExclusive:t.toIndex+1}});const n=this.rowOrCol==="row"?{row:t.toIndex,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:t.toIndex};this.tableState.activeCell=n,this.tableState.anchorCell=n}this.tableState.move=void 0,this.tableState.activeHandle=void 0,!t.moved&&!t.dragged&&this.onClick()}static startMove(t){new Ud(t).start(t.event)}}function jX(i){return i==="row"?"y":"x"}class Hd{constructor({tableState:t,handle:e,position:n,cellSizePixels:r,dragThresholdPixels:s}){C(this,"tableState");C(this,"type");C(this,"initialHandle");C(this,"initialRowOrColCount");C(this,"initialPosition");C(this,"initialOutlinedSection");C(this,"initialActiveCell");C(this,"initialAnchorCell");C(this,"cellSizePixels");C(this,"dragThresholdPixels");C(this,"dragged");this.tableState=t,this.type=this.handleToType(e),this.initialHandle=e,this.initialPosition=n,this.initialRowOrColCount={row:t.table.rowCount,col:t.table.colCount},this.initialActiveCell=t.activeCell,this.initialAnchorCell=t.anchorCell,this.initialOutlinedSection=t.outlinedSection,this.cellSizePixels=r,this.dragThresholdPixels=s,this.dragged=!1}start(){return{activeHandle:{state:"active",handle:this.initialHandle}}}drag(t){return this.dragged=!0,this.calculateDrag(t)}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");const t=this.calculateClickRowOrCol("row"),e=this.calculateClickRowOrCol("col");return{operation:{row:t.operation.row,col:e.operation.col},activeHandle:t.activeHandle,activeCell:L(t.activeCell)&&L(e.activeCell)?{row:t.activeCell.row,col:e.activeCell.col}:void 0,anchorCell:L(t.anchorCell)&&L(e.anchorCell)?{row:t.anchorCell.row,col:e.anchorCell.col}:void 0,outlinedSection:L(t.outlinedSection)&&L(e.outlinedSection)?rt.of({row:t.outlinedSection.row,col:e.outlinedSection.col}):void 0}}calculateClickRowOrCol(t){const e=this.type==="table"?this.tableState.table.lastRowOrColIndex(t)+1:this.initialHandle.index;return{operation:{[t]:{action:"add",index:e,count:1}},activeHandle:this.type==="table"?void 0:{state:"hover",handle:{type:"border",location:this.handleLocationAt(e),index:e}},...this.calculateCellMovement(t,1)}}calculateDrag(t){if(this.type!=="table")return this.calculateDragRowOrCol(this.type,t);if(this.initialHandle.location==="right")return this.calculateDragRowOrCol("col",t);if(this.initialHandle.location==="bottom")return this.calculateDragRowOrCol("row",t);const e=this.calculateDragRowOrCol("row",t),n=this.calculateDragRowOrCol("col",t);if(V(e)&&V(n))return;const r=e??this.calculateCellMovement("row",this.rowOrColDiff("row")),s=n??this.calculateCellMovement("col",this.rowOrColDiff("col"));return{operation:{row:e==null?void 0:e.operation.row,col:n==null?void 0:n.operation.col},activeHandle:(e==null?void 0:e.activeHandle)??(n==null?void 0:n.activeHandle),activeCell:L(r.activeCell)&&L(s.activeCell)?{row:r.activeCell.row,col:s.activeCell.col}:void 0,anchorCell:L(r.anchorCell)&&L(s.anchorCell)?{row:r.anchorCell.row,col:s.anchorCell.col}:void 0,outlinedSection:L(r.outlinedSection)&&L(s.outlinedSection)?rt.of({row:r.outlinedSection.row,col:s.outlinedSection.col}):void 0}}calculateDragRowOrCol(t,e){const n=jX(t),r=e.position[n]-this.initialPosition[n],s=zA(r/this.cellSizePixels[t]),o=r%this.cellSizePixels[t]>=this.dragThresholdPixels[t]?1:0,l=this.tableState.table.rowOrColCount(t)-this.initialRowOrColCount[t],a=s+o-l,c=this.type==="table"?this.tableState.table.lastRowOrColIndex(t)+1:this.initialHandle.index+l;if(a!==0)return a>0?this.calculateDragRowOrColMore({rowOrCol:t,start:c,length:a}):this.calculateDragRowOrColLess({rowOrCol:t,start:c,length:Oc(-a,c,this.tableState.table.lastRowOrColIndex(t))})}calculateDragRowOrColLess({rowOrCol:t,start:e,length:n}){let r=0;for(const o of Qn({start:e-1,endExclusive:e-n-1})){if(!this.tableState.table.hasEmptyRowOrColAt(t,o))break;r++}if(r===0)return;const s=e-(r-1)-1;return{operation:{[t]:{action:"remove",index:e-r,count:r}},activeHandle:this.type==="table"?{state:"active",handle:this.initialHandle}:{state:"active",handle:{type:"border",location:this.handleLocationAt(s),index:s}},...this.calculateCellMovement(t,this.rowOrColDiff(t)-r)}}calculateDragRowOrColMore({rowOrCol:t,start:e,length:n}){return{operation:{[t]:{action:"add",index:e,count:n}},activeHandle:{state:"active",handle:this.type==="table"?this.initialHandle:{type:"border",location:this.handleLocationAt(e+n),index:e+n}},...this.calculateCellMovement(t,this.rowOrColDiff(t)+n)}}calculateCellMovement(t,e){var r,s;const n=this.type==="table"?this.initialRowOrColCount[t]:this.initialHandle.index;if(e>=0)return{outlinedSection:(r=this.initialOutlinedSection)==null?void 0:r.addForwardsByRowOrCol(t,{start:n,count:e}),activeCell:L(this.initialActiveCell)?tg(t,this.initialActiveCell,{start:n,count:e}):void 0,anchorCell:L(this.initialAnchorCell)?tg(t,this.initialAnchorCell,{start:n,count:e}):void 0};{const o=-e,l=(s=this.initialOutlinedSection)==null?void 0:s.subtractBackwardsByRowOrCol(t,{start:n,count:o,min:this.tableState.table.firstRowOrColIndex(t)}),a=L(l)?{min:l.startRowOrCol(t),max:l.endRowOrCol(t)}:void 0,c=L(this.initialActiveCell)?eg(t,this.initialActiveCell,{start:n,count:o,boundary:a}):void 0,h=L(this.initialAnchorCell)?eg(t,this.initialAnchorCell,{start:n,count:o,boundary:a}):void 0;return{outlinedSection:l,activeCell:c,anchorCell:h}}}rowOrColDiff(t){return this.tableState.table.rowOrColCount(t)-this.initialRowOrColCount[t]}handleLocationAt(t){if(this.type!=="table")return this.type==="row"&&t===this.tableState.table.firstRowIndex?"top":this.type==="col"&&t===this.tableState.table.firstColIndex?"left":this.type}handleToType(t){return t.type==="table"?"table":t.location==="top"?"row":t.location==="left"?"col":t.location}static of(t){return new Hd(t)}}function DX(i){const t=Sc(i.tableElement,i.table.firstCellLocation),e=LZ(t),{minWidth:n}=getComputedStyle(t),{lineHeight:r,paddingTop:s,paddingBottom:o}=getComputedStyle(e),l=parseFloat(n)+1,a=parseFloat(r)+parseFloat(s)+parseFloat(o)+1;return{width:l,height:a}}class Fd{constructor({event:t,tableState:e,handle:n}){C(this,"tableState");C(this,"resizeTracker");C(this,"removeEventListeners");this.tableState=e;const{width:r,height:s}=DX(e);this.resizeTracker=Hd.of({tableState:this.tableState,handle:n,position:{x:t.clientX,y:t.clientY},cellSizePixels:{row:s,col:r},dragThresholdPixels:{row:s/2,col:r/2}})}start(t){t.preventDefault();const e=this.resizeTracker.start();this.tableState.resize={},this.tableState.activeHandle=e.activeHandle,this.tableState.focusTable(),this.removeEventListeners=Cr(mv(t,this.tableState.tableElement),Et(this.tableState.tableElement,"pointermove",n=>this.drag(n)),Et(this.tableState.tableElement,"pointerup",()=>this.end()))}drag(t){t.preventDefault();const e=this.resizeTracker.drag({position:{x:t.clientX,y:t.clientY}});L(e)&&(this.resizeTable(e.operation),this.tableState.activeHandle=e.activeHandle,this.tableState.activeCell=e.activeCell,this.tableState.anchorCell=e.anchorCell,this.tableState.outlinedSection=e.outlinedSection)}end(){var e;(e=this.removeEventListeners)==null||e.call(this);const t=this.resizeTracker.end();"operation"in t&&(this.resizeTable(t.operation),this.tableState.activeCell=t.activeCell,this.tableState.anchorCell=t.anchorCell,this.tableState.outlinedSection=t.outlinedSection),this.tableState.activeHandle=t.activeHandle,this.tableState.resize=void 0}resizeTable({row:t,col:e}){if(L(t)){const{action:n,index:r,count:s}=t;n==="add"?this.tableState.table.addEmptyRowsAt({row:r,count:s}):this.tableState.table.removeRowsAt({row:r,count:s})}if(L(e)){const{action:n,index:r,count:s}=e;n==="add"?this.tableState.table.addEmptyColsAt({col:r,count:s}):this.tableState.table.removeColsAt({col:r,count:s})}}static startResize(t){new Fd(t).start(t.event)}}function YX(i,t){t.interactive&&(t.activeHandle={state:"hover",handle:i})}function WX(i){i.interactive&&(i.activeHandle=void 0)}function VX(i,t,e){if(e.interactive){if(!Bd(i)){i.preventDefault();return}t.type==="table"||t.type==="border"?Fd.startResize({event:i,handle:t,tableState:e}):t.type==="header"&&Ud.startMove({event:i,rowOrCol:t.location,index:t.index,tableState:e,onClick:()=>Nd.showMenu({handle:t,point:{x:i.clientX,y:i.clientY},tableState:e})})}}function BX(i,t){const e=i.target;if(V(e))return;const n=Vd(e);if(L(n)){YX(n,t);return}const r=Wl(e);if(L(r)){LX(nh(r),t);return}}function qX(i,t){const e=i.target;if(V(e))return;const n=Vd(e);if(L(n)){WX(t);return}const r=Wl(e);if(L(r)){MX(t);return}}function NX(i,t){const e=i.target;if(V(e))return;const n=Vd(e);if(L(n)){VX(i,n,t);return}const r=Wl(e);if(L(r)){zX(i,nh(r),t);return}i.preventDefault()}function GX(i){i.preventDefault()}var UX=ot("<!> <!> <!>",1),HX=ot('<tr class="tbl-table-row"></tr>'),FX=ot('<tbody class="tbl-table-body"></tbody>'),KX=ot("<!> <!>",1),JX=ot("<!> <!>",1),tE=ot("<!> <!> <!>",1),eE=ot("<!> <!>",1),iE=ot("<!> <!>",1),nE=ot("<!> <!>",1),rE=ot("<!> <!>",1),sE=ot("<!> <!> <!> <!> <!>",1),oE=ot("<!> <!>",1),lE=ot("<!> <!>",1),aE=ot("<!> <!> <!>",1),cE=ot("<!> <!>",1),hE=ot("<!> <!>",1),uE=ot("<!> <!> <!>",1),fE=ot("<!> <!>",1),dE=ot("<!> <!>",1),OE=ot("<!> <!>",1),pE=ot("<!> <!> <!> <!> <!> <!> <!>",1),mE=ot('<div class="tbl-table-wrapper"><table class="tbl-table" role="grid" tabindex="-1"><thead class="tbl-table-head"><!></thead><!></table> <!> <!> <!> <!></div>');function gE(i,t){Dn(t,!0);const e=Qf.of({table:()=>t.table,selection:()=>t.selection,scrollElement:()=>t.scrollElement,rootEditor:()=>t.rootEditor,menuRootElement:()=>t.menuRootElement,extensions:()=>t.extensions,markdownConfig:()=>t.markdownConfig,globalKeyBindings:()=>t.globalKeyBindings,selectionType:()=>t.selectionType,lineWrapping:()=>t.lineWrapping,onUndo:()=>t.onUndo,onRedo:()=>t.onRedo,onNavigate:()=>t.onNavigate,onDelete:()=>t.onDelete});th(()=>Cr(Et(e.document,"selectionchange",()=>MZ(e)),Et(e.document.body,"pointerdown",()=>TZ(e),{capture:!0,passive:!0}),Et(e.document.body,"pointerup",()=>AZ(e),{capture:!0,passive:!0}),Et(e.document.body,"pointerleave",()=>RZ(e),{capture:!0,passive:!0}),Et(e.document.body,"copy",x=>ZZ(x,e)),Et(e.document.body,"cut",x=>XZ(x,e)),Et(e.document.body,"paste",x=>EZ(x,e))));var n=mE(),r=Ue(n);{const x=(y,k=N1)=>{var Q=HX();Oa(Q,20,()=>e.table.colIndices,E=>E,(E,W)=>{const X=H(()=>({row:k(),col:W})),D=H(()=>({top:k()===e.table.firstRowIndex,left:W===e.table.firstColIndex})),_=H(()=>e.selection.isCell()&&Pr($(X),e.selection.cell));{let F=H(()=>{var U;return((U=e.outlinedSection)==null?void 0:U.containsOnEdge($(X)))??{top:!1,right:!1,bottom:!1,left:!1}}),G=H(()=>{var U;return(U=e.move)==null?void 0:U.cellMovement($(X))});BZ(E,{get location(){return $(X)},get alignment(){return e.table.alignments[W]},get selected(){return $(_)},get position(){return $(D)},get outline(){return $(F)},get movement(){return $(G)},get win(){return e.window},children:(U,Zt)=>{var zt=UX(),Bt=Xt(zt);Oa(Bt,16,()=>kZ($(X),$(D)),yt=>yt,(yt,Nt)=>{{let re=H(()=>e.cellHandleState($(X),Nt)),be=H(()=>L(e.resize));cg(yt,{get of(){return Nt},get state(){return $(re)},get toggle(){return $(be)}})}});var lt=et(Bt,2);eX(lt,{get hidden(){return $(_)},children:(yt,Nt)=>{var re=zd(),be=Xt(re);R5(be,()=>SZ(e.table.cellAt($(X)),e.highlighter($(X)))),I(yt,re)},$$slots:{default:!0}});var Dt=et(lt,2);{var $e=yt=>{var Nt=()=>e.table.cellAt($(X)),re=pt=>e.table.setCellAt($(X),pt),be=()=>e.selection.cellSection,tt=pt=>{e.selectionValue={cell:$(X),section:pt}};{let pt=H(()=>e.highlighter($(X)));GZ(yt,{get text(){return Nt()},set text(mt){re(mt)},get selection(){return be()},set selection(mt){tt(mt)},get selectionType(){return e.selectionType},get lineWrapping(){return e.lineWrapping},get extensions(){return e.extensions},get markdownConfig(){return e.markdownConfig},get rootEditor(){return e.rootEditor},get globalKeyBindings(){return e.globalKeyBindings},get highlighter(){return $(pt)},onbeforeinput:mt=>HZ(mt,e),ondragstart:mt=>FZ(mt),onkeydown:(mt,At)=>KZ(mt,At,e),onpaste:mt=>JZ(mt,e)})}};Ft(Dt,yt=>{$(_)&&yt($e)})}I(U,zt)},$$slots:{default:!0}})}}),I(y,Q)};var s=Ue(r),o=Ue(s);x(o,()=>e.table.headerRowIndex);var l=et(s);{var a=y=>{var k=FX();Oa(k,20,()=>e.table.dataRowIndices,Q=>Q,(Q,E)=>{x(Q,()=>E)}),I(y,k)},c=H(()=>e.table.hasDataRows());Ft(l,y=>{$(c)&&y(a)})}bc(r,y=>e.tableElement=y,()=>e==null?void 0:e.tableElement)}var h=et(r,2);{var u=x=>{const y=H(()=>e.menu.type==="row"?"row":"column");IZ(x,{get to(){return e.menuRootElement},children:(k,Q)=>{oX(k,{translate:E=>e.menu.computeTranslation(E),children:(E,W)=>{const X=H(()=>{const{addable:tt,alignable:pt,clearable:mt,duplicatable:At,moveable:Yt,removable:Wt,sortable:fe}=e.menu.capabilities;return{addable:tt,alignable:pt,clearable:mt,duplicatable:At,moveable:Yt,removable:Wt,sortable:fe}});var D=pE(),_=Xt(D);{var F=tt=>{var pt=tE(),mt=Xt(pt);Ae(mt,{onclick:()=>Re({action:"sort",direction:"ascending"},e),children:(Wt,fe)=>{var ut=KX(),gt=Xt(ut);Ze(gt,{name:"sort-ascending"});var _t=et(gt,2);Xe(_t,{children:(kt,Ut)=>{var Rt=Te();se(()=>Bi(Rt,`Sort by ${$(y)??""} (A-Z)`)),I(kt,Rt)}}),I(Wt,ut)}});var At=et(mt,2);Ae(At,{onclick:()=>Re({action:"sort",direction:"descending"},e),children:(Wt,fe)=>{var ut=JX(),gt=Xt(ut);Ze(gt,{name:"sort-descending"});var _t=et(gt,2);Xe(_t,{children:(kt,Ut)=>{var Rt=Te();se(()=>Bi(Rt,`Sort by ${$(y)??""} (Z-A)`)),I(kt,Rt)}}),I(Wt,ut)}});var Yt=et(At,2);ga(Yt),I(tt,pt)};Ft(_,tt=>{$(X).sortable&&tt(F)})}var G=et(_,2);{var U=tt=>{var pt=sE(),mt=Xt(pt);Ae(mt,{onclick:()=>Re({action:"align",alignment:"none"},e),children:(ut,gt)=>{var _t=eE(),kt=Xt(_t);Ze(kt,{name:"align-none"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,si)=>{var Wi=Te("Align none");I(Rt,Wi)}}),I(ut,_t)}});var At=et(mt,2);Ae(At,{onclick:()=>Re({action:"align",alignment:"left"},e),children:(ut,gt)=>{var _t=iE(),kt=Xt(_t);Ze(kt,{name:"align-left"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,si)=>{var Wi=Te("Align left");I(Rt,Wi)}}),I(ut,_t)}});var Yt=et(At,2);Ae(Yt,{onclick:()=>Re({action:"align",alignment:"center"},e),children:(ut,gt)=>{var _t=nE(),kt=Xt(_t);Ze(kt,{name:"align-center"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,si)=>{var Wi=Te("Align center");I(Rt,Wi)}}),I(ut,_t)}});var Wt=et(Yt,2);Ae(Wt,{onclick:()=>Re({action:"align",alignment:"right"},e),children:(ut,gt)=>{var _t=rE(),kt=Xt(_t);Ze(kt,{name:"align-right"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,si)=>{var Wi=Te("Align right");I(Rt,Wi)}}),I(ut,_t)}});var fe=et(Wt,2);ga(fe),I(tt,pt)};Ft(G,tt=>{$(X).alignable&&tt(U)})}var Zt=et(G,2);{var zt=tt=>{var pt=aE(),mt=Xt(pt);Ae(mt,{onclick:()=>Re({action:"add",direction:"before"},e),children:(Wt,fe)=>{var ut=oE(),gt=Xt(ut);Ze(gt,{name:"add-before"});var _t=et(gt,2);Xe(_t,{children:(kt,Ut)=>{var Rt=Te();se(()=>Bi(Rt,`Add ${$(y)??""} ${$(y)==="row"?"above":"before"}`)),I(kt,Rt)}}),I(Wt,ut)}});var At=et(mt,2);Ae(At,{onclick:()=>Re({action:"add",direction:"after"},e),children:(Wt,fe)=>{var ut=lE(),gt=Xt(ut);Ze(gt,{name:"add-after"});var _t=et(gt,2);Xe(_t,{children:(kt,Ut)=>{var Rt=Te();se(()=>Bi(Rt,`Add ${$(y)??""} ${$(y)==="row"?"below":"after"}`)),I(kt,Rt)}}),I(Wt,ut)}});var Yt=et(At,2);ga(Yt),I(tt,pt)};Ft(Zt,tt=>{$(X).addable&&tt(zt)})}var Bt=et(Zt,2);{var lt=tt=>{var pt=uE(),mt=Xt(pt);{var At=ut=>{Ae(ut,{onclick:()=>Re({action:"move",direction:"backward"},e),children:(gt,_t)=>{var kt=cE(),Ut=Xt(kt);{let si=H(()=>`move-${$(y)==="row"?"up":"left"}`);Ze(Ut,{get name(){return $(si)}})}var Rt=et(Ut,2);Xe(Rt,{children:(si,Wi)=>{var So=Te();se(()=>Bi(So,`Move ${$(y)??""} ${$(y)==="row"?"up":"left"}`)),I(si,So)}}),I(gt,kt)}})};Ft(mt,ut=>{($(X).moveable==="backward"||$(X).moveable===!0)&&ut(At)})}var Yt=et(mt,2);{var Wt=ut=>{Ae(ut,{onclick:()=>Re({action:"move",direction:"forward"},e),children:(gt,_t)=>{var kt=hE(),Ut=Xt(kt);{let si=H(()=>`move-${$(y)==="row"?"down":"right"}`);Ze(Ut,{get name(){return $(si)}})}var Rt=et(Ut,2);Xe(Rt,{children:(si,Wi)=>{var So=Te();se(()=>Bi(So,`Move ${$(y)??""} ${$(y)==="row"?"down":"right"}`)),I(si,So)}}),I(gt,kt)}})};Ft(Yt,ut=>{($(X).moveable==="forward"||$(X).moveable===!0)&&ut(Wt)})}var fe=et(Yt,2);ga(fe),I(tt,pt)};Ft(Bt,tt=>{$(X).moveable!==!1&&tt(lt)})}var Dt=et(Bt,2);{var $e=tt=>{Ae(tt,{onclick:()=>Re({action:"duplicate"},e),children:(pt,mt)=>{var At=fE(),Yt=Xt(At);Ze(Yt,{name:"duplicate"});var Wt=et(Yt,2);Xe(Wt,{children:(fe,ut)=>{var gt=Te();se(()=>Bi(gt,`Duplicate ${$(y)??""}`)),I(fe,gt)}}),I(pt,At)}})};Ft(Dt,tt=>{$(X).duplicatable&&tt($e)})}var yt=et(Dt,2);{var Nt=tt=>{Ae(tt,{onclick:()=>Re({action:"clear"},e),children:(pt,mt)=>{var At=dE(),Yt=Xt(At);Ze(Yt,{name:"clear"});var Wt=et(Yt,2);Xe(Wt,{children:(fe,ut)=>{var gt=Te();se(()=>Bi(gt,`Clear ${$(y)??""}`)),I(fe,gt)}}),I(pt,At)}})};Ft(yt,tt=>{$(X).clearable&&tt(Nt)})}var re=et(yt,2);{var be=tt=>{Ae(tt,{onclick:()=>Re({action:"remove"},e),children:(pt,mt)=>{var At=OE(),Yt=Xt(At);Ze(Yt,{name:"remove"});var Wt=et(Yt,2);Xe(Wt,{children:(fe,ut)=>{var gt=Te();se(()=>Bi(gt,`Delete ${$(y)??""}`)),I(fe,gt)}}),I(pt,At)}})};Ft(re,tt=>{$(X).removable&&tt(be)})}I(E,D)},$$slots:{default:!0}})},$$slots:{default:!0}})},f=H(()=>L(e.menu));Ft(h,x=>{$(f)&&x(u)})}var d=et(h,2);Oa(d,16,()=>yZ,x=>x,(x,y)=>{{let k=H(()=>{var Q;return kf((Q=e.activeHandle)==null?void 0:Q.handle,y)?e.activeHandle.state:void 0});cg(x,{get of(){return y},get state(){return $(k)}})}});var O=et(d,2);{var p=x=>{DZ(x)},m=H(()=>!e.interactive&&V(e.outline));Ft(O,x=>{$(m)&&x(p)})}var g=et(O,2);{var b=x=>{xX(x)},S=H(()=>e.selection.isAll());Ft(g,x=>{$(S)&&x(b)})}bc(n,x=>e.wrapperElement=x,()=>e==null?void 0:e.wrapperElement),se(x=>$t(n,"data-select-all",x),[()=>gr(e.selection.isAll())]),Mo("mouseover",n,x=>BX(x,e)),Mo("mouseout",n,x=>qX(x,e)),Mo("pointerdown",n,x=>NX(x,e)),fa("dragover",n,x=>GX(x)),Mo("keydown",r,x=>EX(x,e)),fa("copy",r,x=>RX(x,e)),fa("cut",r,x=>ZX(x,e)),fa("paste",r,x=>XX(x,e)),I(i,n),Yn()}MS(["mouseover","mouseout","pointerdown","keydown"]);class Kd extends Ln{constructor(e,n){super();C(this,"tableDescription");C(this,"widgetElement");C(this,"height");C(this,"destroyWidgetElement");this.tableDescription=e;const r=$E(n);if(L(r)){const{widgetElement:s,destroyWidgetElement:o}=this.create(r);this.widgetElement=s,this.destroyWidgetElement=o,this.height=D5(r,s)}else this.widgetElement=void 0,this.destroyWidgetElement=void 0,this.height=Nm}get estimatedHeight(){return this.height}coordsAt(e,n,r){const s=this.tableDescription.source.closestCell(n),o=Sc(e,s);if(V(o))return null;const l=o.getBoundingClientRect();return{top:l.top,right:l.right,bottom:l.bottom,left:l.left}}toDOM(e){if(L(this.widgetElement))return this.widgetElement;const{widgetElement:n,destroyWidgetElement:r}=this.create(e);return this.widgetElement=n,this.destroyWidgetElement=r,e.requestMeasure({read:()=>{this.height=n.getBoundingClientRect().height}}),n}destroy(e){var n;(n=this.destroyWidgetElement)==null||n.call(this),this.destroyWidgetElement=void 0,this.widgetElement=void 0,this.height=Nm}create(e){const n=bl(e.dom).createElement("div");n.className="tbl-table-widget",n.tabIndex=-1,n.addEventListener("pointerdown",O=>{(O==null?void 0:O.target)===n&&O.preventDefault()});const r=this.tableDescription,s=p5(()=>{Kc(()=>{const O=!r.table.text.eq(r.editorTableText),p=!ih(r.selection.value,r.editorSelectionValue);if(!O&&!p)return;const m=O?r.source.applyContent(r.table.text,r.editorTableText):void 0,g=O?new ro(m,r.table.colCount):r.source;let b;if(r.selection.isCell()){const{from:x}=g.cellSpan(r.selection.cell);b={anchor:r.from+x+r.selection.cellSection.anchor,head:r.from+x+r.selection.cellSection.head}}else r.selection.isAll()?b={anchor:r.from,head:r.to}:r.selection.isHidden()&&(b={anchor:r.from+1,head:r.from+1});const S=O?{from:r.from,to:r.to,insert:m}:void 0;r.markSynchronized(),e.dispatch({annotations:Gr("table.edit"),changes:S,selection:b})})}),{extensions:o,markdownConfig:l,globalKeyBindings:a,selectionType:c,lineWrapping:h}=wv(e.state),u=zS(gE,{target:n,props:{table:r.table,selection:r.selection,scrollElement:n,rootEditor:e,extensions:o,markdownConfig:l,globalKeyBindings:a,selectionType:c,lineWrapping:h,menuRootElement:Ck(e,nv).dom,onUndo:()=>id(e),onRedo:()=>Ka(e),onNavigate:O=>{const p=O==="before"?r.from-1:r.to+1;p<0||p>e.state.doc.length||(e.dispatch({annotations:Gr("table.navigate"),selection:{anchor:p}}),e.focus())},onDelete:()=>{e.dispatch({annotations:Gr("table.delete"),changes:{from:r.from,to:r.to},selection:e.state.selection}),e.focus()}}}),f=()=>{_S(u)},d=Y5(n,({height:O})=>{this.height=O});return{widgetElement:n,destroyWidgetElement:Cr(s,f,d)}}static of(e,n){return new Kd(e,n)}}function bE(i,t){return{widget:Kd.of(i,t),block:!0,inclusive:!0}}function wE(i,t){return K.replace(bE(i,t))}function SE(i,t){const e=new qs;for(const n of i)e.add(n.from,n.to,wE(n,t));return e.finish()}function vE(i){return gv(i)}function xE(i,t){return gv(i,t)}function gv(i,t=[]){const e=[];return kA(St(i),n=>{L1(n)&&e.push({from:i.doc.lineAt(n.from).from,to:i.doc.lineAt(n.to).to})}),{spans:e,formatting:[],complete:Gk(i)}}const yE={create(i){return ba(i)},update(i,t){if(eZ(t))return ba(t.state);if(!t.docChanged&&V(t.selection)&&i.complete)return i;const{tables:e,formatting:n,decorations:r}=i;if(!t.docChanged&&i.complete)return{tables:fg(e,t),formatting:n,decorations:r.map(t.changes),complete:!0};if(tZ(t)||kE(t,e))return ba(t.state);const s=fg(e,t).map(c=>c.span),{complete:o,spans:l,formatting:a}=xE(t.state,s);return mn(s,l,aR)?{complete:o,tables:e,formatting:a,decorations:r.map(t.changes)}:ba(t.state)},provide(i){return z.decorations.from(i,t=>t.decorations)}},bv=mi.define(yE);function ba(i){const{spans:t,formatting:e,complete:n}=vE(i),{doc:r,selection:s}=i,o=t.map(l=>xf.of({span:l,doc:r,selection:s}));return{complete:n,tables:o,formatting:e,decorations:SE(o,i)}}function kE(i,t){return!GS(i)&&t.some(e=>i.changes.touchesRange(e.from,e.to)!==!1)}function fg(i,t){return PA(i,e=>e.applyTransaction(t))}const QE={create(){return{view:void 0}},update(i){return i}},Jd=mi.define(QE);function wv(i){return i.facet(rf)}function uo(i){return i.field(bv)}function $E(i){return i.field(Jd).view}function CE(i){const{handlePosition:t,selectionType:e,lineWrapping:n}=wv(i);return{...Uc(window)?{"data-tbl-hoverable":""}:{},"data-tbl-theme-mode":i.facet(z.darkTheme)?"dark":"light","data-tbl-handle-position":t,"data-tbl-selection-type":e,"data-tbl-line-wrapping":n}}const PE=["undo","redo","select.undo","select.redo"];function TE(i){return PE.some(t=>i.isUserEvent(t))}function AE(i){return Sv(i,"select.search")}function RE(i){return Sv(i,"select")}function ZE(i){return i.isUserEvent("delete.forward")}function XE(i){return i.isUserEvent("delete.backward")}function Sv(i,t){return i.annotation(Lt.userEvent)===t}const EE=({state:i,view:t,transactions:e})=>{t.hasFocus||uo(i).tables.some(n=>n.containsSelection())||e.some(n=>TE(n)||AE(n)&&!dv(t))&&t.focus()},vv=Pt.define(),LE=new Map(NS.map(i=>[i,vv.of(i)]));function xv(i){return LE.get(i)}const ME=(i,t)=>!t||!uo(i).tables.some(e=>e.containsSelection())?null:xv("table.focus"),zE=i=>{const{selection:t,startState:e,docChanged:n}=i;if(V(t)||n||!RE(i)||!hc(t)||!hc(e.selection))return i;const r=e.selection.main,s=t.main;for(const o of uo(e).tables){const l=o.from===s.head,a=o.to===s.head,c=o.from===r.head+1&&o.to===s.head-1,h=o.from===s.head+1&&o.to===r.head-1;let u;if(l?u=o.source.cellSpan(o.table.firstCellLocation).from:c?u=o.source.cellSpan(o.table.firstCellLocation).to:(a||h)&&(u=o.source.cellSpan(o.table.lastCellLocation).to),L(u))return[i,{annotation:Gr("table.navigate"),selection:oA({pos:o.from+u})}]}return i},_E=i=>{const{selection:t,startState:e}=i;if(V(t)||!hc(t))return i;const n=e.selection.main;if(ZE(i)){for(const r of uo(e).tables)if(n.head===r.from-1){const s=r.source.cellSpan(r.table.firstCellLocation).from;return[{selection:{anchor:r.from+s,head:r.from+s}}]}return i}else if(XE(i)){for(const r of uo(e).tables)if(n.head===r.to+1){const s=r.source.cellSpan(r.table.lastCellLocation).to;return[{selection:{anchor:r.from+s,head:r.from+s}}]}return i}else return i};function IE(i,{anchor:t,head:e,goalColumn:n,bidiLevel:r}={}){return P.range(t??i.anchor,e??i.head,n??i.goalColumn,r??i.bidiLevel??void 0)}const jE=i=>{const{selection:t,startState:e,docChanged:n}=i;if(V(t)||n||hc(t))return i;const r=t.ranges.map(s=>{if(s.empty)return s;const o=uo(e).tables,l=dg(s.anchor,o,e.doc.length),a=dg(s.head,o,e.doc.length);return L(l)||L(a)?IE(s,{anchor:l,head:a}):s});return mn(t.ranges,r,(s,o)=>s===o)?i:[i,{annotations:Gr("table.select"),selection:P.create(r,t.mainIndex)}]};function dg(i,t,e){for(const n of t){const r=n.from,s=n.to,o=n.from+1,l=n.to-1;if(i===r||i===o)return Math.max(0,r-1);if(i===s||i===l)return Math.min(e,s+1)}}const DE={"& .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"}},YE={'&[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"}},WE={".cm-tooltip.tbl-menu-tooltip":{border:"none","user-select":"none","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}}},VE={".tbl-blocking-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"transparent",width:"100%",height:"100%"}},BE={"& .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)"}},qE={".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)"}},NE={'&[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"}},GE={".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}},UE={".tbl-menu-item-icon":{"z-index":200,width:"1em",height:"1em","pointer-events":"none","font-size":"var(--tbl-style-menu-font-size)"}},HE={".tbl-menu-item-text":{"z-index":200,"pointer-events":"none","user-select":"none","font-size":"var(--tbl-style-menu-font-size)"}},FE={".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)"}}},KE={".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)"}},JE={".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)"}},tL={".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"}},eL={"& .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)"}},iL={...DE,...WE,...YE,...eL,...VE,...qE,...BE,...NE,...GE,...JE,...FE,...UE,...HE,...KE,...tL},nL=i=>{var e;const t=(e=i.effects.find(n=>n.is(vv)))==null?void 0:e.value;return L(t)?{annotations:Gr(t)}:null},rL=i=>{const t=i.annotation(jd);return L(t)?[xv(H5(t))]:[]};class tO{static of(t){return t.state.field(Jd).view=t,new tO}constructor(){}}function sL(i){return[rf.of(i),bv,Jd,Fe.define(t=>tO.of(t)),z.editorAttributes.compute([rf,z.darkTheme],CE),z.baseTheme(iL),z.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}),z.theme({":where(:root:has(&))":i.style.props}),v0.of(rL),n0.of(nv),J.transactionExtender.of(nL),J.transactionFilter.of(_E),J.transactionFilter.of(zE),J.transactionFilter.of(jE),z.updateListener.of(EE),z.clipboardInputFilter.of(sR),z.focusChangeEffect.of(ME)]}function oL(i){return sL(Z1(i))}const lL=new Set(["about:","blob:","chrome-extension:","chrome:","data:","devtools:","file:","filesystem:","javascript:","view-source:"]);function yv(i,t){try{const e=new URL(t),n=new URL(i,e);return n.protocol==="http:"||n.protocol==="https:"?{kind:"web",url:n.href}:lL.has(n.protocol)?{kind:"browser-local",url:n.href}:{kind:"application",url:n.href}}catch{return{kind:"invalid"}}}const kv="cm-md-mark",Qv="cm-md-inline-code",$f="cm-md-list-item",Cf="cm-md-list-bullet",$v="cm-md-blockquote-line",Cv="cm-md-fenced-line",Pv="cm-md-hr",Tv="cm-md-task-checkbox",Av="cm-md-heading-1",Rv="cm-md-heading-2",eO="cm-md-link",Zv="cm-md-tag",Xv="cm-md-list-indent-source",Og="1.2em",aL="0.62em",Ro=K.replace({}),qn=K.mark({class:kv}),cL=K.mark({class:Xv}),hL=K.mark({class:Qv}),uL=K.line({class:Cf}),fL=K.line({class:$v}),dL=K.line({class:Cv}),OL=K.line({class:Av}),pL=K.line({class:Rv}),mL=K.mark({class:Zv});class gL extends Ln{toDOM(){const t=document.createElement("hr");return t.className=Pv,t}eq(t){return!0}ignoreEvent(){return!0}}const bL=K.replace({widget:new gL});class wL extends Ln{constructor(e,n,r){super();C(this,"checked");C(this,"from");C(this,"to");this.checked=e,this.from=n,this.to=r}eq(e){return e.checked===this.checked&&e.from===this.from&&e.to===this.to}toDOM(e){const n=document.createElement("input");return n.type="checkbox",n.checked=this.checked,n.className=Tv,n.tabIndex=-1,n.addEventListener("mousedown",r=>{r.preventDefault()}),n.addEventListener("change",()=>{const r=this.checked?"[ ]":"[x]";e.dispatch({changes:{from:this.from,to:this.to,insert:r}})}),n}ignoreEvent(e){return e.type!=="click"&&e.type!=="change"&&e.type!=="mousedown"}}const SL=new Set(["EmphasisMark","LinkMark","URL"]),vL=new Set(["HeaderMark","QuoteMark"]),pg=/(^|\s)(#[\p{L}\p{N}_/-]+)/gu,xL=/[/.,;:!?]+$/u,yL=new RegExp("\\p{L}","u"),kL=new Set(["InlineCode","FencedCode","URL","Link"]);function QL(i,t,e,n,r,s){return vL.has(i)?{kind:"block",contextFrom:r,contextTo:s}:i==="CodeMark"?t==="InlineCode"&&e!==null&&n!==null?{kind:"inline",contextFrom:e,contextTo:n}:null:SL.has(i)?e===null||n===null?null:{kind:"inline",contextFrom:e,contextTo:n}:null}function gn(i,t,e,n){return i<=n&&t>=e}function $L(i,t,e,n){const r=i.doc.lineAt(n);return gn(t,e,r.from,r.to)}function CL(i,t,e,n){return t.kind==="inline"?!gn(e,n,t.contextFrom,t.contextTo):!$L(i,e,n,t.contextFrom)}function PL(i){let t=i.firstChild;for(;t;){if(t.name==="TaskMarker")return!0;if(t.name==="Task"){let e=t.firstChild;for(;e;){if(e.name==="TaskMarker")return!0;e=e.nextSibling}}t=t.nextSibling}return!1}function TL(i){let t=i.parent;for(;t;){if(t.name==="ListItem")return t;t=t.parent}return null}function Hn(i,t){let e=i.firstChild;for(;e;){if(e.name===t)return e;e=e.nextSibling}return null}function mg(i,t){const e=[];let n=t.firstChild;for(;n;)n.name==="CodeMark"&&e.push(n),n=n.nextSibling;if(e.length>=2)return{from:t.from,to:e[e.length-1].to,closed:!0};const r=i.doc.lineAt(t.from);return{from:r.from,to:r.to,closed:!1}}function Ev(i,t){let e=t.to;for(;e<i.doc.length&&i.doc.sliceString(e,e+1)===" ";)e+=1;return{from:t.from,to:e}}function Kh(i,t){return{from:i.doc.lineAt(t.from).from,to:Ev(i,t).to}}function Jh(i,t){return Ev(i,t)}function gg(i,t,e){const n=Hn(t,"ListMark"),r=n?i.doc.lineAt(n.from).from:e.from;let s=e.to;for(;s<i.doc.length&&i.doc.sliceString(s,s+1)===" ";)s+=1;return{from:r,to:s}}function tu(i,t,e){const n=i.doc.lineAt(t.from);n.from<t.from&&e.push(cL.range(n.from,t.from))}function AL(i,t,e){let n=0;for(let r=t;r<e;r+=1)n+=i.doc.sliceString(r,r+1)===" "?2:1;return n}function RL(i){return K.line({class:$f,attributes:{style:`--cm-md-list-indent: ${i.prefixRevealed?0:i.indentColumns};`}})}function bg(i,t,e,n,r){let s=t;for(;s<=e;){const o=i.doc.lineAt(s);if(r.push(n.range(o.from)),o.to>=e)break;s=o.to+1}}function ZL(i,t,e,n){const r=Hn(t,"ListMark"),s=i.doc.lineAt(r?r.from:t.from).from,o=r?AL(i,s,r.from):0;let l=t.from;for(;l<=t.to;){const a=i.doc.lineAt(l),c=a.from===s,h=/^\s/.test(a.text);if(c||h){const u=e.get(a.from),f={indentColumns:o,prefixRevealed:c&&n};u===void 0||o>u.indentColumns?e.set(a.from,f):o===u.indentColumns&&f.prefixRevealed&&e.set(a.from,{...u,prefixRevealed:!0})}if(a.to>=t.to)break;l=a.to+1}}function XL(i,t){let e=i.resolveInner(t,1);for(;e;){if(kL.has(e.name)||e.name.startsWith("Table"))return!0;e=e.parent}return!1}function EL(i,t){const e=/^( {0,3})(#{1,6})(?:\s|$)/.exec(i);if(!e)return!1;const n=e[1]??"",r=e[2]??"",s=n.length,o=s+r.length;return t>=s&&t<o}function LL(i,t,e){for(let n=1;n<=i.doc.lines;n+=1){const r=i.doc.line(n);pg.lastIndex=0;let s;for(;(s=pg.exec(r.text))!==null;){const o=s[1]??"",a=(s[2]??"").replace(xL,"");if(a.length<=1||!yL.test(a))continue;const c=r.from+s.index+o.length,h=c+a.length;EL(r.text,c-r.from)||XL(t,c)||e.push(mL.range(c,h))}}}function wg(i,t,e,n){const r=[],s=new Map,o=new Set,l=i.selection.main,a=n?Math.min(l.from,l.to):-1,c=n?Math.max(l.from,l.to):-1;e.iterate({from:0,to:i.doc.length,enter:h=>{var p,m;if(h.name==="Table"||h.name.startsWith("Table"))return!1;const u=h.node.parent,f=(u==null?void 0:u.name)??null;let d=h.to;(h.name==="HeaderMark"||h.name==="QuoteMark")&&i.doc.sliceString(d,d+1)===" "&&(d+=1);const O=QL(h.name,f,(u==null?void 0:u.from)??null,(u==null?void 0:u.to)??null,h.from,d);if(O){const g=CL(i,O,a,c)?Ro:qn;r.push(g.range(h.from,d))}if(h.name==="ListMark"){const g=h.node.parent;if(g&&g.name==="ListItem"){const b=PL(g),S=((p=g.parent)==null?void 0:p.name)==="OrderedList";if(!b&&!S){const x=Kh(i,h.node),y=Jh(i,h.node);gn(a,c,x.from,x.to)?(tu(i,h.node,r),r.push(qn.range(y.from,y.to))):r.push(Ro.range(x.from,x.to))}else if(S){const x=i.doc.lineAt(h.node.from),y=Kh(i,h.node);x.from<h.node.from&&(gn(a,c,y.from,y.to)?tu(i,h.node,r):r.push(Ro.range(x.from,h.node.from))),r.push(qn.range(h.node.from,h.node.to))}}}if(h.name==="InlineCode"){const g=h.node.firstChild,b=h.node.lastChild;g&&b&&g!==b&&g.name==="CodeMark"&&b.name==="CodeMark"&&g.to<b.from&&r.push(hL.range(g.to,b.from))}if(h.name==="ListItem"){const g=Hn(h.node,"ListMark"),b=Hn(h.node,"Task"),S=Hn(h.node,"TaskMarker")??(b?Hn(b,"TaskMarker"):null),x=S!==null,y=((m=h.node.parent)==null?void 0:m.name)==="OrderedList";let k=!1;if(g){const Q=S?gg(i,h.node,S):Kh(i,g);k=gn(a,c,Q.from,Q.to)}if(ZL(i,h.node,s,k),!x&&!y&&g&&!k){const Q=i.doc.lineAt(h.from);o.add(Q.from)}}else if(h.name==="Blockquote")bg(i,h.from,h.to,fL,r);else if(h.name==="ATXHeading1"){const g=i.doc.lineAt(h.from);r.push(OL.range(g.from))}else if(h.name==="ATXHeading2"){const g=i.doc.lineAt(h.from);r.push(pL.range(g.from))}else if(h.name==="FencedCode"){const g=mg(i,h.node);bg(i,g.from,g.to,dL,r)}if(h.name==="Link"){let g=null,b=null,S=null,x=h.node.firstChild;for(;x;)x.name==="LinkMark"?g===null?g=x:b=x:x.name==="URL"&&(S=x),x=x.nextSibling;if(g&&b&&S&&g.to<b.from){const y=i.doc.sliceString(S.from,S.to),k=K.mark({class:eO,tagName:"a",attributes:{"data-href":y}});r.push(k.range(g.to,b.from))}}if(h.name==="CodeMark"&&f==="FencedCode"){const g=h.node.parent;if(g){const b=mg(i,g);if(b.closed){const S=gn(a,c,b.from,b.to)?qn:Ro;r.push(S.range(h.from,h.to))}else r.push(qn.range(h.from,h.to))}}if(h.name==="HorizontalRule"){const g=i.doc.lineAt(h.from);g.to>g.from&&!gn(a,c,g.from,g.to)&&r.push(bL.range(g.from,g.to))}if(h.name==="TaskMarker"){const g=TL(h.node),b=g?Hn(g,"ListMark"):null,S=g?gg(i,g,h.node):{from:h.from,to:h.to};if(gn(a,c,S.from,S.to)){if(b){const y=Jh(i,b);tu(i,b,r),r.push(qn.range(y.from,y.to))}r.push(qn.range(h.from,h.to))}else{if(b){const E=Jh(i,b),W=i.doc.lineAt(b.from).from;r.push(Ro.range(W,E.to))}const y=i.doc.sliceString(h.from,h.to),k=y==="[x]"||y==="[X]",Q=K.replace({widget:new wL(k,h.from,h.to)});r.push(Q.range(h.from,h.to))}}}});for(const[h,u]of s)r.push(RL(u).range(h));for(const h of o)r.push(uL.range(h));return LL(i,e,r),K.set(r,!0)}const ML=Fe.fromClass(class{constructor(i){C(this,"decorations");this.decorations=wg(i.state,i.visibleRanges,St(i.state),i.hasFocus)}update(i){(i.docChanged||i.selectionSet||i.viewportChanged||i.focusChanged||St(i.state)!==St(i.startState))&&(this.decorations=wg(i.state,i.view.visibleRanges,St(i.state),i.view.hasFocus))}},{decorations:i=>i.decorations}),zL=z.theme({"&":{fontFamily:"var(--font-sans)",fontSize:"calc(var(--text-base) + 0.5px)",lineHeight:"1.5"},".cm-scroller":{fontFamily:"inherit",fontSize:"inherit",lineHeight:"inherit"},".cm-content":{fontFamily:"inherit",fontSize:"inherit",lineHeight:"inherit",padding:"1.5rem 1rem"},[`.${Xv}`]:{fontFamily:"var(--font-mono)"},[`.${kv}`]:{fontFamily:"var(--font-mono)",fontSize:"0.9em"},[`.${Av}`]:{fontSize:"1.3em"},[`.${Rv}`]:{fontSize:"1.1em"},[`.${Qv}`]:{fontFamily:"var(--font-mono)",fontSize:"0.92em",padding:"1px 4px",borderRadius:"3px"},[`.${Zv}`]:{borderRadius:"var(--radius-pill)",padding:"0 0.35em",fontWeight:"600",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone"},[`.${$f}`]:{paddingLeft:`calc(0.5rem + var(--cm-md-list-indent, 0) * ${aL})`},[`.${$f}.${Cf}`]:{borderLeft:`${Og} solid transparent`},[`.${Cf}::before`]:{content:"'•'",marginLeft:`calc(-1 * ${Og})`,fontFamily:"var(--font-mono)",fontSize:"0.9em",paddingRight:"0.5rem"},[`.${$v}`]:{borderLeft:"3px solid transparent",paddingLeft:"1rem",marginLeft:"0.25rem"},[`.${Cv}`]:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:"0.92em",paddingLeft:"0.75em"},[`.${Pv}`]:{display:"inline-block",verticalAlign:"middle",border:"none",borderTop:"1px solid transparent",margin:0,width:"100%"},[`.${Tv}`]:{margin:"0 0.4em 0 0",cursor:"default",verticalAlign:"middle"},[`a.${eO}`]:{textDecoration:"underline",textUnderlineOffset:"0.15em",cursor:"pointer"}}),_L=4;function Lv(i){return i instanceof Element?i.closest(`a.${eO}`):null}function IL(i){const t=i.getAttribute("data-href");if(t===null)return null;try{return new URL(t,window.document.baseURI).href}catch{return null}}function Mv(){return window.__televisionContentBridge}function jL(i){const t={type:"navigation-request",url:i},e=Mv();if(e){e.postToHost(t);return}window.parent.postMessage(t,"*")}function DL(i){const t=Mv();if(t!=null&&t.openApplicationLink){t.openApplicationLink(i);return}window.location.href=i}function YL(i,t){return Math.hypot(t.clientX-i.x,t.clientY-i.y)>_L}let zr=null;function Sg(i){const t=Lv(i.target);if(!t||i.altKey)return zr=null,!1;const e=zr;if(zr=null,!e||e.anchor!==t)return!1;if(i.preventDefault(),YL(e,i))return!0;const n=yv(e.url,window.document.baseURI);return n.kind==="application"?DL(n.url):n.kind==="web"&&e.openExternally?window.open(n.url,"_blank","noopener,noreferrer"):n.kind==="web"&&jL(n.url),!0}const Ea={mousedown(i){const t=Lv(i.target);if(zr=null,!t||i.button!==0&&i.button!==1||i.altKey)return!1;const e=IL(t);return e===null||i.button===1&&yv(e,window.document.baseURI).kind!=="application"?!1:(zr={anchor:t,url:e,openExternally:i.metaKey||i.ctrlKey,x:i.clientX,y:i.clientY},i.preventDefault(),!0)},click(i){return i.button!==0?!1:Sg(i)},auxclick(i){return i.button!==1?!1:Sg(i)}},WL=z.domEventHandlers(Ea),Pf=/^(\d+)([.)])(\s|$)/;function VL(i,t){const e=[];let n=[],r=0;const s=a=>{o&&t.some(c=>c.from<=a&&c.to>=r)&&e.push(...n),n=[]};let o=!1,l=1;for(let a=1;a<=i.doc.lines;a+=1){const c=i.doc.line(a),h=Pf.exec(c.text);h?(o||(o=!0,l=1,r=c.from),parseInt(h[1],10)!==l&&n.push({from:c.from,to:c.from+h[1].length,insert:String(l)}),l+=1):c.text===""&&(s(c.from-1),o=!1)}return s(i.doc.length),e}const vg=ei.define(),BL=J.transactionFilter.of(i=>{if(!i.docChanged||i.annotation(vg)||!i.isUserEvent("input")&&!i.isUserEvent("delete"))return i;const t=[];i.changes.iterChangedRanges((n,r,s,o)=>{const l=i.state.doc.lineAt(s),a=Pf.test(i.startState.doc.lineAt(n).text)&&!Pf.test(l.text);t.push({from:l.from,to:a&&l.number<i.state.doc.lines?i.state.doc.line(l.number+1).to:i.state.doc.lineAt(Math.max(s,o-1)).to})});const e=VL(i.state,t);return e.length===0?i:[i,{changes:Vt.of(e,i.state.doc.length),annotations:vg.of(!0),sequential:!0}]}),qL=/^(\s*)([-*]|\d+[.)])(\s\[[ xX]\])?\s$/,NL=i=>{const{state:t}=i,e=t.selection.main;if(e.from!==e.to)return!1;const n=t.doc.lineAt(e.from),r=n.text.slice(0,e.from-n.from);return qL.test(r)?(i.dispatch({changes:{from:e.from-1,to:e.from,insert:""},selection:{anchor:e.from-1},userEvent:"delete.backward",scrollIntoView:!0}),!0):!1},GL=hn.highest(Mn.of([{key:"Backspace",run:NL}])),UL=[ML,zL,BL,GL,WL];function HL(i){const t=i.textContent??"",e=[];fl.parser.parse(t).iterate({enter(n){if(n.name!=="Link")return;const r=n.node,s=r.getChild("LinkMark"),o=r.getChildren("LinkMark")[1],l=r.getChild("URL");!s||!o||!l||s.to>=o.from||e.push({from:n.from,to:n.to,labelFrom:s.to,labelTo:o.from,href:t.slice(l.from,l.to)})}});for(const n of e.reverse()){const r=(h,u)=>{var m;const f=i.ownerDocument.createRange(),d=i.ownerDocument.createTreeWalker(i,NodeFilter.SHOW_TEXT);let O=0,p=!1;for(let g=d.nextNode();g;g=d.nextNode()){const b=O+(((m=g.textContent)==null?void 0:m.length)??0);if(!p&&h<=b&&(f.setStart(g,h-O),p=!0),u<=b){f.setEnd(g,u-O);break}O=b}return f},s=i.ownerDocument.createElement("a");s.className="cm-md-link",s.dataset.href=n.href,s.append(r(n.labelFrom,n.labelTo).cloneContents());const o=i.ownerDocument.createElement("span");o.className="cm-md-table-link";const l=i.ownerDocument.createElement("span");l.hidden=!0,l.textContent=t.slice(n.from,n.labelFrom);const a=i.ownerDocument.createElement("span");a.hidden=!0,a.textContent=t.slice(n.labelTo,n.to),o.append(l,s,a);const c=r(n.from,n.to);c.deleteContents(),c.insertNode(o)}}const FL=Fe.fromClass(class{constructor(i){C(this,"observer");C(this,"rendered",new WeakMap);C(this,"view");C(this,"pointerdown",i=>{this.isTableLink(i)&&!i.altKey&&(i.button===0||i.button===1)&&i.stopPropagation()});C(this,"mousedown",i=>{this.isTableLink(i)&&(Ea.mousedown(i)||i.button===1&&!i.altKey)&&(i.preventDefault(),i.stopPropagation())});C(this,"click",i=>{this.isTableLink(i)&&Ea.click(i)&&i.stopPropagation()});C(this,"auxclick",i=>{this.isTableLink(i)&&Ea.auxclick(i)&&i.stopPropagation()});this.view=i,this.observer=new MutationObserver(()=>this.render()),this.observer.observe(i.dom,{childList:!0,characterData:!0,attributes:!0,attributeFilter:["data-hidden"],subtree:!0}),i.dom.addEventListener("pointerdown",this.pointerdown,!0),i.dom.addEventListener("mousedown",this.mousedown,!0),i.dom.addEventListener("click",this.click,!0),i.dom.addEventListener("auxclick",this.auxclick,!0),this.render()}render(){for(const i of this.view.dom.querySelectorAll(".tbl-cell-view:not(.cm-md-table-cell-view)")){const t=i.innerHTML;let e=this.rendered.get(i);if(!e||e.source!==t){const n=(e==null?void 0:e.display)??i.cloneNode(!1);if(n.classList.add("cm-md-table-cell-view"),n.style.display="",n.replaceChildren(...Array.from(i.childNodes,r=>r.cloneNode(!0))),HL(n),!n.querySelector("a.cm-md-link")){e==null||e.display.remove(),this.rendered.delete(i),i.style.display="";continue}i.style.display="none",e||i.after(n),e={display:n,source:t},this.rendered.set(i,e)}e.display.getAttribute("data-hidden")!==i.getAttribute("data-hidden")&&(i.hasAttribute("data-hidden")?e.display.setAttribute("data-hidden",i.getAttribute("data-hidden")??""):e.display.removeAttribute("data-hidden"))}}isTableLink(i){return i.target instanceof Element&&!!i.target.closest(".tbl-cell-view a.cm-md-link")}destroy(){this.observer.disconnect();for(const i of this.view.dom.querySelectorAll(".tbl-cell-view:not(.cm-md-table-cell-view)")){const t=this.rendered.get(i);t&&(t.display.remove(),i.style.display="")}this.view.dom.removeEventListener("pointerdown",this.pointerdown,!0),this.view.dom.removeEventListener("mousedown",this.mousedown,!0),this.view.dom.removeEventListener("click",this.click,!0),this.view.dom.removeEventListener("auxclick",this.auxclick,!0)}}),KL=500,xg=ei.define(),JL=Lc.define([{tag:v.heading,fontWeight:"600"},{tag:v.strong,fontWeight:"600"},{tag:v.emphasis,fontStyle:"italic"},{tag:v.strikethrough,textDecoration:"line-through"}]);function yg(i){const t=i.length;return({state:e,dispatch:n})=>{const r=e.changeByRange(s=>{if(s.empty)return{changes:{from:s.from,insert:i+i},range:P.cursor(s.from+t)};const o=e.sliceDoc(s.from,s.to);if(o.length>=t*2&&o.startsWith(i)&&o.endsWith(i))return{changes:[{from:s.from,to:s.from+t},{from:s.to-t,to:s.to}],range:P.range(s.from,s.to-t*2)};const l=s.from>=t&&e.sliceDoc(s.from-t,s.from)===i,a=s.to+t<=e.doc.length&&e.sliceDoc(s.to,s.to+t)===i;return l&&a?{changes:[{from:s.from-t,to:s.from},{from:s.to,to:s.to+t}],range:P.range(s.from-t,s.to-t)}:{changes:[{from:s.from,insert:i},{from:s.to,insert:i}],range:P.range(s.from+t,s.to+t)}});return n(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}const tM=hn.highest(Mn.of([{key:"Mod-b",run:yg("**")},{key:"Mod-i",run:yg("*")},{key:"Enter",run:d1({nonTightLists:!1})}])),eM=cc.default.with({"--tbl-style-font-family":"var(--font-sans)","--tbl-style-font-size":"inherit","--tbl-style-menu-font-family":"var(--font-sans)","--tbl-style-menu-font-size":"var(--text-sm, 0.875rem)","--tbl-style-default-header-alignment":"left"}),iM=oL({theme:pl.light,style:eM,selectionType:"native",handlePosition:"outside",lineWrapping:"wrap",extensions:[Mn.of(tw)],globalKeyBindings:[...$0]}),zv=[QQ(),Oo.of(" "),tM,Mn.of([...tw,...$0,$$]),Ml({extensions:[kw,Dc,{remove:["SetextHeading"]}]}),b0(JL),z.lineWrapping,UL,iM,FL];function nM(i){const{parent:t,ctx:e}=i,n=i.debounceMs??KL;let r=null,s=null,o=null;const l=f=>{h.state.doc.toString()!==f&&h.dispatch({changes:{from:0,to:h.state.doc.length,insert:f},annotations:[xg.of(!0),Lt.addToHistory.of(!1)]})},a=async()=>{o=null;const f=h.state.doc.toString();r=f;try{await e.updateContent(f),s=f}catch{const d=s??"";l(d),r=d}},c=z.updateListener.of(f=>{!f.docChanged||f.transactions.some(O=>O.annotation(xg))||(o!==null&&clearTimeout(o),o=setTimeout(()=>{a()},n))}),h=new z({parent:t,state:J.create({doc:"",extensions:[zv,c]})}),u=f=>{const d=f.content;r!==null&&d===r||(l(d),s=d)};return e.addEventListener("content-updated",u),{view:h,dispose(){o!==null&&(clearTimeout(o),o=null),e.removeEventListener("content-updated",u),h.destroy()}}}const rM=`# Heading 1
|
|
66
66
|
|
|
67
67
|
Some paragraph text with **bold**, *italic*, \`inline code\`, and an [inline link](https://example.com).
|
|
68
68
|
|