1!function(){try{var t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},e=(new t.Error).stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="c349aefa-cfc2-4c76-90ad-594a99c66026",t._sentryDebugIdIdentifier="sentry-dbid-c349aefa-cfc2-4c76-90ad-594a99c66026")}catch(t){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3987],{10071:(t,e,r)=>{r.d(e,{W6:()=>tC});var a=class extends Error{constructor(t,e,r){super(t),this.statusCode=e,this.details=r,this.name="PinataError"}},i=class extends a{constructor(t,e,r){super(t,e,r),this.name="NetworkError"}},n=class extends a{constructor(t,e,r){super(t,e,r),this.name="AuthenticationError"}},o=class extends a{constructor(t,e){super(t,void 0,e),this.name="ValidationError"}};function s(t){var e,r;return e=t=t.trim(),/^Qm[1-9A-HJ-NP-Za-km-z]{44}$/.test(e)||(r=t,/^b[a-z2-7]{58,}$/.test(r))}async function u(t){let e;if("string"!=typeof t)throw Error("Input is not a string");let r=t=>{let e=t.split("/");return s(e[0])?e[0]:null},a=r(t);if(a)return{containsCid:!0,cid:a};try{e=new URL(t)}catch(e){for(let e of t.split(/\/|\?/)){let t=r(e);if(t)return{containsCid:!0,cid:t}}return{containsCid:!1,cid:null}}for(let t of e.hostname.split("."))if(s(t))return{containsCid:!0,cid:t};for(let t of e.pathname.split("/")){let e=r(t);if(e)return{containsCid:!0,cid:e}}return{containsCid:!1,cid:null}}async function c(t,e){let r=await u(t);if(!0!==r.containsCid)throw Error("url does not contain CID");if(!t.startsWith("https")&&!t.startsWith("ipfs://"))return`${e}/ipfs/${t}`;let a=new URL(t),i=a.pathname+a.search+a.hash;if(t.startsWith(`ipfs://${r.cid}`))return`${e}/ipfs/${r.cid}${i}`;if(t.includes(`/ipfs/${r.cid}`)||t.includes(`/ipns/${r.cid}`))return`${e}${i}`;if(a.hostname.includes(r.cid))return`${e}/ipfs/${r.cid}${i}`;throw Error("unsupported URL pattern, please submit a github issue with the URL utilized")}var l=t=>{let e=t?.pinataGateway;return t&&e&&(e&&!e.startsWith("https://")&&(e=`https://${e}`),t.pinataGateway=e),t},d=r(95120).Buffer,h=async(t,e)=>{if(!t)throw new o("Pinata configuration is missing");let r=new URLSearchParams;if(e){let{cid:t,gateway_domain:a,start_date:i,end_date:n,file_name:o,user_agent:s,country:u,region:c,referer:l,limit:d,sort_order:h,date_interval:p,sort_by:w}=e;t&&r.append("cid",t),a&&r.append("gateway_domain",a),i&&r.append("start_date",i),n&&r.append("end_date",n),o&&r.append("file_name",o),s&&r.append("user_agent",s.toString()),u&&r.append("country",u.toString()),c&&r.append("region",c),l&&r.append("referer",l.toString()),d&&r.append("limit",d.toString()),h&&r.append("sort_order",h),w&&r.append("sort_by",w),p&&r.append("by",p)}let s="https://api.pinata.cloud/v3";t.endpointUrl&&(s=t.endpointUrl);let u=`${s}/ipfs/gateway_analytics_time_series?${r.toString()}`;try{let e;e=t.customHeaders&&Object.keys(t.customHeaders).length>0?{...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/analyticsDateInterval"};let r=await fetch(u,{method:"GET",headers:e});if(!r.ok){let t=await r.text();if(401===r.status||403===r.status)throw new n(`Authentication failed: ${t}`,r.status,{error:t,code:"AUTH_ERROR",metadata:{requestUrl:r.url}});throw new i(`HTTP error: ${t}`,r.status,{error:t,code:"HTTP_ERROR",metadata:{requestUrl:r.url}})}return(await r.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing anaytics usage: ${t.message}`);throw new a("An unknown error occurred while fetching gateway usage")}},p=async(t,e)=>{if(!t)throw new o("Pinata configuration is missing");let r=new URLSearchParams;if(e){let{cid:a,gateway_domain:i,start_date:n,end_date:o,file_name:s,user_agent:u,country:c,region:l,referer:d,limit:h,sort_order:p,sort_by:w,attribute:f}=e,g=i||t.pinataGateway;if(g){let t=g.replace(/^https?:\/\//,"");r.append("gateway_domain",t)}a&&r.append("cid",a),n&&r.append("start_date",n),o&&r.append("end_date",o),s&&r.append("file_name",s),u&&r.append("user_agent",u.toString()),c&&r.append("country",c.toString()),l&&r.append("region",l),d&&r.append("referer",d.toString()),h&&r.append("limit",h.toString()),p&&r.append("sort_order",p),w&&r.append("sort_by",w),f&&r.append("by",f)}let s="https://api.pinata.cloud/v3";t.endpointUrl&&(s=t.endpointUrl);let u=`${s}/ipfs/gateway_analytics_top?${r.toString()}`;try{let e;e=t.customHeaders&&Object.keys(t.customHeaders).length>0?{...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/analyticsTopUsage"};let r=await fetch(u,{method:"GET",headers:e});if(!r.ok){let t=await r.text();
1if(401===r.status||403===r.status)throw new n(`Authentication failed: ${t}`,r.status,{error:t,code:"AUTH_ERROR",metadata:{requestUrl:r.url}});throw new i(`HTTP error: ${t}`,r.status,{error:t,code:"HTTP_ERROR",metadata:{requestUrl:r.url}})}return await r.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing anaytics usage: ${t.message}`);throw new a("An unknown error occurred while fetching gateway usage")}},w=async t=>{let e;if(!t)throw new o("Pinata configuration is missing");let r="https://api.pinata.cloud";t.endpointUrl&&(r=t.endpointUrl),e=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/testAuthentication"};try{let t=await fetch(`${r}/data/testAuthentication`,{method:"GET",headers:e});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return await t.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing authentication: ${t.message}`);throw new a("An unknown error occurred while testing authentication")}},f=t=>new Promise(e=>{setTimeout(e,t)}),g=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");let u=[];s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/deleteFile"};let c="https://api.pinata.cloud/v3";for(let o of(t.endpointUrl&&(c=t.endpointUrl),e))try{let t=await fetch(`${c}/files/${r}/${o}`,{method:"DELETE",headers:s});if(await f(300),!t.ok){let e=await t.text();if(401===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}});throw new i("HTTP error",t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}u.push({id:o,status:t.statusText})}catch(e){let t;t=e instanceof a?e.message:e instanceof Error?`Error deleting file ${o}: ${e.message}`:`An unknown error occurred while deleting file ${o}`,u.push({id:o,status:t})}return u},m=async(t,e)=>{let r;if(!t)throw new o("Pinata configuration is missing");r=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/vectorizeFile"};let s="https://uploads.pinata.cloud/v3";t.uploadUrl&&(s=t.uploadUrl);try{let t=await fetch(`${s}/vectorize/files/${e}`,{method:"DELETE",headers:r});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return await t.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing vectorize file: ${t.message}`);throw new a("An unknown error occurred while vectorizing file")}},y=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/deleteSwap"};let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}/files/${r}/swap/${e}`,{method:"DELETE",headers:s});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n("Authentication failed",t.status,{error:e,code:"AUTH_ERROR"});if(403===t.status)throw new a("Unauthorized CID Swap Deletion",t.status,{error:e,code:"UNAUTHORIZED"});if(404===t.status)throw new a("CID not pinned to account",t.status,{error:e,code:"NOT_FOUND"});throw new i("HTTP error occurred",t.status,{error:e,code:"NETWORK_ERROR"})}return t.statusText}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing deleteSwap: ${t.message}`,void 0,{code:"DELETE_SWAP_ERROR"});throw new a("An unknown error occurred while deleting swap",void 0,{code:"UNKNOWN_ERROR"})}},T=async(t,e,r)=>{if(!t)throw new o("Pinata configuration is missing");let s=new URLSearchParams;if(r){let{name:t,group:e,cid:a,order:i,limit:n,mimeType:o,pageToken:u,cidPending:c,metadata:l,noGroup:d}=r;n&&s.append("limit",n.toString()),t&&s.append("name",t),e&&s.append("group",e),a&&s.append("cid",a),o&&s.append("mimeType",o),i&&s.append("order",i),u&&s.append("pageToken",u),c&&s.append("cidPending","true"),d&&s.append("group","null"),l&&"object"==typeof l&&Object.entries(l).forEach(([t,e])=>{s.append(`keyvalues[${t.toString()}]`,e.toString())})}let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);let c=`${u}/files/${e}?${s.toString()}`;try{let e;e=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/listFiles"};let r=await fetch(c,{method:"GET",headers:e});if(!r.ok){let t=await r.text();
1if(401===r.status||403===r.status)throw new n(`Authentication failed: ${t}`,r.status,{error:t,code:"AUTH_ERROR",metadata:{requestUrl:r.url}});throw new i(`HTTP error: ${t}`,r.status,{error:t,code:"HTTP_ERROR",metadata:{requestUrl:r.url}})}return(await r.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing list files: ${t.message}`);throw new a("An unknown error occurred while listing files")}},$=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");let u=JSON.stringify({swap_cid:e.swapCid});s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/swapCid"};let c="https://api.pinata.cloud/v3";t.endpointUrl&&(c=t.endpointUrl);try{let t=await fetch(`${c}/files/${r}/swap/${e.cid}`,{method:"PUT",headers:s,body:u});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});if(403===t.status)throw new a("Unauthorized CID Swap",t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});if(404===t.status)throw new a("CID not pinned to account",t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing CID Swap: ${t.message}`);throw new a("An unknown error occurred while swapping CID")}},R=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/swapHistory"};let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}/files/${r}/swap/${e.cid}?domain=${e.domain}`,{method:"GET",headers:s});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});if(404===t.status)throw new a("CID does not have history",t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error fetching swap history: ${t.message}`);throw new a("An unknown error occurred while fetching swap history")}},H=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");if(!e.name&&(!e.keyvalues||0===Object.keys(e.keyvalues).length)&&void 0===e.expires_at)throw new o("At least one of 'name', 'keyvalues', or 'expires_at' must be provided");let u={};void 0!==e.name&&(u.name=e.name),e.keyvalues&&Object.keys(e.keyvalues).length>0&&(u.keyvalues=e.keyvalues),void 0!==e.expires_at&&(u.expires_at=e.expires_at);let c=JSON.stringify(u);s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/updateMetadata"};let l="https://api.pinata.cloud/v3";t.endpointUrl&&(l=t.endpointUrl);try{let t=await fetch(`${l}/files/${r}/${e.id}`,{method:"PUT",headers:s,body:c});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing updateFile: ${t.message}`);throw new a("An unknown error occurred while updating file")}},k=async(t,e)=>{let r;if(!t)throw new o("Pinata configuration is missing");r=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/vectorizeFile"};let s="https://uploads.pinata.cloud/v3";t.uploadUrl&&(s=t.uploadUrl);try{let t=await fetch(`${s}/vectorize/files/${e}`,{method:"POST",headers:r});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return await t.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing vectorize file: ${t.message}`);throw new a("An unknown error occurred while vectorizing file")}},U=async(t,e)=>{let r;if(!t)throw new o("Pinata configuration is missing");r=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/vectorQuery"};let s="https://uploads.pinata.cloud/v3";t.uploadUrl&&(s=t.uploadUrl);let u=JSON.stringify({text:e.query});try{let o=await fetch(`${s}/vectorize/groups/${e.groupId}/query`,{method:"POST",headers:r,body:u});if(!o.ok){let t=await o.text();if(401===o.status||403===o.status)throw new n(`Authentication failed: ${t}`,o.status,{error:t,code:"AUTH_ERROR",metadata:{requestUrl:o.url}});throw new i(`HTTP error: ${t}`,o.status,{error:t,code:"HTTP_ERROR",metadata:{requestUrl:o.url}})}let c=(await o.json()).data;if(e.returnFile){if(0===c.matches.length)throw new a("No files returned in query to fetch");let e=c.matches[0].cid;return await P(t,e,"files")}return c}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing vectorize file: ${t.message}`);throw new a("An unknown error occurred while vectorizing file")}},E=async(t,e)=>{let r;if(!t)throw new o("Pinata configuration is missing");let s=new URLSearchParams({includesCount:"false"});if(e){let{cid:t,status:r,sort:a,limit:i,pageToken:n}=e;t&&s.append("cid",t.toString()),r&&s.append("status",r.toString()),a&&s.append("sort",a.toString()),i&&s.append("limit",i.toString()),n&&s.append("pageToken",n.toString())}let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);let c=`${u}/files/public/pin_by_cid?${s.toString()}`;r=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/pinJobs"};try{let t=await fetch(c,{method:"GET",headers:r});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing pinJobs: ${t.message}`);throw new a("An unknown error occurred while listing pin jobs")}},A=async(t,e)=>{let r;if(!t)throw new o("Pinata configuration is missing");r=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/deletePinRequest"};let s="https://api.pinata.cloud/v3";t.endpointUrl&&(s=t.endpointUrl);try{let t=await fetch(`${s}/files/public/pin_by_cid/${e}`,{method:"DELETE",headers:r});if(!t.ok){let e=await t.text();if(401===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}});throw new i("HTTP error",t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return"OK"}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error deleting pin by request: ${t.message}`);throw new a("An unknown error occurred while deleting pin by CID request")}},P=async(t,e,r,s)=>{let u;if(!t)throw new o("Pinata configuration is missing");let c=`${t?.pinataGateway}/${r}/${e}`,l=new URLSearchParams;s&&(s.width&&l.append("img-width",s.width.toString()),s.height&&l.append("img-height",s.height.toString()),s.dpr&&l.append("img-dpr",s.dpr.toString()),s.fit&&l.append("img-fit",s.fit),s.gravity&&l.append("img-gravity",s.gravity),s.quality&&l.append("img-quality",s.quality.toString()),s.format&&l.append("img-format",s.format),void 0!==s.animation&&l.append("img-
1anim",s.animation.toString()),s.sharpen&&l.append("img-sharpen",s.sharpen.toString()),!0===s.onError&&l.append("img-onerror","redirect"),s.metadata&&l.append("img-metadata",s.metadata)),t?.pinataGatewayKey&&l.append("pinataGatewayToken",t.pinataGatewayKey);let d=l.toString();if(d&&(c+=`?${d}`),"ipfs"===r){let t=await fetch(c);if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication Failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}let e=t.headers.get("content-type")?.split(";")[0]||null;return{data:e?.includes("application/json")?await t.json():e?.includes("text/")?await t.text():await t.blob(),contentType:e}}let h=JSON.stringify({url:c,date:Math.floor(new Date().getTime()/1e3),expires:30,method:"GET"}),p="https://api.pinata.cloud/v3";t.endpointUrl&&(p=t.endpointUrl),u=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{"Content-Type":"application/json",Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/getCid"};let w=await fetch(`${p}/files/sign`,{method:"POST",headers:u,body:h}),f=await w.json();try{let t=await fetch(f.data);if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication Failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}let e=t.headers.get("content-type")?.split(";")[0]||null;return{data:e?.includes("application/json")?await t.json():e?.includes("text/")?await t.text():await t.blob(),contentType:e}}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing getCid: ${t.message}`);throw new a("An unknown error occurred while getting CID contents")}},_=async(t,e,r)=>{let a,i=r||t?.pinataGateway||"https://gateway.pinata.cloud";return a=await c(e,i),t?.pinataGatewayKey&&t?.pinataGatewayKey,a},v=async(t,e,r)=>{let s,u;if(!t)throw new o("Pinata configuration is missing");s=e?.gateway?e.gateway.startsWith("https://")?e.gateway:`https://${e.gateway}`:t.pinataGateway;let c=`${s}/files/${e.cid}`,l=new URLSearchParams;r&&(r.width&&l.append("img-width",r.width.toString()),r.height&&l.append("img-height",r.height.toString()),r.dpr&&l.append("img-dpr",r.dpr.toString()),r.fit&&l.append("img-fit",r.fit),r.gravity&&l.append("img-gravity",r.gravity),r.quality&&l.append("img-quality",r.quality.toString()),r.format&&l.append("img-format",r.format),void 0!==r.animation&&l.append("img-anim",r.animation.toString()),r.sharpen&&l.append("img-sharpen",r.sharpen.toString()),!0===r.onError&&l.append("img-onerror","redirect"),r.metadata&&l.append("img-metadata",r.metadata));let d=l.toString();d&&(c+=`?${d}`);let h=JSON.stringify({url:c,date:e?.date||Math.floor(new Date().getTime()/1e3),expires:e.expires,method:"GET"}),p="https://api.pinata.cloud/v3";t.endpointUrl&&(p=t.endpointUrl),u=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{"Content-Type":"application/json",Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/createSignURL"};try{let t=await fetch(`${p}/files/private/download_link`,{method:"POST",headers:u,body:h});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication Failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing createSignedURL: ${t.message}`);throw new a("An unknown error occurred while getting signed url")}},O=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");let u=t=>new Promise(e=>{setTimeout(e,t)}),c=[];s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/addToGroup"};let l="https://api.pinata.cloud/v3";for(let o of(t.endpointUrl&&(l=t.endpointUrl),e.files))try{let t=await fetch(`${l}/groups/${r}/${e.groupId}/ids/${o}`,{method:"PUT",headers:s});if(await u(300),!t.ok){let e=await t.text();if(401===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}c.push({id:o,status:t.statusText})}catch(e){let t;t=e instanceof a?e.message:e instanceof Error?`Error adding file ${o} to group: ${e.message}`:`An unknown error occurred while adding file ${o} to group`,c.push({id:o,status:t})}return c},q=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");let u=JSON.stringify({name:e.name,is_public:e.isPublic});s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/createGroup"};let c="https://api.pinata.cloud/v3";t.endpointUrl&&(c=t.endpointUrl);try{let t=await fetch(`${c}/groups/${r}`,{method:"POST",headers:s,body:u});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing createGroup: ${t.message}`);throw new a("An unknown error occurred while creating a group")}},S=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/deleteGroup"};let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}/groups/${r}/${e.groupId}`,{method:"DELETE",headers:s});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return t.statusText}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing deleteGroup: ${t.message}`);throw new a("An unknown error occurred while deleting a group")}},b=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/getGroup"};let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}/groups/${r}/${e.groupId}`,{method:"GET",headers:s});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing getGroup: ${t.message}`);throw new a("An unknown error occurred while getting info for a group")}},j=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/listGroups"};let u=new URLSearchParams;if(r){let{pageToken:t,name:e,limit:a,isPublic:i}=r;t&&u.append("pageToken",t.toString()),i&&u.append("isPublic",i.toString()),e&&u.append("name",e),void 0!==a&&u.append("limit",a.toString())}let c="https://api.pinata.cloud/v3";t.endpointUrl&&(c=t.endpointUrl);try{let t=await fetch(`${c}/groups/${e}?${u.toString()}`,{method:"GET",headers:s});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing listGroups: ${t.message}`);throw new a("An unknown error occurred while listing groups")}},C=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");let u=t=>new Promise(e=>{setTimeout(e,t)}),c=[];s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/addToGroup"};let l="https://api.pinata.cloud/v3";for(let o of(t.endpointUrl&&(l=t.endpointUrl),e.files))try{let t=await fetch(`${l}/groups/${r}/${e.groupId}/ids/${o}`,{method:"DELETE",headers:s});if(await u(300),!t.ok){let e=await t.text();if(401===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}c.push({id:o,status:t.statusText})}catch(e){let t;t=e instanceof a?e.message:e instanceof Error?`Error adding file ${o} to group: ${e.message}`:`An unknown error occurred while adding file ${o} to group`,c.push({id:o,status:t})}return c},z=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");let u=JSON.stringify({name:e.name,is_public:e.isPublic});s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/updateGroup"};let c="https://api.pinata.cloud/v3";t.endpointUrl&&(c=t.endpointUrl);try{let t=await fetch(`${c}/groups/${r}/${e.groupId}`,{method:"PUT",headers:s,body:u});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing updateGroup: ${t.message}`);throw new a("An unknown error occurred while updating group")}},x=async(t,e)=>{let r;if(!t)throw new o("Pinata configuration is missing");r=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/createKey"};let s=JSON.stringify(e),u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}/pinata/keys`,{method:"POST",headers:r,body:s});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return await t.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing createKey: ${t.message}`);throw new a("An unknown error occurred while creating API key")}},J=async(t,e)=>{let r;if(!t)throw new o("Pinata configuration is missing");r=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/listKeys"};let s=new URLSearchParams;if(e){let{offset:t,name:r,revoked:a,limitedUse:i,exhausted:n}=e;t&&s.append("offset",t.toString()),void 0!==a&&s.append("revoked",a.toString()),void 0!==i&&s.append("limitedUse",i.toString()),void 0!==n&&s.append("exhausted",n.toString()),r&&s.append("name",r)}let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}/pinata/keys?${s.toString()}`,{method:"GET",headers:r});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).keys}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing listKeys: ${t.message}`);throw new a("An unknown error occurred while listing API keys")}},B=t=>new Promise(e=>{setTimeout(e,t)}),I=async(t,e)=>{let r;if(!t)throw new o("Pinata configuration is missing");t.customHeaders&&Object.keys(t.customHeaders).length>0?(r={Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders},r={...t.customHeaders}):r={Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/revokeKeys"};let s=[],u="https://api.pinata.cloud/v3";for(let o of(t.endpointUrl&&(u=t.endpointUrl),e))try{let t=await fetch(`${u}/pinata/keys/${o}`,{method:"PUT",headers:r});if(await B(300),!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}let e=await t.json();s.push({key:o,status:e})}catch(e){let t;t=e instanceof a?e.message:e instanceof Error?`Error revoking key ${o}: ${e.message}`:`An unknown error occurred while revoking key ${o}`,s.push({key:o,status:t})}return s},D=async(t,e,r,s)=>{let u;if(!t)throw new o("Pinata configuration is missing");let c=s?.keys||t?.pinataJwt,l=s?.metadata?.name?s?.metadata?.name:"base64 string",h=new Blob([d.from(e,"base64")]),p=new FormData;p.append("file",h,l),p.append("network",r),p.append("name",l),s?.groupId&&p.append("group_id",s.groupId),s?.metadata?.keyvalues&&p.append("keyvalues",JSON.stringify(s.metadata.keyvalues)),u=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${c}`,...t.customHeaders}:{Authorization:`Bearer ${c}`,Source:"sdk/base64"};let w="https://uploads.pinata.cloud/v3";if(t.uploadUrl&&(w=t.uploadUrl),s?.url)try{let t=await fetch(s.url,{method:"POST",body:p});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing base64: ${t.message}`);throw new a("An unknown error occurred while trying to upload base64")}try{let t=await fetch(`${w}/files`,{method:"POST",headers:u,body:p});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}let e=(await t.json()).data;if(s?.vectorize){let r=await fetch(`${w}/vectorize/files/${e.id}`,{method:"POST",headers:{Authorization:`Bearer ${c}`}});if(r.ok)e.vectorized=!0;else{let e=await r.text();throw new i(`HTTP error during vectorization: ${e}`,r.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}}return e}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing base64: ${t.message}`);throw new a("An unknown error occurred while trying to upload base64")}},N=async(t,e,r)=>{l
1et s;if(!t)throw new o("Pinata configuration is missing");let u={date:e?.date||Math.floor(new Date().getTime()/1e3),expires:e.expires};e.groupId&&(u.group_id=e.groupId),e.name&&(u.filename=e.name),e.keyvalues&&(u.keyvalues=e.keyvalues),r&&(u.network=r),e.streamable&&(u.streamable=e.streamable),e.maxFileSize&&(u.max_file_size=e.maxFileSize),e.mimeTypes&&(u.allow_mime_types=e.mimeTypes);let c="https://uploads.pinata.cloud/v3";t.uploadUrl&&(c=t.uploadUrl),s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{"Content-Type":"application/json",Authorization:`Bearer ${t.pinataJwt}`,Source:"sdk/createSignURL"};for(let t=0;t<=3;t++)try{let t=await fetch(`${c}/files/sign`,{method:"POST",headers:s,cache:"no-store",body:JSON.stringify(u)});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication Failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(r){if(r instanceof n||r instanceof i&&r.statusCode&&r.statusCode>=400&&r.statusCode<500&&429!==r.statusCode)throw r;if(3===t){if(r instanceof a)throw r;if(r instanceof Error)throw new a(`Error processing createSignedURL: ${r.message}`);throw new a("An unknown error occurred while getting signed url")}let e=Math.min(1e3*Math.pow(2,t),4e3);await new Promise(t=>setTimeout(t,e))}throw new a("An unknown error occurred while getting signed url")},G=async(t,e,r,s)=>{let u;if(!t)throw new o("Pinata configuration is missing");let c=s?.keys||t.pinataJwt,l="https://uploads.pinata.cloud/v3";if(t.uploadUrl&&(l=t.uploadUrl),e.size>0x5a00000){let a,n;a=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${c}`,...t.customHeaders}:{Authorization:`Bearer ${c}`,Source:"sdk/file"};let o=s?.metadata?.name||e.name||"File from SDK",u=`filename ${btoa(o)},filetype ${btoa(e.type)},network ${btoa(r)}`;s?.groupId&&(u+=`,group_id ${btoa(s.groupId)}`),s?.metadata?.keyvalues&&(u+=`,keyvalues ${btoa(JSON.stringify(s.metadata.keyvalues))}`),s?.streamable&&(u+=`,streamable ${btoa("true")}`),s?.car&&(u+=`,car ${btoa("true")}`),s?.cid_version!==void 0&&(u+=`,cid_version ${btoa(s.cid_version)}`),s?.expires_at!==void 0&&(u+=`,expires_at ${btoa(s.expires_at.toString())}`);let d=`${l}/files`;s?.url&&(d=s.url);let h=new URL(d);s?.cid_version!==void 0&&h.searchParams.set("X-Upload-Option-Cid-Version",s.cid_version.toString());let p=await fetch(h.toString(),{method:"POST",headers:{"Upload-Length":`${e.size}`,"Upload-Metadata":u,...a}}),w=p.headers.get("Location");if(!w){let t=await p.text();throw new i("Upload URL not provided",p.status,{error:t,code:"HTTP_ERROR",metadata:{requestUrl:p.url,requestHeaders:p.headers}})}let f=Math.ceil(e.size/0x3200001),g=0;for(let t=0;t<f;t++){let t=e.slice(g,g+0x3200001),r=0;for(;r<=5;)try{if((n=await fetch(w,{method:"PATCH",headers:{"Content-Type":"application/offset+octet-stream","Upload-Offset":g.toString(),...a},body:t})).ok)break;{let t=await n.text();throw Error(`HTTP ${n.status}: ${t}`)}}catch(e){if(++r>5){let t=n?await n.text().catch(()=>"Unknown error"):e instanceof Error?e.message:String(e);throw new i(`HTTP error during chunk upload after 5 retries: ${t}`,n?.status||0,{error:t,code:"HTTP_ERROR",metadata:{requestUrl:n?.url||w,retriesAttempted:5}})}let t=Math.min(1e3*Math.pow(2,r-1),1e4);await new Promise(e=>setTimeout(e,t))}g+=t.size}if(204===n.status){let a,o=n.headers.get("upload-cid");if(!t.pinataJwt)return{id:"",name:"",cid:o,size:e.size,created_at:"",number_of_files:1,group_id:null,mime_type:"",keyvalues:{},vectorized:!1,network:""};a=t.endpointUrl?t.endpointUrl:"https://api.pinata.cloud/v3";let u=await fetch(`${a}/files/${r}?cid=${o}`,{method:"GET",headers:{Authorization:`Bearer ${c}`}}),d=(await u.json()).data.files[0];if(s?.vectorize){let t=await fetch(`${l}/vectorize/files/${d.id}`,{method:"POST",headers:{Authorization:`Bearer ${c}`}});if(t.ok)d.vectorized=!0;else{let e=await t.text();throw new i(`HTTP error during vectorization: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}}return d}}u=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${c}`,...t.customHeaders}:{Authorization:`Bearer ${c}`,Source:"sdk/file"};let d=new FormData;if(d.append("file",e,e.name),d.append("network",r),d.append("name",s?.metadata?.name||e.name||"File from SDK"),s?.groupId&&d.append("group_id",s.groupId),s?.metadata?.keyvalues&&d.append("keyvalues",JSON.stringify(s.metadata.keyvalues)),s?.streamable&&d.append("streamable","true"),s?.car&&d.append("car","true"),s?.cid_version!==void 0&&d.append("cid_version",s.cid_version.toString()),s?.expires_at!==void 0&&d.append("expires_at",s.expires_at.toString()),s?.url)try{let t=new URL(s.url),e=await fetch(t.toString(),{method:"POST",headers:u,body:d});if(!e.ok){let t=await e.text();if(401===e.status||403===e.status)throw new n(`Authentication failed: ${t}`,e.status,{error:t,code:"AUTH_ERROR",metadata:{requestUrl:e.url}});throw new i(`HTTP error: ${t}`,e.status,{error:t,code:"HTTP_ERROR",metadata:{requestUrl:e.url}})}return(await e.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error uploading file: ${t.message}`,void 0,{error:t.toString()});throw new a("An unknown error occurred while trying to upload file")}try{let t=await fetch(`${l}/files`,{method:"POST",headers:u,body:d});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}let e=(await t.json()).data;if(s?.vectorize){let r=await fetch(`${l}/vectorize/files/${e.id}`,{method:"POST",headers:{Authorization:`Bearer ${c}`}});if(r.ok)e.vectorized=!0;else{let e=await r.text();throw new i(`HTTP error during vectorization: ${e}`,r.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}}return e}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error uploading file: ${t.message}`,void 0,{error:t.toString()});throw new a("An unknown error occurred while trying to upload file")}},M=async(t,e,r,s)=>{let u;if(!t)throw new o("Pinata configuration is missing");let c=s?.keys||t?.pinataJwt,l=s?.metadata?.name||"folder_from_sdk",d=new FormData;for(let t of Array.from(e)){let e=t.webkitRelativePath||`${l}/${t.name}`;d.append("file",t,e)}d.append("pinataMetadata",JSON.stringify({name:l,keyvalues:s?.metadata?.keyvalues})),d.append("pinataOptions",JSON.stringify({groupId:s?.groupId,cidVersion:1})),u=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${c}`,...t.customHeaders}:{Authorization:`Bearer ${c}`,Source:"sdk/fileArray"};let h="https://api.pinata.cloud/pinning/pinFileToIPFS";t.legacyUploadUrl&&(h=t.legacyUploadUrl);try{let t=await fetch(`${h}`,{method:"POST",headers:u,body:d});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}let e=await t.json();
1return{id:e.ID,name:e.Name,cid:e.IpfsHash,size:e.PinSize,created_at:e.Timestamp,number_of_files:e.NumberOfFiles,mime_type:e.MimeType,group_id:e.GroupId,keyvalues:e.Keyvalues,vectorized:!1,network:"public"}}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing fileArray: ${t.message}`);throw new a("An unknown error occurred while uploading an array of files")}},F=async(t,e,r,s)=>{let u;if(!t)throw new o("Pinata configuration is missing");let c=s?.keys||t?.pinataJwt,l=new File([new Blob([JSON.stringify(e)])],"data.json",{type:"application/json"}),d=new FormData;d.append("file",l,l.name),d.append("network",r),d.append("name",s?.metadata?.name||l.name||"File from SDK"),s?.groupId&&d.append("group_id",s.groupId),s?.metadata?.keyvalues&&d.append("keyvalues",JSON.stringify(s.metadata.keyvalues)),u=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${c}`,...t.customHeaders}:{Authorization:`Bearer ${c}`,Source:"sdk/json"};let h="https://uploads.pinata.cloud/v3";if(t.uploadUrl&&(h=t.uploadUrl),s?.url)try{let t=await fetch(s.url,{method:"POST",body:d});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing base64: ${t.message}`);throw new a("An unknown error occurred while trying to upload base64")}try{let t=await fetch(`${h}/files`,{method:"POST",headers:u,body:d});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}let e=(await t.json()).data;if(s?.vectorize){let r=await fetch(`${h}/vectorize/files/${e.id}`,{method:"POST",headers:{Authorization:`Bearer ${c}`}});if(r.ok)e.vectorized=!0;else{let e=await r.text();throw new i(`HTTP error during vectorization: ${e}`,r.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}}return e}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing json: ${t.message}`);throw new a("An unknown error occurred while uploading json")}},L=async(t,e,r,s)=>{let u;if(!t)throw new o("Pinata configuration is missing");let c=s?.keys||t?.pinataJwt,l=new FormData,d=await fetch(e);if(!d.ok){let t=await d.text();throw new i(`HTTP error: ${t}`,d.status,{error:t,code:"HTTP_ERROR",metadata:{requestUrl:d.url}})}let h=new Blob([await d.arrayBuffer()]),p=s?.metadata?.name??"url_upload",w=new File([h],p);l.append("file",w,p),l.append("network",r),l.append("name",p),s?.groupId&&l.append("group_id",s.groupId),s?.metadata?.keyvalues&&l.append("keyvalues",JSON.stringify(s.metadata.keyvalues)),u=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${c}`,...t.customHeaders}:{Authorization:`Bearer ${c}`,Source:"sdk/url"};let f="https://uploads.pinata.cloud/v3";if(t.uploadUrl&&(f=t.uploadUrl),s?.url)try{let t=await fetch(s.url,{method:"POST",body:l});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing base64: ${t.message}`);throw new a("An unknown error occurred while trying to upload base64")}try{let t=await fetch(`${f}/files`,{method:"POST",headers:u,body:l});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}let e=(await t.json()).data;if(s?.vectorize){let r=await fetch(`${f}/vectorize/files/${e.id}`,{method:"POST",headers:{Authorization:`Bearer ${c}`}});if(r.ok)e.vectorized=!0;else{let e=await r.text();throw new i(`HTTP error during vectorization: ${e}`,r.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}}return e}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing url: ${t.message}`);throw new a("An unknown error occurred while uploading by url")}},V=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");let u=r?.keys||t?.pinataJwt;s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${u}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${u}`,"Content-Type":"application/json",Source:"sdk/cid"};let c=JSON.stringify({cid:e,name:r?.metadata?r?.metadata?.name:e,keyvalues:r?.metadata?.keyvalues,group_id:r?.groupId,host_nodes:r?.peerAddresses}),l="https://api.pinata.cloud/v3";t.endpointUrl&&(l=t.endpointUrl);try{let t=await fetch(`${l}/files/public/pin_by_cid`,{method:"POST",headers:s,body:c});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing cid: ${t.message}`);throw new a("An unknown error occurred while pinning by CID")}},K=async(t,e)=>{let r;if(!t)throw new o("Pinata configuration is missing");r=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/listPaymentInstructions"};let s=new URLSearchParams;if(e){let{pageToken:t,limit:r,cid:a,name:i,id:n}=e;t&&s.append("pageToken",t),void 0!==r&&s.append("limit",r.toString()),a&&s.append("cid",a),i&&s.append("name",i),n&&s.append("id",n)}let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}
1/x402/payment_instructions?${s.toString()}`,{method:"GET",headers:r});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return await t.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing listPaymentInstructions: ${t.message}`);throw new a("An unknown error occurred while listing payment instructions")}},Z=async(t,e)=>{let r;if(!t)throw new o("Pinata configuration is missing");if(!e.name)throw new o("Payment instruction name is required");if(!e.payment_requirements||0===e.payment_requirements.length)throw new o("At least one payment requirement is required");r=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/createPaymentInstruction"};let s="https://api.pinata.cloud/v3";t.endpointUrl&&(s=t.endpointUrl);try{let t=await fetch(`${s}/x402/payment_instructions`,{method:"POST",headers:r,body:JSON.stringify(e)});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return await t.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing createPaymentInstruction: ${t.message}`);throw new a("An unknown error occurred while creating payment instruction")}},W=async(t,e)=>{let r;if(!t)throw new o("Pinata configuration is missing");if(!e)throw new o("Payment instruction ID is required");r=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/getPaymentInstruction"};let s="https://api.pinata.cloud/v3";t.endpointUrl&&(s=t.endpointUrl);try{let t=await fetch(`${s}/x402/payment_instructions/${e}`,{method:"GET",headers:r});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return await t.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing getPaymentInstruction: ${t.message}`);throw new a("An unknown error occurred while getting payment instruction")}},Q=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");if(!e)throw new o("Payment instruction ID is required");s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/updatePaymentInstruction"};let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}/x402/payment_instructions/${e}`,{method:"PATCH",headers:s,body:JSON.stringify(r)});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return await t.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing updatePaymentInstruction: ${t.message}`);throw new a("An unknown error occurred while updating payment instruction")}},X=async(t,e)=>{let r;if(!t)throw new o("Pinata configuration is missing");if(!e)throw new o("Payment instruction ID is required");r=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/deletePaymentInstruction"};let s="https://api.pinata.cloud/v3";t.endpointUrl&&(s=t.endpointUrl);try{let t=await fetch(`${s}/x402/payment_instructions/${e}`,{method:"DELETE",headers:r});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return await t.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing deletePaymentInstruction: ${t.message}`);throw new a("An unknown error occurred while deleting payment instruction")}},Y=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");if(!e)throw new o("Payment instruction ID is required");s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/listCids"};let u=new URLSearchParams;if(r){let{pageToken:t,limit:e}=r;t&&u.append("pageToken",t),void 0!==e&&u.append("limit",e.toString())}let c="https://api.pinata.cloud/v3";t.endpointUrl&&(c=t.endpointUrl);try{let t=await fetch(`${c}/x402/payment_instructions/${e}/cids?${u.toString()}`,{method:"GET",headers:s});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return await t.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing listCids: ${t.message}`);throw new a("An unknown error occurred while listing CIDs")}},tt=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");if(!e)throw new o("Payment instruction ID is required");if(!r)throw new o("CID is required");s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/addCid"};let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}
1/x402/payment_instructions/${e}/cids/${r}`,{method:"PUT",headers:s});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return await t.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing addCid: ${t.message}`);throw new a("An unknown error occurred while adding CID")}},te=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");if(!e)throw new o("Payment instruction ID is required");if(!r)throw new o("CID is required");s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/removeCid"};let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}/x402/payment_instructions/${e}/cids/${r}`,{method:"DELETE",headers:s});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return await t.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing removeCid: ${t.message}`);throw new a("An unknown error occurred while removing CID")}},tr=class{constructor(t){this.config=l(t),this.requests=new to(this.config),this.bandwidth=new ti(this.config)}updateConfig(t){this.config=t,this.requests.updateConfig(t),this.bandwidth.updateConfig(t)}summary(t){return new ts(this.config,t.domain,t.start,t.end,t.interval)}},ta=class{constructor(t,e,r,a){this.config=t,this.query={gateway_domain:e,start_date:r,end_date:a,sort_by:"requests",attribute:"cid"}}cid(t){return this.query.attribute="cid",t&&(this.query.cid=t),this}fileName(t){return this.query.attribute="file_name",t&&(this.query.file_name=t),this}userAgent(t){return this.query.attribute="user_agent",t&&(this.query.user_agent=t),this}country(t){return this.query.attribute="country",t&&(this.query.country=t),this}region(t){return this.query.attribute="region",t&&(this.query.region=t),this}referer(t){return this.query.attribute="referer",t&&(this.query.referer=t),this}limit(t){return this.query.limit=t,this}sort(t){return this.query.sort_order=t,this}days(t){let{start:e,end:r}=(t=>{let e=new Date,r=new Date;return r.setDate(r.getDate()-t),{start:r.toISOString().split("T")[0],end:e.toISOString().split("T")[0]}})(t);return this.query.start_date=e,this.query.end_date=r,this}then(t,e){return p(this.config,this.query).then(t,e)}},ti=class extends ta{constructor(t){super(t,"","",""),this.query.sort_by="bandwidth"}updateConfig(t){this.config=t}customDates(t,e){return t&&(this.query.start_date=t),e&&(this.query.end_date=e),this}from(t){return this.query.gateway_domain=t,this}},tn=class{constructor(t,e){this.requestCount=0,this.lastRequestTime=0,this.MAX_REQUESTS_PER_MINUTE=30,this.MINUTE_IN_MS=6e4,this.config=t,this.query=e}cid(t){return this.query.cid=t,this}fileName(t){return this.query.file_name=t,this}userAgent(t){return this.query.user_agent=t,this}country(t){return this.query.country=t,this}region(t){return this.query.region=t,this}referer(t){return this.query.referer=t,this}limit(t){return this.query.limit=t,this}sort(t){return this.query.sort_order=t,this}async getAnalytics(){throw Error("getAnalytics method must be implemented in derived class")}then(t,e){return this.getAnalytics().then(t,e)}},to=class extends ta{constructor(t){super(t,"","",""),this.query.sort_by="requests"}updateConfig(t){this.config=t}customDates(t,e){return t&&(this.query.start_date=t),e&&(this.query.end_date=e),this}from(t){return this.query.gateway_domain=t,this}},ts=class extends tn{constructor(t,e,r,a,i){super(t,{gateway_domain:e,start_date:r,end_date:a,date_interval:i})}sortBy(t){return this.query.sort_by=t,this}async getAnalytics(){return h(this.config,this.query)}async all(){return this.getAnalytics()}},tu=class{constructor(t,e){this.query={},this.config=t,this.privacy=e}name(t){return this.query.name=t,this}limit(t){return this.query.limit=t,this}isPublic(t){return this.query.isPublic=t,this}pageToken(t){return this.query.pageToken=t,this}then(t,e){return this.fetchPage().then(t=>(this.nextPageToken=t.next_page_token,t)).then(t,e)}
1async fetchPage(){return this.nextPageToken&&(this.query.pageToken=this.nextPageToken),j(this.config,this.privacy,this.query)}async *[Symbol.asyncIterator](){for(;;){let t=await this.fetchPage();for(let e of t.groups)yield e;if(!t.next_page_token)break;this.nextPageToken=t.next_page_token}}async all(){let t=[];for await(let e of this)t.push(e);return t}},tc=class{constructor(t){this.config=l(t)}updateConfig(t){this.config=t}create(t){return q(this.config,t,"public")}list(){return new tu(this.config,"public")}get(t){return b(this.config,t,"public")}addFiles(t){return O(this.config,t,"public")}removeFiles(t){return C(this.config,t,"public")}update(t){return z(this.config,t,"public")}delete(t){return S(this.config,t,"public")}},tl=class{constructor(t){this.config=l(t)}updateConfig(t){this.config=t}create(t){return q(this.config,t,"private")}list(){return new tu(this.config,"private")}get(t){return b(this.config,t,"private")}addFiles(t){return O(this.config,t,"private")}removeFiles(t){return C(this.config,t,"private")}update(t){return z(this.config,t,"private")}delete(t){return S(this.config,t,"private")}},td=class{constructor(t){this.config=l(t),this.public=new tc(t),this.private=new tl(t)}updateConfig(t){this.config=t}},th=class{constructor(t){this.config=l(t)}updateConfig(t){this.config=t}create(t){return x(this.config,t)}list(){return new tp(this.config)}revoke(t){return I(this.config,t)}},tp=class{constructor(t){this.query={},this.config=t}offset(t){return this.query.offset=t,this}revoked(t){return this.query.revoked=t,this}limitedUse(t){return this.query.limitedUse=t,this}exhausted(t){return this.query.exhausted=t,this}name(t){return this.query.name=t,this}then(t,e){return J(this.config,this.query).then(t,e)}async *[Symbol.asyncIterator](){let t=!0,e=0;for(;t;){this.query.offset=e;let r=await J(this.config,this.query);for(let t of r)yield t;0===r.length?t=!1:e+=r.length}}async all(){let t=[];for await(let e of this)t.push(e);return t}},tw=class{constructor(t){this.config=l(t),this.public=new ty(t),this.private=new tm(t)}updateConfig(t){this.config=t}},tf=class{constructor(t,e){this.imgOpts={},this.config=t,this.urlOpts=e}optimizeImage(t){return this.imgOpts={...this.imgOpts,...t},this}then(t,e){return v(this.config,this.urlOpts,this.imgOpts).then(t,e)}},tg=class{constructor(t,e,r){this.options={},this.config=t,this.cid=e,this.gatewayType=r}optimizeImage(t){return this.options={...this.options,...t},this}then(t,e){return P(this.config,this.cid,this.gatewayType,this.options).then(t,e)}},tm=class{constructor(t){this.config=t}get(t){return new tg(this.config,t,"files")}createAccessLink(t){return new tf(this.config,t)}},ty=class{constructor(t){this.config=t}get(t){return new tg(this.config,t,"ipfs")}convert(t,e){return _(this.config,t,e)}},tT=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/getFile"};let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}/files/${r}/${e}`,{method:"GET",headers:s});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing getGroup: ${t.message}`);throw new a("An unknown error occurred while getting info for a group")}},t$=class{constructor(t,e){this.query={},this.config=t,this.privacy=e}name(t){return this.query.name=t,this}group(t){return this.query.group=t,this}cid(t){return this.query.cid=t,this}mimeType(t){return this.query.mimeType=t,this}order(t){return this.query.order=t,this}limit(t){return this.query.limit=t,this}cidPending(t){return this.query.cidPending=t,this}keyvalues(t){return this.query.metadata=t,this}noGroup(t){return this.query.noGroup=t,this}pageToken(t){return this.query.pageToken=t,this}then(t,e){return this.fetchPage().then(t,e)}
1async fetchPage(){this.currentPageToken&&(this.query.pageToken=this.currentPageToken);let t=await T(this.config,this.privacy,this.query);return this.currentPageToken=t.next_page_token,t}async *[Symbol.asyncIterator](){for(;;){for(let t of(await this.fetchPage()).files)yield t;if(!this.currentPageToken)break}}async all(){let t=[];for await(let e of this)t.push(e);return t}},tR=class{constructor(t){this.query={},this.requestCount=0,this.lastRequestTime=0,this.MAX_REQUESTS_PER_MINUTE=30,this.MINUTE_IN_MS=6e4,this.config=t}cid(t){return this.query.cid=t,this}status(t){return this.query.status=t,this}pageLimit(t){return this.query.limit=t,this}pageToken(t){return this.query.pageToken=t,this}async fetchPage(){this.currentPageToken&&(this.query.pageToken=this.currentPageToken);let t=await E(this.config,this.query);return this.currentPageToken=t.next_page_token,t}sort(t){return this.query.sort=t,this}then(t,e){return E(this.config,this.query).then(t,e)}async rateLimit(){this.requestCount++;let t=Date.now();if(this.requestCount>=this.MAX_REQUESTS_PER_MINUTE){let e=t-this.lastRequestTime;if(e<this.MINUTE_IN_MS){let t=this.MINUTE_IN_MS-e;await new Promise(e=>setTimeout(e,t))}this.requestCount=0}this.lastRequestTime=Date.now()}async *[Symbol.asyncIterator](){for(;;){for(let t of(await this.fetchPage()).jobs)yield t;if(!this.currentPageToken)break}}async all(){let t=[];for await(let e of this)t.push(e);return t}},tH=class{constructor(t){this.config=l(t)}list(){return new t$(this.config,"public")}get(t){return tT(this.config,t,"public")}delete(t){return g(this.config,t,"public")}update(t){return H(this.config,t,"public")}addSwap(t){return $(this.config,t,"public")}getSwapHistory(t){return R(this.config,t,"public")}deleteSwap(t){return y(this.config,t,"public")}queue(){return new tR(this.config)}deletePinRequest(t){return A(this.config,t)}},tk=class{constructor(t){this.config=l(t)}list(){return new t$(this.config,"private")}get(t){return tT(this.config,t,"private")}delete(t){return g(this.config,t,"private")}update(t){return H(this.config,t,"private")}addSwap(t){return $(this.config,t,"private")}getSwapHistory(t){return R(this.config,t,"private")}deleteSwap(t){return y(this.config,t,"private")}vectorize(t){return k(this.config,t)}queryVectors(t){return U(this.config,t)}deleteVectors(t){return m(this.config,t)}},tU=class{constructor(t){this.config=l(t),this.public=new tH(t),this.private=new tk(t)}updateConfig(t){this.config=t}},tE=class{constructor(t,e,...r){this.metadata={},this.config=t,this.uploadFunction=e,this.args=r}name(t){return this.metadata||(this.metadata={}),this.metadata.name=t,this}keyvalues(t){return this.metadata||(this.metadata={}),this.metadata.keyvalues=t,this}key(t){return this.keys=t,this}vectorize(){return this.vector=!0,this}url(t){return this.uploadUrl=t,this}cidVersion(t){return this._cidVersion=t,this}group(t){return this.groupId=t,this}streamable(){return this.isStreamable=!0,this}car(){return this.carFormat=!0,this}peerAddress(t){return this.peerAddresses=t,this}then(t,e){let r=this.args[this.args.length-1]||{};return this.metadata&&(r.metadata=this.metadata),this.keys&&(r.keys=this.keys),this.groupId&&(r.groupId=this.groupId),this.vector&&(r.vectorize=this.vector),this.uploadUrl&&(r.url=this.uploadUrl),this.isStreamable&&(r.streamable=this.isStreamable),this.peerAddresses&&(r.peerAddresses=this.peerAddresses),this.carFormat&&(r.car=this.carFormat),void 0!==this._cidVersion&&(r.cid_version=this._cidVersion),this.args[this.args.length-1]=r,this.uploadFunction(this.config,...this.args).then(t,e)}},tA=class{constructor(t){this.config=l(t)}updateConfig(t){this.config=t}file(t,e){return new tE(this.config,(t,e,r)=>G(t,e,"public",r),t,e)}fileArray(t,e){return new tE(this.config,(t,e,r)=>M(t,e,"public",r),t,e)}base64(t,e){return new tE(this.config,(t,e,r)=>D(t,e,"public",r),t,e)}url(t,e){return new tE(this.config,(t,e,r)=>L(t,e,"public",r),t,e)}json(t,e){return new tE(this.config,(t,e,r)=>F(t,e,"public",r),t,e)}cid(t,e){return new tE(this.config,(t,e,r)=>V(t,e,r),t,e)}createSignedURL(t){return N(this.config,t,"public")}},tP=class{constructor(t){this.config=l(t)}updateConfig(t){this.config=t}file(t,e){return new tE(this.config,(t,e,r)=>G(t,e,"private",r),t,e)}base64(t,e){return new tE(this.config,(t,e,r)=>D(t,e,"private",r),t,e)}url(t,e){return new tE(this.config,(t,e,r)=>L(t,e,"private",r),t,e)}json(t,e){return new tE(this.config,(t,e,r)=>F(t,e,"private",r),t,e)}createSignedURL(t){return N(this.config,t,"private")}},t_=class{constructor(t){this.config=l(t),this.public=new tA(t),this.private=new tP(t)}updateConfig(t){this.config=t}},tv=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");let u=JSON.stringify({signature:e.signature,address:e.address});s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/addSignature"};let c="https://api.pinata.cloud/v3";t.endpointUrl&&(c=t.endpointUrl);try{let t=await fetch(`${c}/files/${r}/signature/${e.cid}`,{method:"POST",headers:s,body:u});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});if(403===t.status)throw new a("Unauthorized signing, you must be the original owner of the file and it must not have a signature",t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing addSignature: ${t.message}`);throw new a("An unknown error occurred while adding signature to CID")}},tO=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/getSignature"};let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}/files/${r}/signature/${e}`,{method:"GET",headers:s});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return(await t.json()).data}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing getSignature: ${t.message}`);throw new a("An unknown error occurred while fetching signature for CID")}},tq=async(t,e,r)=>{let s;if(!t)throw new o("Pinata configuration is missing");s=t.customHeaders&&Object.keys(t.customHeaders).length>0?{...t.customHeaders}:{Authorization:`Bearer ${t.pinataJwt}`,"Content-Type":"application/json",Source:"sdk/removeSignature"};let u="https://api.pinata.cloud/v3";t.endpointUrl&&(u=t.endpointUrl);try{let t=await fetch(`${u}/files/${r}/signature/${e}`,{method:"DELETE",headers:s});if(!t.ok){let e=await t.text();if(401===t.status||403===t.status)throw new n(`Authentication failed: ${e}`,t.status,{error:e,code:"AUTH_ERROR",metadata:{requestUrl:t.url}});throw new i(`HTTP error: ${e}`,t.status,{error:e,code:"HTTP_ERROR",metadata:{requestUrl:t.url}})}return"OK"}catch(t){if(t instanceof a)throw t;if(t instanceof Error)throw new a(`Error processing addSignature: ${t.message}`);throw new a("An unknown error occurred while adding signature to CID")}},tS=class{constructor(t){this.config=l(t)}updateConfig(t){this.config=t}add(t){return tv(this.config,t,"public")}get(t){return tO(this.config,t,"public")}delete(t){return tq(this.config,t,"public")}},tb=class{constructor(t){this.config=l(t),this.public=new tS(t)}updateConfig(t){this.config=t}},tj=class{constructor(t){this.config=l(t)}updateConfig(t){this.config=t}listPaymentInstructions(t){return K(this.config,t)}createPaymentInstruction(t){return Z(this.config,t)}getPaymentInstruction(t){return W(this.config,t)}updatePaymentInstruction(t,e){return Q(this.config,t,e)}deletePaymentInstruction(t){return X(this.config,t)}listCids(t,e){return Y(this.config,t,e)}addCid(t,e){return tt(this.config,t,e)}removeCid(t,e){return te(this.config,t,e)}},tC=class{constructor(t){this.config=l(t),this.files=new tU(this.config),this.upload=new t_(this.config),this.gateways=new tw(this.config),this.keys=new th(this.config),this.groups=new td(this.config),this.analytics=new tr(this.config),this.signatures=new tb(this.config),this.x402=new tj(this.config)}setNewHeaders(t){this.config||(this.config={pinataJwt:"",customHeaders:{}}),this.config.customHeaders={...this.config.customHeaders,...t},this.files.updateConfig(this.config),this.upload.updateConfig(this.config),this.gateways.updateConfig(this.config),this.keys.updateConfig(this.config),this.groups.updateConfig(this.config),this.analytics.updateConfig(this.config),this.signatures.updateConfig(this.config),this.x402.updateConfig(this.config)}setNewJwt(t){this.config||(this.config={pinataJwt:""}),this.config.pinataJwt=t,this.files.updateConfig(this.config),this.upload.updateConfig(this.config),this.gateways.updateConfig(this.config),this.keys.updateConfig(this.config),this.groups.updateConfig(this.config),this.analytics.updateConfig(this.config),this.signatures.updateConfig(this.config),this.x402.updateConfig(this.config)}testAuthentication(){return w(this.config)}}},13090:(t,e,r)=>{r.d(e,{Ay$:()=>a});let a=r(23613)},17729:(t,e,r)=>{r.d(e,{Z:()=>i});var a=r(57727);function i(t){let e=a.useRef({value:t,previous:t});return a.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}},23342:(t,e,r)=>
1{Object.defineProperty(e,"__esModule",{value:!0}),!function(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:e[r]})}(e,{callServer:function(){return a.callServer},createServerReference:function(){return n.createServerReference},findSourceMapURL:function(){return i.findSourceMapURL}});let a=r(11193),i=r(71617),n=r(78345)},26999:(t,e,r)=>{r.d(e,{jH:()=>n});var a=r(57727);r(73559);var i=a.createContext(void 0);function n(t){let e=a.useContext(i);return t||e||"ltr"}},97103:(t,e,r)=>{r.d(e,{C:()=>s,J:()=>o});var a=r(57727),i=r(64624);let n=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M228,144v64a12,12,0,0,1-12,12H40a12,12,0,0,1-12-12V144a12,12,0,0,1,24,0v52H204V144a12,12,0,0,1,24,0ZM96.49,80.49,116,61v83a12,12,0,0,0,24,0V61l19.51,19.52a12,12,0,1,0,17-17l-40-40a12,12,0,0,0-17,0l-40,40a12,12,0,1,0,17,17Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,48V208H40V48A16,16,0,0,1,56,32H200A16,16,0,0,1,216,48Z",opacity:"0.2"}),a.createElement("path",{d:"M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0ZM93.66,77.66,120,51.31V144a8,8,0,0,0,16,0V51.31l26.34,26.35a8,8,0,0,0,11.32-11.32l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,93.66,77.66Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0ZM88,80h32v64a8,8,0,0,0,16,0V80h32a8,8,0,0,0,5.66-13.66l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,88,80Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M222,144v64a6,6,0,0,1-6,6H40a6,6,0,0,1-6-6V144a6,6,0,0,1,12,0v58H210V144a6,6,0,0,1,12,0ZM92.24,76.24,122,46.49V144a6,6,0,0,0,12,0V46.49l29.76,29.75a6,6,0,0,0,8.48-8.48l-40-40a6,6,0,0,0-8.48,0l-40,40a6,6,0,0,0,8.48,8.48Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0ZM93.66,77.66,120,51.31V144a8,8,0,0,0,16,0V51.31l26.34,26.35a8,8,0,0,0,11.32-11.32l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,93.66,77.66Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M220,144v64a4,4,0,0,1-4,4H40a4,4,0,0,1-4-4V144a4,4,0,0,1,8,0v60H212V144a4,4,0,0,1,8,0ZM90.83,74.83,124,41.66V144a4,4,0,0,0,8,0V41.66l33.17,33.17a4,4,0,1,0,5.66-5.66l-40-40a4,4,0,0,0-5.66,0l-40,40a4,4,0,0,0,5.66,5.66Z"}))]]),o=a.forwardRef((t,e)=>a.createElement(i.A,{ref:e,...t,weights:n}));o.displayName="UploadSimpleIcon";let s=o}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.