1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,618566,(e,t,r)=>{t.exports=e.r(976562)},531278,e=>{"use strict";let t=(0,e.i(475254).default)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);e.s(["Loader2",()=>t],531278)},768834,e=>{"use strict";var t=e.i(271645);let r=e=>{let t,r=new Set,n=(e,n)=>{let i="function"==typeof e?e(t):e;if(!Object.is(i,t)){let e=t;t=(null!=n?n:"object"!=typeof i||null===i)?i:Object.assign({},t,i),r.forEach(r=>r(t,e))}},i=()=>t,o={setState:n,getState:i,getInitialState:()=>a,subscribe:e=>(r.add(e),()=>r.delete(e))},a=t=e(n,i,o);return o},n=e=>{let n=e?r(e):r,i=e=>(function(e,r=e=>e){let n=t.default.useSyncExternalStore(e.subscribe,t.default.useCallback(()=>r(e.getState()),[e,r]),t.default.useCallback(()=>r(e.getInitialState()),[e,r]));return t.default.useDebugValue(n),n})(n,e);return Object.assign(i,n),i},i=e=>e?n(e):n;e.s(["create",()=>i],768834)},450018,e=>{"use strict";let t=(0,e.i(768834).create)()(e=>({isOpen:!1,open:()=>e({isOpen:!0}),close:()=>e({isOpen:!1}),toggle:()=>e(e=>({isOpen:!e.isOpen}))}));e.s(["useCommandPalette",0,t])},463278,e=>{"use strict";let t={post:"app.bsky.feed.post",lists:"app.bsky.graph.list",feed:"app.bsky.feed.generator","starter-pack":"app.bsky.graph.starterpack",labeler:"app.bsky.labeler.service"},r=Object.fromEntries(Object.entries(t).map(([e,t])=>[t,e]));e.s(["DEFAULT_ATPROTO_APPS",0,[{hostname:"bsky.app",name:"Bluesky"},{hostname:"blacksky.community",name:"Blacksky"}],"MAX_CUSTOM_APPS",0,10,"NSID_TO_RECORD_TYPE",0,r,"RECORD_TYPE_MAPPINGS",0,t])},856051,10509,e=>{"use strict";function t(e){try{return decodeURIComponent(e)}catch{return null}}function r(e){let r=[];for(let n of e){let e=t(n);if(null===e)return null;r.push(e)}return r}e.s(["safeDecodePathSegments",()=>r,"safeDecodeURIComponent",()=>t],10509);let n=/^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$/,i=/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/,o=/^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/,a=/^[a-zA-Z0-9._:~-]{1,512}$/;function s(e){return n.test(e)}function l(e){return!(e.length>253)&&i.test(e)}function c(e){return s(e)?e:e.toLowerCase()}function d(e){let t=e.startsWith("at://"),r=t?e.slice(5):e,n=r.indexOf("/"),i=-1===n?r:r.slice(0,n);if(!i||!l(i))return e;let o=i.toLowerCase();return o===i?e:`${t?"at://":""}${o}${-1===n?"":r.slice(n)}`}function u(e){return o.test(e)}function p(e){return a.test(e)}function f(e){return e.startsWith("did:web:")}function h(e){return e.startsWith("did:plc:")}function m(e){return!e.startsWith("at:/")||e.startsWith("at://")?e:`at://${e.slice(4)}`}function y(e){if(!e)return null;let t=e.trim();t.startsWith("at://")||(t=`at://${t}`);let r=t.slice(5).split("/");if(0===r.length||!r[0])return null;let n=r[0];if(!s(n)&&!l(n))return null;let i={raw:t,repo:n};return r.length>1&&r[1]&&(i.collection=r[1]),r.length>2&&r[2]&&(i.rkey=r[2]),i}function g(e){let t,r=e.trim();if(!r)return null;try{t=decodeURIComponent(r)}catch{t=r}let n=/(^|[^A-Za-z0-9+.-])at:\/\/?/.exec(t),i=n?n.index+n[1].length:-1;if(-1===i)return null;let o=t.slice(i),a=o.search(/[?#]/),s=m(-1===a?o:o.slice(0,a));return y(s)?s:null}e.s(["extractAtUriFromUrl",()=>g,"isDid",()=>s,"isHandle",()=>l,"isNsid",()=>u,"isPlcDid",()=>h,"isRkey",()=>p,"isWebDid",()=>f,"normalizeAtUriRepo",()=>d,"normalizeRepo",()=>c,"parseAtUri",()=>y,"repairAtUriScheme",()=>m],856051)},17187,e=>{"use strict";var t=e.i(463278),r=e.i(856051);function n(e){let t=e.trim();return(!!t.startsWith("http://")||!!t.startsWith("https://"))&&t.includes("/profile/")}function i(e,r=[]){let n=function(e,r=[]){let n,i,o=e.trim();if(!o.startsWith("http://")&&!o.startsWith("https://"))return null;try{n=new URL(o)}catch{return null}if(!function(e,r=[]){let n=e.toLowerCase();return(function(e=[]){let r=new Set;for(let e of t.DEFAULT_ATPROTO_APPS)r.add(e.hostname.toLowerCase());for(let t of e)r.add(t.hostname.toLowerCase());return r})(r).has(n)}(n.hostname,r))return null;
1let a=n.pathname.split("/").filter(Boolean);if(a.length<2||"profile"!==a[0])return null;try{i=decodeURIComponent(a[1])}catch{return null}if(2===a.length)return{hostname:n.hostname,actor:i};if(a.length>=4){let e,r=a[2];try{e=decodeURIComponent(a[3])}catch{return{hostname:n.hostname,actor:i}}if(t.RECORD_TYPE_MAPPINGS[r])return{hostname:n.hostname,actor:i,recordType:r,rkey:e}}return{hostname:n.hostname,actor:i}}(e,r);if(!n)return null;let o=`at://${n.actor}`;if(n.recordType&&n.rkey){let e=t.RECORD_TYPE_MAPPINGS[n.recordType];e&&(o+=`/${e}/${n.rkey}`)}return{atUri:o,sourceApp:n.hostname}}function o(e,t=[]){let r=i(e,t);return r?.atUri??null}function a(e,r,n,i){let o=`https://${e}/profile/${r}`;if(n&&i){let e=t.NSID_TO_RECORD_TYPE[n];e&&(o+=`/${e}/${encodeURIComponent(i)}`)}return o}function s(e,t,r,n){let i=e.replace(/\/$/,""),o=new URLSearchParams({repo:t,collection:r,rkey:n});return`${i}/xrpc/com.atproto.repo.getRecord?${o.toString()}`}function l(e=[]){return[...t.DEFAULT_ATPROTO_APPS,...e]}function c(e){let n=(0,r.parseAtUri)(e);return!!n&&(!n.collection||!!n.collection&&!!n.rkey&&n.collection in t.NSID_TO_RECORD_TYPE)}e.s(["appUrlToAtUri",()=>i,"buildAppUrl",()=>a,"buildPdsDirectUrl",()=>s,"canOpenInApp",()=>c,"getAllApps",()=>l,"getAtUriFromAppUrl",()=>o,"looksLikeAppUrl",()=>n])},292197,579473,689058,e=>{"use strict";var t=e.i(768834);let r=e=>t=>{try{let n=e(t);if(n instanceof Promise)return n;return{then:e=>r(e)(n),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>r(t)(e)}}},n=(e,t)=>(n,i,o)=>{let a,s={storage:function(e,t){let r;try{r=e()}catch(e){return}return{getItem:e=>{var t;let n=e=>null===e?null:JSON.parse(e,void 0),i=null!=(t=r.getItem(e))?t:null;return i instanceof Promise?i.then(n):n(i)},setItem:(e,t)=>r.setItem(e,JSON.stringify(t,void 0)),removeItem:e=>r.removeItem(e)}}(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},l=!1,c=0,d=new Set,u=new Set,p=s.storage;if(!p)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...e)},i,o);let f=()=>{let e=s.partialize({...i()});return p.setItem(s.name,{state:e,version:s.version})},h=o.setState;o.setState=(e,t)=>(h(e,t),f());let m=e((...e)=>(n(...e),f()),i,o);o.getInitialState=()=>m;let y=()=>{var e,t;if(!p)return;let o=++c;l=!1,d.forEach(e=>{var t;return e(null!=(t=i())?t:m)});let h=(null==(t=s.onRehydrateStorage)?void 0:t.call(s,null!=(e=i())?e:m))||void 0;return r(p.getItem.bind(p))(s.name).then(e=>{if(e)if("number"!=typeof e.version||e.version===s.version)return[!1,e.state];else{if(s.migrate){let t=s.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;if(o!==c)return;let[r,l]=e;if(n(a=s.merge(l,null!=(t=i())?t:m),!0),r)return f()}).then(()=>{o===c&&(null==h||h(a,void 0),a=i(),l=!0,u.forEach(e=>e(a)))}).catch(e=>{o===c&&(null==h||h(void 0,e))})};return o.persist={setOptions:e=>{s={...s,...e},e.storage&&(p=e.storage)},clearStorage:()=>{null==p||p.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>y(),hasHydrated:()=>l,onHydrate:e=>(d.add(e),()=>{d.delete(e)}),onFinishHydration:e=>(u.add(e),()=>{u.delete(e)})},s.skipHydration||y(),a||m};function i(e,t={}){let r,{allowInsecureWs:n=!0}=t,o=e.trim();if(!o)return{valid:!1,error:"URL is required"};if(o.length>2048)return{valid:!1,error:"URL is too long"};try{r=new URL(o)}catch{return{valid:!1,error:"Invalid URL format"}}return"wss:"!==r.protocol&&"ws:"!==r.protocol?{valid:!1,error:"URL must use ws:// or wss://"}:n||"wss:"===r.protocol?r.username||r.password?{valid:!1,error:"URL must not include credentials"}:r.hostname?(r.hash="",{valid:!0,normalized:r.toString()}):{valid:!1,error:"URL must include a hostname"}:{valid:!1,error:"Only wss:// is allowed for this connection"}}e.s(["persist",()=>n],579473),e.s(["validateWebSocketUrl",()=>i],689058),e.i(17187);var o=e.i(463278),a=e.i(856051);let s={background:"",foreground:"",card:"",cardForeground:"",primary:"",primaryForeground:"",secondary:"",secondaryForeground:"",muted:"",mutedForeground:"",accent:"",accentForeground:"",destructive:"",destructiveForeground:"",border:"",input:"",ring:"",sidebar:"",sidebarForeground:"",brand:""}
1,l={identityProvider:"slingshot",identityFallbackProvider:"dns",slingshotUrl:"",plcDirectoryUrl:"",dohEndpoint:"",pdsUrl:"",useProxyMode:!1,constellationUrl:"",spacedustUrl:"",didectoryUrl:"",didectorySpamFilter:!0,jsonColors:{key:"",string:"",number:"",boolean:"",null:"",bracket:""},enableThreeColumnLayout:!0,breadcrumbStyle:"content",reverseRecords:!1,enableInfiniteScroll:!0,showTimestampOnHover:!0,showLexiconOnHover:!1,lexiconSource:"aggregator",mediaSource:"cdn",customImageCdnUrl:"",customThemeBase:"dark",customThemeColors:s,viewerHistory:[],customJetstreams:[],jetstreamAutoConnect:!0,jetstreamDefaultServer:"",customSpacedusts:[],spacedustAutoConnect:!0,firehoseAutoConnect:!0,collectionDirectorySource:"",customCollectionDirectorySources:[],contrailsUrl:"",labelerRelayUrl:"",customApps:[],defaultOpenInApp:"bsky.app",previewCompact:!1,previewShowAvatar:!0,previewTimestampFormat:"relative",previewMaxEmbedDepth:2,enableGranularPermissions:!1,enableSpaces:!1},c=new Set(["identityFallbackProvider","defaultOpenInApp"]),d=new Map([["identityProvider",e=>"slingshot"===e||"dns"===e||"pds"===e],["identityFallbackProvider",e=>null===e||"slingshot"===e||"dns"===e||"pds"===e],["breadcrumbStyle",e=>"omnibar"===e||"content"===e],["lexiconSource",e=>"aggregator"===e||"dns"===e],["mediaSource",e=>"cdn"===e||"custom"===e||"pds"===e],["previewTimestampFormat",e=>"relative"===e||"absolute"===e||"none"===e],["customThemeBase",e=>"light"===e||"dark"===e],["previewMaxEmbedDepth",e=>"number"==typeof e&&Number.isFinite(e)&&e>=0&&e<=5]]),u=e=>!!e&&"object"==typeof e&&"string"==typeof e.name&&"string"==typeof e.url,p=new Map([["viewerHistory",e=>!!e&&"object"==typeof e&&("uri"===e.type||"search"===e.type)&&"string"==typeof e.value&&"number"==typeof e.timestamp&&(void 0===e.label||"string"==typeof e.label)],["customJetstreams",u],["customSpacedusts",u],["customCollectionDirectorySources",u],["customApps",e=>!!e&&"object"==typeof e&&"string"==typeof e.hostname&&"string"==typeof e.name]]);function f(e,t){let r=t&&"object"==typeof t&&!Array.isArray(t)?t:{},n={};for(let[t,i]of Object.entries(e)){let e=r[t];n[t]="string"==typeof e?e:i}return n}let h=(0,t.create)()(n(e=>({...l,setIdentityProvider:t=>e({identityProvider:t}),setIdentityFallbackProvider:t=>e({identityFallbackProvider:t}),setSlingshotUrl:t=>e({slingshotUrl:t}),setPlcDirectoryUrl:t=>e({plcDirectoryUrl:t}),setDohEndpoint:t=>e({dohEndpoint:t}),setPdsUrl:t=>e({pdsUrl:t}),setUseProxyMode:t=>e({useProxyMode:t}),setConstellationUrl:t=>e({constellationUrl:t}),setSpacedustUrl:t=>e({spacedustUrl:t}),setDidectoryUrl:t=>e({didectoryUrl:t}),setDidectorySpamFilter:t=>e({didectorySpamFilter:t}),setJsonColors:t=>e(e=>({jsonColors:{...e.jsonColors,...t}})),setEnableThreeColumnLayout:t=>e({enableThreeColumnLayout:t}),setBreadcrumbStyle:t=>e({breadcrumbStyle:t}),setReverseRecords:t=>e({reverseRecords:t}),setEnableInfiniteScroll:t=>e({enableInfiniteScroll:t}),setShowTimestampOnHover:t=>e({showTimestampOnHover:t}),setShowLexiconOnHover:t=>e({showLexiconOnHover:t}),setLexiconSource:t=>e({lexiconSource:t}),setMediaSource:t=>e({mediaSource:t}),setCustomImageCdnUrl:t=>e({customImageCdnUrl:t.trim()}),setCustomThemeBase:t=>e({customThemeBase:t}),setCustomThemeColors:t=>e(e=>({customThemeColors:{...e.customThemeColors,...t}})),resetCustomThemeColors:()=>e({customThemeColors:s}),resetToDefaults:()=>e(l),addHistoryEntry:t=>e(e=>{let r={...t,timestamp:Date.now()},n=e.viewerHistory[0];return n&&n.type===r.type&&n.value===r.value?{viewerHistory:[{...n,timestamp:r.timestamp},...e.viewerHistory.slice(1)]}:{viewerHistory:[r,...e.viewerHistory].slice(0,100)}}),removeHistoryEntry:t=>e(e=>({viewerHistory:e.viewerHistory.filter((e,r)=>r!==t)})),removeHistoryEntriesForRepos:t=>e(e=>{let r=new Set(t.filter(Boolean).map(a.normalizeRepo));return 0===r.size?{}:{viewerHistory:e.viewerHistory.filter(e=>{if("uri"!==e.type)return!0;let t=(0,a.parseAtUri)(e.value)?.repo;return!t||!r.has((0,a.normalizeRepo)(t))})}}),clearHistory:()=>e({viewerHistory:[]}),addCustomJetstream:t=>{let r=i(t.url);if(!r.valid||!r.normalized)return!1;let n={...t,url:r.normalized},o=!1;return e(e=>e.customJetstreams.length>=5||e.customJetstreams.some(e=>e.url===n.url)?e:(o=!0,{customJetstreams:[...e.customJetstreams,n]})),o},removeCustomJetstream:t=>e(e=>({customJetstreams:e.customJetstreams.filter(e=>e.url!==t)})),clearCustomJetstreams:()=>e({customJetstreams:[]}),setJetstreamAutoConnect:t=>e({jetstreamAutoConnect:t}),setJetstreamDefaultServer:t=>e({jetstreamDefaultServer:t}),addCustomSpacedust:t=>{let r=i(t.url);if(!r.valid||!r.normalized)return!1;let n={...t,url:r.normalized},o=!1;return e(e=>e.customSpacedusts.length>=5||e.customSpacedusts.some(e=>e.url===n.url)?e:(o=!0,{customSpacedusts:[...e.customSpacedusts,n]})),o},removeCustomSpacedust:t=>e(e=>({customSpacedusts:e.customSpacedusts.filter(e=>e.url!==t)})),clearCustomSpacedusts:()=>e({customSpacedusts:[]}),setSpacedustAutoConnect:t=>e({spacedustAutoConnect:t}),setFirehoseAutoConnect:t=>e({firehoseAutoConnect:t}),setCollectionDirectorySource:t=>e({collectionDirectorySource:t}),addCustomCollectionDirectorySource:t=>{let r=t.url.trim(),n=t.name.trim();if(!r||!n)return!1;try{new URL(r)}catch{return!1}let i=!1;return e(e=>e.customCollectionDirectorySources.length>=5||e.customCollectionDirectorySources.some(e=>e.url===r)?e:(i=!0,{customCollectionDirectorySources:[...e.customCollectionDirectorySources,{name:n,url:r}]})),i},removeCustomCollectionDirectorySource:t=>e(e=>({customCollectionDirectorySources:e.customCollectionDirectorySources.filter(e=>e.url!==t)})),clearCustomCollectionDirectorySources:()=>e({customCollectionDirectorySources:[]}),setContrailsUrl:t=>e({contrailsUrl:t}
1),setLabelerRelayUrl:t=>e({labelerRelayUrl:t}),addCustomApp:t=>{let r=t.hostname.trim().toLowerCase(),n=t.name.trim();if(!r||!n)return!1;let i=!1;return e(e=>e.customApps.length>=o.MAX_CUSTOM_APPS||e.customApps.some(e=>e.hostname.toLowerCase()===r)?e:(i=!0,{customApps:[...e.customApps,{hostname:r,name:n}]})),i},removeCustomApp:t=>e(e=>({customApps:e.customApps.filter(e=>e.hostname.toLowerCase()!==t.toLowerCase())})),clearCustomApps:()=>e({customApps:[]}),setDefaultOpenInApp:t=>e({defaultOpenInApp:t}),setPreviewCompact:t=>e({previewCompact:t}),setPreviewShowAvatar:t=>e({previewShowAvatar:t}),setPreviewTimestampFormat:t=>e({previewTimestampFormat:t}),setPreviewMaxEmbedDepth:t=>e({previewMaxEmbedDepth:Math.max(0,Math.min(5,t))}),setEnableGranularPermissions:t=>e({enableGranularPermissions:t}),setEnableSpaces:t=>e({enableSpaces:t})}),{name:"vayumandala-taproot-settings",version:1,merge:function(e,t){let r=e&&"object"==typeof e&&!Array.isArray(e)?e:{},n={};for(let[e,t]of Object.entries(l)){if("jsonColors"===e||"customThemeColors"===e||!(e in r))continue;let i=r[e];if(!function(e,t,r){let n=d.get(e);return n?n(t):c.has(e)?null===t||"string"==typeof t:Array.isArray(r)?Array.isArray(t):typeof t==typeof r}(e,i,t))continue;let o=p.get(e);n[e]=o&&Array.isArray(i)?i.filter(o):i}return{...t,...n,jsonColors:f(t.jsonColors,r.jsonColors),customThemeColors:f(t.customThemeColors,r.customThemeColors)}},migrate:e=>e}));e.s(["MAX_CUSTOM_COLLECTION_DIRECTORY_SOURCES",0,5,"MAX_CUSTOM_JETSTREAMS",0,5,"MAX_CUSTOM_SPACEDUSTS",0,5,"useSettings",0,h],292197)},735139,199097,e=>{"use strict";let t=["create","update","delete"];function r(e){let r=[...new Set(e.map(e=>e.trim()).filter(Boolean))],n=[];for(let e of r)for(let r of t)n.push(`repo:${e}?action=${r}`);return n}function n(){return`http://127.0.0.1:${window.location.port?window.location.port:"https:"===window.location.protocol?"443":"80"}/auth/callback`}function i(e,t){let i=[...new Set(["atproto","repo:at.atproto.profile","repo:at.atproto.settings","repo:*?action=create","repo:*?action=update","repo:*?action=delete","blob:*/*","rpc:at.atproto.contrails.getEvents?aud=*",...e?r(e):[],...t?.spaces?c:[]])].map(e=>encodeURIComponent(e)).join("+");return"http://localhost?redirect_uri="+encodeURIComponent(n())+"&scope="+i}e.s(["buildAllCollectionScopes",()=>r],199097);let o={read:!0,create:!0,update:!0,delete:!0,write:!0};function a(e){return!!e&&(!!e.read||!!e.create||!!e.update||!!e.delete||!!e.write)}function s(e){return a(e)?{...e,read:!0}:e}function l(e){let t=s(e),r=[];for(let e of(t.read&&(r.push("space:*?authority=*&action=read_self"),r.push("space:*?authority=*&action=read")),[t.create?"create":null,t.update?"update":null,t.delete?"delete":null].filter(e=>null!==e)))r.push(`space:*?authority=*&action=read_self&manage=${e}`);return t.write&&r.push("space:*?authority=*&collection=*&action=create&action=update&action=delete"),[...new Set(r)]}let c=l(o);e.s(["ALL_SPACES_SELECTION",0,o,"AUTH_STORAGE_KEY",0,"vayumandala-taproot-auth","HANDLE_RESOLVER_URL",0,"https://bsky.social","OAUTH_CALLBACK_URL",0,"https://atproto.at/auth/callback","OAUTH_CLIENT_ID",0,"https://atproto.at/api/oauth-client-metadata.json","PERMISSION_MODE_LABELS",0,{basic:{label:"Basic",description:"Browse data and manage your profile"},custom:{label:"Custom",description:"Choose which actions to allow"},"full-access":{label:"All Access",description:"Create, edit, and manage your data"},granular:{label:"Granular",description:"Pick specific collections and actions"}},"READ_SPACES_SELECTION",0,{read:!0},"SCOPES",0,{ATPROTO:"atproto",ATPROTO_PROFILE:"repo:at.atproto.profile",ATPROTO_SETTINGS:"repo:at.atproto.settings",REPO_CREATE:"repo:*?action=create",REPO_UPDATE:"repo:*?action=update",REPO_DELETE:"repo:*?action=delete",BLOB_ALL:"blob:*/*",BLOB_IMAGE:"blob?accept=image/*",BLOB_VIDEO:"blob?accept=video/*",CONTRAILS:"rpc:at.atproto.contrails.getEvents?aud=*"},"buildDevOAuthClientId",()=>i,"buildSpacesScopes",()=>l,"getDevOAuthCallbackUrl",()=>n,"normalizeSpacesSelection",()=>s,"spacesSelectionRequested",()=>a],735139)},989455,e=>{"use strict";e.s(["COMPOSER_LOGIN_PERMISSIONS",0,{createRecords:!0,updateRecords:!1,deleteRecords:!1,uploadMedia:!1},"COMPOSER_UPLOAD_LOGIN_PERMISSIONS",0,{createRecords:!0,updateRecords:!1,deleteRecords:!1,uploadMedia:!0},"COMPOSE_ROUTE",0,"/new","COMPOSE_SHARE_BASE_URL",0,"https://at.new/","FRAGMENT_RECORD_PREFIX",0,"record=","FRAGMENT_VARIABLES_FIELD",0,"vars","MAX_COMPOSE_DRAFTS",0,50,"MAX_DECODED_PAYLOAD_LENGTH",0,1e6,"MAX_ENCODED_PAYLOAD_LENGTH",0,1e5,"PARAM_COLLECTION",0,"collection","PARAM_COLLECTION_ALIAS",0,"type","PARAM_RECORD",0,"record","PARAM_RKEY",0,"rkey","PARAM_SPACE",0,"space","PARAM_SPACE_EDIT",0,"edit","PARAM_SPACE_EDIT_AUTHOR",0,"author","PARAM_SPACE_RECOVER",0,"recover","PARAM_TEXT",0,"text","PARAM_TITLE",0,"title","PARAM_URL",0,"url","PDS_BLOB_UPLOAD_LIMIT_BYTES",0,0x12c00000,"SELF_LABEL_VALUES",0,["porn","sexual","nudity","graphic-media","!no-unauthenticated"]])},870330,137020,776134,e=>{"use strict";var t=e.i(768834),r=e.i(579473),n=e.i(735139);let i=(0,t.create)()((0,r.persist)((e,t)=>({sessions:[],activeSessionDid:null,isInitializing:!0,isLoggingIn:!1,addSession:t=>e(e=>{let r=e.sessions.findIndex(e=>e.did===t.did);if(r>=0){let n=[...e.sessions];return n[r]=t,{sessions:n,activeSessionDid:t.did}}return{sessions:[...e.sessions,t],activeSessionDid:t.did}}),updateSession:(t,r)=>e(e=>({sessions:e.sessions.map(e=>e.did===t?{...e,...r}:e)})),removeSession:t=>e(e=>{let r=e.sessions.filter(e=>e.did!==t),n=e.activeSessionDid===t?r.length>0?r[0].did:null:e.activeSessionDid;return{sessions:r,activeSessionDid:n}}),setActiveSession:t=>e(e=>t&&!e.sessions.some(e=>e.did===t)?e:{activeSessionDid:t}),clearAllSessions:()=>e({sessions:[],activeSessionDid:null}),setIsInitializing:t=>e({isInitializing:t}),setIsLoggingIn:t=>e({isLoggingIn:t}),getActiveSession:()=>{let e=t();return e.activeSessionDid&&e.sessions.find(t=>t.did===e.activeSessionDid)||null},getSession:e=>t().sessions.find(t=>t.did===e)||null,hasSession:e=>t().sessions.some(t=>t.did===e)}),{name:n.AUTH_STORAGE_KEY,partialize:e=>({sessions:e.sessions,activeSessionDid:e.activeSessionDid})}));function o(){return i(e=>e.activeSessionDid&&e.sessions.find(t=>t.did===e.activeSessionDid)||null)}function a(){return i(e=>e.sessions)}function s(){return i(e=>e.sessions.length>0)}e.s(["useActiveSession",()=>o,"useAuth",0,i,"useIsLoggedIn",()=>s,"useSessions",()=>a],870330);var l=e.i(989455);let c=(0,t.create)()((0,r.persist)(e=>({drafts:[],activeDraftId:null,saveDraft:t=>{let r=t.id??("u">typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`draft-${Date.now()}-${Math.random().toString(36).slice(2,10)}`),n=Date.now();return e(e=>{let i=e.drafts.find(e=>e.id===r);return{drafts:[{id:r,collection:t.collection,rkey:t.rkey,json:t.json,createdAt:i?.createdAt??n,updatedAt:n},...e.drafts.filter(e=>e.id!==r)].slice(0,l.MAX_COMPOSE_DRAFTS),activeDraftId:r}}),r},deleteDraft:t=>e(e=>({drafts:e.drafts.filter(e=>e.id!==t),activeDraftId:e.activeDraftId===t?null:e.activeDraftId})),clearDrafts:()=>e({drafts:[],activeDraftId:null}),setActiveDraft:t=>e(e=>t&&!e.drafts.some(e=>e.id===t)?e:{activeDraftId:t})}),{name:"vayumandala-taproot-drafts",partialize:e=>({drafts:e.drafts,activeDraftId:e.activeDraftId})}));e.s(["useDrafts",0,c],137020);let d=(0,t.create)((e,t)=>({eventsByTarget:new Map,addEvent:(t,r)=>
1{e(e=>{let n=new Map(e.eventsByTarget),i=n.get(t)||[];if(i.some(e=>e.sourceRecord===r.sourceRecord))return e;let o=[r,...i].slice(0,1e3);for(n.delete(t),n.set(t,o);n.size>20;){let e=n.keys().next().value;if(void 0===e)break;n.delete(e)}return{eventsByTarget:n}})},getEvents:e=>t().eventsByTarget.get(e)||[],clearEvents:t=>{e(e=>{let r=new Map(e.eventsByTarget);return r.delete(t),{eventsByTarget:r}})},clearAll:()=>{e({eventsByTarget:new Map})}}));e.s(["useSpacedustStore",0,d],776134)},28856,e=>{"use strict";e.i(292197),e.i(870330),e.i(137020),e.i(776134),e.i(450018),e.s([])},137129,e=>{"use strict";e.s(["BSKY_IMAGE_CDN",0,"https://cdn.bsky.app","BSKY_PUBLIC_API",0,"https://public.api.bsky.app","BSKY_VIDEO_CDN",0,"https://video.cdn.bsky.app"])},352553,e=>{"use strict";class t extends Error{maxBytes;actualBytes;constructor(e,t){super(`Upstream response exceeds ${function(e){return e>=1048576?`${Math.floor(e/1048576)} MB`:e>=1024?`${Math.floor(e/1024)} KB`:`${e} bytes`}(e)} limit`),this.maxBytes=e,this.actualBytes=t,this.name="UpstreamResponseTooLargeError"}}function r(){return 8388608}async function n(e,r){let n=function(e){if(!e)return;let t=Number.parseInt(e,10);if(Number.isFinite(t)&&!(t<0))return t}(e.headers?.get("content-length")??null);if(void 0!==n&&n>r)throw e.body&&e.body.cancel().catch(()=>void 0),new t(r,n);if(e.body){let n=e.body.getReader(),i=[],o=0;for(;;){let{done:e,value:a}=await n.read();if(e)break;if((o+=a.byteLength)>r)throw n.cancel().catch(()=>void 0),new t(r,o);i.push(a)}let a=new Uint8Array(o),s=0;for(let e of i)a.set(e,s),s+=e.byteLength;return new TextDecoder().decode(a)}if("function"==typeof e.text){let n=await e.text(),i=new TextEncoder().encode(n).byteLength;if(i>r)throw new t(r,i);return n}return null}async function i(e,t=r()){let o=await n(e,t);if(null!==o)return JSON.parse(o);if("function"==typeof e.json)return e.json();throw Error("Response has no readable body")}async function o(e,t=r()){let i=await n(e,t);if(null!==i)return i;throw Error("Response has no readable body")}e.s(["UpstreamResponseTooLargeError",()=>t,"WELL_KNOWN_MAX_BYTES",0,8192,"getMaxUpstreamJsonBytes",()=>r,"readJsonWithLimit",()=>i,"readTextWithLimit",()=>o])},892789,147696,691743,e=>{"use strict";e.i(247167);let t="https://plc.directory";e.s(["DEFAULT_DOH_ENDPOINT",0,"https://cloudflare-dns.com/dns-query","DEFAULT_PLC_DIRECTORY",0,t,"SLINGSHOT_ENDPOINT",0,"https://slingshot.microcosm.blue"],147696);var r=e.i(885128),n=e.i(104072),i=e.i(352553);let o=new Map,a=new Map,s=new Map,l=new Map;function c(e){let t=o.get(e);if(t&&t.expires>Date.now())return t.value}function d(e,t){let r=t?3e5:3e4;o.set(e,{value:t,expires:Date.now()+r})}function u(e){return s.get(e)}function p(e,t){s.set(e,t)}function f(e){s.delete(e)}function h(e){let t=a.get(e);if(t&&t.expires>Date.now())return t.value}function m(e,t){let r=t?3e5:3e4;a.set(e,{value:t,expires:Date.now()+r})}function y(e){return l.get(e)}function g(e,t){l.set(e,t)}function v(e){l.delete(e)}function w(e){if(!Array.isArray(e.service))return null;let t=e.service.find(t=>t?.type==="AtprotoPersonalDataServer"||t?.id==="#atproto_pds"||t?.id===`${e.id}#atproto_pds`);if("string"!=typeof t?.serviceEndpoint)return null;let n=(0,r.validatePdsUrl)(t.serviceEndpoint);return n.valid&&n.normalized?n.normalized:null}function A(e){if(!Array.isArray(e.service))return null;let t=e.service.find(t=>t?.type==="AtprotoLabeler"||t?.id==="#atproto_labeler"||t?.id===`${e.id}#atproto_labeler`);if("string"!=typeof t?.serviceEndpoint)return null;let n=(0,r.validatePdsUrl)(t.serviceEndpoint);return n.valid&&n.normalized?n.normalized:null}function S(e){if(!Array.isArray(e.verificationMethod))return null;let t=e.verificationMethod.find(t=>(t?.id==="#atproto"||t?.id===`${e.id}#atproto`)&&(!t.controller||t.controller===e.id));return t?.publicKeyMultibase&&"string"==typeof t.publicKeyMultibase?t.publicKeyMultibase.startsWith("did:key:")?t.publicKeyMultibase:`did:key:${t.publicKeyMultibase}`:null}function D(e){if(!Array.isArray(e.alsoKnownAs))return null;for(let t of e.alsoKnownAs)if("string"==typeof t&&t.startsWith("at://"))return t.slice(5);return null}async function b(e,o=t,a={}){if(!a.forceRefresh){let t=h(e);if(void 0!==t)return t;let r=y(e);if(r)return r}let s=()=>{a.forceRefresh||y(e)!==l||m(e,null)},l=(async()=>{try{let t,a;if(e.startsWith("did:plc:"))t=`${o}/${e}`;
1else{if(!e.startsWith("did:web:"))return console.error("[Identity] Unsupported DID method",{did:e}),null;let r=e.slice(8).split(":"),n=r[0].replace(/%3A/g,":").replace(/%2F/g,"/"),i=r.slice(1).join("/");if(!n.split(":")[0].includes("."))return console.error("[Identity] Blocked did:web with a non-FQDN (single-label) host",{did:e}),null;t=i?`https://${n}/${i}/did.json`:`https://${n}/.well-known/did.json`}if(!(0,r.validatePdsUrl)(t,{allowHttpLoopback:!1}).valid)return console.error("[Identity] Blocked DID document fetch to disallowed host",{did:e,url:t}),null;let c=new AbortController,d=setTimeout(()=>c.abort(),n.DEFAULT_TIMEOUT_MS);try{let r=await fetch(t,{headers:(0,n.withUserAgent)({Accept:"application/did+json, application/did+ld+json, application/json;q=0.9"}),redirect:"manual",cache:"no-store",signal:c.signal});if(!r.ok)return console.error("[Identity] DID document fetch failed",{did:e,url:t,status:r.status}),s(),null;a=await (0,i.readJsonWithLimit)(r,(0,i.getMaxUpstreamJsonBytes)())}finally{clearTimeout(d)}if(!a||"object"!=typeof a||"string"!=typeof a.id)return console.error("[Identity] Invalid DID document",{did:e}),s(),null;let u=a;if(u.id!==e)return console.error("[Identity] DID document id mismatch",{requested:e,returned:u.id}),s(),null;return y(e)===l&&m(e,u),u}catch(t){return console.error("[Identity] DID document resolution failed",{did:e,error:t}),s(),null}})();return g(e,l),l.finally(()=>{y(e)===l&&v(e)}),l}async function E(e,t){let r=await b(e,t);return r?w(r):null}e.s(["clearPendingDidDocResolution",()=>v,"clearPendingHandleResolution",()=>f,"getCachedDidDocument",()=>h,"getCachedHandle",()=>c,"getPendingDidDocResolution",()=>y,"getPendingHandleResolution",()=>u,"setCachedDidDocument",()=>m,"setCachedHandle",()=>d,"setPendingDidDocResolution",()=>g,"setPendingHandleResolution",()=>p],691743),e.s(["extractHandleFromDocument",()=>D,"extractLabelerFromDocument",()=>A,"extractPdsFromDocument",()=>w,"extractSigningKeyFromDocument",()=>S,"resolveDidDocument",()=>b,"resolvePds",()=>E],892789)},33949,e=>{"use strict";var t=e.i(620196);let r=/^did:[a-z]+:[A-Za-z0-9._%:-]+$/,n=/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/,i=/^[A-Za-z0-9._~:@!$&'()*+,;=%-]{1,512}$/;function o(e){return r.test(e)?{raw:e,isDid:!0}:n.test(e)?{raw:e,isDid:!1}:null}function a(e){return{kind:"invalid",reason:e}}function s(e){let r=e.trim(),n=r.match(/^at:\/{1,2}/);if(!n)return a("Not an at:// identifier.");let s=r.slice(n[0].length);if(s.endsWith("/")&&(s=s.slice(0,-1)),0===s.length)return a("Missing authority.");let l=s.split("/");if(l.some(e=>0===e.length))return a("Empty path segment.");let c=o(l[0]);if(!c)return a(`"${l[0]}" is not a DID or a handle.`);
1if("space"===l[1]){if(4!==l.length&&7!==l.length)return a(`A space URI has 4 segments and a space record has 7; got ${l.length}.`);let e=l[2],r=l[3];if(!(0,t.isValidNsid)(e))return a(`"${e}" is not a valid space type NSID.`);if(!i.test(r))return a(`"${r}" is not a valid space key.`);let n=`at://${c.raw}/space/${e}/${r}`;if(4===l.length)return{kind:"space",authority:c,spaceType:e,skey:r,uri:n};let s=o(l[4]);if(!s)return a(`"${l[4]}" is not a valid author DID or handle.`);if(!s.isDid)return a(`Space record author "${l[4]}" must be a DID, not a handle.`);let d=l[5],u=l[6];return(0,t.isValidNsid)(d)?i.test(u)?{kind:"space-record",authority:c,spaceType:e,skey:r,author:s,collection:d,rkey:u,space:n,uri:`${n}/${s.raw}/${d}/${u}`}:a(`"${u}" is not a valid record key.`):a(`"${d}" is not a valid collection NSID.`)}if(l.length>3)return a("Too many segments for an at-uri (and no /space/ marker for a space URI).");let d=l[1],u=l[2];if(void 0!==d&&!(0,t.isValidNsid)(d))return a(`"${d}" is not a valid collection NSID.`);if(void 0!==u&&!i.test(u))return a(`"${u}" is not a valid record key.`);let p=`at://${c.raw}`;return d&&(p+=`/${d}`),u&&(p+=`/${u}`),{kind:"at-uri",authority:c,collection:d,rkey:u,uri:p}}function l(e,t,r){return`at://${e}/space/${t}/${r}`}function c(e,t,r,n){return`${e}/${t}/${r}/${n}`}e.s(["formatSpaceRecordUri",()=>c,"formatSpaceUri",()=>l,"parseAtIdentifier",()=>s])},395588,e=>{"use strict";let t={e701:{bytes:[231,1],name:"secp256k1",curve:"k256"},8024:{bytes:[128,36],name:"P-256",curve:"p256"},ed01:{bytes:[237,1],name:"Ed25519",curve:"ed25519"},8124:{bytes:[129,36],name:"P-384",curve:"p384"},8224:{bytes:[130,36],name:"P-521",curve:"p521"},8524:{bytes:[133,36],name:"RSA",curve:"rsa"}},r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function n(e){if(33!==e.length||2!==e[0]&&3!==e[0])throw Error(`Not a compressed P-256 point: expected 33 bytes with a 0x02/0x03 prefix, got ${e.length} bytes`+(e.length>0?` starting 0x${e[0].toString(16).padStart(2,"0")}`:""));let n=t["8024"].bytes,i=new Uint8Array(n.length+e.length);return i.set(n,0),i.set(e,n.length),`did:key:z${function(e){let t=0;for(;t<e.length&&0===e[t];)t++;let n=[];for(let r=t;r<e.length;r++){let t=e[r];for(let e=0;e<n.length;e++)t+=256*n[e],n[e]=t%58,t=Math.floor(t/58);for(;t>0;)n.push(t%58),t=Math.floor(t/58)}let i="1".repeat(t);for(let e=n.length-1;e>=0;e--)i+=r[n[e]];return i}(i)}`}function i(e){let n={valid:!1,keyType:null,curve:null,validForRotation:!1,publicKeyHex:null,error:null};if(!e.startsWith("did:key:z"))return n.error="Invalid did:key format (must start with did:key:z)",n;let i=e.slice(8);if(!i.startsWith("z"))return n.error="Invalid multibase prefix (expected 'z' for base58btc)",n;try{let e=function(e){let t=[];for(let n of e){let e=r.indexOf(n);if(-1===e)throw Error(`Invalid base58 character: ${n}`);let i=e;for(let e=0;e<t.length;e++)i+=58*t[e],t[e]=255&i,i>>=8;for(;i>0;)t.push(255&i),i>>=8}for(let r of e)if("1"===r)t.push(0);else break;return new Uint8Array(t.reverse())}(i.slice(1));if(e.length<2)return n.error="Key too short",n;let o=t[Array.from(e.slice(0,2)).map(e=>e.toString(16).padStart(2,"0")).join("")];if(o){let t=e.slice(2),r="k256"===o.curve||"p256"===o.curve?33:null;if(null!==r){if(t.length!==r)return n.error=`Invalid ${o.name} key length: expected ${r} bytes, got ${t.length}`,n;if(2!==t[0]&&3!==t[0])return n.error=`Invalid ${o.name} compressed-point prefix: 0x${t[0].toString(16).padStart(2,"0")}`,n}n.valid=!0,n.keyType=o.name,n.curve=o.curve,n.validForRotation="k256"===o.curve||"p256"===o.curve,n.publicKeyHex=Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}else n.valid=!0,n.keyType="Unknown",n.curve="unknown",n.publicKeyHex=Array.from(e.slice(2)).map(e=>e.toString(16).padStart(2,"0")).join("")}catch(e){n.error=`Failed to decode: ${e instanceof Error?e.message:"unknown error"}`}return n}function o(e){return i(e).validForRotation}e.s(["formatP256DidKey",()=>n,"isValidRotationKey",()=>o,"parseDidKey",()=>i])},939654,115775,600433,e=>{"use strict";var t=e.i(395588);class r extends Error{status;error;constructor(e,t,r){super(r??t),this.status=e,this.error=t,this.name="XrpcError"}}async function n(e){let t,n=e.status>=500?"UpstreamFailure":"InvalidRequest";try{let r=await e.json();"string"==typeof r.error&&(n=r.error),"string"==typeof r.message&&(t=r.message)}catch{}throw new r(e.status,n,t)}let i=new Set(["CredentialRevoked","JwtExpired","BadJwtCnf","BadSpaceSignature"]);function o(e){return"string"==typeof e&&i.has(e)}async function a(e){try{let t=await e.clone().json();return"string"==typeof t?.error?t.error:null}catch{return null}}function s(e){return e instanceof r&&("NotAuthorized"===e.error||"UserNotAuthorized"===e.error||"AppNotAuthorized"===e.error)}function l(e){return e instanceof r&&"SpaceNotFound"===e.error||e instanceof r&&"SpaceDeleted"===e.error}function c(e){return e instanceof r&&401===e.status}function d(e){return e instanceof r&&"SessionExpired"===e.error}e.s(["XrpcError",()=>r,"errorCodeOf",()=>a,"isAccessDenied",()=>s,"isAuthMissing",()=>c,"isCredentialRejectedCode",()=>o,"isLocalSessionExpired",()=>d,"isSpaceAbsent",()=>l,"throwXrpcError",()=>n],115775);let u="atproto-space";function p(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=atob(t+"=".repeat((4-t.length%4)%4));return Uint8Array.from(r,e=>e.charCodeAt(0))}async function f(){try{let e=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),n=await crypto.subtle.exportKey("jwk",e.publicKey);return{privateKey:e.privateKey,keyId:(0,t.formatP256DidKey)(function(e){if("EC"!==e.kty||"P-256"!==e.crv||!e.x||!e.y)throw new r(500,"SigningKeyGenerationFailed","WebCrypto returned an incomplete public JWK");let t=p(e.x),n=p(e.y);if(32!==t.length||32!==n.length)throw new r(500,"SigningKeyGenerationFailed",`WebCrypto returned a P-256 key with ${t.length}/${n.length}-byte coordinates`);let i=new Uint8Array(33);return i[0]=(1&n[31])==0?2:3,i.set(t,1),i}(n))}}catch(e){if(e instanceof r)throw e;throw new r(500,"SigningKeyGenerationFailed",`WebCrypto could not generate a signing key: ${e instanceof Error?e.message:String(e)}`)}}async function h(e,t){let n,i=void 0===t.audience?`("authorization");keyid="${e.keyId}"`:'("authorization" "atproto-space-audience")',o=await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e.privateKey,new TextEncoder().encode((n=[`"authorization": ${t.authorization.trim()}`],void 0!==t.audience&&n.push(`"atproto-space-audience": ${t.audience.trim()}`),n.push(`"@signature-params": ${i}`),n.join("\n"))));if(64!==o.byteLength)throw new r(500,"SigningFailed",`WebCrypto produced a ${o.byteLength}-byte ECDSA signature; expected 64`);return{authorization:t.authorization,...void 0!==t.audience?{"atproto-space-audience":t.audie
1nce}:{},"signature-input":`${u}=${i}`,signature:`${u}=:${function(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),r="";for(let e of t)r+=String.fromCharCode(e);return btoa(r)}(o)}:`}}function m(e){let t=e.split(".");if(3!==t.length)return null;try{let e=t[1].replace(/-/g,"+").replace(/_/g,"/"),r=atob(e+"=".repeat((4-e.length%4)%4)),n=Uint8Array.from(r,e=>e.charCodeAt(0)),i=new TextDecoder().decode(n),o=JSON.parse(i);return"object"==typeof o&&null!==o?o:null}catch{return null}}e.s(["createSpaceSignatureHeaders",()=>h,"generateSpaceSigningKey",()=>f],939654),e.s(["decodeJwtPayload",()=>m],600433)},26614,3734,939810,e=>{"use strict";e.i(247167);var t=e.i(856051),r=e.i(885128),n=e.i(104072),i=e.i(352553),o=e.i(147696),a=e.i(691743),s=e.i(892789);async function l(e,r){let o=`_atproto.${e}`,a=`${r}?name=${encodeURIComponent(o)}&type=TXT`,s=new AbortController,l=setTimeout(()=>s.abort(),n.DEFAULT_TIMEOUT_MS);try{let e=await fetch(a,{headers:(0,n.withUserAgent)({Accept:"application/dns-json"}),redirect:"manual",cache:"no-store",signal:s.signal});if(!e.ok)return null;let r=await (0,i.readJsonWithLimit)(e,(0,i.getMaxUpstreamJsonBytes)());if(!r||"object"!=typeof r)return null;let o=r.Answer;if(!Array.isArray(o))return null;let l=[];for(let e of o)if(16===e.type&&"string"==typeof e.data){let t=e.data.replace(/^"|"$/g,"");t.startsWith("did=")&&l.push(t)}if(1!==l.length)return null;let c=l[0].slice(4);return(0,t.isDid)(c)?c:null}catch(t){return console.error("[Identity] DNS TXT resolution failed",{handle:e,error:t}),null}finally{clearTimeout(l)}}async function c(e){let o=`https://${e}/.well-known/atproto-did`;if(!(0,r.validatePdsUrl)(o,{allowHttpLoopback:!1}).valid)return null;let a=new AbortController,s=setTimeout(()=>a.abort(),n.DEFAULT_TIMEOUT_MS);try{let e=await fetch(o,{headers:(0,n.withUserAgent)({Accept:"text/plain"}),redirect:"manual",cache:"no-store",signal:a.signal});if(!e.ok)return null;let r=(await (0,i.readTextWithLimit)(e,i.WELL_KNOWN_MAX_BYTES)).trim();if(!(0,t.isDid)(r))return null;return r}catch{return null}finally{clearTimeout(s)}}async function d(e,t=o.DEFAULT_DOH_ENDPOINT){let r=e.startsWith("@")?e.slice(1):e,n=(0,a.getCachedHandle)(r);if(void 0!==n)return n;let i=(0,a.getPendingHandleResolution)(r);if(i)return i;let s=(async()=>{try{let[e,n]=await Promise.allSettled([l(r,t),c(r)]),i="fulfilled"===e.status?e.value:null,o="fulfilled"===n.status?n.value:null,s=i??o;return(0,a.setCachedHandle)(r,s),s}finally{(0,a.clearPendingHandleResolution)(r)}})();return(0,a.setPendingHandleResolution)(r,s),s}async function u(e,r){let n,i=e.startsWith("@")?e.slice(1):e;if((0,t.isDid)(i))n=i;else{if(!(0,t.isHandle)(i))return console.error("[Identity] Invalid identifier format",{identifier:e}),null;let o=await d(i,r.dohEndpoint);if(!o)return console.error("[Identity] Handle resolution failed",{handle:i}),null;n=o}let o=await (0,s.resolveDidDocument)(n,r.plcDirectoryUrl);return o?{did:n,handle:(0,s.extractHandleFromDocument)(o)??((0,t.isHandle)(i)?i:null),pds:(0,s.extractPdsFromDocument)(o)}:{did:n,handle:(0,t.isHandle)(i)?i:null,pds:null}}async function p(e,t,r){let n=`_atproto.${e}`,o=`${r}?name=${encodeURIComponent(n)}&type=TXT`,a=new AbortController,s=setTimeout(()=>a.abort(),5e3);try{let e=await fetch(o,{headers:{Accept:"application/dns-json"},redirect:"manual",cache:"no-store",signal:a.signal});if(!e.ok){let t="opaqueredirect"===e.type||e.status>=300&&e.status<400;return{checked:!0,found:!1,record:n,value:null,resolvedDid:null,valid:!1,isRedirect:t,error:t?"DNS endpoint returned a redirect; refusing to follow":`DNS query failed with status ${e.status}`}}let r=await (0,i.readJsonWithLimit)(e,(0,i.getMaxUpstreamJsonBytes)());if(!r||"object"!=typeof r)return{checked:!0,found:!1,record:n,value:null,resolvedDid:null,valid:!1,isRedirect:!1,error:"Invalid DNS response format"};let s=r.Answer;if(!Array.isArray(s)||0===s.length)return{checked:!0,found:!1,record:n,value:null,resolvedDid:null,valid:!1,isRedirect:!1,error:null};let l=[];for(let e of s)if(16===e.type&&"string"==typeof e.data){let t=e.data.replace(/^"|"$/g,"");t.startsWith("did=")&&l.push(t)}if(l.length>1)return{checked:!0,found:!0,record:n,value:l.join(", "),resolvedDid:null,valid:!1,isRedirect:!1,error:"Multiple did= TXT records foun
1d (ambiguous); handle is invalid"};if(1===l.length){let e=l[0],r=e.slice(4);return{checked:!0,found:!0,record:n,value:e,resolvedDid:r,valid:r===t,isRedirect:!1,error:null}}return{checked:!0,found:!1,record:n,value:null,resolvedDid:null,valid:!1,isRedirect:!1,error:"No did= TXT record found"}}catch(e){return{checked:!0,found:!1,record:n,value:null,resolvedDid:null,valid:!1,isRedirect:!1,error:e instanceof Error&&"AbortError"===e.name?"Request timed out":e instanceof Error?e.message:"DNS query failed"}}finally{clearTimeout(s)}}async function f(e,t){let n=`https://${e}/.well-known/atproto-did`;if(!(0,r.validatePdsUrl)(n,{allowHttpLoopback:!1}).valid)return{checked:!1,found:!1,endpoint:n,resolvedDid:null,valid:!1,statusCode:null,isRedirect:!1,error:"Handle host is not a public address"};let o=new AbortController,a=setTimeout(()=>o.abort(),5e3);try{let e=await fetch(n,{headers:{Accept:"text/plain"},redirect:"manual",cache:"no-store",signal:o.signal});if(!e.ok){let t="opaqueredirect"===e.type||e.status>=300&&e.status<400;return{checked:!0,found:!1,endpoint:n,resolvedDid:null,valid:!1,statusCode:e.status,isRedirect:t,error:t?"Endpoint returned a redirect; refusing to follow":null}}let r=(await (0,i.readTextWithLimit)(e,i.WELL_KNOWN_MAX_BYTES)).trim();if(!r.startsWith("did:"))return{checked:!0,found:!1,endpoint:n,resolvedDid:null,valid:!1,statusCode:e.status,isRedirect:!1,error:"Response is not a valid DID"};let a=r===t;return{checked:!0,found:!0,endpoint:n,resolvedDid:r,valid:a,statusCode:e.status,isRedirect:!1,error:null}}catch(e){return{checked:!0,found:!1,endpoint:n,resolvedDid:null,valid:!1,statusCode:null,isRedirect:!1,error:e instanceof Error&&"AbortError"===e.name?"Request timed out":e instanceof Error?e.message:"HTTP request failed"}}finally{clearTimeout(a)}}e.s(["resolveIdentity",()=>u],26614);let h=/^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*$/,m=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;async function y(e,t,r=o.DEFAULT_DOH_ENDPOINT){let n=e.startsWith("@")?e.slice(1):e,i=function(e){if(!function(e){if(!e||!e.trim()||e.length>253||!h.test(e)||!e.includes("."))return!1;let t=e.split(".");for(let e of t)if(0===e.length||e.length>63)return!1;let r=t[t.length-1];return!/^\d+$/.test(r)}(e)||m.test(e))return!0;let t=e.toLowerCase();return!!("localhost"===t||t.endsWith(".localhost")||t.endsWith(".local")||t.endsWith(".internal"))}(n),[a,s]=await Promise.all([i?Promise.resolve({checked:!1,found:!1,record:`_atproto.${n}`,value:null,resolvedDid:null,valid:!1,isRedirect:!1,error:"Handle is not a public hostname"}):p(n,t,r),i?Promise.resolve({checked:!1,found:!1,endpoint:`https://${n}/.well-known/atproto-did`,resolvedDid:null,valid:!1,statusCode:null,isRedirect:!1,error:"Handle is not a public hostname"}):f(n,t)]),l=a.valid||s.valid;return{handle:n,expectedDid:t,dns:a,http:s,overallValid:l,verifiedAt:Date.now()}}function g(e){return e?e.dns.valid||e.http.valid?"verified":"failed":"pending"}function v(e){return e?e.dns.valid&&e.http.valid?"both":e.dns.valid?"dns":e.http.valid?"http":"none":"none"}function w(e){return e.startsWith("at://")?e.slice(5):e}async function A(e,r=o.DEFAULT_PLC_DIRECTORY){if((0,t.isWebDid)(e)||!(0,t.isPlcDid)(e))return{raw:[],processed:[]};let a=new AbortController,s=setTimeout(()=>a.abort(),n.DEFAULT_TIMEOUT_MS);try{let t=`${r}/${e}/log/audit`,o=await fetch(t,{headers:(0,n.withUserAgent)({Accept:"application/json"}),redirect:"manual",cache:"no-store",signal:a.signal});if(!o.ok)return console.error("[PLC] Failed to fetch audit log",{did:e,url:t,status:o.status}),{raw:[],processed:[]};let s=await (0,i.readJsonWithLimit)(o,(0,i.getMaxUpstreamJsonBytes)());if(!Array.isArray(s))return console.error("[PLC] Invalid audit log response",{did:e,data:s}),{raw:[],processed:[]};let l=[];for(let e=0;e<s.length;e++){let t=e>0?l[e-1]:void 0;l.push(function(e,t){var r;let n,{operation:i}=e,o="plc_tombstone"===i.type?"plc_tombstone":"create"===i.type?"create":"plc_operation",a="plc_tombstone"===o,s="create"===i.type&&!t,l=[],c=[],d={},u={};s&&"create"===i.type?(i.handle&&(l=[`at://${i.handle}`]),i.recoveryKey&&(c=[i.recoveryKey]),i.signingKey&&(d={atproto:i.signingKey}),i.service&&(u={atproto_pds:{type:"AtprotoPersonalDataServer",endpoint:i.service}})):a||(l=i.alsoKnownAs??[],c=i.rotationKeys??[],d=i.verificationMethods??{},u=i.services??{});let p={createdAt:e.createdAt,cid:e.cid,nullified:e.nullified,pdsEndpoint:function(e){if(!e)return null;let t=e.atproto_pds;if(t)return t.endpoint;for(let[,t]of Object.entries(e))if("AtprotoPersonalDataServer"===t.type)return t.endpoint;return null}(u),handles:(r=l)?r.filter(e=>e.startsWith("at://")).map(e=>e.slice(5)):[],alsoKnownAs:l,rotationKeys:c,verificationMethods:d,services:u,prev:i.prev,operationType:o,isLegacyGenesis:s,isTombstone:a,inRecoveryWindow:(n=new Date(e.createdAt).getTime(),Date.now()-n<2592e5),signature:i.sig};return{...p,changes:function(e,t){let r=[];if(!t)return r.push({type:"account_create",description:"Account created"}),r;if(e.isTombstone)return r.push({type:"account_tombstone",description:"Account deactivated (tombstoned)"}),r;let n=t.handles[0],i=e.handles[0];
1n!==i&&(n&&i?r.push({type:"handle_change",description:"Changed primary handle",details:{from:n,to:i}}):i&&!n?r.push({type:"handle_add",description:`Set primary handle: ${i}`,details:{to:i}}):n&&!i&&r.push({type:"handle_remove",description:`Removed primary handle: ${n}`,details:{from:n}}));let o=new Set(t.alsoKnownAs),a=new Set(e.alsoKnownAs),s=n?`at://${n}`:null,l=i?`at://${i}`:null;for(let e of a)e!==l&&e!==s&&(o.has(e)||r.push({type:"handle_add",description:"Added additional handle",details:{to:w(e)}}));for(let e of o)e!==l&&e!==s&&(a.has(e)||r.push({type:"handle_remove",description:"Removed additional handle",details:{from:w(e)}}));e.pdsEndpoint!==t.pdsEndpoint&&(t.pdsEndpoint&&e.pdsEndpoint?r.push({type:"pds_change",description:"PDS migrated",details:{from:t.pdsEndpoint,to:e.pdsEndpoint}}):e.pdsEndpoint?r.push({type:"pds_change",description:`PDS set: ${e.pdsEndpoint}`,details:{to:e.pdsEndpoint}}):t.pdsEndpoint&&r.push({type:"pds_change",description:"PDS removed",details:{from:t.pdsEndpoint}}));let c=new Set(t.rotationKeys),d=new Set(e.rotationKeys);for(let e of d)c.has(e)||r.push({type:"key_add",description:"Rotation key added",details:{key:e}});for(let e of c)d.has(e)||r.push({type:"key_remove",description:"Rotation key removed",details:{key:e}});let u=new Set(Object.keys(t.verificationMethods)),p=new Set(Object.keys(e.verificationMethods));for(let n of p)u.has(n)?e.verificationMethods[n]!==t.verificationMethods[n]&&r.push({type:"verification_add",description:`Verification method updated: ${n}`,details:{key:n}}):r.push({type:"verification_add",description:`Verification method added: ${n}`,details:{key:n}});for(let e of u)p.has(e)||r.push({type:"verification_remove",description:`Verification method removed: ${e}`,details:{key:e}});let f=new Set(Object.keys(t.services)),h=new Set(Object.keys(e.services));for(let n of h)"atproto_pds"!==n&&(f.has(n)?e.services[n].endpoint!==t.services[n].endpoint&&r.push({type:"service_change",description:`Service endpoint changed: ${n}`,details:{key:n,from:t.services[n].endpoint,to:e.services[n].endpoint}}):r.push({type:"service_add",description:`Service added: ${n}`,details:{key:n,to:e.services[n].endpoint}}));for(let e of f)"atproto_pds"!==e&&(h.has(e)||r.push({type:"service_remove",description:`Service removed: ${e}`,details:{key:e,from:t.services[e].endpoint}}));return r}(p,t)}}(s[e],t))}return{raw:s,processed:l}}catch(t){return console.error("[PLC] Error fetching audit log",{did:e,error:t}),{raw:[],processed:[]}}finally{clearTimeout(s)}}function S(e){switch(e){case"account_create":return"bg-success";case"account_tombstone":return"bg-destructive";case"handle_add":case"handle_remove":case"handle_change":return"bg-brand";case"pds_change":return"bg-chart-4";case"key_add":case"key_remove":return"bg-chart-5";default:return"bg-muted-foreground"}}e.s(["getVerificationMethods",()=>v,"getVerificationStatus",()=>g,"verifyHandle",()=>y],3734),e.s(["fetchPlcAuditLogWithRaw",()=>A,"getChangeTypeColor",()=>S],939810)},860555,e=>{"use strict";var t=e.i(147696);e.i(691743);var r=e.i(892789),n=e.i(26614);e.i(3734),e.i(939810),e.i(395588);var i=e.i(104072),o=e.i(352553);async function a(e){let r=e.startsWith("@")?e.slice(1):e,n=new AbortController,a=setTimeout(()=>n.abort(),i.DEFAULT_TIMEOUT_MS);try{let e=`${t.SLINGSHOT_ENDPOINT}/xrpc/blue.microcosm.identity.resolveMiniDoc?identifier=${encodeURIComponent(r)}`,a=await fetch(e,{headers:(0,i.withUserAgent)({Accept:"application/json"}),redirect:"manual",cache:"no-store",signal:n.signal});if(!a.ok)return null;let s=await (0,o.readJsonWithLimit)(a,(0,o.getMaxUpstreamJsonBytes)());if(!s||"object"!=typeof s||"string"!=typeof s.did||"string"!=typeof s.handle||"string"!=typeof s.pds)return null;let l={did:s.did,handle:s.handle,pds:s.pds,signing_key:"string"==typeof s.signing_key?s.signing_key:""};return{did:l.did,handle:"handle.invalid"!==l.handle?l.handle:null,pds:l.pds||null}}catch(e){return console.warn("[Identity] Slingshot resolution failed",{identifier:r,error:e}),null}finally{clearTimeout(a)}}e.i(247167);var s=e.i(885128),l=e.i(856051);async function c(e,t){let r=(0,s.validatePdsUrl)(t,{allowHttpLoopback:!1});if(!r.valid||!r.normalized)return console.error("[Identity] PDS handle resolution: disallowed pdsUrl",{pdsUrl:t}),null;let n=new AbortController,a=setTimeout(()=>n.abort(),i.DEFAULT_TIMEOUT_MS);try{let t=`${r.normalized}/xrpc/com.atproto.identity.resolveHandle?handle=${encodeURIComponent(e)}`,a=await fetch(t,{headers:(0,i.withUserAgent)({Accept:"application/json"}),redirect:"manual",cache:"no-store",signal:n.signal});if(!a.ok)return null;let s=await (0,o.readJsonWithLimit)(a,(0,o.getMaxUpstreamJsonBytes)());if(!s||"object"!=typeof s)return null;return"string"==typeof s.did&&(0,l.isDid)(s.did)?s.did:null}catch(r){return console.error("[Identity] PDS handle resolution failed",{handle:e,pdsUrl:t,error:r}),null}finally{clearTimeout(a)}}async function d(e,t){let n=e.startsWith("@")?e.slice(1):e;if((0,l.isDid)(n)){let e=await (0,r.resolveDidDocument)(n,t.plcDirectoryUrl);return e?{did:n,handle:(0,r.extractHandleFromDocument)(e),pds:(0,r.extractPdsFromDocument)(e)}:null}if((0,l.isHandle)(n)){if(!t.pdsUrl)return console.error("[Identity] PDS provider: no pdsUrl configured for handle resolution"),null;let e=await c(n,t.pdsUrl);if(!e)return null;let i=await (0,r.resolveDidDocument)(e,t.plcDirectoryUrl);return{did:e,handle:i?(0,r.extractHandleFromDocument)(i)??n:n,pds:i?(0,r.extractPdsFromDocument)(i):null}}return null}let u={provider:"slingshot",fallbackProvider:"dns",plcDirectoryUrl:t.DEFAULT_PLC_DIRECTORY,dohEndpoint:t.DEFAULT_DOH_ENDPOINT};function p(e){if(!e)return;let t=(0,s.validatePdsUrl)(e);if(t.valid&&t.normalized)return t.normalized}async function f(e,t,r){switch(t){case"dns":return n.resolveIdentity(e,r);case"slingshot":return a(e);case"pds":return d(e,r);default:return null}}async function h(e,r=u){let n={provider:r.provider,fallbackProvider:"fallbackProvider"in r?r.fallbackProvider:u.fallbackProvider,plcDirectoryUrl:r.plcDirectoryUrl??t.DEFAULT_PLC_DIRECTORY,dohEndpoint:r.dohEndpoint??t.DEFAULT_DOH_ENDPOINT,pdsUrl:p(r.pdsUrl)},i=await f(e,n.provider,n),o=i?p(i.pds):void 0;if((!i||!o)&&n.fallbackProvider){let t=await f(e,n.fallbackProvider,n);if(t){let e=p(t.pds);i&&e&&i.did===t.did?i={...i,pds:t.pds}:i?e&&(i=t):i=t}}return i?{...i,pds:p(i.pds)??null}:null}async function m(e){return h(e,u)}function y(e){let r=p(e.pdsUrl);
1return{provider:e.identityProvider,fallbackProvider:e.identityFallbackProvider??void 0,plcDirectoryUrl:e.plcDirectoryUrl||t.DEFAULT_PLC_DIRECTORY,dohEndpoint:e.dohEndpoint||t.DEFAULT_DOH_ENDPOINT,pdsUrl:r}}e.s(["buildConfigFromSettings",()=>y,"resolveIdentity",()=>m,"resolveIdentityWithConfig",()=>h],860555)},957667,e=>{"use strict";var t=e.i(856051),r=e.i(939654),n=e.i(600433),i=e.i(115775),o=e.i(33949),a=e.i(860555);async function s(e){try{let t=await (0,a.resolveIdentity)(e);return t?{did:t.did,pds:t.pds??null}:null}catch(t){return console.error("[spaces] resolveSpaceAuthority failed",{actor:e,error:t}),null}}let l="credentials";function c(){return"u"<typeof indexedDB?Promise.resolve(null):new Promise((e,t)=>{let r;try{r=indexedDB.open("vayumandala-taproot-spaces",1)}catch(e){t(e instanceof Error?e:new i.XrpcError(500,"IndexedDbUnavailable","indexedDB.open threw"));return}r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(l)||e.createObjectStore(l)};let n=!1;r.onsuccess=()=>{n?r.result.close():(n=!0,e(r.result))},r.onerror=()=>{n=!0,t(r.error??new i.XrpcError(500,"IndexedDbOpenFailed","Could not open the store"))},r.onblocked=()=>{n=!0,t(new i.XrpcError(500,"IndexedDbBlocked","Another tab is holding an older version of the store open"))}})}async function d(e,t){try{return await c()}catch(r){return console.warn(`[Spaces] Could not open the credential store to ${e}:`,{...t,error:r}),null}}function u(e){let t=()=>e.error??new i.XrpcError(500,"TransactionAborted","IndexedDB transaction aborted");return new Promise((r,n)=>{e.oncomplete=()=>r(),e.onerror=()=>n(t()),e.onabort=()=>n(t())})}async function p(e){let t=await d("read a credential",{id:e});if(!t)return null;try{var r;let n=t.transaction(l,"readonly"),i=await (r=n.objectStore(l).get(e),new Promise((e,t)=>{r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)}));if(void 0===i)return null;if(!(i&&"object"==typeof i&&"string"==typeof i.token&&i.token.length>0&&"number"==typeof i.expiresAt&&Number.isFinite(i.expiresAt)&&i.key&&"object"==typeof i.key&&"u">typeof CryptoKey&&i.key.privateKey instanceof CryptoKey&&"string"==typeof i.key.keyId&&i.key.keyId.startsWith("did:key:z")))return console.warn("[Spaces] Discarding an unusable persisted credential:",{id:e}),null;return i}catch(t){return console.warn("[Spaces] Failed to read persisted credential:",{id:e,error:t}),null}finally{t.close()}}async function f(e,t){let r=await d("persist a credential",{id:e});if(r)try{let n=r.transaction(l,"readwrite");n.objectStore(l).put(t,e),await u(n)}catch(t){console.warn("[Spaces] Failed to persist credential:",{id:e,error:t})}finally{r.close()}}async function h(e){let t=await c();if(t)try{let r=t.transaction(l,"readwrite");r.objectStore(l).delete(e),await u(r)}catch(t){throw console.warn("[Spaces] Failed to delete persisted credential:",{id:e,error:t}),t}finally{t.close()}}async function m(e){let t=await c();if(t)try{let r=t.transaction(l,"readwrite"),n=r.objectStore(l),i=`${e}|`;n.delete(IDBKeyRange.bound(i,`${i}\uffff`)),await u(r)}catch(t){throw console.warn("[Spaces] Failed to clear an account's credentials:",{did:e,error:t}),t}finally{t.close()}}let y=0;class g{did;space;pdsFetch;id;material;startDidGeneration;reminting;signatures;constructor(e,t,r,n){this.did=e,this.space=t,this.pdsFetch=r,this.reminting=null,this.signatures=new Map,this.id=`c${y++}`,this.material=n,this.startDidGeneration=_.get(e)??0}get token(){return this.material.token}get expiresAt(){return this.material.expiresAt}get key(){return this.material.key}get payload(){return(0,n.decodeJwtPayload)(this.material.token)}get isLive(){return b.get(E(this.did,this.space))===this}refresh(e){this.material=e}fetchFor(e){if(!(0,t.isDid)(e))throw new i.XrpcError(400,"InvalidRequest",`A space audience is a bare DID; got "${e}"`);return async(t,r)=>{let n="string"==typeof t?t:t.toString(),o=async t=>{let i=new Headers(r?.headers);for(let[r,n]of Object.entries(await this.signatureHeaders(t,e)))i.set(r,n);return fetch(n,{...r,headers:i,redirect:"error"})},a=await this.live(),s=await o(a);return 401===s.status&&(0,i.isCredentialRejectedCode)(await (0,i.errorCodeOf)(s))?o(this.material.token===a.token?await this.remint():await this.live()):s}}assertLive(){if(!this.isLive)throw R(this.did,this.startDidGeneration,"This space credential was dropped; open the space again")}async live(){this.assertLive();let e=await M(this.did,this.pdsFetch,this.space);return this.assertLive(),this.material=e,e}remint(){if(!this.reminting){let e=E(this.did,this.space);this.reminting=(async()=>{this.assertLive(),await h(e).catch(e=>{console.warn("[Spaces] Failed to delete a refused credential; re-minting anyway:",{did:this.did,space:this.space,error:e})}),this.assertLive(),D.delete(e);let t=await $(this.did,e,this.pdsFetch,this.space,{skipPersisted:!0});return this.material=t,t})().finally(()=>{this.reminting=null})}return this.reminting}signatureHeaders(e,t){let n=this.signatures.get(t);if(n&&n.token===e.token)return n.headers;
1let i=(0,r.createSpaceSignatureHeaders)(e.key,{authorization:`Atproto-Space ${e.token}`,audience:t});return this.signatures.set(t,{token:e.token,headers:i}),i.catch(()=>{this.signatures.get(t)?.headers===i&&this.signatures.delete(t)}),i}}async function v(e,t){let r=new AbortController,n=!1,o=setTimeout(()=>{n=!0,r.abort()},2e4);try{return await t(r.signal)}catch(t){if(n)throw new i.XrpcError(504,"MintTimeout",`${e} did not respond within 20s`);throw t}finally{clearTimeout(o)}}async function w(e,t){let r=await v("The delegation request",async r=>{let n=await e(`/xrpc/com.atproto.space.getDelegationToken?space=${encodeURIComponent(t)}`,{headers:{accept:"application/json"},signal:r});return n.ok||await (0,i.throwXrpcError)(n),await n.json()});if("string"!=typeof r.token||!r.token)throw new i.XrpcError(502,"InvalidResponse","No delegation token returned");return r.token}async function A(e){let t=new URL("/xrpc/com.atproto.space.getSpaceCredential",e.spaceHost).toString(),n=await (0,r.createSpaceSignatureHeaders)(e.key,{authorization:`Bearer ${e.delegationToken}`});return v("The space host",async r=>{let o=await fetch(t,{method:"POST",redirect:"error",headers:{accept:"application/json","content-type":"application/json",...n},body:JSON.stringify({space:e.space}),signal:r});o.ok||await (0,i.throwXrpcError)(o);let a=await o.json();if("string"!=typeof a.credential||!a.credential)throw new i.XrpcError(502,"InvalidResponse","No credential returned");return a.credential})}async function S(e,t){let a=(0,o.parseAtIdentifier)(t);if("space"!==a.kind&&"space-record"!==a.kind)throw new i.XrpcError(400,"InvalidRequest",`Not a space URI: ${t}`);let l=await s(a.authority.raw);if(!l?.pds)throw new i.XrpcError(502,"ServiceNotResolvable",`No PDS in ${a.authority.raw}'s DID document`);let c=l.pds,d=a.authority.isDid?"space"===a.kind?a.uri:a.space:(0,o.formatSpaceUri)(l.did,a.spaceType,a.skey),u=await w(e,d),p=await (0,r.generateSpaceSigningKey)(),f=await A({spaceHost:c,delegationToken:u,space:d,key:p}),h=(0,n.decodeJwtPayload)(f),m=h?.exp;if("number"!=typeof m||!Number.isFinite(m))throw new i.XrpcError(502,"InvalidResponse","The space credential carries no usable `exp`");let y=h?.cnf,g=y&&"object"==typeof y?y.kid:void 0;if(g!==p.keyId)throw new i.XrpcError(502,"InvalidResponse","string"==typeof g?"The space credential is bound to a key other than the one that signed the exchange":"The space credential is not bound to a key (no cnf.kid)");return{token:f,key:p,expiresAt:1e3*m}}let D=new Map,b=new Map;function E(e,t){return`${e}|${t}`}function C(e){let t=(0,o.parseAtIdentifier)(e);return"space"!==t.kind&&"space-record"!==t.kind?e:t.authority.isDid?"space"===t.kind?t.uri:t.space:null}let T=new Map,_=new Map,k=new Map;function I(e,t){return`0:${_.get(e)??0}:${k.get(t)??0}`}function R(e,t,r){let n=(_.get(e)??0)!==t;return new i.XrpcError(401,n?"SessionExpired":"CredentialsCleared",r)}function P(e){return e.expiresAt-6e4>Date.now()}async function U(e,t,r,n,i){let o=I(e,t),a=_.get(e)??0,s=()=>{if(I(e,t)!==o)throw R(e,a,"Credentials were cleared while resolving")},l=i?.skipPersisted?null:await p(t);if(s(),l&&P(l))return l;let c=await S(r,n);return s(),await f(t,c),I(e,t)!==o&&(await h(t),s()),c}function O(e,t,r){let n=C(r);return null!==n?L(e,t,n):(function(e){let t=C(e);if(null!==t)return Promise.resolve(t);let r=T.get(e);if(r)return r;let n=(0,o.parseAtIdentifier)(e),i=(async()=>{if("space"!==n.kind&&"space-record"!==n.kind)return e;let t=await s(n.authority.raw);return t?.did?(0,o.formatSpaceUri)(t.did,n.spaceType,n.skey):e})();T.set(e,i);let a=()=>{T.get(e)===i&&T.delete(e)};return i.then(a,a),i})(r).then(r=>L(e,t,r))}async function L(e,t,r){let n=E(e,r),i=I(e,n),o=_.get(e)??0,a=await M(e,t,r);if(I(e,n)!==i)throw R(e,o,"Credentials were cleared while resolving");let s=b.get(n);if(s)return s.refresh(a),s;let l=new g(e,r,t,a);return b.set(n,l),l}function $(e,t,r,n,i){let o=U(e,t,r,n,i);return D.set(t,o),o.catch(()=>{D.get(t)===o&&D.delete(t)}),o}function M(e,t,r,n=1){let i=E(e,r),o=D.get(i);return o?o.then(a=>P(a)?a:(D.get(i)===o&&D.delete(i),n<=0)?$(e,i,t,r):M(e,t,r,n-1)):$(e,i,t,r)}function x(e){_.set(e,(_.get(e)??0)+1);let t=`${e}|`;for(let e of[...D.keys()])e.startsWith(t)&&D.delete(e);for(let e of[...b.keys()])e.startsWith(t)&&b.delete(e);return m(e)}e.s(["clearSpaceCredentialsForDid",()=>x,"getSpaceCredential",()=>O],957667)}]);
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.