Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@observablehq/stdlib

Package Overview
Dependencies
Maintainers
5
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@observablehq/stdlib - npm Package Compare versions

Comparing version 5.2.4 to 5.3.0

4

dist/stdlib.js

@@ -1,2 +0,2 @@

// @observablehq/stdlib v5.2.4 Copyright 2022 Observable, Inc.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).observablehq=e.observablehq||{})}(this,(function(e){"use strict";var t={},n={};function r(e){return new Function("d","return {"+e.map((function(e,t){return JSON.stringify(e)+": d["+t+'] || ""'})).join(",")+"}")}function a(e){var t=Object.create(null),n=[];return e.forEach((function(e){for(var r in e)r in t||n.push(t[r]=r)})),n}function o(e,t){var n=e+"",r=n.length;return r<t?new Array(t-r+1).join(0)+n:n}function i(e){var t,n=e.getUTCHours(),r=e.getUTCMinutes(),a=e.getUTCSeconds(),i=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":((t=e.getUTCFullYear())<0?"-"+o(-t,6):t>9999?"+"+o(t,6):o(t,4))+"-"+o(e.getUTCMonth()+1,2)+"-"+o(e.getUTCDate(),2)+(i?"T"+o(n,2)+":"+o(r,2)+":"+o(a,2)+"."+o(i,3)+"Z":a?"T"+o(n,2)+":"+o(r,2)+":"+o(a,2)+"Z":r||n?"T"+o(n,2)+":"+o(r,2)+"Z":"")}function s(e){var o=new RegExp('["'+e+"\n\r]"),s=e.charCodeAt(0);function c(e,r){var a,o=[],i=e.length,c=0,l=0,u=i<=0,f=!1;function d(){if(u)return n;if(f)return f=!1,t;var r,a,o=c;if(34===e.charCodeAt(o)){for(;c++<i&&34!==e.charCodeAt(c)||34===e.charCodeAt(++c););return(r=c)>=i?u=!0:10===(a=e.charCodeAt(c++))?f=!0:13===a&&(f=!0,10===e.charCodeAt(c)&&++c),e.slice(o+1,r-1).replace(/""/g,'"')}for(;c<i;){if(10===(a=e.charCodeAt(r=c++)))f=!0;else if(13===a)f=!0,10===e.charCodeAt(c)&&++c;else if(a!==s)continue;return e.slice(o,r)}return u=!0,e.slice(o,i)}for(10===e.charCodeAt(i-1)&&--i,13===e.charCodeAt(i-1)&&--i;(a=d())!==n;){for(var m=[];a!==t&&a!==n;)m.push(a),a=d();r&&null==(m=r(m,l++))||o.push(m)}return o}function l(t,n){return t.map((function(t){return n.map((function(e){return f(t[e])})).join(e)}))}function u(t){return t.map(f).join(e)}function f(e){return null==e?"":e instanceof Date?i(e):o.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,a,o=c(e,(function(e,o){if(n)return n(e,o-1);a=e,n=t?function(e,t){var n=r(e);return function(r,a){return t(n(r),a,e)}}(e,t):r(e)}));return o.columns=a||[],o},parseRows:c,format:function(t,n){return null==n&&(n=a(t)),[n.map(f).join(e)].concat(l(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=a(e)),l(e,t).join("\n")},formatRows:function(e){return e.map(u).join("\n")},formatRow:u,formatValue:f}}var c=s(","),l=c.parse,u=c.parseRows,f=s("\t"),d=f.parse,m=f.parseRows;function h(e){for(var t in e){var n,r,a=e[t].trim();if(a)if("true"===a)a=!0;else if("false"===a)a=!1;else if("NaN"===a)a=NaN;else if(isNaN(n=+a)){if(!(r=a.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)))continue;p&&r[4]&&!r[7]&&(a=a.replace(/-/g,"/").replace(/T/," ")),a=new Date(a)}else a=n;else a=null;e[t]=a}return e}const p=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours();function w(e,t,n){return{resolve:(r=n)=>`${e}@${t}/${r}`}}const b=w("d3","7.7.0","dist/d3.min.js"),y=w("@observablehq/inputs","0.10.4","dist/inputs.min.js"),v=w("@observablehq/plot","0.6.1","dist/plot.umd.min.js"),g=w("@observablehq/graphviz","0.2.1","dist/graphviz.min.js"),E=w("@observablehq/highlight.js","2.0.0","highlight.min.js"),T=w("@observablehq/katex","0.11.1","dist/katex.min.js"),A=w("lodash","4.17.21","lodash.min.js"),j=w("htl","0.3.1","dist/htl.min.js"),x=w("jszip","3.10.1","dist/jszip.min.js"),N=w("marked","0.3.12","marked.min.js"),O=w("sql.js","1.8.0","dist/sql-wasm.js"),C=w("vega","5.22.1","build/vega.min.js"),q=w("vega-lite","5.6.0","build/vega-lite.min.js"),$=w("vega-lite-api","5.0.0","build/vega-lite-api.min.js"),k=w("apache-arrow","4.0.1","Arrow.es2015.min.js"),R=w("apache-arrow","9.0.0","+esm"),L=w("arquero","4.8.8","dist/arquero.min.js"),I=w("topojson-client","3.1.0","dist/topojson-client.min.js"),S=w("exceljs","4.3.0","dist/exceljs.min.js"),P=w("mermaid","9.2.2","dist/mermaid.min.js"),M=w("leaflet","1.9.3","dist/leaflet.js"),_=w("@duckdb/duckdb-wasm","1.17.0","+esm"),U=new Map,D=[],F=D.map,B=D.some,W=D.hasOwnProperty,H=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,z=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,G=/(?:\.[^/]*|\/)$/;class RequireError extends Error{constructor(e){super(e)}}function V(e){const t=H.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function Y(e="https://cdn.jsdelivr.net/npm/",t=["unpkg","jsdelivr","browser","main"]){if(!/\/$/.test(e))throw new Error("origin lacks trailing slash");function n(t){const n=`${e}${t.name}${t.version?`@${t.version}`:""}/package.json`;let r=U.get(n);return r||U.set(n,r=fetch(n).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!U.has(e.url)&&U.set(e.url,r),e.json()}))),r}return async function(r,a){if(r.startsWith(e)&&(r=r.substring(e.length)),/^(\w+:)|\/\//i.test(r))return r;if(/^[.]{0,2}\//i.test(r))return new URL(r,null==a?location:a).href;if(!r.length||/^[\s._]/.test(r)||/\s$/.test(r))throw new RequireError("illegal name");const o=V(r);if(!o)return`${e}${r}`;if(!o.version&&null!=a&&a.startsWith(e)){const t=await n(V(a.substring(e.length)));o.version=t.dependencies&&t.dependencies[o.name]||t.peerDependencies&&t.peerDependencies[o.name]}if(o.path&&!G.test(o.path)&&(o.path+=".js"),o.path&&o.version&&z.test(o.version))return`${e}${o.name}@${o.version}/${o.path}`;const i=await n(o);return`${e}${i.name}@${i.version}/${o.path||function(e){for(const n of t){let t=e[n];if("string"==typeof t)return t.startsWith("./")&&(t=t.slice(2)),G.test(t)?t:`${t}.js`}}(i)||"index.js"}`}}RequireError.prototype.name=RequireError.name;var Z=J(Y());function J(e){const t=new Map,n=a(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(D.pop()(a(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=ee,document.head.appendChild(r)}))),n}function a(t){return n=>Promise.resolve(e(n,t)).then(r)}function o(e){return arguments.length>1?Promise.all(F.call(arguments,n)).then(Q):n(e)}return o.alias=function(t){return J(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},o.resolve=e,o}function Q(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:X(n,e)}):t[e]=n[e]);return t}function X(e,t){return()=>e[t]}function K(e){return"exports"===(e+="")||"module"===e}function ee(e,t,n){const r=arguments.length;r<2?(n=e,t=[]):r<3&&(n=t,t="string"==typeof e?[]:e),D.push(B.call(t,K)?e=>{const r={},a={exports:r};return Promise.all(F.call(t,(t=>"exports"===(t+="")?r:"module"===t?a:e(t)))).then((e=>(n.apply(null,e),a.exports)))}:e=>Promise.all(F.call(t,e)).then((e=>"function"==typeof n?n.apply(null,e):n)))}ee.amd={};const te="https://cdn.observableusercontent.com/npm/";let ne=Z;async function re(e){const[t,n]=await Promise.all([e(O.resolve()),e.resolve(O.resolve("dist/"))]);return t({locateFile:e=>`${n}${e}`})}class SQLiteDatabaseClient{constructor(e){Object.defineProperties(this,{_db:{value:e}})}static async open(e){const[t,n]=await Promise.all([re(ne),Promise.resolve(e).then(oe)]);return new SQLiteDatabaseClient(new t.Database(n))}async query(e,t){return await async function(e,t,n){const[r]=await e.exec(t,n);if(!r)return[];const{columns:a,values:o}=r,i=o.map((e=>Object.fromEntries(e.map(((e,t)=>[a[t],e])))));return i.columns=a,i}(this._db,e,t)}async queryRow(e,t){return(await this.query(e,t))[0]||null}async explain(e,t){return ie("pre",{className:"observablehq--inspect"},[se((await this.query(`EXPLAIN QUERY PLAN ${e}`,t)).map((e=>e.detail)).join("\n"))])}async describeTables({schema:e}={}){return this.query(`SELECT NULLIF(schema, 'main') AS schema, name FROM pragma_table_list() WHERE type = 'table'${null==e?"":" AND schema = ?"} AND name NOT LIKE 'sqlite_%' ORDER BY schema, name`,null==e?[]:[e])}async describeColumns({schema:e,table:t}={}){if(null==t)throw new Error("missing table");const n=await this.query(`SELECT name, type, "notnull" FROM pragma_table_info(?${null==e?"":", ?"}) ORDER BY cid`,null==e?[t]:[t,e]);if(!n.length)throw new Error(`table not found: ${t}`);return n.map((({name:e,type:t,notnull:n})=>({name:e,type:ae(t),databaseType:t,nullable:!n})))}async describe(e){const t=await(void 0===e?this.query("SELECT name FROM sqlite_master WHERE type = 'table'"):this.query("SELECT * FROM pragma_table_info(?)",[e]));if(!t.length)throw new Error("Not found");const{columns:n}=t;return ie("table",{value:t},[ie("thead",[ie("tr",n.map((e=>ie("th",[se(e)]))))]),ie("tbody",t.map((e=>ie("tr",n.map((t=>ie("td",[se(e[t])])))))))])}async sql(){return this.query(...this.queryTag.apply(this,arguments))}queryTag(e,...t){return[e.join("?"),t]}}function ae(e){switch(e){case"NULL":return"null";case"INT":case"INTEGER":case"TINYINT":case"SMALLINT":case"MEDIUMINT":case"BIGINT":case"UNSIGNED BIG INT":case"INT2":case"INT8":return"integer";case"TEXT":case"CLOB":case"DATE":case"DATETIME":return"string";case"REAL":case"DOUBLE":case"DOUBLE PRECISION":case"FLOAT":case"NUMERIC":return"number";case"BLOB":return"buffer";default:return/^(?:(?:(?:VARYING|NATIVE) )?CHARACTER|(?:N|VAR|NVAR)CHAR)\(/.test(e)?"string":/^(?:DECIMAL|NUMERIC)\(/.test(e)?"number":"other"}}function oe(e){return"string"==typeof e?fetch(e).then(oe):e instanceof Response||e instanceof Blob?e.arrayBuffer().then(oe):e instanceof ArrayBuffer?new Uint8Array(e):e}function ie(e,t,n){2===arguments.length&&(n=t,t=void 0);const r=document.createElement(e);if(void 0!==t)for(const e in t)r[e]=t[e];if(void 0!==n)for(const e of n)r.appendChild(e);return r}function se(e){return document.createTextNode(e)}Object.defineProperty(SQLiteDatabaseClient.prototype,"dialect",{value:"sqlite"});class Workbook{constructor(e){Object.defineProperties(this,{_:{value:e},sheetNames:{value:e.worksheets.map((e=>e.name)),enumerable:!0}})}sheet(e,t){const n="number"==typeof e?this.sheetNames[e]:this.sheetNames.includes(e+="")?e:null;if(null==n)throw new Error(`Sheet not found: ${e}`);return function(e,{range:t,headers:n}={}){let[[r,a],[o,i]]=function(e=":",{columnCount:t,rowCount:n}){if(!(e+="").match(/^[A-Z]*\d*:[A-Z]*\d*$/))throw new Error("Malformed range specifier");const[[r=0,a=0],[o=t-1,i=n-1]]=e.split(":").map(fe);return[[r,a],[o,i]]}(t,e);const s=n?e._rows[a++]:null;let c=new Set(["#"]);for(let e=r;e<=o;e++){const t=s?ce(s.findCell(e+1)):null;let n=t&&t+""||ue(e);for(;c.has(n);)n+="_";c.add(n)}c=new Array(r).concat(Array.from(c));const l=new Array(i-a+1);for(let t=a;t<=i;t++){const n=l[t-a]=Object.create(null,{"#":{value:t+1}}),i=e.getRow(t+1);if(i.hasValues)for(let e=r;e<=o;e++){const t=ce(i.findCell(e+1));null!=t&&(n[c[e+1]]=t)}}return l.columns=c.filter((()=>!0)),l}(this._.getWorksheet(n),t)}}function ce(e){if(!e)return;const{value:t}=e;if(t&&"object"==typeof t&&!(t instanceof Date)){if(t.formula||t.sharedFormula)return t.result&&t.result.error?NaN:t.result;if(t.richText)return le(t);if(t.text){let{text:e}=t;return e.richText&&(e=le(e)),t.hyperlink&&t.hyperlink!==e?`${t.hyperlink} ${e}`:e}return t}return t}function le(e){return e.richText.map((e=>e.text)).join("")}function ue(e){let t="";e++;do{t=String.fromCharCode(64+(e%26||26))+t}while(e=Math.floor((e-1)/26));return t}function fe(e){const[,t,n]=e.match(/^([A-Z]*)(\d*)$/);let r=0;if(t)for(let e=0;e<t.length;e++)r+=Math.pow(26,t.length-e-1)*(t.charCodeAt(e)-64);return[r?r-1:void 0,n?+n-1:void 0]}async function de(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function me(e,t,{array:n=!1,typed:r=!1}={}){const a=await e.text();return("\t"===t?n?m:d:n?u:l)(a,r&&h)}class he{constructor(e,t){Object.defineProperty(this,"name",{value:e,enumerable:!0}),void 0!==t&&Object.defineProperty(this,"mimeType",{value:t+"",enumerable:!0})}async blob(){return(await de(this)).blob()}async arrayBuffer(){return(await de(this)).arrayBuffer()}async text(){return(await de(this)).text()}async json(){return(await de(this)).json()}async stream(){return(await de(this)).body}async csv(e){return me(this,",",e)}async tsv(e){return me(this,"\t",e)}async image(e){const t=await this.url();return new Promise(((n,r)=>{const a=new Image;new URL(t,document.baseURI).origin!==new URL(location).origin&&(a.crossOrigin="anonymous"),Object.assign(a,e),a.onload=()=>n(a),a.onerror=()=>r(new Error(`Unable to load file: ${this.name}`)),a.src=t}))}async arrow({version:e=4}={}){switch(e){case 4:{const[e,t]=await Promise.all([ne(k.resolve()),de(this)]);return e.Table.from(t)}case 9:{const[e,t]=await Promise.all([import(`${te}${R.resolve()}`),de(this)]);return e.tableFromIPC(t)}default:throw new Error(`unsupported arrow version: ${e}`)}}async sqlite(){return SQLiteDatabaseClient.open(de(this))}async zip(){const[e,t]=await Promise.all([ne(x.resolve()),this.arrayBuffer()]);return new ZipArchive(await e.loadAsync(t))}async xml(e="application/xml"){return(new DOMParser).parseFromString(await this.text(),e)}async html(){return this.xml("text/html")}async xlsx(){const[e,t]=await Promise.all([ne(S.resolve()),this.arrayBuffer()]);return new Workbook(await(new e.Workbook).xlsx.load(t))}}class FileAttachment extends he{constructor(e,t,n){super(t,n),Object.defineProperty(this,"_url",{value:e})}async url(){return await this._url+""}}function pe(e){throw new Error(`File not found: ${e}`)}class ZipArchive{constructor(e){Object.defineProperty(this,"_",{value:e}),this.filenames=Object.keys(e.files).filter((t=>!e.files[t].dir))}file(e){const t=this._.file(e+="");if(!t||t.dir)throw new Error(`file not found: ${e}`);return new ZipArchiveEntry(t)}}class ZipArchiveEntry extends he{constructor(e){super(e.name),Object.defineProperty(this,"_",{value:e}),Object.defineProperty(this,"_url",{writable:!0})}async url(){return this._url||(this._url=this.blob().then(URL.createObjectURL))}async blob(){return this._.async("blob")}async arrayBuffer(){return this._.async("arraybuffer")}async text(){return this._.async("text")}async json(){return JSON.parse(await this.text())}}var we={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 be=0;function ye(e){return new ve("O-"+(null==e?"":e+"-")+ ++be)}function ve(e){this.id=e,this.href=new URL(`#${e}`,location)+""}ve.prototype.toString=function(){return"url("+this.href+")"};var ge=Object.freeze({__proto__:null,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 a=r.getContext("2d");return a.scale(n,n),a},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),a=r.appendChild(document.createElement("button"));async function o(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),a.textContent=n,a.disabled=!1}return a.textContent=n,r.download=t,r.onclick=async t=>{if(a.disabled=!0,r.href)return o();a.textContent="Saving…";try{const t=await("function"==typeof e?e():e);a.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){a.textContent=n}if(t.eventPhase)return o();a.disabled=!1},r},element:function(e,t){var n,r=e+="",a=r.indexOf(":");a>=0&&"xmlns"!==(r=e.slice(0,a))&&(e=e.slice(a+1));var o=we.hasOwnProperty(r)?document.createElementNS(we[r],e):document.createElement(e);if(t)for(var i in t)a=(r=i).indexOf(":"),n=t[i],a>=0&&"xmlns"!==(r=i.slice(0,a))&&(i=i.slice(a+1)),we.hasOwnProperty(r)?o.setAttributeNS(we[r],i,n):o.setAttribute(i,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:ye});var Ee=Object.freeze({__proto__:null,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 Te(){return this}function Ae(e,t){let n=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:Te,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function je(e){let t,n,r=!1;const a=e((function(e){n?(n(e),n=null):r=!0;return t=e}));if(null!=a&&"function"!=typeof a)throw new Error("function"==typeof a.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:Te,throw:()=>({done:!0}),return:()=>(null!=a&&a(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise((e=>n=e))}}}}function xe(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];case"select-multiple":return Array.from(e.selectedOptions,(e=>e.value));default:return e.value}}var Ne=Object.freeze({__proto__:null,disposable:Ae,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return je((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=xe(e);function a(){t(xe(e))}return e.addEventListener(n,a),void 0!==r&&t(r),function(){e.removeEventListener(n,a)}}))},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:je,queue:function(e){let t;const n=[],r=e((function(e){n.push(e),t&&(t(n.shift()),t=null);return e}));if(null!=r&&"function"!=typeof r)throw new Error("function"==typeof r.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:Te,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=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+n;for(var r=-1,a=0|Math.max(0,Math.ceil((t-e)/n));++r<a;)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 Ae(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}});function Oe(e){return e&&"function"==typeof e.toArrowBuffer}function Ce(e){return e&&"function"==typeof e.getChild&&"function"==typeof e.toArray&&e.schema&&Array.isArray(e.schema.fields)}function qe(e){return e.schema.fields.map($e)}function $e(e){return{name:e.name,type:ke(e.type),nullable:e.nullable,databaseType:String(e.type)}}function ke(e){switch(e.typeId){case 2:return"integer";case 3:case 7:return"number";case 4:case 15:return"buffer";case 5:return"string";case 6:return"boolean";case 8:case 9:case 10:return"date";case 12:case 16:return"array";case 13:case 14:return"object";default:return"other"}}async function Re(){return await import(`${te}${R.resolve()}`)}class DuckDBClient{constructor(e){Object.defineProperties(this,{_db:{value:e}})}async queryStream(e,t){const n=await this._db.connect();let r,a;try{if(t?.length>0){const a=await n.prepare(e);r=await a.send(...t)}else r=await n.send(e);if(a=await r.next(),a.done)throw new Error("missing first batch")}catch(e){throw await n.close(),e}return{schema:qe(a.value),async*readRows(){try{for(;!a.done;)yield a.value.toArray(),a=await r.next()}finally{await n.close()}}}}async query(e,t){const n=await this.queryStream(e,t),r=[];for await(const e of n.readRows())for(const t of e)r.push(t);return r.schema=n.schema,r}async queryRow(e,t){const n=(await this.queryStream(e,t)).readRows();try{const{done:e,value:t}=await n.next();return e||!t.length?null:t[0]}finally{await n.return()}}async sql(e,...t){return await this.query(e.join("?"),t)}queryTag(e,...t){return[e.join("?"),t]}escape(e){return`"${e}"`}async describeTables(){return(await this.query("SHOW TABLES")).map((({name:e})=>({name:e})))}async describeColumns({table:e}={}){return(await this.query(`DESCRIBE ${this.escape(e)}`)).map((({column_name:e,column_type:t,null:n})=>({name:e,type:Pe(t),nullable:"NO"!==n,databaseType:t})))}static async of(e={},t={}){const n=await async function(){const e=await import(`${te}${_.resolve()}`),t=await e.selectBundle({mvp:{mainModule:`${te}${_.resolve("dist/duckdb-mvp.wasm")}`,mainWorker:`${te}${_.resolve("dist/duckdb-browser-mvp.worker.js")}`},eh:{mainModule:`${te}${_.resolve("dist/duckdb-eh.wasm")}`,mainWorker:`${te}${_.resolve("dist/duckdb-browser-eh.worker.js")}`}}),n=new e.ConsoleLogger,r=await e.createWorker(t.mainWorker),a=new e.AsyncDuckDB(n,r);return await a.instantiate(t.mainModule),a}();return void 0===t.query?.castTimestampToDate&&(t={...t,query:{...t.query,castTimestampToDate:!0}}),await n.open(t),await Promise.all(Object.entries(e).map((async([e,t])=>{if(t instanceof FileAttachment)await Le(n,e,t);else if(Ce(t))await Ie(n,e,t);else if(Array.isArray(t))await Se(n,e,t);else if(Oe(t))await async function(e,t,n){const r=(await Re()).tableFromIPC(n.toArrowBuffer());return await Ie(e,t,r)}(n,e,t);else if("data"in t){const{data:r,...a}=t;Ce(r)?await Ie(n,e,r,a):await Se(n,e,r,a)}else{if(!("file"in t))throw new Error(`invalid source: ${t}`);{const{file:r,...a}=t;await Le(n,e,r,a)}}}))),new DuckDBClient(n)}}async function Le(e,t,n,r){const a=await n.url();if(a.startsWith("blob:")){const t=await n.arrayBuffer();await e.registerFileBuffer(n.name,new Uint8Array(t))}else await e.registerFileURL(n.name,a);const o=await e.connect();try{switch(n.mimeType){case"text/csv":case"text/tab-separated-values":return await o.insertCSVFromPath(n.name,{name:t,schema:"main",...r});case"application/json":return await o.insertJSONFromPath(n.name,{name:t,schema:"main",...r});default:if(/\.arrow$/i.test(n.name)){const e=new Uint8Array(await n.arrayBuffer());return await o.insertArrowFromIPCStream(e,{name:t,schema:"main",...r})}if(/\.parquet$/i.test(n.name))return await o.query(`CREATE VIEW '${t}' AS SELECT * FROM parquet_scan('${n.name}')`);throw new Error(`unknown file type: ${n.mimeType}`)}}finally{await o.close()}}async function Ie(e,t,n,r){const a=await e.connect();try{await a.insertArrowTable(n,{name:t,schema:"main",...r})}finally{await a.close()}}async function Se(e,t,n,r){const a=(await Re()).tableFromJSON(n);return await Ie(e,t,a,r)}function Pe(e){switch(e){case"BIGINT":case"HUGEINT":case"UBIGINT":return"bigint";case"DOUBLE":case"REAL":case"FLOAT":return"number";case"INTEGER":case"SMALLINT":case"TINYINT":case"USMALLINT":case"UINTEGER":case"UTINYINT":return"integer";case"BOOLEAN":return"boolean";case"DATE":case"TIMESTAMP":case"TIMESTAMP WITH TIME ZONE":return"date";case"VARCHAR":case"UUID":return"string";default:return/^DECIMAL\(/.test(e)?"integer":"other"}}function Me(e,t){return function(n){var r,a,o,i,s,c,l,u,f=n[0],d=[],m=null,h=-1;for(s=1,c=arguments.length;s<c;++s){if((r=arguments[s])instanceof Node)d[++h]=r,f+="\x3c!--o:"+h+"--\x3e";else if(Array.isArray(r)){for(l=0,u=r.length;l<u;++l)(a=r[l])instanceof Node?(null===m&&(d[++h]=m=document.createDocumentFragment(),f+="\x3c!--o:"+h+"--\x3e"),m.appendChild(a)):(m=null,f+=a);m=null}else f+=r;f+=n[s]}if(m=e(f),++h>0){for(o=new Array(h),i=document.createTreeWalker(m,NodeFilter.SHOW_COMMENT,null,!1);i.nextNode();)a=i.currentNode,/^o:/.test(a.nodeValue)&&(o[+a.nodeValue.slice(2)]=a);for(s=0;s<h;++s)(a=o[s])&&a.parentNode.replaceChild(d[s],a)}return 1===m.childNodes.length?m.removeChild(m.firstChild):11===m.nodeType?((a=t()).appendChild(m),a):m}}Object.defineProperty(DuckDBClient.prototype,"dialect",{value:"duckdb"});const _e=Me((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));function Ue(e){let t;Object.defineProperties(this,{generator:{value:je((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*De(){for(;;)yield Date.now()}var Fe=new Map;function Be(e,t){var n;return(n=Fe.get(e=+e))?n.then((()=>t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise((function(n){Fe.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 Fe.set(t,n),n}(n,e).then((()=>t))}var We=Object.freeze({__proto__:null,delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return Be(Math.ceil((Date.now()+1)/e)*e,t)},when:Be});function He(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 ze=Me((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")}));var Ge=String.raw;function Ve(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 Ye(){return je((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)}}))}function Ze(e,t){return null==e||null==t?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Je(e,t){return null==e||null==t?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Qe(e,t){return e&&("function"==typeof e.sql||"function"==typeof e.queryTag&&("function"==typeof e.query||"function"==typeof e.queryStream))&&("table"!==t||"function"==typeof e.describeColumns)&&e!==rt}function Xe(e){return Array.isArray(e)&&(n=e.schema,Array.isArray(n)&&n.every((e=>e&&"string"==typeof e.name))||(t=e.columns,Array.isArray(t)&&t.every((e=>"string"==typeof e)))||function(e){const t=Math.min(20,e.length);for(let n=0;n<t;++n){const t=e[n];if(null===t||"object"!=typeof t)return!1}return t>0&&function(e){for(const t in e)return!0;return!1}(e[0])}(e)||et(e)||tt(e))||nt(e);var t,n}function Ke(e){return nt(e)||et(e)||tt(e)}function et(e){const t=Math.min(20,e.length);if(!(t>0))return!1;let n,r=!1;for(let a=0;a<t;++a){const t=e[a];if(null==t)continue;const o=typeof t;if(void 0===n)switch(o){case"number":case"boolean":case"string":case"bigint":n=o;break;default:return!1}else if(o!==n)return!1;r=!0}return r}function tt(e){const t=Math.min(20,e.length);if(!(t>0))return!1;let n=!1;for(let r=0;r<t;++r){const t=e[r];if(null!=t){if(!(t instanceof Date))return!1;n=!0}}return n}function nt(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}const rt=Object.assign((async(e,t,n,r)=>{if(Qe(e=await ot(await e,r)))return ct(e,lt(t,e),n);if(Xe(e))return pt(e,t);if(!e)throw new Error("missing data source");throw new Error("invalid data source")}),{sql:(e,t,n)=>async function(){return ct(await it(await e,n),arguments,t)}});function at(e){const t=new WeakMap;return(n,r)=>{if(!n)throw new Error("data source not found");let a=t.get(n);return(!a||Xe(n)&&n.length!==a._numRows)&&(a=e(n,r),a._numRows=n.length,t.set(n,a)),a}}const ot=at((async(e,t)=>{if(e instanceof FileAttachment){switch(e.mimeType){case"text/csv":return e.csv({typed:!0});case"text/tab-separated-values":return e.tsv({typed:!0});case"application/json":return e.json();case"application/x-sqlite3":return e.sqlite()}if(/\.(arrow|parquet)$/i.test(e.name))return st(e,t);throw new Error(`unsupported file type: ${e.mimeType}`)}return Ce(e)||Oe(e)?st(e,t):e})),it=at((async(e,t)=>{if(e instanceof FileAttachment){switch(e.mimeType){case"text/csv":case"text/tab-separated-values":case"application/json":return st(e,t);case"application/x-sqlite3":return e.sqlite()}if(/\.(arrow|parquet)$/i.test(e.name))return st(e,t);throw new Error(`unsupported file type: ${e.mimeType}`)}return Xe(e)?st(await async function(e,t){const n=await Re();return Ke(e)?n.tableFromArrays({[t]:e}):n.tableFromJSON(e)}(e,t),t):Ce(e)||Oe(e)?st(e,t):e}));function st(e,t=(e instanceof FileAttachment?function(e){return e.name.replace(/@\d+(?=\.|$)/,"").replace(/\.\w+$/,"")}(e):"__table")){return DuckDBClient.of({[t]:e})}async function ct(e,t,n){if(!e)throw new Error("missing data source");if("function"==typeof e.queryTag){const r=new AbortController,a={signal:r.signal};if(n.then((()=>r.abort("invalidated"))),"function"==typeof e.queryStream)return async function*(e){let t=performance.now();const n=await e,r=[];r.done=!1,r.error=null,r.schema=n.schema;try{for await(const e of n.readRows()){performance.now()-t>10&&r.length>0&&(yield r,t=performance.now());for(const t of e)r.push(t)}r.done=!0,yield r}catch(e){r.error=e,yield r}}(e.queryStream(...e.queryTag.apply(e,t),a));if("function"==typeof e.query)return e.query(...e.queryTag.apply(e,t),a)}if("function"==typeof e.sql)return e.sql.apply(e,t);throw new Error("source does not implement query, queryStream, or sql")}function lt(e,t){const n="function"==typeof t.escape?t.escape:e=>e,{select:r,from:a,filter:o,sort:i,slice:s}=e;if(!a.table)throw new Error("missing from table");if(r.columns&&0===r.columns.length)throw new Error("at least one column must be selected");const c=[[`SELECT ${r.columns?r.columns.map(n).join(", "):"*"} FROM ${ut(a.table,n)}`]];for(let e=0;e<o.length;++e)ft(e?"\nAND ":"\nWHERE ",c),mt(o[e],c,n);for(let e=0;e<i.length;++e)ft(e?", ":"\nORDER BY ",c),dt(i[e],c,n);if("mssql"===t.dialect||"oracle"===t.dialect){if(null!==s.to||null!==s.from){if(!i.length){if(!r.columns)throw new Error("at least one column must be explicitly specified. Received '*'.");ft("\nORDER BY ",c),dt({column:r.columns[0],direction:"ASC"},c,n)}ft(`\nOFFSET ${s.from||0} ROWS`,c),ft(`\nFETCH NEXT ${null!==s.to?s.to-(s.from||0):1e9} ROWS ONLY`,c)}}else null===s.to&&null===s.from||ft("\nLIMIT "+(null!==s.to?s.to-(s.from||0):1e9),c),null!==s.from&&ft(` OFFSET ${s.from}`,c);return c}function ut(e,t){if("object"==typeof e){let n="";return null!=e.database&&(n+=t(e.database)+"."),null!=e.schema&&(n+=t(e.schema)+"."),n+=t(e.table),n}return t(e)}function ft(e,t){const n=t[0];n[n.length-1]+=e}function dt({column:e,direction:t},n,r){ft(`${r(e)} ${t.toUpperCase()}`,n)}function mt({type:e,operands:t},n,r){if(t.length<1)throw new Error("Invalid operand length");if(1===t.length)switch(ht(t[0],n,r),e){case"n":return void ft(" IS NULL",n);case"nn":return void ft(" IS NOT NULL",n);default:throw new Error("Invalid filter operation")}if(2!==t.length||["in","nin"].includes(e)){var a;switch(ht(t[0],n,r),e){case"in":ft(" IN (",n);break;case"nin":ft(" NOT IN (",n);break;default:throw new Error("Invalid filter operation")}!function(e,t){let n=!0;for(const r of e)n?n=!1:ft(",",t),t.push(r.value),t[0].push("")}(t.slice(1),n),ft(")",n)}else{if(["c","nc"].includes(e)){switch(ht(t[0],n,r),e){case"c":ft(" LIKE ",n);break;case"nc":ft(" NOT LIKE ",n)}return void ht((a=t[1],{...a,value:`%${a.value}%`}),n,r)}switch(ht(t[0],n,r),e){case"eq":ft(" = ",n);break;case"ne":ft(" <> ",n);break;case"gt":ft(" > ",n);break;case"lt":ft(" < ",n);break;case"gte":ft(" >= ",n);break;case"lte":ft(" <= ",n);break;default:throw new Error("Invalid filter operation")}ht(t[1],n,r)}}function ht(e,t,n){"column"===e.type?ft(n(e.value),t):(t.push(e.value),t[0].push(""))}function pt(e,t){const n=e;let{schema:r,columns:a}=e,o=Ke(e);o&&(e=Array.from(e,(e=>({value:e}))));for(const{type:n,operands:r}of t.filter){const[{value:t}]=r,a=r.slice(1).map((({value:e})=>e));switch(n){case"eq":{const[n]=a;if(n instanceof Date){const r=+n;e=e.filter((e=>+e[t]===r))}else e=e.filter((e=>e[t]===n));break}case"ne":{const[n]=a;e=e.filter((e=>e[t]!==n));break}case"c":{const[n]=a;e=e.filter((e=>"string"==typeof e[t]&&e[t].includes(n)));break}case"nc":{const[n]=a;e=e.filter((e=>"string"==typeof e[t]&&!e[t].includes(n)));break}case"in":{const n=new Set(a);e=e.filter((e=>n.has(e[t])));break}case"nin":{const n=new Set(a);e=e.filter((e=>!n.has(e[t])));break}case"n":e=e.filter((e=>null==e[t]));break;case"nn":e=e.filter((e=>null!=e[t]));break;case"lt":{const[n]=a;e=e.filter((e=>e[t]<n));break}case"lte":{const[n]=a;e=e.filter((e=>e[t]<=n));break}case"gt":{const[n]=a;e=e.filter((e=>e[t]>n));break}case"gte":{const[n]=a;e=e.filter((e=>e[t]>=n));break}default:throw new Error(`unknown filter type: ${n}`)}}for(const{column:r,direction:a}of function(e){if("function"!=typeof e[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(e).reverse()}(t.sort)){const t="desc"===a?Je:Ze;e===n&&(e=e.slice()),e.sort(((e,n)=>t(e[r],n[r])))}let{from:i,to:s}=t.slice;if(i=null==i?0:Math.max(0,i),s=null==s?1/0:Math.max(0,s),(i>0||s<1/0)&&(e=e.slice(Math.max(0,i),Math.max(0,s))),t.select.columns){if(r){const e=new Map(r.map((e=>[e.name,e])));r=t.select.columns.map((t=>e.get(t)))}a&&(a=t.select.columns),e=e.map((e=>Object.fromEntries(t.select.columns.map((t=>[t,e[t]])))))}return o&&(e=e.map((e=>e.value))),e!==n&&(r&&(e.schema=r),a&&(e.columns=a)),e}const wt=Object.assign(Object.defineProperties((function(e){const t=function(e){return null==e?ne:J(e)}(e);var n;Object.defineProperties(this,(n={FileAttachment:()=>pe,Mutable:()=>Ue,now:De,width:Ye,dot:()=>t(g.resolve()),htl:()=>t(j.resolve()),html:()=>_e,md:()=>function(e){return e(N.resolve()).then((function(t){return Me((function(n){var r=document.createElement("div");r.innerHTML=t(n,{langPrefix:""}).trim();var a=r.querySelectorAll("pre code[class]");return a.length>0&&e(E.resolve()).then((function(t){a.forEach((function(n){function r(){t.highlightBlock(n),n.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(n.className)?r():e(E.resolve("async-languages/index.js")).then((r=>{if(r.has(n.className))return e(E.resolve("async-languages/"+r.get(n.className))).then((e=>{t.registerLanguage(n.className,e)}))})).then(r,r)}))})),r}),(function(){return document.createElement("div")}))}))}(t),svg:()=>ze,tex:()=>function(e){return Promise.all([e(T.resolve()),e.resolve(T.resolve("dist/katex.min.css")).then(Ve)]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(Ge.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}))}(t),_:()=>t(A.resolve()),aq:()=>t.alias({"apache-arrow":k.resolve()})(L.resolve()),Arrow:()=>t(k.resolve()),d3:()=>t(b.resolve()),DuckDBClient:()=>DuckDBClient,Inputs:()=>t(y.resolve()).then((e=>({...e,file:e.fileOf(he)}))),L:()=>async function(e){const t=await e(M.resolve());if(!t._style){const n=document.createElement("link");n.rel="stylesheet",n.href=await e.resolve(M.resolve("dist/leaflet.css")),t._style=document.head.appendChild(n)}return t}(t),mermaid:()=>async function(e){const t=await e(P.resolve());return t.initialize({securityLevel:"loose",theme:"neutral"}),function(){const e=document.createElement("div");return e.innerHTML=t.render(ye().id,String.raw.apply(String,arguments)),e.removeChild(e.firstChild)}}(t),Plot:()=>t(v.resolve()),__query:()=>rt,require:()=>t,resolve:()=>He,SQLite:()=>re(t),SQLiteDatabaseClient:()=>SQLiteDatabaseClient,topojson:()=>t(I.resolve()),vl:()=>async function(e){const[t,n,r]=await Promise.all([C,q,$].map((t=>e(t.resolve()))));return r.register(t,n)}(t),aapl:()=>new FileAttachment("https://static.observableusercontent.com/files/3ccff97fd2d93da734e76829b2b066eafdaac6a1fafdec0faf6ebc443271cfc109d29e80dd217468fcb2aff1e6bffdc73f356cc48feb657f35378e6abbbb63b9").csv({typed:!0}),alphabet:()=>new FileAttachment("https://static.observableusercontent.com/files/75d52e6c3130b1cae83cda89305e17b50f33e7420ef205587a135e8562bcfd22e483cf4fa2fb5df6dff66f9c5d19740be1cfaf47406286e2eb6574b49ffc685d").csv({typed:!0}),cars:()=>new FileAttachment("https://static.observableusercontent.com/files/048ec3dfd528110c0665dfa363dd28bc516ffb7247231f3ab25005036717f5c4c232a5efc7bb74bc03037155cb72b1abe85a33d86eb9f1a336196030443be4f6").csv({typed:!0}),citywages:()=>new FileAttachment("https://static.observableusercontent.com/files/39837ec5121fcc163131dbc2fe8c1a2e0b3423a5d1e96b5ce371e2ac2e20a290d78b71a4fb08b9fa6a0107776e17fb78af313b8ea70f4cc6648fad68ddf06f7a").csv({typed:!0}),diamonds:()=>new FileAttachment("https://static.observableusercontent.com/files/87942b1f5d061a21fa4bb8f2162db44e3ef0f7391301f867ab5ba718b225a63091af20675f0bfe7f922db097b217b377135203a7eab34651e21a8d09f4e37252").csv({typed:!0}),flare:()=>new FileAttachment("https://static.observableusercontent.com/files/a6b0d94a7f5828fd133765a934f4c9746d2010e2f342d335923991f31b14120de96b5cb4f160d509d8dc627f0107d7f5b5070d2516f01e4c862b5b4867533000").csv({typed:!0}),industries:()=>new FileAttachment("https://static.observableusercontent.com/files/76f13741128340cc88798c0a0b7fa5a2df8370f57554000774ab8ee9ae785ffa2903010cad670d4939af3e9c17e5e18e7e05ed2b38b848ac2fc1a0066aa0005f").csv({typed:!0}),miserables:()=>new FileAttachment("https://static.observableusercontent.com/files/31d904f6e21d42d4963ece9c8cc4fbd75efcbdc404bf511bc79906f0a1be68b5a01e935f65123670ed04e35ca8cae3c2b943f82bf8db49c5a67c85cbb58db052").json(),olympians:()=>new FileAttachment("https://static.observableusercontent.com/files/31ca24545a0603dce099d10ee89ee5ae72d29fa55e8fc7c9ffb5ded87ac83060d80f1d9e21f4ae8eb04c1e8940b7287d179fe8060d887fb1f055f430e210007c").csv({typed:!0}),penguins:()=>new FileAttachment("https://static.observableusercontent.com/files/715db1223e067f00500780077febc6cebbdd90c151d3d78317c802732252052ab0e367039872ab9c77d6ef99e5f55a0724b35ddc898a1c99cb14c31a379af80a").csv({typed:!0}),weather:()=>new FileAttachment("https://static.observableusercontent.com/files/693a46b22b33db0f042728700e0c73e836fa13d55446df89120682d55339c6db7cc9e574d3d73f24ecc9bc7eb9ac9a1e7e104a1ee52c00aab1e77eb102913c1f").csv({typed:!0}),DOM:ge,Files:Ee,Generators:Ne,Promises:We},Object.fromEntries(Object.entries(n).map(bt))))}),{resolve:{get:()=>ne.resolve,enumerable:!0,configurable:!0},require:{get:()=>ne,set:function(e){ne=e},enumerable:!0,configurable:!0}}),{resolveFrom:Y,requireFrom:J});function bt([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}e.AbstractFile=he,e.FileAttachments=function(e){return Object.assign((t=>{const n=e(t+="");if(null==n)throw new Error(`File not found: ${t}`);if("object"==typeof n&&"url"in n){const{url:e,mimeType:r}=n;return new FileAttachment(e,t,r)}return new FileAttachment(n,t)}),{prototype:FileAttachment.prototype})},e.Library=wt,e.applyDataTableOperations=pt,e.arrayIsPrimitive=Ke,e.getArrowTableSchema=qe,e.isArqueroTable=Oe,e.isArrowTable=Ce,e.isDataArray=Xe,e.isDatabaseClient=Qe,e.loadDataSource=async function(e,t,n){switch(t){case"table":return ot(e,n);case"sql":return it(e,n)}return e},e.makeQueryTemplate=lt}));
// @observablehq/stdlib v5.3.0 Copyright 2022 Observable, Inc.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).observablehq=e.observablehq||{})}(this,(function(e){"use strict";var t={},n={};function r(e){return new Function("d","return {"+e.map((function(e,t){return JSON.stringify(e)+": d["+t+'] || ""'})).join(",")+"}")}function a(e){var t=Object.create(null),n=[];return e.forEach((function(e){for(var r in e)r in t||n.push(t[r]=r)})),n}function o(e,t){var n=e+"",r=n.length;return r<t?new Array(t-r+1).join(0)+n:n}function s(e){var t,n=e.getUTCHours(),r=e.getUTCMinutes(),a=e.getUTCSeconds(),s=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":((t=e.getUTCFullYear())<0?"-"+o(-t,6):t>9999?"+"+o(t,6):o(t,4))+"-"+o(e.getUTCMonth()+1,2)+"-"+o(e.getUTCDate(),2)+(s?"T"+o(n,2)+":"+o(r,2)+":"+o(a,2)+"."+o(s,3)+"Z":a?"T"+o(n,2)+":"+o(r,2)+":"+o(a,2)+"Z":r||n?"T"+o(n,2)+":"+o(r,2)+"Z":"")}function i(e){var o=new RegExp('["'+e+"\n\r]"),i=e.charCodeAt(0);function c(e,r){var a,o=[],s=e.length,c=0,l=0,u=s<=0,f=!1;function d(){if(u)return n;if(f)return f=!1,t;var r,a,o=c;if(34===e.charCodeAt(o)){for(;c++<s&&34!==e.charCodeAt(c)||34===e.charCodeAt(++c););return(r=c)>=s?u=!0:10===(a=e.charCodeAt(c++))?f=!0:13===a&&(f=!0,10===e.charCodeAt(c)&&++c),e.slice(o+1,r-1).replace(/""/g,'"')}for(;c<s;){if(10===(a=e.charCodeAt(r=c++)))f=!0;else if(13===a)f=!0,10===e.charCodeAt(c)&&++c;else if(a!==i)continue;return e.slice(o,r)}return u=!0,e.slice(o,s)}for(10===e.charCodeAt(s-1)&&--s,13===e.charCodeAt(s-1)&&--s;(a=d())!==n;){for(var m=[];a!==t&&a!==n;)m.push(a),a=d();r&&null==(m=r(m,l++))||o.push(m)}return o}function l(t,n){return t.map((function(t){return n.map((function(e){return f(t[e])})).join(e)}))}function u(t){return t.map(f).join(e)}function f(e){return null==e?"":e instanceof Date?s(e):o.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,a,o=c(e,(function(e,o){if(n)return n(e,o-1);a=e,n=t?function(e,t){var n=r(e);return function(r,a){return t(n(r),a,e)}}(e,t):r(e)}));return o.columns=a||[],o},parseRows:c,format:function(t,n){return null==n&&(n=a(t)),[n.map(f).join(e)].concat(l(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=a(e)),l(e,t).join("\n")},formatRows:function(e){return e.map(u).join("\n")},formatRow:u,formatValue:f}}var c=i(","),l=c.parse,u=c.parseRows,f=i("\t"),d=f.parse,m=f.parseRows;function h(e){for(var t in e){var n,r,a=e[t].trim();if(a)if("true"===a)a=!0;else if("false"===a)a=!1;else if("NaN"===a)a=NaN;else if(isNaN(n=+a)){if(!(r=a.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)))continue;p&&r[4]&&!r[7]&&(a=a.replace(/-/g,"/").replace(/T/," ")),a=new Date(a)}else a=n;else a=null;e[t]=a}return e}const p=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours();function w(e,t,n){return{resolve:(r=n)=>`${e}@${t}/${r}`}}const b=w("d3","7.7.0","dist/d3.min.js"),y=w("@observablehq/inputs","0.10.4","dist/inputs.min.js"),v=w("@observablehq/plot","0.6.1","dist/plot.umd.min.js"),g=w("@observablehq/graphviz","0.2.1","dist/graphviz.min.js"),E=w("@observablehq/highlight.js","2.0.0","highlight.min.js"),A=w("@observablehq/katex","0.11.1","dist/katex.min.js"),T=w("lodash","4.17.21","lodash.min.js"),j=w("htl","0.3.1","dist/htl.min.js"),x=w("jszip","3.10.1","dist/jszip.min.js"),N=w("marked","0.3.12","marked.min.js"),O=w("sql.js","1.8.0","dist/sql-wasm.js"),k=w("vega","5.22.1","build/vega.min.js"),C=w("vega-lite","5.6.0","build/vega-lite.min.js"),q=w("vega-lite-api","5.0.0","build/vega-lite-api.min.js"),L=w("apache-arrow","4.0.1","Arrow.es2015.min.js"),$=w("apache-arrow","9.0.0","+esm"),R=w("arquero","4.8.8","dist/arquero.min.js"),I=w("topojson-client","3.1.0","dist/topojson-client.min.js"),S=w("exceljs","4.3.0","dist/exceljs.min.js"),P=w("mermaid","9.2.2","dist/mermaid.min.js"),M=w("leaflet","1.9.3","dist/leaflet.js"),_=w("@duckdb/duckdb-wasm","1.17.0","+esm"),U=new Map,D=[],F=D.map,B=D.some,W=D.hasOwnProperty,H=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,z=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,V=/(?:\.[^/]*|\/)$/;class RequireError extends Error{constructor(e){super(e)}}function G(e){const t=H.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function Y(e="https://cdn.jsdelivr.net/npm/",t=["unpkg","jsdelivr","browser","main"]){if(!/\/$/.test(e))throw new Error("origin lacks trailing slash");function n(t){const n=`${e}${t.name}${t.version?`@${t.version}`:""}/package.json`;let r=U.get(n);return r||U.set(n,r=fetch(n).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!U.has(e.url)&&U.set(e.url,r),e.json()}))),r}return async function(r,a){if(r.startsWith(e)&&(r=r.substring(e.length)),/^(\w+:)|\/\//i.test(r))return r;if(/^[.]{0,2}\//i.test(r))return new URL(r,null==a?location:a).href;if(!r.length||/^[\s._]/.test(r)||/\s$/.test(r))throw new RequireError("illegal name");const o=G(r);if(!o)return`${e}${r}`;if(!o.version&&null!=a&&a.startsWith(e)){const t=await n(G(a.substring(e.length)));o.version=t.dependencies&&t.dependencies[o.name]||t.peerDependencies&&t.peerDependencies[o.name]}if(o.path&&!V.test(o.path)&&(o.path+=".js"),o.path&&o.version&&z.test(o.version))return`${e}${o.name}@${o.version}/${o.path}`;const s=await n(o);return`${e}${s.name}@${s.version}/${o.path||function(e){for(const n of t){let t=e[n];if("string"==typeof t)return t.startsWith("./")&&(t=t.slice(2)),V.test(t)?t:`${t}.js`}}(s)||"index.js"}`}}RequireError.prototype.name=RequireError.name;var Z=J(Y());function J(e){const t=new Map,n=a(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(D.pop()(a(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=ee,document.head.appendChild(r)}))),n}function a(t){return n=>Promise.resolve(e(n,t)).then(r)}function o(e){return arguments.length>1?Promise.all(F.call(arguments,n)).then(Q):n(e)}return o.alias=function(t){return J(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},o.resolve=e,o}function Q(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:X(n,e)}):t[e]=n[e]);return t}function X(e,t){return()=>e[t]}function K(e){return"exports"===(e+="")||"module"===e}function ee(e,t,n){const r=arguments.length;r<2?(n=e,t=[]):r<3&&(n=t,t="string"==typeof e?[]:e),D.push(B.call(t,K)?e=>{const r={},a={exports:r};return Promise.all(F.call(t,(t=>"exports"===(t+="")?r:"module"===t?a:e(t)))).then((e=>(n.apply(null,e),a.exports)))}:e=>Promise.all(F.call(t,e)).then((e=>"function"==typeof n?n.apply(null,e):n)))}ee.amd={};const te="https://cdn.observableusercontent.com/npm/";let ne=Z;async function re(e){const[t,n]=await Promise.all([e(O.resolve()),e.resolve(O.resolve("dist/"))]);return t({locateFile:e=>`${n}${e}`})}class SQLiteDatabaseClient{constructor(e){Object.defineProperties(this,{_db:{value:e}})}static async open(e){const[t,n]=await Promise.all([re(ne),Promise.resolve(e).then(oe)]);return new SQLiteDatabaseClient(new t.Database(n))}async query(e,t){return await async function(e,t,n){const[r]=await e.exec(t,n);if(!r)return[];const{columns:a,values:o}=r,s=o.map((e=>Object.fromEntries(e.map(((e,t)=>[a[t],e])))));return s.columns=a,s}(this._db,e,t)}async queryRow(e,t){return(await this.query(e,t))[0]||null}async explain(e,t){return se("pre",{className:"observablehq--inspect"},[ie((await this.query(`EXPLAIN QUERY PLAN ${e}`,t)).map((e=>e.detail)).join("\n"))])}async describeTables({schema:e}={}){return this.query(`SELECT NULLIF(schema, 'main') AS schema, name FROM pragma_table_list() WHERE type = 'table'${null==e?"":" AND schema = ?"} AND name NOT LIKE 'sqlite_%' ORDER BY schema, name`,null==e?[]:[e])}async describeColumns({schema:e,table:t}={}){if(null==t)throw new Error("missing table");const n=await this.query(`SELECT name, type, "notnull" FROM pragma_table_info(?${null==e?"":", ?"}) ORDER BY cid`,null==e?[t]:[t,e]);if(!n.length)throw new Error(`table not found: ${t}`);return n.map((({name:e,type:t,notnull:n})=>({name:e,type:ae(t),databaseType:t,nullable:!n})))}async describe(e){const t=await(void 0===e?this.query("SELECT name FROM sqlite_master WHERE type = 'table'"):this.query("SELECT * FROM pragma_table_info(?)",[e]));if(!t.length)throw new Error("Not found");const{columns:n}=t;return se("table",{value:t},[se("thead",[se("tr",n.map((e=>se("th",[ie(e)]))))]),se("tbody",t.map((e=>se("tr",n.map((t=>se("td",[ie(e[t])])))))))])}async sql(){return this.query(...this.queryTag.apply(this,arguments))}queryTag(e,...t){return[e.join("?"),t]}}function ae(e){switch(e){case"NULL":return"null";case"INT":case"INTEGER":case"TINYINT":case"SMALLINT":case"MEDIUMINT":case"BIGINT":case"UNSIGNED BIG INT":case"INT2":case"INT8":return"integer";case"TEXT":case"CLOB":case"DATE":case"DATETIME":return"string";case"REAL":case"DOUBLE":case"DOUBLE PRECISION":case"FLOAT":case"NUMERIC":return"number";case"BLOB":return"buffer";default:return/^(?:(?:(?:VARYING|NATIVE) )?CHARACTER|(?:N|VAR|NVAR)CHAR)\(/.test(e)?"string":/^(?:DECIMAL|NUMERIC)\(/.test(e)?"number":"other"}}function oe(e){return"string"==typeof e?fetch(e).then(oe):e instanceof Response||e instanceof Blob?e.arrayBuffer().then(oe):e instanceof ArrayBuffer?new Uint8Array(e):e}function se(e,t,n){2===arguments.length&&(n=t,t=void 0);const r=document.createElement(e);if(void 0!==t)for(const e in t)r[e]=t[e];if(void 0!==n)for(const e of n)r.appendChild(e);return r}function ie(e){return document.createTextNode(e)}Object.defineProperty(SQLiteDatabaseClient.prototype,"dialect",{value:"sqlite"});class Workbook{constructor(e){Object.defineProperties(this,{_:{value:e},sheetNames:{value:e.worksheets.map((e=>e.name)),enumerable:!0}})}sheet(e,t){const n="number"==typeof e?this.sheetNames[e]:this.sheetNames.includes(e+="")?e:null;if(null==n)throw new Error(`Sheet not found: ${e}`);return function(e,{range:t,headers:n}={}){let[[r,a],[o,s]]=function(e=":",{columnCount:t,rowCount:n}){if(!(e+="").match(/^[A-Z]*\d*:[A-Z]*\d*$/))throw new Error("Malformed range specifier");const[[r=0,a=0],[o=t-1,s=n-1]]=e.split(":").map(fe);return[[r,a],[o,s]]}(t,e);const i=n?e._rows[a++]:null;let c=new Set(["#"]);for(let e=r;e<=o;e++){const t=i?ce(i.findCell(e+1)):null;let n=t&&t+""||ue(e);for(;c.has(n);)n+="_";c.add(n)}c=new Array(r).concat(Array.from(c));const l=new Array(s-a+1);for(let t=a;t<=s;t++){const n=l[t-a]=Object.create(null,{"#":{value:t+1}}),s=e.getRow(t+1);if(s.hasValues)for(let e=r;e<=o;e++){const t=ce(s.findCell(e+1));null!=t&&(n[c[e+1]]=t)}}return l.columns=c.filter((()=>!0)),l}(this._.getWorksheet(n),t)}}function ce(e){if(!e)return;const{value:t}=e;if(t&&"object"==typeof t&&!(t instanceof Date)){if(t.formula||t.sharedFormula)return t.result&&t.result.error?NaN:t.result;if(t.richText)return le(t);if(t.text){let{text:e}=t;return e.richText&&(e=le(e)),t.hyperlink&&t.hyperlink!==e?`${t.hyperlink} ${e}`:e}return t}return t}function le(e){return e.richText.map((e=>e.text)).join("")}function ue(e){let t="";e++;do{t=String.fromCharCode(64+(e%26||26))+t}while(e=Math.floor((e-1)/26));return t}function fe(e){const[,t,n]=e.match(/^([A-Z]*)(\d*)$/);let r=0;if(t)for(let e=0;e<t.length;e++)r+=Math.pow(26,t.length-e-1)*(t.charCodeAt(e)-64);return[r?r-1:void 0,n?+n-1:void 0]}async function de(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function me(e,t,{array:n=!1,typed:r=!1}={}){const a=await e.text();return("\t"===t?n?m:d:n?u:l)(a,r&&h)}class he{constructor(e,t){Object.defineProperty(this,"name",{value:e,enumerable:!0}),void 0!==t&&Object.defineProperty(this,"mimeType",{value:t+"",enumerable:!0})}async blob(){return(await de(this)).blob()}async arrayBuffer(){return(await de(this)).arrayBuffer()}async text(){return(await de(this)).text()}async json(){return(await de(this)).json()}async stream(){return(await de(this)).body}async csv(e){return me(this,",",e)}async tsv(e){return me(this,"\t",e)}async image(e){const t=await this.url();return new Promise(((n,r)=>{const a=new Image;new URL(t,document.baseURI).origin!==new URL(location).origin&&(a.crossOrigin="anonymous"),Object.assign(a,e),a.onload=()=>n(a),a.onerror=()=>r(new Error(`Unable to load file: ${this.name}`)),a.src=t}))}async arrow({version:e=4}={}){switch(e){case 4:{const[e,t]=await Promise.all([ne(L.resolve()),de(this)]);return e.Table.from(t)}case 9:{const[e,t]=await Promise.all([import(`${te}${$.resolve()}`),de(this)]);return e.tableFromIPC(t)}default:throw new Error(`unsupported arrow version: ${e}`)}}async sqlite(){return SQLiteDatabaseClient.open(de(this))}async zip(){const[e,t]=await Promise.all([ne(x.resolve()),this.arrayBuffer()]);return new ZipArchive(await e.loadAsync(t))}async xml(e="application/xml"){return(new DOMParser).parseFromString(await this.text(),e)}async html(){return this.xml("text/html")}async xlsx(){const[e,t]=await Promise.all([ne(S.resolve()),this.arrayBuffer()]);return new Workbook(await(new e.Workbook).xlsx.load(t))}}class FileAttachment extends he{constructor(e,t,n){super(t,n),Object.defineProperty(this,"_url",{value:e})}async url(){return await this._url+""}}function pe(e){throw new Error(`File not found: ${e}`)}class ZipArchive{constructor(e){Object.defineProperty(this,"_",{value:e}),this.filenames=Object.keys(e.files).filter((t=>!e.files[t].dir))}file(e){const t=this._.file(e+="");if(!t||t.dir)throw new Error(`file not found: ${e}`);return new ZipArchiveEntry(t)}}class ZipArchiveEntry extends he{constructor(e){super(e.name),Object.defineProperty(this,"_",{value:e}),Object.defineProperty(this,"_url",{writable:!0})}async url(){return this._url||(this._url=this.blob().then(URL.createObjectURL))}async blob(){return this._.async("blob")}async arrayBuffer(){return this._.async("arraybuffer")}async text(){return this._.async("text")}async json(){return JSON.parse(await this.text())}}var we={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 be=0;function ye(e){return new ve("O-"+(null==e?"":e+"-")+ ++be)}function ve(e){this.id=e,this.href=new URL(`#${e}`,location)+""}ve.prototype.toString=function(){return"url("+this.href+")"};var ge=Object.freeze({__proto__:null,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 a=r.getContext("2d");return a.scale(n,n),a},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),a=r.appendChild(document.createElement("button"));async function o(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),a.textContent=n,a.disabled=!1}return a.textContent=n,r.download=t,r.onclick=async t=>{if(a.disabled=!0,r.href)return o();a.textContent="Saving…";try{const t=await("function"==typeof e?e():e);a.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){a.textContent=n}if(t.eventPhase)return o();a.disabled=!1},r},element:function(e,t){var n,r=e+="",a=r.indexOf(":");a>=0&&"xmlns"!==(r=e.slice(0,a))&&(e=e.slice(a+1));var o=we.hasOwnProperty(r)?document.createElementNS(we[r],e):document.createElement(e);if(t)for(var s in t)a=(r=s).indexOf(":"),n=t[s],a>=0&&"xmlns"!==(r=s.slice(0,a))&&(s=s.slice(a+1)),we.hasOwnProperty(r)?o.setAttributeNS(we[r],s,n):o.setAttribute(s,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:ye});var Ee=Object.freeze({__proto__:null,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 Ae(){return this}function Te(e,t){let n=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:Ae,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function je(e){let t,n,r=!1;const a=e((function(e){n?(n(e),n=null):r=!0;return t=e}));if(null!=a&&"function"!=typeof a)throw new Error("function"==typeof a.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:Ae,throw:()=>({done:!0}),return:()=>(null!=a&&a(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise((e=>n=e))}}}}function xe(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];case"select-multiple":return Array.from(e.selectedOptions,(e=>e.value));default:return e.value}}var Ne=Object.freeze({__proto__:null,disposable:Te,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return je((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=xe(e);function a(){t(xe(e))}return e.addEventListener(n,a),void 0!==r&&t(r),function(){e.removeEventListener(n,a)}}))},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:je,queue:function(e){let t;const n=[],r=e((function(e){n.push(e),t&&(t(n.shift()),t=null);return e}));if(null!=r&&"function"!=typeof r)throw new Error("function"==typeof r.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:Ae,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=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+n;for(var r=-1,a=0|Math.max(0,Math.ceil((t-e)/n));++r<a;)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 Te(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}});function Oe(e){return e&&"function"==typeof e.toArrowBuffer}function ke(e){return e&&"function"==typeof e.getChild&&"function"==typeof e.toArray&&e.schema&&Array.isArray(e.schema.fields)}function Ce(e){return e.schema.fields.map(qe)}function qe(e){return{name:e.name,type:Le(e.type),nullable:e.nullable,databaseType:String(e.type)}}function Le(e){switch(e.typeId){case 2:return"integer";case 3:case 7:return"number";case 4:case 15:return"buffer";case 5:return"string";case 6:return"boolean";case 8:case 9:case 10:return"date";case 12:case 16:return"array";case 13:case 14:return"object";default:return"other"}}async function $e(){return await import(`${te}${$.resolve()}`)}class DuckDBClient{constructor(e){Object.defineProperties(this,{_db:{value:e}})}async queryStream(e,t){const n=await this._db.connect();let r,a;try{if(t?.length>0){const a=await n.prepare(e);r=await a.send(...t)}else r=await n.send(e);if(a=await r.next(),a.done)throw new Error("missing first batch")}catch(e){throw await n.close(),e}return{schema:Ce(a.value),async*readRows(){try{for(;!a.done;)yield a.value.toArray(),a=await r.next()}finally{await n.close()}}}}async query(e,t){const n=await this.queryStream(e,t),r=[];for await(const e of n.readRows())for(const t of e)r.push(t);return r.schema=n.schema,r}async queryRow(e,t){const n=(await this.queryStream(e,t)).readRows();try{const{done:e,value:t}=await n.next();return e||!t.length?null:t[0]}finally{await n.return()}}async sql(e,...t){return await this.query(e.join("?"),t)}queryTag(e,...t){return[e.join("?"),t]}escape(e){return`"${e}"`}async describeTables(){return(await this.query("SHOW TABLES")).map((({name:e})=>({name:e})))}async describeColumns({table:e}={}){return(await this.query(`DESCRIBE ${this.escape(e)}`)).map((({column_name:e,column_type:t,null:n})=>({name:e,type:Pe(t),nullable:"NO"!==n,databaseType:t})))}static async of(e={},t={}){const n=await async function(){const e=await import(`${te}${_.resolve()}`),t=await e.selectBundle({mvp:{mainModule:`${te}${_.resolve("dist/duckdb-mvp.wasm")}`,mainWorker:`${te}${_.resolve("dist/duckdb-browser-mvp.worker.js")}`},eh:{mainModule:`${te}${_.resolve("dist/duckdb-eh.wasm")}`,mainWorker:`${te}${_.resolve("dist/duckdb-browser-eh.worker.js")}`}}),n=new e.ConsoleLogger,r=await e.createWorker(t.mainWorker),a=new e.AsyncDuckDB(n,r);return await a.instantiate(t.mainModule),a}();return void 0===t.query?.castTimestampToDate&&(t={...t,query:{...t.query,castTimestampToDate:!0}}),await n.open(t),await Promise.all(Object.entries(e).map((async([e,t])=>{if(t instanceof FileAttachment)await Re(n,e,t);else if(ke(t))await Ie(n,e,t);else if(Array.isArray(t))await Se(n,e,t);else if(Oe(t))await async function(e,t,n){const r=(await $e()).tableFromIPC(n.toArrowBuffer());return await Ie(e,t,r)}(n,e,t);else if("data"in t){const{data:r,...a}=t;ke(r)?await Ie(n,e,r,a):await Se(n,e,r,a)}else{if(!("file"in t))throw new Error(`invalid source: ${t}`);{const{file:r,...a}=t;await Re(n,e,r,a)}}}))),new DuckDBClient(n)}}async function Re(e,t,n,r){const a=await n.url();if(a.startsWith("blob:")){const t=await n.arrayBuffer();await e.registerFileBuffer(n.name,new Uint8Array(t))}else await e.registerFileURL(n.name,a);const o=await e.connect();try{switch(n.mimeType){case"text/csv":case"text/tab-separated-values":return await o.insertCSVFromPath(n.name,{name:t,schema:"main",...r});case"application/json":return await o.insertJSONFromPath(n.name,{name:t,schema:"main",...r});default:if(/\.arrow$/i.test(n.name)){const e=new Uint8Array(await n.arrayBuffer());return await o.insertArrowFromIPCStream(e,{name:t,schema:"main",...r})}if(/\.parquet$/i.test(n.name))return await o.query(`CREATE VIEW '${t}' AS SELECT * FROM parquet_scan('${n.name}')`);throw new Error(`unknown file type: ${n.mimeType}`)}}finally{await o.close()}}async function Ie(e,t,n,r){const a=await e.connect();try{await a.insertArrowTable(n,{name:t,schema:"main",...r})}finally{await a.close()}}async function Se(e,t,n,r){const a=(await $e()).tableFromJSON(n);return await Ie(e,t,a,r)}function Pe(e){switch(e){case"BIGINT":case"HUGEINT":case"UBIGINT":return"bigint";case"DOUBLE":case"REAL":case"FLOAT":return"number";case"INTEGER":case"SMALLINT":case"TINYINT":case"USMALLINT":case"UINTEGER":case"UTINYINT":return"integer";case"BOOLEAN":return"boolean";case"DATE":case"TIMESTAMP":case"TIMESTAMP WITH TIME ZONE":return"date";case"VARCHAR":case"UUID":return"string";default:return/^DECIMAL\(/.test(e)?"integer":"other"}}function Me(e,t){return function(n){var r,a,o,s,i,c,l,u,f=n[0],d=[],m=null,h=-1;for(i=1,c=arguments.length;i<c;++i){if((r=arguments[i])instanceof Node)d[++h]=r,f+="\x3c!--o:"+h+"--\x3e";else if(Array.isArray(r)){for(l=0,u=r.length;l<u;++l)(a=r[l])instanceof Node?(null===m&&(d[++h]=m=document.createDocumentFragment(),f+="\x3c!--o:"+h+"--\x3e"),m.appendChild(a)):(m=null,f+=a);m=null}else f+=r;f+=n[i]}if(m=e(f),++h>0){for(o=new Array(h),s=document.createTreeWalker(m,NodeFilter.SHOW_COMMENT,null,!1);s.nextNode();)a=s.currentNode,/^o:/.test(a.nodeValue)&&(o[+a.nodeValue.slice(2)]=a);for(i=0;i<h;++i)(a=o[i])&&a.parentNode.replaceChild(d[i],a)}return 1===m.childNodes.length?m.removeChild(m.firstChild):11===m.nodeType?((a=t()).appendChild(m),a):m}}Object.defineProperty(DuckDBClient.prototype,"dialect",{value:"duckdb"});const _e=Me((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));function Ue(e){let t;Object.defineProperties(this,{generator:{value:je((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*De(){for(;;)yield Date.now()}var Fe=new Map;function Be(e,t){var n;return(n=Fe.get(e=+e))?n.then((()=>t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise((function(n){Fe.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 Fe.set(t,n),n}(n,e).then((()=>t))}var We=Object.freeze({__proto__:null,delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return Be(Math.ceil((Date.now()+1)/e)*e,t)},when:Be});function He(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 ze=Me((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")}));var Ve=String.raw;function Ge(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 Ye(){return je((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)}}))}function Ze(e,t){return e&&("function"==typeof e.sql||"function"==typeof e.queryTag&&("function"==typeof e.query||"function"==typeof e.queryStream))&&("table"!==t||"function"==typeof e.describeColumns)&&e!==tt}function Je(e){return Array.isArray(e)&&(n=e.schema,Array.isArray(n)&&n.every((e=>e&&"string"==typeof e.name))||(t=e.columns,Array.isArray(t)&&t.every((e=>"string"==typeof e)))||function(e){const t=Math.min(20,e.length);for(let n=0;n<t;++n){const t=e[n];if(null===t||"object"!=typeof t)return!1}return t>0&&function(e){for(const t in e)return!0;return!1}(e[0])}(e)||Xe(e)||Ke(e))||et(e);var t,n}function Qe(e){return et(e)||Xe(e)||Ke(e)}function Xe(e){const t=Math.min(20,e.length);if(!(t>0))return!1;let n,r=!1;for(let a=0;a<t;++a){const t=e[a];if(null==t)continue;const o=typeof t;if(void 0===n)switch(o){case"number":case"boolean":case"string":case"bigint":n=o;break;default:return!1}else if(o!==n)return!1;r=!0}return r}function Ke(e){const t=Math.min(20,e.length);if(!(t>0))return!1;let n=!1;for(let r=0;r<t;++r){const t=e[r];if(null!=t){if(!(t instanceof Date))return!1;n=!0}}return n}function et(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}const tt=Object.assign((async(e,t,n,r)=>{if(Ze(e=await rt(await e,r)))return st(e,it(t,e),n);if(Je(e))return Nt(e,t);if(!e)throw new Error("missing data source");throw new Error("invalid data source")}),{sql:(e,t,n)=>async function(){return st(await at(await e,n),arguments,t)}});function nt(e){const t=new WeakMap;return(n,r)=>{if(!n)throw new Error("data source not found");let a=t.get(n);return(!a||Je(n)&&n.length!==a._numRows)&&(a=e(n,r),a._numRows=n.length,t.set(n,a)),a}}const rt=nt((async(e,t)=>{if(e instanceof FileAttachment){switch(e.mimeType){case"text/csv":return e.csv({typed:!0});case"text/tab-separated-values":return e.tsv({typed:!0});case"application/json":return e.json();case"application/x-sqlite3":return e.sqlite()}if(/\.(arrow|parquet)$/i.test(e.name))return ot(e,t);throw new Error(`unsupported file type: ${e.mimeType}`)}return ke(e)||Oe(e)?ot(e,t):e})),at=nt((async(e,t)=>{if(e instanceof FileAttachment){switch(e.mimeType){case"text/csv":case"text/tab-separated-values":case"application/json":return ot(e,t);case"application/x-sqlite3":return e.sqlite()}if(/\.(arrow|parquet)$/i.test(e.name))return ot(e,t);throw new Error(`unsupported file type: ${e.mimeType}`)}return Je(e)?ot(await async function(e,t){const n=await $e();return Qe(e)?n.tableFromArrays({[t]:e}):n.tableFromJSON(e)}(e,t),t):ke(e)||Oe(e)?ot(e,t):e}));function ot(e,t=(e instanceof FileAttachment?function(e){return e.name.replace(/@\d+(?=\.|$)/,"").replace(/\.\w+$/,"")}(e):"__table")){return DuckDBClient.of({[t]:e})}async function st(e,t,n){if(!e)throw new Error("missing data source");if("function"==typeof e.queryTag){const r=new AbortController,a={signal:r.signal};if(n.then((()=>r.abort("invalidated"))),"function"==typeof e.queryStream)return async function*(e){let t=performance.now();const n=await e,r=[];r.done=!1,r.error=null,r.schema=n.schema;try{for await(const e of n.readRows()){performance.now()-t>10&&r.length>0&&(yield r,t=performance.now());for(const t of e)r.push(t)}r.done=!0,yield r}catch(e){r.error=e,yield r}}(e.queryStream(...e.queryTag.apply(e,t),a));if("function"==typeof e.query)return e.query(...e.queryTag.apply(e,t),a)}if("function"==typeof e.sql)return e.sql.apply(e,t);throw new Error("source does not implement query, queryStream, or sql")}function it(e,t){const n="function"==typeof t.escape?t.escape:e=>e,{select:r,from:a,filter:o,sort:s,slice:i}=e;if(!a.table)throw new Error("missing from table");if(r.columns&&0===r.columns.length)throw new Error("at least one column must be selected");const c=[[`SELECT ${r.columns?r.columns.map(n).join(", "):"*"} FROM ${ct(a.table,n)}`]];for(let e=0;e<o.length;++e)lt(e?"\nAND ":"\nWHERE ",c),ft(o[e],c,n);for(let e=0;e<s.length;++e)lt(e?", ":"\nORDER BY ",c),ut(s[e],c,n);if("mssql"===t.dialect||"oracle"===t.dialect){if(null!==i.to||null!==i.from){if(!s.length){if(!r.columns)throw new Error("at least one column must be explicitly specified. Received '*'.");lt("\nORDER BY ",c),ut({column:r.columns[0],direction:"ASC"},c,n)}lt(`\nOFFSET ${i.from||0} ROWS`,c),lt(`\nFETCH NEXT ${null!==i.to?i.to-(i.from||0):1e9} ROWS ONLY`,c)}}else null===i.to&&null===i.from||lt("\nLIMIT "+(null!==i.to?i.to-(i.from||0):1e9),c),null!==i.from&&lt(` OFFSET ${i.from}`,c);return c}function ct(e,t){if("object"==typeof e){let n="";return null!=e.database&&(n+=t(e.database)+"."),null!=e.schema&&(n+=t(e.schema)+"."),n+=t(e.table),n}return t(e)}function lt(e,t){const n=t[0];n[n.length-1]+=e}function ut({column:e,direction:t},n,r){lt(`${r(e)} ${t.toUpperCase()}`,n)}function ft({type:e,operands:t},n,r){if(t.length<1)throw new Error("Invalid operand length");if(1===t.length)switch(dt(t[0],n,r),e){case"n":return void lt(" IS NULL",n);case"nn":return void lt(" IS NOT NULL",n);default:throw new Error("Invalid filter operation")}if(2!==t.length||["in","nin"].includes(e)){var a;switch(dt(t[0],n,r),e){case"in":lt(" IN (",n);break;case"nin":lt(" NOT IN (",n);break;default:throw new Error("Invalid filter operation")}!function(e,t){let n=!0;for(const r of e)n?n=!1:lt(",",t),t.push(r.value),t[0].push("")}(t.slice(1),n),lt(")",n)}else{if(["c","nc","v","nv"].includes(e)){switch(dt(t[0],n,r),e){case"c":lt(" LIKE ",n);break;case"nc":lt(" NOT LIKE ",n);break;case"nv":lt(" IS NULL",n);break;case"v":lt(" IS NOT NULL",n)}return void dt((a=t[1],{...a,value:`%${a.value}%`}),n,r)}switch(dt(t[0],n,r),e){case"eq":lt(" = ",n);break;case"ne":lt(" <> ",n);break;case"gt":lt(" > ",n);break;case"lt":lt(" < ",n);break;case"gte":lt(" >= ",n);break;case"lte":lt(" <= ",n);break;default:throw new Error("Invalid filter operation")}dt(t[1],n,r)}}function dt(e,t,n){"column"===e.type?lt(n(e.value),t):(t.push(e.value),t[0].push(""))}function mt(e,t){return(null==e||!(e>=e))-(null==t||!(t>=t))}function ht(e,t){return mt(e,t)||(e<t?-1:e>t?1:0)}function pt(e,t){return mt(e,t)||(e>t?-1:e<t?1:0)}const wt=e=>"number"==typeof e&&!Number.isNaN(e),bt=e=>"string"==typeof e,yt=e=>"boolean"==typeof e,vt=e=>"bigint"==typeof e,gt=e=>e instanceof Date&&!isNaN(e),Et=e=>e instanceof ArrayBuffer,At=e=>Array.isArray(e),Tt=e=>"object"==typeof e&&null!==e,jt=e=>null!=e;function xt(e){switch(e){case"string":return bt;case"bigint":return vt;case"boolean":return yt;case"number":return wt;case"date":return gt;case"buffer":return Et;case"array":return At;case"object":return Tt;default:return jt}}function Nt(e,t){const n=e;let{schema:r,columns:a}=e,o=Qe(e);o&&(e=Array.from(e,(e=>({value:e}))));for(const{type:n,operands:r}of t.filter){const[{value:t}]=r,a=r.slice(1).map((({value:e})=>e));switch(n){case"v":{const[n]=a,r=xt(n);e=e.filter((e=>r(e[t])));break}case"nv":{const[n]=a,r=xt(n);e=e.filter((e=>!r(e[t])));break}case"eq":{const[n]=a;if(n instanceof Date){const r=+n;e=e.filter((e=>+e[t]===r))}else e=e.filter((e=>e[t]===n));break}case"ne":{const[n]=a;e=e.filter((e=>e[t]!==n));break}case"c":{const[n]=a;e=e.filter((e=>"string"==typeof e[t]&&e[t].includes(n)));break}case"nc":{const[n]=a;e=e.filter((e=>"string"==typeof e[t]&&!e[t].includes(n)));break}case"in":{const n=new Set(a);e=e.filter((e=>n.has(e[t])));break}case"nin":{const n=new Set(a);e=e.filter((e=>!n.has(e[t])));break}case"n":e=e.filter((e=>null==e[t]));break;case"nn":e=e.filter((e=>null!=e[t]));break;case"lt":{const[n]=a;e=e.filter((e=>e[t]<n));break}case"lte":{const[n]=a;e=e.filter((e=>e[t]<=n));break}case"gt":{const[n]=a;e=e.filter((e=>e[t]>n));break}case"gte":{const[n]=a;e=e.filter((e=>e[t]>=n));break}default:throw new Error(`unknown filter type: ${n}`)}}for(const{column:r,direction:a}of function(e){if("function"!=typeof e[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(e).reverse()}(t.sort)){const t="desc"===a?pt:ht;e===n&&(e=e.slice()),e.sort(((e,n)=>t(e[r],n[r])))}let{from:s,to:i}=t.slice;if(s=null==s?0:Math.max(0,s),i=null==i?1/0:Math.max(0,i),(s>0||i<1/0)&&(e=e.slice(Math.max(0,s),Math.max(0,i))),t.select.columns){if(r){const e=new Map(r.map((e=>[e.name,e])));r=t.select.columns.map((t=>e.get(t)))}a&&(a=t.select.columns),e=e.map((e=>Object.fromEntries(t.select.columns.map((t=>[t,e[t]])))))}return o&&(e=e.map((e=>e.value))),e!==n&&(r&&(e.schema=r),a&&(e.columns=a)),e}const Ot=Object.assign(Object.defineProperties((function(e){const t=function(e){return null==e?ne:J(e)}(e);var n;Object.defineProperties(this,(n={FileAttachment:()=>pe,Mutable:()=>Ue,now:De,width:Ye,dot:()=>t(g.resolve()),htl:()=>t(j.resolve()),html:()=>_e,md:()=>function(e){return e(N.resolve()).then((function(t){return Me((function(n){var r=document.createElement("div");r.innerHTML=t(n,{langPrefix:""}).trim();var a=r.querySelectorAll("pre code[class]");return a.length>0&&e(E.resolve()).then((function(t){a.forEach((function(n){function r(){t.highlightBlock(n),n.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(n.className)?r():e(E.resolve("async-languages/index.js")).then((r=>{if(r.has(n.className))return e(E.resolve("async-languages/"+r.get(n.className))).then((e=>{t.registerLanguage(n.className,e)}))})).then(r,r)}))})),r}),(function(){return document.createElement("div")}))}))}(t),svg:()=>ze,tex:()=>function(e){return Promise.all([e(A.resolve()),e.resolve(A.resolve("dist/katex.min.css")).then(Ge)]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(Ve.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}))}(t),_:()=>t(T.resolve()),aq:()=>t.alias({"apache-arrow":L.resolve()})(R.resolve()),Arrow:()=>t(L.resolve()),d3:()=>t(b.resolve()),DuckDBClient:()=>DuckDBClient,Inputs:()=>t(y.resolve()).then((e=>({...e,file:e.fileOf(he)}))),L:()=>async function(e){const t=await e(M.resolve());if(!t._style){const n=document.createElement("link");n.rel="stylesheet",n.href=await e.resolve(M.resolve("dist/leaflet.css")),t._style=document.head.appendChild(n)}return t}(t),mermaid:()=>async function(e){const t=await e(P.resolve());return t.initialize({securityLevel:"loose",theme:"neutral"}),function(){const e=document.createElement("div");return e.innerHTML=t.render(ye().id,String.raw.apply(String,arguments)),e.removeChild(e.firstChild)}}(t),Plot:()=>t(v.resolve()),__query:()=>tt,require:()=>t,resolve:()=>He,SQLite:()=>re(t),SQLiteDatabaseClient:()=>SQLiteDatabaseClient,topojson:()=>t(I.resolve()),vl:()=>async function(e){const[t,n,r]=await Promise.all([k,C,q].map((t=>e(t.resolve()))));return r.register(t,n)}(t),aapl:()=>new FileAttachment("https://static.observableusercontent.com/files/3ccff97fd2d93da734e76829b2b066eafdaac6a1fafdec0faf6ebc443271cfc109d29e80dd217468fcb2aff1e6bffdc73f356cc48feb657f35378e6abbbb63b9").csv({typed:!0}),alphabet:()=>new FileAttachment("https://static.observableusercontent.com/files/75d52e6c3130b1cae83cda89305e17b50f33e7420ef205587a135e8562bcfd22e483cf4fa2fb5df6dff66f9c5d19740be1cfaf47406286e2eb6574b49ffc685d").csv({typed:!0}),cars:()=>new FileAttachment("https://static.observableusercontent.com/files/048ec3dfd528110c0665dfa363dd28bc516ffb7247231f3ab25005036717f5c4c232a5efc7bb74bc03037155cb72b1abe85a33d86eb9f1a336196030443be4f6").csv({typed:!0}),citywages:()=>new FileAttachment("https://static.observableusercontent.com/files/39837ec5121fcc163131dbc2fe8c1a2e0b3423a5d1e96b5ce371e2ac2e20a290d78b71a4fb08b9fa6a0107776e17fb78af313b8ea70f4cc6648fad68ddf06f7a").csv({typed:!0}),diamonds:()=>new FileAttachment("https://static.observableusercontent.com/files/87942b1f5d061a21fa4bb8f2162db44e3ef0f7391301f867ab5ba718b225a63091af20675f0bfe7f922db097b217b377135203a7eab34651e21a8d09f4e37252").csv({typed:!0}),flare:()=>new FileAttachment("https://static.observableusercontent.com/files/a6b0d94a7f5828fd133765a934f4c9746d2010e2f342d335923991f31b14120de96b5cb4f160d509d8dc627f0107d7f5b5070d2516f01e4c862b5b4867533000").csv({typed:!0}),industries:()=>new FileAttachment("https://static.observableusercontent.com/files/76f13741128340cc88798c0a0b7fa5a2df8370f57554000774ab8ee9ae785ffa2903010cad670d4939af3e9c17e5e18e7e05ed2b38b848ac2fc1a0066aa0005f").csv({typed:!0}),miserables:()=>new FileAttachment("https://static.observableusercontent.com/files/31d904f6e21d42d4963ece9c8cc4fbd75efcbdc404bf511bc79906f0a1be68b5a01e935f65123670ed04e35ca8cae3c2b943f82bf8db49c5a67c85cbb58db052").json(),olympians:()=>new FileAttachment("https://static.observableusercontent.com/files/31ca24545a0603dce099d10ee89ee5ae72d29fa55e8fc7c9ffb5ded87ac83060d80f1d9e21f4ae8eb04c1e8940b7287d179fe8060d887fb1f055f430e210007c").csv({typed:!0}),penguins:()=>new FileAttachment("https://static.observableusercontent.com/files/715db1223e067f00500780077febc6cebbdd90c151d3d78317c802732252052ab0e367039872ab9c77d6ef99e5f55a0724b35ddc898a1c99cb14c31a379af80a").csv({typed:!0}),weather:()=>new FileAttachment("https://static.observableusercontent.com/files/693a46b22b33db0f042728700e0c73e836fa13d55446df89120682d55339c6db7cc9e574d3d73f24ecc9bc7eb9ac9a1e7e104a1ee52c00aab1e77eb102913c1f").csv({typed:!0}),DOM:ge,Files:Ee,Generators:Ne,Promises:We},Object.fromEntries(Object.entries(n).map(kt))))}),{resolve:{get:()=>ne.resolve,enumerable:!0,configurable:!0},require:{get:()=>ne,set:function(e){ne=e},enumerable:!0,configurable:!0}}),{resolveFrom:Y,requireFrom:J});function kt([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}e.AbstractFile=he,e.FileAttachments=function(e){return Object.assign((t=>{const n=e(t+="");if(null==n)throw new Error(`File not found: ${t}`);if("object"==typeof n&&"url"in n){const{url:e,mimeType:r}=n;return new FileAttachment(e,t,r)}return new FileAttachment(n,t)}),{prototype:FileAttachment.prototype})},e.Library=Ot,e.applyDataTableOperations=Nt,e.arrayIsPrimitive=Qe,e.getArrowTableSchema=Ce,e.getTypeValidator=xt,e.isArqueroTable=Oe,e.isArrowTable=ke,e.isDataArray=Je,e.isDatabaseClient=Ze,e.loadDataSource=async function(e,t,n){switch(t){case"table":return rt(e,n);case"sql":return at(e,n)}return e},e.makeQueryTemplate=it}));
{
"name": "@observablehq/stdlib",
"version": "5.2.4",
"version": "5.3.0",
"author": {

@@ -5,0 +5,0 @@ "name": "Observable, Inc.",

@@ -11,3 +11,4 @@ export {FileAttachments, AbstractFile} from "./fileAttachment.js";

isDatabaseClient,
__table as applyDataTableOperations
__table as applyDataTableOperations,
getTypeValidator
} from "./table.js";

@@ -1,2 +0,2 @@

import {ascending, descending, reverse} from "d3-array";
import {reverse} from "d3-array";
import {FileAttachment} from "./fileAttachment.js";

@@ -401,3 +401,3 @@ import {isArqueroTable} from "./arquero.js";

// Fallthrough to next parent block.
} else if (["c", "nc"].includes(type)) {
} else if (["c", "nc", "v", "nv"].includes(type)) {
// TODO: Case (in)sensitive?

@@ -412,2 +412,10 @@ appendOperand(operands[0], args, escaper);

break;
// JavaScript "not valid" filter translate to a SQL "IS NULL"
case "nv":
appendSql(` IS NULL`, args);
break;
// JavaScript "valid" filter translate to a SQL "IS NOT NULL"
case "v":
appendSql(` IS NOT NULL`, args);
break;
}

@@ -485,2 +493,56 @@ appendOperand(likeOperand(operands[1]), args, escaper);

// Comparator function that moves null values (undefined, null, NaN) to the
// end of the array.
function defined(a, b) {
return (a == null || !(a >= a)) - (b == null || !(b >= b));
}
// Comparator function that sorts values in ascending order, with null values at
// the end.
function ascendingDefined(a, b) {
return defined(a, b) || (a < b ? -1 : a > b ? 1 : 0);
}
// Comparator function that sorts values in descending order, with null values
// at the end.
function descendingDefined(a, b) {
return defined(a, b) || (a > b ? -1 : a < b ? 1 : 0);
}
// Functions for checking type validity
const isValidNumber = (value) => typeof value === "number" && !Number.isNaN(value);
const isValidString = (value) => typeof value === "string";
const isValidBoolean = (value) => typeof value === "boolean";
const isValidBigint = (value) => typeof value === "bigint";
const isValidDate = (value) => value instanceof Date && !isNaN(value);
const isValidBuffer = (value) => value instanceof ArrayBuffer;
const isValidArray = (value) => Array.isArray(value);
const isValidObject = (value) => typeof value === "object" && value !== null;
const isValidOther = (value) => value != null;
// Function to get the correct validity checking function based on type
export function getTypeValidator(colType) {
switch (colType) {
case "string":
return isValidString;
case "bigint":
return isValidBigint;
case "boolean":
return isValidBoolean;
case "number":
return isValidNumber;
case "date":
return isValidDate;
case "buffer":
return isValidBuffer;
case "array":
return isValidArray;
case "object":
return isValidObject;
case "other":
default:
return isValidOther;
}
}
// This function applies table cell operations to an in-memory table (array of

@@ -499,2 +561,16 @@ // objects); it should be equivalent to the corresponding SQL query. TODO Use

switch (type) {
// valid (matches the column type)
case "v": {
const [colType] = values;
const isValid = getTypeValidator(colType);
source = source.filter(d => isValid(d[column]));
break;
}
// not valid (doesn't match the column type)
case "nv": {
const [colType] = values;
const isValid = getTypeValidator(colType);
source = source.filter(d => !isValid(d[column]));
break;
}
case "eq": {

@@ -572,3 +648,3 @@ const [value] = values;

for (const {column, direction} of reverse(operations.sort)) {
const compare = direction === "desc" ? descending : ascending;
const compare = direction === "desc" ? descendingDefined : ascendingDefined;
if (source === input) source = source.slice(); // defensive copy

@@ -575,0 +651,0 @@ source.sort((a, b) => compare(a[column], b[column]));

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc