@shumai-one/shumai 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/chunk-02b5bcmc.js +1 -0
- package/bin/{chunk-m0q2cgfg.js → chunk-09mj32d7.js} +1 -1
- package/bin/{chunk-b7bnp021.js → chunk-09mpcg9x.js} +2 -2
- package/bin/{chunk-257dcd2f.js → chunk-0a298n62.js} +2 -2
- package/bin/{chunk-cz13a82m.js → chunk-0rgbxp24.js} +2 -2
- package/bin/{chunk-mwktrwtx.js → chunk-19zbh4fr.js} +1 -1
- package/bin/{chunk-v05rrxp5.js → chunk-1e1q1hyg.js} +2 -2
- package/bin/{chunk-fatmqnp1.js → chunk-1ja2zw4w.js} +1 -1
- package/bin/chunk-1tar0x8s.js +7 -0
- package/bin/{chunk-1nvd90g2.js → chunk-1y6h4vge.js} +1 -1
- package/bin/{chunk-tekwpkjf.js → chunk-20bamhwa.js} +2 -2
- package/bin/{chunk-8mqbztj8.js → chunk-20w1w9x7.js} +2 -2
- package/bin/{chunk-qwpkcp8d.js → chunk-25npafhz.js} +2 -2
- package/bin/{chunk-km4gn6b6.js → chunk-2qgagdb7.js} +1 -1
- package/bin/chunk-2t6g3pny.js +3 -0
- package/bin/{chunk-ns33grgx.js → chunk-34f64q0q.js} +1 -1
- package/bin/{chunk-1wfg56z3.js → chunk-3hgrw1m0.js} +4 -4
- package/bin/{chunk-p3f5aevs.js → chunk-3s2ga6mt.js} +1 -1
- package/bin/{chunk-hzkjgcre.js → chunk-3vpz5nat.js} +1 -1
- package/bin/{chunk-2jj4j8cn.js → chunk-4p31kxjh.js} +2 -2
- package/bin/{chunk-9t3p4xp6.js → chunk-4vjgdj0h.js} +1 -1
- package/bin/{chunk-96qpjght.js → chunk-50pfmxt1.js} +2 -2
- package/bin/{chunk-2cdxm1cp.js → chunk-5ddg5ezb.js} +9 -9
- package/bin/chunk-5ngftxjb.js +218 -0
- package/bin/{chunk-r1xer8gn.js → chunk-6f3zhq64.js} +3 -3
- package/bin/chunk-6nqqe7w9.js +1 -0
- package/bin/{chunk-h1n7jqnw.js → chunk-6t525bmg.js} +1 -1
- package/bin/{chunk-01052ssf.js → chunk-7546ptwg.js} +11 -11
- package/bin/{chunk-82tps5n1.js → chunk-7jz3cmq6.js} +1 -1
- package/bin/{chunk-v5cn90cf.js → chunk-7kah3zb5.js} +2 -2
- package/bin/{chunk-73yncv54.js → chunk-7mawxsk3.js} +2 -2
- package/bin/chunk-8ww98y1m.js +2 -0
- package/bin/{chunk-55h9ze53.js → chunk-9405hzv2.js} +2 -2
- package/bin/{chunk-cgmebxx6.js → chunk-95b4mwyq.js} +1 -1
- package/bin/chunk-9vxmgvc8.js +2 -0
- package/bin/{chunk-knj2s8mg.js → chunk-9x42vgeq.js} +5 -5
- package/bin/{chunk-7sgrtxbt.js → chunk-a859y4e1.js} +2 -2
- package/bin/{chunk-y241cxff.js → chunk-addssm8d.js} +1 -1
- package/bin/{chunk-f6avg5qe.js → chunk-ajq9sxg0.js} +33 -33
- package/bin/chunk-amp9h878.js +2 -0
- package/bin/{chunk-yk12hydf.js → chunk-atdfqdkj.js} +4 -4
- package/bin/{chunk-5wapd171.js → chunk-atpt99h4.js} +10 -10
- package/bin/chunk-awshe30f.js +1 -0
- package/bin/chunk-b3t7gbhm.js +2 -0
- package/bin/{chunk-e4f56spj.js → chunk-bbxwyhz3.js} +3 -3
- package/bin/{chunk-a411xhmm.js → chunk-bd3v8mp1.js} +4 -4
- package/bin/{chunk-167z646e.js → chunk-brgns7hv.js} +1 -1
- package/bin/{chunk-576nj64j.js → chunk-c02727j9.js} +2 -2
- package/bin/{chunk-8yjsmr7g.js → chunk-c1wvs81k.js} +1 -1
- package/bin/chunk-c8frmqsk.js +2 -0
- package/bin/{chunk-xc54vhfz.js → chunk-cagzye3j.js} +1 -1
- package/bin/{chunk-s9ksftq2.js → chunk-cp96e9pq.js} +1 -1
- package/bin/{chunk-q5vkxee3.js → chunk-d55138xx.js} +2 -2
- package/bin/{chunk-7v7mypc6.js → chunk-ddmf9gqv.js} +2 -2
- package/bin/chunk-djb65frk.js +1 -0
- package/bin/{chunk-q83h0hkx.js → chunk-dkhdn92k.js} +2 -2
- package/bin/chunk-dx9f5wab.js +1 -0
- package/bin/{chunk-f25fe9th.js → chunk-dygj751y.js} +11 -11
- package/bin/{chunk-m9adtgzk.js → chunk-e55sgg8t.js} +1 -1
- package/bin/{chunk-q8w4mbw4.js → chunk-enax4303.js} +2 -2
- package/bin/{chunk-vcrmjtcz.js → chunk-erfkd3z9.js} +2 -2
- package/bin/{chunk-8cjet7pp.js → chunk-esj0kwe5.js} +5 -5
- package/bin/{chunk-atfz7g7e.js → chunk-etrm28sy.js} +1 -1
- package/bin/chunk-ex3174e3.js +2 -0
- package/bin/{chunk-9n1w5dw1.js → chunk-ezjxx44x.js} +3 -3
- package/bin/{chunk-cf5axr8c.js → chunk-f4xnx4n6.js} +1 -1
- package/bin/{chunk-7naa7tpn.js → chunk-f8hgy69t.js} +2 -2
- package/bin/chunk-fakph5jp.js +1 -0
- package/bin/{chunk-kvhf12b4.js → chunk-femnbfkj.js} +1 -1
- package/bin/{chunk-ah8fjb6f.js → chunk-ffjdkdcv.js} +2 -2
- package/bin/{chunk-vkzasgxw.js → chunk-gd016e9p.js} +2 -2
- package/bin/{chunk-ympbfzz4.js → chunk-gyv3yrhj.js} +1 -1
- package/bin/{chunk-jzgbxqdg.js → chunk-h2bphev9.js} +2 -2
- package/bin/chunk-h3atwgx2.js +1 -0
- package/bin/chunk-h7xny3de.js +2 -0
- package/bin/{chunk-m82tkhaa.js → chunk-hg3rkp41.js} +5 -5
- package/bin/{chunk-3z85zxkn.js → chunk-hpzk9k55.js} +1 -1
- package/bin/{chunk-9zsv6d2f.js → chunk-hsyfrzdd.js} +1 -1
- package/bin/chunk-hvyy8vct.js +3 -0
- package/bin/{chunk-b5rhvzv9.js → chunk-j2txsbxz.js} +2 -2
- package/bin/chunk-j6x53e33.js +1 -0
- package/bin/chunk-jacanzp7.js +1 -0
- package/bin/{chunk-g6sdezec.js → chunk-jc7dycy6.js} +1 -1
- package/bin/{chunk-cwat1jwx.js → chunk-k7vbk8v4.js} +1 -1
- package/bin/{chunk-zrszykjf.js → chunk-mn0kt3p6.js} +1 -1
- package/bin/chunk-mn71dffh.js +4 -0
- package/bin/{chunk-vp3czaeh.js → chunk-npeapp7e.js} +2 -2
- package/bin/{chunk-2nhgdqdg.js → chunk-p2vsdnd1.js} +2 -2
- package/bin/chunk-pdw77q09.js +2 -0
- package/bin/{chunk-zezje74z.js → chunk-pq6kdp83.js} +3 -3
- package/bin/chunk-ptcz4ed3.js +2 -0
- package/bin/{chunk-z1p13dnc.js → chunk-q1fzgqsv.js} +2 -2
- package/bin/chunk-q4ny4hpt.js +2 -0
- package/bin/{chunk-mzsw9var.js → chunk-q5x0yywj.js} +2 -2
- package/bin/{chunk-g22wmpk1.js → chunk-q8xr1a8j.js} +2 -2
- package/bin/chunk-q8ysc5ex.js +1 -0
- package/bin/{chunk-1ktk6764.js → chunk-qm50g4n5.js} +4 -4
- package/bin/{chunk-q2bew2vc.js → chunk-qvp24w0q.js} +2 -2
- package/bin/{chunk-9xhjy897.js → chunk-r6t0j0jx.js} +3 -3
- package/bin/chunk-s1j4v33x.js +2 -0
- package/bin/{chunk-yq32evnn.js → chunk-s6pk2zyg.js} +5 -5
- package/bin/{chunk-hnkcgvcj.js → chunk-s74g9vsk.js} +1 -1
- package/bin/{chunk-gxepkvt2.js → chunk-sz19nn1x.js} +1 -1
- package/bin/{chunk-hpbn0k9n.js → chunk-sz5zawfw.js} +1 -1
- package/bin/chunk-t68y25gf.js +1 -0
- package/bin/{chunk-mcw198kg.js → chunk-te484xtb.js} +8 -8
- package/bin/{chunk-jt0ykktx.js → chunk-tfrevef9.js} +1 -1
- package/bin/chunk-thpw6tcj.js +2 -0
- package/bin/{chunk-02fvcrej.js → chunk-v0yevesp.js} +7 -7
- package/bin/chunk-vj4gamdn.js +2 -0
- package/bin/{chunk-p4s95471.js → chunk-vmwys2ch.js} +1 -1
- package/bin/{chunk-e4yscwen.js → chunk-vnmggrd6.js} +7 -7
- package/bin/{chunk-hpwv4am3.js → chunk-vv0m0m2f.js} +4 -4
- package/bin/{chunk-x03jwaga.js → chunk-w6g84d59.js} +4 -4
- package/bin/{chunk-3ckkwdjx.js → chunk-wgvgtttc.js} +3 -3
- package/bin/chunk-xy9qpn6b.js +1 -0
- package/bin/{chunk-mcj1xpcc.js → chunk-y3haqtr8.js} +2 -2
- package/bin/chunk-y5dv67mg.js +2 -0
- package/bin/{chunk-4mws03es.js → chunk-yb4mzqrd.js} +2 -2
- package/bin/{chunk-x8mjh387.js → chunk-z0de127n.js} +4 -4
- package/bin/chunk-z8t6e0ee.js +1 -0
- package/bin/chunk-zfg4yy3c.js +2 -0
- package/bin/{chunk-hw6czrya.js → chunk-zkvezz89.js} +1 -1
- package/bin/chunk-zrrnvdxq.js +3 -0
- package/bin/{chunk-srxp5jav.js → chunk-zx1c4vm5.js} +30 -30
- package/bin/chunk-zzqse5qc.js +2 -0
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +328 -328
- package/package.json +7 -7
- package/bin/chunk-0bj887zm.js +0 -2
- package/bin/chunk-26qn7fek.js +0 -2
- package/bin/chunk-2ne2b54t.js +0 -2
- package/bin/chunk-2vbeqczj.js +0 -1
- package/bin/chunk-37p6bcx2.js +0 -1
- package/bin/chunk-3knfx6dm.js +0 -1
- package/bin/chunk-54tbfvya.js +0 -2
- package/bin/chunk-56kh5fxc.js +0 -1
- package/bin/chunk-6cnqjngz.js +0 -1
- package/bin/chunk-7g46e1wy.js +0 -3
- package/bin/chunk-84x8p7v5.js +0 -1
- package/bin/chunk-8fyg9dy4.js +0 -2
- package/bin/chunk-8gtfgkrn.js +0 -2
- package/bin/chunk-8xb6yz11.js +0 -2
- package/bin/chunk-91rb0jpb.js +0 -2
- package/bin/chunk-9f1xk1nt.js +0 -1
- package/bin/chunk-9mk9cvbk.js +0 -1
- package/bin/chunk-9nw5w8vh.js +0 -1
- package/bin/chunk-dk42gf7v.js +0 -2
- package/bin/chunk-eb7mzbfm.js +0 -1
- package/bin/chunk-er14d498.js +0 -3
- package/bin/chunk-fvx9k1dc.js +0 -2
- package/bin/chunk-gtf19jc1.js +0 -2
- package/bin/chunk-hfm82066.js +0 -2
- package/bin/chunk-kj6h5j5a.js +0 -4
- package/bin/chunk-ny1kbmxt.js +0 -2
- package/bin/chunk-p3j6ydk1.js +0 -1
- package/bin/chunk-pk406dgy.js +0 -2
- package/bin/chunk-s1e4qy3q.js +0 -14
- package/bin/chunk-swtwaaqe.js +0 -1
- package/bin/chunk-tagdrg7p.js +0 -1
- package/bin/chunk-twtxnzbv.js +0 -2
- package/bin/chunk-v5mcjwxy.js +0 -2
- package/bin/chunk-x342vzdx.js +0 -2
- package/bin/chunk-xvkwbczx.js +0 -3
- package/bin/chunk-zarz3sqn.js +0 -211
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ye}from"./chunk-2jj4j8cn.js";var Yg={};Ye(Yg,{JOSEAlgNotAllowed:()=>X,JOSEError:()=>dn,JOSENotSupported:()=>m,JWEDecryptionFailed:()=>we,JWEInvalid:()=>u,JWKInvalid:()=>ge,JWKSInvalid:()=>Al,JWKSMultipleMatchingKeys:()=>yc,JWKSNoMatchingKey:()=>_l,JWKSTimeout:()=>yl,JWSInvalid:()=>Ur,JWSSignatureVerificationFailed:()=>$u,JWTClaimValidationFailed:()=>P,JWTExpired:()=>yi,JWTInvalid:()=>zr});var Cm={};Ye(Cm,{decode:()=>I,encode:()=>pr});var ye=new TextEncoder,F=new TextDecoder,te=new TextDecoder("utf-8",{fatal:!0});function b(...e){let t=e.reduce((o,{length:i})=>o+i,0),r=new Uint8Array(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function et(e,t,r){if(t<0||t>=4294967296)throw RangeError(`value must be >= 0 and <= 4294967295. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,t&255],r)}function tt(e){let t=Math.floor(e/4294967296),r=e%4294967296,n=new Uint8Array(8);return et(n,t,0),et(n,r,4),n}function Te(e){let t=new Uint8Array(4);return et(t,e),t}function g(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n>127)throw TypeError("non-ASCII string encountered in encode()");t[r]=n}return t}var Ie=(e,t="algorithm.name")=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);function rt(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function Oe(e,t){let{modulusLength:r}=t.algorithm;if(typeof r!=="number"||r<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}function N(e,t,r){let n=e.algorithm;if(n.name!==t.name)throw Ie(t.name);if(t.hash&&n.hash?.name!==t.hash)throw Ie(t.hash,"algorithm.hash");if(t.namedCurve&&n.namedCurve!==t.namedCurve)throw Ie(t.namedCurve,"algorithm.namedCurve");if(t.length!==void 0&&n.length!==t.length)throw Ie(t.length,"algorithm.length");rt(e,r)}function vt(e,t,...r){if(r.length>2){let n=r.pop();e+=`one of type ${r.join(", ")}, or ${n}.`}else if(r.length===2)e+=`one of type ${r[0]} or ${r[1]}.`;else e+=`of type ${r[0]}.`;if(t==null)e+=` Received ${t}`;else if(typeof t==="function"&&t.name)e+=` Received function ${t.name}`;else if(typeof t==="object"&&t!=null){if(t.constructor?.name)e+=` Received an instance of ${t.constructor.name}`}return e}var R=(e,...t)=>vt("Key must be ",e,...t),he=(e,t,...r)=>vt(`Key for the ${e} algorithm must be `,t,...r);class dn extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t);this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class P extends dn{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}});this.claim=r,this.reason=n,this.payload=t}}class yi extends dn{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}});this.claim=r,this.reason=n,this.payload=t}}class X extends dn{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"}class m extends dn{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class we extends dn{static code="ERR_JWE_DECRYPTION_FAILED";code="ERR_JWE_DECRYPTION_FAILED";constructor(e="decryption operation failed",t){super(e,t)}}class u extends dn{static code="ERR_JWE_INVALID";code="ERR_JWE_INVALID"}class Ur extends dn{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class zr extends dn{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class ge extends dn{static code="ERR_JWK_INVALID";code="ERR_JWK_INVALID"}class Al extends dn{static code="ERR_JWKS_INVALID";code="ERR_JWKS_INVALID"}class _l extends dn{static code="ERR_JWKS_NO_MATCHING_KEY";code="ERR_JWKS_NO_MATCHING_KEY";constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t)}}class yc extends dn{[Symbol.asyncIterator]=async function*(){};static code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t)}}class yl extends dn{static code="ERR_JWKS_TIMEOUT";code="ERR_JWKS_TIMEOUT";constructor(e="request timed out",t){super(e,t)}}class $u extends dn{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",t){super(e,t)}}function _e(e){if(!H(e))throw Error("CryptoKey instance expected")}var H=(e)=>{if(e?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},nt=(e)=>e?.[Symbol.toStringTag]==="KeyObject",De=(e)=>H(e)||nt(e);var k=(e)=>crypto.getRandomValues(new Uint8Array(e.cekBits>>3));function Ct(e,t){let r=e.byteLength<<3;if(r!==t)throw new u(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)}var wr=(e)=>crypto.getRandomValues(new Uint8Array(e.ivBits>>3));function Wt(e,t){if(t.length<<3!==e.ivBits)throw new u("Invalid Initialization Vector length")}async function Pt(e,t,r){if(!(t instanceof Uint8Array))throw TypeError(R(t,"Uint8Array"));let n=e.cekBits>>1,o=await crypto.subtle.importKey("raw",t.subarray(n>>3),"AES-CBC",!1,[r]),i=await crypto.subtle.importKey("raw",t.subarray(0,n>>3),{hash:`SHA-${n<<1}`,name:"HMAC"},!1,["sign"]);return[o,i,n]}async function Tt(e,t,r){return new Uint8Array((await crypto.subtle.sign("HMAC",e,t)).slice(0,r>>3))}async function gr(e,t,r,n,o){let[i,a,s]=await Pt(e,r,"encrypt"),c=new Uint8Array(await crypto.subtle.encrypt({iv:n,name:"AES-CBC"},i,t)),p=b(o,n,c,tt(o.length*8)),d=await Tt(a,p,s);return{ciphertext:c,tag:d,iv:n}}async function Er(e,t){let r={name:"HMAC",hash:"SHA-256"},n=await crypto.subtle.generateKey(r,!1,["sign","verify"]),o=await crypto.subtle.sign(r,n,e);return crypto.subtle.verify(r,n,o,t)}async function br(e,t,r,n,o,i){let[a,s,c]=await Pt(e,t,"decrypt"),p=b(i,n,r,tt(i.length*8)),d=await Tt(s,p,c);try{if(await Er(o,d))return new Uint8Array(await crypto.subtle.decrypt({iv:n,name:"AES-CBC"},a,r))}catch{}throw new we}async function Sr(e,t,r,n,o){let i=r instanceof Uint8Array?await crypto.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(N(r,e.subtle,"encrypt"),r),a=new Uint8Array(await crypto.subtle.encrypt({additionalData:o,iv:n,name:"AES-GCM",tagLength:128},i,t)),s=a.slice(-16);return{ciphertext:a.slice(0,-16),tag:s,iv:n}}async function xr(e,t,r,n,o,i){let a=t instanceof Uint8Array?await crypto.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]):(N(t,e.subtle,"decrypt"),t);try{return new Uint8Array(await crypto.subtle.decrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},a,b(r,o)))}catch{throw new we}}async function Ue(e,t,r,n,o){if(!H(r)&&!(r instanceof Uint8Array))throw TypeError(R(r,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(n)Wt(e,n);else n=wr(e);if(r instanceof Uint8Array)Ct(r,e.cekBits);return e.cbc?gr(e,t,r,n,o):Sr(e,t,r,n,o)}async function Ne(e,t,r,n,o,i){if(!H(t)&&!(t instanceof Uint8Array))throw TypeError(R(t,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(!n)throw new u("JWE Initialization Vector missing");if(!o)throw new u("JWE Authentication Tag missing");if(!e.cbc&&o.length!==16)throw new u("Invalid Authentication Tag length");if(Wt(e,n),t instanceof Uint8Array)Ct(t,e.cekBits);return e.cbc?br(e,t,r,n,o,i):xr(e,t,r,n,o,i)}function ot(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=32768,r=[];for(let n=0;n<e.length;n+=t)r.push(String.fromCharCode.apply(null,e.subarray(n,n+t)));return btoa(r.join(""))}function Re(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}var it="The input to be decoded is not correctly encoded.";function I(e){if(Uint8Array.fromBase64)try{return Uint8Array.fromBase64(typeof e==="string"?e:F.decode(e),{alphabet:"base64url"})}catch(r){throw TypeError(it,{cause:r})}let t=e;if(t instanceof Uint8Array)t=F.decode(t);if(t.includes("+")||t.includes("/"))throw TypeError(it);t=t.replace(/-/g,"+").replace(/_/g,"/");try{return Re(t)}catch{throw TypeError(it)}}function pr(e){let t=e;if(typeof t==="string")t=ye.encode(t);if(Uint8Array.prototype.toBase64)return t.toBase64({alphabet:"base64url",omitPadding:!0});return ot(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Y(e,t){if(!(e instanceof Uint8Array))throw TypeError(`${t} must be an instance of Uint8Array`)}function E(e){if(typeof e!=="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function He(e){return E(e)&&Array.isArray(e.keys)&&Array.from(e.keys).every(E)}function It(...e){let t=new Set;for(let r of e){if(!r)continue;for(let n of Object.keys(r)){if(t.has(n))return!1;t.add(n)}}return!0}var Ot=Symbol();function q(e,t){if(e!==void 0)throw TypeError(`${t} can only be called once`)}function A(e,t,r){try{return I(e)}catch{throw new r(`Failed to base64url decode the ${t}`)}}function at(e,t,r){try{return g(e)}catch{throw new r(`The ${t} is not a valid base64url string`)}}async function ke(e,t){let r=`SHA-${e.slice(-3)}`;return new Uint8Array(await crypto.subtle.digest(r,t))}function V(e,t,r){let n;try{n=JSON.parse(te.decode(I(e)))}catch{throw new t(r)}if(!E(n))throw new t(r);return n}async function B(e,t){if(t.kty==="RSA"&&"oth"in t&&t.oth!==void 0)throw new m('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');if(!e.kty.includes(t.kty))throw new m('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');let r=e.resolve?.({kty:t.kty,crv:t.crv})??e.subtle,n=!!(t.d||t.priv),o={...t};if(o.kty!=="AKP")delete o.alg;return delete o.use,crypto.subtle.importKey("jwk",o,r,t.ext??!n,t.key_ops??e.usages[n?1:0])}function re(e){return{__proto__:null,...e}}function Be(e){let t=re(e);if(t.ext!==void 0&&typeof t.ext!=="boolean")throw TypeError('"ext" (Extractable) Parameter must be a boolean');if(t.key_ops!==void 0){let r=t.key_ops,n=Array.isArray(r)?[...r]:void 0;if(!n||n.some((o)=>typeof o!=="string")||new Set(n).size!==n.length)throw TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');t.key_ops=n}return t}var st=(e)=>e[Symbol.toStringTag],Ar=(e,t,r)=>{let{alg:n}=e;if(t.use!==void 0){let o=r==="sign"||r==="verify"?"sig":"enc";if(t.use!==o)throw TypeError(`Invalid key for this operation, its "use" must be "${o}" when present`)}if(t.alg!==void 0&&t.alg!==n)throw TypeError(`Invalid key for this operation, its "alg" must be "${n}" when present`);if(Array.isArray(t.key_ops)){let o=r==="encrypt"||r==="decrypt"?e.ops?.[r==="encrypt"?0:1]:r;if(o&&!t.key_ops.includes(o))throw TypeError(`Invalid key for this operation, its "key_ops" must include "${o}" when present`)}};function Kr(e,t,r){let{alg:n,secret:o}=e,i=r==="decrypt"||r==="sign";if(o&&t instanceof Uint8Array)return[Dt,t];if(E(t)){let a=Be(t);if(typeof a.kty!=="string")throw TypeError(o?he(n,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"):he(n,t,"CryptoKey","KeyObject","JSON Web Key"));if(!(o?a.kty==="oct"&&typeof a.k==="string":a.kty!=="oct"&&(i?a.kty==="AKP"&&typeof a.priv==="string"||typeof a.d==="string":a.d===void 0&&a.priv===void 0)))throw TypeError(o?'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present':`JSON Web Key for this operation must be a ${i?"private":"public"} JWK`);return Ar(e,a,r),[Rt,t,a]}if(!De(t))throw TypeError(o?he(n,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"):he(n,t,"CryptoKey","KeyObject","JSON Web Key"));if(o){if(t.type!=="secret")throw TypeError(`${st(t)} instances for symmetric algorithms must be of type "secret"`)}else{if(t.type==="secret")throw TypeError(`${st(t)} instances for asymmetric algorithms must not be of type "secret"`);let a=i?"private":"public";if((t.type==="public"||t.type==="private")&&t.type!==a){let s=r==="sign"?"signing":r==="verify"?"verifying":`${r.slice(0,-1)}tion`;throw TypeError(`${st(t)} instances for asymmetric algorithm ${s} must be of type "${a}"`)}}return H(t)?[Ut,t]:[Nt,t]}var Dt=0,Ut=1,Nt=2,Rt=3,ct,Jr={__proto__:null,prime256v1:"P-256",secp384r1:"P-384",secp521r1:"P-521"};function Me(e,t,r){ct||=new WeakMap;let n=ct.get(e);if(r)if(n)n[t]=r;else ct.set(e,{[t]:r});return r??n?.[t]}var _t=async(e,t,r)=>Me(e,r.alg)??Me(e,r.alg,await B(r,{...t,alg:r.alg})),vr=(e,t)=>{let r=Me(e,t.alg);if(r)return r;let n=e.type==="public",o=t.usages[n?0:1],{asymmetricKeyType:i}=e,a=Jr[e.asymmetricKeyDetails?.namedCurve],s=t.resolve?.({crv:a,asymmetricKeyType:i})??t.subtle;return Me(e,t.alg,e.toCryptoKey(s,n,o))};async function O(e,t,r){let n=Kr(e,t,r);switch(n[0]){case Dt:case Ut:return n[1];case Rt:{let o=n[1],i=n[2];if(i.kty==="oct")return I(i.k);if(!Object.isFrozen(o)){let{key_ops:a}=o;if(Array.isArray(a))Object.freeze(a);Object.freeze(o)}return _t(o,i,e)}case Nt:{let o=n[1];if(o.type==="secret")return o.export();if("toCryptoKey"in o&&typeof o.toCryptoKey==="function")return vr(o,e);return _t(o,o.export({format:"jwk"}),e)}}}function Ee(e){let t={__proto__:null};for(let r in e)t[r]={...e[r],alg:r};return t}var Cr=[["encrypt","wrapKey"],["decrypt","unwrapKey"]],Wr=[[],["deriveBits"]],je=[[],[]];function Le(e){return{kty:["RSA"],subtle:{name:"RSA-OAEP",hash:`SHA-${e}`},usages:Cr,ops:["wrapKey","unwrapKey"]}}function $e(){return{kty:["EC","OKP"],subtle:{name:"ECDH"},resolve:({kty:e,crv:t,asymmetricKeyType:r})=>{if(t==="X25519"||r==="x25519")return{name:"X25519"};if(e==="OKP")throw new m('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');return{name:"ECDH",namedCurve:t}},usages:Wr,ops:[void 0,"deriveBits"]}}function ne(e,t=!1){return{kty:["oct"],secret:!0,subtle:{name:t?"AES-GCM":"AES-KW",length:e},usages:je,ops:t?["encrypt","decrypt"]:["wrapKey","unwrapKey"]}}function pt(){return{kty:["oct"],secret:!0,subtle:{name:"PBKDF2"},usages:je,ops:["deriveBits","deriveBits"]}}var dt=Ee({dir:{kty:["oct"],secret:!0,subtle:{name:"AES-GCM"},usages:je,ops:["encrypt","decrypt"]},"RSA-OAEP":Le(1),"RSA-OAEP-256":Le(256),"RSA-OAEP-384":Le(384),"RSA-OAEP-512":Le(512),"ECDH-ES":$e(),"ECDH-ES+A128KW":$e(),"ECDH-ES+A192KW":$e(),"ECDH-ES+A256KW":$e(),A128KW:ne(128),A192KW:ne(192),A256KW:ne(256),A128GCMKW:ne(128,!0),A192GCMKW:ne(192,!0),A256GCMKW:ne(256,!0),"PBES2-HS256+A128KW":pt(),"PBES2-HS384+A192KW":pt(),"PBES2-HS512+A256KW":pt()}),Pr=["encrypt","decrypt"];function oe(e,t=!1){return{kty:["oct"],secret:!0,subtle:{name:t?"AES-CBC":"AES-GCM",length:e},usages:je,ops:Pr,cekBits:e,ivBits:t?128:96,cbc:t}}var Tr=Ee({A128GCM:oe(128),A192GCM:oe(192),A256GCM:oe(256),"A128CBC-HS256":oe(256,!0),"A192CBC-HS384":oe(384,!0),"A256CBC-HS512":oe(512,!0)});function Ht(e,t){throw new m(`Invalid or unsupported "${e}" (JWE ${t}) header value`)}function _(e){return(typeof e==="string"?dt[e]:void 0)??Ht("alg","Algorithm")}function Z(e){return(typeof e==="string"?Tr[e]:void 0)??Ht("enc","Encryption Algorithm")}function kt(e,t){if(e.algorithm.name!=="ECDH"&&e.algorithm.name!=="X25519")throw TypeError("CryptoKey does not support this operation, its algorithm.name must be ECDH or X25519");rt(e,t)}async function Mt(e,t,r){let n=_(t).subtle,o=e instanceof Uint8Array?await crypto.subtle.importKey("raw",e,"AES-KW",!0,[r]):e;return N(o,n,r),o}async function ut(e,t,r){let n=await Mt(t,e,"wrapKey"),o=await crypto.subtle.importKey("raw",r,{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.wrapKey("raw",o,n,"AES-KW"))}async function ft(e,t,r){let n=await Mt(t,e,"unwrapKey"),o=await crypto.subtle.unwrapKey("raw",r,n,"AES-KW",{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.exportKey("raw",o))}function Lt(e,t,r){N(t,_(e).subtle,r),Oe(e,t)}function Ir(e,t){if(e instanceof Uint8Array)return crypto.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);return N(e,_(t).subtle,"deriveBits"),e}async function $t(e,t,r,n){if(!(e instanceof Uint8Array)||e.length<8)throw new u("PBES2 Salt Input must be 8 or more octets");if(!Number.isSafeInteger(r)||Math.sign(r)!==1)throw new u("PBES2 Count Input must be a positive integer");let o=b(g(t),Uint8Array.of(0),e),i=parseInt(t.slice(13,16),10),a={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:o},s=await Ir(n,t);return new Uint8Array(await crypto.subtle.deriveBits(a,s,i))}function lt(e){return b(Te(e.length),e)}async function Or(e,t,r){let n=t>>3,o=32,i=Math.ceil(n/32),a=new Uint8Array(i*32);for(let s=1;s<=i;s++){let c=await ke("sha256",b(Te(s),e,r));a.set(c,(s-1)*32)}return a.slice(0,n)}async function jt(e,t,r,n,o=new Uint8Array,i=new Uint8Array){kt(e),kt(t,"deriveBits");let a=b(lt(g(r)),lt(o),lt(i),Te(n)),s=new Uint8Array(await crypto.subtle.deriveBits({name:e.algorithm.name,public:e},t,e.algorithm.name==="X25519"?256:Math.ceil(parseInt(e.algorithm.namedCurve.slice(-3),10)/8)<<3));return Or(s,n,a)}function Vt(e){_e(e);let t=e.algorithm.namedCurve;if(t!=="P-256"&&t!=="P-384"&&t!=="P-521"&&e.algorithm.name!=="X25519")throw new m("ECDH with the provided key is not allowed or not supported by your javascript runtime")}function be(e){if(e===void 0)throw new u("JWE Encrypted Key missing")}function Bt(e){if(e!==void 0)throw new u("Encountered unexpected JWE Encrypted Key")}async function zt(e,t,r,n,o,i){let a=_(e);if(e==="dir")return Bt(n),r;switch(a.subtle.name){case"ECDH":{if(e==="ECDH-ES")Bt(n);if(!E(o.epk))throw new u('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');Vt(r);let s=await B(a,o.epk),c,p;if(o.apu!==void 0){if(typeof o.apu!=="string")throw new u('JOSE Header "apu" (Agreement PartyUInfo) invalid');c=A(o.apu,"apu",u)}if(o.apv!==void 0){if(typeof o.apv!=="string")throw new u('JOSE Header "apv" (Agreement PartyVInfo) invalid');p=A(o.apv,"apv",u)}let d=await jt(s,r,e==="ECDH-ES"?t.alg:e,e==="ECDH-ES"?t.cekBits:parseInt(e.slice(-5,-2),10),c,p);if(e==="ECDH-ES")return d;return be(n),ft(e.slice(-6),d,n)}case"RSA-OAEP":return be(n),_e(r),Lt(e,r,"decrypt"),new Uint8Array(await crypto.subtle.decrypt("RSA-OAEP",r,n));case"PBKDF2":{if(be(n),typeof o.p2c!=="number")throw new u('JOSE Header "p2c" (PBES2 Count) missing or invalid');let s=i||1e4;if(o.p2c>s)throw new u('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if(typeof o.p2s!=="string")throw new u('JOSE Header "p2s" (PBES2 Salt) missing or invalid');let c=A(o.p2s,"p2s",u),p=await $t(c,e,o.p2c,r);return ft(e.slice(-6),p,n)}case"AES-KW":return be(n),ft(e,r,n);case"AES-GCM":{if(be(n),typeof o.iv!=="string")throw new u('JOSE Header "iv" (Initialization Vector) missing or invalid');if(typeof o.tag!=="string")throw new u('JOSE Header "tag" (Authentication Tag) missing or invalid');let s;s=A(o.iv,"iv",u);let c;return c=A(o.tag,"tag",u),Ne(Z(e.slice(0,-2)),r,n,s,c,new Uint8Array)}}}async function Gt(e,t,r,n,o={}){let i,a,s,c=_(e);if(e==="dir")return[r,void 0,void 0];switch(c.subtle.name){case"ECDH":{Vt(r);let{apu:p,apv:d}=o;if(p!==void 0)Y(p,'"apu"');if(d!==void 0)Y(d,'"apv"');let f;if(o.epk!==void 0)f=await O(c,o.epk,"decrypt");else f=(await crypto.subtle.generateKey(r.algorithm,!0,["deriveBits"])).privateKey;let l=crypto.subtle,S=f;if(!S.extractable){if(typeof l.getPublicKey!=="function")throw TypeError('CryptoKey for "epk" must be extractable');S=await l.getPublicKey(f,[])}let{x:v,y:w,crv:h,kty:J}=await l.exportKey("jwk",S),y=await jt(r,f,e==="ECDH-ES"?t.alg:e,e==="ECDH-ES"?t.cekBits:parseInt(e.slice(-5,-2),10),p,d);if(a={epk:{x:v,crv:h,kty:J}},J==="EC")a.epk.y=w;if(p)a.apu=pr(p);if(d)a.apv=pr(d);if(e==="ECDH-ES"){s=y;break}s=n||k(t);let x=e.slice(-6);i=await ut(x,y,s);break}case"RSA-OAEP":{s=n||k(t),_e(r),Lt(e,r,"encrypt"),i=new Uint8Array(await crypto.subtle.encrypt("RSA-OAEP",r,s));break}case"PBKDF2":{s=n||k(t);let{p2c:p=2048,p2s:d=crypto.getRandomValues(new Uint8Array(16))}=o,f=await $t(d,e,p,r);i=await ut(e.slice(-6),f,s),a={p2c:p,p2s:pr(d)};break}case"AES-KW":{s=n||k(t),i=await ut(e,r,s);break}case"AES-GCM":{s=n||k(t);let{iv:p}=o,d=await Ue(Z(e.slice(0,-2)),s,r,p,new Uint8Array);i=d.ciphertext,a={iv:pr(d.iv),tag:pr(d.tag)};break}}return[s,i,a]}var ie={__proto__:null,b64:!0},Ve={__proto__:null};function Se(e,t){if(t!==void 0&&(!Array.isArray(t)||t.some((r)=>typeof r!=="string")))throw TypeError(`"${e}" option must be an array of strings`);if(!t)return;return new Set(t)}function ze(e,t){let{crit:r}=t??{};if(Array.isArray(r)&&new Set(r).size!==r.length)throw new e('"crit" (Critical) Header Parameter MUST NOT contain duplicate values')}function D(e,t,r,n,o){if(o.crit!==void 0&&n?.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return[];if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some((a)=>typeof a!=="string"||a.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i=r===void 0?t:{__proto__:null,...r,...t};for(let a of n.crit){if(!(a in i))throw new m(`Extension Header Parameter "${a}" is not recognized`);if(!Object.hasOwn(o,a)||o[a]===void 0)throw new e(`Extension Header Parameter "${a}" is missing`);if(i[a]&&(!Object.hasOwn(n,a)||n[a]===void 0))throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return n.crit}function ae(e,t){if(t.includes("b64")){let r=e.b64;if(typeof r!=="boolean")throw new Ur('The "b64" (base64url-encode payload) Header Parameter must be a boolean');return r}return!0}function se(e,t){let r,n;try{r=JSON.stringify(t),n=JSON.parse(r)}catch(o){throw new e("JOSE Header is not valid JSON",{cause:o})}if(!E(n))throw new e("JOSE Header is not a JSON object");return[n,r]}function Ge(e,t){if(e.zip!==void 0&&e.zip!=="DEF")throw new m('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(e.zip!==void 0&&!t?.zip)throw new u('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.')}function Ft(e){if(typeof globalThis[e]>"u")throw new m(`JWE "zip" (Compression Algorithm) Header Parameter requires the ${e} API.`)}async function Xt(e){Ft("CompressionStream");let t=new CompressionStream("deflate-raw"),r=t.writable.getWriter();r.write(e).catch(()=>{}),r.close().catch(()=>{});let n=[],o=t.readable.getReader();for(;;){let{value:i,done:a}=await o.read();if(a)break;n.push(i)}return b(...n)}async function Yt(e,t){Ft("DecompressionStream");let r=new DecompressionStream("deflate-raw"),n=r.writable.getWriter();n.write(e).catch(()=>{}),n.close().catch(()=>{});let o=[],i=0,a=r.readable.getReader();for(;;){let{value:s,done:c}=await a.read();if(c)break;if(o.push(s),i+=s.byteLength,t!==1/0&&i>t)throw new u("Decompressed plaintext exceeded the configured limit")}return b(...o)}function qt(e){return[e&&Se("keyManagementAlgorithms",e.keyManagementAlgorithms),e&&Se("contentEncryptionAlgorithms",e.contentEncryptionAlgorithms),e?.crit,e?.maxPBES2Count,e?.maxDecompressedLength]}async function _r(e,t,r,n,o){let[i,a,s,c,p]=r,[d,f,l,S,v]=t,{encrypted_key:w}=e;D(u,Ve,s,d,o),Ge(o,d);let{alg:h,enc:J}=o;if(typeof h!=="string"||!h)throw new u("missing JWE Algorithm (alg) in JWE Header");if(typeof J!=="string"||!J)throw new u("missing JWE Encryption Algorithm (enc) in JWE Header");if(i&&!i.has(h)||!i&&h.startsWith("PBES2"))throw new X('"alg" (Algorithm) Header Parameter value not allowed');if(a&&!a.has(J))throw new X('"enc" (Encryption Algorithm) Header Parameter value not allowed');let y=Z(J),x;if(w!==void 0)x=A(w,"encrypted_key",u);let C=!1;if(typeof n==="function")n=await n(d,e),C=!0;let U=_(h),T=await O(h==="dir"?y:U,n,"decrypt"),W;try{if(W=await zt(h,y,T,x,o,c),w!==void 0&&W instanceof Uint8Array&&W.byteLength<<3!==y.cekBits)W=k(y)}catch(K){if(K instanceof TypeError||K instanceof u||K instanceof m)throw K;W=k(y)}let z=await Ne(y,W,f,l,S,v);if(o.zip==="DEF"){let K=p??250000;if(K===0)throw new m('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');if(K!==1/0&&(!Number.isSafeInteger(K)||K<1))throw TypeError("maxDecompressedLength must be 0, a positive safe integer, or Infinity");z=await Yt(z,K).catch((G)=>{if(G instanceof u)throw G;throw new u("Failed to decompress plaintext",{cause:G})})}return[z,d,T,C]}async function Zt(e,t,r){if(e instanceof Uint8Array)e=F.decode(e);if(typeof e!=="string")throw new u("Compact JWE must be a string or Uint8Array");let{0:n,1:o,2:i,3:a,4:s,length:c}=e.split(".");if(c!==5)throw new u("Invalid Compact JWE");let p={ciphertext:a,iv:i||void 0,protected:n,tag:s||void 0,encrypted_key:o||void 0},d=V(n,u,"JWE Protected Header is invalid"),f=g(n),l=[d,A(a,"ciphertext",u),i?A(i,"iv",u):void 0,s?A(s,"tag",u):void 0,f];return _r(p,l,t,r,d)}function Qt(e,t,r){if(!It(e,t,r))throw new u("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint")}function Dr(e){let[,t,r,n,o,i,a,s,c]=e;if(o!==void 0)Y(o,"JWE Additional Authenticated Data");if(i!==void 0)Y(i,"JWE Content Encryption Key");if(a!==void 0)Y(a,"JWE Initialization Vector");if(t!==void 0)t=se(u,t)[0],e[1]=t;if(r!==void 0)r=se(u,r)[0],e[2]=r;if(n!==void 0)n=se(u,n)[0],e[3]=n;if(s!==void 0&&!E(s))throw TypeError("JWE Key Management Parameters must be an object");Qt(t,r,n);let p={...t,...r,...n};ze(u,t),D(u,Ve,c,t,p),Ge(p,t);let{alg:d,enc:f}=p;if(typeof d!=="string"||!d)throw new u('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(typeof f!=="string"||!f)throw new u('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');return[p,d,f,Z(f)]}async function Nr(e,t,r){let[n,o,,i]=t,[a,s,c,p,d,f,l,S,,v]=e,w=s,h=c;if(f&&(o==="dir"||o==="ECDH-ES"))throw TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${o}`);let J=_(o),y=await O(o==="dir"?i:J,r,"encrypt"),[x,C,U]=await Gt(o,i,y,f,S);if(U){if(v)h=h?{...h,...U}:U;else w=w?{...w,...U}:U;Qt(w,h,p)}let T,W;if(w)T=pr(JSON.stringify(w)),W=g(T);else T="",W=new Uint8Array;let z,K;if(d?.byteLength)K=pr(d),z=b(W,g("."),g(K));else z=W;let G=a;if(n.zip==="DEF")G=await Xt(G).catch((hr)=>{throw new u("Failed to compress plaintext",{cause:hr})});let{ciphertext:yr,tag:Kt,iv:Jt}=await Ue(i,G,x,l,z),j={ciphertext:pr(yr)};if(Jt)j.iv=pr(Jt);if(Kt)j.tag=pr(Kt);if(C)j.encrypted_key=pr(C);if(K)j.aad=K;if(w)j.protected=T;if(p)j.unprotected=p;if(h)j.header=h;return j}async function er(e,t,r){if(!e[1]&&!e[2]&&!e[3])throw new u("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(r!==void 0)e[8]=r?.crit,e[9]=r?Ot in r:!1;return Nr(e,Dr(e),t)}async function tr(e,t,r){if(t instanceof Uint8Array)return crypto.subtle.importKey("raw",t,e.subtle,!1,[r]);if(N(t,e.subtle,r),e.minRsaBits)Oe(e.alg,t);return t}async function rr(e,t,r){let n=await tr(e,t,"sign"),o=await crypto.subtle.sign(e.signing,n,r);return new Uint8Array(o)}async function nr(e,t,r,n){let o=await tr(e,t,"verify");try{return await crypto.subtle.verify(e.signing,o,r,n)}catch{return!1}}var xe=[["verify"],["sign"]];function mt(e){let t={name:"HMAC",hash:`SHA-${e}`};return{kty:["oct"],secret:!0,subtle:t,signing:t,usages:xe}}function ce(e,t){let n={name:t?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:`SHA-${e}`};return{kty:["RSA"],subtle:n,signing:t?{...n,saltLength:t}:n,usages:xe,minRsaBits:2048}}function yt(e,t){return{kty:["EC"],crv:e,subtle:{name:"ECDSA",namedCurve:e},signing:{name:"ECDSA",hash:`SHA-${t}`},usages:xe}}function or(){let e={name:"Ed25519"};return{kty:["OKP"],crv:"Ed25519",subtle:e,signing:e,usages:xe}}function ht(e){let r={name:`ML-DSA-${e}`};return{kty:["AKP"],subtle:r,signing:r,usages:xe}}var Ae=Ee({HS256:mt(256),HS384:mt(384),HS512:mt(512),RS256:ce(256),RS384:ce(384),RS512:ce(512),PS256:ce(256,32),PS384:ce(384,48),PS512:ce(512,64),ES256:yt("P-256",256),ES384:yt("P-384",384),ES512:yt("P-521",512),EdDSA:or(),Ed25519:or(),"ML-DSA-44":ht(44),"ML-DSA-65":ht(65),"ML-DSA-87":ht(87)});function Fe(e){let t=typeof e==="string"?Ae[e]:void 0;if(!t)throw new m(`alg ${e} is not supported either by JOSE or your javascript runtime`);return t}function Xe(e){return[e&&Se("algorithms",e.algorithms),e?.crit]}function Rr(e,t=e===void 0?{}:V(e,Ur,"JWS Protected Header is invalid")){return t}function kr(e,t,r){let n=ae(e,D(Ur,ie,r[1],e,t)),o=t.alg;if(typeof o!=="string"||!o)throw new Ur('JWS "alg" (Algorithm) Header Parameter missing or invalid');if(r[0]&&!r[0].has(o))throw new X('"alg" (Algorithm) Header Parameter value not allowed');return[n,o]}function Br(e){try{return g(e)}catch{throw new Ur("JWS Compact Serialization payload must use only ASCII characters")}}async function Mr(e,t,r,n,o,i,a){let s=!1;if(typeof r==="function")r=await r(o,e),s=!0;let c=typeof a==="string",p=Fe(i),d=b(n!==void 0?g(n):new Uint8Array,g("."),c?t[2]??=at(a,"payload",Ur):a),f=A(e.signature,"signature",Ur),l=await O(p,r,"verify");if(!await nr(p,l,f,d))throw new $u;return[c?A(a,"payload",Ur):a,o,c,l,s]}async function qe(e,t,r){if(e instanceof Uint8Array)e=F.decode(e);if(typeof e!=="string")throw new Ur("Compact JWS must be a string or Uint8Array");let{0:n,1:o,2:i,length:a}=e.split(".");if(a!==3)throw new Ur("Invalid Compact JWS");let s={payload:o,protected:n,signature:i},c=Rr(n),[p,d]=kr(c,c,t),f=p?o:Br(o);return Mr(s,t,r,n,c,d,f)}async function Hu(e,t,r){let n=await qe(e,Xe(r),t),o={payload:n[0],protectedHeader:n[1]};if(typeof t==="function")return{...o,key:n[3]};return o}var Ke=(e)=>Math.floor(e.getTime()/1000),Lr={s:1,m:60,h:3600,d:86400,w:604800,y:31557600},$r=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,pe="check_failed";function wt(){throw TypeError("Invalid time period format")}function Ze(e){if(typeof e!=="string")wt();let t=$r.exec(e);if(!t||t[4]&&t[1])wt();let r=parseFloat(t[2]),n=Math.round(r*Lr[t[3][0].toLowerCase()]);if(!Number.isFinite(n))wt();if(t[1]==="-"||t[4]==="ago")return-n;return n}function de(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}function gt(e,t){if(typeof t!=="string")throw TypeError(`"${e}" claim must be a string`)}function jr(e){if(typeof e!=="string"&&(!Array.isArray(e)||Array.from(e).some((t)=>typeof t!=="string")))throw TypeError('"aud" claim must be a string or an array of strings')}function Et(e,t){if(typeof e==="number")return de(t,e);if(e instanceof Date)return de(t,Ke(e));return Ke(new Date)+Ze(e)}var ir=(e)=>{let t=e.toLowerCase();return e.includes("/")?t:`application/${t}`},Vr=(e,t)=>{if(typeof e==="string")return t.includes(e);if(Array.isArray(e))return t.some((r)=>e.includes(r));return!1};function bt(e,t,r=!1){let n=e[t];if(n===void 0&&!r)return;if(typeof n!=="number")throw new P(`"${t}" claim must be a number`,e,t,"invalid");return n}function St(e,t){throw new P(`unexpected "${t}" claim value`,e,t,pe)}function ue(e,t,r={}){let n;try{n=JSON.parse(te.decode(t))}catch{}if(!E(n))throw new zr("JWT Claims Set must be a top-level JSON object");let{typ:o}=r;if(o!==void 0&&(typeof e.typ!=="string"||ir(e.typ)!==ir(o)))throw new P('unexpected "typ" JWT header value',n,"typ",pe);let{requiredClaims:i=[],issuer:a,subject:s,audience:c,maxTokenAge:p}=r,d=[...i];if(p!==void 0)d.push("iat");if(c!==void 0)d.push("aud");if(s!==void 0)d.push("sub");if(a!==void 0)d.push("iss");for(let y of new Set(d.reverse()))if(!Object.hasOwn(n,y))throw new P(`missing required "${y}" claim`,n,y,"missing");if(a!==void 0&&!(Array.isArray(a)?a:[a]).includes(n.iss))St(n,"iss");if(s!==void 0&&n.sub!==s)St(n,"sub");if(c!==void 0&&!Vr(n.aud,typeof c==="string"?[c]:c))St(n,"aud");let{clockTolerance:f}=r,l=0;if(typeof f==="string")l=Ze(f);else if(f!==void 0){if(typeof f!=="number")throw TypeError("Invalid clockTolerance option type");l=f}de("clockTolerance option",l);let{currentDate:S}=r,v=de("currentDate option",Ke(S===void 0?new Date:S)),w=bt(n,"iat",p!==void 0),h=bt(n,"nbf");if(h!==void 0){if(h>v+l)throw new P('"nbf" claim timestamp check failed',n,"nbf",pe)}let J=bt(n,"exp");if(J!==void 0){if(J<=v-l)throw new yi('"exp" claim timestamp check failed',n,"exp",pe)}if(p!==void 0){let y=v-w,x=de("maxTokenAge option",typeof p==="number"?p:Ze(p));if(y-l>x)throw new yi('"iat" claim timestamp check failed (too far in the past)',n,"iat",pe);if(y<-l)throw new P('"iat" claim timestamp check failed (it should be in the past)',n,"iat",pe)}return n}var ar;function M(e){return ar.get(e)}function fe(e){let t=M(e);for(let r of["iat","nbf","exp"]){let n=t[r];if(typeof n==="number"&&!Number.isFinite(n))throw TypeError(`"${r}" claim must be a finite number`)}return ye.encode(JSON.stringify(t))}function Qe(e,t){return M(e)[t]}class Q{constructor(e={}){if(!E(e))throw TypeError("JWT Claims Set MUST be an object");(ar||=new WeakMap).set(this,structuredClone(e))}setIssuer(e){return gt("iss",e),M(this).iss=e,this}setSubject(e){return gt("sub",e),M(this).sub=e,this}setAudience(e){return jr(e),M(this).aud=e,this}setJti(e){return gt("jti",e),M(this).jti=e,this}setNotBefore(e){return M(this).nbf=Et(e,"setNotBefore"),this}setExpirationTime(e){return M(this).exp=Et(e,"setExpirationTime"),this}setIssuedAt(e){let t=M(this);if(e===void 0)t.iat=Ke(new Date);else if(typeof e==="string")t.iat=de("setIssuedAt",Ke(new Date)+Ze(e));else t.iat=Et(e,"setIssuedAt");return this}}async function Hr(e,t,r){let n=await qe(e,Xe(r),t);if(!n[2])throw new zr("JWTs MUST NOT use unencoded payload");let i={payload:ue(n[1],n[0],r),protectedHeader:n[1]};if(typeof t==="function")return{...i,key:n[3]};return i}async function Qu(e,t,r){let n=await Zt(e,qt(r),t),o=n[1],i=ue(o,n[0],r);for(let s of["iss","sub","aud"])if(o[s]!==void 0&&(s==="aud"?JSON.stringify(o.aud)!==JSON.stringify(i.aud):o[s]!==i[s]))throw new P(`replicated "${s}" claim header parameter mismatch`,i,s,"mismatch");let a={payload:i,protectedHeader:o};if(typeof t==="function")return{...a,key:n[2]};return a}function Gr(e){if(e===void 0)return[void 0,""];let t=se(Ur,e);return[t[0],pr(t[1])]}function Fr(e,t,r){return ze(Ur,e),ae(e,D(Ur,ie,r,e,t))}function Yr(e){let t=e.alg;if(typeof t!=="string"||!t)throw new Ur('JWS "alg" (Algorithm) Header Parameter missing or invalid');return Fe(t)}async function qr(e,t,r,n){let o=b(g(e),g("."),t),i=await O(r,n,"sign");return pr(await rr(r,i,o))}async function sr(e,t,r,n,o){let[i,a]=Gr(t);if(!i)throw new Ur("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Fr(i,i,r))o();let c=Yr(i),p=pr(e),d=await qr(a,g(p),c,n);return`${a}.${p}.${d}`}var Zr=Q;class bs extends Zr{#e;setProtectedHeader(e){return q(this.#e,"setProtectedHeader"),this.#e=e,this}async sign(e,t){return sr(fe(this),this.#e,t?.crit,e,()=>{throw new zr("JWTs MUST NOT use unencoded payload")})}}var Qr=Q;class Gu extends Qr{#e;#r;#n;#t;#o;#i;#a;setProtectedHeader(e){return q(this.#t,"setProtectedHeader"),this.#t=e,this}setKeyManagementParameters(e){return q(this.#n,"setKeyManagementParameters"),this.#n=e,this}setContentEncryptionKey(e){return q(this.#e,"setContentEncryptionKey"),this.#e=e,this}setInitializationVector(e){return q(this.#r,"setInitializationVector"),this.#r=e,this}replicateIssuerAsHeader(){return this.#o=!0,this}replicateSubjectAsHeader(){return this.#i=!0,this}replicateAudienceAsHeader(){return this.#a=!0,this}async encrypt(e,t){let r=fe(this);if(this.#t&&(this.#o||this.#i||this.#a))this.#t={...this.#t,iss:this.#o?Qe(this,"iss"):void 0,sub:this.#i?Qe(this,"sub"):void 0,aud:this.#a?Qe(this,"aud"):void 0};let n=await er([r,this.#t,void 0,void 0,void 0,this.#e,this.#r,this.#n,void 0,!1],e,t);return[n.protected,n.encrypted_key,n.iv,n.ciphertext,n.tag].join(".")}}var le='"alg" (Algorithm)';function Je(e='JWK "alg" (Algorithm) Parameter'){throw new m(`Invalid or unsupported ${e} value`)}function ee(e,t){return(typeof e==="string"?Ae[e]??dt[e]:void 0)??Je(t)}function me(e){if(e!==void 0&&typeof e!=="boolean")throw TypeError('"extractable" option must be a boolean');return e}var ve=(e,t)=>{if(e.byteLength!==t.length)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},en=(e)=>({data:e,pos:0}),xt=(e)=>{let t=e.data[e.pos++];if(t===void 0)throw Error("Unexpected end of ASN.1 input");return t},Ce=(e)=>{let t=xt(e);if(t&128){let r=t&127,n=0;for(let o=0;o<r;o++)n=n<<8|xt(e);return n}return t};var We=(e,t,r)=>{if(xt(e)!==t)throw Error(r)},cr=(e,t)=>{if(t<0||e.pos+t>e.data.length)throw Error("Unexpected end of ASN.1 input");let r=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,r},tn=(e)=>{We(e,6,"Expected algorithm OID");let t=Ce(e);return cr(e,t)};function rn(e,t){if(We(e,48,`Invalid ${t==="spki"?"SPKI":"PKCS#8"} structure`),Ce(e),t==="pkcs8"){We(e,2,"Expected version field");let r=Ce(e);e.pos+=r}We(e,48,"Expected algorithm identifier"),Ce(e)}var nn=(e)=>{let t=tn(e);if(ve(t,[43,101,110]))return"X25519";if(!ve(t,[42,134,72,206,61,2,1]))throw Error("Unsupported key algorithm");We(e,6,"Expected curve OID");let r=Ce(e),n=cr(e,r);if(ve(n,[42,134,72,206,61,3,1,7]))return"P-256";if(ve(n,[43,129,4,0,34]))return"P-384";if(ve(n,[43,129,4,0,35]))return"P-521";throw Error("Unsupported named curve")},on=async(e,t,r,n)=>{let o=me(n?.extractable),i=ee(r,le);if(i.secret)Je(le);let a=e==="spki",s;if(i.resolve)try{let c=en(t);rn(c,e),s=i.resolve({crv:nn(c)})}catch{throw new m("Invalid or unsupported key format")}else s=i.subtle;return crypto.subtle.importKey(e,t,s,o??a,i.usages[a?0:1])},an=(e,t)=>Re(e.replace(t,"")),dr=(e,t,r)=>{let n=an(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);return on("pkcs8",n,t,r)};function sn(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}async function cn(e){if(nt(e))if(e.type==="secret")e=e.export();else return e.export({format:"jwk"});if(e instanceof Uint8Array)return{kty:"oct",k:pr(e)};if(!H(e))throw TypeError(R(e,"CryptoKey","KeyObject","Uint8Array"));if(!e.extractable)throw TypeError("non-extractable CryptoKey cannot be exported as a JWK");let{ext:t,key_ops:r,alg:n,use:o,...i}=sn(await crypto.subtle.exportKey("jwk",e));if(i.kty==="AKP")i.alg=n;return i}function vl(e){return cn(e)}var L=(e,t)=>{if(typeof e!=="string"||!e)throw new ge(`${t} missing or invalid`)};async function bl(e,t){let r;if(E(e)){if(r=re(e),typeof r.kty!=="string")throw TypeError(R(e,"CryptoKey","KeyObject","JSON Web Key"))}else if(De(e))r=re(await vl(e));else throw TypeError(R(e,"CryptoKey","KeyObject","JSON Web Key"));if(t??="sha256",t!=="sha256"&&t!=="sha384"&&t!=="sha512")throw TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');let n;switch(r.kty){case"AKP":L(r.alg,'"alg" (Algorithm) Parameter'),L(r.pub,'"pub" (Public key) Parameter'),n={alg:r.alg,kty:r.kty,pub:r.pub};break;case"EC":L(r.crv,'"crv" (Curve) Parameter'),L(r.x,'"x" (X Coordinate) Parameter'),L(r.y,'"y" (Y Coordinate) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x,y:r.y};break;case"OKP":L(r.crv,'"crv" (Subtype of Key Pair) Parameter'),L(r.x,'"x" (Public Key) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x};break;case"RSA":L(r.e,'"e" (Exponent) Parameter'),L(r.n,'"n" (Modulus) Parameter'),n={e:r.e,kty:r.kty,n:r.n};break;case"oct":if(typeof r.k!=="string")throw new ge('"k" (Key Value) Parameter missing or invalid');n={k:r.k,kty:r.kty};break;default:throw new m('"kty" (Key Type) Parameter missing or unsupported')}let o=g(JSON.stringify(n));return pr(await ke(t,o))}function pn(e,t,r,n){let{kty:o,key_ops:i,ext:a,kid:s,alg:c,use:p,crv:d}=re(e),f=Array.isArray(i)?[...i]:i;return(a===void 0||typeof a==="boolean")&&(f===void 0||Array.isArray(f)&&f.every((l,S)=>typeof l==="string"&&f.indexOf(l)===S)&&f.includes("verify"))&&t.kty.includes(o)&&(n===void 0||typeof n==="string"&&n===s)&&(c===void 0?o!=="AKP":r===c)&&(p===void 0||p==="sig")&&(!t.crv||d===t.crv)}async function ur(e,t,r){let n=e.get(t)||e.set(t,{}).get(t),{alg:o}=r;if(n[o]===void 0){let i=await B(r,{...t,alg:o,ext:!0});if(i.type!=="public")throw new Al("JSON Web Key Set members must be public keys");n[o]=i}return n[o]}function Qo(e){let t;try{t=structuredClone(e)}catch{}if(!He(t))throw new Al("JSON Web Key Set malformed");let r=new WeakMap;return Object.defineProperty(async(o,i)=>{let{alg:a,kid:s}={...o,...i?.header},c=typeof a==="string"?Ae[a]:void 0;if(!c||c.secret)throw new m('Unsupported "alg" value for a JSON Web Key Set');let p=t.keys.filter((l)=>pn(l,c,a,s)),{0:d,length:f}=p;if(!f)throw new _l;if(f!==1){let l=new yc;throw l[Symbol.asyncIterator]=async function*(){for(let S of p)try{yield await ur(r,S,c)}catch{}},l}return ur(r,d,c)},"jwks",{value:()=>structuredClone(t)})}function un(){return typeof WebSocketPair<"u"||typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime<"u"&&EdgeRuntime==="vercel"}var At;if(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))At="jose/v6.2.10";var lr=Symbol();async function fn(e,t,r,n=fetch){let o=await n(e,{method:"GET",signal:r,redirect:"manual",headers:t}).catch((i)=>{if(i.name==="TimeoutError")throw new yl;throw i});if(o.status!==200)throw new dn("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await o.json()}catch{throw new dn("Failed to parse the JSON Web Key Set HTTP response as JSON")}}var mr=Symbol();function Pe(e,t){return Number.isFinite(e)&&Date.now()<e+t}function fr(e,t,r){if(Number.isNaN(e))throw TypeError(`"${r}" option must not be NaN`);return typeof e==="number"?e:t}function gf(e,t){if(!(e instanceof URL))throw TypeError("url must be an instance of URL");let r=new URL(e.href).href,n=t??{},o=n.timeoutDuration;if(typeof o==="number"&&(!Number.isInteger(o)||o<0))throw TypeError('"timeoutDuration" option must be a non-negative integer');let i=typeof o==="number"?o:5000,a=fr(n.cooldownDuration,30000,"cooldownDuration"),s=fr(n.cacheMaxAge,600000,"cacheMaxAge"),c=new Headers(n.headers);if(At&&!c.has("User-Agent"))c.set("User-Agent",At);if(!c.has("accept"))c.set("accept","application/json, application/jwk-set+json");let p=n[lr],d=n[mr],f,l,S=0,v=0,w;if(d&&typeof d==="object"){let{uat:y,jwks:x}=d;if(Pe(y,s)&&He(x))f=y,w=Qo(x)}let h=async()=>{if(l&&un())l=void 0;if(!l){let y=++S,x=l=fn(r,c,AbortSignal.timeout(i),p).then((C)=>{let U=Qo(C);if(y<=v)return;w=U;let T=Date.now();if(d)d.uat=T,d.jwks=C;f=T,v=y}).finally(()=>{if(l===x)l=void 0})}await l};return Object.defineProperties(async(y,x)=>{if(!w||!Pe(f,s))await h();try{return await w(y,x)}catch(C){if(C instanceof _l&&!Pe(f,a))return await h(),w(y,x);throw C}},{coolingDown:{get:()=>Pe(f,a),enumerable:!0},fresh:{get:()=>Pe(f,s),enumerable:!0},reload:{value:h,enumerable:!0},reloading:{get:()=>!!l,enumerable:!0},jwks:{value:()=>w?.jwks(),enumerable:!0}})}var ln=Q;class vc extends ln{encode(){let e=pr(JSON.stringify({alg:"none"})),t=pr(fe(this));return`${e}.${t}.`}static decode(e,t){if(typeof e!=="string")throw new zr("Unsecured JWT must be a string");let{0:r,1:n,2:o,length:i}=e.split(".");if(i!==3||o!=="")throw new zr("Invalid Unsecured JWT");let a,s;try{a=V(r,Ur,"JWS Protected Header is invalid");let p=D(Ur,ie,void 0,a,a);s=ae(a,p)}catch(p){if(!(p instanceof Ur))throw p;throw new zr("Invalid Unsecured JWT",{cause:p})}if(a.alg!=="none")throw new zr("Invalid Unsecured JWT");if(!s)throw new zr("JWTs MUST NOT use unencoded payload");return{payload:ue(a,A(n,"payload",zr),t),header:a}}}async function qy(e,t,r){if(typeof e!=="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw TypeError('"pkcs8" must be PKCS#8 formatted string');return dr(e,t,r)}async function Sn(e,t,r){if(!E(e))throw TypeError("JWK must be an object");let n=Be(e),o=me(r?.extractable),{alg:i}=n;t??=i;let a=o??n.ext;if(n.kty!=="oct"&&!t)throw TypeError('"alg" argument is required when "jwk.alg" is not present');switch(n.kty){case"oct":if(typeof n.k!=="string")throw TypeError('missing "k" (Key Value) Parameter value');return I(n.k);case"AKP":{if(typeof i!=="string"||!i)throw TypeError('missing "alg" (Algorithm) Parameter value');if(t!==i)throw TypeError("JWK alg and alg option value mismatch");return B(ee(t),{...n,ext:a})}case"RSA":case"EC":case"OKP":return B(ee(t),{...n,alg:t,ext:a});default:throw new m('Unsupported "kty" (Key Type) Parameter value')}}function so(e){let t;if(typeof e==="string"){let n=e.split(".");if(n.length===3||n.length===5)[t]=n}else if(typeof e==="object"&&e)if("protected"in e)t=e.protected;else throw TypeError("Token does not contain a Protected Header");let r="Invalid Token or Protected Header formatting";if(typeof t!=="string"||!t)throw TypeError(r);return V(t,TypeError,r)}function Xr(e){if(typeof e!=="string")throw new zr("JWTs must use Compact JWS serialization, JWT must be a string");let{1:t,length:r}=e.split(".");if(r===5)throw new zr("Only JWTs using Compact JWS serialization can be decoded");if(r!==3)throw new zr("Invalid JWT");if(!t)throw new zr("JWTs must contain a payload");let n;try{n=I(t)}catch{throw new zr("Failed to base64url decode the payload")}let o;try{o=JSON.parse(te.decode(n))}catch{throw new zr("Failed to parse the decoded payload as JSON")}if(!E(o))throw new zr("Invalid JWT Claims Set");return o}function mn(e){let t=e?.modulusLength??2048;if(typeof t!=="number"||!Number.isInteger(t)||t<2048)throw new m("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return t}async function Af(e,t){let r=me(t?.extractable),n=ee(e,le);if(n.secret)Je(le);let o;if(n.resolve){let i=t?.crv??"P-256";switch(i){case"P-256":case"P-384":case"P-521":o={name:"ECDH",namedCurve:i};break;case"X25519":o={name:"X25519"};break;default:throw new m("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, and X25519")}}else{if(n.crv!==void 0&&t?.crv!==void 0&&t.crv!==n.crv)throw new m(`Invalid or unsupported crv option provided, the only supported value for ${e} is ${n.crv}`);o=n.kty[0]==="RSA"?{...n.subtle,publicExponent:Uint8Array.of(1,0,1),modulusLength:mn(t)}:n.subtle}return crypto.subtle.generateKey(o,r??!1,[...n.usages[1],...n.usages[0]])}export{dn,yi,Ur,zr,Al,_l,yc,yl,$u,Yg,pr,Cm,Hu,Hr,Qu,bs,Gu,vl,bl,Qo,gf,vc,qy,Sn,so,Xr,Af};
|
|
2
|
+
import{Ye}from"./chunk-4p31kxjh.js";var eA={};Ye(eA,{JOSEAlgNotAllowed:()=>X,JOSEError:()=>dn,JOSENotSupported:()=>m,JWEDecryptionFailed:()=>we,JWEInvalid:()=>u,JWKInvalid:()=>ge,JWKSInvalid:()=>_l,JWKSMultipleMatchingKeys:()=>vc,JWKSNoMatchingKey:()=>yl,JWKSTimeout:()=>vl,JWSInvalid:()=>zr,JWSSignatureVerificationFailed:()=>Qu,JWTClaimValidationFailed:()=>P,JWTExpired:()=>yi,JWTInvalid:()=>jr});var Im={};Ye(Im,{decode:()=>I,encode:()=>mr});var ye=new TextEncoder,F=new TextDecoder,te=new TextDecoder("utf-8",{fatal:!0});function b(...e){let t=e.reduce((o,{length:i})=>o+i,0),r=new Uint8Array(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function et(e,t,r){if(t<0||t>=4294967296)throw RangeError(`value must be >= 0 and <= 4294967295. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,t&255],r)}function tt(e){let t=Math.floor(e/4294967296),r=e%4294967296,n=new Uint8Array(8);return et(n,t,0),et(n,r,4),n}function Te(e){let t=new Uint8Array(4);return et(t,e),t}function g(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n>127)throw TypeError("non-ASCII string encountered in encode()");t[r]=n}return t}var Ie=(e,t="algorithm.name")=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);function rt(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function Oe(e,t){let{modulusLength:r}=t.algorithm;if(typeof r!=="number"||r<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}function N(e,t,r){let n=e.algorithm;if(n.name!==t.name)throw Ie(t.name);if(t.hash&&n.hash?.name!==t.hash)throw Ie(t.hash,"algorithm.hash");if(t.namedCurve&&n.namedCurve!==t.namedCurve)throw Ie(t.namedCurve,"algorithm.namedCurve");if(t.length!==void 0&&n.length!==t.length)throw Ie(t.length,"algorithm.length");rt(e,r)}function vt(e,t,...r){if(r.length>2){let n=r.pop();e+=`one of type ${r.join(", ")}, or ${n}.`}else if(r.length===2)e+=`one of type ${r[0]} or ${r[1]}.`;else e+=`of type ${r[0]}.`;if(t==null)e+=` Received ${t}`;else if(typeof t==="function"&&t.name)e+=` Received function ${t.name}`;else if(typeof t==="object"&&t!=null){if(t.constructor?.name)e+=` Received an instance of ${t.constructor.name}`}return e}var R=(e,...t)=>vt("Key must be ",e,...t),he=(e,t,...r)=>vt(`Key for the ${e} algorithm must be `,t,...r);class dn extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t);this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class P extends dn{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}});this.claim=r,this.reason=n,this.payload=t}}class yi extends dn{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}});this.claim=r,this.reason=n,this.payload=t}}class X extends dn{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"}class m extends dn{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class we extends dn{static code="ERR_JWE_DECRYPTION_FAILED";code="ERR_JWE_DECRYPTION_FAILED";constructor(e="decryption operation failed",t){super(e,t)}}class u extends dn{static code="ERR_JWE_INVALID";code="ERR_JWE_INVALID"}class zr extends dn{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class jr extends dn{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class ge extends dn{static code="ERR_JWK_INVALID";code="ERR_JWK_INVALID"}class _l extends dn{static code="ERR_JWKS_INVALID";code="ERR_JWKS_INVALID"}class yl extends dn{static code="ERR_JWKS_NO_MATCHING_KEY";code="ERR_JWKS_NO_MATCHING_KEY";constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t)}}class vc extends dn{[Symbol.asyncIterator]=async function*(){};static code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t)}}class vl extends dn{static code="ERR_JWKS_TIMEOUT";code="ERR_JWKS_TIMEOUT";constructor(e="request timed out",t){super(e,t)}}class Qu extends dn{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",t){super(e,t)}}function _e(e){if(!H(e))throw Error("CryptoKey instance expected")}var H=(e)=>{if(e?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},nt=(e)=>e?.[Symbol.toStringTag]==="KeyObject",De=(e)=>H(e)||nt(e);var k=(e)=>crypto.getRandomValues(new Uint8Array(e.cekBits>>3));function Ct(e,t){let r=e.byteLength<<3;if(r!==t)throw new u(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)}var wr=(e)=>crypto.getRandomValues(new Uint8Array(e.ivBits>>3));function Wt(e,t){if(t.length<<3!==e.ivBits)throw new u("Invalid Initialization Vector length")}async function Pt(e,t,r){if(!(t instanceof Uint8Array))throw TypeError(R(t,"Uint8Array"));let n=e.cekBits>>1,o=await crypto.subtle.importKey("raw",t.subarray(n>>3),"AES-CBC",!1,[r]),i=await crypto.subtle.importKey("raw",t.subarray(0,n>>3),{hash:`SHA-${n<<1}`,name:"HMAC"},!1,["sign"]);return[o,i,n]}async function Tt(e,t,r){return new Uint8Array((await crypto.subtle.sign("HMAC",e,t)).slice(0,r>>3))}async function gr(e,t,r,n,o){let[i,a,s]=await Pt(e,r,"encrypt"),c=new Uint8Array(await crypto.subtle.encrypt({iv:n,name:"AES-CBC"},i,t)),p=b(o,n,c,tt(o.length*8)),d=await Tt(a,p,s);return{ciphertext:c,tag:d,iv:n}}async function Er(e,t){let r={name:"HMAC",hash:"SHA-256"},n=await crypto.subtle.generateKey(r,!1,["sign","verify"]),o=await crypto.subtle.sign(r,n,e);return crypto.subtle.verify(r,n,o,t)}async function br(e,t,r,n,o,i){let[a,s,c]=await Pt(e,t,"decrypt"),p=b(i,n,r,tt(i.length*8)),d=await Tt(s,p,c);try{if(await Er(o,d))return new Uint8Array(await crypto.subtle.decrypt({iv:n,name:"AES-CBC"},a,r))}catch{}throw new we}async function Sr(e,t,r,n,o){let i=r instanceof Uint8Array?await crypto.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(N(r,e.subtle,"encrypt"),r),a=new Uint8Array(await crypto.subtle.encrypt({additionalData:o,iv:n,name:"AES-GCM",tagLength:128},i,t)),s=a.slice(-16);return{ciphertext:a.slice(0,-16),tag:s,iv:n}}async function xr(e,t,r,n,o,i){let a=t instanceof Uint8Array?await crypto.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]):(N(t,e.subtle,"decrypt"),t);try{return new Uint8Array(await crypto.subtle.decrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},a,b(r,o)))}catch{throw new we}}async function Ue(e,t,r,n,o){if(!H(r)&&!(r instanceof Uint8Array))throw TypeError(R(r,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(n)Wt(e,n);else n=wr(e);if(r instanceof Uint8Array)Ct(r,e.cekBits);return e.cbc?gr(e,t,r,n,o):Sr(e,t,r,n,o)}async function Ne(e,t,r,n,o,i){if(!H(t)&&!(t instanceof Uint8Array))throw TypeError(R(t,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(!n)throw new u("JWE Initialization Vector missing");if(!o)throw new u("JWE Authentication Tag missing");if(!e.cbc&&o.length!==16)throw new u("Invalid Authentication Tag length");if(Wt(e,n),t instanceof Uint8Array)Ct(t,e.cekBits);return e.cbc?br(e,t,r,n,o,i):xr(e,t,r,n,o,i)}function ot(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=32768,r=[];for(let n=0;n<e.length;n+=t)r.push(String.fromCharCode.apply(null,e.subarray(n,n+t)));return btoa(r.join(""))}function Re(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}var it="The input to be decoded is not correctly encoded.";function I(e){if(Uint8Array.fromBase64)try{return Uint8Array.fromBase64(typeof e==="string"?e:F.decode(e),{alphabet:"base64url"})}catch(r){throw TypeError(it,{cause:r})}let t=e;if(t instanceof Uint8Array)t=F.decode(t);if(t.includes("+")||t.includes("/"))throw TypeError(it);t=t.replace(/-/g,"+").replace(/_/g,"/");try{return Re(t)}catch{throw TypeError(it)}}function mr(e){let t=e;if(typeof t==="string")t=ye.encode(t);if(Uint8Array.prototype.toBase64)return t.toBase64({alphabet:"base64url",omitPadding:!0});return ot(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Y(e,t){if(!(e instanceof Uint8Array))throw TypeError(`${t} must be an instance of Uint8Array`)}function E(e){if(typeof e!=="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function He(e){return E(e)&&Array.isArray(e.keys)&&Array.from(e.keys).every(E)}function It(...e){let t=new Set;for(let r of e){if(!r)continue;for(let n of Object.keys(r)){if(t.has(n))return!1;t.add(n)}}return!0}var Ot=Symbol();function q(e,t){if(e!==void 0)throw TypeError(`${t} can only be called once`)}function A(e,t,r){try{return I(e)}catch{throw new r(`Failed to base64url decode the ${t}`)}}function at(e,t,r){try{return g(e)}catch{throw new r(`The ${t} is not a valid base64url string`)}}async function ke(e,t){let r=`SHA-${e.slice(-3)}`;return new Uint8Array(await crypto.subtle.digest(r,t))}function V(e,t,r){let n;try{n=JSON.parse(te.decode(I(e)))}catch{throw new t(r)}if(!E(n))throw new t(r);return n}async function B(e,t){if(t.kty==="RSA"&&"oth"in t&&t.oth!==void 0)throw new m('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');if(!e.kty.includes(t.kty))throw new m('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');let r=e.resolve?.({kty:t.kty,crv:t.crv})??e.subtle,n=!!(t.d||t.priv),o={...t};if(o.kty!=="AKP")delete o.alg;return delete o.use,crypto.subtle.importKey("jwk",o,r,t.ext??!n,t.key_ops??e.usages[n?1:0])}function re(e){return{__proto__:null,...e}}function Be(e){let t=re(e);if(t.ext!==void 0&&typeof t.ext!=="boolean")throw TypeError('"ext" (Extractable) Parameter must be a boolean');if(t.key_ops!==void 0){let r=t.key_ops,n=Array.isArray(r)?[...r]:void 0;if(!n||n.some((o)=>typeof o!=="string")||new Set(n).size!==n.length)throw TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');t.key_ops=n}return t}var st=(e)=>e[Symbol.toStringTag],Ar=(e,t,r)=>{let{alg:n}=e;if(t.use!==void 0){let o=r==="sign"||r==="verify"?"sig":"enc";if(t.use!==o)throw TypeError(`Invalid key for this operation, its "use" must be "${o}" when present`)}if(t.alg!==void 0&&t.alg!==n)throw TypeError(`Invalid key for this operation, its "alg" must be "${n}" when present`);if(Array.isArray(t.key_ops)){let o=r==="encrypt"||r==="decrypt"?e.ops?.[r==="encrypt"?0:1]:r;if(o&&!t.key_ops.includes(o))throw TypeError(`Invalid key for this operation, its "key_ops" must include "${o}" when present`)}};function Kr(e,t,r){let{alg:n,secret:o}=e,i=r==="decrypt"||r==="sign";if(o&&t instanceof Uint8Array)return[Dt,t];if(E(t)){let a=Be(t);if(typeof a.kty!=="string")throw TypeError(o?he(n,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"):he(n,t,"CryptoKey","KeyObject","JSON Web Key"));if(!(o?a.kty==="oct"&&typeof a.k==="string":a.kty!=="oct"&&(i?a.kty==="AKP"&&typeof a.priv==="string"||typeof a.d==="string":a.d===void 0&&a.priv===void 0)))throw TypeError(o?'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present':`JSON Web Key for this operation must be a ${i?"private":"public"} JWK`);return Ar(e,a,r),[Rt,t,a]}if(!De(t))throw TypeError(o?he(n,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"):he(n,t,"CryptoKey","KeyObject","JSON Web Key"));if(o){if(t.type!=="secret")throw TypeError(`${st(t)} instances for symmetric algorithms must be of type "secret"`)}else{if(t.type==="secret")throw TypeError(`${st(t)} instances for asymmetric algorithms must not be of type "secret"`);let a=i?"private":"public";if((t.type==="public"||t.type==="private")&&t.type!==a){let s=r==="sign"?"signing":r==="verify"?"verifying":`${r.slice(0,-1)}tion`;throw TypeError(`${st(t)} instances for asymmetric algorithm ${s} must be of type "${a}"`)}}return H(t)?[Ut,t]:[Nt,t]}var Dt=0,Ut=1,Nt=2,Rt=3,ct,Jr={__proto__:null,prime256v1:"P-256",secp384r1:"P-384",secp521r1:"P-521"};function Me(e,t,r){ct||=new WeakMap;let n=ct.get(e);if(r)if(n)n[t]=r;else ct.set(e,{[t]:r});return r??n?.[t]}var _t=async(e,t,r)=>Me(e,r.alg)??Me(e,r.alg,await B(r,{...t,alg:r.alg})),vr=(e,t)=>{let r=Me(e,t.alg);if(r)return r;let n=e.type==="public",o=t.usages[n?0:1],{asymmetricKeyType:i}=e,a=Jr[e.asymmetricKeyDetails?.namedCurve],s=t.resolve?.({crv:a,asymmetricKeyType:i})??t.subtle;return Me(e,t.alg,e.toCryptoKey(s,n,o))};async function O(e,t,r){let n=Kr(e,t,r);switch(n[0]){case Dt:case Ut:return n[1];case Rt:{let o=n[1],i=n[2];if(i.kty==="oct")return I(i.k);if(!Object.isFrozen(o)){let{key_ops:a}=o;if(Array.isArray(a))Object.freeze(a);Object.freeze(o)}return _t(o,i,e)}case Nt:{let o=n[1];if(o.type==="secret")return o.export();if("toCryptoKey"in o&&typeof o.toCryptoKey==="function")return vr(o,e);return _t(o,o.export({format:"jwk"}),e)}}}function Ee(e){let t={__proto__:null};for(let r in e)t[r]={...e[r],alg:r};return t}var Cr=[["encrypt","wrapKey"],["decrypt","unwrapKey"]],Wr=[[],["deriveBits"]],je=[[],[]];function Le(e){return{kty:["RSA"],subtle:{name:"RSA-OAEP",hash:`SHA-${e}`},usages:Cr,ops:["wrapKey","unwrapKey"]}}function $e(){return{kty:["EC","OKP"],subtle:{name:"ECDH"},resolve:({kty:e,crv:t,asymmetricKeyType:r})=>{if(t==="X25519"||r==="x25519")return{name:"X25519"};if(e==="OKP")throw new m('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');return{name:"ECDH",namedCurve:t}},usages:Wr,ops:[void 0,"deriveBits"]}}function ne(e,t=!1){return{kty:["oct"],secret:!0,subtle:{name:t?"AES-GCM":"AES-KW",length:e},usages:je,ops:t?["encrypt","decrypt"]:["wrapKey","unwrapKey"]}}function pt(){return{kty:["oct"],secret:!0,subtle:{name:"PBKDF2"},usages:je,ops:["deriveBits","deriveBits"]}}var dt=Ee({dir:{kty:["oct"],secret:!0,subtle:{name:"AES-GCM"},usages:je,ops:["encrypt","decrypt"]},"RSA-OAEP":Le(1),"RSA-OAEP-256":Le(256),"RSA-OAEP-384":Le(384),"RSA-OAEP-512":Le(512),"ECDH-ES":$e(),"ECDH-ES+A128KW":$e(),"ECDH-ES+A192KW":$e(),"ECDH-ES+A256KW":$e(),A128KW:ne(128),A192KW:ne(192),A256KW:ne(256),A128GCMKW:ne(128,!0),A192GCMKW:ne(192,!0),A256GCMKW:ne(256,!0),"PBES2-HS256+A128KW":pt(),"PBES2-HS384+A192KW":pt(),"PBES2-HS512+A256KW":pt()}),Pr=["encrypt","decrypt"];function oe(e,t=!1){return{kty:["oct"],secret:!0,subtle:{name:t?"AES-CBC":"AES-GCM",length:e},usages:je,ops:Pr,cekBits:e,ivBits:t?128:96,cbc:t}}var Tr=Ee({A128GCM:oe(128),A192GCM:oe(192),A256GCM:oe(256),"A128CBC-HS256":oe(256,!0),"A192CBC-HS384":oe(384,!0),"A256CBC-HS512":oe(512,!0)});function Ht(e,t){throw new m(`Invalid or unsupported "${e}" (JWE ${t}) header value`)}function _(e){return(typeof e==="string"?dt[e]:void 0)??Ht("alg","Algorithm")}function Z(e){return(typeof e==="string"?Tr[e]:void 0)??Ht("enc","Encryption Algorithm")}function kt(e,t){if(e.algorithm.name!=="ECDH"&&e.algorithm.name!=="X25519")throw TypeError("CryptoKey does not support this operation, its algorithm.name must be ECDH or X25519");rt(e,t)}async function Mt(e,t,r){let n=_(t).subtle,o=e instanceof Uint8Array?await crypto.subtle.importKey("raw",e,"AES-KW",!0,[r]):e;return N(o,n,r),o}async function ut(e,t,r){let n=await Mt(t,e,"wrapKey"),o=await crypto.subtle.importKey("raw",r,{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.wrapKey("raw",o,n,"AES-KW"))}async function ft(e,t,r){let n=await Mt(t,e,"unwrapKey"),o=await crypto.subtle.unwrapKey("raw",r,n,"AES-KW",{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.exportKey("raw",o))}function Lt(e,t,r){N(t,_(e).subtle,r),Oe(e,t)}function Ir(e,t){if(e instanceof Uint8Array)return crypto.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);return N(e,_(t).subtle,"deriveBits"),e}async function $t(e,t,r,n){if(!(e instanceof Uint8Array)||e.length<8)throw new u("PBES2 Salt Input must be 8 or more octets");if(!Number.isSafeInteger(r)||Math.sign(r)!==1)throw new u("PBES2 Count Input must be a positive integer");let o=b(g(t),Uint8Array.of(0),e),i=parseInt(t.slice(13,16),10),a={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:o},s=await Ir(n,t);return new Uint8Array(await crypto.subtle.deriveBits(a,s,i))}function lt(e){return b(Te(e.length),e)}async function Or(e,t,r){let n=t>>3,o=32,i=Math.ceil(n/32),a=new Uint8Array(i*32);for(let s=1;s<=i;s++){let c=await ke("sha256",b(Te(s),e,r));a.set(c,(s-1)*32)}return a.slice(0,n)}async function jt(e,t,r,n,o=new Uint8Array,i=new Uint8Array){kt(e),kt(t,"deriveBits");let a=b(lt(g(r)),lt(o),lt(i),Te(n)),s=new Uint8Array(await crypto.subtle.deriveBits({name:e.algorithm.name,public:e},t,e.algorithm.name==="X25519"?256:Math.ceil(parseInt(e.algorithm.namedCurve.slice(-3),10)/8)<<3));return Or(s,n,a)}function Vt(e){_e(e);let t=e.algorithm.namedCurve;if(t!=="P-256"&&t!=="P-384"&&t!=="P-521"&&e.algorithm.name!=="X25519")throw new m("ECDH with the provided key is not allowed or not supported by your javascript runtime")}function be(e){if(e===void 0)throw new u("JWE Encrypted Key missing")}function Bt(e){if(e!==void 0)throw new u("Encountered unexpected JWE Encrypted Key")}async function zt(e,t,r,n,o,i){let a=_(e);if(e==="dir")return Bt(n),r;switch(a.subtle.name){case"ECDH":{if(e==="ECDH-ES")Bt(n);if(!E(o.epk))throw new u('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');Vt(r);let s=await B(a,o.epk),c,p;if(o.apu!==void 0){if(typeof o.apu!=="string")throw new u('JOSE Header "apu" (Agreement PartyUInfo) invalid');c=A(o.apu,"apu",u)}if(o.apv!==void 0){if(typeof o.apv!=="string")throw new u('JOSE Header "apv" (Agreement PartyVInfo) invalid');p=A(o.apv,"apv",u)}let d=await jt(s,r,e==="ECDH-ES"?t.alg:e,e==="ECDH-ES"?t.cekBits:parseInt(e.slice(-5,-2),10),c,p);if(e==="ECDH-ES")return d;return be(n),ft(e.slice(-6),d,n)}case"RSA-OAEP":return be(n),_e(r),Lt(e,r,"decrypt"),new Uint8Array(await crypto.subtle.decrypt("RSA-OAEP",r,n));case"PBKDF2":{if(be(n),typeof o.p2c!=="number")throw new u('JOSE Header "p2c" (PBES2 Count) missing or invalid');let s=i||1e4;if(o.p2c>s)throw new u('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if(typeof o.p2s!=="string")throw new u('JOSE Header "p2s" (PBES2 Salt) missing or invalid');let c=A(o.p2s,"p2s",u),p=await $t(c,e,o.p2c,r);return ft(e.slice(-6),p,n)}case"AES-KW":return be(n),ft(e,r,n);case"AES-GCM":{if(be(n),typeof o.iv!=="string")throw new u('JOSE Header "iv" (Initialization Vector) missing or invalid');if(typeof o.tag!=="string")throw new u('JOSE Header "tag" (Authentication Tag) missing or invalid');let s;s=A(o.iv,"iv",u);let c;return c=A(o.tag,"tag",u),Ne(Z(e.slice(0,-2)),r,n,s,c,new Uint8Array)}}}async function Gt(e,t,r,n,o={}){let i,a,s,c=_(e);if(e==="dir")return[r,void 0,void 0];switch(c.subtle.name){case"ECDH":{Vt(r);let{apu:p,apv:d}=o;if(p!==void 0)Y(p,'"apu"');if(d!==void 0)Y(d,'"apv"');let f;if(o.epk!==void 0)f=await O(c,o.epk,"decrypt");else f=(await crypto.subtle.generateKey(r.algorithm,!0,["deriveBits"])).privateKey;let l=crypto.subtle,S=f;if(!S.extractable){if(typeof l.getPublicKey!=="function")throw TypeError('CryptoKey for "epk" must be extractable');S=await l.getPublicKey(f,[])}let{x:v,y:w,crv:h,kty:J}=await l.exportKey("jwk",S),y=await jt(r,f,e==="ECDH-ES"?t.alg:e,e==="ECDH-ES"?t.cekBits:parseInt(e.slice(-5,-2),10),p,d);if(a={epk:{x:v,crv:h,kty:J}},J==="EC")a.epk.y=w;if(p)a.apu=mr(p);if(d)a.apv=mr(d);if(e==="ECDH-ES"){s=y;break}s=n||k(t);let x=e.slice(-6);i=await ut(x,y,s);break}case"RSA-OAEP":{s=n||k(t),_e(r),Lt(e,r,"encrypt"),i=new Uint8Array(await crypto.subtle.encrypt("RSA-OAEP",r,s));break}case"PBKDF2":{s=n||k(t);let{p2c:p=2048,p2s:d=crypto.getRandomValues(new Uint8Array(16))}=o,f=await $t(d,e,p,r);i=await ut(e.slice(-6),f,s),a={p2c:p,p2s:mr(d)};break}case"AES-KW":{s=n||k(t),i=await ut(e,r,s);break}case"AES-GCM":{s=n||k(t);let{iv:p}=o,d=await Ue(Z(e.slice(0,-2)),s,r,p,new Uint8Array);i=d.ciphertext,a={iv:mr(d.iv),tag:mr(d.tag)};break}}return[s,i,a]}var ie={__proto__:null,b64:!0},Ve={__proto__:null};function Se(e,t){if(t!==void 0&&(!Array.isArray(t)||t.some((r)=>typeof r!=="string")))throw TypeError(`"${e}" option must be an array of strings`);if(!t)return;return new Set(t)}function ze(e,t){let{crit:r}=t??{};if(Array.isArray(r)&&new Set(r).size!==r.length)throw new e('"crit" (Critical) Header Parameter MUST NOT contain duplicate values')}function D(e,t,r,n,o){if(o.crit!==void 0&&n?.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return[];if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some((a)=>typeof a!=="string"||a.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i=r===void 0?t:{__proto__:null,...r,...t};for(let a of n.crit){if(!(a in i))throw new m(`Extension Header Parameter "${a}" is not recognized`);if(!Object.hasOwn(o,a)||o[a]===void 0)throw new e(`Extension Header Parameter "${a}" is missing`);if(i[a]&&(!Object.hasOwn(n,a)||n[a]===void 0))throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return n.crit}function ae(e,t){if(t.includes("b64")){let r=e.b64;if(typeof r!=="boolean")throw new zr('The "b64" (base64url-encode payload) Header Parameter must be a boolean');return r}return!0}function se(e,t){let r,n;try{r=JSON.stringify(t),n=JSON.parse(r)}catch(o){throw new e("JOSE Header is not valid JSON",{cause:o})}if(!E(n))throw new e("JOSE Header is not a JSON object");return[n,r]}function Ge(e,t){if(e.zip!==void 0&&e.zip!=="DEF")throw new m('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(e.zip!==void 0&&!t?.zip)throw new u('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.')}function Ft(e){if(typeof globalThis[e]>"u")throw new m(`JWE "zip" (Compression Algorithm) Header Parameter requires the ${e} API.`)}async function Xt(e){Ft("CompressionStream");let t=new CompressionStream("deflate-raw"),r=t.writable.getWriter();r.write(e).catch(()=>{}),r.close().catch(()=>{});let n=[],o=t.readable.getReader();for(;;){let{value:i,done:a}=await o.read();if(a)break;n.push(i)}return b(...n)}async function Yt(e,t){Ft("DecompressionStream");let r=new DecompressionStream("deflate-raw"),n=r.writable.getWriter();n.write(e).catch(()=>{}),n.close().catch(()=>{});let o=[],i=0,a=r.readable.getReader();for(;;){let{value:s,done:c}=await a.read();if(c)break;if(o.push(s),i+=s.byteLength,t!==1/0&&i>t)throw new u("Decompressed plaintext exceeded the configured limit")}return b(...o)}function qt(e){return[e&&Se("keyManagementAlgorithms",e.keyManagementAlgorithms),e&&Se("contentEncryptionAlgorithms",e.contentEncryptionAlgorithms),e?.crit,e?.maxPBES2Count,e?.maxDecompressedLength]}async function _r(e,t,r,n,o){let[i,a,s,c,p]=r,[d,f,l,S,v]=t,{encrypted_key:w}=e;D(u,Ve,s,d,o),Ge(o,d);let{alg:h,enc:J}=o;if(typeof h!=="string"||!h)throw new u("missing JWE Algorithm (alg) in JWE Header");if(typeof J!=="string"||!J)throw new u("missing JWE Encryption Algorithm (enc) in JWE Header");if(i&&!i.has(h)||!i&&h.startsWith("PBES2"))throw new X('"alg" (Algorithm) Header Parameter value not allowed');if(a&&!a.has(J))throw new X('"enc" (Encryption Algorithm) Header Parameter value not allowed');let y=Z(J),x;if(w!==void 0)x=A(w,"encrypted_key",u);let C=!1;if(typeof n==="function")n=await n(d,e),C=!0;let U=_(h),T=await O(h==="dir"?y:U,n,"decrypt"),W;try{if(W=await zt(h,y,T,x,o,c),w!==void 0&&W instanceof Uint8Array&&W.byteLength<<3!==y.cekBits)W=k(y)}catch(K){if(K instanceof TypeError||K instanceof u||K instanceof m)throw K;W=k(y)}let z=await Ne(y,W,f,l,S,v);if(o.zip==="DEF"){let K=p??250000;if(K===0)throw new m('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');if(K!==1/0&&(!Number.isSafeInteger(K)||K<1))throw TypeError("maxDecompressedLength must be 0, a positive safe integer, or Infinity");z=await Yt(z,K).catch((G)=>{if(G instanceof u)throw G;throw new u("Failed to decompress plaintext",{cause:G})})}return[z,d,T,C]}async function Zt(e,t,r){if(e instanceof Uint8Array)e=F.decode(e);if(typeof e!=="string")throw new u("Compact JWE must be a string or Uint8Array");let{0:n,1:o,2:i,3:a,4:s,length:c}=e.split(".");if(c!==5)throw new u("Invalid Compact JWE");let p={ciphertext:a,iv:i||void 0,protected:n,tag:s||void 0,encrypted_key:o||void 0},d=V(n,u,"JWE Protected Header is invalid"),f=g(n),l=[d,A(a,"ciphertext",u),i?A(i,"iv",u):void 0,s?A(s,"tag",u):void 0,f];return _r(p,l,t,r,d)}function Qt(e,t,r){if(!It(e,t,r))throw new u("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint")}function Dr(e){let[,t,r,n,o,i,a,s,c]=e;if(o!==void 0)Y(o,"JWE Additional Authenticated Data");if(i!==void 0)Y(i,"JWE Content Encryption Key");if(a!==void 0)Y(a,"JWE Initialization Vector");if(t!==void 0)t=se(u,t)[0],e[1]=t;if(r!==void 0)r=se(u,r)[0],e[2]=r;if(n!==void 0)n=se(u,n)[0],e[3]=n;if(s!==void 0&&!E(s))throw TypeError("JWE Key Management Parameters must be an object");Qt(t,r,n);let p={...t,...r,...n};ze(u,t),D(u,Ve,c,t,p),Ge(p,t);let{alg:d,enc:f}=p;if(typeof d!=="string"||!d)throw new u('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(typeof f!=="string"||!f)throw new u('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');return[p,d,f,Z(f)]}async function Ur(e,t,r){let[n,o,,i]=t,[a,s,c,p,d,f,l,S,,v]=e,w=s,h=c;if(f&&(o==="dir"||o==="ECDH-ES"))throw TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${o}`);let J=_(o),y=await O(o==="dir"?i:J,r,"encrypt"),[x,C,U]=await Gt(o,i,y,f,S);if(U){if(v)h=h?{...h,...U}:U;else w=w?{...w,...U}:U;Qt(w,h,p)}let T,W;if(w)T=mr(JSON.stringify(w)),W=g(T);else T="",W=new Uint8Array;let z,K;if(d?.byteLength)K=mr(d),z=b(W,g("."),g(K));else z=W;let G=a;if(n.zip==="DEF")G=await Xt(G).catch((hr)=>{throw new u("Failed to compress plaintext",{cause:hr})});let{ciphertext:yr,tag:Kt,iv:Jt}=await Ue(i,G,x,l,z),j={ciphertext:mr(yr)};if(Jt)j.iv=mr(Jt);if(Kt)j.tag=mr(Kt);if(C)j.encrypted_key=mr(C);if(K)j.aad=K;if(w)j.protected=T;if(p)j.unprotected=p;if(h)j.header=h;return j}async function er(e,t,r){if(!e[1]&&!e[2]&&!e[3])throw new u("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(r!==void 0)e[8]=r?.crit,e[9]=r?Ot in r:!1;return Ur(e,Dr(e),t)}async function tr(e,t,r){if(t instanceof Uint8Array)return crypto.subtle.importKey("raw",t,e.subtle,!1,[r]);if(N(t,e.subtle,r),e.minRsaBits)Oe(e.alg,t);return t}async function rr(e,t,r){let n=await tr(e,t,"sign"),o=await crypto.subtle.sign(e.signing,n,r);return new Uint8Array(o)}async function nr(e,t,r,n){let o=await tr(e,t,"verify");try{return await crypto.subtle.verify(e.signing,o,r,n)}catch{return!1}}var xe=[["verify"],["sign"]];function mt(e){let t={name:"HMAC",hash:`SHA-${e}`};return{kty:["oct"],secret:!0,subtle:t,signing:t,usages:xe}}function ce(e,t){let n={name:t?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:`SHA-${e}`};return{kty:["RSA"],subtle:n,signing:t?{...n,saltLength:t}:n,usages:xe,minRsaBits:2048}}function yt(e,t){return{kty:["EC"],crv:e,subtle:{name:"ECDSA",namedCurve:e},signing:{name:"ECDSA",hash:`SHA-${t}`},usages:xe}}function or(){let e={name:"Ed25519"};return{kty:["OKP"],crv:"Ed25519",subtle:e,signing:e,usages:xe}}function ht(e){let r={name:`ML-DSA-${e}`};return{kty:["AKP"],subtle:r,signing:r,usages:xe}}var Ae=Ee({HS256:mt(256),HS384:mt(384),HS512:mt(512),RS256:ce(256),RS384:ce(384),RS512:ce(512),PS256:ce(256,32),PS384:ce(384,48),PS512:ce(512,64),ES256:yt("P-256",256),ES384:yt("P-384",384),ES512:yt("P-521",512),EdDSA:or(),Ed25519:or(),"ML-DSA-44":ht(44),"ML-DSA-65":ht(65),"ML-DSA-87":ht(87)});function Fe(e){let t=typeof e==="string"?Ae[e]:void 0;if(!t)throw new m(`alg ${e} is not supported either by JOSE or your javascript runtime`);return t}function Xe(e){return[e&&Se("algorithms",e.algorithms),e?.crit]}function Nr(e,t=e===void 0?{}:V(e,zr,"JWS Protected Header is invalid")){return t}function Rr(e,t,r){let n=ae(e,D(zr,ie,r[1],e,t)),o=t.alg;if(typeof o!=="string"||!o)throw new zr('JWS "alg" (Algorithm) Header Parameter missing or invalid');if(r[0]&&!r[0].has(o))throw new X('"alg" (Algorithm) Header Parameter value not allowed');return[n,o]}function Hr(e){try{return g(e)}catch{throw new zr("JWS Compact Serialization payload must use only ASCII characters")}}async function kr(e,t,r,n,o,i,a){let s=!1;if(typeof r==="function")r=await r(o,e),s=!0;let c=typeof a==="string",p=Fe(i),d=b(n!==void 0?g(n):new Uint8Array,g("."),c?t[2]??=at(a,"payload",zr):a),f=A(e.signature,"signature",zr),l=await O(p,r,"verify");if(!await nr(p,l,f,d))throw new Qu;return[c?A(a,"payload",zr):a,o,c,l,s]}async function qe(e,t,r){if(e instanceof Uint8Array)e=F.decode(e);if(typeof e!=="string")throw new zr("Compact JWS must be a string or Uint8Array");let{0:n,1:o,2:i,length:a}=e.split(".");if(a!==3)throw new zr("Invalid Compact JWS");let s={payload:o,protected:n,signature:i},c=Nr(n),[p,d]=Rr(c,c,t),f=p?o:Hr(o);return kr(s,t,r,n,c,d,f)}async function Gu(e,t,r){let n=await qe(e,Xe(r),t),o={payload:n[0],protectedHeader:n[1]};if(typeof t==="function")return{...o,key:n[3]};return o}var Ke=(e)=>Math.floor(e.getTime()/1000),Br={s:1,m:60,h:3600,d:86400,w:604800,y:31557600},Mr=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,pe="check_failed";function wt(){throw TypeError("Invalid time period format")}function Ze(e){if(typeof e!=="string")wt();let t=Mr.exec(e);if(!t||t[4]&&t[1])wt();let r=parseFloat(t[2]),n=Math.round(r*Br[t[3][0].toLowerCase()]);if(!Number.isFinite(n))wt();if(t[1]==="-"||t[4]==="ago")return-n;return n}function de(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}function gt(e,t){if(typeof t!=="string")throw TypeError(`"${e}" claim must be a string`)}function Lr(e){if(typeof e!=="string"&&(!Array.isArray(e)||Array.from(e).some((t)=>typeof t!=="string")))throw TypeError('"aud" claim must be a string or an array of strings')}function Et(e,t){if(typeof e==="number")return de(t,e);if(e instanceof Date)return de(t,Ke(e));return Ke(new Date)+Ze(e)}var ir=(e)=>{let t=e.toLowerCase();return e.includes("/")?t:`application/${t}`},$r=(e,t)=>{if(typeof e==="string")return t.includes(e);if(Array.isArray(e))return t.some((r)=>e.includes(r));return!1};function bt(e,t,r=!1){let n=e[t];if(n===void 0&&!r)return;if(typeof n!=="number")throw new P(`"${t}" claim must be a number`,e,t,"invalid");return n}function St(e,t){throw new P(`unexpected "${t}" claim value`,e,t,pe)}function ue(e,t,r={}){let n;try{n=JSON.parse(te.decode(t))}catch{}if(!E(n))throw new jr("JWT Claims Set must be a top-level JSON object");let{typ:o}=r;if(o!==void 0&&(typeof e.typ!=="string"||ir(e.typ)!==ir(o)))throw new P('unexpected "typ" JWT header value',n,"typ",pe);let{requiredClaims:i=[],issuer:a,subject:s,audience:c,maxTokenAge:p}=r,d=[...i];if(p!==void 0)d.push("iat");if(c!==void 0)d.push("aud");if(s!==void 0)d.push("sub");if(a!==void 0)d.push("iss");for(let y of new Set(d.reverse()))if(!Object.hasOwn(n,y))throw new P(`missing required "${y}" claim`,n,y,"missing");if(a!==void 0&&!(Array.isArray(a)?a:[a]).includes(n.iss))St(n,"iss");if(s!==void 0&&n.sub!==s)St(n,"sub");if(c!==void 0&&!$r(n.aud,typeof c==="string"?[c]:c))St(n,"aud");let{clockTolerance:f}=r,l=0;if(typeof f==="string")l=Ze(f);else if(f!==void 0){if(typeof f!=="number")throw TypeError("Invalid clockTolerance option type");l=f}de("clockTolerance option",l);let{currentDate:S}=r,v=de("currentDate option",Ke(S===void 0?new Date:S)),w=bt(n,"iat",p!==void 0),h=bt(n,"nbf");if(h!==void 0){if(h>v+l)throw new P('"nbf" claim timestamp check failed',n,"nbf",pe)}let J=bt(n,"exp");if(J!==void 0){if(J<=v-l)throw new yi('"exp" claim timestamp check failed',n,"exp",pe)}if(p!==void 0){let y=v-w,x=de("maxTokenAge option",typeof p==="number"?p:Ze(p));if(y-l>x)throw new yi('"iat" claim timestamp check failed (too far in the past)',n,"iat",pe);if(y<-l)throw new P('"iat" claim timestamp check failed (it should be in the past)',n,"iat",pe)}return n}var ar;function M(e){return ar.get(e)}function fe(e){let t=M(e);for(let r of["iat","nbf","exp"]){let n=t[r];if(typeof n==="number"&&!Number.isFinite(n))throw TypeError(`"${r}" claim must be a finite number`)}return ye.encode(JSON.stringify(t))}function Qe(e,t){return M(e)[t]}class Q{constructor(e={}){if(!E(e))throw TypeError("JWT Claims Set MUST be an object");(ar||=new WeakMap).set(this,structuredClone(e))}setIssuer(e){return gt("iss",e),M(this).iss=e,this}setSubject(e){return gt("sub",e),M(this).sub=e,this}setAudience(e){return Lr(e),M(this).aud=e,this}setJti(e){return gt("jti",e),M(this).jti=e,this}setNotBefore(e){return M(this).nbf=Et(e,"setNotBefore"),this}setExpirationTime(e){return M(this).exp=Et(e,"setExpirationTime"),this}setIssuedAt(e){let t=M(this);if(e===void 0)t.iat=Ke(new Date);else if(typeof e==="string")t.iat=de("setIssuedAt",Ke(new Date)+Ze(e));else t.iat=Et(e,"setIssuedAt");return this}}async function Qr(e,t,r){let n=await qe(e,Xe(r),t);if(!n[2])throw new jr("JWTs MUST NOT use unencoded payload");let i={payload:ue(n[1],n[0],r),protectedHeader:n[1]};if(typeof t==="function")return{...i,key:n[3]};return i}async function Vu(e,t,r){let n=await Zt(e,qt(r),t),o=n[1],i=ue(o,n[0],r);for(let s of["iss","sub","aud"])if(o[s]!==void 0&&(s==="aud"?JSON.stringify(o.aud)!==JSON.stringify(i.aud):o[s]!==i[s]))throw new P(`replicated "${s}" claim header parameter mismatch`,i,s,"mismatch");let a={payload:i,protectedHeader:o};if(typeof t==="function")return{...a,key:n[2]};return a}function Vr(e){if(e===void 0)return[void 0,""];let t=se(zr,e);return[t[0],mr(t[1])]}function Gr(e,t,r){return ze(zr,e),ae(e,D(zr,ie,r,e,t))}function Fr(e){let t=e.alg;if(typeof t!=="string"||!t)throw new zr('JWS "alg" (Algorithm) Header Parameter missing or invalid');return Fe(t)}async function Xr(e,t,r,n){let o=b(g(e),g("."),t),i=await O(r,n,"sign");return mr(await rr(r,i,o))}async function sr(e,t,r,n,o){let[i,a]=Vr(t);if(!i)throw new zr("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Gr(i,i,r))o();let c=Fr(i),p=mr(e),d=await Xr(a,g(p),c,n);return`${a}.${p}.${d}`}var Yr=Q;class bs extends Yr{#e;setProtectedHeader(e){return q(this.#e,"setProtectedHeader"),this.#e=e,this}async sign(e,t){return sr(fe(this),this.#e,t?.crit,e,()=>{throw new jr("JWTs MUST NOT use unencoded payload")})}}var qr=Q;class Ku extends qr{#e;#r;#n;#t;#o;#i;#a;setProtectedHeader(e){return q(this.#t,"setProtectedHeader"),this.#t=e,this}setKeyManagementParameters(e){return q(this.#n,"setKeyManagementParameters"),this.#n=e,this}setContentEncryptionKey(e){return q(this.#e,"setContentEncryptionKey"),this.#e=e,this}setInitializationVector(e){return q(this.#r,"setInitializationVector"),this.#r=e,this}replicateIssuerAsHeader(){return this.#o=!0,this}replicateSubjectAsHeader(){return this.#i=!0,this}replicateAudienceAsHeader(){return this.#a=!0,this}async encrypt(e,t){let r=fe(this);if(this.#t&&(this.#o||this.#i||this.#a))this.#t={...this.#t,iss:this.#o?Qe(this,"iss"):void 0,sub:this.#i?Qe(this,"sub"):void 0,aud:this.#a?Qe(this,"aud"):void 0};let n=await er([r,this.#t,void 0,void 0,void 0,this.#e,this.#r,this.#n,void 0,!1],e,t);return[n.protected,n.encrypted_key,n.iv,n.ciphertext,n.tag].join(".")}}var le='"alg" (Algorithm)';function Je(e='JWK "alg" (Algorithm) Parameter'){throw new m(`Invalid or unsupported ${e} value`)}function ee(e,t){return(typeof e==="string"?Ae[e]??dt[e]:void 0)??Je(t)}function me(e){if(e!==void 0&&typeof e!=="boolean")throw TypeError('"extractable" option must be a boolean');return e}var ve=(e,t)=>{if(e.byteLength!==t.length)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},Zr=(e)=>({data:e,pos:0}),xt=(e)=>{let t=e.data[e.pos++];if(t===void 0)throw Error("Unexpected end of ASN.1 input");return t},Ce=(e)=>{let t=xt(e);if(t&128){let r=t&127,n=0;for(let o=0;o<r;o++)n=n<<8|xt(e);return n}return t};var We=(e,t,r)=>{if(xt(e)!==t)throw Error(r)},cr=(e,t)=>{if(t<0||e.pos+t>e.data.length)throw Error("Unexpected end of ASN.1 input");let r=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,r},tn=(e)=>{We(e,6,"Expected algorithm OID");let t=Ce(e);return cr(e,t)};function rn(e,t){if(We(e,48,`Invalid ${t==="spki"?"SPKI":"PKCS#8"} structure`),Ce(e),t==="pkcs8"){We(e,2,"Expected version field");let r=Ce(e);e.pos+=r}We(e,48,"Expected algorithm identifier"),Ce(e)}var nn=(e)=>{let t=tn(e);if(ve(t,[43,101,110]))return"X25519";if(!ve(t,[42,134,72,206,61,2,1]))throw Error("Unsupported key algorithm");We(e,6,"Expected curve OID");let r=Ce(e),n=cr(e,r);if(ve(n,[42,134,72,206,61,3,1,7]))return"P-256";if(ve(n,[43,129,4,0,34]))return"P-384";if(ve(n,[43,129,4,0,35]))return"P-521";throw Error("Unsupported named curve")},on=async(e,t,r,n)=>{let o=me(n?.extractable),i=ee(r,le);if(i.secret)Je(le);let a=e==="spki",s;if(i.resolve)try{let c=Zr(t);rn(c,e),s=i.resolve({crv:nn(c)})}catch{throw new m("Invalid or unsupported key format")}else s=i.subtle;return crypto.subtle.importKey(e,t,s,o??a,i.usages[a?0:1])},an=(e,t)=>Re(e.replace(t,"")),pr=(e,t,r)=>{let n=an(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);return on("pkcs8",n,t,r)};function sn(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}async function cn(e){if(nt(e))if(e.type==="secret")e=e.export();else return e.export({format:"jwk"});if(e instanceof Uint8Array)return{kty:"oct",k:mr(e)};if(!H(e))throw TypeError(R(e,"CryptoKey","KeyObject","Uint8Array"));if(!e.extractable)throw TypeError("non-extractable CryptoKey cannot be exported as a JWK");let{ext:t,key_ops:r,alg:n,use:o,...i}=sn(await crypto.subtle.exportKey("jwk",e));if(i.kty==="AKP")i.alg=n;return i}function bl(e){return cn(e)}var L=(e,t)=>{if(typeof e!=="string"||!e)throw new ge(`${t} missing or invalid`)};async function wl(e,t){let r;if(E(e)){if(r=re(e),typeof r.kty!=="string")throw TypeError(R(e,"CryptoKey","KeyObject","JSON Web Key"))}else if(De(e))r=re(await bl(e));else throw TypeError(R(e,"CryptoKey","KeyObject","JSON Web Key"));if(t??="sha256",t!=="sha256"&&t!=="sha384"&&t!=="sha512")throw TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');let n;switch(r.kty){case"AKP":L(r.alg,'"alg" (Algorithm) Parameter'),L(r.pub,'"pub" (Public key) Parameter'),n={alg:r.alg,kty:r.kty,pub:r.pub};break;case"EC":L(r.crv,'"crv" (Curve) Parameter'),L(r.x,'"x" (X Coordinate) Parameter'),L(r.y,'"y" (Y Coordinate) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x,y:r.y};break;case"OKP":L(r.crv,'"crv" (Subtype of Key Pair) Parameter'),L(r.x,'"x" (Public Key) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x};break;case"RSA":L(r.e,'"e" (Exponent) Parameter'),L(r.n,'"n" (Modulus) Parameter'),n={e:r.e,kty:r.kty,n:r.n};break;case"oct":if(typeof r.k!=="string")throw new ge('"k" (Key Value) Parameter missing or invalid');n={k:r.k,kty:r.kty};break;default:throw new m('"kty" (Key Type) Parameter missing or unsupported')}let o=g(JSON.stringify(n));return mr(await ke(t,o))}function pn(e,t,r,n){let{kty:o,key_ops:i,ext:a,kid:s,alg:c,use:p,crv:d}=re(e),f=Array.isArray(i)?[...i]:i;return(a===void 0||typeof a==="boolean")&&(f===void 0||Array.isArray(f)&&f.every((l,S)=>typeof l==="string"&&f.indexOf(l)===S)&&f.includes("verify"))&&t.kty.includes(o)&&(n===void 0||typeof n==="string"&&n===s)&&(c===void 0?o!=="AKP":r===c)&&(p===void 0||p==="sig")&&(!t.crv||d===t.crv)}async function dr(e,t,r){let n=e.get(t)||e.set(t,{}).get(t),{alg:o}=r;if(n[o]===void 0){let i=await B(r,{...t,alg:o,ext:!0});if(i.type!=="public")throw new _l("JSON Web Key Set members must be public keys");n[o]=i}return n[o]}function Qo(e){let t;try{t=structuredClone(e)}catch{}if(!He(t))throw new _l("JSON Web Key Set malformed");let r=new WeakMap;return Object.defineProperty(async(o,i)=>{let{alg:a,kid:s}={...o,...i?.header},c=typeof a==="string"?Ae[a]:void 0;if(!c||c.secret)throw new m('Unsupported "alg" value for a JSON Web Key Set');let p=t.keys.filter((l)=>pn(l,c,a,s)),{0:d,length:f}=p;if(!f)throw new yl;if(f!==1){let l=new vc;throw l[Symbol.asyncIterator]=async function*(){for(let S of p)try{yield await dr(r,S,c)}catch{}},l}return dr(r,d,c)},"jwks",{value:()=>structuredClone(t)})}function un(){return typeof WebSocketPair<"u"||typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime<"u"&&EdgeRuntime==="vercel"}var At;if(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))At="jose/v6.2.10";var fr=Symbol();async function fn(e,t,r,n=fetch){let o=await n(e,{method:"GET",signal:r,redirect:"manual",headers:t}).catch((i)=>{if(i.name==="TimeoutError")throw new vl;throw i});if(o.status!==200)throw new dn("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await o.json()}catch{throw new dn("Failed to parse the JSON Web Key Set HTTP response as JSON")}}var lr=Symbol();function Pe(e,t){return Number.isFinite(e)&&Date.now()<e+t}function ur(e,t,r){if(Number.isNaN(e))throw TypeError(`"${r}" option must not be NaN`);return typeof e==="number"?e:t}function Af(e,t){if(!(e instanceof URL))throw TypeError("url must be an instance of URL");let r=new URL(e.href).href,n=t??{},o=n.timeoutDuration;if(typeof o==="number"&&(!Number.isInteger(o)||o<0))throw TypeError('"timeoutDuration" option must be a non-negative integer');let i=typeof o==="number"?o:5000,a=ur(n.cooldownDuration,30000,"cooldownDuration"),s=ur(n.cacheMaxAge,600000,"cacheMaxAge"),c=new Headers(n.headers);if(At&&!c.has("User-Agent"))c.set("User-Agent",At);if(!c.has("accept"))c.set("accept","application/json, application/jwk-set+json");let p=n[fr],d=n[lr],f,l,S=0,v=0,w;if(d&&typeof d==="object"){let{uat:y,jwks:x}=d;if(Pe(y,s)&&He(x))f=y,w=Qo(x)}let h=async()=>{if(l&&un())l=void 0;if(!l){let y=++S,x=l=fn(r,c,AbortSignal.timeout(i),p).then((C)=>{let U=Qo(C);if(y<=v)return;w=U;let T=Date.now();if(d)d.uat=T,d.jwks=C;f=T,v=y}).finally(()=>{if(l===x)l=void 0})}await l};return Object.defineProperties(async(y,x)=>{if(!w||!Pe(f,s))await h();try{return await w(y,x)}catch(C){if(C instanceof yl&&!Pe(f,a))return await h(),w(y,x);throw C}},{coolingDown:{get:()=>Pe(f,a),enumerable:!0},fresh:{get:()=>Pe(f,s),enumerable:!0},reload:{value:h,enumerable:!0},reloading:{get:()=>!!l,enumerable:!0},jwks:{value:()=>w?.jwks(),enumerable:!0}})}var ln=Q;class bc extends ln{encode(){let e=mr(JSON.stringify({alg:"none"})),t=mr(fe(this));return`${e}.${t}.`}static decode(e,t){if(typeof e!=="string")throw new jr("Unsecured JWT must be a string");let{0:r,1:n,2:o,length:i}=e.split(".");if(i!==3||o!=="")throw new jr("Invalid Unsecured JWT");let a,s;try{a=V(r,zr,"JWS Protected Header is invalid");let p=D(zr,ie,void 0,a,a);s=ae(a,p)}catch(p){if(!(p instanceof zr))throw p;throw new jr("Invalid Unsecured JWT",{cause:p})}if(a.alg!=="none")throw new jr("Invalid Unsecured JWT");if(!s)throw new jr("JWTs MUST NOT use unencoded payload");return{payload:ue(a,A(n,"payload",jr),t),header:a}}}async function Ky(e,t,r){if(typeof e!=="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw TypeError('"pkcs8" must be PKCS#8 formatted string');return pr(e,t,r)}async function In(e,t,r){if(!E(e))throw TypeError("JWK must be an object");let n=Be(e),o=me(r?.extractable),{alg:i}=n;t??=i;let a=o??n.ext;if(n.kty!=="oct"&&!t)throw TypeError('"alg" argument is required when "jwk.alg" is not present');switch(n.kty){case"oct":if(typeof n.k!=="string")throw TypeError('missing "k" (Key Value) Parameter value');return I(n.k);case"AKP":{if(typeof i!=="string"||!i)throw TypeError('missing "alg" (Algorithm) Parameter value');if(t!==i)throw TypeError("JWK alg and alg option value mismatch");return B(ee(t),{...n,ext:a})}case"RSA":case"EC":case"OKP":return B(ee(t),{...n,alg:t,ext:a});default:throw new m('Unsupported "kty" (Key Type) Parameter value')}}function so(e){let t;if(typeof e==="string"){let n=e.split(".");if(n.length===3||n.length===5)[t]=n}else if(typeof e==="object"&&e)if("protected"in e)t=e.protected;else throw TypeError("Token does not contain a Protected Header");let r="Invalid Token or Protected Header formatting";if(typeof t!=="string"||!t)throw TypeError(r);return V(t,TypeError,r)}function en(e){if(typeof e!=="string")throw new jr("JWTs must use Compact JWS serialization, JWT must be a string");let{1:t,length:r}=e.split(".");if(r===5)throw new jr("Only JWTs using Compact JWS serialization can be decoded");if(r!==3)throw new jr("Invalid JWT");if(!t)throw new jr("JWTs must contain a payload");let n;try{n=I(t)}catch{throw new jr("Failed to base64url decode the payload")}let o;try{o=JSON.parse(te.decode(n))}catch{throw new jr("Failed to parse the decoded payload as JSON")}if(!E(o))throw new jr("Invalid JWT Claims Set");return o}function mn(e){let t=e?.modulusLength??2048;if(typeof t!=="number"||!Number.isInteger(t)||t<2048)throw new m("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return t}async function _f(e,t){let r=me(t?.extractable),n=ee(e,le);if(n.secret)Je(le);let o;if(n.resolve){let i=t?.crv??"P-256";switch(i){case"P-256":case"P-384":case"P-521":o={name:"ECDH",namedCurve:i};break;case"X25519":o={name:"X25519"};break;default:throw new m("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, and X25519")}}else{if(n.crv!==void 0&&t?.crv!==void 0&&t.crv!==n.crv)throw new m(`Invalid or unsupported crv option provided, the only supported value for ${e} is ${n.crv}`);o=n.kty[0]==="RSA"?{...n.subtle,publicExponent:Uint8Array.of(1,0,1),modulusLength:mn(t)}:n.subtle}return crypto.subtle.generateKey(o,r??!1,[...n.usages[1],...n.usages[0]])}export{dn,yi,zr,jr,_l,yl,vc,vl,Qu,eA,mr,Im,Gu,Qr,Vu,bs,Ku,bl,wl,Qo,Af,bc,Ky,In,so,en,_f};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{z}from"./chunk-
|
|
1
|
+
import{z}from"./chunk-5ngftxjb.js";var c=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],rs=z("wrench",c);
|
|
2
2
|
export{rs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S,L,a,X,Je,R,Pt,qt,Tg}from"./chunk-5ngftxjb.js";import"./chunk-ajq9sxg0.js";import"./chunk-1tar0x8s.js";import"./chunk-34f64q0q.js";import"./chunk-qvp24w0q.js";import"./chunk-9405hzv2.js";import"./chunk-qm50g4n5.js";import"./chunk-ffjdkdcv.js";import"./chunk-50pfmxt1.js";import"./chunk-20w1w9x7.js";import"./chunk-thpw6tcj.js";import"./chunk-pq6kdp83.js";import"./chunk-6f3zhq64.js";import"./chunk-d55138xx.js";import{xo}from"./chunk-cagzye3j.js";import"./chunk-sz5zawfw.js";import{Ar}from"./chunk-b3t7gbhm.js";import"./chunk-c1wvs81k.js";import"./chunk-etrm28sy.js";import"./chunk-0a298n62.js";import"./chunk-s1j4v33x.js";import"./chunk-pdw77q09.js";import"./chunk-femnbfkj.js";import"./chunk-25npafhz.js";import"./chunk-7kah3zb5.js";L();function s(){let{projectId:o}=m.useParams(),{teamId:r,ensureTeamIdForProject:t}=Pt();S(()=>{t(o)},[o,t]);let{data:n}=Ar(Tg(o)),e=n?.rootFolder,{data:d}=X({queryKey:["folders",e],queryFn:()=>(async()=>await(await R.api.folders[":folderId"].$get({param:{folderId:e}})).json())(),enabled:!!e});if(!r||!e||!d)return a(qt,{});return a(xo,{teamId:r,projectId:o,projectName:n.name??"",assetId:"recently-deleted",rootFolderId:e})}var m=Je("/projects/$projectId/recently-deleted")({component:s});export{m as Route};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Z,ae}from"./chunk-4p31kxjh.js";var X=Z(function(wt,V){var A=1000,E=A*60,I=E*60,S=I*24,Oe=S*7,Se=S*365.25;V.exports=function(e,r){r=r||{};var t=typeof e;if(t==="string"&&e.length>0)return Pe(e);else if(t==="number"&&isFinite(e))return r.long?Ae(e):je(e);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Pe(e){if(e=String(e),e.length>100)return;var r=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!r)return;var t=parseFloat(r[1]),n=(r[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*Se;case"weeks":case"week":case"w":return t*Oe;case"days":case"day":case"d":return t*S;case"hours":case"hour":case"hrs":case"hr":case"h":return t*I;case"minutes":case"minute":case"mins":case"min":case"m":return t*E;case"seconds":case"second":case"secs":case"sec":case"s":return t*A;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}function je(e){var r=Math.abs(e);if(r>=S)return Math.round(e/S)+"d";if(r>=I)return Math.round(e/I)+"h";if(r>=E)return Math.round(e/E)+"m";if(r>=A)return Math.round(e/A)+"s";return e+"ms"}function Ae(e){var r=Math.abs(e);if(r>=S)return k(e,r,S,"day");if(r>=I)return k(e,r,I,"hour");if(r>=E)return k(e,r,E,"minute");if(r>=A)return k(e,r,A,"second");return e+" ms"}function k(e,r,t,n){var s=r>=t*1.5;return Math.round(e/t)+" "+n+(s?"s":"")}});var U=Z(function(Ft,Y){function Ee(e){t.debug=t,t.default=t,t.coerce=_,t.disable=l,t.enable=s,t.enabled=v,t.humanize=X(),t.destroy=N,Object.keys(e).forEach((o)=>{t[o]=e[o]}),t.names=[],t.skips=[],t.formatters={};function r(o){let i=0;for(let c=0;c<o.length;c++)i=(i<<5)-i+o.charCodeAt(c),i|=0;return t.colors[Math.abs(i)%t.colors.length]}t.selectColor=r;function t(o){let i,c=null,a,y;function f(...d){if(!f.enabled)return;let m=f,g=Number(new Date),x=g-(i||g);if(m.diff=x,m.prev=i,m.curr=g,i=g,d[0]=t.coerce(d[0]),typeof d[0]!=="string")d.unshift("%O");let w=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(O,j)=>{if(O==="%%")return"%";w++;let Q=t.formatters[j];if(typeof Q==="function"){let xe=d[w];O=Q.call(m,xe),d.splice(w,1),w--}return O}),t.formatArgs.call(m,d),(m.log||t.log).apply(m,d)}if(f.namespace=o,f.useColors=t.useColors(),f.color=t.selectColor(o),f.extend=n,f.destroy=t.destroy,Object.defineProperty(f,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(c!==null)return c;if(a!==t.namespaces)a=t.namespaces,y=t.enabled(o);return y},set:(d)=>{c=d}}),typeof t.init==="function")t.init(f);return f}function n(o,i){let c=t(this.namespace+(typeof i>"u"?":":i)+o);return c.log=this.log,c}function s(o){t.save(o),t.namespaces=o,t.names=[],t.skips=[];let i=(typeof o==="string"?o:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let c of i)if(c[0]==="-")t.skips.push(c.slice(1));else t.names.push(c)}function u(o,i){let c=0,a=0,y=-1,f=0;while(c<o.length)if(a<i.length&&(i[a]===o[c]||i[a]==="*"))if(i[a]==="*")y=a,f=c,a++;else c++,a++;else if(y!==-1)a=y+1,f++,c=f;else return!1;while(a<i.length&&i[a]==="*")a++;return a===i.length}function l(){let o=[...t.names,...t.skips.map((i)=>"-"+i)].join(",");return t.enable(""),o}function v(o){for(let i of t.skips)if(u(o,i))return!1;for(let i of t.names)if(u(o,i))return!0;return!1}function _(o){if(o instanceof Error)return o.stack||o.message;return o}function N(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}Y.exports=Ee});var ee=Z(function(z,L){z.formatArgs=Me;z.save=Ne;z.load=qe;z.useColors=Ie;z.storage=Be();z.destroy=(()=>{let e=!1;return()=>{if(!e)e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}})();z.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Ie(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Me(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+L.exports.humanize(this.diff),!this.useColors)return;let r="color: "+this.color;e.splice(1,0,r,"color: inherit");let t=0,n=0;e[0].replace(/%[a-zA-Z%]/g,(s)=>{if(s==="%%")return;if(t++,s==="%c")n=t}),e.splice(n,0,r)}z.log=console.debug||console.log||(()=>{});function Ne(e){try{if(e)z.storage.setItem("debug",e);else z.storage.removeItem("debug")}catch(r){}}function qe(){let e;try{e=z.storage.getItem("debug")||z.storage.getItem("DEBUG")}catch(r){}if(!e&&typeof process<"u"&&"env"in process)e=process.env.DEBUG;return e}function Be(){try{return localStorage}catch(e){}}L.exports=U()(z);var{formatters:De}=L.exports;De.j=function(e){try{return JSON.stringify(e)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}});var se=Z(function(G,T){var te=ae("tty"),F=ae("util");G.init=Qe;G.log=We;G.formatArgs=Ge;G.save=Ze;G.load=Ke;G.useColors=ze;G.destroy=F.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");G.colors=[6,2,3,4,5,1];try{let e=(()=>{throw new Error("Cannot require module "+"supports-color");})();if(e&&(e.stderr||e).level>=2)G.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}catch(e){}G.inspectOpts=Object.keys(process.env).filter((e)=>/^debug_/i.test(e)).reduce((e,r)=>{let t=r.substring(6).toLowerCase().replace(/_([a-z])/g,(s,u)=>u.toUpperCase()),n=process.env[r];if(/^(yes|on|true|enabled)$/i.test(n))n=!0;else if(/^(no|off|false|disabled)$/i.test(n))n=!1;else if(n==="null")n=null;else n=Number(n);return e[t]=n,e},{});function ze(){return"colors"in G.inspectOpts?Boolean(G.inspectOpts.colors):te.isatty(process.stderr.fd)}function Ge(e){let{namespace:r,useColors:t}=this;if(t){let n=this.color,s="\x1B[3"+(n<8?n:"8;5;"+n),u=` ${s};1m${r} \x1B[0m`;e[0]=u+e[0].split(`
|
|
3
3
|
`).join(`
|
|
4
|
-
`+u),e.push(s+"m+"+
|
|
5
|
-
`)}function Ze(e){if(e)process.env.DEBUG=e;else delete process.env.DEBUG}function Ke(){return process.env.DEBUG}function Qe(e){e.inspectOpts={};let r=Object.keys(
|
|
6
|
-
`).map((r)=>r.trim()).join(" ")};re.O=function(e){return this.inspectOpts.colors=this.useColors,F.inspect(e,this.inspectOpts)}});var Z
|
|
7
|
-
`).some((t)=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}incrementSockets(e){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;if(!this.sockets[e])this.sockets[e]=[];let r=new dt.Socket({writable:!1});return this.sockets[e].push(r),this.totalSocketCount++,r}decrementSockets(e,r){if(!this.sockets[e]||r===null)return;let t=this.sockets[e],n=t.indexOf(r);if(n!==-1){if(t.splice(n,1),this.totalSocketCount--,t.length===0)delete this.sockets[e]}}getName(e){if(this.isSecureEndpoint(e))return de.Agent.prototype.getName.call(this,e);return super.getName(e)}createSocket(e,r,t){let n={...r,secureEndpoint:this.isSecureEndpoint(r)},s=this.getName(n),u=this.incrementSockets(s);Promise.resolve().then(()=>this.connect(e,n)).then((l)=>{if(this.decrementSockets(s,u),l instanceof ue.Agent)try{return l.addRequest(e,n)}catch(v){return t(v)}this[b].currentSocket=l,super.createSocket(e,r,t)},(l)=>{this.decrementSockets(s,u),t(l)})}createConnection(){let e=this[b].currentSocket;if(this[b].currentSocket=void 0,!e)throw Error("No socket was returned in the `connect()` function");return e}get defaultPort(){return this[b].defaultPort??(this.protocol==="https:"?443:80)}set defaultPort(e){if(this[b])this[b].defaultPort=e}get protocol(){return this[b].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(e){if(this[b])this[b].protocol=e}}h.Agent=pe});var Ce=
|
|
4
|
+
`+u),e.push(s+"m+"+T.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=Je()+r+" "+e[0]}function Je(){if(G.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function We(...e){return process.stderr.write(F.formatWithOptions(G.inspectOpts,...e)+`
|
|
5
|
+
`)}function Ze(e){if(e)process.env.DEBUG=e;else delete process.env.DEBUG}function Ke(){return process.env.DEBUG}function Qe(e){e.inspectOpts={};let r=Object.keys(G.inspectOpts);for(let t=0;t<r.length;t++)e.inspectOpts[r[t]]=G.inspectOpts[r[t]]}T.exports=U()(G);var{formatters:re}=T.exports;re.o=function(e){return this.inspectOpts.colors=this.useColors,F.inspect(e,this.inspectOpts).split(`
|
|
6
|
+
`).map((r)=>r.trim()).join(" ")};re.O=function(e){return this.inspectOpts.colors=this.useColors,F.inspect(e,this.inspectOpts)}});var W=Z(function(St,J){if(typeof process>"u"||process.type==="renderer"||!1||process.__nwjs)J.exports=ee();else J.exports=se()});var ce=Z(function(p){var st=p&&p.__createBinding||(Object.create?function(e,r,t,n){if(n===void 0)n=t;var s=Object.getOwnPropertyDescriptor(r,t);if(!s||("get"in s?!r.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return r[t]}};Object.defineProperty(e,n,s)}:function(e,r,t,n){if(n===void 0)n=t;e[n]=r[t]}),ot=p&&p.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),oe=p&&p.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null){for(var t in e)if(t!=="default"&&Object.prototype.hasOwnProperty.call(e,t))st(r,e,t)}return ot(r,e),r};Object.defineProperty(p,"__esModule",{value:!0});p.req=p.json=p.toBuffer=void 0;var it=oe(ae("http")),ct=oe(ae("https"));async function ie(e){let r=0,t=[];for await(let n of e)r+=n.length,t.push(n);return Buffer.concat(t,r)}p.toBuffer=ie;async function ut(e){let t=(await ie(e)).toString("utf8");try{return JSON.parse(t)}catch(n){let s=n;throw s.message+=` (input: ${t})`,s}}p.json=ut;function at(e,r={}){let n=((typeof e==="string"?e:e.href).startsWith("https:")?ct:it).request(e,r),s=new Promise((u,l)=>{n.once("response",u).once("error",l).end()});return n.then=s.then.bind(s),n}p.req=at});var he=Z(function(h){var fe=h&&h.__createBinding||(Object.create?function(e,r,t,n){if(n===void 0)n=t;var s=Object.getOwnPropertyDescriptor(r,t);if(!s||("get"in s?!r.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return r[t]}};Object.defineProperty(e,n,s)}:function(e,r,t,n){if(n===void 0)n=t;e[n]=r[t]}),ft=h&&h.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),le=h&&h.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null){for(var t in e)if(t!=="default"&&Object.prototype.hasOwnProperty.call(e,t))fe(r,e,t)}return ft(r,e),r},lt=h&&h.__exportStar||function(e,r){for(var t in e)if(t!=="default"&&!Object.prototype.hasOwnProperty.call(r,t))fe(r,e,t)};Object.defineProperty(h,"__esModule",{value:!0});h.Agent=void 0;var dt=le(ae("net")),ue=le(ae("http")),de=ae("https");lt(ce(),h);var b=Symbol("AgentBaseInternalState");class pe extends ue.Agent{constructor(e){super(e);this[b]={}}isSecureEndpoint(e){if(e){if(typeof e.secureEndpoint==="boolean")return e.secureEndpoint;if(typeof e.protocol==="string")return e.protocol==="https:"}let{stack:r}=Error();if(typeof r!=="string")return!1;return r.split(`
|
|
7
|
+
`).some((t)=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}incrementSockets(e){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;if(!this.sockets[e])this.sockets[e]=[];let r=new dt.Socket({writable:!1});return this.sockets[e].push(r),this.totalSocketCount++,r}decrementSockets(e,r){if(!this.sockets[e]||r===null)return;let t=this.sockets[e],n=t.indexOf(r);if(n!==-1){if(t.splice(n,1),this.totalSocketCount--,t.length===0)delete this.sockets[e]}}getName(e){if(this.isSecureEndpoint(e))return de.Agent.prototype.getName.call(this,e);return super.getName(e)}createSocket(e,r,t){let n={...r,secureEndpoint:this.isSecureEndpoint(r)},s=this.getName(n),u=this.incrementSockets(s);Promise.resolve().then(()=>this.connect(e,n)).then((l)=>{if(this.decrementSockets(s,u),l instanceof ue.Agent)try{return l.addRequest(e,n)}catch(v){return t(v)}this[b].currentSocket=l,super.createSocket(e,r,t)},(l)=>{this.decrementSockets(s,u),t(l)})}createConnection(){let e=this[b].currentSocket;if(this[b].currentSocket=void 0,!e)throw Error("No socket was returned in the `connect()` function");return e}get defaultPort(){return this[b].defaultPort??(this.protocol==="https:"?443:80)}set defaultPort(e){if(this[b])this[b].defaultPort=e}get protocol(){return this[b].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(e){if(this[b])this[b].protocol=e}}h.Agent=pe});var Ce=Z(function(M){var pt=M&&M.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(M,"__esModule",{value:!0});M.parseProxyResponse=void 0;var ht=pt(W()),H=(0,ht.default)("https-proxy-agent:parse-proxy-response");function Ct(e){return new Promise((r,t)=>{let n=0,s=[];function u(){let o=e.read();if(o)N(o);else e.once("readable",u)}function l(){e.removeListener("end",v),e.removeListener("error",_),e.removeListener("readable",u)}function v(){l(),H("onend"),t(Error("Proxy connection ended before receiving CONNECT response"))}function _(o){l(),H("onerror %o",o),t(o)}function N(o){s.push(o),n+=o.length;let i=Buffer.concat(s,n),c=i.indexOf(`\r
|
|
8
8
|
\r
|
|
9
|
-
`);if(c===-1){
|
|
10
|
-
`),y=a.shift();if(!y)return e.destroy(),t(Error("No header received from proxy CONNECT response"));let f=y.split(" "),d=+f[1],m=f.slice(2).join(" "),g={};for(let x of a){if(!x)continue;let w=x.indexOf(":");if(w===-1)return e.destroy(),t(Error(`Invalid header from proxy CONNECT response: "${x}"`));let D=x.slice(0,w).toLowerCase(),O=x.slice(w+1).trimStart(),j=g[D];if(typeof j==="string")g[D]=[j,O];else if(Array.isArray(j))j.push(O);else g[D]=O}
|
|
9
|
+
`);if(c===-1){H("have not received end of HTTP headers yet..."),u();return}let a=i.slice(0,c).toString("ascii").split(`\r
|
|
10
|
+
`),y=a.shift();if(!y)return e.destroy(),t(Error("No header received from proxy CONNECT response"));let f=y.split(" "),d=+f[1],m=f.slice(2).join(" "),g={};for(let x of a){if(!x)continue;let w=x.indexOf(":");if(w===-1)return e.destroy(),t(Error(`Invalid header from proxy CONNECT response: "${x}"`));let D=x.slice(0,w).toLowerCase(),O=x.slice(w+1).trimStart(),j=g[D];if(typeof j==="string")g[D]=[j,O];else if(Array.isArray(j))j.push(O);else g[D]=O}H("got proxy server response: %o %o",y,g),l(),r({connect:{statusCode:d,statusText:m,headers:g},buffered:i})}e.on("error",_),e.on("end",v),u()})}M.parseProxyResponse=Ct});var _t=Z(function(C){var yt=C&&C.__createBinding||(Object.create?function(e,r,t,n){if(n===void 0)n=t;var s=Object.getOwnPropertyDescriptor(r,t);if(!s||("get"in s?!r.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return r[t]}};Object.defineProperty(e,n,s)}:function(e,r,t,n){if(n===void 0)n=t;e[n]=r[t]}),gt=C&&C.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),me=C&&C.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null){for(var t in e)if(t!=="default"&&Object.prototype.hasOwnProperty.call(e,t))yt(r,e,t)}return gt(r,e),r},ve=C&&C.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(C,"__esModule",{value:!0});C.HttpsProxyAgent=void 0;var R=me(ae("net")),ye=me(ae("tls")),bt=ve(ae("assert")),mt=ve(W()),_e=he(),we=ae("url"),Fe=Ce(),B=(0,mt.default)("https-proxy-agent"),ge=(e)=>{if(e.servername===void 0&&e.host&&!R.isIP(e.host))return{...e,servername:e.host};return e};class K extends _e.Agent{constructor(e,r){super(r);this.options={path:void 0},this.proxy=typeof e==="string"?new we.URL(e):e,this.proxyHeaders=r?.headers??{},B("Creating new HttpsProxyAgent instance: %o",this.proxy.href);let t=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),n=this.proxy.port?parseInt(this.proxy.port,10):this.proxy.protocol==="https:"?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...r?be(r,"headers"):null,host:t,port:n}}async connect(e,r){let{proxy:t}=this;if(!r.host)throw TypeError('No "host" provided');let n;if(t.protocol==="https:")B("Creating `tls.Socket`: %o",this.connectOpts),n=ye.connect(ge(this.connectOpts));else B("Creating `net.Socket`: %o",this.connectOpts),n=R.connect(this.connectOpts);let s=typeof this.proxyHeaders==="function"?this.proxyHeaders():{...this.proxyHeaders},u=R.isIPv6(r.host)?`[${r.host}]`:r.host,l=`CONNECT ${u}:${r.port} HTTP/1.1\r
|
|
11
11
|
`;if(t.username||t.password){let i=`${decodeURIComponent(t.username)}:${decodeURIComponent(t.password)}`;s["Proxy-Authorization"]=`Basic ${Buffer.from(i).toString("base64")}`}if(s.Host=`${u}:${r.port}`,!s["Proxy-Connection"])s["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close";for(let i of Object.keys(s))l+=`${i}: ${s[i]}\r
|
|
12
12
|
`;let v=Fe.parseProxyResponse(n);n.write(`${l}\r
|
|
13
|
-
`);let{connect:_,buffered:N}=await v;if(e.emit("proxyConnect",_),this.emit("proxyConnect",_,e),_.statusCode===200){if(e.once("socket",vt),r.secureEndpoint)return B("Upgrading socket connection to TLS"),ye.connect({...be(ge(r),"host","path","port"),socket:n});return n}n.destroy();let o=new
|
|
13
|
+
`);let{connect:_,buffered:N}=await v;if(e.emit("proxyConnect",_),this.emit("proxyConnect",_,e),_.statusCode===200){if(e.once("socket",vt),r.secureEndpoint)return B("Upgrading socket connection to TLS"),ye.connect({...be(ge(r),"host","path","port"),socket:n});return n}n.destroy();let o=new R.Socket({writable:!1});return o.readable=!0,e.once("socket",(i)=>{B("Replaying proxy buffer for failed request"),(0,bt.default)(i.listenerCount("data")>0),i.push(N),i.push(null)}),o}}K.protocols=["http","https"];C.HttpsProxyAgent=K;function vt(e){e.resume()}function be(e,...r){let t={},n;for(n in e)if(!r.includes(n))t[n]=e[n];return t}});export default _t();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ct}from"./chunk-v0yevesp.js";import{kr}from"./chunk-k7vbk8v4.js";import"./chunk-z0de127n.js";import{Pa}from"./chunk-ddmf9gqv.js";import{Da,Na}from"./chunk-09mpcg9x.js";import{$i,Hi,Qi}from"./chunk-3hgrw1m0.js";import{Bs}from"./chunk-j2s311yc.js";import{no,oo}from"./chunk-eyjfhdp9.js";import{Us}from"./chunk-jt02kpfc.js";import{Qn}from"./chunk-hvyy8vct.js";import{Co,Xr}from"./chunk-erfkd3z9.js";import{bn}from"./chunk-h2bphev9.js";import{hr}from"./chunk-1e1q1hyg.js";var O=new Set(["openai","openai-codex","opencode"]),E=16;function h(e,o){if(!e)return!1;let r=o.toLowerCase();for(let[t,s]of Object.entries(e))if(t.toLowerCase()===r&&s!==null&&s.trim().length>0)return!0;return!1}function g(e,o,r){if(o)return o;if(h(r,"authorization")||h(r,"cf-aig-authorization"))return"unused";throw Error(`No API key for provider: ${e}`)}function I(e){return e.provider==="openrouter"||e.baseUrl.includes("openrouter.ai")?"openrouter":"openai"}function R(e,o){if(e)return e;if(kr("PI_CACHE_RETENTION",o)==="long")return"long";return"short"}function m(e){return{supportsDeveloperRole:e.compat?.supportsDeveloperRole??!0,sessionAffinityFormat:e.compat?.sessionAffinityFormat??I(e),supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??!0,supportsStrictMode:e.compat?.supportsStrictMode??!1,supportsOpenAIGrammarTools:e.compat?.supportsOpenAIGrammarTools??!1,supportsToolSearch:e.compat?.supportsToolSearch??!1,supportsExplicitPromptCacheMode:e.compat?.supportsExplicitPromptCacheMode??!1}}function P(e,o){return o==="long"&&e.supportsLongCacheRetention?"24h":void 0}function S(e){return oo(no(e),"OpenAI API error")}var C=(e,o,r)=>{let t=new hr;return(async()=>{let s={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let i=g(e.provider,r?.apiKey,r?.headers),c=R(r?.cacheRetention,r?.env)==="none"?void 0:r?.sessionId,p=m(e),a=Co(o.tools,p.supportsOpenAIGrammarTools),u=w(e,o,i,r?.headers,c),f=M(e,o,r,p,a),l=await r?.onPayload?.(f,e);if(l!==void 0)f=l;let v={...r?.signal?{signal:r.signal}:{},...r?.timeoutMs!==void 0?{timeout:r.timeoutMs}:{},maxRetries:0},{data:y,response:d}=await Us(()=>u.responses.create(f,v).withResponse(),{maxRetries:r?.maxRetries,maxRetryDelayMs:r?.maxRetryDelayMs,signal:r?.signal});if(await r?.onResponse?.({status:d.status,headers:Qn(d.headers)},e),t.push({type:"start",partial:s}),await Qi(y,s,t,e,{serviceTier:r?.serviceTier,grammarToolInputProperties:a,applyServiceTierPricing:(T,A)=>b(T,A,e)}),r?.signal?.aborted)throw Error("Request was aborted");if(s.stopReason==="aborted"||s.stopReason==="error")throw Error("An unknown error occurred");t.push({type:"done",reason:s.stopReason,message:s}),t.end()}catch(i){for(let n of s.content)delete n.index,delete n.partialJson,delete n.customInput;s.stopReason=r?.signal?.aborted?"aborted":"error",s.errorMessage=S(i),t.push({type:"error",reason:s.stopReason,error:s}),t.end()}})(),t},z=(e,o,r)=>{g(e.provider,r?.apiKey,r?.headers);let t=Xr(e,o,r,r?.apiKey),s=r?.reasoning?bn(e,r.reasoning):void 0;return C(e,o,{...t,reasoningEffort:s==="off"?void 0:s})};function w(e,o,r,t,s){let i=m(e),n={...e.headers};if(e.provider==="github-copilot"){let c=Da(o.messages),p=Na({messages:o.messages,hasImages:c});Object.assign(n,p)}if(s)if(i.sessionAffinityFormat==="openrouter")n["x-session-id"]=s;else{if(i.sessionAffinityFormat==="openai")n.session_id=s;n["x-client-request-id"]=s}if(t)Object.assign(n,t);return new Ct({apiKey:r,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:n})}function M(e,o,r,t=m(e),s=Co(o.tools,t.supportsOpenAIGrammarTools)){let i=Pa(o,t.supportsToolSearch),n=$i(e,o,O,{grammarToolInputProperties:s,deferredTools:i.deferred,toolOptions:{supportsStrictMode:t.supportsStrictMode,supportsOpenAIGrammarTools:t.supportsOpenAIGrammarTools}}),c=R(r?.cacheRetention,r?.env),p=c==="none"&&t.supportsExplicitPromptCacheMode,a={model:e.id,input:n,stream:!0,prompt_cache_key:c==="none"?void 0:Bs(r?.sessionId),prompt_cache_retention:P(t,c),prompt_cache_options:p?{mode:"explicit"}:void 0,store:!1};if(r?.maxTokens)a.max_output_tokens=Math.max(r.maxTokens,E);if(r?.temperature!==void 0)a.temperature=r?.temperature;if(r?.serviceTier!==void 0)a.service_tier=r.serviceTier;if(i.immediate.length>0)a.tools=Hi(i.immediate,{supportsStrictMode:t.supportsStrictMode,supportsOpenAIGrammarTools:t.supportsOpenAIGrammarTools});if(r?.toolChoice!==void 0)a.tool_choice=r.toolChoice;if(e.reasoning){if(r?.reasoningEffort||r?.reasoningSummary){let u=r?.reasoningEffort?e.thinkingLevelMap?.[r.reasoningEffort]??r.reasoningEffort:"medium";a.reasoning={effort:u,summary:r?.reasoningSummary||"auto"},a.include=["reasoning.encrypted_content"]}else if(e.provider!=="github-copilot"&&e.thinkingLevelMap?.off!==null)a.reasoning={effort:e.thinkingLevelMap?.off??"none"};if(e.provider==="xai")a.include=["reasoning.encrypted_content"]}return a}function _(e,o){switch(o){case"flex":return 0.5;case"priority":return e.id==="gpt-5.5"?2.5:2;default:return 1}}function b(e,o,r){let t=_(r,o);if(t===1)return;e.cost.input*=t,e.cost.output*=t,e.cost.cacheRead*=t,e.cost.cacheWrite*=t,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite}export{C as stream,z as streamSimple};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{S,Q,M,w,L,W,a,g,ie,ee,R,K,rn,Be,jt,Bt,Ti,Re,F,De,Ne,Fe,de,Ve,Xa,o_,Mt,bd,wd,A_,mx,hx,ma,F_,L_,Z_,Ih,Th,kh,Rh,Hc,p0,Ph,Dh,x0,C0,Kh,V0,hy,fg,pO,gg,Ag,dt,ft,pt,mt,ht,gt,At,_t,Se,xe,ke,ot,Ce,Ot,re,Xt,Vt,j,Fr,_n,Zd,Cg}from"./chunk-5ngftxjb.js";import{Ud,Yl,Xl,zd,jd}from"./chunk-1tar0x8s.js";import{As}from"./chunk-ajq9sxg0.js";import{zo}from"./chunk-femnbfkj.js";L();var Ie=[];function Au({teamId:r,projectId:D,assetId:l,folders:m,files:d,totalFolders:Ee,totalFiles:Me,totalFoldersSize:ze,totalFilesSize:Ue,selectedItem:V,selectedIds:v,onItemSelect:G,onItemDoubleClick:J,onSaveField:qe,onClearSelection:$e,fetchNextFoldersPage:X,hasNextFoldersPage:Y,isFetchingNextFoldersPage:y,fetchNextFilesPage:Z,hasNextFilesPage:te,isFetchingNextFilesPage:b,isRecentlyDeleted:x=!1,isRecents:k=!1,isLoading:oe=!1,isShareView:E=!1,isPublic:se=!1,shareId:Oe,allowDownload:ne=!0}){let i=ie();jd({teamId:r,items:d});let{canEdit:C,canAdmin:je}=Xt(D),ae=M(null),le=M(null),[z,We]=w(!0),[B,Qe]=w(!0),[He,N]=w(!1),[_,ce]=w(""),[Ke,U]=w(!1),me=Ee??m.length,ue=Me??d.length,pe=ze??(m.length>0?m.reduce((e,t)=>e+(t.sizeByte||0),0):-1),fe=Ue??(d.length>0?d.reduce((e,t)=>e+(t.sizeByte||0),0):-1),Le=pe>-1,Pe=fe>-1,ge=(e,t)=>{if(t)return e===1?Th({count:e}):Ih({count:e});else return e===1?Rh({count:e}):kh({count:e})},{editingItemId:he,setEditingItemId:ve,handleAction:we,onRenameSubmit:ye,isDeleteDialogOpen:Ge,setIsDeleteDialogOpen:Je,confirmDelete:Xe,isDownloadDialogOpen:Ye,setIsDownloadDialogOpen:q,isLoadingLinks:A,resolvedFiles:be,startDownload:Ze}=zd({teamId:r,projectId:D,assetId:l,folders:m,files:d,selectedIds:v,isPublic:se,shareId:Oe}),{ref:et,inView:_e}=Vt();S(()=>{if(_e){if(Y&&!y)X();else if(te&&!b)Z()}},[_e,Y,y,te,b,X,Z]);let tt=_n((e)=>e.startTask),O=Q(()=>{let e=null,t=0,s=2500,c=()=>{let p=Date.now();if(p-t>=s)t=p,i.invalidateQueries({queryKey:["search",r,l]});else if(!e)e=setTimeout(()=>{e=null,t=Date.now(),i.invalidateQueries({queryKey:["search",r,l]})},s-(p-t))},n=()=>{if(e)clearTimeout(e),e=null};return Object.assign(c,{cancel:n,reset:()=>{n(),t=Date.now()}})},[i,r,l]),rt=R.api.teams[":teamId"].upload.tasks.$post,{mutate:st}=ee({mutationFn:async(e)=>{let t=await rt(e);if(!t.ok)throw Error("Failed to create upload task");return await t.json()},onMutate:()=>({files:[...Ie]}),onError:()=>{j.error(ma())},onSuccess:async(e,t,s)=>{let c=s?.files||[],n=c.map((o)=>{let h=e.createdAssets?.find((f)=>f.tempId===o.id),T=e.presignedUrls?.find((f)=>f.id===o.id);return{fileId:h?.assetId||T?.fileId||o.id,name:o.file.name,size:o.file.size}}).filter((o)=>!!o.fileId),u=c.filter((o)=>!o.file.name.startsWith(".")),p=u.length===1?u[0].file.name:`${u.length} Items`;if(e.taskId)tt(e.taskId,p,n);i.invalidateQueries({queryKey:["search",r,l]}),i.invalidateQueries({queryKey:["teams",r,"upload","tasks"]}),O.reset();try{await Zd({files:c,taskId:e.taskId,teamId:r,storageBackend:e.storageBackend||"local",createdAssets:e.createdAssets,presignedUrls:e.presignedUrls,onFileFinished:()=>{O()}})}finally{O.cancel(),i.invalidateQueries({queryKey:["search",r,l]}),i.invalidateQueries({queryKey:["teams",r,"upload","tasks"]})}}}),Ae=(e)=>{if(!e||e.length===0)return;let t=[],s=[],c=new Map;for(let n of e){let u=(n.webkitRelativePath||n.name).split("/");if(u.some((I)=>I.startsWith(".")))continue;let p=u.pop(),o=s,h="";for(let I of u)if(h=`${h}/${I}`,!c.has(h)){let P=[],ut={name:I,type:"folder",id:As(),children:P,size:0};o.push(ut),c.set(h,P),o=P}else o=c.get(h);let T={file:n,id:As()};t.push(T);let f=n.type;if(p.toLowerCase().endsWith(".wma")&&f?.startsWith("video/"))f=f.replace(/^video\//,"audio/");o.push({name:p,size:n.size,type:"file",id:T.id,children:[],mediaType:f})}Ie=t,st({param:{teamId:r},json:{parentId:l,files:s}})},it=R.api.folders.$post,{mutate:nt,isPending:Te}=ee({mutationFn:async(e)=>{let t=await it({json:{name:e,parentId:l}});if(!t.ok)throw Error("Failed to create folder");return await t.json()},onSuccess:()=>{j.success(Hc()),N(!1),ce(""),i.invalidateQueries({queryKey:["search",r,l]}),i.invalidateQueries({queryKey:["folders"]})},onError:(e)=>{j.error(`Error: ${e.message}`)}}),{mutate:at,isPending:H}=ee({mutationFn:async()=>{let e=await R.api.projects[":projectId"]["empty-trash"].$post({param:{projectId:D}});if(!e.ok)throw Error("Failed to empty trash");return await e.json()},onSuccess:()=>{j.success(pO()),i.invalidateQueries({queryKey:["projects",D,"recently-deleted"]}),$e(),U(!1)},onError:(e)=>{j.error(`Error: ${e.message}`)}}),lt=(e)=>{if(e.preventDefault(),!_.trim())return;nt(_.trim())},ct=!oe&&m.length===0&&d.length===0&&!y&&!b;return g("div",{className:"flex-1 flex flex-col min-h-0 bg-background overflow-hidden relative",children:[C&&g(W,{children:[a("input",{type:"file",ref:ae,multiple:!0,className:"hidden",onChange:(e)=>{if(e.target.files)Ae(e.target.files)}}),a("input",{type:"file",ref:le,multiple:!0,webkitdirectory:"true",className:"hidden",onChange:(e)=>{if(e.target.files)Ae(e.target.files)}})]}),x&&g("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border text-sm shrink-0",children:[g("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a(rn,{className:"h-4 w-4 text-amber-500 shrink-0"}),a("span",{className:"text-xs",children:Kh()})]}),je&&a(F,{variant:"destructive",size:"sm",disabled:H||m.length===0&&d.length===0,onClick:()=>U(!0),className:"h-7 px-2.5 text-xs font-medium bg-destructive/10 text-destructive border border-destructive/20 hover:bg-destructive hover:text-destructive-foreground",children:"Delete"})]}),g("div",{className:"flex-1 overflow-y-auto min-h-0 p-3 pb-24",children:[oe&&m.length===0&&d.length===0?a(Cg,{}):g("div",{className:"max-w-lg mx-auto w-full",children:[me>0&&g("div",{className:"mb-4",children:[g("button",{onClick:()=>We(!z),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground mb-3 font-medium select-none cursor-pointer",children:[z?a(Be,{className:"h-4 w-4"}):a(jt,{className:"h-4 w-4"}),g("span",{children:[ge(me,!1),Le?` • ${Fr(pe)}`:""]})]}),z&&a("div",{className:"grid grid-cols-1 gap-4 w-full",children:m.map((e)=>a(Xl,{item:e,isSelected:V?.id===e.id,isChecked:v.has(e.id),isEditing:he===e.id,onSelect:G,onDoubleClick:J,onContextMenu:()=>{},onDragStart:()=>{},onDrop:()=>{},onRename:(t)=>ye(e,t),onFinishEditing:()=>ve(null),onAction:(t,s)=>we(t,s),isRecentlyDeleted:x,isRecents:k,selectedCount:v.size,canEdit:C,isShareView:E,allowDownload:ne},e.id))})]}),ue>0&&g("div",{className:"mb-4",children:[g("button",{onClick:()=>Qe(!B),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground mb-3 font-medium select-none cursor-pointer",children:[B?a(Be,{className:"h-4 w-4"}):a(jt,{className:"h-4 w-4"}),g("span",{children:[ge(ue,!0),Pe?` • ${Fr(fe)}`:""]})]}),B&&a("div",{className:"grid grid-cols-1 gap-4 w-full",children:d.map((e)=>a(Yl,{teamId:r,item:e,isSelected:V?.id===e.id,isChecked:v.has(e.id),isEditing:he===e.id,onSelect:G,onDoubleClick:J,onContextMenu:()=>{},onDragStart:()=>{},onDrop:()=>{},onRename:(t)=>ye(e,t),onFinishEditing:()=>ve(null),onSaveField:(t,s)=>qe?.(e.id,t,s),fields:[],onAction:(t,s)=>we(t,s),isRecentlyDeleted:x,isRecents:k,selectedCount:v.size,canEdit:C,isShareView:E,allowDownload:ne},e.id))})]})]}),ct&&a("div",{className:"flex flex-col items-center justify-center h-64 text-sm text-muted-foreground p-6 text-center",children:k?g("div",{className:"flex flex-col items-center gap-2",children:[a(Ti,{className:"h-10 w-10 text-muted-foreground/40 mb-1"}),a("p",{className:"font-medium text-foreground",children:Ph()}),a("p",{className:"text-xs text-muted-foreground",children:Dh()})]}):a("span",{children:fg()})}),a("div",{ref:et,className:"py-4 flex justify-center items-center min-h-6",children:(y||b)&&a(K,{className:"h-5 w-5 animate-spin text-muted-foreground"})})]}),C&&!x&&!k&&!E&&!se&&a("div",{className:"fixed bottom-6 right-6 z-30",children:g(De,{modal:!1,children:[a(Ne,{asChild:!0,children:a(F,{size:"icon",className:"h-14 w-14 rounded-full bg-primary text-primary-foreground shadow-lg shadow-primary/25 hover:bg-primary/90 flex items-center justify-center","aria-label":"Actions",children:a(Re,{className:"h-6 w-6"})})}),g(Fe,{align:"end",side:"top",className:"w-48 mb-2",children:[g(de,{onClick:()=>ae.current?.click(),className:"flex items-center gap-2.5 py-2 cursor-pointer",children:[a(zo,{className:"h-4 w-4"}),a("span",{children:gg()})]}),g(de,{onClick:()=>le.current?.click(),className:"flex items-center gap-2.5 py-2 cursor-pointer",children:[a(zo,{className:"h-4 w-4"}),a("span",{children:Ag()})]}),g(de,{onClick:()=>N(!0),className:"flex items-center gap-2.5 py-2 cursor-pointer",children:[a(Ud,{className:"h-4 w-4"}),a("span",{children:Hc()})]})]})]})}),a(Se,{open:He,onOpenChange:N,children:a(xe,{className:"sm:max-w-md",children:g("form",{onSubmit:lt,children:[g(ke,{children:[a(Ce,{children:Hc()}),a(Ot,{children:L_()})]}),a("div",{className:"py-4",children:a(re,{autoFocus:!0,placeholder:L_(),value:_,onChange:(e)=>ce(e.target.value)})}),g(ot,{children:[a(F,{type:"button",variant:"outline",onClick:()=>N(!1),children:Ve()}),g(F,{type:"submit",disabled:!_.trim()||Te,children:[Te?a(K,{className:"h-4 w-4 animate-spin mr-2"}):null,Xa()]})]})]})})}),a(dt,{open:Ge,onOpenChange:Je,children:g(ft,{children:[g(pt,{children:[a(ht,{children:wd()}),a(gt,{children:bd()})]}),g(mt,{children:[a(_t,{children:Ve()}),a(At,{onClick:()=>Xe(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Mt()})]})]})}),a(dt,{open:Ke,onOpenChange:U,children:g(ft,{children:[g(pt,{children:[a(ht,{children:hx()}),a(gt,{children:mx()})]}),g(mt,{children:[a(_t,{children:Ve()}),a(At,{onClick:(e)=>{e.preventDefault(),at()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:H,children:H?"Deleting...":Mt()})]})]})}),a(Se,{open:Ye,onOpenChange:q,children:g(xe,{className:"sm:max-w-md",children:[g(ke,{children:[a(Ce,{children:A?x0():o_()}),a(Ot,{children:A?V0():F_()})]}),A?g("div",{className:"space-y-4 py-6 flex flex-col items-center justify-center",children:[a(K,{className:"h-8 w-8 animate-spin text-primary"}),a("span",{className:"text-sm font-medium text-muted-foreground mt-2",children:C0()})]}):g("div",{className:"space-y-4 py-2",children:[a("div",{className:"text-sm text-muted-foreground",children:A_({count:be.length})}),g("div",{className:"flex items-start gap-3 p-3 text-sm rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 border border-amber-200 dark:border-amber-900/30",children:[a(rn,{className:"h-5 w-5 shrink-0 mt-0.5"}),g("div",{children:[a("p",{className:"font-semibold",children:p0()}),a("p",{className:"mt-0.5 text-xs text-amber-700/90 dark:text-amber-400/90",children:Z_()})]})]})]}),a(ot,{children:!A?g(W,{children:[a(F,{variant:"outline",onClick:()=>q(!1),children:Ve()}),g(F,{onClick:Ze,className:"gap-2",disabled:be.length===0,children:[a(Bt,{className:"h-4 w-4"}),hy()]})]}):a(F,{variant:"outline",onClick:()=>q(!1),children:Ve()})})]})})]})}
|
|
2
|
+
export{Au};
|