@embd/mcp 0.7.6 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -168,6 +168,16 @@ The separate `embd-documents-mcp` entry point works with private workspace Markd
168
168
 
169
169
  A workspace owner opens **Workspace → Agent access**, chooses a name and read/comment/edit scope, and copies the credential once. Access is workspace-scoped, expires after 30 days and can be revoked there. Configure it as `EMBD_DOCUMENT_TOKEN`; optionally set `EMBD_DOCUMENT_ORIGIN` (default `https://app.embd.sh`). Never place the token in document source or a shared configuration file.
170
170
 
171
+ A guest invited to one document can also open **Agent access** from that document.
172
+ That credential is capped to the named document and the guest's current role;
173
+ listing, search, history, comments, images and selected-document sync respect the
174
+ same boundary. The agent cannot create documents, import sets, change folders,
175
+ upload workspace images, invite people or alter access. Revoking the guest or
176
+ lowering their role immediately limits future server requests by their agent.
177
+ An existing downloaded copy cannot be recalled; local replicas retain their
178
+ bounded offline lease. Invitation acceptance and audience management stay in
179
+ the human **Share** flow.
180
+
171
181
  Install the published package with `npm install --global @embd/mcp` using Node.js 22.13 or later, then configure your MCP client to launch `embd-documents-mcp` with that environment and no arguments. The workspace setup panel supplies a version-pinned install command matching its release. If your desktop client cannot find the command, use its absolute path (`command -v embd-documents-mcp` on macOS/Linux).
172
182
 
173
183
  A source build remains available for contributors: run `bun install` and `bun run --filter @embd/mcp build` from the repository, then launch `node /absolute/path/to/embd/packages/mcp/dist/documents-bin.js`. A source checkout is not required for the published client.
@@ -1,4 +1,4 @@
1
- import{q as o,r,s as e,t as ZZ,y as $Z}from"./bin-q74qdkyd.js";import{D as G,E as MZ,F as C,G as z,H as v,I as S,J as c,K as l,L as s}from"./bin-y6yfg1je.js";var VZ=["line","area","bar","stacked-bar","stacked-area","bar-horizontal","scatter","pie","donut","heatmap","radar"],E=["stage","slate","dusk","paper","mist","sepia"];function H(Z,$){return{content:[{type:"text",text:Z}],structuredContent:{url:Z,kind:$}}}function k(Z){return{content:[{type:"text",text:Z instanceof Error?Z.message:String(Z)}],isError:!0}}async function LZ(Z,$={}){try{let Q=await o(Z.data,{origin:$.origin,kind:Z.kind,title:Z.title,themeId:Z.theme});return H(Q,"chart")}catch(Q){return k(Q)}}async function UZ(Z,$={}){try{let Q=await r(Z.content,{origin:$.origin,theme:Z.theme});return H(Q,"markdown")}catch(Q){return k(Q)}}async function fZ(Z,$={}){try{let Q=await e(Z,{origin:$.origin});return H(Q,"kpi")}catch(Q){return k(Q)}}async function AZ(Z,$={}){try{let Q=await ZZ(Z,{origin:$.origin});return H(Q,"qr")}catch(Q){return k(Q)}}var O={readOnlyHint:!0,destructiveHint:!1,openWorldHint:!1},_Z=["create_kpi"];function QZ(Z={}){let $=new s({name:"embd",version:$Z});if($.registerTool("create_chart",{title:"Create a shareable embd chart link",description:"Turn tabular data into a beautiful, shareable chart and return a self-contained embd.sh URL. "+"No account, no upload, no API call — the chart data is encoded directly into the returned link, "+"so it works anywhere and needs no backend. Use this when you have data (CSV text or an array of flat JSON row objects) and the user wants a chart they can link to, share, or embed. "+"Column roles are inferred automatically (first non-numeric column → X axis, numeric columns → "+"series). Because the data rides in the URL, there is a size limit — if the data is too large the "+"tool returns an error asking you to reduce it; very large datasets need the hosted embd server instead.",inputSchema:G.object({data:G.union([G.string(),G.array(G.record(G.string(),G.unknown()))]).describe('CSV text (first row = headers) or an array of flat row objects with identical keys, e.g. [{"month":"Jan","sales":120}, ...].'),kind:G.enum(VZ).optional().describe("Chart type. Default: inferred from the data (usually line or bar)."),title:G.string().optional().describe("Chart title."),theme:G.string().optional().describe("Theme id (e.g. aurora-dark, aurora-light). Default: aurora-dark.")}),annotations:O},async(Q)=>LZ(Q,Z)),$.registerTool("create_doc",{title:"Create a shareable embd markdown doc link",description:"Render Markdown into a clean, shareable page and return a self-contained embd.sh URL. "+"No account and no upload — the Markdown source is encoded into the link. Use this for a report, "+"write-up, or formatted notes the user wants to share as a link. Markdown only (HTML documents require the hosted embd server). Large documents may exceed the URL size limit and return an error.",inputSchema:G.object({content:G.string().describe("The Markdown source text."),theme:G.enum(E).optional().describe("Reading theme. Default: stage.")}),annotations:O},async(Q)=>UZ(Q,Z)),!_Z.includes("create_kpi"))$.registerTool("create_kpi",{title:"Create a shareable embd KPI/stat link",description:"Build a big-number KPI card (value + label, optional change indicator, caption and sparkline) and "+"return a self-contained embd.sh URL. No account or upload — the card is encoded into the link. "+'Values are pre-formatted strings (you format them, e.g. "$1.2M", "98%").',inputSchema:G.object({value:G.string().describe('The big value, pre-formatted (e.g. "$1.2M", "98%").'),label:G.string().describe('What it measures (e.g. "Monthly revenue").'),caption:G.string().optional().describe("Optional sub-line (context or timeframe)."),delta:G.object({value:G.string().describe('Displayed change, e.g. "12%" or "340".'),dir:G.enum(["up","down","flat"]).describe("Arrow direction."),good:G.boolean().optional().describe("Whether this direction reads as positive (drives color). Default: up=good.")}).optional().describe("Optional change indicator."),sparkline:G.array(G.number()).optional().describe("Optional trend series (numbers) drawn behind the value."),theme:G.enum(E).optional().describe("Reading theme. Default: stage.")}),annotations:O},async(Q)=>fZ(Q,Z));return $.registerTool("create_qr",{title:"Create a shareable embd QR-code link",description:"Generate a styled QR code for a URL or text and return a self-contained embd.sh URL that renders it. No account or upload. Supports an optional heading, caption, foreground/background hex colors, and a small center emoji icon.",inputSchema:G.object({content:G.string().describe("What the QR encodes (a URL, text, …)."),label:G.string().optional().describe("Optional heading above the code."),caption:G.string().optional().describe("Optional sub-line below it."),fg:G.string().optional().describe("Module (foreground) color as a 6-digit hex."),bg:G.string().optional().describe("Background color as a 6-digit hex."),icon:G.string().optional().describe("A small center emoji icon."),theme:G.enum(E).optional().describe("Reading theme. Default: stage.")}),annotations:O},async(Q)=>AZ(Q,Z)),$}import{createServer as hZ}from"node:http";import{Http2ServerRequest as YZ,constants as DZ}from"http2";import{Http2ServerRequest as I}from"http2";import{Readable as WZ}from"stream";import vZ from"crypto";var V=class extends Error{constructor(Z,$){super(Z,$);this.name="RequestError"}},NZ=(Z)=>{if(Z instanceof V)return Z;return new V(Z.message,{cause:Z})},TZ=global.Request,N=class extends TZ{constructor(Z,$){if(typeof Z==="object"&&_ in Z)Z=Z[_]();if(typeof $?.body?.getReader<"u")$.duplex??="half";super(Z,$)}},zZ=(Z)=>{let $=[],Q=Z.rawHeaders;for(let W=0;W<Q.length;W+=2){let{[W]:X,[W+1]:Y}=Q;if(X.charCodeAt(0)!==58)$.push([X,Y])}return new Headers($)},jZ=Symbol("wrapBodyStream"),PZ=(Z,$,Q,W,X)=>{let Y={method:Z,headers:Q,signal:X.signal};if(Z==="TRACE"){Y.method="GET";let j=new N($,Y);return Object.defineProperty(j,"method",{get(){return"TRACE"}}),j}if(!(Z==="GET"||Z==="HEAD"))if("rawBody"in W&&W.rawBody instanceof Buffer)Y.body=new ReadableStream({start(j){j.enqueue(W.rawBody),j.close()}});else if(W[jZ]){let j;Y.body=new ReadableStream({async pull(x){try{j||=WZ.toWeb(W).getReader();let{done:B,value:K}=await j.read();if(B)x.close();else x.enqueue(K)}catch(B){x.error(B)}}})}else Y.body=WZ.toWeb(W);return new N($,Y)},_=Symbol("getRequestCache"),xZ=Symbol("requestCache"),w=Symbol("incomingKey"),y=Symbol("urlKey"),OZ=Symbol("headersKey"),A=Symbol("abortControllerKey"),HZ=Symbol("getAbortController"),T={get method(){return this[w].method||"GET"},get url(){return this[y]},get headers(){return this[OZ]||=zZ(this[w])},[HZ](){return this[_](),this[A]},[_](){return this[A]||=new AbortController,this[xZ]||=PZ(this.method,this[y],this.headers,this[w],this[A])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach((Z)=>{Object.defineProperty(T,Z,{get(){return this[_]()[Z]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach((Z)=>{Object.defineProperty(T,Z,{value:function(){return this[_]()[Z]()}})});Object.defineProperty(T,Symbol.for("nodejs.util.inspect.custom"),{value:function(Z,$,Q){let W={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[xZ]};return`Request (lightweight) ${Q(W,{...$,depth:Z==null?null:Z-1})}`}});Object.setPrototypeOf(T,N.prototype);var kZ=(Z,$)=>{let Q=Object.create(T);Q[w]=Z;let W=Z.url||"";if(W[0]!=="/"&&(W.startsWith("http://")||W.startsWith("https://"))){if(Z instanceof I)throw new V("Absolute URL for :path is not allowed in HTTP/2");try{let x=new URL(W);Q[y]=x.href}catch(x){throw new V("Invalid absolute URL",{cause:x})}return Q}let X=(Z instanceof I?Z.authority:Z.headers.host)||$;if(!X)throw new V("Missing host header");let Y;if(Z instanceof I){if(Y=Z.scheme,!(Y==="http"||Y==="https"))throw new V("Unsupported scheme")}else Y=Z.socket&&Z.socket.encrypted?"https":"http";let j=new URL(`${Y}://${X}${W}`);if(j.hostname.length!==X.length&&j.hostname!==X.replace(/:\d+$/,""))throw new V("Invalid host header");return Q[y]=j.href,Q},R=Symbol("responseCache"),f=Symbol("getResponseCache"),L=Symbol("cache"),p=global.Response,D=class Z{#$;#Z;[f](){return delete this[L],this[R]||=new p(this.#$,this.#Z)}constructor($,Q){let W;if(this.#$=$,Q instanceof Z){let X=Q[R];if(X){this.#Z=X,this[f]();return}else this.#Z=Q.#Z,W=new Headers(Q.#Z.headers)}else this.#Z=Q;if(typeof $==="string"||typeof $?.getReader<"u"||$ instanceof Blob||$ instanceof Uint8Array)this[L]=[Q?.status||200,$,W||Q?.headers]}get headers(){let $=this[L];if($){if(!($[2]instanceof Headers))$[2]=new Headers($[2]||{"content-type":"text/plain; charset=UTF-8"});return $[2]}return this[f]().headers}get status(){return this[L]?.[0]??this[f]().status}get ok(){let $=this.status;return $>=200&&$<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach((Z)=>{Object.defineProperty(D.prototype,Z,{get(){return this[f]()[Z]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach((Z)=>{Object.defineProperty(D.prototype,Z,{value:function(){return this[f]()[Z]()}})});Object.defineProperty(D.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(Z,$,Q){let W={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[R]};return`Response (lightweight) ${Q(W,{...$,depth:Z==null?null:Z-1})}`}});Object.setPrototypeOf(D,p);Object.setPrototypeOf(D.prototype,p.prototype);async function wZ(Z){return Promise.race([Z,Promise.resolve().then(()=>Promise.resolve(void 0))])}function GZ(Z,$,Q){let W=(x)=>{Z.cancel(x).catch(()=>{})};return $.on("close",W),$.on("error",W),(Q??Z.read()).then(j,X),Z.closed.finally(()=>{$.off("close",W),$.off("error",W)});function X(x){if(x)$.destroy(x)}function Y(){Z.read().then(j,X)}function j({done:x,value:B}){try{if(x)$.end();else if(!$.write(B))$.once("drain",Y);else return Z.read().then(j,X)}catch(K){X(K)}}}function yZ(Z,$){if(Z.locked)throw TypeError("ReadableStream is locked.");else if($.destroyed)return;return GZ(Z.getReader(),$)}var h=(Z)=>{let $={};if(!(Z instanceof Headers))Z=new Headers(Z??void 0);let Q=[];for(let[W,X]of Z)if(W==="set-cookie")Q.push(X);else $[W]=X;if(Q.length>0)$["set-cookie"]=Q;return $["content-type"]??="text/plain; charset=UTF-8",$},CZ="x-hono-already-sent";if(typeof global.crypto>"u")global.crypto=vZ;var u=Symbol("outgoingEnded"),XZ=Symbol("incomingDraining"),SZ=500,EZ=67108864,b=(Z)=>{let $=Z;if(Z.destroyed||$[XZ])return;if($[XZ]=!0,Z instanceof YZ){try{Z.stream?.close?.(DZ.NGHTTP2_NO_ERROR)}catch{}return}let Q=0,W=()=>{clearTimeout(Y),Z.off("data",j),Z.off("end",W),Z.off("error",W)},X=()=>{W();let x=Z.socket;if(x&&!x.destroyed)x.destroySoon()},Y=setTimeout(X,SZ);Y.unref?.();let j=(x)=>{if(Q+=x.length,Q>EZ)X()};Z.on("data",j),Z.on("end",W),Z.on("error",W),Z.resume()},IZ=()=>new Response(null,{status:400}),BZ=(Z)=>new Response(null,{status:Z instanceof Error&&(Z.name==="TimeoutError"||Z.constructor.name==="TimeoutError")?504:500}),q=(Z,$)=>{let Q=Z instanceof Error?Z:Error("unknown error",{cause:Z});if(Q.code==="ERR_STREAM_PREMATURE_CLOSE")console.info("The user aborted a request.");else{if(console.error(Z),!$.headersSent)$.writeHead(500,{"Content-Type":"text/plain"});$.end(`Error: ${Q.message}`),$.destroy(Q)}},KZ=(Z)=>{if("flushHeaders"in Z&&Z.writable)Z.flushHeaders()},FZ=async(Z,$)=>{let[Q,W,X]=Z[L],Y=!1;if(!X)X={"content-type":"text/plain; charset=UTF-8"};else if(X instanceof Headers)Y=X.has("content-length"),X=h(X);else if(Array.isArray(X)){let j=new Headers(X);Y=j.has("content-length"),X=h(j)}else for(let j in X)if(j.length===14&&j.toLowerCase()==="content-length"){Y=!0;break}if(!Y){if(typeof W==="string")X["Content-Length"]=Buffer.byteLength(W);else if(W instanceof Uint8Array)X["Content-Length"]=W.byteLength;else if(W instanceof Blob)X["Content-Length"]=W.size}if($.writeHead(Q,X),typeof W==="string"||W instanceof Uint8Array)$.end(W);else if(W instanceof Blob)$.end(new Uint8Array(await W.arrayBuffer()));else KZ($),await yZ(W,$)?.catch((j)=>q(j,$));$[u]?.()},bZ=(Z)=>typeof Z.then==="function",RZ=async(Z,$,Q={})=>{if(bZ(Z))if(Q.errorHandler)try{Z=await Z}catch(X){let Y=await Q.errorHandler(X);if(!Y)return;Z=Y}else Z=await Z.catch(BZ);if(L in Z)return FZ(Z,$);let W=h(Z.headers);if(Z.body){let X=Z.body.getReader(),Y=[],j=!1,x=void 0;if(W["transfer-encoding"]!=="chunked"){let B=2;for(let K=0;K<B;K++){x||=X.read();let M=await wZ(x).catch((U)=>{console.error(U),j=!0});if(!M){if(K===1){await new Promise((U)=>setTimeout(U)),B=3;continue}break}if(x=void 0,M.value)Y.push(M.value);if(M.done){j=!0;break}}if(j&&!("content-length"in W))W["content-length"]=Y.reduce((K,M)=>K+M.length,0)}if($.writeHead(Z.status,W),Y.forEach((B)=>{$.write(B)}),j)$.end();else{if(Y.length===0)KZ($);await GZ(X,$,x)}}else if(W[CZ]);else $.writeHead(Z.status,W),$.end();$[u]?.()},m=(Z,$={})=>{let Q=$.autoCleanupIncoming??!0;if($.overrideGlobalObjects!==!1&&global.Request!==N)Object.defineProperty(global,"Request",{value:N}),Object.defineProperty(global,"Response",{value:D});return async(W,X)=>{let Y,j;try{j=kZ(W,$.hostname);let x=!Q||W.method==="GET"||W.method==="HEAD";if(!x){if(W[jZ]=!0,W.on("end",()=>{x=!0}),W instanceof YZ)X[u]=()=>{if(!x)setTimeout(()=>{if(!x)setTimeout(()=>{b(W)})})};X.on("finish",()=>{if(!x)b(W)})}if(X.on("close",()=>{if(j[A]){if(W.errored)j[A].abort(W.errored.toString());else if(!X.writableFinished)j[A].abort("Client connection prematurely closed.")}if(!x)setTimeout(()=>{if(!x)setTimeout(()=>{b(W)})})}),Y=Z(j,{incoming:W,outgoing:X}),L in Y)return FZ(Y,X)}catch(x){if(!Y)if($.errorHandler){if(Y=await $.errorHandler(j?x:NZ(x)),!Y)return}else if(!j)Y=IZ();else Y=BZ(x);else return q(x,X)}try{return await RZ(Y,X,$)}catch(x){return q(x,X)}}};class d{constructor(Z={}){this._started=!1,this._hasHandledRequest=!1,this._streamMapping=new Map,this._requestToStreamMapping=new Map,this._requestResponseMap=new Map,this._initialized=!1,this._enableJsonResponse=!1,this._standaloneSseStreamId="_GET_stream",this.sessionIdGenerator=Z.sessionIdGenerator,this._enableJsonResponse=Z.enableJsonResponse??!1,this._eventStore=Z.eventStore,this._onsessioninitialized=Z.onsessioninitialized,this._onsessionclosed=Z.onsessionclosed,this._allowedHosts=Z.allowedHosts,this._allowedOrigins=Z.allowedOrigins,this._enableDnsRebindingProtection=Z.enableDnsRebindingProtection??!1,this._retryInterval=Z.retryInterval}async start(){if(this._started)throw Error("Transport already started");this._started=!0}createJsonErrorResponse(Z,$,Q,W){let X={code:$,message:Q};if(W?.data!==void 0)X.data=W.data;return new Response(JSON.stringify({jsonrpc:"2.0",error:X,id:null}),{status:Z,headers:{"Content-Type":"application/json",...W?.headers}})}validateRequestHeaders(Z){if(!this._enableDnsRebindingProtection)return;if(this._allowedHosts&&this._allowedHosts.length>0){let $=Z.headers.get("host");if(!$||!this._allowedHosts.includes($)){let Q=`Invalid Host header: ${$}`;return this.onerror?.(Error(Q)),this.createJsonErrorResponse(403,-32000,Q)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let $=Z.headers.get("origin");if($&&!this._allowedOrigins.includes($)){let Q=`Invalid Origin header: ${$}`;return this.onerror?.(Error(Q)),this.createJsonErrorResponse(403,-32000,Q)}}return}async handleRequest(Z,$){if(!this.sessionIdGenerator&&this._hasHandledRequest)throw Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let Q=this.validateRequestHeaders(Z);if(Q)return Q;switch(Z.method){case"POST":return this.handlePostRequest(Z,$);case"GET":return this.handleGetRequest(Z);case"DELETE":return this.handleDeleteRequest(Z);default:return this.handleUnsupportedRequest()}}async writePrimingEvent(Z,$,Q,W){if(!this._eventStore)return;if(W<"2025-11-25")return;let X=await this._eventStore.storeEvent(Q,{}),Y=`id: ${X}
1
+ import{q as o,r,s as e,t as ZZ,y as $Z}from"./bin-nd2pmy0p.js";import{D as G,E as MZ,F as C,G as z,H as v,I as S,J as c,K as l,L as s}from"./bin-wfyqs0fh.js";var VZ=["line","area","bar","stacked-bar","stacked-area","bar-horizontal","scatter","pie","donut","heatmap","radar"],E=["stage","slate","dusk","paper","mist","sepia"];function H(Z,$){return{content:[{type:"text",text:Z}],structuredContent:{url:Z,kind:$}}}function k(Z){return{content:[{type:"text",text:Z instanceof Error?Z.message:String(Z)}],isError:!0}}async function LZ(Z,$={}){try{let Q=await o(Z.data,{origin:$.origin,kind:Z.kind,title:Z.title,themeId:Z.theme});return H(Q,"chart")}catch(Q){return k(Q)}}async function UZ(Z,$={}){try{let Q=await r(Z.content,{origin:$.origin,theme:Z.theme});return H(Q,"markdown")}catch(Q){return k(Q)}}async function fZ(Z,$={}){try{let Q=await e(Z,{origin:$.origin});return H(Q,"kpi")}catch(Q){return k(Q)}}async function AZ(Z,$={}){try{let Q=await ZZ(Z,{origin:$.origin});return H(Q,"qr")}catch(Q){return k(Q)}}var O={readOnlyHint:!0,destructiveHint:!1,openWorldHint:!1},_Z=["create_kpi"];function QZ(Z={}){let $=new s({name:"embd",version:$Z});if($.registerTool("create_chart",{title:"Create a shareable embd chart link",description:"Turn tabular data into a beautiful, shareable chart and return a self-contained embd.sh URL. "+"No account, no upload, no API call — the chart data is encoded directly into the returned link, "+"so it works anywhere and needs no backend. Use this when you have data (CSV text or an array of flat JSON row objects) and the user wants a chart they can link to, share, or embed. "+"Column roles are inferred automatically (first non-numeric column → X axis, numeric columns → "+"series). Because the data rides in the URL, there is a size limit — if the data is too large the "+"tool returns an error asking you to reduce it; very large datasets need the hosted embd server instead.",inputSchema:G.object({data:G.union([G.string(),G.array(G.record(G.string(),G.unknown()))]).describe('CSV text (first row = headers) or an array of flat row objects with identical keys, e.g. [{"month":"Jan","sales":120}, ...].'),kind:G.enum(VZ).optional().describe("Chart type. Default: inferred from the data (usually line or bar)."),title:G.string().optional().describe("Chart title."),theme:G.string().optional().describe("Theme id (e.g. aurora-dark, aurora-light). Default: aurora-dark.")}),annotations:O},async(Q)=>LZ(Q,Z)),$.registerTool("create_doc",{title:"Create a shareable embd markdown doc link",description:"Render Markdown into a clean, shareable page and return a self-contained embd.sh URL. "+"No account and no upload — the Markdown source is encoded into the link. Use this for a report, "+"write-up, or formatted notes the user wants to share as a link. Markdown only (HTML documents require the hosted embd server). Large documents may exceed the URL size limit and return an error.",inputSchema:G.object({content:G.string().describe("The Markdown source text."),theme:G.enum(E).optional().describe("Reading theme. Default: stage.")}),annotations:O},async(Q)=>UZ(Q,Z)),!_Z.includes("create_kpi"))$.registerTool("create_kpi",{title:"Create a shareable embd KPI/stat link",description:"Build a big-number KPI card (value + label, optional change indicator, caption and sparkline) and "+"return a self-contained embd.sh URL. No account or upload — the card is encoded into the link. "+'Values are pre-formatted strings (you format them, e.g. "$1.2M", "98%").',inputSchema:G.object({value:G.string().describe('The big value, pre-formatted (e.g. "$1.2M", "98%").'),label:G.string().describe('What it measures (e.g. "Monthly revenue").'),caption:G.string().optional().describe("Optional sub-line (context or timeframe)."),delta:G.object({value:G.string().describe('Displayed change, e.g. "12%" or "340".'),dir:G.enum(["up","down","flat"]).describe("Arrow direction."),good:G.boolean().optional().describe("Whether this direction reads as positive (drives color). Default: up=good.")}).optional().describe("Optional change indicator."),sparkline:G.array(G.number()).optional().describe("Optional trend series (numbers) drawn behind the value."),theme:G.enum(E).optional().describe("Reading theme. Default: stage.")}),annotations:O},async(Q)=>fZ(Q,Z));return $.registerTool("create_qr",{title:"Create a shareable embd QR-code link",description:"Generate a styled QR code for a URL or text and return a self-contained embd.sh URL that renders it. No account or upload. Supports an optional heading, caption, foreground/background hex colors, and a small center emoji icon.",inputSchema:G.object({content:G.string().describe("What the QR encodes (a URL, text, …)."),label:G.string().optional().describe("Optional heading above the code."),caption:G.string().optional().describe("Optional sub-line below it."),fg:G.string().optional().describe("Module (foreground) color as a 6-digit hex."),bg:G.string().optional().describe("Background color as a 6-digit hex."),icon:G.string().optional().describe("A small center emoji icon."),theme:G.enum(E).optional().describe("Reading theme. Default: stage.")}),annotations:O},async(Q)=>AZ(Q,Z)),$}import{createServer as hZ}from"node:http";import{Http2ServerRequest as YZ,constants as DZ}from"http2";import{Http2ServerRequest as I}from"http2";import{Readable as WZ}from"stream";import vZ from"crypto";var V=class extends Error{constructor(Z,$){super(Z,$);this.name="RequestError"}},NZ=(Z)=>{if(Z instanceof V)return Z;return new V(Z.message,{cause:Z})},TZ=global.Request,N=class extends TZ{constructor(Z,$){if(typeof Z==="object"&&_ in Z)Z=Z[_]();if(typeof $?.body?.getReader<"u")$.duplex??="half";super(Z,$)}},zZ=(Z)=>{let $=[],Q=Z.rawHeaders;for(let W=0;W<Q.length;W+=2){let{[W]:X,[W+1]:Y}=Q;if(X.charCodeAt(0)!==58)$.push([X,Y])}return new Headers($)},jZ=Symbol("wrapBodyStream"),PZ=(Z,$,Q,W,X)=>{let Y={method:Z,headers:Q,signal:X.signal};if(Z==="TRACE"){Y.method="GET";let j=new N($,Y);return Object.defineProperty(j,"method",{get(){return"TRACE"}}),j}if(!(Z==="GET"||Z==="HEAD"))if("rawBody"in W&&W.rawBody instanceof Buffer)Y.body=new ReadableStream({start(j){j.enqueue(W.rawBody),j.close()}});else if(W[jZ]){let j;Y.body=new ReadableStream({async pull(x){try{j||=WZ.toWeb(W).getReader();let{done:B,value:K}=await j.read();if(B)x.close();else x.enqueue(K)}catch(B){x.error(B)}}})}else Y.body=WZ.toWeb(W);return new N($,Y)},_=Symbol("getRequestCache"),xZ=Symbol("requestCache"),w=Symbol("incomingKey"),y=Symbol("urlKey"),OZ=Symbol("headersKey"),A=Symbol("abortControllerKey"),HZ=Symbol("getAbortController"),T={get method(){return this[w].method||"GET"},get url(){return this[y]},get headers(){return this[OZ]||=zZ(this[w])},[HZ](){return this[_](),this[A]},[_](){return this[A]||=new AbortController,this[xZ]||=PZ(this.method,this[y],this.headers,this[w],this[A])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach((Z)=>{Object.defineProperty(T,Z,{get(){return this[_]()[Z]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach((Z)=>{Object.defineProperty(T,Z,{value:function(){return this[_]()[Z]()}})});Object.defineProperty(T,Symbol.for("nodejs.util.inspect.custom"),{value:function(Z,$,Q){let W={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[xZ]};return`Request (lightweight) ${Q(W,{...$,depth:Z==null?null:Z-1})}`}});Object.setPrototypeOf(T,N.prototype);var kZ=(Z,$)=>{let Q=Object.create(T);Q[w]=Z;let W=Z.url||"";if(W[0]!=="/"&&(W.startsWith("http://")||W.startsWith("https://"))){if(Z instanceof I)throw new V("Absolute URL for :path is not allowed in HTTP/2");try{let x=new URL(W);Q[y]=x.href}catch(x){throw new V("Invalid absolute URL",{cause:x})}return Q}let X=(Z instanceof I?Z.authority:Z.headers.host)||$;if(!X)throw new V("Missing host header");let Y;if(Z instanceof I){if(Y=Z.scheme,!(Y==="http"||Y==="https"))throw new V("Unsupported scheme")}else Y=Z.socket&&Z.socket.encrypted?"https":"http";let j=new URL(`${Y}://${X}${W}`);if(j.hostname.length!==X.length&&j.hostname!==X.replace(/:\d+$/,""))throw new V("Invalid host header");return Q[y]=j.href,Q},R=Symbol("responseCache"),f=Symbol("getResponseCache"),L=Symbol("cache"),p=global.Response,D=class Z{#$;#Z;[f](){return delete this[L],this[R]||=new p(this.#$,this.#Z)}constructor($,Q){let W;if(this.#$=$,Q instanceof Z){let X=Q[R];if(X){this.#Z=X,this[f]();return}else this.#Z=Q.#Z,W=new Headers(Q.#Z.headers)}else this.#Z=Q;if(typeof $==="string"||typeof $?.getReader<"u"||$ instanceof Blob||$ instanceof Uint8Array)this[L]=[Q?.status||200,$,W||Q?.headers]}get headers(){let $=this[L];if($){if(!($[2]instanceof Headers))$[2]=new Headers($[2]||{"content-type":"text/plain; charset=UTF-8"});return $[2]}return this[f]().headers}get status(){return this[L]?.[0]??this[f]().status}get ok(){let $=this.status;return $>=200&&$<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach((Z)=>{Object.defineProperty(D.prototype,Z,{get(){return this[f]()[Z]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach((Z)=>{Object.defineProperty(D.prototype,Z,{value:function(){return this[f]()[Z]()}})});Object.defineProperty(D.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(Z,$,Q){let W={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[R]};return`Response (lightweight) ${Q(W,{...$,depth:Z==null?null:Z-1})}`}});Object.setPrototypeOf(D,p);Object.setPrototypeOf(D.prototype,p.prototype);async function wZ(Z){return Promise.race([Z,Promise.resolve().then(()=>Promise.resolve(void 0))])}function GZ(Z,$,Q){let W=(x)=>{Z.cancel(x).catch(()=>{})};return $.on("close",W),$.on("error",W),(Q??Z.read()).then(j,X),Z.closed.finally(()=>{$.off("close",W),$.off("error",W)});function X(x){if(x)$.destroy(x)}function Y(){Z.read().then(j,X)}function j({done:x,value:B}){try{if(x)$.end();else if(!$.write(B))$.once("drain",Y);else return Z.read().then(j,X)}catch(K){X(K)}}}function yZ(Z,$){if(Z.locked)throw TypeError("ReadableStream is locked.");else if($.destroyed)return;return GZ(Z.getReader(),$)}var h=(Z)=>{let $={};if(!(Z instanceof Headers))Z=new Headers(Z??void 0);let Q=[];for(let[W,X]of Z)if(W==="set-cookie")Q.push(X);else $[W]=X;if(Q.length>0)$["set-cookie"]=Q;return $["content-type"]??="text/plain; charset=UTF-8",$},CZ="x-hono-already-sent";if(typeof global.crypto>"u")global.crypto=vZ;var u=Symbol("outgoingEnded"),XZ=Symbol("incomingDraining"),SZ=500,EZ=67108864,b=(Z)=>{let $=Z;if(Z.destroyed||$[XZ])return;if($[XZ]=!0,Z instanceof YZ){try{Z.stream?.close?.(DZ.NGHTTP2_NO_ERROR)}catch{}return}let Q=0,W=()=>{clearTimeout(Y),Z.off("data",j),Z.off("end",W),Z.off("error",W)},X=()=>{W();let x=Z.socket;if(x&&!x.destroyed)x.destroySoon()},Y=setTimeout(X,SZ);Y.unref?.();let j=(x)=>{if(Q+=x.length,Q>EZ)X()};Z.on("data",j),Z.on("end",W),Z.on("error",W),Z.resume()},IZ=()=>new Response(null,{status:400}),BZ=(Z)=>new Response(null,{status:Z instanceof Error&&(Z.name==="TimeoutError"||Z.constructor.name==="TimeoutError")?504:500}),q=(Z,$)=>{let Q=Z instanceof Error?Z:Error("unknown error",{cause:Z});if(Q.code==="ERR_STREAM_PREMATURE_CLOSE")console.info("The user aborted a request.");else{if(console.error(Z),!$.headersSent)$.writeHead(500,{"Content-Type":"text/plain"});$.end(`Error: ${Q.message}`),$.destroy(Q)}},KZ=(Z)=>{if("flushHeaders"in Z&&Z.writable)Z.flushHeaders()},FZ=async(Z,$)=>{let[Q,W,X]=Z[L],Y=!1;if(!X)X={"content-type":"text/plain; charset=UTF-8"};else if(X instanceof Headers)Y=X.has("content-length"),X=h(X);else if(Array.isArray(X)){let j=new Headers(X);Y=j.has("content-length"),X=h(j)}else for(let j in X)if(j.length===14&&j.toLowerCase()==="content-length"){Y=!0;break}if(!Y){if(typeof W==="string")X["Content-Length"]=Buffer.byteLength(W);else if(W instanceof Uint8Array)X["Content-Length"]=W.byteLength;else if(W instanceof Blob)X["Content-Length"]=W.size}if($.writeHead(Q,X),typeof W==="string"||W instanceof Uint8Array)$.end(W);else if(W instanceof Blob)$.end(new Uint8Array(await W.arrayBuffer()));else KZ($),await yZ(W,$)?.catch((j)=>q(j,$));$[u]?.()},bZ=(Z)=>typeof Z.then==="function",RZ=async(Z,$,Q={})=>{if(bZ(Z))if(Q.errorHandler)try{Z=await Z}catch(X){let Y=await Q.errorHandler(X);if(!Y)return;Z=Y}else Z=await Z.catch(BZ);if(L in Z)return FZ(Z,$);let W=h(Z.headers);if(Z.body){let X=Z.body.getReader(),Y=[],j=!1,x=void 0;if(W["transfer-encoding"]!=="chunked"){let B=2;for(let K=0;K<B;K++){x||=X.read();let M=await wZ(x).catch((U)=>{console.error(U),j=!0});if(!M){if(K===1){await new Promise((U)=>setTimeout(U)),B=3;continue}break}if(x=void 0,M.value)Y.push(M.value);if(M.done){j=!0;break}}if(j&&!("content-length"in W))W["content-length"]=Y.reduce((K,M)=>K+M.length,0)}if($.writeHead(Z.status,W),Y.forEach((B)=>{$.write(B)}),j)$.end();else{if(Y.length===0)KZ($);await GZ(X,$,x)}}else if(W[CZ]);else $.writeHead(Z.status,W),$.end();$[u]?.()},m=(Z,$={})=>{let Q=$.autoCleanupIncoming??!0;if($.overrideGlobalObjects!==!1&&global.Request!==N)Object.defineProperty(global,"Request",{value:N}),Object.defineProperty(global,"Response",{value:D});return async(W,X)=>{let Y,j;try{j=kZ(W,$.hostname);let x=!Q||W.method==="GET"||W.method==="HEAD";if(!x){if(W[jZ]=!0,W.on("end",()=>{x=!0}),W instanceof YZ)X[u]=()=>{if(!x)setTimeout(()=>{if(!x)setTimeout(()=>{b(W)})})};X.on("finish",()=>{if(!x)b(W)})}if(X.on("close",()=>{if(j[A]){if(W.errored)j[A].abort(W.errored.toString());else if(!X.writableFinished)j[A].abort("Client connection prematurely closed.")}if(!x)setTimeout(()=>{if(!x)setTimeout(()=>{b(W)})})}),Y=Z(j,{incoming:W,outgoing:X}),L in Y)return FZ(Y,X)}catch(x){if(!Y)if($.errorHandler){if(Y=await $.errorHandler(j?x:NZ(x)),!Y)return}else if(!j)Y=IZ();else Y=BZ(x);else return q(x,X)}try{return await RZ(Y,X,$)}catch(x){return q(x,X)}}};class d{constructor(Z={}){this._started=!1,this._hasHandledRequest=!1,this._streamMapping=new Map,this._requestToStreamMapping=new Map,this._requestResponseMap=new Map,this._initialized=!1,this._enableJsonResponse=!1,this._standaloneSseStreamId="_GET_stream",this.sessionIdGenerator=Z.sessionIdGenerator,this._enableJsonResponse=Z.enableJsonResponse??!1,this._eventStore=Z.eventStore,this._onsessioninitialized=Z.onsessioninitialized,this._onsessionclosed=Z.onsessionclosed,this._allowedHosts=Z.allowedHosts,this._allowedOrigins=Z.allowedOrigins,this._enableDnsRebindingProtection=Z.enableDnsRebindingProtection??!1,this._retryInterval=Z.retryInterval}async start(){if(this._started)throw Error("Transport already started");this._started=!0}createJsonErrorResponse(Z,$,Q,W){let X={code:$,message:Q};if(W?.data!==void 0)X.data=W.data;return new Response(JSON.stringify({jsonrpc:"2.0",error:X,id:null}),{status:Z,headers:{"Content-Type":"application/json",...W?.headers}})}validateRequestHeaders(Z){if(!this._enableDnsRebindingProtection)return;if(this._allowedHosts&&this._allowedHosts.length>0){let $=Z.headers.get("host");if(!$||!this._allowedHosts.includes($)){let Q=`Invalid Host header: ${$}`;return this.onerror?.(Error(Q)),this.createJsonErrorResponse(403,-32000,Q)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let $=Z.headers.get("origin");if($&&!this._allowedOrigins.includes($)){let Q=`Invalid Origin header: ${$}`;return this.onerror?.(Error(Q)),this.createJsonErrorResponse(403,-32000,Q)}}return}async handleRequest(Z,$){if(!this.sessionIdGenerator&&this._hasHandledRequest)throw Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let Q=this.validateRequestHeaders(Z);if(Q)return Q;switch(Z.method){case"POST":return this.handlePostRequest(Z,$);case"GET":return this.handleGetRequest(Z);case"DELETE":return this.handleDeleteRequest(Z);default:return this.handleUnsupportedRequest()}}async writePrimingEvent(Z,$,Q,W){if(!this._eventStore)return;if(W<"2025-11-25")return;let X=await this._eventStore.storeEvent(Q,{}),Y=`id: ${X}
2
2
  data:
3
3
 
4
4
  `;if(this._retryInterval!==void 0)Y=`id: ${X}
@@ -1,4 +1,4 @@
1
- import{J as D}from"./bin-y6yfg1je.js";import F from"node:process";class A{append(b){this._buffer=this._buffer?Buffer.concat([this._buffer,b]):b}readMessage(){if(!this._buffer)return null;let b=this._buffer.indexOf(`
1
+ import{J as D}from"./bin-wfyqs0fh.js";import F from"node:process";class A{append(b){this._buffer=this._buffer?Buffer.concat([this._buffer,b]):b}readMessage(){if(!this._buffer)return null;let b=this._buffer.indexOf(`
2
2
  `);if(b===-1)return null;let q=this._buffer.toString("utf8",0,b).replace(/\r$/,"");return this._buffer=this._buffer.subarray(b+1),G(q)}clear(){this._buffer=void 0}}function G(b){return D.parse(JSON.parse(b))}function E(b){return JSON.stringify(b)+`
3
3
  `}class H{constructor(b=F.stdin,q=F.stdout){this._stdin=b,this._stdout=q,this._readBuffer=new A,this._started=!1,this._ondata=(w)=>{this._readBuffer.append(w),this.processReadBuffer()},this._onerror=(w)=>{this.onerror?.(w)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let b=this._readBuffer.readMessage();if(b===null)break;this.onmessage?.(b)}catch(b){this.onerror?.(b)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(b){return new Promise((q)=>{let w=E(b);if(this._stdout.write(w))q();else this._stdout.once("drain",q)})}}
4
4
  export{H as a};
@@ -1,4 +1,4 @@
1
- import{A as C2,B as N2,C as R2,D as C,L as I2,M as O2}from"./bin-y6yfg1je.js";var $2=N2((h0,g0)=>{(function(Z,$){if(typeof define==="function"&&define.amd)define([],$);else if(typeof g0==="object"&&typeof h0<"u")g0.exports=$();else Z.Papa=$()})(h0,function Z(){var $=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof $<"u")return $;return{}}();function U(){var Y=$.URL||$.webkitURL||null,J=Z.toString();return G.BLOB_URL||(G.BLOB_URL=Y.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",J,")();"],{type:"text/javascript"})))}var V=!$.document&&!!$.postMessage,W=$.IS_PAPA_WORKER||!1,_={},I=0,G={};if(G.parse=Y0,G.unparse=v,G.RECORD_SEP=String.fromCharCode(30),G.UNIT_SEP=String.fromCharCode(31),G.BYTE_ORDER_MARK="\uFEFF",G.BAD_DELIMITERS=["\r",`
1
+ import{A as C2,B as N2,C as R2,D as C,L as I2,M as O2}from"./bin-wfyqs0fh.js";var $2=N2((h0,g0)=>{(function(Z,$){if(typeof define==="function"&&define.amd)define([],$);else if(typeof g0==="object"&&typeof h0<"u")g0.exports=$();else Z.Papa=$()})(h0,function Z(){var $=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof $<"u")return $;return{}}();function U(){var Y=$.URL||$.webkitURL||null,J=Z.toString();return G.BLOB_URL||(G.BLOB_URL=Y.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",J,")();"],{type:"text/javascript"})))}var V=!$.document&&!!$.postMessage,W=$.IS_PAPA_WORKER||!1,_={},I=0,G={};if(G.parse=Y0,G.unparse=v,G.RECORD_SEP=String.fromCharCode(30),G.UNIT_SEP=String.fromCharCode(31),G.BYTE_ORDER_MARK="\uFEFF",G.BAD_DELIMITERS=["\r",`
2
2
  `,'"',G.BYTE_ORDER_MARK],G.WORKERS_SUPPORTED=!V&&!!$.Worker,G.NODE_STREAM_INPUT=1,G.LocalChunkSize=10485760,G.RemoteChunkSize=5242880,G.DefaultDelimiter=",",G.Parser=W0,G.ParserHandle=i,G.NetworkStreamer=m,G.FileStreamer=a,G.StringStreamer=t,G.ReadableStreamStreamer=$0,typeof PAPA_BROWSER_CONTEXT>"u")G.DuplexStreamStreamer=N;if($.jQuery){var f=$.jQuery;f.fn.parse=function(Y){var J=Y.config||{},X=[];return this.each(function(K){var F=f(this).prop("tagName").toUpperCase()==="INPUT"&&f(this).attr("type").toLowerCase()==="file"&&$.FileReader;if(!F||!this.files||this.files.length===0)return!0;for(var E=0;E<this.files.length;E++)X.push({file:this.files[E],inputElem:this,instanceConfig:f.extend({},J)})}),M(),this;function M(){if(X.length===0){if(S(Y.complete))Y.complete();return}var K=X[0];if(S(Y.before)){var F=Y.before(K.file,K.inputElem);if(typeof F==="object"){if(F.action==="abort"){Q("AbortError",K.file,K.inputElem,F.reason);return}else if(F.action==="skip"){L();return}else if(typeof F.config==="object")K.instanceConfig=f.extend(K.instanceConfig,F.config)}else if(F==="skip"){L();return}}var E=K.instanceConfig.complete;K.instanceConfig.complete=function(x){if(S(E))E(x,K.file,K.inputElem);L()},G.parse(K.file,K.instanceConfig)}function Q(K,F,E,x){if(S(Y.error))Y.error({name:K},F,E,x)}function L(){X.splice(0,1),M()}}}if(W)$.onmessage=j2;function e(Y){if(Y.charCodeAt(0)===65279)return Y.slice(1);return Y}function Y0(Y,J){J=J||{};var X=J.dynamicTyping||!1;if(S(X))J.dynamicTypingFunction=X,X={};if(J.dynamicTyping=X,J.transform=S(J.transform)?J.transform:!1,J.worker&&G.WORKERS_SUPPORTED){var M=D0();M.userStep=J.step,M.userChunk=J.chunk,M.userComplete=J.complete,M.userError=J.error,J.step=S(J.step),J.chunk=S(J.chunk),J.complete=S(J.complete),J.error=S(J.error),delete J.worker,M.postMessage({input:Y,config:J,workerId:M.id});return}var Q=null;if(Y===G.NODE_STREAM_INPUT&&typeof PAPA_BROWSER_CONTEXT>"u")return Q=new N(J),Q.getStream();else if(typeof Y==="string")if(Y=e(Y),J.download)Q=new m(J);else Q=new t(J);else if(Y.readable===!0&&S(Y.read)&&S(Y.on))Q=new $0(J);else if($.File&&Y instanceof File||Y instanceof Object)Q=new a(J);return Q.stream(Y)}function v(Y,J){var X=!1,M=!0,Q=",",L=`\r
3
3
  `,K='"',F=K+K,E=!1,x=null,h=!1;r();var O=new RegExp(J0(K),"g");if(typeof Y==="string")Y=JSON.parse(Y);if(Array.isArray(Y)){if(!Y.length||Array.isArray(Y[0]))return B(null,Y,E);else if(typeof Y[0]==="object")return B(x||Object.keys(Y[0]),Y,E)}else if(typeof Y==="object"){if(typeof Y.data==="string")Y.data=JSON.parse(Y.data);if(Array.isArray(Y.data)){if(!Y.fields)Y.fields=Y.meta&&Y.meta.fields||x;if(!Y.fields)Y.fields=Array.isArray(Y.data[0])?Y.fields:typeof Y.data[0]==="object"?Object.keys(Y.data[0]):[];if(!Array.isArray(Y.data[0])&&typeof Y.data[0]!=="object")Y.data=[Y.data]}return B(Y.fields||[],Y.data||[],E)}throw Error("Unable to serialize unrecognized input");function r(){if(typeof J!=="object")return;if(typeof J.delimiter==="string"&&!G.BAD_DELIMITERS.filter(function(A){return J.delimiter.indexOf(A)!==-1}).length)Q=J.delimiter;if(typeof J.quotes==="boolean"||typeof J.quotes==="function"||Array.isArray(J.quotes))X=J.quotes;if(typeof J.skipEmptyLines==="boolean"||typeof J.skipEmptyLines==="string")E=J.skipEmptyLines;if(typeof J.newline==="string")L=J.newline;if(typeof J.quoteChar==="string")K=J.quoteChar,F=K+K;if(typeof J.header==="boolean")M=J.header;if(Array.isArray(J.columns)){if(J.columns.length===0)throw Error("Option columns is empty");x=J.columns}if(J.escapeChar!==void 0)F=J.escapeChar+K;if(J.escapeFormulae instanceof RegExp)h=J.escapeFormulae;else if(typeof J.escapeFormulae==="boolean"&&J.escapeFormulae)h=/^[=+\-@\t\r].*$/}function B(A,R,b){var p="";if(typeof A==="string")A=JSON.parse(A);if(typeof R==="string")R=JSON.parse(R);var g=Array.isArray(A)&&A.length>0,u=!Array.isArray(R[0]);if(g&&M){for(var s=0;s<A.length;s++){if(s>0)p+=Q;p+=j(A[s],s)}if(R.length>0)p+=L}for(var q=0;q<R.length;q++){var G0=g?A.length:R[q].length,Z0=!1,z=g?Object.keys(R[q]).length===0:R[q].length===0;if(b&&!g)Z0=b==="greedy"?R[q].join("").trim()==="":R[q].length===1&&R[q][0].length===0;if(b==="greedy"&&g){var H=[];for(var D=0;D<G0;D++){var k=u?A[D]:D;H.push(R[q][k])}Z0=H.join("").trim()===""}if(!Z0){for(var P=0;P<G0;P++){if(P>0&&!z)p+=Q;var y=g&&u?A[P]:P;p+=j(R[q][y],P)}if(q<R.length-1&&(!b||G0>0&&!z))p+=L}}return p}function j(A,R){if(typeof A>"u"||A===null)return"";if(A.constructor===Date)return JSON.stringify(A).slice(1,25);var b=!1;if(h&&typeof A==="string"&&h.test(A))A="'"+A,b=!0;var p=A.toString(),g=p.replace(O,F);return b=b||X===!0||typeof X==="function"&&X(A,R)||Array.isArray(X)&&X[R]||P0(g,G.BAD_DELIMITERS)||g.indexOf(Q)>-1||p.indexOf(K)>-1||g.charAt(0)===" "||g.charAt(g.length-1)===" ",b?K+g+K:g}function P0(A,R){for(var b=0;b<R.length;b++)if(A.indexOf(R[b])>-1)return!0;return!1}}function T(Y){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},J.call(this,Y),this.parseChunk=function(X,M){let Q=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&Q>0){let h=this._config.newline;if(!h){let r=this._config.quoteChar||'"';h=this._handle.guessLineEndings(X,r)}X=[...X.split(h).slice(Q)].join(h)}if(this.isFirstChunk&&S(this._config.beforeFirstChunk)){var L=this._config.beforeFirstChunk(X);if(L!==void 0)X=L}this.isFirstChunk=!1,this._halted=!1;var K=this._partialLine+X;this._partialLine="";var F=this._handle.parse(K,this._baseIndex,!this._finished);if(this._handle.paused()||this._handle.aborted()){this._halted=!0;return}var E=F.meta.cursor;if(!this._finished)this._partialLine=K.substring(E-this._baseIndex),this._baseIndex=E;if(F&&F.data)this._rowCount+=F.data.length;var x=this._finished||this._config.preview&&this._rowCount>=this._config.preview;if(W)$.postMessage({results:F,workerId:G.WORKER_ID,finished:x});else if(S(this._config.chunk)&&!M){if(this._config.chunk(F,this._handle),this._handle.paused()||this._handle.aborted()){this._halted=!0;return}F=void 0,this._completeResults=void 0}if(!this._config.step&&!this._config.chunk)this._completeResults.data=this._completeResults.data.concat(F.data),this._completeResults.errors=this._completeResults.errors.concat(F.errors),this._completeResults.meta=F.meta;if(!this._completed&&x&&S(this._config.complete)&&(!F||!F.meta.aborted))this._config.complete(this._completeResults,this._input),this._completed=!0;if(!x&&(!F||!F.meta.paused))this._nextChunk();return F},this._sendError=function(X){if(S(this._config.error))this._config.error(X);else if(W&&this._config.error)$.postMessage({workerId:G.WORKER_ID,error:X,finished:!1})};function J(X){var M=N0(X);if(M.chunkSize=parseInt(M.chunkSize),!X.step&&!X.chunk)M.chunkSize=null;this._handle=new i(M),this._handle.streamer=this,this._config=M}}function m(Y){if(Y=Y||{},!Y.chunkSize)Y.chunkSize=G.RemoteChunkSize;T.call(this,Y);var J;if(V)this._nextChunk=function(){this._readChunk(),this._chunkLoaded()};else this._nextChunk=function(){this._readChunk()};this.stream=function(M){this._input=M,this._nextChunk()},this._readChunk=function(){if(this._finished){this._chunkLoaded();return}if(J=new XMLHttpRequest,this._config.withCredentials)J.withCredentials=this._config.withCredentials;if(!V)J.onload=n(this._chunkLoaded,this),J.onerror=n(this._chunkError,this);if(J.open(this._config.downloadRequestBody?"POST":"GET",this._input,!V),this._config.downloadRequestHeaders){var M=this._config.downloadRequestHeaders;for(var Q in M)J.setRequestHeader(Q,M[Q])}if(this._config.chunkSize){var L=this._start+this._config.chunkSize-1;J.setRequestHeader("Range","bytes="+this._start+"-"+L)}try{J.send(this._config.downloadRequestBody)}catch(K){this._chunkError(K.message)}if(V&&J.status===0)this._chunkError()},this._chunkLoaded=function(){if(J.readyState!==4)return;if(J.status<200||J.status>=400){this._chunkError();return}this._start+=this._config.chunkSize?this._config.chunkSize:J.responseText.length,this._finished=!this._config.chunkSize||this._start>=X(J),this.parseChunk(J.responseText)},this._chunkError=function(M){var Q=J.statusText||M;this._sendError(Error(Q))};function X(M){var Q=M.getResponseHeader("Content-Range");if(Q===null)return-1;return parseInt(Q.substring(Q.lastIndexOf("/")+1))}}m.prototype=Object.create(T.prototype),m.prototype.constructor=m;function a(Y){if(Y=Y||{},!Y.chunkSize)Y.chunkSize=G.LocalChunkSize;T.call(this,Y);var J,X,M=typeof FileReader<"u";this.stream=function(Q){if(this._input=Q,X=Q.slice||Q.webkitSlice||Q.mozSlice,M)J=new FileReader,J.onload=n(this._chunkLoaded,this),J.onerror=n(this._chunkError,this);else J=new FileReaderSync;this._nextChunk()},this._nextChunk=function(){if(!this._finished&&(!this._config.preview||this._rowCount<this._config.preview))this._readChunk()},this._readChunk=function(){var Q=this._input;if(this._config.chunkSize){var L=Math.min(this._start+this._config.chunkSize,this._input.size);Q=X.call(Q,this._start,L)}var K=J.readAsText(Q,this._config.encoding);if(!M)this._chunkLoaded({target:{result:K}})},this._chunkLoaded=function(Q){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(Q.target.result)},this._chunkError=function(){this._sendError(J.error)}}a.prototype=Object.create(T.prototype),a.prototype.constructor=a;function t(Y){Y=Y||{},T.call(this,Y);var J;this.stream=function(X){return J=X,this._nextChunk()},this._nextChunk=function(){if(this._finished)return;var X=this._config.chunkSize,M;if(X)M=J.substring(0,X),J=J.substring(X);else M=J,J="";return this._finished=!J,this.parseChunk(M)}}t.prototype=Object.create(t.prototype),t.prototype.constructor=t;function $0(Y){Y=Y||{},T.call(this,Y);var J=[],X=!0,M=!1;this.pause=function(){T.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){T.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(Q){this._input=Q,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){if(M&&J.length===1)this._finished=!0},this._nextChunk=function(){if(this._checkIsFinished(),J.length)this.parseChunk(J.shift());else X=!0},this._streamData=n(function(Q){try{if(J.push(typeof Q==="string"?Q:Q.toString(this._config.encoding)),X)X=!1,this._checkIsFinished(),this.parseChunk(J.shift())}catch(L){this._streamError(L)}},this),this._streamError=n(function(Q){this._streamCleanUp(),this._sendError(Q)},this),this._streamEnd=n(function(){this._streamCleanUp(),M=!0,this._streamData("")},this),this._streamCleanUp=n(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}$0.prototype=Object.create(T.prototype),$0.prototype.constructor=$0;function N(Y){var J=R2("stream").Duplex,X=N0(Y),M=!0,Q=!1,L=[],K=null;this._onCsvData=function(F){var E=F.data;if(!K.push(E)&&!this._handle.paused())this._handle.pause()},this._onCsvComplete=function(){K.push(null)},X.step=n(this._onCsvData,this),X.complete=n(this._onCsvComplete,this),T.call(this,X),this._nextChunk=function(){if(Q&&L.length===1)this._finished=!0;if(L.length)L.shift()();else M=!0},this._addToParseQueue=function(F,E){if(L.push(n(function(){if(this.parseChunk(typeof F==="string"?F:F.toString(X.encoding)),S(E))return E()},this)),M)M=!1,this._nextChunk()},this._onRead=function(){if(this._handle.paused())this._handle.resume()},this._onWrite=function(F,E,x){this._addToParseQueue(F,x)},this._onWriteComplete=function(){Q=!0,this._addToParseQueue("")},this.getStream=function(){return K},K=new J({readableObjectMode:!0,decodeStrings:!1,read:n(this._onRead,this),write:n(this._onWrite,this)}),K.once("finish",n(this._onWriteComplete,this))}if(typeof PAPA_BROWSER_CONTEXT>"u")N.prototype=Object.create(T.prototype),N.prototype.constructor=N;function i(Y){var J=Math.pow(2,53),X=-J,M=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,Q=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,L=this,K=0,F=0,E,x,h=!1,O=!1,r,B=[],j={data:[],errors:[],meta:{}};if(S(Y.step)){var P0=Y.step;Y.step=function(z){if(j=z,p())b();else{if(b(),j.data.length===0)return;if(K+=z.data.length,Y.preview&&K>Y.preview)x.abort();else j.data=j.data[0],P0(j,L)}}}this.parse=function(z,H,D){var k=Y.quoteChar||'"';if(!Y.newline)Y.newline=this.guessLineEndings(z,k);if(r=!1,!Y.delimiter){var P=G0(z,Y.newline,Y.skipEmptyLines,Y.comments,Y.delimitersToGuess);if(P.successful)Y.delimiter=P.bestDelimiter;else r=!0,Y.delimiter=G.DefaultDelimiter;j.meta.delimiter=Y.delimiter}else if(S(Y.delimiter))Y.delimiter=Y.delimiter(z),j.meta.delimiter=Y.delimiter;var y=N0(Y);if(Y.preview&&Y.header)y.preview++;return E=z,x=new W0(y),j=x.parse(E,H,D),b(),h?{meta:{paused:!0}}:j||{meta:{paused:!1}}},this.paused=function(){return h},this.pause=function(){h=!0,x.abort(),E=S(Y.chunk)?"":E.substring(x.getCharIndex())},this.resume=function(){if(L.streamer._halted)h=!1,L.streamer.parseChunk(E,!0);else setTimeout(L.resume,3)},this.aborted=function(){return O},this.abort=function(){if(O=!0,x.abort(),j.meta.aborted=!0,S(Y.complete))Y.complete(j);E=""},this.guessLineEndings=function(z,H){z=z.substring(0,1048576);var D=new RegExp(J0(H)+"([^]*?)"+J0(H),"gm");z=z.replace(D,"");var k=z.split("\r"),P=z.split(`
4
4
  `),y=P.length>1&&P[0].length<k[0].length;if(k.length===1||y)return`