@qitqode/qitqode-android-arm64 0.1.29 → 0.1.30
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/bundle/{chunk-fj7kd4gc.js → chunk-04tw0r4s.js} +1 -1
- package/bundle/{chunk-sbx9z70j.js → chunk-07g7cybt.js} +1 -1
- package/bundle/chunk-07ws99b1.js +2 -0
- package/bundle/chunk-09c4ngag.js +2 -0
- package/bundle/{chunk-j2zay4da.js → chunk-09kba1hg.js} +2 -2
- package/bundle/{chunk-dd3m74rc.js → chunk-0ch32p4c.js} +1 -1
- package/bundle/{chunk-2p2ch1k2.js → chunk-0df4kede.js} +1 -1
- package/bundle/{chunk-f29n7826.js → chunk-0fmbz83g.js} +1 -1
- package/bundle/{chunk-gd5stg49.js → chunk-0jgsp4c2.js} +1 -1
- package/bundle/chunk-0jgst767.js +2 -0
- package/bundle/chunk-0psrr9vp.js +2 -0
- package/bundle/{chunk-hn1f6rne.js → chunk-12bssxd4.js} +2 -2
- package/bundle/{chunk-a2qerqgd.js → chunk-1bhvt33f.js} +1 -1
- package/bundle/{chunk-3rt2k5sc.js → chunk-1dwcga8g.js} +1 -1
- package/bundle/{chunk-xn5v8wgh.js → chunk-1fbeendk.js} +1 -1
- package/bundle/chunk-1j73cnvz.js +2 -0
- package/bundle/{chunk-tqsx2m1j.js → chunk-1ngtxja9.js} +1 -1
- package/bundle/{chunk-p7h2qd7z.js → chunk-1qshjfzm.js} +1 -1
- package/bundle/{chunk-0626rvy2.js → chunk-1rp1cvmc.js} +1 -1
- package/bundle/{chunk-csdm3n24.js → chunk-1sgby720.js} +1 -1
- package/bundle/{chunk-6hmj972a.js → chunk-1t9jne14.js} +1 -1
- package/bundle/chunk-1yddn03z.js +2 -0
- package/bundle/{chunk-74zgcxeg.js → chunk-26nfphsg.js} +1 -1
- package/bundle/{chunk-71pmrpkc.js → chunk-27dgtm8r.js} +1 -1
- package/bundle/{chunk-n3t52cz2.js → chunk-27yxgy03.js} +1 -1
- package/bundle/{chunk-2hw0jzv4.js → chunk-2ahqhh4z.js} +1 -1
- package/bundle/{chunk-z5yrvg40.js → chunk-2bn4b42t.js} +1 -1
- package/bundle/{chunk-9kjj44cr.js → chunk-2dzk5txw.js} +1 -1
- package/bundle/chunk-2ec6ps8r.js +5 -0
- package/bundle/{chunk-q5363rr9.js → chunk-2gerf08b.js} +2 -2
- package/bundle/{chunk-2mjc44ev.js → chunk-2jmxt3fb.js} +1 -1
- package/bundle/{chunk-7926bzm7.js → chunk-2km50rd3.js} +1 -1
- package/bundle/{chunk-rptvpa1v.js → chunk-2q96x1t5.js} +1 -1
- package/bundle/{chunk-pg8dz1rq.js → chunk-2rs39vj2.js} +1 -1
- package/bundle/{chunk-3n49y4kh.js → chunk-2tnarng3.js} +1 -1
- package/bundle/{chunk-z160s5p5.js → chunk-2vepzgek.js} +1 -1
- package/bundle/{chunk-b9hstp7h.js → chunk-2y90ad1v.js} +1 -1
- package/bundle/{chunk-ed723mw1.js → chunk-371r2111.js} +1 -1
- package/bundle/{chunk-g06rv5fq.js → chunk-37n34pzd.js} +1 -1
- package/bundle/chunk-38g8yzw0.js +2 -0
- package/bundle/chunk-3bkd0ar3.js +2 -0
- package/bundle/{chunk-9atkgkaq.js → chunk-3bmzjznz.js} +1 -1
- package/bundle/chunk-3f4zht9e.js +2 -0
- package/bundle/{chunk-0yqbyres.js → chunk-3g1yz39h.js} +1 -1
- package/bundle/{chunk-k095hd3c.js → chunk-3n1324bt.js} +1 -1
- package/bundle/{chunk-ef2b07fm.js → chunk-3nwve06r.js} +1 -1
- package/bundle/{chunk-cev2qj7w.js → chunk-3nyqh1d6.js} +1 -1
- package/bundle/{chunk-p5360c2q.js → chunk-3pxnp6jb.js} +1 -1
- package/bundle/{chunk-94qmhz2p.js → chunk-3szwfy7w.js} +2 -2
- package/bundle/chunk-426dt7be.js +2 -0
- package/bundle/{chunk-6jewfaqa.js → chunk-42f7p0hq.js} +2 -2
- package/bundle/chunk-4amgp4yd.js +3 -0
- package/bundle/{chunk-3vmh2ge6.js → chunk-4p5e5tsz.js} +1 -1
- package/bundle/{chunk-nfzmvy30.js → chunk-4pjm21a5.js} +1 -1
- package/bundle/{chunk-6hdjkvr1.js → chunk-4qqkqrn9.js} +2 -2
- package/bundle/chunk-4sz3jbc5.js +2 -0
- package/bundle/{chunk-bsf6n350.js → chunk-4tbwha3m.js} +2 -2
- package/bundle/{chunk-qtsmgjk7.js → chunk-4xh1qm90.js} +1 -1
- package/bundle/{chunk-t3q7qakr.js → chunk-58x5seqn.js} +1 -1
- package/bundle/{chunk-thk93j3e.js → chunk-5a5t01ka.js} +1 -1
- package/bundle/{chunk-hhgjbag9.js → chunk-5fgx6fa4.js} +1 -1
- package/bundle/{chunk-n86s4fw4.js → chunk-5fz8tph5.js} +1 -1
- package/bundle/{chunk-n5sh2790.js → chunk-5qam3c8r.js} +1 -1
- package/bundle/{chunk-45jqjyk9.js → chunk-5v4py9p2.js} +1 -1
- package/bundle/{chunk-z44m19vm.js → chunk-5xe6x2rt.js} +1 -1
- package/bundle/chunk-618tmyx9.js +2 -0
- package/bundle/{chunk-zasd8cz8.js → chunk-61c62e5s.js} +1 -1
- package/bundle/chunk-6d9wsjxm.js +2 -0
- package/bundle/{chunk-zqxmr01r.js → chunk-6fp8a9ek.js} +1 -1
- package/bundle/{chunk-ndmrg80b.js → chunk-6hv59ere.js} +1 -1
- package/bundle/{chunk-yaj9ywvz.js → chunk-6nbzdb0r.js} +1 -1
- package/bundle/{chunk-k7dcfqjs.js → chunk-6qy1ghrx.js} +1 -1
- package/bundle/chunk-730a2d1k.js +2 -0
- package/bundle/{chunk-gf5pwww1.js → chunk-76wrw0cs.js} +1 -1
- package/bundle/chunk-7bd0x9vf.js +2 -0
- package/bundle/chunk-7czkntef.js +2 -0
- package/bundle/chunk-7ex57nyh.js +2 -0
- package/bundle/chunk-7gpczxbh.js +2 -0
- package/bundle/chunk-7j0bgeh2.js +2 -0
- package/bundle/{chunk-cfxjwfn4.js → chunk-7jbz3dgt.js} +1 -1
- package/bundle/{chunk-cjfgs1x8.js → chunk-7ppd2phw.js} +1 -1
- package/bundle/chunk-7py443fe.js +2 -0
- package/bundle/{chunk-v7deh7aj.js → chunk-7yrhe3xq.js} +1 -1
- package/bundle/{chunk-xhncwg5v.js → chunk-89q1y7tc.js} +1 -1
- package/bundle/{chunk-yn576pje.js → chunk-89v6dgpp.js} +2 -2
- package/bundle/chunk-8qkhddq3.js +8 -0
- package/bundle/chunk-90q5sae0.js +2 -0
- package/bundle/chunk-9amwe0ed.js +2 -0
- package/bundle/chunk-9grvepmd.js +2 -0
- package/bundle/chunk-9hrh15p2.js +2 -0
- package/bundle/{chunk-azx0zxnx.js → chunk-9j1qqdr2.js} +1 -1
- package/bundle/{chunk-s2za1n7h.js → chunk-a0v55ywn.js} +2 -2
- package/bundle/{chunk-a8p9aggx.js → chunk-a1p2f16h.js} +2 -2
- package/bundle/{chunk-8f0g7d7k.js → chunk-a1pw9r6f.js} +1 -1
- package/bundle/{chunk-95qs7wnz.js → chunk-a2qz9m10.js} +1 -1
- package/bundle/{chunk-az9hsk6z.js → chunk-ab6cabxh.js} +1 -1
- package/bundle/chunk-av6ezvxm.js +2 -0
- package/bundle/{chunk-yjj4cvqg.js → chunk-aztre27e.js} +1 -1
- package/bundle/{chunk-b4qd109w.js → chunk-b0syck9r.js} +1 -1
- package/bundle/{chunk-hevb7k95.js → chunk-b3dqcbsc.js} +1 -1
- package/bundle/{chunk-pq2prhb2.js → chunk-b3rpzkcb.js} +1 -1
- package/bundle/{chunk-tsb9g1nz.js → chunk-b8bytvka.js} +1 -1
- package/bundle/{chunk-awav98j0.js → chunk-b8tw709r.js} +1 -1
- package/bundle/{chunk-6528bthc.js → chunk-b9za12y1.js} +1 -1
- package/bundle/{chunk-fsy279s5.js → chunk-be216spx.js} +2 -2
- package/bundle/chunk-beksar7w.js +2 -0
- package/bundle/chunk-bg66rqrx.js +2 -0
- package/bundle/{chunk-a94s0jks.js → chunk-bn15mzd7.js} +1 -1
- package/bundle/{chunk-z29fwg61.js → chunk-bpbptx89.js} +1 -1
- package/bundle/{chunk-qzjpea91.js → chunk-bss414qz.js} +1 -1
- package/bundle/chunk-bt6yw07v.js +2 -0
- package/bundle/{chunk-d0qqgxs4.js → chunk-btz9jvec.js} +1 -1
- package/bundle/{chunk-ypthfv6d.js → chunk-bvkq0a5q.js} +1 -1
- package/bundle/{chunk-bx6kyvg7.js → chunk-c01z3cvg.js} +1 -1
- package/bundle/{chunk-s6me101a.js → chunk-c5e6sk9c.js} +1 -1
- package/bundle/{chunk-yn05n0az.js → chunk-cafzcmrg.js} +2 -2
- package/bundle/{chunk-2xxefrps.js → chunk-cdhmc0t0.js} +1 -1
- package/bundle/{chunk-qredfmch.js → chunk-chmrvbbj.js} +1 -1
- package/bundle/{chunk-b1ntb3dh.js → chunk-ct48575c.js} +1 -1
- package/bundle/{chunk-yp3dj4wh.js → chunk-cvdxgsq1.js} +1 -1
- package/bundle/chunk-cy9s1ma5.js +2 -0
- package/bundle/chunk-d0nkvp57.js +2 -0
- package/bundle/{chunk-abtn6nec.js → chunk-d5bxan80.js} +1 -1
- package/bundle/{chunk-5n4hpc4f.js → chunk-d6r4xwtg.js} +3 -3
- package/bundle/{chunk-xk1nh1ay.js → chunk-dcvatax2.js} +2 -2
- package/bundle/{chunk-m2ny1en7.js → chunk-ddnpx1yx.js} +4 -4
- package/bundle/{chunk-qzcfjz9g.js → chunk-dfnv7vkn.js} +1 -1
- package/bundle/{chunk-18vygvnc.js → chunk-dhjp0zx2.js} +1 -1
- package/bundle/{chunk-sv48x9h8.js → chunk-dq9kpj4a.js} +1 -1
- package/bundle/{chunk-88dhcv37.js → chunk-drs1gv2b.js} +1 -1
- package/bundle/{chunk-geccvf9d.js → chunk-ds69qc8b.js} +1 -1
- package/bundle/chunk-dvk2wwjj.js +2 -0
- package/bundle/chunk-dxe29jj6.js +2 -0
- package/bundle/chunk-e0jy9qxd.js +2 -0
- package/bundle/{chunk-fhdpp77n.js → chunk-eb9mytjq.js} +1 -1
- package/bundle/{chunk-c19t7e8s.js → chunk-ecn8gbtz.js} +1 -1
- package/bundle/chunk-eercqt72.js +2 -0
- package/bundle/{chunk-8jzjvmaz.js → chunk-efxd6b2k.js} +1 -1
- package/bundle/{chunk-hd2kb05a.js → chunk-ejjea8hh.js} +1 -1
- package/bundle/chunk-eneawsj8.js +2 -0
- package/bundle/{chunk-v9xnk9pz.js → chunk-ezja6njs.js} +1 -1
- package/bundle/{chunk-8kz3n8ye.js → chunk-f45tp3e3.js} +1 -1
- package/bundle/chunk-f72pppr7.js +2 -0
- package/bundle/chunk-feyphhxd.js +2 -0
- package/bundle/{chunk-2w20mhch.js → chunk-fjgyrsbw.js} +1 -1
- package/bundle/{chunk-v00cptj6.js → chunk-fkgv2hqd.js} +1 -1
- package/bundle/{chunk-8d2ddmf0.js → chunk-fnbpap62.js} +1 -1
- package/bundle/chunk-fnnch1e9.js +2 -0
- package/bundle/{chunk-7wthn44y.js → chunk-fqw4y7x0.js} +2 -2
- package/bundle/{chunk-yk8kk25c.js → chunk-ft93f33g.js} +1 -1
- package/bundle/{chunk-3q6650we.js → chunk-g1dwbvkg.js} +1 -1
- package/bundle/{chunk-mb4wvwfw.js → chunk-g3dhsmbt.js} +3 -3
- package/bundle/{chunk-1xw68zak.js → chunk-g7rjtehn.js} +1 -1
- package/bundle/{chunk-q0xzbad1.js → chunk-gf0pdgjs.js} +1 -1
- package/bundle/{chunk-gd45tjbd.js → chunk-ggqst87g.js} +1 -1
- package/bundle/{chunk-n34y5gp6.js → chunk-gj3hzx3d.js} +2 -2
- package/bundle/chunk-gk34kh8p.js +2 -0
- package/bundle/{chunk-pycjksh4.js → chunk-gm85xefs.js} +1 -1
- package/bundle/chunk-gn50xqbd.js +2 -0
- package/bundle/{chunk-89f8v2y8.js → chunk-h0rpmne5.js} +1 -1
- package/bundle/chunk-h6rv626m.js +2 -0
- package/bundle/chunk-h7s2w1e2.js +2 -0
- package/bundle/{chunk-yyqrbv2f.js → chunk-h9pvnp5c.js} +1 -1
- package/bundle/{chunk-hpfqnjfz.js → chunk-hj5y7fvk.js} +1 -1
- package/bundle/chunk-hmv2cdnz.js +2 -0
- package/bundle/chunk-ht81ensf.js +2 -0
- package/bundle/{chunk-44jpsp97.js → chunk-hw1dmx28.js} +1 -1
- package/bundle/{chunk-43ae3chd.js → chunk-hwbyqezq.js} +2 -2
- package/bundle/{chunk-97h0jx8y.js → chunk-hxpgs78j.js} +1 -1
- package/bundle/{chunk-yj73ehjd.js → chunk-hxz2rdjq.js} +1 -1
- package/bundle/chunk-j59ktwny.js +2 -0
- package/bundle/{chunk-cd867geb.js → chunk-j5kb0y1m.js} +1 -1
- package/bundle/{chunk-1rn0vmvv.js → chunk-j6emx6jn.js} +2 -2
- package/bundle/{chunk-ekndhwnn.js → chunk-j9pcnkkq.js} +2 -2
- package/bundle/{chunk-2p9py4rw.js → chunk-jje0srjq.js} +1 -1
- package/bundle/{chunk-kkae8ead.js → chunk-jm1ptn8n.js} +1 -1
- package/bundle/chunk-jmz2mq3t.js +2 -0
- package/bundle/{chunk-11d987sj.js → chunk-jvqbvgjy.js} +1 -1
- package/bundle/chunk-k309zez0.js +3 -0
- package/bundle/chunk-k3fn3yed.js +2 -0
- package/bundle/{chunk-1fz0383p.js → chunk-k7gq9bra.js} +1 -1
- package/bundle/{chunk-eqcd9k9p.js → chunk-k8ss3135.js} +130 -130
- package/bundle/{chunk-4fk4se02.js → chunk-kfsb2stm.js} +1 -1
- package/bundle/{chunk-b73s2h43.js → chunk-knpt9n8f.js} +1 -1
- package/bundle/chunk-kpw6nghv.js +2 -0
- package/bundle/{chunk-81h5f8ev.js → chunk-kqn9h2gk.js} +1 -1
- package/bundle/{chunk-jwtev7b7.js → chunk-m02zt1a3.js} +2 -2
- package/bundle/{chunk-ktqrbbkh.js → chunk-m1h5a4vg.js} +1 -1
- package/bundle/chunk-m5ghbt5y.js +2 -0
- package/bundle/{chunk-4vze3djr.js → chunk-m612agnk.js} +1 -1
- package/bundle/{chunk-hbtd620x.js → chunk-m67tcnk4.js} +1 -1
- package/bundle/{chunk-6bsgrr5h.js → chunk-mgk9sh16.js} +1 -1
- package/bundle/{chunk-wnwesaap.js → chunk-mj4bepvj.js} +1 -1
- package/bundle/{chunk-t3tkp1em.js → chunk-mk6cddvd.js} +1 -1
- package/bundle/chunk-mn41f9qv.js +2 -0
- package/bundle/chunk-mqjf9sbm.js +2 -0
- package/bundle/{chunk-r4mnbhe1.js → chunk-mrw279k3.js} +1 -1
- package/bundle/{chunk-qje3683x.js → chunk-msegx0t7.js} +1 -1
- package/bundle/{chunk-x6nbck7p.js → chunk-mskwkcgj.js} +1 -1
- package/bundle/{chunk-ce5t444d.js → chunk-my6sz5d6.js} +1 -1
- package/bundle/{chunk-scqxmv8k.js → chunk-n26yf3he.js} +1 -1
- package/bundle/chunk-n5gwrrbb.js +2 -0
- package/bundle/{chunk-6scqd8fh.js → chunk-n8h6x2en.js} +1 -1
- package/bundle/chunk-nfjhem1c.js +2 -0
- package/bundle/{chunk-h8chkene.js → chunk-ngchsw2g.js} +1 -1
- package/bundle/{chunk-rf524gez.js → chunk-ngytjdg2.js} +1 -1
- package/bundle/chunk-nj4d554m.js +11 -0
- package/bundle/chunk-nrc3bj9p.js +2 -0
- package/bundle/{chunk-0xm85ayc.js → chunk-nt4e3em9.js} +1 -1
- package/bundle/chunk-nxyyn2ra.js +2 -0
- package/bundle/{chunk-t35n89t9.js → chunk-nzehfpxp.js} +1 -1
- package/bundle/chunk-p5tceb4k.js +2 -0
- package/bundle/{chunk-js9wdh67.js → chunk-p68rwmhc.js} +1 -1
- package/bundle/{chunk-g0mbbysk.js → chunk-pekm54ce.js} +1 -1
- package/bundle/{chunk-yvqbewmc.js → chunk-phxrg7aw.js} +2 -2
- package/bundle/{chunk-3h4y7n1a.js → chunk-ppfjf7qx.js} +1 -1
- package/bundle/{chunk-d7t0bcvk.js → chunk-pvpy9kq1.js} +6 -6
- package/bundle/{chunk-k16s2dnx.js → chunk-q1v2pytx.js} +1 -1
- package/bundle/{chunk-svrxk3vf.js → chunk-q6ztpfcs.js} +2 -2
- package/bundle/{chunk-8k55xz7z.js → chunk-qhc90p4a.js} +1 -1
- package/bundle/chunk-qjgm3e2p.js +2 -0
- package/bundle/{chunk-4mrz9b6d.js → chunk-qjjch1zt.js} +2 -2
- package/bundle/{chunk-b20xjnpw.js → chunk-qjn86fc0.js} +1 -1
- package/bundle/{chunk-9epjgend.js → chunk-qrey2gwb.js} +2 -2
- package/bundle/chunk-qt80mhdn.js +2 -0
- package/bundle/chunk-qtw5nrr4.js +2 -0
- package/bundle/{chunk-xk7je9y8.js → chunk-qv2s39dv.js} +1 -1
- package/bundle/chunk-rc9ex3vt.js +2 -0
- package/bundle/{chunk-xn61fgrh.js → chunk-s07j8hfy.js} +1 -1
- package/bundle/{chunk-y212x7ws.js → chunk-s3yna2wm.js} +1 -1
- package/bundle/chunk-s9672vvv.js +2 -0
- package/bundle/chunk-sbyey0qb.js +2 -0
- package/bundle/{chunk-ps6jk326.js → chunk-scnz207s.js} +1 -1
- package/bundle/{chunk-k20nrwbg.js → chunk-sermjas1.js} +1 -1
- package/bundle/chunk-shpq6es1.js +3 -0
- package/bundle/chunk-sj5v361q.js +2 -0
- package/bundle/{chunk-qsszerj7.js → chunk-sn4nez18.js} +2 -2
- package/bundle/{chunk-t299e2aw.js → chunk-snm5q21k.js} +2 -2
- package/bundle/{chunk-yt2k9ga8.js → chunk-srh4xvsj.js} +1 -1
- package/bundle/{chunk-a2g69pv6.js → chunk-svvgv1s0.js} +1 -1
- package/bundle/{chunk-n4gjpgnk.js → chunk-szr0f7k2.js} +1 -1
- package/bundle/{chunk-4vemws1t.js → chunk-t12xrrfr.js} +2 -2
- package/bundle/chunk-ta3k9syc.js +2 -0
- package/bundle/{chunk-d86ma6zk.js → chunk-tj78jsp9.js} +1 -1
- package/bundle/chunk-tk5afan4.js +2 -0
- package/bundle/chunk-tpndnprb.js +2 -0
- package/bundle/{chunk-jkm54mha.js → chunk-tr8sf0dk.js} +1 -1
- package/bundle/{chunk-hgbkg85g.js → chunk-v2zp22r3.js} +1 -1
- package/bundle/{chunk-jntqzhxr.js → chunk-v4xcysh0.js} +1 -1
- package/bundle/{chunk-19sa03c1.js → chunk-v965rsr8.js} +2 -2
- package/bundle/{chunk-2ztdqtnk.js → chunk-vcmrrt8b.js} +1 -1
- package/bundle/chunk-vcrn3v70.js +2 -0
- package/bundle/{chunk-b9nwaaqs.js → chunk-vg2fmyje.js} +2 -2
- package/bundle/{chunk-98vfbn0h.js → chunk-vj62pc0h.js} +1 -1
- package/bundle/{chunk-g3ch14a1.js → chunk-vn7nkrqb.js} +1 -1
- package/bundle/chunk-vwxfgea7.js +2 -0
- package/bundle/chunk-w0kgcz1t.js +2 -0
- package/bundle/{chunk-50w28xj1.js → chunk-w87a3mzm.js} +1 -1
- package/bundle/{chunk-09j71kp6.js → chunk-wfs4pcwa.js} +3 -3
- package/bundle/{chunk-zqjp7jdd.js → chunk-wgpsmxqx.js} +1 -1
- package/bundle/{chunk-kw09hbrb.js → chunk-whcg14sc.js} +1 -1
- package/bundle/{chunk-20d0cd1j.js → chunk-whxjkz9a.js} +2 -2
- package/bundle/chunk-wksczmes.js +2 -0
- package/bundle/{chunk-m6wceqay.js → chunk-wnqwb6fd.js} +1 -1
- package/bundle/{chunk-7mc8nxve.js → chunk-wpajh5s5.js} +1 -1
- package/bundle/chunk-wsxta33r.js +2 -0
- package/bundle/{chunk-byc7ev8p.js → chunk-wsy0m70r.js} +1 -1
- package/bundle/{chunk-csyw14fj.js → chunk-wy46mbwt.js} +1 -1
- package/bundle/{chunk-0wdtbn59.js → chunk-wz0zcddf.js} +2 -2
- package/bundle/{chunk-gjvymdhp.js → chunk-x067eetw.js} +1 -1
- package/bundle/{chunk-s1sepxdp.js → chunk-xc5044tm.js} +1 -1
- package/bundle/{chunk-tj00kzk4.js → chunk-xck0sq3k.js} +1 -1
- package/bundle/chunk-xjyhtm8r.js +2 -0
- package/bundle/{chunk-rs1698xs.js → chunk-xm08fc2q.js} +1 -1
- package/bundle/{chunk-bv8pf0m1.js → chunk-xpc2zgj7.js} +2 -2
- package/bundle/{chunk-nxn4arcf.js → chunk-xs3xtz6x.js} +1 -1
- package/bundle/{chunk-6saj1dhz.js → chunk-y062spw2.js} +1 -1
- package/bundle/{chunk-qk9vccja.js → chunk-y2v09y71.js} +1 -1
- package/bundle/{chunk-61yatzp8.js → chunk-ydp0q1hk.js} +1 -1
- package/bundle/{chunk-z4nay2ef.js → chunk-yfkvjphe.js} +1 -1
- package/bundle/chunk-ygc5qegv.js +2 -0
- package/bundle/chunk-yjqmzm51.js +2 -0
- package/bundle/{chunk-nv2r4cns.js → chunk-yjtdgcq5.js} +1 -1
- package/bundle/{chunk-5z7mjwwa.js → chunk-yn6sbycg.js} +1 -1
- package/bundle/{chunk-4fspp5fg.js → chunk-yp0a8q29.js} +3 -3
- package/bundle/{chunk-bzrsnv2k.js → chunk-yq3m8190.js} +2 -2
- package/bundle/{chunk-7m8fdp5p.js → chunk-yy526n9c.js} +1 -1
- package/bundle/chunk-yzc53n88.js +2 -0
- package/bundle/{chunk-j0znryc6.js → chunk-yzjc15vp.js} +1 -1
- package/bundle/chunk-z7y9pdj7.js +2 -0
- package/bundle/{chunk-rqgcz2zr.js → chunk-z8g819cz.js} +1 -1
- package/bundle/{chunk-4kpvceap.js → chunk-z8r65yw3.js} +1 -1
- package/bundle/{chunk-31wxbws4.js → chunk-zb0me4kk.js} +1 -1
- package/bundle/{chunk-asmfntjm.js → chunk-zcm2jdr5.js} +1 -1
- package/bundle/chunk-zt1nbwmm.js +2 -0
- package/bundle/{chunk-zbq60sw6.js → chunk-ztc3gm8y.js} +1 -1
- package/bundle/{chunk-v9bmpndq.js → chunk-zv6pjtz1.js} +1 -1
- package/bundle/{chunk-1d9f53sk.js → chunk-zyhdxggp.js} +2 -2
- package/bundle/{chunk-ma0m6kpj.js → chunk-zz36xg2n.js} +1 -1
- package/bundle/index.js +3 -3
- package/bundle/parser.worker.js +2 -2
- package/bundle/worker.js +1 -1
- package/package.json +1 -1
- package/bundle/chunk-07c1mvy1.js +0 -2
- package/bundle/chunk-0p7qcm51.js +0 -2
- package/bundle/chunk-0pmb7zzh.js +0 -2
- package/bundle/chunk-1s9ctg0d.js +0 -2
- package/bundle/chunk-2f9fn9xr.js +0 -2
- package/bundle/chunk-2fhcvfyg.js +0 -2
- package/bundle/chunk-3mfj0x4p.js +0 -2
- package/bundle/chunk-3shnje9k.js +0 -2
- package/bundle/chunk-3tz1qhpt.js +0 -2
- package/bundle/chunk-4dtbdycg.js +0 -2
- package/bundle/chunk-4pz8av2y.js +0 -2
- package/bundle/chunk-4r4xh8a6.js +0 -2
- package/bundle/chunk-5hpq59t1.js +0 -2
- package/bundle/chunk-5s90ehww.js +0 -2
- package/bundle/chunk-63kcg127.js +0 -2
- package/bundle/chunk-6fejrpht.js +0 -2
- package/bundle/chunk-6zzdw7q1.js +0 -2
- package/bundle/chunk-78m8rayq.js +0 -2
- package/bundle/chunk-7j6p5j2g.js +0 -2
- package/bundle/chunk-7tjd6ba1.js +0 -2
- package/bundle/chunk-8d8efdry.js +0 -2
- package/bundle/chunk-93jxndr8.js +0 -2
- package/bundle/chunk-99ve54r6.js +0 -2
- package/bundle/chunk-9ksaqyb2.js +0 -2
- package/bundle/chunk-9p7t748e.js +0 -2
- package/bundle/chunk-a69jgepp.js +0 -2
- package/bundle/chunk-ar310tc3.js +0 -2
- package/bundle/chunk-at03h9eq.js +0 -2
- package/bundle/chunk-ay9p70xx.js +0 -2
- package/bundle/chunk-b6dsv601.js +0 -3
- package/bundle/chunk-bajtytm5.js +0 -2
- package/bundle/chunk-bh8v3mfg.js +0 -2
- package/bundle/chunk-bn0h9dny.js +0 -10
- package/bundle/chunk-bp8sxnrm.js +0 -2
- package/bundle/chunk-bw5e8thn.js +0 -2
- package/bundle/chunk-c8ajbhv3.js +0 -2
- package/bundle/chunk-c8n72r2k.js +0 -8
- package/bundle/chunk-ccddzk10.js +0 -2
- package/bundle/chunk-ch8cx9jn.js +0 -2
- package/bundle/chunk-cm4jtnkg.js +0 -2
- package/bundle/chunk-cq7j5tv5.js +0 -2
- package/bundle/chunk-cttqh20d.js +0 -2
- package/bundle/chunk-cvvfa1jf.js +0 -2
- package/bundle/chunk-dfja6dj6.js +0 -5
- package/bundle/chunk-e3qtndrt.js +0 -2
- package/bundle/chunk-e8cac405.js +0 -2
- package/bundle/chunk-ez92ah9y.js +0 -2
- package/bundle/chunk-fazvedgy.js +0 -2
- package/bundle/chunk-gtzcm5sb.js +0 -2
- package/bundle/chunk-kfgn4apg.js +0 -2
- package/bundle/chunk-kzrw6h8t.js +0 -2
- package/bundle/chunk-mjrvj2cg.js +0 -2
- package/bundle/chunk-mpebdv59.js +0 -2
- package/bundle/chunk-n20v44zr.js +0 -2
- package/bundle/chunk-nksathh4.js +0 -2
- package/bundle/chunk-q14890p6.js +0 -2
- package/bundle/chunk-q4n02cwv.js +0 -2
- package/bundle/chunk-q7s17j1b.js +0 -2
- package/bundle/chunk-qm07wesh.js +0 -2
- package/bundle/chunk-qrrg9v3d.js +0 -2
- package/bundle/chunk-rdqgss38.js +0 -2
- package/bundle/chunk-rzc528ym.js +0 -2
- package/bundle/chunk-sbv96mj0.js +0 -3
- package/bundle/chunk-th78zcds.js +0 -2
- package/bundle/chunk-tv26mwx5.js +0 -2
- package/bundle/chunk-v69n6mef.js +0 -2
- package/bundle/chunk-vegwb3t0.js +0 -2
- package/bundle/chunk-w9seyn69.js +0 -2
- package/bundle/chunk-wanf4se3.js +0 -2
- package/bundle/chunk-wdhzmk1b.js +0 -2
- package/bundle/chunk-wxqtda70.js +0 -2
- package/bundle/chunk-wzb6s9rk.js +0 -2
- package/bundle/chunk-x0dg9rg6.js +0 -2
- package/bundle/chunk-xmnzrzbs.js +0 -2
- package/bundle/chunk-xzf62kc6.js +0 -2
- package/bundle/chunk-yned6vmd.js +0 -3
- package/bundle/chunk-yra49yga.js +0 -2
- package/bundle/chunk-ytye0p7f.js +0 -2
- package/bundle/chunk-yv2mxxbq.js +0 -2
- package/bundle/chunk-z2fqqer0.js +0 -2
- package/bundle/chunk-z3qanc8m.js +0 -2
- package/bundle/chunk-zcagdtab.js +0 -2
- package/bundle/chunk-zervk6c5.js +0 -2
package/bundle/chunk-bh8v3mfg.js
DELETED
package/bundle/chunk-bn0h9dny.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
var J=Symbol.for("drizzle:entityKind");function D(X,Y){if(!X||typeof X!=="object")return!1;if(X instanceof Y)return!0;if(!Object.prototype.hasOwnProperty.call(Y,J))throw Error(`Class "${Y.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let Z=Object.getPrototypeOf(X)?.constructor;if(Z)while(Z){if(J in Z&&Z[J]===Y[J])return!0;Z=Object.getPrototypeOf(Z)}return!1}var T1=Symbol.for("drizzle:OriginalColumn");var N=class{static[J]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;length;isLengthExact;isAlias;config;table;onInit(){}constructor(X,Y){this.config=Y,this.onInit(),this.table=X,this.name=Y.name,this.isAlias=!1,this.keyAsName=Y.keyAsName,this.notNull=Y.notNull,this.default=Y.default,this.defaultFn=Y.defaultFn,this.onUpdateFn=Y.onUpdateFn,this.hasDefault=Y.hasDefault,this.primary=Y.primaryKey,this.isUnique=Y.isUnique,this.uniqueName=Y.uniqueName,this.uniqueType=Y.uniqueType,this.dataType=Y.dataType,this.columnType=Y.columnType,this.generated=Y.generated,this.generatedIdentity=Y.generatedIdentity,this.length=Y.length,this.isLengthExact=Y.isLengthExact}mapFromDriverValue(X){return X}mapToDriverValue(X){return X}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}[T1](){return this}};var r=Symbol.for("drizzle:Name");var G1=Symbol.for("drizzle:Schema"),n=Symbol.for("drizzle:Columns"),GY=Symbol.for("drizzle:ExtraConfigColumns"),U1=Symbol.for("drizzle:OriginalName"),QX=Symbol.for("drizzle:BaseName"),_1=Symbol.for("drizzle:IsAlias"),WY=Symbol.for("drizzle:ExtraConfigBuilder"),X0=Symbol.for("drizzle:IsDrizzleTable"),A=class{static[J]="Table";static Symbol={Name:r,Schema:G1,OriginalName:U1,Columns:n,ExtraConfigColumns:GY,BaseName:QX,IsAlias:_1,ExtraConfigBuilder:WY};[r];[U1];[G1];[n];[GY];[QX];[_1]=!1;[X0]=!0;[WY]=void 0;constructor(X,Y,Z){this[r]=this[U1]=X,this[G1]=Y,this[QX]=Z}};function z1(X){return X[r]}function A1(X){return`${X[G1]??"public"}.${X[r]}`}var T=class{static[J]="Subquery";constructor(X,Y,Z,$=!1,G=[]){this._={brand:"Subquery",sql:X,selectedFields:Y,alias:Z,isWith:$,usedTables:G}}},WX=class extends T{static[J]="WithSubquery"};function JY(X,...Y){return X(...Y)}var HY={startActiveSpan(X,Y){return Y()}};var Q=Symbol.for("drizzle:ViewBaseConfig");var Y0=class{static[J]="FakePrimitiveParam"};function E1(X){return X!==null&&X!==void 0&&typeof X.getSQL==="function"}function Z0(X){let Y={sql:"",params:[]};for(let Z of X)if(Y.sql+=Z.sql,Y.params.push(...Z.params),Z.typings?.length){if(!Y.typings)Y.typings=[];Y.typings.push(...Z.typings)}return Y}var h=class{static[J]="StringChunk";value;constructor(X){this.value=Array.isArray(X)?X:[X]}getSQL(){return new x([this])}},x=class X{static[J]="SQL";decoder=C1;shouldInlineParams=!1;usedTables=[];constructor(Y){this.queryChunks=Y;for(let Z of Y)if(D(Z,A)){let $=Z[A.Symbol.Schema];this.usedTables.push($===void 0?Z[A.Symbol.Name]:$+"."+Z[A.Symbol.Name])}}append(Y){return this.queryChunks.push(...Y.queryChunks),this}toQuery(Y){return HY.startActiveSpan("drizzle.buildSQL",(Z)=>{let $=this.buildQueryFromSourceParams(this.queryChunks,Y);return Z?.setAttributes({"drizzle.query.text":$.sql,"drizzle.query.params":JSON.stringify($.params)}),$})}buildQueryFromSourceParams(Y,Z){let $=Object.assign({},Z,{inlineParams:Z.inlineParams||this.shouldInlineParams,paramStartIndex:Z.paramStartIndex||{value:0}}),{casing:G,escapeName:H,escapeParam:_,prepareTyping:z,inlineParams:O,paramStartIndex:E,invokeSource:U}=$;return Z0(Y.map((F)=>{if(D(F,h))return{sql:F.value.join(""),params:[]};if(D(F,S1))return{sql:H(F.value),params:[]};if(F===void 0)return{sql:"",params:[]};if(Array.isArray(F)){let M=[new h("(")];for(let[I,L]of F.entries())if(M.push(L),I<F.length-1)M.push(new h(", "));return M.push(new h(")")),this.buildQueryFromSourceParams(M,$)}if(D(F,X))return this.buildQueryFromSourceParams(F.queryChunks,{...$,inlineParams:O||F.shouldInlineParams});if(D(F,A)){let M=F[A.Symbol.Schema],I=F[A.Symbol.Name];if(U==="mssql-view-with-schemabinding")return{sql:(M===void 0?H("dbo"):H(M))+"."+H(I),params:[]};return{sql:M===void 0||F[_1]?H(I):H(M)+"."+H(I),params:[]}}if(D(F,N)){let M=G.getColumnCasing(F);if(Z.invokeSource==="indexes")return{sql:H(M),params:[]};let I=U==="mssql-check"?void 0:F.table[A.Symbol.Schema];return{sql:F.isAlias?H(F.name):F.table[_1]||I===void 0?H(F.table[A.Symbol.Name])+"."+H(M):H(I)+"."+H(F.table[A.Symbol.Name])+"."+H(M),params:[]}}if(D(F,y)){let M=F[Q].schema,I=F[Q].name;return{sql:M===void 0||F[Q].isAlias?H(I):H(M)+"."+H(I),params:[]}}if(D(F,g)){if(D(F.value,l))return{sql:_(E.value++,F),params:[F],typings:["none"]};let M=F.value===null?null:F.encoder.mapToDriverValue(F.value);if(D(M,X))return this.buildQueryFromSourceParams([M],$);if(O)return{sql:this.mapInlineParam(M,$),params:[]};let I=["none"];if(z)I=[z(F.encoder)];return{sql:_(E.value++,M),params:[M],typings:I}}if(D(F,l))return{sql:_(E.value++,F),params:[F],typings:["none"]};if(D(F,X.Aliased)&&F.fieldAlias!==void 0)return{sql:(F.origin!==void 0?H(F.origin)+".":"")+H(F.fieldAlias),params:[]};if(D(F,T)){if(F._.isWith)return{sql:H(F._.alias),params:[]};return this.buildQueryFromSourceParams([new h("("),F._.sql,new h(") "),new S1(F._.alias)],$)}if(typeof F==="function"&&"enumName"in F){if("schema"in F&&F.schema)return{sql:H(F.schema)+"."+H(F.enumName),params:[]};return{sql:H(F.enumName),params:[]}}if(E1(F)){if(F.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([F.getSQL()],$);return this.buildQueryFromSourceParams([new h("("),F.getSQL(),new h(")")],$)}if(O)return{sql:this.mapInlineParam(F,$),params:[]};return{sql:_(E.value++,F),params:[F],typings:["none"]}}))}mapInlineParam(Y,{escapeString:Z}){if(Y===null)return"null";if(typeof Y==="number"||typeof Y==="boolean"||typeof Y==="bigint")return Y.toString();if(typeof Y==="string")return Z(Y);if(typeof Y==="object"){let $=Y.toString();if($==="[object Object]")return Z(JSON.stringify(Y));return Z($)}throw Error("Unexpected param value: "+Y)}getSQL(){return this}as(Y){if(Y===void 0)return this;return new X.Aliased(this,Y)}mapWith(Y){return this.decoder=typeof Y==="function"?{mapFromDriverValue:Y}:Y,this}inlineParams(){return this.shouldInlineParams=!0,this}if(Y){return Y?this:void 0}},S1=class{static[J]="Name";brand;constructor(X){this.value=X}getSQL(){return new x([this])}};function $0(X){return new S1(X)}function PX(X){return typeof X==="object"&&X!==null&&"mapToDriverValue"in X&&typeof X.mapToDriverValue==="function"}var C1={mapFromDriverValue:(X)=>X},LX={mapToDriverValue:(X)=>X},G0={...C1,...LX},g=class{static[J]="Param";brand;constructor(X,Y=LX){this.value=X,this.encoder=Y}getSQL(){return new x([this])}};function W0(X,Y){return new g(X,Y)}function W(X,...Y){let Z=[];if(Y.length>0||X.length>0&&X[0]!=="")Z.push(new h(X[0]));for(let[$,G]of Y.entries())Z.push(G,new h(X[$+1]));return new x(Z)}(function(X){function Y(){return new x([])}X.empty=Y;function Z(O){return new x(O)}X.fromList=Z;function $(O){return new x([new h(O)])}X.raw=$;function G(O,E){let U=[];for(let[F,M]of O.entries()){if(F>0&&E!==void 0)U.push(E);U.push(M)}return new x(U)}X.join=G;function H(O){return new S1(O)}X.identifier=H;function _(O){return new l(O)}X.placeholder=_;function z(O,E){return new g(O,E)}X.param=z})(W||(W={}));(function(X){class Y{static[J]="SQL.Aliased";isSelectionField=!1;origin;constructor(Z,$){this.sql=Z,this.fieldAlias=$}getSQL(){return this.sql}clone(){return new Y(this.sql,this.fieldAlias)}}X.Aliased=Y})(x||(x={}));var l=class{static[J]="Placeholder";constructor(X){this.name=X}getSQL(){return new x([this])}};function J0(X){return new l(X)}function D1(X,Y){return X.map((Z)=>{if(D(Z,l)){if(!(Z.name in Y))throw Error(`No value for placeholder "${Z.name}" was provided`);return Y[Z.name]}if(D(Z,g)&&D(Z.value,l)){if(!(Z.value.name in Y))throw Error(`No value for placeholder "${Z.value.name}" was provided`);return Z.encoder.mapToDriverValue(Y[Z.value.name])}return Z})}var _Y=Symbol.for("drizzle:IsDrizzleView"),y=class{static[J]="View";[Q];[_Y]=!0;get[r](){return this[Q].name}get[G1](){return this[Q].schema}get[_1](){return this[Q].isAlias}get[U1](){return this[Q].originalName}get[n](){return this[Q].selectedFields}constructor({name:X,schema:Y,selectedFields:Z,query:$}){this[Q]={name:X,originalName:X,schema:Y,selectedFields:Z,query:$,isExisting:!$,isAlias:!1}}};function H0(X){return typeof X==="object"&&X!==null&&_Y in X}function _0(X){return X[Q].name}N.prototype.getSQL=function(){return new x([this])};T.prototype.getSQL=function(){return new x([this])};function BX(X,Y,Z){let $={},G=X.reduce((H,{path:_,field:z},O)=>{let E;if(D(z,N))E=z;else if(D(z,x))E=z.decoder;else if(D(z,T))E=z._.sql.decoder;else E=z.sql.decoder;let U=H;for(let[F,M]of _.entries())if(F<_.length-1){if(!(M in U))U[M]={};U=U[M]}else{let I=Y[O],L=U[M]=I===null?null:E.mapFromDriverValue(I);if(Z&&D(z,N)&&_.length===2){let P=_[0];if(!(P in $))$[P]=L===null?z1(z.table):!1;else if(typeof $[P]==="string"&&$[P]!==z1(z.table))$[P]=!1}}return H},{});if(Z&&Object.keys($).length>0){for(let[H,_]of Object.entries($))if(typeof _==="string"&&!Z[_])G[H]=null}return G}function i(X,Y){return Object.entries(X).reduce((Z,[$,G])=>{if(typeof $!=="string")return Z;let H=Y?[...Y,$]:[$];if(D(G,N)||D(G,x)||D(G,x.Aliased)||D(G,T))Z.push({path:H,field:G});else if(D(G,A))Z.push(...i(G[A.Symbol.Columns],H));else Z.push(...i(G,H));return Z},[])}function q1(X,Y){let Z=Object.keys(X),$=Object.keys(Y);if(Z.length!==$.length)return!1;for(let[G,H]of Z.entries())if(H!==$[G])return!1;return!0}function JX(X,Y){let Z=Object.entries(Y).filter(([,$])=>$!==void 0).map(([$,G])=>{if(D(G,x)||D(G,N))return[$,G];else return[$,new g(G,X[A.Symbol.Columns][$])]});if(Z.length===0)throw Error("No values to set");return Object.fromEntries(Z)}function zY(X,Y){for(let Z of Y)for(let $ of Object.getOwnPropertyNames(Z.prototype)){if($==="constructor")continue;Object.defineProperty(X.prototype,$,Object.getOwnPropertyDescriptor(Z.prototype,$)||Object.create(null))}}function EY(X){return X[A.Symbol.Columns]}function v1(X){return D(X,T)?X._.alias:D(X,y)?X[Q].name:D(X,x)?void 0:X[A.Symbol.IsAlias]?X[A.Symbol.Name]:X[A.Symbol.BaseName]}function k(X,Y){return{name:typeof X==="string"&&X.length>0?X:"",config:typeof X==="object"?X:Y}}var jX=typeof TextDecoder>"u"?null:new TextDecoder;var D3={INT8_MIN:-128,INT8_MAX:127,INT8_UNSIGNED_MAX:255,INT16_MIN:-32768,INT16_MAX:32767,INT16_UNSIGNED_MAX:65535,INT24_MIN:-8388608,INT24_MAX:8388607,INT24_UNSIGNED_MAX:16777215,INT32_MIN:-2147483648,INT32_MAX:2147483647,INT32_UNSIGNED_MAX:4294967295,INT48_MIN:-140737488355328,INT48_MAX:140737488355327,INT48_UNSIGNED_MAX:281474976710655,INT64_MIN:-9223372036854775808n,INT64_MAX:9223372036854775807n,INT64_UNSIGNED_MAX:18446744073709551615n};var z0=class{static[J]="ConsoleLogWriter";write(X){console.log(X)}},DY=class{static[J]="DefaultLogger";writer;constructor(X){this.writer=X?.writer??new z0}logQuery(X,Y){let Z=Y.map((G)=>{try{return JSON.stringify(G)}catch{return String(G)}}),$=Z.length?` -- params: [${Z.join(", ")}]`:"";this.writer.write(`Query: ${X}${$}`)}},OY=class{static[J]="NoopLogger";logQuery(){}};var FY=class{static[J]="ColumnBuilder";config;constructor(X,Y,Z){this.config={name:X,keyAsName:X==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:Y,columnType:Z,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(X){return this.config.default=X,this.config.hasDefault=!0,this}$defaultFn(X){return this.config.defaultFn=X,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(X){return this.config.onUpdateFn=X,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(X){if(this.config.name!=="")return;this.config.name=X}};var HX=class{static[J]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(X,Y){if(this.reference=()=>{let{name:Z,columns:$,foreignColumns:G}=X();return{name:Z,columns:$,foreignTable:G[0].table,foreignColumns:G}},Y)this._onUpdate=Y.onUpdate,this._onDelete=Y.onDelete}onUpdate(X){return this._onUpdate=X,this}onDelete(X){return this._onDelete=X,this}build(X){return new UY(X,this)}},UY=class{static[J]="SQLiteForeignKey";reference;onUpdate;onDelete;constructor(X,Y){this.table=X,this.reference=Y.reference,this.onUpdate=Y._onUpdate,this.onDelete=Y._onDelete}getName(){let{name:X,columns:Y,foreignColumns:Z}=this.reference(),$=Y.map((_)=>_.name),G=Z.map((_)=>_.name),H=[this.table[r],...$,Z[0].table[r],...G];return X??`${H.join("_")}_fk`}isNameExplicit(){return!!this.reference().name}};function E0(X){function Y(){if(typeof X==="function"){let{name:Z,columns:$,foreignColumns:G}=X();return{name:Z,columns:$,foreignColumns:G}}return X}return new HX(Y)}var f=class extends FY{static[J]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(X,Y={}){return this.foreignKeyConfigs.push({ref:X,actions:Y}),this}unique(X){return this.config.isUnique=!0,this.config.uniqueName=X,this}generatedAlwaysAs(X,Y){return this.config.generated={as:X,type:"always",mode:Y?.mode??"virtual"},this}buildForeignKeys(X,Y){return this.foreignKeyConfigs.map(({ref:Z,actions:$})=>{return((G,H)=>{let _=new HX(()=>{let z=G();return{columns:[X],foreignColumns:[z]}});if(H.onUpdate)_.onUpdate(H.onUpdate);if(H.onDelete)_.onDelete(H.onDelete);return _.build(Y)})(Z,$)})}},S=class extends N{static[J]="SQLiteColumn";table;constructor(X,Y){super(X,Y);this.table=X}};var _X=class extends f{static[J]="SQLiteBaseIntegerBuilder";constructor(X,Y,Z){super(X,Y,Z);this.config.autoIncrement=!1}primaryKey(X){if(X?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}},zX=class extends S{static[J]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}},AY=class extends _X{static[J]="SQLiteIntegerBuilder";constructor(X){super(X,"number int53","SQLiteInteger")}build(X){return new VY(X,this.config)}},VY=class extends zX{static[J]="SQLiteInteger"},IY=class extends _X{static[J]="SQLiteTimestampBuilder";constructor(X,Y){super(X,"object date","SQLiteTimestamp");this.config.mode=Y}defaultNow(){return this.default(W`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(X){return new MY(X,this.config)}},MY=class extends zX{static[J]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(X){if(typeof X==="string")return new Date(X.replaceAll('"',""));if(this.config.mode==="timestamp")return new Date(X*1000);return new Date(X)}mapToDriverValue(X){if(typeof X==="number")return X;let Y=X.getTime();if(this.config.mode==="timestamp")return Math.floor(Y/1000);return Y}},xY=class extends _X{static[J]="SQLiteBooleanBuilder";constructor(X,Y){super(X,"boolean","SQLiteBoolean");this.config.mode=Y}build(X){return new KY(X,this.config)}},KY=class extends zX{static[J]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(X){return Number(X)===1}mapToDriverValue(X){return X?1:0}};function TX(X,Y){let{name:Z,config:$}=k(X,Y);if($?.mode==="timestamp"||$?.mode==="timestamp_ms")return new IY(Z,$.mode);if($?.mode==="boolean")return new xY(Z,$.mode);return new AY(Z)}var kY=class extends f{static[J]="SQLiteTextBuilder";constructor(X,Y){super(X,Y.enum?.length?"string enum":"string","SQLiteText");this.config.enumValues=Y.enum,this.config.length=Y.length}build(X){return new NY(X,this.config)}},NY=class extends S{static[J]="SQLiteText";enumValues=this.config.enumValues;constructor(X,Y){super(X,Y)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}},RY=class extends f{static[J]="SQLiteTextJsonBuilder";constructor(X){super(X,"object json","SQLiteTextJson")}build(X){return new wY(X,this.config)}},wY=class extends S{static[J]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(X){return JSON.parse(X)}mapToDriverValue(X){return JSON.stringify(X)}};function SX(X,Y={}){let{name:Z,config:$}=k(X,Y);if($.mode==="json")return new RY(Z);return new kY(Z,$)}var QY=class{static[J]="SQLiteIndexBuilderOn";constructor(X,Y){this.name=X,this.unique=Y}on(...X){return new PY(this.name,X,this.unique)}},PY=class{static[J]="SQLiteIndexBuilder";config;constructor(X,Y,Z){this.config={name:X,columns:Y,unique:Z,where:void 0}}where(X){return this.config.where=X,this}build(X){return new LY(this.config,X)}},LY=class{static[J]="SQLiteIndex";config;isNameExplicit;constructor(X,Y){this.config={...X,table:Y},this.isNameExplicit=!!X.name}};function D0(X){return new QY(X,!1)}function BY(X){let Y="";for(let Z=0;Z<X.length;Z+=2){let $=X.slice(Z,Z+2),G=Number.parseInt($,16);Y+=String.fromCodePoint(G)}return Y}var O0=class extends f{static[J]="SQLiteBigIntBuilder";constructor(X){super(X,"bigint int64","SQLiteBigInt")}build(X){return new F0(X,this.config)}},F0=class extends S{static[J]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue(X){if(typeof X==="string")return BigInt(BY(X));if(typeof Buffer<"u"&&Buffer.from){let Y=Buffer.isBuffer(X)?X:X instanceof ArrayBuffer?Buffer.from(X):X.buffer?Buffer.from(X.buffer,X.byteOffset,X.byteLength):Buffer.from(X);return BigInt(Y.toString("utf8"))}return BigInt(jX.decode(X))}mapToDriverValue(X){return Buffer.from(X.toString())}},U0=class extends f{static[J]="SQLiteBlobJsonBuilder";constructor(X){super(X,"object json","SQLiteBlobJson")}build(X){return new A0(X,this.config)}},A0=class extends S{static[J]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue(X){if(typeof X==="string")return JSON.parse(BY(X));if(typeof Buffer<"u"&&Buffer.from){let Y=Buffer.isBuffer(X)?X:X instanceof ArrayBuffer?Buffer.from(X):X.buffer?Buffer.from(X.buffer,X.byteOffset,X.byteLength):Buffer.from(X);return JSON.parse(Y.toString("utf8"))}return JSON.parse(jX.decode(X))}mapToDriverValue(X){return Buffer.from(JSON.stringify(X))}},V0=class extends f{static[J]="SQLiteBlobBufferBuilder";constructor(X){super(X,"object buffer","SQLiteBlobBuffer")}build(X){return new I0(X,this.config)}},I0=class extends S{static[J]="SQLiteBlobBuffer";mapFromDriverValue(X){if(Buffer.isBuffer(X))return X;if(typeof X==="string")return Buffer.from(X,"hex");return Buffer.from(X)}getSQLType(){return"blob"}};function jY(X,Y){let{name:Z,config:$}=k(X,Y);if($?.mode==="json")return new U0(Z);if($?.mode==="bigint")return new O0(Z);return new V0(Z)}var M0=class extends f{static[J]="SQLiteCustomColumnBuilder";constructor(X,Y,Z){super(X,"custom","SQLiteCustomColumn");this.config.fieldConfig=Y,this.config.customTypeParams=Z}build(X){return new x0(X,this.config)}},x0=class extends S{static[J]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;mapJson;forJsonSelect;constructor(X,Y){super(X,Y);this.sqlName=Y.customTypeParams.dataType(Y.fieldConfig),this.mapTo=Y.customTypeParams.toDriver,this.mapFrom=Y.customTypeParams.fromDriver,this.mapJson=Y.customTypeParams.fromJson,this.forJsonSelect=Y.customTypeParams.forJsonSelect}getSQLType(){return this.sqlName}mapFromDriverValue(X){return typeof this.mapFrom==="function"?this.mapFrom(X):X}mapFromJsonValue(X){return typeof this.mapJson==="function"?this.mapJson(X):this.mapFromDriverValue(X)}jsonSelectIdentifier(X,Y){if(typeof this.forJsonSelect==="function")return this.forJsonSelect(X,Y);let Z=this.getSQLType().toLowerCase(),$=Z.indexOf("(");switch($+1?Z.slice(0,$):Z){case"numeric":case"decimal":case"bigint":return Y`cast(${X} as text)`;case"blob":return Y`hex(${X})`;default:return X}}mapToDriverValue(X){return typeof this.mapTo==="function"?this.mapTo(X):X}};function TY(X){return(Y,Z)=>{let{name:$,config:G}=k(Y,Z);return new M0($,G,X)}}var K0=class extends f{static[J]="SQLiteNumericBuilder";constructor(X){super(X,"string numeric","SQLiteNumeric")}build(X){return new k0(X,this.config)}},k0=class extends S{static[J]="SQLiteNumeric";mapFromDriverValue(X){if(typeof X==="string")return X;return String(X)}getSQLType(){return"numeric"}},N0=class extends f{static[J]="SQLiteNumericNumberBuilder";constructor(X){super(X,"number","SQLiteNumericNumber")}build(X){return new R0(X,this.config)}},R0=class extends S{static[J]="SQLiteNumericNumber";mapFromDriverValue(X){if(typeof X==="number")return X;return Number(X)}mapToDriverValue=String;getSQLType(){return"numeric"}},w0=class extends f{static[J]="SQLiteNumericBigIntBuilder";constructor(X){super(X,"bigint int64","SQLiteNumericBigInt")}build(X){return new Q0(X,this.config)}},Q0=class extends S{static[J]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}};function SY(X,Y){let{name:Z,config:$}=k(X,Y),G=$?.mode;return G==="number"?new N0(Z):G==="bigint"?new w0(Z):new K0(Z)}var P0=class extends f{static[J]="SQLiteRealBuilder";constructor(X){super(X,"number double","SQLiteReal")}build(X){return new L0(X,this.config)}},L0=class extends S{static[J]="SQLiteReal";getSQLType(){return"real"}};function CY(X){return new P0(X??"")}function qY(){return{blob:jY,customType:TY,integer:TX,numeric:SY,real:CY,text:SX}}var EX=Symbol.for("drizzle:SQLiteInlineForeignKeys"),v=class extends A{static[J]="SQLiteTable";static Symbol=Object.assign({},A.Symbol,{InlineForeignKeys:EX});[A.Symbol.Columns];[EX]=[];[A.Symbol.ExtraConfigBuilder]=void 0};function B0(X,Y,Z,$,G=X){let H=new v(X,$,G),_=typeof Y==="function"?Y(qY()):Y,z=Object.fromEntries(Object.entries(_).map(([E,U])=>{let F=U;F.setName(E);let M=F.build(H);return H[EX].push(...F.buildForeignKeys(M,H)),[E,M]})),O=Object.assign(H,z);if(O[A.Symbol.Columns]=z,O[A.Symbol.ExtraConfigColumns]=z,Z)O[v.Symbol.ExtraConfigBuilder]=Z;return O}var j0=(X,Y,Z)=>{return B0(X,Y,Z)};function T0(...X){if(X[0].columns)return new CX(X[0].columns,X[0].name);return new CX(X)}var CX=class{static[J]="SQLitePrimaryKeyBuilder";columns;name;constructor(X,Y){this.columns=X,this.name=Y}build(X){return new vY(X,this.columns,this.name)}},vY=class{static[J]="SQLitePrimaryKey";columns;name;isNameExplicit;constructor(X,Y,Z){this.table=X,this.columns=Y,this.name=Z,this.isNameExplicit=!!Z}getName(){return this.name??`${this.table[v.Symbol.Name]}_${this.columns.map((X)=>X.name).join("_")}_pk`}};function q(X,Y){if(PX(Y)&&!E1(X)&&!D(X,g)&&!D(X,l)&&!D(X,N)&&!D(X,A)&&!D(X,y))return new g(X,Y);return X}var a=(X,Y)=>{return W`${X} = ${q(Y,X)}`},h1=(X,Y)=>{return W`${X} <> ${q(Y,X)}`};function m(...X){let Y=X.filter((Z)=>Z!==void 0);if(Y.length===0)return;if(Y.length===1)return new x(Y);return new x([new h("("),W.join(Y,new h(" and ")),new h(")")])}function V1(...X){let Y=X.filter((Z)=>Z!==void 0);if(Y.length===0)return;if(Y.length===1)return new x(Y);return new x([new h("("),W.join(Y,new h(" or ")),new h(")")])}function I1(X){return W`not ${X}`}var p1=(X,Y)=>{return W`${X} > ${q(Y,X)}`},y1=(X,Y)=>{return W`${X} >= ${q(Y,X)}`},f1=(X,Y)=>{return W`${X} < ${q(Y,X)}`},b1=(X,Y)=>{return W`${X} <= ${q(Y,X)}`};function d1(X,Y){if(Array.isArray(Y)){if(Y.length===0)return W`false`;return W`${X} in ${Y.map((Z)=>q(Z,X))}`}return W`${X} in ${q(Y,X)}`}function g1(X,Y){if(Array.isArray(Y)){if(Y.length===0)return W`true`;return W`${X} not in ${Y.map((Z)=>q(Z,X))}`}return W`${X} not in ${q(Y,X)}`}function m1(X){return W`(${X} is null)`}function c1(X){return W`(${X} is not null)`}function k1(X){return W`exists ${X}`}function N1(X){return W`not exists ${X}`}function u1(X,Y,Z){return W`${X} between ${q(Y,X)} and ${q(Z,X)}`}function r1(X,Y,Z){return W`${X} not between ${q(Y,X)} and ${q(Z,X)}`}function o1(X,Y){return W`${X} like ${Y}`}function s1(X,Y){return W`${X} not like ${Y}`}function t1(X,Y){return W`${X} ilike ${Y}`}function n1(X,Y){return W`${X} not ilike ${Y}`}function qX(X,Y){if(Array.isArray(Y)){if(Y.length===0)throw Error("arrayContains requires at least one value");let Z=q(Y,X);return W`${X} @> ${W`${Array.isArray(Z)?new g(Z):Z}`}`}return W`${X} @> ${q(Y,X)}`}function vX(X,Y){if(Array.isArray(Y)){if(Y.length===0)throw Error("arrayContained requires at least one value");let Z=q(Y,X);return W`${X} <@ ${W`${Array.isArray(Z)?new g(Z):Z}`}`}return W`${X} <@ ${q(Y,X)}`}function hX(X,Y){if(Array.isArray(Y)){if(Y.length===0)throw Error("arrayOverlaps requires at least one value");let Z=q(Y,X);return W`${X} && ${W`${Array.isArray(Z)?new g(Z):Z}`}`}return W`${X} && ${q(Y,X)}`}function M1(X){return W`${X} asc`}function i1(X){return W`${X} desc`}function hY(X,Y,Z){for(let $=Y;$<X.length;$++){let G=X[$];if(G==="\\"){$++;continue}if(G==='"')return[X.slice(Y,$).replace(/\\/g,""),$+1];if(Z)continue;if(G===","||G==="}")return[X.slice(Y,$).replace(/\\/g,""),$]}return[X.slice(Y).replace(/\\/g,""),X.length]}function pY(X,Y=0){let Z=[],$=Y,G=!1;while($<X.length){let H=X[$];if(H===","){if(G||$===Y)Z.push("");G=!0,$++;continue}if(G=!1,H==="\\"){$+=2;continue}if(H==='"'){let[O,E]=hY(X,$+1,!0);Z.push(O),$=E;continue}if(H==="}")return[Z,$+1];if(H==="{"){let[O,E]=pY(X,$+1);Z.push(O),$=E;continue}let[_,z]=hY(X,$,!1);Z.push(_),$=z}return[Z,$]}function DX(X){let[Y]=pY(X,1);return Y}function pX(X){return`{${X.map((Y)=>{if(Array.isArray(Y))return pX(Y);if(typeof Y==="string")return`"${Y.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${Y}`}).join(",")}}`}var yY=class{static[J]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(X,Y){if(this.reference=()=>{let{name:Z,columns:$,foreignColumns:G}=X();return{name:Z,columns:$,foreignTable:G[0].table,foreignColumns:G}},Y)this._onUpdate=Y.onUpdate,this._onDelete=Y.onDelete}onUpdate(X){return this._onUpdate=X===void 0?"no action":X,this}onDelete(X){return this._onDelete=X===void 0?"no action":X,this}build(X){return new S0(X,this)}},S0=class{static[J]="PgForeignKey";reference;onUpdate;onDelete;name;constructor(X,Y){this.table=X,this.reference=Y.reference,this.onUpdate=Y._onUpdate,this.onDelete=Y._onDelete}getName(){let{name:X,columns:Y,foreignColumns:Z}=this.reference(),$=Y.map((_)=>_.name),G=Z.map((_)=>_.name),H=[this.table[r],...$,Z[0].table[r],...G];return X??`${H.join("_")}_fk`}isNameExplicit(){return!!this.reference().name}};var K=class{static[J]="PgColumnBuilder";foreignKeyConfigs=[];config;constructor(X,Y,Z){this.config={name:X,keyAsName:X==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:Y,columnType:Z,generated:void 0,defaultFn:void 0,onUpdateFn:void 0,generatedIdentity:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(X){return this.config.default=X,this.config.hasDefault=!0,this}$defaultFn(X){return this.config.defaultFn=X,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(X){return this.config.onUpdateFn=X,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(X){if(this.config.name!=="")return;this.config.name=X}array(X){let Y=X??"[]";return this.config.dimensions=Y.length/2,this}references(X,Y={}){return this.foreignKeyConfigs.push({ref:X,config:Y}),this}unique(X,Y){return this.config.isUnique=!0,this.config.uniqueName=X,this.config.uniqueType=Y?.nulls,this}generatedAlwaysAs(X){return this.config.generated={as:X,type:"always",mode:"stored"},this}buildForeignKeys(X,Y){return this.foreignKeyConfigs.map(({ref:Z,config:$})=>{return JY((G,H)=>{let _=new yY(()=>{let z=G();return{name:H.name,columns:[X],foreignColumns:[z]}});if(H.onUpdate)_.onUpdate(H.onUpdate);if(H.onDelete)_.onDelete(H.onDelete);return _.build(Y)},Z,$)})}buildExtraConfigColumn(X){return new C0(X,{...this.config,dimensions:this.config.dimensions??0})}},V=class extends N{static[J]="PgColumn";table;dimensions;constructor(X,Y){super(X,Y);if(this.table=X,this.dimensions=Y.dimensions??0,this.dimensions){let Z=this.mapFromDriverValue.bind(this),$=this.mapToDriverValue.bind(this);this.mapFromDriverValue=(G)=>{if(G===null)return G;let H=typeof G==="string"?DX(G):G;return this.mapArrayElements(H,Z,this.dimensions)},this.mapToDriverValue=(G)=>{if(G===null)return G;return pX(this.mapArrayElements(G,$,this.dimensions))}}}mapArrayElements(X,Y,Z){if(Z>0&&Array.isArray(X))return X.map(($)=>$===null?null:this.mapArrayElements($,Y,Z-1));return Y(X)}},C0=class extends V{static[J]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(X){return this.indexConfig.opClass=X,this}};var O1=class extends K{static[J]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(X){if(X){let{name:Y,...Z}=X;this.config.generatedIdentity={type:"always",sequenceName:Y,sequenceOptions:Z}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(X){if(X){let{name:Y,...Z}=X;this.config.generatedIdentity={type:"byDefault",sequenceName:Y,sequenceOptions:Z}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}};var q0=class extends O1{static[J]="PgBigInt53Builder";constructor(X){super(X,"number int53","PgBigInt53")}build(X){return new v0(X,this.config)}},v0=class extends V{static[J]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(X){if(typeof X==="number")return X;return Number(X)}},h0=class extends O1{static[J]="PgBigInt64Builder";constructor(X){super(X,"bigint int64","PgBigInt64")}build(X){return new p0(X,this.config)}},p0=class extends V{static[J]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(X){return BigInt(X)}},y0=class extends O1{static[J]="PgBigIntStringBuilder";constructor(X){super(X,"string int64","PgBigIntString")}build(X){return new f0(X,this.config)}},f0=class extends V{static[J]="PgBigIntString";getSQLType(){return"bigint"}mapFromDriverValue(X){if(typeof X==="string")return X;return String(X)}};function fY(X,Y){let{name:Z,config:$}=k(X,Y);if($.mode==="number")return new q0(Z);if($.mode==="string")return new y0(Z);return new h0(Z)}var b0=class extends K{static[J]="PgBigSerial53Builder";constructor(X){super(X,"number int53","PgBigSerial53");this.config.hasDefault=!0,this.config.notNull=!0}build(X){return new d0(X,this.config)}},d0=class extends V{static[J]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(X){if(typeof X==="number")return X;return Number(X)}},g0=class extends K{static[J]="PgBigSerial64Builder";constructor(X){super(X,"bigint int64","PgBigSerial64");this.config.hasDefault=!0,this.config.notNull=!0}build(X){return new m0(X,this.config)}},m0=class extends V{static[J]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(X){return BigInt(X)}};function bY(X,Y){let{name:Z,config:$}=k(X,Y);if($.mode==="number")return new b0(Z);return new g0(Z)}var c0=class extends K{static[J]="PgBooleanBuilder";constructor(X){super(X,"boolean","PgBoolean")}build(X){return new u0(X,this.config)}},u0=class extends V{static[J]="PgBoolean";getSQLType(){return"boolean"}};function dY(X){return new c0(X??"")}var r0=class extends K{static[J]="PgCharBuilder";constructor(X,Y){super(X,Y.enum?.length?"string enum":"string","PgChar");this.config.length=Y.length??1,this.config.setLength=Y.length!==void 0,this.config.enumValues=Y.enum}build(X){return new o0(X,this.config)}},o0=class extends V{static[J]="PgChar";enumValues;setLength;constructor(X,Y){super(X,Y);this.enumValues=Y.enumValues,this.setLength=Y.setLength}getSQLType(){return this.setLength?`char(${this.length})`:"char"}};function gY(X,Y={}){let{name:Z,config:$}=k(X,Y);return new r0(Z,$)}var s0=class extends K{static[J]="PgCidrBuilder";constructor(X){super(X,"string cidr","PgCidr")}build(X){return new t0(X,this.config)}},t0=class extends V{static[J]="PgCidr";getSQLType(){return"cidr"}};function mY(X){return new s0(X??"")}var n0=class extends K{static[J]="PgCustomColumnBuilder";constructor(X,Y,Z){super(X,"custom","PgCustomColumn");this.config.fieldConfig=Y,this.config.customTypeParams=Z}build(X){return new i0(X,this.config)}},i0=class extends V{static[J]="PgCustomColumn";sqlName;mapTo;mapFrom;mapJson;forJsonSelect;constructor(X,Y){super(X,Y);if(this.sqlName=Y.customTypeParams.dataType(Y.fieldConfig),this.mapTo=Y.customTypeParams.toDriver,this.mapFrom=Y.customTypeParams.fromDriver,this.mapJson=Y.customTypeParams.fromJson,this.forJsonSelect=Y.customTypeParams.forJsonSelect,this.dimensions){let Z=($)=>{if(typeof this.mapJson==="function")return this.mapJson($);if(typeof this.mapFrom==="function")return this.mapFrom($);return $};this.mapFromJsonValue=($)=>{if($===null)return $;let G=typeof $==="string"?DX($):$;return this.mapJsonArrayElements(G,Z,this.dimensions)}}}mapJsonArrayElements(X,Y,Z){if(Z>0&&Array.isArray(X))return X.map(($)=>$===null?null:this.mapJsonArrayElements($,Y,Z-1));return Y(X)}getSQLType(){return this.sqlName}mapFromDriverValue(X){return typeof this.mapFrom==="function"?this.mapFrom(X):X}mapFromJsonValue(X){return typeof this.mapJson==="function"?this.mapJson(X):this.mapFromDriverValue(X)}jsonSelectIdentifier(X,Y,Z){if(typeof this.forJsonSelect==="function")return this.forJsonSelect(X,Y,Z);let $=this.getSQLType().toLowerCase(),G=$.indexOf("(");switch(G+1?$.slice(0,G):$){case"bytea":case"geometry":case"timestamp":case"numeric":case"bigint":{let H="[]".repeat(Z??0);return Y`${X}::text${Y.raw(H).if(Z)}`}default:return X}}mapToDriverValue(X){return typeof this.mapTo==="function"?this.mapTo(X):X}};function cY(X){return(Y,Z)=>{let{name:$,config:G}=k(Y,Z);return new n0($,G,X)}}var F1=class extends K{static[J]="PgDateColumnBaseBuilder";defaultNow(){return this.default(W`now()`)}};var l0=class extends F1{static[J]="PgDateBuilder";constructor(X){super(X,"object date","PgDate")}build(X){return new a0(X,this.config)}},a0=class extends V{static[J]="PgDate";getSQLType(){return"date"}mapFromDriverValue(X){if(typeof X==="string")return new Date(X);return X}mapToDriverValue(X){if(typeof X==="string")return X;return X.toISOString()}},e0=class extends F1{static[J]="PgDateStringBuilder";constructor(X){super(X,"string date","PgDateString")}build(X){return new X8(X,this.config)}},X8=class extends V{static[J]="PgDateString";getSQLType(){return"date"}mapFromDriverValue(X){if(typeof X==="string")return X;return X.toISOString().slice(0,-14)}mapToDriverValue(X){if(typeof X==="string")return X;return X.toISOString()}};function uY(X,Y){let{name:Z,config:$}=k(X,Y);if($?.mode==="date")return new l0(Z);return new e0(Z)}var Y8=class extends K{static[J]="PgDoublePrecisionBuilder";constructor(X){super(X,"number double","PgDoublePrecision")}build(X){return new Z8(X,this.config)}},Z8=class extends V{static[J]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(X){if(typeof X==="string")return Number.parseFloat(X);return X}};function rY(X){return new Y8(X??"")}var $8=class extends K{static[J]="PgInetBuilder";constructor(X){super(X,"string inet","PgInet")}build(X){return new G8(X,this.config)}},G8=class extends V{static[J]="PgInet";getSQLType(){return"inet"}};function oY(X){return new $8(X??"")}var W8=class extends O1{static[J]="PgIntegerBuilder";constructor(X){super(X,"number int32","PgInteger")}build(X){return new J8(X,this.config)}},J8=class extends V{static[J]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(X){if(typeof X==="string")return Number.parseInt(X);return X}};function sY(X){return new W8(X??"")}var H8=class extends K{static[J]="PgIntervalBuilder";constructor(X,Y){super(X,"string interval","PgInterval");this.config.intervalConfig=Y}build(X){return new _8(X,this.config)}},_8=class extends V{static[J]="PgInterval";fields;precision;constructor(X,Y){super(X,Y);this.fields=Y.intervalConfig.fields,this.precision=Y.intervalConfig.precision}getSQLType(){return`interval${this.fields?` ${this.fields}`:""}${this.precision?`(${this.precision})`:""}`}};function tY(X,Y={}){let{name:Z,config:$}=k(X,Y);return new H8(Z,$)}var z8=class extends K{static[J]="PgJsonBuilder";constructor(X){super(X,"object json","PgJson")}build(X){return new E8(X,this.config)}},E8=class extends V{static[J]="PgJson";constructor(X,Y){super(X,Y)}getSQLType(){return"json"}mapToDriverValue(X){return JSON.stringify(X)}mapFromDriverValue(X){if(typeof X==="string")try{return JSON.parse(X)}catch{return X}return X}};function nY(X){return new z8(X??"")}var D8=class extends K{static[J]="PgJsonbBuilder";constructor(X){super(X,"object json","PgJsonb")}build(X){return new O8(X,this.config)}},O8=class extends V{static[J]="PgJsonb";constructor(X,Y){super(X,Y)}getSQLType(){return"jsonb"}mapToDriverValue(X){return JSON.stringify(X)}mapFromDriverValue(X){if(typeof X==="string")try{return JSON.parse(X)}catch{return X}return X}};function iY(X){return new D8(X??"")}var F8=class extends K{static[J]="PgLineBuilder";constructor(X){super(X,"array line","PgLine")}build(X){return new U8(X,this.config)}},U8=class extends V{static[J]="PgLine";mode="tuple";getSQLType(){return"line"}mapFromDriverValue(X){let[Y,Z,$]=X.slice(1,-1).split(",");return[Number.parseFloat(Y),Number.parseFloat(Z),Number.parseFloat($)]}mapToDriverValue(X){return`{${X[0]},${X[1]},${X[2]}}`}},A8=class extends K{static[J]="PgLineABCBuilder";constructor(X){super(X,"object line","PgLineABC")}build(X){return new V8(X,this.config)}},V8=class extends V{static[J]="PgLineABC";mode="abc";getSQLType(){return"line"}mapFromDriverValue(X){let[Y,Z,$]=X.slice(1,-1).split(",");return{a:Number.parseFloat(Y),b:Number.parseFloat(Z),c:Number.parseFloat($)}}mapToDriverValue(X){return`{${X.a},${X.b},${X.c}}`}};function lY(X,Y){let{name:Z,config:$}=k(X,Y);if(!$?.mode||$.mode==="tuple")return new F8(Z);return new A8(Z)}var I8=class extends K{static[J]="PgMacaddrBuilder";constructor(X){super(X,"string macaddr","PgMacaddr")}build(X){return new M8(X,this.config)}},M8=class extends V{static[J]="PgMacaddr";getSQLType(){return"macaddr"}};function aY(X){return new I8(X??"")}var x8=class extends K{static[J]="PgMacaddr8Builder";constructor(X){super(X,"string macaddr8","PgMacaddr8")}build(X){return new K8(X,this.config)}},K8=class extends V{static[J]="PgMacaddr8";getSQLType(){return"macaddr8"}};function eY(X){return new x8(X??"")}var k8=class extends K{static[J]="PgNumericBuilder";constructor(X,Y,Z){super(X,"string numeric","PgNumeric");this.config.precision=Y,this.config.scale=Z}build(X){return new N8(X,this.config)}},N8=class extends V{static[J]="PgNumeric";precision;scale;constructor(X,Y){super(X,Y);this.precision=Y.precision,this.scale=Y.scale}mapFromDriverValue(X){if(typeof X==="string")return X;return String(X)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}},R8=class extends K{static[J]="PgNumericNumberBuilder";constructor(X,Y,Z){super(X,"number","PgNumericNumber");this.config.precision=Y,this.config.scale=Z}build(X){return new w8(X,this.config)}},w8=class extends V{static[J]="PgNumericNumber";precision;scale;constructor(X,Y){super(X,Y);this.precision=Y.precision,this.scale=Y.scale}mapFromDriverValue(X){if(typeof X==="number")return X;return Number(X)}mapToDriverValue(X){return String(X)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}},Q8=class extends K{static[J]="PgNumericBigIntBuilder";constructor(X,Y,Z){super(X,"bigint int64","PgNumericBigInt");this.config.precision=Y,this.config.scale=Z}build(X){return new P8(X,this.config)}},P8=class extends V{static[J]="PgNumericBigInt";precision;scale;constructor(X,Y){super(X,Y);this.precision=Y.precision,this.scale=Y.scale}mapFromDriverValue(X){return BigInt(X)}mapToDriverValue(X){return String(X)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}};function XZ(X,Y){let{name:Z,config:$}=k(X,Y),G=$?.mode;return G==="number"?new R8(Z,$?.precision,$?.scale):G==="bigint"?new Q8(Z,$?.precision,$?.scale):new k8(Z,$?.precision,$?.scale)}var L8=class extends K{static[J]="PgPointTupleBuilder";constructor(X){super(X,"array point","PgPointTuple")}build(X){return new B8(X,this.config)}},B8=class extends V{static[J]="PgPointTuple";mode="tuple";getSQLType(){return"point"}mapFromDriverValue(X){if(typeof X==="string"){let[Y,Z]=X.slice(1,-1).split(",");return[Number.parseFloat(Y),Number.parseFloat(Z)]}return[X.x,X.y]}mapToDriverValue(X){return`(${X[0]},${X[1]})`}},j8=class extends K{static[J]="PgPointObjectBuilder";constructor(X){super(X,"object point","PgPointObject")}build(X){return new T8(X,this.config)}},T8=class extends V{static[J]="PgPointObject";mode="xy";getSQLType(){return"point"}mapFromDriverValue(X){if(typeof X==="string"){let[Y,Z]=X.slice(1,-1).split(",");return{x:Number.parseFloat(Y),y:Number.parseFloat(Z)}}return X}mapToDriverValue(X){return`(${X.x},${X.y})`}};function YZ(X,Y){let{name:Z,config:$}=k(X,Y);if(!$?.mode||$.mode==="tuple")return new L8(Z);return new j8(Z)}function S8(X){let Y=[];for(let Z=0;Z<X.length;Z+=2)Y.push(Number.parseInt(X.slice(Z,Z+2),16));return new Uint8Array(Y)}function ZZ(X,Y){let $=new DataView(new ArrayBuffer(8));for(let G=0;G<8;G++)$.setUint8(G,X[Y+G]);return $.getFloat64(0,!0)}function yX(X){let Y=S8(X),Z=0,$=Y[Z];Z+=1;let G=new DataView(Y.buffer),H=G.getUint32(Z,$===1);Z+=4;let _;if(H&536870912)_=G.getUint32(Z,$===1),Z+=4;if((H&65535)===1){let z=ZZ(Y,Z);Z+=8;let O=ZZ(Y,Z);return Z+=8,{srid:_,point:[z,O]}}throw Error("Unsupported geometry type")}var C8=class extends K{static[J]="PgGeometryBuilder";constructor(X,Y){super(X,"array geometry","PgGeometry");this.config.srid=Y}build(X){return new q8(X,this.config)}},q8=class extends V{static[J]="PgGeometry";srid=this.config.srid;mode="tuple";getSQLType(){return`geometry(point${this.srid===void 0?"":`,${this.srid}`})`}mapFromDriverValue(X){if(typeof X!=="string")return X;return yX(X).point}mapToDriverValue(X){return`point(${X[0]} ${X[1]})`}},v8=class extends K{static[J]="PgGeometryObjectBuilder";constructor(X,Y){super(X,"object geometry","PgGeometryObject");this.config.srid=Y}build(X){return new h8(X,this.config)}},h8=class extends V{static[J]="PgGeometryObject";srid=this.config.srid;mode="object";getSQLType(){return`geometry(point${this.srid===void 0?"":`,${this.srid}`})`}mapFromDriverValue(X){let Y=yX(X);return{x:Y.point[0],y:Y.point[1]}}mapToDriverValue(X){return`point(${X.x} ${X.y})`}};function $Z(X,Y){let{name:Z,config:$}=k(X,Y);if(!$?.mode||$.mode==="tuple")return new C8(Z,$?.srid);return new v8(Z,$?.srid)}var p8=class extends K{static[J]="PgRealBuilder";constructor(X,Y){super(X,"number float","PgReal");this.config.length=Y}build(X){return new y8(X,this.config)}},y8=class extends V{static[J]="PgReal";constructor(X,Y){super(X,Y)}getSQLType(){return"real"}mapFromDriverValue(X){if(typeof X==="string")return Number.parseFloat(X);return X}};function GZ(X){return new p8(X??"")}var f8=class extends K{static[J]="PgSerialBuilder";constructor(X){super(X,"number int32","PgSerial");this.config.hasDefault=!0,this.config.notNull=!0}build(X){return new b8(X,this.config)}},b8=class extends V{static[J]="PgSerial";getSQLType(){return"serial"}};function WZ(X){return new f8(X??"")}var d8=class extends O1{static[J]="PgSmallIntBuilder";constructor(X){super(X,"number int16","PgSmallInt")}build(X){return new g8(X,this.config)}},g8=class extends V{static[J]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue(X){if(typeof X==="string")return Number(X);return X}};function JZ(X){return new d8(X??"")}var m8=class extends K{static[J]="PgSmallSerialBuilder";constructor(X){super(X,"number int16","PgSmallSerial");this.config.hasDefault=!0,this.config.notNull=!0}build(X){return new c8(X,this.config)}},c8=class extends V{static[J]="PgSmallSerial";getSQLType(){return"smallserial"}};function HZ(X){return new m8(X??"")}var u8=class extends K{static[J]="PgTextBuilder";constructor(X,Y){super(X,Y.enum?.length?"string enum":"string","PgText");this.config.enumValues=Y.enum}build(X){return new r8(X,this.config,this.config.enumValues)}},r8=class extends V{static[J]="PgText";enumValues;constructor(X,Y,Z){super(X,Y);this.enumValues=Z}getSQLType(){return"text"}};function _Z(X,Y={}){let{name:Z,config:$}=k(X,Y);return new u8(Z,$)}var o8=class extends F1{static[J]="PgTimeBuilder";constructor(X,Y,Z){super(X,"string time","PgTime");this.withTimezone=Y,this.precision=Z,this.config.withTimezone=Y,this.config.precision=Z}build(X){return new s8(X,this.config)}},s8=class extends V{static[J]="PgTime";withTimezone;precision;constructor(X,Y){super(X,Y);this.withTimezone=Y.withTimezone,this.precision=Y.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}};function zZ(X,Y={}){let{name:Z,config:$}=k(X,Y);return new o8(Z,$.withTimezone??!1,$.precision)}var t8=class extends F1{static[J]="PgTimestampBuilder";constructor(X,Y,Z){super(X,"object date","PgTimestamp");this.config.withTimezone=Y,this.config.precision=Z}build(X){return new n8(X,this.config)}},n8=class extends V{static[J]="PgTimestamp";withTimezone;precision;constructor(X,Y){super(X,Y);this.withTimezone=Y.withTimezone,this.precision=Y.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue(X){if(typeof X==="string")return new Date(this.withTimezone?X:X+"+0000");return X}mapToDriverValue(X){if(typeof X==="string")return X;return X.toISOString()}},i8=class extends F1{static[J]="PgTimestampStringBuilder";constructor(X,Y,Z){super(X,"string timestamp","PgTimestampString");this.config.withTimezone=Y,this.config.precision=Z}build(X){return new l8(X,this.config)}},l8=class extends V{static[J]="PgTimestampString";withTimezone;precision;constructor(X,Y){super(X,Y);this.withTimezone=Y.withTimezone,this.precision=Y.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue(X){if(typeof X==="string")return X;let Y=X.toISOString().slice(0,-1).replace("T"," ");if(this.withTimezone)return`${Y}+00`;return Y}mapToDriverValue(X){if(typeof X==="string")return X;return X.toISOString()}};function EZ(X,Y={}){let{name:Z,config:$}=k(X,Y);if($?.mode==="string")return new i8(Z,$.withTimezone??!1,$.precision);return new t8(Z,$?.withTimezone??!1,$?.precision)}var a8=class extends K{static[J]="PgUUIDBuilder";constructor(X){super(X,"string uuid","PgUUID")}defaultRandom(){return this.default(W`gen_random_uuid()`)}build(X){return new e8(X,this.config)}},e8=class extends V{static[J]="PgUUID";getSQLType(){return"uuid"}};function DZ(X){return new a8(X??"")}var X2=class extends K{static[J]="PgVarcharBuilder";constructor(X,Y){super(X,Y.enum?.length?"string enum":"string","PgVarchar");this.config.length=Y.length,this.config.enumValues=Y.enum}build(X){return new Y2(X,this.config)}},Y2=class extends V{static[J]="PgVarchar";enumValues;constructor(X,Y){super(X,Y);this.enumValues=Y.enumValues}getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}};function OZ(X,Y={}){let{name:Z,config:$}=k(X,Y);return new X2(Z,$)}var Z2=class extends K{static[J]="PgBinaryVectorBuilder";constructor(X,Y){super(X,"string binary","PgBinaryVector");this.config.length=Y.dimensions,this.config.isLengthExact=!0}build(X){return new $2(X,this.config)}},$2=class extends V{static[J]="PgBinaryVector";getSQLType(){return`bit(${this.length})`}};function FZ(X,Y){let{name:Z,config:$}=k(X,Y);return new Z2(Z,$)}var G2=class extends K{static[J]="PgHalfVectorBuilder";constructor(X,Y){super(X,"array halfvector","PgHalfVector");this.config.length=Y.dimensions,this.config.isLengthExact=!0}build(X){return new W2(X,this.config)}},W2=class extends V{static[J]="PgHalfVector";getSQLType(){return`halfvec(${this.length})`}mapToDriverValue(X){return JSON.stringify(X)}mapFromDriverValue(X){return X.slice(1,-1).split(",").map((Y)=>Number.parseFloat(Y))}};function UZ(X,Y){let{name:Z,config:$}=k(X,Y);return new G2(Z,$)}var J2=class extends K{static[J]="PgSparseVectorBuilder";constructor(X,Y){super(X,"string sparsevec","PgSparseVector");this.config.vectorDimensions=Y.dimensions}build(X){return new H2(X,this.config)}},H2=class extends V{static[J]="PgSparseVector";vectorDimensions=this.config.vectorDimensions;getSQLType(){return`sparsevec(${this.vectorDimensions})`}};function AZ(X,Y){let{name:Z,config:$}=k(X,Y);return new J2(Z,$)}var _2=class extends K{static[J]="PgVectorBuilder";constructor(X,Y){super(X,"array vector","PgVector");this.config.length=Y.dimensions,this.config.isLengthExact=!0}build(X){return new z2(X,this.config)}},z2=class extends V{static[J]="PgVector";getSQLType(){return`vector(${this.length})`}mapToDriverValue(X){return JSON.stringify(X)}mapFromDriverValue(X){return X.slice(1,-1).split(",").map((Y)=>Number.parseFloat(Y))}};function VZ(X,Y){let{name:Z,config:$}=k(X,Y);return new _2(Z,$)}function IZ(){return{bigint:fY,bigserial:bY,boolean:dY,char:gY,cidr:mY,customType:cY,date:uY,doublePrecision:rY,inet:oY,integer:sY,interval:tY,json:nY,jsonb:iY,line:lY,macaddr:aY,macaddr8:eY,numeric:XZ,point:YZ,geometry:$Z,real:GZ,serial:WZ,smallint:JZ,smallserial:HZ,text:_Z,time:zZ,timestamp:EZ,uuid:DZ,varchar:OZ,bit:FZ,halfvec:UZ,sparsevec:AZ,vector:VZ}}var fX=Symbol.for("drizzle:PgInlineForeignKeys"),bX=Symbol.for("drizzle:EnableRLS"),l1=class extends A{static[J]="PgTable";static Symbol=Object.assign({},A.Symbol,{InlineForeignKeys:fX,EnableRLS:bX});[fX]=[];[bX]=!1;[A.Symbol.ExtraConfigBuilder]=void 0;[A.Symbol.ExtraConfigColumns]={}};function MZ(X,Y,Z,$,G=X){let H=new l1(X,$,G),_=typeof Y==="function"?Y(IZ()):Y,z=Object.fromEntries(Object.entries(_).map(([U,F])=>{let M=F;M.setName(U);let I=M.build(H);return H[fX].push(...M.buildForeignKeys(I,H)),[U,I]})),O=Object.fromEntries(Object.entries(_).map(([U,F])=>{let M=F;return M.setName(U),[U,M.buildExtraConfigColumn(H)]})),E=Object.assign(H,z);if(E[A.Symbol.Columns]=z,E[A.Symbol.ExtraConfigColumns]=O,Z)E[l1.Symbol.ExtraConfigBuilder]=Z;return Object.assign(E,{enableRLS:()=>{return E[l1.Symbol.EnableRLS]=!0,E}})}var E2=(X,Y,Z)=>{return MZ(X,Y,Z,void 0)},D2=(X,Y,Z)=>{let $=MZ(X,Y,Z,void 0);return $[bX]=!0,$},GG=Object.assign(E2,{withRLS:D2});var xZ=class{static[J]="PgPrimaryKeyBuilder";columns;name;constructor(X,Y){this.columns=X,this.name=Y}build(X){return new O2(X,this.columns,this.name)}},O2=class{static[J]="PgPrimaryKey";columns;name;isNameExplicit;constructor(X,Y,Z){this.table=X,this.columns=Y,this.name=Z,this.isNameExplicit=!!Z}getName(){return this.name??`${this.table[l1.Symbol.Name]}_${this.columns.map((X)=>X.name).join("_")}_pk`}};var KZ=class{static[J]="Relation";referencedTableName;fieldName;constructor(X,Y,Z){this.sourceTable=X,this.referencedTable=Y,this.relationName=Z,this.referencedTableName=Y[A.Symbol.Name]}},F2=class{static[J]="Relations";constructor(X,Y){this.table=X,this.config=Y}},R1=class X extends KZ{static[J]="One";constructor(Y,Z,$,G){super(Y,Z,$?.relationName);this.config=$,this.isNullable=G}withFieldName(Y){let Z=new X(this.sourceTable,this.referencedTable,this.config,this.isNullable);return Z.fieldName=Y,Z}},dX=class X extends KZ{static[J]="Many";constructor(Y,Z,$){super(Y,Z,$?.relationName);this.config=$}withFieldName(Y){let Z=new X(this.sourceTable,this.referencedTable,this.config);return Z.fieldName=Y,Z}};function kZ(){return{and:m,between:u1,eq:a,exists:k1,gt:p1,gte:y1,ilike:t1,inArray:d1,isNull:m1,isNotNull:c1,like:o1,lt:f1,lte:b1,ne:h1,not:I1,notBetween:r1,notExists:N1,notLike:s1,notIlike:n1,notInArray:g1,or:V1,sql:W}}function NZ(){return{sql:W,asc:M1,desc:i1}}function RZ(X,Y){if(Object.keys(X).length===1&&"default"in X&&!D(X.default,A))X=X.default;let Z={},$={},G={};for(let[H,_]of Object.entries(X))if(D(_,A)){let z=A1(_),O=$[z];Z[z]=H,G[H]={tsName:H,dbName:_[A.Symbol.Name],schema:_[A.Symbol.Schema],columns:_[A.Symbol.Columns],relations:O?.relations??{},primaryKey:O?.primaryKey??[]};for(let U of Object.values(_[A.Symbol.Columns]))if(U.primary)G[H].primaryKey.push(U);let E=_[A.Symbol.ExtraConfigBuilder]?.(_[A.Symbol.ExtraConfigColumns]);if(E){for(let U of Object.values(E))if(D(U,xZ))G[H].primaryKey.push(...U.columns)}}else if(D(_,F2)){let z=A1(_.table),O=Z[z],E=_.config(Y(_.table));for(let[U,F]of Object.entries(E))if(O){let M=G[O];M.relations[U]=F}else{if(!(z in $))$[z]={relations:{}};$[z].relations[U]=F}}return{tables:G,tableNamesMap:Z}}function U2(X){return function(Z,$){return new R1(X,Z,$,$?.fields.reduce((G,H)=>G&&H.notNull,!0)??!1)}}function A2(X){return function(Z,$){return new dX(X,Z,$)}}function wZ(X,Y,Z){if(D(Z,R1)&&Z.config)return{fields:Z.config.fields,references:Z.config.references};let $=Y[A1(Z.referencedTable)];if(!$)throw Error(`Table "${Z.referencedTable[A.Symbol.Name]}" not found in schema`);let G=X[$];if(!G)throw Error(`Table "${$}" not found in schema`);let H=Z.sourceTable,_=Y[A1(H)];if(!_)throw Error(`Table "${H[A.Symbol.Name]}" not found in schema`);let z=[];for(let O of Object.values(G.relations))if(Z.relationName&&Z!==O&&O.relationName===Z.relationName||!Z.relationName&&O.referencedTable===Z.sourceTable)z.push(O);if(z.length>1)throw Z.relationName?Error(`There are multiple relations with name "${Z.relationName}" in table "${$}"`):Error(`There are multiple relations between "${$}" and "${Z.sourceTable[A.Symbol.Name]}". Please specify relation name`);if(z[0]&&D(z[0],R1)&&z[0].config)return{fields:z[0].config.references,references:z[0].config.fields};throw Error(`There is not enough information to infer relation "${_}.${Z.fieldName}"`)}function QZ(X){return{one:U2(X),many:A2(X)}}function OX(X,Y,Z,$,G=(H)=>H){let H={};for(let[_,z]of $.entries())if(z.isJson){let O=Y.relations[z.tsKey],E=Z[_],U=typeof E==="string"?JSON.parse(E):E;H[z.tsKey]=D(O,R1)?U&&OX(X,X[z.relationTableTsKey],U,z.selection,G):U.map((F)=>OX(X,X[z.relationTableTsKey],F,z.selection,G))}else{let O=G(Z[_]),E=z.field,U;if(D(E,N))U=E;else if(D(E,x))U=E.decoder;else U=E.sql.decoder;H[z.tsKey]=O===null?null:U.mapFromDriverValue(O)}return H}var c=class{static[J]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(X){return this.then(void 0,X)}finally(X){return this.then((Y)=>{return X?.(),Y},(Y)=>{throw X?.(),Y})}then(X,Y){return this.execute().then(X,Y)}};var LZ=class{static[J]="SQLiteAsyncRelationalQueryBuilder";constructor(X,Y,Z,$,G,H,_,z){this.mode=X,this.fullSchema=Y,this.schema=Z,this.tableNamesMap=$,this.table=G,this.tableConfig=H,this.dialect=_,this.session=z}findMany(X){return this.mode==="sync"?new PZ(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,X?X:{},"many"):new mX(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,X?X:{},"many")}findFirst(X){return this.mode==="sync"?new PZ(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,X?{...X,limit:1}:{limit:1},"first"):new mX(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,X?{...X,limit:1}:{limit:1},"first")}},mX=class extends c{static[J]="SQLiteAsyncRelationalQuery";mode;constructor(X,Y,Z,$,G,H,_,z,O){super();this.fullSchema=X,this.schema=Y,this.tableNamesMap=Z,this.table=$,this.tableConfig=G,this.dialect=H,this.session=_,this.config=z,this.mode=O}getSQL(){return this.dialect._buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}).sql}_prepare(X=!1){let{query:Y,builtQuery:Z}=this._toSQL();return this.session[X?"prepareOneTimeQuery":"prepareQuery"](Z,void 0,this.mode==="first"?"get":"all",!0,($,G)=>{let H=$.map((_)=>OX(this.schema,this.tableConfig,_,Y.selection,G));if(this.mode==="first")return H[0];return H})}prepare(){return this._prepare(!1)}_toSQL(){let X=this.dialect._buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName});return{query:X,builtQuery:this.dialect.sqlToQuery(X.sql)}}toSQL(){return this._toSQL().builtQuery}executeRaw(){if(this.mode==="first")return this._prepare(!1).get();return this._prepare(!1).all()}async execute(){return this.executeRaw()}},PZ=class extends mX{static[J]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}};var BZ=class X extends x{sql;static[J]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(Y,Z){return W`(select count(*) from ${Y}${W.raw(" where ").if(Z)}${Z})`}static buildCount(Y,Z){return W`select count(*) from ${Y}${W.raw(" where ").if(Z)}${Z}`}constructor(Y){super(X.buildEmbeddedCount(Y.source,Y.filters).queryChunks);this.params=Y,this.session=Y.session,this.sql=X.buildCount(Y.source,Y.filters)}then(Y,Z){return Promise.resolve(this.session.count(this.sql)).then(Y,Z)}catch(Y){return this.then(void 0,Y)}finally(Y){return this.then((Z)=>{return Y?.(),Z},(Z)=>{throw Y?.(),Z})}};var w1=class{static[J]="ColumnTableAliasProxyHandler";constructor(X,Y){this.table=X,this.ignoreColumnAlias=Y}get(X,Y){if(Y==="table")return this.table;if(Y==="isAlias"&&this.ignoreColumnAlias)return!1;return X[Y]}},jZ=class{static[J]="ViewSelectionAliasProxyHandler";constructor(X,Y,Z){this.view=X,this.selection=Y,this.ignoreColumnAlias=Z}get(X,Y){let Z=X[Y];if(D(Z,N))return new Proxy(Z,new w1(this.view,this.ignoreColumnAlias));if(D(Z,T)||D(Z,x)||D(Z,x.Aliased)||E1(Z)||typeof Z!=="object"||Z===null)return Z;return new Proxy(Z,this)}},FX=class{static[J]="TableAliasProxyHandler";constructor(X,Y,Z){this.alias=X,this.replaceOriginalName=Y,this.ignoreColumnAlias=Z}get(X,Y){if(Y===A.Symbol.IsAlias)return!0;if(Y===A.Symbol.Name)return this.alias;if(this.replaceOriginalName&&Y===A.Symbol.OriginalName)return this.alias;if(Y===Q)return{...X[Q],name:this.alias,isAlias:!0,selectedFields:new Proxy(X[Q].selectedFields,new jZ(new Proxy(X,this),X[Q].selectedFields,this.ignoreColumnAlias))};if(Y===A.Symbol.Columns){let $=X[A.Symbol.Columns];if(!$)return $;if(D(X,y))return new Proxy(X[A.Symbol.Columns],new jZ(new Proxy(X,this),X[A.Symbol.Columns],this.ignoreColumnAlias));let G={};return Object.keys($).map((H)=>{G[H]=new Proxy($[H],new w1(new Proxy(X,this),this.ignoreColumnAlias))}),G}let Z=X[Y];if(D(Z,N))return new Proxy(Z,new w1(new Proxy(X,this),this.ignoreColumnAlias));return Z}},V2=class{static[J]="ColumnAliasProxyHandler";constructor(X){this.alias=X}get(X,Y){if(Y==="isAlias")return!0;if(Y==="name")return this.alias;if(Y==="keyAsName")return!1;if(Y===T1)return()=>X;return X[Y]}};function Y1(X,Y){return new Proxy(X,new FX(Y,!1,!1))}function I2(X,Y){return new Proxy(X,new V2(Y))}function Z1(X,Y){return new Proxy(X,new w1(new Proxy(X.table,new FX(Y,!1,!1)),!1))}function cX(X,Y){return new x.Aliased(a1(X.sql,Y),X.fieldAlias)}function a1(X,Y){return W.join(X.queryChunks.map((Z)=>{if(D(Z,N))return Z1(Z,Y);if(D(Z,x))return a1(Z,Y);if(D(Z,x.Aliased))return cX(Z,Y);return Z}))}N.prototype.as=function(X){return I2(this,X)};function e1(X){return X[T1]()}var W1=class extends Error{static[J]="DrizzleError";constructor({message:X,cause:Y}){super(X);this.name="DrizzleError",this.cause=Y}},x1=class X extends Error{static[J]="DrizzleQueryError";constructor(Y,Z,$){super(`Failed query: ${Y}
|
|
3
|
-
params: ${Z}`);if(this.query=Y,this.params=Z,this.cause=$,Error.captureStackTrace(this,X),$)this.cause=$}},TZ=class extends W1{static[J]="TransactionRollbackError";constructor(){super({message:"Rollback"})}};var M2=class{static[J]="RelationV2";fieldName;sourceColumns;targetColumns;alias;where;sourceTable;targetTable;through;throughTable;isReversed;sourceColumnTableNames=[];targetColumnTableNames=[];constructor(X,Y){this.targetTableName=Y,this.targetTable=X}},SZ=class extends M2{static[J]="OneV2";relationType="one";optional;constructor(X,Y,Z,$){super(Y,Z);if(this.alias=$?.alias,this.where=$?.where,$?.from)this.sourceColumns=(Array.isArray($.from)?$.from:[$.from]).map((G)=>{return this.throughTable??=G._.through?X[G._.through._.tableName]:void 0,this.sourceColumnTableNames.push(G._.tableName),G._.column});if($?.to)this.targetColumns=(Array.isArray($.to)?$.to:[$.to]).map((G)=>{return this.throughTable??=G._.through?X[G._.through._.tableName]:void 0,this.targetColumnTableNames.push(G._.tableName),G._.column});if(this.throughTable)this.through={source:(Array.isArray($?.from)?$.from:($?.from)?[$.from]:[]).map((G)=>G._.through),target:(Array.isArray($?.to)?$.to:($?.to)?[$.to]:[]).map((G)=>G._.through)};this.optional=$?.optional??!0}};var Q1={and:m,between:u1,eq:a,exists:k1,gt:p1,gte:y1,ilike:t1,inArray:d1,arrayContains:qX,arrayContained:vX,arrayOverlaps:hX,isNull:m1,isNotNull:c1,like:o1,lt:f1,lte:b1,ne:h1,not:I1,notBetween:r1,notExists:N1,notLike:s1,notIlike:n1,notInArray:g1,or:V1,sql:W},x2={sql:W,asc:M1,desc:i1};function AX(X,Y,Z=(_)=>_,$=!1,G=!1,H){for(let _ of Y){if(_.selection){let U=`${H?`${H}.`:""}${_.key}`;if(X[_.key]===null)continue;if($){if(X[_.key]=JSON.parse(X[_.key]),X[_.key]===null)continue}if(G&&typeof X[_.key]==="string")X[_.key]=JSON.parse(X[_.key]);if(_.isArray){for(let F of X[_.key])AX(F,_.selection,Z,!1,G,U);continue}AX(X[_.key],_.selection,Z,!1,G,U);continue}let z=_.field,O=Z(X[_.key]);if(O===null)continue;let E;if(D(z,N))E=z;else if(D(z,x))E=z.decoder;else if(D(z,x.Aliased))E=z.sql.decoder;else if(D(z,A)||D(z,y))E=C1;else E=z.getSQL().decoder;X[_.key]="mapFromJsonValue"in E?E.mapFromJsonValue(O):E.mapFromDriverValue(O)}return X}function CZ(X,Y){let Z=X[n][Y];return Z?D(Z,N)?Z:D(Z,x.Aliased)?W`${X}.${W.identifier(Z.fieldAlias)}`:W`${X}.${W.identifier(Y)}`:W`${X}.${W.identifier(Y)}`}function UX(X,Y){if(typeof Y!=="object"||D(Y,l))return a(X,Y);let Z=Object.entries(Y);if(!Z.length)return;let $=[];for(let[G,H]of Z){if(H===void 0)continue;switch(G){case"NOT":{let _=UX(X,H);if(!_)continue;$.push(I1(_));continue}case"OR":if(!H.length)continue;$.push(V1(...H.map((_)=>UX(X,_))));continue;case"AND":if(!H.length)continue;$.push(m(...H.map((_)=>UX(X,_))));continue;case"isNotNull":case"isNull":if(!H)continue;$.push(Q1[G](X));continue;case"in":$.push(Q1.inArray(X,H));continue;case"notIn":$.push(Q1.notInArray(X,H));continue;default:$.push(Q1[G](X,H));continue}}if(!$.length)return;return m(...$)}function J1(X,Y,Z={},$={},G,H=0){let _=Object.entries(Y);if(!_.length)return;let z=[];for(let[O,E]of _){if(E===void 0)continue;switch(O){case"RAW":{let U=typeof E==="function"?E(X,Q1):E.getSQL();z.push(U);continue}case"OR":if(!E?.length)continue;z.push(V1(...E.map((U)=>J1(X,U,Z,$,G,H))));continue;case"AND":if(!E?.length)continue;z.push(m(...E.map((U)=>J1(X,U,Z,$,G,H))));continue;case"NOT":{if(E===void 0)continue;let U=J1(X,E,Z,$,G,H);if(!U)continue;z.push(I1(U));continue}default:{if(X[n][O]){let R=UX(CZ(X,O),E);if(R)z.push(R);continue}let U=Z[O];if(!U)throw new W1({message:`Unknown relational filter field: "${O}"`});let F=Y1(U.targetTable,`f${H}`),M=U.throughTable?Y1(U.throughTable,`ft${H}`):void 0,I=$[U.targetTableName],{filter:L,joinCondition:P}=uX(G,U,X,F,M),B=m(L,typeof E==="boolean"?void 0:J1(F,E,I.relations,$,G,H+1)),d=M?W`(select * from ${P1(F)} inner join ${P1(M)} on ${P}${W` where ${B}`.if(B)} limit 1)`:W`(select * from ${P1(F)}${W` where ${B}`.if(B)} limit 1)`;if(B)z.push((E?k1:N1)(d))}}}return m(...z)}function qZ(X,Y){if(typeof Y==="function"){let $=Y(X,x2);return D($,x)?$:Array.isArray($)?$.length?W.join($.map((G)=>D(G,x)?G:M1(G)),W`, `):void 0:D($,N)?M1($):void 0}let Z=Object.entries(Y).filter(([$,G])=>G);if(!Z.length)return;return W.join(Z.map(([$,G])=>(G==="asc"?M1:i1)(CZ(X,$))),W`, `)}function vZ(X,Y){let Z=[],$=[];for(let[G,H]of Object.entries(Y)){if(!H)continue;let _=typeof H==="function"?H(X,{sql:Q1.sql}):H,z=W`(${_.getSQL()}) as ${W.identifier(G)}`;z.decoder=_.getSQL().decoder,Z.push(z),$.push({key:G,field:z})}return{sql:Z.length?W.join(Z,W`, `):void 0,selection:$}}function uX(X,Y,Z,$,G){if(Y.through){let H=Y.sourceColumns.map((z,O)=>{let E=Y.through.source[O];return a(W`${Z}.${W.identifier(X.getColumnCasing(z))}`,W`${G}.${W.identifier(D(E._.column,N)?X.getColumnCasing(E._.column):E._.key)}`)}),_=Y.targetColumns.map((z,O)=>{let E=Y.through.target[O];return a(W`${G}.${W.identifier(D(E._.column,N)?X.getColumnCasing(E._.column):E._.key)}`,W`${$}.${W.identifier(X.getColumnCasing(z))}`)});return{filter:m(Y.where?J1(Y.isReversed?Z:$,Y.where):void 0,...H),joinCondition:m(..._)}}return{filter:m(...Y.sourceColumns.map((H,_)=>{let z=Y.targetColumns[_];return a(W`${Z}.${W.identifier(X.getColumnCasing(H))}`,W`${$}.${W.identifier(X.getColumnCasing(z))}`)}),Y.where?J1(Y.isReversed?Z:$,Y.where):void 0)}}function P1(X){return W`${X[_1]?W`${W`${W.identifier(X[G1]??"")}.`.if(X[G1])}${W.identifier(X[U1])} as ${X}`:X}`}var pZ=class{static[J]="SQLiteAsyncRelationalQueryBuilderV2";constructor(X,Y,Z,$,G,H,_,z){this.mode=X,this.schema=Y,this.table=Z,this.tableConfig=$,this.dialect=G,this.session=H,this.rowMode=_,this.forbidJsonb=z}findMany(X){return this.mode==="sync"?new hZ(this.schema,this.table,this.tableConfig,this.dialect,this.session,X??!0,"many",this.rowMode,this.forbidJsonb):new rX(this.schema,this.table,this.tableConfig,this.dialect,this.session,X??!0,"many",this.rowMode,this.forbidJsonb)}findFirst(X){return this.mode==="sync"?new hZ(this.schema,this.table,this.tableConfig,this.dialect,this.session,X??!0,"first",this.rowMode,this.forbidJsonb):new rX(this.schema,this.table,this.tableConfig,this.dialect,this.session,X??!0,"first",this.rowMode,this.forbidJsonb)}},rX=class extends c{static[J]="SQLiteAsyncRelationalQueryV2";mode;table;constructor(X,Y,Z,$,G,H,_,z,O){super();this.schema=X,this.tableConfig=Z,this.dialect=$,this.session=G,this.config=H,this.rowMode=z,this.forbidJsonb=O,this.mode=_,this.table=Y}getSQL(){return this.dialect.buildRelationalQuery({schema:this.schema,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,mode:this.mode,jsonb:this.forbidJsonb?W`json`:W`jsonb`}).sql}_prepare(X=!0){let{query:Y,builtQuery:Z}=this._toSQL();return this.session[X?"prepareOneTimeRelationalQuery":"prepareRelationalQuery"](Z,void 0,this.mode==="first"?"get":"all",($,G)=>{let H=$.map((_)=>AX(_,Y.selection,G,!this.rowMode));if(this.mode==="first")return H[0];return H})}prepare(){return this._prepare(!1)}_getQuery(){let X=this.forbidJsonb?W`json`:W`jsonb`,Y=this.dialect.buildRelationalQuery({schema:this.schema,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,mode:this.mode,isNested:this.rowMode,jsonb:X});if(this.rowMode)Y.sql=W`select json_object(${W.join(Y.selection.map((Z)=>{return W`${W.raw(this.dialect.escapeString(Z.key))}, ${Z.selection?W`${X}(${W.identifier(Z.key)})`:W.identifier(Z.key)}`}),W`, `)}) as ${W.identifier("r")} from (${Y.sql}) as ${W.identifier("t")}`;return Y}_toSQL(){let X=this._getQuery();return{query:X,builtQuery:this.dialect.sqlToQuery(X.sql)}}toSQL(){return this._toSQL().builtQuery}executeRaw(){if(this.mode==="first")return this._prepare().get();return this._prepare().all()}async execute(){return this.executeRaw()}},hZ=class extends rX{static[J]="SQLiteSyncRelationalQueryV2";sync(){return this.executeRaw()}};var XX=class extends c{static[J]="SQLiteRaw";config;constructor(X,Y,Z,$,G){super();this.execute=X,this.getSQL=Y,this.dialect=$,this.mapBatchResult=G,this.config={action:Z}}getQuery(){return{...this.dialect.sqlToQuery(this.getSQL()),method:this.config.action}}mapResult(X,Y){return Y?this.mapBatchResult(X):X}_prepare(){return this}isResponseInArrayMode(){return!1}};var b=class X{static[J]="SelectionProxyHandler";config;constructor(Y){this.config={...Y}}get(Y,Z){if(Z==="_")return{...Y._,selectedFields:new Proxy(Y._.selectedFields,this)};if(Z===Q)return{...Y[Q],selectedFields:new Proxy(Y[Q].selectedFields,this)};if(typeof Z==="symbol")return Y[Z];let $=(D(Y,T)?Y._.selectedFields:D(Y,y)?Y[Q].selectedFields:Y)[Z];if(D($,x.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!$.isSelectionField)return $.sql;let G=$.clone();return G.isSelectionField=!0,G.origin=this.config.alias,G}if(D($,x)){if(this.config.sqlBehavior==="sql")return $;throw Error(`You tried to reference "${Z}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(D($,N)){if(this.config.alias)return new Proxy($,new w1(new Proxy($.table,new FX(this.config.alias,this.config.replaceOriginalName??!1,!0)),!0));return $}if(typeof $!=="object"||$===null)return $;return new Proxy($,new X(this.config))}};function e(X){if(D(X,v))return[`${X[A.Symbol.BaseName]}`];if(D(X,T))return X._.usedTables??[];if(D(X,x))return X.usedTables??[];return[]}var VX=class extends c{static[J]="SQLiteDelete";config;constructor(X,Y,Z,$){super();this.table=X,this.session=Y,this.dialect=Z,this.config={table:X,withList:$}}where(X){return this.config.where=X,this}orderBy(...X){if(typeof X[0]==="function"){let Y=X[0](new Proxy(this.config.table[A.Symbol.Columns],new b({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),Z=Array.isArray(Y)?Y:[Y];this.config.orderBy=Z}else{let Y=X;this.config.orderBy=Y}return this}limit(X){return this.config.limit=X,this}returning(X=this.table[v.Symbol.Columns]){return this.config.returning=i(X),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:X,...Y}=this.dialect.sqlToQuery(this.getSQL());return Y}_prepare(X=!0){return this.session[X?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"delete",tables:e(this.config.table)})}prepare(){return this._prepare(!1)}run=(X)=>{return this._prepare().run(X)};all=(X)=>{return this._prepare().all(X)};get=(X)=>{return this._prepare().get(X)};values=(X)=>{return this._prepare().values(X)};async execute(X){return this._prepare().execute(X)}$dynamic(){return this}};var L1=class extends y{static[J]="SQLiteViewBase"};var yZ=class{static[J]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}};var X1=class{static[J]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(X){this.fields=X.fields,this.session=X.session,this.dialect=X.dialect,this.withList=X.withList,this.distinct=X.distinct}from(X){let Y=!!this.fields,Z;if(this.fields)Z=this.fields;else if(D(X,T))Z=Object.fromEntries(Object.keys(X._.selectedFields).map(($)=>[$,X[$]]));else if(D(X,L1))Z=X[Q].selectedFields;else if(D(X,x))Z={};else Z=EY(X);return new oX({table:X,fields:Z,isPartialSelect:Y,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}},fZ=class extends yZ{static[J]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:X,fields:Y,isPartialSelect:Z,session:$,dialect:G,withList:H,distinct:_}){super();this.config={withList:H,table:X,fields:{...Y},distinct:_,setOperators:[]},this.isPartialSelect=Z,this.session=$,this.dialect=G,this._={selectedFields:Y,config:this.config},this.tableName=v1(X),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let z of e(X))this.usedTables.add(z)}getUsedTables(){return[...this.usedTables]}createJoin(X){return(Y,Z)=>{let $=this.tableName,G=v1(Y);for(let H of e(Y))this.usedTables.add(H);if(typeof G==="string"&&this.config.joins?.some((H)=>H.alias===G))throw Error(`Alias "${G}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof $==="string")this.config.fields={[$]:this.config.fields};if(typeof G==="string"&&!D(Y,x)){let H=D(Y,T)?Y._.selectedFields:D(Y,y)?Y[Q].selectedFields:Y[A.Symbol.Columns];this.config.fields[G]=H}}if(typeof Z==="function")Z=Z(new Proxy(this.config.fields,new b({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:Z,table:Y,joinType:X,alias:G}),typeof G==="string")switch(X){case"left":this.joinsNotNullableMap[G]=!1;break;case"right":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([H])=>[H,!1])),this.joinsNotNullableMap[G]=!0;break;case"cross":case"inner":this.joinsNotNullableMap[G]=!0;break;case"full":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([H])=>[H,!1])),this.joinsNotNullableMap[G]=!1;break}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator(X,Y){return(Z)=>{let $=typeof Z==="function"?Z(K2()):Z;if(!q1(this.getSelectedFields(),$.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:X,isAll:Y,rightSelect:$}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators(X){return this.config.setOperators.push(...X),this}where(X){if(typeof X==="function")X=X(new Proxy(this.config.fields,new b({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=X,this}having(X){if(typeof X==="function")X=X(new Proxy(this.config.fields,new b({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=X,this}groupBy(...X){if(typeof X[0]==="function"){let Y=X[0](new Proxy(this.config.fields,new b({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(Y)?Y:[Y]}else this.config.groupBy=X;return this}orderBy(...X){if(typeof X[0]==="function"){let Y=X[0](new Proxy(this.config.fields,new b({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),Z=Array.isArray(Y)?Y:[Y];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=Z;else this.config.orderBy=Z}else{let Y=X;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=Y;else this.config.orderBy=Y}return this}limit(X){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=X;else this.config.limit=X;return this}offset(X){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=X;else this.config.offset=X;return this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:X,...Y}=this.dialect.sqlToQuery(this.getSQL());return Y}as(X){let Y=[];if(Y.push(...e(this.config.table)),this.config.joins)for(let Z of this.config.joins)Y.push(...e(Z.table));return new Proxy(new T(this.getSQL(),this.config.fields,X,!1,[...new Set(Y)]),new b({alias:X,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new b({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}},oX=class extends fZ{static[J]="SQLiteSelect";_prepare(X=!0){if(!this.session)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let Y=i(this.config.fields),Z=this.session[X?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),Y,"all",!0,void 0,{type:"select",tables:[...this.usedTables]},this.cacheConfig);return Z.joinsNotNullableMap=this.joinsNotNullableMap,Z}$withCache(X){return this.cacheConfig=X===void 0?{config:{},enabled:!0,autoInvalidate:!0}:X===!1?{enabled:!1}:{enabled:!0,autoInvalidate:!0,...X},this}prepare(){return this._prepare(!1)}run=(X)=>{return this._prepare().run(X)};all=(X)=>{return this._prepare().all(X)};get=(X)=>{return this._prepare().get(X)};values=(X)=>{return this._prepare().values(X)};async execute(){return this.all()}};zY(oX,[c]);function IX(X,Y){return(Z,$,...G)=>{let H=[$,...G].map((_)=>({type:X,isAll:Y,rightSelect:_}));for(let _ of H)if(!q1(Z.getSelectedFields(),_.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return Z.addSetOperators(H)}}var K2=()=>({union:bZ,unionAll:dZ,intersect:gZ,except:mZ}),bZ=IX("union",!1),dZ=IX("union",!0),gZ=IX("intersect",!1),mZ=IX("except",!1);function _J(X){let Y=parseInt(X.slice(0,4),10),Z=parseInt(X.slice(4,6),10)-1,$=parseInt(X.slice(6,8),10),G=parseInt(X.slice(8,10),10),H=parseInt(X.slice(10,12),10),_=parseInt(X.slice(12,14),10);return Date.UTC(Y,Z,$,G,H,_)}function cZ(X){let{localMigrations:Y,dbMigrations:Z}=X,$=new Set(Z.map((G)=>G.name).filter((G)=>G!==null));return Y.filter((G)=>!G.name||!$.has(G.name))}var uZ=1;function k2(X){if(X.includes("name"))return 1;return 0}function sX(X,Y,Z=()=>[]){let $=X.all(Y);if($.length===0)return[];if(Array.isArray($[0]))return $.map((G)=>Z(G));return $}function rZ(X,Y,Z){if(sX(Y,W`SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ${X}`,(G)=>({"1":G[0]})).length===0)return{newDb:!0};let $=k2(sX(Y,W`SELECT name as column_name FROM pragma_table_info(${X})`,(G)=>({column_name:G[0]})).map((G)=>G.column_name));for(let G=$;G<uZ;G++){let H=N2[G];if(!H)throw Error(`No upgrade path from migration table version ${G} to ${G+1}`);H(X,Y,Z)}return{prevVersion:$,currentVersion:uZ}}var N2={0:(X,Y,Z)=>{let $=W`${W.identifier(X)}`,G=sX(Y,W`SELECT id, hash, created_at FROM ${$} ORDER BY id ASC`,(E)=>({id:E[0],hash:E[1],created_at:E[2]}));Z.sort((E,U)=>E.folderMillis!==U.folderMillis?E.folderMillis-U.folderMillis:(E.name??"").localeCompare(U.name??""));let H=new Map,_=new Map;for(let E of Z){if(!H.has(E.folderMillis))H.set(E.folderMillis,[]);H.get(E.folderMillis).push(E),_.set(E.hash,E)}let z=[],O=[];for(let E of G){let U=String(E.created_at),F=Number(U.substring(0,U.length-3)+"000"),M=H.get(F),I,L=null;if(M&&M.length===1)I=M[0],L="millis";else if(M&&M.length>1){if(I=M.find((P)=>P.hash&&E.hash&&P.hash===E.hash),I)L="hash"}else if(I=_.get(E.hash),I)L="hash";if(I)z.push({id:E.id,name:I.name,hash:E.hash,created_at:U,matchedBy:E.id?"id":L});else O.push(E)}if(O.length>0)throw Error(`While upgrading your database migrations table we found ${O.length} (${O.map((E)=>`[id: ${E.id}, created_at: ${E.created_at}]`).join(", ")}) migrations in the database that do not match any local migration. This means that some migrations were applied to the database but are missing from the local environment`);Y.transaction((E)=>{E.run(W`ALTER TABLE ${$} ADD COLUMN ${W.identifier("name")} text`),E.run(W`ALTER TABLE ${$} ADD COLUMN ${W.identifier("applied_at")} TEXT`);for(let U of z){let F=W`UPDATE ${$} SET ${W.identifier("name")} = ${U.name}, ${W.identifier("applied_at")} = NULL WHERE`;if(U.id)F.append(W` ${W.identifier("id")} = ${U.id}`);else if(U.matchedBy==="millis")F.append(W` ${W.identifier("created_at")} = ${U.created_at}`);else F.append(W` ${W.identifier("hash")} = ${U.hash}`);E.run(F)}})}};function R2(X){return(X.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((Y)=>Y.toLowerCase()).join("_")}function w2(X){return(X.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((Y,Z,$)=>{return Y+($===0?Z.toLowerCase():`${Z[0].toUpperCase()}${Z.slice(1)}`)},"")}function Q2(X){return X}var oZ=class{static[J]="CasingCache";cache={};cachedTables={};convert;constructor(X){this.convert=X==="snake_case"?R2:X==="camelCase"?w2:Q2}getColumnCasing(X){if(!X.keyAsName)return X.name;let Y=`${X.table[A.Symbol.Schema]??"public"}.${X.table[A.Symbol.OriginalName]}.${X.name}`;if(!this.cache[Y])this.cacheTable(X.table);return this.cache[Y]}cacheTable(X){let Y=`${X[A.Symbol.Schema]??"public"}.${X[A.Symbol.OriginalName]}`;if(!this.cachedTables[Y]){for(let Z of Object.values(X[A.Symbol.Columns])){if(!D(Z,N))continue;let $=`${Y}.${Z.name}`;this.cache[$]=this.convert(Z.name)}this.cachedTables[Y]=!0}}clearCache(){this.cache={},this.cachedTables={}}};var MX=class{static[J]="SQLiteDialect";casing;constructor(X){this.casing=new oZ(X?.casing)}escapeName(X){return`"${X}"`}escapeParam(X){return"?"}escapeString(X){return`'${X.replace(/'/g,"''")}'`}buildWithCTE(X){if(!X?.length)return;let Y=[W`with `];for(let[Z,$]of X.entries())if(Y.push(W`${W.identifier($._.alias)} as (${$._.sql})`),Z<X.length-1)Y.push(W`, `);return Y.push(W` `),W.join(Y)}buildDeleteQuery({table:X,where:Y,returning:Z,withList:$,limit:G,orderBy:H}){let _=this.buildWithCTE($),z=Z?W` returning ${this.buildSelection(Z,{isSingleTable:!0})}`:void 0;return W`${_}delete from ${X}${Y?W` where ${Y}`:void 0}${z}${this.buildOrderBy(H)}${this.buildLimit(G)}`}buildUpdateSet(X,Y){let Z=X[A.Symbol.Columns],$=Object.keys(Z).filter((H)=>Y[H]!==void 0||Z[H]?.onUpdateFn!==void 0),G=$.length;return W.join($.flatMap((H,_)=>{let z=Z[H],O=z.onUpdateFn?.(),E=Y[H]??(D(O,x)?O:W.param(O,z)),U=W`${W.identifier(this.casing.getColumnCasing(z))} = ${E}`;if(_<G-1)return[U,W.raw(", ")];return[U]}))}buildUpdateQuery({table:X,set:Y,where:Z,returning:$,withList:G,joins:H,from:_,limit:z,orderBy:O}){let E=this.buildWithCTE(G),U=this.buildUpdateSet(X,Y),F=_&&W.join([W.raw(" from "),this.buildFromTable(_)]),M=this.buildJoins(H),I=$?W` returning ${this.buildSelection($,{isSingleTable:!0})}`:void 0;return W`${E}update ${X} set ${U}${F}${M}${Z?W` where ${Z}`:void 0}${I}${this.buildOrderBy(O)}${this.buildLimit(z)}`}buildSelection(X,{isSingleTable:Y=!1}={}){let Z=X.length,$=X.flatMap(({field:G},H)=>{let _=[];if(D(G,x.Aliased)&&G.isSelectionField){if(!Y&&G.origin!==void 0)_.push(W.identifier(G.origin),W.raw("."));_.push(W.identifier(G.fieldAlias))}else if(D(G,x.Aliased)||D(G,x)){let z=D(G,x.Aliased)?G.sql:G;if(Y){let O=new x(z.queryChunks.map((E)=>{if(D(E,N))return W.identifier(this.casing.getColumnCasing(E));return E}));_.push(z.shouldInlineParams?O.inlineParams():O)}else _.push(z);if(D(G,x.Aliased))_.push(W` as ${W.identifier(G.fieldAlias)}`)}else if(D(G,N))if(G.columnType==="SQLiteNumericBigInt")if(Y)_.push(G.isAlias?W`cast(${W.identifier(this.casing.getColumnCasing(e1(G)))} as text) as ${G}`:W`cast(${W.identifier(this.casing.getColumnCasing(G))} as text)`);else _.push(G.isAlias?W`cast(${e1(G)} as text) as ${G}`:W`cast(${G} as text)`);else if(Y)_.push(G.isAlias?W`${W.identifier(this.casing.getColumnCasing(e1(G)))} as ${G}`:W.identifier(this.casing.getColumnCasing(G)));else _.push(G.isAlias?W`${e1(G)} as ${G}`:G);else if(D(G,T)){let z=Object.entries(G._.selectedFields);if(z.length===1){let O=z[0][1],E=D(O,x)?O.decoder:D(O,N)?{mapFromDriverValue:(U)=>O.mapFromDriverValue(U)}:O.sql.decoder;if(E)G._.sql.decoder=E}_.push(G)}if(H<Z-1)_.push(W`, `);return _});return W.join($)}buildJoins(X){if(!X||X.length===0)return;let Y=[];if(X)for(let[Z,$]of X.entries()){if(Z===0)Y.push(W` `);let G=$.table,H=$.on?W` on ${$.on}`:void 0;if(D(G,v)){let _=G[v.Symbol.Name],z=G[v.Symbol.Schema],O=G[v.Symbol.OriginalName],E=_===O?void 0:$.alias;Y.push(W`${W.raw($.joinType)} join ${z?W`${W.identifier(z)}.`:void 0}${W.identifier(O)}${E&&W` ${W.identifier(E)}`}${H}`)}else Y.push(W`${W.raw($.joinType)} join ${G}${H}`);if(Z<X.length-1)Y.push(W` `)}return W.join(Y)}buildLimit(X){return typeof X==="object"||typeof X==="number"&&X>=0?W` limit ${X}`:void 0}buildOrderBy(X){let Y=[];if(X){for(let[Z,$]of X.entries())if(Y.push($),Z<X.length-1)Y.push(W`, `)}return Y.length>0?W` order by ${W.join(Y)}`:void 0}buildFromTable(X){if(D(X,A)&&X[A.Symbol.IsAlias])return W`${W`${W.identifier(X[A.Symbol.Schema]??"")}.`.if(X[A.Symbol.Schema])}${W.identifier(X[A.Symbol.OriginalName])} ${W.identifier(X[A.Symbol.Name])}`;if(D(X,y)&&X[Q].isAlias){let Y=W`${W.identifier(X[Q].originalName)}`;if(X[Q].schema)Y=W`${W.identifier(X[Q].schema)}.${Y}`;return W`${Y} ${W.identifier(X[Q].name)}`}return X}buildSelectQuery({withList:X,fields:Y,fieldsFlat:Z,where:$,having:G,table:H,joins:_,orderBy:z,groupBy:O,limit:E,offset:U,distinct:F,setOperators:M}){let I=Z??i(Y);for(let C of I)if(D(C.field,N)&&z1(C.field.table)!==(D(H,T)?H._.alias:D(H,L1)?H[Q].name:D(H,x)?void 0:z1(H))&&!((u)=>_?.some(({alias:t})=>t===(u[A.Symbol.IsAlias]?z1(u):u[A.Symbol.BaseName])))(C.field.table)){let u=z1(C.field.table);throw Error(`Your "${C.path.join("->")}" field references a column "${u}"."${C.field.name}", but the table "${u}" is not part of the query! Did you forget to join it?`)}let L=!_||_.length===0,P=this.buildWithCTE(X),B=F?W` distinct`:void 0,d=this.buildSelection(I,{isSingleTable:L}),R=this.buildFromTable(H),s=this.buildJoins(_),o=$?W` where ${$}`:void 0,p=G?W` having ${G}`:void 0,w=[];if(O){for(let[C,u]of O.entries())if(w.push(u),C<O.length-1)w.push(W`, `)}let j=W`${P}select${B} ${d} from ${R}${s}${o}${w.length>0?W` group by ${W.join(w)}`:void 0}${p}${this.buildOrderBy(z)}${this.buildLimit(E)}${U?W` offset ${U}`:void 0}`;if(M.length>0)return this.buildSetOperations(j,M);return j}buildSetOperations(X,Y){let[Z,...$]=Y;if(!Z)throw Error("Cannot pass undefined values to any set operator");if($.length===0)return this.buildSetOperationQuery({leftSelect:X,setOperator:Z});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:X,setOperator:Z}),$)}buildSetOperationQuery({leftSelect:X,setOperator:{type:Y,isAll:Z,rightSelect:$,limit:G,orderBy:H,offset:_}}){let z=W`${X.getSQL()} `,O=W`${$.getSQL()}`,E;if(H&&H.length>0){let I=[];for(let L of H)if(D(L,S))I.push(W.identifier(L.name));else if(D(L,x)){for(let P=0;P<L.queryChunks.length;P++){let B=L.queryChunks[P];if(D(B,S))L.queryChunks[P]=W.identifier(this.casing.getColumnCasing(B))}I.push(W`${L}`)}else I.push(W`${L}`);E=W` order by ${W.join(I,W`, `)}`}let U=typeof G==="object"||typeof G==="number"&&G>=0?W` limit ${G}`:void 0,F=W.raw(`${Y} ${Z?"all ":""}`),M=_?W` offset ${_}`:void 0;return W`${z}${F}${O}${E}${U}${M}`}buildInsertQuery({table:X,values:Y,onConflict:Z,returning:$,withList:G,select:H}){let _=[],z=X[A.Symbol.Columns],O=Object.entries(z).filter(([I,L])=>!L.shouldDisableInsert()),E=O.map(([,I])=>W.identifier(this.casing.getColumnCasing(I)));if(H){let I=Y;if(D(I,x))_.push(I);else _.push(I.getSQL())}else{let I=Y;_.push(W.raw("values "));for(let[L,P]of I.entries()){let B=[];for(let[d,R]of O){let s=P[d];if(s===void 0||D(s,g)&&s.value===void 0){let o;if(R.default!==null&&R.default!==void 0)o=D(R.default,x)?R.default:W.param(R.default,R);else if(R.defaultFn!==void 0){let p=R.defaultFn();o=D(p,x)?p:W.param(p,R)}else if(!R.default&&R.onUpdateFn!==void 0){let p=R.onUpdateFn();o=D(p,x)?p:W.param(p,R)}else o=W`null`;B.push(o)}else B.push(s)}if(_.push(B),L<I.length-1)_.push(W`, `)}}let U=this.buildWithCTE(G),F=W.join(_),M=$?W` returning ${this.buildSelection($,{isSingleTable:!0})}`:void 0;return W`${U}insert into ${X} ${E} ${F}${Z?.length?W.join(Z):void 0}${M}`}sqlToQuery(X,Y){return X.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:Y})}_buildRelationalQuery({fullSchema:X,schema:Y,tableNamesMap:Z,table:$,tableConfig:G,queryConfig:H,tableAlias:_,nestedQueryRelation:z,joinOn:O}){let E=[],U,F,M=[],I,L=[];if(H===!0)E=Object.entries(G.columns).map(([B,d])=>({dbKey:d.name,tsKey:B,field:Z1(d,_),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let B=Object.fromEntries(Object.entries(G.columns).map(([w,j])=>[w,Z1(j,_)]));if(H.where){let w=typeof H.where==="function"?H.where(B,kZ()):H.where;I=w&&a1(w,_)}let d=[],R=[];if(H.columns){let w=!1;for(let[j,C]of Object.entries(H.columns)){if(C===void 0)continue;if(j in G.columns){if(!w&&C===!0)w=!0;R.push(j)}}if(R.length>0)R=w?R.filter((j)=>H.columns?.[j]===!0):Object.keys(G.columns).filter((j)=>!R.includes(j))}else R=Object.keys(G.columns);for(let w of R){let j=G.columns[w];d.push({tsKey:w,value:j})}let s=[];if(H.with)s=Object.entries(H.with).filter((w)=>!!w[1]).map(([w,j])=>({tsKey:w,queryConfig:j,relation:G.relations[w]}));let o;if(H.extras){o=typeof H.extras==="function"?H.extras(B,{sql:W}):H.extras;for(let[w,j]of Object.entries(o))d.push({tsKey:w,value:cX(j,_)})}for(let{tsKey:w,value:j}of d)E.push({dbKey:D(j,x.Aliased)?j.fieldAlias:G.columns[w].name,tsKey:w,field:D(j,N)?Z1(j,_):j,relationTableTsKey:void 0,isJson:!1,selection:[]});let p=typeof H.orderBy==="function"?H.orderBy(B,NZ()):H.orderBy??[];if(!Array.isArray(p))p=[p];M=p.map((w)=>{if(D(w,N))return Z1(w,_);return a1(w,_)}),U=H.limit,F=H.offset;for(let{tsKey:w,queryConfig:j,relation:C}of s){let u=wZ(Y,Z,C),t=Z[A1(C.referencedTable)],H1=`${_}_${w}`,$1=m(...u.fields.map((j1,wX)=>a(Z1(u.references[wX],H1),Z1(j1,_)))),K1=this._buildRelationalQuery({fullSchema:X,schema:Y,tableNamesMap:Z,table:X[t],tableConfig:Y[t],queryConfig:D(C,R1)?j===!0?{limit:1}:{...j,limit:1}:j,tableAlias:H1,joinOn:$1,nestedQueryRelation:C}),B1=W`(${K1.sql})`.as(w);E.push({dbKey:w,tsKey:w,field:B1,relationTableTsKey:t,isJson:!0,selection:K1.selection})}}if(E.length===0)throw new W1({message:`No fields selected for table "${G.tsName}" ("${_}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});let P;if(I=m(O,I),z){let B=W`json_array(${W.join(E.map(({field:R})=>D(R,S)?W.identifier(this.casing.getColumnCasing(R)):D(R,x.Aliased)?R.sql:R),W`, `)})`;if(D(z,dX))B=W`coalesce(json_group_array(${B}), json_array())`;let d=[{dbKey:"data",tsKey:"data",field:B.as("data"),isJson:!0,relationTableTsKey:G.tsName,selection:E}];if(U!==void 0||F!==void 0||M.length>0)P=this.buildSelectQuery({table:Y1($,_),fields:{},fieldsFlat:[{path:[],field:W.raw("*")}],where:I,limit:U,offset:F,orderBy:M,setOperators:[]}),I=void 0,U=void 0,F=void 0,M=void 0;else P=Y1($,_);P=this.buildSelectQuery({table:D(P,v)?P:new T(P,{},_),fields:{},fieldsFlat:d.map(({field:R})=>({path:[],field:D(R,N)?Z1(R,_):R})),joins:L,where:I,limit:U,offset:F,orderBy:M,setOperators:[]})}else P=this.buildSelectQuery({table:Y1($,_),fields:{},fieldsFlat:E.map(({field:B})=>({path:[],field:D(B,N)?Z1(B,_):B})),joins:L,where:I,limit:U,offset:F,orderBy:M,setOperators:[]});return{tableTsKey:G.tsName,sql:P,selection:E}}nestedSelectionerror(){throw new W1({message:"Views with nested selections are not supported by the relational query builder"})}buildRqbColumn(X,Y,Z){if(D(Y,N)){let $=W`${X}.${W.identifier(this.casing.getColumnCasing(Y))}`;switch(Y.columnType){case"SQLiteBigInt":case"SQLiteBlobJson":case"SQLiteBlobBuffer":return W`hex(${$}) as ${W.identifier(Z)}`;case"SQLiteNumeric":case"SQLiteNumericNumber":case"SQLiteNumericBigInt":return W`cast(${$} as text) as ${W.identifier(Z)}`;case"SQLiteCustomColumn":return W`${Y.jsonSelectIdentifier($,W)} as ${W.identifier(Z)}`;default:return W`${$} as ${W.identifier(Z)}`}}return W`${X}.${D(Y,x.Aliased)?W.identifier(Y.fieldAlias):E1(Y)?W.identifier(Z):this.nestedSelectionerror()} as ${W.identifier(Z)}`}unwrapAllColumns=(X,Y)=>{return W.join(Object.entries(X[n]).map(([Z,$])=>{return Y.push({key:Z,field:$}),this.buildRqbColumn(X,$,Z)}),W`, `)};getSelectedTableColumns=(X,Y)=>{let Z=[],$=X[n],G=Object.entries(Y),H;for(let[_,z]of G){if(z===void 0)continue;if(H=H||z,z){let O=$[_];Z.push({column:O,tsName:_})}}if(H===!1)for(let[_,z]of Object.entries($)){if(Y[_]===!1)continue;Z.push({column:z,tsName:_})}return Z};buildColumns=(X,Y,Z)=>Z?.columns?(()=>{let $=[],G=this.getSelectedTableColumns(X,Z?.columns);for(let{column:H,tsName:_}of G)$.push(this.buildRqbColumn(X,H,_)),Y.push({key:_,field:H});return $.length?W.join($,W`, `):void 0})():this.unwrapAllColumns(X,Y);buildRelationalQuery({schema:X,table:Y,tableConfig:Z,queryConfig:$,relationWhere:G,mode:H,isNested:_,errorPath:z,depth:O,throughJoin:E,jsonb:U}){let F=[],M=H==="first",I=$===!0?void 0:$,L=z??"",P=O??0;if(!P)Y=Y1(Y,`d${P}`);let B=M?1:I?.limit,d=I?.offset,R=this.buildColumns(Y,F,I),s=I?.where&&G?m(J1(Y,I.where,Z.relations,X,this.casing),G):I?.where?J1(Y,I.where,Z.relations,X,this.casing):G,o=I?.orderBy?qZ(Y,I.orderBy):void 0,p=I?.extras?vZ(Y,I.extras):void 0;if(p)F.push(...p.selection);let w=I?(()=>{let{with:C}=I;if(!C)return;let u=Object.entries(C).filter(([t,H1])=>H1);if(!u.length)return;return W.join(u.map(([t,H1])=>{let $1=Z.relations[t],K1=D($1,SZ),B1=Y1($1.targetTable,`d${P+1}`),j1=$1.throughTable?Y1($1.throughTable,`tr${P}`):void 0,{filter:wX,joinCondition:aZ}=uX(this.casing,$1,Y,B1,j1),eZ=j1?W` inner join ${P1(j1)} on ${aZ}`:void 0,$X=this.buildRelationalQuery({table:B1,mode:K1?"first":"many",schema:X,queryConfig:H1,tableConfig:X[$1.targetTableName],relationWhere:wX,isNested:!0,errorPath:`${L.length?`${L}.`:""}${t}`,depth:P+1,throughJoin:eZ,jsonb:U});F.push({field:B1,key:t,selection:$X.selection,isArray:!K1,isOptional:($1.optional??!1)||H1!==!0&&!!H1.where});let ZY=W.join($X.selection.map((GX)=>{return W`${W.raw(this.escapeString(GX.key))}, ${GX.selection?W`${U}(${W.identifier(GX.key)})`:W.identifier(GX.key)}`}),W`, `),$Y=_?U:W`json`;return K1?W`(select ${$Y}_object(${ZY}) as ${W.identifier("r")} from (${$X.sql}) as ${W.identifier("t")}) as ${W.identifier(t)}`:W`coalesce((select ${$Y}_group_array(json_object(${ZY})) as ${W.identifier("r")} from (${$X.sql}) as ${W.identifier("t")}), ${U}_array()) as ${W.identifier(t)}`}),W`, `)})():void 0,j=[R,p?.sql,w].filter((C)=>C!==void 0);if(!j.length)throw new W1({message:`No fields selected for table "${Z.name}"${L?` ("${L}")`:""}`});return{sql:W`select ${W.join(j,W`, `)} from ${P1(Y)}${E}${W` where ${s}`.if(s)}${W` order by ${o}`.if(o)}${W` limit ${B}`.if(B!==void 0)}${W` offset ${d}`.if(d!==void 0)}`,selection:F}}},xX=class extends MX{static[J]="SQLiteSyncDialect";migrate(X,Y,Z){let $=Z===void 0?"__drizzle_migrations":typeof Z==="string"?"__drizzle_migrations":Z.migrationsTable??"__drizzle_migrations",{newDb:G}=rZ($,Y,X);if(G){let z=W`
|
|
4
|
-
CREATE TABLE IF NOT EXISTS ${W.identifier($)} (
|
|
5
|
-
id INTEGER PRIMARY KEY,
|
|
6
|
-
hash text NOT NULL,
|
|
7
|
-
created_at numeric,
|
|
8
|
-
name text,
|
|
9
|
-
applied_at TEXT
|
|
10
|
-
)`;Y.run(z)}let H=Y.all(W`SELECT id, hash, created_at, name FROM ${W.identifier($)}`);if(typeof Z==="object"&&Z.init){if(H.length)return{exitCode:"databaseMigrations"};if(X.length>1)return{exitCode:"localMigrations"};let[z]=X;if(!z)return;Y.run(W`insert into ${W.identifier($)} ("hash", "created_at", "name", "applied_at") values(${z.hash}, ${z.folderMillis}, ${z.name}, ${new Date().toISOString()})`);return}let _=cZ({localMigrations:X,dbMigrations:H});Y.run(W`BEGIN`);try{for(let z of _){for(let O of z.sql)Y.run(W.raw(O));Y.run(W`INSERT INTO ${W.identifier($)} ("hash", "created_at", "name", "applied_at") values(${z.hash}, ${z.folderMillis}, ${z.name}, ${new Date().toISOString()})`)}Y.run(W`COMMIT`)}catch(z){throw Y.run(W`ROLLBACK`),z}}};var YX=class{static[J]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(X){this.dialect=D(X,MX)?X:void 0,this.dialectConfig=D(X,MX)?void 0:X}$with=(X,Y)=>{let Z=this;return{as:(G)=>{if(typeof G==="function")G=G(Z);return new Proxy(new WX(G.getSQL(),Y??("getSelectedFields"in G?G.getSelectedFields()??{}:{}),X,!0),new b({alias:X,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...X){let Y=this;function Z(G){return new X1({fields:G??void 0,session:void 0,dialect:Y.getDialect(),withList:X})}function $(G){return new X1({fields:G??void 0,session:void 0,dialect:Y.getDialect(),withList:X,distinct:!0})}return{select:Z,selectDistinct:$}}select(X){return new X1({fields:X??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(X){return new X1({fields:X??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){if(!this.dialect)this.dialect=new xX(this.dialectConfig);return this.dialect}};var KX=class{static[J]="SQLiteInsertBuilder";constructor(X,Y,Z,$){this.table=X,this.session=Y,this.dialect=Z,this.withList=$}values(X){if(X=Array.isArray(X)?X:[X],X.length===0)throw Error("values() must be called with at least one value");let Y=X.map((Z)=>{let $={},G=this.table[A.Symbol.Columns];for(let H of Object.keys(Z)){let _=Z[H];$[H]=D(_,x)?_:new g(_,G[H])}return $});return new tX(this.table,Y,this.session,this.dialect,this.withList)}select(X){let Y=typeof X==="function"?X(new YX):X;if(!D(Y,x)&&!q1(this.table[n],Y._.selectedFields))throw Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new tX(this.table,Y,this.session,this.dialect,this.withList,!0)}},tX=class extends c{static[J]="SQLiteInsert";config;constructor(X,Y,Z,$,G,H){super();this.session=Z,this.dialect=$,this.config={table:X,values:Y,withList:G,select:H}}returning(X=this.config.table[v.Symbol.Columns]){return this.config.returning=i(X),this}onConflictDoNothing(X={}){if(!this.config.onConflict)this.config.onConflict=[];if(X.target===void 0)this.config.onConflict.push(W` on conflict do nothing`);else{let Y=Array.isArray(X.target)?W`${X.target}`:W`${[X.target]}`,Z=X.where?W` where ${X.where}`:W``;this.config.onConflict.push(W` on conflict ${Y} do nothing${Z}`)}return this}onConflictDoUpdate(X){if(X.where&&(X.targetWhere||X.setWhere))throw Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');if(!this.config.onConflict)this.config.onConflict=[];let Y=X.where?W` where ${X.where}`:void 0,Z=X.targetWhere?W` where ${X.targetWhere}`:void 0,$=X.setWhere?W` where ${X.setWhere}`:void 0,G=Array.isArray(X.target)?W`${X.target}`:W`${[X.target]}`,H=this.dialect.buildUpdateSet(this.config.table,JX(this.config.table,X.set));return this.config.onConflict.push(W` on conflict ${G}${Z} do update set ${H}${Y}${$}`),this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:X,...Y}=this.dialect.sqlToQuery(this.getSQL());return Y}_prepare(X=!0){return this.session[X?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:e(this.config.table)})}prepare(){return this._prepare(!1)}run=(X)=>{return this._prepare().run(X)};all=(X)=>{return this._prepare().all(X)};get=(X)=>{return this._prepare().get(X)};values=(X)=>{return this._prepare().values(X)};async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}};var kX=class{static[J]="SQLiteUpdateBuilder";constructor(X,Y,Z,$){this.table=X,this.session=Y,this.dialect=Z,this.withList=$}set(X){return new sZ(this.table,JX(this.table,X),this.session,this.dialect,this.withList)}},sZ=class extends c{static[J]="SQLiteUpdate";config;constructor(X,Y,Z,$,G){super();this.session=Z,this.dialect=$,this.config={set:Y,table:X,withList:G,joins:[]}}from(X){return this.config.from=X,this}createJoin(X){return(Y,Z)=>{let $=v1(Y);if(typeof $==="string"&&this.config.joins.some((G)=>G.alias===$))throw Error(`Alias "${$}" is already used in this query`);if(typeof Z==="function"){let G=this.config.from?D(Y,v)?Y[A.Symbol.Columns]:D(Y,T)?Y._.selectedFields:D(Y,L1)?Y[Q].selectedFields:void 0:void 0;Z=Z(new Proxy(this.config.table[A.Symbol.Columns],new b({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),G&&new Proxy(G,new b({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:Z,table:Y,joinType:X,alias:$}),this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(X){return this.config.where=X,this}orderBy(...X){if(typeof X[0]==="function"){let Y=X[0](new Proxy(this.config.table[A.Symbol.Columns],new b({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),Z=Array.isArray(Y)?Y:[Y];this.config.orderBy=Z}else{let Y=X;this.config.orderBy=Y}return this}limit(X){return this.config.limit=X,this}returning(X=this.config.table[v.Symbol.Columns]){return this.config.returning=i(X),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:X,...Y}=this.dialect.sqlToQuery(this.getSQL());return Y}_prepare(X=!0){return this.session[X?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:e(this.config.table)})}prepare(){return this._prepare(!1)}run=(X)=>{return this._prepare().run(X)};all=(X)=>{return this._prepare().all(X)};get=(X)=>{return this._prepare().get(X)};values=(X)=>{return this._prepare().values(X)};async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}};var NX=class{static[J]="BaseSQLiteDatabase";_query;query;constructor(X,Y,Z,$,G,H,_){this.resultKind=X,this.dialect=Y,this.session=Z,this.rowModeRQB=H,this.forbidJsonb=_,this._=G?{schema:G.schema,fullSchema:G.fullSchema,tableNamesMap:G.tableNamesMap,relations:$}:{schema:void 0,fullSchema:{},tableNamesMap:{},relations:$},this._query={};let z=this._query;if(this._.schema)for(let[O,E]of Object.entries(this._.schema))z[O]=new LZ(X,G.fullSchema,this._.schema,this._.tableNamesMap,G.fullSchema[O],E,Y,Z);this.query={};for(let[O,E]of Object.entries($))this.query[O]=new pZ(X,$,$[E.name].table,E,Y,Z,H,_);this.$cache={invalidate:async(O)=>{}}}$with=(X,Y)=>{let Z=this;return{as:(G)=>{if(typeof G==="function")G=G(new YX(Z.dialect));return new Proxy(new WX(G.getSQL(),Y??("getSelectedFields"in G?G.getSelectedFields()??{}:{}),X,!0),new b({alias:X,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count(X,Y){return new BZ({source:X,filters:Y,session:this.session})}with(...X){let Y=this;function Z(z){return new X1({fields:z??void 0,session:Y.session,dialect:Y.dialect,withList:X})}function $(z){return new X1({fields:z??void 0,session:Y.session,dialect:Y.dialect,withList:X,distinct:!0})}function G(z){return new kX(z,Y.session,Y.dialect,X)}function H(z){return new KX(z,Y.session,Y.dialect,X)}function _(z){return new VX(z,Y.session,Y.dialect,X)}return{select:Z,selectDistinct:$,update:G,insert:H,delete:_}}select(X){return new X1({fields:X??void 0,session:this.session,dialect:this.dialect})}selectDistinct(X){return new X1({fields:X??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(X){return new kX(X,this.session,this.dialect)}$cache;insert(X){return new KX(X,this.session,this.dialect)}delete(X){return new VX(X,this.session,this.dialect)}run(X){let Y=typeof X==="string"?W.raw(X):X.getSQL();if(this.resultKind==="async")return new XX(async()=>this.session.run(Y),()=>Y,"run",this.dialect,this.session.extractRawRunValueFromBatchResult.bind(this.session));return this.session.run(Y)}all(X){let Y=typeof X==="string"?W.raw(X):X.getSQL();if(this.resultKind==="async")return new XX(async()=>this.session.all(Y),()=>Y,"all",this.dialect,this.session.extractRawAllValueFromBatchResult.bind(this.session));return this.session.all(Y)}get(X){let Y=typeof X==="string"?W.raw(X):X.getSQL();if(this.resultKind==="async")return new XX(async()=>this.session.get(Y),()=>Y,"get",this.dialect,this.session.extractRawGetValueFromBatchResult.bind(this.session));return this.session.get(Y)}values(X){let Y=typeof X==="string"?W.raw(X):X.getSQL();if(this.resultKind==="async")return new XX(async()=>this.session.values(Y),()=>Y,"values",this.dialect,this.session.extractRawValuesValueFromBatchResult.bind(this.session));return this.session.values(Y)}transaction(X,Y){return this.session.transaction(X,Y)}};var P2=class{static[J]="Cache"},tZ=class extends P2{static[J]="NoopCache";strategy(){return"all"}async get(X){}async put(X,Y,Z,$){}async onMutate(X){}};async function nX(X,Y){let Z=`${X}-${JSON.stringify(Y,(H,_)=>typeof _==="bigint"?`${_}n`:_)}`,$=new TextEncoder().encode(Z),G=await crypto.subtle.digest("SHA-256",$);return[...new Uint8Array(G)].map((H)=>H.toString(16).padStart(2,"0")).join("")}var nZ=class extends c{static[J]="ExecuteResultSync";constructor(X){super();this.resultCb=X}async execute(){return this.resultCb()}sync(){return this.resultCb()}},iX=class{static[J]="PreparedQuery";joinsNotNullableMap;constructor(X,Y,Z,$,G,H){if(this.mode=X,this.executeMethod=Y,this.query=Z,this.cache=$,this.queryMetadata=G,this.cacheConfig=H,$&&$.strategy()==="all"&&H===void 0)this.cacheConfig={enabled:!0,autoInvalidate:!0};if(!this.cacheConfig?.enabled)this.cacheConfig=void 0}async queryWithCache(X,Y,Z){if(this.cache===void 0||D(this.cache,tZ)||this.queryMetadata===void 0)try{return await Z()}catch($){throw new x1(X,Y,$)}if(this.cacheConfig&&!this.cacheConfig.enabled)try{return await Z()}catch($){throw new x1(X,Y,$)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{let[$]=await Promise.all([Z(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return $}catch($){throw new x1(X,Y,$)}if(!this.cacheConfig)try{return await Z()}catch($){throw new x1(X,Y,$)}if(this.queryMetadata.type==="select"){let $=await this.cache.get(this.cacheConfig.tag??await nX(X,Y),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if($===void 0){let G;try{G=await Z()}catch(H){throw new x1(X,Y,H)}return await this.cache.put(this.cacheConfig.tag??await nX(X,Y),G,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),G}return $}try{return await Z()}catch($){throw new x1(X,Y,$)}}getQuery(){return this.query}mapRunResult(X,Y){return X}mapAllResult(X,Y){throw Error("Not implemented")}mapGetResult(X,Y){throw Error("Not implemented")}execute(X){if(this.mode==="async")return this[this.executeMethod](X);return new nZ(()=>this[this.executeMethod](X))}mapResult(X,Y){switch(this.executeMethod){case"run":return this.mapRunResult(X,Y);case"all":return this.mapAllResult(X,Y);case"get":return this.mapGetResult(X,Y)}}},lX=class{static[J]="SQLiteSession";constructor(X){this.dialect=X}prepareOneTimeQuery(X,Y,Z,$,G,H,_){return this.prepareQuery(X,Y,Z,$,G,H,_)}prepareOneTimeRelationalQuery(X,Y,Z,$){return this.prepareRelationalQuery(X,Y,Z,$)}run(X){let Y=this.dialect.sqlToQuery(X);try{return this.prepareOneTimeQuery(Y,void 0,"run",!1).run()}catch(Z){throw new W1({cause:Z,message:`Failed to run the query '${Y.sql}'`})}}extractRawRunValueFromBatchResult(X){return X}all(X){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(X),void 0,"run",!1).all()}extractRawAllValueFromBatchResult(X){throw Error("Not implemented")}get(X){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(X),void 0,"run",!1).get()}extractRawGetValueFromBatchResult(X){throw Error("Not implemented")}values(X){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(X),void 0,"run",!1).values()}async count(X){return(await this.values(X))[0][0]}extractRawValuesValueFromBatchResult(X){throw Error("Not implemented")}},aX=class extends NX{static[J]="SQLiteTransaction";constructor(X,Y,Z,$,G,H=0,_,z){super(X,Y,Z,$,G,_,z);this.relations=$,this.schema=G,this.nestedIndex=H}rollback(){throw new TZ}};var XY=class extends lX{static[J]="SQLiteBunSession";logger;constructor(X,Y,Z,$,G={}){super(Y);this.client=X,this.relations=Z,this.schema=$,this.logger=G.logger??new OY}exec(X){this.client.exec(X)}prepareQuery(X,Y,Z,$,G){return new eX(this.client.prepare(X.sql),X,this.logger,Y,Z,$,G)}prepareRelationalQuery(X,Y,Z,$){return new eX(this.client.prepare(X.sql),X,this.logger,Y,Z,!1,$,!0)}transaction(X,Y={}){let Z=new iZ("sync",this.dialect,this,this.relations,this.schema),$;return this.client.transaction(()=>{$=X(Z)})[Y.behavior??"deferred"](),$}},iZ=class X extends aX{static[J]="SQLiteBunTransaction";transaction(Y){let Z=`sp${this.nestedIndex}`,$=new X("sync",this.dialect,this.session,this.relations,this.schema,this.nestedIndex+1);this.session.run(W.raw(`savepoint ${Z}`));try{let G=Y($);return this.session.run(W.raw(`release savepoint ${Z}`)),G}catch(G){throw this.session.run(W.raw(`rollback to savepoint ${Z}`)),G}}},eX=class extends iX{static[J]="SQLiteBunPreparedQuery";constructor(X,Y,Z,$,G,H,_,z){super("sync",G,Y);this.stmt=X,this.logger=Z,this.fields=$,this._isResponseInArrayMode=H,this.customResultMapper=_,this.isRqbV2Query=z}run(X){let Y=D1(this.query.params,X??{});return this.logger.logQuery(this.query.sql,Y),this.stmt.run(...Y)}all(X){if(this.isRqbV2Query)return this.allRqbV2(X);let{fields:Y,query:Z,logger:$,joinsNotNullableMap:G,stmt:H,customResultMapper:_}=this;if(!Y&&!_){let O=D1(Z.params,X??{});return $.logQuery(Z.sql,O),H.all(...O)}let z=this.values(X);if(_)return _(z);return z.map((O)=>BX(Y,O,G))}get(X){if(this.isRqbV2Query)return this.getRqbV2(X);let Y=D1(this.query.params,X??{});this.logger.logQuery(this.query.sql,Y);let{fields:Z,joinsNotNullableMap:$,customResultMapper:G}=this;if(!Z&&!G){let _=this.stmt.get(...Y);if(!_)return;return _}let H=this.stmt.values(...Y)[0];if(!H)return;if(G)return G([H]);return BX(Z,H,$)}allRqbV2(X){let{query:Y,logger:Z,stmt:$,customResultMapper:G}=this,H=D1(Y.params,X??{});return Z.logQuery(Y.sql,H),G($.all(...H))}getRqbV2(X){let Y=D1(this.query.params,X??{});this.logger.logQuery(this.query.sql,Y);let{stmt:Z,customResultMapper:$}=this,G=Z.get(...Y);if(!G)return;return $([G])}values(X){let Y=D1(this.query.params,X??{});return this.logger.logQuery(this.query.sql,Y),this.stmt.values(...Y)}isResponseInArrayMode(){return this._isResponseInArrayMode}};import{Database as RX}from"bun:sqlite";var lZ=class extends NX{static[J]="SQLiteBunDatabase"};function ZX(X,Y={}){let Z=new xX({casing:Y.casing}),$;if(Y.logger===!0)$=new DY;else if(Y.logger!==!1)$=Y.logger;let G;if(Y.schema){let z=RZ(Y.schema,QZ);G={fullSchema:Y.schema,schema:z.tables,tableNamesMap:z.tableNamesMap}}let H=Y.relations??{},_=new lZ("sync",Z,new XY(X,Z,H,G,{logger:$}),H,G);return _.$client=X,_}function YY(...X){if(X[0]===void 0||typeof X[0]==="string")return ZX(X[0]===void 0?new RX:new RX(X[0]),X[1]);let{connection:Y,client:Z,...$}=X[0];if(Z)return ZX(Z,$);if(typeof Y==="object"){let{source:G,...H}=Y;return ZX(new RX(G,Object.values(H).filter((_)=>_!==void 0).length?H:void 0),$)}return ZX(new RX(Y),$)}(function(X){function Y(Z){return ZX({},Z)}X.mock=Y})(YY||(YY={}));export{D as ym,N as zm,E0 as Am,Y0 as Bm,E1 as Cm,h as Dm,x as Em,S1 as Fm,$0 as Gm,PX as Hm,C1 as Im,LX as Jm,G0 as Km,g as Lm,W0 as Mm,W as Nm,l as Om,J0 as Pm,D1 as Qm,y as Rm,H0 as Sm,_0 as Tm,TX as Um,SX as Vm,D0 as Wm,j0 as Xm,T0 as Ym,q as Zm,a as _m,h1 as $m,m as an,V1 as bn,I1 as cn,p1 as dn,y1 as en,f1 as fn,b1 as gn,d1 as hn,g1 as in,m1 as jn,c1 as kn,k1 as ln,N1 as mn,u1 as nn,r1 as on,o1 as pn,s1 as qn,t1 as rn,n1 as sn,qX as tn,vX as un,hX as vn,M1 as wn,i1 as xn,_J as yn,XY as zn,iZ as An,eX as Bn,lZ as Cn,YY as Dn};
|
package/bundle/chunk-bp8sxnrm.js
DELETED
package/bundle/chunk-bw5e8thn.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{of as h}from"./chunk-g3ch14a1.js";import"./chunk-bzrsnv2k.js";import"./chunk-d0qqgxs4.js";import"./chunk-cqtkxwd8.js";import"./chunk-v00cptj6.js";import"./chunk-j2zay4da.js";import"./chunk-4vemws1t.js";import"./chunk-yjj4cvqg.js";var v=(q)=>{return h({baseURL:"https://gateway.ai.cloudflare.com/v1/compat",name:"Unified",...q||{}})},x=v();export{x as unified,v as createUnified};
|
package/bundle/chunk-c8ajbhv3.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Lg as a}from"./chunk-tsb9g1nz.js";import{Yg as t,hh as c}from"./chunk-m2ny1en7.js";import"./chunk-09j71kp6.js";import"./chunk-js9wdh67.js";import"./chunk-0a0vat1h.js";import"./chunk-z8v2tsz2.js";import"./chunk-j8efst22.js";import"./chunk-8f0g7d7k.js";import"./chunk-abtn6nec.js";import"./chunk-d7t0bcvk.js";import"./chunk-7mc8nxve.js";import"./chunk-dfja6dj6.js";import"./chunk-n34y5gp6.js";import"./chunk-bn0h9dny.js";import"./chunk-q5363rr9.js";import"./chunk-7wthn44y.js";import"./chunk-a8p9aggx.js";import"./chunk-0xm85ayc.js";import"./chunk-s2za1n7h.js";import"./chunk-19sa03c1.js";import"./chunk-csdm3n24.js";import"./chunk-xk1nh1ay.js";import"./chunk-bsf6n350.js";import"./chunk-4vze3djr.js";import"./chunk-bzrsnv2k.js";import"./chunk-d0qqgxs4.js";import"./chunk-cqtkxwd8.js";import"./chunk-v00cptj6.js";import"./chunk-1d9f53sk.js";import"./chunk-svrxk3vf.js";import"./chunk-kkae8ead.js";import"./chunk-s6me101a.js";import"./chunk-jwtev7b7.js";import"./chunk-b9nwaaqs.js";import"./chunk-qsszerj7.js";import"./chunk-6jewfaqa.js";import"./chunk-6hdjkvr1.js";import"./chunk-1rn0vmvv.js";import"./chunk-fsy279s5.js";import"./chunk-hn1f6rne.js";import"./chunk-4kpvceap.js";import"./chunk-94qmhz2p.js";import"./chunk-20d0cd1j.js";import"./chunk-yn576pje.js";import{vt as i}from"./chunk-b6dsv601.js";import"./chunk-j2zay4da.js";import"./chunk-4vemws1t.js";import"./chunk-yvqbewmc.js";import"./chunk-t299e2aw.js";import"./chunk-bv8pf0m1.js";import"./chunk-4mrz9b6d.js";import"./chunk-yjj4cvqg.js";var n=i.object({name:a.shape.name,branch:a.shape.branch.unwrap(),directory:a.shape.directory.unwrap()}),d={name:"Worktree",description:"Create a git worktree",async configure(e){let r=await c.runPromise(t.Service.use((o)=>o.makeWorktreeInfo()));return{...e,name:r.name,branch:r.branch,directory:r.directory}},async create(e){let r=n.parse(e);await c.runPromise(t.Service.use((o)=>o.createFromInfo({name:r.name,directory:r.directory,branch:r.branch})))},async remove(e){let r=n.parse(e);await c.runPromise(t.Service.use((o)=>o.remove({directory:r.directory})))},target(e){return{type:"local",directory:n.parse(e).directory}}};export{d as WorktreeAdaptor};
|
package/bundle/chunk-c8n72r2k.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{a as XB,b as YB}from"./chunk-11d987sj.js";import"./chunk-2ztdqtnk.js";import"./chunk-bx6kyvg7.js";import{B as JB}from"./chunk-gsez13bg.js";import{C as r,E as e}from"./chunk-c8k32724.js";import"./chunk-0yqbyres.js";import{I as BB}from"./chunk-s6bar2f9.js";import{O as VB}from"./chunk-6p7yg5sr.js";import"./chunk-2p9py4rw.js";import"./chunk-n3t52cz2.js";import{Rd as t}from"./chunk-yajd975f.js";import{Of as p,Pf as T,Qf as R,Rf as g}from"./chunk-v9xnk9pz.js";import{Vf as H}from"./chunk-cjfgs1x8.js";import{Dg as a}from"./chunk-j0znryc6.js";import{hh as y}from"./chunk-m2ny1en7.js";import"./chunk-09j71kp6.js";import"./chunk-js9wdh67.js";import"./chunk-0a0vat1h.js";import"./chunk-z8v2tsz2.js";import"./chunk-j8efst22.js";import"./chunk-8f0g7d7k.js";import"./chunk-abtn6nec.js";import{ok as n,rl as s}from"./chunk-d7t0bcvk.js";import"./chunk-7mc8nxve.js";import{km as h}from"./chunk-dfja6dj6.js";import"./chunk-n34y5gp6.js";import"./chunk-bn0h9dny.js";import"./chunk-q5363rr9.js";import"./chunk-7wthn44y.js";import"./chunk-a8p9aggx.js";import"./chunk-0xm85ayc.js";import{ko as L,mo as i,po as o}from"./chunk-s2za1n7h.js";import"./chunk-19sa03c1.js";import"./chunk-csdm3n24.js";import"./chunk-xk1nh1ay.js";import"./chunk-bsf6n350.js";import"./chunk-4vze3djr.js";import"./chunk-bzrsnv2k.js";import"./chunk-d0qqgxs4.js";import"./chunk-cqtkxwd8.js";import"./chunk-v00cptj6.js";import"./chunk-1d9f53sk.js";import"./chunk-svrxk3vf.js";import"./chunk-kkae8ead.js";import"./chunk-s6me101a.js";import"./chunk-jwtev7b7.js";import"./chunk-b9nwaaqs.js";import"./chunk-qsszerj7.js";import"./chunk-6jewfaqa.js";import"./chunk-6hdjkvr1.js";import"./chunk-1rn0vmvv.js";import"./chunk-fsy279s5.js";import"./chunk-hn1f6rne.js";import{Ur as I}from"./chunk-4kpvceap.js";import{As as c,Ks as l,Vs as q,ws as v,xs as d,ys as f}from"./chunk-94qmhz2p.js";import{ct as D,qt as u,st as N}from"./chunk-20d0cd1j.js";import"./chunk-yn576pje.js";import"./chunk-b6dsv601.js";import"./chunk-j2zay4da.js";import"./chunk-4vemws1t.js";import"./chunk-yvqbewmc.js";import{qH as F}from"./chunk-t299e2aw.js";import"./chunk-bv8pf0m1.js";import"./chunk-4mrz9b6d.js";import{GO as O}from"./chunk-yjj4cvqg.js";import k from"path";import{fileURLToPath as zB}from"url";import{writeHeapSnapshot as WB}from"v8";import HB,{EOL as K}from"os";var ZB={free:"free",default:"default",fast:"fast",economy:"economical",power:"power",orchestrated:"orchestrated"};function GB(B){for(let[V,X]of Object.entries(ZB))if(B[V]){let Z=I[X];if(Z)return`${Z.providerID}/${Z.modelID}`}return}function KB(B){return async(X,Z)=>{let Y=new Request(X,Z),W=Y.body?await Y.text():void 0,$=await B.call("fetch",{url:Y.url,method:Y.method,headers:Object.fromEntries(Y.headers.entries()),body:W});return new Response($.body,{status:$.status,headers:$.headers})}}function MB(B){return{subscribe:async(V)=>{return B.on("global.event",(X)=>{V(X)})}}}async function jB(){if(typeof globalThis.QITQODE_WORKER_PATH<"u")return globalThis.QITQODE_WORKER_PATH;let B=new URL("./cli/cmd/tui/worker.js",import.meta.url);if(await u(zB(B)))return B;return new URL("./worker.ts",import.meta.url)}async function QB(B){let V=process.stdin.isTTY?void 0:await Bun.stdin.text();if(!B)return V;if(!V)return B;return V+`
|
|
3
|
-
`+B}async function m(B){let V=i({baseUrl:B.url,fetch:B.fetch,directory:B.directory}),X=[{permission:"question",action:"deny",pattern:"*"},{permission:"plan_enter",action:"deny",pattern:"*"},{permission:"plan_exit",action:"deny",pattern:"*"}],Y=(await V.session.create({permission:X})).data?.id;if(!Y){H.error("headless: failed to create session");return}let W=await V.event.subscribe(),$=VB({sessionID:Y,query:async()=>{return(await V.session.status()).data?.[Y]}}),x=W.stream[Symbol.asyncIterator](),b=$.completion.then(()=>"DONE");(async()=>{try{while(!0){let z=await Promise.race([x.next(),b]);if(z==="DONE")break;let C=z;if(C.done)break;let M=C.value;$.onEvent(M);let G=M.properties;if(M.type==="message.part.updated"){let J=G?.part;if(!J||J.sessionID!==Y)continue;if(J.type==="text"&&J.time?.end){let A=String(J.text??"").trim();if(A)process.stdout.write(A+K)}}if(M.type==="permission.asked"){if(!G||G.sessionID!==Y)continue;await V.permission.reply({requestID:String(G.id),reply:"once"})}if(M.type==="session.error"){if(!G||G.sessionID!==Y||!G.error)continue;let J=G.error,A=J?.data!==null&&typeof J?.data==="object"&&"message"in J.data?String(J.data.message):String(J?.name??J);H.error(A)}}}finally{$.stop(),await x.return?.(void 0).catch(()=>{})}})().catch((z)=>{console.error(z),process.exit(1)});let S=B.model?s.parseModel(B.model):void 0;await V.session.prompt({sessionID:Y,agent:B.agent,model:S,parts:[{type:"text",text:B.prompt}]}),$.markStarted(),await $.completion}var pB=t({command:"$0 [project]",describe:"start qitqode tui",builder:(B)=>p(B).positional("project",{type:"string",describe:"path to start qitqode in"}).options(g).option("never-ask",{type:"boolean",describe:"start in never-ask mode \u2014 auto-decide without asking (permissions excluded), toggle at runtime with /never-ask",default:!1}).check((V)=>{if(V.dark&&V.light)throw Error("--dark and --light are mutually exclusive");if(V.sso&&!V.headless)throw Error("--sso requires --headless");if(V.sso&&V["api-key"]!==void 0)throw Error("--sso and --api-key are mutually exclusive");let X=Object.keys(ZB).filter((Z)=>V[Z]);if(X.length>1)throw Error(`${X.map((Z)=>`--${Z}`).join(" and ")} are mutually exclusive \u2014 choose one tier flag`);if(X.length===1&&V.model)throw Error(`--${X[0]} and --model are mutually exclusive \u2014 use one or the other`);return!0}),handler:async(B)=>{if(B.monochrome)process.env.QITQODE_TUI_ACCESSIBLE="1",process.env.NO_COLOR="1";let V=e();try{r();let X=JB(B);if(X){H.error(X),process.exitCode=1;return}let Z=GB(B)??B.model,Y=N(process.env.PWD??process.cwd()),W=B.project?N(k.isAbsolute(B.project)?B.project:k.join(Y,B.project)):N(process.cwd()),$=h(W);if($){if(B.project){H.error("Cannot start in "+W+": "+$),process.exitCode=1;return}let J=N(HB.homedir());if(h(J)){H.error("Cannot start in "+W+": "+$),process.exitCode=1;return}q.warn("unsafe start directory, falling back to home",{requested:W,home:J}),W=J}let x=await jB();try{process.chdir(W)}catch{H.error("Failed to change directory to "+W);return}let b=N(process.cwd()),w=c({[d]:"worker",[v]:f()}),S=new Worker(x,{env:w});S.onerror=(J)=>{q.error("thread error",{message:J.message,filename:J.filename,lineno:J.lineno,colno:J.colno,error:J.error})};let z=l(S),C=()=>{z.call("reload",void 0).catch((J)=>{q.warn("worker reload failed",{error:D(J)})})};process.on("SIGUSR2",C);let M=!1,G=async()=>{if(M)return;M=!0,process.off("SIGUSR2",C),await n(z.call("shutdown",void 0),5000).catch((J)=>{q.warn("worker shutdown failed",{error:D(J)})}),S.terminate()};try{let J=import("./chunk-qm07wesh.js"),A=import("./chunk-7tjd6ba1.js").then(({TuiConfig:P})=>P.get()),U=await QB(B.prompt),$B=await A;if(B.headless&&T(R(B))){H.error("--headless cannot be combined with network-listener flags (--port, --hostname, --mdns)"),process.exitCode=1;return}let E=R(B),_=T(E)?{url:(await z.call("server",E)).url,fetch:void 0,events:void 0}:{url:"http://qitqode.internal",fetch:KB(z),events:MB(z)};if(setTimeout(()=>{z.call("checkUpgrade",{directory:b}).catch(()=>{})},1000).unref?.(),B.headless){if(!U){H.error("--headless requires a prompt: pass --prompt or pipe input via stdin"),process.exitCode=1;return}if(B.sso){try{let j=await a({tryOpen:!1,onCode:(Q)=>{if(process.stdout.write(K),process.stdout.write(" To sign in, open: "+Q.verificationUri+K),process.stdout.write(" and enter code: "+Q.userCode+K),Q.verificationUriComplete)process.stdout.write(K+" Or open this link directly:"+K+" "+Q.verificationUriComplete+K);process.stdout.write(K+" Waiting for approval... (ctrl+c to cancel)"+K)}});await y.runPromise(F.gen(function*(){yield*(yield*L.Service).set("forgewise",BB(j,{rotateRefreshToken:!0}))})),process.stdout.write(" Signed in as "+(j.name||j.email)+K)}catch(j){H.error("SSO sign-in failed: "+D(j)),process.exitCode=1;return}await m({url:_.url,fetch:_.fetch,prompt:U,model:Z,agent:B.agent??"build",directory:b});return}let P=XB(typeof B["api-key"]==="string"?String(B["api-key"]):"");if(P)await y.runPromise(YB(P));else if(!await y.runPromise(F.gen(function*(){if(yield*F.promise(()=>o()))return!0;return!!(yield*(yield*L.Service).get("forgewise"))}))){H.error(`Not signed in. Use one of:
|
|
4
|
-
qode auth login (browser / device-code flow)
|
|
5
|
-
qode auth login --api-key (paste a Qortex API key)
|
|
6
|
-
--api-key <key> (inline for this run)
|
|
7
|
-
$QLEX_API_KEY (environment variable)
|
|
8
|
-
$QITQODE_KEY (environment variable)`),process.exitCode=1;return}await m({url:_.url,fetch:_.fetch,prompt:U,model:Z,agent:B.agent??"build",directory:b})}else{let{tui:P}=await J;await P({url:_.url,async onSnapshot(){let j=WB("tui.heapsnapshot"),Q=await z.call("snapshot",void 0);return[j,Q]},config:$B,directory:b,fetch:_.fetch,events:_.events,args:{continue:B.continue,sessionID:B.session,agent:B.agent,model:Z,prompt:U,fork:B.fork,neverAsk:B["never-ask"]||B.fullauto||!1,fullauto:B.fullauto||!1,themeMode:B.dark?"dark":B.light?"light":void 0,monochrome:B.monochrome||!1,headless:!1}})}}finally{await G()}}finally{V?.()}process.exit(0)}});export{pB as TuiThreadCommand};
|
package/bundle/chunk-ccddzk10.js
DELETED
package/bundle/chunk-ch8cx9jn.js
DELETED
package/bundle/chunk-cm4jtnkg.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{mg as a,ng as b,og as c}from"./chunk-z29fwg61.js";import"./chunk-d7t0bcvk.js";import"./chunk-7mc8nxve.js";import"./chunk-dfja6dj6.js";import"./chunk-n34y5gp6.js";import"./chunk-bn0h9dny.js";import"./chunk-q5363rr9.js";import"./chunk-7wthn44y.js";import"./chunk-a8p9aggx.js";import"./chunk-0xm85ayc.js";import"./chunk-s2za1n7h.js";import"./chunk-19sa03c1.js";import"./chunk-csdm3n24.js";import"./chunk-xk1nh1ay.js";import"./chunk-bsf6n350.js";import"./chunk-4vze3djr.js";import"./chunk-bzrsnv2k.js";import"./chunk-d0qqgxs4.js";import"./chunk-cqtkxwd8.js";import"./chunk-v00cptj6.js";import"./chunk-1d9f53sk.js";import"./chunk-svrxk3vf.js";import"./chunk-kkae8ead.js";import"./chunk-s6me101a.js";import"./chunk-qsszerj7.js";import"./chunk-6jewfaqa.js";import"./chunk-6hdjkvr1.js";import"./chunk-1rn0vmvv.js";import"./chunk-fsy279s5.js";import"./chunk-hn1f6rne.js";import"./chunk-4kpvceap.js";import"./chunk-94qmhz2p.js";import"./chunk-20d0cd1j.js";import"./chunk-yn576pje.js";import"./chunk-b6dsv601.js";import"./chunk-j2zay4da.js";import"./chunk-4vemws1t.js";import"./chunk-yvqbewmc.js";import"./chunk-t299e2aw.js";import"./chunk-4mrz9b6d.js";import"./chunk-yjj4cvqg.js";export{b as run,a as encodeDir,c as ClaudeImport};
|
package/bundle/chunk-cq7j5tv5.js
DELETED
package/bundle/chunk-cttqh20d.js
DELETED
package/bundle/chunk-cvvfa1jf.js
DELETED
package/bundle/chunk-dfja6dj6.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{rm as jn,sm as pt,tm as bn,um as _t,wm as Xr,xm as Yr}from"./chunk-n34y5gp6.js";import{$m as fo,Bm as er,Cm as mr,Dm as ur,Dn as ut,Em as yr,Fm as lr,Gm as fr,Hm as gr,Im as sr,Jm as pr,Km as _r,Lm as Nr,Mm as Tr,Nm as q,Om as Ar,Pm as dr,Qm as Or,Rm as $r,Sm as Dr,Tm as vr,Um as F,Vm as D,Wm as yn,Xm as un,Ym as Zo,Zm as Qr,_m as U,an as Rn,bn as go,cn as so,dn as po,en as _o,fn as No,gn as To,hn as Ao,in as Br,jn as Oo,kn as $o,ln as Do,mn as Ir,nn as vo,on as Lr,pn as Qo,qn as Sr,rn as Gr,sn as Mr,tn as xr,un as Cr,vn as Jr,wn as Bo,xn as Io,ym as uo,yn as wo,zm as yo}from"./chunk-bn0h9dny.js";import{ho as wn}from"./chunk-0xm85ayc.js";import{Co as Fn}from"./chunk-19sa03c1.js";import{Do as ft}from"./chunk-csdm3n24.js";import{Eo as Mo}from"./chunk-xk1nh1ay.js";import{Gq as Pn,Hq as hn,Iq as _n,Jq as hr,Kq as it,Mq as nt}from"./chunk-qsszerj7.js";import{Nq as rt}from"./chunk-6jewfaqa.js";import{Tr as ro}from"./chunk-hn1f6rne.js";import{$s as a,Hs as fn,Rs as On,Ss as nn,Xr as co}from"./chunk-94qmhz2p.js";import{lt as Zr,ot as ko,pt as z,tt as mo}from"./chunk-20d0cd1j.js";import{vt as j}from"./chunk-b6dsv601.js";import{Gz as Cn,kz as Nn,sz as Gn}from"./chunk-yvqbewmc.js";import{AC as Dn,FI as In,PE as h,SM as _,XD as Ro,bO as Ur,cE as Zn,cN as Wo,jE as gn,qH as r,vB as an,zE as Wr}from"./chunk-t299e2aw.js";import{EO as dn}from"./chunk-yjj4cvqg.js";var qo={};dn(qo,{run:()=>Ot});var mn={time_created:F().notNull().$default(()=>Date.now()),time_updated:F().notNull().$onUpdate(()=>Date.now())};var G=un("project",{id:D().$type().primaryKey(),worktree:D().notNull(),vcs:D(),name:D(),icon_url:D(),icon_color:D(),...mn,time_initialized:F(),sandboxes:D({mode:"json"}).notNull().$type(),commands:D({mode:"json"}).$type()});var ln=un("session",{id:D().$type().primaryKey(),project_id:D().$type().notNull().references(()=>G.id,{onDelete:"cascade"}),workspace_id:D().$type(),parent_id:D().$type(),context_from:D().$type(),context_watermark:D().$type(),slug:D().notNull(),directory:D().notNull(),title:D().notNull(),version:D().notNull(),share_url:D(),summary_additions:F(),summary_deletions:F(),summary_files:F(),summary_diffs:D({mode:"json"}).$type(),revert:D({mode:"json"}).$type(),permission:D({mode:"json"}).$type(),...mn,time_compacting:F(),time_archived:F(),last_checkpoint_message_id:D().$type()},(n)=>[yn("session_project_idx").on(n.project_id),yn("session_workspace_idx").on(n.workspace_id),yn("session_parent_idx").on(n.parent_id),yn("session_context_from_idx").on(n.context_from)]),eo=un("message",{id:D().$type().primaryKey(),session_id:D().$type().notNull().references(()=>ln.id,{onDelete:"cascade"}),agent_id:D().notNull().default("main"),...mn,data:D({mode:"json"}).notNull().$type()},(n)=>[yn("message_session_time_created_id_idx").on(n.session_id,n.time_created,n.id),yn("message_session_agent_idx").on(n.session_id,n.agent_id,n.id)]),Xo=un("part",{id:D().$type().primaryKey(),message_id:D().$type().notNull().references(()=>eo.id,{onDelete:"cascade"}),session_id:D().$type().notNull(),...mn,data:D({mode:"json"}).notNull().$type()},(n)=>[yn("part_message_id_id_idx").on(n.message_id,n.id),yn("part_session_idx").on(n.session_id)]),Yo=un("todo",{session_id:D().$type().notNull().references(()=>ln.id,{onDelete:"cascade"}),content:D().notNull(),status:D().notNull(),position:F().notNull(),...mn},(n)=>[Zo({columns:[n.session_id,n.position]}),yn("todo_session_idx").on(n.session_id)]),ao=un("permission",{project_id:D().primaryKey().references(()=>G.id,{onDelete:"cascade"}),...mn,data:D({mode:"json"}).notNull().$type()});var zo=un("session_share",{session_id:D().primaryKey().references(()=>ln.id,{onDelete:"cascade"}),id:D().notNull(),secret:D().notNull(),url:D().notNull(),...mn});import Y from"path";var W=a.create({service:"json-migration"});async function Ot(n,o){let t=Y.join(On.Path.data,"storage");if(!await mo.exists(t))return W.info("storage directory does not exist, skipping migration"),{projects:0,sessions:0,messages:0,parts:0,todos:0,permissions:0,shares:0,errors:[]};W.info("starting json to sqlite migration",{storageDir:t});let g=performance.now();n.run("PRAGMA journal_mode = WAL"),n.run("PRAGMA synchronous = OFF"),n.run("PRAGMA cache_size = 10000"),n.run("PRAGMA temp_store = MEMORY");let e={projects:0,sessions:0,messages:0,parts:0,todos:0,permissions:0,shares:0,errors:[]},T={sessions:0,todos:0,permissions:0,shares:0},p=e.errors,A=1000,M=Date.now();async function H(l){return ko.scan(l,{cwd:t,absolute:!0})}async function C(l,L,x){let v=x-L,N=Array(v);for(let K=0;K<v;K++)N[K]=mo.readJson(l[L+K]);let S=await Promise.allSettled(N),P=Array(v);for(let K=0;K<S.length;K++){let k=S[K];if(k.status==="fulfilled"){P[K]=k.value;continue}p.push(`failed to read ${l[L+K]}: ${k.reason}`)}return P}function J(l,L,x){if(l.length===0)return 0;try{return n.insert(L).values(l).onConflictDoNothing().run(),l.length}catch(v){return p.push(`failed to migrate ${x} batch: ${v}`),0}}W.info("scanning files...");let[R,O,Q,I,f,s,m]=await Promise.all([H("project/*.json"),H("session/*/*.json"),H("message/*/*.json"),H("part/*/*.json"),H("todo/*.json"),H("permission/*.json"),H("session_share/*.json")]);W.info("file scan complete",{projects:R.length,sessions:O.length,messages:Q.length,parts:I.length,todos:f.length,permissions:s.length,shares:m.length});let y=Math.max(1,R.length+O.length+Q.length+I.length+f.length+s.length+m.length),i=o?.progress,u=0,$=(l,L)=>{u=Math.min(y,u+L),i?.({current:u,total:y,label:l})};i?.({current:u,total:y,label:"starting"}),n.run("BEGIN TRANSACTION");let B=new Set,d=[];for(let l=0;l<R.length;l+=A){let L=Math.min(l+A,R.length),x=await C(R,l,L);d.length=0;for(let v=0;v<x.length;v++){let N=x[v];if(!N)continue;let S=Y.basename(R[l+v],".json");B.add(S),d.push({id:S,worktree:N.worktree??"/",vcs:N.vcs,name:N.name??void 0,icon_url:N.icon?.url,icon_color:N.icon?.color,time_created:N.time?.created??M,time_updated:N.time?.updated??M,time_initialized:N.time?.initialized,sandboxes:N.sandboxes??[],commands:N.commands})}e.projects+=J(d,G,"project"),$("projects",L-l)}W.info("migrated projects",{count:e.projects,duration:Math.round(performance.now()-g)});let E=O.map((l)=>Y.basename(Y.dirname(l))),X=new Set,en=[];for(let l=0;l<O.length;l+=A){let L=Math.min(l+A,O.length),x=await C(O,l,L);en.length=0;for(let v=0;v<x.length;v++){let N=x[v];if(!N)continue;let S=Y.basename(O[l+v],".json"),P=E[l+v];if(!B.has(P)){T.sessions++;continue}X.add(S),en.push({id:S,project_id:P,parent_id:N.parentID??null,slug:N.slug??"",directory:N.directory??"",title:N.title??"",version:N.version??"",share_url:N.share?.url??null,summary_additions:N.summary?.additions??null,summary_deletions:N.summary?.deletions??null,summary_files:N.summary?.files??null,summary_diffs:N.summary?.diffs??null,revert:N.revert??null,permission:N.permission??null,time_created:N.time?.created??M,time_updated:N.time?.updated??M,time_compacting:N.time?.compacting??null,time_archived:N.time?.archived??null})}e.sessions+=J(en,ln,"session"),$("sessions",L-l)}if(W.info("migrated sessions",{count:e.sessions}),T.sessions>0)W.warn("skipped orphaned sessions",{count:T.sessions});let sn=[],c=[],zn=new Map;for(let l of Q){let L=Y.basename(Y.dirname(l));if(!X.has(L))continue;sn.push(l),c.push(L)}for(let l=0;l<sn.length;l+=A){let L=Math.min(l+A,sn.length),x=await C(sn,l,L),v=Array(x.length),N=0;for(let S=0;S<x.length;S++){let P=x[S];if(!P)continue;let K=sn[l+S],k=Y.basename(K,".json"),Hn=c[l+S];zn.set(k,Hn);let vn=P;delete vn.id,delete vn.sessionID,v[N++]={id:k,session_id:Hn,time_created:P.time?.created??M,time_updated:P.time?.updated??M,data:vn}}v.length=N,e.messages+=J(v,eo,"message"),$("messages",L-l)}W.info("migrated messages",{count:e.messages});for(let l=0;l<I.length;l+=A){let L=Math.min(l+A,I.length),x=await C(I,l,L),v=Array(x.length),N=0;for(let S=0;S<x.length;S++){let P=x[S];if(!P)continue;let K=I[l+S],k=Y.basename(K,".json"),Hn=Y.basename(Y.dirname(K)),vn=zn.get(Hn);if(!vn){p.push(`part missing message session: ${K}`);continue}if(!X.has(vn))continue;let Vn=P;delete Vn.id,delete Vn.messageID,delete Vn.sessionID,v[N++]={id:k,message_id:Hn,session_id:vn,time_created:P.time?.created??M,time_updated:P.time?.updated??M,data:Vn}}v.length=N,e.parts+=J(v,Xo,"part"),$("parts",L-l)}W.info("migrated parts",{count:e.parts});let An=f.map((l)=>Y.basename(l,".json"));for(let l=0;l<f.length;l+=A){let L=Math.min(l+A,f.length),x=await C(f,l,L),v=[];for(let N=0;N<x.length;N++){let S=x[N];if(!S)continue;let P=An[l+N];if(!X.has(P)){T.todos++;continue}if(!Array.isArray(S)){p.push(`todo not an array: ${f[l+N]}`);continue}for(let K=0;K<S.length;K++){let k=S[K];if(!k?.content||!k?.status)continue;v.push({session_id:P,content:k.content,status:k.status,position:K,time_created:M,time_updated:M})}}e.todos+=J(v,Yo,"todo"),$("todos",L-l)}if(W.info("migrated todos",{count:e.todos}),T.todos>0)W.warn("skipped orphaned todos",{count:T.todos});let kn=s.map((l)=>Y.basename(l,".json")),Jn=[];for(let l=0;l<s.length;l+=A){let L=Math.min(l+A,s.length),x=await C(s,l,L);Jn.length=0;for(let v=0;v<x.length;v++){let N=x[v];if(!N)continue;let S=kn[l+v];if(!B.has(S)){T.permissions++;continue}Jn.push({project_id:S,data:N})}e.permissions+=J(Jn,ao,"permission"),$("permissions",L-l)}if(W.info("migrated permissions",{count:e.permissions}),T.permissions>0)W.warn("skipped orphaned permissions",{count:T.permissions});let qn=m.map((l)=>Y.basename(l,".json")),Ln=[];for(let l=0;l<m.length;l+=A){let L=Math.min(l+A,m.length),x=await C(m,l,L);Ln.length=0;for(let v=0;v<x.length;v++){let N=x[v];if(!N)continue;let S=qn[l+v];if(!X.has(S)){T.shares++;continue}if(!N?.id||!N?.secret||!N?.url){p.push(`session_share missing id/secret/url: ${m[l+v]}`);continue}Ln.push({session_id:S,id:N.id,secret:N.secret,url:N.url})}e.shares+=J(Ln,zo,"session_share"),$("shares",L-l)}if(W.info("migrated session shares",{count:e.shares}),T.shares>0)W.warn("skipped orphaned session shares",{count:T.shares});if(n.run("COMMIT"),W.info("json migration complete",{projects:e.projects,sessions:e.sessions,messages:e.messages,parts:e.parts,todos:e.todos,permissions:e.permissions,shares:e.shares,errorCount:e.errors.length,duration:Math.round(performance.now()-g)}),e.errors.length>0)W.warn("migration errors",{errors:e.errors.slice(0,20)});return i?.({current:y,total:y,label:"complete"}),e}var Bn={};dn(Bn,{use:()=>Ce,transaction:()=>He,textDecoder:()=>re,sumDistinct:()=>rr,sum:()=>or,sql:()=>q,relationsOrderToSQL:()=>ci,relationsFilterToSQL:()=>Ri,relationToSQL:()=>Hi,relationExtrasToSQL:()=>Ji,processRelations:()=>Ci,placeholder:()=>dr,param:()=>Tr,orderSelectedFields:()=>oe,orderByOperators:()=>xi,or:()=>go,operators:()=>Mi,notLike:()=>Sr,notInArray:()=>Br,notIlike:()=>Mr,notExists:()=>Ir,notBetween:()=>Lr,not:()=>so,noopMapper:()=>_r,noopEncoder:()=>pr,noopDecoder:()=>sr,ne:()=>fo,name:()=>fr,min:()=>ir,max:()=>tr,mapUpdateSet:()=>ne,mapResultRow:()=>hi,mapRelationalRow:()=>Gi,mapColumnsInSQLToAlias:()=>ti,mapColumnsInAliasedSQLToAlias:()=>ri,lte:()=>To,lt:()=>No,like:()=>Qo,l2Distance:()=>Zi,l1Distance:()=>Ui,jaccardDistance:()=>Wi,isWithEnum:()=>bi,isView:()=>Dr,isTable:()=>Xt,isSQLWrapper:()=>mr,isNull:()=>Oo,isNotNull:()=>$o,isDriverValueEncoder:()=>gr,isConfig:()=>ji,is:()=>Mt,innerProduct:()=>Pi,inArray:()=>Ao,ilike:()=>Gr,haveSameKeys:()=>Fi,hasOwnEntityKind:()=>Gt,hammingDistance:()=>Ei,gte:()=>_o,gt:()=>po,getViewSelectedFields:()=>wi,getViewName:()=>vr,getTableUniqueName:()=>Zt,getTableName:()=>Ut,getTableLikeName:()=>Vi,getTableColumns:()=>qi,getTableAsAliasSQL:()=>Si,getOriginalColumnFromAlias:()=>oi,getOrderByOperators:()=>Li,getColumns:()=>ki,getColumnTable:()=>Ct,getColumnNameAndConfig:()=>zi,getChannelPath:()=>gt,fillPlaceholders:()=>Or,fieldSelectionToSQL:()=>Ii,extractTablesFromSchema:()=>Bi,extractExtendedColumnType:()=>mi,exists:()=>Do,eq:()=>U,entityKind:()=>St,effect:()=>Je,desc:()=>Io,defineRelationsPart:()=>Qi,defineRelations:()=>vi,createRelationsHelper:()=>Di,countDistinct:()=>bo,count:()=>lo,cosineDistance:()=>Ki,close:()=>xe,buildRelationsParts:()=>$i,buildRelations:()=>Oi,bindIfParam:()=>Qr,between:()=>vo,avgDistinct:()=>nr,avg:()=>ho,assertUnreachable:()=>ai,asc:()=>Bo,arrayOverlaps:()=>Jr,arrayContains:()=>xr,arrayContained:()=>Cr,applyMixins:()=>Yi,and:()=>Rn,aliasedTableColumn:()=>ni,aliasedTable:()=>ht,aliasedRelation:()=>bt,aliasedColumn:()=>jt,WithSubquery:()=>at,ViewSelectionAliasProxyHandler:()=>Ft,ViewBaseConfig:()=>zt,View:()=>$r,TransactionRollbackError:()=>li,TableSchema:()=>Wt,TableColumns:()=>Pt,TableAliasProxyHandler:()=>wt,Table:()=>Et,Subquery:()=>Yt,StringChunk:()=>ur,SQL:()=>yr,RelationsHelperStatic:()=>di,RelationsBuilderTable:()=>Ai,RelationsBuilderJunctionColumn:()=>Ti,RelationsBuilderColumn:()=>Ni,RelationTableAliasProxyHandler:()=>Vt,Relation:()=>_i,QueryPromise:()=>ii,Placeholder:()=>Ar,Path:()=>Ko,Param:()=>Nr,OriginalName:()=>Kt,One:()=>pi,NotFoundError:()=>Me,NoopLogger:()=>Lt,Name:()=>lr,Many:()=>si,IsAlias:()=>ct,FakePrimitiveParam:()=>er,ExtraConfigColumns:()=>Rt,ExtraConfigBuilder:()=>Ht,DrizzleQueryError:()=>yi,DrizzleError:()=>ui,DefaultLogger:()=>It,Count:()=>gi,ConsoleLogWriter:()=>Bt,ColumnTableAliasProxyHandler:()=>qt,ColumnBuilder:()=>ei,ColumnAliasProxyHandler:()=>kt,Column:()=>xt,Client:()=>Mn,CONSTANTS:()=>Xi,BaseName:()=>Jt,AggregatedField:()=>fi});import $t from"crypto";import Vo,{existsSync as Dt,readdirSync as vt}from"fs";import{join as Qt}from"path";function Fo(n){if(Vo.existsSync(`${n.migrationsFolder}/meta/_journal.json`))throw Error('We detected that you have old drizzle-kit migration folders. You must upgrade drizzle-kit and run "drizzle-kit up"');let o=n.migrationsFolder,t=[],g=vt(o).map((e)=>({path:Qt(o,e,"migration.sql"),name:e})).filter((e)=>Dt(e.path));g.sort((e,T)=>e.name.localeCompare(T.name));for(let e of g){let T=e.path,p=e.name.slice(0,14),A=Vo.readFileSync(T).toString(),M=A.split("--> statement-breakpoint").map((C)=>{return C}),H=wo(p);t.push({sql:M,bps:!0,folderMillis:H,hash:$t.createHash("sha256").update(A).digest("hex"),name:e.name})}return t}function jo(n,o){if(Array.isArray(o)||"migrationsJournal"in o){let g=Array.isArray(o)?o:o.migrationsJournal,e=Array.isArray(o)?void 0:o.migrationsTable,T=g.map((p)=>({sql:p.sql.split("--> statement-breakpoint"),folderMillis:p.timestamp,hash:"",bps:!0,name:p.name}));return n.dialect.migrate(T,n.session,{migrationsTable:e})}let t=Fo(o);return n.dialect.migrate(t,n.session,o)}function lo(n){return q`count(${n||q.raw("*")})`.mapWith(Number)}function bo(n){return q`count(distinct ${n})`.mapWith(Number)}function ho(n){return q`avg(${n})`.mapWith(String)}function nr(n){return q`avg(distinct ${n})`.mapWith(String)}function or(n){return q`sum(${n})`.mapWith(String)}function rr(n){return q`sum(distinct ${n})`.mapWith(String)}function tr(n){return q`max(${n})`.mapWith(uo(n,yo)?n:String)}function ir(n){return q`min(${n})`.mapWith(uo(n,yo)?n:String)}import oo from"path";var Wn={};dn(Wn,{workspaceID:()=>$e,useEffect:()=>Qe,use:()=>ve,make:()=>De,invalidate:()=>Ie,has:()=>Be,get:()=>Ho,directory:()=>no,context:()=>Jo,bind:()=>Oe});import{EventEmitter as te}from"events";var cn=new te;var Lo=new Set;function Hr(n){return Lo.add(n),()=>{Lo.delete(n)}}async function So(n){await Promise.allSettled([...Lo].map((o)=>o(n)))}function Kn(n){return n()}var Fr={};dn(Fr,{setInitialized:()=>se,list:()=>fe,layer:()=>wr,get:()=>ge,fromRow:()=>pn,defaultLayer:()=>Co,UpdateInput:()=>le,Service:()=>Sn,Info:()=>qr,Event:()=>Vr});import*as w from"fs/promises";import*as ar from"os";import*as $n from"path";var ie=_.String.pipe(_.brand("ProjectID")),V=ie.pipe(wn((n)=>({global:n.make("global"),zod:j.string().pipe(j.custom())})));import*as Qn from"fs/promises";import*as b from"path";import*as Kr from"crypto";async function Go(n){let o=b.resolve(n);while(!0){let t=b.join(o,".git"),g=await Qn.stat(t).catch(()=>null);if(g){if(g.isDirectory())return t;let p=(await Qn.readFile(t,"utf-8")).trim().match(/^gitdir:\s*(.+)$/);if(!p)return null;let A=b.isAbsolute(p[1])?p[1]:b.resolve(o,p[1]);return b.resolve(A,"../..")}let e=b.dirname(o);if(e===o)return null;o=e}}async function Rr(n){let o=await Qn.readFile(n,"utf-8").catch(()=>null);if(o===null)return null;return o.trim()||null}async function cr(n){let o=await Rr(n);if(o)return o;let t=Kr.randomUUID();try{return await Qn.writeFile(n,t,{flag:"wx"}),t}catch(g){if(g.code!=="EEXIST")throw g;let e=await Rr(n);if(e)return e;throw Error(`Project ID file was concurrently created but is empty: ${n}`)}}async function Er(n){let o=await Go(n);if(o){let g=b.join(o,"qitqode-project-id");return V.make(await cr(g))}let t=b.join(n,".qitqode-project-id");return V.make(await cr(t))}async function me(n){let o=await Go(n);if(!o)return;let t=$n.join(n,".qitqode-project-id"),g=$n.join(o,"qitqode-project-id"),e=(A)=>w.access(A).then(()=>!0).catch(()=>!1);if(await e(t)){if(!await e(g)){let A=await w.readFile(t,"utf-8");await w.writeFile(g,A)}await w.unlink(t).catch(()=>{})}let T=$n.join(o,"info","exclude");if(await w.mkdir($n.dirname(T),{recursive:!0}),!(await w.readFile(T,"utf-8").catch(()=>"")).includes(".qitqode-project-id"))await w.appendFile(T,`
|
|
3
|
-
.qitqode-project-id
|
|
4
|
-
`)}var Pr=a.create({service:"project"}),ue=262144,xo=_.Literal("git"),zr=_.Struct({url:_.optional(_.String),override:_.optional(_.String),color:_.optional(_.String)}),kr=_.Struct({start:_.optional(_.String.annotate({description:"Startup script to run when creating a new workspace (worktree)"}))}),ye=_.Struct({created:_.Number,updated:_.Number,initialized:_.optional(_.Number)}),qr=_.Struct({id:V,worktree:_.String,vcs:_.optional(xo),name:_.optional(_.String),icon:_.optional(zr),commands:_.optional(kr),time:ye,sandboxes:_.Array(_.String)}).annotate({identifier:"Project"}).pipe(wn((n)=>({zod:Fn(n)}))),Vr={Updated:Yr.define("project.updated",qr.zod)};function pn(n){let o=n.icon_url||n.icon_color?{url:n.icon_url??void 0,color:n.icon_color??void 0}:void 0;return{id:n.id,worktree:n.worktree,vcs:n.vcs?_.decodeUnknownSync(xo)(n.vcs):void 0,name:n.name??void 0,icon:o,time:{created:n.time_created,updated:n.time_updated,initialized:n.time_initialized??void 0},sandboxes:n.sandboxes,commands:n.commands??void 0}}var le=j.object({projectID:V.zod,name:j.string().optional(),icon:Fn(zr).optional(),commands:Fn(kr).optional()});class Sn extends Dn.Service()("@qitqode/Project"){}var wr=h.effect(Sn,r.gen(function*(){let n=yield*z.Service,o=yield*Ur.Path,t=yield*jn.ChildProcessSpawner,g=r.fnUntraced(function*(i,u){return yield*Xr(t,i,u)},r.catch(()=>r.succeed({code:1,text:"",stderr:""}))),e=(i)=>r.sync(()=>Bn.use(i)),T=(i)=>r.sync(()=>cn.emit("event",{directory:"global",project:i.id,payload:{type:Vr.Updated.type,properties:i}})),p=_.decodeUnknownSync(_.optional(xo))(nn.QITQODE_FAKE_VCS),A=(i,u)=>{if(!u)return i;if(u=u.replace(/[\r\n]+$/,""),!u)return i;if(u=z.windowsPath(u),o.isAbsolute(u))return o.normalize(u);return o.resolve(i,u)},M=yield*Wr.Scope,H=r.fn("Project.fromDirectory")(function*(i){Pr.info("fromDirectory",{directory:i});let u=yield*r.gen(function*(){if(nn.QITQODE_DISABLE_GIT)return{id:V.global,worktree:i,sandbox:i,vcs:p};let X=(yield*n.up({targets:[".git"],start:i}).pipe(r.orDie))[0];if(!X)return{id:V.global,worktree:"/",sandbox:"/",vcs:p};let en=o.dirname(X),sn=process.env.HOME??process.env.USERPROFILE??ar.homedir();if(en===sn||$n.parse(en).root===en)return Pr.warn("ignoring .git at home or filesystem root, snapshots disabled",{dotgit:X}),{id:V.global,worktree:i,sandbox:i,vcs:p};let c=en,zn=yield*r.sync(()=>Mo("git")),An;if(!zn)return{id:An??V.global,worktree:c,sandbox:c,vcs:p};let kn=yield*g(["rev-parse","--git-common-dir"],{cwd:c});if(kn.code!==0)return{id:An??V.global,worktree:c,sandbox:c,vcs:p};let Jn=(()=>{let Ln=A(c,kn.text.trim());return Ln===c?c:o.dirname(Ln)})();if(An==null)yield*r.promise(()=>me(c)),An=yield*r.promise(()=>Er(c));let qn=yield*g(["rev-parse","--show-toplevel"],{cwd:c});if(qn.code!==0)return{id:An,worktree:c,sandbox:c,vcs:p};return c=A(c,qn.text.trim()),{id:An,sandbox:c,worktree:Jn,vcs:"git"}}),$=yield*e((E)=>E.select().from(G).where(U(G.id,u.id)).get()),B=$?pn($):{id:u.id,worktree:u.worktree,vcs:u.vcs,sandboxes:[],time:{created:Date.now(),updated:Date.now()}};if(nn.QITQODE_EXPERIMENTAL_ICON_DISCOVERY)yield*C(B).pipe(r.ignore,r.forkIn(M));let d={...B,worktree:u.worktree,vcs:u.vcs,time:{...B.time,updated:Date.now()}};if(u.sandbox!==d.worktree&&!d.sandboxes.includes(u.sandbox))d.sandboxes.push(u.sandbox);if(d.sandboxes=yield*r.forEach(d.sandboxes,(E)=>n.exists(E).pipe(r.orDie,r.map((X)=>X?E:void 0)),{concurrency:16}).pipe(r.map((E)=>E.filter((X)=>X!==void 0))),yield*e((E)=>E.insert(G).values({id:d.id,worktree:d.worktree,vcs:d.vcs??null,name:d.name,icon_url:d.icon?.url,icon_color:d.icon?.color,time_created:d.time.created,time_updated:d.time.updated,time_initialized:d.time.initialized,sandboxes:d.sandboxes,commands:d.commands}).onConflictDoUpdate({target:G.id,set:{worktree:d.worktree,vcs:d.vcs??null,name:d.name,icon_url:d.icon?.url,icon_color:d.icon?.color,time_updated:d.time.updated,time_initialized:d.time.initialized,sandboxes:d.sandboxes,commands:d.commands}}).run()),u.id!==V.global)yield*e((E)=>E.update(ln).set({project_id:u.id}).where(Rn(U(ln.project_id,V.global),U(ln.directory,u.worktree))).run());return yield*T(d),{project:d,sandbox:u.sandbox}}),C=r.fn("Project.discover")(function*(i){if(i.vcs!=="git")return;if(i.icon?.override)return;if(i.icon?.url)return;let $=(yield*n.glob("**/favicon.{ico,png,svg,jpg,jpeg,webp}",{cwd:i.worktree,absolute:!0,include:"file"}).pipe(r.orDie)).sort((sn,c)=>sn.length-c.length)[0];if(!$)return;let B=yield*n.stat($).pipe(r.orDie);if(Number(B.size)>ue)return;let d=yield*n.readFile($).pipe(r.orDie),E=Buffer.from(d).toString("base64"),en=`data:${z.mimeType($)};base64,${E}`;yield*O({projectID:i.id,icon:{url:en}})}),J=r.fn("Project.list")(function*(){return yield*e((i)=>i.select().from(G).all().map(pn))}),R=r.fn("Project.get")(function*(i){let u=yield*e(($)=>$.select().from(G).where(U(G.id,i)).get());return u?pn(u):void 0}),O=r.fn("Project.update")(function*(i){let u=yield*e((B)=>B.update(G).set({name:i.name,icon_url:i.icon?.url,icon_color:i.icon?.color,commands:i.commands,time_updated:Date.now()}).where(U(G.id,i.projectID)).returning().get());if(!u)throw Error(`Project not found: ${i.projectID}`);let $=pn(u);return yield*T($),$}),Q=r.fn("Project.initGit")(function*(i){if(i.project.vcs==="git")return i.project;if(!(yield*r.sync(()=>Mo("git"))))throw Error("Git is not installed");let u=yield*g(["init","--quiet"],{cwd:i.directory});if(u.code!==0)throw Error(u.stderr.trim()||u.text.trim()||"Failed to initialize git repository");let{project:$}=yield*H(i.directory);return $}),I=r.fn("Project.setInitialized")(function*(i){yield*e((u)=>u.update(G).set({time_initialized:Date.now()}).where(U(G.id,i)).run())}),f=r.fn("Project.sandboxes")(function*(i){let u=yield*e((B)=>B.select().from(G).where(U(G.id,i)).get());if(!u)return[];let $=pn(u);return yield*r.forEach($.sandboxes,(B)=>n.isDir(B).pipe(r.orDie,r.map((d)=>d?B:void 0)),{concurrency:16}).pipe(r.map((B)=>B.filter((d)=>d!==void 0)))}),s=r.fnUntraced(function*(i,u){let $=yield*e((B)=>B.update(G).set({sandboxes:u,time_updated:Date.now()}).where(U(G.id,i)).returning().get());if(!$)throw Error(`Project not found: ${i}`);yield*T(pn($))}),m=r.fn("Project.addSandbox")(function*(i,u){let $=yield*e((d)=>d.select().from(G).where(U(G.id,i)).get());if(!$)throw Error(`Project not found: ${i}`);let B=[...$.sandboxes];if(!B.includes(u))B.push(u);yield*s(i,B)}),y=r.fn("Project.removeSandbox")(function*(i,u){let $=yield*e((d)=>d.select().from(G).where(U(G.id,i)).get());if(!$)throw Error(`Project not found: ${i}`);let B=$.sandboxes.filter((d)=>d!==u);yield*s(i,B)});return Sn.of({fromDirectory:H,discover:C,list:J,get:R,update:O,initGit:Q,setInitialized:I,sandboxes:f,addSandbox:m,removeSandbox:y})})),Co=wr.pipe(h.provide(bn),h.provide(z.defaultLayer),h.provide(Zr.layer));function fe(){return Bn.use((n)=>n.select().from(G).all().map((o)=>pn(o)))}function ge(n){let o=Bn.use((t)=>t.select().from(G).where(U(G.id,n)).get());if(!o)return;return pn(o)}function se(n){Bn.use((o)=>o.update(G).set({time_initialized:Date.now()}).where(U(G.id,n)).run())}import{parse as pe}from"path";var rn=fn.create("instance");hr(()=>rn.use());var tn=new Map,_e=nt(Sn,Co),Ne=new Set(["/etc","/proc","/sys","/dev","/boot","/root","/var","/private/etc","/private/var"]);function Te(n){if(n===pe(n).root)return"filesystem root is not a valid project directory";for(let o of Ne)if(n===o||z.contains(o,n))return"target is a protected system directory";return null}function Ae(n){let o=Te(n);if(o)throw Error("Access denied: "+o)}var En={all:void 0};function jr(n){return Kn(async()=>{let o=n.project&&n.worktree?{directory:n.directory,worktree:n.worktree,project:n.project}:await _e.runPromise((t)=>t.fromDirectory(n.directory)).then(({project:t,sandbox:g})=>({directory:n.directory,worktree:g,project:t}));return await rn.provide(o,async()=>{await n.init?.()}),o})}function br(n,o){let t=o.catch((g)=>{if(tn.get(n)===t)tn.delete(n);throw g});return tn.set(n,t),t}var on={async provide(n){let o=z.resolve(n.directory);Ae(o);let t=tn.get(o);if(!t)a.Default.info("creating instance",{directory:o}),t=br(o,jr({directory:o,init:n.init}));let g=await t;return rn.provide(g,async()=>{return n.fn()})},get current(){return rn.use()},get directory(){return rn.use().directory},get worktree(){return rn.use().worktree},get project(){return rn.use().project},containsPath(n,o){let t=o??on;if(z.contains(t.directory,n))return!0;if(t.worktree==="/")return!1;return z.contains(t.worktree,n)},bind(n){let o=rn.use();return(...t)=>rn.provide(o,()=>n(...t))},restore(n,o){return rn.provide(n,o)},async reload(n){let o=z.resolve(n.directory);a.Default.info("reloading instance",{directory:o}),await So(o),tn.delete(o);let t=br(o,jr({...n,directory:o}));return cn.emit("event",{directory:o,project:n.project?.id,workspace:_n.workspaceID,payload:{type:"server.instance.disposed",properties:{directory:o}}}),await t},async dispose(){let{directory:n,project:o}=on;a.Default.info("disposing instance",{directory:n}),await So(n),tn.delete(n),cn.emit("event",{directory:n,project:o.id,workspace:_n.workspaceID,payload:{type:"server.instance.disposed",properties:{directory:n}}})},async disposeAll(){if(En.all)return En.all;return En.all=Kn(async()=>{a.Default.info("disposing all instances");let n=[...tn.entries()];for(let[o,t]of n){if(tn.get(o)!==t)continue;let g=await t.catch((e)=>{a.Default.warn("instance dispose failed",{key:o,error:e});return});if(!g){if(tn.get(o)===t)tn.delete(o);continue}if(tn.get(o)!==t)continue;await rn.provide(g,async()=>{await on.dispose()})}}).finally(()=>{En.all=void 0}),En.all}};var ot="~qitqode/InstanceState",Oe=(n)=>{try{return on.bind(n)}catch(g){if(!(g instanceof fn.NotFound))throw g}let o=In.getCurrent(),t=o?Dn.getReferenceUnsafe(o.context,Pn):void 0;if(!t)return n;return(...g)=>on.restore(t,()=>n(...g))},Jo=r.gen(function*(){return(yield*Pn)??on.current}),$e=r.gen(function*(){return(yield*hn)??_n.workspaceID}),no=r.map(Jo,(n)=>n.directory),De=(n)=>r.gen(function*(){let o=yield*Gn.make({capacity:Number.POSITIVE_INFINITY,lookup:()=>r.gen(function*(){return yield*n(yield*Jo)})}),t=Hr((g)=>r.runPromise(Gn.invalidate(o,g).pipe(r.provide(rt))));return yield*r.addFinalizer(()=>r.sync(t)),{[ot]:ot,cache:o}}),Ho=(n)=>r.gen(function*(){return yield*Gn.get(n.cache,yield*no)}),ve=(n,o)=>r.map(Ho(n),o),Qe=(n,o)=>r.flatMap(Ho(n),o),Be=(n)=>r.gen(function*(){return yield*Gn.has(n.cache,yield*no)}),Ie=(n)=>r.gen(function*(){return yield*Gn.invalidate(n.cache,yield*no)});var et={};dn(et,{make:()=>Le});function tt(n,o,t){if(n&&o!==void 0)return _n.restore(o,()=>on.restore(n,t));if(n)return on.restore(n,t);if(o!==void 0)return _n.restore(o,t);return t()}function Le(){return r.gen(function*(){let n=yield*r.context(),t=(yield*Pn)??(()=>{try{return on.current}catch(p){if(!(p instanceof fn.NotFound))throw p}})(),g=(yield*hn)??_n.workspaceID,e=(p)=>it(p,{instance:t,workspace:g}),T=(p)=>e(p).pipe(r.provide(n));return{promise:(p)=>tt(t,g,()=>r.runPromise(T(p))),fork:(p)=>tt(t,g,()=>r.runFork(T(p)))}})}var mt={};dn(mt,{make:()=>Se,Cancelled:()=>Un});class Un extends _.TaggedErrorClass()("RunnerCancelled",{}){}var Se=(n,o)=>{let t=Nn.makeUnsafe({_tag:"Idle"}),g=o?.onIdle??r.void,e=o?.onBusy??r.void,T=o?.onInterrupt,p=0,A=()=>Nn.getUnsafe(t),M=()=>{return p+=1,p},H=(m,y)=>Zn.isFailure(y)&&Ro.hasInterruptsOnly(y.cause)?gn.fail(m,new Un).pipe(r.asVoid):gn.done(m,y).pipe(r.asVoid),C=()=>Nn.modify(t,(m)=>[m._tag==="Idle"?g:r.void,m]).pipe(r.flatten),J=(m,y,i)=>Nn.modify(t,(u)=>[r.gen(function*(){if(u._tag==="Running"&&u.run.id===m)yield*g;yield*H(y,i)}),u._tag==="Running"&&u.run.id===m?{_tag:"Idle"}:u]).pipe(r.flatten),R=(m,y)=>r.gen(function*(){let i=M(),u=yield*m.pipe(r.onExit(($)=>J(i,y,$)),r.forkIn(n));return{id:i,done:y,fiber:u}}),O=(m)=>Nn.modifyEffect(t,r.fnUntraced(function*(y){if(y._tag==="Shell"&&y.shell.id===m)return[g,{_tag:"Idle"}];if(y._tag==="ShellThenRun"&&y.shell.id===m){let i=yield*R(y.run.work,y.run.done);return[r.void,{_tag:"Running",run:i}]}return[r.void,y]})).pipe(r.flatten),Q=(m)=>In.interrupt(m.fiber),I=(m)=>Nn.modifyEffect(t,r.fnUntraced(function*(y){switch(y._tag){case"Running":case"ShellThenRun":if(o?.onReentryWarn)yield*o.onReentryWarn({label:o.label??"(unlabeled)",existingRunId:y.run.id});return[gn.await(y.run.done),y];case"Shell":{let i={id:M(),done:yield*gn.make(),work:m};return[gn.await(i.done),{_tag:"ShellThenRun",shell:y.shell,run:i}]}case"Idle":{let i=yield*gn.make(),u=yield*R(m,i);return[gn.await(i),{_tag:"Running",run:u}]}}})).pipe(r.flatten,r.catch((y)=>y instanceof Un?T??r.die(y):r.fail(y))),f=(m)=>Nn.modifyEffect(t,r.fnUntraced(function*(y){if(y._tag!=="Idle")return[r.sync(()=>{if(o?.busy)o.busy();throw Error("Runner is busy")}),y];yield*e;let i=M(),u=yield*m.pipe(r.ensuring(O(i)),r.forkChild),$={id:i,fiber:u};return[r.gen(function*(){let B=yield*In.await(u);if(Zn.isSuccess(B))return B.value;if(Ro.hasInterruptsOnly(B.cause)&&T)return yield*T;return yield*r.failCause(B.cause)}),{_tag:"Shell",shell:$}]})).pipe(r.flatten),s=Nn.modify(t,(m)=>{switch(m._tag){case"Idle":return[r.void,m];case"Running":return[r.gen(function*(){yield*In.interrupt(m.run.fiber);let y=yield*In.await(m.run.fiber);yield*H(m.run.done,y),yield*gn.await(m.run.done).pipe(r.exit,r.asVoid),yield*C()}),{_tag:"Idle"}];case"Shell":return[r.gen(function*(){yield*Q(m.shell),yield*C()}),{_tag:"Idle"}];case"ShellThenRun":return[r.gen(function*(){yield*gn.fail(m.run.done,new Un).pipe(r.asVoid),yield*Q(m.shell),yield*C()}),{_tag:"Idle"}]}}).pipe(r.flatten);return{get state(){return A()},get busy(){return A()._tag!=="Idle"},ensureRunning:I,startShell:f,cancel:s}};import{Database as Ge}from"bun:sqlite";function yt(n){let o=new Ge(n,{create:!0});return ut({client:o})}var Me=ro.create("NotFoundError",j.object({message:j.string()})),lt=a.create({service:"db"});function gt(){if(["latest","beta","prod"].includes(co)||nn.QITQODE_DISABLE_CHANNEL_DB)return oo.join(On.Path.data,"qitqode.db");let n=co.replace(/[^a-zA-Z0-9._-]/g,"-");return oo.join(On.Path.data,`qitqode-${n}.db`)}var Ko=Kn(()=>{if(nn.QITQODE_DB){if(nn.QITQODE_DB===":memory:"||oo.isAbsolute(nn.QITQODE_DB))return nn.QITQODE_DB;return oo.join(On.Path.data,nn.QITQODE_DB)}return gt()}),Mn=ft(()=>{lt.info("opening database",{path:Ko});let n=yt(Ko);n.run("PRAGMA journal_mode = WAL"),n.run("PRAGMA synchronous = NORMAL"),n.run("PRAGMA busy_timeout = 5000"),n.run("PRAGMA cache_size = -64000"),n.run("PRAGMA foreign_keys = ON"),n.run("PRAGMA wal_checkpoint(PASSIVE)");let o=[{sql:"CREATE TABLE `project` (\n\t`id` text PRIMARY KEY,\n\t`worktree` text NOT NULL,\n\t`vcs` text,\n\t`name` text,\n\t`icon_url` text,\n\t`icon_color` text,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\t`time_initialized` integer,\n\t`sandboxes` text NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE `message` (\n\t`id` text PRIMARY KEY,\n\t`session_id` text NOT NULL,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\t`data` text NOT NULL,\n\tCONSTRAINT `fk_message_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE TABLE `part` (\n\t`id` text PRIMARY KEY,\n\t`message_id` text NOT NULL,\n\t`session_id` text NOT NULL,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\t`data` text NOT NULL,\n\tCONSTRAINT `fk_part_message_id_message_id_fk` FOREIGN KEY (`message_id`) REFERENCES `message`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE TABLE `permission` (\n\t`project_id` text PRIMARY KEY,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\t`data` text NOT NULL,\n\tCONSTRAINT `fk_permission_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE TABLE `session` (\n\t`id` text PRIMARY KEY,\n\t`project_id` text NOT NULL,\n\t`parent_id` text,\n\t`slug` text NOT NULL,\n\t`directory` text NOT NULL,\n\t`title` text NOT NULL,\n\t`version` text NOT NULL,\n\t`share_url` text,\n\t`summary_additions` integer,\n\t`summary_deletions` integer,\n\t`summary_files` integer,\n\t`summary_diffs` text,\n\t`revert` text,\n\t`permission` text,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\t`time_compacting` integer,\n\t`time_archived` integer,\n\tCONSTRAINT `fk_session_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE TABLE `todo` (\n\t`session_id` text NOT NULL,\n\t`content` text NOT NULL,\n\t`status` text NOT NULL,\n\t`priority` text NOT NULL,\n\t`position` integer NOT NULL,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\tCONSTRAINT `todo_pk` PRIMARY KEY(`session_id`, `position`),\n\tCONSTRAINT `fk_todo_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE TABLE `session_share` (\n\t`session_id` text PRIMARY KEY,\n\t`id` text NOT NULL,\n\t`secret` text NOT NULL,\n\t`url` text NOT NULL,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\tCONSTRAINT `fk_session_share_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE INDEX `message_session_idx` ON `message` (`session_id`);--> statement-breakpoint\nCREATE INDEX `part_message_idx` ON `part` (`message_id`);--> statement-breakpoint\nCREATE INDEX `part_session_idx` ON `part` (`session_id`);--> statement-breakpoint\nCREATE INDEX `session_project_idx` ON `session` (`project_id`);--> statement-breakpoint\nCREATE INDEX `session_parent_idx` ON `session` (`parent_id`);--> statement-breakpoint\nCREATE INDEX `todo_session_idx` ON `todo` (`session_id`);",timestamp:1769552633000,name:"20260127222353_familiar_lady_ursula"},{sql:"ALTER TABLE `project` ADD `commands` text;",timestamp:1770830228000,name:"20260211171708_add_project_commands"},{sql:"CREATE TABLE `control_account` (\n\t`email` text NOT NULL,\n\t`url` text NOT NULL,\n\t`access_token` text NOT NULL,\n\t`refresh_token` text NOT NULL,\n\t`token_expiry` integer,\n\t`active` integer NOT NULL,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\tCONSTRAINT `control_account_pk` PRIMARY KEY(`email`, `url`)\n);\n",timestamp:1770993676000,name:"20260213144116_wakeful_the_professor"},{sql:"CREATE TABLE `workspace` (\n\t`id` text PRIMARY KEY,\n\t`branch` text,\n\t`project_id` text NOT NULL,\n\t`config` text NOT NULL,\n\tCONSTRAINT `fk_workspace_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE\n);\n",timestamp:1772056728000,name:"20260225215848_workspace"},{sql:"ALTER TABLE `session` ADD `workspace_id` text;--> statement-breakpoint\nCREATE INDEX `session_workspace_idx` ON `session` (`workspace_id`);",timestamp:1772228279000,name:"20260227213759_add_session_workspace_id"},{sql:"CREATE TABLE `account` (\n\t`id` text PRIMARY KEY,\n\t`email` text NOT NULL,\n\t`url` text NOT NULL,\n\t`access_token` text NOT NULL,\n\t`refresh_token` text NOT NULL,\n\t`token_expiry` integer,\n\t`selected_org_id` text,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE `account_state` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`active_account_id` text,\n\tFOREIGN KEY (`active_account_id`) REFERENCES `account`(`id`) ON UPDATE no action ON DELETE set null\n);\n",timestamp:1772310750000,name:"20260228203230_blue_harpoon"},{sql:"ALTER TABLE `workspace` ADD `type` text NOT NULL;--> statement-breakpoint\nALTER TABLE `workspace` ADD `name` text;--> statement-breakpoint\nALTER TABLE `workspace` ADD `directory` text;--> statement-breakpoint\nALTER TABLE `workspace` ADD `extra` text;--> statement-breakpoint\nALTER TABLE `workspace` DROP COLUMN `config`;",timestamp:1772579546000,name:"20260303231226_add_workspace_fields"},{sql:"ALTER TABLE `account_state` ADD `active_org_id` text;--> statement-breakpoint\nUPDATE `account_state` SET `active_org_id` = (SELECT `selected_org_id` FROM `account` WHERE `account`.`id` = `account_state`.`active_account_id`);--> statement-breakpoint\nALTER TABLE `account` DROP COLUMN `selected_org_id`;\n",timestamp:1773097200000,name:"20260309230000_move_org_to_state"},{sql:"DROP INDEX IF EXISTS `message_session_idx`;--> statement-breakpoint\nDROP INDEX IF EXISTS `part_message_idx`;--> statement-breakpoint\nCREATE INDEX `message_session_time_created_id_idx` ON `message` (`session_id`,`time_created`,`id`);--> statement-breakpoint\nCREATE INDEX `part_message_id_id_idx` ON `part` (`message_id`,`id`);",timestamp:1773290071000,name:"20260312043431_session_message_cursor"},{sql:"CREATE TABLE `event_sequence` (\n\t`aggregate_id` text PRIMARY KEY,\n\t`seq` integer NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE `event` (\n\t`id` text PRIMARY KEY,\n\t`aggregate_id` text NOT NULL,\n\t`seq` integer NOT NULL,\n\t`type` text NOT NULL,\n\t`data` text NOT NULL,\n\tCONSTRAINT `fk_event_aggregate_id_event_sequence_aggregate_id_fk` FOREIGN KEY (`aggregate_id`) REFERENCES `event_sequence`(`aggregate_id`) ON DELETE CASCADE\n);\n",timestamp:1774309702000,name:"20260323234822_events"},{sql:"PRAGMA foreign_keys=OFF;--> statement-breakpoint\nCREATE TABLE `__new_workspace` (\n\t`id` text PRIMARY KEY,\n\t`type` text NOT NULL,\n\t`name` text DEFAULT '' NOT NULL,\n\t`branch` text,\n\t`directory` text,\n\t`extra` text,\n\t`project_id` text NOT NULL,\n\tCONSTRAINT `fk_workspace_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nINSERT INTO `__new_workspace`(`id`, `type`, `branch`, `name`, `directory`, `extra`, `project_id`) SELECT `id`, `type`, `branch`, `name`, `directory`, `extra`, `project_id` FROM `workspace`;--> statement-breakpoint\nDROP TABLE `workspace`;--> statement-breakpoint\nALTER TABLE `__new_workspace` RENAME TO `workspace`;--> statement-breakpoint\nPRAGMA foreign_keys=ON;",timestamp:1775843113000,name:"20260410174513_workspace-name"},{sql:"CREATE TABLE `session_entry` (\n\t`id` text PRIMARY KEY,\n\t`session_id` text NOT NULL,\n\t`type` text NOT NULL,\n\t`time_created` integer NOT NULL,\n\t`time_updated` integer NOT NULL,\n\t`data` text NOT NULL,\n\tCONSTRAINT `fk_session_entry_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE\n);\n--> statement-breakpoint\nCREATE INDEX `session_entry_session_idx` ON `session_entry` (`session_id`);--> statement-breakpoint\nCREATE INDEX `session_entry_session_type_idx` ON `session_entry` (`session_id`,`type`);--> statement-breakpoint\nCREATE INDEX `session_entry_time_created_idx` ON `session_entry` (`time_created`);",timestamp:1776103196000,name:"20260413175956_chief_energizer"},{sql:"ALTER TABLE `session` ADD `context_from` text;--> statement-breakpoint\nALTER TABLE `session` ADD `context_watermark` text;--> statement-breakpoint\nCREATE INDEX `session_context_from_idx` ON `session` (`context_from`);\n",timestamp:1776873600000,name:"20260422160000_context_inheritance"},{sql:"CREATE TABLE `task_registry` (\n `id` text PRIMARY KEY,\n `parent_session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `status` text NOT NULL,\n `agent` text NOT NULL,\n `description` text NOT NULL,\n `context_mode` text NOT NULL,\n `background` integer NOT NULL,\n `last_turn_time` integer NOT NULL,\n `turn_count` integer NOT NULL DEFAULT 0,\n `error` text,\n `time_completed` integer,\n `time_created` integer NOT NULL,\n `time_updated` integer NOT NULL\n);--> statement-breakpoint\nCREATE INDEX `task_registry_parent_idx` ON `task_registry` (`parent_session_id`);--> statement-breakpoint\nCREATE INDEX `task_registry_status_idx` ON `task_registry` (`status`);--> statement-breakpoint\nCREATE INDEX `task_registry_status_last_turn_idx` ON `task_registry` (`status`, `last_turn_time`);\n",timestamp:1776877200000,name:"20260422170000_task_registry"},{sql:"DROP INDEX IF EXISTS `session_entry_session_idx`;--> statement-breakpoint\nDROP INDEX IF EXISTS `session_entry_session_type_idx`;--> statement-breakpoint\nDROP INDEX IF EXISTS `session_entry_time_created_idx`;--> statement-breakpoint\nDROP TABLE IF EXISTS `session_entry`;\n",timestamp:1776956061000,name:"20260423145421_remove_session_entry"},{sql:"DROP INDEX IF EXISTS `task_registry_parent_idx`;--> statement-breakpoint\nDROP INDEX IF EXISTS `task_registry_status_idx`;--> statement-breakpoint\nDROP INDEX IF EXISTS `task_registry_status_last_turn_idx`;--> statement-breakpoint\nALTER TABLE `task_registry` RENAME TO `actor_registry`;--> statement-breakpoint\nCREATE INDEX `actor_registry_parent_idx` ON `actor_registry` (`parent_session_id`);--> statement-breakpoint\nCREATE INDEX `actor_registry_status_idx` ON `actor_registry` (`status`);--> statement-breakpoint\nCREATE INDEX `actor_registry_status_last_turn_idx` ON `actor_registry` (`status`, `last_turn_time`);\n",timestamp:1778803200000,name:"20260515000000_actor_rename"},{sql:"CREATE TABLE `memory_fts` (\n `path` text PRIMARY KEY NOT NULL,\n `scope` text NOT NULL,\n `scope_id` text DEFAULT '' NOT NULL,\n `type` text NOT NULL,\n `body` text NOT NULL,\n `fingerprint` text NOT NULL,\n `last_indexed_at` integer NOT NULL\n);\n--> statement-breakpoint\nCREATE INDEX `memory_fts_scope_idx` ON `memory_fts` (`scope`, `scope_id`);\n--> statement-breakpoint\nCREATE INDEX `memory_fts_type_idx` ON `memory_fts` (`type`);\n--> statement-breakpoint\nCREATE VIRTUAL TABLE `memory_fts_idx` USING fts5(\n body,\n content='memory_fts',\n content_rowid='rowid',\n tokenize='unicode61 remove_diacritics 1'\n);\n--> statement-breakpoint\nCREATE TRIGGER `memory_fts_ai` AFTER INSERT ON `memory_fts` BEGIN\n INSERT INTO `memory_fts_idx`(rowid, body) VALUES (NEW.rowid, NEW.body);\nEND;\n--> statement-breakpoint\nCREATE TRIGGER `memory_fts_ad` AFTER DELETE ON `memory_fts` BEGIN\n DELETE FROM `memory_fts_idx` WHERE rowid = OLD.rowid;\nEND;\n--> statement-breakpoint\nCREATE TRIGGER `memory_fts_au` AFTER UPDATE ON `memory_fts` BEGIN\n DELETE FROM `memory_fts_idx` WHERE rowid = OLD.rowid;\n INSERT INTO `memory_fts_idx`(rowid, body) VALUES (NEW.rowid, NEW.body);\nEND;\n",timestamp:1778806800000,name:"20260515010000_memory_fts"},{sql:"CREATE TABLE `task` (\n `id` text NOT NULL,\n `session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `parent_task_id` text,\n `kind` text NOT NULL DEFAULT 'user',\n `status` text NOT NULL,\n `focus` integer NOT NULL DEFAULT 0,\n `summary` text NOT NULL,\n `created_at` integer NOT NULL,\n `last_event_at` integer NOT NULL,\n `ended_at` integer,\n `cleanup_after` integer,\n PRIMARY KEY (`session_id`, `id`)\n);--> statement-breakpoint\nCREATE INDEX `task_session_idx` ON `task` (`session_id`);--> statement-breakpoint\nCREATE INDEX `task_parent_idx` ON `task` (`session_id`, `parent_task_id`);--> statement-breakpoint\nCREATE INDEX `task_status_idx` ON `task` (`status`);--> statement-breakpoint\nCREATE INDEX `task_kind_idx` ON `task` (`kind`);--> statement-breakpoint\nCREATE UNIQUE INDEX `task_focus_per_session_idx` ON `task` (`session_id`) WHERE focus = 1;--> statement-breakpoint\nCREATE TABLE `task_event` (\n `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n `session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `task_id` text NOT NULL,\n `at` integer NOT NULL,\n `kind` text NOT NULL,\n `summary` text,\n FOREIGN KEY (`session_id`, `task_id`) REFERENCES `task`(`session_id`, `id`) ON DELETE CASCADE\n);--> statement-breakpoint\nCREATE INDEX `task_event_task_idx` ON `task_event` (`session_id`, `task_id`, `at`);\n",timestamp:1778810400000,name:"20260515020000_user_task"},{sql:"ALTER TABLE `session` ADD `last_checkpoint_message_id` text;\n",timestamp:1779148800000,name:"20260519000000_last_checkpoint_message_id"},{sql:"ALTER TABLE `message` ADD `agent_id` text;--> statement-breakpoint\nCREATE INDEX `message_session_agent_idx` ON `message` (`session_id`,`agent_id`,`id`);\n",timestamp:1779321600000,name:"20260521000000_message_agent_id"},{sql:"DROP TABLE `actor_registry`;--> statement-breakpoint\nCREATE TABLE `actor_registry` (\n `session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `actor_id` text NOT NULL,\n `mode` text NOT NULL,\n `parent_actor_id` text,\n `status` text NOT NULL,\n `agent` text NOT NULL,\n `description` text NOT NULL,\n `context_mode` text NOT NULL,\n `context_watermark` text,\n `background` integer NOT NULL,\n `tools` text,\n `last_turn_time` integer NOT NULL,\n `turn_count` integer NOT NULL DEFAULT 0,\n `error` text,\n `time_completed` integer,\n `time_created` integer NOT NULL,\n `time_updated` integer NOT NULL,\n PRIMARY KEY (`session_id`, `actor_id`)\n);--> statement-breakpoint\nCREATE INDEX `actor_registry_session_agent_idx` ON `actor_registry` (`session_id`, `agent`);--> statement-breakpoint\nCREATE INDEX `actor_registry_session_parent_idx` ON `actor_registry` (`session_id`, `parent_actor_id`);--> statement-breakpoint\nCREATE INDEX `actor_registry_status_idx` ON `actor_registry` (`status`);--> statement-breakpoint\nCREATE INDEX `actor_registry_status_last_turn_idx` ON `actor_registry` (`status`, `last_turn_time`);\n",timestamp:1779321660000,name:"20260521000100_actor_registry_v6"},{sql:"DROP TRIGGER IF EXISTS `memory_fts_ai`;--> statement-breakpoint\nDROP TRIGGER IF EXISTS `memory_fts_ad`;--> statement-breakpoint\nDROP TRIGGER IF EXISTS `memory_fts_au`;--> statement-breakpoint\nDROP TABLE IF EXISTS `memory_fts_idx`;--> statement-breakpoint\nDROP TABLE IF EXISTS `memory_fts`;--> statement-breakpoint\nCREATE TABLE `memory_fts` (\n `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n `path` text NOT NULL UNIQUE,\n `scope` text NOT NULL,\n `scope_id` text DEFAULT '' NOT NULL,\n `type` text NOT NULL,\n `body` text NOT NULL,\n `fingerprint` text NOT NULL,\n `last_indexed_at` integer NOT NULL\n);--> statement-breakpoint\nCREATE INDEX `memory_fts_scope_idx` ON `memory_fts` (`scope`, `scope_id`);--> statement-breakpoint\nCREATE INDEX `memory_fts_type_idx` ON `memory_fts` (`type`);--> statement-breakpoint\nCREATE VIRTUAL TABLE `memory_fts_idx` USING fts5(\n body,\n content='memory_fts',\n content_rowid='id',\n tokenize='unicode61 remove_diacritics 1'\n);--> statement-breakpoint\nCREATE TRIGGER `memory_fts_ai` AFTER INSERT ON `memory_fts` BEGIN\n INSERT INTO `memory_fts_idx`(rowid, body) VALUES (NEW.id, NEW.body);\nEND;--> statement-breakpoint\nCREATE TRIGGER `memory_fts_ad` AFTER DELETE ON `memory_fts` BEGIN\n DELETE FROM `memory_fts_idx` WHERE rowid = OLD.id;\nEND;--> statement-breakpoint\nCREATE TRIGGER `memory_fts_au` AFTER UPDATE ON `memory_fts` BEGIN\n DELETE FROM `memory_fts_idx` WHERE rowid = OLD.id;\n INSERT INTO `memory_fts_idx`(rowid, body) VALUES (NEW.id, NEW.body);\nEND;\n",timestamp:1779325200000,name:"20260521010000_memory_fts_v6"},{sql:"-- Fix v6.1 trigger pattern: external content FTS5 vtab requires the 'delete'\n-- magic command to remove OLD body's tokens, NOT a plain DELETE FROM the vtab.\n-- The previous DELETE FROM pattern was contentless-mode syntax misapplied to\n-- external-content mode, leaving stale tokens accumulating until vtab corrupts.\nDROP TRIGGER IF EXISTS `memory_fts_ai`;--> statement-breakpoint\nDROP TRIGGER IF EXISTS `memory_fts_ad`;--> statement-breakpoint\nDROP TRIGGER IF EXISTS `memory_fts_au`;--> statement-breakpoint\nCREATE TRIGGER `memory_fts_ai` AFTER INSERT ON `memory_fts` BEGIN\n INSERT INTO `memory_fts_idx`(rowid, body) VALUES (NEW.id, NEW.body);\nEND;--> statement-breakpoint\nCREATE TRIGGER `memory_fts_ad` AFTER DELETE ON `memory_fts` BEGIN\n INSERT INTO `memory_fts_idx`(`memory_fts_idx`, rowid, body) VALUES('delete', OLD.id, OLD.body);\nEND;--> statement-breakpoint\nCREATE TRIGGER `memory_fts_au` AFTER UPDATE ON `memory_fts` BEGIN\n INSERT INTO `memory_fts_idx`(`memory_fts_idx`, rowid, body) VALUES('delete', OLD.id, OLD.body);\n INSERT INTO `memory_fts_idx`(rowid, body) VALUES (NEW.id, NEW.body);\nEND;\n",timestamp:1779328800000,name:"20260521020000_memory_fts_triggers"},{sql:"UPDATE `message` SET `agent_id` = 'main' WHERE `agent_id` IS NULL;--> statement-breakpoint\nCREATE TABLE `message_new` (\n `id` text PRIMARY KEY NOT NULL,\n `session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `agent_id` text NOT NULL DEFAULT 'main',\n `time_created` integer NOT NULL,\n `time_updated` integer NOT NULL,\n `data` text NOT NULL\n);--> statement-breakpoint\nINSERT INTO `message_new` SELECT `id`, `session_id`, COALESCE(`agent_id`, 'main'), `time_created`, `time_updated`, `data` FROM `message`;--> statement-breakpoint\nDROP TABLE `message`;--> statement-breakpoint\nALTER TABLE `message_new` RENAME TO `message`;--> statement-breakpoint\nCREATE INDEX `message_session_time_created_id_idx` ON `message` (`session_id`,`time_created`,`id`);--> statement-breakpoint\nCREATE INDEX `message_session_agent_idx` ON `message` (`session_id`,`agent_id`,`id`);\n",timestamp:1779753600000,name:"20260526000000_agent_id_main"},{sql:"ALTER TABLE `actor_registry` ADD COLUMN `last_outcome` text;--> statement-breakpoint\nALTER TABLE `actor_registry` ADD COLUMN `lifecycle` text NOT NULL DEFAULT 'ephemeral';--> statement-breakpoint\nALTER TABLE `actor_registry` RENAME COLUMN `error` TO `last_error`;--> statement-breakpoint\nUPDATE `actor_registry` SET `last_outcome` = 'success' WHERE `status` = 'completed';--> statement-breakpoint\nUPDATE `actor_registry` SET `last_outcome` = 'failure' WHERE `status` = 'failed';--> statement-breakpoint\nUPDATE `actor_registry` SET `last_outcome` = 'cancelled' WHERE `status` = 'cancelled';--> statement-breakpoint\nUPDATE `actor_registry` SET `status` = 'idle' WHERE `status` IN ('completed','failed','cancelled');--> statement-breakpoint\nUPDATE `actor_registry` SET `lifecycle` = CASE `mode` WHEN 'peer' THEN 'persistent' WHEN 'main' THEN 'persistent' ELSE 'ephemeral' END;\n",timestamp:1779840000000,name:"20260527000000_actor_lifecycle"},{sql:"CREATE TABLE `inbox` (\n `id` text PRIMARY KEY NOT NULL,\n `receiver_session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `receiver_actor_id` text NOT NULL,\n `sender_session_id` text,\n `sender_actor_id` text,\n `type` text NOT NULL DEFAULT 'text',\n `content` text NOT NULL,\n `created_at` integer NOT NULL\n);--> statement-breakpoint\nCREATE INDEX `inbox_receiver_idx` ON `inbox` (`receiver_session_id`,`receiver_actor_id`,`id`);--> statement-breakpoint\nCREATE INDEX `inbox_created_idx` ON `inbox` (`created_at`);\n",timestamp:1779840060000,name:"20260527000100_inbox"},{sql:"-- todo: drop priority column\nALTER TABLE `todo` DROP COLUMN `priority`;\n--> statement-breakpoint\n\n-- task: drop focus-dependent index before dropping its column\nDROP INDEX `task_focus_per_session_idx`;\n--> statement-breakpoint\nDROP INDEX `task_kind_idx`;\n--> statement-breakpoint\nALTER TABLE `task` DROP COLUMN `focus`;\n--> statement-breakpoint\nALTER TABLE `task` DROP COLUMN `kind`;\n--> statement-breakpoint\n\n-- migrate status values: proposed/active -> open\nUPDATE `task` SET `status` = 'open' WHERE `status` IN ('proposed', 'active');\n",timestamp:1780012800000,name:"20260529000000_task_todo_redesign"},{sql:"ALTER TABLE `task` ADD COLUMN `owner` text;\n",timestamp:1780444800000,name:"20260603000000_task_in_progress_owner"},{sql:"CREATE TABLE `workflow_run` (\n `id` text PRIMARY KEY NOT NULL,\n `session_id` text NOT NULL REFERENCES `session`(`id`) ON DELETE CASCADE,\n `name` text NOT NULL,\n `status` text NOT NULL,\n `running` integer NOT NULL DEFAULT 0,\n `succeeded` integer NOT NULL DEFAULT 0,\n `failed` integer NOT NULL DEFAULT 0,\n `current_phase` text,\n `parent_actor_id` text,\n `args` text,\n `error` text,\n `time_created` integer NOT NULL,\n `time_updated` integer NOT NULL\n);--> statement-breakpoint\nCREATE INDEX `workflow_run_session_idx` ON `workflow_run` (`session_id`);--> statement-breakpoint\nCREATE INDEX `workflow_run_status_idx` ON `workflow_run` (`status`);\n",timestamp:1780444800000,name:"20260603000000_workflow_run"},{sql:"ALTER TABLE `workflow_run` ADD COLUMN `script_sha` text;\n",timestamp:1780531200000,name:"20260604000000_workflow_script_sha"},{sql:"CREATE TABLE `claude_import` (\n `source_uuid` text PRIMARY KEY NOT NULL,\n `session_id` text NOT NULL,\n `source_path` text NOT NULL,\n `source_mtime` integer NOT NULL,\n `time_imported` integer NOT NULL\n);\n",timestamp:1780876800000,name:"20260608000000_claude_import"},{sql:"ALTER TABLE `claude_import` ADD `message_ids` text;\n",timestamp:1780880400000,name:"20260608010000_claude_import_message_ids"},{sql:"CREATE TABLE `history_fts` (\n `part_id` text PRIMARY KEY NOT NULL,\n `session_id` text NOT NULL,\n `message_id` text NOT NULL,\n `project_id` text NOT NULL,\n `kind` text NOT NULL,\n `tool_name` text,\n `body` text NOT NULL,\n `time_created` integer NOT NULL\n);--> statement-breakpoint\nCREATE INDEX `history_fts_session_idx` ON `history_fts` (`session_id`, `time_created`);--> statement-breakpoint\nCREATE INDEX `history_fts_project_idx` ON `history_fts` (`project_id`, `time_created`);--> statement-breakpoint\nCREATE INDEX `history_fts_message_idx` ON `history_fts` (`message_id`);--> statement-breakpoint\nCREATE VIRTUAL TABLE `history_fts_idx` USING fts5(\n body,\n content='history_fts',\n content_rowid='rowid',\n tokenize='unicode61 remove_diacritics 1'\n);--> statement-breakpoint\nCREATE TRIGGER `history_fts_ai` AFTER INSERT ON `history_fts` BEGIN\n INSERT INTO `history_fts_idx`(rowid, body) VALUES (NEW.rowid, NEW.body);\nEND;--> statement-breakpoint\nCREATE TRIGGER `history_fts_ad` AFTER DELETE ON `history_fts` BEGIN\n INSERT INTO `history_fts_idx`(`history_fts_idx`, rowid, body) VALUES('delete', OLD.rowid, OLD.body);\nEND;--> statement-breakpoint\nCREATE TRIGGER `history_fts_au` AFTER UPDATE ON `history_fts` BEGIN\n INSERT INTO `history_fts_idx`(`history_fts_idx`, rowid, body) VALUES('delete', OLD.rowid, OLD.body);\n INSERT INTO `history_fts_idx`(rowid, body) VALUES (NEW.rowid, NEW.body);\nEND;\n",timestamp:1780963200000,name:"20260609000000_history_fts"},{sql:"ALTER TABLE `workflow_run` ADD COLUMN `agent_timeout_ms` integer;\n",timestamp:1781046000000,name:"20260609230000_workflow_agent_timeout"},{sql:"CREATE TABLE `external_import` (\n `source` text NOT NULL,\n `source_key` text NOT NULL,\n `session_id` text NOT NULL,\n `source_path` text NOT NULL,\n `source_mtime` integer NOT NULL,\n `time_imported` integer NOT NULL,\n `message_ids` text,\n PRIMARY KEY (`source`, `source_key`)\n);\n\nINSERT INTO `external_import` (`source`, `source_key`, `session_id`, `source_path`, `source_mtime`, `time_imported`, `message_ids`)\nSELECT 'cc', `source_uuid`, `session_id`, `source_path`, `source_mtime`, `time_imported`, `message_ids`\nFROM `claude_import`;\n\nDROP TABLE `claude_import`;\n",timestamp:1781222400000,name:"20260612000000_external_import"}];if(o.length>0){if(lt.info("applying migrations",{count:o.length,mode:"bundled"}),nn.QITQODE_SKIP_MIGRATIONS)for(let t of o)t.sql="select 1;";jo(n,o)}return n});function xe(){Mn().$client.close(),Mn.reset()}var Xn=fn.create("database");function Ce(n){try{return n(Xn.use().tx)}catch(o){if(o instanceof fn.NotFound){let t=[],g=Xn.provide({effects:t,tx:Mn()},()=>n(Mn()));for(let e of t)e();return g}throw o}}function Je(n){let o=Wn.bind(n);try{Xn.use().effects.push(o)}catch{o()}}function He(n,o){try{return n(Xn.use().tx)}catch(t){if(t instanceof fn.NotFound){let g=[],e=Wn.bind((p)=>Xn.provide({tx:p,effects:g},()=>n(p))),T=Mn().transaction(e,{behavior:o?.behavior});for(let p of g)p();return T}throw t}}var dt={};dn(dt,{layer:()=>At,defaultLayer:()=>Ve,Service:()=>io,NotFoundError:()=>Uo});import Z from"path";var xn={};dn(xn,{layer:()=>Nt,defaultLayer:()=>Ke,Service:()=>to,Git:()=>xn});var Re=["--no-optional-locks","-c","core.autocrlf=false","-c","core.fsmonitor=false","-c","core.longpaths=true","-c","core.symlinks=true","-c","core.quotepath=false"],Yn=(n)=>n.text().trim(),Eo=(n)=>n.split("\x00").filter(Boolean),ce=(n)=>({exitCode:1,text:()=>"",stdout:Buffer.alloc(0),stderr:Buffer.from(n instanceof Error?n.message:String(n))}),st=(n)=>{if(n==="??")return"added";if(n.includes("U"))return"modified";if(n.includes("A")&&!n.includes("D"))return"added";if(n.includes("D")&&!n.includes("A"))return"deleted";return"modified"};class to extends Dn.Service()("@qitqode/Git"){}var Nt=h.effect(to,r.gen(function*(){let n=yield*jn.ChildProcessSpawner,o=r.fn("Git.run")(function*(f,s){let m=pt.make("git",[...Re,...f],{cwd:s.cwd,env:s.env,extendEnv:!0,stdin:"ignore",stdout:"pipe",stderr:"pipe"}),y=yield*_t(n,m);return{exitCode:y.code,text:()=>y.text,stdout:Buffer.from(y.text),stderr:Buffer.from(y.stderr)}},r.scoped,r.catch((f)=>r.succeed(ce(f)))),t=r.fn("Git.text")(function*(f,s){return(yield*o(f,s)).text()}),g=r.fn("Git.lines")(function*(f,s){return(yield*t(f,s)).split(/\r?\n/).map((m)=>m.trim()).filter(Boolean)}),e=r.fnUntraced(function*(f){return yield*g(["for-each-ref","--format=%(refname:short)","refs/heads"],{cwd:f})}),T=r.fnUntraced(function*(f,s){let m=yield*o(["config","init.defaultBranch"],{cwd:f}),y=Yn(m);if(!y||!s.includes(y))return;return{name:y,ref:y}}),p=r.fnUntraced(function*(f){let s=yield*g(["remote"],{cwd:f});if(s.includes("origin"))return"origin";if(s.length===1)return s[0];if(s.includes("upstream"))return"upstream";return s[0]}),A=r.fn("Git.branch")(function*(f){let s=yield*o(["symbolic-ref","--quiet","--short","HEAD"],{cwd:f});if(s.exitCode!==0)return;return Yn(s)||void 0}),M=r.fn("Git.prefix")(function*(f){let s=yield*o(["rev-parse","--show-prefix"],{cwd:f});if(s.exitCode!==0)return"";return Yn(s)}),H=r.fn("Git.defaultBranch")(function*(f){let s=yield*p(f);if(s){let i=yield*o(["symbolic-ref",`refs/remotes/${s}/HEAD`],{cwd:f});if(i.exitCode===0){let u=Yn(i).replace(/^refs\/remotes\//,""),$=u.startsWith(`${s}/`)?u.slice(`${s}/`.length):"";if($)return{name:$,ref:u}}}let m=yield*e(f),y=yield*T(f,m);if(y)return y;if(m.includes("main"))return{name:"main",ref:"main"};if(m.includes("master"))return{name:"master",ref:"master"}}),C=r.fn("Git.hasHead")(function*(f){return(yield*o(["rev-parse","--verify","HEAD"],{cwd:f})).exitCode===0}),J=r.fn("Git.mergeBase")(function*(f,s,m="HEAD"){let y=yield*o(["merge-base",s,m],{cwd:f});if(y.exitCode!==0)return;return Yn(y)||void 0}),R=r.fn("Git.show")(function*(f,s,m,y=""){let i=y?`${y}${m}`:m,u=yield*o(["show",`${s}:${i}`],{cwd:f});if(u.exitCode!==0)return"";if(u.stdout.includes(0))return"";return u.text()}),O=r.fn("Git.status")(function*(f){return Eo(yield*t(["status","--porcelain=v1","--untracked-files=all","--no-renames","-z","--","."],{cwd:f})).flatMap((s)=>{let m=s.slice(3);if(!m)return[];let y=s.slice(0,2);return[{file:m,code:y,status:st(y)}]})}),Q=r.fn("Git.diff")(function*(f,s){let m=Eo(yield*t(["diff","--no-ext-diff","--no-renames","--name-status","-z",s,"--","."],{cwd:f}));return m.flatMap((y,i)=>{if(i%2!==0)return[];let u=m[i+1];if(!y||!u)return[];return[{file:u,code:y,status:st(y)}]})}),I=r.fn("Git.stats")(function*(f,s){return Eo(yield*t(["diff","--no-ext-diff","--no-renames","--numstat","-z",s,"--","."],{cwd:f})).flatMap((m)=>{let y=m.indexOf("\t"),i=m.indexOf("\t",y+1);if(y===-1||i===-1)return[];let u=m.slice(i+1);if(!u)return[];let $=m.slice(0,y),B=m.slice(y+1,i),d=$==="-"?0:Number.parseInt($||"0",10),E=B==="-"?0:Number.parseInt(B||"0",10);return[{file:u,additions:Number.isFinite(d)?d:0,deletions:Number.isFinite(E)?E:0}]})});return to.of({run:o,branch:A,prefix:M,defaultBranch:H,hasHead:C,mergeBase:J,show:R,status:O,diff:Q,stats:I})})),Ke=Nt.pipe(h.provide(bn));var Tn=a.create({service:"storage"}),Uo=ro.create("NotFoundError",j.object({message:j.string()})),Ee=_.Struct({path:_.optional(_.Struct({root:_.optional(_.String)}))}),Pe=_.Struct({id:_.String}),We=_.Struct({id:_.String}),Ue=_.Struct({additions:_.Number,deletions:_.Number}),Ze=_.Struct({id:_.String,projectID:_.String,summary:_.Struct({diffs:_.Array(Ue)})}),Xe=_.decodeUnknownOption(Ee),Ye=_.decodeUnknownOption(Pe),ae=_.decodeUnknownOption(We),ze=_.decodeUnknownOption(Ze);class io extends Dn.Service()("@qitqode/Storage"){}function ke(n,o){return Z.join(n,...o)+".json"}function Po(n){if(!n||typeof n!=="object")return!1;if("code"in n&&n.code==="ENOENT")return!0;if("reason"in n&&n.reason&&typeof n.reason==="object"&&"_tag"in n.reason)return n.reason._tag==="NotFound";return!1}function qe(n){let o=Number.parseInt(n,10);return Number.isNaN(o)?0:o}var Tt=[r.fn("Storage.migration.1")(function*(n,o,t){let g=Z.resolve(n,"../project");if(!(yield*o.isDir(g)))return;let e=yield*o.glob("*",{cwd:g,include:"all"});for(let T of e){let p=Z.join(g,T);if(!(yield*o.isDir(p)))continue;Tn.info(`migrating project ${T}`);let A=T,M="/";if(A!=="global"){for(let J of yield*o.glob("storage/session/message/*/*.json",{cwd:p,absolute:!0})){let R=Xe(yield*o.readJson(J),{onExcessProperty:"preserve"}),O=an.isSome(R)?R.value.path?.root:void 0;if(!O)continue;M=O;break}if(!M)continue;if(!(yield*o.isDir(M)))continue;let H=yield*t.run(["rev-list","--max-parents=0","--all"],{cwd:M}),[C]=H.text().split(`
|
|
5
|
-
`).filter(Boolean).map((J)=>J.trim()).toSorted();if(!C)continue;A=C,yield*o.writeWithDirs(Z.join(n,"project",A+".json"),JSON.stringify({id:C,vcs:"git",worktree:M,time:{created:Date.now(),initialized:Date.now()}},null,2)),Tn.info(`migrating sessions for project ${A}`);for(let J of yield*o.glob("storage/session/info/*.json",{cwd:p,absolute:!0})){let R=Z.join(n,"session",A,Z.basename(J));Tn.info("copying",{sessionFile:J,dest:R});let O=yield*o.readJson(J),Q=Ye(O,{onExcessProperty:"preserve"});if(yield*o.writeWithDirs(R,JSON.stringify(O,null,2)),an.isNone(Q))continue;Tn.info(`migrating messages for session ${Q.value.id}`);for(let I of yield*o.glob(`storage/session/message/${Q.value.id}/*.json`,{cwd:p,absolute:!0})){let f=Z.join(n,"message",Q.value.id,Z.basename(I));Tn.info("copying",{msgFile:I,dest:f});let s=yield*o.readJson(I),m=ae(s,{onExcessProperty:"preserve"});if(yield*o.writeWithDirs(f,JSON.stringify(s,null,2)),an.isNone(m))continue;Tn.info(`migrating parts for message ${m.value.id}`);for(let y of yield*o.glob(`storage/session/part/${Q.value.id}/${m.value.id}/*.json`,{cwd:p,absolute:!0})){let i=Z.join(n,"part",m.value.id,Z.basename(y)),u=yield*o.readJson(y);Tn.info("copying",{partFile:y,dest:i}),yield*o.writeWithDirs(i,JSON.stringify(u,null,2))}}}}}}),r.fn("Storage.migration.2")(function*(n,o){for(let t of yield*o.glob("session/*/*.json",{cwd:n,absolute:!0})){let g=yield*o.readJson(t),e=ze(g,{onExcessProperty:"preserve"});if(an.isNone(e))continue;let T=e.value.summary.diffs;yield*o.writeWithDirs(Z.join(n,"session_diff",e.value.id+".json"),JSON.stringify(T,null,2)),yield*o.writeWithDirs(Z.join(n,"session",e.value.projectID,e.value.id+".json"),JSON.stringify({...g,summary:{additions:T.reduce((p,A)=>p+A.additions,0),deletions:T.reduce((p,A)=>p+A.deletions,0)}},null,2))}})],At=h.effect(io,r.gen(function*(){let n=yield*z.Service,o=yield*xn.Service,t=yield*Wo.make({lookup:()=>Cn.make(),idleTimeToLive:0}),g=yield*r.cached(r.gen(function*(){let O=Z.join(On.Path.data,"storage"),Q=Z.join(O,"migration"),I=yield*n.readFileString(Q).pipe(r.map(qe),r.catchIf(Po,()=>r.succeed(0)),r.orElseSucceed(()=>0));for(let f=I;f<Tt.length;f++){Tn.info("running migration",{index:f});let s=Tt[f],m=yield*r.exit(s(O,n,o));if(Zn.isFailure(m)){Tn.error("failed to run migration",{index:f,cause:m.cause});break}yield*n.writeWithDirs(Q,String(f+1))}return{dir:O}})),e=(O)=>r.fail(new Uo({message:`Resource not found: ${O}`})),T=(O,Q)=>Q.pipe(r.catchIf(Po,()=>e(O))),p=r.fnUntraced(function*(O,Q){yield*n.writeWithDirs(O,JSON.stringify(Q,null,2))}),A=(O,Q)=>r.scoped(r.gen(function*(){let I=ke((yield*g).dir,O);return yield*Q(I,yield*Wo.get(t,I))})),M=r.fn("Storage.remove")(function*(O){yield*A(O,(Q,I)=>Cn.withWriteLock(I,n.remove(Q).pipe(r.catchIf(Po,()=>r.void))))}),H=(O)=>r.gen(function*(){return yield*A(O,(I,f)=>Cn.withReadLock(f,T(I,n.readJson(I))))}),C=(O,Q)=>r.gen(function*(){return yield*A(O,(f,s)=>Cn.withWriteLock(s,r.gen(function*(){let m=yield*T(f,n.readJson(f));return Q(m),yield*p(f,m),m})))}),J=(O,Q)=>r.gen(function*(){yield*A(O,(I,f)=>Cn.withWriteLock(f,p(I,Q)))}),R=r.fn("Storage.list")(function*(O){let Q=(yield*g).dir,I=Z.join(Q,...O);return(yield*n.glob("**/*",{cwd:I,include:"file"}).pipe(r.catch(()=>r.succeed([])))).map((s)=>[...O,...s.slice(0,-5).split(Z.sep)]).toSorted((s,m)=>s.join("/").localeCompare(m.join("/")))});return io.of({remove:M,read:H,update:C,write:J,list:R})})),Ve=At.pipe(h.provide(z.defaultLayer),h.provide(xn.defaultLayer));export{cn as Ql,Hr as Rl,Kn as Sl,mn as Tl,G as Ul,ln as Vl,eo as Wl,Xo as Xl,Yo as Yl,ao as Zl,zo as _l,qo as $l,lo as am,Bn as bm,xn as cm,Uo as dm,dt as em,V as fm,Go as gm,Er as hm,se as im,Fr as jm,Te as km,on as lm,Wn as mm,Le as nm,et as om,mt as pm};
|
package/bundle/chunk-e3qtndrt.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{a,b,c,d,e,f,g}from"./chunk-11d987sj.js";import"./chunk-2ztdqtnk.js";import"./chunk-bx6kyvg7.js";import"./chunk-0yqbyres.js";import"./chunk-s6bar2f9.js";import"./chunk-2p9py4rw.js";import"./chunk-n3t52cz2.js";import"./chunk-yajd975f.js";import"./chunk-cjfgs1x8.js";import"./chunk-j0znryc6.js";import"./chunk-m2ny1en7.js";import"./chunk-09j71kp6.js";import"./chunk-js9wdh67.js";import"./chunk-0a0vat1h.js";import"./chunk-z8v2tsz2.js";import"./chunk-j8efst22.js";import"./chunk-8f0g7d7k.js";import"./chunk-abtn6nec.js";import"./chunk-d7t0bcvk.js";import"./chunk-7mc8nxve.js";import"./chunk-dfja6dj6.js";import"./chunk-n34y5gp6.js";import"./chunk-bn0h9dny.js";import"./chunk-q5363rr9.js";import"./chunk-7wthn44y.js";import"./chunk-a8p9aggx.js";import"./chunk-0xm85ayc.js";import"./chunk-s2za1n7h.js";import"./chunk-19sa03c1.js";import"./chunk-csdm3n24.js";import"./chunk-xk1nh1ay.js";import"./chunk-bsf6n350.js";import"./chunk-4vze3djr.js";import"./chunk-bzrsnv2k.js";import"./chunk-d0qqgxs4.js";import"./chunk-cqtkxwd8.js";import"./chunk-v00cptj6.js";import"./chunk-1d9f53sk.js";import"./chunk-svrxk3vf.js";import"./chunk-kkae8ead.js";import"./chunk-s6me101a.js";import"./chunk-jwtev7b7.js";import"./chunk-b9nwaaqs.js";import"./chunk-qsszerj7.js";import"./chunk-6jewfaqa.js";import"./chunk-6hdjkvr1.js";import"./chunk-1rn0vmvv.js";import"./chunk-fsy279s5.js";import"./chunk-hn1f6rne.js";import"./chunk-4kpvceap.js";import"./chunk-94qmhz2p.js";import"./chunk-20d0cd1j.js";import"./chunk-yn576pje.js";import"./chunk-b6dsv601.js";import"./chunk-j2zay4da.js";import"./chunk-4vemws1t.js";import"./chunk-yvqbewmc.js";import"./chunk-t299e2aw.js";import"./chunk-bv8pf0m1.js";import"./chunk-4mrz9b6d.js";import"./chunk-yjj4cvqg.js";export{f as statusEffect,a as resolveApiKeyFlag,e as logoutEffect,d as loginEffect,c as interactiveLogin,b as apiKeyLoginEffect,g as AuthCommand};
|
package/bundle/chunk-e8cac405.js
DELETED
package/bundle/chunk-ez92ah9y.js
DELETED
package/bundle/chunk-fazvedgy.js
DELETED
package/bundle/chunk-gtzcm5sb.js
DELETED
package/bundle/chunk-kfgn4apg.js
DELETED
package/bundle/chunk-kzrw6h8t.js
DELETED
package/bundle/chunk-mjrvj2cg.js
DELETED