@observablehq/stdlib
Advanced tools
Comparing version 3.2.1 to 3.3.0
@@ -1,2 +0,2 @@ | ||
// @observablehq/stdlib v3.2.1 Copyright 2019 Observable, Inc. | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).observablehq=e.observablehq||{})}(this,function(e){"use strict";async function t(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}class n{constructor(e,t){Object.defineProperties(this,{_url:{value:e},name:{value:t,enumerable:!0}})}async url(){return this._url}async blob(){return(await t(this)).blob()}async arrayBuffer(){return(await t(this)).arrayBuffer()}async text(){return(await t(this)).text()}async json(){return(await t(this)).json()}async stream(){return(await t(this)).body}async image(){const e=await this.url();return new Promise((t,n)=>{const r=new Image;new URL(e,document.baseURI).origin!==new URL(location).origin&&(r.crossOrigin="anonymous"),r.onload=()=>t(r),r.onerror=()=>n(new Error(`Unable to load file: ${this.name}`)),r.src=e})}}function r(e){throw new Error(`File not found: ${e}`)}function i(e){return function(){return e}}var s={math:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};var o=0;function l(e){this.id=e,this.href=new URL(`#${e}`,location)+""}l.prototype.toString=function(){return"url("+this.href+")"};var a={canvas:function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n},context2d:function(e,t,n){null==n&&(n=devicePixelRatio);var r=document.createElement("canvas");r.width=e*n,r.height=t*n,r.style.width=e+"px";var i=r.getContext("2d");return i.scale(n,n),i},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),i=r.appendChild(document.createElement("button"));async function s(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),i.textContent=n,i.disabled=!1}return i.textContent=n,r.download=t,r.onclick=async t=>{if(i.disabled=!0,r.href)return s();i.textContent="Saving…";try{const t=await("function"==typeof e?e():e);i.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){i.textContent=n}if(t.eventPhase)return s();i.disabled=!1},r},element:function(e,t){var n,r=e+="",i=r.indexOf(":");i>=0&&"xmlns"!==(r=e.slice(0,i))&&(e=e.slice(i+1));var o=s.hasOwnProperty(r)?document.createElementNS(s[r],e):document.createElement(e);if(t)for(var l in t)i=(r=l).indexOf(":"),n=t[l],i>=0&&"xmlns"!==(r=l.slice(0,i))&&(l=l.slice(i+1)),s.hasOwnProperty(r)?o.setAttributeNS(s[r],l,n):o.setAttribute(l,n);return o},input:function(e){var t=document.createElement("input");return null!=e&&(t.type=e),t},range:function(e,t,n){1===arguments.length&&(t=e,e=null);var r=document.createElement("input");return r.min=e=null==e?0:+e,r.max=t=null==t?1:+t,r.step=null==n?"any":n=+n,r.type="range",r},select:function(e){var t=document.createElement("select");return Array.prototype.forEach.call(e,function(e){var n=document.createElement("option");n.value=n.textContent=e,t.appendChild(n)}),t},svg:function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox",[0,0,e,t]),n.setAttribute("width",e),n.setAttribute("height",t),n},text:function(e){return document.createTextNode(e)},uid:function(e){return new l("O-"+(null==e?"":e+"-")+ ++o)}};var u={buffer:function(e){return new Promise(function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsArrayBuffer(e)})},text:function(e){return new Promise(function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsText(e)})},url:function(e){return new Promise(function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsDataURL(e)})}};function c(){return this}function h(e,t){let n=!1;return{[Symbol.iterator]:c,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function p(e){let t,n,r=!1;const i=e(function(e){n?(n(e),n=null):r=!0;return t=e});return{[Symbol.iterator]:c,throw:()=>({done:!0}),return:()=>(null!=i&&i(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise(e=>n=e)}}}}function f(e){switch(e.type){case"range":case"number":return e.valueAsNumber;case"date":return e.valueAsDate;case"checkbox":return e.checked;case"file":return e.multiple?e.files:e.files[0];default:return e.value}}var d={disposable:h,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return p(function(t){var n=function(e){switch(e.type){case"button":case"submit":case"checkbox":return"click";case"file":return"change";default:return"input"}}(e),r=f(e);function i(){t(f(e))}return e.addEventListener(n,i),void 0!==r&&t(r),function(){e.removeEventListener(n,i)}})},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:p,queue:function(e){let t;const n=[],r=e(function(e){n.push(e),t&&(t(n.shift()),t=null);return e});return{[Symbol.iterator]:c,throw:()=>({done:!0}),return:()=>(null!=r&&r(),{done:!0}),next:function(){return{done:!1,value:n.length?Promise.resolve(n.shift()):new Promise(e=>t=e)}}}},range:function*(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((t-e)/n));++r<i;)yield e+r*n},valueAt:function(e,t){if(!(!isFinite(t=+t)||t<0||t!=t|0))for(var n,r=-1;!(n=e.next()).done;)if(++r===t)return n.value},worker:function(e){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"})),n=new Worker(t);return h(n,()=>{n.terminate(),URL.revokeObjectURL(t)})}};function g(e,t){return function(n){var r,i,s,o,l,a,u,c,h=n[0],p=[],f=null,d=-1;for(l=1,a=arguments.length;l<a;++l){if((r=arguments[l])instanceof Node)p[++d]=r,h+="\x3c!--o:"+d+"--\x3e";else if(Array.isArray(r)){for(u=0,c=r.length;u<c;++u)(i=r[u])instanceof Node?(null===f&&(p[++d]=f=document.createDocumentFragment(),h+="\x3c!--o:"+d+"--\x3e"),f.appendChild(i)):(f=null,h+=i);f=null}else h+=r;h+=n[l]}if(f=e(h),++d>0){for(s=new Array(d),o=document.createTreeWalker(f,NodeFilter.SHOW_COMMENT,null,!1);o.nextNode();)i=o.currentNode,/^o:/.test(i.nodeValue)&&(s[+i.nodeValue.slice(2)]=i);for(l=0;l<d;++l)(i=s[l])&&i.parentNode.replaceChild(p[l],i)}return 1===f.childNodes.length?f.removeChild(f.firstChild):11===f.nodeType?((i=t()).appendChild(f),i):f}}var m=g(function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)},function(){return document.createElement("span")}),b={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:P,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:P,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:P,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};function w(e){this.tokens=[],this.tokens.links={},this.options=e||C.defaults,this.rules=b.normal,this.options.gfm&&(this.options.tables?this.rules=b.tables:this.rules=b.gfm)}b.bullet=/(?:[*+-]|\d+\.)/,b.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,b.item=_(b.item,"gm")(/bull/g,b.bullet)(),b.list=_(b.list)(/bull/g,b.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+b.def.source+")")(),b.blockquote=_(b.blockquote)("def",b.def)(),b._tag="(?!(?: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",b.html=_(b.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,b._tag)(),b.paragraph=_(b.paragraph)("hr",b.hr)("heading",b.heading)("lheading",b.lheading)("blockquote",b.blockquote)("tag","<"+b._tag)("def",b.def)(),b.normal=A({},b),b.gfm=A({},b.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),b.gfm.paragraph=_(b.paragraph)("(?!","(?!"+b.gfm.fences.source.replace("\\1","\\2")+"|"+b.list.source.replace("\\1","\\3")+"|")(),b.tables=A({},b.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),w.rules=b,w.lex=function(e,t){return new w(t).lex(e)},w.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},w.prototype.token=function(e,t,n){var r,i,s,o,l,a,u,c,h;for(e=e.replace(/^ +$/gm,"");e;)if((s=this.rules.newline.exec(e))&&(e=e.substring(s[0].length),s[0].length>1&&this.tokens.push({type:"space"})),s=this.rules.code.exec(e))e=e.substring(s[0].length),s=s[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?s:s.replace(/\n+$/,"")});else if(s=this.rules.fences.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"code",lang:s[2],text:s[3]||""});else if(s=this.rules.heading.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"heading",depth:s[1].length,text:s[2]});else if(t&&(s=this.rules.nptable.exec(e))){for(e=e.substring(s[0].length),a={type:"table",header:s[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:s[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:s[3].replace(/\n$/,"").split("\n")},c=0;c<a.align.length;c++)/^ *-+: *$/.test(a.align[c])?a.align[c]="right":/^ *:-+: *$/.test(a.align[c])?a.align[c]="center":/^ *:-+ *$/.test(a.align[c])?a.align[c]="left":a.align[c]=null;for(c=0;c<a.cells.length;c++)a.cells[c]=a.cells[c].split(/ *\| */);this.tokens.push(a)}else if(s=this.rules.lheading.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"heading",depth:"="===s[2]?1:2,text:s[1]});else if(s=this.rules.hr.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"hr"});else if(s=this.rules.blockquote.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"blockquote_start"}),s=s[0].replace(/^ *> ?/gm,""),this.token(s,t,!0),this.tokens.push({type:"blockquote_end"});else if(s=this.rules.list.exec(e)){for(e=e.substring(s[0].length),o=s[2],this.tokens.push({type:"list_start",ordered:o.length>1}),r=!1,h=(s=s[0].match(this.rules.item)).length,c=0;c<h;c++)u=(a=s[c]).length,~(a=a.replace(/^ *([*+-]|\d+\.) +/,"")).indexOf("\n ")&&(u-=a.length,a=this.options.pedantic?a.replace(/^ {1,4}/gm,""):a.replace(new RegExp("^ {1,"+u+"}","gm"),"")),this.options.smartLists&&c!==h-1&&(o===(l=b.bullet.exec(s[c+1])[0])||o.length>1&&l.length>1||(e=s.slice(c+1).join("\n")+e,c=h-1)),i=r||/\n\n(?!\s*$)/.test(a),c!==h-1&&(r="\n"===a.charAt(a.length-1),i||(i=r)),this.tokens.push({type:i?"loose_item_start":"list_item_start"}),this.token(a,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(s=this.rules.html.exec(e))e=e.substring(s[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===s[1]||"script"===s[1]||"style"===s[1]),text:s[0]});else if(!n&&t&&(s=this.rules.def.exec(e)))e=e.substring(s[0].length),this.tokens.links[s[1].toLowerCase()]={href:s[2],title:s[3]};else if(t&&(s=this.rules.table.exec(e))){for(e=e.substring(s[0].length),a={type:"table",header:s[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:s[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:s[3].replace(/(?: *\| *)?\n$/,"").split("\n")},c=0;c<a.align.length;c++)/^ *-+: *$/.test(a.align[c])?a.align[c]="right":/^ *:-+: *$/.test(a.align[c])?a.align[c]="center":/^ *:-+ *$/.test(a.align[c])?a.align[c]="left":a.align[c]=null;for(c=0;c<a.cells.length;c++)a.cells[c]=a.cells[c].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(a)}else if(t&&(s=this.rules.paragraph.exec(e)))e=e.substring(s[0].length),this.tokens.push({type:"paragraph",text:"\n"===s[1].charAt(s[1].length-1)?s[1].slice(0,-1):s[1]});else if(s=this.rules.text.exec(e))e=e.substring(s[0].length),this.tokens.push({type:"text",text:s[0]});else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0));return this.tokens};var v={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ <>]+(@|:\/)[^ <>]+)>/,url:P,tag:/^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^<'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)([\s\S]*?[^`])\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:P,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};function x(e,t){if(this.options=t||C.defaults,this.links=e,this.rules=v.normal,this.renderer=this.options.renderer||new k,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=v.breaks:this.rules=v.gfm:this.options.pedantic&&(this.rules=v.pedantic)}function k(e){this.options=e||{}}function y(e){this.tokens=[],this.token=null,this.options=e||C.defaults,this.options.renderer=this.options.renderer||new k,this.renderer=this.options.renderer,this.renderer.options=this.options}function $(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function _(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=(i=i.source||i).replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function L(e,t){return S[" "+e]||(/^[^:]+:\/*[^\/]*$/.test(e)?S[" "+e]=e+"/":S[" "+e]=e.replace(/[^\/]*$/,"")),e=S[" "+e],"//"===t.slice(0,2)?e.replace(/:[\s\S]*/,":")+t:"/"===t.charAt(0)?e.replace(/(:\/*[^\/]*)[\s\S]*/,"$1")+t:e+t}v._inside=/(?:\[[^\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/,v._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,v.link=_(v.link)("inside",v._inside)("href",v._href)(),v.reflink=_(v.reflink)("inside",v._inside)(),v.normal=A({},v),v.pedantic=A({},v.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),v.gfm=A({},v.normal,{escape:_(v.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:_(v.text)("]|","~]|")("|","|https?://|")()}),v.breaks=A({},v.gfm,{br:_(v.br)("{2,}","*")(),text:_(v.gfm.text)("{2,}","*")()}),x.rules=v,x.output=function(e,t,n){return new x(t,n).output(e)},x.prototype.output=function(e){for(var t,n,r,i,s="";e;)if(i=this.rules.escape.exec(e))e=e.substring(i[0].length),s+=i[1];else if(i=this.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=$(":"===i[1].charAt(6)?this.mangle(i[1].substring(7)):this.mangle(i[1])),r=this.mangle("mailto:")+n):r=n=$(i[1]),s+=this.renderer.link(r,null,n);else if(this.inLink||!(i=this.rules.url.exec(e))){if(i=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(i[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(i[0])&&(this.inLink=!1),e=e.substring(i[0].length),s+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):$(i[0]):i[0];else if(i=this.rules.link.exec(e))e=e.substring(i[0].length),this.inLink=!0,s+=this.outputLink(i,{href:i[2],title:i[3]}),this.inLink=!1;else if((i=this.rules.reflink.exec(e))||(i=this.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),!(t=this.links[t.toLowerCase()])||!t.href){s+=i[0].charAt(0),e=i[0].substring(1)+e;continue}this.inLink=!0,s+=this.outputLink(i,t),this.inLink=!1}else if(i=this.rules.strong.exec(e))e=e.substring(i[0].length),s+=this.renderer.strong(this.output(i[2]||i[1]));else if(i=this.rules.em.exec(e))e=e.substring(i[0].length),s+=this.renderer.em(this.output(i[2]||i[1]));else if(i=this.rules.code.exec(e))e=e.substring(i[0].length),s+=this.renderer.codespan($(i[2].trim(),!0));else if(i=this.rules.br.exec(e))e=e.substring(i[0].length),s+=this.renderer.br();else if(i=this.rules.del.exec(e))e=e.substring(i[0].length),s+=this.renderer.del(this.output(i[1]));else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),s+=this.renderer.text($(this.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),r=n=$(i[1]),s+=this.renderer.link(r,null,n);return s},x.prototype.outputLink=function(e,t){var n=$(t.href),r=t.title?$(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,$(e[1]))},x.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},x.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,i=0;i<r;i++)t=e.charCodeAt(i),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},k.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'<pre><code class="'+this.options.langPrefix+$(t,!0)+'">'+(n?e:$(e,!0))+"\n</code></pre>\n":"<pre><code>"+(n?e:$(e,!0))+"\n</code></pre>"},k.prototype.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},k.prototype.html=function(e){return e},k.prototype.heading=function(e,t,n){return"<h"+t+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+e+"</h"+t+">\n"},k.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},k.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"</"+n+">\n"},k.prototype.listitem=function(e){return"<li>"+e+"</li>\n"},k.prototype.paragraph=function(e){return"<p>"+e+"</p>\n"},k.prototype.table=function(e,t){return"<table>\n<thead>\n"+e+"</thead>\n<tbody>\n"+t+"</tbody>\n</table>\n"},k.prototype.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},k.prototype.tablecell=function(e,t){var n=t.header?"th":"td";return(t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">")+e+"</"+n+">\n"},k.prototype.strong=function(e){return"<strong>"+e+"</strong>"},k.prototype.em=function(e){return"<em>"+e+"</em>"},k.prototype.codespan=function(e){return"<code>"+e+"</code>"},k.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},k.prototype.del=function(e){return"<del>"+e+"</del>"},k.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(function(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,function(e,t){return"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return n}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:")||0===r.indexOf("data:"))return n}this.options.baseUrl&&!E.test(e)&&(e=L(this.options.baseUrl,e));var i='<a href="'+e+'"';return t&&(i+=' title="'+t+'"'),i+=">"+n+"</a>"},k.prototype.image=function(e,t,n){this.options.baseUrl&&!E.test(e)&&(e=L(this.options.baseUrl,e));var r='<img src="'+e+'" alt="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">"},k.prototype.text=function(e){return e},y.parse=function(e,t,n){return new y(t,n).parse(e)},y.prototype.parse=function(e){this.inline=new x(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var t="";this.next();)t+=this.tok();return t},y.prototype.next=function(){return this.token=this.tokens.pop()},y.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},y.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},y.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,i="",s="";for(n="",e=0;e<this.token.header.length;e++)({header:!0,align:this.token.align[e]}),n+=this.renderer.tablecell(this.inline.output(this.token.header[e]),{header:!0,align:this.token.align[e]});for(i+=this.renderer.tablerow(n),e=0;e<this.token.cells.length;e++){for(t=this.token.cells[e],n="",r=0;r<t.length;r++)n+=this.renderer.tablecell(this.inline.output(t[r]),{header:!1,align:this.token.align[r]});s+=this.renderer.tablerow(n)}return this.renderer.table(i,s);case"blockquote_start":for(s="";"blockquote_end"!==this.next().type;)s+=this.tok();return this.renderer.blockquote(s);case"list_start":s="";for(var o=this.token.ordered;"list_end"!==this.next().type;)s+=this.tok();return this.renderer.list(s,o);case"list_item_start":for(s="";"list_item_end"!==this.next().type;)s+="text"===this.token.type?this.parseText():this.tok();return this.renderer.listitem(s);case"loose_item_start":for(s="";"list_item_end"!==this.next().type;)s+=this.tok();return this.renderer.listitem(s);case"html":var l=this.token.pre||this.options.pedantic?this.token.text:this.inline.output(this.token.text);return this.renderer.html(l);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText())}};var S={},E=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function P(){}function A(e){for(var t,n,r=1;r<arguments.length;r++)for(n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function C(e,t,n){if(n||"function"==typeof t){n||(n=t,t=null);var r,i,s=(t=A({},C.defaults,t||{})).highlight,o=0;try{r=w.lex(e,t)}catch(e){return n(e)}i=r.length;var l=function(e){if(e)return t.highlight=s,n(e);var i;try{i=y.parse(r,t)}catch(t){e=t}return t.highlight=s,e?n(e):n(null,i)};if(!s||s.length<3)return l();if(delete t.highlight,!i)return l();for(;o<r.length;o++)!function(e){"code"!==e.type?--i||l():s(e.text,e.lang,function(t,n){return t?l(t):null==n||n===e.text?--i||l():(e.text=n,e.escaped=!0,void(--i||l()))})}(r[o])}else try{return t&&(t=A({},C.defaults,t)),y.parse(w.lex(e,t),t)}catch(e){if(e.message+="\nPlease report this to https://github.com/chjj/marked.",(t||C.defaults).silent)return"<p>An error occurred:</p><pre>"+$(e.message+"",!0)+"</pre>";throw e}}P.exec=P,C.options=C.setOptions=function(e){return A(C.defaults,e),C},C.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,sanitizer:null,mangle:!0,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1,headerPrefix:"",renderer:new k,xhtml:!1,baseUrl:null},C.Parser=y,C.parser=y.parse,C.Renderer=k,C.Lexer=w,C.lexer=w.lex,C.InlineLexer=x,C.inlineLexer=x.output,C.parse=C;const j="https://cdn.jsdelivr.net/npm/@observablehq/highlight.js@2.0.0/";function q(e){return function(){return g(function(t){var n=document.createElement("div");n.innerHTML=C(t,{langPrefix:""}).trim();var r=n.querySelectorAll("pre code[class]");return r.length>0&&e(j+"highlight.min.js").then(function(t){r.forEach(function(n){function r(){t.highlightBlock(n),n.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(n.className)?r():e(j+"async-languages/index.js").then(r=>{if(r.has(n.className))return e(j+"async-languages/"+r.get(n.className)).then(e=>{t.registerLanguage(n.className,e)})}).then(r,r)})}),n},function(){return document.createElement("div")})}}function O(e){let t;Object.defineProperties(this,{generator:{value:p(e=>void(t=e))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*R(){for(;;)yield Date.now()}var U=new Map;function N(e,t){var n;return(n=U.get(e=+e))?n.then(i(t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise(function(n){U.delete(t);var r=t-e;if(!(r>0))throw new Error("invalid time");if(r>2147483647)throw new Error("too long to wait");setTimeout(n,r)});return U.set(t,n),n}(n,e).then(i(t))}var M={delay:function(e,t){return new Promise(function(n){setTimeout(function(){n(t)},e)})},tick:function(e,t){return N(Math.ceil((Date.now()+1)/e)*e,t)},when:N};function T(e,t){if(/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new Error("illegal name");return"https://unpkg.com/"+e}const F=new Map,z=[],D=z.map,I=z.some,W=z.hasOwnProperty,B="https://cdn.jsdelivr.net/npm/",H=/^((?:@[^\/@]+\/)?[^\/@]+)(?:@([^\/]+))?(?:\/(.*))?$/,V=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,G=/\.[^\/]*$/,X=["unpkg","jsdelivr","browser","main"];class RequireError extends Error{constructor(e){super(e)}}function J(e){const t=H.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function K(e){const t=`${B}${e.name}${e.version?`@${e.version}`:""}/package.json`;let n=F.get(t);return n||F.set(t,n=fetch(t).then(e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!F.has(e.url)&&F.set(e.url,n),e.json()})),n}RequireError.prototype.name=RequireError.name;var Q=Y(async function(e,t){if(e.startsWith(B)&&(e=e.substring(B.length)),/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new RequireError("illegal name");const n=J(e);if(!n)return`${B}${e}`;if(!n.version&&null!=t&&t.startsWith(B)){const e=await K(J(t.substring(B.length)));n.version=e.dependencies&&e.dependencies[n.name]||e.peerDependencies&&e.peerDependencies[n.name]}if(n.path&&!G.test(n.path)&&(n.path+=".js"),n.path&&n.version&&V.test(n.version))return`${B}${n.name}@${n.version}/${n.path}`;const r=await K(n);return`${B}${r.name}@${r.version}/${n.path||function(e){for(const t of X){const n=e[t];if("string"==typeof n)return G.test(n)?n:`${n}.js`}}(r)||"index.js"}`});function Y(e){const t=new Map,n=i(null);function r(e){if("string"!=typeof e)return e;let n=t.get(e);return n||t.set(e,n=new Promise((t,n)=>{const r=document.createElement("script");r.onload=()=>{try{t(z.pop()(i(e)))}catch(e){n(new RequireError("invalid module"))}r.remove()},r.onerror=()=>{n(new RequireError("unable to load module")),r.remove()},r.async=!0,r.src=e,window.define=ne,document.head.appendChild(r)})),n}function i(t){return n=>Promise.resolve(e(n,t)).then(r)}function s(e){return arguments.length>1?Promise.all(D.call(arguments,n)).then(Z):n(e)}return s.alias=function(t){return Y((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r))},s.resolve=e,s}function Z(e){const t={};for(const n of e)for(const e in n)W.call(n,e)&&(null==n[e]?Object.defineProperty(t,e,{get:ee(n,e)}):t[e]=n[e]);return t}function ee(e,t){return()=>e[t]}function te(e){return"exports"===(e+="")||"module"===e}function ne(e,t,n){const r=arguments.length;r<2?(n=e,t=[]):r<3&&(n=t,t="string"==typeof e?[]:e),z.push(I.call(t,te)?e=>{const r={},i={exports:r};return Promise.all(D.call(t,t=>"exports"===(t+="")?r:"module"===t?i:e(t))).then(e=>(n.apply(null,e),i.exports))}:e=>Promise.all(D.call(t,e)).then(e=>"function"==typeof n?n.apply(null,e):n))}function re(e){return null==e?Q:Y(e)}ne.amd={};var ie=g(function(e){var t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.innerHTML=e.trim(),t},function(){return document.createElementNS("http://www.w3.org/2000/svg","g")}),se=String.raw;function oe(e){return new Promise(function(t,n){var r=document.createElement("link");r.rel="stylesheet",r.href=e,r.onerror=n,r.onload=t,document.head.appendChild(r)})}function le(e){return function(){return Promise.all([e("@observablehq/katex@0.11.1/dist/katex.min.js"),e.resolve("@observablehq/katex@0.11.1/dist/katex.min.css").then(oe)]).then(function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(se.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n})}}function ae(){return p(function(e){var t=e(document.body.clientWidth);function n(){var n=document.body.clientWidth;n!==t&&e(t=n)}return window.addEventListener("resize",n),function(){window.removeEventListener("resize",n)}})}e.FileAttachments=function(e){return t=>{const r=e(t+="");if(null==r)throw new Error(`File not found: ${t}`);return new n(r,t)}},e.Library=function(e){const t=re(e);Object.defineProperties(this,{DOM:{value:a,writable:!0,enumerable:!0},FileAttachment:{value:i(r),writable:!0,enumerable:!0},Files:{value:u,writable:!0,enumerable:!0},Generators:{value:d,writable:!0,enumerable:!0},html:{value:i(m),writable:!0,enumerable:!0},md:{value:q(t),writable:!0,enumerable:!0},Mutable:{value:i(O),writable:!0,enumerable:!0},now:{value:R,writable:!0,enumerable:!0},Promises:{value:M,writable:!0,enumerable:!0},require:{value:i(t),writable:!0,enumerable:!0},resolve:{value:i(T),writable:!0,enumerable:!0},svg:{value:i(ie),writable:!0,enumerable:!0},tex:{value:le(t),writable:!0,enumerable:!0},width:{value:ae,writable:!0,enumerable:!0}})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
// @observablehq/stdlib v3.3.0 Copyright 2020 Observable, Inc. | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).observablehq=e.observablehq||{})}(this,function(e){"use strict";async function t(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}class n{constructor(e,t){Object.defineProperties(this,{_url:{value:e},name:{value:t,enumerable:!0}})}async url(){return this._url}async blob(){return(await t(this)).blob()}async arrayBuffer(){return(await t(this)).arrayBuffer()}async text(){return(await t(this)).text()}async json(){return(await t(this)).json()}async stream(){return(await t(this)).body}async image(){const e=await this.url();return new Promise((t,n)=>{const r=new Image;new URL(e,document.baseURI).origin!==new URL(location).origin&&(r.crossOrigin="anonymous"),r.onload=()=>t(r),r.onerror=()=>n(new Error(`Unable to load file: ${this.name}`)),r.src=e})}}function r(e){throw new Error(`File not found: ${e}`)}const o=new Map,i=[],a=i.map,u=i.some,l=i.hasOwnProperty,c="https://cdn.jsdelivr.net/npm/",s=/^((?:@[^\/@]+\/)?[^\/@]+)(?:@([^\/]+))?(?:\/(.*))?$/,f=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,d=/\.[^\/]*$/,m=["unpkg","jsdelivr","browser","main"];class RequireError extends Error{constructor(e){super(e)}}function h(e){const t=s.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function w(e){const t=`${c}${e.name}${e.version?`@${e.version}`:""}/package.json`;let n=o.get(t);return n||o.set(t,n=fetch(t).then(e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!o.has(e.url)&&o.set(e.url,n),e.json()})),n}RequireError.prototype.name=RequireError.name;var v=p(async function(e,t){if(e.startsWith(c)&&(e=e.substring(c.length)),/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new RequireError("illegal name");const n=h(e);if(!n)return`${c}${e}`;if(!n.version&&null!=t&&t.startsWith(c)){const e=await w(h(t.substring(c.length)));n.version=e.dependencies&&e.dependencies[n.name]||e.peerDependencies&&e.peerDependencies[n.name]}if(n.path&&!d.test(n.path)&&(n.path+=".js"),n.path&&n.version&&f.test(n.version))return`${c}${n.name}@${n.version}/${n.path}`;const r=await w(n);return`${c}${r.name}@${r.version}/${n.path||function(e){for(const t of m){const n=e[t];if("string"==typeof n)return d.test(n)?n:`${n}.js`}}(r)||"index.js"}`});function p(e){const t=new Map,n=o(null);function r(e){if("string"!=typeof e)return e;let n=t.get(e);return n||t.set(e,n=new Promise((t,n)=>{const r=document.createElement("script");r.onload=()=>{try{t(i.pop()(o(e)))}catch(e){n(new RequireError("invalid module"))}r.remove()},r.onerror=()=>{n(new RequireError("unable to load module")),r.remove()},r.async=!0,r.src=e,window.define=x,document.head.appendChild(r)})),n}function o(t){return n=>Promise.resolve(e(n,t)).then(r)}function u(e){return arguments.length>1?Promise.all(a.call(arguments,n)).then(b):n(e)}return u.alias=function(t){return p((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r))},u.resolve=e,u}function b(e){const t={};for(const n of e)for(const e in n)l.call(n,e)&&(null==n[e]?Object.defineProperty(t,e,{get:g(n,e)}):t[e]=n[e]);return t}function g(e,t){return()=>e[t]}function y(e){return"exports"===(e+="")||"module"===e}function x(e,t,n){const r=arguments.length;r<2?(n=e,t=[]):r<3&&(n=t,t="string"==typeof e?[]:e),i.push(u.call(t,y)?e=>{const r={},o={exports:r};return Promise.all(a.call(t,t=>"exports"===(t+="")?r:"module"===t?o:e(t))).then(e=>(n.apply(null,e),o.exports))}:e=>Promise.all(a.call(t,e)).then(e=>"function"==typeof n?n.apply(null,e):n))}function E(e){return function(){return e}}x.amd={};var P={math:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};var j=0;function k(e){this.id=e,this.href=new URL(`#${e}`,location)+""}k.prototype.toString=function(){return"url("+this.href+")"};var L={canvas:function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n},context2d:function(e,t,n){null==n&&(n=devicePixelRatio);var r=document.createElement("canvas");r.width=e*n,r.height=t*n,r.style.width=e+"px";var o=r.getContext("2d");return o.scale(n,n),o},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),o=r.appendChild(document.createElement("button"));async function i(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),o.textContent=n,o.disabled=!1}return o.textContent=n,r.download=t,r.onclick=async t=>{if(o.disabled=!0,r.href)return i();o.textContent="Saving…";try{const t=await("function"==typeof e?e():e);o.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){o.textContent=n}if(t.eventPhase)return i();o.disabled=!1},r},element:function(e,t){var n,r=e+="",o=r.indexOf(":");o>=0&&"xmlns"!==(r=e.slice(0,o))&&(e=e.slice(o+1));var i=P.hasOwnProperty(r)?document.createElementNS(P[r],e):document.createElement(e);if(t)for(var a in t)o=(r=a).indexOf(":"),n=t[a],o>=0&&"xmlns"!==(r=a.slice(0,o))&&(a=a.slice(o+1)),P.hasOwnProperty(r)?i.setAttributeNS(P[r],a,n):i.setAttribute(a,n);return i},input:function(e){var t=document.createElement("input");return null!=e&&(t.type=e),t},range:function(e,t,n){1===arguments.length&&(t=e,e=null);var r=document.createElement("input");return r.min=e=null==e?0:+e,r.max=t=null==t?1:+t,r.step=null==n?"any":n=+n,r.type="range",r},select:function(e){var t=document.createElement("select");return Array.prototype.forEach.call(e,function(e){var n=document.createElement("option");n.value=n.textContent=e,t.appendChild(n)}),t},svg:function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox",[0,0,e,t]),n.setAttribute("width",e),n.setAttribute("height",t),n},text:function(e){return document.createTextNode(e)},uid:function(e){return new k("O-"+(null==e?"":e+"-")+ ++j)}};var $={buffer:function(e){return new Promise(function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsArrayBuffer(e)})},text:function(e){return new Promise(function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsText(e)})},url:function(e){return new Promise(function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsDataURL(e)})}};function A(){return this}function N(e,t){let n=!1;return{[Symbol.iterator]:A,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function O(e){let t,n,r=!1;const o=e(function(e){n?(n(e),n=null):r=!0;return t=e});return{[Symbol.iterator]:A,throw:()=>({done:!0}),return:()=>(null!=o&&o(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise(e=>n=e)}}}}function C(e){switch(e.type){case"range":case"number":return e.valueAsNumber;case"date":return e.valueAsDate;case"checkbox":return e.checked;case"file":return e.multiple?e.files:e.files[0];default:return e.value}}var M={disposable:N,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return O(function(t){var n=function(e){switch(e.type){case"button":case"submit":case"checkbox":return"click";case"file":return"change";default:return"input"}}(e),r=C(e);function o(){t(C(e))}return e.addEventListener(n,o),void 0!==r&&t(r),function(){e.removeEventListener(n,o)}})},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:O,queue:function(e){let t;const n=[],r=e(function(e){n.push(e),t&&(t(n.shift()),t=null);return e});return{[Symbol.iterator]:A,throw:()=>({done:!0}),return:()=>(null!=r&&r(),{done:!0}),next:function(){return{done:!1,value:n.length?Promise.resolve(n.shift()):new Promise(e=>t=e)}}}},range:function*(e,t,n){e=+e,t=+t,n=(o=arguments.length)<2?(t=e,e=0,1):o<3?1:+n;for(var r=-1,o=0|Math.max(0,Math.ceil((t-e)/n));++r<o;)yield e+r*n},valueAt:function(e,t){if(!(!isFinite(t=+t)||t<0||t!=t|0))for(var n,r=-1;!(n=e.next()).done;)if(++r===t)return n.value},worker:function(e){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"})),n=new Worker(t);return N(n,()=>{n.terminate(),URL.revokeObjectURL(t)})}};function R(e,t){return function(n){var r,o,i,a,u,l,c,s,f=n[0],d=[],m=null,h=-1;for(u=1,l=arguments.length;u<l;++u){if((r=arguments[u])instanceof Node)d[++h]=r,f+="\x3c!--o:"+h+"--\x3e";else if(Array.isArray(r)){for(c=0,s=r.length;c<s;++c)(o=r[c])instanceof Node?(null===m&&(d[++h]=m=document.createDocumentFragment(),f+="\x3c!--o:"+h+"--\x3e"),m.appendChild(o)):(m=null,f+=o);m=null}else f+=r;f+=n[u]}if(m=e(f),++h>0){for(i=new Array(h),a=document.createTreeWalker(m,NodeFilter.SHOW_COMMENT,null,!1);a.nextNode();)o=a.currentNode,/^o:/.test(o.nodeValue)&&(i[+o.nodeValue.slice(2)]=o);for(u=0;u<h;++u)(o=i[u])&&o.parentNode.replaceChild(d[u],o)}return 1===m.childNodes.length?m.removeChild(m.firstChild):11===m.nodeType?((o=t()).appendChild(m),o):m}}var U=R(function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)},function(){return document.createElement("span")});const S="https://cdn.jsdelivr.net/npm/@observablehq/highlight.js@2.0.0/";function F(e){return function(){return e("marked@0.3.12/marked.min.js").then(function(t){return R(function(n){var r=document.createElement("div");r.innerHTML=t(n,{langPrefix:""}).trim();var o=r.querySelectorAll("pre code[class]");return o.length>0&&e(S+"highlight.min.js").then(function(t){o.forEach(function(n){function r(){t.highlightBlock(n),n.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(n.className)?r():e(S+"async-languages/index.js").then(r=>{if(r.has(n.className))return e(S+"async-languages/"+r.get(n.className)).then(e=>{t.registerLanguage(n.className,e)})}).then(r,r)})}),r},function(){return document.createElement("div")})})}}function q(e){let t;Object.defineProperties(this,{generator:{value:O(e=>void(t=e))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*D(){for(;;)yield Date.now()}var T=new Map;function W(e,t){var n;return(n=T.get(e=+e))?n.then(E(t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise(function(n){T.delete(t);var r=t-e;if(!(r>0))throw new Error("invalid time");if(r>2147483647)throw new Error("too long to wait");setTimeout(n,r)});return T.set(t,n),n}(n,e).then(E(t))}var _={delay:function(e,t){return new Promise(function(n){setTimeout(function(){n(t)},e)})},tick:function(e,t){return W(Math.ceil((Date.now()+1)/e)*e,t)},when:W};function B(e,t){if(/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new Error("illegal name");return"https://unpkg.com/"+e}function H(e){return null==e?v:p(e)}var z=R(function(e){var t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.innerHTML=e.trim(),t},function(){return document.createElementNS("http://www.w3.org/2000/svg","g")}),I=String.raw;function V(e){return new Promise(function(t,n){var r=document.createElement("link");r.rel="stylesheet",r.href=e,r.onerror=n,r.onload=t,document.head.appendChild(r)})}function G(e){return function(){return Promise.all([e("@observablehq/katex@0.11.1/dist/katex.min.js"),e.resolve("@observablehq/katex@0.11.1/dist/katex.min.css").then(V)]).then(function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(I.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n})}}function X(){return O(function(e){var t=e(document.body.clientWidth);function n(){var n=document.body.clientWidth;n!==t&&e(t=n)}return window.addEventListener("resize",n),function(){window.removeEventListener("resize",n)}})}var J=Object.assign(function(e){const t=H(e);Object.defineProperties(this,{DOM:{value:L,writable:!0,enumerable:!0},FileAttachment:{value:E(r),writable:!0,enumerable:!0},Files:{value:$,writable:!0,enumerable:!0},Generators:{value:M,writable:!0,enumerable:!0},html:{value:E(U),writable:!0,enumerable:!0},md:{value:F(t),writable:!0,enumerable:!0},Mutable:{value:E(q),writable:!0,enumerable:!0},now:{value:D,writable:!0,enumerable:!0},Promises:{value:_,writable:!0,enumerable:!0},require:{value:E(t),writable:!0,enumerable:!0},resolve:{value:E(B),writable:!0,enumerable:!0},svg:{value:E(z),writable:!0,enumerable:!0},tex:{value:G(t),writable:!0,enumerable:!0},width:{value:X,writable:!0,enumerable:!0}})},{resolve:v.resolve});e.FileAttachments=function(e){return t=>{const r=e(t+="");if(null==r)throw new Error(`File not found: ${t}`);return new n(r,t)}},e.Library=J,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@observablehq/stdlib", | ||
"version": "3.2.1", | ||
"version": "3.3.0", | ||
"license": "ISC", | ||
@@ -30,14 +30,12 @@ "main": "dist/stdlib.js", | ||
"dependencies": { | ||
"d3-require": "^1.2.4", | ||
"marked": "https://github.com/observablehq/marked.git#94c6b946f462fd25db4465d71a6859183f86c57f" | ||
"d3-require": "^1.2.4" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^6.5.1", | ||
"husky": "^3.0.7", | ||
"jsdom": "^15.1.0", | ||
"rollup": "^1.22.0", | ||
"eslint": "^6.7.2", | ||
"husky": "^3.1.0", | ||
"rollup": "^1.27.8", | ||
"rollup-plugin-node-resolve": "^5.0.0", | ||
"rollup-plugin-terser": "^5.1.2", | ||
"tap": "^14.6.9" | ||
"tap": "^14.10.2" | ||
} | ||
} |
@@ -884,3 +884,3 @@ # @observablehq/stdlib | ||
<a href="#Library" name="Library">#</a> <b>Library</b>([<i>resolve</i>]) [<>](https://github.com/observablehq/stdlib/blob/master/src/index.js "Source") | ||
<a href="#Library" name="Library">#</a> <b>Library</b>([<i>resolve</i>]) [<>](https://github.com/observablehq/stdlib/blob/master/src/library.js "Source") | ||
@@ -897,1 +897,5 @@ Returns a new standard library object. If a *resolve* function is specified, it is a function that returns a promise to the URL of the module with the specified *name*; this is used internally by [require](#require) (and by extension, [md](#md) and [tex](#tex)). See [d3-require](https://github.com/d3/d3-require/blob/master/README.md) for details. | ||
The properties on the returned *library* instance correspond to the symbols (documented above) that are available in Observable notebooks. However, note that the library fields (such as *library*.now) are *definitions*, not values: the values may be wrapped in a function which, when invoked, returns the corresponding value. | ||
<a href="#Library_resolve" name="Library_resolve">#</a> Library.<b>resolve</b>(<i>name</i>, [<i>base</i>]) [<>](https://github.com/observablehq/stdlib/blob/master/src/library.js "Source") | ||
An alias for [d3.require.resolve](https://github.com/d3/d3-require/blob/master/README.md#require_resolve). |
@@ -0,1 +1,2 @@ | ||
import {require as requireDefault} from "d3-require"; | ||
import constant from "./constant.js"; | ||
@@ -17,3 +18,3 @@ import DOM from "./dom/index.js"; | ||
export default function Library(resolver) { | ||
export default Object.assign(function Library(resolver) { | ||
const require = requirer(resolver); | ||
@@ -36,2 +37,2 @@ Object.defineProperties(this, { | ||
}); | ||
} | ||
}, {resolve: requireDefault.resolve}); |
import template from "./template.js"; | ||
import marked from "marked"; | ||
@@ -9,39 +8,41 @@ const HL_ROOT = | ||
return function() { | ||
return template( | ||
function(string) { | ||
var root = document.createElement("div"); | ||
root.innerHTML = marked(string, {langPrefix: ""}).trim(); | ||
var code = root.querySelectorAll("pre code[class]"); | ||
if (code.length > 0) { | ||
require(HL_ROOT + "highlight.min.js").then(function(hl) { | ||
code.forEach(function(block) { | ||
function done() { | ||
hl.highlightBlock(block); | ||
block.parentNode.classList.add("observablehq--md-pre"); | ||
} | ||
if (hl.getLanguage(block.className)) { | ||
done(); | ||
} else { | ||
require(HL_ROOT + "async-languages/index.js") | ||
.then(index => { | ||
if (index.has(block.className)) { | ||
return require(HL_ROOT + | ||
"async-languages/" + | ||
index.get(block.className)).then(language => { | ||
hl.registerLanguage(block.className, language); | ||
}); | ||
} | ||
}) | ||
.then(done, done); | ||
} | ||
return require("marked@0.3.12/marked.min.js").then(function(marked) { | ||
return template( | ||
function(string) { | ||
var root = document.createElement("div"); | ||
root.innerHTML = marked(string, {langPrefix: ""}).trim(); | ||
var code = root.querySelectorAll("pre code[class]"); | ||
if (code.length > 0) { | ||
require(HL_ROOT + "highlight.min.js").then(function(hl) { | ||
code.forEach(function(block) { | ||
function done() { | ||
hl.highlightBlock(block); | ||
block.parentNode.classList.add("observablehq--md-pre"); | ||
} | ||
if (hl.getLanguage(block.className)) { | ||
done(); | ||
} else { | ||
require(HL_ROOT + "async-languages/index.js") | ||
.then(index => { | ||
if (index.has(block.className)) { | ||
return require(HL_ROOT + | ||
"async-languages/" + | ||
index.get(block.className)).then(language => { | ||
hl.registerLanguage(block.className, language); | ||
}); | ||
} | ||
}) | ||
.then(done, done); | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
return root; | ||
}, | ||
function() { | ||
return document.createElement("div"); | ||
} | ||
return root; | ||
}, | ||
function() { | ||
return document.createElement("div"); | ||
} | ||
); | ||
); | ||
}); | ||
}; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
1
6
900
0
3
78082
687