gemi 0.197.0 → 0.198.0
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/dist/ai/index.js +2 -2
- package/dist/ai/index.js.map +1 -1
- package/dist/app/index.js +1 -1
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-s57n552b.js → chunk-0kfrwbhg.js} +4 -4
- package/dist/{chunk-s57n552b.js.map → chunk-0kfrwbhg.js.map} +1 -1
- package/dist/{chunk-y9pzr1wc.js → chunk-1yq2b55s.js} +2 -2
- package/dist/{chunk-y9pzr1wc.js.map → chunk-1yq2b55s.js.map} +1 -1
- package/dist/{chunk-6nj9xjsm.js → chunk-206n0q1f.js} +2 -2
- package/dist/{chunk-6nj9xjsm.js.map → chunk-206n0q1f.js.map} +1 -1
- package/dist/{chunk-3bsw9sra.js → chunk-2cyd3h4h.js} +2 -2
- package/dist/{chunk-3bsw9sra.js.map → chunk-2cyd3h4h.js.map} +1 -1
- package/dist/{chunk-2g2cntdm.js → chunk-2kkv8515.js} +2 -2
- package/dist/{chunk-2g2cntdm.js.map → chunk-2kkv8515.js.map} +1 -1
- package/dist/{chunk-wprzrnqh.js → chunk-42b6zzg2.js} +2 -2
- package/dist/{chunk-wprzrnqh.js.map → chunk-42b6zzg2.js.map} +1 -1
- package/dist/{chunk-51n7yky9.js → chunk-4reyxar1.js} +1 -1
- package/dist/{chunk-a4kk68xy.js → chunk-503ce1t9.js} +2 -2
- package/dist/{chunk-a4kk68xy.js.map → chunk-503ce1t9.js.map} +1 -1
- package/dist/{chunk-zryrem89.js → chunk-50nex9wg.js} +3 -3
- package/dist/{chunk-zryrem89.js.map → chunk-50nex9wg.js.map} +1 -1
- package/dist/{chunk-4ftk3z34.js → chunk-5zjw41cv.js} +2 -2
- package/dist/{chunk-4ftk3z34.js.map → chunk-5zjw41cv.js.map} +1 -1
- package/dist/{chunk-spsheyx9.js → chunk-61mcmhjp.js} +1 -1
- package/dist/{chunk-5qaxde5h.js → chunk-64hxqsqx.js} +3 -3
- package/dist/{chunk-5qaxde5h.js.map → chunk-64hxqsqx.js.map} +1 -1
- package/dist/{chunk-zehvtpgm.js → chunk-6brwvyrz.js} +2 -2
- package/dist/{chunk-zehvtpgm.js.map → chunk-6brwvyrz.js.map} +1 -1
- package/dist/{chunk-qx1vc11v.js → chunk-6ftdsrkq.js} +2 -2
- package/dist/{chunk-qx1vc11v.js.map → chunk-6ftdsrkq.js.map} +1 -1
- package/dist/{chunk-bcydd231.js → chunk-6nr97atn.js} +2 -2
- package/dist/{chunk-bcydd231.js.map → chunk-6nr97atn.js.map} +1 -1
- package/dist/{chunk-arb0qkrm.js → chunk-6qhhgm73.js} +2 -2
- package/dist/{chunk-arb0qkrm.js.map → chunk-6qhhgm73.js.map} +1 -1
- package/dist/{chunk-tvdmx66x.js → chunk-6xa5yqrw.js} +2 -2
- package/dist/{chunk-tvdmx66x.js.map → chunk-6xa5yqrw.js.map} +1 -1
- package/dist/{chunk-zcmfkb9f.js → chunk-81m95se9.js} +2 -2
- package/dist/{chunk-zcmfkb9f.js.map → chunk-81m95se9.js.map} +1 -1
- package/dist/{chunk-rk34z2wa.js → chunk-8267ggmy.js} +2 -2
- package/dist/{chunk-rk34z2wa.js.map → chunk-8267ggmy.js.map} +1 -1
- package/dist/{chunk-j84r2j7a.js → chunk-84stff4t.js} +2 -2
- package/dist/{chunk-j84r2j7a.js.map → chunk-84stff4t.js.map} +1 -1
- package/dist/{chunk-kjygnj7y.js → chunk-8fzcs8dv.js} +2 -2
- package/dist/{chunk-kjygnj7y.js.map → chunk-8fzcs8dv.js.map} +1 -1
- package/dist/{chunk-tv33103m.js → chunk-93j09zw7.js} +1 -1
- package/dist/{chunk-2v83pskm.js → chunk-97g2qc7j.js} +1 -1
- package/dist/{chunk-rnjjn09d.js → chunk-agc5bqdt.js} +2 -2
- package/dist/{chunk-rnjjn09d.js.map → chunk-agc5bqdt.js.map} +1 -1
- package/dist/{chunk-nnn2f1ew.js → chunk-ahss6dcp.js} +2 -2
- package/dist/{chunk-nnn2f1ew.js.map → chunk-ahss6dcp.js.map} +1 -1
- package/dist/{chunk-zzmgz14a.js → chunk-b2n74m40.js} +2 -2
- package/dist/{chunk-zzmgz14a.js.map → chunk-b2n74m40.js.map} +1 -1
- package/dist/{chunk-ng5qfkgp.js → chunk-bcfcwbp4.js} +2 -2
- package/dist/{chunk-ng5qfkgp.js.map → chunk-bcfcwbp4.js.map} +1 -1
- package/dist/{chunk-mk4x0vtp.js → chunk-bdbg2dt6.js} +2 -2
- package/dist/{chunk-mk4x0vtp.js.map → chunk-bdbg2dt6.js.map} +1 -1
- package/dist/{chunk-7sadg8d7.js → chunk-bxxd1awv.js} +3 -3
- package/dist/{chunk-7sadg8d7.js.map → chunk-bxxd1awv.js.map} +1 -1
- package/dist/{chunk-qw6aa9fy.js → chunk-by0afyps.js} +2 -2
- package/dist/{chunk-qw6aa9fy.js.map → chunk-by0afyps.js.map} +1 -1
- package/dist/chunk-ccpp45dm.js +5 -0
- package/dist/{chunk-tgbky7fc.js.map → chunk-ccpp45dm.js.map} +1 -1
- package/dist/{chunk-zv55h4x9.js → chunk-ct1vh28z.js} +2 -2
- package/dist/{chunk-zv55h4x9.js.map → chunk-ct1vh28z.js.map} +1 -1
- package/dist/chunk-dqgn4wgf.js +15 -0
- package/dist/{chunk-es05kqtp.js.map → chunk-dqgn4wgf.js.map} +5 -4
- package/dist/{chunk-fyk66c5e.js → chunk-drb6gpgv.js} +2 -2
- package/dist/{chunk-fyk66c5e.js.map → chunk-drb6gpgv.js.map} +1 -1
- package/dist/{chunk-c601phyd.js → chunk-drqv10sv.js} +2 -2
- package/dist/{chunk-c601phyd.js.map → chunk-drqv10sv.js.map} +1 -1
- package/dist/{chunk-evdca0b9.js → chunk-e603nm1c.js} +2 -2
- package/dist/{chunk-evdca0b9.js.map → chunk-e603nm1c.js.map} +1 -1
- package/dist/{chunk-02jze3te.js → chunk-e7bb26fb.js} +2 -2
- package/dist/{chunk-02jze3te.js.map → chunk-e7bb26fb.js.map} +1 -1
- package/dist/{chunk-4f2xy9ws.js → chunk-ewknbs3b.js} +3 -3
- package/dist/{chunk-4f2xy9ws.js.map → chunk-ewknbs3b.js.map} +1 -1
- package/dist/chunk-ff22412e.js +117 -0
- package/dist/{chunk-7xy7ebkx.js.map → chunk-ff22412e.js.map} +9 -8
- package/dist/{chunk-cpgc5q74.js → chunk-grwze86x.js} +2 -2
- package/dist/{chunk-cpgc5q74.js.map → chunk-grwze86x.js.map} +1 -1
- package/dist/{chunk-n01mhwkj.js → chunk-gx2fhmnx.js} +3 -3
- package/dist/{chunk-n01mhwkj.js.map → chunk-gx2fhmnx.js.map} +1 -1
- package/dist/{chunk-a77w04sw.js → chunk-ha4er085.js} +2 -2
- package/dist/{chunk-a77w04sw.js.map → chunk-ha4er085.js.map} +1 -1
- package/dist/{chunk-9ky5d5js.js → chunk-jkf5kjaz.js} +3 -3
- package/dist/{chunk-9ky5d5js.js.map → chunk-jkf5kjaz.js.map} +1 -1
- package/dist/{chunk-ecyq52t3.js → chunk-kz15j07h.js} +3 -3
- package/dist/{chunk-ecyq52t3.js.map → chunk-kz15j07h.js.map} +1 -1
- package/dist/{chunk-mnmz8n5k.js → chunk-mddazdpt.js} +2 -2
- package/dist/{chunk-mnmz8n5k.js.map → chunk-mddazdpt.js.map} +1 -1
- package/dist/{chunk-2z160r1b.js → chunk-mzqhn72h.js} +2 -2
- package/dist/{chunk-2z160r1b.js.map → chunk-mzqhn72h.js.map} +1 -1
- package/dist/{chunk-8mmskn4g.js → chunk-n3p16jpb.js} +3 -3
- package/dist/{chunk-8mmskn4g.js.map → chunk-n3p16jpb.js.map} +1 -1
- package/dist/{chunk-x05mj7ye.js → chunk-n9k29mrs.js} +2 -2
- package/dist/{chunk-x05mj7ye.js.map → chunk-n9k29mrs.js.map} +1 -1
- package/dist/{chunk-v4ka65g8.js → chunk-nnaz5djg.js} +2 -2
- package/dist/{chunk-v4ka65g8.js.map → chunk-nnaz5djg.js.map} +1 -1
- package/dist/{chunk-sxww1ka5.js → chunk-pab6ye4d.js} +2 -2
- package/dist/{chunk-sxww1ka5.js.map → chunk-pab6ye4d.js.map} +1 -1
- package/dist/{chunk-ff16m7gm.js → chunk-q1zj3a0e.js} +2 -2
- package/dist/{chunk-ff16m7gm.js.map → chunk-q1zj3a0e.js.map} +1 -1
- package/dist/{chunk-7q42fej6.js → chunk-rcnpjwp4.js} +2 -2
- package/dist/{chunk-7q42fej6.js.map → chunk-rcnpjwp4.js.map} +1 -1
- package/dist/{chunk-y50h3cd6.js → chunk-rh84xq17.js} +2 -2
- package/dist/{chunk-y50h3cd6.js.map → chunk-rh84xq17.js.map} +1 -1
- package/dist/{chunk-e0d6az7p.js → chunk-s9z0xxth.js} +2 -2
- package/dist/{chunk-e0d6az7p.js.map → chunk-s9z0xxth.js.map} +1 -1
- package/dist/{chunk-kjgy7sk0.js → chunk-sg78cmd1.js} +2 -2
- package/dist/{chunk-kjgy7sk0.js.map → chunk-sg78cmd1.js.map} +1 -1
- package/dist/{chunk-htnbmbx1.js → chunk-t0qs2q9j.js} +2 -2
- package/dist/{chunk-htnbmbx1.js.map → chunk-t0qs2q9j.js.map} +1 -1
- package/dist/{chunk-yzazktke.js → chunk-t4z6rkvw.js} +2 -2
- package/dist/{chunk-yzazktke.js.map → chunk-t4z6rkvw.js.map} +1 -1
- package/dist/{chunk-3am1e8ya.js → chunk-tjsv6e3a.js} +2 -2
- package/dist/{chunk-3am1e8ya.js.map → chunk-tjsv6e3a.js.map} +1 -1
- package/dist/{chunk-8xckmvea.js → chunk-txbram9h.js} +2 -2
- package/dist/{chunk-8xckmvea.js.map → chunk-txbram9h.js.map} +1 -1
- package/dist/{chunk-gk0d26zw.js → chunk-tyvc46ns.js} +2 -2
- package/dist/{chunk-gk0d26zw.js.map → chunk-tyvc46ns.js.map} +1 -1
- package/dist/{chunk-9dnbf9q8.js → chunk-v2pt8h42.js} +2 -2
- package/dist/{chunk-9dnbf9q8.js.map → chunk-v2pt8h42.js.map} +1 -1
- package/dist/{chunk-nbry43s8.js → chunk-vn84xe2p.js} +2 -2
- package/dist/{chunk-nbry43s8.js.map → chunk-vn84xe2p.js.map} +1 -1
- package/dist/{chunk-2qbfvb6m.js → chunk-vpqzzrkn.js} +2 -2
- package/dist/{chunk-2qbfvb6m.js.map → chunk-vpqzzrkn.js.map} +1 -1
- package/dist/{chunk-zrykhpn9.js → chunk-w09wtxr6.js} +3 -3
- package/dist/{chunk-zrykhpn9.js.map → chunk-w09wtxr6.js.map} +1 -1
- package/dist/{chunk-degz94dk.js → chunk-w84ke0bp.js} +2 -2
- package/dist/{chunk-degz94dk.js.map → chunk-w84ke0bp.js.map} +1 -1
- package/dist/{chunk-20y02g4n.js → chunk-wxb2pqqz.js} +2 -2
- package/dist/{chunk-20y02g4n.js.map → chunk-wxb2pqqz.js.map} +1 -1
- package/dist/{chunk-rqs2s5nh.js → chunk-xb0k1br9.js} +2 -2
- package/dist/{chunk-fzy1z97a.js.map → chunk-xb0k1br9.js.map} +1 -1
- package/dist/{chunk-kzy4pyqb.js → chunk-xhc16pv1.js} +3 -3
- package/dist/{chunk-kzy4pyqb.js.map → chunk-xhc16pv1.js.map} +1 -1
- package/dist/{chunk-pvx66dq2.js → chunk-xwcv0b4b.js} +3 -3
- package/dist/{chunk-pvx66dq2.js.map → chunk-xwcv0b4b.js.map} +1 -1
- package/dist/{chunk-gk12v51y.js → chunk-xxep62yg.js} +1 -1
- package/dist/{chunk-4k62r4hv.js → chunk-xzt117g6.js} +1 -1
- package/dist/{chunk-xb9zjaes.js → chunk-y167pt0p.js} +2 -2
- package/dist/{chunk-xb9zjaes.js.map → chunk-y167pt0p.js.map} +1 -1
- package/dist/{chunk-g1th116z.js → chunk-yxge0cem.js} +2 -2
- package/dist/{chunk-g1th116z.js.map → chunk-yxge0cem.js.map} +1 -1
- package/dist/{chunk-fzy1z97a.js → chunk-zpqcawmq.js} +2 -2
- package/dist/{chunk-rqs2s5nh.js.map → chunk-zpqcawmq.js.map} +1 -1
- package/dist/{chunk-dbe8zgyb.js → chunk-zwbpcch0.js} +2 -2
- package/dist/{chunk-dbe8zgyb.js.map → chunk-zwbpcch0.js.map} +1 -1
- package/dist/chunks/{RealtimeClient-BVQeh_yg.js → RealtimeClient-B7zh4okq.js} +2 -2
- package/dist/chunks/{RealtimeClient-BVQeh_yg.js.map → RealtimeClient-B7zh4okq.js.map} +1 -1
- package/dist/chunks/{ThemeProvider-G2g5Z1ZS.js → ThemeProvider-D33bPpf8.js} +51 -4
- package/dist/chunks/ThemeProvider-D33bPpf8.js.map +1 -0
- package/dist/chunks/{fetchFileRequest-Bzva9J59.js → fetchFileRequest-Cp0QjioM.js} +2 -2
- package/dist/chunks/{fetchFileRequest-Bzva9J59.js.map → fetchFileRequest-Cp0QjioM.js.map} +1 -1
- package/dist/chunks/{live-C2Sck5PO.js → live-D08wnrrZ.js} +3 -3
- package/dist/chunks/{live-C2Sck5PO.js.map → live-D08wnrrZ.js.map} +1 -1
- package/dist/chunks/{mutationExtras-HC7AC6zn.js → mutationExtras-BbDboF8F.js} +2 -2
- package/dist/chunks/{mutationExtras-HC7AC6zn.js.map → mutationExtras-BbDboF8F.js.map} +1 -1
- package/dist/chunks/{subscriptionStream-CaTWWJwt.js → subscriptionStream-CRj9aV4K.js} +2 -2
- package/dist/chunks/{subscriptionStream-CaTWWJwt.js.map → subscriptionStream-CRj9aV4K.js.map} +1 -1
- package/dist/client/ClientRouterContext.d.ts.map +1 -1
- package/dist/client/Head.d.ts.map +1 -1
- package/dist/client/createRoot.d.ts.map +1 -1
- package/dist/client/cspNonce.d.ts +33 -0
- package/dist/client/cspNonce.d.ts.map +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +17 -10
- package/dist/client/index.js.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +1 -1
- package/dist/container/index.js +2 -2
- package/dist/container/index.js.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/foundation/index.js +2 -2
- package/dist/foundation/index.js.map +1 -1
- package/dist/http/HttpRequest.d.ts +7 -0
- package/dist/http/HttpRequest.d.ts.map +1 -1
- package/dist/http/cspNonce.d.ts +37 -0
- package/dist/http/cspNonce.d.ts.map +1 -0
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/i18n/dictionaryRuntime.js +2 -2
- package/dist/i18n/dictionaryRuntime.js.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +1 -1
- package/dist/orm/index.js +2 -2
- package/dist/orm/index.js.map +1 -1
- package/dist/probe/index.js +2 -2
- package/dist/probe/index.js.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +3 -3
- package/dist/services/index.js.map +2 -2
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/services/router/ViewRouteDispatcher.d.ts +2 -0
- package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
- package/dist/services/router/config.d.ts +17 -1
- package/dist/services/router/config.d.ts.map +1 -1
- package/dist/services/router/contentSecurityPolicy.d.ts +32 -0
- package/dist/services/router/contentSecurityPolicy.d.ts.map +1 -0
- package/dist/services/router/staticCache.d.ts +1 -0
- package/dist/services/router/staticCache.d.ts.map +1 -1
- package/dist/services/router/staticDocument.d.ts +5 -1
- package/dist/services/router/staticDocument.d.ts.map +1 -1
- package/dist/services/router/streamQueryInjection.d.ts +5 -3
- package/dist/services/router/streamQueryInjection.d.ts.map +1 -1
- package/dist/stats/route-table.js +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/dist/testing/index.js +2 -2
- package/dist/vitest/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-7xy7ebkx.js +0 -117
- package/dist/chunk-es05kqtp.js +0 -15
- package/dist/chunk-tgbky7fc.js +0 -5
- package/dist/chunks/ThemeProvider-G2g5Z1ZS.js.map +0 -1
- /package/dist/{chunk-51n7yky9.js.map → chunk-4reyxar1.js.map} +0 -0
- /package/dist/{chunk-spsheyx9.js.map → chunk-61mcmhjp.js.map} +0 -0
- /package/dist/{chunk-tv33103m.js.map → chunk-93j09zw7.js.map} +0 -0
- /package/dist/{chunk-2v83pskm.js.map → chunk-97g2qc7j.js.map} +0 -0
- /package/dist/{chunk-gk12v51y.js.map → chunk-xxep62yg.js.map} +0 -0
- /package/dist/{chunk-4k62r4hv.js.map → chunk-xzt117g6.js.map} +0 -0
package/dist/chunk-es05kqtp.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{ij as F,jj as I1,kj as A1}from"./chunk-2qbfvb6m.js";import{pj as m1,sj as b}from"./chunk-zzmgz14a.js";import{tl as T0}from"./chunk-yzazktke.js";import{xl as L1}from"./chunk-9ky5d5js.js";import{Ql as W1}from"./chunk-nnn2f1ew.js";import{Yl as VZ}from"./chunk-fzy1z97a.js";class $0{static kind="controller";constructor(){}}class r0 extends $0{}function E1(Q){let Z=new Map;if(!Q)return Z;for(let $ of Q.split(";")){let X=$.indexOf("=");if(X===-1)continue;let G=$.slice(0,X).trim();if(!G)continue;Z.set(G,$.slice(X+1).trim())}return Z}function qZ(Q){return E1(Q.headers.get("cookie"))}function u(Q){if(!/^\d+$/.test(Q))return null;let Z=Number(Q);return Number.isSafeInteger(Z)?Z:null}function X0(Q){if(!Q)return null;let Z=Q.trim();if(!/^bytes=/i.test(Z))return null;let X=Z.slice(6).split(",").map((z)=>z.trim()).filter((z)=>z!=="");if(X.length!==1)return null;let G=X[0],Y=G.indexOf("-");if(Y===-1)return null;let K=G.slice(0,Y),J=G.slice(Y+1);if(K===""){let z=u(J);if(z===null)return null;return{kind:"suffix",suffixLength:z}}let H=u(K);if(H===null)return null;if(J==="")return{kind:"offset",start:H,end:null};let W=u(J);if(W===null||W<H)return null;return{kind:"offset",start:H,end:W}}function G0(Q,Z){if(!Number.isFinite(Z)||Z<=0)return null;let $,X;if(Q.kind==="suffix"){if(Q.suffixLength<=0)return null;$=Math.max(0,Z-Q.suffixLength),X=Z-1}else{if(Q.start>=Z)return null;if($=Q.start,X=Q.end===null?Z-1:Math.min(Q.end,Z-1),X<$)return null}return{start:$,end:X,length:X-$+1}}function EZ(Q){if(Q.kind==="suffix")return`bytes=-${Q.suffixLength}`;return Q.end===null?`bytes=${Q.start}-`:`bytes=${Q.start}-${Q.end}`}function xZ(Q){if(!Q)return null;let Z=/^bytes\s+(\d+)-(\d+)\/(\d+)$/i.exec(Q.trim());if(!Z)return null;let $=u(Z[1]),X=u(Z[2]),G=u(Z[3]);if($===null||X===null||G===null||X<$)return null;return{start:$,end:X,total:G}}function kZ(Q,Z,$){return`bytes ${Q}-${Z}/${$}`}function Y0(Q){return`bytes */${Q}`}class e extends F{errors={};constructor(Q){super("Validation error");this.name="ValidationError",this.errors=Q,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:Q,status:400}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}function H0(Q){let[Z,$]=Q.match(/\d+|\D+/g)??[];if(!Z||!$)return 0;let X=Number.parseInt(Z);switch($){case"B":return X;case"KB":return X*1024;case"MB":return X*1024*1024;case"GB":return X*1024*1024*1024;case"TB":return X*1024*1024*1024*1024;default:return 0}}function e0(Q){switch(Q){case"image":return"image";case"png":return"image/png";case"jpg":return"image/jpeg";case"jpeg":return"image/jpeg";case"ttf":return"font/ttf";case"excel":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"csv":return"text/csv";case"word":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"pdf":return"application/pdf";case"json":return"application/json";default:return Q}}function K0(Q){if(typeof Q==="string"||Array.isArray(Q))return Q.length;return}function x1(Q){return typeof Q==="number"&&!Number.isNaN(Q)}var QQ=["required","string","boolean","number","email","password","min","max","gte","lte","file","fileType","fileSize","array","object","in"];class k extends Error{name="InvalidValidationRuleError"}function B1(Q,Z){let $=Z===void 0||Z.trim()===""?Number.NaN:Number(Z);if(Number.isNaN($))throw new k(`Validation rule "${Q}:${Z??""}" needs a number, e.g. "${Q}:3"`);return $}function J0(Q){let Z=!1,$=0;for(let X of Object.values(Q)){if(!X||typeof X!=="object")continue;for(let G of Object.keys(X)){let Y=G.indexOf(":"),K=Y===-1?G:G.slice(0,Y);if(K!=="file"&&K!=="fileType"&&K!=="fileSize")continue;if(Z=!0,K==="fileSize")$+=H0(G.slice(Y+1))}}return Z?$:null}function W0(Q){let Z=Q.indexOf(":"),$=Z===-1?Q:Q.slice(0,Z),X=Z===-1?void 0:Q.slice(Z+1);switch($){case"required":return(G)=>{if(G instanceof Blob)return G.size>0;if(G===null||G===void 0)return!1;if(typeof G==="string"||Array.isArray(G))return G.length>0;return!0};case"string":return(G)=>typeof G==="string";case"boolean":return(G)=>typeof G==="boolean";case"number":return(G)=>x1(G);case"password":return(G)=>{return typeof G==="string"&&/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(G)};case"min":{let G=B1($,X);return(Y)=>{let K=K0(Y);return K!==void 0&&K>=G}}case"max":{let G=B1($,X);return(Y)=>{let K=K0(Y);return K!==void 0&&K<=G}}case"gte":{let G=B1($,X);return(Y)=>x1(Y)&&Y>=G}case"lte":{let G=B1($,X);return(Y)=>x1(Y)&&Y<=G}case"email":return(G)=>{return typeof G==="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(G)};case"file":return(G)=>{return G instanceof Blob};case"fileType":{if(!X)throw new k('Validation rule "fileType" needs a type, e.g. "fileType:png" or "fileType:image"');let G=e0(X);return(Y)=>Y instanceof Blob&&Y.type.startsWith(G)}case"fileSize":{let G=H0(X??"");if(G===0&&!/^0+(B|KB|MB|GB|TB)$/.test(X??""))throw new k(`Validation rule "fileSize:${X??""}" needs a whole size in B, KB, MB, GB or TB, e.g. "fileSize:5MB"`);return(Y)=>Y instanceof Blob&&Y.size<=G}case"array":return(G)=>Array.isArray(G);case"object":return(G)=>typeof G==="object"&&G!==null&&!Array.isArray(G)&&!(G instanceof Blob);case"in":{let G=(X??"").split(",").filter((Y)=>Y!=="");if(G.length===0)throw new k('Validation rule "in" needs a comma-separated list, e.g. "in:draft,published"');return(Y)=>typeof Y==="string"&&G.includes(Y)}default:throw new k(`Unknown validation rule "${Q}". Known rules: ${QQ.join(", ")}`)}}class g1 extends F{limit;constructor(Q){super("The request body is too large.",{status:413});this.limit=Q}}var V0={b:1,k:1024,kb:1024,m:1048576,mb:1048576,g:1073741824,gb:1073741824};function hZ(Q){if(typeof Q==="number"){if(Number.isFinite(Q)&&Q>=0)return Math.floor(Q);if(Q===1/0)return 1/0}else{let Z=Q.trim().toLowerCase();if(Z==="none"||Z==="off")return 1/0;let $=/^(\d+(?:\.\d+)?)\s*([a-z]*)$/.exec(Z);if($&&($[2]===""||($[2]in V0)))return Math.floor(Number($[1])*(V0[$[2]]??1))}throw Error(`Invalid body limit ${JSON.stringify(Q)}. Use a byte count or a size such as "64kb", "1mb" or "none".`)}var n=new WeakMap;function mZ(Q){return n.has(Q)}function pZ(Q){return n.get(Q)?.limit??null}function cZ(Q){let Z=n.get(Q);return Z?Z.read>Z.limit:!1}function ZQ(Q){let Z=Q.headers.get("Content-Length");if(Z===null||!/^\s*\d+\s*$/.test(Z))return null;return Number(Z)}function y1(Q,Z){let $=ZQ(Q);if($!==null&&$>Z)throw new g1(Z)}function uZ(Q,Z,$={}){let X=$.uploadLimit??null,G=n.get(Q);if(G)G.limit=Z,G.uploadLimit=X;else{let Y={limit:Z,uploadLimit:X,read:0,stream:void 0,used:!1};n.set(Q,Y),XQ(Q,Y)}if($.checkDeclared!==!1)y1(Q,Z)}function P0(Q,Z){let $=n.get(Q);if(!$||$.uploadLimit===null||$.used||$.read>0)return;$.limit=Math.max($.limit,$.uploadLimit,Z+$.limit),$.uploadLimit=null}function $Q(Q){return Reflect.get(Object.getPrototypeOf(Q),"body",Q)??null}function k1(Q,Z){if(Z.stream!==void 0)return Z.stream;let $=$Q(Q);if(!$)return Z.stream=null;let X;return Z.stream=new ReadableStream({async pull(G){X??=$.getReader();let{done:Y,value:K}=await X.read();if(Y){G.close();return}if(Z.read+=K.byteLength,Z.read>Z.limit){let J=new g1(Z.limit);G.error(J),X.cancel(J).catch(()=>{});return}G.enqueue(K)},cancel(G){return X?X.cancel(G):$.cancel(G)}},{highWaterMark:0}),Z.stream}async function d(Q,Z){if(y1(Q,Z.limit),Z.used||Z.stream?.locked)throw TypeError("Body already used");Z.used=!0;let $=k1(Q,Z);if(!$)return new Uint8Array(0);let X=$.getReader(),G=[],Y=0;for(;;){let{done:H,value:W}=await X.read();if(H)break;G.push(W),Y+=W.byteLength}let K=new Uint8Array(Y),J=0;for(let H of G)K.set(H,J),J+=H.byteLength;return K}function z0(Q){return Q.headers.get("Content-Type")??""}function XQ(Q,Z){let $=(X,G)=>Object.defineProperty(Q,X,{configurable:!0,...G});$("body",{get:()=>k1(Q,Z)}),$("bodyUsed",{get:()=>Z.used||Boolean(Z.stream?.locked)||Reflect.get(Object.getPrototypeOf(Q),"bodyUsed",Q)}),$("bytes",{value:()=>d(Q,Z)}),$("arrayBuffer",{value:async()=>{let X=await d(Q,Z);return X.buffer.slice(X.byteOffset,X.byteOffset+X.byteLength)}}),$("text",{value:async()=>new TextDecoder().decode(await d(Q,Z))}),$("json",{value:async()=>JSON.parse(new TextDecoder().decode(await d(Q,Z)))}),$("blob",{value:async()=>new Blob([await d(Q,Z)],{type:z0(Q)})}),$("formData",{value:async()=>new Response(await d(Q,Z),{headers:{"Content-Type":z0(Q)}}).formData()}),$("clone",{value:()=>{y1(Q,Z.limit);let X=k1(Q,Z),G=null;if(X){let[Y,K]=X.tee();Z.stream=Y,G=K}return new Request(Q.url,{method:Q.method,headers:Q.headers,body:G,signal:Q.signal,duplex:"half"})}})}function l(Q){if(!Q.definition)throw Error(`gemi/ai: the recursive schema "${Q.name}" was used before its definition returned; \`self\` can be nested into the schema, but not parsed or emitted inside the callback`);return Q.definition}var O1=new WeakMap;function v1(Q){return typeof Q==="object"&&Q!==null&&O1.has(Q)}function R1(Q){let Z=O1.get(Q);if(!Z)throw Error("gemi/ai: expected a schema built with `s`, got a foreign object");return Z}function GQ(Q){let Z={defs:{},cells:new Map},$=Q;if(Q.node.kind==="ref"){let G=l(Q.node.cell);$={...G,...Q.description?{description:Q.description}:{},optional:Q.optional,nullable:Q.nullable||G.nullable}}let X=Z1($,Z);return Object.keys(Z.defs).length>0?{...X,$defs:Z.defs}:X}function Z1(Q,Z){let $=(Q.optional||Q.nullable)&&Q.node.kind!=="json",X=HQ(KQ(Q.node,Z),$),G=[Q.description,YQ(Q.node)].filter(Boolean).join(" ");if(G&&X.$ref!==void 0)X={anyOf:[X]};return G?{description:G,...X}:X}function YQ(Q){let Z=[];if(Q.kind==="string"||Q.kind==="enum"){let $=Q.checks;if($?.format)Z.push(`Format: ${$.format.name}.`);if($?.minLength!==void 0)Z.push(`At least ${$.minLength} characters.`);if($?.maxLength!==void 0)Z.push(`At most ${$.maxLength} characters.`)}else if(Q.kind==="number"){let $=Q.checks;if($?.minimum!==void 0)Z.push(`Minimum ${$.minimum}.`);if($?.exclusiveMinimum!==void 0)Z.push(`Greater than ${$.exclusiveMinimum}.`);if($?.maximum!==void 0)Z.push(`Maximum ${$.maximum}.`);if($?.exclusiveMaximum!==void 0)Z.push(`Less than ${$.exclusiveMaximum}.`)}else if(Q.kind==="array"){let $=Q.checks;if($?.minItems!==void 0)Z.push(`At least ${$.minItems} items.`);if($?.maxItems!==void 0)Z.push(`At most ${$.maxItems} items.`)}return Z.join(" ")}function KQ(Q,Z){switch(Q.kind){case"string":return{type:"string"};case"number":return{type:Q.checks?.integer?"integer":"number"};case"boolean":return{type:"boolean"};case"literal":return{type:typeof Q.value,const:Q.value};case"enum":return{type:"string",enum:Q.values};case"array":return{type:"array",items:Z1(Q.item,Z)};case"object":return{type:"object",properties:Object.fromEntries(Object.entries(Q.shape).map(([$,X])=>[$,Z1(X,Z)])),required:Object.keys(Q.shape),additionalProperties:!1};case"union":return{anyOf:Q.members.map(($)=>Z1($,Z))};case"json":return{};case"ref":{let{cell:$}=Q,X=Z.cells.get($.name);if(X&&X!==$)throw Error(`gemi/ai: two different recursive schemas are named "${$.name}" in one schema; give each s.recursive(...) its own name`);if(!X)Z.cells.set($.name,$),Z.defs[$.name]={},Z.defs[$.name]=Z1(l($),Z);return{$ref:`#/$defs/${$.name}`}}}}function HQ(Q,Z){if(!Z)return Q;if(Q.anyOf)return{...Q,anyOf:[...Q.anyOf,{type:"null"}]};if(Q.enum||Q.const!==void 0)return{anyOf:[Q,{type:"null"}]};if(typeof Q.type==="string")return{...Q,type:[Q.type,"null"]};return{anyOf:[Q,{type:"null"}]}}function JQ(Q){if(Q===null)return"null";if(Array.isArray(Q))return"array";return typeof Q}function WQ(Q,Z){if(typeof Z==="number"&&!Number.isFinite(Z))return String(Z);if(Q.kind==="literal"||Q.kind==="enum"){if(typeof Z==="string"||typeof Z==="number"||typeof Z==="boolean")return JSON.stringify(Z)}return JQ(Z)}function B0(Q){let Z=Q.node,$=(()=>{switch(Z.kind){case"number":return Z.checks?.integer?"integer":"number";case"string":case"boolean":return Z.kind;case"literal":return JSON.stringify(Z.value);case"enum":return`one of ${Z.values.map((X)=>JSON.stringify(X)).join(" | ")}`;case"array":return"array";case"object":return"object";case"union":return"one of the variants";case"json":return"a JSON value";case"ref":return B0({...l(Z.cell),optional:!1,nullable:!1})}})();return Q.optional||Q.nullable?`${$} or null`:$}function VQ(Q){let Z="";for(let $ of Q)Z+=typeof $==="number"?`[${$}]`:Z?`.${$}`:$;return Z}function zQ(Q){let Z=VQ(Q);return Z?`${Z}: `:""}function b1(Q){return`${zQ(Q.path)}${Q.message}`}function j1(Q,Z){if(Z===null||Z===void 0)return Q.optional||Q.nullable?1:0;let $=Q.node;switch($.kind){case"string":return typeof Z==="string"?1:0;case"number":return typeof Z==="number"?1:0;case"boolean":return typeof Z==="boolean"?1:0;case"literal":return Z===$.value?10:0;case"enum":return typeof Z==="string"&&$.values.includes(Z)?10:0;case"array":return Array.isArray(Z)?1:0;case"object":{if(typeof Z!=="object"||Array.isArray(Z))return 0;let X=Z,G=1;for(let[Y,K]of Object.entries($.shape))G+=j1(K,X[Y]);return G}case"union":return $.members.reduce((X,G)=>Math.max(X,j1(G,Z)),0);case"json":return 1;case"ref":return D0($.cell,Z,()=>1,()=>j1(l($.cell),Z))}}function D0(Q,Z,$,X){if(typeof Z!=="object"||Z===null)return X();if(Q.active.has(Z))return $();Q.active.add(Z);try{return X()}finally{Q.active.delete(Z)}}function h(Q,Z,$,X){if(Q.optional&&(Z===null||Z===void 0))return{drop:!0,value:void 0};if(Q.nullable&&Z===null)return{drop:!1,value:null};return{drop:!1,value:PQ(Q,Z,$,X)}}function PQ(Q,Z,$,X){let G=Q.node,Y=()=>{let K=Z===void 0?"required":G.kind==="literal"?"const":G.kind==="enum"&&typeof Z==="string"?"enum":"type",J=K==="const"?{allowedValue:G.value}:K==="enum"?{allowedValues:G.values}:{};X.push({path:$,code:K,message:`expected ${B0(Q)}, got ${WQ(G,Z)}`,params:J});return};switch(G.kind){case"string":if(typeof Z!=="string")return Y();return M0(G.checks,Z,$,X),Z;case"number":if(typeof Z!=="number"||!Number.isFinite(Z))return Y();if(G.checks?.integer&&!Number.isInteger(Z))return Y();return UQ(G.checks,Z,$,X),Z;case"boolean":return typeof Z==="boolean"?Z:Y();case"literal":return Z===G.value?Z:Y();case"enum":if(typeof Z!=="string"||!G.values.includes(Z))return Y();return M0(G.checks,Z,$,X),Z;case"array":{if(!Array.isArray(Z))return Y();let K=Z.map((W,z)=>{let P=h(G.item,W,[...$,z],X);return P.drop?void 0:P.value}),{minItems:J,maxItems:H}=G.checks??{};if(J!==void 0&&Z.length<J)X.push({path:$,code:"minItems",message:`expected at least ${J} items, got ${Z.length}`,params:{limit:J}});if(H!==void 0&&Z.length>H)X.push({path:$,code:"maxItems",message:`expected at most ${H} items, got ${Z.length}`,params:{limit:H}});return K}case"object":{if(typeof Z!=="object"||Z===null||Array.isArray(Z))return Y();let K=Z,J={};for(let[H,W]of Object.entries(G.shape)){let z=h(W,K[H],[...$,H],X);if(!z.drop)J[H]=z.value}if(G.unknownKeys)for(let H of Object.keys(K)){if(Object.hasOwn(G.shape,H)||K[H]===void 0)continue;if(G.unknownKeys==="error"){X.push({path:[...$,H],code:"additionalProperties",message:"unknown key",params:{additionalProperty:H}});continue}G1(K[H],[...$,H],X,new Set),Object.defineProperty(J,H,{value:K[H],enumerable:!0,writable:!0,configurable:!0})}return J}case"union":{let K;for(let J of G.members){let H=[],W=h(J,Z,$,H);if(H.length===0)return W.drop?void 0:W.value;let z=j1(J,Z);if(!K||z>K.score)K={issues:H,score:z}}X.push({path:$,code:"anyOf",message:`no matching variant; closest: ${K.issues.map(b1).join("; ")}`,params:{closest:K.issues}});return}case"json":if(Z===void 0)return Y();return G1(Z,$,X,new Set),Z;case"ref":return D0(G.cell,Z,()=>{X.push({path:$,code:"type",message:"expected a finite tree, got a circular reference",params:{}});return},()=>h(l(G.cell),Z,$,X).value)}}function MQ(Q){let Z=0;for(let $ of Q)Z++;return Z}function M0(Q,Z,$,X){if(!Q)return;let{minLength:G,maxLength:Y,format:K}=Q;if(G!==void 0||Y!==void 0){let J=MQ(Z);if(G!==void 0&&J<G)X.push({path:$,code:"minLength",message:`expected at least ${G} characters, got ${J}`,params:{limit:G}});if(Y!==void 0&&J>Y)X.push({path:$,code:"maxLength",message:`expected at most ${Y} characters, got ${J}`,params:{limit:Y}})}if(K){let J=!1;try{J=K.test(Z)===!0}catch{}if(!J)X.push({path:$,code:"format",message:`expected a string in format "${K.name}"`,params:{format:K.name}})}}function UQ(Q,Z,$,X){if(!Q)return;let G=(Y,K,J,H)=>{if(K===void 0||J(K))return;X.push({path:$,code:Y,message:`expected ${H} ${K}, got ${Z}`,params:{limit:K}})};G("minimum",Q.minimum,(Y)=>Z>=Y,"at least"),G("exclusiveMinimum",Q.exclusiveMinimum,(Y)=>Z>Y,"more than"),G("maximum",Q.maximum,(Y)=>Z<=Y,"at most"),G("exclusiveMaximum",Q.exclusiveMaximum,(Y)=>Z<Y,"less than")}function G1(Q,Z,$,X,G=!0){let Y=(J)=>{$.push({path:Z,code:"type",message:`expected a JSON value, got ${J}`,params:{}})};switch(typeof Q){case"undefined":case"string":case"boolean":return;case"number":if(!Number.isFinite(Q))Y(String(Q));return;case"bigint":return Y("a bigint");case"function":return Y("a function");case"symbol":return Y("a symbol")}if(Q===null)return;let K=Q;if(X.has(K))return Y("a circular reference");X.add(K);try{let J=G?K.toJSON:void 0;if(typeof J==="function"){let H;try{H=J.call(K)}catch{return Y("a toJSON that threw")}if(H===void 0)return Y("a toJSON that returns undefined");return G1(H,Z,$,X,!1)}if(Array.isArray(Q))Q.forEach((H,W)=>G1(H,[...Z,W],$,X));else for(let[H,W]of Object.entries(K))G1(W,[...Z,H],$,X)}finally{X.delete(K)}}function S(Q){return C1(Q)}function C1(Q){let Z={toJSONSchema:()=>GQ(Q),parse($){let X=[],G=h(Q,$,[],X);if(X.length>0)throw Error(X.map(b1).join("; "));return G.drop?void 0:G.value},safeParse($){let X=[],G=h(Q,$,[],X);if(X.length>0)return{ok:!1,errors:X.map(b1)};return{ok:!0,value:G.drop?void 0:G.value}},validate($){let X=[],G=h(Q,$,[],X);if(X.length>0)return{ok:!1,issues:X};return{ok:!0,value:G.drop?void 0:G.value}},describe:($)=>C1({...Q,description:$}),optional:()=>C1({...Q,optional:!0}),nullable:()=>C1({...Q,nullable:!0,optional:!1})};return O1.set(Z,Q),Z}function x(Q){return{node:Q,optional:!1,nullable:!1}}var U0=["strip","error","passthrough"];class R0 extends Error{problems;constructor(Q){super(`gemi/ai: s.fromJSONSchema cannot model this schema:
|
|
3
|
-
${Q.map((Z)=>`- ${Z}`).join(`
|
|
4
|
-
`)}`);this.name="JSONSchemaError",this.problems=Q}}var BQ=new Set(["title","$schema","$id","$comment","examples","default","deprecated","readOnly","writeOnly"]),Q1={string:["minLength","maxLength","format"],number:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],integer:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],boolean:[],object:["properties","required","additionalProperties"],array:["items","minItems","maxItems"]};function D1(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function _1(Q,Z,$,X){let G=(V,B=$)=>{X.push(B?`${B}: ${V}`:V);return},Y=(V)=>$?`${$}.${V}`:V;if(!D1(Q))return G("expected a schema object");let K=new Set(Z.ignoreKeywords??[]),J=(V)=>BQ.has(V)||V.startsWith("x-")||K.has(V),H=!1,W=Q.type;if(Array.isArray(W)){let V=W.filter((B)=>B!=="null");if(V.length!==1)return G(`type ${JSON.stringify(W)} is not supported; only one type, optionally with "null". Use anyOf for alternatives`,Y("type"));H=V.length<W.length,W=V[0]}if(W!==void 0&&(typeof W!=="string"||!(W in Q1)))return G(`type ${JSON.stringify(W)} is not supported; expected one of ${Object.keys(Q1).join(", ")}`,Y("type"));let z=new Set(["type","description","enum","const","anyOf",...W?Q1[W]:[]]),P=!1;for(let V of Object.keys(Q)){if(z.has(V)||J(V))continue;P=!0;let B=Object.entries(Q1).find(([,M])=>M.includes(V));G(B&&B[0]!==W?`"${V}" applies to type ${B[0]}, and this schema is ${W?`type ${W}`:"untyped"}`:`"${V}" is not supported by s.fromJSONSchema`,Y(V))}if(P)return;if(Q.description!==void 0&&typeof Q.description!=="string")return G("expected a string",Y("description"));let C=Q.description,U=(V)=>({node:V,optional:!1,nullable:H,...C?{description:C}:{}});if(Q.anyOf!==void 0){if(W!==void 0||Q.enum!==void 0||Q.const!==void 0)return G("anyOf cannot be combined with type, enum or const here",Y("anyOf"));if(!Array.isArray(Q.anyOf)||Q.anyOf.length===0)return G("expected a non-empty array",Y("anyOf"));let V=[],B=!1;if(Q.anyOf.forEach((M,R)=>{if(D1(M)&&M.type==="null"&&Object.keys(M).length===1){H=!0;return}let I=_1(M,Z,Y(`anyOf[${R}]`),X);if(I)V.push(I);else B=!0}),B)return;if(V.length===0)return G("anyOf has only null in it",Y("anyOf"));if(V.length===1){let M=V[0];return{...M,nullable:M.nullable||H,...C?{description:C}:{}}}return U({kind:"union",members:V})}if(Q.const!==void 0){let V=Q.const;if(typeof V!=="string"&&typeof V!=="number"&&typeof V!=="boolean")return G("only a string, number or boolean const is supported",Y("const"));if(W!==void 0&&typeof V!==(W==="integer"?"number":W))return G(`const ${JSON.stringify(V)} is not of type ${W}`,Y("const"));return U({kind:"literal",value:V})}let D;if(W==="string"){if(D=DQ(Q,Z,Y,X),D===null)return}if(Q.enum!==void 0){if(!Array.isArray(Q.enum)||Q.enum.length===0)return G("expected a non-empty array",Y("enum"));let V=Q.enum.filter((R)=>R!==null);if(V.length<Q.enum.length)H=!0;let B=V.find((R)=>!(typeof R==="string"||typeof R==="number"||typeof R==="boolean")||W!==void 0&&typeof R!==(W==="integer"?"number":W));if(B!==void 0||V.length===0)return G(W?`every value must be of type ${W}${V.length===0?", and there must be one":`; ${JSON.stringify(B)} is not`}`:"only strings, numbers and booleans are supported",Y("enum"));if(V.every((R)=>typeof R==="string"))return U({kind:"enum",values:[...new Set(V)],...D?{checks:D}:{}});let M=[...new Set(V)];if(M.length===1)return U({kind:"literal",value:M[0]});return U({kind:"union",members:M.map((R)=>x({kind:"literal",value:R}))})}switch(W){case void 0:return G("a schema needs a type, an enum, a const or an anyOf");case"string":return U({kind:"string",...D?{checks:D}:{}});case"number":case"integer":{let V=W==="integer"?{integer:!0}:{},B=!1;for(let M of Q1.number){let R=Q[M];if(R===void 0)continue;if(typeof R!=="number"||!Number.isFinite(R)){G("expected a number",Y(M)),B=!0;continue}V[M]=R}if(B)return;return U({kind:"number",...Object.keys(V).length>0?{checks:V}:{}})}case"boolean":return U({kind:"boolean"});case"array":{if(!D1(Q.items))return G('an array needs "items" to be one schema (tuples are not supported)',Y("items"));let V={},B=!1;for(let R of["minItems","maxItems"]){let I=Q[R];if(I===void 0)continue;if(typeof I!=="number"||!Number.isInteger(I)||I<0){G("expected a non-negative integer",Y(R)),B=!0;continue}V[R]=I}let M=_1(Q.items,Z,Y("items"),X);if(!M||B)return;return U({kind:"array",item:M,...Object.keys(V).length>0?{checks:V}:{}})}case"object":{let V=Q.properties??{};if(!D1(V))return G("expected an object",Y("properties"));if(Q.additionalProperties!==void 0&&Q.additionalProperties!==!1)return G("only false is supported; a record with arbitrary keys has no strict-mode form (use s.json())",Y("additionalProperties"));let B=Q.required??[];if(!Array.isArray(B)||!B.every((N)=>typeof N==="string"))return G("expected an array of property names",Y("required"));let M=B.filter((N)=>!Object.hasOwn(V,N));if(M.length>0)return G(`lists properties the schema doesn't have: ${M.join(", ")}`,Y("required"));let R={},I=!1;for(let[N,L]of Object.entries(V)){let _=_1(L,Z,Y(`properties.${N}`),X);if(!_){I=!0;continue}R[N]=B.includes(N)?_:{..._,optional:!0}}if(I)return;let A=Z.unknownKeys;return U({kind:"object",shape:R,...A==="error"||A==="passthrough"?{unknownKeys:A}:{}})}}return}function DQ(Q,Z,$,X){let G={},Y=!1;for(let K of["minLength","maxLength"]){let J=Q[K];if(J===void 0)continue;if(typeof J!=="number"||!Number.isInteger(J)||J<0){X.push(`${$(K)}: expected a non-negative integer`),Y=!0;continue}G[K]=J}if(Q.format!==void 0){let K=Q.format,J=typeof K==="string"?Z.formats?.[K]:void 0;if(typeof K!=="string")X.push(`${$("format")}: expected a string`),Y=!0;else if(!J||!Object.hasOwn(Z.formats,K))X.push(`${$("format")}: unknown format ${JSON.stringify(K)}; pass a check for it in the formats option`),Y=!0;else G.format={name:K,test:RQ(J)}}if(Y)return null;return Object.keys(G).length>0?G:void 0}function RQ(Q){if(Q===!0)return()=>!0;if(Q instanceof RegExp)return(Z)=>{return Q.lastIndex=0,Q.test(Z)};return Q}var nZ={string:()=>S(x({kind:"string"})),number:()=>S(x({kind:"number"})),boolean:()=>S(x({kind:"boolean"})),literal:(Q)=>S(x({kind:"literal",value:Q})),enum:(Q)=>S(x({kind:"enum",values:Q})),object:(Q)=>S(x({kind:"object",shape:Object.fromEntries(Object.entries(Q).map(([Z,$])=>[Z,R1($)]))})),array:(Q)=>S(x({kind:"array",item:R1(Q)})),union:(Q)=>S(x({kind:"union",members:Q.map(R1)})),json:()=>S(x({kind:"json"})),recursive:CQ,fromJSONSchema:(Q,Z={})=>{let $=[];if(Z.unknownKeys!==void 0&&!U0.includes(Z.unknownKeys))throw Error(`gemi/ai: s.fromJSONSchema's unknownKeys option must be one of ${U0.map((G)=>JSON.stringify(G)).join(", ")}, got ${JSON.stringify(Z.unknownKeys)}`);let X=_1(Q,Z,"",$);if(!X||$.length>0)throw new R0($.length>0?$:["unreadable schema"]);return S(X)}};function lZ(Q){let Z=O1.get(Q);if(Z)return X1(Z.node);return $1(Q.toJSONSchema())}function $1(Q){if(!(Q.$ref!==void 0||Q.type!==void 0||Q.enum!==void 0||Q.const!==void 0||Q.anyOf!==void 0||Q.properties!==void 0||Q.items!==void 0))return!1;for(let $ of Object.values(Q.properties??{}))if(!$1($))return!1;if(Q.items&&!$1(Q.items))return!1;for(let $ of Q.anyOf??[])if(!$1($))return!1;for(let $ of Object.values(Q.$defs??{}))if(!$1($))return!1;return!0}function X1(Q,Z=new Set){switch(Q.kind){case"string":case"number":case"boolean":case"literal":case"enum":return!0;case"object":return Object.values(Q.shape).every(($)=>X1($.node,Z));case"array":return X1(Q.item.node,Z);case"union":return Q.members.every(($)=>X1($.node,Z));case"json":return!1;case"ref":if(Z.has(Q.cell))return!0;return Z.add(Q.cell),X1(l(Q.cell).node,Z)}}function f1(Q,Z,$=new Set){let X=Q.node;if(X.kind==="union")return X.members.some((G)=>f1(G,Z,$));if(X.kind!=="ref")return!1;if(X.cell===Z)return!0;if($.has(X.cell)||!X.cell.definition)return!1;return $.add(X.cell),f1(X.cell.definition,Z,$)}var jQ=/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;function CQ(Q,Z){if(typeof Q!=="string"||!jQ.test(Q))throw Error(`gemi/ai: s.recursive needs a name of letters, digits, "_" and "-" (starting with a letter or "_", at most 64), got ${JSON.stringify(Q)}`);let $={name:Q,active:new Set},X=()=>x({kind:"ref",cell:$}),G=R1(Z(S(X())));if(G.optional)throw Error(`gemi/ai: the recursive schema "${Q}" is optional() as a whole; mark the places that use it optional instead`);if(f1(G,$))throw Error(`gemi/ai: the recursive schema "${Q}" refers to itself outside any object or array, so it describes no finite value; nest \`self\` in an s.object(...) field or an s.array(...)`);return $.definition=G,S(X())}function j0(Q){if(typeof Q!=="string")return null;let[Z]=Q.split(";",1),$=Z.trim().toLowerCase();return $===""?null:$}function C0(Q){if(Q===null)return!1;if(Q==="application/json")return!0;let Z=Q.indexOf("/");return Z>0&&Q.endsWith("+json")&&Q.length>Z+1+5}var Y1=new WeakMap;function sZ(Q,Z,$,X){Y1.set(Q,{clientAddress:Z,...$?{grant:Object.freeze({...$,scopes:Object.freeze([...$.scopes])})}:{},...X?{progress:X}:{}})}function _0(Q){return Y1.get(Q)?.progress}function O0(Q){return Y1.get(Q)?.grant}function L0(Q){return Y1.has(Q)}function tZ(Q){return Y1.get(Q)?.clientAddress}var I0=new WeakMap;function rZ(Q,Z){I0.set(Q,Z)}function A0(Q){return I0.get(Q)??null}var h1=new WeakMap;function eZ(Q,Z){let $=h1.get(Q)??[];if(!$.includes(Z))h1.set(Q,[...$,Z])}function Q8(Q){return h1.get(Q)??[]}class i{data;constructor(Q){this.data=Q}get(Q){return this.data[Q]}has(Q){return this.data[Q]!==void 0}toJSON(){return this.data}}function N0(Q){return typeof Q==="object"&&Q!==null&&!(Q instanceof Blob)}function _Q(Q,Z){if(!Z.includes(".")||Object.hasOwn(Q,Z))return[{path:[Z],value:Q[Z]}];let $=[{path:[],value:Q}];for(let X of Z.split(".")){let G=[];for(let{path:Y,value:K}of $){if(X==="*"){if(Array.isArray(K))K.forEach((J,H)=>G.push({path:[...Y,H],value:J}));else if(N0(K))for(let[J,H]of Object.entries(K))G.push({path:[...Y,J],value:H});continue}if(Array.isArray(K)&&/^\d+$/.test(X)){G.push({path:[...Y,Number(X)],value:K[Number(X)]});continue}G.push({path:[...Y,X],value:N0(K)&&Object.hasOwn(K,X)?K[X]:void 0})}$=G}return $}function F0(Q){return Q.join(".")}class OQ{kind;rawRequest;headers;cookies;search;schema={};routePath;params;domain;state;constructor(Q,Z,$,X){if(!Q){let H=b.getStore().req;this.params=H.params,this.rawRequest=H.rawRequest,this.kind=H.kind,this.routePath=H.routePath,this.domain=H.domain??null,this.state=H.state??new m1}else this.params=Z,this.rawRequest=Q,this.routePath=X,this.kind=$??"api",this.domain=A0(Q),this.state=new m1;this.headers=this.rawRequest.headers;let G=E1(this.rawRequest.headers.get("Cookie")),Y=new URL(this.rawRequest.url),K=new Map;for(let[H,W]of Y.searchParams)if(K.has(H)){let z=K.get(H);if(Array.isArray(z))z.push(W),K.set(H,z);else K.set(H,[z,W])}else K.set(H,W);let J=Object.fromEntries(K.entries());this.search=new i(J),this.cookies=G}locale(){let Q=b.getStore();if(Q.locale)return Q.locale;let Z=L1(T0);return Z.isLocaleAware?Z.detectLocale(Q.req):Q.locale}ctx(){return b.getStore()}isModelOriginated(){return L0(this.rawRequest)}mcpGrant(){return O0(this.rawRequest)??null}reportProgress(Q){let Z=_0(this.rawRequest);if(!Z)return!1;return Z(Q),!0}get signal(){return this.rawRequest.signal}range(){return X0(this.rawRequest.headers.get("Range"))}refine(Q){return{}}async parseBody(){let Q=j0(this.rawRequest.headers.get("Content-Type"));if(C0(Q))return new i(await this.parseJsonBody());if(Q==="application/x-www-form-urlencoded"||Q==="multipart/form-data"){if(Q==="multipart/form-data"&&!v1(this.schema)){let X=J0(this.schema??{});if(X!==null)P0(this.rawRequest,X)}let Z;try{Z=await this.rawRequest.formData()}catch(X){if(X instanceof F)throw X;throw new F("The request body could not be read as a form.")}let $=new Map;for(let[X,G]of Z.entries())if($.has(X)){let Y=$.get(X);if(Array.isArray(Y))Y.push(G);else $.set(X,[Y,G])}else $.set(X,G);return new i(Object.fromEntries($.entries()))}return new i({})}async parseJsonBody(){if(!this.rawRequest.body)return{};let Q;try{Q=await this.rawRequest.text()}catch($){if($ instanceof F)throw $;throw new F("The request body could not be read.")}if(Q.trim()==="")return{};let Z;try{Z=JSON.parse(Q)}catch{throw new F("The request body is not valid JSON.")}if(Z===null||typeof Z!=="object")throw new F("The request body must be a JSON object.");return Z}validateInput(Q){if(v1(this.schema))return this.validateWithSchema(Q);let Z=Q.toJSON()??{},$={},X=Object.entries(this.schema).map(([G,Y])=>({key:G,rules:Object.entries(Y).map(([K,J])=>({rule:K,message:J,check:typeof J==="function"?null:this.ruleFor(G,K)}))}));for(let{key:G,rules:Y}of X)for(let{path:K,value:J}of _Q(Z,G)){let H=this.checkField(J,Y);if(H.length>0){let W=$[F0(K)]??=[];for(let z of H)if(!W.includes(z))W.push(z)}}if(this.addRefinements($,Z),Object.keys($).length>0)throw new e($);return Q}checkField(Q,Z){let $=Z.some(({rule:Y})=>Y==="required"),X=Q===void 0||Q===null||Q==="",G=[];for(let{rule:Y,message:K,check:J}of Z){let H=K,W=!1;if(typeof K==="function")H=K(Q),W=typeof H>"u";else W=J(Q);if(W)continue;if(X&&!$)continue;if(Y==="required")return[String(H)];if(!G.includes(String(H)))G.push(String(H))}return G}validateWithSchema(Q){let Z=this.schema.validate(Q.toJSON()),$={};if("issues"in Z)for(let G of Z.issues){let Y=F0(G.path),K=$[Y]??=[];if(!K.includes(G.message))K.push(G.message)}let X="value"in Z?new i(Z.value):Q;if(this.addRefinements($,X.toJSON()),Object.keys($).length>0)throw new e($);return X}addRefinements(Q,Z){for(let[$,X]of Object.entries(this.refine(Z)??{})){let G=Q[$]??[];Q[$]=G.includes(X)?G:[...G,X]}}ruleFor(Q,Z){try{return W0(Z)}catch($){if($ instanceof k)throw new k(`${this.constructor.name}.schema.${Q}: ${$.message}`);throw $}}async input(){return this.validateInput(await this.parseBody())}async safeInput(){let Q=await this.parseBody();try{return{isValid:!0,errors:{},input:this.validateInput(Q)}}catch(Z){if(!(Z instanceof e))throw Z;return{isValid:!1,errors:Z.errors,input:Q}}}}var w0="x-gemi-sign-in";class LQ extends F{error;constructor(Q="Not authorized"){super(Q);this.name="AuthorizationError",this.error=Q,this.payload={api:{status:401,data:{error:A1("authorization",this.error,401)}},view:{}}}}class p1 extends F{static apiStatus=403;error;constructor(Q="Insufficient permissions"){super(Q);this.name="InsufficientPermissionsError",this.error=Q,this.payload={api:{status:p1.apiStatus,data:{error:A1("permission",this.error,p1.apiStatus)}},view:{status:403}}}}class c1 extends F{total;constructor(Q){super("Range not satisfiable");this.total=Q;this.name="RangeNotSatisfiableError",this.payload={api:{status:416,data:{error:I1("range_not_satisfiable","Range not satisfiable",416)},headers:{"Content-Range":Y0(Q),"Accept-Ranges":"bytes","Cache-Control":"no-store"}},view:{}}}}class IQ extends F{constructor(Q="Not found"){super(Q);this.name="NotFoundError",this.payload={api:{status:404,data:{error:I1("not_found",Q,404)},headers:{"Cache-Control":"no-store"}},view:{status:404}}}}class m extends F{fileName;constructor(Q){super("File not found");this.fileName=Q;this.name="FileNotFoundError",this.payload={api:{status:404,data:{error:I1("not_found","Not found",404)},headers:{"Cache-Control":"no-store"}},view:{status:404}}}}class AQ extends F{constructor(Q={}){super("Authentication error");this.name="AuthenticationError";let Z=Q.redirectTo??"/auth/sign-in";this.payload={api:{status:401,data:{error:A1("authentication","Authentication error",401)},headers:{[w0]:Z}},viewData:{status:200,data:{},headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate"},directive:{kind:"Redirect",path:Z}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:Z}}}}}class K1{static getFacadeAccessor(){throw Error(`Facade [${this.name}] does not implement getFacadeAccessor().`)}static getFacadeRoot(){return L1(this.getFacadeAccessor())}}import{Buffer as NQ}from"buffer";function N1(Q){if(typeof Q!=="string"||/^[\s/.]*$/.test(Q))throw Error(`Refusing to delete by prefix ${JSON.stringify(Q)}: it would match the whole store`)}class H1{async putStream({body:Q,...Z},$={}){$.signal?.throwIfAborted();let X=[],G=Q.getReader();try{for(;;){$.signal?.throwIfAborted();let{done:Y,value:K}=await G.read();if(Y)break;X.push(K)}}catch(Y){throw await G.cancel(Y).catch(()=>{}),Y}return this.put({...Z,body:NQ.concat(X)},$)}async*objects(Q,Z={}){throw Error(`${this.constructor.name} does not implement objects(). Override it to list objects in this backend.`)}async deletePrefix(Q,Z={}){N1(Q);let $=[];for await(let X of this.objects(Q,Z))$.push(X.name);for(let X of $)Z.signal?.throwIfAborted(),await this.delete({name:X,bucket:Z.bucket});return $.length}async delete(Q){throw Error(`${this.constructor.name} does not implement delete(). Override it to remove objects from this backend.`)}async read(Q){let Z=typeof Q==="string"?{name:Q}:Q,$=await this.fetch({name:Z.name,bucket:Z.bucket});if(!$.ok)throw new m(Z.name);let X=$.headers.get("Content-Type")??"application/octet-stream",G=$.headers.get("ETag")??void 0,Y=$.headers.get("Last-Modified"),K=Y?new Date(Y):void 0;if(Z.range){let W=await $.blob();return{body:W,start:0,end:W.size-1,total:W.size,partial:!1,type:X,etag:G,lastModified:K,name:Z.name}}let J=Number($.headers.get("Content-Length")),H=Number.isFinite(J)?J:0;return{body:$.body,start:0,end:H-1,total:H,partial:!1,type:X,etag:G,lastModified:K,name:Z.name}}async size(Q){let Z=typeof Q==="string"?Q:Q.name,$=typeof Q==="string"?void 0:Q.bucket,X=await this.fetch({name:Z,bucket:$});if(!X.ok)throw new m(Z);let G=Number(X.headers.get("Content-Length"));if(Number.isFinite(G))return await X.body?.cancel(),G;return(await X.blob()).size}}function q0(Q,Z){if(!Z)return Q;let $=Q.getReader(),X=!1,G,Y=()=>{if(X=!0,G)Z.removeEventListener("abort",G)};return new ReadableStream({start(K){if(G=()=>{if(X)return;Y(),K.error(Z.reason),$.cancel(Z.reason).catch(()=>{})},Z.aborted)G();else Z.addEventListener("abort",G,{once:!0})},async pull(K){let J;try{J=await $.read()}catch(H){if(X)return;Y(),K.error(H);return}if(X)return;if(J.done){Y(),K.close();return}K.enqueue(J.value)},cancel(K){return Y(),$.cancel(K)}},{highWaterMark:0})}import{mkdir as FQ,open as TQ,readdir as u1,rename as wQ,rmdir as qQ,stat as SQ,unlink as S0}from"fs/promises";import{dirname as EQ,isAbsolute as d1,relative as J1,resolve as o,sep as f}from"path";class n1 extends H1{configured;constructor(Q){super();this.configured=Q}get folderPath(){return this.configured??`${W1()}/storage`}async put(Q,{signal:Z}={}){Z?.throwIfAborted();let $,X;if(Q instanceof Blob)$=Q,X=`${Bun.randomUUIDv7()}.${Q.type.split("/")[1].split(";")[0]}`;else $=Q.body,X=Q.name;let G=$ instanceof Buffer?$:$ instanceof Blob||$ instanceof File?Buffer.from(await $.arrayBuffer()):"",Y=`${this.folderPath}/${X}`;return Z?.throwIfAborted(),await Bun.write(Y,G),X}async putStream({name:Q,body:Z},{signal:$}={}){let X=Z.getReader(),G=null;try{if($?.throwIfAborted(),!Q)throw Error("Object name has to be specified");let Y=o(this.folderPath),K=o(Y,Q),J=J1(Y,K);if(!J||J===".."||J.startsWith(`..${f}`)||d1(J))throw Error(`Refusing to write "${Q}": it is outside the storage folder`);await FQ(EQ(K),{recursive:!0}),G=`${K}.${Bun.randomUUIDv7()}.partial`;let H=await TQ(G,"wx");try{for(;;){$?.throwIfAborted();let{done:W,value:z}=await X.read();if(W)break;for(let P=0;P<z.byteLength;){let{bytesWritten:C}=await H.write(z,P);P+=C}}}finally{await H.close()}return $?.throwIfAborted(),await wQ(G,K),Q}catch(Y){if(await X.cancel(Y).catch(()=>{}),G)await S0(G).catch(()=>{});throw Y}}async fetch(Q,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,X;if(typeof Q==="string")X=Q;else $=Q.bucket??$,X=Q.name;if(!X)throw Error("Object name has to be specified");let G=`${this.folderPath}/${X}`,Y=Bun.file(G),K=q0(Bun.file(G).stream(),Z),J=new Date(Y.lastModified).toUTCString();return new Response(K,{headers:{"Content-Type":Y.type,"Content-Length":String(Y.size),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J}})}async read(Q){let Z=typeof Q==="string"?{name:Q}:Q,{name:$,range:X=null}=Z;if(!$)throw Error("Object name has to be specified");let G=Bun.file(`${this.folderPath}/${$}`);if(!await G.exists())throw new m($);let Y=G.size,K=X?G0(X,Y):null;if(X&&!K)throw new c1(Y);let J=K?.start??0,H=K?K.end:Y-1;return{body:K?G.slice(J,H+1):G,start:J,end:H,total:Y,partial:Boolean(K),type:G.type||"application/octet-stream",lastModified:new Date(G.lastModified),name:$}}async size(Q){let Z=typeof Q==="string"?Q:Q.name,$=Bun.file(`${this.folderPath}/${Z}`);if(!await $.exists())throw new m(Z);return $.size}async delete(Q){let Z=typeof Q==="string"?Q:Q.name;if(!Z)throw Error("Object name has to be specified");let $=o(this.folderPath),X=o($,Z),G=J1($,X);if(!G||G===".."||G.startsWith(`..${f}`)||d1(G))throw Error(`Refusing to delete "${Z}": it is outside the storage folder`);try{await S0(X)}catch(Y){if(Y?.code==="ENOENT")return;throw Y}}resolvePrefix(Q){let Z=o(this.folderPath),$=Q.lastIndexOf("/"),X=$===-1?"":Q.slice(0,$),G=$===-1?Q:Q.slice($+1),Y=o(Z,X),K=J1(Z,Y);if(K===".."||K.startsWith(`..${f}`)||d1(K))throw Error(`Refusing to list "${Q}": it is outside the storage folder`);let J=K.split(f).join("/");return{root:Z,dir:Y,match:J?`${J}/${G}`:G}}async*objects(Q,{signal:Z}={}){Z?.throwIfAborted();let{root:$,dir:X,match:G}=this.resolvePrefix(Q),Y=[],K=async(J)=>{let H;try{H=await u1(J,{withFileTypes:!0})}catch(W){if(W?.code==="ENOENT"||W?.code==="ENOTDIR")return;throw W}for(let W of H){let z=`${J}${f}${W.name}`,P=J1($,z).split(f).join("/");if(W.isDirectory()){if(`${P}/`.startsWith(G)||G.startsWith(`${P}/`))await K(z)}else if(W.isFile()&&P.startsWith(G))Y.push(P)}};await K(X),Y.sort();for(let J of Y){Z?.throwIfAborted();let H;try{H=await SQ(`${$}/${J}`)}catch(W){if(W?.code==="ENOENT")continue;throw W}yield{name:J,size:H.size,lastModified:H.mtime}}}async deletePrefix(Q,Z={}){N1(Q);let{root:$,match:X}=this.resolvePrefix(Q);N1(X);let G=await super.deletePrefix(Q,Z);if(G>0)await this.pruneEmptyDirs($,X);return G}async pruneEmptyDirs(Q,Z){let $=[],X=async(G)=>{let Y;try{Y=await u1(G,{withFileTypes:!0})}catch{return}for(let K of Y){if(!K.isDirectory())continue;let J=`${G}${f}${K.name}`,H=J1(Q,J).split(f).join("/");if(`${H}/`.startsWith(Z)||Z.startsWith(`${H}/`)){if(await X(J),`${H}/`.startsWith(Z))$.push(J)}}};await X(Q);for(let G of $)try{await qQ(G)}catch{}}async list(){return await u1(this.folderPath)}}var v=30000;function f8(Q){return Q}function E0(){return{driver:new n1,fetchTimeoutMs:v,fetchIdleTimeoutMs:v}}class l1{static token="filesystem";driver;fetchTimeoutMs;fetchIdleTimeoutMs;constructor(Q={}){this.driver=Q.driver??E0().driver,this.fetchTimeoutMs=Q.fetchTimeoutMs??v,this.fetchIdleTimeoutMs=Q.fetchIdleTimeoutMs??v}}class x0 extends Error{driver;limit;timeoutMs;object;code="storage-fetch-timeout";constructor(Q,Z,$,X){super(Z==="fetchTimeoutMs"?`${Q}: no response for "${X}" within ${$}ms (fetchTimeoutMs)`:`${Q}: the body of "${X}" sent nothing for ${$}ms (fetchIdleTimeoutMs)`);this.driver=Q;this.limit=Z;this.timeoutMs=$;this.object=X;this.name="StorageFetchTimeoutError"}}async function k0(Q,Z,$,X){let{fetchTimeoutMs:G,fetchIdleTimeoutMs:Y}=X;if($.signal||!G&&!Y)return Q.fetch(Z,$);let K=new AbortController,J=Q.constructor?.name||"FileStorageDriver",H=typeof Z==="string"?Z:Z.name,W=(C,U)=>{let D=new x0(J,C,U,H);return K.abort(D),D},z=Promise.resolve(Q.fetch(Z,{...$,signal:K.signal})),P;if(G){let C,U=new Promise((D,V)=>{C=setTimeout(()=>V(W("fetchTimeoutMs",G)),G)});try{P=await Promise.race([z,U])}catch(D){if(K.signal.aborted)throw z.then((V)=>V.body?.cancel(K.signal.reason).catch(()=>{}),()=>{}),K.signal.reason;throw D}finally{clearTimeout(C)}}else P=await z;if(!Y||!P.body)return P;return new Response(xQ(P.body,Y,()=>W("fetchIdleTimeoutMs",Y)),{status:P.status,statusText:P.statusText,headers:P.headers})}function xQ(Q,Z,$){let X=Q.getReader();return new ReadableStream({async pull(G){let Y,K,J=new Promise((H,W)=>{Y=setTimeout(()=>{K=$(),W(K)},Z)});try{let H=await Promise.race([X.read(),J]);if(H.done)G.close();else G.enqueue(H.value)}catch(H){let W=K??H;G.error(W),X.cancel(W).catch(()=>{})}finally{clearTimeout(Y)}},cancel(G){return X.cancel(G)}},{highWaterMark:0})}class w extends Error{code="safe-fetch";url;constructor(Q,Z,$){super(Q,$);this.name=new.target.name,this.url=Z}}class p extends w{reason;code="invalid-url";constructor(Q,Z,$){super($,Q);this.reason=Z}}class F1 extends w{host;reason;code="blocked-host";constructor(Q,Z,$){super($==="denied"?`Requests to ${Z} are not allowed.`:`${Z} is not on the list of hosts this request may reach.`,Q);this.host=Z;this.reason=$}}class s extends w{host;address;range;code="blocked-address";constructor(Q,Z,$,X){super(Z===$?`${$} is not a public address (${X}).`:`${Z} resolves to ${$}, which is not a public address (${X}).`,Q);this.host=Z;this.address=$;this.range=X}}class T1 extends w{host;code="dns";constructor(Q,Z,$){super(`Couldn't resolve ${Z}.`,Q,{cause:$});this.host=Z}}class w1 extends w{phase;ms;code="timeout";constructor(Q,Z,$){super(Z==="connect"?`Couldn't connect within ${$} ms.`:`The request didn't finish within ${$} ms.`,Q);this.phase=Z;this.ms=$}}class q1 extends w{limit;code="too-large";constructor(Q,Z){super(`The response is larger than ${Z} bytes.`,Q);this.limit=Z}}class V1 extends w{contentType;allowed;code="content-type";constructor(Q,Z,$){super(`The response is ${Z??"of no content type"}, not ${$.join(" or ")}.`,Q);this.contentType=Z;this.allowed=$}}class i1 extends w{limit;code="too-many-redirects";constructor(Q,Z){super(`More than ${Z} redirects.`,Q);this.limit=Z}}class t extends w{code="network";constructor(Q,Z){super(`The request failed: ${Z instanceof Error?Z.message:String(Z)}`,Q,{cause:Z})}}class o1 extends w{status;code="http-status";constructor(Q,Z){super(`The server answered ${Z}.`,Q);this.status=Z}}function kQ(Q){if(Q==="")return null;let Z=Q.split(".");if(Z.length>1&&Z[Z.length-1]==="")Z.pop();if(Z.length===0||Z.length>4)return null;let $=[];for(let Y of Z){let K=gQ(Y);if(K===null)return null;$.push(K)}let X=$.pop();for(let Y of $)if(Y>255)return null;if(X>=256**(4-$.length))return null;let G=X;return $.forEach((Y,K)=>{G+=Y*256**(3-K)}),new Uint8Array([Math.floor(G/16777216)&255,Math.floor(G/65536)&255,Math.floor(G/256)&255,G&255])}function gQ(Q){if(Q==="")return null;let Z=Q,$=10;if(/^0x/i.test(Z)){if(Z=Z.slice(2),$=16,Z==="")return 0}else if(Z.length>1&&Z.startsWith("0"))Z=Z.slice(1),$=8;if(!($===16?/^[0-9a-f]+$/i:$===8?/^[0-7]+$/:/^[0-9]+$/).test(Z))return null;let G=parseInt(Z,$);return Number.isSafeInteger(G)?G:null}function g0(Q){let Z=Q;if(Z.startsWith("[")&&Z.endsWith("]"))Z=Z.slice(1,-1);let $=Z.indexOf("%");if($!==-1)Z=Z.slice(0,$);if(!Z.includes(":"))return null;let X=Z.split("::");if(X.length>2)return null;let G=(W,z)=>{if(W==="")return[];let P=[],C=W.split(":");for(let U=0;U<C.length;U++){let D=C[U];if(z&&U===C.length-1&&D.includes(".")){if(!/^\d{1,3}(\.\d{1,3}){3}$/.test(D))return null;let V=D.split(".").map(Number);if(V.some((B)=>B>255))return null;P.push(V[0]<<8|V[1],V[2]<<8|V[3]);continue}if(!/^[0-9a-f]{1,4}$/i.test(D))return null;P.push(parseInt(D,16))}return P},Y=G(X[0],X.length===1),K=X.length===2?G(X[1],!0):[];if(!Y||!K)return null;let J;if(X.length===2){let W=8-Y.length-K.length;if(W<1)return null;J=[...Y,...Array.from({length:W},()=>0),...K]}else J=Y;if(J.length!==8)return null;let H=new Uint8Array(16);return J.forEach((W,z)=>{H[z*2]=W>>8,H[z*2+1]=W&255}),H}function z1(Q){let Z=g0(Q);if(Z)return{family:6,bytes:Z};let $=kQ(Q);if($)return{family:4,bytes:$};return null}function c(Q){if(Q.family===6&&yQ(Q.bytes))return{family:4,bytes:Q.bytes.slice(12)};return Q}function yQ(Q){for(let Z=0;Z<10;Z++)if(Q[Z]!==0)return!1;return Q[10]===255&&Q[11]===255}function P1(Q){if(Q.family===4)return Array.from(Q.bytes).join(".");let Z=[];for(let $=0;$<16;$+=2)Z.push((Q.bytes[$]<<8|Q.bytes[$+1]).toString(16));return Z.join(":")}function a(Q){let Z=Q.lastIndexOf("/"),$=Z===-1?Q:Q.slice(0,Z),X=/^[0-9.]+$/.test($)?bQ($):g0($);if(!X)return null;let G=c(X.length===4?{family:4,bytes:X}:{family:6,bytes:X}),Y=G.family===4?32:128,K=Y;if(Z!==-1){let J=Q.slice(Z+1);if(!/^\d{1,3}$/.test(J))return null;if(K=Number(J),X.length===16&&G.family===4)K-=96;if(K<0||K>Y)return null}return{family:G.family,bytes:G.bytes,prefix:K}}function bQ(Q){return/^\d{1,3}(\.\d{1,3}){3}$/.test(Q)&&Q.split(".").every((Z)=>Number(Z)<=255)?new Uint8Array(Q.split(".").map(Number)):null}function g(Q,Z){let $=c(Q);if($.family!==Z.family)return!1;let X=Z.prefix;for(let G=0;X>0;G++){let Y=Math.min(8,X),K=255<<8-Y&255;if(($.bytes[G]&K)!==(Z.bytes[G]&K))return!1;X-=Y}return!0}var O=(Q,Z)=>({cidr:a(Q),kind:Z,text:Q}),fQ=[O("0.0.0.0/8","unspecified"),O("10.0.0.0/8","private"),O("100.64.0.0/10","shared"),O("127.0.0.0/8","loopback"),O("169.254.169.254/32","metadata"),O("169.254.0.0/16","link-local"),O("168.63.129.16/32","metadata"),O("172.16.0.0/12","private"),O("192.0.0.0/24","reserved"),O("192.0.2.0/24","documentation"),O("192.88.99.0/24","reserved"),O("192.168.0.0/16","private"),O("198.18.0.0/15","benchmarking"),O("198.51.100.0/24","documentation"),O("203.0.113.0/24","documentation"),O("224.0.0.0/4","multicast"),O("255.255.255.255/32","broadcast"),O("240.0.0.0/4","reserved")],vQ=[O("::/128","unspecified"),O("::1/128","loopback"),O("64:ff9b:1::/48","private"),O("::/8","reserved"),O("100::/64","reserved"),O("2001:db8::/32","documentation"),O("2001::/23","reserved"),O("3fff::/20","documentation"),O("fd00:ec2::254/128","metadata"),O("fc00::/7","unique-local"),O("fe80::/10","link-local"),O("fec0::/10","private"),O("ff00::/8","multicast")],hQ=a("64:ff9b::/96"),mQ=a("2002::/16"),pQ=a("2000::/3");function S1(Q){let Z=typeof Q==="string"?z1(Q):Q;if(!Z)return{kind:"reserved",range:"not an IP address"};let $=c(Z);if($.family===4){let G=fQ.find((Y)=>g($,Y.cidr));return G?{kind:G.kind,range:G.text}:null}if(g($,hQ))return S1({family:4,bytes:$.bytes.slice(12)});if(g($,mQ))return S1({family:4,bytes:$.bytes.slice(2,6)});let X=vQ.find((G)=>g($,G.cidr));if(X)return{kind:X.kind,range:X.text};return g($,pQ)?null:{kind:"reserved",range:"outside 2000::/3"}}function y0(Q,Z){let $=c(Q),X=c(Z);return $.family===X.family&&$.bytes.every((G,Y)=>G===X.bytes[Y])}import{lookup as cQ}from"dns/promises";import*as uQ from"http";import*as dQ from"https";import*as r from"zlib";class s1 extends Response{#Q;#Z;address;constructor(Q,Z,$){super(Q,Z);this.#Q=$.url,this.#Z=$.redirected,this.address=$.address}get url(){return this.#Q}get redirected(){return this.#Z}}var M1={timeout:30000,connectTimeout:1e4,maxSize:10485760,maxRedirects:5,ports:[80,443]},nQ=new Set([301,302,303,307,308]),lQ=new Set([101,103,204,205,304]),iQ=["host","connection","content-length","transfer-encoding","keep-alive","upgrade"],oQ=["authorization","cookie","proxy-authorization"];async function v0(Q,Z={}){let $=sQ(Z),X=Z.signal;X?.throwIfAborted();let G=new AbortController,Y=G.signal,K=String(Q),J=(P)=>{if(!Y.aborted)G.abort(P)},H=setTimeout(()=>J(new w1(K,"total",$.timeout)),$.timeout),W=()=>J(X.reason);X?.addEventListener("abort",W,{once:!0});let z=()=>{clearTimeout(H),X?.removeEventListener("abort",W)};try{let P=f0(K,$),C=(Z.method??"GET").toUpperCase(),U=new Headers(Z.headers);for(let V of iQ)U.delete(V);if(!U.has("accept"))U.set("accept","*/*");if(!U.has("user-agent"))U.set("user-agent","gemi");if(!U.has("accept-encoding"))U.set("accept-encoding","gzip, deflate, br");let D=await eQ(C,Z.body,U);for(let V=0;;V++){K=P.href;let{request:B,response:M,address:R}=await QZ(P,C,U,D,$,Y),I=M.statusCode??0,A=M.headers.location;if(nQ.has(I)&&A&&Z.redirect!=="manual"){if(B.destroy(),V>=$.maxRedirects)throw new i1(P.href,$.maxRedirects);let N;try{N=new URL(A,P)}catch{throw new p(A,"malformed",`The redirect to "${A}" is not a URL.`)}if(I===303?C!=="HEAD":(I===301||I===302)&&C==="POST"){C="GET",D=null;let L=[];U.forEach((_,j)=>{if(j.startsWith("content-"))L.push(j)});for(let _ of L)U.delete(_)}if(N.origin!==P.origin)for(let L of oQ)U.delete(L);P=f0(N.href,$);continue}return ZZ({url:P,hop:V,method:C,request:B,response:M,address:R,policy:$,signal:Y,release:z})}}catch(P){throw z(),Y.aborted?Y.reason:P}}function sQ(Q){let Z=(X,G)=>{let Y={hosts:[],ranges:[]};for(let K of X){let J=K.includes("/")||K.includes(":")||/^[\d.]+$/.test(K),H=J?a(K):null;if(H)Y.ranges.push(H);else if(!J&&/^(\*\.)?[a-z0-9-]+(\.[a-z0-9-]+)*\.?$/i.test(K))Y.hosts.push(h0(K));else throw TypeError(`safeFetch: "${K}" in ${G} is not a host name or an IP range.`)}return Y},$=Q.allowPrivate;return{timeout:Q.timeout??M1.timeout,connectTimeout:Q.connectTimeout??M1.connectTimeout,maxSize:Q.maxSize??M1.maxSize,maxRedirects:Q.maxRedirects??M1.maxRedirects,ports:Q.ports??M1.ports,allow:Q.allow&&Q.allow.length>0?Z(Q.allow,"allow"):null,deny:Z(Q.deny??[],"deny"),allowPrivate:$===!0?!0:Z($||[],"allowPrivate").ranges,contentTypes:Q.contentTypes?.length?Q.contentTypes:null,resolve:Q.resolve??tQ}}async function tQ(Q){return(await cQ(Q,{all:!0,verbatim:!0})).map(($)=>$.address)}function h0(Q){return Q.toLowerCase().replace(/\.$/,"")}function b0(Q,Z){return Z.some(($)=>$.startsWith("*.")?Q.endsWith($.slice(1)):Q===$)}function f0(Q,Z){let $;try{$=new URL(Q)}catch{throw new p(Q,"malformed",`"${Q}" is not a URL.`)}if($.protocol!=="http:"&&$.protocol!=="https:")throw new p($.href,"scheme",`Only http and https URLs can be fetched, not ${$.protocol.slice(0,-1)}.`);if($.username||$.password)throw new p($.href,"credentials","The URL has a username or password in it.");let X=m0($);if(Z.ports!=="any"&&!Z.ports.includes(X))throw new p($.href,"port",`Port ${X} is not allowed.`);return $}function m0(Q){return Q.port?Number(Q.port):Q.protocol==="https:"?443:80}async function aQ(Q,Z,$){let X=h0(Q.hostname.replace(/^\[(.*)\]$/,"$1")),G=z1(X),Y=G!==null&&(X.includes(":")||/^\d+\.\d+\.\d+\.\d+$/.test(X));if(!Y&&b0(X,Z.deny.hosts))throw new F1(Q.href,X,"denied");let K=!Y&&Z.allow!==null&&b0(X,Z.allow.hosts);if(Z.allow&&!K&&Z.allow.ranges.length===0)throw new F1(Q.href,X,"not-allowed");let J;if(Y)J=[G];else{let H;try{H=await rQ(Z.resolve(X),$)}catch(W){if($.aborted)throw $.reason;throw new T1(Q.href,X,W)}if(J=H.map((W)=>z1(W)).filter((W)=>W!==null),J.length===0)throw new T1(Q.href,X)}for(let H of J){let W=P1(H);if(Z.deny.ranges.some((P)=>g(H,P)))throw new s(Q.href,X,W,"denied");if(Z.allow&&!K&&!Z.allow.ranges.some((P)=>g(H,P)))throw new s(Q.href,X,W,"not-allowed");let z=S1(H);if(z&&Z.allowPrivate!==!0&&!Z.allowPrivate.some((P)=>g(H,P)))throw new s(Q.href,X,W,z.kind)}return{host:X,addresses:J,isLiteral:Y}}function rQ(Q,Z){if(Z.aborted)return Promise.reject(Z.reason);return new Promise(($,X)=>{let G=()=>X(Z.reason);Z.addEventListener("abort",G,{once:!0}),Q.then((Y)=>{Z.removeEventListener("abort",G),$(Y)},(Y)=>{Z.removeEventListener("abort",G),X(Y)})})}async function eQ(Q,Z,$){if(Z===void 0||Z===null)return null;if(Q==="GET"||Q==="HEAD")throw TypeError(`safeFetch: a ${Q} request can't have a body.`);let X=new Request("http://body.invalid/",{method:"POST",body:Z}),G=X.headers.get("content-type");if(G&&!$.has("content-type"))$.set("content-type",G);return new Uint8Array(await X.arrayBuffer())}async function QZ(Q,Z,$,X,G,Y){let K=new AbortController,J=setTimeout(()=>K.abort(new w1(Q.href,"connect",G.connectTimeout)),G.connectTimeout),H=AbortSignal.any([Y,K.signal]);try{let{host:W,addresses:z,isLiteral:P}=await aQ(Q,G,H),C=Q.protocol==="https:",U={};if($.forEach((D,V)=>{U[V]=D}),X)U["content-length"]=String(X.byteLength);return await new Promise((D,V)=>{let B={method:Z,host:W,port:m0(Q),path:`${Q.pathname}${Q.search}`,headers:U,agent:!1,lookup:(L,_,j)=>{let q=_?.family,T=z.filter((U1)=>!q||U1.family===q);if(T.length===0)j(Object.assign(Error(`No IPv${q} address for ${W}`),{code:"ENOTFOUND"}));else if(_?.all)j(null,T.map((U1)=>({address:P1(U1),family:U1.family})));else j(null,P1(T[0]),T[0].family)}};if(C&&!P)B.servername=W;let M=(C?dQ:uQ).request(B),R=null,I=(L)=>{H.removeEventListener("abort",A),M.destroy(),V(L)},A=()=>I(H.aborted?H.reason:Y.reason);H.addEventListener("abort",A,{once:!0});let N=(L)=>{let _=L?.remoteAddress;if(!_||R!==null)return!0;let j=z1(_);if(!j||!z.some((q)=>y0(q,j)))return I(new s(Q.href,W,_,"not-allowed")),!1;return R=P1(c(j)),!0};M.once("socket",(L)=>{let _=()=>{if(N(L)&&!C)clearTimeout(J)};if(L.connecting)L.once("connect",_);else _();if(C)L.once("secureConnect",()=>clearTimeout(J))}),M.once("response",(L)=>{if(clearTimeout(J),L.on("error",()=>{}),!N(L.socket))return;H.removeEventListener("abort",A),D({request:M,response:L,address:R})}),M.on("error",(L)=>{if(H.aborted)return I(H.reason);I(L instanceof w?L:new t(Q.href,L))}),M.end(X??void 0)})}finally{clearTimeout(J)}}function ZZ({url:Q,hop:Z,method:$,request:X,response:G,address:Y,policy:K,signal:J,release:H}){let W=G.statusCode??0;if(W<200||W>599)throw X.destroy(),new t(Q.href,Error(`Unexpected status ${W}`));let z=new Headers,P=G.rawHeaders;for(let _=0;_<P.length;_+=2)z.append(P[_],P[_+1]);if(K.contentTypes){let _=z.get("content-type")?.split(";")[0].trim().toLowerCase()??null;if(!_||!K.contentTypes.some((j)=>$Z(_,j)))throw X.destroy(),new V1(Q.href,_,K.contentTypes)}let C={url:Q.href,redirected:Z>0,address:Y},U={status:W,statusText:G.statusMessage??"",headers:z};if($==="HEAD"||lQ.has(W))return X.destroy(),H(),new s1(null,U,C);let D=z.get("content-encoding")?.trim().toLowerCase(),V=D==="gzip"||D==="x-gzip"?r.createGunzip():D==="deflate"?r.createInflate():D==="br"?r.createBrotliDecompress():null,B=Number(z.get("content-length"));if(!V&&Number.isFinite(B)&&B>K.maxSize)throw X.destroy(),new q1(Q.href,K.maxSize);if(V)z.delete("content-encoding"),z.delete("content-length");let M=V?G.pipe(V):G,R=0,I=!1,A=()=>{},N=()=>{I=!0,J.removeEventListener("abort",A),H()},L=new ReadableStream({start(_){let j=(T)=>{if(I)return;if(N(),T===void 0)_.close();else X.destroy(),V?.destroy(),_.error(T)};if(A=()=>j(J.reason),J.addEventListener("abort",A,{once:!0}),J.aborted)return A();M.on("data",(T)=>{if(I)return;if(R+=T.byteLength,R>K.maxSize)return j(new q1(Q.href,K.maxSize));if(_.enqueue(new Uint8Array(T)),(_.desiredSize??1)<=0)M.pause()}),M.once("end",()=>j());let q=(T)=>j(T instanceof w?T:new t(Q.href,T));if(M.on("error",q),V)G.on("error",q);G.once("aborted",()=>j(new t(Q.href,Error("The response was cut off."))))},pull(){M.resume()},cancel(){if(I)return;N(),X.destroy(),V?.destroy()}});return new s1(L,U,C)}function $Z(Q,Z){let $=Z.toLowerCase();return $.endsWith("/*")?Q.startsWith($.slice(0,-1)):Q===$}function c0(Q){return YZ(Q)??HZ(Q)??JZ(Q)}var t1=4096,XZ={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/avif":"avif","image/heic":"heic","image/heif":"heif","image/bmp":"bmp","image/tiff":"tiff","image/x-icon":"ico","image/svg+xml":"svg","audio/mpeg":"mp3","audio/aac":"aac","audio/mp4":"m4a","audio/ogg":"ogg","audio/flac":"flac","audio/wav":"wav","video/mp4":"mp4","video/quicktime":"mov","video/webm":"webm","video/x-matroska":"mkv","video/x-msvideo":"avi","font/woff":"woff","font/woff2":"woff2","font/ttf":"ttf","font/otf":"otf","application/pdf":"pdf","application/zip":"zip","application/gzip":"gz","application/xml":"xml","text/html":"html","text/plain":"txt","application/octet-stream":"bin"};function u0(Q){return XZ[Q]??"bin"}function E(Q,Z,$=0){if(Q.length<$+Z.length)return!1;return Z.every((X,G)=>Q[$+G]===X)}function y(Q,Z,$){return String.fromCharCode(...Q.subarray(Z,$))}var GZ={avif:"image/avif",avis:"image/avif",heic:"image/heic",heix:"image/heic",hevc:"image/heic",hevx:"image/heic",heim:"image/heic",heis:"image/heic",mif1:"image/heif",msf1:"image/heif","qt ":"video/quicktime","M4A ":"audio/mp4","M4B ":"audio/mp4"};function YZ(Q){if(E(Q,[137,80,78,71,13,10,26,10]))return"image/png";if(E(Q,[255,216,255]))return"image/jpeg";if(Q.length>=6&&(y(Q,0,6)==="GIF87a"||y(Q,0,6)==="GIF89a"))return"image/gif";if(Q.length>=12&&y(Q,0,4)==="RIFF"){let Z=y(Q,8,12);if(Z==="WEBP")return"image/webp";if(Z==="WAVE")return"audio/wav";if(Z==="AVI ")return"video/x-msvideo"}if(Q.length>=12&&y(Q,4,8)==="ftyp"){let Z=y(Q,8,12);return GZ[Z]??"video/mp4"}if(E(Q,[73,73,42,0])||E(Q,[77,77,0,42]))return"image/tiff";if(E(Q,[66,77])&&E(Q,[0,0,0,0],6))return"image/bmp";if(E(Q,[0,0,1,0])&&Q.length>=6&&Q[4]>0)return"image/x-icon";if(E(Q,[37,80,68,70,45]))return"application/pdf";if(E(Q,[80,75,3,4]))return"application/zip";if(E(Q,[31,139]))return"application/gzip";if(E(Q,[26,69,223,163]))return y(Q,0,Math.min(Q.length,64)).includes("webm")?"video/webm":"video/x-matroska";if(Q.length>=4){let Z=y(Q,0,4);if(Z==="OggS")return"audio/ogg";if(Z==="fLaC")return"audio/flac";if(Z==="wOFF")return"font/woff";if(Z==="wOF2")return"font/woff2";if(Z==="OTTO")return"font/otf"}if(E(Q,[0,1,0,0,0]))return"font/ttf";if(Q.length>=3&&y(Q,0,3)==="ID3")return"audio/mpeg";if(Q.length>=2&&Q[0]===255){if((Q[1]&246)===240)return"audio/aac";if((Q[1]&224)===224&&(Q[1]&6)!==0)return"audio/mpeg"}return null}var KZ=["!doctype html","html","head","script","iframe","h1","div","font","table","a","style","title","b","body","br","p","!--"];function HZ(Q){let Z=new TextDecoder("utf-8",{fatal:!1}).decode(Q);if(Z.charCodeAt(0)===65279)Z=Z.slice(1);if(Z=Z.trimStart(),!Z.startsWith("<"))return null;let $=Z.toLowerCase(),X=$;for(;;){X=X.trimStart();let G=/^(<\?[\s\S]*?\?>|<!--[\s\S]*?-->|<!doctype[^>]*>)/.exec(X);if(!G)break;X=X.slice(G[0].length)}if(/^<svg[\s>/]/.test(X))return"image/svg+xml";for(let G of KZ){if(!$.startsWith(`<${G}`))continue;if(/^[\s>]/.test($.charAt(G.length+1)))return"text/html"}if(/^<(html|head|body)[\s>]/.test(X))return"text/html";if($.startsWith("<?xml"))return"application/xml";return null}function JZ(Q){if(Q.length===0)return"application/octet-stream";for(let Z of Q)if(Z<32&&Z!==9&&Z!==10&&Z!==12&&Z!==13&&Z!==27)return"application/octet-stream";try{return new TextDecoder("utf-8",{fatal:!0}).decode(Q,{stream:!0}),"text/plain"}catch{return"application/octet-stream"}}var WZ=new Set(["text/html","application/xhtml+xml","image/svg+xml","text/xml","application/xml","text/xsl","application/xslt+xml"]);function p0(Q){let Z=Q.split(";")[0].trim().toLowerCase();return WZ.has(Z)||Z.endsWith("+xml")}function d0(Q,Z){let $=Q.split(";")[0].trim().toLowerCase();return Z.some((X)=>{let G=X.split(";")[0].trim().toLowerCase();if(G==="*/*"||G==="*")return!p0($);if(G.endsWith("/*"))return $.startsWith(G.slice(0,-1))&&!p0($);return $===G})}import{Buffer as PZ}from"buffer";async function n0(Q){try{return(await import("sharp")).default}catch(Z){throw Error(`${Q} requires the 'sharp' package. Install it with \`bun add sharp\`.`,{cause:Z})}}async function l0(Q,Z,$={}){let{name:X,directory:G,bucket:Y,maxSize:K,timeout:J,contentTypes:H,signal:W}=$;if(X!==void 0&&G!==void 0)throw TypeError("Storage.putFromUrl(): pass `name` or `directory`, not both.");if(X!==void 0&&!X)throw TypeError("Storage.putFromUrl(): `name` is empty.");let z=await v0(Z,{...$.fetch,method:"GET",redirect:"follow",contentTypes:void 0,signal:W,timeout:J,maxSize:K});if(!z.ok)throw await z.body?.cancel().catch(()=>{}),new o1(z.url,z.status);let P=(z.body??new Response(new Uint8Array).body).getReader(),C=async(j)=>{throw await P.cancel(j).catch(()=>{}),j},U=[],D=0,V=!1;while(D<t1){let{done:j,value:q}=await P.read();if(j){V=!0;break}U.push(q),D+=q.byteLength}let B=zZ(U,D),M=c0(B.subarray(0,Math.min(D,t1))),R=H?.length?H:["*/*"];if(!d0(M,R))await C(new V1(z.url,M,R));let I=X??[(G??"").replace(/\/+$/,""),`${Bun.randomUUIDv7()}.${u0(M)}`].filter(Boolean).join("/"),A=D,N=new ReadableStream({start(j){if(D>0)j.enqueue(B);if(V)j.close()},async pull(j){let{done:q,value:T}=await P.read();if(q){j.close();return}A+=T.byteLength,j.enqueue(T)},cancel(j){return P.cancel(j)}}),L={name:I,bucket:Y,body:N,contentType:M},_;try{_=Q.putStream?await Q.putStream(L,{signal:W}):await H1.prototype.putStream.call(Q,L,{signal:W})}catch(j){throw await C(j),j}return{name:_,contentType:M,size:A,url:z.url}}function zZ(Q,Z){if(Q.length===1)return Q[0];let $=new Uint8Array(Z),X=0;for(let G of Q)$.set(G,X),X+=G.byteLength;return $}class MZ extends K1{static getFacadeAccessor(){return l1}static async put(Q,Z={}){return this.getFacadeRoot().driver.put(Q,Z)}static async putFromUrl(Q,Z={}){return l0(this.getFacadeRoot().driver,Q,Z)}static async metadata(Q){let Z=PZ.from(await Q.arrayBuffer()),$=await n0("Storage.metadata()");try{return await $(Z).metadata()}catch{return{}}}static async fetch(Q,Z={}){Z.signal?.throwIfAborted();let $=this.getFacadeRoot();return k0($.driver,Q,Z,{fetchTimeoutMs:$.fetchTimeoutMs??v,fetchIdleTimeoutMs:$.fetchIdleTimeoutMs??v})}static async read(Q,Z={}){let $=typeof Q==="string"?{name:Q}:{...Q},X="range"in Z?Z.range??null:$.range!==void 0?$.range:b.getStore()?.rangeRequest??null;return this.getFacadeRoot().driver.read({...$,range:X})}static list(Q){return this.getFacadeRoot().driver.list(Q)}static objects(Q,Z={}){return this.getFacadeRoot().driver.objects(Q,Z)}static async deletePrefix(Q,Z={}){return this.getFacadeRoot().driver.deletePrefix(Q,Z)}static async delete(Q){return this.getFacadeRoot().driver.delete(Q)}}var i0=["cookie","set-cookie","authorization","proxy-authorization","x-api-key"];function V$(Q){return Q}function z$(){let Q=Bun.env.NODE_ENV==="development";return{maxFileSize:10485760,console:Q,consoleFormat:Q?"text":"json",requestFields:[],redactHeaders:[],onLogFileClosed:()=>{},onLogCreated:()=>{}}}import{mkdir as r1,readdir as RZ,access as jZ}from"fs/promises";var a1=["debug","info","notice","warning","error","critical","alert","emergency"],UZ=a1.indexOf("warning");function s0(Q){if(!Q)return-1;if(Q===!0)return 0;let Z=a1.indexOf(Q);return Z===-1?0:Z}function BZ(){let Q=new WeakSet;return function(Z,$){if(typeof $==="bigint")return $.toString();if($ instanceof Error){let X={name:$.name,message:$.message,stack:$.stack};for(let G of Object.keys($))X[G]=$[G];if($.cause!==void 0)X.cause=$.cause;return X}if($!==null&&typeof $==="object"){if(Q.has($))return"[Circular]";Q.add($)}return $}}function o0(Q){try{return JSON.stringify(Q,BZ())}catch{return'"[Unserializable]"'}}function DZ(Q,Z){if(Z==="json")return o0({...Q.metadata,timestamp:Q.timestamp,level:Q.level,message:Q.message});let $=Object.keys(Q.metadata).length>0;return`${Q.timestamp} ${Q.level.toUpperCase()} ${Q.message}${$?` ${o0(Q.metadata)}`:""}`}function t0(Q,Z){let $=a1.indexOf(Q.level);if(Z.threshold===-1||$<Z.threshold)return;try{let X=DZ(Q,Z.format)+`
|
|
5
|
-
`;if($>=UZ)process.stderr.write(X);else process.stdout.write(X)}catch{}}async function e1(Q){try{return await jZ(Q),!0}catch{return!1}}class Q0{config;static token="log";writer;isReady=!1;flushTimeout;fileSize=0;writerSize=0;isCreatingFile=!1;bootPromise=null;currentLogFilePath;get logsDirPath(){return`${W1()}/storage/logs`}consoleThreshold;redactedHeaders;constructor(Q){this.config=Q;this.consoleThreshold=s0(Q.console),this.redactedHeaders=new Set([...i0,...Q.redactHeaders??[]].map((Z)=>Z.toLowerCase()))}requestMetadata(Q){let Z=new URL(Q.url),$={method:Q.method,path:Z.pathname,userAgent:Q.headers.get("user-agent")??void 0},X=Q.headers.get("x-request-id");if(X)$.requestId=X;let G=this.config.requestFields??[];if(G.includes("url"))$.url=Q.url;if(G.includes("headers")){let Y={};Q.headers.forEach((K,J)=>{Y[J]=this.redactedHeaders.has(J)?"[redacted]":K}),$.headers=Y}return $}boot(){if(!this.bootPromise)this.bootPromise=this.createStorage().catch((Q)=>{console.error("Log storage unavailable, file logging disabled",Q)}).then(()=>{this.isReady=!0});return this.bootPromise}async createStorage(){let Q=`${W1()}/storage`;if(!await e1(Q))await r1(Q);if(!await e1(this.logsDirPath))await r1(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await e1(this.logsDirPath))await r1(this.logsDirPath);if(this.isCreatingFile=!0,this.currentLogFilePath){this.writer.flush(),this.writer.end(),this.writer=null;let $=new File([await Bun.file(this.currentLogFilePath).arrayBuffer()],this.currentLogFilePath.split("/").pop(),{type:"text/plain"});this.config.onLogFileClosed($),this.fileSize=0,this.writerSize=0}let Z=(await RZ(this.logsDirPath)).sort().reverse()[0];if(Z){let $=Bun.file(`${this.logsDirPath}/${Z}`);if($.size<this.config.maxFileSize)this.currentLogFilePath=`${this.logsDirPath}/${Z}`,this.writer=$.writer(),this.writer.write(await $.text()),this.writer.write(`
|
|
6
|
-
`),this.writer.flush(),this.fileSize=$.size}if(!this.writer){let $=`${new Date(Date.now()).toISOString()}.log`.replaceAll(":","-");this.currentLogFilePath=`${this.logsDirPath}/${$}`;let X=Bun.file(`${this.logsDirPath}/${$}`);this.writer=X.writer(),this.fileSize=0,this.writerSize=0}this.isCreatingFile=!1}async log(Q,Z,$={}){if(!this.isReady)await this.boot();let X=b.getStore(),G={},Y={};if(X)Y={method:X.req.rawRequest.method,path:new URL(X.req.rawRequest.url).pathname},G=this.requestMetadata(X.req.rawRequest);let K={timestamp:new Date(Date.now()).toISOString(),env:Bun.env.NODE_ENV,level:Q,message:Z,metadata:{...G,...$}};if(this.consoleThreshold!==-1)t0({timestamp:K.timestamp,level:Q,message:Z,metadata:{...Y,...$}},{threshold:this.consoleThreshold,format:this.config.consoleFormat});let J="";try{J=JSON.stringify(K)}catch(H){console.log("Error parsing log object",H)}try{let H=this.config.onLogCreated(K);if(H instanceof Promise)H.catch((W)=>console.error("Error in onLogCreated",W))}catch(H){console.error("Error in onLogCreated",H)}if(!this.writer)return;this.writerSize+=J.length,this.fileSize+=J.length;try{this.writer.write(J),this.writer.write(`
|
|
7
|
-
`),this.tryFlush()}catch(H){console.error("Error writing log",H)}}async tryFlush(){if(this.fileSize>this.config.maxFileSize){if(!this.isCreatingFile)await this.newLogFile()}if(this.writerSize>this.config.maxFileSize/2)await this.writer.flush(),this.writerSize=0,await this.newLogFile();else clearTimeout(this.flushTimeout),this.flushTimeout=setTimeout(async()=>{await this.writer.flush(),this.writerSize=0},100)}}class CZ extends K1{static getFacadeAccessor(){return Q0}static debug(Q,Z){this.getFacadeRoot().log("debug",Q,Z)}static info(Q,Z){this.getFacadeRoot().log("info",Q,Z)}static notice(Q,Z){this.getFacadeRoot().log("notice",Q,Z)}static warning(Q,Z){this.getFacadeRoot().log("warning",Q,Z)}static error(Q,Z){this.getFacadeRoot().log("error",Q,Z)}static critical(Q,Z){this.getFacadeRoot().log("critical",Q,Z)}static alert(Q,Z){this.getFacadeRoot().log("alert",Q,Z)}static emergency(Q,Z){this.getFacadeRoot().log("emergency",Q,Z)}}class _Z{config;static token="redis";instance=null;connectingSince=null;downSince=null;replaceDelay=500;constructor(Q={}){this.config=Q}get client(){if(this.instance===null)return this.build();let Q=this.instance;if(this.isDown(Q,Date.now())){this.instance=null;try{Q.close()}catch{}return this.build()}return Q}set client(Q){this.instance=Q,this.connectingSince=null,this.downSince=null,this.replaceDelay=500}close(){let Q=this.instance;this.instance=null,this.connectingSince=null,this.downSince=null,this.replaceDelay=500,Q?.close()}build(){let Q=new(OZ())(this.config.url,this.config.options);if(this.instance=Q,this.downSince=null,this.connectingSince=null,typeof Q.connect==="function"){this.connectingSince=Date.now();let Z;try{Z=Promise.resolve(Q.connect())}catch($){Z=Promise.reject($)}Z.then(()=>{if(this.instance!==Q)return;this.connectingSince=null,this.replaceDelay=500},()=>{if(this.instance!==Q)return;this.connectingSince=null})}return Q}isDown(Q,Z){if(Q.connected!==!1||typeof Q.connect!=="function")return this.downSince=null,!1;if(this.connectingSince!==null){let $=(this.config.options?.connectionTimeout??1e4)+5000;if(Z-this.connectingSince<$)return!1;this.connectingSince=null}if(this.downSince??=Z,Z-this.downSince<this.replaceDelay)return!1;return this.replaceDelay=Math.min(this.replaceDelay*2,1e4),!0}}function OZ(){let Q=globalThis.Bun?.RedisClient;if(typeof Q!=="function")throw Error("Redis requires Bun's built-in Redis client, which this runtime does not provide. Run the app under Bun, or bind your own client for the 'redis' token.");return Q}var Z0=new TextEncoder;function a0(Q){return`id: ${Q.seq}
|
|
8
|
-
data: ${JSON.stringify(Q.event)}
|
|
9
|
-
|
|
10
|
-
`}var LZ=5000,IZ=`: keepalive
|
|
11
|
-
|
|
12
|
-
`;function AZ(Q,Z=LZ){let $=null,X=!1,G=()=>{if(X)return;if($!==null)clearTimeout($);$=setTimeout(()=>{if($=null,X)return;try{Q.enqueue(Z0.encode(IZ))}catch{Y();return}G()},Z)},Y=()=>{if(X=!0,$!==null)clearTimeout($);$=null};return G(),{touch:G,stop:Y}}function NZ(){return{"Content-Type":"text/event-stream","Cache-Control":"no-store, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}}function A$(Q,Z=200){let $=Q[Symbol.asyncIterator](),X=-1,G,Y=new ReadableStream({start(K){G=AZ(K)},async pull(K){try{let J=await $.next();if(J.done){G.stop(),K.close();return}X=J.value.seq,K.enqueue(Z0.encode(a0(J.value))),G.touch()}catch(J){let H={type:"error",error:TZ(J)};G.stop(),K.enqueue(Z0.encode(a0({seq:X+1,event:H}))),K.close()}},cancel(K){G.stop(),$.return?.(K)}});return new Response(Y,{status:Z,headers:NZ()})}var FZ=new Set(["frame_cursor_evicted","live_run_not_found"]);function TZ(Q){let Z=Q&&typeof Q==="object"?Q.code:void 0;if(Q instanceof Error&&typeof Z==="string"&&FZ.has(Z))return{code:"unknown",message:Q.message,retryable:!1};return console.error("[gemi/ai] agent stream failed",Q),{code:"unknown",message:"The run's stream failed.",retryable:!1}}
|
|
13
|
-
export{$0 as Nh,r0 as Oh,qZ as Ph,j0 as Qh,sZ as Rh,O0 as Sh,tZ as Th,X0 as Uh,G0 as Vh,EZ as Wh,xZ as Xh,kZ as Yh,Y0 as Zh,rZ as _h,A0 as $h,eZ as ai,Q8 as bi,e as ci,k as di,g1 as ei,hZ as fi,mZ as gi,pZ as hi,cZ as ii,uZ as ji,v1 as ki,R0 as li,nZ as mi,lZ as ni,OQ as oi,w0 as pi,LQ as qi,p1 as ri,c1 as si,IQ as ti,m as ui,AQ as vi,K1 as wi,n0 as xi,N1 as yi,H1 as zi,q0 as Ai,n1 as Bi,f8 as Ci,E0 as Di,l1 as Ei,x0 as Fi,w as Gi,p as Hi,F1 as Ii,s as Ji,T1 as Ki,w1 as Li,q1 as Mi,V1 as Ni,i1 as Oi,t as Pi,o1 as Qi,z1 as Ri,S1 as Si,s1 as Ti,v0 as Ui,c0 as Vi,p0 as Wi,MZ as Xi,V$ as Yi,z$ as Zi,Q0 as _i,CZ as $i,_Z as aj,a0 as bj,IZ as cj,AZ as dj,NZ as ej,A$ as fj};
|
|
14
|
-
|
|
15
|
-
//# debugId=B8786C2D425654B164756E2164756E21
|
package/dist/chunk-tgbky7fc.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{ke as o}from"./chunk-2z160r1b.js";import{le as i}from"./chunk-vqq0z746.js";import{tk as t}from"./chunk-ng5qfkgp.js";import{tl as r}from"./chunk-yzazktke.js";class n extends i{register(){this.app.singleton(r,()=>new r(t(o(),this.app.config.get("translation",{}))))}}
|
|
3
|
-
export{n as bb};
|
|
4
|
-
|
|
5
|
-
//# debugId=E491C1602B8BE0A264756E2164756E21
|