wiki-plugin-mech 0.1.48-0 → 0.1.48-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/mech.js +97 -34
- package/client/mech.js.map +4 -4
- package/package.json +2 -1
package/client/mech.js
CHANGED
|
@@ -1,42 +1,105 @@
|
|
|
1
|
-
/* wiki-plugin-mech - 0.1.48-
|
|
2
|
-
(()=>{function ct(n,i=()=>{}){let o={},t={},e="",s=n,c=[],r=[c];o.match=()=>t.sp()&&t.term("match")&&t.node()&&t.chain()&&t.eot(),o.node=()=>t.ch("(")&&t.elem()&&t.ch(")"),o.chain=()=>d(()=>t.rel()&&t.node()&&t.chain()),o.rel=()=>f(()=>t.in(),()=>t.out(),()=>t.both()),o.in=()=>t.term("<-")&&b(()=>t.ch("[")&&t.elem()&&t.ch("]"))&&t.ch("-"),o.out=()=>t.ch("-")&&b(()=>t.ch("[")&&t.elem()&&t.ch("]"))&&t.term("->"),o.both=()=>t.ch("-")&&b(()=>t.ch("[")&&t.elem()&&t.ch("]"))&&t.ch("-"),o.elem=()=>b(()=>t.bind())&&b(()=>t.ch(":")&&t.type())&&b(()=>t.prop()),o.prop=()=>t.ch("{")&&t.word()&&t.ch(":")&&t.expr()&&t.ch("}"),o.expr=()=>t.strn(),o.bind=()=>t.word(),o.type=()=>t.word(),o.word=()=>l(/^[A-Za-z][A-Za-z0-9_]*/)&&t.sp(),o.term=u=>s.startsWith(u)&&a(u.length)&&p(u)&&t.sp(),o.strn=()=>t.ch('"')&&l(/^[^"]{0,20}/)&&t.ch('"')&&t.sp(),o.ch=u=>s.startsWith(u)&&a(1)&&p(u)&&t.sp(),o.sp=()=>l(/^\s*/),o.eot=()=>!s.length;for(let u in o)t[u]=(...O)=>{i(`${e}%c${u}%c${s}`,"color:red","color:black");let v=c;c=[u];let P=o[u](...O);return P&&v.push(c),c=v,P};function l(u){let O=s.match(u);return O&&a(O[0].length)&&p(O[0]),!!O}function p(u){return c.push(u),!0}function a(u){return e+=s.substring(0,u),s=s.substring(u),!0}function d(u){let O=[e,s];return u()?d(u):[e,s]=O,!0}function b(u){let O=[e,s];return u()||([e,s]=O),!0}function f(...u){let O=[e,s];for(let v of u){if(v())return!0;[e,s]=O}}return t.match(),r}function V(n,i,o,t=()=>{}){let e=()=>" |".repeat(n);switch(i[0]){case"sp":case"ch":case"term":break;case"bind":case"type":t(e(),i[0],`"${i[1][1]}"`),o[i[0]]=i[1][1];break;case"prop":t(e(),i[0],`"${i[2][1]}"`,i[4][1][2]),o[i[0]]=[i[2][1],i[4][1][2]];break;case"node":case"rel":case"chain":t(e(),i[0]);{let s={};o[i[0]]=s;for(let c of i.slice(1))V(n+1,c,s,t)}break;case"in":case"out":case"both":t(e(),i[0]),o.dir=i[0];for(let s of i.slice(1))V(n+1,s,o,t);break;case"match":case"elem":t(e(),i[0]);for(let s of i.slice(1))V(n+1,s,o,t);break;case"eot":t(e(),"end");break;default:t(e(),"unknown",i[0])}return o}function ot(n,i,o){i?.node?.type&&o&&(n.nodes[i.node.type]||o.push(`No node of type "${i.node.type}" in the graph.`)),i?.rel?.type&&o&&(n.rels[i.rel.type]||o.push(`No relation of type "${i.rel.type}" in the graph.`)),Object.keys(i.chain).length&&ot(n,i.chain,o)}function lt(n,i){let o=n.nodes,t=n.rels,e=[];for(let c of o)s(c,i,{});return e;function s(c,r,l){(!r.node.type||c.type==r.node.type)&&(!r.node.prop||c.props[r.node.prop[0]]==r.node.prop[1])&&(r.node.bind&&(l[r.node.bind]=c),r.chain.rel?(["in","both"].includes(r.chain.rel.dir)&&p(c.in,"from"),["out","both"].includes(r.chain.rel.dir)&&p(c.out,"to")):e.push(l));function p(a,d){a.forEach(b=>{(!r.chain.rel.type||t[b].type==r.chain.rel.type)&&(!r.chain.rel.prop||t[b].props[r.chain.rel.prop[0]]==r.chain.rel.prop[1])&&(l={...l},r.chain.rel.bind&&(l[r.chain.rel.bind]=t[b]),s(o[t[b][d]],r.chain,l))})}}}var z=(n,i,o)=>o.indexOf(n)===i,C=class n{constructor(i=[],o=[]){this.nodes=i,this.rels=o}addNode(i,o={}){let t={type:i,in:[],out:[],props:o};return this.nodes.push(t),this.nodes.length-1}addUniqNode(i,o={}){let t=this.nodes.findIndex(e=>e.type==i&&e.props?.name==o?.name);return t>=0?t:this.addNode(i,o)}addRel(i,o,t,e={}){if(o==null||t==null)return null;let s={type:i,from:o,to:t,props:e};this.rels.push(s);let c=this.rels.length-1;return this.nodes[o].out.push(c),this.nodes[t].in.push(c),c}tally(){let i=o=>o.reduce((t,e)=>(t[e.type]=t[e.type]?t[e.type]+1:1,t),{});return{nodes:i(this.nodes),rels:i(this.rels)}}size(){return this.nodes.length+this.rels.length}static load(i){return new n(i.nodes,i.rels)}static async fetch(i){let o=await fetch(i).then(t=>t.json());return n.load(o)}static async read(i){let o=await Deno.readTextFile(i),t=JSON.parse(o);return n.load(t)}copy(i,o){let t={},e=[],s=c=>{if(c in t)return;e.push(c);let r=this.nodes[c];t[c]=o.addNode(r.type,r.props);for(let l of r.out)s(this.rels[l].to);for(let l of r.in)s(this.rels[l].from);for(let l of r.out)o.addRel("",t[c],t[this.rels[l].to],{})};return s(i),e}clusters(){let i=[],o=[...this.nodes.keys()],t=e=>{let s=new n,c=this.copy(e,s);for(let r of c){let l=o.indexOf(r);o.splice(l,1)}return s};for(;o.length;)i.push(t(o[0]));return i}n(i=null,o={}){let t=Object.keys(this.nodes).map(e=>+e);i&&(t=t.filter(e=>this.nodes[e].type==i));for(let e in o)t=t.filter(s=>this.nodes[s].props[e]==o[e]);return new Z(this,t)}stringify(...i){let o={nodes:this.nodes,rels:this.rels};return JSON.stringify(o,...i)}search(i,o={}){let t=ct(i),e=V(0,t[0][0],{});return ot(this.tally(),e,o.errors),lt(this,e)}},Z=class n{constructor(i,o){this.graph=i,this.nids=o}i(i=null,o={}){let t=this.nids.map(e=>this.graph.nodes[e].in).flat().filter(z);i&&(t=t.filter(e=>this.graph.rels[e].type==i));for(let e in o)t=t.filter(s=>this.graph.rels[s].props[e]==o[e]);return new et(this.graph,t)}o(i=null,o={}){let t=this.nids.map(e=>this.graph.nodes[e].out).flat().filter(z);i&&(t=t.filter(e=>this.graph.rels[e].type==i));for(let e in o)t=t.filter(s=>this.graph.rels[s].props[e]==o[e]);return new et(this.graph,t)}props(i="name"){return this.nids.map(o=>this.graph.nodes[o].props[i]).filter(z).sort()}types(){return this.nids.map(i=>this.graph.nodes[i].type).filter(z).sort()}tally(){return{nodes:(o=>o.reduce((t,e)=>(t[e.type]=t[e.type]?t[e.type]+1:1,t),{}))(this.nids.map(o=>this.graph.nodes[o]))}}size(){return this.nids.length}filter(i){let o=this.graph.nodes,t=this.nids.filter(e=>{let s=o[e];return i(s.type,s.props)});return new n(this.graph,t)}map(i){let o=this.graph.nodes;return this.nids.map(e=>{let s=o[e];return i(s)})}},et=class n{constructor(i,o){this.graph=i,this.rids=o}f(i=null,o={}){let t=this.rids.map(e=>this.graph.rels[e].from).filter(z);i&&(t=t.filter(e=>this.graph.nodes[e].type==i));for(let e in o)t=t.filter(s=>this.graph.nodes[s].props[e]==o[e]);return new Z(this.graph,t)}t(i=null,o={}){let t=this.rids.map(e=>this.graph.rels[e].to).filter(z);i&&(t=t.filter(e=>this.graph.nodes[e].type==i));for(let e in o)t=t.filter(s=>this.graph.nodes[s].props[e]==o[e]);return new Z(this.graph,t)}props(i="name"){return this.rids.map(o=>this.graph.rels[o].props[i]).filter(z).sort()}types(){return this.rids.map(i=>this.graph.rels[i].type).filter(z).sort()}tally(){return{rels:(o=>o.reduce((t,e)=>(t[e.type]=t[e.type]?t[e.type]+1:1,t),{}))(this.rids.map(o=>this.graph.rels[o]))}}size(){return this.rids.length}filter(i){let o=this.graph.rels,t=this.rids.filter(e=>{let s=o[e];return i(s.type,s.props)});return new n(this.graph,t)}map(i){let o=this.graph.rels;return this.rids.map(e=>{let s=o[e];return i(s)})}};function at(n,i){let o=[];for(let t of document.querySelectorAll(".item"))if(t.classList.contains(`${i}-source`)&&o.unshift(t),t===n)break;return o.map(t=>{let e=t[`${i}Data`],s=e?e():null;return{div:t,result:s}})}function pt(n){let i=e=>Object.entries(e).filter(s=>s[1]).map(s=>`${s[0]}: ${s[1]}`).join("\\n"),o=n.nodes.map((e,s)=>{let c=e.type?`${e.type}\\n${e.props.name}`:e.props.name;return`${s} [label="${c}" ${e.props.url||e.props.tick?`URL="${e.props.url||"#"}" target="_blank"`:""} tooltip="${i(e.props)}"]`}),t=n.rels.map(e=>`${e.from}->${e.to} [label="${e.type}" labeltooltip="${i(e.props)}"]`);return["digraph {","rankdir=LR","node [shape=box style=filled fillcolor=palegreen]",...o,...t,"}"].join(`
|
|
3
|
-
`)}
|
|
4
|
-
`),
|
|
5
|
-
`)
|
|
6
|
-
`)
|
|
7
|
-
`)
|
|
8
|
-
|
|
9
|
-
`)
|
|
10
|
-
`)
|
|
11
|
-
`),
|
|
1
|
+
/* wiki-plugin-mech - 0.1.48-2 - Fri, 05 Jun 2026 17:22:57 GMT */
|
|
2
|
+
(()=>{function Be(s,e=()=>{}){let r={},n={},t="",i=s,o=[],l=[o];r.match=()=>n.sp()&&n.term("match")&&n.node()&&n.chain()&&n.eot(),r.node=()=>n.ch("(")&&n.elem()&&n.ch(")"),r.chain=()=>p(()=>n.rel()&&n.node()&&n.chain()),r.rel=()=>h(()=>n.in(),()=>n.out(),()=>n.both()),r.in=()=>n.term("<-")&&f(()=>n.ch("[")&&n.elem()&&n.ch("]"))&&n.ch("-"),r.out=()=>n.ch("-")&&f(()=>n.ch("[")&&n.elem()&&n.ch("]"))&&n.term("->"),r.both=()=>n.ch("-")&&f(()=>n.ch("[")&&n.elem()&&n.ch("]"))&&n.ch("-"),r.elem=()=>f(()=>n.bind())&&f(()=>n.ch(":")&&n.type())&&f(()=>n.prop()),r.prop=()=>n.ch("{")&&n.word()&&n.ch(":")&&n.expr()&&n.ch("}"),r.expr=()=>n.strn(),r.bind=()=>n.word(),r.type=()=>n.word(),r.word=()=>a(/^[A-Za-z][A-Za-z0-9_]*/)&&n.sp(),r.term=d=>i.startsWith(d)&&u(d.length)&&c(d)&&n.sp(),r.strn=()=>n.ch('"')&&a(/^[^"]{0,20}/)&&n.ch('"')&&n.sp(),r.ch=d=>i.startsWith(d)&&u(1)&&c(d)&&n.sp(),r.sp=()=>a(/^\s*/),r.eot=()=>!i.length;for(let d in r)n[d]=(...x)=>{e(`${t}%c${d}%c${i}`,"color:red","color:black");let T=o;o=[d];let D=r[d](...x);return D&&T.push(o),o=T,D};function a(d){let x=i.match(d);return x&&u(x[0].length)&&c(x[0]),!!x}function c(d){return o.push(d),!0}function u(d){return t+=i.substring(0,d),i=i.substring(d),!0}function p(d){let x=[t,i];return d()?p(d):[t,i]=x,!0}function f(d){let x=[t,i];return d()||([t,i]=x),!0}function h(...d){let x=[t,i];for(let T of d){if(T())return!0;[t,i]=x}}return n.match(),l}function le(s,e,r,n=()=>{}){let t=()=>" |".repeat(s);switch(e[0]){case"sp":case"ch":case"term":break;case"bind":case"type":n(t(),e[0],`"${e[1][1]}"`),r[e[0]]=e[1][1];break;case"prop":n(t(),e[0],`"${e[2][1]}"`,e[4][1][2]),r[e[0]]=[e[2][1],e[4][1][2]];break;case"node":case"rel":case"chain":n(t(),e[0]);{let i={};r[e[0]]=i;for(let o of e.slice(1))le(s+1,o,i,n)}break;case"in":case"out":case"both":n(t(),e[0]),r.dir=e[0];for(let i of e.slice(1))le(s+1,i,r,n);break;case"match":case"elem":n(t(),e[0]);for(let i of e.slice(1))le(s+1,i,r,n);break;case"eot":n(t(),"end");break;default:n(t(),"unknown",e[0])}return r}function Re(s,e,r){e?.node?.type&&r&&(s.nodes[e.node.type]||r.push(`No node of type "${e.node.type}" in the graph.`)),e?.rel?.type&&r&&(s.rels[e.rel.type]||r.push(`No relation of type "${e.rel.type}" in the graph.`)),Object.keys(e.chain).length&&Re(s,e.chain,r)}function We(s,e){let r=s.nodes,n=s.rels,t=[];for(let o of r)i(o,e,{});return t;function i(o,l,a){(!l.node.type||o.type==l.node.type)&&(!l.node.prop||o.props[l.node.prop[0]]==l.node.prop[1])&&(l.node.bind&&(a[l.node.bind]=o),l.chain.rel?(["in","both"].includes(l.chain.rel.dir)&&c(o.in,"from"),["out","both"].includes(l.chain.rel.dir)&&c(o.out,"to")):t.push(a));function c(u,p){u.forEach(f=>{(!l.chain.rel.type||n[f].type==l.chain.rel.type)&&(!l.chain.rel.prop||n[f].props[l.chain.rel.prop[0]]==l.chain.rel.prop[1])&&(a={...a},l.chain.rel.bind&&(a[l.chain.rel.bind]=n[f]),i(r[n[f][p]],l.chain,a))})}}}var X=(s,e,r)=>r.indexOf(s)===e,K=class s{constructor(e=[],r=[]){this.nodes=e,this.rels=r}addNode(e,r={}){let n={type:e,in:[],out:[],props:r};return this.nodes.push(n),this.nodes.length-1}addUniqNode(e,r={}){let n=this.nodes.findIndex(t=>t.type==e&&t.props?.name==r?.name);return n>=0?n:this.addNode(e,r)}addRel(e,r,n,t={}){if(r==null||n==null)return null;let i={type:e,from:r,to:n,props:t};this.rels.push(i);let o=this.rels.length-1;return this.nodes[r].out.push(o),this.nodes[n].in.push(o),o}tally(){let e=r=>r.reduce((n,t)=>(n[t.type]=n[t.type]?n[t.type]+1:1,n),{});return{nodes:e(this.nodes),rels:e(this.rels)}}size(){return this.nodes.length+this.rels.length}static load(e){return new s(e.nodes,e.rels)}static async fetch(e){let r=await fetch(e).then(n=>n.json());return s.load(r)}static async read(e){let r=await Deno.readTextFile(e),n=JSON.parse(r);return s.load(n)}copy(e,r){let n={},t=[],i=o=>{if(o in n)return;t.push(o);let l=this.nodes[o];n[o]=r.addNode(l.type,l.props);for(let a of l.out)i(this.rels[a].to);for(let a of l.in)i(this.rels[a].from);for(let a of l.out)r.addRel("",n[o],n[this.rels[a].to],{})};return i(e),t}clusters(){let e=[],r=[...this.nodes.keys()],n=t=>{let i=new s,o=this.copy(t,i);for(let l of o){let a=r.indexOf(l);r.splice(a,1)}return i};for(;r.length;)e.push(n(r[0]));return e}n(e=null,r={}){let n=Object.keys(this.nodes).map(t=>+t);e&&(n=n.filter(t=>this.nodes[t].type==e));for(let t in r)n=n.filter(i=>this.nodes[i].props[t]==r[t]);return new ae(this,n)}stringify(...e){let r={nodes:this.nodes,rels:this.rels};return JSON.stringify(r,...e)}search(e,r={}){let n=Be(e),t=le(0,n[0][0],{});return Re(this.tally(),t,r.errors),We(this,t)}},ae=class s{constructor(e,r){this.graph=e,this.nids=r}i(e=null,r={}){let n=this.nids.map(t=>this.graph.nodes[t].in).flat().filter(X);e&&(n=n.filter(t=>this.graph.rels[t].type==e));for(let t in r)n=n.filter(i=>this.graph.rels[i].props[t]==r[t]);return new ke(this.graph,n)}o(e=null,r={}){let n=this.nids.map(t=>this.graph.nodes[t].out).flat().filter(X);e&&(n=n.filter(t=>this.graph.rels[t].type==e));for(let t in r)n=n.filter(i=>this.graph.rels[i].props[t]==r[t]);return new ke(this.graph,n)}props(e="name"){return this.nids.map(r=>this.graph.nodes[r].props[e]).filter(X).sort()}types(){return this.nids.map(e=>this.graph.nodes[e].type).filter(X).sort()}tally(){return{nodes:(r=>r.reduce((n,t)=>(n[t.type]=n[t.type]?n[t.type]+1:1,n),{}))(this.nids.map(r=>this.graph.nodes[r]))}}size(){return this.nids.length}filter(e){let r=this.graph.nodes,n=this.nids.filter(t=>{let i=r[t];return e(i.type,i.props)});return new s(this.graph,n)}map(e){let r=this.graph.nodes;return this.nids.map(t=>{let i=r[t];return e(i)})}},ke=class s{constructor(e,r){this.graph=e,this.rids=r}f(e=null,r={}){let n=this.rids.map(t=>this.graph.rels[t].from).filter(X);e&&(n=n.filter(t=>this.graph.nodes[t].type==e));for(let t in r)n=n.filter(i=>this.graph.nodes[i].props[t]==r[t]);return new ae(this.graph,n)}t(e=null,r={}){let n=this.rids.map(t=>this.graph.rels[t].to).filter(X);e&&(n=n.filter(t=>this.graph.nodes[t].type==e));for(let t in r)n=n.filter(i=>this.graph.nodes[i].props[t]==r[t]);return new ae(this.graph,n)}props(e="name"){return this.rids.map(r=>this.graph.rels[r].props[e]).filter(X).sort()}types(){return this.rids.map(e=>this.graph.rels[e].type).filter(X).sort()}tally(){return{rels:(r=>r.reduce((n,t)=>(n[t.type]=n[t.type]?n[t.type]+1:1,n),{}))(this.rids.map(r=>this.graph.rels[r]))}}size(){return this.rids.length}filter(e){let r=this.graph.rels,n=this.rids.filter(t=>{let i=r[t];return e(i.type,i.props)});return new s(this.graph,n)}map(e){let r=this.graph.rels;return this.rids.map(t=>{let i=r[t];return e(i)})}};function Ee(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var se=Ee();function Qe(s){se=s}var ne={exec:()=>null};function ie(s){let e=[];return r=>{let n=Math.max(0,Math.min(3,r-1)),t=e[n];return t||(t=s(n),e[n]=t),t}}function E(s,e=""){let r=typeof s=="string"?s:s.source,n={replace:(t,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(C.caret,"$1"),r=r.replace(t,o),n},getRegex:()=>new RegExp(r,e)};return n}var wt=((s="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+s)}catch{return!1}})(),C={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,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,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,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:s=>new RegExp(`^( {0,3}${s})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:ie(s=>new RegExp(`^ {0,${s}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:ie(s=>new RegExp(`^ {0,${s}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:ie(s=>new RegExp(`^ {0,${s}}(?:\`\`\`|~~~)`)),headingBeginRegex:ie(s=>new RegExp(`^ {0,${s}}#`)),htmlBeginRegex:ie(s=>new RegExp(`^ {0,${s}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:ie(s=>new RegExp(`^ {0,${s}}>`))},yt=/^(?:[ \t]*(?:\n|$))+/,$t=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,St=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ue=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Rt=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ve=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ve=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Xe=E(Ve).replace(/bull/g,ve).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(),Tt=E(Ve).replace(/bull/g,ve).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(),Oe=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Lt=/^[^\n]+/,Ie=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,At=E(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ie).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Et=E(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ve).getRegex(),ye="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",je=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,vt=E("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",je).replace("tag",ye).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ye=E(Oe).replace("hr",ue).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[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ye).getRegex(),Ot=E(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ye).getRegex(),Pe={blockquote:Ot,code:$t,def:At,fences:St,heading:Rt,hr:ue,html:vt,lheading:Xe,list:Et,newline:yt,paragraph:Ye,table:ne,text:Lt},Ke=E("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ue).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[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ye).getRegex(),It={...Pe,lheading:Tt,table:Ke,paragraph:E(Oe).replace("hr",ue).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ke).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ye).getRegex()},jt={...Pe,html:E(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",je).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:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ne,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:E(Oe).replace("hr",ue).replace("heading",` *#{1,6} *[^
|
|
3
|
+
]`).replace("lheading",Xe).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Pt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,zt=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,et=/^( {2,}|\\)\n(?!\s*$)/,Nt=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,oe=/[\p{P}\p{S}]/u,$e=/[\s\p{P}\p{S}]/u,ze=/[^\s\p{P}\p{S}]/u,_t=E(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,$e).getRegex(),tt=/(?!~)[\p{P}\p{S}]/u,Dt=/(?!~)[\s\p{P}\p{S}]/u,Mt=/(?:[^\s\p{P}\p{S}]|~)/u,qt=E(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",wt?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),nt=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ct=E(nt,"u").replace(/punct/g,oe).getRegex(),Bt=E(nt,"u").replace(/punct/g,tt).getRegex(),rt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Wt=E(rt,"gu").replace(/notPunctSpace/g,ze).replace(/punctSpace/g,$e).replace(/punct/g,oe).getRegex(),Kt=E(rt,"gu").replace(/notPunctSpace/g,Mt).replace(/punctSpace/g,Dt).replace(/punct/g,tt).getRegex(),Gt=E("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ze).replace(/punctSpace/g,$e).replace(/punct/g,oe).getRegex(),Ht=E(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,oe).getRegex(),Ut="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Ft=E(Ut,"gu").replace(/notPunctSpace/g,ze).replace(/punctSpace/g,$e).replace(/punct/g,oe).getRegex(),Zt=E(/\\(punct)/,"gu").replace(/punct/g,oe).getRegex(),Jt=E(/^<(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(),Qt=E(je).replace("(?:-->|$)","-->").getRegex(),Vt=E("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Qt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),be=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Xt=E(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",be).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),st=E(/^!?\[(label)\]\[(ref)\]/).replace("label",be).replace("ref",Ie).getRegex(),it=E(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ie).getRegex(),Yt=E("reflink|nolink(?!\\()","g").replace("reflink",st).replace("nolink",it).getRegex(),Ge=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ne={_backpedal:ne,anyPunctuation:Zt,autolink:Jt,blockSkip:qt,br:et,code:zt,del:ne,delLDelim:ne,delRDelim:ne,emStrongLDelim:Ct,emStrongRDelimAst:Wt,emStrongRDelimUnd:Gt,escape:Pt,link:Xt,nolink:it,punctuation:_t,reflink:st,reflinkSearch:Yt,tag:Vt,text:Nt,url:ne},en={...Ne,link:E(/^!?\[(label)\]\((.*?)\)/).replace("label",be).getRegex(),reflink:E(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",be).getRegex()},Te={...Ne,emStrongRDelimAst:Kt,emStrongLDelim:Bt,delLDelim:Ht,delRDelim:Ft,url:E(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ge).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:E(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ge).getRegex()},tn={...Te,br:E(et).replace("{2,}","*").getRegex(),text:E(Te.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},me={normal:Pe,gfm:It,pedantic:jt},ce={normal:Ne,gfm:Te,breaks:tn,pedantic:en},nn={"&":"&","<":"<",">":">",'"':""","'":"'"},He=s=>nn[s];function J(s,e){if(e){if(C.escapeTest.test(s))return s.replace(C.escapeReplace,He)}else if(C.escapeTestNoEncode.test(s))return s.replace(C.escapeReplaceNoEncode,He);return s}function Ue(s){try{s=encodeURI(s).replace(C.percentDecode,"%")}catch{return null}return s}function Fe(s,e){let r=s.replace(C.findPipe,(i,o,l)=>{let a=!1,c=o;for(;--c>=0&&l[c]==="\\";)a=!a;return a?"|":" |"}),n=r.split(C.splitPipe),t=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;t<n.length;t++)n[t]=n[t].trim().replace(C.slashPipe,"|");return n}function Y(s,e,r){let n=s.length;if(n===0)return"";let t=0;for(;t<n;){let i=s.charAt(n-t-1);if(i===e&&!r)t++;else if(i!==e&&r)t++;else break}return s.slice(0,n-t)}function Ze(s){let e=s.split(`
|
|
4
|
+
`),r=e.length-1;for(;r>=0&&C.blankLine.test(e[r]);)r--;return e.length-r<=2?s:e.slice(0,r+1).join(`
|
|
5
|
+
`)}function rn(s,e){if(s.indexOf(e[1])===-1)return-1;let r=0;for(let n=0;n<s.length;n++)if(s[n]==="\\")n++;else if(s[n]===e[0])r++;else if(s[n]===e[1]&&(r--,r<0))return n;return r>0?-2:-1}function sn(s,e=0){let r=e,n="";for(let t of s)if(t===" "){let i=4-r%4;n+=" ".repeat(i),r+=i}else n+=t,r++;return n}function Je(s,e,r,n,t){let i=e.href,o=e.title||null,l=s[1].replace(t.other.outputLinkReplace,"$1");n.state.inLink=!0;let a={type:s[0].charAt(0)==="!"?"image":"link",raw:r,href:i,title:o,text:l,tokens:n.inlineTokens(l)};return n.state.inLink=!1,a}function on(s,e,r){let n=s.match(r.other.indentCodeCompensation);if(n===null)return e;let t=n[1];return e.split(`
|
|
6
|
+
`).map(i=>{let o=i.match(r.other.beginningSpace);if(o===null)return i;let[l]=o;return l.length>=t.length?i.slice(t.length):i}).join(`
|
|
7
|
+
`)}var xe=class{options;rules;lexer;constructor(s){this.options=s||se}space(s){let e=this.rules.block.newline.exec(s);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(s){let e=this.rules.block.code.exec(s);if(e){let r=this.options.pedantic?e[0]:Ze(e[0]),n=r.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:r,codeBlockStyle:"indented",text:n}}}fences(s){let e=this.rules.block.fences.exec(s);if(e){let r=e[0],n=on(r,e[3]||"",this.rules);return{type:"code",raw:r,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:n}}}heading(s){let e=this.rules.block.heading.exec(s);if(e){let r=e[2].trim();if(this.rules.other.endingHash.test(r)){let n=Y(r,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(r=n.trim())}return{type:"heading",raw:Y(e[0],`
|
|
8
|
+
`),depth:e[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(s){let e=this.rules.block.hr.exec(s);if(e)return{type:"hr",raw:Y(e[0],`
|
|
9
|
+
`)}}blockquote(s){let e=this.rules.block.blockquote.exec(s);if(e){let r=Y(e[0],`
|
|
10
|
+
`).split(`
|
|
11
|
+
`),n="",t="",i=[];for(;r.length>0;){let o=!1,l=[],a;for(a=0;a<r.length;a++)if(this.rules.other.blockquoteStart.test(r[a]))l.push(r[a]),o=!0;else if(!o)l.push(r[a]);else break;r=r.slice(a);let c=l.join(`
|
|
12
|
+
`),u=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
13
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
|
|
14
|
+
${c}`:c,t=t?`${t}
|
|
15
|
+
${u}`:u;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=p,r.length===0)break;let f=i.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let h=f,d=h.raw+`
|
|
16
|
+
`+r.join(`
|
|
17
|
+
`),x=this.blockquote(d);i[i.length-1]=x,n=n.substring(0,n.length-h.raw.length)+x.raw,t=t.substring(0,t.length-h.text.length)+x.text;break}else if(f?.type==="list"){let h=f,d=h.raw+`
|
|
18
|
+
`+r.join(`
|
|
19
|
+
`),x=this.list(d);i[i.length-1]=x,n=n.substring(0,n.length-f.raw.length)+x.raw,t=t.substring(0,t.length-h.raw.length)+x.raw,r=d.substring(i.at(-1).raw.length).split(`
|
|
20
|
+
`);continue}}return{type:"blockquote",raw:n,tokens:i,text:t}}}list(s){let e=this.rules.block.list.exec(s);if(e){let r=e[1].trim(),n=r.length>1,t={type:"list",raw:"",ordered:n,start:n?+r.slice(0,-1):"",loose:!1,items:[]};r=n?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=n?r:"[*+-]");let i=this.rules.other.listItemRegex(r),o=!1;for(;s;){let a=!1,c="",u="";if(!(e=i.exec(s))||this.rules.block.hr.test(s))break;c=e[0],s=s.substring(c.length);let p=sn(e[2].split(`
|
|
21
|
+
`,1)[0],e[1].length),f=s.split(`
|
|
22
|
+
`,1)[0],h=!p.trim(),d=0;if(this.options.pedantic?(d=2,u=p.trimStart()):h?d=e[1].length+1:(d=p.search(this.rules.other.nonSpaceChar),d=d>4?1:d,u=p.slice(d),d+=e[1].length),h&&this.rules.other.blankLine.test(f)&&(c+=f+`
|
|
23
|
+
`,s=s.substring(f.length+1),a=!0),!a){let x=this.rules.other.nextBulletRegex(d),T=this.rules.other.hrRegex(d),D=this.rules.other.fencesBeginRegex(d),q=this.rules.other.headingBeginRegex(d),B=this.rules.other.htmlBeginRegex(d),v=this.rules.other.blockquoteBeginRegex(d);for(;s;){let k=s.split(`
|
|
24
|
+
`,1)[0],g;if(f=k,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),g=f):g=f.replace(this.rules.other.tabCharGlobal," "),D.test(f)||q.test(f)||B.test(f)||v.test(f)||x.test(f)||T.test(f))break;if(g.search(this.rules.other.nonSpaceChar)>=d||!f.trim())u+=`
|
|
25
|
+
`+g.slice(d);else{if(h||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||D.test(p)||q.test(p)||T.test(p))break;u+=`
|
|
26
|
+
`+f}h=!f.trim(),c+=k+`
|
|
27
|
+
`,s=s.substring(k.length+1),p=g.slice(d)}}t.loose||(o?t.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0)),t.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),t.raw+=c}let l=t.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;t.raw=t.raw.trimEnd();for(let a of t.items){this.lexer.state.top=!1,a.tokens=this.lexer.blockTokens(a.text,[]);let c=a.tokens[0];if(a.task&&(c?.type==="text"||c?.type==="paragraph")){a.text=a.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(a.raw);if(u){let p={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};a.checked=p.checked,t.loose?a.tokens[0]&&["paragraph","text"].includes(a.tokens[0].type)&&"tokens"in a.tokens[0]&&a.tokens[0].tokens?(a.tokens[0].raw=p.raw+a.tokens[0].raw,a.tokens[0].text=p.raw+a.tokens[0].text,a.tokens[0].tokens.unshift(p)):a.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):a.tokens.unshift(p)}}else a.task&&(a.task=!1);if(!t.loose){let u=a.tokens.filter(f=>f.type==="space"),p=u.length>0&&u.some(f=>this.rules.other.anyLine.test(f.raw));t.loose=p}}if(t.loose)for(let a of t.items){a.loose=!0;for(let c of a.tokens)c.type==="text"&&(c.type="paragraph")}return t}}html(s){let e=this.rules.block.html.exec(s);if(e){let r=Ze(e[0]);return{type:"html",block:!0,raw:r,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:r}}}def(s){let e=this.rules.block.def.exec(s);if(e){let r=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",t=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:r,raw:Y(e[0],`
|
|
28
|
+
`),href:n,title:t}}}table(s){let e=this.rules.block.table.exec(s);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let r=Fe(e[1]),n=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),t=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
29
|
+
`):[],i={type:"table",raw:Y(e[0],`
|
|
30
|
+
`),header:[],align:[],rows:[]};if(r.length===n.length){for(let o of n)this.rules.other.tableAlignRight.test(o)?i.align.push("right"):this.rules.other.tableAlignCenter.test(o)?i.align.push("center"):this.rules.other.tableAlignLeft.test(o)?i.align.push("left"):i.align.push(null);for(let o=0;o<r.length;o++)i.header.push({text:r[o],tokens:this.lexer.inline(r[o]),header:!0,align:i.align[o]});for(let o of t)i.rows.push(Fe(o,i.header.length).map((l,a)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[a]})));return i}}lheading(s){let e=this.rules.block.lheading.exec(s);if(e){let r=e[1].trim();return{type:"heading",raw:Y(e[0],`
|
|
31
|
+
`),depth:e[2].charAt(0)==="="?1:2,text:r,tokens:this.lexer.inline(r)}}}paragraph(s){let e=this.rules.block.paragraph.exec(s);if(e){let r=e[1].charAt(e[1].length-1)===`
|
|
32
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(s){let e=this.rules.block.text.exec(s);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(s){let e=this.rules.inline.escape.exec(s);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(s){let e=this.rules.inline.tag.exec(s);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(s){let e=this.rules.inline.link.exec(s);if(e){let r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let i=Y(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{let i=rn(e[2],"()");if(i===-2)return;if(i>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let n=e[2],t="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(n);i&&(n=i[1],t=i[3])}else t=e[3]?e[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?n=n.slice(1):n=n.slice(1,-1)),Je(e,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:t&&t.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(s,e){let r;if((r=this.rules.inline.reflink.exec(s))||(r=this.rules.inline.nolink.exec(s))){let n=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),t=e[n.toLowerCase()];if(!t){let i=r[0].charAt(0);return{type:"text",raw:i,text:i}}return Je(r,t,r[0],this.lexer,this.rules)}}emStrong(s,e,r=""){let n=this.rules.inline.emStrongLDelim.exec(s);if(!(!n||!n[1]&&!n[2]&&!n[3]&&!n[4]||n[4]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[3])||!r||this.rules.inline.punctuation.exec(r))){let t=[...n[0]].length-1,i,o,l=t,a=0,c=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*s.length+t);(n=c.exec(e))!==null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i)continue;if(o=[...i].length,n[3]||n[4]){l+=o;continue}else if((n[5]||n[6])&&t%3&&!((t+o)%3)){a+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l+a);let u=[...n[0]][0].length,p=s.slice(0,t+n.index+u+o);if(Math.min(t,o)%2){let h=p.slice(1,-1);return{type:"em",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}let f=p.slice(2,-2);return{type:"strong",raw:p,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(s){let e=this.rules.inline.code.exec(s);if(e){let r=e[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(r),t=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return n&&t&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:e[0],text:r}}}br(s){let e=this.rules.inline.br.exec(s);if(e)return{type:"br",raw:e[0]}}del(s,e,r=""){let n=this.rules.inline.delLDelim.exec(s);if(n&&(!n[1]||!r||this.rules.inline.punctuation.exec(r))){let t=[...n[0]].length-1,i,o,l=t,a=this.rules.inline.delRDelim;for(a.lastIndex=0,e=e.slice(-1*s.length+t);(n=a.exec(e))!==null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i||(o=[...i].length,o!==t))continue;if(n[3]||n[4]){l+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l);let c=[...n[0]][0].length,u=s.slice(0,t+n.index+c+o),p=u.slice(t,-t);return{type:"del",raw:u,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(s){let e=this.rules.inline.autolink.exec(s);if(e){let r,n;return e[2]==="@"?(r=e[1],n="mailto:"+r):(r=e[1],n=r),{type:"link",raw:e[0],text:r,href:n,tokens:[{type:"text",raw:r,text:r}]}}}url(s){let e;if(e=this.rules.inline.url.exec(s)){let r,n;if(e[2]==="@")r=e[0],n="mailto:"+r;else{let t;do t=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(t!==e[0]);r=e[0],e[1]==="www."?n="http://"+e[0]:n=e[0]}return{type:"link",raw:e[0],text:r,href:n,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(s){let e=this.rules.inline.text.exec(s);if(e){let r=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:r}}}},G=class Le{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||se,this.options.tokenizer=this.options.tokenizer||new xe,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 r={other:C,block:me.normal,inline:ce.normal};this.options.pedantic?(r.block=me.pedantic,r.inline=ce.pedantic):this.options.gfm&&(r.block=me.gfm,this.options.breaks?r.inline=ce.breaks:r.inline=ce.gfm),this.tokenizer.rules=r}static get rules(){return{block:me,inline:ce}}static lex(e,r){return new Le(r).lex(e)}static lexInline(e,r){return new Le(r).inlineTokens(e)}lex(e){e=e.replace(C.carriageReturn,`
|
|
33
|
+
`),this.blockTokens(e,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){let n=this.inlineQueue[r];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,r=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(C.tabCharGlobal," ").replace(C.spaceLine,""));let t=1/0;for(;e;){if(e.length<t)t=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(l=>(i=l.call({lexer:this},e,r))?(e=e.substring(i.raw.length),r.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let l=r.at(-1);i.raw.length===1&&l!==void 0?l.raw+=`
|
|
34
|
+
`:r.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let l=r.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`
|
|
35
|
+
`)?"":`
|
|
36
|
+
`)+i.raw,l.text+=`
|
|
37
|
+
`+i.text,this.inlineQueue.at(-1).src=l.text):r.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let l=r.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`
|
|
38
|
+
`)?"":`
|
|
39
|
+
`)+i.raw,l.text+=`
|
|
40
|
+
`+i.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},r.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),r.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),r.push(i);continue}let o=e;if(this.options.extensions?.startBlock){let l=1/0,a=e.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},a),typeof c=="number"&&c>=0&&(l=Math.min(l,c))}),l<1/0&&l>=0&&(o=e.substring(0,l+1))}if(this.state.top&&(i=this.tokenizer.paragraph(o))){let l=r.at(-1);n&&l?.type==="paragraph"?(l.raw+=(l.raw.endsWith(`
|
|
41
|
+
`)?"":`
|
|
42
|
+
`)+i.raw,l.text+=`
|
|
43
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):r.push(i),n=o.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let l=r.at(-1);l?.type==="text"?(l.raw+=(l.raw.endsWith(`
|
|
44
|
+
`)?"":`
|
|
45
|
+
`)+i.raw,l.text+=`
|
|
46
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):r.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}inlineTokens(e,r=[]){this.tokenizer.lexer=this;let n=e,t=null;if(this.tokens.links){let c=Object.keys(this.tokens.links);if(c.length>0)for(;(t=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)c.includes(t[0].slice(t[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,t.index)+"["+"a".repeat(t[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(t=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,t.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(t=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=t[2]?t[2].length:0,n=n.slice(0,t.index+i)+"["+"a".repeat(t[0].length-i-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let o=!1,l="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}o||(l=""),o=!1;let c;if(this.options.extensions?.inline?.some(p=>(c=p.call({lexer:this},e,r))?(e=e.substring(c.raw.length),r.push(c),!0):!1))continue;if(c=this.tokenizer.escape(e)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.tag(e)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.link(e)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(c.raw.length);let p=r.at(-1);c.type==="text"&&p?.type==="text"?(p.raw+=c.raw,p.text+=c.text):r.push(c);continue}if(c=this.tokenizer.emStrong(e,n,l)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.codespan(e)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.br(e)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.del(e,n,l)){e=e.substring(c.raw.length),r.push(c);continue}if(c=this.tokenizer.autolink(e)){e=e.substring(c.raw.length),r.push(c);continue}if(!this.state.inLink&&(c=this.tokenizer.url(e))){e=e.substring(c.raw.length),r.push(c);continue}let u=e;if(this.options.extensions?.startInline){let p=1/0,f=e.slice(1),h;this.options.extensions.startInline.forEach(d=>{h=d.call({lexer:this},f),typeof h=="number"&&h>=0&&(p=Math.min(p,h))}),p<1/0&&p>=0&&(u=e.substring(0,p+1))}if(c=this.tokenizer.inlineText(u)){e=e.substring(c.raw.length),c.raw.slice(-1)!=="_"&&(l=c.raw.slice(-1)),o=!0;let p=r.at(-1);p?.type==="text"?(p.raw+=c.raw,p.text+=c.text):r.push(c);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return r}infiniteLoopError(e){let r="Infinite loop on byte: "+e;if(this.options.silent)console.error(r);else throw new Error(r)}},we=class{options;parser;constructor(s){this.options=s||se}space(s){return""}code({text:s,lang:e,escaped:r}){let n=(e||"").match(C.notSpaceStart)?.[0],t=s.replace(C.endingNewline,"")+`
|
|
47
|
+
`;return n?'<pre><code class="language-'+J(n)+'">'+(r?t:J(t,!0))+`</code></pre>
|
|
48
|
+
`:"<pre><code>"+(r?t:J(t,!0))+`</code></pre>
|
|
49
|
+
`}blockquote({tokens:s}){return`<blockquote>
|
|
50
|
+
${this.parser.parse(s)}</blockquote>
|
|
51
|
+
`}html({text:s}){return s}def(s){return""}heading({tokens:s,depth:e}){return`<h${e}>${this.parser.parseInline(s)}</h${e}>
|
|
52
|
+
`}hr(s){return`<hr>
|
|
53
|
+
`}list(s){let e=s.ordered,r=s.start,n="";for(let o=0;o<s.items.length;o++){let l=s.items[o];n+=this.listitem(l)}let t=e?"ol":"ul",i=e&&r!==1?' start="'+r+'"':"";return"<"+t+i+`>
|
|
54
|
+
`+n+"</"+t+`>
|
|
55
|
+
`}listitem(s){return`<li>${this.parser.parse(s.tokens)}</li>
|
|
56
|
+
`}checkbox({checked:s}){return"<input "+(s?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:s}){return`<p>${this.parser.parseInline(s)}</p>
|
|
57
|
+
`}table(s){let e="",r="";for(let t=0;t<s.header.length;t++)r+=this.tablecell(s.header[t]);e+=this.tablerow({text:r});let n="";for(let t=0;t<s.rows.length;t++){let i=s.rows[t];r="";for(let o=0;o<i.length;o++)r+=this.tablecell(i[o]);n+=this.tablerow({text:r})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
|
|
58
|
+
<thead>
|
|
59
|
+
`+e+`</thead>
|
|
60
|
+
`+n+`</table>
|
|
61
|
+
`}tablerow({text:s}){return`<tr>
|
|
62
|
+
${s}</tr>
|
|
63
|
+
`}tablecell(s){let e=this.parser.parseInline(s.tokens),r=s.header?"th":"td";return(s.align?`<${r} align="${s.align}">`:`<${r}>`)+e+`</${r}>
|
|
64
|
+
`}strong({tokens:s}){return`<strong>${this.parser.parseInline(s)}</strong>`}em({tokens:s}){return`<em>${this.parser.parseInline(s)}</em>`}codespan({text:s}){return`<code>${J(s,!0)}</code>`}br(s){return"<br>"}del({tokens:s}){return`<del>${this.parser.parseInline(s)}</del>`}link({href:s,title:e,tokens:r}){let n=this.parser.parseInline(r),t=Ue(s);if(t===null)return n;s=t;let i='<a href="'+s+'"';return e&&(i+=' title="'+J(e)+'"'),i+=">"+n+"</a>",i}image({href:s,title:e,text:r,tokens:n}){n&&(r=this.parser.parseInline(n,this.parser.textRenderer));let t=Ue(s);if(t===null)return J(r);s=t;let i=`<img src="${s}" alt="${J(r)}"`;return e&&(i+=` title="${J(e)}"`),i+=">",i}text(s){return"tokens"in s&&s.tokens?this.parser.parseInline(s.tokens):"escaped"in s&&s.escaped?s.text:J(s.text)}},_e=class{strong({text:s}){return s}em({text:s}){return s}codespan({text:s}){return s}del({text:s}){return s}html({text:s}){return s}text({text:s}){return s}link({text:s}){return""+s}image({text:s}){return""+s}br(){return""}checkbox({raw:s}){return s}},H=class Ae{options;renderer;textRenderer;constructor(e){this.options=e||se,this.options.renderer=this.options.renderer||new we,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new _e}static parse(e,r){return new Ae(r).parse(e)}static parseInline(e,r){return new Ae(r).parseInline(e)}parse(e){this.renderer.parser=this;let r="";for(let n=0;n<e.length;n++){let t=e[n];if(this.options.extensions?.renderers?.[t.type]){let o=t,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){r+=l||"";continue}}let i=t;switch(i.type){case"space":{r+=this.renderer.space(i);break}case"hr":{r+=this.renderer.hr(i);break}case"heading":{r+=this.renderer.heading(i);break}case"code":{r+=this.renderer.code(i);break}case"table":{r+=this.renderer.table(i);break}case"blockquote":{r+=this.renderer.blockquote(i);break}case"list":{r+=this.renderer.list(i);break}case"checkbox":{r+=this.renderer.checkbox(i);break}case"html":{r+=this.renderer.html(i);break}case"def":{r+=this.renderer.def(i);break}case"paragraph":{r+=this.renderer.paragraph(i);break}case"text":{r+=this.renderer.text(i);break}default:{let o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}parseInline(e,r=this.renderer){this.renderer.parser=this;let n="";for(let t=0;t<e.length;t++){let i=e[t];if(this.options.extensions?.renderers?.[i.type]){let l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=l||"";continue}}let o=i;switch(o.type){case"escape":{n+=r.text(o);break}case"html":{n+=r.html(o);break}case"link":{n+=r.link(o);break}case"image":{n+=r.image(o);break}case"checkbox":{n+=r.checkbox(o);break}case"strong":{n+=r.strong(o);break}case"em":{n+=r.em(o);break}case"codespan":{n+=r.codespan(o);break}case"br":{n+=r.br(o);break}case"del":{n+=r.del(o);break}case"text":{n+=r.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}},pe=class{options;block;constructor(s){this.options=s||se}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(s){return s}postprocess(s){return s}processAllTokens(s){return s}emStrongMask(s){return s}provideLexer(s=this.block){return s?G.lex:G.lexInline}provideParser(s=this.block){return s?H.parse:H.parseInline}},ln=class{defaults=Ee();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=H;Renderer=we;TextRenderer=_e;Lexer=G;Tokenizer=xe;Hooks=pe;constructor(...s){this.use(...s)}walkTokens(s,e){let r=[];for(let n of s)switch(r=r.concat(e.call(this,n)),n.type){case"table":{let t=n;for(let i of t.header)r=r.concat(this.walkTokens(i.tokens,e));for(let i of t.rows)for(let o of i)r=r.concat(this.walkTokens(o.tokens,e));break}case"list":{let t=n;r=r.concat(this.walkTokens(t.items,e));break}default:{let t=n;this.defaults.extensions?.childTokens?.[t.type]?this.defaults.extensions.childTokens[t.type].forEach(i=>{let o=t[i].flat(1/0);r=r.concat(this.walkTokens(o,e))}):t.tokens&&(r=r.concat(this.walkTokens(t.tokens,e)))}}return r}use(...s){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return s.forEach(r=>{let n={...r};if(n.async=this.defaults.async||n.async||!1,r.extensions&&(r.extensions.forEach(t=>{if(!t.name)throw new Error("extension name required");if("renderer"in t){let i=e.renderers[t.name];i?e.renderers[t.name]=function(...o){let l=t.renderer.apply(this,o);return l===!1&&(l=i.apply(this,o)),l}:e.renderers[t.name]=t.renderer}if("tokenizer"in t){if(!t.level||t.level!=="block"&&t.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[t.level];i?i.unshift(t.tokenizer):e[t.level]=[t.tokenizer],t.start&&(t.level==="block"?e.startBlock?e.startBlock.push(t.start):e.startBlock=[t.start]:t.level==="inline"&&(e.startInline?e.startInline.push(t.start):e.startInline=[t.start]))}"childTokens"in t&&t.childTokens&&(e.childTokens[t.name]=t.childTokens)}),n.extensions=e),r.renderer){let t=this.defaults.renderer||new we(this.defaults);for(let i in r.renderer){if(!(i in t))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,l=r.renderer[o],a=t[o];t[o]=(...c)=>{let u=l.apply(t,c);return u===!1&&(u=a.apply(t,c)),u||""}}n.renderer=t}if(r.tokenizer){let t=this.defaults.tokenizer||new xe(this.defaults);for(let i in r.tokenizer){if(!(i in t))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,l=r.tokenizer[o],a=t[o];t[o]=(...c)=>{let u=l.apply(t,c);return u===!1&&(u=a.apply(t,c)),u}}n.tokenizer=t}if(r.hooks){let t=this.defaults.hooks||new pe;for(let i in r.hooks){if(!(i in t))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,l=r.hooks[o],a=t[o];pe.passThroughHooks.has(i)?t[o]=c=>{if(this.defaults.async&&pe.passThroughHooksRespectAsync.has(i))return(async()=>{let p=await l.call(t,c);return a.call(t,p)})();let u=l.call(t,c);return a.call(t,u)}:t[o]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await l.apply(t,c);return p===!1&&(p=await a.apply(t,c)),p})();let u=l.apply(t,c);return u===!1&&(u=a.apply(t,c)),u}}n.hooks=t}if(r.walkTokens){let t=this.defaults.walkTokens,i=r.walkTokens;n.walkTokens=function(o){let l=[];return l.push(i.call(this,o)),t&&(l=l.concat(t.call(this,o))),l}}this.defaults={...this.defaults,...n}}),this}setOptions(s){return this.defaults={...this.defaults,...s},this}lexer(s,e){return G.lex(s,e??this.defaults)}parser(s,e){return H.parse(s,e??this.defaults)}parseMarkdown(s){return(e,r)=>{let n={...r},t={...this.defaults,...n},i=this.onError(!!t.silent,!!t.async);if(this.defaults.async===!0&&n.async===!1)return i(new 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 e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(t.hooks&&(t.hooks.options=t,t.hooks.block=s),t.async)return(async()=>{let o=t.hooks?await t.hooks.preprocess(e):e,l=await(t.hooks?await t.hooks.provideLexer(s):s?G.lex:G.lexInline)(o,t),a=t.hooks?await t.hooks.processAllTokens(l):l;t.walkTokens&&await Promise.all(this.walkTokens(a,t.walkTokens));let c=await(t.hooks?await t.hooks.provideParser(s):s?H.parse:H.parseInline)(a,t);return t.hooks?await t.hooks.postprocess(c):c})().catch(i);try{t.hooks&&(e=t.hooks.preprocess(e));let o=(t.hooks?t.hooks.provideLexer(s):s?G.lex:G.lexInline)(e,t);t.hooks&&(o=t.hooks.processAllTokens(o)),t.walkTokens&&this.walkTokens(o,t.walkTokens);let l=(t.hooks?t.hooks.provideParser(s):s?H.parse:H.parseInline)(o,t);return t.hooks&&(l=t.hooks.postprocess(l)),l}catch(o){return i(o)}}}onError(s,e){return r=>{if(r.message+=`
|
|
65
|
+
Please report this to https://github.com/markedjs/marked.`,s){let n="<p>An error occurred:</p><pre>"+J(r.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(r);throw r}}},re=new ln;function O(s,e){return re.parse(s,e)}O.options=O.setOptions=function(s){return re.setOptions(s),O.defaults=re.defaults,Qe(O.defaults),O};O.getDefaults=Ee;O.defaults=se;O.use=function(...s){return re.use(...s),O.defaults=re.defaults,Qe(O.defaults),O};O.walkTokens=function(s,e){return re.walkTokens(s,e)};O.parseInline=re.parseInline;O.Parser=H;O.parser=H.parse;O.Renderer=we;O.TextRenderer=_e;O.Lexer=G;O.lexer=G.lex;O.Tokenizer=xe;O.Hooks=pe;O.parse=O;var cr=O.options,pr=O.setOptions,ur=O.use,hr=O.walkTokens,dr=O.parseInline;var fr=H.parse,gr=G.lex;function ot(s,e){let r=[];for(let n of document.querySelectorAll(".item"))if(n.classList.contains(`${e}-source`)&&r.unshift(n),n===s)break;return r.map(n=>{let t=n[`${e}Data`],i=t?t():null;return{div:n,result:i}})}function lt(s){let e=t=>Object.entries(t).filter(i=>i[1]).map(i=>`${i[0]}: ${i[1]}`).join("\\n"),r=s.nodes.map((t,i)=>{let o=t.type?`${t.type}\\n${t.props.name}`:t.props.name;return`${i} [label="${o}" ${t.props.url||t.props.tick?`URL="${t.props.url||"#"}" target="_blank"`:""} tooltip="${e(t.props)}"]`}),n=s.rels.map(t=>`${t.from}->${t.to} [label="${t.type}" labeltooltip="${e(t.props)}"]`);return["digraph {","rankdir=LR","node [shape=box style=filled fillcolor=palegreen]",...r,...n,"}"].join(`
|
|
66
|
+
`)}function at(s,e="steps",r,n={}){let t=(k,g)=>r.find(L=>L.slug==k&&(!g||L.domain==g)),i=k=>k?k.map(g=>t(g)):null,o=k=>Math.floor(k*Math.abs(Math.random()-Math.random())),l=k=>k[o(k.length)],a=k=>k.links&&Object.keys(k.links).length<10,c=k=>r.filter(g=>a(g)&&k in g.links),u=(k,g,L)=>L.findIndex(A=>A.slug==k.slug)===g,p=k=>k.toSorted((g,L)=>L.date-g.date).filter(u).slice(0,3),f=r.map(k=>k.domain).filter(he);function h(k){let g=new K,L=m=>g.addUniqNode("",{name:m.title.replaceAll(/ /g,`
|
|
67
|
+
`),title:m.title,site:m.domain}),A=m=>i(m?.patterns?.up)??p(c(m.slug)),y=m=>m?.patterns?.down??Object.keys(m.links||{}),b=L(k);for(let m of A(k))g.addRel("",L(m),b);for(let m of y(k)){let R=t(m);if(R){let _=L(R);g.addRel("",b,_);for(let j of A(R))g.addRel("",L(j),_)}}return g}switch(e){case"steps":return d(s);case"days":return x(e,1,s);case"weeks":return x(e,7,s);case"months":return x(e,30,s);case"hubs":return T(s);case"references":return q();case"lineup":return D();case"topics":return B(s);case"clicks":return v(s)}function d(k=5){return f.map(g=>{let L=g.split(".").slice(0,3).join("."),A=new Set,y=new K,b=0,m=r.filter(w=>w.domain==g&&"links"in w);if(!m.length)return{name:L,graph:null};let R=w=>(b=y.addNode("",{name:w.title.replaceAll(/ /g,`
|
|
68
|
+
`),title:w.title,site:g,links:Object.keys(w.links||{}).filter(S=>t(S))}),b),_=(w,S)=>y.addRel("",w,S),j=w=>y.nodes[w].props.links.filter(S=>!A.has(S)),P=l(m);A.add(P.slug),R(P);for(let w=5;w>0;w--)try{let S=j(b),N=l(S);A.add(N);let M=t(N);_(b,R(M))}catch{}return{name:L,graph:y}})}function x(k,g,L=12){let A=g*24*60*60*1e3,b=[...Array(Number(L)).keys()].map(R=>Date.now()-R*A),m=[];for(let R of b){let _=R-A,j=`${k.replace(/s$/,"")} ${new Date(_).toLocaleDateString()}`,P=r.filter(w=>w.date<R&&w.date>=_).filter(w=>!(w.links&&Object.keys(w.links).length>5));if(P.length){let w=P.reduce((S,N)=>(S.add(N.domain),S),new Set);for(let S of w){let N=new K,M=W=>N.addUniqNode("",{name:W.title.replaceAll(/ /g,`
|
|
69
|
+
`),title:W.title,site:W.domain,date:W.date}),V=S.split(/\.|\:/)[0];for(let W of P.filter(F=>F.domain==S)){let F=M(W);for(let ee in W.links||{}){let Z=t(ee);Z&&N.addRel("",F,M(Z))}}m.push({name:`${j} ${V}`,graph:N})}}}return m}function T(k=12){let g=[],L=new Set,A={};for(let b of r)if(b.links)if(Object.keys(b.links).length<=15)for(let m in b.links)t(m)&&(A[m]=(A[m]||0)+1);else L.add(b.slug);L.size>0&&console.log("hub links ignored for large pages:",[...L]);let y=Object.entries(A).sort((b,m)=>m[1]-b[1]).slice(0,k);console.log({hits:A,hubs:y});for(let b of y){let m=`hub ${b[1]} ${b[0]}`,R=h(t(b[0]));g.push({name:m,graph:R})}return g}function D(){let k=[],g=n.lineup();console.log("library lineup",{scope:n,pageObjects:g});for(let L of g){let A=L.getSlug(),y=L.getRemoteSite(n.host()),b=t(A,y);k.push({name:L.getTitle(),graph:h(b)})}return k}function q(){let k=[],g=n.references();console.log("library references",{items:g});for(let L of g){let{title:A,site:y,slug:b}=L,m=t(b,y);m&&k.push({name:A,graph:h(m)})}return k}function B(k=10){let g=[],y=j=>Date.now()-j*6048e5,b=0;for(;g.length<k&&b<k;){let j=y(b++),P=y(b),w=r.filter(S=>S.date>P&&S.date<=j).filter(S=>!!S.links).filter(S=>!S.title.endsWith(" Survey"));if(w.length){let S=m(w),N=new Date(j).toLocaleDateString();g.push(..._({name:N,graph:S},P,j))}}return g;function m(j){let P=new K,w=S=>{let N="",M=r.find(z=>z.slug==S),V=r.filter(z=>z.slug==S).length,W=M.title,F=M.domain,ee=M.date,Z=W.replaceAll(" ",`
|
|
70
|
+
`),fe=P.nodes.findIndex(z=>z.type==N&&z.props.name==Z),I=fe>=0?fe:P.addNode(N,{name:Z,site:F,date:ee});return V>1&&(P.nodes[I].props.twins=V),I};for(let S of j){let N=w(S.slug);for(let M of R(Object.keys(S.links)))P.addRel("",N,w(M))}return P}function R(j){let P=w=>r.filter(S=>S.slug==w);return j.map(w=>[w,P(w)]).filter(w=>w[1].length).map(w=>[w[0],w[1].sort((S,N)=>N.date-S.date)[0]]).sort((w,S)=>S[1].date-w[1].date).map(w=>w[0]).slice(0,3)}function _(j,P,w){let S=j.graph,N=[],M={},V=S.nodes,W=S.rels,F=[...Array(V.length).keys()].map(I=>[I,Math.random()]).sort((I,z)=>I[1]-z[1]).map(I=>I[0]),ee=I=>{if(I in M)return;F.splice(F.indexOf(I),1);let z=V[I];M[I]=N[0].addNode(z.type,z.props);for(let te of z.out)ee(W[te].to);for(let te of z.in)ee(W[te].from);for(let te of z.out)N[0].addRel("",M[I],M[W[te].to],{})};for(;F.length;){let I=F.shift();if(I in M)continue;let z=V[I],te=z.props.name.replaceAll(`
|
|
71
|
+
`," ");z.in.length+z.out.length&&(N.unshift(new K),M={},ee(I))}let Z=I=>I.props.date||0,fe=I=>{let z=I.nodes.slice(0).sort((ge,bt)=>Z(bt)-Z(ge)).filter(ge=>Z(ge)>=P&&Z(ge)<=w)[0];return console.log({node:z,nodes:I.nodes,name:j.name}),z?z.props.name.split(/\s+/).slice(0,3).join(" "):j.name};return N.reverse().map((I,z)=>({name:fe(I),graph:I}))}}function v(k=1){let g=(m,R,_={})=>m.addUniqNode("",Object.assign({name:R.title.replaceAll(/ /g,`
|
|
72
|
+
`),title:R.title,site:R.domain,date:R.date},_)),L=[],y=n.page().story.filter(m=>m.type=="reference").map(m=>m.slug);for(let m of y){let R=r.find(j=>j.slug==m),_=new K;if(R){let j=g(_,R,{color:"lightblue"});b(_,k,j,R)}else _.addNode("",{name:m.replaceAll(/-/g,`
|
|
73
|
+
`),color:"white"});L.push({name:m,graph:_})}return L;function b(m,R,_,j){if(!(R<1))for(let P in j.links){if(y.includes(P))return;let w=r.find(S=>S.slug==P);if(w){let S=g(m,w);m.addRel("",_,S,{}),b(m,R-1,S,w)}else{let S=m.addUniqNode("",{name:P.replaceAll(/-/g,`
|
|
74
|
+
`),color:"white"});m.addRel("",_,S,{})}}}}}function ct(s,e,r){let n=e.filter(l=>l.match(/\t/)).map(o).flat().sort((l,a)=>l.word<a.word?-1:1),t="zzz".slice(0,s),i=[];for(let l of n){let a=l.word.toLowerCase().slice(0,s);a!=t&&(i.push({group:a,quotes:[]}),t=a),i[i.length-1].quotes.push(l)}return i;function o(l){let[a,c]=l.split(/\t/);return c.replaceAll(/'t\b/g,"t").replaceAll(/'s\b/g,"s").split(/[^a-zA-Z]+/).filter(p=>p.length>3&&!r.has(p.toLowerCase())).map(p=>({word:p,line:l,key:a}))}}function pt(s,e){let r=()=>(s.story||[]).map(i=>i?.id),n=(i,o)=>{let l=r().indexOf(i)+1;s.story.splice(l,0,o)},t=()=>{let i=r().indexOf(e.id);i!==-1&&s.story.splice(i,1)};switch(s.story=s.story||[],e.type){case"create":e.item&&(e.item.title!=null&&(s.title=e.item.title),e.item.story!=null&&(s.story=e.item.story.slice()));break;case"add":n(e.after,e.item);break;case"edit":let i=r().indexOf(e.id);i!==-1?s.story.splice(i,1,e.item):s.story.push(e.item);break;case"move":let o=e.order.indexOf(e.id),l=e.order[o-1],a=s.story[r().indexOf(e.id)];t(),n(l,a);break;case"remove":t();break}s.journal=s.journal||[],e.fork&&s.journal.push({type:"fork",site:e.fork,date:e.date-1}),s.journal.push(e)}function Me(s){if(!s.data)return;let{data:e}=s;if(e?.action=="publishSourceData"&&e?.name=="aspect"){wiki.debug&&console.log("soloListener - source update",{event:s,data:e});return}if(!s.source.opener||s.source.location.pathname!=="/plugins/solo/dialog/"){wiki.debug&&console.log("soloListener - not for us",{event:s});return}wiki.debug&&console.log("soloListener - ours",{event:s});let{action:r,keepLineup:n=!1,pageKey:t=null,title:i=null,context:o=null,page:l=null}=e,a=null;switch(t!=null&&(a=n?null:$(".page").filter((c,u)=>$(u).data("key")==t)),r){case"doInternalLink":wiki.pageHandler.context=o,wiki.doInternalLink(i,a);break;case"showResult":let c=n?{}:{$page:a};wiki.showResult(wiki.newPage(l),c);break;default:console.error({where:"soloListener",message:"unknown action",data:e})}}var De=new O.Renderer;De.heading=({tokens:s,depth:e})=>"<h3>"+De.parser.parseInline(s)+"</h3>";var an={gfm:!0,renderer:De,linksInNewTab:!0,breaks:!0,mangle:!1,headerIds:!1};function ut(s){return`<div style="width:640px">${O.parse(s,an)}</div>`}var cn=Number.MAX_SAFE_INTEGER;function qe(s,e=1e3,r=cn){let n=!1,t=Date.now(),i={stop:l,remainingTicks:r,minMS:e,ticksSoFar:0,timeSinceLastTick:0},o=a();return o.api=i,o;function l(){n=!0}async function a(){if(n||i.remainingTicks<1)return;i.remainingTicks-=1,i.ticksSoFar+=1,i.timeSinceLastTick=Date.now()-t,t=Date.now();let c=new Promise(u=>setTimeout(u,i.minMS));return await s(i),await c,a()}}var ht={trouble:dt,inspect:Q,response:ft,button:pn,element:un,jfetch:hn,status:dn,sourceData:fn,showResult:kn,neighborhood:mn,publishSourceData:gn,newSVG:bn,SVGline:xn,ticker:qe,lineupAtKey:gt,thisLineupKey:wn,lineupPages:yn,host:$n,download:Sn,closeTags:Rn,reset:Tn,report:Ln,ago:An};function dt(s,e){s.innerText.match(/✖︎/)||(s.innerHTML+="<button class=trouble>\u2716\uFE0E</button>",s.querySelector("button").addEventListener("click",r=>{s.outerHTML+=`<span class=trouble>${e}</span>`}))}function Q(s,e,r){let n=s.previousElementSibling;if(r.debug){s["sample-"+e]=r[e];let t=n.querySelector(`.look[data-key="${e}"]`);t||(t=document.createElement("div"),t.classList.add("look"),t.dataset.key=e,t.innerHTML=`<font color=gray size=small>${e} \u21D2</font>`,n.insertAdjacentElement("beforeend",t),t.querySelector("font").addEventListener("click",i=>{let o=t.querySelector(".see");o?o.remove():(o=document.createElement("div"),o.classList.add("see"),t.insertAdjacentElement("beforeend",o),o.innerText=JSON.stringify(s["sample-"+e]).substring(0,400)+" ...")}))}}function ft(s,e){s.innerHTML+=e}function pn(s,e,r){s.querySelector("button")||(ft(s,`<button class=button>${e}</button>`),s.querySelector("button").addEventListener("click",r))}function un(s){return document.getElementById(s)}async function hn(s){return fetch(s).then(e=>e.ok?e.json():null)}function dn(s,e,r){s.innerHTML=e+`<span class=status>${r}</span>`}function fn(s,e){let r=s.closest(".item"),n=ot(r,e).map(({div:t,result:i})=>({classList:[...t.classList],id:t.dataset.id,result:i}));return n.length?n:(dt(s,`Expected source for "${e}" in the lineup.`),null)}function gn(s,e,r){let n=s.closest(".item");n.classList.add(`${e}-source`),n[`${e}Data`]=()=>r}function kn(s,e){let r={$page:$(s.closest(".page"))};wiki.showResult(wiki.newPage(e),r)}function mn(s){return Object.entries(wiki.neighborhoodObject.sites).filter(([e,r])=>!r.sitemapRequestInflight&&(!s||e.includes(s))).map(([e,r])=>(r.sitemap||[]).map(n=>Object.assign({domain:e},n)))}function bn(s){let e=document.createElement("div");return s.closest(".item").firstElementChild.prepend(e),e.outerHTML=`
|
|
12
75
|
<div style="border:1px solid black; background-color:#f8f8f8; margin-bottom:16px;">
|
|
13
76
|
<svg viewBox="0 0 400 400" width=100% height=400>
|
|
14
77
|
<circle id=dot r=5 cx=200 cy=200 stroke="#ccc"></circle>
|
|
15
78
|
</svg>
|
|
16
|
-
</div>`,
|
|
17
|
-
`);
|
|
18
|
-
${p
|
|
19
|
-
${
|
|
79
|
+
</div>`,s.closest(".item").getElementsByTagName("svg")[0]}function xn(s,[e,r],[n,t]){let i=document.createElementNS("http://www.w3.org/2000/svg","line"),o=(a,c)=>i.setAttribute(a,Math.round(c));o("x1",e),o("y1",400-r),o("x2",n),o("y2",400-t),i.style.stroke="black",i.style.strokeWidth="2px",s.appendChild(i);let l=s.getElementById("dot");l.setAttribute("cx",Math.round(n)),l.setAttribute("cy",Math.round(400-t))}function gt(s){return wiki.lineup.atKey(s)}function wn(s){return s.closest(".page").dataset.key}function yn(s){let e=[...document.querySelectorAll(".page")],r=e.indexOf(s.closest(".page"));return e.slice(0,r).map(t=>gt(t.dataset.key))}function $n(){location.host}function Sn(s,e,r="text/json"){var n=`data:${r};charset=utf-8,`+encodeURIComponent(s),t=document.createElement("a");t.setAttribute("href",n),t.setAttribute("download",e),document.body.appendChild(t),t.click(),t.remove()}function Rn(s){let e=document.createElement("div");return e.innerHTML=s,e.innerHTML}function Tn(s){let e=s.nextElementSibling;e.querySelectorAll("div.look").forEach(r=>r.outerText=""),e.querySelectorAll(".trouble").forEach(r=>r.outerText=""),e.querySelectorAll("button.button").forEach(r=>r.outerText=""),e.querySelectorAll("span.status").forEach(r=>r.outerText=""),e.querySelectorAll("div.report").forEach(r=>r.outerText="")}function Ln(s,e,r){s.innerHTML=e+r}function An(s,e=Date.now()){let r=s>e?"-":"",n=Math.abs(e-s),t=Math.floor(n/1e3);if(t<2)return`${r}${n} msec`;let i=Math.floor(t/60);if(i<2)return`${r}${t} seconds`;let o=Math.floor(i/60);if(o<2)return`${r}${i} minutes`;let l=Math.floor(o/24);if(l<2)return`${r}${o} hours`;let a=Math.floor(l/7);if(a<2)return`${r}${l} days`;let c=Math.floor(l/30);if(c<2)return`${r}${a} weeks`;let u=Math.floor(l/365);return u<2?`${r}${c} months`:`${r}${u} years`}async function U(s,e){let r=s.slice();for(;r.length;){let n=r.shift();if("command"in n){let t=n.command,i=e.api?e.api.element(n.key):document.getElementById(n.key),[o,...l]=n.command.split(/ +/),a=r[0],c=a&&"command"in a?null:r.shift(),u={command:t,op:o,args:l,body:c,elem:i,state:e};e.debug&&console.log(u),Se[o]?await Se[o].emit.apply(null,[u]):o.match(/^[A-Z]+$/)?e.api.trouble(i,`${o} doesn't name a block we know.`):n.command.match(/\S/)&&e.api.trouble(i,"Expected line to begin with all-caps keyword.")}}}function En({elem:s,body:e,state:r}){if(!e?.length)return r.api.trouble(s,"CLICK expects indented blocks to follow.");r.api.button(s,"\u25B6",n=>{r.api.reset(s),r.debug=n.shiftKey,U(e,r)})}function vn({elem:s,args:e,state:r}){let n=e[0]=="world"?" \u{1F30E}":" \u{1F600}",t=Object.keys(r).filter(i=>!["context","api","debug"].includes(i));for(let i of t)r.api.inspect(s,i,r);r.api.response(s,n)}async function On({elem:s,command:e,args:r,body:n,state:t}){if(!r[0])return t.api.trouble(s,"FROM expects site/slug as way to federated wiki page.");if(!n?.length)return t.api.trouble(s,"FROM expects indented blocks to follow.");let[i,o]=r[0].split(/\//),l=o?`//${i}/${o}.json`:`/${i}.json`,a=await t.api.jfetch(l);if(!a)return t.api.trouble(s,`FROM could not fetch "${l}" `);t.page=a;let c=a.journal?.findLast(u=>u.type!="fork"&&u.date).date;if(c){let u=t.api.ago(c);t.api.status(s,e,` \u21D2 ${u} old`)}U(n,t)}function In({elem:s,command:e,args:r,body:n,state:t}){if(t.api.status(s,e,""),!("page"in t))return t.api.trouble(s,'Expect "page" as with FROM.');t.api.inspect(s,"page",t);let i=t.page.story.find(p=>p.type=="datalog");if(!i)return t.api.trouble(s,"Expect Datalog plugin in the page.");let o=r[0];if(!o)return t.api.trouble(s,"SENSOR needs a sensor name.");let l=i.text.split(/\n/).map(p=>p.split(/ +/)).filter(p=>p[0]=="SENSOR").find(p=>p[1]==o);if(!l)return t.api.trouble(s,`Expect to find "${o}" in Datalog.`);let a=l[2],c=p=>9/5*(p/16)+32,u=p=>p.reduce((f,h)=>f+h,0)/p.length;t.api.status(s,e," \u23F3"),t.api.jfetch(a).then(p=>{t.debug&&console.log({sensor:l,data:p}),t.api.status(s,e," \u231B");let f=c(u(Object.values(p)));t.temperature=`${f.toFixed(2)}\xB0F`,U(n,t)})}function jn({elem:s,command:e,args:r,state:n}){let t=r[0]||"temperature";if(!(t in n))return n.api.trouble(s,`Expect "${t}" in state`);let i=n[t],o=typeof i;if(!["string","number"].includes(o))return n.api.trouble(s,`Expect state.${t} to be a string or number`);n.api.inspect(s,t,n),n.api.report(s,e,`<div class=report>${i}</div>`)}function Pn({elem:s,command:e,args:r,body:n,state:t}){if(!(r&&r.length))return t.api.trouble(s,'Expected Source topic, like "markers" for Map markers.');let i=r[0],o=t.api.sourceData(s,i);if(!o)return;t.debug&&console.log({topic:i,sources:o});let l=c=>{let u=o.filter(p=>p.classList.includes(c)).length;return u?`${u} ${c}`:null},a=[l("map"),l("image"),l("frame"),l("assets")].filter(c=>c).join(", ");t.api.status(s,e," \u21D2 "+a),t[i]=o.map(({id:c,result:u})=>({id:c,result:u})),n&&U(n,t)}function zn({elem:s,command:e,args:r,state:n}){let t=p=>(+p).toFixed(7),i=[],o=r;for(let p of o)switch(p){case"map":if(!("marker"in n))return n.api.trouble(s,'"map" preview expects "marker" state, like from "SOURCE marker".');n.api.inspect(s,"marker",n);let f=n.marker.map(T=>[T.result]).flat(2).map(T=>`${t(T.lat)}, ${t(T.lon)} ${T.label||""}`).filter(he).join(`
|
|
80
|
+
`);i.push({type:"map",text:f});break;case"graph":if(!("aspect"in n))return n.api.trouble(s,'"graph" preview expects "aspect" state, like from "SOURCE aspect".');n.api.inspect(s,"aspect",n);for(let{result:T}of n.aspect){for(let{name:D,graph:q}of T)n.debug&&console.log({name:D,graph:q}),i.push({type:"paragraph",text:D}),i.push({type:"graphviz",text:lt(q)});i.push({type:"pagefold",text:"."})}break;case"items":if(!("items"in n))return n.api.trouble(s,'"items" preview expects "items" state, like from "KWIC".');n.api.inspect(s,"items",n);let h=T=>{switch(typeof T){case"object":return"type"in T?T:h(T.toString());case"function":return h(T());case"string":if(T.charAt(0)=="<")return{type:"html",text:T};if(T.match(/^https?:/i))return{type:"frame",text:T};default:return{type:"paragraph",text:T.toString()}}},d=n.items.map(h);i.push(...d);break;case"page":if(!("page"in n))return n.api.trouble(s,'"page" preview expects "page" state, like from "FROM".');if(n.api.inspect(s,"page",n),r.length==1)return n.api.showResult(s,n.page);i.push(...n.page.story);break;case"synopsis":let x=`This page created with Mech command: "${e}". See [[${n.context.title}]].`;i.push({type:"paragraph",text:x,id:n.context.itemId});break;default:return n.api.trouble(s,`"${p}" doesn't name an item we can preview`)}let a={title:"Mech Preview"+(n.tick?` ${n.tick}`:""),story:i};for(let p of a.story)p.id||=(Math.random()*10**20).toFixed(0);let c=JSON.parse(JSON.stringify(a)),u=Date.now();a.journal=[{type:"create",date:u,item:c}],n.api.showResult(s,a)}async function Nn({elem:s,command:e,args:r,body:n,state:t}){let i=l=>t.api.element(l.key),o=t.api.neighborhood(r[0]);for(let l=1;l<r.length;l++)o.push(...t.api.neighborhood(r[l]));o=o.filter((l,a)=>l.length&&!o.slice(0,a).find(c=>c[0]?.domain==l[0]?.domain));for(let l of n||[]){if(!l.command.endsWith(" Survey")){t.api.trouble(i(l),"NEIGHBORS expects a Site Survey title, like Pattern Link Survey");continue}let a=o.filter(c=>c.find(u=>u.title==l.command));t.api.status(i(l),l.command,`\u21D2 ${a.length} sites`);for(let c of a){let u=`//${c[0].domain}/${de(l.command)}.json`,p=await t.api.jfetch(u);if(!p)continue;let f=p.story.find(h=>h.type=="frame")?.survey;if(f)for(let h of c){let d=Object.assign({},f.find(x=>x.slug==h.slug),h);Object.assign(h,d)}}}t.neighborhood=o.flat(),t.api.status(s,e,`\u21D2 ${t.neighborhood.length} pages, ${o.length} sites`)}function _n({elem:s,command:e,args:r,state:n}){if(!("neighborhood"in n))return n.api.trouble(s,"WALK expects state.neighborhood, like from NEIGHBORS.");n.api.inspect(s,"neighborhood",n);let[,t,i]=e.match(/\b(\d+)? *(steps|days|weeks|months|hubs|lineup|references|topics|clicks)\b/)||[];if(!i&&e!="WALK")return n.api.trouble(s,"WALK can't understand rest of this block.");let o={host(){return n.api.host()},lineup(){return n.api.lineupPages(s)},references(){let u=n.api.thisLineupKey(s);return n.api.lineupAtKey(u).getRawPage().story.filter(h=>h.type=="reference")},page(){return n.page||n.api.trouble(s,"WALK expects a page, like from FROM"),n.api.inspect(s,"page",n),n.page}},l=at(t,i,n.neighborhood,o),a=l.filter(({graph:u})=>u);n.debug&&console.log({steps:l});let c=a.map(({graph:u})=>u.nodes).flat();if(n.api.status(s,e,` \u21D2 ${a.length} aspects, ${c.length} nodes`),l.find(({graph:u})=>!u)&&n.api.trouble(s,"WALK skipped sites with no links in sitemaps"),a.length){n.aspect=n.aspect||[];let u=n.aspect.find(p=>p.id==s.id);u?u.result=a:n.aspect.push({id:s.id,result:a,source:e}),n.api.publishSourceData(s,"aspect",n.aspect.map(p=>p.result).flat()),n.debug&&console.log({command:e,state:n.aspect})}}function Dn({elem:s,command:e,args:r,body:n,state:t}){if(!n?.length)return t.api.trouble(s,"TICK expects indented blocks to follow.");let i=r[0]||"1";if(!i.match(/^[1-9][0-9]?$/))return t.api.trouble(s,"TICK expects a count from 1 to 99");let o,l;if(t.tick!=null)return l=t.tick,u({shiftKey:t.debug}),o;a();function a(){t.api.button(s,"\u25B6",u)}function c(p){t.api.status(s,e,` \u21D2 ${p} remaining`)}function u(p){t.api.reset(s),t.debug=p.shiftKey,t.tick=+i,c(t.tick),o=t.api.ticker(async()=>{t.debug&&console.log({tick:t.tick,count:i}),"tick"in t&&--t.tick>=0?(c(t.tick),await U(n,t)):(o=o.api.stop(),t.tick=l,t.api.status(s,e,""),a())})}}function Mn({elem:s,command:e,args:r,body:n,state:t}){if(!r.length)return t.api.trouble(s,"UNTIL expects an argument, a word to stop running.");if(!t.tick)return t.api.trouble(s,"UNTIL expects to indented below an iterator, like TICKS.");if(!t.aspect)return t.api.trouble(s,'UNTIL expects "aspect", like from WALK.');Q(s,"aspect",t),t.api.status(s,e,` \u21D2 ${t.tick}`);let i=r[0];for(let{div:o,result:l}of t.aspect)for(let{name:a,graph:c}of l)for(let u of c.nodes)if(u.type.includes(i)||u.props.name.includes(i)){t.debug&&console.log({div:o,result:l,name:a,graph:c,node:u}),delete t.tick,t.api.response(s," done"),n&&U(n,t);return}}function qn({elem:s,command:e,args:r,state:n}){if(r.length<1)return n.api.trouble(s,'FORWARD expects an argument, the number of steps to move a "turtle".');n.turtle??={svg:n.api.newSVG(s),position:[200,200],direction:0};let t=r[0],i=n.turtle.direction*2*Math.PI/360,[o,l]=n.turtle.position;n.turtle.position=[o+t*Math.sin(i),l+t*Math.cos(i)],n.api.SVGline(n.turtle.svg,[o,l],n.turtle.position),n.api.status(s,e,` \u21D2 ${n.turtle.position.map(a=>(a-200).toFixed(1)).join(", ")}`)}function Cn({elem:s,command:e,args:r,state:n}){if(r.length<1)return n.api.trouble(s,'TURN expects an argument, the number of degrees to turn a "turtle".');n.turtle??={svg:n.api.newSVG(s),position:[200,200],direction:0};let t=+r[0];n.turtle.direction+=t,n.api.status(s,e,` \u21D2 ${n.turtle.direction}\xB0`)}function Bn({elem:s,command:e,args:r,body:n,state:t}){if(!("assets"in t))return t.api.trouble(s,"FILE expects state.assets, like from SOURCE assets.");Q(s,"assets",t);let i="//"+window.location.host,o=t.assets.map(({id:u,result:p})=>Object.entries(p).map(([f,h])=>Object.entries(h).map(([d,x])=>x.map(T=>{let D=d.startsWith("//")?d:`${i}${d}`,q=D.replace(/\/assets$/,""),B=`${D}/${f}/${T}`;return{id:u,dir:f,path:d,host:q,file:T,url:B}})))).flat(3);if(t.debug&&console.log({assets:o}),r.length<1)return t.api.trouble(s,"FILE expects an argument, the dot suffix for desired files.");if(!n?.length)return t.api.trouble(s,"FILE expects indented blocks to follow.");let l=r[0],a=o.filter(u=>u.file.endsWith(l)),c=u=>`<img width=12 src=${a[u].host+"/favicon.png"}>`;if(!a)return t.api.trouble(s,`FILE expects to find an asset with "${l}" suffix.`);s.innerHTML=e+`<br><div class=choices style="border:1px solid black; background-color:#f8f8f8; padding:8px;" >${a.map((u,p)=>`<span data-choice=${p} style="cursor:pointer;">
|
|
81
|
+
${c(p)}
|
|
82
|
+
${u.file} \u25B6
|
|
20
83
|
</span>`).join(`<br>
|
|
21
|
-
`)}</div>`,
|
|
84
|
+
`)}</div>`,s.querySelector(".choices").addEventListener("click",u=>{if(!("choice"in u.target.dataset))return;let p=a[u.target.dataset.choice].url;fetch(p).then(f=>f.text()).then(f=>{t.api.status(s,e,` \u21D2 ${f.length} bytes`);let h={};h[l]=f,U(n,Object.assign(h,t))})})}function Wn({elem:s,command:e,args:r,body:n,state:t}){let i=n&&n[0]?.command;if(i&&!i.match(/\$[KW]/))return t.api.trouble(s,"KWIK expects $K or $W in link prototype.");if(!("tsv"in t))return t.api.trouble(s,"KWIC expects a .tsv file, like from ASSETS .tsv.");Q(s,"tsv",t);let o=r[0]||1,l=t.tsv.trim().split(/\n/),a=new Set(["of","and","in","at"]),c=$(s.closest(".page")).data("data"),u=c.story.findIndex(h=>h.type=="pagefold"&&h.text=="stop");if(u>=0){let h=c.story.findIndex((d,x)=>x>u&&d.type=="pagefold");c.story.slice(u+1,h).map(d=>d.text.trim().split(/\s+/)).flat().forEach(d=>a.add(d))}let p=ct(o,l,a);t.api.status(s,e,` \u21D2 ${l.length} lines, ${p.length} groups`);let f=h=>{let d=h.line;if(i){let x=i.replaceAll(/\$K\+/g,h.key.replaceAll(/ /g,"+")).replaceAll(/\$K/g,h.key).replaceAll(/\$W/g,h.word),T=i.match(/\$W/)?h.word:h.key;d=d.replace(T,x)}return d};t.items=p.map(h=>({type:"markdown",text:`# ${h.group}
|
|
22
85
|
|
|
23
|
-
${
|
|
24
|
-
`)}`}))}function
|
|
25
|
-
`+
|
|
86
|
+
${h.quotes.map(x=>f(x)).join(`
|
|
87
|
+
`)}`}))}function Kn({elem:s,command:e,args:r,state:n}){n.api.status(s,e,"");let t,i;if(r.length<1)if(n.info)Q(s,"info",n),t=n.info.domain,i=n.info.slug,n.api.status(s,e,` \u21D2 ${n.info.title}`);else return n.api.trouble(s,"SHOW expects a slug or site/slug to open in the lineup.");else{let a=r[0];[t,i]=a.includes("/")?a.split(/\//):[null,a]}if([...document.querySelectorAll(".page")].map(a=>a.id).includes(i))return n.api.trouble(s,"SHOW expects a page not already in the lineup.");let l=s.closest(".page");wiki.doInternalLink(i,l,t)}function Gn({elem:s,command:e,state:r}){if(!r.neighborhood)return r.api.trouble(s,"RANDOM expected a neighborhood, like from NEIGHBORS.");Q(s,"neighborhood",r);let n=r.neighborhood,t=n.length,i=Math.floor(Math.random()*t);r.api.status(s,e,` \u21D2 ${i} of ${t}`),r.info=n[i]}function Hn({elem:s,command:e,args:r,body:n,state:t}){let i=r[0]||"1";return i.match(/^[1-9][0-9]?$/)?new Promise(o=>{n&&U(n,t).then(a=>{t.debug&&console.log(e,"children",a)}),t.api.status(s,e,` \u21D2 ${i} remain`);let l=setInterval(()=>{--i>0?t.api.status(s,e,` \u21D2 ${i} remain`):(clearInterval(l),t.api.status(s,e," \u21D2 done"),t.debug&&console.log(e,"done"),o())},1e3)}):t.api.trouble(s,"SLEEP expects seconds from 1 to 99")}function Un({elem:s,command:e,args:r,body:n,state:t}){if(!n)return t.api.trouble(s,"TOGETHER expects indented commands to run together.");let i=n.map(o=>U([o],t));return Promise.all(i)}async function Fn({elem:s,command:e,args:r,body:n,state:t}){if(!n)return t.api.trouble(s,"GET expects indented commands to run on the server.");let i={},o=t.context.site;if(r.length)for(let d of r)if(d in t)Q(s,d,t),i[d]=t[d];else if(d.match(/\./))o=d;else return t.api.trouble(s,`GET expected "${d}" to name state or site.`);let l=t.context.slug,a=t.context.itemId,c=`mech=${btoa(JSON.stringify(n))}&state=${btoa(JSON.stringify(i))}`,u=`//${o}/plugin/mech/run/${l}/${a}?${c}`;t.api.status(s,e," \u21D2 in progress");let p=Date.now(),f;try{if(f=await fetch(u).then(d=>d.ok?d.json():d.status),"err"in f)return t.api.trouble(s,`RUN received error "${f.err}"`)}catch(d){return t.api.trouble(s,`RUN failed with "${d.message}"`)}t.result=f;for(let d of f.mech.flat(9)){let x=document.getElementById(d.key);"status"in d&&t.api.status(x,d.command,` \u21D2 ${d.status}`),"trouble"in d&&t.api.trouble(x,d.trouble)}"debug"in f.state&&delete f.state.debug,Object.assign(t,f.state);let h=((Date.now()-p)/1e3).toFixed(3);t.api.status(s,e,` \u21D2 ${h} seconds`)}async function Zn({elem:s,command:e,args:r,body:n,state:t}){if(!n)return t.api.trouble(s,"GET expects indented commands to run on the server.");let i={},o;if(r.length){o=r[0];for(let h of r.slice(1))if(h in t)Q(s,h,t),i[h]=t[h];else return t.api.trouble(s,`GET expected "${h}" to name state.`)}else return t.api.trouble(s,"PLUGIN expected a plugin as way to run commands on the server.");let l=t.context.itemId,a=`mech=${btoa(JSON.stringify(n))}&state=${btoa(JSON.stringify(i))}`,c=`/plugin/${o}/mech?${a}`;t.api.status(s,e," \u21D2 in progress");let u=Date.now(),p;try{if(p=await fetch(c).then(h=>h.ok?h.json():{err:h.status}),console.log("result",p),"err"in p)return t.api.trouble(s,`PLUGIN received error "${p.err}"`)}catch(h){return t.api.trouble(s,`PLUGIN failed with "${h.message}"`)}t.result=p;for(let h of p.mech.flat(9)){let d=document.getElementById(h.key);"status"in h&&t.api.status(d,h.command,` \u21D2 ${h.status}`),"trouble"in h&&t.api.trouble(d,h.trouble)}"debug"in p.state&&delete p.state.debug,Object.assign(t,p.state);let f=((Date.now()-u)/1e3).toFixed(3);t.api.status(s,e,` \u21D2 ${f} seconds`)}function Jn({elem:s,command:e,args:r,body:n,state:t}){let i=l=>JSON.parse(JSON.stringify(l)),o=l=>JSON.stringify(l).length;if(r.length<1)return t.api.trouble(s,'DELTA expects argument, "have" or "apply" on client.');if(n)return t.api.trouble(s,"DELTA doesn't expect indented input.");switch(r[0]){case"have":let l=t.context.page.journal.filter(p=>p.type!="fork");t.recent=l[l.length-1].date,t.api.status(s,e,` \u21D2 ${new Date(t.recent).toLocaleString()}`);break;case"apply":if(!("actions"in t))return t.api.trouble(s,'DELTA apply expect "actions" as input.');Q(s,"actions",t);let a=i(t.context.page),c=o(a);for(let p of t.actions)pt(a,p);t.page=a;let u=o(a);t.api.status(s,e,` \u21D2 \u2206 ${((u-c)/c*100).toFixed(1)}%`);break;default:t.api.trouble(s,`DELTA doesn't know "${r[0]}".`)}}function Qn({elem:s,command:e,state:r}){if(!r.neighborhood)return r.api.trouble(s,"ROSTER expected a neighborhood, like from NEIGHBORS.");r.api.inspect(s,"neighborhood",r);let n=r.neighborhood,t=n.map(l=>l.domain).filter(he),i=l=>l[Math.floor(Math.random()*l.length)];r.debug&&console.log(n);let o=[{type:"roster",text:`Mech
|
|
88
|
+
`+t.join(`
|
|
26
89
|
`)},{type:"activity",text:`ROSTER Mech
|
|
27
|
-
SINCE 30 days`}];
|
|
28
|
-
<summary>${
|
|
29
|
-
<pre style="white-space: pre-wrap;">${
|
|
30
|
-
</details>`))}break;case"images":if(!
|
|
31
|
-
`))}async function
|
|
32
|
-
`);
|
|
33
|
-
<pre>${
|
|
34
|
-
${
|
|
35
|
-
`)}),
|
|
36
|
-
`)})}},
|
|
37
|
-
`," "))).filter(
|
|
38
|
-
`),`print-${
|
|
39
|
-
`),
|
|
40
|
-
`),
|
|
41
|
-
`)};return
|
|
90
|
+
SINCE 30 days`}];r.api.status(s,e,` \u21D2 ${t.length} sites`),r.items=o}function Vn({elem:s,command:e,state:r}){let n=r.api.lineupPages(s).map(t=>{let i=t.getRawPage(),o=t.getRemoteSite(r.api.host()),l=i.title||"Empty",a=de(l),c=i.story[0]?.text||"empty";return{type:"reference",site:o,slug:a,title:l,text:c}});r.api.status(s,e,` \u21D2 ${n.length} pages`),r.items=n}function Xn({elem:s,command:e,args:r,state:n}){if(r.length<1)return n.api.trouble(s,"LISTEN expects argument, an action.");let t=r[0],i=Date.now(),o=0,l=a;l.action="publishSourceData",l.id=s.id,window.addEventListener("message",a),$(".main").on("thumb",(c,u)=>console.log("jquery",{evt:c,thumb:u})),n.api.status(s,e," \u21D2 ready");function a(c){console.log({event:c});let{data:u}=c;if(u.action=="publishSourceData"&&(u.name==t||u.topic==t))if(o++,l.count=o,n.debug&&console.log({count:o,data:u}),o<=100){let p=Date.now(),f=p-i;i=p,n.api.status(s,e,` \u21D2 ${o} events, ${f} ms`)}else window.removeEventListener("message",a)}}function Yn({elem:s,command:e,args:r,state:n}){if(r.length<1)return n.api.trouble(s,"MESSAGE expects argument, an action.");let t=r[0],i={action:"publishSourceData",topic:t,name:t};window.postMessage(i,"*"),n.api.status(s,e," \u21D2 sent")}async function er({elem:s,command:e,state:r}){if(!("aspect"in r))return r.api.trouble(s,'"SOLO" expects "aspect" state, like from "WALK".');Q(s,"aspect",r),r.api.status(s,e,"");let n=r.aspect.map(a=>({source:a.source||a.id,aspects:a.result})),t=n.reduce((a,c)=>a+c.aspects.length,0);r.api.status(s,e,` \u21D2 ${n.length} sources, ${t} aspects`);let i=s.closest(".page").dataset.key,o={type:"batch",sources:n,pageKey:i};(typeof window.soloListener>"u"||window.soloListener==null)&&(console.log("**** Adding solo listener"),window.soloListener=Me,window.addEventListener("message",Me)),await kt(750);let l=window.open("/plugins/solo/dialog/#","solo","popup,height=720,width=1280");l.location.pathname!="/plugins/solo/dialog/"?(console.log("launching new dialog"),l.addEventListener("load",a=>{console.log("launched and loaded"),l.postMessage(o,window.origin)})):(console.log("reusing existing dialog"),l.postMessage(o,window.origin))}function tr({elem:s,args:e,state:r}){let n=i=>i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),t=[];switch(e[0]){case"state":for(let o in r){let l=r[o];l!=null&&(typeof l!="string"&&(l=JSON.stringify(r[o],null,2)),t.push(`<details>
|
|
91
|
+
<summary>${o}</summary>
|
|
92
|
+
<pre style="white-space: pre-wrap;">${n(l)}</pre>
|
|
93
|
+
</details>`))}break;case"images":if(!r.commons)return r.api.trouble(s,'POPUP images expects "commons" state, like from "GET" "COMMONS"');let i=e[1]=="all"?r.commons.all:r.commons.here;for(let o of i.items)t.push(`<span><img height=200 src=/assets/plugins/image/${o}></span>`);break;default:return r.api.trouble(s,`POPUP doesn't know "${e[0]}".`)}wiki.dialog(s.innerText,t.join(`
|
|
94
|
+
`))}async function nr({elem:s,command:e,args:r,state:n}){if(!["outline","draft"].includes(r[0]))return n.api.trouble(s,"Expects PRINT outline or PRINT draft.");let t=r[0];if(!n.aspect)return n.api.trouble(s,'PRINT expects "aspect", like from WALK clicks.');if(n.api.inspect(s,"aspect",n),!n.neighborhood)return n.api.trouble(s,'PRINT expectes "neighborhood", like from NEIGHBORS.');n.api.inspect(s,"neighborhood",n);let i=n.aspect,o=n.neighborhood;console.log("print",{aspect:i,neighborhood:o});let l=[],a={missing:[],omitted:[],domains:[],forks:[],wishes:[],errors:[]},c={},u=(v,k,g)=>{k in v||(v[k]=[]),v[k].push(g)},p=(v,k)=>{let g=a[v];console.log("explain",v,c[v]);let L=y=>Math.abs(y.split("").reduce((b,m)=>m.charCodeAt(0)+(b<<6)+(b<<16)-b,0)).toString(16),A=Object.keys(g).toSorted((y,b)=>g[b].length-g[y].length);if(A.length){let y=[];for(let b of A){let m=g[b].filter(D).sort().map(R=>`[[${R}]]`).join(`
|
|
95
|
+
`);y.push(`<details><summary>${b} \xD7 ${g[b].length}</summary>
|
|
96
|
+
<pre>${m}</pre></details>`)}h.push({type:"markdown",text:`# ${k}
|
|
97
|
+
${c[v]||""}`,id:L(k)}),A[0].match(/\.\w+\.\w+$/)&&h.push({type:"roster",text:A.join(`
|
|
98
|
+
`)}),h.push({type:"html",text:y.join(`
|
|
99
|
+
`)})}},h=[{type:"paragraph",text:`From ${new Date().toString().replace(/ *\(.*\)/,"")}`},{type:"solo",text:"INCLUDED",aspects:i[0].result}];l.push("<h1>Story</h1>");let d=i.find(v=>v.source.match(/^WALK.*clicks/));if(!d)return n.api.trouble(s,"PRINT needs aspect from WALK clicks");let x=d.result.map(v=>v.name);await B(x,"story"),l.push("<h1>Garden</h1>");let T=d.result.map(v=>v.graph.nodes.map(k=>k.props)).flat(),D=(v,k,g)=>g.indexOf(v)===k,q=T.map(v=>de(v.name.replaceAll(`
|
|
100
|
+
`," "))).filter(D).filter(v=>!x.includes(v)).sort();await B(q,"garden"),console.log({tally:a,explain:c}),p("domains","Sourced Sites"),p("missing","Missing Pages"),p("omitted","Omitted Links"),p("forks","Omitted Forks"),p("wishes","Unusual Plugins"),p("errors","Program Errors"),h.length&&(n.items=h),n.api.status(s,e,` \u21D2 ${x.length} story, ${q.length} garden`),n.api.download(l.join(`
|
|
101
|
+
`),`print-${t}.html`,"text/html");async function B(v,k){let g='style="width:640px"',L=A=>A.replaceAll(/\[\[(.*?)\]\]/g,(y,b)=>`<a href="#${de(b)}">${b}</a>`).replaceAll(/\[.*? (.*?)\]/g,(y,b)=>`<i>${b}</i>`);for(let A of v){let y=o.find(b=>b.slug==A);if(!y){u(a.missing,k,A),c.missing="These pages weren't found in PRINT's neighborhood.";continue}if(u(a.domains,y.domain,y.slug),c.domains="Pages have been retrieved from these sites. Remove sites from the PRINT neighborhood if these should be found elsewhere.",k=="garden"){for(let b in y.links)v.includes(b)||u(a.omitted,A,b);c.omitted="Garden pages with links to pages omitted from the garden. These may show up with a deeper WALK into the garden'"}if(t=="outline")l.push(`<p id="${y.slug}" ${g}"><b title="${y.domain}">${y.title}</b> -- ${L(y.synopsis)}</p>`);else{let b=v.indexOf(A)+1;n.api.status(s,e,` \u21D2 ${b} of ${v.length} from ${k}`);try{console.log(y.domain,y.title);let m=await n.api.jfetch(`//${y.domain}/${y.slug}.json`);l.push(`<section id="${y.slug}"><h3 title="${y.domain}">${y.title}</h3>`);for(let R of m.story)switch(R.type!="paragraph"&&u(a.wishes,R.type,A),c.wishes='Items of type "paragraph" are expected. Types "markdown" and "html" may show without revision. The remainder appear as only a one-line note.',R.type){case"paragraph":l.push(`<p ${g}>${L(R.text)}</p>`);break;case"markdown":l.push(L(ut(R.text)));break;case"html":l.push(`<p ${g}>${L(n.api.closeTags(R.text))}</p>`);break;default:l.push(`<p ${g}>Item type "${R.type}" omitted.</p>`)}for(let R of m.journal)R.site&&!o.find(_=>_.domain==R.site)&&u(a.forks,R.site,A),c.forks="Wiki remembers where pages may once have lived but PRINT only looks for pages in the neighborhoods prvided.";l.push("</section>")}catch(m){u(a.errors,m.message,y.slug),c.errors="Any pages that lead to program errors should be explored by developers. Until then they will be ignored."}}}}}async function rr({elem:s,command:e,args:r,body:n,state:t}){let i=t.api.thisLineupKey(s),a=t.api.lineupAtKey(i).getRawPage().story.filter(h=>h.type=="code");if(!a)return t.api.trouble(s,"CODE expects the Code plugin in use on this page.");let c=a.map(h=>h.text).join(`
|
|
102
|
+
`),u=r.length?r[0]:"default",p={trouble(h){t.api.trouble(s,h)},response(h){t.api.response(s,h)},status(h){t.api.status(s,e,h)},report(h){t.api.report(s,e,h)},graph(h=[],d=[]){return new K(h,d)},body(){return n}},f={get(h,d){return d=="api"?p:(t.api.inspect(s,d,h),h[d])}};try{let h=await import(`data:text/javascript;base64,${btoa(c)}`);if(!(u in h))return p.trouble(`Expected export of function "${u}".`);let d=new Proxy(t,f),x=await h[u].apply(d,r.slice(1));typeof x<"u"&&t.api.status(s,e,` \u21D2 ${x}`)}catch(h){let d=c.split(/\n/),x=d.map((B,v)=>`${v+1} ${B}`).join(`
|
|
103
|
+
`),T=h.message,D=h.line??h.lineNumber,q=h.columnNumber;if(D){let B=d[D-1];q?T+=`<span class=code>${B.substring(0,q-1)}<font color=red>\u2716\uFE0E</font>${B.substring(q-1)}</span>`:T+=`<span class=code>${B}</span>`}return t.api.trouble(s,T)}}async function sr({elem:s,command:e,args:r,state:n}){let t={txt:"text/plain",html:"text/html",csv:"text/csv",tsv:"text/tsv",json:"application/json"};if(!r.length)return n.api.trouble(s,"DOWNLOAD expects an argument, a file name to use when downloaded.");let i=r[0].match(/^.+\.(txt|html|csv|tsv|json)$/);if(console.log(i),!i)return n.api.trouble(s,"DOWNLOAD expects a familiar suffix, one of txt, html, csv, tsv, or json.");let[o,l]=i;if(!(l in n))return n.api.trouble(s,`DOWNLOAD expects to find "${l}" in state.`);let a=l=="json"?JSON.stringify(n.json):n[l];n.api.status(s,e,` \u21D2 ${a.length} bytes`),n.api.download(a,o,t[l])}var Se={CLICK:{emit:En},HELLO:{emit:vn},FROM:{emit:On},SENSOR:{emit:In},REPORT:{emit:jn},SOURCE:{emit:Pn},PREVIEW:{emit:zn},NEIGHBORS:{emit:Nn},WALK:{emit:_n},TICK:{emit:Dn},UNTIL:{emit:Mn},FORWARD:{emit:qn},TURN:{emit:Cn},FILE:{emit:Bn},KWIC:{emit:Wn},SHOW:{emit:Kn},RANDOM:{emit:Gn},SLEEP:{emit:Hn},TOGETHER:{emit:Un},PLUGIN:{emit:Zn},GET:{emit:Fn},DELTA:{emit:Jn},ROSTER:{emit:Qn},LINEUP:{emit:Vn},LISTEN:{emit:Xn},MESSAGE:{emit:Yn},SOLO:{emit:er},POPUP:{emit:tr},PRINT:{emit:nr},CODE:{emit:rr},DOWNLOAD:{emit:sr}};function ir(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Ce(s,e,r){for(;s.length;){let t=s[0].match(/( *)(.*)/),i=t[1].length,o=t[2];if(i==r)e.push({command:o}),s.shift();else if(i>r){var n=[];e.push(n),Ce(s,n,i)}else return e}return e}function mt(s){let e=Math.floor(Math.random()*1e6),r=(n,t)=>{let i=[];for(let o of n){let l=`${e}.${t.join(".")}`;o.key=l,"command"in o?i.push(`<div></div><span id=${l} class=block >${ir(o.command)}</span>`):i.push(`<div id=${l} class=body>${r(o,[...t,0])}</div>`),t[t.length-1]++}return i.join(`
|
|
104
|
+
`)};return r(s,[0])}var he=(s,e,r)=>r.indexOf(s)===e,kt=s=>new Promise(e=>setTimeout(e,s)),de=s=>s.replace(/\s/g,"-").replace(/[^A-Za-z0-9-]/g,"").toLowerCase();function Wr(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function or(s,e){$("link[href='/plugins/mech/mech.css']").length||$('<link rel="stylesheet" href="/plugins/mech/mech.css" type="text/css">').appendTo("head");let r=e.text.split(/\n/),n=Ce(r,[],0),t=mt(n),i=s.parents(".page"),o=i.data("key"),a={context:{item:e,itemId:e.id,pageKey:o,page:wiki.lineup.atKey(o).getRawPage(),origin:window.origin,site:i.data("site")||window.location.host,slug:i.attr("id"),title:i.data("data").title,blocks:Object.keys(Se)},api:ht};s.append(`<div style="background-color:#eee;padding:15px;border-top:8px;">${t}</div>`),U(n,a)}function lr(s,e){return s.dblclick(()=>wiki.textEditor(s,e))}typeof window<"u"&&window!==null&&(window.plugins.mech={emit:or,bind:lr});})();
|
|
42
105
|
//# sourceMappingURL=mech.js.map
|