this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

atprotocall

+864 -51
+322 -15
app.js
··· 1 - import { createAuthorizationUrl } from "@atcute/oauth-browser-client"; 1 + import { Component, createRef } from "preact"; 2 + import { html } from "htm/preact"; 3 + import { signal } from "@preact/signals"; 4 + import { getSession, createAuthorizationUrl } from "@atcute/oauth-browser-client"; 2 5 3 - import { configure, scope } from "./oauth.js"; 6 + import { configure, client, resolve, scope } from "./oauth.js"; 7 + import { publishSignal, deleteRecord, deleteExpiredRecords, connectJetstream } from "./signaling.js"; 8 + import { createPeerConnection, createOffer, createAnswer } from "./rtc.js"; 4 9 5 10 configure(); 6 11 7 - document.querySelector("form").onsubmit = async (e) => { 8 - e.preventDefault(); 9 - const data = new FormData(e.currentTarget); 10 - const identifier = data.get("handle"); 11 - if (typeof identifier !== "string") throw new Error("invalid handle"); 12 + export class App extends Component { 13 + loading = signal(true); 14 + did = signal(""); 15 + xrpc = null; 16 + callState = signal("idle"); // idle | calling | incoming | connected 17 + incomingOffer = signal(null); // { callerDid, sdp } 18 + localStream = signal(null); 19 + remoteStream = signal(null); 20 + pc = null; 21 + jetstream = null; 22 + status = signal(""); 23 + signalUri = null; // AT URI of the record we published 24 + expiryTimer = null; 25 + 26 + async componentDidMount() { 27 + try { 28 + const did = localStorage.getItem("webrtc:did"); 29 + if (!did) return; 30 + 31 + const session = await getSession(did, { allowStale: false }); 32 + this.did.value = session.info.sub; 33 + this.xrpc = client(session); 34 + this.#startJetstream(); 35 + deleteExpiredRecords(this.xrpc, this.did.value).catch((e) => 36 + console.error("failed to clean up expired records", e), 37 + ); 38 + } catch (e) { 39 + console.error("session restore failed", e); 40 + localStorage.removeItem("webrtc:did"); 41 + } finally { 42 + this.loading.value = false; 43 + } 44 + } 45 + 46 + componentWillUnmount() { 47 + this.jetstream?.close(); 48 + this.#hangup(); 49 + } 50 + 51 + #startJetstream() { 52 + this.jetstream?.close(); 53 + this.jetstream = connectJetstream( 54 + this.did.value, 55 + (callerDid, record) => { 56 + // incoming offer 57 + if (this.callState.value !== "idle") return; 58 + this.incomingOffer.value = { callerDid, sdp: record.sdp }; 59 + this.callState.value = "incoming"; 60 + }, 61 + async (answererDid, record) => { 62 + // incoming answer — we must be in "calling" state 63 + if (this.callState.value !== "calling" || !this.pc) return; 64 + try { 65 + await this.pc.setRemoteDescription( 66 + new RTCSessionDescription({ type: "answer", sdp: record.sdp }), 67 + ); 68 + this.callState.value = "connected"; 69 + this.status.value = ""; 70 + this.#deleteSignalRecord(); 71 + } catch (e) { 72 + console.error("failed to set remote answer", e); 73 + } 74 + }, 75 + ); 76 + } 77 + 78 + startCall = async (handle) => { 79 + try { 80 + this.status.value = "Resolving handle..."; 81 + const targetDid = await resolve(handle); 82 + 83 + this.status.value = "Requesting camera & mic..."; 84 + const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true }); 85 + this.localStream.value = stream; 86 + 87 + this.status.value = "Creating offer..."; 88 + this.pc = createPeerConnection((e) => { 89 + this.remoteStream.value = e.streams[0]; 90 + }); 91 + this.pc.oniceconnectionstatechange = () => { 92 + if (this.pc?.iceConnectionState === "connected") this.#deleteSignalRecord(); 93 + if (this.pc?.iceConnectionState === "disconnected" || this.pc?.iceConnectionState === "failed") { 94 + this.#hangup(); 95 + } 96 + }; 97 + 98 + const sdp = await createOffer(this.pc, stream); 99 + 100 + this.status.value = "Sending offer..."; 101 + this.signalUri = await publishSignal(this.xrpc, this.did.value, targetDid, "offer", sdp); 102 + this.#startExpiryTimer(); 103 + 104 + this.callState.value = "calling"; 105 + this.status.value = "Waiting for answer..."; 106 + } catch (e) { 107 + console.error("call failed", e); 108 + this.status.value = "Call failed: " + e.message; 109 + this.#hangup(); 110 + } 111 + }; 112 + 113 + acceptCall = async () => { 114 + const offer = this.incomingOffer.value; 115 + if (!offer) return; 116 + 117 + try { 118 + this.status.value = "Requesting camera & mic..."; 119 + const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true }); 120 + this.localStream.value = stream; 121 + 122 + this.status.value = "Creating answer..."; 123 + this.pc = createPeerConnection((e) => { 124 + this.remoteStream.value = e.streams[0]; 125 + }); 126 + this.pc.oniceconnectionstatechange = () => { 127 + if (this.pc?.iceConnectionState === "connected") this.#deleteSignalRecord(); 128 + if (this.pc?.iceConnectionState === "disconnected" || this.pc?.iceConnectionState === "failed") { 129 + this.#hangup(); 130 + } 131 + }; 132 + 133 + const sdp = await createAnswer(this.pc, stream, offer.sdp); 134 + 135 + this.status.value = "Sending answer..."; 136 + this.signalUri = await publishSignal(this.xrpc, this.did.value, offer.callerDid, "answer", sdp); 137 + this.#startExpiryTimer(); 138 + 139 + this.callState.value = "connected"; 140 + this.status.value = ""; 141 + } catch (e) { 142 + console.error("accept failed", e); 143 + this.status.value = "Failed to accept: " + e.message; 144 + this.#hangup(); 145 + } 146 + }; 147 + 148 + declineCall = () => { 149 + this.incomingOffer.value = null; 150 + this.callState.value = "idle"; 151 + }; 152 + 153 + hangup = () => this.#hangup(); 154 + 155 + #hangup() { 156 + this.pc?.close(); 157 + this.pc = null; 158 + this.localStream.value?.getTracks().forEach((t) => t.stop()); 159 + this.localStream.value = null; 160 + this.remoteStream.value = null; 161 + this.incomingOffer.value = null; 162 + this.callState.value = "idle"; 163 + this.status.value = ""; 164 + this.#deleteSignalRecord(); 165 + } 166 + 167 + #deleteSignalRecord() { 168 + if (!this.signalUri || !this.xrpc) return; 169 + const rkey = this.signalUri.split("/").pop(); 170 + deleteRecord(this.xrpc, this.did.value, rkey).catch((e) => 171 + console.error("failed to delete signal record", e), 172 + ); 173 + this.signalUri = null; 174 + clearTimeout(this.expiryTimer); 175 + this.expiryTimer = null; 176 + } 12 177 13 - const authUrl = await createAuthorizationUrl({ 14 - target: { type: "account", identifier }, 15 - scope, 16 - }); 178 + #startExpiryTimer() { 179 + clearTimeout(this.expiryTimer); 180 + this.expiryTimer = setTimeout(() => { 181 + this.#deleteSignalRecord(); 182 + // if we're still waiting for an answer, the offer expired 183 + if (this.callState.value === "calling") { 184 + this.status.value = "Call expired — no answer received."; 185 + this.#hangup(); 186 + } 187 + }, 60_000); 188 + } 17 189 18 - // localStorage.setItem("did", identity.id); 19 - await new Promise((r) => setTimeout(r, 100)); 190 + logout = () => { 191 + this.jetstream?.close(); 192 + this.#hangup(); 193 + localStorage.removeItem("webrtc:did"); 194 + this.did.value = ""; 195 + this.xrpc = null; 196 + }; 20 197 21 - window.location.assign(authUrl); 22 - }; 198 + render() { 199 + if (this.loading.value) return html`<div class="center"><p>Loading...</p></div>`; 200 + if (!this.did.value) return html`<${Login} />`; 201 + 202 + const state = this.callState.value; 203 + 204 + return html` 205 + <div class="app"> 206 + <header> 207 + <span>Signed in as <strong>${this.did.value}</strong></span> 208 + <button onClick=${this.logout}>Sign out</button> 209 + </header> 210 + 211 + ${state === "idle" && html`<${CallForm} onCall=${this.startCall} />`} 212 + 213 + ${state === "incoming" && 214 + html`<${IncomingCall} 215 + callerDid=${this.incomingOffer.value?.callerDid} 216 + onAccept=${this.acceptCall} 217 + onDecline=${this.declineCall} 218 + />`} 219 + 220 + ${(state === "calling" || state === "connected") && 221 + html`<${VideoCall} 222 + localStream=${this.localStream.value} 223 + remoteStream=${this.remoteStream.value} 224 + onHangup=${this.hangup} 225 + />`} 226 + 227 + ${this.status.value && html`<div class="status">${this.status.value}</div>`} 228 + </div> 229 + `; 230 + } 231 + } 232 + 233 + class Login extends Component { 234 + async onSubmit(e) { 235 + e.preventDefault(); 236 + const data = new FormData(e.currentTarget); 237 + const identifier = data.get("handle"); 238 + if (typeof identifier !== "string") throw new Error("invalid handle"); 239 + 240 + const authUrl = await createAuthorizationUrl({ 241 + target: { type: "account", identifier }, 242 + scope, 243 + }); 244 + await new Promise((r) => setTimeout(r, 100)); 245 + window.location.assign(authUrl); 246 + } 247 + 248 + render() { 249 + return html` 250 + <div class="center"> 251 + <h1>ATProtoCall</h1> 252 + <form class="login-form" onSubmit=${(e) => this.onSubmit(e)}> 253 + <input name="handle" placeholder="yourhandle.bsky.social" required /> 254 + <button>Log in</button> 255 + </form> 256 + </div> 257 + `; 258 + } 259 + } 260 + 261 + class CallForm extends Component { 262 + async onSubmit(e) { 263 + e.preventDefault(); 264 + const data = new FormData(e.currentTarget); 265 + const handle = data.get("peer"); 266 + if (typeof handle !== "string" || !handle) return; 267 + this.props.onCall(handle); 268 + } 269 + 270 + render() { 271 + return html` 272 + <div class="center"> 273 + <h2>Start a call</h2> 274 + <form class="call-form" onSubmit=${(e) => this.onSubmit(e)}> 275 + <input name="peer" placeholder="theirhandle.bsky.social" required /> 276 + <button>Call</button> 277 + </form> 278 + </div> 279 + `; 280 + } 281 + } 282 + 283 + class IncomingCall extends Component { 284 + render() { 285 + return html` 286 + <div class="toast"> 287 + <p>Incoming call from <strong>${this.props.callerDid}</strong></p> 288 + <div class="toast-actions"> 289 + <button class="accept" onClick=${this.props.onAccept}>Accept</button> 290 + <button class="decline" onClick=${this.props.onDecline}>Decline</button> 291 + </div> 292 + </div> 293 + `; 294 + } 295 + } 296 + 297 + class VideoCall extends Component { 298 + localRef = createRef(); 299 + remoteRef = createRef(); 300 + 301 + componentDidMount() { 302 + this.#syncVideo(); 303 + } 304 + 305 + componentDidUpdate() { 306 + this.#syncVideo(); 307 + } 308 + 309 + #syncVideo() { 310 + if (this.localRef.current && this.props.localStream) { 311 + this.localRef.current.srcObject = this.props.localStream; 312 + } 313 + if (this.remoteRef.current && this.props.remoteStream) { 314 + this.remoteRef.current.srcObject = this.props.remoteStream; 315 + } 316 + } 317 + 318 + render() { 319 + return html` 320 + <div class="video-call"> 321 + <div class="videos"> 322 + <video ref=${this.remoteRef} autoplay playsinline class="remote-video"></video> 323 + <video ref=${this.localRef} autoplay playsinline muted class="local-video"></video> 324 + </div> 325 + <button class="hangup" onClick=${this.props.onHangup}>Hang up</button> 326 + </div> 327 + `; 328 + } 329 + }
+5 -10
callback.html
··· 1 1 <!doctype html> 2 - <script type="importmap"> 3 - { 4 - "imports": { 5 - "@atcute/client": "https://esm.sh/@atcute/client", 6 - "@atcute/identity-resolver": "https://esm.sh/@atcute/identity-resolver", 7 - "@atcute/oauth-browser-client": "https://esm.sh/@atcute/oauth-browser-client@3.0.0" 8 - } 9 - } 10 - </script> 2 + <script src="./vendor/importmap.js"></script> 11 3 <script type="module"> 12 4 import { finalizeAuthorization } from "@atcute/oauth-browser-client"; 13 5 ··· 17 9 const params = new URLSearchParams(location.hash.slice(1)); 18 10 19 11 finalizeAuthorization(params) 20 - .then(() => window.location.assign("/")) 12 + .then((agent) => { 13 + localStorage.setItem("webrtc:did", agent.session.info.sub); 14 + window.location.assign("/atprotocall/"); 15 + }) 21 16 .catch((err) => console.error(err)); 22 17 </script>
+3 -3
client-metadata.json
··· 1 1 { 2 - "client_id": "https://8a49-66-108-106-210.ngrok-free.app/client-metadata.json", 3 - "client_uri": "https://8a49-66-108-106-210.ngrok-free.app", 4 - "redirect_uris": ["https://8a49-66-108-106-210.ngrok-free.app/callback.html"], 2 + "client_id": "https://jake.tngl.io/atprotocall/client-metadata.json", 3 + "client_uri": "https://jake.tngl.io/atprotocall/", 4 + "redirect_uris": ["https://jake.tngl.io/atprotocall/callback.html"], 5 5 "application_type": "native", 6 6 "client_name": "atrtc demo", 7 7 "dpop_bound_access_tokens": true,
+11 -15
index.html
··· 1 1 <!doctype html> 2 2 <html lang="en"> 3 3 <head> 4 - <title>webrtc over atproto</title> 4 + <title>ATProtoCall</title> 5 5 <meta charset="utf8" /> 6 - <script type="importmap"> 7 - { 8 - "imports": { 9 - "@atcute/client": "https://esm.sh/@atcute/client", 10 - "@atcute/identity-resolver": "https://esm.sh/@atcute/identity-resolver", 11 - "@atcute/oauth-browser-client": "https://esm.sh/@atcute/oauth-browser-client@3.0.0" 12 - } 13 - } 14 - </script> 15 - <script type="module" src="./app.js"></script> 6 + <meta name="viewport" content="width=device-width, initial-scale=1" /> 7 + <link rel="stylesheet" href="./style.css" /> 8 + <script src="./vendor/importmap.js"></script> 16 9 </head> 17 10 <body> 18 - <form> 19 - <input name="handle" /> 20 - <button>log in</button> 21 - </form> 11 + <div id="app"></div> 12 + <script type="module"> 13 + import { render } from "preact"; 14 + import { html } from "htm/preact"; 15 + import { App } from "./app.js"; 16 + render(html`<${App} />`, document.getElementById("app")); 17 + </script> 22 18 </body> 23 19 </html>
+16 -8
oauth.js
··· 12 12 XrpcHandleResolver, 13 13 } from "@atcute/identity-resolver"; 14 14 15 + const resolver = new LocalActorResolver({ 16 + handleResolver: new XrpcHandleResolver({ serviceUrl: "https://public.api.bsky.app" }), 17 + didDocumentResolver: new CompositeDidDocumentResolver({ 18 + methods: { plc: new PlcDidDocumentResolver(), web: new WebDidDocumentResolver() }, 19 + }), 20 + }); 21 + 15 22 export function configure() { 16 23 configureOAuth({ 17 24 metadata: { client_id: metadata.client_id, redirect_uri: metadata.redirect_uris[0] }, 18 - identityResolver: new LocalActorResolver({ 19 - handleResolver: new XrpcHandleResolver({ serviceUrl: "https://public.api.bsky.app" }), 20 - didDocumentResolver: new CompositeDidDocumentResolver({ 21 - methods: { plc: new PlcDidDocumentResolver(), web: new WebDidDocumentResolver() }, 22 - }), 23 - }), 25 + identityResolver: resolver, 24 26 }); 25 27 } 26 28 27 - /** @param {import("@atcute/oauth-browser-client").Session} */ 29 + /** @param {string} handleOrDid */ 30 + export async function resolve(handleOrDid) { 31 + const { did } = await resolver.resolve(handleOrDid); 32 + return did; 33 + } 34 + 35 + /** @param {import("@atcute/oauth-browser-client").Session} session */ 28 36 export function client(session) { 29 37 const handler = new OAuthUserAgent(session); 30 - const client = new Client({ handler }); 38 + return new Client({ handler }); 31 39 }
+58
rtc.js
··· 1 + const ICE_SERVERS = [{ urls: "stun:stun.l.google.com:19302" }]; 2 + 3 + /** 4 + * @param {(event: RTCTrackEvent) => void} onTrack 5 + * @returns {RTCPeerConnection} 6 + */ 7 + export function createPeerConnection(onTrack) { 8 + const pc = new RTCPeerConnection({ iceServers: ICE_SERVERS }); 9 + pc.ontrack = onTrack; 10 + return pc; 11 + } 12 + 13 + /** @param {RTCPeerConnection} pc */ 14 + function gatherComplete(pc) { 15 + return new Promise((resolve) => { 16 + if (pc.iceGatheringState === "complete") return resolve(); 17 + const onChange = () => { 18 + if (pc.iceGatheringState === "complete") { 19 + pc.removeEventListener("icegatheringstatechange", onChange); 20 + resolve(); 21 + } 22 + }; 23 + pc.addEventListener("icegatheringstatechange", onChange); 24 + // timeout after 10s — use whatever candidates we have 25 + setTimeout(() => { 26 + pc.removeEventListener("icegatheringstatechange", onChange); 27 + resolve(); 28 + }, 10000); 29 + }); 30 + } 31 + 32 + /** 33 + * @param {RTCPeerConnection} pc 34 + * @param {MediaStream} stream 35 + * @returns {Promise<string>} SDP with all ICE candidates 36 + */ 37 + export async function createOffer(pc, stream) { 38 + for (const track of stream.getTracks()) pc.addTrack(track, stream); 39 + const offer = await pc.createOffer(); 40 + await pc.setLocalDescription(offer); 41 + await gatherComplete(pc); 42 + return pc.localDescription.sdp; 43 + } 44 + 45 + /** 46 + * @param {RTCPeerConnection} pc 47 + * @param {MediaStream} stream 48 + * @param {string} remoteSdp 49 + * @returns {Promise<string>} SDP with all ICE candidates 50 + */ 51 + export async function createAnswer(pc, stream, remoteSdp) { 52 + for (const track of stream.getTracks()) pc.addTrack(track, stream); 53 + await pc.setRemoteDescription(new RTCSessionDescription({ type: "offer", sdp: remoteSdp })); 54 + const answer = await pc.createAnswer(); 55 + await pc.setLocalDescription(answer); 56 + await gatherComplete(pc); 57 + return pc.localDescription.sdp; 58 + }
+108
signaling.js
··· 1 + const COLLECTION = "com.jakelazaroff.webrtc.session"; 2 + const JETSTREAM = "wss://jetstream1.us-east.bsky.network/subscribe"; 3 + const MAX_AGE_MS = 60_000; 4 + 5 + /** 6 + * @param {import("@atcute/client").Client} client 7 + * @param {string} repo - sender's DID 8 + * @param {string} targetDid - recipient's DID 9 + * @param {"offer"|"answer"} type 10 + * @param {string} sdp 11 + * @returns {Promise<string>} the AT URI of the created record 12 + */ 13 + export async function publishSignal(client, repo, targetDid, type, sdp) { 14 + const res = await client.post("com.atproto.repo.createRecord", { 15 + params: {}, 16 + input: { 17 + repo, 18 + collection: COLLECTION, 19 + record: { 20 + $type: COLLECTION, 21 + target: targetDid, 22 + type, 23 + sdp, 24 + createdAt: new Date().toISOString(), 25 + }, 26 + }, 27 + }); 28 + return res.data.uri; 29 + } 30 + 31 + /** 32 + * @param {import("@atcute/client").Client} client 33 + * @param {string} repo 34 + * @param {string} rkey 35 + */ 36 + export async function deleteRecord(client, repo, rkey) { 37 + await client.post("com.atproto.repo.deleteRecord", { 38 + params: {}, 39 + input: { repo, collection: COLLECTION, rkey }, 40 + }); 41 + } 42 + 43 + /** 44 + * Delete all expired session records for the given repo. 45 + * @param {import("@atcute/client").Client} client 46 + * @param {string} repo 47 + */ 48 + export async function deleteExpiredRecords(client, repo) { 49 + const res = await client.get("com.atproto.repo.listRecords", { 50 + params: { repo, collection: COLLECTION, limit: 100 }, 51 + }); 52 + const now = Date.now(); 53 + await Promise.all( 54 + res.data.records 55 + .filter((r) => now - new Date(r.value.createdAt).getTime() > MAX_AGE_MS) 56 + .map((r) => { 57 + const rkey = r.uri.split("/").pop(); 58 + return deleteRecord(client, repo, rkey); 59 + }), 60 + ); 61 + } 62 + 63 + /** 64 + * @param {string} myDid 65 + * @param {(callerDid: string, record: object) => void} onOffer 66 + * @param {(answererDid: string, record: object) => void} onAnswer 67 + * @returns {WebSocket} 68 + */ 69 + export function connectJetstream(myDid, onOffer, onAnswer) { 70 + const url = `${JETSTREAM}?wantedCollections=${COLLECTION}`; 71 + let ws; 72 + let destroyed = false; 73 + 74 + function connect() { 75 + ws = new WebSocket(url); 76 + 77 + ws.onmessage = (e) => { 78 + const event = JSON.parse(e.data); 79 + if (event.kind !== "commit") return; 80 + if (event.commit.operation !== "create") return; 81 + 82 + const record = event.commit.record; 83 + if (record.target !== myDid) return; 84 + 85 + // ignore stale signals 86 + const age = Date.now() - new Date(record.createdAt).getTime(); 87 + if (age > MAX_AGE_MS) return; 88 + 89 + if (record.type === "offer") onOffer(event.did, record); 90 + else if (record.type === "answer") onAnswer(event.did, record); 91 + }; 92 + 93 + ws.onclose = () => { 94 + if (!destroyed) setTimeout(connect, 2000); 95 + }; 96 + 97 + ws.onerror = () => ws.close(); 98 + } 99 + 100 + connect(); 101 + 102 + return { 103 + close() { 104 + destroyed = true; 105 + ws?.close(); 106 + }, 107 + }; 108 + }
+153
style.css
··· 1 + * { 2 + box-sizing: border-box; 3 + margin: 0; 4 + padding: 0; 5 + } 6 + body { 7 + font-family: system-ui, sans-serif; 8 + background: #111; 9 + color: #eee; 10 + min-height: 100dvh; 11 + } 12 + 13 + .center { 14 + display: flex; 15 + flex-direction: column; 16 + align-items: center; 17 + justify-content: center; 18 + min-height: 80dvh; 19 + gap: 1rem; 20 + } 21 + h1 { 22 + font-size: 1.5rem; 23 + } 24 + h2 { 25 + font-size: 1.25rem; 26 + } 27 + 28 + input { 29 + padding: 0.5rem 0.75rem; 30 + border-radius: 6px; 31 + border: 1px solid #444; 32 + background: #222; 33 + color: #eee; 34 + font-size: 1rem; 35 + } 36 + button { 37 + padding: 0.5rem 1rem; 38 + border-radius: 6px; 39 + border: none; 40 + background: #3b82f6; 41 + color: #fff; 42 + font-size: 1rem; 43 + cursor: pointer; 44 + } 45 + button:hover { 46 + background: #2563eb; 47 + } 48 + 49 + .login-form, 50 + .call-form { 51 + display: flex; 52 + gap: 0.5rem; 53 + } 54 + 55 + .app { 56 + display: flex; 57 + flex-direction: column; 58 + min-height: 100dvh; 59 + } 60 + header { 61 + display: flex; 62 + justify-content: space-between; 63 + align-items: center; 64 + padding: 0.75rem 1rem; 65 + background: #1a1a1a; 66 + border-bottom: 1px solid #333; 67 + font-size: 0.85rem; 68 + } 69 + header strong { 70 + word-break: break-all; 71 + } 72 + header button { 73 + background: #333; 74 + font-size: 0.8rem; 75 + padding: 0.35rem 0.75rem; 76 + } 77 + 78 + .status { 79 + text-align: center; 80 + padding: 0.75rem; 81 + color: #aaa; 82 + font-size: 0.9rem; 83 + } 84 + 85 + .toast { 86 + position: fixed; 87 + top: 1.5rem; 88 + left: 50%; 89 + transform: translateX(-50%); 90 + background: #1e293b; 91 + border: 1px solid #334155; 92 + border-radius: 12px; 93 + padding: 1.25rem 1.5rem; 94 + z-index: 100; 95 + text-align: center; 96 + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); 97 + max-width: 90vw; 98 + } 99 + .toast p { 100 + margin-bottom: 1rem; 101 + } 102 + .toast strong { 103 + word-break: break-all; 104 + } 105 + .toast-actions { 106 + display: flex; 107 + gap: 0.75rem; 108 + justify-content: center; 109 + } 110 + .toast .accept { 111 + background: #22c55e; 112 + } 113 + .toast .accept:hover { 114 + background: #16a34a; 115 + } 116 + .toast .decline { 117 + background: #ef4444; 118 + } 119 + .toast .decline:hover { 120 + background: #dc2626; 121 + } 122 + 123 + .video-call { 124 + display: flex; 125 + flex-direction: column; 126 + flex: 1; 127 + } 128 + .videos { 129 + position: relative; 130 + flex: 1; 131 + background: #000; 132 + } 133 + .remote-video { 134 + width: 100%; 135 + height: 100%; 136 + object-fit: contain; 137 + } 138 + .local-video { 139 + position: absolute; 140 + bottom: 1rem; 141 + right: 1rem; 142 + width: 180px; 143 + border-radius: 8px; 144 + border: 2px solid #333; 145 + object-fit: cover; 146 + } 147 + .hangup { 148 + background: #ef4444; 149 + margin: 1rem auto; 150 + } 151 + .hangup:hover { 152 + background: #dc2626; 153 + }
+14
unpm.json
··· 1 + { 2 + "imports": { 3 + "preact": "https://esm.sh/preact", 4 + "preact/hooks": "https://esm.sh/preact/hooks", 5 + "htm/preact": "https://esm.sh/htm/preact?external=preact", 6 + "@preact/signals": "https://esm.sh/@preact/signals?external=preact", 7 + "@atcute/client": "https://esm.sh/@atcute/client", 8 + "@atcute/identity-resolver": "https://esm.sh/@atcute/identity-resolver", 9 + "@atcute/oauth-browser-client": "https://esm.sh/@atcute/oauth-browser-client@3.0.0" 10 + }, 11 + "$unpm": { 12 + "root": "/atprotocall/vendor" 13 + } 14 + }
+3
vendor/esm.sh/@atcute/client@4.2.1/es2022/client.mjs
··· 1 + /* esm.sh - @atcute/client@4.2.1 */ 2 + import*as u from"../../lexicons@1.2.10/es2022/validations.mjs";var v=s=>typeof s=="object"?s.handle.bind(s):s,S=({service:s,fetch:e=fetch})=>async(t,r)=>{let n=new URL(t,s);return await e(n.href,r)};var E=/\bapplication\/json\b/,w=class s{handler;proxy;constructor({handler:e,proxy:t=null}){this.handler=v(e),this.proxy=t}clone({handler:e=this.handler,proxy:t=this.proxy}={}){return new s({handler:e,proxy:t})}get(e,t={}){return this.#e("get",e,t)}post(e,t={}){return this.#e("post",e,t)}async call(e,t={}){if(!u.xrpcSchemaGenerated)return;if("mainSchema"in e&&(e=e.mainSchema),e.params!==null){let a=u.safeParse(e.params,t.params);if(!a.ok)throw new f("params",a)}if(e.type==="xrpc_procedure"&&e.input?.type==="lex"){let a=u.safeParse(e.input.schema,t.input);if(!a.ok)throw new f("input",a)}let r=e.type==="xrpc_query",n=r?"get":"post";if(t.as===void 0&&e.output?.type==="blob")throw new TypeError("`as` option is required for endpoints returning blobs");let i=t.as!==void 0?t.as:e.output?.type==="lex"?"json":null,o=await this.#e(n,e.nsid,{params:t.params,input:r?void 0:t.input,as:i,signal:t.signal,headers:t.headers});if(i==="json"&&o.ok&&e.output?.type==="lex"){let a=u.safeParse(e.output.schema,o.data);if(!a.ok)throw new f("output",a);return{ok:!0,status:o.status,headers:o.headers,data:a.value}}return o}async#e(e,t,{signal:r,as:n="json",headers:i,input:o,params:a}){let k=o&&(o instanceof Blob||ArrayBuffer.isView(o)||o instanceof ArrayBuffer||o instanceof ReadableStream),R=`/xrpc/${t}`+J(a),c=await this.handler(R,{method:e,signal:r,body:o&&!k?JSON.stringify(o):o,headers:P(i,{"content-type":o&&!k?"application/json":null,"atproto-proxy":U(this.proxy)}),duplex:o instanceof ReadableStream?"half":void 0});{let p=c.status,m=c.headers,l=m.get("content-type");if(p!==200){let h;if(l!=null&&E.test(l))try{let x=await c.json();b(x)&&(h=x)}catch{}else await c.body?.cancel();return{ok:!1,status:p,headers:m,data:h??{error:"UnknownXRPCError",message:`Request failed with status code ${p}`}}}{let h;switch(n){case"json":{if(l!=null&&E.test(l))h=await c.json();else throw await c.body?.cancel(),new TypeError(`Invalid response content-type (got ${l})`);break}case null:{h=null,await c.body?.cancel();break}case"blob":{h=await c.blob();break}case"bytes":{h=new Uint8Array(await c.arrayBuffer());break}case"stream":{h=c.body;break}}return{ok:!0,status:p,headers:m,data:h}}}}},J=s=>{let e;for(let t in s){let r=s[t];if(r!==void 0)if(e??=new URLSearchParams,Array.isArray(r))for(let n=0,i=r.length;n<i;n++){let o=r[n];e.append(t,""+o)}else e.set(t,""+r)}return e?"?"+e.toString():""},U=s=>s!=null?`${s.did}${s.serviceId}`:null,P=(s,e)=>{let t;for(let r in e){let n=e[r];n!==null&&(t??=new Headers(s),t.has(r)||t.set(r,n))}return t??s},b=s=>{if(typeof s!="object"||s==null)return!1;let e=typeof s.error,t=typeof s.message;return e==="string"&&(t==="undefined"||t==="string")},y=s=>{if(s instanceof Promise)return s.then(y);if(s.ok)return s.data;throw new d(s)},d=class extends Error{error;description;status;headers;constructor({status:e,headers:t=new Headers,data:r}){super(`${r.error} > ${r.message??"(unspecified description)"}`),this.name="ClientResponseError",this.error=r.error,this.description=r.message,this.status=e,this.headers=t}},f=class extends Error{target;result;constructor(e,t){super(`validation failed for ${e}: ${t.message}`),this.name="ClientValidationError",this.target=e,this.result=t}};import{getPdsEndpoint as I}from"../../identity@1.1.4/es2022/identity.mjs";var g=s=>{let t=s.split(".")[1],r;if(typeof t!="string")throw new Error("invalid token: missing part 2");try{r=j(t)}catch(n){throw new Error("invalid token: invalid b64 for part 2 ("+n.message+")")}try{return JSON.parse(r)}catch(n){throw new Error("invalid token: invalid json for part 2 ("+n.message+")")}},j=s=>{let e=s.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return $(e)}catch{return atob(e)}},$=s=>decodeURIComponent(atob(s).replace(/(.)/g,(e,t)=>{let r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}));var T=class{serviceUrl;fetch;#e;#t;#s;#n;#o;session;constructor({service:e,onExpired:t,onRefresh:r,onSessionUpdate:n,fetch:i=fetch}){this.serviceUrl=e,this.fetch=i,this.#e=new w({handler:S({service:e,fetch:i})}),this.#n=r,this.#s=t,this.#o=n}get dispatchUrl(){return this.session?.pdsUri??this.serviceUrl}async handle(e,t){await this.#t;let r=new URL(e,this.dispatchUrl),n=new Headers(t.headers);if(!this.session||n.has("authorization"))return(0,this.fetch)(r,t);let i=this.session.accessJwt;n.set("authorization",`Bearer ${i}`);let o=await(0,this.fetch)(r,{...t,headers:n});if(o.status!==401&&!await C(o))return o;try{await this.#a()}catch{return o}let a=this.session?.accessJwt;return t.signal?.aborted||!a||a===i||t.body instanceof ReadableStream?o:(await o.body?.cancel(),n.set("authorization",`Bearer ${a}`),await(0,this.fetch)(r,{...t,headers:n}))}#a(){return this.#t||=this.#i().finally(()=>this.#t=void 0)}async#i(){let e=this.session;if(!e)return;let t=await this.#e.post("com.atproto.server.refreshSession",{headers:{authorization:`Bearer ${e.refreshJwt}`}});if(!t.ok)throw(t.status===401||t.data.error==="ExpiredToken"||t.data.error==="InvalidToken")&&(this.session=void 0,this.#s?.(e)),new d(t);if(t.data.did!==e.did)throw this.session=void 0,this.#s?.(e),new d({status:401,data:{error:"InvalidDID"}});if(this.session!==e)throw new Error("concurrent session update detected");this.#r({...e,...t.data}),this.#n?.(this.session)}#r(e){let t=e.didDoc,r;t&&(r=I(t));let n={accessJwt:e.accessJwt,refreshJwt:e.refreshJwt,handle:e.handle,did:e.did,pdsUri:r,email:e.email,emailConfirmed:e.emailConfirmed,emailAuthFactor:e.emailAuthFactor,active:e.active??!0,inactiveStatus:e.status};return this.session=n,this.#o?.(n),n}async resume(e){if(e.refreshJwt===this.session?.refreshJwt){if(await this.#t,!this.session||e.did!==this.session.did)throw new d({status:401,data:{error:"InvalidToken"}});return this.session}let t=Date.now()/1e3+300,r=g(e.refreshJwt);if(t>=r.exp||r.sub!==e.did)throw new d({status:401,data:{error:"InvalidToken"}});let n=g(e.accessJwt);if(n.sub!==e.did)throw new d({status:401,data:{error:"InvalidToken"}});if(this.session=e,this.#t=void 0,t>=n.exp?await this.#a():y(this.#e.get("com.atproto.server.getSession",{headers:{authorization:`Bearer ${e.accessJwt}`}})).then(o=>{let a=this.session;!a||a.did!==o.did||this.#r({...a,...o})},o=>{}),!this.session)throw new d({status:401,data:{error:"InvalidToken"}});return this.session}async login(e){this.session=void 0,this.#t=void 0;let t=await y(this.#e.post("com.atproto.server.createSession",{input:{identifier:e.identifier,password:e.password,authFactorToken:e.code,allowTakendown:e.allowTakendown}}));return this.#r(t)}async logout(){let e=this.session;if(e){this.session=void 0,this.#t=void 0;try{await this.#e.post("com.atproto.server.deleteSession",{as:null,headers:{authorization:`Bearer ${e.refreshJwt}`}})}catch{}}}},C=async s=>{if(s.status!==400||_(s.headers)!=="application/json"||B(s.headers)>54*1.5)return!1;try{let e=await s.clone().json();if(b(e))return e.error==="ExpiredToken"}catch{}return!1},_=s=>s.get("content-type")?.split(";")[0]?.trim(),B=s=>Number(s.get("content-length")??";");export{w as Client,d as ClientResponseError,f as ClientValidationError,T as CredentialManager,v as buildFetchHandler,b as isXRPCErrorPayload,y as ok,S as simpleFetchHandler}; 3 + //# sourceMappingURL=./client.mjs.map
+1
vendor/esm.sh/@atcute/client@4.2.1/es2022/client.mjs.map
··· 1 + {"mappings":";AAEA,UAAYA,MAAO,qDCMZ,IAAMC,EAAqBC,GAC7B,OAAOA,GAAY,SACfA,EAAQ,OAAO,KAAKA,CAAO,EAG5BA,EAQKC,EAAqB,CAAC,CAClC,QAAAC,EACA,MAAOC,EAAS,KAAK,IAEd,MAAOC,EAAUC,IAAS,CAChC,IAAMC,EAAM,IAAI,IAAIF,EAAUF,CAAO,EACrC,OAAO,MA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,UAAUsB,EAAe,UAAU,IAEnD,CACF,MAAQ,CAER,EAAC,GAgBGJ,EAAyB,MAAOK,GAAyC,CAc9E,GAbIA,EAAS,SAAW,KAIpBkB,EAAmBlB,EAAS,OAAO,IAAM,oBASzCmB,EAAqBnB,EAAS,OAAO,EAAI,GAAK,IACjD,MAAO,GAGR,GAAI,CACH,IAAMoB,EAAO,MAAMpB,EAAS,MAAK,EAAG,KAAI,EACxC,GAAIqB,EAAmBD,CAAI,EAC1B,OAAOA,EAAK,QAAU,cAExB,MAAQ,CAAC,CAET,MAAO,EAAM,EAGRF,EAAsB1B,GACpBA,EAAQ,IAAI,cAAc,GAAG,MAAM,GAAG,EAAE,CAAC,GAAG,KAAI,EAElD2B,EAAwB3B,GACtB,OAAOA,EAAQ,IAAI,gBAAgB,GAAK,GAAG","names":["v","buildFetchHandler","handler","simpleFetchHandler","service","_fetch","pathname","init","url","JSON_CONTENT_TYPE_RE","Client","_Client","handler","proxy","buildFetchHandler","name","options","#perform","schema","paramsResult","ClientValidationError","inputResult","isQuery","method","format","response","outputResult","signal","headers","input","params","isWebInput","url","_constructSearchParams","_mergeHeaders","_constructProxyHeader","status","type","json","parsed","isXRPCErrorPayload","data","searchParams","key","value","idx","len","val","init","defaults","kindType","messageType","ok","ClientResponseError","target","result","getPdsEndpoint","decodeJwt","token","part","decoded","base64UrlDecode","e","str","output","b64DecodeUnicode","_m","p","code","CredentialManager","#server","#refreshSessionPromise","#onExpired","#onRefresh","#onSessionUpdate","service","onExpired","onRefresh","onSessionUpdate","_fetch","Client","simpleFetchHandler","pathname","init","url","headers","initialToken","initialResponse","isExpiredTokenResponse","#refreshSession","updatedToken","#refreshSessionInner","currentSession","response","ClientResponseError","#updateSession","raw","didDoc","pdsUri","getPdsEndpoint","newSession","session","now","refreshToken","decodeJwt","accessToken","ok","next","existing","_err","options","extractContentType","extractContentLength","data","isXRPCErrorPayload"],"sources":["../esm/npm/@atcute/client@4.2.1/node_modules/@atcute/client/lib/client.ts","../esm/npm/@atcute/client@4.2.1/node_modules/@atcute/client/lib/fetch-handler.ts","../esm/npm/@atcute/client@4.2.1/node_modules/@atcute/client/lib/credential-manager.ts","../esm/npm/@atcute/client@4.2.1/node_modules/@atcute/client/lib/utils/jwt.ts"],"sourcesContent":["import type { Did } from '@atcute/lexicons';\nimport type { XRPCProcedures, XRPCQueries } from '@atcute/lexicons/ambient';\nimport * as v from '@atcute/lexicons/validations';\nimport type {\n\tInferInput,\n\tInferOutput,\n\tObjectSchema,\n\tXRPCBlobBodyParam,\n\tXRPCLexBodyParam,\n\tXRPCProcedureMetadata,\n\tXRPCQueryMetadata,\n} from '@atcute/lexicons/validations';\n\nimport { buildFetchHandler, type FetchHandler, type FetchHandlerObject } from './fetch-handler.js';\n\n// #region Type utilities\ntype RequiredKeysOf\u003cTType extends object\u003e = TType extends any\n\t? Exclude\u003c\n\t\t\t{\n\t\t\t\t[Key in keyof TType]: TType extends Record\u003cKey, TType[Key]\u003e ? Key : never;\n\t\t\t}[keyof TType],\n\t\t\tundefined\n\t\t\u003e\n\t: never;\n\ntype HasRequiredKeys\u003cTType extends object\u003e = RequiredKeysOf\u003cTType\u003e extends never ? false : true;\n\n// #endregion\n\n// #region Type definitions for response formats\ntype ResponseFormat = 'json' | 'blob' | 'bytes' | 'stream';\n\ntype FormattedResponse\u003cTDef\u003e = {\n\tjson: TDef extends XRPCQueryMetadata\u003cany, infer Body extends XRPCLexBodyParam, any\u003e\n\t\t? InferOutput\u003cBody['schema']\u003e\n\t\t: TDef extends XRPCProcedureMetadata\u003cany, any, infer Body extends XRPCLexBodyParam, any\u003e\n\t\t\t? InferOutput\u003cBody['schema']\u003e\n\t\t\t: unknown;\n\tblob: Blob;\n\tbytes: Uint8Array;\n\tstream: ReadableStream\u003cUint8Array\u003e;\n};\n\n// #endregion\n\n// #region Type definitions for request options\ntype BaseRequestOptions = {\n\tsignal?: AbortSignal;\n\theaders?: HeadersInit;\n};\n\nexport type QueryRequestOptions\u003cTDef\u003e = BaseRequestOptions \u0026\n\t(TDef extends XRPCQueryMetadata\u003cinfer Params, infer Output, any\u003e\n\t\t? (Params extends ObjectSchema\n\t\t\t\t? // query has parameters\n\t\t\t\t\t{ params: InferInput\u003cParams\u003e }\n\t\t\t\t: // query has no parameters\n\t\t\t\t\t{ params?: Record\u003cstring, unknown\u003e }) \u0026\n\t\t\t\t(Output extends XRPCLexBodyParam // query has JSON response, format is optionally specified\n\t\t\t\t\t? { as?: ResponseFormat | null }\n\t\t\t\t\t: // query doesn't have JSON response, format needs to be specified\n\t\t\t\t\t\t{ as: ResponseFormat | null })\n\t\t: {\n\t\t\t\tas: ResponseFormat | null;\n\t\t\t\tparams?: Record\u003cstring, unknown\u003e;\n\t\t\t});\n\nexport type ProcedureRequestOptions\u003cTDef\u003e = BaseRequestOptions \u0026\n\t(TDef extends XRPCProcedureMetadata\u003cinfer Params, infer Input, infer Output, any\u003e\n\t\t? (Params extends ObjectSchema\n\t\t\t\t? // procedure has parameters\n\t\t\t\t\t{ params: InferInput\u003cParams\u003e }\n\t\t\t\t: // procedure has no parameters\n\t\t\t\t\t{ params?: Record\u003cstring, unknown\u003e }) \u0026\n\t\t\t\t(Input extends XRPCLexBodyParam\n\t\t\t\t\t? // procedure requires JSON input\n\t\t\t\t\t\t{ input: InferInput\u003cInput['schema']\u003e }\n\t\t\t\t\t: Input extends XRPCBlobBodyParam\n\t\t\t\t\t\t? // procedure requires blob\n\t\t\t\t\t\t\t{ input: Blob | ArrayBuffer | ArrayBufferView | ReadableStream }\n\t\t\t\t\t\t: // procedure doesn't specify input\n\t\t\t\t\t\t\t{ input?: Record\u003cstring, unknown\u003e | Blob | ArrayBuffer | ArrayBufferView | ReadableStream }) \u0026\n\t\t\t\t(Output extends XRPCLexBodyParam\n\t\t\t\t\t? // procedure has JSON response, format is optionally specified\n\t\t\t\t\t\t{ as?: ResponseFormat | null }\n\t\t\t\t\t: // procedure doesn't have JSON response, format needs to be specified\n\t\t\t\t\t\t{ as: ResponseFormat | null })\n\t\t: {\n\t\t\t\tas: ResponseFormat | null;\n\t\t\t\tinput?: Record\u003cstring, unknown\u003e | Blob | ArrayBuffer | ArrayBufferView | ReadableStream;\n\t\t\t\tparams?: Record\u003cstring, unknown\u003e;\n\t\t\t});\n\nexport type CallRequestOptions\u003cTMeta\u003e = BaseRequestOptions \u0026\n\t// as is required if the endpoint returns blob, optional otherwise\n\t(TMeta extends XRPCQueryMetadata\u003cany, infer Output, any\u003e\n\t\t? Output extends XRPCBlobBodyParam\n\t\t\t? { as: ResponseFormat | null }\n\t\t\t: { as?: ResponseFormat | null }\n\t\t: TMeta extends XRPCProcedureMetadata\u003cany, any, infer Output, any\u003e\n\t\t\t? Output extends XRPCBlobBodyParam\n\t\t\t\t? { as: ResponseFormat | null }\n\t\t\t\t: { as?: ResponseFormat | null }\n\t\t\t: { as?: ResponseFormat | null }) \u0026\n\t(TMeta extends XRPCQueryMetadata\u003cinfer Params, any, any\u003e\n\t\t? // query\n\t\t\tParams extends ObjectSchema\n\t\t\t? { params: InferInput\u003cParams\u003e }\n\t\t\t: { params?: Record\u003cstring, unknown\u003e }\n\t\t: TMeta extends XRPCProcedureMetadata\u003cinfer Params, infer Input, any, any\u003e\n\t\t\t? // procedure\n\t\t\t\t(Params extends ObjectSchema\n\t\t\t\t\t? { params: InferInput\u003cParams\u003e }\n\t\t\t\t\t: { params?: Record\u003cstring, unknown\u003e }) \u0026\n\t\t\t\t\t(Input extends XRPCLexBodyParam\n\t\t\t\t\t\t? { input: InferInput\u003cInput['schema']\u003e }\n\t\t\t\t\t\t: Input extends XRPCBlobBodyParam\n\t\t\t\t\t\t\t? { input: Blob | ArrayBuffer | ArrayBufferView | ReadableStream }\n\t\t\t\t\t\t\t: { input?: Record\u003cstring, unknown\u003e | Blob | ArrayBuffer | ArrayBufferView | ReadableStream })\n\t\t\t: never);\n\ntype InternalRequestOptions = BaseRequestOptions \u0026 {\n\tas?: ResponseFormat | null;\n\tparams?: Record\u003cstring, unknown\u003e;\n\tinput?: Record\u003cstring, unknown\u003e | Blob | BufferSource | ReadableStream;\n};\n\n// #endregion\n\n// #region Type definitions for client response\n/** standard XRPC error payload structure */\nexport type XRPCErrorPayload = {\n\t/** error name */\n\terror: string;\n\t/** error description */\n\tmessage?: string;\n};\n\ntype BaseClientResponse = {\n\t/** response status */\n\tstatus: number;\n\t/** response headers */\n\theaders: Headers;\n};\n\n/** represents a successful response returned by the client */\nexport type SuccessClientResponse\u003cTDef, TInit\u003e = BaseClientResponse \u0026 {\n\tok: true;\n\t/** response data */\n\tdata: TInit extends { as: infer TFormat }\n\t\t? TFormat extends ResponseFormat\n\t\t\t? FormattedResponse\u003cTDef\u003e[TFormat]\n\t\t\t: TFormat extends null\n\t\t\t\t? null\n\t\t\t\t: never\n\t\t: TDef extends XRPCQueryMetadata\u003cany, infer Body, any\u003e\n\t\t\t? Body extends XRPCLexBodyParam\n\t\t\t\t? InferOutput\u003cBody['schema']\u003e\n\t\t\t\t: null\n\t\t\t: TDef extends XRPCProcedureMetadata\u003cany, any, infer Body, any\u003e\n\t\t\t\t? Body extends XRPCLexBodyParam\n\t\t\t\t\t? InferOutput\u003cBody['schema']\u003e\n\t\t\t\t\t: null\n\t\t\t\t: never;\n};\n\n/** represents a failed response returned by the client */\nexport type FailedClientResponse = BaseClientResponse \u0026 {\n\tok: false;\n\t/** response data */\n\tdata: XRPCErrorPayload;\n};\n\n/** represents a response returned by the client */\nexport type ClientResponse\u003cTDef, TInit\u003e = SuccessClientResponse\u003cTDef, TInit\u003e | FailedClientResponse;\n\ntype UnknownClientResponse = { status: number; headers: Headers } \u0026 (\n\t| { ok: true; data: unknown }\n\t| { ok: false; data: XRPCErrorPayload }\n);\n\n// #endregion\n\n// #region Type definitions for call method\ntype Namespaced\u003cT\u003e = { mainSchema: T };\n\n// #endregion\n\n// #region Client\n/** options for configuring service proxying */\nexport type ServiceProxyOptions = {\n\t/** DID identifier that the upstream service should look up */\n\tdid: Did;\n\t/**\n\t * the specific service ID within the resolved DID document's `service` array\n\t * that the upstream service should forward requests to.\n\t *\n\t * must start with `#`\n\t *\n\t * common values include:\n\t * - `#atproto_pds` (personal data server)\n\t * - `#atproto_labeler` (labeler service)\n\t * - `#bsky_chat` (Bluesky chat service)\n\t */\n\tserviceId: `#${string}`;\n};\n\n/** options for configuring the client */\nexport type ClientOptions = {\n\t/** the underlying fetch handler it should make requests with */\n\thandler: FetchHandler | FetchHandlerObject;\n\t/** service proxy configuration */\n\tproxy?: ServiceProxyOptions | null;\n};\n\nconst JSON_CONTENT_TYPE_RE = /\\bapplication\\/json\\b/;\n\n/** XRPC API client */\nexport class Client\u003cTQueries = XRPCQueries, TProcedures = XRPCProcedures\u003e {\n\thandler: FetchHandler;\n\tproxy: ServiceProxyOptions | null;\n\n\tconstructor({ handler, proxy = null }: ClientOptions) {\n\t\tthis.handler = buildFetchHandler(handler);\n\t\tthis.proxy = proxy;\n\t}\n\n\t/**\n\t * clones this XRPC client\n\t * @param opts options to merge with\n\t * @returns the cloned XRPC client\n\t */\n\tclone({ handler = this.handler, proxy = this.proxy }: Partial\u003cClientOptions\u003e = {}): Client\u003c\n\t\tTQueries,\n\t\tTProcedures\n\t\u003e {\n\t\treturn new Client({ handler, proxy });\n\t}\n\n\t/**\n\t * performs an XRPC query request (HTTP GET)\n\t * @param name NSID of the query\n\t * @param options query options\n\t */\n\tget\u003cTName extends keyof TQueries, TInit extends QueryRequestOptions\u003cTQueries[TName]\u003e\u003e(\n\t\tname: TName,\n\t\t...options: HasRequiredKeys\u003cTInit\u003e extends true ? [init: TInit] : [init?: TInit]\n\t): Promise\u003cClientResponse\u003cTQueries[TName], TInit\u003e\u003e;\n\n\tget(name: string, options: InternalRequestOptions = {}) {\n\t\treturn this.#perform('get', name, options);\n\t}\n\n\t/**\n\t * performs an XRPC procedure request (HTTP POST)\n\t * @param name NSID of the procedure\n\t * @param options procedure options\n\t */\n\tpost\u003cTName extends keyof TProcedures, TInit extends ProcedureRequestOptions\u003cTProcedures[TName]\u003e\u003e(\n\t\tname: TName,\n\t\t...options: HasRequiredKeys\u003cTInit\u003e extends true ? [init: TInit] : [init?: TInit]\n\t): Promise\u003cClientResponse\u003cTProcedures[TName], TInit\u003e\u003e;\n\n\tpost(name: string, options: InternalRequestOptions = {}) {\n\t\treturn this.#perform('post', name, options);\n\t}\n\n\t/**\n\t * performs an XRPC call with schema validation\n\t * @param schema the lexicon schema for the endpoint, or a namespace containing mainSchema\n\t * @param options call options\n\t */\n\tcall\u003cTMeta extends XRPCQueryMetadata | XRPCProcedureMetadata, TInit extends CallRequestOptions\u003cTMeta\u003e\u003e(\n\t\tschema: TMeta | Namespaced\u003cTMeta\u003e,\n\t\t...options: HasRequiredKeys\u003cTInit\u003e extends true ? [init: TInit] : [init?: TInit]\n\t): Promise\u003cClientResponse\u003cTMeta, TInit\u003e\u003e;\n\n\tasync call(schema: any, options: any = {}): Promise\u003cany\u003e {\n\t\t// early bailout for tree-shaking when schemas aren't used\n\t\tif (!v.xrpcSchemaGenerated) {\n\t\t\treturn;\n\t\t}\n\n\t\t// extract mainSchema if namespace was passed\n\t\tif ('mainSchema' in schema) {\n\t\t\tschema = schema.mainSchema;\n\t\t}\n\n\t\tif (schema.params !== null) {\n\t\t\tconst paramsResult = v.safeParse(schema.params, options.params);\n\t\t\tif (!paramsResult.ok) {\n\t\t\t\tthrow new ClientValidationError('params', paramsResult);\n\t\t\t}\n\t\t}\n\n\t\tif (schema.type === 'xrpc_procedure' \u0026\u0026 schema.input?.type === 'lex') {\n\t\t\tconst inputResult = v.safeParse(schema.input.schema, options.input);\n\t\t\tif (!inputResult.ok) {\n\t\t\t\tthrow new ClientValidationError('input', inputResult);\n\t\t\t}\n\t\t}\n\n\t\tconst isQuery = schema.type === 'xrpc_query';\n\t\tconst method = isQuery ? 'get' : 'post';\n\n\t\tif (options.as === undefined \u0026\u0026 schema.output?.type === 'blob') {\n\t\t\tthrow new TypeError(`\\`as\\` option is required for endpoints returning blobs`);\n\t\t}\n\n\t\tconst format = options.as !== undefined ? options.as : schema.output?.type === 'lex' ? 'json' : null;\n\n\t\tconst response = await this.#perform(method, schema.nsid, {\n\t\t\tparams: options.params,\n\t\t\tinput: isQuery ? undefined : options.input,\n\t\t\tas: format,\n\t\t\tsignal: options.signal,\n\t\t\theaders: options.headers,\n\t\t});\n\n\t\tif (format === 'json' \u0026\u0026 response.ok \u0026\u0026 schema.output?.type === 'lex') {\n\t\t\tconst outputResult = v.safeParse(schema.output.schema, response.data);\n\t\t\tif (!outputResult.ok) {\n\t\t\t\tthrow new ClientValidationError('output', outputResult);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders: response.headers,\n\t\t\t\tdata: outputResult.value,\n\t\t\t};\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tasync #perform(\n\t\tmethod: 'get' | 'post',\n\t\tname: string,\n\t\t{ signal, as: format = 'json', headers, input, params }: InternalRequestOptions,\n\t) {\n\t\tconst isWebInput =\n\t\t\tinput \u0026\u0026\n\t\t\t(input instanceof Blob ||\n\t\t\t\tArrayBuffer.isView(input) ||\n\t\t\t\tinput instanceof ArrayBuffer ||\n\t\t\t\tinput instanceof ReadableStream);\n\n\t\tconst url = `/xrpc/${name}` + _constructSearchParams(params);\n\n\t\tconst response = await this.handler(url, {\n\t\t\tmethod,\n\t\t\tsignal,\n\t\t\tbody: input \u0026\u0026 !isWebInput ? JSON.stringify(input) : input,\n\t\t\theaders: _mergeHeaders(headers, {\n\t\t\t\t'content-type': input \u0026\u0026 !isWebInput ? 'application/json' : null,\n\t\t\t\t'atproto-proxy': _constructProxyHeader(this.proxy),\n\t\t\t}),\n\t\t\tduplex: input instanceof ReadableStream ? 'half' : undefined,\n\t\t});\n\n\t\t{\n\t\t\tconst status = response.status;\n\t\t\tconst headers = response.headers;\n\n\t\t\tconst type = headers.get('content-type');\n\n\t\t\tif (status !== 200) {\n\t\t\t\tlet json: any;\n\n\t\t\t\tif (type != null \u0026\u0026 JSON_CONTENT_TYPE_RE.test(type)) {\n\t\t\t\t\t// it should be okay to swallow the parsing error here\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst parsed = await response.json();\n\t\t\t\t\t\tif (isXRPCErrorPayload(parsed)) {\n\t\t\t\t\t\t\tjson = parsed;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {}\n\t\t\t\t} else {\n\t\t\t\t\tawait response.body?.cancel();\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\tstatus: status,\n\t\t\t\t\theaders: headers,\n\t\t\t\t\tdata: json ?? {\n\t\t\t\t\t\terror: `UnknownXRPCError`,\n\t\t\t\t\t\tmessage: `Request failed with status code ${status}`,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t{\n\t\t\t\tlet data: any;\n\t\t\t\tswitch (format) {\n\t\t\t\t\tcase 'json': {\n\t\t\t\t\t\tif (type != null \u0026\u0026 JSON_CONTENT_TYPE_RE.test(type)) {\n\t\t\t\t\t\t\t// we shouldn't be handling parsing errors\n\t\t\t\t\t\t\tdata = await response.json();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tawait response.body?.cancel();\n\n\t\t\t\t\t\t\tthrow new TypeError(`Invalid response content-type (got ${type})`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase null: {\n\t\t\t\t\t\tdata = null;\n\n\t\t\t\t\t\tawait response.body?.cancel();\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'blob': {\n\t\t\t\t\t\tdata = await response.blob();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'bytes': {\n\t\t\t\t\t\tdata = new Uint8Array(await response.arrayBuffer());\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'stream': {\n\t\t\t\t\t\tdata = response.body!;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tok: true,\n\t\t\t\t\tstatus: status,\n\t\t\t\t\theaders: headers,\n\t\t\t\t\tdata: data,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n}\n\n// #endregion\n\n// #region Utility functions\nconst _constructSearchParams = (params: Record\u003cstring, unknown\u003e | undefined): string =\u003e {\n\tlet searchParams: URLSearchParams | undefined;\n\n\tfor (const key in params) {\n\t\tconst value = params[key];\n\n\t\tif (value !== undefined) {\n\t\t\tsearchParams ??= new URLSearchParams();\n\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tfor (let idx = 0, len = value.length; idx \u003c len; idx++) {\n\t\t\t\t\tconst val = value[idx];\n\t\t\t\t\tsearchParams.append(key, '' + val);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsearchParams.set(key, '' + value);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn searchParams ? `?` + searchParams.toString() : '';\n};\n\nconst _constructProxyHeader = (proxy: ServiceProxyOptions | null | undefined): string | null =\u003e {\n\tif (proxy != null) {\n\t\treturn `${proxy.did}${proxy.serviceId}`;\n\t}\n\n\treturn null;\n};\n\nconst _mergeHeaders = (\n\tinit: HeadersInit | undefined,\n\tdefaults: Record\u003cstring, string | null\u003e,\n): HeadersInit | undefined =\u003e {\n\tlet headers: Headers | undefined;\n\n\tfor (const name in defaults) {\n\t\tconst value = defaults[name];\n\n\t\tif (value !== null) {\n\t\t\theaders ??= new Headers(init);\n\n\t\t\tif (!headers.has(name)) {\n\t\t\t\theaders.set(name, value);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn headers ?? init;\n};\n\nexport const isXRPCErrorPayload = (input: any): input is XRPCErrorPayload =\u003e {\n\tif (typeof input !== 'object' || input == null) {\n\t\treturn false;\n\t}\n\n\tconst kindType = typeof input.error;\n\tconst messageType = typeof input.message;\n\n\treturn kindType === 'string' \u0026\u0026 (messageType === 'undefined' || messageType === 'string');\n};\n// #endregion\n\n// #region Optimistic response helper\ntype ExtractSuccessData\u003cR\u003e = R extends { ok: true; data: infer D } ? D : never;\n\n/**\n * takes in the response returned by the client, and either returns the data if\n * it is a successful response, or throws if it's a failed response.\n * @param input either a ClientResponse, or a promise that resolves to a ClientResponse\n * @returns the data from a successful response\n *\n * @example\n * const data = await ok(client.get('com.atproto.server.describeServer'));\n * // ^? ComAtprotoServerDescribeServer.Output\n */\nexport const ok: {\n\t\u003cT extends UnknownClientResponse\u003e(promise: Promise\u003cT\u003e): Promise\u003cExtractSuccessData\u003cT\u003e\u003e;\n\t\u003cT extends UnknownClientResponse\u003e(response: T): ExtractSuccessData\u003cT\u003e;\n} = (input: Promise\u003cUnknownClientResponse\u003e | UnknownClientResponse): any =\u003e {\n\tif (input instanceof Promise) {\n\t\treturn input.then(ok);\n\t}\n\n\tif (input.ok) {\n\t\treturn input.data;\n\t}\n\n\tthrow new ClientResponseError(input);\n};\n\n/** options when constructing a ClientResponseError */\nexport type ClientResponseErrorOptions = {\n\tstatus: number;\n\theaders?: Headers;\n\tdata: XRPCErrorPayload;\n};\n\n/** represents an error response returned by the client */\nexport class ClientResponseError extends Error {\n\t/** error name returned by service */\n\treadonly error: string;\n\t/** error message returned by service */\n\treadonly description?: string;\n\n\t/** response status */\n\treadonly status: number;\n\t/** response headers */\n\treadonly headers: Headers;\n\n\tconstructor({ status, headers = new Headers(), data }: ClientResponseErrorOptions) {\n\t\tsuper(`${data.error} \u003e ${data.message ?? '(unspecified description)'}`);\n\n\t\tthis.name = 'ClientResponseError';\n\n\t\tthis.error = data.error;\n\t\tthis.description = data.message;\n\n\t\tthis.status = status;\n\t\tthis.headers = headers;\n\t}\n}\n\n/** represents a validation error during typed calls */\nexport class ClientValidationError extends Error {\n\t/** validation target (params, input, or output) */\n\treadonly target: 'params' | 'input' | 'output';\n\t/** validation result */\n\treadonly result: v.Err;\n\n\tconstructor(target: 'params' | 'input' | 'output', result: v.Err) {\n\t\tsuper(`validation failed for ${target}: ${result.message}`);\n\n\t\tthis.name = 'ClientValidationError';\n\t\tthis.target = target;\n\t\tthis.result = result;\n\t}\n}\n\n// #endregion\n","/** fetch handler function */\nexport type FetchHandler = (pathname: string, init: RequestInit) =\u003e Promise\u003cResponse\u003e;\n\n/** fetch handler in an object */\nexport interface FetchHandlerObject {\n\thandle(this: FetchHandlerObject, pathname: string, init: RequestInit): Promise\u003cResponse\u003e;\n}\n\nexport const buildFetchHandler = (handler: FetchHandler | FetchHandlerObject): FetchHandler =\u003e {\n\tif (typeof handler === 'object') {\n\t\treturn handler.handle.bind(handler);\n\t}\n\n\treturn handler;\n};\n\nexport interface SimpleFetchHandlerOptions {\n\tservice: string | URL;\n\tfetch?: typeof globalThis.fetch;\n}\n\nexport const simpleFetchHandler = ({\n\tservice,\n\tfetch: _fetch = fetch,\n}: SimpleFetchHandlerOptions): FetchHandler =\u003e {\n\treturn async (pathname, init) =\u003e {\n\t\tconst url = new URL(pathname, service);\n\t\treturn await _fetch(url.href, init);\n\t};\n};\n","import { getPdsEndpoint, type DidDocument } from '@atcute/identity';\nimport type { Did } from '@atcute/lexicons';\n\nimport type { ComAtprotoServerCreateSession } from '@atcute/atproto';\n\nimport { Client, ClientResponseError, isXRPCErrorPayload, ok } from './client.js';\nimport { simpleFetchHandler, type FetchHandlerObject } from './fetch-handler.js';\n\nimport { decodeJwt } from './utils/jwt.js';\n\n/**\n * represents the decoded access token, for convenience\n * @deprecated\n */\nexport interface AtpAccessJwt {\n\t/** access token scope */\n\tscope:\n\t\t| 'com.atproto.access'\n\t\t| 'com.atproto.appPass'\n\t\t| 'com.atproto.appPassPrivileged'\n\t\t| 'com.atproto.signupQueued'\n\t\t| 'com.atproto.takendown';\n\t/** account DID */\n\tsub: Did;\n\t/** expiration time in Unix seconds */\n\texp: number;\n\t/** token issued time in Unix seconds */\n\tiat: number;\n}\n\n/**\n * represents the the decoded refresh token, for convenience\n * @deprecated\n */\nexport interface AtpRefreshJwt {\n\t/** refresh token scope */\n\tscope: 'com.atproto.refresh';\n\t/** unique identifier for this session */\n\tjti: string;\n\t/** account DID */\n\tsub: Did;\n\t/** intended audience of this refresh token, in DID */\n\taud: Did;\n\t/** token expiration time in seconds */\n\texp: number;\n\t/** token issued time in seconds */\n\tiat: number;\n}\n\n/** session data, can be persisted and reused */\nexport interface AtpSessionData {\n\t/** refresh token */\n\trefreshJwt: string;\n\t/** access token */\n\taccessJwt: string;\n\t/** account handle */\n\thandle: string;\n\t/** account DID */\n\tdid: Did;\n\t/** PDS endpoint found in the DID document, this will be used as the service URI if provided */\n\tpdsUri?: string;\n\t/** email address of the account, might not be available if on app password */\n\temail?: string;\n\t/** whether the email address has been confirmed or not */\n\temailConfirmed?: boolean;\n\t/** whether the account has email-based two-factor authentication enabled */\n\temailAuthFactor?: boolean;\n\t/** whether the account is active (not deactivated, taken down, or suspended) */\n\tactive: boolean;\n\t/** possible reason for why the account is inactive */\n\tinactiveStatus?: string;\n}\n\nexport interface CredentialManagerOptions {\n\t/** PDS server URL */\n\tservice: string;\n\n\t/** custom fetch function */\n\tfetch?: typeof fetch;\n\n\t/** function called when the session expires and can't be refreshed */\n\tonExpired?: (session: AtpSessionData) =\u003e void;\n\t/** function called after a successful session refresh */\n\tonRefresh?: (session: AtpSessionData) =\u003e void;\n\t/** function called whenever the session object is updated (login, resume, refresh) */\n\tonSessionUpdate?: (session: AtpSessionData) =\u003e void;\n}\n\nexport class CredentialManager implements FetchHandlerObject {\n\t/** service URL to make authentication requests with */\n\treadonly serviceUrl: string;\n\t/** fetch implementation */\n\tfetch: typeof fetch;\n\n\t/** internal client instance for making authentication requests */\n\t#server: Client;\n\t/** holds a promise for the current refresh operation, used for debouncing */\n\t#refreshSessionPromise: Promise\u003cvoid\u003e | undefined;\n\n\t/** callback for session expiration */\n\t#onExpired: CredentialManagerOptions['onExpired'];\n\t/** callback for successful session refresh */\n\t#onRefresh: CredentialManagerOptions['onRefresh'];\n\t/** callback for session updates */\n\t#onSessionUpdate: CredentialManagerOptions['onSessionUpdate'];\n\n\t/** current active session, undefined if not authenticated */\n\tsession?: AtpSessionData;\n\n\tconstructor({\n\t\tservice,\n\t\tonExpired,\n\t\tonRefresh,\n\t\tonSessionUpdate,\n\t\tfetch: _fetch = fetch,\n\t}: CredentialManagerOptions) {\n\t\tthis.serviceUrl = service;\n\t\tthis.fetch = _fetch;\n\n\t\tthis.#server = new Client({ handler: simpleFetchHandler({ service, fetch: _fetch }) });\n\n\t\tthis.#onRefresh = onRefresh;\n\t\tthis.#onExpired = onExpired;\n\t\tthis.#onSessionUpdate = onSessionUpdate;\n\t}\n\n\t/** service URL to make actual API requests with */\n\tget dispatchUrl() {\n\t\treturn this.session?.pdsUri ?? this.serviceUrl;\n\t}\n\n\tasync handle(pathname: string, init: RequestInit): Promise\u003cResponse\u003e {\n\t\tawait this.#refreshSessionPromise;\n\n\t\tconst url = new URL(pathname, this.dispatchUrl);\n\t\tconst headers = new Headers(init.headers);\n\n\t\tif (!this.session || headers.has('authorization')) {\n\t\t\treturn (0, this.fetch)(url, init);\n\t\t}\n\n\t\tconst initialToken = this.session.accessJwt;\n\t\theaders.set('authorization', `Bearer ${initialToken}`);\n\n\t\tconst initialResponse = await (0, this.fetch)(url, { ...init, headers });\n\n\t\tif (initialResponse.status !== 401 \u0026\u0026 !(await isExpiredTokenResponse(initialResponse))) {\n\t\t\treturn initialResponse;\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.#refreshSession();\n\t\t} catch {\n\t\t\treturn initialResponse;\n\t\t}\n\n\t\t// return initial response if:\n\t\t// - request was aborted\n\t\t// - refresh failed and cleared the session\n\t\t// - token didn't actually change (refresh failed silently)\n\t\t// - request body was a stream (can't be resent)\n\t\tconst updatedToken = this.session?.accessJwt;\n\t\tif (\n\t\t\tinit.signal?.aborted ||\n\t\t\t!updatedToken ||\n\t\t\tupdatedToken === initialToken ||\n\t\t\tinit.body instanceof ReadableStream\n\t\t) {\n\t\t\treturn initialResponse;\n\t\t}\n\n\t\t// cancel initial response to avoid resource leaks (Node.js)\n\t\tawait initialResponse.body?.cancel();\n\n\t\theaders.set('authorization', `Bearer ${updatedToken}`);\n\t\treturn await (0, this.fetch)(url, { ...init, headers });\n\t}\n\n\t#refreshSession() {\n\t\treturn (this.#refreshSessionPromise ||= this.#refreshSessionInner().finally(\n\t\t\t() =\u003e (this.#refreshSessionPromise = undefined),\n\t\t));\n\t}\n\n\tasync #refreshSessionInner(): Promise\u003cvoid\u003e {\n\t\tconst currentSession = this.session;\n\t\tif (!currentSession) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst response = await this.#server.post('com.atproto.server.refreshSession', {\n\t\t\theaders: {\n\t\t\t\tauthorization: `Bearer ${currentSession.refreshJwt}`,\n\t\t\t},\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tconst isExpired =\n\t\t\t\tresponse.status === 401 ||\n\t\t\t\tresponse.data.error === 'ExpiredToken' ||\n\t\t\t\tresponse.data.error === 'InvalidToken';\n\n\t\t\tif (isExpired) {\n\t\t\t\tthis.session = undefined;\n\t\t\t\tthis.#onExpired?.(currentSession);\n\t\t\t}\n\n\t\t\tthrow new ClientResponseError(response);\n\t\t}\n\n\t\t// DID must not change during refresh\n\t\tif (response.data.did !== currentSession.did) {\n\t\t\tthis.session = undefined;\n\t\t\tthis.#onExpired?.(currentSession);\n\t\t\tthrow new ClientResponseError({ status: 401, data: { error: 'InvalidDID' } });\n\t\t}\n\n\t\t// protect against concurrent session updates\n\t\tif (this.session !== currentSession) {\n\t\t\tthrow new Error('concurrent session update detected');\n\t\t}\n\n\t\tthis.#updateSession({ ...currentSession, ...response.data });\n\t\tthis.#onRefresh?.(this.session!);\n\t}\n\n\t#updateSession(raw: ComAtprotoServerCreateSession.$output): AtpSessionData {\n\t\tconst didDoc = raw.didDoc as DidDocument | undefined;\n\n\t\tlet pdsUri: string | undefined;\n\t\tif (didDoc) {\n\t\t\tpdsUri = getPdsEndpoint(didDoc);\n\t\t}\n\n\t\tconst newSession: AtpSessionData = {\n\t\t\taccessJwt: raw.accessJwt,\n\t\t\trefreshJwt: raw.refreshJwt,\n\t\t\thandle: raw.handle,\n\t\t\tdid: raw.did,\n\t\t\tpdsUri: pdsUri,\n\t\t\temail: raw.email,\n\t\t\temailConfirmed: raw.emailConfirmed,\n\t\t\temailAuthFactor: raw.emailAuthFactor,\n\t\t\tactive: raw.active ?? true,\n\t\t\tinactiveStatus: raw.status,\n\t\t};\n\n\t\tthis.session = newSession;\n\t\tthis.#onSessionUpdate?.(newSession);\n\n\t\treturn newSession;\n\t}\n\n\t/**\n\t * resume from a persisted session\n\t * @param session session data, taken from `AtpAuth#session` after login\n\t */\n\tasync resume(session: AtpSessionData): Promise\u003cAtpSessionData\u003e {\n\t\t// protect against concurrent resume of the same session\n\t\tif (session.refreshJwt === this.session?.refreshJwt) {\n\t\t\tawait this.#refreshSessionPromise;\n\t\t\tif (!this.session || session.did !== this.session.did) {\n\t\t\t\tthrow new ClientResponseError({ status: 401, data: { error: 'InvalidToken' } });\n\t\t\t}\n\t\t\treturn this.session;\n\t\t}\n\n\t\tconst now = Date.now() / 1_000 + 60 * 5;\n\n\t\tconst refreshToken = decodeJwt(session.refreshJwt) as AtpRefreshJwt;\n\t\tif (now \u003e= refreshToken.exp || refreshToken.sub !== session.did) {\n\t\t\tthrow new ClientResponseError({ status: 401, data: { error: 'InvalidToken' } });\n\t\t}\n\n\t\tconst accessToken = decodeJwt(session.accessJwt) as AtpAccessJwt;\n\t\tif (accessToken.sub !== session.did) {\n\t\t\tthrow new ClientResponseError({ status: 401, data: { error: 'InvalidToken' } });\n\t\t}\n\n\t\t// set the session and clear any stale refresh promise\n\t\tthis.session = session;\n\t\tthis.#refreshSessionPromise = undefined;\n\n\t\tif (now \u003e= accessToken.exp) {\n\t\t\t// access token expired, need to refresh\n\t\t\tawait this.#refreshSession();\n\t\t} else {\n\t\t\t// access token still valid, fetch session info in background\n\t\t\tconst promise = ok(\n\t\t\t\tthis.#server.get('com.atproto.server.getSession', {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tauthorization: `Bearer ${session.accessJwt}`,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\tpromise.then(\n\t\t\t\t(next) =\u003e {\n\t\t\t\t\tconst existing = this.session;\n\t\t\t\t\tif (!existing || existing.did !== next.did) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.#updateSession({ ...existing, ...next });\n\t\t\t\t},\n\t\t\t\t(_err) =\u003e {\n\t\t\t\t\t// ignore error\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tif (!this.session) {\n\t\t\tthrow new ClientResponseError({ status: 401, data: { error: 'InvalidToken' } });\n\t\t}\n\n\t\treturn this.session;\n\t}\n\n\t/**\n\t * sign in to an account\n\t * @param options credential options\n\t * @returns session data\n\t */\n\tasync login(options: AuthLoginOptions): Promise\u003cAtpSessionData\u003e {\n\t\t// reset the session\n\t\tthis.session = undefined;\n\t\tthis.#refreshSessionPromise = undefined;\n\n\t\tconst session = await ok(\n\t\t\tthis.#server.post('com.atproto.server.createSession', {\n\t\t\t\tinput: {\n\t\t\t\t\tidentifier: options.identifier,\n\t\t\t\t\tpassword: options.password,\n\t\t\t\t\tauthFactorToken: options.code,\n\t\t\t\t\tallowTakendown: options.allowTakendown,\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\n\t\treturn this.#updateSession(session);\n\t}\n\n\t/**\n\t * sign out of the current session, invalidating it server-side\n\t */\n\tasync logout(): Promise\u003cvoid\u003e {\n\t\tconst currentSession = this.session;\n\t\tif (!currentSession) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.session = undefined;\n\t\tthis.#refreshSessionPromise = undefined;\n\n\t\ttry {\n\t\t\tawait this.#server.post('com.atproto.server.deleteSession', {\n\t\t\t\tas: null,\n\t\t\t\theaders: {\n\t\t\t\t\tauthorization: `Bearer ${currentSession.refreshJwt}`,\n\t\t\t\t},\n\t\t\t});\n\t\t} catch {\n\t\t\t// ignore errors - session is already cleared locally\n\t\t}\n\t}\n}\n\n/** credentials */\nexport interface AuthLoginOptions {\n\t/** what account to login as, this could be domain handle, DID, or email address */\n\tidentifier: string;\n\t/** account password */\n\tpassword: string;\n\t/** two-factor authentication code, if email TOTP is enabled */\n\tcode?: string;\n\t/** allow signing in even if the account has been taken down */\n\tallowTakendown?: boolean;\n}\n\nconst isExpiredTokenResponse = async (response: Response): Promise\u003cboolean\u003e =\u003e {\n\tif (response.status !== 400) {\n\t\treturn false;\n\t}\n\n\tif (extractContentType(response.headers) !== 'application/json') {\n\t\treturn false;\n\t}\n\n\t// this is nasty as it relies heavily on what the PDS returns, but avoiding\n\t// cloning and reading the request as much as possible is better.\n\n\t// {\"error\":\"ExpiredToken\",\"message\":\"Token has expired\"}\n\t// {\"error\":\"ExpiredToken\",\"message\":\"Token is expired\"}\n\tif (extractContentLength(response.headers) \u003e 54 * 1.5) {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tconst data = await response.clone().json();\n\t\tif (isXRPCErrorPayload(data)) {\n\t\t\treturn data.error === 'ExpiredToken';\n\t\t}\n\t} catch {}\n\n\treturn false;\n};\n\nconst extractContentType = (headers: Headers) =\u003e {\n\treturn headers.get('content-type')?.split(';')[0]?.trim();\n};\nconst extractContentLength = (headers: Headers) =\u003e {\n\treturn Number(headers.get('content-length') ?? ';');\n};\n","/**\n * @module\n * JWT decoding utilities for session resumption checks.\n * This module is exported for convenience and is no way part of public API,\n * it can be removed at any time.\n */\n\n/**\n * Decodes a JWT token\n * @param token The token string\n * @returns JSON object from the token\n */\nexport const decodeJwt = (token: string): unknown =\u003e {\n\tconst pos = 1;\n\tconst part = token.split('.')[1];\n\n\tlet decoded: string;\n\n\tif (typeof part !== 'string') {\n\t\tthrow new Error('invalid token: missing part ' + (pos + 1));\n\t}\n\n\ttry {\n\t\tdecoded = base64UrlDecode(part);\n\t} catch (e) {\n\t\tthrow new Error('invalid token: invalid b64 for part ' + (pos + 1) + ' (' + (e as Error).message + ')');\n\t}\n\n\ttry {\n\t\treturn JSON.parse(decoded);\n\t} catch (e) {\n\t\tthrow new Error('invalid token: invalid json for part ' + (pos + 1) + ' (' + (e as Error).message + ')');\n\t}\n};\n\n/**\n * Decodes a URL-safe Base64 string\n * @param str URL-safe Base64 that needed to be decoded\n * @returns The actual string\n */\nexport const base64UrlDecode = (str: string): string =\u003e {\n\tlet output = str.replace(/-/g, '+').replace(/_/g, '/');\n\n\tswitch (output.length % 4) {\n\t\tcase 0:\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\toutput += '==';\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\toutput += '=';\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error('base64 string is not of the correct length');\n\t}\n\n\ttry {\n\t\treturn b64DecodeUnicode(output);\n\t} catch {\n\t\treturn atob(output);\n\t}\n};\n\nconst b64DecodeUnicode = (str: string): string =\u003e {\n\treturn decodeURIComponent(\n\t\tatob(str).replace(/(.)/g, (_m, p) =\u003e {\n\t\t\tlet code = p.charCodeAt(0).toString(16).toUpperCase();\n\n\t\t\tif (code.length \u003c 2) {\n\t\t\t\tcode = '0' + code;\n\t\t\t}\n\n\t\t\treturn '%' + code;\n\t\t}),\n\t);\n};\n"],"version":3}
+4
vendor/esm.sh/@atcute/identity-resolver@1.2.2/es2022/identity-resolver.mjs
··· 1 + /* esm.sh - @atcute/identity-resolver@1.2.2 */ 2 + import{getAtprotoHandle as H,getPdsEndpoint as S}from"../../identity@1.1.4/es2022/identity.mjs";import{isDid as X}from"../../lexicons@1.2.10/es2022/syntax.mjs";var v=class extends Error{name="DidResolutionError"},h=class extends v{did;name="UnsupportedDidMethodError";constructor(e){super(`unsupported did method; did=${e}`),this.did=e}},U=class extends v{did;name="ImproperDidError";constructor(e){super(`improper did; did=${e}`),this.did=e}},p=class extends v{did;name="DocumentNotFoundError";constructor(e){super(`did document not found; did=${e}`),this.did=e}},u=class extends v{did;name="FailedDocumentResolutionError";constructor(e,r){super(`failed to resolve did document; did=${e}`,r),this.did=e}},E=class extends Error{name="HandleResolutionError"},f=class extends E{handle;name="DidNotFoundError";constructor(e){super(`handle returned no did; handle=${e}`),this.handle=e}},m=class extends E{handle;name="FailedHandleResolutionError";constructor(e,r){super(`failed to resolve handle; handle=${e}`,r),this.handle=e}},g=class extends E{handle;did;name="InvalidResolvedHandleError";constructor(e,r){super(`handle returned invalid did; handle=${e}; did=${r}`),this.handle=e,this.did=r}},R=class extends E{name="AmbiguousHandleError";constructor(e){super(`handle returned multiple did values; handle=${e}`)}},y=class extends Error{name="ActorResolutionError"};var A=class{handleResolver;didDocumentResolver;constructor(e){this.handleResolver=e.handleResolver,this.didDocumentResolver=e.didDocumentResolver}async resolve(e,r){let n=X(e),t;if(n)t=e;else try{t=await this.handleResolver.resolve(e,r)}catch(c){throw new y("failed to resolve handle",{cause:c})}let s;try{s=await this.didDocumentResolver.resolve(t,r)}catch(c){throw new y("failed to resolve did document",{cause:c})}let o=S(s);if(!o)throw new y("missing pds endpoint");let a="handle.invalid";if(n){let c=H(s);if(c)try{await this.handleResolver.resolve(c,r)===t&&(a=c)}catch{}}else H(s)===e&&(a=e);return{did:t,handle:a,pds:new URL(o).href}}};import{extractDidMethod as B}from"../../identity@1.1.4/es2022/identity.mjs";var T=class{#e;constructor({methods:e}){this.#e=new Map(Object.entries(e))}async resolve(e,r){let n=B(e),t=this.#e.get(n);if(t===void 0)throw new h(e);return await t.resolve(e,r)}};import{FailedResponseError as Q}from"../../util-fetch@1.0.5/es2022/util-fetch.mjs";import{defs as _}from"../../identity@1.1.4/es2022/identity.mjs";import{isResponseOk as q,parseResponseAsJson as z,pipe as G,validateJsonWith as K}from"../../util-fetch@1.0.5/es2022/util-fetch.mjs";var j=G(q,z(/^application\/(did\+ld\+)?json$/,20*1024),K(_.didDocument,{mode:"passthrough"}));var N=class{apiUrl;#e;constructor({apiUrl:e="https://plc.directory",fetch:r=fetch}={}){this.apiUrl=e,this.#e=r}async resolve(e,r){if(!e.startsWith("did:plc:"))throw new h(e);let n;try{let t=new URL(`/${encodeURIComponent(e)}`,this.apiUrl),s=await(0,this.#e)(t,{signal:r?.signal,cache:r?.noCache?"no-cache":void 0,redirect:"manual",headers:{accept:"application/did+ld+json,application/json"}});if(s.status>=300&&s.status<400)throw new TypeError("unexpected redirect");n=(await j(s)).json}catch(t){throw t instanceof Q&&t.status===404?new p(e):new u(e,{cause:t})}return n}};import{webDidToDocumentUrl as V}from"../../identity@1.1.4/es2022/identity.mjs";import{FailedResponseError as I}from"../../util-fetch@1.0.5/es2022/util-fetch.mjs";var P=class{#e;constructor({fetch:e=fetch}={}){this.#e=e}async resolve(e,r){if(!e.startsWith("did:web:"))throw new h(e);let n;try{let t=V(e),s=await(0,this.#e)(t,{signal:r?.signal,cache:r?.noCache?"no-cache":void 0,redirect:"manual",headers:{accept:"application/did+ld+json,application/json"}});if(s.status>=300&&s.status<400)throw new TypeError("unexpected redirect");n=(await j(s)).json}catch(t){throw t instanceof I&&t.status===404?new p(e):new u(e,{cause:t})}return n}},C=class{#e;constructor({fetch:e=fetch}={}){this.#e=e}async resolve(e,r){if(!e.startsWith("did:web:"))throw new h(e);let[n,...t]=e.slice(8).split(":").map(decodeURIComponent),s=new URL(`https://${n}/.well-known/did.json`);if(t.length>0)throw new U(e);let o;try{let a=await(0,this.#e)(s,{signal:r?.signal,cache:r?.noCache?"no-cache":void 0,redirect:"manual",headers:{accept:"application/did+ld+json,application/json"}});if(a.status>=300&&a.status<400)throw new TypeError("unexpected redirect");o=(await j(a)).json}catch(a){throw a instanceof I&&a.status===404?new p(e):new u(e,{cause:a})}return o}};import{defs as Y}from"../../identity@1.1.4/es2022/identity.mjs";import{FailedResponseError as Z,isResponseOk as ee,parseResponseAsJson as re,pipe as te,validateJsonWith as oe}from"../../util-fetch@1.0.5/es2022/util-fetch.mjs";import*as M from"../../../@badrap/valita@0.4.6/es2022/valita.mjs";var se=te(ee,re(/^application\/json$/,20*1024+16),oe(M.object({didDoc:Y.didDocument}),{mode:"passthrough"})),L=class{serviceUrl;#e;constructor({serviceUrl:e,fetch:r=fetch}){this.serviceUrl=e,this.#e=r}async resolve(e,r){let n;try{let t=new URL("/xrpc/com.atproto.identity.resolveDid",this.serviceUrl);t.searchParams.set("did",e);let s=await(0,this.#e)(t,{signal:r?.signal,cache:r?.noCache?"no-cache":void 0,headers:{accept:"application/json"}});n=(await se(s)).json.didDoc}catch(t){throw t instanceof Z&&t.status===404?new p(e):new u(e,{cause:t})}return n}};var k=class{#e;strategy;constructor({methods:e,strategy:r="race"}){this.#e=e,this.strategy=r}async resolve(e,r){let{http:n,dns:t}=this.#e,s=r?.signal,o=new AbortController;s&&s.addEventListener("abort",()=>o.abort(),{signal:o.signal});let a=t.resolve(e,{...r,signal:o.signal}),c=n.resolve(e,{...r,signal:o.signal});switch(this.strategy){case"race":return new Promise(d=>{a.then(l=>{o.abort(),d(l)},()=>d(c)),c.then(l=>{o.abort(),d(l)},()=>d(a))});case"dns-first":{c.catch(F);let d=await a.catch(F);return d?(o.abort(),d):c}case"http-first":{a.catch(F);let d=await c.catch(F);return d?(o.abort(),d):a}case"both":{let[d,l]=await Promise.allSettled([a,c]),x=d.status==="fulfilled"?d.value:void 0,D=l.status==="fulfilled"?l.value:void 0;if(x&&D&&x!==D)throw new R(e);return x||D||a}}}},F=()=>{};import{isAtprotoDid as ne}from"../../identity@1.1.4/es2022/identity.mjs";import{fetchDohJsonTxt as ae}from"../../util-fetch@1.0.5/es2022/util-fetch.mjs";var ie="_atproto",b="did=",J=class{dohUrl;#e;constructor({dohUrl:e,fetch:r=fetch}){this.dohUrl=e,this.#e=r}async resolve(e,r){let n;try{let o=new URL(this.dohUrl);o.searchParams.set("name",`${ie}.${e}`),o.searchParams.set("type","TXT");let a=await(0,this.#e)(o,{signal:r?.signal,cache:r?.noCache?"no-cache":void 0,headers:{accept:"application/dns-json"}});n=(await ae(a)).json}catch(o){throw new m(e,{cause:o})}let t=n.Status,s=n.Answer;if(t!==0)throw t===3?new f(e):new m(e,{cause:new TypeError(`dns returned ${t}`)});for(let o=0,a=s.length;o<a;o++){let d=s[o].data;if(!d.startsWith(b))continue;for(let x=o+1;x<a;x++)if(s[x].data.startsWith(b))throw new R(e);let l=d.slice(b.length);if(!ne(l))throw new g(e,l);return l}throw new f(e)}};import{isAtprotoDid as ce}from"../../identity@1.1.4/es2022/identity.mjs";import{FailedResponseError as de,isResponseOk as le,pipe as he,readResponseAsText as pe}from"../../util-fetch@1.0.5/es2022/util-fetch.mjs";var ue=he(le,pe(2064)),O=class{#e;constructor({fetch:e=fetch}={}){this.#e=e}async resolve(e,r){let n;try{let s=new URL("/.well-known/atproto-did",`https://${e}`),o=await(0,this.#e)(s,{signal:r?.signal,cache:r?.noCache?"no-cache":void 0,redirect:"manual"});if(o.status>=300&&o.status<400)throw new TypeError("unexpected redirect");n=(await ue(o)).text}catch(s){throw s instanceof de&&s.status===404?new f(e):new m(e,{cause:s})}let t=n.split(` 3 + `)[0].trim();if(!ce(t))throw new g(e,t);return t}};import*as $ from"../../../@badrap/valita@0.4.6/es2022/valita.mjs";import{isAtprotoDid as fe}from"../../identity@1.1.4/es2022/identity.mjs";import{FailedResponseError as me,isResponseOk as we,parseResponseAsJson as xe,pipe as ve,validateJsonWith as Ee}from"../../util-fetch@1.0.5/es2022/util-fetch.mjs";var ge=$.object({did:$.string().assert(i=>fe(i))}),Re=ve(we,xe(/^application\/json$/,4*1024),Ee(ge,{mode:"passthrough"})),W=class{serviceUrl;#e;constructor({serviceUrl:e,fetch:r=fetch}){this.serviceUrl=e,this.#e=r}async resolve(e,r){let n;try{let t=new URL("/xrpc/com.atproto.identity.resolveHandle",this.serviceUrl);t.searchParams.set("handle",e);let s=await(0,this.#e)(t,{signal:r?.signal,cache:r?.noCache?"no-cache":void 0,headers:{accept:"application/json"}});n=(await Re(s)).json}catch(t){throw t instanceof me&&t.status===400?new f(e):new m(e,{cause:t})}return n.did}};export{y as ActorResolutionError,R as AmbiguousHandleError,C as AtprotoWebDidDocumentResolver,T as CompositeDidDocumentResolver,k as CompositeHandleResolver,v as DidDocumentResolutionError,f as DidNotFoundError,p as DocumentNotFoundError,J as DohJsonHandleResolver,u as FailedDocumentResolutionError,m as FailedHandleResolutionError,E as HandleResolutionError,U as ImproperDidError,g as InvalidResolvedHandleError,A as LocalActorResolver,N as PlcDidDocumentResolver,h as UnsupportedDidMethodError,P as WebDidDocumentResolver,O as WellKnownHandleResolver,L as XrpcDidDocumentResolver,W as XrpcHandleResolver}; 4 + //# sourceMappingURL=./identity-resolver.mjs.map
+1
vendor/esm.sh/@atcute/identity-resolver@1.2.2/es2022/identity-resolver.mjs.map
··· 1 + {"mappings":";AAAA,OAAS,oBAAAA,EAAkB,kBAAAC,MAAsB,yCACjD,OAAS,SAAAC,MAA0D,gDCE7D,IAAOC,EAAP,cAA0C,KAAK,CAC3C,KAAO,sBAGJC,EAAP,cAAyCD,CAA0B,CAGrD,IAFV,KAAO,4BAEhB,YAAmBE,EAAU,CAC5B,MAAM,+BAA+BA,CAAG,EAAE,WADxBA,CAC0B,GAIjCC,EAAP,cAAgCH,CAA0B,CAG5C,IAFV,KAAO,mBAEhB,YAAmBE,EAAU,CAC5B,MAAM,qBAAqBA,CAAG,EAAE,WADdA,CACgB,GAIvBE,EAAP,cAAqCJ,CAA0B,CAGjD,IAFV,KAAO,wBAEhB,YAAmBE,EAAU,CAC5B,MAAM,+BAA+BA,CAAG,EAAE,WADxBA,CAC0B,GAIjCG,EAAP,cAA6CL,CAA0B,CAIpE,IAHC,KAAO,gCAEhB,YACQE,EACPI,EACC,CACD,MAAM,uCAAuCJ,CAAG,GAAII,CAAO,WAHpDJ,CAGsD,GAMlDK,EAAP,cAAqC,KAAK,CACtC,KAAO,yBAGJC,EAAP,cAAgCD,CAAqB,CAGvC,OAFV,KAAO,mBAEhB,YAAmBE,EAAgB,CAClC,MAAM,kCAAkCA,CAAM,EAAE,cAD9BA,CACgC,GAIvCC,EAAP,cAA2CH,CAAqB,CAI7D,OAHC,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AQ,kBAAkB,EACrC,EAIDC,GAFgB,MAAMX,GAAiBH,CAAQ,GAEhC,IAChB,OAASgB,EAAO,CACf,MAAIA,aAAiBC,IAAuBD,EAAM,SAAW,IACtD,IAAQE,EAAiBN,CAAM,EAGhC,IAAQO,EAA4BP,EAAQ,CAAE,MAAAI,CAAK,CAAE,CAC5D,CAEA,OAAOF,EAAK,GAAI","names":["getAtprotoHandle","getPdsEndpoint","isDid","DidDocumentResolutionError","UnsupportedDidMethodError","did","ImproperDidError","DocumentNotFoundError","FailedDocumentResolutionError","options","HandleResolutionError","DidNotFoundError","handle","FailedHandleResolutionError","InvalidResolvedHandleError","AmbiguousHandleError","ActorResolutionError","LocalActorResolver","options","actor","identifierIsDid","isDid","did","err","ActorResolutionError","doc","pds","getPdsEndpoint","handle","writtenHandle","getAtprotoHandle","extractDidMethod","CompositeDidDocumentResolver","#methods","methods","did","options","method","extractDidMethod","resolver","UnsupportedDidMethodError","FailedResponseError","defs","isResponseOk","parseResponseAsJson","pipe","validateJsonWith","fetchDocHandler","PlcDidDocumentResolver","#fetch","apiUrl","fetchThis","did","options","UnsupportedDidMethodError","json","url","response","fetchDocHandler","cause","FailedResponseError","DocumentNotFoundError","FailedDocumentResolutionError","webDidToDocumentUrl","FailedResponseError","WebDidDocumentResolver","#fetch","fetchThis","did","options","UnsupportedDidMethodError","json","url","webDidToDocumentUrl","response","fetchDocHandler","cause","FailedResponseError","DocumentNotFoundError","FailedDocumentResolutionError","AtprotoWebDidDocumentResolver","host","paths","ImproperDidError","defs","FailedResponseError","isResponseOk","parseResponseAsJson","pipe","validateJsonWith","v","fetchXrpcHandler","pipe","isResponseOk","parseResponseAsJson","validateJsonWith","defs","XrpcDidDocumentResolver","#fetch","serviceUrl","fetchThis","did","options","json","url","response","cause","FailedResponseError","DocumentNotFoundError","FailedDocumentResolutionError","CompositeHandleResolver","#methods","methods","strategy","handle","options","http","dns","parentSignal","controller","dnsPromise","httpPromise","resolve","did","noop","resolved","dnsResponse","httpResponse","dnsDid","httpDid","AmbiguousHandleError","isAtprotoDid","fetchDohJsonTxt","SUBDOMAIN","PREFIX","DohJsonHandleResolver","#fetch","dohUrl","fetchThis","handle","options","json","url","response","fetchDohJsonTxt","cause","FailedHandleResolutionError","status","answers","DidNotFoundError","i","il","data","j","AmbiguousHandleError","did","isAtprotoDid","InvalidResolvedHandleError","isAtprotoDid","FailedResponseError","isResponseOk","pipe","readResponseAsText","fetchWellKnownHandler","pipe","isResponseOk","readResponseAsText","WellKnownHandleResolver","#fetch","fetchThis","handle","options","text","url","response","cause","FailedResponseError","DidNotFoundError","FailedHandleResolutionError","did","isAtprotoDid","InvalidResolvedHandleError","v","isAtprotoDid","FailedResponseError","isResponseOk","parseResponseAsJson","pipe","validateJsonWith","response","input","isAtprotoDid","fetchXrpcHandler","pipe","isResponseOk","parseResponseAsJson","validateJsonWith","XrpcHandleResolver","#fetch","serviceUrl","fetchThis","handle","options","json","url","cause","FailedResponseError","DidNotFoundError","FailedHandleResolutionError"],"sources":["../esm/npm/@atcute/identity-resolver@1.2.2/node_modules/@atcute/identity-resolver/lib/actor/local.ts","../esm/npm/@atcute/identity-resolver@1.2.2/node_modules/@atcute/identity-resolver/lib/errors.ts","../esm/npm/@atcute/identity-resolver@1.2.2/node_modules/@atcute/identity-resolver/lib/did/composite.ts","../esm/npm/@atcute/identity-resolver@1.2.2/node_modules/@atcute/identity-resolver/lib/did/methods/plc.ts","../esm/npm/@atcute/identity-resolver@1.2.2/node_modules/@atcute/identity-resolver/lib/did/utils.ts","../esm/npm/@atcute/identity-resolver@1.2.2/node_modules/@atcute/identity-resolver/lib/did/methods/web.ts","../esm/npm/@atcute/identity-resolver@1.2.2/node_modules/@atcute/identity-resolver/lib/did/methods/xrpc.ts","../esm/npm/@atcute/identity-resolver@1.2.2/node_modules/@atcute/identity-resolver/lib/handle/composite.ts","../esm/npm/@atcute/identity-resolver@1.2.2/node_modules/@atcute/identity-resolver/lib/handle/methods/doh-json.ts","../esm/npm/@atcute/identity-resolver@1.2.2/node_modules/@atcute/identity-resolver/lib/handle/methods/well-known.ts","../esm/npm/@atcute/identity-resolver@1.2.2/node_modules/@atcute/identity-resolver/lib/handle/methods/xrpc.ts"],"sourcesContent":["import { getAtprotoHandle, getPdsEndpoint } from '@atcute/identity';\nimport { isDid, type ActorIdentifier, type Did, type Handle } from '@atcute/lexicons/syntax';\n\nimport { ActorResolutionError } from '../errors.js';\nimport type {\n\tActorResolver,\n\tDidDocumentResolver,\n\tHandleResolver,\n\tResolveActorOptions,\n\tResolvedActor,\n} from '../types.js';\n\nexport interface LocalActorResolverOptions {\n\thandleResolver: HandleResolver;\n\tdidDocumentResolver: DidDocumentResolver;\n}\n\nexport class LocalActorResolver implements ActorResolver {\n\thandleResolver: HandleResolver;\n\tdidDocumentResolver: DidDocumentResolver;\n\n\tconstructor(options: LocalActorResolverOptions) {\n\t\tthis.handleResolver = options.handleResolver;\n\t\tthis.didDocumentResolver = options.didDocumentResolver;\n\t}\n\n\tasync resolve(actor: ActorIdentifier, options?: ResolveActorOptions): Promise\u003cResolvedActor\u003e {\n\t\tconst identifierIsDid = isDid(actor);\n\n\t\tlet did: Did;\n\t\tif (identifierIsDid) {\n\t\t\tdid = actor as Did;\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tdid = await this.handleResolver.resolve(actor as Handle, options);\n\t\t\t} catch (err) {\n\t\t\t\tthrow new ActorResolutionError(`failed to resolve handle`, { cause: err });\n\t\t\t}\n\t\t}\n\n\t\tlet doc;\n\t\ttry {\n\t\t\tdoc = await this.didDocumentResolver.resolve(did, options);\n\t\t} catch (err) {\n\t\t\tthrow new ActorResolutionError(`failed to resolve did document`, { cause: err });\n\t\t}\n\n\t\tconst pds = getPdsEndpoint(doc);\n\t\tif (!pds) {\n\t\t\tthrow new ActorResolutionError(`missing pds endpoint`);\n\t\t}\n\n\t\tlet handle: Handle = 'handle.invalid';\n\t\tif (identifierIsDid) {\n\t\t\tconst writtenHandle = getAtprotoHandle(doc);\n\t\t\tif (writtenHandle) {\n\t\t\t\ttry {\n\t\t\t\t\tconst resolved = await this.handleResolver.resolve(writtenHandle, options);\n\n\t\t\t\t\tif (resolved === did) {\n\t\t\t\t\t\thandle = writtenHandle;\n\t\t\t\t\t}\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t} else if (getAtprotoHandle(doc) === actor) {\n\t\t\thandle = actor as Handle;\n\t\t}\n\n\t\treturn {\n\t\t\tdid: did,\n\t\t\thandle: handle,\n\t\t\tpds: new URL(pds).href,\n\t\t};\n\t}\n}\n","import type { Did } from '@atcute/lexicons/syntax';\n\n// #region DID document resolution errors\nexport class DidDocumentResolutionError extends Error {\n\toverride name = 'DidResolutionError';\n}\n\nexport class UnsupportedDidMethodError extends DidDocumentResolutionError {\n\toverride name = 'UnsupportedDidMethodError';\n\n\tconstructor(public did: Did) {\n\t\tsuper(`unsupported did method; did=${did}`);\n\t}\n}\n\nexport class ImproperDidError extends DidDocumentResolutionError {\n\toverride name = 'ImproperDidError';\n\n\tconstructor(public did: Did) {\n\t\tsuper(`improper did; did=${did}`);\n\t}\n}\n\nexport class DocumentNotFoundError extends DidDocumentResolutionError {\n\toverride name = 'DocumentNotFoundError';\n\n\tconstructor(public did: Did) {\n\t\tsuper(`did document not found; did=${did}`);\n\t}\n}\n\nexport class FailedDocumentResolutionError extends DidDocumentResolutionError {\n\toverride name = 'FailedDocumentResolutionError';\n\n\tconstructor(\n\t\tpublic did: Did,\n\t\toptions?: ErrorOptions,\n\t) {\n\t\tsuper(`failed to resolve did document; did=${did}`, options);\n\t}\n}\n// #endregion\n\n// #region Handle resolution errors\nexport class HandleResolutionError extends Error {\n\toverride name = 'HandleResolutionError';\n}\n\nexport class DidNotFoundError extends HandleResolutionError {\n\toverride name = 'DidNotFoundError';\n\n\tconstructor(public handle: string) {\n\t\tsuper(`handle returned no did; handle=${handle}`);\n\t}\n}\n\nexport class FailedHandleResolutionError extends HandleResolutionError {\n\toverride name = 'FailedHandleResolutionError';\n\n\tconstructor(\n\t\tpublic handle: string,\n\t\toptions?: ErrorOptions,\n\t) {\n\t\tsuper(`failed to resolve handle; handle=${handle}`, options);\n\t}\n}\n\nexport class InvalidResolvedHandleError extends HandleResolutionError {\n\toverride name = 'InvalidResolvedHandleError';\n\n\tconstructor(\n\t\tpublic handle: string,\n\t\tpublic did: string,\n\t) {\n\t\tsuper(`handle returned invalid did; handle=${handle}; did=${did}`);\n\t}\n}\n\nexport class AmbiguousHandleError extends HandleResolutionError {\n\toverride name = 'AmbiguousHandleError';\n\n\tconstructor(handle: string) {\n\t\tsuper(`handle returned multiple did values; handle=${handle}`);\n\t}\n}\n// #endregion\n\n// #region Actor resolution errors\nexport class ActorResolutionError extends Error {\n\toverride name = 'ActorResolutionError';\n}\n// #endregion\n","import { extractDidMethod, type DidDocument } from '@atcute/identity';\nimport type { Did } from '@atcute/lexicons/syntax';\n\nimport * as err from '../errors.js';\nimport type { DidDocumentResolver, ResolveDidDocumentOptions } from '../types.js';\n\nexport interface CompositeDidDocumentResolverOptions\u003cM extends string\u003e {\n\tmethods: { [K in M]: DidDocumentResolver\u003cK\u003e };\n}\n\nexport class CompositeDidDocumentResolver\u003cM extends string\u003e implements DidDocumentResolver\u003cM\u003e {\n\t#methods: Map\u003cstring, DidDocumentResolver\u003cM\u003e\u003e;\n\n\tconstructor({ methods }: CompositeDidDocumentResolverOptions\u003cM\u003e) {\n\t\tthis.#methods = new Map(Object.entries(methods));\n\t}\n\n\tasync resolve(did: Did\u003cM\u003e, options?: ResolveDidDocumentOptions): Promise\u003cDidDocument\u003e {\n\t\tconst method = extractDidMethod(did);\n\n\t\tconst resolver = this.#methods.get(method);\n\t\tif (resolver === undefined) {\n\t\t\tthrow new err.UnsupportedDidMethodError(did);\n\t\t}\n\n\t\treturn await resolver.resolve(did, options);\n\t}\n}\n","import type { DidDocument } from '@atcute/identity';\nimport type { Did } from '@atcute/lexicons/syntax';\nimport { FailedResponseError } from '@atcute/util-fetch';\n\nimport * as err from '../../errors.js';\nimport type { DidDocumentResolver, ResolveDidDocumentOptions } from '../../types.js';\nimport { fetchDocHandler } from '../utils.js';\n\nexport interface PlcDidDocumentResolverOptions {\n\tapiUrl?: string;\n\tfetch?: typeof fetch;\n}\n\nexport class PlcDidDocumentResolver implements DidDocumentResolver\u003c'plc'\u003e {\n\treadonly apiUrl: string;\n\t#fetch: typeof fetch;\n\n\tconstructor({\n\t\tapiUrl = 'https://plc.directory',\n\t\tfetch: fetchThis = fetch,\n\t}: PlcDidDocumentResolverOptions = {}) {\n\t\tthis.apiUrl = apiUrl;\n\t\tthis.#fetch = fetchThis;\n\t}\n\n\tasync resolve(did: Did\u003c'plc'\u003e, options?: ResolveDidDocumentOptions): Promise\u003cDidDocument\u003e {\n\t\t// quick sanity check\n\t\tif (!did.startsWith('did:plc:')) {\n\t\t\tthrow new err.UnsupportedDidMethodError(did);\n\t\t}\n\n\t\tlet json: DidDocument;\n\n\t\ttry {\n\t\t\tconst url = new URL(`/${encodeURIComponent(did)}`, this.apiUrl);\n\n\t\t\tconst response = await (0, this.#fetch)(url, {\n\t\t\t\tsignal: options?.signal,\n\t\t\t\tcache: options?.noCache ? 'no-cache' : undefined,\n\t\t\t\tredirect: 'manual',\n\t\t\t\theaders: { accept: 'application/did+ld+json,application/json' },\n\t\t\t});\n\n\t\t\tif (response.status \u003e= 300 \u0026\u0026 response.status \u003c 400) {\n\t\t\t\tthrow new TypeError(`unexpected redirect`);\n\t\t\t}\n\n\t\t\tconst handled = await fetchDocHandler(response);\n\n\t\t\tjson = handled.json;\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof FailedResponseError \u0026\u0026 cause.status === 404) {\n\t\t\t\tthrow new err.DocumentNotFoundError(did);\n\t\t\t}\n\n\t\t\tthrow new err.FailedDocumentResolutionError(did, { cause });\n\t\t}\n\n\t\treturn json;\n\t}\n}\n","import { defs } from '@atcute/identity';\nimport { isResponseOk, parseResponseAsJson, pipe, validateJsonWith } from '@atcute/util-fetch';\n\nexport const fetchDocHandler = pipe(\n\tisResponseOk,\n\tparseResponseAsJson(/^application\\/(did\\+ld\\+)?json$/, 20 * 1024),\n\tvalidateJsonWith(defs.didDocument, { mode: 'passthrough' }),\n);\n","import { webDidToDocumentUrl, type DidDocument } from '@atcute/identity';\nimport type { Did } from '@atcute/lexicons/syntax';\nimport { FailedResponseError } from '@atcute/util-fetch';\n\nimport * as err from '../../errors.js';\nimport type { DidDocumentResolver, ResolveDidDocumentOptions } from '../../types.js';\nimport { fetchDocHandler } from '../utils.js';\n\nexport interface WebDidDocumentResolverOptions {\n\tfetch?: typeof fetch;\n}\n\nexport class WebDidDocumentResolver implements DidDocumentResolver\u003c'web'\u003e {\n\t#fetch: typeof fetch;\n\n\tconstructor({ fetch: fetchThis = fetch }: WebDidDocumentResolverOptions = {}) {\n\t\tthis.#fetch = fetchThis;\n\t}\n\n\tasync resolve(did: Did\u003c'web'\u003e, options?: ResolveDidDocumentOptions): Promise\u003cDidDocument\u003e {\n\t\t// quick sanity check\n\t\tif (!did.startsWith('did:web:')) {\n\t\t\tthrow new err.UnsupportedDidMethodError(did);\n\t\t}\n\n\t\tlet json: DidDocument;\n\n\t\ttry {\n\t\t\tconst url = webDidToDocumentUrl(did);\n\n\t\t\tconst response = await (0, this.#fetch)(url, {\n\t\t\t\tsignal: options?.signal,\n\t\t\t\tcache: options?.noCache ? 'no-cache' : undefined,\n\t\t\t\tredirect: 'manual',\n\t\t\t\theaders: { accept: 'application/did+ld+json,application/json' },\n\t\t\t});\n\n\t\t\tif (response.status \u003e= 300 \u0026\u0026 response.status \u003c 400) {\n\t\t\t\tthrow new TypeError(`unexpected redirect`);\n\t\t\t}\n\n\t\t\tconst handled = await fetchDocHandler(response);\n\n\t\t\tjson = handled.json;\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof FailedResponseError \u0026\u0026 cause.status === 404) {\n\t\t\t\tthrow new err.DocumentNotFoundError(did);\n\t\t\t}\n\n\t\t\tthrow new err.FailedDocumentResolutionError(did, { cause });\n\t\t}\n\n\t\treturn json;\n\t}\n}\n\nexport class AtprotoWebDidDocumentResolver implements DidDocumentResolver\u003c'web'\u003e {\n\t#fetch: typeof fetch;\n\n\tconstructor({ fetch: fetchThis = fetch }: WebDidDocumentResolverOptions = {}) {\n\t\tthis.#fetch = fetchThis;\n\t}\n\n\tasync resolve(did: Did\u003c'web'\u003e, options?: ResolveDidDocumentOptions): Promise\u003cDidDocument\u003e {\n\t\t// quick sanity check\n\t\tif (!did.startsWith('did:web:')) {\n\t\t\tthrow new err.UnsupportedDidMethodError(did);\n\t\t}\n\n\t\tconst [host, ...paths] = did.slice(8).split(':').map(decodeURIComponent);\n\t\tconst url = new URL(`https://${host}/.well-known/did.json`);\n\n\t\tif (paths.length \u003e 0) {\n\t\t\tthrow new err.ImproperDidError(did);\n\t\t}\n\n\t\tlet json: DidDocument;\n\n\t\ttry {\n\t\t\tconst response = await (0, this.#fetch)(url, {\n\t\t\t\tsignal: options?.signal,\n\t\t\t\tcache: options?.noCache ? 'no-cache' : undefined,\n\t\t\t\tredirect: 'manual',\n\t\t\t\theaders: { accept: 'application/did+ld+json,application/json' },\n\t\t\t});\n\n\t\t\tif (response.status \u003e= 300 \u0026\u0026 response.status \u003c 400) {\n\t\t\t\tthrow new TypeError(`unexpected redirect`);\n\t\t\t}\n\n\t\t\tconst handled = await fetchDocHandler(response);\n\n\t\t\tjson = handled.json;\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof FailedResponseError \u0026\u0026 cause.status === 404) {\n\t\t\t\tthrow new err.DocumentNotFoundError(did);\n\t\t\t}\n\n\t\t\tthrow new err.FailedDocumentResolutionError(did, { cause });\n\t\t}\n\n\t\treturn json;\n\t}\n}\n","import { defs, type DidDocument } from '@atcute/identity';\nimport type { Did } from '@atcute/lexicons/syntax';\nimport {\n\tFailedResponseError,\n\tisResponseOk,\n\tparseResponseAsJson,\n\tpipe,\n\tvalidateJsonWith,\n} from '@atcute/util-fetch';\n\nimport * as v from '@badrap/valita';\n\nimport * as err from '../../errors.js';\nimport type { DidDocumentResolver, ResolveDidDocumentOptions } from '../../types.js';\n\nconst fetchXrpcHandler = pipe(\n\tisResponseOk,\n\tparseResponseAsJson(/^application\\/json$/, 20 * 1024 + 16),\n\tvalidateJsonWith(v.object({ didDoc: defs.didDocument }), { mode: 'passthrough' }),\n);\n\nexport interface XrpcDidDocumentResolverOptions {\n\tserviceUrl: string;\n\tfetch?: typeof fetch;\n}\n\nexport class XrpcDidDocumentResolver implements DidDocumentResolver\u003cstring\u003e {\n\treadonly serviceUrl: string;\n\t#fetch: typeof fetch;\n\n\tconstructor({ serviceUrl, fetch: fetchThis = fetch }: XrpcDidDocumentResolverOptions) {\n\t\tthis.serviceUrl = serviceUrl;\n\t\tthis.#fetch = fetchThis;\n\t}\n\n\tasync resolve(did: Did, options?: ResolveDidDocumentOptions): Promise\u003cDidDocument\u003e {\n\t\tlet json: DidDocument;\n\n\t\ttry {\n\t\t\tconst url = new URL(`/xrpc/com.atproto.identity.resolveDid`, this.serviceUrl);\n\t\t\turl.searchParams.set('did', did);\n\n\t\t\tconst response = await (0, this.#fetch)(url, {\n\t\t\t\tsignal: options?.signal,\n\t\t\t\tcache: options?.noCache ? 'no-cache' : undefined,\n\t\t\t\theaders: { accept: 'application/json' },\n\t\t\t});\n\n\t\t\tconst handled = await fetchXrpcHandler(response);\n\n\t\t\tjson = handled.json.didDoc;\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof FailedResponseError \u0026\u0026 cause.status === 404) {\n\t\t\t\tthrow new err.DocumentNotFoundError(did);\n\t\t\t}\n\n\t\t\tthrow new err.FailedDocumentResolutionError(did, { cause });\n\t\t}\n\n\t\treturn json;\n\t}\n}\n","import type { AtprotoDid, Handle } from '@atcute/lexicons/syntax';\n\nimport * as err from '../errors.js';\nimport type { HandleResolver, ResolveHandleOptions } from '../types.js';\n\nexport type CompositeStrategy = 'http-first' | 'dns-first' | 'race' | 'both';\n\nexport interface CompositeHandleResolverOptions {\n\t/** controls how the resolution is done, defaults to 'race' */\n\tstrategy?: CompositeStrategy;\n\t/** the methods to use for resolving the handle. */\n\tmethods: Record\u003c'http' | 'dns', HandleResolver\u003e;\n}\n\nexport class CompositeHandleResolver implements HandleResolver {\n\t#methods: Record\u003c'http' | 'dns', HandleResolver\u003e;\n\tstrategy: CompositeStrategy;\n\n\tconstructor({ methods, strategy = 'race' }: CompositeHandleResolverOptions) {\n\t\tthis.#methods = methods;\n\t\tthis.strategy = strategy;\n\t}\n\n\tasync resolve(handle: Handle, options?: ResolveHandleOptions): Promise\u003cAtprotoDid\u003e {\n\t\tconst { http, dns } = this.#methods;\n\n\t\tconst parentSignal = options?.signal;\n\t\tconst controller = new AbortController();\n\t\tif (parentSignal) {\n\t\t\tparentSignal.addEventListener('abort', () =\u003e controller.abort(), { signal: controller.signal });\n\t\t}\n\n\t\tconst dnsPromise = dns.resolve(handle, { ...options, signal: controller.signal });\n\t\tconst httpPromise = http.resolve(handle, { ...options, signal: controller.signal });\n\n\t\tswitch (this.strategy) {\n\t\t\tcase 'race': {\n\t\t\t\treturn new Promise((resolve) =\u003e {\n\t\t\t\t\tdnsPromise.then(\n\t\t\t\t\t\t(did) =\u003e {\n\t\t\t\t\t\t\tcontroller.abort();\n\t\t\t\t\t\t\tresolve(did);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() =\u003e resolve(httpPromise),\n\t\t\t\t\t);\n\n\t\t\t\t\thttpPromise.then(\n\t\t\t\t\t\t(did) =\u003e {\n\t\t\t\t\t\t\tcontroller.abort();\n\t\t\t\t\t\t\tresolve(did);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() =\u003e resolve(dnsPromise),\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t}\n\t\t\tcase 'dns-first': {\n\t\t\t\thttpPromise.catch(noop);\n\n\t\t\t\tconst resolved = await dnsPromise.catch(noop);\n\t\t\t\tif (resolved) {\n\t\t\t\t\tcontroller.abort();\n\t\t\t\t\treturn resolved;\n\t\t\t\t}\n\n\t\t\t\treturn httpPromise;\n\t\t\t}\n\t\t\tcase 'http-first': {\n\t\t\t\tdnsPromise.catch(noop);\n\n\t\t\t\tconst resolved = await httpPromise.catch(noop);\n\t\t\t\tif (resolved) {\n\t\t\t\t\tcontroller.abort();\n\t\t\t\t\treturn resolved;\n\t\t\t\t}\n\n\t\t\t\treturn dnsPromise;\n\t\t\t}\n\t\t\tcase 'both': {\n\t\t\t\tconst [dnsResponse, httpResponse] = await Promise.allSettled([dnsPromise, httpPromise]);\n\n\t\t\t\tconst dnsDid = dnsResponse.status === 'fulfilled' ? dnsResponse.value : undefined;\n\t\t\t\tconst httpDid = httpResponse.status === 'fulfilled' ? httpResponse.value : undefined;\n\n\t\t\t\tif (dnsDid \u0026\u0026 httpDid \u0026\u0026 dnsDid !== httpDid) {\n\t\t\t\t\tthrow new err.AmbiguousHandleError(handle);\n\t\t\t\t}\n\n\t\t\t\treturn dnsDid || httpDid || dnsPromise;\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst noop = () =\u003e {};\n","import { isAtprotoDid } from '@atcute/identity';\nimport type { AtprotoDid, Handle } from '@atcute/lexicons/syntax';\nimport { type DohJsonTxtResult, fetchDohJsonTxt } from '@atcute/util-fetch';\n\nimport * as err from '../../errors.js';\nimport type { HandleResolver, ResolveHandleOptions } from '../../types.js';\n\nconst SUBDOMAIN = '_atproto';\nconst PREFIX = 'did=';\n\nexport interface DohJsonHandleResolverOptions {\n\tdohUrl: string;\n\tfetch?: typeof fetch;\n}\n\nexport class DohJsonHandleResolver implements HandleResolver {\n\treadonly dohUrl: string;\n\t#fetch: typeof fetch;\n\n\tconstructor({ dohUrl, fetch: fetchThis = fetch }: DohJsonHandleResolverOptions) {\n\t\tthis.dohUrl = dohUrl;\n\t\tthis.#fetch = fetchThis;\n\t}\n\n\tasync resolve(handle: Handle, options?: ResolveHandleOptions): Promise\u003cAtprotoDid\u003e {\n\t\tlet json: DohJsonTxtResult;\n\n\t\ttry {\n\t\t\tconst url = new URL(this.dohUrl);\n\t\t\turl.searchParams.set('name', `${SUBDOMAIN}.${handle}`);\n\t\t\turl.searchParams.set('type', 'TXT');\n\n\t\t\tconst response = await (0, this.#fetch)(url, {\n\t\t\t\tsignal: options?.signal,\n\t\t\t\tcache: options?.noCache ? 'no-cache' : undefined,\n\t\t\t\theaders: { accept: 'application/dns-json' },\n\t\t\t});\n\n\t\t\tconst handled = await fetchDohJsonTxt(response);\n\n\t\t\tjson = handled.json;\n\t\t} catch (cause) {\n\t\t\tthrow new err.FailedHandleResolutionError(handle, { cause });\n\t\t}\n\n\t\tconst status = json.Status;\n\t\tconst answers = json.Answer;\n\n\t\tif (status !== 0 /* NOERROR */) {\n\t\t\tif (status === 3 /* NXDOMAIN */) {\n\t\t\t\tthrow new err.DidNotFoundError(handle);\n\t\t\t}\n\n\t\t\tthrow new err.FailedHandleResolutionError(handle, {\n\t\t\t\tcause: new TypeError(`dns returned ${status}`),\n\t\t\t});\n\t\t}\n\n\t\tfor (let i = 0, il = answers.length; i \u003c il; i++) {\n\t\t\tconst answer = answers[i];\n\t\t\tconst data = answer.data;\n\n\t\t\tif (!data.startsWith(PREFIX)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (let j = i + 1; j \u003c il; j++) {\n\t\t\t\tconst data = answers[j].data;\n\t\t\t\tif (data.startsWith(PREFIX)) {\n\t\t\t\t\tthrow new err.AmbiguousHandleError(handle);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst did = data.slice(PREFIX.length);\n\t\t\tif (!isAtprotoDid(did)) {\n\t\t\t\tthrow new err.InvalidResolvedHandleError(handle, did);\n\t\t\t}\n\n\t\t\treturn did;\n\t\t}\n\n\t\t// theoretically this shouldn't happen, it should've returned NXDOMAIN\n\t\tthrow new err.DidNotFoundError(handle);\n\t}\n}\n","import { isAtprotoDid } from '@atcute/identity';\nimport type { AtprotoDid, Handle } from '@atcute/lexicons/syntax';\nimport { FailedResponseError, isResponseOk, pipe, readResponseAsText } from '@atcute/util-fetch';\n\nimport * as err from '../../errors.js';\nimport type { HandleResolver, ResolveHandleOptions } from '../../types.js';\n\nexport interface WellKnownHandleResolverOptions {\n\tfetch?: typeof fetch;\n}\n\nconst fetchWellKnownHandler = pipe(isResponseOk, readResponseAsText(2048 + 16));\n\nexport class WellKnownHandleResolver implements HandleResolver {\n\t#fetch: typeof fetch;\n\n\tconstructor({ fetch: fetchThis = fetch }: WellKnownHandleResolverOptions = {}) {\n\t\tthis.#fetch = fetchThis;\n\t}\n\n\tasync resolve(handle: Handle, options?: ResolveHandleOptions): Promise\u003cAtprotoDid\u003e {\n\t\tlet text: string;\n\n\t\ttry {\n\t\t\tconst url = new URL('/.well-known/atproto-did', `https://${handle}`);\n\n\t\t\tconst response = await (0, this.#fetch)(url, {\n\t\t\t\tsignal: options?.signal,\n\t\t\t\tcache: options?.noCache ? 'no-cache' : undefined,\n\t\t\t\tredirect: 'manual',\n\t\t\t});\n\n\t\t\tif (response.status \u003e= 300 \u0026\u0026 response.status \u003c 400) {\n\t\t\t\tthrow new TypeError(`unexpected redirect`);\n\t\t\t}\n\n\t\t\tconst handled = await fetchWellKnownHandler(response);\n\n\t\t\ttext = handled.text;\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof FailedResponseError \u0026\u0026 cause.status === 404) {\n\t\t\t\tthrow new err.DidNotFoundError(handle);\n\t\t\t}\n\n\t\t\tthrow new err.FailedHandleResolutionError(handle, { cause });\n\t\t}\n\n\t\tconst did = text.split('\\n')[0]!.trim();\n\t\tif (!isAtprotoDid(did)) {\n\t\t\tthrow new err.InvalidResolvedHandleError(handle, did);\n\t\t}\n\n\t\treturn did;\n\t}\n}\n","import * as v from '@badrap/valita';\n\nimport { isAtprotoDid } from '@atcute/identity';\nimport type { AtprotoDid, Handle } from '@atcute/lexicons/syntax';\nimport {\n\tFailedResponseError,\n\tisResponseOk,\n\tparseResponseAsJson,\n\tpipe,\n\tvalidateJsonWith,\n} from '@atcute/util-fetch';\n\nimport * as err from '../../errors.js';\nimport type { HandleResolver, ResolveHandleOptions } from '../../types.js';\n\nconst response = v.object({\n\tdid: v.string().assert((input) =\u003e isAtprotoDid(input)),\n});\n\nconst fetchXrpcHandler = pipe(\n\tisResponseOk,\n\tparseResponseAsJson(/^application\\/json$/, 4 * 1024),\n\tvalidateJsonWith(response, { mode: 'passthrough' }),\n);\n\nexport interface XrpcHandleResolverOptions {\n\tserviceUrl: string;\n\tfetch?: typeof fetch;\n}\n\nexport class XrpcHandleResolver implements HandleResolver {\n\treadonly serviceUrl: string;\n\t#fetch: typeof fetch;\n\n\tconstructor({ serviceUrl, fetch: fetchThis = fetch }: XrpcHandleResolverOptions) {\n\t\tthis.serviceUrl = serviceUrl;\n\t\tthis.#fetch = fetchThis;\n\t}\n\n\tasync resolve(handle: Handle, options?: ResolveHandleOptions): Promise\u003cAtprotoDid\u003e {\n\t\tlet json: v.Infer\u003ctypeof response\u003e;\n\n\t\ttry {\n\t\t\tconst url = new URL(`/xrpc/com.atproto.identity.resolveHandle`, this.serviceUrl);\n\t\t\turl.searchParams.set('handle', handle);\n\n\t\t\tconst response = await (0, this.#fetch)(url, {\n\t\t\t\tsignal: options?.signal,\n\t\t\t\tcache: options?.noCache ? 'no-cache' : undefined,\n\t\t\t\theaders: { accept: 'application/json' },\n\t\t\t});\n\n\t\t\tconst handled = await fetchXrpcHandler(response);\n\n\t\t\tjson = handled.json;\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof FailedResponseError \u0026\u0026 cause.status === 400) {\n\t\t\t\tthrow new err.DidNotFoundError(handle);\n\t\t\t}\n\n\t\t\tthrow new err.FailedHandleResolutionError(handle, { cause });\n\t\t}\n\n\t\treturn json.did;\n\t}\n}\n"],"version":3}
+3
vendor/esm.sh/@atcute/identity@1.1.4/es2022/identity.mjs
··· 1 + /* esm.sh - @atcute/identity@1.1.4 */ 2 + var E=Object.defineProperty;var D=(e,t)=>{for(var o in t)E(e,o,{get:t[o],enumerable:!0})};var g={};D(g,{FRAGMENT_RE:()=>h,MULTIBASE_RE:()=>m,didDocument:()=>_,didRelativeUri:()=>f,didString:()=>d,multibaseString:()=>y,rfc3968UriSchema:()=>l,service:()=>x,verificationMethod:()=>u});import{isDid as R}from"../../lexicons@1.2.10/es2022/syntax.mjs";import*as r from"../../../@badrap/valita@0.4.6/es2022/valita.mjs";var h=/^#[^#]+$/,m=/^z[a-km-zA-HJ-NP-Z1-9]+$/,l=r.string().assert(e=>URL.canParse(e),"must be a url"),f=r.string().assert(e=>h.test(e)||URL.canParse(e),"must be a did relative uri"),y=r.string().assert(e=>m.test(e),"must be a base58 multibase"),d=r.string().assert(R,"must be a did"),u=r.object({id:f,type:r.string(),controller:d,publicKeyMultibase:y.optional(),publicKeyJwk:r.record().optional()}).chain(e=>{switch(e.type){case"Multikey":{if(e.publicKeyMultibase===void 0)return r.err({message:"missing multikey",path:["publicKeyMultibase"]});break}case"EcdsaSecp256k1VerificationKey2019":case"EcdsaSecp256r1VerificationKey2019":{if(e.publicKeyMultibase===void 0)return r.err({message:"missing multibase key",path:["publicKeyMultibase"]});break}}return r.ok(e)}),x=r.object({id:f,type:r.union(r.string(),r.array(r.string())),serviceEndpoint:r.union(l,r.record(l),r.array(r.union(l,r.record(l))))}),_=r.object({"@context":r.array(l).optional(),id:d,alsoKnownAs:r.array(l).chain(e=>{for(let t=0,o=e.length;t<o;t++){let n=e[t];for(let i=0;i<t;i++)if(n===e[i])return r.err({message:`duplicate "${n}" aka entry`,path:[t]})}return r.ok(e)}).optional(),verificationMethod:r.array(u).chain(e=>{for(let t=0,o=e.length;t<o;t++){let i=e[t].id;for(let s=0;s<t;s++)if(i===e[s].id)return r.err({message:`duplicate "${i}" verification method`,path:[t,"id"]})}return r.ok(e)}).optional(),service:r.array(x).optional(),controller:r.union(d,r.array(d)).optional(),authentication:r.array(r.union(f,u)).optional()}).chain(e=>{let{id:t,service:o}=e;if(o?.length){let n=o.length,i=new Array(n);for(let s=0;s<n;s++){let a=o[s].id;a[0]==="#"&&(a=t+a),i[s]=a}for(let s=0;s<n;s++){let c=i[s];for(let a=0;a<s;a++)if(c===i[a])return r.err({message:`duplicate "${c}" service`,path:["service",s,"id"]})}}return r.ok(e)});import{isHandle as M}from"../../lexicons@1.2.10/es2022/syntax.mjs";var $="parse"in URL,w=e=>{let t=null;if($)t=URL.parse(e);else try{t=new URL(e)}catch{}return t!==null&&(t.protocol==="https:"||t.protocol==="http:")&&t.pathname==="/"&&t.search===""&&t.hash===""},b=(e,t)=>{let o=e.verificationMethod;if(!o)return;let n=`${e.id}${t}`;for(let i=0,s=o.length;i<s;i++){let{id:c,type:a,publicKeyMultibase:v}=o[i];if(c===n&&v!==void 0)return{type:a,publicKeyMultibase:v}}},W=e=>b(e,"#atproto"),F=e=>b(e,"#atproto_label"),N=e=>{let t=e.alsoKnownAs;if(!t)return null;let o="at://";for(let n=0,i=t.length;n<i;n++){let s=t[n];if(!s.startsWith(o))continue;let c=s.slice(o.length);return M(c)?c:void 0}return null},p=(e,t)=>{let o=e.service;if(o)for(let n=0,i=o.length;n<i;n++){let{id:s,type:c,serviceEndpoint:a}=o[n];if(!(s!==t.id&&s!==e.id+t.id)){if(t.type!==void 0){if(Array.isArray(c)){if(!c.includes(t.type))continue}else if(c!==t.type)continue}if(!(typeof a!="string"||!w(a)))return a}}},T=e=>p(e,{id:"#atproto_pds",type:"AtprotoPersonalDataServer"}),V=e=>p(e,{id:"#atproto_labeler",type:"AtprotoLabeler"}),H=e=>p(e,{id:"#bsky_chat",type:"BskyChatService"}),O=e=>p(e,{id:"#bsky_fg",type:"BskyFeedGenerator"}),G=e=>p(e,{id:"#bsky_notif",type:"BskyNotificationService"});var z=/^did:plc:([a-z2-7]{24})$/,A=e=>e.length===32&&z.test(e);var K=/^did:web:([a-zA-Z0-9%-]+(?:(?:\.[a-zA-Z0-9%-]+)*(?:\.[a-zA-Z]{2,}))?)?((?::[a-zA-Z0-9\-%.]+)+)?$/,U=/^did:web:([a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*(?:\.[a-zA-Z]{2,})|localhost(?:%3[aA]\d+)?)$/,Y=e=>e.length>=9&&K.test(e),k=e=>e.length>=12&&U.test(e),q=e=>{let[t,...o]=e.slice(8).split(":").map(decodeURIComponent),n=`did:web:${encodeURIComponent(t.toLowerCase())}`;return o.length>0&&(n+=`:${o.join(":")}`),n},Q=e=>{let[t,...o]=e.slice(8).split(":").map(decodeURIComponent),n="/"+o.join("/");n==="/"?n="/.well-known/did.json":n+="/did.json";let i=new URL(`https://${t}${n}`);return i.hostname==="localhost"&&(i.protocol="http:"),i};var L=/^(?:[A-Za-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9A-Fa-f]{2})*$/,P=e=>A(e)||k(e),oe=e=>{if(e.length<14)return!1;let t=e.indexOf("#",12);return t===-1?!1:L.test(e.slice(t+1))&&P(e.slice(0,t))},ne=e=>{let t=e.indexOf(":",4);return e.slice(4,t)};var S=/^did:key:z[a-km-zA-HJ-NP-Z1-9]+$/,se=e=>e.length>=10&&S.test(e);export{U as ATPROTO_WEB_DID_RE,z as PLC_DID_RE,K as WEB_DID_RE,g as defs,ne as extractDidMethod,N as getAtprotoHandle,F as getAtprotoLabelerVerificationMaterial,p as getAtprotoServiceEndpoint,W as getAtprotoVerificationMaterial,H as getBlueskyChatEndpoint,O as getBlueskyFeedgenEndpoint,G as getBlueskyNotificationEndpoint,V as getLabelerEndpoint,T as getPdsEndpoint,b as getVerificationMaterial,oe as isAtprotoAudience,P as isAtprotoDid,w as isAtprotoServiceEndpoint,k as isAtprotoWebDid,se as isKeyDid,A as isPlcDid,Y as isWebDid,q as normalizeWebDid,Q as webDidToDocumentUrl}; 3 + //# sourceMappingURL=./identity.mjs.map
+1
vendor/esm.sh/@atcute/identity@1.1.4/es2022/identity.mjs.map
··· 1 + {"mappings":";0FAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,iBAAAC,EAAA,gBAAAC,EAAA,mBAAAC,EAAA,cAAAC,EAAA,oBAAAC,EAAA,qBAAAC,EAA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EAM9CE,EAAmBC,GAA+B,CAC9D,GAAM,CAACC,EAAM,GAAGC,CAAK,EAAIF,EAAI,MAAM,CAAC,EAAE,MAAM,GAAG,EAAE,IAAI,kBAAkB,EAEnEG,EAAa,WAAW,mBAAmBF,EAAK,YAAW,CAAE,CAAC,GAClE,OAAIC,EAAM,OAAS,IAClBC,GAAc,IAAID,EAAM,KAAK,GAAG,CAAC,IAG3BC,CACR,EAKaC,EAAuBJ,GAAwB,CAC3D,GAAM,CAACC,EAAM,GAAGC,CAAK,EAAIF,EAAI,MAAM,CAAC,EAAE,MAAM,GAAG,EAAE,IAAI,kBAAkB,EAEnEK,EAAW,IAAMH,EAAM,KAAK,GAAG,EAC/BG,IAAa,IAChBA,EAAW,wBAEXA,GAAY,YAGb,IAAMC,EAAM,IAAI,IAAI,WAAWL,CAAI,GAAGI,CAAQ,EAAE,EAChD,OAAIC,EAAI,WAAa,cACpBA,EAAI,SAAW,SAGTA,CACR,ECtDA,IAAMC,EAAc,yDAKPC,EAAgBC,GACrBC,EAASD,CAAK,GAAKE,EAAgBF,CAAK,EAGnCG,GAAqBH,GAA2C,CAE5E,GAAIA,EAAM,OAAS,GAClB,MAAO,GAGR,IAAMI,EAAOJ,EAAM,QAAQ,IAAK,EAAE,EAClC,OAAII,IAAS,GACL,GAGDN,EAAY,KAAKE,EAAM,MAAMI,EAAO,CAAC,CAAC,GAAKL,EAAaC,EAAM,MAAM,EAAGI,CAAI,CAAC,CACpF,EAKaC,GAAsCC,GAAkB,CACpE,IAAMF,EAAOE,EAAI,QAAQ,IAAK,CAAC,EAE/B,OADeA,EAAI,MAAM,EAAGF,CAAI,CAEjC,ECjCA,IAAMG,EAAa,mCAKNC,GAAYC,GACjBA,EAAM,QAAU,IAAMF,EAAW,KAAKE,CAAK","names":["typedefs_exports","__export","FRAGMENT_RE","MULTIBASE_RE","didDocument","didRelativeUri","didString","multibaseString","rfc3968UriSchema","service","verificationMethod","isDid","v","FRAGMENT_RE","MULTIBASE_RE","rfc3968UriSchema","input","didRelativeUri","multibaseString","didString","isDid","verificationMethod","service","didDocument","i","len","aka","j","methodId","did","services","identifiers","id","isHandle","isUrlParseSupported","isAtprotoServiceEndpoint","input","url","getVerificationMaterial","doc","id","verificationMethods","expectedId","idx","len","type","publicKeyMultibase","getAtprotoVerificationMaterial","getAtprotoLabelerVerificationMaterial","getAtprotoHandle","alsoKnownAs","PREFIX","aka","raw","isHandle","getAtprotoServiceEndpoint","predicate","services","serviceEndpoint","getPdsEndpoint","getLabelerEndpoint","getBlueskyChatEndpoint","getBlueskyFeedgenEndpoint","getBlueskyNotificationEndpoint","PLC_DID_RE","isPlcDid","input","WEB_DID_RE","ATPROTO_WEB_DID_RE","isWebDid","input","isAtprotoWebDid","normalizeWebDid","did","host","paths","normalized","webDidToDocumentUrl","pathname","url","FRAGMENT_RE","isAtprotoDid","input","isPlcDid","isAtprotoWebDid","isAtprotoAudience","isep","extractDidMethod","did","KEY_DID_RE","isKeyDid","input"],"sources":["../esm/npm/@atcute/identity@1.1.4/node_modules/@atcute/identity/lib/typedefs.ts","../esm/npm/@atcute/identity@1.1.4/node_modules/@atcute/identity/lib/utils.ts","../esm/npm/@atcute/identity@1.1.4/node_modules/@atcute/identity/lib/methods/plc.ts","../esm/npm/@atcute/identity@1.1.4/node_modules/@atcute/identity/lib/methods/web.ts","../esm/npm/@atcute/identity@1.1.4/node_modules/@atcute/identity/lib/did.ts","../esm/npm/@atcute/identity@1.1.4/node_modules/@atcute/identity/lib/methods/key.ts"],"sourcesContent":["import { isDid } from '@atcute/lexicons/syntax';\n\nimport * as v from '@badrap/valita';\n\nimport * as t from './types.ts';\n\n/** @deprecated */\nexport const FRAGMENT_RE = /^#[^#]+$/;\n/** @deprecated */\nexport const MULTIBASE_RE = /^z[a-km-zA-HJ-NP-Z1-9]+$/;\n\nexport const rfc3968UriSchema = v.string().assert((input) =\u003e {\n\treturn URL.canParse(input);\n}, `must be a url`);\n\nexport const didRelativeUri = v.string().assert((input) =\u003e {\n\treturn FRAGMENT_RE.test(input) || URL.canParse(input);\n}, `must be a did relative uri`);\n\nexport const multibaseString = v.string().assert((input) =\u003e {\n\treturn MULTIBASE_RE.test(input);\n}, `must be a base58 multibase`);\n\nexport const didString = v.string().assert(isDid, `must be a did`);\n\nexport const verificationMethod: v.Type\u003ct.VerificationMethod\u003e = v\n\t.object({\n\t\tid: didRelativeUri,\n\t\ttype: v.string(),\n\t\tcontroller: didString,\n\t\tpublicKeyMultibase: multibaseString.optional(),\n\t\tpublicKeyJwk: v.record().optional(),\n\t})\n\t.chain((input) =\u003e {\n\t\tswitch (input.type) {\n\t\t\tcase 'Multikey': {\n\t\t\t\tif (input.publicKeyMultibase === undefined) {\n\t\t\t\t\treturn v.err({ message: `missing multikey`, path: ['publicKeyMultibase'] });\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'EcdsaSecp256k1VerificationKey2019':\n\t\t\tcase 'EcdsaSecp256r1VerificationKey2019': {\n\t\t\t\tif (input.publicKeyMultibase === undefined) {\n\t\t\t\t\treturn v.err({ message: `missing multibase key`, path: ['publicKeyMultibase'] });\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn v.ok(input);\n\t});\n\nexport const service: v.Type\u003ct.Service\u003e = v.object({\n\t// should've only been RFC3968, but did:plc uses relative URIs.\n\tid: didRelativeUri,\n\ttype: v.union(v.string(), v.array(v.string())),\n\tserviceEndpoint: v.union(\n\t\trfc3968UriSchema,\n\t\tv.record(rfc3968UriSchema),\n\t\tv.array(v.union(rfc3968UriSchema, v.record(rfc3968UriSchema))),\n\t),\n});\n\nexport const didDocument: v.Type\u003ct.DidDocument\u003e = v\n\t.object({\n\t\t'@context': v.array(rfc3968UriSchema).optional(),\n\n\t\tid: didString,\n\n\t\talsoKnownAs: v\n\t\t\t.array(rfc3968UriSchema)\n\t\t\t.chain((input) =\u003e {\n\t\t\t\tfor (let i = 0, len = input.length; i \u003c len; i++) {\n\t\t\t\t\tconst aka = input[i];\n\n\t\t\t\t\tfor (let j = 0; j \u003c i; j++) {\n\t\t\t\t\t\tif (aka === input[j]) {\n\t\t\t\t\t\t\treturn v.err({\n\t\t\t\t\t\t\t\tmessage: `duplicate \"${aka}\" aka entry`,\n\t\t\t\t\t\t\t\tpath: [i],\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn v.ok(input);\n\t\t\t})\n\t\t\t.optional(),\n\t\tverificationMethod: v\n\t\t\t.array(verificationMethod)\n\t\t\t.chain((input) =\u003e {\n\t\t\t\tfor (let i = 0, len = input.length; i \u003c len; i++) {\n\t\t\t\t\tconst method = input[i];\n\t\t\t\t\tconst methodId = method.id;\n\n\t\t\t\t\tfor (let j = 0; j \u003c i; j++) {\n\t\t\t\t\t\tif (methodId === input[j].id) {\n\t\t\t\t\t\t\treturn v.err({\n\t\t\t\t\t\t\t\tmessage: `duplicate \"${methodId}\" verification method`,\n\t\t\t\t\t\t\t\tpath: [i, 'id'],\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn v.ok(input);\n\t\t\t})\n\t\t\t.optional(),\n\t\tservice: v.array(service).optional(),\n\n\t\tcontroller: v.union(didString, v.array(didString)).optional(),\n\t\tauthentication: v.array(v.union(didRelativeUri, verificationMethod)).optional(),\n\t})\n\t.chain((input) =\u003e {\n\t\tconst { id: did, service: services } = input;\n\n\t\tif (services?.length) {\n\t\t\tconst len = services.length;\n\n\t\t\t// oxlint-disable-next-line no-new-array\n\t\t\tconst identifiers = new Array(len);\n\n\t\t\tfor (let i = 0; i \u003c len; i++) {\n\t\t\t\tconst service = services[i];\n\n\t\t\t\tlet id = service.id;\n\t\t\t\tif (id[0] === '#') {\n\t\t\t\t\tid = did + id;\n\t\t\t\t}\n\n\t\t\t\tidentifiers[i] = id;\n\t\t\t}\n\n\t\t\tfor (let i = 0; i \u003c len; i++) {\n\t\t\t\tconst id = identifiers[i];\n\n\t\t\t\tfor (let j = 0; j \u003c i; j++) {\n\t\t\t\t\tif (id === identifiers[j]) {\n\t\t\t\t\t\treturn v.err({\n\t\t\t\t\t\t\tmessage: `duplicate \"${id}\" service`,\n\t\t\t\t\t\t\tpath: ['service', i, 'id'],\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn v.ok(input);\n\t});\n","import type { Handle } from '@atcute/lexicons';\nimport { isHandle } from '@atcute/lexicons/syntax';\n\nimport * as t from './types.ts';\n\nexport interface VerificationMaterial {\n\ttype: string;\n\tpublicKeyMultibase: string;\n}\n\nconst isUrlParseSupported = 'parse' in URL;\n\nexport const isAtprotoServiceEndpoint = (input: string): boolean =\u003e {\n\tlet url: URL | null = null;\n\tif (isUrlParseSupported) {\n\t\turl = URL.parse(input);\n\t} else {\n\t\ttry {\n\t\t\turl = new URL(input);\n\t\t} catch {}\n\t}\n\n\treturn (\n\t\turl !== null \u0026\u0026\n\t\t(url.protocol === 'https:' || url.protocol === 'http:') \u0026\u0026\n\t\turl.pathname === '/' \u0026\u0026\n\t\turl.search === '' \u0026\u0026\n\t\turl.hash === ''\n\t);\n};\n\nexport const getVerificationMaterial = (\n\tdoc: t.DidDocument,\n\tid: `#${string}`,\n): VerificationMaterial | undefined =\u003e {\n\tconst verificationMethods = doc.verificationMethod;\n\tif (!verificationMethods) {\n\t\treturn;\n\t}\n\n\tconst expectedId = `${doc.id}${id}`;\n\n\tfor (let idx = 0, len = verificationMethods.length; idx \u003c len; idx++) {\n\t\tconst { id, type, publicKeyMultibase } = verificationMethods[idx];\n\n\t\tif (id !== expectedId) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (publicKeyMultibase === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn { type, publicKeyMultibase };\n\t}\n};\n\nexport const getAtprotoVerificationMaterial = (doc: t.DidDocument): VerificationMaterial | undefined =\u003e {\n\treturn getVerificationMaterial(doc, '#atproto');\n};\n\nexport const getAtprotoLabelerVerificationMaterial = (\n\tdoc: t.DidDocument,\n): VerificationMaterial | undefined =\u003e {\n\treturn getVerificationMaterial(doc, '#atproto_label');\n};\n\nexport const getAtprotoHandle = (doc: t.DidDocument): Handle | null | undefined =\u003e {\n\tconst alsoKnownAs = doc.alsoKnownAs;\n\tif (!alsoKnownAs) {\n\t\treturn null;\n\t}\n\n\tconst PREFIX = 'at://';\n\n\tfor (let idx = 0, len = alsoKnownAs.length; idx \u003c len; idx++) {\n\t\tconst aka = alsoKnownAs[idx];\n\n\t\tif (!aka.startsWith(PREFIX)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst raw = aka.slice(PREFIX.length);\n\n\t\tif (!isHandle(raw)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn raw;\n\t}\n\n\treturn null;\n};\n\nexport const getAtprotoServiceEndpoint = (\n\tdoc: t.DidDocument,\n\tpredicate: { id: `#${string}`; type?: string },\n): string | undefined =\u003e {\n\tconst services = doc.service;\n\tif (!services) {\n\t\treturn;\n\t}\n\n\tfor (let idx = 0, len = services.length; idx \u003c len; idx++) {\n\t\tconst { id, type, serviceEndpoint } = services[idx];\n\n\t\tif (id !== predicate.id \u0026\u0026 id !== doc.id + predicate.id) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (predicate.type !== undefined) {\n\t\t\tif (Array.isArray(type)) {\n\t\t\t\tif (!type.includes(predicate.type)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (type !== predicate.type) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (typeof serviceEndpoint !== 'string' || !isAtprotoServiceEndpoint(serviceEndpoint)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn serviceEndpoint;\n\t}\n};\n\nexport const getPdsEndpoint = (doc: t.DidDocument): string | undefined =\u003e {\n\treturn getAtprotoServiceEndpoint(doc, {\n\t\tid: '#atproto_pds',\n\t\ttype: 'AtprotoPersonalDataServer',\n\t});\n};\n\nexport const getLabelerEndpoint = (doc: t.DidDocument): string | undefined =\u003e {\n\treturn getAtprotoServiceEndpoint(doc, {\n\t\tid: '#atproto_labeler',\n\t\ttype: 'AtprotoLabeler',\n\t});\n};\n\nexport const getBlueskyChatEndpoint = (doc: t.DidDocument): string | undefined =\u003e {\n\treturn getAtprotoServiceEndpoint(doc, {\n\t\tid: '#bsky_chat',\n\t\ttype: 'BskyChatService',\n\t});\n};\n\nexport const getBlueskyFeedgenEndpoint = (doc: t.DidDocument): string | undefined =\u003e {\n\treturn getAtprotoServiceEndpoint(doc, {\n\t\tid: '#bsky_fg',\n\t\ttype: 'BskyFeedGenerator',\n\t});\n};\n\nexport const getBlueskyNotificationEndpoint = (doc: t.DidDocument): string | undefined =\u003e {\n\treturn getAtprotoServiceEndpoint(doc, {\n\t\tid: '#bsky_notif',\n\t\ttype: 'BskyNotificationService',\n\t});\n};\n","import type { Did } from '@atcute/lexicons/syntax';\n\n/** @deprecated use `isPlcDid` instead */\nexport const PLC_DID_RE = /^did:plc:([a-z2-7]{24})$/;\n\n/**\n * checks if input is a did:plc identifier\n */\nexport const isPlcDid = (input: string): input is Did\u003c'plc'\u003e =\u003e {\n\treturn input.length === 32 \u0026\u0026 PLC_DID_RE.test(input);\n};\n","import type { Did } from '@atcute/lexicons/syntax';\n\n/** @deprecated use `isWebDid` instead */\nexport const WEB_DID_RE =\n\t/^did:web:([a-zA-Z0-9%-]+(?:(?:\\.[a-zA-Z0-9%-]+)*(?:\\.[a-zA-Z]{2,}))?)?((?::[a-zA-Z0-9\\-%.]+)+)?$/;\n\n/** @deprecated use `isAtprotoWebDid` instead */\nexport const ATPROTO_WEB_DID_RE =\n\t/^did:web:([a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*(?:\\.[a-zA-Z]{2,})|localhost(?:%3[aA]\\d+)?)$/;\n\n/**\n * checks if input is a did:web identifier, note that you should probably use\n * `isAtprotoWebDid` for atproto-related cases as atproto only supports a subset\n * of the did:web specification (namely, no custom paths)\n */\nexport const isWebDid = (input: string): input is Did\u003c'web'\u003e =\u003e {\n\treturn input.length \u003e= 9 \u0026\u0026 WEB_DID_RE.test(input);\n};\n\n/**\n * checks if input is a did:web identifier that is supported by atproto\n */\nexport const isAtprotoWebDid = (input: string): input is Did\u003c'web'\u003e =\u003e {\n\treturn input.length \u003e= 12 \u0026\u0026 ATPROTO_WEB_DID_RE.test(input);\n};\n\n/**\n * normalize a did:web identifier\n */\nexport const normalizeWebDid = (did: Did\u003c'web'\u003e): Did\u003c'web'\u003e =\u003e {\n\tconst [host, ...paths] = did.slice(8).split(':').map(decodeURIComponent);\n\n\tlet normalized = `did:web:${encodeURIComponent(host.toLowerCase())}`;\n\tif (paths.length \u003e 0) {\n\t\tnormalized += `:${paths.join(':')}`;\n\t}\n\n\treturn normalized as Did\u003c'web'\u003e;\n};\n\n/**\n * converts did:web identifier into the DID document's URL\n */\nexport const webDidToDocumentUrl = (did: Did\u003c'web'\u003e): URL =\u003e {\n\tconst [host, ...paths] = did.slice(8).split(':').map(decodeURIComponent);\n\n\tlet pathname = '/' + paths.join('/');\n\tif (pathname === '/') {\n\t\tpathname = `/.well-known/did.json`;\n\t} else {\n\t\tpathname += `/did.json`;\n\t}\n\n\tconst url = new URL(`https://${host}${pathname}`);\n\tif (url.hostname === 'localhost') {\n\t\turl.protocol = 'http:';\n\t}\n\n\treturn url;\n};\n","import type { AtprotoAudience, AtprotoDid, Did } from '@atcute/lexicons/syntax';\n\nimport { isPlcDid } from './methods/plc.ts';\nimport { isAtprotoWebDid } from './methods/web.ts';\n\nconst FRAGMENT_RE = /^(?:[A-Za-z0-9\\-._~!$\u0026'()*+,;=:@/?]|%[0-9A-Fa-f]{2})*$/;\n\n/**\n * checks if it's a DID identifier that is supported by atproto\n */\nexport const isAtprotoDid = (input: string): input is AtprotoDid =\u003e {\n\treturn isPlcDid(input) || isAtprotoWebDid(input);\n};\n\nexport const isAtprotoAudience = (input: string): input is AtprotoAudience =\u003e {\n\t// 'did:web:a.co#f'\n\tif (input.length \u003c 14) {\n\t\treturn false;\n\t}\n\n\tconst isep = input.indexOf('#', 12);\n\tif (isep === -1) {\n\t\treturn false;\n\t}\n\n\treturn FRAGMENT_RE.test(input.slice(isep + 1)) \u0026\u0026 isAtprotoDid(input.slice(0, isep));\n};\n\n/**\n * returns the DID's method\n */\nexport const extractDidMethod = \u003cM extends string\u003e(did: Did\u003cM\u003e): M =\u003e {\n\tconst isep = did.indexOf(':', 4);\n\tconst method = did.slice(4, isep);\n\treturn method as M;\n};\n","import type { Did } from '@atcute/lexicons';\n\nconst KEY_DID_RE = /^did:key:z[a-km-zA-HJ-NP-Z1-9]+$/;\n\n/**\n * checks if input is a did:key identifier\n */\nexport const isKeyDid = (input: string): input is Did\u003c'key'\u003e =\u003e {\n\treturn input.length \u003e= 10 \u0026\u0026 KEY_DID_RE.test(input);\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/interfaces/bytes.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/dist/interfaces/bytes */ 2 + var s=Symbol.for("@atcute/bytes-wrapper"),n=t=>typeof t=="object"&&t!==null&&s in t,r=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}(?:==)?|[A-Za-z0-9+/]{3}=?)?$/,o=t=>typeof t!="string"?!1:r.test(t),c=t=>{let e=t;return typeof e=="object"&&e!==null&&(s in e||o(e.$bytes)&&Object.keys(e).length===1)};export{n as _isBytesWrapper,c as isBytes}; 3 + //# sourceMappingURL=./bytes.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/interfaces/bytes.mjs.map
··· 1 + {"mappings":";AAOA,IAAMA,EAAe,OAAO,IAAI,uBAAuB,EAmB1CC,EAAmBC,GACxB,OAAOA,GAAU,UAAYA,IAAU,MAAQF,KAAgBE,EAGjEC,EAAY,yEACZC,EAAYF,GACb,OAAOA,GAAU,SACb,GAGDC,EAAU,KAAKD,CAAK,EAIfG,EAAWH,GAAkC,CACzD,IAAMI,EAAIJ,EAEV,OACC,OAAOI,GAAM,UACbA,IAAM,OACLN,KAAgBM,GAAMF,EAASE,EAAE,MAAM,GAAK,OAAO,KAAKA,CAAC,EAAE,SAAW,EAEzE","names":["BYTES_SYMBOL","_isBytesWrapper","input","BASE64_RE","isBase64","isBytes","v"],"sources":["../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/interfaces/bytes.ts"],"sourcesContent":["/**\n * represents an object containing raw binary data encoded as a base64 string\n */\nexport interface Bytes {\n\t$bytes: string;\n}\n\nconst BYTES_SYMBOL = Symbol.for('@atcute/bytes-wrapper');\n\n/**\n * this should match with {@link file://./../../../../utilities/cbor/lib/bytes.ts}\n * @internal\n */\nexport interface _BytesWrapper {\n\treadonly [BYTES_SYMBOL]: true;\n\n\treadonly buf: Uint8Array;\n\treadonly $bytes: string;\n\n\ttoJSON(): Bytes;\n}\n\n/**\n * @internal\n */\n// #__NO_SIDE_EFFECTS__\nexport const _isBytesWrapper = (input: unknown): input is _BytesWrapper =\u003e {\n\treturn typeof input === 'object' \u0026\u0026 input !== null \u0026\u0026 BYTES_SYMBOL in input;\n};\n\nconst BASE64_RE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}(?:==)?|[A-Za-z0-9+/]{3}=?)?$/;\nconst isBase64 = (input: unknown): input is string =\u003e {\n\tif (typeof input !== 'string') {\n\t\treturn false;\n\t}\n\n\treturn BASE64_RE.test(input);\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const isBytes = (input: unknown): input is Bytes =\u003e {\n\tconst v = input as any;\n\n\treturn (\n\t\ttypeof v === 'object' \u0026\u0026\n\t\tv !== null \u0026\u0026\n\t\t(BYTES_SYMBOL in v || (isBase64(v.$bytes) \u0026\u0026 Object.keys(v).length === 1))\n\t);\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/at-identifier.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/dist/syntax/at-identifier */ 2 + import{isDid as i}from"./did.mjs";import{isHandle as o}from"./handle.mjs";var m=r=>i(r)||o(r);export{m as isActorIdentifier}; 3 + //# sourceMappingURL=./at-identifier.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/at-identifier.mjs.map
··· 1 + {"mappings":";AAAA,OAAS,SAAAA,MAAuB,YAChC,OAAS,YAAAC,MAA6B,eAS/B,IAAMC,EAAqBC,GAC1BH,EAAMG,CAAK,GAAKF,EAASE,CAAK","names":["isDid","isHandle","isActorIdentifier","input"],"sources":["../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/at-identifier.ts"],"sourcesContent":["import { isDid, type Did } from './did.ts';\nimport { isHandle, type Handle } from './handle.ts';\n\n/**\n * represents an account's identifier, either a {@link Did} or a\n * {@link Handle}\n */\nexport type ActorIdentifier = Did | Handle;\n\n// #__NO_SIDE_EFFECTS__\nexport const isActorIdentifier = (input: unknown): input is ActorIdentifier =\u003e {\n\treturn isDid(input) || isHandle(input);\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/at-uri.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/dist/syntax/at-uri */ 2 + import{isActorIdentifier as u}from"./at-identifier.mjs";import{isDid as A}from"./did.mjs";import{isNsid as c}from"./nsid.mjs";import{isRecordKey as d}from"./record-key.mjs";import{isAsciiAlphaNum as _}from"./utils/ascii.mjs";var k=8,m=20,x=2884,g=/^at:\/\/([a-zA-Z0-9._:%-]+)(?:\/([a-zA-Z0-9-.]+)(?:\/([a-zA-Z0-9._~:@!$&%')(*+,;=-]+))?)?(?:#(\/[a-zA-Z0-9._~:@!$&%')(*+,;=\-[\]/\\]*))?$/,$=r=>_(r)||r===46||r===95||r===126||r===58||r===64||r===33||r===36||r===38||r===37||r===39||r===41||r===40||r===42||r===43||r===44||r===59||r===61||r===45||r===91||r===93||r===47||r===92,I=r=>{if(typeof r!="string")return!1;let s=r.length;if(s<k||s>x||r.charCodeAt(0)!==97||r.charCodeAt(1)!==116||r.charCodeAt(2)!==58||r.charCodeAt(3)!==47||r.charCodeAt(4)!==47)return!1;let n=r.indexOf("#",5),e=n===-1?s:n;if(n!==-1){let f=n+1;if(f>=s||r.charCodeAt(f)!==47)return!1;for(let a=f;a<s;a++)if(!$(r.charCodeAt(a)))return!1}let o=r.indexOf("/",5),t=e,i,l;if(o!==-1&&o<e){t=o;let f=o+1;if(f>=e)return!1;let a=r.indexOf("/",f);if(a!==-1&&a<e){if(a===f||a+1>=e)return!1;let h=r.indexOf("/",a+1);if(h!==-1&&h<e)return!1;i=r.substring(f,a),l=r.substring(a+1,e)}else i=r.substring(f,e)}if(t<=5)return!1;let C=r.substring(5,t);return u(C)&&(i===void 0||c(i))&&(l===void 0||d(l))},O=r=>{let s=r.length;if(s<k||s>x)return{ok:!1,error:`invalid at-uri: ${r}`};let n=g.exec(r);if(n===null)return{ok:!1,error:`invalid at-uri: ${r}`};let[,e,o,t,i]=n;return u(e)?o!==void 0&&!c(o)?{ok:!1,error:`invalid collection in at-uri: ${o}`}:t!==void 0&&!d(t)?{ok:!1,error:`invalid rkey in at-uri: ${t}`}:{ok:!0,value:{repo:e,collection:o,rkey:t,fragment:i}}:{ok:!1,error:`invalid repo in at-uri: ${e}`}},U=r=>{if(typeof r!="string")return!1;let s=r.length;if(s<m||s>x||r.charCodeAt(0)!==97||r.charCodeAt(1)!==116||r.charCodeAt(2)!==58||r.charCodeAt(3)!==47||r.charCodeAt(4)!==47)return!1;let n=r.indexOf("/",5);if(n===-1)return!1;let e=r.indexOf("/",n+1);if(e===-1)return!1;let o=r.indexOf("#",e+1),t=r.substring(5,n),i=r.substring(n+1,e),l=o===-1?r.substring(e+1):r.substring(e+1,o);return A(t)&&c(i)&&d(l)},S=r=>{let s=r.length;if(s<m||s>x)return{ok:!1,error:`invalid canonical-at-uri: ${r}`};let n=g.exec(r);if(n===null)return{ok:!1,error:`invalid canonical-at-uri: ${r}`};let[,e,o,t,i]=n;return A(e)?c(o)?d(t)?{ok:!0,value:{repo:e,collection:o,rkey:t,fragment:i}}:{ok:!1,error:`invalid rkey in canonical-at-uri: ${t}`}:{ok:!1,error:`invalid collection in canonical-at-uri: ${o}`}:{ok:!1,error:`invalid repo in canonical-at-uri: ${e}`}};export{U as isCanonicalResourceUri,I as isResourceUri,S as parseCanonicalResourceUri,O as parseResourceUri}; 3 + //# sourceMappingURL=./at-uri.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/at-uri.mjs.map
··· 1 + {"mappings":";AAEA,OAAS,qBAAAA,MAA+C,sBACxD,OAAS,SAAAC,MAAuB,YAChC,OAAS,UAAAC,MAAyB,aAClC,OAAS,eAAAC,MAAmC,mBAC5C,OAAS,mBAAAC,MAAuB,oBAmBhC,IAAMC,EAAoB,EAEpBC,EAA8B,GAG9BC,EAAoB,KAMpBC,EACL,4IAEKC,EAAkBC,GAEtBN,EAAgBM,CAAC,GACjBA,IAAM,IACNA,IAAM,IACNA,IAAM,KACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,IACNA,IAAM,GAKKC,EAAiBC,GAAwC,CACrE,GAAI,OAAOA,GAAU,SACpB,MAAO,GAGR,IAAMC,EAAMD,EAAM,OAKlB,GAJIC,EAAMR,GAAqBQ,EAAMN,GAKpCK,EAAM,WAAW,CAAC,IAAM,IACxBA,EAAM,WAAW,CAAC,IAAM,KACxBA,EAAM,WAAW,CAAC,IA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ACxDF,EAAOW,IAAY,GAAKpB,EAAM,UAAUW,EAAc,CAAC,EAAIX,EAAM,UAAUW,EAAc,EAAGS,CAAO,EAEzG,OAAO/B,EAAMwB,CAAI,GAAKvB,EAAOkB,CAAU,GAAKjB,EAAYkB,CAAI,CAC7D,EAGaY,EAA6BrB,GAA6D,CACtG,IAAMC,EAAMD,EAAM,OAClB,GAAIC,EAAMP,GAA+BO,EAAMN,EAC9C,MAAO,CAAE,GAAI,GAAO,MAAO,6BAA6BK,CAAK,EAAE,EAGhE,IAAMe,EAAQnB,EAAS,KAAKI,CAAK,EACjC,GAAIe,IAAU,KACb,MAAO,CAAE,GAAI,GAAO,MAAO,6BAA6Bf,CAAK,EAAE,EAGhE,GAAM,CAAC,CAAEgB,EAAGlB,EAAGmB,EAAGC,CAAC,EAAIH,EAEvB,OAAK1B,EAAM2B,CAAC,EAIP1B,EAAOQ,CAAC,EAIRP,EAAY0B,CAAC,EAIX,CAAE,GAAI,GAAM,MAAO,CAAE,KAAMD,EAAG,WAAYlB,EAAG,KAAMmB,EAAG,SAAUC,CAAC,CAAE,EAHlE,CAAE,GAAI,GAAO,MAAO,qCAAqCD,CAAC,EAAE,EAJ5D,CAAE,GAAI,GAAO,MAAO,2CAA2CnB,CAAC,EAAE,EAJlE,CAAE,GAAI,GAAO,MAAO,qCAAqCkB,CAAC,EAAE,CAYrE","names":["isActorIdentifier","isDid","isNsid","isRecordKey","isAsciiAlphaNum","AT_URI_MIN_LENGTH","CANONICAL_AT_URI_MIN_LENGTH","AT_URI_MAX_LENGTH","ATURI_RE","isFragmentChar","c","isResourceUri","input","len","hash","stop","fragmentStart","idx","firstSlash","repoEnd","collection","rkey","collectionStart","secondSlash","thirdSlash","repo","parseResourceUri","match","r","k","f","isCanonicalResourceUri","hashPos","parseCanonicalResourceUri"],"sources":["../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/at-uri.ts"],"sourcesContent":["import { type Result } from '../utils.ts';\n\nimport { isActorIdentifier, type ActorIdentifier } from './at-identifier.ts';\nimport { isDid, type Did } from './did.ts';\nimport { isNsid, type Nsid } from './nsid.ts';\nimport { isRecordKey, type RecordKey } from './record-key.ts';\nimport { isAsciiAlphaNum } from './utils/ascii.ts';\n\n/**\n * represents a general AT Protocol URI, representing either an entire\n * repository, a specific collection within a repository, or a record.\n *\n * it allows using handles over DIDs, but this means that it won't be stable.\n */\nexport type ResourceUri =\n\t| `at://${ActorIdentifier}`\n\t| `at://${ActorIdentifier}/${Nsid}`\n\t| `at://${ActorIdentifier}/${Nsid}/${RecordKey}`;\n\nexport type ParsedResourceUri =\n\t| { repo: ActorIdentifier; collection: undefined; rkey: undefined; fragment: string | undefined }\n\t| { repo: ActorIdentifier; collection: Nsid; rkey: undefined; fragment: string | undefined }\n\t| { repo: ActorIdentifier; collection: Nsid; rkey: RecordKey; fragment: string | undefined };\n\n// minimum valid non-canonical at-uri is `at://a.a` (8 chars)\nconst AT_URI_MIN_LENGTH = 8;\n// minimum canonical at-uri is `at://did:m:v/a.b.c/x` (20 chars)\nconst CANONICAL_AT_URI_MIN_LENGTH = 5 + 7 + 1 + 5 + 1 + 1;\n// maximum structural length:\n// `at://` + DID (2048) + `/` + NSID (317) + `/` + rkey (512)\nconst AT_URI_MAX_LENGTH = 5 + 2048 + 1 + 317 + 1 + 512;\n\n// repo: [a-zA-Z0-9._:%-]\n// collection: [a-zA-Z0-9.-]\n// rkey: [a-zA-Z0-9._~:@!$\u0026%')(*+,;=-]\n// fragment: /[a-zA-Z0-9._~:@!$\u0026%')(*+,;=\\-[\\]/\\\\]*\nconst ATURI_RE =\n\t/^at:\\/\\/([a-zA-Z0-9._:%-]+)(?:\\/([a-zA-Z0-9-.]+)(?:\\/([a-zA-Z0-9._~:@!$\u0026%')(*+,;=-]+))?)?(?:#(\\/[a-zA-Z0-9._~:@!$\u0026%')(*+,;=\\-[\\]/\\\\]*))?$/;\n\nconst isFragmentChar = (c: number): boolean =\u003e {\n\treturn (\n\t\tisAsciiAlphaNum(c) ||\n\t\tc === 0x2e || // .\n\t\tc === 0x5f || // _\n\t\tc === 0x7e || // ~\n\t\tc === 0x3a || // :\n\t\tc === 0x40 || // @\n\t\tc === 0x21 || // !\n\t\tc === 0x24 || // $\n\t\tc === 0x26 || // \u0026\n\t\tc === 0x25 || // %\n\t\tc === 0x27 || // '\n\t\tc === 0x29 || // )\n\t\tc === 0x28 || // (\n\t\tc === 0x2a || // *\n\t\tc === 0x2b || // +\n\t\tc === 0x2c || // ,\n\t\tc === 0x3b || // ;\n\t\tc === 0x3d || // =\n\t\tc === 0x2d || // -\n\t\tc === 0x5b || // [\n\t\tc === 0x5d || // ]\n\t\tc === 0x2f || // /\n\t\tc === 0x5c // \\\n\t);\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const isResourceUri = (input: unknown): input is ResourceUri =\u003e {\n\tif (typeof input !== 'string') {\n\t\treturn false;\n\t}\n\n\tconst len = input.length;\n\tif (len \u003c AT_URI_MIN_LENGTH || len \u003e AT_URI_MAX_LENGTH) {\n\t\treturn false;\n\t}\n\n\tif (\n\t\tinput.charCodeAt(0) !== 0x61 ||\n\t\tinput.charCodeAt(1) !== 0x74 ||\n\t\tinput.charCodeAt(2) !== 0x3a ||\n\t\tinput.charCodeAt(3) !== 0x2f ||\n\t\tinput.charCodeAt(4) !== 0x2f\n\t) {\n\t\treturn false;\n\t}\n\n\tconst hash = input.indexOf('#', 5);\n\tconst stop = hash === -1 ? len : hash;\n\n\tif (hash !== -1) {\n\t\tconst fragmentStart = hash + 1;\n\t\tif (fragmentStart \u003e= len || input.charCodeAt(fragmentStart) !== 0x2f) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (let idx = fragmentStart; idx \u003c len; idx++) {\n\t\t\tif (!isFragmentChar(input.charCodeAt(idx))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst firstSlash = input.indexOf('/', 5);\n\tlet repoEnd = stop;\n\tlet collection: string | undefined;\n\tlet rkey: string | undefined;\n\n\tif (firstSlash !== -1 \u0026\u0026 firstSlash \u003c stop) {\n\t\trepoEnd = firstSlash;\n\n\t\tconst collectionStart = firstSlash + 1;\n\t\tif (collectionStart \u003e= stop) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst secondSlash = input.indexOf('/', collectionStart);\n\t\tif (secondSlash !== -1 \u0026\u0026 secondSlash \u003c stop) {\n\t\t\tif (secondSlash === collectionStart || secondSlash + 1 \u003e= stop) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst thirdSlash = input.indexOf('/', secondSlash + 1);\n\t\t\tif (thirdSlash !== -1 \u0026\u0026 thirdSlash \u003c stop) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tcollection = input.substring(collectionStart, secondSlash);\n\t\t\trkey = input.substring(secondSlash + 1, stop);\n\t\t} else {\n\t\t\tcollection = input.substring(collectionStart, stop);\n\t\t}\n\t}\n\n\tif (repoEnd \u003c= 5) {\n\t\treturn false;\n\t}\n\n\tconst repo = input.substring(5, repoEnd);\n\n\treturn (\n\t\tisActorIdentifier(repo) \u0026\u0026\n\t\t(collection === undefined || isNsid(collection)) \u0026\u0026\n\t\t(rkey === undefined || isRecordKey(rkey))\n\t);\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const parseResourceUri = (input: string): Result\u003cParsedResourceUri, string\u003e =\u003e {\n\tconst len = input.length;\n\tif (len \u003c AT_URI_MIN_LENGTH || len \u003e AT_URI_MAX_LENGTH) {\n\t\treturn { ok: false, error: `invalid at-uri: ${input}` };\n\t}\n\n\tconst match = ATURI_RE.exec(input);\n\tif (match === null) {\n\t\treturn { ok: false, error: `invalid at-uri: ${input}` };\n\t}\n\n\tconst [, r, c, k, f] = match;\n\n\tif (!isActorIdentifier(r)) {\n\t\treturn { ok: false, error: `invalid repo in at-uri: ${r}` };\n\t}\n\n\tif (c !== undefined \u0026\u0026 !isNsid(c)) {\n\t\treturn { ok: false, error: `invalid collection in at-uri: ${c}` };\n\t}\n\n\tif (k !== undefined \u0026\u0026 !isRecordKey(k)) {\n\t\treturn { ok: false, error: `invalid rkey in at-uri: ${k}` };\n\t}\n\n\treturn { ok: true, value: { repo: r, collection: c, rkey: k, fragment: f } };\n};\n\n/**\n * represents a canonical AT Protocol URI for a specific record.\n *\n * this URI format uses the account's DID as the authority, ensuring that\n * the URI remains valid even as the account changes handles, uniquely\n * identifying a specific piece of record within AT Protocol.\n */\nexport type CanonicalResourceUri = `at://${Did}/${Nsid}/${RecordKey}`;\n\nexport type ParsedCanonicalResourceUri = {\n\trepo: Did;\n\tcollection: Nsid;\n\trkey: RecordKey;\n\tfragment: string | undefined;\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const isCanonicalResourceUri = (input: unknown): input is CanonicalResourceUri =\u003e {\n\tif (typeof input !== 'string') {\n\t\treturn false;\n\t}\n\n\tconst len = input.length;\n\tif (len \u003c CANONICAL_AT_URI_MIN_LENGTH || len \u003e AT_URI_MAX_LENGTH) {\n\t\treturn false;\n\t}\n\n\t// must start with \"at://\"\n\tif (\n\t\tinput.charCodeAt(0) !== 0x61 ||\n\t\tinput.charCodeAt(1) !== 0x74 ||\n\t\tinput.charCodeAt(2) !== 0x3a ||\n\t\tinput.charCodeAt(3) !== 0x2f ||\n\t\tinput.charCodeAt(4) !== 0x2f\n\t) {\n\t\treturn false;\n\t}\n\n\tconst firstSlash = input.indexOf('/', 5);\n\tif (firstSlash === -1) {\n\t\treturn false;\n\t}\n\n\tconst secondSlash = input.indexOf('/', firstSlash + 1);\n\tif (secondSlash === -1) {\n\t\treturn false;\n\t}\n\n\t// check for fragment\n\tconst hashPos = input.indexOf('#', secondSlash + 1);\n\n\tconst repo = input.substring(5, firstSlash);\n\tconst collection = input.substring(firstSlash + 1, secondSlash);\n\tconst rkey = hashPos === -1 ? input.substring(secondSlash + 1) : input.substring(secondSlash + 1, hashPos);\n\n\treturn isDid(repo) \u0026\u0026 isNsid(collection) \u0026\u0026 isRecordKey(rkey);\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const parseCanonicalResourceUri = (input: string): Result\u003cParsedCanonicalResourceUri, string\u003e =\u003e {\n\tconst len = input.length;\n\tif (len \u003c CANONICAL_AT_URI_MIN_LENGTH || len \u003e AT_URI_MAX_LENGTH) {\n\t\treturn { ok: false, error: `invalid canonical-at-uri: ${input}` };\n\t}\n\n\tconst match = ATURI_RE.exec(input);\n\tif (match === null) {\n\t\treturn { ok: false, error: `invalid canonical-at-uri: ${input}` };\n\t}\n\n\tconst [, r, c, k, f] = match;\n\n\tif (!isDid(r)) {\n\t\treturn { ok: false, error: `invalid repo in canonical-at-uri: ${r}` };\n\t}\n\n\tif (!isNsid(c)) {\n\t\treturn { ok: false, error: `invalid collection in canonical-at-uri: ${c}` };\n\t}\n\n\tif (!isRecordKey(k)) {\n\t\treturn { ok: false, error: `invalid rkey in canonical-at-uri: ${k}` };\n\t}\n\n\treturn { ok: true, value: { repo: r, collection: c, rkey: k, fragment: f } };\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/cid.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/dist/syntax/cid */ 2 + var e=/^baf[ky]rei[a-z2-7]{52}$/,r=t=>typeof t=="string"&&t.length===59&&e.test(t);export{r as isCid}; 3 + //# sourceMappingURL=./cid.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/cid.mjs.map
··· 1 + {"mappings":";AAKA,IAAMA,EAAc,2BAGPC,EAASC,GACd,OAAOA,GAAU,UAAYA,EAAM,SAAW,IAAMF,EAAY,KAAKE,CAAK","names":["DASL_CID_RE","isCid","input"],"sources":["../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/cid.ts"],"sourcesContent":["/**\n * represents a content identifier (CID)\n */\nexport type Cid = string;\n\nconst DASL_CID_RE = /^baf[ky]rei[a-z2-7]{52}$/;\n\n// #__NO_SIDE_EFFECTS__\nexport const isCid = (input: unknown): input is Cid =\u003e {\n\treturn typeof input === 'string' \u0026\u0026 input.length === 59 \u0026\u0026 DASL_CID_RE.test(input);\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/did.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/dist/syntax/did */ 2 + var e=/^did:([a-z]+):([a-zA-Z0-9._:%-]*[a-zA-Z0-9._-])$/,s=t=>typeof t=="string"&&t.length>=7&&t.length<=2048&&e.test(t);export{s as isDid}; 3 + //# sourceMappingURL=./did.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/did.mjs.map
··· 1 + {"mappings":";AAYA,IAAMA,EAAS,mDAGFC,EAASC,GACd,OAAOA,GAAU,UAAYA,EAAM,QAAU,GAAKA,EAAM,QAAU,MAAQF,EAAO,KAAKE,CAAK","names":["DID_RE","isDid","input"],"sources":["../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/did.ts"],"sourcesContent":["/**\n * represents a decentralized identifier (DID).\n */\nexport type Did\u003cMethod extends string = string\u003e = `did:${Method}:${string}`;\n\n/**\n * represents a decentralized identifier with methods supported in atproto\n */\nexport type AtprotoDid = Did\u003c'plc' | 'web'\u003e;\n\nexport type AtprotoAudience = `${AtprotoDid}#${string}`;\n\nconst DID_RE = /^did:([a-z]+):([a-zA-Z0-9._:%-]*[a-zA-Z0-9._-])$/;\n\n// #__NO_SIDE_EFFECTS__\nexport const isDid = (input: unknown): input is Did =\u003e {\n\treturn typeof input === 'string' \u0026\u0026 input.length \u003e= 7 \u0026\u0026 input.length \u003c= 2048 \u0026\u0026 DID_RE.test(input);\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/handle.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/dist/syntax/handle */ 2 + import{isAsciiAlpha as i,isAsciiAlphaNum as s}from"./utils/ascii.mjs";var c=(r,t,l)=>{let f=l-t;if(f===0||f>63)return!1;let a=r.charCodeAt(t);if(!s(a))return!1;if(f>1){if(!s(r.charCodeAt(l-1)))return!1;for(let e=t+1;e<l-1;e++){let o=r.charCodeAt(e);if(!s(o)&&o!==45)return!1}}return!0},A=r=>{if(typeof r!="string")return!1;let t=r.length;if(t<3||t>253)return!1;let l=0,f=0,a=0;for(let e=0;e<=t;e++)if(e===t||r.charCodeAt(e)===46){if(!c(r,l,e))return!1;a=l,l=e+1,f++}return f<2?!1:i(r.charCodeAt(a))};export{A as isHandle}; 3 + //# sourceMappingURL=./handle.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/handle.mjs.map
··· 1 + {"mappings":";AAAA,OAAS,gBAAAA,EAAc,mBAAAC,MAAuB,oBAS9C,IAAMC,EAAe,CAACC,EAAeC,EAAeC,IAAwB,CAC3E,IAAMC,EAAMD,EAAMD,EAClB,GAAIE,IAAQ,GAAKA,EAAM,GACtB,MAAO,GAGR,IAAMC,EAAQJ,EAAM,WAAWC,CAAK,EACpC,GAAI,CAACH,EAAgBM,CAAK,EACzB,MAAO,GAGR,GAAID,EAAM,EAAG,CACZ,GAAI,CAACL,EAAgBE,EAAM,WAAWE,EAAM,CAAC,CAAC,EAAG,MAAO,GACxD,QAASG,EAAIJ,EAAQ,EAAGI,EAAIH,EAAM,EAAGG,IAAK,CACzC,IAAMC,EAAIN,EAAM,WAAWK,CAAC,EAC5B,GAAI,CAACP,EAAgBQ,CAAC,GAAKA,IAAM,GAChC,MAAO,EAET,CACD,CAEA,MAAO,EACR,EAGaC,EAAYP,GAAmC,CAC3D,GAAI,OAAOA,GAAU,SACpB,MAAO,GAGR,IAAMG,EAAMH,EAAM,OAClB,GAAIG,EAAM,GAAKA,EAAM,IACpB,MAAO,GAGR,IAAIK,EAAa,EACbC,EAAa,EACbC,EAAiB,EAErB,QAASC,EAAI,EAAGA,GAAKR,EAAKQ,IACzB,GAAIA,IAAMR,GAAOH,EAAM,WAAWW,CAAC,IAAM,GAAM,CAC9C,GAAI,CAACZ,EAAaC,EAAOQ,EAAYG,CAAC,EACrC,MAAO,GAERD,EAAiBF,EACjBA,EAAaG,EAAI,EACjBF,GACD,CAID,OAAIA,EAAa,EACT,GAIDZ,EAAaG,EAAM,WAAWU,CAAc,CAAC,CACrD","names":["isAsciiAlpha","isAsciiAlphaNum","isValidLabel","input","start","end","len","first","j","c","isHandle","labelStart","labelCount","lastLabelStart","i"],"sources":["../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/handle.ts"],"sourcesContent":["import { isAsciiAlpha, isAsciiAlphaNum } from './utils/ascii.ts';\n\n/**\n * represents an account's handle, using domains as a human-friendly\n * identifier.\n */\nexport type Handle = `${string}.${string}`;\n\n// validates a domain label: starts/ends with alphanumeric, middle allows hyphens, max 63 chars\nconst isValidLabel = (input: string, start: number, end: number): boolean =\u003e {\n\tconst len = end - start;\n\tif (len === 0 || len \u003e 63) {\n\t\treturn false;\n\t}\n\n\tconst first = input.charCodeAt(start);\n\tif (!isAsciiAlphaNum(first)) {\n\t\treturn false;\n\t}\n\n\tif (len \u003e 1) {\n\t\tif (!isAsciiAlphaNum(input.charCodeAt(end - 1))) return false;\n\t\tfor (let j = start + 1; j \u003c end - 1; j++) {\n\t\t\tconst c = input.charCodeAt(j);\n\t\t\tif (!isAsciiAlphaNum(c) \u0026\u0026 c !== 0x2d) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const isHandle = (input: unknown): input is Handle =\u003e {\n\tif (typeof input !== 'string') {\n\t\treturn false;\n\t}\n\n\tconst len = input.length;\n\tif (len \u003c 3 || len \u003e 253) {\n\t\treturn false;\n\t}\n\n\tlet labelStart = 0;\n\tlet labelCount = 0;\n\tlet lastLabelStart = 0;\n\n\tfor (let i = 0; i \u003c= len; i++) {\n\t\tif (i === len || input.charCodeAt(i) === 0x2e) {\n\t\t\tif (!isValidLabel(input, labelStart, i)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tlastLabelStart = labelStart;\n\t\t\tlabelStart = i + 1;\n\t\t\tlabelCount++;\n\t\t}\n\t}\n\n\t// need at least 2 labels (one dot)\n\tif (labelCount \u003c 2) {\n\t\treturn false;\n\t}\n\n\t// TLD must start with a letter\n\treturn isAsciiAlpha(input.charCodeAt(lastLabelStart));\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/nsid.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/dist/syntax/nsid */ 2 + import{isAsciiAlpha as h,isAsciiAlphaNum as a}from"./utils/ascii.mjs";var C=r=>{if(typeof r!="string")return!1;let t=r.length;if(t<5||t>317)return!1;let f=-1;for(let e=t-1;e>=0;e--)if(r.charCodeAt(e)===46){f=e;break}if(f===-1)return!1;let s=0,l=0;for(let e=0;e<=f;e++)if(e===f||r.charCodeAt(e)===46){let i=e-s;if(i===0||i>63)return!1;let A=r.charCodeAt(s);if(l===0){if(!h(A))return!1}else if(!a(A))return!1;if(i>1){if(!a(r.charCodeAt(e-1)))return!1;for(let n=s+1;n<e-1;n++){let d=r.charCodeAt(n);if(!a(d)&&d!==45)return!1}}s=e+1,l++}if(l<2)return!1;let o=f+1,c=t-o;if(c===0||c>63||!h(r.charCodeAt(o)))return!1;for(let e=o+1;e<t;e++)if(!a(r.charCodeAt(e)))return!1;return!0};export{C as isNsid}; 3 + //# sourceMappingURL=./nsid.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/nsid.mjs.map
··· 1 + {"mappings":";AAAA,OAAS,gBAAAA,EAAc,mBAAAC,MAAuB,oBAQvC,IAAMC,EAAUC,GAAiC,CACvD,GAAI,OAAOA,GAAU,SACpB,MAAO,GAGR,IAAMC,EAAMD,EAAM,OAClB,GAAIC,EAAM,GAAKA,EAAM,IACpB,MAAO,GAIR,IAAIC,EAAU,GACd,QAASC,EAAIF,EAAM,EAAGE,GAAK,EAAGA,IAC7B,GAAIH,EAAM,WAAWG,CAAC,IAAM,GAAM,CACjCD,EAAUC,EACV,KACD,CAED,GAAID,IAAY,GACf,MAAO,GAIR,IAAIE,EAAW,EACXC,EAAS,EACb,QAASC,EAAI,EAAGA,GAAKJ,EAASI,IAC7B,GAAIA,IAAMJ,GAAWF,EAAM,WAAWM,CAAC,IAAM,GAAM,CAClD,IAAMC,EAASD,EAAIF,EACnB,GAAIG,IAAW,GAAKA,EAAS,GAC5B,MAAO,GAGR,IAAMC,EAAQR,EAAM,WAAWI,CAAQ,EACvC,GAAIC,IAAW,GAEd,GAAI,CAACR,EAAaW,CAAK,EACtB,MAAO,WAIJ,CAACV,EAAgBU,CAAK,EACzB,MAAO,GAIT,GAAID,EAAS,EAAG,CACf,GAAI,CAACT,EAAgBE,EAAM,WAAWM,EAAI,CAAC,CAAC,EAC3C,MAAO,GAER,QAASH,EAAIC,EAAW,EAAGD,EAAIG,EAAI,EAAGH,IAAK,CAC1C,IAAMM,EAAIT,EAAM,WAAWG,CAAC,EAC5B,GAAI,CAACL,EAAgBW,CAAC,GAAKA,IAAM,GAChC,MAAO,EAET,CACD,CAEAL,EAAWE,EAAI,EACfD,GACD,CAID,GAAIA,EAAS,EACZ,MAAO,GAIR,IAAMK,EAAYR,EAAU,EACtBS,EAAUV,EAAMS,EAKtB,GAJIC,IAAY,GAAKA,EAAU,IAI3B,CAACd,EAAaG,EAAM,WAAWU,CAAS,CAAC,EAC5C,MAAO,GAER,QAASP,EAAIO,EAAY,EAAGP,EAAIF,EAAKE,IACpC,GAAI,CAACL,EAAgBE,EAAM,WAAWG,CAAC,CAAC,EACvC,MAAO,GAIT,MAAO,EACR","names":["isAsciiAlpha","isAsciiAlphaNum","isNsid","input","len","lastDot","j","segStart","segIdx","i","segLen","first","c","nameStart","nameLen"],"sources":["../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/nsid.ts"],"sourcesContent":["import { isAsciiAlpha, isAsciiAlphaNum } from './utils/ascii.ts';\n\n/**\n * represents a namespace identifier (NSID)\n */\nexport type Nsid = `${string}.${string}.${string}`;\n\n// #__NO_SIDE_EFFECTS__\nexport const isNsid = (input: unknown): input is Nsid =\u003e {\n\tif (typeof input !== 'string') {\n\t\treturn false;\n\t}\n\n\tconst len = input.length;\n\tif (len \u003c 5 || len \u003e 317) {\n\t\treturn false;\n\t}\n\n\t// find the last dot to separate domain labels from the name segment\n\tlet lastDot = -1;\n\tfor (let j = len - 1; j \u003e= 0; j--) {\n\t\tif (input.charCodeAt(j) === 0x2e) {\n\t\t\tlastDot = j;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (lastDot === -1) {\n\t\treturn false;\n\t}\n\n\t// validate domain segments (before lastDot)\n\tlet segStart = 0;\n\tlet segIdx = 0;\n\tfor (let i = 0; i \u003c= lastDot; i++) {\n\t\tif (i === lastDot || input.charCodeAt(i) === 0x2e) {\n\t\t\tconst segLen = i - segStart;\n\t\t\tif (segLen === 0 || segLen \u003e 63) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst first = input.charCodeAt(segStart);\n\t\t\tif (segIdx === 0) {\n\t\t\t\t// first domain label must start with a letter\n\t\t\t\tif (!isAsciiAlpha(first)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// subsequent domain labels start with alphanumeric\n\t\t\t\tif (!isAsciiAlphaNum(first)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (segLen \u003e 1) {\n\t\t\t\tif (!isAsciiAlphaNum(input.charCodeAt(i - 1))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tfor (let j = segStart + 1; j \u003c i - 1; j++) {\n\t\t\t\t\tconst c = input.charCodeAt(j);\n\t\t\t\t\tif (!isAsciiAlphaNum(c) \u0026\u0026 c !== 0x2d) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tsegStart = i + 1;\n\t\t\tsegIdx++;\n\t\t}\n\t}\n\n\t// need at least 2 domain segments\n\tif (segIdx \u003c 2) {\n\t\treturn false;\n\t}\n\n\t// name segment (after lastDot): starts with letter, rest alphanumeric, max 63\n\tconst nameStart = lastDot + 1;\n\tconst nameLen = len - nameStart;\n\tif (nameLen === 0 || nameLen \u003e 63) {\n\t\treturn false;\n\t}\n\n\tif (!isAsciiAlpha(input.charCodeAt(nameStart))) {\n\t\treturn false;\n\t}\n\tfor (let j = nameStart + 1; j \u003c len; j++) {\n\t\tif (!isAsciiAlphaNum(input.charCodeAt(j))) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/record-key.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/dist/syntax/record-key */ 2 + import{isAsciiAlphaNum as o}from"./utils/ascii.mjs";var a=r=>{if(typeof r!="string")return!1;let t=r.length;if(t<1||t>512||t<=2&&r.charCodeAt(0)===46&&(t===1||r.charCodeAt(1)===46))return!1;for(let f=0;f<t;f++){let e=r.charCodeAt(f);if(!o(e)&&e!==95&&e!==126&&e!==46&&e!==58&&e!==45)return!1}return!0};export{a as isRecordKey}; 3 + //# sourceMappingURL=./record-key.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/record-key.mjs.map
··· 1 + {"mappings":";AAAA,OAAS,mBAAAA,MAAuB,oBAQzB,IAAMC,EAAeC,GAAsC,CACjE,GAAI,OAAOA,GAAU,SACpB,MAAO,GAGR,IAAMC,EAAMD,EAAM,OAMlB,GALIC,EAAM,GAAKA,EAAM,KAKjBA,GAAO,GAAKD,EAAM,WAAW,CAAC,IAAM,KAASC,IAAQ,GAAKD,EAAM,WAAW,CAAC,IAAM,IACrF,MAAO,GAGR,QAASE,EAAI,EAAGA,EAAID,EAAKC,IAAK,CAC7B,IAAMC,EAAIH,EAAM,WAAWE,CAAC,EAE5B,GACC,CAACJ,EAAgBK,CAAC,GAClBA,IAAM,IACNA,IAAM,KACNA,IAAM,IACNA,IAAM,IACNA,IAAM,GAEN,MAAO,EAET,CAEA,MAAO,EACR","names":["isAsciiAlphaNum","isRecordKey","input","len","i","c"],"sources":["../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/record-key.ts"],"sourcesContent":["import { isAsciiAlphaNum } from './utils/ascii.ts';\n\n/**\n * represents a record key\n */\nexport type RecordKey = string;\n\n// #__NO_SIDE_EFFECTS__\nexport const isRecordKey = (input: unknown): input is RecordKey =\u003e {\n\tif (typeof input !== 'string') {\n\t\treturn false;\n\t}\n\n\tconst len = input.length;\n\tif (len \u003c 1 || len \u003e 512) {\n\t\treturn false;\n\t}\n\n\t// reject \".\" and \"..\"\n\tif (len \u003c= 2 \u0026\u0026 input.charCodeAt(0) === 0x2e \u0026\u0026 (len === 1 || input.charCodeAt(1) === 0x2e)) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i \u003c len; i++) {\n\t\tconst c = input.charCodeAt(i);\n\t\t// [a-zA-Z0-9_~.:-]\n\t\tif (\n\t\t\t!isAsciiAlphaNum(c) \u0026\u0026\n\t\t\tc !== 0x5f \u0026\u0026 // _\n\t\t\tc !== 0x7e \u0026\u0026 // ~\n\t\t\tc !== 0x2e \u0026\u0026 // .\n\t\t\tc !== 0x3a \u0026\u0026 // :\n\t\t\tc !== 0x2d // -\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/utils/ascii.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/dist/syntax/utils/ascii */ 2 + var i=x=>x>=65&&x<=90||x>=97&&x<=122,r=x=>i(x)||x>=48&&x<=57;export{i as isAsciiAlpha,r as isAsciiAlphaNum}; 3 + //# sourceMappingURL=./ascii.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/syntax/utils/ascii.mjs.map
··· 1 + {"mappings":";AACO,IAAMA,EAAgBC,GACpBA,GAAK,IAAQA,GAAK,IAAUA,GAAK,IAAQA,GAAK,IAI1CC,EAAmBD,GACxBD,EAAaC,CAAC,GAAMA,GAAK,IAAQA,GAAK","names":["isAsciiAlpha","c","isAsciiAlphaNum"],"sources":["../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/utils/ascii.ts"],"sourcesContent":["// #__NO_SIDE_EFFECTS__\nexport const isAsciiAlpha = (c: number): boolean =\u003e {\n\treturn (c \u003e= 0x41 \u0026\u0026 c \u003c= 0x5a) || (c \u003e= 0x61 \u0026\u0026 c \u003c= 0x7a);\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const isAsciiAlphaNum = (c: number): boolean =\u003e {\n\treturn isAsciiAlpha(c) || (c \u003e= 0x30 \u0026\u0026 c \u003c= 0x39);\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/utils.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/dist/utils */ 2 + var e=!1;var t=(r,o)=>{if(!r)throw e?new Error("Assertion failed"+(o?`: ${o}`:"")):new Error("Assertion failed")},f=(r,o)=>{t(!1,o)};export{t as assert,f as assertNever}; 3 + //# sourceMappingURL=./utils.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/dist/utils.mjs.map
··· 1 + {"mappings":";AAAA,IAA2CA,EAAE,GCItC,IAAMC,EAAoE,CAACC,EAAWC,IAAW,CACvG,GAAI,CAACD,EACJ,MAAIE,EACG,IAAI,MAAM,oBAAsBD,EAAU,KAAKA,CAAO,GAAK,GAAG,EAG/D,IAAI,MAAM,kBAAkB,CAEpC,EAEaE,EAAc,CAACC,EAAUH,IAA2B,CAChEF,EAAO,GAAOE,CAAO,CACtB","names":["o","assert","condition","message","o","assertNever","_"],"sources":["npm-replacement:esm-env","../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/utils.ts"],"sourcesContent":["const e=typeof window\u003c\"u\"\u0026\u0026typeof Deno\u003e\"u\",o=!1,n=!1;export{e as BROWSER,o as DEV,n as NODE};\n","import { DEV } from 'esm-env';\n\nexport type Result\u003cT, E\u003e = { ok: true; value: T } | { ok: false; error: E };\n\nexport const assert: { (condition: any, message?: string): asserts condition } = (condition, message) =\u003e {\n\tif (!condition) {\n\t\tif (DEV) {\n\t\t\tthrow new Error(`Assertion failed` + (message ? `: ${message}` : ``));\n\t\t}\n\n\t\tthrow new Error(`Assertion failed`);\n\t}\n};\n\nexport const assertNever = (_: never, message?: string): never =\u003e {\n\tassert(false, message);\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/interfaces.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/interfaces */ 2 + import{isCid as r}from"./dist/syntax/cid.mjs";var i=Symbol.for("@atcute/cid-link-wrapper");var o=t=>{let e=t;return typeof e=="object"&&e!==null&&(i in e||r(e.$link))};var n=t=>{let e=t;return typeof e=="object"&&e!==null&&e.$type==="blob"&&typeof e.mimeType=="string"&&Number.isSafeInteger(e.size)&&o(e.ref)&&Object.keys(e).length===4},s=t=>{let e=t;return typeof e=="object"&&e!==null&&typeof e.cid=="string"&&typeof e.mimeType=="string"&&Object.keys(e).length===2};import{isBytes as g}from"./dist/interfaces/bytes.mjs";export{n as isBlob,g as isBytes,o as isCidLink,s as isLegacyBlob}; 3 + //# sourceMappingURL=./interfaces.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/interfaces.mjs.map
··· 1 + {"mappings":";AAAA,OAAS,SAAAA,MAAuB,wBAShC,IAAMC,EAAkB,OAAO,IAAI,0BAA0B,EAsBtD,IAAMC,EAAaC,GAAoC,CAC7D,IAAMC,EAAID,EAEV,OAAO,OAAOC,GAAM,UAAYA,IAAM,OAASC,KAAmBD,GAAKE,EAAMF,EAAE,KAAK,EACrF,ECrBO,IAAMG,EAAUC,GAAiC,CACvD,IAAMC,EAAID,EAEV,OACC,OAAOC,GAAM,UACbA,IAAM,MACNA,EAAE,QAAU,QACZ,OAAOA,EAAE,UAAa,UACtB,OAAO,cAAcA,EAAE,IAAI,GAC3BC,EAAUD,EAAE,GAAG,GACf,OAAO,KAAKA,CAAC,EAAE,SAAW,CAE5B,EAUaE,EAAgBH,GAAuC,CACnE,IAAMC,EAAID,EAEV,OACC,OAAOC,GAAM,UACbA,IAAM,MACN,OAAOA,EAAE,KAAQ,UACjB,OAAOA,EAAE,UAAa,UACtB,OAAO,KAAKA,CAAC,EAAE,SAAW,CAE5B,EC7CA,OAAS,WAAAG,MAA2B","names":["isCid","CID_LINK_SYMBOL","isCidLink","input","v","CID_LINK_SYMBOL","isCid","isBlob","input","v","isCidLink","isLegacyBlob","isBytes"],"sources":["../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/interfaces/cid-link.ts","../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/interfaces/blob.ts","../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/interfaces/index.ts"],"sourcesContent":["import { isCid, type Cid } from '../syntax/cid.ts';\n\n/**\n * represents a content identifier (CID) reference\n */\nexport interface CidLink {\n\t$link: Cid;\n}\n\nconst CID_LINK_SYMBOL = Symbol.for('@atcute/cid-link-wrapper');\n\n/**\n * this should match with {@link file://./../../../../utilities/cid/lib/cid-link.ts}\n * @internal\n */\nexport interface _CidLinkWrapper {\n\treadonly [CID_LINK_SYMBOL]: true;\n\n\treadonly bytes: Uint8Array;\n\treadonly $link: string;\n\n\ttoJSON(): CidLink;\n}\n\n/**\n * @internal\n */\nexport const _isCidLinkWrapper = (input: unknown): input is _CidLinkWrapper =\u003e {\n\treturn typeof input === 'object' \u0026\u0026 input !== null \u0026\u0026 CID_LINK_SYMBOL in input;\n};\n\nexport const isCidLink = (input: unknown): input is CidLink =\u003e {\n\tconst v = input as any;\n\n\treturn typeof v === 'object' \u0026\u0026 v !== null \u0026\u0026 (CID_LINK_SYMBOL in v || isCid(v.$link));\n};\n","import type { Cid } from '../syntax/cid.ts';\n\nimport { isCidLink, type CidLink } from './cid-link.ts';\n\n/**\n * represents a reference to a data blob\n */\nexport interface Blob\u003cTMime extends string = string\u003e {\n\t$type: 'blob';\n\tmimeType: TMime;\n\tref: CidLink;\n\tsize: number;\n}\n\nexport const isBlob = (input: unknown): input is Blob =\u003e {\n\tconst v = input as any;\n\n\treturn (\n\t\ttypeof v === 'object' \u0026\u0026\n\t\tv !== null \u0026\u0026\n\t\tv.$type === 'blob' \u0026\u0026\n\t\ttypeof v.mimeType === 'string' \u0026\u0026\n\t\tNumber.isSafeInteger(v.size) \u0026\u0026\n\t\tisCidLink(v.ref) \u0026\u0026\n\t\tObject.keys(v).length === 4\n\t);\n};\n\n/**\n * deprecated interface representing an interface to a data blob\n */\nexport interface LegacyBlob\u003cTMime extends string = string\u003e {\n\tcid: Cid;\n\tmimeType: TMime;\n}\n\nexport const isLegacyBlob = (input: unknown): input is LegacyBlob =\u003e {\n\tconst v = input as any;\n\n\treturn (\n\t\ttypeof v === 'object' \u0026\u0026\n\t\tv !== null \u0026\u0026\n\t\ttypeof v.cid === 'string' \u0026\u0026\n\t\ttypeof v.mimeType === 'string' \u0026\u0026\n\t\tObject.keys(v).length === 2\n\t);\n};\n","export { isBlob, isLegacyBlob, type Blob, type LegacyBlob } from './blob.ts';\nexport { isBytes, type Bytes } from './bytes.ts';\nexport { isCidLink, type CidLink } from './cid-link.ts';\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/syntax.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/syntax */ 2 + export*from"./dist/syntax/at-identifier.mjs";export*from"./dist/syntax/at-uri.mjs";export*from"./dist/syntax/cid.mjs";var t=/^((?!0{3})\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]))T((?:[01]\d|2[0-3]):(?:[0-5]\d):(?:[0-5]\d))(\.\d+)?(Z|(?!-00:00)[+-](?:[01]\d|2[0-3]):(?:[0-5]\d))$/,i=e=>typeof e=="string"&&e.length>=20&&e.length<=64&&t.test(e);export*from"./dist/syntax/did.mjs";export*from"./dist/syntax/handle.mjs";var o=/^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-(?<extension>[0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(?<privateUseA>x(-[A-Za-z0-9]{1,8})+))?)|(?<privateUseB>x(-[A-Za-z0-9]{1,8})+))$/,g=e=>typeof e=="string"&&e.length>=2&&o.test(e);export*from"./dist/syntax/nsid.mjs";export*from"./dist/syntax/record-key.mjs";var r=/^[234567abcdefghij][234567abcdefghijklmnopqrstuvwxyz]{12}$/,x=e=>typeof e=="string"&&e.length===13&&r.test(e);import{isUtf8LengthInRange as n}from"../../uint8array@1.1.1/es2022/uint8array.mjs";var a=/^\w+:(?:\/\/)?[^\s/][^\s]*$/,h=e=>typeof e!="string"||!n(e,3,8192)?!1:a.test(e);export{i as isDatetime,h as isGenericUri,g as isLanguageCode,x as isTid}; 3 + //# sourceMappingURL=./syntax.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/syntax.mjs.map
··· 1 + {"mappings":";AAAA,WAAc,kCACd,WAAc,2BACd,WAAc,wBCAd,IAAMA,EACL,iKAGYC,EAAcC,GACnB,OAAOA,GAAU,UAAYA,EAAM,QAAU,IAAMA,EAAM,QAAU,IAAMF,EAAa,KAAKE,CAAK,EDHxG,WAAc,wBACd,WAAc,2BEHd,IAAMC,EACL,olBAGYC,EAAkBC,GACvB,OAAOA,GAAU,UAAYA,EAAM,QAAU,GAAKF,EAAiB,KAAKE,CAAK,EFArF,WAAc,yBACd,WAAc,+BGHd,IAAMC,EAAS,6DAGFC,EAASC,GACd,OAAOA,GAAU,UAAYA,EAAM,SAAW,IAAMF,EAAO,KAAKE,CAAK,ECT7E,OAAS,uBAAAC,MAA2B,2CAOpC,IAAMC,EAAS,8BAGFC,EAAgBC,GACxB,OAAOA,GAAU,UAIjB,CAACH,EAAoBG,EAAO,EAAG,IAAI,EAC/B,GAGDF,EAAO,KAAKE,CAAK","names":["DATE_TIME_RE","isDatetime","input","LANGUAGE_CODE_RE","isLanguageCode","input","TID_RE","isTid","input","isUtf8LengthInRange","URI_RE","isGenericUri","input"],"sources":["../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/index.ts","../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/datetime.ts","../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/language.ts","../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/tid.ts","../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/syntax/uri.ts"],"sourcesContent":["export * from './at-identifier.ts';\nexport * from './at-uri.ts';\nexport * from './cid.ts';\nexport * from './datetime.ts';\nexport * from './did.ts';\nexport * from './handle.ts';\nexport * from './language.ts';\nexport * from './nsid.ts';\nexport * from './record-key.ts';\nexport * from './tid.ts';\nexport * from './uri.ts';\n","export type Datetime = string;\n\nconst DATE_TIME_RE =\n\t/^((?!0{3})\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\\d|3[01]))T((?:[01]\\d|2[0-3]):(?:[0-5]\\d):(?:[0-5]\\d))(\\.\\d+)?(Z|(?!-00:00)[+-](?:[01]\\d|2[0-3]):(?:[0-5]\\d))$/;\n\n// #__NO_SIDE_EFFECTS__\nexport const isDatetime = (input: unknown): input is Datetime =\u003e {\n\treturn typeof input === 'string' \u0026\u0026 input.length \u003e= 20 \u0026\u0026 input.length \u003c= 64 \u0026\u0026 DATE_TIME_RE.test(input);\n};\n","export type LanguageCode = string;\n\nconst LANGUAGE_CODE_RE =\n\t/^((?\u003cgrandfathered\u003e(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?\u003clanguage\u003e([A-Za-z]{2,3}(-(?\u003cextlang\u003e[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?\u003cscript\u003e[A-Za-z]{4}))?(-(?\u003cregion\u003e[A-Za-z]{2}|[0-9]{3}))?(-(?\u003cvariant\u003e[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-(?\u003cextension\u003e[0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(?\u003cprivateUseA\u003ex(-[A-Za-z0-9]{1,8})+))?)|(?\u003cprivateUseB\u003ex(-[A-Za-z0-9]{1,8})+))$/;\n\n// #__NO_SIDE_EFFECTS__\nexport const isLanguageCode = (input: unknown): input is LanguageCode =\u003e {\n\treturn typeof input === 'string' \u0026\u0026 input.length \u003e= 2 \u0026\u0026 LANGUAGE_CODE_RE.test(input);\n};\n","/**\n * represents a timestamp identifier (TID)\n */\nexport type Tid = string;\n\nconst TID_RE = /^[234567abcdefghij][234567abcdefghijklmnopqrstuvwxyz]{12}$/;\n\n// #__NO_SIDE_EFFECTS__\nexport const isTid = (input: unknown): input is Tid =\u003e {\n\treturn typeof input === 'string' \u0026\u0026 input.length === 13 \u0026\u0026 TID_RE.test(input);\n};\n","import { isUtf8LengthInRange } from '@atcute/uint8array';\n\n/**\n * represents a generic URI\n */\nexport type GenericUri = `${string}:${string}`;\n\nconst URI_RE = /^\\w+:(?:\\/\\/)?[^\\s/][^\\s]*$/;\n\n// #__NO_SIDE_EFFECTS__\nexport const isGenericUri = (input: unknown): input is GenericUri =\u003e {\n\tif (typeof input !== 'string') {\n\t\treturn false;\n\t}\n\n\tif (!isUtf8LengthInRange(input, 3, 8192)) {\n\t\treturn false;\n\t}\n\n\treturn URI_RE.test(input);\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/validations.mjs
··· 1 + /* esm.sh - @atcute/lexicons@1.2.10/validations */ 2 + import{isUtf8LengthInRange as J}from"../../uint8array@1.1.1/es2022/uint8array.mjs";import{isGraphemeLengthInRange as X}from"../../util-text@1.2.0/es2022/util-text.mjs";import{_isBytesWrapper as q}from"./dist/interfaces/bytes.mjs";import*as $ from"./interfaces.mjs";import*as l from"./syntax.mjs";import{assert as I}from"./dist/utils.mjs";var u=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),v=e=>({get value(){let t=e();return u(this,"value",t)}}),A=Array.isArray,E=e=>typeof e=="object"&&e!==null&&!A(e),R=v(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});var G=!1,S=(e,t)=>e?{ok:!1,code:"join",left:e,right:t}:t,k=(e,t)=>({ok:!1,code:"prepend",key:e,tree:t}),b=e=>({ok:!0,value:e}),O=0,_=1,Q=(e,t)=>{let{ok:n,msg:r,...s}=e;return{...s,path:t}},C=(e,t=[],n=[])=>{for(;;)switch(e.code){case"join":{C(e.left,t.slice(),n),e=e.right;continue}case"prepend":{t.push(e.key),e=e.tree;continue}default:return n.push(Q(e,t)),n}},M=e=>{let t=0;for(;;)switch(e.code){case"join":{t+=M(e.left),e=e.right;continue}case"prepend":{e=e.tree;continue}default:return t+1}},z=(e,t)=>{switch(e.length){case 0:return"nothing";case 1:return e[0];default:return`${e.slice(0,-1).join(", ")} ${t} ${e[e.length-1]}`}},D=e=>JSON.stringify(e),T=(e,t,n,r)=>{let s=`expected ${e} `;return n>0?r===n?s+=`${n}`:r!==1/0?s+=`between ${n} and ${r}`:s+=`at least ${n}`:s+=`at most ${r}`,s+=` ${t}(s)`,s},H=e=>{let t="",n=0;for(;;){switch(e.code){case"join":{n+=M(e.right),e=e.left;continue}case"prepend":{t+=`.${e.key}`,e=e.tree;continue}}break}let r=e.msg(),s=`${e.code} at ${t||"."} (${r})`;return n>0&&(s+=` (+${n} other issue(s))`),s},w=class extends Error{name="ValidationError";#e;constructor(t){super(),this.#e=t}get message(){return H(this.#e)}get issues(){return C(this.#e)}},N=class{ok=!1;#e;constructor(t){this.#e=t}get message(){return H(this.#e)}get issues(){return C(this.#e)}throw(){throw new w(this.#e)}},_e=(e,t)=>{let n=e["~run"](t,_);return n===void 0||n.ok},ke=(e,t)=>{let n=e["~run"](t,O);return n===void 0?b(t):n.ok?n:new N(n)},be=(e,t)=>{let n=e["~run"](t,O);if(n===void 0)return t;if(n.ok)return n.value;throw new w(n)},F=(e,t=[],n=[])=>{for(;;)switch(e.code){case"join":{F(e.left,t.slice(),n),e=e.right;continue}case"prepend":{t.push(e.key),e=e.tree;continue}default:return n.push({message:e.msg(),path:t.length>0?t:void 0}),n}},p=e=>({version:1,vendor:"@atcute/lexicons",validate(t){let n=e["~run"](t,O);return n===void 0?{value:t}:n.ok?{value:n.value}:{issues:F(n)}}}),ve=(e,t)=>{let n=t.length;return{...e,constraints:t,"~run"(r,s){let c=e["~run"](r,s),i;if(c===void 0)i=r;else if(c.ok)i=c.value;else return c;for(let o=0;o<n;o++){let a=t[o]["~run"](i,s);if(a!==void 0)if(a.ok)i=a.value,(c===void 0||c.ok)&&(c=a);else{if(s&_)return a;c===void 0||c.ok?c=a:c=S(c,a)}}return c}}},Se=e=>{let t={ok:!1,code:"invalid_literal",expected:[e],msg(){return`expected ${D(e)}`}};return{kind:"schema",type:"literal",expected:e,"~run"(n,r){if(n!==e)return t},get"~standard"(){return u(this,"~standard",p(this))}}},Ee=e=>{let t={ok:!1,code:"invalid_literal",expected:e,msg(){return`expected ${z(e.map(D),"or")}`}};return{kind:"schema",type:"literal_enum",expected:e,"~run"(n,r){if(!e.includes(n))return t},get"~standard"(){return u(this,"~standard",p(this))}}},Z={ok:!1,code:"invalid_type",expected:"boolean",msg(){return"expected boolean"}},V={kind:"schema",type:"boolean","~run"(e,t){if(typeof e!="boolean")return Z},get"~standard"(){return u(this,"~standard",p(this))}},Ie=()=>V,B={ok:!1,code:"invalid_type",expected:"integer",msg(){return"expected integer"}},ee={kind:"schema",type:"integer","~run"(e,t){if(typeof e!="number"||e<0||!Number.isSafeInteger(e))return B},get"~standard"(){return u(this,"~standard",p(this))}},we=()=>ee,Te=(e,t=1/0)=>{let n={ok:!1,code:"invalid_integer_range",min:e,max:t,msg(){let r="expected an integer ";return e>0?t===e?r+=`of exactly ${e}`:t!==1/0?r+=`between ${e} and ${t}`:r+=`of at least ${e}`:r+=`of at most ${t}`,r}};return{kind:"constraint",type:"integer_range",min:e,max:t,"~run"(r,s){if(r<e||r>t)return n}}},U={ok:!1,code:"invalid_type",expected:"string",msg(){return"expected string"}},te={kind:"schema",type:"string",format:null,"~run"(e,t){if(typeof e!="string")return U},get"~standard"(){return u(this,"~standard",p(this))}},je=()=>te,m=(e,t)=>{let n={ok:!1,code:"invalid_string_format",expected:e,msg(){return`expected a ${e} formatted string`}},r={kind:"schema",type:"string",format:e,"~run"(s,c){if(typeof s!="string")return U;if(!t(s))return n},get"~standard"(){return u(this,"~standard",p(this))}};return()=>r},Ae=m("at-identifier",l.isActorIdentifier),Ne=m("at-uri",l.isResourceUri),Pe=m("cid",l.isCid),Oe=m("datetime",l.isDatetime),Ce=m("did",l.isDid),Ue=m("handle",l.isHandle),Le=m("language",l.isLanguageCode),Re=m("nsid",l.isNsid),Be=m("record-key",l.isRecordKey),Ye=m("tid",l.isTid),Ge=m("uri",l.isGenericUri),Me=(e,t=1/0)=>{let n={ok:!1,code:"invalid_string_length",minLength:e,maxLength:t,msg(){return T("a string","character",e,t)}};return{kind:"constraint",type:"string_length",minLength:e,maxLength:t,"~run"(r,s){if(!J(r,e,t))return n}}},ze=(e,t=1/0)=>{let n={ok:!1,code:"invalid_string_graphemes",minGraphemes:e,maxGraphemes:t,msg(){return T("a string","grapheme",e,t)}};return{kind:"constraint",type:"string_graphemes",minGraphemes:e,maxGraphemes:t,"~run"(r,s){if(!X(r,e,t))return n}}},Y={ok:!1,code:"invalid_type",expected:"blob",msg(){return"expected blob"}},ne={kind:"schema",type:"blob","~run"(e,t){if(typeof e!="object"||e===null)return Y;if(!$.isBlob(e)){if($.isLegacyBlob(e)){let n={$type:"blob",mimeType:e.mimeType,ref:{$link:e.cid},size:-1};return b(n)}return Y}},get"~standard"(){return u(this,"~standard",p(this))}},De=()=>ne,re={ok:!1,code:"invalid_type",expected:"bytes",msg(){return"expected bytes"}},se={kind:"schema",type:"bytes","~run"(e,t){if(!$.isBytes(e))return re},get"~standard"(){return u(this,"~standard",p(this))}},He=()=>se,Fe=(e,t=1/0)=>{let n={ok:!1,code:"invalid_bytes_size",minSize:e,maxSize:t,msg(){return T("a byte array","byte",e,t)}};return{kind:"constraint",type:"bytes_size",minSize:e,maxSize:t,"~run"(r,s){let c;if(q(r))c=r.buf.length;else{let i=r.$bytes,o=i.length;i.charCodeAt(o-1)===61&&o--,o>1&&i.charCodeAt(o-1)===61&&o--,c=o*3>>>2}if(c<e||c>t)return n}}},ie={ok:!1,code:"invalid_type",expected:"cid-link",msg(){return"expected cid-link"}},oe={kind:"schema",type:"cid_link","~run"(e,t){if(!$.isCidLink(e))return ie},get"~standard"(){return u(this,"~standard",p(this))}},Ke=()=>oe,We=e=>({kind:"schema",type:"nullable",wrapped:e,"~run"(t,n){if(t!==null)return e["~run"](t,n)},get"~standard"(){return u(this,"~standard",p(this))}}),Je=(e,t)=>({kind:"schema",type:"optional",wrapped:e,default:t,"~run"(n,r){if(n===void 0){if(t===void 0)return;let s=typeof t=="function"?t():t;return b(s)}return e["~run"](n,r)},get"~standard"(){return u(this,"~standard",p(this))}}),ae=e=>e.type==="optional",ue={ok:!1,code:"invalid_type",expected:"array",msg(){return"expected array"}},Xe=e=>{let t=v(()=>typeof e=="function"?e():e);return{kind:"schema",type:"array",get item(){return u(this,"item",t.value)},get"~run"(){let n=t.value;return u(this,"~run",(s,c)=>{if(!A(s))return ue;let i,o;for(let a=0,d=s.length;a<d;a++){let g=s[a],f=n["~run"](g,c);if(f!==void 0){if(f.ok)o===void 0&&(o=s.slice()),o[a]=f.value;else if(i=S(i,k(a,f)),c&_)return i}}if(i!==void 0)return i;if(o!==void 0)return b(o)})},get"~standard"(){return u(this,"~standard",p(this))}}},qe=(e,t=1/0)=>{let n={ok:!1,code:"invalid_array_length",minLength:e,maxLength:t,msg(){return T("an array","item",e,t)}};return{kind:"constraint",type:"array_length",minLength:e,maxLength:t,"~run"(r,s){let c=r.length;if(c<e||c>t)return n}}},P={ok:!1,code:"invalid_type",expected:"object",msg(){return"expected object"}},K={ok:!1,code:"missing_value",msg(){return"missing value"}},ce=(e,t,n)=>{t==="__proto__"?Object.defineProperty(e,t,{value:n}):e[t]=n},Qe=e=>{let t=v(()=>{let n=[];for(let r in e){let s=e[r];n.push({key:r,schema:s,optional:ae(s),missing:k(r,K)})}return n});return{kind:"schema",type:"object",get shape(){let n=t.value,r={};for(let s of n)r[s.key]=s.schema;return u(this,"shape",r)},get"~run"(){let n=t.value,r=n.length,s=()=>{let i=[["$ok",b],["$joinIssues",S],["$prependPath",k]],o="let $iss,$out;";for(let d=0;d<r;d++){let g=n[d],f=g.key,h=JSON.stringify(f),y=`_${d}`;if(o+=`{const $val=$in[${h}];`,g.optional?o+="if($val!==undefined){":o+=`if($val!==undefined||${h} in $in){`,o+=`const $res=${y}$schema["~run"]($val,$flags);if($res!==undefined)if($res.ok)${f!=="__proto__"?`($out??={...$in})[${h}]=$res.value`:`Object.defineProperty($out??={...$in},${h},{value:$res.value})`};else if((($iss=$joinIssues($iss,$prependPath(${h},$res))),$flags&${_}))return $iss;}`,g.optional){let x=g.schema,W=x.wrapped,j=x.default;if(i.push([`${y}$schema`,W]),j!==void 0){let L=typeof j=="function"?`${y}$default()`:`${y}$default`;i.push([`${y}$default`,j]),o+=f!=="__proto__"?`else($out??={...$in})[${h}]=${L};`:`else Object.defineProperty($out??={...$in},${h},{value:${L}});`}}else i.push([`${y}$schema`,g.schema]),i.push([`${y}$missing`,g.missing]),o+=`else if((($iss=$joinIssues($iss,${y}$missing)),$flags&${_}))return $iss;`;o+="}"}return o+="if($iss!==undefined)return $iss;if($out!==undefined)return $ok($out);",new Function(`[${i.map(([d])=>d).join(",")}]`,`return function matcher($in,$flags){${o}}`)(i.map(([,d])=>d))};if(R.value){let i=s();return u(this,"~run",(a,d)=>E(a)?i(a,d):P)}return u(this,"~run",(i,o)=>{if(!E(i))return P;let a,d;for(let g=0;g<r;g++){let f=n[g],h=f.key,y=i[h];if(!f.optional&&y===void 0&&!(h in i)){if(a=S(a,f.missing),o&_)return a;continue}let x=f.schema["~run"](y,o);if(x!==void 0){if(x.ok)d===void 0&&(d={...i}),ce(d,h,x.value);else if(a=S(a,k(h,x)),o&_)return a}}if(a!==void 0)return a;if(d!==void 0)return b(d)})},get"~standard"(){return u(this,"~standard",p(this))}}},Ze=(e,t)=>{let n=v(()=>{let s=t.shape.$type;return I(s!==void 0,"expected $type in record to be defined"),s.type==="optional"&&(s=s.wrapped),I(s.type==="literal"&&typeof s.expected=="string","expected $type to be a string literal"),t});return{kind:"schema",type:"record",key:e,get object(){return u(this,"object",n.value)},"~run"(r,s){return u(this,"~run",n.value["~run"])(r,s)},get"~standard"(){return u(this,"~standard",p(this))}}},de=k("$type",K),le=k("$type",U),Ve=(e,t=!1)=>({kind:"schema",type:"variant",members:e,closed:t,get"~run"(){let n=[],r=[];for(let i=0,o=e.length;i<o;i++){let a=e[i],d=a.type==="record"?a.object:a,f=d.shape.$type;I(f!==void 0,`expected $type in variant member #${i} to be defined`),f.type==="optional"&&(f=f.wrapped),I(f.type==="literal"&&typeof f.expected=="string",`expected $type in variant member #${i} to be a string literal`),n.push(f.expected),r.push(d)}let s={ok:!1,code:"invalid_variant",expected:n,msg(){return`expected ${z(n,"or")}`}};return u(this,"~run",(i,o)=>{if(!E(i))return P;let a=i.$type;if(a===void 0&&!("$type"in i))return de;if(typeof a!="string")return t?s:le;for(let d=0,g=n.length;d<g;d++)if(n[d]===a)return r[d]["~run"](i,o);if(t)return s})},get"~standard"(){return u(this,"~standard",p(this))}}),fe={ok:!1,code:"invalid_type",expected:"unknown",msg(){return"expected unknown"}},pe={kind:"schema",type:"unknown","~run"(e,t){if(typeof e!="object"||e===null)return fe},get"~standard"(){return u(this,"~standard",p(this))}},et=()=>pe,tt=(e,t)=>(G=!0,{kind:"metadata",type:"xrpc_procedure",nsid:e,params:t.params,get input(){let n=t.input;return n?.type==="lex"&&(n={type:"lex",schema:n.schema}),u(this,"input",n)},get output(){let n=t.output;return n?.type==="lex"&&(n={type:"lex",schema:n.schema}),u(this,"output",n)}}),nt=(e,t)=>(G=!0,{kind:"metadata",type:"xrpc_query",nsid:e,params:t.params,get output(){let n=t.output;return n?.type==="lex"&&(n={type:"lex",schema:n.schema}),u(this,"output",n)}}),rt=(e,t)=>({kind:"metadata",type:"xrpc_subscription",nsid:e,params:t.params,get message(){return u(this,"message",t.message)}});export{_ as FLAG_ABORT_EARLY,O as FLAG_EMPTY,w as ValidationError,Ae as actorIdentifierString,Xe as array,qe as arrayLength,De as blob,Ie as boolean,He as bytes,Fe as bytesSize,Ke as cidLink,Pe as cidString,ve as constrain,Oe as datetimeString,Ce as didString,Ge as genericUriString,Ue as handleString,we as integer,Te as integerRange,_e as is,Le as languageCodeString,Se as literal,Ee as literalEnum,Re as nsidString,We as nullable,Qe as object,b as ok,Je as optional,be as parse,tt as procedure,nt as query,Ze as record,Be as recordKeyString,Ne as resourceUriString,ke as safeParse,je as string,ze as stringGraphemes,Me as stringLength,rt as subscription,Ye as tidString,et as unknown,Ve as variant,G as xrpcSchemaGenerated}; 3 + //# sourceMappingURL=./validations.mjs.map
+1
vendor/esm.sh/@atcute/lexicons@1.2.10/es2022/validations.mjs.map
··· 1 + {"mappings":";AAAA,OAAS,uBAAAA,MAA2B,2CACpC,OAAS,2BAAAC,MAA+B,0CAIxC,OAAS,mBAAAC,MAAuB,8BAChC,UAAYC,MAAgB,mBAC5B,UAAYC,MAAY,eAExB,OAAS,UAAAC,MAAc,mBCRhB,IAAMC,EAAe,CAAIC,EAAaC,EAAgCC,KAC5E,OAAO,eAAeF,EAAKC,EAAM,CAAE,MAAAC,CAAK,CAAE,EACnCA,GAIKC,EAAWC,IAChB,CACN,IAAI,OAAK,CACR,IAAMF,EAAQE,EAAM,EACpB,OAAOL,EAAa,KAAM,QAASG,CAAK,CACzC,IAIWG,EAAU,MAAM,QAGhBC,EAAYC,GACjB,OAAOA,GAAU,UAAYA,IAAU,MAAQ,CAACF,EAAQE,CAAK,EAGxDC,EAA2BL,EAAK,IAAc,CAC1D,GAAI,OAAO,UAAc,KAAe,WAAW,WAAW,SAAS,YAAY,EAClF,MAAO,GAGR,GAAI,CACH,IAAMM,EAAI,SAEV,WAAIA,EAAE,EAAE,EACD,EACR,MAAQ,CACP,MAAO,EACR,CACD,CAAC,EDjBM,IAAIC,EAAsB,GAuE3BC,EAAa,CAACC,EAA6BC,IACzCD,EAAO,CAAE,GAAI,GAAO,KAAM,OAAQ,KAAAA,EAAM,MAAAC,CAAK,EAAKA,EAIpDC,EAAc,CAACC,EAAUC,KACvB,CAAE,GAAI,GAAO,KAAM,UAAW,IAAAD,EAAK,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I,QAAM,CACT,IAAIA,EAAMwC,EAAQ,OAElB,OAAQxC,GAAK,OACP,QACJA,EAAM,CACL,KAAM,MACN,OAAQA,EAAI,SAMR/D,EAAa,KAAM,SAAU+D,CAAG,CACxC,IAkBWyC,GAAQ,CAKpBF,EACAC,KAOA9J,EAAsB,GAEf,CACN,KAAM,WACN,KAAM,aACN,KAAM6J,EACN,OAAQC,EAAQ,OAChB,IAAI,QAAM,CACT,IAAIxC,EAAMwC,EAAQ,OAElB,OAAQxC,GAAK,OACP,QACJA,EAAM,CACL,KAAM,MACN,OAAQA,EAAI,SAKR/D,EAAa,KAAM,SAAU+D,CAAG,CACxC,IAqBW0C,GAAe,CAK3BH,EACAC,KAOO,CACN,KAAM,WACN,KAAM,oBACN,KAAMD,EACN,OAAQC,EAAQ,OAChB,IAAI,SAAO,CACV,OAAOvG,EAAa,KAAM,UAAWuG,EAAQ,OAAO,CACrD","names":["isUtf8LengthInRange","isGraphemeLengthInRange","_isBytesWrapper","interfaces","syntax","assert","lazyProperty","obj","prop","value","lazy","getter","isArray","isObject","input","allowsEval","F","xrpcSchemaGenerated","joinIssues","left","right","prependPath","key","tree","ok","value","FLAG_EMPTY","FLAG_ABORT_EARLY","cloneIssueWithPath","issue","path","_ok","_fmt","clone","collectIssues","issues","countIssues","count","separatedList","list","sep","formatLiteral","formatRangeMessage","type","unit","min","max","message","formatIssueTree","msg","ValidationError","#issueTree","issueTree","ErrImpl","is","schema","input","r","safeParse","parse","collectStandardIssues","toStandardSchema","constrain","base","constraints","len","flags","result","current","idx","literal","_flags","lazyProperty","literalEnum","values","ISSUE_TYPE_BOOLEAN","BOOLEAN_SCHEMA","boolean","ISSUE_TYPE_INTEGER","INTEGER_SCHEMA","integer","integerRange","ISSUE_TYPE_STRING","STRING_SINGLETON","string","_formattedString","format","validate","actorIdentifierString","resourceUriString","cidString","datetimeString","didString","handleString","languageCodeString","nsidString","recordKeyString","tidString","genericUriString","stringLength","minLength","maxLength","isUtf8LengthInRange","stringGraphemes","minGraphemes","maxGraphemes","isGraphemeLengthInRange","ISSUE_EXPECTED_BLOB","BLOB_SCHEMA","blob","ISSUE_EXPECTED_BYTES","BYTES_SCHEMA","bytes","bytesSize","minSize","maxSize","size","_isBytesWrapper","str","ISSUE_EXPECTED_CID_LINK","CID_LINK_SCHEMA","cidLink","nullable","wrapped","optional","defaultValue","isOptionalSchema","ISSUE_TYPE_ARRAY","array","item","resolvedShape","lazy","shape","isArray","output","val","arrayLength","length","ISSUE_TYPE_OBJECT","ISSUE_MISSING","set","obj","object","resolvedEntries","resolved","entry","generateFastpass","fields","doc","esckey","id","innerSchema","calls","field","allowsEval","fastpass","isObject","record","validatedObject","t","assert","ISSUE_VARIANT_MISSING","ISSUE_VARIANT_TYPE","variant","members","closed","types","schemas","raw","member","ISSUE_TYPE_UNKNOWN","UNKNOWN_SCHEMA","unknown","procedure","nsid","options","query","subscription"],"sources":["../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/validations/index.ts","../esm/npm/@atcute/lexicons@1.2.10/node_modules/@atcute/lexicons/lib/validations/utils.ts"],"sourcesContent":["import { isUtf8LengthInRange } from '@atcute/uint8array';\nimport { isGraphemeLengthInRange } from '@atcute/util-text';\n\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\nimport { _isBytesWrapper } from '../interfaces/bytes.ts';\nimport * as interfaces from '../interfaces/index.ts';\nimport * as syntax from '../syntax/index.ts';\nimport type { $type } from '../types/brand.ts';\nimport { assert } from '../utils.ts';\n\nimport { allowsEval, isArray, isObject, lazy, lazyProperty } from './utils.ts';\n\n/**\n * flag indicating whether xrpc schema generation helpers are used. set to true\n * when query() or procedure() is called. this enables conditional tree-shaking\n * of validation code when schemas are not used.\n * @deprecated internal flag for tree-shaking, do not use directly\n */\nexport let xrpcSchemaGenerated = false;\n\ntype Identity\u003cT\u003e = T;\ntype Flatten\u003cT\u003e = Identity\u003c{ [K in keyof T]: T[K] }\u003e;\n\ntype InputType =\n\t| 'unknown'\n\t| 'null'\n\t| 'undefined'\n\t| 'string'\n\t| 'integer'\n\t| 'boolean'\n\t| 'blob'\n\t| 'bytes'\n\t| 'cid-link'\n\t| 'object'\n\t| 'array';\n\ntype StringFormatMap = {\n\t'at-identifier': syntax.ActorIdentifier;\n\t'at-uri': syntax.ResourceUri;\n\tcid: syntax.Cid;\n\tdatetime: syntax.Datetime;\n\tdid: syntax.Did;\n\thandle: syntax.Handle;\n\tlanguage: syntax.LanguageCode;\n\tnsid: syntax.Nsid;\n\t'record-key': syntax.RecordKey;\n\ttid: syntax.Tid;\n\turi: syntax.GenericUri;\n};\n\nexport type StringFormat = keyof StringFormatMap;\n\ntype Literal = string | number | boolean;\ntype Key = string | number;\n\ntype IssueFormatter = () =\u003e string;\n\n// #region Schema issue types\nexport type IssueLeaf = { ok: false; msg: IssueFormatter } \u0026 (\n\t| { code: 'missing_value' }\n\t| { code: 'invalid_literal'; expected: readonly Literal[] }\n\t| { code: 'invalid_type'; expected: InputType }\n\t| { code: 'invalid_variant'; expected: string[] }\n\t| { code: 'invalid_integer_range'; min: number; max: number }\n\t| { code: 'invalid_string_format'; expected: StringFormat }\n\t| { code: 'invalid_string_graphemes'; minGraphemes: number; maxGraphemes: number }\n\t| { code: 'invalid_string_length'; minLength: number; maxLength: number }\n\t| { code: 'invalid_array_length'; minLength: number; maxLength: number }\n\t| { code: 'invalid_bytes_size'; minSize: number; maxSize: number }\n);\n\nexport type IssueTree =\n\t| IssueLeaf\n\t| { ok: false; code: 'prepend'; key: Key; tree: IssueTree }\n\t| { ok: false; code: 'join'; left: IssueTree; right: IssueTree };\n\nexport type Issue =\n\t| { code: 'missing_value'; path: Key[] }\n\t| { code: 'invalid_literal'; path: Key[]; expected: readonly Literal[] }\n\t| { code: 'invalid_type'; path: Key[]; expected: InputType }\n\t| { code: 'invalid_variant'; path: Key[]; expected: string[] }\n\t| { code: 'invalid_integer_range'; path: Key[]; min: number; max: number }\n\t| { code: 'invalid_string_format'; path: Key[]; expected: StringFormat }\n\t| { code: 'invalid_string_graphemes'; path: Key[]; minGraphemes: number; maxGraphemes: number }\n\t| { code: 'invalid_string_length'; path: Key[]; minLength: number; maxLength: number }\n\t| { code: 'invalid_array_length'; path: Key[]; minLength: number; maxLength: number }\n\t| { code: 'invalid_bytes_size'; path: Key[]; minSize: number; maxSize: number };\n\n// #__NO_SIDE_EFFECTS__\nconst joinIssues = (left: IssueTree | undefined, right: IssueTree): IssueTree =\u003e {\n\treturn left ? { ok: false, code: 'join', left, right } : right;\n};\n\n// #__NO_SIDE_EFFECTS__\nconst prependPath = (key: Key, tree: IssueTree): IssueTree =\u003e {\n\treturn { ok: false, code: 'prepend', key, tree };\n};\n\n// #region Schema result types\n\nexport type Ok\u003cT\u003e = {\n\tok: true;\n\tvalue: T;\n};\nexport type Err = {\n\tok: false;\n\treadonly message: string;\n\treadonly issues: readonly Issue[];\n\tthrow(): never;\n};\n\nexport type ValidationResult\u003cT\u003e = Ok\u003cT\u003e | Err;\n\n// #__NO_SIDE_EFFECTS__\nexport const ok = \u003cT\u003e(value: T): Ok\u003cT\u003e =\u003e {\n\treturn { ok: true, value };\n};\n\n// #region Base schema\n\n// Private symbols meant to hold types\ndeclare const kType: unique symbol;\ntype kType = typeof kType;\n\n// None set\nexport const FLAG_EMPTY = 0;\n// Don't continue validation if an error is encountered\nexport const FLAG_ABORT_EARLY = 1 \u003c\u003c 0;\n\ntype MatcherResult = undefined | Ok\u003cunknown\u003e | IssueTree;\ntype Matcher = (input: unknown, flags: number) =\u003e MatcherResult;\n\ntype LexStandardSchemaResult\u003cT extends BaseSchema\u003e = StandardSchemaV1.Result\u003cInferOutput\u003cT\u003e\u003e;\n\ninterface LexStandardSchema\u003cT extends BaseSchema\u003e extends StandardSchemaV1.Props\u003cunknown\u003e {\n\treadonly validate: (value: unknown) =\u003e LexStandardSchemaResult\u003cT\u003e | Promise\u003cLexStandardSchemaResult\u003cT\u003e\u003e;\n\treadonly types?: StandardSchemaV1.Types\u003cInferInput\u003cT\u003e, InferOutput\u003cT\u003e\u003e;\n}\n\nexport interface BaseSchema\u003cTInput = unknown, TOutput = TInput\u003e {\n\treadonly kind: 'schema';\n\treadonly type: string;\n\treadonly '~run': Matcher;\n\treadonly '~standard': LexStandardSchema\u003cthis\u003e;\n\n\treadonly [kType]?: { in: TInput; out: TOutput };\n}\n\nexport type InferInput\u003cT extends BaseSchema\u003e = NonNullable\u003cT[kType]\u003e['in'];\n\nexport type InferOutput\u003cT extends BaseSchema\u003e = NonNullable\u003cT[kType]\u003e['out'];\n\n// #region Schema runner\nconst cloneIssueWithPath = (issue: IssueLeaf, path: Key[]): Issue =\u003e {\n\tconst { ok: _ok, msg: _fmt, ...clone } = issue;\n\n\treturn { ...clone, path };\n};\n\nconst collectIssues = (tree: IssueTree, path: Key[] = [], issues: Issue[] = []): Issue[] =\u003e {\n\tfor (;;) {\n\t\tswitch (tree.code) {\n\t\t\tcase 'join': {\n\t\t\t\tcollectIssues(tree.left, path.slice(), issues);\n\t\t\t\ttree = tree.right;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcase 'prepend': {\n\t\t\t\tpath.push(tree.key);\n\t\t\t\ttree = tree.tree;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tissues.push(cloneIssueWithPath(tree, path));\n\t\t\t\treturn issues;\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst countIssues = (tree: IssueTree): number =\u003e {\n\tlet count = 0;\n\tfor (;;) {\n\t\tswitch (tree.code) {\n\t\t\tcase 'join': {\n\t\t\t\tcount += countIssues(tree.left);\n\t\t\t\ttree = tree.right;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcase 'prepend': {\n\t\t\t\ttree = tree.tree;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn count + 1;\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst separatedList = (list: string[], sep: 'or' | 'and'): string =\u003e {\n\tswitch (list.length) {\n\t\tcase 0: {\n\t\t\treturn `nothing`;\n\t\t}\n\t\tcase 1: {\n\t\t\treturn list[0];\n\t\t}\n\t\tdefault: {\n\t\t\treturn `${list.slice(0, -1).join(', ')} ${sep} ${list[list.length - 1]}`;\n\t\t}\n\t}\n};\n\nconst formatLiteral = (value: Literal): string =\u003e {\n\treturn JSON.stringify(value);\n};\n\nconst formatRangeMessage = (\n\ttype: 'a string' | 'an array' | 'a byte array',\n\tunit: 'character' | 'grapheme' | 'item' | 'byte',\n\tmin: number,\n\tmax: number,\n): string =\u003e {\n\tlet message = `expected ${type} `;\n\n\tif (min \u003e 0) {\n\t\tif (max === min) {\n\t\t\tmessage += `${min}`;\n\t\t} else if (max !== Infinity) {\n\t\t\tmessage += `between ${min} and ${max}`;\n\t\t} else {\n\t\t\tmessage += `at least ${min}`;\n\t\t}\n\t} else {\n\t\tmessage += `at most ${max}`;\n\t}\n\n\tmessage += ` ${unit}(s)`;\n\treturn message;\n};\n\nconst formatIssueTree = (tree: IssueTree): string =\u003e {\n\tlet path = '';\n\tlet count = 0;\n\tfor (;;) {\n\t\tswitch (tree.code) {\n\t\t\tcase 'join': {\n\t\t\t\tcount += countIssues(tree.right);\n\t\t\t\ttree = tree.left;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcase 'prepend': {\n\t\t\t\tpath += `.${tree.key}`;\n\t\t\t\ttree = tree.tree;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tbreak;\n\t}\n\n\tconst message = tree.msg();\n\n\tlet msg = `${tree.code} at ${path || '.'} (${message})`;\n\tif (count \u003e 0) {\n\t\tmsg += ` (+${count} other issue(s))`;\n\t}\n\n\treturn msg;\n};\n\nexport class ValidationError extends Error {\n\toverride readonly name = 'ValidationError';\n\n\t#issueTree: IssueTree;\n\n\tconstructor(issueTree: IssueTree) {\n\t\tsuper();\n\n\t\tthis.#issueTree = issueTree;\n\t}\n\n\toverride get message(): string {\n\t\treturn formatIssueTree(this.#issueTree);\n\t}\n\n\tget issues(): readonly Issue[] {\n\t\treturn collectIssues(this.#issueTree);\n\t}\n}\n\nclass ErrImpl implements Err {\n\treadonly ok = false;\n\n\t#issueTree: IssueTree;\n\n\tconstructor(issueTree: IssueTree) {\n\t\tthis.#issueTree = issueTree;\n\t}\n\n\tget message(): string {\n\t\treturn formatIssueTree(this.#issueTree);\n\t}\n\n\tget issues(): readonly Issue[] {\n\t\treturn collectIssues(this.#issueTree);\n\t}\n\n\tthrow(): never {\n\t\tthrow new ValidationError(this.#issueTree);\n\t}\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const is = \u003cconst TSchema extends BaseSchema\u003e(\n\tschema: TSchema,\n\tinput: unknown,\n): input is InferInput\u003cTSchema\u003e =\u003e {\n\tconst r = schema['~run'](input, FLAG_ABORT_EARLY);\n\treturn r === undefined || r.ok;\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const safeParse = \u003cconst TSchema extends BaseSchema\u003e(\n\tschema: TSchema,\n\tinput: unknown,\n): ValidationResult\u003cInferOutput\u003cTSchema\u003e\u003e =\u003e {\n\tconst r = schema['~run'](input, FLAG_EMPTY);\n\n\tif (r === undefined) {\n\t\treturn ok(input as InferOutput\u003cTSchema\u003e);\n\t}\n\n\tif (r.ok) {\n\t\treturn r as Ok\u003cInferOutput\u003cTSchema\u003e\u003e;\n\t}\n\n\treturn new ErrImpl(r);\n};\n\nexport const parse = \u003cconst TSchema extends BaseSchema\u003e(\n\tschema: TSchema,\n\tinput: unknown,\n): InferOutput\u003cTSchema\u003e =\u003e {\n\tconst r = schema['~run'](input, FLAG_EMPTY);\n\n\tif (r === undefined) {\n\t\treturn input as InferOutput\u003cTSchema\u003e;\n\t}\n\n\tif (r.ok) {\n\t\treturn r.value as InferOutput\u003cTSchema\u003e;\n\t}\n\n\tthrow new ValidationError(r);\n};\n\n// #region Standard Schema support\n\nconst collectStandardIssues = (\n\ttree: IssueTree,\n\tpath: Key[] = [],\n\tissues: StandardSchemaV1.Issue[] = [],\n): StandardSchemaV1.Issue[] =\u003e {\n\tfor (;;) {\n\t\tswitch (tree.code) {\n\t\t\tcase 'join': {\n\t\t\t\tcollectStandardIssues(tree.left, path.slice(), issues);\n\t\t\t\ttree = tree.right;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcase 'prepend': {\n\t\t\t\tpath.push(tree.key);\n\t\t\t\ttree = tree.tree;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tissues.push({ message: tree.msg(), path: path.length \u003e 0 ? path : undefined });\n\t\t\t\treturn issues;\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst toStandardSchema = \u003cTSchema extends BaseSchema\u003e(schema: TSchema): LexStandardSchema\u003cTSchema\u003e =\u003e {\n\treturn {\n\t\tversion: 1,\n\t\tvendor: '@atcute/lexicons',\n\t\tvalidate(value) {\n\t\t\tconst r = schema['~run'](value, FLAG_EMPTY);\n\n\t\t\tif (r === undefined) {\n\t\t\t\treturn { value: value as InferOutput\u003cTSchema\u003e };\n\t\t\t}\n\n\t\t\tif (r.ok) {\n\t\t\t\treturn { value: r.value as InferOutput\u003cTSchema\u003e };\n\t\t\t}\n\n\t\t\treturn { issues: collectStandardIssues(r) };\n\t\t},\n\t};\n};\n\n// #region Base constraint\n\nexport interface BaseConstraint\u003cTType = unknown\u003e {\n\treadonly kind: 'constraint';\n\treadonly type: string;\n\treadonly '~run': (input: TType, flags: number) =\u003e MatcherResult;\n}\n\ntype ConstraintTuple\u003cT\u003e = readonly [BaseConstraint\u003cT\u003e, ...BaseConstraint\u003cT\u003e[]];\n\nexport type SchemaWithConstraint\u003c\n\tTItem extends BaseSchema,\n\tTConstraints extends ConstraintTuple\u003cInferOutput\u003cTItem\u003e\u003e,\n\u003e = TItem \u0026 {\n\treadonly constraints: TConstraints;\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const constrain = \u003c\n\tTItem extends BaseSchema,\n\tconst TConstraints extends ConstraintTuple\u003cInferOutput\u003cTItem\u003e\u003e,\n\u003e(\n\tbase: TItem,\n\tconstraints: TConstraints,\n): SchemaWithConstraint\u003cTItem, TConstraints\u003e =\u003e {\n\tconst len = constraints.length;\n\n\treturn {\n\t\t...base,\n\t\tconstraints: constraints,\n\t\t'~run'(input, flags) {\n\t\t\tlet result = base['~run'](input, flags);\n\t\t\tlet current: any;\n\n\t\t\tif (result === undefined) {\n\t\t\t\tcurrent = input;\n\t\t\t} else if (result.ok) {\n\t\t\t\tcurrent = result.value;\n\t\t\t} else {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tfor (let idx = 0; idx \u003c len; idx++) {\n\t\t\t\tconst r = constraints[idx]['~run'](current, flags);\n\n\t\t\t\tif (r !== undefined) {\n\t\t\t\t\tif (r.ok) {\n\t\t\t\t\t\tcurrent = r.value;\n\n\t\t\t\t\t\tif (result === undefined || result.ok) {\n\t\t\t\t\t\t\tresult = r;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (flags \u0026 FLAG_ABORT_EARLY) {\n\t\t\t\t\t\t\treturn r;\n\t\t\t\t\t\t} else if (result === undefined || result.ok) {\n\t\t\t\t\t\t\tresult = r;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult = joinIssues(result, r);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result;\n\t\t},\n\t};\n};\n\n// #region Base metadata\n\nexport interface BaseMetadata {\n\treadonly kind: 'metadata';\n\treadonly type: string;\n}\n\n// #region Literal schema\n\nexport interface LiteralSchema\u003cT extends Literal = Literal\u003e extends BaseSchema\u003cT\u003e {\n\treadonly type: 'literal';\n\treadonly expected: T;\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const literal = \u003cT extends Literal\u003e(value: T): LiteralSchema\u003cT\u003e =\u003e {\n\tconst issue: IssueLeaf = {\n\t\tok: false,\n\t\tcode: 'invalid_literal',\n\t\texpected: [value],\n\t\tmsg() {\n\t\t\treturn `expected ${formatLiteral(value)}`;\n\t\t},\n\t};\n\n\treturn {\n\t\tkind: 'schema',\n\t\ttype: 'literal',\n\t\texpected: value,\n\t\t'~run'(input, _flags) {\n\t\t\tif (input !== value) {\n\t\t\t\treturn issue;\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tget '~standard'() {\n\t\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t\t},\n\t};\n};\n\nexport interface LiteralEnumSchema\u003cTEnums extends readonly Literal[] = []\u003e extends BaseSchema\u003c\n\tTEnums[number]\n\u003e {\n\treadonly type: 'literal_enum';\n\treadonly expected: TEnums;\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const literalEnum = \u003cconst TEnums extends readonly Literal[]\u003e(\n\tvalues: TEnums,\n): LiteralEnumSchema\u003cTEnums\u003e =\u003e {\n\tconst issue: IssueLeaf = {\n\t\tok: false,\n\t\tcode: 'invalid_literal',\n\t\texpected: values,\n\t\tmsg() {\n\t\t\treturn `expected ${separatedList(values.map(formatLiteral), 'or')}`;\n\t\t},\n\t};\n\n\treturn {\n\t\tkind: 'schema',\n\t\ttype: 'literal_enum',\n\t\texpected: values,\n\t\t'~run'(input, _flags) {\n\t\t\tif (!values.includes(input as any)) {\n\t\t\t\treturn issue;\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tget '~standard'() {\n\t\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t\t},\n\t};\n};\n\n// #region Boolean schema\n\nexport interface BooleanSchema extends BaseSchema\u003cboolean\u003e {\n\treadonly type: 'boolean';\n}\n\nconst ISSUE_TYPE_BOOLEAN: IssueLeaf = {\n\tok: false,\n\tcode: 'invalid_type',\n\texpected: 'boolean',\n\tmsg() {\n\t\treturn `expected boolean`;\n\t},\n};\n\nconst BOOLEAN_SCHEMA: BooleanSchema = {\n\tkind: 'schema',\n\ttype: 'boolean',\n\t'~run'(input, _flags) {\n\t\tif (typeof input !== 'boolean') {\n\t\t\treturn ISSUE_TYPE_BOOLEAN;\n\t\t}\n\n\t\treturn undefined;\n\t},\n\tget '~standard'() {\n\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t},\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const boolean = (): BooleanSchema =\u003e {\n\treturn BOOLEAN_SCHEMA;\n};\n\n// #region Integer schema\n\nexport interface IntegerSchema extends BaseSchema\u003cnumber\u003e {\n\treadonly type: 'integer';\n}\n\nconst ISSUE_TYPE_INTEGER: IssueLeaf = {\n\tok: false,\n\tcode: 'invalid_type',\n\texpected: 'integer',\n\tmsg() {\n\t\treturn `expected integer`;\n\t},\n};\n\nconst INTEGER_SCHEMA: IntegerSchema = {\n\tkind: 'schema',\n\ttype: 'integer',\n\t'~run'(input, _flags) {\n\t\tif (typeof input !== 'number') {\n\t\t\treturn ISSUE_TYPE_INTEGER;\n\t\t}\n\n\t\tif (input \u003c 0 || !Number.isSafeInteger(input)) {\n\t\t\treturn ISSUE_TYPE_INTEGER;\n\t\t}\n\n\t\treturn undefined;\n\t},\n\tget '~standard'() {\n\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t},\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const integer = (): IntegerSchema =\u003e {\n\treturn INTEGER_SCHEMA;\n};\n\n// #region Integer constraints\n\nexport interface IntegerRangeConstraint\u003c\n\tTMin extends number = number,\n\tTMax extends number = number,\n\u003e extends BaseConstraint\u003cnumber\u003e {\n\treadonly type: 'integer_range';\n\treadonly min: TMin;\n\treadonly max: TMax;\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const integerRange: {\n\t\u003cconst TMin extends number\u003e(min: TMin): IntegerRangeConstraint\u003cTMin\u003e;\n\t\u003cconst TMin extends number, const TMax extends number\u003e(\n\t\tmin: TMin,\n\t\tmax: TMax,\n\t): IntegerRangeConstraint\u003cTMin, TMax\u003e;\n} = (min: number, max: number = Infinity): IntegerRangeConstraint =\u003e {\n\tconst issue: IssueLeaf = {\n\t\tok: false,\n\t\tcode: 'invalid_integer_range',\n\t\tmin: min,\n\t\tmax: max,\n\t\tmsg() {\n\t\t\tlet message = `expected an integer `;\n\n\t\t\tif (min \u003e 0) {\n\t\t\t\tif (max === min) {\n\t\t\t\t\tmessage += `of exactly ${min}`;\n\t\t\t\t} else if (max !== Infinity) {\n\t\t\t\t\tmessage += `between ${min} and ${max}`;\n\t\t\t\t} else {\n\t\t\t\t\tmessage += `of at least ${min}`;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmessage += `of at most ${max}`;\n\t\t\t}\n\n\t\t\treturn message;\n\t\t},\n\t};\n\n\treturn {\n\t\tkind: 'constraint',\n\t\ttype: 'integer_range',\n\t\tmin: min,\n\t\tmax: max,\n\t\t'~run'(input, _flags) {\n\t\t\tif (input \u003c min) {\n\t\t\t\treturn issue;\n\t\t\t}\n\n\t\t\tif (input \u003e max) {\n\t\t\t\treturn issue;\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n};\n\n// #region String schema\n\nexport interface StringSchema\u003cT extends string = string\u003e extends BaseSchema\u003cT\u003e {\n\treadonly type: 'string';\n\treadonly format: null;\n}\n\nexport interface FormattedStringSchema\u003c\n\tTFormat extends keyof StringFormatMap = keyof StringFormatMap,\n\u003e extends BaseSchema\u003cStringFormatMap[TFormat]\u003e {\n\treadonly type: 'string';\n\treadonly format: TFormat;\n}\n\nconst ISSUE_TYPE_STRING: IssueLeaf = {\n\tok: false,\n\tcode: 'invalid_type',\n\texpected: 'string',\n\tmsg() {\n\t\treturn `expected string`;\n\t},\n};\n\nconst STRING_SINGLETON: StringSchema = {\n\tkind: 'schema',\n\ttype: 'string',\n\tformat: null,\n\t'~run'(input, _flags) {\n\t\tif (typeof input !== 'string') {\n\t\t\treturn ISSUE_TYPE_STRING;\n\t\t}\n\n\t\treturn undefined;\n\t},\n\tget '~standard'() {\n\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t},\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const string = \u003cT extends string = string\u003e(): StringSchema\u003cT\u003e =\u003e {\n\treturn STRING_SINGLETON as StringSchema\u003cT\u003e;\n};\n\n// #__NO_SIDE_EFFECTS__\nconst _formattedString = \u003cTFormat extends keyof StringFormatMap\u003e(\n\tformat: TFormat,\n\tvalidate: (input: string) =\u003e boolean,\n) =\u003e {\n\tconst issue: IssueLeaf = {\n\t\tok: false,\n\t\tcode: 'invalid_string_format',\n\t\texpected: format,\n\t\tmsg() {\n\t\t\treturn `expected a ${format} formatted string`;\n\t\t},\n\t};\n\n\tconst schema: FormattedStringSchema\u003cTFormat\u003e = {\n\t\tkind: 'schema',\n\t\ttype: 'string',\n\t\tformat: format,\n\t\t'~run'(input, _flags) {\n\t\t\tif (typeof input !== 'string') {\n\t\t\t\treturn ISSUE_TYPE_STRING;\n\t\t\t}\n\n\t\t\tif (!validate(input)) {\n\t\t\t\treturn issue;\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tget '~standard'() {\n\t\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t\t},\n\t};\n\n\treturn () =\u003e schema;\n};\n\n// prettier-ignore\nexport const actorIdentifierString = /*#__PURE__*/ _formattedString('at-identifier', syntax.isActorIdentifier);\nexport const resourceUriString = /*#__PURE__*/ _formattedString('at-uri', syntax.isResourceUri);\nexport const cidString = /*#__PURE__*/ _formattedString('cid', syntax.isCid);\nexport const datetimeString = /*#__PURE__*/ _formattedString('datetime', syntax.isDatetime);\nexport const didString = /*#__PURE__*/ _formattedString('did', syntax.isDid);\nexport const handleString = /*#__PURE__*/ _formattedString('handle', syntax.isHandle);\nexport const languageCodeString = /*#__PURE__*/ _formattedString('language', syntax.isLanguageCode);\nexport const nsidString = /*#__PURE__*/ _formattedString('nsid', syntax.isNsid);\nexport const recordKeyString = /*#__PURE__*/ _formattedString('record-key', syntax.isRecordKey);\nexport const tidString = /*#__PURE__*/ _formattedString('tid', syntax.isTid);\nexport const genericUriString = /*#__PURE__*/ _formattedString('uri', syntax.isGenericUri);\n\n// #region String constraints\n\nexport interface StringLengthConstraint\u003c\n\tTMinLength extends number = number,\n\tTMaxLength extends number = number,\n\u003e extends BaseConstraint\u003cstring\u003e {\n\treadonly type: 'string_length';\n\treadonly minLength: TMinLength;\n\treadonly maxLength: TMaxLength;\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const stringLength: {\n\t\u003cconst TMinLength extends number\u003e(min: TMinLength): StringLengthConstraint\u003cTMinLength\u003e;\n\t\u003cconst TMinLength extends number, const TMaxLength extends number\u003e(\n\t\tmin: TMinLength,\n\t\tmax: TMaxLength,\n\t): StringLengthConstraint\u003cTMinLength, TMaxLength\u003e;\n} = (minLength: number, maxLength: number = Infinity): StringLengthConstraint =\u003e {\n\tconst issue: IssueLeaf = {\n\t\tok: false,\n\t\tcode: 'invalid_string_length',\n\t\tminLength: minLength,\n\t\tmaxLength: maxLength,\n\t\tmsg() {\n\t\t\treturn formatRangeMessage('a string', 'character', minLength, maxLength);\n\t\t},\n\t};\n\n\treturn {\n\t\tkind: 'constraint',\n\t\ttype: 'string_length',\n\t\tminLength: minLength,\n\t\tmaxLength: maxLength,\n\t\t'~run'(input, _flags) {\n\t\t\tif (!isUtf8LengthInRange(input, minLength, maxLength)) {\n\t\t\t\treturn issue;\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n};\n\nexport interface StringGraphemesConstraint\u003c\n\tTMinGraphemes extends number = number,\n\tTMaxGraphemes extends number = number,\n\u003e extends BaseConstraint\u003cstring\u003e {\n\treadonly type: 'string_graphemes';\n\treadonly minGraphemes: TMinGraphemes;\n\treadonly maxGraphemes: TMaxGraphemes;\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const stringGraphemes: {\n\t\u003cconst TMinGraphemes extends number\u003e(min: TMinGraphemes): StringGraphemesConstraint\u003cTMinGraphemes\u003e;\n\t\u003cconst TMinGraphemes extends number, const TMaxGraphemes extends number\u003e(\n\t\tmin: TMinGraphemes,\n\t\tmax: TMaxGraphemes,\n\t): StringGraphemesConstraint\u003cTMinGraphemes, TMaxGraphemes\u003e;\n} = (minGraphemes: number, maxGraphemes: number = Infinity): StringGraphemesConstraint =\u003e {\n\tconst issue: IssueLeaf = {\n\t\tok: false,\n\t\tcode: 'invalid_string_graphemes',\n\t\tminGraphemes: minGraphemes,\n\t\tmaxGraphemes: maxGraphemes,\n\t\tmsg() {\n\t\t\treturn formatRangeMessage('a string', 'grapheme', minGraphemes, maxGraphemes);\n\t\t},\n\t};\n\n\treturn {\n\t\tkind: 'constraint',\n\t\ttype: 'string_graphemes',\n\t\tminGraphemes: minGraphemes,\n\t\tmaxGraphemes: maxGraphemes,\n\t\t'~run'(input, _flags) {\n\t\t\tif (!isGraphemeLengthInRange(input, minGraphemes, maxGraphemes)) {\n\t\t\t\treturn issue;\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n};\n\n// #region Blob schema\n\nexport interface BlobSchema extends BaseSchema\u003cinterfaces.Blob | interfaces.LegacyBlob, interfaces.Blob\u003e {\n\treadonly type: 'blob';\n}\n\nconst ISSUE_EXPECTED_BLOB: IssueLeaf = {\n\tok: false,\n\tcode: 'invalid_type',\n\texpected: 'blob',\n\tmsg() {\n\t\treturn `expected blob`;\n\t},\n};\n\nconst BLOB_SCHEMA: BlobSchema = {\n\tkind: 'schema',\n\ttype: 'blob',\n\t'~run'(input, _flags) {\n\t\tif (typeof input !== 'object' || input === null) {\n\t\t\treturn ISSUE_EXPECTED_BLOB;\n\t\t}\n\n\t\tif (interfaces.isBlob(input)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (interfaces.isLegacyBlob(input)) {\n\t\t\tconst blob: interfaces.Blob = {\n\t\t\t\t$type: 'blob',\n\t\t\t\tmimeType: input.mimeType,\n\t\t\t\tref: { $link: input.cid },\n\t\t\t\tsize: -1,\n\t\t\t};\n\n\t\t\treturn ok(blob);\n\t\t}\n\n\t\treturn ISSUE_EXPECTED_BLOB;\n\t},\n\tget '~standard'() {\n\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t},\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const blob = (): BlobSchema =\u003e {\n\treturn BLOB_SCHEMA;\n};\n\n// #region IPLD bytes schema\n\nexport interface BytesSchema extends BaseSchema\u003cinterfaces.Bytes, interfaces.Bytes\u003e {\n\treadonly type: 'bytes';\n}\n\nconst ISSUE_EXPECTED_BYTES: IssueLeaf = {\n\tok: false,\n\tcode: 'invalid_type',\n\texpected: 'bytes',\n\tmsg() {\n\t\treturn `expected bytes`;\n\t},\n};\n\nconst BYTES_SCHEMA: BytesSchema = {\n\tkind: 'schema',\n\ttype: 'bytes',\n\t'~run'(input, _flags) {\n\t\tif (!interfaces.isBytes(input)) {\n\t\t\treturn ISSUE_EXPECTED_BYTES;\n\t\t}\n\n\t\treturn undefined;\n\t},\n\tget '~standard'() {\n\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t},\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const bytes = (): BytesSchema =\u003e {\n\treturn BYTES_SCHEMA;\n};\n\n// #region IPLD bytes constraint\nexport interface BytesSizeConstraint\u003c\n\tTMinLength extends number = number,\n\tTMaxLength extends number = number,\n\u003e extends BaseConstraint\u003cinterfaces.Bytes\u003e {\n\treadonly type: 'bytes_size';\n\treadonly minSize: TMinLength;\n\treadonly maxSize: TMaxLength;\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const bytesSize: {\n\t\u003cconst TMinLength extends number\u003e(min: TMinLength): BytesSizeConstraint\u003cTMinLength\u003e;\n\t\u003cconst TMinLength extends number, const TMaxLength extends number\u003e(\n\t\tmin: TMinLength,\n\t\tmax: TMaxLength,\n\t): BytesSizeConstraint\u003cTMinLength, TMaxLength\u003e;\n} = (minSize: number, maxSize: number = Infinity): BytesSizeConstraint =\u003e {\n\tconst issue: IssueLeaf = {\n\t\tok: false,\n\t\tcode: 'invalid_bytes_size',\n\t\tminSize: minSize,\n\t\tmaxSize: maxSize,\n\t\tmsg() {\n\t\t\treturn formatRangeMessage('a byte array', 'byte', minSize, maxSize);\n\t\t},\n\t};\n\n\treturn {\n\t\tkind: 'constraint',\n\t\ttype: 'bytes_size',\n\t\tminSize: minSize,\n\t\tmaxSize: maxSize,\n\t\t'~run'(input, _flags) {\n\t\t\tlet size: number;\n\n\t\t\tif (_isBytesWrapper(input)) {\n\t\t\t\tsize = input.buf.length;\n\t\t\t} else {\n\t\t\t\tconst str = input.$bytes;\n\t\t\t\tlet bytes = str.length;\n\n\t\t\t\tif (str.charCodeAt(bytes - 1) === 0x3d) {\n\t\t\t\t\tbytes--;\n\t\t\t\t}\n\t\t\t\tif (bytes \u003e 1 \u0026\u0026 str.charCodeAt(bytes - 1) === 0x3d) {\n\t\t\t\t\tbytes--;\n\t\t\t\t}\n\n\t\t\t\tsize = (bytes * 3) \u003e\u003e\u003e 2;\n\t\t\t}\n\n\t\t\tif (size \u003c minSize) {\n\t\t\t\treturn issue;\n\t\t\t}\n\n\t\t\tif (size \u003e maxSize) {\n\t\t\t\treturn issue;\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n};\n\n// #region IPLD CID type schema\n\nexport interface CidLinkSchema extends BaseSchema\u003cinterfaces.CidLink, interfaces.CidLink\u003e {\n\treadonly type: 'cid_link';\n}\n\nconst ISSUE_EXPECTED_CID_LINK: IssueLeaf = {\n\tok: false,\n\tcode: 'invalid_type',\n\texpected: 'cid-link',\n\tmsg() {\n\t\treturn `expected cid-link`;\n\t},\n};\n\nconst CID_LINK_SCHEMA: CidLinkSchema = {\n\tkind: 'schema',\n\ttype: 'cid_link',\n\t'~run'(input, _flags) {\n\t\tif (!interfaces.isCidLink(input)) {\n\t\t\treturn ISSUE_EXPECTED_CID_LINK;\n\t\t}\n\n\t\treturn undefined;\n\t},\n\tget '~standard'() {\n\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t},\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const cidLink = (): CidLinkSchema =\u003e {\n\treturn CID_LINK_SCHEMA;\n};\n\n// #region Nullable schema\n\nexport interface NullableSchema\u003cTItem extends BaseSchema = BaseSchema\u003e extends BaseSchema\u003c\n\tInferInput\u003cTItem\u003e | null,\n\tInferOutput\u003cTItem\u003e | null\n\u003e {\n\treadonly type: 'nullable';\n\treadonly wrapped: TItem;\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const nullable = \u003cTItem extends BaseSchema\u003e(wrapped: TItem): NullableSchema\u003cTItem\u003e =\u003e {\n\treturn {\n\t\tkind: 'schema',\n\t\ttype: 'nullable',\n\t\twrapped: wrapped,\n\t\t'~run'(input, flags) {\n\t\t\tif (input === null) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn wrapped['~run'](input, flags);\n\t\t},\n\t\tget '~standard'() {\n\t\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t\t},\n\t};\n};\n\n// #region Optional schema\n\nexport type DefaultValue\u003cTItem extends BaseSchema\u003e =\n\t| InferOutput\u003cTItem\u003e\n\t| (() =\u003e InferOutput\u003cTItem\u003e)\n\t| undefined;\n\nexport type InferOptionalOutput\u003c\n\tTItem extends BaseSchema,\n\tTDefault extends DefaultValue\u003cTItem\u003e,\n\u003e = undefined extends TDefault ? InferOutput\u003cTItem\u003e | undefined : InferOutput\u003cTItem\u003e;\n\nexport interface OptionalSchema\u003c\n\tTItem extends BaseSchema = BaseSchema,\n\tTDefault extends DefaultValue\u003cTItem\u003e = DefaultValue\u003cTItem\u003e,\n\u003e extends BaseSchema\u003cInferInput\u003cTItem\u003e | undefined, InferOptionalOutput\u003cTItem, TDefault\u003e\u003e {\n\treadonly type: 'optional';\n\treadonly wrapped: TItem;\n\treadonly default: TDefault;\n}\n\ntype MaybeOptional\u003cTItem extends BaseSchema\u003e = TItem | OptionalSchema\u003cTItem, undefined\u003e;\n\n// #__NO_SIDE_EFFECTS__\nexport const optional: {\n\t\u003cTItem extends BaseSchema\u003e(wrapped: TItem): OptionalSchema\u003cTItem, undefined\u003e;\n\t\u003cTItem extends BaseSchema, TDefault extends DefaultValue\u003cTItem\u003e\u003e(\n\t\twrapped: TItem,\n\t\tdefaultValue: TDefault,\n\t): OptionalSchema\u003cTItem, TDefault\u003e;\n} = (wrapped: BaseSchema, defaultValue?: any): OptionalSchema\u003cany, any\u003e =\u003e {\n\treturn {\n\t\tkind: 'schema',\n\t\ttype: 'optional',\n\t\twrapped: wrapped,\n\t\tdefault: defaultValue,\n\t\t'~run'(input, flags) {\n\t\t\tif (input === undefined) {\n\t\t\t\tif (defaultValue === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst value = typeof defaultValue === 'function' ? defaultValue() : defaultValue;\n\n\t\t\t\treturn ok(value);\n\t\t\t}\n\n\t\t\treturn wrapped['~run'](input, flags);\n\t\t},\n\t\tget '~standard'() {\n\t\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t\t},\n\t};\n};\n\nconst isOptionalSchema = (schema: BaseSchema): schema is OptionalSchema\u003cany, unknown\u003e =\u003e {\n\treturn schema.type === 'optional';\n};\n\n// #region Array schema\n\nexport interface ArraySchema\u003cTItem extends BaseSchema = BaseSchema\u003e extends BaseSchema\u003cunknown[], unknown[]\u003e {\n\treadonly type: 'array';\n\treadonly item: TItem;\n\n\treadonly [kType]?: { in: InferInput\u003cTItem\u003e[]; out: InferOutput\u003cTItem\u003e[] };\n}\n\nconst ISSUE_TYPE_ARRAY: IssueLeaf = {\n\tok: false,\n\tcode: 'invalid_type',\n\texpected: 'array',\n\tmsg() {\n\t\treturn `expected array`;\n\t},\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const array = \u003cTItem extends BaseSchema\u003e(item: TItem | (() =\u003e TItem)): ArraySchema\u003cTItem\u003e =\u003e {\n\tconst resolvedShape = lazy(() =\u003e {\n\t\treturn typeof item === 'function' ? item() : item;\n\t});\n\n\treturn {\n\t\tkind: 'schema',\n\t\ttype: 'array',\n\t\tget item() {\n\t\t\treturn lazyProperty(this, 'item', resolvedShape.value);\n\t\t},\n\t\tget '~run'() {\n\t\t\tconst shape = resolvedShape.value;\n\n\t\t\tconst matcher: Matcher = (input, flags) =\u003e {\n\t\t\t\tif (!isArray(input)) {\n\t\t\t\t\treturn ISSUE_TYPE_ARRAY;\n\t\t\t\t}\n\n\t\t\t\tlet issues: IssueTree | undefined;\n\t\t\t\tlet output: any[] | undefined;\n\n\t\t\t\tfor (let idx = 0, len = input.length; idx \u003c len; idx++) {\n\t\t\t\t\tconst val = input[idx];\n\t\t\t\t\tconst r = shape['~run'](val, flags);\n\n\t\t\t\t\tif (r !== undefined) {\n\t\t\t\t\t\tif (r.ok) {\n\t\t\t\t\t\t\tif (output === undefined) {\n\t\t\t\t\t\t\t\toutput = input.slice();\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\toutput[idx] = r.value;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tissues = joinIssues(issues, prependPath(idx, r));\n\n\t\t\t\t\t\t\tif (flags \u0026 FLAG_ABORT_EARLY) {\n\t\t\t\t\t\t\t\treturn issues;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (issues !== undefined) {\n\t\t\t\t\treturn issues;\n\t\t\t\t}\n\n\t\t\t\tif (output !== undefined) {\n\t\t\t\t\treturn ok(output);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t};\n\n\t\t\treturn lazyProperty(this, '~run', matcher);\n\t\t},\n\t\tget '~standard'() {\n\t\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t\t},\n\t};\n};\n\n// #region Array constraints\n\nexport interface ArrayLengthConstraint\u003c\n\tTMinLength extends number = number,\n\tTMaxLength extends number = number,\n\u003e extends BaseConstraint\u003cunknown[]\u003e {\n\treadonly type: 'array_length';\n\treadonly minLength: TMinLength;\n\treadonly maxLength: TMaxLength;\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const arrayLength: {\n\t\u003cconst TMinLength extends number\u003e(min: TMinLength): ArrayLengthConstraint\u003cTMinLength\u003e;\n\t\u003cconst TMinLength extends number, const TMaxLength extends number\u003e(\n\t\tmin: TMinLength,\n\t\tmax: TMaxLength,\n\t): ArrayLengthConstraint\u003cTMinLength, TMaxLength\u003e;\n} = (minLength: number, maxLength: number = Infinity): ArrayLengthConstraint =\u003e {\n\tconst issue: IssueLeaf = {\n\t\tok: false,\n\t\tcode: 'invalid_array_length',\n\t\tminLength: minLength,\n\t\tmaxLength: maxLength,\n\t\tmsg() {\n\t\t\treturn formatRangeMessage('an array', 'item', minLength, maxLength);\n\t\t},\n\t};\n\n\treturn {\n\t\tkind: 'constraint',\n\t\ttype: 'array_length',\n\t\tminLength: minLength,\n\t\tmaxLength: maxLength,\n\t\t'~run'(input, _flags) {\n\t\t\tconst length = input.length;\n\n\t\t\tif (length \u003c minLength) {\n\t\t\t\treturn issue;\n\t\t\t}\n\n\t\t\tif (length \u003e maxLength) {\n\t\t\t\treturn issue;\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n};\n\n// #region Object schema\n\n// `ObjectSchema` accepts a `LooseObjectShape` instead of `ObjectShape` to allow\n// for circular references, and this means preventing TypeScript from attempting\n// to eagerly evaluate the shape, unfortunate that this means we can't throw a\n// type issue if you add a non-schema value into the shape though\n\nexport type LooseObjectShape = Record\u003cstring, any\u003e;\nexport type ObjectShape = Record\u003cstring, BaseSchema\u003e;\n\nexport type OptionalObjectInputKeys\u003cTShape extends ObjectShape\u003e = {\n\t[Key in keyof TShape]: TShape[Key] extends OptionalSchema\u003cany, any\u003e ? Key : never;\n}[keyof TShape];\n\nexport type OptionalObjectOutputKeys\u003cTShape extends ObjectShape\u003e = {\n\t[Key in keyof TShape]: TShape[Key] extends OptionalSchema\u003cany, infer Default\u003e\n\t\t? undefined extends Default\n\t\t\t? Key\n\t\t\t: never\n\t\t: never;\n}[keyof TShape];\n\ntype InferObjectInput\u003cTShape extends ObjectShape\u003e = Flatten\u003c\n\t{\n\t\t-readonly [Key in keyof TShape as Key extends OptionalObjectInputKeys\u003cTShape\u003e ? never : Key]: InferInput\u003c\n\t\t\tTShape[Key]\n\t\t\u003e;\n\t} \u0026 {\n\t\t-readonly [Key in keyof TShape as Key extends OptionalObjectInputKeys\u003cTShape\u003e ? Key : never]?: InferInput\u003c\n\t\t\tTShape[Key]\n\t\t\u003e;\n\t}\n\u003e;\n\ntype InferObjectOutput\u003cTShape extends ObjectShape\u003e = Flatten\u003c\n\t{\n\t\t-readonly [Key in keyof TShape as Key extends OptionalObjectOutputKeys\u003cTShape\u003e\n\t\t\t? never\n\t\t\t: Key]: InferOutput\u003cTShape[Key]\u003e;\n\t} \u0026 {\n\t\t-readonly [Key in keyof TShape as Key extends OptionalObjectOutputKeys\u003cTShape\u003e\n\t\t\t? Key\n\t\t\t: never]?: InferOutput\u003cTShape[Key]\u003e;\n\t}\n\u003e;\n\nexport interface ObjectSchema\u003cTShape extends LooseObjectShape = LooseObjectShape\u003e extends BaseSchema\u003c\n\tRecord\u003cstring, unknown\u003e\n\u003e {\n\treadonly type: 'object';\n\treadonly shape: Readonly\u003cTShape\u003e;\n\n\t// passing `InferObjectX` into `extends BaseSchema\u003c...\u003e` eagerly evaluates the\n\t// shape, however, passing it as a property means that it's only evaluated if\n\t// you attempt to grab the value.\n\treadonly [kType]?: { in: InferObjectInput\u003cTShape\u003e; out: InferObjectOutput\u003cTShape\u003e };\n}\n\ninterface ObjectEntry {\n\tkey: string;\n\tschema: BaseSchema;\n\toptional: boolean;\n\tmissing: IssueTree;\n}\n\nconst ISSUE_TYPE_OBJECT: IssueLeaf = {\n\tok: false,\n\tcode: 'invalid_type',\n\texpected: 'object',\n\tmsg() {\n\t\treturn `expected object`;\n\t},\n};\n\nconst ISSUE_MISSING: IssueLeaf = {\n\tok: false,\n\tcode: 'missing_value',\n\tmsg() {\n\t\treturn `missing value`;\n\t},\n};\n\nconst set = (obj: Record\u003cstring, unknown\u003e, key: string, value: unknown): void =\u003e {\n\tif (key === '__proto__') {\n\t\tObject.defineProperty(obj, key, { value });\n\t} else {\n\t\tobj[key] = value;\n\t}\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const object = \u003cTShape extends LooseObjectShape\u003e(shape: TShape): ObjectSchema\u003cTShape\u003e =\u003e {\n\tconst resolvedEntries = lazy(() =\u003e {\n\t\tconst resolved: ObjectEntry[] = [];\n\n\t\tfor (const key in shape) {\n\t\t\tconst schema = shape[key];\n\n\t\t\tresolved.push({\n\t\t\t\tkey: key,\n\t\t\t\tschema: schema,\n\t\t\t\toptional: isOptionalSchema(schema),\n\t\t\t\tmissing: prependPath(key, ISSUE_MISSING),\n\t\t\t});\n\t\t}\n\n\t\treturn resolved;\n\t});\n\n\treturn {\n\t\tkind: 'schema',\n\t\ttype: 'object',\n\t\tget shape() {\n\t\t\t// if we just return the shape as is then it wouldn't be the same exact\n\t\t\t// shape when getters are present.\n\t\t\tconst resolved = resolvedEntries.value;\n\t\t\tconst obj: any = {};\n\n\t\t\tfor (const entry of resolved) {\n\t\t\t\tobj[entry.key] = entry.schema;\n\t\t\t}\n\n\t\t\treturn lazyProperty(this, 'shape', obj as TShape);\n\t\t},\n\t\tget '~run'() {\n\t\t\tconst shape = resolvedEntries.value;\n\t\t\tconst len = shape.length;\n\n\t\t\tconst generateFastpass = (): Matcher =\u003e {\n\t\t\t\tconst fields: [string, any][] = [\n\t\t\t\t\t['$ok', ok],\n\t\t\t\t\t['$joinIssues', joinIssues],\n\t\t\t\t\t['$prependPath', prependPath],\n\t\t\t\t];\n\n\t\t\t\tlet doc = `let $iss,$out;`;\n\n\t\t\t\tfor (let idx = 0; idx \u003c len; idx++) {\n\t\t\t\t\tconst entry = shape[idx];\n\n\t\t\t\t\tconst key = entry.key;\n\t\t\t\t\tconst esckey = JSON.stringify(key);\n\n\t\t\t\t\tconst id = `_${idx}`;\n\n\t\t\t\t\tdoc += `{const $val=$in[${esckey}];`;\n\n\t\t\t\t\tif (entry.optional) {\n\t\t\t\t\t\tdoc += `if($val!==undefined){`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdoc += `if($val!==undefined||${esckey} in $in){`;\n\t\t\t\t\t}\n\n\t\t\t\t\tdoc += `const $res=${id}$schema[\"~run\"]($val,$flags);if($res!==undefined)if($res.ok)${key !== '__proto__' ? `($out??={...$in})[${esckey}]=$res.value` : `Object.defineProperty($out??={...$in},${esckey},{value:$res.value})`};else if((($iss=$joinIssues($iss,$prependPath(${esckey},$res))),$flags\u0026${FLAG_ABORT_EARLY}))return $iss;}`;\n\n\t\t\t\t\tif (entry.optional) {\n\t\t\t\t\t\tconst schema = entry.schema as OptionalSchema;\n\t\t\t\t\t\tconst innerSchema = schema.wrapped;\n\t\t\t\t\t\tconst defaultValue = schema.default;\n\n\t\t\t\t\t\tfields.push([`${id}$schema`, innerSchema]);\n\n\t\t\t\t\t\tif (defaultValue !== undefined) {\n\t\t\t\t\t\t\tconst calls = typeof defaultValue === 'function' ? `${id}$default()` : `${id}$default`;\n\n\t\t\t\t\t\t\tfields.push([`${id}$default`, defaultValue]);\n\n\t\t\t\t\t\t\tdoc +=\n\t\t\t\t\t\t\t\tkey !== '__proto__'\n\t\t\t\t\t\t\t\t\t? `else($out??={...$in})[${esckey}]=${calls};`\n\t\t\t\t\t\t\t\t\t: `else Object.defineProperty($out??={...$in},${esckey},{value:${calls}});`;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfields.push([`${id}$schema`, entry.schema]);\n\t\t\t\t\t\tfields.push([`${id}$missing`, entry.missing]);\n\n\t\t\t\t\t\tdoc += `else if((($iss=$joinIssues($iss,${id}$missing)),$flags\u0026${FLAG_ABORT_EARLY}))return $iss;`;\n\t\t\t\t\t}\n\n\t\t\t\t\tdoc += `}`;\n\t\t\t\t}\n\n\t\t\t\tdoc += `if($iss!==undefined)return $iss;if($out!==undefined)return $ok($out);`;\n\n\t\t\t\tconst fn = new Function(\n\t\t\t\t\t`[${fields.map(([id]) =\u003e id).join(',')}]`,\n\t\t\t\t\t`return function matcher($in,$flags){${doc}}`,\n\t\t\t\t);\n\n\t\t\t\treturn fn(fields.map(([, field]) =\u003e field));\n\t\t\t};\n\n\t\t\tif (allowsEval.value) {\n\t\t\t\tconst fastpass = generateFastpass();\n\n\t\t\t\tconst matcher: Matcher = (input, flags) =\u003e {\n\t\t\t\t\tif (!isObject(input)) {\n\t\t\t\t\t\treturn ISSUE_TYPE_OBJECT;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn fastpass(input, flags);\n\t\t\t\t};\n\n\t\t\t\treturn lazyProperty(this, '~run', matcher);\n\t\t\t}\n\n\t\t\tconst matcher: Matcher = (input, flags) =\u003e {\n\t\t\t\tif (!isObject(input)) {\n\t\t\t\t\treturn ISSUE_TYPE_OBJECT;\n\t\t\t\t}\n\n\t\t\t\tlet issues: IssueTree | undefined;\n\t\t\t\tlet output: Record\u003cstring, unknown\u003e | undefined;\n\n\t\t\t\tfor (let idx = 0; idx \u003c len; idx++) {\n\t\t\t\t\tconst entry = shape[idx];\n\n\t\t\t\t\tconst key = entry.key;\n\t\t\t\t\tconst value = input[key];\n\n\t\t\t\t\tif (!entry.optional \u0026\u0026 value === undefined \u0026\u0026 !(key in input)) {\n\t\t\t\t\t\tissues = joinIssues(issues, entry.missing);\n\n\t\t\t\t\t\tif (flags \u0026 FLAG_ABORT_EARLY) {\n\t\t\t\t\t\t\treturn issues;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst r = entry.schema['~run'](value, flags);\n\n\t\t\t\t\tif (r !== undefined) {\n\t\t\t\t\t\tif (r.ok) {\n\t\t\t\t\t\t\tif (output === undefined) {\n\t\t\t\t\t\t\t\toutput = { ...input };\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t/*#__INLINE__*/ set(output, key, r.value);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tissues = joinIssues(issues, prependPath(key, r));\n\n\t\t\t\t\t\t\tif (flags \u0026 FLAG_ABORT_EARLY) {\n\t\t\t\t\t\t\t\treturn issues;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (issues !== undefined) {\n\t\t\t\t\treturn issues;\n\t\t\t\t}\n\n\t\t\t\tif (output !== undefined) {\n\t\t\t\t\treturn ok(output);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t};\n\n\t\t\treturn lazyProperty(this, '~run', matcher);\n\t\t},\n\t\tget '~standard'() {\n\t\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t\t},\n\t};\n};\n\n// #region Record schema\n//\n// unfortunately, adapting for circular references has meant that we can't have\n// TypeScript check the object against a particular shape ($type field required)\n\nexport type RecordObjectShape = {\n\t$type: LiteralSchema\u003csyntax.Nsid\u003e;\n\t[key: string]: BaseSchema;\n};\n\nexport type RecordKeySchema = StringSchema | FormattedStringSchema | LiteralSchema\u003cstring\u003e;\nexport type RecordObjectSchema = ObjectSchema\u003cRecordObjectShape\u003e;\n\nexport interface RecordSchema\u003cTObject extends ObjectSchema, TKey extends RecordKeySchema\u003e extends BaseSchema\u003c\n\tRecord\u003cstring, unknown\u003e\n\u003e {\n\treadonly type: 'record';\n\treadonly key: TKey;\n\treadonly object: TObject;\n\n\treadonly [kType]?: { in: InferInput\u003cTObject\u003e; out: InferOutput\u003cTObject\u003e };\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const record = \u003cTKey extends RecordKeySchema, TObject extends ObjectSchema\u003e(\n\tkey: TKey,\n\tobject: TObject,\n): RecordSchema\u003cTObject, TKey\u003e =\u003e {\n\tconst validatedObject = lazy((): TObject =\u003e {\n\t\tconst shape = object.shape;\n\n\t\tlet t = shape.$type as MaybeOptional\u003cLiteralSchema\u003csyntax.Nsid\u003e\u003e | undefined;\n\n\t\tassert(t !== undefined, `expected $type in record to be defined`);\n\t\tif (t.type === 'optional') {\n\t\t\tt = t.wrapped;\n\t\t}\n\n\t\tassert(t.type === 'literal' \u0026\u0026 typeof t.expected === 'string', `expected $type to be a string literal`);\n\n\t\treturn object;\n\t});\n\n\treturn {\n\t\tkind: 'schema',\n\t\ttype: 'record',\n\t\tkey: key,\n\t\tget object() {\n\t\t\treturn lazyProperty(this, 'object', validatedObject.value);\n\t\t},\n\t\t'~run'(input, flags) {\n\t\t\treturn lazyProperty(this, '~run', validatedObject.value['~run'])(input, flags);\n\t\t},\n\t\tget '~standard'() {\n\t\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t\t},\n\t};\n};\n\n// #region Variant schema\n\ntype VariantMember = ObjectSchema\u003cany\u003e | RecordSchema\u003cObjectSchema\u003cany\u003e, RecordKeySchema\u003e;\ntype VariantTuple = readonly VariantMember[];\n\ntype InferVariantInput\u003cTMembers extends VariantTuple\u003e = $type.enforce\u003cInferInput\u003cTMembers[number]\u003e\u003e;\n\ntype InferVariantOutput\u003cTMembers extends VariantTuple\u003e = $type.enforce\u003cInferOutput\u003cTMembers[number]\u003e\u003e;\n\nexport interface VariantSchema\u003c\n\tTMembers extends VariantTuple = VariantTuple,\n\tTClosed extends boolean = boolean,\n\u003e extends BaseSchema\u003cRecord\u003cstring, unknown\u003e\u003e {\n\treadonly type: 'variant';\n\treadonly members: TMembers;\n\treadonly closed: TClosed;\n\n\treadonly [kType]?: { in: InferVariantInput\u003cTMembers\u003e; out: InferVariantOutput\u003cTMembers\u003e };\n}\n\nconst ISSUE_VARIANT_MISSING = /*#__PURE__*/ prependPath('$type', ISSUE_MISSING);\n\nconst ISSUE_VARIANT_TYPE = /*#__PURE__*/ prependPath('$type', ISSUE_TYPE_STRING);\n\n// #__NO_SIDE_EFFECTS__\nexport const variant: {\n\t\u003cconst TMembers extends VariantTuple\u003e(members: TMembers): VariantSchema\u003cTMembers\u003e;\n\t\u003cconst TMembers extends VariantTuple, TClosed extends boolean\u003e(\n\t\tmembers: TMembers,\n\t\tclosed: TClosed,\n\t): VariantSchema\u003cTMembers, TClosed\u003e;\n} = (members: VariantMember[], closed: boolean = false): VariantSchema\u003cany, any\u003e =\u003e {\n\treturn {\n\t\tkind: 'schema',\n\t\ttype: 'variant',\n\t\tmembers: members,\n\t\tclosed: closed,\n\t\tget '~run'() {\n\t\t\tconst types: string[] = [];\n\t\t\tconst schemas: ObjectSchema[] = [];\n\n\t\t\tfor (let idx = 0, len = members.length; idx \u003c len; idx++) {\n\t\t\t\tconst raw = members[idx]!;\n\t\t\t\tconst member = raw.type === 'record' ? raw.object : raw;\n\t\t\t\tconst shape = member.shape;\n\n\t\t\t\tlet t = shape.$type as MaybeOptional\u003cLiteralSchema\u003csyntax.Nsid\u003e\u003e | undefined;\n\n\t\t\t\tassert(t !== undefined, `expected $type in variant member #${idx} to be defined`);\n\t\t\t\tif (t.type === 'optional') {\n\t\t\t\t\tt = t.wrapped;\n\t\t\t\t}\n\n\t\t\t\tassert(\n\t\t\t\t\tt.type === 'literal' \u0026\u0026 typeof t.expected === 'string',\n\t\t\t\t\t`expected $type in variant member #${idx} to be a string literal`,\n\t\t\t\t);\n\n\t\t\t\ttypes.push(t.expected);\n\t\t\t\tschemas.push(member);\n\t\t\t}\n\n\t\t\tconst issue: IssueLeaf = {\n\t\t\t\tok: false,\n\t\t\t\tcode: 'invalid_variant',\n\t\t\t\texpected: types,\n\t\t\t\tmsg() {\n\t\t\t\t\treturn `expected ${separatedList(types, 'or')}`;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst matcher: Matcher = (input, flags) =\u003e {\n\t\t\t\tif (!isObject(input)) {\n\t\t\t\t\treturn ISSUE_TYPE_OBJECT;\n\t\t\t\t}\n\n\t\t\t\tconst type = input.$type;\n\n\t\t\t\tif (type === undefined \u0026\u0026 !('$type' in input)) {\n\t\t\t\t\treturn ISSUE_VARIANT_MISSING;\n\t\t\t\t}\n\n\t\t\t\tif (typeof type !== 'string') {\n\t\t\t\t\treturn closed ? issue : ISSUE_VARIANT_TYPE;\n\t\t\t\t}\n\n\t\t\t\tfor (let idx = 0, len = types.length; idx \u003c len; idx++) {\n\t\t\t\t\tif (types[idx] === type) {\n\t\t\t\t\t\treturn schemas[idx]!['~run'](input, flags);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (closed) {\n\t\t\t\t\treturn issue;\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t};\n\n\t\t\treturn lazyProperty(this, '~run', matcher);\n\t\t},\n\t\tget '~standard'() {\n\t\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t\t},\n\t};\n};\n\n// #region Unknown schema\n\nexport interface UnknownSchema extends BaseSchema\u003cRecord\u003cstring, unknown\u003e\u003e {\n\treadonly type: 'unknown';\n}\n\nconst ISSUE_TYPE_UNKNOWN: IssueLeaf = {\n\tok: false,\n\tcode: 'invalid_type',\n\texpected: 'unknown',\n\tmsg() {\n\t\treturn `expected unknown`;\n\t},\n};\n\nconst UNKNOWN_SCHEMA: UnknownSchema = {\n\tkind: 'schema',\n\ttype: 'unknown',\n\t'~run'(input, _flags) {\n\t\tif (typeof input !== 'object' || input === null) {\n\t\t\treturn ISSUE_TYPE_UNKNOWN;\n\t\t}\n\n\t\treturn undefined;\n\t},\n\tget '~standard'() {\n\t\treturn lazyProperty(this, '~standard', toStandardSchema(this));\n\t},\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const unknown = (): UnknownSchema =\u003e {\n\treturn UNKNOWN_SCHEMA;\n};\n\n// #region XRPC types\n\nexport interface XRPCLexBodyParam\u003c\n\tTSchema extends ObjectSchema | VariantSchema = ObjectSchema | VariantSchema,\n\u003e {\n\treadonly type: 'lex';\n\treadonly schema: TSchema;\n}\n\nexport interface XRPCBlobBodyParam {\n\treadonly type: 'blob';\n\treadonly encoding?: string[];\n}\n\nexport type XRPCBodyParam = XRPCLexBodyParam | XRPCBlobBodyParam | null;\n\nexport type InferXRPCBodyInput\u003cT extends XRPCBodyParam\u003e =\n\tT extends XRPCLexBodyParam\u003cinfer Schema\u003e\n\t\t? InferInput\u003cSchema\u003e\n\t\t: T extends XRPCBlobBodyParam\n\t\t\t? Blob\n\t\t\t: T extends null\n\t\t\t\t? void\n\t\t\t\t: never;\n\nexport type InferXRPCBodyOutput\u003cT extends XRPCBodyParam\u003e =\n\tT extends XRPCLexBodyParam\u003cinfer Schema\u003e\n\t\t? InferOutput\u003cSchema\u003e\n\t\t: T extends XRPCBlobBodyParam\n\t\t\t? Blob\n\t\t\t: T extends null\n\t\t\t\t? void\n\t\t\t\t: never;\n\n// #region XRPC procedure metadata\n\nexport interface XRPCProcedureMetadata\u003c\n\tTParams extends ObjectSchema | null = ObjectSchema | null,\n\tTInput extends XRPCBodyParam = XRPCBodyParam,\n\tTOutput extends XRPCBodyParam = XRPCBodyParam,\n\tTNsid extends syntax.Nsid = syntax.Nsid,\n\u003e extends BaseMetadata {\n\treadonly type: 'xrpc_procedure';\n\treadonly nsid: TNsid;\n\treadonly params: TParams;\n\treadonly input: TInput;\n\treadonly output: TOutput;\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const procedure = \u003c\n\tTNsid extends syntax.Nsid,\n\tTParams extends ObjectSchema | null,\n\tTInput extends XRPCBodyParam,\n\tTOutput extends XRPCBodyParam,\n\u003e(\n\tnsid: TNsid,\n\toptions: {\n\t\tparams: TParams;\n\t\tinput: TInput;\n\t\toutput: TOutput;\n\t},\n): XRPCProcedureMetadata\u003cTParams, TInput, TOutput, TNsid\u003e =\u003e {\n\t// `schema` can be a getter, and we'd have to resolve that getter.\n\n\txrpcSchemaGenerated = true;\n\n\treturn {\n\t\tkind: 'metadata',\n\t\ttype: 'xrpc_procedure',\n\t\tnsid: nsid,\n\t\tparams: options.params,\n\t\tget input() {\n\t\t\tlet val = options.input;\n\n\t\t\tswitch (val?.type) {\n\t\t\t\tcase 'lex': {\n\t\t\t\t\tval = {\n\t\t\t\t\t\ttype: 'lex',\n\t\t\t\t\t\tschema: val.schema,\n\t\t\t\t\t} as TInput;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn lazyProperty(this, 'input', val);\n\t\t},\n\t\tget output() {\n\t\t\tlet val = options.output;\n\n\t\t\tswitch (val?.type) {\n\t\t\t\tcase 'lex': {\n\t\t\t\t\tval = {\n\t\t\t\t\t\ttype: 'lex',\n\t\t\t\t\t\tschema: val.schema,\n\t\t\t\t\t} as TOutput;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn lazyProperty(this, 'output', val);\n\t\t},\n\t};\n};\n\n// #region XRPC query metadata\n\nexport interface XRPCQueryMetadata\u003c\n\tTParams extends ObjectSchema | null = ObjectSchema | null,\n\tTOutput extends XRPCBodyParam = XRPCBodyParam,\n\tTNsid extends syntax.Nsid = syntax.Nsid,\n\u003e extends BaseMetadata {\n\treadonly type: 'xrpc_query';\n\treadonly nsid: TNsid;\n\treadonly params: TParams;\n\treadonly output: TOutput;\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const query = \u003c\n\tTNsid extends syntax.Nsid,\n\tTParams extends ObjectSchema | null,\n\tTOutput extends XRPCBodyParam,\n\u003e(\n\tnsid: TNsid,\n\toptions: {\n\t\tparams: TParams;\n\t\toutput: TOutput;\n\t},\n): XRPCQueryMetadata\u003cTParams, TOutput, TNsid\u003e =\u003e {\n\t// `schema` can be a getter, and we'd have to resolve that getter.\n\n\txrpcSchemaGenerated = true;\n\n\treturn {\n\t\tkind: 'metadata',\n\t\ttype: 'xrpc_query',\n\t\tnsid: nsid,\n\t\tparams: options.params,\n\t\tget output() {\n\t\t\tlet val = options.output;\n\n\t\t\tswitch (val?.type) {\n\t\t\t\tcase 'lex': {\n\t\t\t\t\tval = {\n\t\t\t\t\t\ttype: 'lex',\n\t\t\t\t\t\tschema: val.schema,\n\t\t\t\t\t} as TOutput;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn lazyProperty(this, 'output', val);\n\t\t},\n\t};\n};\n\n// #region XRPC subscription metadata\n\nexport interface XRPCSubscriptionMetadata\u003c\n\tTParams extends ObjectSchema | null = ObjectSchema | null,\n\tTMessage extends ObjectSchema\u003cany\u003e | VariantSchema\u003cany, any\u003e | null =\n\t\t| ObjectSchema\u003cany\u003e\n\t\t| VariantSchema\u003cany, any\u003e\n\t\t| null,\n\tTNsid extends syntax.Nsid = syntax.Nsid,\n\u003e extends BaseMetadata {\n\treadonly type: 'xrpc_subscription';\n\treadonly nsid: TNsid;\n\treadonly params: TParams;\n\treadonly message: TMessage;\n}\n\n// #__NO_SIDE_EFFECTS__\nexport const subscription = \u003c\n\tTNsid extends syntax.Nsid,\n\tTParams extends ObjectSchema | null,\n\tTMessage extends ObjectSchema\u003cany\u003e | VariantSchema\u003cany, any\u003e | null,\n\u003e(\n\tnsid: TNsid,\n\toptions: {\n\t\tparams: TParams;\n\t\treadonly message: TMessage;\n\t},\n): XRPCSubscriptionMetadata\u003cTParams, TMessage, TNsid\u003e =\u003e {\n\t// `message` can be a getter, and we'd have to resolve that getter.\n\n\treturn {\n\t\tkind: 'metadata',\n\t\ttype: 'xrpc_subscription',\n\t\tnsid: nsid,\n\t\tparams: options.params,\n\t\tget message() {\n\t\t\treturn lazyProperty(this, 'message', options.message);\n\t\t},\n\t};\n};\n","// #__NO_SIDE_EFFECTS__\nexport const lazyProperty = \u003cT\u003e(obj: object, prop: string | number | symbol, value: T): T =\u003e {\n\tObject.defineProperty(obj, prop, { value });\n\treturn value;\n};\n\n// #__NO_SIDE_EFFECTS__\nexport const lazy = \u003cT\u003e(getter: () =\u003e T): { readonly value: T } =\u003e {\n\treturn {\n\t\tget value() {\n\t\t\tconst value = getter();\n\t\t\treturn lazyProperty(this, 'value', value);\n\t\t},\n\t};\n};\n\nexport const isArray = Array.isArray;\n\n// #__NO_SIDE_EFFECTS__\nexport const isObject = (input: unknown): input is Record\u003cstring, unknown\u003e =\u003e {\n\treturn typeof input === 'object' \u0026\u0026 input !== null \u0026\u0026 !isArray(input);\n};\n\nexport const allowsEval = /*#__PURE__*/ lazy((): boolean =\u003e {\n\tif (typeof navigator !== 'undefined' \u0026\u0026 navigator?.userAgent?.includes('Cloudflare')) {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tconst F = Function;\n\t\t// oxlint-disable-next-line no-new -- intentional check for Function constructor availability\n\t\tnew F('');\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n});\n"],"version":3}
+3
vendor/esm.sh/@atcute/multibase@1.2.0/es2022/multibase.mjs
··· 1 + /* esm.sh - @atcute/multibase@1.2.0 */ 2 + var H=t=>Uint8Array.fromHex(t),N=t=>t.toHex();import{alloc as T,allocUnsafe as b}from"../../uint8array@1.1.1/es2022/uint8array.mjs";var w=(t,a,i)=>x=>{let e=(1<<a)-1,B="",o=0,r=0;for(let n=0;n<x.length;++n)for(r=r<<8|x[n],o+=8;o>a;)o-=a,B+=t[e&r>>o];if(o!==0&&(B+=t[e&r<<a-o]),i)for(;(B.length*a&7)!==0;)B+="=";return B},E=(t,a,i)=>{let x={};for(let e=0;e<t.length;++e)x[t[e]]=e;return e=>{let B=e.length;for(;i&&e[B-1]==="=";)--B;let o=b(B*a/8|0),r=0,n=0,s=0;for(let f=0;f<B;++f){let l=x[e[f]];if(l===void 0)throw new SyntaxError("invalid base string");n=n<<a|l,r+=a,r>=8&&(r-=8,o[s++]=255&n>>r)}if(r>=a||(255&n<<8-r)!==0)throw new SyntaxError("unexpected end of data");return o}},_=t=>{if(t.length>=255)throw new RangeError("alphabet too long");let a=t.length,i=t.charAt(0),x=Math.log(256)/Math.log(a);return e=>{if(e.length===0)return"";let B=0,o=0,r=0,n=e.length;for(;r!==n&&e[r]===0;)r++,B++;let s=n-r,f=s*x+1>>>0,l=T(f);{let p=s%3,m=n-p;for(;r<m;){let d=e[r]<<16|e[r+1]<<8|e[r+2],A=0;for(let g=f-1;(d!==0||A<o)&&g!==-1;g--,A++)d=d+16777216*l[g],l[g]=d%a|0,d=d/a|0;o=A,r+=3}}for(;r!==n;){let p=e[r],m=0;for(let d=f-1;(p!==0||m<o)&&d!==-1;d--,m++)p=p+256*l[d],l[d]=p%a|0,p=p/a|0;o=m,r++}let c=f-o;for(;c!==f&&l[c]===0;)c++;let h=i.repeat(B);for(;c<f;++c)h+=t.charAt(l[c]);return h}},z=t=>{if(t.length>=255)throw new RangeError("alphabet too long");let a=new Uint8Array(128).fill(255);for(let o=0;o<t.length;o++){let r=t.charCodeAt(o);if(r>=128)throw new RangeError("non-ASCII character in alphabet");if(a[r]!==255)throw new RangeError(`${t[o]} is ambiguous`);a[r]=o}let i=t.length,x=i*i,e=t.charAt(0),B=Math.log(i)/Math.log(256);return o=>{if(o.length===0)return b(0);let r=0,n=0,s=0;for(;o[r]===e;)n++,r++;let f=o.length-r,l=f*B+1>>>0,c=T(l);{let m=f&1,d=o.length-m;for(;r<d;){let A=a[o.charCodeAt(r)],g=a[o.charCodeAt(r+1)];if(A===255||g===255)throw new Error("invalid string");let u=A*i+g,y=0;for(let C=l-1;(u!==0||y<s)&&C!==-1;C--,y++)u+=x*c[C],c[C]=u&255,u=(u-(u&255))/256;if(u!==0)throw new Error("non-zero carry");s=y,r+=2}}if(r<o.length){let m=a[o.charCodeAt(r)];if(m===255)throw new Error("invalid string");let d=0;for(let A=l-1;(m!==0||d<s)&&A!==-1;A--,d++)m+=i*c[A],c[A]=m&255,m=m>>>8;if(m!==0)throw new Error("non-zero carry");s=d}let h=l-s;for(;h!==l&&c[h]===0;)h++;if(h===n)return c;let p=b(n+(l-h));return p.fill(0,0,n),p.set(c.subarray(h),n),p}};var k="0123456789abcdef",D=E(k,4,!1),L=w(k,4,!1);var M="fromHex"in Uint8Array,rt=M?H:D,at=M?N:L;var I=t=>Uint8Array.fromBase64(t,{alphabet:"base64",lastChunkHandling:"loose"}),O=t=>t.toBase64({alphabet:"base64",omitPadding:!0}),j=t=>Uint8Array.fromBase64(t,{alphabet:"base64",lastChunkHandling:"strict"}),q=t=>t.toBase64({alphabet:"base64",omitPadding:!1}),F=t=>Uint8Array.fromBase64(t,{alphabet:"base64url",lastChunkHandling:"loose"}),V=t=>t.toBase64({alphabet:"base64url",omitPadding:!0}),G=t=>Uint8Array.fromBase64(t,{alphabet:"base64url",lastChunkHandling:"strict"}),J=t=>t.toBase64({alphabet:"base64url",omitPadding:!1});var S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",K=E(S,6,!1),Q=w(S,6,!1),W=E(S,6,!0),X=w(S,6,!0),Y=E(R,6,!1),Z=w(R,6,!1),$=E(R,6,!0),tt=w(R,6,!0);var P="fromBase64"in Uint8Array,nt=P?I:K,st=P?O:Q,ft=P?j:W,lt=P?q:X,ct=P?F:Y,it=P?V:Z,Bt=P?G:$,dt=P?J:tt;import{allocUnsafe as ht}from"../../uint8array@1.1.1/es2022/uint8array.mjs";var xt="abcdefghijklmnopqrstuvwxyz234567",mt=(()=>{let t=new Uint8Array(32);for(let a=0;a<32;a++)t[a]=xt.charCodeAt(a);return t})(),v=String.fromCharCode,et=t=>{let a=t.length,i=a/5|0,x=a-i*5,e=mt,B="",o=0,r=i/2|0;for(let n=0;n<r;n++){let s=t[o],f=t[o+1],l=t[o+2],c=t[o+3],h=t[o+4],p=t[o+5],m=t[o+6],d=t[o+7],A=t[o+8],g=t[o+9];B+=v(e[s>>>3],e[(s<<2|f>>>6)&31],e[f>>>1&31],e[(f<<4|l>>>4)&31],e[(l<<1|c>>>7)&31],e[c>>>2&31],e[(c<<3|h>>>5)&31],e[h&31],e[p>>>3],e[(p<<2|m>>>6)&31],e[m>>>1&31],e[(m<<4|d>>>4)&31],e[(d<<1|A>>>7)&31],e[A>>>2&31],e[(A<<3|g>>>5)&31],e[g&31]),o+=10}if(i&1){let n=t[o],s=t[o+1],f=t[o+2],l=t[o+3],c=t[o+4];B+=v(e[n>>>3],e[(n<<2|s>>>6)&31],e[s>>>1&31],e[(s<<4|f>>>4)&31],e[(f<<1|l>>>7)&31],e[l>>>2&31],e[(l<<3|c>>>5)&31],e[c&31]),o+=5}if(x>0){let n=0,s=0;for(let f=o;f<a;f++)n=n<<8|t[f],s+=8;for(;s>=5;)s-=5,B+=v(e[n>>>s&31]);s>0&&(B+=v(e[n<<5-s&31]))}return B};var pt="abcdefghijklmnopqrstuvwxyz234567",U=(()=>{let t=new Uint8Array(128).fill(255);for(let a=0;a<32;a++)t[pt.charCodeAt(a)]=a;return t})(),At=t=>{let a=t.length,i=ht(a*5/8|0),x=0,e=0,B=a-a%8;for(;e<B;e+=8){let o=U[t.charCodeAt(e)],r=U[t.charCodeAt(e+1)],n=U[t.charCodeAt(e+2)],s=U[t.charCodeAt(e+3)],f=U[t.charCodeAt(e+4)],l=U[t.charCodeAt(e+5)],c=U[t.charCodeAt(e+6)],h=U[t.charCodeAt(e+7)];if((o|r|n|s|f|l|c|h)&224)throw new SyntaxError("invalid base string");i[x]=o<<3|r>>>2,i[x+1]=(r<<6|n<<1|s>>>4)&255,i[x+2]=(s<<4|f>>>1)&255,i[x+3]=(f<<7|l<<2|c>>>3)&255,i[x+4]=(c<<5|h)&255,x+=5}if(e<a){let o=0,r=0;for(;e<a;++e){let n=U[t.charCodeAt(e)];if(n&224)throw new SyntaxError("invalid base string");r=r<<5|n,o+=5,o>=8&&(o-=8,i[x++]=255&r>>o)}if(o>=5||(255&r<<8-o)!==0)throw new SyntaxError("unexpected end of data")}return i};var ot="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",gt=z(ot),Ut=_(ot);export{rt as fromBase16,At as fromBase32,gt as fromBase58Btc,nt as fromBase64,ft as fromBase64Pad,ct as fromBase64Url,Bt as fromBase64UrlPad,at as toBase16,et as toBase32,Ut as toBase58Btc,st as toBase64,lt as toBase64Pad,it as toBase64Url,dt as toBase64UrlPad}; 3 + //# sourceMappingURL=./multibase.mjs.map
+1
vendor/esm.sh/@atcute/multibase@1.2.0/es2022/multibase.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,IAC5DV,EAAME,EAAU,CAAC,GAAMQ,GAAM,EAAKC,GAAM,IACxCT,GAAW,CACZ,CAGA,GAAIN,EAAIG,EAAK,CACZ,IAAIa,EAAO,EACPC,EAAS,EACb,KAAOjB,EAAIG,EAAK,EAAEH,EAAG,CACpB,IAAMkB,EAAQnB,EAAWG,EAAI,WAAWF,CAAC,CAAC,EAC1C,GAAIkB,EAAQ,IACX,MAAM,IAAI,YAAY,qBAAqB,EAE5CD,EAAUA,GAAU,EAAKC,EACzBF,GAAQ,EACJA,GAAQ,IACXA,GAAQ,EACRZ,EAAME,GAAS,EAAI,IAAQW,GAAUD,EAEvC,CAEA,GAAIA,GAAQ,IAAM,IAAQC,GAAW,EAAID,KAAY,EACpD,MAAM,IAAI,YAAY,wBAAwB,CAEhD,CAEA,OAAOZ,CACR,EE9EA,IAAMe,GAAoB,6DAEbC,GACEC,EAAoBF,EAAiB,EAEvCG,GACEC,EAAoBJ,EAAiB","names":["fromBase16","str","toBase16","bytes","alloc","allocUnsafe","createRfc4648Encode","alphabet","bitsPerChar","pad","bytes","mask","str","bits","buffer","i","createRfc4648Decode","codes","end","written","value","createBtcBaseEncode","BASE","LEADER","iFACTOR","source","zeroes","length","pbegin","pend","dataLen","size","bN","rem","tripleEnd","carry","it1","it2","createBtcBaseDecode","BASE_MAP","xc","BASE2","FACTOR","psz","remaining","b256","pairEnd","c0","c1","it3","it4","vch","BASE16_CHARSET","fromBase16","createRfc4648Decode","toBase16","createRfc4648Encode","HAS_NATIVE_SUPPORT","fromBase16","toBase16","fromBase64","str","toBase64","bytes","fromBase64Pad","toBase64Pad","fromBase64Url","toBase64Url","fromBase64UrlPad","toBase64UrlPad","BASE64_CHARSET","BASE64URL_CHARSET","fromBase64","createRfc4648Decode","toBase64","createRfc4648Encode","fromBase64Pad","toBase64Pad","fromBase64Url","toBase64Url","fromBase64UrlPad","toBase64UrlPad","HAS_NATIVE_SUPPORT","fromBase64","toBase64","fromBase64Pad","toBase64Pad","fromBase64Url","toBase64Url","fromBase64UrlPad","toBase64UrlPad","allocUnsafe","ALPHABET","_cc","i","_fromCharCode","toBase32","bytes","len","full","rem","cc","str","ip","pairs","g","a0","a1","a2","a3","a4","b0","b1","b2","b3","b4","buffer","bits","ALPHABET","_decodeLut","i","fromBase32","str","end","bytes","allocUnsafe","written","fullGroups","c0","c1","c2","c3","c4","c5","c6","c7","bits","buffer","value","BASE58BTC_CHARSET","fromBase58Btc","createBtcBaseDecode","toBase58Btc","createBtcBaseEncode"],"sources":["../esm/npm/@atcute/multibase@1.2.0/node_modules/@atcute/multibase/lib/bases/base16-web-native.ts","../esm/npm/@atcute/multibase@1.2.0/node_modules/@atcute/multibase/lib/utils.ts","../esm/npm/@atcute/multibase@1.2.0/node_modules/@atcute/multibase/lib/bases/base16-web-polyfill.ts","../esm/npm/@atcute/multibase@1.2.0/node_modules/@atcute/multibase/lib/bases/base16-web.ts","../esm/npm/@atcute/multibase@1.2.0/node_modules/@atcute/multibase/lib/bases/base64-web-native.ts","../esm/npm/@atcute/multibase@1.2.0/node_modules/@atcute/multibase/lib/bases/base64-web-polyfill.ts","../esm/npm/@atcute/multibase@1.2.0/node_modules/@atcute/multibase/lib/bases/base64-web.ts","../esm/npm/@atcute/multibase@1.2.0/node_modules/@atcute/multibase/lib/bases/base32.ts","../esm/npm/@atcute/multibase@1.2.0/node_modules/@atcute/multibase/lib/bases/base32-encode.ts","../esm/npm/@atcute/multibase@1.2.0/node_modules/@atcute/multibase/lib/bases/base58.ts"],"sourcesContent":["export const fromBase16 = (str: string): Uint8Array\u003cArrayBuffer\u003e =\u003e {\n\treturn Uint8Array.fromHex(str) as Uint8Array\u003cArrayBuffer\u003e;\n};\n\nexport const toBase16 = (bytes: Uint8Array): string =\u003e {\n\treturn bytes.toHex();\n};\n","import { alloc, allocUnsafe } from '@atcute/uint8array';\n\nexport const createRfc4648Encode = (alphabet: string, bitsPerChar: number, pad: boolean) =\u003e {\n\treturn (bytes: Uint8Array): string =\u003e {\n\t\tconst mask = (1 \u003c\u003c bitsPerChar) - 1;\n\t\tlet str = '';\n\n\t\tlet bits = 0; // Number of bits currently in the buffer\n\t\tlet buffer = 0; // Bits waiting to be written out, MSB first\n\t\tfor (let i = 0; i \u003c bytes.length; ++i) {\n\t\t\t// Slurp data into the buffer:\n\t\t\tbuffer = (buffer \u003c\u003c 8) | bytes[i];\n\t\t\tbits += 8;\n\n\t\t\t// Write out as much as we can:\n\t\t\twhile (bits \u003e bitsPerChar) {\n\t\t\t\tbits -= bitsPerChar;\n\t\t\t\tstr += alphabet[mask \u0026 (buffer \u003e\u003e bits)];\n\t\t\t}\n\t\t}\n\n\t\t// Partial character:\n\t\tif (bits !== 0) {\n\t\t\tstr += alphabet[mask \u0026 (buffer \u003c\u003c (bitsPerChar - bits))];\n\t\t}\n\n\t\t// Add padding characters until we hit a byte boundary:\n\t\tif (pad) {\n\t\t\twhile (((str.length * bitsPerChar) \u0026 7) !== 0) {\n\t\t\t\tstr += '=';\n\t\t\t}\n\t\t}\n\n\t\treturn str;\n\t};\n};\n\nexport const createRfc4648Decode = (alphabet: string, bitsPerChar: number, pad: boolean) =\u003e {\n\t// Build the character lookup table:\n\tconst codes: Record\u003cstring, number\u003e = {};\n\tfor (let i = 0; i \u003c alphabet.length; ++i) {\n\t\tcodes[alphabet[i]] = i;\n\t}\n\n\treturn (str: string): Uint8Array\u003cArrayBuffer\u003e =\u003e {\n\t\t// Count the padding bytes:\n\t\tlet end = str.length;\n\t\t// oxlint-disable-next-line no-unmodified-loop-condition\n\t\twhile (pad \u0026\u0026 str[end - 1] === '=') {\n\t\t\t--end;\n\t\t}\n\n\t\t// Allocate the output:\n\t\tconst bytes = allocUnsafe(((end * bitsPerChar) / 8) | 0);\n\n\t\t// Parse the data:\n\t\tlet bits = 0; // Number of bits currently in the buffer\n\t\tlet buffer = 0; // Bits waiting to be written out, MSB first\n\t\tlet written = 0; // Next byte to write\n\t\tfor (let i = 0; i \u003c end; ++i) {\n\t\t\t// Read one character from the string:\n\t\t\tconst value = codes[str[i]];\n\t\t\tif (value === undefined) {\n\t\t\t\tthrow new SyntaxError(`invalid base string`);\n\t\t\t}\n\n\t\t\t// Append the bits to the buffer:\n\t\t\tbuffer = (buffer \u003c\u003c bitsPerChar) | value;\n\t\t\tbits += bitsPerChar;\n\n\t\t\t// Write out some bits if the buffer has a byte's worth:\n\t\t\tif (bits \u003e= 8) {\n\t\t\t\tbits -= 8;\n\t\t\t\tbytes[written++] = 0xff \u0026 (buffer \u003e\u003e bits);\n\t\t\t}\n\t\t}\n\n\t\t// Verify that we have received just enough bits:\n\t\tif (bits \u003e= bitsPerChar || (0xff \u0026 (buffer \u003c\u003c (8 - bits))) !== 0) {\n\t\t\tthrow new SyntaxError('unexpected end of data');\n\t\t}\n\n\t\treturn bytes;\n\t};\n};\n\nexport const createBtcBaseEncode = (alphabet: string) =\u003e {\n\tif (alphabet.length \u003e= 255) {\n\t\tthrow new RangeError(`alphabet too long`);\n\t}\n\n\tconst BASE = alphabet.length;\n\tconst LEADER = alphabet.charAt(0);\n\tconst iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up\n\n\treturn (source: Uint8Array): string =\u003e {\n\t\tif (source.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\t// Skip \u0026 count leading zeroes.\n\t\tlet zeroes = 0;\n\t\tlet length = 0;\n\t\tlet pbegin = 0;\n\t\tconst pend = source.length;\n\t\twhile (pbegin !== pend \u0026\u0026 source[pbegin] === 0) {\n\t\t\tpbegin++;\n\t\t\tzeroes++;\n\t\t}\n\n\t\t// Allocate enough space in big-endian base-N representation.\n\t\tconst dataLen = pend - pbegin;\n\t\tconst size = (dataLen * iFACTOR + 1) \u003e\u003e\u003e 0;\n\t\tconst bN = alloc(size);\n\n\t\t// Process 3 source bytes at a time where possible.\n\t\t// multiplier: 256^3 = 16777216. max carry: 16777216 * (BASE-1) + (BASE-1).\n\t\t// for BASE=58: 16777216 * 57 = 956301312, well within 2^32 - 1.\n\t\t{\n\t\t\tconst rem = dataLen % 3;\n\t\t\tconst tripleEnd = pend - rem;\n\n\t\t\twhile (pbegin \u003c tripleEnd) {\n\t\t\t\tlet carry = (source[pbegin] \u003c\u003c 16) | (source[pbegin + 1] \u003c\u003c 8) | source[pbegin + 2];\n\n\t\t\t\tlet i = 0;\n\t\t\t\tfor (let it1 = size - 1; (carry !== 0 || i \u003c length) \u0026\u0026 it1 !== -1; it1--, i++) {\n\t\t\t\t\tcarry = carry + 16777216 * bN[it1];\n\t\t\t\t\tbN[it1] = (carry % BASE) | 0;\n\t\t\t\t\tcarry = (carry / BASE) | 0;\n\t\t\t\t}\n\n\t\t\t\tlength = i;\n\t\t\t\tpbegin += 3;\n\t\t\t}\n\t\t}\n\n\t\t// Process remaining 0-2 bytes one at a time.\n\t\twhile (pbegin !== pend) {\n\t\t\tlet carry = source[pbegin];\n\n\t\t\tlet i = 0;\n\t\t\tfor (let it1 = size - 1; (carry !== 0 || i \u003c length) \u0026\u0026 it1 !== -1; it1--, i++) {\n\t\t\t\tcarry = carry + 256 * bN[it1];\n\t\t\t\tbN[it1] = (carry % BASE) | 0;\n\t\t\t\tcarry = (carry / BASE) | 0;\n\t\t\t}\n\n\t\t\tlength = i;\n\t\t\tpbegin++;\n\t\t}\n\n\t\t// Skip leading zeroes in base-N result.\n\t\tlet it2 = size - length;\n\t\twhile (it2 !== size \u0026\u0026 bN[it2] === 0) {\n\t\t\tit2++;\n\t\t}\n\n\t\t// Translate the result into a string.\n\t\tlet str = LEADER.repeat(zeroes);\n\t\tfor (; it2 \u003c size; ++it2) {\n\t\t\tstr += alphabet.charAt(bN[it2]);\n\t\t}\n\n\t\treturn str;\n\t};\n};\n\nexport const createBtcBaseDecode = (alphabet: string) =\u003e {\n\tif (alphabet.length \u003e= 255) {\n\t\tthrow new RangeError(`alphabet too long`);\n\t}\n\n\tconst BASE_MAP = new Uint8Array(128).fill(255);\n\tfor (let i = 0; i \u003c alphabet.length; i++) {\n\t\tconst xc = alphabet.charCodeAt(i);\n\n\t\tif (xc \u003e= 128) {\n\t\t\tthrow new RangeError(`non-ASCII character in alphabet`);\n\t\t}\n\t\tif (BASE_MAP[xc] !== 255) {\n\t\t\tthrow new RangeError(`${alphabet[i]} is ambiguous`);\n\t\t}\n\n\t\tBASE_MAP[xc] = i;\n\t}\n\n\tconst BASE = alphabet.length;\n\tconst BASE2 = BASE * BASE;\n\tconst LEADER = alphabet.charAt(0);\n\tconst FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up\n\n\treturn (source: string): Uint8Array\u003cArrayBuffer\u003e =\u003e {\n\t\tif (source.length === 0) {\n\t\t\treturn allocUnsafe(0);\n\t\t}\n\n\t\t// Skip and count leading leader characters.\n\t\tlet psz = 0;\n\t\tlet zeroes = 0;\n\t\tlet length = 0;\n\n\t\twhile (source[psz] === LEADER) {\n\t\t\tzeroes++;\n\t\t\tpsz++;\n\t\t}\n\n\t\t// Allocate enough space in big-endian base256 representation.\n\t\tconst remaining = source.length - psz;\n\t\tconst size = (remaining * FACTOR + 1) \u003e\u003e\u003e 0;\n\t\tconst b256 = alloc(size);\n\n\t\t// Process 2 source characters at a time where possible.\n\t\t// combined value: c0 * BASE + c1, multiplier: BASE^2.\n\t\t// max carry: BASE^2 * 255 + (BASE^2 - 1).\n\t\t// for BASE=58: 3364 * 255 + 3363 = 861183, well within safe integer range.\n\t\t{\n\t\t\tconst rem = remaining \u0026 1;\n\t\t\tconst pairEnd = source.length - rem;\n\n\t\t\twhile (psz \u003c pairEnd) {\n\t\t\t\tconst c0 = BASE_MAP[source.charCodeAt(psz)];\n\t\t\t\tconst c1 = BASE_MAP[source.charCodeAt(psz + 1)];\n\n\t\t\t\tif (c0 === 255 || c1 === 255) {\n\t\t\t\t\tthrow new Error(`invalid string`);\n\t\t\t\t}\n\n\t\t\t\tlet carry = c0 * BASE + c1;\n\n\t\t\t\tlet i = 0;\n\t\t\t\tfor (let it3 = size - 1; (carry !== 0 || i \u003c length) \u0026\u0026 it3 !== -1; it3--, i++) {\n\t\t\t\t\tcarry += BASE2 * b256[it3];\n\t\t\t\t\tb256[it3] = carry \u0026 0xff;\n\t\t\t\t\tcarry = (carry - (carry \u0026 0xff)) / 256;\n\t\t\t\t}\n\t\t\t\tif (carry !== 0) {\n\t\t\t\t\tthrow new Error('non-zero carry');\n\t\t\t\t}\n\t\t\t\tlength = i;\n\t\t\t\tpsz += 2;\n\t\t\t}\n\t\t}\n\n\t\t// Process remaining character if odd count.\n\t\tif (psz \u003c source.length) {\n\t\t\tlet carry = BASE_MAP[source.charCodeAt(psz)];\n\n\t\t\tif (carry === 255) {\n\t\t\t\tthrow new Error(`invalid string`);\n\t\t\t}\n\n\t\t\tlet i = 0;\n\t\t\tfor (let it3 = size - 1; (carry !== 0 || i \u003c length) \u0026\u0026 it3 !== -1; it3--, i++) {\n\t\t\t\tcarry += BASE * b256[it3];\n\t\t\t\tb256[it3] = carry \u0026 0xff;\n\t\t\t\tcarry = carry \u003e\u003e\u003e 8;\n\t\t\t}\n\t\t\tif (carry !== 0) {\n\t\t\t\tthrow new Error('non-zero carry');\n\t\t\t}\n\t\t\tlength = i;\n\t\t}\n\n\t\t// Skip leading zeroes in b256.\n\t\tlet it4 = size - length;\n\t\twhile (it4 !== size \u0026\u0026 b256[it4] === 0) {\n\t\t\tit4++;\n\t\t}\n\n\t\tif (it4 === zeroes) {\n\t\t\treturn b256;\n\t\t}\n\n\t\tconst vch = allocUnsafe(zeroes + (size - it4));\n\t\tvch.fill(0, 0, zeroes);\n\t\tvch.set(b256.subarray(it4), zeroes);\n\n\t\treturn vch;\n\t};\n};\n","// remove after September 2027\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/toHex\n\nimport { createRfc4648Decode, createRfc4648Encode } from '../utils.ts';\n\nconst BASE16_CHARSET = '0123456789abcdef';\n\nexport const fromBase16: (str: string) =\u003e Uint8Array\u003cArrayBuffer\u003e =\n\t/*#__PURE__*/ createRfc4648Decode(BASE16_CHARSET, 4, false);\nexport const toBase16: (bytes: Uint8Array) =\u003e string =\n\t/*#__PURE__*/ createRfc4648Encode(BASE16_CHARSET, 4, false);\n","import { fromBase16 as fromBase16Native, toBase16 as toBase16Native } from './base16-web-native.ts';\nimport { fromBase16 as fromBase16Polyfill, toBase16 as toBase16Polyfill } from './base16-web-polyfill.ts';\n\nconst HAS_NATIVE_SUPPORT = 'fromHex' in Uint8Array;\n\nexport const fromBase16 = !HAS_NATIVE_SUPPORT ? fromBase16Polyfill : fromBase16Native;\nexport const toBase16 = !HAS_NATIVE_SUPPORT ? toBase16Polyfill : toBase16Native;\n","// #region base64\nexport const fromBase64 = (str: string): Uint8Array\u003cArrayBuffer\u003e =\u003e {\n\treturn Uint8Array.fromBase64(str, {\n\t\talphabet: 'base64',\n\t\tlastChunkHandling: 'loose',\n\t}) as Uint8Array\u003cArrayBuffer\u003e;\n};\n\nexport const toBase64 = (bytes: Uint8Array): string =\u003e {\n\treturn bytes.toBase64({ alphabet: 'base64', omitPadding: true });\n};\n// #endregion\n\n// #region base64pad\nexport const fromBase64Pad = (str: string): Uint8Array\u003cArrayBuffer\u003e =\u003e {\n\treturn Uint8Array.fromBase64(str, {\n\t\talphabet: 'base64',\n\t\tlastChunkHandling: 'strict',\n\t}) as Uint8Array\u003cArrayBuffer\u003e;\n};\n\nexport const toBase64Pad = (bytes: Uint8Array): string =\u003e {\n\treturn bytes.toBase64({ alphabet: 'base64', omitPadding: false });\n};\n// #endregion\n\n// #region base64url\nexport const fromBase64Url = (str: string): Uint8Array\u003cArrayBuffer\u003e =\u003e {\n\treturn Uint8Array.fromBase64(str, {\n\t\talphabet: 'base64url',\n\t\tlastChunkHandling: 'loose',\n\t}) as Uint8Array\u003cArrayBuffer\u003e;\n};\n\nexport const toBase64Url = (bytes: Uint8Array): string =\u003e {\n\treturn bytes.toBase64({ alphabet: 'base64url', omitPadding: true });\n};\n// #endregion\n\n// #region base64urlpad\nexport const fromBase64UrlPad = (str: string): Uint8Array\u003cArrayBuffer\u003e =\u003e {\n\treturn Uint8Array.fromBase64(str, {\n\t\talphabet: 'base64url',\n\t\tlastChunkHandling: 'strict',\n\t}) as Uint8Array\u003cArrayBuffer\u003e;\n};\n\nexport const toBase64UrlPad = (bytes: Uint8Array): string =\u003e {\n\treturn bytes.toBase64({ alphabet: 'base64url', omitPadding: false });\n};\n// #endregion\n","// remove after September 2027\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/toBase64\n\nimport { createRfc4648Decode, createRfc4648Encode } from '../utils.ts';\n\nconst BASE64_CHARSET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nconst BASE64URL_CHARSET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';\n\n// #region base64\nexport const fromBase64: (str: string) =\u003e Uint8Array\u003cArrayBuffer\u003e =\n\t/*#__PURE__*/ createRfc4648Decode(BASE64_CHARSET, 6, false);\nexport const toBase64: (bytes: Uint8Array) =\u003e string =\n\t/*#__PURE__*/ createRfc4648Encode(BASE64_CHARSET, 6, false);\n// #endregion\n\n// #region base64pad\nexport const fromBase64Pad: (str: string) =\u003e Uint8Array\u003cArrayBuffer\u003e =\n\t/*#__PURE__*/ createRfc4648Decode(BASE64_CHARSET, 6, true);\nexport const toBase64Pad: (bytes: Uint8Array) =\u003e string =\n\t/*#__PURE__*/ createRfc4648Encode(BASE64_CHARSET, 6, true);\n// #endregion\n\n// #region base64url\nexport const fromBase64Url: (str: string) =\u003e Uint8Array\u003cArrayBuffer\u003e =\n\t/*#__PURE__*/ createRfc4648Decode(BASE64URL_CHARSET, 6, false);\nexport const toBase64Url: (bytes: Uint8Array) =\u003e string =\n\t/*#__PURE__*/ createRfc4648Encode(BASE64URL_CHARSET, 6, false);\n// #endregion\n\n// #region base64urlpad\nexport const fromBase64UrlPad: (str: string) =\u003e Uint8Array\u003cArrayBuffer\u003e =\n\t/*#__PURE__*/ createRfc4648Decode(BASE64URL_CHARSET, 6, true);\nexport const toBase64UrlPad: (bytes: Uint8Array) =\u003e string =\n\t/*#__PURE__*/ createRfc4648Encode(BASE64URL_CHARSET, 6, true);\n// #endregion\n","import {\n\tfromBase64 as fromBase64Native,\n\tfromBase64Pad as fromBase64PadNative,\n\tfromBase64Url as fromBase64UrlNative,\n\tfromBase64UrlPad as fromBase64UrlPadNative,\n\ttoBase64 as toBase64Native,\n\ttoBase64Pad as toBase64PadNative,\n\ttoBase64Url as toBase64UrlNative,\n\ttoBase64UrlPad as toBase64UrlPadNative,\n} from './base64-web-native.ts';\nimport {\n\tfromBase64Pad as fromBase64PadPolyfill,\n\tfromBase64 as fromBase64Polyfill,\n\tfromBase64UrlPad as fromBase64UrlPadPolyfill,\n\tfromBase64Url as fromBase64UrlPolyfill,\n\ttoBase64Pad as toBase64PadPolyfill,\n\ttoBase64 as toBase64Polyfill,\n\ttoBase64UrlPad as toBase64UrlPadPolyfill,\n\ttoBase64Url as toBase64UrlPolyfill,\n} from './base64-web-polyfill.ts';\n\nconst HAS_NATIVE_SUPPORT = 'fromBase64' in Uint8Array;\n\n// #region base64\nexport const fromBase64 = !HAS_NATIVE_SUPPORT ? fromBase64Polyfill : fromBase64Native;\nexport const toBase64 = !HAS_NATIVE_SUPPORT ? toBase64Polyfill : toBase64Native;\n// #endregion\n\n// #region base64pad\nexport const fromBase64Pad = !HAS_NATIVE_SUPPORT ? fromBase64PadPolyfill : fromBase64PadNative;\nexport const toBase64Pad = !HAS_NATIVE_SUPPORT ? toBase64PadPolyfill : toBase64PadNative;\n// #endregion\n\n// #region base64url\nexport const fromBase64Url = !HAS_NATIVE_SUPPORT ? fromBase64UrlPolyfill : fromBase64UrlNative;\nexport const toBase64Url = !HAS_NATIVE_SUPPORT ? toBase64UrlPolyfill : toBase64UrlNative;\n// #endregion\n\n// #region base64urlpad\nexport const fromBase64UrlPad = !HAS_NATIVE_SUPPORT ? fromBase64UrlPadPolyfill : fromBase64UrlPadNative;\nexport const toBase64UrlPad = !HAS_NATIVE_SUPPORT ? toBase64UrlPadPolyfill : toBase64UrlPadNative;\n// #endregion\n","import { allocUnsafe } from '@atcute/uint8array';\n\nexport { toBase32 } from '#bases/base32-encode';\n\nconst ALPHABET = 'abcdefghijklmnopqrstuvwxyz234567';\n\n// #region decode\n\n// charCode -\u003e 5-bit value lookup table, 0xff for invalid characters.\n// valid base32 chars: a-z (97-122) map to 0-25, 2-7 (50-55) map to 26-31.\nconst _decodeLut: Uint8Array = /*#__PURE__*/ (() =\u003e {\n\tconst t = new Uint8Array(128).fill(0xff);\n\tfor (let i = 0; i \u003c 32; i++) {\n\t\tt[ALPHABET.charCodeAt(i)] = i;\n\t}\n\treturn t;\n})();\n\n/**\n * decodes an unpadded RFC 4648 base32 (lowercase) string to a Uint8Array\n * @param str base32 encoded string\n * @returns decoded buffer\n * @throws {SyntaxError} on invalid characters or malformed trailing bits\n */\nexport const fromBase32 = (str: string): Uint8Array\u003cArrayBuffer\u003e =\u003e {\n\tconst end = str.length;\n\tconst bytes = allocUnsafe(((end * 5) / 8) | 0);\n\n\tlet written = 0;\n\tlet i = 0;\n\n\t// process 8-character groups (= 40 bits = 5 bytes each)\n\tconst fullGroups = end - (end % 8);\n\tfor (; i \u003c fullGroups; i += 8) {\n\t\tconst c0 = _decodeLut[str.charCodeAt(i)];\n\t\tconst c1 = _decodeLut[str.charCodeAt(i + 1)];\n\t\tconst c2 = _decodeLut[str.charCodeAt(i + 2)];\n\t\tconst c3 = _decodeLut[str.charCodeAt(i + 3)];\n\t\tconst c4 = _decodeLut[str.charCodeAt(i + 4)];\n\t\tconst c5 = _decodeLut[str.charCodeAt(i + 5)];\n\t\tconst c6 = _decodeLut[str.charCodeAt(i + 6)];\n\t\tconst c7 = _decodeLut[str.charCodeAt(i + 7)];\n\n\t\t// valid base32 values are 0-31 (5 bits), so any value with bits\n\t\t// outside the low 5 means 0xff was in the mix\n\t\tif ((c0 | c1 | c2 | c3 | c4 | c5 | c6 | c7) \u0026 0xe0) {\n\t\t\tthrow new SyntaxError(`invalid base string`);\n\t\t}\n\n\t\tbytes[written] = (c0 \u003c\u003c 3) | (c1 \u003e\u003e\u003e 2);\n\t\tbytes[written + 1] = ((c1 \u003c\u003c 6) | (c2 \u003c\u003c 1) | (c3 \u003e\u003e\u003e 4)) \u0026 0xff;\n\t\tbytes[written + 2] = ((c3 \u003c\u003c 4) | (c4 \u003e\u003e\u003e 1)) \u0026 0xff;\n\t\tbytes[written + 3] = ((c4 \u003c\u003c 7) | (c5 \u003c\u003c 2) | (c6 \u003e\u003e\u003e 3)) \u0026 0xff;\n\t\tbytes[written + 4] = ((c6 \u003c\u003c 5) | c7) \u0026 0xff;\n\t\twritten += 5;\n\t}\n\n\t// handle remaining 1-7 characters\n\tif (i \u003c end) {\n\t\tlet bits = 0;\n\t\tlet buffer = 0;\n\t\tfor (; i \u003c end; ++i) {\n\t\t\tconst value = _decodeLut[str.charCodeAt(i)];\n\t\t\tif (value \u0026 0xe0) {\n\t\t\t\tthrow new SyntaxError(`invalid base string`);\n\t\t\t}\n\t\t\tbuffer = (buffer \u003c\u003c 5) | value;\n\t\t\tbits += 5;\n\t\t\tif (bits \u003e= 8) {\n\t\t\t\tbits -= 8;\n\t\t\t\tbytes[written++] = 0xff \u0026 (buffer \u003e\u003e bits);\n\t\t\t}\n\t\t}\n\n\t\tif (bits \u003e= 5 || (0xff \u0026 (buffer \u003c\u003c (8 - bits))) !== 0) {\n\t\t\tthrow new SyntaxError(`unexpected end of data`);\n\t\t}\n\t}\n\n\treturn bytes;\n};\n\n// #endregion\n","const ALPHABET = 'abcdefghijklmnopqrstuvwxyz234567';\n\n// charCode lookup table: cc[i] = ALPHABET.charCodeAt(i) for i in 0..31\nconst _cc: Uint8Array = /*#__PURE__*/ (() =\u003e {\n\tconst t = new Uint8Array(32);\n\tfor (let i = 0; i \u003c 32; i++) {\n\t\tt[i] = ALPHABET.charCodeAt(i);\n\t}\n\treturn t;\n})();\n\nconst _fromCharCode = String.fromCharCode;\n\n/**\n * encodes a Uint8Array to an unpadded RFC 4648 base32 (lowercase) string\n * @param bytes source buffer\n * @returns base32 encoded string\n */\nexport const toBase32 = (bytes: Uint8Array): string =\u003e {\n\tconst len = bytes.length;\n\tconst full = (len / 5) | 0;\n\tconst rem = len - full * 5;\n\tconst cc = _cc;\n\n\tlet str = '';\n\tlet ip = 0;\n\n\t// process pairs of 5-byte groups (10 bytes → 16 base32 chars) at a time,\n\t// batching into a single String.fromCharCode call for fewer string concats\n\tconst pairs = (full / 2) | 0;\n\tfor (let g = 0; g \u003c pairs; g++) {\n\t\tconst a0 = bytes[ip],\n\t\t\ta1 = bytes[ip + 1],\n\t\t\ta2 = bytes[ip + 2],\n\t\t\ta3 = bytes[ip + 3],\n\t\t\ta4 = bytes[ip + 4];\n\t\tconst b0 = bytes[ip + 5],\n\t\t\tb1 = bytes[ip + 6],\n\t\t\tb2 = bytes[ip + 7],\n\t\t\tb3 = bytes[ip + 8],\n\t\t\tb4 = bytes[ip + 9];\n\n\t\tstr += _fromCharCode(\n\t\t\tcc[a0 \u003e\u003e\u003e 3],\n\t\t\tcc[((a0 \u003c\u003c 2) | (a1 \u003e\u003e\u003e 6)) \u0026 0x1f],\n\t\t\tcc[(a1 \u003e\u003e\u003e 1) \u0026 0x1f],\n\t\t\tcc[((a1 \u003c\u003c 4) | (a2 \u003e\u003e\u003e 4)) \u0026 0x1f],\n\t\t\tcc[((a2 \u003c\u003c 1) | (a3 \u003e\u003e\u003e 7)) \u0026 0x1f],\n\t\t\tcc[(a3 \u003e\u003e\u003e 2) \u0026 0x1f],\n\t\t\tcc[((a3 \u003c\u003c 3) | (a4 \u003e\u003e\u003e 5)) \u0026 0x1f],\n\t\t\tcc[a4 \u0026 0x1f],\n\t\t\tcc[b0 \u003e\u003e\u003e 3],\n\t\t\tcc[((b0 \u003c\u003c 2) | (b1 \u003e\u003e\u003e 6)) \u0026 0x1f],\n\t\t\tcc[(b1 \u003e\u003e\u003e 1) \u0026 0x1f],\n\t\t\tcc[((b1 \u003c\u003c 4) | (b2 \u003e\u003e\u003e 4)) \u0026 0x1f],\n\t\t\tcc[((b2 \u003c\u003c 1) | (b3 \u003e\u003e\u003e 7)) \u0026 0x1f],\n\t\t\tcc[(b3 \u003e\u003e\u003e 2) \u0026 0x1f],\n\t\t\tcc[((b3 \u003c\u003c 3) | (b4 \u003e\u003e\u003e 5)) \u0026 0x1f],\n\t\t\tcc[b4 \u0026 0x1f],\n\t\t);\n\t\tip += 10;\n\t}\n\n\t// remaining full group if odd count\n\tif (full \u0026 1) {\n\t\tconst b0 = bytes[ip],\n\t\t\tb1 = bytes[ip + 1],\n\t\t\tb2 = bytes[ip + 2],\n\t\t\tb3 = bytes[ip + 3],\n\t\t\tb4 = bytes[ip + 4];\n\n\t\tstr += _fromCharCode(\n\t\t\tcc[b0 \u003e\u003e\u003e 3],\n\t\t\tcc[((b0 \u003c\u003c 2) | (b1 \u003e\u003e\u003e 6)) \u0026 0x1f],\n\t\t\tcc[(b1 \u003e\u003e\u003e 1) \u0026 0x1f],\n\t\t\tcc[((b1 \u003c\u003c 4) | (b2 \u003e\u003e\u003e 4)) \u0026 0x1f],\n\t\t\tcc[((b2 \u003c\u003c 1) | (b3 \u003e\u003e\u003e 7)) \u0026 0x1f],\n\t\t\tcc[(b3 \u003e\u003e\u003e 2) \u0026 0x1f],\n\t\t\tcc[((b3 \u003c\u003c 3) | (b4 \u003e\u003e\u003e 5)) \u0026 0x1f],\n\t\t\tcc[b4 \u0026 0x1f],\n\t\t);\n\t\tip += 5;\n\t}\n\n\t// handle remaining 1-4 bytes\n\tif (rem \u003e 0) {\n\t\tlet buffer = 0;\n\t\tlet bits = 0;\n\t\tfor (let i = ip; i \u003c len; i++) {\n\t\t\tbuffer = (buffer \u003c\u003c 8) | bytes[i];\n\t\t\tbits += 8;\n\t\t}\n\t\twhile (bits \u003e= 5) {\n\t\t\tbits -= 5;\n\t\t\tstr += _fromCharCode(cc[(buffer \u003e\u003e\u003e bits) \u0026 0x1f]);\n\t\t}\n\t\tif (bits \u003e 0) {\n\t\t\tstr += _fromCharCode(cc[(buffer \u003c\u003c (5 - bits)) \u0026 0x1f]);\n\t\t}\n\t}\n\n\treturn str;\n};\n","import { createBtcBaseDecode, createBtcBaseEncode } from '../utils.ts';\n\nconst BASE58BTC_CHARSET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n\nexport const fromBase58Btc: (source: string) =\u003e Uint8Array\u003cArrayBuffer\u003e =\n\t/*#__PURE__*/ createBtcBaseDecode(BASE58BTC_CHARSET);\n\nexport const toBase58Btc: (source: Uint8Array) =\u003e string =\n\t/*#__PURE__*/ createBtcBaseEncode(BASE58BTC_CHARSET);\n"],"version":3}
+3
vendor/esm.sh/@atcute/oauth-browser-client@3.0.0/es2022/oauth-browser-client.mjs
··· 1 + /* esm.sh - @atcute/oauth-browser-client@3.0.0 */ 2 + var b=typeof navigator<"u"?navigator.locks:void 0;var ee=t=>{if(t!=null){let e=JSON.parse(t);if(e!=null)return e}return{}},M=({name:t})=>{let e=new AbortController,r=e.signal,s=(o,i,a=!1)=>{let n,u=`${t}:${o}`,h=()=>n&&localStorage.setItem(u,JSON.stringify(n)),d=()=>{if(r.aborted)throw new Error("store closed");return n??=ee(localStorage.getItem(u))};{let p=c=>{c.key===u&&(n=void 0)};globalThis.addEventListener("storage",p,{signal:r})}{let p=async c=>{if(!c||r.aborted||(await new Promise(l=>setTimeout(l,1e4)),r.aborted))return;let f=Date.now(),y=!1;d();for(let l in n){let S=n[l].expiresAt;S!==null&&f>S&&(y=!0,delete n[l])}y&&h()};b?b.request(`${u}:cleanup`,{ifAvailable:!0},p):p(!0)}return{get(p){d();let c=n[p];if(!c)return;let f=c.expiresAt;if(f!==null&&Date.now()>f){delete n[p],h();return}return c.value},getWithLapsed(p){d();let c=n[p],f=Date.now();if(!c)return[void 0,1/0];let y=c.updatedAt;return y===void 0?[c.value,1/0]:[c.value,f-y]},set(p,c){d();let f={value:c,expiresAt:i(c),updatedAt:a?Date.now():void 0};n[p]=f,h()},delete(p){d(),n[p]!==void 0&&(delete n[p],h())},keys(){return d(),Object.keys(n)}}};return{dispose:()=>{e.abort()},sessions:s("sessions",({token:o})=>o.refresh?null:o.expires_at??null),states:s("states",o=>Date.now()+600*1e3),dpopNonces:s("dpopNonces",o=>Date.now()+1440*60*1e3,!0),inflightDpop:new Map}};var A,P,T,w,$,te=t=>{({identityResolver:$,fetchClientAssertion:T}=t),{client_id:A,redirect_uri:P}=t.metadata,w=M({name:t.storageName??"atcute-oauth"})};var x=class extends Error{name="LoginError"},I=class extends Error{name="AuthorizationError"},m=class extends Error{name="ResolverError"},v=class extends Error{sub;name="TokenRefreshError";constructor(e,r,s){super(r,s),this.sub=e}},E=class extends Error{response;data;name="OAuthResponseError";error;description;constructor(e,r){let s=W(B(r)?.error),o=W(B(r)?.error_description),i=s?`"${s}"`:"unknown",a=o?`: ${o}`:"",n=`OAuth ${i} error${a}`;super(n),this.response=e,this.data=r,this.error=s,this.description=o}get status(){return this.response.status}get headers(){return this.response.headers}},j=class extends Error{response;status;name="FetchResponseError";constructor(e,r,s){super(s),this.response=e,this.status=r}},W=t=>typeof t=="string"?t:void 0,B=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0;import{generateDpopKey as ye,generatePkce as ge}from"../../oauth-crypto@0.1.0/es2022/oauth-crypto.mjs";import{nanoid as _e}from"../../../nanoid@5.1.7/es2022/nanoid.mjs";var k=t=>t.get("content-type")?.split(";")[0];var re="parse"in URL,H=t=>{let e=null;if(re)e=URL.parse(t);else try{e=new URL(t)}catch{}return e!==null?e.protocol==="https:"||e.protocol==="http:":!1};var L=async t=>{let e=await $.resolve(t);return{identity:e,metadata:await G(e.pds)}},J=async t=>{try{return{metadata:await G(t)}}catch(e){if(e instanceof m)try{return{metadata:await V(t)}}catch{}throw e}},se=async t=>{let e=new URL("/.well-known/oauth-protected-resource",t),r=await fetch(e.href,{redirect:"manual",headers:{accept:"application/json"}});if(r.status!==200||k(r.headers)!=="application/json")throw new m("unexpected response");let s=await r.json();if(s.resource!==e.origin)throw new m("unexpected issuer");return s},V=async t=>{let e=new URL("/.well-known/oauth-authorization-server",t),r=await fetch(e.href,{redirect:"manual",headers:{accept:"application/json"}});if(r.status!==200||k(r.headers)!=="application/json")throw new m("unexpected response");let s=await r.json();if(s.issuer!==e.origin)throw new m("unexpected issuer");if(!H(s.authorization_endpoint))throw new m("authorization server provided incorrect authorization endpoint");if(!s.client_id_metadata_document_supported)throw new m("authorization server does not support 'client_id_metadata_document'");if(!s.pushed_authorization_request_endpoint)throw new m("authorization server does not support 'pushed_authorization request'");if(s.response_types_supported&&!s.response_types_supported.includes("code"))throw new m("authorization server does not support 'code' response type");return s},G=async t=>{let e=await se(t);if(e.authorization_servers?.length!==1)throw new m("expected exactly one authorization server in the listing");let r=e.authorization_servers[0],s=await V(r);if(s.protected_resources&&!s.protected_resources.includes(e.resource))throw new m("server is not in authorization server's jurisdiction");return s};import{createDpopProofSigner as ae}from"../../oauth-crypto@0.1.0/es2022/oauth-crypto.mjs";import{createDpopProofSigner as oe,sha256Base64Url as ne}from"../../oauth-crypto@0.1.0/es2022/oauth-crypto.mjs";var U=(t,e)=>{let r=w.dpopNonces,s=w.inflightDpop,o=oe(t);return async(i,a)=>{let n=new Request(i,a),u=n.headers.get("authorization"),h=u?.startsWith("DPoP ")?await ne(u.slice(5)):void 0,{method:d,url:p}=n,{origin:c,pathname:f}=new URL(p),y=c+f,l=s.get(c);l&&(await l.promise,l=void 0);let z,S=!1;try{let[D,g]=r.getWithLapsed(c);z=D,S=g>180*1e3}catch{}S&&s.set(c,l=Promise.withResolvers());let R;try{let D=await o(d,y,z,h);n.headers.set("dpop",D);let g=await fetch(n);if(R=g.headers.get("dpop-nonce"),R===null||R===z)return g;try{r.set(c,R)}catch{}if(!await ie(g,e)||i===n||a?.body instanceof ReadableStream)return g}finally{l&&(s.delete(c),l.resolve())}{let D=await o(d,y,R,h),g=new Request(i,a);g.headers.set("dpop",D);let C=await fetch(g),O=C.headers.get("dpop-nonce");if(O!==null&&O!==R)try{r.set(c,O)}catch{}return C}}},ie=async(t,e)=>{if((e===void 0||e===!1)&&t.status===401){let r=t.headers.get("www-authenticate");if(r?.startsWith("DPoP"))return r.includes('error="use_dpop_nonce"')}if((e===void 0||e===!0)&&t.status===400&&k(t.headers)==="application/json")try{let r=await t.clone().json();return typeof r=="object"&&r?.error==="use_dpop_nonce"}catch{return!1}return!1};var Q=(t,e)=>{let r={};for(let s=0,o=e.length;s<o;s++){let i=e[s];r[i]=t[i]}return r};var _=class{#t;#e;#r;constructor(e,r){this.#e=e,this.#r=r,this.#t=U(r,!0)}async request(e,r){let s=this.#e[`${e}_endpoint`];if(!s)throw new Error(`no endpoint for ${e}`);if((e==="token"||e==="pushed_authorization_request")&&T!==void 0){let a=ae(this.#r),n=await T({aud:this.#e.issuer,createDpopProof:async(u,h)=>await a("POST",u,h,void 0)});r={...r,...n}}let o=await this.#t(s,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({...r,client_id:A})});if(k(o.headers)!=="application/json")throw new j(o,2,"unexpected content-type");let i=await o.json();if(o.ok)return i;throw new E(o,i)}async revoke(e){try{await this.request("revocation",{token:e})}catch{}}async exchangeCode(e,r){let s=await this.request("token",{grant_type:"authorization_code",redirect_uri:P,code:e,code_verifier:r});try{return await this.#o(s)}catch(o){throw await this.revoke(s.access_token),o}}async refresh({sub:e,token:r}){if(!r.refresh)throw new v(e,"no refresh token available");let s=await this.request("token",{grant_type:"refresh_token",refresh_token:r.refresh});try{if(e!==s.sub)throw new v(e,`sub mismatch in token response; got ${s.sub}`);return this.#s(s)}catch(o){throw await this.revoke(s.access_token),o}}#s(e){if(!e.sub)throw new TypeError("missing sub field in token response");if(!e.scope)throw new TypeError("missing scope field in token response");if(e.token_type!=="DPoP")throw new TypeError("token response returned a non-dpop token");return{scope:e.scope,refresh:e.refresh_token,access:e.access_token,type:e.token_type,expires_at:typeof e.expires_in=="number"?Date.now()+e.expires_in*1e3:void 0}}async#o(e){let r=e.sub;if(!r)throw new TypeError("missing sub field in token response");let s=this.#s(e),o=await L(r);if(o.metadata.issuer!==this.#e.issuer)throw new TypeError(`issuer mismatch; got ${o.metadata.issuer}`);return{token:s,info:{sub:r,aud:o.identity.pds,server:Q(o.metadata,["issuer","authorization_endpoint","introspection_endpoint","pushed_authorization_request_endpoint","revocation_endpoint","token_endpoint"])}}}};import{fromBase64Url as ce}from"../../multibase@1.2.0/es2022/multibase.mjs";var pe={name:"ECDSA",namedCurve:"P-256"},X=t=>typeof t.key=="string"&&typeof t.jwt=="string",Y=async t=>{let e=ce(t.key),r=await crypto.subtle.importKey("pkcs8",e,pe,!0,["sign"]),s=await crypto.subtle.exportKey("jwk",r);return s.alg="ES256",s};var q=new Map,K=async(t,e)=>{e?.signal?.throwIfAborted();let r=we;e?.noCache?r=le:e?.allowStale&&(r=de);let s;for(;s=q.get(t);){try{let{isFresh:n,value:u}=await s;if(n||r(u))return u}catch{}e?.signal?.throwIfAborted()}let o=async()=>{let n=await me(t,w.sessions.get(t));if(n&&r(n))return{isFresh:!1,value:n};let u=await he(t,n);return await F(t,u),{isFresh:!0,value:u}},i;if(b?i=b.request(`atcute-oauth:${t}`,o):i=o(),i=i.finally(()=>q.delete(t)),q.has(t))throw new Error("concurrent request for the same key");q.set(t,i);let{value:a}=await i;return a},F=async(t,e)=>{try{w.sessions.set(t,e)}catch(r){throw await fe(e),r}},N=t=>{w.sessions.delete(t)},ue=()=>w.sessions.keys(),de=()=>!0,le=()=>!1,he=async(t,e)=>{if(e===void 0)throw new v(t,"session deleted by another tab");let{dpopKey:r,info:s,token:o}=e,i=new _(s.server,r);try{let a=await i.refresh({sub:s.sub,token:o});return{dpopKey:r,info:s,token:a}}catch(a){throw a instanceof E&&a.status===400&&a.error==="invalid_grant"?new v(t,"session was revoked",{cause:a}):a}},fe=async({dpopKey:t,info:e,token:r})=>{await new _(e.server,t).revoke(r.refresh??r.access)},we=({token:t})=>{let e=t.expires_at;return e==null||Date.now()+6e4<=e},me=async(t,e)=>{if(!e||!X(e.dpopKey))return e;let r=await Y(e.dpopKey),s={...e,dpopKey:r};try{w.sessions.set(t,s)}catch{}return s};var ct=async t=>{let{target:e,scope:r,state:s=null,...o}=t,i;switch(e.type){case"account":{i=await L(e.identifier);break}case"pds":i=await J(e.serviceUrl)}let{identity:a,metadata:n}=i,u=a?a.handle!=="handle.invalid"?a.handle:a.did:void 0,h=_e(24),d=await ge(),p=await ye(["ES256"]),c={display:o.display,ui_locales:o.locale,prompt:o.prompt,redirect_uri:P,code_challenge:d.challenge,code_challenge_method:d.method,state:h,login_hint:u,response_mode:"fragment",response_type:"code",scope:r};w.states.set(h,{dpopKey:p,metadata:n,verifier:d.verifier,state:s});let y=await new _(n,p).request("pushed_authorization_request",c),l=new URL(n.authorization_endpoint);return l.searchParams.set("client_id",A),l.searchParams.set("request_uri",y.request_uri),l},pt=async t=>{let e=t.get("iss"),r=t.get("state"),s=t.get("code"),o=t.get("error");if(!r||!(s||o))throw new x("missing parameters");let i=w.states.get(r);if(i)w.states.delete(r);else throw new x("unknown state provided");if(o)throw new I(t.get("error_description")||o);if(!s)throw new x("missing code parameter");let a=i.dpopKey,n=i.metadata,u=i.state??null;if(e===null)throw new x("missing issuer parameter");if(e!==n.issuer)throw new x("issuer mismatch");let h=new _(n,a),{info:d,token:p}=await h.exchangeCode(s,i.verifier),c=d.sub,f={dpopKey:a,info:d,token:p};return await F(c,f),{session:f,state:u}};var Z=class{session;#t;#e;constructor(e){this.session=e,this.#t=U(e.dpopKey,!1)}get sub(){return this.session.info.sub}getSession(e){let r=K(this.session.info.sub,e);return r.then(s=>{this.session=s}).finally(()=>{this.#e=void 0}),this.#e=r}async signOut(){let e=this.session.info.sub;try{let{dpopKey:r,info:s,token:o}=await K(e,{allowStale:!0});await new _(s.server,r).revoke(o.refresh??o.access)}finally{N(e)}}async handle(e,r){await this.#e;let s=new Headers(r?.headers),o=this.session,i=new URL(e,o.info.aud);s.set("authorization",`${o.token.type} ${o.token.access}`);let a=await this.#t(i.href,{...r,headers:s});if(!xe(a))return a;try{this.#e?o=await this.#e:o=await this.getSession()}catch{return a}return r?.body instanceof ReadableStream?a:(i=new URL(e,o.info.aud),s.set("authorization",`${o.token.type} ${o.token.access}`),await this.#t(i.href,{...r,headers:s}))}},xe=t=>{if(t.status!==401)return!1;let e=t.headers.get("www-authenticate");return e!=null&&(e.startsWith("Bearer ")||e.startsWith("DPoP "))&&e.includes('error="invalid_token"')};export{I as AuthorizationError,j as FetchResponseError,x as LoginError,E as OAuthResponseError,Z as OAuthUserAgent,m as ResolverError,v as TokenRefreshError,te as configureOAuth,ct as createAuthorizationUrl,N as deleteStoredSession,pt as finalizeAuthorization,K as getSession,ue as listStoredSessions}; 3 + //# sourceMappingURL=./oauth-browser-client.mjs.map
+1
vendor/esm.sh/@atcute/oauth-browser-client@3.0.0/es2022/oauth-browser-client.mjs.map
··· 1 + {"mappings":";AAAO,IAAMA,EAAiC,OAAO,UAAc,IAAc,UAAU,MAAQ,OC0CnG,IAAMC,GAASC,GAAuB,CACrC,GAAIA,GAAO,KAAM,CAChB,IAAMC,EAAS,KAAK,MAAMD,CAAG,EAC7B,GAAIC,GAAU,KACb,OAAOA,CAET,CAEA,MAAO,CAAA,CAAG,EAKEC,EAAsB,CAAC,CAAE,KAAAC,CAAI,IAA6B,CACtE,IAAMC,EAAa,IAAI,gBACjBC,EAASD,EAAW,OAEpBE,EAAc,CACnBC,EACAC,EACAC,EAAmB,KACoC,CACvD,IAAIC,EAEEC,EAAa,GAAGR,CAAI,IAAII,CAAO,GAE/BK,EAAU,IAAMF,GAAS,aAAa,QAAQC,EAAY,KAAK,UAAUD,CAAK,CAAC,EAC/EG,EAAO,IAAM,CAClB,GAAIR,EAAO,QACV,MAAM,IAAI,MAAM,cAAc,EAG/B,OAAQK,IAAUX,GAAM,aAAa,QAAQY,CAAU,CAAC,CAAG,EA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AE,EAE5E,IAAIe,EAAW,MAAM,KAAKjB,GAAOgB,EAAI,KAAM,CAAE,GAAGF,EAAM,QAAAC,CAAO,CAAE,EAC/D,GAAI,CAACG,GAAuBD,CAAQ,EACnC,OAAOA,EAGR,GAAI,CACC,KAAKhB,GACRC,EAAU,MAAM,KAAKD,GAErBC,EAAU,MAAM,KAAK,WAAU,CAEjC,MAAQ,CACP,OAAOe,CACR,CAGA,OAAIH,GAAM,gBAAgB,eAClBG,GAGRD,EAAM,IAAI,IAAIH,EAAUX,EAAQ,KAAK,GAAG,EACxCa,EAAQ,IAAI,gBAAiB,GAAGb,EAAQ,MAAM,IAAI,IAAIA,EAAQ,MAAM,MAAM,EAAE,EAErE,MAAM,KAAKF,GAAOgB,EAAI,KAAM,CAAE,GAAGF,EAAM,QAAAC,CAAO,CAAE,EAAE,GAIrDG,GAA0BD,GAAuB,CACtD,GAAIA,EAAS,SAAW,IACvB,MAAO,GAGR,IAAME,EAAOF,EAAS,QAAQ,IAAI,kBAAkB,EAEpD,OACCE,GAAQ,OACPA,EAAK,WAAW,SAAS,GAAKA,EAAK,WAAW,OAAO,IACtDA,EAAK,SAAS,uBAAuB,CACpC","names":["locks","parse","raw","parsed","createOAuthDatabase","name","controller","signal","createStore","subname","expiresAt","persistUpdatedAt","store","storageKey","persist","read","listener","ev","cleanup","lock","resolve","now","changed","key","locks","item","updatedAt","value","token","_item","CLIENT_ID","REDIRECT_URI","fetchClientAssertion","database","identityResolver","configureOAuth","options","createOAuthDatabase","LoginError","AuthorizationError","ResolverError","TokenRefreshError","sub","message","options","OAuthResponseError","response","data","error","ifString","ifObject","errorDescription","messageError","messageDesc","FetchResponseError","status","v","generateDpopKey","generatePkce","nanoid","extractContentType","headers","isUrlParseSupported","isValidUrl","urlString","url","resolveFromIdentifier","ident","identity","identityResolver","getMetadataFromResourceServer","resolveFromService","host","err","ResolverError","getOAuthAuthorizationServerMetadata","getOAuthProtectedResourceMetadata","url","response","extractContentType","metadata","isValidUrl","input","rs_metadata","issuer","as_metadata","createDpopProofSigner","createDpopProofSigner","sha256Base64Url","createDPoPFetch","dpopKey","isAuthServer","nonces","database","pending","sign","createDpopProofSigner","input","init","request","authorizationHeader","ath","sha256Base64Url","method","url","origin","pathname","htu","deferred","initNonce","expiredOrMissing","nonce","lapsed","nextNonce","initProof","initResponse","isUseDpopNonceError","nextProof","nextRequest","retryResponse","retryNonce","response","wwwAuth","extractContentType","json","pick","obj","keys","cloned","idx","len","key","OAuthServerAgent","#fetch","#metadata","#dpopKey","metadata","dpopKey","createDPoPFetch","endpoint","payload","url","fetchClientAssertion","sign","createDpopProofSigner","assertion","nonce","response","CLIENT_ID","extractContentType","FetchResponseError","json","OAuthResponseError","token","code","verifier","REDIRECT_URI","#processExchangeResponse","err","sub","TokenRefreshError","#processTokenResponse","res","resolved","resolveFromIdentifier","pick","fromBase64Url","ES256_ALG","isLegacyDpopKey","key","migrateLegacyDpopKey","pkcs8","cryptoKey","jwk","pending","getSession","sub","options","allowStored","isTokenUsable","returnFalse","returnTrue","previousExecutionFlow","isFresh","value","run","storedSession","migrateSessionIfNeeded","database","newSession","refreshToken","storeSession","promise","locks","err","onRefreshError","deleteStoredSession","listStoredSessions","TokenRefreshError","dpopKey","info","token","server","OAuthServerAgent","newToken","cause","OAuthResponseError","expires","session","isLegacyDpopKey","migrateLegacyDpopKey","migrated","createAuthorizationUrl","options","target","scope","state","reqs","resolved","resolveFromIdentifier","resolveFromService","identity","metadata","loginHint","sid","nanoid","pkce","generatePkce","dpopKey","generateDpopKey","params","REDIRECT_URI","database","response","OAuthServerAgent","authUrl","CLIENT_ID","finalizeAuthorization","issuer","code","error","LoginError","stored","AuthorizationError","server","info","token","sub","session","storeSession","OAuthUserAgent","#fetch","#getSessionPromise","session","createDPoPFetch","options","promise","getSession","sub","dpopKey","info","token","OAuthServerAgent","deleteStoredSession","pathname","init","headers","url","response","isInvalidTokenResponse","auth"],"sources":["../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/utils/runtime.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/store/db.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/environment.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/errors.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/agents/exchange.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/utils/response.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/utils/strings.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/resolvers.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/agents/server-agent.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/dpop.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/utils/misc.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/utils/dpop-key.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/agents/sessions.ts","../esm/npm/@atcute/oauth-browser-client@3.0.0/node_modules/@atcute/oauth-browser-client/lib/agents/user-agent.ts"],"sourcesContent":["export const locks: LockManager | undefined = typeof navigator !== 'undefined' ? navigator.locks : undefined;\n","import type { Did } from '@atcute/lexicons';\nimport type { DpopPrivateJwk } from '@atcute/oauth-crypto';\nimport type { OAuthAuthorizationServerMetadata } from '@atcute/oauth-types';\n\nimport type { SimpleStore } from '../types/store.js';\nimport type { RawSession } from '../types/token.js';\nimport { locks } from '../utils/runtime.js';\n\nexport interface OAuthDatabaseOptions {\n\tname: string;\n}\n\ninterface SchemaItem\u003cT\u003e {\n\tvalue: T;\n\texpiresAt: number | null;\n\tupdatedAt?: number;\n}\n\ninterface Schema {\n\tsessions: {\n\t\tkey: Did;\n\t\tvalue: RawSession;\n\t\tindexes: {\n\t\t\texpiresAt: number;\n\t\t};\n\t};\n\tstates: {\n\t\tkey: string;\n\t\tvalue: {\n\t\t\tdpopKey: DpopPrivateJwk;\n\t\t\tmetadata: OAuthAuthorizationServerMetadata;\n\t\t\tverifier?: string;\n\t\t\tstate?: unknown;\n\t\t};\n\t};\n\n\tdpopNonces: {\n\t\tkey: string;\n\t\tvalue: string;\n\t};\n}\n\nconst parse = (raw: string | null) =\u003e {\n\tif (raw != null) {\n\t\tconst parsed = JSON.parse(raw);\n\t\tif (parsed != null) {\n\t\t\treturn parsed;\n\t\t}\n\t}\n\n\treturn {};\n};\n\nexport type OAuthDatabase = ReturnType\u003ctypeof createOAuthDatabase\u003e;\n\nexport const createOAuthDatabase = ({ name }: OAuthDatabaseOptions) =\u003e {\n\tconst controller = new AbortController();\n\tconst signal = controller.signal;\n\n\tconst createStore = \u003cN extends keyof Schema\u003e(\n\t\tsubname: N,\n\t\texpiresAt: (item: Schema[N]['value']) =\u003e null | number,\n\t\tpersistUpdatedAt = false,\n\t): SimpleStore\u003cSchema[N]['key'], Schema[N]['value']\u003e =\u003e {\n\t\tlet store: any;\n\n\t\tconst storageKey = `${name}:${subname}`;\n\n\t\tconst persist = () =\u003e store \u0026\u0026 localStorage.setItem(storageKey, JSON.stringify(store));\n\t\tconst read = () =\u003e {\n\t\t\tif (signal.aborted) {\n\t\t\t\tthrow new Error(`store closed`);\n\t\t\t}\n\n\t\t\treturn (store ??= parse(localStorage.getItem(storageKey)));\n\t\t};\n\n\t\t{\n\t\t\tconst listener = (ev: StorageEvent) =\u003e {\n\t\t\t\tif (ev.key === storageKey) {\n\t\t\t\t\tstore = undefined;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tglobalThis.addEventListener('storage', listener, { signal });\n\t\t}\n\n\t\t{\n\t\t\tconst cleanup = async (lock: Lock | true | null) =\u003e {\n\t\t\t\tif (!lock || signal.aborted) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tawait new Promise((resolve) =\u003e setTimeout(resolve, 10_000));\n\t\t\t\tif (signal.aborted) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet now = Date.now();\n\t\t\t\tlet changed = false;\n\n\t\t\t\tread();\n\n\t\t\t\tfor (const key in store) {\n\t\t\t\t\tconst item = store[key];\n\t\t\t\t\tconst expiresAt = item.expiresAt;\n\n\t\t\t\t\tif (expiresAt !== null \u0026\u0026 now \u003e expiresAt) {\n\t\t\t\t\t\tchanged = true;\n\t\t\t\t\t\tdelete store[key];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (changed) {\n\t\t\t\t\tpersist();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (locks) {\n\t\t\t\tlocks.request(`${storageKey}:cleanup`, { ifAvailable: true }, cleanup);\n\t\t\t} else {\n\t\t\t\tcleanup(true);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tget(key) {\n\t\t\t\tread();\n\n\t\t\t\tconst item: SchemaItem\u003cSchema[N]['value']\u003e = store[key];\n\t\t\t\tif (!item) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst expiresAt = item.expiresAt;\n\t\t\t\tif (expiresAt !== null \u0026\u0026 Date.now() \u003e expiresAt) {\n\t\t\t\t\tdelete store[key];\n\t\t\t\t\tpersist();\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treturn item.value;\n\t\t\t},\n\t\t\tgetWithLapsed(key) {\n\t\t\t\tread();\n\n\t\t\t\tconst item: SchemaItem\u003cSchema[N]['value']\u003e = store[key];\n\t\t\t\tconst now = Date.now();\n\t\t\t\tif (!item) {\n\t\t\t\t\treturn [undefined, Infinity];\n\t\t\t\t}\n\n\t\t\t\tconst updatedAt = item.updatedAt;\n\t\t\t\tif (updatedAt === undefined) {\n\t\t\t\t\treturn [item.value, Infinity];\n\t\t\t\t}\n\n\t\t\t\treturn [item.value, now - updatedAt];\n\t\t\t},\n\t\t\tset(key, value) {\n\t\t\t\tread();\n\n\t\t\t\tconst item: SchemaItem\u003cSchema[N]['value']\u003e = {\n\t\t\t\t\tvalue: value,\n\t\t\t\t\texpiresAt: expiresAt(value),\n\t\t\t\t\tupdatedAt: persistUpdatedAt ? Date.now() : undefined,\n\t\t\t\t};\n\n\t\t\t\tstore[key] = item;\n\t\t\t\tpersist();\n\t\t\t},\n\t\t\tdelete(key) {\n\t\t\t\tread();\n\n\t\t\t\tif (store[key] !== undefined) {\n\t\t\t\t\tdelete store[key];\n\t\t\t\t\tpersist();\n\t\t\t\t}\n\t\t\t},\n\t\t\tkeys() {\n\t\t\t\tread();\n\n\t\t\t\treturn Object.keys(store);\n\t\t\t},\n\t\t};\n\t};\n\n\treturn {\n\t\tdispose: () =\u003e {\n\t\t\tcontroller.abort();\n\t\t},\n\n\t\tsessions: createStore('sessions', ({ token }) =\u003e {\n\t\t\tif (token.refresh) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn token.expires_at ?? null;\n\t\t}),\n\t\tstates: createStore('states', (_item) =\u003e Date.now() + 10 * 60 * 1_000), // 10 minutes\n\n\t\t// The reference PDS have nonces that expire after 3 minutes, while other\n\t\t// implementations can have varying expiration times.\n\t\t// Stored for 24 hours.\n\t\tdpopNonces: createStore('dpopNonces', (_item) =\u003e Date.now() + 24 * 60 * 60 * 1_000, true),\n\t\tinflightDpop: new Map\u003cstring, PromiseWithResolvers\u003cvoid\u003e\u003e(),\n\t};\n};\n","import type { ActorResolver } from '@atcute/identity-resolver';\n\nimport { createOAuthDatabase, type OAuthDatabase } from './store/db.js';\nimport type { ClientAssertionFetcher } from './types/client-assertion.js';\n\nexport let CLIENT_ID: string;\nexport let REDIRECT_URI: string;\n\nexport let fetchClientAssertion: ClientAssertionFetcher | undefined;\n\nexport let database: OAuthDatabase;\n\nexport let identityResolver: ActorResolver;\n\nexport interface ConfigureOAuthOptions {\n\t/**\n\t * client metadata, necessary to drive the whole request\n\t */\n\tmetadata: {\n\t\tclient_id: string;\n\t\tredirect_uri: string;\n\t};\n\n\t/** resolves actor identifiers into identity metadata */\n\tidentityResolver: ActorResolver;\n\n\t/**\n\t * optional function to fetch DPoP-bound client assertions from your backend.\n\t */\n\tfetchClientAssertion?: ClientAssertionFetcher;\n\n\t/**\n\t * name that will be used as prefix for storage keys needed to persist authentication.\n\t * @default \"atcute-oauth\"\n\t */\n\tstorageName?: string;\n}\n\nexport const configureOAuth = (options: ConfigureOAuthOptions) =\u003e {\n\t({ identityResolver, fetchClientAssertion } = options);\n\t({ client_id: CLIENT_ID, redirect_uri: REDIRECT_URI } = options.metadata);\n\n\tdatabase = createOAuthDatabase({ name: options.storageName ?? 'atcute-oauth' });\n};\n","import type { Did } from '@atcute/lexicons';\n\nexport class LoginError extends Error {\n\toverride name = 'LoginError';\n}\n\nexport class AuthorizationError extends Error {\n\toverride name = 'AuthorizationError';\n}\n\nexport class ResolverError extends Error {\n\toverride name = 'ResolverError';\n}\n\nexport class TokenRefreshError extends Error {\n\toverride name = 'TokenRefreshError';\n\n\tconstructor(\n\t\tpublic readonly sub: Did,\n\t\tmessage: string,\n\t\toptions?: ErrorOptions,\n\t) {\n\t\tsuper(message, options);\n\t}\n}\n\nexport class OAuthResponseError extends Error {\n\toverride name = 'OAuthResponseError';\n\n\treadonly error: string | undefined;\n\treadonly description: string | undefined;\n\n\tconstructor(\n\t\tpublic readonly response: Response,\n\t\tpublic readonly data: any,\n\t) {\n\t\tconst error = ifString(ifObject(data)?.['error']);\n\t\tconst errorDescription = ifString(ifObject(data)?.['error_description']);\n\n\t\tconst messageError = error ? `\"${error}\"` : 'unknown';\n\t\tconst messageDesc = errorDescription ? `: ${errorDescription}` : '';\n\t\tconst message = `OAuth ${messageError} error${messageDesc}`;\n\n\t\tsuper(message);\n\n\t\tthis.error = error;\n\t\tthis.description = errorDescription;\n\t}\n\n\tget status() {\n\t\treturn this.response.status;\n\t}\n\n\tget headers() {\n\t\treturn this.response.headers;\n\t}\n}\n\nexport class FetchResponseError extends Error {\n\toverride name = 'FetchResponseError';\n\n\tconstructor(\n\t\tpublic readonly response: Response,\n\t\tpublic status: number,\n\t\tmessage: string,\n\t) {\n\t\tsuper(message);\n\t}\n}\n\nconst ifString = (v: unknown): string | undefined =\u003e {\n\treturn typeof v === 'string' ? v : undefined;\n};\nconst ifObject = (v: unknown): Record\u003cstring, unknown\u003e | undefined =\u003e {\n\treturn typeof v === 'object' \u0026\u0026 v !== null \u0026\u0026 !Array.isArray(v) ? (v as any) : undefined;\n};\n","import type { ResolvedActor } from '@atcute/identity-resolver';\nimport type { ActorIdentifier } from '@atcute/lexicons';\nimport { generateDpopKey, generatePkce } from '@atcute/oauth-crypto';\nimport type { OAuthAuthorizationServerMetadata, OAuthPrompt } from '@atcute/oauth-types';\n\nimport { nanoid } from 'nanoid';\n\nimport { CLIENT_ID, database, REDIRECT_URI } from '../environment.js';\nimport { AuthorizationError, LoginError } from '../errors.js';\nimport { resolveFromIdentifier, resolveFromService } from '../resolvers.js';\nimport type { Session } from '../types/token.js';\n\nimport { OAuthServerAgent } from './server-agent.js';\nimport { storeSession } from './sessions.js';\n\nexport type AuthorizeTargetOptions =\n\t| { type: 'account'; identifier: ActorIdentifier }\n\t| { type: 'pds'; serviceUrl: string };\n\nexport interface AuthorizeOptions {\n\ttarget: AuthorizeTargetOptions;\n\tscope: string;\n\tstate?: unknown;\n\tprompt?: OAuthPrompt | (string \u0026 {});\n\tdisplay?: 'page' | 'popup' | 'touch' | 'wap';\n\tlocale?: string;\n}\n\n/**\n * Create authentication URL for authorization\n * @param options\n * @returns URL to redirect the user for authorization\n */\nexport const createAuthorizationUrl = async (options: AuthorizeOptions): Promise\u003cURL\u003e =\u003e {\n\tconst { target, scope, state = null, ...reqs } = options;\n\n\tlet resolved: { identity?: ResolvedActor; metadata: OAuthAuthorizationServerMetadata };\n\tswitch (target.type) {\n\t\tcase 'account': {\n\t\t\tresolved = await resolveFromIdentifier(target.identifier);\n\t\t\tbreak;\n\t\t}\n\t\tcase 'pds': {\n\t\t\tresolved = await resolveFromService(target.serviceUrl);\n\t\t}\n\t}\n\n\tconst { identity, metadata } = resolved;\n\tconst loginHint = identity\n\t\t? identity.handle !== 'handle.invalid'\n\t\t\t? identity.handle\n\t\t\t: identity.did\n\t\t: undefined;\n\n\tconst sid = nanoid(24);\n\n\tconst pkce = await generatePkce();\n\tconst dpopKey = await generateDpopKey(['ES256']);\n\n\tconst params = {\n\t\tdisplay: reqs.display,\n\t\tui_locales: reqs.locale,\n\t\tprompt: reqs.prompt,\n\n\t\tredirect_uri: REDIRECT_URI,\n\t\tcode_challenge: pkce.challenge,\n\t\tcode_challenge_method: pkce.method,\n\t\tstate: sid,\n\t\tlogin_hint: loginHint,\n\t\tresponse_mode: 'fragment',\n\t\tresponse_type: 'code',\n\t\tscope: scope,\n\t} satisfies Record\u003cstring, string | undefined\u003e;\n\n\tdatabase.states.set(sid, {\n\t\tdpopKey: dpopKey,\n\t\tmetadata: metadata,\n\t\tverifier: pkce.verifier,\n\t\tstate: state,\n\t});\n\n\tconst server = new OAuthServerAgent(metadata, dpopKey);\n\tconst response = await server.request('pushed_authorization_request', params);\n\n\tconst authUrl = new URL(metadata.authorization_endpoint);\n\tauthUrl.searchParams.set('client_id', CLIENT_ID);\n\tauthUrl.searchParams.set('request_uri', response.request_uri);\n\n\treturn authUrl;\n};\n\n/**\n * Finalize authorization\n * @param params Search params\n * @returns Session object, which you can use to instantiate user agents\n */\nexport const finalizeAuthorization = async (params: URLSearchParams) =\u003e {\n\tconst issuer = params.get('iss');\n\tconst sid = params.get('state');\n\tconst code = params.get('code');\n\tconst error = params.get('error');\n\n\tif (!sid || !(code || error)) {\n\t\tthrow new LoginError(`missing parameters`);\n\t}\n\n\tconst stored = database.states.get(sid);\n\tif (stored) {\n\t\t// Delete now that we've caught it\n\t\tdatabase.states.delete(sid);\n\t} else {\n\t\tthrow new LoginError(`unknown state provided`);\n\t}\n\n\tif (error) {\n\t\tthrow new AuthorizationError(params.get('error_description') || error);\n\t}\n\tif (!code) {\n\t\tthrow new LoginError(`missing code parameter`);\n\t}\n\n\tconst dpopKey = stored.dpopKey;\n\tconst metadata = stored.metadata;\n\tconst state = stored.state ?? null;\n\n\tif (issuer === null) {\n\t\tthrow new LoginError(`missing issuer parameter`);\n\t} else if (issuer !== metadata.issuer) {\n\t\tthrow new LoginError(`issuer mismatch`);\n\t}\n\n\t// Retrieve authentication tokens\n\tconst server = new OAuthServerAgent(metadata, dpopKey);\n\tconst { info, token } = await server.exchangeCode(code, stored.verifier);\n\n\t// We're finished!\n\tconst sub = info.sub;\n\tconst session: Session = { dpopKey, info, token };\n\n\tawait storeSession(sub, session);\n\n\treturn { session, state };\n};\n","export const extractContentType = (headers: Headers): string | undefined =\u003e {\n\treturn headers.get('content-type')?.split(';')[0];\n};\n","const isUrlParseSupported = 'parse' in URL;\n\nexport const isValidUrl = (urlString: string): boolean =\u003e {\n\tlet url: URL | null = null;\n\tif (isUrlParseSupported) {\n\t\turl = URL.parse(urlString);\n\t} else {\n\t\ttry {\n\t\t\turl = new URL(urlString);\n\t\t} catch {}\n\t}\n\n\tif (url !== null) {\n\t\treturn url.protocol === 'https:' || url.protocol === 'http:';\n\t}\n\n\treturn false;\n};\n","import type { ResolvedActor } from '@atcute/identity-resolver';\nimport type { ActorIdentifier } from '@atcute/lexicons';\nimport type { OAuthAuthorizationServerMetadata, OAuthProtectedResourceMetadata } from '@atcute/oauth-types';\n\nimport { identityResolver } from './environment.js';\nimport { ResolverError } from './errors.js';\nimport { extractContentType } from './utils/response.js';\nimport { isValidUrl } from './utils/strings.js';\n\nexport const resolveFromIdentifier = async (\n\tident: ActorIdentifier,\n): Promise\u003c{ identity: ResolvedActor; metadata: OAuthAuthorizationServerMetadata }\u003e =\u003e {\n\tconst identity = await identityResolver.resolve(ident);\n\n\treturn {\n\t\tidentity: identity,\n\t\tmetadata: await getMetadataFromResourceServer(identity.pds),\n\t};\n};\n\nexport const resolveFromService = async (\n\thost: string,\n): Promise\u003c{ metadata: OAuthAuthorizationServerMetadata }\u003e =\u003e {\n\ttry {\n\t\tconst metadata = await getMetadataFromResourceServer(host);\n\t\treturn { metadata };\n\t} catch (err) {\n\t\tif (err instanceof ResolverError) {\n\t\t\ttry {\n\t\t\t\tconst metadata = await getOAuthAuthorizationServerMetadata(host);\n\t\t\t\treturn { metadata };\n\t\t\t} catch {}\n\t\t}\n\n\t\tthrow err;\n\t}\n};\n\nconst getOAuthProtectedResourceMetadata = async (host: string): Promise\u003cOAuthProtectedResourceMetadata\u003e =\u003e {\n\tconst url = new URL(`/.well-known/oauth-protected-resource`, host);\n\tconst response = await fetch(url.href, {\n\t\tredirect: 'manual',\n\t\theaders: {\n\t\t\taccept: 'application/json',\n\t\t},\n\t});\n\n\tif (response.status !== 200 || extractContentType(response.headers) !== 'application/json') {\n\t\tthrow new ResolverError(`unexpected response`);\n\t}\n\n\tconst metadata = (await response.json()) as OAuthProtectedResourceMetadata;\n\tif (metadata.resource !== url.origin) {\n\t\tthrow new ResolverError(`unexpected issuer`);\n\t}\n\n\treturn metadata;\n};\n\nconst getOAuthAuthorizationServerMetadata = async (\n\thost: string,\n): Promise\u003cOAuthAuthorizationServerMetadata\u003e =\u003e {\n\tconst url = new URL(`/.well-known/oauth-authorization-server`, host);\n\tconst response = await fetch(url.href, {\n\t\tredirect: 'manual',\n\t\theaders: {\n\t\t\taccept: 'application/json',\n\t\t},\n\t});\n\n\tif (response.status !== 200 || extractContentType(response.headers) !== 'application/json') {\n\t\tthrow new ResolverError(`unexpected response`);\n\t}\n\n\tconst metadata = (await response.json()) as OAuthAuthorizationServerMetadata;\n\tif (metadata.issuer !== url.origin) {\n\t\tthrow new ResolverError(`unexpected issuer`);\n\t}\n\tif (!isValidUrl(metadata.authorization_endpoint)) {\n\t\tthrow new ResolverError(`authorization server provided incorrect authorization endpoint`);\n\t}\n\tif (!metadata.client_id_metadata_document_supported) {\n\t\tthrow new ResolverError(`authorization server does not support 'client_id_metadata_document'`);\n\t}\n\tif (!metadata.pushed_authorization_request_endpoint) {\n\t\tthrow new ResolverError(`authorization server does not support 'pushed_authorization request'`);\n\t}\n\tif (metadata.response_types_supported) {\n\t\tif (!metadata.response_types_supported.includes('code')) {\n\t\t\tthrow new ResolverError(`authorization server does not support 'code' response type`);\n\t\t}\n\t}\n\n\treturn metadata;\n};\n\nconst getMetadataFromResourceServer = async (input: string) =\u003e {\n\tconst rs_metadata = await getOAuthProtectedResourceMetadata(input);\n\n\tif (rs_metadata.authorization_servers?.length !== 1) {\n\t\tthrow new ResolverError(`expected exactly one authorization server in the listing`);\n\t}\n\n\tconst issuer = rs_metadata.authorization_servers[0];\n\n\tconst as_metadata = await getOAuthAuthorizationServerMetadata(issuer);\n\n\tif (as_metadata.protected_resources) {\n\t\tif (!as_metadata.protected_resources.includes(rs_metadata.resource)) {\n\t\t\tthrow new ResolverError(`server is not in authorization server's jurisdiction`);\n\t\t}\n\t}\n\n\treturn as_metadata;\n};\n","import type { Did } from '@atcute/lexicons';\nimport { createDpopProofSigner, type DpopPrivateJwk } from '@atcute/oauth-crypto';\nimport type { AtprotoOAuthTokenResponse, OAuthParResponse } from '@atcute/oauth-types';\n\nimport { createDPoPFetch } from '../dpop.js';\nimport { CLIENT_ID, fetchClientAssertion, REDIRECT_URI } from '../environment.js';\nimport { FetchResponseError, OAuthResponseError, TokenRefreshError } from '../errors.js';\nimport { resolveFromIdentifier } from '../resolvers.js';\nimport type { PersistedAuthorizationServerMetadata } from '../types/server.js';\nimport type { ExchangeInfo, TokenInfo } from '../types/token.js';\nimport { pick } from '../utils/misc.js';\nimport { extractContentType } from '../utils/response.js';\n\nexport class OAuthServerAgent {\n\t#fetch: typeof fetch;\n\t#metadata: PersistedAuthorizationServerMetadata;\n\t#dpopKey: DpopPrivateJwk;\n\n\tconstructor(metadata: PersistedAuthorizationServerMetadata, dpopKey: DpopPrivateJwk) {\n\t\tthis.#metadata = metadata;\n\t\tthis.#dpopKey = dpopKey;\n\t\tthis.#fetch = createDPoPFetch(dpopKey, true);\n\t}\n\n\tasync request(\n\t\tendpoint: 'pushed_authorization_request',\n\t\tpayload: Record\u003cstring, unknown\u003e,\n\t): Promise\u003cOAuthParResponse\u003e;\n\tasync request(endpoint: 'token', payload: Record\u003cstring, unknown\u003e): Promise\u003cAtprotoOAuthTokenResponse\u003e;\n\tasync request(endpoint: 'revocation', payload: Record\u003cstring, unknown\u003e): Promise\u003cany\u003e;\n\tasync request(endpoint: 'introspection', payload: Record\u003cstring, unknown\u003e): Promise\u003cany\u003e;\n\tasync request(endpoint: string, payload: Record\u003cstring, unknown\u003e): Promise\u003cany\u003e {\n\t\tconst url: string | undefined = (this.#metadata as any)[`${endpoint}_endpoint`];\n\t\tif (!url) {\n\t\t\tthrow new Error(`no endpoint for ${endpoint}`);\n\t\t}\n\n\t\tif (\n\t\t\t(endpoint === 'token' || endpoint === 'pushed_authorization_request') \u0026\u0026\n\t\t\tfetchClientAssertion !== undefined\n\t\t) {\n\t\t\tconst sign = createDpopProofSigner(this.#dpopKey);\n\n\t\t\tconst assertion = await fetchClientAssertion({\n\t\t\t\taud: this.#metadata.issuer,\n\t\t\t\tcreateDpopProof: async (url, nonce) =\u003e {\n\t\t\t\t\treturn await sign('POST', url, nonce, undefined);\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tpayload = { ...payload, ...assertion };\n\t\t}\n\n\t\tconst response = await this.#fetch(url, {\n\t\t\tmethod: 'post',\n\t\t\theaders: { 'content-type': 'application/json' },\n\t\t\tbody: JSON.stringify({ ...payload, client_id: CLIENT_ID }),\n\t\t});\n\n\t\tif (extractContentType(response.headers) !== 'application/json') {\n\t\t\tthrow new FetchResponseError(response, 2, `unexpected content-type`);\n\t\t}\n\n\t\tconst json = await response.json();\n\n\t\tif (response.ok) {\n\t\t\treturn json;\n\t\t} else {\n\t\t\tthrow new OAuthResponseError(response, json);\n\t\t}\n\t}\n\n\tasync revoke(token: string): Promise\u003cvoid\u003e {\n\t\ttry {\n\t\t\tawait this.request('revocation', { token: token });\n\t\t} catch {}\n\t}\n\n\tasync exchangeCode(code: string, verifier?: string): Promise\u003c{ info: ExchangeInfo; token: TokenInfo }\u003e {\n\t\tconst response = await this.request('token', {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: REDIRECT_URI,\n\t\t\tcode: code,\n\t\t\tcode_verifier: verifier,\n\t\t});\n\n\t\ttry {\n\t\t\treturn await this.#processExchangeResponse(response);\n\t\t} catch (err) {\n\t\t\tawait this.revoke(response.access_token);\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tasync refresh({ sub, token }: { sub: Did; token: TokenInfo }): Promise\u003cTokenInfo\u003e {\n\t\tif (!token.refresh) {\n\t\t\tthrow new TokenRefreshError(sub, 'no refresh token available');\n\t\t}\n\n\t\tconst response = await this.request('token', {\n\t\t\tgrant_type: 'refresh_token',\n\t\t\trefresh_token: token.refresh,\n\t\t});\n\n\t\ttry {\n\t\t\tif (sub !== response.sub) {\n\t\t\t\tthrow new TokenRefreshError(sub, `sub mismatch in token response; got ${response.sub}`);\n\t\t\t}\n\n\t\t\treturn this.#processTokenResponse(response);\n\t\t} catch (err) {\n\t\t\tawait this.revoke(response.access_token);\n\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\t#processTokenResponse(res: AtprotoOAuthTokenResponse): TokenInfo {\n\t\tif (!res.sub) {\n\t\t\tthrow new TypeError(`missing sub field in token response`);\n\t\t}\n\t\tif (!res.scope) {\n\t\t\tthrow new TypeError(`missing scope field in token response`);\n\t\t}\n\t\tif (res.token_type !== 'DPoP') {\n\t\t\tthrow new TypeError(`token response returned a non-dpop token`);\n\t\t}\n\n\t\treturn {\n\t\t\tscope: res.scope,\n\t\t\trefresh: res.refresh_token,\n\t\t\taccess: res.access_token,\n\t\t\ttype: res.token_type,\n\t\t\texpires_at: typeof res.expires_in === 'number' ? Date.now() + res.expires_in * 1_000 : undefined,\n\t\t};\n\t}\n\n\tasync #processExchangeResponse(\n\t\tres: AtprotoOAuthTokenResponse,\n\t): Promise\u003c{ info: ExchangeInfo; token: TokenInfo }\u003e {\n\t\tconst sub = res.sub;\n\t\tif (!sub) {\n\t\t\tthrow new TypeError(`missing sub field in token response`);\n\t\t}\n\n\t\tconst token = this.#processTokenResponse(res);\n\t\tconst resolved = await resolveFromIdentifier(sub as Did);\n\n\t\tif (resolved.metadata.issuer !== this.#metadata.issuer) {\n\t\t\tthrow new TypeError(`issuer mismatch; got ${resolved.metadata.issuer}`);\n\t\t}\n\n\t\treturn {\n\t\t\ttoken: token,\n\t\t\tinfo: {\n\t\t\t\tsub: sub as Did,\n\t\t\t\taud: resolved.identity.pds,\n\t\t\t\tserver: pick(resolved.metadata, [\n\t\t\t\t\t'issuer',\n\t\t\t\t\t'authorization_endpoint',\n\t\t\t\t\t'introspection_endpoint',\n\t\t\t\t\t'pushed_authorization_request_endpoint',\n\t\t\t\t\t'revocation_endpoint',\n\t\t\t\t\t'token_endpoint',\n\t\t\t\t]),\n\t\t\t},\n\t\t};\n\t}\n}\n","import { createDpopProofSigner, sha256Base64Url, type DpopPrivateJwk } from '@atcute/oauth-crypto';\n\nimport { database } from './environment.js';\nimport { extractContentType } from './utils/response.js';\n\nexport const createDPoPFetch = (dpopKey: DpopPrivateJwk, isAuthServer?: boolean): typeof fetch =\u003e {\n\tconst nonces = database.dpopNonces;\n\tconst pending = database.inflightDpop;\n\n\tconst sign = createDpopProofSigner(dpopKey);\n\n\treturn async (input, init) =\u003e {\n\t\tconst request = new Request(input, init);\n\n\t\tconst authorizationHeader = request.headers.get('authorization');\n\t\tconst ath = authorizationHeader?.startsWith('DPoP ')\n\t\t\t? await sha256Base64Url(authorizationHeader.slice(5))\n\t\t\t: undefined;\n\n\t\tconst { method, url } = request;\n\t\tconst { origin, pathname } = new URL(url);\n\n\t\tconst htu = origin + pathname;\n\n\t\tlet deferred = pending.get(origin);\n\t\tif (deferred) {\n\t\t\tawait deferred.promise;\n\t\t\tdeferred = undefined;\n\t\t}\n\n\t\tlet initNonce: string | undefined;\n\t\tlet expiredOrMissing = false;\n\t\ttry {\n\t\t\tconst [nonce, lapsed] = nonces.getWithLapsed(origin);\n\n\t\t\tinitNonce = nonce;\n\t\t\texpiredOrMissing = lapsed \u003e 3 * 60 * 1_000;\n\t\t} catch {\n\t\t\t// ignore read errors\n\t\t}\n\n\t\tif (expiredOrMissing) {\n\t\t\tpending.set(origin, (deferred = Promise.withResolvers()));\n\t\t}\n\n\t\tlet nextNonce: string | null;\n\t\ttry {\n\t\t\tconst initProof = await sign(method, htu, initNonce, ath);\n\t\t\trequest.headers.set('dpop', initProof);\n\n\t\t\tconst initResponse = await fetch(request);\n\n\t\t\tnextNonce = initResponse.headers.get('dpop-nonce');\n\t\t\tif (nextNonce === null || nextNonce === initNonce) {\n\t\t\t\treturn initResponse;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tnonces.set(origin, nextNonce);\n\t\t\t} catch {\n\t\t\t\t// ignore write errors\n\t\t\t}\n\n\t\t\tconst shouldRetry = await isUseDpopNonceError(initResponse, isAuthServer);\n\t\t\tif (!shouldRetry) {\n\t\t\t\treturn initResponse;\n\t\t\t}\n\n\t\t\tif (input === request || init?.body instanceof ReadableStream) {\n\t\t\t\treturn initResponse;\n\t\t\t}\n\t\t} finally {\n\t\t\tif (deferred) {\n\t\t\t\tpending.delete(origin);\n\t\t\t\tdeferred.resolve();\n\t\t\t}\n\t\t}\n\n\t\t{\n\t\t\tconst nextProof = await sign(method, htu, nextNonce, ath);\n\t\t\tconst nextRequest = new Request(input, init);\n\t\t\tnextRequest.headers.set('dpop', nextProof);\n\n\t\t\tconst retryResponse = await fetch(nextRequest);\n\n\t\t\tconst retryNonce = retryResponse.headers.get('dpop-nonce');\n\t\t\tif (retryNonce !== null \u0026\u0026 retryNonce !== nextNonce) {\n\t\t\t\ttry {\n\t\t\t\t\tnonces.set(origin, retryNonce);\n\t\t\t\t} catch {\n\t\t\t\t\t// ignore write errors\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn retryResponse;\n\t\t}\n\t};\n};\n\nconst isUseDpopNonceError = async (response: Response, isAuthServer?: boolean): Promise\u003cboolean\u003e =\u003e {\n\tif (isAuthServer === undefined || isAuthServer === false) {\n\t\tif (response.status === 401) {\n\t\t\tconst wwwAuth = response.headers.get('www-authenticate');\n\t\t\tif (wwwAuth?.startsWith('DPoP')) {\n\t\t\t\treturn wwwAuth.includes('error=\"use_dpop_nonce\"');\n\t\t\t}\n\t\t}\n\t}\n\n\tif (isAuthServer === undefined || isAuthServer === true) {\n\t\tif (response.status === 400 \u0026\u0026 extractContentType(response.headers) === 'application/json') {\n\t\t\ttry {\n\t\t\t\tconst json = await response.clone().json();\n\t\t\t\treturn typeof json === 'object' \u0026\u0026 json?.['error'] === 'use_dpop_nonce';\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n};\n","type UnwrapArray\u003cT\u003e = T extends (infer V)[] ? V : never;\n\nexport const pick = \u003cT, K extends (keyof T)[]\u003e(obj: T, keys: K): Pick\u003cT, UnwrapArray\u003cK\u003e\u003e =\u003e {\n\tconst cloned = {};\n\n\tfor (let idx = 0, len = keys.length; idx \u003c len; idx++) {\n\t\tconst key = keys[idx];\n\n\t\t// @ts-expect-error\n\t\tcloned[key] = obj[key];\n\t}\n\n\treturn cloned as Pick\u003cT, UnwrapArray\u003cK\u003e\u003e;\n};\n","import { fromBase64Url } from '@atcute/multibase';\nimport type { DpopPrivateJwk } from '@atcute/oauth-crypto';\n\nexport interface LegacyDpopKey {\n\ttyp: 'ES256';\n\tkey: string;\n\tjwt: string;\n\tjkt?: string;\n}\n\nconst ES256_ALG = { name: 'ECDSA', namedCurve: 'P-256' } as const;\n\nexport const isLegacyDpopKey = (key: DpopPrivateJwk | LegacyDpopKey): key is LegacyDpopKey =\u003e {\n\treturn typeof (key as LegacyDpopKey).key === 'string' \u0026\u0026 typeof (key as LegacyDpopKey).jwt === 'string';\n};\n\nexport const migrateLegacyDpopKey = async (key: LegacyDpopKey): Promise\u003cDpopPrivateJwk\u003e =\u003e {\n\tconst pkcs8 = fromBase64Url(key.key);\n\tconst cryptoKey = await crypto.subtle.importKey('pkcs8', pkcs8, ES256_ALG, true, ['sign']);\n\tconst jwk = (await crypto.subtle.exportKey('jwk', cryptoKey)) as DpopPrivateJwk;\n\tjwk.alg = 'ES256';\n\n\treturn jwk;\n};\n","import type { Did } from '@atcute/lexicons';\n\nimport { database } from '../environment.js';\nimport { OAuthResponseError, TokenRefreshError } from '../errors.js';\nimport type { RawSession, Session } from '../types/token.js';\nimport { isLegacyDpopKey, migrateLegacyDpopKey } from '../utils/dpop-key.js';\nimport { locks } from '../utils/runtime.js';\n\nimport { OAuthServerAgent } from './server-agent.js';\n\nexport interface SessionGetOptions {\n\tsignal?: AbortSignal;\n\tnoCache?: boolean;\n\tallowStale?: boolean;\n}\n\ntype PendingItem\u003cV\u003e = Promise\u003c{ value: V; isFresh: boolean }\u003e;\nconst pending = new Map\u003cDid, Promise\u003cPendingItem\u003cSession\u003e\u003e\u003e();\n\nexport const getSession = async (sub: Did, options?: SessionGetOptions): Promise\u003cSession\u003e =\u003e {\n\toptions?.signal?.throwIfAborted();\n\n\tlet allowStored = isTokenUsable;\n\tif (options?.noCache) {\n\t\tallowStored = returnFalse;\n\t} else if (options?.allowStale) {\n\t\tallowStored = returnTrue;\n\t}\n\n\t// As long as concurrent requests are made for the same key, only one\n\t// request will be made to the cache \u0026 getter function at a time. This works\n\t// because there is no async operation between the while() loop and the\n\t// pending.set() call. Because of the \"single threaded\" nature of\n\t// JavaScript, the pending item will be set before the next iteration of the\n\t// while loop.\n\tlet previousExecutionFlow: Promise\u003cPendingItem\u003cSession\u003e\u003e | undefined;\n\twhile ((previousExecutionFlow = pending.get(sub))) {\n\t\ttry {\n\t\t\tconst { isFresh, value } = await previousExecutionFlow;\n\n\t\t\tif (isFresh || allowStored(value)) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore errors from previous execution flows (they will have been\n\t\t\t// propagated by that flow).\n\t\t}\n\n\t\toptions?.signal?.throwIfAborted();\n\t}\n\n\tconst run = async (): Promise\u003cPendingItem\u003cSession\u003e\u003e =\u003e {\n\t\tconst storedSession = await migrateSessionIfNeeded(sub, database.sessions.get(sub));\n\n\t\tif (storedSession \u0026\u0026 allowStored(storedSession)) {\n\t\t\t// Use the stored value as return value for the current execution\n\t\t\t// flow. Notify other concurrent execution flows (that should be\n\t\t\t// \"stuck\" in the loop before until this promise resolves) that we got\n\t\t\t// a value, but that it came from the store (isFresh = false).\n\t\t\treturn { isFresh: false, value: storedSession };\n\t\t}\n\n\t\tconst newSession = await refreshToken(sub, storedSession);\n\n\t\tawait storeSession(sub, newSession);\n\t\treturn { isFresh: true, value: newSession };\n\t};\n\n\tlet promise: Promise\u003cPendingItem\u003cSession\u003e\u003e;\n\n\tif (locks) {\n\t\tpromise = locks.request\u003cPendingItem\u003cSession\u003e\u003e(`atcute-oauth:${sub}`, run as any);\n\t} else {\n\t\tpromise = run();\n\t}\n\n\tpromise = promise.finally(() =\u003e pending.delete(sub));\n\n\tif (pending.has(sub)) {\n\t\t// This should never happen. Indeed, there must not be any 'await'\n\t\t// statement between this and the loop iteration check meaning that\n\t\t// this.pending.get returned undefined. It is there to catch bugs that\n\t\t// would occur in future changes to the code.\n\t\tthrow new Error('concurrent request for the same key');\n\t}\n\n\tpending.set(sub, promise);\n\n\tconst { value } = await promise;\n\treturn value;\n};\n\nexport const storeSession = async (sub: Did, newSession: Session): Promise\u003cvoid\u003e =\u003e {\n\ttry {\n\t\tdatabase.sessions.set(sub, newSession);\n\t} catch (err) {\n\t\tawait onRefreshError(newSession);\n\t\tthrow err;\n\t}\n};\n\nexport const deleteStoredSession = (sub: Did): void =\u003e {\n\tdatabase.sessions.delete(sub);\n};\n\nexport const listStoredSessions = (): Did[] =\u003e {\n\treturn database.sessions.keys();\n};\n\nconst returnTrue = () =\u003e true;\nconst returnFalse = () =\u003e false;\n\nconst refreshToken = async (sub: Did, storedSession: Session | undefined): Promise\u003cSession\u003e =\u003e {\n\tif (storedSession === undefined) {\n\t\tthrow new TokenRefreshError(sub, `session deleted by another tab`);\n\t}\n\n\tconst { dpopKey, info, token } = storedSession;\n\tconst server = new OAuthServerAgent(info.server, dpopKey);\n\n\ttry {\n\t\tconst newToken = await server.refresh({ sub: info.sub, token });\n\n\t\treturn { dpopKey, info, token: newToken };\n\t} catch (cause) {\n\t\tif (cause instanceof OAuthResponseError \u0026\u0026 cause.status === 400 \u0026\u0026 cause.error === 'invalid_grant') {\n\t\t\tthrow new TokenRefreshError(sub, `session was revoked`, { cause });\n\t\t}\n\n\t\tthrow cause;\n\t}\n};\n\nconst onRefreshError = async ({ dpopKey, info, token }: Session) =\u003e {\n\t// If the token data cannot be stored, let's revoke it\n\tconst server = new OAuthServerAgent(info.server, dpopKey);\n\tawait server.revoke(token.refresh ?? token.access);\n};\n\nconst isTokenUsable = ({ token }: Session): boolean =\u003e {\n\tconst expires = token.expires_at;\n\treturn expires == null || Date.now() + 60_000 \u003c= expires;\n};\n\nconst migrateSessionIfNeeded = async (\n\tsub: Did,\n\tsession: RawSession | undefined,\n): Promise\u003cSession | undefined\u003e =\u003e {\n\tif (!session || !isLegacyDpopKey(session.dpopKey)) {\n\t\treturn session as Session | undefined;\n\t}\n\n\tconst dpopKey = await migrateLegacyDpopKey(session.dpopKey);\n\tconst migrated = { ...session, dpopKey };\n\n\ttry {\n\t\tdatabase.sessions.set(sub, migrated);\n\t} catch {\n\t\t// ignore persistence errors\n\t}\n\n\treturn migrated;\n};\n","import type { FetchHandlerObject } from '@atcute/client';\nimport type { Did } from '@atcute/lexicons';\n\nimport { createDPoPFetch } from '../dpop.js';\nimport type { Session } from '../types/token.js';\n\nimport { OAuthServerAgent } from './server-agent.js';\nimport { type SessionGetOptions, deleteStoredSession, getSession } from './sessions.js';\n\nexport class OAuthUserAgent implements FetchHandlerObject {\n\t#fetch: typeof fetch;\n\t#getSessionPromise: Promise\u003cSession\u003e | undefined;\n\n\tconstructor(public session: Session) {\n\t\tthis.#fetch = createDPoPFetch(session.dpopKey, false);\n\t}\n\n\tget sub(): Did {\n\t\treturn this.session.info.sub;\n\t}\n\n\tgetSession(options?: SessionGetOptions): Promise\u003cSession\u003e {\n\t\tconst promise = getSession(this.session.info.sub, options);\n\n\t\tpromise\n\t\t\t.then((session) =\u003e {\n\t\t\t\tthis.session = session;\n\t\t\t})\n\t\t\t.finally(() =\u003e {\n\t\t\t\tthis.#getSessionPromise = undefined;\n\t\t\t});\n\n\t\treturn (this.#getSessionPromise = promise);\n\t}\n\n\tasync signOut(): Promise\u003cvoid\u003e {\n\t\tconst sub = this.session.info.sub;\n\n\t\ttry {\n\t\t\tconst { dpopKey, info, token } = await getSession(sub, { allowStale: true });\n\t\t\tconst server = new OAuthServerAgent(info.server, dpopKey);\n\n\t\t\tawait server.revoke(token.refresh ?? token.access);\n\t\t} finally {\n\t\t\tdeleteStoredSession(sub);\n\t\t}\n\t}\n\n\tasync handle(pathname: string, init?: RequestInit): Promise\u003cResponse\u003e {\n\t\tawait this.#getSessionPromise;\n\n\t\tconst headers = new Headers(init?.headers);\n\n\t\tlet session = this.session;\n\t\tlet url = new URL(pathname, session.info.aud);\n\n\t\theaders.set('authorization', `${session.token.type} ${session.token.access}`);\n\n\t\tlet response = await this.#fetch(url.href, { ...init, headers });\n\t\tif (!isInvalidTokenResponse(response)) {\n\t\t\treturn response;\n\t\t}\n\n\t\ttry {\n\t\t\tif (this.#getSessionPromise) {\n\t\t\t\tsession = await this.#getSessionPromise;\n\t\t\t} else {\n\t\t\t\tsession = await this.getSession();\n\t\t\t}\n\t\t} catch {\n\t\t\treturn response;\n\t\t}\n\n\t\t// Stream already consumed, can't retry.\n\t\tif (init?.body instanceof ReadableStream) {\n\t\t\treturn response;\n\t\t}\n\n\t\turl = new URL(pathname, session.info.aud);\n\t\theaders.set('authorization', `${session.token.type} ${session.token.access}`);\n\n\t\treturn await this.#fetch(url.href, { ...init, headers });\n\t}\n}\n\nconst isInvalidTokenResponse = (response: Response) =\u003e {\n\tif (response.status !== 401) {\n\t\treturn false;\n\t}\n\n\tconst auth = response.headers.get('www-authenticate');\n\n\treturn (\n\t\tauth != null \u0026\u0026\n\t\t(auth.startsWith('Bearer ') || auth.startsWith('DPoP ')) \u0026\u0026\n\t\tauth.includes('error=\"invalid_token\"')\n\t);\n};\n"],"version":3}
+4
vendor/esm.sh/@atcute/oauth-crypto@0.1.0/es2022/oauth-crypto.mjs
··· 1 + /* esm.sh - @atcute/oauth-crypto@0.1.0 */ 2 + import{nanoid as st}from"../../../nanoid@5.1.7/es2022/nanoid.mjs";import{fromBase64Pad as Z,toBase64Pad as tt}from"../../multibase@1.2.0/es2022/multibase.mjs";var z={ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512",PS256:"SHA-256",PS384:"SHA-384",PS512:"SHA-512",RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"},Q={ES256:"P-256",ES384:"P-384",ES512:"P-521",PS256:null,PS384:null,PS512:null,RS256:null,RS384:null,RS512:null},u=t=>z[t],O=t=>Q[t],J=t=>t.startsWith("ES")?{name:"ECDSA",hash:{name:u(t)}}:t.startsWith("PS")?{name:"RSA-PSS",hash:{name:u(t)},saltLength:X(u(t))}:{name:"RSASSA-PKCS1-v1_5"},v=(t,e)=>{if(t.startsWith("ES")){let r=e??O(t);if(!r)throw new Error(`unable to determine curve for ${t}`);return{name:"ECDSA",namedCurve:r}}return t.startsWith("PS")?{name:"RSA-PSS",hash:{name:u(t)}}:{name:"RSASSA-PKCS1-v1_5",hash:{name:u(t)}}},A=t=>{let e=O(t);if(e)return{name:"ECDSA",namedCurve:e};let r={name:u(t)};return{name:t.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:r,modulusLength:2048,publicExponent:new Uint8Array([1,0,1])}},X=t=>{switch(t){case"SHA-256":return 32;case"SHA-384":return 48;case"SHA-512":return 64}};var et=["ES256","ES384","ES512","PS256","PS384","PS512","RS256","RS384","RS512"];var $=t=>et.includes(t);var K=(t,e,r)=>{if(t.kty==="EC"){let{crv:o,x:n,y:s}=t;return{kty:"EC",crv:o,x:n,y:s,kid:e,alg:r,use:"sig"}}if(t.kty==="RSA"){let{n:o,e:n}=t;return{kty:"RSA",n:o,e:n,kid:e,alg:r,use:"sig"}}throw new Error("unsupported key type")},B=async(t,e)=>{if(!("d"in t)||!t.d)throw new Error("expected a private key (missing 'd' parameter)");if(t.kty==="EC"&&!e.startsWith("ES"))throw new Error(`algorithm ${e} does not match ec key`);if(t.kty==="RSA"&&e.startsWith("ES"))throw new Error(`algorithm ${e} does not match rsa key`);let r=v(e,t.kty==="EC"?t.crv:void 0),o=await crypto.subtle.importKey("jwk",t,r,!0,["sign"]);if(!(o instanceof CryptoKey))throw new Error("expected asymmetric key, got symmetric");return o},d=async(t,e,r)=>{let o=await crypto.subtle.exportKey("jwk",t);return o.alg=e,r&&(o.kid=r),o},M=async(t,e)=>{let r=rt(t),o=v(e),n=await crypto.subtle.importKey("pkcs8",r,o,!0,["sign"]);if(!(n instanceof CryptoKey))throw new Error("expected asymmetric key, got symmetric");return n},j=async t=>{let e=await crypto.subtle.exportKey("pkcs8",t),r=new Uint8Array(e),o=tt(r);return["-----BEGIN PRIVATE KEY-----",...ot(o),"-----END PRIVATE KEY-----",""].join(` 3 + `)},rt=t=>{let e=t.match(/-----BEGIN PRIVATE KEY-----([\s\S]*?)-----END PRIVATE KEY-----/);if(!e)throw new Error("invalid pkcs8 pem");let r=e[1].replace(/\s+/g,""),o=Z(r);return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)},ot=t=>{let e=[];for(let r=0;r<t.length;r+=64)e.push(t.slice(r,r+64));return e};var D=new WeakMap,g=async t=>{let e=D.get(t);if(e)return e;let{alg:r}=t,o=await B(t,r),n=K(t,t.kid,r),s={cryptoKey:o,publicJwk:n};return D.set(t,s),s},S=(t,e)=>{let r=K(t,t.kid,t.alg);D.set(t,{cryptoKey:e,publicJwk:r})};import{fromBase64Url as G,toBase64Url as L}from"../../multibase@1.2.0/es2022/multibase.mjs";import{decodeUtf8From as nt,encodeUtf8 as N}from"../../uint8array@1.1.1/es2022/uint8array.mjs";var b=async t=>{let{header:e,payload:r,key:o,alg:n}=t,s={...e,alg:n},a=F(s),m=F(r),p=`${a}.${m}`,c=await crypto.subtle.sign(J(n),o,N(p)),f=L(new Uint8Array(c));return`${p}.${f}`},T=async(t,e)=>{let{key:r,alg:o,typ:n}=e,s=t.split(".");if(s.length!==3)throw new Error("invalid jwt format");let a=W(s[0]);if(a.alg!==o)throw new Error("invalid jwt alg");if(n&&a.typ!==n)throw new Error("invalid jwt typ");let m=W(s[1]),p=G(s[2]),c=`${s[0]}.${s[1]}`;if(!await crypto.subtle.verify(J(o),r,p,N(c)))throw new Error("invalid jwt signature");return m},F=t=>L(N(JSON.stringify(t))),W=t=>{let e=G(t);return JSON.parse(nt(e))};var it=async t=>{let{client_id:e,aud:r,jkt:o,key:n}=t,{kid:s,alg:a}=n,{cryptoKey:m}=await g(n),p=Math.floor(Date.now()/1e3),c=o?{jkt:o}:void 0;return b({header:{alg:a,kid:s},payload:{iss:e,sub:e,aud:r,jti:st(24),iat:p,exp:p+60,cnf:c},key:m,alg:a})};var at=async(t,e="ES256")=>{let r=await crypto.subtle.generateKey(A(e),!0,["sign","verify"]),o=await d(r.privateKey,e,t);return S(o,r.privateKey),o};var ct=async(t,e)=>{let{kid:r,alg:o}=e,n=await M(t,o),s=await d(n,o,r);return S(s,n),s};import{toBase64Url as pt}from"../../multibase@1.2.0/es2022/multibase.mjs";import{encodeUtf8 as mt,toSha256 as ft}from"../../uint8array@1.1.1/es2022/uint8array.mjs";var E=async t=>{let e=mt(t),r=await ft(e);return pt(r)};import{nanoid as yt}from"../../../nanoid@5.1.7/es2022/nanoid.mjs";var U=t=>{let e=t.alg,r;return async(o,n,s,a)=>{r||=g(t);let{cryptoKey:m,publicJwk:p}=await r,c=Math.floor(Date.now()/1e3);return b({header:{typ:"dpop+jwt",jwk:p},payload:{htm:o,htu:n,iat:c,jti:yt(24),nonce:s,ath:a},key:m,alg:e})}};var ht=t=>{let{key:e,nonces:r,supportedAlgs:o,isAuthServer:n,fetch:s=globalThis.fetch}=t;ut(e,o);let a=U(e);return async(m,p)=>{let c=p==null&&m instanceof Request?m:new Request(m,p),f=c.headers.get("Authorization"),w=f?.startsWith("DPoP ")?await E(f.slice(5)):void 0,{origin:P}=new URL(c.url),h=c.method,k=lt(c.url),R;try{R=await r.get(P)}catch{}let q=await a(h,k,R,w);c.headers.set("DPoP",q);let l=await s(c),x=l.headers.get("DPoP-Nonce");if(!x||x===R)return l;try{await r.set(P,x)}catch{}if(!await dt(l,n)||m===c||p?.body instanceof ReadableStream)return l;await l.body?.cancel();let Y=await a(h,k,x,w),I=new Request(m,p);I.headers.set("DPoP",Y);let _=await s(I),C=_.headers.get("DPoP-Nonce");if(C&&C!==x)try{await r.set(P,C)}catch{}return _}},lt=t=>{let e=t.indexOf("#"),r=t.indexOf("?"),o=e===-1?r:r===-1?e:Math.min(e,r);return o===-1?t:t.slice(0,o)},ut=(t,e)=>{let r=t.alg;if(e?.length){if(e.includes(r))return r;throw new Error(`DPoP key algorithm ${r} not supported by server: ${e.join(", ")}`)}return r},dt=async(t,e)=>{if((e===void 0||e===!1)&&t.status===401){let r=t.headers.get("WWW-Authenticate");if(r?.startsWith("DPoP"))return r.includes('error="use_dpop_nonce"')}if((e===void 0||e===!0)&&t.status===400)try{let r=await t.clone().json();return typeof r=="object"&&r?.error==="use_dpop_nonce"}catch{return!1}return!1};var V=["ES256","ES384","ES512","PS256","PS384","PS512","RS256","RS384","RS512"],gt=t=>[...t].sort((e,r)=>{let o=V.indexOf(e),n=V.indexOf(r);return o===-1&&n===-1?0:o===-1?1:n===-1?-1:o-n}),St=async t=>{let e=t?.filter($)??[];if(t?.length&&e.length===0)throw new Error("no supported algorithms provided");let r=e.length?gt(e):["ES256"],o=[];for(let n of r)try{let s=await crypto.subtle.generateKey(A(n),!0,["sign","verify"]),a=await d(s.privateKey,n);return S(a,s.privateKey),a}catch(s){o.push(s)}throw new AggregateError(o,`failed to generate DPoP key for any of: ${r.join(", ")}`)};import{fromBase64Url as vt}from"../../multibase@1.2.0/es2022/multibase.mjs";import{decodeUtf8From as Et}from"../../uint8array@1.1.1/es2022/uint8array.mjs";import*as i from"../../../@badrap/valita@0.4.6/es2022/valita.mjs";import{toBase64Url as wt}from"../../multibase@1.2.0/es2022/multibase.mjs";import{encodeUtf8 as Pt,toSha256 as xt}from"../../uint8array@1.1.1/es2022/uint8array.mjs";var H=async t=>{let e;if(t.kty==="EC"){let{crv:n,x:s,y:a}=t;e={crv:n,kty:t.kty,x:s,y:a}}else{let{e:n,n:s}=t;e={e:n,kty:t.kty,n:s}}let r=JSON.stringify(e),o=await xt(Pt(r));return wt(o)};var kt=i.union(i.object({kty:i.literal("EC"),crv:i.union(i.literal("P-256"),i.literal("P-384"),i.literal("P-521")),x:i.string(),y:i.string()}),i.object({kty:i.literal("RSA"),e:i.string(),n:i.string()})),At=i.object({typ:i.literal("dpop+jwt"),alg:i.string().assert(t=>t!=="none",'alg must not be "none"'),jwk:kt}),Kt=i.object({htm:i.string(),htu:i.string(),iat:i.number(),jti:i.string(),nonce:i.string().optional()}),y=class extends Error{code;constructor(e,r){super(e),this.code=r,this.name="DpopVerifyError"}},bt=async(t,e)=>{if(!t)throw new y("missing dpop header","missing");let{method:r,url:o,nonce:n,maxClockSkew:s=60}=e,a=t.split(".");if(a.length!==3)throw new y("invalid dpop proof format","invalid");let m;try{m=At.parse(Jt(a[0]),{mode:"passthrough"})}catch{throw new y("invalid dpop header","invalid")}let{jwk:p,alg:c}=m;if(!Ct(c))throw new y("unsupported dpop alg","invalid");let f;try{let h=await Rt(p,c),k=await T(t,{key:h,alg:c,typ:"dpop+jwt"});f=Kt.parse(k,{mode:"passthrough"})}catch(h){throw h instanceof i.ValitaError?new y("invalid dpop payload","invalid"):new y("dpop signature verification failed","invalid")}if(f.htm!==r)throw new y(`dpop htm mismatch: expected ${r}, got ${f.htm}`,"invalid");if(f.htu!==o)throw new y(`dpop htu mismatch: expected ${o}, got ${f.htu}`,"invalid");let w=Math.floor(Date.now()/1e3);if(f.iat>w+s)throw new y("dpop proof issued in the future","invalid");if(f.iat<w-s)throw new y("dpop proof expired","expired");if(n&&(!f.nonce||!await n.check(f.nonce)))throw new y("invalid or missing dpop nonce","nonce_required");let P=await H(p);return{claims:f,jwk:p,jkt:P}},Rt=async(t,e)=>{let r=v(e,t.kty==="EC"?t.crv:void 0),o=await crypto.subtle.importKey("jwk",t,r,!0,["verify"]);if(!(o instanceof CryptoKey))throw new Error("expected asymmetric key, got symmetric");return o},Ct=t=>t==="ES256"||t==="ES384"||t==="ES512"||t==="PS256"||t==="PS384"||t==="PS512"||t==="RS256"||t==="RS384"||t==="RS512",Jt=t=>{let e=vt(t);return JSON.parse(Et(e))};import{nanoid as Dt}from"../../../nanoid@5.1.7/es2022/nanoid.mjs";var Nt=async(t=64)=>{let e=Dt(t),r=await E(e);return{verifier:e,challenge:r,method:"S256"}};var Ut=async t=>{let{cryptoKey:e}=await g(t);return j(e)};export{y as DpopVerifyError,H as computeJktFromJwk,it as createClientAssertion,ht as createDpopFetch,U as createDpopProofSigner,K as derivePublicJwk,Ut as exportPkcs8PrivateKey,at as generateClientAssertionKey,St as generateDpopKey,Nt as generatePkce,ct as importClientAssertionPkcs8,E as sha256Base64Url,b as signJwt,bt as verifyDpopProof,T as verifyJwt}; 4 + //# sourceMappingURL=./oauth-crypto.mjs.map
+1
vendor/esm.sh/@atcute/oauth-crypto@0.1.0/es2022/oauth-crypto.mjs.map
··· 1 + {"mappings":";AAAA,OAAS,UAAAA,OAAc,+BCAvB,OAAS,iBAAAC,EAAe,eAAAC,OAAmB,0CCE3C,IAAMC,EAA2E,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AAQ,CAAC,EACjF,GAAI,EAAER,aAAe,WACpB,MAAM,IAAI,MAAM,wCAAwC,EAGzD,OAAOA,CAAI,EAGNF,GAAsBhB,GAE1BA,IAAQ,SACRA,IAAQ,SACRA,IAAQ,SACRA,IAAQ,SACRA,IAAQ,SACRA,IAAQ,SACRA,IAAQ,SACRA,IAAQ,SACRA,IAAQ,QAIJc,GAAiBc,GAA6B,CACnD,IAAMC,EAAQC,GAAcF,CAAO,EACnC,OAAO,KAAK,MAAMG,GAAeF,CAAK,CAAC,CAAE,EEvK1C,OAAS,UAAAG,OAAc,+BAUhB,IAAMC,GAAe,MAC3BC,EAAS,KAC6D,CACtE,IAAMC,EAAWC,GAAOF,CAAM,EACxBG,EAAY,MAAMC,EAAgBH,CAAQ,EAEhD,MAAO,CAAE,SAAAA,EAAU,UAAAE,EAAW,OAAQ,MAAM,CAAG,ECLzC,IAAME,GAAwB,MAAOC,GAAqC,CAChF,GAAM,CAAE,UAAAC,CAAS,EAAK,MAAMC,EAAqBF,CAAG,EACpD,OAAOD,EAAYE,CAAS,CAAE","names":["nanoid","fromBase64Pad","toBase64Pad","HASH_BY_ALG","CURVE_BY_ALG","getHashName","alg","getNamedCurve","getSignAlgorithm","getHashLength","getImportAlgorithm","curve","namedCurve","getGenerateAlgorithm","hash","SIGNING_ALGORITHMS","isSigningAlgorithm","alg","SIGNING_ALGORITHMS","derivePublicJwk","privateJwk","kid","alg","crv","x","y","n","e","importPrivateKeyFromJwk","jwk","algorithm","getImportAlgorithm","key","exportPrivateJwkFromKey","importPkcs8PrivateKey","pem","bytes","parsePkcs8Pem","exportPkcs8PrivateKey","pkcs8","base64","toBase64Pad","chunk64","match","fromBase64Pad","input","chunks","i","keyCache","getCachedKeyMaterial","jwk","cached","alg","cryptoKey","importPrivateKeyFromJwk","publicJwk","derivePublicJwk","material","setCachedKeyMaterial","fromBase64Url","toBase64Url","decodeUtf8From","encodeUtf8","signJwt","params","header","payload","key","alg","fullHeader","headerSegment","encodeSegment","payloadSegment","signingInput","signature","getSignAlgorithm","encodeUtf8","signatureSegment","toBase64Url","verifyJwt","jwt","options","typ","parts","decodeSegment","fromBase64Url","value","bytes","decodeUtf8From","createClientAssertion","options","client_id","aud","jkt","key","kid","alg","cryptoKey","getCachedKeyMaterial","now","cnf","signJwt","nanoid","generateClientAssertionKey","kid","alg","pair","getGenerateAlgorithm","jwk","exportPrivateJwkFromKey","setCachedKeyMaterial","importClientAssertionPkcs8","pem","options","kid","alg","cryptoKey","importPkcs8PrivateKey","jwk","exportPrivateJwkFromKey","setCachedKeyMaterial","toBase64Url","encodeUtf8","toSha256","sha256Base64Url","input","bytes","digest","nanoid","createDpopProofSigner","jwk","alg","materialPromise","htm","htu","nonce","ath","getCachedKeyMaterial","cryptoKey","publicJwk","now","signJwt","nanoid","createDpopFetch","options","key","nonces","supportedAlgs","isAuthServer","fetch","negotiateAlg","sign","createDpopProofSigner","input","init","request","authHeader","ath","sha256Base64Url","origin","htm","htu","buildHtu","initNonce","initProof","initResponse","nextNonce","isUseDpopNonceError","nextProof","nextRequest","retryResponse","retryNonce","url","fragmentIdx","queryIdx","end","keyAlg","response","wwwAuth","json","PREFERRED_ALGORITHMS","sortAlgorithms","algs","a","b","aIdx","bIdx","generateDpopKey","supportedAlgs","normalized","isSigningAlgorithm","errors","alg","pair","getGenerateAlgorithm","jwk","exportPrivateJwkFromKey","setCachedKeyMaterial","err","fromBase64Url","decodeUtf8From","v","toBase64Url","encodeUtf8","toSha256","computeJktFromJwk","jwk","canonical","crv","x","y","e","n","serialized","hash","dpopJwkSchema","dpopHeaderSchema","alg","dpopPayloadSchema","DpopVerifyError","message","code","verifyDpopProof","dpopHeader","options","method","url","dpopNonce","maxClockSkew","parts","header","decodeSegment","jwk","isSigningAlgorithm","payload","key","importPublicKey","raw","verifyJwt","err","now","jkt","computeJktFromJwk","algorithm","getImportAlgorithm","segment","bytes","fromBase64Url","decodeUtf8From","nanoid","generatePkce","length","verifier","nanoid","challenge","sha256Base64Url","exportPkcs8PrivateKey","jwk","cryptoKey","getCachedKeyMaterial"],"sources":["../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/client-assertion/create-client-assertion.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/internal/jwk.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/internal/crypto.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/internal/key-cache.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/jwt/index.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/client-assertion/generate-key.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/client-assertion/keys.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/hash/sha256.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/dpop/proof.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/dpop/fetch.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/dpop/generate-key.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/dpop/verify.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/jwk/compute-jkt.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/hash/pkce.ts","../esm/npm/@atcute/oauth-crypto@0.1.0/node_modules/@atcute/oauth-crypto/lib/jwk/keys.ts"],"sourcesContent":["import { nanoid } from 'nanoid';\n\nimport { getCachedKeyMaterial } from '../internal/key-cache.js';\nimport { signJwt } from '../jwt/index.js';\n\nimport type { ClientAssertionPrivateJwk } from './types.js';\n\nexport interface CreateClientAssertionOptions {\n\t/** client id */\n\tclient_id: string;\n\t/** authorization server issuer */\n\taud: string;\n\t/** JWK thumbprint of the DPoP key to bind to (for CAB pattern) */\n\tjkt?: string;\n\t/** client assertion signing key */\n\tkey: ClientAssertionPrivateJwk;\n}\n\n/**\n * creates a DPoP-bound client assertion per RFC 7523.\n *\n * @param options creation options\n * @returns signed client assertion JWT\n */\nexport const createClientAssertion = async (options: CreateClientAssertionOptions): Promise\u003cstring\u003e =\u003e {\n\tconst { client_id, aud, jkt, key } = options;\n\tconst { kid, alg } = key;\n\tconst { cryptoKey } = await getCachedKeyMaterial(key);\n\n\tconst now = Math.floor(Date.now() / 1000);\n\tconst cnf = jkt ? { jkt } : undefined;\n\n\treturn signJwt({\n\t\theader: {\n\t\t\talg,\n\t\t\tkid,\n\t\t},\n\t\tpayload: {\n\t\t\tiss: client_id,\n\t\t\tsub: client_id,\n\t\t\taud: aud,\n\t\t\tjti: nanoid(24),\n\t\t\tiat: now,\n\t\t\texp: now + 60,\n\t\t\tcnf,\n\t\t},\n\t\tkey: cryptoKey,\n\t\talg,\n\t});\n};\n","import { fromBase64Pad, toBase64Pad } from '@atcute/multibase';\n\nimport type { PrivateJwk, PublicJwk, SigningAlgorithm } from '../jwk/types.js';\n\nimport { getImportAlgorithm } from './crypto.js';\n\nconst SIGNING_ALGORITHMS: readonly SigningAlgorithm[] = [\n\t'ES256',\n\t'ES384',\n\t'ES512',\n\t'PS256',\n\t'PS384',\n\t'PS512',\n\t'RS256',\n\t'RS384',\n\t'RS512',\n];\n\nconst CURVE_TO_ALG: Record\u003cstring, SigningAlgorithm\u003e = {\n\t'P-256': 'ES256',\n\t'P-384': 'ES384',\n\t'P-521': 'ES512',\n};\n\nexport const isSigningAlgorithm = (alg: string): alg is SigningAlgorithm =\u003e {\n\treturn (SIGNING_ALGORITHMS as readonly string[]).includes(alg);\n};\n\nexport const parsePrivateJwkInput = (input: PrivateJwk | string): PrivateJwk =\u003e {\n\tif (typeof input === 'string') {\n\t\ttry {\n\t\t\tconst jwk = JSON.parse(input) as PrivateJwk;\n\t\t\treturn jwk;\n\t\t} catch {\n\t\t\tthrow new Error(`invalid JSON string`);\n\t\t}\n\t}\n\n\tif (typeof input === 'object' \u0026\u0026 input !== null \u0026\u0026 'kty' in input) {\n\t\treturn input;\n\t}\n\n\tthrow new Error(`invalid input: expected JWK object or JSON string`);\n};\n\nexport const resolveSigningAlgorithm = (\n\tjwk: PrivateJwk,\n\toverride?: SigningAlgorithm,\n): SigningAlgorithm | undefined =\u003e {\n\tif (override) {\n\t\treturn override;\n\t}\n\n\tconst alg = jwk.alg;\n\tif (alg \u0026\u0026 isSigningAlgorithm(alg)) {\n\t\treturn alg;\n\t}\n\n\tif (jwk.kty === 'EC') {\n\t\tconst inferred = CURVE_TO_ALG[jwk.crv];\n\t\tif (inferred) {\n\t\t\treturn inferred;\n\t\t}\n\t}\n\n\treturn undefined;\n};\n\nexport const derivePublicJwk = (privateJwk: PrivateJwk, kid?: string, alg?: SigningAlgorithm): PublicJwk =\u003e {\n\tif (privateJwk.kty === 'EC') {\n\t\tconst { crv, x, y } = privateJwk;\n\t\treturn { kty: 'EC', crv, x, y, kid, alg, use: 'sig' };\n\t}\n\n\tif (privateJwk.kty === 'RSA') {\n\t\tconst { n, e } = privateJwk;\n\t\treturn { kty: 'RSA', n, e, kid, alg, use: 'sig' };\n\t}\n\n\tthrow new Error(`unsupported key type`);\n};\n\nexport const importPrivateKeyFromJwk = async (jwk: PrivateJwk, alg: SigningAlgorithm): Promise\u003cCryptoKey\u003e =\u003e {\n\tif (!('d' in jwk) || !jwk.d) {\n\t\tthrow new Error(`expected a private key (missing 'd' parameter)`);\n\t}\n\n\tif (jwk.kty === 'EC' \u0026\u0026 !alg.startsWith('ES')) {\n\t\tthrow new Error(`algorithm ${alg} does not match ec key`);\n\t}\n\tif (jwk.kty === 'RSA' \u0026\u0026 alg.startsWith('ES')) {\n\t\tthrow new Error(`algorithm ${alg} does not match rsa key`);\n\t}\n\n\tconst algorithm = getImportAlgorithm(alg, jwk.kty === 'EC' ? jwk.crv : undefined);\n\tconst key = await crypto.subtle.importKey('jwk', jwk, algorithm, true, ['sign']);\n\n\tif (!(key instanceof CryptoKey)) {\n\t\tthrow new Error(`expected asymmetric key, got symmetric`);\n\t}\n\n\treturn key;\n};\n\nexport const exportPrivateJwkFromKey = async (\n\tkey: CryptoKey,\n\talg: SigningAlgorithm,\n\tkid?: string,\n): Promise\u003cPrivateJwk\u003e =\u003e {\n\tconst jwk = (await crypto.subtle.exportKey('jwk', key)) as PrivateJwk;\n\tjwk.alg = alg;\n\tif (kid) {\n\t\tjwk.kid = kid;\n\t}\n\treturn jwk;\n};\n\nexport const importPkcs8PrivateKey = async (pem: string, alg: SigningAlgorithm): Promise\u003cCryptoKey\u003e =\u003e {\n\tconst bytes = parsePkcs8Pem(pem);\n\tconst algorithm = getImportAlgorithm(alg);\n\n\tconst key = await crypto.subtle.importKey('pkcs8', bytes, algorithm, true, ['sign']);\n\n\tif (!(key instanceof CryptoKey)) {\n\t\tthrow new Error(`expected asymmetric key, got symmetric`);\n\t}\n\n\treturn key;\n};\n\nexport const exportPkcs8PrivateKey = async (key: CryptoKey): Promise\u003cstring\u003e =\u003e {\n\tconst pkcs8 = await crypto.subtle.exportKey('pkcs8', key);\n\tconst bytes = new Uint8Array(pkcs8);\n\tconst base64 = toBase64Pad(bytes);\n\n\treturn ['-----BEGIN PRIVATE KEY-----', ...chunk64(base64), '-----END PRIVATE KEY-----', ''].join('\\n');\n};\n\nconst parsePkcs8Pem = (pem: string): ArrayBuffer =\u003e {\n\tconst match = pem.match(/-----BEGIN PRIVATE KEY-----([\\s\\S]*?)-----END PRIVATE KEY-----/);\n\tif (!match) {\n\t\tthrow new Error(`invalid pkcs8 pem`);\n\t}\n\n\tconst base64 = match[1].replace(/\\s+/g, '');\n\tconst bytes = fromBase64Pad(base64);\n\tconst buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);\n\treturn buffer;\n};\n\nconst chunk64 = (input: string): string[] =\u003e {\n\tconst chunks: string[] = [];\n\tfor (let i = 0; i \u003c input.length; i += 64) {\n\t\tchunks.push(input.slice(i, i + 64));\n\t}\n\treturn chunks;\n};\n","import type { SigningAlgorithm } from '../jwk/types.js';\n\nconst HASH_BY_ALG: Record\u003cSigningAlgorithm, 'SHA-256' | 'SHA-384' | 'SHA-512'\u003e = {\n\tES256: 'SHA-256',\n\tES384: 'SHA-384',\n\tES512: 'SHA-512',\n\tPS256: 'SHA-256',\n\tPS384: 'SHA-384',\n\tPS512: 'SHA-512',\n\tRS256: 'SHA-256',\n\tRS384: 'SHA-384',\n\tRS512: 'SHA-512',\n};\n\nconst CURVE_BY_ALG: Record\u003cSigningAlgorithm, 'P-256' | 'P-384' | 'P-521' | null\u003e = {\n\tES256: 'P-256',\n\tES384: 'P-384',\n\tES512: 'P-521',\n\tPS256: null,\n\tPS384: null,\n\tPS512: null,\n\tRS256: null,\n\tRS384: null,\n\tRS512: null,\n};\n\nexport const getHashName = (alg: SigningAlgorithm): 'SHA-256' | 'SHA-384' | 'SHA-512' =\u003e {\n\treturn HASH_BY_ALG[alg];\n};\n\nexport const getNamedCurve = (alg: SigningAlgorithm): 'P-256' | 'P-384' | 'P-521' | null =\u003e {\n\treturn CURVE_BY_ALG[alg];\n};\n\nexport const getSignAlgorithm = (alg: SigningAlgorithm): AlgorithmIdentifier | EcdsaParams | RsaPssParams =\u003e {\n\tif (alg.startsWith('ES')) {\n\t\treturn { name: 'ECDSA', hash: { name: getHashName(alg) } };\n\t}\n\tif (alg.startsWith('PS')) {\n\t\treturn {\n\t\t\tname: 'RSA-PSS',\n\t\t\thash: { name: getHashName(alg) },\n\t\t\tsaltLength: getHashLength(getHashName(alg)),\n\t\t};\n\t}\n\treturn { name: 'RSASSA-PKCS1-v1_5' };\n};\n\nexport const getImportAlgorithm = (\n\talg: SigningAlgorithm,\n\tcurve?: 'P-256' | 'P-384' | 'P-521',\n): EcKeyImportParams | RsaHashedImportParams =\u003e {\n\tif (alg.startsWith('ES')) {\n\t\tconst namedCurve = curve ?? getNamedCurve(alg);\n\t\tif (!namedCurve) {\n\t\t\tthrow new Error(`unable to determine curve for ${alg}`);\n\t\t}\n\t\treturn { name: 'ECDSA', namedCurve };\n\t}\n\n\tif (alg.startsWith('PS')) {\n\t\treturn { name: 'RSA-PSS', hash: { name: getHashName(alg) } };\n\t}\n\n\treturn { name: 'RSASSA-PKCS1-v1_5', hash: { name: getHashName(alg) } };\n};\n\nexport const getGenerateAlgorithm = (alg: SigningAlgorithm): EcKeyGenParams | RsaHashedKeyGenParams =\u003e {\n\tconst curve = getNamedCurve(alg);\n\tif (curve) {\n\t\treturn { name: 'ECDSA', namedCurve: curve };\n\t}\n\n\tconst hash = { name: getHashName(alg) };\n\treturn {\n\t\tname: alg.startsWith('PS') ? 'RSA-PSS' : 'RSASSA-PKCS1-v1_5',\n\t\thash,\n\t\tmodulusLength: 2048,\n\t\tpublicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n\t};\n};\n\nconst getHashLength = (hash: 'SHA-256' | 'SHA-384' | 'SHA-512'): number =\u003e {\n\tswitch (hash) {\n\t\tcase 'SHA-256':\n\t\t\treturn 32;\n\t\tcase 'SHA-384':\n\t\t\treturn 48;\n\t\tcase 'SHA-512':\n\t\t\treturn 64;\n\t}\n};\n","import type { PrivateJwk, PublicJwk } from '../jwk/types.js';\n\nimport { derivePublicJwk, importPrivateKeyFromJwk } from './jwk.js';\n\n/**\n * cached key material for a JWK.\n */\nexport interface CachedKeyMaterial {\n\tcryptoKey: CryptoKey;\n\tpublicJwk: PublicJwk;\n}\n\n/**\n * cache for imported keys.\n * uses WeakMap so entries are garbage collected when JWK objects are no longer referenced.\n */\nconst keyCache = new WeakMap\u003cPrivateJwk, CachedKeyMaterial\u003e();\n\n/**\n * retrieves or creates cached key material for a JWK.\n *\n * @param jwk private JWK to get material for\n * @returns cached key material (CryptoKey and derived public JWK)\n */\nexport const getCachedKeyMaterial = async (jwk: PrivateJwk): Promise\u003cCachedKeyMaterial\u003e =\u003e {\n\tconst cached = keyCache.get(jwk);\n\tif (cached) {\n\t\treturn cached;\n\t}\n\n\tconst { alg } = jwk;\n\tconst cryptoKey = await importPrivateKeyFromJwk(jwk, alg);\n\tconst publicJwk = derivePublicJwk(jwk, jwk.kid, alg);\n\tconst material: CachedKeyMaterial = { cryptoKey, publicJwk };\n\n\tkeyCache.set(jwk, material);\n\n\treturn material;\n};\n\n/**\n * pre-populates the cache with already-imported key material.\n * useful for PKCS8 imports where we already have the CryptoKey.\n *\n * @param jwk private JWK to cache for\n * @param cryptoKey already-imported CryptoKey\n */\nexport const setCachedKeyMaterial = (jwk: PrivateJwk, cryptoKey: CryptoKey): void =\u003e {\n\tconst publicJwk = derivePublicJwk(jwk, jwk.kid, jwk.alg);\n\tkeyCache.set(jwk, { cryptoKey, publicJwk });\n};\n","import { fromBase64Url, toBase64Url } from '@atcute/multibase';\nimport { decodeUtf8From, encodeUtf8 } from '@atcute/uint8array';\n\nimport { getSignAlgorithm } from '../internal/crypto.js';\nimport type { SigningAlgorithm } from '../jwk/types.js';\n\n/**\n * signs a jwt using webcrypto.\n *\n * @param params signing parameters\n * @returns signed jwt\n */\nexport const signJwt = async (params: {\n\theader: Record\u003cstring, unknown\u003e;\n\tpayload: Record\u003cstring, unknown\u003e;\n\tkey: CryptoKey;\n\talg: SigningAlgorithm;\n}): Promise\u003cstring\u003e =\u003e {\n\tconst { header, payload, key, alg } = params;\n\tconst fullHeader = { ...header, alg };\n\tconst headerSegment = encodeSegment(fullHeader);\n\tconst payloadSegment = encodeSegment(payload);\n\tconst signingInput = `${headerSegment}.${payloadSegment}`;\n\n\tconst signature = await crypto.subtle.sign(\n\t\tgetSignAlgorithm(alg),\n\t\tkey,\n\t\tencodeUtf8(signingInput) as Uint8Array\u003cArrayBuffer\u003e,\n\t);\n\n\tconst signatureSegment = toBase64Url(new Uint8Array(signature));\n\n\treturn `${signingInput}.${signatureSegment}`;\n};\n\n/**\n * verifies a jwt and returns its payload.\n *\n * @param jwt jwt string\n * @param options verification options\n * @returns decoded payload\n */\nexport const verifyJwt = async (\n\tjwt: string,\n\toptions: { key: CryptoKey; alg: SigningAlgorithm; typ?: string },\n): Promise\u003cRecord\u003cstring, unknown\u003e\u003e =\u003e {\n\tconst { key, alg, typ } = options;\n\tconst parts = jwt.split('.');\n\tif (parts.length !== 3) {\n\t\tthrow new Error(`invalid jwt format`);\n\t}\n\n\tconst header = decodeSegment\u003cRecord\u003cstring, unknown\u003e\u003e(parts[0]);\n\tif (header.alg !== alg) {\n\t\tthrow new Error(`invalid jwt alg`);\n\t}\n\tif (typ \u0026\u0026 header.typ !== typ) {\n\t\tthrow new Error(`invalid jwt typ`);\n\t}\n\n\tconst payload = decodeSegment\u003cRecord\u003cstring, unknown\u003e\u003e(parts[1]);\n\tconst signature = fromBase64Url(parts[2]);\n\tconst signingInput = `${parts[0]}.${parts[1]}`;\n\n\tconst ok = await crypto.subtle.verify(\n\t\tgetSignAlgorithm(alg),\n\t\tkey,\n\t\tsignature,\n\t\tencodeUtf8(signingInput) as Uint8Array\u003cArrayBuffer\u003e,\n\t);\n\n\tif (!ok) {\n\t\tthrow new Error(`invalid jwt signature`);\n\t}\n\n\treturn payload;\n};\n\nconst encodeSegment = (value: unknown): string =\u003e {\n\treturn toBase64Url(encodeUtf8(JSON.stringify(value)));\n};\n\nconst decodeSegment = \u003cT\u003e(value: string): T =\u003e {\n\tconst bytes = fromBase64Url(value);\n\treturn JSON.parse(decodeUtf8From(bytes)) as T;\n};\n","import { getGenerateAlgorithm } from '../internal/crypto.js';\nimport { exportPrivateJwkFromKey } from '../internal/jwk.js';\nimport { setCachedKeyMaterial } from '../internal/key-cache.js';\nimport type { SigningAlgorithm } from '../jwk/types.js';\n\nimport type { ClientAssertionPrivateJwk } from './types.js';\n\n/**\n * generates a new client assertion private key.\n *\n * @param kid key id to assign\n * @param alg signing algorithm (defaults to es256)\n * @returns client assertion private JWK (with cache pre-warmed)\n */\nexport const generateClientAssertionKey = async (\n\tkid: string,\n\talg: SigningAlgorithm = 'ES256',\n): Promise\u003cClientAssertionPrivateJwk\u003e =\u003e {\n\tconst pair = await crypto.subtle.generateKey(getGenerateAlgorithm(alg), true, ['sign', 'verify']);\n\tconst jwk = (await exportPrivateJwkFromKey(pair.privateKey, alg, kid)) as ClientAssertionPrivateJwk;\n\n\t// pre-populate cache so we don't re-import\n\tsetCachedKeyMaterial(jwk, pair.privateKey);\n\n\treturn jwk;\n};\n","import { exportPrivateJwkFromKey, importPkcs8PrivateKey } from '../internal/jwk.js';\nimport { setCachedKeyMaterial } from '../internal/key-cache.js';\nimport type { SigningAlgorithm } from '../jwk/types.js';\n\nimport type { ClientAssertionPrivateJwk } from './types.js';\n\n/**\n * imports a client assertion private key from a pkcs8 pem string.\n *\n * @param pem pkcs8 pem string\n * @param options import options (kid + alg)\n * @returns client assertion private JWK (with cache pre-warmed)\n */\nexport const importClientAssertionPkcs8 = async (\n\tpem: string,\n\toptions: { kid: string; alg: SigningAlgorithm },\n): Promise\u003cClientAssertionPrivateJwk\u003e =\u003e {\n\tconst { kid, alg } = options;\n\tconst cryptoKey = await importPkcs8PrivateKey(pem, alg);\n\tconst jwk = (await exportPrivateJwkFromKey(cryptoKey, alg, kid)) as ClientAssertionPrivateJwk;\n\n\t// pre-populate cache so we don't re-import\n\tsetCachedKeyMaterial(jwk, cryptoKey);\n\n\treturn jwk;\n};\n","import { toBase64Url } from '@atcute/multibase';\nimport { encodeUtf8, toSha256 } from '@atcute/uint8array';\n\n/**\n * computes sha-256 hash and returns base64url-encoded result.\n *\n * @param input string to hash\n * @returns base64url-encoded sha-256 hash\n */\nexport const sha256Base64Url = async (input: string): Promise\u003cstring\u003e =\u003e {\n\tconst bytes = encodeUtf8(input);\n\tconst digest = await toSha256(bytes);\n\treturn toBase64Url(digest);\n};\n","import { nanoid } from 'nanoid';\n\nimport type { CachedKeyMaterial } from '../internal/key-cache.js';\nimport { getCachedKeyMaterial } from '../internal/key-cache.js';\nimport { signJwt } from '../jwt/index.js';\n\nimport type { DpopPrivateJwk } from './types.js';\n\n/**\n * creates a DPoP proof signer.\n *\n * @param jwk DPoP private JWK (with `alg` set)\n * @returns signing function for DPoP proofs\n */\nexport const createDpopProofSigner = (\n\tjwk: DpopPrivateJwk,\n): ((htm: string, htu: string, nonce?: string, ath?: string) =\u003e Promise\u003cstring\u003e) =\u003e {\n\tconst alg = jwk.alg;\n\n\t// lazily resolve key material on first sign\n\tlet materialPromise: Promise\u003cCachedKeyMaterial\u003e | undefined;\n\n\treturn async (htm: string, htu: string, nonce?: string, ath?: string) =\u003e {\n\t\tmaterialPromise ||= getCachedKeyMaterial(jwk);\n\t\tconst { cryptoKey, publicJwk } = await materialPromise;\n\n\t\tconst now = Math.floor(Date.now() / 1_000);\n\n\t\treturn signJwt({\n\t\t\theader: {\n\t\t\t\ttyp: 'dpop+jwt',\n\t\t\t\tjwk: publicJwk,\n\t\t\t},\n\t\t\tpayload: {\n\t\t\t\thtm,\n\t\t\t\thtu,\n\t\t\t\tiat: now,\n\t\t\t\tjti: nanoid(24),\n\t\t\t\tnonce,\n\t\t\t\tath,\n\t\t\t},\n\t\t\tkey: cryptoKey,\n\t\t\talg,\n\t\t});\n\t};\n};\n","import { sha256Base64Url } from '../hash/sha256.js';\n\nimport { createDpopProofSigner } from './proof.js';\nimport type { DpopPrivateJwk, DpopNonceCache } from './types.js';\n\nexport interface CreateDpopFetchOptions {\n\t/** DPoP private key (JWK with `alg` set) */\n\tkey: DpopPrivateJwk;\n\t/** nonce store, keyed by origin */\n\tnonces: DpopNonceCache;\n\t/** server's supported DPoP signing algorithms */\n\tsupportedAlgs?: readonly string[];\n\t/**\n\t * is the target an authorization server (true) or resource server (false)?\n\t * affects how `use_dpop_nonce` errors are detected.\n\t */\n\tisAuthServer?: boolean;\n\t/** custom fetch implementation */\n\tfetch?: typeof globalThis.fetch;\n}\n\n/**\n * creates a fetch wrapper that adds DPoP proofs to requests.\n *\n * @param options DPoP configuration\n * @returns fetch function with DPoP support\n */\nexport const createDpopFetch = (options: CreateDpopFetchOptions): typeof globalThis.fetch =\u003e {\n\tconst { key, nonces, supportedAlgs, isAuthServer, fetch = globalThis.fetch } = options;\n\n\tnegotiateAlg(key, supportedAlgs);\n\tconst sign = createDpopProofSigner(key);\n\n\treturn async (input, init) =\u003e {\n\t\tconst request: Request = init == null \u0026\u0026 input instanceof Request ? input : new Request(input, init);\n\n\t\tconst authHeader = request.headers.get('Authorization');\n\t\tconst ath = authHeader?.startsWith('DPoP ') ? await sha256Base64Url(authHeader.slice(5)) : undefined;\n\n\t\tconst { origin } = new URL(request.url);\n\t\tconst htm = request.method;\n\t\tconst htu = buildHtu(request.url);\n\n\t\tlet initNonce: string | undefined;\n\t\ttry {\n\t\t\tinitNonce = await nonces.get(origin);\n\t\t} catch {\n\t\t\t// ignore get errors\n\t\t}\n\n\t\tconst initProof = await sign(htm, htu, initNonce, ath);\n\t\trequest.headers.set('DPoP', initProof);\n\n\t\tconst initResponse = await fetch(request);\n\n\t\tconst nextNonce = initResponse.headers.get('DPoP-Nonce');\n\t\tif (!nextNonce || nextNonce === initNonce) {\n\t\t\treturn initResponse;\n\t\t}\n\n\t\ttry {\n\t\t\tawait nonces.set(origin, nextNonce);\n\t\t} catch {\n\t\t\t// ignore set errors\n\t\t}\n\n\t\tconst shouldRetry = await isUseDpopNonceError(initResponse, isAuthServer);\n\t\tif (!shouldRetry) {\n\t\t\treturn initResponse;\n\t\t}\n\n\t\tif (input === request || init?.body instanceof ReadableStream) {\n\t\t\treturn initResponse;\n\t\t}\n\n\t\tawait initResponse.body?.cancel();\n\n\t\tconst nextProof = await sign(htm, htu, nextNonce, ath);\n\t\tconst nextRequest = new Request(input, init);\n\t\tnextRequest.headers.set('DPoP', nextProof);\n\n\t\tconst retryResponse = await fetch(nextRequest);\n\n\t\tconst retryNonce = retryResponse.headers.get('DPoP-Nonce');\n\t\tif (retryNonce \u0026\u0026 retryNonce !== nextNonce) {\n\t\t\ttry {\n\t\t\t\tawait nonces.set(origin, retryNonce);\n\t\t\t} catch {\n\t\t\t\t// ignore set errors\n\t\t\t}\n\t\t}\n\n\t\treturn retryResponse;\n\t};\n};\n\nconst buildHtu = (url: string): string =\u003e {\n\tconst fragmentIdx = url.indexOf('#');\n\tconst queryIdx = url.indexOf('?');\n\tconst end = fragmentIdx === -1 ? queryIdx : queryIdx === -1 ? fragmentIdx : Math.min(fragmentIdx, queryIdx);\n\n\treturn end === -1 ? url : url.slice(0, end);\n};\n\nconst negotiateAlg = (key: DpopPrivateJwk, supportedAlgs?: readonly string[]): string =\u003e {\n\tconst keyAlg = key.alg;\n\n\tif (supportedAlgs?.length) {\n\t\tif (supportedAlgs.includes(keyAlg)) {\n\t\t\treturn keyAlg;\n\t\t}\n\t\tthrow new Error(`DPoP key algorithm ${keyAlg} not supported by server: ${supportedAlgs.join(', ')}`);\n\t}\n\n\treturn keyAlg;\n};\n\nconst isUseDpopNonceError = async (response: Response, isAuthServer?: boolean): Promise\u003cboolean\u003e =\u003e {\n\tif (isAuthServer === undefined || isAuthServer === false) {\n\t\tif (response.status === 401) {\n\t\t\tconst wwwAuth = response.headers.get('WWW-Authenticate');\n\t\t\tif (wwwAuth?.startsWith('DPoP')) {\n\t\t\t\treturn wwwAuth.includes('error=\"use_dpop_nonce\"');\n\t\t\t}\n\t\t}\n\t}\n\n\tif (isAuthServer === undefined || isAuthServer === true) {\n\t\tif (response.status === 400) {\n\t\t\ttry {\n\t\t\t\tconst json = await response.clone().json();\n\t\t\t\treturn typeof json === 'object' \u0026\u0026 json?.error === 'use_dpop_nonce';\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n};\n","import { getGenerateAlgorithm } from '../internal/crypto.js';\nimport { exportPrivateJwkFromKey, isSigningAlgorithm } from '../internal/jwk.js';\nimport { setCachedKeyMaterial } from '../internal/key-cache.js';\nimport type { SigningAlgorithm } from '../jwk/types.js';\n\nimport type { DpopPrivateJwk } from './types.js';\n\n/**\n * preferred algorithm order for DPoP key generation.\n */\nconst PREFERRED_ALGORITHMS: readonly SigningAlgorithm[] = [\n\t'ES256',\n\t'ES384',\n\t'ES512',\n\t'PS256',\n\t'PS384',\n\t'PS512',\n\t'RS256',\n\t'RS384',\n\t'RS512',\n];\n\nconst sortAlgorithms = (algs: readonly SigningAlgorithm[]): SigningAlgorithm[] =\u003e {\n\treturn [...algs].sort((a, b) =\u003e {\n\t\tconst aIdx = PREFERRED_ALGORITHMS.indexOf(a);\n\t\tconst bIdx = PREFERRED_ALGORITHMS.indexOf(b);\n\n\t\tif (aIdx === -1 \u0026\u0026 bIdx === -1) {\n\t\t\treturn 0;\n\t\t}\n\t\tif (aIdx === -1) {\n\t\t\treturn 1;\n\t\t}\n\t\tif (bIdx === -1) {\n\t\t\treturn -1;\n\t\t}\n\n\t\treturn aIdx - bIdx;\n\t});\n};\n\n/**\n * generates a new DPoP private JWK with `alg` set.\n *\n * @param supportedAlgs server supported algorithms (optional)\n * @returns private JWK (with cache pre-warmed)\n */\nexport const generateDpopKey = async (supportedAlgs?: readonly string[]): Promise\u003cDpopPrivateJwk\u003e =\u003e {\n\tconst normalized = supportedAlgs?.filter(isSigningAlgorithm) ?? [];\n\tif (supportedAlgs?.length \u0026\u0026 normalized.length === 0) {\n\t\tthrow new Error(`no supported algorithms provided`);\n\t}\n\n\tconst algs: SigningAlgorithm[] = normalized.length ? sortAlgorithms(normalized) : ['ES256'];\n\tconst errors: unknown[] = [];\n\n\tfor (const alg of algs) {\n\t\ttry {\n\t\t\tconst pair = await crypto.subtle.generateKey(getGenerateAlgorithm(alg), true, ['sign', 'verify']);\n\t\t\tconst jwk = (await exportPrivateJwkFromKey(pair.privateKey, alg)) as DpopPrivateJwk;\n\n\t\t\t// pre-populate cache so we don't re-import\n\t\t\tsetCachedKeyMaterial(jwk, pair.privateKey);\n\n\t\t\treturn jwk;\n\t\t} catch (err) {\n\t\t\terrors.push(err);\n\t\t}\n\t}\n\n\tthrow new AggregateError(errors, `failed to generate DPoP key for any of: ${algs.join(', ')}`);\n};\n","import { fromBase64Url } from '@atcute/multibase';\nimport { decodeUtf8From } from '@atcute/uint8array';\n\nimport * as v from '@badrap/valita';\n\nimport { getImportAlgorithm } from '../internal/crypto.js';\nimport { computeJktFromJwk } from '../jwk/compute-jkt.js';\nimport type { PublicJwk, SigningAlgorithm } from '../jwk/types.js';\nimport { verifyJwt } from '../jwt/index.js';\n\nimport type { Awaitable } from './types.js';\n\nconst dpopJwkSchema = v.union(\n\tv.object({\n\t\tkty: v.literal('EC'),\n\t\tcrv: v.union(v.literal('P-256'), v.literal('P-384'), v.literal('P-521')),\n\t\tx: v.string(),\n\t\ty: v.string(),\n\t}),\n\tv.object({\n\t\tkty: v.literal('RSA'),\n\t\te: v.string(),\n\t\tn: v.string(),\n\t}),\n);\n\nconst dpopHeaderSchema = v.object({\n\ttyp: v.literal('dpop+jwt'),\n\talg: v.string().assert((alg) =\u003e alg !== 'none', 'alg must not be \"none\"'),\n\tjwk: dpopJwkSchema,\n});\n\nconst dpopPayloadSchema = v.object({\n\thtm: v.string(),\n\thtu: v.string(),\n\tiat: v.number(),\n\tjti: v.string(),\n\tnonce: v.string().optional(),\n});\n\nexport type DpopClaims = v.Infer\u003ctypeof dpopPayloadSchema\u003e;\ntype DpopJwk = v.Infer\u003ctypeof dpopJwkSchema\u003e;\n\nexport interface DpopVerifyResult {\n\tclaims: DpopClaims;\n\tjkt: string;\n\tjwk: PublicJwk;\n}\n\nexport interface DpopVerifyOptions {\n\tmethod: string;\n\turl: string;\n\tnonce?: { check(nonce: string): Awaitable\u003cboolean\u003e };\n\tmaxClockSkew?: number;\n}\n\n/**\n * error thrown when dpop verification fails.\n */\nexport class DpopVerifyError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic code: 'missing' | 'invalid' | 'expired' | 'nonce_required',\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'DpopVerifyError';\n\t}\n}\n\n/**\n * verifies a dpop proof from a request header.\n *\n * @param dpopHeader dpop header value\n * @param options verification options\n * @returns verification result with claims and jwk thumbprint\n * @throws {DpopVerifyError} if verification fails\n */\nexport const verifyDpopProof = async (\n\tdpopHeader: string | null | undefined,\n\toptions: DpopVerifyOptions,\n): Promise\u003cDpopVerifyResult\u003e =\u003e {\n\tif (!dpopHeader) {\n\t\tthrow new DpopVerifyError(`missing dpop header`, 'missing');\n\t}\n\n\tconst { method, url, nonce: dpopNonce, maxClockSkew = 60 } = options;\n\tconst parts = dpopHeader.split('.');\n\tif (parts.length !== 3) {\n\t\tthrow new DpopVerifyError(`invalid dpop proof format`, 'invalid');\n\t}\n\n\tlet header: v.Infer\u003ctypeof dpopHeaderSchema\u003e;\n\ttry {\n\t\theader = dpopHeaderSchema.parse(decodeSegment(parts[0]), { mode: 'passthrough' });\n\t} catch {\n\t\tthrow new DpopVerifyError(`invalid dpop header`, 'invalid');\n\t}\n\n\tconst { jwk, alg } = header;\n\tif (!isSigningAlgorithm(alg)) {\n\t\tthrow new DpopVerifyError(`unsupported dpop alg`, 'invalid');\n\t}\n\n\tlet payload: DpopClaims;\n\ttry {\n\t\tconst key = await importPublicKey(jwk, alg);\n\t\tconst raw = await verifyJwt(dpopHeader, { key, alg, typ: 'dpop+jwt' });\n\t\tpayload = dpopPayloadSchema.parse(raw, { mode: 'passthrough' });\n\t} catch (err) {\n\t\tif (err instanceof v.ValitaError) {\n\t\t\tthrow new DpopVerifyError(`invalid dpop payload`, 'invalid');\n\t\t}\n\t\tthrow new DpopVerifyError(`dpop signature verification failed`, 'invalid');\n\t}\n\n\tif (payload.htm !== method) {\n\t\tthrow new DpopVerifyError(`dpop htm mismatch: expected ${method}, got ${payload.htm}`, 'invalid');\n\t}\n\tif (payload.htu !== url) {\n\t\tthrow new DpopVerifyError(`dpop htu mismatch: expected ${url}, got ${payload.htu}`, 'invalid');\n\t}\n\n\tconst now = Math.floor(Date.now() / 1000);\n\tif (payload.iat \u003e now + maxClockSkew) {\n\t\tthrow new DpopVerifyError(`dpop proof issued in the future`, 'invalid');\n\t}\n\tif (payload.iat \u003c now - maxClockSkew) {\n\t\tthrow new DpopVerifyError(`dpop proof expired`, 'expired');\n\t}\n\n\tif (dpopNonce) {\n\t\tif (!payload.nonce || !(await dpopNonce.check(payload.nonce))) {\n\t\t\tthrow new DpopVerifyError(`invalid or missing dpop nonce`, 'nonce_required');\n\t\t}\n\t}\n\n\tconst jkt = await computeJktFromJwk(jwk as PublicJwk);\n\n\treturn { claims: payload, jwk: jwk as DpopJwk, jkt };\n};\n\nconst importPublicKey = async (jwk: PublicJwk, alg: SigningAlgorithm): Promise\u003cCryptoKey\u003e =\u003e {\n\tconst algorithm = getImportAlgorithm(alg, jwk.kty === 'EC' ? jwk.crv : undefined);\n\tconst key = await crypto.subtle.importKey('jwk', jwk, algorithm, true, ['verify']);\n\tif (!(key instanceof CryptoKey)) {\n\t\tthrow new Error(`expected asymmetric key, got symmetric`);\n\t}\n\n\treturn key;\n};\n\nconst isSigningAlgorithm = (alg: string): alg is SigningAlgorithm =\u003e {\n\treturn (\n\t\talg === 'ES256' ||\n\t\talg === 'ES384' ||\n\t\talg === 'ES512' ||\n\t\talg === 'PS256' ||\n\t\talg === 'PS384' ||\n\t\talg === 'PS512' ||\n\t\talg === 'RS256' ||\n\t\talg === 'RS384' ||\n\t\talg === 'RS512'\n\t);\n};\n\nconst decodeSegment = (segment: string): unknown =\u003e {\n\tconst bytes = fromBase64Url(segment);\n\treturn JSON.parse(decodeUtf8From(bytes));\n};\n","import { toBase64Url } from '@atcute/multibase';\nimport { encodeUtf8, toSha256 } from '@atcute/uint8array';\n\nimport type { PublicJwk } from './types.js';\n\n/**\n * computes the jwk thumbprint (rfc 7638) for a public key.\n *\n * @param jwk public jwk\n * @returns base64url-encoded sha-256 thumbprint\n */\nexport const computeJktFromJwk = async (jwk: PublicJwk): Promise\u003cstring\u003e =\u003e {\n\tlet canonical: Record\u003cstring, string\u003e;\n\n\tif (jwk.kty === 'EC') {\n\t\tconst { crv, x, y } = jwk;\n\t\tcanonical = { crv, kty: jwk.kty, x, y };\n\t} else {\n\t\tconst { e, n } = jwk;\n\t\tcanonical = { e, kty: jwk.kty, n };\n\t}\n\n\tconst serialized = JSON.stringify(canonical);\n\tconst hash = await toSha256(encodeUtf8(serialized));\n\n\treturn toBase64Url(hash);\n};\n","import { nanoid } from 'nanoid';\n\nimport { sha256Base64Url } from './sha256.js';\n\n/**\n * generates pkce verifier and challenge (s256).\n *\n * @param length verifier length (43-128 per rfc 7636)\n * @returns pkce values\n */\nexport const generatePkce = async (\n\tlength = 64,\n): Promise\u003c{ verifier: string; challenge: string; method: 'S256' }\u003e =\u003e {\n\tconst verifier = nanoid(length);\n\tconst challenge = await sha256Base64Url(verifier);\n\n\treturn { verifier, challenge, method: 'S256' };\n};\n","import { exportPkcs8PrivateKey as exportPkcs8 } from '../internal/jwk.js';\nimport { getCachedKeyMaterial } from '../internal/key-cache.js';\n\nimport type { PrivateJwk } from './types.js';\n\n/**\n * exports a private JWK to PKCS8 PEM format.\n *\n * @param jwk private JWK to export\n * @returns PKCS8 PEM string\n */\nexport const exportPkcs8PrivateKey = async (jwk: PrivateJwk): Promise\u003cstring\u003e =\u003e {\n\tconst { cryptoKey } = await getCachedKeyMaterial(jwk);\n\treturn exportPkcs8(cryptoKey);\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/uint8array@1.1.1/es2022/uint8array.mjs
··· 1 + /* esm.sh - @atcute/uint8array@1.1.1 */ 2 + var E=new TextEncoder,S=new TextDecoder,I=crypto.subtle,j=n=>new Uint8Array(n),D=j,L=(n,e)=>{let t=n.length,u=e.length;if(t>u)return 1;if(t<u)return-1;for(let r=0;r<t;r++){let c=n[r],o=e[r];if(c<o)return-1;if(c>o)return 1}return 0},R=(n,e)=>{if(n===e)return!0;let t;if((t=n.length)===e.length){for(;t--;)if(n[t]!==e[t])return!1}return t===-1},T=(n,e)=>{let t,u=0;if((t=n.length)===e.length)for(;t--;)u|=n[t]^e[t];return t===-1&&u===0},_=(n,e)=>{let t=0,u=n.length,r;if(e===void 0)for(r=e=0;r<u;r++){let o=n[r];e+=o.length}let c=new Uint8Array(e);for(r=0;r<u;r++){let o=n[r];c.set(o,t),t+=o.length}return c},B=n=>E.encode(n),F=(n,e,t,u)=>{let r;return t===void 0?r=n:u===void 0?r=n.subarray(t):r=n.subarray(t,t+u),E.encodeInto(e,r).written},s=String.fromCharCode,q=(n,e,t)=>{if(t<4){if(t<2){if(t===0)return"";let k=n[e];return k&128?null:s(k)}let l=n[e],x=n[e+1];if((l|x)&128)return null;if(t===2)return s(l,x);let h=n[e+2];return h&128?null:s(l,x,h)}let u=n[e],r=n[e+1],c=n[e+2],o=n[e+3];if((u|r|c|o)&128)return null;if(t<8){if(t===4)return s(u,r,c,o);let l=n[e+4];if(l&128)return null;if(t===5)return s(u,r,c,o,l);let x=n[e+5];if(x&128)return null;if(t===6)return s(u,r,c,o,l,x);let h=n[e+6];return h&128?null:s(u,r,c,o,l,x,h)}let i=n[e+4],f=n[e+5],d=n[e+6],a=n[e+7];if((i|f|d|a)&128)return null;if(t<12){if(t===8)return s(u,r,c,o,i,f,d,a);let l=n[e+8];if(l&128)return null;if(t===9)return s(u,r,c,o,i,f,d,a,l);let x=n[e+9];if(x&128)return null;if(t===10)return s(u,r,c,o,i,f,d,a,l,x);let h=n[e+10];return h&128?null:s(u,r,c,o,i,f,d,a,l,x,h)}let w=n[e+8],b=n[e+9],A=n[e+10],C=n[e+11];if((w|b|A|C)&128)return null;if(t===12)return s(u,r,c,o,i,f,d,a,w,b,A,C);let U=n[e+12];if(U&128)return null;if(t===13)return s(u,r,c,o,i,f,d,a,w,b,A,C,U);let y=n[e+13];if(y&128)return null;if(t===14)return s(u,r,c,o,i,f,d,a,w,b,A,C,U,y);let g=n[e+14];return g&128?null:s(u,r,c,o,i,f,d,a,w,b,A,C,U,y,g)},H=(n,e=0,t=n.length)=>{if(t<=15){let u=q(n,e,t);if(u!==null)return u}return e===0&&t===n.length?S.decode(n):S.decode(n.subarray(e,e+t))},V=n=>{let e=n.length,t=0,u=0;for(;t+3<e;){let r=n.charCodeAt(t),c=n.charCodeAt(t+1),o=n.charCodeAt(t+2),i=n.charCodeAt(t+3);if((r|c|o|i)>=128)break;t+=4,u+=4}for(;t<e;){let r=n.charCodeAt(t);r<128?(t+=1,u+=1):r<2048?(t+=1,u+=2):r<55296||r>56319?(t+=1,u+=3):(t+=2,u+=4)}return u},v=(n,e,t)=>{let u=n.length;if(u*3<e)return!1;if(u>=e&&u*3<=t)return!0;let r=0,c=0;for(;r<u;){let o=n.charCodeAt(r);if(o<128?(r+=1,c+=1):o<2048?(r+=1,c+=2):o<55296||o>56319?(r+=1,c+=3):(r+=2,c+=4),c>t)return!1}return c>=e},G=async n=>new Uint8Array(await I.digest("SHA-256",n)),J=n=>crypto.getRandomValues(new Uint8Array(n));export{j as alloc,D as allocUnsafe,L as compare,_ as concat,H as decodeUtf8From,B as encodeUtf8,F as encodeUtf8Into,R as equals,V as getUtf8Length,v as isUtf8LengthInRange,J as randomBytes,T as timingSafeEquals,G as toSha256}; 3 + //# sourceMappingURL=./uint8array.mjs.map
+1
vendor/esm.sh/@atcute/uint8array@1.1.1/es2022/uint8array.mjs.map
··· 1 + {"mappings":";AAAA,IAAMA,EAAc,IAAI,YAClBC,EAAc,IAAI,YAElBC,EAAS,OAAO,OAKTC,EAASC,GACd,IAAI,WAAWA,CAAI,EAOdC,EAAcF,EAKdG,EAAU,CAACC,EAAeC,IAA0B,CAChE,IAAMC,EAAOF,EAAE,OACTG,EAAOF,EAAE,OAEf,GAAIC,EAAOC,EACV,MAAO,GAER,GAAID,EAAOC,EACV,MAAO,GAGR,QAASC,EAAI,EAAGA,EAAIF,EAAME,IAAK,CAC9B,IAAMC,EAAKL,EAAEI,CAAC,EACRE,EAAKL,EAAEG,CAAC,EAEd,GAAIC,EAAKC,EACR,MAAO,GAGR,GAAID,EAAKC,EACR,MAAO,E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,GAAU,EACVC,GAAS,GACCC,EAAO,MACjBF,GAAU,EACVC,GAAS,GACCC,EAAO,OAAUA,EAAO,OAClCF,GAAU,EACVC,GAAS,IAETD,GAAU,EACVC,GAAS,EAEX,CAEA,OAAOA,CAAM,EAWDE,EAAsB,CAAC3B,EAAa4B,EAAaC,IAAyB,CACtF,IAAMvC,EAAMU,EAAI,OAGhB,GAAIV,EAAM,EAAIsC,EACb,MAAO,GAIR,GAAItC,GAAOsC,GAAOtC,EAAM,GAAKuC,EAC5B,MAAO,GAGR,IAAIL,EAAS,EACTC,EAAQ,EAEZ,KAAOD,EAASlC,GAAK,CACpB,IAAMoC,EAAO1B,EAAI,WAAWwB,CAAM,EAiBlC,GAfIE,EAAO,KACVF,GAAU,EACVC,GAAS,GACCC,EAAO,MACjBF,GAAU,EACVC,GAAS,GACCC,EAAO,OAAUA,EAAO,OAClCF,GAAU,EACVC,GAAS,IAETD,GAAU,EACVC,GAAS,GAINA,EAAQI,EACX,MAAO,EAET,CAEA,OAAOJ,GAASG,CAAI,EAMRE,EAAW,MAAOhC,GACvB,IAAI,WAAW,MAAMrB,EAAO,OAAO,UAAWqB,CAAM,CAAC,EAQhDiC,EAAepD,GACpB,OAAO,gBAAgB,IAAI,WAAWA,CAAI,CAAC","names":["textEncoder","textDecoder","subtle","alloc","size","allocUnsafe","compare","a","b","alen","blen","i","ax","bx","equals","len","timingSafeEquals","out","concat","arrays","written","idx","chunk","buffer","encodeUtf8","str","encodeUtf8Into","to","offset","length","_fromCharCode","_shortString","from","p","c","d","e","f","g","h","j","k","l","m","n","o","decodeUtf8From","result","getUtf8Length","u16pos","u8pos","code","isUtf8LengthInRange","min","max","toSha256","randomBytes"],"sources":["../esm/npm/@atcute/uint8array@1.1.1/node_modules/@atcute/uint8array/lib/index.ts"],"sourcesContent":["const textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\n\nconst subtle = crypto.subtle;\n\n/**\n * creates an Uint8Array of the requested size, with the contents zeroed\n */\nexport const alloc = (size: number): Uint8Array\u003cArrayBuffer\u003e =\u003e {\n\treturn new Uint8Array(size);\n};\n\n/**\n * creates an Uint8Array of the requested size, where the contents may not be\n * zeroed out. only use if you're certain that the contents will be overwritten\n */\nexport const allocUnsafe = alloc;\n\n/**\n * compares two Uint8Array buffers\n */\nexport const compare = (a: Uint8Array, b: Uint8Array): number =\u003e {\n\tconst alen = a.length;\n\tconst blen = b.length;\n\n\tif (alen \u003e blen) {\n\t\treturn 1;\n\t}\n\tif (alen \u003c blen) {\n\t\treturn -1;\n\t}\n\n\tfor (let i = 0; i \u003c alen; i++) {\n\t\tconst ax = a[i];\n\t\tconst bx = b[i];\n\n\t\tif (ax \u003c bx) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif (ax \u003e bx) {\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\treturn 0;\n};\n\n/**\n * checks if the two Uint8Array buffers are equal\n */\nexport const equals = (a: Uint8Array, b: Uint8Array): boolean =\u003e {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tlet len: number;\n\tif ((len = a.length) === b.length) {\n\t\twhile (len--) {\n\t\t\tif (a[len] !== b[len]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn len === -1;\n};\n\n/**\n * checks if the two Uint8Array buffers are equal, timing-safe version\n */\nexport const timingSafeEquals = (a: Uint8Array, b: Uint8Array): boolean =\u003e {\n\tlet len: number;\n\tlet out = 0;\n\tif ((len = a.length) === b.length) {\n\t\twhile (len--) {\n\t\t\tout |= a[len] ^ b[len];\n\t\t}\n\t}\n\n\treturn len === -1 \u0026\u0026 out === 0;\n};\n\n/**\n * concatenates multiple Uint8Array buffers into one\n */\nexport const concat = (arrays: Uint8Array[], size?: number): Uint8Array\u003cArrayBuffer\u003e =\u003e {\n\tlet written = 0;\n\n\tlet len = arrays.length;\n\tlet idx: number;\n\n\tif (size === undefined) {\n\t\tfor (idx = size = 0; idx \u003c len; idx++) {\n\t\t\tconst chunk = arrays[idx];\n\t\t\tsize += chunk.length;\n\t\t}\n\t}\n\n\tconst buffer = new Uint8Array(size);\n\n\tfor (idx = 0; idx \u003c len; idx++) {\n\t\tconst chunk = arrays[idx];\n\n\t\tbuffer.set(chunk, written);\n\t\twritten += chunk.length;\n\t}\n\n\treturn buffer;\n};\n\n/**\n * encodes a UTF-8 string\n */\nexport const encodeUtf8 = (str: string): Uint8Array\u003cArrayBuffer\u003e =\u003e {\n\treturn textEncoder.encode(str);\n};\n\n/**\n * encodes a UTF-8 string into a given buffer\n */\nexport const encodeUtf8Into = (to: Uint8Array, str: string, offset?: number, length?: number): number =\u003e {\n\tlet buffer: Uint8Array;\n\n\tif (offset === undefined) {\n\t\tbuffer = to;\n\t} else if (length === undefined) {\n\t\tbuffer = to.subarray(offset);\n\t} else {\n\t\tbuffer = to.subarray(offset, offset + length);\n\t}\n\n\tconst result = textEncoder.encodeInto(str, buffer);\n\n\treturn result.written;\n};\n\nconst _fromCharCode = String.fromCharCode;\n\n// fully unrolled short string decoder, inspired by cbor-x\n// returns null if non-ASCII byte encountered, signaling fallback to TextDecoder\nconst _shortString = (from: Uint8Array, p: number, length: number): string | null =\u003e {\n\tif (length \u003c 4) {\n\t\tif (length \u003c 2) {\n\t\t\tif (length === 0) return '';\n\t\t\tconst a = from[p];\n\t\t\tif (a \u0026 0x80) return null;\n\t\t\treturn _fromCharCode(a);\n\t\t}\n\t\tconst a = from[p];\n\t\tconst b = from[p + 1];\n\t\tif ((a | b) \u0026 0x80) return null;\n\t\tif (length === 2) return _fromCharCode(a, b);\n\t\tconst c = from[p + 2];\n\t\tif (c \u0026 0x80) return null;\n\t\treturn _fromCharCode(a, b, c);\n\t}\n\tconst a = from[p];\n\tconst b = from[p + 1];\n\tconst c = from[p + 2];\n\tconst d = from[p + 3];\n\tif ((a | b | c | d) \u0026 0x80) return null;\n\tif (length \u003c 8) {\n\t\tif (length === 4) return _fromCharCode(a, b, c, d);\n\t\tconst e = from[p + 4];\n\t\tif (e \u0026 0x80) return null;\n\t\tif (length === 5) return _fromCharCode(a, b, c, d, e);\n\t\tconst f = from[p + 5];\n\t\tif (f \u0026 0x80) return null;\n\t\tif (length === 6) return _fromCharCode(a, b, c, d, e, f);\n\t\tconst g = from[p + 6];\n\t\tif (g \u0026 0x80) return null;\n\t\treturn _fromCharCode(a, b, c, d, e, f, g);\n\t}\n\tconst e = from[p + 4];\n\tconst f = from[p + 5];\n\tconst g = from[p + 6];\n\tconst h = from[p + 7];\n\tif ((e | f | g | h) \u0026 0x80) return null;\n\tif (length \u003c 12) {\n\t\tif (length === 8) return _fromCharCode(a, b, c, d, e, f, g, h);\n\t\tconst i = from[p + 8];\n\t\tif (i \u0026 0x80) return null;\n\t\tif (length === 9) return _fromCharCode(a, b, c, d, e, f, g, h, i);\n\t\tconst j = from[p + 9];\n\t\tif (j \u0026 0x80) return null;\n\t\tif (length === 10) return _fromCharCode(a, b, c, d, e, f, g, h, i, j);\n\t\tconst k = from[p + 10];\n\t\tif (k \u0026 0x80) return null;\n\t\treturn _fromCharCode(a, b, c, d, e, f, g, h, i, j, k);\n\t}\n\tconst i = from[p + 8];\n\tconst j = from[p + 9];\n\tconst k = from[p + 10];\n\tconst l = from[p + 11];\n\tif ((i | j | k | l) \u0026 0x80) return null;\n\tif (length === 12) return _fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l);\n\tconst m = from[p + 12];\n\tif (m \u0026 0x80) return null;\n\tif (length === 13) return _fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m);\n\tconst n = from[p + 13];\n\tif (n \u0026 0x80) return null;\n\tif (length === 14) return _fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n);\n\tconst o = from[p + 14];\n\tif (o \u0026 0x80) return null;\n\treturn _fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);\n};\n\n/**\n * decodes a UTF-8 string from a given buffer\n * @param from source buffer\n * @param offset byte offset to start reading from\n * @param length number of bytes to read\n * @returns decoded string\n */\nexport const decodeUtf8From = (\n\tfrom: Uint8Array,\n\toffset: number = 0,\n\tlength: number = from.length,\n): string =\u003e {\n\tif (length \u003c= 15) {\n\t\tconst result = _shortString(from, offset, length);\n\t\tif (result !== null) return result;\n\t}\n\tif (offset === 0 \u0026\u0026 length === from.length) {\n\t\treturn textDecoder.decode(from);\n\t}\n\treturn textDecoder.decode(from.subarray(offset, offset + length));\n};\n\n/**\n * calculates the UTF-8 byte length of a string\n * @param str string to measure\n * @returns byte length when encoded as UTF-8\n */\nexport const getUtf8Length = (str: string): number =\u003e {\n\tconst len = str.length;\n\n\tlet u16pos = 0;\n\tlet u8pos = 0;\n\n\t// ASCII fast-path: batch process 4 chars at a time\n\twhile (u16pos + 3 \u003c len) {\n\t\tconst a = str.charCodeAt(u16pos);\n\t\tconst b = str.charCodeAt(u16pos + 1);\n\t\tconst c = str.charCodeAt(u16pos + 2);\n\t\tconst d = str.charCodeAt(u16pos + 3);\n\n\t\tif ((a | b | c | d) \u003e= 0x80) {\n\t\t\tbreak;\n\t\t}\n\n\t\tu16pos += 4;\n\t\tu8pos += 4;\n\t}\n\n\t// handle remaining chars\n\twhile (u16pos \u003c len) {\n\t\tconst code = str.charCodeAt(u16pos);\n\n\t\tif (code \u003c 0x80) {\n\t\t\tu16pos += 1;\n\t\t\tu8pos += 1;\n\t\t} else if (code \u003c 0x800) {\n\t\t\tu16pos += 1;\n\t\t\tu8pos += 2;\n\t\t} else if (code \u003c 0xd800 || code \u003e 0xdbff) {\n\t\t\tu16pos += 1;\n\t\t\tu8pos += 3;\n\t\t} else {\n\t\t\tu16pos += 2;\n\t\t\tu8pos += 4;\n\t\t}\n\t}\n\n\treturn u8pos;\n};\n\n/**\n * checks if a string's UTF-8 byte length is within a given range.\n * includes early-exit optimization when exceeding max length.\n * @param str string to measure\n * @param min minimum byte length (inclusive)\n * @param max maximum byte length (inclusive)\n * @returns true if byte length is within [min, max]\n */\nexport const isUtf8LengthInRange = (str: string, min: number, max: number): boolean =\u003e {\n\tconst len = str.length;\n\n\t// fast path: if max possible UTF-8 length is below min, fail\n\tif (len * 3 \u003c min) {\n\t\treturn false;\n\t}\n\n\t// fast path: if UTF-16 length satisfies min and max possible satisfies max\n\tif (len \u003e= min \u0026\u0026 len * 3 \u003c= max) {\n\t\treturn true;\n\t}\n\n\tlet u16pos = 0;\n\tlet u8pos = 0;\n\n\twhile (u16pos \u003c len) {\n\t\tconst code = str.charCodeAt(u16pos);\n\n\t\tif (code \u003c 0x80) {\n\t\t\tu16pos += 1;\n\t\t\tu8pos += 1;\n\t\t} else if (code \u003c 0x800) {\n\t\t\tu16pos += 1;\n\t\t\tu8pos += 2;\n\t\t} else if (code \u003c 0xd800 || code \u003e 0xdbff) {\n\t\t\tu16pos += 1;\n\t\t\tu8pos += 3;\n\t\t} else {\n\t\t\tu16pos += 2;\n\t\t\tu8pos += 4;\n\t\t}\n\n\t\t// early exit once we exceed max\n\t\tif (u8pos \u003e max) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn u8pos \u003e= min;\n};\n\n/**\n * get a SHA-256 digest of this buffer\n */\nexport const toSha256 = async (buffer: Uint8Array\u003cArrayBuffer\u003e): Promise\u003cUint8Array\u003cArrayBuffer\u003e\u003e =\u003e {\n\treturn new Uint8Array(await subtle.digest('SHA-256', buffer));\n};\n\n/**\n * generates cryptographically secure random bytes\n * @param size number of bytes to generate\n * @returns buffer filled with random bytes\n */\nexport const randomBytes = (size: number): Uint8Array\u003cArrayBuffer\u003e =\u003e {\n\treturn crypto.getRandomValues(new Uint8Array(size));\n};\n"],"version":3}
+3
vendor/esm.sh/@atcute/util-fetch@1.0.5/es2022/util-fetch.mjs
··· 1 + /* esm.sh - @atcute/util-fetch@1.0.5 */ 2 + import*as t from"../../../@badrap/valita@0.4.6/es2022/valita.mjs";function y(...e){return e.reduce(w)}var w=(e,r)=>n=>e(n).then(r);import"../../../@badrap/valita@0.4.6/es2022/valita.mjs";var p=class extends Error{name="FetchResponseError"},u=class extends p{response;name="FailedResponseError";constructor(r){super(`got http ${r.status}`),this.response=r}get status(){return this.response.status}},i=class extends p{contentType;name="ImproperContentTypeError";constructor(r,n){super(n),this.contentType=r}},a=class extends p{expectedSize;actualSize;name="ImproperContentLengthError";constructor(r,n,o){super(o),this.expectedSize=r,this.actualSize=n}},l=class extends p{name="ImproperResponseError";constructor(r,n){super(r,n)}};var m=class extends TransformStream{constructor(r){let n=0;super({transform(o,s){if(n+=o.length,n>r){s.error(new a(r,n,"response content-length too large"));return}s.enqueue(o)}})}};var v=async e=>{if(e.ok)return e;throw new u(e)},D=e=>async r=>{let n=await g(r,e);return{response:r,text:n}},x=(e,r)=>async n=>{await b(n,e);let o=await g(n,r);try{let s=JSON.parse(o);return{response:n,json:s}}catch(s){throw new l("unexpected json data",{cause:s})}},f=(e,r)=>async n=>{let o=e.parse(n.json,r);return{response:n.response,json:o}},b=async(e,r)=>{let n=e.headers.get("content-type")?.split(";",1)[0].trim();if(n===void 0)throw e.body&&await e.body.cancel(),new i(null,"missing response content-type");if(!r.test(n))throw e.body&&await e.body.cancel(),new i(n,"unexpected response content-type")},g=async(e,r)=>{let n=e.headers.get("content-length");if(n!==null){let c=Number(n);if(!Number.isSafeInteger(c)||c<=0)throw e.body?.cancel(),new a(r,null,"invalid response content-length");if(c>r)throw e.body?.cancel(),new a(r,c,"response content-length too large")}let o=e.body.pipeThrough(new m(r)).pipeThrough(new TextDecoderStream),s="";for await(let c of T(o))s+=c;return s},T=Symbol.asyncIterator in ReadableStream.prototype?e=>e[Symbol.asyncIterator]():e=>{let r=e.getReader();return{[Symbol.asyncIterator](){return this},next(){return r.read()},async return(){return await r.cancel(),{done:!0,value:void 0}},async throw(n){return await r.cancel(n),{done:!0,value:void 0}}}};var d=t.number().assert(e=>Number.isInteger(e)&&e>=0&&e<=2**32-1),R=t.object({name:t.string(),type:t.literal(16)}),I=t.object({name:t.string(),type:t.literal(16),TTL:d,data:t.string().chain(e=>t.ok(e.replace(/^"|"$/g,"").replace(/\\"/g,'"')))}),S=t.object({name:t.string(),type:d,TTL:d,data:t.string()}),j=t.object({Status:d,TC:t.boolean(),RD:t.boolean(),RA:t.boolean(),AD:t.boolean(),CD:t.boolean(),Question:t.tuple([R]),Answer:t.array(I).optional(()=>[]),Authority:t.array(S).optional(),Comment:t.union(t.string(),t.array(t.string())).optional()}),O=y(v,x(/^application\/(dns-)?json$/,16*1024),f(j,{mode:"passthrough"}));export{u as FailedResponseError,p as FetchResponseError,a as ImproperContentLengthError,i as ImproperContentTypeError,l as ImproperResponseError,j as dohJsonTxtResult,O as fetchDohJsonTxt,v as isResponseOk,x as parseResponseAsJson,y as pipe,D as readResponseAsText,f as validateJsonWith}; 3 + //# sourceMappingURL=./util-fetch.mjs.map
+1
vendor/esm.sh/@atcute/util-fetch@1.0.5/es2022/util-fetch.mjs.map
··· 1 + {"mappings":";AAAA,UAAYA,MAAO,uCC6Bb,SAAUC,KACZC,EACuD,CAC1D,OAAOA,EAAS,OAAOC,CAAO,CAAE,CAGjC,IAAMA,EAAU,CACfC,EACAC,IAEQC,GAAUF,EAAME,CAAK,EAAE,KAAKD,CAAM,ECvC3C,MAAmB,uCCAb,IAAOE,EAAP,cAAkC,KAAK,CACnC,KAAO,sBAGJC,EAAP,cAAmCD,CAAkB,CAGvC,SAFV,KAAO,sBAEhB,YAAmBE,EAAoB,CACtC,MAAM,YAAYA,EAAS,MAAM,EAAE,gBADjBA,CACmB,CAGtC,IAAI,QAAiB,CACpB,OAAO,KAAK,SAAS,MAAO,GAIjBC,EAAP,cAAwCH,CAAkB,CAIvD,YAHC,KAAO,2BAEhB,YACQI,EACPC,EACC,CACD,MAAMA,CAAM,mBAHLD,CAGO,GAIHE,EAAP,cAA0CN,CAAkB,CAIzD,aACA,WAJC,KAAO,6BAEhB,YACQO,EACAC,EACPH,EACC,CACD,MAAMA,CAAM,oBAJLE,kBACAC,CAGO,GAIHC,EAAP,cAAqCT,CAAkB,CACnD,KAAO,wBAEhB,YAAYK,EAAgBK,EAAwB,CACnD,MAAML,EA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AS,GAAK,GAAK,CAAC,EAEnGC,EAAa,SAAO,CACzB,KAAQ,SAAM,EACd,KAAQ,UAAQ,EAAE,EAClB,EAEKC,EAAW,SAAO,CACvB,KAAQ,SAAM,EACd,KAAQ,UAAQ,EAAE,EAClB,IAAKH,EACL,KAAQ,SAAM,EAAG,MAAOC,GACd,KAAGA,EAAM,QAAQ,SAAU,EAAE,EAAE,QAAQ,OAAQ,GAAG,CAAC,CAC5D,EACD,EAEKG,EAAc,SAAO,CAC1B,KAAQ,SAAM,EACd,KAAMJ,EACN,IAAKA,EACL,KAAQ,SAAM,EACd,EAGYK,EAAqB,SAAO,CAExC,OAAQL,EAER,GAAM,UAAO,EAEb,GAAM,UAAO,EAEb,GAAM,UAAO,EAEb,GAAM,UAAO,EAEb,GAAM,UAAO,EAEb,SAAY,QAAM,CAACE,CAAQ,CAAC,EAE5B,OAAU,QAAMC,CAAM,EAAE,SAAS,IAAM,CAAA,CAAE,EAEzC,UAAa,QAAMC,CAAS,EAAE,SAAQ,EAEtC,QAAW,QAAQ,SAAM,EAAM,QAAQ,SAAM,CAAE,CAAC,EAAE,SAAQ,EAC1D,EAKYE,EAAkBC,EAC9BC,EACAC,EAAoB,6BAA8B,GAAK,IAAI,EAC3DC,EAAiBL,EAAkB,CAAE,KAAM,aAAa,CAAE,CAAC","names":["v","pipe","pipeline","pipeTwo","first","second","input","FetchResponseError","FailedResponseError","response","ImproperContentTypeError","contentType","reason","ImproperContentLengthError","expectedSize","actualSize","ImproperResponseError","options","SizeLimitStream","maxSize","bytesRead","chunk","controller","ImproperContentLengthError","isResponseOk","response","FailedResponseError","readResponseAsText","maxSize","text","readResponse","parseResponseAsJson","typeRegex","assertContentType","json","error","ImproperResponseError","validateJsonWith","schema","options","parsed","type","ImproperContentTypeError","rawSize","size","ImproperContentLengthError","stream","SizeLimitStream","chunk","createStreamIterator","reader","uint32","input","question","answer","authority","dohJsonTxtResult","fetchDohJsonTxt","pipe","isResponseOk","parseResponseAsJson","validateJsonWith"],"sources":["../esm/npm/@atcute/util-fetch@1.0.5/node_modules/@atcute/util-fetch/lib/doh-json.ts","../esm/npm/@atcute/util-fetch@1.0.5/node_modules/@atcute/util-fetch/lib/pipeline.ts","../esm/npm/@atcute/util-fetch@1.0.5/node_modules/@atcute/util-fetch/lib/transformers.ts","../esm/npm/@atcute/util-fetch@1.0.5/node_modules/@atcute/util-fetch/lib/errors.ts","../esm/npm/@atcute/util-fetch@1.0.5/node_modules/@atcute/util-fetch/lib/streams/size-limit.ts"],"sourcesContent":["import * as v from '@badrap/valita';\n\nimport { pipe } from './pipeline.js';\nimport { isResponseOk, parseResponseAsJson, validateJsonWith } from './transformers.js';\n\nconst uint32 = v.number().assert((input) =\u003e Number.isInteger(input) \u0026\u0026 input \u003e= 0 \u0026\u0026 input \u003c= 2 ** 32 - 1);\n\nconst question = v.object({\n\tname: v.string(),\n\ttype: v.literal(16), // TXT\n});\n\nconst answer = v.object({\n\tname: v.string(),\n\ttype: v.literal(16), // TXT\n\tTTL: uint32,\n\tdata: v.string().chain((input) =\u003e {\n\t\treturn v.ok(input.replace(/^\"|\"$/g, '').replace(/\\\\\"/g, '\"'));\n\t}),\n});\n\nconst authority = v.object({\n\tname: v.string(),\n\ttype: uint32,\n\tTTL: uint32,\n\tdata: v.string(),\n});\n\n/** DoH JSON response schema for TXT record queries */\nexport const dohJsonTxtResult = v.object({\n\t/** DNS response code */\n\tStatus: uint32,\n\t/** whether response is truncated */\n\tTC: v.boolean(),\n\t/** whether recursive desired bit is set, always true for Google and Cloudflare DoH */\n\tRD: v.boolean(),\n\t/** whether recursive available bit is set, always true for Google and Cloudflare DoH */\n\tRA: v.boolean(),\n\t/** whether response data was validated with DNSSEC */\n\tAD: v.boolean(),\n\t/** whether client asked to disable DNSSEC validation */\n\tCD: v.boolean(),\n\t/** requested records */\n\tQuestion: v.tuple([question]),\n\t/** answers */\n\tAnswer: v.array(answer).optional(() =\u003e []),\n\t/** authority */\n\tAuthority: v.array(authority).optional(),\n\t/** comment from the DNS server */\n\tComment: v.union(v.string(), v.array(v.string())).optional(),\n});\n\nexport type DohJsonTxtResult = v.Infer\u003ctypeof dohJsonTxtResult\u003e;\n\n/** fetch handler pipeline for DoH JSON TXT record responses */\nexport const fetchDohJsonTxt = pipe(\n\tisResponseOk,\n\tparseResponseAsJson(/^application\\/(dns-)?json$/, 16 * 1024),\n\tvalidateJsonWith(dohJsonTxtResult, { mode: 'passthrough' }),\n);\n","type Transformer\u003cI, O = I\u003e = (input: I) =\u003e Promise\u003cO\u003e;\n\ntype PipelineInput\u003cT extends readonly Transformer\u003cany\u003e[]\u003e = T extends [Transformer\u003cinfer I, any\u003e, ...any[]]\n\t? I\n\t: T extends Transformer\u003cinfer I, any\u003e[]\n\t\t? I\n\t\t: never;\n\ntype PipelineOutput\u003cT extends readonly Transformer\u003cany\u003e[]\u003e = T extends [...any[], Transformer\u003cany, infer O\u003e]\n\t? O\n\t: T extends Transformer\u003cany, infer O\u003e[]\n\t\t? O\n\t\t: never;\n\ntype Pipeline\u003c\n\tF extends readonly Transformer\u003cany\u003e[],\n\tAcc extends readonly Transformer\u003cany\u003e[] = [],\n\u003e = F extends [Transformer\u003cinfer I, infer O\u003e]\n\t? [...Acc, Transformer\u003cI, O\u003e]\n\t: F extends [Transformer\u003cinfer A, any\u003e, ...infer Tail]\n\t\t? Tail extends [Transformer\u003cinfer B, any\u003e, ...any[]]\n\t\t\t? Pipeline\u003cTail, [...Acc, Transformer\u003cA, B\u003e]\u003e\n\t\t\t: Acc\n\t\t: Acc;\n\nexport function pipe(): never;\nexport function pipe\u003cT extends readonly Transformer\u003cany\u003e[]\u003e(\n\t...pipeline: Pipeline\u003cT\u003e extends T ? T : Pipeline\u003cT\u003e\n): (input: PipelineInput\u003cT\u003e) =\u003e Promise\u003cPipelineOutput\u003cT\u003e\u003e;\nexport function pipe\u003cT extends readonly Transformer\u003cany\u003e[]\u003e(\n\t...pipeline: Pipeline\u003cT\u003e extends T ? T : Pipeline\u003cT\u003e\n): (input: PipelineInput\u003cT\u003e) =\u003e Promise\u003cPipelineOutput\u003cT\u003e\u003e {\n\treturn pipeline.reduce(pipeTwo);\n}\n\nconst pipeTwo = \u003cI, O, X = unknown\u003e(\n\tfirst: Transformer\u003cI, X\u003e,\n\tsecond: Transformer\u003cX, O\u003e,\n): ((input: I) =\u003e Promise\u003cO\u003e) =\u003e {\n\treturn (input) =\u003e first(input).then(second);\n};\n","import * as v from '@badrap/valita';\n\nimport * as err from './errors.js';\nimport { SizeLimitStream } from './streams/size-limit.js';\n\nexport type TextResponse = {\n\tresponse: Response;\n\ttext: string;\n};\n\nexport type ParsedJsonResponse\u003cT = unknown\u003e = {\n\tresponse: Response;\n\tjson: T;\n};\n\nexport const isResponseOk = async (response: Response): Promise\u003cResponse\u003e =\u003e {\n\tif (response.ok) {\n\t\treturn response;\n\t}\n\n\tthrow new err.FailedResponseError(response);\n};\n\nexport const readResponseAsText =\n\t(maxSize: number) =\u003e\n\tasync (response: Response): Promise\u003cTextResponse\u003e =\u003e {\n\t\tconst text = await readResponse(response, maxSize);\n\t\treturn { response, text };\n\t};\n\nexport const parseResponseAsJson =\n\t(typeRegex: RegExp, maxSize: number) =\u003e\n\tasync (response: Response): Promise\u003cParsedJsonResponse\u003e =\u003e {\n\t\tawait assertContentType(response, typeRegex);\n\n\t\tconst text = await readResponse(response, maxSize);\n\n\t\ttry {\n\t\t\tconst json = JSON.parse(text);\n\t\t\treturn { response, json };\n\t\t} catch (error) {\n\t\t\tthrow new err.ImproperResponseError(`unexpected json data`, { cause: error });\n\t\t}\n\t};\n\ntype ParseOptions = NonNullable\u003cParameters\u003cv.Type['parse']\u003e[1]\u003e;\n\nexport const validateJsonWith =\n\t\u003cT\u003e(schema: v.Type\u003cT\u003e, options?: ParseOptions) =\u003e\n\tasync (parsed: ParsedJsonResponse): Promise\u003cParsedJsonResponse\u003cT\u003e\u003e =\u003e {\n\t\tconst json = schema.parse(parsed.json, options);\n\t\treturn { response: parsed.response, json };\n\t};\n\nconst assertContentType = async (response: Response, typeRegex: RegExp): Promise\u003cvoid\u003e =\u003e {\n\tconst type = response.headers.get('content-type')?.split(';', 1)[0].trim();\n\n\tif (type === undefined) {\n\t\tif (response.body) {\n\t\t\tawait response.body.cancel();\n\t\t}\n\n\t\tthrow new err.ImproperContentTypeError(null, `missing response content-type`);\n\t}\n\n\tif (!typeRegex.test(type)) {\n\t\tif (response.body) {\n\t\t\tawait response.body.cancel();\n\t\t}\n\n\t\tthrow new err.ImproperContentTypeError(type, `unexpected response content-type`);\n\t}\n};\n\nconst readResponse = async (response: Response, maxSize: number): Promise\u003cstring\u003e =\u003e {\n\tconst rawSize = response.headers.get('content-length');\n\tif (rawSize !== null) {\n\t\tconst size = Number(rawSize);\n\n\t\tif (!Number.isSafeInteger(size) || size \u003c= 0) {\n\t\t\tresponse.body?.cancel();\n\t\t\tthrow new err.ImproperContentLengthError(maxSize, null, `invalid response content-length`);\n\t\t}\n\n\t\tif (size \u003e maxSize) {\n\t\t\tresponse.body?.cancel();\n\t\t\tthrow new err.ImproperContentLengthError(maxSize, size, `response content-length too large`);\n\t\t}\n\t}\n\n\tconst stream = response\n\t\t.body!.pipeThrough(new SizeLimitStream(maxSize))\n\t\t.pipeThrough(new TextDecoderStream());\n\n\tlet text = '';\n\tfor await (const chunk of createStreamIterator(stream)) {\n\t\ttext += chunk;\n\t}\n\n\treturn text;\n};\n\nconst createStreamIterator: \u003cT\u003e(stream: ReadableStream\u003cT\u003e) =\u003e AsyncIterableIterator\u003cT\u003e =\n\tSymbol.asyncIterator in ReadableStream.prototype\n\t\t? (stream) =\u003e stream[Symbol.asyncIterator]()\n\t\t: (stream) =\u003e {\n\t\t\t\tconst reader = stream.getReader();\n\n\t\t\t\treturn {\n\t\t\t\t\t[Symbol.asyncIterator]() {\n\t\t\t\t\t\treturn this;\n\t\t\t\t\t},\n\t\t\t\t\tnext() {\n\t\t\t\t\t\treturn reader.read() as Promise\u003cIteratorResult\u003cany\u003e\u003e;\n\t\t\t\t\t},\n\t\t\t\t\tasync return() {\n\t\t\t\t\t\tawait reader.cancel();\n\t\t\t\t\t\treturn { done: true, value: undefined };\n\t\t\t\t\t},\n\t\t\t\t\tasync throw(error: unknown) {\n\t\t\t\t\t\tawait reader.cancel(error);\n\t\t\t\t\t\treturn { done: true, value: undefined };\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t};\n","export class FetchResponseError extends Error {\n\toverride name = 'FetchResponseError';\n}\n\nexport class FailedResponseError extends FetchResponseError {\n\toverride name = 'FailedResponseError';\n\n\tconstructor(public response: Response) {\n\t\tsuper(`got http ${response.status}`);\n\t}\n\n\tget status(): number {\n\t\treturn this.response.status;\n\t}\n}\n\nexport class ImproperContentTypeError extends FetchResponseError {\n\toverride name = 'ImproperContentTypeError';\n\n\tconstructor(\n\t\tpublic contentType: string | null,\n\t\treason: string,\n\t) {\n\t\tsuper(reason);\n\t}\n}\n\nexport class ImproperContentLengthError extends FetchResponseError {\n\toverride name = 'ImproperContentLengthError';\n\n\tconstructor(\n\t\tpublic expectedSize: number,\n\t\tpublic actualSize: number | null,\n\t\treason: string,\n\t) {\n\t\tsuper(reason);\n\t}\n}\n\nexport class ImproperResponseError extends FetchResponseError {\n\toverride name = 'ImproperResponseError';\n\n\tconstructor(reason: string, options?: ErrorOptions) {\n\t\tsuper(reason, options);\n\t}\n}\n","import * as err from '../errors.js';\n\nexport class SizeLimitStream extends TransformStream\u003cUint8Array\u003cArrayBuffer\u003e, Uint8Array\u003cArrayBuffer\u003e\u003e {\n\tconstructor(maxSize: number) {\n\t\tlet bytesRead = 0;\n\n\t\tsuper({\n\t\t\ttransform(chunk, controller) {\n\t\t\t\tbytesRead += chunk.length;\n\n\t\t\t\tif (bytesRead \u003e maxSize) {\n\t\t\t\t\tcontroller.error(\n\t\t\t\t\t\tnew err.ImproperContentLengthError(maxSize, bytesRead, `response content-length too large`),\n\t\t\t\t\t);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t},\n\t\t});\n\t}\n}\n"],"version":3}
+3
vendor/esm.sh/@atcute/util-text@1.2.0/es2022/util-text.mjs
··· 1 + /* esm.sh - @atcute/util-text@1.2.0 */ 2 + var c=t=>{let n=t.length,e=0;for(;e+3<n;){let r=t.charCodeAt(e),s=t.charCodeAt(e+1),o=t.charCodeAt(e+2),i=t.charCodeAt(e+3);if((r|s|o|i)>127||r===13||s===13||o===13||i===13)return!1;e+=4}for(;e<n;){let r=t.charCodeAt(e);if(r>127||r===13)return!1;e++}return!0};var h=new Intl.Segmenter,a=t=>{if(c(t))return t.length;let n=h.segment(t)[Symbol.iterator](),e=0;for(;!n.next().done;)e++;return e},d=(t,n,e)=>{let r=t.length;if(r<n)return!1;if(n===0&&r<=e)return!0;if(c(t))return r<=e;let s=h.segment(t)[Symbol.iterator](),o=0;for(;!s.next().done;)if(o++,o>e)return!1;return o>=n};export{a as getGraphemeLength,d as isGraphemeLengthInRange}; 3 + //# sourceMappingURL=./util-text.mjs.map
+1
vendor/esm.sh/@atcute/util-text@1.2.0/es2022/util-text.mjs.map
··· 1 + {"mappings":";AAAO,IAAMA,EAAoBC,GAAyB,CACzD,IAAMC,EAAMD,EAAK,OACbE,EAAM,EAEV,KAAOA,EAAM,EAAID,GAAK,CACrB,IAAME,EAAIH,EAAK,WAAWE,CAAG,EACvBE,EAAIJ,EAAK,WAAWE,EAAM,CAAC,EAC3BG,EAAIL,EAAK,WAAWE,EAAM,CAAC,EAC3BI,EAAIN,EAAK,WAAWE,EAAM,CAAC,EAEjC,IAAKC,EAAIC,EAAIC,EAAIC,GAAK,KAAQH,IAAM,IAAQC,IAAM,IAAQC,IAAM,IAAQC,IAAM,GAC7E,MAAO,GAGRJ,GAAO,CACR,CAEA,KAAOA,EAAMD,GAAK,CACjB,IAAMM,EAAOP,EAAK,WAAWE,CAAG,EAChC,GAAIK,EAAO,KAAQA,IAAS,GAC3B,MAAO,GAGRL,GACD,CAEA,MAAO,EACR,ECzBA,IAAMM,EAAY,IAAI,KAAK,UAOdC,EAAqBC,GAAwB,CACzD,GAAIC,EAAiBD,CAAI,EACxB,OAAOA,EAAK,OAGb,IAAME,EAAWJ,EAAU,QAAQE,CAAI,EAAE,OAAO,QAAQ,EAAC,EACrDG,EAAQ,EAEZ,KAAO,CAACD,EAAS,KAAI,EAAG,MACvBC,IAGD,OAAOA,CACR,EASaC,EAA0B,CAACJ,EAAcK,EAAaC,IAAwB,CAC1F,IAAMC,EAAWP,EAAK,OAGtB,GAAIO,EAAWF,EACd,MAAO,GAKR,GAAIA,IAAQ,GAAKE,GAAYD,EAC5B,MAAO,GAGR,GAAIL,EAAiBD,CAAI,EACxB,OAAOO,GAAYD,EAIpB,IAAMJ,EAAWJ,EAAU,QAAQE,CAAI,EAAE,OAAO,QAAQ,EAAC,EACrDG,EAAQ,EAEZ,KAAO,CAACD,EAAS,KAAI,EAAG,MAEvB,GADAC,IACIA,EAAQG,EACX,MAAO,GAIT,OAAOH,GAASE,CACjB","names":["isAsciiWithoutCr","text","len","idx","a","b","c","d","code","segmenter","getGraphemeLength","text","isAsciiWithoutCr","iterator","count","isGraphemeLengthInRange","min","max","utf16Len"],"sources":["../esm/npm/@atcute/util-text@1.2.0/node_modules/@atcute/util-text/lib/utils.ts","../esm/npm/@atcute/util-text@1.2.0/node_modules/@atcute/util-text/lib/index.ts"],"sourcesContent":["export const isAsciiWithoutCr = (text: string): boolean =\u003e {\n\tconst len = text.length;\n\tlet idx = 0;\n\n\twhile (idx + 3 \u003c len) {\n\t\tconst a = text.charCodeAt(idx);\n\t\tconst b = text.charCodeAt(idx + 1);\n\t\tconst c = text.charCodeAt(idx + 2);\n\t\tconst d = text.charCodeAt(idx + 3);\n\n\t\tif ((a | b | c | d) \u003e 0x7f || a === 0x0d || b === 0x0d || c === 0x0d || d === 0x0d) {\n\t\t\treturn false;\n\t\t}\n\n\t\tidx += 4;\n\t}\n\n\twhile (idx \u003c len) {\n\t\tconst code = text.charCodeAt(idx);\n\t\tif (code \u003e 0x7f || code === 0x0d) {\n\t\t\treturn false;\n\t\t}\n\n\t\tidx++;\n\t}\n\n\treturn true;\n};\n","import { isAsciiWithoutCr } from './utils.ts';\n\nconst segmenter = new Intl.Segmenter();\n\n/**\n * returns the grapheme length of a string\n * @param text string to count graphemes in\n * @returns grapheme count\n */\nexport const getGraphemeLength = (text: string): number =\u003e {\n\tif (isAsciiWithoutCr(text)) {\n\t\treturn text.length;\n\t}\n\n\tconst iterator = segmenter.segment(text)[Symbol.iterator]();\n\tlet count = 0;\n\n\twhile (!iterator.next().done) {\n\t\tcount++;\n\t}\n\n\treturn count;\n};\n\n/**\n * checks if the grapheme length of a string is within the specified range\n * @param text string to check\n * @param min minimum grapheme length (inclusive)\n * @param max maximum grapheme length (inclusive)\n * @returns true if the grapheme length is within range\n */\nexport const isGraphemeLengthInRange = (text: string, min: number, max: number): boolean =\u003e {\n\tconst utf16Len = text.length;\n\n\t// UTF-16 length \u003c min means grapheme count \u003c min\n\tif (utf16Len \u003c min) {\n\t\treturn false;\n\t}\n\n\t// if there's no minimum constraint and UTF-16 length is within max,\n\t// grapheme count is definitely within max\n\tif (min === 0 \u0026\u0026 utf16Len \u003c= max) {\n\t\treturn true;\n\t}\n\n\tif (isAsciiWithoutCr(text)) {\n\t\treturn utf16Len \u003c= max;\n\t}\n\n\t// count graphemes with early termination\n\tconst iterator = segmenter.segment(text)[Symbol.iterator]();\n\tlet count = 0;\n\n\twhile (!iterator.next().done) {\n\t\tcount++;\n\t\tif (count \u003e max) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn count \u003e= min;\n};\n"],"version":3}
+3
vendor/esm.sh/@badrap/valita@0.4.6/es2022/valita.mjs
··· 1 + /* esm.sh - @badrap/valita@0.4.6 */ 2 + function A(n){return{ok:!1,code:"invalid_type",expected:n}}var q=A([]),ee=A(["string"]),ne=A(["number"]),te=A(["bigint"]),se=A(["boolean"]),oe=A(["undefined"]),ie=A(["null"]),be=A(["object"]),Oe=A(["array"]),Q={ok:!1,code:"missing_value"};function N(n,e){return n?{ok:!1,code:"join",left:n,right:e}:e}function L(n,e){return{ok:!1,code:"prepend",key:n,tree:e}}function Ne(n,e){var t;let s=n.code;switch(s){case"invalid_type":return{code:s,path:e,expected:n.expected};case"invalid_literal":return{code:s,path:e,expected:n.expected};case"missing_value":return{code:s,path:e};case"invalid_length":return{code:s,path:e,minLength:n.minLength,maxLength:n.maxLength};case"unrecognized_keys":return{code:s,path:e,keys:n.keys};case"invalid_union":return{code:s,path:e,tree:n.tree,issues:D(n.tree)};case"custom_error":return typeof n.error=="object"&&n.error.path!==void 0&&e.push(...n.error.path),{code:s,path:e,message:typeof n.error=="string"?n.error:(t=n.error)===null||t===void 0?void 0:t.message,error:n.error}}}function D(n,e=[],t=[]){for(;;)if(n.code==="join")D(n.left,e.slice(),t),n=n.right;else if(n.code==="prepend")e.push(n.key),n=n.tree;else return t.push(Ne(n,e)),t}function F(n,e){return n.length===0?"nothing":n.length===1?n[0]:`${n.slice(0,-1).join(", ")} ${e} ${n[n.length-1]}`}function Z(n){return typeof n=="bigint"?`${n}n`:JSON.stringify(n)}function re(n){let e=0;for(;;)if(n.code==="join")e+=re(n.left),n=n.right;else if(n.code==="prepend")n=n.tree;else return e+1}function ue(n){let e="",t=0;for(;;)if(n.code==="join")t+=re(n.right),n=n.left;else if(n.code==="prepend")e+=`.${n.key}`,n=n.tree;else break;let s="validation failed";if(n.code==="invalid_type")s=`expected ${F(n.expected,"or")}`;else if(n.code==="invalid_literal")s=`expected ${F(n.expected.map(Z),"or")}`;else if(n.code==="missing_value")s="missing value";else if(n.code==="unrecognized_keys"){let o=n.keys;s=`unrecognized ${o.length===1?"key":"keys"} ${F(o.map(Z),"and")}`}else if(n.code==="invalid_length"){let o=n.minLength,d=n.maxLength;s="expected an array with ",o>0?d===o?s+=`${o}`:d!==void 0?s+=`between ${o} and ${d}`:s+=`at least ${o}`:s+=`at most ${d??"\u221E"}`,s+=" item(s)"}else if(n.code==="custom_error"){let o=n.error;typeof o=="string"?s=o:o!==void 0&&(o.message!==void 0&&(s=o.message),o.path!==void 0&&(e+="."+o.path.join(".")))}let i=`${n.code} at .${e.slice(1)} (${s})`;return t===1?i+=" (+ 1 other issue)":t>1&&(i+=` (+ ${t} other issues)`),i}function w(n,e,t,s){return Object.defineProperty(n,e,{value:t,enumerable:s,writable:!1}),t}var P=class extends Error{constructor(e){super(ue(e)),Object.setPrototypeOf(this,new.target.prototype),this.name=new.target.name,this._issueTree=e}get issues(){return w(this,"issues",D(this._issueTree),!0)}},$=class{constructor(e){this.ok=!1,this._issueTree=e}get issues(){return w(this,"issues",D(this._issueTree),!0)}get message(){return w(this,"message",ue(this._issueTree),!0)}throw(){throw new P(this._issueTree)}};function ce(n){return{ok:!0,value:n}}function Be(n){return new $({ok:!1,code:"custom_error",error:n})}function fe(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var O=1,U=2,X=4,de=0,le=1,ae=2,he=3,pe=4,_e=5,me=6,ge=7,ye=8,ke=9,Te=10,xe=11,ve=12,we=13,Ee=14,Le=15,S=(n,e)=>({tag:n,match:e});function x(n,e,t){switch(n.tag){case de:return;case le:return q;case ae:return typeof e=="string"?void 0:ee;case he:return typeof e=="number"?void 0:ne;case pe:return typeof e=="bigint"?void 0:te;case _e:return typeof e=="boolean"?void 0:se;case me:return e===null?void 0:ie;case ge:return e===void 0?void 0:oe;case ye:return n.match(e,t);case ke:return n.match(e,t);case Te:return n.match(e,t);case xe:return n.match(e,t);case ve:return n.match(e,t);case we:return n.match(e,t);case Ee:return n.match(e,t);default:return n.match(e,t)}}var h=Symbol.for("@valita/internal"),z=class{default(e){let t=ce(e);return new E(this.optional(),s=>s===void 0?t:void 0)}assert(e,t){let s={ok:!1,code:"custom_error",error:t};return new E(this,(i,o)=>e(i,H(o))?void 0:s)}map(e){return new E(this,(t,s)=>({ok:!0,value:e(t,H(s))}))}chain(e){return typeof e=="function"?new E(this,(t,s)=>{let i=e(t,H(s));return i.ok?i:i._issueTree}):new E(this,(t,s)=>x(e[h],t,s))}},I=class extends z{optional(e){let t=new K(this);return e?new E(t,s=>s===void 0?{ok:!0,value:e()}:void 0):t}nullable(e){let t=new Y([je(),this]);return e?new E(t,s=>s===null?{ok:!0,value:e()}:void 0):t}_toTerminals(e){e(this)}try(e,t){let s=x(this[h],e,t===void 0?O:t.mode==="strip"?U:t.mode==="passthrough"?0:O);return s===void 0||s.ok?{ok:!0,value:s===void 0?e:s.value}:new $(s)}parse(e,t){let s=x(this[h],e,t===void 0?O:t.mode==="strip"?U:t.mode==="passthrough"?0:O);if(s===void 0||s.ok)return s===void 0?e:s.value;throw new P(s)}},Y=class extends I{constructor(e){super(),this.name="union",this.options=e}get[h](){let e=this.options.map(t=>t[h]);return w(this,h,S(we,(t,s)=>{let i=q;for(let o of e){let d=x(o,t,s);if(d===void 0||d.ok)return d;i=d}return i}),!1)}_toTerminals(e){for(let t of this.options)t._toTerminals(e)}},K=class extends z{constructor(e){super(),this.name="optional",this.type=e}optional(e){return e?new E(this,t=>t===void 0?{ok:!0,value:e()}:void 0):this}get[h](){let e=this.type[h];return w(this,h,S(ke,(t,s)=>t===void 0||s&X?void 0:x(e,t,s)),!1)}_toTerminals(e){e(this),e(Ce()),this.type._toTerminals(e)}};function Se(n,e){if(typeof n!="number"){let t=e>>5;for(let s=n.length;s<=t;s++)n.push(0);return n[t]|=1<<e%32,n}else return e<32?n|1<<e:Se([n,0],e)}function M(n,e){return typeof n=="number"?e<32?n>>>e&1:0:n[e>>5]>>>e%32&1}var j=class n extends I{constructor(e,t,s){super(),this.name="object",this.shape=e,this._restType=t,this._checks=s}get[h](){let e=Ge(this.shape,this._restType,this._checks);return w(this,h,S(Te,(t,s)=>fe(t)?e(t,s):be),!1)}check(e,t){var s;let i={ok:!1,code:"custom_error",error:t};return new n(this.shape,this._restType,[...(s=this._checks)!==null&&s!==void 0?s:[],{func:e,issue:i}])}rest(e){return new n(this.shape,e)}extend(e){return new n(Object.assign(Object.assign({},this.shape),e),this._restType)}pick(...e){let t={};for(let s of e)v(t,s,this.shape[s]);return new n(t,void 0)}omit(...e){let t=Object.assign({},this.shape);for(let s of e)delete t[s];return new n(t,this._restType)}partial(){var e;let t={};for(let i of Object.keys(this.shape))v(t,i,this.shape[i].optional());let s=(e=this._restType)===null||e===void 0?void 0:e.optional();return new n(t,s)}};function v(n,e,t){e==="__proto__"?Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0}):n[e]=t}function Ge(n,e,t){let s=Object.keys(n).map((u,y)=>{let r=n[u],a=!1;return r._toTerminals(f=>{a||(a=f.name==="optional")}),{key:u,index:y,matcher:r[h],optional:a,missing:L(u,Q)}}),i=Object.create(null);for(let u of s)i[u.key]=u;let o=e?.[h],d=s.length===0&&e?.name==="unknown"&&t===void 0;return(u,y)=>{if(d)return;let r,a,f,l=0,_=0;if(y&(O|U)||o!==void 0)for(let c in u){let p=u[c],m=i[c];if(m===void 0&&o===void 0){if(y&O)f===void 0?(f=[c],a=N(a,{ok:!1,code:"unrecognized_keys",keys:f})):f.push(c);else if(y&U&&a===void 0&&r===void 0){r={};for(let g=0;g<s.length;g++)if(M(l,g)){let k=s[g].key;v(r,k,u[k])}}continue}let T=x(m===void 0?o:m.matcher,p,y);if(T===void 0)r!==void 0&&a===void 0&&v(r,c,p);else if(!T.ok)a=N(a,L(c,T));else if(a===void 0){if(r===void 0)if(r={},o===void 0){for(let g=0;g<s.length;g++)if(M(l,g)){let k=s[g].key;v(r,k,u[k])}}else for(let g in u)v(r,g,u[g]);v(r,c,T.value)}m!==void 0&&(_++,l=Se(l,m.index))}if(_<s.length)for(let c=0;c<s.length;c++){if(M(l,c))continue;let p=s[c],m=u[p.key],T=0;if(m===void 0&&!(p.key in u)){if(!p.optional){a=N(a,p.missing);continue}T=X}let g=x(p.matcher,m,y|T);if(g===void 0)r!==void 0&&a===void 0&&!T&&v(r,p.key,m);else if(!g.ok)a=N(a,L(p.key,g));else if(a===void 0){if(r===void 0)if(r={},o===void 0){for(let k=0;k<s.length;k++)if(k<c||M(l,k)){let G=s[k].key;v(r,G,u[G])}}else{for(let k in u)v(r,k,u[k]);for(let k=0;k<c;k++)if(!M(l,k)){let G=s[k].key;v(r,G,u[G])}}v(r,p.key,g.value)}}if(a!==void 0)return a;if(t!==void 0){for(let{func:c,issue:p}of t)if(!c(r??u))return p}return r&&{ok:!0,value:r}}}var C=class n extends I{constructor(e,t,s){super(),this.name="array",this._prefix=e,this._rest=t,this._suffix=s}get[h](){var e,t;let s=this._prefix.map(r=>r[h]),i=this._suffix.map(r=>r[h]),o=(t=(e=this._rest)===null||e===void 0?void 0:e[h])!==null&&t!==void 0?t:S(1,()=>Q),d=s.length+i.length,u=this._rest?1/0:d,y={ok:!1,code:"invalid_length",minLength:d,maxLength:u===1/0?void 0:u};return w(this,h,S(xe,(r,a)=>{if(!Array.isArray(r))return Oe;let f=r.length;if(f<d||f>u)return y;let l=s.length,_=r.length-i.length,c,p=r;for(let m=0;m<r.length;m++){let T=m<l?s[m]:m>=_?i[m-_]:o,g=x(T,r[m],a);g!==void 0&&(g.ok?(p===r&&(p=r.slice()),p[m]=g.value):c=N(c,L(m,g)))}return c||(r===p?void 0:{ok:!0,value:p})}),!1)}concat(e){if(this._rest){if(e._rest)throw new TypeError("can not concatenate two variadic types");return new n(this._prefix,this._rest,[...this._suffix,...e._prefix,...e._suffix])}else return e._rest?new n([...this._prefix,...this._suffix,...e._prefix],e._rest,e._suffix):new n([...this._prefix,...this._suffix,...e._prefix,...e._suffix],e._rest,e._suffix)}};function B(n){let e=typeof n;return e!=="object"?e:n===null?"null":Array.isArray(n)?"array":e}function R(n){return[...new Set(n)]}function Ie(n){var e,t,s;let i=new Map,o=new Map,d=new Map,u=[],y=[],r=[];for(let{root:f,terminal:l}of n)if(i.set(f,(e=i.get(f))!==null&&e!==void 0?e:i.size),l.name!=="never")if(l.name==="optional")y.push(f);else if(l.name==="unknown")u.push(f);else if(l.name==="literal"){let _=(t=o.get(l.value))!==null&&t!==void 0?t:[];_.push(f),o.set(l.value,_),r.push(B(l.value))}else{let _=(s=d.get(l.name))!==null&&s!==void 0?s:[];_.push(f),d.set(l.name,_),r.push(l.name)}let a=(f,l)=>{var _,c;return((_=i.get(f))!==null&&_!==void 0?_:0)-((c=i.get(l))!==null&&c!==void 0?c:0)};for(let[f,l]of o){let _=d.get(B(f));_?(_.push(...l),o.delete(f)):o.set(f,R(l.concat(u)).sort(a))}for(let[f,l]of d)d.set(f,R(l.concat(u)).sort(a));return{types:d,literals:o,unknowns:R(u).sort(a),optionals:R(y).sort(a),expectedTypes:R(r)}}function Me(n,e){var t;let s=[];for(let{root:c,terminal:p}of n)p.shape[e]._toTerminals(m=>s.push({root:c,terminal:m}));let{types:i,literals:o,optionals:d,unknowns:u,expectedTypes:y}=Ie(s);if(u.length>0||d.length>1)return;for(let c of o.values())if(c.length>1)return;for(let c of i.values())if(c.length>1)return;let r=L(e,Q),a=L(e,i.size===0?{ok:!1,code:"invalid_literal",expected:[...o.keys()]}:{ok:!1,code:"invalid_type",expected:y}),f=o.size>0?new Map:void 0;if(f)for(let[c,p]of o)f.set(c,p[0][h]);let l=i.size>0?{}:void 0;if(l)for(let[c,p]of i)l[c]=p[0][h];let _=(t=d[0])===null||t===void 0?void 0:t[h];return(c,p)=>{var m;let T=c[e];if(T===void 0&&!(e in c))return _===void 0?r:x(_,c,p);let g=(m=l?.[B(T)])!==null&&m!==void 0?m:f?.get(T);return g?x(g,c,p):a}}function Re(n){var e;let t=[],s=new Map;for(let{root:i,terminal:o}of n){if(o.name==="unknown")return;if(o.name==="object"){for(let d in o.shape)s.set(d,((e=s.get(d))!==null&&e!==void 0?e:0)+1);t.push({root:i,terminal:o})}}if(!(t.length<2)){for(let[i,o]of s)if(o===t.length){let d=Me(t,i);if(d)return d}}}function Ue(n){let{expectedTypes:e,literals:t,types:s,unknowns:i,optionals:o}=Ie(n),d=s.size===0&&i.length===0?{ok:!1,code:"invalid_literal",expected:[...t.keys()]}:{ok:!1,code:"invalid_type",expected:e},u=t.size>0?new Map:void 0;if(u)for(let[f,l]of t)u.set(f,l.map(_=>_[h]));let y=s.size>0?{}:void 0;if(y)for(let[f,l]of s)y[f]=l.map(_=>_[h]);let r=o.map(f=>f[h]),a=i.map(f=>f[h]);return(f,l)=>{var _,c;let p=l&X?r:(c=(_=y?.[B(f)])!==null&&_!==void 0?_:u?.get(f))!==null&&c!==void 0?c:a,m=0,T=d;for(let g=0;g<p.length;g++){let k=x(p[g],f,l);if(k===void 0||k.ok)return k;T=m>0?N(T,k):k,m++}return m>1?{ok:!1,code:"invalid_union",tree:T}:T}}var J=class extends I{constructor(e){super(),this.name="union",this.options=e}_toTerminals(e){for(let t of this.options)t._toTerminals(e)}get[h](){let e=[];for(let i of this.options)i._toTerminals(o=>{e.push({root:i,terminal:o})});let t=Ue(e),s=Re(e);return w(this,h,S(ve,(i,o)=>s!==void 0&&fe(i)?s(i,o):t(i,o)),!1)}},Pe=Object.freeze({mode:"strict"}),$e=Object.freeze({mode:"strip"}),ze=Object.freeze({mode:"passthrough"});function H(n){return n&O?Pe:n&U?$e:ze}var E=class n extends I{constructor(e,t){super(),this.name="transform",this._transformed=e,this._transform=t}get[h](){let e=[],t=this;for(;t instanceof n;)e.push(t._transform),t=t._transformed;e.reverse();let s=t[h],i=ce(void 0);return w(this,h,S(Ee,(o,d)=>{let u=x(s,o,d);if(u!==void 0&&!u.ok)return u;let y;u!==void 0?y=u.value:d&X?(y=void 0,u=i):y=o;for(let r=0;r<e.length;r++){let a=e[r](y,d);if(a!==void 0){if(!a.ok)return a;y=a.value,u=a}}return u}),!1)}_toTerminals(e){this._transformed._toTerminals(e)}},V=class extends I{constructor(e){super(),this.name="lazy",this._recursing=!1,this._definer=e}get type(){return w(this,"type",this._definer(),!0)}get[h](){let e=S(Le,(t,s)=>{let i=this.type[h];return e.tag=i.tag,e.match=i.match,w(this,h,i,!1),x(i,t,s)});return e}_toTerminals(e){if(!this._recursing){this._recursing=!0;try{this.type._toTerminals(e)}finally{this._recursing=!1}}}};function b(n,e,t){let s=S(e,t);class i extends I{constructor(){super(),this.name=n,this[h]=s}}let o=new i;return()=>o}var Ae=b("unknown",de,()=>{}),De=b("never",le,()=>q),Xe=b("string",ae,n=>typeof n=="string"?void 0:ee),Fe=b("number",he,n=>typeof n=="number"?void 0:ne),He=b("bigint",pe,n=>typeof n=="bigint"?void 0:te),Ye=b("boolean",_e,n=>typeof n=="boolean"?void 0:se),je=b("null",me,n=>n===null?void 0:ie);var Ce=b("undefined",ge,n=>n===void 0?void 0:oe);var W=class extends I{constructor(e){super(),this.name="literal";let t={ok:!1,code:"invalid_literal",expected:[e]};this[h]=S(ye,s=>s===e?void 0:t),this.value=e}},Ke=n=>new W(n),Je=n=>new j(n,void 0),Ve=n=>new j({},n??Ae()),We=n=>new C([],n??Ae(),[]),qe=n=>new C(n,void 0,[]),Qe=(...n)=>new J(n),Ze=n=>new V(n);export{P as ValitaError,We as array,He as bigint,Ye as boolean,Be as err,Ze as lazy,Ke as literal,De as never,je as null,Fe as number,Je as object,ce as ok,Ve as record,Xe as string,qe as tuple,Ce as undefined,Qe as union,Ae as unknown}; 3 + //# sourceMappingURL=valita.mjs.map
+3
vendor/esm.sh/@preact/signals-core@1.14.1/es2022/signals-core.mjs
··· 1 + /* esm.sh - @preact/signals-core@1.14.1 */ 2 + var C=Symbol.for("preact-signals");function p(){if(h>1)h--;else{var t,i=!1;for((function(){var f=d;for(d=void 0;f!==void 0;)f.S.v===f.v&&(f.S.i=f.i),f=f.o})();a!==void 0;){var o=a;for(a=void 0,c++;o!==void 0;){var r=o.u;if(o.u=void 0,o.f&=-3,!(8&o.f)&&b(o))try{o.c()}catch(f){i||(t=f,i=!0)}o=r}}if(c=0,h--,i)throw t}}function N(t){if(h>0)return t();y=++j,h++;try{return t()}finally{p()}}var n=void 0;function S(t){var i=n;n=void 0;try{return t()}finally{n=i}}var e,a=void 0,h=0,c=0,j=0,y=0,d=void 0,l=0;function m(t){if(n!==void 0){var i=t.n;if(i===void 0||i.t!==n)return i={i:0,S:t,p:n.s,n:void 0,t:n,e:void 0,x:void 0,r:i},n.s!==void 0&&(n.s.n=i),n.s=i,t.n=i,32&n.f&&t.S(i),i;if(i.i===-1)return i.i=0,i.n!==void 0&&(i.n.p=i.p,i.p!==void 0&&(i.p.n=i.n),i.p=n.s,i.n=void 0,n.s.n=i,n.s=i),i}}function s(t,i){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=i?.watched,this.Z=i?.unwatched,this.name=i?.name}s.prototype.brand=C;s.prototype.h=function(){return!0};s.prototype.S=function(t){var i=this,o=this.t;o!==t&&t.e===void 0&&(t.x=o,this.t=t,o!==void 0?o.e=t:S(function(){var r;(r=i.W)==null||r.call(i)}))};s.prototype.U=function(t){var i=this;if(this.t!==void 0){var o=t.e,r=t.x;o!==void 0&&(o.x=r,t.e=void 0),r!==void 0&&(r.e=o,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&S(function(){var f;(f=i.Z)==null||f.call(i)}))}};s.prototype.subscribe=function(t){var i=this;return W(function(){var o=i.value,r=n;n=void 0;try{t(o)}finally{n=r}},{name:"sub"})};s.prototype.valueOf=function(){return this.value};s.prototype.toString=function(){return this.value+""};s.prototype.toJSON=function(){return this.value};s.prototype.peek=function(){var t=n;n=void 0;try{return this.value}finally{n=t}};Object.defineProperty(s.prototype,"value",{get:function(){var t=m(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(c>100)throw new Error("Cycle detected");(function(o){h!==0&&c===0&&o.l!==y&&(o.l=y,d={S:o,v:o.v,i:o.i,o:d})})(this),this.v=t,this.i++,l++,h++;try{for(var i=this.t;i!==void 0;i=i.x)i.t.N()}finally{p()}}}});function P(t,i){return new s(t,i)}function b(t){for(var i=t.s;i!==void 0;i=i.n)if(i.S.i!==i.i||!i.S.h()||i.S.i!==i.i)return!0;return!1}function x(t){for(var i=t.s;i!==void 0;i=i.n){var o=i.S.n;if(o!==void 0&&(i.r=o),i.S.n=i,i.i=-1,i.n===void 0){t.s=i;break}}}function g(t){for(var i=t.s,o=void 0;i!==void 0;){var r=i.p;i.i===-1?(i.S.U(i),r!==void 0&&(r.n=i.n),i.n!==void 0&&(i.n.p=r)):o=i,i.S.n=i.r,i.r!==void 0&&(i.r=void 0),i=r}t.s=o}function v(t,i){s.call(this,void 0),this.x=t,this.s=void 0,this.g=l-1,this.f=4,this.W=i?.watched,this.Z=i?.unwatched,this.name=i?.name}v.prototype=new s;v.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===l))return!0;if(this.g=l,this.f|=1,this.i>0&&!b(this))return this.f&=-2,!0;var t=n;try{x(this),n=this;var i=this.x();(16&this.f||this.v!==i||this.i===0)&&(this.v=i,this.f&=-17,this.i++)}catch(o){this.v=o,this.f|=16,this.i++}return n=t,g(this),this.f&=-2,!0};v.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var i=this.s;i!==void 0;i=i.n)i.S.S(i)}s.prototype.S.call(this,t)};v.prototype.U=function(t){if(this.t!==void 0&&(s.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var i=this.s;i!==void 0;i=i.n)i.S.U(i)}};v.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(v.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=m(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function J(t,i){return new v(t,i)}function E(t){var i=t.m;if(t.m=void 0,typeof i=="function"){h++;var o=n;n=void 0;try{i()}catch(r){throw t.f&=-2,t.f|=8,w(t),r}finally{n=o,p()}}}function w(t){for(var i=t.s;i!==void 0;i=i.n)i.S.U(i);t.x=void 0,t.s=void 0,E(t)}function k(t){if(n!==this)throw new Error("Out-of-order effect");g(this),n=t,this.f&=-2,8&this.f&&w(this),p()}function u(t,i){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=i?.name,e&&e.push(this)}u.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var i=this.x();typeof i=="function"&&(this.m=i)}finally{t()}};u.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,E(this),x(this),h++;var t=n;return n=this,k.bind(this,t)};u.prototype.N=function(){2&this.f||(this.f|=2,this.u=a,a=this)};u.prototype.d=function(){this.f|=8,1&this.f||w(this)};u.prototype.dispose=function(){this.d()};function W(t,i){var o=new u(t,i);try{o.c()}catch(f){throw o.d(),f}var r=o.d.bind(o);return r[Symbol.dispose]=r,r}function O(t){return function(){var i=arguments,o=this;return N(function(){return S(function(){return t.apply(o,[].slice.call(i))})})}}function Z(){var t=e;return e=[],function(){var i=e;return e&&t&&(t=t.concat(e)),e=t,i}}var U=function(t){for(var i in t){var o=t[i];typeof o=="function"?t[i]=O(o):typeof o=="object"&&o!==null&&!("brand"in o)&&U(o)}};function M(t){return function(){var i,o,r=Z();try{o=t.apply(void 0,[].slice.call(arguments))}catch(f){throw e=void 0,f}finally{i=r()}return U(o),o[Symbol.dispose]=O(function(){if(i)for(var f=0;f<i.length;f++)i[f].dispose();i=void 0}),o}}export{v as Computed,u as Effect,s as Signal,O as action,N as batch,J as computed,M as createModel,W as effect,P as signal,S as untracked}; 3 + //# sourceMappingURL=./signals-core.mjs.map
+1
vendor/esm.sh/@preact/signals-core@1.14.1/es2022/signals-core.mjs.map
··· 1 + {"mappings":";AAEA,IAAMA,EAAeC,OAAU,IAAC,gBAAA,EAsChC,SAASC,GAAAA,CACR,GAAIC,EAAa,EAChBA,QADD,CAKA,IAAIC,EACAC,EAAAA,GAGJ,KAkHD,UAAA,CACC,IAAIC,EAAYC,EAGhB,IAFAA,EAAAA,OAEOD,IAAP,QACKA,EAAUE,EAAQC,IAAWH,EAAUG,IAC1CH,EAAUE,EAAQE,EAAWJ,EAAUI,GAExCJ,EAAYA,EAAUK,CAExB,GA9HCC,EAEOC,IA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,CAAA,EAEX,UAAA,CACN,IAAIgF,EAAehF,EACnB,OAAIA,GAAmB+E,IACtBA,EAAsBA,EAAoBE,OAAOjF,CAAAA,GAGlDA,EAAkB+E,EAEXC,CACR,CACD,CAEA,IAAME,EAAe,SAACnE,EAAAA,CACrB,QAAWoE,KAAOpE,EAAO,CACxB,IAAMqE,EAAMrE,EAAMoE,CAAAA,EACC,OAARC,GAAQ,WAClBrE,EAAMoE,CAAAA,EAAOX,EAAOY,CAAAA,EACK,OAARA,GAAQ,UAAYA,IAAQ,MAARA,EAAkB,UAAWA,IAGlEF,EAAaE,CAAAA,CAEf,CACD,EAEA,SAASC,EACRC,EAAAA,CAEA,OAAA,UAAA,CACC,IAAIN,EACAO,EAEEC,EAAuBV,EAAAA,EAC7B,GAAA,CACCS,EAAQD,EAAYV,MAAAA,OAAA,CAAA,EAAAC,MAAA9C,KAAA2C,SAAAA,CAAAA,CASrB,OARSlF,EAAAA,CAIRQ,MAAAA,EAAAA,OACMR,CACP,QAAC,CACAwF,EAAeQ,EAAAA,CAChB,CAEAN,OAAAA,EAAaK,CAAAA,EAEbA,EAAMnH,OAAOmG,OAAAA,EAAWC,EAAO,UAAA,CAC9B,GAAIQ,EACH,QAASS,EAAI,EAAGA,EAAIT,EAAaU,OAAQD,IACxCT,EAAaS,CAAAA,EAAGlB,QAAAA,EAIlBS,EAAAA,MACD,CAAA,EAEOO,CACR,CACD","names":["BRAND_SYMBOL","Symbol","endBatch","batchDepth","error","hasError","snapshots","batchSnapshots","_source","_value","_version","_next","reconcileBatchSnapshots","batchedEffect","effect","batchIteration","next","_nextBatchedEffect","_flags","needsToRecompute","_callback","err","batch","fn","currentBatchSnapshotVersion","batchSnapshotVersion","evalContext","untracked","prevContext","capturedEffects","globalVersion","addDependency","signal","node","_node","_target","_prevSource","_sources","_nextSource","_prevTarget","_nextTarget","_rollbackNode","_subscribe","Signal","value","options","this","_targets","_batchSnapshotVersion","_watched","watched","_unwatched","unwatched","name","prototype","brand","_refresh","_this","targets","_this$_watched","call","_unsubscribe","_this2","prev","_this2$_unwatched","subscribe","_this3","valueOf","toString","toJSON","peek","Object","defineProperty","get","set","Error","source","_notify","target","prepareSources","rollbackNode","cleanupSources","head","Computed","undefined","_fn","_globalVersion","OUTDATED","computed","cleanupEffect","cleanup","_cleanup","disposeEffect","endEffect","Effect","push","finish","_start","bind","_dispose","dispose","action","_arguments","arguments","_this4","apply","slice","startCapturingEffects","prevCapturedEffects","modelEffects","concat","wrapInAction","key","val","createModel","modelFactory","model","stopCapturingEffects","i","length"],"sources":["../esm/npm/@preact/signals-core@1.14.1/node_modules/@preact/signals-core/src/index.ts"],"sourcesContent":["// An named symbol/brand for detecting Signal instances even when they weren't\n// created using the same signals library version.\nconst BRAND_SYMBOL = Symbol.for(\"preact-signals\");\n\n// Flags for Computed and Effect.\nconst RUNNING = 1 \u003c\u003c 0;\nconst NOTIFIED = 1 \u003c\u003c 1;\nconst OUTDATED = 1 \u003c\u003c 2;\nconst DISPOSED = 1 \u003c\u003c 3;\nconst HAS_ERROR = 1 \u003c\u003c 4;\nconst TRACKING = 1 \u003c\u003c 5;\n\n// A linked list node used to track dependencies (sources) and dependents (targets).\n// Also used to remember the source's last version number that the target saw.\ntype Node = {\n\t// A source whose value the target depends on.\n\t_source: Signal;\n\t_prevSource?: Node;\n\t_nextSource?: Node;\n\n\t// A target that depends on the source and should be notified when the source changes.\n\t_target: Computed | Effect;\n\t_prevTarget?: Node;\n\t_nextTarget?: Node;\n\n\t// The version number of the source that target has last seen. We use version numbers\n\t// instead of storing the source value, because source values can take arbitrary amount\n\t// of memory, and computeds could hang on to them forever because they're lazily evaluated.\n\t// Use the special value -1 to mark potentially unused but recyclable nodes.\n\t_version: number;\n\n\t// Used to remember \u0026 roll back the source's previous `._node` value when entering \u0026\n\t// exiting a new evaluation context.\n\t_rollbackNode?: Node;\n};\n\nfunction startBatch() {\n\tbatchDepth++;\n}\n\nfunction endBatch() {\n\tif (batchDepth \u003e 1) {\n\t\tbatchDepth--;\n\t\treturn;\n\t}\n\n\tlet error: unknown;\n\tlet hasError = false;\n\treconcileBatchSnapshots();\n\n\twhile (batchedEffect !== undefined) {\n\t\tlet effect: Effect | undefined = batchedEffect;\n\t\tbatchedEffect = undefined;\n\n\t\tbatchIteration++;\n\n\t\twhile (effect !== undefined) {\n\t\t\tconst next: Effect | undefined = effect._nextBatchedEffect;\n\t\t\teffect._nextBatchedEffect = undefined;\n\t\t\teffect._flags \u0026= ~NOTIFIED;\n\n\t\t\tif (!(effect._flags \u0026 DISPOSED) \u0026\u0026 needsToRecompute(effect)) {\n\t\t\t\ttry {\n\t\t\t\t\teffect._callback();\n\t\t\t\t} catch (err) {\n\t\t\t\t\tif (!hasError) {\n\t\t\t\t\t\terror = err;\n\t\t\t\t\t\thasError = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\teffect = next;\n\t\t}\n\t}\n\tbatchIteration = 0;\n\tbatchDepth--;\n\n\tif (hasError) {\n\t\tthrow error;\n\t}\n}\n\n/**\n * Combine multiple value updates into one \"commit\" at the end of the provided callback.\n *\n * Batches can be nested and changes are only flushed once the outermost batch callback\n * completes.\n *\n * Accessing a signal that has been modified within a batch will reflect its updated\n * value.\n *\n * @param fn The callback function.\n * @returns The value returned by the callback.\n */\nfunction batch\u003cT\u003e(fn: () =\u003e T): T {\n\tif (batchDepth \u003e 0) {\n\t\treturn fn();\n\t}\n\tcurrentBatchSnapshotVersion = ++batchSnapshotVersion;\n\t/*@__INLINE__**/ startBatch();\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\tendBatch();\n\t}\n}\n\n// Currently evaluated computed or effect.\nlet evalContext: Computed | Effect | undefined = undefined;\n\n/**\n * Run a callback function that can access signal values without\n * subscribing to the signal updates.\n *\n * @param fn The callback function.\n * @returns The value returned by the callback.\n */\nfunction untracked\u003cT\u003e(fn: () =\u003e T): T {\n\tconst prevContext = evalContext;\n\tevalContext = undefined;\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\tevalContext = prevContext;\n\t}\n}\n\n// Effects collected into a batch.\nlet batchedEffect: Effect | undefined = undefined;\nlet batchDepth = 0;\nlet batchIteration = 0;\n\ntype BatchSnapshot = {\n\t_source: Signal;\n\t_value: unknown;\n\t_version: number;\n\t_next?: BatchSnapshot;\n};\n\nlet batchSnapshotVersion = 0;\nlet currentBatchSnapshotVersion = 0;\nlet batchSnapshots: BatchSnapshot | undefined = undefined;\n\n// A global version number for signals, used for fast-pathing repeated\n// computed.peek()/computed.value calls when nothing has changed globally.\nlet globalVersion = 0;\n\nfunction recordBatchSnapshot(source: Signal) {\n\t// Only capture writes during the user-visible batch callback, not during effect flush.\n\tif (batchDepth === 0 || batchIteration !== 0) {\n\t\treturn;\n\t}\n\n\tif (source._batchSnapshotVersion !== currentBatchSnapshotVersion) {\n\t\tsource._batchSnapshotVersion = currentBatchSnapshotVersion;\n\t\tbatchSnapshots = {\n\t\t\t_source: source,\n\t\t\t_value: source._value,\n\t\t\t_version: source._version,\n\t\t\t_next: batchSnapshots,\n\t\t};\n\t}\n}\n\nfunction reconcileBatchSnapshots() {\n\tlet snapshots = batchSnapshots;\n\tbatchSnapshots = undefined;\n\n\twhile (snapshots !== undefined) {\n\t\tif (snapshots._source._value === snapshots._value) {\n\t\t\tsnapshots._source._version = snapshots._version;\n\t\t}\n\t\tsnapshots = snapshots._next;\n\t}\n}\n\nfunction addDependency(signal: Signal): Node | undefined {\n\tif (evalContext === undefined) {\n\t\treturn undefined;\n\t}\n\n\tlet node = signal._node;\n\tif (node === undefined || node._target !== evalContext) {\n\t\t/**\n\t\t * `signal` is a new dependency. Create a new dependency node, and set it\n\t\t * as the tail of the current context's dependency list. e.g:\n\t\t *\n\t\t * { A \u003c-\u003e B }\n\t\t * ↑ ↑\n\t\t * tail node (new)\n\t\t * ↓\n\t\t * { A \u003c-\u003e B \u003c-\u003e C }\n\t\t * ↑\n\t\t * tail (evalContext._sources)\n\t\t */\n\t\tnode = {\n\t\t\t_version: 0,\n\t\t\t_source: signal,\n\t\t\t_prevSource: evalContext._sources,\n\t\t\t_nextSource: undefined,\n\t\t\t_target: evalContext,\n\t\t\t_prevTarget: undefined,\n\t\t\t_nextTarget: undefined,\n\t\t\t_rollbackNode: node,\n\t\t};\n\n\t\tif (evalContext._sources !== undefined) {\n\t\t\tevalContext._sources._nextSource = node;\n\t\t}\n\t\tevalContext._sources = node;\n\t\tsignal._node = node;\n\n\t\t// Subscribe to change notifications from this dependency if we're in an effect\n\t\t// OR evaluating a computed signal that in turn has subscribers.\n\t\tif (evalContext._flags \u0026 TRACKING) {\n\t\t\tsignal._subscribe(node);\n\t\t}\n\t\treturn node;\n\t} else if (node._version === -1) {\n\t\t// `signal` is an existing dependency from a previous evaluation. Reuse it.\n\t\tnode._version = 0;\n\n\t\t/**\n\t\t * If `node` is not already the current tail of the dependency list (i.e.\n\t\t * there is a next node in the list), then make the `node` the new tail. e.g:\n\t\t *\n\t\t * { A \u003c-\u003e B \u003c-\u003e C \u003c-\u003e D }\n\t\t * ↑ ↑\n\t\t * node ┌─── tail (evalContext._sources)\n\t\t * └─────│─────┐\n\t\t * ↓ ↓\n\t\t * { A \u003c-\u003e C \u003c-\u003e D \u003c-\u003e B }\n\t\t * ↑\n\t\t * tail (evalContext._sources)\n\t\t */\n\t\tif (node._nextSource !== undefined) {\n\t\t\tnode._nextSource._prevSource = node._prevSource;\n\n\t\t\tif (node._prevSource !== undefined) {\n\t\t\t\tnode._prevSource._nextSource = node._nextSource;\n\t\t\t}\n\n\t\t\tnode._prevSource = evalContext._sources;\n\t\t\tnode._nextSource = undefined;\n\n\t\t\tevalContext._sources!._nextSource = node;\n\t\t\tevalContext._sources = node;\n\t\t}\n\n\t\t// We can assume that the currently evaluated effect / computed signal is already\n\t\t// subscribed to change notifications from `signal` if needed.\n\t\treturn node;\n\t}\n\treturn undefined;\n}\n\n//#region Signal\n\n/**\n * The base class for plain and computed signals.\n */\n//\n// A function with the same name is defined later, so we need to ignore TypeScript's\n// warning about a redeclared variable.\n//\n// The class is declared here, but later implemented with ES5-style prototypes.\n// This enables better control of the transpiled output size.\n// @ts-ignore: \"Cannot redeclare exported variable 'Signal'.\"\ndeclare class Signal\u003cT = any\u003e {\n\t/** @internal */\n\t_value: unknown;\n\n\t/**\n\t * @internal\n\t * Version numbers should always be \u003e= 0, because the special value -1 is used\n\t * by Nodes to signify potentially unused but recyclable nodes.\n\t */\n\t_version: number;\n\n\t/** @internal */\n\t_node?: Node;\n\n\t/** @internal */\n\t_targets?: Node;\n\n\t/** @internal */\n\t_batchSnapshotVersion: number;\n\n\tconstructor(value?: T, options?: SignalOptions\u003cT\u003e);\n\n\t/** @internal */\n\t_refresh(): boolean;\n\n\t/** @internal */\n\t_subscribe(node: Node): void;\n\n\t/** @internal */\n\t_unsubscribe(node: Node): void;\n\n\t/** @internal */\n\t_watched?(this: Signal\u003cT\u003e): void;\n\n\t/** @internal */\n\t_unwatched?(this: Signal\u003cT\u003e): void;\n\n\tsubscribe(fn: (value: T) =\u003e void): () =\u003e void;\n\n\tname?: string;\n\n\tvalueOf(): T;\n\n\ttoString(): string;\n\n\ttoJSON(): T;\n\n\tpeek(): T;\n\n\tbrand: typeof BRAND_SYMBOL;\n\n\tget value(): T;\n\tset value(value: T);\n}\n\nexport interface SignalOptions\u003cT = any\u003e {\n\twatched?: (this: Signal\u003cT\u003e) =\u003e void;\n\tunwatched?: (this: Signal\u003cT\u003e) =\u003e void;\n\tname?: string;\n}\n\n/** @internal */\n// A class with the same name has already been declared, so we need to ignore\n// TypeScript's warning about a redeclared variable.\n//\n// The previously declared class is implemented here with ES5-style prototypes.\n// This enables better control of the transpiled output size.\n// @ts-ignore: \"Cannot redeclare exported variable 'Signal'.\"\nfunction Signal(this: Signal, value?: unknown, options?: SignalOptions) {\n\tthis._value = value;\n\tthis._version = 0;\n\tthis._node = undefined;\n\tthis._targets = undefined;\n\tthis._batchSnapshotVersion = 0;\n\tthis._watched = options?.watched;\n\tthis._unwatched = options?.unwatched;\n\tthis.name = options?.name;\n}\n\nSignal.prototype.brand = BRAND_SYMBOL;\n\nSignal.prototype._refresh = function () {\n\treturn true;\n};\n\nSignal.prototype._subscribe = function (node) {\n\tconst targets = this._targets;\n\tif (targets !== node \u0026\u0026 node._prevTarget === undefined) {\n\t\tnode._nextTarget = targets;\n\t\tthis._targets = node;\n\n\t\tif (targets !== undefined) {\n\t\t\ttargets._prevTarget = node;\n\t\t} else {\n\t\t\tuntracked(() =\u003e {\n\t\t\t\tthis._watched?.call(this);\n\t\t\t});\n\t\t}\n\t}\n};\n\nSignal.prototype._unsubscribe = function (node) {\n\t// Only run the unsubscribe step if the signal has any subscribers to begin with.\n\tif (this._targets !== undefined) {\n\t\tconst prev = node._prevTarget;\n\t\tconst next = node._nextTarget;\n\t\tif (prev !== undefined) {\n\t\t\tprev._nextTarget = next;\n\t\t\tnode._prevTarget = undefined;\n\t\t}\n\n\t\tif (next !== undefined) {\n\t\t\tnext._prevTarget = prev;\n\t\t\tnode._nextTarget = undefined;\n\t\t}\n\n\t\tif (node === this._targets) {\n\t\t\tthis._targets = next;\n\t\t\tif (next === undefined) {\n\t\t\t\tuntracked(() =\u003e {\n\t\t\t\t\tthis._unwatched?.call(this);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n};\n\nSignal.prototype.subscribe = function (fn) {\n\treturn effect(\n\t\t() =\u003e {\n\t\t\tconst value = this.value;\n\t\t\tconst prevContext = evalContext;\n\t\t\tevalContext = undefined;\n\t\t\ttry {\n\t\t\t\tfn(value);\n\t\t\t} finally {\n\t\t\t\tevalContext = prevContext;\n\t\t\t}\n\t\t},\n\t\t{ name: \"sub\" }\n\t);\n};\n\nSignal.prototype.valueOf = function () {\n\treturn this.value;\n};\n\nSignal.prototype.toString = function () {\n\treturn this.value + \"\";\n};\n\nSignal.prototype.toJSON = function () {\n\treturn this.value;\n};\n\nSignal.prototype.peek = function () {\n\tconst prevContext = evalContext;\n\tevalContext = undefined;\n\ttry {\n\t\treturn this.value;\n\t} finally {\n\t\tevalContext = prevContext;\n\t}\n};\n\nObject.defineProperty(Signal.prototype, \"value\", {\n\tget(this: Signal) {\n\t\tconst node = addDependency(this);\n\t\tif (node !== undefined) {\n\t\t\tnode._version = this._version;\n\t\t}\n\t\treturn this._value;\n\t},\n\tset(this: Signal, value) {\n\t\tif (value !== this._value) {\n\t\t\tif (batchIteration \u003e 100) {\n\t\t\t\tthrow new Error(\"Cycle detected\");\n\t\t\t}\n\n\t\t\trecordBatchSnapshot(this);\n\t\t\tthis._value = value;\n\t\t\tthis._version++;\n\t\t\tglobalVersion++;\n\n\t\t\t/**@__INLINE__*/ startBatch();\n\t\t\ttry {\n\t\t\t\tfor (\n\t\t\t\t\tlet node = this._targets;\n\t\t\t\t\tnode !== undefined;\n\t\t\t\t\tnode = node._nextTarget\n\t\t\t\t) {\n\t\t\t\t\tnode._target._notify();\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tendBatch();\n\t\t\t}\n\t\t}\n\t},\n});\n\n/**\n * Create a new plain signal.\n *\n * @param value The initial value for the signal.\n * @returns A new signal.\n */\nexport function signal\u003cT\u003e(value: T, options?: SignalOptions\u003cT\u003e): Signal\u003cT\u003e;\nexport function signal\u003cT = undefined\u003e(): Signal\u003cT | undefined\u003e;\nexport function signal\u003cT\u003e(value?: T, options?: SignalOptions\u003cT\u003e): Signal\u003cT\u003e {\n\treturn new Signal(value, options);\n}\n\n//#endregion Signal\n\n//#region Computed\n\nfunction needsToRecompute(target: Computed | Effect): boolean {\n\t// Check the dependencies for changed values. The dependency list is already\n\t// in order of use. Therefore if multiple dependencies have changed values, only\n\t// the first used dependency is re-evaluated at this point.\n\tfor (\n\t\tlet node = target._sources;\n\t\tnode !== undefined;\n\t\tnode = node._nextSource\n\t) {\n\t\tif (\n\t\t\t// If the dependency has definitely been updated since its version number\n\t\t\t// was observed, then we need to recompute. This first check is not strictly\n\t\t\t// necessary for correctness, but allows us to skip the refresh call if the\n\t\t\t// dependency has already been updated.\n\t\t\tnode._source._version !== node._version ||\n\t\t\t// Refresh the dependency. If there's something blocking the refresh (e.g. a\n\t\t\t// dependency cycle), then we need to recompute.\n\t\t\t!node._source._refresh() ||\n\t\t\t// If the dependency got a new version after the refresh, then we need to recompute.\n\t\t\tnode._source._version !== node._version\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t}\n\t// If none of the dependencies have changed values since last recompute then\n\t// there's no need to recompute.\n\treturn false;\n}\n\nfunction prepareSources(target: Computed | Effect) {\n\t/**\n\t * 1. Mark all current sources as re-usable nodes (version: -1)\n\t * 2. Set a rollback node if the current node is being used in a different context\n\t * 3. Point 'target._sources' to the tail of the doubly-linked list, e.g:\n\t *\n\t * { undefined \u003c- A \u003c-\u003e B \u003c-\u003e C -\u003e undefined }\n\t * ↑ ↑\n\t * │ └──────┐\n\t * target._sources = A; (node is head) │\n\t * ↓ │\n\t * target._sources = C; (node is tail) ─┘\n\t */\n\tfor (\n\t\tlet node = target._sources;\n\t\tnode !== undefined;\n\t\tnode = node._nextSource\n\t) {\n\t\tconst rollbackNode = node._source._node;\n\t\tif (rollbackNode !== undefined) {\n\t\t\tnode._rollbackNode = rollbackNode;\n\t\t}\n\t\tnode._source._node = node;\n\t\tnode._version = -1;\n\n\t\tif (node._nextSource === undefined) {\n\t\t\ttarget._sources = node;\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction cleanupSources(target: Computed | Effect) {\n\tlet node = target._sources;\n\tlet head: Node | undefined = undefined;\n\n\t/**\n\t * At this point 'target._sources' points to the tail of the doubly-linked list.\n\t * It contains all existing sources + new sources in order of use.\n\t * Iterate backwards until we find the head node while dropping old dependencies.\n\t */\n\twhile (node !== undefined) {\n\t\tconst prev = node._prevSource;\n\n\t\t/**\n\t\t * The node was not re-used, unsubscribe from its change notifications and remove itself\n\t\t * from the doubly-linked list. e.g:\n\t\t *\n\t\t * { A \u003c-\u003e B \u003c-\u003e C }\n\t\t * ↓\n\t\t * { A \u003c-\u003e C }\n\t\t */\n\t\tif (node._version === -1) {\n\t\t\tnode._source._unsubscribe(node);\n\n\t\t\tif (prev !== undefined) {\n\t\t\t\tprev._nextSource = node._nextSource;\n\t\t\t}\n\t\t\tif (node._nextSource !== undefined) {\n\t\t\t\tnode._nextSource._prevSource = prev;\n\t\t\t}\n\t\t} else {\n\t\t\t/**\n\t\t\t * The new head is the last node seen which wasn't removed/unsubscribed\n\t\t\t * from the doubly-linked list. e.g:\n\t\t\t *\n\t\t\t * { A \u003c-\u003e B \u003c-\u003e C }\n\t\t\t * ↑ ↑ ↑\n\t\t\t * │ │ └ head = node\n\t\t\t * │ └ head = node\n\t\t\t * └ head = node\n\t\t\t */\n\t\t\thead = node;\n\t\t}\n\n\t\tnode._source._node = node._rollbackNode;\n\t\tif (node._rollbackNode !== undefined) {\n\t\t\tnode._rollbackNode = undefined;\n\t\t}\n\n\t\tnode = prev;\n\t}\n\n\ttarget._sources = head;\n}\n\n/**\n * The base class for computed signals.\n */\ndeclare class Computed\u003cT = any\u003e extends Signal\u003cT\u003e {\n\t_fn: () =\u003e T;\n\t_sources?: Node;\n\t_globalVersion: number;\n\t_flags: number;\n\n\tconstructor(fn: () =\u003e T, options?: SignalOptions\u003cT\u003e);\n\n\t_notify(): void;\n\tget value(): T;\n}\n\n/** @internal */\nfunction Computed(this: Computed, fn: () =\u003e unknown, options?: SignalOptions) {\n\tSignal.call(this, undefined);\n\n\tthis._fn = fn;\n\tthis._sources = undefined;\n\tthis._globalVersion = globalVersion - 1;\n\tthis._flags = OUTDATED;\n\tthis._watched = options?.watched;\n\tthis._unwatched = options?.unwatched;\n\tthis.name = options?.name;\n}\n\nComputed.prototype = new Signal() as Computed;\n\nComputed.prototype._refresh = function () {\n\tthis._flags \u0026= ~NOTIFIED;\n\n\tif (this._flags \u0026 RUNNING) {\n\t\treturn false;\n\t}\n\n\t// If this computed signal has subscribed to updates from its dependencies\n\t// (TRACKING flag set) and none of them have notified about changes (OUTDATED\n\t// flag not set), then the computed value can't have changed.\n\tif ((this._flags \u0026 (OUTDATED | TRACKING)) === TRACKING) {\n\t\treturn true;\n\t}\n\tthis._flags \u0026= ~OUTDATED;\n\n\tif (this._globalVersion === globalVersion) {\n\t\treturn true;\n\t}\n\tthis._globalVersion = globalVersion;\n\n\t// Mark this computed signal running before checking the dependencies for value\n\t// changes, so that the RUNNING flag can be used to notice cyclical dependencies.\n\tthis._flags |= RUNNING;\n\tif (this._version \u003e 0 \u0026\u0026 !needsToRecompute(this)) {\n\t\tthis._flags \u0026= ~RUNNING;\n\t\treturn true;\n\t}\n\n\tconst prevContext = evalContext;\n\ttry {\n\t\tprepareSources(this);\n\t\tevalContext = this;\n\t\tconst value = this._fn();\n\t\tif (\n\t\t\tthis._flags \u0026 HAS_ERROR ||\n\t\t\tthis._value !== value ||\n\t\t\tthis._version === 0\n\t\t) {\n\t\t\tthis._value = value;\n\t\t\tthis._flags \u0026= ~HAS_ERROR;\n\t\t\tthis._version++;\n\t\t}\n\t} catch (err) {\n\t\tthis._value = err;\n\t\tthis._flags |= HAS_ERROR;\n\t\tthis._version++;\n\t}\n\tevalContext = prevContext;\n\tcleanupSources(this);\n\tthis._flags \u0026= ~RUNNING;\n\treturn true;\n};\n\nComputed.prototype._subscribe = function (node) {\n\tif (this._targets === undefined) {\n\t\tthis._flags |= OUTDATED | TRACKING;\n\n\t\t// A computed signal subscribes lazily to its dependencies when it\n\t\t// gets its first subscriber.\n\t\tfor (\n\t\t\tlet node = this._sources;\n\t\t\tnode !== undefined;\n\t\t\tnode = node._nextSource\n\t\t) {\n\t\t\tnode._source._subscribe(node);\n\t\t}\n\t}\n\tSignal.prototype._subscribe.call(this, node);\n};\n\nComputed.prototype._unsubscribe = function (node) {\n\t// Only run the unsubscribe step if the computed signal has any subscribers.\n\tif (this._targets !== undefined) {\n\t\tSignal.prototype._unsubscribe.call(this, node);\n\n\t\t// Computed signal unsubscribes from its dependencies when it loses its last subscriber.\n\t\t// This makes it possible for unreferences subgraphs of computed signals to get garbage collected.\n\t\tif (this._targets === undefined) {\n\t\t\tthis._flags \u0026= ~TRACKING;\n\n\t\t\tfor (\n\t\t\t\tlet node = this._sources;\n\t\t\t\tnode !== undefined;\n\t\t\t\tnode = node._nextSource\n\t\t\t) {\n\t\t\t\tnode._source._unsubscribe(node);\n\t\t\t}\n\t\t}\n\t}\n};\n\nComputed.prototype._notify = function () {\n\tif (!(this._flags \u0026 NOTIFIED)) {\n\t\tthis._flags |= OUTDATED | NOTIFIED;\n\n\t\tfor (\n\t\t\tlet node = this._targets;\n\t\t\tnode !== undefined;\n\t\t\tnode = node._nextTarget\n\t\t) {\n\t\t\tnode._target._notify();\n\t\t}\n\t}\n};\n\nObject.defineProperty(Computed.prototype, \"value\", {\n\tget(this: Computed) {\n\t\tif (this._flags \u0026 RUNNING) {\n\t\t\tthrow new Error(\"Cycle detected\");\n\t\t}\n\t\tconst node = addDependency(this);\n\t\tthis._refresh();\n\t\tif (node !== undefined) {\n\t\t\tnode._version = this._version;\n\t\t}\n\t\tif (this._flags \u0026 HAS_ERROR) {\n\t\t\tthrow this._value;\n\t\t}\n\t\treturn this._value;\n\t},\n});\n\n/**\n * An interface for read-only signals.\n */\ninterface ReadonlySignal\u003cT = any\u003e {\n\treadonly value: T;\n\tpeek(): T;\n\n\tsubscribe(fn: (value: T) =\u003e void): () =\u003e void;\n\tvalueOf(): T;\n\ttoString(): string;\n\ttoJSON(): T;\n\tbrand: typeof BRAND_SYMBOL;\n}\n\n/**\n * Create a new signal that is computed based on the values of other signals.\n *\n * The returned computed signal is read-only, and its value is automatically\n * updated when any signals accessed from within the callback function change.\n *\n * @param fn The effect callback.\n * @returns A new read-only signal.\n */\nfunction computed\u003cT\u003e(\n\tfn: () =\u003e T,\n\toptions?: SignalOptions\u003cT\u003e\n): ReadonlySignal\u003cT\u003e {\n\treturn new Computed(fn, options);\n}\n\n//#endregion Computed\n\n//#region Effect\n\nfunction cleanupEffect(effect: Effect) {\n\tconst cleanup = effect._cleanup;\n\teffect._cleanup = undefined;\n\n\tif (typeof cleanup === \"function\") {\n\t\t/*@__INLINE__**/ startBatch();\n\n\t\t// Run cleanup functions always outside of any context.\n\t\tconst prevContext = evalContext;\n\t\tevalContext = undefined;\n\t\ttry {\n\t\t\tcleanup();\n\t\t} catch (err) {\n\t\t\teffect._flags \u0026= ~RUNNING;\n\t\t\teffect._flags |= DISPOSED;\n\t\t\tdisposeEffect(effect);\n\t\t\tthrow err;\n\t\t} finally {\n\t\t\tevalContext = prevContext;\n\t\t\tendBatch();\n\t\t}\n\t}\n}\n\nfunction disposeEffect(effect: Effect) {\n\tfor (\n\t\tlet node = effect._sources;\n\t\tnode !== undefined;\n\t\tnode = node._nextSource\n\t) {\n\t\tnode._source._unsubscribe(node);\n\t}\n\teffect._fn = undefined;\n\teffect._sources = undefined;\n\n\tcleanupEffect(effect);\n}\n\nfunction endEffect(this: Effect, prevContext?: Computed | Effect) {\n\tif (evalContext !== this) {\n\t\tthrow new Error(\"Out-of-order effect\");\n\t}\n\tcleanupSources(this);\n\tevalContext = prevContext;\n\n\tthis._flags \u0026= ~RUNNING;\n\tif (this._flags \u0026 DISPOSED) {\n\t\tdisposeEffect(this);\n\t}\n\tendBatch();\n}\n\ntype EffectFn =\n\t| ((this: { dispose: () =\u003e void }) =\u003e void | (() =\u003e void))\n\t| (() =\u003e void | (() =\u003e void));\n\n// Avoid hard-requiring the ESNext.Disposable lib in consuming tsconfigs.\n// When `Symbol.dispose` is available, this becomes a symbol-keyed disposer type.\ntype DisposeSymbol = typeof Symbol extends { readonly dispose: infer TDispose }\n\t? TDispose\n\t: never;\ntype DisposableLike = {\n\t[K in DisposeSymbol \u0026 PropertyKey]: () =\u003e void;\n};\ntype DisposeFn = (() =\u003e void) \u0026 DisposableLike;\n\n/**\n * The base class for reactive effects.\n */\ndeclare class Effect {\n\t_fn?: EffectFn;\n\t_cleanup?: () =\u003e void;\n\t_sources?: Node;\n\t_nextBatchedEffect?: Effect;\n\t_flags: number;\n\t_debugCallback?: () =\u003e void;\n\tname?: string;\n\n\tconstructor(fn: EffectFn, options?: EffectOptions);\n\n\t_callback(): void;\n\t_start(): () =\u003e void;\n\t_notify(): void;\n\t_dispose(): void;\n\tdispose(): void;\n}\n\nexport interface EffectOptions {\n\tname?: string;\n}\n\nlet capturedEffects: Effect[] | undefined;\n\n/** @internal */\nfunction Effect(this: Effect, fn: EffectFn, options?: EffectOptions) {\n\tthis._fn = fn;\n\tthis._cleanup = undefined;\n\tthis._sources = undefined;\n\tthis._nextBatchedEffect = undefined;\n\tthis._flags = TRACKING;\n\tthis.name = options?.name;\n\n\tif (capturedEffects) {\n\t\tcapturedEffects.push(this);\n\t}\n}\n\nEffect.prototype._callback = function () {\n\tconst finish = this._start();\n\ttry {\n\t\tif (this._flags \u0026 DISPOSED) return;\n\t\tif (this._fn === undefined) return;\n\n\t\tconst cleanup = this._fn();\n\t\tif (typeof cleanup === \"function\") {\n\t\t\tthis._cleanup = cleanup;\n\t\t}\n\t} finally {\n\t\tfinish();\n\t}\n};\n\nEffect.prototype._start = function () {\n\tif (this._flags \u0026 RUNNING) {\n\t\tthrow new Error(\"Cycle detected\");\n\t}\n\tthis._flags |= RUNNING;\n\tthis._flags \u0026= ~DISPOSED;\n\tcleanupEffect(this);\n\tprepareSources(this);\n\n\t/*@__INLINE__**/ startBatch();\n\tconst prevContext = evalContext;\n\tevalContext = this;\n\treturn endEffect.bind(this, prevContext);\n};\n\nEffect.prototype._notify = function () {\n\tif (!(this._flags \u0026 NOTIFIED)) {\n\t\tthis._flags |= NOTIFIED;\n\t\tthis._nextBatchedEffect = batchedEffect;\n\t\tbatchedEffect = this;\n\t}\n};\n\nEffect.prototype._dispose = function () {\n\tthis._flags |= DISPOSED;\n\n\tif (!(this._flags \u0026 RUNNING)) {\n\t\tdisposeEffect(this);\n\t}\n};\n\nEffect.prototype.dispose = function () {\n\tthis._dispose();\n};\n/**\n * Create an effect to run arbitrary code in response to signal changes.\n *\n * An effect tracks which signals are accessed within the given callback\n * function `fn`, and re-runs the callback when those signals change.\n *\n * The callback may return a cleanup function. The cleanup function gets\n * run once, either when the callback is next called or when the effect\n * gets disposed, whichever happens first.\n *\n * @param fn The effect callback.\n * @returns A function for disposing the effect.\n */\nfunction effect(fn: EffectFn, options?: EffectOptions): DisposeFn {\n\tconst effect = new Effect(fn, options);\n\ttry {\n\t\teffect._callback();\n\t} catch (err) {\n\t\teffect._dispose();\n\t\tthrow err;\n\t}\n\t// Return a bound function instead of a wrapper like `() =\u003e effect._dispose()`,\n\t// because bound functions seem to be just as fast and take up a lot less memory.\n\tconst dispose = effect._dispose.bind(effect);\n\t(dispose as any)[Symbol.dispose] = dispose;\n\treturn dispose as DisposeFn;\n}\n\n//#endregion Effect\n\n//#region Action\n\nfunction action\u003cTArgs extends unknown[], TReturn\u003e(\n\tfn: (...args: TArgs) =\u003e TReturn\n): (...args: TArgs) =\u003e TReturn {\n\treturn function actionWrapper(this: unknown, ...args: TArgs) {\n\t\treturn batch(() =\u003e untracked(() =\u003e fn.apply(this, args)));\n\t};\n}\n\n//#endregion Action\n\n//#region createModel\n\n/** Models should only contain signals, actions, and nested objects containing only signals and actions. */\ntype ValidateModel\u003cTModel\u003e = {\n\t[Key in keyof TModel]: TModel[Key] extends ReadonlySignal\u003cunknown\u003e\n\t\t? TModel[Key]\n\t\t: TModel[Key] extends (...args: any[]) =\u003e any\n\t\t\t? TModel[Key]\n\t\t\t: TModel[Key] extends object\n\t\t\t\t? ValidateModel\u003cTModel[Key]\u003e\n\t\t\t\t: `Property ${Key extends string ? `'${Key}' ` : \"\"}is not a Signal, Action, or an object that contains only Signals and Actions.`;\n};\n\nexport type Model\u003cTModel\u003e = ValidateModel\u003cTModel\u003e \u0026 DisposableLike;\n\nexport type ModelFactory\u003cTModel, TFactoryArgs extends any[] = []\u003e = (\n\t...args: TFactoryArgs\n) =\u003e ValidateModel\u003cTModel\u003e;\nexport type ModelConstructor\u003cTModel, TFactoryArgs extends any[] = []\u003e = new (\n\t...args: TFactoryArgs\n) =\u003e Model\u003cTModel\u003e;\n\n/**\n * The public types for ModelConstructor require using `new` to help\n * disambiguate the function passed into `createModel` and the returned\n * constructor function. It is easier to say that `createModel` accepts\n * a factory and returns a class, then to say it accepts a factory and\n * returns a factory. In other words, this example:\n *\n * ```ts\n * const PersonModel = createModel((name: string) =\u003e ({ ... }));\n * const person = new PersonModel(\"John\");\n * ```\n *\n * is easier to understand than this example:\n *\n * ```ts\n * const createPerson = createModel((name: string) =\u003e ({ ... }));\n * const person = createPerson(\"John\");\n * ```\n *\n * However, internally we implement `createModel` to return a function\n * that can be called without `new` for simplicity. To bridge the gap\n * between the public types and the internal implementation, we define\n * this internal interface that extends the public interface but also\n * allows calling without `new`.\n *\n * This pattern is used by the Preact \u0026 React adapters to make instantiating\n * a model or a function that returns a model easier.\n *\n * @internal\n */\ninterface InternalModelConstructor\u003c\n\tTModel,\n\tTFactoryArgs extends any[],\n\u003e extends ModelConstructor\u003cTModel, TFactoryArgs\u003e {\n\t(...args: TFactoryArgs): Model\u003cTModel\u003e;\n}\n\nfunction startCapturingEffects(): () =\u003e Effect[] | undefined {\n\tlet prevCapturedEffects = capturedEffects;\n\tcapturedEffects = [];\n\n\treturn function stopCapturingEffects() {\n\t\tlet modelEffects = capturedEffects;\n\t\tif (capturedEffects \u0026\u0026 prevCapturedEffects) {\n\t\t\tprevCapturedEffects = prevCapturedEffects.concat(capturedEffects);\n\t\t}\n\n\t\tcapturedEffects = prevCapturedEffects;\n\n\t\treturn modelEffects;\n\t};\n}\n\nconst wrapInAction = (value: Record\u003cstring, unknown\u003e) =\u003e {\n\tfor (const key in value) {\n\t\tconst val = value[key];\n\t\tif (typeof val === \"function\") {\n\t\t\tvalue[key] = action(val as (...args: unknown[]) =\u003e unknown);\n\t\t} else if (typeof val === \"object\" \u0026\u0026 val !== null \u0026\u0026 !(\"brand\" in val)) {\n\t\t\t// Recursively wrap nested object properties in actions. This allows users to write\n\t\t\t// nested models without worrying about wrapping their functions in `action`.\n\t\t\twrapInAction(val as Record\u003cstring, unknown\u003e);\n\t\t}\n\t}\n};\n\nfunction createModel\u003cTModel, TFactoryArgs extends any[] = []\u003e(\n\tmodelFactory: ModelFactory\u003cTModel, TFactoryArgs\u003e\n): ModelConstructor\u003cTModel, TFactoryArgs\u003e {\n\treturn function SignalModel(...args: TFactoryArgs): Model\u003cTModel\u003e {\n\t\tlet modelEffects: Effect[] | undefined;\n\t\tlet model: Model\u003cTModel\u003e;\n\n\t\tconst stopCapturingEffects = startCapturingEffects();\n\t\ttry {\n\t\t\tmodel = modelFactory(...args) as Model\u003cTModel\u003e;\n\t\t} catch (err) {\n\t\t\t// Drop any captured effects on error. Errors from nested models will bubble\n\t\t\t// up here and recursively reset `capturedEffects` to `undefined` preventing\n\t\t\t// any captured effects from leaking\n\t\t\tcapturedEffects = undefined;\n\t\t\tthrow err;\n\t\t} finally {\n\t\t\tmodelEffects = stopCapturingEffects();\n\t\t}\n\n\t\twrapInAction(model);\n\n\t\tmodel[Symbol.dispose] = action(function disposeModel() {\n\t\t\tif (modelEffects) {\n\t\t\t\tfor (let i = 0; i \u003c modelEffects.length; i++) {\n\t\t\t\t\tmodelEffects[i].dispose();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmodelEffects = undefined;\n\t\t});\n\n\t\treturn model;\n\t} as InternalModelConstructor\u003cTModel, TFactoryArgs\u003e;\n}\n\n//#endregion createModel\n\nexport {\n\tcomputed,\n\teffect,\n\tbatch,\n\tuntracked,\n\taction,\n\tcreateModel,\n\tSignal,\n\tReadonlySignal,\n\tEffect,\n\tComputed,\n};\n"],"version":3}
+3
vendor/esm.sh/@preact/signals@2.9.0/X-ZXByZWFjdA/es2022/signals.mjs
··· 1 + /* esm.sh - @preact/signals@2.9.0 */ 2 + import{Component as U,options as m,isValidElement as x,Fragment as C}from"preact";import{useMemo as y,useRef as A,useEffect as S}from"preact/hooks";import{effect as l,Signal as k,computed as $,signal as w,batch as N}from"../../../signals-core@1.14.1/es2022/signals-core.mjs";import{Signal as X,action as Y,batch as Z,computed as ee,createModel as ie,effect as te,signal as ne,untracked as re}from"../../../signals-core@1.14.1/es2022/signals-core.mjs";var b,g,d,R=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,T=[],q=[];l(function(){b=this.N})();function s(i,e){m[i]=e.bind(null,m[i]||function(){})}function h(i){if(d){var e=d;d=void 0,e()}d=i&&i.S()}function F(i){var e=this,t=i.data,n=V(t);n.value=t;var f=y(function(){for(var o=e,a=e.__v;a=a.__;)if(a.__c){a.__c.__$f|=4;break}var _=$(function(){var v=n.value.value;return v===0?0:v===!0?"":v||""}),c=$(function(){return!Array.isArray(_.value)&&!x(_.value)}),p=l(function(){if(this.N=E,c.value){var v=_.value;o.__v&&o.__v.__e&&o.__v.__e.nodeType===3&&(o.__v.__e.data=v)}}),M=e.__$u.d;return e.__$u.d=function(){p(),M.call(this)},[c,_]},[]),r=f[0],u=f[1];return r.value?u.peek():u.value}F.displayName="ReactiveTextNode";Object.defineProperties(k.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:F},props:{configurable:!0,get:function(){var i=this;return{data:{get value(){return i.value}}}}},__b:{configurable:!0,value:1}});s("__b",function(i,e){if(typeof e.type=="string"){var t,n=e.props;for(var f in n)if(f!=="children"){var r=n[f];r instanceof k&&(t||(e.__np=t={}),t[f]=r,n[f]=r.peek())}}i(e)});s("__r",function(i,e){if(i(e),e.type!==C){h();var t,n=e.__c;n&&(n.__$f&=-2,(t=n.__$u)===void 0&&(n.__$u=t=(function(f,r){var u;return l(function(){u=this},{name:r}),u.c=f,u})(function(){var f;R&&((f=t.y)==null||f.call(t)),n.__$f|=1,n.setState({})},typeof e.type=="function"?e.type.displayName||e.type.name:""))),g=n,h(t)}});s("__e",function(i,e,t,n){h(),g=void 0,i(e,t,n)});s("diffed",function(i,e){h(),g=void 0;var t;if(typeof e.type=="string"&&(t=e.__e)){var n=e.__np,f=e.props;if(n){var r=t.U;if(r)for(var u in r){var o=r[u];o!==void 0&&!(u in n)&&(o.d(),r[u]=void 0)}else r={},t.U=r;for(var a in n){var _=r[a],c=n[a];_===void 0?(_=O(t,a,c),r[a]=_):_.o(c,f)}for(var p in n)f[p]=n[p]}}i(e)});function O(i,e,t,n){var f=e in i&&i.ownerSVGElement===void 0,r=w(t),u=t.peek();return{o:function(o,a){r.value=o,u=o.peek()},d:l(function(){this.N=E;var o=r.value.value;u!==o?(u=void 0,f?i[e]=o:o!=null&&(o!==!1||e[4]==="-")?i.setAttribute(e,o):i.removeAttribute(e)):u=void 0})}}s("unmount",function(i,e){if(typeof e.type=="string"){var t=e.__e;if(t){var n=t.U;if(n){t.U=void 0;for(var f in n){var r=n[f];r&&r.d()}}}e.__np=void 0}else{var u=e.__c;if(u){var o=u.__$u;o&&(u.__$u=void 0,o.d())}}i(e)});s("__h",function(i,e,t,n){(n<3||n===9)&&(e.__$f|=2),i(e,t,n)});U.prototype.shouldComponentUpdate=function(i,e){if(this.__R)return!0;var t=this.__$u,n=t&&t.s!==void 0;for(var f in e)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var r=2&this.__$f;if(!(n||r||4&this.__$f)||1&this.__$f)return!0}else if(!(n||4&this.__$f)||3&this.__$f)return!0;for(var u in i)if(u!=="__source"&&i[u]!==this.props[u])return!0;for(var o in this.props)if(!(o in i))return!0;return!1};function V(i,e){return y(function(){return w(i,e)},[])}function H(i,e){var t=A(i);return t.current=i,g.__$f|=4,y(function(){return $(function(){return t.current()},e)},[])}var G=typeof requestAnimationFrame>"u"?setTimeout:function(i){var e=function(){clearTimeout(t),cancelAnimationFrame(n),i()},t=setTimeout(e,35),n=requestAnimationFrame(e)},L=function(i){queueMicrotask(function(){queueMicrotask(i)})};function P(){N(function(){for(var i;i=T.shift();)b.call(i)})}function j(){T.push(this)===1&&(m.requestAnimationFrame||G)(P)}function D(){N(function(){for(var i;i=q.shift();)b.call(i)})}function E(){q.push(this)===1&&(m.requestAnimationFrame||L)(D)}function J(i,e){var t=A(i);t.current=i,S(function(){return l(function(){return this.N=j,t.current()},e)},[])}function K(i){var e=y(function(){return i()},[]);return S(function(){return e[Symbol.dispose]},[e]),e}export{X as Signal,Y as action,Z as batch,ee as computed,ie as createModel,te as effect,ne as signal,re as untracked,H as useComputed,K as useModel,V as useSignal,J as useSignalEffect}; 3 + //# sourceMappingURL=./signals.mjs.map
+1
vendor/esm.sh/@preact/signals@2.9.0/X-ZXByZWFjdA/es2022/signals.mjs.map
··· 1 + {"mappings":";ibAyCA,IAOIA,EAiBAC,EACAC,EAzBEC,EACa,OAAXC,OAAW,KAAXA,CAAAA,CAA4BA,OAAOC,4BAO1CC,EAA8B,CAAA,EAC9BC,EAA0B,CAAA,EAK3BC,EAAO,UAAA,CACNR,EAAYS,KAAKC,CAClB,CAAA,EAFAF,EAKA,SAASG,EAA6BC,EAAaC,EAAAA,CAElDC,EAAQF,CAAAA,EAAYC,EAAOE,KAAK,KAAMD,EAAQF,CAAAA,GAAc,UAAA,CAAO,CAAA,CACpE,CAKA,SAASI,EAAkBC,EAAAA,CAE1B,GAAIf,EAAc,CACjB,IAAMgB,EAAShB,EACfA,EAAAA,OACAgB,EAAAA,CACD,CAEAhB,EAAee,GAAWA,EAAQE,EAAAA,CACnC,CA2BA,SAASC,EAAWC,EAAAA,CAAqDC,IAAAA,EAAxBb,KAAAc,EAAIF,EAAJE,KAK1CC,EAAgBC,EAAUF,CAAAA,EAChCC,EAAcE,MAAQH,EAEtB,IAAAI,EAAoBC,EAAQ,UAAA,CAI3B,QAHIC,EAAOP,EAEPQ,EAAIR,EAAKS,IACLD,EAAIA,EAAEE,IACb,GAAIF,EAAEG,IAAK,CACVH,EAAEG,IAAIC,MAxEY,EAyElB,KACD,CAGD,IAAMC,EAAgBC,EAAS,UAAA,CAC9B,IAAIC,EAAIb,EAAcE,MAAMA,MAC5B,OAAOW,IAAM,EAAI,EAAIA,IAAJ,GAAiB,GAAKA,GAAK,EAC7C,CAAA,EAEMC,EAASF,EACd,UAAA,CAAA,MAAA,CACEG,MAAMC,QAAQL,EAAcT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ACfT,EACA1G,EAAAA,CAEA,IAAMmG,EAAWL,EAAOY,CAAAA,EACxBP,EAASJ,QAAUW,EAEnBU,EAAU,UAAA,CACT,OAAO1H,EAAO,UAAA,CACbC,YAAKC,EAAUoH,EACRb,EAASJ,QAAAA,CACjB,EAAG/F,CAAAA,CACJ,EAAG,CAAA,CAAA,CACJ,CAUgB,SAAAqH,EACfC,EAAAA,CAMA,IAAMR,EAAOhG,EAAQ,UAAA,CAAA,OAAOwG,EAAAA,CAA6B,EAAE,CAAA,CAAA,EAC3DF,OAAAA,EAAU,UAAA,CAAM,OAAAN,EAAKS,OAAO3F,OAAAA,CAAQ,EAAE,CAACkF,CAAAA,CAAAA,EAChCA,CACR","names":["oldNotify","currentComponent","finishUpdate","DEVTOOLS_ENABLED","window","__PREACT_SIGNALS_DEVTOOLS__","effectsQueue","domQueue","effect","this","_notify","hook","hookName","hookFn","options","bind","setCurrentUpdater","updater","finish","_start","SignalValue","_ref","_this","data","currentSignal","useSignal","value","_useMemo","useMemo","self","v","__v","__","__c","_updateFlags","wrappedSignal","computed","s","isText","Array","isArray","isValidElement","dispose","notifyDomUpdates","__e","nodeType","oldDispose","_updater","_dispose","call","peek","displayName","Object","defineProperties","Signal","prototype","constructor","configurable","undefined","type","props","get","__b","old","vnode","signalProps","i","__np","Fragment","component","update","name","_callback","_updater$_debugCallba","_debugCallback","setState","error","oldVNode","dom","renderedProps","updaters","_updaters","prop","signal","createPropUpdater","_update","propSignal","setAsProperty","ownerSVGElement","changeSignal","lastRenderedValue","newSignal","newProps","setAttribute","removeAttribute","index","Component","shouldComponentUpdate","state","__R","hasSignals","_sources","__f","u","hasHooksState","useComputed","compute","$compute","useRef","current","deferEffects","requestAnimationFrame","setTimeout","callback","done","clearTimeout","timeout","cancelAnimationFrame","raf","deferDomUpdates","cb","queueMicrotask","flushEffects","batch","inst","shift","notifyEffects","push","flushDomUpdates","useSignalEffect","useEffect","useModel","factory","Symbol"],"sources":["../esm/npm/@preact/signals@2.9.0/node_modules/@preact/signals/src/index.ts"],"sourcesContent":["import { options, Component, isValidElement, Fragment } from \"preact\";\nimport { useRef, useMemo, useEffect } from \"preact/hooks\";\nimport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\taction,\n\tcreateModel,\n\ttype Model,\n\ttype ModelConstructor,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n\tSignalOptions,\n\tEffectOptions,\n} from \"@preact/signals-core\";\nimport {\n\tVNode,\n\tOptionsTypes,\n\tHookFn,\n\tEffect,\n\tPropertyUpdater,\n\tAugmentedComponent,\n\tAugmentedElement as Element,\n} from \"./internal\";\n\nexport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\taction,\n\ttype Model,\n\ttype ModelConstructor,\n\tcreateModel,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n};\n\nconst DEVTOOLS_ENABLED =\n\ttypeof window !== \"undefined\" \u0026\u0026 !!window.__PREACT_SIGNALS_DEVTOOLS__;\n\nconst HAS_PENDING_UPDATE = 1 \u003c\u003c 0;\nconst HAS_HOOK_STATE = 1 \u003c\u003c 1;\nconst HAS_COMPUTEDS = 1 \u003c\u003c 2;\n\nlet oldNotify: (this: Effect) =\u003e void,\n\teffectsQueue: Array\u003cEffect\u003e = [],\n\tdomQueue: Array\u003cEffect\u003e = [];\n\n// Capture the original `Effect.prototype._notify` method so that we can install\n// custom `._notify`s for each different use-case but still call the original\n// implementation in the end. Dispose the temporary effect immediately afterwards.\neffect(function (this: Effect) {\n\toldNotify = this._notify;\n})();\n\n// Install a Preact options hook\nfunction hook\u003cT extends OptionsTypes\u003e(hookName: T, hookFn: HookFn\u003cT\u003e) {\n\t// @ts-ignore-next-line private options hooks usage\n\toptions[hookName] = hookFn.bind(null, options[hookName] || (() =\u003e {}));\n}\n\nlet currentComponent: AugmentedComponent | undefined;\nlet finishUpdate: (() =\u003e void) | undefined;\n\nfunction setCurrentUpdater(updater?: Effect) {\n\t// end tracking for the current update:\n\tif (finishUpdate) {\n\t\tconst finish = finishUpdate;\n\t\tfinishUpdate = undefined;\n\t\tfinish();\n\t}\n\t// start tracking the new update:\n\tfinishUpdate = updater \u0026\u0026 updater._start();\n}\n\nfunction createUpdater(update: () =\u003e void, name: string) {\n\tlet updater!: Effect;\n\teffect(\n\t\tfunction (this: Effect) {\n\t\t\tupdater = this;\n\t\t},\n\t\t{ name }\n\t);\n\tupdater._callback = update;\n\treturn updater;\n}\n\n/** @todo This may be needed for complex prop value detection. */\n// function isSignalValue(value: any): value is Signal {\n// \tif (typeof value !== \"object\" || value == null) return false;\n// \tif (value instanceof Signal) return true;\n// \t// @TODO: uncomment this when we land Reactive (ideally behind a brand check)\n// \t// for (let i in value) if (value[i] instanceof Signal) return true;\n// \treturn false;\n// }\n\n/**\n * A wrapper component that renders a Signal directly as a Text node.\n * @todo: in Preact 11, just decorate Signal with `type:null`\n */\nfunction SignalValue(this: AugmentedComponent, { data }: { data: Signal }) {\n\t// hasComputeds.add(this);\n\n\t// Store the props.data signal in another signal so that\n\t// passing a new signal reference re-runs the text computed:\n\tconst currentSignal = useSignal(data);\n\tcurrentSignal.value = data;\n\n\tconst [isText, s] = useMemo(() =\u003e {\n\t\tlet self = this;\n\t\t// mark the parent component as having computeds so it gets optimized\n\t\tlet v = this.__v;\n\t\twhile ((v = v.__!)) {\n\t\t\tif (v.__c) {\n\t\t\t\tv.__c._updateFlags |= HAS_COMPUTEDS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst wrappedSignal = computed(() =\u003e {\n\t\t\tlet s = currentSignal.value.value;\n\t\t\treturn s === 0 ? 0 : s === true ? \"\" : s || \"\";\n\t\t});\n\n\t\tconst isText = computed(\n\t\t\t() =\u003e\n\t\t\t\t!Array.isArray(wrappedSignal.value) \u0026\u0026\n\t\t\t\t!isValidElement(wrappedSignal.value)\n\t\t);\n\t\t// Update text nodes directly without rerendering when the new value\n\t\t// is also text.\n\t\tconst dispose = effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\n\t\t\t// Subscribe to wrappedSignal updates only when its values are text...\n\t\t\tif (isText.value) {\n\t\t\t\t// ...but regardless of `self.base`'s current value, as it can be\n\t\t\t\t// undefined before mounting or a non-text node. In both of those cases\n\t\t\t\t// the update gets handled by a full rerender.\n\t\t\t\tconst value = wrappedSignal.value;\n\t\t\t\tif (self.__v \u0026\u0026 self.__v.__e \u0026\u0026 self.__v.__e.nodeType === 3) {\n\t\t\t\t\t(self.__v.__e as Text).data = value;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Piggyback this._updater's disposal to ensure that the text updater effect\n\t\t// above also gets disposed on unmount.\n\t\tconst oldDispose = this._updater!._dispose;\n\t\tthis._updater!._dispose = function () {\n\t\t\tdispose();\n\t\t\toldDispose.call(this);\n\t\t};\n\n\t\treturn [isText, wrappedSignal];\n\t}, []);\n\n\t// Rerender the component whenever `data.value` changes from a VNode\n\t// to another VNode, from text to a VNode, or from a VNode to text.\n\t// That is, everything else except text-to-text updates.\n\t//\n\t// This also ensures that the backing DOM node types gets updated to\n\t// text nodes and back when needed.\n\t//\n\t// For text-to-text updates, `.peek()` is used to skip full rerenders,\n\t// leaving them to the optimized path above.\n\treturn isText.value ? s.peek() : s.value;\n}\n\nSignalValue.displayName = \"ReactiveTextNode\";\n\nObject.defineProperties(Signal.prototype, {\n\tconstructor: { configurable: true, value: undefined },\n\ttype: { configurable: true, value: SignalValue },\n\tprops: {\n\t\tconfigurable: true,\n\t\tget() {\n\t\t\tconst s: Signal = this;\n\t\t\treturn {\n\t\t\t\tdata: {\n\t\t\t\t\tget value() {\n\t\t\t\t\t\treturn s.value;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t},\n\t// Setting a VNode's _depth to 1 forces Preact to clone it before modifying:\n\t// https://github.com/preactjs/preact/blob/d7a433ee8463a7dc23a05111bb47de9ec729ad4d/src/diff/children.js#L77\n\t// @todo remove this for Preact 11\n\t__b: { configurable: true, value: 1 },\n});\n\n/** Inject low-level property/attribute bindings for Signals into Preact's diff */\nhook(OptionsTypes.DIFF, (old, vnode) =\u003e {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet signalProps: Record\u003cstring, any\u003e | undefined;\n\n\t\tlet props = vnode.props;\n\t\tfor (let i in props) {\n\t\t\tif (i === \"children\") continue;\n\n\t\t\tlet value = props[i];\n\t\t\tif (value instanceof Signal) {\n\t\t\t\tif (!signalProps) vnode.__np = signalProps = {};\n\t\t\t\tsignalProps[i] = value;\n\t\t\t\tprops[i] = value.peek();\n\t\t\t}\n\t\t}\n\t}\n\n\told(vnode);\n});\n\n/** Set up Updater before rendering a component */\nhook(OptionsTypes.RENDER, (old, vnode) =\u003e {\n\told(vnode);\n\t// Ignore the Fragment inserted by preact.createElement().\n\tif (vnode.type !== Fragment) {\n\t\tsetCurrentUpdater();\n\n\t\tlet updater: Effect | undefined;\n\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tcomponent._updateFlags \u0026= ~HAS_PENDING_UPDATE;\n\n\t\t\tupdater = component._updater;\n\t\t\tif (updater === undefined) {\n\t\t\t\tcomponent._updater = updater = createUpdater(\n\t\t\t\t\t() =\u003e {\n\t\t\t\t\t\tif (DEVTOOLS_ENABLED) updater!._debugCallback?.call(updater);\n\t\t\t\t\t\tcomponent._updateFlags |= HAS_PENDING_UPDATE;\n\t\t\t\t\t\tcomponent.setState({});\n\t\t\t\t\t},\n\t\t\t\t\ttypeof vnode.type === \"function\"\n\t\t\t\t\t\t? vnode.type.displayName || vnode.type.name\n\t\t\t\t\t\t: \"\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tcurrentComponent = component;\n\t\tsetCurrentUpdater(updater);\n\t}\n});\n\n/** Finish current updater if a component errors */\nhook(OptionsTypes.CATCH_ERROR, (old, error, vnode, oldVNode) =\u003e {\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\told(error, vnode, oldVNode);\n});\n\n/** Finish current updater after rendering any VNode */\nhook(OptionsTypes.DIFFED, (old, vnode) =\u003e {\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\n\tlet dom: Element;\n\n\t// vnode._dom is undefined during string rendering,\n\t// so we use this to skip prop subscriptions during SSR.\n\tif (typeof vnode.type === \"string\" \u0026\u0026 (dom = vnode.__e as Element)) {\n\t\tlet props = vnode.__np;\n\t\tlet renderedProps = vnode.props;\n\t\tif (props) {\n\t\t\tlet updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater !== undefined \u0026\u0026 !(prop in props)) {\n\t\t\t\t\t\tupdater._dispose();\n\t\t\t\t\t\t// @todo we could just always invoke _dispose() here\n\t\t\t\t\t\tupdaters[prop] = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tupdaters = {};\n\t\t\t\tdom._updaters = updaters;\n\t\t\t}\n\n\t\t\tfor (let prop in props) {\n\t\t\t\tlet updater = updaters[prop];\n\t\t\t\tlet signal = props[prop];\n\t\t\t\tif (updater === undefined) {\n\t\t\t\t\tupdater = createPropUpdater(dom, prop, signal, renderedProps);\n\t\t\t\t\tupdaters[prop] = updater;\n\t\t\t\t} else {\n\t\t\t\t\tupdater._update(signal, renderedProps);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (let prop in props) {\n\t\t\t\trenderedProps[prop] = props[prop];\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\nfunction createPropUpdater(\n\tdom: Element,\n\tprop: string,\n\tpropSignal: Signal,\n\tprops: Record\u003cstring, any\u003e\n): PropertyUpdater {\n\tconst setAsProperty =\n\t\tprop in dom \u0026\u0026\n\t\t// SVG elements need to go through `setAttribute` because they\n\t\t// expect things like SVGAnimatedTransformList instead of strings.\n\t\t// @ts-ignore\n\t\tdom.ownerSVGElement === undefined;\n\n\tconst changeSignal = signal(propSignal);\n\t// Track the last value we know was applied to the DOM, so we can skip\n\t// redundant updates without writing back to vnode.props (which would\n\t// clobber the Signal reference and break unmount/remount cycles).\n\tlet lastRenderedValue: any = propSignal.peek();\n\treturn {\n\t\t_update: (newSignal: Signal, newProps: typeof props) =\u003e {\n\t\t\tchangeSignal.value = newSignal;\n\t\t\tprops = newProps;\n\t\t\tlastRenderedValue = newSignal.peek();\n\t\t},\n\t\t_dispose: effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\t\t\tconst value = changeSignal.value.value;\n\t\t\t// If Preact just rendered this value, don't render it again:\n\t\t\tif (lastRenderedValue === value) {\n\t\t\t\tlastRenderedValue = undefined;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlastRenderedValue = undefined;\n\t\t\tif (setAsProperty) {\n\t\t\t\t// @ts-ignore-next-line silly\n\t\t\t\tdom[prop] = value;\n\t\t\t\t// Match Preact's attribute handling: data-* and aria-* attributes\n\t\t\t\t// https://github.com/preactjs/preact/blob/main/src/diff/props.js#L132\n\t\t\t} else if (value != null \u0026\u0026 (value !== false || prop[4] === \"-\")) {\n\t\t\t\tdom.setAttribute(prop, value);\n\t\t\t} else {\n\t\t\t\tdom.removeAttribute(prop);\n\t\t\t}\n\t\t}),\n\t};\n}\n\n/** Unsubscribe from Signals when unmounting components/vnodes */\nhook(OptionsTypes.UNMOUNT, (old, vnode: VNode) =\u003e {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet dom = vnode.__e as Element | undefined;\n\t\t// vnode._dom is undefined during string rendering\n\t\tif (dom) {\n\t\t\tconst updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tdom._updaters = undefined;\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater) updater._dispose();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvnode.__np = undefined;\n\t} else {\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tconst updater = component._updater;\n\t\t\tif (updater) {\n\t\t\t\tcomponent._updater = undefined;\n\t\t\t\tupdater._dispose();\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\n/** Mark components that use hook state so we can skip sCU optimization. */\nhook(OptionsTypes.HOOK, (old, component, index, type) =\u003e {\n\tif (type \u003c 3 || type === 9)\n\t\t(component as AugmentedComponent)._updateFlags |= HAS_HOOK_STATE;\n\told(component, index, type);\n});\n\n/**\n * Auto-memoize components that use Signals/Computeds.\n * Note: Does _not_ optimize components that use hook/class state.\n */\nComponent.prototype.shouldComponentUpdate = function (\n\tthis: AugmentedComponent,\n\tprops,\n\tstate\n) {\n\t// Suspended vnodes should always update:\n\tif (this.__R) return true;\n\n\t// @todo: Once preactjs/preact#3671 lands, this could just use `currentUpdater`:\n\tconst updater = this._updater;\n\tconst hasSignals = updater \u0026\u0026 updater._sources !== undefined;\n\n\t// If this is a component using state, rerender\n\t// @ts-ignore\n\tfor (let i in state) return true;\n\n\tif (this.__f || (typeof this.u == \"boolean\" \u0026\u0026 this.u === true)) {\n\t\tconst hasHooksState = this._updateFlags \u0026 HAS_HOOK_STATE;\n\t\t// if this component used no signals or computeds and no hooks state, update:\n\t\tif (!hasSignals \u0026\u0026 !hasHooksState \u0026\u0026 !(this._updateFlags \u0026 HAS_COMPUTEDS))\n\t\t\treturn true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags \u0026 HAS_PENDING_UPDATE) return true;\n\t} else {\n\t\t// if this component used no signals or computeds, update:\n\t\tif (!hasSignals \u0026\u0026 !(this._updateFlags \u0026 HAS_COMPUTEDS)) return true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags \u0026 (HAS_PENDING_UPDATE | HAS_HOOK_STATE)) return true;\n\t}\n\n\t// if any non-Signal props changed, update:\n\tfor (let i in props) {\n\t\tif (i !== \"__source\" \u0026\u0026 props[i] !== this.props[i]) return true;\n\t}\n\tfor (let i in this.props) if (!(i in props)) return true;\n\n\t// this is a purely Signal-driven component, don't update:\n\treturn false;\n};\n\nexport function useSignal\u003cT\u003e(value: T, options?: SignalOptions\u003cT\u003e): Signal\u003cT\u003e;\nexport function useSignal\u003cT = undefined\u003e(): Signal\u003cT | undefined\u003e;\nexport function useSignal\u003cT\u003e(value?: T, options?: SignalOptions\u003cT\u003e) {\n\treturn useMemo(\n\t\t() =\u003e signal\u003cT | undefined\u003e(value, options as SignalOptions),\n\t\t[]\n\t);\n}\n\nexport function useComputed\u003cT\u003e(compute: () =\u003e T, options?: SignalOptions\u003cT\u003e) {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\t(currentComponent as AugmentedComponent)._updateFlags |= HAS_COMPUTEDS;\n\treturn useMemo(() =\u003e computed\u003cT\u003e(() =\u003e $compute.current(), options), []);\n}\n\nfunction safeRaf(callback: () =\u003e void) {\n\tconst done = () =\u003e {\n\t\tclearTimeout(timeout);\n\t\tcancelAnimationFrame(raf);\n\t\tcallback();\n\t};\n\n\tconst timeout = setTimeout(done, 35);\n\tconst raf = requestAnimationFrame(done);\n}\n\nconst deferEffects =\n\ttypeof requestAnimationFrame === \"undefined\" ? setTimeout : safeRaf;\n\nconst deferDomUpdates = (cb: any) =\u003e {\n\tqueueMicrotask(() =\u003e {\n\t\tqueueMicrotask(cb);\n\t});\n};\n\nfunction flushEffects() {\n\tbatch(() =\u003e {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = effectsQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyEffects(this: Effect) {\n\tif (effectsQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferEffects)(flushEffects);\n\t}\n}\n\nfunction flushDomUpdates() {\n\tbatch(() =\u003e {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = domQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyDomUpdates(this: Effect) {\n\tif (domQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferDomUpdates)(flushDomUpdates);\n\t}\n}\n\nexport function useSignalEffect(\n\tcb: () =\u003e void | (() =\u003e void),\n\toptions?: EffectOptions\n) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() =\u003e {\n\t\treturn effect(function (this: Effect) {\n\t\t\tthis._notify = notifyEffects;\n\t\t\treturn callback.current();\n\t\t}, options);\n\t}, []);\n}\n\n/** See comment in packages/core/src/index.ts on the same interface for an explanation */\ninterface InternalModelConstructor\u003c\n\tTModel,\n\tTArgs extends any[],\n\u003e extends ModelConstructor\u003cTModel, TArgs\u003e {\n\t(...args: TArgs): Model\u003cTModel\u003e;\n}\n\nexport function useModel\u003cTModel\u003e(\n\tfactory: ModelConstructor\u003cTModel, []\u003e | (() =\u003e Model\u003cTModel\u003e)\n): Model\u003cTModel\u003e {\n\ttype InternalFactory =\n\t\t| InternalModelConstructor\u003cTModel, []\u003e\n\t\t| (() =\u003e Model\u003cTModel\u003e);\n\n\tconst inst = useMemo(() =\u003e (factory as InternalFactory)(), []);\n\tuseEffect(() =\u003e inst[Symbol.dispose], [inst]);\n\treturn inst;\n}\n\n/**\n * @todo Determine which Reactive implementation we'll be using.\n * @internal\n */\n// export function useReactive\u003cT extends object\u003e(value: T): Reactive\u003cT\u003e {\n// \treturn useMemo(() =\u003e reactive\u003cT\u003e(value), []);\n// }\n\n/**\n * @internal\n * Update a Reactive's using the properties of an object or other Reactive.\n * Also works for Signals.\n * @example\n * // Update a Reactive with Object.assign()-like syntax:\n * const r = reactive({ name: \"Alice\" });\n * update(r, { name: \"Bob\" });\n * update(r, { age: 42 }); // property 'age' does not exist in type '{ name?: string }'\n * update(r, 2); // '2' has no properties in common with '{ name?: string }'\n * console.log(r.name.value); // \"Bob\"\n *\n * @example\n * // Update a Reactive with the properties of another Reactive:\n * const A = reactive({ name: \"Alice\" });\n * const B = reactive({ name: \"Bob\", age: 42 });\n * update(A, B);\n * console.log(`${A.name} is ${A.age}`); // \"Bob is 42\"\n *\n * @example\n * // Update a signal with assign()-like syntax:\n * const s = signal(42);\n * update(s, \"hi\"); // Argument type 'string' not assignable to type 'number'\n * update(s, {}); // Argument type '{}' not assignable to type 'number'\n * update(s, 43);\n * console.log(s.value); // 43\n *\n * @param obj The Reactive or Signal to be updated\n * @param update The value, Signal, object or Reactive to update `obj` to match\n * @param overwrite If `true`, any properties `obj` missing from `update` are set to `undefined`\n */\n/*\nexport function update\u003cT extends SignalOrReactive\u003e(\n\tobj: T,\n\tupdate: Partial\u003cUnwrap\u003cT\u003e\u003e,\n\toverwrite = false\n) {\n\tif (obj instanceof Signal) {\n\t\tobj.value = peekValue(update);\n\t} else {\n\t\tfor (let i in update) {\n\t\t\tif (i in obj) {\n\t\t\t\tobj[i].value = peekValue(update[i]);\n\t\t\t} else {\n\t\t\t\tlet sig = signal(peekValue(update[i]));\n\t\t\t\tsig[KEY] = i;\n\t\t\t\tobj[i] = sig;\n\t\t\t}\n\t\t}\n\t\tif (overwrite) {\n\t\t\tfor (let i in obj) {\n\t\t\t\tif (!(i in update)) {\n\t\t\t\t\tobj[i].value = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n*/\n"],"version":3}
+4
vendor/esm.sh/htm@3.1.1/X-ZXByZWFjdA/es2022/htm.mjs
··· 1 + /* esm.sh - htm@3.1.1 */ 2 + var a=function(p,f,c,n){var l;f[0]=0;for(var u=1;u<f.length;u++){var g=f[u++],o=f[u]?(f[0]|=g?1:2,c[f[u++]]):f[++u];g===3?n[0]=o:g===4?n[1]=Object.assign(n[1]||{},o):g===5?(n[1]=n[1]||{})[f[++u]]=o:g===6?n[1][f[++u]]+=o+"":g?(l=p.apply(o,a(p,o,c,["",null])),n.push(l),o[0]?f[0]|=2:(f[u-2]=0,f[u]=l)):n.push(o)}return n},M=new Map;function b(p){var f=M.get(this);return f||(f=new Map,M.set(this,f)),(f=a(this,f.get(p)||(f.set(p,f=(function(c){for(var n,l,u=1,g="",o="",i=[0],s=function(v){u===1&&(v||(g=g.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?i.push(0,v,g):u===3&&(v||g)?(i.push(3,v,g),u=2):u===2&&g==="..."&&v?i.push(4,v,0):u===2&&g&&!v?i.push(5,0,!0,g):u>=5&&((g||!v&&u===5)&&(i.push(u,0,g,l),u=6),v&&(i.push(u,v,0,l),u=6)),g=""},t=0;t<c.length;t++){t&&(u===1&&s(),s(t));for(var w=0;w<c[t].length;w++)n=c[t][w],u===1?n==="<"?(s(),i=[i],u=3):g+=n:u===4?g==="--"&&n===">"?(u=1,g=""):g=n+g[0]:o?n===o?o="":g+=n:n==='"'||n==="'"?o=n:n===">"?(s(),u=1):u&&(n==="="?(u=5,l=g,g=""):n==="/"&&(u<5||c[t][w+1]===">")?(s(),u===3&&(i=i[0]),u=i,(i=i[0]).push(2,0,u),u=0):n===" "||n===" "||n===` 3 + `||n==="\r"?(s(),u=2):g+=n),u===3&&g==="!--"&&(u=4,i=i[0])}return s(),i})(p)),f),arguments,[])).length>1?f:f[0]}export{b as default}; 4 + //# sourceMappingURL=./htm.mjs.map
+1
vendor/esm.sh/htm@3.1.1/X-ZXByZWFjdA/es2022/htm.mjs.map
··· 1 + {"mappings":";AAAA,IAAIA,EAAE,SAASC,EAAEC,EAAEC,EAAEC,EAAE,CAAC,IAAIC,EAAEH,EAAE,CAAC,EAAE,EAAE,QAAQI,EAAE,EAAEA,EAAEJ,EAAE,OAAOI,IAAI,CAAC,IAAIC,EAAEL,EAAEI,GAAG,EAAEE,EAAEN,EAAEI,CAAC,GAAGJ,EAAE,CAAC,GAAGK,EAAE,EAAE,EAAEJ,EAAED,EAAEI,GAAG,CAAC,GAAGJ,EAAE,EAAEI,CAAC,EAAMC,IAAJ,EAAMH,EAAE,CAAC,EAAEI,EAAMD,IAAJ,EAAMH,EAAE,CAAC,EAAE,OAAO,OAAOA,EAAE,CAAC,GAAG,CAAC,EAAEI,CAAC,E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e","u","h","p","a","htm_module_default","l"],"sources":["../esm/npm/htm@3.1.1/node_modules/htm/dist/htm.module.js"],"sourcesContent":["var n=function(t,s,r,e){var u;s[0]=0;for(var h=1;h\u003cs.length;h++){var p=s[h++],a=s[h]?(s[0]|=p?1:2,r[s[h++]]):s[++h];3===p?e[0]=a:4===p?e[1]=Object.assign(e[1]||{},a):5===p?(e[1]=e[1]||{})[s[++h]]=a:6===p?e[1][s[++h]]+=a+\"\":p?(u=t.apply(a,n(t,a,r,[\"\",null])),e.push(u),a[0]?s[0]|=2:(s[h-2]=0,s[h]=u)):e.push(a)}return e},t=new Map;export default function(s){var r=t.get(this);return r||(r=new Map,t.set(this,r)),(r=n(this,r.get(s)||(r.set(s,r=function(n){for(var t,s,r=1,e=\"\",u=\"\",h=[0],p=function(n){1===r\u0026\u0026(n||(e=e.replace(/^\\s*\\n\\s*|\\s*\\n\\s*$/g,\"\")))?h.push(0,n,e):3===r\u0026\u0026(n||e)?(h.push(3,n,e),r=2):2===r\u0026\u0026\"...\"===e\u0026\u0026n?h.push(4,n,0):2===r\u0026\u0026e\u0026\u0026!n?h.push(5,0,!0,e):r\u003e=5\u0026\u0026((e||!n\u0026\u00265===r)\u0026\u0026(h.push(r,0,e,s),r=6),n\u0026\u0026(h.push(r,n,0,s),r=6)),e=\"\"},a=0;a\u003cn.length;a++){a\u0026\u0026(1===r\u0026\u0026p(),p(a));for(var l=0;l\u003cn[a].length;l++)t=n[a][l],1===r?\"\u003c\"===t?(p(),h=[h],r=3):e+=t:4===r?\"--\"===e\u0026\u0026\"\u003e\"===t?(r=1,e=\"\"):e=t+e[0]:u?t===u?u=\"\":e+=t:'\"'===t||\"'\"===t?u=t:\"\u003e\"===t?(p(),r=1):r\u0026\u0026(\"=\"===t?(r=5,s=e,e=\"\"):\"/\"===t\u0026\u0026(r\u003c5||\"\u003e\"===n[a][l+1])?(p(),3===r\u0026\u0026(h=h[0]),r=h,(h=h[0]).push(2,0,r),r=0):\" \"===t||\"\\t\"===t||\"\\n\"===t||\"\\r\"===t?(p(),r=2):e+=t),3===r\u0026\u0026\"!--\"===e\u0026\u0026(r=4,h=h[0])}return p(),h}(s)),r),arguments,[])).length\u003e1?r:r[0]}\n"],"version":3}
+3
vendor/esm.sh/htm@3.1.1/X-ZXByZWFjdA/es2022/preact.mjs
··· 1 + /* esm.sh - htm@3.1.1/preact */ 2 + import{h as r}from"preact";import{h as d,render as f,Component as h}from"preact";import o from"./htm.mjs";var p=o.bind(r);export{h as Component,d as h,p as html,f as render}; 3 + //# sourceMappingURL=./preact.mjs.map
+1
vendor/esm.sh/htm@3.1.1/X-ZXByZWFjdA/es2022/preact.mjs.map
··· 1 + {"mappings":";AAAA,OAAO,KAAK,MAAiC,SAAS,OAAO,KAAAA,EAAE,UAAAC,EAAO,aAAAC,MAAc,SAAS,OAAOC,MAAM,YAAM,IAAIC,EAAED,EAAE,KAAK,CAAC","names":["h","render","Component","e","m"],"sources":["../esm/npm/htm@3.1.1/node_modules/htm/preact/index.module.js"],"sourcesContent":["import{h as r,Component as o,render as t}from\"preact\";export{h,render,Component}from\"preact\";import e from\"htm\";var m=e.bind(r);export{m as html};\n"],"version":3}
+3
vendor/esm.sh/nanoid@5.1.7/es2022/nanoid.mjs
··· 1 + /* esm.sh - nanoid@5.1.7 */ 2 + var o="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var u=t=>crypto.getRandomValues(new Uint8Array(t)),s=(t,e,l)=>{let n=(2<<Math.log2(t.length-1))-1,p=-~(1.6*n*e/t.length);return(h=e)=>{let r="";for(;;){let m=l(p),a=p|0;for(;a--;)if(r+=t[m[a]&n]||"",r.length>=h)return r}}},A=(t,e=21)=>s(t,e|0,u),g=(t=21)=>{let e="",l=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=o[l[t]&63];return e};export{A as customAlphabet,s as customRandom,g as nanoid,u as random,o as urlAlphabet}; 3 + //# sourceMappingURL=./nanoid.mjs.map
+1
vendor/esm.sh/nanoid@5.1.7/es2022/nanoid.mjs.map
··· 1 + {"mappings":";AAAO,IAAIA,EACT,mECEK,IAAIC,EAASC,GAAS,OAAO,gBAAgB,IAAI,WAAWA,CAAK,CAAC,EAC9DC,EAAe,CAACC,EAAUC,EAAaC,IAAc,CAC9D,IAAIC,GAAQ,GAAK,KAAK,KAAKH,EAAS,OAAS,CAAC,GAAK,EAC/CI,EAAO,CAAC,EAAG,IAAMD,EAAOF,EAAeD,EAAS,QACpD,MAAO,CAACK,EAAOJ,IAAgB,CAC7B,IAAIK,EAAK,GACT,OAAa,CACX,IAAIR,EAAQI,EAAUE,CAAI,EACtBG,EAAIH,EAAO,EACf,KAAOG,KAEL,GADAD,GAAMN,EAASF,EAAMS,CAAC,EAAIJ,CAAI,GAAK,GAC/BG,EAAG,QAAUD,EAAM,OAAOC,CAElC,CACF,CACF,EACWE,EAAiB,CAACR,EAAUK,EAAO,KAC5CN,EAAaC,EAAUK,EAAO,EAAGR,CAAM,EAC9BY,EAAS,CAACJ,EAAO,KAAO,CACjC,IAAIC,EAAK,GACLR,EAAQ,OAAO,gBAAgB,IAAI,WAAYO,GAAQ,CAAE,CAAC,EAC9D,KAAOA,KACLC,GAAMI,EAAkBZ,EAAMO,CAAI,EAAI,EAAE,EAE1C,OAAOC,CACT","names":["urlAlphabet","random","bytes","customRandom","alphabet","defaultSize","getRandom","mask","step","size","id","j","customAlphabet","nanoid","urlAlphabet"],"sources":["../esm/npm/nanoid@5.1.7/node_modules/nanoid/url-alphabet/index.js","../esm/npm/nanoid@5.1.7/node_modules/nanoid/index.browser.js"],"sourcesContent":["export let urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","/* @ts-self-types=\"./index.d.ts\" */\nimport { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes =\u003e crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) =\u003e {\n let mask = (2 \u003c\u003c Math.log2(alphabet.length - 1)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) =\u003e {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step | 0\n while (j--) {\n id += alphabet[bytes[j] \u0026 mask] || ''\n if (id.length \u003e= size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =\u003e\n customRandom(alphabet, size | 0, random)\nexport let nanoid = (size = 21) =\u003e {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += scopedUrlAlphabet[bytes[size] \u0026 63]\n }\n return id\n}\n"],"version":3}
+3
vendor/esm.sh/preact@10.29.1/es2022/hooks.mjs
··· 1 + /* esm.sh - preact@10.29.1/hooks */ 2 + import{options as V}from"./preact.mjs";var c,e,d,g,v=0,T=[],o=V,C=o.__b,A=o.__r,D=o.diffed,F=o.__c,k=o.unmount,q=o.__;function m(t,_){o.__h&&o.__h(e,t,v||_),v=0;var u=e.__H||(e.__H={__:[],__h:[]});return t>=u.__.length&&u.__.push({}),u.__[t]}function B(t){return v=1,I(E,t)}function I(t,_,u){var n=m(c++,2);if(n.t=t,!n.__c&&(n.__=[u?u(_):E(void 0,_),function(f){var a=n.__N?n.__N[0]:n.__[0],s=n.t(a,f);a!==s&&(n.__N=[s,n.__[1]],n.__c.setState({}))}],n.__c=e,!e.__f)){var i=function(f,a,s){if(!n.__c.__H)return!0;var h=n.__c.__H.__.filter(function(r){return r.__c});if(h.every(function(r){return!r.__N}))return!l||l.call(this,f,a,s);var b=n.__c.props!==f;return h.some(function(r){if(r.__N){var P=r.__[0];r.__=r.__N,r.__N=void 0,P!==r.__[0]&&(b=!0)}}),l&&l.call(this,f,a,s)||b};e.__f=!0;var l=e.shouldComponentUpdate,N=e.componentWillUpdate;e.componentWillUpdate=function(f,a,s){if(this.__e){var h=l;l=void 0,i(f,a,s),l=h}N&&N.call(this,f,a,s)},e.shouldComponentUpdate=i}return n.__N||n.__}function w(t,_){var u=m(c++,3);!o.__s&&y(u.__H,_)&&(u.__=t,u.u=_,e.__H.__h.push(u))}function R(t,_){var u=m(c++,4);!o.__s&&y(u.__H,_)&&(u.__=t,u.u=_,e.__h.push(u))}function z(t){return v=5,U(function(){return{current:t}},[])}function L(t,_,u){v=6,R(function(){if(typeof t=="function"){var n=t(_());return function(){t(null),n&&typeof n=="function"&&n()}}if(t)return t.current=_(),function(){return t.current=null}},u==null?u:u.concat(t))}function U(t,_){var u=m(c++,7);return y(u.__H,_)&&(u.__=t(),u.__H=_,u.__h=t),u.__}function M(t,_){return v=8,U(function(){return t},_)}function G(t){var _=e.context[t.__c],u=m(c++,9);return u.c=t,_?(u.__==null&&(u.__=!0,_.sub(e)),_.props.value):t.__}function J(t,_){o.useDebugValue&&o.useDebugValue(_?_(t):t)}function K(t){var _=m(c++,10),u=B();return _.__=t,e.componentDidCatch||(e.componentDidCatch=function(n,i){_.__&&_.__(n,i),u[1](n)}),[u[0],function(){u[1](void 0)}]}function O(){var t=m(c++,11);if(!t.__){for(var _=e.__v;_!==null&&!_.__m&&_.__!==null;)_=_.__;var u=_.__m||(_.__m=[0,0]);t.__="P"+u[0]+"-"+u[1]++}return t.__}function S(){for(var t;t=T.shift();){var _=t.__H;if(t.__P&&_)try{_.__h.some(p),_.__h.some(H),_.__h=[]}catch(u){_.__h=[],o.__e(u,t.__v)}}}o.__b=function(t){e=null,C&&C(t)},o.__=function(t,_){t&&_.__k&&_.__k.__m&&(t.__m=_.__k.__m),q&&q(t,_)},o.__r=function(t){A&&A(t),c=0;var _=(e=t.__c).__H;_&&(d===e?(_.__h=[],e.__h=[],_.__.some(function(u){u.__N&&(u.__=u.__N),u.u=u.__N=void 0})):(_.__h.some(p),_.__h.some(H),_.__h=[],c=0)),d=e},o.diffed=function(t){D&&D(t);var _=t.__c;_&&_.__H&&(_.__H.__h.length&&(T.push(_)!==1&&g===o.requestAnimationFrame||((g=o.requestAnimationFrame)||W)(S)),_.__H.__.some(function(u){u.u&&(u.__H=u.u),u.u=void 0})),d=e=null},o.__c=function(t,_){_.some(function(u){try{u.__h.some(p),u.__h=u.__h.filter(function(n){return!n.__||H(n)})}catch(n){_.some(function(i){i.__h&&(i.__h=[])}),_=[],o.__e(n,u.__v)}}),F&&F(t,_)},o.unmount=function(t){k&&k(t);var _,u=t.__c;u&&u.__H&&(u.__H.__.some(function(n){try{p(n)}catch(i){_=i}}),u.__H=void 0,_&&o.__e(_,u.__v))};var x=typeof requestAnimationFrame=="function";function W(t){var _,u=function(){clearTimeout(n),x&&cancelAnimationFrame(_),setTimeout(t)},n=setTimeout(u,35);x&&(_=requestAnimationFrame(u))}function p(t){var _=e,u=t.__c;typeof u=="function"&&(t.__c=void 0,u()),e=_}function H(t){var _=e;t.__c=t.__(),e=_}function y(t,_){return!t||t.length!==_.length||_.some(function(u,n){return u!==t[n]})}function E(t,_){return typeof _=="function"?_(t):_}export{M as useCallback,G as useContext,J as useDebugValue,w as useEffect,K as useErrorBoundary,O as useId,L as useImperativeHandle,R as useLayoutEffect,U as useMemo,I as useReducer,z as useRef,B as useState}; 3 + //# sourceMappingURL=./hooks.mjs.map
+1
vendor/esm.sh/preact@10.29.1/es2022/hooks.mjs.map
··· 1 + {"mappings":";uCAGA,IAAIA,EAGAC,EAGAC,EAsBAC,EAnBAC,EAAc,EAGdC,EAAoB,CAAA,EAGlBC,EAAuDC,EAEzDC,EAAgBF,EAAOG,IACvBC,EAAkBJ,EAAOK,IACzBC,EAAeN,EAAQO,OACvBC,EAAYR,EAAOS,IACnBC,EAAmBV,EAAQW,QAC3BC,EAAUZ,EAAOa,GAiHrB,SAASC,EAAaC,EAAOC,EAAAA,CACxBhB,EAAOiB,KACVjB,EAAOiB,IAAOtB,EAAkBoB,EAAOjB,GAAekB,CAAAA,EAEvDlB,EAAc,EAOd,IAAMoB,EACLvB,EAAgBwB,MACfxB,EAAgBwB,IAAW,CAC3BN,GAA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AQnG,SAAWoG,EAAQpG,QAC3BoG,EAAQvE,KAAK,SAACwE,EAAK1G,EAAAA,CAAU,OAAA0G,IAAQF,EAAQxG,CAAAA,CAAM,CAAA,CAErD,CAQA,SAASU,EAAegG,EAAKC,EAAAA,CAC5B,OAAmB,OAALA,GAAK,WAAaA,EAAED,CAAAA,EAAOC,CAC1C","names":["currentIndex","currentComponent","previousComponent","prevRaf","currentHook","afterPaintEffects","options","_options","oldBeforeDiff","__b","oldBeforeRender","__r","oldAfterDiff","diffed","oldCommit","__c","oldBeforeUnmount","unmount","oldRoot","__","getHookState","index","type","__h","hooks","__H","length","push","useState","initialState","useReducer","invokeOrReturn","reducer","init","hookState","_reducer","action","currentValue","__N","nextValue","setState","__f","updateHookState","p","s","c","stateHooks","filter","x","every","prevScu","call","this","shouldUpdate","props","some","hookItem","shouldComponentUpdate","prevCWU","componentWillUpdate","__e","tmp","useEffect","callback","args","state","__s","argsChanged","_pendingArgs","useLayoutEffect","useRef","initialValue","useMemo","current","useImperativeHandle","ref","createHandle","result","concat","factory","useCallback","useContext","context","provider","sub","value","useDebugValue","formatter","n","useErrorBoundary","cb","errState","componentDidCatch","err","errorInfo","undefined","useId","root","__v","__m","mask","flushAfterPaintEffects","component","shift","__P","invokeCleanup","invokeEffect","e","vnode","parentDom","__k","requestAnimationFrame","afterNextFrame","commitQueue","hasErrored","HAS_RAF","raf","done","clearTimeout","timeout","cancelAnimationFrame","setTimeout","hook","comp","cleanup","oldArgs","newArgs","arg","f"],"sources":["../esm/npm/preact@10.29.1/node_modules/preact/hooks/src/index.js"],"sourcesContent":["import { options as _options } from 'preact';\n\n/** @type {number} */\nlet currentIndex;\n\n/** @type {import('./internal').Component} */\nlet currentComponent;\n\n/** @type {import('./internal').Component} */\nlet previousComponent;\n\n/** @type {number} */\nlet currentHook = 0;\n\n/** @type {Array\u003cimport('./internal').Component\u003e} */\nlet afterPaintEffects = [];\n\n// Cast to use internal Options type\nconst options = /** @type {import('./internal').Options} */ (_options);\n\nlet oldBeforeDiff = options._diff;\nlet oldBeforeRender = options._render;\nlet oldAfterDiff = options.diffed;\nlet oldCommit = options._commit;\nlet oldBeforeUnmount = options.unmount;\nlet oldRoot = options._root;\n\n// We take the minimum timeout for requestAnimationFrame to ensure that\n// the callback is invoked after the next frame. 35ms is based on a 30hz\n// refresh rate, which is the minimum rate for a smooth user experience.\nconst RAF_TIMEOUT = 35;\nlet prevRaf;\n\n/** @type {(vnode: import('./internal').VNode) =\u003e void} */\noptions._diff = vnode =\u003e {\n\tcurrentComponent = null;\n\tif (oldBeforeDiff) oldBeforeDiff(vnode);\n};\n\noptions._root = (vnode, parentDom) =\u003e {\n\tif (vnode \u0026\u0026 parentDom._children \u0026\u0026 parentDom._children._mask) {\n\t\tvnode._mask = parentDom._children._mask;\n\t}\n\n\tif (oldRoot) oldRoot(vnode, parentDom);\n};\n\n/** @type {(vnode: import('./internal').VNode) =\u003e void} */\noptions._render = vnode =\u003e {\n\tif (oldBeforeRender) oldBeforeRender(vnode);\n\n\tcurrentComponent = vnode._component;\n\tcurrentIndex = 0;\n\n\tconst hooks = currentComponent.__hooks;\n\tif (hooks) {\n\t\tif (previousComponent === currentComponent) {\n\t\t\thooks._pendingEffects = [];\n\t\t\tcurrentComponent._renderCallbacks = [];\n\t\t\thooks._list.some(hookItem =\u003e {\n\t\t\t\tif (hookItem._nextValue) {\n\t\t\t\t\thookItem._value = hookItem._nextValue;\n\t\t\t\t}\n\t\t\t\thookItem._pendingArgs = hookItem._nextValue = undefined;\n\t\t\t});\n\t\t} else {\n\t\t\thooks._pendingEffects.some(invokeCleanup);\n\t\t\thooks._pendingEffects.some(invokeEffect);\n\t\t\thooks._pendingEffects = [];\n\t\t\tcurrentIndex = 0;\n\t\t}\n\t}\n\tpreviousComponent = currentComponent;\n};\n\n/** @type {(vnode: import('./internal').VNode) =\u003e void} */\noptions.diffed = vnode =\u003e {\n\tif (oldAfterDiff) oldAfterDiff(vnode);\n\n\tconst c = vnode._component;\n\tif (c \u0026\u0026 c.__hooks) {\n\t\tif (c.__hooks._pendingEffects.length) afterPaint(afterPaintEffects.push(c));\n\t\tc.__hooks._list.some(hookItem =\u003e {\n\t\t\tif (hookItem._pendingArgs) {\n\t\t\t\thookItem._args = hookItem._pendingArgs;\n\t\t\t}\n\t\t\thookItem._pendingArgs = undefined;\n\t\t});\n\t}\n\tpreviousComponent = currentComponent = null;\n};\n\n// TODO: Improve typing of commitQueue parameter\n/** @type {(vnode: import('./internal').VNode, commitQueue: any) =\u003e void} */\noptions._commit = (vnode, commitQueue) =\u003e {\n\tcommitQueue.some(component =\u003e {\n\t\ttry {\n\t\t\tcomponent._renderCallbacks.some(invokeCleanup);\n\t\t\tcomponent._renderCallbacks = component._renderCallbacks.filter(cb =\u003e\n\t\t\t\tcb._value ? invokeEffect(cb) : true\n\t\t\t);\n\t\t} catch (e) {\n\t\t\tcommitQueue.some(c =\u003e {\n\t\t\t\tif (c._renderCallbacks) c._renderCallbacks = [];\n\t\t\t});\n\t\t\tcommitQueue = [];\n\t\t\toptions._catchError(e, component._vnode);\n\t\t}\n\t});\n\n\tif (oldCommit) oldCommit(vnode, commitQueue);\n};\n\n/** @type {(vnode: import('./internal').VNode) =\u003e void} */\noptions.unmount = vnode =\u003e {\n\tif (oldBeforeUnmount) oldBeforeUnmount(vnode);\n\n\tconst c = vnode._component;\n\tif (c \u0026\u0026 c.__hooks) {\n\t\tlet hasErrored;\n\t\tc.__hooks._list.some(s =\u003e {\n\t\t\ttry {\n\t\t\t\tinvokeCleanup(s);\n\t\t\t} catch (e) {\n\t\t\t\thasErrored = e;\n\t\t\t}\n\t\t});\n\t\tc.__hooks = undefined;\n\t\tif (hasErrored) options._catchError(hasErrored, c._vnode);\n\t}\n};\n\n/**\n * Get a hook's state from the currentComponent\n * @param {number} index The index of the hook to get\n * @param {number} type The index of the hook to get\n * @returns {any}\n */\nfunction getHookState(index, type) {\n\tif (options._hook) {\n\t\toptions._hook(currentComponent, index, currentHook || type);\n\t}\n\tcurrentHook = 0;\n\n\t// Largely inspired by:\n\t// * https://github.com/michael-klein/funcy.js/blob/f6be73468e6ec46b0ff5aa3cc4c9baf72a29025a/src/hooks/core_hooks.mjs\n\t// * https://github.com/michael-klein/funcy.js/blob/650beaa58c43c33a74820a3c98b3c7079cf2e333/src/renderer.mjs\n\t// Other implementations to look at:\n\t// * https://codesandbox.io/s/mnox05qp8\n\tconst hooks =\n\t\tcurrentComponent.__hooks ||\n\t\t(currentComponent.__hooks = {\n\t\t\t_list: [],\n\t\t\t_pendingEffects: []\n\t\t});\n\n\tif (index \u003e= hooks._list.length) {\n\t\thooks._list.push({});\n\t}\n\n\treturn hooks._list[index];\n}\n\n/**\n * @template {unknown} S\n * @param {import('./index').Dispatch\u003cimport('./index').StateUpdater\u003cS\u003e\u003e} [initialState]\n * @returns {[S, (state: S) =\u003e void]}\n */\nexport function useState(initialState) {\n\tcurrentHook = 1;\n\treturn useReducer(invokeOrReturn, initialState);\n}\n\n/**\n * @template {unknown} S\n * @template {unknown} A\n * @param {import('./index').Reducer\u003cS, A\u003e} reducer\n * @param {import('./index').Dispatch\u003cimport('./index').StateUpdater\u003cS\u003e\u003e} initialState\n * @param {(initialState: any) =\u003e void} [init]\n * @returns {[ S, (state: S) =\u003e void ]}\n */\nexport function useReducer(reducer, initialState, init) {\n\t/** @type {import('./internal').ReducerHookState} */\n\tconst hookState = getHookState(currentIndex++, 2);\n\thookState._reducer = reducer;\n\tif (!hookState._component) {\n\t\thookState._value = [\n\t\t\t!init ? invokeOrReturn(undefined, initialState) : init(initialState),\n\n\t\t\taction =\u003e {\n\t\t\t\tconst currentValue = hookState._nextValue\n\t\t\t\t\t? hookState._nextValue[0]\n\t\t\t\t\t: hookState._value[0];\n\t\t\t\tconst nextValue = hookState._reducer(currentValue, action);\n\n\t\t\t\tif (currentValue !== nextValue) {\n\t\t\t\t\thookState._nextValue = [nextValue, hookState._value[1]];\n\t\t\t\t\thookState._component.setState({});\n\t\t\t\t}\n\t\t\t}\n\t\t];\n\n\t\thookState._component = currentComponent;\n\n\t\tif (!currentComponent._hasScuFromHooks) {\n\t\t\tcurrentComponent._hasScuFromHooks = true;\n\t\t\tlet prevScu = currentComponent.shouldComponentUpdate;\n\t\t\tconst prevCWU = currentComponent.componentWillUpdate;\n\n\t\t\t// If we're dealing with a forced update `shouldComponentUpdate` will\n\t\t\t// not be called. But we use that to update the hook values, so we\n\t\t\t// need to call it.\n\t\t\tcurrentComponent.componentWillUpdate = function (p, s, c) {\n\t\t\t\tif (this._force) {\n\t\t\t\t\tlet tmp = prevScu;\n\t\t\t\t\t// Clear to avoid other sCU hooks from being called\n\t\t\t\t\tprevScu = undefined;\n\t\t\t\t\tupdateHookState(p, s, c);\n\t\t\t\t\tprevScu = tmp;\n\t\t\t\t}\n\n\t\t\t\tif (prevCWU) prevCWU.call(this, p, s, c);\n\t\t\t};\n\n\t\t\t// This SCU has the purpose of bailing out after repeated updates\n\t\t\t// to stateful hooks.\n\t\t\t// we store the next value in _nextValue[0] and keep doing that for all\n\t\t\t// state setters, if we have next states and\n\t\t\t// all next states within a component end up being equal to their original state\n\t\t\t// we are safe to bail out for this specific component.\n\t\t\t/**\n\t\t\t *\n\t\t\t * @type {import('./internal').Component[\"shouldComponentUpdate\"]}\n\t\t\t */\n\t\t\t// @ts-ignore - We don't use TS to downtranspile\n\t\t\t// eslint-disable-next-line no-inner-declarations\n\t\t\tfunction updateHookState(p, s, c) {\n\t\t\t\tif (!hookState._component.__hooks) return true;\n\n\t\t\t\tconst stateHooks = hookState._component.__hooks._list.filter(\n\t\t\t\t\tx =\u003e x._component\n\t\t\t\t);\n\n\t\t\t\tconst allHooksEmpty = stateHooks.every(x =\u003e !x._nextValue);\n\t\t\t\t// When we have no updated hooks in the component we invoke the previous SCU or\n\t\t\t\t// traverse the VDOM tree further.\n\t\t\t\tif (allHooksEmpty) {\n\t\t\t\t\treturn prevScu ? prevScu.call(this, p, s, c) : true;\n\t\t\t\t}\n\n\t\t\t\t// We check whether we have components with a nextValue set that\n\t\t\t\t// have values that aren't equal to one another this pushes\n\t\t\t\t// us to update further down the tree\n\t\t\t\tlet shouldUpdate = hookState._component.props !== p;\n\t\t\t\tstateHooks.some(hookItem =\u003e {\n\t\t\t\t\tif (hookItem._nextValue) {\n\t\t\t\t\t\tconst currentValue = hookItem._value[0];\n\t\t\t\t\t\thookItem._value = hookItem._nextValue;\n\t\t\t\t\t\thookItem._nextValue = undefined;\n\t\t\t\t\t\tif (currentValue !== hookItem._value[0]) shouldUpdate = true;\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\treturn prevScu\n\t\t\t\t\t? prevScu.call(this, p, s, c) || shouldUpdate\n\t\t\t\t\t: shouldUpdate;\n\t\t\t}\n\n\t\t\tcurrentComponent.shouldComponentUpdate = updateHookState;\n\t\t}\n\t}\n\n\treturn hookState._nextValue || hookState._value;\n}\n\n/**\n * @param {import('./internal').Effect} callback\n * @param {unknown[]} args\n * @returns {void}\n */\nexport function useEffect(callback, args) {\n\t/** @type {import('./internal').EffectHookState} */\n\tconst state = getHookState(currentIndex++, 3);\n\tif (!options._skipEffects \u0026\u0026 argsChanged(state._args, args)) {\n\t\tstate._value = callback;\n\t\tstate._pendingArgs = args;\n\n\t\tcurrentComponent.__hooks._pendingEffects.push(state);\n\t}\n}\n\n/**\n * @param {import('./internal').Effect} callback\n * @param {unknown[]} args\n * @returns {void}\n */\nexport function useLayoutEffect(callback, args) {\n\t/** @type {import('./internal').EffectHookState} */\n\tconst state = getHookState(currentIndex++, 4);\n\tif (!options._skipEffects \u0026\u0026 argsChanged(state._args, args)) {\n\t\tstate._value = callback;\n\t\tstate._pendingArgs = args;\n\n\t\tcurrentComponent._renderCallbacks.push(state);\n\t}\n}\n\n/** @type {(initialValue: unknown) =\u003e unknown} */\nexport function useRef(initialValue) {\n\tcurrentHook = 5;\n\treturn useMemo(() =\u003e ({ current: initialValue }), []);\n}\n\n/**\n * @param {object} ref\n * @param {() =\u003e object} createHandle\n * @param {unknown[]} args\n * @returns {void}\n */\nexport function useImperativeHandle(ref, createHandle, args) {\n\tcurrentHook = 6;\n\tuseLayoutEffect(\n\t\t() =\u003e {\n\t\t\tif (typeof ref == 'function') {\n\t\t\t\tconst result = ref(createHandle());\n\t\t\t\treturn () =\u003e {\n\t\t\t\t\tref(null);\n\t\t\t\t\tif (result \u0026\u0026 typeof result == 'function') result();\n\t\t\t\t};\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = createHandle();\n\t\t\t\treturn () =\u003e (ref.current = null);\n\t\t\t}\n\t\t},\n\t\targs == null ? args : args.concat(ref)\n\t);\n}\n\n/**\n * @template {unknown} T\n * @param {() =\u003e T} factory\n * @param {unknown[]} args\n * @returns {T}\n */\nexport function useMemo(factory, args) {\n\t/** @type {import('./internal').MemoHookState\u003cT\u003e} */\n\tconst state = getHookState(currentIndex++, 7);\n\tif (argsChanged(state._args, args)) {\n\t\tstate._value = factory();\n\t\tstate._args = args;\n\t\tstate._factory = factory;\n\t}\n\n\treturn state._value;\n}\n\n/**\n * @param {() =\u003e void} callback\n * @param {unknown[]} args\n * @returns {() =\u003e void}\n */\nexport function useCallback(callback, args) {\n\tcurrentHook = 8;\n\treturn useMemo(() =\u003e callback, args);\n}\n\n/**\n * @param {import('./internal').PreactContext} context\n */\nexport function useContext(context) {\n\tconst provider = currentComponent.context[context._id];\n\t// We could skip this call here, but than we'd not call\n\t// `options._hook`. We need to do that in order to make\n\t// the devtools aware of this hook.\n\t/** @type {import('./internal').ContextHookState} */\n\tconst state = getHookState(currentIndex++, 9);\n\t// The devtools needs access to the context object to\n\t// be able to pull of the default value when no provider\n\t// is present in the tree.\n\tstate._context = context;\n\tif (!provider) return context._defaultValue;\n\t// This is probably not safe to convert to \"!\"\n\tif (state._value == null) {\n\t\tstate._value = true;\n\t\tprovider.sub(currentComponent);\n\t}\n\treturn provider.props.value;\n}\n\n/**\n * Display a custom label for a custom hook for the devtools panel\n * @type {\u003cT\u003e(value: T, cb?: (value: T) =\u003e string | number) =\u003e void}\n */\nexport function useDebugValue(value, formatter) {\n\tif (options.useDebugValue) {\n\t\toptions.useDebugValue(\n\t\t\tformatter ? formatter(value) : /** @type {any}*/ (value)\n\t\t);\n\t}\n}\n\n/**\n * @param {(error: unknown, errorInfo: import('preact').ErrorInfo) =\u003e void} cb\n * @returns {[unknown, () =\u003e void]}\n */\nexport function useErrorBoundary(cb) {\n\t/** @type {import('./internal').ErrorBoundaryHookState} */\n\tconst state = getHookState(currentIndex++, 10);\n\tconst errState = useState();\n\tstate._value = cb;\n\tif (!currentComponent.componentDidCatch) {\n\t\tcurrentComponent.componentDidCatch = (err, errorInfo) =\u003e {\n\t\t\tif (state._value) state._value(err, errorInfo);\n\t\t\terrState[1](err);\n\t\t};\n\t}\n\treturn [\n\t\terrState[0],\n\t\t() =\u003e {\n\t\t\terrState[1](undefined);\n\t\t}\n\t];\n}\n\n/** @type {() =\u003e string} */\nexport function useId() {\n\t/** @type {import('./internal').IdHookState} */\n\tconst state = getHookState(currentIndex++, 11);\n\tif (!state._value) {\n\t\t// Grab either the root node or the nearest async boundary node.\n\t\t/** @type {import('./internal').VNode} */\n\t\tlet root = currentComponent._vnode;\n\t\twhile (root !== null \u0026\u0026 !root._mask \u0026\u0026 root._parent !== null) {\n\t\t\troot = root._parent;\n\t\t}\n\n\t\tlet mask = root._mask || (root._mask = [0, 0]);\n\t\tstate._value = 'P' + mask[0] + '-' + mask[1]++;\n\t}\n\n\treturn state._value;\n}\n\n/**\n * After paint effects consumer.\n */\nfunction flushAfterPaintEffects() {\n\tlet component;\n\twhile ((component = afterPaintEffects.shift())) {\n\t\tconst hooks = component.__hooks;\n\t\tif (!component._parentDom || !hooks) continue;\n\t\ttry {\n\t\t\thooks._pendingEffects.some(invokeCleanup);\n\t\t\thooks._pendingEffects.some(invokeEffect);\n\t\t\thooks._pendingEffects = [];\n\t\t} catch (e) {\n\t\t\thooks._pendingEffects = [];\n\t\t\toptions._catchError(e, component._vnode);\n\t\t}\n\t}\n}\n\nlet HAS_RAF = typeof requestAnimationFrame == 'function';\n\n/**\n * Schedule a callback to be invoked after the browser has a chance to paint a new frame.\n * Do this by combining requestAnimationFrame (rAF) + setTimeout to invoke a callback after\n * the next browser frame.\n *\n * Also, schedule a timeout in parallel to the the rAF to ensure the callback is invoked\n * even if RAF doesn't fire (for example if the browser tab is not visible)\n *\n * @param {() =\u003e void} callback\n */\nfunction afterNextFrame(callback) {\n\tconst done = () =\u003e {\n\t\tclearTimeout(timeout);\n\t\tif (HAS_RAF) cancelAnimationFrame(raf);\n\t\tsetTimeout(callback);\n\t};\n\tconst timeout = setTimeout(done, RAF_TIMEOUT);\n\n\tlet raf;\n\tif (HAS_RAF) {\n\t\traf = requestAnimationFrame(done);\n\t}\n}\n\n// Note: if someone used options.debounceRendering = requestAnimationFrame,\n// then effects will ALWAYS run on the NEXT frame instead of the current one, incurring a ~16ms delay.\n// Perhaps this is not such a big deal.\n/**\n * Schedule afterPaintEffects flush after the browser paints\n * @param {number} newQueueLength\n * @returns {void}\n */\nfunction afterPaint(newQueueLength) {\n\tif (newQueueLength === 1 || prevRaf !== options.requestAnimationFrame) {\n\t\tprevRaf = options.requestAnimationFrame;\n\t\t(prevRaf || afterNextFrame)(flushAfterPaintEffects);\n\t}\n}\n\n/**\n * @param {import('./internal').HookState} hook\n * @returns {void}\n */\nfunction invokeCleanup(hook) {\n\t// A hook cleanup can introduce a call to render which creates a new root, this will call options.vnode\n\t// and move the currentComponent away.\n\tconst comp = currentComponent;\n\tlet cleanup = hook._cleanup;\n\tif (typeof cleanup == 'function') {\n\t\thook._cleanup = undefined;\n\t\tcleanup();\n\t}\n\n\tcurrentComponent = comp;\n}\n\n/**\n * Invoke a Hook's effect\n * @param {import('./internal').EffectHookState} hook\n * @returns {void}\n */\nfunction invokeEffect(hook) {\n\t// A hook call can introduce a call to render which creates a new root, this will call options.vnode\n\t// and move the currentComponent away.\n\tconst comp = currentComponent;\n\thook._cleanup = hook._value();\n\tcurrentComponent = comp;\n}\n\n/**\n * @param {unknown[]} oldArgs\n * @param {unknown[]} newArgs\n * @returns {boolean}\n */\nfunction argsChanged(oldArgs, newArgs) {\n\treturn (\n\t\t!oldArgs ||\n\t\toldArgs.length !== newArgs.length ||\n\t\tnewArgs.some((arg, index) =\u003e arg !== oldArgs[index])\n\t);\n}\n\n/**\n * @template Arg\n * @param {Arg} arg\n * @param {(arg: Arg) =\u003e any} f\n * @returns {any}\n */\nfunction invokeOrReturn(arg, f) {\n\treturn typeof f == 'function' ? f(arg) : f;\n}\n"],"version":3}
+3
vendor/esm.sh/preact@10.29.1/es2022/preact.mjs
··· 1 + /* esm.sh - preact@10.29.1 */ 2 + var E,v,ee,pe,x,X,_e,te,B,F,T,ne,q,O,j,re,N={},H=[],fe=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,D=Array.isArray;function b(_,e){for(var t in e)_[t]=e[t];return _}function G(_){_&&_.parentNode&&_.parentNode.removeChild(_)}function ae(_,e,t){var o,l,n,i={};for(n in e)n=="key"?o=e[n]:n=="ref"?l=e[n]:i[n]=e[n];if(arguments.length>2&&(i.children=arguments.length>3?E.call(arguments,2):t),typeof _=="function"&&_.defaultProps!=null)for(n in _.defaultProps)i[n]===void 0&&(i[n]=_.defaultProps[n]);return M(_,i,o,l,null)}function M(_,e,t,o,l){var n={type:_,props:e,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:l??++ee,__i:-1,__u:0};return l==null&&v.vnode!=null&&v.vnode(n),n}function we(){return{current:null}}function R(_){return _.children}function L(_,e){this.props=_,this.context=e}function S(_,e){if(e==null)return _.__?S(_.__,_.__i+1):null;for(var t;e<_.__k.length;e++)if((t=_.__k[e])!=null&&t.__e!=null)return t.__e;return typeof _.type=="function"?S(_):null}function he(_){if(_.__P&&_.__d){var e=_.__v,t=e.__e,o=[],l=[],n=b({},e);n.__v=e.__v+1,v.vnode&&v.vnode(n),J(_.__P,n,e,_.__n,_.__P.namespaceURI,32&e.__u?[t]:null,o,t??S(e),!!(32&e.__u),l),n.__v=e.__v,n.__.__k[n.__i]=n,se(o,n,l),e.__e=e.__=null,n.__e!=t&&oe(n)}}function oe(_){if((_=_.__)!=null&&_.__c!=null)return _.__e=_.__c.base=null,_.__k.some(function(e){if(e!=null&&e.__e!=null)return _.__e=_.__c.base=e.__e}),oe(_)}function V(_){(!_.__d&&(_.__d=!0)&&x.push(_)&&!I.__r++||X!=v.debounceRendering)&&((X=v.debounceRendering)||_e)(I)}function I(){try{for(var _,e=1;x.length;)x.length>e&&x.sort(te),_=x.shift(),e=x.length,he(_)}finally{x.length=I.__r=0}}function le(_,e,t,o,l,n,i,c,f,s,p){var r,d,u,y,g,m,a,h=o&&o.__k||H,w=e.length;for(f=de(t,e,h,f,w),r=0;r<w;r++)(u=t.__k[r])!=null&&(d=u.__i!=-1&&h[u.__i]||N,u.__i=r,m=J(_,u,d,l,n,i,c,f,s,p),y=u.__e,u.ref&&d.ref!=u.ref&&(d.ref&&K(d.ref,null,u),p.push(u.ref,u.__c||y,u)),g==null&&y!=null&&(g=y),(a=!!(4&u.__u))||d.__k===u.__k?(f=ie(u,f,_,a),a&&d.__e&&(d.__e=null)):typeof u.type=="function"&&m!==void 0?f=m:y&&(f=y.nextSibling),u.__u&=-7);return t.__e=g,f}function de(_,e,t,o,l){var n,i,c,f,s,p=t.length,r=p,d=0;for(_.__k=new Array(l),n=0;n<l;n++)(i=e[n])!=null&&typeof i!="boolean"&&typeof i!="function"?(typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?i=_.__k[n]=M(null,i,null,null,null):D(i)?i=_.__k[n]=M(R,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?i=_.__k[n]=M(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):_.__k[n]=i,f=n+d,i.__=_,i.__b=_.__b+1,c=null,(s=i.__i=ye(i,t,f,r))!=-1&&(r--,(c=t[s])&&(c.__u|=2)),c==null||c.__v==null?(s==-1&&(l>p?d--:l<p&&d++),typeof i.type!="function"&&(i.__u|=4)):s!=f&&(s==f-1?d--:s==f+1?d++:(s>f?d--:d++,i.__u|=4))):_.__k[n]=null;if(r)for(n=0;n<p;n++)(c=t[n])!=null&&(2&c.__u)==0&&(c.__e==o&&(o=S(c)),ue(c,c));return o}function ie(_,e,t,o){var l,n;if(typeof _.type=="function"){for(l=_.__k,n=0;l&&n<l.length;n++)l[n]&&(l[n].__=_,e=ie(l[n],e,t,o));return e}_.__e!=e&&(o&&(e&&_.type&&!e.parentNode&&(e=S(_)),t.insertBefore(_.__e,e||null)),e=_.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ve(_,e){return e=e||[],_==null||typeof _=="boolean"||(D(_)?_.some(function(t){ve(t,e)}):e.push(_)),e}function ye(_,e,t,o){var l,n,i,c=_.key,f=_.type,s=e[t],p=s!=null&&(2&s.__u)==0;if(s===null&&c==null||p&&c==s.key&&f==s.type)return t;if(o>(p?1:0)){for(l=t-1,n=t+1;l>=0||n<e.length;)if((s=e[i=l>=0?l--:n++])!=null&&(2&s.__u)==0&&c==s.key&&f==s.type)return i}return-1}function Y(_,e,t){e[0]=="-"?_.setProperty(e,t??""):_[e]=t==null?"":typeof t!="number"||fe.test(e)?t:t+"px"}function A(_,e,t,o,l){var n,i;e:if(e=="style")if(typeof t=="string")_.style.cssText=t;else{if(typeof o=="string"&&(_.style.cssText=o=""),o)for(e in o)t&&e in t||Y(_.style,e,"");if(t)for(e in t)o&&t[e]==o[e]||Y(_.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")n=e!=(e=e.replace(ne,"$1")),i=e.toLowerCase(),e=i in _||e=="onFocusOut"||e=="onFocusIn"?i.slice(2):e.slice(2),_.l||(_.l={}),_.l[e+n]=t,t?o?t[T]=o[T]:(t[T]=q,_.addEventListener(e,n?j:O,n)):_.removeEventListener(e,n?j:O,n);else{if(l=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in _)try{_[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?_.removeAttribute(e):_.setAttribute(e,e=="popover"&&t==1?"":t))}}function Z(_){return function(e){if(this.l){var t=this.l[e.type+_];if(e[F]==null)e[F]=q++;else if(e[F]<t[T])return;return t(v.event?v.event(e):e)}}}function J(_,e,t,o,l,n,i,c,f,s){var p,r,d,u,y,g,m,a,h,w,C,U,Q,W,$,k=e.type;if(e.constructor!==void 0)return null;128&t.__u&&(f=!!(32&t.__u),n=[c=e.__e=t.__e]),(p=v.__b)&&p(e);e:if(typeof k=="function")try{if(a=e.props,h=k.prototype&&k.prototype.render,w=(p=k.contextType)&&o[p.__c],C=p?w?w.props.value:p.__:o,t.__c?m=(r=e.__c=t.__c).__=r.__E:(h?e.__c=r=new k(a,C):(e.__c=r=new L(a,C),r.constructor=k,r.render=ge),w&&w.sub(r),r.state||(r.state={}),r.__n=o,d=r.__d=!0,r.__h=[],r._sb=[]),h&&r.__s==null&&(r.__s=r.state),h&&k.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=b({},r.__s)),b(r.__s,k.getDerivedStateFromProps(a,r.__s))),u=r.props,y=r.state,r.__v=e,d)h&&k.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),h&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(h&&k.getDerivedStateFromProps==null&&a!==u&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(a,C),e.__v==t.__v||!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(a,r.__s,C)===!1){e.__v!=t.__v&&(r.props=a,r.state=r.__s,r.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.some(function(P){P&&(P.__=e)}),H.push.apply(r.__h,r._sb),r._sb=[],r.__h.length&&i.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(a,r.__s,C),h&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(u,y,g)})}if(r.context=C,r.props=a,r.__P=_,r.__e=!1,U=v.__r,Q=0,h)r.state=r.__s,r.__d=!1,U&&U(e),p=r.render(r.props,r.state,r.context),H.push.apply(r.__h,r._sb),r._sb=[];else do r.__d=!1,U&&U(e),p=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++Q<25);r.state=r.__s,r.getChildContext!=null&&(o=b(b({},o),r.getChildContext())),h&&!d&&r.getSnapshotBeforeUpdate!=null&&(g=r.getSnapshotBeforeUpdate(u,y)),W=p!=null&&p.type===R&&p.key==null?ce(p.props.children):p,c=le(_,D(W)?W:[W],e,t,o,l,n,i,c,f,s),r.base=e.__e,e.__u&=-161,r.__h.length&&i.push(r),m&&(r.__E=r.__=null)}catch(P){if(e.__v=null,f||n!=null)if(P.then){for(e.__u|=f?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;n[n.indexOf(c)]=null,e.__e=c}else{for($=n.length;$--;)G(n[$]);z(e)}else e.__e=t.__e,e.__k=t.__k,P.then||z(e);v.__e(P,e,t)}else n==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):c=e.__e=me(t.__e,e,t,o,l,n,i,f,s);return(p=v.diffed)&&p(e),128&e.__u?void 0:c}function z(_){_&&(_.__c&&(_.__c.__e=!0),_.__k&&_.__k.some(z))}function se(_,e,t){for(var o=0;o<t.length;o++)K(t[o],t[++o],t[++o]);v.__c&&v.__c(e,_),_.some(function(l){try{_=l.__h,l.__h=[],_.some(function(n){n.call(l)})}catch(n){v.__e(n,l.__v)}})}function ce(_){return typeof _!="object"||_==null||_.__b>0?_:D(_)?_.map(ce):b({},_)}function me(_,e,t,o,l,n,i,c,f){var s,p,r,d,u,y,g,m=t.props||N,a=e.props,h=e.type;if(h=="svg"?l="http://www.w3.org/2000/svg":h=="math"?l="http://www.w3.org/1998/Math/MathML":l||(l="http://www.w3.org/1999/xhtml"),n!=null){for(s=0;s<n.length;s++)if((u=n[s])&&"setAttribute"in u==!!h&&(h?u.localName==h:u.nodeType==3)){_=u,n[s]=null;break}}if(_==null){if(h==null)return document.createTextNode(a);_=document.createElementNS(l,h,a.is&&a),c&&(v.__m&&v.__m(e,n),c=!1),n=null}if(h==null)m===a||c&&_.data==a||(_.data=a);else{if(n=n&&E.call(_.childNodes),!c&&n!=null)for(m={},s=0;s<_.attributes.length;s++)m[(u=_.attributes[s]).name]=u.value;for(s in m)u=m[s],s=="dangerouslySetInnerHTML"?r=u:s=="children"||s in a||s=="value"&&"defaultValue"in a||s=="checked"&&"defaultChecked"in a||A(_,s,null,u,l);for(s in a)u=a[s],s=="children"?d=u:s=="dangerouslySetInnerHTML"?p=u:s=="value"?y=u:s=="checked"?g=u:c&&typeof u!="function"||m[s]===u||A(_,s,u,m[s],l);if(p)c||r&&(p.__html==r.__html||p.__html==_.innerHTML)||(_.innerHTML=p.__html),e.__k=[];else if(r&&(_.innerHTML=""),le(e.type=="template"?_.content:_,D(d)?d:[d],e,t,o,h=="foreignObject"?"http://www.w3.org/1999/xhtml":l,n,i,n?n[0]:t.__k&&S(t,0),c,f),n!=null)for(s=n.length;s--;)G(n[s]);c||(s="value",h=="progress"&&y==null?_.removeAttribute("value"):y!=null&&(y!==_[s]||h=="progress"&&!y||h=="option"&&y!=m[s])&&A(_,s,y,m[s],l),s="checked",g!=null&&g!=_[s]&&A(_,s,g,m[s],l))}return _}function K(_,e,t){try{if(typeof _=="function"){var o=typeof _.__u=="function";o&&_.__u(),o&&e==null||(_.__u=_(e))}else _.current=e}catch(l){v.__e(l,t)}}function ue(_,e,t){var o,l;if(v.unmount&&v.unmount(_),(o=_.ref)&&(o.current&&o.current!=_.__e||K(o,null,e)),(o=_.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(n){v.__e(n,e)}o.base=o.__P=null}if(o=_.__k)for(l=0;l<o.length;l++)o[l]&&ue(o[l],e,t||typeof _.type!="function");t||G(_.__e),_.__c=_.__=_.__e=void 0}function ge(_,e,t){return this.constructor(_,t)}function ke(_,e,t){var o,l,n,i;e==document&&(e=document.documentElement),v.__&&v.__(_,e),l=(o=typeof t=="function")?null:t&&t.__k||e.__k,n=[],i=[],J(e,_=(!o&&t||e).__k=ae(R,null,[_]),l||N,N,e.namespaceURI,!o&&t?[t]:l?null:e.firstChild?E.call(e.childNodes):null,n,!o&&t?t:l?l.__e:e.firstChild,o,i),se(n,_,i)}function be(_,e){ke(_,e,be)}function xe(_,e,t){var o,l,n,i,c=b({},_.props);for(n in _.type&&_.type.defaultProps&&(i=_.type.defaultProps),e)n=="key"?o=e[n]:n=="ref"?l=e[n]:c[n]=e[n]===void 0&&i!=null?i[n]:e[n];return arguments.length>2&&(c.children=arguments.length>3?E.call(arguments,2):t),M(_.type,c,o||_.key,l||_.ref,null)}function Ce(_){function e(t){var o,l;return this.getChildContext||(o=new Set,(l={})[e.__c]=this,this.getChildContext=function(){return l},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(n){this.props.value!=n.value&&o.forEach(function(i){i.__e=!0,V(i)})},this.sub=function(n){o.add(n);var i=n.componentWillUnmount;n.componentWillUnmount=function(){o&&o.delete(n),i&&i.call(n)}}),t.children}return e.__c="__cC"+re++,e.__=_,e.Provider=e.__l=(e.Consumer=function(t,o){return t.children(o)}).contextType=e,e}E=H.slice,v={__e:function(_,e,t,o){for(var l,n,i;e=e.__;)if((l=e.__c)&&!l.__)try{if((n=l.constructor)&&n.getDerivedStateFromError!=null&&(l.setState(n.getDerivedStateFromError(_)),i=l.__d),l.componentDidCatch!=null&&(l.componentDidCatch(_,o||{}),i=l.__d),i)return l.__E=l}catch(c){_=c}throw _}},ee=0,pe=function(_){return _!=null&&_.constructor===void 0},L.prototype.setState=function(_,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=b({},this.state),typeof _=="function"&&(_=_(b({},t),this.props)),_&&b(t,_),_!=null&&this.__v&&(e&&this._sb.push(e),V(this))},L.prototype.forceUpdate=function(_){this.__v&&(this.__e=!0,_&&this.__h.push(_),V(this))},L.prototype.render=R,x=[],_e=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,te=function(_,e){return _.__v.__b-e.__v.__b},I.__r=0,B=Math.random().toString(8),F="__d"+B,T="__a"+B,ne=/(PointerCapture)$|Capture$/i,q=0,O=Z(!1),j=Z(!0),re=0;export{L as Component,R as Fragment,xe as cloneElement,Ce as createContext,ae as createElement,we as createRef,ae as h,be as hydrate,pe as isValidElement,v as options,ke as render,ve as toChildArray}; 3 + //# sourceMappingURL=./preact.mjs.map
+1
vendor/esm.sh/preact@10.29.1/es2022/preact.mjs.map
··· 1 + {"mappings":";AACO,IC0BMA,EChBPC,ECPFC,GA2FSC,GCiFTC,EAWAC,EAEEC,GA0BAC,GC7MFC,EACHC,EACAC,EAcKC,GAaFC,EA+IEC,EACAC,ECpLKC,GNeEC,EAAgC,CAAG,EACnCC,EAAY,CAAA,EACZC,GACZ,oECnBYC,EAAUC,MAAMD,QAStB,SAASE,EAAOC,EAAKC,EAAAA,CAE3B,QAASR,KAAKQ,EAAOD,EAAIP,CAAAA,EAAKQ,EAAMR,CAAAA,EACpC,OAA6BO,CAC9B,CAQgB,SAAAE,EAAWC,EAAAA,CACtBA,GAAQA,EAAKC,YAAYD,EAAKC,WAAWC,YAAYF,CAAAA,CAC1D,CEVgB,SAAAG,GAAcC,EAAMN,EAAOO,EAAAA,CAC1C,IACCC,EACAC,EACAjB,EAHGkB,EAAkB,CAAA,EAItB,IAAKlB,KAAKQ,EACLR,GAAK,MAAOgB,EAAMR,EAAMR,CAAAA,EACnBA,GAAK,MAAOiB,EAAMT,EAAMR,CAAAA,EAC5BkB,EAAgBlB,CAAAA,EAAKQ,EAAMR,CAAAA,EAUjC,GAPImB,UAAUC,OAAS,IACtBF,EAAgBH,SACfI,UAAUC,OAAS,EAAInC,EAAMoC,KA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4G,MAClD5G,KAAI+G,IAEJ/G,KAAI+G,IAAcjJ,EAAO,CAAA,EAAIkC,KAAK4G,KAAAA,EAGlB,OAAVyE,GAAU,aAGpBA,EAASA,EAAOvN,EAAO,CAAE,EAAEyN,CAAAA,EAAIvL,KAAKhC,KAAAA,GAGjCqN,GACHvN,EAAOyN,EAAGF,CAAAA,EAIPA,GJ/Be,MIiCfrL,KAAIR,MACH8L,GACHtL,KAAI8G,IAAiBvF,KAAK+J,CAAAA,EAE3BjK,EAAcrB,IAAAA,EAEhB,EAQAF,EAAcwG,UAAUkF,YAAc,SAAUF,EAAAA,CAC3CtL,KAAIR,MAIPQ,KAAIX,IAAAA,GACAiM,GAAUtL,KAAI6G,IAAkBtF,KAAK+J,CAAAA,EACzCjK,EAAcrB,IAAAA,EAEhB,EAYAF,EAAcwG,UAAUC,OAAS1G,EA4F7BhD,EAAgB,CAAA,EAadE,GACa,OAAX0O,SAAW,WACfA,QAAQnF,UAAUqB,KAAK+D,KAAKD,QAAQE,QAAAA,CAAAA,EACpCC,WAuBE5O,GAAY,SAAC6O,EAAGC,EAAAA,CAAAA,OAAMD,EAACrM,IAAAJ,IAAiB0M,EAACtM,IAAAJ,GAAc,EA+B7DoC,EAAOC,IAAkB,EC5OrBxE,EAAM8O,KAAKC,OAAAA,EAASC,SAAS,CAAA,EAChC/O,EAAmB,MAAQD,EAC3BE,EAAiB,MAAQF,EAcpBG,GAAgB,8BAalBC,EAAa,EA+IXC,EAAa+H,EAAAA,EAAiB,EAC9B9H,EAAoB8H,EAAAA,EAAiB,ECpLhC7H,GAAI","names":["slice","options","vnodeId","isValidElement","rerenderQueue","prevDebounce","defer","depthSort","_id","EVENT_DISPATCHED","EVENT_ATTACHED","CAPTURE_REGEX","eventClock","eventProxy","eventProxyCapture","i","EMPTY_OBJ","EMPTY_ARR","IS_NON_DIMENSIONAL","isArray","Array","assign","obj","props","removeNode","node","parentNode","removeChild","createElement","type","children","key","ref","normalizedProps","arguments","length","call","defaultProps","createVNode","original","vnode","__k","__","__b","__e","__c","constructor","__v","__i","__u","createRef","current","Fragment","BaseComponent","context","this","getDomSibling","childIndex","sibling","renderComponent","component","__P","__d","oldVNode","oldDom","commitQueue","refQueue","newVNode","diff","__n","namespaceURI","commitRoot","updateParentDomPointers","base","some","child","enqueueRender","c","push","process","__r","debounceRendering","l","sort","shift","diffChildren","parentDom","renderResult","newParentVNode","oldParentVNode","globalContext","namespace","excessDomChildren","isHydrating","childVNode","newDom","firstChildDom","result","shouldPlace","oldChildren","newChildrenLength","constructNewChildrenArray","applyRef","insert","nextSibling","skewedIndex","matchingIndex","oldChildrenLength","remainingOldChildren","skew","String","findMatchingIndex","unmount","parentVNode","insertBefore","nodeType","toChildArray","out","x","y","matched","setStyle","style","value","setProperty","test","dom","name","oldValue","useCapture","lowerCaseName","o","cssText","replace","toLowerCase","addEventListener","removeEventListener","e","removeAttribute","setAttribute","createEventProxy","eventHandler","event","tmp","isNew","oldProps","oldState","snapshot","clearProcessingException","newProps","isClassComponent","provider","componentContext","renderHook","count","newType","outer","prototype","render","contextType","__E","doRender","sub","state","__h","_sb","__s","getDerivedStateFromProps","componentWillMount","componentDidMount","componentWillReceiveProps","shouldComponentUpdate","apply","componentWillUpdate","componentDidUpdate","getChildContext","getSnapshotBeforeUpdate","cloneNode","then","MODE_HYDRATE","indexOf","markAsForce","diffElementNodes","diffed","root","cb","map","newHtml","oldHtml","newChildren","inputValue","checked","localName","document","createTextNode","createElementNS","is","__m","data","childNodes","attributes","__html","innerHTML","content","undefined","hasRefUnmount","skipRemove","r","componentWillUnmount","replaceNode","documentElement","firstChild","hydrate","cloneElement","createContext","defaultValue","Context","subs","ctx","Set","_props","forEach","add","old","delete","Provider","__l","Consumer","contextValue","error","errorInfo","ctor","handled","getDerivedStateFromError","setState","componentDidCatch","update","callback","s","forceUpdate","Promise","bind","resolve","setTimeout","a","b","Math","random","toString"],"sources":["../esm/npm/preact@10.29.1/node_modules/preact/src/constants.js","../esm/npm/preact@10.29.1/node_modules/preact/src/util.js","../esm/npm/preact@10.29.1/node_modules/preact/src/options.js","../esm/npm/preact@10.29.1/node_modules/preact/src/create-element.js","../esm/npm/preact@10.29.1/node_modules/preact/src/component.js","../esm/npm/preact@10.29.1/node_modules/preact/src/diff/props.js","../esm/npm/preact@10.29.1/node_modules/preact/src/create-context.js","../esm/npm/preact@10.29.1/node_modules/preact/src/diff/children.js","../esm/npm/preact@10.29.1/node_modules/preact/src/diff/index.js","../esm/npm/preact@10.29.1/node_modules/preact/src/render.js","../esm/npm/preact@10.29.1/node_modules/preact/src/clone-element.js","../esm/npm/preact@10.29.1/node_modules/preact/src/diff/catch-error.js"],"sourcesContent":["/** Normal hydration that attaches to a DOM tree but does not diff it. */\nexport const MODE_HYDRATE = 1 \u003c\u003c 5;\n/** Signifies this VNode suspended on the previous render */\nexport const MODE_SUSPENDED = 1 \u003c\u003c 7;\n/** Indicates that this node needs to be inserted while patching children */\nexport const INSERT_VNODE = 1 \u003c\u003c 2;\n/** Indicates a VNode has been matched with another VNode in the diff */\nexport const MATCHED = 1 \u003c\u003c 1;\n\n/** Reset all mode flags */\nexport const RESET_MODE = ~(MODE_HYDRATE | MODE_SUSPENDED);\n\nexport const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\nexport const XHTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\nexport const MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';\n\nexport const NULL = null;\nexport const UNDEFINED = undefined;\nexport const EMPTY_OBJ = /** @type {any} */ ({});\nexport const EMPTY_ARR = [];\nexport const IS_NON_DIMENSIONAL =\n\t/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;\n","import { EMPTY_ARR } from './constants';\n\nexport const isArray = Array.isArray;\n\n/**\n * Assign properties from `props` to `obj`\n * @template O, P The obj and props types\n * @param {O} obj The object to copy properties to\n * @param {P} props The object to copy properties from\n * @returns {O \u0026 P}\n */\nexport function assign(obj, props) {\n\t// @ts-expect-error We change the type of `obj` to be `O \u0026 P`\n\tfor (let i in props) obj[i] = props[i];\n\treturn /** @type {O \u0026 P} */ (obj);\n}\n\n/**\n * Remove a child node from its parent if attached. This is a workaround for\n * IE11 which doesn't support `Element.prototype.remove()`. Using this function\n * is smaller than including a dedicated polyfill.\n * @param {import('./index').ContainerNode} node The node to remove\n */\nexport function removeNode(node) {\n\tif (node \u0026\u0026 node.parentNode) node.parentNode.removeChild(node);\n}\n\nexport const slice = EMPTY_ARR.slice;\n","import { _catchError } from './diff/catch-error';\n\n/**\n * The `option` object can potentially contain callback functions\n * that are called during various stages of our renderer. This is the\n * foundation on which all our addons like `preact/debug`, `preact/compat`,\n * and `preact/hooks` are based on. See the `Options` type in `internal.d.ts`\n * for a full list of available option hooks (most editors/IDEs allow you to\n * ctrl+click or cmd+click on mac the type definition below).\n * @type {import('./internal').Options}\n */\nconst options = {\n\t_catchError\n};\n\nexport default options;\n","import { slice } from './util';\nimport options from './options';\nimport { NULL, UNDEFINED } from './constants';\n\nlet vnodeId = 0;\n\n/**\n * Create an virtual node (used for JSX)\n * @param {import('./internal').VNode[\"type\"]} type The node name or Component constructor for this\n * virtual node\n * @param {object | null | undefined} [props] The properties of the virtual node\n * @param {Array\u003cimport('.').ComponentChildren\u003e} [children] The children of the\n * virtual node\n * @returns {import('./internal').VNode}\n */\nexport function createElement(type, props, children) {\n\tlet normalizedProps = {},\n\t\tkey,\n\t\tref,\n\t\ti;\n\tfor (i in props) {\n\t\tif (i == 'key') key = props[i];\n\t\telse if (i == 'ref') ref = props[i];\n\t\telse normalizedProps[i] = props[i];\n\t}\n\n\tif (arguments.length \u003e 2) {\n\t\tnormalizedProps.children =\n\t\t\targuments.length \u003e 3 ? slice.call(arguments, 2) : children;\n\t}\n\n\t// If a Component VNode, check for and apply defaultProps\n\t// Note: type may be undefined in development, must never error here.\n\tif (typeof type == 'function' \u0026\u0026 type.defaultProps != NULL) {\n\t\tfor (i in type.defaultProps) {\n\t\t\tif (normalizedProps[i] === UNDEFINED) {\n\t\t\t\tnormalizedProps[i] = type.defaultProps[i];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn createVNode(type, normalizedProps, key, ref, NULL);\n}\n\n/**\n * Create a VNode (used internally by Preact)\n * @param {import('./internal').VNode[\"type\"]} type The node name or Component\n * Constructor for this virtual node\n * @param {object | string | number | null} props The properties of this virtual node.\n * If this virtual node represents a text node, this is the text of the node (string or number).\n * @param {string | number | null} key The key for this virtual node, used when\n * diffing it against its children\n * @param {import('./internal').VNode[\"ref\"]} ref The ref property that will\n * receive a reference to its created child\n * @returns {import('./internal').VNode}\n */\nexport function createVNode(type, props, key, ref, original) {\n\t// V8 seems to be better at detecting type shapes if the object is allocated from the same call site\n\t// Do not inline into createElement and coerceToVNode!\n\t/** @type {import('./internal').VNode} */\n\tconst vnode = {\n\t\ttype,\n\t\tprops,\n\t\tkey,\n\t\tref,\n\t\t_children: NULL,\n\t\t_parent: NULL,\n\t\t_depth: 0,\n\t\t_dom: NULL,\n\t\t_component: NULL,\n\t\tconstructor: UNDEFINED,\n\t\t_original: original == NULL ? ++vnodeId : original,\n\t\t_index: -1,\n\t\t_flags: 0\n\t};\n\n\t// Only invoke the vnode hook if this was *not* a direct copy:\n\tif (original == NULL \u0026\u0026 options.vnode != NULL) options.vnode(vnode);\n\n\treturn vnode;\n}\n\nexport function createRef() {\n\treturn { current: NULL };\n}\n\nexport function Fragment(props) {\n\treturn props.children;\n}\n\n/**\n * Check if a the argument is a valid Preact VNode.\n * @param {*} vnode\n * @returns {vnode is VNode}\n */\nexport const isValidElement = vnode =\u003e\n\tvnode != NULL \u0026\u0026 vnode.constructor === UNDEFINED;\n","import { assign } from './util';\nimport { diff, commitRoot } from './diff/index';\nimport options from './options';\nimport { Fragment } from './create-element';\nimport { MODE_HYDRATE, NULL } from './constants';\n\n/**\n * Base Component class. Provides `setState()` and `forceUpdate()`, which\n * trigger rendering\n * @param {object} props The initial component props\n * @param {object} context The initial context from parent components'\n * getChildContext\n */\nexport function BaseComponent(props, context) {\n\tthis.props = props;\n\tthis.context = context;\n}\n\n/**\n * Update component state and schedule a re-render.\n * @this {import('./internal').Component}\n * @param {object | ((s: object, p: object) =\u003e object)} update A hash of state\n * properties to update with new values or a function that given the current\n * state and props returns a new partial state\n * @param {() =\u003e void} [callback] A function to be called once component state is\n * updated\n */\nBaseComponent.prototype.setState = function (update, callback) {\n\t// only clone state when copying to nextState the first time.\n\tlet s;\n\tif (this._nextState != NULL \u0026\u0026 this._nextState != this.state) {\n\t\ts = this._nextState;\n\t} else {\n\t\ts = this._nextState = assign({}, this.state);\n\t}\n\n\tif (typeof update == 'function') {\n\t\t// Some libraries like `immer` mark the current state as readonly,\n\t\t// preventing us from mutating it, so we need to clone it. See #2716\n\t\tupdate = update(assign({}, s), this.props);\n\t}\n\n\tif (update) {\n\t\tassign(s, update);\n\t}\n\n\t// Skip update if updater function returned null\n\tif (update == NULL) return;\n\n\tif (this._vnode) {\n\t\tif (callback) {\n\t\t\tthis._stateCallbacks.push(callback);\n\t\t}\n\t\tenqueueRender(this);\n\t}\n};\n\n/**\n * Immediately perform a synchronous re-render of the component\n * @this {import('./internal').Component}\n * @param {() =\u003e void} [callback] A function to be called after component is\n * re-rendered\n */\nBaseComponent.prototype.forceUpdate = function (callback) {\n\tif (this._vnode) {\n\t\t// Set render mode so that we can differentiate where the render request\n\t\t// is coming from. We need this because forceUpdate should never call\n\t\t// shouldComponentUpdate\n\t\tthis._force = true;\n\t\tif (callback) this._renderCallbacks.push(callback);\n\t\tenqueueRender(this);\n\t}\n};\n\n/**\n * Accepts `props` and `state`, and returns a new Virtual DOM tree to build.\n * Virtual DOM is generally constructed via [JSX](https://jasonformat.com/wtf-is-jsx).\n * @param {object} props Props (eg: JSX attributes) received from parent\n * element/component\n * @param {object} state The component's current state\n * @param {object} context Context object, as returned by the nearest\n * ancestor's `getChildContext()`\n * @returns {ComponentChildren | void}\n */\nBaseComponent.prototype.render = Fragment;\n\n/**\n * @param {import('./internal').VNode} vnode\n * @param {number | null} [childIndex]\n */\nexport function getDomSibling(vnode, childIndex) {\n\tif (childIndex == NULL) {\n\t\t// Use childIndex==null as a signal to resume the search from the vnode's sibling\n\t\treturn vnode._parent\n\t\t\t? getDomSibling(vnode._parent, vnode._index + 1)\n\t\t\t: NULL;\n\t}\n\n\tlet sibling;\n\tfor (; childIndex \u003c vnode._children.length; childIndex++) {\n\t\tsibling = vnode._children[childIndex];\n\n\t\tif (sibling != NULL \u0026\u0026 sibling._dom != NULL) {\n\t\t\t// Since updateParentDomPointers keeps _dom pointer correct,\n\t\t\t// we can rely on _dom to tell us if this subtree contains a\n\t\t\t// rendered DOM node, and what the first rendered DOM node is\n\t\t\treturn sibling._dom;\n\t\t}\n\t}\n\n\t// If we get here, we have not found a DOM node in this vnode's children.\n\t// We must resume from this vnode's sibling (in it's parent _children array)\n\t// Only climb up and search the parent if we aren't searching through a DOM\n\t// VNode (meaning we reached the DOM parent of the original vnode that began\n\t// the search)\n\treturn typeof vnode.type == 'function' ? getDomSibling(vnode) : NULL;\n}\n\n/**\n * Trigger in-place re-rendering of a component.\n * @param {import('./internal').Component} component The component to rerender\n */\nfunction renderComponent(component) {\n\tif (component._parentDom \u0026\u0026 component._dirty) {\n\t\tlet oldVNode = component._vnode,\n\t\t\toldDom = oldVNode._dom,\n\t\t\tcommitQueue = [],\n\t\t\trefQueue = [],\n\t\t\tnewVNode = assign({}, oldVNode);\n\t\tnewVNode._original = oldVNode._original + 1;\n\t\tif (options.vnode) options.vnode(newVNode);\n\n\t\tdiff(\n\t\t\tcomponent._parentDom,\n\t\t\tnewVNode,\n\t\t\toldVNode,\n\t\t\tcomponent._globalContext,\n\t\t\tcomponent._parentDom.namespaceURI,\n\t\t\toldVNode._flags \u0026 MODE_HYDRATE ? [oldDom] : NULL,\n\t\t\tcommitQueue,\n\t\t\toldDom == NULL ? getDomSibling(oldVNode) : oldDom,\n\t\t\t!!(oldVNode._flags \u0026 MODE_HYDRATE),\n\t\t\trefQueue\n\t\t);\n\n\t\tnewVNode._original = oldVNode._original;\n\t\tnewVNode._parent._children[newVNode._index] = newVNode;\n\t\tcommitRoot(commitQueue, newVNode, refQueue);\n\t\toldVNode._dom = oldVNode._parent = null;\n\n\t\tif (newVNode._dom != oldDom) {\n\t\t\tupdateParentDomPointers(newVNode);\n\t\t}\n\t}\n}\n\n/**\n * @param {import('./internal').VNode} vnode\n */\nfunction updateParentDomPointers(vnode) {\n\tif ((vnode = vnode._parent) != NULL \u0026\u0026 vnode._component != NULL) {\n\t\tvnode._dom = vnode._component.base = NULL;\n\t\tvnode._children.some(child =\u003e {\n\t\t\tif (child != NULL \u0026\u0026 child._dom != NULL) {\n\t\t\t\treturn (vnode._dom = vnode._component.base = child._dom);\n\t\t\t}\n\t\t});\n\n\t\treturn updateParentDomPointers(vnode);\n\t}\n}\n\n/**\n * The render queue\n * @type {Array\u003cimport('./internal').Component\u003e}\n */\nlet rerenderQueue = [];\n\n/*\n * The value of `Component.debounce` must asynchronously invoke the passed in callback. It is\n * important that contributors to Preact can consistently reason about what calls to `setState`, etc.\n * do, and when their effects will be applied. See the links below for some further reading on designing\n * asynchronous APIs.\n * * [Designing APIs for Asynchrony](https://blog.izs.me/2013/08/designing-apis-for-asynchrony)\n * * [Callbacks synchronous and asynchronous](https://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/)\n */\n\nlet prevDebounce;\n\nconst defer =\n\ttypeof Promise == 'function'\n\t\t? Promise.prototype.then.bind(Promise.resolve())\n\t\t: setTimeout;\n\n/**\n * Enqueue a rerender of a component\n * @param {import('./internal').Component} c The component to rerender\n */\nexport function enqueueRender(c) {\n\tif (\n\t\t(!c._dirty \u0026\u0026\n\t\t\t(c._dirty = true) \u0026\u0026\n\t\t\trerenderQueue.push(c) \u0026\u0026\n\t\t\t!process._rerenderCount++) ||\n\t\tprevDebounce != options.debounceRendering\n\t) {\n\t\tprevDebounce = options.debounceRendering;\n\t\t(prevDebounce || defer)(process);\n\t}\n}\n\n/**\n * @param {import('./internal').Component} a\n * @param {import('./internal').Component} b\n */\nconst depthSort = (a, b) =\u003e a._vnode._depth - b._vnode._depth;\n\n/** Flush the render queue by rerendering all queued components */\nfunction process() {\n\ttry {\n\t\tlet c,\n\t\t\tl = 1;\n\n\t\t// Don't update `renderCount` yet. Keep its value non-zero to prevent unnecessary\n\t\t// process() calls from getting scheduled while `queue` is still being consumed.\n\t\twhile (rerenderQueue.length) {\n\t\t\t// Keep the rerender queue sorted by (depth, insertion order). The queue\n\t\t\t// will initially be sorted on the first iteration only if it has more than 1 item.\n\t\t\t//\n\t\t\t// New items can be added to the queue e.g. when rerendering a provider, so we want to\n\t\t\t// keep the order from top to bottom with those new items so we can handle them in a\n\t\t\t// single pass\n\t\t\tif (rerenderQueue.length \u003e l) {\n\t\t\t\trerenderQueue.sort(depthSort);\n\t\t\t}\n\n\t\t\tc = rerenderQueue.shift();\n\t\t\tl = rerenderQueue.length;\n\n\t\t\trenderComponent(c);\n\t\t}\n\t} finally {\n\t\trerenderQueue.length = process._rerenderCount = 0;\n\t}\n}\n\nprocess._rerenderCount = 0;\n","import { IS_NON_DIMENSIONAL, NULL, SVG_NAMESPACE } from '../constants';\nimport options from '../options';\n\n// Per-instance unique key for event clock stamps. Each Preact copy on the page\n// gets its own random suffix so that `_dispatched` / `_attached` properties on\n// shared event objects and handler functions cannot collide across instances.\n// ~1 in 60M collision odds - if you have that many praect versions on the page,\n// you deserve some weird bugs.\n// In 11 we can replace this with a\n// Symbol\nlet _id = Math.random().toString(8),\n\tEVENT_DISPATCHED = '__d' + _id,\n\tEVENT_ATTACHED = '__a' + _id;\n\nfunction setStyle(style, key, value) {\n\tif (key[0] == '-') {\n\t\tstyle.setProperty(key, value == NULL ? '' : value);\n\t} else if (value == NULL) {\n\t\tstyle[key] = '';\n\t} else if (typeof value != 'number' || IS_NON_DIMENSIONAL.test(key)) {\n\t\tstyle[key] = value;\n\t} else {\n\t\tstyle[key] = value + 'px';\n\t}\n}\n\nconst CAPTURE_REGEX = /(PointerCapture)$|Capture$/i;\n\n// A logical clock to solve issues like https://github.com/preactjs/preact/issues/3927.\n// When the DOM performs an event it leaves micro-ticks in between bubbling up which means that\n// an event can trigger on a newly reated DOM-node while the event bubbles up.\n//\n// Originally inspired by Vue\n// (https://github.com/vuejs/core/blob/caeb8a68811a1b0f79/packages/runtime-dom/src/modules/events.ts#L90-L101),\n// but modified to use a logical clock instead of Date.now() in case event handlers get attached\n// and events get dispatched during the same millisecond.\n//\n// The clock is incremented after each new event dispatch. This allows 1 000 000 new events\n// per second for over 280 years before the value reaches Number.MAX_SAFE_INTEGER (2**53 - 1).\nlet eventClock = 0;\n\n/**\n * Set a property value on a DOM node\n * @param {import('../internal').PreactElement} dom The DOM node to modify\n * @param {string} name The name of the property to set\n * @param {*} value The value to set the property to\n * @param {*} oldValue The old value the property had\n * @param {string} namespace Whether or not this DOM node is an SVG node or not\n */\nexport function setProperty(dom, name, value, oldValue, namespace) {\n\tlet useCapture;\n\n\to: if (name == 'style') {\n\t\tif (typeof value == 'string') {\n\t\t\tdom.style.cssText = value;\n\t\t} else {\n\t\t\tif (typeof oldValue == 'string') {\n\t\t\t\tdom.style.cssText = oldValue = '';\n\t\t\t}\n\n\t\t\tif (oldValue) {\n\t\t\t\tfor (name in oldValue) {\n\t\t\t\t\tif (!(value \u0026\u0026 name in value)) {\n\t\t\t\t\t\tsetStyle(dom.style, name, '');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (value) {\n\t\t\t\tfor (name in value) {\n\t\t\t\t\tif (!oldValue || value[name] != oldValue[name]) {\n\t\t\t\t\t\tsetStyle(dom.style, name, value[name]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// Benchmark for comparison: https://esbench.com/bench/574c954bdb965b9a00965ac6\n\telse if (name[0] == 'o' \u0026\u0026 name[1] == 'n') {\n\t\tuseCapture = name != (name = name.replace(CAPTURE_REGEX, '$1'));\n\t\tconst lowerCaseName = name.toLowerCase();\n\n\t\t// Infer correct casing for DOM built-in events:\n\t\tif (lowerCaseName in dom || name == 'onFocusOut' || name == 'onFocusIn')\n\t\t\tname = lowerCaseName.slice(2);\n\t\telse name = name.slice(2);\n\n\t\tif (!dom._listeners) dom._listeners = {};\n\t\tdom._listeners[name + useCapture] = value;\n\n\t\tif (value) {\n\t\t\tif (!oldValue) {\n\t\t\t\tvalue[EVENT_ATTACHED] = eventClock;\n\t\t\t\tdom.addEventListener(\n\t\t\t\t\tname,\n\t\t\t\t\tuseCapture ? eventProxyCapture : eventProxy,\n\t\t\t\t\tuseCapture\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tvalue[EVENT_ATTACHED] = oldValue[EVENT_ATTACHED];\n\t\t\t}\n\t\t} else {\n\t\t\tdom.removeEventListener(\n\t\t\t\tname,\n\t\t\t\tuseCapture ? eventProxyCapture : eventProxy,\n\t\t\t\tuseCapture\n\t\t\t);\n\t\t}\n\t} else {\n\t\tif (namespace == SVG_NAMESPACE) {\n\t\t\t// Normalize incorrect prop usage for SVG:\n\t\t\t// - xlink:href / xlinkHref --\u003e href (xlink:href was removed from SVG and isn't needed)\n\t\t\t// - className --\u003e class\n\t\t\tname = name.replace(/xlink(H|:h)/, 'h').replace(/sName$/, 's');\n\t\t} else if (\n\t\t\tname != 'width' \u0026\u0026\n\t\t\tname != 'height' \u0026\u0026\n\t\t\tname != 'href' \u0026\u0026\n\t\t\tname != 'list' \u0026\u0026\n\t\t\tname != 'form' \u0026\u0026\n\t\t\t// Default value in browsers is `-1` and an empty string is\n\t\t\t// cast to `0` instead\n\t\t\tname != 'tabIndex' \u0026\u0026\n\t\t\tname != 'download' \u0026\u0026\n\t\t\tname != 'rowSpan' \u0026\u0026\n\t\t\tname != 'colSpan' \u0026\u0026\n\t\t\tname != 'role' \u0026\u0026\n\t\t\tname != 'popover' \u0026\u0026\n\t\t\tname in dom\n\t\t) {\n\t\t\ttry {\n\t\t\t\tdom[name] = value == NULL ? '' : value;\n\t\t\t\t// labelled break is 1b smaller here than a return statement (sorry)\n\t\t\t\tbreak o;\n\t\t\t} catch (e) {}\n\t\t}\n\n\t\t// aria- and data- attributes have no boolean representation.\n\t\t// A `false` value is different from the attribute not being\n\t\t// present, so we can't remove it. For non-boolean aria\n\t\t// attributes we could treat false as a removal, but the\n\t\t// amount of exceptions would cost too many bytes. On top of\n\t\t// that other frameworks generally stringify `false`.\n\n\t\tif (typeof value == 'function') {\n\t\t\t// never serialize functions as attribute values\n\t\t} else if (value != NULL \u0026\u0026 (value !== false || name[4] == '-')) {\n\t\t\tdom.setAttribute(name, name == 'popover' \u0026\u0026 value == true ? '' : value);\n\t\t} else {\n\t\t\tdom.removeAttribute(name);\n\t\t}\n\t}\n}\n\n/**\n * Create an event proxy function.\n * @param {boolean} useCapture Is the event handler for the capture phase.\n * @private\n */\nfunction createEventProxy(useCapture) {\n\t/**\n\t * Proxy an event to hooked event handlers\n\t * @param {import('../internal').PreactEvent} e The event object from the browser\n\t * @private\n\t */\n\treturn function (e) {\n\t\tif (this._listeners) {\n\t\t\tconst eventHandler = this._listeners[e.type + useCapture];\n\t\t\tif (e[EVENT_DISPATCHED] == NULL) {\n\t\t\t\te[EVENT_DISPATCHED] = eventClock++;\n\n\t\t\t\t// When `e[EVENT_DISPATCHED]` is smaller than the time when the targeted event\n\t\t\t\t// handler was attached we know we have bubbled up to an element that was added\n\t\t\t\t// during patching the DOM.\n\t\t\t} else if (e[EVENT_DISPATCHED] \u003c eventHandler[EVENT_ATTACHED]) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn eventHandler(options.event ? options.event(e) : e);\n\t\t}\n\t};\n}\n\nconst eventProxy = createEventProxy(false);\nconst eventProxyCapture = createEventProxy(true);\n","import { enqueueRender } from './component';\nimport { NULL } from './constants';\n\nexport let i = 0;\n\nexport function createContext(defaultValue) {\n\tfunction Context(props) {\n\t\tif (!this.getChildContext) {\n\t\t\t/** @type {Set\u003cimport('./internal').Component\u003e | null} */\n\t\t\tlet subs = new Set();\n\t\t\tlet ctx = {};\n\t\t\tctx[Context._id] = this;\n\n\t\t\tthis.getChildContext = () =\u003e ctx;\n\n\t\t\tthis.componentWillUnmount = () =\u003e {\n\t\t\t\tsubs = NULL;\n\t\t\t};\n\n\t\t\tthis.shouldComponentUpdate = function (_props) {\n\t\t\t\t// @ts-expect-error even\n\t\t\t\tif (this.props.value != _props.value) {\n\t\t\t\t\tsubs.forEach(c =\u003e {\n\t\t\t\t\t\tc._force = true;\n\t\t\t\t\t\tenqueueRender(c);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.sub = c =\u003e {\n\t\t\t\tsubs.add(c);\n\t\t\t\tlet old = c.componentWillUnmount;\n\t\t\t\tc.componentWillUnmount = () =\u003e {\n\t\t\t\t\tif (subs) {\n\t\t\t\t\t\tsubs.delete(c);\n\t\t\t\t\t}\n\t\t\t\t\tif (old) old.call(c);\n\t\t\t\t};\n\t\t\t};\n\t\t}\n\n\t\treturn props.children;\n\t}\n\n\tContext._id = '__cC' + i++;\n\tContext._defaultValue = defaultValue;\n\n\t/** @type {import('./internal').FunctionComponent} */\n\tContext.Consumer = (props, contextValue) =\u003e {\n\t\treturn props.children(contextValue);\n\t};\n\n\t// we could also get rid of _contextRef entirely\n\tContext.Provider =\n\t\tContext._contextRef =\n\t\tContext.Consumer.contextType =\n\t\t\tContext;\n\n\treturn Context;\n}\n","import { diff, unmount, applyRef } from './index';\nimport { createVNode, Fragment } from '../create-element';\nimport {\n\tEMPTY_OBJ,\n\tEMPTY_ARR,\n\tINSERT_VNODE,\n\tMATCHED,\n\tUNDEFINED,\n\tNULL\n} from '../constants';\nimport { isArray } from '../util';\nimport { getDomSibling } from '../component';\n\n/**\n * @typedef {import('../internal').ComponentChildren} ComponentChildren\n * @typedef {import('../internal').Component} Component\n * @typedef {import('../internal').PreactElement} PreactElement\n * @typedef {import('../internal').VNode} VNode\n */\n\n/**\n * Diff the children of a virtual node\n * @param {PreactElement} parentDom The DOM element whose children are being\n * diffed\n * @param {ComponentChildren[]} renderResult\n * @param {VNode} newParentVNode The new virtual node whose children should be\n * diff'ed against oldParentVNode\n * @param {VNode} oldParentVNode The old virtual node whose children should be\n * diff'ed against newParentVNode\n * @param {object} globalContext The current context object - modified by\n * getChildContext\n * @param {string} namespace Current namespace of the DOM node (HTML, SVG, or MathML)\n * @param {Array\u003cPreactElement\u003e} excessDomChildren\n * @param {Array\u003cComponent\u003e} commitQueue List of components which have callbacks\n * to invoke in commitRoot\n * @param {PreactElement} oldDom The current attached DOM element any new dom\n * elements should be placed around. Likely `null` on first render (except when\n * hydrating). Can be a sibling DOM element when diffing Fragments that have\n * siblings. In most cases, it starts out as `oldChildren[0]._dom`.\n * @param {boolean} isHydrating Whether or not we are in hydration\n * @param {any[]} refQueue an array of elements needed to invoke refs\n */\nexport function diffChildren(\n\tparentDom,\n\trenderResult,\n\tnewParentVNode,\n\toldParentVNode,\n\tglobalContext,\n\tnamespace,\n\texcessDomChildren,\n\tcommitQueue,\n\toldDom,\n\tisHydrating,\n\trefQueue\n) {\n\tlet i,\n\t\t/** @type {VNode} */\n\t\toldVNode,\n\t\t/** @type {VNode} */\n\t\tchildVNode,\n\t\t/** @type {PreactElement} */\n\t\tnewDom,\n\t\t/** @type {PreactElement} */\n\t\tfirstChildDom;\n\n\t// This is a compression of oldParentVNode!=null \u0026\u0026 oldParentVNode != EMPTY_OBJ \u0026\u0026 oldParentVNode._children || EMPTY_ARR\n\t// as EMPTY_OBJ._children should be `undefined`.\n\t/** @type {VNode[]} */\n\tlet oldChildren = (oldParentVNode \u0026\u0026 oldParentVNode._children) || EMPTY_ARR;\n\n\tlet newChildrenLength = renderResult.length;\n\n\toldDom = constructNewChildrenArray(\n\t\tnewParentVNode,\n\t\trenderResult,\n\t\toldChildren,\n\t\toldDom,\n\t\tnewChildrenLength\n\t);\n\n\tfor (i = 0; i \u003c newChildrenLength; i++) {\n\t\tchildVNode = newParentVNode._children[i];\n\t\tif (childVNode == NULL) continue;\n\n\t\t// At this point, constructNewChildrenArray has assigned _index to be the\n\t\t// matchingIndex for this VNode's oldVNode (or -1 if there is no oldVNode).\n\t\toldVNode =\n\t\t\t(childVNode._index != -1 \u0026\u0026 oldChildren[childVNode._index]) || EMPTY_OBJ;\n\n\t\t// Update childVNode._index to its final index\n\t\tchildVNode._index = i;\n\n\t\t// Morph the old element into the new one, but don't append it to the dom yet\n\t\tlet result = diff(\n\t\t\tparentDom,\n\t\t\tchildVNode,\n\t\t\toldVNode,\n\t\t\tglobalContext,\n\t\t\tnamespace,\n\t\t\texcessDomChildren,\n\t\t\tcommitQueue,\n\t\t\toldDom,\n\t\t\tisHydrating,\n\t\t\trefQueue\n\t\t);\n\n\t\t// Adjust DOM nodes\n\t\tnewDom = childVNode._dom;\n\t\tif (childVNode.ref \u0026\u0026 oldVNode.ref != childVNode.ref) {\n\t\t\tif (oldVNode.ref) {\n\t\t\t\tapplyRef(oldVNode.ref, NULL, childVNode);\n\t\t\t}\n\t\t\trefQueue.push(\n\t\t\t\tchildVNode.ref,\n\t\t\t\tchildVNode._component || newDom,\n\t\t\t\tchildVNode\n\t\t\t);\n\t\t}\n\n\t\tif (firstChildDom == NULL \u0026\u0026 newDom != NULL) {\n\t\t\tfirstChildDom = newDom;\n\t\t}\n\n\t\tlet shouldPlace = !!(childVNode._flags \u0026 INSERT_VNODE);\n\t\tif (shouldPlace || oldVNode._children === childVNode._children) {\n\t\t\toldDom = insert(childVNode, oldDom, parentDom, shouldPlace);\n\n\t\t\t// When a matched VNode is physically moved via INSERT_VNODE, its old\n\t\t\t// _dom pointer becomes a stale positional reference. Clear it so that\n\t\t\t// getDomSibling (called from nested diffs) won't return this stale\n\t\t\t// reference and mis-place subsequent DOM nodes. See #5065.\n\t\t\tif (shouldPlace \u0026\u0026 oldVNode._dom) {\n\t\t\t\toldVNode._dom = NULL;\n\t\t\t}\n\t\t} else if (typeof childVNode.type == 'function' \u0026\u0026 result !== UNDEFINED) {\n\t\t\toldDom = result;\n\t\t} else if (newDom) {\n\t\t\toldDom = newDom.nextSibling;\n\t\t}\n\n\t\t// Unset diffing flags\n\t\tchildVNode._flags \u0026= ~(INSERT_VNODE | MATCHED);\n\t}\n\n\tnewParentVNode._dom = firstChildDom;\n\n\treturn oldDom;\n}\n\n/**\n * @param {VNode} newParentVNode\n * @param {ComponentChildren[]} renderResult\n * @param {VNode[]} oldChildren\n */\nfunction constructNewChildrenArray(\n\tnewParentVNode,\n\trenderResult,\n\toldChildren,\n\toldDom,\n\tnewChildrenLength\n) {\n\t/** @type {number} */\n\tlet i;\n\t/** @type {VNode} */\n\tlet childVNode;\n\t/** @type {VNode} */\n\tlet oldVNode;\n\n\tlet oldChildrenLength = oldChildren.length,\n\t\tremainingOldChildren = oldChildrenLength;\n\n\tlet skew = 0;\n\n\tnewParentVNode._children = new Array(newChildrenLength);\n\tfor (i = 0; i \u003c newChildrenLength; i++) {\n\t\t// @ts-expect-error We are reusing the childVNode variable to hold both the\n\t\t// pre and post normalized childVNode\n\t\tchildVNode = renderResult[i];\n\n\t\tif (\n\t\t\tchildVNode == NULL ||\n\t\t\ttypeof childVNode == 'boolean' ||\n\t\t\ttypeof childVNode == 'function'\n\t\t) {\n\t\t\tnewParentVNode._children[i] = NULL;\n\t\t\tcontinue;\n\t\t}\n\t\t// If this newVNode is being reused (e.g. \u003cdiv\u003e{reuse}{reuse}\u003c/div\u003e) in the same diff,\n\t\t// or we are rendering a component (e.g. setState) copy the oldVNodes so it can have\n\t\t// it's own DOM \u0026 etc. pointers\n\t\telse if (\n\t\t\ttypeof childVNode == 'string' ||\n\t\t\ttypeof childVNode == 'number' ||\n\t\t\t// eslint-disable-next-line valid-typeof\n\t\t\ttypeof childVNode == 'bigint' ||\n\t\t\tchildVNode.constructor == String\n\t\t) {\n\t\t\tchildVNode = newParentVNode._children[i] = createVNode(\n\t\t\t\tNULL,\n\t\t\t\tchildVNode,\n\t\t\t\tNULL,\n\t\t\t\tNULL,\n\t\t\t\tNULL\n\t\t\t);\n\t\t} else if (isArray(childVNode)) {\n\t\t\tchildVNode = newParentVNode._children[i] = createVNode(\n\t\t\t\tFragment,\n\t\t\t\t{ children: childVNode },\n\t\t\t\tNULL,\n\t\t\t\tNULL,\n\t\t\t\tNULL\n\t\t\t);\n\t\t} else if (childVNode.constructor === UNDEFINED \u0026\u0026 childVNode._depth \u003e 0) {\n\t\t\t// VNode is already in use, clone it. This can happen in the following\n\t\t\t// scenario:\n\t\t\t// const reuse = \u003cdiv /\u003e\n\t\t\t// \u003cdiv\u003e{reuse}\u003cspan /\u003e{reuse}\u003c/div\u003e\n\t\t\tchildVNode = newParentVNode._children[i] = createVNode(\n\t\t\t\tchildVNode.type,\n\t\t\t\tchildVNode.props,\n\t\t\t\tchildVNode.key,\n\t\t\t\tchildVNode.ref ? childVNode.ref : NULL,\n\t\t\t\tchildVNode._original\n\t\t\t);\n\t\t} else {\n\t\t\tnewParentVNode._children[i] = childVNode;\n\t\t}\n\n\t\tconst skewedIndex = i + skew;\n\t\tchildVNode._parent = newParentVNode;\n\t\tchildVNode._depth = newParentVNode._depth + 1;\n\n\t\t// Temporarily store the matchingIndex on the _index property so we can pull\n\t\t// out the oldVNode in diffChildren. We'll override this to the VNode's\n\t\t// final index after using this property to get the oldVNode\n\t\tconst matchingIndex = (childVNode._index = findMatchingIndex(\n\t\t\tchildVNode,\n\t\t\toldChildren,\n\t\t\tskewedIndex,\n\t\t\tremainingOldChildren\n\t\t));\n\n\t\toldVNode = NULL;\n\t\tif (matchingIndex != -1) {\n\t\t\toldVNode = oldChildren[matchingIndex];\n\t\t\tremainingOldChildren--;\n\t\t\tif (oldVNode) {\n\t\t\t\toldVNode._flags |= MATCHED;\n\t\t\t}\n\t\t}\n\n\t\t// Here, we define isMounting for the purposes of the skew diffing\n\t\t// algorithm. Nodes that are unsuspending are considered mounting and we detect\n\t\t// this by checking if oldVNode._original == null\n\t\tconst isMounting = oldVNode == NULL || oldVNode._original == NULL;\n\n\t\tif (isMounting) {\n\t\t\tif (matchingIndex == -1) {\n\t\t\t\t// When the array of children is growing we need to decrease the skew\n\t\t\t\t// as we are adding a new element to the array.\n\t\t\t\t// Example:\n\t\t\t\t// [1, 2, 3] --\u003e [0, 1, 2, 3]\n\t\t\t\t// oldChildren newChildren\n\t\t\t\t//\n\t\t\t\t// The new element is at index 0, so our skew is 0,\n\t\t\t\t// we need to decrease the skew as we are adding a new element.\n\t\t\t\t// The decrease will cause us to compare the element at position 1\n\t\t\t\t// with value 1 with the element at position 0 with value 0.\n\t\t\t\t//\n\t\t\t\t// A linear concept is applied when the array is shrinking,\n\t\t\t\t// if the length is unchanged we can assume that no skew\n\t\t\t\t// changes are needed.\n\t\t\t\tif (newChildrenLength \u003e oldChildrenLength) {\n\t\t\t\t\tskew--;\n\t\t\t\t} else if (newChildrenLength \u003c oldChildrenLength) {\n\t\t\t\t\tskew++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If we are mounting a DOM VNode, mark it for insertion\n\t\t\tif (typeof childVNode.type != 'function') {\n\t\t\t\tchildVNode._flags |= INSERT_VNODE;\n\t\t\t}\n\t\t} else if (matchingIndex != skewedIndex) {\n\t\t\t// When we move elements around i.e. [0, 1, 2] --\u003e [1, 0, 2]\n\t\t\t// --\u003e we diff 1, we find it at position 1 while our skewed index is 0 and our skew is 0\n\t\t\t// we set the skew to 1 as we found an offset.\n\t\t\t// --\u003e we diff 0, we find it at position 0 while our skewed index is at 2 and our skew is 1\n\t\t\t// this makes us increase the skew again.\n\t\t\t// --\u003e we diff 2, we find it at position 2 while our skewed index is at 4 and our skew is 2\n\t\t\t//\n\t\t\t// this becomes an optimization question where currently we see a 1 element offset as an insertion\n\t\t\t// or deletion i.e. we optimize for [0, 1, 2] --\u003e [9, 0, 1, 2]\n\t\t\t// while a more than 1 offset we see as a swap.\n\t\t\t// We could probably build heuristics for having an optimized course of action here as well, but\n\t\t\t// might go at the cost of some bytes.\n\t\t\t//\n\t\t\t// If we wanted to optimize for i.e. only swaps we'd just do the last two code-branches and have\n\t\t\t// only the first item be a re-scouting and all the others fall in their skewed counter-part.\n\t\t\t// We could also further optimize for swaps\n\t\t\tif (matchingIndex == skewedIndex - 1) {\n\t\t\t\tskew--;\n\t\t\t} else if (matchingIndex == skewedIndex + 1) {\n\t\t\t\tskew++;\n\t\t\t} else {\n\t\t\t\tif (matchingIndex \u003e skewedIndex) {\n\t\t\t\t\tskew--;\n\t\t\t\t} else {\n\t\t\t\t\tskew++;\n\t\t\t\t}\n\n\t\t\t\t// Move this VNode's DOM if the original index (matchingIndex) doesn't\n\t\t\t\t// match the new skew index (i + new skew)\n\t\t\t\t// In the former two branches we know that it matches after skewing\n\t\t\t\tchildVNode._flags |= INSERT_VNODE;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Remove remaining oldChildren if there are any. Loop forwards so that as we\n\t// unmount DOM from the beginning of the oldChildren, we can adjust oldDom to\n\t// point to the next child, which needs to be the first DOM node that won't be\n\t// unmounted.\n\tif (remainingOldChildren) {\n\t\tfor (i = 0; i \u003c oldChildrenLength; i++) {\n\t\t\toldVNode = oldChildren[i];\n\t\t\tif (oldVNode != NULL \u0026\u0026 (oldVNode._flags \u0026 MATCHED) == 0) {\n\t\t\t\tif (oldVNode._dom == oldDom) {\n\t\t\t\t\toldDom = getDomSibling(oldVNode);\n\t\t\t\t}\n\n\t\t\t\tunmount(oldVNode, oldVNode);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn oldDom;\n}\n\n/**\n * @param {VNode} parentVNode\n * @param {PreactElement} oldDom\n * @param {PreactElement} parentDom\n * @param {boolean} shouldPlace\n * @returns {PreactElement}\n */\nfunction insert(parentVNode, oldDom, parentDom, shouldPlace) {\n\t// Note: VNodes in nested suspended trees may be missing _children.\n\n\tif (typeof parentVNode.type == 'function') {\n\t\tlet children = parentVNode._children;\n\t\tfor (let i = 0; children \u0026\u0026 i \u003c children.length; i++) {\n\t\t\tif (children[i]) {\n\t\t\t\t// If we enter this code path on sCU bailout, where we copy\n\t\t\t\t// oldVNode._children to newVNode._children, we need to update the old\n\t\t\t\t// children's _parent pointer to point to the newVNode (parentVNode\n\t\t\t\t// here).\n\t\t\t\tchildren[i]._parent = parentVNode;\n\t\t\t\toldDom = insert(children[i], oldDom, parentDom, shouldPlace);\n\t\t\t}\n\t\t}\n\n\t\treturn oldDom;\n\t} else if (parentVNode._dom != oldDom) {\n\t\tif (shouldPlace) {\n\t\t\tif (oldDom \u0026\u0026 parentVNode.type \u0026\u0026 !oldDom.parentNode) {\n\t\t\t\toldDom = getDomSibling(parentVNode);\n\t\t\t}\n\t\t\tparentDom.insertBefore(parentVNode._dom, oldDom || NULL);\n\t\t}\n\t\toldDom = parentVNode._dom;\n\t}\n\n\tdo {\n\t\toldDom = oldDom \u0026\u0026 oldDom.nextSibling;\n\t} while (oldDom != NULL \u0026\u0026 oldDom.nodeType == 8);\n\n\treturn oldDom;\n}\n\n/**\n * Flatten and loop through the children of a virtual node\n * @param {ComponentChildren} children The unflattened children of a virtual\n * node\n * @returns {VNode[]}\n */\nexport function toChildArray(children, out) {\n\tout = out || [];\n\tif (children == NULL || typeof children == 'boolean') {\n\t} else if (isArray(children)) {\n\t\tchildren.some(child =\u003e {\n\t\t\ttoChildArray(child, out);\n\t\t});\n\t} else {\n\t\tout.push(children);\n\t}\n\treturn out;\n}\n\n/**\n * @param {VNode} childVNode\n * @param {VNode[]} oldChildren\n * @param {number} skewedIndex\n * @param {number} remainingOldChildren\n * @returns {number}\n */\nfunction findMatchingIndex(\n\tchildVNode,\n\toldChildren,\n\tskewedIndex,\n\tremainingOldChildren\n) {\n\tconst key = childVNode.key;\n\tconst type = childVNode.type;\n\tlet oldVNode = oldChildren[skewedIndex];\n\tconst matched = oldVNode != NULL \u0026\u0026 (oldVNode._flags \u0026 MATCHED) == 0;\n\n\t// We only need to perform a search if there are more children\n\t// (remainingOldChildren) to search. However, if the oldVNode we just looked\n\t// at skewedIndex was not already used in this diff, then there must be at\n\t// least 1 other (so greater than 1) remainingOldChildren to attempt to match\n\t// against. So the following condition checks that ensuring\n\t// remainingOldChildren \u003e 1 if the oldVNode is not already used/matched. Else\n\t// if the oldVNode was null or matched, then there could needs to be at least\n\t// 1 (aka `remainingOldChildren \u003e 0`) children to find and compare against.\n\t//\n\t// If there is an unkeyed functional VNode, that isn't a built-in like our Fragment,\n\t// we should not search as we risk re-using state of an unrelated VNode. (reverted for now)\n\tlet shouldSearch =\n\t\t// (typeof type != 'function' || type === Fragment || key) \u0026\u0026\n\t\tremainingOldChildren \u003e (matched ? 1 : 0);\n\n\tif (\n\t\t(oldVNode === NULL \u0026\u0026 key == null) ||\n\t\t(matched \u0026\u0026 key == oldVNode.key \u0026\u0026 type == oldVNode.type)\n\t) {\n\t\treturn skewedIndex;\n\t} else if (shouldSearch) {\n\t\tlet x = skewedIndex - 1;\n\t\tlet y = skewedIndex + 1;\n\t\twhile (x \u003e= 0 || y \u003c oldChildren.length) {\n\t\t\tconst childIndex = x \u003e= 0 ? x-- : y++;\n\t\t\toldVNode = oldChildren[childIndex];\n\t\t\tif (\n\t\t\t\toldVNode != NULL \u0026\u0026\n\t\t\t\t(oldVNode._flags \u0026 MATCHED) == 0 \u0026\u0026\n\t\t\t\tkey == oldVNode.key \u0026\u0026\n\t\t\t\ttype == oldVNode.type\n\t\t\t) {\n\t\t\t\treturn childIndex;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn -1;\n}\n","import {\n\tEMPTY_ARR,\n\tEMPTY_OBJ,\n\tMATH_NAMESPACE,\n\tMODE_HYDRATE,\n\tMODE_SUSPENDED,\n\tNULL,\n\tRESET_MODE,\n\tSVG_NAMESPACE,\n\tUNDEFINED,\n\tXHTML_NAMESPACE\n} from '../constants';\nimport { BaseComponent, getDomSibling } from '../component';\nimport { Fragment } from '../create-element';\nimport { diffChildren } from './children';\nimport { setProperty } from './props';\nimport { assign, isArray, removeNode, slice } from '../util';\nimport options from '../options';\n\n/**\n * @typedef {import('../internal').ComponentChildren} ComponentChildren\n * @typedef {import('../internal').Component} Component\n * @typedef {import('../internal').PreactElement} PreactElement\n * @typedef {import('../internal').VNode} VNode\n */\n\n/**\n * @template {any} T\n * @typedef {import('../internal').Ref\u003cT\u003e} Ref\u003cT\u003e\n */\n\n/**\n * Diff two virtual nodes and apply proper changes to the DOM\n * @param {PreactElement} parentDom The parent of the DOM element\n * @param {VNode} newVNode The new virtual node\n * @param {VNode} oldVNode The old virtual node\n * @param {object} globalContext The current context object. Modified by\n * getChildContext\n * @param {string} namespace Current namespace of the DOM node (HTML, SVG, or MathML)\n * @param {Array\u003cPreactElement\u003e} excessDomChildren\n * @param {Array\u003cComponent\u003e} commitQueue List of components which have callbacks\n * to invoke in commitRoot\n * @param {PreactElement} oldDom The current attached DOM element any new dom\n * elements should be placed around. Likely `null` on first render (except when\n * hydrating). Can be a sibling DOM element when diffing Fragments that have\n * siblings. In most cases, it starts out as `oldChildren[0]._dom`.\n * @param {boolean} isHydrating Whether or not we are in hydration\n * @param {any[]} refQueue an array of elements needed to invoke refs\n */\nexport function diff(\n\tparentDom,\n\tnewVNode,\n\toldVNode,\n\tglobalContext,\n\tnamespace,\n\texcessDomChildren,\n\tcommitQueue,\n\toldDom,\n\tisHydrating,\n\trefQueue\n) {\n\t/** @type {any} */\n\tlet tmp,\n\t\tnewType = newVNode.type;\n\n\t// When passing through createElement it assigns the object\n\t// constructor as undefined. This to prevent JSON-injection.\n\tif (newVNode.constructor !== UNDEFINED) return NULL;\n\n\t// If the previous diff bailed out, resume creating/hydrating.\n\tif (oldVNode._flags \u0026 MODE_SUSPENDED) {\n\t\tisHydrating = !!(oldVNode._flags \u0026 MODE_HYDRATE);\n\t\toldDom = newVNode._dom = oldVNode._dom;\n\t\texcessDomChildren = [oldDom];\n\t}\n\n\tif ((tmp = options._diff)) tmp(newVNode);\n\n\touter: if (typeof newType == 'function') {\n\t\ttry {\n\t\t\tlet c, isNew, oldProps, oldState, snapshot, clearProcessingException;\n\t\t\tlet newProps = newVNode.props;\n\t\t\tconst isClassComponent = newType.prototype \u0026\u0026 newType.prototype.render;\n\n\t\t\t// Necessary for createContext api. Setting this property will pass\n\t\t\t// the context value as `this.context` just for this component.\n\t\t\ttmp = newType.contextType;\n\t\t\tlet provider = tmp \u0026\u0026 globalContext[tmp._id];\n\t\t\tlet componentContext = tmp\n\t\t\t\t? provider\n\t\t\t\t\t? provider.props.value\n\t\t\t\t\t: tmp._defaultValue\n\t\t\t\t: globalContext;\n\n\t\t\t// Get component and set it to `c`\n\t\t\tif (oldVNode._component) {\n\t\t\t\tc = newVNode._component = oldVNode._component;\n\t\t\t\tclearProcessingException = c._processingException = c._pendingError;\n\t\t\t} else {\n\t\t\t\t// Instantiate the new component\n\t\t\t\tif (isClassComponent) {\n\t\t\t\t\t// @ts-expect-error The check above verifies that newType is suppose to be constructed\n\t\t\t\t\tnewVNode._component = c = new newType(newProps, componentContext); // eslint-disable-line new-cap\n\t\t\t\t} else {\n\t\t\t\t\t// @ts-expect-error Trust me, Component implements the interface we want\n\t\t\t\t\tnewVNode._component = c = new BaseComponent(\n\t\t\t\t\t\tnewProps,\n\t\t\t\t\t\tcomponentContext\n\t\t\t\t\t);\n\t\t\t\t\tc.constructor = newType;\n\t\t\t\t\tc.render = doRender;\n\t\t\t\t}\n\t\t\t\tif (provider) provider.sub(c);\n\n\t\t\t\tif (!c.state) c.state = {};\n\t\t\t\tc._globalContext = globalContext;\n\t\t\t\tisNew = c._dirty = true;\n\t\t\t\tc._renderCallbacks = [];\n\t\t\t\tc._stateCallbacks = [];\n\t\t\t}\n\n\t\t\t// Invoke getDerivedStateFromProps\n\t\t\tif (isClassComponent \u0026\u0026 c._nextState == NULL) {\n\t\t\t\tc._nextState = c.state;\n\t\t\t}\n\n\t\t\tif (isClassComponent \u0026\u0026 newType.getDerivedStateFromProps != NULL) {\n\t\t\t\tif (c._nextState == c.state) {\n\t\t\t\t\tc._nextState = assign({}, c._nextState);\n\t\t\t\t}\n\n\t\t\t\tassign(\n\t\t\t\t\tc._nextState,\n\t\t\t\t\tnewType.getDerivedStateFromProps(newProps, c._nextState)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\toldProps = c.props;\n\t\t\toldState = c.state;\n\t\t\tc._vnode = newVNode;\n\n\t\t\t// Invoke pre-render lifecycle methods\n\t\t\tif (isNew) {\n\t\t\t\tif (\n\t\t\t\t\tisClassComponent \u0026\u0026\n\t\t\t\t\tnewType.getDerivedStateFromProps == NULL \u0026\u0026\n\t\t\t\t\tc.componentWillMount != NULL\n\t\t\t\t) {\n\t\t\t\t\tc.componentWillMount();\n\t\t\t\t}\n\n\t\t\t\tif (isClassComponent \u0026\u0026 c.componentDidMount != NULL) {\n\t\t\t\t\tc._renderCallbacks.push(c.componentDidMount);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tisClassComponent \u0026\u0026\n\t\t\t\t\tnewType.getDerivedStateFromProps == NULL \u0026\u0026\n\t\t\t\t\tnewProps !== oldProps \u0026\u0026\n\t\t\t\t\tc.componentWillReceiveProps != NULL\n\t\t\t\t) {\n\t\t\t\t\tc.componentWillReceiveProps(newProps, componentContext);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tnewVNode._original == oldVNode._original ||\n\t\t\t\t\t(!c._force \u0026\u0026\n\t\t\t\t\t\tc.shouldComponentUpdate != NULL \u0026\u0026\n\t\t\t\t\t\tc.shouldComponentUpdate(\n\t\t\t\t\t\t\tnewProps,\n\t\t\t\t\t\t\tc._nextState,\n\t\t\t\t\t\t\tcomponentContext\n\t\t\t\t\t\t) === false)\n\t\t\t\t) {\n\t\t\t\t\t// More info about this here: https://gist.github.com/JoviDeCroock/bec5f2ce93544d2e6070ef8e0036e4e8\n\t\t\t\t\tif (newVNode._original != oldVNode._original) {\n\t\t\t\t\t\t// When we are dealing with a bail because of sCU we have to update\n\t\t\t\t\t\t// the props, state and dirty-state.\n\t\t\t\t\t\t// when we are dealing with strict-equality we don't as the child could still\n\t\t\t\t\t\t// be dirtied see #3883\n\t\t\t\t\t\tc.props = newProps;\n\t\t\t\t\t\tc.state = c._nextState;\n\t\t\t\t\t\tc._dirty = false;\n\t\t\t\t\t}\n\n\t\t\t\t\tnewVNode._dom = oldVNode._dom;\n\t\t\t\t\tnewVNode._children = oldVNode._children;\n\t\t\t\t\tnewVNode._children.some(vnode =\u003e {\n\t\t\t\t\t\tif (vnode) vnode._parent = newVNode;\n\t\t\t\t\t});\n\n\t\t\t\t\tEMPTY_ARR.push.apply(c._renderCallbacks, c._stateCallbacks);\n\t\t\t\t\tc._stateCallbacks = [];\n\n\t\t\t\t\tif (c._renderCallbacks.length) {\n\t\t\t\t\t\tcommitQueue.push(c);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak outer;\n\t\t\t\t}\n\n\t\t\t\tif (c.componentWillUpdate != NULL) {\n\t\t\t\t\tc.componentWillUpdate(newProps, c._nextState, componentContext);\n\t\t\t\t}\n\n\t\t\t\tif (isClassComponent \u0026\u0026 c.componentDidUpdate != NULL) {\n\t\t\t\t\tc._renderCallbacks.push(() =\u003e {\n\t\t\t\t\t\tc.componentDidUpdate(oldProps, oldState, snapshot);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tc.context = componentContext;\n\t\t\tc.props = newProps;\n\t\t\tc._parentDom = parentDom;\n\t\t\tc._force = false;\n\n\t\t\tlet renderHook = options._render,\n\t\t\t\tcount = 0;\n\t\t\tif (isClassComponent) {\n\t\t\t\tc.state = c._nextState;\n\t\t\t\tc._dirty = false;\n\n\t\t\t\tif (renderHook) renderHook(newVNode);\n\n\t\t\t\ttmp = c.render(c.props, c.state, c.context);\n\n\t\t\t\tEMPTY_ARR.push.apply(c._renderCallbacks, c._stateCallbacks);\n\t\t\t\tc._stateCallbacks = [];\n\t\t\t} else {\n\t\t\t\tdo {\n\t\t\t\t\tc._dirty = false;\n\t\t\t\t\tif (renderHook) renderHook(newVNode);\n\n\t\t\t\t\ttmp = c.render(c.props, c.state, c.context);\n\n\t\t\t\t\t// Handle setState called in render, see #2553\n\t\t\t\t\tc.state = c._nextState;\n\t\t\t\t} while (c._dirty \u0026\u0026 ++count \u003c 25);\n\t\t\t}\n\n\t\t\t// Handle setState called in render, see #2553\n\t\t\tc.state = c._nextState;\n\n\t\t\tif (c.getChildContext != NULL) {\n\t\t\t\tglobalContext = assign(assign({}, globalContext), c.getChildContext());\n\t\t\t}\n\n\t\t\tif (isClassComponent \u0026\u0026 !isNew \u0026\u0026 c.getSnapshotBeforeUpdate != NULL) {\n\t\t\t\tsnapshot = c.getSnapshotBeforeUpdate(oldProps, oldState);\n\t\t\t}\n\n\t\t\tlet renderResult =\n\t\t\t\ttmp != NULL \u0026\u0026 tmp.type === Fragment \u0026\u0026 tmp.key == NULL\n\t\t\t\t\t? cloneNode(tmp.props.children)\n\t\t\t\t\t: tmp;\n\n\t\t\toldDom = diffChildren(\n\t\t\t\tparentDom,\n\t\t\t\tisArray(renderResult) ? renderResult : [renderResult],\n\t\t\t\tnewVNode,\n\t\t\t\toldVNode,\n\t\t\t\tglobalContext,\n\t\t\t\tnamespace,\n\t\t\t\texcessDomChildren,\n\t\t\t\tcommitQueue,\n\t\t\t\toldDom,\n\t\t\t\tisHydrating,\n\t\t\t\trefQueue\n\t\t\t);\n\n\t\t\tc.base = newVNode._dom;\n\n\t\t\t// We successfully rendered this VNode, unset any stored hydration/bailout state:\n\t\t\tnewVNode._flags \u0026= RESET_MODE;\n\n\t\t\tif (c._renderCallbacks.length) {\n\t\t\t\tcommitQueue.push(c);\n\t\t\t}\n\n\t\t\tif (clearProcessingException) {\n\t\t\t\tc._pendingError = c._processingException = NULL;\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tnewVNode._original = NULL;\n\t\t\t// if hydrating or creating initial tree, bailout preserves DOM:\n\t\t\tif (isHydrating || excessDomChildren != NULL) {\n\t\t\t\tif (e.then) {\n\t\t\t\t\tnewVNode._flags |= isHydrating\n\t\t\t\t\t\t? MODE_HYDRATE | MODE_SUSPENDED\n\t\t\t\t\t\t: MODE_SUSPENDED;\n\n\t\t\t\t\twhile (oldDom \u0026\u0026 oldDom.nodeType == 8 \u0026\u0026 oldDom.nextSibling) {\n\t\t\t\t\t\toldDom = oldDom.nextSibling;\n\t\t\t\t\t}\n\n\t\t\t\t\texcessDomChildren[excessDomChildren.indexOf(oldDom)] = NULL;\n\t\t\t\t\tnewVNode._dom = oldDom;\n\t\t\t\t} else {\n\t\t\t\t\tfor (let i = excessDomChildren.length; i--; ) {\n\t\t\t\t\t\tremoveNode(excessDomChildren[i]);\n\t\t\t\t\t}\n\t\t\t\t\tmarkAsForce(newVNode);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnewVNode._dom = oldVNode._dom;\n\t\t\t\tnewVNode._children = oldVNode._children;\n\t\t\t\tif (!e.then) markAsForce(newVNode);\n\t\t\t}\n\t\t\toptions._catchError(e, newVNode, oldVNode);\n\t\t}\n\t} else if (\n\t\texcessDomChildren == NULL \u0026\u0026\n\t\tnewVNode._original == oldVNode._original\n\t) {\n\t\tnewVNode._children = oldVNode._children;\n\t\tnewVNode._dom = oldVNode._dom;\n\t} else {\n\t\toldDom = newVNode._dom = diffElementNodes(\n\t\t\toldVNode._dom,\n\t\t\tnewVNode,\n\t\t\toldVNode,\n\t\t\tglobalContext,\n\t\t\tnamespace,\n\t\t\texcessDomChildren,\n\t\t\tcommitQueue,\n\t\t\tisHydrating,\n\t\t\trefQueue\n\t\t);\n\t}\n\n\tif ((tmp = options.diffed)) tmp(newVNode);\n\n\treturn newVNode._flags \u0026 MODE_SUSPENDED ? undefined : oldDom;\n}\n\nfunction markAsForce(vnode) {\n\tif (vnode) {\n\t\tif (vnode._component) vnode._component._force = true;\n\t\tif (vnode._children) vnode._children.some(markAsForce);\n\t}\n}\n\n/**\n * @param {Array\u003cComponent\u003e} commitQueue List of components\n * which have callbacks to invoke in commitRoot\n * @param {VNode} root\n */\nexport function commitRoot(commitQueue, root, refQueue) {\n\tfor (let i = 0; i \u003c refQueue.length; i++) {\n\t\tapplyRef(refQueue[i], refQueue[++i], refQueue[++i]);\n\t}\n\n\tif (options._commit) options._commit(root, commitQueue);\n\n\tcommitQueue.some(c =\u003e {\n\t\ttry {\n\t\t\t// @ts-expect-error Reuse the commitQueue variable here so the type changes\n\t\t\tcommitQueue = c._renderCallbacks;\n\t\t\tc._renderCallbacks = [];\n\t\t\tcommitQueue.some(cb =\u003e {\n\t\t\t\t// @ts-expect-error See above comment on commitQueue\n\t\t\t\tcb.call(c);\n\t\t\t});\n\t\t} catch (e) {\n\t\t\toptions._catchError(e, c._vnode);\n\t\t}\n\t});\n}\n\nfunction cloneNode(node) {\n\tif (typeof node != 'object' || node == NULL || node._depth \u003e 0) {\n\t\treturn node;\n\t}\n\n\tif (isArray(node)) {\n\t\treturn node.map(cloneNode);\n\t}\n\n\treturn assign({}, node);\n}\n\n/**\n * Diff two virtual nodes representing DOM element\n * @param {PreactElement} dom The DOM element representing the virtual nodes\n * being diffed\n * @param {VNode} newVNode The new virtual node\n * @param {VNode} oldVNode The old virtual node\n * @param {object} globalContext The current context object\n * @param {string} namespace Current namespace of the DOM node (HTML, SVG, or MathML)\n * @param {Array\u003cPreactElement\u003e} excessDomChildren\n * @param {Array\u003cComponent\u003e} commitQueue List of components which have callbacks\n * to invoke in commitRoot\n * @param {boolean} isHydrating Whether or not we are in hydration\n * @param {any[]} refQueue an array of elements needed to invoke refs\n * @returns {PreactElement}\n */\nfunction diffElementNodes(\n\tdom,\n\tnewVNode,\n\toldVNode,\n\tglobalContext,\n\tnamespace,\n\texcessDomChildren,\n\tcommitQueue,\n\tisHydrating,\n\trefQueue\n) {\n\tlet oldProps = oldVNode.props || EMPTY_OBJ;\n\tlet newProps = newVNode.props;\n\tlet nodeType = /** @type {string} */ (newVNode.type);\n\t/** @type {any} */\n\tlet i;\n\t/** @type {{ __html?: string }} */\n\tlet newHtml;\n\t/** @type {{ __html?: string }} */\n\tlet oldHtml;\n\t/** @type {ComponentChildren} */\n\tlet newChildren;\n\tlet value;\n\tlet inputValue;\n\tlet checked;\n\n\t// Tracks entering and exiting namespaces when descending through the tree.\n\tif (nodeType == 'svg') namespace = SVG_NAMESPACE;\n\telse if (nodeType == 'math') namespace = MATH_NAMESPACE;\n\telse if (!namespace) namespace = XHTML_NAMESPACE;\n\n\tif (excessDomChildren != NULL) {\n\t\tfor (i = 0; i \u003c excessDomChildren.length; i++) {\n\t\t\tvalue = excessDomChildren[i];\n\n\t\t\t// if newVNode matches an element in excessDomChildren or the `dom`\n\t\t\t// argument matches an element in excessDomChildren, remove it from\n\t\t\t// excessDomChildren so it isn't later removed in diffChildren\n\t\t\tif (\n\t\t\t\tvalue \u0026\u0026\n\t\t\t\t'setAttribute' in value == !!nodeType \u0026\u0026\n\t\t\t\t(nodeType ? value.localName == nodeType : value.nodeType == 3)\n\t\t\t) {\n\t\t\t\tdom = value;\n\t\t\t\texcessDomChildren[i] = NULL;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (dom == NULL) {\n\t\tif (nodeType == NULL) {\n\t\t\treturn document.createTextNode(newProps);\n\t\t}\n\n\t\tdom = document.createElementNS(\n\t\t\tnamespace,\n\t\t\tnodeType,\n\t\t\tnewProps.is \u0026\u0026 newProps\n\t\t);\n\n\t\t// we are creating a new node, so we can assume this is a new subtree (in\n\t\t// case we are hydrating), this deopts the hydrate\n\t\tif (isHydrating) {\n\t\t\tif (options._hydrationMismatch)\n\t\t\t\toptions._hydrationMismatch(newVNode, excessDomChildren);\n\t\t\tisHydrating = false;\n\t\t}\n\t\t// we created a new parent, so none of the previously attached children can be reused:\n\t\texcessDomChildren = NULL;\n\t}\n\n\tif (nodeType == NULL) {\n\t\t// During hydration, we still have to split merged text from SSR'd HTML.\n\t\tif (oldProps !== newProps \u0026\u0026 (!isHydrating || dom.data != newProps)) {\n\t\t\tdom.data = newProps;\n\t\t}\n\t} else {\n\t\t// If excessDomChildren was not null, repopulate it with the current element's children:\n\t\texcessDomChildren = excessDomChildren \u0026\u0026 slice.call(dom.childNodes);\n\n\t\t// If we are in a situation where we are not hydrating but are using\n\t\t// existing DOM (e.g. replaceNode) we should read the existing DOM\n\t\t// attributes to diff them\n\t\tif (!isHydrating \u0026\u0026 excessDomChildren != NULL) {\n\t\t\toldProps = {};\n\t\t\tfor (i = 0; i \u003c dom.attributes.length; i++) {\n\t\t\t\tvalue = dom.attributes[i];\n\t\t\t\toldProps[value.name] = value.value;\n\t\t\t}\n\t\t}\n\n\t\tfor (i in oldProps) {\n\t\t\tvalue = oldProps[i];\n\t\t\tif (i == 'dangerouslySetInnerHTML') {\n\t\t\t\toldHtml = value;\n\t\t\t} else if (\n\t\t\t\ti != 'children' \u0026\u0026\n\t\t\t\t!(i in newProps) \u0026\u0026\n\t\t\t\t!(i == 'value' \u0026\u0026 'defaultValue' in newProps) \u0026\u0026\n\t\t\t\t!(i == 'checked' \u0026\u0026 'defaultChecked' in newProps)\n\t\t\t) {\n\t\t\t\tsetProperty(dom, i, NULL, value, namespace);\n\t\t\t}\n\t\t}\n\n\t\t// During hydration, props are not diffed at all (including dangerouslySetInnerHTML)\n\t\t// @TODO we should warn in debug mode when props don't match here.\n\t\tfor (i in newProps) {\n\t\t\tvalue = newProps[i];\n\t\t\tif (i == 'children') {\n\t\t\t\tnewChildren = value;\n\t\t\t} else if (i == 'dangerouslySetInnerHTML') {\n\t\t\t\tnewHtml = value;\n\t\t\t} else if (i == 'value') {\n\t\t\t\tinputValue = value;\n\t\t\t} else if (i == 'checked') {\n\t\t\t\tchecked = value;\n\t\t\t} else if (\n\t\t\t\t(!isHydrating || typeof value == 'function') \u0026\u0026\n\t\t\t\toldProps[i] !== value\n\t\t\t) {\n\t\t\t\tsetProperty(dom, i, value, oldProps[i], namespace);\n\t\t\t}\n\t\t}\n\n\t\t// If the new vnode didn't have dangerouslySetInnerHTML, diff its children\n\t\tif (newHtml) {\n\t\t\t// Avoid re-applying the same '__html' if it did not changed between re-render\n\t\t\tif (\n\t\t\t\t!isHydrating \u0026\u0026\n\t\t\t\t(!oldHtml ||\n\t\t\t\t\t(newHtml.__html != oldHtml.__html \u0026\u0026 newHtml.__html != dom.innerHTML))\n\t\t\t) {\n\t\t\t\tdom.innerHTML = newHtml.__html;\n\t\t\t}\n\n\t\t\tnewVNode._children = [];\n\t\t} else {\n\t\t\tif (oldHtml) dom.innerHTML = '';\n\n\t\t\tdiffChildren(\n\t\t\t\t// @ts-expect-error\n\t\t\t\tnewVNode.type == 'template' ? dom.content : dom,\n\t\t\t\tisArray(newChildren) ? newChildren : [newChildren],\n\t\t\t\tnewVNode,\n\t\t\t\toldVNode,\n\t\t\t\tglobalContext,\n\t\t\t\tnodeType == 'foreignObject' ? XHTML_NAMESPACE : namespace,\n\t\t\t\texcessDomChildren,\n\t\t\t\tcommitQueue,\n\t\t\t\texcessDomChildren\n\t\t\t\t\t? excessDomChildren[0]\n\t\t\t\t\t: oldVNode._children \u0026\u0026 getDomSibling(oldVNode, 0),\n\t\t\t\tisHydrating,\n\t\t\t\trefQueue\n\t\t\t);\n\n\t\t\t// Remove children that are not part of any vnode.\n\t\t\tif (excessDomChildren != NULL) {\n\t\t\t\tfor (i = excessDomChildren.length; i--; ) {\n\t\t\t\t\tremoveNode(excessDomChildren[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// As above, don't diff props during hydration\n\t\tif (!isHydrating) {\n\t\t\ti = 'value';\n\t\t\tif (nodeType == 'progress' \u0026\u0026 inputValue == NULL) {\n\t\t\t\tdom.removeAttribute('value');\n\t\t\t} else if (\n\t\t\t\tinputValue != UNDEFINED \u0026\u0026\n\t\t\t\t// #2756 For the \u003cprogress\u003e-element the initial value is 0,\n\t\t\t\t// despite the attribute not being present. When the attribute\n\t\t\t\t// is missing the progress bar is treated as indeterminate.\n\t\t\t\t// To fix that we'll always update it when it is 0 for progress elements\n\t\t\t\t(inputValue !== dom[i] ||\n\t\t\t\t\t(nodeType == 'progress' \u0026\u0026 !inputValue) ||\n\t\t\t\t\t// This is only for IE 11 to fix \u003cselect\u003e value not being updated.\n\t\t\t\t\t// To avoid a stale select value we need to set the option.value\n\t\t\t\t\t// again, which triggers IE11 to re-evaluate the select value\n\t\t\t\t\t(nodeType == 'option' \u0026\u0026 inputValue != oldProps[i]))\n\t\t\t) {\n\t\t\t\tsetProperty(dom, i, inputValue, oldProps[i], namespace);\n\t\t\t}\n\n\t\t\ti = 'checked';\n\t\t\tif (checked != UNDEFINED \u0026\u0026 checked != dom[i]) {\n\t\t\t\tsetProperty(dom, i, checked, oldProps[i], namespace);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn dom;\n}\n\n/**\n * Invoke or update a ref, depending on whether it is a function or object ref.\n * @param {Ref\u003cany\u003e \u0026 { _unmount?: unknown }} ref\n * @param {any} value\n * @param {VNode} vnode\n */\nexport function applyRef(ref, value, vnode) {\n\ttry {\n\t\tif (typeof ref == 'function') {\n\t\t\tlet hasRefUnmount = typeof ref._unmount == 'function';\n\t\t\tif (hasRefUnmount) {\n\t\t\t\t// @ts-ignore TS doesn't like moving narrowing checks into variables\n\t\t\t\tref._unmount();\n\t\t\t}\n\n\t\t\tif (!hasRefUnmount || value != NULL) {\n\t\t\t\t// Store the cleanup function on the function\n\t\t\t\t// instance object itself to avoid shape\n\t\t\t\t// transitioning vnode\n\t\t\t\tref._unmount = ref(value);\n\t\t\t}\n\t\t} else ref.current = value;\n\t} catch (e) {\n\t\toptions._catchError(e, vnode);\n\t}\n}\n\n/**\n * Unmount a virtual node from the tree and apply DOM changes\n * @param {VNode} vnode The virtual node to unmount\n * @param {VNode} parentVNode The parent of the VNode that initiated the unmount\n * @param {boolean} [skipRemove] Flag that indicates that a parent node of the\n * current element is already detached from the DOM.\n */\nexport function unmount(vnode, parentVNode, skipRemove) {\n\tlet r;\n\tif (options.unmount) options.unmount(vnode);\n\n\tif ((r = vnode.ref)) {\n\t\tif (!r.current || r.current == vnode._dom) {\n\t\t\tapplyRef(r, NULL, parentVNode);\n\t\t}\n\t}\n\n\tif ((r = vnode._component) != NULL) {\n\t\tif (r.componentWillUnmount) {\n\t\t\ttry {\n\t\t\t\tr.componentWillUnmount();\n\t\t\t} catch (e) {\n\t\t\t\toptions._catchError(e, parentVNode);\n\t\t\t}\n\t\t}\n\n\t\tr.base = r._parentDom = NULL;\n\t}\n\n\tif ((r = vnode._children)) {\n\t\tfor (let i = 0; i \u003c r.length; i++) {\n\t\t\tif (r[i]) {\n\t\t\t\tunmount(\n\t\t\t\t\tr[i],\n\t\t\t\t\tparentVNode,\n\t\t\t\t\tskipRemove || typeof vnode.type != 'function'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!skipRemove) {\n\t\tremoveNode(vnode._dom);\n\t}\n\n\tvnode._component = vnode._parent = vnode._dom = UNDEFINED;\n}\n\n/** The `.render()` method for a PFC backing instance. */\nfunction doRender(props, state, context) {\n\treturn this.constructor(props, context);\n}\n","import { EMPTY_OBJ, NULL } from './constants';\nimport { commitRoot, diff } from './diff/index';\nimport { createElement, Fragment } from './create-element';\nimport options from './options';\nimport { slice } from './util';\n\n/**\n * Render a Preact virtual node into a DOM element\n * @param {import('./internal').ComponentChild} vnode The virtual node to render\n * @param {import('./internal').PreactElement} parentDom The DOM element to render into\n * @param {import('./internal').PreactElement | object} [replaceNode] Optional: Attempt to re-use an\n * existing DOM tree rooted at `replaceNode`\n */\nexport function render(vnode, parentDom, replaceNode) {\n\t// https://github.com/preactjs/preact/issues/3794\n\tif (parentDom == document) {\n\t\tparentDom = document.documentElement;\n\t}\n\n\tif (options._root) options._root(vnode, parentDom);\n\n\t// We abuse the `replaceNode` parameter in `hydrate()` to signal if we are in\n\t// hydration mode or not by passing the `hydrate` function instead of a DOM\n\t// element..\n\tlet isHydrating = typeof replaceNode == 'function';\n\n\t// To be able to support calling `render()` multiple times on the same\n\t// DOM node, we need to obtain a reference to the previous tree. We do\n\t// this by assigning a new `_children` property to DOM nodes which points\n\t// to the last rendered tree. By default this property is not present, which\n\t// means that we are mounting a new tree for the first time.\n\tlet oldVNode = isHydrating\n\t\t? NULL\n\t\t: (replaceNode \u0026\u0026 replaceNode._children) || parentDom._children;\n\n\tvnode = ((!isHydrating \u0026\u0026 replaceNode) || parentDom)._children =\n\t\tcreateElement(Fragment, NULL, [vnode]);\n\n\t// List of effects that need to be called after diffing.\n\tlet commitQueue = [],\n\t\trefQueue = [];\n\tdiff(\n\t\tparentDom,\n\t\t// Determine the new vnode tree and store it on the DOM element on\n\t\t// our custom `_children` property.\n\t\tvnode,\n\t\toldVNode || EMPTY_OBJ,\n\t\tEMPTY_OBJ,\n\t\tparentDom.namespaceURI,\n\t\t!isHydrating \u0026\u0026 replaceNode\n\t\t\t? [replaceNode]\n\t\t\t: oldVNode\n\t\t\t\t? NULL\n\t\t\t\t: parentDom.firstChild\n\t\t\t\t\t? slice.call(parentDom.childNodes)\n\t\t\t\t\t: NULL,\n\t\tcommitQueue,\n\t\t!isHydrating \u0026\u0026 replaceNode\n\t\t\t? replaceNode\n\t\t\t: oldVNode\n\t\t\t\t? oldVNode._dom\n\t\t\t\t: parentDom.firstChild,\n\t\tisHydrating,\n\t\trefQueue\n\t);\n\n\t// Flush all queued effects\n\tcommitRoot(commitQueue, vnode, refQueue);\n}\n\n/**\n * Update an existing DOM element with data from a Preact virtual node\n * @param {import('./internal').ComponentChild} vnode The virtual node to render\n * @param {import('./internal').PreactElement} parentDom The DOM element to update\n */\nexport function hydrate(vnode, parentDom) {\n\trender(vnode, parentDom, hydrate);\n}\n","import { assign, slice } from './util';\nimport { createVNode } from './create-element';\nimport { NULL, UNDEFINED } from './constants';\n\n/**\n * Clones the given VNode, optionally adding attributes/props and replacing its\n * children.\n * @param {import('./internal').VNode} vnode The virtual DOM element to clone\n * @param {object} props Attributes/props to add when cloning\n * @param {Array\u003cimport('./internal').ComponentChildren\u003e} rest Any additional arguments will be used\n * as replacement children.\n * @returns {import('./internal').VNode}\n */\nexport function cloneElement(vnode, props, children) {\n\tlet normalizedProps = assign({}, vnode.props),\n\t\tkey,\n\t\tref,\n\t\ti;\n\n\tlet defaultProps;\n\n\tif (vnode.type \u0026\u0026 vnode.type.defaultProps) {\n\t\tdefaultProps = vnode.type.defaultProps;\n\t}\n\n\tfor (i in props) {\n\t\tif (i == 'key') key = props[i];\n\t\telse if (i == 'ref') ref = props[i];\n\t\telse if (props[i] === UNDEFINED \u0026\u0026 defaultProps != UNDEFINED) {\n\t\t\tnormalizedProps[i] = defaultProps[i];\n\t\t} else {\n\t\t\tnormalizedProps[i] = props[i];\n\t\t}\n\t}\n\n\tif (arguments.length \u003e 2) {\n\t\tnormalizedProps.children =\n\t\t\targuments.length \u003e 3 ? slice.call(arguments, 2) : children;\n\t}\n\n\treturn createVNode(\n\t\tvnode.type,\n\t\tnormalizedProps,\n\t\tkey || vnode.key,\n\t\tref || vnode.ref,\n\t\tNULL\n\t);\n}\n","import { NULL } from '../constants';\n\n/**\n * Find the closest error boundary to a thrown error and call it\n * @param {object} error The thrown value\n * @param {import('../internal').VNode} vnode The vnode that threw the error that was caught (except\n * for unmounting when this parameter is the highest parent that was being\n * unmounted)\n * @param {import('../internal').VNode} [oldVNode]\n * @param {import('../internal').ErrorInfo} [errorInfo]\n */\nexport function _catchError(error, vnode, oldVNode, errorInfo) {\n\t/** @type {import('../internal').Component} */\n\tlet component,\n\t\t/** @type {import('../internal').ComponentType} */\n\t\tctor,\n\t\t/** @type {boolean} */\n\t\thandled;\n\n\tfor (; (vnode = vnode._parent); ) {\n\t\tif ((component = vnode._component) \u0026\u0026 !component._processingException) {\n\t\t\ttry {\n\t\t\t\tctor = component.constructor;\n\n\t\t\t\tif (ctor \u0026\u0026 ctor.getDerivedStateFromError != NULL) {\n\t\t\t\t\tcomponent.setState(ctor.getDerivedStateFromError(error));\n\t\t\t\t\thandled = component._dirty;\n\t\t\t\t}\n\n\t\t\t\tif (component.componentDidCatch != NULL) {\n\t\t\t\t\tcomponent.componentDidCatch(error, errorInfo || {});\n\t\t\t\t\thandled = component._dirty;\n\t\t\t\t}\n\n\t\t\t\t// This is an error boundary. Mark it as having bailed out, and whether it was mid-hydration.\n\t\t\t\tif (handled) {\n\t\t\t\t\treturn (component._pendingError = component);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\terror = e;\n\t\t\t}\n\t\t}\n\t}\n\n\tthrow error;\n}\n"],"version":3}
+14
vendor/importmap.js
··· 1 + const importmap = document.createElement("script"); 2 + importmap.type = "importmap"; 3 + importmap.textContent = JSON.stringify({ 4 + imports: { 5 + "@atcute/client": "/atprotocall/vendor/esm.sh/@atcute/client@4.2.1/es2022/client.mjs", 6 + "@atcute/identity-resolver": "/atprotocall/vendor/esm.sh/@atcute/identity-resolver@1.2.2/es2022/identity-resolver.mjs", 7 + "@atcute/oauth-browser-client": "/atprotocall/vendor/esm.sh/@atcute/oauth-browser-client@3.0.0/es2022/oauth-browser-client.mjs", 8 + "@preact/signals": "/atprotocall/vendor/esm.sh/@preact/signals@2.9.0/X-ZXByZWFjdA/es2022/signals.mjs", 9 + "htm/preact": "/atprotocall/vendor/esm.sh/htm@3.1.1/X-ZXByZWFjdA/es2022/preact.mjs", 10 + "preact": "/atprotocall/vendor/esm.sh/preact@10.29.1/es2022/preact.mjs", 11 + "preact/hooks": "/atprotocall/vendor/esm.sh/preact@10.29.1/es2022/hooks.mjs", 12 + }, 13 + }); 14 + document.currentScript.after(importmap);
+11
vendor/importmap.json
··· 1 + { 2 + "imports": { 3 + "@atcute/client": "/atprotocall/vendor/esm.sh/@atcute/client@4.2.1/es2022/client.mjs", 4 + "@atcute/identity-resolver": "/atprotocall/vendor/esm.sh/@atcute/identity-resolver@1.2.2/es2022/identity-resolver.mjs", 5 + "@atcute/oauth-browser-client": "/atprotocall/vendor/esm.sh/@atcute/oauth-browser-client@3.0.0/es2022/oauth-browser-client.mjs", 6 + "@preact/signals": "/atprotocall/vendor/esm.sh/@preact/signals@2.9.0/X-ZXByZWFjdA/es2022/signals.mjs", 7 + "htm/preact": "/atprotocall/vendor/esm.sh/htm@3.1.1/X-ZXByZWFjdA/es2022/preact.mjs", 8 + "preact": "/atprotocall/vendor/esm.sh/preact@10.29.1/es2022/preact.mjs", 9 + "preact/hooks": "/atprotocall/vendor/esm.sh/preact@10.29.1/es2022/hooks.mjs" 10 + } 11 + }
+27
vendor/jsconfig.json
··· 1 + { 2 + "compilerOptions": { 3 + "paths": { 4 + "@atcute/client": [ 5 + "./esm.sh/@atcute/client@4.2.1/es2022/client.mjs" 6 + ], 7 + "@atcute/identity-resolver": [ 8 + "./esm.sh/@atcute/identity-resolver@1.2.2/es2022/identity-resolver.mjs" 9 + ], 10 + "@atcute/oauth-browser-client": [ 11 + "./esm.sh/@atcute/oauth-browser-client@3.0.0/es2022/oauth-browser-client.mjs" 12 + ], 13 + "@preact/signals": [ 14 + "./esm.sh/@preact/signals@2.9.0/X-ZXByZWFjdA/es2022/signals.mjs" 15 + ], 16 + "htm/preact": [ 17 + "./esm.sh/htm@3.1.1/X-ZXByZWFjdA/es2022/preact.mjs" 18 + ], 19 + "preact": [ 20 + "./esm.sh/preact@10.29.1/es2022/preact.mjs" 21 + ], 22 + "preact/hooks": [ 23 + "./esm.sh/preact@10.29.1/es2022/hooks.mjs" 24 + ] 25 + } 26 + } 27 + }