diff --git a/Packages/editor-bridge/dist/index.html b/Packages/editor-bridge/dist/index.html index d3cdf6b..7a6596a 100644 --- a/Packages/editor-bridge/dist/index.html +++ b/Packages/editor-bridge/dist/index.html @@ -146,28 +146,28 @@ img.ProseMirror-separator { `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(jk,this.editor.getAttributes(Mk)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new D({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=Tk(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=Gp({find:Nk,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Gp({find:Nk,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Mk)}),joinPredicate:e,editor:this.editor})),[t]}}),Ik=/^\s*(\[([( |x])?\])\s$/,Lk=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,Rk=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},zk=Jp.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,A(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>op(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[IO(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=Lk;let l=e=>{let t=Rk(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Lu(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[Gp({find:Ik,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),Bk=Jp.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,A(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` `):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=rp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=rp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Tp.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(MO.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(ok.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(hk.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Fk.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(zk.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Bk.configure(this.options.taskList)),e}});var Vk=` `,Hk=`\xA0`,Uk=Jp.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,A(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===Vk||n[0].text===Vk||n[0].raw===Hk||n[0].text===Hk)&&r.length===1&&r[0].type===`text`&&(r[0].text===Vk||r[0].text===Hk)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?Vk:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Wk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Gk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Kk=_p.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Hp({find:Wk,type:this.type})]},addPasteRules(){return[Yp({find:Gk,type:this.type})]}}),qk=Jp.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),Jk=_p.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,A(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`${t.renderChildren(e)}`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.toLowerCase().indexOf(``)},tokenize(e,t,n){if(!/^/i.test(e))return;let r=/\\[\s\S]|`+|<\/u>/gi;r.lastIndex=3;let i=r.exec(e);for(;i;){if(i[0].startsWith("`")){let t=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/.exec(e.slice(i.index));t&&(r.lastIndex=i.index+t[0].length)}else if(!i[0].startsWith(`\\`)){let t=e.slice(3,i.index);return t?{type:`underline`,raw:e.slice(0,r.lastIndex),text:t,tokens:n.inlineTokens(t)}:void 0}i=r.exec(e)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Yk=Tp.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(LT.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(MT.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(MO.configure(this.options.bulletList)),this.options.code!==!1&&e.push(VT.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(GT.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(qT.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(Xw.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(Zw.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(JT.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(YT.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(ST.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(XT.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(tE.configure(this.options.italic)),this.options.listItem!==!1&&e.push(ok.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(hk.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(OO.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(Fk.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(Uk.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(Kk.configure(this.options.strike)),this.options.text!==!1&&e.push(qk.configure(this.options.text)),this.options.underline!==!1&&e.push(Jk.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(xT.configure(this.options?.trailingNode)),e}}),Xk=Math.min,Zk=Math.max,Qk=Math.round,$k=Math.floor,eA=e=>({x:e,y:e}),tA={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function nA(e,t,n){return Zk(e,Xk(t,n))}function rA(e,t){return typeof e==`function`?e(t):e}function iA(e){return e.split(`-`)[0]}function aA(e){return e.split(`-`)[1]}function oA(e){return e===`x`?`y`:`x`}function sA(e){return e===`y`?`height`:`width`}function cA(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function lA(e){return oA(cA(e))}function uA(e,t,n){n===void 0&&(n=!1);let r=aA(e),i=lA(e),a=sA(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=yA(o)),[o,yA(o)]}function dA(e){let t=yA(e);return[fA(e),t,fA(t)]}function fA(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var pA=[`left`,`right`],mA=[`right`,`left`],hA=[`top`,`bottom`],gA=[`bottom`,`top`];function _A(e,t,n){switch(e){case`top`:case`bottom`:return n?t?mA:pA:t?pA:mA;case`left`:case`right`:return t?hA:gA;default:return[]}}function vA(e,t,n,r){let i=aA(e),a=_A(iA(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(fA)))),a}function yA(e){let t=iA(e);return tA[t]+e.slice(t.length)}function bA(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function xA(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:bA(e)}function SA(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function CA(e,t,n){let{reference:r,floating:i}=e,a=cA(t),o=lA(t),s=sA(o),c=iA(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=aA(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function wA(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=rA(t,e),p=xA(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=SA(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=SA(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var TA=50,EA=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:wA},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=CA(l,r,c),f=r,p=0,m={};for(let n=0;ne<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===cA(t)||te.every(e=>cA(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:te},reset:{placement:t}};let n=te.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=te.filter(e=>{if(x){let t=cA(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},OA=new Set([`left`,`top`]);async function kA(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=iA(n),s=aA(n),c=cA(n)===`y`,l=OA.has(o)?-1:1,u=a&&c?-1:1,d=rA(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var AA=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await kA(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},jA=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=rA(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=cA(i),p=oA(f),m=u[p],h=u[f],g=(e,t)=>nA(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}};function MA(){return typeof window<`u`}function NA(e){return IA(e)?(e.nodeName||``).toLowerCase():`#document`}function PA(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function FA(e){return((IA(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function IA(e){return MA()?e instanceof Node||e instanceof PA(e).Node:!1}function LA(e){return MA()?e instanceof Element||e instanceof PA(e).Element:!1}function RA(e){return MA()?e instanceof HTMLElement||e instanceof PA(e).HTMLElement:!1}function zA(e){return!MA()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof PA(e).ShadowRoot}function BA(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=ZA(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function VA(e){return/^(table|td|th)$/.test(NA(e))}function HA(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var UA=/transform|translate|scale|rotate|perspective|filter/,WA=/paint|layout|strict|content/,GA=e=>!!e&&e!==`none`,KA;function qA(e){let t=LA(e)?ZA(e):e;return GA(t.transform)||GA(t.translate)||GA(t.scale)||GA(t.rotate)||GA(t.perspective)||!YA()&&(GA(t.backdropFilter)||GA(t.filter))||UA.test(t.willChange||``)||WA.test(t.contain||``)}function JA(e){let t=$A(e);for(;RA(t)&&!XA(t);){if(qA(t))return t;if(HA(t))return null;t=$A(t)}return null}function YA(){return KA??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),KA}function XA(e){return/^(html|body|#document)$/.test(NA(e))}function ZA(e){return PA(e).getComputedStyle(e)}function QA(e){return LA(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $A(e){if(NA(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||zA(e)&&e.host||FA(e);return zA(t)?t.host:t}function ej(e){let t=$A(e);return XA(t)?(e.ownerDocument||e).body:RA(t)&&BA(t)?t:ej(t)}function tj(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=ej(e),i=r===e.ownerDocument?.body,a=PA(r);if(i){let e=nj(a);return t.concat(a,a.visualViewport||[],BA(r)?r:[],e&&n?tj(e):[])}return t.concat(r,tj(r,[],n))}function nj(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function rj(e){let t=ZA(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=RA(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Qk(n)!==a||Qk(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function ij(e){return LA(e)?e:e.contextElement}function aj(e){let t=ij(e);if(!RA(t))return eA(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=rj(t),o=(a?Qk(n.width):n.width)/r,s=(a?Qk(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var oj=eA(0);function sj(e){let t=PA(e);return!YA()||!t.visualViewport?oj:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function cj(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===PA(e)}function lj(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=ij(e),o=eA(1);t&&(r?LA(r)&&(o=aj(r)):o=aj(e));let s=cj(a,n,r)?sj(a):eA(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=PA(a),t=LA(r)?PA(r):r,n=e,i=nj(n);for(;i&&t!==n;){let e=aj(i),t=i.getBoundingClientRect(),r=ZA(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=PA(i),i=nj(n)}}return SA({width:u,height:d,x:c,y:l})}function uj(e,t){let n=QA(e).scrollLeft;return t?t.left+n:lj(FA(e)).left+n}function dj(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-uj(e,n),y:n.top+t.scrollTop}}function fj(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=FA(r),s=t?HA(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=eA(1),u=eA(0),d=RA(r);if((d||!a)&&((NA(r)!==`body`||BA(o))&&(c=QA(r)),d)){let e=lj(r);l=aj(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?dj(o,c):eA(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function pj(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function mj(e){let t=QA(e),n=e.ownerDocument.body,r=Zk(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Zk(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+uj(e),o=-t.scrollTop;return ZA(n).direction===`rtl`&&(a+=Zk(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var hj=25;function gj(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=PA(e),a=FA(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!YA()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(uj(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=hj&&(s-=o)}return{width:s,height:c,x:l,y:u}}function _j(e,t){let n=lj(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=aj(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function vj(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=gj(e,n,t);else if(t===`document`)r=mj(FA(e));else if(LA(t))r=_j(t,n);else{let n=sj(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return SA(r)}function yj(e,t){let n=t.get(e);if(n)return n;let r=tj(e,[],!1).filter(e=>LA(e)&&NA(e)!==`body`),i=null,a=ZA(e).position===`fixed`,o=a?$A(e):e;for(;LA(o)&&!XA(o);){let e=ZA(o),t=qA(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=$A(o)}return t.set(e,r),r}function bj(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?HA(t)?[]:yj(t,this._c):[].concat(n),r],o=vj(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=PA(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function jj(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=ij(e),u=i||a?[...l?tj(l):[],...t?tj(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Aj(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?lj(e):null;c&&g();function g(){let t=lj(e);h&&!kj(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Mj=AA,Nj=jA,Pj=DA,Fj=(e,t,n)=>{let r=new Map,i=n??{},a={...Oj,...i.platform,_c:r};return EA(e,t,{...i,platform:a})};function Ij(e,t){return typeof e==`boolean`?e:t}var Lj=KT.extend({addOptions(){return{...this.parent(),lineNumbers:!1}},addAttributes(){return{...this.parent?.(),lineNumbers:{default:null,parseHTML:e=>{let t=e.getAttribute(`data-line-numbers`);return t===`true`||t!==`false`&&null},renderHTML:e=>typeof e.lineNumbers==`boolean`?{"data-line-numbers":String(e.lineNumbers)}:{}}}},addCommands(){return{...this.parent?.(),toggleCodeLineNumbers:()=>({editor:e,commands:t})=>{if(!e.isActive(this.name))return!1;let n=Ij(e.getAttributes(this.name).lineNumbers,this.options.lineNumbers);return t.updateAttributes(this.name,{lineNumbers:!n})}}},addNodeView(){let e=this.options.lineNumbers,t=this.options.languageClassPrefix??`language-`;return({node:n})=>{let r=document.createElement(`pre`);r.className=`dw-code`;let i=document.createElement(`div`);i.className=`dw-code__gutter`,i.contentEditable=`false`,i.setAttribute(`aria-hidden`,`true`);let a=document.createElement(`code`);r.append(i,a);let o=-1,s=n=>{let s=Ij(n.attrs.lineNumbers,e);r.classList.toggle(`dw-code--numbered`,s),a.className=n.attrs.language?`${t}${String(n.attrs.language)}`:``;let c=s?n.textContent.split(` `).length:0;c!==o&&(o=c,i.textContent=Array.from({length:c},(e,t)=>t+1).join(` -`))};return s(n),{dom:r,contentDOM:a,update:e=>e.type===n.type&&(s(e),!0),ignoreMutation:e=>i.contains(e.target)}}}}),Rj=(e,t)=>e===`application/pdf`||typeof t==`string`&&/\.pdf$/i.test(t);function zj(e,t,n,r){let i=!1,a=null,o=null,s=document.createElement(`div`);return s.className=`dw-pdf__status`,s.textContent=r.blocks.pdfLoading,e.replaceChildren(s),(async()=>{try{let c=await n();if(i)return;o=c.getDocument({url:t});let l=await o.promise;if(i)return;s.remove();let u=Math.max(e.clientWidth-2,200),d=window.devicePixelRatio||1;a=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=t.target;a?.unobserve(e),p(e,Number(e.dataset.page))}},{root:e,rootMargin:`400px 0px`});let f=(await l.getPage(1)).getViewport({scale:1});for(let t=1;t<=l.numPages;t++){let n=document.createElement(`div`);n.className=`dw-pdf__page`,n.dataset.page=String(t),n.style.aspectRatio=`${f.width} / ${f.height}`,n.setAttribute(`aria-label`,r.blocks.pdfPage.replace(`{n}`,String(t))),e.append(n),a.observe(n)}async function p(e,t){let n=await l.getPage(t);if(i)return;let r=u/n.getViewport({scale:1}).width,a=n.getViewport({scale:r*d}),o=document.createElement(`canvas`);o.width=Math.floor(a.width),o.height=Math.floor(a.height),e.style.aspectRatio=`${a.width} / ${a.height}`,e.append(o),await n.render({canvas:o,viewport:a}).promise}}catch{i||(s.textContent=r.blocks.loadFailed)}})(),()=>{i=!0,a?.disconnect(),o?.destroy()}}var Bj={page:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M9 12h6`,`M9 16h6`],"chevron-right":[`M10 6l6 6-6 6`],"chevron-left":[`M14 6l-6 6 6 6`],"chevron-down":[`M6 10l6 6 6-6`],"chevron-up":[`M6 14l6-6 6 6`],plus:[`M12 5v14`,`M5 12h14`],search:[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`],more:[`M6 12h.01`,`M12 12h.01`,`M18 12h.01`],drop:[`M12 4h7v7a7 7 0 1 1-7-7z`],info:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 11v5`,`M12 8h.01`],check:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8 12.5l2.5 2.5L16 9.5`],alert:[`M12 4l9 16H3z`,`M12 10v4`,`M12 17h.01`],error:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M9 9l6 6`,`M15 9l-6 6`],text:[`M5 6h14`,`M12 6v13`],heading:[`M6 5v14`,`M18 5v14`,`M6 12h12`],list:[`M9 6h11`,`M9 12h11`,`M9 18h11`,`M4.5 6h.01`,`M4.5 12h.01`,`M4.5 18h.01`],todo:[`M4 4h7v7H4z`,`M5.5 7.5l1.5 1.5 2.5-2.5`,`M14 7h6`,`M4 14h7v7H4z`,`M14 17h6`],code:[`M9 7l-5 5 5 5`,`M15 7l5 5-5 5`],quote:[`M6 6v12`,`M10 8h9`,`M10 12h9`,`M10 16h6`],image:[`M4 5h16v14H4z`,`M4 16l5-5 4 4 2-2 5 5`,`M15.5 8.5h.01`],table:[`M4 5h16v14H4z`,`M4 10h16`,`M4 15h16`,`M10 5v14`],lock:[`M6 11h12v9H6z`,`M8.5 11V8a3.5 3.5 0 0 1 7 0v3`],trash:[`M4 7h16`,`M10 4h4`,`M6 7l1 13h10l1-13`,`M10 11v6`,`M14 11v6`],settings:[`M4 7h9`,`M17 7h3`,`M15 5v4`,`M4 17h3`,`M11 17h9`,`M9 15v4`],menu:[`M4 7h16`,`M4 12h16`,`M4 17h16`],close:[`M6 6l12 12`,`M18 6L6 18`],open:[`M8 16L16 8`,`M9 8h7v7`],restore:[`M4.5 13a7.5 7.5 0 1 0 2.2-6.3`,`M5 4v4h4`],"sign-out":[`M14 4h5v16h-5`,`M10 8l-4 4 4 4`,`M6 12h9`],sidebar:[`M4 5h16v14H4z`,`M9.5 5v14`],home:[`M4 11l8-7 8 7`,`M6 9.5V20h12V9.5`,`M10 20v-5h4v5`],sun:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M12 3v1.5`,`M12 19.5V21`,`M3 12h1.5`,`M19.5 12H21`,`M5.6 5.6l1.1 1.1`,`M17.3 17.3l1.1 1.1`,`M5.6 18.4l1.1-1.1`,`M17.3 6.7l1.1-1.1`],moon:[`M19.5 14.5A8 8 0 0 1 9.5 4.5a8 8 0 1 0 10 10z`],monitor:[`M4 5h16v11H4z`,`M9 20h6`,`M12 16v4`],selector:[`M8 9l4-4 4 4`,`M8 15l4 4 4-4`],star:[`M12 4l2.5 5.2 5.5.8-4 3.9.9 5.6L12 16.9l-4.9 2.6.9-5.6-4-3.9 5.5-.8z`],clock:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 7v5l3 2`],calendar:[`M5 5h14a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z`,`M4 10h16`,`M8 3v4`,`M16 3v4`],share:[`M12 4v11`,`M8 8l4-4 4 4`,`M6 13v7h12v-7`],link:[`M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1`,`M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1`],upload:[`M12 16V4`,`M7 9l5-5 5 5`,`M4 20h16`],download:[`M12 4v12`,`M7 11l5 5 5-5`,`M4 20h16`],file:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`],paperclip:[`M18 11.5l-6.4 6.4a4.2 4.2 0 0 1-6-6l7-7a2.8 2.8 0 0 1 4 4l-7 7a1.4 1.4 0 0 1-2-2l6.4-6.4`],comment:[`M5 5h14v10H9l-4 4z`],at:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7.1`],bold:[`M7 5h6a3.5 3.5 0 0 1 0 7H7z`,`M7 12h7a3.5 3.5 0 0 1 0 7H7z`],italic:[`M10 5h8`,`M6 19h8`,`M14 5l-4 14`],strike:[`M5 12h14`,`M16 7.5A3.5 3 0 0 0 12.5 5h-1A3.5 3 0 0 0 8 8c0 4 8 3 8 7.5a3.5 3.5 0 0 1-3.5 3.5h-1A3.5 3 0 0 1 8 16.5`],underline:[`M7 4v7a5 5 0 0 0 10 0V4`,`M5 20h14`],"list-ordered":[`M10 6h10`,`M10 12h10`,`M10 18h10`,`M4 5l1.5-1v5`,`M4 15.5a1.5 1.5 0 0 1 3 .5L4 19h3`],divider:[`M4 12h16`],globe:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M3 12h18`,`M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9`,`M12 3C9.5 5.5 8.5 8.5 8.5 12s1 6.5 3.5 9`],bell:[`M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z`,`M10 20a2 2 0 0 0 4 0`],"bell-off":[`M6 16V11a6 6 0 0 1 9.5-4.9`,`M18 11v5l1.5 2H8`,`M10 20a2 2 0 0 0 4 0`,`M4 4l16 16`],smile:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8.5 14a4 4 0 0 0 7 0`,`M9 9.5h.01`,`M15 9.5h.01`],reply:[`M9 7L4 12l5 5`,`M4 12h10a6 6 0 0 1 6 6v1`],pencil:[`M15 5l4 4L8 20H4v-4z`],sigma:[`M18 6V4H6l6 8l-6 8h12v-2`],diagram:[`M4 4h6v5H4z`,`M14 15h6v5h-6z`,`M7 9v4a2 2 0 0 0 2 2h5`],video:[`M4 6h11v12H4z`,`M15 10l5-3v10l-5-3`],archive:[`M4 5h16v4H4z`,`M5 9v10h14V9`,`M10 13h4`],pin:[`M9 4h6`,`M10 4v6l-3 4h10l-3-4V4`,`M12 14v6`],width:[`M3 12h18`,`M7 8l-4 4 4 4`,`M17 8l4 4-4 4`],type:[`M5 7V5h14v2`,`M12 5v14`,`M9 19h6`],server:[`M4 4h16v6H4z`,`M4 14h16v6H4z`,`M8 7h.01`,`M8 17h.01`],users:[`M9 11a3.5 3.5 0 1 0 0-7a3.5 3.5 0 1 0 0 7z`,`M3 20a6 6 0 0 1 12 0`,`M16 4.5a3.5 3.5 0 0 1 0 6.5`,`M18 14a6 6 0 0 1 3 6`],"align-left":[`M4 6h16`,`M4 10h10`,`M4 14h16`,`M4 18h10`],"align-center":[`M4 6h16`,`M7 10h10`,`M4 14h16`,`M7 18h10`],"align-right":[`M4 6h16`,`M10 10h10`,`M4 14h16`,`M10 18h10`],grip:[`M9 6h.01`,`M15 6h.01`,`M9 12h.01`,`M15 12h.01`,`M9 18h.01`,`M15 18h.01`],copy:[`M9 9h11v11H9z`,`M5 15H4V4h11v1`],"arrow-up":[`M12 19V5`,`M6 11l6-6 6 6`],"arrow-down":[`M12 5v14`,`M6 13l6 6 6-6`],callout:[`M4 5h16v14H4z`,`M8 10h.01`,`M11 10h5`,`M8 14h8`],palette:[`M12 3a9 9 0 1 0 0 18c1 0 1.5-.7 1.5-1.5 0-1.2-1-1.5-1-2.5s.8-1.5 2-1.5H17a4 4 0 0 0 4-4c0-4.7-4-8.5-9-8.5z`,`M7.5 11h.01`,`M10 7.5h.01`,`M14.5 7.5h.01`],"page-plus":[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M12 11v6`,`M9 14h6`],tag:[`M4 4h7l9 9-7 7-9-9z`,`M8 8h.01`],grid:[`M4 4h7v7H4z`,`M13 4h7v7h-7z`,`M4 13h7v7H4z`,`M13 13h7v7h-7z`],cards:[`M4 5h16v6H4z`,`M4 15h16v4H4z`],filter:[`M4 5h16l-6 8v6l-4-2v-4z`],layers:[`M12 4l8 4-8 4-8-4z`,`M4 12l8 4 8-4`,`M4 16l8 4 8-4`],journal:[`M6 3h11a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H6z`,`M9 3v18`,`M12 8h3`,`M12 12h3`],sliders:[`M5 6h14`,`M5 12h14`,`M5 18h14`,`M9 4v4`,`M15 10v4`,`M11 16v4`],sort:[`M7 4v16`,`M4 7l3-3 3 3`,`M17 20V4`,`M14 17l3 3 3-3`],database:[`M4 5h16v14H4z`,`M4 10h16`,`M4 15h16`,`M10 10v9`],relation:[`M3 6h7v5H3z`,`M14 13h7v5h-7z`,`M10 8.5h2.5a2 2 0 0 1 2 2V13`],rollup:[`M4 5h16`,`M4 9h16`,`M4 13h16`,`M12 16v5`,`M9 18l3 3 3-3`],edgeless:[`M4 5h16v14H4z`,`M7 15l3-4 3 3 4-5`,`M7 8.5h.01`],cursor:[`M6 4l12 7-5.5 1.5L10 18z`],hand:[`M8 13V6.5a1.5 1.5 0 0 1 3 0V12`,`M11 11V5a1.5 1.5 0 0 1 3 0v6`,`M14 11V6.5a1.5 1.5 0 0 1 3 0V14a6 6 0 0 1-6 6h-1a5 5 0 0 1-4.2-2.3L4.5 14a1.5 1.5 0 0 1 2.5-1.6L8 14`],note:[`M5 4h14v10l-6 6H5z`,`M13 20v-6h6`],shapes:[`M4 13h7v7H4z`,`M16.5 4a3.5 3.5 0 1 0 0 7a3.5 3.5 0 1 0 0-7z`,`M7.5 4l3.5 6H4z`],connector:[`M5 19a2 2 0 1 0 0-4a2 2 0 1 0 0 4z`,`M19 9a2 2 0 1 0 0-4a2 2 0 1 0 0 4z`,`M6.5 15.5C9 10 13 13 17.5 8.5`],pen:[`M4 20l1-4L16 5l3 3L8 19z`,`M14 7l3 3`],eraser:[`M8 20h12`,`M4.5 15.5l9-9 6 6-7.5 7.5H9z`,`M9 11l5 5`],frame:[`M7 3v18`,`M17 3v18`,`M3 7h18`,`M3 17h18`],mindmap:[`M10 10h4v4h-4z`,`M3 4h4v3H3z`,`M17 4h4v3h-4z`,`M3 17h4v3H3z`,`M17 17h4v3h-4z`,`M7 6l3 4`,`M17 6l-3 4`,`M7 18l3-4`,`M17 18l-3-4`],sticker:[`M12 3a9 9 0 1 0 9 9h-5a4 4 0 0 1-4-4z`,`M12 3a9 9 0 0 1 9 9`,`M9 14.5c1.5 1.5 4.5 1.5 6 0`],present:[`M3 4h18`,`M5 4v11h14V4`,`M12 15v3`,`M8 21l4-3 4 3`],"zoom-in":[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`,`M8 11h6`,`M11 8v6`],"zoom-out":[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`,`M8 11h6`],fit:[`M4 9V4h5`,`M15 4h5v5`,`M20 15v5h-5`,`M9 20H4v-5`],"send-back":[`M4 12h9v8H4z`,`M11 4h9v8h-9z`],group:[`M4 4h3`,`M10 4h4`,`M17 4h3v3`,`M20 10v4`,`M20 17v3h-3`,`M14 20h-4`,`M7 20H4v-3`,`M4 14v-4`,`M8 8h8v8H8z`],sparkles:[`M10 4l1.6 4.4L16 10l-4.4 1.6L10 16l-1.6-4.4L4 10l4.4-1.6z`,`M17 14l.8 2.2L20 17l-2.2.8L17 20l-.8-2.2L14 17l2.2-.8z`,`M17 3v4`,`M15 5h4`],send:[`M4 12l16-8-6 16-2-6z`,`M12 14l8-10`],eye:[`M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z`,`M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6z`],"user-plus":[`M15 20v-1a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v1`,`M8.5 4a3.5 3.5 0 1 0 0 7a3.5 3.5 0 1 0 0-7z`,`M19 8v6`,`M16 11h6`]},Vj=`http://www.w3.org/2000/svg`;function Hj(e,t=18){let n=document.createElementNS(Vj,`svg`);for(let[e,r]of Object.entries({width:String(t),height:String(t),viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.75`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`}))n.setAttribute(e,r);for(let t of Bj[e]){let e=document.createElementNS(Vj,`path`);e.setAttribute(`d`,t),n.append(e)}return n}function Uj(e){return()=>{let t=null,n=null,r=null,i=0,a=null,o=()=>a?.items??r?.items??[],s=t=>{let n=o()[t];if(!r||n===void 0)return;let s=e.children?.(n);s?.length?(a={parent:n,items:s},i=0,c()):e.pick(r,n)},c=()=>{if(!t||!r)return;let n=r;if(t.replaceChildren(),e.showQuery){let e=document.createElement(`div`);e.className=`dw-suggest__query`,e.textContent=`/${n.query}`,t.append(e)}if(a){let n=document.createElement(`div`);n.className=`dw-suggest__query`,n.textContent=`‹ ${e.toItem(a.parent).label}`,t.append(n)}let c=o();if(c.length)c.forEach((n,r)=>{let a=e.toItem(n),o=document.createElement(`div`);o.className=r===i?`dw-suggest__item is-active`:`dw-suggest__item`,o.setAttribute(`role`,`option`),o.setAttribute(`aria-selected`,String(r===i)),o.addEventListener(`mousedown`,e=>{e.preventDefault(),s(r)});let c=document.createElement(`span`);c.className=`dw-suggest__icon`,c.append(Hj(a.icon??`text`));let l=document.createElement(`span`);l.className=`dw-suggest__text`;let u=document.createElement(`span`);if(u.className=`dw-suggest__label`,u.textContent=a.label,l.append(u),a.description){let e=document.createElement(`span`);e.className=`dw-suggest__desc`,e.textContent=a.description,l.append(e)}if(o.append(c,l),e.children?.(n)?.length){o.setAttribute(`aria-haspopup`,`listbox`);let e=Hj(`chevron-right`,14);e.classList.add(`dw-suggest__more`),o.append(e)}t.append(o)}),t.querySelector(`.is-active`)?.scrollIntoView({block:`nearest`});else{let n=document.createElement(`div`);n.className=`dw-suggest__empty`,n.setAttribute(`role`,`status`),n.textContent=e.empty,t.append(n)}},l=()=>{let e=r?.clientRect?.();if(!t||!e)return;let i={getBoundingClientRect:()=>r?.clientRect?.()??e};n?.(),n=jj(i,t,()=>{t&&Fj(i,t,{placement:`bottom-start`,strategy:`fixed`,middleware:[Mj(6),Pj(),Nj({padding:8})]}).then(({x:e,y:n})=>{t&&Object.assign(t.style,{left:`${e}px`,top:`${n}px`})})})},u=()=>{n?.(),n=null,t?.remove(),t=null};return{onStart(n){r=n,i=0,a=null,t=document.createElement(`div`),t.className=`dw-suggest`,t.setAttribute(`role`,`listbox`),t.setAttribute(`aria-label`,e.label),document.body.append(t),c(),l()},onUpdate(e){e.items!==r?.items&&(i=0,a=null),r=e,c(),l()},onKeyDown({event:t}){let n=o().length;if(a&&(t.key===`Escape`||t.key===`ArrowLeft`))return a=null,i=0,c(),!0;let r=o()[i];return t.key===`ArrowRight`&&r!==void 0&&e.children?.(r)?.length?(s(i),!0):t.key===`Escape`?(u(),!0):n?t.key===`ArrowDown`||t.key===`ArrowUp`?(i=(i+(t.key===`ArrowDown`?1:-1)+n)%n,c(),!0):t.key===`Enter`||t.key===`Tab`?(s(i),!0):!1:!1},onExit(){r=null,u()}}}}var Wj=[[`text`,`text`,e=>e],[`h1`,`heading`,e=>e.setNode(`heading`,{level:1})],[`h2`,`heading`,e=>e.setNode(`heading`,{level:2})],[`h3`,`heading`,e=>e.setNode(`heading`,{level:3})],[`bullet`,`list`,e=>e.toggleBulletList()],[`ordered`,`list-ordered`,e=>e.toggleOrderedList()],[`todo`,`todo`,e=>e.toggleTaskList()],[`quote`,`quote`,e=>e.setBlockquote()],[`code`,`code`,e=>e.setCodeBlock()],[`callout`,`callout`,e=>e.setCallout()]],Gj=[`paragraph`,`heading`,`codeBlock`,`blockquote`,`bulletList`,`orderedList`,`taskList`,`callout`];function Kj(e){let t={...e};return t.attrs&&`blockId`in t.attrs&&(t.attrs={...t.attrs,blockId:null}),t.content&&=t.content.map(Kj),t}function qj(e,t,n,r){let i=e.state.doc.nodeAt(t);if(!i)return[];let a=n.blockMenu,o=t+i.nodeSize,c=e.state.doc.resolve(t).index(0),l=[];if(Gj.includes(i.type.name)&&l.push({id:`turnInto`,label:a.turnInto,icon:`text`,children:Wj.map(([r,a,c])=>({id:r,icon:a,label:n.slash[r]?.label??r,run:()=>{if(r===`callout`){if(i.type.name===`callout`)return;let n=i.type.name===`blockquote`?i.content:s.from(i),r=e.schema.nodes.callout.create(null,n),a=e.state.tr.replaceWith(t,o,r);e.view.dispatch(a.setSelection(w.near(a.doc.resolve(t+1))).scrollIntoView()),e.commands.focus();return}let n=e.state.doc,a=w.findFrom(n.resolve(t),1,!0)?.from??t+1,l=w.findFrom(n.resolve(o),-1,!0)?.to??o-1;c(e.chain().focus().setTextSelection({from:a,to:l}).clearNodes()).run()}}))}),[`bulletList`,`orderedList`,`taskList`].includes(i.type.name)&&l.push({id:`groupAsDatabase`,label:n.database.groupAsDatabase,icon:`database`,run:()=>{e.chain().focus().setTextSelection(t+2).groupAsDatabase().run()}}),i.type.name===`codeBlock`){let n=!!e.extensionManager.extensions.find(e=>e.name===`codeBlock`)?.options.lineNumbers,r=Ij(i.attrs.lineNumbers,n);l.push({id:`lineNumbers`,label:r?a.hideLineNumbers:a.showLineNumbers,icon:`list-ordered`,run:()=>e.view.dispatch(e.state.tr.setNodeAttribute(t,`lineNumbers`,!r))})}if(i.type.name===`fileAttachment`&&Rj(i.attrs.mime,i.attrs.name)){let n=i.attrs.view===`preview`;l.push({id:`pdfView`,label:n?a.showAsFile:a.showPages,icon:n?`paperclip`:`file`,run:()=>e.view.dispatch(e.state.tr.setNodeAttribute(t,`view`,n?`card`:`preview`))})}return c>0&&l.push({id:`moveUp`,label:a.moveUp,icon:`arrow-up`,run:()=>{let n=e.state.doc.child(c-1),r=e.state.tr.delete(t,o).insert(t-n.nodeSize,i);e.view.dispatch(r.scrollIntoView())}}),c{let n=e.state.doc.child(c+1),r=e.state.tr.delete(t,o).insert(t+n.nodeSize,i);e.view.dispatch(r.scrollIntoView())}}),l.push({id:`duplicate`,label:a.duplicate,icon:`plus`,run:()=>{let t=e.schema.nodeFromJSON(Kj(i.toJSON()));e.view.dispatch(e.state.tr.insert(o,t).scrollIntoView())}},{id:`copy`,label:a.copy,icon:`copy`,run:()=>{e.chain().focus().setNodeSelection(t).run(),document.execCommand(`copy`)}}),r&&l.push({id:`copyLink`,label:n.blocks.copyBlockLink,icon:`link`,run:r}),l.push({id:`delete`,label:a.delete,icon:`trash`,danger:!0,run:()=>{e.view.dispatch(e.state.tr.delete(t,o)),e.commands.focus()}}),l}function Jj(e,t,n,r){let i=document.createElement(`div`);i.className=`dw-suggest dw-block-menu`,i.setAttribute(`role`,`menu`),i.setAttribute(`aria-label`,n);let a=t,o=0,s=[],c=()=>{i.replaceChildren(),a.forEach((e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.className=`dw-suggest__item${t===o?` is-active`:``}${e.danger?` is-danger`:``}`,n.setAttribute(`role`,`menuitem`),n.tabIndex=-1,e.children&&n.setAttribute(`aria-haspopup`,`menu`);let r=document.createElement(`span`);r.className=`dw-suggest__icon`,r.append(Hj(e.icon));let a=document.createElement(`span`);if(a.className=`dw-suggest__label`,a.textContent=e.label,n.append(r,a),e.children){let e=Hj(`chevron-right`,14);e.classList.add(`dw-block-menu__more`),n.append(e)}n.addEventListener(`mousedown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>l(t)),n.addEventListener(`mouseenter`,()=>{o=t;for(let[e,n]of[...i.children].entries())n.classList.toggle(`is-active`,e===t)}),i.append(n)}),i.children[o]?.focus()},l=e=>{let t=a[e];t&&(t.children?(s.push(a),a=t.children,o=0,c()):(m(),t.run?.()))},u=e=>{e.key===`Escape`||e.key===`ArrowLeft`&&s.length?(e.preventDefault(),e.stopPropagation(),s.length?(a=s.pop(),o=0,c()):m()):e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),o=(o+(e.key===`ArrowDown`?1:-1)+a.length)%a.length,c()):(e.key===`Enter`||e.key===` `||e.key===`ArrowRight`)&&(e.preventDefault(),(e.key!==`ArrowRight`||a[o]?.children)&&l(o))},d=t=>{!i.contains(t.target)&&!e.contains(t.target)&&m()};document.body.append(i);let f=jj(e,i,()=>{Fj(e,i,{placement:`bottom-start`,strategy:`fixed`,middleware:[Mj(4),Pj(),Nj({padding:8})]}).then(({x:e,y:t})=>Object.assign(i.style,{left:`${e}px`,top:`${t}px`}))});i.addEventListener(`keydown`,u),document.addEventListener(`mousedown`,d,!0);let p=!1;function m(){p||(p=!0,f(),i.remove(),document.removeEventListener(`mousedown`,d,!0),s=[],r?.())}return c(),m}var Yj=[`paragraph`,`heading`,`blockquote`,`codeBlock`,`bulletList`,`orderedList`,`taskList`,`callout`,`table`,`details`,`image`,`embed`,`linkCard`,`mermaid`,`blockMath`,`drawio`,`excalidraw`,`fileAttachment`],Xj=/^[a-z0-9]{6,16}$/;function Zj(e){return/^#?b-([a-z0-9]{6,16})$/.exec(e)?.[1]??``}var Qj=e=>`#b-${e}`;function $j(){return[...crypto.getRandomValues(new Uint8Array(8))].map(e=>(e%36).toString(36)).join(``)}function eM(e,t){let n=e.state.doc.nodeAt(t);if(!n)return null;let r=n.attrs.blockId;if(r)return r;if(!e.editable||!Yj.includes(n.type.name))return null;let i=$j();return e.dispatch(e.state.tr.setNodeAttribute(t,`blockId`,i)),i}async function tM(e,t,n,r){let i=eM(e,t);if(!i)return!1;let a=n(Qj(i));try{await navigator.clipboard.writeText(a),r?.(a)}catch{window.prompt(``,a)}return!0}function nM(e,t){let n=-1;return e.descendants((e,r)=>n>=0?!1:(e.attrs.blockId===t&&(n=r),!0)),n}function rM(e,t){let n=nM(e.state.doc,t);if(n<0)return!1;let r=e.view.nodeDOM(n);if(!(r instanceof HTMLElement))return!1;r.scrollIntoView({block:`center`});let i=getComputedStyle(r).getPropertyValue(`--color-selection`).trim()||`rgba(47,125,109,.25)`;return r.animate?.([{backgroundColor:i},{backgroundColor:`transparent`}],{duration:2e3,easing:`ease-out`}),!0}var iM=Tp.create({name:`blockLinks`,addOptions(){return{labels:null,link:void 0,onCopied:void 0}},addGlobalAttributes(){return[{types:Yj,attributes:{blockId:{default:null,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-block-id`);return t&&Xj.test(t)?t:null},renderHTML:e=>e.blockId?{"data-block-id":e.blockId}:{}}}}]},addKeyboardShortcuts(){let{link:e,onCopied:t}=this.options;return{"Mod-Shift-c":({editor:n})=>{if(!e)return!1;let r=n.state.selection.$from;if(r.depth<1)return!1;let i=r.before(1),a=n.state.doc.nodeAt(i);return!a||!Yj.includes(a.type.name)||!a.attrs.blockId&&!n.isEditable?!1:(tM(n.view,i,e,t),!0)}}},addProseMirrorPlugins(){let{link:e,onCopied:t}=this.options,n=this.options.labels,r=this.editor;return[new D({key:new Un(`blockLinks`),view:i=>new sM(i,r,n,e,t)})]}}),aM=``,oM=``,sM=class{view;editor;labels;link;onCopied;gutter=document.createElement(`div`);linkButton=document.createElement(`button`);grip=document.createElement(`button`);pos=-1;closeMenu=null;constructor(e,t,n,r,i){this.view=e,this.editor=t,this.labels=n,this.link=r,this.onCopied=i;let a=this.gutter;a.className=`dw-block-gutter`,a.contentEditable=`false`,a.hidden=!0,a.addEventListener(`mouseleave`,this.leave);let o=this.linkButton;o.type=`button`,o.className=`dw-block-handle`,o.setAttribute(`aria-label`,n.blocks.copyBlockLink),o.title=n.blocks.copyBlockLink,o.innerHTML=aM,o.addEventListener(`mousedown`,e=>e.preventDefault()),o.addEventListener(`click`,()=>void this.copy());let s=this.grip;s.type=`button`,s.className=`dw-block-handle dw-block-grip`,s.setAttribute(`aria-label`,n.blockMenu.open),s.setAttribute(`aria-haspopup`,`menu`),s.setAttribute(`aria-expanded`,`false`),s.title=n.blockMenu.open,s.innerHTML=oM,s.draggable=!0,s.addEventListener(`click`,this.openMenu),s.addEventListener(`dragstart`,this.dragStart),s.addEventListener(`dragend`,()=>this.hide()),r&&a.append(o),a.append(s),e.dom.addEventListener(`mousemove`,this.move),e.dom.addEventListener(`mouseleave`,this.leave)}get host(){let e=this.view.dom.parentElement;return e&&this.gutter.parentElement!==e&&(e.classList.add(`dw-block-host`),e.append(this.gutter)),e}hide=()=>{this.closeMenu||(this.gutter.hidden=!0,this.pos=-1)};leave=e=>{let t=e.relatedTarget;t&&(this.gutter.contains(t)||this.view.dom.contains(t))||this.hide()};move=e=>{if(this.closeMenu)return;let t=e.target;for(;t&&t.parentElement!==this.view.dom;)t=t.parentElement;let n=this.host;if(!t||!n)return this.hide();let r;try{r=this.view.posAtDOM(t,0)}catch{return this.hide()}let i=this.view.state.doc.resolve(Math.min(r,this.view.state.doc.content.size)),a=i.depth>=1?i.before(1):r,o=this.view.state.doc.nodeAt(a);if(!o)return this.hide();let s=!!this.link&&Yj.includes(o.type.name)&&(!!o.attrs.blockId||this.view.editable),c=this.view.editable;if(!s&&!c)return this.hide();this.linkButton.hidden=!s,this.grip.hidden=!c,this.pos=a;let l=t.getBoundingClientRect(),u=n.getBoundingClientRect();this.gutter.style.top=`${l.top-u.top+Math.min(l.height/2,14)-11}px`,this.gutter.hidden=!1};openMenu=()=>{if(this.closeMenu){this.closeMenu();return}let e=this.pos;if(e<0||!this.view.editable)return;let t=this.view.state.doc.nodeAt(e),n=!!this.link&&!!t&&Yj.includes(t.type.name),r=qj(this.editor,e,this.labels,n?()=>void this.copy(e):void 0);this.grip.setAttribute(`aria-expanded`,`true`),this.closeMenu=Jj(this.grip,r,this.labels.blockMenu.open,()=>{this.closeMenu=null,this.grip.setAttribute(`aria-expanded`,`false`),this.hide()})};dragStart=e=>{let t=this.pos;if(t<0||!e.dataTransfer)return;this.closeMenu?.();let n=E.create(this.view.state.doc,t);this.view.dispatch(this.view.state.tr.setSelection(n)),e.dataTransfer.effectAllowed=`copyMove`,e.dataTransfer.setData(`text/plain`,n.node.textContent);let r=this.view.nodeDOM(t);r instanceof HTMLElement&&e.dataTransfer.setDragImage(r,0,0),this.view.dragging={slice:n.content(),move:!0}};async copy(e=this.pos){e>=0&&this.link&&await tM(this.view,e,this.link,this.onCopied)}update(){this.pos>=this.view.state.doc.content.size&&this.hide()}destroy(){this.closeMenu?.(),this.gutter.parentElement?.classList.remove(`dw-block-host`),this.gutter.remove(),this.view.dom.removeEventListener(`mousemove`,this.move),this.view.dom.removeEventListener(`mouseleave`,this.leave)}},cM,lM;if(typeof WeakMap<`u`){let e=new WeakMap;cM=t=>e.get(t),lM=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;cM=t=>{for(let n=0;n(t==10&&(t=0),e[t++]=n,e[t++]=r)}var uM=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;er&&(a+=i.attrs.colspan)}}for(let e=0;e1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function pM(e,t,n){e.problems||=[];let r={};for(let i=0;i0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function vM(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function yM(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function bM(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=_M(t.$head)||xM(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function xM(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function SM(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function CM(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function wM(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function TM(e,t,n){let r=e.node(-1),i=uM.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function EM(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function DM(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;ee!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Sn(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(SM(r)&&SM(i)&&wM(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return T.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=uM.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n0||u>0){let e=c.attrs;if(l>0&&(e=EM(e,0,l)),u>0&&(e=EM(e,e.colspan-u,u)),s.leftr.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=uM.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom0&&(n=c.resolve(a+i.map[s.left])),o.bottom0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=uM.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right{t.push(vs.node(n,n+e.nodeSize,{class:`selectedCell`}))}),xs.create(e.doc,t)}function MM({$from:e,$to:t}){if(e.pos==t.pos||e.pos=0&&!(e.after(i+1)=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function NM({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function PM(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof E&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=kM.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=kM.rowSelection(e,e)}else if(!n){let e=uM.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=kM.create(i,t+1,n)}}else r instanceof T&&MM(r)?a=T.create(i,r.from):r instanceof T&&NM(r)&&(a=T.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var FM=new Un(`fix-tables`);function IM(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o{t.type.spec.tableRole==`table`&&(n=RM(e,t,r,n))};return t?t.doc!=e.doc&&IM(t.doc,e.doc,0,r):e.doc.descendants(r),n}function RM(e,t,n,r){let i=uM.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n0?-1:0;OM(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o0&&i0&&t.map[s-1]==c||i0?-1:0;GM(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a0&&i0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i0&&n[a]==n[a-1]||r.right0&&n[i]==n[i-e]||r.bottom0){let e=c+1+l.content.size,t=ZM(l)?c+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new kM(n.doc.resolve(c+r.tableStart))),t(n)}return!0}function eN(e,t){let n=hM(e.schema);return tN(({node:e})=>n[e.type.spec.tableRole])(e,t)}function tN(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof kM){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=vM(r.$from),!i)return!1;a=_M(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=zM(t),u=t.tr;for(let e=0;e{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function rN(e){return function(t,n){if(!yM(t))return!1;if(n){let r=hM(t.schema),i=zM(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}aN(`row`,{useDeprecatedLogic:!0}),aN(`column`,{useDeprecatedLogic:!0});var oN=aN(`cell`,{useDeprecatedLogic:!0});function sN(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function uN(e,t){let n=e.selection;if(!(n instanceof kM))return!1;if(t){let r=e.tr,i=hM(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new p(i,0,0))}),r.docChanged&&t(r)}return!0}function dN(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t=t.length&&t.push(s.empty),n[i]r&&(s=s.type.createChecked(EM(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;ni&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(s.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function hN(e,t,n,r,i,a,o){let c=e.doc.type.schema,l=hM(c),u,d;if(i>t.width)for(let a=0,s=0;at.height){let c=[];for(let e=0,r=(t.height-1)*t.width;e=t.width?!1:n.nodeAt(t.map[r+e]).type==l.header_cell;c.push(i?d||=l.header_cell.createAndFill():u||=l.cell.createAndFill())}let f=l.row.create(null,s.from(c)),p=[];for(let e=t.height;e{if(!i)return!1;let a=n.selection;if(a instanceof kM)return bN(n,r,w.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=EN(i,e,t);if(o==null)return!1;if(e==`horiz`)return bN(n,r,w.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=TM(i,e,t),s;return s=a?w.near(a,1):t<0?w.near(n.doc.resolve(i.before(-1)),-1):w.near(n.doc.resolve(i.after(-1)),1),bN(n,r,s)}}}function SN(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof kM)o=a;else{let r=EN(i,e,t);if(r==null)return!1;o=new kM(n.doc.resolve(r))}let s=TM(o.$headCell,e,t);return s?bN(n,r,new kM(o.$anchorCell,s)):!1}}function CN(e,t){let n=e.state.doc,r=_M(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new kM(r))),!0):!1}function wN(e,t,n){if(!yM(e.state))return!1;let r=dN(n),i=e.state.selection;if(i instanceof kM){r||={width:1,height:1,rows:[s.from(pN(hM(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=uM.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=mN(r,o.right-o.left,o.bottom-o.top),vN(e.state,e.dispatch,a,o,r),!0}if(r){let t=bM(e.state),n=t.start(-1);return vN(e.state,e.dispatch,n,uM.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function TN(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=DN(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof kM)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=_M(e.state.selection.$anchor))!=null&&ON(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=ON(e,n),i=gM.getState(e.state)==null;if(!r||!wM(t,r)){if(i)r=t;else return}let a=new kM(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(gM,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),gM.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(gM,-1))}function o(r){let o=r,s=gM.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(DN(e,o.target)!=n&&(c=ON(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function EN(e,t,n){if(!(e.state.selection instanceof T))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function DN(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function ON(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&_M(e.state.doc.resolve(r))||_M(e.state.doc.resolve(i))}var kN=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),AN(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,AN(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function AN(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;enew r(e,n,t)),new NN(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=jN.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{PN(t,n,e,i)},mouseleave:e=>{FN(e)},mousedown:(e,r)=>{IN(e,r,t,n)}},decorations:e=>{let t=jN.getState(e);if(t&&t.activeHandle>-1)return GN(e,t.activeHandle)},nodeViews:{}}});return a}var NN=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(jN);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return SM(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function PN(e,t,n,r){if(!e.editable)return;let i=jN.getState(e.state);if(i&&!i.dragging){let a=RN(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=zN(e,t,`left`,n):i-t.clientX<=n&&(o=zN(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=uM.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}VN(e,o)}}}function FN(e){if(!e.editable)return;let t=jN.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&VN(e,-1)}function IN(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=jN.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=LN(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(jN,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=jN.getState(e.state);r?.dragging&&(HN(e,r.activeHandle,BN(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(jN,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=jN.getState(e.state);if(i&&i.dragging){let a=BN(i.dragging,t,n);UN(e,i.activeHandle,a,r)}}return UN(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function LN(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;eJN(e),renderHTML:e=>{let t=qN(e.align);return Pf(t)?{style:`text-align: ${t}`}:{}}}}function ZN(e){let t=e.parentElement,n=e.closest(`table`);if(!t||!n)return null;let r=Array.from(t.children).indexOf(e),i=n.querySelectorAll(`colgroup > col`)[r]?.getAttribute(`width`);return i?[parseInt(i,10)]:null}function QN(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):ZN(e)}var $N=/[ \t\r\n\f]+/g;function eP(e){return e.children.length>0?!1:(e.textContent??``).replace($N,``)===``}function tP(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function nP(e,t,n){if(!(n in t))return;let r=t[n];(r===1||r===`1`||r==null)&&delete e[n]}var rP=Jp.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:QN},align:XN()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>eP(e)?{}:!1,getContent:(e,t)=>tP(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){let t=A(this.options.HTMLAttributes,e);return nP(t,e,`colspan`),nP(t,e,`rowspan`),[`td`,t,0]}}),iP=Jp.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:QN},align:XN()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>eP(e)?{}:!1,getContent:(e,t)=>tP(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){let t=A(this.options.HTMLAttributes,e);return nP(t,e,`colspan`),nP(t,e,`rowspan`),[`th`,t,0]}}),aP=Jp.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,A(this.options.HTMLAttributes,e),0]}});function oP(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function sP(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l!==null)for(let e=0,n=0;e{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function fP(e,t,n,r,i){let a=dP(e),o=[],s=[];for(let e=0;e{let{selection:t}=e.state;if(!pP(t))return!1;let n=0;return vu(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)};function hP(e,t){let n=e.mapping.map(t);if(vu(e.selection.$from,e=>e.type.name===`table`)?.pos===n)return;let r=e.doc.nodeAt(n);if(!r)return;let i=n+r.nodeSize-1;e.setSelection(T.near(e.doc.resolve(i),-1))}function gP(e){let t=``,n=0;for(;ne===`|`?`\\|`:e)+e.slice(i,i+r),n=i+r,a=!0;break}i+=o}a||(t+=e.slice(n,n+r),n+=r)}return t}function _P(e){return e.split(` -`).map(e=>!e.includes(`|`)||!e.includes("`")?e:gP(e)).join(` -`)}function vP(e){return(e||``).replaceAll(``,` `).replace(/\s+/g,` `).trim()}function yP(e,t){return t?e.split(t).join(` -`):e}function bP(e){return e.replace(/\\.|\|/g,e=>e===`|`?`\\|`:e)}function xP(e,t,n={}){if(!e||!e.content||e.content.length===0)return``;let r=[];e.content.forEach(e=>{let i=[];e.content&&e.content.forEach(e=>{let r=``;r=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>yP(t.renderChildren(e),n.cellLineSeparator)).join(` -`):yP(e.content?t.renderChildren(e.content):``,n.cellLineSeparator);let a=bP(vP(r.replace(/[ \t]*\r?\n[ \t]*/g,`
`))),o=e.type===`tableHeader`,s=YN(e.attrs);i.push({text:a,isHeader:o,align:s})}),r.push(i)});let i=r.reduce((e,t)=>Math.max(e,t.length),0);if(i===0)return``;let a=Array.from({length:i}).fill(0);r.forEach(e=>{for(let t=0;ta[t]&&(a[t]=n),a[t]<3&&(a[t]=3)}});let o=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),s=r[0],c=s.some(e=>e.isHeader),l=Array.from({length:i}).fill(null);r.forEach(e=>{for(let t=0;tc&&s[t]&&s[t].text||``);return u+=`| ${d.map((e,t)=>o(e,a[t])).join(` | `)} |\n`,u+=`| ${a.map((e,t)=>{let n=Math.max(3,e),r=l[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(c?r.slice(1):r).forEach(e=>{u+=`| ${Array.from({length:i}).fill(0).map((t,n)=>o(e[n]&&e[n].text||``,a[n])).join(` | `)} |\n`}),u}var SP=new Un(`preserveCellSelectionOnContextMenu`);function CP(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function wP(e,t){let n=!1;return e.forEachCell((e,r)=>{t>=r&&t{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=qN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=qN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>xP(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(` +`))};return s(n),{dom:r,contentDOM:a,update:e=>e.type===n.type&&(s(e),!0),ignoreMutation:e=>i.contains(e.target)}}}}),Rj=(e,t)=>e===`application/pdf`||typeof t==`string`&&/\.pdf$/i.test(t);function zj(e,t,n,r){let i=!1,a=null,o=null,s=document.createElement(`div`);return s.className=`dw-pdf__status`,s.textContent=r.blocks.pdfLoading,e.replaceChildren(s),(async()=>{try{let c=await n();if(i)return;o=c.getDocument({url:t});let l=await o.promise;if(i)return;s.remove();let u=Math.max(e.clientWidth-2,200),d=window.devicePixelRatio||1;a=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=t.target;a?.unobserve(e),p(e,Number(e.dataset.page))}},{root:e,rootMargin:`400px 0px`});let f=(await l.getPage(1)).getViewport({scale:1});for(let t=1;t<=l.numPages;t++){let n=document.createElement(`div`);n.className=`dw-pdf__page`,n.dataset.page=String(t),n.style.aspectRatio=`${f.width} / ${f.height}`,n.setAttribute(`aria-label`,r.blocks.pdfPage.replace(`{n}`,String(t))),e.append(n),a.observe(n)}async function p(e,t){let n=await l.getPage(t);if(i)return;let r=u/n.getViewport({scale:1}).width,a=n.getViewport({scale:r*d}),o=document.createElement(`canvas`);o.width=Math.floor(a.width),o.height=Math.floor(a.height),e.style.aspectRatio=`${a.width} / ${a.height}`,e.append(o),await n.render({canvas:o,viewport:a}).promise}}catch{i||(s.textContent=r.blocks.loadFailed)}})(),()=>{i=!0,a?.disconnect(),o?.destroy()}}var Bj={page:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M9 12h6`,`M9 16h6`],"chevron-right":[`M10 6l6 6-6 6`],"chevron-left":[`M14 6l-6 6 6 6`],"chevron-down":[`M6 10l6 6 6-6`],"chevron-up":[`M6 14l6-6 6 6`],plus:[`M12 5v14`,`M5 12h14`],search:[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`],more:[`M6 12h.01`,`M12 12h.01`,`M18 12h.01`],drop:[`M12 4h7v7a7 7 0 1 1-7-7z`],info:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 11v5`,`M12 8h.01`],check:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8 12.5l2.5 2.5L16 9.5`],alert:[`M12 4l9 16H3z`,`M12 10v4`,`M12 17h.01`],error:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M9 9l6 6`,`M15 9l-6 6`],text:[`M5 6h14`,`M12 6v13`],heading:[`M6 5v14`,`M18 5v14`,`M6 12h12`],list:[`M9 6h11`,`M9 12h11`,`M9 18h11`,`M4.5 6h.01`,`M4.5 12h.01`,`M4.5 18h.01`],todo:[`M4 4h7v7H4z`,`M5.5 7.5l1.5 1.5 2.5-2.5`,`M14 7h6`,`M4 14h7v7H4z`,`M14 17h6`],code:[`M9 7l-5 5 5 5`,`M15 7l5 5-5 5`],quote:[`M6 6v12`,`M10 8h9`,`M10 12h9`,`M10 16h6`],image:[`M4 5h16v14H4z`,`M4 16l5-5 4 4 2-2 5 5`,`M15.5 8.5h.01`],table:[`M4 5h16v14H4z`,`M4 10h16`,`M4 15h16`,`M10 5v14`],lock:[`M6 11h12v9H6z`,`M8.5 11V8a3.5 3.5 0 0 1 7 0v3`],trash:[`M4 7h16`,`M10 4h4`,`M6 7l1 13h10l1-13`,`M10 11v6`,`M14 11v6`],settings:[`M4 7h9`,`M17 7h3`,`M15 5v4`,`M4 17h3`,`M11 17h9`,`M9 15v4`],menu:[`M4 7h16`,`M4 12h16`,`M4 17h16`],close:[`M6 6l12 12`,`M18 6L6 18`],open:[`M8 16L16 8`,`M9 8h7v7`],restore:[`M4.5 13a7.5 7.5 0 1 0 2.2-6.3`,`M5 4v4h4`],"sign-out":[`M14 4h5v16h-5`,`M10 8l-4 4 4 4`,`M6 12h9`],sidebar:[`M4 5h16v14H4z`,`M9.5 5v14`],home:[`M4 11l8-7 8 7`,`M6 9.5V20h12V9.5`,`M10 20v-5h4v5`],sun:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M12 3v1.5`,`M12 19.5V21`,`M3 12h1.5`,`M19.5 12H21`,`M5.6 5.6l1.1 1.1`,`M17.3 17.3l1.1 1.1`,`M5.6 18.4l1.1-1.1`,`M17.3 6.7l1.1-1.1`],moon:[`M19.5 14.5A8 8 0 0 1 9.5 4.5a8 8 0 1 0 10 10z`],monitor:[`M4 5h16v11H4z`,`M9 20h6`,`M12 16v4`],selector:[`M8 9l4-4 4 4`,`M8 15l4 4 4-4`],star:[`M12 4l2.5 5.2 5.5.8-4 3.9.9 5.6L12 16.9l-4.9 2.6.9-5.6-4-3.9 5.5-.8z`],clock:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 7v5l3 2`],calendar:[`M5 5h14a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z`,`M4 10h16`,`M8 3v4`,`M16 3v4`],share:[`M12 4v11`,`M8 8l4-4 4 4`,`M6 13v7h12v-7`],link:[`M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1`,`M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1`],upload:[`M12 16V4`,`M7 9l5-5 5 5`,`M4 20h16`],download:[`M12 4v12`,`M7 11l5 5 5-5`,`M4 20h16`],file:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`],paperclip:[`M18 11.5l-6.4 6.4a4.2 4.2 0 0 1-6-6l7-7a2.8 2.8 0 0 1 4 4l-7 7a1.4 1.4 0 0 1-2-2l6.4-6.4`],comment:[`M5 5h14v10H9l-4 4z`],at:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7.1`],bold:[`M7 5h6a3.5 3.5 0 0 1 0 7H7z`,`M7 12h7a3.5 3.5 0 0 1 0 7H7z`],italic:[`M10 5h8`,`M6 19h8`,`M14 5l-4 14`],strike:[`M5 12h14`,`M16 7.5A3.5 3 0 0 0 12.5 5h-1A3.5 3 0 0 0 8 8c0 4 8 3 8 7.5a3.5 3.5 0 0 1-3.5 3.5h-1A3.5 3 0 0 1 8 16.5`],underline:[`M7 4v7a5 5 0 0 0 10 0V4`,`M5 20h14`],"list-ordered":[`M10 6h10`,`M10 12h10`,`M10 18h10`,`M4 5l1.5-1v5`,`M4 15.5a1.5 1.5 0 0 1 3 .5L4 19h3`],divider:[`M4 12h16`],globe:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M3 12h18`,`M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9`,`M12 3C9.5 5.5 8.5 8.5 8.5 12s1 6.5 3.5 9`],bell:[`M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z`,`M10 20a2 2 0 0 0 4 0`],"bell-off":[`M6 16V11a6 6 0 0 1 9.5-4.9`,`M18 11v5l1.5 2H8`,`M10 20a2 2 0 0 0 4 0`,`M4 4l16 16`],smile:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8.5 14a4 4 0 0 0 7 0`,`M9 9.5h.01`,`M15 9.5h.01`],reply:[`M9 7L4 12l5 5`,`M4 12h10a6 6 0 0 1 6 6v1`],pencil:[`M15 5l4 4L8 20H4v-4z`],sigma:[`M18 6V4H6l6 8l-6 8h12v-2`],diagram:[`M4 4h6v5H4z`,`M14 15h6v5h-6z`,`M7 9v4a2 2 0 0 0 2 2h5`],video:[`M4 6h11v12H4z`,`M15 10l5-3v10l-5-3`],archive:[`M4 5h16v4H4z`,`M5 9v10h14V9`,`M10 13h4`],pin:[`M9 4h6`,`M10 4v6l-3 4h10l-3-4V4`,`M12 14v6`],width:[`M3 12h18`,`M7 8l-4 4 4 4`,`M17 8l4 4-4 4`],type:[`M5 7V5h14v2`,`M12 5v14`,`M9 19h6`],server:[`M4 4h16v6H4z`,`M4 14h16v6H4z`,`M8 7h.01`,`M8 17h.01`],users:[`M9 11a3.5 3.5 0 1 0 0-7a3.5 3.5 0 1 0 0 7z`,`M3 20a6 6 0 0 1 12 0`,`M16 4.5a3.5 3.5 0 0 1 0 6.5`,`M18 14a6 6 0 0 1 3 6`],"align-left":[`M4 6h16`,`M4 10h10`,`M4 14h16`,`M4 18h10`],"align-center":[`M4 6h16`,`M7 10h10`,`M4 14h16`,`M7 18h10`],"align-right":[`M4 6h16`,`M10 10h10`,`M4 14h16`,`M10 18h10`],grip:[`M9 6h.01`,`M15 6h.01`,`M9 12h.01`,`M15 12h.01`,`M9 18h.01`,`M15 18h.01`],copy:[`M9 9h11v11H9z`,`M5 15H4V4h11v1`],"arrow-up":[`M12 19V5`,`M6 11l6-6 6 6`],"arrow-down":[`M12 5v14`,`M6 13l6 6 6-6`],callout:[`M4 5h16v14H4z`,`M8 10h.01`,`M11 10h5`,`M8 14h8`],columns:[`M4 5h6v14H4z`,`M14 5h6v14h-6z`],palette:[`M12 3a9 9 0 1 0 0 18c1 0 1.5-.7 1.5-1.5 0-1.2-1-1.5-1-2.5s.8-1.5 2-1.5H17a4 4 0 0 0 4-4c0-4.7-4-8.5-9-8.5z`,`M7.5 11h.01`,`M10 7.5h.01`,`M14.5 7.5h.01`],"page-plus":[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M12 11v6`,`M9 14h6`],tag:[`M4 4h7l9 9-7 7-9-9z`,`M8 8h.01`],grid:[`M4 4h7v7H4z`,`M13 4h7v7h-7z`,`M4 13h7v7H4z`,`M13 13h7v7h-7z`],cards:[`M4 5h16v6H4z`,`M4 15h16v4H4z`],filter:[`M4 5h16l-6 8v6l-4-2v-4z`],layers:[`M12 4l8 4-8 4-8-4z`,`M4 12l8 4 8-4`,`M4 16l8 4 8-4`],journal:[`M6 3h11a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H6z`,`M9 3v18`,`M12 8h3`,`M12 12h3`],sliders:[`M5 6h14`,`M5 12h14`,`M5 18h14`,`M9 4v4`,`M15 10v4`,`M11 16v4`],sort:[`M7 4v16`,`M4 7l3-3 3 3`,`M17 20V4`,`M14 17l3 3 3-3`],database:[`M4 5h16v14H4z`,`M4 10h16`,`M4 15h16`,`M10 10v9`],relation:[`M3 6h7v5H3z`,`M14 13h7v5h-7z`,`M10 8.5h2.5a2 2 0 0 1 2 2V13`],rollup:[`M4 5h16`,`M4 9h16`,`M4 13h16`,`M12 16v5`,`M9 18l3 3 3-3`],edgeless:[`M4 5h16v14H4z`,`M7 15l3-4 3 3 4-5`,`M7 8.5h.01`],cursor:[`M6 4l12 7-5.5 1.5L10 18z`],hand:[`M8 13V6.5a1.5 1.5 0 0 1 3 0V12`,`M11 11V5a1.5 1.5 0 0 1 3 0v6`,`M14 11V6.5a1.5 1.5 0 0 1 3 0V14a6 6 0 0 1-6 6h-1a5 5 0 0 1-4.2-2.3L4.5 14a1.5 1.5 0 0 1 2.5-1.6L8 14`],note:[`M5 4h14v10l-6 6H5z`,`M13 20v-6h6`],shapes:[`M4 13h7v7H4z`,`M16.5 4a3.5 3.5 0 1 0 0 7a3.5 3.5 0 1 0 0-7z`,`M7.5 4l3.5 6H4z`],connector:[`M5 19a2 2 0 1 0 0-4a2 2 0 1 0 0 4z`,`M19 9a2 2 0 1 0 0-4a2 2 0 1 0 0 4z`,`M6.5 15.5C9 10 13 13 17.5 8.5`],pen:[`M4 20l1-4L16 5l3 3L8 19z`,`M14 7l3 3`],eraser:[`M8 20h12`,`M4.5 15.5l9-9 6 6-7.5 7.5H9z`,`M9 11l5 5`],frame:[`M7 3v18`,`M17 3v18`,`M3 7h18`,`M3 17h18`],mindmap:[`M10 10h4v4h-4z`,`M3 4h4v3H3z`,`M17 4h4v3h-4z`,`M3 17h4v3H3z`,`M17 17h4v3h-4z`,`M7 6l3 4`,`M17 6l-3 4`,`M7 18l3-4`,`M17 18l-3-4`],sticker:[`M12 3a9 9 0 1 0 9 9h-5a4 4 0 0 1-4-4z`,`M12 3a9 9 0 0 1 9 9`,`M9 14.5c1.5 1.5 4.5 1.5 6 0`],present:[`M3 4h18`,`M5 4v11h14V4`,`M12 15v3`,`M8 21l4-3 4 3`],"zoom-in":[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`,`M8 11h6`,`M11 8v6`],"zoom-out":[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`,`M8 11h6`],fit:[`M4 9V4h5`,`M15 4h5v5`,`M20 15v5h-5`,`M9 20H4v-5`],"send-back":[`M4 12h9v8H4z`,`M11 4h9v8h-9z`],group:[`M4 4h3`,`M10 4h4`,`M17 4h3v3`,`M20 10v4`,`M20 17v3h-3`,`M14 20h-4`,`M7 20H4v-3`,`M4 14v-4`,`M8 8h8v8H8z`],sparkles:[`M10 4l1.6 4.4L16 10l-4.4 1.6L10 16l-1.6-4.4L4 10l4.4-1.6z`,`M17 14l.8 2.2L20 17l-2.2.8L17 20l-.8-2.2L14 17l2.2-.8z`,`M17 3v4`,`M15 5h4`],send:[`M4 12l16-8-6 16-2-6z`,`M12 14l8-10`],eye:[`M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z`,`M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6z`],"user-plus":[`M15 20v-1a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v1`,`M8.5 4a3.5 3.5 0 1 0 0 7a3.5 3.5 0 1 0 0-7z`,`M19 8v6`,`M16 11h6`]},Vj=`http://www.w3.org/2000/svg`;function Hj(e,t=18){let n=document.createElementNS(Vj,`svg`);for(let[e,r]of Object.entries({width:String(t),height:String(t),viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.75`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`}))n.setAttribute(e,r);for(let t of Bj[e]){let e=document.createElementNS(Vj,`path`);e.setAttribute(`d`,t),n.append(e)}return n}function Uj(e){return()=>{let t=null,n=null,r=null,i=0,a=null,o=()=>a?.items??r?.items??[],s=t=>{let n=o()[t];if(!r||n===void 0)return;let s=e.children?.(n);s?.length?(a={parent:n,items:s},i=0,c()):e.pick(r,n)},c=()=>{if(!t||!r)return;let n=r;if(t.replaceChildren(),e.showQuery){let e=document.createElement(`div`);e.className=`dw-suggest__query`,e.textContent=`/${n.query}`,t.append(e)}if(a){let n=document.createElement(`div`);n.className=`dw-suggest__query`,n.textContent=`‹ ${e.toItem(a.parent).label}`,t.append(n)}let c=o();if(c.length)c.forEach((n,r)=>{let a=e.toItem(n),o=document.createElement(`div`);o.className=r===i?`dw-suggest__item is-active`:`dw-suggest__item`,o.setAttribute(`role`,`option`),o.setAttribute(`aria-selected`,String(r===i)),o.addEventListener(`mousedown`,e=>{e.preventDefault(),s(r)});let c=document.createElement(`span`);c.className=`dw-suggest__icon`,c.append(Hj(a.icon??`text`));let l=document.createElement(`span`);l.className=`dw-suggest__text`;let u=document.createElement(`span`);if(u.className=`dw-suggest__label`,u.textContent=a.label,l.append(u),a.description){let e=document.createElement(`span`);e.className=`dw-suggest__desc`,e.textContent=a.description,l.append(e)}if(o.append(c,l),e.children?.(n)?.length){o.setAttribute(`aria-haspopup`,`listbox`);let e=Hj(`chevron-right`,14);e.classList.add(`dw-suggest__more`),o.append(e)}t.append(o)}),t.querySelector(`.is-active`)?.scrollIntoView({block:`nearest`});else{let n=document.createElement(`div`);n.className=`dw-suggest__empty`,n.setAttribute(`role`,`status`),n.textContent=e.empty,t.append(n)}},l=()=>{let e=r?.clientRect?.();if(!t||!e)return;let i={getBoundingClientRect:()=>r?.clientRect?.()??e};n?.(),n=jj(i,t,()=>{t&&Fj(i,t,{placement:`bottom-start`,strategy:`fixed`,middleware:[Mj(6),Pj(),Nj({padding:8})]}).then(({x:e,y:n})=>{t&&Object.assign(t.style,{left:`${e}px`,top:`${n}px`})})})},u=()=>{n?.(),n=null,t?.remove(),t=null};return{onStart(n){r=n,i=0,a=null,t=document.createElement(`div`),t.className=`dw-suggest`,t.setAttribute(`role`,`listbox`),t.setAttribute(`aria-label`,e.label),document.body.append(t),c(),l()},onUpdate(e){e.items!==r?.items&&(i=0,a=null),r=e,c(),l()},onKeyDown({event:t}){let n=o().length;if(a&&(t.key===`Escape`||t.key===`ArrowLeft`))return a=null,i=0,c(),!0;let r=o()[i];return t.key===`ArrowRight`&&r!==void 0&&e.children?.(r)?.length?(s(i),!0):t.key===`Escape`?(u(),!0):n?t.key===`ArrowDown`||t.key===`ArrowUp`?(i=(i+(t.key===`ArrowDown`?1:-1)+n)%n,c(),!0):t.key===`Enter`||t.key===`Tab`?(s(i),!0):!1:!1},onExit(){r=null,u()}}}}function Wj(e){let t={...e};return t.attrs&&`blockId`in t.attrs&&(t.attrs={...t.attrs,blockId:null}),t.content&&=t.content.map(Wj),t}function Gj(e,t,n,r){let i=e.state.doc.nodeAt(t);if(!i)return[];let a=n.blockMenu,o=t+i.nodeSize,s=e.state.doc.resolve(t).index(0),c=[];if([`bulletList`,`orderedList`,`taskList`].includes(i.type.name)&&c.push({id:`groupAsDatabase`,label:n.database.groupAsDatabase,icon:`database`,run:()=>{e.chain().focus().setTextSelection(t+2).groupAsDatabase().run()}}),i.type.name===`codeBlock`){let n=!!e.extensionManager.extensions.find(e=>e.name===`codeBlock`)?.options.lineNumbers,r=Ij(i.attrs.lineNumbers,n);c.push({id:`lineNumbers`,label:r?a.hideLineNumbers:a.showLineNumbers,icon:`list-ordered`,run:()=>e.view.dispatch(e.state.tr.setNodeAttribute(t,`lineNumbers`,!r))})}if(i.type.name===`fileAttachment`&&Rj(i.attrs.mime,i.attrs.name)){let n=i.attrs.view===`preview`;c.push({id:`pdfView`,label:n?a.showAsFile:a.showPages,icon:n?`paperclip`:`file`,run:()=>e.view.dispatch(e.state.tr.setNodeAttribute(t,`view`,n?`card`:`preview`))})}return s>0&&c.push({id:`moveUp`,label:a.moveUp,icon:`arrow-up`,run:()=>{let n=e.state.doc.child(s-1),r=e.state.tr.delete(t,o).insert(t-n.nodeSize,i);e.view.dispatch(r.scrollIntoView())}}),s{let n=e.state.doc.child(s+1),r=e.state.tr.delete(t,o).insert(t+n.nodeSize,i);e.view.dispatch(r.scrollIntoView())}}),c.push({id:`duplicate`,label:a.duplicate,icon:`plus`,run:()=>{let t=e.schema.nodeFromJSON(Wj(i.toJSON()));e.view.dispatch(e.state.tr.insert(o,t).scrollIntoView())}},{id:`copy`,label:a.copy,icon:`copy`,run:()=>{e.chain().focus().setNodeSelection(t).run(),document.execCommand(`copy`)}}),r&&c.push({id:`copyLink`,label:n.blocks.copyBlockLink,icon:`link`,run:r}),c.push({id:`delete`,label:a.delete,icon:`trash`,danger:!0,run:()=>{e.view.dispatch(e.state.tr.delete(t,o)),e.commands.focus()}}),c}function Kj(e,t,n,r){let i=document.createElement(`div`);i.className=`dw-suggest dw-block-menu`,i.setAttribute(`role`,`menu`),i.setAttribute(`aria-label`,n);let a=t,o=0,s=[],c=()=>{i.replaceChildren(),a.forEach((e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.className=`dw-suggest__item${t===o?` is-active`:``}${e.danger?` is-danger`:``}`,n.setAttribute(`role`,`menuitem`),n.tabIndex=-1,e.children&&n.setAttribute(`aria-haspopup`,`menu`);let r=document.createElement(`span`);r.className=`dw-suggest__icon`,r.append(Hj(e.icon));let a=document.createElement(`span`);if(a.className=`dw-suggest__label`,a.textContent=e.label,n.append(r,a),e.children){let e=Hj(`chevron-right`,14);e.classList.add(`dw-block-menu__more`),n.append(e)}n.addEventListener(`mousedown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>l(t)),n.addEventListener(`mouseenter`,()=>{o=t;for(let[e,n]of[...i.children].entries())n.classList.toggle(`is-active`,e===t)}),i.append(n)}),i.children[o]?.focus()},l=e=>{let t=a[e];t&&(t.children?(s.push(a),a=t.children,o=0,c()):(m(),t.run?.()))},u=e=>{e.key===`Escape`||e.key===`ArrowLeft`&&s.length?(e.preventDefault(),e.stopPropagation(),s.length?(a=s.pop(),o=0,c()):m()):e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),o=(o+(e.key===`ArrowDown`?1:-1)+a.length)%a.length,c()):(e.key===`Enter`||e.key===` `||e.key===`ArrowRight`)&&(e.preventDefault(),(e.key!==`ArrowRight`||a[o]?.children)&&l(o))},d=t=>{!i.contains(t.target)&&!e.contains(t.target)&&m()};document.body.append(i);let f=jj(e,i,()=>{Fj(e,i,{placement:`bottom-start`,strategy:`fixed`,middleware:[Mj(4),Pj(),Nj({padding:8})]}).then(({x:e,y:t})=>Object.assign(i.style,{left:`${e}px`,top:`${t}px`}))});i.addEventListener(`keydown`,u),document.addEventListener(`mousedown`,d,!0);let p=!1;function m(){p||(p=!0,f(),i.remove(),document.removeEventListener(`mousedown`,d,!0),s=[],r?.())}return c(),m}var qj=[`paragraph`,`heading`,`blockquote`,`codeBlock`,`bulletList`,`orderedList`,`taskList`,`callout`,`table`,`details`,`image`,`embed`,`linkCard`,`mermaid`,`blockMath`,`drawio`,`excalidraw`,`fileAttachment`],Jj=/^[a-z0-9]{6,16}$/;function Yj(e){return/^#?b-([a-z0-9]{6,16})$/.exec(e)?.[1]??``}var Xj=e=>`#b-${e}`;function Zj(){return[...crypto.getRandomValues(new Uint8Array(8))].map(e=>(e%36).toString(36)).join(``)}function Qj(e,t){let n=e.state.doc.nodeAt(t);if(!n)return null;let r=n.attrs.blockId;if(r)return r;if(!e.editable||!qj.includes(n.type.name))return null;let i=Zj();return e.dispatch(e.state.tr.setNodeAttribute(t,`blockId`,i)),i}async function $j(e,t,n,r){let i=Qj(e,t);if(!i)return!1;let a=n(Xj(i));try{await navigator.clipboard.writeText(a),r?.(a)}catch{window.prompt(``,a)}return!0}function eM(e,t){let n=-1;return e.descendants((e,r)=>n>=0?!1:(e.attrs.blockId===t&&(n=r),!0)),n}function tM(e,t){let n=eM(e.state.doc,t);if(n<0)return!1;let r=e.view.nodeDOM(n);if(!(r instanceof HTMLElement))return!1;r.scrollIntoView({block:`center`});let i=getComputedStyle(r).getPropertyValue(`--color-selection`).trim()||`rgba(47,125,109,.25)`;return r.animate?.([{backgroundColor:i},{backgroundColor:`transparent`}],{duration:2e3,easing:`ease-out`}),!0}var nM=Tp.create({name:`blockLinks`,addOptions(){return{labels:null,link:void 0,onCopied:void 0}},addGlobalAttributes(){return[{types:qj,attributes:{blockId:{default:null,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-block-id`);return t&&Jj.test(t)?t:null},renderHTML:e=>e.blockId?{"data-block-id":e.blockId}:{}}}}]},addKeyboardShortcuts(){let{link:e,onCopied:t}=this.options;return{"Mod-Shift-c":({editor:n})=>{if(!e)return!1;let r=n.state.selection.$from;if(r.depth<1)return!1;let i=r.before(1),a=n.state.doc.nodeAt(i);return!a||!qj.includes(a.type.name)||!a.attrs.blockId&&!n.isEditable?!1:($j(n.view,i,e,t),!0)}}},addProseMirrorPlugins(){let{link:e,onCopied:t}=this.options,n=this.options.labels,r=this.editor;return[new D({key:new Un(`blockLinks`),view:i=>new oM(i,r,n,e,t),props:{decorations:e=>{let t=aM(e);if(t<0)return null;let n=e.doc.nodeAt(t);return xs.create(e.doc,[vs.node(t,t+n.nodeSize,{class:`dw-block-current`})])}}})]}}),rM=``,iM=``;function aM(e){let{$from:t,$to:n}=e.selection;if(e.selection instanceof E&&t.depth===0)return t.pos;if(t.depth<1||n.depth<1)return-1;let r=t.before(1);return r===n.before(1)?r:-1}var oM=class{view;editor;labels;link;onCopied;gutter=document.createElement(`div`);linkButton=document.createElement(`button`);grip=document.createElement(`button`);pos=-1;closeMenu=null;constructor(e,t,n,r,i){this.view=e,this.editor=t,this.labels=n,this.link=r,this.onCopied=i;let a=this.gutter;a.className=`dw-block-gutter`,a.contentEditable=`false`,a.hidden=!0,a.addEventListener(`mouseleave`,this.leave);let o=this.linkButton;o.type=`button`,o.className=`dw-block-handle`,o.setAttribute(`aria-label`,n.blocks.copyBlockLink),o.title=n.blocks.copyBlockLink,o.innerHTML=rM,o.addEventListener(`mousedown`,e=>e.preventDefault()),o.addEventListener(`click`,()=>void this.copy());let s=this.grip;s.type=`button`,s.className=`dw-block-handle dw-block-grip`,s.setAttribute(`aria-label`,n.blockMenu.open),s.setAttribute(`aria-haspopup`,`menu`),s.setAttribute(`aria-expanded`,`false`),s.title=n.blockMenu.open,s.innerHTML=iM,s.draggable=!0,s.addEventListener(`click`,this.openMenu),s.addEventListener(`dragstart`,this.dragStart),s.addEventListener(`dragend`,()=>this.rest()),r&&a.append(o),a.append(s),e.dom.addEventListener(`mousemove`,this.move),e.dom.addEventListener(`mouseleave`,this.leave),e.dom.addEventListener(`focus`,this.rest),e.dom.addEventListener(`blur`,this.blur)}get host(){let e=this.view.dom.parentElement;return e&&this.gutter.parentElement!==e&&(e.classList.add(`dw-block-host`),e.append(this.gutter)),e}hovering=!1;hide=()=>{this.closeMenu||(this.gutter.hidden=!0,this.pos=-1)};rest=()=>{if(this.closeMenu||this.hovering)return;let e=this.view.hasFocus()?aM(this.view.state):-1;(e<0||!this.place(e))&&this.hide()};blur=e=>{e.relatedTarget instanceof Node&&this.gutter.contains(e.relatedTarget)||this.rest()};leave=e=>{let t=e.relatedTarget;t&&(this.gutter.contains(t)||this.view.dom.contains(t))||(this.hovering=!1,this.rest())};move=e=>{if(this.closeMenu)return;this.hovering=!0;let t=e.target;for(;t&&t.parentElement!==this.view.dom;)t=t.parentElement;if(!t)return;let n;try{n=this.view.posAtDOM(t,0)}catch{return}let r=this.view.state.doc.resolve(Math.min(n,this.view.state.doc.content.size)),i=r.depth>=1?r.before(1):n;this.place(i)||this.hide()};place(e){let t=this.host,n=this.view.state.doc.nodeAt(e),r=n&&this.view.nodeDOM(e);if(!t||!n||!(r instanceof HTMLElement))return!1;let i=!!this.link&&qj.includes(n.type.name)&&(!!n.attrs.blockId||this.view.editable),a=this.view.editable;if(!i&&!a)return!1;this.linkButton.hidden=!i,this.grip.hidden=!a,this.pos=e;let o=r.getBoundingClientRect(),s=t.getBoundingClientRect();return this.gutter.style.top=`${o.top-s.top+o.height/2-11}px`,this.gutter.hidden=!1,!0}openMenu=()=>{if(this.closeMenu){this.closeMenu();return}let e=this.pos;if(e<0||!this.view.editable)return;let t=this.view.state.doc.nodeAt(e),n=!!this.link&&!!t&&qj.includes(t.type.name),r=Gj(this.editor,e,this.labels,n?()=>void this.copy(e):void 0);this.grip.setAttribute(`aria-expanded`,`true`),this.closeMenu=Kj(this.grip,r,this.labels.blockMenu.open,()=>{this.closeMenu=null,this.grip.setAttribute(`aria-expanded`,`false`),this.rest()})};dragStart=e=>{let t=this.pos;if(t<0||!e.dataTransfer)return;this.closeMenu?.();let n=E.create(this.view.state.doc,t);this.view.dispatch(this.view.state.tr.setSelection(n)),e.dataTransfer.effectAllowed=`copyMove`,e.dataTransfer.setData(`text/plain`,n.node.textContent);let r=this.view.nodeDOM(t);r instanceof HTMLElement&&e.dataTransfer.setDragImage(r,0,0),this.view.dragging={slice:n.content(),move:!0}};async copy(e=this.pos){e>=0&&this.link&&await $j(this.view,e,this.link,this.onCopied)}update(){if(!this.closeMenu){if(!this.hovering)return this.rest();(this.pos<0||this.pos>=this.view.state.doc.content.size||!this.place(this.pos))&&this.hide()}}destroy(){this.closeMenu?.(),this.gutter.parentElement?.classList.remove(`dw-block-host`),this.gutter.remove(),this.view.dom.removeEventListener(`mousemove`,this.move),this.view.dom.removeEventListener(`mouseleave`,this.leave),this.view.dom.removeEventListener(`focus`,this.rest),this.view.dom.removeEventListener(`blur`,this.blur)}},sM,cM;if(typeof WeakMap<`u`){let e=new WeakMap;sM=t=>e.get(t),cM=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;sM=t=>{for(let n=0;n(t==10&&(t=0),e[t++]=n,e[t++]=r)}var lM=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;er&&(a+=i.attrs.colspan)}}for(let e=0;e1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function fM(e,t,n){e.problems||=[];let r={};for(let i=0;i0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function _M(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function vM(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function yM(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=gM(t.$head)||bM(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function bM(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function xM(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function SM(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function CM(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function wM(e,t,n){let r=e.node(-1),i=lM.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function TM(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function EM(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;ee!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Sn(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(xM(r)&&xM(i)&&CM(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return T.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=lM.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n0||u>0){let e=c.attrs;if(l>0&&(e=TM(e,0,l)),u>0&&(e=TM(e,e.colspan-u,u)),s.leftr.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=lM.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom0&&(n=c.resolve(a+i.map[s.left])),o.bottom0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=lM.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right{t.push(vs.node(n,n+e.nodeSize,{class:`selectedCell`}))}),xs.create(e.doc,t)}function jM({$from:e,$to:t}){if(e.pos==t.pos||e.pos=0&&!(e.after(i+1)=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function MM({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function NM(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof E&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=OM.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=OM.rowSelection(e,e)}else if(!n){let e=lM.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=OM.create(i,t+1,n)}}else r instanceof T&&jM(r)?a=T.create(i,r.from):r instanceof T&&MM(r)&&(a=T.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var PM=new Un(`fix-tables`);function FM(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o{t.type.spec.tableRole==`table`&&(n=LM(e,t,r,n))};return t?t.doc!=e.doc&&FM(t.doc,e.doc,0,r):e.doc.descendants(r),n}function LM(e,t,n,r){let i=lM.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n0?-1:0;DM(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o0&&i0&&t.map[s-1]==c||i0?-1:0;WM(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a0&&i0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i0&&n[a]==n[a-1]||r.right0&&n[i]==n[i-e]||r.bottom0){let e=c+1+l.content.size,t=XM(l)?c+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new OM(n.doc.resolve(c+r.tableStart))),t(n)}return!0}function $M(e,t){let n=mM(e.schema);return eN(({node:e})=>n[e.type.spec.tableRole])(e,t)}function eN(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof OM){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=_M(r.$from),!i)return!1;a=gM(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=RM(t),u=t.tr;for(let e=0;e{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function nN(e){return function(t,n){if(!vM(t))return!1;if(n){let r=mM(t.schema),i=RM(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}iN(`row`,{useDeprecatedLogic:!0}),iN(`column`,{useDeprecatedLogic:!0});var aN=iN(`cell`,{useDeprecatedLogic:!0});function oN(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function lN(e,t){let n=e.selection;if(!(n instanceof OM))return!1;if(t){let r=e.tr,i=mM(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new p(i,0,0))}),r.docChanged&&t(r)}return!0}function uN(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t=t.length&&t.push(s.empty),n[i]r&&(s=s.type.createChecked(TM(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;ni&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(s.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function mN(e,t,n,r,i,a,o){let c=e.doc.type.schema,l=mM(c),u,d;if(i>t.width)for(let a=0,s=0;at.height){let c=[];for(let e=0,r=(t.height-1)*t.width;e=t.width?!1:n.nodeAt(t.map[r+e]).type==l.header_cell;c.push(i?d||=l.header_cell.createAndFill():u||=l.cell.createAndFill())}let f=l.row.create(null,s.from(c)),p=[];for(let e=t.height;e{if(!i)return!1;let a=n.selection;if(a instanceof OM)return yN(n,r,w.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=TN(i,e,t);if(o==null)return!1;if(e==`horiz`)return yN(n,r,w.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=wM(i,e,t),s;return s=a?w.near(a,1):t<0?w.near(n.doc.resolve(i.before(-1)),-1):w.near(n.doc.resolve(i.after(-1)),1),yN(n,r,s)}}}function xN(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof OM)o=a;else{let r=TN(i,e,t);if(r==null)return!1;o=new OM(n.doc.resolve(r))}let s=wM(o.$headCell,e,t);return s?yN(n,r,new OM(o.$anchorCell,s)):!1}}function SN(e,t){let n=e.state.doc,r=gM(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new OM(r))),!0):!1}function CN(e,t,n){if(!vM(e.state))return!1;let r=uN(n),i=e.state.selection;if(i instanceof OM){r||={width:1,height:1,rows:[s.from(fN(mM(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=lM.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=pN(r,o.right-o.left,o.bottom-o.top),_N(e.state,e.dispatch,a,o,r),!0}if(r){let t=yM(e.state),n=t.start(-1);return _N(e.state,e.dispatch,n,lM.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function wN(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=EN(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof OM)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=gM(e.state.selection.$anchor))!=null&&DN(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=DN(e,n),i=hM.getState(e.state)==null;if(!r||!CM(t,r)){if(i)r=t;else return}let a=new OM(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(hM,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),hM.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(hM,-1))}function o(r){let o=r,s=hM.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(EN(e,o.target)!=n&&(c=DN(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function TN(e,t,n){if(!(e.state.selection instanceof T))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function EN(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function DN(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&gM(e.state.doc.resolve(r))||gM(e.state.doc.resolve(i))}var ON=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),kN(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,kN(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function kN(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;enew r(e,n,t)),new MN(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=AN.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{NN(t,n,e,i)},mouseleave:e=>{PN(e)},mousedown:(e,r)=>{FN(e,r,t,n)}},decorations:e=>{let t=AN.getState(e);if(t&&t.activeHandle>-1)return WN(e,t.activeHandle)},nodeViews:{}}});return a}var MN=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(AN);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return xM(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function NN(e,t,n,r){if(!e.editable)return;let i=AN.getState(e.state);if(i&&!i.dragging){let a=LN(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=RN(e,t,`left`,n):i-t.clientX<=n&&(o=RN(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=lM.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}BN(e,o)}}}function PN(e){if(!e.editable)return;let t=AN.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&BN(e,-1)}function FN(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=AN.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=IN(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(AN,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=AN.getState(e.state);r?.dragging&&(VN(e,r.activeHandle,zN(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(AN,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=AN.getState(e.state);if(i&&i.dragging){let a=zN(i.dragging,t,n);HN(e,i.activeHandle,a,r)}}return HN(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function IN(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;eqN(e),renderHTML:e=>{let t=KN(e.align);return Pf(t)?{style:`text-align: ${t}`}:{}}}}function XN(e){let t=e.parentElement,n=e.closest(`table`);if(!t||!n)return null;let r=Array.from(t.children).indexOf(e),i=n.querySelectorAll(`colgroup > col`)[r]?.getAttribute(`width`);return i?[parseInt(i,10)]:null}function ZN(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):XN(e)}var QN=/[ \t\r\n\f]+/g;function $N(e){return e.children.length>0?!1:(e.textContent??``).replace(QN,``)===``}function eP(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function tP(e,t,n){if(!(n in t))return;let r=t[n];(r===1||r===`1`||r==null)&&delete e[n]}var nP=Jp.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:ZN},align:YN()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>$N(e)?{}:!1,getContent:(e,t)=>eP(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){let t=A(this.options.HTMLAttributes,e);return tP(t,e,`colspan`),tP(t,e,`rowspan`),[`td`,t,0]}}),rP=Jp.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:ZN},align:YN()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>$N(e)?{}:!1,getContent:(e,t)=>eP(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){let t=A(this.options.HTMLAttributes,e);return tP(t,e,`colspan`),tP(t,e,`rowspan`),[`th`,t,0]}}),iP=Jp.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,A(this.options.HTMLAttributes,e),0]}});function aP(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function oP(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l!==null)for(let e=0,n=0;e{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function dP(e,t,n,r,i){let a=uP(e),o=[],s=[];for(let e=0;e{let{selection:t}=e.state;if(!fP(t))return!1;let n=0;return vu(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)};function mP(e,t){let n=e.mapping.map(t);if(vu(e.selection.$from,e=>e.type.name===`table`)?.pos===n)return;let r=e.doc.nodeAt(n);if(!r)return;let i=n+r.nodeSize-1;e.setSelection(T.near(e.doc.resolve(i),-1))}function hP(e){let t=``,n=0;for(;ne===`|`?`\\|`:e)+e.slice(i,i+r),n=i+r,a=!0;break}i+=o}a||(t+=e.slice(n,n+r),n+=r)}return t}function gP(e){return e.split(` +`).map(e=>!e.includes(`|`)||!e.includes("`")?e:hP(e)).join(` +`)}function _P(e){return(e||``).replaceAll(``,` `).replace(/\s+/g,` `).trim()}function vP(e,t){return t?e.split(t).join(` +`):e}function yP(e){return e.replace(/\\.|\|/g,e=>e===`|`?`\\|`:e)}function bP(e,t,n={}){if(!e||!e.content||e.content.length===0)return``;let r=[];e.content.forEach(e=>{let i=[];e.content&&e.content.forEach(e=>{let r=``;r=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>vP(t.renderChildren(e),n.cellLineSeparator)).join(` +`):vP(e.content?t.renderChildren(e.content):``,n.cellLineSeparator);let a=yP(_P(r.replace(/[ \t]*\r?\n[ \t]*/g,`
`))),o=e.type===`tableHeader`,s=JN(e.attrs);i.push({text:a,isHeader:o,align:s})}),r.push(i)});let i=r.reduce((e,t)=>Math.max(e,t.length),0);if(i===0)return``;let a=Array.from({length:i}).fill(0);r.forEach(e=>{for(let t=0;ta[t]&&(a[t]=n),a[t]<3&&(a[t]=3)}});let o=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),s=r[0],c=s.some(e=>e.isHeader),l=Array.from({length:i}).fill(null);r.forEach(e=>{for(let t=0;tc&&s[t]&&s[t].text||``);return u+=`| ${d.map((e,t)=>o(e,a[t])).join(` | `)} |\n`,u+=`| ${a.map((e,t)=>{let n=Math.max(3,e),r=l[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(c?r.slice(1):r).forEach(e=>{u+=`| ${Array.from({length:i}).fill(0).map((t,n)=>o(e[n]&&e[n].text||``,a[n])).join(` | `)} |\n`}),u}var xP=new Un(`preserveCellSelectionOnContextMenu`);function SP(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function CP(e,t){let n=!1;return e.forEachCell((e,r)=>{t>=r&&t{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=KN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=KN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>bP(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(` `);if(t.length<2)return-1;let n=t[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes(`|`)?-1:t[0].includes(`|`)?0:-1},tokenize(e,t,n){let r=e.indexOf(` `),i=r>=0?e.slice(0,r):e,a=i.split(` -`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=_P(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(` +`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=gP(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=fP(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(T.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>VM(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>HM(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return WM(e,t&&(e=>{n&&hP(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>qM(e,t),addRowAfter:()=>({state:e,dispatch:t})=>JM(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return XM(e,t&&(e=>{n&&hP(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>lN(e,t),mergeCells:()=>({state:e,dispatch:t})=>$M(e,t),splitCell:()=>({state:e,dispatch:t})=>eN(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>aN(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>aN(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>oN(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>$M(e,t)?!0:eN(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>nN(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>cN(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>cN(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&LM(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=kM.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:mP,"Mod-Backspace":mP,Delete:mP,"Mod-Delete":mP}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[MN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],KN({allowTableNodeSelection:this.options.allowTableNodeSelection}),TP()]},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}))}}}),DP=Tp.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(EP.configure(this.options.table)),this.options.tableCell!==!1&&e.push(rP.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(iP.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(aP.configure(this.options.tableRow)),e}}),OP=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 kP(){return[Bk.configure({HTMLAttributes:{class:`dw-tasks`}}),zk.configure({nested:!0})]}function AP(){return[DP.configure({table:{resizable:!0,cellMinWidth:60,HTMLAttributes:{class:`dw-table`}}})]}var jP=OP.configure({types:[`heading`,`paragraph`],alignments:[`left`,`center`,`right`]}),MP=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}}),NP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,PP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,FP=_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}){return[`mark`,A(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark(`highlight`,t.parseInline(e.tokens||[])),markdownTokenizer:{name:`highlight`,level:`inline`,start:e=>e.indexOf(`==`),tokenize(e,t,n){let r=/^(==)(?!\s)([^=]*[^=\s])(==)/.exec(e);if(r){let e=r[2].trim(),t=n.inlineTokens(e);return{type:`highlight`,raw:r[0],text:e,tokens:t}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Hp({find:NP,type:this.type})]},addPasteRules(){return[Yp({find:PP,type:this.type})]}}),IP=[`gray`,`red`,`orange`,`yellow`,`green`,`teal`,`blue`,`purple`,`pink`],LP=e=>typeof e==`string`&&IP.includes(e),RP=_p.create({name:`textColor`,addAttributes(){return{color:{default:null,parseHTML:e=>{let t=e.getAttribute(`data-color`);return LP(t)?t:null},renderHTML:e=>e.color?{"data-color":e.color}:{}}}},parseHTML(){return[{tag:`span[data-color]`,getAttrs:e=>LP(e.getAttribute(`data-color`))?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`span`,A(e,{class:`dw-text-color`}),0]},addCommands(){return{setTextColor:e=>({commands:t})=>t.setMark(this.name,{color:e}),unsetTextColor:()=>({commands:e})=>e.unsetMark(this.name)}}}),zP=FP.extend({addOptions(){return{...this.parent(),multicolor:!0}},addAttributes(){return{color:{default:null,parseHTML:e=>{let t=e.getAttribute(`data-color`);return LP(t)?t:null},renderHTML:e=>({"data-color":LP(e.color)?e.color:`yellow`})}}},renderHTML({HTMLAttributes:e}){return[`mark`,A(e,{class:`dw-highlight`}),0]}}),BP=`💡`;function VP(e){let t=e.trim();return t&&[...t].length<=4?t:``}var HP=Jp.create({name:`callout`,group:`block`,content:`block+`,defining:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){return{emoji:{default:BP,parseHTML:e=>VP(e.getAttribute(`data-emoji`)??``)||BP,renderHTML:e=>({"data-emoji":e.emoji})},color:{default:`blue`,parseHTML:e=>{let t=e.getAttribute(`data-color`);return LP(t)?t:`blue`},renderHTML:e=>({"data-color":e.color})}}},parseHTML(){return[{tag:`aside[data-type=callout]`,contentElement:e=>e.querySelector(`:scope > .callout-body`)??e}]},renderHTML({HTMLAttributes:e}){return[`aside`,A(e,{"data-type":`callout`,class:`dw-callout`}),0]},addCommands(){return{setCallout:e=>({commands:t})=>t.wrapIn(this.name,e),unsetCallout:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{$from:t,empty:n}=e.state.selection;if(!n||t.parentOffset>0)return!1;for(let n=t.depth-1;n>0;n--){if(t.node(n).type.name===this.name)return t.index(n)!==0||t.start(n+1)!==t.start()?!1:e.commands.lift(this.name);if(t.index(n)!==0)return!1}return!1}}},addNodeView(){return({node:e,getPos:t,editor:n})=>{let r=this.options.labels,i=document.createElement(`aside`);i.className=`dw-callout`,i.setAttribute(`data-type`,`callout`);let a=document.createElement(`div`);a.className=`dw-callout__side`,a.contentEditable=`false`;let o=document.createElement(`button`);o.type=`button`,o.className=`dw-callout__emoji`;let s=document.createElement(`button`);s.type=`button`,s.className=`dw-callout__color`,a.append(o,s);let c=document.createElement(`div`);c.className=`dw-callout__body`,i.append(a,c);let l=e,u=e=>{let r=t();typeof r==`number`&&n.isEditable&&n.view.dispatch(n.state.tr.setNodeMarkup(r,void 0,{...l.attrs,...e}))};o.addEventListener(`mousedown`,e=>e.preventDefault()),o.addEventListener(`click`,()=>{if(!n.isEditable)return;let e=VP(window.prompt(r?.blocks.calloutEmoji??`Emoji`,l.attrs.emoji)??``);e&&u({emoji:e})}),s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`click`,()=>{let e=IP.indexOf(l.attrs.color);u({color:IP[(e+1)%IP.length]})});let d=()=>{i.setAttribute(`data-color`,String(l.attrs.color)),o.textContent=String(l.attrs.emoji);let e=r?.blocks.calloutEmoji??`Emoji`;o.setAttribute(`aria-label`,e),o.title=e;let t=r?.blocks.calloutColor??`Colour`;s.setAttribute(`aria-label`,t),s.title=t};return d(),{dom:i,contentDOM:c,update:t=>t.type===e.type&&(l=t,d(),!0),stopEvent:e=>a.contains(e.target),ignoreMutation:e=>a.contains(e.target)}}}}),UP=e=>[e.x+e.w/2,e.y+e.h/2];function WP(e){if(!e.length)return null;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.w),i=Math.max(i,a.y+a.h);return{x:t,y:n,w:r-t,h:i-n}}var GP=(e,t)=>({x:e.x-t,y:e.y-t,w:e.w+2*t,h:e.h+2*t}),KP=(e,t)=>e.x<=t.x+t.w&&t.x<=e.x+e.w&&e.y<=t.y+t.h&&t.y<=e.y+e.h,qP=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.w<=e.x+e.w&&t.y+t.h<=e.y+e.h;function JP(e,t){return{x:Math.min(e[0],t[0]),y:Math.min(e[1],t[1]),w:Math.abs(e[0]-t[0]),h:Math.abs(e[1]-t[1])}}function YP([e,t],[n,r],i){if(!i)return[e,t];let a=i*Math.PI/180,o=Math.cos(a),s=Math.sin(a);return[n+(e-n)*o-(t-r)*s,r+(e-n)*s+(t-r)*o]}function XP(e,t){if(!t)return e;let n=UP(e),r=[[e.x,e.y],[e.x+e.w,e.y],[e.x+e.w,e.y+e.h],[e.x,e.y+e.h]].map(e=>YP(e,n,t));return JP([Math.min(...r.map(e=>e[0])),Math.min(...r.map(e=>e[1]))],[Math.max(...r.map(e=>e[0])),Math.max(...r.map(e=>e[1]))])}function ZP([e,t],[n,r],[i,a]){let o=i-n,s=a-r,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c)):0;return Math.hypot(e-(n+l*o),t-(r+l*s))}function QP(e,t){if(t.length===1)return Math.hypot(e[0]-t[0][0],e[1]-t[0][1]);let n=1/0;for(let r=1;re[1]-t[1]),r[0][0]}var eF={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]};function tF(e,t,n=!1){let[r,i]=UP(e),a=t[0]-r,o=t[1]-i;if(!a&&!o)return[r,i];let s=Math.max(e.w/2,.5),c=Math.max(e.h/2,.5),l=n?1/Math.sqrt(a*a/(s*s)+o*o/(c*c)):Math.min(Math.abs(s/(a||1e-9)),Math.abs(c/(o||1e-9)));return[r+a*l,i+o*l]}var nF=e=>[[`top`,[e.x+e.w/2,e.y]],[`right`,[e.x+e.w,e.y+e.h/2]],[`bottom`,[e.x+e.w/2,e.y+e.h]],[`left`,[e.x,e.y+e.h/2]]];function rF(e,t){let n=e=>{if(!e.id)return[e.x??0,e.y??0];let n=t(e.id);return n?e.pos?[n.box.x+n.box.w*e.pos[0],n.box.y+n.box.h*e.pos[1]]:null:[e.x??0,e.y??0]},r=e=>{let n=e.id?t(e.id):null;return n?UP(n.box):[e.x??0,e.y??0]},i=(e,i)=>{let a=n(e),o=e.id?t(e.id):null;if(a)return{at:a,side:o?$P(o.box,a):null};let s=tF(o.box,n(i)??r(i),o.ellipse);return{at:s,side:$P(o.box,s)}};return[i(e.source,e.target),i(e.target,e.source)]}var iF=e=>Math.round(e*100)/100,aF=e=>e.map((e,t)=>`${t?`L`:`M`}${iF(e[0])} ${iF(e[1])}`).join(` `),oF=(e,t)=>Math.atan2(t[1]-e[1],t[0]-e[0]);function sF(e,t,n){let[r,i]=t.at,[a,o]=n.at,s=Math.hypot(a-r,o-i);if(e===`straight`||s<1)return{points:[t.at,n.at],d:aF([t.at,n.at]),mid:[(r+a)/2,(i+o)/2],startAngle:oF(n.at,t.at),endAngle:oF(t.at,n.at)};if(e===`curve`){let e=Math.min(s/2,160),c=t.side?eF[t.side]:cF(t.at,n.at),l=n.side?eF[n.side]:cF(n.at,t.at),u=[r+c[0]*e,i+c[1]*e],d=[a+l[0]*e,o+l[1]*e],f=[];for(let e=0;e<=24;e++)f.push(lF(t.at,u,d,n.at,e/24));return{points:f,d:`M${iF(r)} ${iF(i)} C${iF(u[0])} ${iF(u[1])} ${iF(d[0])} ${iF(d[1])} ${iF(a)} ${iF(o)}`,mid:lF(t.at,u,d,n.at,.5),startAngle:oF(u,t.at),endAngle:oF(d,n.at)}}let c=t.side??(Math.abs(a-r)>Math.abs(o-i)?a>r?`right`:`left`:o>i?`bottom`:`top`),l=n.side??(Math.abs(a-r)>Math.abs(o-i)?a>r?`left`:`right`:o>i?`top`:`bottom`),u=[r+eF[c][0]*24,i+eF[c][1]*24],d=[a+eF[l][0]*24,o+eF[l][1]*24],f=c===`left`||c===`right`,p=l===`left`||l===`right`,m;if(f&&p){let e=(u[0]+d[0])/2;m=[[e,u[1]],[e,d[1]]]}else if(!f&&!p){let e=(u[1]+d[1])/2;m=[[u[0],e],[d[0],e]]}else m=f?[[d[0],u[1]]]:[[u[0],d[1]]];let h=uF([t.at,u,...m,d,n.at]);return{points:h,d:aF(h),mid:dF(h),startAngle:oF(h[1]??n.at,t.at),endAngle:oF(h[h.length-2]??t.at,n.at)}}function cF(e,t){let n=Math.hypot(t[0]-e[0],t[1]-e[1])||1;return[(t[0]-e[0])/n,(t[1]-e[1])/n]}function lF(e,t,n,r,i){let a=1-i,o=a*a*a,s=3*a*a*i,c=3*a*i*i,l=i*i*i;return[o*e[0]+s*t[0]+c*n[0]+l*r[0],o*e[1]+s*t[1]+c*n[1]+l*r[1]]}function uF(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&Math.abs(e[0]-n[0])<.01&&Math.abs(e[1]-n[1])<.01)continue;let r=t[t.length-2];if(r&&e){let i=(e[0]-r[0])*(n[1]-r[1])-(e[1]-r[1])*(n[0]-r[0]);Math.abs(i)<.01&&t.pop()}t.push(n)}return t}function dF(e){let t=0;for(let n=1;n=n&&a>0)return[r[0]+(i[0]-r[0])*n/a,r[1]+(i[1]-r[1])*n/a];n-=a}return e[0]??[0,0]}function fF(e,t,n){let r=e=>[e.x,e.x+e.w/2,e.x+e.w],i=e=>[e.y,e.y+e.h/2,e.y+e.h],a={dx:0,ox:null,vx:0},o={dy:0,oy:null,vy:0},s=n+1,c=n+1;for(let n of t){for(let t of r(e))for(let e of r(n)){let r=Math.abs(e-t);rtypeof e==`string`&&gF.includes(e),vF=[`rect`,`roundrect`,`ellipse`,`diamond`,`triangle`],yF=[`straight`,`curve`,`elbow`],bF=[`none`,`arrow`,`triangle`,`circle`,`diamond`],xF=[`right`,`left`,`radial`],SF=`page`,CF=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t,wF=(e,t=``)=>typeof e==`string`?e:t,TF=e=>e===!0,EF=(e,t)=>_F(e)?e:t,DF=(e,t,n)=>typeof e==`string`&&t.includes(e)?e:n;function OF(e){if(!e||typeof e!=`object`)return{x:0,y:0};let t=e,n={};return typeof t.id==`string`&&t.id&&(n.id=t.id),Array.isArray(t.pos)&&t.pos.length===2&&(n.pos=[CF(t.pos[0],.5),CF(t.pos[1],.5)]),n.id||(n.x=CF(t.x,0),n.y=CF(t.y,0)),n}function kF(e){let t={};if(!e||typeof e!=`object`)return t;for(let[n,r]of Object.entries(e)){if(!r||typeof r!=`object`)continue;let e=r;t[n]={text:wF(e.text),parent:wF(e.parent),pos:CF(e.pos,0)}}return t}function AF(e){let t={id:wF(e.id),index:CF(e.index,0),x:CF(e.x,0),y:CF(e.y,0),w:Math.max(0,CF(e.w,0)),h:Math.max(0,CF(e.h,0)),rotate:CF(e.rotate,0),group:wF(e.group)};switch(e.type){case`shape`:return{...t,type:`shape`,shape:DF(e.shape,vF,`rect`),stroke:EF(e.stroke,`ink`),fill:EF(e.fill,`none`),strokeWidth:CF(e.strokeWidth,2),strokeStyle:DF(e.strokeStyle,[`solid`,`dash`,`none`],`solid`),rough:TF(e.rough),text:wF(e.text),textColor:EF(e.textColor,`ink`),fontSize:CF(e.fontSize,18)};case`text`:return{...t,type:`text`,text:wF(e.text),color:EF(e.color,`ink`),fontSize:CF(e.fontSize,24),font:DF(e.font,[``,`serif`,`mono`],``),align:DF(e.align,[`left`,`center`,`right`],`left`),bold:TF(e.bold)};case`connector`:return{...t,type:`connector`,source:OF(e.source),target:OF(e.target),mode:DF(e.mode,yF,`curve`),stroke:EF(e.stroke,`ink`),strokeWidth:CF(e.strokeWidth,2),strokeStyle:DF(e.strokeStyle,[`solid`,`dash`,`none`],`solid`),startArrow:DF(e.startArrow,bF,`none`),endArrow:DF(e.endArrow,bF,`arrow`),label:wF(e.label),rough:TF(e.rough)};case`brush`:return{...t,type:`brush`,points:Array.isArray(e.points)?e.points.filter(e=>Array.isArray(e)&&e.length>=2).map(e=>[CF(e[0],0),CF(e[1],0),CF(e[2],.5)]):[],color:EF(e.color,`ink`),size:CF(e.size,4)};case`note`:return{...t,type:`note`,page:TF(e.page),background:EF(e.background,`paper`)};case`frame`:return{...t,type:`frame`,title:wF(e.title),background:EF(e.background,`none`)};case`image`:return{...t,type:`image`,src:wF(e.src),alt:wF(e.alt)};case`embed`:return{...t,type:`embed`,url:wF(e.url)};case`group`:return{...t,type:`group`,title:wF(e.title)};case`mindmap`:return{...t,type:`mindmap`,layout:DF(e.layout,xF,`right`),color:EF(e.color,`blue`),nodes:kF(e.nodes)};default:return null}}var jF=e=>![`connector`,`group`,`mindmap`].includes(e.type),MF=e=>[`shape`,`text`,`image`,`brush`].includes(e.type),NF=e=>![`connector`,`brush`,`group`].includes(e.type),PF=0;function FF(){return PF=(PF+1)%1296,Date.now().toString(36).slice(-6)+PF.toString(36).padStart(2,`0`)+Math.random().toString(36).slice(2,8)}var IF={shape:{shape:`rect`,stroke:`blue`,fill:`blue`,strokeWidth:2,strokeStyle:`solid`,rough:!1,textColor:`ink`},connector:{mode:`curve`,stroke:`gray`,strokeWidth:2,strokeStyle:`solid`,startArrow:`none`,endArrow:`arrow`},brush:{color:`ink`,size:4},text:{color:`ink`,fontSize:24,font:``},note:{background:`yellow`},frame:{background:`none`},mindmap:{layout:`right`,color:`blue`}};function LF(e){let t=structuredClone(IF);if(!e||typeof e!=`object`)return t;for(let n of Object.keys(t)){let r=e[n];if(!r||typeof r!=`object`)continue;let i=AF({...t[n],...r,type:n===`note`?`note`:n});if(i)for(let e of Object.keys(t[n])){let a=r[e];a!==void 0&&i[e]===a&&(t[n][e]=a)}}return t}var RF=[`👍`,`⭐`,`❤️`,`✅`,`❌`,`💡`,`❓`,`❗`,`🎉`,`🔥`,`📌`,`🚀`,`👀`,`🎯`,`⚠️`,`🙂`];function zF(e){return[{id:FF(),type:`text`,text:e,fontSize:64,x:0,y:0,w:0,h:0}]}var BF=[`kanban`,`swot`,`flow`,`brainstorm`,`retro`],VF=e=>[{type:`paragraph`,content:e?[{type:`text`,text:e}]:[]}],HF=(e,t,n,r,i,a=`none`)=>({id:FF(),type:`frame`,title:e,x:t,y:n,w:r,h:i,background:a}),UF=(e,t,n,r,i=220)=>({id:FF(),type:`note`,background:r,x:t,y:n,w:i,h:90,body:VF(e)}),WF=(e,t,n,r,i,a,o)=>({id:FF(),type:`shape`,shape:e,text:t,x:n,y:r,w:i,h:a,stroke:o,fill:o,strokeWidth:2}),GF=(e,t,n=`elbow`)=>({id:FF(),type:`connector`,source:{id:e},target:{id:t},mode:n,stroke:`gray`,endArrow:`arrow`});function KF(e,t){switch(e){case`kanban`:return[[t.todo,`gray`],[t.doing,`blue`],[t.done,`green`]].flatMap(([e,t],n)=>[HF(e,n*300,0,280,520),UF(``,n*300+30,50,t),UF(``,n*300+30,170,t)]);case`swot`:return[[t.strengths,`green`],[t.weaknesses,`red`],[t.opportunities,`blue`],[t.threats,`orange`]].flatMap(([e,t],n)=>[WF(`roundrect`,e,n%2*380,Math.floor(n/2)*300,360,280,t)]);case`flow`:{let e=WF(`ellipse`,t.start,0,0,180,70,`green`),n=WF(`rect`,t.step,0,140,180,80,`blue`),r=WF(`diamond`,t.decision,-10,290,200,120,`orange`),i=WF(`rect`,t.step,280,310,180,80,`blue`),a=WF(`ellipse`,t.end,0,480,180,70,`red`);return[e,n,r,i,a,GF(e.id,n.id),GF(n.id,r.id),GF(r.id,i.id),GF(r.id,a.id)]}case`brainstorm`:{let e=FF(),n={[e]:{text:t.centralIdea,parent:``,pos:0}};for(let r=0;r<4;r++)n[FF()]={text:`${t.idea} ${r+1}`,parent:e,pos:r};return[{id:FF(),type:`mindmap`,layout:`radial`,color:`purple`,x:0,y:0,nodes:n}]}case`retro`:return[[t.wentWell,`green`],[t.toImprove,`orange`],[t.actions,`blue`]].flatMap(([e,t],n)=>[HF(e,n*300,0,280,420),UF(``,n*300+30,50,t)])}}var qF;function JF(){if(qF!==void 0)return qF;try{qF=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):null}catch{qF=null}return qF}var YF=`"Inter Variable", Inter, ui-sans-serif, system-ui, sans-serif`,XF=`"Source Serif 4 Variable", "Source Serif 4", Georgia, serif`,ZF=`"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, monospace`;function QF(e){return e===`serif`?XF:e===`mono`?ZF:YF}function $F(e,t,n=YF,r=400){let i=JF();return i?(i.font=`${r} ${t}px ${n}`,i.measureText(e).width):e.length*t*.56}function eI(e,t,n,r=YF,i=400){let a=[];for(let o of e.split(` -`)){if(!o){a.push(``);continue}let e=``;for(let s of o.split(/(\s+)/)){let o=e+s;if(!e||$F(o,t,r,i)<=n)e=o;else for(a.push(e.trimEnd()),e=s.trimStart();e&&$F(e,t,r,i)>n;){let o=e.length-1;for(;o>1&&$F(e.slice(0,o),t,r,i)>n;)o--;a.push(e.slice(0,o)),e=e.slice(o)}}a.push(e)}return a}function tI(e,t){let n=t===0?18:15,r=t===0?600:400,i=eI(e||` `,n,260,YF,r),a=Math.max(...i.map(e=>$F(e,n,YF,r)),t===0?60:40);return{w:Math.ceil(a)+(t===0?32:24),h:i.length*Math.round(n*1.4)+(t===0?20:14)}}var nI=56,rI=14;function iI(e){let t=Object.entries(e).filter(([,t])=>!t.parent||!e[t.parent]);return t.sort((e,t)=>e[1].pos-t[1].pos||(e[0]n.parent===t&&e!==t).sort((e,t)=>e[1].pos-t[1].pos||(e[0]e)}function oI(e,t,n){let r=iI(e),i=new Map,a=[];if(!r)return{root:``,boxes:i,edges:a,bounds:{x:0,y:0,w:0,h:0}};let o=new Map,s=new Set,c=(t,r)=>{if(!(s.has(t)||r>50)){s.add(t),o.set(t,n(e[t].text,r));for(let n of aI(e,t))c(n,r+1)}};c(r,0);let l=t=>aI(e,t).filter(e=>o.has(e)),u=new Map,d=e=>{let t=u.get(e);if(t!==void 0)return t;let n=l(e),r=n.reduce((e,t)=>e+d(t),0)+rI*Math.max(0,n.length-1),i=Math.max(o.get(e).h,r);return u.set(e,i),i},f=(e,t,n,r,a,s)=>{let c=o.get(e),u=a===1?t:t-c.w;i.set(e,{id:e,x:u,y:n-c.h/2,w:c.w,h:c.h,depth:r,dir:a,parent:s}),p(e,l(e),a===1?u+c.w+nI:u-nI,n,r+1,a)},p=(e,t,n,r,i,a)=>{let o=r-(t.reduce((e,t)=>e+d(t),0)+rI*Math.max(0,t.length-1))/2;for(let r of t){let t=d(r);f(r,n,o+t/2,i,a,e),o+=t+rI}},m=o.get(r);i.set(r,{id:r,x:0,y:0,w:m.w,h:m.h,depth:0,dir:1,parent:``});let h=m.h/2,g=l(r);if(t===`right`)p(r,g,m.w+nI,h,1,1);else if(t===`left`)p(r,g,-56,h,1,-1);else{let e=Math.ceil(g.length/2);p(r,g.slice(0,e),m.w+nI,h,1,1),p(r,g.slice(e),-56,h,1,-1)}for(let e of i.values()){if(!e.parent)continue;let t=i.get(e.parent),n=e.dir===1?[t.x+t.w,t.y+t.h/2]:[t.x,t.y+t.h/2],r=e.dir===1?[e.x,e.y+e.h/2]:[e.x+e.w,e.y+e.h/2];a.push({from:n,to:r,child:e.id})}let _=1/0,v=1/0,y=-1/0,b=-1/0;for(let e of i.values())_=Math.min(_,e.x),v=Math.min(v,e.y),y=Math.max(y,e.x+e.w),b=Math.max(b,e.y+e.h);return{root:r,boxes:i,edges:a,bounds:{x:_,y:v,w:y-_,h:b-v}}}function sI(e,t,n,r){let i=e.boxes.get(n);if(!i)return null;if(r===`ArrowUp`||r===`ArrowDown`){let a=i.parent?aI(t,i.parent).filter(t=>e.boxes.get(t)?.dir===i.dir):[];return a[a.indexOf(n)+(r===`ArrowUp`?-1:1)]??null}let a=r===`ArrowRight`?1:-1;return i.parent?a===i.dir?aI(t,n)[0]??null:i.parent:aI(t,n).find(t=>e.boxes.get(t)?.dir===a)??null}function cI(e,t){let n=(e[0]+t[0])/2;return`M${e[0]} ${e[1]} C${n} ${e[1]} ${n} ${t[1]} ${t[0]} ${t[1]}`}function lI(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}function uI(e){return[-e[0],-e[1]]}function dI(e,t){return[e[0]+t[0],e[1]+t[1]]}function fI(e,t){return[e[0]-t[0],e[1]-t[1]]}function pI(e,t){return[e[0]*t,e[1]*t]}function mI(e,t){return[e[0]/t,e[1]/t]}function hI(e){return[e[1],-e[0]]}function gI(e,t){return e[0]*t[0]+e[1]*t[1]}function _I(e,t){return e[0]===t[0]&&e[1]===t[1]}function vI(e){return Math.hypot(e[0],e[1])}function yI(e){return e[0]*e[0]+e[1]*e[1]}function bI(e,t){return yI(fI(e,t))}function xI(e){return mI(e,vI(e))}function SI(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function CI(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function wI(e,t,n){return dI(e,pI(fI(t,e),n))}function TI(e,t,n){return dI(e,pI(t,n))}var{min:EI,PI:DI}=Math,OI=.275,kI=DI+1e-4;function AI(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=s.taper===!1?0:s.taper===!0?Math.max(n,m):s.taper,g=c.taper===!1?0:c.taper===!0?Math.max(n,m):c.taper,_=(n*r)**2,v=[],y=[],b=e.slice(0,10).reduce((e,t)=>{let r=t.pressure;if(a){let i=EI(1,t.distance/n);r=EI(1,e+(EI(1,1-i)-e)*(i*OI))}return(e+r)/2},e[0].pressure),x=lI(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,ee=e[0].point,te=ee,ne=ee,re=te,ie=!1;for(let t=0;t_)&&(v.push(ne),ee=ne),re=dI(s,ue),(t<=1||bI(te,re)>_)&&(y.push(re),te=re),b=r,C=c}let ae=e[0].point.slice(0,2),oe=e.length>1?e[e.length-1].point.slice(0,2):dI(e[0].point,[1,1]),se=[],ce=[];if(e.length===1){if(!(h||g)||l){let e=TI(ae,xI(hI(fI(ae,oe))),-(S||x)),t=[];for(let n=1/13,r=n;r<=1;r+=n)t.push(CI(e,ae,kI*2*r));return t}}else{if(!(h||g&&e.length===1)){if(u)for(let e=1/13,t=e;t<=1;t+=e){let e=CI(y[0],ae,kI*t);se.push(e)}else{let e=fI(v[0],y[0]),t=pI(e,.5),n=pI(e,.51);se.push(fI(ae,t),fI(ae,n),dI(ae,n),dI(ae,t))}}let t=hI(uI(e[e.length-1].vector));if(g||h&&e.length===1)ce.push(oe);else if(f){let e=TI(oe,t,x);for(let t=1/29,n=t;n<1;n+=t)ce.push(CI(e,oe,kI*3*n))}else ce.push(dI(oe,pI(t,x)),dI(oe,pI(t,x*.99)),fI(oe,pI(t,x*.99)),fI(oe,pI(t,x)))}return v.concat(ce,y.reverse(),se)}function jI(e,t={}){let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let a=.15+(1-n)*.85,o=Array.isArray(e[0])?e:e.map(({x:e,y:t,pressure:n=.5})=>[e,t,n]);if(o.length===2){let e=o[1];o=o.slice(0,-1);for(let t=1;t<5;t++)o.push(wI(o[0],e,t/4))}o.length===1&&(o=[...o,[...dI(o[0],[1,1]),...o[0].slice(2)]]);let s=[{point:[o[0][0],o[0][1]],pressure:o[0][2]>=0?o[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],c=!1,l=0,u=s[0],d=o.length-1;for(let e=1;e=0?o[e][2]:.5,vector:xI(fI(u.point,t)),distance:n,runningLength:l},s.push(u)}return s[0].vector=s[1]?.vector||[0,0],s}function MI(e,t={}){return AI(jI(e,t),t)}function NI(e,t,n){if(e&&e.length){let[r,i]=t,a=Math.PI/180*n,o=Math.cos(a),s=Math.sin(a);for(let t of e){let[e,n]=t;t[0]=(e-r)*o-(n-i)*s+r,t[1]=(e-r)*s+(n-i)*o+i}}}function PI(e,t){return e[0]===t[0]&&e[1]===t[1]}function FI(e,t,n,r=1){let i=n,a=Math.max(t,.1),o=e[0]&&e[0][0]&&typeof e[0][0]==`number`?[e]:e,s=[0,0];if(i)for(let e of o)NI(e,s,i);let c=function(e,t,n){let r=[];for(let t of e){let e=[...t];PI(e[0],e[e.length-1])||e.push([e[0][0],e[0][1]]),e.length>2&&r.push(e)}let i=[];t=Math.max(t,.1);let a=[];for(let e of r)for(let t=0;te.ymint.ymin?1:e.xt.x?1:e.ymax===t.ymax?0:(e.ymax-t.ymax)/Math.abs(e.ymax-t.ymax))),!a.length)return i;let o=[],s=a[0].ymin,c=0;for(;o.length||a.length;){if(a.length){let e=-1;for(let t=0;ts);t++)e=t;a.splice(0,e+1).forEach((e=>{o.push({s,edge:e})}))}if(o=o.filter((e=>!(e.edge.ymax<=s))),o.sort(((e,t)=>e.edge.x===t.edge.x?0:(e.edge.x-t.edge.x)/Math.abs(e.edge.x-t.edge.x))),(n!==1||c%t==0)&&o.length>1)for(let e=0;e=o.length)break;let n=o[e].edge,r=o[t].edge;i.push([[Math.round(n.x),s],[Math.round(r.x),s]])}s+=n,o.forEach((e=>{e.edge.x=e.edge.x+n*e.edge.islope})),c++}return i}(o,a,r);if(i){for(let e of o)NI(e,s,-i);(function(e,t,n){let r=[];e.forEach((e=>r.push(...e))),NI(r,t,n)})(c,s,-i)}return c}function II(e,t){let n=t.hachureAngle+90,r=t.hachureGap;r<0&&(r=4*t.strokeWidth),r=Math.max(r,.1);let i=1;return t.roughness>=1&&(t.randomizer?.next()||Math.random())>.7&&(i=r),FI(e,r,n,i||1)}var LI=class{constructor(e){this.helper=e}fillPolygons(e,t){return this._fillPolygons(e,t)}_fillPolygons(e,t){let n=II(e,t);return{type:`fillSketch`,ops:this.renderLines(n,t)}}renderLines(e,t){let n=[];for(let r of e)n.push(...this.helper.doubleLineOps(r[0][0],r[0][1],r[1][0],r[1][1],t));return n}};function RI(e){let t=e[0],n=e[1];return Math.sqrt((t[0]-n[0])**2+(t[1]-n[1])**2)}var zI=class extends LI{fillPolygons(e,t){let n=t.hachureGap;n<0&&(n=4*t.strokeWidth),n=Math.max(n,.1);let r=II(e,Object.assign({},t,{hachureGap:n})),i=Math.PI/180*t.hachureAngle,a=[],o=.5*n*Math.cos(i),s=.5*n*Math.sin(i);for(let[e,t]of r)RI([e,t])&&a.push([[e[0]-o,e[1]+s],[...t]],[[e[0]+o,e[1]-s],[...t]]);return{type:`fillSketch`,ops:this.renderLines(a,t)}}},BI=class extends LI{fillPolygons(e,t){let n=this._fillPolygons(e,t),r=Object.assign({},t,{hachureAngle:t.hachureAngle+90}),i=this._fillPolygons(e,r);return n.ops=n.ops.concat(i.ops),n}},VI=class{constructor(e){this.helper=e}fillPolygons(e,t){let n=II(e,t=Object.assign({},t,{hachureAngle:0}));return this.dotsOnLines(n,t)}dotsOnLines(e,t){let n=[],r=t.hachureGap;r<0&&(r=4*t.strokeWidth),r=Math.max(r,.1);let i=t.fillWeight;i<0&&(i=t.strokeWidth/2);let a=r/4;for(let o of e){let e=RI(o),s=e/r,c=Math.ceil(s)-1,l=e-c*r,u=(o[0][0]+o[1][0])/2-r/4,d=Math.min(o[0][1],o[1][1]);for(let e=0;e{let a=RI(e),o=Math.floor(a/(n+r)),s=(a+r-o*(n+r))/2,c=e[0],l=e[1];c[0]>l[0]&&(c=e[1],l=e[0]);let u=Math.atan((l[1]-c[1])/(l[0]-c[0]));for(let e=0;e{let i=RI(e),a=Math.round(i/(2*t)),o=e[0],s=e[1];o[0]>s[0]&&(o=e[1],s=e[0]);let c=Math.atan((s[1]-o[1])/(s[0]-o[0]));for(let e=0;er%2?e+n:e+t));a.push({key:`C`,data:e}),t=e[4],n=e[5];break}case`Q`:a.push({key:`Q`,data:[...s]}),t=s[2],n=s[3];break;case`q`:{let e=s.map(((e,r)=>r%2?e+n:e+t));a.push({key:`Q`,data:e}),t=e[2],n=e[3];break}case`A`:a.push({key:`A`,data:[...s]}),t=s[5],n=s[6];break;case`a`:t+=s[5],n+=s[6],a.push({key:`A`,data:[s[0],s[1],s[2],s[3],s[4],t,n]});break;case`H`:a.push({key:`H`,data:[...s]}),t=s[0];break;case`h`:t+=s[0],a.push({key:`H`,data:[t]});break;case`V`:a.push({key:`V`,data:[...s]}),n=s[0];break;case`v`:n+=s[0],a.push({key:`V`,data:[n]});break;case`S`:a.push({key:`S`,data:[...s]}),t=s[2],n=s[3];break;case`s`:{let e=s.map(((e,r)=>r%2?e+n:e+t));a.push({key:`S`,data:e}),t=e[2],n=e[3];break}case`T`:a.push({key:`T`,data:[...s]}),t=s[0],n=s[1];break;case`t`:t+=s[0],n+=s[1],a.push({key:`T`,data:[t,n]});break;case`Z`:case`z`:a.push({key:`Z`,data:[]}),t=r,n=i}return a}function $I(e){let t=[],n=``,r=0,i=0,a=0,o=0,s=0,c=0;for(let{key:l,data:u}of e){switch(l){case`M`:t.push({key:`M`,data:[...u]}),[r,i]=u,[a,o]=u;break;case`C`:t.push({key:`C`,data:[...u]}),r=u[4],i=u[5],s=u[2],c=u[3];break;case`L`:t.push({key:`L`,data:[...u]}),[r,i]=u;break;case`H`:r=u[0],t.push({key:`L`,data:[r,i]});break;case`V`:i=u[0],t.push({key:`L`,data:[r,i]});break;case`S`:{let e=0,a=0;n===`C`||n===`S`?(e=r+(r-s),a=i+(i-c)):(e=r,a=i),t.push({key:`C`,data:[e,a,...u]}),s=u[0],c=u[1],r=u[2],i=u[3];break}case`T`:{let[e,a]=u,o=0,l=0;n===`Q`||n===`T`?(o=r+(r-s),l=i+(i-c)):(o=r,l=i);let d=r+2*(o-r)/3,f=i+2*(l-i)/3,p=e+2*(o-e)/3,m=a+2*(l-a)/3;t.push({key:`C`,data:[d,f,p,m,e,a]}),s=o,c=l,r=e,i=a;break}case`Q`:{let[e,n,a,o]=u,l=r+2*(e-r)/3,d=i+2*(n-i)/3,f=a+2*(e-a)/3,p=o+2*(n-o)/3;t.push({key:`C`,data:[l,d,f,p,a,o]}),s=e,c=n,r=a,i=o;break}case`A`:{let e=Math.abs(u[0]),n=Math.abs(u[1]),a=u[2],o=u[3],s=u[4],c=u[5],l=u[6];e===0||n===0?(t.push({key:`C`,data:[r,i,c,l,c,l]}),r=c,i=l):(r!==c||i!==l)&&(tL(r,i,c,l,e,n,a,o,s).forEach((function(e){t.push({key:`C`,data:e})})),r=c,i=l);break}case`Z`:t.push({key:`Z`,data:[]}),r=a,i=o}n=l}return t}function eL(e,t,n){return[e*Math.cos(n)-t*Math.sin(n),e*Math.sin(n)+t*Math.cos(n)]}function tL(e,t,n,r,i,a,o,s,c,l){let u=(d=o,Math.PI*d/180);var d;let f=[],p=0,m=0,h=0,g=0;if(l)[p,m,h,g]=l;else{[e,t]=eL(e,t,-u),[n,r]=eL(n,r,-u);let o=(e-n)/2,l=(t-r)/2,d=o*o/(i*i)+l*l/(a*a);d>1&&(d=Math.sqrt(d),i*=d,a*=d);let f=i*i,_=a*a,v=f*_-f*l*l-_*o*o,y=f*l*l+_*o*o,b=(s===c?-1:1)*Math.sqrt(Math.abs(v/y));h=b*i*l/a+(e+n)/2,g=b*-a*o/i+(t+r)/2,p=Math.asin(parseFloat(((t-g)/a).toFixed(9))),m=Math.asin(parseFloat(((r-g)/a).toFixed(9))),em&&(p-=2*Math.PI),!c&&m>p&&(m-=2*Math.PI)}let _=m-p;if(Math.abs(_)>120*Math.PI/180){let e=m,t=n,s=r;m=c&&m>p?p+120*Math.PI/180*1:p+120*Math.PI/180*-1,f=tL(n=h+i*Math.cos(m),r=g+a*Math.sin(m),t,s,i,a,o,0,c,[m,e,h,g])}_=m-p;let v=Math.cos(p),y=Math.sin(p),b=Math.cos(m),x=Math.sin(m),S=Math.tan(_/4),C=4/3*i*S,ee=4/3*a*S,te=[e,t],ne=[e+C*y,t-ee*v],re=[n+C*x,r-ee*b],ie=[n,r];if(ne[0]=2*te[0]-ne[0],ne[1]=2*te[1]-ne[1],l)return[ne,re,ie].concat(f);{f=[ne,re,ie].concat(f);let e=[];for(let t=0;t2){let i=[];for(let t=0;t2*Math.PI&&(p=0,m=2*Math.PI);let h=2*Math.PI/c.curveStepCount,g=Math.min(h/2,(m-p)/2),_=bL(g,l,u,d,f,p,m,1,c);if(!c.disableMultiStroke){let e=bL(g,l,u,d,f,p,m,1.5,c);_.push(...e)}return o&&(s?_.push(...hL(l,u,l+d*Math.cos(p),u+f*Math.sin(p),c),...hL(l,u,l+d*Math.cos(m),u+f*Math.sin(m),c)):_.push({op:`lineTo`,data:[l,u]},{op:`lineTo`,data:[l+d*Math.cos(p),u+f*Math.sin(p)]})),{type:`path`,ops:_}}function uL(e,t){let n=$I(QI(ZI(e))),r=[],i=[0,0],a=[0,0];for(let{key:e,data:o}of n)switch(e){case`M`:a=[o[0],o[1]],i=[o[0],o[1]];break;case`L`:r.push(...hL(a[0],a[1],o[0],o[1],t)),a=[o[0],o[1]];break;case`C`:{let[e,n,i,s,c,l]=o;r.push(...xL(e,n,i,s,c,l,a,t)),a=[c,l];break}case`Z`:r.push(...hL(a[0],a[1],i[0],i[1],t)),a=[i[0],i[1]]}return{type:`path`,ops:r}}function dL(e,t){let n=[];for(let r of e)if(r.length){let e=t.maxRandomnessOffset||0,i=r.length;if(i>2){n.push({op:`move`,data:[r[0][0]+F(e,t),r[0][1]+F(e,t)]});for(let a=1;a500?.4:-.0016668*c+1.233334;let u=i.maxRandomnessOffset||0;u*u*100>s&&(u=c/10);let d=u/2,f=.2+.2*pL(i),p=i.bowing*i.maxRandomnessOffset*(r-t)/200,m=i.bowing*i.maxRandomnessOffset*(e-n)/200;p=F(p,i,l),m=F(m,i,l);let h=[],g=()=>F(d,i,l),_=()=>F(u,i,l),v=i.preserveVertices;return a&&(o?h.push({op:`move`,data:[e+(v?0:g()),t+(v?0:g())]}):h.push({op:`move`,data:[e+(v?0:F(u,i,l)),t+(v?0:F(u,i,l))]})),o?h.push({op:`bcurveTo`,data:[p+e+(n-e)*f+g(),m+t+(r-t)*f+g(),p+e+2*(n-e)*f+g(),m+t+2*(r-t)*f+g(),n+(v?0:g()),r+(v?0:g())]}):h.push({op:`bcurveTo`,data:[p+e+(n-e)*f+_(),m+t+(r-t)*f+_(),p+e+2*(n-e)*f+_(),m+t+2*(r-t)*f+_(),n+(v?0:_()),r+(v?0:_())]}),h}function _L(e,t,n){let r=[];r.push([e[0][0]+F(t,n),e[0][1]+F(t,n)]),r.push([e[0][0]+F(t,n),e[0][1]+F(t,n)]);for(let i=1;i3){let a=[],o=1-n.curveTightness;i.push({op:`move`,data:[e[1][0],e[1][1]]});for(let t=1;t+21&&i.push(n)):i.push(n),i.push(e[t+3])}else{let r=.5,a=e[t+0],o=e[t+1],s=e[t+2],c=e[t+3],l=TL(a,o,r),u=TL(o,s,r),d=TL(s,c,r),f=TL(l,u,r),p=TL(u,d,r),m=TL(f,p,r);EL([a,l,f,m],0,n,i),EL([m,p,d,c],0,n,i)}var a,o;return i}function DL(e,t){return OL(e,0,e.length,t)}function OL(e,t,n,r,i){let a=i||[],o=e[t],s=e[n-1],c=0,l=1;for(let r=t+1;rc&&(c=t,l=r)}return Math.sqrt(c)>r?(OL(e,t,l+1,r,a),OL(e,l,n,r,a)):(a.length||a.push(o),a.push(s)),a}function kL(e,t=.15,n){let r=[],i=(e.length-1)/3;for(let n=0;n0?OL(r,0,r.length,n):r}var AL=`none`,jL=class{constructor(e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:`#000`,strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:`hachure`,fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=e||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Math.floor(Math.random()*2**31)}_o(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_d(e,t,n){return{shape:e,sets:t||[],options:n||this.defaultOptions}}line(e,t,n,r,i){let a=this._o(i);return this._d(`line`,[rL(e,t,n,r,a)],a)}rectangle(e,t,n,r,i){let a=this._o(i),o=[],s=aL(e,t,n,r,a);if(a.fill){let i=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]];a.fillStyle===`solid`?o.push(dL([i],a)):o.push(fL([i],a))}return a.stroke!==AL&&o.push(s),this._d(`rectangle`,o,a)}ellipse(e,t,n,r,i){let a=this._o(i),o=[],s=sL(n,r,a),c=cL(e,t,a,s);if(a.fill){if(a.fillStyle===`solid`){let n=cL(e,t,a,s).opset;n.type=`fillPath`,o.push(n)}else o.push(fL([c.estimatedPoints],a))}return a.stroke!==AL&&o.push(c.opset),this._d(`ellipse`,o,a)}circle(e,t,n,r){let i=this.ellipse(e,t,n,n,r);return i.shape=`circle`,i}linearPath(e,t){let n=this._o(t);return this._d(`linearPath`,[iL(e,!1,n)],n)}arc(e,t,n,r,i,a,o=!1,s){let c=this._o(s),l=[],u=lL(e,t,n,r,i,a,o,!0,c);if(o&&c.fill){if(c.fillStyle===`solid`){let o=Object.assign({},c);o.disableMultiStroke=!0;let s=lL(e,t,n,r,i,a,!0,!1,o);s.type=`fillPath`,l.push(s)}else l.push(function(e,t,n,r,i,a,o){let s=e,c=t,l=Math.abs(n/2),u=Math.abs(r/2);l+=F(.01*l,o),u+=F(.01*u,o);let d=i,f=a;for(;d<0;)d+=2*Math.PI,f+=2*Math.PI;f-d>2*Math.PI&&(d=0,f=2*Math.PI);let p=(f-d)/o.curveStepCount,m=[];for(let e=d;e<=f;e+=p)m.push([s+l*Math.cos(e),c+u*Math.sin(e)]);return m.push([s+l*Math.cos(f),c+u*Math.sin(f)]),m.push([s,c]),fL([m],o)}(e,t,n,r,i,a,c))}return c.stroke!==AL&&l.push(u),this._d(`arc`,l,c)}curve(e,t){let n=this._o(t),r=[],i=oL(e,n);if(n.fill&&n.fill!==AL&&e.length>=3){if(n.fillStyle===`solid`){let t=oL(e,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));r.push({type:`fillPath`,ops:this._mergedShape(t.ops)})}else{let t=kL(function(e,t=0){let n=e.length;if(n<3)throw Error(`A curve must have at least three points.`);let r=[];if(n===3)r.push(SL(e[0]),SL(e[1]),SL(e[2]),SL(e[2]));else{let n=[];n.push(e[0],e[0]);for(let t=1;t{s.length>=4&&a.push(...kL(s,t)),s=[]},l=()=>{c(),a.length&&(i.push(a),a=[])};for(let{key:e,data:t}of r)switch(e){case`M`:l(),o=[t[0],t[1]],a.push(o);break;case`L`:c(),a.push([t[0],t[1]]);break;case`C`:if(!s.length){let e=a.length?a[a.length-1]:o;s.push([e[0],e[1]])}s.push([t[0],t[1]]),s.push([t[2],t[3]]),s.push([t[4],t[5]]);break;case`Z`:c(),a.push([o[0],o[1]])}if(l(),!n)return i;let u=[];for(let e of i){let t=DL(e,n);t.length&&u.push(t)}return u}(e,1,o?4-4*(n.simplification||1):(1+n.roughness)/2),c=uL(e,n);if(i){if(n.fillStyle===`solid`){if(s.length===1){let t=uL(e,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));r.push({type:`fillPath`,ops:this._mergedShape(t.ops)})}else r.push(dL(s,n))}else r.push(fL(s,n))}return a&&(o?s.forEach((e=>{r.push(iL(e,!1,n))})):r.push(c)),this._d(`path`,r,n)}opsToPath(e,t){let n=``;for(let r of e.ops){let e=typeof t==`number`&&t>=0?r.data.map((e=>+e.toFixed(t))):r.data;switch(r.op){case`move`:n+=`M${e[0]} ${e[1]} `;break;case`bcurveTo`:n+=`C${e[0]} ${e[1]}, ${e[2]} ${e[3]}, ${e[4]} ${e[5]} `;break;case`lineTo`:n+=`L${e[0]} ${e[1]} `}}return n.trim()}toPaths(e){let t=e.sets||[],n=e.options||this.defaultOptions,r=[];for(let e of t){let t=null;switch(e.type){case`path`:t={d:this.opsToPath(e),stroke:n.stroke,strokeWidth:n.strokeWidth,fill:AL};break;case`fillPath`:t={d:this.opsToPath(e),stroke:AL,strokeWidth:0,fill:n.fill||AL};break;case`fillSketch`:t=this.fillSketch(e,n)}t&&r.push(t)}return r}fillSketch(e,t){let n=t.fillWeight;return n<0&&(n=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||AL,strokeWidth:n,fill:AL}}_mergedShape(e){return e.filter(((e,t)=>t===0||e.op!==`move`))}},ML=class{constructor(e,t){this.canvas=e,this.ctx=this.canvas.getContext(`2d`),this.gen=new jL(t)}draw(e){let t=e.sets||[],n=e.options||this.getDefaultOptions(),r=this.ctx,i=e.options.fixedDecimalPlaceDigits;for(let a of t)switch(a.type){case`path`:r.save(),r.strokeStyle=n.stroke===`none`?`transparent`:n.stroke,r.lineWidth=n.strokeWidth,n.strokeLineDash&&r.setLineDash(n.strokeLineDash),n.strokeLineDashOffset&&(r.lineDashOffset=n.strokeLineDashOffset),this._drawToContext(r,a,i),r.restore();break;case`fillPath`:{r.save(),r.fillStyle=n.fill||``;let t=e.shape===`curve`||e.shape===`polygon`||e.shape===`path`?`evenodd`:`nonzero`;this._drawToContext(r,a,i,t),r.restore();break}case`fillSketch`:this.fillSketch(r,a,n)}}fillSketch(e,t,n){let r=n.fillWeight;r<0&&(r=n.strokeWidth/2),e.save(),n.fillLineDash&&e.setLineDash(n.fillLineDash),n.fillLineDashOffset&&(e.lineDashOffset=n.fillLineDashOffset),e.strokeStyle=n.fill||``,e.lineWidth=r,this._drawToContext(e,t,n.fixedDecimalPlaceDigits),e.restore()}_drawToContext(e,t,n,r=`nonzero`){e.beginPath();for(let r of t.ops){let t=typeof n==`number`&&n>=0?r.data.map((e=>+e.toFixed(n))):r.data;switch(r.op){case`move`:e.moveTo(t[0],t[1]);break;case`bcurveTo`:e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]);break;case`lineTo`:e.lineTo(t[0],t[1])}}t.type===`fillPath`?e.fill(r):e.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(e,t,n,r,i){let a=this.gen.line(e,t,n,r,i);return this.draw(a),a}rectangle(e,t,n,r,i){let a=this.gen.rectangle(e,t,n,r,i);return this.draw(a),a}ellipse(e,t,n,r,i){let a=this.gen.ellipse(e,t,n,r,i);return this.draw(a),a}circle(e,t,n,r){let i=this.gen.circle(e,t,n,r);return this.draw(i),i}linearPath(e,t){let n=this.gen.linearPath(e,t);return this.draw(n),n}polygon(e,t){let n=this.gen.polygon(e,t);return this.draw(n),n}arc(e,t,n,r,i,a,o=!1,s){let c=this.gen.arc(e,t,n,r,i,a,o,s);return this.draw(c),c}curve(e,t){let n=this.gen.curve(e,t);return this.draw(n),n}path(e,t){let n=this.gen.path(e,t);return this.draw(n),n}},NL=`http://www.w3.org/2000/svg`,PL=class{constructor(e,t){this.svg=e,this.gen=new jL(t)}draw(e){let t=e.sets||[],n=e.options||this.getDefaultOptions(),r=this.svg.ownerDocument||window.document,i=r.createElementNS(NL,`g`),a=e.options.fixedDecimalPlaceDigits;for(let o of t){let t=null;switch(o.type){case`path`:t=r.createElementNS(NL,`path`),t.setAttribute(`d`,this.opsToPath(o,a)),t.setAttribute(`stroke`,n.stroke),t.setAttribute(`stroke-width`,n.strokeWidth+``),t.setAttribute(`fill`,`none`),n.strokeLineDash&&t.setAttribute(`stroke-dasharray`,n.strokeLineDash.join(` `).trim()),n.strokeLineDashOffset&&t.setAttribute(`stroke-dashoffset`,`${n.strokeLineDashOffset}`);break;case`fillPath`:t=r.createElementNS(NL,`path`),t.setAttribute(`d`,this.opsToPath(o,a)),t.setAttribute(`stroke`,`none`),t.setAttribute(`stroke-width`,`0`),t.setAttribute(`fill`,n.fill||``),e.shape!==`curve`&&e.shape!==`polygon`||t.setAttribute(`fill-rule`,`evenodd`);break;case`fillSketch`:t=this.fillSketch(r,o,n)}t&&i.appendChild(t)}return i}fillSketch(e,t,n){let r=n.fillWeight;r<0&&(r=n.strokeWidth/2);let i=e.createElementNS(NL,`path`);return i.setAttribute(`d`,this.opsToPath(t,n.fixedDecimalPlaceDigits)),i.setAttribute(`stroke`,n.fill||``),i.setAttribute(`stroke-width`,r+``),i.setAttribute(`fill`,`none`),n.fillLineDash&&i.setAttribute(`stroke-dasharray`,n.fillLineDash.join(` `).trim()),n.fillLineDashOffset&&i.setAttribute(`stroke-dashoffset`,`${n.fillLineDashOffset}`),i}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(e,t){return this.gen.opsToPath(e,t)}line(e,t,n,r,i){let a=this.gen.line(e,t,n,r,i);return this.draw(a)}rectangle(e,t,n,r,i){let a=this.gen.rectangle(e,t,n,r,i);return this.draw(a)}ellipse(e,t,n,r,i){let a=this.gen.ellipse(e,t,n,r,i);return this.draw(a)}circle(e,t,n,r){let i=this.gen.circle(e,t,n,r);return this.draw(i)}linearPath(e,t){let n=this.gen.linearPath(e,t);return this.draw(n)}polygon(e,t){let n=this.gen.polygon(e,t);return this.draw(n)}arc(e,t,n,r,i,a,o=!1,s){let c=this.gen.arc(e,t,n,r,i,a,o,s);return this.draw(c)}curve(e,t){let n=this.gen.curve(e,t);return this.draw(n)}path(e,t){let n=this.gen.path(e,t);return this.draw(n)}},FL={canvas:(e,t)=>new ML(e,t),svg:(e,t)=>new PL(e,t),generator:e=>new jL(e),newSeed:()=>jL.newSeed()},IL=(e,t)=>e===`none`?`none`:e===`ink`?t===`fill`?`var(--dw-surface-sunken)`:`var(--dw-ink)`:e===`paper`?t===`fill`?`var(--dw-surface-raised)`:`var(--dw-surface)`:t===`fill`?`color-mix(in srgb, var(--dw-c-${e}) 22%, var(--dw-surface))`:`var(--dw-c-${e})`,LL=e=>e.replace(/&/g,`&`).replace(//g,`>`).replace(/"/g,`"`),RL=e=>Math.round(e*100)/100,zL=`#000001`,BL=`#000002`;function VL(e,t){return e===`dash`?`stroke-dasharray:${RL(t*4)} ${RL(t*3)};`:``}function HL(e){let t=2166136261;for(let n of e)t=Math.imul(t^n.charCodeAt(0),16777619);return(t>>>0)%2**31||1}function UL(e,t,n){switch(e){case`diamond`:return[[t/2,0],[t,n/2],[t/2,n],[0,n/2]];case`triangle`:return[[t/2,0],[t,n],[0,n]];case`rect`:return[[0,0],[t,0],[t,n],[0,n]];default:return null}}function WL(e,t){let n=Math.min(16,e*.15,t*.15);return`M${RL(n)} 0 H${RL(e-n)} Q${RL(e)} 0 ${RL(e)} ${RL(n)} V${RL(t-n)} Q${RL(e)} ${RL(t)} ${RL(e-n)} ${RL(t)} H${RL(n)} Q0 ${RL(t)} 0 ${RL(t-n)} V${RL(n)} Q0 0 ${RL(n)} 0 Z`}function GL(e,t){let{w:n,h:r}=e,i=e.strokeStyle===`none`?`none`:t(e.stroke,`line`),a=t(e.fill,`fill`),o=e.strokeStyle===`none`?0:e.strokeWidth;if(e.rough){let t=FL.generator(),s={seed:HL(e.id),roughness:1.2,bowing:1,strokeWidth:Math.max(o,1),stroke:i===`none`?`none`:zL,fill:a===`none`?void 0:BL,fillStyle:`hachure`,hachureGap:8,fillWeight:1.4,disableMultiStroke:o===0},c=UL(e.shape,n,r),l=e.shape===`ellipse`?t.ellipse(n/2,r/2,n,r,s):e.shape===`roundrect`?t.path(WL(n,r),s):t.polygon(c,s);return t.toPaths(l).map(t=>{if(t.fill===BL)return``;let n=t.stroke===BL,r=n?a.replace(`22%`,`60%`):i;return r===`none`||t.stroke===`none`?``:``}).join(``)}let s=`fill:${a};stroke:${i};stroke-width:${RL(o)};stroke-linejoin:round;${VL(e.strokeStyle,o)}`;return e.shape===`ellipse`?``:e.shape===`roundrect`?``:``}function KL(e,t,n,r,i){if(e===`none`)return``;let a=6+r*2.5,o=(e,r)=>{let i=Math.cos(n),a=Math.sin(n);return`${RL(t[0]+e*i-r*a)},${RL(t[1]+e*a+r*i)}`};switch(e){case`arrow`:return``;case`triangle`:return``;case`circle`:{let[e,t]=o(-a*.45,0).split(`,`).map(Number);return``}case`diamond`:return``}}function qL(e,t,n){let r=e.strokeStyle===`none`?n(`gray`,`line`):n(e.stroke,`line`),i=e.strokeWidth,a;if(e.rough){let n=FL.generator();a=n.toPaths(n.path(t.d,{seed:HL(e.id),roughness:1,strokeWidth:i,stroke:`#000`})).map(e=>``).join(``)}else a=``;let o=t.points[t.points.length-1];return a+KL(e.startArrow,t.points[0],t.startAngle,i,r)+KL(e.endArrow,o,t.endAngle,i,r)}function JL(e,t){let n=MI(e,{size:t,thinning:.55,smoothing:.5,streamline:.4,simulatePressure:e.every(e=>e[2]===.5),last:!0});if(!n.length)return``;let r=(e,t)=>(e+t)/2,i=`M${RL(n[0][0])} ${RL(n[0][1])} Q`;for(let e=0;e`}function XL(e){let t=[];for(let n of e.toArray())if(n instanceof mx)for(let e of n.toDelta()){if(typeof e.insert!=`string`)continue;let n={type:`text`,text:e.insert};e.attributes&&(n.marks=Object.entries(e.attributes).map(([e,t])=>({type:e,attrs:t&&typeof t==`object`?t:{}}))),t.push(n)}else if(n instanceof lx){let e={type:n.nodeName},r=n.getAttributes();Object.keys(r).length&&(e.attrs=r),n.length&&(e.content=XL(n)),t.push(e)}return t}function ZL(e,t,n=0){if(n>100)return;let r=0;for(;r{let r=``,i=!1;for(let a of e)a.type===`text`?(r+=a.text??``,i=!0):a.type===`hardBreak`?(t.push(r),r=``):a.content?.length&&a.content.some(e=>e.type!==`text`&&e.type!==`hardBreak`)?(i&&t.push(r),r=``,i=!1,n(a.content)):(i&&t.push(r),t.push((a.content??[]).map(e=>e.text??``).join(``)),r=``,i=!1);i&&t.push(r)};return n(e),t}var $L=`docwell-canvas`,eR=e=>e.getMap(`surface`);function tR(e){let t={};for(let[n,r]of e.entries())r instanceof Bb?t[n]=r.toJSON():r instanceof gb||(t[n]=r);return AF(t)}function nR(e,t){return(e.type===`frame`?0:1)-(t.type===`frame`?0:1)||e.index-t.index||(e.idt.id))}function rR(){return AF({id:SF,type:`note`,page:!0,background:`paper`,x:0,y:0,w:760,h:400,index:0})}var iR=class{doc;map;undo;cache=null;byId=new Map;listeners=new Set;observer=e=>{this.cache=null;let t=new Set;for(let n of e){if(n.target===this.map){t=null;break}let e=n.target;for(;e&&e.parent!==this.map;)e=e.parent;let r=e&&e._item?.parentSub;r&&t.add(r)}for(let e of this.listeners)e(t)};constructor(e,t={}){this.doc=e,this.map=eR(e),this.map.observeDeep(this.observer),this.undo=t.undo===!1?null:new Wy(this.map,{trackedOrigins:new Set([$L]),captureTimeout:400})}destroy(){this.map.unobserveDeep(this.observer),this.undo?.destroy(),this.listeners.clear()}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}elements(){if(this.cache)return this.cache;let e=[];for(let[t,n]of this.map.entries()){let r=n instanceof Bb?tR(n):null;r&&e.push({...r,id:t})}return e.some(e=>e.type===`note`&&e.page)||e.push(rR()),e.sort(nR),this.cache=e,this.byId=new Map(e.map(e=>[e.id,e])),e}get(e){return this.elements(),this.byId.get(e)}get isEmpty(){return this.map.size===0}body(e){let t=this.map.get(e);if(!(t instanceof Bb))return null;let n=t.get(`body`);return n instanceof sx?n:null}nodes(e){let t=this.map.get(e)?.get(`nodes`);return t instanceof Bb?t:null}transact(e){this.doc.transact(e,$L)}nextIndex(){let e=0;for(let t of this.elements())t.type!==`frame`&&(e=Math.max(e,t.index));return e+1}ensure(e){let t=this.map.get(e);if(t instanceof Bb)return t;if(e!==`page`)return null;let n=this.get(e),r=new Bb;this.map.set(e,r);for(let[e,t]of Object.entries(n))e!==`id`&&r.set(e,t);return r}add(e,t){let n=e.id||FF();return this.transact(()=>{let r=new Bb;this.map.set(n,r);let{nodes:i,...a}=e;for(let[e,t]of Object.entries(a))e!==`id`&&t!==void 0&&r.set(e,t);if(`index`in a||r.set(`index`,e.type===`frame`?-this.nextIndex():this.nextIndex()),e.type===`note`&&!e.page){let e=new sx;r.set(`body`,e),ZL(e,t?.length?t:[{type:`paragraph`}])}if(e.type===`mindmap`){let e=new Bb;r.set(`nodes`,e);let t=i&&Object.keys(i).length?i:{[FF()]:{text:``,parent:``,pos:0}};for(let[n,r]of Object.entries(t))e.set(n,aR(r))}}),n}update(e,t){this.updateMany([[e,t]])}updateMany(e){e.length&&this.transact(()=>{for(let[t,n]of e){let e=this.ensure(t);if(e)for(let[t,r]of Object.entries(n))t!==`id`&&t!==`type`&&t!==`body`&&t!==`nodes`&&(r===void 0?e.delete(t):oR(e.get(t),r)||e.set(t,r))}})}remove(e){let t=this.elements(),n=new Set;for(let r of e){n.add(r);for(let e of t)e.group===r&&n.add(e.id)}n.delete(SF);for(let e of t)e.type===`note`&&e.page&&n.delete(e.id);n.size&&this.transact(()=>{for(let e of t)if(!(e.type!==`connector`||n.has(e.id)))for(let t of[`source`,`target`]){let r=e[t];if(r.id&&n.has(r.id)){let n=this.endPoint(r);this.map.get(e.id)?.set(t,{x:n[0],y:n[1]})}}for(let e of n)this.map.delete(e);let e=this.elements();for(let t of e.filter(e=>e.type===`group`)){let n=e.filter(e=>e.group===t.id);if(n.length<2){for(let e of n)this.map.get(e.id)?.delete(`group`);this.map.delete(t.id)}}})}endPoint(e){let t=e.id?this.get(e.id):void 0;if(!t)return[e.x??0,e.y??0];let[n,r]=e.pos??[.5,.5];return[t.x+t.w*n,t.y+t.h*r]}reorder(e,t){let n=this.elements().filter(e=>e.type!==`frame`),r=new Set(e),i=n.filter(e=>r.has(e.id));if(!i.length)return;let a=n.filter(e=>!r.has(e.id)),o;if(t===`front`)o=[...a,...i];else if(t===`back`)o=[...i,...a];else{o=[...n];let e=t===`forward`?1:-1,a=e=>o.indexOf(e),s=e===1?[...i].reverse():i;for(let t of s){let n=a(t),i=n+e;i<0||i>=o.length||r.has(o[i].id)||([o[n],o[i]]=[o[i],o[n]])}}this.updateMany(o.map((e,t)=>[e.id,{index:t+1}]).filter(([e,t])=>this.get(e)?.index!==t.index))}groupOf(e){let t=e.filter(e=>{let t=this.get(e);return t&&t.type!==`group`&&!(t.type===`note`&&t.page)});if(t.length<2)return null;let n=FF();return this.transact(()=>{let e=new Bb;this.map.set(n,e),e.set(`type`,`group`),e.set(`index`,this.nextIndex());for(let e of t)this.ensure(e)?.set(`group`,n)}),n}ungroup(e){let t=this.elements().filter(t=>t.group===e).map(e=>e.id);return this.transact(()=>{for(let e of t)this.map.get(e)?.delete(`group`);this.map.delete(e)}),t}addNode(e,t,n,r=``){let i=FF();return this.transact(()=>this.nodes(e)?.set(i,aR({text:r,parent:t,pos:n}))),i}updateNode(e,t,n){this.transact(()=>{let r=this.nodes(e)?.get(t);if(r)for(let[e,t]of Object.entries(n))r.get(e)!==t&&r.set(e,t)})}removeNode(e,t){let n=this.get(e);if(n?.type!==`mindmap`)return;if(t===Object.entries(n.nodes).find(([,e])=>!e.parent)?.[0]){this.remove([e]);return}let r=new Set([t]),i=!0;for(;i;){i=!1;for(let[e,t]of Object.entries(n.nodes))!r.has(e)&&r.has(t.parent)&&(r.add(e),i=!0)}this.transact(()=>{let t=this.nodes(e);for(let e of r)t?.delete(e)})}toJSON(e){let t=this.elements(),n;if(e){n=new Set(e);for(let e of t)n.has(e.group)&&n.add(e.id)}else n=new Set(t.map(e=>e.id));return t.filter(e=>n.has(e.id)).map(e=>{let t={...e,id:e.id,type:e.type},n=e.type===`note`&&!e.page?this.body(e.id):null;return n&&(t.body=XL(n)),t})}insertJSON(e,t=0,n=0){let r=e.filter(e=>e&&typeof e==`object`&&!(e.type===`note`&&e.page)),i=new Map(r.map(e=>[String(e.id),FF()])),a=[],o=this.nextIndex();return this.transact(()=>{for(let e of r){let r=AF(e);if(!r)continue;let s=i.get(String(e.id)),c={...r};if(delete c.id,c.x=r.x+t,c.y=r.y+n,c.index=r.type===`frame`?-o++:o++,c.group=r.group&&i.has(r.group)?i.get(r.group):void 0,r.type===`connector`)for(let e of[`source`,`target`]){let a=r[e];if(a.id&&i.has(a.id))c[e]={id:i.get(a.id),...a.pos?{pos:a.pos}:{}};else if(a.id){let r=this.endPoint(a);c[e]={x:r[0]+t,y:r[1]+n}}else c[e]={x:(a.x??0)+t,y:(a.y??0)+n}}for(let e of Object.keys(c))(c[e]===void 0||c[e]===``)&&delete c[e];this.add({...c,id:s,type:r.type},Array.isArray(e.body)?e.body:void 0),a.push(s)}}),a}load(e){this.transact(()=>{for(let e of[...this.map.keys()])this.map.delete(e);for(let t of e){let e=AF(t);if(!e||!t.id)continue;let n={...e},r=String(t.id);delete n.id;for(let e of Object.keys(n))n[e]===``&&delete n[e];this.add({...n,id:r,type:e.type},Array.isArray(t.body)?t.body:void 0)}})}};function aR(e){let t=new Bb;return t.set(`text`,e.text),t.set(`parent`,e.parent),t.set(`pos`,e.pos),t}function oR(e,t){return e===t?!0:typeof e!=`object`||typeof t!=`object`||!e||!t?!1:JSON.stringify(e)===JSON.stringify(t)}var sR=(e,t=18)=>``,cR={rect:``,roundrect:``,ellipse:``,diamond:``,triangle:``,straight:``,curve:``,elbow:``,none:``,arrow:``,triangleEnd:``,circle:``,diamondEnd:``,solid:``,dash:``,noLine:``,right:``,left:``,radial:``},lR=e=>``;function uR(e){return e===`none`?`background:transparent`:e===`ink`?`background:var(--dw-ink)`:e===`paper`?`background:var(--dw-surface)`:`background:var(--dw-c-${e})`}var dR=class{v;bar;zoomBox;props;zoomLabel;pop=null;popFor=``;fileInput;lastProps=``;closePop=e=>{this.pop&&!this.pop.contains(e.target)&&!e.target.closest?.(`[data-pop]`)&&this.hidePop()};constructor(e){this.v=e;let t=e.root;this.bar=this.div(`dw-cv-ui dw-cv-toolbar`),this.bar.setAttribute(`role`,`toolbar`),this.bar.setAttribute(`aria-label`,e.labels.toolbar),this.zoomBox=this.div(`dw-cv-ui dw-cv-zoom`),this.props=this.div(`dw-cv-ui dw-cv-props`),this.props.setAttribute(`role`,`toolbar`),this.zoomLabel=document.createElement(`button`),this.fileInput=document.createElement(`input`),this.fileInput.type=`file`,this.fileInput.accept=`image/*`,this.fileInput.multiple=!0,this.fileInput.hidden=!0,this.fileInput.addEventListener(`change`,()=>{let t=[...this.fileInput.files??[]];this.fileInput.value=``,t.length&&e.addImages(t)}),t.append(this.bar,this.zoomBox,this.props,this.fileInput),document.addEventListener(`pointerdown`,this.closePop,!0),this.buildZoom(),this.refresh()}destroy(){document.removeEventListener(`pointerdown`,this.closePop,!0)}div(e){let t=document.createElement(`div`);return t.className=e,t}button(e,t,n,r={}){let i=document.createElement(`button`);return i.type=`button`,i.className=`dw-cv-btn${r.cls?` ${r.cls}`:``}`,i.innerHTML=e,i.title=t,i.setAttribute(`aria-label`,t),r.active!==void 0&&i.setAttribute(`aria-pressed`,String(r.active)),r.pop&&(i.dataset.pop=r.pop),i.addEventListener(`pointerdown`,e=>e.stopPropagation()),i.addEventListener(`click`,e=>{e.stopPropagation(),n()}),i}buildBar(){let e=this.v,t=e.labels;if(this.bar.replaceChildren(),this.bar.hidden=e.isPresenting,!e.editable){this.bar.append(this.button(sR(`cursor`),t.select,()=>e.setTool(`select`),{active:e.tool===`select`}),this.button(sR(`hand`),t.hand,()=>e.setTool(`hand`),{active:e.tool===`hand`}),this.sep(),this.button(sR(`present`),t.present,()=>e.present()));return}let n=(t,n,r)=>this.button(sR(n),r,()=>e.setTool(t),{active:e.tool===t}),r=this.button(lR(e.shapeKind),t.shape,()=>{e.setTool(`shape`),this.togglePop(`shape`,r,()=>this.shapePop())},{active:e.tool===`shape`,pop:`shape`}),i=this.button(sR(`pen`),t.pen,()=>{e.setTool(`pen`),this.togglePop(`pen`,i,()=>this.penPop())},{active:e.tool===`pen`,pop:`pen`}),a=this.button(sR(`connector`),t.connector,()=>{e.setTool(`connector`),this.togglePop(`connector`,a,()=>this.connectorPop())},{active:e.tool===`connector`,pop:`connector`}),o=this.button(sR(`sticker`),t.library,()=>this.togglePop(`library`,o,()=>this.libraryPop()),{pop:`library`});this.bar.append(n(`select`,`cursor`,t.select),n(`hand`,`hand`,t.hand),this.sep(),n(`note`,`note`,t.note),n(`text`,`type`,t.text),r,a,i,n(`eraser`,`eraser`,t.eraser),n(`frame`,`frame`,t.frame),n(`mindmap`,`mindmap`,t.mindmap),this.button(sR(`image`),t.image,()=>this.pickImage()),this.button(sR(`link`),t.link,()=>void e.addLink()),o,this.sep(),this.button(sR(`present`),t.present,()=>e.present()))}sep(){return this.div(`dw-cv-sep`)}pickImage(){this.v.editable&&this.v.opts.files?.upload&&this.fileInput.click()}togglePop(e,t,n){if(this.pop&&this.popFor===e)return this.hidePop();this.hidePop();let r=n();r.classList.add(`dw-cv-ui`,`dw-cv-pop`),r.addEventListener(`pointerdown`,e=>e.stopPropagation()),this.v.root.append(r),this.pop=r,this.popFor=e;let i=this.v.root.getBoundingClientRect(),a=t.getBoundingClientRect(),o=r.offsetWidth,s=r.offsetHeight,c=a.left-i.left+a.width/2-o/2;c=Math.max(8,Math.min(i.width-o-8,c));let l=a.top-i.top-s-8;l<8&&(l=a.bottom-i.top+8),r.style.left=`${c}px`,r.style.top=`${l}px`}hidePop(){this.pop?.remove(),this.pop=null,this.popFor=``}row(...e){let t=this.div(`dw-cv-row`);return t.append(...e),t}colorRow(e,t,n,r){let i=this.div(`dw-cv-row dw-cv-colors`);i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,r);let a=this.v.labels,o=[`ink`,...hF,...n?[`paper`,`none`]:[]];for(let n of o){let r=n===`ink`?a.colorInk:n===`paper`?a.colorPaper:n===`none`?a.colorNone:a.colors[n]??n,o=this.button(``,r,()=>{t(n),this.lastProps=``,this.refresh()},{active:n===e});i.append(o)}return i}shapePop(){let e=this.v,t=e.labels,n=this.div(``);return n.append(this.row(...vF.map(n=>this.button(lR(n),t[n],()=>{e.setShapeKind(n),this.hidePop()},{active:e.shapeKind===n}))),this.row(this.button(`${t.general}`,t.general,()=>{e.setStyle(`shape`,{rough:!1}),this.hidePop()},{active:!e.styles.shape.rough}),this.button(`${t.scribbled}`,t.scribbled,()=>{e.setStyle(`shape`,{rough:!0}),this.hidePop()},{active:e.styles.shape.rough}))),n}penPop(){let e=this.v,t=this.div(``);return t.append(this.colorRow(e.styles.brush.color,t=>e.setStyle(`brush`,{color:t}),!1,e.labels.stroke),this.row(...[2,4,8,14].map(t=>this.button(``,`${e.labels.thickness} ${t}`,()=>{e.setStyle(`brush`,{size:t}),this.hidePop()},{active:e.styles.brush.size===t})))),t}connectorPop(){let e=this.v,t=this.div(``);return t.append(this.row(...yF.map(t=>this.button(lR(t),e.labels[t],()=>{e.setStyle(`connector`,{mode:t}),this.hidePop()},{active:e.styles.connector.mode===t})))),t}libraryPop(){let e=this.v,t=e.labels,n=this.div(`dw-cv-library`),r=this.div(`dw-cv-poptitle`);r.textContent=t.stickers;let i=this.div(`dw-cv-stickers`);for(let t of RF)i.append(this.button(`${t}`,t,()=>{e.insertSticker(t),this.hidePop()}));let a=this.div(`dw-cv-poptitle`);a.textContent=t.templates;let o=this.div(`dw-cv-templates`),s={kanban:t.templateKanban,swot:t.templateSwot,flow:t.templateFlow,brainstorm:t.templateBrainstorm,retro:t.templateRetro};for(let t of BF){let n=this.button(`${s[t]}`,s[t],()=>{e.insertTemplate(t),this.hidePop()},{cls:`dw-cv-wide`});o.append(n)}return n.append(r,i,a,o),n}buildZoom(){let e=this.v,t=e.labels;this.zoomLabel.type=`button`,this.zoomLabel.className=`dw-cv-btn dw-cv-zoomlabel`,this.zoomLabel.title=t.zoomReset,this.zoomLabel.addEventListener(`pointerdown`,e=>e.stopPropagation()),this.zoomLabel.addEventListener(`click`,()=>e.zoomAt(1)),this.zoomBox.append(this.button(sR(`zoom-out`),t.zoomOut,()=>e.zoomBy(.8)),this.zoomLabel,this.button(sR(`zoom-in`),t.zoomIn,()=>e.zoomBy(1.25)),this.button(sR(`fit`),t.zoomFit,()=>e.fit()))}zoomChanged(){this.zoomLabel.textContent=`${Math.round(this.v.zoom*100)}%`}refresh(){this.buildBar();let e=(this.v.editable||this.v.opts.onComment)&&!this.v.editing&&!this.v.isPresenting?this.v.selection():[],t=JSON.stringify([e,this.v.activeNode,this.v.styles.shape.rough]);t!==this.lastProps&&(this.lastProps=t,this.buildProps(e)),this.place()}place(){let e=this.props;if(e.hidden)return;let t=this.v.selectionScreenBox();if(!t){e.hidden=!0;return}let n=this.v.root.getBoundingClientRect(),r=e.offsetWidth,i=e.offsetHeight,a=t.x+t.w/2-r/2;a=Math.max(8,Math.min(n.width-r-8,a));let o=t.y-i-40;o<8&&(o=Math.min(n.height-i-64,t.y+t.h+16)),e.style.left=`${a}px`,e.style.top=`${Math.max(8,o)}px`}buildProps(e){let t=this.props;if(t.replaceChildren(),!e.length){t.hidden=!0;return}t.hidden=!1;let n=this.v,r=n.labels,i=n.opts.onComment,a=()=>this.button(sR(`comment`),r.comment,()=>{let t=e[0].id;i?.({id:t,text:n.elementText(t).slice(0,500)})});if(!n.editable){i&&e.length===1?t.append(a()):t.hidden=!0;return}let o=new Set(e.map(e=>e.type)).size===1?e[0]:null,s=[],c=(e,t,n,r)=>{let i=this.button(t,n,()=>this.togglePop(e,i,r),{pop:e});s.push(i)},l=(e,t,r,i,a)=>c(e,``,t,()=>{let e=this.div(``);return e.append(this.colorRow(r,e=>n.restyle({[i]:e}),a,t)),e}),u=(e,t,r,i,a,o,s,l=e=>e)=>c(e,a(r),t,()=>{let e=this.div(``);return e.append(this.row(...i.map(e=>this.button(a(e),s(e),()=>{n.restyle({[o]:l(e)}),this.hidePop(),this.lastProps=``,this.refresh()},{active:e===r})))),e}),d=(e,t,n,r)=>s.push(this.button(e,t,r,{active:n}));if(o?.type===`shape`)u(`kind`,r.shape,o.shape,vF,lR,`shape`,e=>r[e]),l(`fill`,r.fill,o.fill,`fill`,!0),l(`stroke`,r.stroke,o.stroke,`stroke`,!0),u(`style`,r.lineStyle,o.strokeStyle,[`solid`,`dash`,`none`],e=>lR(e===`none`?`noLine`:e),`strokeStyle`,e=>e===`none`?r.noLine:r[e]),u(`width`,r.thickness,String(o.strokeWidth),[`1`,`2`,`4`,`6`],e=>``,`strokeWidth`,e=>`${r.thickness} ${e}`,Number),d(`${r.scribbled}`,r.scribbled,o.rough,()=>{n.restyle({rough:!o.rough}),this.lastProps=``,this.refresh()}),l(`textColor`,r.textColor,o.textColor,`textColor`,!1);else if(o?.type===`connector`){u(`mode`,r.connector,o.mode,yF,lR,`mode`,e=>r[e]),l(`stroke`,r.stroke,o.stroke,`stroke`,!1),u(`style`,r.lineStyle,o.strokeStyle===`none`?`solid`:o.strokeStyle,[`solid`,`dash`],lR,`strokeStyle`,e=>r[e]);let e=e=>lR(e===`triangle`?`triangleEnd`:e===`diamond`?`diamondEnd`:e);u(`start`,r.startArrow,o.startArrow,bF,t=>`${e(t)}`,`startArrow`,e=>e),u(`end`,r.endArrow,o.endArrow,bF,e,`endArrow`,e=>e)}else o?.type===`brush`?l(`color`,r.stroke,o.color,`color`,!1):o?.type===`text`?(l(`color`,r.textColor,o.color,`color`,!1),u(`size`,r.fontSize,String(o.fontSize),[`16`,`24`,`32`,`48`,`64`],e=>`${e}`,`fontSize`,e=>`${r.fontSize} ${e}`,Number),u(`font`,r.font,o.font||`sans`,[`sans`,`serif`,`mono`],e=>`Aa`,`font`,e=>r[e],e=>e===`sans`?``:e),u(`align`,r.alignLeft,o.align,[`left`,`center`,`right`],e=>sR(`align-${e}`),`align`,e=>r[e===`left`?`alignLeft`:e===`center`?`alignCenter`:`alignRight`]),d(sR(`bold`),r.bold,o.bold,()=>{n.restyle({bold:!o.bold}),this.lastProps=``,this.refresh()})):o?.type===`note`||o?.type===`frame`?l(`bg`,r.background,o.background,`background`,!0):o?.type===`mindmap`?(u(`layout`,r.layout,o.layout,xF,e=>lR(e),`layout`,e=>r[e===`right`?`layoutRight`:e===`left`?`layoutLeft`:`layoutRadial`]),l(`color`,r.stroke,o.color,`color`,!1),n.activeNode?.map===o.id&&s.push(this.button(`+ ${r.addChild}`,r.addChild,()=>n.mindmapAdd(`child`),{cls:`dw-cv-wide`}))):o?.type===`embed`&&e.length===1&&s.push(this.button(sR(`open`),r.openLink,()=>window.open(o.url,`_blank`,`noopener,noreferrer`)));t.append(...s),i&&e.length===1&&t.append(a()),s.length&&t.append(this.sep());let f=e.filter(e=>e.type===`group`);e.length>1&&!f.length&&t.append(this.button(sR(`group`),r.group,()=>n.group())),f.length&&t.append(this.button(sR(`layers`),r.ungroup,()=>n.ungroup()));let p=e.every(e=>e.type===`note`&&e.page);t.append(this.button(sR(`arrow-up`),r.bringFront,()=>n.reorder(`front`)),this.button(sR(`send-back`),r.sendBack,()=>n.reorder(`back`))),p||t.append(this.button(sR(`copy`),r.duplicate,()=>n.duplicate()),this.button(sR(`trash`),r.delete,()=>n.deleteSelection(),{cls:`dw-cv-danger`}))}toast(e){let t=this.div(`dw-cv-ui dw-cv-toast`);t.setAttribute(`role`,`status`),t.textContent=e,this.v.root.append(t),setTimeout(()=>t.remove(),2600)}presentBar(){let e=this.v,t=e.labels,n=this.div(`dw-cv-ui dw-cv-presentbar`),r=this.div(`dw-cv-step`);return r.setAttribute(`aria-live`,`polite`),n.append(this.button(sR(`chevron-left`),t.presentPrevious,()=>e.presentStep(-1)),r,this.button(sR(`chevron-right`),t.presentNext,()=>e.presentStep(1)),this.button(sR(`close`),t.presentExit,()=>e.stopPresenting())),e.root.append(n),this.hidePop(),this.refresh(),n}presentStep(e,t){let n=this.v.root.querySelector(`.dw-cv-step`);n&&(n.textContent=this.v.labels.presentStep.replace(`{n}`,String(e+1)).replace(`{total}`,String(t)))}};function fR(e){let t=getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n,r=n(`--dw-surface`,`#ffffff`),i=e=>{let t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e);if(!t)return null;let n=t[1].length===3?[...t[1]].map(e=>e+e).join(``):t[1];return[0,2,4].map(e=>parseInt(n.slice(e,e+2),16))},a=(e,t,n)=>{let r=i(e),a=i(t);return!r||!a?e:`#${r.map((e,t)=>Math.round(e*n+a[t]*(1-n)).toString(16).padStart(2,`0`)).join(``)}`};return(e,t)=>{if(e===`none`)return`none`;if(e===`ink`)return t===`fill`?n(`--dw-surface-sunken`,`#f3f3f1`):n(`--dw-ink`,`#1d1f1e`);if(e===`paper`)return t===`fill`?n(`--dw-surface-raised`,`#ffffff`):r;let i=n(`--dw-c-${e}`,`#888888`);return t===`fill`?a(i,r,.22):i}}function pR(e){let t=[],n=e=>(e.content??[]).map(e=>e.type===`text`?e.text??``:e.type===`hardBreak`?` -`:n(e)).join(``),r=(e,i)=>{for(let a of e)if(a.type===`heading`){let e=Number(a.attrs?.level)||1;t.push({text:n(a),size:[0,26,21,18,16,16,16][e]??16,weight:650})}else if(a.type===`paragraph`)t.push({text:i+n(a),size:15,weight:400});else if(a.type===`listItem`||a.type===`taskItem`){let e=a.type===`taskItem`?a.attrs?.checked?`☑ `:`☐ `:`• `,[i,...o]=a.content??[];i&&t.push({text:e+n(i),size:15,weight:400}),r(o,` `)}else a.type===`codeBlock`?t.push({text:n(a),size:13,weight:400}):a.content?.length&&r(a.content,i)};return r(e,``),t}function mR(e,t,n,r,i,a,o=400,s=`start`){let c=Math.round(r*1.35);return n.map((n,l)=>`${LL(n)}`).join(``)}async function hR(e){if(e.startsWith(`data:`))return e;try{let t=await fetch(e,{credentials:`include`});if(!t.ok)return null;let n=await t.blob();return await new Promise(e=>{let t=new FileReader;t.onload=()=>e(typeof t.result==`string`?t.result:null),t.onerror=()=>e(null),t.readAsDataURL(n)})}catch{return null}}async function gR(e){let t=fR(e.root),n=e.elements.filter(e=>e.type!==`group`),r=GP(WP(n.map(t=>e.boxOf(t)))??{x:0,y:0,w:400,h:300},32),i=t(`ink`,`line`),a=[];for(let r of n){let n=e.boxOf(r),o=r.rotate?` rotate(${r.rotate} ${n.w/2} ${n.h/2})`:``,s=e=>`${e}`;switch(r.type){case`shape`:{let e=eI(r.text,r.fontSize,Math.max(20,n.w-16)),i=Math.round(r.fontSize*1.35),o=n.h/2-e.length*i/2-r.fontSize*.25;a.push(s(GL(r,t)+(r.text?mR(n.w/2,o,e,r.fontSize,t(r.textColor,`line`),YF,400,`middle`):``)));break}case`text`:{let e=QF(r.font),i=r.w?eI(r.text,r.fontSize,r.w,e):r.text.split(` -`),o=r.align===`center`?n.w/2:r.align===`right`?n.w:0,c=r.align===`center`?`middle`:r.align===`right`?`end`:`start`;a.push(s(mR(o,0,i,r.fontSize,t(r.color,`line`),e,r.bold?650:400,c)));break}case`connector`:{let n=e.routeOf(r);if(a.push(qL(r,n,t)),r.label){let e=Math.min(240,r.label.length*8+16);a.push(``+mR(n.mid[0],n.mid[1]-12+3,[r.label],13,i,YF,400,`middle`))}break}case`brush`:a.push(s(YL(r,t)));break;case`frame`:a.push(s(``+mR(4,-24,[r.title],13,t(`gray`,`line`),YF,600)));break;case`note`:{let o=e.noteBody(r),c=o?pR(XL(o)):[],l=18,u=``;if(r.page&&e.pageTitle){let t=eI(e.pageTitle,26,n.w-48,YF,650);u+=mR(24,l-4,t,26,i,YF,650),l+=t.length*35+8}for(let e of c){let t=eI(e.text,e.size,n.w-48,YF,e.weight);if(u+=mR(24,l,t,e.size,i,YF,e.weight),l+=t.length*Math.round(e.size*1.35)+8,l>n.h-12)break}a.push(s(u));break}case`image`:{let i=await hR(e.resolve(r.src));a.push(s(i?``:``));break}case`embed`:a.push(s(``+mR(16,16,eI(r.url,13,n.w-32),13,t(`blue`,`line`),YF)));break;case`mindmap`:{let n=e.layoutOf(r),o=t(r.color,`line`),s=t(r.color,`fill`),c=n.edges.map(e=>``).join(``);for(let e of n.boxes.values()){let n=e.depth===0?18:15,a=e.depth===0?600:400,l=e.depth===0?o:e.depth===1?s:t(`paper`,`line`),u=e.depth===0?t(`paper`,`line`):i;c+=``;let d=eI(r.nodes[e.id]?.text||` `,n,260,YF,a);c+=mR(e.x+e.w/2,e.y+(e.h-d.length*Math.round(n*1.4))/2-2,d,n,u,YF,a,`middle`)}a.push(`${c}`);break}}}return{svg:`${a.join(``)}`,box:r}}async function _R(e,t){let{svg:n,box:r}=await gR(t),i=new Blob([n],{type:`image/svg+xml`});if(e===`svg`)return i;let a=Math.min(2,8192/Math.max(r.w,r.h,1)),o=URL.createObjectURL(i);try{let e=await new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=()=>t(Error(`could not draw the canvas`)),n.src=o}),t=document.createElement(`canvas`);t.width=Math.ceil(r.w*a),t.height=Math.ceil(r.h*a);let n=t.getContext(`2d`);if(!n)throw Error(`could not draw the canvas`);return n.drawImage(e,0,0,t.width,t.height),await new Promise((e,n)=>t.toBlob(t=>t?e(t):n(Error(`could not draw the canvas`)),`image/png`))}finally{URL.revokeObjectURL(o)}}var vR=.1,yR=4,bR=`http://www.w3.org/2000/svg`,xR=e=>e instanceof HTMLElement&&(e.isContentEditable||e.tagName===`INPUT`||e.tagName===`TEXTAREA`),SR=class{opts;store;labels;root;styles;editable;tool=`select`;shapeKind;selected=new Set;activeNode=null;editing=null;entered=null;world;overlay;ui;view={x:0,y:0,zoom:1};rendered=new Map;measured=new Map;layouts=new Map;routes=new Map;previews=new Map;drag=null;guides=[];marquee=null;hover=null;raf=0;spaceDown=!1;pointers=new Map;pinch=null;presenting=null;comments=[];activeComment=``;resize=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>this.onResize(e));unsub;cleanups=[];saveTimer;constructor(e,t){this.opts=t,this.labels=t.labels??mF,this.editable=t.editable,this.styles=LF(t.styles),this.shapeKind=this.styles.shape.shape,this.store=new iR(t.doc,{undo:t.undo!==!1}),this.root=document.createElement(`div`),this.root.className=`dw-cv`,this.root.tabIndex=0,this.root.setAttribute(`role`,`application`),this.root.dataset.testid=`edgeless-canvas`,this.world=document.createElement(`div`),this.world.className=`dw-cv-world`,this.overlay=document.createElementNS(bR,`svg`),this.overlay.classList.add(`dw-cv-overlay`),this.root.append(this.world,this.overlay),e.append(this.root),this.ui=new dR(this),this.root.classList.toggle(`dw-cv-readonly`,!this.editable),this.unsub=this.store.onChange(()=>this.schedule()),this.listen(),this.render(),this.restoreView()||this.fit(void 0,!1),this.applyView()}destroy(){cancelAnimationFrame(this.raf),clearTimeout(this.saveTimer),this.saveView(),this.unsub(),this.resize?.disconnect();for(let e of this.cleanups)e();for(let e of this.rendered.values())e.note?.destroy();this.rendered.clear(),this.ui.destroy(),this.store.destroy(),this.root.remove()}setEditable(e){if(e!==this.editable){this.editable=e,this.root.classList.toggle(`dw-cv-readonly`,!e),e||(this.stopEditing(),this.tool=`select`);for(let t of this.rendered.values())t.note?.setEditable(e);this.ui.refresh()}}get(e){return this.store.get(e)}elements(){return this.store.elements()}boxOf(e){switch(e.type){case`note`:{let t=this.measured.get(e.id);return{x:e.x,y:e.y,w:e.w,h:t?.h??e.h}}case`text`:{let t=this.measured.get(e.id);return{x:e.x,y:e.y,w:t?.w??e.w,h:t?.h??e.h}}case`group`:return WP(this.elements().filter(t=>t.group===e.id).map(e=>this.outerBox(e)))??{x:e.x,y:e.y,w:0,h:0};case`mindmap`:{let t=this.layoutOf(e);return{x:e.x+t.bounds.x,y:e.y+t.bounds.y,w:t.bounds.w,h:t.bounds.h}}case`connector`:{let t=this.routeOf(e),n=t.points.map(e=>e[0]),r=t.points.map(e=>e[1]);return JP([Math.min(...n),Math.min(...r)],[Math.max(...n),Math.max(...r)])}default:return{x:e.x,y:e.y,w:e.w,h:e.h}}}outerBox(e){let t=this.boxOf(e);return e.rotate?XP(t,e.rotate):t}layoutOf(e){let t=this.layouts.get(e.id),n=JSON.stringify([e.layout,e.nodes]);return t&&t.key===n||(t=oI(e.nodes,e.layout,tI),t.key=n,this.layouts.set(e.id,t)),t}routeOf(e){let t=rF(e,e=>{let t=this.get(e);return!t||t.type===`connector`?null:{box:this.outerBox(t),ellipse:t.type===`shape`&&t.shape===`ellipse`}});return sF(e.mode,t[0],t[1])}selection(){return[...this.selected].map(e=>this.get(e)).filter(e=>!!e)}expanded(e){let t=new Set,n=this.elements();for(let r of e){t.add(r);for(let e of n)e.group===r&&t.add(e.id)}return[...t]}schedule(){this.raf||=requestAnimationFrame(()=>{this.raf=0,this.render()})}render(){let e=this.elements(),t=new Set,n=null;for(let r of e){t.add(r.id);let e=this.rendered.get(r.id);e&&e.type!==r.type&&(e.note?.destroy(),e.el.remove(),e=void 0),e||(e={el:document.createElement(`div`),key:``,type:r.type},e.el.className=`dw-cv-el dw-cv-${r.type}`,e.el.dataset.id=r.id,this.rendered.set(r.id,e),(r.type===`note`||r.type===`text`)&&this.resize?.observe(e.el));let i=this.keyOf(r);e.key===i||this.editing?.id===r.id&&this.stopEditingFn&&r.type!==`note`||(this.draw(e,r),e.key=i),e.el.classList.toggle(`dw-cv-selected`,this.selected.has(r.id)),e.el.classList.toggle(`dw-cv-editing`,this.editing?.id===r.id);let a=n?n.nextElementSibling:this.world.firstElementChild;a!==e.el&&this.world.insertBefore(e.el,a),n=e.el}for(let[e,n]of this.rendered)t.has(e)||(n.note?.destroy(),this.resize?.unobserve(n.el),n.el.remove(),this.rendered.delete(e),this.measured.delete(e),this.selected.delete(e));this.editing&&!t.has(this.editing.id)&&(this.editing=null),this.drawOverlay(),this.ui.refresh()}keyOf(e){if(e.type===`connector`){let t=this.routeOf(e);return this.routes.set(e.id,t),JSON.stringify(e)+t.d}return e.type===`note`&&e.page?JSON.stringify(e)+(this.opts.pageTitle?.()??``):JSON.stringify(e)}place(e,t,n=0,r=!1){e.style.transform=`translate(${t.x}px, ${t.y}px)${n?` rotate(${n}deg)`:``}`,e.style.width=r?``:`${t.w}px`,e.style.height=r?``:`${t.h}px`}draw(e,t){let n=e.el,r=this.editing?.id===t.id;switch(t.type){case`shape`:{this.place(n,t,t.rotate);let e=r?n.querySelector(`.dw-cv-label`):null;n.innerHTML=`${GL(t,IL)}`;let i=e??document.createElement(`div`);i.className=`dw-cv-label`,e||(i.textContent=t.text),i.style.color=IL(t.textColor,`line`),i.style.fontSize=`${t.fontSize}px`,n.append(i);return}case`text`:{n.style.transform=`translate(${t.x}px, ${t.y}px)${t.rotate?` rotate(${t.rotate}deg)`:``}`,n.style.width=t.w?`${t.w}px`:``,n.style.height=``;let e=n.querySelector(`.dw-cv-textbody`);e||(e=document.createElement(`div`),e.className=`dw-cv-textbody`,n.append(e)),r||(e.textContent=t.text),e.dataset.placeholder=this.labels.textPlaceholder,Object.assign(e.style,{color:IL(t.color,`line`),fontSize:`${t.fontSize}px`,fontFamily:QF(t.font),textAlign:t.align,fontWeight:t.bold?`650`:``,whiteSpace:t.w?`pre-wrap`:`pre`});return}case`connector`:{let e=this.routes.get(t.id)??this.routeOf(t),i=this.boxOf(t),a=24+t.strokeWidth*3,o={x:i.x-a,y:i.y-a,w:i.w+a*2,h:i.h+a*2};this.place(n,o);let s=``,c=t.label||r;n.innerHTML=`${qL(t,e,IL)}${s}`+(c?`
${LL(t.label)}
`:``);return}case`brush`:this.place(n,t,t.rotate),n.innerHTML=`${YL(t,IL).replace(``;return;case`note`:this.drawNote(e,t);return;case`frame`:{this.place(n,t);let e=r?n.querySelector(`.dw-cv-frametitle`):null;n.innerHTML=``;let i=e??document.createElement(`div`);i.className=`dw-cv-frametitle`,e||(i.textContent=t.title||this.labels.frameTitle),n.append(i);return}case`image`:{this.place(n,t,t.rotate);let e=this.opts.files?.resolve(t.src)??t.src,r=n.querySelector(`img`);r||(r=document.createElement(`img`),r.draggable=!1,n.replaceChildren(r)),r.getAttribute(`src`)!==e&&(r.src=e),r.alt=t.alt;return}case`embed`:this.drawEmbed(n,t);return;case`group`:n.style.display=`none`;return;case`mindmap`:this.drawMindmap(n,t);return}}drawNote(e,t){let n=e.el;if(n.style.transform=`translate(${t.x}px, ${t.y}px)`,n.style.width=`${t.w}px`,n.style.height=``,n.style.setProperty(`--dw-cv-note-bg`,IL(t.background,`fill`)),n.classList.toggle(`dw-cv-pagenote`,t.page),!e.note){let r=document.createElement(`div`);r.className=`dw-cv-notehead`;let i=document.createElement(`div`);i.className=`dw-cv-notebody`,n.replaceChildren(r,i);let a=t.page?this.opts.doc.getXmlFragment(`default`):this.store.body(t.id);if(a)try{e.note=this.opts.notes.mount(i,{id:t.id,page:t.page,fragment:a,doc:this.opts.doc,editable:this.editable})}catch(e){this.opts.onError?.(e)}}let r=n.querySelector(`.dw-cv-notehead`);r&&(r.textContent=t.page?this.opts.pageTitle?.()||this.labels.pageNote:``)}drawEmbed(e,t){this.place(e,t);let n=this.opts.embedSource?.(t.url)??null;if(n){if(e.querySelector(`iframe`)?.getAttribute(`src`)===n.src)return;let r=document.createElement(`iframe`);r.src=n.src,r.title=t.url,r.allow=`fullscreen; picture-in-picture; encrypted-media`,r.referrerPolicy=`strict-origin-when-cross-origin`,r.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-popups allow-presentation`),e.replaceChildren(r);return}let r=this.previews.get(t.url);r===void 0&&this.opts.links&&(this.previews.set(t.url,`loading`),this.opts.links.preview(t.url).then(e=>this.previews.set(t.url,e)).catch(()=>this.previews.set(t.url,null)).finally(()=>{let e=this.rendered.get(t.id);e&&(e.key=``),this.schedule()}),r=`loading`);let i=r&&r!==`loading`?r:null,a=t.url;try{a=new URL(t.url).hostname}catch{}let o=i?.image?``:``;e.innerHTML=`${o}${LL(i?.title||a)}${i?.description?`${LL(i.description)}`:``}${LL(i?.site||a)}`}drawMindmap(e,t){let n=this.layoutOf(t),r=n.bounds;this.place(e,{x:t.x+r.x,y:t.y+r.y,w:r.w,h:r.h});let i=IL(t.color,`line`),a=IL(t.color,`fill`),o=n.edges.map(e=>``).join(``),s=this.editing?.id===t.id?this.editing.node:void 0,c=s?e.querySelector(`[data-node="${s}"]`):null,l=[...n.boxes.values()].map(e=>{let n=e.depth===0?`dw-cv-node dw-cv-root`:`dw-cv-node`,o=this.activeNode?.map===t.id&&this.activeNode.node===e.id?` dw-cv-active`:``,s=`left:${e.x-r.x}px;top:${e.y-r.y}px;width:${e.w}px;height:${e.h}px;${e.depth===0?`background:${i};color:var(--dw-surface)`:e.depth===1?`background:${a};border-color:${i}`:`border-color:${i}`}`;return`
${LL(t.nodes[e.id]?.text??``)}
`});e.innerHTML=`${o}${l.join(``)}`,c&&s&&e.querySelector(`[data-node="${s}"]`)?.replaceWith(c)}onResize(e){let t=!1;for(let n of e){let e=n.target,r=e.dataset.id;if(!r)continue;let i={w:e.offsetWidth,h:e.offsetHeight},a=this.measured.get(r);a&&a.w===i.w&&a.h===i.h||(this.measured.set(r,i),t=!0)}if(t){for(let e of this.rendered.values())e.type===`connector`&&(e.key=``);this.schedule()}}toScreen([e,t]){return[e*this.view.zoom+this.view.x,t*this.view.zoom+this.view.y]}toWorld(e,t){let n=this.root.getBoundingClientRect();return[(e-n.left-this.view.x)/this.view.zoom,(t-n.top-this.view.y)/this.view.zoom]}get zoom(){return this.view.zoom}selectionScreenBox(){let e=WP(this.selection().map(e=>this.outerBox(e)));if(!e)return null;let[t,n]=this.toScreen([e.x,e.y]);return{x:t,y:n,w:e.w*this.view.zoom,h:e.h*this.view.zoom}}drawOverlay(){let e=[],t=this.view.zoom,n=(e,t)=>{let n=UP(e);return[[e.x,e.y],[e.x+e.w,e.y],[e.x+e.w,e.y+e.h],[e.x,e.y+e.h]].map(e=>this.toScreen(YP(e,n,t)).join(`,`)).join(` `)};if(this.entered){let t=this.get(this.entered);t&&e.push(``)}if(this.hover&&this.hover!==this.editing?.id){let t=this.get(this.hover);t&&e.push(``)}let r=this.presenting?[]:this.selection();for(let t of r)if(t.type===`connector`){let n=this.routes.get(t.id)??this.routeOf(t);e.push(``)}else e.push(``);if(this.editable&&!this.presenting&&r.length&&!this.editing){let i=r.length===1?r[0]:null;if(i?.type===`connector`){let t=this.routes.get(i.id)??this.routeOf(i);for(let[n,r]of[[`source`,t.points[0]],[`target`,t.points[t.points.length-1]]]){let[t,i]=this.toScreen(r);e.push(``)}}else if(r.some(jF)&&i?.type!==`mindmap`){let a=i?i.rotate:0,o=i?this.boxOf(i):WP(r.map(e=>this.outerBox(e)));r.length>1&&e.push(``);let s=UP(o),c=[[`nw`,[o.x,o.y]],[`n`,[o.x+o.w/2,o.y]],[`ne`,[o.x+o.w,o.y]],[`e`,[o.x+o.w,o.y+o.h/2]],[`se`,[o.x+o.w,o.y+o.h]],[`s`,[o.x+o.w/2,o.y+o.h]],[`sw`,[o.x,o.y+o.h]],[`w`,[o.x,o.y+o.h/2]]],l=i?.type===`note`;for(let[n,r]of c){if(l&&n!==`e`&&n!==`w`||o.w*t<24&&(n===`n`||n===`s`)||o.h*t<24&&(n===`e`||n===`w`))continue;let[i,c]=this.toScreen(YP(r,s,a));e.push(``)}if(i&&MF(i)){let[n,r]=this.toScreen(YP([o.x+o.w/2,o.y-28/t],s,a));e.push(``)}}}if(this.presenting||this.drawComments(e,n),this.marquee){let[n,r]=this.toScreen([this.marquee.x,this.marquee.y]);e.push(``)}for(let t of this.guides){let n=this.toScreen(t.axis===`x`?[t.value,t.from]:[t.from,t.value]),r=this.toScreen(t.axis===`x`?[t.value,t.to]:[t.to,t.value]);e.push(``)}this.overlay.innerHTML=e.join(``),this.ui.place()}applyView(){let{x:e,y:t,zoom:n}=this.view;this.world.style.transform=`translate(${e}px, ${t}px) scale(${n})`;let r=24*n;this.root.style.backgroundSize=`${r}px ${r}px`,this.root.style.backgroundPosition=`${e}px ${t}px`,this.root.style.setProperty(`--dw-cv-zoom`,String(n)),this.drawOverlay(),this.ui.zoomChanged(),clearTimeout(this.saveTimer),this.saveTimer=setTimeout(()=>this.saveView(),500)}saveView(){if(this.opts.viewKey)try{localStorage.setItem(this.opts.viewKey,JSON.stringify(this.view))}catch{}}restoreView(){if(!this.opts.viewKey)return!1;try{let e=JSON.parse(localStorage.getItem(this.opts.viewKey)??`null`);if(e&&[e.x,e.y,e.zoom].every(e=>typeof e==`number`&&Number.isFinite(e))&&e.zoom>0)return this.view={x:e.x,y:e.y,zoom:Math.min(yR,Math.max(vR,e.zoom))},!0}catch{}return!1}zoomAt(e,t){let n=Math.min(yR,Math.max(vR,e)),r=this.root.getBoundingClientRect(),[i,a]=t??[r.width/2,r.height/2],o=(i-this.view.x)/this.view.zoom,s=(a-this.view.y)/this.view.zoom;this.view={zoom:n,x:i-o*n,y:a-s*n},this.applyView()}zoomBy(e){this.zoomAt(this.view.zoom*e)}fit(e,t=!0,n=48){let r=e??WP(this.elements().map(e=>this.outerBox(e))),i=this.root.getBoundingClientRect(),a=i.width||800,o=i.height||600;if(!r)this.view={x:a/2,y:o/3,zoom:1};else{let t=Math.min(yR,Math.max(vR,Math.min((a-n*2)/Math.max(r.w,1),(o-n*2)/Math.max(r.h,1),e?yR:1)));this.view={zoom:t,x:a/2-(r.x+r.w/2)*t,y:o/2-(r.y+r.h/2)*t},!e&&r.h*t>o&&(this.view.y=n-r.y*t)}t&&this.applyView()}animateTo(e){let t={...this.view},n=performance.now(),r=i=>{let a=Math.min(1,(i-n)/350),o=1-(1-a)**3;this.view={x:t.x+(e.x-t.x)*o,y:t.y+(e.y-t.y)*o,zoom:t.zoom+(e.zoom-t.zoom)*o},this.applyView(),a<1&&requestAnimationFrame(r)};requestAnimationFrame(r)}setTool(e){(this.editable||e===`select`||e===`hand`)&&(this.stopEditing(),this.tool=e,e!==`select`&&this.clearSelection(),this.root.dataset.tool=e,this.ui.refresh())}setShapeKind(e){this.shapeKind=e,this.setStyle(`shape`,{shape:e}),this.setTool(`shape`)}setStyle(e,t){this.styles={...this.styles,[e]:{...this.styles[e],...t}},this.opts.onStyles?.(this.styles)}restyle(e){let t=[];for(let n of this.selection()){let r=Object.fromEntries(Object.entries(e).filter(([e])=>e in n));if(!Object.keys(r).length)continue;t.push([n.id,r]);let i=n.type;if(i in this.styles){let e=Object.fromEntries(Object.entries(r).filter(([e])=>e in this.styles[i]));Object.keys(e).length&&!(n.type===`note`&&n.page)&&this.setStyle(i,e)}}this.store.updateMany(t)}select(e,t=!1){t||this.selected.clear();for(let t of e)this.selected.add(t);this.activeNode&&!this.selected.has(this.activeNode.map)&&(this.activeNode=null),this.refreshSelection()}clearSelection(){(this.selected.size||this.activeNode||this.entered)&&(this.selected.clear(),this.activeNode=null,this.entered=null,this.refreshSelection())}refreshSelection(){for(let[e,t]of this.rendered)t.el.classList.toggle(`dw-cv-selected`,this.selected.has(e)),t.type===`mindmap`&&(t.key=``);this.schedule(),this.drawOverlay(),this.ui.refresh()}pick(e){let t=this.get(e);return t?.group&&this.entered!==t.group&&this.get(t.group)?t.group:e}hit(e){if(!(e instanceof Element)||!this.world.contains(e))return null;let t=e.closest(`[data-id]`);if(!t?.dataset.id)return null;let n=e.closest(`[data-node]`)?.dataset.node;return{id:t.dataset.id,node:n}}connectableAt(e,t,n){for(let r of document.elementsFromPoint(e,t)){let e=this.hit(r);if(!e||n.has(e.id))continue;let t=this.get(e.id);if(t&&NF(t))return t}return null}listen(){let e=(e,t,n,r)=>{e.addEventListener(t,n,r),this.cleanups.push(()=>e.removeEventListener(t,n,r))};e(this.root,`pointerdown`,e=>this.onDown(e)),e(this.root,`pointermove`,e=>this.onMove(e)),e(this.root,`pointerup`,e=>this.onUp(e)),e(this.root,`pointercancel`,e=>this.onUp(e)),e(this.root,`dblclick`,e=>this.onDouble(e)),e(this.root,`wheel`,e=>this.onWheel(e),{passive:!1}),e(this.root,`keydown`,e=>this.onKey(e)),e(this.root,`keyup`,e=>{e.key===` `&&(this.spaceDown=!1,this.root.classList.remove(`dw-cv-panning`))}),e(document,`copy`,e=>this.onCopy(e,!1)),e(document,`cut`,e=>this.onCopy(e,!0)),e(document,`paste`,e=>this.onPaste(e)),e(this.root,`dragover`,e=>{this.editable&&e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()}),e(this.root,`drop`,e=>{let t=[...e.dataTransfer?.files??[]].filter(e=>e.type.startsWith(`image/`));this.editable&&t.length&&(e.preventDefault(),this.addImages(t,this.toWorld(e.clientX,e.clientY)))}),e(document,`fullscreenchange`,()=>{!document.fullscreenElement&&this.presenting&&this.stopPresenting()}),e(this.root,`click`,e=>{e.target.closest?.(`a.dw-cv-card`)&&this.editable&&e.preventDefault()})}inEditor(e){if(!(e instanceof Element))return!1;if(e.closest(`.dw-cv-ui`))return!0;if(this.editing){let t=this.rendered.get(this.editing.id);if(t&&t.el.contains(e)&&(e.closest(`[contenteditable=true]`)||e.closest(`.dw-cv-notebody`)||e.closest(`iframe`)))return!0}return!(this.editable||!e.closest(`.dw-cv-notebody, a.dw-cv-card`))}onDown(e){let t=e.target instanceof Element?e.target.closest(`[data-comment]`):null;if(t?.dataset.comment){e.preventDefault(),this.opts.onCommentSelect?.(t.dataset.comment);return}if(this.inEditor(e.target)||e.button===2)return;if(e.preventDefault(),this.root.focus({preventScroll:!0}),this.pointers.set(e.pointerId,[e.clientX,e.clientY]),this.pointers.size===2){this.cancelDrag();let[e,t]=[...this.pointers.values()],n=this.root.getBoundingClientRect();this.pinch={dist:Math.hypot(e[0]-t[0],e[1]-t[1]),mid:[(e[0]+t[0])/2-n.left,(e[1]+t[1])/2-n.top],zoom:this.view.zoom,vx:this.view.x,vy:this.view.y};return}if(this.pointers.size>2)return;this.editing&&this.stopEditing();let n=this.toWorld(e.clientX,e.clientY),r=e.pointerType===`touch`,i=()=>{this.drag={kind:`pan`,sx:e.clientX,sy:e.clientY,vx:this.view.x,vy:this.view.y},this.root.classList.add(`dw-cv-panning`)};if(this.root.setPointerCapture?.(e.pointerId),e.button===1||this.tool===`hand`||this.spaceDown||this.presenting)return e.preventDefault(),i();let a=e.target;if(!this.editable){let e=this.opts.onComment&&this.tool===`select`?this.hit(a):null;if(e){let t=this.pick(e.id);this.select([t]);return}return i()}switch(this.tool){case`pen`:{let t=document.createElementNS(bR,`svg`);t.classList.add(`dw-cv-temp`),this.world.append(t),this.drag={kind:`pen`,points:[[n[0],n[1],e.pressure||.5]],temp:t};return}case`eraser`:this.drag={kind:`erase`,hits:new Set},this.erase(e);return;case`shape`:case`frame`:this.drag={kind:`create`,type:this.tool,start:n,id:null};return;case`connector`:{let t=this.connectableAt(e.clientX,e.clientY,new Set),r=t?this.endOn(t,n):{x:n[0],y:n[1]},i=this.store.add({type:`connector`,...this.styles.connector,source:r,target:{x:n[0],y:n[1]}});this.drag={kind:`end`,id:i,side:`target`};return}case`note`:this.addNote(n);return;case`text`:this.addText(n);return;case`mindmap`:this.addMindmap(n);return}let o=a.dataset?.handle,s=a.dataset?.end;if(s){let e=this.selection()[0];e?.type===`connector`&&(this.store.undo?.stopCapturing(),this.drag={kind:`end`,id:e.id,side:s});return}if(o===`rotate`){let e=this.selection()[0],t=UP(this.boxOf(e));this.store.undo?.stopCapturing(),this.drag={kind:`rotate`,id:e.id,c:t,a0:Math.atan2(n[1]-t[1],n[0]-t[0]),r0:e.rotate};return}if(o){let e=this.selection(),t=e.length===1?e[0]:null,n=new Map(this.expanded(this.selected).map(e=>[e,this.get(e)]));for(let[e,t]of n){let r=this.measured.get(e);t.type===`text`&&r&&n.set(e,{...t,w:r.w,h:r.h}),t.type===`note`&&r&&n.set(e,{...t,h:r.h})}this.store.undo?.stopCapturing(),this.drag={kind:`resize`,handle:o,box:t?this.boxOf(t):WP(e.map(e=>this.outerBox(e))),deg:t?t.rotate:0,orig:n,keep:e.some(e=>e.type===`image`||e.type===`text`||e.type===`brush`)||e.length>1};return}let c=this.hit(a);if(c){let t=this.pick(c.id),r=this.get(t);if(r?.type===`mindmap`&&c.node){this.activeNode={map:t,node:c.node};let e=this.rendered.get(t);e&&(e.key=``)}else r?.type!==`mindmap`&&(this.activeNode=null);e.shiftKey?(this.selected.has(t)?this.selected.delete(t):this.selected.add(t),this.refreshSelection()):this.selected.has(t)?this.refreshSelection():this.select([t]),this.startMove(n,t)}else{if(r)return i();this.entered=null,this.drag={kind:`marquee`,start:n,add:e.shiftKey,base:e.shiftKey?new Set(this.selected):new Set},e.shiftKey||this.clearSelection()}}startMove(e,t){let n=this.expanded(this.selected);for(let e of[...n]){let t=this.get(e);if(t?.type===`frame`)for(let e of this.elements())e.type!==`frame`&&!n.includes(e.id)&&qP(t,this.outerBox(e))&&n.push(...this.expanded([e.id]))}let r=[...new Set(n)].filter(e=>this.get(e)?.type!==`group`),i=new Map(r.map(e=>[e,this.get(e)])),a=WP(r.map(e=>this.outerBox(this.get(e))))??{x:e[0],y:e[1],w:0,h:0};this.store.undo?.stopCapturing(),this.drag={kind:`move`,start:e,ids:r,orig:i,box:a,moved:!1,clickId:t}}endOn(e,t){let n=this.outerBox(e),r=pF(n,t,14/this.view.zoom);return r?{id:e.id,pos:[(r[0]-n.x)/Math.max(n.w,1),(r[1]-n.y)/Math.max(n.h,1)]}:{id:e.id}}onMove(e){if(this.pointers.has(e.pointerId)&&this.pointers.set(e.pointerId,[e.clientX,e.clientY]),this.pinch&&this.pointers.size>=2){let[e,t]=[...this.pointers.values()],n=this.root.getBoundingClientRect(),r=Math.hypot(e[0]-t[0],e[1]-t[1]),i=[(e[0]+t[0])/2-n.left,(e[1]+t[1])/2-n.top],a=this.pinch,o=Math.min(yR,Math.max(vR,a.zoom*r/Math.max(a.dist,1))),s=(a.mid[0]-a.vx)/a.zoom,c=(a.mid[1]-a.vy)/a.zoom;this.view={zoom:o,x:i[0]-s*o,y:i[1]-c*o},this.applyView();return}let t=this.drag,n=this.toWorld(e.clientX,e.clientY);if(t)switch(t.kind){case`pan`:this.view={...this.view,x:t.vx+e.clientX-t.sx,y:t.vy+e.clientY-t.sy},this.applyView();return;case`move`:{let r=n[0]-t.start[0],i=n[1]-t.start[1];if(!t.moved&&Math.hypot(r,i)*this.view.zoom<3)return;if(t.moved=!0,e.altKey)this.guides=[];else{let e=new Set(t.ids),n=this.visibleBoxes().filter(([t])=>!e.has(t)).map(([,e])=>e),a=fF({...t.box,x:t.box.x+r,y:t.box.y+i},n,6/this.view.zoom);r+=a.dx,i+=a.dy,this.guides=a.guides}let a=[];for(let[e,n]of t.orig)if(n.type===`connector`){let t={};for(let e of[`source`,`target`]){let a=n[e];a.id||(t[e]={x:(a.x??0)+r,y:(a.y??0)+i})}Object.keys(t).length&&a.push([e,t])}else a.push([e,{x:n.x+r,y:n.y+i}]);this.store.updateMany(a);return}case`marquee`:{this.marquee=JP(t.start,n);let e=new Set(t.base),r=this.marquee;for(let t of this.elements()){if(t.group&&this.get(t.group))continue;let n=this.outerBox(t);(t.type===`frame`?qP(r,n):KP(r,n))&&e.add(t.id)}for(let t of this.elements().filter(e=>e.type===`group`))KP(r,this.boxOf(t))&&e.add(t.id);this.selected.clear();for(let t of e)this.selected.add(t);this.refreshSelection();return}case`resize`:this.doResize(t,n,e.shiftKey);return;case`rotate`:{let r=t.r0+(Math.atan2(n[1]-t.c[1],n[0]-t.c[0])-t.a0)*180/Math.PI;e.shiftKey&&(r=Math.round(r/15)*15),r=(r%360+360)%360,this.store.update(t.id,{rotate:Math.round(r*10)/10});return}case`create`:{let r=JP(t.start,n);if(!t.id&&r.w*this.view.zoom<4&&r.h*this.view.zoom<4)return;e.shiftKey&&(r.w=r.h=Math.max(r.w,r.h)),t.id?this.store.update(t.id,{...r}):t.id=t.type===`shape`?this.store.add({type:`shape`,...this.styles.shape,shape:this.shapeKind,...r}):this.store.add({type:`frame`,...this.styles.frame,title:this.frameName(),...r});return}case`end`:{let r=this.get(t.id);if(r?.type!==`connector`)return;let i=r[t.side===`source`?`target`:`source`],a=new Set([t.id]),o=this.connectableAt(e.clientX,e.clientY,a);this.hover=o?.id??null;let s=o&&o.id!==i.id?this.endOn(o,n):{x:n[0],y:n[1]};this.store.update(t.id,{[t.side]:s});return}case`pen`:t.points.push([n[0],n[1],e.pressure||.5]),t.temp.innerHTML=``;return;case`erase`:this.erase(e);return}else if(this.editable&&this.tool===`connector`){let t=this.connectableAt(e.clientX,e.clientY,new Set);(t?.id??null)!==this.hover&&(this.hover=t?.id??null,this.drawOverlay())}}erase(e){let t=this.drag;if(t?.kind!==`erase`)return;let n=this.toWorld(e.clientX,e.clientY),r=6/this.view.zoom;for(let n of document.elementsFromPoint(e.clientX,e.clientY)){let e=this.hit(n);if(!e)continue;let r=this.get(e.id);r&&r.type!==`note`&&r.type!==`frame`&&(t.hits.add(r.id),this.rendered.get(r.id)?.el.classList.add(`dw-cv-erasing`))}for(let e of this.elements())e.type!==`brush`||t.hits.has(e.id)||QP(n,e.points.map(t=>[t[0]+e.x,t[1]+e.y]))<=r+e.size/2&&(t.hits.add(e.id),this.rendered.get(e.id)?.el.classList.add(`dw-cv-erasing`))}doResize(e,t,n){let r=e.box,i=UP(r),a=YP(t,i,-e.deg),o=r.x,s=r.y,c=r.x+r.w,l=r.y+r.h;e.handle.includes(`w`)&&(o=a[0]),e.handle.includes(`e`)&&(c=a[0]),e.handle.includes(`n`)&&(s=a[1]),e.handle.includes(`s`)&&(l=a[1]);let u=8/this.view.zoom;c-o[e[0]*m,e[1]*h,e[2]??.5])}]);break;case`mindmap`:case`group`:v.push([t,{x:e,y:i}]);break;default:v.push([t,{x:e,y:i,w:n.w*m,h:n.h*h}])}}this.store.updateMany(v)}visibleBoxes(){let e=this.root.getBoundingClientRect(),t=JP(this.toWorld(e.left,e.top),this.toWorld(e.right,e.bottom)),n=[];for(let e of this.elements()){if(e.type===`connector`||e.type===`group`)continue;let r=this.outerBox(e);if(KP(t,r)&&n.push([e.id,r]),n.length>300)break}return n}onUp(e){if(this.pointers.delete(e.pointerId),this.pinch){this.pointers.size<2&&(this.pinch=null);return}let t=this.drag;if(this.drag=null,this.root.classList.remove(`dw-cv-panning`),this.guides=[],this.marquee=null,this.hover=null,!t)return;let n=this.toWorld(e.clientX,e.clientY);switch(t.kind){case`create`:{let e=t.id;if(!e){let r=t.type===`frame`?{w:800,h:600}:{w:140,h:100},i={x:n[0]-r.w/2,y:n[1]-r.h/2,...r};e=t.type===`shape`?this.store.add({type:`shape`,...this.styles.shape,shape:this.shapeKind,...i}):this.store.add({type:`frame`,...this.styles.frame,title:this.frameName(),...i})}this.tool=`select`,this.root.dataset.tool=`select`,this.select([e]);break}case`end`:{let e=this.get(t.id);if(e?.type===`connector`){let n=this.routeOf(e),r=n.points[0],i=n.points[n.points.length-1];Math.hypot(r[0]-i[0],r[1]-i[1])*this.view.zoom<8&&this.tool===`connector`?this.store.remove([t.id]):this.tool===`connector`&&this.select([t.id])}break}case`pen`:{t.temp.remove(),t.points.length<2&&t.points.push([t.points[0][0]+.5,t.points[0][1]+.5,.5]);let e=t.points.map(e=>e[0]),n=t.points.map(e=>e[1]),r=this.styles.brush.size,i=Math.min(...e)-r,a=Math.min(...n)-r,o=Math.max(...e)+r-i,s=Math.max(...n)+r-a;this.store.add({type:`brush`,...this.styles.brush,x:i,y:a,w:o,h:s,points:t.points.map(e=>[Math.round((e[0]-i)*10)/10,Math.round((e[1]-a)*10)/10,Math.round((e[2]??.5)*100)/100])});break}case`erase`:for(let e of t.hits)this.rendered.get(e)?.el.classList.remove(`dw-cv-erasing`);t.hits.size&&this.store.remove(t.hits)}this.drawOverlay(),this.ui.refresh()}cancelDrag(){let e=this.drag;e?.kind===`pen`&&e.temp.remove(),this.drag=null,this.marquee=null,this.guides=[]}onDouble(e){if(this.inEditor(e.target)||!this.editable||this.tool!==`select`)return;let t=this.hit(e.target);if(!t){this.addText(this.toWorld(e.clientX,e.clientY));return}let n=this.get(t.id);n&&(n.group&&this.entered!==n.group&&this.get(n.group)?(this.entered=n.group,this.select([n.id])):(n.type!==`frame`||e.target.closest(`.dw-cv-frametitle`))&&this.startEdit(n.id,t.node))}onWheel(e){if(this.presenting||e.target instanceof Element&&e.target.closest(`.dw-cv-ui`))return;e.preventDefault();let t=this.root.getBoundingClientRect();if(e.ctrlKey||e.metaKey){this.zoomAt(this.view.zoom*Math.exp(-e.deltaY*.01),[e.clientX-t.left,e.clientY-t.top]);return}let n=e.deltaMode===1?16:1,r=e.shiftKey&&!e.deltaX?e.deltaY:e.deltaX,i=e.shiftKey&&!e.deltaX?0:e.deltaY;this.view={...this.view,x:this.view.x-r*n,y:this.view.y-i*n},this.applyView()}onKey(e){if(this.presenting){this.presentKey(e);return}if(xR(e.target)||this.inEditor(e.target))return;let t=e.ctrlKey||e.metaKey,n=e.key.toLowerCase();if(e.key===` `&&!t){this.spaceDown=!0,this.root.classList.add(`dw-cv-panning`),e.preventDefault();return}if(t&&(n===`=`||n===`+`))return e.preventDefault(),this.zoomBy(1.25);if(t&&n===`-`)return e.preventDefault(),this.zoomBy(.8);if(e.altKey&&!t&&(e.code===`Digit0`||e.code===`Digit1`||e.code===`Digit2`)){if(e.preventDefault(),e.code===`Digit0`)return this.zoomAt(1);if(e.code===`Digit1`)return this.fit();let t=WP(this.selection().map(e=>this.outerBox(e)));return this.fit(t??void 0)}if(e.key===`Escape`){this.entered?(this.select([this.entered]),this.entered=null):this.selected.size?this.clearSelection():this.setTool(`select`);return}if(!this.editable){!t&&n===`h`&&this.setTool(`hand`),!t&&n===`v`&&this.setTool(`select`);return}if(this.activeNode&&this.mindmapKey(e))return;if(t&&n===`z`){e.preventDefault(),e.shiftKey?this.store.undo?.redo():this.store.undo?.undo();return}if(t&&n===`y`){e.preventDefault(),this.store.undo?.redo();return}if(t&&n===`a`){e.preventDefault(),this.select(this.elements().filter(e=>!e.group||!this.get(e.group)).map(e=>e.id));return}if(t&&n===`d`){e.preventDefault(),this.duplicate();return}if(t&&n===`g`){e.preventDefault(),e.shiftKey?this.ungroup():this.group();return}if((e.key===`Delete`||e.key===`Backspace`)&&this.selected.size){e.preventDefault(),this.deleteSelection();return}if(e.key===`Enter`&&this.selected.size===1){e.preventDefault();let t=[...this.selected][0];this.startEdit(t);return}if(e.key.startsWith(`Arrow`)&&this.selected.size){e.preventDefault();let t=e.shiftKey?10:1,n=e.key===`ArrowLeft`?-t:e.key===`ArrowRight`?t:0,r=e.key===`ArrowUp`?-t:e.key===`ArrowDown`?t:0;this.nudge(n,r);return}if(t||e.altKey)return;let r={v:`select`,h:`hand`,n:`note`,t:`text`,s:`shape`,c:`connector`,p:`pen`,e:`eraser`,f:`frame`,m:`mindmap`};r[n]?(e.preventDefault(),this.setTool(r[n])):n===`i`?this.ui.pickImage():n===`l`&&this.addLink()}nudge(e,t){let n=this.expanded(this.selected),r=[];for(let i of n){let n=this.get(i);if(n&&n.type!==`group`){if(n.type===`connector`){let a={};for(let r of[`source`,`target`]){let i=n[r];i.id||(a[r]={x:(i.x??0)+e,y:(i.y??0)+t})}r.push([i,a])}else r.push([i,{x:n.x+e,y:n.y+t}])}}this.store.updateMany(r)}startEdit(e,t){if(!this.editable)return;let n=this.get(e),r=this.rendered.get(e);if(n&&r){if(n.type===`group`)this.entered=e;else if(n.type===`mindmap`){let i=t??(this.activeNode?.map===e?this.activeNode.node:iI(n.nodes));if(!i)return;this.activeNode={map:e,node:i},this.editing={id:e,node:i},this.draw(r,n);let a=r.el.querySelector(`[data-node="${i}"]`);a&&this.editText(a,n.nodes[i]?.text??``,!0,t=>this.store.updateNode(e,i,{text:t}))}else if(n.type!==`image`&&n.type!==`brush`)switch(this.select([e]),this.editing={id:e,node:t},r.el.classList.add(`dw-cv-editing`),this.drawOverlay(),this.ui.refresh(),n.type){case`note`:r.note?.focus();return;case`embed`:return;case`text`:{let t=r.el.querySelector(`.dw-cv-textbody`);t&&this.editText(t,n.text,!1,t=>t.trim()?this.store.update(e,{text:t}):this.store.remove([e]));return}case`shape`:{let t=r.el.querySelector(`.dw-cv-label`);t&&this.editText(t,n.text,!1,t=>this.store.update(e,{text:t}));return}case`frame`:{let t=r.el.querySelector(`.dw-cv-frametitle`);t&&this.editText(t,n.title,!0,t=>this.store.update(e,{title:t}));return}case`connector`:{this.draw(r,n);let t=r.el.querySelector(`.dw-cv-clabel`);t&&this.editText(t,n.label,!0,t=>this.store.update(e,{label:t}));return}}}}editText(e,t,n,r){e.contentEditable=`true`,e.spellcheck=!0,e.textContent=t,e.classList.add(`dw-cv-typing`);let i=!1,a=n=>{if(i)return;i=!0,this.stopEditingFn=null,e.contentEditable=`false`,e.classList.remove(`dw-cv-typing`),e.removeEventListener(`keydown`,o),e.removeEventListener(`blur`,s),e.removeEventListener(`paste`,c);let a=(e.innerText??e.textContent??``).replace(/\n$/,``),l=this.editing?.id;if(this.editing=null,(n&&a!==t||n&&!a.trim())&&r(a),l){let e=this.rendered.get(l);e&&(e.key=``)}this.schedule(),this.ui.refresh()},o=e=>{e.stopPropagation(),e.key===`Escape`||e.key===`Enter`&&(n||e.ctrlKey||e.metaKey)&&!e.shiftKey?(e.preventDefault(),a(!0),this.root.focus({preventScroll:!0})):e.key===`Tab`&&this.activeNode&&(e.preventDefault(),a(!0),this.mindmapAdd(`child`))},s=()=>a(!0),c=e=>{e.preventDefault(),e.stopPropagation(),document.execCommand(`insertText`,!1,e.clipboardData?.getData(`text/plain`)??``)};e.addEventListener(`keydown`,o),e.addEventListener(`blur`,s),e.addEventListener(`paste`,c),this.stopEditingFn=()=>a(!0),e.focus({preventScroll:!0});let l=document.createRange();l.selectNodeContents(e);let u=getSelection();u?.removeAllRanges(),u?.addRange(l)}stopEditingFn=null;stopEditing(){let e=this.stopEditingFn;if(this.stopEditingFn=null,e?.(),this.editing){let e=this.rendered.get(this.editing.id);e?.el.classList.remove(`dw-cv-editing`),e?.note&&document.activeElement&&e.el.contains(document.activeElement)&&document.activeElement.blur(),this.editing=null,this.drawOverlay(),this.ui.refresh()}}frameName(){let e=this.elements().filter(e=>e.type===`frame`).length+1;return`${this.labels.frameTitle} ${e}`}addNote(e){let t=this.store.add({type:`note`,...this.styles.note,x:e[0]-24,y:e[1]-24,w:320,h:120});this.setTool(`select`),this.select([t]),this.render(),this.startEdit(t)}addText(e){let t=this.store.add({type:`text`,...this.styles.text,x:e[0],y:e[1]-this.styles.text.fontSize*.7,w:0,h:0,text:``});this.setTool(`select`),this.render(),this.startEdit(t)}addMindmap(e){let t=`r${Date.now().toString(36)}`,n=this.store.add({type:`mindmap`,...this.styles.mindmap,x:e[0],y:e[1],nodes:{[t]:{text:this.labels.centralIdea,parent:``,pos:0}}});this.setTool(`select`),this.select([n]),this.activeNode={map:n,node:t},this.render(),this.startEdit(n,t)}viewCentre(){let e=this.root.getBoundingClientRect();return this.toWorld(e.left+e.width/2,e.top+e.height/2)}async addImages(e,t){let n=this.opts.files?.upload;if(!n)return;let[r,i]=t??this.viewCentre(),a=[];for(let t of e)try{let e=await n.call(this.opts.files,t),o=await CR(this.opts.files?.resolve(e.url)??e.url),s=Math.min(1,480/Math.max(o.w,1)),c=o.w*s,l=o.h*s;a.push(this.store.add({type:`image`,src:e.url,alt:e.name,x:r-c/2,y:i-l/2,w:c,h:l})),r+=24,i+=24}catch(e){this.opts.onError?.(e)}a.length&&this.select(a)}async addLink(e,t){let n=(e??window.prompt(this.labels.linkPrompt,`https://`))?.trim();if(!n||!/^https?:\/\//i.test(n))return;let[r,i]=t??this.viewCentre(),a=this.opts.embedSource?.(n),o=a?560:380,s=a?a.ratio===`video`?315:420:120,c=this.store.add({type:`embed`,url:n,x:r-o/2,y:i-s/2,w:o,h:s});this.setTool(`select`),this.select([c])}insertElements(e){let t=WP(e.map(e=>({x:Number(e.x)||0,y:Number(e.y)||0,w:Number(e.w)||0,h:Number(e.h)||0})))??{x:0,y:0,w:0,h:0},[n,r]=this.viewCentre(),i=this.store.insertJSON(e,n-(t.x+t.w/2),r-(t.y+t.h/2));this.setTool(`select`),this.select(i.filter(e=>!i.includes(this.get(e)?.group??``)))}insertSticker(e){this.insertElements(zF(e))}insertTemplate(e){this.insertElements(KF(e,this.labels))}deleteSelection(){let e=[...this.selected];this.clearSelection(),this.store.remove(e)}duplicate(){let e=this.store.toJSON(this.selected);if(!e.length)return;let t=this.store.insertJSON(e,24,24);this.select(t.filter(e=>!this.get(e)?.group||!t.includes(this.get(e).group)))}group(){let e=this.store.groupOf([...this.selected]);e&&this.select([e])}ungroup(){let e=this.selection().filter(e=>e.type===`group`),t=e.flatMap(e=>this.store.ungroup(e.id));e.length&&this.select(t)}reorder(e){this.store.reorder(this.expanded(this.selected),e)}mindmapAdd(e){let t=this.activeNode,n=t?this.get(t.map):void 0;if(!t||n?.type!==`mindmap`)return;let r=n.nodes[t.node];if(!r)return;let i=e===`child`||!r.parent?t.node:r.parent,a=aI(n.nodes,i),o;if(e===`sibling`&&r.parent){let e=a.indexOf(t.node),r=n.nodes[a[e]]?.pos??0;o=(r+(a[e+1]?n.nodes[a[e+1]]?.pos??r+2:r+2))/2}else o=a.length?Math.max(...a.map(e=>n.nodes[e]?.pos??0))+1:0;let s=this.store.addNode(t.map,i,o,``);this.activeNode={map:t.map,node:s},this.render(),this.startEdit(t.map,s)}mindmapKey(e){let t=this.activeNode,n=this.get(t.map);if(n?.type!==`mindmap`||!this.selected.has(t.map))return!1;if(e.key===`Tab`)return e.preventDefault(),this.mindmapAdd(`child`),!0;if(e.key===`Enter`)return e.preventDefault(),this.mindmapAdd(`sibling`),!0;if(e.key===`F2`)return e.preventDefault(),this.startEdit(t.map,t.node),!0;if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault();let r=n.nodes[t.node]?.parent;return this.store.removeNode(t.map,t.node),this.activeNode=r?{map:t.map,node:r}:null,this.schedule(),!0}if(e.key.startsWith(`Arrow`)&&!e.shiftKey){e.preventDefault();let r=sI(this.layoutOf(n),n.nodes,t.node,e.key);if(r){this.activeNode={map:t.map,node:r};let e=this.rendered.get(t.map);e&&(e.key=``),this.schedule()}return!0}return!1}owns(){let e=document.activeElement;return!!e&&(e===this.root||this.root.contains(e)&&!xR(e)&&!this.inEditor(e))}onCopy(e,t){if(!this.owns()||!this.selected.size||getSelection()?.toString())return;let n=this.store.toJSON(this.selected);e.clipboardData?.setData(`text/plain`,`docwell-canvas:${JSON.stringify(n)}`),e.preventDefault(),t&&this.editable&&this.deleteSelection()}onPaste(e){if(!this.editable||!this.owns())return;let t=[...e.clipboardData?.files??[]].filter(e=>e.type.startsWith(`image/`));if(t.length){e.preventDefault(),this.addImages(t);return}let n=e.clipboardData?.getData(`text/plain`)??``;if(!n)return;if(e.preventDefault(),n.startsWith(`docwell-canvas:`)){try{let e=JSON.parse(n.slice(15));Array.isArray(e)&&this.insertElements(e)}catch{}return}if(/^https?:\/\/\S+$/i.test(n.trim())){this.addLink(n.trim());return}let[r,i]=this.viewCentre(),a=this.store.add({type:`text`,...this.styles.text,x:r,y:i,w:n.length>60?480:0,h:0,text:n});this.select([a])}setComments(e,t=``){this.comments=e;let n=t!==this.activeComment;this.activeComment=t;let r=t?e.find(e=>e.comment===t):void 0;n&&r&&this.reveal(r.element),this.drawOverlay()}reveal(e){let t=this.get(e);if(!t)return;let n=this.outerBox(t),r=this.root.getBoundingClientRect(),[i,a]=this.toScreen([n.x,n.y]),[o,s]=this.toScreen([n.x+n.w,n.y+n.h]);if(i>=0&&a>=0&&o<=r.width&&s<=r.height)return;let c={...this.view};if(n.w*c.zoome.comment===this.activeComment);o&&e.push(``);let[s,c]=this.toScreen([a.x+a.w,a.y]),l=(o??i[0]).comment;e.push(`${LL(this.labels.comment)}${i.length}`)}}async exportImage(e,t=!1){let n=t&&this.selected.size?new Set(this.expanded(this.selected)):null,r=this.elements().filter(e=>!n||n.has(e.id));return _R(e,{root:this.root,elements:r,boxOf:e=>this.boxOf(e),routeOf:e=>this.routes.get(e.id)??this.routeOf(e),layoutOf:e=>this.layoutOf(e),noteBody:e=>e.page?this.opts.doc.getXmlFragment(`default`):this.store.body(e.id),pageTitle:this.opts.pageTitle?.()??``,resolve:e=>this.opts.files?.resolve(e)??e})}frames(){return this.elements().filter(e=>e.type===`frame`).sort((e,t)=>t.index-e.index)}present(){let e=this.frames().map(e=>e.id);if(!e.length){this.ui.toast(this.labels.presentNoFrames);return}this.stopEditing(),this.clearSelection();let t=this.ui.presentBar();this.presenting={frames:e,at:0,bar:t},this.root.classList.add(`dw-cv-presenting`),this.root.requestFullscreen?.().catch(()=>{}),requestAnimationFrame(()=>this.goTo(0))}goTo(e){let t=this.presenting;if(!t)return;t.at=Math.max(0,Math.min(t.frames.length-1,e));let n=this.get(t.frames[t.at]);if(n){let e={...this.view};this.fit(this.boxOf(n),!1,24);let t={...this.view};this.view=e,this.animateTo(t)}this.ui.presentStep(t.at,t.frames.length)}presentStep(e){this.presenting&&this.goTo(this.presenting.at+e)}stopPresenting(){let e=this.presenting;e&&(this.presenting=null,e.bar.remove(),this.root.classList.remove(`dw-cv-presenting`),document.fullscreenElement===this.root&&document.exitFullscreen().catch(()=>{}),this.drawOverlay())}get isPresenting(){return!!this.presenting}presentKey(e){[`ArrowRight`,`ArrowDown`,`PageDown`,` `,`Enter`].includes(e.key)?(e.preventDefault(),this.presentStep(1)):[`ArrowLeft`,`ArrowUp`,`PageUp`,`Backspace`].includes(e.key)?(e.preventDefault(),this.presentStep(-1)):e.key===`Escape`&&(e.preventDefault(),this.stopPresenting())}};function CR(e){return new Promise(t=>{let n=new Image;n.onload=()=>t({w:n.naturalWidth||320,h:n.naturalHeight||240}),n.onerror=()=>t({w:320,h:240}),n.src=e})}var wR={database:`Database`,untitled:`Untitled database`,untitledRow:`Untitled`,newRow:`New record`,addColumn:`Add property`,columnName:`Property name`,search:`Search records`,filter:`Filter`,sort:`Sort`,group:`Group`,properties:`Properties`,more:`More`,addView:`Add view`,viewName:`View name`,renameView:`Rename view`,duplicateView:`Duplicate view`,deleteView:`Delete view`,layout:`Layout`,viewTable:`Table`,viewKanban:`Kanban`,viewCalendar:`Calendar`,noValue:`No value`,checked:`Checked`,unchecked:`Unchecked`,noRows:`No records`,noMatches:`No records match`,rename:`Rename`,type:`Type`,hide:`Hide in view`,show:`Show in view`,sortAscending:`Sort ascending`,sortDescending:`Sort descending`,filterBy:`Filter by this property`,insertLeft:`Insert left`,insertRight:`Insert right`,moveLeft:`Move left`,moveRight:`Move right`,duplicate:`Duplicate`,deleteColumn:`Delete property`,typeTitle:`Title`,typeText:`Text`,typeNumber:`Number`,typeCheckbox:`Checkbox`,typeSelect:`Select`,typeMultiSelect:`Multi-select`,typeDate:`Date`,typeProgress:`Progress`,typeLink:`Link`,typeAttachment:`Attachment`,typeMember:`Member`,typeCreatedTime:`Created time`,typeCreatedBy:`Created by`,typeRelation:`Relation`,typeRollup:`Rollup`,linkedCount:`{n} linked`,rollupDays:`{n} days`,relationTo:`Related database`,relationPick:`Choose a database`,relationThisPage:`On this page`,relationOtherPage:`On another page…`,relationSearchPage:`Find a page`,relationNoDatabases:`No databases on that page`,relationMissing:`The related database is not available.`,relationTwoWay:`Two-way`,relationOneWay:`Links kept here`,relationMirror:`Show the links of “{n}”`,relationShowOn:`Show on “{n}” too`,relationBackReadOnly:`Change these links on the page that holds the related database.`,linkRecord:`Link a record`,searchRecords:`Search records`,noRecords:`No records`,openRelated:`Open record`,rollupSettings:`Rollup`,rollupRelation:`Relation`,rollupProperty:`Property`,rollupFn:`Calculate`,rollupRecords:`Records`,rollupNeedsRelation:`Add a relation property first.`,fnShowOriginal:`Show values`,fnCount:`Count records`,fnCountValues:`Count values`,fnCountUnique:`Count unique values`,fnCountEmpty:`Count empty`,fnCountNotEmpty:`Count not empty`,fnPercentNotEmpty:`Percent not empty`,fnSum:`Sum`,fnAverage:`Average`,fnMedian:`Median`,fnMin:`Min`,fnMax:`Max`,fnRange:`Range`,fnEarliest:`Earliest date`,fnLatest:`Latest date`,fnChecked:`Checked`,fnPercentChecked:`Percent checked`,openFullPage:`Open as full page`,backToPage:`Back to the page`,recordNotFound:`This record is not in the database any more.`,opContains:`contains`,opNotContains:`does not contain`,opIs:`is`,opIsNot:`is not`,opIsEmpty:`is empty`,opIsNotEmpty:`is not empty`,opGt:`is greater than`,opLt:`is less than`,opGte:`is at least`,opLte:`is at most`,opBefore:`is before`,opAfter:`is after`,opChecked:`is checked`,opUnchecked:`is not checked`,addFilter:`Add filter`,matchAll:`Every filter matches`,matchAny:`Any filter matches`,remove:`Remove`,value:`Value`,noFilters:`No filters yet`,addSort:`Add sort`,ascending:`Ascending`,descending:`Descending`,noSorts:`No sorts yet`,groupBy:`Group by`,noGrouping:`No grouping`,showAll:`Show all`,hideAll:`Hide all`,dateColumn:`Date property`,today:`Today`,previousMonth:`Previous month`,nextMonth:`Next month`,noDateColumn:`Add a date property to place records on the calendar.`,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`,insertBelow:`Insert below`,deleteRows:`Delete`,selected:`{n} selected`,selectRow:`Select record`,dragRow:`Drag to move`,close:`Close`,expand:`Full width`,collapse:`Narrow`,previousRow:`Previous record`,nextRow:`Next record`,bodyPlaceholder:`Write about this record…`,bodyReadOnly:`This record has no notes.`,searchOptions:`Find or create a choice`,createOption:`Create “{n}”`,optionColor:`Colour`,deleteOption:`Delete choice`,renameOption:`Rename choice`,searchPeople:`Find a person`,noPeople:`Nobody found`,upload:`Upload a file`,linkPlaceholder:`Paste a link`,clear:`Clear`,exportCsv:`Export as CSV`,importCsv:`Import CSV`,imported:`Added {n} records`,copyNotice:`Copied {n} cells`,readOnly:`Only people who can edit the page can change this database.`,resize:`Drag to change the width`,groupAsDatabase:`Group as database`,done:`Done`},TR={title:`typeTitle`,text:`typeText`,number:`typeNumber`,checkbox:`typeCheckbox`,select:`typeSelect`,multiSelect:`typeMultiSelect`,date:`typeDate`,progress:`typeProgress`,link:`typeLink`,attachment:`typeAttachment`,member:`typeMember`,createdTime:`typeCreatedTime`,createdBy:`typeCreatedBy`,relation:`typeRelation`,rollup:`typeRollup`},ER=(e,t)=>e[TR[t]],DR={contains:`opContains`,notContains:`opNotContains`,is:`opIs`,isNot:`opIsNot`,isEmpty:`opIsEmpty`,isNotEmpty:`opIsNotEmpty`,gt:`opGt`,lt:`opLt`,gte:`opGte`,lte:`opLte`,before:`opBefore`,after:`opAfter`,checked:`opChecked`,unchecked:`opUnchecked`},OR=(e,t)=>e[DR[t]],kR=(e,t)=>t===`kanban`?e.viewKanban:t===`calendar`?e.viewCalendar:e.viewTable,AR=(e,t)=>e.replace(`{n}`,String(t)),{colors:jR,...MR}=mF,NR={slashMenu:`Insert block`,noMatches:`No matching blocks`,slash:{text:{label:`Text`,description:`Plain paragraph`},h1:{label:`Heading 1`,description:`Big section heading`},h2:{label:`Heading 2`,description:`Medium section heading`},h3:{label:`Heading 3`,description:`Small section heading`},otherHeadings:{label:`Other headings`,description:`Headings 4 to 6`},h4:{label:`Heading 4`,description:`A heading below level 3`},h5:{label:`Heading 5`,description:`A heading below level 4`},h6:{label:`Heading 6`,description:`The smallest heading`},bullet:{label:`Bulleted list`,description:`A simple list`},ordered:{label:`Numbered list`,description:`A list with numbers`},todo:{label:`To-do list`,description:`Tasks to tick off (or type [])`},callout:{label:`Callout`,description:`Set a note apart with an emoji and colour`},table:{label:`Table`,description:`Rows and columns`},quote:{label:`Quote`,description:`Set text apart as a quote`},code:{label:`Code block`,description:`Monospaced code`},divider:{label:`Divider`,description:`A line between sections`},image:{label:`Image`,description:`Upload a picture`},file:{label:`File`,description:`Attach a file to download`},math:{label:`Math block`,description:`A formula on its own line (LaTeX)`},mathInline:{label:`Inline math`,description:`A formula inside the text (LaTeX)`},mermaid:{label:`Mermaid diagram`,description:`Flowcharts and sequences from text`},drawio:{label:`Draw.io diagram`,description:`Draw a diagram with diagrams.net`},excalidraw:{label:`Excalidraw drawing`,description:`Sketch by hand`},toc:{label:`Table of contents`,description:`The page's headings, kept up to date`},pageLink:{label:`Link to page`,description:`Link another page (or type [[)`},toggle:{label:`Toggle`,description:`A heading that hides the blocks under it`},embed:{label:`Embed`,description:`A video, design or document from YouTube, Figma and more`},linkCard:{label:`Link card`,description:`A link with its page's title and picture`},syncedPage:{label:`Synced page`,description:`Show another page here, always up to date`},database:{label:`Database`,description:`Records in a table, board or calendar`},newPage:{label:`New page`,description:`Make a page and link it here`},today:{label:`Today`,description:`Insert today's date`},tomorrow:{label:`Tomorrow`,description:`Insert tomorrow's date`},yesterday:{label:`Yesterday`,description:`Insert yesterday's date`},now:{label:`Now`,description:`Insert the date and time`}},format:{bold:`Bold`,italic:`Italic`,strike:`Strikethrough`,code:`Inline code`,link:`Link`,linkPrompt:`Link address (leave empty to remove the link)`,comment:`Comment`,underline:`Underline`,color:`Colour`,textColor:`Text colour`,highlight:`Highlight`,noColor:`Default`,align:`Align`,alignLeft:`Align left`,alignCenter:`Align centre`,alignRight:`Align right`,math:`Inline math`,linkedPage:`Make a linked page`},colors:{gray:`Grey`,red:`Red`,orange:`Orange`,yellow:`Yellow`,green:`Green`,teal:`Teal`,blue:`Blue`,purple:`Purple`,pink:`Pink`},table:{toolbar:`Table`,dragRow:`Drag to move the row`,dragColumn:`Drag to move the column`,moveRowUp:`Move row up`,moveRowDown:`Move row down`,moveColumnLeft:`Move column left`,moveColumnRight:`Move column right`,addRowBefore:`Add row above`,addRowAfter:`Add row below`,addColumnBefore:`Add column left`,addColumnAfter:`Add column right`,deleteRow:`Delete row`,deleteColumn:`Delete column`,toggleHeaderRow:`Header row`,mergeCells:`Merge cells`,splitCell:`Split cell`,deleteTable:`Delete table`},blockMenu:{open:`Drag to move, click for actions`,turnInto:`Turn into`,moveUp:`Move up`,moveDown:`Move down`,duplicate:`Duplicate`,copy:`Copy`,delete:`Delete`,showLineNumbers:`Show line numbers`,hideLineNumbers:`Hide line numbers`,showPages:`Show pages`,showAsFile:`Show as file`},mentions:`Mention someone`,noPeople:`Nobody found`,pageLinks:`Link to a page`,noPages:`No pages found`,blocks:{edit:`Edit`,done:`Done`,cancel:`Cancel`,save:`Save`,remove:`Remove`,saving:`Saving…`,latex:`LaTeX formula`,mermaid:`Mermaid diagram source`,mermaidError:`This diagram has an error:`,emptyDrawio:`Empty diagram. Click to draw.`,emptyExcalidraw:`Empty drawing. Click to sketch.`,loadFailed:`The editor could not be loaded.`,toc:`Contents`,tocEmpty:`Add headings to the page to fill the table of contents.`,expand:`Show contents`,collapse:`Hide contents`,embed:`Embedded content`,embedUrl:`Address of the video, design or document`,embedInvalid:`This address can't be embedded.`,syncedPage:`Synced page`,syncedOpen:`Open`,syncedFold:`Fold`,syncedUnfold:`Unfold`,syncedLoading:`Loading the page…`,syncedDenied:`You can't open this page.`,syncedSelf:`A page can't show itself.`,linkUrl:`Address of the page to link`,copyBlockLink:`Copy link to this block`,calloutEmoji:`Change emoji`,calloutColor:`Change colour`,pdfLoading:`Loading PDF…`,pdfPage:`Page {n}`,transcribe:`Transcribe`,transcribeHint:`Add a summary and the transcript below, with AI`,transcribing:`Transcribing…`,transcribeFailed:`The recording could not be transcribed.`},find:{find:`Find in page`,replace:`Replace with`,previous:`Previous match`,next:`Next match`,replaceOne:`Replace`,replaceAll:`Replace all`,matchCase:`Match case`,close:`Close`,count:`{current} of {total}`,none:`No matches`},ai:{button:`Ask AI`,rewrite:`Improve writing`,summarize:`Summarise`,translate:`Translate`,continue:`Continue writing`,shorter:`Make shorter`,longer:`Make longer`,fix:`Fix spelling and grammar`,custom:`Ask AI to…`,customPlaceholder:`Tell AI what to do with the selection`,language:`Language`,run:`Go`,working:`Writing…`,replace:`Replace selection`,insertBelow:`Insert below`,discard:`Discard`,stop:`Stop`,retry:`Try again`,failed:`AI could not finish this.`},dates:{today:`Today`,tomorrow:`Tomorrow`,yesterday:`Yesterday`,nextWeek:`Next week`,remindWord:`remind`,remindMe:`Remind me`,reminderAt:`Reminder at 9:00 on the day`,someoneElse:`Someone else set a reminder on this date.`,edit:`Change date`,openJournal:`Open journal`},database:wR,edgeless:MR},PR=[`title`,`text`,`number`,`checkbox`,`select`,`multiSelect`,`date`,`progress`,`link`,`attachment`,`member`,`createdTime`,`createdBy`,`relation`,`rollup`],FR=PR.filter(e=>e!==`title`),IR=[`table`,`kanban`,`calendar`];function LR(){let e=new Uint8Array(6);return crypto.getRandomValues(e),[...e].map(e=>e.toString(36).padStart(2,`0`)).join(``).slice(0,10)}function RR(e,t,n){let r=n.find(e=>zR.includes(e.type)),i=n.find(e=>e.type===`date`||e.type===`createdTime`);return{id:LR(),name:t,type:e,hidden:[],filters:[],filterMode:`and`,sorts:[],groupBy:e===`kanban`?r?.id??null:null,dateColumn:e===`calendar`?i?.id??null:null,widths:{}}}var zR=[`select`,`multiSelect`,`checkbox`,`member`,`createdBy`];function BR(e){let t=UR(e)?e:{},n=(Array.isArray(t.columns)?t.columns:[]).flatMap(e=>{if(!UR(e)||typeof e.id!=`string`||!e.id)return[];let t=PR.includes(String(e.type))?e.type:`text`,n={id:e.id,name:typeof e.name==`string`?e.name:``,type:t};Array.isArray(e.options)&&(n.options=e.options.flatMap(VR));let r=t===`relation`?pz(e.relation):void 0;r&&(n.relation=r);let i=t===`rollup`?mz(e.rollup):void 0;return i&&(n.rollup=i),[n]});n.some(e=>e.type===`title`)||n.unshift({id:LR(),name:``,type:`title`});let r=(Array.isArray(t.rows)?t.rows:[]).flatMap(e=>{if(!UR(e)||typeof e.id!=`string`||!e.id)return[];let t={id:e.id,cells:UR(e.cells)?{...e.cells}:{},createdAt:typeof e.createdAt==`number`?e.createdAt:0,createdBy:HR(e.createdBy)};return Array.isArray(e.body)&&e.body.length&&(t.body=e.body,t.hasBody=!0),[t]}),i=new Set(n.map(e=>e.id)),a=(Array.isArray(t.views)?t.views:[]).flatMap(e=>{if(!UR(e)||typeof e.id!=`string`||!e.id)return[];let t=IR.includes(String(e.type))?e.type:`table`;return[{id:e.id,name:typeof e.name==`string`?e.name:``,type:t,hidden:Array.isArray(e.hidden)?e.hidden.filter(e=>typeof e==`string`):[],filters:Array.isArray(e.filters)?e.filters.filter(e=>UR(e)&&typeof e.column==`string`&&typeof e.op==`string`):[],filterMode:e.filterMode===`or`?`or`:`and`,sorts:Array.isArray(e.sorts)?e.sorts.flatMap(e=>UR(e)&&typeof e.column==`string`?[{column:e.column,desc:!!e.desc}]:[]):[],groupBy:typeof e.groupBy==`string`&&i.has(e.groupBy)?e.groupBy:null,dateColumn:typeof e.dateColumn==`string`&&i.has(e.dateColumn)?e.dateColumn:null,widths:UR(e.widths)?Object.fromEntries(Object.entries(e.widths).filter(e=>typeof e[1]==`number`)):{}}]});return{title:typeof t.title==`string`?t.title:``,columns:n,rows:r,views:a}}function VR(e){return!UR(e)||typeof e.id!=`string`?[]:[{id:e.id,name:typeof e.name==`string`?e.name:``,color:LP(e.color)?e.color:`gray`}]}function HR(e){return UR(e)&&typeof e.id==`string`?{id:e.id,name:typeof e.name==`string`?e.name:``}:null}function UR(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function WR(e){return e.columns.find(e=>e.type===`title`)??e.columns[0]}function GR(e,t){return t.type===`createdTime`?e.createdAt||null:t.type===`createdBy`?e.createdBy?[e.createdBy]:[]:t.type===`rollup`?e.computed?.[t.id]?.value??null:t.type===`relation`&&t.relation?.back?e.computed?.[t.id]?.value??[]:e.cells[t.id]}function KR(e){return e==null||e===``||e===!1||Array.isArray(e)&&e.length===0}function qR(e){return typeof e==`number`&&e>0?JR(new Date(e)):typeof e==`string`&&/^\d{4}-\d{2}-\d{2}/.test(e)?e.slice(0,10):``}function JR(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function YR(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e.trim().replace(`,`,`.`));return Number.isFinite(t)?t:null}return null}function XR(e){return Array.isArray(e)?e:[]}function ZR(e,t){let n=GR(e,t);switch(t.type){case`title`:case`text`:case`link`:return typeof n==`string`?n:``;case`number`:case`progress`:{let e=YR(n);return e===null?``:String(e)}case`checkbox`:return n===!0?`true`:`false`;case`select`:return t.options?.find(e=>e.id===n)?.name??``;case`multiSelect`:return XR(n).map(e=>t.options?.find(t=>t.id===e)?.name).filter(e=>!!e).join(`, `);case`date`:case`createdTime`:return qR(n);case`attachment`:return XR(n).map(e=>e?.name??``).join(`, `);case`member`:case`createdBy`:return XR(n).map(e=>e?.name??``).join(`, `);case`relation`:case`rollup`:return e.computed?.[t.id]?.text??``}}function QR(e){switch(e){case`number`:case`progress`:return[`is`,`isNot`,`gt`,`lt`,`gte`,`lte`,`isEmpty`,`isNotEmpty`];case`checkbox`:return[`checked`,`unchecked`];case`select`:return[`is`,`isNot`,`isEmpty`,`isNotEmpty`];case`multiSelect`:case`member`:case`createdBy`:return[`contains`,`notContains`,`isEmpty`,`isNotEmpty`];case`date`:case`createdTime`:return[`is`,`before`,`after`,`isEmpty`,`isNotEmpty`];case`attachment`:return[`isEmpty`,`isNotEmpty`];case`relation`:return[`contains`,`notContains`,`isEmpty`,`isNotEmpty`];case`rollup`:return[`is`,`isNot`,`gt`,`lt`,`gte`,`lte`,`contains`,`isEmpty`,`isNotEmpty`];default:return[`contains`,`notContains`,`is`,`isNot`,`isEmpty`,`isNotEmpty`]}}var $R=e=>![`isEmpty`,`isNotEmpty`,`checked`,`unchecked`].includes(e);function ez(e,t,n){let r=GR(e,t);if(t.type===`relation`){let e=gz(r).length===0;if(n.op===`isEmpty`)return e;if(n.op===`isNotEmpty`)return!e}if(n.op===`isEmpty`)return KR(r)||ZR(e,t)===``;if(n.op===`isNotEmpty`)return!(KR(r)||ZR(e,t)===``);if(n.op===`checked`)return r===!0;if(n.op===`unchecked`)return r!==!0;if(n.value===void 0||n.value===null||n.value===``)return!0;switch(t.type===`rollup`&&(typeof r==`number`||r===null)&&[`is`,`isNot`,`gt`,`lt`,`gte`,`lte`].includes(n.op)?`number`:t.type){case`number`:case`progress`:{let e=YR(r),t=YR(n.value);return t===null?!0:e===null?n.op===`isNot`:{is:e===t,isNot:e!==t,gt:e>t,lt:e=t,lte:e<=t}[n.op]}case`select`:return n.op===`is`?r===n.value:r!==n.value;case`multiSelect`:{let e=XR(r).includes(String(n.value));return n.op===`notContains`?!e:e}case`member`:case`createdBy`:{let e=String(n.value).toLowerCase(),t=XR(r).some(t=>t?.id===n.value||t?.name?.toLowerCase().includes(e));return n.op===`notContains`?!t:t}case`date`:case`createdTime`:{let e=qR(r),t=qR(n.value);return e?n.op===`before`?et:e===t:!1}default:{let r=ZR(e,t).toLowerCase(),i=String(n.value).toLowerCase();switch(n.op){case`contains`:return r.includes(i);case`notContains`:return!r.includes(i);case`is`:return r===i;case`isNot`:return r!==i;default:return!0}}}}function tz(e,t,n){let r=ZR(e,n)===``&&n.type!==`checkbox`,i=ZR(t,n)===``&&n.type!==`checkbox`;if(r||i)return r===i?0:r?1:-1;switch(n.type){case`number`:case`progress`:return(YR(GR(e,n))??0)-(YR(GR(t,n))??0);case`checkbox`:return Number(GR(e,n)===!0)-Number(GR(t,n)===!0);case`createdTime`:return e.createdAt-t.createdAt;case`rollup`:{let r=GR(e,n),i=GR(t,n);return typeof r==`number`&&typeof i==`number`?r-i:ZR(e,n).localeCompare(ZR(t,n),void 0,{numeric:!0,sensitivity:`base`})}case`select`:{let r=e=>n.options?.findIndex(t=>t.id===GR(e,n))??-1;return r(e)-r(t)}default:return ZR(e,n).localeCompare(ZR(t,n),void 0,{numeric:!0,sensitivity:`base`})}}function nz(e,t,n=``){let r=new Map(e.columns.map(e=>[e.id,e])),i=t.filters.flatMap(e=>{let t=r.get(e.column);return t?[{f:e,col:t}]:[]}),a=n.trim().toLowerCase(),o=e.rows.filter(n=>{if(i.length){let e=({f:e,col:t})=>ez(n,t,e);if(t.filterMode===`or`?!i.some(e):!i.every(e))return!1}return!a||e.columns.some(e=>ZR(n,e).toLowerCase().includes(a))}),s=t.sorts.flatMap(e=>{let t=r.get(e.column);return t?[{col:t,desc:e.desc}]:[]});return s.length&&(o=o.map((e,t)=>({r:e,i:t})).sort((e,t)=>{for(let n of s){let r=tz(e.r,t.r,n.col);if(r!==0){let i=ZR(e.r,n.col)===``||ZR(t.r,n.col)===``;return n.desc&&!(i&&n.col.type!==`checkbox`)?-r:r}}return e.i-t.i}).map(e=>e.r)),o}function rz(e,t){return e.columns.filter(e=>e.type===`title`||!t.hidden.includes(e.id))}function iz(e,t,n,r,i){let a=new Map,o=(e,t,n)=>(a.has(e)||a.set(e,{key:e,label:t,color:n,rows:[]}),a.get(e));if(t.type===`checkbox`)o(`false`,i),o(`true`,r);else{o(``,n);for(let e of t.options??[])o(e.id,e.name,e.color)}for(let n of e)for(let e of oz(n,t))(a.get(e)??o(e,az(n,t,e)||e)).rows.push(n);return[...a.values()]}function az(e,t,n){return XR(GR(e,t)).find(e=>e?.id===n)?.name??``}function oz(e,t){let n=GR(e,t);switch(t.type){case`checkbox`:return[n===!0?`true`:`false`];case`select`:return[typeof n==`string`&&t.options?.some(e=>e.id===n)?n:``];case`multiSelect`:{let e=XR(n).filter(e=>t.options?.some(t=>t.id===e));return e.length?e:[``]}case`member`:case`createdBy`:{let e=XR(n).flatMap(e=>e?.id?[e.id]:[]);return e.length?e:[``]}default:return[``]}}function sz(e,t,n,r,i=[]){let a=GR(e,t);switch(t.type){case`checkbox`:return r===`true`;case`select`:return r||null;case`multiSelect`:{let e=XR(a).filter(e=>e!==n&&e!==r);return r?[...e,r]:e}case`member`:{let e=XR(a).filter(e=>e?.id!==n&&e?.id!==r),t=i.find(e=>e.id===r)??XR(a).find(e=>e?.id===r);return r&&t?[...e,t]:e}default:return a}}function cz(e){let t=IP.filter(e=>e!==`gray`);return t[e.length%t.length]}function lz(e,t,n,r){if(t.type===n)return{value:e,options:r};let i=ZR({id:``,cells:{[t.id]:e},createdAt:0,createdBy:null},t),a=e=>{let t=e.trim();if(!t)return null;let n=r.find(e=>e.name.toLowerCase()===t.toLowerCase());return n||(n={id:LR(),name:t,color:cz(r)},r=[...r,n]),n.id};switch(n){case`title`:case`text`:case`link`:return{value:i||null,options:r};case`number`:return{value:YR(i),options:r};case`progress`:{let e=YR(i);return{value:e===null?null:Math.max(0,Math.min(100,Math.round(e))),options:r}}case`checkbox`:return{value:[`true`,`yes`,`1`,`x`,`✓`,`done`].includes(i.trim().toLowerCase()),options:r};case`select`:return{value:a(i.split(`,`)[0]??``),options:r};case`multiSelect`:{let e=i.split(`,`).flatMap(e=>{let t=a(e);return t?[t]:[]});return{value:[...new Set(e)],options:r}}case`date`:return{value:qR(i)||null,options:r};case`member`:return{value:t.type===`member`||t.type===`createdBy`?e:[],options:r};default:return{value:null,options:r}}}function uz(e,t,n=1){let r=(new Date(e,t,1).getDay()-n+7)%7,i=new Date(e,t,1-r),a=new Date(e,t+1,0).getDate(),o=Math.ceil((r+a)/7);return Array.from({length:o*7},(e,t)=>JR(new Date(i.getFullYear(),i.getMonth(),i.getDate()+t)))}var dz=e=>e.type===`relation`&&!!e.relation?.back,fz=[`showOriginal`,`count`,`countValues`,`countUnique`,`countEmpty`,`countNotEmpty`,`percentNotEmpty`,`sum`,`average`,`median`,`min`,`max`,`range`,`earliest`,`latest`,`checked`,`percentChecked`];function pz(e){if(!UR(e)||typeof e.database!=`string`||!e.database)return;let t={page:typeof e.page==`string`?e.page:``,database:e.database};return typeof e.back==`string`&&e.back&&(t.back=e.back),t}function mz(e){if(!UR(e)||typeof e.relation!=`string`)return;let t=fz.includes(String(e.fn))?e.fn:`count`;return{relation:e.relation,property:typeof e.property==`string`?e.property:``,fn:t}}function hz(e){let t=[`count`,`countValues`,`countUnique`,`countEmpty`,`countNotEmpty`,`percentNotEmpty`];switch(e){case`number`:case`progress`:return[`sum`,`average`,`median`,`min`,`max`,`range`,...t,`showOriginal`];case`date`:case`createdTime`:return[`earliest`,`latest`,`range`,...t,`showOriginal`];case`checkbox`:return[`checked`,`percentChecked`,`count`,`showOriginal`];default:return[`showOriginal`,...t]}}var gz=e=>XR(e).filter(e=>typeof e==`string`&&!!e);function _z(e,t,n){let r=t.relation?.back;return r?n?n.rows.filter(t=>gz(t.cells[r]).includes(e.id)).map(e=>e.id):[]:gz(e.cells[t.id])}var vz=e=>String(Number.isInteger(e)?e:Math.round(e*100)/100),yz=(e,t)=>Math.round((Date.parse(t)-Date.parse(e))/864e5);function bz(e,t,n,r){let i=t.map(e=>n?GR(e,n):e.id),a=t.map(e=>n?ZR(e,n):``),o=a.filter((e,t)=>n?.type===`checkbox`?i[t]===!0:e!==``),s=n?i.map(YR).filter(e=>e!==null):[],c=n?i.map(qR).filter(Boolean).sort():[],l=e=>({text:e===null?``:vz(e),value:e});switch(e){case`count`:return l(t.length);case`countValues`:return l(o.length);case`countUnique`:return l(new Set(o).size);case`countEmpty`:return l(t.length-o.length);case`countNotEmpty`:return l(o.length);case`percentNotEmpty`:return t.length?{text:`${vz(o.length/t.length*100)}%`,value:o.length/t.length*100}:l(null);case`sum`:return l(s.length?s.reduce((e,t)=>e+t,0):null);case`average`:return l(s.length?s.reduce((e,t)=>e+t,0)/s.length:null);case`median`:{if(!s.length)return l(null);let e=[...s].sort((e,t)=>e-t),t=Math.floor(e.length/2);return l(e.length%2?e[t]:(e[t-1]+e[t])/2)}case`min`:return l(s.length?Math.min(...s):null);case`max`:return l(s.length?Math.max(...s):null);case`range`:if(n&&(n.type===`date`||n.type===`createdTime`)){if(!c.length)return l(null);let e=yz(c[0],c[c.length-1]);return{text:r.rollupDays.replace(`{n}`,String(e)),value:e}}return l(s.length?Math.max(...s)-Math.min(...s):null);case`earliest`:return{text:c[0]??``,value:c[0]??null};case`latest`:return{text:c[c.length-1]??``,value:c[c.length-1]??null};case`checked`:return l(i.filter(e=>e===!0).length);case`percentChecked`:return t.length?{text:`${vz(i.filter(e=>e===!0).length/t.length*100)}%`,value:i.filter(e=>e===!0).length/t.length*100}:l(null);case`showOriginal`:{let e=a.filter(Boolean);return{text:e.join(`, `),value:e}}}}function xz(e,t,n){let r=e.columns.filter(e=>e.type===`relation`&&e.relation),i=e.columns.filter(e=>e.type===`rollup`&&e.rollup);if(!r.length&&!i.length)return e;let a=new Map;for(let e of r)a.set(e.id,t(e.relation));let o=e.rows.map(e=>{let t={};for(let i of r){let r=a.get(i.id),o=_z(e,i,r);if(!r){t[i.id]={text:o.length?n.linkedCount.replace(`{n}`,String(o.length)):``,value:o};continue}let s=r.columns.find(e=>e.type===`title`),c=new Map(r.rows.map(e=>[e.id,e])),l=o.flatMap(e=>{let t=c.get(e);return t?[{id:e,title:s?ZR(t,s):``}]:[]});t[i.id]={text:l.map(e=>e.title).join(`, `),value:o,links:l}}for(let o of i){let i=o.rollup,s=r.find(e=>e.id===i.relation),c=s?a.get(s.id):null;if(!s||!c){t[o.id]={text:``,value:null};continue}let l=new Map(c.rows.map(e=>[e.id,e])),u=_z(e,s,c).flatMap(e=>{let t=l.get(e);return t?[t]:[]}),d=i.property?c.columns.find(e=>e.id===i.property)??null:c.columns.find(e=>e.type===`title`)??null;t[o.id]=bz(i.fn,u,d,n)}return{...e,computed:t}});return{...e,rows:o}}function I(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))if(n!=null&&n!==!1){if(e===`class`)r.className=String(n);else if(e===`on`)for(let[e,t]of Object.entries(n))r.addEventListener(e,t);else e===`dataset`?Object.assign(r.dataset,n):e===`style`?Object.assign(r.style,n):e in r&&typeof n!=`string`?r[e]=n:r.setAttribute(e,n===!0?``:String(n))}for(let e of n.flat())e!=null&&e!==!1&&r.append(e);return r}function Sz(e,t=16){return Hj(e,t)}function Cz(e,t,n,r){let i=I(`button`,{type:`button`,class:r?`dw-db__btn`:`dw-db__btn dw-db__btn--icon`,title:t,"aria-label":t},Sz(e,15),r?I(`span`,{},r):null);return i.addEventListener(`click`,e=>{e.preventDefault(),n(e)}),i}var wz=null;function Tz(e,t,n={}){wz?.close();let r=I(`div`,{class:`dw-db-pop ${n.class??``}`,role:`dialog`,"aria-label":n.label}),i=!1,a=()=>{i||(i=!0,c(),r.remove(),document.removeEventListener(`mousedown`,o,!0),document.removeEventListener(`keydown`,s,!0),wz?.box===r&&(wz=null),n.onClose?.())},o=t=>{let n=t.target;r.contains(n)||e.contains(n)||n instanceof Element&&n.closest(`.dw-block-menu`)||a()},s=t=>{t.key===`Escape`&&!document.querySelector(`.dw-block-menu`)&&(t.preventDefault(),t.stopPropagation(),a(),e instanceof HTMLElement&&e.focus())};document.body.append(r);let c=jj(e,r,()=>{Fj(e,r,{placement:n.placement??`bottom-start`,strategy:`fixed`,middleware:[Mj(4),Pj(),Nj({padding:8})]}).then(({x:e,y:t})=>Object.assign(r.style,{left:`${e}px`,top:`${t}px`}))});return document.addEventListener(`mousedown`,o,!0),document.addEventListener(`keydown`,s,!0),t(r,a),wz={box:r,close:a},wz}function Ez(){wz?.close()}function Dz(e,t){let n=I(`input`,{type:t.type??`text`,class:t.class??`dw-db-input`,placeholder:t.placeholder,"aria-label":t.label??t.placeholder});n.value=e;let r=!1,i=()=>{r||(r=!0,t.onCommit(n.value))};return n.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(r=!0,t.onCancel?.())}),n.addEventListener(`blur`,i),n}function Oz(e,t,n){let r=URL.createObjectURL(new Blob([t],{type:n})),i=I(`a`,{href:r,download:e});document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function kz(e){return new Promise(t=>{let n=I(`input`,{type:`file`,accept:e});n.onchange=()=>t(n.files?.[0]??null),n.click()})}function Az(e,t){let n=e.read(t);return!n||!e.pointsHere?[]:n.columns.filter(n=>n.type===`relation`&&n.relation&&!n.relation.back&&e.pointsHere(t,n.relation))}var jz=e=>`fn${e[0].toUpperCase()}${e.slice(1)}`,Mz=(e,t)=>e[jz(t)];function Nz(e,t,n,r){let i=I(`div`,{class:`dw-db-pop__item${t?` is-active`:``}`,role:`option`,"aria-selected":String(t)},I(`span`,{},e),r?I(`small`,{class:`dw-db-pop__sub`},r):null);return i.addEventListener(`mousedown`,e=>e.preventDefault()),i.addEventListener(`click`,n),i}function Pz(e,t,n,r){let i=e.store,a=e.linked;if(!i||!a)return;let o=e.labels;Tz(t,(t,r)=>{let s=n.relation,c=e=>{let c={page:e.page,database:e.database},l=Az(a,c);if(!l.length)return i.setRelation(n.id,c),r();let u=!!s&&s.page===e.page&&s.database===e.database;t.replaceChildren(I(`div`,{class:`dw-db-pop__title`},e.title||o.untitled),I(`div`,{class:`dw-db-pop__list`,role:`listbox`},Nz(o.relationOneWay,u&&!s.back,()=>{i.setRelation(n.id,c),r()}),...l.map(e=>Nz(AR(o.relationMirror,e.name||o.typeRelation),u&&s.back===e.id,()=>{i.setRelation(n.id,{...c,back:e.id}),r()},o.relationTwoWay))))},l=I(`div`,{class:`dw-db-pop__list`,role:`listbox`});if((()=>{let e=a.local();l.replaceChildren(I(`div`,{class:`dw-db-pop__heading`},o.relationThisPage),...e.length?e.map(e=>Nz(e.title||o.untitled,!!s&&!s.page&&s.database===e.database,()=>c(e))):[I(`div`,{class:`dw-db-pop__empty`},o.relationNoDatabases)])})(),t.append(I(`div`,{class:`dw-db-pop__title`},o.relationPick),l),a.searchPages&&a.databasesOn){let e=I(`input`,{class:`dw-db-input`,placeholder:o.relationSearchPage,"aria-label":o.relationOtherPage}),n=I(`div`,{class:`dw-db-pop__list`,role:`listbox`}),r=0;e.addEventListener(`input`,async()=>{let t=e.value.trim(),i=++r;if(!t)return n.replaceChildren();let l=await a.searchPages(t).catch(()=>[]);i===r&&n.replaceChildren(...l.slice(0,8).map(e=>Nz(e.title||o.untitled,!1,async()=>{let t=await a.databasesOn(e.id).catch(()=>[]);i===r&&n.replaceChildren(I(`div`,{class:`dw-db-pop__heading`},e.title||o.untitled),...t.length?t.map(e=>Nz(e.title||o.untitled,s?.page===e.page&&s.database===e.database,()=>c(e))):[I(`div`,{class:`dw-db-pop__empty`},o.relationNoDatabases)])})))}),e.addEventListener(`keydown`,e=>e.stopPropagation()),t.append(I(`div`,{class:`dw-db-pop__heading`},o.relationOtherPage),e,n)}if(s&&!s.back&&a.addBack&&a.writable?.(s)){let i=a.read(s),c=i?.columns.some(e=>e.relation?.back===n.id&&a.pointsHere?.(s,e.relation));if(i&&!c){let c=I(`button`,{type:`button`,class:`dw-db__btn dw-db-pop__add`},Sz(`plus`,14),I(`span`,{},AR(o.relationShowOn,i.title||o.untitled)));c.addEventListener(`click`,()=>{a.addBack(s,n.id,e.db.title||n.name||o.typeRelation),r()}),t.append(c)}}},{class:`dw-db-pop--choices`,label:o.relationTo,onClose:r})}function Fz(e,t,n,r,i){let a=e.store,o=e.labels,s=r.relation,c=s?e.linked?.read(s):null;if(!s||!c){if(t.append(I(`div`,{class:`dw-db-pop__empty`},s?o.relationMissing:o.relationPick)),!s&&e.linked){let n=I(`button`,{type:`button`,class:`dw-db__btn`},o.relationTo);n.addEventListener(`click`,()=>{i(),Pz(e,t,r)}),t.append(n)}return}let l=WR(c),u=!!s.back,d=!u||!!e.linked?.writable?.(s),f=_z(n,r,c),p=I(`div`,{class:`dw-db-tags dw-db-pop__chosen`}),m=I(`input`,{class:`dw-db-input`,placeholder:o.searchRecords,"aria-label":o.linkRecord}),h=I(`div`,{class:`dw-db-pop__list`,role:`listbox`});t.append(p),d?t.append(m,h):t.append(I(`div`,{class:`dw-db-pop__empty`},o.relationBackReadOnly));let g=e=>ZR(e,l)||o.untitledRow,_=t=>{if(!d)return;let i=!f.includes(t);if(u){if(!e.linked?.link?.(s,n.id,t,i))return}else a.setCell(n.id,r.id,i?[...f,t]:f.filter(e=>e!==t));f=i?[...f,t]:f.filter(e=>e!==t),b()},v=0,y=[],b=()=>{let e=new Map(c.rows.map(e=>[e.id,e]));p.replaceChildren(...f.flatMap(t=>{let n=e.get(t);if(!n)return[];let r=I(`span`,{class:`dw-db-tag`,dataset:{color:`gray`}},g(n));if(d){let e=I(`button`,{type:`button`,class:`dw-db-tag__x`,"aria-label":`×`},`×`);e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,()=>_(t)),r.append(e)}return[r]}));let t=m.value.trim().toLowerCase();y=c.rows.filter(e=>!t||g(e).toLowerCase().includes(t)).slice(0,50),v=Math.min(v,Math.max(0,y.length-1)),h.replaceChildren(...y.length?y.map((e,t)=>{let n=Nz(g(e),t===v,()=>_(e.id));return f.includes(e.id)&&n.prepend(I(`span`,{class:`dw-db-pop__check`},`✓`)),n}):[I(`div`,{class:`dw-db-pop__empty`},o.noRecords)])};m.addEventListener(`input`,()=>{v=0,b()}),m.addEventListener(`keydown`,e=>{if(e.stopPropagation(),e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),y.length&&(v=(v+(e.key===`ArrowDown`?1:-1)+y.length)%y.length),b();else if(e.key===`Enter`){e.preventDefault();let t=y[v];t&&_(t.id)}else e.key===`Escape`&&(e.preventDefault(),i())}),b(),d&&m.focus({preventScroll:!0})}function Iz(e,t,n,r){let i=e.store;if(!i)return;let a=e.labels;Tz(t,t=>{let r=e.db.columns.filter(e=>e.type===`relation`);if(!r.length){t.append(I(`div`,{class:`dw-db-pop__empty`},a.rollupNeedsRelation));return}let o=n.rollup??{relation:r[0].id,property:``,fn:`count`},s=(e,t,n,r)=>{let i=I(`select`,{class:`dw-db-input`,"aria-label":e});for(let[e,n]of t)i.append(I(`option`,{value:e},n));return i.value=n,i.addEventListener(`change`,()=>r(i.value)),I(`label`,{class:`dw-db-pop__field`},I(`span`,{},e),i)},c=()=>{let l=r.find(e=>e.id===o.relation)??r[0],u=l.relation?e.linked?.read(l.relation):null,d=[[``,a.rollupRecords]];for(let e of u?.columns??[])d.push([e.id,e.name||ER(a,e.type)]);let f=u?.columns.find(e=>e.id===o.property),p=hz(f?f.type:``);p.includes(o.fn)||(o.fn=o.property?p[0]:`count`),t.replaceChildren(s(a.rollupRelation,r.map(e=>[e.id,e.name||a.typeRelation]),l.id,e=>{o.relation=e,o.property=``,o.fn=`count`,i.setRollup(n.id,{...o}),c()}),s(a.rollupProperty,d,o.property,e=>{o.property=e;let t=u?.columns.find(t=>t.id===e);o.fn=e?hz(t?t.type:``)[0]:`count`,i.setRollup(n.id,{...o}),c()}),s(a.rollupFn,(o.property?p:[`count`,`showOriginal`]).map(e=>[e,Mz(a,e)]),o.fn,e=>{o.fn=e,i.setRollup(n.id,{...o})}),u?I(`span`):I(`div`,{class:`dw-db-pop__empty`},a.relationMissing))};n.rollup||i.setRollup(n.id,{...o}),c()},{class:`dw-db-pop--choices`,label:a.rollupSettings,onClose:r})}function Lz(e,t,n){let r=t.computed?.[n.id],i=I(`span`,{class:`dw-db-tags`});if(r?.links&&n.relation){let t=n.relation;for(let n of r.links){let r=I(`button`,{type:`button`,class:`dw-db-tag dw-db-rel`,dataset:{color:`gray`},title:e.labels.openRelated},n.title||e.labels.untitledRow);r.addEventListener(`click`,r=>{r.stopPropagation(),e.linked?.openRecord(t,n.id)}),i.append(r)}}else r?.text&&i.append(I(`span`,{class:`dw-db-cell__text`},r.text));return i}var Rz={title:`text`,text:`type`,number:`sigma`,checkbox:`todo`,select:`tag`,multiSelect:`layers`,date:`calendar`,progress:`sliders`,link:`link`,attachment:`paperclip`,member:`users`,createdTime:`clock`,createdBy:`at`,relation:`relation`,rollup:`rollup`},zz=[`title`,`text`,`number`,`link`],Bz=[`createdTime`,`createdBy`,`rollup`];function Vz(e,t){let[n,r,i]=e.split(`-`).map(Number);return!n||!r||!i?e:new Date(n,r-1,i).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`})}function Hz(e,t,n){let r=I(`span`,{class:`dw-db-tag`,dataset:{color:t??`gray`}},e);if(n){let e=I(`button`,{type:`button`,class:`dw-db-tag__x`,"aria-label":`×`},`×`);e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,e=>{e.stopPropagation(),n()}),r.append(e)}return r}function Uz(e){try{let t=new URL(e.includes(`://`)?e:`https://${e}`);return t.protocol===`http:`||t.protocol===`https:`||t.protocol===`mailto:`?t.href:null}catch{return null}}function Wz(e,t,n){let r=GR(t,n),i=e.labels;switch(n.type){case`title`:{let e=typeof r==`string`?r:``;return I(`span`,{class:e?`dw-db-cell__title`:`dw-db-cell__title is-empty`},e||i.untitledRow)}case`text`:return I(`span`,{class:`dw-db-cell__text`},typeof r==`string`?r:``);case`number`:{let t=YR(r);return I(`span`,{class:`dw-db-cell__number`},t===null?``:t.toLocaleString(e.locale))}case`checkbox`:return I(`span`,{class:r===!0?`dw-db-check is-on`:`dw-db-check`,role:`img`,"aria-label":r===!0?i.checked:i.unchecked},r===!0?Sz(`check`,13):null);case`select`:{let e=n.options?.find(e=>e.id===r);return I(`span`,{class:`dw-db-tags`},e?Hz(e.name,e.color):null)}case`multiSelect`:return I(`span`,{class:`dw-db-tags`},XR(r).flatMap(e=>{let t=n.options?.find(t=>t.id===e);return t?[Hz(t.name,t.color)]:[]}));case`date`:case`createdTime`:{let t=qR(r);return I(`span`,{class:`dw-db-cell__text`},t?Vz(t,e.locale):``)}case`progress`:{let e=YR(r);if(e===null)return I(`span`);let t=Math.max(0,Math.min(100,e));return I(`span`,{class:`dw-db-progress`},I(`span`,{class:`dw-db-progress__bar`},I(`span`,{class:`dw-db-progress__fill`,style:{width:`${t}%`}})),I(`span`,{class:`dw-db-progress__num`},`${t}%`))}case`link`:{let e=typeof r==`string`?r:``,t=e?Uz(e):null;if(!t)return I(`span`,{class:`dw-db-cell__text`},e);let n=I(`a`,{class:`dw-db-cell__link`,href:t,target:`_blank`,rel:`noopener noreferrer`},e);return n.addEventListener(`click`,e=>{!e.ctrlKey&&!e.metaKey&&e.preventDefault()}),n}case`attachment`:return I(`span`,{class:`dw-db-tags`},XR(r).map(t=>{let n=I(`a`,{class:`dw-db-file`,href:e.files?e.files.resolve(t.src):t.src,target:`_blank`,rel:`noopener noreferrer`},Sz(`paperclip`,12),t.name);return n.addEventListener(`click`,e=>{!e.ctrlKey&&!e.metaKey&&e.preventDefault()}),n}));case`member`:case`createdBy`:return I(`span`,{class:`dw-db-tags`},XR(r).map(e=>I(`span`,{class:`dw-db-person`},I(`span`,{class:`dw-db-person__dot`},(e?.name||`?`).slice(0,1).toUpperCase()),e?.name??``)));case`relation`:return Lz(e,t,n);case`rollup`:{let r=t.computed?.[n.id],i=r?.value;return typeof i==`number`?I(`span`,{class:`dw-db-cell__number`},/^-?\d+(\.\d+)?%?$/.test(r.text)?i.toLocaleString(e.locale,{maximumFractionDigits:2})+(r.text.endsWith(`%`)?`%`:``):r.text):I(`span`,{class:`dw-db-cell__text`},r?.text??``)}}}function Gz(e,t,n,r,i){let a=e.store;if(!a||Bz.includes(r.type))return i.onDone();let o=GR(n,r);if(r.type===`checkbox`)return a.setCell(n.id,r.id,o!==!0),i.onDone();e.setEditing(!0);let s=t=>{e.setEditing(!1),i.onDone(t)};if(zz.includes(r.type)){let e=i.initial??(r.type===`number`?YR(o)?.toString()??``:typeof o==`string`?o:``),c,l=Dz(e,{class:`dw-db-cell__input`,type:(r.type,`text`),label:r.name,onCommit:e=>{let t=e.trim(),i=r.type===`number`?YR(t):r.type===`title`||r.type===`text`?e:t;i!==(o??null)&&(i!==``||o!==void 0)&&a.setCell(n.id,r.id,i),s(c)},onCancel:()=>s()});l.addEventListener(`keydown`,e=>{e.key===`Enter`&&(c=`down`),e.key===`Tab`&&(e.preventDefault(),c=e.shiftKey?`left`:`right`,l.blur())}),t.replaceChildren(l),t.classList.add(`is-editing`),l.focus(),i.initial===void 0?l.select():l.setSelectionRange(l.value.length,l.value.length);return}let c=(e,n=``)=>Tz(t,e,{class:n,onClose:()=>s(),label:r.name});switch(r.type){case`select`:case`multiSelect`:c((t,a)=>Kz(e,t,n,r,a,i.initial),`dw-db-pop--choices`);break;case`date`:c((t,i)=>{let s=I(`input`,{type:`date`,class:`dw-db-input`,"aria-label":r.name});s.value=qR(o),s.addEventListener(`change`,()=>a.setCell(n.id,r.id,s.value||null)),s.addEventListener(`keydown`,e=>{e.key===`Enter`&&i()});let c=I(`button`,{type:`button`,class:`dw-db__btn`},e.labels.clear);c.addEventListener(`click`,()=>{a.setCell(n.id,r.id,null),i()});let l=I(`button`,{type:`button`,class:`dw-db__btn`},e.labels.today);l.addEventListener(`click`,()=>{let e=new Date;a.setCell(n.id,r.id,`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`),i()}),t.append(s,I(`div`,{class:`dw-db-pop__row`},l,c)),s.focus({preventScroll:!0})});break;case`progress`:c((e,t)=>{let i=YR(o)??0,s=I(`input`,{type:`range`,min:`0`,max:`100`,step:`1`,class:`dw-db-range`,"aria-label":r.name});s.value=String(i);let c=I(`span`,{class:`dw-db-progress__num`},`${i}%`);s.addEventListener(`input`,()=>c.textContent=`${s.value}%`),s.addEventListener(`change`,()=>a.setCell(n.id,r.id,Number(s.value))),s.addEventListener(`keydown`,e=>{e.key===`Enter`&&t()}),e.append(I(`div`,{class:`dw-db-pop__row`},s,c)),s.focus({preventScroll:!0})});break;case`member`:c((t,i)=>qz(e,t,n,r,i),`dw-db-pop--choices`);break;case`attachment`:c(t=>Jz(e,t,n,r),`dw-db-pop--choices`);break;case`relation`:c((t,i)=>Fz(e,t,n,r,i),`dw-db-pop--choices`);break;default:s()}}function Kz(e,t,n,r,i,a){let o=e.store,s=e.labels,c=r.type===`multiSelect`,l=[...r.options??[]],u=c?XR(GR(n,r)):[String(GR(n,r)??``)].filter(Boolean),d=0,f=I(`div`,{class:`dw-db-tags dw-db-pop__chosen`}),p=I(`input`,{class:`dw-db-input`,placeholder:s.searchOptions,"aria-label":s.searchOptions});p.value=a??``;let m=I(`div`,{class:`dw-db-pop__list`,role:`listbox`});t.append(f,p,m);let h=()=>o.setCell(n.id,r.id,c?u:u[0]??null),g=e=>{u=c?u.includes(e)?u.filter(t=>t!==e):[...u,e]:u[0]===e?[]:[e],h(),c?b():i()},_=e=>{let t={id:LR(),name:e,color:cz(l)};l=[...l,t],o.tx(()=>{o.setOptions(r.id,l),u=c?[...u,t.id]:[t.id],h()}),p.value=``,c?b():i()},v=(t,n)=>{Jj(t,[{id:`rename`,label:s.renameOption,icon:`pencil`,run:()=>{let e=window.prompt(s.renameOption,n.name)?.trim();e&&(l=l.map(t=>t.id===n.id?{...t,name:e}:t),o.setOptions(r.id,l),b())}},{id:`color`,label:s.optionColor,icon:`palette`,children:IP.map(t=>({id:t,label:e.colorNames[t]??t,icon:t===n.color?`check`:`drop`,run:()=>{l=l.map(e=>e.id===n.id?{...e,color:t}:e),o.setOptions(r.id,l),b()}}))},{id:`delete`,label:s.deleteOption,icon:`trash`,danger:!0,run:()=>{l=l.filter(e=>e.id!==n.id),u=u.filter(e=>e!==n.id),o.setOptions(r.id,l),b()}}],s.optionColor,()=>p.focus())},y=[];function b(){f.replaceChildren(...u.flatMap(e=>{let t=l.find(t=>t.id===e);return t?[Hz(t.name,t.color,()=>g(e))]:[]}));let e=p.value.trim();y=l.filter(t=>t.name.toLowerCase().includes(e.toLowerCase())).map(e=>({kind:`option`,o:e})),e&&!l.some(t=>t.name.toLowerCase()===e.toLowerCase())&&y.push({kind:`create`,name:e}),d=Math.min(d,Math.max(0,y.length-1)),m.replaceChildren(...y.map((e,t)=>{let n=I(`div`,{class:`dw-db-pop__item${t===d?` is-active`:``}`,role:`option`,"aria-selected":String(e.kind===`option`&&u.includes(e.o.id))});if(n.addEventListener(`mousedown`,e=>e.preventDefault()),e.kind===`option`){n.append(I(`span`,{class:`dw-db-pop__check`},u.includes(e.o.id)?Sz(`check`,13):null),Hz(e.o.name,e.o.color));let t=I(`button`,{type:`button`,class:`dw-db__btn dw-db__btn--icon dw-db-pop__more`,"aria-label":s.optionColor},Sz(`more`,14));t.addEventListener(`click`,n=>{n.stopPropagation(),v(t,e.o)}),n.append(t),n.addEventListener(`click`,()=>g(e.o.id))}else n.append(I(`span`,{class:`dw-db-pop__check`},Sz(`plus`,13)),I(`span`,{},AR(s.createOption,e.name))),n.addEventListener(`click`,()=>_(e.name));return n}))}p.addEventListener(`input`,()=>{d=0,b()}),p.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),y.length&&(d=(d+(e.key===`ArrowDown`?1:-1)+y.length)%y.length),b();else if(e.key===`Enter`){e.preventDefault();let t=y[d];t?.kind===`option`?g(t.o.id):t?.kind===`create`?_(t.name):i()}else e.key===`Backspace`&&!p.value&&c&&u.length&&g(u[u.length-1])}),b(),p.focus({preventScroll:!0}),p.setSelectionRange(p.value.length,p.value.length)}function qz(e,t,n,r,i){let a=e.store,o=e.labels,s=XR(GR(n,r)).filter(e=>e?.id),c=I(`div`,{class:`dw-db-tags dw-db-pop__chosen`}),l=I(`input`,{class:`dw-db-input`,placeholder:o.searchPeople,"aria-label":o.searchPeople}),u=I(`div`,{class:`dw-db-pop__list`,role:`listbox`});t.append(c,l,u);let d=()=>a.setCell(n.id,r.id,s),f=()=>c.replaceChildren(...s.map(e=>Hz(e.name,`gray`,()=>{s=s.filter(t=>t.id!==e.id),d(),f()}))),p=0,m=[],h=0,g=()=>{u.replaceChildren(...m.length?m.map((e,t)=>{let n=I(`div`,{class:`dw-db-pop__item${t===h?` is-active`:``}`,role:`option`},I(`span`,{class:`dw-db-person__dot`},(e.name||`?`).slice(0,1).toUpperCase()),I(`span`,{},e.name));return n.addEventListener(`mousedown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>_(e)),n}):[I(`div`,{class:`dw-db-pop__empty`},l.value.trim()?o.noPeople:``)])},_=e=>{s.some(t=>t.id===e.id)||(s=[...s,e]),d(),l.value=``,m=[],f(),g()};l.addEventListener(`input`,async()=>{let t=l.value.trim(),n=++p,r=e.people&&t?await e.people.search(t).catch(()=>[]):[];n===p&&(m=r.slice(0,8).map(e=>({id:e.id,name:e.label})),h=0,g())}),l.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),m.length&&(h=(h+(e.key===`ArrowDown`?1:-1)+m.length)%m.length),g();else if(e.key===`Enter`){e.preventDefault();let t=m[h];t?_(t):i()}}),f(),g(),l.focus({preventScroll:!0})}function Jz(e,t,n,r){let i=e.store,a=e.labels,o=XR(GR(n,r)).filter(e=>e?.src),s=I(`div`,{class:`dw-db-pop__list`}),c=()=>s.replaceChildren(...o.map((t,s)=>{let l=e.files?e.files.resolve(t.src):t.src,u=I(`button`,{type:`button`,class:`dw-db__btn dw-db__btn--icon`,"aria-label":a.remove,title:a.remove},Sz(`trash`,14));return u.addEventListener(`click`,()=>{o=o.filter((e,t)=>t!==s),i.setCell(n.id,r.id,o),c()}),I(`div`,{class:`dw-db-pop__item`},I(`a`,{class:`dw-db-file`,href:l,target:`_blank`,rel:`noopener noreferrer`},Sz(`paperclip`,12),t.name),u)}));t.append(s);let l=e.files?.upload;if(l){let s=I(`button`,{type:`button`,class:`dw-db__btn`},Sz(`upload`,14),I(`span`,{},a.upload));s.addEventListener(`click`,()=>{let t=I(`input`,{type:`file`,multiple:!0});t.onchange=async()=>{for(let a of[...t.files??[]])try{let t=await l.call(e.files,a);o=[...o,{name:t.name,src:t.url,size:t.size,mime:t.mime}],i.setCell(n.id,r.id,o),c()}catch{}},t.click()}),t.append(I(`div`,{class:`dw-db-pop__row`},s))}c()}var Yz=class{host;db;rowId;order;onClose;dom;panel;head=I(`div`,{class:`dw-db-peek__head`});props=I(`div`,{class:`dw-db-peek__props`});bodyEl=I(`div`,{class:`dw-db-peek__body`});unmount=null;editing=0;pending=!1;wide=!1;returnFocus;constructor(e,t,n,r,i){this.host=e,this.db=t,this.rowId=n,this.order=r,this.onClose=i,this.returnFocus=document.activeElement,this.panel=I(`div`,{class:`dw-db-peek__panel`,role:`dialog`,"aria-modal":`true`,tabIndex:-1},this.head,this.props,this.bodyEl),this.dom=I(`div`,{class:e.page?`dw-db-peek dw-db-peek--page`:`dw-db-peek`},this.panel),this.dom.addEventListener(`mousedown`,e=>{e.target===this.dom&&!this.host.page&&this.close()}),this.dom.addEventListener(`keydown`,e=>{e.key===`Escape`&&!document.querySelector(`.dw-db-pop, .dw-block-menu`)&&(e.preventDefault(),e.stopPropagation(),this.close())}),e.page?(this.panel.removeAttribute(`aria-modal`),this.panel.setAttribute(`role`,`region`),e.page.container.replaceChildren(this.dom)):document.body.append(this.dom),this.draw(!0),this.panel.focus({preventScroll:!0})}get row(){return this.rowId}ctx(){return{...this.host.ctx,db:this.db,openRow:e=>this.show(e),setEditing:e=>{this.editing=Math.max(0,this.editing+(e?1:-1)),!this.editing&&this.pending&&(this.pending=!1,this.draw(!1))}}}update(e,t){if(this.db=e,t&&(this.host={...this.host,ctx:{...this.host.ctx,...t}}),!e.rows.some(e=>e.id===this.rowId))return this.close();this.editing?this.pending=!0:this.draw(!1)}show(e){e!==this.rowId&&(this.rowId=e,this.draw(!0))}draw(e){let t=this.db.rows.find(e=>e.id===this.rowId);if(!t)return;let n=this.ctx(),r=n.labels,i=n.store;this.panel.classList.toggle(`is-wide`,this.wide);let a=this.order.indexOf(this.rowId),o=Cz(`chevron-up`,r.previousRow,()=>this.show(this.order[a-1])),s=Cz(`chevron-down`,r.nextRow,()=>this.show(this.order[a+1]));o.disabled=a<=0,s.disabled=a<0||a>=this.order.length-1;let c=this.host.page;this.head.replaceChildren(...c?[Cz(`chevron-left`,r.backToPage,()=>this.close())]:[],I(`span`,{class:`dw-db-peek__db`},Sz(`database`,14),this.db.title||r.untitled),I(`span`,{class:`dw-db-peek__grow`}),o,s,...c?[]:[Cz((this.wide,`width`),this.wide?r.collapse:r.expand,()=>{this.wide=!this.wide,this.panel.classList.toggle(`is-wide`,this.wide)})],...this.host.openPage?[Cz(`open`,r.openFullPage,()=>this.host.openPage(this.rowId))]:[],...this.host.copyLink?[Cz(`link`,r.copyLink,()=>this.host.copyLink(this.rowId))]:[],...c?[]:[Cz(`close`,r.close,()=>this.close())]);let l=WR(this.db),u=String(GR(t,l)??``),d=i?(()=>{let e=I(`input`,{class:`dw-db-peek__title`,placeholder:r.untitledRow,"aria-label":l.name||r.typeTitle});return e.value=u,e.addEventListener(`focus`,()=>n.setEditing(!0)),e.addEventListener(`blur`,()=>{e.value!==u&&i.setCell(t.id,l.id,e.value),n.setEditing(!1)}),e.addEventListener(`keydown`,t=>{t.stopPropagation(),t.key===`Enter`&&e.blur()}),e})():I(`h2`,{class:`dw-db-peek__title`},u||r.untitledRow);this.panel.setAttribute(`aria-label`,u||r.untitledRow);let f=[d,...this.db.columns.filter(e=>e.type!==`title`).map(e=>{let a=I(`div`,{class:`dw-db-peek__value dw-db-t__cell--${e.type}`,tabIndex:i&&!Bz.includes(e.type)?0:-1},Wz(n,t,e)),o=()=>{i&&Gz(n,a,t,e,{onDone:()=>this.draw(!1)})};return a.addEventListener(`click`,e=>{e.target.closest(`a, button`)||o()}),a.addEventListener(`keydown`,e=>{e.target===a&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())}),I(`div`,{class:`dw-db-peek__prop`},I(`div`,{class:`dw-db-peek__label`},Sz(Rz[e.type],14),I(`span`,{},e.name||ER(r,e.type))),a)})];if(i){let e=Cz(`plus`,r.addColumn,()=>Jj(e,FR.map(e=>({id:e,label:ER(r,e),icon:Rz[e],run:()=>i.addColumn(e,ER(r,e))})),r.addColumn),r.addColumn);e.classList.add(`dw-db-peek__add`),f.push(e)}let p=this.props.contains(document.activeElement);this.props.replaceChildren(...f),p&&this.panel.focus({preventScroll:!0}),e&&(this.unmount?.(),this.bodyEl.replaceChildren(),this.unmount=this.host.mountBody(this.bodyEl,t))}close(e=!0){this.unmount?.(),this.unmount=null,this.dom.remove(),this.onClose(),e&&this.host.page?.onLeave?.(),this.returnFocus instanceof HTMLElement&&this.returnFocus.isConnected&&this.returnFocus.focus({preventScroll:!0})}},Xz=`docwell-database`,Zz=e=>e.getMap(`blocks`);function Qz(e){let t=new Bb;t.set(`title`,e.title);let n=(e,t)=>{let n=new Lb;return n.push(e.map((e,n)=>$z(t(e),n))),n};return t.set(`columns`,n(e.columns,eB)),t.set(`rows`,n(e.rows,tB)),t.set(`views`,n(e.views,nB)),t}function $z(e,t){return e.set(`pos`,t),e}function eB(e){let t=new Bb;return t.set(`id`,e.id),t.set(`name`,e.name),t.set(`type`,e.type),e.options&&t.set(`options`,e.options),e.relation&&t.set(`relation`,e.relation),e.rollup&&t.set(`rollup`,e.rollup),t}function tB(e){let t=new Bb;t.set(`id`,e.id),t.set(`createdAt`,e.createdAt),e.createdBy&&t.set(`createdBy`,e.createdBy);let n=new Bb;for(let[t,r]of Object.entries(e.cells))r!=null&&n.set(t,r);return t.set(`cells`,n),t}function nB(e){let t=new Bb;for(let[n,r]of Object.entries(e))t.set(n,r);return t}function rB(e){return e.toArray().filter(e=>e instanceof Bb).map((e,t)=>({m:e,p:iB(e,t),i:t})).sort((e,t)=>e.p-t.p||e.i-t.i).map(e=>e.m)}function iB(e,t){let n=e?.get(`pos`);return typeof n==`number`?n:t}function aB(e,t,n){let r=n?e.filter(e=>e!==n):e,i=Math.max(0,Math.min(t,r.length)),a=i>0?iB(r[i-1],i-1):null,o=i{let n=e.get(t);return n instanceof Lb?rB(n):[]},n=e=>{let t=e.toJSON();return delete t.pos,t},r=new Set,i=t(`rows`).map(e=>{let t=e.get(`cells`),n=e.get(`body`),i=e.get(`id`);return typeof i==`string`&&n instanceof sx&&n.length>0&&r.add(i),{id:i,createdAt:e.get(`createdAt`),createdBy:e.get(`createdBy`),cells:t instanceof Bb?t.toJSON():{}}}),a=BR({title:e.get(`title`),columns:t(`columns`).map(n),rows:i,views:t(`views`).map(n)});for(let e of a.rows)r.has(e.id)&&(e.hasBody=!0);return a}function sB(e,t=``){let n=[{id:LR(),name:e.columnName(`title`),type:`title`},{id:LR(),name:e.columnName(`select`),type:`select`,options:[]}],r=Date.now();return{title:t,columns:n,rows:[0,1,2].map(e=>({id:LR(),cells:{},createdAt:r+e,createdBy:null})),views:[RR(`table`,e.tableView,n)]}}var cB=e=>e==null||e===``||Array.isArray(e)&&!e.length,lB=class{doc;map;me;constructor(e,t,n){this.doc=e,this.map=t,this.me=n}snapshot(){return oB(this.map)}observe(e){let t=()=>e();return this.map.observeDeep(t),()=>this.map.unobserveDeep(t)}tx(e){this.doc.transact(e,Xz)}list(e){let t=this.map.get(e);return t instanceof Lb||(t=new Lb,this.map.set(e,t)),t}find(e,t){let n=rB(this.list(e)),r=n.findIndex(e=>e.get(`id`)===t);return r<0?null:{item:n[r],index:r}}insertAt(e,t,n){let r=this.list(e),i=rB(r),a=Math.max(0,Math.min(t??i.length,i.length));for(let e of n)e.set(`pos`,aB(i,a)),i.splice(a++,0,e);r.push(n)}moveTo(e,t,n){let r=this.find(e,t);r&&r.index!==n&&r.item.set(`pos`,aB(rB(this.list(e)),n,r.item))}remove(e,t){let n=this.list(e),r=n.toArray().indexOf(t);r>=0&&n.delete(r,1)}setTitle(e){this.tx(()=>this.map.set(`title`,e))}addColumn(e,t,n){let r={id:LR(),name:t,type:e};return(e===`select`||e===`multiSelect`)&&(r.options=[]),this.tx(()=>this.insertAt(`columns`,n,[eB(r)])),r.id}renameColumn(e,t){this.tx(()=>this.find(`columns`,e)?.item.set(`name`,t))}setRelation(e,t){this.tx(()=>{let n=this.find(`columns`,e);if(!n)return;let r=n.item.get(`relation`);if(n.item.set(`relation`,t),t.back||r&&(r.page!==t.page||r.database!==t.database))for(let t of this.list(`rows`).toArray()){let n=t.get(`cells`);n instanceof Bb&&n.delete(e)}})}setRollup(e,t){this.tx(()=>this.find(`columns`,e)?.item.set(`rollup`,t))}setOptions(e,t){this.tx(()=>this.find(`columns`,e)?.item.set(`options`,t))}changeType(e,t){let n=this.snapshot(),r=n.columns.find(t=>t.id===e);if(!r||r.type===t||r.type===`title`||t===`title`)return;let i=t===`select`||t===`multiSelect`?r.options??[]:[],a=new Map;for(let o of n.rows){let n=lz(o.cells[e],r,t,i);i=n.options,a.set(o.id,n.value)}this.tx(()=>{let n=this.find(`columns`,e);if(n){n.item.set(`type`,t),t===`select`||t===`multiSelect`?n.item.set(`options`,i):n.item.delete(`options`),t!==`relation`&&n.item.delete(`relation`),t!==`rollup`&&n.item.delete(`rollup`);for(let t of this.list(`rows`).toArray()){let n=t.get(`cells`);if(!(n instanceof Bb))continue;let r=a.get(String(t.get(`id`)));cB(r)||r===!1?n.delete(e):n.set(e,r)}}})}deleteColumn(e){this.tx(()=>{let t=this.find(`columns`,e);if(t&&t.item.get(`type`)!==`title`){this.remove(`columns`,t.item);for(let t of this.list(`rows`).toArray()){let n=t.get(`cells`);n instanceof Bb&&n.delete(e)}}})}moveColumn(e,t){this.tx(()=>this.moveTo(`columns`,e,t))}duplicateColumn(e,t){let n=this.snapshot().columns.find(t=>t.id===e);if(!n||n.type===`title`)return null;let r={...structuredClone(n),id:LR(),name:t};return this.tx(()=>{let t=this.find(`columns`,e);if(t){this.insertAt(`columns`,t.index+1,[eB(r)]);for(let t of this.list(`rows`).toArray()){let n=t.get(`cells`);n instanceof Bb&&n.has(e)&&n.set(r.id,n.get(e))}}}),r.id}addRow(e={},t){return this.addRows([e],t)[0]}addRows(e,t){let n=this.me(),r=Date.now(),i=e.map((e,t)=>({id:LR(),cells:e,createdAt:r+t,createdBy:n}));return this.tx(()=>this.insertAt(`rows`,t,i.map(tB))),i.map(e=>e.id)}setCell(e,t,n){this.setCells([{row:e,col:t,value:n}])}setCells(e){this.tx(()=>{for(let{row:t,col:n,value:r}of e){let e=this.find(`rows`,t)?.item.get(`cells`);e instanceof Bb&&(cB(r)?e.delete(n):e.set(n,r))}})}deleteRows(e){this.tx(()=>{let t=this.list(`rows`);for(let n=t.length-1;n>=0;n--)e.includes(String(t.get(n)?.get(`id`)))&&t.delete(n,1)})}moveRow(e,t){this.tx(()=>this.moveTo(`rows`,e,t))}duplicateRow(e){let t=this.find(`rows`,e);if(!t)return null;let n=uB(t.item,this.me());return this.tx(()=>this.insertAt(`rows`,t.index+1,[n])),String(n.get(`id`))}rowBody(e){let t=this.find(`rows`,e);if(!t)return null;let n=t.item.get(`body`);if(n instanceof sx)return n;let r=new sx;return this.tx(()=>t.item.set(`body`,r)),r}rowIndex(e){return this.find(`rows`,e)?.index??-1}addView(e,t){let n=RR(e,t,this.snapshot().columns);return this.tx(()=>this.insertAt(`views`,void 0,[nB(n)])),n.id}updateView(e,t){this.tx(()=>{let n=this.find(`views`,e);if(n)for(let[e,r]of Object.entries(t))n.item.set(e,r)})}duplicateView(e,t){let n=this.snapshot().views.find(t=>t.id===e);if(!n)return null;let r={...structuredClone(n),id:LR(),name:t};return this.tx(()=>{let t=this.find(`views`,e);this.insertAt(`views`,(t?.index??-1)+1,[nB(r)])}),r.id}deleteView(e){this.tx(()=>{let t=this.find(`views`,e);t&&this.list(`views`).length>1&&this.remove(`views`,t.item)})}moveView(e,t){this.tx(()=>this.moveTo(`views`,e,t))}};function uB(e,t){let n=new Bb;n.set(`id`,LR()),n.set(`createdAt`,Date.now());let r=t??e.get(`createdBy`);UR(r)&&n.set(`createdBy`,r);let i=new Bb,a=e.get(`cells`);if(a instanceof Bb)for(let[e,t]of a.entries())i.set(e,t);n.set(`cells`,i);let o=e.get(`body`);if(o instanceof sx&&o.length){let e=new sx;e.insert(0,o.toArray().map(e=>e.clone())),n.set(`body`,e)}return n}function dB(e,t){let n=oB(e),r=e.get(`rows`);if(r instanceof Lb){let e=new Map;for(let t of r.toArray()){let n=t.get(`body`);n instanceof sx&&n.length&&e.set(String(t.get(`id`)),n)}for(let r of n.rows){let n=e.get(r.id);n&&(r.body=t(n))}}return n}function fB(e,t,n,r){e.transact(()=>{let i=Qz(n);Zz(e).set(t,i);let a=i.get(`rows`),o=new Map(n.rows.map(e=>[e.id,e]));for(let e of a.toArray()){let t=o.get(String(e.get(`id`)))?.body;if(!t?.length)continue;let n=new sx;e.set(`body`,n),r(t,n)}},Xz)}function pB(e,t=`,`){let n=[],r=[],i=``,a=!1,o=0,s=e.replace(/^\uFEFF/,``);for(;o({tr:r,dispatch:i,editor:a})=>{let o=dP(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(T.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>BM(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>VM(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return UM(e,t&&(e=>{n&&mP(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>KM(e,t),addRowAfter:()=>({state:e,dispatch:t})=>qM(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return YM(e,t&&(e=>{n&&mP(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>cN(e,t),mergeCells:()=>({state:e,dispatch:t})=>QM(e,t),splitCell:()=>({state:e,dispatch:t})=>$M(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>iN(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>iN(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>aN(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>QM(e,t)?!0:$M(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>tN(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>sN(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>sN(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&IM(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=OM.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:pP,"Mod-Backspace":pP,Delete:pP,"Mod-Delete":pP}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[jN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],GN({allowTableNodeSelection:this.options.allowTableNodeSelection}),wP()]},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}))}}}),EP=Tp.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(TP.configure(this.options.table)),this.options.tableCell!==!1&&e.push(nP.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(rP.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(iP.configure(this.options.tableRow)),e}}),DP=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 OP(){return[Bk.configure({HTMLAttributes:{class:`dw-tasks`}}),zk.configure({nested:!0})]}function kP(){return[EP.configure({table:{resizable:!0,cellMinWidth:60,HTMLAttributes:{class:`dw-table`}}})]}var AP=DP.configure({types:[`heading`,`paragraph`],alignments:[`left`,`center`,`right`]}),jP=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}}),MP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,NP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,PP=_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}){return[`mark`,A(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark(`highlight`,t.parseInline(e.tokens||[])),markdownTokenizer:{name:`highlight`,level:`inline`,start:e=>e.indexOf(`==`),tokenize(e,t,n){let r=/^(==)(?!\s)([^=]*[^=\s])(==)/.exec(e);if(r){let e=r[2].trim(),t=n.inlineTokens(e);return{type:`highlight`,raw:r[0],text:e,tokens:t}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Hp({find:MP,type:this.type})]},addPasteRules(){return[Yp({find:NP,type:this.type})]}}),FP=[`gray`,`red`,`orange`,`yellow`,`green`,`teal`,`blue`,`purple`,`pink`],IP=e=>typeof e==`string`&&FP.includes(e),LP=_p.create({name:`textColor`,addAttributes(){return{color:{default:null,parseHTML:e=>{let t=e.getAttribute(`data-color`);return IP(t)?t:null},renderHTML:e=>e.color?{"data-color":e.color}:{}}}},parseHTML(){return[{tag:`span[data-color]`,getAttrs:e=>IP(e.getAttribute(`data-color`))?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`span`,A(e,{class:`dw-text-color`}),0]},addCommands(){return{setTextColor:e=>({commands:t})=>t.setMark(this.name,{color:e}),unsetTextColor:()=>({commands:e})=>e.unsetMark(this.name)}}}),RP=PP.extend({addOptions(){return{...this.parent(),multicolor:!0}},addAttributes(){return{color:{default:null,parseHTML:e=>{let t=e.getAttribute(`data-color`);return IP(t)?t:null},renderHTML:e=>({"data-color":IP(e.color)?e.color:`yellow`})}}},renderHTML({HTMLAttributes:e}){return[`mark`,A(e,{class:`dw-highlight`}),0]}}),zP=`💡`;function BP(e){let t=e.trim();return t&&[...t].length<=4?t:``}var VP=Jp.create({name:`callout`,group:`block`,content:`block+`,defining:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){return{emoji:{default:zP,parseHTML:e=>BP(e.getAttribute(`data-emoji`)??``)||zP,renderHTML:e=>({"data-emoji":e.emoji})},color:{default:`blue`,parseHTML:e=>{let t=e.getAttribute(`data-color`);return IP(t)?t:`blue`},renderHTML:e=>({"data-color":e.color})}}},parseHTML(){return[{tag:`aside[data-type=callout]`,contentElement:e=>e.querySelector(`:scope > .callout-body`)??e}]},renderHTML({HTMLAttributes:e}){return[`aside`,A(e,{"data-type":`callout`,class:`dw-callout`}),0]},addCommands(){return{setCallout:e=>({commands:t})=>t.wrapIn(this.name,e),unsetCallout:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{$from:t,empty:n}=e.state.selection;if(!n||t.parentOffset>0)return!1;for(let n=t.depth-1;n>0;n--){if(t.node(n).type.name===this.name)return t.index(n)!==0||t.start(n+1)!==t.start()?!1:e.commands.lift(this.name);if(t.index(n)!==0)return!1}return!1}}},addNodeView(){return({node:e,getPos:t,editor:n})=>{let r=this.options.labels,i=document.createElement(`aside`);i.className=`dw-callout`,i.setAttribute(`data-type`,`callout`);let a=document.createElement(`div`);a.className=`dw-callout__side`,a.contentEditable=`false`;let o=document.createElement(`button`);o.type=`button`,o.className=`dw-callout__emoji`;let s=document.createElement(`button`);s.type=`button`,s.className=`dw-callout__color`,a.append(o,s);let c=document.createElement(`div`);c.className=`dw-callout__body`,i.append(a,c);let l=e,u=e=>{let r=t();typeof r==`number`&&n.isEditable&&n.view.dispatch(n.state.tr.setNodeMarkup(r,void 0,{...l.attrs,...e}))};o.addEventListener(`mousedown`,e=>e.preventDefault()),o.addEventListener(`click`,()=>{if(!n.isEditable)return;let e=BP(window.prompt(r?.blocks.calloutEmoji??`Emoji`,l.attrs.emoji)??``);e&&u({emoji:e})}),s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`click`,()=>{let e=FP.indexOf(l.attrs.color);u({color:FP[(e+1)%FP.length]})});let d=()=>{i.setAttribute(`data-color`,String(l.attrs.color)),o.textContent=String(l.attrs.emoji);let e=r?.blocks.calloutEmoji??`Emoji`;o.setAttribute(`aria-label`,e),o.title=e;let t=r?.blocks.calloutColor??`Colour`;s.setAttribute(`aria-label`,t),s.title=t};return d(),{dom:i,contentDOM:c,update:t=>t.type===e.type&&(l=t,d(),!0),stopEvent:e=>a.contains(e.target),ignoreMutation:e=>a.contains(e.target)}}}}),HP=10;function UP(e){let t=typeof e==`string`?parseFloat(e):typeof e==`number`?e:NaN;return Number.isFinite(t)&&t>0&&t<=100?Math.round(t*10)/10:null}function WP(e){let t=[];e.forEach(e=>t.push(UP(e.attrs.width)));let n=t.reduce((e,t)=>e+(t??0),0),r=t.filter(e=>e===null).length,i=r?Math.max(100-n,r*HP)/r:0,a=t.map(e=>e??i),o=a.reduce((e,t)=>e+t,0)||1;return a.map(e=>e*100/o)}function GP(e){let{$from:t}=e.state.selection;for(let e=t.depth;e>0;e--)if(t.node(e).type.name===`columns`)return e;return-1}function KP(e,t=null){let{schema:n}=e.state;return n.nodes.column.create({width:t},n.nodes.paragraph.create())}function qP(e){return e.childCount===1&&e.firstChild.type.name===`paragraph`&&e.firstChild.content.size===0}var JP=Jp.create({name:`columns`,group:`block`,content:`column{2,4}`,defining:!0,isolating:!0,draggable:!0,addOptions(){return{labels:null}},parseHTML(){return[{tag:`div[data-type=columns]`}]},renderHTML({HTMLAttributes:e}){return[`div`,A(e,{"data-type":`columns`,class:`dw-columns`}),0]},addCommands(){return{insertColumns:(e=2)=>({editor:t,tr:n,dispatch:r})=>{let i=Math.min(Math.max(Math.round(e),2),4),a=t.schema.nodes.columns.create(null,Array.from({length:i},()=>KP(t)));if(!r)return!0;let o=n.selection.from;n.replaceSelectionWith(a);let s=-1;return n.doc.nodesBetween(o,Math.min(o+a.nodeSize+2,n.doc.content.size),(e,t)=>(s<0&&e.type.name===`columns`&&(s=t),s<0)),s>=0&&n.setSelection(T.create(n.doc,s+3)),n.scrollIntoView(),!0},addColumn:()=>({editor:e,tr:t,dispatch:n})=>{let r=GP(e);if(r<0)return!1;let{$from:i}=t.selection,a=i.node(r);if(a.childCount>=4)return!1;if(!n)return!0;let o=i.index(r),s=i.before(r),c=WP(a),l=100/(a.childCount+1),u=(100-l)/100,d=s+1;a.forEach((e,n,r)=>{t.setNodeMarkup(t.mapping.map(d),void 0,{...e.attrs,width:c[r]*u}),d+=e.nodeSize});let f=s+1;for(let e=0;e<=o;e++)f+=a.child(e).nodeSize;let p=t.mapping.map(f);return t.insert(p,KP(e,l)),t.setSelection(T.create(t.doc,p+2)),!0},unsetColumns:()=>({editor:e,tr:t,dispatch:n})=>{let r=GP(e);if(r<0)return!1;if(!n)return!0;let{$from:i}=t.selection,a=i.node(r),o=[];a.forEach(e=>{qP(e)||e.forEach(e=>o.push(e))}),o.length||o.push(e.schema.nodes.paragraph.create());let c=i.before(r);return t.replaceWith(c,c+a.nodeSize,s.from(o)),t.setSelection(T.near(t.doc.resolve(c+1))),!0}}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{$from:t,empty:n}=e.state.selection;if(!n||t.parentOffset>0)return!1;let r=GP(e);if(r<0||t.depth!==r+2)return!1;let i=t.node(r),a=t.node(r+1);if(!qP(a))return!1;if(i.childCount<=2)return e.commands.unsetColumns();let o=t.index(r),s=t.before(r+1),c=e.state.tr.delete(s,s+a.nodeSize),l=t.before(r),u=c.doc.nodeAt(l),d=WP(u),f=l+1;u.forEach((e,t,n)=>{c.setNodeMarkup(f,void 0,{...e.attrs,width:d[n]}),f+=e.nodeSize});let p=Math.max(o-1,0),m=l+1;for(let e=0;e<=p;e++)m+=c.doc.nodeAt(l).child(e).nodeSize;return c.setSelection(T.near(c.doc.resolve(m-1),-1)),e.view.dispatch(c.scrollIntoView()),!0},"Mod-Alt-ArrowRight":({editor:e})=>e.commands.addColumn()}}}),YP=Jp.create({name:`column`,content:`block+`,isolating:!0,addOptions(){return{labels:null}},addAttributes(){return{width:{default:null,parseHTML:e=>UP(e.getAttribute(`data-width`)),renderHTML:e=>e.width==null?{}:{"data-width":String(UP(e.width))}}}},parseHTML(){return[{tag:`div[data-type=column]`}]},renderHTML({HTMLAttributes:e}){return[`div`,A(e,{"data-type":`column`,class:`dw-column`}),0]},addNodeView(){return({node:e,getPos:t,editor:n})=>{let r=this.options.labels,i=document.createElement(`div`);i.className=`dw-column`,i.setAttribute(`data-type`,`column`);let a=document.createElement(`div`);a.className=`dw-column__body`;let o=document.createElement(`div`);o.className=`dw-column__resize`,o.contentEditable=`false`,o.setAttribute(`role`,`separator`),o.setAttribute(`aria-orientation`,`vertical`);let s=document.createElement(`button`);s.type=`button`,s.className=`dw-column__add`,s.contentEditable=`false`,s.textContent=`+`,i.append(a,o,s);let c=()=>{let e=t();if(typeof e!=`number`)return null;let r=n.state.doc.resolve(e),i=r.parent;return i.type.name===`columns`?{row:i,index:r.index(),rowPos:r.before()}:null},l=()=>{let e=c(),t=e?WP(e.row):[100],n=e?t[e.index]:100;i.style.flexGrow=String(n);let a=!e||e.index===e.row.childCount-1;o.hidden=a,s.hidden=!e||e.row.childCount>=4;let l=r?.blocks.resizeColumn??`Drag to resize`;o.title=l,o.setAttribute(`aria-label`,l);let u=r?.blocks.addColumn??`Add a column`;s.title=u,s.setAttribute(`aria-label`,u)};return l(),s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`click`,()=>{let e=t();typeof e==`number`&&n.isEditable&&n.chain().setTextSelection(e+2).addColumn().focus().run()}),o.addEventListener(`pointerdown`,e=>{let t=c();if(!t||!n.isEditable||t.index>=t.row.childCount-1)return;e.preventDefault();let r=i.parentElement,a=i.nextElementSibling;if(!r||!a)return;let s=r.getBoundingClientRect().width||1,u=WP(t.row),d=u[t.index]+u[t.index+1],f=e.clientX,p=u[t.index],m=p;o.setPointerCapture(e.pointerId),i.classList.add(`is-resizing`);let h=e=>{m=Math.min(Math.max(p+(e.clientX-f)*100/s,HP),d-HP),i.style.flexGrow=String(m),a.style.flexGrow=String(d-m)},g=()=>{o.removeEventListener(`pointermove`,h),o.removeEventListener(`pointerup`,g),o.removeEventListener(`pointercancel`,g),i.classList.remove(`is-resizing`);let e=c();if(!e||Math.abs(m-p)<.5)return l();let t=WP(e.row);t[e.index]=m,t[e.index+1]=d-m;let r=n.state.tr,a=e.rowPos+1;e.row.forEach((e,n,i)=>{r.setNodeMarkup(a,void 0,{...e.attrs,width:Math.round(t[i]*10)/10}),a+=e.nodeSize}),n.view.dispatch(r)};o.addEventListener(`pointermove`,h),o.addEventListener(`pointerup`,g),o.addEventListener(`pointercancel`,g)}),{dom:i,contentDOM:a,update:t=>t.type===e.type&&(l(),!0),stopEvent:e=>o.contains(e.target)||s.contains(e.target),ignoreMutation:e=>o.contains(e.target)||s.contains(e.target)||e.type===`attributes`&&e.target===i}}}}),XP=e=>[e.x+e.w/2,e.y+e.h/2];function ZP(e){if(!e.length)return null;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.w),i=Math.max(i,a.y+a.h);return{x:t,y:n,w:r-t,h:i-n}}var QP=(e,t)=>({x:e.x-t,y:e.y-t,w:e.w+2*t,h:e.h+2*t}),$P=(e,t)=>e.x<=t.x+t.w&&t.x<=e.x+e.w&&e.y<=t.y+t.h&&t.y<=e.y+e.h,eF=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.w<=e.x+e.w&&t.y+t.h<=e.y+e.h;function tF(e,t){return{x:Math.min(e[0],t[0]),y:Math.min(e[1],t[1]),w:Math.abs(e[0]-t[0]),h:Math.abs(e[1]-t[1])}}function nF([e,t],[n,r],i){if(!i)return[e,t];let a=i*Math.PI/180,o=Math.cos(a),s=Math.sin(a);return[n+(e-n)*o-(t-r)*s,r+(e-n)*s+(t-r)*o]}function rF(e,t){if(!t)return e;let n=XP(e),r=[[e.x,e.y],[e.x+e.w,e.y],[e.x+e.w,e.y+e.h],[e.x,e.y+e.h]].map(e=>nF(e,n,t));return tF([Math.min(...r.map(e=>e[0])),Math.min(...r.map(e=>e[1]))],[Math.max(...r.map(e=>e[0])),Math.max(...r.map(e=>e[1]))])}function iF([e,t],[n,r],[i,a]){let o=i-n,s=a-r,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c)):0;return Math.hypot(e-(n+l*o),t-(r+l*s))}function aF(e,t){if(t.length===1)return Math.hypot(e[0]-t[0][0],e[1]-t[0][1]);let n=1/0;for(let r=1;re[1]-t[1]),r[0][0]}var sF={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]};function cF(e,t,n=!1){let[r,i]=XP(e),a=t[0]-r,o=t[1]-i;if(!a&&!o)return[r,i];let s=Math.max(e.w/2,.5),c=Math.max(e.h/2,.5),l=n?1/Math.sqrt(a*a/(s*s)+o*o/(c*c)):Math.min(Math.abs(s/(a||1e-9)),Math.abs(c/(o||1e-9)));return[r+a*l,i+o*l]}var lF=e=>[[`top`,[e.x+e.w/2,e.y]],[`right`,[e.x+e.w,e.y+e.h/2]],[`bottom`,[e.x+e.w/2,e.y+e.h]],[`left`,[e.x,e.y+e.h/2]]];function uF(e,t){let n=e=>{if(!e.id)return[e.x??0,e.y??0];let n=t(e.id);return n?e.pos?[n.box.x+n.box.w*e.pos[0],n.box.y+n.box.h*e.pos[1]]:null:[e.x??0,e.y??0]},r=e=>{let n=e.id?t(e.id):null;return n?XP(n.box):[e.x??0,e.y??0]},i=(e,i)=>{let a=n(e),o=e.id?t(e.id):null;if(a)return{at:a,side:o?oF(o.box,a):null};let s=cF(o.box,n(i)??r(i),o.ellipse);return{at:s,side:oF(o.box,s)}};return[i(e.source,e.target),i(e.target,e.source)]}var dF=e=>Math.round(e*100)/100,fF=e=>e.map((e,t)=>`${t?`L`:`M`}${dF(e[0])} ${dF(e[1])}`).join(` `),pF=(e,t)=>Math.atan2(t[1]-e[1],t[0]-e[0]);function mF(e,t,n){let[r,i]=t.at,[a,o]=n.at,s=Math.hypot(a-r,o-i);if(e===`straight`||s<1)return{points:[t.at,n.at],d:fF([t.at,n.at]),mid:[(r+a)/2,(i+o)/2],startAngle:pF(n.at,t.at),endAngle:pF(t.at,n.at)};if(e===`curve`){let e=Math.min(s/2,160),c=t.side?sF[t.side]:hF(t.at,n.at),l=n.side?sF[n.side]:hF(n.at,t.at),u=[r+c[0]*e,i+c[1]*e],d=[a+l[0]*e,o+l[1]*e],f=[];for(let e=0;e<=24;e++)f.push(gF(t.at,u,d,n.at,e/24));return{points:f,d:`M${dF(r)} ${dF(i)} C${dF(u[0])} ${dF(u[1])} ${dF(d[0])} ${dF(d[1])} ${dF(a)} ${dF(o)}`,mid:gF(t.at,u,d,n.at,.5),startAngle:pF(u,t.at),endAngle:pF(d,n.at)}}let c=t.side??(Math.abs(a-r)>Math.abs(o-i)?a>r?`right`:`left`:o>i?`bottom`:`top`),l=n.side??(Math.abs(a-r)>Math.abs(o-i)?a>r?`left`:`right`:o>i?`top`:`bottom`),u=[r+sF[c][0]*24,i+sF[c][1]*24],d=[a+sF[l][0]*24,o+sF[l][1]*24],f=c===`left`||c===`right`,p=l===`left`||l===`right`,m;if(f&&p){let e=(u[0]+d[0])/2;m=[[e,u[1]],[e,d[1]]]}else if(!f&&!p){let e=(u[1]+d[1])/2;m=[[u[0],e],[d[0],e]]}else m=f?[[d[0],u[1]]]:[[u[0],d[1]]];let h=_F([t.at,u,...m,d,n.at]);return{points:h,d:fF(h),mid:vF(h),startAngle:pF(h[1]??n.at,t.at),endAngle:pF(h[h.length-2]??t.at,n.at)}}function hF(e,t){let n=Math.hypot(t[0]-e[0],t[1]-e[1])||1;return[(t[0]-e[0])/n,(t[1]-e[1])/n]}function gF(e,t,n,r,i){let a=1-i,o=a*a*a,s=3*a*a*i,c=3*a*i*i,l=i*i*i;return[o*e[0]+s*t[0]+c*n[0]+l*r[0],o*e[1]+s*t[1]+c*n[1]+l*r[1]]}function _F(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&Math.abs(e[0]-n[0])<.01&&Math.abs(e[1]-n[1])<.01)continue;let r=t[t.length-2];if(r&&e){let i=(e[0]-r[0])*(n[1]-r[1])-(e[1]-r[1])*(n[0]-r[0]);Math.abs(i)<.01&&t.pop()}t.push(n)}return t}function vF(e){let t=0;for(let n=1;n=n&&a>0)return[r[0]+(i[0]-r[0])*n/a,r[1]+(i[1]-r[1])*n/a];n-=a}return e[0]??[0,0]}function yF(e,t,n){let r=e=>[e.x,e.x+e.w/2,e.x+e.w],i=e=>[e.y,e.y+e.h/2,e.y+e.h],a={dx:0,ox:null,vx:0},o={dy:0,oy:null,vy:0},s=n+1,c=n+1;for(let n of t){for(let t of r(e))for(let e of r(n)){let r=Math.abs(e-t);rtypeof e==`string`&&CF.includes(e),TF=[`rect`,`roundrect`,`ellipse`,`diamond`,`triangle`],EF=[`straight`,`curve`,`elbow`],DF=[`none`,`arrow`,`triangle`,`circle`,`diamond`],OF=[`right`,`left`,`radial`],kF=`page`,AF=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t,jF=(e,t=``)=>typeof e==`string`?e:t,MF=e=>e===!0,NF=(e,t)=>wF(e)?e:t,PF=(e,t,n)=>typeof e==`string`&&t.includes(e)?e:n;function FF(e){if(!e||typeof e!=`object`)return{x:0,y:0};let t=e,n={};return typeof t.id==`string`&&t.id&&(n.id=t.id),Array.isArray(t.pos)&&t.pos.length===2&&(n.pos=[AF(t.pos[0],.5),AF(t.pos[1],.5)]),n.id||(n.x=AF(t.x,0),n.y=AF(t.y,0)),n}function IF(e){let t={};if(!e||typeof e!=`object`)return t;for(let[n,r]of Object.entries(e)){if(!r||typeof r!=`object`)continue;let e=r;t[n]={text:jF(e.text),parent:jF(e.parent),pos:AF(e.pos,0)}}return t}function LF(e){let t={id:jF(e.id),index:AF(e.index,0),x:AF(e.x,0),y:AF(e.y,0),w:Math.max(0,AF(e.w,0)),h:Math.max(0,AF(e.h,0)),rotate:AF(e.rotate,0),group:jF(e.group)};switch(e.type){case`shape`:return{...t,type:`shape`,shape:PF(e.shape,TF,`rect`),stroke:NF(e.stroke,`ink`),fill:NF(e.fill,`none`),strokeWidth:AF(e.strokeWidth,2),strokeStyle:PF(e.strokeStyle,[`solid`,`dash`,`none`],`solid`),rough:MF(e.rough),text:jF(e.text),textColor:NF(e.textColor,`ink`),fontSize:AF(e.fontSize,18)};case`text`:return{...t,type:`text`,text:jF(e.text),color:NF(e.color,`ink`),fontSize:AF(e.fontSize,24),font:PF(e.font,[``,`serif`,`mono`],``),align:PF(e.align,[`left`,`center`,`right`],`left`),bold:MF(e.bold)};case`connector`:return{...t,type:`connector`,source:FF(e.source),target:FF(e.target),mode:PF(e.mode,EF,`curve`),stroke:NF(e.stroke,`ink`),strokeWidth:AF(e.strokeWidth,2),strokeStyle:PF(e.strokeStyle,[`solid`,`dash`,`none`],`solid`),startArrow:PF(e.startArrow,DF,`none`),endArrow:PF(e.endArrow,DF,`arrow`),label:jF(e.label),rough:MF(e.rough)};case`brush`:return{...t,type:`brush`,points:Array.isArray(e.points)?e.points.filter(e=>Array.isArray(e)&&e.length>=2).map(e=>[AF(e[0],0),AF(e[1],0),AF(e[2],.5)]):[],color:NF(e.color,`ink`),size:AF(e.size,4)};case`note`:return{...t,type:`note`,page:MF(e.page),background:NF(e.background,`paper`)};case`frame`:return{...t,type:`frame`,title:jF(e.title),background:NF(e.background,`none`)};case`image`:return{...t,type:`image`,src:jF(e.src),alt:jF(e.alt)};case`embed`:return{...t,type:`embed`,url:jF(e.url)};case`group`:return{...t,type:`group`,title:jF(e.title)};case`mindmap`:return{...t,type:`mindmap`,layout:PF(e.layout,OF,`right`),color:NF(e.color,`blue`),nodes:IF(e.nodes)};default:return null}}var RF=e=>![`connector`,`group`,`mindmap`].includes(e.type),zF=e=>[`shape`,`text`,`image`,`brush`].includes(e.type),BF=e=>![`connector`,`brush`,`group`].includes(e.type),VF=0;function HF(){return VF=(VF+1)%1296,Date.now().toString(36).slice(-6)+VF.toString(36).padStart(2,`0`)+Math.random().toString(36).slice(2,8)}var UF={shape:{shape:`rect`,stroke:`blue`,fill:`blue`,strokeWidth:2,strokeStyle:`solid`,rough:!1,textColor:`ink`},connector:{mode:`curve`,stroke:`gray`,strokeWidth:2,strokeStyle:`solid`,startArrow:`none`,endArrow:`arrow`},brush:{color:`ink`,size:4},text:{color:`ink`,fontSize:24,font:``},note:{background:`yellow`},frame:{background:`none`},mindmap:{layout:`right`,color:`blue`}};function WF(e){let t=structuredClone(UF);if(!e||typeof e!=`object`)return t;for(let n of Object.keys(t)){let r=e[n];if(!r||typeof r!=`object`)continue;let i=LF({...t[n],...r,type:n===`note`?`note`:n});if(i)for(let e of Object.keys(t[n])){let a=r[e];a!==void 0&&i[e]===a&&(t[n][e]=a)}}return t}var GF=[`👍`,`⭐`,`❤️`,`✅`,`❌`,`💡`,`❓`,`❗`,`🎉`,`🔥`,`📌`,`🚀`,`👀`,`🎯`,`⚠️`,`🙂`];function KF(e){return[{id:HF(),type:`text`,text:e,fontSize:64,x:0,y:0,w:0,h:0}]}var qF=[`kanban`,`swot`,`flow`,`brainstorm`,`retro`],JF=e=>[{type:`paragraph`,content:e?[{type:`text`,text:e}]:[]}],YF=(e,t,n,r,i,a=`none`)=>({id:HF(),type:`frame`,title:e,x:t,y:n,w:r,h:i,background:a}),XF=(e,t,n,r,i=220)=>({id:HF(),type:`note`,background:r,x:t,y:n,w:i,h:90,body:JF(e)}),ZF=(e,t,n,r,i,a,o)=>({id:HF(),type:`shape`,shape:e,text:t,x:n,y:r,w:i,h:a,stroke:o,fill:o,strokeWidth:2}),QF=(e,t,n=`elbow`)=>({id:HF(),type:`connector`,source:{id:e},target:{id:t},mode:n,stroke:`gray`,endArrow:`arrow`});function $F(e,t){switch(e){case`kanban`:return[[t.todo,`gray`],[t.doing,`blue`],[t.done,`green`]].flatMap(([e,t],n)=>[YF(e,n*300,0,280,520),XF(``,n*300+30,50,t),XF(``,n*300+30,170,t)]);case`swot`:return[[t.strengths,`green`],[t.weaknesses,`red`],[t.opportunities,`blue`],[t.threats,`orange`]].flatMap(([e,t],n)=>[ZF(`roundrect`,e,n%2*380,Math.floor(n/2)*300,360,280,t)]);case`flow`:{let e=ZF(`ellipse`,t.start,0,0,180,70,`green`),n=ZF(`rect`,t.step,0,140,180,80,`blue`),r=ZF(`diamond`,t.decision,-10,290,200,120,`orange`),i=ZF(`rect`,t.step,280,310,180,80,`blue`),a=ZF(`ellipse`,t.end,0,480,180,70,`red`);return[e,n,r,i,a,QF(e.id,n.id),QF(n.id,r.id),QF(r.id,i.id),QF(r.id,a.id)]}case`brainstorm`:{let e=HF(),n={[e]:{text:t.centralIdea,parent:``,pos:0}};for(let r=0;r<4;r++)n[HF()]={text:`${t.idea} ${r+1}`,parent:e,pos:r};return[{id:HF(),type:`mindmap`,layout:`radial`,color:`purple`,x:0,y:0,nodes:n}]}case`retro`:return[[t.wentWell,`green`],[t.toImprove,`orange`],[t.actions,`blue`]].flatMap(([e,t],n)=>[YF(e,n*300,0,280,420),XF(``,n*300+30,50,t)])}}var eI;function tI(){if(eI!==void 0)return eI;try{eI=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):null}catch{eI=null}return eI}var nI=`"Inter Variable", Inter, ui-sans-serif, system-ui, sans-serif`,rI=`"Source Serif 4 Variable", "Source Serif 4", Georgia, serif`,iI=`"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, monospace`;function aI(e){return e===`serif`?rI:e===`mono`?iI:nI}function oI(e,t,n=nI,r=400){let i=tI();return i?(i.font=`${r} ${t}px ${n}`,i.measureText(e).width):e.length*t*.56}function sI(e,t,n,r=nI,i=400){let a=[];for(let o of e.split(` +`)){if(!o){a.push(``);continue}let e=``;for(let s of o.split(/(\s+)/)){let o=e+s;if(!e||oI(o,t,r,i)<=n)e=o;else for(a.push(e.trimEnd()),e=s.trimStart();e&&oI(e,t,r,i)>n;){let o=e.length-1;for(;o>1&&oI(e.slice(0,o),t,r,i)>n;)o--;a.push(e.slice(0,o)),e=e.slice(o)}}a.push(e)}return a}function cI(e,t){let n=t===0?18:15,r=t===0?600:400,i=sI(e||` `,n,260,nI,r),a=Math.max(...i.map(e=>oI(e,n,nI,r)),t===0?60:40);return{w:Math.ceil(a)+(t===0?32:24),h:i.length*Math.round(n*1.4)+(t===0?20:14)}}var lI=56,uI=14;function dI(e){let t=Object.entries(e).filter(([,t])=>!t.parent||!e[t.parent]);return t.sort((e,t)=>e[1].pos-t[1].pos||(e[0]n.parent===t&&e!==t).sort((e,t)=>e[1].pos-t[1].pos||(e[0]e)}function pI(e,t,n){let r=dI(e),i=new Map,a=[];if(!r)return{root:``,boxes:i,edges:a,bounds:{x:0,y:0,w:0,h:0}};let o=new Map,s=new Set,c=(t,r)=>{if(!(s.has(t)||r>50)){s.add(t),o.set(t,n(e[t].text,r));for(let n of fI(e,t))c(n,r+1)}};c(r,0);let l=t=>fI(e,t).filter(e=>o.has(e)),u=new Map,d=e=>{let t=u.get(e);if(t!==void 0)return t;let n=l(e),r=n.reduce((e,t)=>e+d(t),0)+uI*Math.max(0,n.length-1),i=Math.max(o.get(e).h,r);return u.set(e,i),i},f=(e,t,n,r,a,s)=>{let c=o.get(e),u=a===1?t:t-c.w;i.set(e,{id:e,x:u,y:n-c.h/2,w:c.w,h:c.h,depth:r,dir:a,parent:s}),p(e,l(e),a===1?u+c.w+lI:u-lI,n,r+1,a)},p=(e,t,n,r,i,a)=>{let o=r-(t.reduce((e,t)=>e+d(t),0)+uI*Math.max(0,t.length-1))/2;for(let r of t){let t=d(r);f(r,n,o+t/2,i,a,e),o+=t+uI}},m=o.get(r);i.set(r,{id:r,x:0,y:0,w:m.w,h:m.h,depth:0,dir:1,parent:``});let h=m.h/2,g=l(r);if(t===`right`)p(r,g,m.w+lI,h,1,1);else if(t===`left`)p(r,g,-56,h,1,-1);else{let e=Math.ceil(g.length/2);p(r,g.slice(0,e),m.w+lI,h,1,1),p(r,g.slice(e),-56,h,1,-1)}for(let e of i.values()){if(!e.parent)continue;let t=i.get(e.parent),n=e.dir===1?[t.x+t.w,t.y+t.h/2]:[t.x,t.y+t.h/2],r=e.dir===1?[e.x,e.y+e.h/2]:[e.x+e.w,e.y+e.h/2];a.push({from:n,to:r,child:e.id})}let _=1/0,v=1/0,y=-1/0,b=-1/0;for(let e of i.values())_=Math.min(_,e.x),v=Math.min(v,e.y),y=Math.max(y,e.x+e.w),b=Math.max(b,e.y+e.h);return{root:r,boxes:i,edges:a,bounds:{x:_,y:v,w:y-_,h:b-v}}}function mI(e,t,n,r){let i=e.boxes.get(n);if(!i)return null;if(r===`ArrowUp`||r===`ArrowDown`){let a=i.parent?fI(t,i.parent).filter(t=>e.boxes.get(t)?.dir===i.dir):[];return a[a.indexOf(n)+(r===`ArrowUp`?-1:1)]??null}let a=r===`ArrowRight`?1:-1;return i.parent?a===i.dir?fI(t,n)[0]??null:i.parent:fI(t,n).find(t=>e.boxes.get(t)?.dir===a)??null}function hI(e,t){let n=(e[0]+t[0])/2;return`M${e[0]} ${e[1]} C${n} ${e[1]} ${n} ${t[1]} ${t[0]} ${t[1]}`}function gI(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}function _I(e){return[-e[0],-e[1]]}function vI(e,t){return[e[0]+t[0],e[1]+t[1]]}function yI(e,t){return[e[0]-t[0],e[1]-t[1]]}function bI(e,t){return[e[0]*t,e[1]*t]}function xI(e,t){return[e[0]/t,e[1]/t]}function SI(e){return[e[1],-e[0]]}function CI(e,t){return e[0]*t[0]+e[1]*t[1]}function wI(e,t){return e[0]===t[0]&&e[1]===t[1]}function TI(e){return Math.hypot(e[0],e[1])}function EI(e){return e[0]*e[0]+e[1]*e[1]}function DI(e,t){return EI(yI(e,t))}function OI(e){return xI(e,TI(e))}function kI(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function AI(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function jI(e,t,n){return vI(e,bI(yI(t,e),n))}function MI(e,t,n){return vI(e,bI(t,n))}var{min:NI,PI}=Math,FI=.275,II=PI+1e-4;function LI(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=s.taper===!1?0:s.taper===!0?Math.max(n,m):s.taper,g=c.taper===!1?0:c.taper===!0?Math.max(n,m):c.taper,_=(n*r)**2,v=[],y=[],b=e.slice(0,10).reduce((e,t)=>{let r=t.pressure;if(a){let i=NI(1,t.distance/n);r=NI(1,e+(NI(1,1-i)-e)*(i*FI))}return(e+r)/2},e[0].pressure),x=gI(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,ee=e[0].point,te=ee,ne=ee,re=te,ie=!1;for(let t=0;t_)&&(v.push(ne),ee=ne),re=vI(s,ue),(t<=1||DI(te,re)>_)&&(y.push(re),te=re),b=r,C=c}let ae=e[0].point.slice(0,2),oe=e.length>1?e[e.length-1].point.slice(0,2):vI(e[0].point,[1,1]),se=[],ce=[];if(e.length===1){if(!(h||g)||l){let e=MI(ae,OI(SI(yI(ae,oe))),-(S||x)),t=[];for(let n=1/13,r=n;r<=1;r+=n)t.push(AI(e,ae,II*2*r));return t}}else{if(!(h||g&&e.length===1)){if(u)for(let e=1/13,t=e;t<=1;t+=e){let e=AI(y[0],ae,II*t);se.push(e)}else{let e=yI(v[0],y[0]),t=bI(e,.5),n=bI(e,.51);se.push(yI(ae,t),yI(ae,n),vI(ae,n),vI(ae,t))}}let t=SI(_I(e[e.length-1].vector));if(g||h&&e.length===1)ce.push(oe);else if(f){let e=MI(oe,t,x);for(let t=1/29,n=t;n<1;n+=t)ce.push(AI(e,oe,II*3*n))}else ce.push(vI(oe,bI(t,x)),vI(oe,bI(t,x*.99)),yI(oe,bI(t,x*.99)),yI(oe,bI(t,x)))}return v.concat(ce,y.reverse(),se)}function RI(e,t={}){let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let a=.15+(1-n)*.85,o=Array.isArray(e[0])?e:e.map(({x:e,y:t,pressure:n=.5})=>[e,t,n]);if(o.length===2){let e=o[1];o=o.slice(0,-1);for(let t=1;t<5;t++)o.push(jI(o[0],e,t/4))}o.length===1&&(o=[...o,[...vI(o[0],[1,1]),...o[0].slice(2)]]);let s=[{point:[o[0][0],o[0][1]],pressure:o[0][2]>=0?o[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],c=!1,l=0,u=s[0],d=o.length-1;for(let e=1;e=0?o[e][2]:.5,vector:OI(yI(u.point,t)),distance:n,runningLength:l},s.push(u)}return s[0].vector=s[1]?.vector||[0,0],s}function zI(e,t={}){return LI(RI(e,t),t)}function BI(e,t,n){if(e&&e.length){let[r,i]=t,a=Math.PI/180*n,o=Math.cos(a),s=Math.sin(a);for(let t of e){let[e,n]=t;t[0]=(e-r)*o-(n-i)*s+r,t[1]=(e-r)*s+(n-i)*o+i}}}function VI(e,t){return e[0]===t[0]&&e[1]===t[1]}function HI(e,t,n,r=1){let i=n,a=Math.max(t,.1),o=e[0]&&e[0][0]&&typeof e[0][0]==`number`?[e]:e,s=[0,0];if(i)for(let e of o)BI(e,s,i);let c=function(e,t,n){let r=[];for(let t of e){let e=[...t];VI(e[0],e[e.length-1])||e.push([e[0][0],e[0][1]]),e.length>2&&r.push(e)}let i=[];t=Math.max(t,.1);let a=[];for(let e of r)for(let t=0;te.ymint.ymin?1:e.xt.x?1:e.ymax===t.ymax?0:(e.ymax-t.ymax)/Math.abs(e.ymax-t.ymax))),!a.length)return i;let o=[],s=a[0].ymin,c=0;for(;o.length||a.length;){if(a.length){let e=-1;for(let t=0;ts);t++)e=t;a.splice(0,e+1).forEach((e=>{o.push({s,edge:e})}))}if(o=o.filter((e=>!(e.edge.ymax<=s))),o.sort(((e,t)=>e.edge.x===t.edge.x?0:(e.edge.x-t.edge.x)/Math.abs(e.edge.x-t.edge.x))),(n!==1||c%t==0)&&o.length>1)for(let e=0;e=o.length)break;let n=o[e].edge,r=o[t].edge;i.push([[Math.round(n.x),s],[Math.round(r.x),s]])}s+=n,o.forEach((e=>{e.edge.x=e.edge.x+n*e.edge.islope})),c++}return i}(o,a,r);if(i){for(let e of o)BI(e,s,-i);(function(e,t,n){let r=[];e.forEach((e=>r.push(...e))),BI(r,t,n)})(c,s,-i)}return c}function UI(e,t){let n=t.hachureAngle+90,r=t.hachureGap;r<0&&(r=4*t.strokeWidth),r=Math.max(r,.1);let i=1;return t.roughness>=1&&(t.randomizer?.next()||Math.random())>.7&&(i=r),HI(e,r,n,i||1)}var WI=class{constructor(e){this.helper=e}fillPolygons(e,t){return this._fillPolygons(e,t)}_fillPolygons(e,t){let n=UI(e,t);return{type:`fillSketch`,ops:this.renderLines(n,t)}}renderLines(e,t){let n=[];for(let r of e)n.push(...this.helper.doubleLineOps(r[0][0],r[0][1],r[1][0],r[1][1],t));return n}};function GI(e){let t=e[0],n=e[1];return Math.sqrt((t[0]-n[0])**2+(t[1]-n[1])**2)}var KI=class extends WI{fillPolygons(e,t){let n=t.hachureGap;n<0&&(n=4*t.strokeWidth),n=Math.max(n,.1);let r=UI(e,Object.assign({},t,{hachureGap:n})),i=Math.PI/180*t.hachureAngle,a=[],o=.5*n*Math.cos(i),s=.5*n*Math.sin(i);for(let[e,t]of r)GI([e,t])&&a.push([[e[0]-o,e[1]+s],[...t]],[[e[0]+o,e[1]-s],[...t]]);return{type:`fillSketch`,ops:this.renderLines(a,t)}}},qI=class extends WI{fillPolygons(e,t){let n=this._fillPolygons(e,t),r=Object.assign({},t,{hachureAngle:t.hachureAngle+90}),i=this._fillPolygons(e,r);return n.ops=n.ops.concat(i.ops),n}},JI=class{constructor(e){this.helper=e}fillPolygons(e,t){let n=UI(e,t=Object.assign({},t,{hachureAngle:0}));return this.dotsOnLines(n,t)}dotsOnLines(e,t){let n=[],r=t.hachureGap;r<0&&(r=4*t.strokeWidth),r=Math.max(r,.1);let i=t.fillWeight;i<0&&(i=t.strokeWidth/2);let a=r/4;for(let o of e){let e=GI(o),s=e/r,c=Math.ceil(s)-1,l=e-c*r,u=(o[0][0]+o[1][0])/2-r/4,d=Math.min(o[0][1],o[1][1]);for(let e=0;e{let a=GI(e),o=Math.floor(a/(n+r)),s=(a+r-o*(n+r))/2,c=e[0],l=e[1];c[0]>l[0]&&(c=e[1],l=e[0]);let u=Math.atan((l[1]-c[1])/(l[0]-c[0]));for(let e=0;e{let i=GI(e),a=Math.round(i/(2*t)),o=e[0],s=e[1];o[0]>s[0]&&(o=e[1],s=e[0]);let c=Math.atan((s[1]-o[1])/(s[0]-o[0]));for(let e=0;er%2?e+n:e+t));a.push({key:`C`,data:e}),t=e[4],n=e[5];break}case`Q`:a.push({key:`Q`,data:[...s]}),t=s[2],n=s[3];break;case`q`:{let e=s.map(((e,r)=>r%2?e+n:e+t));a.push({key:`Q`,data:e}),t=e[2],n=e[3];break}case`A`:a.push({key:`A`,data:[...s]}),t=s[5],n=s[6];break;case`a`:t+=s[5],n+=s[6],a.push({key:`A`,data:[s[0],s[1],s[2],s[3],s[4],t,n]});break;case`H`:a.push({key:`H`,data:[...s]}),t=s[0];break;case`h`:t+=s[0],a.push({key:`H`,data:[t]});break;case`V`:a.push({key:`V`,data:[...s]}),n=s[0];break;case`v`:n+=s[0],a.push({key:`V`,data:[n]});break;case`S`:a.push({key:`S`,data:[...s]}),t=s[2],n=s[3];break;case`s`:{let e=s.map(((e,r)=>r%2?e+n:e+t));a.push({key:`S`,data:e}),t=e[2],n=e[3];break}case`T`:a.push({key:`T`,data:[...s]}),t=s[0],n=s[1];break;case`t`:t+=s[0],n+=s[1],a.push({key:`T`,data:[t,n]});break;case`Z`:case`z`:a.push({key:`Z`,data:[]}),t=r,n=i}return a}function oL(e){let t=[],n=``,r=0,i=0,a=0,o=0,s=0,c=0;for(let{key:l,data:u}of e){switch(l){case`M`:t.push({key:`M`,data:[...u]}),[r,i]=u,[a,o]=u;break;case`C`:t.push({key:`C`,data:[...u]}),r=u[4],i=u[5],s=u[2],c=u[3];break;case`L`:t.push({key:`L`,data:[...u]}),[r,i]=u;break;case`H`:r=u[0],t.push({key:`L`,data:[r,i]});break;case`V`:i=u[0],t.push({key:`L`,data:[r,i]});break;case`S`:{let e=0,a=0;n===`C`||n===`S`?(e=r+(r-s),a=i+(i-c)):(e=r,a=i),t.push({key:`C`,data:[e,a,...u]}),s=u[0],c=u[1],r=u[2],i=u[3];break}case`T`:{let[e,a]=u,o=0,l=0;n===`Q`||n===`T`?(o=r+(r-s),l=i+(i-c)):(o=r,l=i);let d=r+2*(o-r)/3,f=i+2*(l-i)/3,p=e+2*(o-e)/3,m=a+2*(l-a)/3;t.push({key:`C`,data:[d,f,p,m,e,a]}),s=o,c=l,r=e,i=a;break}case`Q`:{let[e,n,a,o]=u,l=r+2*(e-r)/3,d=i+2*(n-i)/3,f=a+2*(e-a)/3,p=o+2*(n-o)/3;t.push({key:`C`,data:[l,d,f,p,a,o]}),s=e,c=n,r=a,i=o;break}case`A`:{let e=Math.abs(u[0]),n=Math.abs(u[1]),a=u[2],o=u[3],s=u[4],c=u[5],l=u[6];e===0||n===0?(t.push({key:`C`,data:[r,i,c,l,c,l]}),r=c,i=l):(r!==c||i!==l)&&(cL(r,i,c,l,e,n,a,o,s).forEach((function(e){t.push({key:`C`,data:e})})),r=c,i=l);break}case`Z`:t.push({key:`Z`,data:[]}),r=a,i=o}n=l}return t}function sL(e,t,n){return[e*Math.cos(n)-t*Math.sin(n),e*Math.sin(n)+t*Math.cos(n)]}function cL(e,t,n,r,i,a,o,s,c,l){let u=(d=o,Math.PI*d/180);var d;let f=[],p=0,m=0,h=0,g=0;if(l)[p,m,h,g]=l;else{[e,t]=sL(e,t,-u),[n,r]=sL(n,r,-u);let o=(e-n)/2,l=(t-r)/2,d=o*o/(i*i)+l*l/(a*a);d>1&&(d=Math.sqrt(d),i*=d,a*=d);let f=i*i,_=a*a,v=f*_-f*l*l-_*o*o,y=f*l*l+_*o*o,b=(s===c?-1:1)*Math.sqrt(Math.abs(v/y));h=b*i*l/a+(e+n)/2,g=b*-a*o/i+(t+r)/2,p=Math.asin(parseFloat(((t-g)/a).toFixed(9))),m=Math.asin(parseFloat(((r-g)/a).toFixed(9))),em&&(p-=2*Math.PI),!c&&m>p&&(m-=2*Math.PI)}let _=m-p;if(Math.abs(_)>120*Math.PI/180){let e=m,t=n,s=r;m=c&&m>p?p+120*Math.PI/180*1:p+120*Math.PI/180*-1,f=cL(n=h+i*Math.cos(m),r=g+a*Math.sin(m),t,s,i,a,o,0,c,[m,e,h,g])}_=m-p;let v=Math.cos(p),y=Math.sin(p),b=Math.cos(m),x=Math.sin(m),S=Math.tan(_/4),C=4/3*i*S,ee=4/3*a*S,te=[e,t],ne=[e+C*y,t-ee*v],re=[n+C*x,r-ee*b],ie=[n,r];if(ne[0]=2*te[0]-ne[0],ne[1]=2*te[1]-ne[1],l)return[ne,re,ie].concat(f);{f=[ne,re,ie].concat(f);let e=[];for(let t=0;t2){let i=[];for(let t=0;t2*Math.PI&&(p=0,m=2*Math.PI);let h=2*Math.PI/c.curveStepCount,g=Math.min(h/2,(m-p)/2),_=DL(g,l,u,d,f,p,m,1,c);if(!c.disableMultiStroke){let e=DL(g,l,u,d,f,p,m,1.5,c);_.push(...e)}return o&&(s?_.push(...SL(l,u,l+d*Math.cos(p),u+f*Math.sin(p),c),...SL(l,u,l+d*Math.cos(m),u+f*Math.sin(m),c)):_.push({op:`lineTo`,data:[l,u]},{op:`lineTo`,data:[l+d*Math.cos(p),u+f*Math.sin(p)]})),{type:`path`,ops:_}}function _L(e,t){let n=oL(aL(iL(e))),r=[],i=[0,0],a=[0,0];for(let{key:e,data:o}of n)switch(e){case`M`:a=[o[0],o[1]],i=[o[0],o[1]];break;case`L`:r.push(...SL(a[0],a[1],o[0],o[1],t)),a=[o[0],o[1]];break;case`C`:{let[e,n,i,s,c,l]=o;r.push(...OL(e,n,i,s,c,l,a,t)),a=[c,l];break}case`Z`:r.push(...SL(a[0],a[1],i[0],i[1],t)),a=[i[0],i[1]]}return{type:`path`,ops:r}}function vL(e,t){let n=[];for(let r of e)if(r.length){let e=t.maxRandomnessOffset||0,i=r.length;if(i>2){n.push({op:`move`,data:[r[0][0]+F(e,t),r[0][1]+F(e,t)]});for(let a=1;a500?.4:-.0016668*c+1.233334;let u=i.maxRandomnessOffset||0;u*u*100>s&&(u=c/10);let d=u/2,f=.2+.2*bL(i),p=i.bowing*i.maxRandomnessOffset*(r-t)/200,m=i.bowing*i.maxRandomnessOffset*(e-n)/200;p=F(p,i,l),m=F(m,i,l);let h=[],g=()=>F(d,i,l),_=()=>F(u,i,l),v=i.preserveVertices;return a&&(o?h.push({op:`move`,data:[e+(v?0:g()),t+(v?0:g())]}):h.push({op:`move`,data:[e+(v?0:F(u,i,l)),t+(v?0:F(u,i,l))]})),o?h.push({op:`bcurveTo`,data:[p+e+(n-e)*f+g(),m+t+(r-t)*f+g(),p+e+2*(n-e)*f+g(),m+t+2*(r-t)*f+g(),n+(v?0:g()),r+(v?0:g())]}):h.push({op:`bcurveTo`,data:[p+e+(n-e)*f+_(),m+t+(r-t)*f+_(),p+e+2*(n-e)*f+_(),m+t+2*(r-t)*f+_(),n+(v?0:_()),r+(v?0:_())]}),h}function wL(e,t,n){let r=[];r.push([e[0][0]+F(t,n),e[0][1]+F(t,n)]),r.push([e[0][0]+F(t,n),e[0][1]+F(t,n)]);for(let i=1;i3){let a=[],o=1-n.curveTightness;i.push({op:`move`,data:[e[1][0],e[1][1]]});for(let t=1;t+21&&i.push(n)):i.push(n),i.push(e[t+3])}else{let r=.5,a=e[t+0],o=e[t+1],s=e[t+2],c=e[t+3],l=ML(a,o,r),u=ML(o,s,r),d=ML(s,c,r),f=ML(l,u,r),p=ML(u,d,r),m=ML(f,p,r);NL([a,l,f,m],0,n,i),NL([m,p,d,c],0,n,i)}var a,o;return i}function PL(e,t){return FL(e,0,e.length,t)}function FL(e,t,n,r,i){let a=i||[],o=e[t],s=e[n-1],c=0,l=1;for(let r=t+1;rc&&(c=t,l=r)}return Math.sqrt(c)>r?(FL(e,t,l+1,r,a),FL(e,l,n,r,a)):(a.length||a.push(o),a.push(s)),a}function IL(e,t=.15,n){let r=[],i=(e.length-1)/3;for(let n=0;n0?FL(r,0,r.length,n):r}var LL=`none`,RL=class{constructor(e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:`#000`,strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:`hachure`,fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=e||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Math.floor(Math.random()*2**31)}_o(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_d(e,t,n){return{shape:e,sets:t||[],options:n||this.defaultOptions}}line(e,t,n,r,i){let a=this._o(i);return this._d(`line`,[uL(e,t,n,r,a)],a)}rectangle(e,t,n,r,i){let a=this._o(i),o=[],s=fL(e,t,n,r,a);if(a.fill){let i=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]];a.fillStyle===`solid`?o.push(vL([i],a)):o.push(yL([i],a))}return a.stroke!==LL&&o.push(s),this._d(`rectangle`,o,a)}ellipse(e,t,n,r,i){let a=this._o(i),o=[],s=mL(n,r,a),c=hL(e,t,a,s);if(a.fill){if(a.fillStyle===`solid`){let n=hL(e,t,a,s).opset;n.type=`fillPath`,o.push(n)}else o.push(yL([c.estimatedPoints],a))}return a.stroke!==LL&&o.push(c.opset),this._d(`ellipse`,o,a)}circle(e,t,n,r){let i=this.ellipse(e,t,n,n,r);return i.shape=`circle`,i}linearPath(e,t){let n=this._o(t);return this._d(`linearPath`,[dL(e,!1,n)],n)}arc(e,t,n,r,i,a,o=!1,s){let c=this._o(s),l=[],u=gL(e,t,n,r,i,a,o,!0,c);if(o&&c.fill){if(c.fillStyle===`solid`){let o=Object.assign({},c);o.disableMultiStroke=!0;let s=gL(e,t,n,r,i,a,!0,!1,o);s.type=`fillPath`,l.push(s)}else l.push(function(e,t,n,r,i,a,o){let s=e,c=t,l=Math.abs(n/2),u=Math.abs(r/2);l+=F(.01*l,o),u+=F(.01*u,o);let d=i,f=a;for(;d<0;)d+=2*Math.PI,f+=2*Math.PI;f-d>2*Math.PI&&(d=0,f=2*Math.PI);let p=(f-d)/o.curveStepCount,m=[];for(let e=d;e<=f;e+=p)m.push([s+l*Math.cos(e),c+u*Math.sin(e)]);return m.push([s+l*Math.cos(f),c+u*Math.sin(f)]),m.push([s,c]),yL([m],o)}(e,t,n,r,i,a,c))}return c.stroke!==LL&&l.push(u),this._d(`arc`,l,c)}curve(e,t){let n=this._o(t),r=[],i=pL(e,n);if(n.fill&&n.fill!==LL&&e.length>=3){if(n.fillStyle===`solid`){let t=pL(e,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));r.push({type:`fillPath`,ops:this._mergedShape(t.ops)})}else{let t=IL(function(e,t=0){let n=e.length;if(n<3)throw Error(`A curve must have at least three points.`);let r=[];if(n===3)r.push(kL(e[0]),kL(e[1]),kL(e[2]),kL(e[2]));else{let n=[];n.push(e[0],e[0]);for(let t=1;t{s.length>=4&&a.push(...IL(s,t)),s=[]},l=()=>{c(),a.length&&(i.push(a),a=[])};for(let{key:e,data:t}of r)switch(e){case`M`:l(),o=[t[0],t[1]],a.push(o);break;case`L`:c(),a.push([t[0],t[1]]);break;case`C`:if(!s.length){let e=a.length?a[a.length-1]:o;s.push([e[0],e[1]])}s.push([t[0],t[1]]),s.push([t[2],t[3]]),s.push([t[4],t[5]]);break;case`Z`:c(),a.push([o[0],o[1]])}if(l(),!n)return i;let u=[];for(let e of i){let t=PL(e,n);t.length&&u.push(t)}return u}(e,1,o?4-4*(n.simplification||1):(1+n.roughness)/2),c=_L(e,n);if(i){if(n.fillStyle===`solid`){if(s.length===1){let t=_L(e,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));r.push({type:`fillPath`,ops:this._mergedShape(t.ops)})}else r.push(vL(s,n))}else r.push(yL(s,n))}return a&&(o?s.forEach((e=>{r.push(dL(e,!1,n))})):r.push(c)),this._d(`path`,r,n)}opsToPath(e,t){let n=``;for(let r of e.ops){let e=typeof t==`number`&&t>=0?r.data.map((e=>+e.toFixed(t))):r.data;switch(r.op){case`move`:n+=`M${e[0]} ${e[1]} `;break;case`bcurveTo`:n+=`C${e[0]} ${e[1]}, ${e[2]} ${e[3]}, ${e[4]} ${e[5]} `;break;case`lineTo`:n+=`L${e[0]} ${e[1]} `}}return n.trim()}toPaths(e){let t=e.sets||[],n=e.options||this.defaultOptions,r=[];for(let e of t){let t=null;switch(e.type){case`path`:t={d:this.opsToPath(e),stroke:n.stroke,strokeWidth:n.strokeWidth,fill:LL};break;case`fillPath`:t={d:this.opsToPath(e),stroke:LL,strokeWidth:0,fill:n.fill||LL};break;case`fillSketch`:t=this.fillSketch(e,n)}t&&r.push(t)}return r}fillSketch(e,t){let n=t.fillWeight;return n<0&&(n=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||LL,strokeWidth:n,fill:LL}}_mergedShape(e){return e.filter(((e,t)=>t===0||e.op!==`move`))}},zL=class{constructor(e,t){this.canvas=e,this.ctx=this.canvas.getContext(`2d`),this.gen=new RL(t)}draw(e){let t=e.sets||[],n=e.options||this.getDefaultOptions(),r=this.ctx,i=e.options.fixedDecimalPlaceDigits;for(let a of t)switch(a.type){case`path`:r.save(),r.strokeStyle=n.stroke===`none`?`transparent`:n.stroke,r.lineWidth=n.strokeWidth,n.strokeLineDash&&r.setLineDash(n.strokeLineDash),n.strokeLineDashOffset&&(r.lineDashOffset=n.strokeLineDashOffset),this._drawToContext(r,a,i),r.restore();break;case`fillPath`:{r.save(),r.fillStyle=n.fill||``;let t=e.shape===`curve`||e.shape===`polygon`||e.shape===`path`?`evenodd`:`nonzero`;this._drawToContext(r,a,i,t),r.restore();break}case`fillSketch`:this.fillSketch(r,a,n)}}fillSketch(e,t,n){let r=n.fillWeight;r<0&&(r=n.strokeWidth/2),e.save(),n.fillLineDash&&e.setLineDash(n.fillLineDash),n.fillLineDashOffset&&(e.lineDashOffset=n.fillLineDashOffset),e.strokeStyle=n.fill||``,e.lineWidth=r,this._drawToContext(e,t,n.fixedDecimalPlaceDigits),e.restore()}_drawToContext(e,t,n,r=`nonzero`){e.beginPath();for(let r of t.ops){let t=typeof n==`number`&&n>=0?r.data.map((e=>+e.toFixed(n))):r.data;switch(r.op){case`move`:e.moveTo(t[0],t[1]);break;case`bcurveTo`:e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]);break;case`lineTo`:e.lineTo(t[0],t[1])}}t.type===`fillPath`?e.fill(r):e.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(e,t,n,r,i){let a=this.gen.line(e,t,n,r,i);return this.draw(a),a}rectangle(e,t,n,r,i){let a=this.gen.rectangle(e,t,n,r,i);return this.draw(a),a}ellipse(e,t,n,r,i){let a=this.gen.ellipse(e,t,n,r,i);return this.draw(a),a}circle(e,t,n,r){let i=this.gen.circle(e,t,n,r);return this.draw(i),i}linearPath(e,t){let n=this.gen.linearPath(e,t);return this.draw(n),n}polygon(e,t){let n=this.gen.polygon(e,t);return this.draw(n),n}arc(e,t,n,r,i,a,o=!1,s){let c=this.gen.arc(e,t,n,r,i,a,o,s);return this.draw(c),c}curve(e,t){let n=this.gen.curve(e,t);return this.draw(n),n}path(e,t){let n=this.gen.path(e,t);return this.draw(n),n}},BL=`http://www.w3.org/2000/svg`,VL=class{constructor(e,t){this.svg=e,this.gen=new RL(t)}draw(e){let t=e.sets||[],n=e.options||this.getDefaultOptions(),r=this.svg.ownerDocument||window.document,i=r.createElementNS(BL,`g`),a=e.options.fixedDecimalPlaceDigits;for(let o of t){let t=null;switch(o.type){case`path`:t=r.createElementNS(BL,`path`),t.setAttribute(`d`,this.opsToPath(o,a)),t.setAttribute(`stroke`,n.stroke),t.setAttribute(`stroke-width`,n.strokeWidth+``),t.setAttribute(`fill`,`none`),n.strokeLineDash&&t.setAttribute(`stroke-dasharray`,n.strokeLineDash.join(` `).trim()),n.strokeLineDashOffset&&t.setAttribute(`stroke-dashoffset`,`${n.strokeLineDashOffset}`);break;case`fillPath`:t=r.createElementNS(BL,`path`),t.setAttribute(`d`,this.opsToPath(o,a)),t.setAttribute(`stroke`,`none`),t.setAttribute(`stroke-width`,`0`),t.setAttribute(`fill`,n.fill||``),e.shape!==`curve`&&e.shape!==`polygon`||t.setAttribute(`fill-rule`,`evenodd`);break;case`fillSketch`:t=this.fillSketch(r,o,n)}t&&i.appendChild(t)}return i}fillSketch(e,t,n){let r=n.fillWeight;r<0&&(r=n.strokeWidth/2);let i=e.createElementNS(BL,`path`);return i.setAttribute(`d`,this.opsToPath(t,n.fixedDecimalPlaceDigits)),i.setAttribute(`stroke`,n.fill||``),i.setAttribute(`stroke-width`,r+``),i.setAttribute(`fill`,`none`),n.fillLineDash&&i.setAttribute(`stroke-dasharray`,n.fillLineDash.join(` `).trim()),n.fillLineDashOffset&&i.setAttribute(`stroke-dashoffset`,`${n.fillLineDashOffset}`),i}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(e,t){return this.gen.opsToPath(e,t)}line(e,t,n,r,i){let a=this.gen.line(e,t,n,r,i);return this.draw(a)}rectangle(e,t,n,r,i){let a=this.gen.rectangle(e,t,n,r,i);return this.draw(a)}ellipse(e,t,n,r,i){let a=this.gen.ellipse(e,t,n,r,i);return this.draw(a)}circle(e,t,n,r){let i=this.gen.circle(e,t,n,r);return this.draw(i)}linearPath(e,t){let n=this.gen.linearPath(e,t);return this.draw(n)}polygon(e,t){let n=this.gen.polygon(e,t);return this.draw(n)}arc(e,t,n,r,i,a,o=!1,s){let c=this.gen.arc(e,t,n,r,i,a,o,s);return this.draw(c)}curve(e,t){let n=this.gen.curve(e,t);return this.draw(n)}path(e,t){let n=this.gen.path(e,t);return this.draw(n)}},HL={canvas:(e,t)=>new zL(e,t),svg:(e,t)=>new VL(e,t),generator:e=>new RL(e),newSeed:()=>RL.newSeed()},UL=(e,t)=>e===`none`?`none`:e===`ink`?t===`fill`?`var(--dw-surface-sunken)`:`var(--dw-ink)`:e===`paper`?t===`fill`?`var(--dw-surface-raised)`:`var(--dw-surface)`:t===`fill`?`color-mix(in srgb, var(--dw-c-${e}) 22%, var(--dw-surface))`:`var(--dw-c-${e})`,WL=e=>e.replace(/&/g,`&`).replace(//g,`>`).replace(/"/g,`"`),GL=e=>Math.round(e*100)/100,KL=`#000001`,qL=`#000002`;function JL(e,t){return e===`dash`?`stroke-dasharray:${GL(t*4)} ${GL(t*3)};`:``}function YL(e){let t=2166136261;for(let n of e)t=Math.imul(t^n.charCodeAt(0),16777619);return(t>>>0)%2**31||1}function XL(e,t,n){switch(e){case`diamond`:return[[t/2,0],[t,n/2],[t/2,n],[0,n/2]];case`triangle`:return[[t/2,0],[t,n],[0,n]];case`rect`:return[[0,0],[t,0],[t,n],[0,n]];default:return null}}function ZL(e,t){let n=Math.min(16,e*.15,t*.15);return`M${GL(n)} 0 H${GL(e-n)} Q${GL(e)} 0 ${GL(e)} ${GL(n)} V${GL(t-n)} Q${GL(e)} ${GL(t)} ${GL(e-n)} ${GL(t)} H${GL(n)} Q0 ${GL(t)} 0 ${GL(t-n)} V${GL(n)} Q0 0 ${GL(n)} 0 Z`}function QL(e,t){let{w:n,h:r}=e,i=e.strokeStyle===`none`?`none`:t(e.stroke,`line`),a=t(e.fill,`fill`),o=e.strokeStyle===`none`?0:e.strokeWidth;if(e.rough){let t=HL.generator(),s={seed:YL(e.id),roughness:1.2,bowing:1,strokeWidth:Math.max(o,1),stroke:i===`none`?`none`:KL,fill:a===`none`?void 0:qL,fillStyle:`hachure`,hachureGap:8,fillWeight:1.4,disableMultiStroke:o===0},c=XL(e.shape,n,r),l=e.shape===`ellipse`?t.ellipse(n/2,r/2,n,r,s):e.shape===`roundrect`?t.path(ZL(n,r),s):t.polygon(c,s);return t.toPaths(l).map(t=>{if(t.fill===qL)return``;let n=t.stroke===qL,r=n?a.replace(`22%`,`60%`):i;return r===`none`||t.stroke===`none`?``:``}).join(``)}let s=`fill:${a};stroke:${i};stroke-width:${GL(o)};stroke-linejoin:round;${JL(e.strokeStyle,o)}`;return e.shape===`ellipse`?``:e.shape===`roundrect`?``:``}function $L(e,t,n,r,i){if(e===`none`)return``;let a=6+r*2.5,o=(e,r)=>{let i=Math.cos(n),a=Math.sin(n);return`${GL(t[0]+e*i-r*a)},${GL(t[1]+e*a+r*i)}`};switch(e){case`arrow`:return``;case`triangle`:return``;case`circle`:{let[e,t]=o(-a*.45,0).split(`,`).map(Number);return``}case`diamond`:return``}}function eR(e,t,n){let r=e.strokeStyle===`none`?n(`gray`,`line`):n(e.stroke,`line`),i=e.strokeWidth,a;if(e.rough){let n=HL.generator();a=n.toPaths(n.path(t.d,{seed:YL(e.id),roughness:1,strokeWidth:i,stroke:`#000`})).map(e=>``).join(``)}else a=``;let o=t.points[t.points.length-1];return a+$L(e.startArrow,t.points[0],t.startAngle,i,r)+$L(e.endArrow,o,t.endAngle,i,r)}function tR(e,t){let n=zI(e,{size:t,thinning:.55,smoothing:.5,streamline:.4,simulatePressure:e.every(e=>e[2]===.5),last:!0});if(!n.length)return``;let r=(e,t)=>(e+t)/2,i=`M${GL(n[0][0])} ${GL(n[0][1])} Q`;for(let e=0;e`}function rR(e){let t=[];for(let n of e.toArray())if(n instanceof mx)for(let e of n.toDelta()){if(typeof e.insert!=`string`)continue;let n={type:`text`,text:e.insert};e.attributes&&(n.marks=Object.entries(e.attributes).map(([e,t])=>({type:e,attrs:t&&typeof t==`object`?t:{}}))),t.push(n)}else if(n instanceof lx){let e={type:n.nodeName},r=n.getAttributes();Object.keys(r).length&&(e.attrs=r),n.length&&(e.content=rR(n)),t.push(e)}return t}function iR(e,t,n=0){if(n>100)return;let r=0;for(;r{let r=``,i=!1;for(let a of e)a.type===`text`?(r+=a.text??``,i=!0):a.type===`hardBreak`?(t.push(r),r=``):a.content?.length&&a.content.some(e=>e.type!==`text`&&e.type!==`hardBreak`)?(i&&t.push(r),r=``,i=!1,n(a.content)):(i&&t.push(r),t.push((a.content??[]).map(e=>e.text??``).join(``)),r=``,i=!1);i&&t.push(r)};return n(e),t}var oR=`docwell-canvas`,sR=e=>e.getMap(`surface`);function cR(e){let t={};for(let[n,r]of e.entries())r instanceof Bb?t[n]=r.toJSON():r instanceof gb||(t[n]=r);return LF(t)}function lR(e,t){return(e.type===`frame`?0:1)-(t.type===`frame`?0:1)||e.index-t.index||(e.idt.id))}function uR(){return LF({id:kF,type:`note`,page:!0,background:`paper`,x:0,y:0,w:760,h:400,index:0})}var dR=class{doc;map;undo;cache=null;byId=new Map;listeners=new Set;observer=e=>{this.cache=null;let t=new Set;for(let n of e){if(n.target===this.map){t=null;break}let e=n.target;for(;e&&e.parent!==this.map;)e=e.parent;let r=e&&e._item?.parentSub;r&&t.add(r)}for(let e of this.listeners)e(t)};constructor(e,t={}){this.doc=e,this.map=sR(e),this.map.observeDeep(this.observer),this.undo=t.undo===!1?null:new Wy(this.map,{trackedOrigins:new Set([oR]),captureTimeout:400})}destroy(){this.map.unobserveDeep(this.observer),this.undo?.destroy(),this.listeners.clear()}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}elements(){if(this.cache)return this.cache;let e=[];for(let[t,n]of this.map.entries()){let r=n instanceof Bb?cR(n):null;r&&e.push({...r,id:t})}return e.some(e=>e.type===`note`&&e.page)||e.push(uR()),e.sort(lR),this.cache=e,this.byId=new Map(e.map(e=>[e.id,e])),e}get(e){return this.elements(),this.byId.get(e)}get isEmpty(){return this.map.size===0}body(e){let t=this.map.get(e);if(!(t instanceof Bb))return null;let n=t.get(`body`);return n instanceof sx?n:null}nodes(e){let t=this.map.get(e)?.get(`nodes`);return t instanceof Bb?t:null}transact(e){this.doc.transact(e,oR)}nextIndex(){let e=0;for(let t of this.elements())t.type!==`frame`&&(e=Math.max(e,t.index));return e+1}ensure(e){let t=this.map.get(e);if(t instanceof Bb)return t;if(e!==`page`)return null;let n=this.get(e),r=new Bb;this.map.set(e,r);for(let[e,t]of Object.entries(n))e!==`id`&&r.set(e,t);return r}add(e,t){let n=e.id||HF();return this.transact(()=>{let r=new Bb;this.map.set(n,r);let{nodes:i,...a}=e;for(let[e,t]of Object.entries(a))e!==`id`&&t!==void 0&&r.set(e,t);if(`index`in a||r.set(`index`,e.type===`frame`?-this.nextIndex():this.nextIndex()),e.type===`note`&&!e.page){let e=new sx;r.set(`body`,e),iR(e,t?.length?t:[{type:`paragraph`}])}if(e.type===`mindmap`){let e=new Bb;r.set(`nodes`,e);let t=i&&Object.keys(i).length?i:{[HF()]:{text:``,parent:``,pos:0}};for(let[n,r]of Object.entries(t))e.set(n,fR(r))}}),n}update(e,t){this.updateMany([[e,t]])}updateMany(e){e.length&&this.transact(()=>{for(let[t,n]of e){let e=this.ensure(t);if(e)for(let[t,r]of Object.entries(n))t!==`id`&&t!==`type`&&t!==`body`&&t!==`nodes`&&(r===void 0?e.delete(t):pR(e.get(t),r)||e.set(t,r))}})}remove(e){let t=this.elements(),n=new Set;for(let r of e){n.add(r);for(let e of t)e.group===r&&n.add(e.id)}n.delete(kF);for(let e of t)e.type===`note`&&e.page&&n.delete(e.id);n.size&&this.transact(()=>{for(let e of t)if(!(e.type!==`connector`||n.has(e.id)))for(let t of[`source`,`target`]){let r=e[t];if(r.id&&n.has(r.id)){let n=this.endPoint(r);this.map.get(e.id)?.set(t,{x:n[0],y:n[1]})}}for(let e of n)this.map.delete(e);let e=this.elements();for(let t of e.filter(e=>e.type===`group`)){let n=e.filter(e=>e.group===t.id);if(n.length<2){for(let e of n)this.map.get(e.id)?.delete(`group`);this.map.delete(t.id)}}})}endPoint(e){let t=e.id?this.get(e.id):void 0;if(!t)return[e.x??0,e.y??0];let[n,r]=e.pos??[.5,.5];return[t.x+t.w*n,t.y+t.h*r]}reorder(e,t){let n=this.elements().filter(e=>e.type!==`frame`),r=new Set(e),i=n.filter(e=>r.has(e.id));if(!i.length)return;let a=n.filter(e=>!r.has(e.id)),o;if(t===`front`)o=[...a,...i];else if(t===`back`)o=[...i,...a];else{o=[...n];let e=t===`forward`?1:-1,a=e=>o.indexOf(e),s=e===1?[...i].reverse():i;for(let t of s){let n=a(t),i=n+e;i<0||i>=o.length||r.has(o[i].id)||([o[n],o[i]]=[o[i],o[n]])}}this.updateMany(o.map((e,t)=>[e.id,{index:t+1}]).filter(([e,t])=>this.get(e)?.index!==t.index))}groupOf(e){let t=e.filter(e=>{let t=this.get(e);return t&&t.type!==`group`&&!(t.type===`note`&&t.page)});if(t.length<2)return null;let n=HF();return this.transact(()=>{let e=new Bb;this.map.set(n,e),e.set(`type`,`group`),e.set(`index`,this.nextIndex());for(let e of t)this.ensure(e)?.set(`group`,n)}),n}ungroup(e){let t=this.elements().filter(t=>t.group===e).map(e=>e.id);return this.transact(()=>{for(let e of t)this.map.get(e)?.delete(`group`);this.map.delete(e)}),t}addNode(e,t,n,r=``){let i=HF();return this.transact(()=>this.nodes(e)?.set(i,fR({text:r,parent:t,pos:n}))),i}updateNode(e,t,n){this.transact(()=>{let r=this.nodes(e)?.get(t);if(r)for(let[e,t]of Object.entries(n))r.get(e)!==t&&r.set(e,t)})}removeNode(e,t){let n=this.get(e);if(n?.type!==`mindmap`)return;if(t===Object.entries(n.nodes).find(([,e])=>!e.parent)?.[0]){this.remove([e]);return}let r=new Set([t]),i=!0;for(;i;){i=!1;for(let[e,t]of Object.entries(n.nodes))!r.has(e)&&r.has(t.parent)&&(r.add(e),i=!0)}this.transact(()=>{let t=this.nodes(e);for(let e of r)t?.delete(e)})}toJSON(e){let t=this.elements(),n;if(e){n=new Set(e);for(let e of t)n.has(e.group)&&n.add(e.id)}else n=new Set(t.map(e=>e.id));return t.filter(e=>n.has(e.id)).map(e=>{let t={...e,id:e.id,type:e.type},n=e.type===`note`&&!e.page?this.body(e.id):null;return n&&(t.body=rR(n)),t})}insertJSON(e,t=0,n=0){let r=e.filter(e=>e&&typeof e==`object`&&!(e.type===`note`&&e.page)),i=new Map(r.map(e=>[String(e.id),HF()])),a=[],o=this.nextIndex();return this.transact(()=>{for(let e of r){let r=LF(e);if(!r)continue;let s=i.get(String(e.id)),c={...r};if(delete c.id,c.x=r.x+t,c.y=r.y+n,c.index=r.type===`frame`?-o++:o++,c.group=r.group&&i.has(r.group)?i.get(r.group):void 0,r.type===`connector`)for(let e of[`source`,`target`]){let a=r[e];if(a.id&&i.has(a.id))c[e]={id:i.get(a.id),...a.pos?{pos:a.pos}:{}};else if(a.id){let r=this.endPoint(a);c[e]={x:r[0]+t,y:r[1]+n}}else c[e]={x:(a.x??0)+t,y:(a.y??0)+n}}for(let e of Object.keys(c))(c[e]===void 0||c[e]===``)&&delete c[e];this.add({...c,id:s,type:r.type},Array.isArray(e.body)?e.body:void 0),a.push(s)}}),a}load(e){this.transact(()=>{for(let e of[...this.map.keys()])this.map.delete(e);for(let t of e){let e=LF(t);if(!e||!t.id)continue;let n={...e},r=String(t.id);delete n.id;for(let e of Object.keys(n))n[e]===``&&delete n[e];this.add({...n,id:r,type:e.type},Array.isArray(t.body)?t.body:void 0)}})}};function fR(e){let t=new Bb;return t.set(`text`,e.text),t.set(`parent`,e.parent),t.set(`pos`,e.pos),t}function pR(e,t){return e===t?!0:typeof e!=`object`||typeof t!=`object`||!e||!t?!1:JSON.stringify(e)===JSON.stringify(t)}var mR=(e,t=18)=>``,hR={rect:``,roundrect:``,ellipse:``,diamond:``,triangle:``,straight:``,curve:``,elbow:``,none:``,arrow:``,triangleEnd:``,circle:``,diamondEnd:``,solid:``,dash:``,noLine:``,right:``,left:``,radial:``},gR=e=>``;function _R(e){return e===`none`?`background:transparent`:e===`ink`?`background:var(--dw-ink)`:e===`paper`?`background:var(--dw-surface)`:`background:var(--dw-c-${e})`}var vR=class{v;bar;zoomBox;props;zoomLabel;pop=null;popFor=``;fileInput;lastProps=``;closePop=e=>{this.pop&&!this.pop.contains(e.target)&&!e.target.closest?.(`[data-pop]`)&&this.hidePop()};constructor(e){this.v=e;let t=e.root;this.bar=this.div(`dw-cv-ui dw-cv-toolbar`),this.bar.setAttribute(`role`,`toolbar`),this.bar.setAttribute(`aria-label`,e.labels.toolbar),this.zoomBox=this.div(`dw-cv-ui dw-cv-zoom`),this.props=this.div(`dw-cv-ui dw-cv-props`),this.props.setAttribute(`role`,`toolbar`),this.zoomLabel=document.createElement(`button`),this.fileInput=document.createElement(`input`),this.fileInput.type=`file`,this.fileInput.accept=`image/*`,this.fileInput.multiple=!0,this.fileInput.hidden=!0,this.fileInput.addEventListener(`change`,()=>{let t=[...this.fileInput.files??[]];this.fileInput.value=``,t.length&&e.addImages(t)}),t.append(this.bar,this.zoomBox,this.props,this.fileInput),document.addEventListener(`pointerdown`,this.closePop,!0),this.buildZoom(),this.refresh()}destroy(){document.removeEventListener(`pointerdown`,this.closePop,!0)}div(e){let t=document.createElement(`div`);return t.className=e,t}button(e,t,n,r={}){let i=document.createElement(`button`);return i.type=`button`,i.className=`dw-cv-btn${r.cls?` ${r.cls}`:``}`,i.innerHTML=e,i.title=t,i.setAttribute(`aria-label`,t),r.active!==void 0&&i.setAttribute(`aria-pressed`,String(r.active)),r.pop&&(i.dataset.pop=r.pop),i.addEventListener(`pointerdown`,e=>e.stopPropagation()),i.addEventListener(`click`,e=>{e.stopPropagation(),n()}),i}buildBar(){let e=this.v,t=e.labels;if(this.bar.replaceChildren(),this.bar.hidden=e.isPresenting,!e.editable){this.bar.append(this.button(mR(`cursor`),t.select,()=>e.setTool(`select`),{active:e.tool===`select`}),this.button(mR(`hand`),t.hand,()=>e.setTool(`hand`),{active:e.tool===`hand`}),this.sep(),this.button(mR(`present`),t.present,()=>e.present()));return}let n=(t,n,r)=>this.button(mR(n),r,()=>e.setTool(t),{active:e.tool===t}),r=this.button(gR(e.shapeKind),t.shape,()=>{e.setTool(`shape`),this.togglePop(`shape`,r,()=>this.shapePop())},{active:e.tool===`shape`,pop:`shape`}),i=this.button(mR(`pen`),t.pen,()=>{e.setTool(`pen`),this.togglePop(`pen`,i,()=>this.penPop())},{active:e.tool===`pen`,pop:`pen`}),a=this.button(mR(`connector`),t.connector,()=>{e.setTool(`connector`),this.togglePop(`connector`,a,()=>this.connectorPop())},{active:e.tool===`connector`,pop:`connector`}),o=this.button(mR(`sticker`),t.library,()=>this.togglePop(`library`,o,()=>this.libraryPop()),{pop:`library`});this.bar.append(n(`select`,`cursor`,t.select),n(`hand`,`hand`,t.hand),this.sep(),n(`note`,`note`,t.note),n(`text`,`type`,t.text),r,a,i,n(`eraser`,`eraser`,t.eraser),n(`frame`,`frame`,t.frame),n(`mindmap`,`mindmap`,t.mindmap),this.button(mR(`image`),t.image,()=>this.pickImage()),this.button(mR(`link`),t.link,()=>void e.addLink()),o,this.sep(),this.button(mR(`present`),t.present,()=>e.present()))}sep(){return this.div(`dw-cv-sep`)}pickImage(){this.v.editable&&this.v.opts.files?.upload&&this.fileInput.click()}togglePop(e,t,n){if(this.pop&&this.popFor===e)return this.hidePop();this.hidePop();let r=n();r.classList.add(`dw-cv-ui`,`dw-cv-pop`),r.addEventListener(`pointerdown`,e=>e.stopPropagation()),this.v.root.append(r),this.pop=r,this.popFor=e;let i=this.v.root.getBoundingClientRect(),a=t.getBoundingClientRect(),o=r.offsetWidth,s=r.offsetHeight,c=a.left-i.left+a.width/2-o/2;c=Math.max(8,Math.min(i.width-o-8,c));let l=a.top-i.top-s-8;l<8&&(l=a.bottom-i.top+8),r.style.left=`${c}px`,r.style.top=`${l}px`}hidePop(){this.pop?.remove(),this.pop=null,this.popFor=``}row(...e){let t=this.div(`dw-cv-row`);return t.append(...e),t}colorRow(e,t,n,r){let i=this.div(`dw-cv-row dw-cv-colors`);i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,r);let a=this.v.labels,o=[`ink`,...SF,...n?[`paper`,`none`]:[]];for(let n of o){let r=n===`ink`?a.colorInk:n===`paper`?a.colorPaper:n===`none`?a.colorNone:a.colors[n]??n,o=this.button(``,r,()=>{t(n),this.lastProps=``,this.refresh()},{active:n===e});i.append(o)}return i}shapePop(){let e=this.v,t=e.labels,n=this.div(``);return n.append(this.row(...TF.map(n=>this.button(gR(n),t[n],()=>{e.setShapeKind(n),this.hidePop()},{active:e.shapeKind===n}))),this.row(this.button(`${t.general}`,t.general,()=>{e.setStyle(`shape`,{rough:!1}),this.hidePop()},{active:!e.styles.shape.rough}),this.button(`${t.scribbled}`,t.scribbled,()=>{e.setStyle(`shape`,{rough:!0}),this.hidePop()},{active:e.styles.shape.rough}))),n}penPop(){let e=this.v,t=this.div(``);return t.append(this.colorRow(e.styles.brush.color,t=>e.setStyle(`brush`,{color:t}),!1,e.labels.stroke),this.row(...[2,4,8,14].map(t=>this.button(``,`${e.labels.thickness} ${t}`,()=>{e.setStyle(`brush`,{size:t}),this.hidePop()},{active:e.styles.brush.size===t})))),t}connectorPop(){let e=this.v,t=this.div(``);return t.append(this.row(...EF.map(t=>this.button(gR(t),e.labels[t],()=>{e.setStyle(`connector`,{mode:t}),this.hidePop()},{active:e.styles.connector.mode===t})))),t}libraryPop(){let e=this.v,t=e.labels,n=this.div(`dw-cv-library`),r=this.div(`dw-cv-poptitle`);r.textContent=t.stickers;let i=this.div(`dw-cv-stickers`);for(let t of GF)i.append(this.button(`${t}`,t,()=>{e.insertSticker(t),this.hidePop()}));let a=this.div(`dw-cv-poptitle`);a.textContent=t.templates;let o=this.div(`dw-cv-templates`),s={kanban:t.templateKanban,swot:t.templateSwot,flow:t.templateFlow,brainstorm:t.templateBrainstorm,retro:t.templateRetro};for(let t of qF){let n=this.button(`${s[t]}`,s[t],()=>{e.insertTemplate(t),this.hidePop()},{cls:`dw-cv-wide`});o.append(n)}return n.append(r,i,a,o),n}buildZoom(){let e=this.v,t=e.labels;this.zoomLabel.type=`button`,this.zoomLabel.className=`dw-cv-btn dw-cv-zoomlabel`,this.zoomLabel.title=t.zoomReset,this.zoomLabel.addEventListener(`pointerdown`,e=>e.stopPropagation()),this.zoomLabel.addEventListener(`click`,()=>e.zoomAt(1)),this.zoomBox.append(this.button(mR(`zoom-out`),t.zoomOut,()=>e.zoomBy(.8)),this.zoomLabel,this.button(mR(`zoom-in`),t.zoomIn,()=>e.zoomBy(1.25)),this.button(mR(`fit`),t.zoomFit,()=>e.fit()))}zoomChanged(){this.zoomLabel.textContent=`${Math.round(this.v.zoom*100)}%`}refresh(){this.buildBar();let e=(this.v.editable||this.v.opts.onComment)&&!this.v.editing&&!this.v.isPresenting?this.v.selection():[],t=JSON.stringify([e,this.v.activeNode,this.v.styles.shape.rough]);t!==this.lastProps&&(this.lastProps=t,this.buildProps(e)),this.place()}place(){let e=this.props;if(e.hidden)return;let t=this.v.selectionScreenBox();if(!t){e.hidden=!0;return}let n=this.v.root.getBoundingClientRect(),r=e.offsetWidth,i=e.offsetHeight,a=t.x+t.w/2-r/2;a=Math.max(8,Math.min(n.width-r-8,a));let o=t.y-i-40;o<8&&(o=Math.min(n.height-i-64,t.y+t.h+16)),e.style.left=`${a}px`,e.style.top=`${Math.max(8,o)}px`}buildProps(e){let t=this.props;if(t.replaceChildren(),!e.length){t.hidden=!0;return}t.hidden=!1;let n=this.v,r=n.labels,i=n.opts.onComment,a=()=>this.button(mR(`comment`),r.comment,()=>{let t=e[0].id;i?.({id:t,text:n.elementText(t).slice(0,500)})});if(!n.editable){i&&e.length===1?t.append(a()):t.hidden=!0;return}let o=new Set(e.map(e=>e.type)).size===1?e[0]:null,s=[],c=(e,t,n,r)=>{let i=this.button(t,n,()=>this.togglePop(e,i,r),{pop:e});s.push(i)},l=(e,t,r,i,a)=>c(e,``,t,()=>{let e=this.div(``);return e.append(this.colorRow(r,e=>n.restyle({[i]:e}),a,t)),e}),u=(e,t,r,i,a,o,s,l=e=>e)=>c(e,a(r),t,()=>{let e=this.div(``);return e.append(this.row(...i.map(e=>this.button(a(e),s(e),()=>{n.restyle({[o]:l(e)}),this.hidePop(),this.lastProps=``,this.refresh()},{active:e===r})))),e}),d=(e,t,n,r)=>s.push(this.button(e,t,r,{active:n}));if(o?.type===`shape`)u(`kind`,r.shape,o.shape,TF,gR,`shape`,e=>r[e]),l(`fill`,r.fill,o.fill,`fill`,!0),l(`stroke`,r.stroke,o.stroke,`stroke`,!0),u(`style`,r.lineStyle,o.strokeStyle,[`solid`,`dash`,`none`],e=>gR(e===`none`?`noLine`:e),`strokeStyle`,e=>e===`none`?r.noLine:r[e]),u(`width`,r.thickness,String(o.strokeWidth),[`1`,`2`,`4`,`6`],e=>``,`strokeWidth`,e=>`${r.thickness} ${e}`,Number),d(`${r.scribbled}`,r.scribbled,o.rough,()=>{n.restyle({rough:!o.rough}),this.lastProps=``,this.refresh()}),l(`textColor`,r.textColor,o.textColor,`textColor`,!1);else if(o?.type===`connector`){u(`mode`,r.connector,o.mode,EF,gR,`mode`,e=>r[e]),l(`stroke`,r.stroke,o.stroke,`stroke`,!1),u(`style`,r.lineStyle,o.strokeStyle===`none`?`solid`:o.strokeStyle,[`solid`,`dash`],gR,`strokeStyle`,e=>r[e]);let e=e=>gR(e===`triangle`?`triangleEnd`:e===`diamond`?`diamondEnd`:e);u(`start`,r.startArrow,o.startArrow,DF,t=>`${e(t)}`,`startArrow`,e=>e),u(`end`,r.endArrow,o.endArrow,DF,e,`endArrow`,e=>e)}else o?.type===`brush`?l(`color`,r.stroke,o.color,`color`,!1):o?.type===`text`?(l(`color`,r.textColor,o.color,`color`,!1),u(`size`,r.fontSize,String(o.fontSize),[`16`,`24`,`32`,`48`,`64`],e=>`${e}`,`fontSize`,e=>`${r.fontSize} ${e}`,Number),u(`font`,r.font,o.font||`sans`,[`sans`,`serif`,`mono`],e=>`Aa`,`font`,e=>r[e],e=>e===`sans`?``:e),u(`align`,r.alignLeft,o.align,[`left`,`center`,`right`],e=>mR(`align-${e}`),`align`,e=>r[e===`left`?`alignLeft`:e===`center`?`alignCenter`:`alignRight`]),d(mR(`bold`),r.bold,o.bold,()=>{n.restyle({bold:!o.bold}),this.lastProps=``,this.refresh()})):o?.type===`note`||o?.type===`frame`?l(`bg`,r.background,o.background,`background`,!0):o?.type===`mindmap`?(u(`layout`,r.layout,o.layout,OF,e=>gR(e),`layout`,e=>r[e===`right`?`layoutRight`:e===`left`?`layoutLeft`:`layoutRadial`]),l(`color`,r.stroke,o.color,`color`,!1),n.activeNode?.map===o.id&&s.push(this.button(`+ ${r.addChild}`,r.addChild,()=>n.mindmapAdd(`child`),{cls:`dw-cv-wide`}))):o?.type===`embed`&&e.length===1&&s.push(this.button(mR(`open`),r.openLink,()=>window.open(o.url,`_blank`,`noopener,noreferrer`)));t.append(...s),i&&e.length===1&&t.append(a()),s.length&&t.append(this.sep());let f=e.filter(e=>e.type===`group`);e.length>1&&!f.length&&t.append(this.button(mR(`group`),r.group,()=>n.group())),f.length&&t.append(this.button(mR(`layers`),r.ungroup,()=>n.ungroup()));let p=e.every(e=>e.type===`note`&&e.page);t.append(this.button(mR(`arrow-up`),r.bringFront,()=>n.reorder(`front`)),this.button(mR(`send-back`),r.sendBack,()=>n.reorder(`back`))),p||t.append(this.button(mR(`copy`),r.duplicate,()=>n.duplicate()),this.button(mR(`trash`),r.delete,()=>n.deleteSelection(),{cls:`dw-cv-danger`}))}toast(e){let t=this.div(`dw-cv-ui dw-cv-toast`);t.setAttribute(`role`,`status`),t.textContent=e,this.v.root.append(t),setTimeout(()=>t.remove(),2600)}presentBar(){let e=this.v,t=e.labels,n=this.div(`dw-cv-ui dw-cv-presentbar`),r=this.div(`dw-cv-step`);return r.setAttribute(`aria-live`,`polite`),n.append(this.button(mR(`chevron-left`),t.presentPrevious,()=>e.presentStep(-1)),r,this.button(mR(`chevron-right`),t.presentNext,()=>e.presentStep(1)),this.button(mR(`close`),t.presentExit,()=>e.stopPresenting())),e.root.append(n),this.hidePop(),this.refresh(),n}presentStep(e,t){let n=this.v.root.querySelector(`.dw-cv-step`);n&&(n.textContent=this.v.labels.presentStep.replace(`{n}`,String(e+1)).replace(`{total}`,String(t)))}};function yR(e){let t=getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n,r=n(`--dw-surface`,`#ffffff`),i=e=>{let t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e);if(!t)return null;let n=t[1].length===3?[...t[1]].map(e=>e+e).join(``):t[1];return[0,2,4].map(e=>parseInt(n.slice(e,e+2),16))},a=(e,t,n)=>{let r=i(e),a=i(t);return!r||!a?e:`#${r.map((e,t)=>Math.round(e*n+a[t]*(1-n)).toString(16).padStart(2,`0`)).join(``)}`};return(e,t)=>{if(e===`none`)return`none`;if(e===`ink`)return t===`fill`?n(`--dw-surface-sunken`,`#f3f3f1`):n(`--dw-ink`,`#1d1f1e`);if(e===`paper`)return t===`fill`?n(`--dw-surface-raised`,`#ffffff`):r;let i=n(`--dw-c-${e}`,`#888888`);return t===`fill`?a(i,r,.22):i}}function bR(e){let t=[],n=e=>(e.content??[]).map(e=>e.type===`text`?e.text??``:e.type===`hardBreak`?` +`:n(e)).join(``),r=(e,i)=>{for(let a of e)if(a.type===`heading`){let e=Number(a.attrs?.level)||1;t.push({text:n(a),size:[0,26,21,18,16,16,16][e]??16,weight:650})}else if(a.type===`paragraph`)t.push({text:i+n(a),size:15,weight:400});else if(a.type===`listItem`||a.type===`taskItem`){let e=a.type===`taskItem`?a.attrs?.checked?`☑ `:`☐ `:`• `,[i,...o]=a.content??[];i&&t.push({text:e+n(i),size:15,weight:400}),r(o,` `)}else a.type===`codeBlock`?t.push({text:n(a),size:13,weight:400}):a.content?.length&&r(a.content,i)};return r(e,``),t}function xR(e,t,n,r,i,a,o=400,s=`start`){let c=Math.round(r*1.35);return n.map((n,l)=>`${WL(n)}`).join(``)}async function SR(e){if(e.startsWith(`data:`))return e;try{let t=await fetch(e,{credentials:`include`});if(!t.ok)return null;let n=await t.blob();return await new Promise(e=>{let t=new FileReader;t.onload=()=>e(typeof t.result==`string`?t.result:null),t.onerror=()=>e(null),t.readAsDataURL(n)})}catch{return null}}async function CR(e){let t=yR(e.root),n=e.elements.filter(e=>e.type!==`group`),r=QP(ZP(n.map(t=>e.boxOf(t)))??{x:0,y:0,w:400,h:300},32),i=t(`ink`,`line`),a=[];for(let r of n){let n=e.boxOf(r),o=r.rotate?` rotate(${r.rotate} ${n.w/2} ${n.h/2})`:``,s=e=>`${e}`;switch(r.type){case`shape`:{let e=sI(r.text,r.fontSize,Math.max(20,n.w-16)),i=Math.round(r.fontSize*1.35),o=n.h/2-e.length*i/2-r.fontSize*.25;a.push(s(QL(r,t)+(r.text?xR(n.w/2,o,e,r.fontSize,t(r.textColor,`line`),nI,400,`middle`):``)));break}case`text`:{let e=aI(r.font),i=r.w?sI(r.text,r.fontSize,r.w,e):r.text.split(` +`),o=r.align===`center`?n.w/2:r.align===`right`?n.w:0,c=r.align===`center`?`middle`:r.align===`right`?`end`:`start`;a.push(s(xR(o,0,i,r.fontSize,t(r.color,`line`),e,r.bold?650:400,c)));break}case`connector`:{let n=e.routeOf(r);if(a.push(eR(r,n,t)),r.label){let e=Math.min(240,r.label.length*8+16);a.push(``+xR(n.mid[0],n.mid[1]-12+3,[r.label],13,i,nI,400,`middle`))}break}case`brush`:a.push(s(nR(r,t)));break;case`frame`:a.push(s(``+xR(4,-24,[r.title],13,t(`gray`,`line`),nI,600)));break;case`note`:{let o=e.noteBody(r),c=o?bR(rR(o)):[],l=18,u=``;if(r.page&&e.pageTitle){let t=sI(e.pageTitle,26,n.w-48,nI,650);u+=xR(24,l-4,t,26,i,nI,650),l+=t.length*35+8}for(let e of c){let t=sI(e.text,e.size,n.w-48,nI,e.weight);if(u+=xR(24,l,t,e.size,i,nI,e.weight),l+=t.length*Math.round(e.size*1.35)+8,l>n.h-12)break}a.push(s(u));break}case`image`:{let i=await SR(e.resolve(r.src));a.push(s(i?``:``));break}case`embed`:a.push(s(``+xR(16,16,sI(r.url,13,n.w-32),13,t(`blue`,`line`),nI)));break;case`mindmap`:{let n=e.layoutOf(r),o=t(r.color,`line`),s=t(r.color,`fill`),c=n.edges.map(e=>``).join(``);for(let e of n.boxes.values()){let n=e.depth===0?18:15,a=e.depth===0?600:400,l=e.depth===0?o:e.depth===1?s:t(`paper`,`line`),u=e.depth===0?t(`paper`,`line`):i;c+=``;let d=sI(r.nodes[e.id]?.text||` `,n,260,nI,a);c+=xR(e.x+e.w/2,e.y+(e.h-d.length*Math.round(n*1.4))/2-2,d,n,u,nI,a,`middle`)}a.push(`${c}`);break}}}return{svg:`${a.join(``)}`,box:r}}async function wR(e,t){let{svg:n,box:r}=await CR(t),i=new Blob([n],{type:`image/svg+xml`});if(e===`svg`)return i;let a=Math.min(2,8192/Math.max(r.w,r.h,1)),o=URL.createObjectURL(i);try{let e=await new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=()=>t(Error(`could not draw the canvas`)),n.src=o}),t=document.createElement(`canvas`);t.width=Math.ceil(r.w*a),t.height=Math.ceil(r.h*a);let n=t.getContext(`2d`);if(!n)throw Error(`could not draw the canvas`);return n.drawImage(e,0,0,t.width,t.height),await new Promise((e,n)=>t.toBlob(t=>t?e(t):n(Error(`could not draw the canvas`)),`image/png`))}finally{URL.revokeObjectURL(o)}}var TR=.1,ER=4,DR=`http://www.w3.org/2000/svg`,OR=e=>e instanceof HTMLElement&&(e.isContentEditable||e.tagName===`INPUT`||e.tagName===`TEXTAREA`),kR=class{opts;store;labels;root;styles;editable;tool=`select`;shapeKind;selected=new Set;activeNode=null;editing=null;entered=null;world;overlay;ui;view={x:0,y:0,zoom:1};rendered=new Map;measured=new Map;layouts=new Map;routes=new Map;previews=new Map;drag=null;guides=[];marquee=null;hover=null;raf=0;spaceDown=!1;pointers=new Map;pinch=null;presenting=null;comments=[];activeComment=``;resize=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>this.onResize(e));unsub;cleanups=[];saveTimer;constructor(e,t){this.opts=t,this.labels=t.labels??xF,this.editable=t.editable,this.styles=WF(t.styles),this.shapeKind=this.styles.shape.shape,this.store=new dR(t.doc,{undo:t.undo!==!1}),this.root=document.createElement(`div`),this.root.className=`dw-cv`,this.root.tabIndex=0,this.root.setAttribute(`role`,`application`),this.root.dataset.testid=`edgeless-canvas`,this.world=document.createElement(`div`),this.world.className=`dw-cv-world`,this.overlay=document.createElementNS(DR,`svg`),this.overlay.classList.add(`dw-cv-overlay`),this.root.append(this.world,this.overlay),e.append(this.root),this.ui=new vR(this),this.root.classList.toggle(`dw-cv-readonly`,!this.editable),this.unsub=this.store.onChange(()=>this.schedule()),this.listen(),this.render(),this.restoreView()||this.fit(void 0,!1),this.applyView()}destroy(){cancelAnimationFrame(this.raf),clearTimeout(this.saveTimer),this.saveView(),this.unsub(),this.resize?.disconnect();for(let e of this.cleanups)e();for(let e of this.rendered.values())e.note?.destroy();this.rendered.clear(),this.ui.destroy(),this.store.destroy(),this.root.remove()}setEditable(e){if(e!==this.editable){this.editable=e,this.root.classList.toggle(`dw-cv-readonly`,!e),e||(this.stopEditing(),this.tool=`select`);for(let t of this.rendered.values())t.note?.setEditable(e);this.ui.refresh()}}get(e){return this.store.get(e)}elements(){return this.store.elements()}boxOf(e){switch(e.type){case`note`:{let t=this.measured.get(e.id);return{x:e.x,y:e.y,w:e.w,h:t?.h??e.h}}case`text`:{let t=this.measured.get(e.id);return{x:e.x,y:e.y,w:t?.w??e.w,h:t?.h??e.h}}case`group`:return ZP(this.elements().filter(t=>t.group===e.id).map(e=>this.outerBox(e)))??{x:e.x,y:e.y,w:0,h:0};case`mindmap`:{let t=this.layoutOf(e);return{x:e.x+t.bounds.x,y:e.y+t.bounds.y,w:t.bounds.w,h:t.bounds.h}}case`connector`:{let t=this.routeOf(e),n=t.points.map(e=>e[0]),r=t.points.map(e=>e[1]);return tF([Math.min(...n),Math.min(...r)],[Math.max(...n),Math.max(...r)])}default:return{x:e.x,y:e.y,w:e.w,h:e.h}}}outerBox(e){let t=this.boxOf(e);return e.rotate?rF(t,e.rotate):t}layoutOf(e){let t=this.layouts.get(e.id),n=JSON.stringify([e.layout,e.nodes]);return t&&t.key===n||(t=pI(e.nodes,e.layout,cI),t.key=n,this.layouts.set(e.id,t)),t}routeOf(e){let t=uF(e,e=>{let t=this.get(e);return!t||t.type===`connector`?null:{box:this.outerBox(t),ellipse:t.type===`shape`&&t.shape===`ellipse`}});return mF(e.mode,t[0],t[1])}selection(){return[...this.selected].map(e=>this.get(e)).filter(e=>!!e)}expanded(e){let t=new Set,n=this.elements();for(let r of e){t.add(r);for(let e of n)e.group===r&&t.add(e.id)}return[...t]}schedule(){this.raf||=requestAnimationFrame(()=>{this.raf=0,this.render()})}render(){let e=this.elements(),t=new Set,n=null;for(let r of e){t.add(r.id);let e=this.rendered.get(r.id);e&&e.type!==r.type&&(e.note?.destroy(),e.el.remove(),e=void 0),e||(e={el:document.createElement(`div`),key:``,type:r.type},e.el.className=`dw-cv-el dw-cv-${r.type}`,e.el.dataset.id=r.id,this.rendered.set(r.id,e),(r.type===`note`||r.type===`text`)&&this.resize?.observe(e.el));let i=this.keyOf(r);e.key===i||this.editing?.id===r.id&&this.stopEditingFn&&r.type!==`note`||(this.draw(e,r),e.key=i),e.el.classList.toggle(`dw-cv-selected`,this.selected.has(r.id)),e.el.classList.toggle(`dw-cv-editing`,this.editing?.id===r.id);let a=n?n.nextElementSibling:this.world.firstElementChild;a!==e.el&&this.world.insertBefore(e.el,a),n=e.el}for(let[e,n]of this.rendered)t.has(e)||(n.note?.destroy(),this.resize?.unobserve(n.el),n.el.remove(),this.rendered.delete(e),this.measured.delete(e),this.selected.delete(e));this.editing&&!t.has(this.editing.id)&&(this.editing=null),this.drawOverlay(),this.ui.refresh()}keyOf(e){if(e.type===`connector`){let t=this.routeOf(e);return this.routes.set(e.id,t),JSON.stringify(e)+t.d}return e.type===`note`&&e.page?JSON.stringify(e)+(this.opts.pageTitle?.()??``):JSON.stringify(e)}place(e,t,n=0,r=!1){e.style.transform=`translate(${t.x}px, ${t.y}px)${n?` rotate(${n}deg)`:``}`,e.style.width=r?``:`${t.w}px`,e.style.height=r?``:`${t.h}px`}draw(e,t){let n=e.el,r=this.editing?.id===t.id;switch(t.type){case`shape`:{this.place(n,t,t.rotate);let e=r?n.querySelector(`.dw-cv-label`):null;n.innerHTML=`${QL(t,UL)}`;let i=e??document.createElement(`div`);i.className=`dw-cv-label`,e||(i.textContent=t.text),i.style.color=UL(t.textColor,`line`),i.style.fontSize=`${t.fontSize}px`,n.append(i);return}case`text`:{n.style.transform=`translate(${t.x}px, ${t.y}px)${t.rotate?` rotate(${t.rotate}deg)`:``}`,n.style.width=t.w?`${t.w}px`:``,n.style.height=``;let e=n.querySelector(`.dw-cv-textbody`);e||(e=document.createElement(`div`),e.className=`dw-cv-textbody`,n.append(e)),r||(e.textContent=t.text),e.dataset.placeholder=this.labels.textPlaceholder,Object.assign(e.style,{color:UL(t.color,`line`),fontSize:`${t.fontSize}px`,fontFamily:aI(t.font),textAlign:t.align,fontWeight:t.bold?`650`:``,whiteSpace:t.w?`pre-wrap`:`pre`});return}case`connector`:{let e=this.routes.get(t.id)??this.routeOf(t),i=this.boxOf(t),a=24+t.strokeWidth*3,o={x:i.x-a,y:i.y-a,w:i.w+a*2,h:i.h+a*2};this.place(n,o);let s=``,c=t.label||r;n.innerHTML=`${eR(t,e,UL)}${s}`+(c?`
${WL(t.label)}
`:``);return}case`brush`:this.place(n,t,t.rotate),n.innerHTML=`${nR(t,UL).replace(``;return;case`note`:this.drawNote(e,t);return;case`frame`:{this.place(n,t);let e=r?n.querySelector(`.dw-cv-frametitle`):null;n.innerHTML=``;let i=e??document.createElement(`div`);i.className=`dw-cv-frametitle`,e||(i.textContent=t.title||this.labels.frameTitle),n.append(i);return}case`image`:{this.place(n,t,t.rotate);let e=this.opts.files?.resolve(t.src)??t.src,r=n.querySelector(`img`);r||(r=document.createElement(`img`),r.draggable=!1,n.replaceChildren(r)),r.getAttribute(`src`)!==e&&(r.src=e),r.alt=t.alt;return}case`embed`:this.drawEmbed(n,t);return;case`group`:n.style.display=`none`;return;case`mindmap`:this.drawMindmap(n,t);return}}drawNote(e,t){let n=e.el;if(n.style.transform=`translate(${t.x}px, ${t.y}px)`,n.style.width=`${t.w}px`,n.style.height=``,n.style.setProperty(`--dw-cv-note-bg`,UL(t.background,`fill`)),n.classList.toggle(`dw-cv-pagenote`,t.page),!e.note){let r=document.createElement(`div`);r.className=`dw-cv-notehead`;let i=document.createElement(`div`);i.className=`dw-cv-notebody`,n.replaceChildren(r,i);let a=t.page?this.opts.doc.getXmlFragment(`default`):this.store.body(t.id);if(a)try{e.note=this.opts.notes.mount(i,{id:t.id,page:t.page,fragment:a,doc:this.opts.doc,editable:this.editable})}catch(e){this.opts.onError?.(e)}}let r=n.querySelector(`.dw-cv-notehead`);r&&(r.textContent=t.page?this.opts.pageTitle?.()||this.labels.pageNote:``)}drawEmbed(e,t){this.place(e,t);let n=this.opts.embedSource?.(t.url)??null;if(n){if(e.querySelector(`iframe`)?.getAttribute(`src`)===n.src)return;let r=document.createElement(`iframe`);r.src=n.src,r.title=t.url,r.allow=`fullscreen; picture-in-picture; encrypted-media`,r.referrerPolicy=`strict-origin-when-cross-origin`,r.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-popups allow-presentation`),e.replaceChildren(r);return}let r=this.previews.get(t.url);r===void 0&&this.opts.links&&(this.previews.set(t.url,`loading`),this.opts.links.preview(t.url).then(e=>this.previews.set(t.url,e)).catch(()=>this.previews.set(t.url,null)).finally(()=>{let e=this.rendered.get(t.id);e&&(e.key=``),this.schedule()}),r=`loading`);let i=r&&r!==`loading`?r:null,a=t.url;try{a=new URL(t.url).hostname}catch{}let o=i?.image?``:``;e.innerHTML=`${o}${WL(i?.title||a)}${i?.description?`${WL(i.description)}`:``}${WL(i?.site||a)}`}drawMindmap(e,t){let n=this.layoutOf(t),r=n.bounds;this.place(e,{x:t.x+r.x,y:t.y+r.y,w:r.w,h:r.h});let i=UL(t.color,`line`),a=UL(t.color,`fill`),o=n.edges.map(e=>``).join(``),s=this.editing?.id===t.id?this.editing.node:void 0,c=s?e.querySelector(`[data-node="${s}"]`):null,l=[...n.boxes.values()].map(e=>{let n=e.depth===0?`dw-cv-node dw-cv-root`:`dw-cv-node`,o=this.activeNode?.map===t.id&&this.activeNode.node===e.id?` dw-cv-active`:``,s=`left:${e.x-r.x}px;top:${e.y-r.y}px;width:${e.w}px;height:${e.h}px;${e.depth===0?`background:${i};color:var(--dw-surface)`:e.depth===1?`background:${a};border-color:${i}`:`border-color:${i}`}`;return`
${WL(t.nodes[e.id]?.text??``)}
`});e.innerHTML=`${o}${l.join(``)}`,c&&s&&e.querySelector(`[data-node="${s}"]`)?.replaceWith(c)}onResize(e){let t=!1;for(let n of e){let e=n.target,r=e.dataset.id;if(!r)continue;let i={w:e.offsetWidth,h:e.offsetHeight},a=this.measured.get(r);a&&a.w===i.w&&a.h===i.h||(this.measured.set(r,i),t=!0)}if(t){for(let e of this.rendered.values())e.type===`connector`&&(e.key=``);this.schedule()}}toScreen([e,t]){return[e*this.view.zoom+this.view.x,t*this.view.zoom+this.view.y]}toWorld(e,t){let n=this.root.getBoundingClientRect();return[(e-n.left-this.view.x)/this.view.zoom,(t-n.top-this.view.y)/this.view.zoom]}get zoom(){return this.view.zoom}selectionScreenBox(){let e=ZP(this.selection().map(e=>this.outerBox(e)));if(!e)return null;let[t,n]=this.toScreen([e.x,e.y]);return{x:t,y:n,w:e.w*this.view.zoom,h:e.h*this.view.zoom}}drawOverlay(){let e=[],t=this.view.zoom,n=(e,t)=>{let n=XP(e);return[[e.x,e.y],[e.x+e.w,e.y],[e.x+e.w,e.y+e.h],[e.x,e.y+e.h]].map(e=>this.toScreen(nF(e,n,t)).join(`,`)).join(` `)};if(this.entered){let t=this.get(this.entered);t&&e.push(``)}if(this.hover&&this.hover!==this.editing?.id){let t=this.get(this.hover);t&&e.push(``)}let r=this.presenting?[]:this.selection();for(let t of r)if(t.type===`connector`){let n=this.routes.get(t.id)??this.routeOf(t);e.push(``)}else e.push(``);if(this.editable&&!this.presenting&&r.length&&!this.editing){let i=r.length===1?r[0]:null;if(i?.type===`connector`){let t=this.routes.get(i.id)??this.routeOf(i);for(let[n,r]of[[`source`,t.points[0]],[`target`,t.points[t.points.length-1]]]){let[t,i]=this.toScreen(r);e.push(``)}}else if(r.some(RF)&&i?.type!==`mindmap`){let a=i?i.rotate:0,o=i?this.boxOf(i):ZP(r.map(e=>this.outerBox(e)));r.length>1&&e.push(``);let s=XP(o),c=[[`nw`,[o.x,o.y]],[`n`,[o.x+o.w/2,o.y]],[`ne`,[o.x+o.w,o.y]],[`e`,[o.x+o.w,o.y+o.h/2]],[`se`,[o.x+o.w,o.y+o.h]],[`s`,[o.x+o.w/2,o.y+o.h]],[`sw`,[o.x,o.y+o.h]],[`w`,[o.x,o.y+o.h/2]]],l=i?.type===`note`;for(let[n,r]of c){if(l&&n!==`e`&&n!==`w`||o.w*t<24&&(n===`n`||n===`s`)||o.h*t<24&&(n===`e`||n===`w`))continue;let[i,c]=this.toScreen(nF(r,s,a));e.push(``)}if(i&&zF(i)){let[n,r]=this.toScreen(nF([o.x+o.w/2,o.y-28/t],s,a));e.push(``)}}}if(this.presenting||this.drawComments(e,n),this.marquee){let[n,r]=this.toScreen([this.marquee.x,this.marquee.y]);e.push(``)}for(let t of this.guides){let n=this.toScreen(t.axis===`x`?[t.value,t.from]:[t.from,t.value]),r=this.toScreen(t.axis===`x`?[t.value,t.to]:[t.to,t.value]);e.push(``)}this.overlay.innerHTML=e.join(``),this.ui.place()}applyView(){let{x:e,y:t,zoom:n}=this.view;this.world.style.transform=`translate(${e}px, ${t}px) scale(${n})`;let r=24*n;this.root.style.backgroundSize=`${r}px ${r}px`,this.root.style.backgroundPosition=`${e}px ${t}px`,this.root.style.setProperty(`--dw-cv-zoom`,String(n)),this.drawOverlay(),this.ui.zoomChanged(),clearTimeout(this.saveTimer),this.saveTimer=setTimeout(()=>this.saveView(),500)}saveView(){if(this.opts.viewKey)try{localStorage.setItem(this.opts.viewKey,JSON.stringify(this.view))}catch{}}restoreView(){if(!this.opts.viewKey)return!1;try{let e=JSON.parse(localStorage.getItem(this.opts.viewKey)??`null`);if(e&&[e.x,e.y,e.zoom].every(e=>typeof e==`number`&&Number.isFinite(e))&&e.zoom>0)return this.view={x:e.x,y:e.y,zoom:Math.min(ER,Math.max(TR,e.zoom))},!0}catch{}return!1}zoomAt(e,t){let n=Math.min(ER,Math.max(TR,e)),r=this.root.getBoundingClientRect(),[i,a]=t??[r.width/2,r.height/2],o=(i-this.view.x)/this.view.zoom,s=(a-this.view.y)/this.view.zoom;this.view={zoom:n,x:i-o*n,y:a-s*n},this.applyView()}zoomBy(e){this.zoomAt(this.view.zoom*e)}fit(e,t=!0,n=48){let r=e??ZP(this.elements().map(e=>this.outerBox(e))),i=this.root.getBoundingClientRect(),a=i.width||800,o=i.height||600;if(!r)this.view={x:a/2,y:o/3,zoom:1};else{let t=Math.min(ER,Math.max(TR,Math.min((a-n*2)/Math.max(r.w,1),(o-n*2)/Math.max(r.h,1),e?ER:1)));this.view={zoom:t,x:a/2-(r.x+r.w/2)*t,y:o/2-(r.y+r.h/2)*t},!e&&r.h*t>o&&(this.view.y=n-r.y*t)}t&&this.applyView()}animateTo(e){let t={...this.view},n=performance.now(),r=i=>{let a=Math.min(1,(i-n)/350),o=1-(1-a)**3;this.view={x:t.x+(e.x-t.x)*o,y:t.y+(e.y-t.y)*o,zoom:t.zoom+(e.zoom-t.zoom)*o},this.applyView(),a<1&&requestAnimationFrame(r)};requestAnimationFrame(r)}setTool(e){(this.editable||e===`select`||e===`hand`)&&(this.stopEditing(),this.tool=e,e!==`select`&&this.clearSelection(),this.root.dataset.tool=e,this.ui.refresh())}setShapeKind(e){this.shapeKind=e,this.setStyle(`shape`,{shape:e}),this.setTool(`shape`)}setStyle(e,t){this.styles={...this.styles,[e]:{...this.styles[e],...t}},this.opts.onStyles?.(this.styles)}restyle(e){let t=[];for(let n of this.selection()){let r=Object.fromEntries(Object.entries(e).filter(([e])=>e in n));if(!Object.keys(r).length)continue;t.push([n.id,r]);let i=n.type;if(i in this.styles){let e=Object.fromEntries(Object.entries(r).filter(([e])=>e in this.styles[i]));Object.keys(e).length&&!(n.type===`note`&&n.page)&&this.setStyle(i,e)}}this.store.updateMany(t)}select(e,t=!1){t||this.selected.clear();for(let t of e)this.selected.add(t);this.activeNode&&!this.selected.has(this.activeNode.map)&&(this.activeNode=null),this.refreshSelection()}clearSelection(){(this.selected.size||this.activeNode||this.entered)&&(this.selected.clear(),this.activeNode=null,this.entered=null,this.refreshSelection())}refreshSelection(){for(let[e,t]of this.rendered)t.el.classList.toggle(`dw-cv-selected`,this.selected.has(e)),t.type===`mindmap`&&(t.key=``);this.schedule(),this.drawOverlay(),this.ui.refresh()}pick(e){let t=this.get(e);return t?.group&&this.entered!==t.group&&this.get(t.group)?t.group:e}hit(e){if(!(e instanceof Element)||!this.world.contains(e))return null;let t=e.closest(`[data-id]`);if(!t?.dataset.id)return null;let n=e.closest(`[data-node]`)?.dataset.node;return{id:t.dataset.id,node:n}}connectableAt(e,t,n){for(let r of document.elementsFromPoint(e,t)){let e=this.hit(r);if(!e||n.has(e.id))continue;let t=this.get(e.id);if(t&&BF(t))return t}return null}listen(){let e=(e,t,n,r)=>{e.addEventListener(t,n,r),this.cleanups.push(()=>e.removeEventListener(t,n,r))};e(this.root,`pointerdown`,e=>this.onDown(e)),e(this.root,`pointermove`,e=>this.onMove(e)),e(this.root,`pointerup`,e=>this.onUp(e)),e(this.root,`pointercancel`,e=>this.onUp(e)),e(this.root,`dblclick`,e=>this.onDouble(e)),e(this.root,`wheel`,e=>this.onWheel(e),{passive:!1}),e(this.root,`keydown`,e=>this.onKey(e)),e(this.root,`keyup`,e=>{e.key===` `&&(this.spaceDown=!1,this.root.classList.remove(`dw-cv-panning`))}),e(document,`copy`,e=>this.onCopy(e,!1)),e(document,`cut`,e=>this.onCopy(e,!0)),e(document,`paste`,e=>this.onPaste(e)),e(this.root,`dragover`,e=>{this.editable&&e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()}),e(this.root,`drop`,e=>{let t=[...e.dataTransfer?.files??[]].filter(e=>e.type.startsWith(`image/`));this.editable&&t.length&&(e.preventDefault(),this.addImages(t,this.toWorld(e.clientX,e.clientY)))}),e(document,`fullscreenchange`,()=>{!document.fullscreenElement&&this.presenting&&this.stopPresenting()}),e(this.root,`click`,e=>{e.target.closest?.(`a.dw-cv-card`)&&this.editable&&e.preventDefault()})}inEditor(e){if(!(e instanceof Element))return!1;if(e.closest(`.dw-cv-ui`))return!0;if(this.editing){let t=this.rendered.get(this.editing.id);if(t&&t.el.contains(e)&&(e.closest(`[contenteditable=true]`)||e.closest(`.dw-cv-notebody`)||e.closest(`iframe`)))return!0}return!(this.editable||!e.closest(`.dw-cv-notebody, a.dw-cv-card`))}onDown(e){let t=e.target instanceof Element?e.target.closest(`[data-comment]`):null;if(t?.dataset.comment){e.preventDefault(),this.opts.onCommentSelect?.(t.dataset.comment);return}if(this.inEditor(e.target)||e.button===2)return;if(e.preventDefault(),this.root.focus({preventScroll:!0}),this.pointers.set(e.pointerId,[e.clientX,e.clientY]),this.pointers.size===2){this.cancelDrag();let[e,t]=[...this.pointers.values()],n=this.root.getBoundingClientRect();this.pinch={dist:Math.hypot(e[0]-t[0],e[1]-t[1]),mid:[(e[0]+t[0])/2-n.left,(e[1]+t[1])/2-n.top],zoom:this.view.zoom,vx:this.view.x,vy:this.view.y};return}if(this.pointers.size>2)return;this.editing&&this.stopEditing();let n=this.toWorld(e.clientX,e.clientY),r=e.pointerType===`touch`,i=()=>{this.drag={kind:`pan`,sx:e.clientX,sy:e.clientY,vx:this.view.x,vy:this.view.y},this.root.classList.add(`dw-cv-panning`)};if(this.root.setPointerCapture?.(e.pointerId),e.button===1||this.tool===`hand`||this.spaceDown||this.presenting)return e.preventDefault(),i();let a=e.target;if(!this.editable){let e=this.opts.onComment&&this.tool===`select`?this.hit(a):null;if(e){let t=this.pick(e.id);this.select([t]);return}return i()}switch(this.tool){case`pen`:{let t=document.createElementNS(DR,`svg`);t.classList.add(`dw-cv-temp`),this.world.append(t),this.drag={kind:`pen`,points:[[n[0],n[1],e.pressure||.5]],temp:t};return}case`eraser`:this.drag={kind:`erase`,hits:new Set},this.erase(e);return;case`shape`:case`frame`:this.drag={kind:`create`,type:this.tool,start:n,id:null};return;case`connector`:{let t=this.connectableAt(e.clientX,e.clientY,new Set),r=t?this.endOn(t,n):{x:n[0],y:n[1]},i=this.store.add({type:`connector`,...this.styles.connector,source:r,target:{x:n[0],y:n[1]}});this.drag={kind:`end`,id:i,side:`target`};return}case`note`:this.addNote(n);return;case`text`:this.addText(n);return;case`mindmap`:this.addMindmap(n);return}let o=a.dataset?.handle,s=a.dataset?.end;if(s){let e=this.selection()[0];e?.type===`connector`&&(this.store.undo?.stopCapturing(),this.drag={kind:`end`,id:e.id,side:s});return}if(o===`rotate`){let e=this.selection()[0],t=XP(this.boxOf(e));this.store.undo?.stopCapturing(),this.drag={kind:`rotate`,id:e.id,c:t,a0:Math.atan2(n[1]-t[1],n[0]-t[0]),r0:e.rotate};return}if(o){let e=this.selection(),t=e.length===1?e[0]:null,n=new Map(this.expanded(this.selected).map(e=>[e,this.get(e)]));for(let[e,t]of n){let r=this.measured.get(e);t.type===`text`&&r&&n.set(e,{...t,w:r.w,h:r.h}),t.type===`note`&&r&&n.set(e,{...t,h:r.h})}this.store.undo?.stopCapturing(),this.drag={kind:`resize`,handle:o,box:t?this.boxOf(t):ZP(e.map(e=>this.outerBox(e))),deg:t?t.rotate:0,orig:n,keep:e.some(e=>e.type===`image`||e.type===`text`||e.type===`brush`)||e.length>1};return}let c=this.hit(a);if(c){let t=this.pick(c.id),r=this.get(t);if(r?.type===`mindmap`&&c.node){this.activeNode={map:t,node:c.node};let e=this.rendered.get(t);e&&(e.key=``)}else r?.type!==`mindmap`&&(this.activeNode=null);e.shiftKey?(this.selected.has(t)?this.selected.delete(t):this.selected.add(t),this.refreshSelection()):this.selected.has(t)?this.refreshSelection():this.select([t]),this.startMove(n,t)}else{if(r)return i();this.entered=null,this.drag={kind:`marquee`,start:n,add:e.shiftKey,base:e.shiftKey?new Set(this.selected):new Set},e.shiftKey||this.clearSelection()}}startMove(e,t){let n=this.expanded(this.selected);for(let e of[...n]){let t=this.get(e);if(t?.type===`frame`)for(let e of this.elements())e.type!==`frame`&&!n.includes(e.id)&&eF(t,this.outerBox(e))&&n.push(...this.expanded([e.id]))}let r=[...new Set(n)].filter(e=>this.get(e)?.type!==`group`),i=new Map(r.map(e=>[e,this.get(e)])),a=ZP(r.map(e=>this.outerBox(this.get(e))))??{x:e[0],y:e[1],w:0,h:0};this.store.undo?.stopCapturing(),this.drag={kind:`move`,start:e,ids:r,orig:i,box:a,moved:!1,clickId:t}}endOn(e,t){let n=this.outerBox(e),r=bF(n,t,14/this.view.zoom);return r?{id:e.id,pos:[(r[0]-n.x)/Math.max(n.w,1),(r[1]-n.y)/Math.max(n.h,1)]}:{id:e.id}}onMove(e){if(this.pointers.has(e.pointerId)&&this.pointers.set(e.pointerId,[e.clientX,e.clientY]),this.pinch&&this.pointers.size>=2){let[e,t]=[...this.pointers.values()],n=this.root.getBoundingClientRect(),r=Math.hypot(e[0]-t[0],e[1]-t[1]),i=[(e[0]+t[0])/2-n.left,(e[1]+t[1])/2-n.top],a=this.pinch,o=Math.min(ER,Math.max(TR,a.zoom*r/Math.max(a.dist,1))),s=(a.mid[0]-a.vx)/a.zoom,c=(a.mid[1]-a.vy)/a.zoom;this.view={zoom:o,x:i[0]-s*o,y:i[1]-c*o},this.applyView();return}let t=this.drag,n=this.toWorld(e.clientX,e.clientY);if(t)switch(t.kind){case`pan`:this.view={...this.view,x:t.vx+e.clientX-t.sx,y:t.vy+e.clientY-t.sy},this.applyView();return;case`move`:{let r=n[0]-t.start[0],i=n[1]-t.start[1];if(!t.moved&&Math.hypot(r,i)*this.view.zoom<3)return;if(t.moved=!0,e.altKey)this.guides=[];else{let e=new Set(t.ids),n=this.visibleBoxes().filter(([t])=>!e.has(t)).map(([,e])=>e),a=yF({...t.box,x:t.box.x+r,y:t.box.y+i},n,6/this.view.zoom);r+=a.dx,i+=a.dy,this.guides=a.guides}let a=[];for(let[e,n]of t.orig)if(n.type===`connector`){let t={};for(let e of[`source`,`target`]){let a=n[e];a.id||(t[e]={x:(a.x??0)+r,y:(a.y??0)+i})}Object.keys(t).length&&a.push([e,t])}else a.push([e,{x:n.x+r,y:n.y+i}]);this.store.updateMany(a);return}case`marquee`:{this.marquee=tF(t.start,n);let e=new Set(t.base),r=this.marquee;for(let t of this.elements()){if(t.group&&this.get(t.group))continue;let n=this.outerBox(t);(t.type===`frame`?eF(r,n):$P(r,n))&&e.add(t.id)}for(let t of this.elements().filter(e=>e.type===`group`))$P(r,this.boxOf(t))&&e.add(t.id);this.selected.clear();for(let t of e)this.selected.add(t);this.refreshSelection();return}case`resize`:this.doResize(t,n,e.shiftKey);return;case`rotate`:{let r=t.r0+(Math.atan2(n[1]-t.c[1],n[0]-t.c[0])-t.a0)*180/Math.PI;e.shiftKey&&(r=Math.round(r/15)*15),r=(r%360+360)%360,this.store.update(t.id,{rotate:Math.round(r*10)/10});return}case`create`:{let r=tF(t.start,n);if(!t.id&&r.w*this.view.zoom<4&&r.h*this.view.zoom<4)return;e.shiftKey&&(r.w=r.h=Math.max(r.w,r.h)),t.id?this.store.update(t.id,{...r}):t.id=t.type===`shape`?this.store.add({type:`shape`,...this.styles.shape,shape:this.shapeKind,...r}):this.store.add({type:`frame`,...this.styles.frame,title:this.frameName(),...r});return}case`end`:{let r=this.get(t.id);if(r?.type!==`connector`)return;let i=r[t.side===`source`?`target`:`source`],a=new Set([t.id]),o=this.connectableAt(e.clientX,e.clientY,a);this.hover=o?.id??null;let s=o&&o.id!==i.id?this.endOn(o,n):{x:n[0],y:n[1]};this.store.update(t.id,{[t.side]:s});return}case`pen`:t.points.push([n[0],n[1],e.pressure||.5]),t.temp.innerHTML=``;return;case`erase`:this.erase(e);return}else if(this.editable&&this.tool===`connector`){let t=this.connectableAt(e.clientX,e.clientY,new Set);(t?.id??null)!==this.hover&&(this.hover=t?.id??null,this.drawOverlay())}}erase(e){let t=this.drag;if(t?.kind!==`erase`)return;let n=this.toWorld(e.clientX,e.clientY),r=6/this.view.zoom;for(let n of document.elementsFromPoint(e.clientX,e.clientY)){let e=this.hit(n);if(!e)continue;let r=this.get(e.id);r&&r.type!==`note`&&r.type!==`frame`&&(t.hits.add(r.id),this.rendered.get(r.id)?.el.classList.add(`dw-cv-erasing`))}for(let e of this.elements())e.type!==`brush`||t.hits.has(e.id)||aF(n,e.points.map(t=>[t[0]+e.x,t[1]+e.y]))<=r+e.size/2&&(t.hits.add(e.id),this.rendered.get(e.id)?.el.classList.add(`dw-cv-erasing`))}doResize(e,t,n){let r=e.box,i=XP(r),a=nF(t,i,-e.deg),o=r.x,s=r.y,c=r.x+r.w,l=r.y+r.h;e.handle.includes(`w`)&&(o=a[0]),e.handle.includes(`e`)&&(c=a[0]),e.handle.includes(`n`)&&(s=a[1]),e.handle.includes(`s`)&&(l=a[1]);let u=8/this.view.zoom;c-o[e[0]*m,e[1]*h,e[2]??.5])}]);break;case`mindmap`:case`group`:v.push([t,{x:e,y:i}]);break;default:v.push([t,{x:e,y:i,w:n.w*m,h:n.h*h}])}}this.store.updateMany(v)}visibleBoxes(){let e=this.root.getBoundingClientRect(),t=tF(this.toWorld(e.left,e.top),this.toWorld(e.right,e.bottom)),n=[];for(let e of this.elements()){if(e.type===`connector`||e.type===`group`)continue;let r=this.outerBox(e);if($P(t,r)&&n.push([e.id,r]),n.length>300)break}return n}onUp(e){if(this.pointers.delete(e.pointerId),this.pinch){this.pointers.size<2&&(this.pinch=null);return}let t=this.drag;if(this.drag=null,this.root.classList.remove(`dw-cv-panning`),this.guides=[],this.marquee=null,this.hover=null,!t)return;let n=this.toWorld(e.clientX,e.clientY);switch(t.kind){case`create`:{let e=t.id;if(!e){let r=t.type===`frame`?{w:800,h:600}:{w:140,h:100},i={x:n[0]-r.w/2,y:n[1]-r.h/2,...r};e=t.type===`shape`?this.store.add({type:`shape`,...this.styles.shape,shape:this.shapeKind,...i}):this.store.add({type:`frame`,...this.styles.frame,title:this.frameName(),...i})}this.tool=`select`,this.root.dataset.tool=`select`,this.select([e]);break}case`end`:{let e=this.get(t.id);if(e?.type===`connector`){let n=this.routeOf(e),r=n.points[0],i=n.points[n.points.length-1];Math.hypot(r[0]-i[0],r[1]-i[1])*this.view.zoom<8&&this.tool===`connector`?this.store.remove([t.id]):this.tool===`connector`&&this.select([t.id])}break}case`pen`:{t.temp.remove(),t.points.length<2&&t.points.push([t.points[0][0]+.5,t.points[0][1]+.5,.5]);let e=t.points.map(e=>e[0]),n=t.points.map(e=>e[1]),r=this.styles.brush.size,i=Math.min(...e)-r,a=Math.min(...n)-r,o=Math.max(...e)+r-i,s=Math.max(...n)+r-a;this.store.add({type:`brush`,...this.styles.brush,x:i,y:a,w:o,h:s,points:t.points.map(e=>[Math.round((e[0]-i)*10)/10,Math.round((e[1]-a)*10)/10,Math.round((e[2]??.5)*100)/100])});break}case`erase`:for(let e of t.hits)this.rendered.get(e)?.el.classList.remove(`dw-cv-erasing`);t.hits.size&&this.store.remove(t.hits)}this.drawOverlay(),this.ui.refresh()}cancelDrag(){let e=this.drag;e?.kind===`pen`&&e.temp.remove(),this.drag=null,this.marquee=null,this.guides=[]}onDouble(e){if(this.inEditor(e.target)||!this.editable||this.tool!==`select`)return;let t=this.hit(e.target);if(!t){this.addText(this.toWorld(e.clientX,e.clientY));return}let n=this.get(t.id);n&&(n.group&&this.entered!==n.group&&this.get(n.group)?(this.entered=n.group,this.select([n.id])):(n.type!==`frame`||e.target.closest(`.dw-cv-frametitle`))&&this.startEdit(n.id,t.node))}onWheel(e){if(this.presenting||e.target instanceof Element&&e.target.closest(`.dw-cv-ui`))return;e.preventDefault();let t=this.root.getBoundingClientRect();if(e.ctrlKey||e.metaKey){this.zoomAt(this.view.zoom*Math.exp(-e.deltaY*.01),[e.clientX-t.left,e.clientY-t.top]);return}let n=e.deltaMode===1?16:1,r=e.shiftKey&&!e.deltaX?e.deltaY:e.deltaX,i=e.shiftKey&&!e.deltaX?0:e.deltaY;this.view={...this.view,x:this.view.x-r*n,y:this.view.y-i*n},this.applyView()}onKey(e){if(this.presenting){this.presentKey(e);return}if(OR(e.target)||this.inEditor(e.target))return;let t=e.ctrlKey||e.metaKey,n=e.key.toLowerCase();if(e.key===` `&&!t){this.spaceDown=!0,this.root.classList.add(`dw-cv-panning`),e.preventDefault();return}if(t&&(n===`=`||n===`+`))return e.preventDefault(),this.zoomBy(1.25);if(t&&n===`-`)return e.preventDefault(),this.zoomBy(.8);if(e.altKey&&!t&&(e.code===`Digit0`||e.code===`Digit1`||e.code===`Digit2`)){if(e.preventDefault(),e.code===`Digit0`)return this.zoomAt(1);if(e.code===`Digit1`)return this.fit();let t=ZP(this.selection().map(e=>this.outerBox(e)));return this.fit(t??void 0)}if(e.key===`Escape`){this.entered?(this.select([this.entered]),this.entered=null):this.selected.size?this.clearSelection():this.setTool(`select`);return}if(!this.editable){!t&&n===`h`&&this.setTool(`hand`),!t&&n===`v`&&this.setTool(`select`);return}if(this.activeNode&&this.mindmapKey(e))return;if(t&&n===`z`){e.preventDefault(),e.shiftKey?this.store.undo?.redo():this.store.undo?.undo();return}if(t&&n===`y`){e.preventDefault(),this.store.undo?.redo();return}if(t&&n===`a`){e.preventDefault(),this.select(this.elements().filter(e=>!e.group||!this.get(e.group)).map(e=>e.id));return}if(t&&n===`d`){e.preventDefault(),this.duplicate();return}if(t&&n===`g`){e.preventDefault(),e.shiftKey?this.ungroup():this.group();return}if((e.key===`Delete`||e.key===`Backspace`)&&this.selected.size){e.preventDefault(),this.deleteSelection();return}if(e.key===`Enter`&&this.selected.size===1){e.preventDefault();let t=[...this.selected][0];this.startEdit(t);return}if(e.key.startsWith(`Arrow`)&&this.selected.size){e.preventDefault();let t=e.shiftKey?10:1,n=e.key===`ArrowLeft`?-t:e.key===`ArrowRight`?t:0,r=e.key===`ArrowUp`?-t:e.key===`ArrowDown`?t:0;this.nudge(n,r);return}if(t||e.altKey)return;let r={v:`select`,h:`hand`,n:`note`,t:`text`,s:`shape`,c:`connector`,p:`pen`,e:`eraser`,f:`frame`,m:`mindmap`};r[n]?(e.preventDefault(),this.setTool(r[n])):n===`i`?this.ui.pickImage():n===`l`&&this.addLink()}nudge(e,t){let n=this.expanded(this.selected),r=[];for(let i of n){let n=this.get(i);if(n&&n.type!==`group`){if(n.type===`connector`){let a={};for(let r of[`source`,`target`]){let i=n[r];i.id||(a[r]={x:(i.x??0)+e,y:(i.y??0)+t})}r.push([i,a])}else r.push([i,{x:n.x+e,y:n.y+t}])}}this.store.updateMany(r)}startEdit(e,t){if(!this.editable)return;let n=this.get(e),r=this.rendered.get(e);if(n&&r){if(n.type===`group`)this.entered=e;else if(n.type===`mindmap`){let i=t??(this.activeNode?.map===e?this.activeNode.node:dI(n.nodes));if(!i)return;this.activeNode={map:e,node:i},this.editing={id:e,node:i},this.draw(r,n);let a=r.el.querySelector(`[data-node="${i}"]`);a&&this.editText(a,n.nodes[i]?.text??``,!0,t=>this.store.updateNode(e,i,{text:t}))}else if(n.type!==`image`&&n.type!==`brush`)switch(this.select([e]),this.editing={id:e,node:t},r.el.classList.add(`dw-cv-editing`),this.drawOverlay(),this.ui.refresh(),n.type){case`note`:r.note?.focus();return;case`embed`:return;case`text`:{let t=r.el.querySelector(`.dw-cv-textbody`);t&&this.editText(t,n.text,!1,t=>t.trim()?this.store.update(e,{text:t}):this.store.remove([e]));return}case`shape`:{let t=r.el.querySelector(`.dw-cv-label`);t&&this.editText(t,n.text,!1,t=>this.store.update(e,{text:t}));return}case`frame`:{let t=r.el.querySelector(`.dw-cv-frametitle`);t&&this.editText(t,n.title,!0,t=>this.store.update(e,{title:t}));return}case`connector`:{this.draw(r,n);let t=r.el.querySelector(`.dw-cv-clabel`);t&&this.editText(t,n.label,!0,t=>this.store.update(e,{label:t}));return}}}}editText(e,t,n,r){e.contentEditable=`true`,e.spellcheck=!0,e.textContent=t,e.classList.add(`dw-cv-typing`);let i=!1,a=n=>{if(i)return;i=!0,this.stopEditingFn=null,e.contentEditable=`false`,e.classList.remove(`dw-cv-typing`),e.removeEventListener(`keydown`,o),e.removeEventListener(`blur`,s),e.removeEventListener(`paste`,c);let a=(e.innerText??e.textContent??``).replace(/\n$/,``),l=this.editing?.id;if(this.editing=null,(n&&a!==t||n&&!a.trim())&&r(a),l){let e=this.rendered.get(l);e&&(e.key=``)}this.schedule(),this.ui.refresh()},o=e=>{e.stopPropagation(),e.key===`Escape`||e.key===`Enter`&&(n||e.ctrlKey||e.metaKey)&&!e.shiftKey?(e.preventDefault(),a(!0),this.root.focus({preventScroll:!0})):e.key===`Tab`&&this.activeNode&&(e.preventDefault(),a(!0),this.mindmapAdd(`child`))},s=()=>a(!0),c=e=>{e.preventDefault(),e.stopPropagation(),document.execCommand(`insertText`,!1,e.clipboardData?.getData(`text/plain`)??``)};e.addEventListener(`keydown`,o),e.addEventListener(`blur`,s),e.addEventListener(`paste`,c),this.stopEditingFn=()=>a(!0),e.focus({preventScroll:!0});let l=document.createRange();l.selectNodeContents(e);let u=getSelection();u?.removeAllRanges(),u?.addRange(l)}stopEditingFn=null;stopEditing(){let e=this.stopEditingFn;if(this.stopEditingFn=null,e?.(),this.editing){let e=this.rendered.get(this.editing.id);e?.el.classList.remove(`dw-cv-editing`),e?.note&&document.activeElement&&e.el.contains(document.activeElement)&&document.activeElement.blur(),this.editing=null,this.drawOverlay(),this.ui.refresh()}}frameName(){let e=this.elements().filter(e=>e.type===`frame`).length+1;return`${this.labels.frameTitle} ${e}`}addNote(e){let t=this.store.add({type:`note`,...this.styles.note,x:e[0]-24,y:e[1]-24,w:320,h:120});this.setTool(`select`),this.select([t]),this.render(),this.startEdit(t)}addText(e){let t=this.store.add({type:`text`,...this.styles.text,x:e[0],y:e[1]-this.styles.text.fontSize*.7,w:0,h:0,text:``});this.setTool(`select`),this.render(),this.startEdit(t)}addMindmap(e){let t=`r${Date.now().toString(36)}`,n=this.store.add({type:`mindmap`,...this.styles.mindmap,x:e[0],y:e[1],nodes:{[t]:{text:this.labels.centralIdea,parent:``,pos:0}}});this.setTool(`select`),this.select([n]),this.activeNode={map:n,node:t},this.render(),this.startEdit(n,t)}viewCentre(){let e=this.root.getBoundingClientRect();return this.toWorld(e.left+e.width/2,e.top+e.height/2)}async addImages(e,t){let n=this.opts.files?.upload;if(!n)return;let[r,i]=t??this.viewCentre(),a=[];for(let t of e)try{let e=await n.call(this.opts.files,t),o=await AR(this.opts.files?.resolve(e.url)??e.url),s=Math.min(1,480/Math.max(o.w,1)),c=o.w*s,l=o.h*s;a.push(this.store.add({type:`image`,src:e.url,alt:e.name,x:r-c/2,y:i-l/2,w:c,h:l})),r+=24,i+=24}catch(e){this.opts.onError?.(e)}a.length&&this.select(a)}async addLink(e,t){let n=(e??window.prompt(this.labels.linkPrompt,`https://`))?.trim();if(!n||!/^https?:\/\//i.test(n))return;let[r,i]=t??this.viewCentre(),a=this.opts.embedSource?.(n),o=a?560:380,s=a?a.ratio===`video`?315:420:120,c=this.store.add({type:`embed`,url:n,x:r-o/2,y:i-s/2,w:o,h:s});this.setTool(`select`),this.select([c])}insertElements(e){let t=ZP(e.map(e=>({x:Number(e.x)||0,y:Number(e.y)||0,w:Number(e.w)||0,h:Number(e.h)||0})))??{x:0,y:0,w:0,h:0},[n,r]=this.viewCentre(),i=this.store.insertJSON(e,n-(t.x+t.w/2),r-(t.y+t.h/2));this.setTool(`select`),this.select(i.filter(e=>!i.includes(this.get(e)?.group??``)))}insertSticker(e){this.insertElements(KF(e))}insertTemplate(e){this.insertElements($F(e,this.labels))}deleteSelection(){let e=[...this.selected];this.clearSelection(),this.store.remove(e)}duplicate(){let e=this.store.toJSON(this.selected);if(!e.length)return;let t=this.store.insertJSON(e,24,24);this.select(t.filter(e=>!this.get(e)?.group||!t.includes(this.get(e).group)))}group(){let e=this.store.groupOf([...this.selected]);e&&this.select([e])}ungroup(){let e=this.selection().filter(e=>e.type===`group`),t=e.flatMap(e=>this.store.ungroup(e.id));e.length&&this.select(t)}reorder(e){this.store.reorder(this.expanded(this.selected),e)}mindmapAdd(e){let t=this.activeNode,n=t?this.get(t.map):void 0;if(!t||n?.type!==`mindmap`)return;let r=n.nodes[t.node];if(!r)return;let i=e===`child`||!r.parent?t.node:r.parent,a=fI(n.nodes,i),o;if(e===`sibling`&&r.parent){let e=a.indexOf(t.node),r=n.nodes[a[e]]?.pos??0;o=(r+(a[e+1]?n.nodes[a[e+1]]?.pos??r+2:r+2))/2}else o=a.length?Math.max(...a.map(e=>n.nodes[e]?.pos??0))+1:0;let s=this.store.addNode(t.map,i,o,``);this.activeNode={map:t.map,node:s},this.render(),this.startEdit(t.map,s)}mindmapKey(e){let t=this.activeNode,n=this.get(t.map);if(n?.type!==`mindmap`||!this.selected.has(t.map))return!1;if(e.key===`Tab`)return e.preventDefault(),this.mindmapAdd(`child`),!0;if(e.key===`Enter`)return e.preventDefault(),this.mindmapAdd(`sibling`),!0;if(e.key===`F2`)return e.preventDefault(),this.startEdit(t.map,t.node),!0;if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault();let r=n.nodes[t.node]?.parent;return this.store.removeNode(t.map,t.node),this.activeNode=r?{map:t.map,node:r}:null,this.schedule(),!0}if(e.key.startsWith(`Arrow`)&&!e.shiftKey){e.preventDefault();let r=mI(this.layoutOf(n),n.nodes,t.node,e.key);if(r){this.activeNode={map:t.map,node:r};let e=this.rendered.get(t.map);e&&(e.key=``),this.schedule()}return!0}return!1}owns(){let e=document.activeElement;return!!e&&(e===this.root||this.root.contains(e)&&!OR(e)&&!this.inEditor(e))}onCopy(e,t){if(!this.owns()||!this.selected.size||getSelection()?.toString())return;let n=this.store.toJSON(this.selected);e.clipboardData?.setData(`text/plain`,`docwell-canvas:${JSON.stringify(n)}`),e.preventDefault(),t&&this.editable&&this.deleteSelection()}onPaste(e){if(!this.editable||!this.owns())return;let t=[...e.clipboardData?.files??[]].filter(e=>e.type.startsWith(`image/`));if(t.length){e.preventDefault(),this.addImages(t);return}let n=e.clipboardData?.getData(`text/plain`)??``;if(!n)return;if(e.preventDefault(),n.startsWith(`docwell-canvas:`)){try{let e=JSON.parse(n.slice(15));Array.isArray(e)&&this.insertElements(e)}catch{}return}if(/^https?:\/\/\S+$/i.test(n.trim())){this.addLink(n.trim());return}let[r,i]=this.viewCentre(),a=this.store.add({type:`text`,...this.styles.text,x:r,y:i,w:n.length>60?480:0,h:0,text:n});this.select([a])}setComments(e,t=``){this.comments=e;let n=t!==this.activeComment;this.activeComment=t;let r=t?e.find(e=>e.comment===t):void 0;n&&r&&this.reveal(r.element),this.drawOverlay()}reveal(e){let t=this.get(e);if(!t)return;let n=this.outerBox(t),r=this.root.getBoundingClientRect(),[i,a]=this.toScreen([n.x,n.y]),[o,s]=this.toScreen([n.x+n.w,n.y+n.h]);if(i>=0&&a>=0&&o<=r.width&&s<=r.height)return;let c={...this.view};if(n.w*c.zoome.comment===this.activeComment);o&&e.push(``);let[s,c]=this.toScreen([a.x+a.w,a.y]),l=(o??i[0]).comment;e.push(`${WL(this.labels.comment)}${i.length}`)}}async exportImage(e,t=!1){let n=t&&this.selected.size?new Set(this.expanded(this.selected)):null,r=this.elements().filter(e=>!n||n.has(e.id));return wR(e,{root:this.root,elements:r,boxOf:e=>this.boxOf(e),routeOf:e=>this.routes.get(e.id)??this.routeOf(e),layoutOf:e=>this.layoutOf(e),noteBody:e=>e.page?this.opts.doc.getXmlFragment(`default`):this.store.body(e.id),pageTitle:this.opts.pageTitle?.()??``,resolve:e=>this.opts.files?.resolve(e)??e})}frames(){return this.elements().filter(e=>e.type===`frame`).sort((e,t)=>t.index-e.index)}present(){let e=this.frames().map(e=>e.id);if(!e.length){this.ui.toast(this.labels.presentNoFrames);return}this.stopEditing(),this.clearSelection();let t=this.ui.presentBar();this.presenting={frames:e,at:0,bar:t},this.root.classList.add(`dw-cv-presenting`),this.root.requestFullscreen?.().catch(()=>{}),requestAnimationFrame(()=>this.goTo(0))}goTo(e){let t=this.presenting;if(!t)return;t.at=Math.max(0,Math.min(t.frames.length-1,e));let n=this.get(t.frames[t.at]);if(n){let e={...this.view};this.fit(this.boxOf(n),!1,24);let t={...this.view};this.view=e,this.animateTo(t)}this.ui.presentStep(t.at,t.frames.length)}presentStep(e){this.presenting&&this.goTo(this.presenting.at+e)}stopPresenting(){let e=this.presenting;e&&(this.presenting=null,e.bar.remove(),this.root.classList.remove(`dw-cv-presenting`),document.fullscreenElement===this.root&&document.exitFullscreen().catch(()=>{}),this.drawOverlay())}get isPresenting(){return!!this.presenting}presentKey(e){[`ArrowRight`,`ArrowDown`,`PageDown`,` `,`Enter`].includes(e.key)?(e.preventDefault(),this.presentStep(1)):[`ArrowLeft`,`ArrowUp`,`PageUp`,`Backspace`].includes(e.key)?(e.preventDefault(),this.presentStep(-1)):e.key===`Escape`&&(e.preventDefault(),this.stopPresenting())}};function AR(e){return new Promise(t=>{let n=new Image;n.onload=()=>t({w:n.naturalWidth||320,h:n.naturalHeight||240}),n.onerror=()=>t({w:320,h:240}),n.src=e})}var jR={database:`Database`,untitled:`Untitled database`,untitledRow:`Untitled`,newRow:`New record`,addColumn:`Add property`,columnName:`Property name`,search:`Search records`,filter:`Filter`,sort:`Sort`,group:`Group`,properties:`Properties`,more:`More`,addView:`Add view`,viewName:`View name`,renameView:`Rename view`,duplicateView:`Duplicate view`,deleteView:`Delete view`,layout:`Layout`,viewTable:`Table`,viewKanban:`Kanban`,viewCalendar:`Calendar`,noValue:`No value`,checked:`Checked`,unchecked:`Unchecked`,noRows:`No records`,noMatches:`No records match`,rename:`Rename`,type:`Type`,hide:`Hide in view`,show:`Show in view`,sortAscending:`Sort ascending`,sortDescending:`Sort descending`,filterBy:`Filter by this property`,insertLeft:`Insert left`,insertRight:`Insert right`,moveLeft:`Move left`,moveRight:`Move right`,duplicate:`Duplicate`,deleteColumn:`Delete property`,typeTitle:`Title`,typeText:`Text`,typeNumber:`Number`,typeCheckbox:`Checkbox`,typeSelect:`Select`,typeMultiSelect:`Multi-select`,typeDate:`Date`,typeProgress:`Progress`,typeLink:`Link`,typeAttachment:`Attachment`,typeMember:`Member`,typeCreatedTime:`Created time`,typeCreatedBy:`Created by`,typeRelation:`Relation`,typeRollup:`Rollup`,linkedCount:`{n} linked`,rollupDays:`{n} days`,relationTo:`Related database`,relationPick:`Choose a database`,relationThisPage:`On this page`,relationOtherPage:`On another page…`,relationSearchPage:`Find a page`,relationNoDatabases:`No databases on that page`,relationMissing:`The related database is not available.`,relationTwoWay:`Two-way`,relationOneWay:`Links kept here`,relationMirror:`Show the links of “{n}”`,relationShowOn:`Show on “{n}” too`,relationBackReadOnly:`Change these links on the page that holds the related database.`,linkRecord:`Link a record`,searchRecords:`Search records`,noRecords:`No records`,openRelated:`Open record`,rollupSettings:`Rollup`,rollupRelation:`Relation`,rollupProperty:`Property`,rollupFn:`Calculate`,rollupRecords:`Records`,rollupNeedsRelation:`Add a relation property first.`,fnShowOriginal:`Show values`,fnCount:`Count records`,fnCountValues:`Count values`,fnCountUnique:`Count unique values`,fnCountEmpty:`Count empty`,fnCountNotEmpty:`Count not empty`,fnPercentNotEmpty:`Percent not empty`,fnSum:`Sum`,fnAverage:`Average`,fnMedian:`Median`,fnMin:`Min`,fnMax:`Max`,fnRange:`Range`,fnEarliest:`Earliest date`,fnLatest:`Latest date`,fnChecked:`Checked`,fnPercentChecked:`Percent checked`,openFullPage:`Open as full page`,backToPage:`Back to the page`,recordNotFound:`This record is not in the database any more.`,opContains:`contains`,opNotContains:`does not contain`,opIs:`is`,opIsNot:`is not`,opIsEmpty:`is empty`,opIsNotEmpty:`is not empty`,opGt:`is greater than`,opLt:`is less than`,opGte:`is at least`,opLte:`is at most`,opBefore:`is before`,opAfter:`is after`,opChecked:`is checked`,opUnchecked:`is not checked`,addFilter:`Add filter`,matchAll:`Every filter matches`,matchAny:`Any filter matches`,remove:`Remove`,value:`Value`,noFilters:`No filters yet`,addSort:`Add sort`,ascending:`Ascending`,descending:`Descending`,noSorts:`No sorts yet`,groupBy:`Group by`,noGrouping:`No grouping`,showAll:`Show all`,hideAll:`Hide all`,dateColumn:`Date property`,today:`Today`,previousMonth:`Previous month`,nextMonth:`Next month`,noDateColumn:`Add a date property to place records on the calendar.`,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`,insertBelow:`Insert below`,deleteRows:`Delete`,selected:`{n} selected`,selectRow:`Select record`,dragRow:`Drag to move`,close:`Close`,expand:`Full width`,collapse:`Narrow`,previousRow:`Previous record`,nextRow:`Next record`,bodyPlaceholder:`Write about this record…`,bodyReadOnly:`This record has no notes.`,searchOptions:`Find or create a choice`,createOption:`Create “{n}”`,optionColor:`Colour`,deleteOption:`Delete choice`,renameOption:`Rename choice`,searchPeople:`Find a person`,noPeople:`Nobody found`,upload:`Upload a file`,linkPlaceholder:`Paste a link`,clear:`Clear`,exportCsv:`Export as CSV`,importCsv:`Import CSV`,imported:`Added {n} records`,copyNotice:`Copied {n} cells`,readOnly:`Only people who can edit the page can change this database.`,resize:`Drag to change the width`,groupAsDatabase:`Group as database`,done:`Done`},MR={title:`typeTitle`,text:`typeText`,number:`typeNumber`,checkbox:`typeCheckbox`,select:`typeSelect`,multiSelect:`typeMultiSelect`,date:`typeDate`,progress:`typeProgress`,link:`typeLink`,attachment:`typeAttachment`,member:`typeMember`,createdTime:`typeCreatedTime`,createdBy:`typeCreatedBy`,relation:`typeRelation`,rollup:`typeRollup`},NR=(e,t)=>e[MR[t]],PR={contains:`opContains`,notContains:`opNotContains`,is:`opIs`,isNot:`opIsNot`,isEmpty:`opIsEmpty`,isNotEmpty:`opIsNotEmpty`,gt:`opGt`,lt:`opLt`,gte:`opGte`,lte:`opLte`,before:`opBefore`,after:`opAfter`,checked:`opChecked`,unchecked:`opUnchecked`},FR=(e,t)=>e[PR[t]],IR=(e,t)=>t===`kanban`?e.viewKanban:t===`calendar`?e.viewCalendar:e.viewTable,LR=(e,t)=>e.replace(`{n}`,String(t)),{colors:RR,...zR}=xF,BR={slashMenu:`Insert block`,noMatches:`No matching blocks`,slash:{text:{label:`Text`,description:`Plain paragraph`},h1:{label:`Heading 1`,description:`Big section heading`},h2:{label:`Heading 2`,description:`Medium section heading`},h3:{label:`Heading 3`,description:`Small section heading`},otherHeadings:{label:`Other headings`,description:`Headings 4 to 6`},h4:{label:`Heading 4`,description:`A heading below level 3`},h5:{label:`Heading 5`,description:`A heading below level 4`},h6:{label:`Heading 6`,description:`The smallest heading`},bullet:{label:`Bulleted list`,description:`A simple list`},ordered:{label:`Numbered list`,description:`A list with numbers`},todo:{label:`To-do list`,description:`Tasks to tick off (or type [])`},callout:{label:`Callout`,description:`Set a note apart with an emoji and colour`},columns:{label:`Columns`,description:`Put blocks side by side`},columns2:{label:`2 columns`,description:`Two blocks side by side`},columns3:{label:`3 columns`,description:`Three blocks side by side`},columns4:{label:`4 columns`,description:`Four blocks side by side`},table:{label:`Table`,description:`Rows and columns`},quote:{label:`Quote`,description:`Set text apart as a quote`},code:{label:`Code block`,description:`Monospaced code`},divider:{label:`Divider`,description:`A line between sections`},image:{label:`Image`,description:`Upload a picture`},file:{label:`File`,description:`Attach a file to download`},math:{label:`Math block`,description:`A formula on its own line (LaTeX)`},mathInline:{label:`Inline math`,description:`A formula inside the text (LaTeX)`},mermaid:{label:`Mermaid diagram`,description:`Flowcharts and sequences from text`},drawio:{label:`Draw.io diagram`,description:`Draw a diagram with diagrams.net`},excalidraw:{label:`Excalidraw drawing`,description:`Sketch by hand`},toc:{label:`Table of contents`,description:`The page's headings, kept up to date`},pageLink:{label:`Link to page`,description:`Link another page (or type [[)`},toggle:{label:`Toggle`,description:`A heading that hides the blocks under it`},embed:{label:`Embed`,description:`A video, design or document from YouTube, Figma and more`},linkCard:{label:`Link card`,description:`A link with its page's title and picture`},syncedPage:{label:`Synced page`,description:`Show another page here, always up to date`},database:{label:`Database`,description:`Records in a table, board or calendar`},newPage:{label:`New page`,description:`Make a page and link it here`},today:{label:`Today`,description:`Insert today's date`},tomorrow:{label:`Tomorrow`,description:`Insert tomorrow's date`},yesterday:{label:`Yesterday`,description:`Insert yesterday's date`},now:{label:`Now`,description:`Insert the date and time`}},format:{bold:`Bold`,italic:`Italic`,strike:`Strikethrough`,code:`Inline code`,link:`Link`,linkPrompt:`Link address (leave empty to remove the link)`,comment:`Comment`,underline:`Underline`,color:`Colour`,textColor:`Text colour`,highlight:`Highlight`,noColor:`Default`,align:`Align`,alignLeft:`Align left`,alignCenter:`Align centre`,alignRight:`Align right`,math:`Inline math`,linkedPage:`Make a linked page`},colors:{gray:`Grey`,red:`Red`,orange:`Orange`,yellow:`Yellow`,green:`Green`,teal:`Teal`,blue:`Blue`,purple:`Purple`,pink:`Pink`},table:{toolbar:`Table`,dragRow:`Drag to move the row`,dragColumn:`Drag to move the column`,moveRowUp:`Move row up`,moveRowDown:`Move row down`,moveColumnLeft:`Move column left`,moveColumnRight:`Move column right`,addRowBefore:`Add row above`,addRowAfter:`Add row below`,addColumnBefore:`Add column left`,addColumnAfter:`Add column right`,deleteRow:`Delete row`,deleteColumn:`Delete column`,toggleHeaderRow:`Header row`,mergeCells:`Merge cells`,splitCell:`Split cell`,deleteTable:`Delete table`},blockMenu:{open:`Drag to move, click for actions`,turnInto:`Turn into`,moveUp:`Move up`,moveDown:`Move down`,duplicate:`Duplicate`,copy:`Copy`,delete:`Delete`,showLineNumbers:`Show line numbers`,hideLineNumbers:`Hide line numbers`,showPages:`Show pages`,showAsFile:`Show as file`},mentions:`Mention someone`,noPeople:`Nobody found`,pageLinks:`Link to a page`,noPages:`No pages found`,blocks:{edit:`Edit`,done:`Done`,cancel:`Cancel`,save:`Save`,remove:`Remove`,saving:`Saving…`,latex:`LaTeX formula`,mermaid:`Mermaid diagram source`,mermaidError:`This diagram has an error:`,emptyDrawio:`Empty diagram. Click to draw.`,emptyExcalidraw:`Empty drawing. Click to sketch.`,loadFailed:`The editor could not be loaded.`,toc:`Contents`,tocEmpty:`Add headings to the page to fill the table of contents.`,expand:`Show contents`,collapse:`Hide contents`,embed:`Embedded content`,embedUrl:`Address of the video, design or document`,embedInvalid:`This address can't be embedded.`,syncedPage:`Synced page`,syncedOpen:`Open`,syncedFold:`Fold`,syncedUnfold:`Unfold`,syncedLoading:`Loading the page…`,syncedDenied:`You can't open this page.`,syncedSelf:`A page can't show itself.`,linkUrl:`Address of the page to link`,copyBlockLink:`Copy link to this block`,calloutEmoji:`Change emoji`,calloutColor:`Change colour`,resizeColumn:`Drag to resize the columns`,addColumn:`Add a column`,pdfLoading:`Loading PDF…`,pdfPage:`Page {n}`,transcribe:`Transcribe`,transcribeHint:`Add a summary and the transcript below, with AI`,transcribing:`Transcribing…`,transcribeFailed:`The recording could not be transcribed.`},suggest:{mode:`Suggesting`,hint:`Your edits show as suggestions until someone accepts them`,one:`1 suggestion`,count:`{n} suggestions`,accept:`Accept`,reject:`Reject`,acceptAll:`Accept all`,rejectAll:`Reject all`,adds:`Adds`,removes:`Removes`},find:{find:`Find in page`,replace:`Replace with`,previous:`Previous match`,next:`Next match`,replaceOne:`Replace`,replaceAll:`Replace all`,matchCase:`Match case`,close:`Close`,count:`{current} of {total}`,none:`No matches`},ai:{button:`Ask AI`,rewrite:`Improve writing`,summarize:`Summarise`,translate:`Translate`,continue:`Continue writing`,shorter:`Make shorter`,longer:`Make longer`,fix:`Fix spelling and grammar`,custom:`Ask AI to…`,customPlaceholder:`Tell AI what to do with the selection`,language:`Language`,run:`Go`,working:`Writing…`,replace:`Replace selection`,insertBelow:`Insert below`,discard:`Discard`,stop:`Stop`,retry:`Try again`,failed:`AI could not finish this.`},dates:{today:`Today`,tomorrow:`Tomorrow`,yesterday:`Yesterday`,nextWeek:`Next week`,remindWord:`remind`,remindMe:`Remind me`,reminderAt:`Reminder at 9:00 on the day`,someoneElse:`Someone else set a reminder on this date.`,edit:`Change date`,openJournal:`Open journal`},database:jR,edgeless:zR},VR=[`title`,`text`,`number`,`checkbox`,`select`,`multiSelect`,`date`,`progress`,`link`,`attachment`,`member`,`createdTime`,`createdBy`,`relation`,`rollup`],HR=VR.filter(e=>e!==`title`),UR=[`table`,`kanban`,`calendar`];function WR(){let e=new Uint8Array(6);return crypto.getRandomValues(e),[...e].map(e=>e.toString(36).padStart(2,`0`)).join(``).slice(0,10)}function GR(e,t,n){let r=n.find(e=>KR.includes(e.type)),i=n.find(e=>e.type===`date`||e.type===`createdTime`);return{id:WR(),name:t,type:e,hidden:[],filters:[],filterMode:`and`,sorts:[],groupBy:e===`kanban`?r?.id??null:null,dateColumn:e===`calendar`?i?.id??null:null,widths:{}}}var KR=[`select`,`multiSelect`,`checkbox`,`member`,`createdBy`];function qR(e){let t=XR(e)?e:{},n=(Array.isArray(t.columns)?t.columns:[]).flatMap(e=>{if(!XR(e)||typeof e.id!=`string`||!e.id)return[];let t=VR.includes(String(e.type))?e.type:`text`,n={id:e.id,name:typeof e.name==`string`?e.name:``,type:t};Array.isArray(e.options)&&(n.options=e.options.flatMap(JR));let r=t===`relation`?bz(e.relation):void 0;r&&(n.relation=r);let i=t===`rollup`?xz(e.rollup):void 0;return i&&(n.rollup=i),[n]});n.some(e=>e.type===`title`)||n.unshift({id:WR(),name:``,type:`title`});let r=(Array.isArray(t.rows)?t.rows:[]).flatMap(e=>{if(!XR(e)||typeof e.id!=`string`||!e.id)return[];let t={id:e.id,cells:XR(e.cells)?{...e.cells}:{},createdAt:typeof e.createdAt==`number`?e.createdAt:0,createdBy:YR(e.createdBy)};return Array.isArray(e.body)&&e.body.length&&(t.body=e.body,t.hasBody=!0),[t]}),i=new Set(n.map(e=>e.id)),a=(Array.isArray(t.views)?t.views:[]).flatMap(e=>{if(!XR(e)||typeof e.id!=`string`||!e.id)return[];let t=UR.includes(String(e.type))?e.type:`table`;return[{id:e.id,name:typeof e.name==`string`?e.name:``,type:t,hidden:Array.isArray(e.hidden)?e.hidden.filter(e=>typeof e==`string`):[],filters:Array.isArray(e.filters)?e.filters.filter(e=>XR(e)&&typeof e.column==`string`&&typeof e.op==`string`):[],filterMode:e.filterMode===`or`?`or`:`and`,sorts:Array.isArray(e.sorts)?e.sorts.flatMap(e=>XR(e)&&typeof e.column==`string`?[{column:e.column,desc:!!e.desc}]:[]):[],groupBy:typeof e.groupBy==`string`&&i.has(e.groupBy)?e.groupBy:null,dateColumn:typeof e.dateColumn==`string`&&i.has(e.dateColumn)?e.dateColumn:null,widths:XR(e.widths)?Object.fromEntries(Object.entries(e.widths).filter(e=>typeof e[1]==`number`)):{}}]});return{title:typeof t.title==`string`?t.title:``,columns:n,rows:r,views:a}}function JR(e){return!XR(e)||typeof e.id!=`string`?[]:[{id:e.id,name:typeof e.name==`string`?e.name:``,color:IP(e.color)?e.color:`gray`}]}function YR(e){return XR(e)&&typeof e.id==`string`?{id:e.id,name:typeof e.name==`string`?e.name:``}:null}function XR(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ZR(e){return e.columns.find(e=>e.type===`title`)??e.columns[0]}function QR(e,t){return t.type===`createdTime`?e.createdAt||null:t.type===`createdBy`?e.createdBy?[e.createdBy]:[]:t.type===`rollup`?e.computed?.[t.id]?.value??null:t.type===`relation`&&t.relation?.back?e.computed?.[t.id]?.value??[]:e.cells[t.id]}function $R(e){return e==null||e===``||e===!1||Array.isArray(e)&&e.length===0}function ez(e){return typeof e==`number`&&e>0?tz(new Date(e)):typeof e==`string`&&/^\d{4}-\d{2}-\d{2}/.test(e)?e.slice(0,10):``}function tz(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function nz(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e.trim().replace(`,`,`.`));return Number.isFinite(t)?t:null}return null}function rz(e){return Array.isArray(e)?e:[]}function iz(e,t){let n=QR(e,t);switch(t.type){case`title`:case`text`:case`link`:return typeof n==`string`?n:``;case`number`:case`progress`:{let e=nz(n);return e===null?``:String(e)}case`checkbox`:return n===!0?`true`:`false`;case`select`:return t.options?.find(e=>e.id===n)?.name??``;case`multiSelect`:return rz(n).map(e=>t.options?.find(t=>t.id===e)?.name).filter(e=>!!e).join(`, `);case`date`:case`createdTime`:return ez(n);case`attachment`:return rz(n).map(e=>e?.name??``).join(`, `);case`member`:case`createdBy`:return rz(n).map(e=>e?.name??``).join(`, `);case`relation`:case`rollup`:return e.computed?.[t.id]?.text??``}}function az(e){switch(e){case`number`:case`progress`:return[`is`,`isNot`,`gt`,`lt`,`gte`,`lte`,`isEmpty`,`isNotEmpty`];case`checkbox`:return[`checked`,`unchecked`];case`select`:return[`is`,`isNot`,`isEmpty`,`isNotEmpty`];case`multiSelect`:case`member`:case`createdBy`:return[`contains`,`notContains`,`isEmpty`,`isNotEmpty`];case`date`:case`createdTime`:return[`is`,`before`,`after`,`isEmpty`,`isNotEmpty`];case`attachment`:return[`isEmpty`,`isNotEmpty`];case`relation`:return[`contains`,`notContains`,`isEmpty`,`isNotEmpty`];case`rollup`:return[`is`,`isNot`,`gt`,`lt`,`gte`,`lte`,`contains`,`isEmpty`,`isNotEmpty`];default:return[`contains`,`notContains`,`is`,`isNot`,`isEmpty`,`isNotEmpty`]}}var oz=e=>![`isEmpty`,`isNotEmpty`,`checked`,`unchecked`].includes(e);function sz(e,t,n){let r=QR(e,t);if(t.type===`relation`){let e=Cz(r).length===0;if(n.op===`isEmpty`)return e;if(n.op===`isNotEmpty`)return!e}if(n.op===`isEmpty`)return $R(r)||iz(e,t)===``;if(n.op===`isNotEmpty`)return!($R(r)||iz(e,t)===``);if(n.op===`checked`)return r===!0;if(n.op===`unchecked`)return r!==!0;if(n.value===void 0||n.value===null||n.value===``)return!0;switch(t.type===`rollup`&&(typeof r==`number`||r===null)&&[`is`,`isNot`,`gt`,`lt`,`gte`,`lte`].includes(n.op)?`number`:t.type){case`number`:case`progress`:{let e=nz(r),t=nz(n.value);return t===null?!0:e===null?n.op===`isNot`:{is:e===t,isNot:e!==t,gt:e>t,lt:e=t,lte:e<=t}[n.op]}case`select`:return n.op===`is`?r===n.value:r!==n.value;case`multiSelect`:{let e=rz(r).includes(String(n.value));return n.op===`notContains`?!e:e}case`member`:case`createdBy`:{let e=String(n.value).toLowerCase(),t=rz(r).some(t=>t?.id===n.value||t?.name?.toLowerCase().includes(e));return n.op===`notContains`?!t:t}case`date`:case`createdTime`:{let e=ez(r),t=ez(n.value);return e?n.op===`before`?et:e===t:!1}default:{let r=iz(e,t).toLowerCase(),i=String(n.value).toLowerCase();switch(n.op){case`contains`:return r.includes(i);case`notContains`:return!r.includes(i);case`is`:return r===i;case`isNot`:return r!==i;default:return!0}}}}function cz(e,t,n){let r=iz(e,n)===``&&n.type!==`checkbox`,i=iz(t,n)===``&&n.type!==`checkbox`;if(r||i)return r===i?0:r?1:-1;switch(n.type){case`number`:case`progress`:return(nz(QR(e,n))??0)-(nz(QR(t,n))??0);case`checkbox`:return Number(QR(e,n)===!0)-Number(QR(t,n)===!0);case`createdTime`:return e.createdAt-t.createdAt;case`rollup`:{let r=QR(e,n),i=QR(t,n);return typeof r==`number`&&typeof i==`number`?r-i:iz(e,n).localeCompare(iz(t,n),void 0,{numeric:!0,sensitivity:`base`})}case`select`:{let r=e=>n.options?.findIndex(t=>t.id===QR(e,n))??-1;return r(e)-r(t)}default:return iz(e,n).localeCompare(iz(t,n),void 0,{numeric:!0,sensitivity:`base`})}}function lz(e,t,n=``){let r=new Map(e.columns.map(e=>[e.id,e])),i=t.filters.flatMap(e=>{let t=r.get(e.column);return t?[{f:e,col:t}]:[]}),a=n.trim().toLowerCase(),o=e.rows.filter(n=>{if(i.length){let e=({f:e,col:t})=>sz(n,t,e);if(t.filterMode===`or`?!i.some(e):!i.every(e))return!1}return!a||e.columns.some(e=>iz(n,e).toLowerCase().includes(a))}),s=t.sorts.flatMap(e=>{let t=r.get(e.column);return t?[{col:t,desc:e.desc}]:[]});return s.length&&(o=o.map((e,t)=>({r:e,i:t})).sort((e,t)=>{for(let n of s){let r=cz(e.r,t.r,n.col);if(r!==0){let i=iz(e.r,n.col)===``||iz(t.r,n.col)===``;return n.desc&&!(i&&n.col.type!==`checkbox`)?-r:r}}return e.i-t.i}).map(e=>e.r)),o}function uz(e,t){return e.columns.filter(e=>e.type===`title`||!t.hidden.includes(e.id))}function dz(e,t,n,r,i){let a=new Map,o=(e,t,n)=>(a.has(e)||a.set(e,{key:e,label:t,color:n,rows:[]}),a.get(e));if(t.type===`checkbox`)o(`false`,i),o(`true`,r);else{o(``,n);for(let e of t.options??[])o(e.id,e.name,e.color)}for(let n of e)for(let e of pz(n,t))(a.get(e)??o(e,fz(n,t,e)||e)).rows.push(n);return[...a.values()]}function fz(e,t,n){return rz(QR(e,t)).find(e=>e?.id===n)?.name??``}function pz(e,t){let n=QR(e,t);switch(t.type){case`checkbox`:return[n===!0?`true`:`false`];case`select`:return[typeof n==`string`&&t.options?.some(e=>e.id===n)?n:``];case`multiSelect`:{let e=rz(n).filter(e=>t.options?.some(t=>t.id===e));return e.length?e:[``]}case`member`:case`createdBy`:{let e=rz(n).flatMap(e=>e?.id?[e.id]:[]);return e.length?e:[``]}default:return[``]}}function mz(e,t,n,r,i=[]){let a=QR(e,t);switch(t.type){case`checkbox`:return r===`true`;case`select`:return r||null;case`multiSelect`:{let e=rz(a).filter(e=>e!==n&&e!==r);return r?[...e,r]:e}case`member`:{let e=rz(a).filter(e=>e?.id!==n&&e?.id!==r),t=i.find(e=>e.id===r)??rz(a).find(e=>e?.id===r);return r&&t?[...e,t]:e}default:return a}}function hz(e){let t=FP.filter(e=>e!==`gray`);return t[e.length%t.length]}function gz(e,t,n,r){if(t.type===n)return{value:e,options:r};let i=iz({id:``,cells:{[t.id]:e},createdAt:0,createdBy:null},t),a=e=>{let t=e.trim();if(!t)return null;let n=r.find(e=>e.name.toLowerCase()===t.toLowerCase());return n||(n={id:WR(),name:t,color:hz(r)},r=[...r,n]),n.id};switch(n){case`title`:case`text`:case`link`:return{value:i||null,options:r};case`number`:return{value:nz(i),options:r};case`progress`:{let e=nz(i);return{value:e===null?null:Math.max(0,Math.min(100,Math.round(e))),options:r}}case`checkbox`:return{value:[`true`,`yes`,`1`,`x`,`✓`,`done`].includes(i.trim().toLowerCase()),options:r};case`select`:return{value:a(i.split(`,`)[0]??``),options:r};case`multiSelect`:{let e=i.split(`,`).flatMap(e=>{let t=a(e);return t?[t]:[]});return{value:[...new Set(e)],options:r}}case`date`:return{value:ez(i)||null,options:r};case`member`:return{value:t.type===`member`||t.type===`createdBy`?e:[],options:r};default:return{value:null,options:r}}}function _z(e,t,n=1){let r=(new Date(e,t,1).getDay()-n+7)%7,i=new Date(e,t,1-r),a=new Date(e,t+1,0).getDate(),o=Math.ceil((r+a)/7);return Array.from({length:o*7},(e,t)=>tz(new Date(i.getFullYear(),i.getMonth(),i.getDate()+t)))}var vz=e=>e.type===`relation`&&!!e.relation?.back,yz=[`showOriginal`,`count`,`countValues`,`countUnique`,`countEmpty`,`countNotEmpty`,`percentNotEmpty`,`sum`,`average`,`median`,`min`,`max`,`range`,`earliest`,`latest`,`checked`,`percentChecked`];function bz(e){if(!XR(e)||typeof e.database!=`string`||!e.database)return;let t={page:typeof e.page==`string`?e.page:``,database:e.database};return typeof e.back==`string`&&e.back&&(t.back=e.back),t}function xz(e){if(!XR(e)||typeof e.relation!=`string`)return;let t=yz.includes(String(e.fn))?e.fn:`count`;return{relation:e.relation,property:typeof e.property==`string`?e.property:``,fn:t}}function Sz(e){let t=[`count`,`countValues`,`countUnique`,`countEmpty`,`countNotEmpty`,`percentNotEmpty`];switch(e){case`number`:case`progress`:return[`sum`,`average`,`median`,`min`,`max`,`range`,...t,`showOriginal`];case`date`:case`createdTime`:return[`earliest`,`latest`,`range`,...t,`showOriginal`];case`checkbox`:return[`checked`,`percentChecked`,`count`,`showOriginal`];default:return[`showOriginal`,...t]}}var Cz=e=>rz(e).filter(e=>typeof e==`string`&&!!e);function wz(e,t,n){let r=t.relation?.back;return r?n?n.rows.filter(t=>Cz(t.cells[r]).includes(e.id)).map(e=>e.id):[]:Cz(e.cells[t.id])}var Tz=e=>String(Number.isInteger(e)?e:Math.round(e*100)/100),Ez=(e,t)=>Math.round((Date.parse(t)-Date.parse(e))/864e5);function Dz(e,t,n,r){let i=t.map(e=>n?QR(e,n):e.id),a=t.map(e=>n?iz(e,n):``),o=a.filter((e,t)=>n?.type===`checkbox`?i[t]===!0:e!==``),s=n?i.map(nz).filter(e=>e!==null):[],c=n?i.map(ez).filter(Boolean).sort():[],l=e=>({text:e===null?``:Tz(e),value:e});switch(e){case`count`:return l(t.length);case`countValues`:return l(o.length);case`countUnique`:return l(new Set(o).size);case`countEmpty`:return l(t.length-o.length);case`countNotEmpty`:return l(o.length);case`percentNotEmpty`:return t.length?{text:`${Tz(o.length/t.length*100)}%`,value:o.length/t.length*100}:l(null);case`sum`:return l(s.length?s.reduce((e,t)=>e+t,0):null);case`average`:return l(s.length?s.reduce((e,t)=>e+t,0)/s.length:null);case`median`:{if(!s.length)return l(null);let e=[...s].sort((e,t)=>e-t),t=Math.floor(e.length/2);return l(e.length%2?e[t]:(e[t-1]+e[t])/2)}case`min`:return l(s.length?Math.min(...s):null);case`max`:return l(s.length?Math.max(...s):null);case`range`:if(n&&(n.type===`date`||n.type===`createdTime`)){if(!c.length)return l(null);let e=Ez(c[0],c[c.length-1]);return{text:r.rollupDays.replace(`{n}`,String(e)),value:e}}return l(s.length?Math.max(...s)-Math.min(...s):null);case`earliest`:return{text:c[0]??``,value:c[0]??null};case`latest`:return{text:c[c.length-1]??``,value:c[c.length-1]??null};case`checked`:return l(i.filter(e=>e===!0).length);case`percentChecked`:return t.length?{text:`${Tz(i.filter(e=>e===!0).length/t.length*100)}%`,value:i.filter(e=>e===!0).length/t.length*100}:l(null);case`showOriginal`:{let e=a.filter(Boolean);return{text:e.join(`, `),value:e}}}}function Oz(e,t,n){let r=e.columns.filter(e=>e.type===`relation`&&e.relation),i=e.columns.filter(e=>e.type===`rollup`&&e.rollup);if(!r.length&&!i.length)return e;let a=new Map;for(let e of r)a.set(e.id,t(e.relation));let o=e.rows.map(e=>{let t={};for(let i of r){let r=a.get(i.id),o=wz(e,i,r);if(!r){t[i.id]={text:o.length?n.linkedCount.replace(`{n}`,String(o.length)):``,value:o};continue}let s=r.columns.find(e=>e.type===`title`),c=new Map(r.rows.map(e=>[e.id,e])),l=o.flatMap(e=>{let t=c.get(e);return t?[{id:e,title:s?iz(t,s):``}]:[]});t[i.id]={text:l.map(e=>e.title).join(`, `),value:o,links:l}}for(let o of i){let i=o.rollup,s=r.find(e=>e.id===i.relation),c=s?a.get(s.id):null;if(!s||!c){t[o.id]={text:``,value:null};continue}let l=new Map(c.rows.map(e=>[e.id,e])),u=wz(e,s,c).flatMap(e=>{let t=l.get(e);return t?[t]:[]}),d=i.property?c.columns.find(e=>e.id===i.property)??null:c.columns.find(e=>e.type===`title`)??null;t[o.id]=Dz(i.fn,u,d,n)}return{...e,computed:t}});return{...e,rows:o}}function I(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))if(n!=null&&n!==!1){if(e===`class`)r.className=String(n);else if(e===`on`)for(let[e,t]of Object.entries(n))r.addEventListener(e,t);else e===`dataset`?Object.assign(r.dataset,n):e===`style`?Object.assign(r.style,n):e in r&&typeof n!=`string`?r[e]=n:r.setAttribute(e,n===!0?``:String(n))}for(let e of n.flat())e!=null&&e!==!1&&r.append(e);return r}function kz(e,t=16){return Hj(e,t)}function Az(e,t,n,r){let i=I(`button`,{type:`button`,class:r?`dw-db__btn`:`dw-db__btn dw-db__btn--icon`,title:t,"aria-label":t},kz(e,15),r?I(`span`,{},r):null);return i.addEventListener(`click`,e=>{e.preventDefault(),n(e)}),i}var jz=null;function Mz(e,t,n={}){jz?.close();let r=I(`div`,{class:`dw-db-pop ${n.class??``}`,role:`dialog`,"aria-label":n.label}),i=!1,a=()=>{i||(i=!0,c(),r.remove(),document.removeEventListener(`mousedown`,o,!0),document.removeEventListener(`keydown`,s,!0),jz?.box===r&&(jz=null),n.onClose?.())},o=t=>{let n=t.target;r.contains(n)||e.contains(n)||n instanceof Element&&n.closest(`.dw-block-menu`)||a()},s=t=>{t.key===`Escape`&&!document.querySelector(`.dw-block-menu`)&&(t.preventDefault(),t.stopPropagation(),a(),e instanceof HTMLElement&&e.focus())};document.body.append(r);let c=jj(e,r,()=>{Fj(e,r,{placement:n.placement??`bottom-start`,strategy:`fixed`,middleware:[Mj(4),Pj(),Nj({padding:8})]}).then(({x:e,y:t})=>Object.assign(r.style,{left:`${e}px`,top:`${t}px`}))});return document.addEventListener(`mousedown`,o,!0),document.addEventListener(`keydown`,s,!0),t(r,a),jz={box:r,close:a},jz}function Nz(){jz?.close()}function Pz(e,t){let n=I(`input`,{type:t.type??`text`,class:t.class??`dw-db-input`,placeholder:t.placeholder,"aria-label":t.label??t.placeholder});n.value=e;let r=!1,i=()=>{r||(r=!0,t.onCommit(n.value))};return n.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(r=!0,t.onCancel?.())}),n.addEventListener(`blur`,i),n}function Fz(e,t,n){let r=URL.createObjectURL(new Blob([t],{type:n})),i=I(`a`,{href:r,download:e});document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function Iz(e){return new Promise(t=>{let n=I(`input`,{type:`file`,accept:e});n.onchange=()=>t(n.files?.[0]??null),n.click()})}function Lz(e,t){let n=e.read(t);return!n||!e.pointsHere?[]:n.columns.filter(n=>n.type===`relation`&&n.relation&&!n.relation.back&&e.pointsHere(t,n.relation))}var Rz=e=>`fn${e[0].toUpperCase()}${e.slice(1)}`,zz=(e,t)=>e[Rz(t)];function Bz(e,t,n,r){let i=I(`div`,{class:`dw-db-pop__item${t?` is-active`:``}`,role:`option`,"aria-selected":String(t)},I(`span`,{},e),r?I(`small`,{class:`dw-db-pop__sub`},r):null);return i.addEventListener(`mousedown`,e=>e.preventDefault()),i.addEventListener(`click`,n),i}function Vz(e,t,n,r){let i=e.store,a=e.linked;if(!i||!a)return;let o=e.labels;Mz(t,(t,r)=>{let s=n.relation,c=e=>{let c={page:e.page,database:e.database},l=Lz(a,c);if(!l.length)return i.setRelation(n.id,c),r();let u=!!s&&s.page===e.page&&s.database===e.database;t.replaceChildren(I(`div`,{class:`dw-db-pop__title`},e.title||o.untitled),I(`div`,{class:`dw-db-pop__list`,role:`listbox`},Bz(o.relationOneWay,u&&!s.back,()=>{i.setRelation(n.id,c),r()}),...l.map(e=>Bz(LR(o.relationMirror,e.name||o.typeRelation),u&&s.back===e.id,()=>{i.setRelation(n.id,{...c,back:e.id}),r()},o.relationTwoWay))))},l=I(`div`,{class:`dw-db-pop__list`,role:`listbox`});if((()=>{let e=a.local();l.replaceChildren(I(`div`,{class:`dw-db-pop__heading`},o.relationThisPage),...e.length?e.map(e=>Bz(e.title||o.untitled,!!s&&!s.page&&s.database===e.database,()=>c(e))):[I(`div`,{class:`dw-db-pop__empty`},o.relationNoDatabases)])})(),t.append(I(`div`,{class:`dw-db-pop__title`},o.relationPick),l),a.searchPages&&a.databasesOn){let e=I(`input`,{class:`dw-db-input`,placeholder:o.relationSearchPage,"aria-label":o.relationOtherPage}),n=I(`div`,{class:`dw-db-pop__list`,role:`listbox`}),r=0;e.addEventListener(`input`,async()=>{let t=e.value.trim(),i=++r;if(!t)return n.replaceChildren();let l=await a.searchPages(t).catch(()=>[]);i===r&&n.replaceChildren(...l.slice(0,8).map(e=>Bz(e.title||o.untitled,!1,async()=>{let t=await a.databasesOn(e.id).catch(()=>[]);i===r&&n.replaceChildren(I(`div`,{class:`dw-db-pop__heading`},e.title||o.untitled),...t.length?t.map(e=>Bz(e.title||o.untitled,s?.page===e.page&&s.database===e.database,()=>c(e))):[I(`div`,{class:`dw-db-pop__empty`},o.relationNoDatabases)])})))}),e.addEventListener(`keydown`,e=>e.stopPropagation()),t.append(I(`div`,{class:`dw-db-pop__heading`},o.relationOtherPage),e,n)}if(s&&!s.back&&a.addBack&&a.writable?.(s)){let i=a.read(s),c=i?.columns.some(e=>e.relation?.back===n.id&&a.pointsHere?.(s,e.relation));if(i&&!c){let c=I(`button`,{type:`button`,class:`dw-db__btn dw-db-pop__add`},kz(`plus`,14),I(`span`,{},LR(o.relationShowOn,i.title||o.untitled)));c.addEventListener(`click`,()=>{a.addBack(s,n.id,e.db.title||n.name||o.typeRelation),r()}),t.append(c)}}},{class:`dw-db-pop--choices`,label:o.relationTo,onClose:r})}function Hz(e,t,n,r,i){let a=e.store,o=e.labels,s=r.relation,c=s?e.linked?.read(s):null;if(!s||!c){if(t.append(I(`div`,{class:`dw-db-pop__empty`},s?o.relationMissing:o.relationPick)),!s&&e.linked){let n=I(`button`,{type:`button`,class:`dw-db__btn`},o.relationTo);n.addEventListener(`click`,()=>{i(),Vz(e,t,r)}),t.append(n)}return}let l=ZR(c),u=!!s.back,d=!u||!!e.linked?.writable?.(s),f=wz(n,r,c),p=I(`div`,{class:`dw-db-tags dw-db-pop__chosen`}),m=I(`input`,{class:`dw-db-input`,placeholder:o.searchRecords,"aria-label":o.linkRecord}),h=I(`div`,{class:`dw-db-pop__list`,role:`listbox`});t.append(p),d?t.append(m,h):t.append(I(`div`,{class:`dw-db-pop__empty`},o.relationBackReadOnly));let g=e=>iz(e,l)||o.untitledRow,_=t=>{if(!d)return;let i=!f.includes(t);if(u){if(!e.linked?.link?.(s,n.id,t,i))return}else a.setCell(n.id,r.id,i?[...f,t]:f.filter(e=>e!==t));f=i?[...f,t]:f.filter(e=>e!==t),b()},v=0,y=[],b=()=>{let e=new Map(c.rows.map(e=>[e.id,e]));p.replaceChildren(...f.flatMap(t=>{let n=e.get(t);if(!n)return[];let r=I(`span`,{class:`dw-db-tag`,dataset:{color:`gray`}},g(n));if(d){let e=I(`button`,{type:`button`,class:`dw-db-tag__x`,"aria-label":`×`},`×`);e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,()=>_(t)),r.append(e)}return[r]}));let t=m.value.trim().toLowerCase();y=c.rows.filter(e=>!t||g(e).toLowerCase().includes(t)).slice(0,50),v=Math.min(v,Math.max(0,y.length-1)),h.replaceChildren(...y.length?y.map((e,t)=>{let n=Bz(g(e),t===v,()=>_(e.id));return f.includes(e.id)&&n.prepend(I(`span`,{class:`dw-db-pop__check`},`✓`)),n}):[I(`div`,{class:`dw-db-pop__empty`},o.noRecords)])};m.addEventListener(`input`,()=>{v=0,b()}),m.addEventListener(`keydown`,e=>{if(e.stopPropagation(),e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),y.length&&(v=(v+(e.key===`ArrowDown`?1:-1)+y.length)%y.length),b();else if(e.key===`Enter`){e.preventDefault();let t=y[v];t&&_(t.id)}else e.key===`Escape`&&(e.preventDefault(),i())}),b(),d&&m.focus({preventScroll:!0})}function Uz(e,t,n,r){let i=e.store;if(!i)return;let a=e.labels;Mz(t,t=>{let r=e.db.columns.filter(e=>e.type===`relation`);if(!r.length){t.append(I(`div`,{class:`dw-db-pop__empty`},a.rollupNeedsRelation));return}let o=n.rollup??{relation:r[0].id,property:``,fn:`count`},s=(e,t,n,r)=>{let i=I(`select`,{class:`dw-db-input`,"aria-label":e});for(let[e,n]of t)i.append(I(`option`,{value:e},n));return i.value=n,i.addEventListener(`change`,()=>r(i.value)),I(`label`,{class:`dw-db-pop__field`},I(`span`,{},e),i)},c=()=>{let l=r.find(e=>e.id===o.relation)??r[0],u=l.relation?e.linked?.read(l.relation):null,d=[[``,a.rollupRecords]];for(let e of u?.columns??[])d.push([e.id,e.name||NR(a,e.type)]);let f=u?.columns.find(e=>e.id===o.property),p=Sz(f?f.type:``);p.includes(o.fn)||(o.fn=o.property?p[0]:`count`),t.replaceChildren(s(a.rollupRelation,r.map(e=>[e.id,e.name||a.typeRelation]),l.id,e=>{o.relation=e,o.property=``,o.fn=`count`,i.setRollup(n.id,{...o}),c()}),s(a.rollupProperty,d,o.property,e=>{o.property=e;let t=u?.columns.find(t=>t.id===e);o.fn=e?Sz(t?t.type:``)[0]:`count`,i.setRollup(n.id,{...o}),c()}),s(a.rollupFn,(o.property?p:[`count`,`showOriginal`]).map(e=>[e,zz(a,e)]),o.fn,e=>{o.fn=e,i.setRollup(n.id,{...o})}),u?I(`span`):I(`div`,{class:`dw-db-pop__empty`},a.relationMissing))};n.rollup||i.setRollup(n.id,{...o}),c()},{class:`dw-db-pop--choices`,label:a.rollupSettings,onClose:r})}function Wz(e,t,n){let r=t.computed?.[n.id],i=I(`span`,{class:`dw-db-tags`});if(r?.links&&n.relation){let t=n.relation;for(let n of r.links){let r=I(`button`,{type:`button`,class:`dw-db-tag dw-db-rel`,dataset:{color:`gray`},title:e.labels.openRelated},n.title||e.labels.untitledRow);r.addEventListener(`click`,r=>{r.stopPropagation(),e.linked?.openRecord(t,n.id)}),i.append(r)}}else r?.text&&i.append(I(`span`,{class:`dw-db-cell__text`},r.text));return i}var Gz={title:`text`,text:`type`,number:`sigma`,checkbox:`todo`,select:`tag`,multiSelect:`layers`,date:`calendar`,progress:`sliders`,link:`link`,attachment:`paperclip`,member:`users`,createdTime:`clock`,createdBy:`at`,relation:`relation`,rollup:`rollup`},Kz=[`title`,`text`,`number`,`link`],qz=[`createdTime`,`createdBy`,`rollup`];function Jz(e,t){let[n,r,i]=e.split(`-`).map(Number);return!n||!r||!i?e:new Date(n,r-1,i).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`})}function Yz(e,t,n){let r=I(`span`,{class:`dw-db-tag`,dataset:{color:t??`gray`}},e);if(n){let e=I(`button`,{type:`button`,class:`dw-db-tag__x`,"aria-label":`×`},`×`);e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,e=>{e.stopPropagation(),n()}),r.append(e)}return r}function Xz(e){try{let t=new URL(e.includes(`://`)?e:`https://${e}`);return t.protocol===`http:`||t.protocol===`https:`||t.protocol===`mailto:`?t.href:null}catch{return null}}function Zz(e,t,n){let r=QR(t,n),i=e.labels;switch(n.type){case`title`:{let e=typeof r==`string`?r:``;return I(`span`,{class:e?`dw-db-cell__title`:`dw-db-cell__title is-empty`},e||i.untitledRow)}case`text`:return I(`span`,{class:`dw-db-cell__text`},typeof r==`string`?r:``);case`number`:{let t=nz(r);return I(`span`,{class:`dw-db-cell__number`},t===null?``:t.toLocaleString(e.locale))}case`checkbox`:return I(`span`,{class:r===!0?`dw-db-check is-on`:`dw-db-check`,role:`img`,"aria-label":r===!0?i.checked:i.unchecked},r===!0?kz(`check`,13):null);case`select`:{let e=n.options?.find(e=>e.id===r);return I(`span`,{class:`dw-db-tags`},e?Yz(e.name,e.color):null)}case`multiSelect`:return I(`span`,{class:`dw-db-tags`},rz(r).flatMap(e=>{let t=n.options?.find(t=>t.id===e);return t?[Yz(t.name,t.color)]:[]}));case`date`:case`createdTime`:{let t=ez(r);return I(`span`,{class:`dw-db-cell__text`},t?Jz(t,e.locale):``)}case`progress`:{let e=nz(r);if(e===null)return I(`span`);let t=Math.max(0,Math.min(100,e));return I(`span`,{class:`dw-db-progress`},I(`span`,{class:`dw-db-progress__bar`},I(`span`,{class:`dw-db-progress__fill`,style:{width:`${t}%`}})),I(`span`,{class:`dw-db-progress__num`},`${t}%`))}case`link`:{let e=typeof r==`string`?r:``,t=e?Xz(e):null;if(!t)return I(`span`,{class:`dw-db-cell__text`},e);let n=I(`a`,{class:`dw-db-cell__link`,href:t,target:`_blank`,rel:`noopener noreferrer`},e);return n.addEventListener(`click`,e=>{!e.ctrlKey&&!e.metaKey&&e.preventDefault()}),n}case`attachment`:return I(`span`,{class:`dw-db-tags`},rz(r).map(t=>{let n=I(`a`,{class:`dw-db-file`,href:e.files?e.files.resolve(t.src):t.src,target:`_blank`,rel:`noopener noreferrer`},kz(`paperclip`,12),t.name);return n.addEventListener(`click`,e=>{!e.ctrlKey&&!e.metaKey&&e.preventDefault()}),n}));case`member`:case`createdBy`:return I(`span`,{class:`dw-db-tags`},rz(r).map(e=>I(`span`,{class:`dw-db-person`},I(`span`,{class:`dw-db-person__dot`},(e?.name||`?`).slice(0,1).toUpperCase()),e?.name??``)));case`relation`:return Wz(e,t,n);case`rollup`:{let r=t.computed?.[n.id],i=r?.value;return typeof i==`number`?I(`span`,{class:`dw-db-cell__number`},/^-?\d+(\.\d+)?%?$/.test(r.text)?i.toLocaleString(e.locale,{maximumFractionDigits:2})+(r.text.endsWith(`%`)?`%`:``):r.text):I(`span`,{class:`dw-db-cell__text`},r?.text??``)}}}function Qz(e,t,n,r,i){let a=e.store;if(!a||qz.includes(r.type))return i.onDone();let o=QR(n,r);if(r.type===`checkbox`)return a.setCell(n.id,r.id,o!==!0),i.onDone();e.setEditing(!0);let s=t=>{e.setEditing(!1),i.onDone(t)};if(Kz.includes(r.type)){let e=i.initial??(r.type===`number`?nz(o)?.toString()??``:typeof o==`string`?o:``),c,l=Pz(e,{class:`dw-db-cell__input`,type:(r.type,`text`),label:r.name,onCommit:e=>{let t=e.trim(),i=r.type===`number`?nz(t):r.type===`title`||r.type===`text`?e:t;i!==(o??null)&&(i!==``||o!==void 0)&&a.setCell(n.id,r.id,i),s(c)},onCancel:()=>s()});l.addEventListener(`keydown`,e=>{e.key===`Enter`&&(c=`down`),e.key===`Tab`&&(e.preventDefault(),c=e.shiftKey?`left`:`right`,l.blur())}),t.replaceChildren(l),t.classList.add(`is-editing`),l.focus(),i.initial===void 0?l.select():l.setSelectionRange(l.value.length,l.value.length);return}let c=(e,n=``)=>Mz(t,e,{class:n,onClose:()=>s(),label:r.name});switch(r.type){case`select`:case`multiSelect`:c((t,a)=>$z(e,t,n,r,a,i.initial),`dw-db-pop--choices`);break;case`date`:c((t,i)=>{let s=I(`input`,{type:`date`,class:`dw-db-input`,"aria-label":r.name});s.value=ez(o),s.addEventListener(`change`,()=>a.setCell(n.id,r.id,s.value||null)),s.addEventListener(`keydown`,e=>{e.key===`Enter`&&i()});let c=I(`button`,{type:`button`,class:`dw-db__btn`},e.labels.clear);c.addEventListener(`click`,()=>{a.setCell(n.id,r.id,null),i()});let l=I(`button`,{type:`button`,class:`dw-db__btn`},e.labels.today);l.addEventListener(`click`,()=>{let e=new Date;a.setCell(n.id,r.id,`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`),i()}),t.append(s,I(`div`,{class:`dw-db-pop__row`},l,c)),s.focus({preventScroll:!0})});break;case`progress`:c((e,t)=>{let i=nz(o)??0,s=I(`input`,{type:`range`,min:`0`,max:`100`,step:`1`,class:`dw-db-range`,"aria-label":r.name});s.value=String(i);let c=I(`span`,{class:`dw-db-progress__num`},`${i}%`);s.addEventListener(`input`,()=>c.textContent=`${s.value}%`),s.addEventListener(`change`,()=>a.setCell(n.id,r.id,Number(s.value))),s.addEventListener(`keydown`,e=>{e.key===`Enter`&&t()}),e.append(I(`div`,{class:`dw-db-pop__row`},s,c)),s.focus({preventScroll:!0})});break;case`member`:c((t,i)=>eB(e,t,n,r,i),`dw-db-pop--choices`);break;case`attachment`:c(t=>tB(e,t,n,r),`dw-db-pop--choices`);break;case`relation`:c((t,i)=>Hz(e,t,n,r,i),`dw-db-pop--choices`);break;default:s()}}function $z(e,t,n,r,i,a){let o=e.store,s=e.labels,c=r.type===`multiSelect`,l=[...r.options??[]],u=c?rz(QR(n,r)):[String(QR(n,r)??``)].filter(Boolean),d=0,f=I(`div`,{class:`dw-db-tags dw-db-pop__chosen`}),p=I(`input`,{class:`dw-db-input`,placeholder:s.searchOptions,"aria-label":s.searchOptions});p.value=a??``;let m=I(`div`,{class:`dw-db-pop__list`,role:`listbox`});t.append(f,p,m);let h=()=>o.setCell(n.id,r.id,c?u:u[0]??null),g=e=>{u=c?u.includes(e)?u.filter(t=>t!==e):[...u,e]:u[0]===e?[]:[e],h(),c?b():i()},_=e=>{let t={id:WR(),name:e,color:hz(l)};l=[...l,t],o.tx(()=>{o.setOptions(r.id,l),u=c?[...u,t.id]:[t.id],h()}),p.value=``,c?b():i()},v=(t,n)=>{Kj(t,[{id:`rename`,label:s.renameOption,icon:`pencil`,run:()=>{let e=window.prompt(s.renameOption,n.name)?.trim();e&&(l=l.map(t=>t.id===n.id?{...t,name:e}:t),o.setOptions(r.id,l),b())}},{id:`color`,label:s.optionColor,icon:`palette`,children:FP.map(t=>({id:t,label:e.colorNames[t]??t,icon:t===n.color?`check`:`drop`,run:()=>{l=l.map(e=>e.id===n.id?{...e,color:t}:e),o.setOptions(r.id,l),b()}}))},{id:`delete`,label:s.deleteOption,icon:`trash`,danger:!0,run:()=>{l=l.filter(e=>e.id!==n.id),u=u.filter(e=>e!==n.id),o.setOptions(r.id,l),b()}}],s.optionColor,()=>p.focus())},y=[];function b(){f.replaceChildren(...u.flatMap(e=>{let t=l.find(t=>t.id===e);return t?[Yz(t.name,t.color,()=>g(e))]:[]}));let e=p.value.trim();y=l.filter(t=>t.name.toLowerCase().includes(e.toLowerCase())).map(e=>({kind:`option`,o:e})),e&&!l.some(t=>t.name.toLowerCase()===e.toLowerCase())&&y.push({kind:`create`,name:e}),d=Math.min(d,Math.max(0,y.length-1)),m.replaceChildren(...y.map((e,t)=>{let n=I(`div`,{class:`dw-db-pop__item${t===d?` is-active`:``}`,role:`option`,"aria-selected":String(e.kind===`option`&&u.includes(e.o.id))});if(n.addEventListener(`mousedown`,e=>e.preventDefault()),e.kind===`option`){n.append(I(`span`,{class:`dw-db-pop__check`},u.includes(e.o.id)?kz(`check`,13):null),Yz(e.o.name,e.o.color));let t=I(`button`,{type:`button`,class:`dw-db__btn dw-db__btn--icon dw-db-pop__more`,"aria-label":s.optionColor},kz(`more`,14));t.addEventListener(`click`,n=>{n.stopPropagation(),v(t,e.o)}),n.append(t),n.addEventListener(`click`,()=>g(e.o.id))}else n.append(I(`span`,{class:`dw-db-pop__check`},kz(`plus`,13)),I(`span`,{},LR(s.createOption,e.name))),n.addEventListener(`click`,()=>_(e.name));return n}))}p.addEventListener(`input`,()=>{d=0,b()}),p.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),y.length&&(d=(d+(e.key===`ArrowDown`?1:-1)+y.length)%y.length),b();else if(e.key===`Enter`){e.preventDefault();let t=y[d];t?.kind===`option`?g(t.o.id):t?.kind===`create`?_(t.name):i()}else e.key===`Backspace`&&!p.value&&c&&u.length&&g(u[u.length-1])}),b(),p.focus({preventScroll:!0}),p.setSelectionRange(p.value.length,p.value.length)}function eB(e,t,n,r,i){let a=e.store,o=e.labels,s=rz(QR(n,r)).filter(e=>e?.id),c=I(`div`,{class:`dw-db-tags dw-db-pop__chosen`}),l=I(`input`,{class:`dw-db-input`,placeholder:o.searchPeople,"aria-label":o.searchPeople}),u=I(`div`,{class:`dw-db-pop__list`,role:`listbox`});t.append(c,l,u);let d=()=>a.setCell(n.id,r.id,s),f=()=>c.replaceChildren(...s.map(e=>Yz(e.name,`gray`,()=>{s=s.filter(t=>t.id!==e.id),d(),f()}))),p=0,m=[],h=0,g=()=>{u.replaceChildren(...m.length?m.map((e,t)=>{let n=I(`div`,{class:`dw-db-pop__item${t===h?` is-active`:``}`,role:`option`},I(`span`,{class:`dw-db-person__dot`},(e.name||`?`).slice(0,1).toUpperCase()),I(`span`,{},e.name));return n.addEventListener(`mousedown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>_(e)),n}):[I(`div`,{class:`dw-db-pop__empty`},l.value.trim()?o.noPeople:``)])},_=e=>{s.some(t=>t.id===e.id)||(s=[...s,e]),d(),l.value=``,m=[],f(),g()};l.addEventListener(`input`,async()=>{let t=l.value.trim(),n=++p,r=e.people&&t?await e.people.search(t).catch(()=>[]):[];n===p&&(m=r.slice(0,8).map(e=>({id:e.id,name:e.label})),h=0,g())}),l.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),m.length&&(h=(h+(e.key===`ArrowDown`?1:-1)+m.length)%m.length),g();else if(e.key===`Enter`){e.preventDefault();let t=m[h];t?_(t):i()}}),f(),g(),l.focus({preventScroll:!0})}function tB(e,t,n,r){let i=e.store,a=e.labels,o=rz(QR(n,r)).filter(e=>e?.src),s=I(`div`,{class:`dw-db-pop__list`}),c=()=>s.replaceChildren(...o.map((t,s)=>{let l=e.files?e.files.resolve(t.src):t.src,u=I(`button`,{type:`button`,class:`dw-db__btn dw-db__btn--icon`,"aria-label":a.remove,title:a.remove},kz(`trash`,14));return u.addEventListener(`click`,()=>{o=o.filter((e,t)=>t!==s),i.setCell(n.id,r.id,o),c()}),I(`div`,{class:`dw-db-pop__item`},I(`a`,{class:`dw-db-file`,href:l,target:`_blank`,rel:`noopener noreferrer`},kz(`paperclip`,12),t.name),u)}));t.append(s);let l=e.files?.upload;if(l){let s=I(`button`,{type:`button`,class:`dw-db__btn`},kz(`upload`,14),I(`span`,{},a.upload));s.addEventListener(`click`,()=>{let t=I(`input`,{type:`file`,multiple:!0});t.onchange=async()=>{for(let a of[...t.files??[]])try{let t=await l.call(e.files,a);o=[...o,{name:t.name,src:t.url,size:t.size,mime:t.mime}],i.setCell(n.id,r.id,o),c()}catch{}},t.click()}),t.append(I(`div`,{class:`dw-db-pop__row`},s))}c()}var nB=class{host;db;rowId;order;onClose;dom;panel;head=I(`div`,{class:`dw-db-peek__head`});props=I(`div`,{class:`dw-db-peek__props`});bodyEl=I(`div`,{class:`dw-db-peek__body`});unmount=null;editing=0;pending=!1;wide=!1;returnFocus;constructor(e,t,n,r,i){this.host=e,this.db=t,this.rowId=n,this.order=r,this.onClose=i,this.returnFocus=document.activeElement,this.panel=I(`div`,{class:`dw-db-peek__panel`,role:`dialog`,"aria-modal":`true`,tabIndex:-1},this.head,this.props,this.bodyEl),this.dom=I(`div`,{class:e.page?`dw-db-peek dw-db-peek--page`:`dw-db-peek`},this.panel),this.dom.addEventListener(`mousedown`,e=>{e.target===this.dom&&!this.host.page&&this.close()}),this.dom.addEventListener(`keydown`,e=>{e.key===`Escape`&&!document.querySelector(`.dw-db-pop, .dw-block-menu`)&&(e.preventDefault(),e.stopPropagation(),this.close())}),e.page?(this.panel.removeAttribute(`aria-modal`),this.panel.setAttribute(`role`,`region`),e.page.container.replaceChildren(this.dom)):document.body.append(this.dom),this.draw(!0),this.panel.focus({preventScroll:!0})}get row(){return this.rowId}ctx(){return{...this.host.ctx,db:this.db,openRow:e=>this.show(e),setEditing:e=>{this.editing=Math.max(0,this.editing+(e?1:-1)),!this.editing&&this.pending&&(this.pending=!1,this.draw(!1))}}}update(e,t){if(this.db=e,t&&(this.host={...this.host,ctx:{...this.host.ctx,...t}}),!e.rows.some(e=>e.id===this.rowId))return this.close();this.editing?this.pending=!0:this.draw(!1)}show(e){e!==this.rowId&&(this.rowId=e,this.draw(!0))}draw(e){let t=this.db.rows.find(e=>e.id===this.rowId);if(!t)return;let n=this.ctx(),r=n.labels,i=n.store;this.panel.classList.toggle(`is-wide`,this.wide);let a=this.order.indexOf(this.rowId),o=Az(`chevron-up`,r.previousRow,()=>this.show(this.order[a-1])),s=Az(`chevron-down`,r.nextRow,()=>this.show(this.order[a+1]));o.disabled=a<=0,s.disabled=a<0||a>=this.order.length-1;let c=this.host.page;this.head.replaceChildren(...c?[Az(`chevron-left`,r.backToPage,()=>this.close())]:[],I(`span`,{class:`dw-db-peek__db`},kz(`database`,14),this.db.title||r.untitled),I(`span`,{class:`dw-db-peek__grow`}),o,s,...c?[]:[Az((this.wide,`width`),this.wide?r.collapse:r.expand,()=>{this.wide=!this.wide,this.panel.classList.toggle(`is-wide`,this.wide)})],...this.host.openPage?[Az(`open`,r.openFullPage,()=>this.host.openPage(this.rowId))]:[],...this.host.copyLink?[Az(`link`,r.copyLink,()=>this.host.copyLink(this.rowId))]:[],...c?[]:[Az(`close`,r.close,()=>this.close())]);let l=ZR(this.db),u=String(QR(t,l)??``),d=i?(()=>{let e=I(`input`,{class:`dw-db-peek__title`,placeholder:r.untitledRow,"aria-label":l.name||r.typeTitle});return e.value=u,e.addEventListener(`focus`,()=>n.setEditing(!0)),e.addEventListener(`blur`,()=>{e.value!==u&&i.setCell(t.id,l.id,e.value),n.setEditing(!1)}),e.addEventListener(`keydown`,t=>{t.stopPropagation(),t.key===`Enter`&&e.blur()}),e})():I(`h2`,{class:`dw-db-peek__title`},u||r.untitledRow);this.panel.setAttribute(`aria-label`,u||r.untitledRow);let f=[d,...this.db.columns.filter(e=>e.type!==`title`).map(e=>{let a=I(`div`,{class:`dw-db-peek__value dw-db-t__cell--${e.type}`,tabIndex:i&&!qz.includes(e.type)?0:-1},Zz(n,t,e)),o=()=>{i&&Qz(n,a,t,e,{onDone:()=>this.draw(!1)})};return a.addEventListener(`click`,e=>{e.target.closest(`a, button`)||o()}),a.addEventListener(`keydown`,e=>{e.target===a&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())}),I(`div`,{class:`dw-db-peek__prop`},I(`div`,{class:`dw-db-peek__label`},kz(Gz[e.type],14),I(`span`,{},e.name||NR(r,e.type))),a)})];if(i){let e=Az(`plus`,r.addColumn,()=>Kj(e,HR.map(e=>({id:e,label:NR(r,e),icon:Gz[e],run:()=>i.addColumn(e,NR(r,e))})),r.addColumn),r.addColumn);e.classList.add(`dw-db-peek__add`),f.push(e)}let p=this.props.contains(document.activeElement);this.props.replaceChildren(...f),p&&this.panel.focus({preventScroll:!0}),e&&(this.unmount?.(),this.bodyEl.replaceChildren(),this.unmount=this.host.mountBody(this.bodyEl,t))}close(e=!0){this.unmount?.(),this.unmount=null,this.dom.remove(),this.onClose(),e&&this.host.page?.onLeave?.(),this.returnFocus instanceof HTMLElement&&this.returnFocus.isConnected&&this.returnFocus.focus({preventScroll:!0})}},rB=`docwell-database`,iB=e=>e.getMap(`blocks`);function aB(e){let t=new Bb;t.set(`title`,e.title);let n=(e,t)=>{let n=new Lb;return n.push(e.map((e,n)=>oB(t(e),n))),n};return t.set(`columns`,n(e.columns,sB)),t.set(`rows`,n(e.rows,cB)),t.set(`views`,n(e.views,lB)),t}function oB(e,t){return e.set(`pos`,t),e}function sB(e){let t=new Bb;return t.set(`id`,e.id),t.set(`name`,e.name),t.set(`type`,e.type),e.options&&t.set(`options`,e.options),e.relation&&t.set(`relation`,e.relation),e.rollup&&t.set(`rollup`,e.rollup),t}function cB(e){let t=new Bb;t.set(`id`,e.id),t.set(`createdAt`,e.createdAt),e.createdBy&&t.set(`createdBy`,e.createdBy);let n=new Bb;for(let[t,r]of Object.entries(e.cells))r!=null&&n.set(t,r);return t.set(`cells`,n),t}function lB(e){let t=new Bb;for(let[n,r]of Object.entries(e))t.set(n,r);return t}function uB(e){return e.toArray().filter(e=>e instanceof Bb).map((e,t)=>({m:e,p:dB(e,t),i:t})).sort((e,t)=>e.p-t.p||e.i-t.i).map(e=>e.m)}function dB(e,t){let n=e?.get(`pos`);return typeof n==`number`?n:t}function fB(e,t,n){let r=n?e.filter(e=>e!==n):e,i=Math.max(0,Math.min(t,r.length)),a=i>0?dB(r[i-1],i-1):null,o=i{let n=e.get(t);return n instanceof Lb?uB(n):[]},n=e=>{let t=e.toJSON();return delete t.pos,t},r=new Set,i=t(`rows`).map(e=>{let t=e.get(`cells`),n=e.get(`body`),i=e.get(`id`);return typeof i==`string`&&n instanceof sx&&n.length>0&&r.add(i),{id:i,createdAt:e.get(`createdAt`),createdBy:e.get(`createdBy`),cells:t instanceof Bb?t.toJSON():{}}}),a=qR({title:e.get(`title`),columns:t(`columns`).map(n),rows:i,views:t(`views`).map(n)});for(let e of a.rows)r.has(e.id)&&(e.hasBody=!0);return a}function mB(e,t=``){let n=[{id:WR(),name:e.columnName(`title`),type:`title`},{id:WR(),name:e.columnName(`select`),type:`select`,options:[]}],r=Date.now();return{title:t,columns:n,rows:[0,1,2].map(e=>({id:WR(),cells:{},createdAt:r+e,createdBy:null})),views:[GR(`table`,e.tableView,n)]}}var hB=e=>e==null||e===``||Array.isArray(e)&&!e.length,gB=class{doc;map;me;constructor(e,t,n){this.doc=e,this.map=t,this.me=n}snapshot(){return pB(this.map)}observe(e){let t=()=>e();return this.map.observeDeep(t),()=>this.map.unobserveDeep(t)}tx(e){this.doc.transact(e,rB)}list(e){let t=this.map.get(e);return t instanceof Lb||(t=new Lb,this.map.set(e,t)),t}find(e,t){let n=uB(this.list(e)),r=n.findIndex(e=>e.get(`id`)===t);return r<0?null:{item:n[r],index:r}}insertAt(e,t,n){let r=this.list(e),i=uB(r),a=Math.max(0,Math.min(t??i.length,i.length));for(let e of n)e.set(`pos`,fB(i,a)),i.splice(a++,0,e);r.push(n)}moveTo(e,t,n){let r=this.find(e,t);r&&r.index!==n&&r.item.set(`pos`,fB(uB(this.list(e)),n,r.item))}remove(e,t){let n=this.list(e),r=n.toArray().indexOf(t);r>=0&&n.delete(r,1)}setTitle(e){this.tx(()=>this.map.set(`title`,e))}addColumn(e,t,n){let r={id:WR(),name:t,type:e};return(e===`select`||e===`multiSelect`)&&(r.options=[]),this.tx(()=>this.insertAt(`columns`,n,[sB(r)])),r.id}renameColumn(e,t){this.tx(()=>this.find(`columns`,e)?.item.set(`name`,t))}setRelation(e,t){this.tx(()=>{let n=this.find(`columns`,e);if(!n)return;let r=n.item.get(`relation`);if(n.item.set(`relation`,t),t.back||r&&(r.page!==t.page||r.database!==t.database))for(let t of this.list(`rows`).toArray()){let n=t.get(`cells`);n instanceof Bb&&n.delete(e)}})}setRollup(e,t){this.tx(()=>this.find(`columns`,e)?.item.set(`rollup`,t))}setOptions(e,t){this.tx(()=>this.find(`columns`,e)?.item.set(`options`,t))}changeType(e,t){let n=this.snapshot(),r=n.columns.find(t=>t.id===e);if(!r||r.type===t||r.type===`title`||t===`title`)return;let i=t===`select`||t===`multiSelect`?r.options??[]:[],a=new Map;for(let o of n.rows){let n=gz(o.cells[e],r,t,i);i=n.options,a.set(o.id,n.value)}this.tx(()=>{let n=this.find(`columns`,e);if(n){n.item.set(`type`,t),t===`select`||t===`multiSelect`?n.item.set(`options`,i):n.item.delete(`options`),t!==`relation`&&n.item.delete(`relation`),t!==`rollup`&&n.item.delete(`rollup`);for(let t of this.list(`rows`).toArray()){let n=t.get(`cells`);if(!(n instanceof Bb))continue;let r=a.get(String(t.get(`id`)));hB(r)||r===!1?n.delete(e):n.set(e,r)}}})}deleteColumn(e){this.tx(()=>{let t=this.find(`columns`,e);if(t&&t.item.get(`type`)!==`title`){this.remove(`columns`,t.item);for(let t of this.list(`rows`).toArray()){let n=t.get(`cells`);n instanceof Bb&&n.delete(e)}}})}moveColumn(e,t){this.tx(()=>this.moveTo(`columns`,e,t))}duplicateColumn(e,t){let n=this.snapshot().columns.find(t=>t.id===e);if(!n||n.type===`title`)return null;let r={...structuredClone(n),id:WR(),name:t};return this.tx(()=>{let t=this.find(`columns`,e);if(t){this.insertAt(`columns`,t.index+1,[sB(r)]);for(let t of this.list(`rows`).toArray()){let n=t.get(`cells`);n instanceof Bb&&n.has(e)&&n.set(r.id,n.get(e))}}}),r.id}addRow(e={},t){return this.addRows([e],t)[0]}addRows(e,t){let n=this.me(),r=Date.now(),i=e.map((e,t)=>({id:WR(),cells:e,createdAt:r+t,createdBy:n}));return this.tx(()=>this.insertAt(`rows`,t,i.map(cB))),i.map(e=>e.id)}setCell(e,t,n){this.setCells([{row:e,col:t,value:n}])}setCells(e){this.tx(()=>{for(let{row:t,col:n,value:r}of e){let e=this.find(`rows`,t)?.item.get(`cells`);e instanceof Bb&&(hB(r)?e.delete(n):e.set(n,r))}})}deleteRows(e){this.tx(()=>{let t=this.list(`rows`);for(let n=t.length-1;n>=0;n--)e.includes(String(t.get(n)?.get(`id`)))&&t.delete(n,1)})}moveRow(e,t){this.tx(()=>this.moveTo(`rows`,e,t))}duplicateRow(e){let t=this.find(`rows`,e);if(!t)return null;let n=_B(t.item,this.me());return this.tx(()=>this.insertAt(`rows`,t.index+1,[n])),String(n.get(`id`))}rowBody(e){let t=this.find(`rows`,e);if(!t)return null;let n=t.item.get(`body`);if(n instanceof sx)return n;let r=new sx;return this.tx(()=>t.item.set(`body`,r)),r}rowIndex(e){return this.find(`rows`,e)?.index??-1}addView(e,t){let n=GR(e,t,this.snapshot().columns);return this.tx(()=>this.insertAt(`views`,void 0,[lB(n)])),n.id}updateView(e,t){this.tx(()=>{let n=this.find(`views`,e);if(n)for(let[e,r]of Object.entries(t))n.item.set(e,r)})}duplicateView(e,t){let n=this.snapshot().views.find(t=>t.id===e);if(!n)return null;let r={...structuredClone(n),id:WR(),name:t};return this.tx(()=>{let t=this.find(`views`,e);this.insertAt(`views`,(t?.index??-1)+1,[lB(r)])}),r.id}deleteView(e){this.tx(()=>{let t=this.find(`views`,e);t&&this.list(`views`).length>1&&this.remove(`views`,t.item)})}moveView(e,t){this.tx(()=>this.moveTo(`views`,e,t))}};function _B(e,t){let n=new Bb;n.set(`id`,WR()),n.set(`createdAt`,Date.now());let r=t??e.get(`createdBy`);XR(r)&&n.set(`createdBy`,r);let i=new Bb,a=e.get(`cells`);if(a instanceof Bb)for(let[e,t]of a.entries())i.set(e,t);n.set(`cells`,i);let o=e.get(`body`);if(o instanceof sx&&o.length){let e=new sx;e.insert(0,o.toArray().map(e=>e.clone())),n.set(`body`,e)}return n}function vB(e,t){let n=pB(e),r=e.get(`rows`);if(r instanceof Lb){let e=new Map;for(let t of r.toArray()){let n=t.get(`body`);n instanceof sx&&n.length&&e.set(String(t.get(`id`)),n)}for(let r of n.rows){let n=e.get(r.id);n&&(r.body=t(n))}}return n}function yB(e,t,n,r){e.transact(()=>{let i=aB(n);iB(e).set(t,i);let a=i.get(`rows`),o=new Map(n.rows.map(e=>[e.id,e]));for(let e of a.toArray()){let t=o.get(String(e.get(`id`)))?.body;if(!t?.length)continue;let n=new sx;e.set(`body`,n),r(t,n)}},rB)}function bB(e,t=`,`){let n=[],r=[],i=``,a=!1,o=0,s=e.replace(/^\uFEFF/,``);for(;oe.map(e=>mB(e,t)).join(t)).join(`\r -`)}function gB(e,t,n){return hB([t.map(e=>e.name),...n.map(e=>t.map(t=>ZR(e,t)))])}function _B(e){let t=e.map(e=>e.trim()).filter(Boolean);if(!t.length)return`text`;if(t.every(e=>YR(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 vB(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:LR(),name:e,color:cz(n)},n.push(t)),t.id};switch(t.type){case`number`:return YR(r);case`progress`:{let e=YR(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 qR(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 yB(e,t=`,`){let n=pB(e,t).filter(e=>e.some(e=>e.trim())),r=n[0]??[],i=n.slice(1),a=r.map((e,t)=>({id:LR(),name:e.trim()||`${t+1}`,type:t===0?`title`:_B(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=vB(e[r]??``,n,n.options??[]);i!==null&&(!Array.isArray(i)||i.length)&&(t[n.id]=i)}),t})}}function bB(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 xB(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 SB=e=>e.map(e=>({value:e.id,label:e.name||`…`}));function CB(e,t,n,r){let i=e.labels;if(!$R(n.op))return null;if(t.type===`select`||t.type===`multiSelect`)return xB(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 wB(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(xB(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=QR(l.type),d=I(`div`,{class:`dw-db-pop__line`},xB(n.column,SB(a),i.filter,e=>{let t=a.find(t=>t.id===e);o[r]={column:e,op:QR(t.type)[0]},s(),c()}),xB(n.op,u.map(e=>({value:e,label:OR(i,e)})),i.filter,e=>{o[r]={...n,op:e},$R(e)||delete o[r].value,s(),c()}),CB(e,l,n,e=>{o[r]={...o[r],value:e},s()}),kB(i.remove,()=>{o.splice(r,1),s(),c()}));t.append(d)}),r&&t.append(AB(i.addFilter,()=>{let e=a.find(e=>e.type!==`title`)??a[0];o.push({column:e.id,op:QR(e.type)[0]}),s(),c()}))};c()}function TB(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`},xB(e.column,SB(a),i.sort,t=>{o[n]={...e,column:t},s()}),xB(e.desc?`desc`:`asc`,[{value:`asc`,label:i.ascending},{value:`desc`,label:i.descending}],i.sort,t=>{o[n]={...e,desc:t===`desc`},s()}),kB(i.remove,()=>{o.splice(n,1),s(),c()})))}),r&&t.append(AB(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 EB(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>zR.includes(e.type)),o=a.map(e=>({value:e.id,label:e.name||ER(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`?xB(n.groupBy??``,o,i.groupBy,e=>r?.updateView(n.id,{groupBy:e||null})):I(`p`,{class:`dw-db-pop__empty`},i.noGroupColumn))}function DB(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?xB(n.dateColumn??``,[{value:``,label:`—`},...a.map(e=>({value:e.id,label:e.name||ER(i,e.type)}))],i.dateColumn,e=>r?.updateView(n.id,{dateColumn:e||null})):I(`p`,{class:`dw-db-pop__empty`},i.noDateColumn))}function OB(e,t,n){let r=e.store,i=e.labels,a=[...n.hidden],o=()=>r?.updateView(n.id,{hidden:a}),s=()=>{t.replaceChildren();let n=e.db.columns.filter(e=>e.type!==`title`);if(r&&n.length){let e=I(`button`,{type:`button`,class:`dw-db__btn`},a.length?i.showAll:i.hideAll);e.addEventListener(`click`,()=>{a=a.length?[]:n.map(e=>e.id),o(),s()}),t.append(I(`div`,{class:`dw-db-pop__row dw-db-pop__row--end`},e))}for(let n of e.db.columns){let e=n.type===`title`||!a.includes(n.id),c=I(`button`,{type:`button`,class:`dw-db-pop__item`,role:`switch`,"aria-checked":String(e),disabled:n.type===`title`||!r},I(`span`,{class:`dw-db-pop__check`},Sz(Rz[n.type],14)),I(`span`,{class:`dw-db-pop__grow`},n.name||ER(i,n.type)),I(`span`,{class:e?`dw-db-switch is-on`:`dw-db-switch`}));c.addEventListener(`click`,()=>{a=e?[...a,n.id]:a.filter(e=>e!==n.id),o(),s()}),t.append(c)}};s()}function kB(e,t){let n=I(`button`,{type:`button`,class:`dw-db__btn dw-db__btn--icon`,"aria-label":e,title:e},Sz(`close`,14));return n.addEventListener(`click`,t),n}function AB(e,t){let n=I(`button`,{type:`button`,class:`dw-db__btn dw-db-pop__add`},Sz(`plus`,14),I(`span`,{},e));return n.addEventListener(`click`,t),n}var jB=6,MB=48;function NB(e,t){e.classList.add(`dw-db-touch-handle`);let n=!1,r=-1,i=0,a=0,o=0,s=0,c=0,l=null,u=null,d=0,f,p=0,m=()=>document.elementFromPoint(o,s),h=()=>{clearTimeout(f),cancelAnimationFrame(d),u&&(u.remove(),u=null,t.end()),t.source.classList.remove(`is-held`,`is-dragging`),n=!1,r=-1,p=Date.now()},g=()=>{if(!u)return;let e=oinnerWidth-MB),n=sinnerHeight-MB),r=!1;for(let[i,a]of[[`x`,e],[`y`,n]]){if(!a)continue;let e=PB(t.source,i)??(i===`y`?document.scrollingElement:null);if(!e)continue;let n=i===`x`?`scrollLeft`:`scrollTop`,o=e[n];e[n]+=a*12,r||=e[n]!==o}r&&t.over(m(),o,s),d=requestAnimationFrame(g)},_=e=>[...e.changedTouches].find(e=>e.identifier===r);e.addEventListener(`touchstart`,u=>{if(n||u.touches.length!==1)return;let d=u.changedTouches[0],p=u.target.closest(`input, textarea, select, [contenteditable='true']`);p&&e.contains(p)||(u.preventDefault(),n=!0,r=d.identifier,i=o=d.clientX,a=s=d.clientY,c=Date.now(),l=u.target,f=setTimeout(()=>{t.source.classList.add(`is-held`),navigator.vibrate?.(10)},500))},{passive:!1}),e.addEventListener(`touchmove`,e=>{let r=n&&_(e);if(r){if(e.preventDefault(),o=r.clientX,s=r.clientY,!u){if(Math.hypot(o-i,s-a)<=jB)return;clearTimeout(f),t.source.classList.remove(`is-held`),u=t.ghost();let e=t.source.getBoundingClientRect();Object.assign(u.style,{position:`fixed`,left:`${e.left}px`,top:`${e.top}px`,width:`${Math.max(80,Math.min(e.width,innerWidth-Math.max(e.left,0)-8))}px`,margin:`0`,pointerEvents:`none`,zIndex:`1000`}),u.classList.add(`dw-db-ghost`),document.body.append(u),t.source.classList.add(`is-dragging`),d=requestAnimationFrame(g)}u.style.transform=`translate(${o-i}px, ${s-a}px)`,t.over(m(),o,s)}},{passive:!1}),e.addEventListener(`touchend`,e=>{if(!n||!_(e))return;e.preventDefault();let r=u!==null,i=Date.now()-c>=500,a=l;r&&t.drop(m(),o,s),h(),r||(i&&t.hold?t.hold():a instanceof HTMLElement&&a.click())}),e.addEventListener(`touchcancel`,e=>{n&&_(e)&&h()});for(let t of[`contextmenu`,`dragstart`])e.addEventListener(t,e=>{(n||Date.now()-p<800)&&(e.preventDefault(),e.stopPropagation())},!0)}function PB(e,t){for(let n=e.parentElement;n;n=n.parentElement){let e=getComputedStyle(n),r=t===`x`?e.overflowX:e.overflowY;if((t===`x`?n.scrollWidth>n.clientWidth:n.scrollHeight>n.clientHeight)&&(r===`auto`||r===`scroll`))return n}return null}var FB=200,IB=class{host;dom=I(`div`,{class:`dw-db`,dataset:{type:`database`},contentEditable:`false`});db;viewId=null;search=``;editing=0;pending=!1;limit=FB;collapsed=new Set;sel=null;anchor=null;picked=new Set;month;titleEl=I(`div`,{class:`dw-db__title`});tabs=I(`div`,{class:`dw-db__tabs`,role:`tablist`});tools=I(`div`,{class:`dw-db__tools`});body=I(`div`,{class:`dw-db__body`});bulk=I(`div`,{class:`dw-db__bulk`});searchInput;buttons;constructor(e,t){this.host=e,this.db=t;let n=new Date;this.month={y:n.getFullYear(),m:n.getMonth()};let r=e.labels;this.searchInput=I(`input`,{class:`dw-db-input dw-db__search`,placeholder:r.search,"aria-label":r.search,hidden:!0}),this.searchInput.addEventListener(`input`,()=>{this.search=this.searchInput.value,this.limit=FB,this.drawBody()}),this.searchInput.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Escape`&&(this.searchInput.value=``,this.search=``,this.searchInput.hidden=!0,this.drawBody())}),this.buttons={search:Cz(`search`,r.search,()=>{this.searchInput.hidden=!this.searchInput.hidden,this.searchInput.hidden||this.searchInput.focus()}),filter:Cz(`filter`,r.filter,e=>this.panel(e,`filter`),r.filter),sort:Cz(`sort`,r.sort,e=>this.panel(e,`sort`),r.sort),group:Cz(`layers`,r.group,e=>this.panel(e,`group`),r.group),props:Cz(`sliders`,r.properties,e=>this.panel(e,`props`)),more:Cz(`more`,r.more,()=>this.moreMenu()),add:Cz(`plus`,r.newRow,()=>this.addRow(),r.newRow)},this.buttons.add.classList.add(`dw-db__btn--primary`);let i=I(`div`,{class:`dw-db__head`},this.titleEl),a=I(`div`,{class:`dw-db__bar`},this.tabs,this.tools);this.tools.append(this.searchInput,this.buttons.search,this.buttons.filter,this.buttons.sort,this.buttons.group,this.buttons.props,this.buttons.more,this.buttons.add),this.dom.append(i,a,this.bulk,this.body),this.draw()}get labels(){return this.host.labels}get editable(){return!!this.host.store}get view(){return this.db.views.find(e=>e.id===this.viewId)??this.db.views[0]??LB}ctx(){return{...this.host,db:this.db,openRow:e=>this.openRow(e),setEditing:e=>{this.editing=Math.max(0,this.editing+(e?1:-1)),!this.editing&&this.pending&&(this.pending=!1,this.draw())}}}update(e,t){this.db=e,t&&(this.host={...this.host,...t}),this.editing?this.pending=!0:this.draw()}destroy(){Ez()}draw(){this.drawTitle(),this.drawTabs(),this.drawTools(),this.drawBody()}drawTitle(){let e=this.labels,t=this.db.title;if(this.titleEl.querySelector(`input`)===document.activeElement)return;if(!this.editable){this.titleEl.replaceChildren(I(`span`,{class:t?``:`is-empty`},t||e.untitled));return}let n=I(`input`,{class:`dw-db__title-input`,placeholder:e.untitled,"aria-label":e.untitled});n.value=t,n.addEventListener(`keydown`,e=>{e.stopPropagation(),(e.key===`Enter`||e.key===`Escape`)&&n.blur()}),n.addEventListener(`change`,()=>this.host.store?.setTitle(n.value)),this.titleEl.replaceChildren(n)}drawTabs(){let e=this.labels,t=this.view;if(this.tabs.replaceChildren(...this.db.views.map(n=>{let r=I(`button`,{type:`button`,class:n.id===t.id?`dw-db__tab is-active`:`dw-db__tab`,role:`tab`,"aria-selected":String(n.id===t.id)},Sz(n.type===`kanban`?`cards`:n.type===`calendar`?`calendar`:`table`,14),I(`span`,{},n.name||kR(e,n.type)));return r.addEventListener(`click`,()=>{if(n.id===t.id&&this.editable)return this.viewMenu(r,n);this.viewId=n.id,this.sel=null,this.limit=FB,this.draw()}),r.addEventListener(`contextmenu`,e=>{this.editable&&(e.preventDefault(),this.viewMenu(r,n))}),r})),this.editable){let t=Cz(`plus`,e.addView,()=>Jj(t,IR.map(t=>({id:t,label:kR(e,t),icon:t===`kanban`?`cards`:t===`calendar`?`calendar`:`table`,run:()=>{this.showView(this.host.store.addView(t,kR(e,t)))}})),e.addView));this.tabs.append(t)}}drawTools(){let e=this.view,t=this.buttons,n=(e,t)=>{e.classList.toggle(`is-on`,t>0);let n=e.querySelector(`span`);n&&(n.textContent=t?`${e.title} ${t}`:e.title)};n(t.filter,e.filters.length),n(t.sort,e.sorts.length),t.sort.hidden=e.type===`calendar`,t.group.classList.toggle(`is-on`,!!e.groupBy&&e.type===`table`),t.group.hidden=e.type===`calendar`,t.add.hidden=!this.editable,this.drawBulk()}drawBulk(){let e=[...this.picked].filter(e=>this.db.rows.some(t=>t.id===e));if(this.picked=new Set(e),this.bulk.hidden=!e.length||!this.editable,this.bulk.hidden)return this.bulk.replaceChildren();let t=this.labels;this.bulk.replaceChildren(I(`span`,{},AR(t.selected,e.length)),Cz(`trash`,t.deleteRows,()=>{this.host.store?.deleteRows(e),this.picked.clear()},t.deleteRows),Cz(`close`,t.close,()=>{this.picked.clear(),this.draw()}))}panel(e,t){let n=e.currentTarget;Tz(n,e=>{let n=this.ctx(),r=this.view;t===`filter`?wB(n,e,r):t===`sort`?TB(n,e,r):t===`group`?EB(n,e,r):(r.type===`calendar`&&DB(n,e,r),r.type===`kanban`&&EB(n,e,r),OB(n,e,r))},{class:`dw-db-pop--panel`,label:n.title,placement:`bottom-end`})}viewMenu(e,t){let n=this.labels,r=this.host.store,i=[{id:`rename`,label:n.renameView,icon:`pencil`,run:()=>{let e=window.prompt(n.viewName,t.name)?.trim();e&&r.updateView(t.id,{name:e})}},{id:`layout`,label:n.layout,icon:`grid`,children:IR.map(e=>({id:e,label:kR(n,e),icon:e===t.type?`check`:e===`kanban`?`cards`:e===`calendar`?`calendar`:`table`,run:()=>this.setLayout(t,e)}))},{id:`duplicate`,label:n.duplicateView,icon:`copy`,run:()=>{this.showView(r.duplicateView(t.id,`${t.name||kR(n,t.type)} 2`))}}];this.db.views.length>1&&i.push({id:`delete`,label:n.deleteView,icon:`trash`,danger:!0,run:()=>r.deleteView(t.id)}),Jj(e,i,n.layout)}showView(e){e&&(this.viewId=e,this.sel=null,this.limit=FB,this.draw())}setLayout(e,t){let n={type:t},r=this.db.columns;t===`kanban`&&!e.groupBy&&(n.groupBy=r.find(e=>[`select`,`multiSelect`,`checkbox`,`member`].includes(e.type))?.id??null),t===`calendar`&&!e.dateColumn&&(n.dateColumn=r.find(e=>e.type===`date`)?.id??null),t===`calendar`&&!n.dateColumn&&!e.dateColumn&&this.host.store&&(n.dateColumn=this.host.store.addColumn(`date`,this.labels.typeDate)),this.host.store?.updateView(e.id,n)}moreMenu(){let e=this.labels,t=this.view,n=[{id:`csv`,label:e.exportCsv,icon:`download`,run:()=>{let n=rz(this.db,t);Oz(`${(this.db.title||e.untitled).replace(/[\\/:*?"<>|]+/g,` `).trim()}.csv`,`\uFEFF${gB(this.db,n,nz(this.db,t,this.search))}`,`text/csv`)}}];this.editable&&(n.push({id:`import`,label:e.importCsv,icon:`upload`,run:()=>void this.importCsv()}),n.push({id:`view`,label:e.layout,icon:`grid`,run:()=>this.viewMenu(this.buttons.more,t)})),Jj(this.buttons.more,n,e.more)}async importCsv(){let e=this.host.store,t=await kz(`.csv,text/csv,.tsv,text/tab-separated-values`);if(!e||!t)return;let n=await t.text(),r=t.name.endsWith(`.tsv`)?` `:`,`,i=pB(n,r).filter(e=>e.some(e=>e.trim()));i.length<2||e.tx(()=>{if(this.db.rows.every(e=>!ZR(e,WR(this.db)))){let t=yB(n,r);e.deleteRows(this.db.rows.map(e=>e.id));let i=WR(this.db),[a,...o]=t.columns,s=new Map;a&&(e.renameColumn(i.id,a.name),s.set(a.id,i.id));for(let t of o){let n=this.db.columns.find(e=>e.name.toLowerCase()===t.name.toLowerCase()&&e.type!==`title`);n&&e.deleteColumn(n.id);let r=e.addColumn(t.type,t.name);t.options&&e.setOptions(r,t.options),s.set(t.id,r)}e.addRows(t.rows.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[s.get(e)??e,t])))),this.host.notify?.(AR(this.labels.imported,t.rows.length));return}let{index:t,missing:a}=bB(i[0],this.db.columns),o=new Map(a.map(t=>[t,e.addColumn(`text`,t)])),s=i[0].map((e,n)=>{let r=t[n];if(r)return r;let i=o.get(e.trim());return i?{id:i,name:e,type:`text`}:null}),c=new Map(this.db.columns.map(e=>[e.id,[...e.options??[]]])),l=i.slice(1).map(e=>{let t={};return s.forEach((n,r)=>{if(!n)return;let i=vB(e[r]??``,n,c.get(n.id)??[]);i!==null&&(t[n.id]=i)}),t});for(let t of this.db.columns){let n=c.get(t.id);n&&n.length!==(t.options?.length??0)&&e.setOptions(t.id,n)}e.addRows(l),this.host.notify?.(AR(this.labels.imported,l.length))})}addRow(e={},t=!1){let n=this.host.store;if(!n)return;let r=this.view;for(let t of r.filters){let n=this.db.columns.find(e=>e.id===t.column);!n||t.column in e||(t.op===`is`&&(n.type===`select`||n.type===`text`)&&t.value&&(e[n.id]=t.value),t.op===`contains`&&n.type===`multiSelect`&&t.value&&(e[n.id]=[t.value]),t.op===`checked`&&(e[n.id]=!0))}let i=n.addRow(e);t||r.type!==`table`?this.openRow(i):(this.sel={row:i,col:WR(this.db).id},queueMicrotask(()=>this.startEdit()))}openRow(e){let t=nz(this.db,this.view,this.search).map(e=>e.id);this.host.openRow(e,t)}drawBody(){let e=this.view;e.type===`kanban`?this.drawKanban(e):e.type===`calendar`?this.drawCalendar(e):this.drawTable(e)}tableRows=[];tableCols=[];grid=null;drawTable(e){let t=this.labels,n=rz(this.db,e),r=nz(this.db,e,this.search),i=e.groupBy?this.db.columns.find(t=>t.id===e.groupBy):void 0,a=i?iz(r,i,t.noValue,t.checked,t.unchecked).filter(e=>e.rows.length||e.key!==``):[{key:``,label:``,rows:r}];this.tableCols=n,this.tableRows=[];let o=this.editable,s=e.sorts.length>0,c=I(`colgroup`,{},I(`col`,{class:`dw-db-t__gutter-col`}),n.map(t=>I(`col`,{style:{width:`${e.widths[t.id]??(t.type===`title`?240:160)}px`}})),o?I(`col`,{class:`dw-db-t__add-col`}):null),l=I(`table`,{class:`dw-db-t`},c,I(`thead`,{},I(`tr`,{},I(`th`,{class:`dw-db-t__gutter`,"aria-hidden":`true`}),n.map((e,t)=>this.headerCell(e,t,c.children[t+1])),o?I(`th`,{class:`dw-db-t__add`},Cz(`plus`,t.addColumn,e=>this.addColumnMenu(e.currentTarget))):null))),u=0;for(let r of a){let a=I(`tbody`,{}),c=`${e.id}:${r.key}`;if(i){let e=!this.collapsed.has(c),t=I(`button`,{type:`button`,class:`dw-db-t__group`,"aria-expanded":String(e)},Sz(e?`chevron-down`:`chevron-right`,14),r.key&&i.type!==`checkbox`&&i.type!==`member`&&i.type!==`createdBy`?I(`span`,{class:`dw-db-tag`,dataset:{color:r.color??`gray`}},r.label):I(`span`,{},r.label),I(`span`,{class:`dw-db-t__count`},String(r.rows.length)));if(t.addEventListener(`click`,()=>{e?this.collapsed.add(c):this.collapsed.delete(c),this.drawBody()}),a.append(I(`tr`,{class:`dw-db-t__group-row`},I(`td`,{colSpan:n.length+2},t))),!e){l.append(a);continue}}for(let e of r.rows){if(u>=this.limit)break;u++,this.tableRows.push(e),a.append(this.tableRow(e,n,o&&!s))}if(o&&u{let e={};i&&r.key?e[i.id]=sz({id:``,cells:{},createdAt:0,createdBy:null},i,``,r.key,r.rows.flatMap(e=>RB(GR(e,i)))):i?.type===`checkbox`&&(e[i.id]=r.key===`true`),this.addRow(e)}),a.append(I(`tr`,{class:`dw-db-t__new-row`},I(`td`,{colSpan:n.length+2},e)))}l.append(a)}let d=[],f=I(`div`,{class:`dw-db-t__wrap`,role:`grid`,tabIndex:0,"aria-label":this.db.title||t.database},l);if(d.push(f),r.length||d.push(I(`p`,{class:`dw-db__empty`},this.db.rows.length?t.noMatches:t.noRows)),r.length>u&&u>=this.limit){let e=I(`button`,{type:`button`,class:`dw-db__btn dw-db__more`},`${t.more} (${r.length-u})`);e.addEventListener(`click`,()=>{this.limit+=FB,this.drawBody()}),d.push(e)}this.grid=f,f.addEventListener(`keydown`,e=>this.onGridKey(e)),f.addEventListener(`copy`,e=>this.onCopy(e)),f.addEventListener(`paste`,e=>this.onPaste(e));let p=this.body.querySelector(`.dw-db-t__wrap`)?.scrollLeft??0,m=this.body.contains(document.activeElement);this.body.replaceChildren(...d),f.scrollLeft=p,this.markSelection(),m&&this.sel&&f.focus({preventScroll:!0})}headerCell(e,t,n){let r=this.labels,i=I(`span`,{class:`dw-db-t__name`},e.name||ER(r,e.type)),a=I(`button`,{type:`button`,class:`dw-db-t__head`,"aria-haspopup":`menu`,draggable:this.editable},Sz(Rz[e.type],14),i),o=I(`th`,{dataset:{col:e.id}},a);if(a.addEventListener(`click`,()=>this.columnMenu(a,e,t)),this.editable){a.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(`application/x-docwell-column`,e.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),o.addEventListener(`dragover`,e=>{e.dataTransfer?.types.includes(`application/x-docwell-column`)&&(e.preventDefault(),o.classList.add(`is-drop`))}),o.addEventListener(`dragleave`,()=>o.classList.remove(`is-drop`)),o.addEventListener(`drop`,t=>{o.classList.remove(`is-drop`);let n=t.dataTransfer?.getData(`application/x-docwell-column`);n&&n!==e.id&&(t.preventDefault(),this.host.store?.moveColumn(n,this.db.columns.findIndex(t=>t.id===e.id)))});let t=I(`span`,{class:`dw-db-t__resize`,title:r.resize,"aria-hidden":`true`});t.addEventListener(`pointerdown`,r=>{r.preventDefault(),r.stopPropagation();let i=r.clientX,a=n.getBoundingClientRect().width||160,o=a;t.setPointerCapture(r.pointerId);let s=e=>{o=Math.max(72,Math.round(a+e.clientX-i)),n.style.width=`${o}px`},c=()=>{t.removeEventListener(`pointermove`,s),t.removeEventListener(`pointerup`,c);let n=this.view;o!==a&&this.host.store?.updateView(n.id,{widths:{...n.widths,[e.id]:o}})};t.addEventListener(`pointermove`,s),t.addEventListener(`pointerup`,c)}),o.append(t)}return o}columnMenu(e,t,n){let r=this.labels,i=this.host.store,a=this.view,o=e=>({id:e?`desc`:`asc`,label:e?r.sortDescending:r.sortAscending,icon:e?`arrow-down`:`arrow-up`,run:()=>i?.updateView(a.id,{sorts:[{column:t.id,desc:e}]})});if(!i){Jj(e,[o(!1),o(!0)],t.name);return}let s=this.db.columns,c=s.findIndex(e=>e.id===t.id),l=[{id:`rename`,label:r.rename,icon:`pencil`,run:()=>this.renameColumn(t)}];t.type!==`title`&&l.push({id:`type`,label:r.type,icon:Rz[t.type],children:FR.map(n=>({id:n,label:ER(r,n),icon:n===t.type?`check`:Rz[n],run:()=>{i.changeType(t.id,n),(n===`relation`||n===`rollup`)&&queueMicrotask(()=>this.linkSettings(e,t.id))}}))}),t.type===`relation`&&l.push({id:`relationTo`,label:r.relationTo,icon:`relation`,run:()=>this.linkSettings(e,t.id)}),t.type===`rollup`&&l.push({id:`rollup`,label:r.rollupSettings,icon:`rollup`,run:()=>this.linkSettings(e,t.id)}),l.push(o(!1),o(!0),{id:`filter`,label:r.filterBy,icon:`filter`,run:()=>{i.updateView(a.id,{filters:[...a.filters,{column:t.id,op:QR(t.type)[0]}]}),this.buttons.filter.click()}}),t.type!==`title`&&l.push({id:`hide`,label:r.hide,icon:`close`,run:()=>i.updateView(a.id,{hidden:[...a.hidden,t.id]})}),l.push({id:`left`,label:r.insertLeft,icon:`plus`,run:()=>this.insertColumn(c)},{id:`right`,label:r.insertRight,icon:`plus`,run:()=>this.insertColumn(c+1)}),c>0&&l.push({id:`moveLeft`,label:r.moveLeft,icon:`arrow-up`,run:()=>i.moveColumn(t.id,c-1)}),ci.moveColumn(t.id,c+1)}),t.type!==`title`&&l.push({id:`duplicate`,label:r.duplicate,icon:`copy`,run:()=>i.duplicateColumn(t.id,`${t.name} 2`)},{id:`delete`,label:r.deleteColumn,icon:`trash`,danger:!0,run:()=>i.deleteColumn(t.id)}),Jj(e,l,t.name||ER(r,t.type))}linkSettings(e,t){let n=this.db.columns.find(e=>e.id===t),r=e.isConnected?e:this.dom.querySelector(`[data-col="${t}"]`)??this.dom;n?.type===`relation`?Pz(this.ctx(),r,n):n?.type===`rollup`&&Iz(this.ctx(),r,n)}insertColumn(e){let t=this.host.store;if(!t)return;let n=t.addColumn(`text`,this.labels.typeText,e);queueMicrotask(()=>{let e=this.db.columns.find(e=>e.id===n);e&&this.renameColumn(e)})}addColumnMenu(e){let t=this.labels;Jj(e,FR.map(e=>({id:e,label:ER(t,e),icon:Rz[e],run:()=>{let n=this.host.store?.addColumn(e,ER(t,e));queueMicrotask(()=>{let e=this.db.columns.find(e=>e.id===n);e&&this.renameColumn(e)})}})),t.addColumn)}renameColumn(e){let t=this.body.querySelector(`th[data-col="${CSS.escape(e.id)}"]`),n=this.host.store;if(!n)return;if(!t){let t=window.prompt(this.labels.columnName,e.name)?.trim();t&&n.renameColumn(e.id,t);return}let r=this.ctx();r.setEditing(!0);let i=Dz(e.name,{class:`dw-db-t__name-input`,label:this.labels.columnName,onCommit:t=>{t.trim()&&t.trim()!==e.name&&n.renameColumn(e.id,t.trim()),r.setEditing(!1),this.drawBody()},onCancel:()=>{r.setEditing(!1),this.drawBody()}});t.replaceChildren(i),i.focus(),i.select()}tableRow(e,t,n){let r=this.labels,i=I(`tr`,{dataset:{row:e.id},class:this.picked.has(e.id)?`is-picked`:``}),a=I(`td`,{class:`dw-db-t__gutter`});if(this.editable){let t=I(`input`,{type:`checkbox`,class:`dw-db-t__pick`,"aria-label":r.selectRow,checked:this.picked.has(e.id)});if(t.addEventListener(`change`,()=>{t.checked?this.picked.add(e.id):this.picked.delete(e.id),i.classList.toggle(`is-picked`,t.checked),this.drawBulk()}),a.append(t),n){let t=I(`span`,{class:`dw-db-t__grip`,draggable:!0,title:r.dragRow,"aria-hidden":`true`},Sz(`grip`,14));t.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(`application/x-docwell-row`,e.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`),t.dataTransfer?.setDragImage(i,0,0)}),a.append(t),i.addEventListener(`dragover`,e=>{if(!e.dataTransfer?.types.includes(`application/x-docwell-row`))return;e.preventDefault();let t=e.clientY>i.getBoundingClientRect().top+i.offsetHeight/2;i.classList.toggle(`is-drop-below`,t),i.classList.toggle(`is-drop-above`,!t)}),i.addEventListener(`dragleave`,()=>i.classList.remove(`is-drop-below`,`is-drop-above`)),i.addEventListener(`drop`,t=>{let n=i.classList.contains(`is-drop-below`);i.classList.remove(`is-drop-below`,`is-drop-above`);let r=t.dataTransfer?.getData(`application/x-docwell-row`);r&&r!==e.id&&this.host.store&&(t.preventDefault(),this.moveRowBeside(r,e.id,n))});let n=null,o=()=>n?.classList.remove(`is-drop-below`,`is-drop-above`),s=e=>{let t=e?.closest(`tr[data-row]`);return t&&t.parentElement===i.parentElement&&t!==i?t:null},c=(e,t)=>t>e.getBoundingClientRect().top+e.offsetHeight/2;NB(t,{source:i,ghost:()=>I(`div`,{class:`dw-db-ghost--row`},ZR(e,WR(this.db))||r.untitledRow),over:(e,t,r)=>{o(),n=s(e),n&&n.classList.add(c(n,r)?`is-drop-below`:`is-drop-above`)},drop:(t,n,r)=>{let i=s(t);i?.dataset.row&&this.moveRowBeside(e.id,i.dataset.row,c(i,r))},end:o,hold:()=>this.rowMenu(i,e)})}}i.append(a);for(let n of t){let t=I(`td`,{dataset:{col:n.id},class:`dw-db-t__cell dw-db-t__cell--${n.type}`,role:`gridcell`},Wz(this.ctx(),e,n));if(n.type===`title`){let n=I(`button`,{type:`button`,class:`dw-db-t__open`,title:r.openRow},Sz(`open`,13),I(`span`,{},r.openRow));n.addEventListener(`click`,t=>{t.stopPropagation(),this.openRow(e.id)}),t.append(n)}t.addEventListener(`mousedown`,t=>{t.target.closest(`input, button, a`)||(this.anchor=t.shiftKey&&this.sel?this.anchor??this.sel:null,this.sel={row:e.id,col:n.id},t.shiftKey||(this.anchor=null),this.markSelection(),t.preventDefault(),this.grid?.focus({preventScroll:!0}))});let a=!1;t.addEventListener(`pointerdown`,e=>a=e.pointerType===`touch`),t.addEventListener(`click`,e=>{e.target.closest(`input, button, a`)||e.shiftKey||(n.type===`checkbox`||a)&&this.startEdit()}),t.addEventListener(`dblclick`,()=>this.startEdit()),i.append(t)}return this.editable&&i.append(I(`td`,{class:`dw-db-t__add`})),i.addEventListener(`contextmenu`,t=>{(this.editable||this.host.copyLink)&&(t.preventDefault(),this.rowMenu(i,e))}),i}moveRowBeside(e,t,n){let r=this.host.store;if(!r||e===t)return;let i=r.rowIndex(e),a=r.rowIndex(t)+ +!!n;ithis.openRow(t.id)}];if(i&&a.push({id:`link`,label:n.copyLink,icon:`link`,run:()=>i(t.id)}),r){let e=r.rowIndex(t.id);a.push({id:`above`,label:n.insertAbove,icon:`arrow-up`,run:()=>r.addRow({},e)},{id:`below`,label:n.insertBelow,icon:`arrow-down`,run:()=>r.addRow({},e+1)},{id:`duplicate`,label:n.duplicateRow,icon:`copy`,run:()=>r.duplicateRow(t.id)},{id:`delete`,label:n.deleteRow,icon:`trash`,danger:!0,run:()=>r.deleteRows([t.id])})}Jj(e,a,n.openRow)}range(){if(!this.sel)return null;let e=e=>this.tableRows.findIndex(t=>t.id===e),t=e=>this.tableCols.findIndex(t=>t.id===e),n=this.anchor??this.sel,[r,i,a,o]=[e(n.row),e(this.sel.row),t(n.col),t(this.sel.col)];if(i<0||o<0)return null;let s=r<0?i:r,c=a<0?o:a;return{r0:Math.min(s,i),r1:Math.max(s,i),c0:Math.min(c,o),c1:Math.max(c,o)}}markSelection(){if(!this.grid)return;for(let e of this.grid.querySelectorAll(`.is-selected, .is-in-range`))e.classList.remove(`is-selected`,`is-in-range`);let e=this.range();if(!e||!this.sel)return;for(let t=e.r0;t<=e.r1;t++)for(let n=e.c0;n<=e.c1;n++)this.cellEl(this.tableRows[t].id,this.tableCols[n].id)?.classList.add(`is-in-range`);let t=this.cellEl(this.sel.row,this.sel.col);t?.classList.add(`is-selected`),t?.scrollIntoView({block:`nearest`,inline:`nearest`})}cellEl(e,t){return this.grid?.querySelector(`tr[data-row="${CSS.escape(e)}"] td[data-col="${CSS.escape(t)}"]`)??null}startEdit(e){if(!this.sel||!this.host.store)return;let t=this.db.rows.find(e=>e.id===this.sel.row),n=this.db.columns.find(e=>e.id===this.sel.col),r=this.cellEl(this.sel.row,this.sel.col);t&&n&&r&&Gz(this.ctx(),r,t,n,{initial:e,onDone:e=>{e&&this.moveSel(+(e===`down`),e===`right`?1:e===`left`?-1:0,!1),this.drawBody(),this.grid?.focus({preventScroll:!0})}})}moveSel(e,t,n){let r=this.tableRows,i=this.tableCols;if(!r.length||!i.length)return;if(!this.sel)return this.sel={row:r[0].id,col:i[0].id},this.markSelection();this.anchor=n?this.anchor??{...this.sel}:null;let a=Math.max(0,Math.min(r.length-1,r.findIndex(e=>e.id===this.sel.row)+e)),o=Math.max(0,Math.min(i.length-1,i.findIndex(e=>e.id===this.sel.col)+t));this.sel={row:r[a].id,col:i[o].id},this.markSelection()}onGridKey(e){if(e.target.closest(`input, select, textarea`))return;let t=e.ctrlKey||e.metaKey;if(t&&e.key.toLowerCase()===`z`)return e.preventDefault(),e.shiftKey?this.host.redo():this.host.undo();if(t&&e.key.toLowerCase()===`y`)return e.preventDefault(),this.host.redo();if(t)return;let n={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]}[e.key];if(n)return e.preventDefault(),this.moveSel(n[0],n[1],e.shiftKey);if(this.sel){if(e.key===`Tab`)return e.preventDefault(),this.moveSel(0,e.shiftKey?-1:1,!1);if(e.key===`Escape`)this.sel=null,this.anchor=null,this.markSelection();else{if(e.key===`Enter`||e.key===`F2`)return e.preventDefault(),this.startEdit();if(e.key===` `)return e.preventDefault(),this.db.columns.find(e=>e.id===this.sel.col)?.type===`title`?this.openRow(this.sel.row):this.startEdit();if((e.key===`Delete`||e.key===`Backspace`)&&this.host.store){e.preventDefault();let t=this.range();if(!t)return;let n=[];for(let e=t.r0;e<=t.r1;e++)for(let r=t.c0;r<=t.c1;r++){let t=this.tableCols[r];!Bz.includes(t.type)&&!dz(t)&&n.push({row:this.tableRows[e].id,col:t.id,value:null})}this.host.store.setCells(n)}else if(e.key.length===1&&this.host.store){let t=this.db.columns.find(e=>e.id===this.sel.col);t&&(zz.includes(t.type)||t.type===`select`||t.type===`multiSelect`)&&(e.preventDefault(),this.startEdit(e.key))}}}}onCopy(e){if(e.target.closest(`input, textarea`))return;let t=this.range();if(!t||!e.clipboardData)return;e.preventDefault();let n=[];for(let e=t.r0;e<=t.r1;e++){let r=[];for(let n=t.c0;n<=t.c1;n++)r.push(ZR(this.tableRows[e],this.tableCols[n]));n.push(r)}e.clipboardData.setData(`text/plain`,hB(n,` `)),this.host.notify?.(AR(this.labels.copyNotice,(t.r1-t.r0+1)*(t.c1-t.c0+1)))}onPaste(e){if(e.target.closest(`input, textarea`))return;let t=this.host.store,n=e.clipboardData?.getData(`text/plain`);if(!t||!n||!this.sel)return;e.preventDefault();let r=pB(n.replace(/\r?\n$/,``),(n.includes(` `),` `)),i=this.tableRows.findIndex(e=>e.id===this.sel.row),a=this.tableCols.findIndex(e=>e.id===this.sel.col);if(i<0||a<0)return;let o=new Map(this.db.columns.map(e=>[e.id,[...e.options??[]]])),s=[],c=[];r.forEach((e,t)=>{let n=this.tableRows[i+t],r={};e.forEach((e,t)=>{let i=this.tableCols[a+t];if(!i||Bz.includes(i.type)||dz(i))return;let c=vB(e,i,o.get(i.id)??[]);n?s.push({row:n.id,col:i.id,value:c}):c!==null&&(r[i.id]=c)}),n||c.push(r)}),t.tx(()=>{for(let e of this.db.columns){let n=o.get(e.id);n&&n.length!==(e.options?.length??0)&&t.setOptions(e.id,n)}t.setCells(s),c.length&&t.addRows(c)})}drawKanban(e){let t=this.labels,n=this.db.columns.find(t=>t.id===e.groupBy);if(!n){this.body.replaceChildren(I(`p`,{class:`dw-db__empty`},t.noGroupColumn));return}let r=nz(this.db,e,this.search),i=iz(r,n,t.noValue,t.checked,t.unchecked),a=rz(this.db,e).filter(e=>e.type!==`title`&&e.id!==n.id),o=WR(this.db),s=r.flatMap(e=>RB(GR(e,n))),c=I(`div`,{class:`dw-db-k`}),l=(t,r,i,a)=>{let o=this.host.store,c=this.db.rows.find(e=>e.id===t);o&&c&&o.tx(()=>{if(r!==i&&o.setCell(t,n.id,sz(c,n,r,i,s)),a&&a!==t&&!e.sorts.length){let e=o.rowIndex(t),n=o.rowIndex(a);e0)continue;let r=I(`div`,{class:`dw-db-k__cards`,dataset:{group:e.key}}),i=I(`div`,{class:`dw-db-k__head`},e.key&&n.type!==`checkbox`&&n.type!==`member`&&n.type!==`createdBy`?I(`span`,{class:`dw-db-tag`,dataset:{color:e.color??`gray`}},e.label):I(`span`,{class:`dw-db-k__label`},e.label),I(`span`,{class:`dw-db-t__count`},String(e.rows.length)));for(let t of e.rows.slice(0,this.limit)){let i=I(`div`,{class:`dw-db-k__card`,tabIndex:0,role:`button`,draggable:this.editable&&!Bz.includes(n.type),dataset:{row:t.id}},I(`div`,{class:`dw-db-k__title`},Wz(this.ctx(),t,o)),a.flatMap(e=>ZR(t,e)===``||e.type===`checkbox`&&GR(t,e)!==!0?[]:[I(`div`,{class:`dw-db-k__prop`,title:e.name},Wz(this.ctx(),t,e))]));if(i.addEventListener(`click`,()=>this.openRow(t.id)),i.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this.openRow(t.id))}),i.addEventListener(`dragstart`,n=>{n.dataTransfer?.setData(`application/x-docwell-card`,JSON.stringify({row:t.id,from:e.key})),n.dataTransfer&&(n.dataTransfer.effectAllowed=`move`),i.classList.add(`is-dragging`)}),i.addEventListener(`dragend`,()=>i.classList.remove(`is-dragging`)),i.draggable){let n=I(`span`,{class:`dw-db-k__grip`,"aria-hidden":`true`},Sz(`grip`,14));i.append(n);let r=null,a=e=>{let t=e?.closest(`.dw-db-k__cards`);return t&&c.contains(t)?t:null};NB(n,{source:i,ghost:()=>i.cloneNode(!0),over:e=>{r?.classList.remove(`is-drop`),r=a(e),r?.classList.add(`is-drop`)},drop:n=>{let r=a(n);r&&l(t.id,e.key,r.dataset.group??``,n?.closest(`.dw-db-k__card`)?.dataset.row)},end:()=>r?.classList.remove(`is-drop`)})}r.append(i)}if(this.editable){let i=I(`button`,{type:`button`,class:`dw-db-t__new`},Sz(`plus`,14),I(`span`,{},t.newRow));i.addEventListener(`click`,()=>{let t={id:``,cells:{},createdAt:0,createdBy:null};this.addRow(e.key||n.type===`checkbox`?{[n.id]:sz(t,n,``,e.key,s)}:{},!0)}),r.append(i),r.addEventListener(`dragover`,e=>{e.dataTransfer?.types.includes(`application/x-docwell-card`)&&(e.preventDefault(),r.classList.add(`is-drop`))}),r.addEventListener(`dragleave`,e=>{r.contains(e.relatedTarget)||r.classList.remove(`is-drop`)}),r.addEventListener(`drop`,t=>{r.classList.remove(`is-drop`);let n=t.dataTransfer?.getData(`application/x-docwell-card`),i=this.host.store;if(!n||!i)return;t.preventDefault();let{row:a,from:o}=JSON.parse(n);l(a,o,e.key,t.target.closest(`.dw-db-k__card`)?.dataset.row)})}c.append(I(`section`,{class:`dw-db-k__col`,"aria-label":e.label},i,r))}this.body.replaceChildren(c)}drawCalendar(e){let t=this.labels,n=this.db.columns.find(t=>t.id===e.dateColumn);if(!n){this.body.replaceChildren(I(`p`,{class:`dw-db__empty`},t.noDateColumn));return}let r=this.editable&&n.type===`date`,{y:i,m:a}=this.month,o=uz(i,a),s=nz(this.db,e,this.search),c=new Map,l=[];for(let e of s){let t=qR(GR(e,n));t?c.set(t,[...c.get(t)??[],e]):l.push(e)}let u=WR(this.db),d=JR(new Date),f=new Date(i,a,1).toLocaleDateString(this.host.locale,{month:`long`,year:`numeric`}),p=e=>{let t=new Date(i,a+e,1);this.month={y:t.getFullYear(),m:t.getMonth()},this.drawBody()},m=I(`div`,{class:`dw-db-c__nav`},I(`strong`,{class:`dw-db-c__month`},f),Cz(`chevron-left`,t.previousMonth,()=>p(-1)),Cz(`chevron-right`,t.nextMonth,()=>p(1)),Cz(`calendar`,t.today,()=>{let e=new Date;this.month={y:e.getFullYear(),m:e.getMonth()},this.drawBody()},t.today)),h=o.slice(0,7).map(e=>{let[t,n,r]=e.split(`-`).map(Number);return I(`div`,{class:`dw-db-c__wd`},new Date(t,n-1,r).toLocaleDateString(this.host.locale,{weekday:`short`}))}),g=e=>{let i=I(`button`,{type:`button`,class:`dw-db-c__chip`,draggable:r,dataset:{row:e.id}},ZR(e,u)||t.untitledRow);if(i.addEventListener(`click`,()=>this.openRow(e.id)),i.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(`application/x-docwell-row-date`,e.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),r){let t=null,r=e=>{let t=e?.closest(`.dw-db-c__day`);return t&&this.body.contains(t)?t:null};NB(i,{source:i,ghost:()=>i.cloneNode(!0),over:e=>{t?.classList.remove(`is-drop`),t=r(e),t?.classList.add(`is-drop`)},drop:t=>{let i=r(t)?.dataset.day;i&&this.host.store?.setCell(e.id,n.id,i)},end:()=>t?.classList.remove(`is-drop`)})}return i},_=I(`div`,{class:`dw-db-c__grid`,role:`grid`},h);for(let e of o){let i=I(`div`,{class:`dw-db-c__day${Number(e.slice(5,7))===a+1?``:` is-out`}${e===d?` is-today`:``}`,role:`gridcell`,dataset:{day:e}},I(`span`,{class:`dw-db-c__num`},String(Number(e.slice(8)))),(c.get(e)??[]).map(g));if(this.editable&&n.type===`date`){let r=I(`button`,{type:`button`,class:`dw-db-c__add`,"aria-label":`${t.newRow} ${e}`,title:t.newRow},Sz(`plus`,12));r.addEventListener(`click`,()=>this.addRow({[n.id]:e},!0)),i.append(r)}r&&(i.addEventListener(`dragover`,e=>{e.dataTransfer?.types.includes(`application/x-docwell-row-date`)&&(e.preventDefault(),i.classList.add(`is-drop`))}),i.addEventListener(`dragleave`,()=>i.classList.remove(`is-drop`)),i.addEventListener(`drop`,t=>{i.classList.remove(`is-drop`);let r=t.dataTransfer?.getData(`application/x-docwell-row-date`);r&&(t.preventDefault(),this.host.store?.setCell(r,n.id,e))})),_.append(i)}let v=[m,_];l.length&&v.push(I(`details`,{class:`dw-db-c__undated`},I(`summary`,{},AR(t.noDate,l.length)),I(`div`,{class:`dw-db-c__chips`},l.slice(0,this.limit).map(g)))),this.body.replaceChildren(I(`div`,{class:`dw-db-c`},v))}},LB={id:``,name:``,type:`table`,hidden:[],filters:[],filterMode:`and`,sorts:[],groupBy:null,dateColumn:null,widths:{}};function RB(e){return Array.isArray(e)?e.filter(e=>e&&typeof e.id==`string`):[]}var zB=`[A-Za-z0-9]{1,32}`,BB=(e,t)=>`#r-${e}-${t}`;function VB(e){let t=RegExp(`^#?r-(${zB})-(${zB})$`).exec(e);return t?{database:t[1],row:t[2]}:null}var HB=`dw-open-record`;function UB(e,t,n,r){let i=-1;if(e.state.doc.descendants((e,n)=>i>=0?!1:(e.type.name===`database`&&e.attrs.id===t&&(i=n),!0)),i<0)return!1;let a=e.view.nodeDOM(i);if(!(a instanceof HTMLElement))return!1;let o={row:n,...r};return a.dispatchEvent(new CustomEvent(HB,{detail:o})),!!o.found}async function WB(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}var GB=e=>(e??NR).database;function KB(e){let t=GB(e);return{tableView:t.viewTable,columnName:e=>e===`title`?t.typeTitle:ER(t,e)}}var qB=e=>xw(e).content??[];function JB(e,t){let n=[];return e.forEach(e=>{e.type.name===`database`?n.push(t(e)):e.content.size?n.push(e.copy(JB(e.content,t))):n.push(e)}),s.from(n)}function YB(e){let t=!1;return e.descendants(e=>(e.type.name===`database`&&(t=!0),!t)),t}var XB=Jp.create({name:`database`,group:`block`,atom:!0,draggable:!0,selectable:!0,addOptions(){return{labels:null,doc:void 0,readOnlyDoc:!1,undoScope:!0,files:void 0,people:void 0,me:void 0,rowExtensions:void 0,notify:void 0,recordLink:void 0,onLinkCopied:void 0,linkedPages:void 0,pages:void 0,onNavigate:void 0,recordPage:void 0}},addAttributes(){return{id:{default:``,parseHTML:e=>e.getAttribute(`data-id`)??``,renderHTML:e=>({"data-id":e.id})},data:{default:null,parseHTML:e=>{try{let t=e.getAttribute(`data-db`);return t?JSON.parse(t):null}catch{return null}},renderHTML:e=>e.data?{"data-db":JSON.stringify(e.data)}:{}}}},parseHTML(){return[{tag:`div[data-type='database']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=A(t,{"data-type":`database`});if(!e.attrs.data)return[`div`,n];let r=BR(e.attrs.data),i=r.views[0],a=r.columns.filter(e=>e.type===`title`||!i?.hidden.includes(e.id));return[`div`,n,[`p`,{},[`strong`,{},r.title||GB(this.options.labels).untitled]],[`table`,{},[`tr`,{},...a.map(e=>[`th`,{},e.name])],...r.rows.map(e=>[`tr`,{},...a.map(t=>[`td`,{},ZR(e,t)])])]]},renderText({node:e}){let t=e.attrs.data?BR(e.attrs.data):null;if(!t)return``;let n=WR(t);return[t.title,...t.rows.map(e=>ZR(e,n))].filter(Boolean).join(` -`)},onCreate(){let{doc:e,readOnlyDoc:t,undoScope:n}=this.options;e&&!t&&n&&(IS.getState(this.editor.state)?.undoManager)?.addToScope(Zz(e))},addCommands(){let e=e=>{let t=LR(),{doc:n,readOnlyDoc:r}=this.options;return!n||r?{id:t,data:e}:(fB(n,t,e,(e,t)=>ZB(this.editor,e,t)),{id:t,data:null})};return{insertDatabase:t=>({commands:n})=>n.insertContent([{type:this.name,attrs:e(t??sB(KB(this.options.labels)))},{type:`paragraph`}]),groupAsDatabase:()=>({state:t,dispatch:n,commands:r})=>{let i=eV(t.selection.$from,t.selection.$to);if(!i)return!1;if(!n)return!0;let a=GB(this.options.labels),o={id:LR(),name:a.typeTitle,type:`title`},s=[o],c=i.checks?{id:LR(),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:LR(),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:[RR(`table`,a.viewTable,s)]},d=this.type.create(e(u));return r.command(({tr:e})=>(e.replaceWith(i.from,i.to,d),e.setSelection(E.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 D({key:new Un(`databaseClipboard`),props:{transformCopied:t=>!e||!YB(t.content)?t:new p(JB(t.content,t=>{let n=Zz(e).get(String(t.attrs.id));return n instanceof Bb?t.type.create({...t.attrs,data:dB(n,qB)}):t}),t.openStart,t.openEnd),transformPasted:e=>YB(e.content)?new p(JB(e.content,e=>{let t=LR();if(!n)return e.type.create({...e.attrs,id:t});let i=e.attrs.data?BR(e.attrs.data):null,a=Zz(n).get(String(e.attrs.id)),o=i??(a instanceof Bb?dB(a,qB):sB(KB(this.options.labels)));return fB(n,t,$B(o),(e,t)=>ZB(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(FS))||!e.some(e=>e.steps.some(e=>YB(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=Zz(n).get(String(t.attrs.id)),a=LR();i instanceof Bb&&fB(n,a,$B(dB(i,qB)),(e,t)=>ZB(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??NR,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?Zz(o).get(p()):void 0;return e instanceof Bb?e:null},h=()=>{let t=m();return t?oB(t):i.attrs.data?BR(i.attrs.data):sB(KB(e.labels))},g=e=>{let t=o?Zz(o).get(e):void 0;if(t instanceof Bb)return oB(t);let r=null;return n.state.doc.descendants(t=>!r&&(t.type.name===`database`&&t.attrs.id===e&&t.attrs.data&&(r=BR(t.attrs.data)),!0)),r},_=new Map,v=t=>{let n=e.linkedPages;if(!n)return null;let r=_.get(t);if(!r){let e=n.open(t),i=e.onChange(re);e.doc.on(`update`,re),r={provider:e,stop:()=>{i(),e.doc.off(`update`,re),e.destroy()}},_.set(t,r)}return r.provider},y=t=>!t||t===e.linkedPages?.self,b=new Set,x=e=>{if(y(e.page))return b.add(e.database),e.database===p()?h():g(e.database);let t=v(e.page);if(!t?.synced)return null;let n=Zz(t.doc).get(e.database);return n instanceof Bb?oB(n):null},S=(e,t,n)=>{let r=[],i=e=>{for(let a of e.toArray())if(a instanceof lx){if(a.nodeName===`database`){let e=String(a.getAttribute(`id`)??``);e&&r.push({page:t,database:e,title:n(e)?.title??``})}else i(a)}};return i(e),r},C=t=>{if(!s()||!o||!y(t.page))return null;if(t.database===p())return c;let n=Zz(o).get(t.database);return n instanceof Bb?new lB(o,n,()=>e.me?.()??null):null},ee={local:()=>{let e=[];return n.state.doc.descendants(t=>(t.type.name===`database`&&t.attrs.id&&t.attrs.id!==p()&&e.push({page:``,database:String(t.attrs.id),title:g(String(t.attrs.id))?.title??``}),!0)),e},searchPages:e.pages?t=>e.pages.search(t).then(e=>e.filter(e=>!y(e.id)).map(e=>({id:e.id,title:e.title}))):void 0,databasesOn:e.linkedPages?e=>new Promise(t=>{let n=v(e),r=()=>{t(S(n.doc.getXmlFragment(`default`),e,e=>{let t=Zz(n.doc).get(e);return t instanceof Bb?oB(t):null}))};if(n.synced)return r();let i=setTimeout(()=>{a(),t([])},8e3),a=n.onChange(()=>{n.synced&&(clearTimeout(i),a(),r())})}):void 0,read:x,pointsHere:(t,n)=>n.database===p()?y(t.page)?y(n.page):!!e.linkedPages?.self&&n.page===e.linkedPages.self:!1,writable:e=>!!C(e),link:(e,t,n,r)=>{let i=C(e),a=e.back;if(!i||!a)return!1;let o=i.snapshot().rows.find(e=>e.id===n);if(!o)return!1;let s=gz(o.cells[a]).filter(e=>e!==t);return r&&s.push(t),i.setCell(n,a,s.length?s:null),!0},addBack:(e,t,n)=>{let r=C(e);return r?(r.tx(()=>{let e=r.addColumn(`relation`,n);r.setRelation(e,{page:``,database:p(),back:t})}),!0):!1},openRecord:(t,r)=>{y(t.page)?UB(n,t.database,r):e.onNavigate?.(`/p/${encodeURIComponent(t.page)}${BB(t.database,r)}`)}},te=e=>{for(let t of e)if((t.path.length?[String(t.path[0])]:[...t.keysChanged??[]]).some(e=>e!==p()&&b.has(e)))return re()};o&&Zz(o).observeDeep(te);let ne;function re(){clearTimeout(ne),ne=setTimeout(()=>fe(),60)}let ie=()=>xz(h(),x,a.database),ae=()=>({labels:a.database,colorNames:a.colors,locale:a.locale,files:e.files,people:e.people,store:c,linked:ee}),oe=(t,n)=>{let r=e.rowExtensions;if(!r)return null;let i=m(),o=null;if(i&&(o=c?c.rowBody(n.id):QB(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()},se=e.recordLink,ce=se?t=>{let n=se(BB(p(),t));WB(n).then(t=>t&&e.onLinkCopied?.(n))}:void 0;f.addEventListener(HB,e=>{let t=e.detail,n=ie();n.rows.some(e=>e.id===t.row)&&(t.found=!0,t.container||f.scrollIntoView?.({block:`start`}),de(t.row,n.rows.map(e=>e.id),t.container?{container:t.container,onLeave:t.onClose}:void 0))});let le=e.recordPage,ue,de=(e,t,n)=>{u?.close(!1),ue=n,u=new Yz({ctx:{...ae()},mountBody:oe,copyLink:ce,openPage:le&&!n?e=>le(p(),e):void 0,page:n},ie(),e,t,()=>{u=null,ue=void 0})},fe=()=>{let e=ie();d?.update(e,{store:c}),u?.update(e,{store:c})},pe=()=>{if(l?.(),l=null,c=null,!o)return;let t=m();if(!t&&s()){let a=i.attrs.data?BR(i.attrs.data):sB(KB(e.labels)),s=p()?p():LR();fB(o,s,a,(e,t)=>ZB(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=Zz(o).get(s)}let a=Zz(o),d=e=>{if(!e.keysChanged.has(p()))return;pe(),fe();let t=u?.row;t&&ie().rows.some(e=>e.id===t)&&de(t,[t],ue)};if(a.observe(d),t){s()&&(c=new lB(o,t,()=>e.me?.()??null));let n=t,r=()=>fe();n.observeDeep(r),l=()=>{a.unobserve(d),n.unobserveDeep(r)}}else l=()=>a.unobserve(d)};pe(),d=new IB({...ae(),openRow:de,undo:()=>n.commands.undo?.(),redo:()=>n.commands.redo?.(),notify:e.notify,copyLink:ce},ie()),f.append(d.dom);let me=s(),he=()=>{s()!==me&&(me=s(),pe(),fe())};return n.on(`update`,he),n.on(`transaction`,he),{dom:f,update(e){if(e.type!==i.type)return!1;let t=e.attrs.id!==i.attrs.id;return i=e,t&&pe(),fe(),!0},ignoreMutation:()=>!0,stopEvent:e=>e.type!==`dragstart`||e.target!==f,destroy(){l?.(),clearTimeout(ne),o&&Zz(o).unobserveDeep(te);for(let e of _.values())e.stop();_.clear(),u?.close(!1),d?.destroy(),n.off(`update`,he),n.off(`transaction`,he)}}}}});function ZB(e,t,n){try{Sw(e.schema,{type:`doc`,content:t},n)}catch{}}function QB(e,t){let n=e.get(`rows`);if(!(n instanceof Lb))return null;for(let e of n.toArray())if(e.get(`id`)===t){let t=e.get(`body`);return t instanceof sx&&t.length?t:null}return null}function $B(e){return{...e,rows:e.rows.map(e=>({...e,id:LR()}))}}function eV(e,t){for(let t=e.depth;t>0;t--){let n=e.node(t);if([`bulletList`,`orderedList`,`taskList`].includes(n.type.name)){let r=[];return n.forEach(e=>{let t=e.firstChild,n=[];e.forEach((e,t,r)=>{r>0&&n.push(e.toJSON())}),r.push({text:t?.textContent??``,checked:!!e.attrs.checked,rest:n})}),{from:e.before(t),to:e.after(t),checks:n.type.name===`taskList`,items:r}}}if(e.depth<1)return null;let n=e.before(1),r=t.after(Math.min(1,t.depth)||1),i=[];return e.doc.nodesBetween(n,r,(e,t)=>t=r?!1:(e.isTextblock&&e.textContent.trim()&&i.push({text:e.textContent,checked:!1,rest:[]}),!e.isTextblock)),i.length>1?{from:n,to:r,checks:!1,items:i}:null}function tV(e){let t=FS.getState(e);return t?.type&&t.binding&&t.doc?t:null}function nV(e,t){let n=tV(e);if(!n||!t?.from||!t.to)return null;try{let r=e=>PS(n.doc,n.type,fy(yg(e)),n.binding.mapping),i=r(t.from),a=r(t.to);return i===null||a===null||a<=i||a>e.doc.content.size?null:{from:i,to:a}}catch{return null}}var rV=new Un(`docwellComments`);function iV(e,t,n){let r=[];for(let i of t){let t=nV(e,i.anchor);t&&r.push(vs.inline(t.from,t.to,{class:i.id===n?`dw-comment is-active`:`dw-comment`,"data-comment":i.id}))}return xs.create(e.doc,r)}var aV=Tp.create({name:`commentHighlights`,addOptions(){return{onSelect:void 0}},addProseMirrorPlugins(){let e=()=>this.options.onSelect;return[new D({key:rV,state:{init:()=>({marks:[],active:``,decos:xs.empty}),apply(e,t,n,r){let i=e.getMeta(rV);if(i)return{...i,decos:iV(r,i.marks,i.active)};if(!e.docChanged||!t.marks.length)return t;let a=e.getMeta(FS)?.isChangeOrigin;return{...t,decos:a?iV(r,t.marks,t.active):t.decos.map(e.mapping,e.doc)}}},props:{decorations:e=>rV.getState(e)?.decos??xs.empty,handleClick(t,n,r){let i=r.target?.closest?.(`[data-comment]`)?.getAttribute(`data-comment`);return i&&e()?.(i),!1}}})]}}),oV=/^(\d{4})-(\d{2})-(\d{2})$/;function sV(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function cV(e){let t=oV.exec(e);if(!t)return null;let n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return sV(n)===e?n:null}function lV(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function uV(e,t){return Math.round((t.getTime()-e.getTime())/864e5)}function dV(e,t,n=new Date){let r=cV(e);if(!r)return e;let i=t.dates,a=uV(lV(n,0),r);return a===0?i.today:a===1?i.tomorrow:a===-1?i.yesterday:new Intl.DateTimeFormat(t.locale,{month:`short`,day:`numeric`,year:r.getFullYear()===n.getFullYear()?void 0:`numeric`}).format(r)}function fV(e,t){let n=cV(e);return n?new Intl.DateTimeFormat(t.locale,{dateStyle:`full`}).format(n):e}function pV(e,t,n,r=new Date){let i=t.dates,a=e.trim().toLowerCase(),o=!1;for(let e of new Set([i.remindWord.toLowerCase(),`remind`])){if(a.startsWith(e)){o=!0,a=a.slice(e.length).trim();break}if(a.length>=3&&e.startsWith(a)){o=!0,a=``;break}}if(o&&!n)return[];let s=lV(r,0);if(!a)return o?[1,0,7].map(e=>({date:sV(lV(s,e)),remind:o})):[{date:sV(s),remind:!1},...n?[{date:sV(lV(s,1)),remind:!0}]:[]];let c=[{words:[i.today,`today`],date:s},{words:[i.tomorrow,`tomorrow`],date:lV(s,1)},{words:[i.nextWeek,`next week`],date:lV(s,7)}];o||c.push({words:[i.yesterday,`yesterday`],date:lV(s,-1)});let l=e=>new Intl.DateTimeFormat(e,{weekday:`long`});for(let e=1;e<=7;e++){let n=lV(s,e);c.push({words:[l(t.locale).format(n),l(`en`).format(n)],date:n})}let u=[];cV(a)&&u.push({date:a,remind:o});for(let e of c)e.words.some(e=>e.toLowerCase().startsWith(a))&&u.push({date:sV(e.date),remind:o});return u.filter((e,t)=>u.findIndex(t=>t.date===e.date)===t).slice(0,5)}function mV(e,t){let n=e.toLowerCase().split(` `),r=[t.dates.remindWord,`remind`,t.dates.nextWeek.split(` `)[0]??``,`next`];return n.length>1&&n.length<=3&&r.some(e=>e&&e.toLowerCase()===n[0])}var hV=Jp.create({name:`dateMention`,group:`inline`,inline:!0,atom:!0,selectable:!0,addOptions(){return{labels:void 0,me:()=>void 0,onOpen:void 0}},addAttributes(){return{date:{default:``,parseHTML:e=>e.getAttribute(`data-date`)??``,renderHTML:e=>({"data-date":e.date})},remind:{default:``,parseHTML:e=>e.getAttribute(`data-remind`)??``,renderHTML:e=>e.remind?{"data-remind":e.remind}:{}},tz:{default:``,parseHTML:e=>e.getAttribute(`data-tz`)??``,renderHTML:e=>e.tz?{"data-tz":e.tz}:{}}}},parseHTML(){return[{tag:`span[data-type="date"]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`span`,A({"data-type":`date`,class:`dw-date`},t),dV(e.attrs.date,this.options.labels)]},renderText({node:e}){return dV(e.attrs.date,this.options.labels)},addNodeView(){let{labels:e,me:t,onOpen:n}=this.options;return({node:r,editor:i,getPos:a})=>{let o=r,s=document.createElement(`span`);s.dataset.type=`date`,s.className=`dw-date`,s.contentEditable=`false`,s.classList.toggle(`is-link`,!!n);let c=null,l=()=>{let t=o.attrs.date,n=o.attrs.remind,r=!!cV(t)&&t{let t=typeof a==`function`?a():void 0;t!==void 0&&i.chain().command(({tr:n})=>(n.setNodeMarkup(t,void 0,{...o.attrs,...e}),!0)).run()};return s.addEventListener(`mousedown`,r=>{c||(i.isEditable?(r.preventDefault(),c=vV(s,i,o,e,t(),u,()=>c=null,n)):n&&cV(o.attrs.date)&&(r.preventDefault(),n(o.attrs.date)))}),{dom:s,update(e){return e.type===o.type&&(o=e,l(),!0)},ignoreMutation:()=>!0,stopEvent:e=>s.contains(e.target)&&e.type!==`mousedown`,destroy(){c?.()}}}}});function gV(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone??``}catch{return``}}function _V(e,t,n,r){let i={date:n.date,remind:n.remind&&r?r:``,tz:n.remind&&r?gV():``};e.chain().focus().insertContentAt(t,[{type:`dateMention`,attrs:i},{type:`text`,text:` `}]).run()}function vV(e,t,n,r,i,a,o,s){let c=r.dates,l=document.createElement(`div`);l.className=`dw-date-pop`,l.setAttribute(`role`,`dialog`),l.setAttribute(`aria-label`,c.edit);let u=document.createElement(`input`);u.type=`date`,u.className=`dw-input`,u.value=n.attrs.date,u.setAttribute(`aria-label`,c.edit),u.addEventListener(`change`,()=>{cV(u.value)&&a({date:u.value})}),l.append(u);let d=n.attrs.remind;if(d&&d!==i){let e=document.createElement(`p`);e.className=`dw-date-pop__note`,e.textContent=c.someoneElse,l.append(e)}else if(i){let e=document.createElement(`label`);e.className=`dw-date-pop__check`;let t=document.createElement(`input`);t.type=`checkbox`,t.checked=d===i,t.addEventListener(`change`,()=>a(t.checked?{remind:i,tz:gV()}:{remind:``,tz:``})),e.append(t,document.createTextNode(c.remindMe));let n=document.createElement(`span`);n.className=`dw-date-pop__note`,n.textContent=c.reminderAt,l.append(e,n)}if(s){let e=document.createElement(`button`);e.type=`button`,e.className=`dw-date-pop__open`,e.textContent=c.openJournal??`Open journal`,e.addEventListener(`click`,()=>{let e=n.attrs.date;h(),cV(e)&&s(e)}),l.append(e)}document.body.append(l);let f=jj(e,l,()=>{Fj(e,l,{placement:`bottom-start`,strategy:`fixed`,middleware:[Mj(6),Pj(),Nj({padding:8})]}).then(({x:e,y:t})=>Object.assign(l.style,{left:`${e}px`,top:`${t}px`}))}),p=t=>{!l.contains(t.target)&&!e.contains(t.target)&&h()},m=e=>{e.key===`Escape`&&(e.preventDefault(),h(),t.commands.focus())};function h(){f(),l.remove(),document.removeEventListener(`mousedown`,p,!0),document.removeEventListener(`keydown`,m,!0),o()}return document.addEventListener(`mousedown`,p,!0),document.addEventListener(`keydown`,m,!0),u.focus(),h}function yV(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=kf(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.map(kf).join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function bV(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,` -`);return/\s/.test(n)}):!1}function xV(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 SV(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:xV(e)}function CV({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&&!bV(r)}function wV({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function TV({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 EV({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)){(yf.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 DV({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 OV({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Mj({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(Pj()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function kV(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 AV({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&&kV(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=jj(c,o,()=>{Fj(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 jV({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,_=DV({editor:e,items:n}),v=OV({placement:s,offset:c,flip:u,floatingUi:d});function y(e,t){switch(e){case`started`:var n;r==null||(n=r.onStart)==null||n.call(r,t);break;case`updated`:var i;r==null||(i=r.onUpdate)==null||i.call(r,t);break;case`stopped`:var a;r==null||(a=r.onExit)==null||a.call(r,t)}}return{update:async(n,d)=>{let b=t.getState(d),x=t.getState(n.state);if(!b||!x)return;let S=null,C=b.query!==x.query,ee=b.text!==x.text,te=b.range.from!==x.range.from||b.range.to!==x.range.to,ne=C||ee||te;if(!b.active&&x.active)S=`started`;else if(b.active&&!x.active)S=`stopped`;else if(x.active&&ne)S=`updated`;else return;let re=S===`stopped`?b:x,ie=n.dom.querySelector(`[data-decoration-id="${re.decorationId}"]`),ae=m(n,ie),oe=i===0||(re.query?re.query.length>=i:!1),se=(S===`started`||S===`updated`)&&oe;if(g={editor:e,range:re.range,query:re.query||``,text:re.text||``,items:o??[],command:t=>p({editor:e,range:re.range,props:t}),decorationNode:ie,clientRect:ae,loading:se,placement:s,offset:{mainAxis:c.mainAxis??4,crossAxis:c.crossAxis??0},container:l,flip:u,floatingUi:v,mount:AV({getReferenceRect:ae,contextElement:n.dom,config:v,container:l,dismissOnOutsideClick:f,dismiss:()=>h(e.view)})},S===`started`){var ce;r==null||(ce=r.onBeforeStart)==null||ce.call(r,g)}if(S===`updated`){var le;r==null||(le=r.onBeforeUpdate)==null||le.call(r,g)}if(S===`started`&&y(S,g),S===`started`||S===`updated`){if(!se)_.abort(),g={...g,items:o??[],loading:!1};else{g={...g,items:o??[],loading:!0},S=`updated`,y(S,g);let e=await _.fetch(re.query||``,a);if(e.status===`aborted`)return;if(!t.getState(n.state)?.active){_.abort();return}g=e.status===`resolved`?{...g,items:e.items,loading:!1}:{...g,loading:!1}}}S===`stopped`?(_.abort(),y(S,g),g=void 0):S===`updated`&&y(S,g)},destroy:()=>{var e;_.abort(),g&&(r==null||(e=r.onExit)==null||e.call(r,g))}}}var MV=new Un(`suggestion`);function NV({pluginKey:e=MV,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],minQueryLength:p=0,debounce:m=0,initialItems:h,placement:g=`bottom-start`,offset:_={},container:v,flip:y=!0,floatingUi:b,dismissOnOutsideClick:x=!0,render:S=()=>({}),allow:C=()=>!0,findSuggestionMatch:ee=yV,shouldShow:te,shouldResetDismissed:ne}){let re=S?.(),ie=r&&!i,ae=(n,r)=>SV(t,n,r,e);function oe(e){return CV({...e,editor:t,shouldResetDismissed:ne,effectiveAllowSpaces:ie})}let se=t=>wV({view:t,pluginKeyRef:e});return new D({key:e,view:()=>jV({editor:t,pluginKey:e,items:f,renderer:re,minQueryLength:p,debounce:m,initialItems:h,placement:g,offset:_,container:v,flip:y,floatingUi:b,dismissOnOutsideClick:x,command:d,clientRectFor:ae,dispatchExit:se}),state:EV({editor:t,char:n,effectiveAllowSpaces:ie,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:ee,allow:C,shouldShow:te,shouldKeepDismissed:oe,pluginKey:e}),props:TV({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:re,dispatchExit:se})})}var PV=NV,FV=e=>`/p/${encodeURIComponent(e)}`,IV=/^\/p\/([A-Za-z0-9_-]+)\/?(?:[?#].*)?$/;function LV(e){return IV.exec(e)?.[1]??``}function RV(e,t,n,r=`Untitled`){let i=`${n.icon?`${n.icon} `:``}${n.title||r}`;e.chain().focus().deleteRange(t).insertContent([{type:`text`,text:i,marks:[{type:`link`,attrs:{href:FV(n.id)}}]},{type:`text`,text:` `}]).run()}async function zV(e,t,n){if(!t.create)return;let{from:r,to:i,empty:a}=e.state.selection,o=a?``:e.state.doc.textBetween(r,i,` `).trim().slice(0,200),s=await t.create(o);a||!o?RV(e,{from:r,to:r},s,n):e.chain().focus().setTextSelection({from:r,to:i}).setLink({href:FV(s.id)}).run()}var BV=Tp.create({name:`pageLinks`,addOptions(){return{host:void 0,labels:null,onNavigate:void 0}},addProseMirrorPlugins(){let{host:e,onNavigate:t}=this.options,n=this.options.labels,r=[];return e&&r.push(PV({editor:this.editor,pluginKey:new Un(`pageLinks`),char:`[[`,allowSpaces:!0,allow:({state:e,range:t})=>!e.doc.resolve(t.from).parent.type.spec.code,items:async({query:t})=>(await e.search(t).catch(()=>[])).slice(0,8),render:Uj({label:n.pageLinks,empty:n.noPages,toItem:e=>({label:`${e.icon?`${e.icon} `:``}${e.title||`…`}`,description:e.hint,icon:`page`}),pick:(e,t)=>RV(e.editor,e.range,t)})})),t&&r.push(new D({key:new Un(`pageLinkClicks`),props:{handleClick:(e,n,r)=>{let i=(r.target?.closest?.(`a[href]`))?.getAttribute(`href`)??``;return!LV(i)||e.editable&&!(r.ctrlKey||r.metaKey)?!1:(r.preventDefault(),t(i),!0)}}})),r}});function VV(e,t,n){e.chain().focus().deleteRange(t).insertSyncedPage(n).run()}var HV=Jp.create({name:`syncedPage`,group:`block`,atom:!0,draggable:!0,addOptions(){return{host:void 0,pages:void 0,labels:null,onNavigate:void 0,nested:void 0}},addAttributes(){return{page:{default:``,parseHTML:e=>e.getAttribute(`data-page`)??``,renderHTML:e=>({"data-page":e.page})},title:{default:``,parseHTML:e=>e.getAttribute(`data-title`)??``,renderHTML:e=>e.title?{"data-title":e.title}:{}},icon:{default:``,parseHTML:e=>e.getAttribute(`data-icon`)??``,renderHTML:e=>e.icon?{"data-icon":e.icon}:{}},folded:{default:!1,parseHTML:e=>e.hasAttribute(`data-folded`),renderHTML:e=>e.folded?{"data-folded":``}:{}}}},parseHTML(){return[{tag:`div[data-type='syncedPage']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=`${e.attrs.icon?`${e.attrs.icon} `:``}${e.attrs.title||`…`}`;return[`div`,A(t,{"data-type":`syncedPage`}),[`a`,{href:FV(String(e.attrs.page))},n]]},addCommands(){return{insertSyncedPage:e=>({commands:t})=>t.insertContent([{type:this.name,attrs:{page:e.id,title:e.title,icon:e.icon??``}},{type:`paragraph`}])}},addProseMirrorPlugins(){let{pages:e}=this.options,t=this.options.labels;return e?[PV({editor:this.editor,pluginKey:new Un(`syncedPages`),char:`![[`,allowSpaces:!0,allow:({state:e,range:t})=>!e.doc.resolve(t.from).parent.type.spec.code,items:async({query:t})=>(await e.search(t).catch(()=>[])).slice(0,8),render:Uj({label:t.blocks.syncedPage,empty:t.noPages,toItem:e=>({label:`${e.icon?`${e.icon} `:``}${e.title||`…`}`,description:e.hint,icon:`page`}),pick:(e,t)=>VV(e.editor,e.range,t)})})]:[]},addNodeView(){let{host:e,onNavigate:t,nested:n}=this.options,r=this.options.labels.blocks;return({node:i,editor:a,getPos:o})=>{let s=i,c=String(s.attrs.page),l=document.createElement(`div`);l.className=`dw-synced`,l.dataset.type=`syncedPage`,l.contentEditable=`false`;let u=document.createElement(`div`);u.className=`dw-synced__head`;let d=document.createElement(`a`);d.className=`dw-synced__title`,d.href=FV(c);let f=Hj(`copy`,14);f.classList.add(`dw-synced__badge`);let p=document.createElement(`button`);p.type=`button`,p.className=`dw-synced__btn`;let m=document.createElement(`button`);m.type=`button`,m.className=`dw-synced__btn`,m.textContent=r.syncedOpen,u.append(f,d,p,m);let h=document.createElement(`div`);h.className=`dw-synced__body`,l.append(u,h);let g=e=>{e.preventDefault(),t?t(FV(c)):window.location.assign(FV(c))};d.addEventListener(`click`,g),m.addEventListener(`click`,g);let _=e=>{let t=typeof o==`function`?o():void 0;t!==void 0&&a.view.dispatch(a.state.tr.setNodeMarkup(t,void 0,{...s.attrs,...e}))},v=null,y=()=>v??!!s.attrs.folded;p.addEventListener(`click`,()=>{a.isEditable?_({folded:!s.attrs.folded}):(v=!y(),ne())});let b=null,x=null,S=null,C=e=>{let t=document.createElement(`p`);t.className=`dw-synced__note`,t.textContent=e,h.replaceChildren(t)},ee=()=>{S?.(),x?.destroy(),b?.destroy(),S=null,x=null,b=null},te=()=>{if(x||!e||!n)return;if(c===e.self)return C(r.syncedSelf);b=e.open(c),C(r.syncedLoading);let t=b,i=()=>{t.status===`denied`?(ee(),C(r.syncedDenied)):t.synced&&!x&&(h.replaceChildren(),x=new Vp({element:h,editable:!1,extensions:n(t.doc),editorProps:{attributes:{class:`dw-prose`}}}))};S=t.onChange(i),i()};function ne(){let t=s.attrs.title;d.textContent=`${s.attrs.icon?`${s.attrs.icon} `:``}${t||r.syncedPage}`;let n=y();l.classList.toggle(`is-folded`,n),p.textContent=n?r.syncedUnfold:r.syncedFold,p.setAttribute(`aria-expanded`,String(!n)),n?(ee(),h.replaceChildren()):e?te():h.replaceChildren()}return ne(),e?.meta(c).then(e=>{e?a.isEditable&&(e.title!==s.attrs.title||e.icon!==s.attrs.icon)?_({title:e.title,icon:e.icon}):d.textContent=`${e.icon?`${e.icon} `:``}${e.title||r.syncedPage}`:y()||C(r.syncedDenied)}),{dom:l,update(e){return e.type!==s.type||String(e.attrs.page)!==c?!1:(s=e,ne(),!0)},ignoreMutation:()=>!0,stopEvent:e=>e.target instanceof globalThis.Node&&(u.contains(e.target)||h.contains(e.target)),destroy:ee}}}});function UV(e){let t=document.createElement(`div`);t.className=`dw-diagram-editor`,t.setAttribute(`role`,`dialog`),t.setAttribute(`aria-modal`,`true`),t.setAttribute(`aria-label`,e);let n=document.createElement(`p`);n.className=`dw-diagram-editor__status`,t.append(n),document.body.append(t);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,{root:t,status:e=>{n.textContent=e,n.hidden=!e},close:()=>{t.remove(),document.body.style.overflow=r}}}async function WV(e,t){let n=await fetch(e.resolve(t));if(!n.ok)throw Error(`loading the drawing failed (${n.status})`);return n.text()}function GV(e,t){return new File([e],t,{type:`image/svg+xml`})}function KV(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n)}function qV(e,t,n){return new Promise(r=>{let i=UV(n.slash.drawio?.label??`Draw.io`),a=document.createElement(`iframe`),o=new URL(e);for(let[e,t]of Object.entries({embed:`1`,proto:`json`,spin:`1`,saveAndExit:`1`,noExitBtn:`0`}))o.searchParams.set(e,t);a.src=o.toString(),a.className=`dw-diagram-editor__frame`,a.title=n.slash.drawio?.label??`Draw.io`;let s=document.createElement(`div`);s.className=`dw-diagram-editor__bar`;let c=document.createElement(`button`);c.type=`button`,c.className=`dw-source__btn`,c.textContent=n.blocks.cancel,c.addEventListener(`click`,()=>d(null)),s.append(c),i.root.append(s,a),i.status(``);let l=e=>a.contentWindow?.postMessage(JSON.stringify(e),o.origin),u=!1,d=e=>{window.removeEventListener(`message`,f),i.close(),r(e)},f=e=>{if(e.source!==a.contentWindow||e.origin!==o.origin||typeof e.data!=`string`)return;let n;try{n=JSON.parse(e.data)}catch{return}switch(n.event){case`init`:l({action:`load`,autosave:0,xml:t?`data:image/svg+xml;base64,${KV(t)}`:``});break;case`save`:u=!0,l({action:`export`,format:`xmlsvg`,spinKey:`saving`});break;case`export`:{let e=n.data??``,t=e.indexOf(`,`),r=e.slice(0,t),i=e.slice(t+1),a=r.includes(`;base64`)?new TextDecoder().decode(Uint8Array.from(atob(i),e=>e.charCodeAt(0))):decodeURIComponent(i);d(u?a:null);break}case`exit`:d(null)}};window.addEventListener(`message`,f)})}async function JV(e,t,n){let r=UV(n.slash.excalidraw?.label??`Excalidraw`);r.status(``);try{let{openExcalidraw:i}=await e();return await i(r.root,t,n)}finally{r.close()}}var YV=!1;function XV(e){return Jp.create({name:e,group:`block`,atom:!0,draggable:!0,addOptions(){return{host:void 0,loadExcalidraw:void 0,labels:null,drawioUrl:void 0,onError:void 0}},addAttributes(){return{src:{default:``},alt:{default:``}}},parseHTML(){return[{tag:`figure[data-type='${e}']`,getAttrs:e=>({src:e.querySelector(`img`)?.getAttribute(`src`)??``})}]},renderHTML({node:t,HTMLAttributes:n}){return[`figure`,A(n,{"data-type":e}),[`img`,{src:String(t.attrs.src),alt:String(t.attrs.alt||e)}]]},addCommands(){return{insertDiagram:e=>({commands:t})=>(YV=!0,t.insertContent({type:e,attrs:{src:``}}))}},addNodeView(){return({node:t,editor:n,getPos:r})=>{let i=this.options,a=i.labels,o=document.createElement(`figure`);o.className=`dw-diagram dw-diagram--${e}`,o.setAttribute(`data-type`,e);let s=document.createElement(`img`);s.className=`dw-diagram__img`;let c=document.createElement(`p`);c.className=`dw-diagram__empty`,c.textContent=e===`drawio`?a.blocks.emptyDrawio:a.blocks.emptyExcalidraw;let l=document.createElement(`button`);l.type=`button`,l.className=`dw-diagram__edit`,l.textContent=a.blocks.edit,o.append(s,c,l);let u=``,d=t=>{u=String(t.attrs.src??``),s.hidden=!u,c.hidden=!!u,u&&(s.src=i.host?i.host.resolve(u):u,s.alt=String(t.attrs.alt||a.slash[e]?.label||e))};d(t);let f=!1,p=async()=>{if(!f&&m()&&i.host?.upload){f=!0;try{let t=u?await WV(i.host,u):``,o=e===`drawio`?await qV(i.drawioUrl||`https://embed.diagrams.net`,t,a):await JV(i.loadExcalidraw,t,a);if(o===null)return;let s=await i.host.upload(GV(o,`${e===`drawio`?`diagram.drawio`:`drawing.excalidraw`}.svg`)),c=typeof r==`function`?r():void 0;c!==void 0&&ZV(n,c,e,s.url)}catch(e){i.onError?.(e)}finally{f=!1}}},m=()=>n.isEditable&&!!i.host?.upload&&(e===`drawio`||!!i.loadExcalidraw),h=()=>l.hidden=!m()||!u;return h(),n.on(`update`,h),o.addEventListener(`dblclick`,()=>void p()),c.addEventListener(`click`,()=>void p()),l.addEventListener(`click`,()=>void p()),YV&&(YV=!1,queueMicrotask(()=>void p())),{dom:o,update:t=>t.type.name===e&&(d(t),h(),!0),ignoreMutation:()=>!0,stopEvent:e=>e.target===l||e.target===c,destroy:()=>n.off(`update`,h)}}}})}function ZV(e,t,n,r){e.chain().setNodeSelection(t).updateAttributes(n,{src:r}).run()}var QV=XV(`drawio`),$V=XV(`excalidraw`),eH=null;function tH(e){eH?.();let t=document.createElement(`div`);t.className=`dw-source`,t.setAttribute(`role`,`dialog`),t.setAttribute(`aria-label`,e.label);let n=document.createElement(e.multiline?`textarea`:`input`);n.className=`dw-source__field`+(e.monospace?` dw-source__field--mono`:``),n.value=e.value,n.setAttribute(`aria-label`,e.label),n.spellcheck=!1,n instanceof HTMLTextAreaElement&&(n.rows=Math.min(16,Math.max(4,e.value.split(` -`).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=jj(e.anchor,t,()=>{Fj(e.anchor,t,{placement:`bottom-start`,middleware:[Mj(6),Pj(),Nj({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(),eH===d&&(eH=null),n||e.onCancel?.())}let d=()=>u();return eH=d,n.focus(),e.multiline||n.select(),d}var nH={open:`green`,started:`yellow`,draft:`gray`,merged:`purple`,done:`blue`,closed:`red`,canceled:`gray`},rH=[{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 iH(e){let t;try{t=new URL(e.trim())}catch{return null}for(let e of rH){let n=e.pattern.exec(t.href);if(n)return{src:e.src(n,t),ratio:e.ratio??`video`}}return null}function aH(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`?t.href:``}catch{return``}}var oH=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}};function sH(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;tH({anchor:i,value:`https://`,label:n,labels:{done:r.done,cancel:r.cancel,remove:r.remove},onSave:t=>e(aH(t)),onCancel:()=>e(``)})})}async function cH(e,t,n,r){let i=await sH(e,t,t.blocks.embedUrl);i&&(iH(i)?e.chain().focus().insertEmbed(i).run():await uH(e,i,n,r))}async function lH(e,t,n,r){let i=await sH(e,t,t.blocks.linkUrl);i&&await uH(e,i,n,r)}async function uH(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 dH=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=aH(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=aH(e),i=iH(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}: ${oH(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.target=`_blank`,s.rel=`noopener noreferrer`,s.textContent=oH(r),o.append(s),n.append(a,o)},i=String(e.attrs.url);return r(i),{dom:n,update:e=>e.type.name===`embed`&&(e.attrs.url!==i&&r(i=String(e.attrs.url)),!0),ignoreMutation:()=>!0,stopEvent:e=>e.target instanceof Element&&!!e.target.closest(`a`)}}}}),fH=Jp.create({name:`linkCard`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){let e=e=>({default:``,parseHTML:t=>t.getAttribute(`data-${e}`)??``,renderHTML:t=>({[`data-${e}`]:t[e]})});return{url:e(`url`),title:e(`title`),description:e(`description`),image:e(`image`),site:e(`site`),kind:e(`kind`),status:e(`status`),state:e(`state`),meta:e(`meta`)}},parseHTML(){return[{tag:`div[data-type='link-card']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=aH(String(e.attrs.url));return[`div`,A(t,{"data-type":`link-card`}),[`a`,{href:n},String(e.attrs.title||n)]]},addCommands(){return{insertLinkCard:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{url:e.url,title:e.title??``,description:e.description??``,image:e.image??``,site:e.site??``,kind:e.kind??``,status:e.status??``,state:e.state??``,meta:e.meta??``}})}},addNodeView(){return({node:e})=>{let t=document.createElement(`a`);t.className=`dw-linkcard`,t.setAttribute(`data-type`,`link-card`),t.contentEditable=`false`,t.target=`_blank`,t.rel=`noopener noreferrer`;let n=e=>{let n=aH(String(e.url));t.href=n,t.replaceChildren();let r=document.createElement(`span`);r.className=`dw-linkcard__text`;let i=document.createElement(`span`);i.className=`dw-linkcard__title`,i.textContent=String(e.title||``)||oH(n);let a=String(e.kind||``);if(t.dataset.kind=a,e.status){let t=document.createElement(`span`);t.className=`dw-linkcard__head`;let n=document.createElement(`span`);n.className=`dw-linkcard__status`,n.dataset.color=nH[String(e.state)]??`gray`,n.textContent=String(e.status),t.append(n,i),r.append(t)}else r.append(i);if(e.description){let t=document.createElement(`span`);t.className=`dw-linkcard__desc`,t.textContent=String(e.description),r.append(t)}let o=document.createElement(`span`);o.className=`dw-linkcard__site`,o.textContent=[String(e.site||``)||oH(n),String(e.meta||``)].filter(Boolean).join(` · `),r.append(o),t.append(r);let s=aH(String(e.image||``));if(s.startsWith(`https:`)){let e=document.createElement(`img`);e.className=a.startsWith(`github.`)?`dw-linkcard__image dw-linkcard__image--avatar`:`dw-linkcard__image`,e.src=s,e.alt=``,e.loading=`lazy`,e.referrerPolicy=`no-referrer`,e.onerror=()=>e.remove(),t.append(e)}},r=e;return n(e.attrs),t.addEventListener(`click`,e=>{this.editor.view.editable&&!(e.ctrlKey||e.metaKey)&&e.preventDefault()}),{dom:t,update:e=>e.type.name===`linkCard`&&(e.attrs!==r.attrs&&n(e.attrs),r=e,!0),ignoreMutation:()=>!0}}}}),pH=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,mH=Jp.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,A(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,i=new Set([`src`,`width`,`height`]);return({node:a,getPos:o,HTMLAttributes:s,editor:c})=>{let l=document.createElement(`img`);l.draggable=!1;let u=A(this.options.HTMLAttributes,s);Object.entries(u).forEach(([e,t])=>{if(t!=null)switch(e){case`src`:case`width`:case`height`:break;default:l.setAttribute(e,t)}}),u.src!==null&&(l.src=u.src);let d={...s},f=e=>{typeof e==`string`&&e!==``?l.getAttribute(`src`)!==e&&(l.src=e):(l.hasAttribute(`src`)&&l.removeAttribute(`src`),l.src!==``&&(l.src=``))};f(s.src);let p=new qp({element:l,editor:c,node:a,getPos:o,onResize:(e,t)=>{l.style.width=`${e}px`,l.style.height=`${t}px`},onCommit:(e,t)=>{let n=o();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:e=>{if(e.type!==a.type)return!1;let t=Lu(e,c.extensionManager.attributes.filter(t=>t.type===e.type.name));return Object.keys(d).forEach(e=>{!i.has(e)&&!(e in t)&&l.removeAttribute(e)}),Object.entries(t).forEach(([e,t])=>{i.has(e)||(t==null?l.removeAttribute(e):l.setAttribute(e,t))}),f(t.src),d=t,!0},options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),m=p.dom,h=()=>{m.style.visibility=``,m.style.pointerEvents=``};return m.style.visibility=`hidden`,m.style.pointerEvents=`none`,l.complete&&l.naturalWidth>0?h():(l.onload=h,l.onerror=h),p}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[Up({find:pH,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function hH(e,t){return/^(audio|video)\//.test(e)||/\.(mp3|mp4|mpeg|mpga|m4a|wav|webm|ogg|oga|flac|aac|opus|mov)$/i.test(t)}async function gH(e,t,n,r){if(t.upload)for(let i of n){let n=await t.upload(i),a=n.mime.startsWith(`image/`)?{type:`image`,attrs:{src:n.url,alt:n.name}}:{type:`fileAttachment`,attrs:{url:n.url,name:n.name,size:n.size,mime:n.mime,view:Rj(n.mime,n.name)?`preview`:`card`}};e.chain().focus().insertContentAt(r??e.state.selection.to,a).run(),r=void 0}}var _H=mH.extend({addOptions(){return{...this.parent(),host:void 0,inline:!1,allowBase64:!1}},addNodeView(){return({node:e})=>{let t=document.createElement(`img`),n=e=>{let n=String(e.attrs.src??``);t.src=this.options.host?this.options.host.resolve(n):n,t.alt=String(e.attrs.alt??``),e.attrs.title&&(t.title=String(e.attrs.title))};return n(e),t.draggable=!0,{dom:t,update:t=>t.type===e.type&&(n(t),!0)}}}});function vH(e){if(!e)return``;let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n({editor:e,commands:t})=>{let n=e.getAttributes(this.name);return!e.isActive(this.name)||!Rj(n.mime,n.name)?!1:t.updateAttributes(this.name,{view:n.view===`preview`?`card`:`preview`})}}},parseHTML(){return[{tag:`div[data-type=file]`,getAttrs:e=>({url:e.getAttribute(`data-url`)??``,name:e.getAttribute(`data-name`)??e.textContent??`file`,size:Number(e.getAttribute(`data-size`)??0),mime:e.getAttribute(`data-mime`)??``,view:e.getAttribute(`data-view`)===`preview`?`preview`:`card`})}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,A(t,{"data-type":`file`,"data-url":e.attrs.url,"data-name":e.attrs.name,"data-size":e.attrs.size,"data-mime":e.attrs.mime,"data-view":e.attrs.view}),[`a`,{href:e.attrs.url,download:e.attrs.name},e.attrs.name]]},addNodeView(){return({node:e,editor:t,getPos:n})=>{let{host:r,loadPdf:i,labels:a}=this.options,o=document.createElement(`div`);o.className=`dw-file-block`,o.setAttribute(`data-type`,`file`);let s=document.createElement(`div`);s.className=`dw-file`;let c=document.createElement(`a`);c.className=`dw-file__name`,c.target=`_blank`,c.rel=`noopener`;let l=document.createElement(`span`);l.className=`dw-file__size`,s.append(c,l),o.append(s);let u=null,d=null,f=e,p=async()=>{let e=r?.transcribe;if(e&&u&&a){u.disabled=!0,u.textContent=a.blocks.transcribing,d&&(d.textContent=``);try{let r=await e(String(f.attrs.url??``),String(f.attrs.name??`file`)),i=typeof n==`function`?n():void 0;i!==void 0&&r&&t.chain().insertContentAt(i+f.nodeSize,r).run()}catch(e){d&&(d.textContent=e instanceof Error&&e.message?e.message:a.blocks.transcribeFailed)}finally{u&&(u.disabled=!1,u.textContent=a.blocks.transcribe)}}},m=null,h=null,g=``,_=e=>{let n=String(e.attrs.url??``),_=r?r.resolve(n):n;c.href=_,c.textContent=String(e.attrs.name??`file`),l.textContent=vH(Number(e.attrs.size??0)),f=e;let v=!!r?.transcribe&&!!a&&t.isEditable&&hH(String(e.attrs.mime??``),String(e.attrs.name??``));v&&!u&&a?(u=document.createElement(`button`),u.type=`button`,u.className=`dw-file__action`,u.textContent=a.blocks.transcribe,u.title=a.blocks.transcribeHint,u.setAttribute(`data-testid`,`file-transcribe`),u.addEventListener(`click`,()=>void p()),d=document.createElement(`span`),d.className=`dw-file__status`,d.setAttribute(`role`,`status`),s.append(u),o.append(d)):!v&&u&&(u.remove(),d?.remove(),u=d=null),!(e.attrs.view===`preview`&&Rj(e.attrs.mime,e.attrs.name)&&n)||!i||!a?(h?.(),h=null,m?.remove(),m=null,g=``):g!==_&&(h?.(),m||(m=document.createElement(`div`),m.className=`dw-pdf`,m.tabIndex=0,m.setAttribute(`role`,`document`),o.append(m)),m.setAttribute(`aria-label`,String(e.attrs.name??`PDF`)),g=_,h=zj(m,_,i,a))};return _(e),{dom:o,update:t=>t.type===e.type&&(_(t),!0),stopEvent:e=>!!u&&u.contains(e.target)||!!m&&m.contains(e.target)&&e.type!==`mousedown`,ignoreMutation:()=>!0,destroy:()=>h?.()}}}}),bH=Tp.create({name:`fileDrop`,addOptions(){return{host:void 0,onError:void 0}},addProseMirrorPlugins(){let e=this.options.host;return e?[xH(()=>this.editor,e,this.options.onError)]:[]}});function xH(e,t,n){let r=(r,i)=>{let a=e();return!a||!r.length||!t.upload?!1:(gH(a,t,r,i).catch(n),!0)};return new D({key:new Un(`docwellFileDrop`),props:{handlePaste(e,t){return r([...t.clipboardData?.files??[]])},handleDrop(e,t){let n=[...t.dataTransfer?.files??[]];if(!n.length)return!1;let i=e.posAtCoords({left:t.clientX,top:t.clientY});return t.preventDefault(),r(n,i?.pos)}}})}var SH=new Un(`dwFind`),CH=``;function wH(e,t,n=!1){if(!t)return[];let r=n?t:t.toLowerCase(),i=[];return e.descendants((e,t)=>{if(!e.isTextblock)return!0;let a=``,o=[];e.forEach((e,n)=>{let r=t+1+n;if(e.isText){let t=e.text??``;for(let e=0;ee.from>=r);return a===-1&&(a=i.length?0:-1),{term:t,caseSensitive:n,matches:i,current:a}}function EH(e,t){return t&&e.setSelection(T.create(e.doc,t.from,t.to)).scrollIntoView(),e}var DH=Tp.create({name:`findReplace`,addCommands(){return{setFind:(e,t=!1)=>({state:n,tr:r,dispatch:i})=>{let a=TH(n.doc,e,t,n.selection.from);return r.setMeta(SH,{term:e,caseSensitive:t,near:n.selection.from}),i&&i(EH(r,a.matches[a.current])),!0},findStep:e=>({state:t,tr:n,dispatch:r})=>{let i=SH.getState(t);if(!i?.matches.length)return!1;let a=(i.current+e+i.matches.length)%i.matches.length;return n.setMeta(SH,{current:a}),r&&r(EH(n,i.matches[a])),!0},replaceCurrent:e=>({state:t,tr:n,dispatch:r})=>{let i=SH.getState(t),a=i?.matches[i.current];if(!i||!a)return!1;if(r){n.insertText(e,a.from,a.to),n.setMeta(SH,{term:i.term,caseSensitive:i.caseSensitive,near:a.from+e.length});let t=TH(n.doc,i.term,i.caseSensitive,a.from+e.length);r(EH(n,t.matches[t.current]))}return!0},replaceAll:e=>({state:t,tr:n,dispatch:r})=>{let i=SH.getState(t);if(!i?.matches.length)return!1;if(r){for(let t of[...i.matches].reverse())n.insertText(e,t.from,t.to);n.setMeta(SH,{term:i.term,caseSensitive:i.caseSensitive,near:0}),r(n)}return!0},clearFind:()=>({tr:e,dispatch:t})=>(t&&t(e.setMeta(SH,{clear:!0})),!0)}},addProseMirrorPlugins(){let e={term:``,caseSensitive:!1,matches:[],current:-1};return[new D({key:SH,state:{init:()=>e,apply(t,n,r,i){let a=t.getMeta(SH);if(a&&`clear`in a)return e;if(a&&`term`in a)return TH(i.doc,a.term,a.caseSensitive,a.near);if(a&&`current`in a)return{...n,current:a.current};if(!n.term||!t.docChanged)return n;let o=n.matches[n.current]?.from??0;return TH(i.doc,n.term,n.caseSensitive,t.mapping.map(o))}},props:{decorations(e){let t=SH.getState(e);return t?.matches.length?xs.create(e.doc,t.matches.map((e,n)=>vs.inline(e.from,e.to,{class:n===t.current?`dw-find dw-find-current`:`dw-find`}))):null}}})]}}),L=class e extends Error{constructor(t,n){var r=`KaTeX parse error: `+t,i,a,o=n&&n.loc;if(o&&o.start<=o.end){var s=o.lexer.input;i=o.start,a=o.end,i===s.length?r+=` at end of input: `:r+=` at position `+(i+1)+`: `;var c=s.slice(i,a).replace(/[^]/g,`$&̲`),l=i>15?`…`+s.slice(i-15,i):s.slice(0,i),u=a+15e.replace(OH,`-$1`).toLowerCase(),AH={"&":`&`,">":`>`,"<":`<`,'"':`"`,"'":`'`},jH=/[&><"']/g,MH=e=>String(e).replace(jH,e=>AH[e]),NH=e=>e.type===`ordgroup`||e.type===`color`?e.body.length===1?NH(e.body[0]):e:e.type===`font`?NH(e.body):e,PH=new Set([`mathord`,`textord`,`atom`]),FH=e=>PH.has(NH(e).type),IH=e=>{var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==`:`||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():`_relative`},LH={displayMode:{type:`boolean`,description:`Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.`,cli:`-d, --display-mode`},output:{type:{enum:[`htmlAndMathml`,`html`,`mathml`]},description:`Determines the markup language of the output.`,cli:`-F, --format `},leqno:{type:`boolean`,description:`Render display math in leqno style (left-justified tags).`},fleqn:{type:`boolean`,description:`Render display math flush left.`},throwOnError:{type:`boolean`,default:!0,cli:`-t, --no-throw-on-error`,cliDescription:`Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.`},errorColor:{type:`string`,default:`#cc0000`,cli:`-c, --error-color `,cliDescription:`A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.`,cliProcessor:e=>`#`+e},macros:{type:`object`,cli:`-m, --macro `,cliDescription:`Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).`,cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:`number`,description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:`--min-rule-thickness `,cliProcessor:parseFloat},colorIsTextColor:{type:`boolean`,description:`Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.`,cli:`-b, --color-is-text-color`},strict:{type:[{enum:[`warn`,`ignore`,`error`]},`boolean`,`function`],description:`Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.`,cli:`-S, --strict`,cliDefault:!1},trust:{type:[`boolean`,`function`],description:`Trust the input, enabling all HTML features such as \\url.`,cli:`-T, --trust`},maxSize:{type:`number`,default:1/0,description:`If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large`,processor:e=>Math.max(0,e),cli:`-s, --max-size `,cliProcessor:parseInt},maxExpand:{type:`number`,default:1e3,description:`Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.`,processor:e=>Math.max(0,e),cli:`-e, --max-expand `,cliProcessor:e=>e===`Infinity`?1/0:parseInt(e)},globalGroup:{type:`boolean`,cli:!1}};function RH(e){if(typeof e!=`string`)return e.enum[0];switch(e){case`boolean`:return!1;case`string`:return``;case`number`:return 0;case`object`:return{};default:throw Error(`Unexpected schema type; settings must declare an explicit default.`)}}function zH(e){return Object.prototype.hasOwnProperty.call(e,`default`)&&e.default!==void 0?e.default:RH(Array.isArray(e.type)?e.type[0]:e.type)}function BH(e,t,n,r){var i=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0,a=Object.prototype.hasOwnProperty.call(r,`processor`)?r.processor:void 0;e[t]=i===void 0?zH(r):a?a(i):i}var VH=class{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e||={};for(var t of Object.keys(LH)){var n=LH[t];n&&BH(this,t,e,n)}}reportNonstrict(e,t,n){var r=this.strict;if(typeof r==`function`&&(r=r(e,t,n)),r&&r!==`ignore`){if(r===!0||r===`error`)throw new L(`LaTeX-incompatible input and strict mode is set to 'error': `+(t+` [`+e+`]`),n);r===`warn`?typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to 'warn': `+(t+` [`+e+`]`)):typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to `+(`unrecognized '`+r+`': `+t+` [`+e+`]`))}}useStrictBehavior(e,t,n){var r=this.strict;if(typeof r==`function`)try{r=r(e,t,n)}catch{r=`error`}return!r||r===`ignore`?!1:r===!0||r===`error`?!0:r===`warn`?(typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to 'warn': `+(t+` [`+e+`]`)),!1):(typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to `+(`unrecognized '`+r+`': `+t+` [`+e+`]`)),!1)}isTrusted(e){if(`url`in e&&e.url&&!e.protocol){var t=IH(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},HH=class{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return ZH[QH[this.id]]}sub(){return ZH[$H[this.id]]}fracNum(){return ZH[eU[this.id]]}fracDen(){return ZH[tU[this.id]]}cramp(){return ZH[nU[this.id]]}text(){return ZH[rU[this.id]]}isTight(){return this.size>=2}},UH=0,WH=1,GH=2,KH=3,qH=4,JH=5,YH=6,XH=7,ZH=[new HH(UH,0,!1),new HH(WH,0,!0),new HH(GH,1,!1),new HH(KH,1,!0),new HH(qH,2,!1),new HH(JH,2,!0),new HH(YH,3,!1),new HH(XH,3,!0)],QH=[qH,JH,qH,JH,YH,XH,YH,XH],$H=[JH,JH,JH,JH,XH,XH,XH,XH],eU=[GH,KH,qH,JH,YH,XH,YH,XH],tU=[KH,KH,JH,JH,XH,XH,XH,XH],nU=[WH,WH,KH,KH,JH,JH,XH,XH],rU=[UH,WH,GH,KH,GH,KH,GH,KH],R={DISPLAY:ZH[UH],TEXT:ZH[GH],SCRIPT:ZH[qH],SCRIPTSCRIPT:ZH[YH]},iU=[{name:`latin`,blocks:[[256,591],[768,879]]},{name:`cyrillic`,blocks:[[1024,1279]]},{name:`armenian`,blocks:[[1328,1423]]},{name:`brahmic`,blocks:[[2304,4255]]},{name:`georgian`,blocks:[[4256,4351]]},{name:`cjk`,blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:`hangul`,blocks:[[44032,55215]]}];function aU(e){for(var t=0;t=i[0]&&e<=i[1])return n.name}return null}var oU=[];iU.forEach(e=>e.blocks.forEach(e=>oU.push(...e)));function sU(e){for(var t=0;t=oU[t]&&e<=oU[t+1])return!0;return!1}var cU=e=>e+` `+e,lU=80,uU=function(e,t){return`M95,`+(622+e+t)+` +`&&o++):i+=e,o++}return(i!==``||r.length)&&(r.push(i),n.push(r)),n}function xB(e,t){return e.includes(t)||/["\r\n]/.test(e)||/^\s|\s$/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function SB(e,t=`,`){return e.map(e=>e.map(e=>xB(e,t)).join(t)).join(`\r +`)}function CB(e,t,n){return SB([t.map(e=>e.name),...n.map(e=>t.map(t=>iz(e,t)))])}function wB(e){let t=e.map(e=>e.trim()).filter(Boolean);if(!t.length)return`text`;if(t.every(e=>nz(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 TB(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:WR(),name:e,color:hz(n)},n.push(t)),t.id};switch(t.type){case`number`:return nz(r);case`progress`:{let e=nz(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 ez(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 EB(e,t=`,`){let n=bB(e,t).filter(e=>e.some(e=>e.trim())),r=n[0]??[],i=n.slice(1),a=r.map((e,t)=>({id:WR(),name:e.trim()||`${t+1}`,type:t===0?`title`:wB(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=TB(e[r]??``,n,n.options??[]);i!==null&&(!Array.isArray(i)||i.length)&&(t[n.id]=i)}),t})}}function DB(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 OB(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 kB=e=>e.map(e=>({value:e.id,label:e.name||`…`}));function AB(e,t,n,r){let i=e.labels;if(!oz(n.op))return null;if(t.type===`select`||t.type===`multiSelect`)return OB(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 jB(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(OB(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=az(l.type),d=I(`div`,{class:`dw-db-pop__line`},OB(n.column,kB(a),i.filter,e=>{let t=a.find(t=>t.id===e);o[r]={column:e,op:az(t.type)[0]},s(),c()}),OB(n.op,u.map(e=>({value:e,label:FR(i,e)})),i.filter,e=>{o[r]={...n,op:e},oz(e)||delete o[r].value,s(),c()}),AB(e,l,n,e=>{o[r]={...o[r],value:e},s()}),IB(i.remove,()=>{o.splice(r,1),s(),c()}));t.append(d)}),r&&t.append(LB(i.addFilter,()=>{let e=a.find(e=>e.type!==`title`)??a[0];o.push({column:e.id,op:az(e.type)[0]}),s(),c()}))};c()}function MB(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`},OB(e.column,kB(a),i.sort,t=>{o[n]={...e,column:t},s()}),OB(e.desc?`desc`:`asc`,[{value:`asc`,label:i.ascending},{value:`desc`,label:i.descending}],i.sort,t=>{o[n]={...e,desc:t===`desc`},s()}),IB(i.remove,()=>{o.splice(n,1),s(),c()})))}),r&&t.append(LB(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 NB(e,t,n){let r=e.store,i=e.labels,a=e.db.columns.filter(e=>KR.includes(e.type)),o=a.map(e=>({value:e.id,label:e.name||NR(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`?OB(n.groupBy??``,o,i.groupBy,e=>r?.updateView(n.id,{groupBy:e||null})):I(`p`,{class:`dw-db-pop__empty`},i.noGroupColumn))}function PB(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?OB(n.dateColumn??``,[{value:``,label:`—`},...a.map(e=>({value:e.id,label:e.name||NR(i,e.type)}))],i.dateColumn,e=>r?.updateView(n.id,{dateColumn:e||null})):I(`p`,{class:`dw-db-pop__empty`},i.noDateColumn))}function FB(e,t,n){let r=e.store,i=e.labels,a=[...n.hidden],o=()=>r?.updateView(n.id,{hidden:a}),s=()=>{t.replaceChildren();let n=e.db.columns.filter(e=>e.type!==`title`);if(r&&n.length){let e=I(`button`,{type:`button`,class:`dw-db__btn`},a.length?i.showAll:i.hideAll);e.addEventListener(`click`,()=>{a=a.length?[]:n.map(e=>e.id),o(),s()}),t.append(I(`div`,{class:`dw-db-pop__row dw-db-pop__row--end`},e))}for(let n of e.db.columns){let e=n.type===`title`||!a.includes(n.id),c=I(`button`,{type:`button`,class:`dw-db-pop__item`,role:`switch`,"aria-checked":String(e),disabled:n.type===`title`||!r},I(`span`,{class:`dw-db-pop__check`},kz(Gz[n.type],14)),I(`span`,{class:`dw-db-pop__grow`},n.name||NR(i,n.type)),I(`span`,{class:e?`dw-db-switch is-on`:`dw-db-switch`}));c.addEventListener(`click`,()=>{a=e?[...a,n.id]:a.filter(e=>e!==n.id),o(),s()}),t.append(c)}};s()}function IB(e,t){let n=I(`button`,{type:`button`,class:`dw-db__btn dw-db__btn--icon`,"aria-label":e,title:e},kz(`close`,14));return n.addEventListener(`click`,t),n}function LB(e,t){let n=I(`button`,{type:`button`,class:`dw-db__btn dw-db-pop__add`},kz(`plus`,14),I(`span`,{},e));return n.addEventListener(`click`,t),n}var RB=6,zB=48;function BB(e,t){e.classList.add(`dw-db-touch-handle`);let n=!1,r=-1,i=0,a=0,o=0,s=0,c=0,l=null,u=null,d=0,f,p=0,m=()=>document.elementFromPoint(o,s),h=()=>{clearTimeout(f),cancelAnimationFrame(d),u&&(u.remove(),u=null,t.end()),t.source.classList.remove(`is-held`,`is-dragging`),n=!1,r=-1,p=Date.now()},g=()=>{if(!u)return;let e=oinnerWidth-zB),n=sinnerHeight-zB),r=!1;for(let[i,a]of[[`x`,e],[`y`,n]]){if(!a)continue;let e=VB(t.source,i)??(i===`y`?document.scrollingElement:null);if(!e)continue;let n=i===`x`?`scrollLeft`:`scrollTop`,o=e[n];e[n]+=a*12,r||=e[n]!==o}r&&t.over(m(),o,s),d=requestAnimationFrame(g)},_=e=>[...e.changedTouches].find(e=>e.identifier===r);e.addEventListener(`touchstart`,u=>{if(n||u.touches.length!==1)return;let d=u.changedTouches[0],p=u.target.closest(`input, textarea, select, [contenteditable='true']`);p&&e.contains(p)||(u.preventDefault(),n=!0,r=d.identifier,i=o=d.clientX,a=s=d.clientY,c=Date.now(),l=u.target,f=setTimeout(()=>{t.source.classList.add(`is-held`),navigator.vibrate?.(10)},500))},{passive:!1}),e.addEventListener(`touchmove`,e=>{let r=n&&_(e);if(r){if(e.preventDefault(),o=r.clientX,s=r.clientY,!u){if(Math.hypot(o-i,s-a)<=RB)return;clearTimeout(f),t.source.classList.remove(`is-held`),u=t.ghost();let e=t.source.getBoundingClientRect();Object.assign(u.style,{position:`fixed`,left:`${e.left}px`,top:`${e.top}px`,width:`${Math.max(80,Math.min(e.width,innerWidth-Math.max(e.left,0)-8))}px`,margin:`0`,pointerEvents:`none`,zIndex:`1000`}),u.classList.add(`dw-db-ghost`),document.body.append(u),t.source.classList.add(`is-dragging`),d=requestAnimationFrame(g)}u.style.transform=`translate(${o-i}px, ${s-a}px)`,t.over(m(),o,s)}},{passive:!1}),e.addEventListener(`touchend`,e=>{if(!n||!_(e))return;e.preventDefault();let r=u!==null,i=Date.now()-c>=500,a=l;r&&t.drop(m(),o,s),h(),r||(i&&t.hold?t.hold():a instanceof HTMLElement&&a.click())}),e.addEventListener(`touchcancel`,e=>{n&&_(e)&&h()});for(let t of[`contextmenu`,`dragstart`])e.addEventListener(t,e=>{(n||Date.now()-p<800)&&(e.preventDefault(),e.stopPropagation())},!0)}function VB(e,t){for(let n=e.parentElement;n;n=n.parentElement){let e=getComputedStyle(n),r=t===`x`?e.overflowX:e.overflowY;if((t===`x`?n.scrollWidth>n.clientWidth:n.scrollHeight>n.clientHeight)&&(r===`auto`||r===`scroll`))return n}return null}var HB=200,UB=class{host;dom=I(`div`,{class:`dw-db`,dataset:{type:`database`},contentEditable:`false`});db;viewId=null;search=``;editing=0;pending=!1;limit=HB;collapsed=new Set;sel=null;anchor=null;picked=new Set;month;titleEl=I(`div`,{class:`dw-db__title`});tabs=I(`div`,{class:`dw-db__tabs`,role:`tablist`});tools=I(`div`,{class:`dw-db__tools`});body=I(`div`,{class:`dw-db__body`});bulk=I(`div`,{class:`dw-db__bulk`});searchInput;buttons;constructor(e,t){this.host=e,this.db=t;let n=new Date;this.month={y:n.getFullYear(),m:n.getMonth()};let r=e.labels;this.searchInput=I(`input`,{class:`dw-db-input dw-db__search`,placeholder:r.search,"aria-label":r.search,hidden:!0}),this.searchInput.addEventListener(`input`,()=>{this.search=this.searchInput.value,this.limit=HB,this.drawBody()}),this.searchInput.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Escape`&&(this.searchInput.value=``,this.search=``,this.searchInput.hidden=!0,this.drawBody())}),this.buttons={search:Az(`search`,r.search,()=>{this.searchInput.hidden=!this.searchInput.hidden,this.searchInput.hidden||this.searchInput.focus()}),filter:Az(`filter`,r.filter,e=>this.panel(e,`filter`),r.filter),sort:Az(`sort`,r.sort,e=>this.panel(e,`sort`),r.sort),group:Az(`layers`,r.group,e=>this.panel(e,`group`),r.group),props:Az(`sliders`,r.properties,e=>this.panel(e,`props`)),more:Az(`more`,r.more,()=>this.moreMenu()),add:Az(`plus`,r.newRow,()=>this.addRow(),r.newRow)},this.buttons.add.classList.add(`dw-db__btn--primary`);let i=I(`div`,{class:`dw-db__head`},this.titleEl),a=I(`div`,{class:`dw-db__bar`},this.tabs,this.tools);this.tools.append(this.searchInput,this.buttons.search,this.buttons.filter,this.buttons.sort,this.buttons.group,this.buttons.props,this.buttons.more,this.buttons.add),this.dom.append(i,a,this.bulk,this.body),this.draw()}get labels(){return this.host.labels}get editable(){return!!this.host.store}get view(){return this.db.views.find(e=>e.id===this.viewId)??this.db.views[0]??WB}ctx(){return{...this.host,db:this.db,openRow:e=>this.openRow(e),setEditing:e=>{this.editing=Math.max(0,this.editing+(e?1:-1)),!this.editing&&this.pending&&(this.pending=!1,this.draw())}}}update(e,t){this.db=e,t&&(this.host={...this.host,...t}),this.editing?this.pending=!0:this.draw()}destroy(){Nz()}draw(){this.drawTitle(),this.drawTabs(),this.drawTools(),this.drawBody()}drawTitle(){let e=this.labels,t=this.db.title;if(this.titleEl.querySelector(`input`)===document.activeElement)return;if(!this.editable){this.titleEl.replaceChildren(I(`span`,{class:t?``:`is-empty`},t||e.untitled));return}let n=I(`input`,{class:`dw-db__title-input`,placeholder:e.untitled,"aria-label":e.untitled});n.value=t,n.addEventListener(`keydown`,e=>{e.stopPropagation(),(e.key===`Enter`||e.key===`Escape`)&&n.blur()}),n.addEventListener(`change`,()=>this.host.store?.setTitle(n.value)),this.titleEl.replaceChildren(n)}drawTabs(){let e=this.labels,t=this.view;if(this.tabs.replaceChildren(...this.db.views.map(n=>{let r=I(`button`,{type:`button`,class:n.id===t.id?`dw-db__tab is-active`:`dw-db__tab`,role:`tab`,"aria-selected":String(n.id===t.id)},kz(n.type===`kanban`?`cards`:n.type===`calendar`?`calendar`:`table`,14),I(`span`,{},n.name||IR(e,n.type)));return r.addEventListener(`click`,()=>{if(n.id===t.id&&this.editable)return this.viewMenu(r,n);this.viewId=n.id,this.sel=null,this.limit=HB,this.draw()}),r.addEventListener(`contextmenu`,e=>{this.editable&&(e.preventDefault(),this.viewMenu(r,n))}),r})),this.editable){let t=Az(`plus`,e.addView,()=>Kj(t,UR.map(t=>({id:t,label:IR(e,t),icon:t===`kanban`?`cards`:t===`calendar`?`calendar`:`table`,run:()=>{this.showView(this.host.store.addView(t,IR(e,t)))}})),e.addView));this.tabs.append(t)}}drawTools(){let e=this.view,t=this.buttons,n=(e,t)=>{e.classList.toggle(`is-on`,t>0);let n=e.querySelector(`span`);n&&(n.textContent=t?`${e.title} ${t}`:e.title)};n(t.filter,e.filters.length),n(t.sort,e.sorts.length),t.sort.hidden=e.type===`calendar`,t.group.classList.toggle(`is-on`,!!e.groupBy&&e.type===`table`),t.group.hidden=e.type===`calendar`,t.add.hidden=!this.editable,this.drawBulk()}drawBulk(){let e=[...this.picked].filter(e=>this.db.rows.some(t=>t.id===e));if(this.picked=new Set(e),this.bulk.hidden=!e.length||!this.editable,this.bulk.hidden)return this.bulk.replaceChildren();let t=this.labels;this.bulk.replaceChildren(I(`span`,{},LR(t.selected,e.length)),Az(`trash`,t.deleteRows,()=>{this.host.store?.deleteRows(e),this.picked.clear()},t.deleteRows),Az(`close`,t.close,()=>{this.picked.clear(),this.draw()}))}panel(e,t){let n=e.currentTarget;Mz(n,e=>{let n=this.ctx(),r=this.view;t===`filter`?jB(n,e,r):t===`sort`?MB(n,e,r):t===`group`?NB(n,e,r):(r.type===`calendar`&&PB(n,e,r),r.type===`kanban`&&NB(n,e,r),FB(n,e,r))},{class:`dw-db-pop--panel`,label:n.title,placement:`bottom-end`})}viewMenu(e,t){let n=this.labels,r=this.host.store,i=[{id:`rename`,label:n.renameView,icon:`pencil`,run:()=>{let e=window.prompt(n.viewName,t.name)?.trim();e&&r.updateView(t.id,{name:e})}},{id:`layout`,label:n.layout,icon:`grid`,children:UR.map(e=>({id:e,label:IR(n,e),icon:e===t.type?`check`:e===`kanban`?`cards`:e===`calendar`?`calendar`:`table`,run:()=>this.setLayout(t,e)}))},{id:`duplicate`,label:n.duplicateView,icon:`copy`,run:()=>{this.showView(r.duplicateView(t.id,`${t.name||IR(n,t.type)} 2`))}}];this.db.views.length>1&&i.push({id:`delete`,label:n.deleteView,icon:`trash`,danger:!0,run:()=>r.deleteView(t.id)}),Kj(e,i,n.layout)}showView(e){e&&(this.viewId=e,this.sel=null,this.limit=HB,this.draw())}setLayout(e,t){let n={type:t},r=this.db.columns;t===`kanban`&&!e.groupBy&&(n.groupBy=r.find(e=>[`select`,`multiSelect`,`checkbox`,`member`].includes(e.type))?.id??null),t===`calendar`&&!e.dateColumn&&(n.dateColumn=r.find(e=>e.type===`date`)?.id??null),t===`calendar`&&!n.dateColumn&&!e.dateColumn&&this.host.store&&(n.dateColumn=this.host.store.addColumn(`date`,this.labels.typeDate)),this.host.store?.updateView(e.id,n)}moreMenu(){let e=this.labels,t=this.view,n=[{id:`csv`,label:e.exportCsv,icon:`download`,run:()=>{let n=uz(this.db,t);Fz(`${(this.db.title||e.untitled).replace(/[\\/:*?"<>|]+/g,` `).trim()}.csv`,`\uFEFF${CB(this.db,n,lz(this.db,t,this.search))}`,`text/csv`)}}];this.editable&&(n.push({id:`import`,label:e.importCsv,icon:`upload`,run:()=>void this.importCsv()}),n.push({id:`view`,label:e.layout,icon:`grid`,run:()=>this.viewMenu(this.buttons.more,t)})),Kj(this.buttons.more,n,e.more)}async importCsv(){let e=this.host.store,t=await Iz(`.csv,text/csv,.tsv,text/tab-separated-values`);if(!e||!t)return;let n=await t.text(),r=t.name.endsWith(`.tsv`)?` `:`,`,i=bB(n,r).filter(e=>e.some(e=>e.trim()));i.length<2||e.tx(()=>{if(this.db.rows.every(e=>!iz(e,ZR(this.db)))){let t=EB(n,r);e.deleteRows(this.db.rows.map(e=>e.id));let i=ZR(this.db),[a,...o]=t.columns,s=new Map;a&&(e.renameColumn(i.id,a.name),s.set(a.id,i.id));for(let t of o){let n=this.db.columns.find(e=>e.name.toLowerCase()===t.name.toLowerCase()&&e.type!==`title`);n&&e.deleteColumn(n.id);let r=e.addColumn(t.type,t.name);t.options&&e.setOptions(r,t.options),s.set(t.id,r)}e.addRows(t.rows.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[s.get(e)??e,t])))),this.host.notify?.(LR(this.labels.imported,t.rows.length));return}let{index:t,missing:a}=DB(i[0],this.db.columns),o=new Map(a.map(t=>[t,e.addColumn(`text`,t)])),s=i[0].map((e,n)=>{let r=t[n];if(r)return r;let i=o.get(e.trim());return i?{id:i,name:e,type:`text`}:null}),c=new Map(this.db.columns.map(e=>[e.id,[...e.options??[]]])),l=i.slice(1).map(e=>{let t={};return s.forEach((n,r)=>{if(!n)return;let i=TB(e[r]??``,n,c.get(n.id)??[]);i!==null&&(t[n.id]=i)}),t});for(let t of this.db.columns){let n=c.get(t.id);n&&n.length!==(t.options?.length??0)&&e.setOptions(t.id,n)}e.addRows(l),this.host.notify?.(LR(this.labels.imported,l.length))})}addRow(e={},t=!1){let n=this.host.store;if(!n)return;let r=this.view;for(let t of r.filters){let n=this.db.columns.find(e=>e.id===t.column);!n||t.column in e||(t.op===`is`&&(n.type===`select`||n.type===`text`)&&t.value&&(e[n.id]=t.value),t.op===`contains`&&n.type===`multiSelect`&&t.value&&(e[n.id]=[t.value]),t.op===`checked`&&(e[n.id]=!0))}let i=n.addRow(e);t||r.type!==`table`?this.openRow(i):(this.sel={row:i,col:ZR(this.db).id},queueMicrotask(()=>this.startEdit()))}openRow(e){let t=lz(this.db,this.view,this.search).map(e=>e.id);this.host.openRow(e,t)}drawBody(){let e=this.view;e.type===`kanban`?this.drawKanban(e):e.type===`calendar`?this.drawCalendar(e):this.drawTable(e)}tableRows=[];tableCols=[];grid=null;drawTable(e){let t=this.labels,n=uz(this.db,e),r=lz(this.db,e,this.search),i=e.groupBy?this.db.columns.find(t=>t.id===e.groupBy):void 0,a=i?dz(r,i,t.noValue,t.checked,t.unchecked).filter(e=>e.rows.length||e.key!==``):[{key:``,label:``,rows:r}];this.tableCols=n,this.tableRows=[];let o=this.editable,s=e.sorts.length>0,c=I(`colgroup`,{},I(`col`,{class:`dw-db-t__gutter-col`}),n.map(t=>I(`col`,{style:{width:`${e.widths[t.id]??(t.type===`title`?240:160)}px`}})),o?I(`col`,{class:`dw-db-t__add-col`}):null),l=I(`table`,{class:`dw-db-t`},c,I(`thead`,{},I(`tr`,{},I(`th`,{class:`dw-db-t__gutter`,"aria-hidden":`true`}),n.map((e,t)=>this.headerCell(e,t,c.children[t+1])),o?I(`th`,{class:`dw-db-t__add`},Az(`plus`,t.addColumn,e=>this.addColumnMenu(e.currentTarget))):null))),u=0;for(let r of a){let a=I(`tbody`,{}),c=`${e.id}:${r.key}`;if(i){let e=!this.collapsed.has(c),t=I(`button`,{type:`button`,class:`dw-db-t__group`,"aria-expanded":String(e)},kz(e?`chevron-down`:`chevron-right`,14),r.key&&i.type!==`checkbox`&&i.type!==`member`&&i.type!==`createdBy`?I(`span`,{class:`dw-db-tag`,dataset:{color:r.color??`gray`}},r.label):I(`span`,{},r.label),I(`span`,{class:`dw-db-t__count`},String(r.rows.length)));if(t.addEventListener(`click`,()=>{e?this.collapsed.add(c):this.collapsed.delete(c),this.drawBody()}),a.append(I(`tr`,{class:`dw-db-t__group-row`},I(`td`,{colSpan:n.length+2},t))),!e){l.append(a);continue}}for(let e of r.rows){if(u>=this.limit)break;u++,this.tableRows.push(e),a.append(this.tableRow(e,n,o&&!s))}if(o&&u{let e={};i&&r.key?e[i.id]=mz({id:``,cells:{},createdAt:0,createdBy:null},i,``,r.key,r.rows.flatMap(e=>GB(QR(e,i)))):i?.type===`checkbox`&&(e[i.id]=r.key===`true`),this.addRow(e)}),a.append(I(`tr`,{class:`dw-db-t__new-row`},I(`td`,{colSpan:n.length+2},e)))}l.append(a)}let d=[],f=I(`div`,{class:`dw-db-t__wrap`,role:`grid`,tabIndex:0,"aria-label":this.db.title||t.database},l);if(d.push(f),r.length||d.push(I(`p`,{class:`dw-db__empty`},this.db.rows.length?t.noMatches:t.noRows)),r.length>u&&u>=this.limit){let e=I(`button`,{type:`button`,class:`dw-db__btn dw-db__more`},`${t.more} (${r.length-u})`);e.addEventListener(`click`,()=>{this.limit+=HB,this.drawBody()}),d.push(e)}this.grid=f,f.addEventListener(`keydown`,e=>this.onGridKey(e)),f.addEventListener(`copy`,e=>this.onCopy(e)),f.addEventListener(`paste`,e=>this.onPaste(e));let p=this.body.querySelector(`.dw-db-t__wrap`)?.scrollLeft??0,m=this.body.contains(document.activeElement);this.body.replaceChildren(...d),f.scrollLeft=p,this.markSelection(),m&&this.sel&&f.focus({preventScroll:!0})}headerCell(e,t,n){let r=this.labels,i=I(`span`,{class:`dw-db-t__name`},e.name||NR(r,e.type)),a=I(`button`,{type:`button`,class:`dw-db-t__head`,"aria-haspopup":`menu`,draggable:this.editable},kz(Gz[e.type],14),i),o=I(`th`,{dataset:{col:e.id}},a);if(a.addEventListener(`click`,()=>this.columnMenu(a,e,t)),this.editable){a.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(`application/x-docwell-column`,e.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),o.addEventListener(`dragover`,e=>{e.dataTransfer?.types.includes(`application/x-docwell-column`)&&(e.preventDefault(),o.classList.add(`is-drop`))}),o.addEventListener(`dragleave`,()=>o.classList.remove(`is-drop`)),o.addEventListener(`drop`,t=>{o.classList.remove(`is-drop`);let n=t.dataTransfer?.getData(`application/x-docwell-column`);n&&n!==e.id&&(t.preventDefault(),this.host.store?.moveColumn(n,this.db.columns.findIndex(t=>t.id===e.id)))});let t=I(`span`,{class:`dw-db-t__resize`,title:r.resize,"aria-hidden":`true`});t.addEventListener(`pointerdown`,r=>{r.preventDefault(),r.stopPropagation();let i=r.clientX,a=n.getBoundingClientRect().width||160,o=a;t.setPointerCapture(r.pointerId);let s=e=>{o=Math.max(72,Math.round(a+e.clientX-i)),n.style.width=`${o}px`},c=()=>{t.removeEventListener(`pointermove`,s),t.removeEventListener(`pointerup`,c);let n=this.view;o!==a&&this.host.store?.updateView(n.id,{widths:{...n.widths,[e.id]:o}})};t.addEventListener(`pointermove`,s),t.addEventListener(`pointerup`,c)}),o.append(t)}return o}columnMenu(e,t,n){let r=this.labels,i=this.host.store,a=this.view,o=e=>({id:e?`desc`:`asc`,label:e?r.sortDescending:r.sortAscending,icon:e?`arrow-down`:`arrow-up`,run:()=>i?.updateView(a.id,{sorts:[{column:t.id,desc:e}]})});if(!i){Kj(e,[o(!1),o(!0)],t.name);return}let s=this.db.columns,c=s.findIndex(e=>e.id===t.id),l=[{id:`rename`,label:r.rename,icon:`pencil`,run:()=>this.renameColumn(t)}];t.type!==`title`&&l.push({id:`type`,label:r.type,icon:Gz[t.type],children:HR.map(n=>({id:n,label:NR(r,n),icon:n===t.type?`check`:Gz[n],run:()=>{i.changeType(t.id,n),(n===`relation`||n===`rollup`)&&queueMicrotask(()=>this.linkSettings(e,t.id))}}))}),t.type===`relation`&&l.push({id:`relationTo`,label:r.relationTo,icon:`relation`,run:()=>this.linkSettings(e,t.id)}),t.type===`rollup`&&l.push({id:`rollup`,label:r.rollupSettings,icon:`rollup`,run:()=>this.linkSettings(e,t.id)}),l.push(o(!1),o(!0),{id:`filter`,label:r.filterBy,icon:`filter`,run:()=>{i.updateView(a.id,{filters:[...a.filters,{column:t.id,op:az(t.type)[0]}]}),this.buttons.filter.click()}}),t.type!==`title`&&l.push({id:`hide`,label:r.hide,icon:`close`,run:()=>i.updateView(a.id,{hidden:[...a.hidden,t.id]})}),l.push({id:`left`,label:r.insertLeft,icon:`plus`,run:()=>this.insertColumn(c)},{id:`right`,label:r.insertRight,icon:`plus`,run:()=>this.insertColumn(c+1)}),c>0&&l.push({id:`moveLeft`,label:r.moveLeft,icon:`arrow-up`,run:()=>i.moveColumn(t.id,c-1)}),ci.moveColumn(t.id,c+1)}),t.type!==`title`&&l.push({id:`duplicate`,label:r.duplicate,icon:`copy`,run:()=>i.duplicateColumn(t.id,`${t.name} 2`)},{id:`delete`,label:r.deleteColumn,icon:`trash`,danger:!0,run:()=>i.deleteColumn(t.id)}),Kj(e,l,t.name||NR(r,t.type))}linkSettings(e,t){let n=this.db.columns.find(e=>e.id===t),r=e.isConnected?e:this.dom.querySelector(`[data-col="${t}"]`)??this.dom;n?.type===`relation`?Vz(this.ctx(),r,n):n?.type===`rollup`&&Uz(this.ctx(),r,n)}insertColumn(e){let t=this.host.store;if(!t)return;let n=t.addColumn(`text`,this.labels.typeText,e);queueMicrotask(()=>{let e=this.db.columns.find(e=>e.id===n);e&&this.renameColumn(e)})}addColumnMenu(e){let t=this.labels;Kj(e,HR.map(e=>({id:e,label:NR(t,e),icon:Gz[e],run:()=>{let n=this.host.store?.addColumn(e,NR(t,e));queueMicrotask(()=>{let e=this.db.columns.find(e=>e.id===n);e&&this.renameColumn(e)})}})),t.addColumn)}renameColumn(e){let t=this.body.querySelector(`th[data-col="${CSS.escape(e.id)}"]`),n=this.host.store;if(!n)return;if(!t){let t=window.prompt(this.labels.columnName,e.name)?.trim();t&&n.renameColumn(e.id,t);return}let r=this.ctx();r.setEditing(!0);let i=Pz(e.name,{class:`dw-db-t__name-input`,label:this.labels.columnName,onCommit:t=>{t.trim()&&t.trim()!==e.name&&n.renameColumn(e.id,t.trim()),r.setEditing(!1),this.drawBody()},onCancel:()=>{r.setEditing(!1),this.drawBody()}});t.replaceChildren(i),i.focus(),i.select()}tableRow(e,t,n){let r=this.labels,i=I(`tr`,{dataset:{row:e.id},class:this.picked.has(e.id)?`is-picked`:``}),a=I(`td`,{class:`dw-db-t__gutter`});if(this.editable){let t=I(`input`,{type:`checkbox`,class:`dw-db-t__pick`,"aria-label":r.selectRow,checked:this.picked.has(e.id)});if(t.addEventListener(`change`,()=>{t.checked?this.picked.add(e.id):this.picked.delete(e.id),i.classList.toggle(`is-picked`,t.checked),this.drawBulk()}),a.append(t),n){let t=I(`span`,{class:`dw-db-t__grip`,draggable:!0,title:r.dragRow,"aria-hidden":`true`},kz(`grip`,14));t.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(`application/x-docwell-row`,e.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`),t.dataTransfer?.setDragImage(i,0,0)}),a.append(t),i.addEventListener(`dragover`,e=>{if(!e.dataTransfer?.types.includes(`application/x-docwell-row`))return;e.preventDefault();let t=e.clientY>i.getBoundingClientRect().top+i.offsetHeight/2;i.classList.toggle(`is-drop-below`,t),i.classList.toggle(`is-drop-above`,!t)}),i.addEventListener(`dragleave`,()=>i.classList.remove(`is-drop-below`,`is-drop-above`)),i.addEventListener(`drop`,t=>{let n=i.classList.contains(`is-drop-below`);i.classList.remove(`is-drop-below`,`is-drop-above`);let r=t.dataTransfer?.getData(`application/x-docwell-row`);r&&r!==e.id&&this.host.store&&(t.preventDefault(),this.moveRowBeside(r,e.id,n))});let n=null,o=()=>n?.classList.remove(`is-drop-below`,`is-drop-above`),s=e=>{let t=e?.closest(`tr[data-row]`);return t&&t.parentElement===i.parentElement&&t!==i?t:null},c=(e,t)=>t>e.getBoundingClientRect().top+e.offsetHeight/2;BB(t,{source:i,ghost:()=>I(`div`,{class:`dw-db-ghost--row`},iz(e,ZR(this.db))||r.untitledRow),over:(e,t,r)=>{o(),n=s(e),n&&n.classList.add(c(n,r)?`is-drop-below`:`is-drop-above`)},drop:(t,n,r)=>{let i=s(t);i?.dataset.row&&this.moveRowBeside(e.id,i.dataset.row,c(i,r))},end:o,hold:()=>this.rowMenu(i,e)})}}i.append(a);for(let n of t){let t=I(`td`,{dataset:{col:n.id},class:`dw-db-t__cell dw-db-t__cell--${n.type}`,role:`gridcell`},Zz(this.ctx(),e,n));if(n.type===`title`){let n=I(`button`,{type:`button`,class:`dw-db-t__open`,title:r.openRow},kz(`open`,13),I(`span`,{},r.openRow));n.addEventListener(`click`,t=>{t.stopPropagation(),this.openRow(e.id)}),t.append(n)}t.addEventListener(`mousedown`,t=>{t.target.closest(`input, button, a`)||(this.anchor=t.shiftKey&&this.sel?this.anchor??this.sel:null,this.sel={row:e.id,col:n.id},t.shiftKey||(this.anchor=null),this.markSelection(),t.preventDefault(),this.grid?.focus({preventScroll:!0}))});let a=!1;t.addEventListener(`pointerdown`,e=>a=e.pointerType===`touch`),t.addEventListener(`click`,e=>{e.target.closest(`input, button, a`)||e.shiftKey||(n.type===`checkbox`||a)&&this.startEdit()}),t.addEventListener(`dblclick`,()=>this.startEdit()),i.append(t)}return this.editable&&i.append(I(`td`,{class:`dw-db-t__add`})),i.addEventListener(`contextmenu`,t=>{(this.editable||this.host.copyLink)&&(t.preventDefault(),this.rowMenu(i,e))}),i}moveRowBeside(e,t,n){let r=this.host.store;if(!r||e===t)return;let i=r.rowIndex(e),a=r.rowIndex(t)+ +!!n;ithis.openRow(t.id)}];if(i&&a.push({id:`link`,label:n.copyLink,icon:`link`,run:()=>i(t.id)}),r){let e=r.rowIndex(t.id);a.push({id:`above`,label:n.insertAbove,icon:`arrow-up`,run:()=>r.addRow({},e)},{id:`below`,label:n.insertBelow,icon:`arrow-down`,run:()=>r.addRow({},e+1)},{id:`duplicate`,label:n.duplicateRow,icon:`copy`,run:()=>r.duplicateRow(t.id)},{id:`delete`,label:n.deleteRow,icon:`trash`,danger:!0,run:()=>r.deleteRows([t.id])})}Kj(e,a,n.openRow)}range(){if(!this.sel)return null;let e=e=>this.tableRows.findIndex(t=>t.id===e),t=e=>this.tableCols.findIndex(t=>t.id===e),n=this.anchor??this.sel,[r,i,a,o]=[e(n.row),e(this.sel.row),t(n.col),t(this.sel.col)];if(i<0||o<0)return null;let s=r<0?i:r,c=a<0?o:a;return{r0:Math.min(s,i),r1:Math.max(s,i),c0:Math.min(c,o),c1:Math.max(c,o)}}markSelection(){if(!this.grid)return;for(let e of this.grid.querySelectorAll(`.is-selected, .is-in-range`))e.classList.remove(`is-selected`,`is-in-range`);let e=this.range();if(!e||!this.sel)return;for(let t=e.r0;t<=e.r1;t++)for(let n=e.c0;n<=e.c1;n++)this.cellEl(this.tableRows[t].id,this.tableCols[n].id)?.classList.add(`is-in-range`);let t=this.cellEl(this.sel.row,this.sel.col);t?.classList.add(`is-selected`),t?.scrollIntoView({block:`nearest`,inline:`nearest`})}cellEl(e,t){return this.grid?.querySelector(`tr[data-row="${CSS.escape(e)}"] td[data-col="${CSS.escape(t)}"]`)??null}startEdit(e){if(!this.sel||!this.host.store)return;let t=this.db.rows.find(e=>e.id===this.sel.row),n=this.db.columns.find(e=>e.id===this.sel.col),r=this.cellEl(this.sel.row,this.sel.col);t&&n&&r&&Qz(this.ctx(),r,t,n,{initial:e,onDone:e=>{e&&this.moveSel(+(e===`down`),e===`right`?1:e===`left`?-1:0,!1),this.drawBody(),this.grid?.focus({preventScroll:!0})}})}moveSel(e,t,n){let r=this.tableRows,i=this.tableCols;if(!r.length||!i.length)return;if(!this.sel)return this.sel={row:r[0].id,col:i[0].id},this.markSelection();this.anchor=n?this.anchor??{...this.sel}:null;let a=Math.max(0,Math.min(r.length-1,r.findIndex(e=>e.id===this.sel.row)+e)),o=Math.max(0,Math.min(i.length-1,i.findIndex(e=>e.id===this.sel.col)+t));this.sel={row:r[a].id,col:i[o].id},this.markSelection()}onGridKey(e){if(e.target.closest(`input, select, textarea`))return;let t=e.ctrlKey||e.metaKey;if(t&&e.key.toLowerCase()===`z`)return e.preventDefault(),e.shiftKey?this.host.redo():this.host.undo();if(t&&e.key.toLowerCase()===`y`)return e.preventDefault(),this.host.redo();if(t)return;let n={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]}[e.key];if(n)return e.preventDefault(),this.moveSel(n[0],n[1],e.shiftKey);if(this.sel){if(e.key===`Tab`)return e.preventDefault(),this.moveSel(0,e.shiftKey?-1:1,!1);if(e.key===`Escape`)this.sel=null,this.anchor=null,this.markSelection();else{if(e.key===`Enter`||e.key===`F2`)return e.preventDefault(),this.startEdit();if(e.key===` `)return e.preventDefault(),this.db.columns.find(e=>e.id===this.sel.col)?.type===`title`?this.openRow(this.sel.row):this.startEdit();if((e.key===`Delete`||e.key===`Backspace`)&&this.host.store){e.preventDefault();let t=this.range();if(!t)return;let n=[];for(let e=t.r0;e<=t.r1;e++)for(let r=t.c0;r<=t.c1;r++){let t=this.tableCols[r];!qz.includes(t.type)&&!vz(t)&&n.push({row:this.tableRows[e].id,col:t.id,value:null})}this.host.store.setCells(n)}else if(e.key.length===1&&this.host.store){let t=this.db.columns.find(e=>e.id===this.sel.col);t&&(Kz.includes(t.type)||t.type===`select`||t.type===`multiSelect`)&&(e.preventDefault(),this.startEdit(e.key))}}}}onCopy(e){if(e.target.closest(`input, textarea`))return;let t=this.range();if(!t||!e.clipboardData)return;e.preventDefault();let n=[];for(let e=t.r0;e<=t.r1;e++){let r=[];for(let n=t.c0;n<=t.c1;n++)r.push(iz(this.tableRows[e],this.tableCols[n]));n.push(r)}e.clipboardData.setData(`text/plain`,SB(n,` `)),this.host.notify?.(LR(this.labels.copyNotice,(t.r1-t.r0+1)*(t.c1-t.c0+1)))}onPaste(e){if(e.target.closest(`input, textarea`))return;let t=this.host.store,n=e.clipboardData?.getData(`text/plain`);if(!t||!n||!this.sel)return;e.preventDefault();let r=bB(n.replace(/\r?\n$/,``),(n.includes(` `),` `)),i=this.tableRows.findIndex(e=>e.id===this.sel.row),a=this.tableCols.findIndex(e=>e.id===this.sel.col);if(i<0||a<0)return;let o=new Map(this.db.columns.map(e=>[e.id,[...e.options??[]]])),s=[],c=[];r.forEach((e,t)=>{let n=this.tableRows[i+t],r={};e.forEach((e,t)=>{let i=this.tableCols[a+t];if(!i||qz.includes(i.type)||vz(i))return;let c=TB(e,i,o.get(i.id)??[]);n?s.push({row:n.id,col:i.id,value:c}):c!==null&&(r[i.id]=c)}),n||c.push(r)}),t.tx(()=>{for(let e of this.db.columns){let n=o.get(e.id);n&&n.length!==(e.options?.length??0)&&t.setOptions(e.id,n)}t.setCells(s),c.length&&t.addRows(c)})}drawKanban(e){let t=this.labels,n=this.db.columns.find(t=>t.id===e.groupBy);if(!n){this.body.replaceChildren(I(`p`,{class:`dw-db__empty`},t.noGroupColumn));return}let r=lz(this.db,e,this.search),i=dz(r,n,t.noValue,t.checked,t.unchecked),a=uz(this.db,e).filter(e=>e.type!==`title`&&e.id!==n.id),o=ZR(this.db),s=r.flatMap(e=>GB(QR(e,n))),c=I(`div`,{class:`dw-db-k`}),l=(t,r,i,a)=>{let o=this.host.store,c=this.db.rows.find(e=>e.id===t);o&&c&&o.tx(()=>{if(r!==i&&o.setCell(t,n.id,mz(c,n,r,i,s)),a&&a!==t&&!e.sorts.length){let e=o.rowIndex(t),n=o.rowIndex(a);e0)continue;let r=I(`div`,{class:`dw-db-k__cards`,dataset:{group:e.key}}),i=I(`div`,{class:`dw-db-k__head`},e.key&&n.type!==`checkbox`&&n.type!==`member`&&n.type!==`createdBy`?I(`span`,{class:`dw-db-tag`,dataset:{color:e.color??`gray`}},e.label):I(`span`,{class:`dw-db-k__label`},e.label),I(`span`,{class:`dw-db-t__count`},String(e.rows.length)));for(let t of e.rows.slice(0,this.limit)){let i=I(`div`,{class:`dw-db-k__card`,tabIndex:0,role:`button`,draggable:this.editable&&!qz.includes(n.type),dataset:{row:t.id}},I(`div`,{class:`dw-db-k__title`},Zz(this.ctx(),t,o)),a.flatMap(e=>iz(t,e)===``||e.type===`checkbox`&&QR(t,e)!==!0?[]:[I(`div`,{class:`dw-db-k__prop`,title:e.name},Zz(this.ctx(),t,e))]));if(i.addEventListener(`click`,()=>this.openRow(t.id)),i.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this.openRow(t.id))}),i.addEventListener(`dragstart`,n=>{n.dataTransfer?.setData(`application/x-docwell-card`,JSON.stringify({row:t.id,from:e.key})),n.dataTransfer&&(n.dataTransfer.effectAllowed=`move`),i.classList.add(`is-dragging`)}),i.addEventListener(`dragend`,()=>i.classList.remove(`is-dragging`)),i.draggable){let n=I(`span`,{class:`dw-db-k__grip`,"aria-hidden":`true`},kz(`grip`,14));i.append(n);let r=null,a=e=>{let t=e?.closest(`.dw-db-k__cards`);return t&&c.contains(t)?t:null};BB(n,{source:i,ghost:()=>i.cloneNode(!0),over:e=>{r?.classList.remove(`is-drop`),r=a(e),r?.classList.add(`is-drop`)},drop:n=>{let r=a(n);r&&l(t.id,e.key,r.dataset.group??``,n?.closest(`.dw-db-k__card`)?.dataset.row)},end:()=>r?.classList.remove(`is-drop`)})}r.append(i)}if(this.editable){let i=I(`button`,{type:`button`,class:`dw-db-t__new`},kz(`plus`,14),I(`span`,{},t.newRow));i.addEventListener(`click`,()=>{let t={id:``,cells:{},createdAt:0,createdBy:null};this.addRow(e.key||n.type===`checkbox`?{[n.id]:mz(t,n,``,e.key,s)}:{},!0)}),r.append(i),r.addEventListener(`dragover`,e=>{e.dataTransfer?.types.includes(`application/x-docwell-card`)&&(e.preventDefault(),r.classList.add(`is-drop`))}),r.addEventListener(`dragleave`,e=>{r.contains(e.relatedTarget)||r.classList.remove(`is-drop`)}),r.addEventListener(`drop`,t=>{r.classList.remove(`is-drop`);let n=t.dataTransfer?.getData(`application/x-docwell-card`),i=this.host.store;if(!n||!i)return;t.preventDefault();let{row:a,from:o}=JSON.parse(n);l(a,o,e.key,t.target.closest(`.dw-db-k__card`)?.dataset.row)})}c.append(I(`section`,{class:`dw-db-k__col`,"aria-label":e.label},i,r))}this.body.replaceChildren(c)}drawCalendar(e){let t=this.labels,n=this.db.columns.find(t=>t.id===e.dateColumn);if(!n){this.body.replaceChildren(I(`p`,{class:`dw-db__empty`},t.noDateColumn));return}let r=this.editable&&n.type===`date`,{y:i,m:a}=this.month,o=_z(i,a),s=lz(this.db,e,this.search),c=new Map,l=[];for(let e of s){let t=ez(QR(e,n));t?c.set(t,[...c.get(t)??[],e]):l.push(e)}let u=ZR(this.db),d=tz(new Date),f=new Date(i,a,1).toLocaleDateString(this.host.locale,{month:`long`,year:`numeric`}),p=e=>{let t=new Date(i,a+e,1);this.month={y:t.getFullYear(),m:t.getMonth()},this.drawBody()},m=I(`div`,{class:`dw-db-c__nav`},I(`strong`,{class:`dw-db-c__month`},f),Az(`chevron-left`,t.previousMonth,()=>p(-1)),Az(`chevron-right`,t.nextMonth,()=>p(1)),Az(`calendar`,t.today,()=>{let e=new Date;this.month={y:e.getFullYear(),m:e.getMonth()},this.drawBody()},t.today)),h=o.slice(0,7).map(e=>{let[t,n,r]=e.split(`-`).map(Number);return I(`div`,{class:`dw-db-c__wd`},new Date(t,n-1,r).toLocaleDateString(this.host.locale,{weekday:`short`}))}),g=e=>{let i=I(`button`,{type:`button`,class:`dw-db-c__chip`,draggable:r,dataset:{row:e.id}},iz(e,u)||t.untitledRow);if(i.addEventListener(`click`,()=>this.openRow(e.id)),i.addEventListener(`dragstart`,t=>{t.dataTransfer?.setData(`application/x-docwell-row-date`,e.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}),r){let t=null,r=e=>{let t=e?.closest(`.dw-db-c__day`);return t&&this.body.contains(t)?t:null};BB(i,{source:i,ghost:()=>i.cloneNode(!0),over:e=>{t?.classList.remove(`is-drop`),t=r(e),t?.classList.add(`is-drop`)},drop:t=>{let i=r(t)?.dataset.day;i&&this.host.store?.setCell(e.id,n.id,i)},end:()=>t?.classList.remove(`is-drop`)})}return i},_=I(`div`,{class:`dw-db-c__grid`,role:`grid`},h);for(let e of o){let i=I(`div`,{class:`dw-db-c__day${Number(e.slice(5,7))===a+1?``:` is-out`}${e===d?` is-today`:``}`,role:`gridcell`,dataset:{day:e}},I(`span`,{class:`dw-db-c__num`},String(Number(e.slice(8)))),(c.get(e)??[]).map(g));if(this.editable&&n.type===`date`){let r=I(`button`,{type:`button`,class:`dw-db-c__add`,"aria-label":`${t.newRow} ${e}`,title:t.newRow},kz(`plus`,12));r.addEventListener(`click`,()=>this.addRow({[n.id]:e},!0)),i.append(r)}r&&(i.addEventListener(`dragover`,e=>{e.dataTransfer?.types.includes(`application/x-docwell-row-date`)&&(e.preventDefault(),i.classList.add(`is-drop`))}),i.addEventListener(`dragleave`,()=>i.classList.remove(`is-drop`)),i.addEventListener(`drop`,t=>{i.classList.remove(`is-drop`);let r=t.dataTransfer?.getData(`application/x-docwell-row-date`);r&&(t.preventDefault(),this.host.store?.setCell(r,n.id,e))})),_.append(i)}let v=[m,_];l.length&&v.push(I(`details`,{class:`dw-db-c__undated`},I(`summary`,{},LR(t.noDate,l.length)),I(`div`,{class:`dw-db-c__chips`},l.slice(0,this.limit).map(g)))),this.body.replaceChildren(I(`div`,{class:`dw-db-c`},v))}},WB={id:``,name:``,type:`table`,hidden:[],filters:[],filterMode:`and`,sorts:[],groupBy:null,dateColumn:null,widths:{}};function GB(e){return Array.isArray(e)?e.filter(e=>e&&typeof e.id==`string`):[]}var KB=`[A-Za-z0-9]{1,32}`,qB=(e,t)=>`#r-${e}-${t}`;function JB(e){let t=RegExp(`^#?r-(${KB})-(${KB})$`).exec(e);return t?{database:t[1],row:t[2]}:null}var YB=`dw-open-record`;function XB(e,t,n,r){let i=-1;if(e.state.doc.descendants((e,n)=>i>=0?!1:(e.type.name===`database`&&e.attrs.id===t&&(i=n),!0)),i<0)return!1;let a=e.view.nodeDOM(i);if(!(a instanceof HTMLElement))return!1;let o={row:n,...r};return a.dispatchEvent(new CustomEvent(YB,{detail:o})),!!o.found}async function ZB(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}var QB=e=>(e??BR).database;function $B(e){let t=QB(e);return{tableView:t.viewTable,columnName:e=>e===`title`?t.typeTitle:NR(t,e)}}var eV=e=>xw(e).content??[];function tV(e,t){let n=[];return e.forEach(e=>{e.type.name===`database`?n.push(t(e)):e.content.size?n.push(e.copy(tV(e.content,t))):n.push(e)}),s.from(n)}function nV(e){let t=!1;return e.descendants(e=>(e.type.name===`database`&&(t=!0),!t)),t}var rV=Jp.create({name:`database`,group:`block`,atom:!0,draggable:!0,selectable:!0,addOptions(){return{labels:null,doc:void 0,readOnlyDoc:!1,undoScope:!0,files:void 0,people:void 0,me:void 0,rowExtensions:void 0,notify:void 0,recordLink:void 0,onLinkCopied:void 0,linkedPages:void 0,pages:void 0,onNavigate:void 0,recordPage:void 0}},addAttributes(){return{id:{default:``,parseHTML:e=>e.getAttribute(`data-id`)??``,renderHTML:e=>({"data-id":e.id})},data:{default:null,parseHTML:e=>{try{let t=e.getAttribute(`data-db`);return t?JSON.parse(t):null}catch{return null}},renderHTML:e=>e.data?{"data-db":JSON.stringify(e.data)}:{}}}},parseHTML(){return[{tag:`div[data-type='database']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=A(t,{"data-type":`database`});if(!e.attrs.data)return[`div`,n];let r=qR(e.attrs.data),i=r.views[0],a=r.columns.filter(e=>e.type===`title`||!i?.hidden.includes(e.id));return[`div`,n,[`p`,{},[`strong`,{},r.title||QB(this.options.labels).untitled]],[`table`,{},[`tr`,{},...a.map(e=>[`th`,{},e.name])],...r.rows.map(e=>[`tr`,{},...a.map(t=>[`td`,{},iz(e,t)])])]]},renderText({node:e}){let t=e.attrs.data?qR(e.attrs.data):null;if(!t)return``;let n=ZR(t);return[t.title,...t.rows.map(e=>iz(e,n))].filter(Boolean).join(` +`)},onCreate(){let{doc:e,readOnlyDoc:t,undoScope:n}=this.options;e&&!t&&n&&(IS.getState(this.editor.state)?.undoManager)?.addToScope(iB(e))},addCommands(){let e=e=>{let t=WR(),{doc:n,readOnlyDoc:r}=this.options;return!n||r?{id:t,data:e}:(yB(n,t,e,(e,t)=>iV(this.editor,e,t)),{id:t,data:null})};return{insertDatabase:t=>({commands:n})=>n.insertContent([{type:this.name,attrs:e(t??mB($B(this.options.labels)))},{type:`paragraph`}]),groupAsDatabase:()=>({state:t,dispatch:n,commands:r})=>{let i=sV(t.selection.$from,t.selection.$to);if(!i)return!1;if(!n)return!0;let a=QB(this.options.labels),o={id:WR(),name:a.typeTitle,type:`title`},s=[o],c=i.checks?{id:WR(),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:WR(),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:[GR(`table`,a.viewTable,s)]},d=this.type.create(e(u));return r.command(({tr:e})=>(e.replaceWith(i.from,i.to,d),e.setSelection(E.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 D({key:new Un(`databaseClipboard`),props:{transformCopied:t=>!e||!nV(t.content)?t:new p(tV(t.content,t=>{let n=iB(e).get(String(t.attrs.id));return n instanceof Bb?t.type.create({...t.attrs,data:vB(n,eV)}):t}),t.openStart,t.openEnd),transformPasted:e=>nV(e.content)?new p(tV(e.content,e=>{let t=WR();if(!n)return e.type.create({...e.attrs,id:t});let i=e.attrs.data?qR(e.attrs.data):null,a=iB(n).get(String(e.attrs.id)),o=i??(a instanceof Bb?vB(a,eV):mB($B(this.options.labels)));return yB(n,t,oV(o),(e,t)=>iV(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(FS))||!e.some(e=>e.steps.some(e=>nV(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=iB(n).get(String(t.attrs.id)),a=WR();i instanceof Bb&&yB(n,a,oV(vB(i,eV)),(e,t)=>iV(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??BR,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?iB(o).get(p()):void 0;return e instanceof Bb?e:null},h=()=>{let t=m();return t?pB(t):i.attrs.data?qR(i.attrs.data):mB($B(e.labels))},g=e=>{let t=o?iB(o).get(e):void 0;if(t instanceof Bb)return pB(t);let r=null;return n.state.doc.descendants(t=>!r&&(t.type.name===`database`&&t.attrs.id===e&&t.attrs.data&&(r=qR(t.attrs.data)),!0)),r},_=new Map,v=t=>{let n=e.linkedPages;if(!n)return null;let r=_.get(t);if(!r){let e=n.open(t),i=e.onChange(re);e.doc.on(`update`,re),r={provider:e,stop:()=>{i(),e.doc.off(`update`,re),e.destroy()}},_.set(t,r)}return r.provider},y=t=>!t||t===e.linkedPages?.self,b=new Set,x=e=>{if(y(e.page))return b.add(e.database),e.database===p()?h():g(e.database);let t=v(e.page);if(!t?.synced)return null;let n=iB(t.doc).get(e.database);return n instanceof Bb?pB(n):null},S=(e,t,n)=>{let r=[],i=e=>{for(let a of e.toArray())if(a instanceof lx){if(a.nodeName===`database`){let e=String(a.getAttribute(`id`)??``);e&&r.push({page:t,database:e,title:n(e)?.title??``})}else i(a)}};return i(e),r},C=t=>{if(!s()||!o||!y(t.page))return null;if(t.database===p())return c;let n=iB(o).get(t.database);return n instanceof Bb?new gB(o,n,()=>e.me?.()??null):null},ee={local:()=>{let e=[];return n.state.doc.descendants(t=>(t.type.name===`database`&&t.attrs.id&&t.attrs.id!==p()&&e.push({page:``,database:String(t.attrs.id),title:g(String(t.attrs.id))?.title??``}),!0)),e},searchPages:e.pages?t=>e.pages.search(t).then(e=>e.filter(e=>!y(e.id)).map(e=>({id:e.id,title:e.title}))):void 0,databasesOn:e.linkedPages?e=>new Promise(t=>{let n=v(e),r=()=>{t(S(n.doc.getXmlFragment(`default`),e,e=>{let t=iB(n.doc).get(e);return t instanceof Bb?pB(t):null}))};if(n.synced)return r();let i=setTimeout(()=>{a(),t([])},8e3),a=n.onChange(()=>{n.synced&&(clearTimeout(i),a(),r())})}):void 0,read:x,pointsHere:(t,n)=>n.database===p()?y(t.page)?y(n.page):!!e.linkedPages?.self&&n.page===e.linkedPages.self:!1,writable:e=>!!C(e),link:(e,t,n,r)=>{let i=C(e),a=e.back;if(!i||!a)return!1;let o=i.snapshot().rows.find(e=>e.id===n);if(!o)return!1;let s=Cz(o.cells[a]).filter(e=>e!==t);return r&&s.push(t),i.setCell(n,a,s.length?s:null),!0},addBack:(e,t,n)=>{let r=C(e);return r?(r.tx(()=>{let e=r.addColumn(`relation`,n);r.setRelation(e,{page:``,database:p(),back:t})}),!0):!1},openRecord:(t,r)=>{y(t.page)?XB(n,t.database,r):e.onNavigate?.(`/p/${encodeURIComponent(t.page)}${qB(t.database,r)}`)}},te=e=>{for(let t of e)if((t.path.length?[String(t.path[0])]:[...t.keysChanged??[]]).some(e=>e!==p()&&b.has(e)))return re()};o&&iB(o).observeDeep(te);let ne;function re(){clearTimeout(ne),ne=setTimeout(()=>fe(),60)}let ie=()=>Oz(h(),x,a.database),ae=()=>({labels:a.database,colorNames:a.colors,locale:a.locale,files:e.files,people:e.people,store:c,linked:ee}),oe=(t,n)=>{let r=e.rowExtensions;if(!r)return null;let i=m(),o=null;if(i&&(o=c?c.rowBody(n.id):aV(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()},se=e.recordLink,ce=se?t=>{let n=se(qB(p(),t));ZB(n).then(t=>t&&e.onLinkCopied?.(n))}:void 0;f.addEventListener(YB,e=>{let t=e.detail,n=ie();n.rows.some(e=>e.id===t.row)&&(t.found=!0,t.container||f.scrollIntoView?.({block:`start`}),de(t.row,n.rows.map(e=>e.id),t.container?{container:t.container,onLeave:t.onClose}:void 0))});let le=e.recordPage,ue,de=(e,t,n)=>{u?.close(!1),ue=n,u=new nB({ctx:{...ae()},mountBody:oe,copyLink:ce,openPage:le&&!n?e=>le(p(),e):void 0,page:n},ie(),e,t,()=>{u=null,ue=void 0})},fe=()=>{let e=ie();d?.update(e,{store:c}),u?.update(e,{store:c})},pe=()=>{if(l?.(),l=null,c=null,!o)return;let t=m();if(!t&&s()){let a=i.attrs.data?qR(i.attrs.data):mB($B(e.labels)),s=p()?p():WR();yB(o,s,a,(e,t)=>iV(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=iB(o).get(s)}let a=iB(o),d=e=>{if(!e.keysChanged.has(p()))return;pe(),fe();let t=u?.row;t&&ie().rows.some(e=>e.id===t)&&de(t,[t],ue)};if(a.observe(d),t){s()&&(c=new gB(o,t,()=>e.me?.()??null));let n=t,r=()=>fe();n.observeDeep(r),l=()=>{a.unobserve(d),n.unobserveDeep(r)}}else l=()=>a.unobserve(d)};pe(),d=new UB({...ae(),openRow:de,undo:()=>n.commands.undo?.(),redo:()=>n.commands.redo?.(),notify:e.notify,copyLink:ce},ie()),f.append(d.dom);let me=s(),he=()=>{s()!==me&&(me=s(),pe(),fe())};return n.on(`update`,he),n.on(`transaction`,he),{dom:f,update(e){if(e.type!==i.type)return!1;let t=e.attrs.id!==i.attrs.id;return i=e,t&&pe(),fe(),!0},ignoreMutation:()=>!0,stopEvent:e=>e.type!==`dragstart`||e.target!==f,destroy(){l?.(),clearTimeout(ne),o&&iB(o).unobserveDeep(te);for(let e of _.values())e.stop();_.clear(),u?.close(!1),d?.destroy(),n.off(`update`,he),n.off(`transaction`,he)}}}}});function iV(e,t,n){try{Sw(e.schema,{type:`doc`,content:t},n)}catch{}}function aV(e,t){let n=e.get(`rows`);if(!(n instanceof Lb))return null;for(let e of n.toArray())if(e.get(`id`)===t){let t=e.get(`body`);return t instanceof sx&&t.length?t:null}return null}function oV(e){return{...e,rows:e.rows.map(e=>({...e,id:WR()}))}}function sV(e,t){for(let t=e.depth;t>0;t--){let n=e.node(t);if([`bulletList`,`orderedList`,`taskList`].includes(n.type.name)){let r=[];return n.forEach(e=>{let t=e.firstChild,n=[];e.forEach((e,t,r)=>{r>0&&n.push(e.toJSON())}),r.push({text:t?.textContent??``,checked:!!e.attrs.checked,rest:n})}),{from:e.before(t),to:e.after(t),checks:n.type.name===`taskList`,items:r}}}if(e.depth<1)return null;let n=e.before(1),r=t.after(Math.min(1,t.depth)||1),i=[];return e.doc.nodesBetween(n,r,(e,t)=>t=r?!1:(e.isTextblock&&e.textContent.trim()&&i.push({text:e.textContent,checked:!1,rest:[]}),!e.isTextblock)),i.length>1?{from:n,to:r,checks:!1,items:i}:null}function cV(e){let t=FS.getState(e);return t?.type&&t.binding&&t.doc?t:null}function lV(e,t){let n=cV(e);if(!n||!t?.from||!t.to)return null;try{let r=e=>PS(n.doc,n.type,fy(yg(e)),n.binding.mapping),i=r(t.from),a=r(t.to);return i===null||a===null||a<=i||a>e.doc.content.size?null:{from:i,to:a}}catch{return null}}var uV=new Un(`docwellComments`);function dV(e,t,n){let r=[];for(let i of t){let t=lV(e,i.anchor);t&&r.push(vs.inline(t.from,t.to,{class:i.id===n?`dw-comment is-active`:`dw-comment`,"data-comment":i.id}))}return xs.create(e.doc,r)}var fV=Tp.create({name:`commentHighlights`,addOptions(){return{onSelect:void 0}},addProseMirrorPlugins(){let e=()=>this.options.onSelect;return[new D({key:uV,state:{init:()=>({marks:[],active:``,decos:xs.empty}),apply(e,t,n,r){let i=e.getMeta(uV);if(i)return{...i,decos:dV(r,i.marks,i.active)};if(!e.docChanged||!t.marks.length)return t;let a=e.getMeta(FS)?.isChangeOrigin;return{...t,decos:a?dV(r,t.marks,t.active):t.decos.map(e.mapping,e.doc)}}},props:{decorations:e=>uV.getState(e)?.decos??xs.empty,handleClick(t,n,r){let i=r.target?.closest?.(`[data-comment]`)?.getAttribute(`data-comment`);return i&&e()?.(i),!1}}})]}}),pV=/^(\d{4})-(\d{2})-(\d{2})$/;function mV(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function hV(e){let t=pV.exec(e);if(!t)return null;let n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return mV(n)===e?n:null}function gV(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function _V(e,t){return Math.round((t.getTime()-e.getTime())/864e5)}function vV(e,t,n=new Date){let r=hV(e);if(!r)return e;let i=t.dates,a=_V(gV(n,0),r);return a===0?i.today:a===1?i.tomorrow:a===-1?i.yesterday:new Intl.DateTimeFormat(t.locale,{month:`short`,day:`numeric`,year:r.getFullYear()===n.getFullYear()?void 0:`numeric`}).format(r)}function yV(e,t){let n=hV(e);return n?new Intl.DateTimeFormat(t.locale,{dateStyle:`full`}).format(n):e}function bV(e,t,n,r=new Date){let i=t.dates,a=e.trim().toLowerCase(),o=!1;for(let e of new Set([i.remindWord.toLowerCase(),`remind`])){if(a.startsWith(e)){o=!0,a=a.slice(e.length).trim();break}if(a.length>=3&&e.startsWith(a)){o=!0,a=``;break}}if(o&&!n)return[];let s=gV(r,0);if(!a)return o?[1,0,7].map(e=>({date:mV(gV(s,e)),remind:o})):[{date:mV(s),remind:!1},...n?[{date:mV(gV(s,1)),remind:!0}]:[]];let c=[{words:[i.today,`today`],date:s},{words:[i.tomorrow,`tomorrow`],date:gV(s,1)},{words:[i.nextWeek,`next week`],date:gV(s,7)}];o||c.push({words:[i.yesterday,`yesterday`],date:gV(s,-1)});let l=e=>new Intl.DateTimeFormat(e,{weekday:`long`});for(let e=1;e<=7;e++){let n=gV(s,e);c.push({words:[l(t.locale).format(n),l(`en`).format(n)],date:n})}let u=[];hV(a)&&u.push({date:a,remind:o});for(let e of c)e.words.some(e=>e.toLowerCase().startsWith(a))&&u.push({date:mV(e.date),remind:o});return u.filter((e,t)=>u.findIndex(t=>t.date===e.date)===t).slice(0,5)}function xV(e,t){let n=e.toLowerCase().split(` `),r=[t.dates.remindWord,`remind`,t.dates.nextWeek.split(` `)[0]??``,`next`];return n.length>1&&n.length<=3&&r.some(e=>e&&e.toLowerCase()===n[0])}var SV=Jp.create({name:`dateMention`,group:`inline`,inline:!0,atom:!0,selectable:!0,addOptions(){return{labels:void 0,me:()=>void 0,onOpen:void 0}},addAttributes(){return{date:{default:``,parseHTML:e=>e.getAttribute(`data-date`)??``,renderHTML:e=>({"data-date":e.date})},remind:{default:``,parseHTML:e=>e.getAttribute(`data-remind`)??``,renderHTML:e=>e.remind?{"data-remind":e.remind}:{}},tz:{default:``,parseHTML:e=>e.getAttribute(`data-tz`)??``,renderHTML:e=>e.tz?{"data-tz":e.tz}:{}}}},parseHTML(){return[{tag:`span[data-type="date"]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`span`,A({"data-type":`date`,class:`dw-date`},t),vV(e.attrs.date,this.options.labels)]},renderText({node:e}){return vV(e.attrs.date,this.options.labels)},addNodeView(){let{labels:e,me:t,onOpen:n}=this.options;return({node:r,editor:i,getPos:a})=>{let o=r,s=document.createElement(`span`);s.dataset.type=`date`,s.className=`dw-date`,s.contentEditable=`false`,s.classList.toggle(`is-link`,!!n);let c=null,l=()=>{let t=o.attrs.date,n=o.attrs.remind,r=!!hV(t)&&t{let t=typeof a==`function`?a():void 0;t!==void 0&&i.chain().command(({tr:n})=>(n.setNodeMarkup(t,void 0,{...o.attrs,...e}),!0)).run()};return s.addEventListener(`mousedown`,r=>{c||(i.isEditable?(r.preventDefault(),c=TV(s,i,o,e,t(),u,()=>c=null,n)):n&&hV(o.attrs.date)&&(r.preventDefault(),n(o.attrs.date)))}),{dom:s,update(e){return e.type===o.type&&(o=e,l(),!0)},ignoreMutation:()=>!0,stopEvent:e=>s.contains(e.target)&&e.type!==`mousedown`,destroy(){c?.()}}}}});function CV(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone??``}catch{return``}}function wV(e,t,n,r){let i={date:n.date,remind:n.remind&&r?r:``,tz:n.remind&&r?CV():``};e.chain().focus().insertContentAt(t,[{type:`dateMention`,attrs:i},{type:`text`,text:` `}]).run()}function TV(e,t,n,r,i,a,o,s){let c=r.dates,l=document.createElement(`div`);l.className=`dw-date-pop`,l.setAttribute(`role`,`dialog`),l.setAttribute(`aria-label`,c.edit);let u=document.createElement(`input`);u.type=`date`,u.className=`dw-input`,u.value=n.attrs.date,u.setAttribute(`aria-label`,c.edit),u.addEventListener(`change`,()=>{hV(u.value)&&a({date:u.value})}),l.append(u);let d=n.attrs.remind;if(d&&d!==i){let e=document.createElement(`p`);e.className=`dw-date-pop__note`,e.textContent=c.someoneElse,l.append(e)}else if(i){let e=document.createElement(`label`);e.className=`dw-date-pop__check`;let t=document.createElement(`input`);t.type=`checkbox`,t.checked=d===i,t.addEventListener(`change`,()=>a(t.checked?{remind:i,tz:CV()}:{remind:``,tz:``})),e.append(t,document.createTextNode(c.remindMe));let n=document.createElement(`span`);n.className=`dw-date-pop__note`,n.textContent=c.reminderAt,l.append(e,n)}if(s){let e=document.createElement(`button`);e.type=`button`,e.className=`dw-date-pop__open`,e.textContent=c.openJournal??`Open journal`,e.addEventListener(`click`,()=>{let e=n.attrs.date;h(),hV(e)&&s(e)}),l.append(e)}document.body.append(l);let f=jj(e,l,()=>{Fj(e,l,{placement:`bottom-start`,strategy:`fixed`,middleware:[Mj(6),Pj(),Nj({padding:8})]}).then(({x:e,y:t})=>Object.assign(l.style,{left:`${e}px`,top:`${t}px`}))}),p=t=>{!l.contains(t.target)&&!e.contains(t.target)&&h()},m=e=>{e.key===`Escape`&&(e.preventDefault(),h(),t.commands.focus())};function h(){f(),l.remove(),document.removeEventListener(`mousedown`,p,!0),document.removeEventListener(`keydown`,m,!0),o()}return document.addEventListener(`mousedown`,p,!0),document.addEventListener(`keydown`,m,!0),u.focus(),h}function EV(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=kf(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.map(kf).join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function DV(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,` +`);return/\s/.test(n)}):!1}function OV(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 kV(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:OV(e)}function AV({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&&!DV(r)}function jV({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function MV({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 NV({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)){(yf.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 PV({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 FV({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Mj({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(Pj()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function IV(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 LV({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&&IV(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=jj(c,o,()=>{Fj(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 RV({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,_=PV({editor:e,items:n}),v=FV({placement:s,offset:c,flip:u,floatingUi:d});function y(e,t){switch(e){case`started`:var n;r==null||(n=r.onStart)==null||n.call(r,t);break;case`updated`:var i;r==null||(i=r.onUpdate)==null||i.call(r,t);break;case`stopped`:var a;r==null||(a=r.onExit)==null||a.call(r,t)}}return{update:async(n,d)=>{let b=t.getState(d),x=t.getState(n.state);if(!b||!x)return;let S=null,C=b.query!==x.query,ee=b.text!==x.text,te=b.range.from!==x.range.from||b.range.to!==x.range.to,ne=C||ee||te;if(!b.active&&x.active)S=`started`;else if(b.active&&!x.active)S=`stopped`;else if(x.active&&ne)S=`updated`;else return;let re=S===`stopped`?b:x,ie=n.dom.querySelector(`[data-decoration-id="${re.decorationId}"]`),ae=m(n,ie),oe=i===0||(re.query?re.query.length>=i:!1),se=(S===`started`||S===`updated`)&&oe;if(g={editor:e,range:re.range,query:re.query||``,text:re.text||``,items:o??[],command:t=>p({editor:e,range:re.range,props:t}),decorationNode:ie,clientRect:ae,loading:se,placement:s,offset:{mainAxis:c.mainAxis??4,crossAxis:c.crossAxis??0},container:l,flip:u,floatingUi:v,mount:LV({getReferenceRect:ae,contextElement:n.dom,config:v,container:l,dismissOnOutsideClick:f,dismiss:()=>h(e.view)})},S===`started`){var ce;r==null||(ce=r.onBeforeStart)==null||ce.call(r,g)}if(S===`updated`){var le;r==null||(le=r.onBeforeUpdate)==null||le.call(r,g)}if(S===`started`&&y(S,g),S===`started`||S===`updated`){if(!se)_.abort(),g={...g,items:o??[],loading:!1};else{g={...g,items:o??[],loading:!0},S=`updated`,y(S,g);let e=await _.fetch(re.query||``,a);if(e.status===`aborted`)return;if(!t.getState(n.state)?.active){_.abort();return}g=e.status===`resolved`?{...g,items:e.items,loading:!1}:{...g,loading:!1}}}S===`stopped`?(_.abort(),y(S,g),g=void 0):S===`updated`&&y(S,g)},destroy:()=>{var e;_.abort(),g&&(r==null||(e=r.onExit)==null||e.call(r,g))}}}var zV=new Un(`suggestion`);function BV({pluginKey:e=zV,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],minQueryLength:p=0,debounce:m=0,initialItems:h,placement:g=`bottom-start`,offset:_={},container:v,flip:y=!0,floatingUi:b,dismissOnOutsideClick:x=!0,render:S=()=>({}),allow:C=()=>!0,findSuggestionMatch:ee=EV,shouldShow:te,shouldResetDismissed:ne}){let re=S?.(),ie=r&&!i,ae=(n,r)=>kV(t,n,r,e);function oe(e){return AV({...e,editor:t,shouldResetDismissed:ne,effectiveAllowSpaces:ie})}let se=t=>jV({view:t,pluginKeyRef:e});return new D({key:e,view:()=>RV({editor:t,pluginKey:e,items:f,renderer:re,minQueryLength:p,debounce:m,initialItems:h,placement:g,offset:_,container:v,flip:y,floatingUi:b,dismissOnOutsideClick:x,command:d,clientRectFor:ae,dispatchExit:se}),state:NV({editor:t,char:n,effectiveAllowSpaces:ie,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:ee,allow:C,shouldShow:te,shouldKeepDismissed:oe,pluginKey:e}),props:MV({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:re,dispatchExit:se})})}var VV=BV,HV=e=>`/p/${encodeURIComponent(e)}`,UV=/^\/p\/([A-Za-z0-9_-]+)\/?(?:[?#].*)?$/;function WV(e){return UV.exec(e)?.[1]??``}function GV(e,t,n,r=`Untitled`){let i=`${n.icon?`${n.icon} `:``}${n.title||r}`;e.chain().focus().deleteRange(t).insertContent([{type:`text`,text:i,marks:[{type:`link`,attrs:{href:HV(n.id)}}]},{type:`text`,text:` `}]).run()}async function KV(e,t,n){if(!t.create)return;let{from:r,to:i,empty:a}=e.state.selection,o=a?``:e.state.doc.textBetween(r,i,` `).trim().slice(0,200),s=await t.create(o);a||!o?GV(e,{from:r,to:r},s,n):e.chain().focus().setTextSelection({from:r,to:i}).setLink({href:HV(s.id)}).run()}var qV=Tp.create({name:`pageLinks`,addOptions(){return{host:void 0,labels:null,onNavigate:void 0}},addProseMirrorPlugins(){let{host:e,onNavigate:t}=this.options,n=this.options.labels,r=[];return e&&r.push(VV({editor:this.editor,pluginKey:new Un(`pageLinks`),char:`[[`,allowSpaces:!0,allow:({state:e,range:t})=>!e.doc.resolve(t.from).parent.type.spec.code,items:async({query:t})=>(await e.search(t).catch(()=>[])).slice(0,8),render:Uj({label:n.pageLinks,empty:n.noPages,toItem:e=>({label:`${e.icon?`${e.icon} `:``}${e.title||`…`}`,description:e.hint,icon:`page`}),pick:(e,t)=>GV(e.editor,e.range,t)})})),t&&r.push(new D({key:new Un(`pageLinkClicks`),props:{handleClick:(e,n,r)=>{let i=(r.target?.closest?.(`a[href]`))?.getAttribute(`href`)??``;return!WV(i)||e.editable&&!(r.ctrlKey||r.metaKey)?!1:(r.preventDefault(),t(i),!0)}}})),r}});function JV(e,t,n){e.chain().focus().deleteRange(t).insertSyncedPage(n).run()}var YV=Jp.create({name:`syncedPage`,group:`block`,atom:!0,draggable:!0,addOptions(){return{host:void 0,pages:void 0,labels:null,onNavigate:void 0,nested:void 0}},addAttributes(){return{page:{default:``,parseHTML:e=>e.getAttribute(`data-page`)??``,renderHTML:e=>({"data-page":e.page})},title:{default:``,parseHTML:e=>e.getAttribute(`data-title`)??``,renderHTML:e=>e.title?{"data-title":e.title}:{}},icon:{default:``,parseHTML:e=>e.getAttribute(`data-icon`)??``,renderHTML:e=>e.icon?{"data-icon":e.icon}:{}},folded:{default:!1,parseHTML:e=>e.hasAttribute(`data-folded`),renderHTML:e=>e.folded?{"data-folded":``}:{}}}},parseHTML(){return[{tag:`div[data-type='syncedPage']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=`${e.attrs.icon?`${e.attrs.icon} `:``}${e.attrs.title||`…`}`;return[`div`,A(t,{"data-type":`syncedPage`}),[`a`,{href:HV(String(e.attrs.page))},n]]},addCommands(){return{insertSyncedPage:e=>({commands:t})=>t.insertContent([{type:this.name,attrs:{page:e.id,title:e.title,icon:e.icon??``}},{type:`paragraph`}])}},addProseMirrorPlugins(){let{pages:e}=this.options,t=this.options.labels;return e?[VV({editor:this.editor,pluginKey:new Un(`syncedPages`),char:`![[`,allowSpaces:!0,allow:({state:e,range:t})=>!e.doc.resolve(t.from).parent.type.spec.code,items:async({query:t})=>(await e.search(t).catch(()=>[])).slice(0,8),render:Uj({label:t.blocks.syncedPage,empty:t.noPages,toItem:e=>({label:`${e.icon?`${e.icon} `:``}${e.title||`…`}`,description:e.hint,icon:`page`}),pick:(e,t)=>JV(e.editor,e.range,t)})})]:[]},addNodeView(){let{host:e,onNavigate:t,nested:n}=this.options,r=this.options.labels.blocks;return({node:i,editor:a,getPos:o})=>{let s=i,c=String(s.attrs.page),l=document.createElement(`div`);l.className=`dw-synced`,l.dataset.type=`syncedPage`,l.contentEditable=`false`;let u=document.createElement(`div`);u.className=`dw-synced__head`;let d=document.createElement(`a`);d.className=`dw-synced__title`,d.href=HV(c);let f=Hj(`copy`,14);f.classList.add(`dw-synced__badge`);let p=document.createElement(`button`);p.type=`button`,p.className=`dw-synced__btn`;let m=document.createElement(`button`);m.type=`button`,m.className=`dw-synced__btn`,m.textContent=r.syncedOpen,u.append(f,d,p,m);let h=document.createElement(`div`);h.className=`dw-synced__body`,l.append(u,h);let g=e=>{e.preventDefault(),t?t(HV(c)):window.location.assign(HV(c))};d.addEventListener(`click`,g),m.addEventListener(`click`,g);let _=e=>{let t=typeof o==`function`?o():void 0;t!==void 0&&a.view.dispatch(a.state.tr.setNodeMarkup(t,void 0,{...s.attrs,...e}))},v=null,y=()=>v??!!s.attrs.folded;p.addEventListener(`click`,()=>{a.isEditable?_({folded:!s.attrs.folded}):(v=!y(),ne())});let b=null,x=null,S=null,C=e=>{let t=document.createElement(`p`);t.className=`dw-synced__note`,t.textContent=e,h.replaceChildren(t)},ee=()=>{S?.(),x?.destroy(),b?.destroy(),S=null,x=null,b=null},te=()=>{if(x||!e||!n)return;if(c===e.self)return C(r.syncedSelf);b=e.open(c),C(r.syncedLoading);let t=b,i=()=>{t.status===`denied`?(ee(),C(r.syncedDenied)):t.synced&&!x&&(h.replaceChildren(),x=new Vp({element:h,editable:!1,extensions:n(t.doc),editorProps:{attributes:{class:`dw-prose`}}}))};S=t.onChange(i),i()};function ne(){let t=s.attrs.title;d.textContent=`${s.attrs.icon?`${s.attrs.icon} `:``}${t||r.syncedPage}`;let n=y();l.classList.toggle(`is-folded`,n),p.textContent=n?r.syncedUnfold:r.syncedFold,p.setAttribute(`aria-expanded`,String(!n)),n?(ee(),h.replaceChildren()):e?te():h.replaceChildren()}return ne(),e?.meta(c).then(e=>{e?a.isEditable&&(e.title!==s.attrs.title||e.icon!==s.attrs.icon)?_({title:e.title,icon:e.icon}):d.textContent=`${e.icon?`${e.icon} `:``}${e.title||r.syncedPage}`:y()||C(r.syncedDenied)}),{dom:l,update(e){return e.type!==s.type||String(e.attrs.page)!==c?!1:(s=e,ne(),!0)},ignoreMutation:()=>!0,stopEvent:e=>e.target instanceof globalThis.Node&&(u.contains(e.target)||h.contains(e.target)),destroy:ee}}}});function XV(e){let t=document.createElement(`div`);t.className=`dw-diagram-editor`,t.setAttribute(`role`,`dialog`),t.setAttribute(`aria-modal`,`true`),t.setAttribute(`aria-label`,e);let n=document.createElement(`p`);n.className=`dw-diagram-editor__status`,t.append(n),document.body.append(t);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,{root:t,status:e=>{n.textContent=e,n.hidden=!e},close:()=>{t.remove(),document.body.style.overflow=r}}}async function ZV(e,t){let n=await fetch(e.resolve(t));if(!n.ok)throw Error(`loading the drawing failed (${n.status})`);return n.text()}function QV(e,t){return new File([e],t,{type:`image/svg+xml`})}function $V(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n)}function eH(e,t,n){return new Promise(r=>{let i=XV(n.slash.drawio?.label??`Draw.io`),a=document.createElement(`iframe`),o=new URL(e);for(let[e,t]of Object.entries({embed:`1`,proto:`json`,spin:`1`,saveAndExit:`1`,noExitBtn:`0`}))o.searchParams.set(e,t);a.src=o.toString(),a.className=`dw-diagram-editor__frame`,a.title=n.slash.drawio?.label??`Draw.io`;let s=document.createElement(`div`);s.className=`dw-diagram-editor__bar`;let c=document.createElement(`button`);c.type=`button`,c.className=`dw-source__btn`,c.textContent=n.blocks.cancel,c.addEventListener(`click`,()=>d(null)),s.append(c),i.root.append(s,a),i.status(``);let l=e=>a.contentWindow?.postMessage(JSON.stringify(e),o.origin),u=!1,d=e=>{window.removeEventListener(`message`,f),i.close(),r(e)},f=e=>{if(e.source!==a.contentWindow||e.origin!==o.origin||typeof e.data!=`string`)return;let n;try{n=JSON.parse(e.data)}catch{return}switch(n.event){case`init`:l({action:`load`,autosave:0,xml:t?`data:image/svg+xml;base64,${$V(t)}`:``});break;case`save`:u=!0,l({action:`export`,format:`xmlsvg`,spinKey:`saving`});break;case`export`:{let e=n.data??``,t=e.indexOf(`,`),r=e.slice(0,t),i=e.slice(t+1),a=r.includes(`;base64`)?new TextDecoder().decode(Uint8Array.from(atob(i),e=>e.charCodeAt(0))):decodeURIComponent(i);d(u?a:null);break}case`exit`:d(null)}};window.addEventListener(`message`,f)})}async function tH(e,t,n){let r=XV(n.slash.excalidraw?.label??`Excalidraw`);r.status(``);try{let{openExcalidraw:i}=await e();return await i(r.root,t,n)}finally{r.close()}}var nH=!1;function rH(e){return Jp.create({name:e,group:`block`,atom:!0,draggable:!0,addOptions(){return{host:void 0,loadExcalidraw:void 0,labels:null,drawioUrl:void 0,onError:void 0}},addAttributes(){return{src:{default:``},alt:{default:``}}},parseHTML(){return[{tag:`figure[data-type='${e}']`,getAttrs:e=>({src:e.querySelector(`img`)?.getAttribute(`src`)??``})}]},renderHTML({node:t,HTMLAttributes:n}){return[`figure`,A(n,{"data-type":e}),[`img`,{src:String(t.attrs.src),alt:String(t.attrs.alt||e)}]]},addCommands(){return{insertDiagram:e=>({commands:t})=>(nH=!0,t.insertContent({type:e,attrs:{src:``}}))}},addNodeView(){return({node:t,editor:n,getPos:r})=>{let i=this.options,a=i.labels,o=document.createElement(`figure`);o.className=`dw-diagram dw-diagram--${e}`,o.setAttribute(`data-type`,e);let s=document.createElement(`img`);s.className=`dw-diagram__img`;let c=document.createElement(`p`);c.className=`dw-diagram__empty`,c.textContent=e===`drawio`?a.blocks.emptyDrawio:a.blocks.emptyExcalidraw;let l=document.createElement(`button`);l.type=`button`,l.className=`dw-diagram__edit`,l.textContent=a.blocks.edit,o.append(s,c,l);let u=``,d=t=>{u=String(t.attrs.src??``),s.hidden=!u,c.hidden=!!u,u&&(s.src=i.host?i.host.resolve(u):u,s.alt=String(t.attrs.alt||a.slash[e]?.label||e))};d(t);let f=!1,p=async()=>{if(!f&&m()&&i.host?.upload){f=!0;try{let t=u?await ZV(i.host,u):``,o=e===`drawio`?await eH(i.drawioUrl||`https://embed.diagrams.net`,t,a):await tH(i.loadExcalidraw,t,a);if(o===null)return;let s=await i.host.upload(QV(o,`${e===`drawio`?`diagram.drawio`:`drawing.excalidraw`}.svg`)),c=typeof r==`function`?r():void 0;c!==void 0&&iH(n,c,e,s.url)}catch(e){i.onError?.(e)}finally{f=!1}}},m=()=>n.isEditable&&!!i.host?.upload&&(e===`drawio`||!!i.loadExcalidraw),h=()=>l.hidden=!m()||!u;return h(),n.on(`update`,h),o.addEventListener(`dblclick`,()=>void p()),c.addEventListener(`click`,()=>void p()),l.addEventListener(`click`,()=>void p()),nH&&(nH=!1,queueMicrotask(()=>void p())),{dom:o,update:t=>t.type.name===e&&(d(t),h(),!0),ignoreMutation:()=>!0,stopEvent:e=>e.target===l||e.target===c,destroy:()=>n.off(`update`,h)}}}})}function iH(e,t,n,r){e.chain().setNodeSelection(t).updateAttributes(n,{src:r}).run()}var aH=rH(`drawio`),oH=rH(`excalidraw`),sH=null;function cH(e){sH?.();let t=document.createElement(`div`);t.className=`dw-source`,t.setAttribute(`role`,`dialog`),t.setAttribute(`aria-label`,e.label);let n=document.createElement(e.multiline?`textarea`:`input`);n.className=`dw-source__field`+(e.monospace?` dw-source__field--mono`:``),n.value=e.value,n.setAttribute(`aria-label`,e.label),n.spellcheck=!1,n instanceof HTMLTextAreaElement&&(n.rows=Math.min(16,Math.max(4,e.value.split(` +`).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=jj(e.anchor,t,()=>{Fj(e.anchor,t,{placement:`bottom-start`,middleware:[Mj(6),Pj(),Nj({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(),sH===d&&(sH=null),n||e.onCancel?.())}let d=()=>u();return sH=d,n.focus(),e.multiline||n.select(),d}var lH={open:`green`,started:`yellow`,draft:`gray`,merged:`purple`,done:`blue`,closed:`red`,canceled:`gray`},uH=[{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 dH(e){let t;try{t=new URL(e.trim())}catch{return null}for(let e of uH){let n=e.pattern.exec(t.href);if(n)return{src:e.src(n,t),ratio:e.ratio??`video`}}return null}function fH(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`?t.href:``}catch{return``}}var pH=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}};function mH(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;cH({anchor:i,value:`https://`,label:n,labels:{done:r.done,cancel:r.cancel,remove:r.remove},onSave:t=>e(fH(t)),onCancel:()=>e(``)})})}async function hH(e,t,n,r){let i=await mH(e,t,t.blocks.embedUrl);i&&(dH(i)?e.chain().focus().insertEmbed(i).run():await _H(e,i,n,r))}async function gH(e,t,n,r){let i=await mH(e,t,t.blocks.linkUrl);i&&await _H(e,i,n,r)}async function _H(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 vH=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=fH(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=fH(e),i=dH(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}: ${pH(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.target=`_blank`,s.rel=`noopener noreferrer`,s.textContent=pH(r),o.append(s),n.append(a,o)},i=String(e.attrs.url);return r(i),{dom:n,update:e=>e.type.name===`embed`&&(e.attrs.url!==i&&r(i=String(e.attrs.url)),!0),ignoreMutation:()=>!0,stopEvent:e=>e.target instanceof Element&&!!e.target.closest(`a`)}}}}),yH=Jp.create({name:`linkCard`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){let e=e=>({default:``,parseHTML:t=>t.getAttribute(`data-${e}`)??``,renderHTML:t=>({[`data-${e}`]:t[e]})});return{url:e(`url`),title:e(`title`),description:e(`description`),image:e(`image`),site:e(`site`),kind:e(`kind`),status:e(`status`),state:e(`state`),meta:e(`meta`)}},parseHTML(){return[{tag:`div[data-type='link-card']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=fH(String(e.attrs.url));return[`div`,A(t,{"data-type":`link-card`}),[`a`,{href:n},String(e.attrs.title||n)]]},addCommands(){return{insertLinkCard:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{url:e.url,title:e.title??``,description:e.description??``,image:e.image??``,site:e.site??``,kind:e.kind??``,status:e.status??``,state:e.state??``,meta:e.meta??``}})}},addNodeView(){return({node:e})=>{let t=document.createElement(`a`);t.className=`dw-linkcard`,t.setAttribute(`data-type`,`link-card`),t.contentEditable=`false`,t.target=`_blank`,t.rel=`noopener noreferrer`;let n=e=>{let n=fH(String(e.url));t.href=n,t.replaceChildren();let r=document.createElement(`span`);r.className=`dw-linkcard__text`;let i=document.createElement(`span`);i.className=`dw-linkcard__title`,i.textContent=String(e.title||``)||pH(n);let a=String(e.kind||``);if(t.dataset.kind=a,e.status){let t=document.createElement(`span`);t.className=`dw-linkcard__head`;let n=document.createElement(`span`);n.className=`dw-linkcard__status`,n.dataset.color=lH[String(e.state)]??`gray`,n.textContent=String(e.status),t.append(n,i),r.append(t)}else r.append(i);if(e.description){let t=document.createElement(`span`);t.className=`dw-linkcard__desc`,t.textContent=String(e.description),r.append(t)}let o=document.createElement(`span`);o.className=`dw-linkcard__site`,o.textContent=[String(e.site||``)||pH(n),String(e.meta||``)].filter(Boolean).join(` · `),r.append(o),t.append(r);let s=fH(String(e.image||``));if(s.startsWith(`https:`)){let e=document.createElement(`img`);e.className=a.startsWith(`github.`)?`dw-linkcard__image dw-linkcard__image--avatar`:`dw-linkcard__image`,e.src=s,e.alt=``,e.loading=`lazy`,e.referrerPolicy=`no-referrer`,e.onerror=()=>e.remove(),t.append(e)}},r=e;return n(e.attrs),t.addEventListener(`click`,e=>{this.editor.view.editable&&!(e.ctrlKey||e.metaKey)&&e.preventDefault()}),{dom:t,update:e=>e.type.name===`linkCard`&&(e.attrs!==r.attrs&&n(e.attrs),r=e,!0),ignoreMutation:()=>!0}}}}),bH=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,xH=Jp.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,A(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,i=new Set([`src`,`width`,`height`]);return({node:a,getPos:o,HTMLAttributes:s,editor:c})=>{let l=document.createElement(`img`);l.draggable=!1;let u=A(this.options.HTMLAttributes,s);Object.entries(u).forEach(([e,t])=>{if(t!=null)switch(e){case`src`:case`width`:case`height`:break;default:l.setAttribute(e,t)}}),u.src!==null&&(l.src=u.src);let d={...s},f=e=>{typeof e==`string`&&e!==``?l.getAttribute(`src`)!==e&&(l.src=e):(l.hasAttribute(`src`)&&l.removeAttribute(`src`),l.src!==``&&(l.src=``))};f(s.src);let p=new qp({element:l,editor:c,node:a,getPos:o,onResize:(e,t)=>{l.style.width=`${e}px`,l.style.height=`${t}px`},onCommit:(e,t)=>{let n=o();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:e=>{if(e.type!==a.type)return!1;let t=Lu(e,c.extensionManager.attributes.filter(t=>t.type===e.type.name));return Object.keys(d).forEach(e=>{!i.has(e)&&!(e in t)&&l.removeAttribute(e)}),Object.entries(t).forEach(([e,t])=>{i.has(e)||(t==null?l.removeAttribute(e):l.setAttribute(e,t))}),f(t.src),d=t,!0},options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),m=p.dom,h=()=>{m.style.visibility=``,m.style.pointerEvents=``};return m.style.visibility=`hidden`,m.style.pointerEvents=`none`,l.complete&&l.naturalWidth>0?h():(l.onload=h,l.onerror=h),p}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[Up({find:bH,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function SH(e,t){return/^(audio|video)\//.test(e)||/\.(mp3|mp4|mpeg|mpga|m4a|wav|webm|ogg|oga|flac|aac|opus|mov)$/i.test(t)}async function CH(e,t,n,r){if(t.upload)for(let i of n){let n=await t.upload(i),a=n.mime.startsWith(`image/`)?{type:`image`,attrs:{src:n.url,alt:n.name}}:{type:`fileAttachment`,attrs:{url:n.url,name:n.name,size:n.size,mime:n.mime,view:Rj(n.mime,n.name)?`preview`:`card`}};e.chain().focus().insertContentAt(r??e.state.selection.to,a).run(),r=void 0}}var wH=xH.extend({addOptions(){return{...this.parent(),host:void 0,inline:!1,allowBase64:!1}},addNodeView(){return({node:e})=>{let t=document.createElement(`img`),n=e=>{let n=String(e.attrs.src??``);t.src=this.options.host?this.options.host.resolve(n):n,t.alt=String(e.attrs.alt??``),e.attrs.title&&(t.title=String(e.attrs.title))};return n(e),t.draggable=!0,{dom:t,update:t=>t.type===e.type&&(n(t),!0)}}}});function TH(e){if(!e)return``;let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n({editor:e,commands:t})=>{let n=e.getAttributes(this.name);return!e.isActive(this.name)||!Rj(n.mime,n.name)?!1:t.updateAttributes(this.name,{view:n.view===`preview`?`card`:`preview`})}}},parseHTML(){return[{tag:`div[data-type=file]`,getAttrs:e=>({url:e.getAttribute(`data-url`)??``,name:e.getAttribute(`data-name`)??e.textContent??`file`,size:Number(e.getAttribute(`data-size`)??0),mime:e.getAttribute(`data-mime`)??``,view:e.getAttribute(`data-view`)===`preview`?`preview`:`card`})}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,A(t,{"data-type":`file`,"data-url":e.attrs.url,"data-name":e.attrs.name,"data-size":e.attrs.size,"data-mime":e.attrs.mime,"data-view":e.attrs.view}),[`a`,{href:e.attrs.url,download:e.attrs.name},e.attrs.name]]},addNodeView(){return({node:e,editor:t,getPos:n})=>{let{host:r,loadPdf:i,labels:a}=this.options,o=document.createElement(`div`);o.className=`dw-file-block`,o.setAttribute(`data-type`,`file`);let s=document.createElement(`div`);s.className=`dw-file`;let c=document.createElement(`a`);c.className=`dw-file__name`,c.target=`_blank`,c.rel=`noopener`;let l=document.createElement(`span`);l.className=`dw-file__size`,s.append(c,l),o.append(s);let u=null,d=null,f=e,p=async()=>{let e=r?.transcribe;if(e&&u&&a){u.disabled=!0,u.textContent=a.blocks.transcribing,d&&(d.textContent=``);try{let r=await e(String(f.attrs.url??``),String(f.attrs.name??`file`)),i=typeof n==`function`?n():void 0;i!==void 0&&r&&t.chain().insertContentAt(i+f.nodeSize,r).run()}catch(e){d&&(d.textContent=e instanceof Error&&e.message?e.message:a.blocks.transcribeFailed)}finally{u&&(u.disabled=!1,u.textContent=a.blocks.transcribe)}}},m=null,h=null,g=``,_=e=>{let n=String(e.attrs.url??``),_=r?r.resolve(n):n;c.href=_,c.textContent=String(e.attrs.name??`file`),l.textContent=TH(Number(e.attrs.size??0)),f=e;let v=!!r?.transcribe&&!!a&&t.isEditable&&SH(String(e.attrs.mime??``),String(e.attrs.name??``));v&&!u&&a?(u=document.createElement(`button`),u.type=`button`,u.className=`dw-file__action`,u.textContent=a.blocks.transcribe,u.title=a.blocks.transcribeHint,u.setAttribute(`data-testid`,`file-transcribe`),u.addEventListener(`click`,()=>void p()),d=document.createElement(`span`),d.className=`dw-file__status`,d.setAttribute(`role`,`status`),s.append(u),o.append(d)):!v&&u&&(u.remove(),d?.remove(),u=d=null),!(e.attrs.view===`preview`&&Rj(e.attrs.mime,e.attrs.name)&&n)||!i||!a?(h?.(),h=null,m?.remove(),m=null,g=``):g!==_&&(h?.(),m||(m=document.createElement(`div`),m.className=`dw-pdf`,m.tabIndex=0,m.setAttribute(`role`,`document`),o.append(m)),m.setAttribute(`aria-label`,String(e.attrs.name??`PDF`)),g=_,h=zj(m,_,i,a))};return _(e),{dom:o,update:t=>t.type===e.type&&(_(t),!0),stopEvent:e=>!!u&&u.contains(e.target)||!!m&&m.contains(e.target)&&e.type!==`mousedown`,ignoreMutation:()=>!0,destroy:()=>h?.()}}}}),DH=Tp.create({name:`fileDrop`,addOptions(){return{host:void 0,onError:void 0}},addProseMirrorPlugins(){let e=this.options.host;return e?[OH(()=>this.editor,e,this.options.onError)]:[]}});function OH(e,t,n){let r=(r,i)=>{let a=e();return!a||!r.length||!t.upload?!1:(CH(a,t,r,i).catch(n),!0)};return new D({key:new Un(`docwellFileDrop`),props:{handlePaste(e,t){return r([...t.clipboardData?.files??[]])},handleDrop(e,t){let n=[...t.dataTransfer?.files??[]];if(!n.length)return!1;let i=e.posAtCoords({left:t.clientX,top:t.clientY});return t.preventDefault(),r(n,i?.pos)}}})}var kH=new Un(`dwFind`),AH=``;function jH(e,t,n=!1){if(!t)return[];let r=n?t:t.toLowerCase(),i=[];return e.descendants((e,t)=>{if(!e.isTextblock)return!0;let a=``,o=[];e.forEach((e,n)=>{let r=t+1+n;if(e.isText){let t=e.text??``;for(let e=0;ee.from>=r);return a===-1&&(a=i.length?0:-1),{term:t,caseSensitive:n,matches:i,current:a}}function NH(e,t){return t&&e.setSelection(T.create(e.doc,t.from,t.to)).scrollIntoView(),e}var PH=Tp.create({name:`findReplace`,addCommands(){return{setFind:(e,t=!1)=>({state:n,tr:r,dispatch:i})=>{let a=MH(n.doc,e,t,n.selection.from);return r.setMeta(kH,{term:e,caseSensitive:t,near:n.selection.from}),i&&i(NH(r,a.matches[a.current])),!0},findStep:e=>({state:t,tr:n,dispatch:r})=>{let i=kH.getState(t);if(!i?.matches.length)return!1;let a=(i.current+e+i.matches.length)%i.matches.length;return n.setMeta(kH,{current:a}),r&&r(NH(n,i.matches[a])),!0},replaceCurrent:e=>({state:t,tr:n,dispatch:r})=>{let i=kH.getState(t),a=i?.matches[i.current];if(!i||!a)return!1;if(r){n.insertText(e,a.from,a.to),n.setMeta(kH,{term:i.term,caseSensitive:i.caseSensitive,near:a.from+e.length});let t=MH(n.doc,i.term,i.caseSensitive,a.from+e.length);r(NH(n,t.matches[t.current]))}return!0},replaceAll:e=>({state:t,tr:n,dispatch:r})=>{let i=kH.getState(t);if(!i?.matches.length)return!1;if(r){for(let t of[...i.matches].reverse())n.insertText(e,t.from,t.to);n.setMeta(kH,{term:i.term,caseSensitive:i.caseSensitive,near:0}),r(n)}return!0},clearFind:()=>({tr:e,dispatch:t})=>(t&&t(e.setMeta(kH,{clear:!0})),!0)}},addProseMirrorPlugins(){let e={term:``,caseSensitive:!1,matches:[],current:-1};return[new D({key:kH,state:{init:()=>e,apply(t,n,r,i){let a=t.getMeta(kH);if(a&&`clear`in a)return e;if(a&&`term`in a)return MH(i.doc,a.term,a.caseSensitive,a.near);if(a&&`current`in a)return{...n,current:a.current};if(!n.term||!t.docChanged)return n;let o=n.matches[n.current]?.from??0;return MH(i.doc,n.term,n.caseSensitive,t.mapping.map(o))}},props:{decorations(e){let t=kH.getState(e);return t?.matches.length?xs.create(e.doc,t.matches.map((e,n)=>vs.inline(e.from,e.to,{class:n===t.current?`dw-find dw-find-current`:`dw-find`}))):null}}})]}}),L=class e extends Error{constructor(t,n){var r=`KaTeX parse error: `+t,i,a,o=n&&n.loc;if(o&&o.start<=o.end){var s=o.lexer.input;i=o.start,a=o.end,i===s.length?r+=` at end of input: `:r+=` at position `+(i+1)+`: `;var c=s.slice(i,a).replace(/[^]/g,`$&̲`),l=i>15?`…`+s.slice(i-15,i):s.slice(0,i),u=a+15e.replace(FH,`-$1`).toLowerCase(),LH={"&":`&`,">":`>`,"<":`<`,'"':`"`,"'":`'`},RH=/[&><"']/g,zH=e=>String(e).replace(RH,e=>LH[e]),BH=e=>e.type===`ordgroup`||e.type===`color`?e.body.length===1?BH(e.body[0]):e:e.type===`font`?BH(e.body):e,VH=new Set([`mathord`,`textord`,`atom`]),HH=e=>VH.has(BH(e).type),UH=e=>{var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==`:`||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():`_relative`},WH={displayMode:{type:`boolean`,description:`Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.`,cli:`-d, --display-mode`},output:{type:{enum:[`htmlAndMathml`,`html`,`mathml`]},description:`Determines the markup language of the output.`,cli:`-F, --format `},leqno:{type:`boolean`,description:`Render display math in leqno style (left-justified tags).`},fleqn:{type:`boolean`,description:`Render display math flush left.`},throwOnError:{type:`boolean`,default:!0,cli:`-t, --no-throw-on-error`,cliDescription:`Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.`},errorColor:{type:`string`,default:`#cc0000`,cli:`-c, --error-color `,cliDescription:`A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.`,cliProcessor:e=>`#`+e},macros:{type:`object`,cli:`-m, --macro `,cliDescription:`Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).`,cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:`number`,description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:`--min-rule-thickness `,cliProcessor:parseFloat},colorIsTextColor:{type:`boolean`,description:`Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.`,cli:`-b, --color-is-text-color`},strict:{type:[{enum:[`warn`,`ignore`,`error`]},`boolean`,`function`],description:`Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.`,cli:`-S, --strict`,cliDefault:!1},trust:{type:[`boolean`,`function`],description:`Trust the input, enabling all HTML features such as \\url.`,cli:`-T, --trust`},maxSize:{type:`number`,default:1/0,description:`If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large`,processor:e=>Math.max(0,e),cli:`-s, --max-size `,cliProcessor:parseInt},maxExpand:{type:`number`,default:1e3,description:`Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.`,processor:e=>Math.max(0,e),cli:`-e, --max-expand `,cliProcessor:e=>e===`Infinity`?1/0:parseInt(e)},globalGroup:{type:`boolean`,cli:!1}};function GH(e){if(typeof e!=`string`)return e.enum[0];switch(e){case`boolean`:return!1;case`string`:return``;case`number`:return 0;case`object`:return{};default:throw Error(`Unexpected schema type; settings must declare an explicit default.`)}}function KH(e){return Object.prototype.hasOwnProperty.call(e,`default`)&&e.default!==void 0?e.default:GH(Array.isArray(e.type)?e.type[0]:e.type)}function qH(e,t,n,r){var i=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0,a=Object.prototype.hasOwnProperty.call(r,`processor`)?r.processor:void 0;e[t]=i===void 0?KH(r):a?a(i):i}var JH=class{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e||={};for(var t of Object.keys(WH)){var n=WH[t];n&&qH(this,t,e,n)}}reportNonstrict(e,t,n){var r=this.strict;if(typeof r==`function`&&(r=r(e,t,n)),r&&r!==`ignore`){if(r===!0||r===`error`)throw new L(`LaTeX-incompatible input and strict mode is set to 'error': `+(t+` [`+e+`]`),n);r===`warn`?typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to 'warn': `+(t+` [`+e+`]`)):typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to `+(`unrecognized '`+r+`': `+t+` [`+e+`]`))}}useStrictBehavior(e,t,n){var r=this.strict;if(typeof r==`function`)try{r=r(e,t,n)}catch{r=`error`}return!r||r===`ignore`?!1:r===!0||r===`error`?!0:r===`warn`?(typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to 'warn': `+(t+` [`+e+`]`)),!1):(typeof console<`u`&&console.warn(`LaTeX-incompatible input and strict mode is set to `+(`unrecognized '`+r+`': `+t+` [`+e+`]`)),!1)}isTrusted(e){if(`url`in e&&e.url&&!e.protocol){var t=UH(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},YH=class{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return iU[aU[this.id]]}sub(){return iU[oU[this.id]]}fracNum(){return iU[sU[this.id]]}fracDen(){return iU[cU[this.id]]}cramp(){return iU[lU[this.id]]}text(){return iU[uU[this.id]]}isTight(){return this.size>=2}},XH=0,ZH=1,QH=2,$H=3,eU=4,tU=5,nU=6,rU=7,iU=[new YH(XH,0,!1),new YH(ZH,0,!0),new YH(QH,1,!1),new YH($H,1,!0),new YH(eU,2,!1),new YH(tU,2,!0),new YH(nU,3,!1),new YH(rU,3,!0)],aU=[eU,tU,eU,tU,nU,rU,nU,rU],oU=[tU,tU,tU,tU,rU,rU,rU,rU],sU=[QH,$H,eU,tU,nU,rU,nU,rU],cU=[$H,$H,tU,tU,rU,rU,rU,rU],lU=[ZH,ZH,$H,$H,tU,tU,rU,rU],uU=[XH,ZH,QH,$H,QH,$H,QH,$H],R={DISPLAY:iU[XH],TEXT:iU[QH],SCRIPT:iU[eU],SCRIPTSCRIPT:iU[nU]},dU=[{name:`latin`,blocks:[[256,591],[768,879]]},{name:`cyrillic`,blocks:[[1024,1279]]},{name:`armenian`,blocks:[[1328,1423]]},{name:`brahmic`,blocks:[[2304,4255]]},{name:`georgian`,blocks:[[4256,4351]]},{name:`cjk`,blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:`hangul`,blocks:[[44032,55215]]}];function fU(e){for(var t=0;t=i[0]&&e<=i[1])return n.name}return null}var pU=[];dU.forEach(e=>e.blocks.forEach(e=>pU.push(...e)));function mU(e){for(var t=0;t=pU[t]&&e<=pU[t+1])return!0;return!1}var hU=e=>e+` `+e,gU=80,_U=function(e,t){return`M95,`+(622+e+t)+` 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 @@ -178,7 +178,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`},dU=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`},vU=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+` @@ -188,7 +188,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`},fU=function(e,t){return`M983 `+(10+e+t)+` +M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},yU=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 @@ -197,7 +197,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`},pU=function(e,t){return`M424,`+(2398+e+t)+` +M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},bU=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 @@ -207,18 +207,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`},mU=function(e,t){return`M473,`+(2713+e+t)+` +h400000v`+(40+e)+`h-400000z`},xU=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`},hU=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},gU=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`},SU=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},CU=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`},_U=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=uU(t,lU);break;case`sqrtSize1`:r=dU(t,lU);break;case`sqrtSize2`:r=fU(t,lU);break;case`sqrtSize3`:r=pU(t,lU);break;case`sqrtSize4`:r=mU(t,lU);break;case`sqrtTall`:r=gU(t,lU,n)}return r},vU=function(e,t){switch(e){case`⎜`:return cU(`M291 0 H417 V`+t+` H291z`);case`∣`:return cU(`M145 0 H188 V`+t+` H145z`);case`∥`:return cU(`M145 0 H188 V`+t+` H145z`)+cU(`M367 0 H410 V`+t+` H367z`);case`⎟`:return cU(`M457 0 H583 V`+t+` H457z`);case`⎢`:return cU(`M319 0 H403 V`+t+` H319z`);case`⎥`:return cU(`M263 0 H347 V`+t+` H263z`);case`⎪`:return cU(`M384 0 H504 V`+t+` H384z`);case`⏐`:return cU(`M312 0 H355 V`+t+` H312z`);case`‖`:return cU(`M257 0 H300 V`+t+` H257z`)+cU(`M478 0 H521 V`+t+` H478z`);default:return``}},yU={doubleleftarrow:`M262 157 +219 661 l218 661zM702 `+t+`H400000v`+(40+e)+`H742z`},wU=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=_U(t,gU);break;case`sqrtSize1`:r=vU(t,gU);break;case`sqrtSize2`:r=yU(t,gU);break;case`sqrtSize3`:r=bU(t,gU);break;case`sqrtSize4`:r=xU(t,gU);break;case`sqrtTall`:r=CU(t,gU,n)}return r},TU=function(e,t){switch(e){case`⎜`:return hU(`M291 0 H417 V`+t+` H291z`);case`∣`:return hU(`M145 0 H188 V`+t+` H145z`);case`∥`:return hU(`M145 0 H188 V`+t+` H145z`)+hU(`M367 0 H410 V`+t+` H367z`);case`⎟`:return hU(`M457 0 H583 V`+t+` H457z`);case`⎢`:return hU(`M319 0 H403 V`+t+` H319z`);case`⎥`:return hU(`M263 0 H347 V`+t+` H263z`);case`⎪`:return hU(`M384 0 H504 V`+t+` H384z`);case`⏐`:return hU(`M312 0 H355 V`+t+` H312z`);case`‖`:return hU(`M257 0 H300 V`+t+` H257z`)+hU(`M478 0 H521 V`+t+` H478z`);default:return``}},EU={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 @@ -264,10 +264,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:cU(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:cU(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:cU(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:cU(`M40 281 V448H0V74H40V241H400000v40z`),leftToFrom:`M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23 + 71.5 23h399859zM103 281v-40h399897v40z`,leftlinesegment:hU(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:hU(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:hU(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:hU(`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:cU(`M0 50 h400000 v40H0z m0 194h40000v40H0z`),midbrace:`M200428 334 + 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,longequal:hU(`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 @@ -316,7 +316,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:cU(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:cU(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:cU(`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:hU(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:hU(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:hU(`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 @@ -389,7 +389,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`},bU=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`},DU=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 @@ -417,20 +417,20 @@ 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 xU(e){return`toText`in e}var SU=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{if(xU(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},CU={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},wU={ex:!0,em:!0,mu:!0},TU=function(e){return typeof e!=`string`&&(e=e.unit),e in CU||e in wU||e===`ex`},EU=function(e,t){var n;if(e.unit in CU)n=CU[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`},DU=function(e){return e.filter(e=>e).join(` `)},OU=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=kH(n)+`:`+r+`;`)}return t},kU=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)}},AU=function(e){var t=document.createElement(e);t.className=DU(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/=\x00-\x1f]/,MU=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+MH(DU(this.classes))+`"`);var n=OU(this.style);n&&(t+=` style="`+MH(n)+`"`);for(var r of Object.keys(this.attributes)){if(jU.test(r))throw new L(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+MH(this.attributes[r])+`"`}t+=`>`;for(var i=0;i`,t},NU=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,kU.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return AU.call(this,`span`)}toMarkup(){return MU.call(this,`span`)}},PU=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,kU.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 AU.call(this,`a`)}toMarkup(){return MU.call(this,`a`)}},FU=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=``+MH(this.alt)+``,e}},IU={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},LU=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=aU(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=IU[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=DU(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=`0&&(n+=`margin-right:`+z(this.italic)+`;`),n+=OU(this.style),n&&(e=!0,t+=` style="`+MH(n)+`"`);var r=MH(this.text);return e?(t+=`>`,t+=r,t+=``,t):r}},RU=class{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);for(var t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);for(var n=0;n`;for(var n=0;n`,e}},zU=class{constructor(e,t){this.pathName=void 0,this.alternate=void 0,this.pathName=e,this.alternate=t}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return this.alternate?e.setAttribute(`d`,this.alternate):e.setAttribute(`d`,yU[this.pathName]),e}toMarkup(){return this.alternate?``:``}},BU=class{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`line`);for(var t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);return e}toMarkup(){var e=``,e}};function VU(e){if(e instanceof LU)return e;throw Error(`Expected symbolNode but got `+String(e)+`.`)}function HU(e){if(e instanceof NU)return e;throw Error(`Expected span but got `+String(e)+`.`)}var UU=e=>e instanceof NU||e instanceof PU||e instanceof SU,WU={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}},GU={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},KU={Å:`A`,Ð:`D`,Þ:`o`,å:`a`,ð:`d`,þ:`o`,А:`A`,Б:`B`,В:`B`,Г:`F`,Д:`A`,Е:`E`,Ж:`K`,З:`3`,И:`N`,Й:`N`,К:`K`,Л:`N`,М:`M`,Н:`H`,О:`O`,П:`N`,Р:`P`,С:`C`,Т:`T`,У:`y`,Ф:`O`,Х:`X`,Ц:`U`,Ч:`h`,Ш:`W`,Щ:`W`,Ъ:`B`,Ы:`X`,Ь:`B`,Э:`3`,Ю:`X`,Я:`R`,а:`a`,б:`b`,в:`a`,г:`r`,д:`y`,е:`e`,ж:`m`,з:`e`,и:`n`,й:`n`,к:`n`,л:`n`,м:`m`,н:`n`,о:`o`,п:`n`,р:`p`,с:`c`,т:`o`,у:`y`,ф:`b`,х:`x`,ц:`n`,ч:`n`,ш:`w`,щ:`w`,ъ:`a`,ы:`m`,ь:`a`,э:`e`,ю:`m`,я:`r`};function qU(e,t){WU[e]=t}function JU(e,t,n){if(!WU[t])throw Error(`Font metrics not found for font: `+t+`.`);var r=e.charCodeAt(0),i=WU[t][r];if(!i&&e[0]in KU&&(r=KU[e[0]].charCodeAt(0),i=WU[t][r]),!i&&n===`text`&&sU(r)&&(i=WU[t][77]),i)return{depth:i[0],height:i[1],italic:i[2],skew:i[3],width:i[4]}}var YU={};function XU(e){var t=e>=5?0:e>=3?1:2;if(!YU[t]){var n=YU[t]={cssEmPerMu:GU.quad[t]/18};for(var r of Object.keys(GU))n[r]=GU[r][t]}return YU[t]}var ZU={math:{},text:{}};function B(e,t,n,r,i,a){ZU[e][i]={font:t,group:n,replace:r},a&&r&&(ZU[e][r]=ZU[e][i])}var V=`math`,H=`text`,U=`main`,W=`ams`,QU=`accent-token`,G=`bin`,$U=`close`,eW=`inner`,K=`mathord`,tW=`op-token`,nW=`open`,rW=`punct`,q=`rel`,iW=`spacing`,J=`textord`;B(V,U,q,`≡`,`\\equiv`,!0),B(V,U,q,`≺`,`\\prec`,!0),B(V,U,q,`≻`,`\\succ`,!0),B(V,U,q,`∼`,`\\sim`,!0),B(V,U,q,`⊥`,`\\perp`),B(V,U,q,`⪯`,`\\preceq`,!0),B(V,U,q,`⪰`,`\\succeq`,!0),B(V,U,q,`≃`,`\\simeq`,!0),B(V,U,q,`∣`,`\\mid`,!0),B(V,U,q,`≪`,`\\ll`,!0),B(V,U,q,`≫`,`\\gg`,!0),B(V,U,q,`≍`,`\\asymp`,!0),B(V,U,q,`∥`,`\\parallel`),B(V,U,q,`⋈`,`\\bowtie`,!0),B(V,U,q,`⌣`,`\\smile`,!0),B(V,U,q,`⊑`,`\\sqsubseteq`,!0),B(V,U,q,`⊒`,`\\sqsupseteq`,!0),B(V,U,q,`≐`,`\\doteq`,!0),B(V,U,q,`⌢`,`\\frown`,!0),B(V,U,q,`∋`,`\\ni`,!0),B(V,U,q,`∝`,`\\propto`,!0),B(V,U,q,`⊢`,`\\vdash`,!0),B(V,U,q,`⊣`,`\\dashv`,!0),B(V,U,q,`∋`,`\\owns`),B(V,U,rW,`.`,`\\ldotp`),B(V,U,rW,`⋅`,`\\cdotp`),B(V,U,rW,`⋅`,`·`),B(H,U,J,`⋅`,`·`),B(V,U,J,`#`,`\\#`),B(H,U,J,`#`,`\\#`),B(V,U,J,`&`,`\\&`),B(H,U,J,`&`,`\\&`),B(V,U,J,`ℵ`,`\\aleph`,!0),B(V,U,J,`∀`,`\\forall`,!0),B(V,U,J,`ℏ`,`\\hbar`,!0),B(V,U,J,`∃`,`\\exists`,!0),B(V,U,J,`∇`,`\\nabla`,!0),B(V,U,J,`♭`,`\\flat`,!0),B(V,U,J,`ℓ`,`\\ell`,!0),B(V,U,J,`♮`,`\\natural`,!0),B(V,U,J,`♣`,`\\clubsuit`,!0),B(V,U,J,`℘`,`\\wp`,!0),B(V,U,J,`♯`,`\\sharp`,!0),B(V,U,J,`♢`,`\\diamondsuit`,!0),B(V,U,J,`ℜ`,`\\Re`,!0),B(V,U,J,`♡`,`\\heartsuit`,!0),B(V,U,J,`ℑ`,`\\Im`,!0),B(V,U,J,`♠`,`\\spadesuit`,!0),B(V,U,J,`§`,`\\S`,!0),B(H,U,J,`§`,`\\S`),B(V,U,J,`¶`,`\\P`,!0),B(H,U,J,`¶`,`\\P`),B(V,U,J,`†`,`\\dag`),B(H,U,J,`†`,`\\dag`),B(H,U,J,`†`,`\\textdagger`),B(V,U,J,`‡`,`\\ddag`),B(H,U,J,`‡`,`\\ddag`),B(H,U,J,`‡`,`\\textdaggerdbl`),B(V,U,$U,`⎱`,`\\rmoustache`,!0),B(V,U,nW,`⎰`,`\\lmoustache`,!0),B(V,U,$U,`⟯`,`\\rgroup`,!0),B(V,U,nW,`⟮`,`\\lgroup`,!0),B(V,U,G,`∓`,`\\mp`,!0),B(V,U,G,`⊖`,`\\ominus`,!0),B(V,U,G,`⊎`,`\\uplus`,!0),B(V,U,G,`⊓`,`\\sqcap`,!0),B(V,U,G,`∗`,`\\ast`),B(V,U,G,`⊔`,`\\sqcup`,!0),B(V,U,G,`◯`,`\\bigcirc`,!0),B(V,U,G,`∙`,`\\bullet`,!0),B(V,U,G,`‡`,`\\ddagger`),B(V,U,G,`≀`,`\\wr`,!0),B(V,U,G,`⨿`,`\\amalg`),B(V,U,G,`&`,`\\And`),B(V,U,q,`⟵`,`\\longleftarrow`,!0),B(V,U,q,`⇐`,`\\Leftarrow`,!0),B(V,U,q,`⟸`,`\\Longleftarrow`,!0),B(V,U,q,`⟶`,`\\longrightarrow`,!0),B(V,U,q,`⇒`,`\\Rightarrow`,!0),B(V,U,q,`⟹`,`\\Longrightarrow`,!0),B(V,U,q,`↔`,`\\leftrightarrow`,!0),B(V,U,q,`⟷`,`\\longleftrightarrow`,!0),B(V,U,q,`⇔`,`\\Leftrightarrow`,!0),B(V,U,q,`⟺`,`\\Longleftrightarrow`,!0),B(V,U,q,`↦`,`\\mapsto`,!0),B(V,U,q,`⟼`,`\\longmapsto`,!0),B(V,U,q,`↗`,`\\nearrow`,!0),B(V,U,q,`↩`,`\\hookleftarrow`,!0),B(V,U,q,`↪`,`\\hookrightarrow`,!0),B(V,U,q,`↘`,`\\searrow`,!0),B(V,U,q,`↼`,`\\leftharpoonup`,!0),B(V,U,q,`⇀`,`\\rightharpoonup`,!0),B(V,U,q,`↙`,`\\swarrow`,!0),B(V,U,q,`↽`,`\\leftharpoondown`,!0),B(V,U,q,`⇁`,`\\rightharpoondown`,!0),B(V,U,q,`↖`,`\\nwarrow`,!0),B(V,U,q,`⇌`,`\\rightleftharpoons`,!0),B(V,W,q,`≮`,`\\nless`,!0),B(V,W,q,``,`\\@nleqslant`),B(V,W,q,``,`\\@nleqq`),B(V,W,q,`⪇`,`\\lneq`,!0),B(V,W,q,`≨`,`\\lneqq`,!0),B(V,W,q,``,`\\@lvertneqq`),B(V,W,q,`⋦`,`\\lnsim`,!0),B(V,W,q,`⪉`,`\\lnapprox`,!0),B(V,W,q,`⊀`,`\\nprec`,!0),B(V,W,q,`⋠`,`\\npreceq`,!0),B(V,W,q,`⋨`,`\\precnsim`,!0),B(V,W,q,`⪹`,`\\precnapprox`,!0),B(V,W,q,`≁`,`\\nsim`,!0),B(V,W,q,``,`\\@nshortmid`),B(V,W,q,`∤`,`\\nmid`,!0),B(V,W,q,`⊬`,`\\nvdash`,!0),B(V,W,q,`⊭`,`\\nvDash`,!0),B(V,W,q,`⋪`,`\\ntriangleleft`),B(V,W,q,`⋬`,`\\ntrianglelefteq`,!0),B(V,W,q,`⊊`,`\\subsetneq`,!0),B(V,W,q,``,`\\@varsubsetneq`),B(V,W,q,`⫋`,`\\subsetneqq`,!0),B(V,W,q,``,`\\@varsubsetneqq`),B(V,W,q,`≯`,`\\ngtr`,!0),B(V,W,q,``,`\\@ngeqslant`),B(V,W,q,``,`\\@ngeqq`),B(V,W,q,`⪈`,`\\gneq`,!0),B(V,W,q,`≩`,`\\gneqq`,!0),B(V,W,q,``,`\\@gvertneqq`),B(V,W,q,`⋧`,`\\gnsim`,!0),B(V,W,q,`⪊`,`\\gnapprox`,!0),B(V,W,q,`⊁`,`\\nsucc`,!0),B(V,W,q,`⋡`,`\\nsucceq`,!0),B(V,W,q,`⋩`,`\\succnsim`,!0),B(V,W,q,`⪺`,`\\succnapprox`,!0),B(V,W,q,`≆`,`\\ncong`,!0),B(V,W,q,``,`\\@nshortparallel`),B(V,W,q,`∦`,`\\nparallel`,!0),B(V,W,q,`⊯`,`\\nVDash`,!0),B(V,W,q,`⋫`,`\\ntriangleright`),B(V,W,q,`⋭`,`\\ntrianglerighteq`,!0),B(V,W,q,``,`\\@nsupseteqq`),B(V,W,q,`⊋`,`\\supsetneq`,!0),B(V,W,q,``,`\\@varsupsetneq`),B(V,W,q,`⫌`,`\\supsetneqq`,!0),B(V,W,q,``,`\\@varsupsetneqq`),B(V,W,q,`⊮`,`\\nVdash`,!0),B(V,W,q,`⪵`,`\\precneqq`,!0),B(V,W,q,`⪶`,`\\succneqq`,!0),B(V,W,q,``,`\\@nsubseteqq`),B(V,W,G,`⊴`,`\\unlhd`),B(V,W,G,`⊵`,`\\unrhd`),B(V,W,q,`↚`,`\\nleftarrow`,!0),B(V,W,q,`↛`,`\\nrightarrow`,!0),B(V,W,q,`⇍`,`\\nLeftarrow`,!0),B(V,W,q,`⇏`,`\\nRightarrow`,!0),B(V,W,q,`↮`,`\\nleftrightarrow`,!0),B(V,W,q,`⇎`,`\\nLeftrightarrow`,!0),B(V,W,q,`△`,`\\vartriangle`),B(V,W,J,`ℏ`,`\\hslash`),B(V,W,J,`▽`,`\\triangledown`),B(V,W,J,`◊`,`\\lozenge`),B(V,W,J,`Ⓢ`,`\\circledS`),B(V,W,J,`®`,`\\circledR`),B(H,W,J,`®`,`\\circledR`),B(V,W,J,`∡`,`\\measuredangle`,!0),B(V,W,J,`∄`,`\\nexists`),B(V,W,J,`℧`,`\\mho`),B(V,W,J,`Ⅎ`,`\\Finv`,!0),B(V,W,J,`⅁`,`\\Game`,!0),B(V,W,J,`‵`,`\\backprime`),B(V,W,J,`▲`,`\\blacktriangle`),B(V,W,J,`▼`,`\\blacktriangledown`),B(V,W,J,`■`,`\\blacksquare`),B(V,W,J,`⧫`,`\\blacklozenge`),B(V,W,J,`★`,`\\bigstar`),B(V,W,J,`∢`,`\\sphericalangle`,!0),B(V,W,J,`∁`,`\\complement`,!0),B(V,W,J,`ð`,`\\eth`,!0),B(H,U,J,`ð`,`ð`),B(V,W,J,`╱`,`\\diagup`),B(V,W,J,`╲`,`\\diagdown`),B(V,W,J,`□`,`\\square`),B(V,W,J,`□`,`\\Box`),B(V,W,J,`◊`,`\\Diamond`),B(V,W,J,`¥`,`\\yen`,!0),B(H,W,J,`¥`,`\\yen`,!0),B(V,W,J,`✓`,`\\checkmark`,!0),B(H,W,J,`✓`,`\\checkmark`),B(V,W,J,`ℶ`,`\\beth`,!0),B(V,W,J,`ℸ`,`\\daleth`,!0),B(V,W,J,`ℷ`,`\\gimel`,!0),B(V,W,J,`ϝ`,`\\digamma`,!0),B(V,W,J,`ϰ`,`\\varkappa`),B(V,W,nW,`┌`,`\\@ulcorner`,!0),B(V,W,$U,`┐`,`\\@urcorner`,!0),B(V,W,nW,`└`,`\\@llcorner`,!0),B(V,W,$U,`┘`,`\\@lrcorner`,!0),B(V,W,q,`≦`,`\\leqq`,!0),B(V,W,q,`⩽`,`\\leqslant`,!0),B(V,W,q,`⪕`,`\\eqslantless`,!0),B(V,W,q,`≲`,`\\lesssim`,!0),B(V,W,q,`⪅`,`\\lessapprox`,!0),B(V,W,q,`≊`,`\\approxeq`,!0),B(V,W,G,`⋖`,`\\lessdot`),B(V,W,q,`⋘`,`\\lll`,!0),B(V,W,q,`≶`,`\\lessgtr`,!0),B(V,W,q,`⋚`,`\\lesseqgtr`,!0),B(V,W,q,`⪋`,`\\lesseqqgtr`,!0),B(V,W,q,`≑`,`\\doteqdot`),B(V,W,q,`≓`,`\\risingdotseq`,!0),B(V,W,q,`≒`,`\\fallingdotseq`,!0),B(V,W,q,`∽`,`\\backsim`,!0),B(V,W,q,`⋍`,`\\backsimeq`,!0),B(V,W,q,`⫅`,`\\subseteqq`,!0),B(V,W,q,`⋐`,`\\Subset`,!0),B(V,W,q,`⊏`,`\\sqsubset`,!0),B(V,W,q,`≼`,`\\preccurlyeq`,!0),B(V,W,q,`⋞`,`\\curlyeqprec`,!0),B(V,W,q,`≾`,`\\precsim`,!0),B(V,W,q,`⪷`,`\\precapprox`,!0),B(V,W,q,`⊲`,`\\vartriangleleft`),B(V,W,q,`⊴`,`\\trianglelefteq`),B(V,W,q,`⊨`,`\\vDash`,!0),B(V,W,q,`⊪`,`\\Vvdash`,!0),B(V,W,q,`⌣`,`\\smallsmile`),B(V,W,q,`⌢`,`\\smallfrown`),B(V,W,q,`≏`,`\\bumpeq`,!0),B(V,W,q,`≎`,`\\Bumpeq`,!0),B(V,W,q,`≧`,`\\geqq`,!0),B(V,W,q,`⩾`,`\\geqslant`,!0),B(V,W,q,`⪖`,`\\eqslantgtr`,!0),B(V,W,q,`≳`,`\\gtrsim`,!0),B(V,W,q,`⪆`,`\\gtrapprox`,!0),B(V,W,G,`⋗`,`\\gtrdot`),B(V,W,q,`⋙`,`\\ggg`,!0),B(V,W,q,`≷`,`\\gtrless`,!0),B(V,W,q,`⋛`,`\\gtreqless`,!0),B(V,W,q,`⪌`,`\\gtreqqless`,!0),B(V,W,q,`≖`,`\\eqcirc`,!0),B(V,W,q,`≗`,`\\circeq`,!0),B(V,W,q,`≜`,`\\triangleq`,!0),B(V,W,q,`∼`,`\\thicksim`),B(V,W,q,`≈`,`\\thickapprox`),B(V,W,q,`⫆`,`\\supseteqq`,!0),B(V,W,q,`⋑`,`\\Supset`,!0),B(V,W,q,`⊐`,`\\sqsupset`,!0),B(V,W,q,`≽`,`\\succcurlyeq`,!0),B(V,W,q,`⋟`,`\\curlyeqsucc`,!0),B(V,W,q,`≿`,`\\succsim`,!0),B(V,W,q,`⪸`,`\\succapprox`,!0),B(V,W,q,`⊳`,`\\vartriangleright`),B(V,W,q,`⊵`,`\\trianglerighteq`),B(V,W,q,`⊩`,`\\Vdash`,!0),B(V,W,q,`∣`,`\\shortmid`),B(V,W,q,`∥`,`\\shortparallel`),B(V,W,q,`≬`,`\\between`,!0),B(V,W,q,`⋔`,`\\pitchfork`,!0),B(V,W,q,`∝`,`\\varpropto`),B(V,W,q,`◀`,`\\blacktriangleleft`),B(V,W,q,`∴`,`\\therefore`,!0),B(V,W,q,`∍`,`\\backepsilon`),B(V,W,q,`▶`,`\\blacktriangleright`),B(V,W,q,`∵`,`\\because`,!0),B(V,W,q,`⋘`,`\\llless`),B(V,W,q,`⋙`,`\\gggtr`),B(V,W,G,`⊲`,`\\lhd`),B(V,W,G,`⊳`,`\\rhd`),B(V,W,q,`≂`,`\\eqsim`,!0),B(V,U,q,`⋈`,`\\Join`),B(V,W,q,`≑`,`\\Doteq`,!0),B(V,W,G,`∔`,`\\dotplus`,!0),B(V,W,G,`∖`,`\\smallsetminus`),B(V,W,G,`⋒`,`\\Cap`,!0),B(V,W,G,`⋓`,`\\Cup`,!0),B(V,W,G,`⩞`,`\\doublebarwedge`,!0),B(V,W,G,`⊟`,`\\boxminus`,!0),B(V,W,G,`⊞`,`\\boxplus`,!0),B(V,W,G,`⋇`,`\\divideontimes`,!0),B(V,W,G,`⋉`,`\\ltimes`,!0),B(V,W,G,`⋊`,`\\rtimes`,!0),B(V,W,G,`⋋`,`\\leftthreetimes`,!0),B(V,W,G,`⋌`,`\\rightthreetimes`,!0),B(V,W,G,`⋏`,`\\curlywedge`,!0),B(V,W,G,`⋎`,`\\curlyvee`,!0),B(V,W,G,`⊝`,`\\circleddash`,!0),B(V,W,G,`⊛`,`\\circledast`,!0),B(V,W,G,`⋅`,`\\centerdot`),B(V,W,G,`⊺`,`\\intercal`,!0),B(V,W,G,`⋒`,`\\doublecap`),B(V,W,G,`⋓`,`\\doublecup`),B(V,W,G,`⊠`,`\\boxtimes`,!0),B(V,W,q,`⇢`,`\\dashrightarrow`,!0),B(V,W,q,`⇠`,`\\dashleftarrow`,!0),B(V,W,q,`⇇`,`\\leftleftarrows`,!0),B(V,W,q,`⇆`,`\\leftrightarrows`,!0),B(V,W,q,`⇚`,`\\Lleftarrow`,!0),B(V,W,q,`↞`,`\\twoheadleftarrow`,!0),B(V,W,q,`↢`,`\\leftarrowtail`,!0),B(V,W,q,`↫`,`\\looparrowleft`,!0),B(V,W,q,`⇋`,`\\leftrightharpoons`,!0),B(V,W,q,`↶`,`\\curvearrowleft`,!0),B(V,W,q,`↺`,`\\circlearrowleft`,!0),B(V,W,q,`↰`,`\\Lsh`,!0),B(V,W,q,`⇈`,`\\upuparrows`,!0),B(V,W,q,`↿`,`\\upharpoonleft`,!0),B(V,W,q,`⇃`,`\\downharpoonleft`,!0),B(V,U,q,`⊶`,`\\origof`,!0),B(V,U,q,`⊷`,`\\imageof`,!0),B(V,W,q,`⊸`,`\\multimap`,!0),B(V,W,q,`↭`,`\\leftrightsquigarrow`,!0),B(V,W,q,`⇉`,`\\rightrightarrows`,!0),B(V,W,q,`⇄`,`\\rightleftarrows`,!0),B(V,W,q,`↠`,`\\twoheadrightarrow`,!0),B(V,W,q,`↣`,`\\rightarrowtail`,!0),B(V,W,q,`↬`,`\\looparrowright`,!0),B(V,W,q,`↷`,`\\curvearrowright`,!0),B(V,W,q,`↻`,`\\circlearrowright`,!0),B(V,W,q,`↱`,`\\Rsh`,!0),B(V,W,q,`⇊`,`\\downdownarrows`,!0),B(V,W,q,`↾`,`\\upharpoonright`,!0),B(V,W,q,`⇂`,`\\downharpoonright`,!0),B(V,W,q,`⇝`,`\\rightsquigarrow`,!0),B(V,W,q,`⇝`,`\\leadsto`),B(V,W,q,`⇛`,`\\Rrightarrow`,!0),B(V,W,q,`↾`,`\\restriction`),B(V,U,J,`‘`,"`"),B(V,U,J,`$`,`\\$`),B(H,U,J,`$`,`\\$`),B(H,U,J,`$`,`\\textdollar`),B(V,U,J,`%`,`\\%`),B(H,U,J,`%`,`\\%`),B(V,U,J,`_`,`\\_`),B(H,U,J,`_`,`\\_`),B(H,U,J,`_`,`\\textunderscore`),B(V,U,J,`∠`,`\\angle`,!0),B(V,U,J,`∞`,`\\infty`,!0),B(V,U,J,`′`,`\\prime`),B(V,U,J,`△`,`\\triangle`),B(V,U,J,`Γ`,`\\Gamma`,!0),B(V,U,J,`Δ`,`\\Delta`,!0),B(V,U,J,`Θ`,`\\Theta`,!0),B(V,U,J,`Λ`,`\\Lambda`,!0),B(V,U,J,`Ξ`,`\\Xi`,!0),B(V,U,J,`Π`,`\\Pi`,!0),B(V,U,J,`Σ`,`\\Sigma`,!0),B(V,U,J,`Υ`,`\\Upsilon`,!0),B(V,U,J,`Φ`,`\\Phi`,!0),B(V,U,J,`Ψ`,`\\Psi`,!0),B(V,U,J,`Ω`,`\\Omega`,!0),B(V,U,J,`A`,`Α`),B(V,U,J,`B`,`Β`),B(V,U,J,`E`,`Ε`),B(V,U,J,`Z`,`Ζ`),B(V,U,J,`H`,`Η`),B(V,U,J,`I`,`Ι`),B(V,U,J,`K`,`Κ`),B(V,U,J,`M`,`Μ`),B(V,U,J,`N`,`Ν`),B(V,U,J,`O`,`Ο`),B(V,U,J,`P`,`Ρ`),B(V,U,J,`T`,`Τ`),B(V,U,J,`X`,`Χ`),B(V,U,J,`¬`,`\\neg`,!0),B(V,U,J,`¬`,`\\lnot`),B(V,U,J,`⊤`,`\\top`),B(V,U,J,`⊥`,`\\bot`),B(V,U,J,`∅`,`\\emptyset`),B(V,W,J,`∅`,`\\varnothing`),B(V,U,K,`α`,`\\alpha`,!0),B(V,U,K,`β`,`\\beta`,!0),B(V,U,K,`γ`,`\\gamma`,!0),B(V,U,K,`δ`,`\\delta`,!0),B(V,U,K,`ϵ`,`\\epsilon`,!0),B(V,U,K,`ζ`,`\\zeta`,!0),B(V,U,K,`η`,`\\eta`,!0),B(V,U,K,`θ`,`\\theta`,!0),B(V,U,K,`ι`,`\\iota`,!0),B(V,U,K,`κ`,`\\kappa`,!0),B(V,U,K,`λ`,`\\lambda`,!0),B(V,U,K,`μ`,`\\mu`,!0),B(V,U,K,`ν`,`\\nu`,!0),B(V,U,K,`ξ`,`\\xi`,!0),B(V,U,K,`ο`,`\\omicron`,!0),B(V,U,K,`π`,`\\pi`,!0),B(V,U,K,`ρ`,`\\rho`,!0),B(V,U,K,`σ`,`\\sigma`,!0),B(V,U,K,`τ`,`\\tau`,!0),B(V,U,K,`υ`,`\\upsilon`,!0),B(V,U,K,`ϕ`,`\\phi`,!0),B(V,U,K,`χ`,`\\chi`,!0),B(V,U,K,`ψ`,`\\psi`,!0),B(V,U,K,`ω`,`\\omega`,!0),B(V,U,K,`ε`,`\\varepsilon`,!0),B(V,U,K,`ϑ`,`\\vartheta`,!0),B(V,U,K,`ϖ`,`\\varpi`,!0),B(V,U,K,`ϱ`,`\\varrho`,!0),B(V,U,K,`ς`,`\\varsigma`,!0),B(V,U,K,`φ`,`\\varphi`,!0),B(V,U,G,`∗`,`*`,!0),B(V,U,G,`+`,`+`),B(V,U,G,`−`,`-`,!0),B(V,U,G,`⋅`,`\\cdot`,!0),B(V,U,G,`∘`,`\\circ`,!0),B(V,U,G,`÷`,`\\div`,!0),B(V,U,G,`±`,`\\pm`,!0),B(V,U,G,`×`,`\\times`,!0),B(V,U,G,`∩`,`\\cap`,!0),B(V,U,G,`∪`,`\\cup`,!0),B(V,U,G,`∖`,`\\setminus`,!0),B(V,U,G,`∧`,`\\land`),B(V,U,G,`∨`,`\\lor`),B(V,U,G,`∧`,`\\wedge`,!0),B(V,U,G,`∨`,`\\vee`,!0),B(V,U,J,`√`,`\\surd`),B(V,U,nW,`⟨`,`\\langle`,!0),B(V,U,nW,`∣`,`\\lvert`),B(V,U,nW,`∥`,`\\lVert`),B(V,U,$U,`?`,`?`),B(V,U,$U,`!`,`!`),B(V,U,$U,`⟩`,`\\rangle`,!0),B(V,U,$U,`∣`,`\\rvert`),B(V,U,$U,`∥`,`\\rVert`),B(V,U,q,`=`,`=`),B(V,U,q,`:`,`:`),B(V,U,q,`≈`,`\\approx`,!0),B(V,U,q,`≅`,`\\cong`,!0),B(V,U,q,`≥`,`\\ge`),B(V,U,q,`≥`,`\\geq`,!0),B(V,U,q,`←`,`\\gets`),B(V,U,q,`>`,`\\gt`,!0),B(V,U,q,`∈`,`\\in`,!0),B(V,U,q,``,`\\@not`),B(V,U,q,`⊂`,`\\subset`,!0),B(V,U,q,`⊃`,`\\supset`,!0),B(V,U,q,`⊆`,`\\subseteq`,!0),B(V,U,q,`⊇`,`\\supseteq`,!0),B(V,W,q,`⊈`,`\\nsubseteq`,!0),B(V,W,q,`⊉`,`\\nsupseteq`,!0),B(V,U,q,`⊨`,`\\models`),B(V,U,q,`←`,`\\leftarrow`,!0),B(V,U,q,`≤`,`\\le`),B(V,U,q,`≤`,`\\leq`,!0),B(V,U,q,`<`,`\\lt`,!0),B(V,U,q,`→`,`\\rightarrow`,!0),B(V,U,q,`→`,`\\to`),B(V,W,q,`≱`,`\\ngeq`,!0),B(V,W,q,`≰`,`\\nleq`,!0),B(V,U,iW,`\xA0`,`\\ `),B(V,U,iW,`\xA0`,`\\space`),B(V,U,iW,`\xA0`,`\\nobreakspace`),B(H,U,iW,`\xA0`,`\\ `),B(H,U,iW,`\xA0`,` `),B(H,U,iW,`\xA0`,`\\space`),B(H,U,iW,`\xA0`,`\\nobreakspace`),B(V,U,iW,``,`\\nobreak`),B(V,U,iW,``,`\\allowbreak`),B(V,U,rW,`,`,`,`),B(V,U,rW,`;`,`;`),B(V,W,G,`⊼`,`\\barwedge`,!0),B(V,W,G,`⊻`,`\\veebar`,!0),B(V,U,G,`⊙`,`\\odot`,!0),B(V,U,G,`⊕`,`\\oplus`,!0),B(V,U,G,`⊗`,`\\otimes`,!0),B(V,U,J,`∂`,`\\partial`,!0),B(V,U,G,`⊘`,`\\oslash`,!0),B(V,W,G,`⊚`,`\\circledcirc`,!0),B(V,W,G,`⊡`,`\\boxdot`,!0),B(V,U,G,`△`,`\\bigtriangleup`),B(V,U,G,`▽`,`\\bigtriangledown`),B(V,U,G,`†`,`\\dagger`),B(V,U,G,`⋄`,`\\diamond`),B(V,U,G,`⋆`,`\\star`),B(V,U,G,`◃`,`\\triangleleft`),B(V,U,G,`▹`,`\\triangleright`),B(V,U,nW,`{`,`\\{`),B(H,U,J,`{`,`\\{`),B(H,U,J,`{`,`\\textbraceleft`),B(V,U,$U,`}`,`\\}`),B(H,U,J,`}`,`\\}`),B(H,U,J,`}`,`\\textbraceright`),B(V,U,nW,`{`,`\\lbrace`),B(V,U,$U,`}`,`\\rbrace`),B(V,U,nW,`[`,`\\lbrack`,!0),B(H,U,J,`[`,`\\lbrack`,!0),B(V,U,$U,`]`,`\\rbrack`,!0),B(H,U,J,`]`,`\\rbrack`,!0),B(V,U,nW,`(`,`\\lparen`,!0),B(V,U,$U,`)`,`\\rparen`,!0),B(H,U,J,`<`,`\\textless`,!0),B(H,U,J,`>`,`\\textgreater`,!0),B(V,U,nW,`⌊`,`\\lfloor`,!0),B(V,U,$U,`⌋`,`\\rfloor`,!0),B(V,U,nW,`⌈`,`\\lceil`,!0),B(V,U,$U,`⌉`,`\\rceil`,!0),B(V,U,J,`\\`,`\\backslash`),B(V,U,J,`∣`,`|`),B(V,U,J,`∣`,`\\vert`),B(H,U,J,`|`,`\\textbar`,!0),B(V,U,J,`∥`,`\\|`),B(V,U,J,`∥`,`\\Vert`),B(H,U,J,`∥`,`\\textbardbl`),B(H,U,J,`~`,`\\textasciitilde`),B(H,U,J,`\\`,`\\textbackslash`),B(H,U,J,`^`,`\\textasciicircum`),B(V,U,q,`↑`,`\\uparrow`,!0),B(V,U,q,`⇑`,`\\Uparrow`,!0),B(V,U,q,`↓`,`\\downarrow`,!0),B(V,U,q,`⇓`,`\\Downarrow`,!0),B(V,U,q,`↕`,`\\updownarrow`,!0),B(V,U,q,`⇕`,`\\Updownarrow`,!0),B(V,U,tW,`∐`,`\\coprod`),B(V,U,tW,`⋁`,`\\bigvee`),B(V,U,tW,`⋀`,`\\bigwedge`),B(V,U,tW,`⨄`,`\\biguplus`),B(V,U,tW,`⋂`,`\\bigcap`),B(V,U,tW,`⋃`,`\\bigcup`),B(V,U,tW,`∫`,`\\int`),B(V,U,tW,`∫`,`\\intop`),B(V,U,tW,`∬`,`\\iint`),B(V,U,tW,`∭`,`\\iiint`),B(V,U,tW,`∏`,`\\prod`),B(V,U,tW,`∑`,`\\sum`),B(V,U,tW,`⨂`,`\\bigotimes`),B(V,U,tW,`⨁`,`\\bigoplus`),B(V,U,tW,`⨀`,`\\bigodot`),B(V,U,tW,`∮`,`\\oint`),B(V,U,tW,`∯`,`\\oiint`),B(V,U,tW,`∰`,`\\oiiint`),B(V,U,tW,`⨆`,`\\bigsqcup`),B(V,U,tW,`∫`,`\\smallint`),B(H,U,eW,`…`,`\\textellipsis`),B(V,U,eW,`…`,`\\mathellipsis`),B(H,U,eW,`…`,`\\ldots`,!0),B(V,U,eW,`…`,`\\ldots`,!0),B(V,U,eW,`⋯`,`\\@cdots`,!0),B(V,U,eW,`⋱`,`\\ddots`,!0),B(V,U,J,`⋮`,`\\varvdots`),B(H,U,J,`⋮`,`\\varvdots`),B(V,U,QU,`ˊ`,`\\acute`),B(V,U,QU,`ˋ`,`\\grave`),B(V,U,QU,`¨`,`\\ddot`),B(V,U,QU,`~`,`\\tilde`),B(V,U,QU,`ˉ`,`\\bar`),B(V,U,QU,`˘`,`\\breve`),B(V,U,QU,`ˇ`,`\\check`),B(V,U,QU,`^`,`\\hat`),B(V,U,QU,`⃗`,`\\vec`),B(V,U,QU,`˙`,`\\dot`),B(V,U,QU,`˚`,`\\mathring`),B(V,U,K,``,`\\@imath`),B(V,U,K,``,`\\@jmath`),B(V,U,J,`ı`,`ı`),B(V,U,J,`ȷ`,`ȷ`),B(H,U,J,`ı`,`\\i`,!0),B(H,U,J,`ȷ`,`\\j`,!0),B(H,U,J,`ß`,`\\ss`,!0),B(H,U,J,`æ`,`\\ae`,!0),B(H,U,J,`œ`,`\\oe`,!0),B(H,U,J,`ø`,`\\o`,!0),B(H,U,J,`Æ`,`\\AE`,!0),B(H,U,J,`Œ`,`\\OE`,!0),B(H,U,J,`Ø`,`\\O`,!0),B(H,U,QU,`ˊ`,`\\'`),B(H,U,QU,`ˋ`,"\\`"),B(H,U,QU,`ˆ`,`\\^`),B(H,U,QU,`˜`,`\\~`),B(H,U,QU,`ˉ`,`\\=`),B(H,U,QU,`˘`,`\\u`),B(H,U,QU,`˙`,`\\.`),B(H,U,QU,`¸`,`\\c`),B(H,U,QU,`˚`,`\\r`),B(H,U,QU,`ˇ`,`\\v`),B(H,U,QU,`¨`,`\\"`),B(H,U,QU,`˝`,`\\H`),B(H,U,QU,`◯`,`\\textcircled`);var aW={"--":!0,"---":!0,"``":!0,"''":!0};B(H,U,J,`–`,`--`,!0),B(H,U,J,`–`,`\\textendash`),B(H,U,J,`—`,`---`,!0),B(H,U,J,`—`,`\\textemdash`),B(H,U,J,`‘`,"`",!0),B(H,U,J,`‘`,`\\textquoteleft`),B(H,U,J,`’`,`'`,!0),B(H,U,J,`’`,`\\textquoteright`),B(H,U,J,`“`,"``",!0),B(H,U,J,`“`,`\\textquotedblleft`),B(H,U,J,`”`,`''`,!0),B(H,U,J,`”`,`\\textquotedblright`),B(V,U,J,`°`,`\\degree`,!0),B(H,U,J,`°`,`\\degree`),B(H,U,J,`°`,`\\textdegree`,!0),B(V,U,J,`£`,`\\pounds`),B(V,U,J,`£`,`\\mathsterling`,!0),B(H,U,J,`£`,`\\pounds`),B(H,U,J,`£`,`\\textsterling`,!0),B(V,W,J,`✠`,`\\maltese`),B(H,W,J,`✠`,`\\maltese`);for(var oW=`0123456789/@."`,sW=0;sW{var t=e.charCodeAt(0),n=e.charCodeAt(1),r=(t-55296)*1024+(n-56320)+65536;if(119808<=r&&r<120484)return PW[Math.floor((r-119808)/26)];if(120782<=r&&r<=120831)return FW[Math.floor((r-120782)/10)];if(r===120485||r===120486)return PW[0];if(120486{if(DU(e.classes)!==DU(t.classes)||e.skew!==t.skew||e.maxFontSize!==t.maxFontSize||e.italic!==0&&e.hasClass(`mathnormal`))return!1;if(e.classes.length===1){var n=e.classes[0];if(n===`mbin`||n===`mord`)return!1}for(var r of Object.keys(e.style))if(e.style[r]!==t.style[r])return!1;for(var i of Object.keys(t.style))if(e.style[i]!==t.style[i])return!1;return!0},UW=e=>{for(var t=0;tt&&(t=a.height),a.depth>n&&(n=a.depth),a.maxFontSize>r&&(r=a.maxFontSize)}e.height=t,e.depth=n,e.maxFontSize=r},X=function(e,t,n,r){var i=new NU(e,t,n,r);return WW(i),i},GW=(e,t,n,r)=>new NU(e,t,n,r),KW=function(e,t,n){var r=X([e],[],t);return r.height=Math.max(n||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),r.style.borderBottomWidth=z(r.height),r.maxFontSize=1,r},qW=function(e,t,n,r){var i=new PU(e,t,n,r);return WW(i),i},JW=function(e){var t=new SU(e);return WW(t),t},YW=function(e,t){return e instanceof SU?X([],[e],t):e},XW=function(e){if(e.positionType===`individualShift`){for(var t=e.children,n=[t[0]],r=-t[0].shift-t[0].elem.depth,i=r,a=1;a{var n=X([`mspace`],[],t),r=EU(e,t);return n.style.marginRight=z(r),n},$W=(e,t,n)=>{var r,i;switch(e){case`amsrm`:r=`AMS`;break;case`textrm`:r=`Main`;break;case`textsf`:r=`SansSerif`;break;case`texttt`:r=`Typewriter`;break;default:r=e}return i=t===`textbf`&&n===`textit`?`BoldItalic`:t===`textbf`?`Bold`:n===`textit`?`Italic`:`Regular`,r+`-`+i},eG={mathbf:{variant:`bold`,fontName:`Main-Bold`},mathrm:{variant:`normal`,fontName:`Main-Regular`},textit:{variant:`italic`,fontName:`Main-Italic`},mathit:{variant:`italic`,fontName:`Main-Italic`},mathnormal:{variant:`italic`,fontName:`Math-Italic`},mathsfit:{variant:`sans-serif-italic`,fontName:`SansSerif-Italic`},mathbb:{variant:`double-struck`,fontName:`AMS-Regular`},mathcal:{variant:`script`,fontName:`Caligraphic-Regular`},mathfrak:{variant:`fraktur`,fontName:`Fraktur-Regular`},mathscr:{variant:`script`,fontName:`Script-Regular`},mathsf:{variant:`sans-serif`,fontName:`SansSerif-Regular`},mathtt:{variant:`monospace`,fontName:`Typewriter-Regular`}},tG={vec:[`vec`,.471,.714],oiintSize1:[`oiintSize1`,.957,.499],oiintSize2:[`oiintSize2`,1.472,.659],oiiintSize1:[`oiiintSize1`,1.304,.499],oiiintSize2:[`oiiintSize2`,1.98,.659]},nG=function(e,t){var n=tG[e],r=n[0],i=n[1],a=n[2],o=GW([`katex-overlay`],[new RU([new zU(r)],{width:z(i),height:z(a),style:`width:`+z(i),viewBox:`0 0 `+1e3*i+` `+1e3*a,preserveAspectRatio:`xMinYMin`})],t);return o.height=a,o.style.height=z(a),o.style.width=z(i),o},rG={number:3,unit:`mu`},iG={number:4,unit:`mu`},aG={number:5,unit:`mu`},oG={mord:{mop:rG,mbin:iG,mrel:aG,minner:rG},mop:{mord:rG,mop:rG,mrel:aG,minner:rG},mbin:{mord:iG,mop:iG,mopen:iG,minner:iG},mrel:{mord:aG,mop:aG,mopen:aG,minner:aG},mopen:{},mclose:{mop:rG,mbin:iG,mrel:aG,minner:rG},mpunct:{mord:rG,mop:rG,mrel:aG,mopen:rG,mclose:rG,mpunct:rG,minner:rG},minner:{mord:rG,mop:rG,mbin:iG,mrel:aG,mopen:rG,mpunct:rG,minner:rG}},sG={mord:{mop:rG},mop:{mord:rG,mop:rG},mbin:{},mrel:{},mopen:{},mclose:{mop:rG},mpunct:{},minner:{mop:rG}},cG={},lG={},uG={};function Z(e){for(var t=e.type,n=e.names,r=e.htmlBuilder,i=e.mathmlBuilder,a=0;a{var n=t.classes[0],r=e.classes[0];n===`mbin`&&hG.has(r)?t.classes[0]=`mord`:r===`mbin`&&mG.has(n)&&(e.classes[0]=`mord`)},{node:u},d,f),yG(i,(e,t)=>{var n=SG(t),r=SG(e),i=n&&r?e.hasClass(`mtight`)?sG[n]?.[r]:oG[n]?.[r]:null;if(i)return QW(i,c)},{node:u},d,f),i},yG=function(e,t,n,r,i){r&&e.push(r);for(var a=0;an=>{e.splice(t+1,0,n),a++})(a)}}r&&e.pop()},bG=function(e){return e instanceof SU||e instanceof PU||e instanceof NU&&e.hasClass(`enclosing`)?e:null},xG=function(e,t){var n=bG(e);if(n){var r=n.children;if(r.length){if(t===`right`)return xG(r[r.length-1],`right`);if(t===`left`)return xG(r[0],`left`)}}return e},SG=function(e,t){return e?(t&&(e=xG(e,t)),_G[e.classes[0]]||null):null},CG=function(e,t){var n=[`nulldelimiter`].concat(e.baseSizingClasses());return X(t.concat(n))},wG=function(e,t,n){if(!e)return X();if(lG[e.type]){var r=lG[e.type](e,t);if(n&&t.size!==n.size){r=X(t.sizingClasses(n),[r],t);var i=t.sizeMultiplier/n.sizeMultiplier;r.height*=i,r.depth*=i}return r}throw new L(`Got group of unknown type: '`+e.type+`'`)};function TG(e,t){var n=X([`katex-base`],e,t),r=X([`katex-strut`]);return r.style.height=z(n.height+n.depth),n.depth&&(r.style.verticalAlign=z(-n.depth)),n.children.unshift(r),n}function EG(e,t){var n=null;e.length===1&&e[0].type===`tag`&&(n=e[0].tag,e=e[0].body);var r=vG(e,t,`root`),i;r.length===2&&r[1].hasClass(`katex-tag`)&&(i=r.pop());for(var a=[],o=[],s=0;s0&&(a.push(TG(o,t)),o=[]),a.push(r[s]));o.length>0&&a.push(TG(o,t));var l;n?(l=TG(vG(n,t,!0),t),l.classes=[`katex-tag`],a.push(l)):i&&a.push(i);var u=X([`katex-html`],a);if(u.setAttribute(`aria-hidden`,`true`),l){var d=l.children[0];d.style.height=z(u.height+u.depth),u.depth&&(d.style.verticalAlign=z(-u.depth))}return u}function DG(e){return new SU(e)}var Q=class{constructor(e,t,n){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=n||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){var e=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,this.type);for(var t of Object.entries(this.attributes)){var n=t[0],r=t[1];e.setAttribute(n,r)}this.classes.length>0&&(e.className=DU(this.classes));for(var i=0;i0&&(e+=` class ="`+MH(DU(this.classes))+`"`),e+=`>`;for(var i=0;i`,e}toText(){return this.children.map(e=>e.toText()).join(``)}},OG=class{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return MH(this.toText())}toText(){return this.text}},kG=class{constructor(e){this.width=void 0,this.character=void 0,this.width=e,this.character=e>=.05555&&e<=.05556?` `:e>=.1666&&e<=.1667?` `:e>=.2222&&e<=.2223?` `:e>=.2777&&e<=.2778?`  `:e>=-.05556&&e<=-.05555?` ⁣`:e>=-.1667&&e<=-.1666?` ⁣`:e>=-.2223&&e<=-.2222?` ⁣`:e>=-.2778&&e<=-.2777?` ⁣`:null}toNode(){if(this.character)return document.createTextNode(this.character);var e=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`mspace`);return e.setAttribute(`width`,z(this.width)),e}toMarkup(){return this.character?``+this.character+``:``}toText(){return this.character?this.character:` `}},AG=new Set([`\\imath`,`\\jmath`]),jG=new Set([`mrow`,`mtable`]),MG=function(e,t,n){var r,i;return ZU[t][e]&&ZU[t][e].replace&&e.charCodeAt(0)!==55349&&(!Object.prototype.hasOwnProperty.call(aW,e)||(n==null||(r=n.fontFamily)==null?void 0:r.slice(4,6))!==`tt`&&(n==null||(i=n.font)==null?void 0:i.slice(4,6))!==`tt`)&&(e=ZU[t][e].replace),new OG(e)},NG=function(e){return e.length===1?e[0]:new Q(`mrow`,e)},PG={mathit:`italic`,boldsymbol:e=>e.type===`textord`?`bold`:`bold-italic`,mathbf:`bold`,mathbb:`double-struck`,mathsfit:`sans-serif-italic`,mathfrak:`fraktur`,mathscr:`script`,mathcal:`script`,mathsf:`sans-serif`,mathtt:`monospace`},FG=(e,t)=>{if(e.mode===`text`){if(t.fontFamily===`texttt`)return`monospace`;if(t.fontFamily===`textsf`)return t.fontShape===`textit`&&t.fontWeight===`textbf`?`sans-serif-bold-italic`:t.fontShape===`textit`?`sans-serif-italic`:t.fontWeight===`textbf`?`bold-sans-serif`:`sans-serif`;if(t.fontShape===`textit`&&t.fontWeight===`textbf`)return`bold-italic`;if(t.fontShape===`textit`)return`italic`;if(t.fontWeight===`textbf`)return`bold`}var n=t.font;if(!n||n===`mathnormal`)return null;var r=e.mode,i=PG[n];if(i)return typeof i==`function`?i(e):i;var a=e.text;if(AG.has(a))return null;if(ZU[r][a]){var o=ZU[r][a].replace;o&&(a=o)}var s=eG[n].fontName;return JU(a,s,r)?eG[n].variant:null};function IG(e){if(!e)return!1;if(e.type===`mi`&&e.children.length===1){var t=e.children[0];return t instanceof OG&&t.text===`.`}if(e.type===`mo`&&e.children.length===1&&e.getAttribute(`separator`)===`true`&&e.getAttribute(`lspace`)===`0em`&&e.getAttribute(`rspace`)===`0em`){var n=e.children[0];return n instanceof OG&&n.text===`,`}return!1}var LG=function(e,t,n){if(e.length===1){var r=zG(e[0],t);return n&&r instanceof Q&&r.type===`mo`&&(r.setAttribute(`lspace`,`0em`),r.setAttribute(`rspace`,`0em`)),[r]}for(var i=[],a,o=0;o=1&&(a.type===`mn`||IG(a))){var c=s.children[0];c instanceof Q&&c.type===`mn`&&(c.children=[...a.children,...c.children],i.pop())}else if(a.type===`mi`&&a.children.length===1){var l=a.children[0];if(l instanceof OG&&l.text===`̸`&&(s.type===`mo`||s.type===`mi`||s.type===`mn`)){var u=s.children[0];u instanceof OG&&u.text.length>0&&(u.text=u.text.slice(0,1)+`̸`+u.text.slice(1),i.pop())}}}i.push(s),a=s}return i},RG=function(e,t,n){return NG(LG(e,t,n))},zG=function(e,t){if(!e)return new Q(`mrow`);if(uG[e.type])return uG[e.type](e,t);throw new L(`Got group of unknown type: '`+e.type+`'`)};function BG(e,t,n,r,i){var a=LG(e,n),o=a.length===1&&a[0]instanceof Q&&jG.has(a[0].type)?a[0]:new Q(`mrow`,a),s=new Q(`annotation`,[new OG(t)]);s.setAttribute(`encoding`,`application/x-tex`);var c=new Q(`math`,[new Q(`semantics`,[o,s])]);return c.setAttribute(`xmlns`,`http://www.w3.org/1998/Math/MathML`),r&&c.setAttribute(`display`,`block`),X([i?`katex`:`katex-mathml`],[c])}var VG=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],HG=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],UG=function(e,t){return t.size<2?e:VG[e-1][t.size-1]},WG=class e{constructor(t){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=t.style,this.color=t.color,this.size=t.size||e.BASESIZE,this.textSize=t.textSize||this.size,this.phantom=!!t.phantom,this.font=t.font||``,this.fontFamily=t.fontFamily||``,this.fontWeight=t.fontWeight||``,this.fontShape=t.fontShape||``,this.sizeMultiplier=HG[this.size-1],this.maxSize=t.maxSize,this.minRuleThickness=t.minRuleThickness,this._fontMetrics=void 0}extend(t){var n={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};return Object.assign(n,t),new e(n)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:UG(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:HG[e-1]})}havingBaseStyle(t){t||=this.style.text();var n=UG(e.BASESIZE,t);return this.size===n&&this.textSize===e.BASESIZE&&this.style===t?this:this.extend({style:t,size:n})}havingBaseSizing(){var e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:``})}withTextFontWeight(e){return this.extend({fontWeight:e,font:``})}withTextFontShape(e){return this.extend({fontShape:e,font:``})}sizingClasses(e){return e.size===this.size?[]:[`katex-sizing`,`reset-size`+e.size,`size`+this.size]}baseSizingClasses(){return this.size===e.BASESIZE?[]:[`katex-sizing`,`reset-size`+this.size,`size`+e.BASESIZE]}fontMetrics(){return this._fontMetrics||=XU(this.size),this._fontMetrics}getColor(){return this.phantom?`transparent`:this.color}};WG.BASESIZE=6;var GG=function(e){return new WG({style:e.displayMode?R.DISPLAY:R.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},KG=function(e,t){if(t.displayMode){var n=[`katex-display`];t.leqno&&n.push(`leqno`),t.fleqn&&n.push(`fleqn`),e=X(n,[e])}return e},qG=function(e,t,n){var r=GG(n),i;return n.output===`mathml`?BG(e,t,r,n.displayMode,!0):(i=n.output===`html`?X([`katex`],[EG(e,r)]):X([`katex`],[BG(e,t,r,n.displayMode,!1),EG(e,r)]),KG(i,n))},JG=function(e,t,n){return KG(X([`katex`],[EG(e,GG(n))]),n)},YG={widehat:`^`,widecheck:`ˇ`,widetilde:`~`,utilde:`~`,overleftarrow:`←`,underleftarrow:`←`,xleftarrow:`←`,overrightarrow:`→`,underrightarrow:`→`,xrightarrow:`→`,underbrace:`⏟`,overbrace:`⏞`,underbracket:`⎵`,overbracket:`⎴`,overgroup:`⏠`,undergroup:`⏡`,overleftrightarrow:`↔`,underleftrightarrow:`↔`,xleftrightarrow:`↔`,Overrightarrow:`⇒`,xRightarrow:`⇒`,overleftharpoon:`↼`,xleftharpoonup:`↼`,overrightharpoon:`⇀`,xrightharpoonup:`⇀`,xLeftarrow:`⇐`,xLeftrightarrow:`⇔`,xhookleftarrow:`↩`,xhookrightarrow:`↪`,xmapsto:`↦`,xrightharpoondown:`⇁`,xleftharpoondown:`↽`,xrightleftharpoons:`⇌`,xleftrightharpoons:`⇋`,xtwoheadleftarrow:`↞`,xtwoheadrightarrow:`↠`,xlongequal:`=`,xtofrom:`⇄`,xrightleftarrows:`⇄`,xrightequilibrium:`⇌`,xleftequilibrium:`⇋`,"\\cdrightarrow":`→`,"\\cdleftarrow":`←`,"\\cdlongequal":`=`},XG=function(e){var t=new Q(`mo`,[new OG(YG[e.replace(/^\\/,``)])]);return t.setAttribute(`stretchy`,`true`),t},ZG={overrightarrow:[[`rightarrow`],.888,522,`xMaxYMin`],overleftarrow:[[`leftarrow`],.888,522,`xMinYMin`],underrightarrow:[[`rightarrow`],.888,522,`xMaxYMin`],underleftarrow:[[`leftarrow`],.888,522,`xMinYMin`],xrightarrow:[[`rightarrow`],1.469,522,`xMaxYMin`],"\\cdrightarrow":[[`rightarrow`],3,522,`xMaxYMin`],xleftarrow:[[`leftarrow`],1.469,522,`xMinYMin`],"\\cdleftarrow":[[`leftarrow`],3,522,`xMinYMin`],Overrightarrow:[[`doublerightarrow`],.888,560,`xMaxYMin`],xRightarrow:[[`doublerightarrow`],1.526,560,`xMaxYMin`],xLeftarrow:[[`doubleleftarrow`],1.526,560,`xMinYMin`],overleftharpoon:[[`leftharpoon`],.888,522,`xMinYMin`],xleftharpoonup:[[`leftharpoon`],.888,522,`xMinYMin`],xleftharpoondown:[[`leftharpoondown`],.888,522,`xMinYMin`],overrightharpoon:[[`rightharpoon`],.888,522,`xMaxYMin`],xrightharpoonup:[[`rightharpoon`],.888,522,`xMaxYMin`],xrightharpoondown:[[`rightharpoondown`],.888,522,`xMaxYMin`],xlongequal:[[`longequal`],.888,334,`xMinYMin`],"\\cdlongequal":[[`longequal`],3,334,`xMinYMin`],xtwoheadleftarrow:[[`twoheadleftarrow`],.888,334,`xMinYMin`],xtwoheadrightarrow:[[`twoheadrightarrow`],.888,334,`xMaxYMin`],overleftrightarrow:[[`leftarrow`,`rightarrow`],.888,522],overbrace:[[`leftbrace`,`midbrace`,`rightbrace`],1.6,548],underbrace:[[`leftbraceunder`,`midbraceunder`,`rightbraceunder`],1.6,548],underleftrightarrow:[[`leftarrow`,`rightarrow`],.888,522],xleftrightarrow:[[`leftarrow`,`rightarrow`],1.75,522],xLeftrightarrow:[[`doubleleftarrow`,`doublerightarrow`],1.75,560],xrightleftharpoons:[[`leftharpoondownplus`,`rightharpoonplus`],1.75,716],xleftrightharpoons:[[`leftharpoonplus`,`rightharpoondownplus`],1.75,716],xhookleftarrow:[[`leftarrow`,`righthook`],1.08,522],xhookrightarrow:[[`lefthook`,`rightarrow`],1.08,522],overlinesegment:[[`leftlinesegment`,`rightlinesegment`],.888,522],underlinesegment:[[`leftlinesegment`,`rightlinesegment`],.888,522],overbracket:[[`leftbracketover`,`rightbracketover`],1.6,440],underbracket:[[`leftbracketunder`,`rightbracketunder`],1.6,410],overgroup:[[`leftgroup`,`rightgroup`],.888,342],undergroup:[[`leftgroupunder`,`rightgroupunder`],.888,342],xmapsto:[[`leftmapsto`,`rightarrow`],1.5,522],xtofrom:[[`leftToFrom`,`rightToFrom`],1.75,528],xrightleftarrows:[[`baraboveleftarrow`,`rightarrowabovebar`],1.75,901],xrightequilibrium:[[`baraboveshortleftharpoon`,`rightharpoonaboveshortbar`],1.75,716],xleftequilibrium:[[`shortbaraboveleftharpoon`,`shortrightharpoonabovebar`],1.75,716]},QG=new Set([`widehat`,`widecheck`,`widetilde`,`utilde`]),$G=function(e,t){function n(){var n=4e5,r=e.label.slice(1);if(QG.has(r)&&`base`in e){var i=e.base.type===`ordgroup`?e.base.body.length:1,a,o,s;if(i>5)r===`widehat`||r===`widecheck`?(a=420,n=2364,s=.42,o=r+`4`):(a=312,n=2340,s=.34,o=`tilde4`);else{var c=[1,1,2,2,3,3][i];r===`widehat`||r===`widecheck`?(n=[0,1062,2364,2364,2364][c],a=[0,239,300,360,420][c],s=[0,.24,.3,.3,.36,.42][c],o=r+c):(n=[0,600,1033,2339,2340][c],a=[0,260,286,306,312][c],s=[0,.26,.286,.3,.306,.34][c],o=`tilde`+c)}return{span:GW([],[new RU([new zU(o)],{width:`100%`,height:z(s),viewBox:`0 0 `+n+` `+a,preserveAspectRatio:`none`})],t),minWidth:0,height:s}}var l=[],u=ZG[r];if(!u)throw Error(`No SVG data for "`+r+`".`);var d=u[0],f=u[1],p=u[2],m=p/1e3,h=d.length,g,_;if(h===1){if(u.length!==4)throw Error(`Expected 4-tuple for single-path SVG data "`+r+`".`);g=[`hide-tail`],_=[u[3]]}else if(h===2)g=[`halfarrow-left`,`halfarrow-right`],_=[`xMinYMin`,`xMaxYMin`];else if(h===3)g=[`brace-left`,`brace-center`,`brace-right`],_=[`xMinYMin`,`xMidYMin`,`xMaxYMin`];else throw Error(`Correct katexImagesData or update code here to support - `+h+` children.`);for(var v=0;v0&&(i.style.minWidth=z(a)),i},eK=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 BU({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new BU({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=GW([],[new RU(c,{width:`100%`,height:z(o)})],i)}return a.height=o,a.style.height=z(o),a},tK=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],nK=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],rK=new Set(tK),iK=new Set(nK);function aK(e){return rK.has(e)}function oK(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 sK(e){var t=cK(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function cK(e){return e.type===`atom`||iK.has(e.type)?e:null}function lK(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 uK=e=>{if(e instanceof LU)return e;if(UU(e)&&e.children.length===1)return uK(e.children[0])},dK=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=oK(e.base,`accent`),n=r.base,e.base=n,i=HU(wG(e,t)),e.base=r):(r=oK(e,`accent`),n=r.base);var a=wG(n,t.havingCrampedStyle()),o=r.isShifty&&FH(n),s=0;o&&(s=uK(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=$G(r,t),u=ZW({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=nG(`vec`,t),f=tG.vec[1]):(d=VW({type:`textord`,mode:r.mode,text:r.label},t),d=VU(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=ZW({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},fK=(e,t)=>{var n=e.isStretchy?XG(e.label):new Q(`mo`,[MG(e.label,e.mode)]),r=new Q(`mover`,[zG(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},pK=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=fG(t[0]),r=!pK.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:dK,mathmlBuilder:fK}),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=wG(e.base,t),r=$G(e,t),i=e.label===`\\utilde`?.12:0;return X([`mord`,`accentunder`],[ZW({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=XG(e.label),r=new Q(`munder`,[zG(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var mK=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`,`\\xleftrightarrow`,`\\xLeftrightarrow`,`\\xhookleftarrow`,`\\xhookrightarrow`,`\\xmapsto`,`\\xrightharpoondown`,`\\xrightharpoonup`,`\\xleftharpoondown`,`\\xleftharpoonup`,`\\xrightleftharpoons`,`\\xleftrightharpoons`,`\\xlongequal`,`\\xtwoheadrightarrow`,`\\xtwoheadleftarrow`,`\\xtofrom`,`\\xrightleftarrows`,`\\xrightequilibrium`,`\\xleftequilibrium`,`\\\\cdrightarrow`,`\\\\cdleftarrow`,`\\\\cdlongequal`],numArgs:1,numOptionalArgs:1,handler(e,t,n){var r=e.parser,i=e.funcName;return{type:`xArrow`,mode:r.mode,label:i,body:t[0],below:n[0]}},htmlBuilder(e,t){var n=t.style,r=t.havingStyle(n.sup()),i=YW(wG(e.body,r,t),t),a=e.label.slice(0,2)===`\\x`?`x`:`cd`;i.classes.push(a+`-arrow-pad`);var o;e.below&&(r=t.havingStyle(n.sub()),o=YW(wG(e.below,r,t),t),o.classes.push(a+`-arrow-pad`));var s=$G(e,t),c=-t.fontMetrics().axisHeight+.5*s.height,l=-t.fontMetrics().axisHeight-.5*s.height-.111;(i.depth>.25||e.label===`\\xleftequilibrium`)&&(l-=i.depth);var u;if(o){var d=-t.fontMetrics().axisHeight+o.height+.5*s.height+.111;u=ZW({positionType:`individualShift`,children:[{type:`elem`,elem:i,shift:l},{type:`elem`,elem:s,shift:c,wrapperClasses:[`svg-align`]},{type:`elem`,elem:o,shift:d}]})}else u=ZW({positionType:`individualShift`,children:[{type:`elem`,elem:i,shift:l},{type:`elem`,elem:s,shift:c,wrapperClasses:[`svg-align`]}]});return X([`mrel`,`x-arrow`],[u],t)},mathmlBuilder(e,t){var n=XG(e.label);n.setAttribute(`minsize`,e.label.charAt(0)===`x`?`1.75em`:`3.0em`);var r;if(e.body){var i=mK(zG(e.body,t));r=e.below?new Q(`munderover`,[n,mK(zG(e.below,t)),i]):new Q(`mover`,[n,i])}else e.below?r=new Q(`munder`,[n,mK(zG(e.below,t))]):(r=mK(),r=new Q(`mover`,[n,r]));return r}});function hK(e,t){var n=vG(e.body,t,!0);return X([e.mclass],n,t)}function gK(e,t){var n,r=LG(e.body,t);return e.mclass===`minner`?n=new Q(`mpadded`,r):e.mclass===`mord`?e.isCharacterBox?(n=r[0],n.type=`mi`):n=new Q(`mi`,r):(e.isCharacterBox?(n=r[0],n.type=`mo`):n=new Q(`mo`,r),e.mclass===`mbin`?(n.attributes.lspace=`0.22em`,n.attributes.rspace=`0.22em`):e.mclass===`mpunct`?(n.attributes.lspace=`0em`,n.attributes.rspace=`0.17em`):(e.mclass===`mopen`||e.mclass===`mclose`)&&(n.attributes.lspace=`0em`,n.attributes.rspace=`0em`)),n}Z({type:`mclass`,names:[`\\mathord`,`\\mathbin`,`\\mathrel`,`\\mathopen`,`\\mathclose`,`\\mathpunct`,`\\mathinner`],numArgs:1,primitive:!0,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`mclass`,mode:n.mode,mclass:`m`+r.slice(5),body:pG(i),isCharacterBox:FH(i)}},htmlBuilder:hK,mathmlBuilder:gK});var _K=e=>{var t=e.type===`ordgroup`&&e.body.length?e.body[0]:e;return t.type===`atom`&&(t.family===`bin`||t.family===`rel`)?`m`+t.family:`mord`};Z({type:`mclass`,names:[`\\@binrel`],numArgs:2,handler(e,t){return{type:`mclass`,mode:e.parser.mode,mclass:_K(t[0]),body:pG(t[1]),isCharacterBox:FH(t[1])}}}),Z({type:`mclass`,names:[`\\stackrel`,`\\overset`,`\\underset`],numArgs:2,handler(e,t){var n=e.parser,r=e.funcName,i=t[1],a=t[0],o=r===`\\stackrel`?`mrel`:_K(i),s={type:`op`,mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:r!==`\\stackrel`,body:pG(i)},c=r===`\\underset`?{type:`supsub`,mode:a.mode,base:s,sub:a}:{type:`supsub`,mode:a.mode,base:s,sup:a};return{type:`mclass`,mode:n.mode,mclass:o,body:[c],isCharacterBox:FH(c)}}}),Z({type:`pmb`,names:[`\\pmb`],numArgs:1,allowedInText:!0,handler(e,t){return{type:`pmb`,mode:e.parser.mode,mclass:_K(t[0]),body:pG(t[0])}},htmlBuilder(e,t){var n=vG(e.body,t,!0),r=X([e.mclass],n,t);return r.style.textShadow=`0.02em 0.01em 0.04px`,r},mathmlBuilder(e,t){var n=new Q(`mstyle`,LG(e.body,t));return n.setAttribute(`style`,`text-shadow: 0.02em 0.01em 0.04px`),n}});var vK={">":`\\\\cdrightarrow`,"<":`\\\\cdleftarrow`,"=":`\\\\cdlongequal`,A:`\\uparrow`,V:`\\downarrow`,"|":`\\Vert`,".":`no arrow`},yK=()=>({type:`styling`,body:[],mode:`math`,style:`display`,resetFont:!0}),bK=e=>e.type===`textord`&&e.text===`@`,xK=(e,t)=>(e.type===`mathord`||e.type===`atom`)&&e.text===t;function SK(e,t,n){var r=vK[e];switch(r){case`\\\\cdrightarrow`:case`\\\\cdleftarrow`:return n.callFunction(r,[t[0]],[t[1]]);case`\\uparrow`:case`\\downarrow`:var i=n.callFunction(`\\\\cdleft`,[t[0]],[]),a={type:`atom`,text:r,mode:`math`,family:`rel`},o={type:`ordgroup`,mode:`math`,body:[i,n.callFunction(`\\Big`,[a],[]),n.callFunction(`\\\\cdright`,[t[1]],[])]};return n.callFunction(`\\\\cdparent`,[o],[]);case`\\\\cdlongequal`:return n.callFunction(`\\\\cdlongequal`,[],[]);case`\\Vert`:return n.callFunction(`\\Big`,[{type:`textord`,text:`\\Vert`,mode:`math`}],[]);default:return{type:`textord`,text:` `,mode:`math`}}}function CK(e){var t=[];for(e.gullet.beginGroup(),e.gullet.macros.set(`\\cr`,`\\\\\\relax`),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,`\\\\`)),e.gullet.endGroup(),e.gullet.beginGroup();var n=e.fetch().text;if(n===`&`||n===`\\\\`)e.consume();else if(n===`\\end`){t[t.length-1].length===0&&t.pop();break}else throw new L(`Expected \\\\ or \\cr or \\end`,e.nextToken)}for(var r=[],i=[r],a=0;aAV`.includes(l))for(var d=0;d<2;d++){for(var f=!0,p=c+1;pAV=|." after @`,o[c])}var m={type:`styling`,body:[SK(l,u,e)],mode:`math`,style:`display`,resetFont:!0};r.push(m),s=yK()}a%2==0?r.push(s):r.shift(),r=[],i.push(r)}return e.gullet.endGroup(),e.gullet.endGroup(),{type:`array`,mode:`math`,body:i,arraystretch:1,addJot:!0,rowGaps:[null],cols:Array(i[0].length).fill({type:`align`,align:`c`,pregap:.25,postgap:.25}),colSeparationType:`CD`,hLinesBeforeRow:Array(i.length+1).fill([])}}Z({type:`cdlabel`,names:[`\\\\cdleft`,`\\\\cdright`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName;return{type:`cdlabel`,mode:n.mode,side:r.slice(4),label:t[0]}},htmlBuilder(e,t){var n=t.havingStyle(t.style.sup()),r=YW(wG(e.label,n,t),t);return r.classes.push(`cd-label-`+e.side),r.style.bottom=z(.8-r.depth),r.height=0,r.depth=0,r},mathmlBuilder(e,t){var n=new Q(`mrow`,[zG(e.label,t)]);return n=new Q(`mpadded`,[n]),n.setAttribute(`width`,`0`),e.side===`left`&&n.setAttribute(`lspace`,`-1width`),n.setAttribute(`voffset`,`0.7em`),n=new Q(`mstyle`,[n]),n.setAttribute(`displaystyle`,`false`),n.setAttribute(`scriptlevel`,`1`),n}}),Z({type:`cdlabelparent`,names:[`\\\\cdparent`],numArgs:1,handler(e,t){return{type:`cdlabelparent`,mode:e.parser.mode,fragment:t[0]}},htmlBuilder(e,t){var n=YW(wG(e.fragment,t),t);return n.classes.push(`cd-vert-arrow`),n},mathmlBuilder(e,t){return new Q(`mrow`,[zG(e.fragment,t)])}}),Z({type:`textord`,names:[`\\@char`],numArgs:1,allowedInText:!0,handler(e,t){var n=e.parser,r=lK(oK(t[0],`ordgroup`),`\\@char has non-numeric argument`),i=parseInt(r),a;if(isNaN(i))throw new L(`\\@char has non-numeric argument `+r);if(i<0||i>1114111)throw new L(`\\@char with invalid code point `+r);return i<=65535?a=String.fromCharCode(i):(i-=65536,a=String.fromCharCode((i>>10)+55296,(i&1023)+56320)),{type:`textord`,mode:n.mode,text:a}}}),Z({type:`color`,names:[`\\textcolor`],numArgs:2,allowedInText:!0,argTypes:[`color`,`original`],handler(e,t){var n=e.parser,r=oK(t[0],`color-token`).color,i=t[1];return{type:`color`,mode:n.mode,color:r,body:pG(i)}},htmlBuilder:(e,t)=>JW(vG(e.body,t.withColor(e.color),!1)),mathmlBuilder:(e,t)=>{var n=new Q(`mstyle`,LG(e.body,t.withColor(e.color)));return n.setAttribute(`mathcolor`,e.color),n}}),Z({type:`color`,names:[`\\color`],numArgs:1,allowedInText:!0,argTypes:[`color`],handler(e,t){var n=e.parser,r=e.breakOnTokenText,i=oK(t[0],`color-token`).color;n.gullet.macros.set(`\\current@color`,i);var a=n.parseExpression(!0,r);return{type:`color`,mode:n.mode,color:i,body:a}}}),Z({type:`cr`,names:[`\\\\`],numArgs:0,numOptionalArgs:0,allowedInText:!0,handler(e,t,n){var r=e.parser,i=r.gullet.future().text===`[`?r.parseSizeGroup(!0):null,a=!r.settings.displayMode||!r.settings.useStrictBehavior(`newLineInDisplayMode`,`In LaTeX, \\\\ or \\newline does nothing in display mode`);return{type:`cr`,mode:r.mode,newLine:a,size:i&&oK(i,`size`).value}},htmlBuilder(e,t){var n=X([`mspace`],[],t);return e.newLine&&(n.classes.push(`katex-newline`),e.size&&(n.style.marginTop=z(EU(e.size,t)))),n},mathmlBuilder(e,t){var n=new Q(`mspace`);return e.newLine&&(n.setAttribute(`linebreak`,`newline`),e.size&&n.setAttribute(`height`,z(EU(e.size,t)))),n}});var wK={"\\global":`\\global`,"\\long":`\\\\globallong`,"\\\\globallong":`\\\\globallong`,"\\def":`\\gdef`,"\\gdef":`\\gdef`,"\\edef":`\\xdef`,"\\xdef":`\\xdef`,"\\let":`\\\\globallet`,"\\futurelet":`\\\\globalfuture`},TK=e=>{var t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new L(`Expected a control sequence`,e);return t},EK=e=>{var t=e.gullet.popToken();return t.text===`=`&&(t=e.gullet.popToken(),t.text===` `&&(t=e.gullet.popToken())),t},DK=(e,t,n,r)=>{var i=e.gullet.macros.get(n.text);i??=(n.noexpand=!0,{tokens:[n],numArgs:0,unexpandable:!e.gullet.isExpandable(n.text)}),e.gullet.macros.set(t,i,r)};Z({type:`internal`,names:[`\\global`,`\\long`,`\\\\globallong`],numArgs:0,allowedInText:!0,handler(e){var t=e.parser,n=e.funcName;t.consumeSpaces();var r=t.fetch();if(wK[r.text])return(n===`\\global`||n===`\\\\globallong`)&&(r.text=wK[r.text]),oK(t.parseFunction(),`internal`);throw new L(`Invalid token after macro prefix`,r)}}),Z({type:`internal`,names:[`\\def`,`\\gdef`,`\\edef`,`\\xdef`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=t.gullet.popToken(),i=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(i))throw new L(`Expected a control sequence`,r);for(var a=0,o,s=[[]];t.gullet.future().text!==`{`;)if(r=t.gullet.popToken(),r.text===`#`){if(t.gullet.future().text===`{`){o=t.gullet.future(),s[a].push(`{`);break}if(r=t.gullet.popToken(),!/^[1-9]$/.test(r.text))throw new L(`Invalid argument number "`+r.text+`"`);if(parseInt(r.text)!==a+1)throw new L(`Argument number "`+r.text+`" out of order`);a++,s.push([])}else if(r.text===`EOF`)throw new L(`Expected a macro definition`);else s[a].push(r.text);var c=t.gullet.consumeArg().tokens;return o&&c.unshift(o),(n===`\\edef`||n===`\\xdef`)&&(c=t.gullet.expandTokens(c),c.reverse()),t.gullet.macros.set(i,{tokens:c,numArgs:a,delimiters:s},n===wK[n]),{type:`internal`,mode:t.mode}}}),Z({type:`internal`,names:[`\\let`,`\\\\globallet`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=TK(t.gullet.popToken());return t.gullet.consumeSpaces(),DK(t,r,EK(t),n===`\\\\globallet`),{type:`internal`,mode:t.mode}}}),Z({type:`internal`,names:[`\\futurelet`,`\\\\globalfuture`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=TK(t.gullet.popToken()),i=t.gullet.popToken(),a=t.gullet.popToken();return DK(t,r,a,n===`\\\\globalfuture`),t.gullet.pushToken(a),t.gullet.pushToken(i),{type:`internal`,mode:t.mode}}});var OK=function(e,t,n){var r=JU(ZU.math[e]&&ZU.math[e].replace||e,t,n);if(!r)throw Error(`Unsupported symbol `+e+` and font size `+t+`.`);return r},kK=function(e,t,n,r){var i=n.havingBaseStyle(t),a=X(r.concat(i.sizingClasses(n)),[e],n),o=i.sizeMultiplier/n.sizeMultiplier;return a.height*=o,a.depth*=o,a.maxFontSize=i.sizeMultiplier,a},AK=function(e,t,n){var r=t.havingBaseStyle(n),i=(1-t.sizeMultiplier/r.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push(`delimcenter`),e.style.top=z(i),e.height-=i,e.depth+=i},jK=function(e,t,n,r,i,a){var o=kK(RW(e,`Main-Regular`,i,r),t,r,a);return n&&AK(o,r,t),o},MK=function(e,t,n,r){return RW(e,`Size`+t+`-Regular`,n,r)},NK=function(e,t,n,r,i,a){var o=MK(e,t,i,r),s=kK(X([`delimsizing`,`size`+t],[o],r),R.TEXT,r,a);return n&&AK(s,r,R.TEXT),s},PK=function(e,t,n){return{type:`elem`,elem:X([`delimsizinginner`,t===`Size1-Regular`?`delim-size1`:`delim-size4`],[X([],[RW(e,t,n)])])}},FK=function(e,t,n){var r=WU[`Size4-Regular`][e.charCodeAt(0)]?WU[`Size4-Regular`][e.charCodeAt(0)][4]:WU[`Size1-Regular`][e.charCodeAt(0)][4],i=GW([],[new RU([new zU(`inner`,vU(e,Math.round(1e3*t)))],{width:z(r),height:z(t),style:`width:`+z(r),viewBox:`0 0 `+1e3*r+` `+Math.round(1e3*t),preserveAspectRatio:`xMinYMin`})],n);return i.height=t,i.style.height=z(t),i.style.width=z(r),{type:`elem`,elem:i}},IK=.008,LK={type:`kern`,size:-1*IK},RK=new Set([`|`,`\\lvert`,`\\rvert`,`\\vert`]),zK=new Set([`\\|`,`\\lVert`,`\\rVert`,`\\Vert`]),BK=function(e,t,n,r,i,a){var o,s,c,l,u=``,d=0;o=c=l=e,s=null;var f=`Size1-Regular`;e===`\\uparrow`?c=l=`⏐`:e===`\\Uparrow`?c=l=`‖`:e===`\\downarrow`?o=c=`⏐`:e===`\\Downarrow`?o=c=`‖`:e===`\\updownarrow`?(o=`\\uparrow`,c=`⏐`,l=`\\downarrow`):e===`\\Updownarrow`?(o=`\\Uparrow`,c=`‖`,l=`\\Downarrow`):RK.has(e)?(c=`∣`,u=`vert`,d=333):zK.has(e)?(c=`∥`,u=`doublevert`,d=556):e===`[`||e===`\\lbrack`?(o=`⎡`,c=`⎢`,l=`⎣`,f=`Size4-Regular`,u=`lbrack`,d=667):e===`]`||e===`\\rbrack`?(o=`⎤`,c=`⎥`,l=`⎦`,f=`Size4-Regular`,u=`rbrack`,d=667):e===`\\lfloor`||e===`⌊`?(c=o=`⎢`,l=`⎣`,f=`Size4-Regular`,u=`lfloor`,d=667):e===`\\lceil`||e===`⌈`?(o=`⎡`,c=l=`⎢`,f=`Size4-Regular`,u=`lceil`,d=667):e===`\\rfloor`||e===`⌋`?(c=o=`⎥`,l=`⎦`,f=`Size4-Regular`,u=`rfloor`,d=667):e===`\\rceil`||e===`⌉`?(o=`⎤`,c=l=`⎥`,f=`Size4-Regular`,u=`rceil`,d=667):e===`(`||e===`\\lparen`?(o=`⎛`,c=`⎜`,l=`⎝`,f=`Size4-Regular`,u=`lparen`,d=875):e===`)`||e===`\\rparen`?(o=`⎞`,c=`⎟`,l=`⎠`,f=`Size4-Regular`,u=`rparen`,d=875):e===`\\{`||e===`\\lbrace`?(o=`⎧`,s=`⎨`,l=`⎩`,c=`⎪`,f=`Size4-Regular`):e===`\\}`||e===`\\rbrace`?(o=`⎫`,s=`⎬`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):e===`\\lgroup`||e===`⟮`?(o=`⎧`,l=`⎩`,c=`⎪`,f=`Size4-Regular`):e===`\\rgroup`||e===`⟯`?(o=`⎫`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):e===`\\lmoustache`||e===`⎰`?(o=`⎧`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):(e===`\\rmoustache`||e===`⎱`)&&(o=`⎫`,l=`⎩`,c=`⎪`,f=`Size4-Regular`);var p=OK(o,f,i),m=p.height+p.depth,h=OK(c,f,i),g=h.height+h.depth,_=OK(l,f,i),v=_.height+_.depth,y=0,b=1;if(s!==null){var x=OK(s,f,i);y=x.height+x.depth,b=2}var S=m+v+y,C=S+Math.max(0,Math.ceil((t-S)/(b*g)))*b*g,ee=r.fontMetrics().axisHeight;n&&(ee*=r.sizeMultiplier);var te=C/2-ee,ne=[];if(u.length>0){var re=C-m-v,ie=Math.round(C*1e3),ae=bU(u,Math.round(re*1e3)),oe=new zU(u,ae),se=z(d/1e3),ce=z(ie/1e3),le=GW([],[new RU([oe],{width:se,height:ce,viewBox:`0 0 `+d+` `+ie})],r);le.height=ie/1e3,le.style.width=se,le.style.height=ce,ne.push({type:`elem`,elem:le})}else{if(ne.push(PK(l,f,i)),ne.push(LK),s===null){var ue=C-m-v+2*IK;ne.push(FK(c,ue,r))}else{var de=(C-m-v-y)/2+2*IK;ne.push(FK(c,de,r)),ne.push(LK),ne.push(PK(s,f,i)),ne.push(LK),ne.push(FK(c,de,r))}ne.push(LK),ne.push(PK(o,f,i))}var fe=r.havingBaseStyle(R.TEXT);return kK(X([`delimsizing`,`mult`],[ZW({positionType:`bottom`,positionData:te,children:ne})],fe),R.TEXT,r,a)},VK=80,HK=.08,UK=function(e,t,n,r,i){return GW([`hide-tail`],[new RU([new zU(e,_U(e,r,n))],{width:`400em`,height:z(t),viewBox:`0 0 400000 `+n,preserveAspectRatio:`xMinYMin slice`})],i)},WK=function(e,t){var n=t.havingBaseSizing(),r=eq(`\\surd`,e*n.sizeMultiplier,QK,n),i=n.sizeMultiplier,a=Math.max(0,t.minRuleThickness-t.fontMetrics().sqrtRuleThickness),o,s,c,l,u;return r.type===`small`?(l=1e3+1e3*a+VK,e<1?i=1:e<1.4&&(i=.7),s=(1+a+HK)/i,c=(1+a)/i,o=UK(`sqrtMain`,s,l,a,t),o.style.minWidth=`0.853em`,u=.833/i):r.type===`large`?(l=(1e3+VK)*JK[r.size],c=(JK[r.size]+a)/i,s=(JK[r.size]+a+HK)/i,o=UK(`sqrtSize`+r.size,s,l,a,t),o.style.minWidth=`1.02em`,u=1/i):(s=e+a+HK,c=e+a,l=Math.floor(1e3*e+a)+VK,o=UK(`sqrtTall`,s,l,a,t),o.style.minWidth=`0.742em`,u=1.056),o.height=c,o.style.height=z(s),{span:o,advanceWidth:u,ruleWidth:(t.fontMetrics().sqrtRuleThickness+a)*i}},GK=new Set([`(`,`\\lparen`,`)`,`\\rparen`,`[`,`\\lbrack`,`]`,`\\rbrack`,`\\{`,`\\lbrace`,`\\}`,`\\rbrace`,`\\lfloor`,`\\rfloor`,`⌊`,`⌋`,`\\lceil`,`\\rceil`,`⌈`,`⌉`,`\\surd`]),KK=new Set([`\\uparrow`,`\\downarrow`,`\\updownarrow`,`\\Uparrow`,`\\Downarrow`,`\\Updownarrow`,`|`,`\\|`,`\\vert`,`\\Vert`,`\\lvert`,`\\rvert`,`\\lVert`,`\\rVert`,`\\lgroup`,`\\rgroup`,`⟮`,`⟯`,`\\lmoustache`,`\\rmoustache`,`⎰`,`⎱`]),qK=new Set([`<`,`>`,`\\langle`,`\\rangle`,`/`,`\\backslash`,`\\lt`,`\\gt`]),JK=[0,1.2,1.8,2.4,3],YK=function(e,t,n,r,i){if(e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`),GK.has(e)||qK.has(e))return NK(e,t,!1,n,r,i);if(KK.has(e))return BK(e,JK[t],!1,n,r,i);throw new L(`Illegal delimiter: '`+e+`'`)},XK=[{type:`small`,style:R.SCRIPTSCRIPT},{type:`small`,style:R.SCRIPT},{type:`small`,style:R.TEXT},{type:`large`,size:1},{type:`large`,size:2},{type:`large`,size:3},{type:`large`,size:4}],ZK=[{type:`small`,style:R.SCRIPTSCRIPT},{type:`small`,style:R.SCRIPT},{type:`small`,style:R.TEXT},{type:`stack`}],QK=[{type:`small`,style:R.SCRIPTSCRIPT},{type:`small`,style:R.SCRIPT},{type:`small`,style:R.TEXT},{type:`large`,size:1},{type:`large`,size:2},{type:`large`,size:3},{type:`large`,size:4},{type:`stack`}],$K=function(e){if(e.type===`small`)return`Main-Regular`;if(e.type===`large`)return`Size`+e.size+`-Regular`;if(e.type===`stack`)return`Size4-Regular`;var t=e.type;throw Error(`Add support for delim type '`+t+`' here.`)},eq=function(e,t,n,r){for(var i=Math.min(2,3-r.style.size);it)return a}return n[n.length-1]},tq=function(e,t,n,r,i,a){e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`);var o=qK.has(e)?XK:GK.has(e)?QK:ZK,s=eq(e,t,o,r);return s.type===`small`?jK(e,s.style,n,r,i,a):s.type===`large`?NK(e,s.size,n,r,i,a):BK(e,t,n,r,i,a)},nq=function(e,t,n,r,i,a){var o=r.fontMetrics().axisHeight*r.sizeMultiplier,s=901,c=5/r.fontMetrics().ptPerEm,l=Math.max(t-o,n+o);return tq(e,Math.max(l/500*s,2*l-c),!0,r,i,a)},rq={"\\bigl":{mclass:`mopen`,size:1},"\\Bigl":{mclass:`mopen`,size:2},"\\biggl":{mclass:`mopen`,size:3},"\\Biggl":{mclass:`mopen`,size:4},"\\bigr":{mclass:`mclose`,size:1},"\\Bigr":{mclass:`mclose`,size:2},"\\biggr":{mclass:`mclose`,size:3},"\\Biggr":{mclass:`mclose`,size:4},"\\bigm":{mclass:`mrel`,size:1},"\\Bigm":{mclass:`mrel`,size:2},"\\biggm":{mclass:`mrel`,size:3},"\\Biggm":{mclass:`mrel`,size:4},"\\big":{mclass:`mord`,size:1},"\\Big":{mclass:`mord`,size:2},"\\bigg":{mclass:`mord`,size:3},"\\Bigg":{mclass:`mord`,size:4}},iq=new Set(`(,\\lparen,),\\rparen,[,\\lbrack,],\\rbrack,\\{,\\lbrace,\\},\\rbrace,\\lfloor,\\rfloor,⌊,⌋,\\lceil,\\rceil,⌈,⌉,<,>,\\langle,⟨,\\rangle,⟩,\\lt,\\gt,\\lvert,\\rvert,\\lVert,\\rVert,\\lgroup,\\rgroup,⟮,⟯,\\lmoustache,\\rmoustache,⎰,⎱,/,\\backslash,|,\\vert,\\|,\\Vert,\\uparrow,\\Uparrow,\\downarrow,\\Downarrow,\\updownarrow,\\Updownarrow,.`.split(`,`));function aq(e){return`isMiddle`in e}function oq(e,t){var n=cK(e);if(n&&iq.has(n.text))return n;throw n?new L(`Invalid delimiter '`+n.text+`' after '`+t.funcName+`'`,e):new L(`Invalid delimiter type '`+e.type+`'`,e)}Z({type:`delimsizing`,names:[`\\bigl`,`\\Bigl`,`\\biggl`,`\\Biggl`,`\\bigr`,`\\Bigr`,`\\biggr`,`\\Biggr`,`\\bigm`,`\\Bigm`,`\\biggm`,`\\Biggm`,`\\big`,`\\Big`,`\\bigg`,`\\Bigg`],numArgs:1,argTypes:[`primitive`],handler:(e,t)=>{var n=oq(fG(t[0]),e);return{type:`delimsizing`,mode:e.parser.mode,size:rq[e.funcName].size,mclass:rq[e.funcName].mclass,delim:n.text}},htmlBuilder:(e,t)=>e.delim===`.`?X([e.mclass]):YK(e.delim,e.size,t,e.mode,[e.mclass]),mathmlBuilder:e=>{var t=[];e.delim!==`.`&&t.push(MG(e.delim,e.mode));var n=new Q(`mo`,t);e.mclass===`mopen`||e.mclass===`mclose`?n.setAttribute(`fence`,`true`):n.setAttribute(`fence`,`false`),n.setAttribute(`stretchy`,`true`);var r=z(JK[e.size]);return n.setAttribute(`minsize`,r),n.setAttribute(`maxsize`,r),n}});function sq(e){if(!e.body)throw Error(`Bug: The leftright ParseNode wasn't fully parsed.`)}Z({type:`leftright-right`,names:[`\\right`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=e.parser.gullet.macros.get(`\\current@color`);if(n&&typeof n!=`string`)throw new L(`\\current@color set to non-string in \\right`);return{type:`leftright-right`,mode:e.parser.mode,delim:oq(t[0],e).text,color:n}}}),Z({type:`leftright`,names:[`\\left`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=oq(t[0],e),r=e.parser;++r.leftrightDepth;var i=r.parseExpression(!1);--r.leftrightDepth,r.expect(`\\right`,!1);var a=oK(r.parseFunction(),`leftright-right`);return{type:`leftright`,mode:r.mode,body:i,left:n.text,right:a.delim,rightColor:a.color}},htmlBuilder:(e,t)=>{sq(e);for(var n=vG(e.body,t,!0,[`mopen`,`mclose`]),r=0,i=0,a=!1,o=0;o{sq(e);var n=LG(e.body,t);if(e.left!==`.`){var r=new Q(`mo`,[MG(e.left,e.mode)]);r.setAttribute(`fence`,`true`),n.unshift(r)}if(e.right!==`.`){var i=new Q(`mo`,[MG(e.right,e.mode)]);i.setAttribute(`fence`,`true`),e.rightColor&&i.setAttribute(`mathcolor`,e.rightColor),n.push(i)}return NG(n)}}),Z({type:`middle`,names:[`\\middle`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=oq(t[0],e);if(!e.parser.leftrightDepth)throw new L(`\\middle without preceding \\left`,n);return{type:`middle`,mode:e.parser.mode,delim:n.text}},htmlBuilder:(e,t)=>{var n;return e.delim===`.`?n=CG(t,[]):(n=YK(e.delim,1,t,e.mode,[]),n.isMiddle={delim:e.delim,options:t}),n},mathmlBuilder:(e,t)=>{var n=new Q(`mo`,[e.delim===`\\vert`||e.delim===`|`?MG(`|`,`text`):MG(e.delim,e.mode)]);return n.setAttribute(`fence`,`true`),n.setAttribute(`lspace`,`0.05em`),n.setAttribute(`rspace`,`0.05em`),n}}),Z({type:`enclose`,names:[`\\colorbox`],numArgs:2,allowedInText:!0,argTypes:[`color`,`hbox`],handler(e,t,n){var r=e.parser,i=e.funcName,a=oK(t[0],`color-token`).color,o=t[1];return{type:`enclose`,mode:r.mode,label:i,backgroundColor:a,body:o}},htmlBuilder:(e,t)=>{var n=YW(wG(e.body,t),t),r=e.label.slice(1),i=t.sizeMultiplier,a,o,s=FH(e.body);if(r===`sout`)a=X([`katex-stretchy`,`katex-sout`]),a.height=t.fontMetrics().defaultRuleThickness/i,o=-.5*t.fontMetrics().xHeight;else if(r===`phase`){var c=EU({number:.6,unit:`pt`},t),l=EU({number:.35,unit:`ex`},t),u=t.havingBaseSizing();i/=u.sizeMultiplier;var d=n.height+n.depth+c+l;n.style.paddingLeft=z(d/2+c);var f=Math.floor(1e3*d*i);a=GW([`hide-tail`],[new RU([new zU(`phase`,hU(f))],{width:`400em`,height:z(f/1e3),viewBox:`0 0 400000 `+f,preserveAspectRatio:`xMinYMin slice`})],t),a.style.height=z(d),o=n.depth+c+l}else{/cancel/.test(r)?s||n.classes.push(`cancel-pad`):r===`angl`?n.classes.push(`anglpad`):n.classes.push(`boxpad`);var p,m,h=0;/box/.test(r)?(h=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness),p=t.fontMetrics().fboxsep+(r===`colorbox`?0:h),m=p):r===`angl`?(h=Math.max(t.fontMetrics().defaultRuleThickness,t.minRuleThickness),p=4*h,m=Math.max(0,.25-n.depth)):(p=s?.2:0,m=p),a=eK(n,r,p,m,t),/fbox|boxed|fcolorbox/.test(r)?(a.style.borderStyle=`solid`,a.style.borderWidth=z(h)):r===`angl`&&h!==.049&&(a.style.borderTopWidth=z(h),a.style.borderRightWidth=z(h)),o=n.depth+m,e.backgroundColor&&(a.style.backgroundColor=e.backgroundColor,e.borderColor&&(a.style.borderColor=e.borderColor))}var g;if(e.backgroundColor)g=ZW({positionType:`individualShift`,children:[{type:`elem`,elem:a,shift:o},{type:`elem`,elem:n,shift:0}]});else{var _=/cancel|phase/.test(r)?[`svg-align`]:[];g=ZW({positionType:`individualShift`,children:[{type:`elem`,elem:n,shift:0},{type:`elem`,elem:a,shift:o,wrapperClasses:_}]})}return/cancel/.test(r)&&(g.height=n.height,g.depth=n.depth),/cancel/.test(r)&&!s?X([`mord`,`cancel-lap`],[g],t):X([`mord`],[g],t)},mathmlBuilder:(e,t)=>{var n,r=new Q(e.label.includes(`colorbox`)?`mpadded`:`menclose`,[zG(e.body,t)]);switch(e.label){case`\\cancel`:r.setAttribute(`notation`,`updiagonalstrike`);break;case`\\bcancel`:r.setAttribute(`notation`,`downdiagonalstrike`);break;case`\\phase`:r.setAttribute(`notation`,`phasorangle`);break;case`\\sout`:r.setAttribute(`notation`,`horizontalstrike`);break;case`\\fbox`:r.setAttribute(`notation`,`box`);break;case`\\angl`:r.setAttribute(`notation`,`actuarial`);break;case`\\fcolorbox`:case`\\colorbox`:if(n=t.fontMetrics().fboxsep*t.fontMetrics().ptPerEm,r.setAttribute(`width`,`+`+2*n+`pt`),r.setAttribute(`height`,`+`+2*n+`pt`),r.setAttribute(`lspace`,n+`pt`),r.setAttribute(`voffset`,n+`pt`),e.label===`\\fcolorbox`){var i=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness);r.setAttribute(`style`,`border: `+z(i)+` solid `+e.borderColor)}break;case`\\xcancel`:r.setAttribute(`notation`,`updiagonalstrike downdiagonalstrike`)}return e.backgroundColor&&r.setAttribute(`mathbackground`,e.backgroundColor),r}}),Z({type:`enclose`,names:[`\\fcolorbox`],numArgs:3,allowedInText:!0,argTypes:[`color`,`color`,`hbox`],handler(e,t,n){var r=e.parser,i=e.funcName,a=oK(t[0],`color-token`).color,o=oK(t[1],`color-token`).color,s=t[2];return{type:`enclose`,mode:r.mode,label:i,backgroundColor:o,borderColor:a,body:s}}}),Z({type:`enclose`,names:[`\\fbox`],numArgs:1,argTypes:[`hbox`],allowedInText:!0,handler(e,t){return{type:`enclose`,mode:e.parser.mode,label:`\\fbox`,body:t[0]}}}),Z({type:`enclose`,names:[`\\cancel`,`\\bcancel`,`\\xcancel`,`\\phase`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`enclose`,mode:n.mode,label:r,body:i}}}),Z({type:`enclose`,names:[`\\sout`],numArgs:1,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName;n.mode===`math`&&n.settings.reportNonstrict(`mathVsSout`,`LaTeX's \\sout works only in text mode`);var i=t[0];return{type:`enclose`,mode:n.mode,label:r,body:i}}}),Z({type:`enclose`,names:[`\\angl`],numArgs:1,argTypes:[`hbox`],allowedInText:!1,handler(e,t){return{type:`enclose`,mode:e.parser.mode,label:`\\angl`,body:t[0]}}});var cq={};function lq(e){for(var t=e.type,n=e.names,r=e.props,i=e.handler,a=e.htmlBuilder,o=e.mathmlBuilder,s={type:t,numArgs:r.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:i},c=0;c{if(!e.parser.settings.displayMode)throw new L(`{`+e.envName+`} can be used only in display mode.`)},hq=new Set([`gather`,`gather*`]);function gq(e){if(!e.includes(`ed`))return!e.includes(`*`)}function _q(e,t,n){var r=t.hskipBeforeAndAfter,i=t.addJot,a=t.cols,o=t.arraystretch,s=t.colSeparationType,c=t.autoTag,l=t.singleRow,u=t.emptySingleRow,d=t.maxNumCols,f=t.leqno;if(e.gullet.beginGroup(),l||e.gullet.macros.set(`\\cr`,`\\\\\\relax`),!o){var p=e.gullet.expandMacroAsText(`\\arraystretch`);if(p==null)o=1;else if(o=parseFloat(p),!o||o<0)throw new L(`Invalid \\arraystretch: `+p)}e.gullet.beginGroup();var m=[],h=[m],g=[],_=[],v=c==null?void 0:[];function y(){c&&e.gullet.macros.set(`\\@eqnsw`,`1`,!0)}function b(){v&&(e.gullet.macros.get(`\\df@tag`)?(v.push(e.subparse([new fq(`\\df@tag`)])),e.gullet.macros.set(`\\df@tag`,void 0,!0)):v.push(!!c&&e.gullet.macros.get(`\\@eqnsw`)===`1`))}for(y(),_.push(pq(e));;){var x=e.parseExpression(!1,l?`\\end`:`\\\\`);e.gullet.endGroup(),e.gullet.beginGroup();var S={type:`ordgroup`,mode:e.mode,body:x};n&&(S={type:`styling`,mode:e.mode,style:n,resetFont:!0,body:[S]}),m.push(S);var C=e.fetch().text;if(C===`&`){if(d&&m.length===d){if(l||s)throw new L(`Too many tab characters: &`,e.nextToken);e.settings.reportNonstrict(`textEnv`,`Too few columns specified in the {array} column argument.`)}e.consume()}else if(C===`\\end`){b(),m.length===1&&S.type===`styling`&&S.body.length===1&&S.body[0].type===`ordgroup`&&S.body[0].body.length===0&&(h.length>1||!u)&&!Array.isArray(v?.[v.length-1])&&!(c&&v?.[v.length-1]===!0)&&h.pop(),_.length0&&(_+=.25),c.push({pos:_,isDashed:e[t]})}for(v(a[0]),n=0;n0&&(te+=g,xe))for(n=0;n=o)){var ve=void 0;(r>0||e.hskipBeforeAndAfter)&&(ve=fe?.pregap??d,ve!==0&&(ae=X([`arraycolsep`],[]),ae.style.width=z(ve),ie.push(ae)));var ye=[];for(n=0;n0){for(var Ee=KW(`katex-hline`,t,l),De=KW(`katex-hdashline`,t,l),Oe=[{type:`elem`,elem:Te,shift:0}];c.length>0;){var ke=c.pop(),Ae=ke.pos-ne;ke.isDashed?Oe.push({type:`elem`,elem:De,shift:Ae}):Oe.push({type:`elem`,elem:Ee,shift:Ae})}Te=ZW({positionType:`individualShift`,children:Oe})}if(se.length===0)return X([`mord`],[Te],t);var je=X([`katex-tag`],[ZW({positionType:`individualShift`,children:se})],t);return JW([Te,je])},bq={c:`center `,l:`left `,r:`right `},xq=function(e,t){for(var n=[],r=new Q(`mtd`,[],[`mtr-glue`]),i=new Q(`mtd`,[],[`mml-eqn-num`]),a=0;a0){var p=e.cols,m=``,h=!1,g=0,_=p.length;p[0].type===`separator`&&(d+=`top `,g=1),p[p.length-1].type===`separator`&&(d+=`bottom `,--_);for(var v=g;v<_;v++){var y=p[v];y.type===`align`?(f+=bq[y.align],h&&(m+=`none `),h=!0):y.type===`separator`&&(h&&=(m+=y.separator===`|`?`solid `:`dashed `,!1))}l.setAttribute(`columnalign`,f.trim()),/[sd]/.test(m)&&l.setAttribute(`columnlines`,m.trim())}if(e.colSeparationType===`align`){for(var b=e.cols||[],x=``,S=1;S0?`left `:``,d+=ee[ee.length-1].length>0?`right `:``;for(var te=1;te0&&u&&(p=1),n[d]={type:`align`,align:f,pregap:p,postgap:0}}return i.colSeparationType=u?`align`:`alignat`,i};lq({type:`array`,names:[`array`,`darray`],props:{numArgs:1},handler(e,t){var n=(cK(t[0])?[t[0]]:oK(t[0],`ordgroup`).body).map(function(e){var t=sK(e).text;if(`lcr`.includes(t))return{type:`align`,align:t};if(t===`|`)return{type:`separator`,separator:`|`};if(t===`:`)return{type:`separator`,separator:`:`};throw new L(`Unknown column alignment: `+t,e)}),r={cols:n,hskipBeforeAndAfter:!0,maxNumCols:n.length};return _q(e.parser,r,vq(e.envName))},htmlBuilder:yq,mathmlBuilder:xq}),lq({type:`array`,names:[`matrix`,`pmatrix`,`bmatrix`,`Bmatrix`,`vmatrix`,`Vmatrix`,`matrix*`,`pmatrix*`,`bmatrix*`,`Bmatrix*`,`vmatrix*`,`Vmatrix*`],props:{numArgs:0},handler(e){var t={matrix:null,pmatrix:[`(`,`)`],bmatrix:[`[`,`]`],Bmatrix:[`\\{`,`\\}`],vmatrix:[`|`,`|`],Vmatrix:[`\\Vert`,`\\Vert`]}[e.envName.replace(`*`,``)],n=`c`,r={hskipBeforeAndAfter:!1,cols:[{type:`align`,align:n}]};if(e.envName.charAt(e.envName.length-1)===`*`){var i=e.parser;if(i.consumeSpaces(),i.fetch().text===`[`){if(i.consume(),i.consumeSpaces(),n=i.fetch().text,!`lcr`.includes(n))throw new L(`Expected l or c or r`,i.nextToken);i.consume(),i.consumeSpaces(),i.expect(`]`),i.consume(),r.cols=[{type:`align`,align:n}]}}var a=_q(e.parser,r,vq(e.envName)),o=Math.max(0,...a.body.map(e=>e.length));return a.cols=Array(o).fill({type:`align`,align:n}),t?{type:`leftright`,mode:e.mode,body:[a],left:t[0],right:t[1],rightColor:void 0}:a},htmlBuilder:yq,mathmlBuilder:xq}),lq({type:`array`,names:[`smallmatrix`],props:{numArgs:0},handler(e){var t=_q(e.parser,{arraystretch:.5},`script`);return t.colSeparationType=`small`,t},htmlBuilder:yq,mathmlBuilder:xq}),lq({type:`array`,names:[`subarray`],props:{numArgs:1},handler(e,t){var n=(cK(t[0])?[t[0]]:oK(t[0],`ordgroup`).body).map(function(e){var t=sK(e).text;if(`lc`.includes(t))return{type:`align`,align:t};throw new L(`Unknown column alignment: `+t,e)});if(n.length>1)throw new L(`{subarray} can contain only one column`);var r={cols:n,hskipBeforeAndAfter:!1,arraystretch:.5},i=_q(e.parser,r,`script`);if(i.body.length>0&&i.body[0].length>1)throw new L(`{subarray} can contain only one column`);return i},htmlBuilder:yq,mathmlBuilder:xq}),lq({type:`array`,names:[`cases`,`dcases`,`rcases`,`drcases`],props:{numArgs:0},handler(e){var t=_q(e.parser,{arraystretch:1.2,cols:[{type:`align`,align:`l`,pregap:0,postgap:1},{type:`align`,align:`l`,pregap:0,postgap:0}]},vq(e.envName));return{type:`leftright`,mode:e.mode,body:[t],left:e.envName.includes(`r`)?`.`:`\\{`,right:e.envName.includes(`r`)?`\\}`:`.`,rightColor:void 0}},htmlBuilder:yq,mathmlBuilder:xq}),lq({type:`array`,names:[`align`,`align*`,`aligned`,`split`],props:{numArgs:0},handler:Sq,htmlBuilder:yq,mathmlBuilder:xq}),lq({type:`array`,names:[`gathered`,`gather`,`gather*`],props:{numArgs:0},handler(e){hq.has(e.envName)&&mq(e);var t={cols:[{type:`align`,align:`c`}],addJot:!0,colSeparationType:`gather`,autoTag:gq(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return _q(e.parser,t,`display`)},htmlBuilder:yq,mathmlBuilder:xq}),lq({type:`array`,names:[`alignat`,`alignat*`,`alignedat`],props:{numArgs:1},handler:Sq,htmlBuilder:yq,mathmlBuilder:xq}),lq({type:`array`,names:[`equation`,`equation*`],props:{numArgs:0},handler(e){mq(e);var t={autoTag:gq(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:e.parser.settings.leqno};return _q(e.parser,t,`display`)},htmlBuilder:yq,mathmlBuilder:xq}),lq({type:`array`,names:[`CD`],props:{numArgs:0},handler(e){return mq(e),CK(e.parser)},htmlBuilder:yq,mathmlBuilder:xq}),$(`\\nonumber`,`\\gdef\\@eqnsw{0}`),$(`\\notag`,`\\nonumber`),Z({type:`text`,names:[`\\hline`,`\\hdashline`],numArgs:0,allowedInText:!0,allowedInMath:!0,handler(e,t){throw new L(e.funcName+` valid only within array environment`)}});var Cq=cq;Z({type:`environment`,names:[`\\begin`,`\\end`],numArgs:1,argTypes:[`text`],handler(e,t){var n=e.parser,r=e.funcName,i=t[0];if(i.type!==`ordgroup`)throw new L(`Invalid environment name`,i);var a=lK(i,`Environment name should contain only text characters and spaces`,!0);if(r===`\\begin`){if(!Object.prototype.hasOwnProperty.call(Cq,a))throw new L(`No such environment: `+a,i);var o=Cq[a],s=n.parseArguments(`\\begin{`+a+`}`,o),c=s.args,l=s.optArgs,u={mode:n.mode,envName:a,parser:n},d=o.handler(u,c,l);n.expect(`\\end`,!1);var f=n.nextToken,p=oK(n.parseFunction(),`environment`);if(p.name!==a)throw new L(`Mismatch: \\begin{`+a+`} matched by \\end{`+p.name+`}`,f);return d}return{type:`environment`,mode:n.mode,name:a,nameGroup:i}}});var wq=(e,t)=>{var n=e.font,r=t.withFont(n);return wG(e.body,r)},Tq=(e,t)=>{var n=e.font,r=t.withFont(n);return zG(e.body,r)},Eq={"\\Bbb":`\\mathbb`,"\\bold":`\\mathbf`,"\\frak":`\\mathfrak`};Z({type:`font`,names:[`\\mathrm`,`\\mathit`,`\\mathbf`,`\\mathnormal`,`\\mathsfit`,`\\mathbb`,`\\mathcal`,`\\mathfrak`,`\\mathscr`,`\\mathsf`,`\\mathtt`,`\\Bbb`,`\\bold`,`\\frak`],numArgs:1,allowedInArgument:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=fG(t[0]),a=r in Eq?Eq[r]:r;return{type:`font`,mode:n.mode,font:a.slice(1),body:i}},htmlBuilder:wq,mathmlBuilder:Tq}),Z({type:`mclass`,names:[`\\boldsymbol`,`\\bm`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`mclass`,mode:n.mode,mclass:_K(r),body:[{type:`font`,mode:n.mode,font:`boldsymbol`,body:r}],isCharacterBox:FH(r)}}}),Z({type:`font`,names:[`\\rm`,`\\sf`,`\\tt`,`\\bf`,`\\it`,`\\cal`],numArgs:0,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=e.breakOnTokenText,a=n.mode,o=n.parseExpression(!0,i);return{type:`font`,mode:a,font:`math`+r.slice(1),body:{type:`ordgroup`,mode:n.mode,body:o}}}});var Dq=(e,t)=>{var n=t.style,r=n.fracNum(),i=n.fracDen(),a=t.havingStyle(r),o=wG(e.numer,a,t);if(e.continued){var s=8.5/t.fontMetrics().ptPerEm,c=3.5/t.fontMetrics().ptPerEm;o.height=o.height0?3*f:7*f,h=t.fontMetrics().denom1):(d>0?(p=t.fontMetrics().num2,m=f):(p=t.fontMetrics().num3,m=3*f),h=t.fontMetrics().denom2);var g;if(u){var _=t.fontMetrics().axisHeight;p-o.depth-(_+.5*d){var n=new Q(`mfrac`,[zG(e.numer,t),zG(e.denom,t)]);if(!e.hasBarLine)n.setAttribute(`linethickness`,`0px`);else if(e.barSize){var r=EU(e.barSize,t);n.setAttribute(`linethickness`,z(r))}if(e.leftDelim!=null||e.rightDelim!=null){var i=[];if(e.leftDelim!=null){var a=new Q(`mo`,[new OG(e.leftDelim.replace(`\\`,``))]);a.setAttribute(`fence`,`true`),i.push(a)}if(i.push(n),e.rightDelim!=null){var o=new Q(`mo`,[new OG(e.rightDelim.replace(`\\`,``))]);o.setAttribute(`fence`,`true`),i.push(o)}return NG(i)}return n},kq=(e,t)=>t?{type:`styling`,mode:e.mode,style:t,body:[e]}:e;Z({type:`genfrac`,names:[`\\cfrac`,`\\dfrac`,`\\frac`,`\\tfrac`,`\\dbinom`,`\\binom`,`\\tbinom`,`\\\\atopfrac`,`\\\\bracefrac`,`\\\\brackfrac`],numArgs:2,allowedInArgument:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0],a=t[1],o,s=null,c=null;switch(r){case`\\cfrac`:case`\\dfrac`:case`\\frac`:case`\\tfrac`:o=!0;break;case`\\\\atopfrac`:o=!1;break;case`\\dbinom`:case`\\binom`:case`\\tbinom`:o=!1,s=`(`,c=`)`;break;case`\\\\bracefrac`:o=!1,s=`\\{`,c=`\\}`;break;case`\\\\brackfrac`:o=!1,s=`[`,c=`]`;break;default:throw Error(`Unrecognized genfrac command`)}var l=r===`\\cfrac`,u=null;return l||r.startsWith(`\\d`)?u=`display`:r.startsWith(`\\t`)&&(u=`text`),kq({type:`genfrac`,mode:n.mode,numer:i,denom:a,continued:l,hasBarLine:o,leftDelim:s,rightDelim:c,barSize:null},u)},htmlBuilder:Dq,mathmlBuilder:Oq}),Z({type:`infix`,names:[`\\over`,`\\choose`,`\\atop`,`\\brace`,`\\brack`],numArgs:0,infix:!0,handler(e){var t=e.parser,n=e.funcName,r=e.token,i;switch(n){case`\\over`:i=`\\frac`;break;case`\\choose`:i=`\\binom`;break;case`\\atop`:i=`\\\\atopfrac`;break;case`\\brace`:i=`\\\\bracefrac`;break;case`\\brack`:i=`\\\\brackfrac`;break;default:throw Error(`Unrecognized infix genfrac command`)}return{type:`infix`,mode:t.mode,replaceWith:i,token:r}}});var Aq=[`display`,`text`,`script`,`scriptscript`],jq=function(e){var t=null;return e.length>0&&(t=e,t=t===`.`?null:t),t};Z({type:`genfrac`,names:[`\\genfrac`],numArgs:6,allowedInArgument:!0,argTypes:[`math`,`math`,`size`,`text`,`math`,`math`],handler(e,t){var n=e.parser,r=t[4],i=t[5],a=fG(t[0]),o=a.type===`atom`&&a.family===`open`?jq(a.text):null,s=fG(t[1]),c=s.type===`atom`&&s.family===`close`?jq(s.text):null,l=oK(t[2],`size`),u,d=null;l.isBlank?u=!0:(d=l.value,u=d.number>0);var f=null,p=t[3];if(p.type===`ordgroup`){if(p.body.length>0){var m=oK(p.body[0],`textord`);f=Aq[Number(m.text)]}}else p=oK(p,`textord`),f=Aq[Number(p.text)];return kq({type:`genfrac`,mode:n.mode,numer:r,denom:i,continued:!1,hasBarLine:u,barSize:d,leftDelim:o,rightDelim:c},f)}}),Z({type:`infix`,names:[`\\above`],numArgs:1,argTypes:[`size`],infix:!0,handler(e,t){var n=e.parser;e.funcName;var r=e.token;return{type:`infix`,mode:n.mode,replaceWith:`\\\\abovefrac`,size:oK(t[0],`size`).value,token:r}}}),Z({type:`genfrac`,names:[`\\\\abovefrac`],numArgs:3,argTypes:[`math`,`size`,`math`],handler:(e,t)=>{var n=e.parser;e.funcName;var r=t[0],i=oK(t[1],`infix`).size;if(!i)throw Error(`\\\\abovefrac expected size, but got `+String(i));var a=t[2],o=i.number>0;return{type:`genfrac`,mode:n.mode,numer:r,denom:a,continued:!1,hasBarLine:o,barSize:i,leftDelim:null,rightDelim:null}}});var Mq=(e,t)=>{var n=t.style,r,i;e.type===`supsub`?(r=e.sup?wG(e.sup,t.havingStyle(n.sup()),t):wG(e.sub,t.havingStyle(n.sub()),t),i=oK(e.base,`horizBrace`)):i=oK(e,`horizBrace`);var a=wG(i.base,t.havingBaseStyle(R.DISPLAY)),o=$G(i,t),s=i.isOver?ZW({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:.1},{type:`elem`,elem:o,wrapperClasses:[`svg-align`]}]}):ZW({positionType:`bottom`,positionData:a.depth+.1+o.height,children:[{type:`elem`,elem:o,wrapperClasses:[`svg-align`]},{type:`kern`,size:.1},{type:`elem`,elem:a}]});if(r){var c=X([`minner`,i.isOver?`mover`:`munder`],[s],t);s=i.isOver?ZW({positionType:`firstBaseline`,children:[{type:`elem`,elem:c},{type:`kern`,size:.2},{type:`elem`,elem:r}]}):ZW({positionType:`bottom`,positionData:c.depth+.2+r.height+r.depth,children:[{type:`elem`,elem:r},{type:`kern`,size:.2},{type:`elem`,elem:c}]})}return X([`minner`,i.isOver?`mover`:`munder`],[s],t)};Z({type:`horizBrace`,names:[`\\overbrace`,`\\underbrace`,`\\overbracket`,`\\underbracket`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName;return{type:`horizBrace`,mode:n.mode,label:r,isOver:r.includes(`\\over`),base:t[0]}},htmlBuilder:Mq,mathmlBuilder:(e,t)=>{var n=XG(e.label);return new Q(e.isOver?`mover`:`munder`,[zG(e.base,t),n])}}),Z({type:`href`,names:[`\\href`],numArgs:2,argTypes:[`url`,`original`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[1],i=oK(t[0],`url`).url;return n.settings.isTrusted({command:`\\href`,url:i})?{type:`href`,mode:n.mode,href:i,body:pG(r)}:n.formatUnsupportedCmd(`\\href`)},htmlBuilder:(e,t)=>{var n=vG(e.body,t,!1);return qW(e.href,[],n,t)},mathmlBuilder:(e,t)=>{var n=RG(e.body,t);return n instanceof Q||(n=new Q(`mrow`,[n])),n.setAttribute(`href`,e.href),n}}),Z({type:`href`,names:[`\\url`],numArgs:1,argTypes:[`url`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=oK(t[0],`url`).url;if(!n.settings.isTrusted({command:`\\url`,url:r}))return n.formatUnsupportedCmd(`\\url`);for(var i=[],a=0;a{var n=e.parser,r=e.funcName;e.token;var i=oK(t[0],`raw`).string,a=t[1];n.settings.strict&&n.settings.reportNonstrict(`htmlExtension`,`HTML extension is disabled on strict mode`);var o,s={};switch(r){case`\\htmlClass`:s.class=i,o={command:`\\htmlClass`,class:i};break;case`\\htmlId`:s.id=i,o={command:`\\htmlId`,id:i};break;case`\\htmlStyle`:s.style=i,o={command:`\\htmlStyle`,style:i};break;case`\\htmlData`:for(var c=`{,}`,l=[],u=``,d=0;d{var n=vG(e.body,t,!1),r=[`enclosing`];e.attributes.class&&r.push(...e.attributes.class.trim().split(/\s+/));var i=X(r,n,t);for(var a of Object.entries(e.attributes)){var o=a[0],s=a[1];o!==`class`&&i.setAttribute(o,s)}return i},mathmlBuilder:(e,t)=>RG(e.body,t)}),Z({type:`htmlmathml`,names:[`\\html@mathml`],numArgs:2,allowedInArgument:!0,allowedInText:!0,handler:(e,t)=>({type:`htmlmathml`,mode:e.parser.mode,html:pG(t[0]),mathml:pG(t[1])}),htmlBuilder:(e,t)=>JW(vG(e.html,t,!1)),mathmlBuilder:(e,t)=>RG(e.mathml,t)});var Nq=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:`bp`};var t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new L(`Invalid size: '`+e+`' in \\includegraphics`);var n={number:+(t[1]+t[2]),unit:t[3]};if(!TU(n))throw new L(`Invalid unit: '`+n.unit+`' in \\includegraphics.`);return n};Z({type:`includegraphics`,names:[`\\includegraphics`],numArgs:1,numOptionalArgs:1,argTypes:[`raw`,`url`],allowedInText:!1,handler:(e,t,n)=>{var r=e.parser,i={number:0,unit:`em`},a={number:.9,unit:`em`},o={number:0,unit:`em`},s=``;if(n[0])for(var c=oK(n[0],`raw`).string.split(`,`),l=0;l{var n=EU(e.height,t),r=0;e.totalheight.number>0&&(r=EU(e.totalheight,t)-n);var i=0;e.width.number>0&&(i=EU(e.width,t));var a={height:z(n+r)};i>0&&(a.width=z(i)),r>0&&(a.verticalAlign=z(-r));var o=new FU(e.src,e.alt,a);return o.height=n,o.depth=r,o},mathmlBuilder:(e,t)=>{var n=new Q(`mglyph`,[]);n.setAttribute(`alt`,e.alt);var r=EU(e.height,t),i=0;if(e.totalheight.number>0&&(i=EU(e.totalheight,t)-r,n.setAttribute(`valign`,z(-i))),n.setAttribute(`height`,z(r+i)),e.width.number>0){var a=EU(e.width,t);n.setAttribute(`width`,z(a))}return n.setAttribute(`src`,e.src),n}}),Z({type:`kern`,names:[`\\kern`,`\\mkern`,`\\hskip`,`\\mskip`],numArgs:1,argTypes:[`size`],primitive:!0,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName,i=oK(t[0],`size`);if(n.settings.strict){var a=r[1]===`m`,o=i.value.unit===`mu`;a?(o||n.settings.reportNonstrict(`mathVsTextUnits`,`LaTeX's `+r+` supports only mu units, `+(`not `+i.value.unit+` units`)),n.mode!==`math`&&n.settings.reportNonstrict(`mathVsTextUnits`,`LaTeX's `+r+` works only in math mode`)):o&&n.settings.reportNonstrict(`mathVsTextUnits`,`LaTeX's `+r+` doesn't support mu units`)}return{type:`kern`,mode:n.mode,dimension:i.value}},htmlBuilder(e,t){return QW(e.dimension,t)},mathmlBuilder(e,t){return new kG(EU(e.dimension,t))}}),Z({type:`lap`,names:[`\\mathllap`,`\\mathrlap`,`\\mathclap`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`lap`,mode:n.mode,alignment:r.slice(5),body:i}},htmlBuilder:(e,t)=>{var n;e.alignment===`clap`?(n=X([],[wG(e.body,t)]),n=X([`katex-inner`],[n],t)):n=X([`katex-inner`],[wG(e.body,t)]);var r=X([`katex-fix`],[]),i=X([e.alignment],[n,r],t),a=X([`katex-strut`]);return a.style.height=z(i.height+i.depth),i.depth&&(a.style.verticalAlign=z(-i.depth)),i.children.unshift(a),i=X([`katex-thinbox`],[i],t),X([`mord`,`katex-vbox`],[i],t)},mathmlBuilder:(e,t)=>{var n=new Q(`mpadded`,[zG(e.body,t)]);if(e.alignment!==`rlap`){var r=e.alignment===`llap`?`-1`:`-0.5`;n.setAttribute(`lspace`,r+`width`)}return n.setAttribute(`width`,`0px`),n}}),Z({type:`styling`,names:[`\\(`,`$`],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){var n=e.funcName,r=e.parser,i=r.mode;r.switchMode(`math`);var a=n===`\\(`?`\\)`:`$`,o=r.parseExpression(!1,a);return r.expect(a),r.switchMode(i),{type:`styling`,mode:r.mode,style:`text`,resetFont:!0,body:o}}}),Z({type:`text`,names:[`\\)`,`\\]`],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){throw new L(`Mismatched `+e.funcName)}});var Pq=(e,t)=>{switch(t.style.size){case R.DISPLAY.size:return e.display;case R.TEXT.size:return e.text;case R.SCRIPT.size:return e.script;case R.SCRIPTSCRIPT.size:return e.scriptscript;default:return e.text}};Z({type:`mathchoice`,names:[`\\mathchoice`],numArgs:4,primitive:!0,handler:(e,t)=>({type:`mathchoice`,mode:e.parser.mode,display:pG(t[0]),text:pG(t[1]),script:pG(t[2]),scriptscript:pG(t[3])}),htmlBuilder:(e,t)=>JW(vG(Pq(e,t),t,!1)),mathmlBuilder:(e,t)=>RG(Pq(e,t),t)});var Fq=(e,t,n,r,i,a,o)=>{e=X([],[e]);var s=n&&FH(n),c,l;if(t){var u=wG(t,r.havingStyle(i.sup()),r);l={elem:u,kern:Math.max(r.fontMetrics().bigOpSpacing1,r.fontMetrics().bigOpSpacing3-u.depth)}}if(n){var d=wG(n,r.havingStyle(i.sub()),r);c={elem:d,kern:Math.max(r.fontMetrics().bigOpSpacing2,r.fontMetrics().bigOpSpacing4-d.height)}}var f;if(l&&c)f=ZW({positionType:`bottom`,positionData:r.fontMetrics().bigOpSpacing5+c.elem.height+c.elem.depth+c.kern+e.depth+o,children:[{type:`kern`,size:r.fontMetrics().bigOpSpacing5},{type:`elem`,elem:c.elem,marginLeft:z(-a)},{type:`kern`,size:c.kern},{type:`elem`,elem:e},{type:`kern`,size:l.kern},{type:`elem`,elem:l.elem,marginLeft:z(a)},{type:`kern`,size:r.fontMetrics().bigOpSpacing5}]});else if(c)f=ZW({positionType:`top`,positionData:e.height-o,children:[{type:`kern`,size:r.fontMetrics().bigOpSpacing5},{type:`elem`,elem:c.elem,marginLeft:z(-a)},{type:`kern`,size:c.kern},{type:`elem`,elem:e}]});else if(l)f=ZW({positionType:`bottom`,positionData:e.depth+o,children:[{type:`elem`,elem:e},{type:`kern`,size:l.kern},{type:`elem`,elem:l.elem,marginLeft:z(a)},{type:`kern`,size:r.fontMetrics().bigOpSpacing5}]});else return e;var p=[f];if(c&&a!==0&&!s){var m=X([`mspace`],[],r);m.style.marginRight=z(a),p.unshift(m)}return X([`mop`,`op-limits`],p,r)},Iq=new Set([`\\smallint`]),Lq=(e,t)=>{var n,r,i=!1,a;e.type===`supsub`?(n=e.sup,r=e.sub,a=oK(e.base,`op`),i=!0):a=oK(e,`op`);var o=t.style,s=!1;o.size===R.DISPLAY.size&&a.symbol&&!Iq.has(a.name)&&(s=!0);var c,l;if(a.symbol){var u=s?`Size2-Regular`:`Size1-Regular`,d=``;if((a.name===`\\oiint`||a.name===`\\oiiint`)&&(d=a.name.slice(1),a.name=d===`oiint`?`\\iint`:`\\iiint`),c=RW(a.name,u,`math`,t,[`mop`,`op-symbol`,s?`large-op`:`small-op`]),l=c.italic,d.length>0){var f=nG(d+`Size`+(s?`2`:`1`),t);c=ZW({positionType:`individualShift`,children:[{type:`elem`,elem:c,shift:0},{type:`elem`,elem:f,shift:s?.08:0}]}),a.name=`\\`+d,c.classes.unshift(`mop`),c.italic=l}}else if(a.body){var p=vG(a.body,t,!0);p.length===1&&p[0]instanceof LU?(c=p[0],c.classes[0]=`mop`):c=X([`mop`],p,t)}else{for(var m=[],h=1;h{var n;if(e.symbol)n=new Q(`mo`,[MG(e.name,e.mode)]),Iq.has(e.name)&&n.setAttribute(`largeop`,`false`);else if(e.body)n=new Q(`mo`,LG(e.body,t));else{n=new Q(`mi`,[new OG(e.name.slice(1))]);var r=new Q(`mo`,[MG(`⁡`,`text`)]);n=e.parentIsSupSub?new Q(`mrow`,[n,r]):DG([n,r])}return n},zq={"∏":`\\prod`,"∐":`\\coprod`,"∑":`\\sum`,"⋀":`\\bigwedge`,"⋁":`\\bigvee`,"⋂":`\\bigcap`,"⋃":`\\bigcup`,"⨀":`\\bigodot`,"⨁":`\\bigoplus`,"⨂":`\\bigotimes`,"⨄":`\\biguplus`,"⨆":`\\bigsqcup`};Z({type:`op`,names:`\\coprod.\\bigvee.\\bigwedge.\\biguplus.\\bigcap.\\bigcup.\\intop.\\prod.\\sum.\\bigotimes.\\bigoplus.\\bigodot.\\bigsqcup.\\smallint.∏.∐.∑.⋀.⋁.⋂.⋃.⨀.⨁.⨂.⨄.⨆`.split(`.`),numArgs:0,handler:(e,t)=>{var n=e.parser,r=e.funcName;return r.length===1&&(r=zq[r]),{type:`op`,mode:n.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:r}},htmlBuilder:Lq,mathmlBuilder:Rq}),Z({type:`op`,names:[`\\mathop`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`op`,mode:n.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:pG(r)}}});var Bq={"∫":`\\int`,"∬":`\\iint`,"∭":`\\iiint`,"∮":`\\oint`,"∯":`\\oiint`,"∰":`\\oiiint`};Z({type:`op`,names:`\\arcsin.\\arccos.\\arctan.\\arctg.\\arcctg.\\arg.\\ch.\\cos.\\cosec.\\cosh.\\cot.\\cotg.\\coth.\\csc.\\ctg.\\cth.\\deg.\\dim.\\exp.\\hom.\\ker.\\lg.\\ln.\\log.\\sec.\\sin.\\sinh.\\sh.\\tan.\\tanh.\\tg.\\th`.split(`.`),numArgs:0,handler(e){var t=e.parser,n=e.funcName;return{type:`op`,mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:n}}}),Z({type:`op`,names:[`\\det`,`\\gcd`,`\\inf`,`\\lim`,`\\max`,`\\min`,`\\Pr`,`\\sup`],numArgs:0,handler(e){var t=e.parser,n=e.funcName;return{type:`op`,mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:n}}}),Z({type:`op`,names:[`\\int`,`\\iint`,`\\iiint`,`\\oint`,`\\oiint`,`\\oiiint`,`∫`,`∬`,`∭`,`∮`,`∯`,`∰`],numArgs:0,allowedInArgument:!0,handler(e){var t=e.parser,n=e.funcName;return n.length===1&&(n=Bq[n]),{type:`op`,mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}}});var Vq=(e,t)=>{var n,r,i=!1,a;e.type===`supsub`?(n=e.sup,r=e.sub,a=oK(e.base,`operatorname`),i=!0):a=oK(e,`operatorname`);var o;if(a.body.length>0){for(var s=vG(a.body.map(e=>{var t=`text`in e?e.text:void 0;return typeof t==`string`?{type:`textord`,mode:e.mode,text:t}:e}),t.withFont(`mathrm`),!0),c=0;c{var n=e.parser,r=e.funcName,i=t[0];return{type:`operatorname`,mode:n.mode,body:pG(i),alwaysHandleSupSub:r===`\\operatornamewithlimits`,limits:!1,parentIsSupSub:!1}},htmlBuilder:Vq,mathmlBuilder:(e,t)=>{for(var n=LG(e.body,t.withFont(`mathrm`)),r=!0,i=0;ie.toText()).join(``))]);var s=new Q(`mi`,n);s.setAttribute(`mathvariant`,`normal`);var c=new Q(`mo`,[MG(`⁡`,`text`)]);return e.parentIsSupSub?new Q(`mrow`,[s,c]):DG([s,c])}}),$(`\\operatorname`,`\\@ifstar\\operatornamewithlimits\\operatorname@`),dG({type:`ordgroup`,htmlBuilder(e,t){return e.semisimple?JW(vG(e.body,t,!1)):X([`mord`],vG(e.body,t,!0),t)},mathmlBuilder(e,t){return RG(e.body,t,!0)}}),Z({type:`overline`,names:[`\\overline`],numArgs:1,handler(e,t){var n=e.parser,r=t[0];return{type:`overline`,mode:n.mode,body:r}},htmlBuilder(e,t){var n=wG(e.body,t.havingCrampedStyle()),r=KW(`overline-line`,t),i=t.fontMetrics().defaultRuleThickness;return X([`mord`,`katex-overline`],[ZW({positionType:`firstBaseline`,children:[{type:`elem`,elem:n},{type:`kern`,size:3*i},{type:`elem`,elem:r},{type:`kern`,size:i}]})],t)},mathmlBuilder(e,t){var n=new Q(`mo`,[new OG(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new Q(`mover`,[zG(e.body,t),n]);return r.setAttribute(`accent`,`true`),r}}),Z({type:`phantom`,names:[`\\phantom`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`phantom`,mode:n.mode,body:pG(r)}},htmlBuilder:(e,t)=>JW(vG(e.body,t.withPhantom(),!1)),mathmlBuilder:(e,t)=>new Q(`mphantom`,LG(e.body,t))}),$(`\\hphantom`,`\\smash{\\phantom{#1}}`),Z({type:`vphantom`,names:[`\\vphantom`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`vphantom`,mode:n.mode,body:r}},htmlBuilder:(e,t)=>X([`mord`,`rlap`],[X([`katex-inner`],[wG(e.body,t.withPhantom())]),X([`katex-fix`],[])],t),mathmlBuilder:(e,t)=>{var n=new Q(`mpadded`,[new Q(`mphantom`,LG(pG(e.body),t))]);return n.setAttribute(`width`,`0px`),n}}),Z({type:`raisebox`,names:[`\\raisebox`],numArgs:2,argTypes:[`size`,`hbox`],allowedInText:!0,handler(e,t){var n=e.parser,r=oK(t[0],`size`).value,i=t[1];return{type:`raisebox`,mode:n.mode,dy:r,body:i}},htmlBuilder(e,t){var n=wG(e.body,t);return ZW({positionType:`shift`,positionData:-EU(e.dy,t),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){var n=new Q(`mpadded`,[zG(e.body,t)]),r=e.dy.number+e.dy.unit;return n.setAttribute(`voffset`,r),n}});var Hq=(e,t)=>({type:`reflectbox`,mode:e.parser.mode,body:t[0]});Z({type:`reflectbox`,names:[`\\reflectbox`],numArgs:1,argTypes:[`hbox`],allowedInText:!0,handler:Hq,htmlBuilder(e,t){return X([`mord`,`reflectbox`],[wG(e.body,t)],t)},mathmlBuilder(e,t){return zG(e.body,t)}}),Z({type:`reflectbox`,names:[`\\mathreflectbox`],numArgs:1,argTypes:[`math`],handler:Hq}),Z({type:`internal`,names:[`\\relax`],numArgs:0,allowedInText:!0,allowedInArgument:!0,handler(e){return{type:`internal`,mode:e.parser.mode}}}),Z({type:`rule`,names:[`\\rule`],numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`size`,`size`,`size`],handler(e,t,n){var r=e.parser,i=n[0],a=oK(t[0],`size`),o=oK(t[1],`size`);return{type:`rule`,mode:r.mode,shift:i&&oK(i,`size`).value,width:a.value,height:o.value}},htmlBuilder(e,t){var n=X([`mord`,`katex-rule`],[],t),r=EU(e.width,t),i=EU(e.height,t),a=e.shift?EU(e.shift,t):0;return n.style.borderRightWidth=z(r),n.style.borderTopWidth=z(i),n.style.bottom=z(a),n.width=r,n.height=i+a,n.depth=-a,n.maxFontSize=i*1.125*t.sizeMultiplier,n},mathmlBuilder(e,t){var n=EU(e.width,t),r=EU(e.height,t),i=e.shift?EU(e.shift,t):0,a=t.color&&t.getColor()||`black`,o=new Q(`mspace`);o.setAttribute(`mathbackground`,a),o.setAttribute(`width`,z(n)),o.setAttribute(`height`,z(r));var s=new Q(`mpadded`,[o]);return i>=0?s.setAttribute(`height`,z(i)):(s.setAttribute(`height`,z(i)),s.setAttribute(`depth`,z(-i))),s.setAttribute(`voffset`,z(i)),s}});function Uq(e,t,n){for(var r=vG(e,t,!1),i=t.sizeMultiplier/n.sizeMultiplier,a=0;a{var n=e.breakOnTokenText,r=e.funcName,i=e.parser,a=i.parseExpression(!1,n);return{type:`sizing`,mode:i.mode,size:Wq.indexOf(r)+1,body:a}},htmlBuilder:(e,t)=>{var n=t.havingSize(e.size);return Uq(e.body,n,t)},mathmlBuilder:(e,t)=>{var n=t.havingSize(e.size),r=new Q(`mstyle`,LG(e.body,n));return r.setAttribute(`mathsize`,z(n.sizeMultiplier)),r}}),Z({type:`smash`,names:[`\\smash`],numArgs:1,numOptionalArgs:1,allowedInText:!0,handler:(e,t,n)=>{var r=e.parser,i=!1,a=!1,o=n[0]&&oK(n[0],`ordgroup`);if(o)for(var s,c=0;c{var n=X([],[wG(e.body,t)]);if(!e.smashHeight&&!e.smashDepth)return n;if(e.smashHeight&&(n.height=0),e.smashDepth&&(n.depth=0),e.smashHeight&&e.smashDepth)return X([`mord`,`katex-smash`],[n],t);if(n.children)for(var r=0;r{var n=new Q(`mpadded`,[zG(e.body,t)]);return e.smashHeight&&n.setAttribute(`height`,`0px`),e.smashDepth&&n.setAttribute(`depth`,`0px`),n}}),Z({type:`sqrt`,names:[`\\sqrt`],numArgs:1,numOptionalArgs:1,handler(e,t,n){var r=e.parser,i=n[0],a=t[0];return{type:`sqrt`,mode:r.mode,body:a,index:i}},htmlBuilder(e,t){var n=wG(e.body,t.havingCrampedStyle());n.height===0&&(n.height=t.fontMetrics().xHeight),n=YW(n,t);var r=t.fontMetrics().defaultRuleThickness,i=r;t.style.idn.height+n.depth+a&&(a=(a+u-n.height-n.depth)/2);var d=s.height-n.height-a-c;n.style.paddingLeft=z(l);var f=ZW({positionType:`firstBaseline`,children:[{type:`elem`,elem:n,wrapperClasses:[`svg-align`]},{type:`kern`,size:-(n.height+d)},{type:`elem`,elem:s},{type:`kern`,size:c}]});if(e.index){var p=t.havingStyle(R.SCRIPTSCRIPT),m=wG(e.index,p,t);return X([`mord`,`sqrt`],[X([`katex-root`],[ZW({positionType:`shift`,positionData:-(.6*(f.height-f.depth)),children:[{type:`elem`,elem:m}]})]),f],t)}return X([`mord`,`sqrt`],[f],t)},mathmlBuilder(e,t){var n=e.body,r=e.index;return r?new Q(`mroot`,[zG(n,t),zG(r,t)]):new Q(`msqrt`,[zG(n,t)])}});var Gq={display:R.DISPLAY,text:R.TEXT,script:R.SCRIPT,scriptscript:R.SCRIPTSCRIPT};function Kq(e){return e in Gq}Z({type:`styling`,names:[`\\displaystyle`,`\\textstyle`,`\\scriptstyle`,`\\scriptscriptstyle`],numArgs:0,allowedInText:!0,primitive:!0,handler(e,t){var n=e.breakOnTokenText,r=e.funcName,i=e.parser,a=i.parseExpression(!0,n),o=r.slice(1,r.length-5);if(!Kq(o))throw Error(`Unknown style: `+o);return{type:`styling`,mode:i.mode,style:o,body:a}},htmlBuilder(e,t){var n=Gq[e.style],r=t.havingStyle(n);return e.resetFont&&(r=r.withFont(``)),Uq(e.body,r,t)},mathmlBuilder(e,t){var n=Gq[e.style],r=t.havingStyle(n);e.resetFont&&(r=r.withFont(``));var i=new Q(`mstyle`,LG(e.body,r)),a={display:[`0`,`true`],text:[`0`,`false`],script:[`1`,`false`],scriptscript:[`2`,`false`]}[e.style];return i.setAttribute(`scriptlevel`,a[0]),i.setAttribute(`displaystyle`,a[1]),i}});var qq=function(e,t){var n=e.base;return n?n.type===`op`?n.limits&&(t.style.size===R.DISPLAY.size||n.alwaysHandleSupSub)?Lq:null:n.type===`operatorname`?n.alwaysHandleSupSub&&(t.style.size===R.DISPLAY.size||n.limits)?Vq:null:n.type===`accent`?FH(n.base)?dK:null:n.type===`horizBrace`&&!e.sub===n.isOver?Mq:null:null};dG({type:`supsub`,htmlBuilder(e,t){var n=qq(e,t);if(n)return n(e,t);var r=e.base,i=e.sup,a=e.sub,o=wG(r,t),s,c,l=t.fontMetrics(),u=0,d=0,f=r&&FH(r);if(i){var p=t.havingStyle(t.style.sup());s=wG(i,p,t),f||(u=o.height-p.fontMetrics().supDrop*p.sizeMultiplier/t.sizeMultiplier)}if(a){var m=t.havingStyle(t.style.sub());c=wG(a,m,t),f||(d=o.depth+m.fontMetrics().subDrop*m.sizeMultiplier/t.sizeMultiplier)}var h=t.style===R.DISPLAY?l.sup1:t.style.cramped?l.sup3:l.sup2,g=t.sizeMultiplier,_=z(.5/l.ptPerEm/g),v=null;if(c){var y=e.base&&e.base.type===`op`&&e.base.name&&(e.base.name===`\\oiint`||e.base.name===`\\oiiint`);(o instanceof LU||y)&&(v=z(-(o.italic??0)))}var b;if(s&&c){u=Math.max(u,h,s.depth+.25*l.xHeight),d=Math.max(d,l.sub2);var x=4*l.defaultRuleThickness;if(u-s.depth-(c.height-d)0&&(u+=S,d-=S)}b=ZW({positionType:`individualShift`,children:[{type:`elem`,elem:c,shift:d,marginRight:_,marginLeft:v},{type:`elem`,elem:s,shift:-u,marginRight:_}]})}else if(c)d=Math.max(d,l.sub1,c.height-.8*l.xHeight),b=ZW({positionType:`shift`,positionData:d,children:[{type:`elem`,elem:c,marginLeft:v,marginRight:_}]});else if(s)u=Math.max(u,h,s.depth+.25*l.xHeight),b=ZW({positionType:`shift`,positionData:-u,children:[{type:`elem`,elem:s,marginRight:_}]});else throw Error(`supsub must have either sup or sub.`);return X([SG(o,`right`)||`mord`],[o,X([`msupsub`],[b])],t)},mathmlBuilder(e,t){var n=!1,r,i;e.base&&e.base.type===`horizBrace`&&(i=!!e.sup,i===e.base.isOver&&(n=!0,r=e.base.isOver)),e.base&&(e.base.type===`op`||e.base.type===`operatorname`)&&(e.base.parentIsSupSub=!0);var a=[zG(e.base,t)];e.sub&&a.push(zG(e.sub,t)),e.sup&&a.push(zG(e.sup,t));var o;if(n)o=r?`mover`:`munder`;else if(!e.sub){var s=e.base;o=s&&s.type===`op`&&s.limits&&(t.style===R.DISPLAY||s.alwaysHandleSupSub)||s&&s.type===`operatorname`&&s.alwaysHandleSupSub&&(s.limits||t.style===R.DISPLAY)?`mover`:`msup`}else if(e.sup){var c=e.base;o=c&&c.type===`op`&&c.limits&&t.style===R.DISPLAY||c&&c.type===`operatorname`&&c.alwaysHandleSupSub&&(t.style===R.DISPLAY||c.limits)?`munderover`:`msubsup`}else{var l=e.base;o=l&&l.type===`op`&&l.limits&&(t.style===R.DISPLAY||l.alwaysHandleSupSub)||l&&l.type===`operatorname`&&l.alwaysHandleSupSub&&(l.limits||t.style===R.DISPLAY)?`munder`:`msub`}return new Q(o,a)}}),dG({type:`atom`,htmlBuilder(e,t){return zW(e.text,e.mode,t,[`m`+e.family])},mathmlBuilder(e,t){var n=new Q(`mo`,[MG(e.text,e.mode)]);if(e.family===`bin`){var r=FG(e,t);r===`bold-italic`&&n.setAttribute(`mathvariant`,r)}else e.family===`punct`?n.setAttribute(`separator`,`true`):(e.family===`open`||e.family===`close`)&&n.setAttribute(`stretchy`,`false`);return n}});var Jq={mi:`italic`,mn:`normal`,mtext:`normal`};dG({type:`mathord`,htmlBuilder(e,t){return VW(e,t)},mathmlBuilder(e,t){var n=new Q(`mi`,[MG(e.text,e.mode,t)]),r=FG(e,t)||`italic`;return r!==Jq[n.type]&&n.setAttribute(`mathvariant`,r),n}}),dG({type:`textord`,htmlBuilder(e,t){return VW(e,t)},mathmlBuilder(e,t){var n=MG(e.text,e.mode,t),r=FG(e,t)||`normal`,i=e.mode===`text`?new Q(`mtext`,[n]):/[0-9]/.test(e.text)?new Q(`mn`,[n]):e.text===`\\prime`?new Q(`mo`,[n]):new Q(`mi`,[n]);return r!==Jq[i.type]&&i.setAttribute(`mathvariant`,r),i}});var Yq=new Map([[`\\nobreak`,`nobreak`],[`\\allowbreak`,`allowbreak`]]),Xq=new Map([[` `,{}],[`\\ `,{}],[`~`,{className:`nobreak`}],[`\\space`,{}],[`\\nobreakspace`,{className:`nobreak`}]]);dG({type:`spacing`,htmlBuilder(e,t){var n=Xq.get(e.text),r=Yq.get(e.text);if(n){var i=n.className||``;if(e.mode===`text`){var a=VW(e,t);return a.classes.push(i),a}return X([`mspace`,i],[zW(e.text,e.mode,t)],t)}if(r)return X([`mspace`,r],[],t);throw new L(`Unknown type of space "`+e.text+`"`)},mathmlBuilder(e,t){var n;if(Xq.has(e.text))n=new Q(`mtext`,[new OG(`\xA0`)]);else if(Yq.has(e.text))return new Q(`mspace`);else throw new L(`Unknown type of space "`+e.text+`"`);return n}});var Zq=()=>{var e=new Q(`mtd`,[]);return e.setAttribute(`width`,`50%`),e};dG({type:`tag`,mathmlBuilder(e,t){var n=new Q(`mtable`,[new Q(`mtr`,[Zq(),new Q(`mtd`,[RG(e.body,t)]),Zq(),new Q(`mtd`,[RG(e.tag,t)])])]);return n.setAttribute(`width`,`100%`),n}});var Qq={"\\text":void 0,"\\textrm":`textrm`,"\\textsf":`textsf`,"\\texttt":`texttt`,"\\textnormal":`textrm`},$q={"\\textbf":`textbf`,"\\textmd":`textmd`},eJ={"\\textit":`textit`,"\\textup":`textup`},tJ=(e,t)=>{var n=e.font;return n?Qq[n]?t.withTextFontFamily(Qq[n]):$q[n]?t.withTextFontWeight($q[n]):n===`\\emph`?t.fontShape===`textit`?t.withTextFontShape(`textup`):t.withTextFontShape(`textit`):t.withTextFontShape(eJ[n]):t};Z({type:`text`,names:[`\\text`,`\\textrm`,`\\textsf`,`\\texttt`,`\\textnormal`,`\\textbf`,`\\textmd`,`\\textit`,`\\textup`,`\\emph`],numArgs:1,argTypes:[`text`],allowedInArgument:!0,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`text`,mode:n.mode,body:pG(i),font:r}},htmlBuilder(e,t){var n=tJ(e,t);return X([`mord`,`text`],vG(e.body,n,!0),n)},mathmlBuilder(e,t){var n=tJ(e,t);return RG(e.body,n)}}),Z({type:`underline`,names:[`\\underline`],numArgs:1,allowedInText:!0,handler(e,t){return{type:`underline`,mode:e.parser.mode,body:t[0]}},htmlBuilder(e,t){var n=wG(e.body,t),r=KW(`underline-line`,t),i=t.fontMetrics().defaultRuleThickness;return X([`mord`,`katex-underline`],[ZW({positionType:`top`,positionData:n.height,children:[{type:`kern`,size:i},{type:`elem`,elem:r},{type:`kern`,size:3*i},{type:`elem`,elem:n}]})],t)},mathmlBuilder(e,t){var n=new Q(`mo`,[new OG(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new Q(`munder`,[zG(e.body,t),n]);return r.setAttribute(`accentunder`,`true`),r}}),Z({type:`vcenter`,names:[`\\vcenter`],numArgs:1,argTypes:[`original`],allowedInText:!1,handler(e,t){return{type:`vcenter`,mode:e.parser.mode,body:t[0]}},htmlBuilder(e,t){var n=wG(e.body,t),r=t.fontMetrics().axisHeight;return ZW({positionType:`shift`,positionData:.5*(n.height-r-(n.depth+r)),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){return new Q(`mrow`,[new Q(`mpadded`,[zG(e.body,t)],[`vcenter`])])}}),Z({type:`verb`,names:[`\\verb`],numArgs:0,allowedInText:!0,handler(e,t,n){throw new L(`\\verb ended by end of line instead of matching delimiter`)},htmlBuilder(e,t){for(var n=nJ(e),r=[],i=t.havingStyle(t.style.text()),a=0;ae.body.replace(/ /g,e.star?`␣`:`\xA0`),rJ=cG,iJ=`[ \r - ]`,aJ=`\\\\[a-zA-Z@]+`,oJ=`\\\\[^\ud800-\udfff]`,sJ=`(`+aJ+`)`+iJ+`*`,cJ=`\\\\( +-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 OU(e){return`toText`in e}var kU=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{if(OU(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},AU={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},jU={ex:!0,em:!0,mu:!0},MU=function(e){return typeof e!=`string`&&(e=e.unit),e in AU||e in jU||e===`ex`},NU=function(e,t){var n;if(e.unit in AU)n=AU[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`},PU=function(e){return e.filter(e=>e).join(` `)},FU=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=IH(n)+`:`+r+`;`)}return t},IU=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)}},LU=function(e){var t=document.createElement(e);t.className=PU(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/=\x00-\x1f]/,zU=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+zH(PU(this.classes))+`"`);var n=FU(this.style);n&&(t+=` style="`+zH(n)+`"`);for(var r of Object.keys(this.attributes)){if(RU.test(r))throw new L(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+zH(this.attributes[r])+`"`}t+=`>`;for(var i=0;i`,t},BU=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,IU.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return LU.call(this,`span`)}toMarkup(){return zU.call(this,`span`)}},VU=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,IU.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 LU.call(this,`a`)}toMarkup(){return zU.call(this,`a`)}},HU=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=``+zH(this.alt)+``,e}},UU={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},WU=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=fU(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=UU[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=PU(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=`0&&(n+=`margin-right:`+z(this.italic)+`;`),n+=FU(this.style),n&&(e=!0,t+=` style="`+zH(n)+`"`);var r=zH(this.text);return e?(t+=`>`,t+=r,t+=``,t):r}},GU=class{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);for(var t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);for(var n=0;n`;for(var n=0;n`,e}},KU=class{constructor(e,t){this.pathName=void 0,this.alternate=void 0,this.pathName=e,this.alternate=t}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return this.alternate?e.setAttribute(`d`,this.alternate):e.setAttribute(`d`,EU[this.pathName]),e}toMarkup(){return this.alternate?``:``}},qU=class{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){var e=document.createElementNS(`http://www.w3.org/2000/svg`,`line`);for(var t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);return e}toMarkup(){var e=``,e}};function JU(e){if(e instanceof WU)return e;throw Error(`Expected symbolNode but got `+String(e)+`.`)}function YU(e){if(e instanceof BU)return e;throw Error(`Expected span but got `+String(e)+`.`)}var XU=e=>e instanceof BU||e instanceof VU||e instanceof kU,ZU={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}},QU={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},$U={Å:`A`,Ð:`D`,Þ:`o`,å:`a`,ð:`d`,þ:`o`,А:`A`,Б:`B`,В:`B`,Г:`F`,Д:`A`,Е:`E`,Ж:`K`,З:`3`,И:`N`,Й:`N`,К:`K`,Л:`N`,М:`M`,Н:`H`,О:`O`,П:`N`,Р:`P`,С:`C`,Т:`T`,У:`y`,Ф:`O`,Х:`X`,Ц:`U`,Ч:`h`,Ш:`W`,Щ:`W`,Ъ:`B`,Ы:`X`,Ь:`B`,Э:`3`,Ю:`X`,Я:`R`,а:`a`,б:`b`,в:`a`,г:`r`,д:`y`,е:`e`,ж:`m`,з:`e`,и:`n`,й:`n`,к:`n`,л:`n`,м:`m`,н:`n`,о:`o`,п:`n`,р:`p`,с:`c`,т:`o`,у:`y`,ф:`b`,х:`x`,ц:`n`,ч:`n`,ш:`w`,щ:`w`,ъ:`a`,ы:`m`,ь:`a`,э:`e`,ю:`m`,я:`r`};function eW(e,t){ZU[e]=t}function tW(e,t,n){if(!ZU[t])throw Error(`Font metrics not found for font: `+t+`.`);var r=e.charCodeAt(0),i=ZU[t][r];if(!i&&e[0]in $U&&(r=$U[e[0]].charCodeAt(0),i=ZU[t][r]),!i&&n===`text`&&mU(r)&&(i=ZU[t][77]),i)return{depth:i[0],height:i[1],italic:i[2],skew:i[3],width:i[4]}}var nW={};function rW(e){var t=e>=5?0:e>=3?1:2;if(!nW[t]){var n=nW[t]={cssEmPerMu:QU.quad[t]/18};for(var r of Object.keys(QU))n[r]=QU[r][t]}return nW[t]}var iW={math:{},text:{}};function B(e,t,n,r,i,a){iW[e][i]={font:t,group:n,replace:r},a&&r&&(iW[e][r]=iW[e][i])}var V=`math`,H=`text`,U=`main`,W=`ams`,aW=`accent-token`,G=`bin`,oW=`close`,sW=`inner`,K=`mathord`,cW=`op-token`,lW=`open`,uW=`punct`,q=`rel`,dW=`spacing`,J=`textord`;B(V,U,q,`≡`,`\\equiv`,!0),B(V,U,q,`≺`,`\\prec`,!0),B(V,U,q,`≻`,`\\succ`,!0),B(V,U,q,`∼`,`\\sim`,!0),B(V,U,q,`⊥`,`\\perp`),B(V,U,q,`⪯`,`\\preceq`,!0),B(V,U,q,`⪰`,`\\succeq`,!0),B(V,U,q,`≃`,`\\simeq`,!0),B(V,U,q,`∣`,`\\mid`,!0),B(V,U,q,`≪`,`\\ll`,!0),B(V,U,q,`≫`,`\\gg`,!0),B(V,U,q,`≍`,`\\asymp`,!0),B(V,U,q,`∥`,`\\parallel`),B(V,U,q,`⋈`,`\\bowtie`,!0),B(V,U,q,`⌣`,`\\smile`,!0),B(V,U,q,`⊑`,`\\sqsubseteq`,!0),B(V,U,q,`⊒`,`\\sqsupseteq`,!0),B(V,U,q,`≐`,`\\doteq`,!0),B(V,U,q,`⌢`,`\\frown`,!0),B(V,U,q,`∋`,`\\ni`,!0),B(V,U,q,`∝`,`\\propto`,!0),B(V,U,q,`⊢`,`\\vdash`,!0),B(V,U,q,`⊣`,`\\dashv`,!0),B(V,U,q,`∋`,`\\owns`),B(V,U,uW,`.`,`\\ldotp`),B(V,U,uW,`⋅`,`\\cdotp`),B(V,U,uW,`⋅`,`·`),B(H,U,J,`⋅`,`·`),B(V,U,J,`#`,`\\#`),B(H,U,J,`#`,`\\#`),B(V,U,J,`&`,`\\&`),B(H,U,J,`&`,`\\&`),B(V,U,J,`ℵ`,`\\aleph`,!0),B(V,U,J,`∀`,`\\forall`,!0),B(V,U,J,`ℏ`,`\\hbar`,!0),B(V,U,J,`∃`,`\\exists`,!0),B(V,U,J,`∇`,`\\nabla`,!0),B(V,U,J,`♭`,`\\flat`,!0),B(V,U,J,`ℓ`,`\\ell`,!0),B(V,U,J,`♮`,`\\natural`,!0),B(V,U,J,`♣`,`\\clubsuit`,!0),B(V,U,J,`℘`,`\\wp`,!0),B(V,U,J,`♯`,`\\sharp`,!0),B(V,U,J,`♢`,`\\diamondsuit`,!0),B(V,U,J,`ℜ`,`\\Re`,!0),B(V,U,J,`♡`,`\\heartsuit`,!0),B(V,U,J,`ℑ`,`\\Im`,!0),B(V,U,J,`♠`,`\\spadesuit`,!0),B(V,U,J,`§`,`\\S`,!0),B(H,U,J,`§`,`\\S`),B(V,U,J,`¶`,`\\P`,!0),B(H,U,J,`¶`,`\\P`),B(V,U,J,`†`,`\\dag`),B(H,U,J,`†`,`\\dag`),B(H,U,J,`†`,`\\textdagger`),B(V,U,J,`‡`,`\\ddag`),B(H,U,J,`‡`,`\\ddag`),B(H,U,J,`‡`,`\\textdaggerdbl`),B(V,U,oW,`⎱`,`\\rmoustache`,!0),B(V,U,lW,`⎰`,`\\lmoustache`,!0),B(V,U,oW,`⟯`,`\\rgroup`,!0),B(V,U,lW,`⟮`,`\\lgroup`,!0),B(V,U,G,`∓`,`\\mp`,!0),B(V,U,G,`⊖`,`\\ominus`,!0),B(V,U,G,`⊎`,`\\uplus`,!0),B(V,U,G,`⊓`,`\\sqcap`,!0),B(V,U,G,`∗`,`\\ast`),B(V,U,G,`⊔`,`\\sqcup`,!0),B(V,U,G,`◯`,`\\bigcirc`,!0),B(V,U,G,`∙`,`\\bullet`,!0),B(V,U,G,`‡`,`\\ddagger`),B(V,U,G,`≀`,`\\wr`,!0),B(V,U,G,`⨿`,`\\amalg`),B(V,U,G,`&`,`\\And`),B(V,U,q,`⟵`,`\\longleftarrow`,!0),B(V,U,q,`⇐`,`\\Leftarrow`,!0),B(V,U,q,`⟸`,`\\Longleftarrow`,!0),B(V,U,q,`⟶`,`\\longrightarrow`,!0),B(V,U,q,`⇒`,`\\Rightarrow`,!0),B(V,U,q,`⟹`,`\\Longrightarrow`,!0),B(V,U,q,`↔`,`\\leftrightarrow`,!0),B(V,U,q,`⟷`,`\\longleftrightarrow`,!0),B(V,U,q,`⇔`,`\\Leftrightarrow`,!0),B(V,U,q,`⟺`,`\\Longleftrightarrow`,!0),B(V,U,q,`↦`,`\\mapsto`,!0),B(V,U,q,`⟼`,`\\longmapsto`,!0),B(V,U,q,`↗`,`\\nearrow`,!0),B(V,U,q,`↩`,`\\hookleftarrow`,!0),B(V,U,q,`↪`,`\\hookrightarrow`,!0),B(V,U,q,`↘`,`\\searrow`,!0),B(V,U,q,`↼`,`\\leftharpoonup`,!0),B(V,U,q,`⇀`,`\\rightharpoonup`,!0),B(V,U,q,`↙`,`\\swarrow`,!0),B(V,U,q,`↽`,`\\leftharpoondown`,!0),B(V,U,q,`⇁`,`\\rightharpoondown`,!0),B(V,U,q,`↖`,`\\nwarrow`,!0),B(V,U,q,`⇌`,`\\rightleftharpoons`,!0),B(V,W,q,`≮`,`\\nless`,!0),B(V,W,q,``,`\\@nleqslant`),B(V,W,q,``,`\\@nleqq`),B(V,W,q,`⪇`,`\\lneq`,!0),B(V,W,q,`≨`,`\\lneqq`,!0),B(V,W,q,``,`\\@lvertneqq`),B(V,W,q,`⋦`,`\\lnsim`,!0),B(V,W,q,`⪉`,`\\lnapprox`,!0),B(V,W,q,`⊀`,`\\nprec`,!0),B(V,W,q,`⋠`,`\\npreceq`,!0),B(V,W,q,`⋨`,`\\precnsim`,!0),B(V,W,q,`⪹`,`\\precnapprox`,!0),B(V,W,q,`≁`,`\\nsim`,!0),B(V,W,q,``,`\\@nshortmid`),B(V,W,q,`∤`,`\\nmid`,!0),B(V,W,q,`⊬`,`\\nvdash`,!0),B(V,W,q,`⊭`,`\\nvDash`,!0),B(V,W,q,`⋪`,`\\ntriangleleft`),B(V,W,q,`⋬`,`\\ntrianglelefteq`,!0),B(V,W,q,`⊊`,`\\subsetneq`,!0),B(V,W,q,``,`\\@varsubsetneq`),B(V,W,q,`⫋`,`\\subsetneqq`,!0),B(V,W,q,``,`\\@varsubsetneqq`),B(V,W,q,`≯`,`\\ngtr`,!0),B(V,W,q,``,`\\@ngeqslant`),B(V,W,q,``,`\\@ngeqq`),B(V,W,q,`⪈`,`\\gneq`,!0),B(V,W,q,`≩`,`\\gneqq`,!0),B(V,W,q,``,`\\@gvertneqq`),B(V,W,q,`⋧`,`\\gnsim`,!0),B(V,W,q,`⪊`,`\\gnapprox`,!0),B(V,W,q,`⊁`,`\\nsucc`,!0),B(V,W,q,`⋡`,`\\nsucceq`,!0),B(V,W,q,`⋩`,`\\succnsim`,!0),B(V,W,q,`⪺`,`\\succnapprox`,!0),B(V,W,q,`≆`,`\\ncong`,!0),B(V,W,q,``,`\\@nshortparallel`),B(V,W,q,`∦`,`\\nparallel`,!0),B(V,W,q,`⊯`,`\\nVDash`,!0),B(V,W,q,`⋫`,`\\ntriangleright`),B(V,W,q,`⋭`,`\\ntrianglerighteq`,!0),B(V,W,q,``,`\\@nsupseteqq`),B(V,W,q,`⊋`,`\\supsetneq`,!0),B(V,W,q,``,`\\@varsupsetneq`),B(V,W,q,`⫌`,`\\supsetneqq`,!0),B(V,W,q,``,`\\@varsupsetneqq`),B(V,W,q,`⊮`,`\\nVdash`,!0),B(V,W,q,`⪵`,`\\precneqq`,!0),B(V,W,q,`⪶`,`\\succneqq`,!0),B(V,W,q,``,`\\@nsubseteqq`),B(V,W,G,`⊴`,`\\unlhd`),B(V,W,G,`⊵`,`\\unrhd`),B(V,W,q,`↚`,`\\nleftarrow`,!0),B(V,W,q,`↛`,`\\nrightarrow`,!0),B(V,W,q,`⇍`,`\\nLeftarrow`,!0),B(V,W,q,`⇏`,`\\nRightarrow`,!0),B(V,W,q,`↮`,`\\nleftrightarrow`,!0),B(V,W,q,`⇎`,`\\nLeftrightarrow`,!0),B(V,W,q,`△`,`\\vartriangle`),B(V,W,J,`ℏ`,`\\hslash`),B(V,W,J,`▽`,`\\triangledown`),B(V,W,J,`◊`,`\\lozenge`),B(V,W,J,`Ⓢ`,`\\circledS`),B(V,W,J,`®`,`\\circledR`),B(H,W,J,`®`,`\\circledR`),B(V,W,J,`∡`,`\\measuredangle`,!0),B(V,W,J,`∄`,`\\nexists`),B(V,W,J,`℧`,`\\mho`),B(V,W,J,`Ⅎ`,`\\Finv`,!0),B(V,W,J,`⅁`,`\\Game`,!0),B(V,W,J,`‵`,`\\backprime`),B(V,W,J,`▲`,`\\blacktriangle`),B(V,W,J,`▼`,`\\blacktriangledown`),B(V,W,J,`■`,`\\blacksquare`),B(V,W,J,`⧫`,`\\blacklozenge`),B(V,W,J,`★`,`\\bigstar`),B(V,W,J,`∢`,`\\sphericalangle`,!0),B(V,W,J,`∁`,`\\complement`,!0),B(V,W,J,`ð`,`\\eth`,!0),B(H,U,J,`ð`,`ð`),B(V,W,J,`╱`,`\\diagup`),B(V,W,J,`╲`,`\\diagdown`),B(V,W,J,`□`,`\\square`),B(V,W,J,`□`,`\\Box`),B(V,W,J,`◊`,`\\Diamond`),B(V,W,J,`¥`,`\\yen`,!0),B(H,W,J,`¥`,`\\yen`,!0),B(V,W,J,`✓`,`\\checkmark`,!0),B(H,W,J,`✓`,`\\checkmark`),B(V,W,J,`ℶ`,`\\beth`,!0),B(V,W,J,`ℸ`,`\\daleth`,!0),B(V,W,J,`ℷ`,`\\gimel`,!0),B(V,W,J,`ϝ`,`\\digamma`,!0),B(V,W,J,`ϰ`,`\\varkappa`),B(V,W,lW,`┌`,`\\@ulcorner`,!0),B(V,W,oW,`┐`,`\\@urcorner`,!0),B(V,W,lW,`└`,`\\@llcorner`,!0),B(V,W,oW,`┘`,`\\@lrcorner`,!0),B(V,W,q,`≦`,`\\leqq`,!0),B(V,W,q,`⩽`,`\\leqslant`,!0),B(V,W,q,`⪕`,`\\eqslantless`,!0),B(V,W,q,`≲`,`\\lesssim`,!0),B(V,W,q,`⪅`,`\\lessapprox`,!0),B(V,W,q,`≊`,`\\approxeq`,!0),B(V,W,G,`⋖`,`\\lessdot`),B(V,W,q,`⋘`,`\\lll`,!0),B(V,W,q,`≶`,`\\lessgtr`,!0),B(V,W,q,`⋚`,`\\lesseqgtr`,!0),B(V,W,q,`⪋`,`\\lesseqqgtr`,!0),B(V,W,q,`≑`,`\\doteqdot`),B(V,W,q,`≓`,`\\risingdotseq`,!0),B(V,W,q,`≒`,`\\fallingdotseq`,!0),B(V,W,q,`∽`,`\\backsim`,!0),B(V,W,q,`⋍`,`\\backsimeq`,!0),B(V,W,q,`⫅`,`\\subseteqq`,!0),B(V,W,q,`⋐`,`\\Subset`,!0),B(V,W,q,`⊏`,`\\sqsubset`,!0),B(V,W,q,`≼`,`\\preccurlyeq`,!0),B(V,W,q,`⋞`,`\\curlyeqprec`,!0),B(V,W,q,`≾`,`\\precsim`,!0),B(V,W,q,`⪷`,`\\precapprox`,!0),B(V,W,q,`⊲`,`\\vartriangleleft`),B(V,W,q,`⊴`,`\\trianglelefteq`),B(V,W,q,`⊨`,`\\vDash`,!0),B(V,W,q,`⊪`,`\\Vvdash`,!0),B(V,W,q,`⌣`,`\\smallsmile`),B(V,W,q,`⌢`,`\\smallfrown`),B(V,W,q,`≏`,`\\bumpeq`,!0),B(V,W,q,`≎`,`\\Bumpeq`,!0),B(V,W,q,`≧`,`\\geqq`,!0),B(V,W,q,`⩾`,`\\geqslant`,!0),B(V,W,q,`⪖`,`\\eqslantgtr`,!0),B(V,W,q,`≳`,`\\gtrsim`,!0),B(V,W,q,`⪆`,`\\gtrapprox`,!0),B(V,W,G,`⋗`,`\\gtrdot`),B(V,W,q,`⋙`,`\\ggg`,!0),B(V,W,q,`≷`,`\\gtrless`,!0),B(V,W,q,`⋛`,`\\gtreqless`,!0),B(V,W,q,`⪌`,`\\gtreqqless`,!0),B(V,W,q,`≖`,`\\eqcirc`,!0),B(V,W,q,`≗`,`\\circeq`,!0),B(V,W,q,`≜`,`\\triangleq`,!0),B(V,W,q,`∼`,`\\thicksim`),B(V,W,q,`≈`,`\\thickapprox`),B(V,W,q,`⫆`,`\\supseteqq`,!0),B(V,W,q,`⋑`,`\\Supset`,!0),B(V,W,q,`⊐`,`\\sqsupset`,!0),B(V,W,q,`≽`,`\\succcurlyeq`,!0),B(V,W,q,`⋟`,`\\curlyeqsucc`,!0),B(V,W,q,`≿`,`\\succsim`,!0),B(V,W,q,`⪸`,`\\succapprox`,!0),B(V,W,q,`⊳`,`\\vartriangleright`),B(V,W,q,`⊵`,`\\trianglerighteq`),B(V,W,q,`⊩`,`\\Vdash`,!0),B(V,W,q,`∣`,`\\shortmid`),B(V,W,q,`∥`,`\\shortparallel`),B(V,W,q,`≬`,`\\between`,!0),B(V,W,q,`⋔`,`\\pitchfork`,!0),B(V,W,q,`∝`,`\\varpropto`),B(V,W,q,`◀`,`\\blacktriangleleft`),B(V,W,q,`∴`,`\\therefore`,!0),B(V,W,q,`∍`,`\\backepsilon`),B(V,W,q,`▶`,`\\blacktriangleright`),B(V,W,q,`∵`,`\\because`,!0),B(V,W,q,`⋘`,`\\llless`),B(V,W,q,`⋙`,`\\gggtr`),B(V,W,G,`⊲`,`\\lhd`),B(V,W,G,`⊳`,`\\rhd`),B(V,W,q,`≂`,`\\eqsim`,!0),B(V,U,q,`⋈`,`\\Join`),B(V,W,q,`≑`,`\\Doteq`,!0),B(V,W,G,`∔`,`\\dotplus`,!0),B(V,W,G,`∖`,`\\smallsetminus`),B(V,W,G,`⋒`,`\\Cap`,!0),B(V,W,G,`⋓`,`\\Cup`,!0),B(V,W,G,`⩞`,`\\doublebarwedge`,!0),B(V,W,G,`⊟`,`\\boxminus`,!0),B(V,W,G,`⊞`,`\\boxplus`,!0),B(V,W,G,`⋇`,`\\divideontimes`,!0),B(V,W,G,`⋉`,`\\ltimes`,!0),B(V,W,G,`⋊`,`\\rtimes`,!0),B(V,W,G,`⋋`,`\\leftthreetimes`,!0),B(V,W,G,`⋌`,`\\rightthreetimes`,!0),B(V,W,G,`⋏`,`\\curlywedge`,!0),B(V,W,G,`⋎`,`\\curlyvee`,!0),B(V,W,G,`⊝`,`\\circleddash`,!0),B(V,W,G,`⊛`,`\\circledast`,!0),B(V,W,G,`⋅`,`\\centerdot`),B(V,W,G,`⊺`,`\\intercal`,!0),B(V,W,G,`⋒`,`\\doublecap`),B(V,W,G,`⋓`,`\\doublecup`),B(V,W,G,`⊠`,`\\boxtimes`,!0),B(V,W,q,`⇢`,`\\dashrightarrow`,!0),B(V,W,q,`⇠`,`\\dashleftarrow`,!0),B(V,W,q,`⇇`,`\\leftleftarrows`,!0),B(V,W,q,`⇆`,`\\leftrightarrows`,!0),B(V,W,q,`⇚`,`\\Lleftarrow`,!0),B(V,W,q,`↞`,`\\twoheadleftarrow`,!0),B(V,W,q,`↢`,`\\leftarrowtail`,!0),B(V,W,q,`↫`,`\\looparrowleft`,!0),B(V,W,q,`⇋`,`\\leftrightharpoons`,!0),B(V,W,q,`↶`,`\\curvearrowleft`,!0),B(V,W,q,`↺`,`\\circlearrowleft`,!0),B(V,W,q,`↰`,`\\Lsh`,!0),B(V,W,q,`⇈`,`\\upuparrows`,!0),B(V,W,q,`↿`,`\\upharpoonleft`,!0),B(V,W,q,`⇃`,`\\downharpoonleft`,!0),B(V,U,q,`⊶`,`\\origof`,!0),B(V,U,q,`⊷`,`\\imageof`,!0),B(V,W,q,`⊸`,`\\multimap`,!0),B(V,W,q,`↭`,`\\leftrightsquigarrow`,!0),B(V,W,q,`⇉`,`\\rightrightarrows`,!0),B(V,W,q,`⇄`,`\\rightleftarrows`,!0),B(V,W,q,`↠`,`\\twoheadrightarrow`,!0),B(V,W,q,`↣`,`\\rightarrowtail`,!0),B(V,W,q,`↬`,`\\looparrowright`,!0),B(V,W,q,`↷`,`\\curvearrowright`,!0),B(V,W,q,`↻`,`\\circlearrowright`,!0),B(V,W,q,`↱`,`\\Rsh`,!0),B(V,W,q,`⇊`,`\\downdownarrows`,!0),B(V,W,q,`↾`,`\\upharpoonright`,!0),B(V,W,q,`⇂`,`\\downharpoonright`,!0),B(V,W,q,`⇝`,`\\rightsquigarrow`,!0),B(V,W,q,`⇝`,`\\leadsto`),B(V,W,q,`⇛`,`\\Rrightarrow`,!0),B(V,W,q,`↾`,`\\restriction`),B(V,U,J,`‘`,"`"),B(V,U,J,`$`,`\\$`),B(H,U,J,`$`,`\\$`),B(H,U,J,`$`,`\\textdollar`),B(V,U,J,`%`,`\\%`),B(H,U,J,`%`,`\\%`),B(V,U,J,`_`,`\\_`),B(H,U,J,`_`,`\\_`),B(H,U,J,`_`,`\\textunderscore`),B(V,U,J,`∠`,`\\angle`,!0),B(V,U,J,`∞`,`\\infty`,!0),B(V,U,J,`′`,`\\prime`),B(V,U,J,`△`,`\\triangle`),B(V,U,J,`Γ`,`\\Gamma`,!0),B(V,U,J,`Δ`,`\\Delta`,!0),B(V,U,J,`Θ`,`\\Theta`,!0),B(V,U,J,`Λ`,`\\Lambda`,!0),B(V,U,J,`Ξ`,`\\Xi`,!0),B(V,U,J,`Π`,`\\Pi`,!0),B(V,U,J,`Σ`,`\\Sigma`,!0),B(V,U,J,`Υ`,`\\Upsilon`,!0),B(V,U,J,`Φ`,`\\Phi`,!0),B(V,U,J,`Ψ`,`\\Psi`,!0),B(V,U,J,`Ω`,`\\Omega`,!0),B(V,U,J,`A`,`Α`),B(V,U,J,`B`,`Β`),B(V,U,J,`E`,`Ε`),B(V,U,J,`Z`,`Ζ`),B(V,U,J,`H`,`Η`),B(V,U,J,`I`,`Ι`),B(V,U,J,`K`,`Κ`),B(V,U,J,`M`,`Μ`),B(V,U,J,`N`,`Ν`),B(V,U,J,`O`,`Ο`),B(V,U,J,`P`,`Ρ`),B(V,U,J,`T`,`Τ`),B(V,U,J,`X`,`Χ`),B(V,U,J,`¬`,`\\neg`,!0),B(V,U,J,`¬`,`\\lnot`),B(V,U,J,`⊤`,`\\top`),B(V,U,J,`⊥`,`\\bot`),B(V,U,J,`∅`,`\\emptyset`),B(V,W,J,`∅`,`\\varnothing`),B(V,U,K,`α`,`\\alpha`,!0),B(V,U,K,`β`,`\\beta`,!0),B(V,U,K,`γ`,`\\gamma`,!0),B(V,U,K,`δ`,`\\delta`,!0),B(V,U,K,`ϵ`,`\\epsilon`,!0),B(V,U,K,`ζ`,`\\zeta`,!0),B(V,U,K,`η`,`\\eta`,!0),B(V,U,K,`θ`,`\\theta`,!0),B(V,U,K,`ι`,`\\iota`,!0),B(V,U,K,`κ`,`\\kappa`,!0),B(V,U,K,`λ`,`\\lambda`,!0),B(V,U,K,`μ`,`\\mu`,!0),B(V,U,K,`ν`,`\\nu`,!0),B(V,U,K,`ξ`,`\\xi`,!0),B(V,U,K,`ο`,`\\omicron`,!0),B(V,U,K,`π`,`\\pi`,!0),B(V,U,K,`ρ`,`\\rho`,!0),B(V,U,K,`σ`,`\\sigma`,!0),B(V,U,K,`τ`,`\\tau`,!0),B(V,U,K,`υ`,`\\upsilon`,!0),B(V,U,K,`ϕ`,`\\phi`,!0),B(V,U,K,`χ`,`\\chi`,!0),B(V,U,K,`ψ`,`\\psi`,!0),B(V,U,K,`ω`,`\\omega`,!0),B(V,U,K,`ε`,`\\varepsilon`,!0),B(V,U,K,`ϑ`,`\\vartheta`,!0),B(V,U,K,`ϖ`,`\\varpi`,!0),B(V,U,K,`ϱ`,`\\varrho`,!0),B(V,U,K,`ς`,`\\varsigma`,!0),B(V,U,K,`φ`,`\\varphi`,!0),B(V,U,G,`∗`,`*`,!0),B(V,U,G,`+`,`+`),B(V,U,G,`−`,`-`,!0),B(V,U,G,`⋅`,`\\cdot`,!0),B(V,U,G,`∘`,`\\circ`,!0),B(V,U,G,`÷`,`\\div`,!0),B(V,U,G,`±`,`\\pm`,!0),B(V,U,G,`×`,`\\times`,!0),B(V,U,G,`∩`,`\\cap`,!0),B(V,U,G,`∪`,`\\cup`,!0),B(V,U,G,`∖`,`\\setminus`,!0),B(V,U,G,`∧`,`\\land`),B(V,U,G,`∨`,`\\lor`),B(V,U,G,`∧`,`\\wedge`,!0),B(V,U,G,`∨`,`\\vee`,!0),B(V,U,J,`√`,`\\surd`),B(V,U,lW,`⟨`,`\\langle`,!0),B(V,U,lW,`∣`,`\\lvert`),B(V,U,lW,`∥`,`\\lVert`),B(V,U,oW,`?`,`?`),B(V,U,oW,`!`,`!`),B(V,U,oW,`⟩`,`\\rangle`,!0),B(V,U,oW,`∣`,`\\rvert`),B(V,U,oW,`∥`,`\\rVert`),B(V,U,q,`=`,`=`),B(V,U,q,`:`,`:`),B(V,U,q,`≈`,`\\approx`,!0),B(V,U,q,`≅`,`\\cong`,!0),B(V,U,q,`≥`,`\\ge`),B(V,U,q,`≥`,`\\geq`,!0),B(V,U,q,`←`,`\\gets`),B(V,U,q,`>`,`\\gt`,!0),B(V,U,q,`∈`,`\\in`,!0),B(V,U,q,``,`\\@not`),B(V,U,q,`⊂`,`\\subset`,!0),B(V,U,q,`⊃`,`\\supset`,!0),B(V,U,q,`⊆`,`\\subseteq`,!0),B(V,U,q,`⊇`,`\\supseteq`,!0),B(V,W,q,`⊈`,`\\nsubseteq`,!0),B(V,W,q,`⊉`,`\\nsupseteq`,!0),B(V,U,q,`⊨`,`\\models`),B(V,U,q,`←`,`\\leftarrow`,!0),B(V,U,q,`≤`,`\\le`),B(V,U,q,`≤`,`\\leq`,!0),B(V,U,q,`<`,`\\lt`,!0),B(V,U,q,`→`,`\\rightarrow`,!0),B(V,U,q,`→`,`\\to`),B(V,W,q,`≱`,`\\ngeq`,!0),B(V,W,q,`≰`,`\\nleq`,!0),B(V,U,dW,`\xA0`,`\\ `),B(V,U,dW,`\xA0`,`\\space`),B(V,U,dW,`\xA0`,`\\nobreakspace`),B(H,U,dW,`\xA0`,`\\ `),B(H,U,dW,`\xA0`,` `),B(H,U,dW,`\xA0`,`\\space`),B(H,U,dW,`\xA0`,`\\nobreakspace`),B(V,U,dW,``,`\\nobreak`),B(V,U,dW,``,`\\allowbreak`),B(V,U,uW,`,`,`,`),B(V,U,uW,`;`,`;`),B(V,W,G,`⊼`,`\\barwedge`,!0),B(V,W,G,`⊻`,`\\veebar`,!0),B(V,U,G,`⊙`,`\\odot`,!0),B(V,U,G,`⊕`,`\\oplus`,!0),B(V,U,G,`⊗`,`\\otimes`,!0),B(V,U,J,`∂`,`\\partial`,!0),B(V,U,G,`⊘`,`\\oslash`,!0),B(V,W,G,`⊚`,`\\circledcirc`,!0),B(V,W,G,`⊡`,`\\boxdot`,!0),B(V,U,G,`△`,`\\bigtriangleup`),B(V,U,G,`▽`,`\\bigtriangledown`),B(V,U,G,`†`,`\\dagger`),B(V,U,G,`⋄`,`\\diamond`),B(V,U,G,`⋆`,`\\star`),B(V,U,G,`◃`,`\\triangleleft`),B(V,U,G,`▹`,`\\triangleright`),B(V,U,lW,`{`,`\\{`),B(H,U,J,`{`,`\\{`),B(H,U,J,`{`,`\\textbraceleft`),B(V,U,oW,`}`,`\\}`),B(H,U,J,`}`,`\\}`),B(H,U,J,`}`,`\\textbraceright`),B(V,U,lW,`{`,`\\lbrace`),B(V,U,oW,`}`,`\\rbrace`),B(V,U,lW,`[`,`\\lbrack`,!0),B(H,U,J,`[`,`\\lbrack`,!0),B(V,U,oW,`]`,`\\rbrack`,!0),B(H,U,J,`]`,`\\rbrack`,!0),B(V,U,lW,`(`,`\\lparen`,!0),B(V,U,oW,`)`,`\\rparen`,!0),B(H,U,J,`<`,`\\textless`,!0),B(H,U,J,`>`,`\\textgreater`,!0),B(V,U,lW,`⌊`,`\\lfloor`,!0),B(V,U,oW,`⌋`,`\\rfloor`,!0),B(V,U,lW,`⌈`,`\\lceil`,!0),B(V,U,oW,`⌉`,`\\rceil`,!0),B(V,U,J,`\\`,`\\backslash`),B(V,U,J,`∣`,`|`),B(V,U,J,`∣`,`\\vert`),B(H,U,J,`|`,`\\textbar`,!0),B(V,U,J,`∥`,`\\|`),B(V,U,J,`∥`,`\\Vert`),B(H,U,J,`∥`,`\\textbardbl`),B(H,U,J,`~`,`\\textasciitilde`),B(H,U,J,`\\`,`\\textbackslash`),B(H,U,J,`^`,`\\textasciicircum`),B(V,U,q,`↑`,`\\uparrow`,!0),B(V,U,q,`⇑`,`\\Uparrow`,!0),B(V,U,q,`↓`,`\\downarrow`,!0),B(V,U,q,`⇓`,`\\Downarrow`,!0),B(V,U,q,`↕`,`\\updownarrow`,!0),B(V,U,q,`⇕`,`\\Updownarrow`,!0),B(V,U,cW,`∐`,`\\coprod`),B(V,U,cW,`⋁`,`\\bigvee`),B(V,U,cW,`⋀`,`\\bigwedge`),B(V,U,cW,`⨄`,`\\biguplus`),B(V,U,cW,`⋂`,`\\bigcap`),B(V,U,cW,`⋃`,`\\bigcup`),B(V,U,cW,`∫`,`\\int`),B(V,U,cW,`∫`,`\\intop`),B(V,U,cW,`∬`,`\\iint`),B(V,U,cW,`∭`,`\\iiint`),B(V,U,cW,`∏`,`\\prod`),B(V,U,cW,`∑`,`\\sum`),B(V,U,cW,`⨂`,`\\bigotimes`),B(V,U,cW,`⨁`,`\\bigoplus`),B(V,U,cW,`⨀`,`\\bigodot`),B(V,U,cW,`∮`,`\\oint`),B(V,U,cW,`∯`,`\\oiint`),B(V,U,cW,`∰`,`\\oiiint`),B(V,U,cW,`⨆`,`\\bigsqcup`),B(V,U,cW,`∫`,`\\smallint`),B(H,U,sW,`…`,`\\textellipsis`),B(V,U,sW,`…`,`\\mathellipsis`),B(H,U,sW,`…`,`\\ldots`,!0),B(V,U,sW,`…`,`\\ldots`,!0),B(V,U,sW,`⋯`,`\\@cdots`,!0),B(V,U,sW,`⋱`,`\\ddots`,!0),B(V,U,J,`⋮`,`\\varvdots`),B(H,U,J,`⋮`,`\\varvdots`),B(V,U,aW,`ˊ`,`\\acute`),B(V,U,aW,`ˋ`,`\\grave`),B(V,U,aW,`¨`,`\\ddot`),B(V,U,aW,`~`,`\\tilde`),B(V,U,aW,`ˉ`,`\\bar`),B(V,U,aW,`˘`,`\\breve`),B(V,U,aW,`ˇ`,`\\check`),B(V,U,aW,`^`,`\\hat`),B(V,U,aW,`⃗`,`\\vec`),B(V,U,aW,`˙`,`\\dot`),B(V,U,aW,`˚`,`\\mathring`),B(V,U,K,``,`\\@imath`),B(V,U,K,``,`\\@jmath`),B(V,U,J,`ı`,`ı`),B(V,U,J,`ȷ`,`ȷ`),B(H,U,J,`ı`,`\\i`,!0),B(H,U,J,`ȷ`,`\\j`,!0),B(H,U,J,`ß`,`\\ss`,!0),B(H,U,J,`æ`,`\\ae`,!0),B(H,U,J,`œ`,`\\oe`,!0),B(H,U,J,`ø`,`\\o`,!0),B(H,U,J,`Æ`,`\\AE`,!0),B(H,U,J,`Œ`,`\\OE`,!0),B(H,U,J,`Ø`,`\\O`,!0),B(H,U,aW,`ˊ`,`\\'`),B(H,U,aW,`ˋ`,"\\`"),B(H,U,aW,`ˆ`,`\\^`),B(H,U,aW,`˜`,`\\~`),B(H,U,aW,`ˉ`,`\\=`),B(H,U,aW,`˘`,`\\u`),B(H,U,aW,`˙`,`\\.`),B(H,U,aW,`¸`,`\\c`),B(H,U,aW,`˚`,`\\r`),B(H,U,aW,`ˇ`,`\\v`),B(H,U,aW,`¨`,`\\"`),B(H,U,aW,`˝`,`\\H`),B(H,U,aW,`◯`,`\\textcircled`);var fW={"--":!0,"---":!0,"``":!0,"''":!0};B(H,U,J,`–`,`--`,!0),B(H,U,J,`–`,`\\textendash`),B(H,U,J,`—`,`---`,!0),B(H,U,J,`—`,`\\textemdash`),B(H,U,J,`‘`,"`",!0),B(H,U,J,`‘`,`\\textquoteleft`),B(H,U,J,`’`,`'`,!0),B(H,U,J,`’`,`\\textquoteright`),B(H,U,J,`“`,"``",!0),B(H,U,J,`“`,`\\textquotedblleft`),B(H,U,J,`”`,`''`,!0),B(H,U,J,`”`,`\\textquotedblright`),B(V,U,J,`°`,`\\degree`,!0),B(H,U,J,`°`,`\\degree`),B(H,U,J,`°`,`\\textdegree`,!0),B(V,U,J,`£`,`\\pounds`),B(V,U,J,`£`,`\\mathsterling`,!0),B(H,U,J,`£`,`\\pounds`),B(H,U,J,`£`,`\\textsterling`,!0),B(V,W,J,`✠`,`\\maltese`),B(H,W,J,`✠`,`\\maltese`);for(var pW=`0123456789/@."`,mW=0;mW{var t=e.charCodeAt(0),n=e.charCodeAt(1),r=(t-55296)*1024+(n-56320)+65536;if(119808<=r&&r<120484)return VW[Math.floor((r-119808)/26)];if(120782<=r&&r<=120831)return HW[Math.floor((r-120782)/10)];if(r===120485||r===120486)return VW[0];if(120486{if(PU(e.classes)!==PU(t.classes)||e.skew!==t.skew||e.maxFontSize!==t.maxFontSize||e.italic!==0&&e.hasClass(`mathnormal`))return!1;if(e.classes.length===1){var n=e.classes[0];if(n===`mbin`||n===`mord`)return!1}for(var r of Object.keys(e.style))if(e.style[r]!==t.style[r])return!1;for(var i of Object.keys(t.style))if(e.style[i]!==t.style[i])return!1;return!0},XW=e=>{for(var t=0;tt&&(t=a.height),a.depth>n&&(n=a.depth),a.maxFontSize>r&&(r=a.maxFontSize)}e.height=t,e.depth=n,e.maxFontSize=r},X=function(e,t,n,r){var i=new BU(e,t,n,r);return ZW(i),i},QW=(e,t,n,r)=>new BU(e,t,n,r),$W=function(e,t,n){var r=X([e],[],t);return r.height=Math.max(n||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),r.style.borderBottomWidth=z(r.height),r.maxFontSize=1,r},eG=function(e,t,n,r){var i=new VU(e,t,n,r);return ZW(i),i},tG=function(e){var t=new kU(e);return ZW(t),t},nG=function(e,t){return e instanceof kU?X([],[e],t):e},rG=function(e){if(e.positionType===`individualShift`){for(var t=e.children,n=[t[0]],r=-t[0].shift-t[0].elem.depth,i=r,a=1;a{var n=X([`mspace`],[],t),r=NU(e,t);return n.style.marginRight=z(r),n},oG=(e,t,n)=>{var r,i;switch(e){case`amsrm`:r=`AMS`;break;case`textrm`:r=`Main`;break;case`textsf`:r=`SansSerif`;break;case`texttt`:r=`Typewriter`;break;default:r=e}return i=t===`textbf`&&n===`textit`?`BoldItalic`:t===`textbf`?`Bold`:n===`textit`?`Italic`:`Regular`,r+`-`+i},sG={mathbf:{variant:`bold`,fontName:`Main-Bold`},mathrm:{variant:`normal`,fontName:`Main-Regular`},textit:{variant:`italic`,fontName:`Main-Italic`},mathit:{variant:`italic`,fontName:`Main-Italic`},mathnormal:{variant:`italic`,fontName:`Math-Italic`},mathsfit:{variant:`sans-serif-italic`,fontName:`SansSerif-Italic`},mathbb:{variant:`double-struck`,fontName:`AMS-Regular`},mathcal:{variant:`script`,fontName:`Caligraphic-Regular`},mathfrak:{variant:`fraktur`,fontName:`Fraktur-Regular`},mathscr:{variant:`script`,fontName:`Script-Regular`},mathsf:{variant:`sans-serif`,fontName:`SansSerif-Regular`},mathtt:{variant:`monospace`,fontName:`Typewriter-Regular`}},cG={vec:[`vec`,.471,.714],oiintSize1:[`oiintSize1`,.957,.499],oiintSize2:[`oiintSize2`,1.472,.659],oiiintSize1:[`oiiintSize1`,1.304,.499],oiiintSize2:[`oiiintSize2`,1.98,.659]},lG=function(e,t){var n=cG[e],r=n[0],i=n[1],a=n[2],o=QW([`katex-overlay`],[new GU([new KU(r)],{width:z(i),height:z(a),style:`width:`+z(i),viewBox:`0 0 `+1e3*i+` `+1e3*a,preserveAspectRatio:`xMinYMin`})],t);return o.height=a,o.style.height=z(a),o.style.width=z(i),o},uG={number:3,unit:`mu`},dG={number:4,unit:`mu`},fG={number:5,unit:`mu`},pG={mord:{mop:uG,mbin:dG,mrel:fG,minner:uG},mop:{mord:uG,mop:uG,mrel:fG,minner:uG},mbin:{mord:dG,mop:dG,mopen:dG,minner:dG},mrel:{mord:fG,mop:fG,mopen:fG,minner:fG},mopen:{},mclose:{mop:uG,mbin:dG,mrel:fG,minner:uG},mpunct:{mord:uG,mop:uG,mrel:fG,mopen:uG,mclose:uG,mpunct:uG,minner:uG},minner:{mord:uG,mop:uG,mbin:dG,mrel:fG,mopen:uG,mpunct:uG,minner:uG}},mG={mord:{mop:uG},mop:{mord:uG,mop:uG},mbin:{},mrel:{},mopen:{},mclose:{mop:uG},mpunct:{},minner:{mop:uG}},hG={},gG={},_G={};function Z(e){for(var t=e.type,n=e.names,r=e.htmlBuilder,i=e.mathmlBuilder,a=0;a{var n=t.classes[0],r=e.classes[0];n===`mbin`&&SG.has(r)?t.classes[0]=`mord`:r===`mbin`&&xG.has(n)&&(e.classes[0]=`mord`)},{node:u},d,f),EG(i,(e,t)=>{var n=kG(t),r=kG(e),i=n&&r?e.hasClass(`mtight`)?mG[n]?.[r]:pG[n]?.[r]:null;if(i)return aG(i,c)},{node:u},d,f),i},EG=function(e,t,n,r,i){r&&e.push(r);for(var a=0;an=>{e.splice(t+1,0,n),a++})(a)}}r&&e.pop()},DG=function(e){return e instanceof kU||e instanceof VU||e instanceof BU&&e.hasClass(`enclosing`)?e:null},OG=function(e,t){var n=DG(e);if(n){var r=n.children;if(r.length){if(t===`right`)return OG(r[r.length-1],`right`);if(t===`left`)return OG(r[0],`left`)}}return e},kG=function(e,t){return e?(t&&(e=OG(e,t)),wG[e.classes[0]]||null):null},AG=function(e,t){var n=[`nulldelimiter`].concat(e.baseSizingClasses());return X(t.concat(n))},jG=function(e,t,n){if(!e)return X();if(gG[e.type]){var r=gG[e.type](e,t);if(n&&t.size!==n.size){r=X(t.sizingClasses(n),[r],t);var i=t.sizeMultiplier/n.sizeMultiplier;r.height*=i,r.depth*=i}return r}throw new L(`Got group of unknown type: '`+e.type+`'`)};function MG(e,t){var n=X([`katex-base`],e,t),r=X([`katex-strut`]);return r.style.height=z(n.height+n.depth),n.depth&&(r.style.verticalAlign=z(-n.depth)),n.children.unshift(r),n}function NG(e,t){var n=null;e.length===1&&e[0].type===`tag`&&(n=e[0].tag,e=e[0].body);var r=TG(e,t,`root`),i;r.length===2&&r[1].hasClass(`katex-tag`)&&(i=r.pop());for(var a=[],o=[],s=0;s0&&(a.push(MG(o,t)),o=[]),a.push(r[s]));o.length>0&&a.push(MG(o,t));var l;n?(l=MG(TG(n,t,!0),t),l.classes=[`katex-tag`],a.push(l)):i&&a.push(i);var u=X([`katex-html`],a);if(u.setAttribute(`aria-hidden`,`true`),l){var d=l.children[0];d.style.height=z(u.height+u.depth),u.depth&&(d.style.verticalAlign=z(-u.depth))}return u}function PG(e){return new kU(e)}var Q=class{constructor(e,t,n){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=n||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){var e=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,this.type);for(var t of Object.entries(this.attributes)){var n=t[0],r=t[1];e.setAttribute(n,r)}this.classes.length>0&&(e.className=PU(this.classes));for(var i=0;i0&&(e+=` class ="`+zH(PU(this.classes))+`"`),e+=`>`;for(var i=0;i`,e}toText(){return this.children.map(e=>e.toText()).join(``)}},FG=class{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return zH(this.toText())}toText(){return this.text}},IG=class{constructor(e){this.width=void 0,this.character=void 0,this.width=e,this.character=e>=.05555&&e<=.05556?` `:e>=.1666&&e<=.1667?` `:e>=.2222&&e<=.2223?` `:e>=.2777&&e<=.2778?`  `:e>=-.05556&&e<=-.05555?` ⁣`:e>=-.1667&&e<=-.1666?` ⁣`:e>=-.2223&&e<=-.2222?` ⁣`:e>=-.2778&&e<=-.2777?` ⁣`:null}toNode(){if(this.character)return document.createTextNode(this.character);var e=document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`mspace`);return e.setAttribute(`width`,z(this.width)),e}toMarkup(){return this.character?``+this.character+``:``}toText(){return this.character?this.character:` `}},LG=new Set([`\\imath`,`\\jmath`]),RG=new Set([`mrow`,`mtable`]),zG=function(e,t,n){var r,i;return iW[t][e]&&iW[t][e].replace&&e.charCodeAt(0)!==55349&&(!Object.prototype.hasOwnProperty.call(fW,e)||(n==null||(r=n.fontFamily)==null?void 0:r.slice(4,6))!==`tt`&&(n==null||(i=n.font)==null?void 0:i.slice(4,6))!==`tt`)&&(e=iW[t][e].replace),new FG(e)},BG=function(e){return e.length===1?e[0]:new Q(`mrow`,e)},VG={mathit:`italic`,boldsymbol:e=>e.type===`textord`?`bold`:`bold-italic`,mathbf:`bold`,mathbb:`double-struck`,mathsfit:`sans-serif-italic`,mathfrak:`fraktur`,mathscr:`script`,mathcal:`script`,mathsf:`sans-serif`,mathtt:`monospace`},HG=(e,t)=>{if(e.mode===`text`){if(t.fontFamily===`texttt`)return`monospace`;if(t.fontFamily===`textsf`)return t.fontShape===`textit`&&t.fontWeight===`textbf`?`sans-serif-bold-italic`:t.fontShape===`textit`?`sans-serif-italic`:t.fontWeight===`textbf`?`bold-sans-serif`:`sans-serif`;if(t.fontShape===`textit`&&t.fontWeight===`textbf`)return`bold-italic`;if(t.fontShape===`textit`)return`italic`;if(t.fontWeight===`textbf`)return`bold`}var n=t.font;if(!n||n===`mathnormal`)return null;var r=e.mode,i=VG[n];if(i)return typeof i==`function`?i(e):i;var a=e.text;if(LG.has(a))return null;if(iW[r][a]){var o=iW[r][a].replace;o&&(a=o)}var s=sG[n].fontName;return tW(a,s,r)?sG[n].variant:null};function UG(e){if(!e)return!1;if(e.type===`mi`&&e.children.length===1){var t=e.children[0];return t instanceof FG&&t.text===`.`}if(e.type===`mo`&&e.children.length===1&&e.getAttribute(`separator`)===`true`&&e.getAttribute(`lspace`)===`0em`&&e.getAttribute(`rspace`)===`0em`){var n=e.children[0];return n instanceof FG&&n.text===`,`}return!1}var WG=function(e,t,n){if(e.length===1){var r=KG(e[0],t);return n&&r instanceof Q&&r.type===`mo`&&(r.setAttribute(`lspace`,`0em`),r.setAttribute(`rspace`,`0em`)),[r]}for(var i=[],a,o=0;o=1&&(a.type===`mn`||UG(a))){var c=s.children[0];c instanceof Q&&c.type===`mn`&&(c.children=[...a.children,...c.children],i.pop())}else if(a.type===`mi`&&a.children.length===1){var l=a.children[0];if(l instanceof FG&&l.text===`̸`&&(s.type===`mo`||s.type===`mi`||s.type===`mn`)){var u=s.children[0];u instanceof FG&&u.text.length>0&&(u.text=u.text.slice(0,1)+`̸`+u.text.slice(1),i.pop())}}}i.push(s),a=s}return i},GG=function(e,t,n){return BG(WG(e,t,n))},KG=function(e,t){if(!e)return new Q(`mrow`);if(_G[e.type])return _G[e.type](e,t);throw new L(`Got group of unknown type: '`+e.type+`'`)};function qG(e,t,n,r,i){var a=WG(e,n),o=a.length===1&&a[0]instanceof Q&&RG.has(a[0].type)?a[0]:new Q(`mrow`,a),s=new Q(`annotation`,[new FG(t)]);s.setAttribute(`encoding`,`application/x-tex`);var c=new Q(`math`,[new Q(`semantics`,[o,s])]);return c.setAttribute(`xmlns`,`http://www.w3.org/1998/Math/MathML`),r&&c.setAttribute(`display`,`block`),X([i?`katex`:`katex-mathml`],[c])}var JG=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],YG=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],XG=function(e,t){return t.size<2?e:JG[e-1][t.size-1]},ZG=class e{constructor(t){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=t.style,this.color=t.color,this.size=t.size||e.BASESIZE,this.textSize=t.textSize||this.size,this.phantom=!!t.phantom,this.font=t.font||``,this.fontFamily=t.fontFamily||``,this.fontWeight=t.fontWeight||``,this.fontShape=t.fontShape||``,this.sizeMultiplier=YG[this.size-1],this.maxSize=t.maxSize,this.minRuleThickness=t.minRuleThickness,this._fontMetrics=void 0}extend(t){var n={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};return Object.assign(n,t),new e(n)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:XG(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:YG[e-1]})}havingBaseStyle(t){t||=this.style.text();var n=XG(e.BASESIZE,t);return this.size===n&&this.textSize===e.BASESIZE&&this.style===t?this:this.extend({style:t,size:n})}havingBaseSizing(){var e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:``})}withTextFontWeight(e){return this.extend({fontWeight:e,font:``})}withTextFontShape(e){return this.extend({fontShape:e,font:``})}sizingClasses(e){return e.size===this.size?[]:[`katex-sizing`,`reset-size`+e.size,`size`+this.size]}baseSizingClasses(){return this.size===e.BASESIZE?[]:[`katex-sizing`,`reset-size`+this.size,`size`+e.BASESIZE]}fontMetrics(){return this._fontMetrics||=rW(this.size),this._fontMetrics}getColor(){return this.phantom?`transparent`:this.color}};ZG.BASESIZE=6;var QG=function(e){return new ZG({style:e.displayMode?R.DISPLAY:R.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},$G=function(e,t){if(t.displayMode){var n=[`katex-display`];t.leqno&&n.push(`leqno`),t.fleqn&&n.push(`fleqn`),e=X(n,[e])}return e},eK=function(e,t,n){var r=QG(n),i;return n.output===`mathml`?qG(e,t,r,n.displayMode,!0):(i=n.output===`html`?X([`katex`],[NG(e,r)]):X([`katex`],[qG(e,t,r,n.displayMode,!1),NG(e,r)]),$G(i,n))},tK=function(e,t,n){return $G(X([`katex`],[NG(e,QG(n))]),n)},nK={widehat:`^`,widecheck:`ˇ`,widetilde:`~`,utilde:`~`,overleftarrow:`←`,underleftarrow:`←`,xleftarrow:`←`,overrightarrow:`→`,underrightarrow:`→`,xrightarrow:`→`,underbrace:`⏟`,overbrace:`⏞`,underbracket:`⎵`,overbracket:`⎴`,overgroup:`⏠`,undergroup:`⏡`,overleftrightarrow:`↔`,underleftrightarrow:`↔`,xleftrightarrow:`↔`,Overrightarrow:`⇒`,xRightarrow:`⇒`,overleftharpoon:`↼`,xleftharpoonup:`↼`,overrightharpoon:`⇀`,xrightharpoonup:`⇀`,xLeftarrow:`⇐`,xLeftrightarrow:`⇔`,xhookleftarrow:`↩`,xhookrightarrow:`↪`,xmapsto:`↦`,xrightharpoondown:`⇁`,xleftharpoondown:`↽`,xrightleftharpoons:`⇌`,xleftrightharpoons:`⇋`,xtwoheadleftarrow:`↞`,xtwoheadrightarrow:`↠`,xlongequal:`=`,xtofrom:`⇄`,xrightleftarrows:`⇄`,xrightequilibrium:`⇌`,xleftequilibrium:`⇋`,"\\cdrightarrow":`→`,"\\cdleftarrow":`←`,"\\cdlongequal":`=`},rK=function(e){var t=new Q(`mo`,[new FG(nK[e.replace(/^\\/,``)])]);return t.setAttribute(`stretchy`,`true`),t},iK={overrightarrow:[[`rightarrow`],.888,522,`xMaxYMin`],overleftarrow:[[`leftarrow`],.888,522,`xMinYMin`],underrightarrow:[[`rightarrow`],.888,522,`xMaxYMin`],underleftarrow:[[`leftarrow`],.888,522,`xMinYMin`],xrightarrow:[[`rightarrow`],1.469,522,`xMaxYMin`],"\\cdrightarrow":[[`rightarrow`],3,522,`xMaxYMin`],xleftarrow:[[`leftarrow`],1.469,522,`xMinYMin`],"\\cdleftarrow":[[`leftarrow`],3,522,`xMinYMin`],Overrightarrow:[[`doublerightarrow`],.888,560,`xMaxYMin`],xRightarrow:[[`doublerightarrow`],1.526,560,`xMaxYMin`],xLeftarrow:[[`doubleleftarrow`],1.526,560,`xMinYMin`],overleftharpoon:[[`leftharpoon`],.888,522,`xMinYMin`],xleftharpoonup:[[`leftharpoon`],.888,522,`xMinYMin`],xleftharpoondown:[[`leftharpoondown`],.888,522,`xMinYMin`],overrightharpoon:[[`rightharpoon`],.888,522,`xMaxYMin`],xrightharpoonup:[[`rightharpoon`],.888,522,`xMaxYMin`],xrightharpoondown:[[`rightharpoondown`],.888,522,`xMaxYMin`],xlongequal:[[`longequal`],.888,334,`xMinYMin`],"\\cdlongequal":[[`longequal`],3,334,`xMinYMin`],xtwoheadleftarrow:[[`twoheadleftarrow`],.888,334,`xMinYMin`],xtwoheadrightarrow:[[`twoheadrightarrow`],.888,334,`xMaxYMin`],overleftrightarrow:[[`leftarrow`,`rightarrow`],.888,522],overbrace:[[`leftbrace`,`midbrace`,`rightbrace`],1.6,548],underbrace:[[`leftbraceunder`,`midbraceunder`,`rightbraceunder`],1.6,548],underleftrightarrow:[[`leftarrow`,`rightarrow`],.888,522],xleftrightarrow:[[`leftarrow`,`rightarrow`],1.75,522],xLeftrightarrow:[[`doubleleftarrow`,`doublerightarrow`],1.75,560],xrightleftharpoons:[[`leftharpoondownplus`,`rightharpoonplus`],1.75,716],xleftrightharpoons:[[`leftharpoonplus`,`rightharpoondownplus`],1.75,716],xhookleftarrow:[[`leftarrow`,`righthook`],1.08,522],xhookrightarrow:[[`lefthook`,`rightarrow`],1.08,522],overlinesegment:[[`leftlinesegment`,`rightlinesegment`],.888,522],underlinesegment:[[`leftlinesegment`,`rightlinesegment`],.888,522],overbracket:[[`leftbracketover`,`rightbracketover`],1.6,440],underbracket:[[`leftbracketunder`,`rightbracketunder`],1.6,410],overgroup:[[`leftgroup`,`rightgroup`],.888,342],undergroup:[[`leftgroupunder`,`rightgroupunder`],.888,342],xmapsto:[[`leftmapsto`,`rightarrow`],1.5,522],xtofrom:[[`leftToFrom`,`rightToFrom`],1.75,528],xrightleftarrows:[[`baraboveleftarrow`,`rightarrowabovebar`],1.75,901],xrightequilibrium:[[`baraboveshortleftharpoon`,`rightharpoonaboveshortbar`],1.75,716],xleftequilibrium:[[`shortbaraboveleftharpoon`,`shortrightharpoonabovebar`],1.75,716]},aK=new Set([`widehat`,`widecheck`,`widetilde`,`utilde`]),oK=function(e,t){function n(){var n=4e5,r=e.label.slice(1);if(aK.has(r)&&`base`in e){var i=e.base.type===`ordgroup`?e.base.body.length:1,a,o,s;if(i>5)r===`widehat`||r===`widecheck`?(a=420,n=2364,s=.42,o=r+`4`):(a=312,n=2340,s=.34,o=`tilde4`);else{var c=[1,1,2,2,3,3][i];r===`widehat`||r===`widecheck`?(n=[0,1062,2364,2364,2364][c],a=[0,239,300,360,420][c],s=[0,.24,.3,.3,.36,.42][c],o=r+c):(n=[0,600,1033,2339,2340][c],a=[0,260,286,306,312][c],s=[0,.26,.286,.3,.306,.34][c],o=`tilde`+c)}return{span:QW([],[new GU([new KU(o)],{width:`100%`,height:z(s),viewBox:`0 0 `+n+` `+a,preserveAspectRatio:`none`})],t),minWidth:0,height:s}}var l=[],u=iK[r];if(!u)throw Error(`No SVG data for "`+r+`".`);var d=u[0],f=u[1],p=u[2],m=p/1e3,h=d.length,g,_;if(h===1){if(u.length!==4)throw Error(`Expected 4-tuple for single-path SVG data "`+r+`".`);g=[`hide-tail`],_=[u[3]]}else if(h===2)g=[`halfarrow-left`,`halfarrow-right`],_=[`xMinYMin`,`xMaxYMin`];else if(h===3)g=[`brace-left`,`brace-center`,`brace-right`],_=[`xMinYMin`,`xMidYMin`,`xMaxYMin`];else throw Error(`Correct katexImagesData or update code here to support + `+h+` children.`);for(var v=0;v0&&(i.style.minWidth=z(a)),i},sK=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 qU({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new qU({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=QW([],[new GU(c,{width:`100%`,height:z(o)})],i)}return a.height=o,a.style.height=z(o),a},cK=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],lK=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],uK=new Set(cK),dK=new Set(lK);function fK(e){return uK.has(e)}function pK(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 mK(e){var t=hK(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function hK(e){return e.type===`atom`||dK.has(e.type)?e:null}function gK(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 _K=e=>{if(e instanceof WU)return e;if(XU(e)&&e.children.length===1)return _K(e.children[0])},vK=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=pK(e.base,`accent`),n=r.base,e.base=n,i=YU(jG(e,t)),e.base=r):(r=pK(e,`accent`),n=r.base);var a=jG(n,t.havingCrampedStyle()),o=r.isShifty&&HH(n),s=0;o&&(s=_K(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=oK(r,t),u=iG({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=lG(`vec`,t),f=cG.vec[1]):(d=JW({type:`textord`,mode:r.mode,text:r.label},t),d=JU(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=iG({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},yK=(e,t)=>{var n=e.isStretchy?rK(e.label):new Q(`mo`,[zG(e.label,e.mode)]),r=new Q(`mover`,[KG(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},bK=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=yG(t[0]),r=!bK.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:vK,mathmlBuilder:yK}),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=jG(e.base,t),r=oK(e,t),i=e.label===`\\utilde`?.12:0;return X([`mord`,`accentunder`],[iG({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=rK(e.label),r=new Q(`munder`,[KG(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var xK=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`,`\\xleftrightarrow`,`\\xLeftrightarrow`,`\\xhookleftarrow`,`\\xhookrightarrow`,`\\xmapsto`,`\\xrightharpoondown`,`\\xrightharpoonup`,`\\xleftharpoondown`,`\\xleftharpoonup`,`\\xrightleftharpoons`,`\\xleftrightharpoons`,`\\xlongequal`,`\\xtwoheadrightarrow`,`\\xtwoheadleftarrow`,`\\xtofrom`,`\\xrightleftarrows`,`\\xrightequilibrium`,`\\xleftequilibrium`,`\\\\cdrightarrow`,`\\\\cdleftarrow`,`\\\\cdlongequal`],numArgs:1,numOptionalArgs:1,handler(e,t,n){var r=e.parser,i=e.funcName;return{type:`xArrow`,mode:r.mode,label:i,body:t[0],below:n[0]}},htmlBuilder(e,t){var n=t.style,r=t.havingStyle(n.sup()),i=nG(jG(e.body,r,t),t),a=e.label.slice(0,2)===`\\x`?`x`:`cd`;i.classes.push(a+`-arrow-pad`);var o;e.below&&(r=t.havingStyle(n.sub()),o=nG(jG(e.below,r,t),t),o.classes.push(a+`-arrow-pad`));var s=oK(e,t),c=-t.fontMetrics().axisHeight+.5*s.height,l=-t.fontMetrics().axisHeight-.5*s.height-.111;(i.depth>.25||e.label===`\\xleftequilibrium`)&&(l-=i.depth);var u;if(o){var d=-t.fontMetrics().axisHeight+o.height+.5*s.height+.111;u=iG({positionType:`individualShift`,children:[{type:`elem`,elem:i,shift:l},{type:`elem`,elem:s,shift:c,wrapperClasses:[`svg-align`]},{type:`elem`,elem:o,shift:d}]})}else u=iG({positionType:`individualShift`,children:[{type:`elem`,elem:i,shift:l},{type:`elem`,elem:s,shift:c,wrapperClasses:[`svg-align`]}]});return X([`mrel`,`x-arrow`],[u],t)},mathmlBuilder(e,t){var n=rK(e.label);n.setAttribute(`minsize`,e.label.charAt(0)===`x`?`1.75em`:`3.0em`);var r;if(e.body){var i=xK(KG(e.body,t));r=e.below?new Q(`munderover`,[n,xK(KG(e.below,t)),i]):new Q(`mover`,[n,i])}else e.below?r=new Q(`munder`,[n,xK(KG(e.below,t))]):(r=xK(),r=new Q(`mover`,[n,r]));return r}});function SK(e,t){var n=TG(e.body,t,!0);return X([e.mclass],n,t)}function CK(e,t){var n,r=WG(e.body,t);return e.mclass===`minner`?n=new Q(`mpadded`,r):e.mclass===`mord`?e.isCharacterBox?(n=r[0],n.type=`mi`):n=new Q(`mi`,r):(e.isCharacterBox?(n=r[0],n.type=`mo`):n=new Q(`mo`,r),e.mclass===`mbin`?(n.attributes.lspace=`0.22em`,n.attributes.rspace=`0.22em`):e.mclass===`mpunct`?(n.attributes.lspace=`0em`,n.attributes.rspace=`0.17em`):(e.mclass===`mopen`||e.mclass===`mclose`)&&(n.attributes.lspace=`0em`,n.attributes.rspace=`0em`)),n}Z({type:`mclass`,names:[`\\mathord`,`\\mathbin`,`\\mathrel`,`\\mathopen`,`\\mathclose`,`\\mathpunct`,`\\mathinner`],numArgs:1,primitive:!0,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`mclass`,mode:n.mode,mclass:`m`+r.slice(5),body:bG(i),isCharacterBox:HH(i)}},htmlBuilder:SK,mathmlBuilder:CK});var wK=e=>{var t=e.type===`ordgroup`&&e.body.length?e.body[0]:e;return t.type===`atom`&&(t.family===`bin`||t.family===`rel`)?`m`+t.family:`mord`};Z({type:`mclass`,names:[`\\@binrel`],numArgs:2,handler(e,t){return{type:`mclass`,mode:e.parser.mode,mclass:wK(t[0]),body:bG(t[1]),isCharacterBox:HH(t[1])}}}),Z({type:`mclass`,names:[`\\stackrel`,`\\overset`,`\\underset`],numArgs:2,handler(e,t){var n=e.parser,r=e.funcName,i=t[1],a=t[0],o=r===`\\stackrel`?`mrel`:wK(i),s={type:`op`,mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:r!==`\\stackrel`,body:bG(i)},c=r===`\\underset`?{type:`supsub`,mode:a.mode,base:s,sub:a}:{type:`supsub`,mode:a.mode,base:s,sup:a};return{type:`mclass`,mode:n.mode,mclass:o,body:[c],isCharacterBox:HH(c)}}}),Z({type:`pmb`,names:[`\\pmb`],numArgs:1,allowedInText:!0,handler(e,t){return{type:`pmb`,mode:e.parser.mode,mclass:wK(t[0]),body:bG(t[0])}},htmlBuilder(e,t){var n=TG(e.body,t,!0),r=X([e.mclass],n,t);return r.style.textShadow=`0.02em 0.01em 0.04px`,r},mathmlBuilder(e,t){var n=new Q(`mstyle`,WG(e.body,t));return n.setAttribute(`style`,`text-shadow: 0.02em 0.01em 0.04px`),n}});var TK={">":`\\\\cdrightarrow`,"<":`\\\\cdleftarrow`,"=":`\\\\cdlongequal`,A:`\\uparrow`,V:`\\downarrow`,"|":`\\Vert`,".":`no arrow`},EK=()=>({type:`styling`,body:[],mode:`math`,style:`display`,resetFont:!0}),DK=e=>e.type===`textord`&&e.text===`@`,OK=(e,t)=>(e.type===`mathord`||e.type===`atom`)&&e.text===t;function kK(e,t,n){var r=TK[e];switch(r){case`\\\\cdrightarrow`:case`\\\\cdleftarrow`:return n.callFunction(r,[t[0]],[t[1]]);case`\\uparrow`:case`\\downarrow`:var i=n.callFunction(`\\\\cdleft`,[t[0]],[]),a={type:`atom`,text:r,mode:`math`,family:`rel`},o={type:`ordgroup`,mode:`math`,body:[i,n.callFunction(`\\Big`,[a],[]),n.callFunction(`\\\\cdright`,[t[1]],[])]};return n.callFunction(`\\\\cdparent`,[o],[]);case`\\\\cdlongequal`:return n.callFunction(`\\\\cdlongequal`,[],[]);case`\\Vert`:return n.callFunction(`\\Big`,[{type:`textord`,text:`\\Vert`,mode:`math`}],[]);default:return{type:`textord`,text:` `,mode:`math`}}}function AK(e){var t=[];for(e.gullet.beginGroup(),e.gullet.macros.set(`\\cr`,`\\\\\\relax`),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,`\\\\`)),e.gullet.endGroup(),e.gullet.beginGroup();var n=e.fetch().text;if(n===`&`||n===`\\\\`)e.consume();else if(n===`\\end`){t[t.length-1].length===0&&t.pop();break}else throw new L(`Expected \\\\ or \\cr or \\end`,e.nextToken)}for(var r=[],i=[r],a=0;aAV`.includes(l))for(var d=0;d<2;d++){for(var f=!0,p=c+1;pAV=|." after @`,o[c])}var m={type:`styling`,body:[kK(l,u,e)],mode:`math`,style:`display`,resetFont:!0};r.push(m),s=EK()}a%2==0?r.push(s):r.shift(),r=[],i.push(r)}return e.gullet.endGroup(),e.gullet.endGroup(),{type:`array`,mode:`math`,body:i,arraystretch:1,addJot:!0,rowGaps:[null],cols:Array(i[0].length).fill({type:`align`,align:`c`,pregap:.25,postgap:.25}),colSeparationType:`CD`,hLinesBeforeRow:Array(i.length+1).fill([])}}Z({type:`cdlabel`,names:[`\\\\cdleft`,`\\\\cdright`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName;return{type:`cdlabel`,mode:n.mode,side:r.slice(4),label:t[0]}},htmlBuilder(e,t){var n=t.havingStyle(t.style.sup()),r=nG(jG(e.label,n,t),t);return r.classes.push(`cd-label-`+e.side),r.style.bottom=z(.8-r.depth),r.height=0,r.depth=0,r},mathmlBuilder(e,t){var n=new Q(`mrow`,[KG(e.label,t)]);return n=new Q(`mpadded`,[n]),n.setAttribute(`width`,`0`),e.side===`left`&&n.setAttribute(`lspace`,`-1width`),n.setAttribute(`voffset`,`0.7em`),n=new Q(`mstyle`,[n]),n.setAttribute(`displaystyle`,`false`),n.setAttribute(`scriptlevel`,`1`),n}}),Z({type:`cdlabelparent`,names:[`\\\\cdparent`],numArgs:1,handler(e,t){return{type:`cdlabelparent`,mode:e.parser.mode,fragment:t[0]}},htmlBuilder(e,t){var n=nG(jG(e.fragment,t),t);return n.classes.push(`cd-vert-arrow`),n},mathmlBuilder(e,t){return new Q(`mrow`,[KG(e.fragment,t)])}}),Z({type:`textord`,names:[`\\@char`],numArgs:1,allowedInText:!0,handler(e,t){var n=e.parser,r=gK(pK(t[0],`ordgroup`),`\\@char has non-numeric argument`),i=parseInt(r),a;if(isNaN(i))throw new L(`\\@char has non-numeric argument `+r);if(i<0||i>1114111)throw new L(`\\@char with invalid code point `+r);return i<=65535?a=String.fromCharCode(i):(i-=65536,a=String.fromCharCode((i>>10)+55296,(i&1023)+56320)),{type:`textord`,mode:n.mode,text:a}}}),Z({type:`color`,names:[`\\textcolor`],numArgs:2,allowedInText:!0,argTypes:[`color`,`original`],handler(e,t){var n=e.parser,r=pK(t[0],`color-token`).color,i=t[1];return{type:`color`,mode:n.mode,color:r,body:bG(i)}},htmlBuilder:(e,t)=>tG(TG(e.body,t.withColor(e.color),!1)),mathmlBuilder:(e,t)=>{var n=new Q(`mstyle`,WG(e.body,t.withColor(e.color)));return n.setAttribute(`mathcolor`,e.color),n}}),Z({type:`color`,names:[`\\color`],numArgs:1,allowedInText:!0,argTypes:[`color`],handler(e,t){var n=e.parser,r=e.breakOnTokenText,i=pK(t[0],`color-token`).color;n.gullet.macros.set(`\\current@color`,i);var a=n.parseExpression(!0,r);return{type:`color`,mode:n.mode,color:i,body:a}}}),Z({type:`cr`,names:[`\\\\`],numArgs:0,numOptionalArgs:0,allowedInText:!0,handler(e,t,n){var r=e.parser,i=r.gullet.future().text===`[`?r.parseSizeGroup(!0):null,a=!r.settings.displayMode||!r.settings.useStrictBehavior(`newLineInDisplayMode`,`In LaTeX, \\\\ or \\newline does nothing in display mode`);return{type:`cr`,mode:r.mode,newLine:a,size:i&&pK(i,`size`).value}},htmlBuilder(e,t){var n=X([`mspace`],[],t);return e.newLine&&(n.classes.push(`katex-newline`),e.size&&(n.style.marginTop=z(NU(e.size,t)))),n},mathmlBuilder(e,t){var n=new Q(`mspace`);return e.newLine&&(n.setAttribute(`linebreak`,`newline`),e.size&&n.setAttribute(`height`,z(NU(e.size,t)))),n}});var jK={"\\global":`\\global`,"\\long":`\\\\globallong`,"\\\\globallong":`\\\\globallong`,"\\def":`\\gdef`,"\\gdef":`\\gdef`,"\\edef":`\\xdef`,"\\xdef":`\\xdef`,"\\let":`\\\\globallet`,"\\futurelet":`\\\\globalfuture`},MK=e=>{var t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new L(`Expected a control sequence`,e);return t},NK=e=>{var t=e.gullet.popToken();return t.text===`=`&&(t=e.gullet.popToken(),t.text===` `&&(t=e.gullet.popToken())),t},PK=(e,t,n,r)=>{var i=e.gullet.macros.get(n.text);i??=(n.noexpand=!0,{tokens:[n],numArgs:0,unexpandable:!e.gullet.isExpandable(n.text)}),e.gullet.macros.set(t,i,r)};Z({type:`internal`,names:[`\\global`,`\\long`,`\\\\globallong`],numArgs:0,allowedInText:!0,handler(e){var t=e.parser,n=e.funcName;t.consumeSpaces();var r=t.fetch();if(jK[r.text])return(n===`\\global`||n===`\\\\globallong`)&&(r.text=jK[r.text]),pK(t.parseFunction(),`internal`);throw new L(`Invalid token after macro prefix`,r)}}),Z({type:`internal`,names:[`\\def`,`\\gdef`,`\\edef`,`\\xdef`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=t.gullet.popToken(),i=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(i))throw new L(`Expected a control sequence`,r);for(var a=0,o,s=[[]];t.gullet.future().text!==`{`;)if(r=t.gullet.popToken(),r.text===`#`){if(t.gullet.future().text===`{`){o=t.gullet.future(),s[a].push(`{`);break}if(r=t.gullet.popToken(),!/^[1-9]$/.test(r.text))throw new L(`Invalid argument number "`+r.text+`"`);if(parseInt(r.text)!==a+1)throw new L(`Argument number "`+r.text+`" out of order`);a++,s.push([])}else if(r.text===`EOF`)throw new L(`Expected a macro definition`);else s[a].push(r.text);var c=t.gullet.consumeArg().tokens;return o&&c.unshift(o),(n===`\\edef`||n===`\\xdef`)&&(c=t.gullet.expandTokens(c),c.reverse()),t.gullet.macros.set(i,{tokens:c,numArgs:a,delimiters:s},n===jK[n]),{type:`internal`,mode:t.mode}}}),Z({type:`internal`,names:[`\\let`,`\\\\globallet`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=MK(t.gullet.popToken());return t.gullet.consumeSpaces(),PK(t,r,NK(t),n===`\\\\globallet`),{type:`internal`,mode:t.mode}}}),Z({type:`internal`,names:[`\\futurelet`,`\\\\globalfuture`],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,n=e.funcName,r=MK(t.gullet.popToken()),i=t.gullet.popToken(),a=t.gullet.popToken();return PK(t,r,a,n===`\\\\globalfuture`),t.gullet.pushToken(a),t.gullet.pushToken(i),{type:`internal`,mode:t.mode}}});var FK=function(e,t,n){var r=tW(iW.math[e]&&iW.math[e].replace||e,t,n);if(!r)throw Error(`Unsupported symbol `+e+` and font size `+t+`.`);return r},IK=function(e,t,n,r){var i=n.havingBaseStyle(t),a=X(r.concat(i.sizingClasses(n)),[e],n),o=i.sizeMultiplier/n.sizeMultiplier;return a.height*=o,a.depth*=o,a.maxFontSize=i.sizeMultiplier,a},LK=function(e,t,n){var r=t.havingBaseStyle(n),i=(1-t.sizeMultiplier/r.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push(`delimcenter`),e.style.top=z(i),e.height-=i,e.depth+=i},RK=function(e,t,n,r,i,a){var o=IK(GW(e,`Main-Regular`,i,r),t,r,a);return n&&LK(o,r,t),o},zK=function(e,t,n,r){return GW(e,`Size`+t+`-Regular`,n,r)},BK=function(e,t,n,r,i,a){var o=zK(e,t,i,r),s=IK(X([`delimsizing`,`size`+t],[o],r),R.TEXT,r,a);return n&&LK(s,r,R.TEXT),s},VK=function(e,t,n){return{type:`elem`,elem:X([`delimsizinginner`,t===`Size1-Regular`?`delim-size1`:`delim-size4`],[X([],[GW(e,t,n)])])}},HK=function(e,t,n){var r=ZU[`Size4-Regular`][e.charCodeAt(0)]?ZU[`Size4-Regular`][e.charCodeAt(0)][4]:ZU[`Size1-Regular`][e.charCodeAt(0)][4],i=QW([],[new GU([new KU(`inner`,TU(e,Math.round(1e3*t)))],{width:z(r),height:z(t),style:`width:`+z(r),viewBox:`0 0 `+1e3*r+` `+Math.round(1e3*t),preserveAspectRatio:`xMinYMin`})],n);return i.height=t,i.style.height=z(t),i.style.width=z(r),{type:`elem`,elem:i}},UK=.008,WK={type:`kern`,size:-1*UK},GK=new Set([`|`,`\\lvert`,`\\rvert`,`\\vert`]),KK=new Set([`\\|`,`\\lVert`,`\\rVert`,`\\Vert`]),qK=function(e,t,n,r,i,a){var o,s,c,l,u=``,d=0;o=c=l=e,s=null;var f=`Size1-Regular`;e===`\\uparrow`?c=l=`⏐`:e===`\\Uparrow`?c=l=`‖`:e===`\\downarrow`?o=c=`⏐`:e===`\\Downarrow`?o=c=`‖`:e===`\\updownarrow`?(o=`\\uparrow`,c=`⏐`,l=`\\downarrow`):e===`\\Updownarrow`?(o=`\\Uparrow`,c=`‖`,l=`\\Downarrow`):GK.has(e)?(c=`∣`,u=`vert`,d=333):KK.has(e)?(c=`∥`,u=`doublevert`,d=556):e===`[`||e===`\\lbrack`?(o=`⎡`,c=`⎢`,l=`⎣`,f=`Size4-Regular`,u=`lbrack`,d=667):e===`]`||e===`\\rbrack`?(o=`⎤`,c=`⎥`,l=`⎦`,f=`Size4-Regular`,u=`rbrack`,d=667):e===`\\lfloor`||e===`⌊`?(c=o=`⎢`,l=`⎣`,f=`Size4-Regular`,u=`lfloor`,d=667):e===`\\lceil`||e===`⌈`?(o=`⎡`,c=l=`⎢`,f=`Size4-Regular`,u=`lceil`,d=667):e===`\\rfloor`||e===`⌋`?(c=o=`⎥`,l=`⎦`,f=`Size4-Regular`,u=`rfloor`,d=667):e===`\\rceil`||e===`⌉`?(o=`⎤`,c=l=`⎥`,f=`Size4-Regular`,u=`rceil`,d=667):e===`(`||e===`\\lparen`?(o=`⎛`,c=`⎜`,l=`⎝`,f=`Size4-Regular`,u=`lparen`,d=875):e===`)`||e===`\\rparen`?(o=`⎞`,c=`⎟`,l=`⎠`,f=`Size4-Regular`,u=`rparen`,d=875):e===`\\{`||e===`\\lbrace`?(o=`⎧`,s=`⎨`,l=`⎩`,c=`⎪`,f=`Size4-Regular`):e===`\\}`||e===`\\rbrace`?(o=`⎫`,s=`⎬`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):e===`\\lgroup`||e===`⟮`?(o=`⎧`,l=`⎩`,c=`⎪`,f=`Size4-Regular`):e===`\\rgroup`||e===`⟯`?(o=`⎫`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):e===`\\lmoustache`||e===`⎰`?(o=`⎧`,l=`⎭`,c=`⎪`,f=`Size4-Regular`):(e===`\\rmoustache`||e===`⎱`)&&(o=`⎫`,l=`⎩`,c=`⎪`,f=`Size4-Regular`);var p=FK(o,f,i),m=p.height+p.depth,h=FK(c,f,i),g=h.height+h.depth,_=FK(l,f,i),v=_.height+_.depth,y=0,b=1;if(s!==null){var x=FK(s,f,i);y=x.height+x.depth,b=2}var S=m+v+y,C=S+Math.max(0,Math.ceil((t-S)/(b*g)))*b*g,ee=r.fontMetrics().axisHeight;n&&(ee*=r.sizeMultiplier);var te=C/2-ee,ne=[];if(u.length>0){var re=C-m-v,ie=Math.round(C*1e3),ae=DU(u,Math.round(re*1e3)),oe=new KU(u,ae),se=z(d/1e3),ce=z(ie/1e3),le=QW([],[new GU([oe],{width:se,height:ce,viewBox:`0 0 `+d+` `+ie})],r);le.height=ie/1e3,le.style.width=se,le.style.height=ce,ne.push({type:`elem`,elem:le})}else{if(ne.push(VK(l,f,i)),ne.push(WK),s===null){var ue=C-m-v+2*UK;ne.push(HK(c,ue,r))}else{var de=(C-m-v-y)/2+2*UK;ne.push(HK(c,de,r)),ne.push(WK),ne.push(VK(s,f,i)),ne.push(WK),ne.push(HK(c,de,r))}ne.push(WK),ne.push(VK(o,f,i))}var fe=r.havingBaseStyle(R.TEXT);return IK(X([`delimsizing`,`mult`],[iG({positionType:`bottom`,positionData:te,children:ne})],fe),R.TEXT,r,a)},JK=80,YK=.08,XK=function(e,t,n,r,i){return QW([`hide-tail`],[new GU([new KU(e,wU(e,r,n))],{width:`400em`,height:z(t),viewBox:`0 0 400000 `+n,preserveAspectRatio:`xMinYMin slice`})],i)},ZK=function(e,t){var n=t.havingBaseSizing(),r=sq(`\\surd`,e*n.sizeMultiplier,aq,n),i=n.sizeMultiplier,a=Math.max(0,t.minRuleThickness-t.fontMetrics().sqrtRuleThickness),o,s,c,l,u;return r.type===`small`?(l=1e3+1e3*a+JK,e<1?i=1:e<1.4&&(i=.7),s=(1+a+YK)/i,c=(1+a)/i,o=XK(`sqrtMain`,s,l,a,t),o.style.minWidth=`0.853em`,u=.833/i):r.type===`large`?(l=(1e3+JK)*tq[r.size],c=(tq[r.size]+a)/i,s=(tq[r.size]+a+YK)/i,o=XK(`sqrtSize`+r.size,s,l,a,t),o.style.minWidth=`1.02em`,u=1/i):(s=e+a+YK,c=e+a,l=Math.floor(1e3*e+a)+JK,o=XK(`sqrtTall`,s,l,a,t),o.style.minWidth=`0.742em`,u=1.056),o.height=c,o.style.height=z(s),{span:o,advanceWidth:u,ruleWidth:(t.fontMetrics().sqrtRuleThickness+a)*i}},QK=new Set([`(`,`\\lparen`,`)`,`\\rparen`,`[`,`\\lbrack`,`]`,`\\rbrack`,`\\{`,`\\lbrace`,`\\}`,`\\rbrace`,`\\lfloor`,`\\rfloor`,`⌊`,`⌋`,`\\lceil`,`\\rceil`,`⌈`,`⌉`,`\\surd`]),$K=new Set([`\\uparrow`,`\\downarrow`,`\\updownarrow`,`\\Uparrow`,`\\Downarrow`,`\\Updownarrow`,`|`,`\\|`,`\\vert`,`\\Vert`,`\\lvert`,`\\rvert`,`\\lVert`,`\\rVert`,`\\lgroup`,`\\rgroup`,`⟮`,`⟯`,`\\lmoustache`,`\\rmoustache`,`⎰`,`⎱`]),eq=new Set([`<`,`>`,`\\langle`,`\\rangle`,`/`,`\\backslash`,`\\lt`,`\\gt`]),tq=[0,1.2,1.8,2.4,3],nq=function(e,t,n,r,i){if(e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`),QK.has(e)||eq.has(e))return BK(e,t,!1,n,r,i);if($K.has(e))return qK(e,tq[t],!1,n,r,i);throw new L(`Illegal delimiter: '`+e+`'`)},rq=[{type:`small`,style:R.SCRIPTSCRIPT},{type:`small`,style:R.SCRIPT},{type:`small`,style:R.TEXT},{type:`large`,size:1},{type:`large`,size:2},{type:`large`,size:3},{type:`large`,size:4}],iq=[{type:`small`,style:R.SCRIPTSCRIPT},{type:`small`,style:R.SCRIPT},{type:`small`,style:R.TEXT},{type:`stack`}],aq=[{type:`small`,style:R.SCRIPTSCRIPT},{type:`small`,style:R.SCRIPT},{type:`small`,style:R.TEXT},{type:`large`,size:1},{type:`large`,size:2},{type:`large`,size:3},{type:`large`,size:4},{type:`stack`}],oq=function(e){if(e.type===`small`)return`Main-Regular`;if(e.type===`large`)return`Size`+e.size+`-Regular`;if(e.type===`stack`)return`Size4-Regular`;var t=e.type;throw Error(`Add support for delim type '`+t+`' here.`)},sq=function(e,t,n,r){for(var i=Math.min(2,3-r.style.size);it)return a}return n[n.length-1]},cq=function(e,t,n,r,i,a){e===`<`||e===`\\lt`||e===`⟨`?e=`\\langle`:(e===`>`||e===`\\gt`||e===`⟩`)&&(e=`\\rangle`);var o=eq.has(e)?rq:QK.has(e)?aq:iq,s=sq(e,t,o,r);return s.type===`small`?RK(e,s.style,n,r,i,a):s.type===`large`?BK(e,s.size,n,r,i,a):qK(e,t,n,r,i,a)},lq=function(e,t,n,r,i,a){var o=r.fontMetrics().axisHeight*r.sizeMultiplier,s=901,c=5/r.fontMetrics().ptPerEm,l=Math.max(t-o,n+o);return cq(e,Math.max(l/500*s,2*l-c),!0,r,i,a)},uq={"\\bigl":{mclass:`mopen`,size:1},"\\Bigl":{mclass:`mopen`,size:2},"\\biggl":{mclass:`mopen`,size:3},"\\Biggl":{mclass:`mopen`,size:4},"\\bigr":{mclass:`mclose`,size:1},"\\Bigr":{mclass:`mclose`,size:2},"\\biggr":{mclass:`mclose`,size:3},"\\Biggr":{mclass:`mclose`,size:4},"\\bigm":{mclass:`mrel`,size:1},"\\Bigm":{mclass:`mrel`,size:2},"\\biggm":{mclass:`mrel`,size:3},"\\Biggm":{mclass:`mrel`,size:4},"\\big":{mclass:`mord`,size:1},"\\Big":{mclass:`mord`,size:2},"\\bigg":{mclass:`mord`,size:3},"\\Bigg":{mclass:`mord`,size:4}},dq=new Set(`(,\\lparen,),\\rparen,[,\\lbrack,],\\rbrack,\\{,\\lbrace,\\},\\rbrace,\\lfloor,\\rfloor,⌊,⌋,\\lceil,\\rceil,⌈,⌉,<,>,\\langle,⟨,\\rangle,⟩,\\lt,\\gt,\\lvert,\\rvert,\\lVert,\\rVert,\\lgroup,\\rgroup,⟮,⟯,\\lmoustache,\\rmoustache,⎰,⎱,/,\\backslash,|,\\vert,\\|,\\Vert,\\uparrow,\\Uparrow,\\downarrow,\\Downarrow,\\updownarrow,\\Updownarrow,.`.split(`,`));function fq(e){return`isMiddle`in e}function pq(e,t){var n=hK(e);if(n&&dq.has(n.text))return n;throw n?new L(`Invalid delimiter '`+n.text+`' after '`+t.funcName+`'`,e):new L(`Invalid delimiter type '`+e.type+`'`,e)}Z({type:`delimsizing`,names:[`\\bigl`,`\\Bigl`,`\\biggl`,`\\Biggl`,`\\bigr`,`\\Bigr`,`\\biggr`,`\\Biggr`,`\\bigm`,`\\Bigm`,`\\biggm`,`\\Biggm`,`\\big`,`\\Big`,`\\bigg`,`\\Bigg`],numArgs:1,argTypes:[`primitive`],handler:(e,t)=>{var n=pq(yG(t[0]),e);return{type:`delimsizing`,mode:e.parser.mode,size:uq[e.funcName].size,mclass:uq[e.funcName].mclass,delim:n.text}},htmlBuilder:(e,t)=>e.delim===`.`?X([e.mclass]):nq(e.delim,e.size,t,e.mode,[e.mclass]),mathmlBuilder:e=>{var t=[];e.delim!==`.`&&t.push(zG(e.delim,e.mode));var n=new Q(`mo`,t);e.mclass===`mopen`||e.mclass===`mclose`?n.setAttribute(`fence`,`true`):n.setAttribute(`fence`,`false`),n.setAttribute(`stretchy`,`true`);var r=z(tq[e.size]);return n.setAttribute(`minsize`,r),n.setAttribute(`maxsize`,r),n}});function mq(e){if(!e.body)throw Error(`Bug: The leftright ParseNode wasn't fully parsed.`)}Z({type:`leftright-right`,names:[`\\right`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=e.parser.gullet.macros.get(`\\current@color`);if(n&&typeof n!=`string`)throw new L(`\\current@color set to non-string in \\right`);return{type:`leftright-right`,mode:e.parser.mode,delim:pq(t[0],e).text,color:n}}}),Z({type:`leftright`,names:[`\\left`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=pq(t[0],e),r=e.parser;++r.leftrightDepth;var i=r.parseExpression(!1);--r.leftrightDepth,r.expect(`\\right`,!1);var a=pK(r.parseFunction(),`leftright-right`);return{type:`leftright`,mode:r.mode,body:i,left:n.text,right:a.delim,rightColor:a.color}},htmlBuilder:(e,t)=>{mq(e);for(var n=TG(e.body,t,!0,[`mopen`,`mclose`]),r=0,i=0,a=!1,o=0;o{mq(e);var n=WG(e.body,t);if(e.left!==`.`){var r=new Q(`mo`,[zG(e.left,e.mode)]);r.setAttribute(`fence`,`true`),n.unshift(r)}if(e.right!==`.`){var i=new Q(`mo`,[zG(e.right,e.mode)]);i.setAttribute(`fence`,`true`),e.rightColor&&i.setAttribute(`mathcolor`,e.rightColor),n.push(i)}return BG(n)}}),Z({type:`middle`,names:[`\\middle`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=pq(t[0],e);if(!e.parser.leftrightDepth)throw new L(`\\middle without preceding \\left`,n);return{type:`middle`,mode:e.parser.mode,delim:n.text}},htmlBuilder:(e,t)=>{var n;return e.delim===`.`?n=AG(t,[]):(n=nq(e.delim,1,t,e.mode,[]),n.isMiddle={delim:e.delim,options:t}),n},mathmlBuilder:(e,t)=>{var n=new Q(`mo`,[e.delim===`\\vert`||e.delim===`|`?zG(`|`,`text`):zG(e.delim,e.mode)]);return n.setAttribute(`fence`,`true`),n.setAttribute(`lspace`,`0.05em`),n.setAttribute(`rspace`,`0.05em`),n}}),Z({type:`enclose`,names:[`\\colorbox`],numArgs:2,allowedInText:!0,argTypes:[`color`,`hbox`],handler(e,t,n){var r=e.parser,i=e.funcName,a=pK(t[0],`color-token`).color,o=t[1];return{type:`enclose`,mode:r.mode,label:i,backgroundColor:a,body:o}},htmlBuilder:(e,t)=>{var n=nG(jG(e.body,t),t),r=e.label.slice(1),i=t.sizeMultiplier,a,o,s=HH(e.body);if(r===`sout`)a=X([`katex-stretchy`,`katex-sout`]),a.height=t.fontMetrics().defaultRuleThickness/i,o=-.5*t.fontMetrics().xHeight;else if(r===`phase`){var c=NU({number:.6,unit:`pt`},t),l=NU({number:.35,unit:`ex`},t),u=t.havingBaseSizing();i/=u.sizeMultiplier;var d=n.height+n.depth+c+l;n.style.paddingLeft=z(d/2+c);var f=Math.floor(1e3*d*i);a=QW([`hide-tail`],[new GU([new KU(`phase`,SU(f))],{width:`400em`,height:z(f/1e3),viewBox:`0 0 400000 `+f,preserveAspectRatio:`xMinYMin slice`})],t),a.style.height=z(d),o=n.depth+c+l}else{/cancel/.test(r)?s||n.classes.push(`cancel-pad`):r===`angl`?n.classes.push(`anglpad`):n.classes.push(`boxpad`);var p,m,h=0;/box/.test(r)?(h=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness),p=t.fontMetrics().fboxsep+(r===`colorbox`?0:h),m=p):r===`angl`?(h=Math.max(t.fontMetrics().defaultRuleThickness,t.minRuleThickness),p=4*h,m=Math.max(0,.25-n.depth)):(p=s?.2:0,m=p),a=sK(n,r,p,m,t),/fbox|boxed|fcolorbox/.test(r)?(a.style.borderStyle=`solid`,a.style.borderWidth=z(h)):r===`angl`&&h!==.049&&(a.style.borderTopWidth=z(h),a.style.borderRightWidth=z(h)),o=n.depth+m,e.backgroundColor&&(a.style.backgroundColor=e.backgroundColor,e.borderColor&&(a.style.borderColor=e.borderColor))}var g;if(e.backgroundColor)g=iG({positionType:`individualShift`,children:[{type:`elem`,elem:a,shift:o},{type:`elem`,elem:n,shift:0}]});else{var _=/cancel|phase/.test(r)?[`svg-align`]:[];g=iG({positionType:`individualShift`,children:[{type:`elem`,elem:n,shift:0},{type:`elem`,elem:a,shift:o,wrapperClasses:_}]})}return/cancel/.test(r)&&(g.height=n.height,g.depth=n.depth),/cancel/.test(r)&&!s?X([`mord`,`cancel-lap`],[g],t):X([`mord`],[g],t)},mathmlBuilder:(e,t)=>{var n,r=new Q(e.label.includes(`colorbox`)?`mpadded`:`menclose`,[KG(e.body,t)]);switch(e.label){case`\\cancel`:r.setAttribute(`notation`,`updiagonalstrike`);break;case`\\bcancel`:r.setAttribute(`notation`,`downdiagonalstrike`);break;case`\\phase`:r.setAttribute(`notation`,`phasorangle`);break;case`\\sout`:r.setAttribute(`notation`,`horizontalstrike`);break;case`\\fbox`:r.setAttribute(`notation`,`box`);break;case`\\angl`:r.setAttribute(`notation`,`actuarial`);break;case`\\fcolorbox`:case`\\colorbox`:if(n=t.fontMetrics().fboxsep*t.fontMetrics().ptPerEm,r.setAttribute(`width`,`+`+2*n+`pt`),r.setAttribute(`height`,`+`+2*n+`pt`),r.setAttribute(`lspace`,n+`pt`),r.setAttribute(`voffset`,n+`pt`),e.label===`\\fcolorbox`){var i=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness);r.setAttribute(`style`,`border: `+z(i)+` solid `+e.borderColor)}break;case`\\xcancel`:r.setAttribute(`notation`,`updiagonalstrike downdiagonalstrike`)}return e.backgroundColor&&r.setAttribute(`mathbackground`,e.backgroundColor),r}}),Z({type:`enclose`,names:[`\\fcolorbox`],numArgs:3,allowedInText:!0,argTypes:[`color`,`color`,`hbox`],handler(e,t,n){var r=e.parser,i=e.funcName,a=pK(t[0],`color-token`).color,o=pK(t[1],`color-token`).color,s=t[2];return{type:`enclose`,mode:r.mode,label:i,backgroundColor:o,borderColor:a,body:s}}}),Z({type:`enclose`,names:[`\\fbox`],numArgs:1,argTypes:[`hbox`],allowedInText:!0,handler(e,t){return{type:`enclose`,mode:e.parser.mode,label:`\\fbox`,body:t[0]}}}),Z({type:`enclose`,names:[`\\cancel`,`\\bcancel`,`\\xcancel`,`\\phase`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`enclose`,mode:n.mode,label:r,body:i}}}),Z({type:`enclose`,names:[`\\sout`],numArgs:1,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName;n.mode===`math`&&n.settings.reportNonstrict(`mathVsSout`,`LaTeX's \\sout works only in text mode`);var i=t[0];return{type:`enclose`,mode:n.mode,label:r,body:i}}}),Z({type:`enclose`,names:[`\\angl`],numArgs:1,argTypes:[`hbox`],allowedInText:!1,handler(e,t){return{type:`enclose`,mode:e.parser.mode,label:`\\angl`,body:t[0]}}});var hq={};function gq(e){for(var t=e.type,n=e.names,r=e.props,i=e.handler,a=e.htmlBuilder,o=e.mathmlBuilder,s={type:t,numArgs:r.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:i},c=0;c{if(!e.parser.settings.displayMode)throw new L(`{`+e.envName+`} can be used only in display mode.`)},Sq=new Set([`gather`,`gather*`]);function Cq(e){if(!e.includes(`ed`))return!e.includes(`*`)}function wq(e,t,n){var r=t.hskipBeforeAndAfter,i=t.addJot,a=t.cols,o=t.arraystretch,s=t.colSeparationType,c=t.autoTag,l=t.singleRow,u=t.emptySingleRow,d=t.maxNumCols,f=t.leqno;if(e.gullet.beginGroup(),l||e.gullet.macros.set(`\\cr`,`\\\\\\relax`),!o){var p=e.gullet.expandMacroAsText(`\\arraystretch`);if(p==null)o=1;else if(o=parseFloat(p),!o||o<0)throw new L(`Invalid \\arraystretch: `+p)}e.gullet.beginGroup();var m=[],h=[m],g=[],_=[],v=c==null?void 0:[];function y(){c&&e.gullet.macros.set(`\\@eqnsw`,`1`,!0)}function b(){v&&(e.gullet.macros.get(`\\df@tag`)?(v.push(e.subparse([new yq(`\\df@tag`)])),e.gullet.macros.set(`\\df@tag`,void 0,!0)):v.push(!!c&&e.gullet.macros.get(`\\@eqnsw`)===`1`))}for(y(),_.push(bq(e));;){var x=e.parseExpression(!1,l?`\\end`:`\\\\`);e.gullet.endGroup(),e.gullet.beginGroup();var S={type:`ordgroup`,mode:e.mode,body:x};n&&(S={type:`styling`,mode:e.mode,style:n,resetFont:!0,body:[S]}),m.push(S);var C=e.fetch().text;if(C===`&`){if(d&&m.length===d){if(l||s)throw new L(`Too many tab characters: &`,e.nextToken);e.settings.reportNonstrict(`textEnv`,`Too few columns specified in the {array} column argument.`)}e.consume()}else if(C===`\\end`){b(),m.length===1&&S.type===`styling`&&S.body.length===1&&S.body[0].type===`ordgroup`&&S.body[0].body.length===0&&(h.length>1||!u)&&!Array.isArray(v?.[v.length-1])&&!(c&&v?.[v.length-1]===!0)&&h.pop(),_.length0&&(_+=.25),c.push({pos:_,isDashed:e[t]})}for(v(a[0]),n=0;n0&&(te+=g,xe))for(n=0;n=o)){var ve=void 0;(r>0||e.hskipBeforeAndAfter)&&(ve=fe?.pregap??d,ve!==0&&(ae=X([`arraycolsep`],[]),ae.style.width=z(ve),ie.push(ae)));var ye=[];for(n=0;n0){for(var Ee=$W(`katex-hline`,t,l),De=$W(`katex-hdashline`,t,l),Oe=[{type:`elem`,elem:Te,shift:0}];c.length>0;){var ke=c.pop(),Ae=ke.pos-ne;ke.isDashed?Oe.push({type:`elem`,elem:De,shift:Ae}):Oe.push({type:`elem`,elem:Ee,shift:Ae})}Te=iG({positionType:`individualShift`,children:Oe})}if(se.length===0)return X([`mord`],[Te],t);var je=X([`katex-tag`],[iG({positionType:`individualShift`,children:se})],t);return tG([Te,je])},Dq={c:`center `,l:`left `,r:`right `},Oq=function(e,t){for(var n=[],r=new Q(`mtd`,[],[`mtr-glue`]),i=new Q(`mtd`,[],[`mml-eqn-num`]),a=0;a0){var p=e.cols,m=``,h=!1,g=0,_=p.length;p[0].type===`separator`&&(d+=`top `,g=1),p[p.length-1].type===`separator`&&(d+=`bottom `,--_);for(var v=g;v<_;v++){var y=p[v];y.type===`align`?(f+=Dq[y.align],h&&(m+=`none `),h=!0):y.type===`separator`&&(h&&=(m+=y.separator===`|`?`solid `:`dashed `,!1))}l.setAttribute(`columnalign`,f.trim()),/[sd]/.test(m)&&l.setAttribute(`columnlines`,m.trim())}if(e.colSeparationType===`align`){for(var b=e.cols||[],x=``,S=1;S0?`left `:``,d+=ee[ee.length-1].length>0?`right `:``;for(var te=1;te0&&u&&(p=1),n[d]={type:`align`,align:f,pregap:p,postgap:0}}return i.colSeparationType=u?`align`:`alignat`,i};gq({type:`array`,names:[`array`,`darray`],props:{numArgs:1},handler(e,t){var n=(hK(t[0])?[t[0]]:pK(t[0],`ordgroup`).body).map(function(e){var t=mK(e).text;if(`lcr`.includes(t))return{type:`align`,align:t};if(t===`|`)return{type:`separator`,separator:`|`};if(t===`:`)return{type:`separator`,separator:`:`};throw new L(`Unknown column alignment: `+t,e)}),r={cols:n,hskipBeforeAndAfter:!0,maxNumCols:n.length};return wq(e.parser,r,Tq(e.envName))},htmlBuilder:Eq,mathmlBuilder:Oq}),gq({type:`array`,names:[`matrix`,`pmatrix`,`bmatrix`,`Bmatrix`,`vmatrix`,`Vmatrix`,`matrix*`,`pmatrix*`,`bmatrix*`,`Bmatrix*`,`vmatrix*`,`Vmatrix*`],props:{numArgs:0},handler(e){var t={matrix:null,pmatrix:[`(`,`)`],bmatrix:[`[`,`]`],Bmatrix:[`\\{`,`\\}`],vmatrix:[`|`,`|`],Vmatrix:[`\\Vert`,`\\Vert`]}[e.envName.replace(`*`,``)],n=`c`,r={hskipBeforeAndAfter:!1,cols:[{type:`align`,align:n}]};if(e.envName.charAt(e.envName.length-1)===`*`){var i=e.parser;if(i.consumeSpaces(),i.fetch().text===`[`){if(i.consume(),i.consumeSpaces(),n=i.fetch().text,!`lcr`.includes(n))throw new L(`Expected l or c or r`,i.nextToken);i.consume(),i.consumeSpaces(),i.expect(`]`),i.consume(),r.cols=[{type:`align`,align:n}]}}var a=wq(e.parser,r,Tq(e.envName)),o=Math.max(0,...a.body.map(e=>e.length));return a.cols=Array(o).fill({type:`align`,align:n}),t?{type:`leftright`,mode:e.mode,body:[a],left:t[0],right:t[1],rightColor:void 0}:a},htmlBuilder:Eq,mathmlBuilder:Oq}),gq({type:`array`,names:[`smallmatrix`],props:{numArgs:0},handler(e){var t=wq(e.parser,{arraystretch:.5},`script`);return t.colSeparationType=`small`,t},htmlBuilder:Eq,mathmlBuilder:Oq}),gq({type:`array`,names:[`subarray`],props:{numArgs:1},handler(e,t){var n=(hK(t[0])?[t[0]]:pK(t[0],`ordgroup`).body).map(function(e){var t=mK(e).text;if(`lc`.includes(t))return{type:`align`,align:t};throw new L(`Unknown column alignment: `+t,e)});if(n.length>1)throw new L(`{subarray} can contain only one column`);var r={cols:n,hskipBeforeAndAfter:!1,arraystretch:.5},i=wq(e.parser,r,`script`);if(i.body.length>0&&i.body[0].length>1)throw new L(`{subarray} can contain only one column`);return i},htmlBuilder:Eq,mathmlBuilder:Oq}),gq({type:`array`,names:[`cases`,`dcases`,`rcases`,`drcases`],props:{numArgs:0},handler(e){var t=wq(e.parser,{arraystretch:1.2,cols:[{type:`align`,align:`l`,pregap:0,postgap:1},{type:`align`,align:`l`,pregap:0,postgap:0}]},Tq(e.envName));return{type:`leftright`,mode:e.mode,body:[t],left:e.envName.includes(`r`)?`.`:`\\{`,right:e.envName.includes(`r`)?`\\}`:`.`,rightColor:void 0}},htmlBuilder:Eq,mathmlBuilder:Oq}),gq({type:`array`,names:[`align`,`align*`,`aligned`,`split`],props:{numArgs:0},handler:kq,htmlBuilder:Eq,mathmlBuilder:Oq}),gq({type:`array`,names:[`gathered`,`gather`,`gather*`],props:{numArgs:0},handler(e){Sq.has(e.envName)&&xq(e);var t={cols:[{type:`align`,align:`c`}],addJot:!0,colSeparationType:`gather`,autoTag:Cq(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return wq(e.parser,t,`display`)},htmlBuilder:Eq,mathmlBuilder:Oq}),gq({type:`array`,names:[`alignat`,`alignat*`,`alignedat`],props:{numArgs:1},handler:kq,htmlBuilder:Eq,mathmlBuilder:Oq}),gq({type:`array`,names:[`equation`,`equation*`],props:{numArgs:0},handler(e){xq(e);var t={autoTag:Cq(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:e.parser.settings.leqno};return wq(e.parser,t,`display`)},htmlBuilder:Eq,mathmlBuilder:Oq}),gq({type:`array`,names:[`CD`],props:{numArgs:0},handler(e){return xq(e),AK(e.parser)},htmlBuilder:Eq,mathmlBuilder:Oq}),$(`\\nonumber`,`\\gdef\\@eqnsw{0}`),$(`\\notag`,`\\nonumber`),Z({type:`text`,names:[`\\hline`,`\\hdashline`],numArgs:0,allowedInText:!0,allowedInMath:!0,handler(e,t){throw new L(e.funcName+` valid only within array environment`)}});var Aq=hq;Z({type:`environment`,names:[`\\begin`,`\\end`],numArgs:1,argTypes:[`text`],handler(e,t){var n=e.parser,r=e.funcName,i=t[0];if(i.type!==`ordgroup`)throw new L(`Invalid environment name`,i);var a=gK(i,`Environment name should contain only text characters and spaces`,!0);if(r===`\\begin`){if(!Object.prototype.hasOwnProperty.call(Aq,a))throw new L(`No such environment: `+a,i);var o=Aq[a],s=n.parseArguments(`\\begin{`+a+`}`,o),c=s.args,l=s.optArgs,u={mode:n.mode,envName:a,parser:n},d=o.handler(u,c,l);n.expect(`\\end`,!1);var f=n.nextToken,p=pK(n.parseFunction(),`environment`);if(p.name!==a)throw new L(`Mismatch: \\begin{`+a+`} matched by \\end{`+p.name+`}`,f);return d}return{type:`environment`,mode:n.mode,name:a,nameGroup:i}}});var jq=(e,t)=>{var n=e.font,r=t.withFont(n);return jG(e.body,r)},Mq=(e,t)=>{var n=e.font,r=t.withFont(n);return KG(e.body,r)},Nq={"\\Bbb":`\\mathbb`,"\\bold":`\\mathbf`,"\\frak":`\\mathfrak`};Z({type:`font`,names:[`\\mathrm`,`\\mathit`,`\\mathbf`,`\\mathnormal`,`\\mathsfit`,`\\mathbb`,`\\mathcal`,`\\mathfrak`,`\\mathscr`,`\\mathsf`,`\\mathtt`,`\\Bbb`,`\\bold`,`\\frak`],numArgs:1,allowedInArgument:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=yG(t[0]),a=r in Nq?Nq[r]:r;return{type:`font`,mode:n.mode,font:a.slice(1),body:i}},htmlBuilder:jq,mathmlBuilder:Mq}),Z({type:`mclass`,names:[`\\boldsymbol`,`\\bm`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`mclass`,mode:n.mode,mclass:wK(r),body:[{type:`font`,mode:n.mode,font:`boldsymbol`,body:r}],isCharacterBox:HH(r)}}}),Z({type:`font`,names:[`\\rm`,`\\sf`,`\\tt`,`\\bf`,`\\it`,`\\cal`],numArgs:0,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=e.breakOnTokenText,a=n.mode,o=n.parseExpression(!0,i);return{type:`font`,mode:a,font:`math`+r.slice(1),body:{type:`ordgroup`,mode:n.mode,body:o}}}});var Pq=(e,t)=>{var n=t.style,r=n.fracNum(),i=n.fracDen(),a=t.havingStyle(r),o=jG(e.numer,a,t);if(e.continued){var s=8.5/t.fontMetrics().ptPerEm,c=3.5/t.fontMetrics().ptPerEm;o.height=o.height0?3*f:7*f,h=t.fontMetrics().denom1):(d>0?(p=t.fontMetrics().num2,m=f):(p=t.fontMetrics().num3,m=3*f),h=t.fontMetrics().denom2);var g;if(u){var _=t.fontMetrics().axisHeight;p-o.depth-(_+.5*d){var n=new Q(`mfrac`,[KG(e.numer,t),KG(e.denom,t)]);if(!e.hasBarLine)n.setAttribute(`linethickness`,`0px`);else if(e.barSize){var r=NU(e.barSize,t);n.setAttribute(`linethickness`,z(r))}if(e.leftDelim!=null||e.rightDelim!=null){var i=[];if(e.leftDelim!=null){var a=new Q(`mo`,[new FG(e.leftDelim.replace(`\\`,``))]);a.setAttribute(`fence`,`true`),i.push(a)}if(i.push(n),e.rightDelim!=null){var o=new Q(`mo`,[new FG(e.rightDelim.replace(`\\`,``))]);o.setAttribute(`fence`,`true`),i.push(o)}return BG(i)}return n},Iq=(e,t)=>t?{type:`styling`,mode:e.mode,style:t,body:[e]}:e;Z({type:`genfrac`,names:[`\\cfrac`,`\\dfrac`,`\\frac`,`\\tfrac`,`\\dbinom`,`\\binom`,`\\tbinom`,`\\\\atopfrac`,`\\\\bracefrac`,`\\\\brackfrac`],numArgs:2,allowedInArgument:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0],a=t[1],o,s=null,c=null;switch(r){case`\\cfrac`:case`\\dfrac`:case`\\frac`:case`\\tfrac`:o=!0;break;case`\\\\atopfrac`:o=!1;break;case`\\dbinom`:case`\\binom`:case`\\tbinom`:o=!1,s=`(`,c=`)`;break;case`\\\\bracefrac`:o=!1,s=`\\{`,c=`\\}`;break;case`\\\\brackfrac`:o=!1,s=`[`,c=`]`;break;default:throw Error(`Unrecognized genfrac command`)}var l=r===`\\cfrac`,u=null;return l||r.startsWith(`\\d`)?u=`display`:r.startsWith(`\\t`)&&(u=`text`),Iq({type:`genfrac`,mode:n.mode,numer:i,denom:a,continued:l,hasBarLine:o,leftDelim:s,rightDelim:c,barSize:null},u)},htmlBuilder:Pq,mathmlBuilder:Fq}),Z({type:`infix`,names:[`\\over`,`\\choose`,`\\atop`,`\\brace`,`\\brack`],numArgs:0,infix:!0,handler(e){var t=e.parser,n=e.funcName,r=e.token,i;switch(n){case`\\over`:i=`\\frac`;break;case`\\choose`:i=`\\binom`;break;case`\\atop`:i=`\\\\atopfrac`;break;case`\\brace`:i=`\\\\bracefrac`;break;case`\\brack`:i=`\\\\brackfrac`;break;default:throw Error(`Unrecognized infix genfrac command`)}return{type:`infix`,mode:t.mode,replaceWith:i,token:r}}});var Lq=[`display`,`text`,`script`,`scriptscript`],Rq=function(e){var t=null;return e.length>0&&(t=e,t=t===`.`?null:t),t};Z({type:`genfrac`,names:[`\\genfrac`],numArgs:6,allowedInArgument:!0,argTypes:[`math`,`math`,`size`,`text`,`math`,`math`],handler(e,t){var n=e.parser,r=t[4],i=t[5],a=yG(t[0]),o=a.type===`atom`&&a.family===`open`?Rq(a.text):null,s=yG(t[1]),c=s.type===`atom`&&s.family===`close`?Rq(s.text):null,l=pK(t[2],`size`),u,d=null;l.isBlank?u=!0:(d=l.value,u=d.number>0);var f=null,p=t[3];if(p.type===`ordgroup`){if(p.body.length>0){var m=pK(p.body[0],`textord`);f=Lq[Number(m.text)]}}else p=pK(p,`textord`),f=Lq[Number(p.text)];return Iq({type:`genfrac`,mode:n.mode,numer:r,denom:i,continued:!1,hasBarLine:u,barSize:d,leftDelim:o,rightDelim:c},f)}}),Z({type:`infix`,names:[`\\above`],numArgs:1,argTypes:[`size`],infix:!0,handler(e,t){var n=e.parser;e.funcName;var r=e.token;return{type:`infix`,mode:n.mode,replaceWith:`\\\\abovefrac`,size:pK(t[0],`size`).value,token:r}}}),Z({type:`genfrac`,names:[`\\\\abovefrac`],numArgs:3,argTypes:[`math`,`size`,`math`],handler:(e,t)=>{var n=e.parser;e.funcName;var r=t[0],i=pK(t[1],`infix`).size;if(!i)throw Error(`\\\\abovefrac expected size, but got `+String(i));var a=t[2],o=i.number>0;return{type:`genfrac`,mode:n.mode,numer:r,denom:a,continued:!1,hasBarLine:o,barSize:i,leftDelim:null,rightDelim:null}}});var zq=(e,t)=>{var n=t.style,r,i;e.type===`supsub`?(r=e.sup?jG(e.sup,t.havingStyle(n.sup()),t):jG(e.sub,t.havingStyle(n.sub()),t),i=pK(e.base,`horizBrace`)):i=pK(e,`horizBrace`);var a=jG(i.base,t.havingBaseStyle(R.DISPLAY)),o=oK(i,t),s=i.isOver?iG({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:.1},{type:`elem`,elem:o,wrapperClasses:[`svg-align`]}]}):iG({positionType:`bottom`,positionData:a.depth+.1+o.height,children:[{type:`elem`,elem:o,wrapperClasses:[`svg-align`]},{type:`kern`,size:.1},{type:`elem`,elem:a}]});if(r){var c=X([`minner`,i.isOver?`mover`:`munder`],[s],t);s=i.isOver?iG({positionType:`firstBaseline`,children:[{type:`elem`,elem:c},{type:`kern`,size:.2},{type:`elem`,elem:r}]}):iG({positionType:`bottom`,positionData:c.depth+.2+r.height+r.depth,children:[{type:`elem`,elem:r},{type:`kern`,size:.2},{type:`elem`,elem:c}]})}return X([`minner`,i.isOver?`mover`:`munder`],[s],t)};Z({type:`horizBrace`,names:[`\\overbrace`,`\\underbrace`,`\\overbracket`,`\\underbracket`],numArgs:1,handler(e,t){var n=e.parser,r=e.funcName;return{type:`horizBrace`,mode:n.mode,label:r,isOver:r.includes(`\\over`),base:t[0]}},htmlBuilder:zq,mathmlBuilder:(e,t)=>{var n=rK(e.label);return new Q(e.isOver?`mover`:`munder`,[KG(e.base,t),n])}}),Z({type:`href`,names:[`\\href`],numArgs:2,argTypes:[`url`,`original`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[1],i=pK(t[0],`url`).url;return n.settings.isTrusted({command:`\\href`,url:i})?{type:`href`,mode:n.mode,href:i,body:bG(r)}:n.formatUnsupportedCmd(`\\href`)},htmlBuilder:(e,t)=>{var n=TG(e.body,t,!1);return eG(e.href,[],n,t)},mathmlBuilder:(e,t)=>{var n=GG(e.body,t);return n instanceof Q||(n=new Q(`mrow`,[n])),n.setAttribute(`href`,e.href),n}}),Z({type:`href`,names:[`\\url`],numArgs:1,argTypes:[`url`],allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=pK(t[0],`url`).url;if(!n.settings.isTrusted({command:`\\url`,url:r}))return n.formatUnsupportedCmd(`\\url`);for(var i=[],a=0;a{var n=e.parser,r=e.funcName;e.token;var i=pK(t[0],`raw`).string,a=t[1];n.settings.strict&&n.settings.reportNonstrict(`htmlExtension`,`HTML extension is disabled on strict mode`);var o,s={};switch(r){case`\\htmlClass`:s.class=i,o={command:`\\htmlClass`,class:i};break;case`\\htmlId`:s.id=i,o={command:`\\htmlId`,id:i};break;case`\\htmlStyle`:s.style=i,o={command:`\\htmlStyle`,style:i};break;case`\\htmlData`:for(var c=`{,}`,l=[],u=``,d=0;d{var n=TG(e.body,t,!1),r=[`enclosing`];e.attributes.class&&r.push(...e.attributes.class.trim().split(/\s+/));var i=X(r,n,t);for(var a of Object.entries(e.attributes)){var o=a[0],s=a[1];o!==`class`&&i.setAttribute(o,s)}return i},mathmlBuilder:(e,t)=>GG(e.body,t)}),Z({type:`htmlmathml`,names:[`\\html@mathml`],numArgs:2,allowedInArgument:!0,allowedInText:!0,handler:(e,t)=>({type:`htmlmathml`,mode:e.parser.mode,html:bG(t[0]),mathml:bG(t[1])}),htmlBuilder:(e,t)=>tG(TG(e.html,t,!1)),mathmlBuilder:(e,t)=>GG(e.mathml,t)});var Bq=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:`bp`};var t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new L(`Invalid size: '`+e+`' in \\includegraphics`);var n={number:+(t[1]+t[2]),unit:t[3]};if(!MU(n))throw new L(`Invalid unit: '`+n.unit+`' in \\includegraphics.`);return n};Z({type:`includegraphics`,names:[`\\includegraphics`],numArgs:1,numOptionalArgs:1,argTypes:[`raw`,`url`],allowedInText:!1,handler:(e,t,n)=>{var r=e.parser,i={number:0,unit:`em`},a={number:.9,unit:`em`},o={number:0,unit:`em`},s=``;if(n[0])for(var c=pK(n[0],`raw`).string.split(`,`),l=0;l{var n=NU(e.height,t),r=0;e.totalheight.number>0&&(r=NU(e.totalheight,t)-n);var i=0;e.width.number>0&&(i=NU(e.width,t));var a={height:z(n+r)};i>0&&(a.width=z(i)),r>0&&(a.verticalAlign=z(-r));var o=new HU(e.src,e.alt,a);return o.height=n,o.depth=r,o},mathmlBuilder:(e,t)=>{var n=new Q(`mglyph`,[]);n.setAttribute(`alt`,e.alt);var r=NU(e.height,t),i=0;if(e.totalheight.number>0&&(i=NU(e.totalheight,t)-r,n.setAttribute(`valign`,z(-i))),n.setAttribute(`height`,z(r+i)),e.width.number>0){var a=NU(e.width,t);n.setAttribute(`width`,z(a))}return n.setAttribute(`src`,e.src),n}}),Z({type:`kern`,names:[`\\kern`,`\\mkern`,`\\hskip`,`\\mskip`],numArgs:1,argTypes:[`size`],primitive:!0,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName,i=pK(t[0],`size`);if(n.settings.strict){var a=r[1]===`m`,o=i.value.unit===`mu`;a?(o||n.settings.reportNonstrict(`mathVsTextUnits`,`LaTeX's `+r+` supports only mu units, `+(`not `+i.value.unit+` units`)),n.mode!==`math`&&n.settings.reportNonstrict(`mathVsTextUnits`,`LaTeX's `+r+` works only in math mode`)):o&&n.settings.reportNonstrict(`mathVsTextUnits`,`LaTeX's `+r+` doesn't support mu units`)}return{type:`kern`,mode:n.mode,dimension:i.value}},htmlBuilder(e,t){return aG(e.dimension,t)},mathmlBuilder(e,t){return new IG(NU(e.dimension,t))}}),Z({type:`lap`,names:[`\\mathllap`,`\\mathrlap`,`\\mathclap`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`lap`,mode:n.mode,alignment:r.slice(5),body:i}},htmlBuilder:(e,t)=>{var n;e.alignment===`clap`?(n=X([],[jG(e.body,t)]),n=X([`katex-inner`],[n],t)):n=X([`katex-inner`],[jG(e.body,t)]);var r=X([`katex-fix`],[]),i=X([e.alignment],[n,r],t),a=X([`katex-strut`]);return a.style.height=z(i.height+i.depth),i.depth&&(a.style.verticalAlign=z(-i.depth)),i.children.unshift(a),i=X([`katex-thinbox`],[i],t),X([`mord`,`katex-vbox`],[i],t)},mathmlBuilder:(e,t)=>{var n=new Q(`mpadded`,[KG(e.body,t)]);if(e.alignment!==`rlap`){var r=e.alignment===`llap`?`-1`:`-0.5`;n.setAttribute(`lspace`,r+`width`)}return n.setAttribute(`width`,`0px`),n}}),Z({type:`styling`,names:[`\\(`,`$`],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){var n=e.funcName,r=e.parser,i=r.mode;r.switchMode(`math`);var a=n===`\\(`?`\\)`:`$`,o=r.parseExpression(!1,a);return r.expect(a),r.switchMode(i),{type:`styling`,mode:r.mode,style:`text`,resetFont:!0,body:o}}}),Z({type:`text`,names:[`\\)`,`\\]`],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){throw new L(`Mismatched `+e.funcName)}});var Vq=(e,t)=>{switch(t.style.size){case R.DISPLAY.size:return e.display;case R.TEXT.size:return e.text;case R.SCRIPT.size:return e.script;case R.SCRIPTSCRIPT.size:return e.scriptscript;default:return e.text}};Z({type:`mathchoice`,names:[`\\mathchoice`],numArgs:4,primitive:!0,handler:(e,t)=>({type:`mathchoice`,mode:e.parser.mode,display:bG(t[0]),text:bG(t[1]),script:bG(t[2]),scriptscript:bG(t[3])}),htmlBuilder:(e,t)=>tG(TG(Vq(e,t),t,!1)),mathmlBuilder:(e,t)=>GG(Vq(e,t),t)});var Hq=(e,t,n,r,i,a,o)=>{e=X([],[e]);var s=n&&HH(n),c,l;if(t){var u=jG(t,r.havingStyle(i.sup()),r);l={elem:u,kern:Math.max(r.fontMetrics().bigOpSpacing1,r.fontMetrics().bigOpSpacing3-u.depth)}}if(n){var d=jG(n,r.havingStyle(i.sub()),r);c={elem:d,kern:Math.max(r.fontMetrics().bigOpSpacing2,r.fontMetrics().bigOpSpacing4-d.height)}}var f;if(l&&c)f=iG({positionType:`bottom`,positionData:r.fontMetrics().bigOpSpacing5+c.elem.height+c.elem.depth+c.kern+e.depth+o,children:[{type:`kern`,size:r.fontMetrics().bigOpSpacing5},{type:`elem`,elem:c.elem,marginLeft:z(-a)},{type:`kern`,size:c.kern},{type:`elem`,elem:e},{type:`kern`,size:l.kern},{type:`elem`,elem:l.elem,marginLeft:z(a)},{type:`kern`,size:r.fontMetrics().bigOpSpacing5}]});else if(c)f=iG({positionType:`top`,positionData:e.height-o,children:[{type:`kern`,size:r.fontMetrics().bigOpSpacing5},{type:`elem`,elem:c.elem,marginLeft:z(-a)},{type:`kern`,size:c.kern},{type:`elem`,elem:e}]});else if(l)f=iG({positionType:`bottom`,positionData:e.depth+o,children:[{type:`elem`,elem:e},{type:`kern`,size:l.kern},{type:`elem`,elem:l.elem,marginLeft:z(a)},{type:`kern`,size:r.fontMetrics().bigOpSpacing5}]});else return e;var p=[f];if(c&&a!==0&&!s){var m=X([`mspace`],[],r);m.style.marginRight=z(a),p.unshift(m)}return X([`mop`,`op-limits`],p,r)},Uq=new Set([`\\smallint`]),Wq=(e,t)=>{var n,r,i=!1,a;e.type===`supsub`?(n=e.sup,r=e.sub,a=pK(e.base,`op`),i=!0):a=pK(e,`op`);var o=t.style,s=!1;o.size===R.DISPLAY.size&&a.symbol&&!Uq.has(a.name)&&(s=!0);var c,l;if(a.symbol){var u=s?`Size2-Regular`:`Size1-Regular`,d=``;if((a.name===`\\oiint`||a.name===`\\oiiint`)&&(d=a.name.slice(1),a.name=d===`oiint`?`\\iint`:`\\iiint`),c=GW(a.name,u,`math`,t,[`mop`,`op-symbol`,s?`large-op`:`small-op`]),l=c.italic,d.length>0){var f=lG(d+`Size`+(s?`2`:`1`),t);c=iG({positionType:`individualShift`,children:[{type:`elem`,elem:c,shift:0},{type:`elem`,elem:f,shift:s?.08:0}]}),a.name=`\\`+d,c.classes.unshift(`mop`),c.italic=l}}else if(a.body){var p=TG(a.body,t,!0);p.length===1&&p[0]instanceof WU?(c=p[0],c.classes[0]=`mop`):c=X([`mop`],p,t)}else{for(var m=[],h=1;h{var n;if(e.symbol)n=new Q(`mo`,[zG(e.name,e.mode)]),Uq.has(e.name)&&n.setAttribute(`largeop`,`false`);else if(e.body)n=new Q(`mo`,WG(e.body,t));else{n=new Q(`mi`,[new FG(e.name.slice(1))]);var r=new Q(`mo`,[zG(`⁡`,`text`)]);n=e.parentIsSupSub?new Q(`mrow`,[n,r]):PG([n,r])}return n},Kq={"∏":`\\prod`,"∐":`\\coprod`,"∑":`\\sum`,"⋀":`\\bigwedge`,"⋁":`\\bigvee`,"⋂":`\\bigcap`,"⋃":`\\bigcup`,"⨀":`\\bigodot`,"⨁":`\\bigoplus`,"⨂":`\\bigotimes`,"⨄":`\\biguplus`,"⨆":`\\bigsqcup`};Z({type:`op`,names:`\\coprod.\\bigvee.\\bigwedge.\\biguplus.\\bigcap.\\bigcup.\\intop.\\prod.\\sum.\\bigotimes.\\bigoplus.\\bigodot.\\bigsqcup.\\smallint.∏.∐.∑.⋀.⋁.⋂.⋃.⨀.⨁.⨂.⨄.⨆`.split(`.`),numArgs:0,handler:(e,t)=>{var n=e.parser,r=e.funcName;return r.length===1&&(r=Kq[r]),{type:`op`,mode:n.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:r}},htmlBuilder:Wq,mathmlBuilder:Gq}),Z({type:`op`,names:[`\\mathop`],numArgs:1,primitive:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`op`,mode:n.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:bG(r)}}});var qq={"∫":`\\int`,"∬":`\\iint`,"∭":`\\iiint`,"∮":`\\oint`,"∯":`\\oiint`,"∰":`\\oiiint`};Z({type:`op`,names:`\\arcsin.\\arccos.\\arctan.\\arctg.\\arcctg.\\arg.\\ch.\\cos.\\cosec.\\cosh.\\cot.\\cotg.\\coth.\\csc.\\ctg.\\cth.\\deg.\\dim.\\exp.\\hom.\\ker.\\lg.\\ln.\\log.\\sec.\\sin.\\sinh.\\sh.\\tan.\\tanh.\\tg.\\th`.split(`.`),numArgs:0,handler(e){var t=e.parser,n=e.funcName;return{type:`op`,mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:n}}}),Z({type:`op`,names:[`\\det`,`\\gcd`,`\\inf`,`\\lim`,`\\max`,`\\min`,`\\Pr`,`\\sup`],numArgs:0,handler(e){var t=e.parser,n=e.funcName;return{type:`op`,mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:n}}}),Z({type:`op`,names:[`\\int`,`\\iint`,`\\iiint`,`\\oint`,`\\oiint`,`\\oiiint`,`∫`,`∬`,`∭`,`∮`,`∯`,`∰`],numArgs:0,allowedInArgument:!0,handler(e){var t=e.parser,n=e.funcName;return n.length===1&&(n=qq[n]),{type:`op`,mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}}});var Jq=(e,t)=>{var n,r,i=!1,a;e.type===`supsub`?(n=e.sup,r=e.sub,a=pK(e.base,`operatorname`),i=!0):a=pK(e,`operatorname`);var o;if(a.body.length>0){for(var s=TG(a.body.map(e=>{var t=`text`in e?e.text:void 0;return typeof t==`string`?{type:`textord`,mode:e.mode,text:t}:e}),t.withFont(`mathrm`),!0),c=0;c{var n=e.parser,r=e.funcName,i=t[0];return{type:`operatorname`,mode:n.mode,body:bG(i),alwaysHandleSupSub:r===`\\operatornamewithlimits`,limits:!1,parentIsSupSub:!1}},htmlBuilder:Jq,mathmlBuilder:(e,t)=>{for(var n=WG(e.body,t.withFont(`mathrm`)),r=!0,i=0;ie.toText()).join(``))]);var s=new Q(`mi`,n);s.setAttribute(`mathvariant`,`normal`);var c=new Q(`mo`,[zG(`⁡`,`text`)]);return e.parentIsSupSub?new Q(`mrow`,[s,c]):PG([s,c])}}),$(`\\operatorname`,`\\@ifstar\\operatornamewithlimits\\operatorname@`),vG({type:`ordgroup`,htmlBuilder(e,t){return e.semisimple?tG(TG(e.body,t,!1)):X([`mord`],TG(e.body,t,!0),t)},mathmlBuilder(e,t){return GG(e.body,t,!0)}}),Z({type:`overline`,names:[`\\overline`],numArgs:1,handler(e,t){var n=e.parser,r=t[0];return{type:`overline`,mode:n.mode,body:r}},htmlBuilder(e,t){var n=jG(e.body,t.havingCrampedStyle()),r=$W(`overline-line`,t),i=t.fontMetrics().defaultRuleThickness;return X([`mord`,`katex-overline`],[iG({positionType:`firstBaseline`,children:[{type:`elem`,elem:n},{type:`kern`,size:3*i},{type:`elem`,elem:r},{type:`kern`,size:i}]})],t)},mathmlBuilder(e,t){var n=new Q(`mo`,[new FG(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new Q(`mover`,[KG(e.body,t),n]);return r.setAttribute(`accent`,`true`),r}}),Z({type:`phantom`,names:[`\\phantom`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`phantom`,mode:n.mode,body:bG(r)}},htmlBuilder:(e,t)=>tG(TG(e.body,t.withPhantom(),!1)),mathmlBuilder:(e,t)=>new Q(`mphantom`,WG(e.body,t))}),$(`\\hphantom`,`\\smash{\\phantom{#1}}`),Z({type:`vphantom`,names:[`\\vphantom`],numArgs:1,allowedInText:!0,handler:(e,t)=>{var n=e.parser,r=t[0];return{type:`vphantom`,mode:n.mode,body:r}},htmlBuilder:(e,t)=>X([`mord`,`rlap`],[X([`katex-inner`],[jG(e.body,t.withPhantom())]),X([`katex-fix`],[])],t),mathmlBuilder:(e,t)=>{var n=new Q(`mpadded`,[new Q(`mphantom`,WG(bG(e.body),t))]);return n.setAttribute(`width`,`0px`),n}}),Z({type:`raisebox`,names:[`\\raisebox`],numArgs:2,argTypes:[`size`,`hbox`],allowedInText:!0,handler(e,t){var n=e.parser,r=pK(t[0],`size`).value,i=t[1];return{type:`raisebox`,mode:n.mode,dy:r,body:i}},htmlBuilder(e,t){var n=jG(e.body,t);return iG({positionType:`shift`,positionData:-NU(e.dy,t),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){var n=new Q(`mpadded`,[KG(e.body,t)]),r=e.dy.number+e.dy.unit;return n.setAttribute(`voffset`,r),n}});var Yq=(e,t)=>({type:`reflectbox`,mode:e.parser.mode,body:t[0]});Z({type:`reflectbox`,names:[`\\reflectbox`],numArgs:1,argTypes:[`hbox`],allowedInText:!0,handler:Yq,htmlBuilder(e,t){return X([`mord`,`reflectbox`],[jG(e.body,t)],t)},mathmlBuilder(e,t){return KG(e.body,t)}}),Z({type:`reflectbox`,names:[`\\mathreflectbox`],numArgs:1,argTypes:[`math`],handler:Yq}),Z({type:`internal`,names:[`\\relax`],numArgs:0,allowedInText:!0,allowedInArgument:!0,handler(e){return{type:`internal`,mode:e.parser.mode}}}),Z({type:`rule`,names:[`\\rule`],numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`size`,`size`,`size`],handler(e,t,n){var r=e.parser,i=n[0],a=pK(t[0],`size`),o=pK(t[1],`size`);return{type:`rule`,mode:r.mode,shift:i&&pK(i,`size`).value,width:a.value,height:o.value}},htmlBuilder(e,t){var n=X([`mord`,`katex-rule`],[],t),r=NU(e.width,t),i=NU(e.height,t),a=e.shift?NU(e.shift,t):0;return n.style.borderRightWidth=z(r),n.style.borderTopWidth=z(i),n.style.bottom=z(a),n.width=r,n.height=i+a,n.depth=-a,n.maxFontSize=i*1.125*t.sizeMultiplier,n},mathmlBuilder(e,t){var n=NU(e.width,t),r=NU(e.height,t),i=e.shift?NU(e.shift,t):0,a=t.color&&t.getColor()||`black`,o=new Q(`mspace`);o.setAttribute(`mathbackground`,a),o.setAttribute(`width`,z(n)),o.setAttribute(`height`,z(r));var s=new Q(`mpadded`,[o]);return i>=0?s.setAttribute(`height`,z(i)):(s.setAttribute(`height`,z(i)),s.setAttribute(`depth`,z(-i))),s.setAttribute(`voffset`,z(i)),s}});function Xq(e,t,n){for(var r=TG(e,t,!1),i=t.sizeMultiplier/n.sizeMultiplier,a=0;a{var n=e.breakOnTokenText,r=e.funcName,i=e.parser,a=i.parseExpression(!1,n);return{type:`sizing`,mode:i.mode,size:Zq.indexOf(r)+1,body:a}},htmlBuilder:(e,t)=>{var n=t.havingSize(e.size);return Xq(e.body,n,t)},mathmlBuilder:(e,t)=>{var n=t.havingSize(e.size),r=new Q(`mstyle`,WG(e.body,n));return r.setAttribute(`mathsize`,z(n.sizeMultiplier)),r}}),Z({type:`smash`,names:[`\\smash`],numArgs:1,numOptionalArgs:1,allowedInText:!0,handler:(e,t,n)=>{var r=e.parser,i=!1,a=!1,o=n[0]&&pK(n[0],`ordgroup`);if(o)for(var s,c=0;c{var n=X([],[jG(e.body,t)]);if(!e.smashHeight&&!e.smashDepth)return n;if(e.smashHeight&&(n.height=0),e.smashDepth&&(n.depth=0),e.smashHeight&&e.smashDepth)return X([`mord`,`katex-smash`],[n],t);if(n.children)for(var r=0;r{var n=new Q(`mpadded`,[KG(e.body,t)]);return e.smashHeight&&n.setAttribute(`height`,`0px`),e.smashDepth&&n.setAttribute(`depth`,`0px`),n}}),Z({type:`sqrt`,names:[`\\sqrt`],numArgs:1,numOptionalArgs:1,handler(e,t,n){var r=e.parser,i=n[0],a=t[0];return{type:`sqrt`,mode:r.mode,body:a,index:i}},htmlBuilder(e,t){var n=jG(e.body,t.havingCrampedStyle());n.height===0&&(n.height=t.fontMetrics().xHeight),n=nG(n,t);var r=t.fontMetrics().defaultRuleThickness,i=r;t.style.idn.height+n.depth+a&&(a=(a+u-n.height-n.depth)/2);var d=s.height-n.height-a-c;n.style.paddingLeft=z(l);var f=iG({positionType:`firstBaseline`,children:[{type:`elem`,elem:n,wrapperClasses:[`svg-align`]},{type:`kern`,size:-(n.height+d)},{type:`elem`,elem:s},{type:`kern`,size:c}]});if(e.index){var p=t.havingStyle(R.SCRIPTSCRIPT),m=jG(e.index,p,t);return X([`mord`,`sqrt`],[X([`katex-root`],[iG({positionType:`shift`,positionData:-(.6*(f.height-f.depth)),children:[{type:`elem`,elem:m}]})]),f],t)}return X([`mord`,`sqrt`],[f],t)},mathmlBuilder(e,t){var n=e.body,r=e.index;return r?new Q(`mroot`,[KG(n,t),KG(r,t)]):new Q(`msqrt`,[KG(n,t)])}});var Qq={display:R.DISPLAY,text:R.TEXT,script:R.SCRIPT,scriptscript:R.SCRIPTSCRIPT};function $q(e){return e in Qq}Z({type:`styling`,names:[`\\displaystyle`,`\\textstyle`,`\\scriptstyle`,`\\scriptscriptstyle`],numArgs:0,allowedInText:!0,primitive:!0,handler(e,t){var n=e.breakOnTokenText,r=e.funcName,i=e.parser,a=i.parseExpression(!0,n),o=r.slice(1,r.length-5);if(!$q(o))throw Error(`Unknown style: `+o);return{type:`styling`,mode:i.mode,style:o,body:a}},htmlBuilder(e,t){var n=Qq[e.style],r=t.havingStyle(n);return e.resetFont&&(r=r.withFont(``)),Xq(e.body,r,t)},mathmlBuilder(e,t){var n=Qq[e.style],r=t.havingStyle(n);e.resetFont&&(r=r.withFont(``));var i=new Q(`mstyle`,WG(e.body,r)),a={display:[`0`,`true`],text:[`0`,`false`],script:[`1`,`false`],scriptscript:[`2`,`false`]}[e.style];return i.setAttribute(`scriptlevel`,a[0]),i.setAttribute(`displaystyle`,a[1]),i}});var eJ=function(e,t){var n=e.base;return n?n.type===`op`?n.limits&&(t.style.size===R.DISPLAY.size||n.alwaysHandleSupSub)?Wq:null:n.type===`operatorname`?n.alwaysHandleSupSub&&(t.style.size===R.DISPLAY.size||n.limits)?Jq:null:n.type===`accent`?HH(n.base)?vK:null:n.type===`horizBrace`&&!e.sub===n.isOver?zq:null:null};vG({type:`supsub`,htmlBuilder(e,t){var n=eJ(e,t);if(n)return n(e,t);var r=e.base,i=e.sup,a=e.sub,o=jG(r,t),s,c,l=t.fontMetrics(),u=0,d=0,f=r&&HH(r);if(i){var p=t.havingStyle(t.style.sup());s=jG(i,p,t),f||(u=o.height-p.fontMetrics().supDrop*p.sizeMultiplier/t.sizeMultiplier)}if(a){var m=t.havingStyle(t.style.sub());c=jG(a,m,t),f||(d=o.depth+m.fontMetrics().subDrop*m.sizeMultiplier/t.sizeMultiplier)}var h=t.style===R.DISPLAY?l.sup1:t.style.cramped?l.sup3:l.sup2,g=t.sizeMultiplier,_=z(.5/l.ptPerEm/g),v=null;if(c){var y=e.base&&e.base.type===`op`&&e.base.name&&(e.base.name===`\\oiint`||e.base.name===`\\oiiint`);(o instanceof WU||y)&&(v=z(-(o.italic??0)))}var b;if(s&&c){u=Math.max(u,h,s.depth+.25*l.xHeight),d=Math.max(d,l.sub2);var x=4*l.defaultRuleThickness;if(u-s.depth-(c.height-d)0&&(u+=S,d-=S)}b=iG({positionType:`individualShift`,children:[{type:`elem`,elem:c,shift:d,marginRight:_,marginLeft:v},{type:`elem`,elem:s,shift:-u,marginRight:_}]})}else if(c)d=Math.max(d,l.sub1,c.height-.8*l.xHeight),b=iG({positionType:`shift`,positionData:d,children:[{type:`elem`,elem:c,marginLeft:v,marginRight:_}]});else if(s)u=Math.max(u,h,s.depth+.25*l.xHeight),b=iG({positionType:`shift`,positionData:-u,children:[{type:`elem`,elem:s,marginRight:_}]});else throw Error(`supsub must have either sup or sub.`);return X([kG(o,`right`)||`mord`],[o,X([`msupsub`],[b])],t)},mathmlBuilder(e,t){var n=!1,r,i;e.base&&e.base.type===`horizBrace`&&(i=!!e.sup,i===e.base.isOver&&(n=!0,r=e.base.isOver)),e.base&&(e.base.type===`op`||e.base.type===`operatorname`)&&(e.base.parentIsSupSub=!0);var a=[KG(e.base,t)];e.sub&&a.push(KG(e.sub,t)),e.sup&&a.push(KG(e.sup,t));var o;if(n)o=r?`mover`:`munder`;else if(!e.sub){var s=e.base;o=s&&s.type===`op`&&s.limits&&(t.style===R.DISPLAY||s.alwaysHandleSupSub)||s&&s.type===`operatorname`&&s.alwaysHandleSupSub&&(s.limits||t.style===R.DISPLAY)?`mover`:`msup`}else if(e.sup){var c=e.base;o=c&&c.type===`op`&&c.limits&&t.style===R.DISPLAY||c&&c.type===`operatorname`&&c.alwaysHandleSupSub&&(t.style===R.DISPLAY||c.limits)?`munderover`:`msubsup`}else{var l=e.base;o=l&&l.type===`op`&&l.limits&&(t.style===R.DISPLAY||l.alwaysHandleSupSub)||l&&l.type===`operatorname`&&l.alwaysHandleSupSub&&(l.limits||t.style===R.DISPLAY)?`munder`:`msub`}return new Q(o,a)}}),vG({type:`atom`,htmlBuilder(e,t){return KW(e.text,e.mode,t,[`m`+e.family])},mathmlBuilder(e,t){var n=new Q(`mo`,[zG(e.text,e.mode)]);if(e.family===`bin`){var r=HG(e,t);r===`bold-italic`&&n.setAttribute(`mathvariant`,r)}else e.family===`punct`?n.setAttribute(`separator`,`true`):(e.family===`open`||e.family===`close`)&&n.setAttribute(`stretchy`,`false`);return n}});var tJ={mi:`italic`,mn:`normal`,mtext:`normal`};vG({type:`mathord`,htmlBuilder(e,t){return JW(e,t)},mathmlBuilder(e,t){var n=new Q(`mi`,[zG(e.text,e.mode,t)]),r=HG(e,t)||`italic`;return r!==tJ[n.type]&&n.setAttribute(`mathvariant`,r),n}}),vG({type:`textord`,htmlBuilder(e,t){return JW(e,t)},mathmlBuilder(e,t){var n=zG(e.text,e.mode,t),r=HG(e,t)||`normal`,i=e.mode===`text`?new Q(`mtext`,[n]):/[0-9]/.test(e.text)?new Q(`mn`,[n]):e.text===`\\prime`?new Q(`mo`,[n]):new Q(`mi`,[n]);return r!==tJ[i.type]&&i.setAttribute(`mathvariant`,r),i}});var nJ=new Map([[`\\nobreak`,`nobreak`],[`\\allowbreak`,`allowbreak`]]),rJ=new Map([[` `,{}],[`\\ `,{}],[`~`,{className:`nobreak`}],[`\\space`,{}],[`\\nobreakspace`,{className:`nobreak`}]]);vG({type:`spacing`,htmlBuilder(e,t){var n=rJ.get(e.text),r=nJ.get(e.text);if(n){var i=n.className||``;if(e.mode===`text`){var a=JW(e,t);return a.classes.push(i),a}return X([`mspace`,i],[KW(e.text,e.mode,t)],t)}if(r)return X([`mspace`,r],[],t);throw new L(`Unknown type of space "`+e.text+`"`)},mathmlBuilder(e,t){var n;if(rJ.has(e.text))n=new Q(`mtext`,[new FG(`\xA0`)]);else if(nJ.has(e.text))return new Q(`mspace`);else throw new L(`Unknown type of space "`+e.text+`"`);return n}});var iJ=()=>{var e=new Q(`mtd`,[]);return e.setAttribute(`width`,`50%`),e};vG({type:`tag`,mathmlBuilder(e,t){var n=new Q(`mtable`,[new Q(`mtr`,[iJ(),new Q(`mtd`,[GG(e.body,t)]),iJ(),new Q(`mtd`,[GG(e.tag,t)])])]);return n.setAttribute(`width`,`100%`),n}});var aJ={"\\text":void 0,"\\textrm":`textrm`,"\\textsf":`textsf`,"\\texttt":`texttt`,"\\textnormal":`textrm`},oJ={"\\textbf":`textbf`,"\\textmd":`textmd`},sJ={"\\textit":`textit`,"\\textup":`textup`},cJ=(e,t)=>{var n=e.font;return n?aJ[n]?t.withTextFontFamily(aJ[n]):oJ[n]?t.withTextFontWeight(oJ[n]):n===`\\emph`?t.fontShape===`textit`?t.withTextFontShape(`textup`):t.withTextFontShape(`textit`):t.withTextFontShape(sJ[n]):t};Z({type:`text`,names:[`\\text`,`\\textrm`,`\\textsf`,`\\texttt`,`\\textnormal`,`\\textbf`,`\\textmd`,`\\textit`,`\\textup`,`\\emph`],numArgs:1,argTypes:[`text`],allowedInArgument:!0,allowedInText:!0,handler(e,t){var n=e.parser,r=e.funcName,i=t[0];return{type:`text`,mode:n.mode,body:bG(i),font:r}},htmlBuilder(e,t){var n=cJ(e,t);return X([`mord`,`text`],TG(e.body,n,!0),n)},mathmlBuilder(e,t){var n=cJ(e,t);return GG(e.body,n)}}),Z({type:`underline`,names:[`\\underline`],numArgs:1,allowedInText:!0,handler(e,t){return{type:`underline`,mode:e.parser.mode,body:t[0]}},htmlBuilder(e,t){var n=jG(e.body,t),r=$W(`underline-line`,t),i=t.fontMetrics().defaultRuleThickness;return X([`mord`,`katex-underline`],[iG({positionType:`top`,positionData:n.height,children:[{type:`kern`,size:i},{type:`elem`,elem:r},{type:`kern`,size:3*i},{type:`elem`,elem:n}]})],t)},mathmlBuilder(e,t){var n=new Q(`mo`,[new FG(`‾`)]);n.setAttribute(`stretchy`,`true`);var r=new Q(`munder`,[KG(e.body,t),n]);return r.setAttribute(`accentunder`,`true`),r}}),Z({type:`vcenter`,names:[`\\vcenter`],numArgs:1,argTypes:[`original`],allowedInText:!1,handler(e,t){return{type:`vcenter`,mode:e.parser.mode,body:t[0]}},htmlBuilder(e,t){var n=jG(e.body,t),r=t.fontMetrics().axisHeight;return iG({positionType:`shift`,positionData:.5*(n.height-r-(n.depth+r)),children:[{type:`elem`,elem:n}]})},mathmlBuilder(e,t){return new Q(`mrow`,[new Q(`mpadded`,[KG(e.body,t)],[`vcenter`])])}}),Z({type:`verb`,names:[`\\verb`],numArgs:0,allowedInText:!0,handler(e,t,n){throw new L(`\\verb ended by end of line instead of matching delimiter`)},htmlBuilder(e,t){for(var n=lJ(e),r=[],i=t.havingStyle(t.style.text()),a=0;ae.body.replace(/ /g,e.star?`␣`:`\xA0`),uJ=hG,dJ=`[ \r + ]`,fJ=`\\\\[a-zA-Z@]+`,pJ=`\\\\[^\ud800-\udfff]`,mJ=`(`+fJ+`)`+dJ+`*`,hJ=`\\\\( |[ \r ]+ -?)[ \r ]*`,lJ=`[̀-ͯ]`,uJ=RegExp(lJ+`+$`),dJ=`(`+iJ+`+)|`+(cJ+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(lJ+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(lJ+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+sJ)+(`|`+oJ+`)`),fJ=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(dJ,`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 fq(`EOF`,new dq(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new L(`Unexpected character: '`+e[t]+`'`,new fq(e[t],new dq(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 fq(r,new dq(this,t,this.tokenRegex.lastIndex))}},pJ=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;r0&&(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}},mJ=uq;$(`\\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 hJ={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=hJ[t.text],r==null||r>=n)throw new L(`Invalid base-`+n+` digit `+t.text);for(var i;(i=hJ[e.future().text])!=null&&i{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=>gJ(e,!1,!0,!1)),$(`\\renewcommand`,e=>gJ(e,!0,!1,!1)),$(`\\providecommand`,e=>gJ(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),rJ[n],ZU.math[n],ZU.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{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),$(`\\ne`,`\\neq`),$(`≠`,`\\neq`),$(`\\notin`,"\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),$(`∉`,`\\notin`),$(`≘`,"\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),$(`≙`,"\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),$(`≚`,"\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),$(`≛`,"\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),$(`≝`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),$(`≞`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),$(`≟`,"\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),$(`⟂`,`\\perp`),$(`‼`,`\\mathclose{!\\mkern-0.8mu!}`),$(`∌`,`\\notni`),$(`⌜`,`\\ulcorner`),$(`⌝`,`\\urcorner`),$(`⌞`,`\\llcorner`),$(`⌟`,`\\lrcorner`),$(`©`,`\\copyright`),$(`®`,`\\textregistered`),$(`\\ulcorner`,`\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}`),$(`\\urcorner`,`\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}`),$(`\\llcorner`,`\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}`),$(`\\lrcorner`,`\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}`),$(`\\vdots`,`{\\varvdots\\rule{0pt}{15pt}}`),$(`⋮`,`\\vdots`),$(`\\varGamma`,`\\mathit{\\Gamma}`),$(`\\varDelta`,`\\mathit{\\Delta}`),$(`\\varTheta`,`\\mathit{\\Theta}`),$(`\\varLambda`,`\\mathit{\\Lambda}`),$(`\\varXi`,`\\mathit{\\Xi}`),$(`\\varPi`,`\\mathit{\\Pi}`),$(`\\varSigma`,`\\mathit{\\Sigma}`),$(`\\varUpsilon`,`\\mathit{\\Upsilon}`),$(`\\varPhi`,`\\mathit{\\Phi}`),$(`\\varPsi`,`\\mathit{\\Psi}`),$(`\\varOmega`,`\\mathit{\\Omega}`),$(`\\substack`,`\\begin{subarray}{c}#1\\end{subarray}`),$(`\\colon`,`\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax`),$(`\\boxed`,`\\fbox{$\\displaystyle{#1}$}`),$(`\\iff`,`\\DOTSB\\;\\Longleftrightarrow\\;`),$(`\\implies`,`\\DOTSB\\;\\Longrightarrow\\;`),$(`\\impliedby`,`\\DOTSB\\;\\Longleftarrow\\;`),$(`\\dddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}`),$(`\\ddddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}`);var _J={",":`\\dotsc`,"\\not":`\\dotsb`,"+":`\\dotsb`,"=":`\\dotsb`,"<":`\\dotsb`,">":`\\dotsb`,"-":`\\dotsb`,"*":`\\dotsb`,":":`\\dotsb`,"\\DOTSB":`\\dotsb`,"\\coprod":`\\dotsb`,"\\bigvee":`\\dotsb`,"\\bigwedge":`\\dotsb`,"\\biguplus":`\\dotsb`,"\\bigcap":`\\dotsb`,"\\bigcup":`\\dotsb`,"\\prod":`\\dotsb`,"\\sum":`\\dotsb`,"\\bigotimes":`\\dotsb`,"\\bigoplus":`\\dotsb`,"\\bigodot":`\\dotsb`,"\\bigsqcup":`\\dotsb`,"\\And":`\\dotsb`,"\\longrightarrow":`\\dotsb`,"\\Longrightarrow":`\\dotsb`,"\\longleftarrow":`\\dotsb`,"\\Longleftarrow":`\\dotsb`,"\\longleftrightarrow":`\\dotsb`,"\\Longleftrightarrow":`\\dotsb`,"\\mapsto":`\\dotsb`,"\\longmapsto":`\\dotsb`,"\\hookrightarrow":`\\dotsb`,"\\doteq":`\\dotsb`,"\\mathbin":`\\dotsb`,"\\mathrel":`\\dotsb`,"\\relbar":`\\dotsb`,"\\Relbar":`\\dotsb`,"\\xrightarrow":`\\dotsb`,"\\xleftarrow":`\\dotsb`,"\\DOTSI":`\\dotsi`,"\\int":`\\dotsi`,"\\oint":`\\dotsi`,"\\iint":`\\dotsi`,"\\iiint":`\\dotsi`,"\\iiiint":`\\dotsi`,"\\idotsint":`\\dotsi`,"\\DOTSX":`\\dotsx`},vJ=new Set([`bin`,`rel`]);$(`\\dots`,function(e){var t=`\\dotso`,n=e.expandAfterFuture().text;return n in _J?t=_J[n]:(n.slice(0,4)===`\\not`||n in ZU.math&&vJ.has(ZU.math[n].group))&&(t=`\\dotsb`),t});var yJ={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};$(`\\dotso`,function(e){return e.future().text in yJ?`\\ldots\\,`:`\\ldots`}),$(`\\dotsc`,function(e){var t=e.future().text;return t in yJ&&t!==`,`?`\\ldots\\,`:`\\ldots`}),$(`\\cdots`,function(e){return e.future().text in yJ?`\\@cdots\\,`:`\\@cdots`}),$(`\\dotsb`,`\\cdots`),$(`\\dotsm`,`\\cdots`),$(`\\dotsi`,`\\!\\cdots`),$(`\\dotsx`,`\\ldots\\,`),$(`\\DOTSI`,`\\relax`),$(`\\DOTSB`,`\\relax`),$(`\\DOTSX`,`\\relax`),$(`\\tmspace`,`\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax`),$(`\\,`,`\\tmspace+{3mu}{.1667em}`),$(`\\thinspace`,`\\,`),$(`\\>`,`\\mskip{4mu}`),$(`\\:`,`\\tmspace+{4mu}{.2222em}`),$(`\\medspace`,`\\:`),$(`\\;`,`\\tmspace+{5mu}{.2777em}`),$(`\\thickspace`,`\\;`),$(`\\!`,`\\tmspace-{3mu}{.1667em}`),$(`\\negthinspace`,`\\!`),$(`\\negmedspace`,`\\tmspace-{4mu}{.2222em}`),$(`\\negthickspace`,`\\tmspace-{5mu}{.277em}`),$(`\\enspace`,`\\kern.5em `),$(`\\enskip`,`\\hskip.5em\\relax`),$(`\\quad`,`\\hskip1em\\relax`),$(`\\qquad`,`\\hskip2em\\relax`),$(`\\tag`,`\\@ifstar\\tag@literal\\tag@paren`),$(`\\tag@paren`,`\\tag@literal{({#1})}`),$(`\\tag@literal`,e=>{if(e.macros.get(`\\df@tag`))throw new L(`Multiple \\tag`);return`\\gdef\\df@tag{\\text{#1}}`}),$(`\\bmod`,`\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}`),$(`\\pod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)`),$(`\\pmod`,`\\pod{{\\rm mod}\\mkern6mu#1}`),$(`\\mod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1`),$(`\\newline`,`\\\\\\relax`),$(`\\TeX`,`\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}`);var bJ=z(WU[`Main-Regular`][84][1]-.7*WU[`Main-Regular`][65][1]);$(`\\LaTeX`,`\\textrm{\\html@mathml{`+(`L\\kern-.36em\\raisebox{`+bJ+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{LaTeX}}`),$(`\\KaTeX`,`\\textrm{\\html@mathml{`+(`K\\kern-.17em\\raisebox{`+bJ+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{KaTeX}}`),$(`\\hspace`,`\\@ifstar\\@hspacer\\@hspace`),$(`\\@hspace`,`\\hskip #1\\relax`),$(`\\@hspacer`,`\\rule{0pt}{0pt}\\hskip #1\\relax`),$(`\\ordinarycolon`,`:`),$(`\\vcentcolon`,`\\mathrel{\\mathop\\ordinarycolon}`),$(`\\dblcolon`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}`),$(`\\coloneqq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}`),$(`\\Coloneqq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}`),$(`\\coloneq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}`),$(`\\Coloneq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}`),$(`\\eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}`),$(`\\Eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}`),$(`\\eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}`),$(`\\Eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}`),$(`\\colonapprox`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}`),$(`\\Colonapprox`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}`),$(`\\colonsim`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}`),$(`\\Colonsim`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}`),$(`∷`,`\\dblcolon`),$(`∹`,`\\eqcolon`),$(`≔`,`\\coloneqq`),$(`≕`,`\\eqqcolon`),$(`⩴`,`\\Coloneqq`),$(`\\ratio`,`\\vcentcolon`),$(`\\coloncolon`,`\\dblcolon`),$(`\\colonequals`,`\\coloneqq`),$(`\\coloncolonequals`,`\\Coloneqq`),$(`\\equalscolon`,`\\eqqcolon`),$(`\\equalscoloncolon`,`\\Eqqcolon`),$(`\\colonminus`,`\\coloneq`),$(`\\coloncolonminus`,`\\Coloneq`),$(`\\minuscolon`,`\\eqcolon`),$(`\\minuscoloncolon`,`\\Eqcolon`),$(`\\coloncolonapprox`,`\\Colonapprox`),$(`\\coloncolonsim`,`\\Colonsim`),$(`\\simcolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\simcoloncolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\approxcolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\approxcoloncolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\notni`,"\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),$(`\\limsup`,`\\DOTSB\\operatorname*{lim\\,sup}`),$(`\\liminf`,`\\DOTSB\\operatorname*{lim\\,inf}`),$(`\\injlim`,`\\DOTSB\\operatorname*{inj\\,lim}`),$(`\\projlim`,`\\DOTSB\\operatorname*{proj\\,lim}`),$(`\\varlimsup`,`\\DOTSB\\operatorname*{\\overline{lim}}`),$(`\\varliminf`,`\\DOTSB\\operatorname*{\\underline{lim}}`),$(`\\varinjlim`,`\\DOTSB\\operatorname*{\\underrightarrow{lim}}`),$(`\\varprojlim`,`\\DOTSB\\operatorname*{\\underleftarrow{lim}}`),$(`\\gvertneqq`,`\\html@mathml{\\@gvertneqq}{≩}`),$(`\\lvertneqq`,`\\html@mathml{\\@lvertneqq}{≨}`),$(`\\ngeqq`,`\\html@mathml{\\@ngeqq}{≱}`),$(`\\ngeqslant`,`\\html@mathml{\\@ngeqslant}{≱}`),$(`\\nleqq`,`\\html@mathml{\\@nleqq}{≰}`),$(`\\nleqslant`,`\\html@mathml{\\@nleqslant}{≰}`),$(`\\nshortmid`,`\\html@mathml{\\@nshortmid}{∤}`),$(`\\nshortparallel`,`\\html@mathml{\\@nshortparallel}{∦}`),$(`\\nsubseteqq`,`\\html@mathml{\\@nsubseteqq}{⊈}`),$(`\\nsupseteqq`,`\\html@mathml{\\@nsupseteqq}{⊉}`),$(`\\varsubsetneq`,`\\html@mathml{\\@varsubsetneq}{⊊}`),$(`\\varsubsetneqq`,`\\html@mathml{\\@varsubsetneqq}{⫋}`),$(`\\varsupsetneq`,`\\html@mathml{\\@varsupsetneq}{⊋}`),$(`\\varsupsetneqq`,`\\html@mathml{\\@varsupsetneqq}{⫌}`),$(`\\imath`,`\\html@mathml{\\@imath}{ı}`),$(`\\jmath`,`\\html@mathml{\\@jmath}{ȷ}`),$(`\\llbracket`,"\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),$(`\\rrbracket`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),$(`⟦`,`\\llbracket`),$(`⟧`,`\\rrbracket`),$(`\\lBrace`,"\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),$(`\\rBrace`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),$(`↤`,`\\mapsfrom`),$(`\\mapsfrom`,"\\html@mathml{\\mathrel{\\mathreflectbox{\\mapsto}}}{\\mathrel{\\char`↤}}"),$(`⦃`,`\\lBrace`),$(`⦄`,`\\rBrace`),$(`\\minuso`,"\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),$(`⦵`,`\\minuso`),$(`\\darr`,`\\downarrow`),$(`\\dArr`,`\\Downarrow`),$(`\\Darr`,`\\Downarrow`),$(`\\lang`,`\\langle`),$(`\\rang`,`\\rangle`),$(`\\uarr`,`\\uparrow`),$(`\\uArr`,`\\Uparrow`),$(`\\Uarr`,`\\Uparrow`),$(`\\N`,`\\mathbb{N}`),$(`\\R`,`\\mathbb{R}`),$(`\\Z`,`\\mathbb{Z}`),$(`\\alef`,`\\aleph`),$(`\\alefsym`,`\\aleph`),$(`\\Alpha`,`\\mathrm{A}`),$(`\\Beta`,`\\mathrm{B}`),$(`\\bull`,`\\bullet`),$(`\\Chi`,`\\mathrm{X}`),$(`\\clubs`,`\\clubsuit`),$(`\\cnums`,`\\mathbb{C}`),$(`\\Complex`,`\\mathbb{C}`),$(`\\Dagger`,`\\ddagger`),$(`\\diamonds`,`\\diamondsuit`),$(`\\empty`,`\\emptyset`),$(`\\Epsilon`,`\\mathrm{E}`),$(`\\Eta`,`\\mathrm{H}`),$(`\\exist`,`\\exists`),$(`\\harr`,`\\leftrightarrow`),$(`\\hArr`,`\\Leftrightarrow`),$(`\\Harr`,`\\Leftrightarrow`),$(`\\hearts`,`\\heartsuit`),$(`\\image`,`\\Im`),$(`\\infin`,`\\infty`),$(`\\Iota`,`\\mathrm{I}`),$(`\\isin`,`\\in`),$(`\\Kappa`,`\\mathrm{K}`),$(`\\larr`,`\\leftarrow`),$(`\\lArr`,`\\Leftarrow`),$(`\\Larr`,`\\Leftarrow`),$(`\\lrarr`,`\\leftrightarrow`),$(`\\lrArr`,`\\Leftrightarrow`),$(`\\Lrarr`,`\\Leftrightarrow`),$(`\\Mu`,`\\mathrm{M}`),$(`\\natnums`,`\\mathbb{N}`),$(`\\Nu`,`\\mathrm{N}`),$(`\\Omicron`,`\\mathrm{O}`),$(`\\plusmn`,`\\pm`),$(`\\rarr`,`\\rightarrow`),$(`\\rArr`,`\\Rightarrow`),$(`\\Rarr`,`\\Rightarrow`),$(`\\real`,`\\Re`),$(`\\reals`,`\\mathbb{R}`),$(`\\Reals`,`\\mathbb{R}`),$(`\\Rho`,`\\mathrm{P}`),$(`\\sdot`,`\\cdot`),$(`\\sect`,`\\S`),$(`\\spades`,`\\spadesuit`),$(`\\sub`,`\\subset`),$(`\\sube`,`\\subseteq`),$(`\\supe`,`\\supseteq`),$(`\\Tau`,`\\mathrm{T}`),$(`\\thetasym`,`\\vartheta`),$(`\\weierp`,`\\wp`),$(`\\Zeta`,`\\mathrm{Z}`),$(`\\argmin`,`\\DOTSB\\operatorname*{arg\\,min}`),$(`\\argmax`,`\\DOTSB\\operatorname*{arg\\,max}`),$(`\\plim`,`\\DOTSB\\mathop{\\operatorname{plim}}\\limits`),$(`\\bra`,`\\mathinner{\\langle{#1}|}`),$(`\\ket`,`\\mathinner{|{#1}\\rangle}`),$(`\\braket`,`\\mathinner{\\langle{#1}\\rangle}`),$(`\\Bra`,`\\left\\langle#1\\right|`),$(`\\Ket`,`\\left|#1\\right\\rangle`);var xJ=e=>t=>{var n=t.consumeArg().tokens,r=t.consumeArg().tokens,i=t.consumeArg().tokens,a=t.consumeArg().tokens,o=t.macros.get(`|`),s=t.macros.get(`\\|`);t.macros.beginGroup();var c=t=>n=>{e&&(n.macros.set(`|`,o),i.length&&n.macros.set(`\\|`,s));var a=t;return!t&&i.length&&n.future().text===`|`&&(n.popToken(),a=!0),{tokens:a?i:r,numArgs:0}};t.macros.set(`|`,c(!1)),i.length&&t.macros.set(`\\|`,c(!0));var l=t.consumeArg().tokens,u=t.expandTokens([...a,...l,...n]);return t.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};$(`\\bra@ket`,xJ(!1)),$(`\\bra@set`,xJ(!0)),$(`\\Braket`,`\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}`),$(`\\Set`,`\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}`),$(`\\set`,`\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}`),$(`\\angln`,`{\\angl n}`),$(`\\blue`,`\\textcolor{##6495ed}{#1}`),$(`\\orange`,`\\textcolor{##ffa500}{#1}`),$(`\\pink`,`\\textcolor{##ff00af}{#1}`),$(`\\red`,`\\textcolor{##df0030}{#1}`),$(`\\green`,`\\textcolor{##28ae7b}{#1}`),$(`\\gray`,`\\textcolor{gray}{#1}`),$(`\\purple`,`\\textcolor{##9d38bd}{#1}`),$(`\\blueA`,`\\textcolor{##ccfaff}{#1}`),$(`\\blueB`,`\\textcolor{##80f6ff}{#1}`),$(`\\blueC`,`\\textcolor{##63d9ea}{#1}`),$(`\\blueD`,`\\textcolor{##11accd}{#1}`),$(`\\blueE`,`\\textcolor{##0c7f99}{#1}`),$(`\\tealA`,`\\textcolor{##94fff5}{#1}`),$(`\\tealB`,`\\textcolor{##26edd5}{#1}`),$(`\\tealC`,`\\textcolor{##01d1c1}{#1}`),$(`\\tealD`,`\\textcolor{##01a995}{#1}`),$(`\\tealE`,`\\textcolor{##208170}{#1}`),$(`\\greenA`,`\\textcolor{##b6ffb0}{#1}`),$(`\\greenB`,`\\textcolor{##8af281}{#1}`),$(`\\greenC`,`\\textcolor{##74cf70}{#1}`),$(`\\greenD`,`\\textcolor{##1fab54}{#1}`),$(`\\greenE`,`\\textcolor{##0d923f}{#1}`),$(`\\goldA`,`\\textcolor{##ffd0a9}{#1}`),$(`\\goldB`,`\\textcolor{##ffbb71}{#1}`),$(`\\goldC`,`\\textcolor{##ff9c39}{#1}`),$(`\\goldD`,`\\textcolor{##e07d10}{#1}`),$(`\\goldE`,`\\textcolor{##a75a05}{#1}`),$(`\\redA`,`\\textcolor{##fca9a9}{#1}`),$(`\\redB`,`\\textcolor{##ff8482}{#1}`),$(`\\redC`,`\\textcolor{##f9685d}{#1}`),$(`\\redD`,`\\textcolor{##e84d39}{#1}`),$(`\\redE`,`\\textcolor{##bc2612}{#1}`),$(`\\maroonA`,`\\textcolor{##ffbde0}{#1}`),$(`\\maroonB`,`\\textcolor{##ff92c6}{#1}`),$(`\\maroonC`,`\\textcolor{##ed5fa6}{#1}`),$(`\\maroonD`,`\\textcolor{##ca337c}{#1}`),$(`\\maroonE`,`\\textcolor{##9e034e}{#1}`),$(`\\purpleA`,`\\textcolor{##ddd7ff}{#1}`),$(`\\purpleB`,`\\textcolor{##c6b9fc}{#1}`),$(`\\purpleC`,`\\textcolor{##aa87ff}{#1}`),$(`\\purpleD`,`\\textcolor{##7854ab}{#1}`),$(`\\purpleE`,`\\textcolor{##543b78}{#1}`),$(`\\mintA`,`\\textcolor{##f5f9e8}{#1}`),$(`\\mintB`,`\\textcolor{##edf2df}{#1}`),$(`\\mintC`,`\\textcolor{##e0e5cc}{#1}`),$(`\\grayA`,`\\textcolor{##f6f7f7}{#1}`),$(`\\grayB`,`\\textcolor{##f0f1f2}{#1}`),$(`\\grayC`,`\\textcolor{##e3e5e6}{#1}`),$(`\\grayD`,`\\textcolor{##d6d8da}{#1}`),$(`\\grayE`,`\\textcolor{##babec2}{#1}`),$(`\\grayF`,`\\textcolor{##888d93}{#1}`),$(`\\grayG`,`\\textcolor{##626569}{#1}`),$(`\\grayH`,`\\textcolor{##3b3e40}{#1}`),$(`\\grayI`,`\\textcolor{##21242c}{#1}`),$(`\\kaBlue`,`\\textcolor{##314453}{#1}`),$(`\\kaGreen`,`\\textcolor{##71B307}{#1}`);var SJ={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},CJ=class{constructor(e,t,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new pJ(mJ,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new fJ(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,r;if(e){if(this.consumeSpaces(),this.future().text!==`[`)return null;t=this.popToken();var i=this.consumeArg([`]`]);r=i.tokens,n=i.end}else{var a=this.consumeArg();r=a.tokens,t=a.start,n=a.end}return this.pushToken(new fq(`EOF`,n.loc)),this.pushTokens(r),new fq(``,dq.range(t,n))}consumeSpaces(){for(;this.future().text===` `;)this.stack.pop()}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var r=this.future(),i,a=0,o=0;do{if(i=this.popToken(),t.push(i),i.text===`{`)++a;else if(i.text===`}`){if(--a,a===-1)throw new L(`Extra }`,i)}else if(i.text===`EOF`)throw new L(`Unexpected end of input in a macro argument, expected '`+(e&&n?e[o]:`}`)+`'`,i);if(e&&n){if((a===0||a===1&&e[o]===`{`)&&i.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}}while(a!==0||n);return r.text===`{`&&t[t.length-1].text===`}`&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:r,end:i}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new L(`The length of delimiters doesn't match the number of args!`);for(var n=t[0],r=0;rthis.settings.maxExpand)throw new L(`Too many expansions: infinite loop or need to increase maxExpand setting`)}expandOnce(e){var t=this.popToken(),n=t.text,r=t.noexpand?null:this._getExpansion(n);if(r==null||e&&r.unexpandable){if(e&&r==null&&n[0]===`\\`&&!this.isDefined(n))throw new L(`Undefined control sequence: `+n);return this.pushToken(t),!1}this.countExpansion(1);var i=r.tokens,a=this.consumeArgs(r.numArgs,r.delimiters);if(r.numArgs){i=i.slice();for(var o=i.length-1;o>=0;--o){var s=i[o];if(s.text===`#`){if(o===0)throw new L(`Incomplete placeholder at end of macro body`,s);if(s=i[--o],s.text===`#`)i.splice(o+1,1);else if(/^[1-9]$/.test(s.text))i.splice(o,2,...a[s.text-1]);else throw new L(`Not a valid argument number`,s)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text=`\\relax`),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new fq(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var r=this.stack.pop();r.treatAsRelax&&=(r.noexpand=!1,!1),t.push(r)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(e=>e.text).join(``)}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var r=typeof t==`function`?t(this):t;if(typeof r==`string`){var i=0;if(r.includes(`#`))for(var a=r.replace(/##/g,``);a.includes(`#`+(i+1));)++i;for(var o=new fJ(r,this.settings),s=[],c=o.lex();c.text!==`EOF`;)s.push(c),c=o.lex();return s.reverse(),{tokens:s,numArgs:i}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(rJ,e)||Object.prototype.hasOwnProperty.call(ZU.math,e)||Object.prototype.hasOwnProperty.call(ZU.text,e)||Object.prototype.hasOwnProperty.call(SJ,e)}isExpandable(e){var t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(rJ,e)&&!rJ[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},wJ=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,TJ=Object.freeze({"₊":`+`,"₋":`-`,"₌":`=`,"₍":`(`,"₎":`)`,"₀":`0`,"₁":`1`,"₂":`2`,"₃":`3`,"₄":`4`,"₅":`5`,"₆":`6`,"₇":`7`,"₈":`8`,"₉":`9`,ₐ:`a`,ₑ:`e`,ₕ:`h`,ᵢ:`i`,ⱼ:`j`,ₖ:`k`,ₗ:`l`,ₘ:`m`,ₙ:`n`,ₒ:`o`,ₚ:`p`,ᵣ:`r`,ₛ:`s`,ₜ:`t`,ᵤ:`u`,ᵥ:`v`,ₓ:`x`,ᵦ:`β`,ᵧ:`γ`,ᵨ:`ρ`,ᵩ:`ϕ`,ᵪ:`χ`,"⁺":`+`,"⁻":`-`,"⁼":`=`,"⁽":`(`,"⁾":`)`,"⁰":`0`,"¹":`1`,"²":`2`,"³":`3`,"⁴":`4`,"⁵":`5`,"⁶":`6`,"⁷":`7`,"⁸":`8`,"⁹":`9`,ᴬ:`A`,ᴮ:`B`,ᴰ:`D`,ᴱ:`E`,ᴳ:`G`,ᴴ:`H`,ᴵ:`I`,ᴶ:`J`,ᴷ:`K`,ᴸ:`L`,ᴹ:`M`,ᴺ:`N`,ᴼ:`O`,ᴾ:`P`,ᴿ:`R`,ᵀ:`T`,ᵁ:`U`,ⱽ:`V`,ᵂ:`W`,ᵃ:`a`,ᵇ:`b`,ᶜ:`c`,ᵈ:`d`,ᵉ:`e`,ᶠ:`f`,ᵍ:`g`,ʰ:`h`,ⁱ:`i`,ʲ:`j`,ᵏ:`k`,ˡ:`l`,ᵐ:`m`,ⁿ:`n`,ᵒ:`o`,ᵖ:`p`,ʳ:`r`,ˢ:`s`,ᵗ:`t`,ᵘ:`u`,ᵛ:`v`,ʷ:`w`,ˣ:`x`,ʸ:`y`,ᶻ:`z`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),EJ={"́":{text:`\\'`,math:`\\acute`},"̀":{text:"\\`",math:`\\grave`},"̈":{text:`\\"`,math:`\\ddot`},"̃":{text:`\\~`,math:`\\tilde`},"̄":{text:`\\=`,math:`\\bar`},"̆":{text:`\\u`,math:`\\breve`},"̌":{text:`\\v`,math:`\\check`},"̂":{text:`\\^`,math:`\\hat`},"̇":{text:`\\.`,math:`\\dot`},"̊":{text:`\\r`,math:`\\mathring`},"̋":{text:`\\H`},"̧":{text:`\\c`}},DJ={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,ḉ:`ḉ`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ç:`ç`,ď:`ď`,ḋ:`ḋ`,ḑ:`ḑ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ḝ:`ḝ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ȩ:`ȩ`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ģ:`ģ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,ḩ:`ḩ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ķ:`ķ`,ĺ:`ĺ`,ľ:`ľ`,ļ:`ļ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ņ:`ņ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ŗ:`ŗ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ş:`ş`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ţ:`ţ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Ḉ:`Ḉ`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ç:`Ç`,Ď:`Ď`,Ḋ:`Ḋ`,Ḑ:`Ḑ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ḝ:`Ḝ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ȩ:`Ȩ`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ģ:`Ģ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Ḩ:`Ḩ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ķ:`Ķ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ļ:`Ļ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ņ:`Ņ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ŗ:`Ŗ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ş:`Ş`,Ť:`Ť`,Ṫ:`Ṫ`,Ţ:`Ţ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},OJ=class e{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode=`math`,this.gullet=new CJ(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new L(`Expected '`+e+`', got '`+this.fetch().text+`'`,this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken??=this.gullet.expandNextToken(),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set(`\\color`,`\\textcolor`);try{var e=this.parseExpression(!1);return this.expect(`EOF`),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new fq(`}`)),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect(`}`),this.nextToken=t,n}parseExpression(t,n){for(var r=[];;){this.mode===`math`&&this.consumeSpaces();var i=this.fetch();if(e.endOfExpression.has(i.text)||n&&i.text===n||t&&rJ[i.text]&&rJ[i.text].infix)break;var a=this.parseAtom(n);if(!a)break;a.type!==`internal`&&r.push(a)}return this.mode===`text`&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){for(var t=-1,n,r=0;r=128)this.settings.strict&&(sU(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:dq.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;ce.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{FJ.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)}}}}}),LJ=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},RJ=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:LJ,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{FJ.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)}}}}}),zJ=Tp.create({name:`Mathematics`,addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[IJ.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),RJ.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}});function BJ(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;tH({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 zJ.configure({katexOptions:{throwOnError:!1,strict:!1,trust:!1},inlineOptions:{onClick:n(`inline`)},blockOptions:{onClick:n(`block`)}})}function VJ({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r=`@`}){return{editor:e,char:r,pluginKey:new Un,command:({editor:e,range:t,props:i})=>{var a,o;let s=e.view.state.selection.$to.nodeAfter;s!=null&&(a=s.text)!=null&&a.startsWith(` `)&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:n,attrs:{...i,mentionSuggestionChar:r}},{type:`text`,text:` `}]).run(),(o=e.view.dom.ownerDocument.defaultView)==null||(o=o.getSelection())==null||o.collapseToEnd()},allow:({state:e,range:t})=>{let r=e.doc.resolve(t.from),i=e.schema.nodes[n];return!!r.parent.type.contentMatch.matchType(i)},...t}}function HJ(e){return(e.options.suggestions.length?e.options.suggestions:[e.options.suggestion]).map(t=>VJ({editor:e.editor,overrideSuggestionOptions:t,extensionName:e.name,char:t.char}))}function UJ(e,t){let n=HJ(e);return n.find(e=>e.char===t)||(n.length?n[0]:null)}var WJ=Jp.create({name:`mention`,priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:e,suggestion:t}){return`${t?.char??`@`}${e.attrs.label??e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:t,suggestion:n}){return[`span`,A(this.HTMLAttributes,e.HTMLAttributes),`${n?.char??`@`}${t.attrs.label??t.attrs.id}`]},suggestions:[],suggestion:{}}},group:`inline`,inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute(`data-id`),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute(`data-label`),renderHTML:e=>e.label?{"data-label":e.label}:{}},mentionSuggestionChar:{default:`@`,parseHTML:e=>e.getAttribute(`data-mention-suggestion-char`),renderHTML:e=>({"data-mention-suggestion-char":e.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=UJ(this,e.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn(`renderLabel is deprecated use renderText and renderHTML instead`),[`span`,A({"data-type":this.name},this.options.HTMLAttributes,t),this.options.renderLabel({options:this.options,node:e,suggestion:n})];let r={...this.options};r.HTMLAttributes=A({"data-type":this.name},this.options.HTMLAttributes,t);let i=this.options.renderHTML({options:r,node:e,suggestion:n});return typeof i==`string`?[`span`,A({"data-type":this.name},this.options.HTMLAttributes,t),i]:i},...$f({nodeName:`mention`,name:`@`,selfClosing:!0,allowedAttributes:[`id`,`label`,{name:`mentionSuggestionChar`,skipIfDefault:`@`}],parseAttributes:e=>{let t={},n=/(?:^|\s)(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;r!==null;){let[,i,a,o]=r;t[i===`char`?`mentionSuggestionChar`:i]=a??o,r=n.exec(e)}return t},serializeAttributes:e=>Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e===`mentionSuggestionChar`?`char`:e}="${t}"`).join(` `)}),renderText({node:e}){let t={options:this.options,node:e,suggestion:UJ(this,e.attrs.mentionSuggestionChar)};return this.options.renderLabel===void 0?this.options.renderText(t):(console.warn(`renderLabel is deprecated use renderText and renderHTML instead`),this.options.renderLabel(t))},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1,{selection:r}=t,{empty:i,anchor:a}=r;if(!i)return!1;let o=new ce,s=0;return t.doc.nodesBetween(a-1,a,(e,t)=>{if(e.type.name===this.name)return n=!0,o=e,s=t,!1}),n&&e.insertText(this.options.deleteTriggerWithBackspace?``:o.attrs.mentionSuggestionChar,s,s+o.nodeSize),n})}},addProseMirrorPlugins(){return HJ(this).map(NV)}});function GJ(e,t){return WJ.configure({HTMLAttributes:{class:`dw-mention`},renderText:({node:e})=>`@${e.attrs.label??e.attrs.id}`,suggestion:{char:`@`,allow:()=>!!t,findSuggestionMatch:t=>{let n=yV({...t,allowSpaces:!0});return n&&mV(n.query,e)?n:yV({...t,allowSpaces:!1})},items:async({query:n})=>{if(!t)return[];let r=pV(n,e,!!t.me).map(e=>({date:e})),i=(await t.search(n).catch(()=>[])).map(e=>({person:e}));return n.trim()?[...r,...i].slice(0,8):[...i.slice(0,6),...r]},render:Uj({label:e.mentions,empty:e.noPeople,toItem:t=>`person`in t?{label:t.person.label,description:t.person.hint,icon:`at`}:{label:dV(t.date.date,e),description:t.date.remind?`${e.dates.remindMe} · ${fV(t.date.date,e)}`:fV(t.date.date,e),icon:t.date.remind?`bell`:`calendar`},pick:(e,n)=>{`person`in n?e.command({id:n.person.id,label:n.person.label}):_V(e.editor,e.range,n.date,t?.me)}})}})}var KJ=`flowchart LR - Idea --> Draft --> Review --> Published`,qJ=null;function JJ(e){return qJ??=e().then(e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:document.documentElement.classList.contains(`dark`)?`dark`:`neutral`,fontFamily:`inherit`}),e)),qJ}var YJ=0;async function XJ(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 JJ(r)).render(`dw-mermaid-${++YJ}`,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 ZJ=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=KJ)=>({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 XJ(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;tH({anchor:a,value:s,label:c.mermaid,multiline:!0,monospace:!0,labels:{done:c.done,cancel:c.cancel,remove:c.remove},onInput:e=>void XJ(o,e,r,i),onSave:n=>{t.chain().setNodeSelection(e).updateAttributes(`mermaid`,{code:n}).run(),XJ(o,n,r,i)},onRemove:()=>t.chain().setNodeSelection(e).deleteSelection().focus().run(),onCancel:()=>void XJ(o,s,r,i)})}),{dom:a,update:e=>e.type.name===`mermaid`&&(e.attrs.code!==s&&(s=String(e.attrs.code),XJ(o,s,r,i)),!0),ignoreMutation:()=>!0,stopEvent:()=>!1}}}});function QJ(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 $J(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().focus().deleteRange(r).run(),cH(t,e,a,n)}),o(`linkCard`,`link`,[`bookmark`,`preview`,`card`,`url`,`web`],(t,r)=>{t.chain().focus().deleteRange(r).run(),lH(t,e,a,n)})],c=e=>{let t=new Date;return sV(new Date(t.getFullYear(),t.getMonth(),t.getDate()+e))};if(s.push(o(`today`,`calendar`,[`date`,`day`],(e,t)=>_V(e,t,{date:c(0),remind:!1})),o(`tomorrow`,`calendar`,[`date`,`day`],(e,t)=>_V(e,t,{date:c(1),remind:!1})),o(`yesterday`,`calendar`,[`date`,`day`],(e,t)=>_V(e,t,{date:c(-1),remind:!1})),o(`now`,`clock`,[`time`,`date`,`timestamp`],(t,n)=>{_V(t,n,{date:c(0),remind:!1});let r=new Intl.DateTimeFormat(e.locale,{hour:`numeric`,minute:`2-digit`}).format(new Date);t.chain().focus().insertContent(`${r} `).run()})),r&&(s.push(o(`pageLink`,`link`,[`page`,`link`,`[[`,`wiki`],(e,t)=>e.chain().focus().deleteRange(t).insertContent(`[[`).run())),s.push(o(`syncedPage`,`copy`,[`embed`,`transclude`,`include`,`mirror`,`![[`],(e,t)=>e.chain().focus().deleteRange(t).insertContent(`![[`).run())),r.create&&s.push(o(`newPage`,`page-plus`,[`page`,`doc`,`subpage`,`create`],(e,t)=>{e.chain().focus().deleteRange(t).run(),zV(e,r,``).catch(n)}))),t?.upload){let e=e=>(r,i)=>{r.chain().focus().deleteRange(i).run(),QJ(e).then(e=>gH(r,t,e).catch(n))};s.push(o(`image`,`image`,[`picture`,`photo`,`img`],e(`image/*`)),o(`file`,`paperclip`,[`attachment`,`upload`,`pdf`],e(``)),o(`drawio`,`diagram`,[`diagram`,`diagrams.net`,`draw`,`chart`,`uml`],(e,t)=>e.chain().focus().deleteRange(t).insertDiagram(`drawio`).run())),i&&s.push(o(`excalidraw`,`pencil`,[`drawing`,`sketch`,`whiteboard`,`draw`],(e,t)=>e.chain().focus().deleteRange(t).insertDiagram(`excalidraw`).run()))}return s}function eY(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e=>e.label.toLowerCase().includes(n)||e.id.startsWith(n)||e.keywords.some(e=>e.toLowerCase().startsWith(n));return e.flatMap(e=>{let t=e.children?.filter(r)??[];return t.length?t:r(e)?[e]:[]})}var tY=Tp.create({name:`slashMenu`,addOptions(){return{commands:[],labels:void 0}},addProseMirrorPlugins(){return[PV({editor:this.editor,pluginKey:new Un(`slashMenu`),char:`/`,allowSpaces:!1,startOfLine:!1,allow:({state:e,range:t})=>!e.doc.resolve(t.from).parent.type.spec.code,items:({query:e})=>eY(this.options.commands,e),render:Uj({label:this.options.labels.slashMenu,empty:this.options.labels.noMatches,showQuery:!0,toItem:e=>({label:e.label,description:e.description,icon:e.icon}),children:e=>e.children,pick:(e,t)=>t.run(e.editor,e.range)})})]}});function nY(e,t){let n=!0,r=e.firstChild?.childCount??0;return e.forEach(e=>{t===`column`&&e.childCount!==r&&(n=!1),e.forEach(e=>{((t===`row`?e.attrs.rowspan:e.attrs.colspan)??1)>1&&(n=!1)})}),n}function rY(e,t,n){let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r}var iY=e=>{let t=[];return e.forEach(e=>t.push(e)),t};function aY(e,t,n,r,i,a=0){let o=e.doc.nodeAt(t);if(!o||o.type.name!==`table`||!nY(o,n))return null;let c=iY(o),l=n===`row`?c.length:c[0]?.childCount??0;if(r===i||r<0||i<0||r>=l||i>=l)return null;let u=n===`row`?rY(c,r,i):c.map(e=>e.copy(s.fromArray(rY(iY(e),r,i)))),d=e.tr.replaceWith(t,t+o.nodeSize,o.copy(s.fromArray(u))),[f,p]=n===`row`?[i,0]:[Math.min(a,u.length-1),i],m=t+1;for(let e=0;e0;e--)if(n.node(e).type.name===`table`)return{tablePos:n.before(e),row:n.index(e),column:e+1<=n.depth?n.index(e+1):0};return null}var sY=Tp.create({name:`tableMove`,addOptions(){return{labels:null}},addCommands(){let e=e=>t=>({state:n,dispatch:r})=>{let i=oY(n,n.selection.from);if(!i)return!1;let a=e===`row`?i.row:i.column,o=aY(n,i.tablePos,e,a,a+t,i.row);return o?(r?.(o),!0):!1};return{moveTableRow:e(`row`),moveTableColumn:e(`column`)}},addKeyboardShortcuts(){return{"Mod-Alt-ArrowUp":()=>this.editor.commands.moveTableRow(-1),"Mod-Alt-ArrowDown":()=>this.editor.commands.moveTableRow(1),"Mod-Alt-ArrowLeft":()=>this.editor.commands.moveTableColumn(-1),"Mod-Alt-ArrowRight":()=>this.editor.commands.moveTableColumn(1)}},addProseMirrorPlugins(){let e=this.options.labels?.table;return[new D({key:new Un(`tableMove`),view:t=>new cY(t,{row:e?.dragRow??`Drag to move the row`,column:e?.dragColumn??`Drag to move the column`})})]}}),cY=class{view;grips={row:document.createElement(`button`),column:document.createElement(`button`)};line=document.createElement(`div`);cell=null;drag=null;constructor(e,t){this.view=e;for(let e of[`row`,`column`]){let n=this.grips[e];n.type=`button`,n.className=`dw-table-grip dw-table-grip--${e}`,n.contentEditable=`false`,n.setAttribute(`aria-label`,t[e]),n.title=t[e],n.hidden=!0,n.tabIndex=-1,n.addEventListener(`pointerdown`,t=>this.start(t,e)),n.addEventListener(`mouseleave`,this.leave)}this.line.className=`dw-table-drop`,this.line.hidden=!0,e.dom.addEventListener(`mousemove`,this.move),e.dom.addEventListener(`mouseleave`,this.leave)}get host(){let e=this.view.dom.parentElement;return e&&this.line.parentElement!==e&&(e.classList.add(`dw-block-host`),e.append(this.grips.row,this.grips.column,this.line)),e}hide=()=>{this.drag||(this.grips.row.hidden=!0,this.grips.column.hidden=!0,this.cell=null)};leave=e=>{let t=e.relatedTarget;t&&(this.grips.row.contains(t)||this.grips.column.contains(t)||this.view.dom.contains(t))||this.hide()};move=e=>{if(this.drag)return;let t=e.target?.closest?.(`td, th`),n=this.host;if(!this.view.editable||!n||!(t instanceof HTMLTableCellElement)||!this.view.dom.contains(t))return this.hide();let r=this.locate(t),i=r&&this.view.state.doc.nodeAt(r.tablePos);if(!r||!i)return this.hide();this.cell=t;let a=n.getBoundingClientRect(),o=t.closest(`table`).getBoundingClientRect(),s=t.parentElement.getBoundingClientRect(),c=t.getBoundingClientRect(),l=i.childCount>1&&nY(i,`row`),u=(i.firstChild?.childCount??0)>1&&nY(i,`column`);Object.assign(this.grips.row.style,{top:`${s.top-a.top+s.height/2-11}px`,left:`${o.left-a.left-7}px`}),Object.assign(this.grips.column.style,{top:`${o.top-a.top-7}px`,left:`${c.left-a.left+c.width/2-11}px`}),this.grips.row.hidden=!l,this.grips.column.hidden=!u};locate(e){try{return oY(this.view.state,this.view.posAtDOM(e,0))}catch{return null}}start(e,t){let n=this.cell;if(!n||e.button!==0)return;let r=this.locate(n),i=n.parentElement?.parentElement;if(!r||!i)return;e.preventDefault();let a=this.grips[t];a.setPointerCapture(e.pointerId);let o=[...i.children].filter(e=>e instanceof HTMLTableRowElement),s=t===`row`?r.row:r.column,c=t===`row`?o:[...o[0]?.children??[]],l=t===`row`?[o[s]]:o.map(e=>e.children[s]).filter(Boolean);for(let e of l)e.classList.add(`dw-table-dragging`);this.drag={axis:t,tablePos:r.tablePos,from:s,slots:c,dimmed:l,to:s,cursorRow:r.row},a.addEventListener(`pointermove`,this.dragMove),a.addEventListener(`pointerup`,this.drop),a.addEventListener(`pointercancel`,this.cancel)}dragMove=e=>{let t=this.drag,n=this.host;if(!t||!n)return;let r=t.axis===`row`,i=r?e.clientY:e.clientX,a=t.slots.length;for(let[e,n]of t.slots.entries()){let t=n.getBoundingClientRect();if(i<(r?t.top+t.height/2:t.left+t.width/2)){a=e;break}}t.to=a>t.from?a-1:a;let o=n.getBoundingClientRect(),s=t.slots[0].closest(`table`).getBoundingClientRect(),c=t.slots.at(-1).getBoundingClientRect(),l=t.slots[a]?.getBoundingClientRect(),u=r?l?.top??c.bottom:l?.left??c.right;Object.assign(this.line.style,r?{top:`${u-o.top-1}px`,left:`${s.left-o.left}px`,width:`${s.width}px`,height:`2px`}:{top:`${s.top-o.top}px`,left:`${u-o.left-1}px`,width:`2px`,height:`${s.height}px`}),this.line.hidden=t.to===t.from};drop=()=>{let e=this.drag;if(this.cancel(),!e||e.to===e.from)return;let t=aY(this.view.state,e.tablePos,e.axis,e.from,e.to,e.cursorRow);t&&this.view.dispatch(t),this.view.focus()};cancel=()=>{let e=this.drag;for(let t of e?.dimmed??[])t.classList.remove(`dw-table-dragging`);this.drag=null,this.line.hidden=!0;for(let e of Object.values(this.grips))e.removeEventListener(`pointermove`,this.dragMove),e.removeEventListener(`pointerup`,this.drop),e.removeEventListener(`pointercancel`,this.cancel);this.hide()};update(){this.cell&&!this.cell.isConnected&&this.hide()}destroy(){this.cancel();for(let e of Object.values(this.grips))e.remove();this.line.remove(),this.view.dom.removeEventListener(`mousemove`,this.move),this.view.dom.removeEventListener(`mouseleave`,this.leave)}};function lY(e){let t=[];return e.descendants((e,n)=>e.type.name!==`heading`||(t.push({level:Number(e.attrs.level)||1,text:e.textContent.trim(),pos:n}),!1)),t}function uY(e,t){let n=e.view.nodeDOM(t);n instanceof HTMLElement&&n.scrollIntoView({behavior:`smooth`,block:`start`}),e.isEditable&&e.commands.setTextSelection(t+1)}var dY=Jp.create({name:`tableOfContents`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},parseHTML(){return[{tag:`nav[data-type='toc']`}]},renderHTML(){return[`nav`,{"data-type":`toc`}]},addCommands(){return{insertTableOfContents:()=>({commands:e})=>e.insertContent({type:this.name})}},addNodeView(){return({editor:e})=>{let t=this.options.labels.blocks,n=document.createElement(`nav`);n.className=`dw-toc`,n.setAttribute(`data-type`,`toc`),n.setAttribute(`aria-label`,t.toc),n.contentEditable=`false`;let r=document.createElement(`p`);r.className=`dw-toc__title`,r.textContent=t.toc;let i=document.createElement(`ol`);i.className=`dw-toc__list`,n.append(r,i);let a=``,o=()=>{let n=lY(e.state.doc),r=JSON.stringify(n.map(e=>[e.level,e.text]));if(r===a){i.querySelectorAll(`a`).forEach((e,t)=>e.dataset.pos=String(n[t]?.pos??0));return}if(a=r,i.replaceChildren(),!n.length){let e=document.createElement(`li`);e.className=`dw-toc__empty`,e.textContent=t.tocEmpty,i.append(e);return}let o=Math.min(...n.map(e=>e.level));for(let t of n){let n=document.createElement(`li`);n.style.paddingLeft=`${(t.level-o)*1}rem`;let r=document.createElement(`a`);r.href=`#`,r.textContent=t.text||`…`,r.dataset.pos=String(t.pos),r.addEventListener(`click`,t=>{t.preventDefault(),uY(e,Number(r.dataset.pos))}),n.append(r),i.append(n)}};return o(),e.on(`update`,o),{dom:n,update:e=>e.type.name===`tableOfContents`,ignoreMutation:()=>!0,stopEvent:e=>e.target instanceof Element&&!!e.target.closest(`a`),destroy:()=>e.off(`update`,o)}}}}),fY=(e,t)=>{let n=t.view.domAtPos(e).node,r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return r?r.offsetParent!==null:!1},pY=(e,t,n)=>{for(let r=e.depth;r>0;--r){let i=e.node(r),a=t(i),o=fY(e.start(r),n);if(a&&o)return{pos:r>0?e.before(r):0,start:e.start(r),depth:r,node:i}}},mY=(e,t)=>{let{state:n,view:r,extensionManager:i}=e,{schema:a,selection:o}=n,{empty:s,$anchor:c}=o,l=!!i.extensions.find(e=>e.name===`gapCursor`);if(!s||c.parent.type!==a.nodes.detailsSummary||!l||t===`right`&&c.parentOffset!==c.parent.nodeSize-2)return!1;let u=yu(e=>e.type===a.nodes.details)(o);if(!u)return!1;let d=gu(u.node,e=>e.type===a.nodes.detailsContent);if(!d.length||fY(u.start+d[0].pos+1,e))return!1;let f=n.doc.resolve(u.pos+u.node.nodeSize),p=zw.findFrom(f,1,!1);if(!p)return!1;let{tr:m}=n,h=new zw(p);return m.setSelection(h),m.scrollIntoView(),r.dispatch(m),!0},hY=Jp.create({name:`details`,content:`detailsSummary detailsContent`,group:`block`,defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:`is-open`,HTMLAttributes:{},renderToggleButton:({element:e,isOpen:t})=>{e.setAttribute(`aria-label`,t?`Collapse details content`:`Expand details content`)}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:e=>e.hasAttribute(`open`),renderHTML:({open:e})=>e?{open:``}:{}}}:[]},parseHTML(){return[{tag:`details`}]},renderHTML({HTMLAttributes:e}){return[`details`,A(this.options.HTMLAttributes,e),0]},...Xf({nodeName:`details`,content:`block`}),addNodeView(){return({editor:e,getPos:t,node:n,HTMLAttributes:r})=>{let i=document.createElement(`div`),a=A(this.options.HTMLAttributes,r,{"data-type":this.name});Object.entries(a).forEach(([e,t])=>i.setAttribute(e,t));let o=document.createElement(`button`);o.type=`button`;let s=e=>{this.options.renderToggleButton({element:o,...e})};i.append(o);let c=document.createElement(`div`);i.append(c);let l=e=>{let{setToValue:t,node:r=n}=e||{};if(t!==void 0){if(t){if(i.classList.contains(this.options.openClassName))return;i.classList.add(this.options.openClassName)}else{if(!i.classList.contains(this.options.openClassName))return;i.classList.remove(this.options.openClassName)}}else i.classList.toggle(this.options.openClassName);let a=i.classList.contains(this.options.openClassName);s({isOpen:a,node:r});let o=new Event(`toggleDetailsContent`);c.querySelector(`:scope > div[data-type="detailsContent"]`)?.dispatchEvent(o)};return s({isOpen:!!n.attrs.open,node:n}),n.attrs.open&&setTimeout(()=>l()),o.addEventListener(`click`,()=>{if(l(),!this.options.persist)e.commands.focus(void 0,{scrollIntoView:!1});else if(e.isEditable&&typeof t==`function`){let{from:n,to:r}=e.state.selection;e.chain().command(({tr:e})=>{let n=t();if(typeof n!=`number`)return!1;let r=e.doc.nodeAt(n);return r?.type===this.type&&(e.setNodeMarkup(n,void 0,{open:!r.attrs.open}),!0)}).setTextSelection({from:n,to:r}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:i,contentDOM:c,ignoreMutation(e){if(e.type===`selection`)return!1;let t=e.target,n=i.contains(t);return o.contains(t)||!n||i===t},update:e=>e.type===this.type&&(e.attrs.open===void 0?s({isOpen:i.classList.contains(this.options.openClassName),node:e}):l({setToValue:e.attrs.open,node:e}),!0)}}},addCommands(){return{setDetails:()=>({state:e,chain:t})=>{let{schema:n,selection:r}=e,{$from:i,$to:a}=r,o=i.blockRange(a);if(!o)return!1;let s=e.doc.slice(o.start,o.end);if(!n.nodes.detailsContent.contentMatch.matchFragment(s.content))return!1;let c=s.toJSON()?.content||[];return t().insertContentAt({from:o.start,to:o.end},{type:this.name,content:[{type:`detailsSummary`},{type:`detailsContent`,content:c}]}).setTextSelection(o.start+2).run()},unsetDetails:()=>({state:e,chain:t})=>{let{selection:n,schema:r}=e,i=yu(e=>e.type===this.type)(n);if(!i)return!1;let a=gu(i.node,e=>e.type===r.nodes.detailsSummary),o=gu(i.node,e=>e.type===r.nodes.detailsContent);if(!a.length||!o.length)return!1;let s=a[0],c=o[0],l=i.pos,u=e.doc.resolve(l),d={from:l,to:l+i.node.nodeSize},f=c.node.content.toJSON()||[],p=[u.parent.type.contentMatch.defaultType?.create(null,s.node.content).toJSON(),...f];return t().insertContentAt(d,p).setTextSelection(l+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{let{schema:e,selection:t}=this.editor.state,{empty:n,$anchor:r}=t;return!n||r.parent.type!==e.nodes.detailsSummary?!1:r.parentOffset===0?this.editor.commands.unsetDetails():this.editor.commands.command(({tr:e})=>{let t=r.pos-1,n=r.pos;return e.delete(t,n),!0})},Enter:({editor:e})=>{let{state:t,view:n}=e,{schema:r,selection:i}=t,{$head:a}=i;if(a.parent.type!==r.nodes.detailsSummary)return!1;let o=fY(a.after()+1,e),s=o?t.doc.nodeAt(a.after()):a.node(-2);if(!s)return!1;let c=o?0:a.indexAfter(-1),l=Ll(s.contentMatchAt(c));if(!l||!s.canReplaceWith(c,c,l))return!1;let u=l.createAndFill();if(!u)return!1;let d=o?a.after()+1:a.after(-1),f=t.tr.replaceWith(d,d,u),p=f.doc.resolve(d),m=w.near(p,1);return f.setSelection(m),f.scrollIntoView(),n.dispatch(f),!0},ArrowRight:({editor:e})=>mY(e,`right`),ArrowDown:({editor:e})=>mY(e,`down`)}},addProseMirrorPlugins(){return[new D({key:new Un(`detailsSelection`),appendTransaction:(e,t,n)=>{let{editor:r,type:i}=this;if(r.view.composing||!e.some(e=>e.selectionSet)||!t.selection.empty||!n.selection.empty||!sd(n,i.name))return;let{$from:a}=n.selection;if(fY(a.pos,r))return;let o=pY(a,e=>e.type===i,r);if(!o)return;let s=gu(o.node,e=>e.type===n.schema.nodes.detailsSummary);if(!s.length)return;let c=s[0],l=(t.selection.from{let t=document.createElement(`div`),n=A(this.options.HTMLAttributes,e,{"data-type":this.name,hidden:`hidden`});return Object.entries(n).forEach(([e,n])=>t.setAttribute(e,n)),t.addEventListener(`toggleDetailsContent`,()=>{t.toggleAttribute(`hidden`)}),{dom:t,contentDOM:t,ignoreMutation(e){return e.type===`selection`?!1:!t.contains(e.target)||t===e.target},update:e=>e.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let{state:t,view:n}=e,{selection:r}=t,{$from:i,empty:a}=r,o=yu(e=>e.type===this.type)(r);if(!a||!o||!o.node.childCount)return!1;let s=i.index(o.depth),{childCount:c}=o.node;if(c!==s+1)return!1;let l=o.node.type.contentMatch.defaultType?.createAndFill();if(!l)return!1;let u=t.doc.resolve(o.pos+1),d=c-1,f=o.node.child(d),p=u.posAtIndex(d,o.depth);if(!f.eq(l))return!1;let m=i.node(-3);if(!m)return!1;let h=i.indexAfter(-3),g=Ll(m.contentMatchAt(h));if(!g||!m.canReplaceWith(h,h,g))return!1;let _=g.createAndFill();if(!_)return!1;let{tr:v}=t,y=i.after(-2);v.replaceWith(y,y,_);let b=v.doc.resolve(y),x=w.near(b,1);v.setSelection(x);let S=p,C=p+f.nodeSize;return v.delete(S,C),v.scrollIntoView(),n.dispatch(v),!0}}},...Xf({nodeName:`detailsContent`})}),_Y=Jp.create({name:`detailsSummary`,content:`text*`,defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`summary`}]},renderHTML({HTMLAttributes:e}){return[`summary`,A(this.options.HTMLAttributes,e),0]},...Xf({nodeName:`detailsSummary`,content:`inline`})});function vY(e){return[hY.configure({persist:!1,HTMLAttributes:{class:`dw-toggle`},renderToggleButton:({element:t,isOpen:n})=>{t.setAttribute(`aria-label`,n?e.blocks.collapse:e.blocks.expand),t.setAttribute(`aria-expanded`,String(n))}}),_Y,gY]}function yY(e={}){let t=e.labels??NR,n=null,r=Tp.create({name:`editorRef`,onCreate(){n=this.editor}}),i={host:e.files,labels:t,drawioUrl:e.drawioUrl,loadExcalidraw:e.loadExcalidraw,onError:e.onError},a=[r,Yk.configure({heading:{levels:[1,2,3,4,5,6]},codeBlock:!1,link:{openOnClick:!1,autolink:!0},undoRedo:e.collab||e.syncedDoc||e.rowBody||e.rowFragmentReadOnly?!1:void 0}),hT.configure({placeholder:e.placeholder??`Type '/' for commands…`}),_H.configure({host:e.files}),yH.configure({host:e.files,loadPdf:e.loadPdf,labels:t}),Lj.configure({lineNumbers:e.codeLineNumbers??!1}),MP,jP,RP,zP,...kP(),...AP(),sY.configure({labels:t}),HP.configure({labels:t}),bH.configure({host:e.files,onError:e.onError}),GJ(t,e.mentions),hV.configure({labels:t,me:()=>e.mentions?.me,onOpen:e.onOpenDate}),tY.configure({commands:$J(t,e.files,e.onError,e.pages,!!e.loadExcalidraw,e.links),labels:t}),aV.configure({onSelect:e.onCommentSelect}),BJ(t,()=>n),ZJ.configure({labels:t,load:e.loadMermaid}),dY.configure({labels:t}),QV.configure(i),$V.configure(i),BV.configure({host:e.pages,labels:t,onNavigate:e.onNavigate}),HV.configure({host:e.syncedPages,pages:e.pages,labels:t,onNavigate:e.onNavigate,nested:t=>yY({syncedDoc:t,files:e.files,links:e.links,onNavigate:e.onNavigate,drawioUrl:e.drawioUrl,loadMermaid:e.loadMermaid,loadPdf:e.loadPdf,codeLineNumbers:e.codeLineNumbers,labels:e.labels,placeholder:``})}),...vY(t),dH.configure({labels:t}),fH.configure({labels:t}),iM.configure({labels:t,link:e.blockLink,onCopied:e.onBlockLinkCopied}),DH,XB.configure({labels:t,doc:e.collab?.provider.doc??e.syncedDoc??e.rowBody?.doc,readOnlyDoc:!!e.syncedDoc,undoScope:!e.rowBody,files:e.files,people:e.mentions,recordLink:e.blockLink,linkedPages:e.syncedPages,pages:e.pages,onNavigate:e.onNavigate,recordPage:e.recordPage,onLinkCopied:e.onBlockLinkCopied,me:()=>{let t=e.mentions?.me;return t?{id:t,name:e.collab?.user.name??``}:null},rowExtensions:n=>{let r=e.collab?.provider.doc??e.syncedDoc??e.rowBody?.doc;return yY({rowBody:n&&r&&!e.syncedDoc?{doc:r,fragment:n}:void 0,files:e.files,mentions:e.mentions,pages:e.pages,links:e.links,onNavigate:e.onNavigate,drawioUrl:e.drawioUrl,loadMermaid:e.loadMermaid,loadExcalidraw:e.loadExcalidraw,loadPdf:e.loadPdf,codeLineNumbers:e.codeLineNumbers,labels:e.labels,placeholder:t.database.bodyPlaceholder,rowFragmentReadOnly:n&&e.syncedDoc?n:void 0})}})],o={trackedOrigins:[Xz]};return e.rowBody?a.push(jw.configure({document:e.rowBody.doc,fragment:e.rowBody.fragment,yUndoOptions:o})):e.rowFragmentReadOnly?a.push(jw.configure({fragment:e.rowFragmentReadOnly})):e.syncedDoc?a.push(jw.configure({document:e.syncedDoc})):e.collab&&a.push(jw.configure({document:e.collab.provider.doc,yUndoOptions:o}),Iw.configure({provider:e.collab.provider,user:e.collab.user,render:bY})),a}function bY(e){let t=typeof e.color==`string`&&/^#[0-9a-f]{3,8}$/i.test(e.color)?e.color:`#888`,n=document.createElement(`span`);n.classList.add(`collaboration-carets__caret`),n.style.borderColor=t;let r=document.createElement(`div`);return r.classList.add(`collaboration-carets__label`),r.setAttribute(`aria-hidden`,`true`),r.style.backgroundColor=t,r.textContent=typeof e.name==`string`?e.name:``,n.append(r),n}function xY(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var SY=xY();function CY(e){SY=e}var wY={exec:()=>null};function TY(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(DY.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var EY=(()=>{try{return!0}catch{return!1}})(),DY={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},OY=/^(?:[ \t]*(?:\n|$))+/,kY=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,AY=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,jY=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,MY=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,NY=/(?:[*+-]|\d{1,9}[.)])/,PY=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,FY=TY(PY).replace(/bull/g,NY).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),IY=TY(PY).replace(/bull/g,NY).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),LY=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,RY=/^[^\n]+/,zY=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,BY=TY(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,zY).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),VY=TY(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,NY).getRegex(),HY=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,UY=/\x3C!--(?:-?>|[\s\S]*?(?:-->|$))/,WY=TY(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,UY).replace(`tag`,HY).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),GY=TY(LY).replace(`hr`,jY).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,HY).getRegex(),KY={blockquote:TY(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,GY).getRegex(),code:kY,def:BY,fences:AY,heading:MY,hr:jY,html:WY,lheading:FY,list:VY,newline:OY,paragraph:GY,table:wY,text:RY},qY=TY(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,jY).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,HY).getRegex(),JY={...KY,lheading:IY,table:qY,paragraph:TY(LY).replace(`hr`,jY).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,qY).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,HY).getRegex()},YY={...KY,html:TY(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,UY).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:wY,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:TY(LY).replace(`hr`,jY).replace(`heading`,` *#{1,6} *[^ -]`).replace(`lheading`,FY).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},XY=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ZY=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,QY=/^( {2,}|\\)\n(?!\s*$)/,$Y=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\`+)[^`]+\k(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,EY?"(?`+)[^`]+\k(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),cX=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,lX=TY(cX,`u`).replace(/punct/g,eX).getRegex(),uX=TY(cX,`u`).replace(/punct/g,iX).getRegex(),dX=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,fX=TY(dX,`gu`).replace(/notPunctSpace/g,nX).replace(/punctSpace/g,tX).replace(/punct/g,eX).getRegex(),pX=TY(dX,`gu`).replace(/notPunctSpace/g,oX).replace(/punctSpace/g,aX).replace(/punct/g,iX).getRegex(),mX=TY(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,nX).replace(/punctSpace/g,tX).replace(/punct/g,eX).getRegex(),hX=TY(/\\(punct)/,`gu`).replace(/punct/g,eX).getRegex(),gX=TY(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),_X=TY(UY).replace(`(?:-->|$)`,`-->`).getRegex(),vX=TY(`^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^`).replace(`comment`,_X).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),yX=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,bX=TY(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,yX).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),xX=TY(/^!?\[(label)\]\[(ref)\]/).replace(`label`,yX).replace(`ref`,zY).getRegex(),SX=TY(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,zY).getRegex(),CX=TY(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,xX).replace(`nolink`,SX).getRegex(),wX=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,TX={_backpedal:wY,anyPunctuation:hX,autolink:gX,blockSkip:sX,br:QY,code:ZY,del:wY,emStrongLDelim:lX,emStrongRDelimAst:fX,emStrongRDelimUnd:mX,escape:XY,link:bX,nolink:SX,punctuation:rX,reflink:xX,reflinkSearch:CX,tag:vX,text:$Y,url:wY},EX={...TX,link:TY(/^!?\[(label)\]\((.*?)\)/).replace(`label`,yX).getRegex(),reflink:TY(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,yX).getRegex()},DX={...TX,emStrongRDelimAst:pX,emStrongLDelim:uX,url:TY(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,wX).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:TY(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\":`>`,'"':`"`,"'":`'`},MX=e=>jX[e];function NX(e,t){if(t){if(DY.escapeTest.test(e))return e.replace(DY.escapeReplace,MX)}else if(DY.escapeTestNoEncode.test(e))return e.replace(DY.escapeReplaceNoEncode,MX);return e}function PX(e){try{e=encodeURI(e).replace(DY.percentDecode,`%`)}catch{return null}return e}function FX(e,t){let n=e.replace(DY.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(DY.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length0?-2:-1}function RX(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function zX(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(` +?)[ \r ]*`,gJ=`[̀-ͯ]`,_J=RegExp(gJ+`+$`),vJ=`(`+dJ+`+)|`+(hJ+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(gJ+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(gJ+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+mJ)+(`|`+pJ+`)`),yJ=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(vJ,`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 yq(`EOF`,new vq(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new L(`Unexpected character: '`+e[t]+`'`,new yq(e[t],new vq(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 yq(r,new vq(this,t,this.tokenRegex.lastIndex))}},bJ=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;r0&&(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}},xJ=_q;$(`\\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 SJ={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=SJ[t.text],r==null||r>=n)throw new L(`Invalid base-`+n+` digit `+t.text);for(var i;(i=SJ[e.future().text])!=null&&i{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=>CJ(e,!1,!0,!1)),$(`\\renewcommand`,e=>CJ(e,!0,!1,!1)),$(`\\providecommand`,e=>CJ(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),uJ[n],iW.math[n],iW.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{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),$(`\\ne`,`\\neq`),$(`≠`,`\\neq`),$(`\\notin`,"\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),$(`∉`,`\\notin`),$(`≘`,"\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),$(`≙`,"\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),$(`≚`,"\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),$(`≛`,"\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),$(`≝`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),$(`≞`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),$(`≟`,"\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),$(`⟂`,`\\perp`),$(`‼`,`\\mathclose{!\\mkern-0.8mu!}`),$(`∌`,`\\notni`),$(`⌜`,`\\ulcorner`),$(`⌝`,`\\urcorner`),$(`⌞`,`\\llcorner`),$(`⌟`,`\\lrcorner`),$(`©`,`\\copyright`),$(`®`,`\\textregistered`),$(`\\ulcorner`,`\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}`),$(`\\urcorner`,`\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}`),$(`\\llcorner`,`\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}`),$(`\\lrcorner`,`\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}`),$(`\\vdots`,`{\\varvdots\\rule{0pt}{15pt}}`),$(`⋮`,`\\vdots`),$(`\\varGamma`,`\\mathit{\\Gamma}`),$(`\\varDelta`,`\\mathit{\\Delta}`),$(`\\varTheta`,`\\mathit{\\Theta}`),$(`\\varLambda`,`\\mathit{\\Lambda}`),$(`\\varXi`,`\\mathit{\\Xi}`),$(`\\varPi`,`\\mathit{\\Pi}`),$(`\\varSigma`,`\\mathit{\\Sigma}`),$(`\\varUpsilon`,`\\mathit{\\Upsilon}`),$(`\\varPhi`,`\\mathit{\\Phi}`),$(`\\varPsi`,`\\mathit{\\Psi}`),$(`\\varOmega`,`\\mathit{\\Omega}`),$(`\\substack`,`\\begin{subarray}{c}#1\\end{subarray}`),$(`\\colon`,`\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax`),$(`\\boxed`,`\\fbox{$\\displaystyle{#1}$}`),$(`\\iff`,`\\DOTSB\\;\\Longleftrightarrow\\;`),$(`\\implies`,`\\DOTSB\\;\\Longrightarrow\\;`),$(`\\impliedby`,`\\DOTSB\\;\\Longleftarrow\\;`),$(`\\dddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}`),$(`\\ddddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}`);var wJ={",":`\\dotsc`,"\\not":`\\dotsb`,"+":`\\dotsb`,"=":`\\dotsb`,"<":`\\dotsb`,">":`\\dotsb`,"-":`\\dotsb`,"*":`\\dotsb`,":":`\\dotsb`,"\\DOTSB":`\\dotsb`,"\\coprod":`\\dotsb`,"\\bigvee":`\\dotsb`,"\\bigwedge":`\\dotsb`,"\\biguplus":`\\dotsb`,"\\bigcap":`\\dotsb`,"\\bigcup":`\\dotsb`,"\\prod":`\\dotsb`,"\\sum":`\\dotsb`,"\\bigotimes":`\\dotsb`,"\\bigoplus":`\\dotsb`,"\\bigodot":`\\dotsb`,"\\bigsqcup":`\\dotsb`,"\\And":`\\dotsb`,"\\longrightarrow":`\\dotsb`,"\\Longrightarrow":`\\dotsb`,"\\longleftarrow":`\\dotsb`,"\\Longleftarrow":`\\dotsb`,"\\longleftrightarrow":`\\dotsb`,"\\Longleftrightarrow":`\\dotsb`,"\\mapsto":`\\dotsb`,"\\longmapsto":`\\dotsb`,"\\hookrightarrow":`\\dotsb`,"\\doteq":`\\dotsb`,"\\mathbin":`\\dotsb`,"\\mathrel":`\\dotsb`,"\\relbar":`\\dotsb`,"\\Relbar":`\\dotsb`,"\\xrightarrow":`\\dotsb`,"\\xleftarrow":`\\dotsb`,"\\DOTSI":`\\dotsi`,"\\int":`\\dotsi`,"\\oint":`\\dotsi`,"\\iint":`\\dotsi`,"\\iiint":`\\dotsi`,"\\iiiint":`\\dotsi`,"\\idotsint":`\\dotsi`,"\\DOTSX":`\\dotsx`},TJ=new Set([`bin`,`rel`]);$(`\\dots`,function(e){var t=`\\dotso`,n=e.expandAfterFuture().text;return n in wJ?t=wJ[n]:(n.slice(0,4)===`\\not`||n in iW.math&&TJ.has(iW.math[n].group))&&(t=`\\dotsb`),t});var EJ={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};$(`\\dotso`,function(e){return e.future().text in EJ?`\\ldots\\,`:`\\ldots`}),$(`\\dotsc`,function(e){var t=e.future().text;return t in EJ&&t!==`,`?`\\ldots\\,`:`\\ldots`}),$(`\\cdots`,function(e){return e.future().text in EJ?`\\@cdots\\,`:`\\@cdots`}),$(`\\dotsb`,`\\cdots`),$(`\\dotsm`,`\\cdots`),$(`\\dotsi`,`\\!\\cdots`),$(`\\dotsx`,`\\ldots\\,`),$(`\\DOTSI`,`\\relax`),$(`\\DOTSB`,`\\relax`),$(`\\DOTSX`,`\\relax`),$(`\\tmspace`,`\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax`),$(`\\,`,`\\tmspace+{3mu}{.1667em}`),$(`\\thinspace`,`\\,`),$(`\\>`,`\\mskip{4mu}`),$(`\\:`,`\\tmspace+{4mu}{.2222em}`),$(`\\medspace`,`\\:`),$(`\\;`,`\\tmspace+{5mu}{.2777em}`),$(`\\thickspace`,`\\;`),$(`\\!`,`\\tmspace-{3mu}{.1667em}`),$(`\\negthinspace`,`\\!`),$(`\\negmedspace`,`\\tmspace-{4mu}{.2222em}`),$(`\\negthickspace`,`\\tmspace-{5mu}{.277em}`),$(`\\enspace`,`\\kern.5em `),$(`\\enskip`,`\\hskip.5em\\relax`),$(`\\quad`,`\\hskip1em\\relax`),$(`\\qquad`,`\\hskip2em\\relax`),$(`\\tag`,`\\@ifstar\\tag@literal\\tag@paren`),$(`\\tag@paren`,`\\tag@literal{({#1})}`),$(`\\tag@literal`,e=>{if(e.macros.get(`\\df@tag`))throw new L(`Multiple \\tag`);return`\\gdef\\df@tag{\\text{#1}}`}),$(`\\bmod`,`\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}`),$(`\\pod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)`),$(`\\pmod`,`\\pod{{\\rm mod}\\mkern6mu#1}`),$(`\\mod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1`),$(`\\newline`,`\\\\\\relax`),$(`\\TeX`,`\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}`);var DJ=z(ZU[`Main-Regular`][84][1]-.7*ZU[`Main-Regular`][65][1]);$(`\\LaTeX`,`\\textrm{\\html@mathml{`+(`L\\kern-.36em\\raisebox{`+DJ+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{LaTeX}}`),$(`\\KaTeX`,`\\textrm{\\html@mathml{`+(`K\\kern-.17em\\raisebox{`+DJ+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{KaTeX}}`),$(`\\hspace`,`\\@ifstar\\@hspacer\\@hspace`),$(`\\@hspace`,`\\hskip #1\\relax`),$(`\\@hspacer`,`\\rule{0pt}{0pt}\\hskip #1\\relax`),$(`\\ordinarycolon`,`:`),$(`\\vcentcolon`,`\\mathrel{\\mathop\\ordinarycolon}`),$(`\\dblcolon`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}`),$(`\\coloneqq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}`),$(`\\Coloneqq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}`),$(`\\coloneq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}`),$(`\\Coloneq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}`),$(`\\eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}`),$(`\\Eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}`),$(`\\eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}`),$(`\\Eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}`),$(`\\colonapprox`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}`),$(`\\Colonapprox`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}`),$(`\\colonsim`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}`),$(`\\Colonsim`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}`),$(`∷`,`\\dblcolon`),$(`∹`,`\\eqcolon`),$(`≔`,`\\coloneqq`),$(`≕`,`\\eqqcolon`),$(`⩴`,`\\Coloneqq`),$(`\\ratio`,`\\vcentcolon`),$(`\\coloncolon`,`\\dblcolon`),$(`\\colonequals`,`\\coloneqq`),$(`\\coloncolonequals`,`\\Coloneqq`),$(`\\equalscolon`,`\\eqqcolon`),$(`\\equalscoloncolon`,`\\Eqqcolon`),$(`\\colonminus`,`\\coloneq`),$(`\\coloncolonminus`,`\\Coloneq`),$(`\\minuscolon`,`\\eqcolon`),$(`\\minuscoloncolon`,`\\Eqcolon`),$(`\\coloncolonapprox`,`\\Colonapprox`),$(`\\coloncolonsim`,`\\Colonsim`),$(`\\simcolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\simcoloncolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\approxcolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\approxcoloncolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\notni`,"\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),$(`\\limsup`,`\\DOTSB\\operatorname*{lim\\,sup}`),$(`\\liminf`,`\\DOTSB\\operatorname*{lim\\,inf}`),$(`\\injlim`,`\\DOTSB\\operatorname*{inj\\,lim}`),$(`\\projlim`,`\\DOTSB\\operatorname*{proj\\,lim}`),$(`\\varlimsup`,`\\DOTSB\\operatorname*{\\overline{lim}}`),$(`\\varliminf`,`\\DOTSB\\operatorname*{\\underline{lim}}`),$(`\\varinjlim`,`\\DOTSB\\operatorname*{\\underrightarrow{lim}}`),$(`\\varprojlim`,`\\DOTSB\\operatorname*{\\underleftarrow{lim}}`),$(`\\gvertneqq`,`\\html@mathml{\\@gvertneqq}{≩}`),$(`\\lvertneqq`,`\\html@mathml{\\@lvertneqq}{≨}`),$(`\\ngeqq`,`\\html@mathml{\\@ngeqq}{≱}`),$(`\\ngeqslant`,`\\html@mathml{\\@ngeqslant}{≱}`),$(`\\nleqq`,`\\html@mathml{\\@nleqq}{≰}`),$(`\\nleqslant`,`\\html@mathml{\\@nleqslant}{≰}`),$(`\\nshortmid`,`\\html@mathml{\\@nshortmid}{∤}`),$(`\\nshortparallel`,`\\html@mathml{\\@nshortparallel}{∦}`),$(`\\nsubseteqq`,`\\html@mathml{\\@nsubseteqq}{⊈}`),$(`\\nsupseteqq`,`\\html@mathml{\\@nsupseteqq}{⊉}`),$(`\\varsubsetneq`,`\\html@mathml{\\@varsubsetneq}{⊊}`),$(`\\varsubsetneqq`,`\\html@mathml{\\@varsubsetneqq}{⫋}`),$(`\\varsupsetneq`,`\\html@mathml{\\@varsupsetneq}{⊋}`),$(`\\varsupsetneqq`,`\\html@mathml{\\@varsupsetneqq}{⫌}`),$(`\\imath`,`\\html@mathml{\\@imath}{ı}`),$(`\\jmath`,`\\html@mathml{\\@jmath}{ȷ}`),$(`\\llbracket`,"\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),$(`\\rrbracket`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),$(`⟦`,`\\llbracket`),$(`⟧`,`\\rrbracket`),$(`\\lBrace`,"\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),$(`\\rBrace`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),$(`↤`,`\\mapsfrom`),$(`\\mapsfrom`,"\\html@mathml{\\mathrel{\\mathreflectbox{\\mapsto}}}{\\mathrel{\\char`↤}}"),$(`⦃`,`\\lBrace`),$(`⦄`,`\\rBrace`),$(`\\minuso`,"\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),$(`⦵`,`\\minuso`),$(`\\darr`,`\\downarrow`),$(`\\dArr`,`\\Downarrow`),$(`\\Darr`,`\\Downarrow`),$(`\\lang`,`\\langle`),$(`\\rang`,`\\rangle`),$(`\\uarr`,`\\uparrow`),$(`\\uArr`,`\\Uparrow`),$(`\\Uarr`,`\\Uparrow`),$(`\\N`,`\\mathbb{N}`),$(`\\R`,`\\mathbb{R}`),$(`\\Z`,`\\mathbb{Z}`),$(`\\alef`,`\\aleph`),$(`\\alefsym`,`\\aleph`),$(`\\Alpha`,`\\mathrm{A}`),$(`\\Beta`,`\\mathrm{B}`),$(`\\bull`,`\\bullet`),$(`\\Chi`,`\\mathrm{X}`),$(`\\clubs`,`\\clubsuit`),$(`\\cnums`,`\\mathbb{C}`),$(`\\Complex`,`\\mathbb{C}`),$(`\\Dagger`,`\\ddagger`),$(`\\diamonds`,`\\diamondsuit`),$(`\\empty`,`\\emptyset`),$(`\\Epsilon`,`\\mathrm{E}`),$(`\\Eta`,`\\mathrm{H}`),$(`\\exist`,`\\exists`),$(`\\harr`,`\\leftrightarrow`),$(`\\hArr`,`\\Leftrightarrow`),$(`\\Harr`,`\\Leftrightarrow`),$(`\\hearts`,`\\heartsuit`),$(`\\image`,`\\Im`),$(`\\infin`,`\\infty`),$(`\\Iota`,`\\mathrm{I}`),$(`\\isin`,`\\in`),$(`\\Kappa`,`\\mathrm{K}`),$(`\\larr`,`\\leftarrow`),$(`\\lArr`,`\\Leftarrow`),$(`\\Larr`,`\\Leftarrow`),$(`\\lrarr`,`\\leftrightarrow`),$(`\\lrArr`,`\\Leftrightarrow`),$(`\\Lrarr`,`\\Leftrightarrow`),$(`\\Mu`,`\\mathrm{M}`),$(`\\natnums`,`\\mathbb{N}`),$(`\\Nu`,`\\mathrm{N}`),$(`\\Omicron`,`\\mathrm{O}`),$(`\\plusmn`,`\\pm`),$(`\\rarr`,`\\rightarrow`),$(`\\rArr`,`\\Rightarrow`),$(`\\Rarr`,`\\Rightarrow`),$(`\\real`,`\\Re`),$(`\\reals`,`\\mathbb{R}`),$(`\\Reals`,`\\mathbb{R}`),$(`\\Rho`,`\\mathrm{P}`),$(`\\sdot`,`\\cdot`),$(`\\sect`,`\\S`),$(`\\spades`,`\\spadesuit`),$(`\\sub`,`\\subset`),$(`\\sube`,`\\subseteq`),$(`\\supe`,`\\supseteq`),$(`\\Tau`,`\\mathrm{T}`),$(`\\thetasym`,`\\vartheta`),$(`\\weierp`,`\\wp`),$(`\\Zeta`,`\\mathrm{Z}`),$(`\\argmin`,`\\DOTSB\\operatorname*{arg\\,min}`),$(`\\argmax`,`\\DOTSB\\operatorname*{arg\\,max}`),$(`\\plim`,`\\DOTSB\\mathop{\\operatorname{plim}}\\limits`),$(`\\bra`,`\\mathinner{\\langle{#1}|}`),$(`\\ket`,`\\mathinner{|{#1}\\rangle}`),$(`\\braket`,`\\mathinner{\\langle{#1}\\rangle}`),$(`\\Bra`,`\\left\\langle#1\\right|`),$(`\\Ket`,`\\left|#1\\right\\rangle`);var OJ=e=>t=>{var n=t.consumeArg().tokens,r=t.consumeArg().tokens,i=t.consumeArg().tokens,a=t.consumeArg().tokens,o=t.macros.get(`|`),s=t.macros.get(`\\|`);t.macros.beginGroup();var c=t=>n=>{e&&(n.macros.set(`|`,o),i.length&&n.macros.set(`\\|`,s));var a=t;return!t&&i.length&&n.future().text===`|`&&(n.popToken(),a=!0),{tokens:a?i:r,numArgs:0}};t.macros.set(`|`,c(!1)),i.length&&t.macros.set(`\\|`,c(!0));var l=t.consumeArg().tokens,u=t.expandTokens([...a,...l,...n]);return t.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};$(`\\bra@ket`,OJ(!1)),$(`\\bra@set`,OJ(!0)),$(`\\Braket`,`\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}`),$(`\\Set`,`\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}`),$(`\\set`,`\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}`),$(`\\angln`,`{\\angl n}`),$(`\\blue`,`\\textcolor{##6495ed}{#1}`),$(`\\orange`,`\\textcolor{##ffa500}{#1}`),$(`\\pink`,`\\textcolor{##ff00af}{#1}`),$(`\\red`,`\\textcolor{##df0030}{#1}`),$(`\\green`,`\\textcolor{##28ae7b}{#1}`),$(`\\gray`,`\\textcolor{gray}{#1}`),$(`\\purple`,`\\textcolor{##9d38bd}{#1}`),$(`\\blueA`,`\\textcolor{##ccfaff}{#1}`),$(`\\blueB`,`\\textcolor{##80f6ff}{#1}`),$(`\\blueC`,`\\textcolor{##63d9ea}{#1}`),$(`\\blueD`,`\\textcolor{##11accd}{#1}`),$(`\\blueE`,`\\textcolor{##0c7f99}{#1}`),$(`\\tealA`,`\\textcolor{##94fff5}{#1}`),$(`\\tealB`,`\\textcolor{##26edd5}{#1}`),$(`\\tealC`,`\\textcolor{##01d1c1}{#1}`),$(`\\tealD`,`\\textcolor{##01a995}{#1}`),$(`\\tealE`,`\\textcolor{##208170}{#1}`),$(`\\greenA`,`\\textcolor{##b6ffb0}{#1}`),$(`\\greenB`,`\\textcolor{##8af281}{#1}`),$(`\\greenC`,`\\textcolor{##74cf70}{#1}`),$(`\\greenD`,`\\textcolor{##1fab54}{#1}`),$(`\\greenE`,`\\textcolor{##0d923f}{#1}`),$(`\\goldA`,`\\textcolor{##ffd0a9}{#1}`),$(`\\goldB`,`\\textcolor{##ffbb71}{#1}`),$(`\\goldC`,`\\textcolor{##ff9c39}{#1}`),$(`\\goldD`,`\\textcolor{##e07d10}{#1}`),$(`\\goldE`,`\\textcolor{##a75a05}{#1}`),$(`\\redA`,`\\textcolor{##fca9a9}{#1}`),$(`\\redB`,`\\textcolor{##ff8482}{#1}`),$(`\\redC`,`\\textcolor{##f9685d}{#1}`),$(`\\redD`,`\\textcolor{##e84d39}{#1}`),$(`\\redE`,`\\textcolor{##bc2612}{#1}`),$(`\\maroonA`,`\\textcolor{##ffbde0}{#1}`),$(`\\maroonB`,`\\textcolor{##ff92c6}{#1}`),$(`\\maroonC`,`\\textcolor{##ed5fa6}{#1}`),$(`\\maroonD`,`\\textcolor{##ca337c}{#1}`),$(`\\maroonE`,`\\textcolor{##9e034e}{#1}`),$(`\\purpleA`,`\\textcolor{##ddd7ff}{#1}`),$(`\\purpleB`,`\\textcolor{##c6b9fc}{#1}`),$(`\\purpleC`,`\\textcolor{##aa87ff}{#1}`),$(`\\purpleD`,`\\textcolor{##7854ab}{#1}`),$(`\\purpleE`,`\\textcolor{##543b78}{#1}`),$(`\\mintA`,`\\textcolor{##f5f9e8}{#1}`),$(`\\mintB`,`\\textcolor{##edf2df}{#1}`),$(`\\mintC`,`\\textcolor{##e0e5cc}{#1}`),$(`\\grayA`,`\\textcolor{##f6f7f7}{#1}`),$(`\\grayB`,`\\textcolor{##f0f1f2}{#1}`),$(`\\grayC`,`\\textcolor{##e3e5e6}{#1}`),$(`\\grayD`,`\\textcolor{##d6d8da}{#1}`),$(`\\grayE`,`\\textcolor{##babec2}{#1}`),$(`\\grayF`,`\\textcolor{##888d93}{#1}`),$(`\\grayG`,`\\textcolor{##626569}{#1}`),$(`\\grayH`,`\\textcolor{##3b3e40}{#1}`),$(`\\grayI`,`\\textcolor{##21242c}{#1}`),$(`\\kaBlue`,`\\textcolor{##314453}{#1}`),$(`\\kaGreen`,`\\textcolor{##71B307}{#1}`);var kJ={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},AJ=class{constructor(e,t,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new bJ(xJ,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new yJ(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,r;if(e){if(this.consumeSpaces(),this.future().text!==`[`)return null;t=this.popToken();var i=this.consumeArg([`]`]);r=i.tokens,n=i.end}else{var a=this.consumeArg();r=a.tokens,t=a.start,n=a.end}return this.pushToken(new yq(`EOF`,n.loc)),this.pushTokens(r),new yq(``,vq.range(t,n))}consumeSpaces(){for(;this.future().text===` `;)this.stack.pop()}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var r=this.future(),i,a=0,o=0;do{if(i=this.popToken(),t.push(i),i.text===`{`)++a;else if(i.text===`}`){if(--a,a===-1)throw new L(`Extra }`,i)}else if(i.text===`EOF`)throw new L(`Unexpected end of input in a macro argument, expected '`+(e&&n?e[o]:`}`)+`'`,i);if(e&&n){if((a===0||a===1&&e[o]===`{`)&&i.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}}while(a!==0||n);return r.text===`{`&&t[t.length-1].text===`}`&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:r,end:i}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new L(`The length of delimiters doesn't match the number of args!`);for(var n=t[0],r=0;rthis.settings.maxExpand)throw new L(`Too many expansions: infinite loop or need to increase maxExpand setting`)}expandOnce(e){var t=this.popToken(),n=t.text,r=t.noexpand?null:this._getExpansion(n);if(r==null||e&&r.unexpandable){if(e&&r==null&&n[0]===`\\`&&!this.isDefined(n))throw new L(`Undefined control sequence: `+n);return this.pushToken(t),!1}this.countExpansion(1);var i=r.tokens,a=this.consumeArgs(r.numArgs,r.delimiters);if(r.numArgs){i=i.slice();for(var o=i.length-1;o>=0;--o){var s=i[o];if(s.text===`#`){if(o===0)throw new L(`Incomplete placeholder at end of macro body`,s);if(s=i[--o],s.text===`#`)i.splice(o+1,1);else if(/^[1-9]$/.test(s.text))i.splice(o,2,...a[s.text-1]);else throw new L(`Not a valid argument number`,s)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text=`\\relax`),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new yq(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var r=this.stack.pop();r.treatAsRelax&&=(r.noexpand=!1,!1),t.push(r)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(e=>e.text).join(``)}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var r=typeof t==`function`?t(this):t;if(typeof r==`string`){var i=0;if(r.includes(`#`))for(var a=r.replace(/##/g,``);a.includes(`#`+(i+1));)++i;for(var o=new yJ(r,this.settings),s=[],c=o.lex();c.text!==`EOF`;)s.push(c),c=o.lex();return s.reverse(),{tokens:s,numArgs:i}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(uJ,e)||Object.prototype.hasOwnProperty.call(iW.math,e)||Object.prototype.hasOwnProperty.call(iW.text,e)||Object.prototype.hasOwnProperty.call(kJ,e)}isExpandable(e){var t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(uJ,e)&&!uJ[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},jJ=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,MJ=Object.freeze({"₊":`+`,"₋":`-`,"₌":`=`,"₍":`(`,"₎":`)`,"₀":`0`,"₁":`1`,"₂":`2`,"₃":`3`,"₄":`4`,"₅":`5`,"₆":`6`,"₇":`7`,"₈":`8`,"₉":`9`,ₐ:`a`,ₑ:`e`,ₕ:`h`,ᵢ:`i`,ⱼ:`j`,ₖ:`k`,ₗ:`l`,ₘ:`m`,ₙ:`n`,ₒ:`o`,ₚ:`p`,ᵣ:`r`,ₛ:`s`,ₜ:`t`,ᵤ:`u`,ᵥ:`v`,ₓ:`x`,ᵦ:`β`,ᵧ:`γ`,ᵨ:`ρ`,ᵩ:`ϕ`,ᵪ:`χ`,"⁺":`+`,"⁻":`-`,"⁼":`=`,"⁽":`(`,"⁾":`)`,"⁰":`0`,"¹":`1`,"²":`2`,"³":`3`,"⁴":`4`,"⁵":`5`,"⁶":`6`,"⁷":`7`,"⁸":`8`,"⁹":`9`,ᴬ:`A`,ᴮ:`B`,ᴰ:`D`,ᴱ:`E`,ᴳ:`G`,ᴴ:`H`,ᴵ:`I`,ᴶ:`J`,ᴷ:`K`,ᴸ:`L`,ᴹ:`M`,ᴺ:`N`,ᴼ:`O`,ᴾ:`P`,ᴿ:`R`,ᵀ:`T`,ᵁ:`U`,ⱽ:`V`,ᵂ:`W`,ᵃ:`a`,ᵇ:`b`,ᶜ:`c`,ᵈ:`d`,ᵉ:`e`,ᶠ:`f`,ᵍ:`g`,ʰ:`h`,ⁱ:`i`,ʲ:`j`,ᵏ:`k`,ˡ:`l`,ᵐ:`m`,ⁿ:`n`,ᵒ:`o`,ᵖ:`p`,ʳ:`r`,ˢ:`s`,ᵗ:`t`,ᵘ:`u`,ᵛ:`v`,ʷ:`w`,ˣ:`x`,ʸ:`y`,ᶻ:`z`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),NJ={"́":{text:`\\'`,math:`\\acute`},"̀":{text:"\\`",math:`\\grave`},"̈":{text:`\\"`,math:`\\ddot`},"̃":{text:`\\~`,math:`\\tilde`},"̄":{text:`\\=`,math:`\\bar`},"̆":{text:`\\u`,math:`\\breve`},"̌":{text:`\\v`,math:`\\check`},"̂":{text:`\\^`,math:`\\hat`},"̇":{text:`\\.`,math:`\\dot`},"̊":{text:`\\r`,math:`\\mathring`},"̋":{text:`\\H`},"̧":{text:`\\c`}},PJ={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,ḉ:`ḉ`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ç:`ç`,ď:`ď`,ḋ:`ḋ`,ḑ:`ḑ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ḝ:`ḝ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ȩ:`ȩ`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ģ:`ģ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,ḩ:`ḩ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ķ:`ķ`,ĺ:`ĺ`,ľ:`ľ`,ļ:`ļ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ņ:`ņ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ŗ:`ŗ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ş:`ş`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ţ:`ţ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Ḉ:`Ḉ`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ç:`Ç`,Ď:`Ď`,Ḋ:`Ḋ`,Ḑ:`Ḑ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ḝ:`Ḝ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ȩ:`Ȩ`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ģ:`Ģ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Ḩ:`Ḩ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ķ:`Ķ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ļ:`Ļ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ņ:`Ņ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ŗ:`Ŗ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ş:`Ş`,Ť:`Ť`,Ṫ:`Ṫ`,Ţ:`Ţ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},FJ=class e{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode=`math`,this.gullet=new AJ(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new L(`Expected '`+e+`', got '`+this.fetch().text+`'`,this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken??=this.gullet.expandNextToken(),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set(`\\color`,`\\textcolor`);try{var e=this.parseExpression(!1);return this.expect(`EOF`),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new yq(`}`)),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect(`}`),this.nextToken=t,n}parseExpression(t,n){for(var r=[];;){this.mode===`math`&&this.consumeSpaces();var i=this.fetch();if(e.endOfExpression.has(i.text)||n&&i.text===n||t&&uJ[i.text]&&uJ[i.text].infix)break;var a=this.parseAtom(n);if(!a)break;a.type!==`internal`&&r.push(a)}return this.mode===`text`&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){for(var t=-1,n,r=0;r=128)this.settings.strict&&(mU(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:vq.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;ce.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{HJ.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)}}}}}),WJ=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},GJ=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:WJ,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{HJ.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)}}}}}),KJ=Tp.create({name:`Mathematics`,addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[UJ.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),GJ.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}});function qJ(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;cH({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 KJ.configure({katexOptions:{throwOnError:!1,strict:!1,trust:!1},inlineOptions:{onClick:n(`inline`)},blockOptions:{onClick:n(`block`)}})}function JJ({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r=`@`}){return{editor:e,char:r,pluginKey:new Un,command:({editor:e,range:t,props:i})=>{var a,o;let s=e.view.state.selection.$to.nodeAfter;s!=null&&(a=s.text)!=null&&a.startsWith(` `)&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:n,attrs:{...i,mentionSuggestionChar:r}},{type:`text`,text:` `}]).run(),(o=e.view.dom.ownerDocument.defaultView)==null||(o=o.getSelection())==null||o.collapseToEnd()},allow:({state:e,range:t})=>{let r=e.doc.resolve(t.from),i=e.schema.nodes[n];return!!r.parent.type.contentMatch.matchType(i)},...t}}function YJ(e){return(e.options.suggestions.length?e.options.suggestions:[e.options.suggestion]).map(t=>JJ({editor:e.editor,overrideSuggestionOptions:t,extensionName:e.name,char:t.char}))}function XJ(e,t){let n=YJ(e);return n.find(e=>e.char===t)||(n.length?n[0]:null)}var ZJ=Jp.create({name:`mention`,priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:e,suggestion:t}){return`${t?.char??`@`}${e.attrs.label??e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:t,suggestion:n}){return[`span`,A(this.HTMLAttributes,e.HTMLAttributes),`${n?.char??`@`}${t.attrs.label??t.attrs.id}`]},suggestions:[],suggestion:{}}},group:`inline`,inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute(`data-id`),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute(`data-label`),renderHTML:e=>e.label?{"data-label":e.label}:{}},mentionSuggestionChar:{default:`@`,parseHTML:e=>e.getAttribute(`data-mention-suggestion-char`),renderHTML:e=>({"data-mention-suggestion-char":e.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=XJ(this,e.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn(`renderLabel is deprecated use renderText and renderHTML instead`),[`span`,A({"data-type":this.name},this.options.HTMLAttributes,t),this.options.renderLabel({options:this.options,node:e,suggestion:n})];let r={...this.options};r.HTMLAttributes=A({"data-type":this.name},this.options.HTMLAttributes,t);let i=this.options.renderHTML({options:r,node:e,suggestion:n});return typeof i==`string`?[`span`,A({"data-type":this.name},this.options.HTMLAttributes,t),i]:i},...$f({nodeName:`mention`,name:`@`,selfClosing:!0,allowedAttributes:[`id`,`label`,{name:`mentionSuggestionChar`,skipIfDefault:`@`}],parseAttributes:e=>{let t={},n=/(?:^|\s)(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;r!==null;){let[,i,a,o]=r;t[i===`char`?`mentionSuggestionChar`:i]=a??o,r=n.exec(e)}return t},serializeAttributes:e=>Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e===`mentionSuggestionChar`?`char`:e}="${t}"`).join(` `)}),renderText({node:e}){let t={options:this.options,node:e,suggestion:XJ(this,e.attrs.mentionSuggestionChar)};return this.options.renderLabel===void 0?this.options.renderText(t):(console.warn(`renderLabel is deprecated use renderText and renderHTML instead`),this.options.renderLabel(t))},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1,{selection:r}=t,{empty:i,anchor:a}=r;if(!i)return!1;let o=new ce,s=0;return t.doc.nodesBetween(a-1,a,(e,t)=>{if(e.type.name===this.name)return n=!0,o=e,s=t,!1}),n&&e.insertText(this.options.deleteTriggerWithBackspace?``:o.attrs.mentionSuggestionChar,s,s+o.nodeSize),n})}},addProseMirrorPlugins(){return YJ(this).map(BV)}});function QJ(e,t){return ZJ.configure({HTMLAttributes:{class:`dw-mention`},renderText:({node:e})=>`@${e.attrs.label??e.attrs.id}`,suggestion:{char:`@`,allow:()=>!!t,findSuggestionMatch:t=>{let n=EV({...t,allowSpaces:!0});return n&&xV(n.query,e)?n:EV({...t,allowSpaces:!1})},items:async({query:n})=>{if(!t)return[];let r=bV(n,e,!!t.me).map(e=>({date:e})),i=(await t.search(n).catch(()=>[])).map(e=>({person:e}));return n.trim()?[...r,...i].slice(0,8):[...i.slice(0,6),...r]},render:Uj({label:e.mentions,empty:e.noPeople,toItem:t=>`person`in t?{label:t.person.label,description:t.person.hint,icon:`at`}:{label:vV(t.date.date,e),description:t.date.remind?`${e.dates.remindMe} · ${yV(t.date.date,e)}`:yV(t.date.date,e),icon:t.date.remind?`bell`:`calendar`},pick:(e,n)=>{`person`in n?e.command({id:n.person.id,label:n.person.label}):wV(e.editor,e.range,n.date,t?.me)}})}})}var $J=`flowchart LR + Idea --> Draft --> Review --> Published`,eY=null;function tY(e){return eY??=e().then(e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:document.documentElement.classList.contains(`dark`)?`dark`:`neutral`,fontFamily:`inherit`}),e)),eY}var nY=0;async function rY(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 tY(r)).render(`dw-mermaid-${++nY}`,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 iY=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=$J)=>({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 rY(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;cH({anchor:a,value:s,label:c.mermaid,multiline:!0,monospace:!0,labels:{done:c.done,cancel:c.cancel,remove:c.remove},onInput:e=>void rY(o,e,r,i),onSave:n=>{t.chain().setNodeSelection(e).updateAttributes(`mermaid`,{code:n}).run(),rY(o,n,r,i)},onRemove:()=>t.chain().setNodeSelection(e).deleteSelection().focus().run(),onCancel:()=>void rY(o,s,r,i)})}),{dom:a,update:e=>e.type.name===`mermaid`&&(e.attrs.code!==s&&(s=String(e.attrs.code),rY(o,s,r,i)),!0),ignoreMutation:()=>!0,stopEvent:()=>!1}}}});function aY(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 oY(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(`columns`,`columns`,[`layout`,`side by side`,`split`,`grid`,`multi-column`],()=>{}),children:[2,3,4].map(e=>o(`columns${e}`,`columns`,[`columns`,`layout`,`side by side`,String(e)],(t,n)=>t.chain().focus().deleteRange(n).insertColumns(e).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().focus().deleteRange(r).run(),hH(t,e,a,n)}),o(`linkCard`,`link`,[`bookmark`,`preview`,`card`,`url`,`web`],(t,r)=>{t.chain().focus().deleteRange(r).run(),gH(t,e,a,n)})],c=e=>{let t=new Date;return mV(new Date(t.getFullYear(),t.getMonth(),t.getDate()+e))};if(s.push(o(`today`,`calendar`,[`date`,`day`],(e,t)=>wV(e,t,{date:c(0),remind:!1})),o(`tomorrow`,`calendar`,[`date`,`day`],(e,t)=>wV(e,t,{date:c(1),remind:!1})),o(`yesterday`,`calendar`,[`date`,`day`],(e,t)=>wV(e,t,{date:c(-1),remind:!1})),o(`now`,`clock`,[`time`,`date`,`timestamp`],(t,n)=>{wV(t,n,{date:c(0),remind:!1});let r=new Intl.DateTimeFormat(e.locale,{hour:`numeric`,minute:`2-digit`}).format(new Date);t.chain().focus().insertContent(`${r} `).run()})),r&&(s.push(o(`pageLink`,`link`,[`page`,`link`,`[[`,`wiki`],(e,t)=>e.chain().focus().deleteRange(t).insertContent(`[[`).run())),s.push(o(`syncedPage`,`copy`,[`embed`,`transclude`,`include`,`mirror`,`![[`],(e,t)=>e.chain().focus().deleteRange(t).insertContent(`![[`).run())),r.create&&s.push(o(`newPage`,`page-plus`,[`page`,`doc`,`subpage`,`create`],(e,t)=>{e.chain().focus().deleteRange(t).run(),KV(e,r,``).catch(n)}))),t?.upload){let e=e=>(r,i)=>{r.chain().focus().deleteRange(i).run(),aY(e).then(e=>CH(r,t,e).catch(n))};s.push(o(`image`,`image`,[`picture`,`photo`,`img`],e(`image/*`)),o(`file`,`paperclip`,[`attachment`,`upload`,`pdf`],e(``)),o(`drawio`,`diagram`,[`diagram`,`diagrams.net`,`draw`,`chart`,`uml`],(e,t)=>e.chain().focus().deleteRange(t).insertDiagram(`drawio`).run())),i&&s.push(o(`excalidraw`,`pencil`,[`drawing`,`sketch`,`whiteboard`,`draw`],(e,t)=>e.chain().focus().deleteRange(t).insertDiagram(`excalidraw`).run()))}return s}function sY(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e=>e.label.toLowerCase().includes(n)||e.id.startsWith(n)||e.keywords.some(e=>e.toLowerCase().startsWith(n));return e.flatMap(e=>{let t=e.children?.filter(r)??[];return t.length?t:r(e)?[e]:[]})}var cY=Tp.create({name:`slashMenu`,addOptions(){return{commands:[],labels:void 0}},addProseMirrorPlugins(){return[VV({editor:this.editor,pluginKey:new Un(`slashMenu`),char:`/`,allowSpaces:!1,startOfLine:!1,allow:({state:e,range:t})=>!e.doc.resolve(t.from).parent.type.spec.code,items:({query:e})=>sY(this.options.commands,e),render:Uj({label:this.options.labels.slashMenu,empty:this.options.labels.noMatches,showQuery:!0,toItem:e=>({label:e.label,description:e.description,icon:e.icon}),children:e=>e.children,pick:(e,t)=>t.run(e.editor,e.range)})})]}}),lY=`suggestInsert`,uY=`suggestDelete`,dY=`suggestionSkip`,fY=new Un(`suggestions`),pY=()=>Math.random().toString(36).slice(2,10);function mY(e,t){return _p.create({name:e,inclusive:!1,excludes:``,priority:1100,addAttributes(){return{id:{default:``,parseHTML:e=>e.getAttribute(`data-suggestion`)??``},author:{default:``,parseHTML:e=>e.getAttribute(`data-author`)??``},name:{default:``,parseHTML:e=>e.getAttribute(`data-name`)??``},at:{default:0,parseHTML:e=>Number(e.getAttribute(`data-at`))||0}}},parseHTML(){return[{tag:`${t}[data-suggestion]`}]},renderHTML({mark:e,HTMLAttributes:n}){let r=e.attrs;return[t,A({class:t===`ins`?`dw-suggest-ins`:`dw-suggest-del`},{"data-suggestion":r.id,"data-author":r.author,"data-name":r.name,"data-at":String(r.at),title:r.name},Object.fromEntries(Object.entries(n).filter(([e])=>e===`class`||e===`style`))),0]}})}var hY=mY(lY,`ins`),gY=mY(uY,`del`),_Y=(e,t)=>e.marks.find(e=>e.type===t);function vY(e,t){let n=new Map;return e.descendants((e,r)=>{if(!e.isInline)return!0;for(let i of e.marks){if(i.type.name!==lY&&i.type.name!==uY)continue;let a=String(i.attrs.id);if(t&&a!==t)continue;let o=n.get(a)??[],s=i.type.name===lY,c=o[o.length-1];c&&c.to===r&&c.insert===s?c.to=r+e.nodeSize:o.push({from:r,to:r+e.nodeSize,insert:s}),n.set(a,o)}return!1}),n}function yY(e,t,n){let r=vY(e.doc,n);if(!r.size)return!1;let i=e.doc.type.schema,a=[];for(let n of r.values())for(let r of n){let n=i.marks[r.insert?lY:uY];r.insert===t?e.removeMark(r.from,r.to,n):a.push(r)}a.sort((e,t)=>t.from-e.from);for(let t of a)e.delete(t.from,t.to);return e.setMeta(dY,!0),!0}function bY(e){let t=!1;return e.descendants(e=>(e.isInline&&(t=!0),!t)),t}function xY(e,t,n,r,i){let a=[];return e.forEach(e=>{if(e.isInline){let o=_Y(e,n);if(o&&o.attrs.author===i)return;a.push(_Y(e,t)?e:e.mark(t.create(r).addToSet(e.marks)))}else a.push(e.copy(xY(e.content,t,n,r,i)))}),s.from(a)}function SY(e,t,n,r){let i=e.resolve(Math.min(Math.max(t,0),e.content.size));for(let e of[i.nodeBefore,i.nodeAfter]){let t=e&&_Y(e,n);if(t&&t.attrs.author===r)return t.attrs}return null}function CY(e,t,n,r){if(!e.steps.length||!e.steps.every(e=>e instanceof Et))return null;let i=n.schema,a=i.marks[lY],o=i.marks[uY],s=n.tr,c=Date.now(),l=null,u=e.steps.length===1;if(e.steps.forEach((n,i)=>{let d=n,f=e.docs[i].slice(d.from,d.to),m=s.mapping.map(e.mapping.slice(i+1).map(d.from,-1),-1),h=d.slice.size;if(h>0&&bY(d.slice.content)){let e=m+h,t=SY(s.doc,m,a,r.id)??SY(s.doc,e,a,r.id)??{id:pY(),author:r.id,name:r.name,at:c};s.doc.nodesBetween(m,e,(n,r)=>{if(!n.isInline)return!0;let i=Math.max(r,m),c=Math.min(r+n.nodeSize,e);return _Y(n,o)&&s.removeMark(i,c,o),s.addMark(i,c,a.create(t)),!1})}let g=0;if(f.size>0&&bY(f.content)){let e=SY(s.doc,m,o,r.id)??SY(s.doc,m+1,o,r.id)??{id:pY(),author:r.id,name:r.name,at:c},t=xY(f.content,o,a,e,r.id);if(bY(t)){let e=new p(t,f.openStart,f.openEnd),n=s.doc.content.size;s.replace(m,m,e),g=s.doc.content.size-n}}if(u){let e=t.selection;l=h>0?m+g+h:e.empty&&e.head===d.to?m:m+g}}),!s.docChanged)return null;if(l!==null){let t=Math.min(Math.max(l,0),s.doc.content.size);s.setSelection(T.near(s.doc.resolve(t),wY(e)))}return s.setMeta(dY,!0),s}function wY(e){return e.steps[0].slice.size>0?1:-1}var TY=Tp.create({name:`suggestions`,addOptions(){return{onSelect:void 0}},addExtensions(){return[hY,gY]},addCommands(){return{setSuggesting:e=>({tr:t,dispatch:n})=>(n&&t.setMeta(fY,{author:e}).setMeta(dY,!0).setMeta(`addToHistory`,!1),!0),acceptSuggestion:e=>({tr:t})=>yY(t,!0,e),rejectSuggestion:e=>({tr:t})=>yY(t,!1,e),acceptAllSuggestions:()=>({tr:e})=>yY(e,!0),rejectAllSuggestions:()=>({tr:e})=>yY(e,!1)}},addProseMirrorPlugins(){let e=()=>this.options.onSelect;return[new D({key:fY,state:{init:()=>({author:null}),apply:(e,t)=>e.getMeta(fY)??t},appendTransaction(e,t,n){let r=fY.getState(n)?.author;if(!r||e.length!==1)return null;let i=e[0];return!i.docChanged||i.getMeta(dY)||i.getMeta(FS)?.isChangeOrigin||i.getMeta(`history$`)||i.getMeta(`isUndoRedo`)?null:CY(i,t,n,r)},props:{attributes:e=>fY.getState(e)?.author?{"data-suggesting":`true`}:{},handleClick(t,n,r){let i=r.target?.closest?.(`[data-suggestion]`),a=i?.getAttribute(`data-suggestion`);return!i||!a||e()?.(a,i),!1}}})]}});function EY(e,t){let n=!0,r=e.firstChild?.childCount??0;return e.forEach(e=>{t===`column`&&e.childCount!==r&&(n=!1),e.forEach(e=>{((t===`row`?e.attrs.rowspan:e.attrs.colspan)??1)>1&&(n=!1)})}),n}function DY(e,t,n){let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r}var OY=e=>{let t=[];return e.forEach(e=>t.push(e)),t};function kY(e,t,n,r,i,a=0){let o=e.doc.nodeAt(t);if(!o||o.type.name!==`table`||!EY(o,n))return null;let c=OY(o),l=n===`row`?c.length:c[0]?.childCount??0;if(r===i||r<0||i<0||r>=l||i>=l)return null;let u=n===`row`?DY(c,r,i):c.map(e=>e.copy(s.fromArray(DY(OY(e),r,i)))),d=e.tr.replaceWith(t,t+o.nodeSize,o.copy(s.fromArray(u))),[f,p]=n===`row`?[i,0]:[Math.min(a,u.length-1),i],m=t+1;for(let e=0;e0;e--)if(n.node(e).type.name===`table`)return{tablePos:n.before(e),row:n.index(e),column:e+1<=n.depth?n.index(e+1):0};return null}var jY=Tp.create({name:`tableMove`,addOptions(){return{labels:null}},addCommands(){let e=e=>t=>({state:n,dispatch:r})=>{let i=AY(n,n.selection.from);if(!i)return!1;let a=e===`row`?i.row:i.column,o=kY(n,i.tablePos,e,a,a+t,i.row);return o?(r?.(o),!0):!1};return{moveTableRow:e(`row`),moveTableColumn:e(`column`)}},addKeyboardShortcuts(){return{"Mod-Alt-ArrowUp":()=>this.editor.commands.moveTableRow(-1),"Mod-Alt-ArrowDown":()=>this.editor.commands.moveTableRow(1),"Mod-Alt-ArrowLeft":()=>this.editor.commands.moveTableColumn(-1),"Mod-Alt-ArrowRight":()=>this.editor.commands.moveTableColumn(1)}},addProseMirrorPlugins(){let e=this.options.labels?.table;return[new D({key:new Un(`tableMove`),view:t=>new MY(t,{row:e?.dragRow??`Drag to move the row`,column:e?.dragColumn??`Drag to move the column`})})]}}),MY=class{view;grips={row:document.createElement(`button`),column:document.createElement(`button`)};line=document.createElement(`div`);cell=null;drag=null;constructor(e,t){this.view=e;for(let e of[`row`,`column`]){let n=this.grips[e];n.type=`button`,n.className=`dw-table-grip dw-table-grip--${e}`,n.contentEditable=`false`,n.setAttribute(`aria-label`,t[e]),n.title=t[e],n.hidden=!0,n.tabIndex=-1,n.addEventListener(`pointerdown`,t=>this.start(t,e)),n.addEventListener(`mouseleave`,this.leave)}this.line.className=`dw-table-drop`,this.line.hidden=!0,e.dom.addEventListener(`mousemove`,this.move),e.dom.addEventListener(`mouseleave`,this.leave)}get host(){let e=this.view.dom.parentElement;return e&&this.line.parentElement!==e&&(e.classList.add(`dw-block-host`),e.append(this.grips.row,this.grips.column,this.line)),e}hide=()=>{this.drag||(this.grips.row.hidden=!0,this.grips.column.hidden=!0,this.cell=null)};leave=e=>{let t=e.relatedTarget;t&&(this.grips.row.contains(t)||this.grips.column.contains(t)||this.view.dom.contains(t))||this.hide()};move=e=>{if(this.drag)return;let t=e.target?.closest?.(`td, th`),n=this.host;if(!this.view.editable||!n||!(t instanceof HTMLTableCellElement)||!this.view.dom.contains(t))return this.hide();let r=this.locate(t),i=r&&this.view.state.doc.nodeAt(r.tablePos);if(!r||!i)return this.hide();this.cell=t;let a=n.getBoundingClientRect(),o=t.closest(`table`).getBoundingClientRect(),s=t.parentElement.getBoundingClientRect(),c=t.getBoundingClientRect(),l=i.childCount>1&&EY(i,`row`),u=(i.firstChild?.childCount??0)>1&&EY(i,`column`);Object.assign(this.grips.row.style,{top:`${s.top-a.top+s.height/2-11}px`,left:`${o.left-a.left-7}px`}),Object.assign(this.grips.column.style,{top:`${o.top-a.top-7}px`,left:`${c.left-a.left+c.width/2-11}px`}),this.grips.row.hidden=!l,this.grips.column.hidden=!u};locate(e){try{return AY(this.view.state,this.view.posAtDOM(e,0))}catch{return null}}start(e,t){let n=this.cell;if(!n||e.button!==0)return;let r=this.locate(n),i=n.parentElement?.parentElement;if(!r||!i)return;e.preventDefault();let a=this.grips[t];a.setPointerCapture(e.pointerId);let o=[...i.children].filter(e=>e instanceof HTMLTableRowElement),s=t===`row`?r.row:r.column,c=t===`row`?o:[...o[0]?.children??[]],l=t===`row`?[o[s]]:o.map(e=>e.children[s]).filter(Boolean);for(let e of l)e.classList.add(`dw-table-dragging`);this.drag={axis:t,tablePos:r.tablePos,from:s,slots:c,dimmed:l,to:s,cursorRow:r.row},a.addEventListener(`pointermove`,this.dragMove),a.addEventListener(`pointerup`,this.drop),a.addEventListener(`pointercancel`,this.cancel)}dragMove=e=>{let t=this.drag,n=this.host;if(!t||!n)return;let r=t.axis===`row`,i=r?e.clientY:e.clientX,a=t.slots.length;for(let[e,n]of t.slots.entries()){let t=n.getBoundingClientRect();if(i<(r?t.top+t.height/2:t.left+t.width/2)){a=e;break}}t.to=a>t.from?a-1:a;let o=n.getBoundingClientRect(),s=t.slots[0].closest(`table`).getBoundingClientRect(),c=t.slots.at(-1).getBoundingClientRect(),l=t.slots[a]?.getBoundingClientRect(),u=r?l?.top??c.bottom:l?.left??c.right;Object.assign(this.line.style,r?{top:`${u-o.top-1}px`,left:`${s.left-o.left}px`,width:`${s.width}px`,height:`2px`}:{top:`${s.top-o.top}px`,left:`${u-o.left-1}px`,width:`2px`,height:`${s.height}px`}),this.line.hidden=t.to===t.from};drop=()=>{let e=this.drag;if(this.cancel(),!e||e.to===e.from)return;let t=kY(this.view.state,e.tablePos,e.axis,e.from,e.to,e.cursorRow);t&&this.view.dispatch(t),this.view.focus()};cancel=()=>{let e=this.drag;for(let t of e?.dimmed??[])t.classList.remove(`dw-table-dragging`);this.drag=null,this.line.hidden=!0;for(let e of Object.values(this.grips))e.removeEventListener(`pointermove`,this.dragMove),e.removeEventListener(`pointerup`,this.drop),e.removeEventListener(`pointercancel`,this.cancel);this.hide()};update(){this.cell&&!this.cell.isConnected&&this.hide()}destroy(){this.cancel();for(let e of Object.values(this.grips))e.remove();this.line.remove(),this.view.dom.removeEventListener(`mousemove`,this.move),this.view.dom.removeEventListener(`mouseleave`,this.leave)}};function NY(e){let t=[];return e.descendants((e,n)=>e.type.name!==`heading`||(t.push({level:Number(e.attrs.level)||1,text:e.textContent.trim(),pos:n}),!1)),t}function PY(e,t){let n=e.view.nodeDOM(t);n instanceof HTMLElement&&n.scrollIntoView({behavior:`smooth`,block:`start`}),e.isEditable&&e.commands.setTextSelection(t+1)}var FY=Jp.create({name:`tableOfContents`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},parseHTML(){return[{tag:`nav[data-type='toc']`}]},renderHTML(){return[`nav`,{"data-type":`toc`}]},addCommands(){return{insertTableOfContents:()=>({commands:e})=>e.insertContent({type:this.name})}},addNodeView(){return({editor:e})=>{let t=this.options.labels.blocks,n=document.createElement(`nav`);n.className=`dw-toc`,n.setAttribute(`data-type`,`toc`),n.setAttribute(`aria-label`,t.toc),n.contentEditable=`false`;let r=document.createElement(`p`);r.className=`dw-toc__title`,r.textContent=t.toc;let i=document.createElement(`ol`);i.className=`dw-toc__list`,n.append(r,i);let a=``,o=()=>{let n=NY(e.state.doc),r=JSON.stringify(n.map(e=>[e.level,e.text]));if(r===a){i.querySelectorAll(`a`).forEach((e,t)=>e.dataset.pos=String(n[t]?.pos??0));return}if(a=r,i.replaceChildren(),!n.length){let e=document.createElement(`li`);e.className=`dw-toc__empty`,e.textContent=t.tocEmpty,i.append(e);return}let o=Math.min(...n.map(e=>e.level));for(let t of n){let n=document.createElement(`li`);n.style.paddingLeft=`${(t.level-o)*1}rem`;let r=document.createElement(`a`);r.href=`#`,r.textContent=t.text||`…`,r.dataset.pos=String(t.pos),r.addEventListener(`click`,t=>{t.preventDefault(),PY(e,Number(r.dataset.pos))}),n.append(r),i.append(n)}};return o(),e.on(`update`,o),{dom:n,update:e=>e.type.name===`tableOfContents`,ignoreMutation:()=>!0,stopEvent:e=>e.target instanceof Element&&!!e.target.closest(`a`),destroy:()=>e.off(`update`,o)}}}}),IY=(e,t)=>{let n=t.view.domAtPos(e).node,r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return r?r.offsetParent!==null:!1},LY=(e,t,n)=>{for(let r=e.depth;r>0;--r){let i=e.node(r),a=t(i),o=IY(e.start(r),n);if(a&&o)return{pos:r>0?e.before(r):0,start:e.start(r),depth:r,node:i}}},RY=(e,t)=>{let{state:n,view:r,extensionManager:i}=e,{schema:a,selection:o}=n,{empty:s,$anchor:c}=o,l=!!i.extensions.find(e=>e.name===`gapCursor`);if(!s||c.parent.type!==a.nodes.detailsSummary||!l||t===`right`&&c.parentOffset!==c.parent.nodeSize-2)return!1;let u=yu(e=>e.type===a.nodes.details)(o);if(!u)return!1;let d=gu(u.node,e=>e.type===a.nodes.detailsContent);if(!d.length||IY(u.start+d[0].pos+1,e))return!1;let f=n.doc.resolve(u.pos+u.node.nodeSize),p=zw.findFrom(f,1,!1);if(!p)return!1;let{tr:m}=n,h=new zw(p);return m.setSelection(h),m.scrollIntoView(),r.dispatch(m),!0},zY=Jp.create({name:`details`,content:`detailsSummary detailsContent`,group:`block`,defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:`is-open`,HTMLAttributes:{},renderToggleButton:({element:e,isOpen:t})=>{e.setAttribute(`aria-label`,t?`Collapse details content`:`Expand details content`)}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:e=>e.hasAttribute(`open`),renderHTML:({open:e})=>e?{open:``}:{}}}:[]},parseHTML(){return[{tag:`details`}]},renderHTML({HTMLAttributes:e}){return[`details`,A(this.options.HTMLAttributes,e),0]},...Xf({nodeName:`details`,content:`block`}),addNodeView(){return({editor:e,getPos:t,node:n,HTMLAttributes:r})=>{let i=document.createElement(`div`),a=A(this.options.HTMLAttributes,r,{"data-type":this.name});Object.entries(a).forEach(([e,t])=>i.setAttribute(e,t));let o=document.createElement(`button`);o.type=`button`;let s=e=>{this.options.renderToggleButton({element:o,...e})};i.append(o);let c=document.createElement(`div`);i.append(c);let l=e=>{let{setToValue:t,node:r=n}=e||{};if(t!==void 0){if(t){if(i.classList.contains(this.options.openClassName))return;i.classList.add(this.options.openClassName)}else{if(!i.classList.contains(this.options.openClassName))return;i.classList.remove(this.options.openClassName)}}else i.classList.toggle(this.options.openClassName);let a=i.classList.contains(this.options.openClassName);s({isOpen:a,node:r});let o=new Event(`toggleDetailsContent`);c.querySelector(`:scope > div[data-type="detailsContent"]`)?.dispatchEvent(o)};return s({isOpen:!!n.attrs.open,node:n}),n.attrs.open&&setTimeout(()=>l()),o.addEventListener(`click`,()=>{if(l(),!this.options.persist)e.commands.focus(void 0,{scrollIntoView:!1});else if(e.isEditable&&typeof t==`function`){let{from:n,to:r}=e.state.selection;e.chain().command(({tr:e})=>{let n=t();if(typeof n!=`number`)return!1;let r=e.doc.nodeAt(n);return r?.type===this.type&&(e.setNodeMarkup(n,void 0,{open:!r.attrs.open}),!0)}).setTextSelection({from:n,to:r}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:i,contentDOM:c,ignoreMutation(e){if(e.type===`selection`)return!1;let t=e.target,n=i.contains(t);return o.contains(t)||!n||i===t},update:e=>e.type===this.type&&(e.attrs.open===void 0?s({isOpen:i.classList.contains(this.options.openClassName),node:e}):l({setToValue:e.attrs.open,node:e}),!0)}}},addCommands(){return{setDetails:()=>({state:e,chain:t})=>{let{schema:n,selection:r}=e,{$from:i,$to:a}=r,o=i.blockRange(a);if(!o)return!1;let s=e.doc.slice(o.start,o.end);if(!n.nodes.detailsContent.contentMatch.matchFragment(s.content))return!1;let c=s.toJSON()?.content||[];return t().insertContentAt({from:o.start,to:o.end},{type:this.name,content:[{type:`detailsSummary`},{type:`detailsContent`,content:c}]}).setTextSelection(o.start+2).run()},unsetDetails:()=>({state:e,chain:t})=>{let{selection:n,schema:r}=e,i=yu(e=>e.type===this.type)(n);if(!i)return!1;let a=gu(i.node,e=>e.type===r.nodes.detailsSummary),o=gu(i.node,e=>e.type===r.nodes.detailsContent);if(!a.length||!o.length)return!1;let s=a[0],c=o[0],l=i.pos,u=e.doc.resolve(l),d={from:l,to:l+i.node.nodeSize},f=c.node.content.toJSON()||[],p=[u.parent.type.contentMatch.defaultType?.create(null,s.node.content).toJSON(),...f];return t().insertContentAt(d,p).setTextSelection(l+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{let{schema:e,selection:t}=this.editor.state,{empty:n,$anchor:r}=t;return!n||r.parent.type!==e.nodes.detailsSummary?!1:r.parentOffset===0?this.editor.commands.unsetDetails():this.editor.commands.command(({tr:e})=>{let t=r.pos-1,n=r.pos;return e.delete(t,n),!0})},Enter:({editor:e})=>{let{state:t,view:n}=e,{schema:r,selection:i}=t,{$head:a}=i;if(a.parent.type!==r.nodes.detailsSummary)return!1;let o=IY(a.after()+1,e),s=o?t.doc.nodeAt(a.after()):a.node(-2);if(!s)return!1;let c=o?0:a.indexAfter(-1),l=Ll(s.contentMatchAt(c));if(!l||!s.canReplaceWith(c,c,l))return!1;let u=l.createAndFill();if(!u)return!1;let d=o?a.after()+1:a.after(-1),f=t.tr.replaceWith(d,d,u),p=f.doc.resolve(d),m=w.near(p,1);return f.setSelection(m),f.scrollIntoView(),n.dispatch(f),!0},ArrowRight:({editor:e})=>RY(e,`right`),ArrowDown:({editor:e})=>RY(e,`down`)}},addProseMirrorPlugins(){return[new D({key:new Un(`detailsSelection`),appendTransaction:(e,t,n)=>{let{editor:r,type:i}=this;if(r.view.composing||!e.some(e=>e.selectionSet)||!t.selection.empty||!n.selection.empty||!sd(n,i.name))return;let{$from:a}=n.selection;if(IY(a.pos,r))return;let o=LY(a,e=>e.type===i,r);if(!o)return;let s=gu(o.node,e=>e.type===n.schema.nodes.detailsSummary);if(!s.length)return;let c=s[0],l=(t.selection.from{let t=document.createElement(`div`),n=A(this.options.HTMLAttributes,e,{"data-type":this.name,hidden:`hidden`});return Object.entries(n).forEach(([e,n])=>t.setAttribute(e,n)),t.addEventListener(`toggleDetailsContent`,()=>{t.toggleAttribute(`hidden`)}),{dom:t,contentDOM:t,ignoreMutation(e){return e.type===`selection`?!1:!t.contains(e.target)||t===e.target},update:e=>e.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let{state:t,view:n}=e,{selection:r}=t,{$from:i,empty:a}=r,o=yu(e=>e.type===this.type)(r);if(!a||!o||!o.node.childCount)return!1;let s=i.index(o.depth),{childCount:c}=o.node;if(c!==s+1)return!1;let l=o.node.type.contentMatch.defaultType?.createAndFill();if(!l)return!1;let u=t.doc.resolve(o.pos+1),d=c-1,f=o.node.child(d),p=u.posAtIndex(d,o.depth);if(!f.eq(l))return!1;let m=i.node(-3);if(!m)return!1;let h=i.indexAfter(-3),g=Ll(m.contentMatchAt(h));if(!g||!m.canReplaceWith(h,h,g))return!1;let _=g.createAndFill();if(!_)return!1;let{tr:v}=t,y=i.after(-2);v.replaceWith(y,y,_);let b=v.doc.resolve(y),x=w.near(b,1);v.setSelection(x);let S=p,C=p+f.nodeSize;return v.delete(S,C),v.scrollIntoView(),n.dispatch(v),!0}}},...Xf({nodeName:`detailsContent`})}),VY=Jp.create({name:`detailsSummary`,content:`text*`,defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`summary`}]},renderHTML({HTMLAttributes:e}){return[`summary`,A(this.options.HTMLAttributes,e),0]},...Xf({nodeName:`detailsSummary`,content:`inline`})});function HY(e){return[zY.configure({persist:!1,HTMLAttributes:{class:`dw-toggle`},renderToggleButton:({element:t,isOpen:n})=>{t.setAttribute(`aria-label`,n?e.blocks.collapse:e.blocks.expand),t.setAttribute(`aria-expanded`,String(n))}}),VY,BY]}function UY(e={}){let t=e.labels??BR,n=null,r=Tp.create({name:`editorRef`,onCreate(){n=this.editor}}),i={host:e.files,labels:t,drawioUrl:e.drawioUrl,loadExcalidraw:e.loadExcalidraw,onError:e.onError},a=[r,Yk.configure({heading:{levels:[1,2,3,4,5,6]},codeBlock:!1,link:{openOnClick:!1,autolink:!0},undoRedo:e.collab||e.syncedDoc||e.rowBody||e.rowFragmentReadOnly?!1:void 0}),hT.configure({placeholder:e.placeholder??`Type '/' for commands…`}),wH.configure({host:e.files}),EH.configure({host:e.files,loadPdf:e.loadPdf,labels:t}),Lj.configure({lineNumbers:e.codeLineNumbers??!1}),jP,AP,LP,RP,...OP(),...kP(),jY.configure({labels:t}),VP.configure({labels:t}),JP.configure({labels:t}),YP.configure({labels:t}),DH.configure({host:e.files,onError:e.onError}),QJ(t,e.mentions),SV.configure({labels:t,me:()=>e.mentions?.me,onOpen:e.onOpenDate}),cY.configure({commands:oY(t,e.files,e.onError,e.pages,!!e.loadExcalidraw,e.links),labels:t}),fV.configure({onSelect:e.onCommentSelect}),TY.configure({onSelect:e.onSuggestionSelect}),qJ(t,()=>n),iY.configure({labels:t,load:e.loadMermaid}),FY.configure({labels:t}),aH.configure(i),oH.configure(i),qV.configure({host:e.pages,labels:t,onNavigate:e.onNavigate}),YV.configure({host:e.syncedPages,pages:e.pages,labels:t,onNavigate:e.onNavigate,nested:t=>UY({syncedDoc:t,files:e.files,links:e.links,onNavigate:e.onNavigate,drawioUrl:e.drawioUrl,loadMermaid:e.loadMermaid,loadPdf:e.loadPdf,codeLineNumbers:e.codeLineNumbers,labels:e.labels,placeholder:``})}),...HY(t),vH.configure({labels:t}),yH.configure({labels:t}),nM.configure({labels:t,link:e.blockLink,onCopied:e.onBlockLinkCopied}),PH,rV.configure({labels:t,doc:e.collab?.provider.doc??e.syncedDoc??e.rowBody?.doc,readOnlyDoc:!!e.syncedDoc,undoScope:!e.rowBody,files:e.files,people:e.mentions,recordLink:e.blockLink,linkedPages:e.syncedPages,pages:e.pages,onNavigate:e.onNavigate,recordPage:e.recordPage,onLinkCopied:e.onBlockLinkCopied,me:()=>{let t=e.mentions?.me;return t?{id:t,name:e.collab?.user.name??``}:null},rowExtensions:n=>{let r=e.collab?.provider.doc??e.syncedDoc??e.rowBody?.doc;return UY({rowBody:n&&r&&!e.syncedDoc?{doc:r,fragment:n}:void 0,files:e.files,mentions:e.mentions,pages:e.pages,links:e.links,onNavigate:e.onNavigate,drawioUrl:e.drawioUrl,loadMermaid:e.loadMermaid,loadExcalidraw:e.loadExcalidraw,loadPdf:e.loadPdf,codeLineNumbers:e.codeLineNumbers,labels:e.labels,placeholder:t.database.bodyPlaceholder,rowFragmentReadOnly:n&&e.syncedDoc?n:void 0})}})],o={trackedOrigins:[rB]};return e.rowBody?a.push(jw.configure({document:e.rowBody.doc,fragment:e.rowBody.fragment,yUndoOptions:o})):e.rowFragmentReadOnly?a.push(jw.configure({fragment:e.rowFragmentReadOnly})):e.syncedDoc?a.push(jw.configure({document:e.syncedDoc})):e.collab&&a.push(jw.configure({document:e.collab.provider.doc,yUndoOptions:o}),Iw.configure({provider:e.collab.provider,user:e.collab.user,render:WY})),a}function WY(e){let t=typeof e.color==`string`&&/^#[0-9a-f]{3,8}$/i.test(e.color)?e.color:`#888`,n=document.createElement(`span`);n.classList.add(`collaboration-carets__caret`),n.style.borderColor=t;let r=document.createElement(`div`);return r.classList.add(`collaboration-carets__label`),r.setAttribute(`aria-hidden`,`true`),r.style.backgroundColor=t,r.textContent=typeof e.name==`string`?e.name:``,n.append(r),n}function GY(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var KY=GY();function qY(e){KY=e}var JY={exec:()=>null};function YY(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(ZY.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var XY=(()=>{try{return!0}catch{return!1}})(),ZY={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},QY=/^(?:[ \t]*(?:\n|$))+/,$Y=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,eX=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,tX=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,nX=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,rX=/(?:[*+-]|\d{1,9}[.)])/,iX=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,aX=YY(iX).replace(/bull/g,rX).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),oX=YY(iX).replace(/bull/g,rX).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),sX=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,cX=/^[^\n]+/,lX=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,uX=YY(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,lX).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),dX=YY(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,rX).getRegex(),fX=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,pX=/\x3C!--(?:-?>|[\s\S]*?(?:-->|$))/,mX=YY(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,pX).replace(`tag`,fX).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),hX=YY(sX).replace(`hr`,tX).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,fX).getRegex(),gX={blockquote:YY(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,hX).getRegex(),code:$Y,def:uX,fences:eX,heading:nX,hr:tX,html:mX,lheading:aX,list:dX,newline:QY,paragraph:hX,table:JY,text:cX},_X=YY(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,tX).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,fX).getRegex(),vX={...gX,lheading:oX,table:_X,paragraph:YY(sX).replace(`hr`,tX).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,_X).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,fX).getRegex()},yX={...gX,html:YY(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,pX).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:JY,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:YY(sX).replace(`hr`,tX).replace(`heading`,` *#{1,6} *[^ +]`).replace(`lheading`,aX).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},bX=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,xX=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,SX=/^( {2,}|\\)\n(?!\s*$)/,CX=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\`+)[^`]+\k(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,XY?"(?`+)[^`]+\k(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),MX=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,NX=YY(MX,`u`).replace(/punct/g,wX).getRegex(),PX=YY(MX,`u`).replace(/punct/g,OX).getRegex(),FX=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,IX=YY(FX,`gu`).replace(/notPunctSpace/g,EX).replace(/punctSpace/g,TX).replace(/punct/g,wX).getRegex(),LX=YY(FX,`gu`).replace(/notPunctSpace/g,AX).replace(/punctSpace/g,kX).replace(/punct/g,OX).getRegex(),RX=YY(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,EX).replace(/punctSpace/g,TX).replace(/punct/g,wX).getRegex(),zX=YY(/\\(punct)/,`gu`).replace(/punct/g,wX).getRegex(),BX=YY(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),VX=YY(pX).replace(`(?:-->|$)`,`-->`).getRegex(),HX=YY(`^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^`).replace(`comment`,VX).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),UX=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,WX=YY(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,UX).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),GX=YY(/^!?\[(label)\]\[(ref)\]/).replace(`label`,UX).replace(`ref`,lX).getRegex(),KX=YY(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,lX).getRegex(),qX=YY(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,GX).replace(`nolink`,KX).getRegex(),JX=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,YX={_backpedal:JY,anyPunctuation:zX,autolink:BX,blockSkip:jX,br:SX,code:xX,del:JY,emStrongLDelim:NX,emStrongRDelimAst:IX,emStrongRDelimUnd:RX,escape:bX,link:WX,nolink:KX,punctuation:DX,reflink:GX,reflinkSearch:qX,tag:HX,text:CX,url:JY},XX={...YX,link:YY(/^!?\[(label)\]\((.*?)\)/).replace(`label`,UX).getRegex(),reflink:YY(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,UX).getRegex()},ZX={...YX,emStrongRDelimAst:LX,emStrongLDelim:PX,url:YY(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,JX).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:YY(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\":`>`,'"':`"`,"'":`'`},nZ=e=>tZ[e];function rZ(e,t){if(t){if(ZY.escapeTest.test(e))return e.replace(ZY.escapeReplace,nZ)}else if(ZY.escapeTestNoEncode.test(e))return e.replace(ZY.escapeReplaceNoEncode,nZ);return e}function iZ(e){try{e=encodeURI(e).replace(ZY.percentDecode,`%`)}catch{return null}return e}function aZ(e,t){let n=e.replace(ZY.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(ZY.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length0?-2:-1}function cZ(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function lZ(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(` `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(` -`)}var BX=class{options;rules;lexer;constructor(e){this.options=e||SY}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:IX(e,` -`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=zX(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=IX(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:IX(t[0],` -`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=IX(t[0],` +`)}var uZ=class{options;rules;lexer;constructor(e){this.options=e||KY}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:oZ(e,` +`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=lZ(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=oZ(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:oZ(t[0],` +`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=oZ(t[0],` `).split(` `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o=d||!l.trim())s+=` `+p.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=` `+l}!u&&!l.trim()&&(u=!0),r+=f+` -`,e=e.substring(f.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let f=null,p;this.options.gfm&&(f=this.rules.other.listIsTask.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(this.rules.other.listReplaceTask,``))),i.items.push({type:`list_item`,raw:r,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e=0;ee.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}if(i.loose)for(let e=0;e({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===` -`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=IX(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=LX(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),RX(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return RX(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},VX=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||SY,this.options.tokenizer=this.options.tokenizer||new BX,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:DY,block:kX.normal,inline:AX.normal};this.options.pedantic?(t.block=kX.pedantic,t.inline=AX.pedantic):this.options.gfm&&(t.block=kX.gfm,t.inline=this.options.breaks?AX.breaks:AX.gfm),this.tokenizer.rules=t}static get rules(){return{block:kX,inline:AX}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(DY.carriageReturn,` -`),this.blockTokens(e,this.tokens);for(let e=0;e(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=` +`,e=e.substring(f.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let f=null,p;this.options.gfm&&(f=this.rules.other.listIsTask.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(this.rules.other.listReplaceTask,``))),i.items.push({type:`list_item`,raw:r,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e=0;ee.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}if(i.loose)for(let e=0;e({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===` +`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=oZ(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=sZ(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),cZ(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return cZ(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},dZ=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||KY,this.options.tokenizer=this.options.tokenizer||new uZ,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:ZY,block:$X.normal,inline:eZ.normal};this.options.pedantic?(t.block=$X.pedantic,t.inline=eZ.pedantic):this.options.gfm&&(t.block=$X.gfm,t.inline=this.options.breaks?eZ.breaks:eZ.gfm),this.tokenizer.rules=t}static get rules(){return{block:$X,inline:eZ}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(ZY.carriageReturn,` +`),this.blockTokens(e,this.tokens);for(let e=0;e(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=` `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(` `)?``:` `)+r.raw,n.text+=` @@ -464,16 +464,16 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length)}else if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(` `)?``:` `)+r.raw,n.text+=` -`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r)}else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if((r=this.tokenizer.escape(e))||(r=this.tokenizer.tag(e))||(r=this.tokenizer.link(e))){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if((r=this.tokenizer.emStrong(e,n,o))||(r=this.tokenizer.codespan(e))||(r=this.tokenizer.br(e))||(r=this.tokenizer.del(e))||(r=this.tokenizer.autolink(e))||!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r)}else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return t}},HX=class{options;parser;constructor(e){this.options=e||SY}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(DY.notSpaceStart)?.[0],i=e.replace(DY.endingNewline,``)+` -`;return r?`
`+(n?i:NX(i,!0))+`
-`:`
`+(n?i:NX(i,!0))+`
+`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r)}else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if((r=this.tokenizer.escape(e))||(r=this.tokenizer.tag(e))||(r=this.tokenizer.link(e))){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if((r=this.tokenizer.emStrong(e,n,o))||(r=this.tokenizer.codespan(e))||(r=this.tokenizer.br(e))||(r=this.tokenizer.del(e))||(r=this.tokenizer.autolink(e))||!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r)}else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return t}},fZ=class{options;parser;constructor(e){this.options=e||KY}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(ZY.notSpaceStart)?.[0],i=e.replace(ZY.endingNewline,``)+` +`;return r?`
`+(n?i:rZ(i,!0))+`
+`:`
`+(n?i:rZ(i,!0))+`
`}blockquote({tokens:e}){return`
${this.parser.parse(e)}
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`${this.parser.parseInline(e)} `}hr(e){return`
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t `+r+` -`}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+NX(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`
  • ${t}
  • +`}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+rZ(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`
  • ${t}
  • `}checkbox({checked:e}){return``}paragraph({tokens:e}){return`

    ${this.parser.parseInline(e)}

    `}table(e){let t=``,n=``;for(let t=0;t${r}`,` @@ -482,15 +482,15 @@ ${this.parser.parse(e)} `}tablerow({text:e}){return` ${e} `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+` -`}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${NX(e,!0)}`}br(e){return`
    `}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=PX(e);if(i===null)return r;e=i;let a=``+r+``,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=PX(e);if(i===null)return NX(n);e=i;let a=`${n}`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:NX(e.text)}},UX=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},WX=class e{options;renderer;textRenderer;constructor(e){this.options=e||SY,this.options.renderer=this.options.renderer||new HX,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new UX}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new HX(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new BX(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new GX;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=GX.passThroughHooks.has(n)?e=>{if(this.defaults.async&&GX.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return VX.lex(e,t??this.defaults)}parser(e,t){return WX.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?VX.lex:VX.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?WX.parse:WX.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?VX.lex:VX.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?WX.parse:WX.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=` -Please report this to https://github.com/markedjs/marked.`,e){let e=`

    An error occurred:

    `+NX(n.message+``,!0)+`
    `;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function qX(e,t){return KX.parse(e,t)}qX.options=qX.setOptions=function(e){return KX.setOptions(e),qX.defaults=KX.defaults,CY(qX.defaults),qX},qX.getDefaults=xY,qX.defaults=SY,qX.use=function(...e){return KX.use(...e),qX.defaults=KX.defaults,CY(qX.defaults),qX},qX.walkTokens=function(e,t){return KX.walkTokens(e,t)},qX.parseInline=KX.parseInline,qX.Parser=WX,qX.parser=WX.parse,qX.Renderer=HX,qX.TextRenderer=UX,qX.Lexer=VX,qX.lexer=VX.lex,qX.Tokenizer=BX,qX.Hooks=GX,qX.parse=qX,qX.options,qX.setOptions,qX.use,qX.walkTokens,qX.parseInline,WX.parse,VX.lex;function JX(e){let t=e??NR;return{...mF,...t.edgeless,colors:{...mF.colors,...t.colors}}}function YX(e){let t=e?.surface;return Array.isArray(t?.elements)?t.elements:[]}function XX(e,t,n){let r={...n,placeholder:n.placeholder??``},i=new Vp({element:e,editable:t.kind!==`json`&&t.editable,content:t.kind===`json`?t.content:void 0,extensions:t.kind===`page`?yY({...r,collab:{provider:t.provider,user:t.user}}):t.kind===`body`?yY({...r,rowBody:{doc:t.doc,fragment:t.fragment}}):yY(r),editorProps:{attributes:{class:`dw-prose`}}});return{destroy:()=>i.destroy(),focus:()=>i.commands.focus(`end`),setEditable:e=>i.setEditable(e&&t.kind!==`json`)}}function ZX(e,t){let n=!!t.provider,r,i=null;if(t.provider)r=t.provider.doc;else{i=new Cv,r=i;let e=t.content;i.transact(()=>ZL(i.getXmlFragment(`default`),e?.content??[]));let n=YX(e);if(n.length){let e=new iR(i,{undo:!1});e.load(n),e.destroy()}}let a={...t};delete a.provider,delete a.content;let o=new SR(e,{doc:r,editable:n&&t.editable,notes:{mount:(e,r)=>{let i=n?r.page?{kind:`page`,provider:t.provider,user:t.user??{name:`?`,color:`#888`},editable:r.editable}:{kind:`body`,doc:r.doc,fragment:r.fragment,editable:r.editable}:{kind:`json`,content:r.page&&t.content?t.content:{type:`doc`,content:XL(r.fragment)}};return t.mountNote?t.mountNote(e,i):XX(e,i,a)}},labels:JX(t.labels),files:t.files,links:t.links,embedSource:iH,styles:t.styles,onStyles:t.onStyles,viewKey:t.viewKey,pageTitle:t.pageTitle,undo:n,onError:t.onError,onComment:t.onComment,onCommentSelect:t.onCommentSelect});return{view:o,setEditable:e=>o.setEditable(n&&e),destroy:()=>{o.destroy(),i?.destroy()}}}function QX(e,t,n){let r=Zj(t),i=VB(t);if(!r&&!i)return()=>{};let a=()=>i?UB(e,i.database,i.row):rM(e,r),o=!1,s,c=()=>{clearTimeout(s),s=setTimeout(()=>{o||e.isDestroyed||!a()||(o=!0,l(),n?.())},50)},l=()=>{e.off(`transaction`,c),clearTimeout(u)},u=setTimeout(l,5e3);return e.on(`transaction`,c),c(),()=>{l(),clearTimeout(s)}}var $X=3e4,eZ=class extends pm{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Fh();this.getLocalState()!==null&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&3e4<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&tZ(this,t,`timeout`)},mm($X/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:Fh()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),tg(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},tZ=(e,t,n)=>{let r=[];for(let n=0;n0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},nZ=(e,t,n=e.states)=>{let r=t.length,i=Fm();j(i,r);for(let a=0;a{let r=hh(t),i=Fh(),a=[],o=[],s=[],c=[],l=M(r);for(let t=0;t0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},iZ=(e,t)=>{j(e,0),qm(e,Jv(t))},aZ=(e,t,n)=>{j(e,1),qm(e,Hv(t,n))},oZ=(e,t,n)=>aZ(t,n,vh(e)),sZ=(e,t,n,r)=>{try{zv(t,vh(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},cZ=(e,t)=>{j(e,2),qm(e,t)},lZ=sZ,uZ=(e,t,n,r,i)=>{let a=M(e);switch(a){case 0:oZ(e,t,n);break;case 1:sZ(e,n,r,i);break;case 2:lZ(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},dZ=0,fZ=1,pZ=4401,mZ=4404,hZ=4409,gZ=class{opts;doc=new Cv;awareness=new eZ(this.doc);status=`connecting`;synced=!1;ws=null;retries=0;retryTimer;destroyed=!1;listeners=new Set;constructor(e){this.opts=e,this.doc.on(`update`,this.onDocUpdate),this.awareness.on(`update`,this.onAwarenessUpdate),e.readOnly&&this.awareness.setLocalState(null),window.addEventListener(`beforeunload`,this.onUnload),this.connect()}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.destroyed||(this.destroyed=!0,this.listeners.clear(),clearTimeout(this.retryTimer),window.removeEventListener(`beforeunload`,this.onUnload),tZ(this.awareness,[this.doc.clientID],`local`),this.doc.off(`update`,this.onDocUpdate),this.awareness.off(`update`,this.onAwarenessUpdate),this.ws?.close(),this.awareness.destroy(),this.doc.destroy(),this.listeners.clear())}set(e,t=this.synced){(e!==this.status||t!==this.synced)&&(this.status=e,this.synced=t,this.listeners.forEach(e=>e()))}connect(){let e=new WebSocket(`${this.opts.url}?page=${encodeURIComponent(this.opts.page)}`);e.binaryType=`arraybuffer`,this.ws=e,e.onopen=()=>{e.send(this.opts.token()??``);let t=Fm();j(t,dZ),iZ(t,this.doc),e.send(Rm(t)),this.awareness.getLocalState()!==null&&this.sendAwareness([this.doc.clientID])},e.onmessage=e=>this.onMessage(new Uint8Array(e.data)),e.onclose=t=>{if(this.ws!==e)return;this.ws=null;let n=[...this.awareness.getStates().keys()].filter(e=>e!==this.doc.clientID);tZ(this.awareness,n,this),this.destroyed||(t.code===pZ||t.code===mZ?this.set(`denied`,!1):t.code===hZ?this.set(`changed`):(this.set(`offline`),this.retryTimer=setTimeout(()=>this.connect(),Math.min(1e3*2**this.retries++,3e4))))}}onMessage(e){let t=hh(e),n=M(t);if(n===dZ){let e=Fm();j(e,dZ);let n=uZ(t,e,this.doc,this);Lm(e)>1&&!this.opts.readOnly&&this.ws?.send(Rm(e)),n===1&&(this.retries=0,this.set(`connected`,!0))}else n===fZ&&rZ(this.awareness,vh(t),this)}onDocUpdate=(e,t)=>{if(t===this||this.opts.readOnly||this.ws?.readyState!==WebSocket.OPEN)return;let n=Fm();j(n,dZ),cZ(n,e),this.ws.send(Rm(n))};onAwarenessUpdate=({added:e,updated:t,removed:n},r)=>{r===this||this.opts.readOnly||this.sendAwareness([...e,...t,...n])};sendAwareness(e){if(this.ws?.readyState!==WebSocket.OPEN)return;let t=Fm();j(t,fZ),qm(t,nZ(this.awareness,e)),this.ws.send(Rm(t))}onUnload=()=>tZ(this.awareness,[this.doc.clientID],`unload`)},_Z=`.dw-db-peek, .dw-db-pop, .dw-block-menu`,vZ={bold:e=>e.chain().focus().toggleBold().run(),italic:e=>e.chain().focus().toggleItalic().run(),strike:e=>e.chain().focus().toggleStrike().run(),code:e=>e.chain().focus().toggleCode().run(),heading1:e=>e.chain().focus().toggleHeading({level:1}).run(),heading2:e=>e.chain().focus().toggleHeading({level:2}).run(),heading3:e=>e.chain().focus().toggleHeading({level:3}).run(),bulletList:e=>e.chain().focus().toggleBulletList().run(),orderedList:e=>e.chain().focus().toggleOrderedList().run(),blockquote:e=>e.chain().focus().toggleBlockquote().run(),codeBlock:e=>e.chain().focus().toggleCodeBlock().run(),underline:e=>e.chain().focus().toggleUnderline().run(),taskList:e=>e.chain().focus().toggleTaskList().run(),callout:e=>e.isActive(`callout`)?e.chain().focus().unsetCallout().run():e.chain().focus().setCallout().run(),table:e=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),undo:e=>e.chain().focus().undo().run(),redo:e=>e.chain().focus().redo().run()},yZ=[[`bold`,e=>e.isActive(`bold`)],[`italic`,e=>e.isActive(`italic`)],[`strike`,e=>e.isActive(`strike`)],[`code`,e=>e.isActive(`code`)],[`heading1`,e=>e.isActive(`heading`,{level:1})],[`heading2`,e=>e.isActive(`heading`,{level:2})],[`heading3`,e=>e.isActive(`heading`,{level:3})],[`bulletList`,e=>e.isActive(`bulletList`)],[`orderedList`,e=>e.isActive(`orderedList`)],[`blockquote`,e=>e.isActive(`blockquote`)],[`codeBlock`,e=>e.isActive(`codeBlock`)],[`underline`,e=>e.isActive(`underline`)],[`taskList`,e=>e.isActive(`taskList`)],[`callout`,e=>e.isActive(`callout`)],[`table`,e=>e.isActive(`table`)]],bZ=class{el;send;editor;provider=null;lastState=``;editable=!0;overlay=!1;overlays=new MutationObserver(()=>this.reportOverlay());inner=null;onFocusIn=e=>this.track(e.target);canvas=null;canvasEl=null;mode=`page`;lastContent=null;title=``;labels={...NR,blocks:{...NR.blocks}};transcribeOn=!1;words=null;pendingTranscripts=new Map;nextTranscript=1;picked=null;files={resolve:e=>e};constructor(e,t){this.el=e,this.send=t,Object.defineProperty(this.files,"transcribe",{get:()=>this.transcribeOn?(e,t)=>this.requestTranscript(e,t):void 0}),this.editor=this.create({}),this.overlays.observe(document.body,{childList:!0}),document.addEventListener(`focusin`,this.onFocusIn),t({type:`ready`,version:4})}receive(e){try{let t=typeof e==`string`?JSON.parse(e):e;this.handle(t)}catch(e){this.send({type:`error`,message:e instanceof Error?e.message:String(e)})}}get content(){return this.editor.getJSON()}destroy(){this.overlays.disconnect(),document.removeEventListener(`focusin`,this.onFocusIn),this.setInner(null),this.closeCanvas(),this.editor.destroy(),this.provider?.destroy()}handle(e){switch(e.type){case`hello`:this.send({type:`ready`,version:4}),this.lastState=``,this.reportState();return;case`setContent`:this.lastContent=e.content,this.editor.commands.setContent(e.content??``,{emitUpdate:!1}),this.reportState(),this.mode===`edgeless`&&!this.provider&&this.openCanvas();return;case`setEditable`:this.editable=e.editable,this.editor.setEditable(e.editable),this.canvas?.setEditable(e.editable);return;case`setTheme`:document.documentElement.classList.toggle(`dark`,e.dark);return;case`setLayout`:{let t=document.documentElement.classList;t.toggle(`dw-full-width`,e.fullWidth),t.toggle(`dw-font-serif`,e.font===`serif`),t.toggle(`dw-font-mono`,e.font===`mono`);return}case`command`:{let t=vZ[e.command];if(!t)throw Error(`unknown command ${e.command}`);t(this.target);return}case`focus`:this.editor.commands.focus();return;case`blur`:this.editor.commands.blur();return;case`connect`:this.connect(e);return;case`follow`:QX(this.editor,e.hash);return;case`setMode`:this.mode=e.mode===`edgeless`?`edgeless`:`page`,typeof e.title==`string`&&(this.title=e.title),this.mode===`edgeless`?this.openCanvas():this.closeCanvas();return;case`dismiss`:[...document.querySelectorAll(_Z)].at(-1)?.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Escape`,bubbles:!0,cancelable:!0}));return;case`setAi`:this.transcribeOn=e.transcribe,this.words=e.words,Object.assign(this.labels.blocks,{transcribe:e.words.transcribe,transcribeHint:e.words.transcribeHint,transcribing:e.words.transcribing,transcribeFailed:e.words.transcribeFailed}),SZ(this.editor);return;case`getSelection`:{let e=this.target,{from:t,to:n}=e.state.selection;this.picked={editor:e,from:t,to:n},this.send({type:`selection`,text:e.state.doc.textBetween(t,n,` +`}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${rZ(e,!0)}`}br(e){return`
    `}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=iZ(e);if(i===null)return r;e=i;let a=``+r+``,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=iZ(e);if(i===null)return rZ(n);e=i;let a=`${n}`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:rZ(e.text)}},pZ=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},mZ=class e{options;renderer;textRenderer;constructor(e){this.options=e||KY,this.options.renderer=this.options.renderer||new fZ,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new pZ}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new fZ(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new uZ(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new hZ;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=hZ.passThroughHooks.has(n)?e=>{if(this.defaults.async&&hZ.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return dZ.lex(e,t??this.defaults)}parser(e,t){return mZ.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?dZ.lex:dZ.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?mZ.parse:mZ.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?dZ.lex:dZ.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?mZ.parse:mZ.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=` +Please report this to https://github.com/markedjs/marked.`,e){let e=`

    An error occurred:

    `+rZ(n.message+``,!0)+`
    `;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function _Z(e,t){return gZ.parse(e,t)}_Z.options=_Z.setOptions=function(e){return gZ.setOptions(e),_Z.defaults=gZ.defaults,qY(_Z.defaults),_Z},_Z.getDefaults=GY,_Z.defaults=KY,_Z.use=function(...e){return gZ.use(...e),_Z.defaults=gZ.defaults,qY(_Z.defaults),_Z},_Z.walkTokens=function(e,t){return gZ.walkTokens(e,t)},_Z.parseInline=gZ.parseInline,_Z.Parser=mZ,_Z.parser=mZ.parse,_Z.Renderer=fZ,_Z.TextRenderer=pZ,_Z.Lexer=dZ,_Z.lexer=dZ.lex,_Z.Tokenizer=uZ,_Z.Hooks=hZ,_Z.parse=_Z,_Z.options,_Z.setOptions,_Z.use,_Z.walkTokens,_Z.parseInline,mZ.parse,dZ.lex;function vZ(e){let t=e??BR;return{...xF,...t.edgeless,colors:{...xF.colors,...t.colors}}}function yZ(e){let t=e?.surface;return Array.isArray(t?.elements)?t.elements:[]}function bZ(e,t,n){let r={...n,placeholder:n.placeholder??``},i=new Vp({element:e,editable:t.kind!==`json`&&t.editable,content:t.kind===`json`?t.content:void 0,extensions:t.kind===`page`?UY({...r,collab:{provider:t.provider,user:t.user}}):t.kind===`body`?UY({...r,rowBody:{doc:t.doc,fragment:t.fragment}}):UY(r),editorProps:{attributes:{class:`dw-prose`}}});return{destroy:()=>i.destroy(),focus:()=>i.commands.focus(`end`),setEditable:e=>i.setEditable(e&&t.kind!==`json`)}}function xZ(e,t){let n=!!t.provider,r,i=null;if(t.provider)r=t.provider.doc;else{i=new Cv,r=i;let e=t.content;i.transact(()=>iR(i.getXmlFragment(`default`),e?.content??[]));let n=yZ(e);if(n.length){let e=new dR(i,{undo:!1});e.load(n),e.destroy()}}let a={...t};delete a.provider,delete a.content;let o=new kR(e,{doc:r,editable:n&&t.editable,notes:{mount:(e,r)=>{let i=n?r.page?{kind:`page`,provider:t.provider,user:t.user??{name:`?`,color:`#888`},editable:r.editable}:{kind:`body`,doc:r.doc,fragment:r.fragment,editable:r.editable}:{kind:`json`,content:r.page&&t.content?t.content:{type:`doc`,content:rR(r.fragment)}};return t.mountNote?t.mountNote(e,i):bZ(e,i,a)}},labels:vZ(t.labels),files:t.files,links:t.links,embedSource:dH,styles:t.styles,onStyles:t.onStyles,viewKey:t.viewKey,pageTitle:t.pageTitle,undo:n,onError:t.onError,onComment:t.onComment,onCommentSelect:t.onCommentSelect});return{view:o,setEditable:e=>o.setEditable(n&&e),destroy:()=>{o.destroy(),i?.destroy()}}}function SZ(e,t,n){let r=Yj(t),i=JB(t);if(!r&&!i)return()=>{};let a=()=>i?XB(e,i.database,i.row):tM(e,r),o=!1,s,c=()=>{clearTimeout(s),s=setTimeout(()=>{o||e.isDestroyed||!a()||(o=!0,l(),n?.())},50)},l=()=>{e.off(`transaction`,c),clearTimeout(u)},u=setTimeout(l,5e3);return e.on(`transaction`,c),c(),()=>{l(),clearTimeout(s)}}var CZ=3e4,wZ=class extends pm{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Fh();this.getLocalState()!==null&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&3e4<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&TZ(this,t,`timeout`)},mm(CZ/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:Fh()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),tg(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},TZ=(e,t,n)=>{let r=[];for(let n=0;n0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},EZ=(e,t,n=e.states)=>{let r=t.length,i=Fm();j(i,r);for(let a=0;a{let r=hh(t),i=Fh(),a=[],o=[],s=[],c=[],l=M(r);for(let t=0;t0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},OZ=(e,t)=>{j(e,0),qm(e,Jv(t))},kZ=(e,t,n)=>{j(e,1),qm(e,Hv(t,n))},AZ=(e,t,n)=>kZ(t,n,vh(e)),jZ=(e,t,n,r)=>{try{zv(t,vh(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},MZ=(e,t)=>{j(e,2),qm(e,t)},NZ=jZ,PZ=(e,t,n,r,i)=>{let a=M(e);switch(a){case 0:AZ(e,t,n);break;case 1:jZ(e,n,r,i);break;case 2:NZ(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},FZ=0,IZ=1,LZ=4401,RZ=4404,zZ=4409,BZ=class{opts;doc=new Cv;awareness=new wZ(this.doc);status=`connecting`;synced=!1;ws=null;retries=0;retryTimer;destroyed=!1;listeners=new Set;constructor(e){this.opts=e,this.doc.on(`update`,this.onDocUpdate),this.awareness.on(`update`,this.onAwarenessUpdate),e.readOnly&&this.awareness.setLocalState(null),window.addEventListener(`beforeunload`,this.onUnload),this.connect()}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.destroyed||(this.destroyed=!0,this.listeners.clear(),clearTimeout(this.retryTimer),window.removeEventListener(`beforeunload`,this.onUnload),TZ(this.awareness,[this.doc.clientID],`local`),this.doc.off(`update`,this.onDocUpdate),this.awareness.off(`update`,this.onAwarenessUpdate),this.ws?.close(),this.awareness.destroy(),this.doc.destroy(),this.listeners.clear())}set(e,t=this.synced){(e!==this.status||t!==this.synced)&&(this.status=e,this.synced=t,this.listeners.forEach(e=>e()))}connect(){let e=new WebSocket(`${this.opts.url}?page=${encodeURIComponent(this.opts.page)}`);e.binaryType=`arraybuffer`,this.ws=e,e.onopen=()=>{e.send(this.opts.token()??``);let t=Fm();j(t,FZ),OZ(t,this.doc),e.send(Rm(t)),this.awareness.getLocalState()!==null&&this.sendAwareness([this.doc.clientID])},e.onmessage=e=>this.onMessage(new Uint8Array(e.data)),e.onclose=t=>{if(this.ws!==e)return;this.ws=null;let n=[...this.awareness.getStates().keys()].filter(e=>e!==this.doc.clientID);TZ(this.awareness,n,this),this.destroyed||(t.code===LZ||t.code===RZ?this.set(`denied`,!1):t.code===zZ?this.set(`changed`):(this.set(`offline`),this.retryTimer=setTimeout(()=>this.connect(),Math.min(1e3*2**this.retries++,3e4))))}}onMessage(e){let t=hh(e),n=M(t);if(n===FZ){let e=Fm();j(e,FZ);let n=PZ(t,e,this.doc,this);Lm(e)>1&&!this.opts.readOnly&&this.ws?.send(Rm(e)),n===1&&(this.retries=0,this.set(`connected`,!0))}else n===IZ&&DZ(this.awareness,vh(t),this)}onDocUpdate=(e,t)=>{if(t===this||this.opts.readOnly||this.ws?.readyState!==WebSocket.OPEN)return;let n=Fm();j(n,FZ),MZ(n,e),this.ws.send(Rm(n))};onAwarenessUpdate=({added:e,updated:t,removed:n},r)=>{r===this||this.opts.readOnly||this.sendAwareness([...e,...t,...n])};sendAwareness(e){if(this.ws?.readyState!==WebSocket.OPEN)return;let t=Fm();j(t,IZ),qm(t,EZ(this.awareness,e)),this.ws.send(Rm(t))}onUnload=()=>TZ(this.awareness,[this.doc.clientID],`unload`)},VZ=`.dw-db-peek, .dw-db-pop, .dw-block-menu`,HZ={bold:e=>e.chain().focus().toggleBold().run(),italic:e=>e.chain().focus().toggleItalic().run(),strike:e=>e.chain().focus().toggleStrike().run(),code:e=>e.chain().focus().toggleCode().run(),heading1:e=>e.chain().focus().toggleHeading({level:1}).run(),heading2:e=>e.chain().focus().toggleHeading({level:2}).run(),heading3:e=>e.chain().focus().toggleHeading({level:3}).run(),bulletList:e=>e.chain().focus().toggleBulletList().run(),orderedList:e=>e.chain().focus().toggleOrderedList().run(),blockquote:e=>e.chain().focus().toggleBlockquote().run(),codeBlock:e=>e.chain().focus().toggleCodeBlock().run(),underline:e=>e.chain().focus().toggleUnderline().run(),taskList:e=>e.chain().focus().toggleTaskList().run(),callout:e=>e.isActive(`callout`)?e.chain().focus().unsetCallout().run():e.chain().focus().setCallout().run(),table:e=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),undo:e=>e.chain().focus().undo().run(),redo:e=>e.chain().focus().redo().run()},UZ=[[`bold`,e=>e.isActive(`bold`)],[`italic`,e=>e.isActive(`italic`)],[`strike`,e=>e.isActive(`strike`)],[`code`,e=>e.isActive(`code`)],[`heading1`,e=>e.isActive(`heading`,{level:1})],[`heading2`,e=>e.isActive(`heading`,{level:2})],[`heading3`,e=>e.isActive(`heading`,{level:3})],[`bulletList`,e=>e.isActive(`bulletList`)],[`orderedList`,e=>e.isActive(`orderedList`)],[`blockquote`,e=>e.isActive(`blockquote`)],[`codeBlock`,e=>e.isActive(`codeBlock`)],[`underline`,e=>e.isActive(`underline`)],[`taskList`,e=>e.isActive(`taskList`)],[`callout`,e=>e.isActive(`callout`)],[`table`,e=>e.isActive(`table`)]],WZ=class{el;send;editor;provider=null;lastState=``;editable=!0;overlay=!1;overlays=new MutationObserver(()=>this.reportOverlay());inner=null;onFocusIn=e=>this.track(e.target);canvas=null;canvasEl=null;mode=`page`;lastContent=null;title=``;labels={...BR,blocks:{...BR.blocks}};transcribeOn=!1;words=null;pendingTranscripts=new Map;nextTranscript=1;picked=null;files={resolve:e=>e};constructor(e,t){this.el=e,this.send=t,Object.defineProperty(this.files,"transcribe",{get:()=>this.transcribeOn?(e,t)=>this.requestTranscript(e,t):void 0}),this.editor=this.create({}),this.overlays.observe(document.body,{childList:!0}),document.addEventListener(`focusin`,this.onFocusIn),t({type:`ready`,version:4})}receive(e){try{let t=typeof e==`string`?JSON.parse(e):e;this.handle(t)}catch(e){this.send({type:`error`,message:e instanceof Error?e.message:String(e)})}}get content(){return this.editor.getJSON()}destroy(){this.overlays.disconnect(),document.removeEventListener(`focusin`,this.onFocusIn),this.setInner(null),this.closeCanvas(),this.editor.destroy(),this.provider?.destroy()}handle(e){switch(e.type){case`hello`:this.send({type:`ready`,version:4}),this.lastState=``,this.reportState();return;case`setContent`:this.lastContent=e.content,this.editor.commands.setContent(e.content??``,{emitUpdate:!1}),this.reportState(),this.mode===`edgeless`&&!this.provider&&this.openCanvas();return;case`setEditable`:this.editable=e.editable,this.editor.setEditable(e.editable),this.canvas?.setEditable(e.editable);return;case`setTheme`:document.documentElement.classList.toggle(`dark`,e.dark);return;case`setLayout`:{let t=document.documentElement.classList;t.toggle(`dw-full-width`,e.fullWidth),t.toggle(`dw-font-serif`,e.font===`serif`),t.toggle(`dw-font-mono`,e.font===`mono`);return}case`command`:{let t=HZ[e.command];if(!t)throw Error(`unknown command ${e.command}`);t(this.target);return}case`focus`:this.editor.commands.focus();return;case`blur`:this.editor.commands.blur();return;case`connect`:this.connect(e);return;case`follow`:SZ(this.editor,e.hash);return;case`setMode`:this.mode=e.mode===`edgeless`?`edgeless`:`page`,typeof e.title==`string`&&(this.title=e.title),this.mode===`edgeless`?this.openCanvas():this.closeCanvas();return;case`dismiss`:[...document.querySelectorAll(VZ)].at(-1)?.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Escape`,bubbles:!0,cancelable:!0}));return;case`setAi`:this.transcribeOn=e.transcribe,this.words=e.words,Object.assign(this.labels.blocks,{transcribe:e.words.transcribe,transcribeHint:e.words.transcribeHint,transcribing:e.words.transcribing,transcribeFailed:e.words.transcribeFailed}),KZ(this.editor);return;case`getSelection`:{let e=this.target,{from:t,to:n}=e.state.selection;this.picked={editor:e,from:t,to:n},this.send({type:`selection`,text:e.state.doc.textBetween(t,n,` `),before:e.state.doc.textBetween(Math.max(0,t-4e3),t,` -`)});return}case`insertMarkdown`:this.insertMarkdown(e.markdown,e.mode);return;case`transcribed`:{let t=this.pendingTranscripts.get(e.id);if(!t)return;this.pendingTranscripts.delete(e.id),e.result&&this.words?t.resolve(Qp(e.result,this.words,xZ)):t.reject(Error(e.error||this.labels.blocks.transcribeFailed));return}default:throw Error(`unknown message ${e.type}`)}}requestTranscript(e,t){let n=this.nextTranscript++;return new Promise((r,i)=>{this.pendingTranscripts.set(n,{resolve:r,reject:i}),this.send({type:`transcribe`,id:n,src:e,name:t})})}insertMarkdown(e,t){let n=this.picked,r=n&&!n.editor.isDestroyed?n.editor:this.target,i=xZ(e);if(!i.trim())return;let a=r.state.doc.content.size,o=Math.min(n?.from??r.state.selection.from,a),s=Math.min(n?.to??r.state.selection.to,a);if(t===`replace`)r.chain().focus().insertContentAt({from:o,to:s},i).run();else{let e=r.state.doc.resolve(s);r.chain().focus().insertContentAt(e.depth>=1?e.after(1):s,i).run()}this.picked=null}connect(e){this.provider?.destroy();let t=new gZ({url:e.url,page:e.page,token:()=>e.token});t.onChange(()=>this.send({type:`collab`,status:t.status})),this.provider=t,this.editor.destroy(),this.editor=this.create({collab:{provider:t,user:e.user}}),this.mode===`edgeless`&&this.openCanvas()}openCanvas(){this.closeCanvas();let e=document.createElement(`div`);e.className=`dw-bridge-canvas`,document.body.append(e),this.canvasEl=e,this.el.hidden=!0,this.canvas=ZX(e,{provider:this.provider??void 0,content:this.provider?void 0:this.lastContent??this.editor.getJSON(),editable:this.editable&&!!this.provider,pageTitle:()=>this.title,onNavigate:e=>this.send({type:`navigate`,path:e}),onError:e=>this.send({type:`error`,message:e instanceof Error?e.message:String(e)})})}closeCanvas(){this.canvas?.destroy(),this.canvas=null,this.canvasEl?.remove(),this.canvasEl=null,this.el.hidden=!1}create(e){return this.el.replaceChildren(),new Vp({element:this.el,editable:this.editable,extensions:yY({...e,files:this.files,labels:this.labels,onNavigate:e=>this.send({type:`navigate`,path:e})}),editorProps:{attributes:{class:`dw-prose`}},onUpdate:({editor:e})=>this.send({type:`change`,content:e.getJSON()}),onSelectionUpdate:()=>this.reportState(),onTransaction:()=>this.reportState(),onFocus:()=>this.reportState(),onBlur:()=>this.reportState()})}get target(){return this.inner&&!this.inner.isDestroyed?this.inner:this.editor}track(e){let t=(e instanceof Element?e.closest(`.ProseMirror`):null)?.editor;t&&(this.setInner(t===this.editor?null:t),this.reportState())}innerChanged=()=>this.reportState();innerGone=()=>{this.setInner(null),this.reportState()};setInner(e){if(e!==this.inner){if(this.inner){for(let e of[`selectionUpdate`,`transaction`,`focus`,`blur`])this.inner.off(e,this.innerChanged);this.inner.off(`destroy`,this.innerGone)}if(this.inner=e,e){for(let t of[`selectionUpdate`,`transaction`,`focus`,`blur`])e.on(t,this.innerChanged);e.on(`destroy`,this.innerGone)}}}reportOverlay(){let e=document.querySelector(_Z)!==null;e!==this.overlay&&(this.overlay=e,this.send({type:`overlay`,open:e}))}reportState(){let e=this.target;if(e.isDestroyed)return;let t={active:yZ.filter(([,t])=>t(e)).map(([e])=>e),canUndo:e.can().undo(),canRedo:e.can().redo(),focused:e.isFocused},n=JSON.stringify(t);n!==this.lastState&&(this.lastState=n,this.send({type:`state`,state:t}))}};function xZ(e){return qX.parse(e.trim(),{async:!1,gfm:!0})}function SZ(e){if(e.isDestroyed)return;let t=e.view.props.nodeViews??{},n=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)]));e.view.setProps({nodeViews:n})}function CZ(e){let t=JSON.stringify(e);window.DocwellNative?window.DocwellNative.postMessage(t):(window.parent.postMessage(t,`*`),console.debug(`[docwell bridge]`,e))}var wZ=new bZ(document.getElementById(`editor`),CZ);window.docwell={receive:e=>wZ.receive(e)}; +`)});return}case`insertMarkdown`:this.insertMarkdown(e.markdown,e.mode);return;case`transcribed`:{let t=this.pendingTranscripts.get(e.id);if(!t)return;this.pendingTranscripts.delete(e.id),e.result&&this.words?t.resolve(Qp(e.result,this.words,GZ)):t.reject(Error(e.error||this.labels.blocks.transcribeFailed));return}default:throw Error(`unknown message ${e.type}`)}}requestTranscript(e,t){let n=this.nextTranscript++;return new Promise((r,i)=>{this.pendingTranscripts.set(n,{resolve:r,reject:i}),this.send({type:`transcribe`,id:n,src:e,name:t})})}insertMarkdown(e,t){let n=this.picked,r=n&&!n.editor.isDestroyed?n.editor:this.target,i=GZ(e);if(!i.trim())return;let a=r.state.doc.content.size,o=Math.min(n?.from??r.state.selection.from,a),s=Math.min(n?.to??r.state.selection.to,a);if(t===`replace`)r.chain().focus().insertContentAt({from:o,to:s},i).run();else{let e=r.state.doc.resolve(s);r.chain().focus().insertContentAt(e.depth>=1?e.after(1):s,i).run()}this.picked=null}connect(e){this.provider?.destroy();let t=new BZ({url:e.url,page:e.page,token:()=>e.token});t.onChange(()=>this.send({type:`collab`,status:t.status})),this.provider=t,this.editor.destroy(),this.editor=this.create({collab:{provider:t,user:e.user}}),this.mode===`edgeless`&&this.openCanvas()}openCanvas(){this.closeCanvas();let e=document.createElement(`div`);e.className=`dw-bridge-canvas`,document.body.append(e),this.canvasEl=e,this.el.hidden=!0,this.canvas=xZ(e,{provider:this.provider??void 0,content:this.provider?void 0:this.lastContent??this.editor.getJSON(),editable:this.editable&&!!this.provider,pageTitle:()=>this.title,onNavigate:e=>this.send({type:`navigate`,path:e}),onError:e=>this.send({type:`error`,message:e instanceof Error?e.message:String(e)})})}closeCanvas(){this.canvas?.destroy(),this.canvas=null,this.canvasEl?.remove(),this.canvasEl=null,this.el.hidden=!1}create(e){return this.el.replaceChildren(),new Vp({element:this.el,editable:this.editable,extensions:UY({...e,files:this.files,labels:this.labels,onNavigate:e=>this.send({type:`navigate`,path:e})}),editorProps:{attributes:{class:`dw-prose`}},onUpdate:({editor:e})=>this.send({type:`change`,content:e.getJSON()}),onSelectionUpdate:()=>this.reportState(),onTransaction:()=>this.reportState(),onFocus:()=>this.reportState(),onBlur:()=>this.reportState()})}get target(){return this.inner&&!this.inner.isDestroyed?this.inner:this.editor}track(e){let t=(e instanceof Element?e.closest(`.ProseMirror`):null)?.editor;t&&(this.setInner(t===this.editor?null:t),this.reportState())}innerChanged=()=>this.reportState();innerGone=()=>{this.setInner(null),this.reportState()};setInner(e){if(e!==this.inner){if(this.inner){for(let e of[`selectionUpdate`,`transaction`,`focus`,`blur`])this.inner.off(e,this.innerChanged);this.inner.off(`destroy`,this.innerGone)}if(this.inner=e,e){for(let t of[`selectionUpdate`,`transaction`,`focus`,`blur`])e.on(t,this.innerChanged);e.on(`destroy`,this.innerGone)}}}reportOverlay(){let e=document.querySelector(VZ)!==null;e!==this.overlay&&(this.overlay=e,this.send({type:`overlay`,open:e}))}reportState(){let e=this.target;if(e.isDestroyed)return;let t={active:UZ.filter(([,t])=>t(e)).map(([e])=>e),canUndo:e.can().undo(),canRedo:e.can().redo(),focused:e.isFocused},n=JSON.stringify(t);n!==this.lastState&&(this.lastState=n,this.send({type:`state`,state:t}))}};function GZ(e){return _Z.parse(e.trim(),{async:!1,gfm:!0})}function KZ(e){if(e.isDestroyed)return;let t=e.view.props.nodeViews??{},n=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)]));e.view.setProps({nodeViews:n})}function qZ(e){let t=JSON.stringify(e);window.DocwellNative?window.DocwellNative.postMessage(t):(window.parent.postMessage(t,`*`),console.debug(`[docwell bridge]`,e))}var JZ=new WZ(document.getElementById(`editor`),qZ);window.docwell={receive:e=>JZ.receive(e)}; diff --git a/Phone-App/test/widget_test.dart b/Phone-App/test/widget_test.dart index 8d9de3a..57f05f8 100644 --- a/Phone-App/test/widget_test.dart +++ b/Phone-App/test/widget_test.dart @@ -291,6 +291,12 @@ void main() { 'name': 'Ann', 'email': 'ann@docwell.test', }, + 'verification': { + 'by': {'id': '', 'name': '', 'email': ''}, + 'at': '', + 'until': '', + 'expired': false, + }, }); await tester.pumpWidget( MaterialApp(