Add links to database records
CI / go (Server) (push) Failing after 20m11s
CI / mobile (push) Failing after 7m33s
CI / go (Web-App) (push) Canceled after 4s
CI / docker (push) Successful in 49m7s
Docs / build (push) Successful in 12m55s
Docs / deploy (push) Skipped
CI / frontend (push) Failing after 8m8s
CI / desktop (ubuntu-latest) (push) Successful in 1h41m4s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s

A record can be linked like a block: the page's address plus
"#r-<database>-<record>". Opening the link loads the page, scrolls to
the database and opens the record beside it; a link to a deleted record
just shows the page. Records stay part of their page, so the link needs
nothing beyond the page's own access.

"Copy link to record" is in the record's panel header and in the row's
right-click menu, which readers now get too (Open and Copy link only).
The page view opens record links the way it scrolls to block links,
retrying while the shared document loads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-11-15 11:18:03 +01:00
1 parent f7b7022958
commit db6f2caa4a
16 files changed
+181 -37

No files matched your search

+2 -1
View File
@@ -54,7 +54,8 @@ it together, and Ctrl+Z undoes database changes like any other.
**calendar** that places records on a date property (drag them to another day). Click the active tab to rename,
duplicate, change or delete the view; which view you look at is yours alone.
- **Records as pages:** **Open** on a record, or a click on a card, opens it beside the page, with its properties on
top and room to write below.
top and room to write below. The link button there, or **Copy link to record** when you right-click a row, copies
a link that opens the page with that record open; it works for anyone who can open the page.
- **CSV:** the ⋯ menu exports the current view as a CSV file, or adds records from one; an empty database takes the
file's columns and guesses their types.
+23 -23
View File
@@ -158,13 +158,13 @@ img.ProseMirror-separator {
`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=uP(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(`
`).length,u=e.split(`
`).slice(0,l).join(`
`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=aP(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(w.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>PM(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>FM(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return LM(e,t&&(e=>{n&&cP(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>BM(e,t),addRowAfter:()=>({state:e,dispatch:t})=>VM(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return UM(e,t&&(e=>{n&&cP(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>nN(e,t),mergeCells:()=>({state:e,dispatch:t})=>KM(e,t),splitCell:()=>({state:e,dispatch:t})=>qM(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>QM(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>QM(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>$M(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>KM(e,t)?!0:qM(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>YM(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>tN(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>tN(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&AM(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=SM.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:sP,"Mod-Backspace":sP,Delete:sP,"Mod-Delete":sP}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[TN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],zN({allowTableNodeSelection:this.options.allowTableNodeSelection}),vP()]},addNodeView(){let e=this.options.View;return e?({node:t,view:n,HTMLAttributes:r})=>{let i=A(this.options.HTMLAttributes,r);return new e(t,this.options.cellMinWidth,n,i)}:null},extendNodeSchema(e){return{tableRole:Nu(k(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}}),bP=Tp.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(yP.configure(this.options.table)),this.options.tableCell!==!1&&e.push(XN.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(ZN.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(QN.configure(this.options.tableRow)),e}}),xP=Tp.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!Pf(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}});function SP(){return[Ik.configure({HTMLAttributes:{class:`dw-tasks`}}),Fk.configure({nested:!0})]}function CP(){return[bP.configure({table:{resizable:!0,cellMinWidth:60,HTMLAttributes:{class:`dw-table`}}})]}var wP=xP.configure({types:[`heading`,`paragraph`],alignments:[`left`,`center`,`right`]}),TP=Tp.create({name:`headingShortcuts`,addKeyboardShortcuts(){let e={"Mod-Shift-0":()=>this.editor.commands.setParagraph()};for(let t of[1,2,3,4,5,6])e[`Mod-Shift-${t}`]=()=>this.editor.commands.toggleHeading({level:t});return e}}),EP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,DP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,OP=_p.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||Af(e,`background-color`)||e.style.backgroundColor,renderHTML:e=>Pf(e.color)?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){retuLine truncated
`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=aP(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(w.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>PM(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>FM(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return LM(e,t&&(e=>{n&&cP(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>BM(e,t),addRowAfter:()=>({state:e,dispatch:t})=>VM(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return UM(e,t&&(e=>{n&&cP(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>nN(e,t),mergeCells:()=>({state:e,dispatch:t})=>KM(e,t),splitCell:()=>({state:e,dispatch:t})=>qM(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>QM(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>QM(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>$M(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>KM(e,t)?!0:qM(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>YM(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>tN(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>tN(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&AM(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=SM.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:sP,"Mod-Backspace":sP,Delete:sP,"Mod-Delete":sP}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[TN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],zN({allowTableNodeSelection:this.options.allowTableNodeSelection}),vP()]},addNodeView(){let e=this.options.View;return e?({node:t,view:n,HTMLAttributes:r})=>{let i=A(this.options.HTMLAttributes,r);return new e(t,this.options.cellMinWidth,n,i)}:null},extendNodeSchema(e){return{tableRole:Nu(k(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}}),bP=Tp.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(yP.configure(this.options.table)),this.options.tableCell!==!1&&e.push(XN.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(ZN.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(QN.configure(this.options.tableRow)),e}}),xP=Tp.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!Pf(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}});function SP(){return[Ik.configure({HTMLAttributes:{class:`dw-tasks`}}),Fk.configure({nested:!0})]}function CP(){return[bP.configure({table:{resizable:!0,cellMinWidth:60,HTMLAttributes:{class:`dw-table`}}})]}var wP=xP.configure({types:[`heading`,`paragraph`],alignments:[`left`,`center`,`right`]}),TP=Tp.create({name:`headingShortcuts`,addKeyboardShortcuts(){let e={"Mod-Shift-0":()=>this.editor.commands.setParagraph()};for(let t of[1,2,3,4,5,6])e[`Mod-Shift-${t}`]=()=>this.editor.commands.toggleHeading({level:t});return e}}),EP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,DP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,OP=_p.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||Af(e,`background-color`)||e.style.backgroundColor,renderHTML:e=>Pf(e.color)?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){retuLine truncated
`||e===`\r`?(r.push(i),n.push(r),r=[],i=``,e===`\r`&&s[o+1]===`
`&&o++):i+=e,o++}return(i!==``||r.length)&&(r.push(i),n.push(r)),n}function aI(e,t){return e.includes(t)||/["\r\n]/.test(e)||/^\s|\s$/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function oI(e,t=`,`){return e.map(e=>e.map(e=>aI(e,t)).join(t)).join(`\r
`)}function sI(e,t,n){return oI([t.map(e=>e.name),...n.map(e=>t.map(t=>hF(e,t)))])}function cI(e){let t=e.map(e=>e.trim()).filter(Boolean);if(!t.length)return`text`;if(t.every(e=>pF(e)!==null))return`number`;if(t.every(e=>/^\d{4}-\d{2}-\d{2}/.test(e)))return`date`;if(t.every(e=>/^(true|false|yes|no)$/i.test(e)))return`checkbox`;if(t.every(e=>/^https?:\/\/\S+$/.test(e)))return`link`;let n=new Set(t.map(e=>e.toLowerCase()));return t.length>=4&&n.size<=Math.max(2,t.length/3)&&t.every(e=>e.length<=40)?`select`:`text`}function lI(e,t,n){let r=e.trim();if(!r)return null;let i=e=>{let t=n.find(t=>t.name.toLowerCase()===e.toLowerCase());return t||(t={id:tF(),name:e,color:EF(n)},n.push(t)),t.id};switch(t.type){case`number`:return pF(r);case`progress`:{let e=pF(r.replace(`%`,``));return e===null?null:Math.max(0,Math.min(100,Math.round(e)))}case`checkbox`:return/^(true|yes|1|x|✓|done)$/i.test(r);case`date`:return dF(r)||null;case`select`:return i(r);case`multiSelect`:return[...new Set(r.split(/[,;]/).map(e=>e.trim()).filter(Boolean).map(i))];case`member`:case`attachment`:case`createdBy`:case`createdTime`:return null;default:return r}}function uI(e,t=`,`){let n=iI(e,t).filter(e=>e.some(e=>e.trim())),r=n[0]??[],i=n.slice(1),a=r.map((e,t)=>({id:tF(),name:e.trim()||`${t+1}`,type:t===0?`title`:cI(i.map(e=>e[t]??``))}));for(let e of a)e.type===`select`&&(e.options=[]);return{columns:a,rows:i.map(e=>{let t={};return a.forEach((n,r)=>{let i=lI(e[r]??``,n,n.options??[]);i!==null&&(!Array.isArray(i)||i.length)&&(t[n.id]=i)}),t})}}function dI(e,t){let n=[];return{index:e.map(e=>{let r=t.find(t=>t.name.trim().toLowerCase()===e.trim().toLowerCase());return!r&&e.trim()&&n.push(e.trim()),r??null}),missing:n}}function fI(e,t,n,r){let i=I(`select`,{class:`dw-db-select`,"aria-label":n});for(let n of t){let t=I(`option`,{value:n.value},n.label);n.value===e&&(t.selected=!0),i.append(t)}return i.addEventListener(`change`,()=>r(i.value)),i.addEventListener(`keydown`,e=>e.stopPropagation()),i}var pI=e=>e.map(e=>({value:e.id,label:e.name||`…`}));function mI(e,t,n,r){let i=e.labels;if(!_F(n.op))return null;if(t.type===`select`||t.type===`multiSelect`)return fI(typeof n.value==`string`?n.value:``,[{value:``,label:`—`},...(t.options??[]).map(e=>({value:e.id,label:e.name}))],i.value,r);let a=t.type===`date`||t.type===`createdTime`?`date`:t.type===`number`||t.type===`progress`?`number`:`text`,o=I(`input`,{class:`dw-db-input dw-db-input--small`,type:a,"aria-label":i.value,placeholder:i.value});return o.value=n.value===void 0||n.value===null?``:String(n.value),o.addEventListener(`keydown`,e=>e.stopPropagation()),o.addEventListener(`change`,()=>r(a===`number`?o.value===``?null:Number(o.value):o.value)),o}function hI(e,t,n){let r=e.store,i=e.labels,a=e.db.columns,o=structuredClone(n.filters),s=()=>r?.updateView(n.id,{filters:o}),c=()=>{t.replaceChildren(),o.length>1&&t.append(fI(n.filterMode,[{value:`and`,label:i.matchAll},{value:`or`,label:i.matchAny}],i.filter,e=>{n.filterMode=e,r?.updateView(n.id,{filterMode:n.filterMode})})),o.length||t.append(I(`p`,{class:`dw-db-pop__empty`},i.noFilters)),o.forEach((n,r)=>{let l=a.find(e=>e.id===n.column);if(!l)return;let u=gF(l.type),d=I(`div`,{class:`dw-db-pop__line`},fI(n.column,pI(a),i.filter,e=>{let t=a.find(t=>t.id===e);o[r]={column:e,op:gF(t.type)[0]},s(),c()}),fI(n.op,u.map(e=>({value:e,label:BP(i,e)})),i.filter,e=>{o[r]={...n,op:e},_F(e)||delete o[r].value,s(),c()}),mI(e,l,n,e=>{o[r]={...o[r],value:e},s()}),bI(i.remove,()=>{o.splice(r,1),s(),c()}));t.append(d)}),r&&t.append(xI(i.addFilter,()=>{let e=a.find(e=>e.type!==`title`)??a[0];o.push({column:e.id,op:gF(e.type)[0]}),s(),c()}))};c()}function gI(e,t,n){let r=e.store,i=e.labels,a=e.db.columns,o=structuredClone(n.sorts),s=()=>r?.updateView(n.id,{sorts:o}),c=()=>{t.replaceChildren(),o.length||t.append(I(`p`,{class:`dw-db-pop__empty`},i.noSorts)),o.forEach((e,n)=>{t.append(I(`div`,{class:`dw-db-pop__line`},fI(e.column,pI(a),i.sort,t=>{o[n]={...e,column:t},s()}),fI(e.desc?`desc`:`asc`,[{value:`asc`,label:i.ascending},{value:`desc`,label:i.descending}],i.sort,t=>{o[n]={...e,desc:t===`desc`},s()}),bI(i.remove,()=>{o.splice(n,1),s(),c()})))}),r&&t.append(xI(i.addSort,()=>{let e=new Set(o.map(e=>e.column)),t=a.find(t=>!e.has(t.id))??a[0];o.push({column:t.id,desc:!1}),s(),c()}))};c()}function _I(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>rF.includes(e.type)),o=a.map(e=>({value:e.id,label:e.name||RP(i,e.type)}));n.type!==`kanban`&&o.unshift({value:``,label:i.noGrouping}),t.append(I(`label`,{class:`dw-db-pop__label`},i.groupBy),a.length||n.type!==`kanban`?fI(n.groupBy??``,o,i.groupBy,e=>r?.updateView(n.id,{groupBy:e||null})):I(`p`,{class:`dw-db-pop__empty`},i.noGroupColumn))}function vI(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>e.type===`date`||e.type===`createdTime`);t.append(I(`label`,{class:`dw-db-pop__label`},i.dateColumn),a.length?fI(n.dateColumn??``,[{value:``,label:`—`},...a.map(e=>({value:e.id,label:e.name||RP(i,e.tyLine truncated
`)},onCreate(){let{doc:e,readOnlyDoc:t,undoScope:n}=this.options;e&&!t&&n&&(NS.getState(this.editor.state)?.undoManager)?.addToScope(HF(e))},addCommands(){let e=e=>{let t=tF(),{doc:n,readOnlyDoc:r}=this.options;return!n||r?{id:t,data:e}:(rI(n,t,e,(e,t)=>MI(this.editor,e,t)),{id:t,data:null})};return{insertDatabase:t=>({commands:n})=>n.insertContent([{type:this.name,attrs:e(t??QF(DI(this.options.labels)))},{type:`paragraph`}]),groupAsDatabase:()=>({state:t,dispatch:n,commands:r})=>{let i=FI(t.selection.$from,t.selection.$to);if(!i)return!1;if(!n)return!0;let a=EI(this.options.labels),o={id:tF(),name:a.typeTitle,type:`title`},s=[o],c=i.checks?{id:tF(),name:a.done,type:`checkbox`}:null;c&&s.push(c);let l=Date.now(),u={title:``,columns:s,rows:i.items.map((e,t)=>({id:tF(),cells:{[o.id]:e.text,...c&&e.checked?{[c.id]:!0}:{}},createdAt:l+t,createdBy:this.options.me?.()??null,body:e.rest.length?e.rest:void 0})),views:[nF(`table`,a.viewTable,s)]},d=this.type.create(e(u));return r.command(({tr:e})=>(e.replaceWith(i.from,i.to,d),e.setSelection(T.create(e.doc,i.from)),!0))}}},addKeyboardShortcuts(){return{"Mod-g":()=>this.editor.commands.groupAsDatabase()}},addProseMirrorPlugins(){let{doc:e,readOnlyDoc:t}=this.options,n=e&&!t?e:null,r=this.editor;return[new E({key:new D(`databaseClipboard`),props:{transformCopied:t=>!e||!AI(t.content)?t:new p(kI(t.content,t=>{let n=HF(e).get(String(t.attrs.id));return n instanceof Lb?t.type.create({...t.attrs,data:nI(n,OI)}):t}),t.openStart,t.openEnd),transformPasted:e=>AI(e.content)?new p(kI(e.content,e=>{let t=tF();if(!n)return e.type.create({...e.attrs,id:t});let i=e.attrs.data?iF(e.attrs.data):null,a=HF(n).get(String(e.attrs.id)),o=i??(a instanceof Lb?nI(a,OI):QF(DI(this.options.labels)));return rI(n,t,PI(o),(e,t)=>MI(r,e,t)),e.type.create({id:t,data:null})}),e.openStart,e.openEnd):e},appendTransaction:(e,t,i)=>{if(!n||!e.some(e=>e.docChanged&&!e.getMeta(MS))||!e.some(e=>e.steps.some(e=>AI(e.slice?.content??s.empty))))return null;let a=new Set,o=[];if(i.doc.descendants((e,t)=>{if(e.type.name!==`database`)return;let n=String(e.attrs.id);return n&&a.has(n)&&o.push({pos:t,node:e}),a.add(n),!1}),!o.length)return null;let c=i.tr;for(let{pos:e,node:t}of o){let i=HF(n).get(String(t.attrs.id)),a=tF();i instanceof Lb&&rI(n,a,PI(nI(i,OI)),(e,t)=>MI(r,e,t)),c.setNodeMarkup(e,void 0,{...t.attrs,id:a,data:null})}return c}})]},addNodeView(){let e=this.options;return({node:t,editor:n,getPos:r})=>{let i=t,a=e.labels??UP,o=e.doc,s=()=>n.isEditable&&!!o&&!e.readOnlyDoc,c=null,l=null,u=null,d=null,f=I(`div`,{class:`dw-db-node`}),p=()=>String(i.attrs.id),m=()=>{let e=o?HF(o).get(p()):void 0;return e instanceof Lb?e:null},h=()=>{let t=m();return t?ZF(t):i.attrs.data?iF(i.attrs.data):QF(DI(e.labels))},g=()=>({labels:a.database,colorNames:a.colors,locale:a.locale,files:e.files,people:e.people,store:c}),_=(t,n)=>{let r=e.rowExtensions;if(!r)return null;let i=m(),o=null;if(i&&(o=c?c.rowBody(n.id):NI(i,n.id),!o))return t.append(I(`p`,{class:`dw-db-peek__note`},a.database.bodyReadOnly)),null;let s=new Vp({element:t,editable:!!c,extensions:r(o),content:o?void 0:{type:`doc`,content:n.body??[{type:`paragraph`}]},editorProps:{attributes:{class:`dw-prose dw-db-peek__prose`}}});return!o&&!n.body?.length&&t.replaceChildren(I(`p`,{class:`dw-db-peek__note`},a.database.bodyReadOnly)),()=>s.destroy()},v=(e,t)=>{u?.close(),u=new BF({ctx:{...g()},mountBody:_},h(),e,t,()=>u=null)},y=()=>{let e=h();d?.update(e,{store:c}),u?.update(e,{store:c})},b=()=>{if(l?.(),l=null,c=null,!o)return;let t=m();if(!t&&s()){let a=i.attrs.data?iF(i.attrs.data):QF(DI(e.labels)),s=p()?p():tF();rI(o,s,a,(e,t)=>MI(n,e,t)),queueMicrotask(()=>{let e=typeof r==`function`?r():void 0;e!==void 0&&n.state.doc.nodeAt(e)?.type.name===`database`&&n.view.dispatch(n.state.tr.setNodeMarkup(e,void 0,{...i.attrs,id:s,data:null}).setMeta(`addToHistory`,!1))}),t=HF(o).get(s)}let a=HF(o),d=e=>{if(!e.keysChanged.has(p()))return;b(),y();let t=u?.row;t&&h().rows.some(e=>e.id===t)&&v(t,[t])};if(a.observe(d),t){s()&&(c=new eI(o,t,()=>e.me?.()??null));let n=t,r=()=>y();n.observeDeep(r),l=()=>{a.unobserve(d),n.unobserveDeep(r)}}else l=()=>a.unobserve(d)};b(),d=new CI({...g(),openRow:v,undo:()=>n.commands.undo?.(),redo:()=>n.commands.redo?.(),notify:e.notify},h()),f.append(d.dom);let x=s(),S=()=>{s()!==x&&(x=s(),b(),y())};return n.on(`update`,S),n.on(`transaction`,S),{dom:f,update(e){if(e.type!==i.type)return!1;let t=e.attrs.id!==i.attrs.id;return i=e,t&&b(),y(),!0},ignoreMutation:()=>!0,stopEvent:e=>e.type!==`dragstart`||e.target!==f,destroy(){l?.(),u?.close(),d?.destroy(),n.off(`update`,S),n.off(`transaction`,S)}}}}});function MI(e,t,n){try{yw(e.schema,{type:`doc`,content:t},n)}catch{}}function NI(e,t){let n=e.get(`rows`);if(!(n instanceof Pb))return null;for(let e of n.toArray())if(e.get(`id`)===t){let t=e.get(`body`);return t instanceof ix&&t.length?t:null}return null}function PI(e){return{...e,rows:e.rows.map(e=>({...e,id:tF()}))}}function FI(e,t){for(let t=e.depth;Line truncated
`);return/\s/.test(n)}):!1}function nL(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function rL(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:nL(e)}function iL({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!tL(r)}function aL({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function oL({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),xs.create(a.doc,[vs.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function sL({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(y<f.range.from||y>f.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function cL({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function lL({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Oj({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(Aj()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function uL(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function dL({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&uL(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=Dj(c,o,()=>{jj(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{s.onPosition?s.onPosition({x:e,y:t,placement:n,strategy:r}):(Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``))})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function fL({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=cL({editor:e,items:n}),v=lL({placLine truncated
`).length+1)));let r=document.createElement(`div`);r.className=`dw-source__actions`;let i=(e,t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.className=`dw-source__btn ${t}`,r.textContent=e,r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`click`,n),r};e.onRemove&&r.append(i(e.labels.remove,`dw-source__btn--danger`,()=>{u(!0),e.onRemove()}));let a=document.createElement(`span`);a.style.flex=`1`,r.append(a,i(e.labels.cancel,``,()=>u()),i(e.labels.done,`dw-source__btn--primary`,()=>o())),t.append(n,r),document.body.append(t);let o=()=>{let t=n.value;u(!0),e.onSave(t)};n.addEventListener(`input`,()=>e.onInput?.(n.value)),n.addEventListener(`keydown`,t=>{let n=t;n.key===`Escape`?(n.preventDefault(),u()):n.key===`Enter`&&(n.ctrlKey||n.metaKey||!e.multiline)&&(n.preventDefault(),o()),n.stopPropagation()});let s=n=>{!t.contains(n.target)&&!e.anchor.contains(n.target)&&u()};setTimeout(()=>document.addEventListener(`mousedown`,s),0);let c=Dj(e.anchor,t,()=>{jj(e.anchor,t,{placement:`bottom-start`,middleware:[Oj(6),Aj(),kj({padding:8})]}).then(({x:e,y:n})=>Object.assign(t.style,{left:`${e}px`,top:`${n}px`}))}),l=!1;function u(n=!1){l||(l=!0,c(),document.removeEventListener(`mousedown`,s),t.remove(),FL===d&&(FL=null),n||e.onCancel?.())}let d=()=>u();return FL=d,n.focus(),e.multiline||n.select(),d}var LL=[{pattern:/^https:\/\/(?:www\.|m\.)?youtube\.com\/(?:watch\?(?:.*&)?v=|shorts\/|embed\/|live\/)([\w-]{11})/,src:e=>`https://www.youtube-nocookie.com/embed/${e[1]}`},{pattern:/^https:\/\/youtu\.be\/([\w-]{11})/,src:e=>`https://www.youtube-nocookie.com/embed/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?vimeo\.com\/(?:video\/)?(\d+)/,src:e=>`https://player.vimeo.com/video/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/([\da-f]{32})/,src:e=>`https://www.loom.com/embed/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?figma\.com\/(?:file|design|proto|board|slides)\/[\w-]+/,src:(e,t)=>`https://www.figma.com/embed?embed_host=docwell&url=${encodeURIComponent(t.href)}`},{pattern:/^https:\/\/codepen\.io\/([\w-]+)\/(?:pen|embed)\/([\w-]+)/,src:e=>`https://codepen.io/${e[1]}/embed/${e[2]}?default-tab=result`},{pattern:/^https:\/\/open\.spotify\.com\/(?:embed\/)?(track|album|playlist|episode|show)\/(\w+)/,src:e=>`https://open.spotify.com/embed/${e[1]}/${e[2]}`,ratio:`audio`},{pattern:/^https:\/\/docs\.google\.com\/(document|spreadsheets|presentation)\/d\/([\w-]+)/,src:e=>`https://docs.google.com/${e[1]}/d/${e[2]}/preview`,ratio:`tall`},{pattern:/^https:\/\/(?:www\.)?google\.com\/maps\/embed\?/,src:(e,t)=>t.href}];function RL(e){let t;try{t=new URL(e.trim())}catch{return null}for(let e of LL){let n=e.pattern.exec(t.href);if(n)return{src:e.src(n,t),ratio:e.ratio??`video`}}return null}function zL(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`?t.href:``}catch{return``}}var BL=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}};function VL(e,t,n){let{node:r}=e.view.domAtPos(e.state.selection.from),i=r instanceof HTMLElement?r:r.parentElement??e.view.dom;return new Promise(e=>{let r=t.blocks;IL({anchor:i,value:`https://`,label:n,labels:{done:r.done,cancel:r.cancel,remove:r.remove},onSave:t=>e(zL(t)),onCancel:()=>e(``)})})}async function HL(e,t,n,r){let i=await VL(e,t,t.blocks.embedUrl);i&&(RL(i)?e.chain().focus().insertEmbed(i).run():await WL(e,i,n,r))}async function UL(e,t,n,r){let i=await VL(e,t,t.blocks.linkUrl);i&&await WL(e,i,n,r)}async function WL(e,t,n,r){let i={url:t};if(n)try{i={...await n.preview(t),url:t}}catch(e){r?.(e)}e.chain().focus().insertLinkCard(i).run()}var GL=Jp.create({name:`embed`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){return{url:{default:``,parseHTML:e=>e.getAttribute(`data-url`)??``,renderHTML:e=>({"data-url":e.url})}}},parseHTML(){return[{tag:`div[data-type='embed']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=zL(String(e.attrs.url));return[`div`,A(t,{"data-type":`embed`}),[`a`,{href:n},n]]},addCommands(){return{insertEmbed:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{url:e}})}},addNodeView(){return({node:e})=>{let t=this.options.labels.blocks,n=document.createElement(`figure`);n.className=`dw-embed`,n.setAttribute(`data-type`,`embed`),n.contentEditable=`false`;let r=e=>{let r=zL(e),i=RL(r);if(n.replaceChildren(),!i){let e=document.createElement(`a`);e.href=r,e.target=`_blank`,e.rel=`noopener noreferrer`,e.textContent=r||t.embedInvalid,n.append(e);return}n.dataset.ratio=i.ratio;let a=document.createElement(`iframe`);a.className=`dw-embed__frame`,a.src=i.src,a.title=`${t.embed}: ${BL(r)}`,a.loading=`lazy`,a.allow=`fullscreen; picture-in-picture; encrypted-media; clipboard-write`,a.referrerPolicy=`strict-origin-when-cross-origin`,a.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-popups allow-presentation`);let o=document.createElement(`figcaption`);o.className=`dw-embed__caption`;let s=document.createElement(`a`);s.href=r,s.targeLine truncated
`)}function sI(e,t,n){return oI([t.map(e=>e.name),...n.map(e=>t.map(t=>hF(e,t)))])}function cI(e){let t=e.map(e=>e.trim()).filter(Boolean);if(!t.length)return`text`;if(t.every(e=>pF(e)!==null))return`number`;if(t.every(e=>/^\d{4}-\d{2}-\d{2}/.test(e)))return`date`;if(t.every(e=>/^(true|false|yes|no)$/i.test(e)))return`checkbox`;if(t.every(e=>/^https?:\/\/\S+$/.test(e)))return`link`;let n=new Set(t.map(e=>e.toLowerCase()));return t.length>=4&&n.size<=Math.max(2,t.length/3)&&t.every(e=>e.length<=40)?`select`:`text`}function lI(e,t,n){let r=e.trim();if(!r)return null;let i=e=>{let t=n.find(t=>t.name.toLowerCase()===e.toLowerCase());return t||(t={id:tF(),name:e,color:EF(n)},n.push(t)),t.id};switch(t.type){case`number`:return pF(r);case`progress`:{let e=pF(r.replace(`%`,``));return e===null?null:Math.max(0,Math.min(100,Math.round(e)))}case`checkbox`:return/^(true|yes|1|x|✓|done)$/i.test(r);case`date`:return dF(r)||null;case`select`:return i(r);case`multiSelect`:return[...new Set(r.split(/[,;]/).map(e=>e.trim()).filter(Boolean).map(i))];case`member`:case`attachment`:case`createdBy`:case`createdTime`:return null;default:return r}}function uI(e,t=`,`){let n=iI(e,t).filter(e=>e.some(e=>e.trim())),r=n[0]??[],i=n.slice(1),a=r.map((e,t)=>({id:tF(),name:e.trim()||`${t+1}`,type:t===0?`title`:cI(i.map(e=>e[t]??``))}));for(let e of a)e.type===`select`&&(e.options=[]);return{columns:a,rows:i.map(e=>{let t={};return a.forEach((n,r)=>{let i=lI(e[r]??``,n,n.options??[]);i!==null&&(!Array.isArray(i)||i.length)&&(t[n.id]=i)}),t})}}function dI(e,t){let n=[];return{index:e.map(e=>{let r=t.find(t=>t.name.trim().toLowerCase()===e.trim().toLowerCase());return!r&&e.trim()&&n.push(e.trim()),r??null}),missing:n}}function fI(e,t,n,r){let i=I(`select`,{class:`dw-db-select`,"aria-label":n});for(let n of t){let t=I(`option`,{value:n.value},n.label);n.value===e&&(t.selected=!0),i.append(t)}return i.addEventListener(`change`,()=>r(i.value)),i.addEventListener(`keydown`,e=>e.stopPropagation()),i}var pI=e=>e.map(e=>({value:e.id,label:e.name||`…`}));function mI(e,t,n,r){let i=e.labels;if(!_F(n.op))return null;if(t.type===`select`||t.type===`multiSelect`)return fI(typeof n.value==`string`?n.value:``,[{value:``,label:`—`},...(t.options??[]).map(e=>({value:e.id,label:e.name}))],i.value,r);let a=t.type===`date`||t.type===`createdTime`?`date`:t.type===`number`||t.type===`progress`?`number`:`text`,o=I(`input`,{class:`dw-db-input dw-db-input--small`,type:a,"aria-label":i.value,placeholder:i.value});return o.value=n.value===void 0||n.value===null?``:String(n.value),o.addEventListener(`keydown`,e=>e.stopPropagation()),o.addEventListener(`change`,()=>r(a===`number`?o.value===``?null:Number(o.value):o.value)),o}function hI(e,t,n){let r=e.store,i=e.labels,a=e.db.columns,o=structuredClone(n.filters),s=()=>r?.updateView(n.id,{filters:o}),c=()=>{t.replaceChildren(),o.length>1&&t.append(fI(n.filterMode,[{value:`and`,label:i.matchAll},{value:`or`,label:i.matchAny}],i.filter,e=>{n.filterMode=e,r?.updateView(n.id,{filterMode:n.filterMode})})),o.length||t.append(I(`p`,{class:`dw-db-pop__empty`},i.noFilters)),o.forEach((n,r)=>{let l=a.find(e=>e.id===n.column);if(!l)return;let u=gF(l.type),d=I(`div`,{class:`dw-db-pop__line`},fI(n.column,pI(a),i.filter,e=>{let t=a.find(t=>t.id===e);o[r]={column:e,op:gF(t.type)[0]},s(),c()}),fI(n.op,u.map(e=>({value:e,label:BP(i,e)})),i.filter,e=>{o[r]={...n,op:e},_F(e)||delete o[r].value,s(),c()}),mI(e,l,n,e=>{o[r]={...o[r],value:e},s()}),bI(i.remove,()=>{o.splice(r,1),s(),c()}));t.append(d)}),r&&t.append(xI(i.addFilter,()=>{let e=a.find(e=>e.type!==`title`)??a[0];o.push({column:e.id,op:gF(e.type)[0]}),s(),c()}))};c()}function gI(e,t,n){let r=e.store,i=e.labels,a=e.db.columns,o=structuredClone(n.sorts),s=()=>r?.updateView(n.id,{sorts:o}),c=()=>{t.replaceChildren(),o.length||t.append(I(`p`,{class:`dw-db-pop__empty`},i.noSorts)),o.forEach((e,n)=>{t.append(I(`div`,{class:`dw-db-pop__line`},fI(e.column,pI(a),i.sort,t=>{o[n]={...e,column:t},s()}),fI(e.desc?`desc`:`asc`,[{value:`asc`,label:i.ascending},{value:`desc`,label:i.descending}],i.sort,t=>{o[n]={...e,desc:t===`desc`},s()}),bI(i.remove,()=>{o.splice(n,1),s(),c()})))}),r&&t.append(xI(i.addSort,()=>{let e=new Set(o.map(e=>e.column)),t=a.find(t=>!e.has(t.id))??a[0];o.push({column:t.id,desc:!1}),s(),c()}))};c()}function _I(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>rF.includes(e.type)),o=a.map(e=>({value:e.id,label:e.name||RP(i,e.type)}));n.type!==`kanban`&&o.unshift({value:``,label:i.noGrouping}),t.append(I(`label`,{class:`dw-db-pop__label`},i.groupBy),a.length||n.type!==`kanban`?fI(n.groupBy??``,o,i.groupBy,e=>r?.updateView(n.id,{groupBy:e||null})):I(`p`,{class:`dw-db-pop__empty`},i.noGroupColumn))}function vI(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>e.type===`date`||e.type===`createdTime`);t.append(I(`label`,{class:`dw-db-pop__label`},i.dateColumn),a.length?fI(n.dateColumn??``,[{value:``,label:`—`},...a.map(e=>({value:e.id,label:e.name||RP(i,e.tyLine truncated
`)},onCreate(){let{doc:e,readOnlyDoc:t,undoScope:n}=this.options;e&&!t&&n&&(NS.getState(this.editor.state)?.undoManager)?.addToScope(HF(e))},addCommands(){let e=e=>{let t=tF(),{doc:n,readOnlyDoc:r}=this.options;return!n||r?{id:t,data:e}:(rI(n,t,e,(e,t)=>FI(this.editor,e,t)),{id:t,data:null})};return{insertDatabase:t=>({commands:n})=>n.insertContent([{type:this.name,attrs:e(t??QF(AI(this.options.labels)))},{type:`paragraph`}]),groupAsDatabase:()=>({state:t,dispatch:n,commands:r})=>{let i=RI(t.selection.$from,t.selection.$to);if(!i)return!1;if(!n)return!0;let a=kI(this.options.labels),o={id:tF(),name:a.typeTitle,type:`title`},s=[o],c=i.checks?{id:tF(),name:a.done,type:`checkbox`}:null;c&&s.push(c);let l=Date.now(),u={title:``,columns:s,rows:i.items.map((e,t)=>({id:tF(),cells:{[o.id]:e.text,...c&&e.checked?{[c.id]:!0}:{}},createdAt:l+t,createdBy:this.options.me?.()??null,body:e.rest.length?e.rest:void 0})),views:[nF(`table`,a.viewTable,s)]},d=this.type.create(e(u));return r.command(({tr:e})=>(e.replaceWith(i.from,i.to,d),e.setSelection(T.create(e.doc,i.from)),!0))}}},addKeyboardShortcuts(){return{"Mod-g":()=>this.editor.commands.groupAsDatabase()}},addProseMirrorPlugins(){let{doc:e,readOnlyDoc:t}=this.options,n=e&&!t?e:null,r=this.editor;return[new E({key:new D(`databaseClipboard`),props:{transformCopied:t=>!e||!NI(t.content)?t:new p(MI(t.content,t=>{let n=HF(e).get(String(t.attrs.id));return n instanceof Lb?t.type.create({...t.attrs,data:nI(n,jI)}):t}),t.openStart,t.openEnd),transformPasted:e=>NI(e.content)?new p(MI(e.content,e=>{let t=tF();if(!n)return e.type.create({...e.attrs,id:t});let i=e.attrs.data?iF(e.attrs.data):null,a=HF(n).get(String(e.attrs.id)),o=i??(a instanceof Lb?nI(a,jI):QF(AI(this.options.labels)));return rI(n,t,LI(o),(e,t)=>FI(r,e,t)),e.type.create({id:t,data:null})}),e.openStart,e.openEnd):e},appendTransaction:(e,t,i)=>{if(!n||!e.some(e=>e.docChanged&&!e.getMeta(MS))||!e.some(e=>e.steps.some(e=>NI(e.slice?.content??s.empty))))return null;let a=new Set,o=[];if(i.doc.descendants((e,t)=>{if(e.type.name!==`database`)return;let n=String(e.attrs.id);return n&&a.has(n)&&o.push({pos:t,node:e}),a.add(n),!1}),!o.length)return null;let c=i.tr;for(let{pos:e,node:t}of o){let i=HF(n).get(String(t.attrs.id)),a=tF();i instanceof Lb&&rI(n,a,LI(nI(i,jI)),(e,t)=>FI(r,e,t)),c.setNodeMarkup(e,void 0,{...t.attrs,id:a,data:null})}return c}})]},addNodeView(){let e=this.options;return({node:t,editor:n,getPos:r})=>{let i=t,a=e.labels??UP,o=e.doc,s=()=>n.isEditable&&!!o&&!e.readOnlyDoc,c=null,l=null,u=null,d=null,f=I(`div`,{class:`dw-db-node`}),p=()=>String(i.attrs.id),m=()=>{let e=o?HF(o).get(p()):void 0;return e instanceof Lb?e:null},h=()=>{let t=m();return t?ZF(t):i.attrs.data?iF(i.attrs.data):QF(AI(e.labels))},g=()=>({labels:a.database,colorNames:a.colors,locale:a.locale,files:e.files,people:e.people,store:c}),_=(t,n)=>{let r=e.rowExtensions;if(!r)return null;let i=m(),o=null;if(i&&(o=c?c.rowBody(n.id):II(i,n.id),!o))return t.append(I(`p`,{class:`dw-db-peek__note`},a.database.bodyReadOnly)),null;let s=new Vp({element:t,editable:!!c,extensions:r(o),content:o?void 0:{type:`doc`,content:n.body??[{type:`paragraph`}]},editorProps:{attributes:{class:`dw-prose dw-db-peek__prose`}}});return!o&&!n.body?.length&&t.replaceChildren(I(`p`,{class:`dw-db-peek__note`},a.database.bodyReadOnly)),()=>s.destroy()},v=e.recordLink,y=v?t=>{let n=v(EI(p(),t));OI(n).then(t=>t&&e.onLinkCopied?.(n))}:void 0;f.addEventListener(DI,e=>{let t=e.detail,n=h();n.rows.some(e=>e.id===t.row)&&(t.found=!0,f.scrollIntoView?.({block:`start`}),b(t.row,n.rows.map(e=>e.id)))});let b=(e,t)=>{u?.close(),u=new BF({ctx:{...g()},mountBody:_,copyLink:y},h(),e,t,()=>u=null)},x=()=>{let e=h();d?.update(e,{store:c}),u?.update(e,{store:c})},S=()=>{if(l?.(),l=null,c=null,!o)return;let t=m();if(!t&&s()){let a=i.attrs.data?iF(i.attrs.data):QF(AI(e.labels)),s=p()?p():tF();rI(o,s,a,(e,t)=>FI(n,e,t)),queueMicrotask(()=>{let e=typeof r==`function`?r():void 0;e!==void 0&&n.state.doc.nodeAt(e)?.type.name===`database`&&n.view.dispatch(n.state.tr.setNodeMarkup(e,void 0,{...i.attrs,id:s,data:null}).setMeta(`addToHistory`,!1))}),t=HF(o).get(s)}let a=HF(o),d=e=>{if(!e.keysChanged.has(p()))return;S(),x();let t=u?.row;t&&h().rows.some(e=>e.id===t)&&b(t,[t])};if(a.observe(d),t){s()&&(c=new eI(o,t,()=>e.me?.()??null));let n=t,r=()=>x();n.observeDeep(r),l=()=>{a.unobserve(d),n.unobserveDeep(r)}}else l=()=>a.unobserve(d)};S(),d=new CI({...g(),openRow:b,undo:()=>n.commands.undo?.(),redo:()=>n.commands.redo?.(),notify:e.notify,copyLink:y},h()),f.append(d.dom);let ee=s(),te=()=>{s()!==ee&&(ee=s(),S(),x())};return n.on(`update`,te),n.on(`transaction`,te),{dom:f,update(e){if(e.type!==i.type)return!1;let t=e.attrs.id!==i.attrs.id;return i=e,t&&S(),x(),!0},ignoreMutation:()=>!0,stopEvent:e=>e.type!==`dragstart`||e.target!==f,destroy(){l?.(),u?.close(),d?.destroy(),n.off(`update`,te),n.off(`transaction`,te)}}}}});function FI(e,t,n){try{yw(e.schema,{type:`doc`,content:t},n)}catch{}}function Line truncated
`);return/\s/.test(n)}):!1}function aL(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function oL(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:aL(e)}function sL({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!iL(r)}function cL({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function lL({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),xs.create(a.doc,[vs.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function uL({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(y<f.range.from||y>f.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function dL({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function fL({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Oj({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(Aj()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function pL(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function mL({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&pL(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=Dj(c,o,()=>{jj(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{s.onPosition?s.onPosition({x:e,y:t,placement:n,strategy:r}):(Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``))})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function hL({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=dL({editor:e,items:n}),v=fL({placLine truncated
`).length+1)));let r=document.createElement(`div`);r.className=`dw-source__actions`;let i=(e,t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.className=`dw-source__btn ${t}`,r.textContent=e,r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`click`,n),r};e.onRemove&&r.append(i(e.labels.remove,`dw-source__btn--danger`,()=>{u(!0),e.onRemove()}));let a=document.createElement(`span`);a.style.flex=`1`,r.append(a,i(e.labels.cancel,``,()=>u()),i(e.labels.done,`dw-source__btn--primary`,()=>o())),t.append(n,r),document.body.append(t);let o=()=>{let t=n.value;u(!0),e.onSave(t)};n.addEventListener(`input`,()=>e.onInput?.(n.value)),n.addEventListener(`keydown`,t=>{let n=t;n.key===`Escape`?(n.preventDefault(),u()):n.key===`Enter`&&(n.ctrlKey||n.metaKey||!e.multiline)&&(n.preventDefault(),o()),n.stopPropagation()});let s=n=>{!t.contains(n.target)&&!e.anchor.contains(n.target)&&u()};setTimeout(()=>document.addEventListener(`mousedown`,s),0);let c=Dj(e.anchor,t,()=>{jj(e.anchor,t,{placement:`bottom-start`,middleware:[Oj(6),Aj(),kj({padding:8})]}).then(({x:e,y:n})=>Object.assign(t.style,{left:`${e}px`,top:`${n}px`}))}),l=!1;function u(n=!1){l||(l=!0,c(),document.removeEventListener(`mousedown`,s),t.remove(),RL===d&&(RL=null),n||e.onCancel?.())}let d=()=>u();return RL=d,n.focus(),e.multiline||n.select(),d}var BL=[{pattern:/^https:\/\/(?:www\.|m\.)?youtube\.com\/(?:watch\?(?:.*&)?v=|shorts\/|embed\/|live\/)([\w-]{11})/,src:e=>`https://www.youtube-nocookie.com/embed/${e[1]}`},{pattern:/^https:\/\/youtu\.be\/([\w-]{11})/,src:e=>`https://www.youtube-nocookie.com/embed/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?vimeo\.com\/(?:video\/)?(\d+)/,src:e=>`https://player.vimeo.com/video/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/([\da-f]{32})/,src:e=>`https://www.loom.com/embed/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?figma\.com\/(?:file|design|proto|board|slides)\/[\w-]+/,src:(e,t)=>`https://www.figma.com/embed?embed_host=docwell&url=${encodeURIComponent(t.href)}`},{pattern:/^https:\/\/codepen\.io\/([\w-]+)\/(?:pen|embed)\/([\w-]+)/,src:e=>`https://codepen.io/${e[1]}/embed/${e[2]}?default-tab=result`},{pattern:/^https:\/\/open\.spotify\.com\/(?:embed\/)?(track|album|playlist|episode|show)\/(\w+)/,src:e=>`https://open.spotify.com/embed/${e[1]}/${e[2]}`,ratio:`audio`},{pattern:/^https:\/\/docs\.google\.com\/(document|spreadsheets|presentation)\/d\/([\w-]+)/,src:e=>`https://docs.google.com/${e[1]}/d/${e[2]}/preview`,ratio:`tall`},{pattern:/^https:\/\/(?:www\.)?google\.com\/maps\/embed\?/,src:(e,t)=>t.href}];function VL(e){let t;try{t=new URL(e.trim())}catch{return null}for(let e of BL){let n=e.pattern.exec(t.href);if(n)return{src:e.src(n,t),ratio:e.ratio??`video`}}return null}function HL(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`?t.href:``}catch{return``}}var UL=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}};function WL(e,t,n){let{node:r}=e.view.domAtPos(e.state.selection.from),i=r instanceof HTMLElement?r:r.parentElement??e.view.dom;return new Promise(e=>{let r=t.blocks;zL({anchor:i,value:`https://`,label:n,labels:{done:r.done,cancel:r.cancel,remove:r.remove},onSave:t=>e(HL(t)),onCancel:()=>e(``)})})}async function GL(e,t,n,r){let i=await WL(e,t,t.blocks.embedUrl);i&&(VL(i)?e.chain().focus().insertEmbed(i).run():await qL(e,i,n,r))}async function KL(e,t,n,r){let i=await WL(e,t,t.blocks.linkUrl);i&&await qL(e,i,n,r)}async function qL(e,t,n,r){let i={url:t};if(n)try{i={...await n.preview(t),url:t}}catch(e){r?.(e)}e.chain().focus().insertLinkCard(i).run()}var JL=Jp.create({name:`embed`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){return{url:{default:``,parseHTML:e=>e.getAttribute(`data-url`)??``,renderHTML:e=>({"data-url":e.url})}}},parseHTML(){return[{tag:`div[data-type='embed']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=HL(String(e.attrs.url));return[`div`,A(t,{"data-type":`embed`}),[`a`,{href:n},n]]},addCommands(){return{insertEmbed:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{url:e}})}},addNodeView(){return({node:e})=>{let t=this.options.labels.blocks,n=document.createElement(`figure`);n.className=`dw-embed`,n.setAttribute(`data-type`,`embed`),n.contentEditable=`false`;let r=e=>{let r=HL(e),i=VL(r);if(n.replaceChildren(),!i){let e=document.createElement(`a`);e.href=r,e.target=`_blank`,e.rel=`noopener noreferrer`,e.textContent=r||t.embedInvalid,n.append(e);return}n.dataset.ratio=i.ratio;let a=document.createElement(`iframe`);a.className=`dw-embed__frame`,a.src=i.src,a.title=`${t.embed}: ${UL(r)}`,a.loading=`lazy`,a.allow=`fullscreen; picture-in-picture; encrypted-media; clipboard-write`,a.referrerPolicy=`strict-origin-when-cross-origin`,a.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-popups allow-presentation`);let o=document.createElement(`figcaption`);o.className=`dw-embed__caption`;let s=document.createElement(`a`);s.href=r,s.targeLine truncated
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
@@ -175,7 +175,7 @@ c5.3,-9.3,12,-14,20,-14
H400000v`+(40+e)+`H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M`+(834+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},WR=function(e,t){return`M263,`+(601+e+t)+`c0.7,0,18,39.7,52,119
M`+(834+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},qR=function(e,t){return`M263,`+(601+e+t)+`c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l`+e/2.084+` -`+e+`
@@ -185,7 +185,7 @@ s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},GR=function(e,t){return`M983 `+(10+e+t)+`
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},JR=function(e,t){return`M983 `+(10+e+t)+`
l`+e/3.13+` -`+e+`
c4,-6.7,10,-10,18,-10 H400000v`+(40+e)+`
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
@@ -194,7 +194,7 @@ c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},KR=function(e,t){return`M424,`+(2398+e+t)+`
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},YR=function(e,t){return`M424,`+(2398+e+t)+`
c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514
c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20
s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121
@@ -204,18 +204,18 @@ v`+(40+e)+`H1014.6
s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185
c-2,6,-10,9,-24,9
c-8,0,-12,-0.7,-12,-2z M`+(1001+e)+` `+t+`
h400000v`+(40+e)+`h-400000z`},qR=function(e,t){return`M473,`+(2713+e+t)+`
h400000v`+(40+e)+`h-400000z`},XR=function(e,t){return`M473,`+(2713+e+t)+`
c339.3,-1799.3,509.3,-2700,510,-2702 l`+e/5.298+` -`+e+`
c3.3,-7.3,9.3,-11,18,-11 H400000v`+(40+e)+`H1017.7
s-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9
c-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200
c0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26
s76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,
606zM`+(1001+e)+` `+t+`h400000v`+(40+e)+`H1017.7z`},JR=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},YR=function(e,t,n){var r=n-54-t-e;return`M702 `+(e+t)+`H400000`+(40+e)+`
606zM`+(1001+e)+` `+t+`h400000v`+(40+e)+`H1017.7z`},ZR=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},QR=function(e,t,n){var r=n-54-t-e;return`M702 `+(e+t)+`H400000`+(40+e)+`
H742v`+r+`l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1
h-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170
c-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667
219 661 l218 661zM702 `+t+`H400000v`+(40+e)+`H742z`},XR=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=UR(t,HR);break;case`sqrtSize1`:r=WR(t,HR);break;case`sqrtSize2`:r=GR(t,HR);break;case`sqrtSize3`:r=KR(t,HR);break;case`sqrtSize4`:r=qR(t,HR);break;case`sqrtTall`:r=YR(t,HR,n)}return r},ZR=function(e,t){switch(e){case`⎜`:return VR(`M291 0 H417 V`+t+` H291z`);case`∣`:return VR(`M145 0 H188 V`+t+` H145z`);case`∥`:return VR(`M145 0 H188 V`+t+` H145z`)+VR(`M367 0 H410 V`+t+` H367z`);case`⎟`:return VR(`M457 0 H583 V`+t+` H457z`);case`⎢`:return VR(`M319 0 H403 V`+t+` H319z`);case`⎥`:return VR(`M263 0 H347 V`+t+` H263z`);case`⎪`:return VR(`M384 0 H504 V`+t+` H384z`);case`⏐`:return VR(`M312 0 H355 V`+t+` H312z`);case`‖`:return VR(`M257 0 H300 V`+t+` H257z`)+VR(`M478 0 H521 V`+t+` H478z`);default:return``}},QR={doubleleftarrow:`M262 157
219 661 l218 661zM702 `+t+`H400000v`+(40+e)+`H742z`},$R=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=KR(t,GR);break;case`sqrtSize1`:r=qR(t,GR);break;case`sqrtSize2`:r=JR(t,GR);break;case`sqrtSize3`:r=YR(t,GR);break;case`sqrtSize4`:r=XR(t,GR);break;case`sqrtTall`:r=QR(t,GR,n)}return r},ez=function(e,t){switch(e){case`⎜`:return WR(`M291 0 H417 V`+t+` H291z`);case`∣`:return WR(`M145 0 H188 V`+t+` H145z`);case`∥`:return WR(`M145 0 H188 V`+t+` H145z`)+WR(`M367 0 H410 V`+t+` H367z`);case`⎟`:return WR(`M457 0 H583 V`+t+` H457z`);case`⎢`:return WR(`M319 0 H403 V`+t+` H319z`);case`⎥`:return WR(`M263 0 H347 V`+t+` H263z`);case`⎪`:return WR(`M384 0 H504 V`+t+` H384z`);case`⏐`:return WR(`M312 0 H355 V`+t+` H312z`);case`‖`:return WR(`M257 0 H300 V`+t+` H257z`)+WR(`M478 0 H521 V`+t+` H478z`);default:return``}},tz={doubleleftarrow:`M262 157
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
@@ -261,10 +261,10 @@ m0 0v40h400000v-40z`,leftharpoondown:`M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9
v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z`,lefthook:`M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5
-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3
-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21
71.5 23h399859zM103 281v-40h399897v40z`,leftlinesegment:VR(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:VR(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:VR(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:VR(`M40 281 V448H0V74H40V241H400000v40z`),leftToFrom:`M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
71.5 23h399859zM103 281v-40h399897v40z`,leftlinesegment:WR(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:WR(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:WR(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:WR(`M40 281 V448H0V74H40V241H400000v40z`),leftToFrom:`M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8
c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3
68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,longequal:VR(`M0 50 h400000 v40H0z m0 194h40000v40H0z`),midbrace:`M200428 334
68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,longequal:WR(`M0 50 h400000 v40H0z m0 194h40000v40H0z`),midbrace:`M200428 334
c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
@@ -313,7 +313,7 @@ m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z`,rightharpoondown
m0-194v40h400000v-40zm0 0v40h400000v-40z`,righthook:`M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3
15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0
-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21
66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`,rightlinesegment:VR(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:VR(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:VR(`M399995 440 h-120 V150 H0 v-120 H399995z`),rightToFrom:`M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`,rightlinesegment:WR(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:WR(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:WR(`M399995 440 h-120 V150 H0 v-120 H399995z`),rightToFrom:`M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32
-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142
-167z M100 147v40h399900v-40zM0 341v40h399900v-40z`,twoheadleftarrow:`M0 167c68 40
@@ -386,7 +386,7 @@ M93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z`
c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6
c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`},$R=function(e,t){switch(e){case`lbrack`:return`M403 1759 V84 H666 V0 H319 V1759 v`+t+` v1759 v84 h347 v-84
M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`},nz=function(e,t){switch(e){case`lbrack`:return`M403 1759 V84 H666 V0 H319 V1759 v`+t+` v1759 v84 h347 v-84
H403z M403 1759 V0 H319 V1759 v`+t+` v1759 v84 h84z`;case`rbrack`:return`M347 1759 V0 H0 V84 H263 V1759 v`+t+` v1759 H0 v84 H347z
M347 1759 V0 H263 V1759 v`+t+` v1759 h84z`;case`vert`:return`M145 15 v585 v`+t+` v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v`+-t+` v-585 c-2.667,-10,-9.667,-15,-21,-15
@@ -414,15 +414,15 @@ c-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6
c0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17
c242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558
l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;default:throw Error(`Unknown stretchy delimiter.`)}};function ez(e){return`toText`in e}var tz=class{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){for(var e=document.createDocumentFragment(),t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){for(var e=``,t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map(e=>{if(ez(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},nz={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:803/800,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:803/800},rz={ex:!0,em:!0,mu:!0},iz=function(e){return typeof e!=`string`&&(e=e.unit),e in nz||e in rz||e===`ex`},az=function(e,t){var n;if(e.unit in nz)n=nz[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit===`mu`)n=t.fontMetrics().cssEmPerMu;else{var r=t.style.isTight()?t.havingStyle(t.style.text()):t;if(e.unit===`ex`)n=r.fontMetrics().xHeight;else if(e.unit===`em`)n=r.fontMetrics().quad;else throw new L(`Invalid unit: '`+e.unit+`'`);r!==t&&(n*=r.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},z=function(e){return+e.toFixed(4)+`em`},oz=function(e){return e.filter(e=>e).join(` `)},sz=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=cR(n)+`:`+r+`;`)}return t},cz=function(e,t,n){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=n||{},t){t.style.isTight()&&this.classes.push(`mtight`);var r=t.getColor();r&&(this.style.color=r)}},lz=function(e){var t=document.createElement(e);t.className=oz(this.classes),Object.assign(t.style,this.style);for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);for(var r=0;r<this.children.length;r++)t.appendChild(this.children[r].toNode());return t},uz=/[\s"'>/=\x00-\x1f]/,dz=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+dR(oz(this.classes))+`"`);var n=sz(this.style);n&&(t+=` style="`+dR(n)+`"`);for(var r of Object.keys(this.attributes)){if(uz.test(r))throw new L(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+dR(this.attributes[r])+`"`}t+=`>`;for(var i=0;i<this.children.length;i++)t+=this.children[i].toMarkup();return t+=`</`+e+`>`,t},fz=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,cz.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return lz.call(this,`span`)}toMarkup(){return dz.call(this,`span`)}},pz=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,cz.call(this,t,r),this.children=n||[],this.setAttribute(`href`,e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return lz.call(this,`a`)}toMarkup(){return dz.call(this,`a`)}},mz=class{constructor(e,t,n){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=[`mord`],this.height=0,this.depth=0,this.maxFontSize=0,this.style=n}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createElement(`img`);return e.src=this.src,e.alt=this.alt,e.className=`mord`,Object.assign(e.style,this.style),e}toMarkup(){var e=`<img src="`+dR(this.src)+`"`+(` alt="`+dR(this.alt)+`"`),t=sz(this.style);return t&&(e+=` style="`+dR(t)+`"`),e+=`'/>`,e}},hz={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},gz=class{constructor(e,t,n,r,i,a,o,s){this.text=void 0,this.height=void 0,this.depth=void 0,this.italic=void 0,this.skew=void 0,this.width=void 0,this.maxFontSize=void 0,this.classes=void 0,this.style=void 0,this.text=e,this.height=t||0,this.depth=n||0,this.italic=r||0,this.skew=i||0,this.width=a||0,this.classes=o||[],this.style=s||{},this.maxFontSize=0;var c=RR(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=hz[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createTextNode(this.text),t=null;return this.italic>0&&(t=document.createElement(`span`),t.style.marginRight=z(this.italic)),this.classes.length>0&&(t||=document.createElement(`span`),t.className=oz(this.classes)),Object.keys(this.style).length>0&&(t||=document.createElement(`span`),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t=`<span`;this.classes.length&&(e=!0,t+=` class="`,t+=dR(oz(this.classes)Line truncated
`+h+` children.`);for(var v=0;v<h;v++){var y=new _z([new vz(d[v])],{width:`400em`,height:z(m),viewBox:`0 0 `+n+` `+p,preserveAspectRatio:_[v]+` slice`}),b=wB([g[v]],[y],t);if(h===1)return{span:b,minWidth:f,height:m};b.style.height=z(m),l.push(b)}return{span:X([`katex-stretchy`],l,t),minWidth:f,height:m}}var r=n(),i=r.span,a=r.minWidth,o=r.height;return i.height=o,i.style.height=z(o),a>0&&(i.style.minWidth=z(a)),i},NV=function(e,t,n,r,i){var a,o=e.height+e.depth+n+r;if(/fbox|color|angl/.test(t)){if(a=X([`katex-stretchy`,t],[],i),t===`fbox`){var s=i.color&&i.getColor();s&&(a.style.borderColor=s)}}else{var c=[];/^[bx]cancel$/.test(t)&&c.push(new yz({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new yz({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=wB([],[new _z(c,{width:`100%`,height:z(o)})],i)}return a.height=o,a.style.height=z(o),a},PV=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],FV=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],IV=new Set(PV),LV=new Set(FV);function RV(e){return IV.has(e)}function zV(e,t){if(!e||e.type!==t)throw Error(`Expected node of type `+t+`, but got `+(e?`node of type `+e.type:String(e)));return e}function BV(e){var t=VV(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function VV(e){return e.type===`atom`||LV.has(e.type)?e:null}function HV(e,t,n){var r=``;for(var i of e.body)if(i.type===`textord`)r+=i.text;else if(n&&i.type===`spacing`&&i.text===` `)r+=` `;else throw new L(t,e);return r}var UV=e=>{if(e instanceof gz)return e;if(Sz(e)&&e.children.length===1)return UV(e.children[0])},WV=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=zV(e.base,`accent`),n=r.base,e.base=n,i=xz(rV(e,t)),e.base=r):(r=zV(e,`accent`),n=r.base);var a=rV(n,t.havingCrampedStyle()),o=r.isShifty&&mR(n),s=0;o&&(s=UV(a)?.skew??0);var c=r.label===`\\c`,l=c?a.height+a.depth:Math.min(a.height,t.fontMetrics().xHeight),u;if(r.isStretchy)u=MV(r,t),u=AB({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`elem`,elem:u,wrapperClasses:[`svg-align`],wrapperStyle:s>0?{width:`calc(100% - `+z(2*s)+`)`,marginLeft:z(2*s)}:void 0}]});else{var d,f;r.label===`\\vec`?(d=FB(`vec`,t),f=PB.vec[1]):(d=bB({type:`textord`,mode:r.mode,text:r.label},t),d=bz(d),d.italic=0,f=d.width,c&&(l+=d.depth)),u=X([`accent-body`],[d]);var p=r.label===`\\textcircled`;p&&(u.classes.push(`accent-full`),l=a.height);var m=s;p||(m-=f/2),u.style.left=z(m),r.label===`\\textcircled`&&(u.style.top=`.2em`),u=AB({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:-l},{type:`elem`,elem:u}]})}var h=X([`mord`,`katex-accent`],[u],t);return i?(i.children[0]=h,i.height=Math.max(h.height,i.height),i.classes[0]=`mord`,i):h},GV=(e,t)=>{var n=e.isStretchy?kV(e.label):new Q(`mo`,[dV(e.label,e.mode)]),r=new Q(`mover`,[vV(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},KV=new RegExp([`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`].map(e=>`\\`+e).join(`|`));Z({type:`accent`,names:[`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`,`\\widecheck`,`\\widehat`,`\\widetilde`,`\\overrightarrow`,`\\overleftarrow`,`\\Overrightarrow`,`\\overleftrightarrow`,`\\overgroup`,`\\overlinesegment`,`\\overleftharpoon`,`\\overrightharpoon`],numArgs:1,handler:(e,t)=>{var n=GB(t[0]),r=!KV.test(e.funcName),i=!r||e.funcName===`\\widehat`||e.funcName===`\\widetilde`||e.funcName===`\\widecheck`;return{type:`accent`,mode:e.parser.mode,label:e.funcName,isStretchy:r,isShifty:i,base:n}},htmlBuilder:WV,mathmlBuilder:GV}),Z({type:`accent`,names:[`\\'`,"\\`",`\\^`,`\\~`,`\\=`,`\\u`,`\\.`,`\\"`,`\\c`,`\\r`,`\\H`,`\\v`,`\\textcircled`],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`primitive`],handler:(e,t)=>{var n=t[0],r=e.parser.mode;return r===`math`&&(e.parser.settings.reportNonstrict(`mathVsTextAccents`,`LaTeX's accent `+e.funcName+` works only in text mode`),r=`text`),{type:`accent`,mode:r,label:e.funcName,isStretchy:!1,isShifty:!0,base:n}}}),Z({type:`accentUnder`,names:[`\\underleftarrow`,`\\underrightarrow`,`\\underleftrightarrow`,`\\undergroup`,`\\underlinesegment`,`\\utilde`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`accentUnder`,mode:n.mode,label:r,base:i}},htmlBuilder:(e,t)=>{var n=rV(e.base,t),r=MV(e,t),i=e.label===`\\utilde`?.12:0;return X([`mord`,`accentunder`],[AB({positionType:`top`,positionData:n.height,children:[{type:`elem`,elem:r,wrapperClasses:[`svg-align`]},{type:`kern`,size:i},{type:`elem`,elem:n}]})],t)},mathmlBuilder:(e,t)=>{var n=kV(e.label),r=new Q(`munder`,[vV(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var qV=e=>{var t=new Q(`mpadded`,e?[e]:[]);return t.setAttribute(`width`,`+0.6em`),t.setAttribute(`lspace`,`0.3em`),t};Z({type:`xArrow`,names:[`\\xleftarrow`,`\\xrightarrow`,`\\xLeftarrow`,`\\xRightarrow`,`\\xleftrighLine truncated
]`,RU=`\\\\[a-zA-Z@]+`,zU=`\\\\[^\ud800-\udfff]`,BU=`(`+RU+`)`+LU+`*`,VU=`\\\\(
-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;default:throw Error(`Unknown stretchy delimiter.`)}};function rz(e){return`toText`in e}var iz=class{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){for(var e=document.createDocumentFragment(),t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){for(var e=``,t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map(e=>{if(rz(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},az={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:803/800,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:803/800},oz={ex:!0,em:!0,mu:!0},sz=function(e){return typeof e!=`string`&&(e=e.unit),e in az||e in oz||e===`ex`},cz=function(e,t){var n;if(e.unit in az)n=az[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit===`mu`)n=t.fontMetrics().cssEmPerMu;else{var r=t.style.isTight()?t.havingStyle(t.style.text()):t;if(e.unit===`ex`)n=r.fontMetrics().xHeight;else if(e.unit===`em`)n=r.fontMetrics().quad;else throw new L(`Invalid unit: '`+e.unit+`'`);r!==t&&(n*=r.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},z=function(e){return+e.toFixed(4)+`em`},lz=function(e){return e.filter(e=>e).join(` `)},uz=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=dR(n)+`:`+r+`;`)}return t},dz=function(e,t,n){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=n||{},t){t.style.isTight()&&this.classes.push(`mtight`);var r=t.getColor();r&&(this.style.color=r)}},fz=function(e){var t=document.createElement(e);t.className=lz(this.classes),Object.assign(t.style,this.style);for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);for(var r=0;r<this.children.length;r++)t.appendChild(this.children[r].toNode());return t},pz=/[\s"'>/=\x00-\x1f]/,mz=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+mR(lz(this.classes))+`"`);var n=uz(this.style);n&&(t+=` style="`+mR(n)+`"`);for(var r of Object.keys(this.attributes)){if(pz.test(r))throw new L(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+mR(this.attributes[r])+`"`}t+=`>`;for(var i=0;i<this.children.length;i++)t+=this.children[i].toMarkup();return t+=`</`+e+`>`,t},hz=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,dz.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return fz.call(this,`span`)}toMarkup(){return mz.call(this,`span`)}},gz=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,dz.call(this,t,r),this.children=n||[],this.setAttribute(`href`,e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return fz.call(this,`a`)}toMarkup(){return mz.call(this,`a`)}},_z=class{constructor(e,t,n){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=[`mord`],this.height=0,this.depth=0,this.maxFontSize=0,this.style=n}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createElement(`img`);return e.src=this.src,e.alt=this.alt,e.className=`mord`,Object.assign(e.style,this.style),e}toMarkup(){var e=`<img src="`+mR(this.src)+`"`+(` alt="`+mR(this.alt)+`"`),t=uz(this.style);return t&&(e+=` style="`+mR(t)+`"`),e+=`'/>`,e}},vz={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},yz=class{constructor(e,t,n,r,i,a,o,s){this.text=void 0,this.height=void 0,this.depth=void 0,this.italic=void 0,this.skew=void 0,this.width=void 0,this.maxFontSize=void 0,this.classes=void 0,this.style=void 0,this.text=e,this.height=t||0,this.depth=n||0,this.italic=r||0,this.skew=i||0,this.width=a||0,this.classes=o||[],this.style=s||{},this.maxFontSize=0;var c=VR(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=vz[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createTextNode(this.text),t=null;return this.italic>0&&(t=document.createElement(`span`),t.style.marginRight=z(this.italic)),this.classes.length>0&&(t||=document.createElement(`span`),t.className=lz(this.classes)),Object.keys(this.style).length>0&&(t||=document.createElement(`span`),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t=`<span`;this.classes.length&&(e=!0,t+=` class="`,t+=mR(lz(this.classes)Line truncated
`+h+` children.`);for(var v=0;v<h;v++){var y=new bz([new xz(d[v])],{width:`400em`,height:z(m),viewBox:`0 0 `+n+` `+p,preserveAspectRatio:_[v]+` slice`}),b=DB([g[v]],[y],t);if(h===1)return{span:b,minWidth:f,height:m};b.style.height=z(m),l.push(b)}return{span:X([`katex-stretchy`],l,t),minWidth:f,height:m}}var r=n(),i=r.span,a=r.minWidth,o=r.height;return i.height=o,i.style.height=z(o),a>0&&(i.style.minWidth=z(a)),i},IV=function(e,t,n,r,i){var a,o=e.height+e.depth+n+r;if(/fbox|color|angl/.test(t)){if(a=X([`katex-stretchy`,t],[],i),t===`fbox`){var s=i.color&&i.getColor();s&&(a.style.borderColor=s)}}else{var c=[];/^[bx]cancel$/.test(t)&&c.push(new Sz({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new Sz({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=DB([],[new bz(c,{width:`100%`,height:z(o)})],i)}return a.height=o,a.style.height=z(o),a},LV=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],RV=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],zV=new Set(LV),BV=new Set(RV);function VV(e){return zV.has(e)}function HV(e,t){if(!e||e.type!==t)throw Error(`Expected node of type `+t+`, but got `+(e?`node of type `+e.type:String(e)));return e}function UV(e){var t=WV(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function WV(e){return e.type===`atom`||BV.has(e.type)?e:null}function GV(e,t,n){var r=``;for(var i of e.body)if(i.type===`textord`)r+=i.text;else if(n&&i.type===`spacing`&&i.text===` `)r+=` `;else throw new L(t,e);return r}var KV=e=>{if(e instanceof yz)return e;if(Tz(e)&&e.children.length===1)return KV(e.children[0])},qV=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=HV(e.base,`accent`),n=r.base,e.base=n,i=wz(oV(e,t)),e.base=r):(r=HV(e,`accent`),n=r.base);var a=oV(n,t.havingCrampedStyle()),o=r.isShifty&&_R(n),s=0;o&&(s=KV(a)?.skew??0);var c=r.label===`\\c`,l=c?a.height+a.depth:Math.min(a.height,t.fontMetrics().xHeight),u;if(r.isStretchy)u=FV(r,t),u=NB({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`elem`,elem:u,wrapperClasses:[`svg-align`],wrapperStyle:s>0?{width:`calc(100% - `+z(2*s)+`)`,marginLeft:z(2*s)}:void 0}]});else{var d,f;r.label===`\\vec`?(d=RB(`vec`,t),f=LB.vec[1]):(d=CB({type:`textord`,mode:r.mode,text:r.label},t),d=Cz(d),d.italic=0,f=d.width,c&&(l+=d.depth)),u=X([`accent-body`],[d]);var p=r.label===`\\textcircled`;p&&(u.classes.push(`accent-full`),l=a.height);var m=s;p||(m-=f/2),u.style.left=z(m),r.label===`\\textcircled`&&(u.style.top=`.2em`),u=NB({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:-l},{type:`elem`,elem:u}]})}var h=X([`mord`,`katex-accent`],[u],t);return i?(i.children[0]=h,i.height=Math.max(h.height,i.height),i.classes[0]=`mord`,i):h},JV=(e,t)=>{var n=e.isStretchy?MV(e.label):new Q(`mo`,[mV(e.label,e.mode)]),r=new Q(`mover`,[xV(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},YV=new RegExp([`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`].map(e=>`\\`+e).join(`|`));Z({type:`accent`,names:[`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`,`\\widecheck`,`\\widehat`,`\\widetilde`,`\\overrightarrow`,`\\overleftarrow`,`\\Overrightarrow`,`\\overleftrightarrow`,`\\overgroup`,`\\overlinesegment`,`\\overleftharpoon`,`\\overrightharpoon`],numArgs:1,handler:(e,t)=>{var n=JB(t[0]),r=!YV.test(e.funcName),i=!r||e.funcName===`\\widehat`||e.funcName===`\\widetilde`||e.funcName===`\\widecheck`;return{type:`accent`,mode:e.parser.mode,label:e.funcName,isStretchy:r,isShifty:i,base:n}},htmlBuilder:qV,mathmlBuilder:JV}),Z({type:`accent`,names:[`\\'`,"\\`",`\\^`,`\\~`,`\\=`,`\\u`,`\\.`,`\\"`,`\\c`,`\\r`,`\\H`,`\\v`,`\\textcircled`],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`primitive`],handler:(e,t)=>{var n=t[0],r=e.parser.mode;return r===`math`&&(e.parser.settings.reportNonstrict(`mathVsTextAccents`,`LaTeX's accent `+e.funcName+` works only in text mode`),r=`text`),{type:`accent`,mode:r,label:e.funcName,isStretchy:!1,isShifty:!0,base:n}}}),Z({type:`accentUnder`,names:[`\\underleftarrow`,`\\underrightarrow`,`\\underleftrightarrow`,`\\undergroup`,`\\underlinesegment`,`\\utilde`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`accentUnder`,mode:n.mode,label:r,base:i}},htmlBuilder:(e,t)=>{var n=oV(e.base,t),r=FV(e,t),i=e.label===`\\utilde`?.12:0;return X([`mord`,`accentunder`],[NB({positionType:`top`,positionData:n.height,children:[{type:`elem`,elem:r,wrapperClasses:[`svg-align`]},{type:`kern`,size:i},{type:`elem`,elem:n}]})],t)},mathmlBuilder:(e,t)=>{var n=MV(e.label),r=new Q(`munder`,[xV(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var XV=e=>{var t=new Q(`mpadded`,e?[e]:[]);return t.setAttribute(`width`,`+0.6em`),t.setAttribute(`lspace`,`0.3em`),t};Z({type:`xArrow`,names:[`\\xleftarrow`,`\\xrightarrow`,`\\xLeftarrow`,`\\xRightarrow`,`\\xleftrighLine truncated
]`,VU=`\\\\[a-zA-Z@]+`,HU=`\\\\[^\ud800-\udfff]`,UU=`(`+VU+`)`+BU+`*`,WU=`\\\\(
|[ \r ]+
?)[ \r ]*`,HU=`[̀-ͯ]`,UU=RegExp(HU+`+$`),WU=`(`+LU+`+)|`+(VU+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(HU+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(HU+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+BU)+(`|`+zU+`)`),GU=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(WU,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new GH(`EOF`,new WH(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new L(`Unexpected character: '`+e[t]+`'`,new GH(e[t],new WH(this,t,t+1)));var r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){var i=e.indexOf(`
`,this.tokenRegex.lastIndex);return i===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict(`commentAtEnd`,`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)`)):this.tokenRegex.lastIndex=i+1,this.lex()}return new GH(r,new WH(this,t,this.tokenRegex.lastIndex))}},KU=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new L(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);var e=this.undefStack.pop();for(var t of Object.keys(e))e[t]===void 0?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){if(Object.prototype.hasOwnProperty.call(this.current,e))return this.current[e];if(Object.prototype.hasOwnProperty.call(this.builtins,e))return this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var r=0;r<this.undefStack.length;r++)delete this.undefStack[r][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var i=this.undefStack[this.undefStack.length-1];i&&!Object.prototype.hasOwnProperty.call(i,e)&&(i[e]=Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:void 0)}t==null?delete this.current[e]:this.current[e]=t}},qU=UH;$(`\\noexpand`,function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),$(`\\expandafter`,function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),$(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),$(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),$(`\\@ifnextchar`,function(e){var t=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),$(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),$(`\\TextOrMath`,function(e){var t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var JU={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};$(`\\char`,function(e){var t=e.popToken(),n,r=0;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`"){if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new L("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){if(r=JU[t.text],r==null||r>=n)throw new L(`Invalid base-`+n+` digit `+t.text);for(var i;(i=JU[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var YU=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new L(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new L(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new L(`\\renewcommand{`+a+`} when command `+a+` does not yet exist; use \\newcommand`);var s=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text===`[`){for(var c=``,l=e.expandNextToken();l.text!==`]`&&l.text!==`EOF`;)c+=l.text,l=e.expandNextToken();if(!c.match(/^\s*[0-9]+\s*$/))throw new L(`Invalid number of arguments: `+c);s=parseInt(c),i=e.consumeArg().tokens}return o&&r||e.macros.set(a,{tokens:i,numArgs:s}),``};$(`\\newcommand`,e=>YU(e,!1,!0,!1)),$(`\\renewcommand`,e=>YU(e,!0,!1,!1)),$(`\\providecommand`,e=>YU(e,!0,!0,!0)),$(`\\message`,e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join(``)),``}),$(`\\errmessage`,e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join(``)),``}),$(`\\show`,e=>{var t=e.popToken(),n=t.text;return console.log(t,e.macros.get(n),IU[n],Az.math[n],Az.text[n]),``}),$(`\\bgroup`,`{`),$(`\\egroup`,`}`),$(`~`,`\\nobreakspace`),$(`\\lq`,"`"),$(`\\rq`,`'`),$(`\\aa`,`\\r a`),$(`\\AA`,`\\r A`),$(`\\textcopyright`,"\\html@mathml{\\textcircled{c}}{\\char`©}"),$(`\\copyright`,`\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}`),$(`\\textregistered`,"\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),$(`ℬ`,`\\mathscr{B}`),$(`ℰ`,`\\mathscr{E}`),$(`ℱ`,`\\mathscr{F}`),$(`ℋ`,`\\mathscr{H}`),$(`ℐ`,`\\mathscr{I}`),$(`ℒ`,`\\mathscr{L}`),$(`ℳ`,`\\mathscr{M}`),$(`ℛ`,`\\mathscr{R}`),$(`ℭ`,`\\mathfrak{C}`),$(`ℌ`,`\\mathfrak{H}`),$(`ℨ`,`\\mathfrak{Z}`),$(`\\Bbbk`,`\\Bbb{k}`),$(`\\llap`,`\\mathllap{\\textrm{#1}}`),$(`\\rlap`,`\\mathrlap{\\textrm{#1}}`),$(`\\clap`,`\\mathclap{\\textrm{#1}}`),$(`\\mathstrut`,`\\vphantom{(}`),$(`\\underbar`,`\\underline{\\text{#1}}`),$(`\\not`,`\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}`),$(`\\neq`,"\\html@mathml{\\mathreLine truncated
please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(oW,t[0])&&!Az[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Accented Unicode text character "`+t[0]+`" used in math mode`,e),t=oW[t[0]]+t.slice(1));var i=UU.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(Az[this.mode][t]){this.settings.strict&&this.mode===`math`&&Qz.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=Az[this.mode][t].group,s=WH.range(e);a=RV(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(BR(t.charCodeAt(0))?this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Unicode text character "`+t[0]+`" used in math mode`,e):this.settings.reportNonstrict(`unknownSymbol`,`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),e)),a={type:`textord`,mode:`text`,loc:WH.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!aW[l])throw new L(`Unknown accent ' `+l+`'`,e);var u=aW[l][this.mode]||aW[l].text;if(!u)throw new L(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:WH.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};sW.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var cW=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new sW(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new L(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new GH(`\\df@tag`)])}]}return r},lW=function(e,t,n){t.textContent=``;var r=pW(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),lW=function(){throw new L(`KaTeX doesn't work in quirks mode.`)});var uW=function(e,t){return pW(e,t).toMarkup()},dW=function(e,t){return cW(e,new bR(t))},fW=function(e,t,n){if(n.throwOnError||!(e instanceof L))throw e;var r=X([`katex-error`],[new gz(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},pW=function(e,t){var n=new bR(t);try{return EV(cW(e,n),e,n)}catch(t){return fW(t,e,n)}},mW={version:`0.18.10`,render:lW,renderToString:uW,ParseError:L,SETTINGS_SCHEMA:gR,__parse:dW,__renderToDomTree:pW,__renderToHTMLTree:function(e,t){var n=new bR(t);try{return DV(cW(e,n),e,n)}catch(t){return fW(t,e,n)}},__setFontMetrics:Ez,__defineSymbol:B,__defineFunction:Z,__defineMacro:$,__domTree:{Span:fz,Anchor:pz,SymbolNode:gz,SvgNode:_z,PathNode:vz,LineNode:yz}},hW=Jp.create({name:`blockMath`,group:`block`,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertBlockMath:e=>({commands:t,editor:n})=>{let{latex:r,pos:i}=e;return r?t.insertContentAt(i??n.state.selection.from,{type:this.name,attrs:{latex:r}}):!1},deleteBlockMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateBlockMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r??a.attrs.latex}),!0)}}},parseHTML(){return[{tag:`div[data-type="block-math"]`}]},renderHTML({HTMLAttributes:e}){return[`div`,A(e,{"data-type":`block-math`})]},parseMarkdown:e=>({type:`blockMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>[`$$`,e.attrs?.latex||``,`$$`].join(`
`),markdownTokenizer:{name:`blockMath`,level:`block`,start:e=>e.indexOf(`$$`),tokenize:e=>{let t=e.match(/^\$\$([^$]+)\$\$/);if(!t)return;let[n,r]=t;return{type:`blockMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new lp({find:/^\$\$\$([^$]+)\$\$\$$/,handler:({state:e,range:t,match:n})=>{let[,r]=n,{tr:i}=e,a=e.doc.resolve(t.from),o=this.type.create({latex:r}),s=a.depth>0&&a.parent.isTextblock&&t.from===a.start()&&t.to===a.end()&&a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),this.type)?{from:a.before(),to:a.after()}:t;i.replaceWith(s.from,s.to,o)}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`div`),i=document.createElement(`div`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),i.className=`block-math-inner`,r.dataset.type=`block-math`,r.setAttribute(`data-latex`,t.attrs.latex),r.appendChild(i);function a(){try{mW.render(t.attrs.latex,i,e),r.classList.remove(`block-math-error`)}catch{r.textContent=t.attrs.latex,r.classList.add(`block-math-error`)}}let o=e=>{e.preventDefault(),e.stopPropagation();let r=n();r!=null&&this.options.onClick&&this.options.onClick(t,r)};return this.options.onClick&&r.addEventListener(`click`,o),a(),{dom:r,destroy(){r.removeEventListener(`click`,o)}}}}}),gW=e=>{let t=/\$\$([^$\n]+?)\$\$(?!\$)/g,n=t.exec(e);for(;n!==null;){if(n.index===0||e[n.index-1]!==`$`)return{index:n.index,text:n[0],data:{latex:n[1]}};t.lastIndex=n.index+1,n=t.exec(e)}return null},_W=Jp.create({name:`inlineMath`,group:`inline`,inline:!0,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertInlineMath:e=>({editor:t,tr:n})=>{let r=e.latex,i=e?.pos??t.state.selection.from;return r?(n.replaceWith(i,i,this.type.create({latex:r})),!0):!1},deleteInlineMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateInlineMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r}),!0)}}},parseHTML(){return[{tag:`span[data-type="inline-math"]`}]},renderHTML({HTMLAttributes:e}){return[`span`,A(e,{"data-type":`inline-math`})]},parseMarkdown:e=>({type:`inlineMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>`$${e.attrs?.latex||``}$`,markdownTokenizer:{name:`inlineMath`,level:`inline`,start:e=>e.indexOf(`$`),tokenize:e=>{let t=e.match(/^\$([^$]+)\$(?!\$)/);if(!t)return;let[n,r]=t;return{type:`inlineMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new lp({find:gW,handler:({state:e,range:t,match:n})=>{let r=n.data?.latex;if(typeof r!=`string`)return null;let{tr:i}=e,a=t.from,o=t.to;i.replaceWith(a,o,this.type.create({latex:r}))}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`span`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),r.dataset.type=`inline-math`,r.setAttribute(`data-latex`,t.attrs.latex);function i(){try{mW.render(t.attrs.latex,r,e),r.classList.remove(`inline-math-error`)}catch{r.textContent=t.attrs.latex,r.classList.add(`inline-math-error`)}}let a=e=>{e.preventDefault(),e.stopPropagation();let r=n();r!=null&&this.options.onClick&&this.options.onClick(t,r)};return this.options.onClick&&r.addEventListener(`click`,a),i(),{dom:r,destroy(){r.removeEventListener(`click`,a)}}}}}),vW=Tp.create({name:`Mathematics`,addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[hW.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),_W.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}});function yW(e,t){let n=n=>(r,i)=>{let a=t();if(!a?.isEditable)return;let o=a.view.nodeDOM(i);if(!(o instanceof HTMLElement))return;let s=e.blocks;IL({anchor:o,value:String(r.attrs.latex??``),label:s.latex,multiline:n===`block`,monospace:!0,labels:{done:s.done,cancel:s.cancel,remove:s.remove},onSave:e=>{let t=a.chain().setNodeSelection(i);e.trim()?(n===`inline`?t.updateInlineMath({latex:e,pos:i}):t.updateBlockMath({latex:e,pos:i})).focus().run():(n===`inline`?t.deleteInlineMath({pos:i}):t.deleteBlockMath({pos:i})).focus().run()},onRemove:()=>{let e=a.chain();(n===`inline`?e.deleteInlineMath({pos:i}):e.deleteBlockMath({pos:i})).focus().run()}})};return vW.configure({katexOptions:{throwOnError:!1,strict:!1,trust:!1},inlineOptions:{onClick:n(`inline`)},blockOptions:{onClick:n(`block`)}})}function bW({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r=`@`}){return{editor:e,char:r,pluginKey:new D,command:({editor:e,range:t,props:i})=>{var a,o;let s=Line truncated
Idea --> Draft --> Review --> Published`,EW=null;function DW(e){return EW??=e().then(e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:document.documentElement.classList.contains(`dark`)?`dark`:`neutral`,fontFamily:`inherit`}),e)),EW}var OW=0;async function kW(e,t,n,r){if(e.classList.remove(`dw-mermaid__body--error`),!t.trim())e.textContent=``;else if(r)try{let{svg:n}=await(await DW(r)).render(`dw-mermaid-${++OW}`,t);e.innerHTML=n}catch(t){e.classList.add(`dw-mermaid__body--error`),e.textContent=`${n.blocks.mermaidError} ${t instanceof Error?t.message:String(t)}`}else{let n=document.createElement(`pre`);n.className=`dw-mermaid__source`,n.textContent=t,e.replaceChildren(n)}}var AW=Jp.create({name:`mermaid`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null,load:void 0}},addAttributes(){return{code:{default:``,parseHTML:e=>e.getAttribute(`data-code`)??e.textContent??``,renderHTML:e=>({"data-code":e.code})}}},parseHTML(){return[{tag:`div[data-type='mermaid']`},{tag:`pre.mermaid`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,A(t,{"data-type":`mermaid`}),[`pre`,{},String(e.attrs.code)]]},addCommands(){return{insertMermaid:(e=TW)=>({commands:t})=>t.insertContent({type:this.name,attrs:{code:e}})}},addNodeView(){return({node:e,editor:t,getPos:n})=>{let r=this.options.labels,i=this.options.load,a=document.createElement(`div`);a.className=`dw-mermaid`,a.setAttribute(`data-type`,`mermaid`);let o=document.createElement(`div`);o.className=`dw-mermaid__body`,a.append(o);let s=String(e.attrs.code);return kW(o,s,r,i),a.addEventListener(`click`,()=>{if(!t.isEditable)return;let e=typeof n==`function`?n():void 0;if(e===void 0)return;let c=r.blocks;IL({anchor:a,value:s,label:c.mermaid,multiline:!0,monospace:!0,labels:{done:c.done,cancel:c.cancel,remove:c.remove},onInput:e=>void kW(o,e,r,i),onSave:n=>{t.chain().setNodeSelection(e).updateAttributes(`mermaid`,{code:n}).run(),kW(o,n,r,i)},onRemove:()=>t.chain().setNodeSelection(e).deleteSelection().focus().run(),onCancel:()=>void kW(o,s,r,i)})}),{dom:a,update:e=>e.type.name===`mermaid`&&(e.attrs.code!==s&&(s=String(e.attrs.code),kW(o,s,r,i)),!0),ignoreMutation:()=>!0,stopEvent:()=>!1}}}});function jW(e){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.multiple=!0,n.onchange=()=>t([...n.files??[]]),n.click()})}function MW(e,t,n,r,i=!1,a){let o=(t,n,r,i)=>({id:t,icon:n,keywords:r,label:e.slash[t]?.label??t,description:e.slash[t]?.description??``,run:i}),s=[o(`text`,`text`,[`paragraph`,`p`],(e,t)=>e.chain().focus().deleteRange(t).setParagraph().run()),o(`h1`,`heading`,[`heading`,`title`,`#`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:1}).run()),o(`h2`,`heading`,[`heading`,`subtitle`,`##`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:2}).run()),o(`h3`,`heading`,[`heading`,`###`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:3}).run()),{...o(`otherHeadings`,`heading`,[`other`,`more headings`,`smaller`],()=>{}),children:[4,5,6].map(e=>o(`h${e}`,`heading`,[`heading`,`#`.repeat(e)],(t,n)=>t.chain().focus().deleteRange(n).setHeading({level:e}).run()))},o(`bullet`,`list`,[`list`,`ul`,`-`],(e,t)=>e.chain().focus().deleteRange(t).toggleBulletList().run()),o(`ordered`,`list-ordered`,[`list`,`ol`,`1.`],(e,t)=>e.chain().focus().deleteRange(t).toggleOrderedList().run()),o(`todo`,`todo`,[`task`,`checkbox`,`checklist`,`[]`],(e,t)=>e.chain().focus().deleteRange(t).toggleTaskList().run()),o(`callout`,`callout`,[`note`,`info`,`tip`,`warning`,`aside`,`box`],(e,t)=>e.chain().focus().deleteRange(t).setCallout().run()),o(`table`,`table`,[`grid`,`rows`,`columns`,`spreadsheet`],(e,t)=>e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()),o(`database`,`database`,[`kanban`,`board`,`calendar`,`records`,`tracker`,`notion`],(e,t)=>e.chain().focus().deleteRange(t).insertDatabase().run()),o(`quote`,`quote`,[`blockquote`,`>`],(e,t)=>e.chain().focus().deleteRange(t).toggleBlockquote().run()),o(`code`,`code`,[`codeblock`,"```",`snippet`],(e,t)=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()),o(`toggle`,`chevron-right`,[`details`,`collapse`,`expand`,`fold`,`>`],(e,t)=>e.chain().focus().deleteRange(t).setDetails().run()),o(`divider`,`divider`,[`hr`,`rule`,`line`,`---`],(e,t)=>e.chain().focus().deleteRange(t).setHorizontalRule().run()),o(`toc`,`list`,[`contents`,`outline`,`headings`,`index`],(e,t)=>e.chain().focus().deleteRange(t).insertTableOfContents().run()),o(`math`,`sigma`,[`latex`,`formula`,`equation`,`katex`,`$$`],(e,t)=>e.chain().focus().deleteRange(t).insertBlockMath({latex:`E = mc^2`}).run()),o(`mathInline`,`sigma`,[`latex`,`formula`,`equation`,`$`],(e,t)=>e.chain().focus().deleteRange(t).insertInlineMath({latex:`x^2`}).run()),o(`mermaid`,`diagram`,[`diagram`,`flowchart`,`chart`,`sequence`,`graph`],(e,t)=>e.chain().focus().deleteRange(t).insertMermaid().run()),o(`embed`,`video`,[`video`,`youtube`,`vimeo`,`figma`,`loom`,`iframe`,`map`],(t,r)=>{t.chain().Line truncated
?)[ \r ]*`,GU=`[̀-ͯ]`,KU=RegExp(GU+`+$`),qU=`(`+BU+`+)|`+(WU+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(GU+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(GU+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+UU)+(`|`+HU+`)`),JU=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(qU,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new JH(`EOF`,new qH(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new L(`Unexpected character: '`+e[t]+`'`,new JH(e[t],new qH(this,t,t+1)));var r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){var i=e.indexOf(`
`,this.tokenRegex.lastIndex);return i===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict(`commentAtEnd`,`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)`)):this.tokenRegex.lastIndex=i+1,this.lex()}return new JH(r,new qH(this,t,this.tokenRegex.lastIndex))}},YU=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new L(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);var e=this.undefStack.pop();for(var t of Object.keys(e))e[t]===void 0?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){if(Object.prototype.hasOwnProperty.call(this.current,e))return this.current[e];if(Object.prototype.hasOwnProperty.call(this.builtins,e))return this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var r=0;r<this.undefStack.length;r++)delete this.undefStack[r][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var i=this.undefStack[this.undefStack.length-1];i&&!Object.prototype.hasOwnProperty.call(i,e)&&(i[e]=Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:void 0)}t==null?delete this.current[e]:this.current[e]=t}},XU=KH;$(`\\noexpand`,function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),$(`\\expandafter`,function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),$(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),$(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),$(`\\@ifnextchar`,function(e){var t=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),$(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),$(`\\TextOrMath`,function(e){var t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var ZU={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};$(`\\char`,function(e){var t=e.popToken(),n,r=0;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`"){if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new L("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){if(r=ZU[t.text],r==null||r>=n)throw new L(`Invalid base-`+n+` digit `+t.text);for(var i;(i=ZU[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var QU=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new L(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new L(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new L(`\\renewcommand{`+a+`} when command `+a+` does not yet exist; use \\newcommand`);var s=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text===`[`){for(var c=``,l=e.expandNextToken();l.text!==`]`&&l.text!==`EOF`;)c+=l.text,l=e.expandNextToken();if(!c.match(/^\s*[0-9]+\s*$/))throw new L(`Invalid number of arguments: `+c);s=parseInt(c),i=e.consumeArg().tokens}return o&&r||e.macros.set(a,{tokens:i,numArgs:s}),``};$(`\\newcommand`,e=>QU(e,!1,!0,!1)),$(`\\renewcommand`,e=>QU(e,!0,!1,!1)),$(`\\providecommand`,e=>QU(e,!0,!0,!0)),$(`\\message`,e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join(``)),``}),$(`\\errmessage`,e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join(``)),``}),$(`\\show`,e=>{var t=e.popToken(),n=t.text;return console.log(t,e.macros.get(n),zU[n],Nz.math[n],Nz.text[n]),``}),$(`\\bgroup`,`{`),$(`\\egroup`,`}`),$(`~`,`\\nobreakspace`),$(`\\lq`,"`"),$(`\\rq`,`'`),$(`\\aa`,`\\r a`),$(`\\AA`,`\\r A`),$(`\\textcopyright`,"\\html@mathml{\\textcircled{c}}{\\char`©}"),$(`\\copyright`,`\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}`),$(`\\textregistered`,"\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),$(`ℬ`,`\\mathscr{B}`),$(`ℰ`,`\\mathscr{E}`),$(`ℱ`,`\\mathscr{F}`),$(`ℋ`,`\\mathscr{H}`),$(`ℐ`,`\\mathscr{I}`),$(`ℒ`,`\\mathscr{L}`),$(`ℳ`,`\\mathscr{M}`),$(`ℛ`,`\\mathscr{R}`),$(`ℭ`,`\\mathfrak{C}`),$(`ℌ`,`\\mathfrak{H}`),$(`ℨ`,`\\mathfrak{Z}`),$(`\\Bbbk`,`\\Bbb{k}`),$(`\\llap`,`\\mathllap{\\textrm{#1}}`),$(`\\rlap`,`\\mathrlap{\\textrm{#1}}`),$(`\\clap`,`\\mathclap{\\textrm{#1}}`),$(`\\mathstrut`,`\\vphantom{(}`),$(`\\underbar`,`\\underline{\\text{#1}}`),$(`\\not`,`\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}`),$(`\\neq`,"\\html@mathml{\\mathreLine truncated
please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(lW,t[0])&&!Nz[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Accented Unicode text character "`+t[0]+`" used in math mode`,e),t=lW[t[0]]+t.slice(1));var i=KU.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(Nz[this.mode][t]){this.settings.strict&&this.mode===`math`&&tB.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=Nz[this.mode][t].group,s=qH.range(e);a=VV(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(UR(t.charCodeAt(0))?this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Unicode text character "`+t[0]+`" used in math mode`,e):this.settings.reportNonstrict(`unknownSymbol`,`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),e)),a={type:`textord`,mode:`text`,loc:qH.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!cW[l])throw new L(`Unknown accent ' `+l+`'`,e);var u=cW[l][this.mode]||cW[l].text;if(!u)throw new L(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:qH.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};uW.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var dW=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new uW(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new L(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new JH(`\\df@tag`)])}]}return r},fW=function(e,t,n){t.textContent=``;var r=gW(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),fW=function(){throw new L(`KaTeX doesn't work in quirks mode.`)});var pW=function(e,t){return gW(e,t).toMarkup()},mW=function(e,t){return dW(e,new CR(t))},hW=function(e,t,n){if(n.throwOnError||!(e instanceof L))throw e;var r=X([`katex-error`],[new yz(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},gW=function(e,t){var n=new CR(t);try{return kV(dW(e,n),e,n)}catch(t){return hW(t,e,n)}},_W={version:`0.18.10`,render:fW,renderToString:pW,ParseError:L,SETTINGS_SCHEMA:yR,__parse:mW,__renderToDomTree:gW,__renderToHTMLTree:function(e,t){var n=new CR(t);try{return AV(dW(e,n),e,n)}catch(t){return hW(t,e,n)}},__setFontMetrics:kz,__defineSymbol:B,__defineFunction:Z,__defineMacro:$,__domTree:{Span:hz,Anchor:gz,SymbolNode:yz,SvgNode:bz,PathNode:xz,LineNode:Sz}},vW=Jp.create({name:`blockMath`,group:`block`,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertBlockMath:e=>({commands:t,editor:n})=>{let{latex:r,pos:i}=e;return r?t.insertContentAt(i??n.state.selection.from,{type:this.name,attrs:{latex:r}}):!1},deleteBlockMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateBlockMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r??a.attrs.latex}),!0)}}},parseHTML(){return[{tag:`div[data-type="block-math"]`}]},renderHTML({HTMLAttributes:e}){return[`div`,A(e,{"data-type":`block-math`})]},parseMarkdown:e=>({type:`blockMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>[`$$`,e.attrs?.latex||``,`$$`].join(`
`),markdownTokenizer:{name:`blockMath`,level:`block`,start:e=>e.indexOf(`$$`),tokenize:e=>{let t=e.match(/^\$\$([^$]+)\$\$/);if(!t)return;let[n,r]=t;return{type:`blockMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new lp({find:/^\$\$\$([^$]+)\$\$\$$/,handler:({state:e,range:t,match:n})=>{let[,r]=n,{tr:i}=e,a=e.doc.resolve(t.from),o=this.type.create({latex:r}),s=a.depth>0&&a.parent.isTextblock&&t.from===a.start()&&t.to===a.end()&&a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),this.type)?{from:a.before(),to:a.after()}:t;i.replaceWith(s.from,s.to,o)}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`div`),i=document.createElement(`div`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),i.className=`block-math-inner`,r.dataset.type=`block-math`,r.setAttribute(`data-latex`,t.attrs.latex),r.appendChild(i);function a(){try{_W.render(t.attrs.latex,i,e),r.classList.remove(`block-math-error`)}catch{r.textContent=t.attrs.latex,r.classList.add(`block-math-error`)}}let o=e=>{e.preventDefault(),e.stopPropagation();let r=n();r!=null&&this.options.onClick&&this.options.onClick(t,r)};return this.options.onClick&&r.addEventListener(`click`,o),a(),{dom:r,destroy(){r.removeEventListener(`click`,o)}}}}}),yW=e=>{let t=/\$\$([^$\n]+?)\$\$(?!\$)/g,n=t.exec(e);for(;n!==null;){if(n.index===0||e[n.index-1]!==`$`)return{index:n.index,text:n[0],data:{latex:n[1]}};t.lastIndex=n.index+1,n=t.exec(e)}return null},bW=Jp.create({name:`inlineMath`,group:`inline`,inline:!0,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertInlineMath:e=>({editor:t,tr:n})=>{let r=e.latex,i=e?.pos??t.state.selection.from;return r?(n.replaceWith(i,i,this.type.create({latex:r})),!0):!1},deleteInlineMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateInlineMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r}),!0)}}},parseHTML(){return[{tag:`span[data-type="inline-math"]`}]},renderHTML({HTMLAttributes:e}){return[`span`,A(e,{"data-type":`inline-math`})]},parseMarkdown:e=>({type:`inlineMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>`$${e.attrs?.latex||``}$`,markdownTokenizer:{name:`inlineMath`,level:`inline`,start:e=>e.indexOf(`$`),tokenize:e=>{let t=e.match(/^\$([^$]+)\$(?!\$)/);if(!t)return;let[n,r]=t;return{type:`inlineMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new lp({find:yW,handler:({state:e,range:t,match:n})=>{let r=n.data?.latex;if(typeof r!=`string`)return null;let{tr:i}=e,a=t.from,o=t.to;i.replaceWith(a,o,this.type.create({latex:r}))}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`span`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),r.dataset.type=`inline-math`,r.setAttribute(`data-latex`,t.attrs.latex);function i(){try{_W.render(t.attrs.latex,r,e),r.classList.remove(`inline-math-error`)}catch{r.textContent=t.attrs.latex,r.classList.add(`inline-math-error`)}}let a=e=>{e.preventDefault(),e.stopPropagation();let r=n();r!=null&&this.options.onClick&&this.options.onClick(t,r)};return this.options.onClick&&r.addEventListener(`click`,a),i(),{dom:r,destroy(){r.removeEventListener(`click`,a)}}}}}),xW=Tp.create({name:`Mathematics`,addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[vW.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),bW.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}});function SW(e,t){let n=n=>(r,i)=>{let a=t();if(!a?.isEditable)return;let o=a.view.nodeDOM(i);if(!(o instanceof HTMLElement))return;let s=e.blocks;zL({anchor:o,value:String(r.attrs.latex??``),label:s.latex,multiline:n===`block`,monospace:!0,labels:{done:s.done,cancel:s.cancel,remove:s.remove},onSave:e=>{let t=a.chain().setNodeSelection(i);e.trim()?(n===`inline`?t.updateInlineMath({latex:e,pos:i}):t.updateBlockMath({latex:e,pos:i})).focus().run():(n===`inline`?t.deleteInlineMath({pos:i}):t.deleteBlockMath({pos:i})).focus().run()},onRemove:()=>{let e=a.chain();(n===`inline`?e.deleteInlineMath({pos:i}):e.deleteBlockMath({pos:i})).focus().run()}})};return xW.configure({katexOptions:{throwOnError:!1,strict:!1,trust:!1},inlineOptions:{onClick:n(`inline`)},blockOptions:{onClick:n(`block`)}})}function CW({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r=`@`}){return{editor:e,char:r,pluginKey:new D,command:({editor:e,range:t,props:i})=>{var a,o;let s=Line truncated
Idea --> Draft --> Review --> Published`,kW=null;function AW(e){return kW??=e().then(e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:document.documentElement.classList.contains(`dark`)?`dark`:`neutral`,fontFamily:`inherit`}),e)),kW}var jW=0;async function MW(e,t,n,r){if(e.classList.remove(`dw-mermaid__body--error`),!t.trim())e.textContent=``;else if(r)try{let{svg:n}=await(await AW(r)).render(`dw-mermaid-${++jW}`,t);e.innerHTML=n}catch(t){e.classList.add(`dw-mermaid__body--error`),e.textContent=`${n.blocks.mermaidError} ${t instanceof Error?t.message:String(t)}`}else{let n=document.createElement(`pre`);n.className=`dw-mermaid__source`,n.textContent=t,e.replaceChildren(n)}}var NW=Jp.create({name:`mermaid`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null,load:void 0}},addAttributes(){return{code:{default:``,parseHTML:e=>e.getAttribute(`data-code`)??e.textContent??``,renderHTML:e=>({"data-code":e.code})}}},parseHTML(){return[{tag:`div[data-type='mermaid']`},{tag:`pre.mermaid`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,A(t,{"data-type":`mermaid`}),[`pre`,{},String(e.attrs.code)]]},addCommands(){return{insertMermaid:(e=OW)=>({commands:t})=>t.insertContent({type:this.name,attrs:{code:e}})}},addNodeView(){return({node:e,editor:t,getPos:n})=>{let r=this.options.labels,i=this.options.load,a=document.createElement(`div`);a.className=`dw-mermaid`,a.setAttribute(`data-type`,`mermaid`);let o=document.createElement(`div`);o.className=`dw-mermaid__body`,a.append(o);let s=String(e.attrs.code);return MW(o,s,r,i),a.addEventListener(`click`,()=>{if(!t.isEditable)return;let e=typeof n==`function`?n():void 0;if(e===void 0)return;let c=r.blocks;zL({anchor:a,value:s,label:c.mermaid,multiline:!0,monospace:!0,labels:{done:c.done,cancel:c.cancel,remove:c.remove},onInput:e=>void MW(o,e,r,i),onSave:n=>{t.chain().setNodeSelection(e).updateAttributes(`mermaid`,{code:n}).run(),MW(o,n,r,i)},onRemove:()=>t.chain().setNodeSelection(e).deleteSelection().focus().run(),onCancel:()=>void MW(o,s,r,i)})}),{dom:a,update:e=>e.type.name===`mermaid`&&(e.attrs.code!==s&&(s=String(e.attrs.code),MW(o,s,r,i)),!0),ignoreMutation:()=>!0,stopEvent:()=>!1}}}});function PW(e){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.multiple=!0,n.onchange=()=>t([...n.files??[]]),n.click()})}function FW(e,t,n,r,i=!1,a){let o=(t,n,r,i)=>({id:t,icon:n,keywords:r,label:e.slash[t]?.label??t,description:e.slash[t]?.description??``,run:i}),s=[o(`text`,`text`,[`paragraph`,`p`],(e,t)=>e.chain().focus().deleteRange(t).setParagraph().run()),o(`h1`,`heading`,[`heading`,`title`,`#`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:1}).run()),o(`h2`,`heading`,[`heading`,`subtitle`,`##`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:2}).run()),o(`h3`,`heading`,[`heading`,`###`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:3}).run()),{...o(`otherHeadings`,`heading`,[`other`,`more headings`,`smaller`],()=>{}),children:[4,5,6].map(e=>o(`h${e}`,`heading`,[`heading`,`#`.repeat(e)],(t,n)=>t.chain().focus().deleteRange(n).setHeading({level:e}).run()))},o(`bullet`,`list`,[`list`,`ul`,`-`],(e,t)=>e.chain().focus().deleteRange(t).toggleBulletList().run()),o(`ordered`,`list-ordered`,[`list`,`ol`,`1.`],(e,t)=>e.chain().focus().deleteRange(t).toggleOrderedList().run()),o(`todo`,`todo`,[`task`,`checkbox`,`checklist`,`[]`],(e,t)=>e.chain().focus().deleteRange(t).toggleTaskList().run()),o(`callout`,`callout`,[`note`,`info`,`tip`,`warning`,`aside`,`box`],(e,t)=>e.chain().focus().deleteRange(t).setCallout().run()),o(`table`,`table`,[`grid`,`rows`,`columns`,`spreadsheet`],(e,t)=>e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()),o(`database`,`database`,[`kanban`,`board`,`calendar`,`records`,`tracker`,`notion`],(e,t)=>e.chain().focus().deleteRange(t).insertDatabase().run()),o(`quote`,`quote`,[`blockquote`,`>`],(e,t)=>e.chain().focus().deleteRange(t).toggleBlockquote().run()),o(`code`,`code`,[`codeblock`,"```",`snippet`],(e,t)=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()),o(`toggle`,`chevron-right`,[`details`,`collapse`,`expand`,`fold`,`>`],(e,t)=>e.chain().focus().deleteRange(t).setDetails().run()),o(`divider`,`divider`,[`hr`,`rule`,`line`,`---`],(e,t)=>e.chain().focus().deleteRange(t).setHorizontalRule().run()),o(`toc`,`list`,[`contents`,`outline`,`headings`,`index`],(e,t)=>e.chain().focus().deleteRange(t).insertTableOfContents().run()),o(`math`,`sigma`,[`latex`,`formula`,`equation`,`katex`,`$$`],(e,t)=>e.chain().focus().deleteRange(t).insertBlockMath({latex:`E = mc^2`}).run()),o(`mathInline`,`sigma`,[`latex`,`formula`,`equation`,`$`],(e,t)=>e.chain().focus().deleteRange(t).insertInlineMath({latex:`x^2`}).run()),o(`mermaid`,`diagram`,[`diagram`,`flowchart`,`chart`,`sequence`,`graph`],(e,t)=>e.chain().focus().deleteRange(t).insertMermaid().run()),o(`embed`,`video`,[`video`,`youtube`,`vimeo`,`figma`,`loom`,`iframe`,`map`],(t,r)=>{t.chain().Line truncated
<style rel="stylesheet" crossorigin>/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:"Inter Variable", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--font-serif:"Source Serif 4 Variable", "Source Serif 4", "Iowan Old Style", Georgia, serif;--font-mono:"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--spacing:.25rem;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--radius-xs:4px;--radius-sm:6px;--radius-md:10px;--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-surface:var(--dw-surface);--color-surface-sunken:var(--dw-surface-sunken);--color-surface-raised:var(--dw-surface-raised);--color-surface-hover:var(--dw-surface-hover);--color-line:var(--dw-line);--color-line-strong:var(--dw-line-strong);--color-ink:var(--dw-ink);--color-ink-muted:var(--dw-ink-muted);--color-ink-faint:var(--dw-ink-faint);--color-primary:var(--dw-primary);--color-primary-hover:var(--dw-primary-hover);--color-on-primary:var(--dw-on-primary);--color-accent:var(--dw-accent);--color-accent-soft:var(--dw-accent-soft);--color-selection:var(--dw-selection);--color-focus-ring:var(--dw-focus-ring);--color-success:var(--dw-success);--color-success-soft:var(--dw-success-soft);--color-warning:var(--dw-warning);--color-warning-soft:var(--dw-warning-soft);--color-danger:var(--dw-danger);--color-danger-soft:var(--dw-danger-soft);--color-on-danger:var(--dw-on-danger);--color-info:var(--dw-info);--color-info-soft:var(--dw-info-soft);--color-code-bg:var(--dw-code-bg);--text-ui-xs:12px;--text-ui-xs--line-height:16px;--text-ui-xs--letter-spacing:.01em;--text-ui-xs--font-weight:500;--text-ui-sm:13px;--text-ui-sm--line-height:18px;--text-ui-md:14px;--text-ui-md--line-height:20px;--text-doc-h1:30px;--text-doc-h1--line-height:38px;--text-doc-h2:24px;--text-doc-h2--line-height:32px;--text-doc-h3:18px;--text-doc-h3--line-height:28px;--text-doc-body:16px;--text-doc-body--line-height:27px;--text-code:14px;--text-code--line-height:22px;--shadow-menu:var(--dw-shadow-menu);--shadow-dialog:var(--dw-shadow-dialog);--container-doc:720px;--container-doc-wide:1040px;--spacing-control-sm:28px;--spacing-control-md:34px}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-varLine truncated
/*$vite$:1*/</style>
+33 -1
View File
@@ -19,6 +19,7 @@ import { RowPeek } from "./peek";
import { blocksOf, DbStore, emptyDb, exportDb, readDb, seedDb } from "./store";
import { DatabaseView } from "./view";
import { typeLabel } from "./labels";
import { copyText, OPEN_RECORD, recordHash, type OpenRecordDetail } from "./links";
export interface DatabaseOptions {
labels: EditorLabels | null;
@@ -39,6 +40,13 @@ export interface DatabaseOptions {
rowExtensions?: (fragment: Y.XmlFragment | null) => AnyExtension[];
/** Shows a short message, e.g. "Copied 6 cells". */
notify?: (text: string) => void;
/**
* The full address of a link to a record, from its "#r-…" fragment
* (links.ts). Without it records have no "Copy link".
*/
recordLink?: (hash: string) => string;
/** Called after a link to a record was copied. */
onLinkCopied?: (url: string) => void;
}
declare module "@tiptap/core" {
@@ -100,6 +108,8 @@ export const Database = Node.create<DatabaseOptions>({
me: undefined,
rowExtensions: undefined,
notify: undefined,
recordLink: undefined,
onLinkCopied: undefined,
};
},
@@ -336,9 +346,30 @@ export const Database = Node.create<DatabaseOptions>({
return () => ed.destroy();
};
const link = opts.recordLink;
const copyLink = link
? (rowId: string) => {
const url = link(recordHash(id(), rowId));
void copyText(url).then((ok) => ok && opts.onLinkCopied?.(url));
}
: undefined;
// A link to one of this database's records (links.ts) opens it.
wrap.addEventListener(OPEN_RECORD, (e) => {
const detail = (e as CustomEvent<OpenRecordDetail>).detail;
const db = snapshot();
if (!db.rows.some((r) => r.id === detail.row)) return;
detail.found = true;
wrap.scrollIntoView?.({ block: "start" });
openRow(
detail.row,
db.rows.map((r) => r.id),
);
});
const openRow = (rowId: string, order: string[]) => {
peek?.close();
peek = new RowPeek({ ctx: { ...host(), }, mountBody }, snapshot(), rowId, order, () => (peek = null));
peek = new RowPeek({ ctx: { ...host() }, mountBody, copyLink }, snapshot(), rowId, order, () => (peek = null));
};
const refresh = () => {
@@ -403,6 +434,7 @@ export const Database = Node.create<DatabaseOptions>({
undo: () => editor.commands.undo?.(),
redo: () => editor.commands.redo?.(),
notify: opts.notify,
copyLink,
},
snapshot(),
);
+1
View File
@@ -92,6 +92,7 @@ export const englishDatabaseLabels = {
noDate: "No date ({n})",
noGroupColumn: "Add a select, checkbox or member property to sort cards into columns.",
openRow: "Open",
copyLink: "Copy link to record",
deleteRow: "Delete record",
duplicateRow: "Duplicate record",
insertAbove: "Insert above",
+57
View File
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// Links to one record of a database: the page's address plus
// "#r-<database id>-<record id>". Opening one scrolls to the database and
// opens the record beside the page. Records stay part of their page: the
// link needs the page's own access, nothing more.
import type { Editor } from "@tiptap/core";
const ID = "[A-Za-z0-9]{1,32}";
/** The #fragment of a link to a record. */
export const recordHash = (database: string, row: string) => `#r-${database}-${row}`;
/** The database and record in a link's #fragment, or null. */
export function linkedRecord(hash: string): { database: string; row: string } | null {
const m = new RegExp(`^#?r-(${ID})-(${ID})$`).exec(hash);
return m ? { database: m[1]!, row: m[2]! } : null;
}
/** The event a database block listens for to open one of its records. */
export const OPEN_RECORD = "dw-open-record";
export interface OpenRecordDetail {
row: string;
/** Set by the block when it has the record and opened it. */
found?: boolean;
}
/**
* Opens a record of the page's database. Returns false while the page does
* not show it (yet): the document may still be loading, or it was deleted.
*/
export function openRecord(editor: Editor, database: string, row: string): boolean {
let pos = -1;
editor.state.doc.descendants((n, p) => {
if (pos >= 0) return false;
if (n.type.name === "database" && n.attrs.id === database) pos = p;
return true;
});
if (pos < 0) return false;
const dom = editor.view.nodeDOM(pos);
if (!(dom instanceof HTMLElement)) return false;
const detail: OpenRecordDetail = { row };
dom.dispatchEvent(new CustomEvent(OPEN_RECORD, { detail }));
return !!detail.found;
}
/** Copies text to the clipboard; resolves false when the browser refused. */
export async function copyText(text: string): Promise<boolean> {
try {
await navigator.clipboard.writeText(text);
return true;
} catch {
return false;
}
}
+32
View File
@@ -6,6 +6,7 @@ import { Awareness } from "y-protocols/awareness";
import * as Y from "yjs";
import { docwellExtensions } from "../extensions";
import { defaultView, type Column, type DbData } from "./model";
import { linkedRecord, openRecord, recordHash } from "./links";
import { blocksOf, seedDb } from "./store";
const cols: Column[] = [{ id: "t", name: "Name", type: "title" }];
@@ -43,3 +44,34 @@ it("follows its map when the server replaces it (a restore or import)", () => {
el.querySelector(".dw-db__title-input")!.dispatchEvent(new Event("change"));
expect(blocksOf(doc).get(id)!.get("title")).toBe("Renamed");
});
it("opens a record from a link to it", () => {
const doc = new Y.Doc();
const el = document.createElement("div");
document.body.append(el);
let copied = "";
editor = new Editor({
element: el,
extensions: docwellExtensions({
collab: { provider: { doc, awareness: new Awareness(doc) } as never, user: { name: "A", color: "#888" } },
blockLink: (hash) => `https://docs.test/p/page${hash}`,
onBlockLinkCopied: (url) => (copied = url),
}),
});
editor.commands.insertDatabase(db(["one", "two"]));
let id = "";
editor.state.doc.descendants((n) => {
if (n.type.name === "database") id = String(n.attrs.id);
});
const link = linkedRecord(recordHash(id, "r1"));
expect(link).toEqual({ database: id, row: "r1" });
expect(linkedRecord("#b-abcdef")).toBeNull();
expect(openRecord(editor, id, "nope")).toBe(false);
expect(openRecord(editor, id, "r1")).toBe(true);
const panel = document.querySelector(".dw-db-peek__panel")!;
expect(panel.getAttribute("aria-label")).toBe("two");
expect(panel.querySelector('[aria-label="Copy link to record"]')).not.toBeNull();
void copied;
document.querySelector(".dw-db-peek")!.remove();
});
+3
View File
@@ -14,6 +14,8 @@ export interface PeekHost {
ctx: Omit<DbContext, "db" | "setEditing" | "openRow">;
/** Draws the row's body into el; returns a cleanup. */
mountBody: (el: HTMLElement, row: Row) => (() => void) | null;
/** Copies a link to the record; without it there is no button. */
copyLink?: (row: string) => void;
}
export class RowPeek {
@@ -110,6 +112,7 @@ export class RowPeek {
this.wide = !this.wide;
this.panel.classList.toggle("is-wide", this.wide);
}),
...(this.host.copyLink ? [iconButton("link", l.copyLink, () => this.host.copyLink!(this.rowId))] : []),
iconButton("close", l.close, () => this.close()),
);
+13 -10
View File
@@ -39,6 +39,8 @@ export interface ViewHost extends Omit<DbContext, "db" | "openRow" | "setEditing
redo: () => void;
/** Shows a short message (copied, imported). */
notify?: (text: string) => void;
/** Copies a link to a record; without it the row menu has no "Copy link". */
copyLink?: (row: string) => void;
}
const PAGE = 200;
@@ -823,7 +825,7 @@ export class DatabaseView {
}
if (this.editable) tr.append(h("td", { class: "dw-db-t__add" }));
tr.addEventListener("contextmenu", (e) => {
if (!this.editable) return;
if (!this.editable && !this.host.copyLink) return;
e.preventDefault();
this.rowMenu(tr, r);
});
@@ -832,19 +834,20 @@ export class DatabaseView {
private rowMenu(anchor: HTMLElement, r: Row) {
const l = this.labels;
const store = this.host.store!;
const i = store.rowIndex(r.id);
openBlockMenu(
anchor,
[
{ id: "open", label: l.openRow, icon: "open", run: () => this.openRow(r.id) },
const store = this.host.store;
const copy = this.host.copyLink;
const actions: BlockAction[] = [{ id: "open", label: l.openRow, icon: "open", run: () => this.openRow(r.id) }];
if (copy) actions.push({ id: "link", label: l.copyLink, icon: "link", run: () => copy(r.id) });
if (store) {
const i = store.rowIndex(r.id);
actions.push(
{ id: "above", label: l.insertAbove, icon: "arrow-up", run: () => store.addRow({}, i) },
{ id: "below", label: l.insertBelow, icon: "arrow-down", run: () => store.addRow({}, i + 1) },
{ id: "duplicate", label: l.duplicateRow, icon: "copy", run: () => store.duplicateRow(r.id) },
{ id: "delete", label: l.deleteRow, icon: "trash", danger: true, run: () => store.deleteRows([r.id]) },
],
l.openRow,
);
);
}
openBlockMenu(anchor, actions, l.openRow);
}
/** The (row, column) indexes of the selection's rectangle in the drawn table. */
+3
View File
@@ -175,6 +175,9 @@ export function docwellExtensions(opts: ExtensionOptions = {}): AnyExtension[] {
undoScope: !opts.rowBody,
files: opts.files,
people: opts.mentions,
// Records are linked like blocks: the page address plus a #fragment.
recordLink: opts.blockLink,
onLinkCopied: opts.onBlockLinkCopied,
me: () => {
const id = opts.mentions?.me;
return id ? { id, name: opts.collab?.user.name ?? "" } : null;
+1
View File
@@ -14,5 +14,6 @@ export { linkedPage, pagePath, type PageHost, type PageRef as LinkablePage } fro
export { headingsOf, type Heading } from "./toc";
export { findMatches, type FindMatch } from "./find";
export { blockHash, linkedBlock, scrollToBlock } from "./blocklinks";
export { linkedRecord, openRecord, recordHash } from "./database/links";
export { embedSource, type LinkHost, type LinkPreview } from "./embeds";
export { dateChoices, formatDate, type DateChoice } from "./dates";
+1
View File
@@ -749,6 +749,7 @@
"noDate": "Ohne Datum ({n})",
"noGroupColumn": "Füge eine Auswahl-, Kontrollkästchen- oder Personeneigenschaft hinzu, um Karten in Spalten zu ordnen.",
"openRow": "Öffnen",
"copyLink": "Link zum Eintrag kopieren",
"deleteRow": "Eintrag löschen",
"duplicateRow": "Eintrag duplizieren",
"insertAbove": "Darüber einfügen",
+1
View File
@@ -749,6 +749,7 @@
"noDate": "No date ({n})",
"noGroupColumn": "Add a select, checkbox or member property to sort cards into columns.",
"openRow": "Open",
"copyLink": "Copy link to record",
"deleteRow": "Delete record",
"duplicateRow": "Duplicate record",
"insertAbove": "Insert above",
+1
View File
@@ -749,6 +749,7 @@
"noDate": "Sin fecha ({n})",
"noGroupColumn": "Añade una propiedad de selección, casilla o miembro para ordenar las tarjetas en columnas.",
"openRow": "Abrir",
"copyLink": "Copiar enlace al registro",
"deleteRow": "Eliminar registro",
"duplicateRow": "Duplicar registro",
"insertAbove": "Insertar encima",
+1
View File
@@ -749,6 +749,7 @@
"noDate": "Sans date ({n})",
"noGroupColumn": "Ajoutez une propriété de sélection, de case à cocher ou de membre pour ranger les cartes en colonnes.",
"openRow": "Ouvrir",
"copyLink": "Copier le lien vers l’élément",
"deleteRow": "Supprimer l’élément",
"duplicateRow": "Dupliquer l’élément",
"insertAbove": "Insérer au-dessus",
+1
View File
@@ -749,6 +749,7 @@
"noDate": "Bez daty ({n})",
"noGroupColumn": "Dodaj właściwość wyboru, pola wyboru lub osoby, aby układać karty w kolumny.",
"openRow": "Otwórz",
"copyLink": "Kopiuj link do rekordu",
"deleteRow": "Usuń rekord",
"duplicateRow": "Duplikuj rekord",
"insertAbove": "Wstaw powyżej",
+8 -2
View File
@@ -7,6 +7,8 @@ import {
encodeAnchor,
insertFiles,
linkedBlock,
linkedRecord,
openRecord,
pagePath,
scrollToBlock,
setCommentMarks,
@@ -88,14 +90,18 @@ function blockLinkCopied() {
let scrolledTo = "";
function scrollToHash() {
const editor = editorRef.value?.editor;
const id = main.value ? linkedBlock(route.hash) : "";
// "#b-<id>" scrolls to a block; "#r-<database>-<record>" opens a database record.
const block = main.value ? linkedBlock(route.hash) : "";
const record = main.value ? linkedRecord(route.hash) : null;
const id = block || (record ? route.hash : "");
const key = `${props.id}${id}`;
if (!editor || !id || scrolledTo === key) return;
const go = () => (record ? openRecord(editor, record.database, record.row) : scrollToBlock(editor, block));
// The shared document fills the editor just after it is created, and node
// views draw a moment later: try again as it changes, for a few seconds.
const attempt = () =>
setTimeout(() => {
if (scrolledTo !== key && scrollToBlock(editor, id)) {
if (scrolledTo !== key && go()) {
scrolledTo = key;
stop();
}