@shumai-one/shumai 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/chunk-02b5bcmc.js +1 -0
- package/bin/chunk-09mj32d7.js +2 -0
- package/bin/{chunk-bg6waaf9.js → chunk-09mpcg9x.js} +2 -2
- package/bin/{chunk-ahgq10a7.js → chunk-0a298n62.js} +2 -2
- package/bin/chunk-0rgbxp24.js +3 -0
- package/bin/{chunk-9s0k533c.js → chunk-19zbh4fr.js} +1 -1
- package/bin/{chunk-c6f8x05m.js → chunk-1e1q1hyg.js} +2 -2
- package/bin/chunk-1ja2zw4w.js +2 -0
- package/bin/chunk-1tar0x8s.js +7 -0
- package/bin/{chunk-p1ed0pa6.js → chunk-1y6h4vge.js} +1 -1
- package/bin/{chunk-d18v5vmp.js → chunk-20bamhwa.js} +2 -2
- package/bin/chunk-20w1w9x7.js +2 -0
- package/bin/{chunk-b7qs7hxg.js → chunk-25npafhz.js} +2 -2
- package/bin/chunk-2qgagdb7.js +1 -0
- package/bin/chunk-2t6g3pny.js +3 -0
- package/bin/chunk-34f64q0q.js +2 -0
- package/bin/{chunk-kywdke0y.js → chunk-3hgrw1m0.js} +5 -5
- package/bin/{chunk-16n160h1.js → chunk-3s2ga6mt.js} +1 -1
- package/bin/{chunk-r9gp9yqw.js → chunk-3vpz5nat.js} +1 -1
- package/bin/chunk-4p31kxjh.js +3 -0
- package/bin/{chunk-3j82q2gj.js → chunk-4vjgdj0h.js} +1 -1
- package/bin/chunk-50pfmxt1.js +2 -0
- package/bin/chunk-5ddg5ezb.js +55 -0
- package/bin/chunk-5ngftxjb.js +218 -0
- package/bin/chunk-6f3zhq64.js +5 -0
- package/bin/chunk-6nqqe7w9.js +1 -0
- package/bin/chunk-6t525bmg.js +1 -0
- package/bin/chunk-7546ptwg.js +32 -0
- package/bin/chunk-7jz3cmq6.js +2 -0
- package/bin/{chunk-ht5rht98.js → chunk-7kah3zb5.js} +2 -2
- package/bin/chunk-7mawxsk3.js +2 -0
- package/bin/{chunk-fxtzy5f5.js → chunk-88jg9dq5.js} +2 -2
- package/bin/chunk-8ww98y1m.js +2 -0
- package/bin/chunk-9405hzv2.js +2 -0
- package/bin/chunk-95b4mwyq.js +2 -0
- package/bin/chunk-9vxmgvc8.js +2 -0
- package/bin/chunk-9x42vgeq.js +16 -0
- package/bin/{chunk-s01p4w8d.js → chunk-a74g6h8a.js} +2 -2
- package/bin/{chunk-am6dg0a5.js → chunk-a859y4e1.js} +2 -2
- package/bin/chunk-addssm8d.js +1 -0
- package/bin/chunk-ajq9sxg0.js +129 -0
- package/bin/chunk-amp9h878.js +2 -0
- package/bin/chunk-atdfqdkj.js +7 -0
- package/bin/{chunk-dfecgpce.js → chunk-atpt99h4.js} +13 -13
- package/bin/chunk-awshe30f.js +1 -0
- package/bin/chunk-b3t7gbhm.js +2 -0
- package/bin/chunk-bbxwyhz3.js +4 -0
- package/bin/chunk-bd3v8mp1.js +7 -0
- package/bin/chunk-brgns7hv.js +2 -0
- package/bin/chunk-c02727j9.js +2 -0
- package/bin/chunk-c1wvs81k.js +2 -0
- package/bin/chunk-c8frmqsk.js +2 -0
- package/bin/chunk-cagzye3j.js +2 -0
- package/bin/{chunk-b9d8xdhb.js → chunk-cp96e9pq.js} +1 -1
- package/bin/chunk-d55138xx.js +5 -0
- package/bin/{chunk-3me1v3z5.js → chunk-ddmf9gqv.js} +2 -2
- package/bin/chunk-djb65frk.js +1 -0
- package/bin/{chunk-hzv1mhr5.js → chunk-dkhdn92k.js} +2 -2
- package/bin/chunk-dx9f5wab.js +1 -0
- package/bin/chunk-dygj751y.js +393 -0
- package/bin/chunk-e55sgg8t.js +2 -0
- package/bin/{chunk-fre31bhw.js → chunk-enax4303.js} +2 -2
- package/bin/{chunk-jb8vbeb0.js → chunk-erfkd3z9.js} +2 -2
- package/bin/chunk-esj0kwe5.js +12 -0
- package/bin/chunk-etrm28sy.js +2 -0
- package/bin/chunk-ex3174e3.js +2 -0
- package/bin/{chunk-bs6saf4d.js → chunk-eyjfhdp9.js} +2 -2
- package/bin/{chunk-r5g84kj4.js → chunk-ezjxx44x.js} +3 -3
- package/bin/chunk-f4xnx4n6.js +1 -0
- package/bin/{chunk-jq3pq545.js → chunk-f8hgy69t.js} +2 -2
- package/bin/chunk-fakph5jp.js +1 -0
- package/bin/{chunk-1eqw2dpx.js → chunk-femnbfkj.js} +2 -2
- package/bin/chunk-ffjdkdcv.js +2 -0
- package/bin/chunk-gd016e9p.js +2 -0
- package/bin/chunk-gyv3yrhj.js +2 -0
- package/bin/{chunk-sd6w0z6a.js → chunk-h2bphev9.js} +2 -2
- package/bin/chunk-h3atwgx2.js +1 -0
- package/bin/chunk-h7xny3de.js +2 -0
- package/bin/chunk-hg3rkp41.js +11 -0
- package/bin/chunk-hpzk9k55.js +1 -0
- package/bin/chunk-hsyfrzdd.js +1 -0
- package/bin/chunk-hvyy8vct.js +3 -0
- package/bin/chunk-j2s311yc.js +3 -0
- package/bin/{chunk-swz6v48q.js → chunk-j2txsbxz.js} +2 -2
- package/bin/chunk-j6x53e33.js +1 -0
- package/bin/chunk-jacanzp7.js +1 -0
- package/bin/chunk-jc7dycy6.js +2 -0
- package/bin/{chunk-6hzktewz.js → chunk-jt02kpfc.js} +2 -2
- package/bin/chunk-k7vbk8v4.js +3 -0
- package/bin/chunk-mn0kt3p6.js +3 -0
- package/bin/chunk-mn71dffh.js +4 -0
- package/bin/chunk-npeapp7e.js +7 -0
- package/bin/{chunk-qqj2m1b1.js → chunk-p2vsdnd1.js} +2 -2
- package/bin/chunk-pdw77q09.js +2 -0
- package/bin/chunk-pq6kdp83.js +4 -0
- package/bin/chunk-ptcz4ed3.js +2 -0
- package/bin/chunk-q1fzgqsv.js +2 -0
- package/bin/chunk-q4ny4hpt.js +2 -0
- package/bin/{chunk-wsprap60.js → chunk-q5x0yywj.js} +2 -2
- package/bin/{chunk-h6f2gyt5.js → chunk-q8xr1a8j.js} +2 -2
- package/bin/chunk-q8ysc5ex.js +1 -0
- package/bin/chunk-qm50g4n5.js +10 -0
- package/bin/chunk-qvp24w0q.js +2 -0
- package/bin/chunk-r6t0j0jx.js +11 -0
- package/bin/chunk-s1j4v33x.js +2 -0
- package/bin/{chunk-n412a1hp.js → chunk-s6pk2zyg.js} +6 -6
- package/bin/chunk-s74g9vsk.js +3 -0
- package/bin/chunk-sz19nn1x.js +2 -0
- package/bin/{chunk-agcnbjxk.js → chunk-sz5zawfw.js} +2 -2
- package/bin/chunk-t68y25gf.js +1 -0
- package/bin/chunk-te484xtb.js +13 -0
- package/bin/{chunk-c60j1b4w.js → chunk-tfrevef9.js} +1 -1
- package/bin/chunk-thpw6tcj.js +2 -0
- package/bin/{chunk-w4ydfy9d.js → chunk-v0yevesp.js} +7 -7
- package/bin/chunk-vj4gamdn.js +2 -0
- package/bin/chunk-vmwys2ch.js +2 -0
- package/bin/chunk-vnmggrd6.js +18 -0
- package/bin/{chunk-d4hk62q2.js → chunk-vv0m0m2f.js} +4 -4
- package/bin/chunk-w6g84d59.js +8 -0
- package/bin/chunk-wgvgtttc.js +13 -0
- package/bin/chunk-xy9qpn6b.js +1 -0
- package/bin/{chunk-0tvnfy4k.js → chunk-y3haqtr8.js} +2 -2
- package/bin/chunk-y5dv67mg.js +2 -0
- package/bin/chunk-yb4mzqrd.js +5 -0
- package/bin/chunk-z0de127n.js +5 -0
- package/bin/chunk-z8t6e0ee.js +1 -0
- package/bin/chunk-zfg4yy3c.js +2 -0
- package/bin/{chunk-acmr8v0d.js → chunk-zkvezz89.js} +1 -1
- package/bin/chunk-zrrnvdxq.js +3 -0
- package/bin/chunk-zx1c4vm5.js +42 -0
- package/bin/chunk-zzqse5qc.js +2 -0
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +942 -1015
- package/package.json +7 -7
- package/prisma/migrations/20261026024507_hash_api_tokens/migration.sql +28 -0
- package/prisma/migrations/20261026031904_add_audit_log_via/migration.sql +2 -0
- package/prisma/migrations/20261029024626_add_oauth_and_jwks/migration.sql +205 -0
- package/prisma/migrations/20261029030321_default_empty_arrays_oauth/migration.sql +25 -0
- package/prisma/schema.prisma +186 -1
- package/bin/chunk-0502p2k7.js +0 -3
- package/bin/chunk-0b0t6y8h.js +0 -11
- package/bin/chunk-1vt9ss7d.js +0 -2
- package/bin/chunk-23780yj6.js +0 -3
- package/bin/chunk-2cpsfc87.js +0 -1
- package/bin/chunk-2w0d9veg.js +0 -2
- package/bin/chunk-2xp9prpq.js +0 -1
- package/bin/chunk-3gqs15zq.js +0 -2
- package/bin/chunk-3pw7z25v.js +0 -3
- package/bin/chunk-3tx9v8kj.js +0 -2
- package/bin/chunk-3wdtp4ht.js +0 -1
- package/bin/chunk-57axjy7y.js +0 -1
- package/bin/chunk-5aqthcm6.js +0 -5
- package/bin/chunk-5gq4q1bb.js +0 -2
- package/bin/chunk-5r1br11d.js +0 -2
- package/bin/chunk-61hrdg0g.js +0 -1
- package/bin/chunk-6aa4xmnw.js +0 -2
- package/bin/chunk-6mrgtn78.js +0 -18
- package/bin/chunk-6s55r0z9.js +0 -1
- package/bin/chunk-6vkfzzvt.js +0 -5
- package/bin/chunk-7dprpnm6.js +0 -2
- package/bin/chunk-7rycq6wb.js +0 -129
- package/bin/chunk-895gzdtp.js +0 -7
- package/bin/chunk-8d1p8qpv.js +0 -1
- package/bin/chunk-8r3k84dh.js +0 -2
- package/bin/chunk-99sarrvt.js +0 -3
- package/bin/chunk-b21z62fj.js +0 -1
- package/bin/chunk-bv589v2m.js +0 -3
- package/bin/chunk-c8kjpmfe.js +0 -2
- package/bin/chunk-c9xyejnk.js +0 -2
- package/bin/chunk-cb9peqy5.js +0 -2
- package/bin/chunk-ckczqmrz.js +0 -5
- package/bin/chunk-cr33cs6j.js +0 -2
- package/bin/chunk-cxet91kt.js +0 -2
- package/bin/chunk-d7e351jd.js +0 -6
- package/bin/chunk-ebcfbn00.js +0 -2
- package/bin/chunk-f0b4a9y3.js +0 -2
- package/bin/chunk-fkn6f4qt.js +0 -4
- package/bin/chunk-g78vapcm.js +0 -2
- package/bin/chunk-gdpfwxea.js +0 -4
- package/bin/chunk-gwqqq0b1.js +0 -32
- package/bin/chunk-h3cwf9aw.js +0 -2
- package/bin/chunk-h4ty530v.js +0 -16
- package/bin/chunk-h58yfx7w.js +0 -2
- package/bin/chunk-h9ngpxyd.js +0 -1
- package/bin/chunk-hbr17jvr.js +0 -13
- package/bin/chunk-hc0xbmtt.js +0 -5
- package/bin/chunk-j9t7tvt5.js +0 -2
- package/bin/chunk-jvt8q0eg.js +0 -2
- package/bin/chunk-jzgtthsj.js +0 -3
- package/bin/chunk-jzjhg7ng.js +0 -1
- package/bin/chunk-k547syp2.js +0 -2
- package/bin/chunk-k7sjpke6.js +0 -2
- package/bin/chunk-k8ct1qgv.js +0 -3
- package/bin/chunk-k9q4nn8b.js +0 -11
- package/bin/chunk-keetdtxb.js +0 -2
- package/bin/chunk-kjjw8mbg.js +0 -1
- package/bin/chunk-mey80kv9.js +0 -54
- package/bin/chunk-nfncawpm.js +0 -12
- package/bin/chunk-nvwt8atc.js +0 -1
- package/bin/chunk-p1d500sf.js +0 -211
- package/bin/chunk-q0vs124k.js +0 -2
- package/bin/chunk-q5795f3s.js +0 -2
- package/bin/chunk-q5j3b0h5.js +0 -3
- package/bin/chunk-qd7pvaxb.js +0 -2
- package/bin/chunk-qhpt7170.js +0 -2
- package/bin/chunk-qt78vs3g.js +0 -2
- package/bin/chunk-ra6mdjr0.js +0 -1
- package/bin/chunk-ryfvaz6v.js +0 -3
- package/bin/chunk-s22eapcc.js +0 -2
- package/bin/chunk-sbg86tch.js +0 -2
- package/bin/chunk-sbqy6m8t.js +0 -1
- package/bin/chunk-sdp9w627.js +0 -14
- package/bin/chunk-sn0nypvd.js +0 -42
- package/bin/chunk-sv92vkyh.js +0 -2
- package/bin/chunk-t6cn018t.js +0 -3
- package/bin/chunk-ts4d1mxf.js +0 -2
- package/bin/chunk-wkdkc12e.js +0 -4
- package/bin/chunk-xgnvktq6.js +0 -10
- package/bin/chunk-xjw3mpvx.js +0 -1
- package/bin/chunk-xsfy8hz3.js +0 -2
- package/bin/chunk-xznq2axj.js +0 -1
- package/bin/chunk-y4v08wq7.js +0 -1
- package/bin/chunk-yncvy335.js +0 -3
- package/bin/chunk-ytzddcj2.js +0 -1
- package/bin/chunk-zxqasmvz.js +0 -2
package/bin/chunk-sv92vkyh.js
DELETED
package/bin/chunk-t6cn018t.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
var k=Object.create;var{getPrototypeOf:l,defineProperty:f,getOwnPropertyNames:m}=Object;var j=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,H=(a,b,c)=>{var d=a!=null&&typeof a==="object";if(d){var h=b?o??=new WeakMap:p??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?k(l(a)):{};let e=b||!a||!a.__esModule||!j.call(a,"default")?f(c,"default",{value:a,enumerable:!0}):c;if(a&&typeof a==="object"||typeof a==="function"){for(let g of m(a))if(!j.call(e,g))f(e,g,{get:n.bind(a,g),enumerable:!0})}if(d)h.set(a,e);return e};var w=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var q=(a)=>a;function r(a,b){this[a]=q.bind(null,b)}var qe=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0,configurable:!0,set:r.bind(b,c)})};var Zm=(a,b,c)=>()=>{if(a)try{b=a(a=0)}catch(d){c=[d]}if(c)throw c[0];return b};var Bm=(a)=>JSON.parse(a);var Um=(a,b,c)=>{for(var d in b)f(a,d,{get:b[d],set:c[d],enumerable:!0,configurable:!0})},V=import.meta.require;
|
|
3
|
-
export{H,w,qe,Zm,Bm,Um,V};
|
package/bin/chunk-ts4d1mxf.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{I}from"./chunk-p1d500sf.js";var e=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Jn=I("user",e);var c=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],fo=I("users",c);
|
|
2
|
-
export{Jn,fo};
|
package/bin/chunk-wkdkc12e.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{jr,ii,vf,e,h,d,x,U,i,r,T,y,l,s}from"./chunk-mey80kv9.js";function ya(t){return{ok:!0,value:t}}function os(t){return{ok:!1,error:t}}async function D(t){let n=await t;if(!n.ok)throw n.error;return n.value}class I extends Error{rawValue;rawMessage;static[Symbol.hasInstance](t){if(!(t instanceof Error))return!1;if(!("rawValue"in t))return!1;if(!("rawMessage"in t))return!1;if(!("pretty"in t))return!1;if(typeof t.pretty!=="function")return!1;return!0}constructor(t,n,o){super(`${t}: ${n}`);this.name="SDKValidationError",this.cause=n,this.rawValue=o,this.rawMessage=t}pretty(){if(this.cause instanceof ii)return`${this.rawMessage}
|
|
3
|
-
${mf(this.cause)}`;else return this.toString()}}function mf(t){return vf(t)}function c(t,n){let o={};if(!Object.keys(n).length)return o=t,o;for(let[u,a]of Object.entries(t)){let m=n[u];if(m===null)continue;o[m??u]=a}return o}function b(t){let n={};for(let[o,u]of Object.entries(t))if(typeof u<"u")n[o]=u;return n}function v(t,n,o){try{return ya(n(t))}catch(u){return os(new I(o,u,t))}}function w(t){return O++,t}var O=0,P=0;function N(){P++;let t=O;return{end:(n)=>{let o=O-t;if(O=t+(n??o),--P===0)O=0;return o}}}function J(t){let n=Object.values(t);return T([...n.map((o)=>l(o)),e().transform((o)=>w(o))])}function rl(t){let n=Object.values(t).filter((o)=>typeof o==="number");return T([...n.map((o)=>l(o)),h().transform((o)=>w(o))])}function bt(t){return e()}function Cm(t){return h()}var M=Symbol("UNKNOWN");function K(t){return typeof t==="object"&&t!==null&&M in t}function tt(t,n,o={}){let{unknownValue:u="UNKNOWN",outputPropertyName:a}=o;return U().transform((m)=>{let f=Object.defineProperties({raw:m,[a??t]:u,isUnknown:!0},{[M]:{value:!0,enumerable:!1,configurable:!1}});if(!(typeof m==="object"&&m!==null))return f;let S=m[t];if(typeof S!=="string")return f;if(!(S in n))return f;let F=n[S];if(!F)return f;let g=N(),C=F.safeParse(m);if(!C.success)return g.end(0),f;if(g.end(),a)C.data[a]=S;return C.data})}var Y=/^\d{4}-\d{2}-\d{2}$/;class j{serialized;static today(){return new j(new Date)}constructor(t){if(typeof t==="string"&&!Y.test(t))throw RangeError("RFCDate: date strings must be in the format YYYY-MM-DD: "+t);let n=new Date(t);if(isNaN(+n))throw RangeError("RFCDate: invalid date provided: "+t);if(this.serialized=n.toISOString().slice(0,10),!Y.test(this.serialized))throw TypeError(`RFCDate: failed to build valid date with given value: ${t} serialized to ${this.serialized}`)}toJSON(){return this.toString()}toString(){return this.serialized}}function k(t){return U().transform((n,o)=>{let u=[],a=t.map(()=>[]),m=N();for(let[z,S]of t.entries()){let F=N(),g=S.safeParse(n),C=F.end(),ie=0;if(g.success){u.push({data:g.data,inexactCount:C,zeroDefaultCount:0,fieldCount:-1});continue}a[z].push(...g.error.issues)}if(u.length===0)return m.end(0),o.addIssue({input:n,code:"invalid_union",errors:a}),jr;let f=u[0];for(let z of u){if(u.length>1)z.fieldCount=ne(z.data);f=te(z,f)}return m.end(f.inexactCount),f.data})}function te(t,n){let o=t.inexactCount===0,u=n.inexactCount===0;if(o!==u)return o?t:n;let a=t.fieldCount-t.zeroDefaultCount,m=n.fieldCount-n.zeroDefaultCount;if(a!==m)return a>m?t:n;return t.inexactCount<n.inexactCount?t:n}function ne(t){let n=0,o=[t],u=0;while(u<o.length){let a=o[u++];if(a===void 0||K(a))continue;let m=typeof a;if(a===null||m==="number"||m==="string"||m==="boolean"||m==="bigint"||a instanceof Date||a instanceof j){n++;continue}if(Array.isArray(a)){o.push(...a);continue}if(m==="object")o.push(...Object.values(a))}return n}var B=r({type:l("input_audio"),input_audio:e()}).transform((t)=>c(t,{input_audio:"inputAudio"})),V=r({type:l("input_audio"),inputAudio:e()}).transform((t)=>c(t,{inputAudio:"input_audio"}));var Li=r({type:l("document_url").default("document_url"),document_url:e(),document_name:s(e()).optional()}).transform((t)=>c(t,{document_url:"documentUrl",document_name:"documentName"})),Xs=r({type:l("document_url").default("document_url"),documentUrl:e(),documentName:s(e()).optional()}).transform((t)=>c(t,{documentUrl:"document_url",documentName:"document_name"}));var W=r({type:l("file").default("file"),file_id:e()}).transform((t)=>c(t,{file_id:"fileId"})),mc=r({type:l("file").default("file"),fileId:e()}).transform((t)=>c(t,{fileId:"file_id"}));var Z={Low:"low",Auto:"auto",High:"high"},q=J(Z),G=bt(Z);var L=r({url:e(),detail:s(q).optional()}),A=r({url:e(),detail:s(G).optional()});var Ie=k([L,e()]),we=k([A,e()]);var Zi=r({type:l("image_url").default("image_url"),image_url:k([L,e()])}).transform((t)=>c(t,{image_url:"imageUrl"})),ei=r({type:l("image_url").default("image_url"),imageUrl:k([A,e()])}).transform((t)=>c(t,{imageUrl:"image_url"}));var Ae=k([h(),e()]),ve=k([h(),e()]);var _=r({type:l("reference").default("reference"),reference_ids:i(k([h(),e()]))}).transform((t)=>c(t,{reference_ids:"referenceIds"})),R=r({type:l("reference").default("reference"),referenceIds:i(k([h(),e()]))}).transform((t)=>c(t,{referenceIds:"reference_ids"}));var ss=r({type:l("text").default("text"),text:e()}),is=r({type:l("text").default("text"),text:e()});var H={WebSearch:"web_search",WebSearchPremium:"web_search_premium",CodeInterpreter:"code_interpreter",ImageGeneration:"image_generation",DocumentLibrary:"document_library"},yn=J(H),ti=bt(H);var Ve=k([yn,e()]),We=k([ti,e()]);var ba=r({type:l("tool_reference").default("tool_reference"),tool:k([yn,e()]),title:e(),url:s(e()).optional(),favicon:s(e()).optional(),description:s(e()).optional()}),hc=r({type:l("tool_reference").default("tool_reference"),tool:k([ti,e()]),title:e(),url:s(e()).optional(),favicon:s(e()).optional(),description:s(e()).optional()});var Xe=k([ba,ss,_]),et=k([hc,is,R]);var Bi=r({type:l("thinking").default("thinking"),thinking:i(k([ba,ss,_])),signature:s(e()).optional(),closed:d().optional()}),Ui=r({type:l("thinking").default("thinking"),thinking:i(k([hc,is,R])),signature:s(e()).optional(),closed:d().optional()});var nl=tt("type",{image_url:Zi.and(r({type:l("image_url")})),document_url:Li.and(r({type:l("document_url")})),text:ss.and(r({type:l("text")})),reference:_.and(r({type:l("reference")})),file:W.and(r({type:l("file")})),thinking:Bi.and(r({type:l("thinking")})),input_audio:B}),ri=T([ei.and(r({type:l("image_url")})),Xs.and(r({type:l("document_url")})),is.and(r({type:l("text")})),R.and(r({type:l("reference")})),mc.and(r({type:l("file")})),Ui.and(r({type:l("thinking")})),V]);var ft=k([y(e(),x()),e()]),dt=k([y(e(),x()),e()]);var Q=r({name:e(),arguments:k([y(e(),x()),e()])}),X=r({name:e(),arguments:k([y(e(),x()),e()])});var Cu=r({id:e().default("null"),type:e().optional(),function:Q,index:h().default(0)}),Im=r({id:e().default("null"),type:e().optional(),function:X,index:h().default(0)});var Ot=k([e(),i(nl)]);var Iu=r({role:s(e()).optional(),content:s(k([e(),i(nl)])).optional(),tool_calls:s(i(Cu)).optional(),tool_call_id:s(e()).optional(),index:s(h()).optional(),metadata:s(y(e(),x())).optional()}).transform((t)=>c(t,{tool_calls:"toolCalls",tool_call_id:"toolCallId"}));var qo=r({prompt_tokens:h().default(0),completion_tokens:h().default(0),total_tokens:h().default(0),prompt_audio_seconds:s(h()).optional()}).catchall(x()).transform((t)=>c(t,{prompt_tokens:"promptTokens",completion_tokens:"completionTokens",total_tokens:"totalTokens",prompt_audio_seconds:"promptAudioSeconds"})),gc=r({promptTokens:h().default(0),completionTokens:h().default(0),totalTokens:h().default(0),promptAudioSeconds:s(h()).optional()}).catchall(x()).transform((t)=>({...c(t,{promptTokens:"prompt_tokens",completionTokens:"completion_tokens",totalTokens:"total_tokens",promptAudioSeconds:"prompt_audio_seconds"})}));var oe={Stop:"stop",Length:"length",Error:"error",ToolCalls:"tool_calls"},re=J(oe),ee=r({index:h(),delta:Iu,finish_reason:s(re)}).transform((t)=>c(t,{finish_reason:"finishReason"}));var hf=r({id:e(),object:e().optional(),created:h().optional(),model:e(),usage:qo.optional(),choices:i(ee)});function Tm(t){return v(t,(n)=>hf.parse(JSON.parse(n)),"Failed to parse 'CompletionChunk' from JSON")}
|
|
4
|
-
export{mf,ya,os,D,v,c,b,J,rl,bt,Cm,tt,k,Li,Xs,mc,Zi,ei,ss,is,yn,ti,ba,hc,Bi,Ui,nl,ri,Cu,Im,Iu,qo,gc,hf,Tm};
|
package/bin/chunk-xgnvktq6.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import{F,P,m,N,_,u,E,L,t,o,B,g,I,ea,ve,Qt,ar,Ra,we,Ne,S,un,dn,fn,pn,Ce,Ie,Te,D_,kb,Wb,up,nS,tI,aI,lI,R1,gt,Ei,Je,Xe,et,Ws,Vr,Gt,fe}from"./chunk-p1d500sf.js";import{To,In,zr,ma}from"./chunk-cxet91kt.js";import{ec}from"./chunk-1vt9ss7d.js";var At=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],xu=I("arrow-left",At);var Et=[["path",{d:"m11 10 3 3",key:"fzmg1i"}],["path",{d:"M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z",key:"p4q2r7"}],["path",{d:"M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031",key:"wy6l02"}]],ze=I("brush",Et);var It=[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]],je=I("redo",It);var Rt=[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]],$e=I("undo",Rt);E();var Dt=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#a855f7","#ec4899","#000000","#ffffff"],Ys=F(({projectId:y,onSendMessage:Be,replyingTo:d,onCancelReply:ne,placeholder:He,initialText:V="",value:D,onChangeText:T,disabled:pe=!1,allowMentions:Oe,disableMentions:qe=!1,allowAttachments:We=!0,workspaceAssets:w,onRemoveWorkspaceAsset:ge,allowMarkup:Ke,hideAnnotationControl:Ve=!1,canMarkup:Qe=!0,markupDisabledTooltip:Ge,allowTimestamp:Ye=!0,currentTime:f,frameRate:b,startTimecode:be,formatTimestamp:k,bottomLeftExtra:Ze,isStreaming:oe=!1,onAbort:tt,onTyping:U},nt)=>{let[h,z]=u([]),[re,X]=u(null),[x,ot]=u(!0),j=Oe??!qe,rt=Ke??!Ve,H=Ye,{videoTimeDisplayMode:Q}=Gt(),at=N(()=>{if(f===void 0)return"";if(k)return k(f);if(!b)return"";let e=Math.round(f*b);return In(e,b,Q,be)},[f,b,Q,be,k]),{teamId:G,ensureTeamIdForProject:he}=gt(),{members:xe,loading:ye,fetchMembers:st,fetchProjectMembers:lt}=Vr();m(()=>{if(y&&!G)he(y)},[y,G,he]);let{isDrawing:it,setIsDrawing:O,currentTool:J,setTool:Y,currentColor:ke,setColor:ct,undo:dt,redo:ut,history:mt,historyIndex:Me,annotations:ae,reset:Ae}=zr(),[se,C]=u(!1),[le,pt]=u(""),[q,W]=u(0),[v,Ee]=u({bots:!1,users:!1}),[ie,M]=u(!1),ft=N(()=>{if(!x||!H||f===void 0||!k&&!b||ie)return"";if(Q==="timecode")return"pl-[120px]";return"pl-[85px]"},[x,H,f,b,ie,Q,k]),s=_(null),Z=_(null),A=_(null),Re=_(null),R=_(!1),{mutateAsync:De}=B({mutationFn:async({projectId:e,data:n})=>{let r=await g.api.projects[":projectId"].attachments.$post({param:{projectId:e},json:n});if(!r.ok)throw Error("Failed to create attachment");return await r.json()}});m(()=>{if(D!==void 0&&s.current){if(R.current){R.current=!1;return}if(s.current.innerText!==D)s.current.innerText=D,M(!!D.trim())}else if(V&&s.current){s.current.innerText=V,M(!!V.trim()),s.current.focus();let e=document.createRange(),n=window.getSelection();e.selectNodeContents(s.current),e.collapse(!1),n?.removeAllRanges(),n?.addRange(e)}},[D,V]);let ce=_(null),Le=P((e)=>{if(!s.current)return;let n=document.createElement("span");n.contentEditable="false",n.dataset.type="mention",n.dataset.id=e.id,n.className="inline-block bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300 px-1.5 py-0.5 rounded-md text-sm font-medium align-middle select-none mx-0.5",n.innerText=`@${e.name}`;let r=document.createTextNode(" ");s.current.appendChild(n),s.current.appendChild(r);let l=document.createRange(),i=window.getSelection();l.setStartAfter(r),l.collapse(!0),i?.removeAllRanges(),i?.addRange(l),M(!0);let a=s.current.innerText||"";R.current=!0,T?.(a),U?.(),s.current.focus()},[T,U]);m(()=>{if(d&&s.current){if(d.id!==ce.current){if(ce.current=d.id,j&&d.creator?.id&&d.creator?.name){let r=s.current.querySelectorAll('span[data-type="mention"]');if(!Array.from(r).some((i)=>i.dataset.id===d.creator.id)){Le({id:d.creator.id,name:d.creator.name});return}}}s.current.focus();let e=document.createRange(),n=window.getSelection();e.selectNodeContents(s.current),e.collapse(!1),n?.removeAllRanges(),n?.addRange(e)}else if(!d)ce.current=null},[d,j,Le]),m(()=>()=>{O(!1)},[O]);let K=xe.filter((e)=>e.type==="agent"&&e.name?.toLowerCase().startsWith(le.toLowerCase())).map((e)=>({type:"user",data:e})),ee=xe.filter((e)=>e.type!=="agent"&&e.name?.toLowerCase().startsWith(le.toLowerCase())).map((e)=>({type:"user",data:e})),te=[...v.bots?[]:K,...v.users?[]:ee];m(()=>{W(0)},[le,se,v]),m(()=>{Re.current?.querySelector(`[data-index="${q}"]`)?.scrollIntoView({block:"nearest"})},[q]);let Se=(e)=>e.split(" ").map((n)=>n[0]).slice(0,2).join("").toUpperCase(),Pe=()=>{if(!s.current)return;let e=s.current.innerText||"";if(M(!!e.trim()),R.current=!0,T?.(e),U?.(),!j){C(!1),A.current=null;return}let n=window.getSelection();if(!n||n.rangeCount===0)return;let r=n.getRangeAt(0),{startContainer:l,startOffset:i}=r;if(l.nodeType===Node.TEXT_NODE){let c=(l.textContent||"").slice(0,i),p=c.lastIndexOf("@");if(p!==-1){let Ct=p===0,Mt=c[p-1];if(Ct||/\s/.test(Mt)){let _e=c.slice(p+1);if(!/\s/.test(_e)){if(pt(_e),C(!0),y)lt(y,!0,!0);else if(G)st(G,!0,!0);let me=document.createRange();me.setStart(l,p),me.setEnd(l,i),A.current=me;return}}}}C(!1),A.current=null},de=(e)=>{if(!A.current||!s.current)return;let n=A.current;n.deleteContents();let r=document.createElement("span");r.contentEditable="false",r.dataset.type="mention",r.dataset.id=e.data.id,r.className="inline-block bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300 px-1.5 py-0.5 rounded-md text-sm font-medium align-middle select-none mx-0.5",r.innerText=`@${e.data.name}`,n.insertNode(r);let l=document.createTextNode(" ");r.after(l);let i=document.createRange(),a=window.getSelection();i.setStartAfter(l),i.collapse(!0),a?.removeAllRanges(),a?.addRange(i),C(!1),A.current=null,M(!0);let c=s.current.innerText||"";R.current=!0,T?.(c),U?.(),s.current.focus()},bt=(e)=>{e.preventDefault();let n=e.clipboardData.getData("text/plain");if(!n)return;let r=window.getSelection();if(!r||r.rangeCount===0||!s.current?.contains(r.anchorNode)){if(s.current){s.current.focus();let i=document.createRange();i.selectNodeContents(s.current),i.collapse(!1),r=window.getSelection(),r?.removeAllRanges(),r?.addRange(i)}}if(!(typeof document.execCommand==="function"&&document.queryCommandSupported?.("insertText")&&document.execCommand("insertText",!1,n))){let i=window.getSelection();if(i&&i.rangeCount>0){let a=i.getRangeAt(0);a.deleteContents();let c=document.createTextNode(n);a.insertNode(c),a.setStartAfter(c),a.collapse(!0),i.removeAllRanges(),i.addRange(a)}else if(s.current)s.current.innerText+=n}Pe()},ht=(e)=>{if(e.nativeEvent.isComposing)return;if(se&&j&&te.length>0){if(e.key==="ArrowUp"){e.preventDefault(),W((n)=>n>0?n-1:te.length-1);return}if(e.key==="ArrowDown"){e.preventDefault(),W((n)=>n<te.length-1?n+1:0);return}if(e.key==="Enter"||e.key==="Tab"){e.preventDefault(),de(te[q]);return}if(e.key==="Escape"){e.preventDefault(),C(!1);return}}if(e.key==="Enter"&&!e.shiftKey)e.preventDefault(),Fe()},xt=P(async(e)=>{if(!e.target.files)return;let n=Array.from(e.target.files);for(let r of n){let l=`${Date.now()}-${r.name}`,i={id:l,file:r,progress:0};z((a)=>[...a,i]);try{let a=await De({projectId:y,data:{fileName:r.name,contentType:r.type,size:r.size}});if(a.uploadUrl&&a.id)await fetch(a.uploadUrl,{method:"PUT",body:r,headers:{"Content-Type":r.type}}),z((c)=>c.map((p)=>p.id===l?{...p,progress:100,attachmentId:a.id}:p))}catch(a){z((c)=>c.map((p)=>p.id===l?{...p,error:a instanceof Error?a.message:"Upload failed"}:p))}}if(Z.current)Z.current.value=""},[y,De]),vt=(e)=>{z((n)=>n.filter((r)=>r.id!==e))},Fe=()=>{if(!s.current)return;if(h.some((a)=>!a.attachmentId&&!a.error))return;let n=h.map((a)=>a.attachmentId).filter((a)=>!!a),r=h.filter((a)=>!a.error&&!!a.attachmentId).map((a)=>({id:a.attachmentId,name:a.file.name,type:a.file.type,url:a.file.type.startsWith("image/")||Ws(a.file.name)?URL.createObjectURL(a.file):void 0})),l="";s.current.childNodes.forEach((a)=>{if(a.nodeType===Node.TEXT_NODE)l+=a.textContent;else if(a.nodeType===Node.ELEMENT_NODE){let c=a;if(c.dataset.type==="mention")l+=`<@${c.dataset.id}>`;else if(c.tagName==="BR")l+=`
|
|
2
|
-
`;else if(c.tagName==="DIV"||c.tagName==="P")l+=`
|
|
3
|
-
`+c.innerText;else l+=c.innerText}}),l=l.trim();let i=(w?.length??0)>0;if(!l&&n.length===0&&ae.length===0&&!i)return;if(Be(l,n,ae,d?.id,H&&x?f:void 0,r),s.current.innerHTML="",M(!1),R.current=!0,T?.(""),z([]),X(null),O(!1),Ae(),C(!1),ne)ne()},ue=h.some((e)=>!e.attachmentId&&!e.error),yt=h.some((e)=>!!e.attachmentId),wt=(w?.length??0)>0,Nt=pe||oe,Ue=(ie||yt||ae.length>0||wt)&&!Nt,kt=w&&w.length>0||h.length>0||!!d;return o("div",{ref:nt,className:"relative flex flex-col w-full border border-foreground/35 rounded-3xl shadow-sm transition-all duration-200 bg-background",children:[t("style",{children:`
|
|
4
|
-
[contenteditable]:empty:before {
|
|
5
|
-
content: attr(data-placeholder);
|
|
6
|
-
color: #9ca3af;
|
|
7
|
-
cursor: text;
|
|
8
|
-
}
|
|
9
|
-
`}),se&&j&&(ye||K.length>0||ee.length>0)&&t("div",{onMouseDown:(e)=>e.preventDefault(),className:"absolute bottom-full left-4 mb-2 w-64 rounded-xl shadow-lg border border-border overflow-hidden z-20 bg-popover text-popover-foreground animate-in fade-in slide-in-from-bottom-2 duration-200",children:t("div",{ref:Re,className:"h-64 overflow-y-auto",children:ye?o("div",{className:"p-2 space-y-4 animate-pulse",children:[o("div",{className:"space-y-2",children:[t("div",{className:"px-3 py-1.5 bg-muted/50 border-b border-border",children:t(fe,{className:"h-3 w-16"})}),o("div",{className:"flex items-center gap-2 px-3 py-2",children:[t(fe,{className:"w-6 h-6 rounded-full"}),t(fe,{className:"h-4 w-28"})]}),o("div",{className:"flex items-center gap-2 px-3 py-2",children:[t(fe,{className:"w-6 h-6 rounded-full"}),t(fe,{className:"h-4 w-20"})]})]}),o("div",{className:"space-y-2",children:[t("div",{className:"px-3 py-1.5 bg-muted/50 border-b border-border",children:t(fe,{className:"h-3 w-16"})}),o("div",{className:"flex items-center gap-2 px-3 py-2",children:[t(fe,{className:"w-6 h-6 rounded-full"}),t(fe,{className:"h-4 w-32"})]}),o("div",{className:"flex items-center gap-2 px-3 py-2",children:[t(fe,{className:"w-6 h-6 rounded-full"}),t(fe,{className:"h-4 w-24"})]})]})]}):o(L,{children:[K.length>0&&o(L,{children:[o("button",{type:"button",onMouseDown:(e)=>e.preventDefault(),onClick:(e)=>{e.preventDefault(),e.stopPropagation(),Ee((n)=>({...n,bots:!n.bots})),s.current?.focus()},className:"w-full text-xs font-semibold text-muted-foreground px-3 py-2 bg-muted/50 border-b border-border flex items-center justify-between hover:bg-muted transition-colors cursor-pointer select-none",children:[t("span",{children:"Agents"}),t(ve,{className:`w-3 h-3 transition-transform ${v.bots?"-rotate-90":""}`})]}),!v.bots&&K.map((e,n)=>{let r=n;return o("button",{type:"button","data-index":r,onMouseDown:(l)=>l.preventDefault(),onClick:()=>de(e),onMouseEnter:()=>W(r),className:`w-full flex items-center gap-2 px-3 py-2 transition-colors text-left cursor-pointer ${r===q?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,children:[o(Ce,{className:"w-6 h-6",children:[e.type==="user"&&e.data.image&&t(Ie,{src:e.data.image,alt:e.data.name,className:"object-cover"}),t(Te,{className:"text-[10px] bg-purple-400 text-black font-semibold",children:Se(e.data.name)})]}),t("span",{className:"text-sm",children:e.data.name})]},e.data.id)})]}),ee.length>0&&o(L,{children:[o("button",{type:"button",onMouseDown:(e)=>e.preventDefault(),onClick:(e)=>{e.preventDefault(),e.stopPropagation(),Ee((n)=>({...n,users:!n.users})),s.current?.focus()},className:"w-full text-xs font-semibold text-muted-foreground px-3 py-2 bg-muted/50 border-b border-border flex items-center justify-between hover:bg-muted transition-colors cursor-pointer select-none",children:[t("span",{children:"Members"}),t(ve,{className:`w-3 h-3 transition-transform ${v.users?"-rotate-90":""}`})]}),!v.users&&ee.map((e,n)=>{let r=v.bots?0:K.length,l=n+r;return o("button",{type:"button","data-index":l,onMouseDown:(i)=>i.preventDefault(),onClick:()=>de(e),onMouseEnter:()=>W(l),className:`w-full flex items-center gap-2 px-3 py-2 transition-colors text-left cursor-pointer ${l===q?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,children:[o(Ce,{className:"w-6 h-6",children:[e.type==="user"&&e.data.image&&t(Ie,{src:e.data.image,alt:e.data.name,className:"object-cover"}),t(Te,{className:"text-[10px] bg-purple-400 text-black font-semibold",children:Se(e.data.name)})]}),t("span",{className:"text-sm",children:e.data.name})]},e.data.id)})]})]})})}),kt&&o("div",{className:"flex flex-col gap-2 p-3 pb-0 animate-in fade-in slide-in-from-bottom-2 duration-200",children:[w&&w.length>0&&t("div",{className:"flex flex-col gap-1.5 min-h-0 max-h-[160px] overflow-y-auto border border-border/60 rounded-lg bg-muted/20 p-2.5 divide-y divide-border/50",children:w.map((e)=>o("div",{className:"flex items-center justify-between py-1 text-xs group",children:[o("div",{className:"flex items-baseline gap-1.5 min-w-0 pr-2",children:[t("span",{className:"truncate font-medium text-foreground",children:e.name}),t("span",{className:"text-[9px] text-muted-foreground uppercase flex-shrink-0",children:e.type})]}),ge&&t("button",{onClick:()=>ge(e.id),className:"text-muted-foreground hover:text-destructive transition-colors p-0.5 cursor-pointer",title:tI?.()||"Remove from context",children:t(we,{className:"h-3.5 w-3.5"})})]},e.id))}),d&&o("div",{className:"flex items-center justify-between bg-muted p-2 px-3 rounded-lg border border-border",children:[t("div",{className:"text-xs text-muted-foreground truncate mr-2",children:lI({message:d.message||""})}),t("button",{onClick:ne,className:"text-muted-foreground hover:text-foreground p-1 rounded-full hover:bg-muted-foreground/10 shrink-0",children:t(Ne,{className:"w-3.5 h-3.5"})})]}),h.length>0&&t("div",{className:"flex gap-3 overflow-x-auto py-2 px-1 scrollbar-hide",children:h.map((e)=>o("div",{className:"relative group flex-shrink-0",children:[o("div",{className:"w-16 h-16 rounded-lg border border-gray-200 overflow-hidden bg-gray-50 flex items-center justify-center",children:[e.file.type.startsWith("image/")?t("img",{src:URL.createObjectURL(e.file),alt:"preview",onClick:()=>X(e.file),className:`w-full h-full object-cover ${!e.attachmentId?"opacity-50":""}`}):t(ar,{className:"w-8 h-8 text-gray-400"}),ue&&!e.attachmentId&&!e.error&&t("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:t(ma,{progress:e.progress,className:"w-10 h-10"})})]}),t("button",{onClick:()=>vt(e.id),className:"absolute -top-1.5 -right-1.5 bg-gray-500 text-white rounded-full p-0.5 shadow-md opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500 z-10 cursor-pointer",children:t(Ne,{className:"w-3 h-3"})}),t("span",{className:"text-[10px] text-gray-500 mt-1 block max-w-[4rem] truncate text-center",children:e.file.name})]},e.id))})]}),o("div",{onClick:()=>s.current?.focus(),className:"w-full px-4 pt-1 pb-1 cursor-text flow-root max-h-60 overflow-y-auto",children:[H&&x&&f!==void 0&&(b!==void 0||k!==void 0)&&t("div",{onClick:(e)=>{e.stopPropagation(),s.current?.focus()},className:"float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-2.5 py-0.5 mt-3 mr-2 rounded-sm text-xs font-mono font-bold flex items-center gap-1 cursor-text",children:at}),t("div",{ref:s,contentEditable:!pe&&!oe,suppressContentEditableWarning:!0,onInput:Pe,onKeyDown:ht,onPaste:bt,"data-placeholder":He||(d?aI():nS()),className:`bg-transparent border-none focus:ring-0 resize-none min-h-[40px] leading-relaxed py-2 focus:outline-none block whitespace-pre-wrap break-words ${ft}`})]}),o("div",{className:"flex justify-between items-center px-2 pb-2",children:[it?o("div",{className:"flex items-center gap-2 overflow-x-auto scrollbar-hide w-full mr-2",children:[t(S,{onClick:()=>{O(!1),Ae()},variant:"ghost",size:"icon",className:"p-2 rounded-full cursor-pointer text-gray-500 hover:text-gray-700 hover:bg-gray-100 mr-2",title:"Back",children:t(xu,{className:"w-4 h-4"})}),t("div",{className:"h-4 w-px bg-gray-300 mx-1"}),t("button",{onClick:()=>Y("arrow"),className:`p-1.5 rounded hover:bg-gray-100 ${J==="arrow"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Arrow",children:t(ea,{size:16,className:"rotate-45"})}),t("button",{onClick:()=>Y("line"),className:`p-1.5 rounded hover:bg-gray-100 ${J==="line"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Line",children:t(To,{size:16,className:"-rotate-45"})}),t("button",{onClick:()=>Y("box"),className:`p-1.5 rounded hover:bg-gray-100 ${J==="box"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Box",children:t(ec,{size:16})}),t("button",{onClick:()=>Y("freehand"),className:`p-1.5 rounded hover:bg-gray-100 ${J==="freehand"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Freehand",children:t(ze,{size:16})}),t("div",{className:"h-4 w-px bg-gray-300 mx-1"}),o(Je,{children:[t(Xe,{asChild:!0,children:o("button",{className:"flex items-center gap-1 p-1 rounded hover:bg-gray-100",children:[t("div",{className:"w-4 h-4 rounded-full border border-gray-200",style:{backgroundColor:ke}}),t(ve,{size:12,className:"text-gray-500"})]})}),t(et,{className:"w-auto p-2",align:"center",side:"top",children:t("div",{className:"flex items-center gap-1",children:Dt.map((e)=>t("button",{onClick:()=>ct(e),className:`w-6 h-6 rounded-full border border-gray-200 transition-transform hover:scale-110 ${ke===e?"ring-2 ring-blue-500 ring-offset-1":""}`,style:{backgroundColor:e}},e))})})]}),t("div",{className:"h-4 w-px bg-gray-300 mx-1"}),t("button",{onClick:dt,disabled:Me<=0,className:"p-1.5 rounded hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-500",children:t($e,{size:16})}),t("button",{onClick:ut,disabled:Me>=mt.length-1,className:"p-1.5 rounded hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-500",children:t(je,{size:16})})]}):o("div",{className:"flex items-center gap-1.5 min-w-0 max-w-[80%]",children:[Ze,We&&o(L,{children:[t("input",{type:"file",ref:Z,className:"hidden",multiple:!0,onChange:xt}),t(S,{onClick:()=>Z.current?.click(),className:"p-2 rounded-full cursor-pointer shrink-0",variant:"ghost",size:"icon",title:D_(),children:t(Ra,{className:"w-4 h-4"})})]}),H&&f!==void 0&&(b!==void 0||k!==void 0)&&t(S,{onClick:()=>ot(!x),variant:x?"secondary":"ghost",size:"icon",className:`p-2 rounded-full cursor-pointer shrink-0 ${x?"text-blue-600 bg-blue-50 dark:bg-blue-900/20":""}`,title:x?kb():Wb(),children:t(Qt,{className:"w-4 h-4"})}),rt&&(Qe?t(S,{onClick:()=>{U?.(),O(!0)},variant:"ghost",size:"icon",className:"p-2 rounded-full cursor-pointer shrink-0",title:R1(),children:t(Ei,{className:"w-4 h-4"})}):t(un,{children:o(dn,{children:[t(fn,{asChild:!0,children:t("span",{className:"inline-block cursor-not-allowed shrink-0",children:t(S,{disabled:!0,variant:"ghost",size:"icon",className:"p-2 rounded-full opacity-40 cursor-not-allowed pointer-events-none",children:t(Ei,{className:"w-4 h-4"})})})}),t(pn,{side:"top",children:t("p",{className:"text-xs",children:Ge||up()})})]})}))]}),oe?t("button",{onClick:tt,className:"p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 shadow-sm bg-destructive text-destructive-foreground hover:bg-destructive/90 transform hover:-translate-y-0.5 cursor-pointer",title:"Stop generation",children:t("div",{className:"h-4 w-4 flex items-center justify-center",children:t("div",{className:"h-3 w-3 rounded-[2px] bg-white"})})}):t("button",{onClick:Fe,disabled:!Ue||ue,className:`p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 ${Ue&&!ue?"bg-blue-600 text-white shadow-md hover:bg-blue-700 hover:shadow-lg transform hover:-translate-y-0.5 cursor-pointer":"bg-gray-400 cursor-not-allowed opacity-50"}`,children:t(ea,{className:"w-4 h-4"})})]}),re&&o("div",{className:"fixed inset-0 z-[100] bg-black/95 flex flex-col items-center justify-center p-4 animate-in fade-in duration-200",onClick:()=>X(null),children:[t("button",{className:"absolute top-4 right-4 text-white/70 hover:text-white hover:bg-white/20 rounded-full p-2 transition-colors z-50",children:t(Ne,{className:"w-8 h-8"})}),t("div",{className:"w-full h-full flex items-center justify-center p-2",children:t("img",{src:URL.createObjectURL(re),alt:"Enlarged view",className:"max-w-full max-h-[85vh] object-contain rounded shadow-2xl cursor-zoom-out",onClick:(e)=>{e.stopPropagation(),X(null)}})}),t("div",{className:"absolute bottom-6 text-white text-sm font-medium bg-black/50 px-4 py-2 rounded-full backdrop-blur-sm",children:re.name})]})]})});Ys.displayName="ChatInput";
|
|
10
|
-
export{xu,Ys};
|
package/bin/chunk-xjw3mpvx.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{m,u,E,L,t,o,Pe,xn,ze,I,ir,O,oo,cn,S,jm,Ey,Cy,op,ip,Jw,MS,kS,Ip,FE,LE,ZE,aA,uI,dI,z,f,R,W,jl,ql,Hl}from"./chunk-p1d500sf.js";import{nr}from"./chunk-xsfy8hz3.js";var v=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],w=I("key-round",v);E();var x=R({password:f().min(3,Ip()),confirmPassword:f().min(3,Ip())}).refine((s)=>s.password===s.confirmPassword,{message:ZE(),path:["confirmPassword"]}),b=ze("/reset-password")({component:N});function N(){let s=Pe(),r=b.useSearch().token||"",[n,a]=u(null),[l,c]=u(!1),[i,h]=u(!1),e=ql({resolver:Hl(x),defaultValues:{password:"",confirmPassword:""}});m(()=>{if(i){let d=setTimeout(()=>{s({to:"/login"})},3000);return()=>clearTimeout(d)}},[i,s]);let g=async(d)=>{if(!r){a(ip());return}c(!0),a(null);let{error:p}=await jm({newPassword:d.password,token:r});if(c(!1),p){a(p.message||ip());return}h(!0)};return o(jl,{children:[o("div",{className:"mb-8",children:[t("h1",{className:"text-2xl font-bold tracking-tight text-foreground",children:aA()}),t("p",{className:"text-muted-foreground text-sm mt-1",children:uI()})]}),!r?o("div",{className:"space-y-6",children:[o("div",{className:"p-4 bg-destructive/10 border border-destructive/20 text-destructive rounded-xl text-sm flex items-start gap-3",children:[t(nr,{className:"w-5 h-5 shrink-0 mt-0.5"}),o("div",{className:"space-y-1",children:[t("p",{className:"font-semibold",children:ip()}),t("p",{className:"text-xs text-muted-foreground",children:Jw()})]})]}),t(xn,{to:"/login",className:"block w-full",children:o(S,{variant:"outline",className:"w-full h-11 rounded-xl flex items-center justify-center gap-2",children:[op(),t(oo,{className:"w-4 h-4"})]})})]}):i?o("div",{className:"space-y-6",children:[o("div",{className:"p-4 bg-emerald-500/10 border border-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded-xl text-sm flex items-start gap-3",children:[t(ir,{className:"w-5 h-5 shrink-0 mt-0.5"}),o("div",{className:"space-y-1",children:[t("p",{className:"font-semibold",children:FE()}),t("p",{className:"text-xs text-muted-foreground",children:LE()})]})]}),t(xn,{to:"/login",className:"block w-full",children:o(S,{className:"w-full h-11 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-600 hover:to-orange-600 text-white font-semibold rounded-xl shadow-md shadow-rose-500/10 hover:shadow-rose-500/20 active:scale-[0.98] transition-all flex items-center justify-center gap-2 border-0",children:[op(),t(oo,{className:"w-4 h-4"})]})})]}):o("form",{onSubmit:e.handleSubmit(g),className:"space-y-5",children:[n&&t("div",{className:"p-3 bg-destructive/10 border border-destructive/20 text-destructive rounded-xl text-sm text-center font-medium",children:n}),o("div",{className:"space-y-2",children:[t(W,{htmlFor:"password",className:"text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:MS()}),o("div",{className:"relative group",children:[t(cn,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground transition-colors group-focus-within:text-rose-500"}),t(z,{id:"password",type:"password",...e.register("password"),placeholder:kS(),className:"pl-10.5 h-11 border-border focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"})]}),e.formState.errors.password&&t("p",{className:"text-destructive text-xs font-medium",children:e.formState.errors.password.message})]}),o("div",{className:"space-y-2",children:[t(W,{htmlFor:"confirmPassword",className:"text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:Ey()}),o("div",{className:"relative group",children:[t(cn,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground transition-colors group-focus-within:text-rose-500"}),t(z,{id:"confirmPassword",type:"password",...e.register("confirmPassword"),placeholder:Cy(),className:"pl-10.5 h-11 border-border focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"})]}),e.formState.errors.confirmPassword&&t("p",{className:"text-destructive text-xs font-medium",children:e.formState.errors.confirmPassword.message})]}),t(S,{type:"submit",className:"w-full h-11 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-600 hover:to-orange-600 text-white font-semibold rounded-xl shadow-md shadow-rose-500/10 hover:shadow-rose-500/20 active:scale-[0.98] transition-all flex items-center justify-center gap-2 border-0",disabled:l,children:l?o(L,{children:[t(O,{className:"h-4 w-4 animate-spin"}),dI()]}):o(L,{children:[t(w,{className:"w-4 h-4"}),aA()]})}),t("div",{className:"pt-2 text-center text-sm",children:t(xn,{to:"/login",className:"font-semibold text-rose-500 hover:text-rose-600 dark:text-rose-400 dark:hover:text-rose-300 transition-colors hover:underline inline-flex items-center gap-1",children:op()})})]})]})}export{b as Route};
|
package/bin/chunk-xsfy8hz3.js
DELETED
package/bin/chunk-xznq2axj.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{m,E,t,Z,ze,g,gt,Tt,_m}from"./chunk-p1d500sf.js";import"./chunk-cxet91kt.js";import"./chunk-xgnvktq6.js";import"./chunk-keetdtxb.js";import"./chunk-5aqthcm6.js";import{Va}from"./chunk-sn0nypvd.js";import"./chunk-swz6v48q.js";import"./chunk-am6dg0a5.js";import{tr}from"./chunk-qd7pvaxb.js";import"./chunk-ahgq10a7.js";import"./chunk-1vt9ss7d.js";import"./chunk-ebcfbn00.js";import"./chunk-agcnbjxk.js";import"./chunk-xsfy8hz3.js";E();function c(){let{projectId:e}=f.useParams(),{teamId:r,ensureTeamIdForProject:n}=gt();m(()=>{n(e)},[e,n]);let{data:a}=tr(_m(e)),o=a?.rootFolder,{data:s}=Z({queryKey:["folders",o],queryFn:async()=>{let d=await g.api.folders[":folderId"].$get({param:{folderId:o}});if(!d.ok)throw Error("failed to fetch folder");return await d.json()},enabled:!!o});if(!r||!o||!s)return t(Tt,{});return t(Va,{teamId:r,projectId:e,projectName:a.name??"",assetId:o,rootFolderId:o,isRoot:!0})}var f=ze("/projects/$projectId/agentsmd")({component:c});export{f as Route};
|
package/bin/chunk-y4v08wq7.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F,P,m,N,_,u,ro,E,L,t,o,G,Vu,Qu,xr,Bc,Ji,So,$t,Yo,Ku,Wu,Yu,Ju,Uc,Xu,Z,B,pt,ze,g,I,ir,O,Dr,Mt,Me,ve,Qt,ln,zt,Jo,Ne,C,xt,ye,Y,Pt,Cr,Zt,ie,cr,S,Ce,Ie,Te,s0,i0,Rf,l_,d_,f_,T_,Zf,F_,_h,Re,ay,dy,fy,na,xh,Vy,_d,Qc,Ih,$s,Xo,qh,xv,Hh,rp,Wv,Yv,Jv,Xv,Zw,og,tx,tS,rS,mp,DS,bp,vp,QS,rE,aE,TE,Ng,eu,BE,qg,Fd,eA,vC,xC,kp,EC,TC,rA,kC,RC,nA,PC,DC,jd,qd,Hd,Ol,Fp,jC,qC,HC,$C,$d,XC,Vs,fI,II,kI,qI,$p,$I,rT,nT,sT,iT,aT,lT,SA,cT,EA,kA,LT,ZT,BT,a1,NA,OA,l1,ZA,Wd,d1,h1,k1,L1,jA,Sn,om,iM,fM,pM,iu,yM,lm,DM,nt,ot,st,it,at,lt,ct,ut,de,ce,me,ue,Et,z,le,Nt,M,qa,Ha,zl,Fr,dm,Ln,Zn,Tr,Gr,ne,Je,Xe,et,ur,Lr,ff,Ve,_t,yt,kt,dt}from"./chunk-p1d500sf.js";import{Ro,vr}from"./chunk-qt78vs3g.js";import{Xl}from"./chunk-fkn6f4qt.js";import{ec}from"./chunk-1vt9ss7d.js";import{Js,Tn,zo,oc,tl,Fi,sc}from"./chunk-fre31bhw.js";import{hn,gn,An,fr,Ye,Qe}from"./chunk-g78vapcm.js";import"./chunk-agcnbjxk.js";import"./chunk-zxqasmvz.js";import{Jn,fo}from"./chunk-ts4d1mxf.js";import{wr}from"./chunk-ht5rht98.js";E();function be(e,a){let s=new Set(a);return e.filter((n)=>!s.has(n))}var he=class extends So{#r;#e;#o;#a;#t;#s;#i;#n;#l;#d=[];constructor(e,a,s){super();this.#r=e,this.#a=s,this.#o=[],this.#t=[],this.#e=[],this.setQueries(a)}onSubscribe(){if(this.listeners.size===1)this.#t.forEach((e)=>{e.subscribe((a)=>{this.#p(e,a)})})}onUnsubscribe(){if(!this.listeners.size)this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach((e)=>{e.destroy()})}setQueries(e,a){this.#o=e,this.#a=a,$t.batch(()=>{let s=this.#t,n=this.#u(this.#o);n.forEach((b)=>b.observer.setOptions(b.defaultedQueryOptions));let l=n.map((b)=>b.observer),r=l.map((b)=>b.getCurrentResult()),f=s.length!==l.length,x=l.some((b,w)=>b!==s[w]),h=f||x,T=h?!0:r.some((b,w)=>{let y=this.#e[w];return!y||!Ji(b,y)});if(!h&&!T)return;if(h)this.#d=n,this.#t=l;if(this.#e=r,!this.hasListeners())return;if(h)be(s,l).forEach((b)=>{b.destroy()}),be(l,s).forEach((b)=>{b.subscribe((w)=>{this.#p(b,w)})});this.#f()})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map((e)=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,a){let s=this.#u(e),n=s.map((r)=>r.observer.getOptimisticResult(r.defaultedQueryOptions)),l=s.map((r)=>r.defaultedQueryOptions.queryHash);return[n,(r)=>this.#c(r??n,a,l),()=>this.#m(n,s)]}#m(e,a){let s=new Set;return a.map((n,l)=>{let r=e[l];return!n.defaultedQueryOptions.notifyOnChangeProps?n.observer.trackResult(r,(f)=>{if(!s.has(f))s.add(f),a.forEach((x)=>{x.observer.trackProp(f)})}):r})}#c(e,a,s){if(a){let n=this.#l,l=s!==void 0&&n!==void 0&&(n.length!==s.length||s.some((r,f)=>r!==n[f]));if(this.#e!==this.#n||l||a!==this.#i){if(this.#i=a,this.#n=this.#e,s!==void 0)this.#l=s;this.#s=Bc(this.#s,a(e))}return this.#s}return e}#g(){return!this.#a?.combine||this.#t.some((e,a)=>e.options.suspense&&this.#e[a]?.data===void 0)}#u(e){let a=new Map;this.#t.forEach((n)=>{let l=n.options.queryHash;if(!l)return;let r=a.get(l);if(r)r.push(n);else a.set(l,[n])});let s=[];return e.forEach((n)=>{let l=this.#r.defaultQueryOptions(n),r=a.get(l.queryHash)?.shift()??new Yo(this.#r,l);s.push({defaultedQueryOptions:l,observer:r})}),s}#p(e,a){let s=this.#t.indexOf(e);if(s!==-1)this.#e=this.#e.slice(),this.#e[s]=a,this.#f()}#f(){if(this.hasListeners()){let e=this.#g(),a=this.#s,s=e?a:this.#c(this.#m(this.#e,this.#d),this.#a?.combine);if(e||a!==s)$t.batch(()=>{this.listeners.forEach((n)=>{n(this.#e)})})}}};E();function we({queries:e,...a},s){let n=G(s),l=Vu(),r=Qu(),f=a.subscribed!==!1,x=N(()=>e.map((p)=>{let v=n.defaultQueryOptions(p);return v._optimisticResults=l?"isRestoring":f?"optimistic":void 0,v}),[e,n,l,f]);x.forEach((p)=>{Ju(p);let v=n.getQueryCache().get(p.queryHash);Ku(p,r,v)}),Wu(r);let[h]=u(()=>new he(n,x,a)),[T,b,w]=h.getOptimisticResult(x,a.combine),y=!l&&f;ro(P((p)=>y?h.subscribe($t.batchCalls(p)):xr,[h,y]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),m(()=>{h.setQueries(x,a)},[x,a,h]);let d=T.some((p,v)=>Uc(x[v],p))?T.flatMap((p,v)=>{let D=x[v];if(D&&Uc(D,p)){let H=new Yo(n,D);return Xu(D,H,r)}return[]}):[];if(d.length>0)throw Promise.all(d);let R=T.find((p,v)=>{let D=x[v];return D&&Yu({result:p,errorResetBoundary:r,throwOnError:D.throwOnError,query:n.getQueryCache().get(D.queryHash),suspense:D.suspense})});if(R)throw R.error;return b(w())}E();E();var $e=Object.defineProperty,ee=(e,a)=>$e(e,"name",{value:a,configurable:!0}),pe="Collapsible",[Ke,fa]=xt(pe),[Ge,fe]=Ke(pe),Ze=F(ee(function(a,s){let{__scopeCollapsible:n,open:l,defaultOpen:r,disabled:f,onOpenChange:x,...h}=a,[T,b]=Zt({prop:l,defaultProp:r??!1,onChange:x,caller:pe});return t(Ge,{scope:n,disabled:f,contentId:Cr(),open:T,onOpenToggle:P(()=>b((w)=>!w),[b]),children:t(ie.div,{"data-state":re(T),"data-disabled":f?"":void 0,...h,ref:s})})},"Collapsible")),tt="CollapsibleTrigger",rt=F(ee(function(a,s){let{__scopeCollapsible:n,...l}=a,r=fe(tt,n);return t(ie.button,{type:"button","aria-controls":r.open?r.contentId:void 0,"aria-expanded":r.open||!1,"data-state":re(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...l,ref:s,onClick:Y(a.onClick,r.onOpenToggle)})},"CollapsibleTrigger")),_e="CollapsibleContent",mt=F(ee(function(a,s){let{forceMount:n,...l}=a,r=fe(_e,a.__scopeCollapsible);return t(cr,{present:n||r.open,children:({present:f})=>t(ft,{...l,ref:s,present:f})})},"CollapsibleContent")),ft=F(ee(function(a,s){let{__scopeCollapsible:n,present:l,children:r,...f}=a,x=fe(_e,n),[h,T]=u(l),b=_(null),w=ye(s,b),y=_(0),d=y.current,R=_(0),p=R.current,v=x.open||h,D=_(v),H=_(void 0);return m(()=>{let q=requestAnimationFrame(()=>D.current=!1);return()=>cancelAnimationFrame(q)},[]),Pt(()=>{let q=b.current;if(q){H.current=H.current||{transitionDuration:q.style.transitionDuration,animationName:q.style.animationName},q.style.transitionDuration="0s",q.style.animationName="none";let W=q.getBoundingClientRect();if(y.current=W.height,R.current=W.width,!D.current)q.style.transitionDuration=H.current.transitionDuration,q.style.animationName=H.current.animationName;T(l)}},[x.open,l]),t(ie.div,{"data-state":re(x.open),"data-disabled":x.disabled?"":void 0,id:x.contentId,hidden:!v,...f,ref:w,style:{["--radix-collapsible-content-height"]:d?`${d}px`:void 0,["--radix-collapsible-content-width"]:p?`${p}px`:void 0,...a.style},children:v&&r})},"CollapsibleContentImpl"));function re(e){return e?"open":"closed"}ee(re,"getState");var gt=Ze;var ht=[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V3",key:"1lcnhd"}],["path",{d:"M19 21V9",key:"unv183"}]],ke=I("chart-no-axes-column",ht);var vt=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],K=I("funnel",vt);var wt=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ae=I("eye",wt);var Ct=[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]],te=I("messages-square",Ct);var Tt=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],De=I("rotate-cw",Tt);var At=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],oe=I("workflow",At);function qe({teamId:e}){let[a,s]=u("team"),[n,l]=u("1h"),{data:r,isLoading:f}=Z({queryKey:["teams",e,"ai-usage",n,"team"],queryFn:async()=>{let p=await g.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:e},query:{timeframe:n}});if(!p.ok)throw Error("Failed to fetch team AI usage");return await p.json()},enabled:!!e&&a==="team"}),{data:x,isLoading:h}=Z({queryKey:["teams",e,"members"],queryFn:async()=>{let p=await g.api.teams[":teamId"].members.$get({param:{teamId:e},query:{}});if(!p.ok)throw Error("Failed to fetch team members");return await p.json()},enabled:!!e&&a==="members"}),T=we({queries:(x||[]).map((p)=>({queryKey:["teams",e,"ai-usage",n,p.id],queryFn:async()=>{let v=await g.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:e},query:{timeframe:n,userId:p.id}});if(!v.ok)throw Error(`Failed to fetch AI usage for member ${p.id}`);return await v.json()},enabled:!!e&&a==="members"}))}),b=h||T.some((p)=>p.isLoading),w=(p)=>{if(!p)return"U";let v=p.split(" ");if(v.length>1)return`${v[0][0]}${v[v.length-1][0]}`.toUpperCase();return p.substring(0,2).toUpperCase()},y=(p)=>{if(!p)return"";switch(p.toLowerCase()){case"owner":return eu();case"editor":return $s();case"reviewer":return Vs();default:return p}},d=(p)=>(p??0).toLocaleString(),R=(p)=>`$${(p??0).toFixed(6)}`;return o(Ve,{className:"border-border/60 shadow-sm",children:[o(_t,{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between pb-6",children:[o("div",{children:[t(yt,{className:"text-xl font-semibold tracking-tight",children:d_()}),t(kt,{className:"text-sm text-muted-foreground mt-1",children:f_()})]}),o("div",{className:"flex flex-wrap items-center gap-3",children:[o(Ro,{type:"single",value:a,onValueChange:(p)=>{if(p)s(p)},className:"border rounded-lg p-1 bg-muted/30",children:[t(vr,{value:"team",className:"px-3 py-1.5 text-xs font-medium",children:h1()}),t(vr,{value:"members",className:"px-3 py-1.5 text-xs font-medium",children:rS()})]}),o(Ro,{type:"single",value:n,onValueChange:(p)=>{if(p)l(p)},className:"border rounded-lg p-1 bg-muted/30",children:[t(vr,{value:"1h",className:"px-2.5 py-1.5 text-xs font-medium",children:"1h"}),t(vr,{value:"24h",className:"px-2.5 py-1.5 text-xs font-medium",children:"24h"}),t(vr,{value:"7d",className:"px-2.5 py-1.5 text-xs font-medium",children:"7d"}),t(vr,{value:"30d",className:"px-2.5 py-1.5 text-xs font-medium",children:"30d"})]})]})]}),t(dt,{children:a==="team"?f?t("div",{className:"flex h-48 items-center justify-center",children:t(O,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t("div",{className:"rounded-md border",children:o(hn,{children:[t(gn,{children:o(fr,{children:[t(Ye,{children:Wd()}),t(Ye,{className:"text-right",children:og()}),t(Ye,{className:"text-right",children:Ng()}),t(Ye,{className:"text-right",children:_h()}),t(Ye,{className:"text-right",children:jA()}),t(Ye,{className:"text-right",children:xh()})]})}),t(An,{children:o(fr,{children:[t(Qe,{className:"font-medium",children:Wd()}),t(Qe,{className:"text-right",children:d(r?.team?.inputTokens)}),t(Qe,{className:"text-right",children:d(r?.team?.outputTokens)}),t(Qe,{className:"text-right",children:d(r?.team?.cacheReadTokens)}),t(Qe,{className:"text-right font-medium",children:d(r?.team?.totalTokens)}),t(Qe,{className:"text-right font-medium",children:R(r?.team?.cost)})]})})]})}):b?t("div",{className:"flex h-48 items-center justify-center",children:t(O,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t("div",{className:"rounded-md border",children:o(hn,{children:[t(gn,{children:o(fr,{children:[t(Ye,{children:tS()}),t(Ye,{children:fI()}),t(Ye,{className:"text-right",children:og()}),t(Ye,{className:"text-right",children:Ng()}),t(Ye,{className:"text-right",children:_h()}),t(Ye,{className:"text-right",children:jA()}),t(Ye,{className:"text-right",children:xh()})]})}),t(An,{children:(x||[]).map((p,v)=>{let D=T[v]?.data?.member;return o(fr,{children:[t(Qe,{children:o("div",{className:"flex items-center gap-3",children:[o(Ce,{className:"h-8 w-8 rounded-full",children:[p.image&&t(Ie,{src:p.image,alt:p.name,className:"object-cover"}),t(Te,{className:"bg-primary/20 text-xs",children:w(p.name)})]}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium leading-none",children:p.name}),t("span",{className:"text-xs text-muted-foreground mt-0.5",children:p.email})]})]})}),t(Qe,{className:"text-xs text-muted-foreground",children:y(p.role)}),t(Qe,{className:"text-right",children:d(D?.inputTokens)}),t(Qe,{className:"text-right",children:d(D?.outputTokens)}),t(Qe,{className:"text-right",children:d(D?.cacheReadTokens)}),t(Qe,{className:"text-right font-medium",children:d(D?.totalTokens)}),t(Qe,{className:"text-right font-medium",children:R(D?.cost)})]},p.id)})})]})})})]})}E();function Se({teamId:e}){let[a,s]=u(null),{ref:n,inView:l}=Nt(),{data:r,isLoading:f,isError:x,fetchNextPage:h,hasNextPage:T,isFetchingNextPage:b}=pt({queryKey:["teams",e,"agent-sessions"],queryFn:async({pageParam:d})=>{let R=await g.api.teams[":teamId"]["agent-sessions"].$get({param:{teamId:e},query:{first:"20",after:d?String(d):void 0}});if(!R.ok)throw Error("Failed to fetch agent sessions");return await R.json()},initialPageParam:"",getNextPageParam:(d)=>d.pageInfo.cursor||void 0,enabled:!!e});m(()=>{if(l&&T&&!b)h()},[l,T,b,h]);let w=r?.pages.flatMap((d)=>d.data).filter((d)=>d.id!=="pending")||[],y=(d)=>{switch(d){case"comment":return t(ne,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20",children:aT()});case"chat":return t(ne,{variant:"outline",className:"bg-violet-500/10 text-violet-600 dark:text-violet-400 border-violet-500/20",children:iT()});case"naming":return t(ne,{variant:"outline",className:"bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20",children:lT()});default:return t(ne,{variant:"outline",className:"bg-muted text-muted-foreground border-border",children:d})}};return o("div",{className:"space-y-6",children:[o(Ve,{className:"border border-border/50 shadow-xs",children:[t(_t,{className:"pb-4",children:t("div",{className:"flex items-center justify-between",children:o("div",{children:[o(yt,{className:"text-xl font-bold flex items-center gap-2",children:[t(te,{className:"w-5 h-5 text-violet-500"}),SA()]}),t(kt,{className:"mt-1 text-sm text-muted-foreground",children:cT()})]})})}),t(dt,{children:f?t("div",{className:"flex h-64 items-center justify-center",children:t(O,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):x?t("div",{className:"flex h-64 items-center justify-center text-destructive",children:"Failed to load agent sessions."}):w.length===0?o("div",{className:"flex flex-col items-center justify-center py-12 text-center text-muted-foreground",children:[t(te,{className:"w-10 h-10 text-muted-foreground/40 mb-3"}),t("p",{className:"text-base font-medium",children:QS()})]}):o("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o(hn,{children:[t(gn,{className:"bg-muted/40",children:o(fr,{children:[t(Ye,{children:nT()}),t(Ye,{children:Qc()}),t(Ye,{children:sT()}),t(Ye,{className:"text-right",children:Vy()})]})}),t(An,{children:w.map((d)=>o(fr,{onClick:()=>s(d.id),className:"cursor-pointer hover:bg-muted/50 transition-colors",children:[t(Qe,{className:"font-medium",children:o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-semibold text-foreground",children:d.name||om()}),t("span",{className:"text-xs font-mono text-muted-foreground/70",children:d.id})]})}),t(Qe,{children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{className:"h-6 w-6",children:[t(Ie,{src:d.creator?.image||void 0}),t(Te,{className:"text-[10px]",children:d.creator?.name?.[0]?.toUpperCase()||"?"})]}),t("span",{className:"text-sm text-foreground/90",children:d.creator?.name||"System / Agent"})]})}),t(Qe,{children:y(d.type)}),t(Qe,{className:"text-right text-xs text-muted-foreground",children:Fr(d.createdAt)})]},d.id))})]}),t("div",{ref:n,className:"py-4 flex justify-center",children:b&&t(O,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})})]}),t(Xl,{sessionId:a,open:!!a,onOpenChange:(d)=>{if(!d)s(null)}})]})}E();function Pe({...e}){return t(gt,{"data-slot":"collapsible",...e})}function Be({...e}){return t(rt,{"data-slot":"collapsible-trigger",...e})}function He({...e}){return t(mt,{"data-slot":"collapsible-content",...e})}function ge(e){switch(e.toLowerCase()){case"owner":return eu();case"editor":return $s();case"reviewer":return Vs();default:return e}}function Rt(e,a){if(typeof e==="object"&&e!==null&&"message"in e){let s=e.message;if(typeof s==="string")return s}return a}function Dt({rule:e}){let a=e.resourceData??{};if(e.resource==="agent_mcp_call_count")return t("span",{children:qC({value:String(a.id??"")})});if(e.resource==="agent_bash_call_count")return t("span",{children:jC({value:String(a.match??"*")})});if(e.resource==="agent_tool_call_count")return t("span",{children:HC({value:String(a.name??a.toolName??"*")})});return null}function qt({rule:e}){if(e.scopeMode==="all_members")return o(ne,{variant:"secondary",className:"gap-1 text-xs",children:[t(fo,{className:"h-3 w-3"}),o("span",{children:[jd(),e.role?` (${ge(e.role)})`:` (${Ol()})`]})]});if(e.scopeMode==="each_member")return o(ne,{variant:"secondary",className:"gap-1 text-xs",children:[t(Jn,{className:"h-3 w-3"}),o("span",{children:[qd(),e.role?` (${ge(e.role)})`:` (${Ol()})`]})]});return o(ne,{variant:"secondary",className:"gap-1 text-xs",children:[t(Jo,{className:"h-3 w-3"}),o("span",{children:[Hd()," (",e.userIds?.length||0,")"]})]})}function It({teamId:e,rule:a,record:s}){let n=G(),[l,r]=u(!1),[f,x]=u(()=>new Date),h=tl[a.resource],T=a.scopeMode==="all_members",b=s.percent>=100,w=T?a.role?`${DC()}: ${ge(a.role)}`:$C():s.user?.name||s.userId||Sn();m(()=>{if(!s.isWindowActive||!s.periodEnd)return;let d=window.setInterval(()=>x(new Date),60000);return()=>window.clearInterval(d)},[s.isWindowActive,s.periodEnd]);let y=B({mutationFn:async()=>{let d=await g.api.teams[":teamId"].quotas[":id"].records.reset.$post({param:{teamId:e,id:a.id},json:{userId:s.userId??null}});if(!d.ok){let R=await d.json().catch(()=>null);throw Error(Rt(R,Hh()))}return await d.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["teams",e,"quotas",a.id,"records"]}),n.invalidateQueries({queryKey:["teams",e,"quotas"]}),r(!1),M.success(RC())},onError:(d)=>{let R=d instanceof Error?d.message:Hh();r(!1),M.error(R)}});return o(L,{children:[o("div",{className:"space-y-3 rounded-xl border border-border/70 bg-card p-4 text-card-foreground shadow-2xs",children:[o("div",{className:"flex items-center justify-between gap-3",children:[o("div",{className:"flex min-w-0 items-center gap-3",children:[T?t("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:t(fo,{className:"h-5 w-5"})}):o(Ce,{className:"h-9 w-9 shrink-0 border border-border/50",children:[t(Ie,{src:s.user?.image||void 0}),t(Te,{className:"text-xs font-semibold",children:s.user?.name?.[0]?.toUpperCase()||"U"})]}),o("div",{className:"min-w-0",children:[t("div",{className:"truncate text-sm font-semibold text-foreground",children:w}),!T&&s.user?.email&&t("div",{className:"truncate text-xs text-muted-foreground",children:s.user.email})]})]}),o("div",{className:"flex shrink-0 items-center gap-2",children:[s.isWindowActive&&s.periodEnd?o(ne,{variant:"outline",className:"hidden gap-1 border-primary/30 bg-primary/5 text-xs text-primary sm:flex",children:[t(Qt,{className:"h-3 w-3"}),t("span",{children:rA({time:dm(s.periodEnd,f)})})]}):o(ne,{variant:"secondary",className:"hidden gap-1 text-xs text-muted-foreground sm:flex",children:[t(ir,{className:"h-3 w-3 text-primary"}),t("span",{children:eA()})]}),o(S,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>r(!0),disabled:y.isPending,children:[y.isPending?t(O,{className:"h-3.5 w-3.5 animate-spin"}):t(Js,{className:"h-3.5 w-3.5"}),nA()]})]})]}),o("div",{className:"space-y-1.5 pt-1",children:[t(ff,{value:Math.min(100,Math.max(0,s.percent)),className:"h-2"}),o("div",{className:"flex items-center justify-between gap-2 text-xs font-medium",children:[o("span",{className:b?"font-bold text-destructive":"text-foreground",children:[Fi(a.resource,s.consumed)," /"," ",Fi(a.resource,a.limit)," ",h?.unit]}),o("span",{className:b?"font-bold text-destructive":"text-muted-foreground",children:[s.percent,"%"]})]})]}),o("div",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground sm:hidden",children:[s.isWindowActive&&s.periodEnd?o("span",{className:"flex items-center gap-1 text-primary",children:[t(Qt,{className:"h-3 w-3"}),rA({time:dm(s.periodEnd,f)})]}):o("span",{className:"flex items-center gap-1",children:[t(ir,{className:"h-3 w-3 text-primary"}),eA()]}),o("span",{children:[kC(),": ",Fi(a.resource,s.remaining)," ",h?.unit]})]})]}),t(nt,{open:l,onOpenChange:r,children:o(ot,{children:[o(st,{children:[t(at,{children:nA()}),t(lt,{children:PC({target:w})})]}),o(it,{children:[t(ut,{disabled:y.isPending,children:Re()}),o(ct,{onClick:(d)=>{d.preventDefault(),y.mutate()},disabled:y.isPending,children:[y.isPending&&t(O,{className:"mr-2 h-4 w-4 animate-spin"}),na()]})]})]})})]})}function St({teamId:e,rule:a}){let[s,n]=u(!1),[l,r]=u(""),f=tl[a.resource],x=f?.icon||zo,{data:h,isLoading:T,isError:b}=Z({queryKey:["teams",e,"quotas",a.id,"records"],queryFn:async()=>{let d=await g.api.teams[":teamId"].quotas[":id"].records.$get({param:{teamId:e,id:a.id}});if(!d.ok)throw Error(qh());return await d.json()},enabled:s,refetchInterval:s?1e4:!1}),w=h?.records??[],y=w.filter((d)=>{if(!l.trim())return!0;let R=l.toLowerCase();return d.user?.name.toLowerCase().includes(R)||d.user?.email.toLowerCase().includes(R)});return o(Pe,{open:s,onOpenChange:n,className:"rounded-xl border border-border/70",children:[t(Be,{asChild:!0,children:o("button",{type:"button","aria-label":s?vC():EC(),className:"flex w-full items-center justify-between gap-4 p-4 text-left transition-colors hover:bg-muted/40",children:[o("div",{className:"flex min-w-0 items-start gap-3",children:[t("div",{className:"mt-0.5 rounded-lg bg-primary/10 p-2 text-primary",children:t(x,{className:"h-5 w-5"})}),o("div",{className:"min-w-0",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[t("span",{className:"font-semibold text-foreground",children:f?.label()||a.resource}),!a.enabled&&t(ne,{variant:"secondary",children:kp()})]}),o("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[t(qt,{rule:a}),o(ne,{variant:"outline",className:"gap-1 text-xs",children:[t(Qt,{className:"h-3 w-3"}),Fi(a.resource,a.limit)," ",f?.unit," /"," ",sc(a.period)]}),t(Dt,{rule:a})]})]})]}),t(ve,{className:`h-5 w-5 shrink-0 text-muted-foreground transition-transform ${s?"rotate-180":""}`})]})}),t(He,{children:o("div",{className:"space-y-3 border-t border-border/60 bg-muted/10 p-4",children:[a.scopeMode!=="all_members"&&w.length>3&&o("div",{className:"relative",children:[t(zt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t(z,{value:l,onChange:(d)=>r(d.target.value),placeholder:Fp(),className:"h-9 pl-9 text-sm"})]}),T?t("div",{className:"flex justify-center py-10",children:t(O,{className:"h-7 w-7 animate-spin text-primary"})}):b?t("div",{className:"py-8 text-center text-sm text-destructive",children:qh()}):y.length===0?t("div",{className:"py-8 text-center text-sm text-muted-foreground",children:TC()}):y.map((d,R)=>t(It,{teamId:e,rule:a,record:d},d.id||d.userId||`record-${R}`))]})})]})}function Ee({teamId:e}){let{data:a,isLoading:s,isError:n}=Z({queryKey:["teams",e,"quotas"],queryFn:async()=>{let r=await g.api.teams[":teamId"].quotas.$get({param:{teamId:e}});if(!r.ok)throw Error(Xo());return await r.json()},enabled:!!e}),l=a?.rules??[];return o(Ve,{className:"border-border/60 shadow-sm",children:[o(_t,{children:[o(yt,{className:"flex items-center gap-2 text-xl font-semibold tracking-tight",children:[t(zo,{className:"h-5 w-5 text-primary"}),$d()]}),t(kt,{children:xC()})]}),t(dt,{children:s?t("div",{className:"flex h-48 items-center justify-center",children:t(O,{className:"h-7 w-7 animate-spin text-muted-foreground"})}):n?t("div",{className:"py-10 text-center text-sm text-destructive",children:Xo()}):l.length===0?o("div",{className:"flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-border py-12 text-center",children:[t(zo,{className:"mb-3 h-10 w-10 text-muted-foreground/50"}),t("p",{className:"text-base font-medium text-foreground",children:vp()}),t("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:bp()})]}):t("div",{className:"space-y-3",children:l.map((r)=>t(St,{teamId:e,rule:r},r.id))})})]})}E();var Bt=Object.values(zl);function Le({teamId:e}){let[a,s]=u([]),[n,l]=u([]),[r,f]=u(""),{ref:x,inView:h}=Nt(),{data:T}=Z({queryKey:["teams",e,"members"],queryFn:async()=>{let c=await g.api.teams[":teamId"].members.$get({param:{teamId:e},query:{}});if(!c.ok)return[];return await c.json()},enabled:!!e}),b=T||[],{data:w,isLoading:y,isError:d,fetchNextPage:R,hasNextPage:p,isFetchingNextPage:v}=pt({queryKey:["teams",e,"audit-logs",a,n,r],queryFn:async({pageParam:c})=>{let k=await g.api.teams[":teamId"]["audit-logs"].$get({param:{teamId:e},query:{first:"20",after:c?String(c):void 0,actions:a.length>0?a:void 0,userIds:n.length>0?n:void 0,itemId:r.trim()||void 0}});if(!k.ok)throw Error("Failed to fetch audit logs");return await k.json()},initialPageParam:"",getNextPageParam:(c)=>c.pageInfo.endCursor||void 0,enabled:!!e});m(()=>{if(h&&p&&!v)R()},[h,p,v,R]);let D=w?.pages.flatMap((c)=>c.nodes)||[],H=w?.pages[0]?.total??0,q=(c)=>{s((k)=>k.includes(c)?k.filter((j)=>j!==c):[...k,c])},W=(c)=>{l((k)=>k.includes(c)?k.filter((j)=>j!==c):[...k,c])},U=(c)=>{if(c.includes("delete")||c.includes("remove")||c.includes("revoke"))return t(ne,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs",children:c});if(c.includes("create")||c.includes("add"))return t(ne,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs",children:c});if(c.includes("update")||c.includes("reparent")||c.includes("copy"))return t(ne,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs",children:c});return t(ne,{variant:"outline",className:"bg-muted text-muted-foreground border-border font-mono text-xs",children:c})},ae=new Map(b.map((c)=>[c.userId||c.id,c]));return t("div",{className:"space-y-6",children:o(Ve,{className:"border border-border/50 shadow-xs",children:[o(_t,{className:"pb-4",children:[o("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[o("div",{children:[o(yt,{className:"text-xl font-bold flex items-center gap-2",children:[t(Js,{className:"h-5 w-5 text-primary"}),Zf()]}),t(kt,{className:"mt-1",children:F_()})]}),H>0&&o(ne,{variant:"secondary",className:"w-fit text-xs font-normal",children:[H," ",Zf()]})]}),o("div",{className:"mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40",children:[o(Je,{children:[t(Xe,{asChild:!0,children:o(S,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[t(K,{className:"h-3.5 w-3.5"}),Wv(),a.length>0&&t(ne,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:a.length})]})}),o(et,{className:"w-64 p-2",align:"start",children:[t("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:kI()}),t("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:Bt.map((c)=>o("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[t(ur,{checked:a.includes(c),onCheckedChange:()=>q(c)}),t("span",{className:"font-mono",children:c})]},c))}),a.length>0&&t(S,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>s([]),children:"Clear Actions"})]})]}),o(Je,{children:[t(Xe,{asChild:!0,children:o(S,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[t(K,{className:"h-3.5 w-3.5"}),Xv(),n.length>0&&t(ne,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:n.length})]})}),o(et,{className:"w-64 p-2",align:"start",children:[t("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:$I()}),t("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:b.map((c)=>{let k=c.userId||c.user?.id||c.id,j=c.user?.name||c.name||k,J=c.user?.image||c.image;return o("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[t(ur,{checked:n.includes(k),onCheckedChange:()=>W(k)}),o(Ce,{className:"h-5 w-5",children:[t(Ie,{src:J||void 0}),t(Te,{className:"text-[10px]",children:j.slice(0,2).toUpperCase()})]}),t("span",{className:"truncate",children:j})]},k)})}),n.length>0&&t(S,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>l([]),children:"Clear Users"})]})]}),o("div",{className:"relative flex-1 min-w-[200px] max-w-xs",children:[t(zt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),t(z,{type:"text",placeholder:II(),value:r,onChange:(c)=>f(c.target.value),className:"pl-8 pr-8 h-9 text-xs"}),r&&t("button",{onClick:()=>f(""),className:"absolute right-2.5 top-2.5 text-muted-foreground hover:text-foreground",children:t(Ne,{className:"h-4 w-4"})})]}),(a.length>0||n.length>0||r)&&t(S,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{s([]),l([]),f("")},children:"Clear all"})]})]}),o(dt,{className:"p-0",children:[y?t("div",{className:"flex h-64 items-center justify-center",children:t(O,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):d?t("div",{className:"p-8 text-center text-sm text-destructive",children:"Failed to load audit logs."}):D.length===0?t("div",{className:"p-12 text-center text-sm text-muted-foreground",children:DS()}):o(hn,{children:[t(gn,{children:o(fr,{className:"hover:bg-transparent border-b border-border/50",children:[t(Ye,{className:"w-[180px] pl-6 text-xs font-semibold",children:i0()}),t(Ye,{className:"w-[200px] px-4 text-xs font-semibold",children:pM()}),t(Ye,{className:"px-4 text-xs font-semibold",children:tx()}),t(Ye,{className:"px-4 text-xs font-semibold",children:qg()}),t(Ye,{className:"w-[160px] pr-6 text-right text-xs font-semibold",children:k1()})]})}),t(An,{children:D.map((c)=>{let k=c.userId?ae.get(c.userId):null,j=k?.user?.name||k?.name||c.userId||"System",J=k?.user?.image||k?.image;return o(fr,{className:"hover:bg-muted/40 transition-colors",children:[t(Qe,{className:"py-3 pl-6 font-medium",children:U(c.action)}),t(Qe,{className:"py-3 px-4",children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{className:"h-6 w-6",children:[t(Ie,{src:J||void 0}),t(Te,{className:"text-[10px]",children:j.slice(0,2).toUpperCase()})]}),t("span",{className:"text-xs font-medium text-foreground truncate max-w-[160px]",children:c.agent?iu({user:j,agent:c.agent.name}):j}),c.agent&&t(Mt,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]})}),t(Qe,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:c.itemId||"-"}),t(Qe,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:c.projectId||"-"}),t(Qe,{className:"py-3 pr-6 text-right text-xs text-muted-foreground",children:Fr(c.createdAt)})]},c.id)})})]}),t("div",{ref:x,className:"py-4 flex justify-center",children:v&&t(O,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]})})}E();E();function Oe({task:e,open:a,onOpenChange:s}){let[n,l]=u(null);if(!e)return null;let r=(x,h)=>{navigator.clipboard.writeText(x),l(h),setTimeout(()=>{l(null)},2000)},f=(x)=>{switch(x){case"completed":return t(ne,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-xs font-mono",children:"completed"});case"processing":return t(ne,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 text-xs font-mono",children:"processing"});case"pending":return t(ne,{variant:"outline",className:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20 text-xs font-mono",children:"pending"});case"failed":return t(ne,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 text-xs font-mono",children:"failed"});default:return t(ne,{variant:"outline",className:"text-xs font-mono",children:x||"unknown"})}};return t(de,{open:a,onOpenChange:s,children:o(ce,{className:"max-w-2xl max-h-[90vh] flex flex-col p-6",children:[o(me,{className:"pb-2 border-b border-border/50",children:[o("div",{className:"flex items-center justify-between gap-2 pr-6",children:[o("div",{className:"flex items-center gap-2",children:[t(ln,{className:"h-5 w-5 text-primary"}),t(ue,{className:"text-lg font-bold",children:a1()})]}),o("div",{className:"flex items-center gap-2",children:[f(e.status),e.type&&t(ne,{variant:"secondary",className:"font-mono text-xs",children:e.type})]})]}),o(Et,{className:"text-xs text-muted-foreground mt-1 flex items-center gap-2",children:[o("span",{children:[NA(),": ",t("span",{className:"font-mono text-foreground",children:e.id})]}),t(S,{variant:"ghost",size:"icon",className:"h-5 w-5 text-muted-foreground hover:text-foreground",onClick:()=>r(e.id,"task_id"),children:n==="task_id"?t(Me,{className:"h-3 w-3 text-emerald-500"}):t(wr,{className:"h-3 w-3"})})]})]}),o("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 py-3 text-xs border-b border-border/40",children:[o("div",{children:[t("div",{className:"text-muted-foreground",children:rp()}),t("div",{className:"truncate font-medium text-foreground mt-0.5",title:e.fileName||"-",children:e.fileName||"-"})]}),o("div",{children:[t("div",{className:"text-muted-foreground",children:EA()}),t("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.fileSize!==null&&e.fileSize!==void 0?Lr(e.fileSize):"-"})]}),o("div",{children:[t("div",{className:"text-muted-foreground",children:Fd()}),t("div",{className:"truncate font-medium text-foreground mt-0.5",title:e.projectName||"-",children:e.projectName||"-"})]}),o("div",{children:[t("div",{className:"text-muted-foreground",children:T_()}),t("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.assetId||"-"})]}),o("div",{children:[t("div",{className:"text-muted-foreground",children:qg()}),t("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.projectId||"-"})]}),o("div",{children:[t("div",{className:"text-muted-foreground",children:_d()}),o("div",{className:"font-medium text-foreground mt-0.5 flex items-center gap-1",children:[t(Qt,{className:"h-3 w-3 text-muted-foreground"}),Fr(e.createdAt)]})]}),o("div",{children:[t("div",{className:"text-muted-foreground",children:iM()}),t("div",{className:"font-medium text-foreground mt-0.5",children:Fr(e.updatedAt)})]}),e.heartbeat&&o("div",{children:[t("div",{className:"text-muted-foreground",children:Zw()}),t("div",{className:"font-medium text-foreground mt-0.5",children:Fr(e.heartbeat)})]}),e.model&&o("div",{children:[t("div",{className:"text-muted-foreground",children:mp()}),t("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.model})]}),(e.inputTokens>0||e.outputTokens>0)&&o("div",{children:[o("div",{className:"text-muted-foreground flex items-center gap-1",children:[t(Tn,{className:"h-3 w-3"})," ",L1()]}),o("div",{className:"font-medium text-foreground mt-0.5 font-mono",children:[e.inputTokens.toLocaleString()," in / ",e.outputTokens.toLocaleString()," out"]})]}),e.sessionId&&o("div",{className:"col-span-2",children:[t("div",{className:"text-muted-foreground",children:rT()}),t("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.sessionId})]})]}),t("div",{className:"flex-1 min-h-0 pt-3",children:o(Ln,{defaultValue:"payload",className:"w-full h-full flex flex-col",children:[o(Zn,{className:"grid w-full grid-cols-2",children:[t(Tr,{value:"payload",children:BE()}),t(Tr,{value:"output",children:TE()})]}),t(Gr,{value:"payload",className:"flex-1 mt-2 min-h-0",children:t(le,{className:"h-64 w-full rounded-md border border-border/50 bg-muted/30 p-3 font-mono text-xs",children:t("pre",{className:"whitespace-pre-wrap break-all text-foreground/90",children:e.payload?JSON.stringify(e.payload,null,2):"null"})})}),t(Gr,{value:"output",className:"flex-1 mt-2 min-h-0",children:t(le,{className:"h-64 w-full rounded-md border border-border/50 bg-muted/30 p-3 font-mono text-xs",children:t("pre",{className:"whitespace-pre-wrap break-all text-foreground/90",children:e.output?JSON.stringify(e.output,null,2):"null"})})})]})})]})})}var Ht=Object.values(qa),Lt=Object.values(Ha);function je({teamId:e}){let a=G(),[s,n]=u([]),[l,r]=u([]),[f,x]=u(null),[h,T]=u(null),{ref:b,inView:w}=Nt(),y=N(()=>["teams",e,"workflow-tasks",s,l],[e,s,l]),{data:d,isLoading:R,isError:p,fetchNextPage:v,hasNextPage:D,isFetchingNextPage:H,refetch:q,isRefetching:W}=pt({queryKey:y,queryFn:async({pageParam:i})=>{let A=await g.api.teams[":teamId"]["workflow-tasks"].$get({param:{teamId:e},query:{first:"20",after:i?String(i):void 0,status:s.length>0?s:void 0,types:l.length>0?l:void 0}});if(!A.ok)throw Error("Failed to fetch workflow tasks");return await A.json()},initialPageParam:"",getNextPageParam:(i)=>i.pageInfo.endCursor||void 0,enabled:!!e});m(()=>{if(w&&D&&!H)v()},[w,D,H,v]);let U=N(()=>d?.pages.flatMap((i)=>i.nodes)||[],[d]),ae=d?.pages[0]?.total??0,c=N(()=>U.filter((i)=>i.status==="pending"||i.status==="processing").map((i)=>i.id),[U]);Z({queryKey:["teams",e,"workflow-tasks","batch-status",c],queryFn:async()=>{if(c.length===0)return null;let i=await g.api.teams[":teamId"]["workflow-tasks"]["batch-status"].$post({param:{teamId:e},json:{taskIds:c}});if(!i.ok)return null;let A=await i.json();if(A.tasks&&A.tasks.length>0)a.setQueryData(y,(Q)=>{if(!Q)return Q;let se=new Map(A.tasks.map((X)=>[X.id,X]));return{...Q,pages:Q.pages.map((X)=>({...X,nodes:X.nodes.map((xe)=>se.get(xe.id)||xe)}))}});return A},enabled:c.length>0,refetchInterval:6000});let k=B({mutationFn:async(i)=>{let A=await g.api.teams[":teamId"]["workflow-tasks"][":taskId"].stop.$post({param:{teamId:e,taskId:i}});if(!A.ok){let Q=await A.json().catch(()=>({message:"Failed to stop task"}));throw Error(Q.message||"Failed to stop task")}return await A.json()},onSuccess:(i)=>{M.success(l1()),a.setQueryData(y,(A)=>{if(!A)return A;return{...A,pages:A.pages.map((Q)=>({...Q,nodes:Q.nodes.map((se)=>se.id===i.task.id?i.task:se)}))}}),x(null)},onError:(i)=>{M.error(i.message||"Failed to stop task")}}),j=(i)=>{n((A)=>A.includes(i)?A.filter((Q)=>Q!==i):[...A,i])},J=(i)=>{r((A)=>A.includes(i)?A.filter((Q)=>Q!==i):[...A,i])},Fe=(i)=>{switch(i){case"completed":return t(ne,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs",children:"completed"});case"processing":return o(ne,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs gap-1.5",children:[t(O,{className:"h-3 w-3 animate-spin"}),"processing"]});case"pending":return t(ne,{variant:"outline",className:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20 font-mono text-xs",children:"pending"});case"failed":return t(ne,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs",children:"failed"});default:return t(ne,{variant:"outline",className:"font-mono text-xs",children:i||"-"})}},We=(i)=>{if(!i)return t(ne,{variant:"outline",children:"-"});if(i.startsWith("transcode"))return t(ne,{variant:"outline",className:"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20 font-mono text-xs",children:i});if(i.startsWith("ai_")||i==="chat")return t(ne,{variant:"outline",className:"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border-indigo-500/20 font-mono text-xs",children:i});return t(ne,{variant:"secondary",className:"font-mono text-xs",children:i})};return o("div",{className:"space-y-6",children:[o(Ve,{className:"border border-border/50 shadow-xs",children:[o(_t,{className:"pb-4",children:[o("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[o("div",{children:[o(yt,{className:"text-xl font-bold flex items-center gap-2",children:[t(oe,{className:"h-5 w-5 text-primary"}),lm()]}),t(kt,{className:"mt-1",children:DM()})]}),o("div",{className:"flex items-center gap-3",children:[ae>0&&o(ne,{variant:"secondary",className:"w-fit text-xs font-normal",children:[ae," ",lm()]}),o(S,{variant:"outline",size:"sm",className:"h-9 gap-1.5 text-xs",onClick:()=>q(),disabled:W,children:[t(De,{className:`h-3.5 w-3.5 ${W?"animate-spin":""}`}),XC()]})]})]}),o("div",{className:"mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40",children:[o(Je,{children:[t(Xe,{asChild:!0,children:o(S,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[t(K,{className:"h-3.5 w-3.5"}),Yv(),s.length>0&&t(ne,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:s.length})]})}),o(et,{className:"w-56 p-2",align:"start",children:[t("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:qI()}),t("div",{className:"space-y-1",children:Lt.map((i)=>o("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[t(ur,{checked:s.includes(i),onCheckedChange:()=>j(i)}),t("span",{className:"font-mono",children:i})]},i))}),s.length>0&&t(S,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>n([]),children:dy()})]})]}),o(Je,{children:[t(Xe,{asChild:!0,children:o(S,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[t(K,{className:"h-3.5 w-3.5"}),Jv(),l.length>0&&t(ne,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:l.length})]})}),o(et,{className:"w-64 p-2",align:"start",children:[t("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:$p()}),t("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:Ht.map((i)=>o("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[t(ur,{checked:l.includes(i),onCheckedChange:()=>J(i)}),t("span",{className:"font-mono truncate",children:i})]},i))}),l.length>0&&t(S,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>r([]),children:fy()})]})]}),(s.length>0||l.length>0)&&t(S,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{n([]),r([])},children:ay()})]})]}),o(dt,{className:"p-0",children:[R?t("div",{className:"flex h-64 items-center justify-center",children:t(O,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):p?t("div",{className:"p-8 text-center text-sm text-destructive",children:xv()}):U.length===0?t("div",{className:"p-12 text-center text-sm text-muted-foreground",children:rE()}):o(hn,{children:[t(gn,{children:o(fr,{className:"hover:bg-transparent border-b border-border/50",children:[t(Ye,{className:"w-[170px] pl-6 text-xs font-semibold",children:ZA()}),t(Ye,{className:"w-[130px] px-4 text-xs font-semibold",children:OA()}),t(Ye,{className:"min-w-[180px] px-4 text-xs font-semibold",children:rp()}),t(Ye,{className:"w-[110px] px-4 text-xs font-semibold",children:EA()}),t(Ye,{className:"w-[160px] px-4 text-xs font-semibold",children:Fd()}),t(Ye,{className:"w-[130px] px-4 text-right text-xs font-semibold",children:_d()}),t(Ye,{className:"w-[120px] pr-6 text-right text-xs font-semibold",children:Rf()})]})}),t(An,{children:U.map((i)=>{let A=i.status==="pending"||i.status==="processing";return o(fr,{className:"hover:bg-muted/40 transition-colors",children:[t(Qe,{className:"py-3 pl-6 font-medium",children:We(i.type)}),t(Qe,{className:"py-3 px-4 font-medium",children:Fe(i.status)}),t(Qe,{className:"py-3 px-4 text-xs font-medium",children:t("span",{className:"truncate block max-w-[220px]",title:i.fileName||i.assetId||"-",children:i.fileName||i.assetId||"-"})}),t(Qe,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:i.fileSize!==null&&i.fileSize!==void 0?Lr(i.fileSize):"-"}),t(Qe,{className:"py-3 px-4 text-xs text-muted-foreground",children:t("span",{className:"truncate block max-w-[160px]",title:i.projectName||i.projectId||"-",children:i.projectName||i.projectId||"-"})}),t(Qe,{className:"py-3 px-4 text-right text-xs text-muted-foreground whitespace-nowrap",children:Fr(i.createdAt)}),t(Qe,{className:"py-3 pr-6 text-right",children:o("div",{className:"flex items-center justify-end gap-1",children:[t(S,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",onClick:()=>T(i),title:yM(),children:t(Ae,{className:"h-4 w-4"})}),A&&o(S,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs border-destructive/30 text-destructive hover:bg-destructive/10",onClick:()=>x(i),disabled:k.isPending,children:[t(ec,{className:"h-3 w-3 mr-1 fill-current"}),kA()]})]})})]},i.id)})})]}),t("div",{ref:b,className:"py-4 flex justify-center",children:H&&t(O,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]}),t(nt,{open:!!f,onOpenChange:(i)=>{if(!i)x(null)},children:o(ot,{children:[o(st,{children:[o("div",{className:"flex items-center gap-2",children:[t(Dr,{className:"h-5 w-5 text-destructive"}),t(at,{children:ZT()})]}),t(lt,{className:"pt-2 text-sm text-muted-foreground",children:LT()}),f&&o("div",{className:"mt-3 p-2.5 rounded-md bg-muted/50 border border-border/40 font-mono text-xs space-y-1",children:[o("div",{children:[NA(),": ",f.id]}),f.fileName&&o("div",{className:"font-sans",children:[rp(),":"," ",t("span",{className:"font-medium text-foreground",children:f.fileName})]}),o("div",{children:[ZA(),": ",f.type||"unknown"]}),o("div",{children:[OA(),": ",f.status]})]})]}),o(it,{children:[t(ut,{disabled:k.isPending,children:Re()}),t(ct,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",disabled:k.isPending,onClick:()=>{if(f)k.mutate(f.id)},children:k.isPending?o(L,{children:[t(O,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),BT()]}):kA()})]})]})}),t(Oe,{task:h,open:!!h,onOpenChange:(i)=>{if(!i)T(null)}})]})}function Ot(){let{teamId:e}=jt.useParams(),[a,s]=u("audit-logs"),{data:n,isLoading:l}=Z({queryKey:["teams",e,"me"],queryFn:async()=>{let r=await g.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!r.ok)throw Error("Failed to fetch me");return await r.json()},enabled:!!e});if(l)return t("div",{className:"flex h-screen items-center justify-center",children:t(O,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(n?.role?.toLowerCase()!=="owner")return o("div",{className:"flex h-full flex-col items-center justify-center p-8 text-center",children:[t(oc,{className:"h-12 w-12 text-destructive mb-4"}),t("h2",{className:"text-xl font-bold tracking-tight mb-2",children:s0()}),t("p",{className:"text-sm text-muted-foreground max-w-md",children:aE()})]});return t("div",{className:"h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300",children:o("div",{className:"flex flex-col md:flex-row h-full",children:[t("div",{className:"w-full h-full md:w-72 bg-sidebar border-b md:border-b-0 md:border-r border-sidebar-border z-10 md:left-16 overflow-y-auto transition-colors duration-300",children:o("nav",{className:"p-4 space-y-1 mt-4",children:[t("div",{className:"mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider",children:Ih()}),t("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:d1()}),o("button",{onClick:()=>s("audit-logs"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="audit-logs"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Js,{className:"w-5 h-5"}),Zf(),a==="audit-logs"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("workflow-tasks"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="workflow-tasks"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(oe,{className:"w-5 h-5"}),lm(),a==="workflow-tasks"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("quotas"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="quotas"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(zo,{className:"w-5 h-5"}),$d(),a==="quotas"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),t("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:l_()}),o("button",{onClick:()=>s("ai-usage"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="ai-usage"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(ke,{className:"w-5 h-5"}),fM(),a==="ai-usage"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("ai-sessions"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="ai-sessions"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(te,{className:"w-5 h-5"}),SA(),a==="ai-sessions"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]})}),t("div",{className:"flex-1 overflow-y-auto p-4 md:p-8",children:o("div",{className:"max-w-6xl mx-auto space-y-8",children:[a==="audit-logs"&&t(Le,{teamId:e}),a==="workflow-tasks"&&t(je,{teamId:e}),a==="ai-usage"&&t(qe,{teamId:e}),a==="ai-sessions"&&t(Se,{teamId:e}),a==="quotas"&&t(Ee,{teamId:e})]})})]})})}var jt=ze("/teams/$teamId/dashboard")({component:Ot});export{jt as Route};
|
package/bin/chunk-yncvy335.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Un,Wt,$o,Fs,di,fi,Yt,Rr,p,Mc,zn,je,Pn,Om,Do,Tf,Ut,fs,Oo,Pr,Go,Uu}from"./chunk-bv589v2m.js";var l=p({is(e){return e.kind==="AliasNode"},create(e,r){return p({kind:"AliasNode",node:e,alias:r})}});var g=p({is(e){return e.kind==="TableNode"},create(e){return p({kind:"TableNode",table:Pn.create(e)})},createWithSchema(e,r){return p({kind:"TableNode",table:Pn.createWithSchema(e,r)})}});function hr(e){return Rr(e)&&Yt(e.toOperationNode)}function Ce(e){return Rr(e)&&"expressionType"in e&&hr(e)}function xr(e){return Rr(e)&&"expression"in e&&Wt(e.alias)&&hr(e)}var D=p({is(e){return e.kind==="SelectModifierNode"},create(e,r){return p({kind:"SelectModifierNode",modifier:e,of:r})},createWithExpression(e){return p({kind:"SelectModifierNode",rawModifier:e})}});var W=p({is(e){return e.kind==="AndNode"},create(e,r){return p({kind:"AndNode",left:e,right:r})}});var C=p({is(e){return e.kind==="OrNode"},create(e,r){return p({kind:"OrNode",left:e,right:r})}});var Re=p({is(e){return e.kind==="OnNode"},create(e){return p({kind:"OnNode",on:e})},cloneWithOperation(e,r,t){return p({...e,on:r==="And"?W.create(e.on,t):C.create(e.on,t)})}});var R=p({is(e){return e.kind==="JoinNode"},create(e,r){return p({kind:"JoinNode",joinType:e,table:r,on:void 0})},createWithOn(e,r,t){return p({kind:"JoinNode",joinType:e,table:r,on:Re.create(t)})},cloneWithOn(e,r){return p({...e,on:e.on?Re.cloneWithOperation(e.on,"And",r):Re.create(r)})}});var I=p({is(e){return e.kind==="BinaryOperationNode"},create(e,r,t){return p({kind:"BinaryOperationNode",leftOperand:e,operator:r,rightOperand:t})}});var Bt=p({is(e){return e.kind==="ColumnNode"},create(e){return p({kind:"ColumnNode",column:je.create(e)})}});var cl=p({is(e){return e.kind==="SelectAllNode"},create(){return p({kind:"SelectAllNode"})}});var te=p({is(e){return e.kind==="ReferenceNode"},create(e,r){return p({kind:"ReferenceNode",table:r,column:e})},createSelectAll(e){return p({kind:"ReferenceNode",table:e,column:cl.create()})}});class Ef{#e;get dynamicReference(){return this.#e}get refType(){return}constructor(e){this.#e=e}toOperationNode(){return Ie(this.#e)}}function Te(e){return Rr(e)&&hr(e)&&Wt(e.dynamicReference)}var T=p({is(e){return e.kind==="OrderByItemNode"},create(e,r){return p({kind:"OrderByItemNode",orderBy:e,direction:r})},cloneWith(e,r){return p({...e,...r})}});var Wr=p({is(e){return e.kind==="CollateNode"},create(e){return p({kind:"CollateNode",collation:je.create(e)})}});class _{#e;constructor(e){this.#e=p(e)}desc(){return new _({node:T.cloneWith(this.#e.node,{direction:Ut.createWithSql("desc")})})}asc(){return new _({node:T.cloneWith(this.#e.node,{direction:Ut.createWithSql("asc")})})}nullsLast(){return new _({node:T.cloneWith(this.#e.node,{nulls:"last"})})}nullsFirst(){return new _({node:T.cloneWith(this.#e.node,{nulls:"first"})})}collate(e){return new _({node:T.cloneWith(this.#e.node,{collation:Wr.create(e)})})}toOperationNode(){return this.#e.node}}function _e(e){return e==="asc"||e==="desc"}function k(e){if(e.length===2)return[$e(e[0],e[1])];if(e.length===1){let[r]=e;if(Array.isArray(r))return fs("orderBy(array) is deprecated, use multiple orderBy calls instead."),r.map((t)=>$e(t));return[$e(r)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${e.length}`)}function $e(e,r){let t=wt(e);if(T.is(t)){if(r)throw Error("Cannot specify direction twice!");return t}return br(t,r)}function wt(e){if(V(e))return yo(e);if(Te(e))return e.toOperationNode();let[r,t]=e.split(" ");if(t)return fs("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),br(Po(r),t);return Po(e)}function br(e,r){if(typeof r==="string"){if(!_e(r))throw Error(`Invalid order by direction: ${r}`);return T.create(e,Ut.createWithSql(r))}if(Ce(r))return fs("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),T.create(e,r.toOperationNode());let t=T.create(e);if(!r)return t;return r(new _({node:t})).toOperationNode()}var oe=p({is(e){return e.kind==="JSONReferenceNode"},create(e,r){return p({kind:"JSONReferenceNode",reference:e,traversal:r})},cloneWithTraversal(e,r){return p({...e,traversal:r})}});var Ae=p({is(e){return e.kind==="JSONOperatorChainNode"},create(e){return p({kind:"JSONOperatorChainNode",operator:e,values:p([])})},cloneWithValue(e,r){return p({...e,values:p([...e.values,r])})}});var j=p({is(e){return e.kind==="JSONPathNode"},create(e){return p({kind:"JSONPathNode",inOperator:e,pathLegs:p([])})},cloneWithLeg(e,r){return p({...e,pathLegs:p([...e.pathLegs,r])})}});function Ie(e){if(Wt(e))return Po(e);return e.toOperationNode()}function U(e){if(zn(e))return e.map((r)=>w(r));else return[w(e)]}function w(e){if(V(e))return yo(e);return Ie(e)}function Sr(e,r){let t=Po(e);if(Tf(r))return oe.create(t,Ae.create(Do.create(r)));let o=r.slice(0,-1);if(Tf(o))return oe.create(t,j.create(Do.create(o)));throw Error(`Invalid JSON operator: ${r}`)}function Po(e){if(!e.includes("."))return te.create(Bt.create(e));let t=e.split(".").map(Ge);if(t.length===3)return Ot(t);if(t.length===2)return xt(t);throw Error(`invalid column reference ${e}`)}function kr(e){if(e.includes(" as ")){let[t,o]=e.split(" as ").map(Ge);return l.create(Po(t),je.create(o))}else return Po(e)}function Cf(e){return Bt.create(e)}function ul(e){if(e.includes(" ")){let[t,o]=e.split(" ").map(Ge);if(!_e(o))throw Error(`invalid order direction "${o}" next to "${t}"`);return k([t,o])[0]}else return Cf(e)}function Ot(e){let[r,t,o]=e;return te.create(Bt.create(o),g.createWithSchema(r,t))}function xt(e){let[r,t]=e;return te.create(Bt.create(t),g.create(r))}function Ge(e){return e.trim()}var qe=p({is(e){return e.kind==="PrimitiveValueListNode"},create(e){return p({kind:"PrimitiveValueListNode",values:p([...e])})}});var Gi=p({is(e){return e.kind==="ValueListNode"},create(e){return p({kind:"ValueListNode",values:p(e)})}});var Kr=p({is(e){return e.kind==="ValueNode"},create(e){return p({kind:"ValueNode",value:e})},createImmediate(e){return p({kind:"ValueNode",value:e,immediate:!0})}});function Er(e){if(zn(e))return gt(e);return m(e)}function m(e){if(V(e))return yo(e);return Kr.create(e)}function Le(e){return $o(e)||Fs(e)||di(e)}function le(e){if(!Le(e))throw Error(`unsafe immediate value ${JSON.stringify(e)}`);return Kr.createImmediate(e)}function gt(e){if(e.some(V))return Gi.create(e.map((r)=>m(r)));return qe.create(e)}function or(e){if(e.length===3)return Be(e[0],e[1],e[2]);else if(e.length===1)return m(e[0]);throw Error(`invalid arguments: ${JSON.stringify(e)}`)}function Be(e,r,t){if(bt(r)&&Tr(t))return I.create(w(e),Ke(r),Kr.createImmediate(t));return I.create(w(e),Ke(r),Er(t))}function N(e,r,t){return I.create(w(e),Ke(r),w(t))}function He(e,r){return ie(Object.entries(e).filter(([,t])=>!Un(t)).map(([t,o])=>Be(t,Tr(o)?"is":"=",o)),r)}function ie(e,r,t=!0){let o=r==="and"?W.create:C.create;if(e.length===0)return I.create(Kr.createImmediate(1),Do.create("="),Kr.createImmediate(r==="and"?1:0));let n=Cr(e[0]);for(let u=1;u<e.length;++u)n=o(n,Cr(e[u]));if(e.length>1&&t)return Oo.create(n);return n}function bt(e){return e==="is"||e==="is not"}function Tr(e){return di(e)||Fs(e)}function Ke(e){if(Wt(e)&&Om.includes(e))return Do.create(e);if(hr(e))return e.toOperationNode();throw Error(`invalid operator ${JSON.stringify(e)}`)}function Cr(e){return hr(e)?e.toOperationNode():e}var z=p({is(e){return e.kind==="OrderByNode"},create(e){return p({kind:"OrderByNode",items:p([...e])})},cloneWithItems(e,r){return p({...e,items:p([...e.items,...r])})}});var Xe=p({is(e){return e.kind==="PartitionByNode"},create(e){return p({kind:"PartitionByNode",items:p(e)})},cloneWithItems(e,r){return p({...e,items:p([...e.items,...r])})}});var Ne=p({is(e){return e.kind==="OverNode"},create(){return p({kind:"OverNode"})},cloneWithOrderByItems(e,r){return p({...e,orderBy:e.orderBy?z.cloneWithItems(e.orderBy,r):z.create(r)})},cloneWithPartitionByItems(e,r){return p({...e,partitionBy:e.partitionBy?Xe.cloneWithItems(e.partitionBy,r):Xe.create(r)})}});var X=p({is(e){return e.kind==="FromNode"},create(e){return p({kind:"FromNode",froms:p(e)})},cloneWithFroms(e,r){return p({...e,froms:p([...e.froms,...r])})}});var Ye=p({is(e){return e.kind==="GroupByNode"},create(e){return p({kind:"GroupByNode",items:p(e)})},cloneWithItems(e,r){return p({...e,items:p([...e.items,...r])})}});var Ze=p({is(e){return e.kind==="HavingNode"},create(e){return p({kind:"HavingNode",having:e})},cloneWithOperation(e,r,t){return p({...e,having:r==="And"?W.create(e.having,t):C.create(e.having,t)})}});var Fe=p({is(e){return e.kind==="ListNode"},create(e){return p({kind:"ListNode",items:p(e)})}});var F=p({is(e){return e.kind==="UpdateQueryNode"},create(e,r){return p({kind:"UpdateQueryNode",table:e.length===1?e[0]:Fe.create(e),...r&&{with:r}})},createWithoutTable(){return p({kind:"UpdateQueryNode"})},cloneWithFromItems(e,r){return p({...e,from:e.from?X.cloneWithFroms(e.from,r):X.create(r)})},cloneWithUpdates(e,r){return p({...e,updates:e.updates?p([...e.updates,...r]):r})},cloneWithLimit(e,r){return p({...e,limit:r})}});var ye=p({is(e){return e.kind==="UsingNode"},create(e){return p({kind:"UsingNode",tables:p(e)})},cloneWithTables(e,r){return p({...e,tables:p([...e.tables,...r])})}});var G=p({is(e){return e.kind==="DeleteQueryNode"},create(e,r){return p({kind:"DeleteQueryNode",from:X.create(e),...r&&{with:r}})},cloneWithOrderByItems:(e,r)=>he.cloneWithOrderByItems(e,r),cloneWithoutOrderBy:(e)=>he.cloneWithoutOrderBy(e),cloneWithLimit(e,r){return p({...e,limit:r})},cloneWithoutLimit(e){return p({...e,limit:void 0})},cloneWithUsing(e,r){return p({...e,using:e.using!==void 0?ye.cloneWithTables(e.using,r):ye.create(r)})}});var O=p({is(e){return e.kind==="WhereNode"},create(e){return p({kind:"WhereNode",where:e})},cloneWithOperation(e,r,t){return p({...e,where:r==="And"?W.create(e.where,t):C.create(e.where,t)})}});var er=p({is(e){return e.kind==="ReturningNode"},create(e){return p({kind:"ReturningNode",selections:p(e)})},cloneWithSelections(e,r){return p({...e,selections:e.selections?p([...e.selections,...r]):p(r)})}});var Ar=p({is(e){return e.kind==="ExplainNode"},create(e,r){return p({kind:"ExplainNode",format:e,options:r})}});var E=p({is(e){return e.kind==="MergeQueryNode"},create(e,r){return p({kind:"MergeQueryNode",into:e,...r&&{with:r}})},cloneWithUsing(e,r){return p({...e,using:r})},cloneWithWhen(e,r){return p({...e,whens:e.whens?p([...e.whens,r]):p([r])})},cloneWithThen(e,r){return p({...e,whens:e.whens?p([...e.whens.slice(0,-1),Go.cloneWithResult(e.whens[e.whens.length-1],r)]):void 0})}});var rr=p({is(e){return e.kind==="OutputNode"},create(e){return p({kind:"OutputNode",selections:p(e)})},cloneWithSelections(e,r){return p({...e,selections:e.selections?p([...e.selections,...r]):p(r)})}});var he=p({is(e){return Vt.is(e)||Pr.is(e)||F.is(e)||G.is(e)||E.is(e)},cloneWithEndModifier(e,r){return p({...e,endModifiers:e.endModifiers?p([...e.endModifiers,r]):p([r])})},cloneWithWhere(e,r){return p({...e,where:e.where?O.cloneWithOperation(e.where,"And",r):O.create(r)})},cloneWithJoin(e,r){return p({...e,joins:e.joins?p([...e.joins,r]):p([r])})},cloneWithReturning(e,r){return p({...e,returning:e.returning?er.cloneWithSelections(e.returning,r):er.create(r)})},cloneWithoutReturning(e){return p({...e,returning:void 0})},cloneWithoutWhere(e){return p({...e,where:void 0})},cloneWithExplain(e,r,t){return p({...e,explain:Ar.create(r,t?.toOperationNode())})},cloneWithTop(e,r){return p({...e,top:r})},cloneWithOutput(e,r){return p({...e,output:e.output?rr.cloneWithSelections(e.output,r):rr.create(r)})},cloneWithOrderByItems(e,r){return p({...e,orderBy:e.orderBy?z.cloneWithItems(e.orderBy,r):z.create(r)})},cloneWithoutOrderBy(e){return p({...e,orderBy:void 0})}});var Vt=p({is(e){return e.kind==="SelectQueryNode"},create(e){return p({kind:"SelectQueryNode",...e&&{with:e}})},createFrom(e,r){return p({kind:"SelectQueryNode",from:X.create(e),...r&&{with:r}})},cloneWithSelections(e,r){return p({...e,selections:e.selections?p([...e.selections,...r]):p(r)})},cloneWithDistinctOn(e,r){return p({...e,distinctOn:e.distinctOn?p([...e.distinctOn,...r]):p(r)})},cloneWithFrontModifier(e,r){return p({...e,frontModifiers:e.frontModifiers?p([...e.frontModifiers,r]):p([r])})},cloneWithOrderByItems:(e,r)=>he.cloneWithOrderByItems(e,r),cloneWithGroupByItems(e,r){return p({...e,groupBy:e.groupBy?Ye.cloneWithItems(e.groupBy,r):Ye.create(r)})},cloneWithLimit(e,r){return p({...e,limit:r})},cloneWithOffset(e,r){return p({...e,offset:r})},cloneWithFetch(e,r){return p({...e,fetch:r})},cloneWithHaving(e,r){return p({...e,having:e.having?Ze.cloneWithOperation(e.having,"And",r):Ze.create(r)})},cloneWithSetOperations(e,r){return p({...e,setOperations:e.setOperations?p([...e.setOperations,...r]):p([...r])})},cloneWithoutSelections(e){return p({...e,selections:[]})},cloneWithoutLimit(e){return p({...e,limit:void 0})},cloneWithoutOffset(e){return p({...e,offset:void 0})},cloneWithoutOrderBy:(e)=>he.cloneWithoutOrderBy(e),cloneWithoutGroupBy(e){return p({...e,groupBy:void 0})}});class ne{#e;constructor(e){this.#e=p(e)}on(...e){return new ne({...this.#e,joinNode:R.cloneWithOn(this.#e.joinNode,or(e))})}onRef(e,r,t){return new ne({...this.#e,joinNode:R.cloneWithOn(this.#e.joinNode,N(e,r,t))})}onTrue(){return new ne({...this.#e,joinNode:R.cloneWithOn(this.#e.joinNode,Ut.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#e.joinNode}}var qr=p({is(e){return e.kind==="PartitionByItemNode"},create(e){return p({kind:"PartitionByItemNode",partitionBy:e})}});function Lr(e){return U(e).map(qr.create)}class se{#e;constructor(e){this.#e=p(e)}orderBy(...e){return new se({overNode:Ne.cloneWithOrderByItems(this.#e.overNode,k(e))})}clearOrderBy(){return new se({overNode:he.cloneWithoutOrderBy(this.#e.overNode)})}partitionBy(e){return new se({overNode:Ne.cloneWithPartitionByItems(this.#e.overNode,Lr(e))})}$call(e){return e(this)}toOperationNode(){return this.#e.overNode}}var ae=p({is(e){return e.kind==="SelectionNode"},create(e){return p({kind:"SelectionNode",selection:e})},createSelectAll(){return p({kind:"SelectionNode",selection:cl.create()})},createSelectAllFromTable(e){return p({kind:"SelectionNode",selection:te.createSelectAll(e)})}});function f(e){if(Yt(e))return f(e(A()));else if(zn(e))return e.map((r)=>Br(r));else return[Br(e)]}function Br(e){if(Wt(e))return ae.create(kr(e));else if(Te(e))return ae.create(e.toOperationNode());else return ae.create(ve(e))}function y(e){if(!e)return[ae.createSelectAll()];else if(Array.isArray(e))return e.map(Dr);else return[Dr(e)]}function Dr(e){if(Wt(e))return ae.createSelectAllFromTable(jt(e));throw Error(`invalid value selectAll expression: ${JSON.stringify(e)}`)}var Fr=p({is(e){return e.kind==="ValuesNode"},create(e){return p({kind:"ValuesNode",values:p(e)})}});var vr=p({is(e){return e.kind==="DefaultInsertValueNode"},create(){return p({kind:"DefaultInsertValueNode"})}});function Pe(e){let r=Yt(e)?e(A()):e,t=zn(r)?r:p([r]);return St(t)}function St(e){let r=kt(e);return[p([...r.keys()].map(Bt.create)),Fr.create(e.map((t)=>Et(t,r)))]}function kt(e){let r=new Map;for(let t of e){let o=Object.keys(t);for(let n of o)if(!r.has(n)&&t[n]!==void 0)r.set(n,r.size)}return r}function Et(e,r){let t=Object.keys(e),o=Array.from({length:r.size}),n=!1,u=t.length;for(let Ee of t){let pe=r.get(Ee);if(Un(pe)){u--;continue}let Qe=e[Ee];if(Un(Qe)||V(Qe))n=!0;o[pe]=Qe}if(u<r.size||n){let Ee=vr.create();return Gi.create(o.map((pe)=>Un(pe)?Ee:m(pe)))}return qe.create(o)}var tr=p({is(e){return e.kind==="ColumnUpdateNode"},create(e,r){return p({kind:"ColumnUpdateNode",column:e,value:r})}});function Mr(...e){if(e.length===2)return[tr.create(w(e[0]),m(e[1]))];return we(e[0])}function we(e){let r=Yt(e)?e(A()):e;return Object.entries(r).filter(([t,o])=>o!==void 0).map(([t,o])=>tr.create(Bt.create(t),m(o)))}var Vr=p({is(e){return e.kind==="OnDuplicateKeyNode"},create(e){return p({kind:"OnDuplicateKeyNode",updates:e})}});class ir{insertId;numInsertedOrUpdatedRows;constructor(e,r){this.insertId=e,this.numInsertedOrUpdatedRows=r}}class q extends Error{node;constructor(e){super("no result");this.node=e}}function v(e){return Object.prototype.hasOwnProperty.call(e,"prototype")}var x=p({is(e){return e.kind==="OnConflictNode"},create(){return p({kind:"OnConflictNode"})},cloneWith(e,r){return p({...e,...r})},cloneWithIndexWhere(e,r){return p({...e,indexWhere:e.indexWhere?O.cloneWithOperation(e.indexWhere,"And",r):O.create(r)})},cloneWithIndexOrWhere(e,r){return p({...e,indexWhere:e.indexWhere?O.cloneWithOperation(e.indexWhere,"Or",r):O.create(r)})},cloneWithUpdateWhere(e,r){return p({...e,updateWhere:e.updateWhere?O.cloneWithOperation(e.updateWhere,"And",r):O.create(r)})},cloneWithUpdateOrWhere(e,r){return p({...e,updateWhere:e.updateWhere?O.cloneWithOperation(e.updateWhere,"Or",r):O.create(r)})},cloneWithoutIndexWhere(e){return p({...e,indexWhere:void 0})},cloneWithoutUpdateWhere(e){return p({...e,updateWhere:void 0})}});class P{#e;constructor(e){this.#e=p(e)}column(e){let r=Bt.create(e);return new P({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?p([...this.#e.onConflictNode.columns,r]):p([r])})})}columns(e){let r=e.map(Bt.create);return new P({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?p([...this.#e.onConflictNode.columns,...r]):p(r)})})}constraint(e){return new P({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{constraint:je.create(e)})})}expression(e){return new P({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new P({...this.#e,onConflictNode:x.cloneWithIndexWhere(this.#e.onConflictNode,or(e))})}whereRef(e,r,t){return new P({...this.#e,onConflictNode:x.cloneWithIndexWhere(this.#e.onConflictNode,N(e,r,t))})}clearWhere(){return new P({...this.#e,onConflictNode:x.cloneWithoutIndexWhere(this.#e.onConflictNode)})}doNothing(){return new Ur({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new Oe({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{updates:we(e)})})}$call(e){return e(this)}}class Ur{#e;constructor(e){this.#e=p(e)}toOperationNode(){return this.#e.onConflictNode}}class Oe{#e;constructor(e){this.#e=p(e)}where(...e){return new Oe({...this.#e,onConflictNode:x.cloneWithUpdateWhere(this.#e.onConflictNode,or(e))})}whereRef(e,r,t){return new Oe({...this.#e,onConflictNode:x.cloneWithUpdateWhere(this.#e.onConflictNode,N(e,r,t))})}clearWhere(){return new Oe({...this.#e,onConflictNode:x.cloneWithoutUpdateWhere(this.#e.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#e.onConflictNode}}var zr=p({is(e){return e.kind==="TopNode"},create(e,r){return p({kind:"TopNode",expression:e,modifiers:r})}});function L(e,r){if(!$o(e)&&!fi(e))throw Error(`Invalid top expression: ${e}`);if(!Un(r)&&!Ct(r))throw Error(`Invalid top modifiers: ${r}`);return zr.create(e,r)}function Ct(e){return e==="percent"||e==="with ties"||e==="percent with ties"}var Y=p({is(e){return e.kind==="OrActionNode"},create(e){return p({kind:"OrActionNode",action:e})}});class d{#e;constructor(e){this.#e=p(e)}values(e){let[r,t]=Pe(e);return new d({...this.#e,queryNode:Pr.cloneWith(this.#e.queryNode,{columns:r,values:t})})}columns(e){return new d({...this.#e,queryNode:Pr.cloneWith(this.#e.queryNode,{columns:p(e.map(Bt.create))})})}expression(e){return new d({...this.#e,queryNode:Pr.cloneWith(this.#e.queryNode,{values:yo(e)})})}defaultValues(){return new d({...this.#e,queryNode:Pr.cloneWith(this.#e.queryNode,{defaultValues:!0})})}modifyEnd(e){return new d({...this.#e,queryNode:he.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}ignore(){return new d({...this.#e,queryNode:Pr.cloneWith(this.#e.queryNode,{orAction:Y.create("ignore")})})}orIgnore(){return new d({...this.#e,queryNode:Pr.cloneWith(this.#e.queryNode,{orAction:Y.create("ignore")})})}orAbort(){return new d({...this.#e,queryNode:Pr.cloneWith(this.#e.queryNode,{orAction:Y.create("abort")})})}orFail(){return new d({...this.#e,queryNode:Pr.cloneWith(this.#e.queryNode,{orAction:Y.create("fail")})})}orReplace(){return new d({...this.#e,queryNode:Pr.cloneWith(this.#e.queryNode,{orAction:Y.create("replace")})})}orRollback(){return new d({...this.#e,queryNode:Pr.cloneWith(this.#e.queryNode,{orAction:Y.create("rollback")})})}top(e,r){return new d({...this.#e,queryNode:he.cloneWithTop(this.#e.queryNode,L(e,r))})}onConflict(e){return new d({...this.#e,queryNode:Pr.cloneWith(this.#e.queryNode,{onConflict:e(new P({onConflictNode:x.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new d({...this.#e,queryNode:Pr.cloneWith(this.#e.queryNode,{onDuplicateKey:Vr.create(we(e))})})}returning(e){return new d({...this.#e,queryNode:he.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(){return new d({...this.#e,queryNode:he.cloneWithReturning(this.#e.queryNode,y())})}output(e){return new d({...this.#e,queryNode:he.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new d({...this.#e,queryNode:he.cloneWithOutput(this.#e.queryNode,y(e))})}clearReturning(){return new d({...this.#e,queryNode:he.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new d({...this.#e})}$castTo(){return new d(this.#e)}$narrowType(){return new d(this.#e)}$assertType(){return new d(this.#e)}withPlugin(e){return new d({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),r=await this.#e.executor.executeQuery(e),{adapter:t}=this.#e.executor,o=e.query;if(o.returning&&t.supportsReturning||o.output&&t.supportsOutput)return r.rows;return[new ir(r.insertId,r.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=q){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){let r=this.compile(),t=this.#e.executor.stream(r,e);for await(let o of t)yield*o.rows}async explain(e,r){return await new d({...this.#e,queryNode:he.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}class nr{numDeletedRows;constructor(e){this.numDeletedRows=e}}var ue=p({is(e){return e.kind==="LimitNode"},create(e){return p({kind:"LimitNode",limit:e})}});var c;class Me{#e;constructor(e){this.#e=p(e)}where(...e){return new c({...this.#e,queryNode:he.cloneWithWhere(this.#e.queryNode,or(e))})}whereRef(e,r,t){return new c({...this.#e,queryNode:he.cloneWithWhere(this.#e.queryNode,N(e,r,t))})}clearWhere(){return new c({...this.#e,queryNode:he.cloneWithoutWhere(this.#e.queryNode)})}top(e,r){return new c({...this.#e,queryNode:he.cloneWithTop(this.#e.queryNode,L(e,r))})}using(e){return new c({...this.#e,queryNode:G.cloneWithUsing(this.#e.queryNode,B(e))})}innerJoin(...e){return this.#r("InnerJoin",e)}leftJoin(...e){return this.#r("LeftJoin",e)}rightJoin(...e){return this.#r("RightJoin",e)}fullJoin(...e){return this.#r("FullJoin",e)}#r(e,r){return new c({...this.#e,queryNode:he.cloneWithJoin(this.#e.queryNode,K(e,r))})}returning(e){return new c({...this.#e,queryNode:he.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(e){return new c({...this.#e,queryNode:he.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new c({...this.#e,queryNode:he.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new c({...this.#e,queryNode:he.cloneWithOutput(this.#e.queryNode,y(e))})}clearReturning(){return new c({...this.#e,queryNode:he.cloneWithoutReturning(this.#e.queryNode)})}clearLimit(){return new c({...this.#e,queryNode:G.cloneWithoutLimit(this.#e.queryNode)})}orderBy(...e){return new c({...this.#e,queryNode:he.cloneWithOrderByItems(this.#e.queryNode,k(e))})}clearOrderBy(){return new c({...this.#e,queryNode:he.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new c({...this.#e,queryNode:G.cloneWithLimit(this.#e.queryNode,ue.create(m(e)))})}modifyEnd(e){return new c({...this.#e,queryNode:he.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new c({...this.#e})}$castTo(){return new c(this.#e)}$narrowType(){return new c(this.#e)}$assertType(){return new c(this.#e)}withPlugin(e){return new c({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),r=await this.#e.executor.executeQuery(e),{adapter:t}=this.#e.executor,o=e.query;if(o.returning&&t.supportsReturning||o.output&&t.supportsOutput)return r.rows;return[new nr(r.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=q){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){let r=this.compile(),t=this.#e.executor.stream(r,e);for await(let o of t)yield*o.rows}async explain(e,r){return await new c({...this.#e,queryNode:he.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}c=Me;class sr{numUpdatedRows;numChangedRows;constructor(e,r){this.numUpdatedRows=e,this.numChangedRows=r}}var h;class me{#e;constructor(e){this.#e=p(e)}where(...e){return new h({...this.#e,queryNode:he.cloneWithWhere(this.#e.queryNode,or(e))})}whereRef(e,r,t){return new h({...this.#e,queryNode:he.cloneWithWhere(this.#e.queryNode,N(e,r,t))})}clearWhere(){return new h({...this.#e,queryNode:he.cloneWithoutWhere(this.#e.queryNode)})}top(e,r){return new h({...this.#e,queryNode:he.cloneWithTop(this.#e.queryNode,L(e,r))})}from(e){return new h({...this.#e,queryNode:F.cloneWithFromItems(this.#e.queryNode,B(e))})}innerJoin(...e){return this.#r("InnerJoin",e)}leftJoin(...e){return this.#r("LeftJoin",e)}rightJoin(...e){return this.#r("RightJoin",e)}fullJoin(...e){return this.#r("FullJoin",e)}#r(e,r){return new h({...this.#e,queryNode:he.cloneWithJoin(this.#e.queryNode,K(e,r))})}orderBy(...e){return new h({...this.#e,queryNode:he.cloneWithOrderByItems(this.#e.queryNode,k(e))})}clearOrderBy(){return new h({...this.#e,queryNode:he.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new h({...this.#e,queryNode:F.cloneWithLimit(this.#e.queryNode,ue.create(m(e)))})}set(...e){return new h({...this.#e,queryNode:F.cloneWithUpdates(this.#e.queryNode,Mr(...e))})}returning(e){return new h({...this.#e,queryNode:he.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(e){return new h({...this.#e,queryNode:he.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new h({...this.#e,queryNode:he.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new h({...this.#e,queryNode:he.cloneWithOutput(this.#e.queryNode,y(e))})}modifyEnd(e){return new h({...this.#e,queryNode:he.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}clearReturning(){return new h({...this.#e,queryNode:he.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new h({...this.#e})}$castTo(){return new h(this.#e)}$narrowType(){return new h(this.#e)}$assertType(){return new h(this.#e)}withPlugin(e){return new h({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),r=await this.#e.executor.executeQuery(e),{adapter:t}=this.#e.executor,o=e.query;if(o.returning&&t.supportsReturning||o.output&&t.supportsOutput)return r.rows;return[new sr(r.numAffectedRows??BigInt(0),r.numChangedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=q){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){let r=this.compile(),t=this.#e.executor.stream(r,e);for await(let o of t)yield*o.rows}async explain(e,r){return await new h({...this.#e,queryNode:he.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}h=me;var ar=p({is(e){return e.kind==="CommonTableExpressionNameNode"},create(e,r){return p({kind:"CommonTableExpressionNameNode",table:g.create(e),columns:r?p(r.map(Bt.create)):void 0})}});var de=p({is(e){return e.kind==="CommonTableExpressionNode"},create(e,r){return p({kind:"CommonTableExpressionNode",name:e,expression:r})},cloneWith(e,r){return p({...e,...r})}});class xe{#e;constructor(e){this.#e=p(e)}materialized(){return new xe({...this.#e,node:de.cloneWith(this.#e.node,{materialized:!0})})}notMaterialized(){return new xe({...this.#e,node:de.cloneWith(this.#e.node,{materialized:!1})})}toOperationNode(){return this.#e.node}}function ur(e,r){let t=r(Qr()).toOperationNode();if(Yt(e))return e(Rt(t)).toOperationNode();return de.create(Jr(e),t)}function Rt(e){return(r)=>new xe({node:de.create(Jr(r),e)})}function Jr(e){if(e.includes("(")){let r=e.split(/[\(\)]/),t=r[0],o=r[1].split(",").map((n)=>n.trim());return ar.create(t,o)}else return ar.create(e)}var ge=p({is(e){return e.kind==="WithNode"},create(e,r){return p({kind:"WithNode",expressions:p([e]),...r})},cloneWithExpression(e,r){return p({...e,expressions:p([...e.expressions,r])})}});var Ir=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function Fu(e){let r="";for(let t=0;t<e;++t)r+=Tt();return r}function Tt(){return Ir[~~(Math.random()*Ir.length)]}function ft(){return new $r}class $r{#e;get queryId(){if(this.#e===void 0)this.#e=Fu(8);return this.#e}}function i(e){return e}class Cc{nodeStack=[];#e=p({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this)});transformNode(e,r){if(!e)return e;this.nodeStack.push(e);let t=this.transformNodeImpl(e,r);return this.nodeStack.pop(),p(t)}transformNodeImpl(e,r){return this.#e[e.kind](e,r)}transformNodeList(e,r){if(!e)return e;return p(e.map((t)=>this.transformNode(t,r)))}transformSelectQuery(e,r){return i({kind:"SelectQueryNode",from:this.transformNode(e.from,r),selections:this.transformNodeList(e.selections,r),distinctOn:this.transformNodeList(e.distinctOn,r),joins:this.transformNodeList(e.joins,r),groupBy:this.transformNode(e.groupBy,r),orderBy:this.transformNode(e.orderBy,r),where:this.transformNode(e.where,r),frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),limit:this.transformNode(e.limit,r),offset:this.transformNode(e.offset,r),with:this.transformNode(e.with,r),having:this.transformNode(e.having,r),explain:this.transformNode(e.explain,r),setOperations:this.transformNodeList(e.setOperations,r),fetch:this.transformNode(e.fetch,r),top:this.transformNode(e.top,r)})}transformSelection(e,r){return i({kind:"SelectionNode",selection:this.transformNode(e.selection,r)})}transformColumn(e,r){return i({kind:"ColumnNode",column:this.transformNode(e.column,r)})}transformAlias(e,r){return i({kind:"AliasNode",node:this.transformNode(e.node,r),alias:this.transformNode(e.alias,r)})}transformTable(e,r){return i({kind:"TableNode",table:this.transformNode(e.table,r)})}transformFrom(e,r){return i({kind:"FromNode",froms:this.transformNodeList(e.froms,r)})}transformReference(e,r){return i({kind:"ReferenceNode",column:this.transformNode(e.column,r),table:this.transformNode(e.table,r)})}transformAnd(e,r){return i({kind:"AndNode",left:this.transformNode(e.left,r),right:this.transformNode(e.right,r)})}transformOr(e,r){return i({kind:"OrNode",left:this.transformNode(e.left,r),right:this.transformNode(e.right,r)})}transformValueList(e,r){return i({kind:"ValueListNode",values:this.transformNodeList(e.values,r)})}transformParens(e,r){return i({kind:"ParensNode",node:this.transformNode(e.node,r)})}transformJoin(e,r){return i({kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,r),on:this.transformNode(e.on,r)})}transformRaw(e,r){return i({kind:"RawNode",sqlFragments:p([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,r)})}transformWhere(e,r){return i({kind:"WhereNode",where:this.transformNode(e.where,r)})}transformInsertQuery(e,r){return i({kind:"InsertQueryNode",into:this.transformNode(e.into,r),columns:this.transformNodeList(e.columns,r),values:this.transformNode(e.values,r),returning:this.transformNode(e.returning,r),onConflict:this.transformNode(e.onConflict,r),onDuplicateKey:this.transformNode(e.onDuplicateKey,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),ignore:e.ignore,orAction:this.transformNode(e.orAction,r),replace:e.replace,explain:this.transformNode(e.explain,r),defaultValues:e.defaultValues,top:this.transformNode(e.top,r),output:this.transformNode(e.output,r)})}transformValues(e,r){return i({kind:"ValuesNode",values:this.transformNodeList(e.values,r)})}transformDeleteQuery(e,r){return i({kind:"DeleteQueryNode",from:this.transformNode(e.from,r),using:this.transformNode(e.using,r),joins:this.transformNodeList(e.joins,r),where:this.transformNode(e.where,r),returning:this.transformNode(e.returning,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),orderBy:this.transformNode(e.orderBy,r),limit:this.transformNode(e.limit,r),explain:this.transformNode(e.explain,r),top:this.transformNode(e.top,r),output:this.transformNode(e.output,r)})}transformReturning(e,r){return i({kind:"ReturningNode",selections:this.transformNodeList(e.selections,r)})}transformCreateTable(e,r){return i({kind:"CreateTableNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),constraints:this.transformNodeList(e.constraints,r),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),selectQuery:this.transformNode(e.selectQuery,r)})}transformColumnDefinition(e,r){return i({kind:"ColumnDefinitionNode",column:this.transformNode(e.column,r),dataType:this.transformNode(e.dataType,r),references:this.transformNode(e.references,r),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,r),check:this.transformNode(e.check,r),generated:this.transformNode(e.generated,r),frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists})}transformAddColumn(e,r){return i({kind:"AddColumnNode",column:this.transformNode(e.column,r)})}transformDropTable(e,r){return i({kind:"DropTableNode",table:this.transformNode(e.table,r),ifExists:e.ifExists,cascade:e.cascade})}transformOrderBy(e,r){return i({kind:"OrderByNode",items:this.transformNodeList(e.items,r)})}transformOrderByItem(e,r){return i({kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,r),direction:this.transformNode(e.direction,r),collation:this.transformNode(e.collation,r),nulls:e.nulls})}transformGroupBy(e,r){return i({kind:"GroupByNode",items:this.transformNodeList(e.items,r)})}transformGroupByItem(e,r){return i({kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,r)})}transformUpdateQuery(e,r){return i({kind:"UpdateQueryNode",table:this.transformNode(e.table,r),from:this.transformNode(e.from,r),joins:this.transformNodeList(e.joins,r),where:this.transformNode(e.where,r),updates:this.transformNodeList(e.updates,r),returning:this.transformNode(e.returning,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),explain:this.transformNode(e.explain,r),limit:this.transformNode(e.limit,r),top:this.transformNode(e.top,r),output:this.transformNode(e.output,r),orderBy:this.transformNode(e.orderBy,r)})}transformColumnUpdate(e,r){return i({kind:"ColumnUpdateNode",column:this.transformNode(e.column,r),value:this.transformNode(e.value,r)})}transformLimit(e,r){return i({kind:"LimitNode",limit:this.transformNode(e.limit,r)})}transformOffset(e,r){return i({kind:"OffsetNode",offset:this.transformNode(e.offset,r)})}transformOnConflict(e,r){return i({kind:"OnConflictNode",columns:this.transformNodeList(e.columns,r),constraint:this.transformNode(e.constraint,r),indexExpression:this.transformNode(e.indexExpression,r),indexWhere:this.transformNode(e.indexWhere,r),updates:this.transformNodeList(e.updates,r),updateWhere:this.transformNode(e.updateWhere,r),doNothing:e.doNothing})}transformOnDuplicateKey(e,r){return i({kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,r)})}transformCreateIndex(e,r){return i({kind:"CreateIndexNode",name:this.transformNode(e.name,r),table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),unique:e.unique,using:this.transformNode(e.using,r),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,r),nullsNotDistinct:e.nullsNotDistinct})}transformList(e,r){return i({kind:"ListNode",items:this.transformNodeList(e.items,r)})}transformDropIndex(e,r){return i({kind:"DropIndexNode",name:this.transformNode(e.name,r),table:this.transformNode(e.table,r),ifExists:e.ifExists,cascade:e.cascade})}transformPrimaryKeyConstraint(e,r){return i({kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,r),name:this.transformNode(e.name,r),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred})}transformUniqueConstraint(e,r){return i({kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,r),name:this.transformNode(e.name,r),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred})}transformForeignKeyConstraint(e,r){return i({kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,r),references:this.transformNode(e.references,r),name:this.transformNode(e.name,r),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred})}transformSetOperation(e,r){return i({kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,r),all:e.all})}transformReferences(e,r){return i({kind:"ReferencesNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),onDelete:e.onDelete,onUpdate:e.onUpdate})}transformCheckConstraint(e,r){return i({kind:"CheckConstraintNode",expression:this.transformNode(e.expression,r),name:this.transformNode(e.name,r)})}transformWith(e,r){return i({kind:"WithNode",expressions:this.transformNodeList(e.expressions,r),recursive:e.recursive})}transformCommonTableExpression(e,r){return i({kind:"CommonTableExpressionNode",name:this.transformNode(e.name,r),materialized:e.materialized,expression:this.transformNode(e.expression,r)})}transformCommonTableExpressionName(e,r){return i({kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r)})}transformHaving(e,r){return i({kind:"HavingNode",having:this.transformNode(e.having,r)})}transformCreateSchema(e,r){return i({kind:"CreateSchemaNode",schema:this.transformNode(e.schema,r),ifNotExists:e.ifNotExists})}transformDropSchema(e,r){return i({kind:"DropSchemaNode",schema:this.transformNode(e.schema,r),ifExists:e.ifExists,cascade:e.cascade})}transformAlterTable(e,r){return i({kind:"AlterTableNode",table:this.transformNode(e.table,r),renameTo:this.transformNode(e.renameTo,r),setSchema:this.transformNode(e.setSchema,r),columnAlterations:this.transformNodeList(e.columnAlterations,r),addConstraint:this.transformNode(e.addConstraint,r),dropConstraint:this.transformNode(e.dropConstraint,r),renameConstraint:this.transformNode(e.renameConstraint,r),addIndex:this.transformNode(e.addIndex,r),dropIndex:this.transformNode(e.dropIndex,r)})}transformDropColumn(e,r){return i({kind:"DropColumnNode",column:this.transformNode(e.column,r)})}transformRenameColumn(e,r){return i({kind:"RenameColumnNode",column:this.transformNode(e.column,r),renameTo:this.transformNode(e.renameTo,r)})}transformAlterColumn(e,r){return i({kind:"AlterColumnNode",column:this.transformNode(e.column,r),dataType:this.transformNode(e.dataType,r),dataTypeExpression:this.transformNode(e.dataTypeExpression,r),setDefault:this.transformNode(e.setDefault,r),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull})}transformModifyColumn(e,r){return i({kind:"ModifyColumnNode",column:this.transformNode(e.column,r)})}transformAddConstraint(e,r){return i({kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,r)})}transformDropConstraint(e,r){return i({kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,r),ifExists:e.ifExists,modifier:e.modifier})}transformRenameConstraint(e,r){return i({kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,r),newName:this.transformNode(e.newName,r)})}transformCreateView(e,r){return i({kind:"CreateViewNode",name:this.transformNode(e.name,r),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,r),as:this.transformNode(e.as,r)})}transformRefreshMaterializedView(e,r){return i({kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,r),concurrently:e.concurrently,withNoData:e.withNoData})}transformDropView(e,r){return i({kind:"DropViewNode",name:this.transformNode(e.name,r),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade})}transformGenerated(e,r){return i({kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,r)})}transformDefaultValue(e,r){return i({kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,r)})}transformOn(e,r){return i({kind:"OnNode",on:this.transformNode(e.on,r)})}transformSelectModifier(e,r){return i({kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,r),of:this.transformNodeList(e.of,r)})}transformCreateType(e,r){return i({kind:"CreateTypeNode",name:this.transformNode(e.name,r),enum:this.transformNode(e.enum,r)})}transformDropType(e,r){return i({kind:"DropTypeNode",name:this.transformNode(e.name,r),ifExists:e.ifExists})}transformExplain(e,r){return i({kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,r)})}transformSchemableIdentifier(e,r){return i({kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,r),identifier:this.transformNode(e.identifier,r)})}transformAggregateFunction(e,r){return i({kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,r),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,r),withinGroup:this.transformNode(e.withinGroup,r),filter:this.transformNode(e.filter,r),over:this.transformNode(e.over,r)})}transformOver(e,r){return i({kind:"OverNode",orderBy:this.transformNode(e.orderBy,r),partitionBy:this.transformNode(e.partitionBy,r)})}transformPartitionBy(e,r){return i({kind:"PartitionByNode",items:this.transformNodeList(e.items,r)})}transformPartitionByItem(e,r){return i({kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,r)})}transformBinaryOperation(e,r){return i({kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,r),operator:this.transformNode(e.operator,r),rightOperand:this.transformNode(e.rightOperand,r)})}transformUnaryOperation(e,r){return i({kind:"UnaryOperationNode",operator:this.transformNode(e.operator,r),operand:this.transformNode(e.operand,r)})}transformUsing(e,r){return i({kind:"UsingNode",tables:this.transformNodeList(e.tables,r)})}transformFunction(e,r){return i({kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,r)})}transformCase(e,r){return i({kind:"CaseNode",value:this.transformNode(e.value,r),when:this.transformNodeList(e.when,r),else:this.transformNode(e.else,r),isStatement:e.isStatement})}transformWhen(e,r){return i({kind:"WhenNode",condition:this.transformNode(e.condition,r),result:this.transformNode(e.result,r)})}transformJSONReference(e,r){return i({kind:"JSONReferenceNode",reference:this.transformNode(e.reference,r),traversal:this.transformNode(e.traversal,r)})}transformJSONPath(e,r){return i({kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,r),pathLegs:this.transformNodeList(e.pathLegs,r)})}transformJSONPathLeg(e,r){return i({kind:"JSONPathLegNode",type:e.type,value:e.value})}transformJSONOperatorChain(e,r){return i({kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,r),values:this.transformNodeList(e.values,r)})}transformTuple(e,r){return i({kind:"TupleNode",values:this.transformNodeList(e.values,r)})}transformMergeQuery(e,r){return i({kind:"MergeQueryNode",into:this.transformNode(e.into,r),using:this.transformNode(e.using,r),whens:this.transformNodeList(e.whens,r),with:this.transformNode(e.with,r),top:this.transformNode(e.top,r),endModifiers:this.transformNodeList(e.endModifiers,r),output:this.transformNode(e.output,r),returning:this.transformNode(e.returning,r)})}transformMatched(e,r){return i({kind:"MatchedNode",not:e.not,bySource:e.bySource})}transformAddIndex(e,r){return i({kind:"AddIndexNode",name:this.transformNode(e.name,r),columns:this.transformNodeList(e.columns,r),unique:e.unique,using:this.transformNode(e.using,r),ifNotExists:e.ifNotExists})}transformCast(e,r){return i({kind:"CastNode",expression:this.transformNode(e.expression,r),dataType:this.transformNode(e.dataType,r)})}transformFetch(e,r){return i({kind:"FetchNode",rowCount:this.transformNode(e.rowCount,r),modifier:e.modifier})}transformTop(e,r){return i({kind:"TopNode",expression:e.expression,modifiers:e.modifiers})}transformOutput(e,r){return i({kind:"OutputNode",selections:this.transformNodeList(e.selections,r)})}transformDataType(e,r){return e}transformSelectAll(e,r){return e}transformIdentifier(e,r){return e}transformValue(e,r){return e}transformPrimitiveValueList(e,r){return e}transformOperator(e,r){return e}transformDefaultInsertValue(e,r){return e}transformOrAction(e,r){return e}transformCollate(e,r){return e}}var At=p({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,RefreshMaterializedViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),qt={json_agg:!0,to_json:!0};class mr extends Cc{#e;#r=new Set;#t=new Set;constructor(e){super();this.#e=e}transformNodeImpl(e,r){if(!this.#s(e))return super.transformNodeImpl(e,r);let t=this.#u(e);for(let u of t)this.#t.add(u);let o=this.#a(e);for(let u of o)this.#r.add(u);let n=super.transformNodeImpl(e,r);for(let u of o)this.#r.delete(u);for(let u of t)this.#t.delete(u);return n}transformSchemableIdentifier(e,r){let t=super.transformSchemableIdentifier(e,r);if(t.schema||!this.#r.has(e.identifier.name))return t;return{...t,schema:je.create(this.#e)}}transformReferences(e,r){let t=super.transformReferences(e,r);if(t.table.table.schema)return t;return{...t,table:g.createWithSchema(this.#e,t.table.table.identifier.name)}}transformAggregateFunction(e,r){return{...super.transformAggregateFunction({...e,aggregated:[]},r),aggregated:this.#i(e,r,"aggregated")}}transformFunction(e,r){return{...super.transformFunction({...e,arguments:[]},r),arguments:this.#i(e,r,"arguments")}}transformSelectModifier(e,r){return{...super.transformSelectModifier({...e,of:void 0},r),of:e.of?.map((t)=>g.is(t)&&!t.table.schema?{...t,table:this.transformIdentifier(t.table.identifier,r)}:this.transformNode(t,r))}}#i(e,r,t){return qt[e.func]?e[t].map((o)=>!g.is(o)||o.table.schema?this.transformNode(o,r):{...o,table:this.transformIdentifier(o.table.identifier,r)}):this.transformNodeList(e[t],r)}#s(e){return e.kind in At}#a(e){let r=new Set;if("name"in e&&e.name&&Pn.is(e.name))this.#n(e.name,r);if("from"in e&&e.from)for(let t of e.from.froms)this.#o(t,r);if("into"in e&&e.into)this.#o(e.into,r);if("table"in e&&e.table)this.#o(e.table,r);if("joins"in e&&e.joins)for(let t of e.joins)this.#o(t.table,r);if("using"in e&&e.using)if(R.is(e.using))this.#o(e.using.table,r);else this.#o(e.using,r);return r}#u(e){let r=new Set;if("with"in e&&e.with)this.#m(e.with,r);return r}#o(e,r){if(g.is(e))return this.#n(e.table,r);if(l.is(e)&&g.is(e.node))return this.#n(e.node.table,r);if(Fe.is(e)){for(let t of e.items)this.#o(t,r);return}if(ye.is(e)){for(let t of e.tables)this.#o(t,r);return}}#n(e,r){let t=e.identifier.name;if(!this.#r.has(t)&&!this.#t.has(t))r.add(t)}#m(e,r){for(let t of e.expressions){let o=t.name.table.table.identifier.name;if(!this.#t.has(o))r.add(o)}}}class us{#e;constructor(e){this.#e=new mr(e)}transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}}var _r=p({is(e){return e.kind==="MatchedNode"},create(e,r=!1){return p({kind:"MatchedNode",not:e,bySource:r})}});function dr(e,r,t){return Go.create(ie([_r.create(!e.isMatched,e.bySource),...r&&r.length>0?[r.length===3&&t?N(r[0],r[1],r[2]):or(r)]:[]],"and",!1))}function ce(e){if(Wt(e))return Ut.create([e],[]);if(hr(e))return e.toOperationNode();return e}class Vi{#e;#r;#t;constructor(){this.#e=new Promise((e,r)=>{this.#t=r,this.#r=e})}get promise(){return this.#e}resolve=(e)=>{if(this.#r)this.#r(e)};reject=(e)=>{if(this.#t)this.#t(e)}}async function Lu(e){let r=new Vi,t=new Vi;return e.provideConnection(async(o)=>(r.resolve(o),await t.promise)).catch((o)=>r.reject(o)),p({connection:await r.promise,release:t.resolve})}var Lt=p([]);class Ic{#e;constructor(e=Lt){this.#e=e}get plugins(){return this.#e}transformQuery(e,r){for(let t of this.#e){let o=t.transformQuery({node:e,queryId:r});if(o.kind===e.kind)e=o;else throw Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${o.kind}`].join(" "))}return e}async executeQuery(e){return await this.provideConnection(async(r)=>{let t=await r.executeQuery(e);if("numUpdatedOrDeletedRows"in t)fs("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`.");return await this.#r(t,e.queryId)})}async*stream(e,r){let{connection:t,release:o}=await Lu(this);try{for await(let n of t.streamQuery(e,r))yield await this.#r(n,e.queryId)}finally{o()}}async#r(e,r){for(let t of this.#e)e=await t.transformResult({result:e,queryId:r});return e}}class fe extends Ic{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(e){return new fe([...this.plugins,e])}withPlugins(e){return new fe([...this.plugins,...e])}withPluginAtFront(e){return new fe([e,...this.plugins])}withoutPlugins(){return new fe([])}}var H=new fe;class cr{numChangedRows;constructor(e){this.numChangedRows=e}}class J{#e;constructor(e){this.#e=p(e)}modifyEnd(e){return new J({...this.#e,queryNode:he.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,r){return new J({...this.#e,queryNode:he.cloneWithTop(this.#e.queryNode,L(e,r))})}using(...e){return new b({...this.#e,queryNode:E.cloneWithUsing(this.#e.queryNode,K("Using",e))})}returning(e){return new J({...this.#e,queryNode:he.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(e){return new J({...this.#e,queryNode:he.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new J({...this.#e,queryNode:he.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new J({...this.#e,queryNode:he.cloneWithOutput(this.#e.queryNode,y(e))})}}class b{#e;constructor(e){this.#e=p(e)}modifyEnd(e){return new b({...this.#e,queryNode:he.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,r){return new b({...this.#e,queryNode:he.cloneWithTop(this.#e.queryNode,L(e,r))})}whenMatched(){return this.#r([])}whenMatchedAnd(...e){return this.#r(e)}whenMatchedAndRef(e,r,t){return this.#r([e,r,t],!0)}#r(e,r){return new fr({...this.#e,queryNode:E.cloneWithWhen(this.#e.queryNode,dr({isMatched:!0},e,r))})}whenNotMatched(){return this.#t([])}whenNotMatchedAnd(...e){return this.#t(e)}whenNotMatchedAndRef(e,r,t){return this.#t([e,r,t],!0)}whenNotMatchedBySource(){return this.#t([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#t(e,!1,!0)}whenNotMatchedBySourceAndRef(e,r,t){return this.#t([e,r,t],!0,!0)}returning(e){return new b({...this.#e,queryNode:he.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(e){return new b({...this.#e,queryNode:he.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new b({...this.#e,queryNode:he.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new b({...this.#e,queryNode:he.cloneWithOutput(this.#e.queryNode,y(e))})}#t(e,r=!1,t=!1){let o={...this.#e,queryNode:E.cloneWithWhen(this.#e.queryNode,dr({isMatched:!1,bySource:t},e,r))};return new(t?fr:jr)(o)}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new b({...this.#e})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),r=await this.#e.executor.executeQuery(e),{adapter:t}=this.#e.executor,o=e.query;if(o.returning&&t.supportsReturning||o.output&&t.supportsOutput)return r.rows;return[new cr(r.numAffectedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=q){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}}class fr{#e;constructor(e){this.#e=p(e)}thenDelete(){return new b({...this.#e,queryNode:E.cloneWithThen(this.#e.queryNode,ce("delete"))})}thenDoNothing(){return new b({...this.#e,queryNode:E.cloneWithThen(this.#e.queryNode,ce("do nothing"))})}thenUpdate(e){return new b({...this.#e,queryNode:E.cloneWithThen(this.#e.queryNode,ce(e(new me({queryId:this.#e.queryId,executor:H,queryNode:F.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate((r)=>r.set(...e))}}class jr{#e;constructor(e){this.#e=p(e)}thenDoNothing(){return new b({...this.#e,queryNode:E.cloneWithThen(this.#e.queryNode,ce("do nothing"))})}thenInsertValues(e){let[r,t]=Pe(e);return new b({...this.#e,queryNode:E.cloneWithThen(this.#e.queryNode,ce(Pr.cloneWith(Pr.createWithoutInto(),{columns:r,values:t})))})}}class Os{#e;constructor(e){this.#e=p(e)}selectFrom(e){return We({queryId:ft(),executor:this.#e.executor,queryNode:Vt.createFrom(B(e),this.#e.withNode)})}selectNoFrom(e){return We({queryId:ft(),executor:this.#e.executor,queryNode:Vt.cloneWithSelections(Vt.create(this.#e.withNode),f(e))})}insertInto(e){return new d({queryId:ft(),executor:this.#e.executor,queryNode:Pr.create(jt(e),this.#e.withNode)})}replaceInto(e){return new d({queryId:ft(),executor:this.#e.executor,queryNode:Pr.create(jt(e),this.#e.withNode,!0)})}deleteFrom(e){return new Me({queryId:ft(),executor:this.#e.executor,queryNode:G.create(B(e),this.#e.withNode)})}updateTable(e){return new me({queryId:ft(),executor:this.#e.executor,queryNode:F.create(B(e),this.#e.withNode)})}mergeInto(e){return new J({queryId:ft(),executor:this.#e.executor,queryNode:E.create(pr(e),this.#e.withNode)})}with(e,r){let t=ur(e,r);return new Os({...this.#e,withNode:this.#e.withNode?ge.cloneWithExpression(this.#e.withNode,t):ge.create(t)})}withRecursive(e,r){let t=ur(e,r);return new Os({...this.#e,withNode:this.#e.withNode?ge.cloneWithExpression(this.#e.withNode,t):ge.create(t,{recursive:!0})})}withPlugin(e){return new Os({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new Os({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new Os({...this.#e,executor:this.#e.executor.withPluginAtFront(new us(e))})}}function Qr(){return new Os({executor:H})}function Gr(e,r){return new ne({joinNode:R.create(e,Z(r))})}function Hr(){return new se({overNode:Ne.create()})}function K(e,r){if(r.length===3)return Ft(e,r[0],r[1],r[2]);else if(r.length===2)return Dt(e,r[0],r[1]);else if(r.length===1)return vt(e,r[0]);else throw Error("not implemented")}function Dt(e,r,t){return t(Gr(e,r)).toOperationNode()}function Ft(e,r,t,o){return R.createWithOn(e,Z(r),N(t,"=",o))}function vt(e,r){return R.create(e,Z(r))}var Xr=p({is(e){return e.kind==="OffsetNode"},create(e){return p({kind:"OffsetNode",offset:e})}});var Yr=p({is(e){return e.kind==="GroupByItemNode"},create(e){return p({kind:"GroupByItemNode",groupBy:e})}});function Zr(e){return e=Yt(e)?e(A()):e,U(e).map(Yr.create)}function ee(e,r,t){if(Yt(r))r=r(Ve());if(!zn(r))r=[r];return r.map((o)=>Uu.create(e,yo(o),t))}class a{#e;constructor(e){this.#e=e}get expressionType(){return}as(e){return new Je(this,e)}or(...e){return new Ue(C.create(this.#e,or(e)))}and(...e){return new ze(W.create(this.#e,or(e)))}$castTo(){return new a(this.#e)}$notNull(){return new a(this.#e)}toOperationNode(){return this.#e}}class Je{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return l.create(this.#e.toOperationNode(),hr(this.#r)?this.#r.toOperationNode():je.create(this.#r))}}class Ue{#e;constructor(e){this.#e=e}get expressionType(){return}as(e){return new Je(this,e)}or(...e){return new Ue(C.create(this.#e,or(e)))}$castTo(){return new Ue(this.#e)}toOperationNode(){return Oo.create(this.#e)}}class ze{#e;constructor(e){this.#e=e}get expressionType(){return}as(e){return new Je(this,e)}and(...e){return new ze(W.create(this.#e,or(e)))}$castTo(){return new ze(this.#e)}toOperationNode(){return Oo.create(this.#e)}}var et=p({is(e){return e.kind==="FetchNode"},create(e,r){return{kind:"FetchNode",rowCount:Kr.create(e),modifier:r}}});function rt(e,r){if(!$o(e)&&!fi(e))throw Error(`Invalid fetch row count: ${e}`);if(!Pt(r))throw Error(`Invalid fetch modifier: ${r}`);return et.create(e,r)}function Pt(e){return e==="only"||e==="with ties"}var s;class lr{#e;constructor(e){this.#e=p(e)}get expressionType(){return}get isSelectQueryBuilder(){return!0}where(...e){return new s({...this.#e,queryNode:he.cloneWithWhere(this.#e.queryNode,or(e))})}whereRef(e,r,t){return new s({...this.#e,queryNode:he.cloneWithWhere(this.#e.queryNode,N(e,r,t))})}having(...e){return new s({...this.#e,queryNode:Vt.cloneWithHaving(this.#e.queryNode,or(e))})}havingRef(e,r,t){return new s({...this.#e,queryNode:Vt.cloneWithHaving(this.#e.queryNode,N(e,r,t))})}select(e){return new s({...this.#e,queryNode:Vt.cloneWithSelections(this.#e.queryNode,f(e))})}distinctOn(e){return new s({...this.#e,queryNode:Vt.cloneWithDistinctOn(this.#e.queryNode,U(e))})}modifyFront(e){return new s({...this.#e,queryNode:Vt.cloneWithFrontModifier(this.#e.queryNode,D.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new s({...this.#e,queryNode:he.cloneWithEndModifier(this.#e.queryNode,D.createWithExpression(e.toOperationNode()))})}distinct(){return new s({...this.#e,queryNode:Vt.cloneWithFrontModifier(this.#e.queryNode,D.create("Distinct"))})}forUpdate(e){return new s({...this.#e,queryNode:he.cloneWithEndModifier(this.#e.queryNode,D.create("ForUpdate",e?Mc(e).map(jt):void 0))})}forShare(e){return new s({...this.#e,queryNode:he.cloneWithEndModifier(this.#e.queryNode,D.create("ForShare",e?Mc(e).map(jt):void 0))})}forKeyShare(e){return new s({...this.#e,queryNode:he.cloneWithEndModifier(this.#e.queryNode,D.create("ForKeyShare",e?Mc(e).map(jt):void 0))})}forNoKeyUpdate(e){return new s({...this.#e,queryNode:he.cloneWithEndModifier(this.#e.queryNode,D.create("ForNoKeyUpdate",e?Mc(e).map(jt):void 0))})}skipLocked(){return new s({...this.#e,queryNode:he.cloneWithEndModifier(this.#e.queryNode,D.create("SkipLocked"))})}noWait(){return new s({...this.#e,queryNode:he.cloneWithEndModifier(this.#e.queryNode,D.create("NoWait"))})}selectAll(e){return new s({...this.#e,queryNode:Vt.cloneWithSelections(this.#e.queryNode,y(e))})}innerJoin(...e){return this.#r("InnerJoin",e)}leftJoin(...e){return this.#r("LeftJoin",e)}rightJoin(...e){return this.#r("RightJoin",e)}fullJoin(...e){return this.#r("FullJoin",e)}crossJoin(...e){return this.#r("CrossJoin",e)}innerJoinLateral(...e){return this.#r("LateralInnerJoin",e)}leftJoinLateral(...e){return this.#r("LateralLeftJoin",e)}crossJoinLateral(...e){return this.#r("LateralCrossJoin",e)}crossApply(...e){return this.#r("CrossApply",e)}outerApply(...e){return this.#r("OuterApply",e)}#r(e,r){return new s({...this.#e,queryNode:he.cloneWithJoin(this.#e.queryNode,K(e,r))})}orderBy(...e){return new s({...this.#e,queryNode:he.cloneWithOrderByItems(this.#e.queryNode,k(e))})}groupBy(e){return new s({...this.#e,queryNode:Vt.cloneWithGroupByItems(this.#e.queryNode,Zr(e))})}limit(e){return new s({...this.#e,queryNode:Vt.cloneWithLimit(this.#e.queryNode,ue.create(m(e)))})}offset(e){return new s({...this.#e,queryNode:Vt.cloneWithOffset(this.#e.queryNode,Xr.create(m(e)))})}fetch(e,r="only"){return new s({...this.#e,queryNode:Vt.cloneWithFetch(this.#e.queryNode,rt(e,r))})}top(e,r){return new s({...this.#e,queryNode:he.cloneWithTop(this.#e.queryNode,L(e,r))})}union(e){return new s({...this.#e,queryNode:Vt.cloneWithSetOperations(this.#e.queryNode,ee("union",e,!1))})}unionAll(e){return new s({...this.#e,queryNode:Vt.cloneWithSetOperations(this.#e.queryNode,ee("union",e,!0))})}intersect(e){return new s({...this.#e,queryNode:Vt.cloneWithSetOperations(this.#e.queryNode,ee("intersect",e,!1))})}intersectAll(e){return new s({...this.#e,queryNode:Vt.cloneWithSetOperations(this.#e.queryNode,ee("intersect",e,!0))})}except(e){return new s({...this.#e,queryNode:Vt.cloneWithSetOperations(this.#e.queryNode,ee("except",e,!1))})}exceptAll(e){return new s({...this.#e,queryNode:Vt.cloneWithSetOperations(this.#e.queryNode,ee("except",e,!0))})}as(e){return new tt(this,e)}clearSelect(){return new s({...this.#e,queryNode:Vt.cloneWithoutSelections(this.#e.queryNode)})}clearWhere(){return new s({...this.#e,queryNode:he.cloneWithoutWhere(this.#e.queryNode)})}clearLimit(){return new s({...this.#e,queryNode:Vt.cloneWithoutLimit(this.#e.queryNode)})}clearOffset(){return new s({...this.#e,queryNode:Vt.cloneWithoutOffset(this.#e.queryNode)})}clearOrderBy(){return new s({...this.#e,queryNode:he.cloneWithoutOrderBy(this.#e.queryNode)})}clearGroupBy(){return new s({...this.#e,queryNode:Vt.cloneWithoutGroupBy(this.#e.queryNode)})}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new s({...this.#e})}$castTo(){return new s(this.#e)}$narrowType(){return new s(this.#e)}$assertType(){return new s(this.#e)}$asTuple(){return new a(this.toOperationNode())}$asScalar(){return new a(this.toOperationNode())}withPlugin(e){return new s({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile();return(await this.#e.executor.executeQuery(e)).rows}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=q){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){let r=this.compile(),t=this.#e.executor.stream(r,e);for await(let o of t)yield*o.rows}async explain(e,r){return await new s({...this.#e,queryNode:he.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}s=lr;function We(e){return new lr(e)}class tt{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return l.create(this.#e.toOperationNode(),je.create(this.#r))}}var M=p({is(e){return e.kind==="AggregateFunctionNode"},create(e,r=[]){return p({kind:"AggregateFunctionNode",func:e,aggregated:r})},cloneWithDistinct(e){return p({...e,distinct:!0})},cloneWithOrderBy(e,r,t=!1){let o=t?"withinGroup":"orderBy";return p({...e,[o]:e[o]?z.cloneWithItems(e[o],r):z.create(r)})},cloneWithFilter(e,r){return p({...e,filter:e.filter?O.cloneWithOperation(e.filter,"And",r):O.create(r)})},cloneWithOrFilter(e,r){return p({...e,filter:e.filter?O.cloneWithOperation(e.filter,"Or",r):O.create(r)})},cloneWithOver(e,r){return p({...e,over:r})}});var Nr=p({is(e){return e.kind==="FunctionNode"},create(e,r){return p({kind:"FunctionNode",func:e,arguments:r})}});class S{#e;constructor(e){this.#e=p(e)}get expressionType(){return}as(e){return new ot(this,e)}distinct(){return new S({...this.#e,aggregateFunctionNode:M.cloneWithDistinct(this.#e.aggregateFunctionNode)})}orderBy(...e){return new S({...this.#e,aggregateFunctionNode:he.cloneWithOrderByItems(this.#e.aggregateFunctionNode,k(e))})}clearOrderBy(){return new S({...this.#e,aggregateFunctionNode:he.cloneWithoutOrderBy(this.#e.aggregateFunctionNode)})}withinGroupOrderBy(...e){return new S({...this.#e,aggregateFunctionNode:M.cloneWithOrderBy(this.#e.aggregateFunctionNode,k(e),!0)})}filterWhere(...e){return new S({...this.#e,aggregateFunctionNode:M.cloneWithFilter(this.#e.aggregateFunctionNode,or(e))})}filterWhereRef(e,r,t){return new S({...this.#e,aggregateFunctionNode:M.cloneWithFilter(this.#e.aggregateFunctionNode,N(e,r,t))})}over(e){let r=Hr();return new S({...this.#e,aggregateFunctionNode:M.cloneWithOver(this.#e.aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}$castTo(){return new S(this.#e)}$notNull(){return new S(this.#e)}toOperationNode(){return this.#e.aggregateFunctionNode}}class ot{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return l.create(this.#e.toOperationNode(),je.create(this.#r))}}function Zu(){let e=(t,o)=>new a(Nr.create(t,U(o??[]))),r=(t,o)=>new S({aggregateFunctionNode:M.create(t,o?U(o):void 0)});return Object.assign(e,{agg:r,avg(t){return r("avg",[t])},coalesce(...t){return e("coalesce",t)},count(t){return r("count",[t])},countAll(t){return new S({aggregateFunctionNode:M.create("count",y(t))})},max(t){return r("max",[t])},min(t){return r("min",[t])},sum(t){return r("sum",[t])},any(t){return e("any",[t])},jsonAgg(t){return new S({aggregateFunctionNode:M.create("json_agg",[Wt(t)?jt(t):t.toOperationNode()])})},toJson(t){return new a(Nr.create("to_json",[Wt(t)?jt(t):t.toOperationNode()]))}})}var it=p({is(e){return e.kind==="UnaryOperationNode"},create(e,r){return p({kind:"UnaryOperationNode",operator:e,operand:r})}});function nt(e,r){return it.create(Do.create(e),w(r))}var No=p({is(e){return e.kind==="CaseNode"},create(e){return p({kind:"CaseNode",value:e})},cloneWithWhen(e,r){return p({...e,when:p(e.when?[...e.when,r]:[r])})},cloneWithThen(e,r){return p({...e,when:e.when?p([...e.when.slice(0,-1),Go.cloneWithResult(e.when[e.when.length-1],r)]):void 0})},cloneWith(e,r){return p({...e,...r})}});class Tc{#e;constructor(e){this.#e=p(e)}when(...e){return new yr({...this.#e,node:No.cloneWithWhen(this.#e.node,Go.create(or(e)))})}}class yr{#e;constructor(e){this.#e=p(e)}then(e){return new st({...this.#e,node:No.cloneWithThen(this.#e.node,Le(e)?le(e):m(e))})}}class st{#e;constructor(e){this.#e=p(e)}when(...e){return new yr({...this.#e,node:No.cloneWithWhen(this.#e.node,Go.create(or(e)))})}else(e){return new at({...this.#e,node:No.cloneWith(this.#e.node,{else:Le(e)?le(e):m(e)})})}end(){return new a(No.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new a(No.cloneWith(this.#e.node,{isStatement:!0}))}}class at{#e;constructor(e){this.#e=p(e)}end(){return new a(No.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new a(No.cloneWith(this.#e.node,{isStatement:!0}))}}var wr=p({is(e){return e.kind==="JSONPathLegNode"},create(e,r){return p({kind:"JSONPathLegNode",type:e,value:r})}});var Mt=/^#-\d+$/;class Se{#e;constructor(e){this.#e=e}at(e){if(typeof e!=="number"&&typeof e!=="string"||typeof e==="number"&&!Number.isInteger(e)||typeof e==="string"&&e!=="last"&&!Mt.test(e))throw Error(`Unexpected index value in .at(...): ${e}`);return this.#r("ArrayLocation",e)}key(e){return this.#r("Member",e)}#r(e,r){if(oe.is(this.#e))return new be(oe.cloneWithTraversal(this.#e,j.is(this.#e.traversal)?j.cloneWithLeg(this.#e.traversal,wr.create(e,r)):Ae.cloneWithValue(this.#e.traversal,Kr.createImmediate(r))));return new be(j.cloneWithLeg(this.#e,wr.create(e,r)))}}class be extends Se{#e;constructor(e){super(e);this.#e=e}get expressionType(){return}as(e){return new ut(this,e)}$castTo(){return new be(this.#e)}$notNull(){return new be(this.#e)}toOperationNode(){return this.#e}}class ut{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return l.create(this.#e.toOperationNode(),hr(this.#r)?this.#r.toOperationNode():je.create(this.#r))}}var Or=p({is(e){return e.kind==="TupleNode"},create(e){return p({kind:"TupleNode",values:p(e)})}});var zt=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],Jt=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],mt=p({is(e){return e.kind==="DataTypeNode"},create(e){return p({kind:"DataTypeNode",dataType:e})}});function dt(e){if(zt.includes(e))return!0;if(Jt.some((r)=>r.test(e)))return!0;return!1}function ds(e){if(hr(e))return e.toOperationNode();if(dt(e))return mt.create(e);throw Error(`invalid column data type ${JSON.stringify(e)}`)}var ct=p({is(e){return e.kind==="CastNode"},create(e,r){return p({kind:"CastNode",expression:e,dataType:r})}});function Ve(e=H){function r(n,u,re){return new a(Be(n,u,re))}function t(n,u){return new a(nt(n,u))}let o=Object.assign(r,{fn:void 0,eb:void 0,selectFrom(n){return We({queryId:ft(),executor:e,queryNode:Vt.createFrom(B(n))})},case(n){return new Tc({node:No.create(Un(n)?void 0:w(n))})},ref(n,u){if(Un(u))return new a(Po(n));return new Se(Sr(n,u))},jsonPath(){return new Se(j.create())},table(n){return new a(jt(n))},val(n){return new a(m(n))},refTuple(...n){return new a(Or.create(n.map(w)))},tuple(...n){return new a(Or.create(n.map(m)))},lit(n){return new a(le(n))},unary:t,not(n){return t("not",n)},exists(n){return t("exists",n)},neg(n){return t("-",n)},between(n,u,re){return new a(I.create(w(n),Do.create("between"),W.create(m(u),m(re))))},betweenSymmetric(n,u,re){return new a(I.create(w(n),Do.create("between symmetric"),W.create(m(u),m(re))))},and(n){if(zn(n))return new a(ie(n,"and"));return new a(He(n,"and"))},or(n){if(zn(n))return new a(ie(n,"or"));return new a(He(n,"or"))},parens(...n){let u=or(n);if(Oo.is(u))return new a(u);else return new a(Oo.create(u))},cast(n,u){return new a(ct.create(w(n),ds(u)))},withSchema(n){return Ve(e.withPluginAtFront(new us(n)))}});return o.fn=Zu(),o.eb=o,o}function A(e){return Ve()}function yo(e){if(hr(e))return e.toOperationNode();else if(Yt(e))return e(A()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(e)}`)}function ve(e){if(hr(e))return e.toOperationNode();else if(Yt(e))return e(A()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(e)}`)}function V(e){return Ce(e)||xr(e)||Yt(e)}class If{#e;get table(){return this.#e}constructor(e){this.#e=e}as(e){return new ht(this.#e,e)}}class ht{#e;#r;get table(){return this.#e}get alias(){return this.#r}constructor(e,r){this.#e=e,this.#r=r}toOperationNode(){return l.create(jt(this.#e),je.create(this.#r))}}function pt(e){return Rr(e)&&hr(e)&&Wt(e.table)&&Wt(e.alias)}function B(e){if(zn(e))return e.map((r)=>Z(r));else return[Z(e)]}function Z(e){if(Wt(e))return pr(e);else if(pt(e))return e.toOperationNode();else return ve(e)}function pr(e){if(e.includes(" as ")){let[t,o]=e.split(" as ").map(lt);return l.create(jt(t),je.create(o))}else return jt(e)}function jt(e){if(e.includes(".")){let[t,o]=e.split(".").map(lt);return g.createWithSchema(t,o)}else return g.create(e)}function lt(e){return e.trim()}class ke{#e;constructor(e){this.#e=p(e)}get expressionType(){return}get isRawBuilder(){return!0}as(e){return new Nt(this,e)}$castTo(){return new ke({...this.#e})}$notNull(){return new ke(this.#e)}withPlugin(e){return new ke({...this.#e,plugins:this.#e.plugins!==void 0?p([...this.#e.plugins,e]):p([e])})}toOperationNode(){return this.#t(this.#r())}compile(e){return this.#i(this.#r(e))}async execute(e){let r=this.#r(e);return r.executeQuery(this.#i(r))}#r(e){let r=e!==void 0?e.getExecutor():H;return this.#e.plugins!==void 0?r.withPlugins(this.#e.plugins):r}#t(e){return e.transformQuery(this.#e.rawNode,this.#e.queryId)}#i(e){return e.compileQuery(this.#t(e),this.#e.queryId)}}function Q(e){return new ke(e)}class Nt{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}get rawBuilder(){return this.#e}toOperationNode(){return l.create(this.#e.toOperationNode(),hr(this.#r)?this.#r.toOperationNode():je.create(this.#r))}}var De=Object.assign((e,...r)=>Q({queryId:ft(),rawNode:Ut.create(e,r?.map(yt)??[])}),{ref(e){return Q({queryId:ft(),rawNode:Ut.createWithChild(Po(e))})},val(e){return Q({queryId:ft(),rawNode:Ut.createWithChild(m(e))})},value(e){return this.val(e)},table(e){return Q({queryId:ft(),rawNode:Ut.createWithChild(jt(e))})},id(...e){let r=Array(e.length+1).fill(".");return r[0]="",r[r.length-1]="",Q({queryId:ft(),rawNode:Ut.create(r,e.map(je.create))})},lit(e){return Q({queryId:ft(),rawNode:Ut.createWithChild(Kr.createImmediate(e))})},literal(e){return this.lit(e)},raw(e){return Q({queryId:ft(),rawNode:Ut.createWithSql(e)})},join(e,r=De`, `){let t=Array(Math.max(2*e.length-1,0)),o=r.toOperationNode();for(let n=0;n<e.length;++n)if(t[2*n]=yt(e[n]),n!==e.length-1)t[2*n+1]=o;return Q({queryId:ft(),rawNode:Ut.createWithChildren(t)})}});function yt(e){if(hr(e))return e.toOperationNode();return m(e)}var gr=p({raw(e,r=[]){return p({sql:e,query:Ut.createWithSql(e),parameters:p(r),queryId:ft()})}});
|
|
3
|
-
export{hr,Bt,cl,Ef,Po,Cf,ul,Gi,Kr,or,he,Vt,Fu,ft,Cc,us,Vi,Lu,Ic,Os,Zu,No,Tc,ds,yo,If,jt,De,gr};
|
package/bin/chunk-ytzddcj2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{P,m,N,_,u,E,L,t,o,G,Z,B,pt,ze,g,I,O,Me,an,It,so,io,Lo,pe,we,Ne,S,ge,Ae,_e,K,en,Kt,Pf,qm,Df,g_,A_,Ff,Lf,Re,gy,na,Py,Oy,Eh,ht,Gf,Bb,ev,Bh,av,dv,fv,pv,mv,hv,Oa,xi,Yc,Xf,Fa,Gv,rw,kw,$w,Vw,cx,dx,fx,Md,fS,XS,tE,cE,dE,Ep,Og,Cp,VE,QE,Fl,oI,mI,Kn,yI,MI,PI,bA,za,tu,Ll,Qp,Kp,Wp,Zl,ru,nu,Yp,Jp,ou,g1,A1,_1,y1,v1,Sn,am,uM,dM,su,VA,vM,wM,xM,SM,EM,de,ce,me,He,ue,z,le,gt,Zr,En,Wn,au,M,Sr,mn,W,ke,Fe,Le,Ze,Be,oe,Ii,Gt,br,Tt,vm}from"./chunk-p1d500sf.js";import{Ja}from"./chunk-7rycq6wb.js";import{mu,ki}from"./chunk-sdp9w627.js";import{jo}from"./chunk-c8kjpmfe.js";import"./chunk-qt78vs3g.js";import"./chunk-cxet91kt.js";import"./chunk-sbg86tch.js";import{Mr}from"./chunk-5aqthcm6.js";import{da,Kl}from"./chunk-j9t7tvt5.js";import{ua}from"./chunk-swz6v48q.js";import{$l}from"./chunk-jq3pq545.js";import{Gl}from"./chunk-sv92vkyh.js";import{tr}from"./chunk-qd7pvaxb.js";import"./chunk-ahgq10a7.js";import{rc,nc}from"./chunk-d18v5vmp.js";import"./chunk-ts4d1mxf.js";import"./chunk-xsfy8hz3.js";import{po}from"./chunk-1eqw2dpx.js";import"./chunk-b7qs7hxg.js";import{mo}from"./chunk-fxtzy5f5.js";import{wr}from"./chunk-ht5rht98.js";E();var kt=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],it=I("folder-open",kt);var St=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],lt=I("list-filter",St);E();function _t({ratio:a}){switch(a){case"16:9":return t("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"});case"9:16":return t("span",{className:"inline-block w-2.5 h-4 border border-current rounded-[1px] shrink-0"});case"4:3":return t("span",{className:"inline-block w-3.5 h-2.5 border border-current rounded-[1px] shrink-0"});case"3:4":return t("span",{className:"inline-block w-2.5 h-3.5 border border-current rounded-[1px] shrink-0"});case"1:1":return t("span",{className:"inline-block w-3 h-3 border border-current rounded-[1px] shrink-0"});default:return t("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"})}}function st(){return Math.random().toString(36).substring(2,9)}function dt(){return{id:st(),type:"text",text:"CONFIDENTIAL",x:0.5,y:0.5,size:0.05,color:"#999999",opacity:0.5,rotation:-30}}function Ct(){return{id:st(),type:"image",imageAssetKey:"",x:0.5,y:0.5,size:0.15,opacity:0.5,rotation:0}}var rt=[{id:"dark",label:"Dark Slate",bg:"#1e293b",dot:"#475569"},{id:"black",label:"Black",bg:"#000000",dot:"#404040"},{id:"gray",label:"Slate Gray",bg:"#64748b",dot:"#cbd5e1"},{id:"white",label:"White",bg:"#ffffff",dot:"#94a3b8"},{id:"green",label:"Chroma Green",bg:"#059669",dot:"#047857"}],Ft={"16:9":1.7777777777777777,"9:16":0.5625,"4:3":1.3333333333333333,"3:4":0.75,"1:1":1};function mt({open:a,onOpenChange:k,initialConfig:h,shareId:f,teamId:C,onSaveSuccess:w}){let q=G(),[d,b]=u([]),[c,v]=u(null),[R,V]=u(null),[F,xe]=u("16:9"),[he,be]=u("grid"),[Ce,J]=u(!1),[ve,ne]=u("new"),[fe,ee]=u(""),[te,ae]=u(null),D=_(null),re=_(null),[se,De]=u({w:0,h:0}),[T,H]=u(!1),s=P((e)=>{if(re.current=e,!e)return;let l=()=>{let{clientWidth:A,clientHeight:y}=e;if(A<=0||y<=0)return;let Q=Ft[F],at=A,$e=at/Q;if($e>y)$e=y,at=$e*Q;De({w:Math.round(at),h:Math.round($e)})};l();let n=new ResizeObserver(l);return n.observe(e),()=>{n.disconnect(),re.current=null}},[F]),X=gt((e)=>e.teamId),ye=C||X,[Ue,je]=u(!1),[Y,Te]=u({}),ie=_(null),Se=g.api.teams[":teamId"].files.$post,Pe=async(e,l)=>{let n=e.target.files?.[0];if(!n)return;if(n.size>1048576){if(M.error(Gv()),ie.current)ie.current.value="";return}if(!ye){M.error(Yc());return}je(!0);let A=URL.createObjectURL(n);Te((y)=>({...y,[l]:A}));try{let y=await Se({param:{teamId:ye},form:{file:n}});if(!y.ok)throw Error(Yc());let Q=await y.json();j(l,{imageAssetKey:Q.key,imageAssetUrl:Q.url})}catch(y){let Q=y instanceof Error?y.message:Yc();M.error(Q)}finally{if(je(!1),ie.current)ie.current.value=""}};m(()=>{if(a){if(h?.blocks&&h.blocks.length>0)b(h.blocks),v(h.blocks[0].id);else{let e=dt();b([e]),v(e.id)}V(null)}},[a,h]);let{data:U=[]}=Z({queryKey:["watermark-templates",C],queryFn:async()=>{let e=await g.api["watermark-templates"].$get({query:C?{teamId:C}:{}});if(!e.ok)return[];return await e.json()},enabled:a}),Ee=g.api.shares[":shareId"].watermark.$put,{mutate:Ie,isPending:Qe}=B({mutationFn:async(e)=>{let l=await Ee({param:{shareId:f},json:{enabled:!0,config:e}});if(!l.ok){let n=await l.json().catch(()=>null);throw Error(n?.error||xi())}return await l.json()},onSuccess:()=>{q.invalidateQueries({queryKey:["share",f]}),q.invalidateQueries({queryKey:["shares"]}),M.success(EM()),k(!1),w?.()},onError:(e)=>{M.error(e.message||xi())}}),Ve=g.api["watermark-templates"].$post,{mutate:Ge,isPending:Xe}=B({mutationFn:async({name:e,config:l})=>{let n=await Ve({json:{name:e,teamId:C||void 0,config:l}});if(!n.ok)throw Error(xi());return await n.json()},onSuccess:(e)=>{q.invalidateQueries({queryKey:["watermark-templates"]}),V(e.id),J(!1),M.success(_1())},onError:()=>{M.error(xi())}}),Ye=g.api["watermark-templates"][":templateId"].$put,{mutate:We,isPending:Je}=B({mutationFn:async({templateId:e,config:l})=>{let n=await Ye({param:{templateId:e},json:{config:l}});if(!n.ok)throw Error(xi());return await n.json()},onSuccess:()=>{q.invalidateQueries({queryKey:["watermark-templates"]}),J(!1),M.success(y1())},onError:()=>{M.error(xi())}}),r=g.api["watermark-templates"][":templateId"].$delete,{mutate:p}=B({mutationFn:async(e)=>{if(!(await r({param:{templateId:e}})).ok)throw Error(Oa())},onSuccess:(e,l)=>{if(q.invalidateQueries({queryKey:["watermark-templates"]}),R===l)V(null);M.success(g1())},onError:()=>{M.error(Oa())}}),x=d.findIndex((e)=>e.id===c),i=x>=0?d[x]:null,qe=()=>{let e=dt();b((l)=>[...l,e]),v(e.id)},ft=()=>{let e=Ct();b((l)=>[...l,e]),v(e.id)},nt=(e)=>{if(!e)return;b((l)=>{let n=l.filter((A)=>A.id!==e);if(c===e)v(n.length>0?n[Math.max(0,x-1)].id:null);return n})},j=(e,l)=>{b((n)=>n.map((A)=>A.id===e?{...A,...l}:A))},xt=()=>{if(d.length===0)return;let e=(x-1+d.length)%d.length;v(d[e].id)},vt=()=>{if(d.length===0)return;let e=(x+1)%d.length;v(d[e].id)},wt=(e,l)=>{e.stopPropagation(),v(l),H(!0)},et=P((e)=>{if(!T||!c||!D.current)return;let l=D.current.getBoundingClientRect(),n=(e.clientX-l.left)/l.width,A=(e.clientY-l.top)/l.height,y=Math.max(0,Math.min(1,Math.round(n*100)/100)),Q=Math.max(0,Math.min(1,Math.round(A*100)/100));j(c,{x:y,y:Q})},[T,c]),tt=P(()=>{H(!1)},[]);m(()=>{if(T)window.addEventListener("mousemove",et),window.addEventListener("mouseup",tt);return()=>{window.removeEventListener("mousemove",et),window.removeEventListener("mouseup",tt)}},[T,et,tt]),m(()=>{let e=(l)=>{if(!a||!c)return;let n=l.target?.tagName?.toLowerCase();if(n==="input"||n==="textarea"||n==="select")return;if(l.key==="Delete"||l.key==="Backspace")l.preventDefault(),nt(c)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,c,x]);let bt=(e)=>{if(e.config?.blocks&&e.config.blocks.length>0){let l=e.config.blocks.map((n)=>({...n,id:st()}));b(l),v(l[0].id),V(e.id)}},yt=()=>{if(d.length===0){M.error(tE());return}Ie({blocks:d})},Nt=()=>{if(ve==="new"){if(!fe.trim()){M.error(Bh());return}Ge({name:fe.trim(),config:{blocks:d}})}else{let e=te||R;if(!e){M.error(bA());return}We({templateId:e,config:{blocks:d}})}};return o(L,{children:[t(de,{open:a,onOpenChange:k,children:o(ce,{showCloseButton:!1,className:"sm:max-w-[1400px] max-w-[95vw] w-[95vw] h-[88vh] flex flex-col p-0 gap-0 overflow-hidden",onPointerDownOutside:(e)=>e.preventDefault(),children:[o("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-card",children:[t("div",{className:"flex items-center gap-3",children:t(ue,{className:"text-base font-semibold",children:wM()})}),o("div",{className:"flex items-center gap-2",children:[o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:o(S,{variant:"outline",size:"sm",className:"gap-2 text-xs",children:[t(it,{className:"h-4 w-4 text-muted-foreground"}),xM()]})}),o(_e,{align:"end",className:"w-56",children:[t(en,{className:"text-xs font-semibold text-muted-foreground",children:fx()}),U.length===0?t("div",{className:"px-2 py-1.5 text-xs text-muted-foreground italic",children:XS()}):U.map((e)=>o(K,{onClick:()=>bt(e),className:"flex items-center justify-between text-xs cursor-pointer",children:[t("span",{className:"truncate flex-1",children:e.name}),R===e.id&&t(Me,{className:"h-3.5 w-3.5 text-primary ml-2 flex-shrink-0"}),t(S,{variant:"ghost",size:"icon",className:"h-5 w-5 hover:bg-destructive/10 hover:text-destructive ml-1",onClick:(l)=>{l.stopPropagation(),p(e.id)},children:t(we,{className:"h-3 w-3"})})]},e.id)),t(Kt,{}),o(K,{onClick:()=>{ne("new"),ee(""),J(!0)},className:"text-xs gap-2 cursor-pointer",children:[t(pe,{className:"h-3.5 w-3.5 text-primary"}),Eh()]}),U.length>0&&o(K,{onClick:()=>{ne("overwrite"),ae(R||U[0].id),J(!0)},className:"text-xs gap-2 cursor-pointer",children:[t(ua,{className:"h-3.5 w-3.5 text-muted-foreground"}),Og()]})]})]}),t(S,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>k(!1),children:Re()}),o(S,{size:"sm",className:"text-xs bg-primary hover:bg-primary/90 text-primary-foreground gap-1.5",disabled:Qe,onClick:yt,children:[t(ua,{className:"h-3.5 w-3.5"}),yI()]})]})]}),o("div",{className:"flex-1 flex overflow-hidden",children:[o("div",{className:"w-[65%] flex flex-col p-4 bg-muted/20 border-r border-border overflow-hidden select-none",children:[o("div",{className:"flex items-center justify-between mb-3",children:[t("div",{className:"flex items-center gap-1 bg-muted/60 p-1 rounded-md border border-border/60",children:["16:9","9:16","4:3","3:4","1:1"].map((e)=>o(S,{variant:F===e?"secondary":"ghost",size:"sm",className:Oe("h-7 px-2.5 text-xs gap-1.5 font-mono transition-all",F===e?"bg-background shadow-xs font-semibold text-foreground border border-border/50":"text-muted-foreground hover:text-foreground"),onClick:()=>xe(e),children:[t(_t,{ratio:e}),t("span",{children:e})]},e))}),t("div",{className:"flex items-center gap-1.5 bg-background border border-border/60 rounded-md p-1",children:rt.map((e)=>t("button",{type:"button",onClick:()=>be(e.id),style:{backgroundColor:e.bg},className:Oe("w-5 h-5 rounded-full border border-border/80 transition-all cursor-pointer relative",he===e.id?"ring-2 ring-primary ring-offset-1 scale-110":"hover:scale-105 opacity-80 hover:opacity-100"),title:e.label},e.id))})]}),t("div",{ref:s,className:"flex-1 flex items-center justify-center overflow-hidden",children:(()=>{let e=rt.find((n)=>n.id===he)||rt[0],l=se.w>0&&se.h>0;return t("div",{ref:D,onClick:()=>v(null),style:{backgroundColor:e.bg,backgroundImage:`radial-gradient(${e.dot} 1px, transparent 1px)`,backgroundSize:"16px 16px",...l?{width:se.w,height:se.h}:{}},className:Oe("relative rounded-lg border border-border overflow-hidden shadow-inner transition-all",F==="16:9"&&"aspect-[16/9] w-full max-h-full",F==="9:16"&&"aspect-[9/16] h-full max-w-full",F==="4:3"&&"aspect-[4/3] w-full max-h-full",F==="3:4"&&"aspect-[3/4] h-full max-w-full",F==="1:1"&&"aspect-square h-full max-w-full"),children:d.map((n)=>{let A=n.id===c,y=n.size*(se.w||640);return t("div",{onMouseDown:(Q)=>wt(Q,n.id),onClick:(Q)=>{Q.stopPropagation(),v(n.id)},style:{left:`${n.x*100}%`,top:`${n.y*100}%`,transform:`translate(-50%, -50%) rotate(${n.rotation}deg)`,opacity:n.opacity},className:Oe("absolute cursor-move select-none transition-shadow rounded p-1.5 flex items-center justify-center",A?"ring-2 ring-primary ring-offset-2 ring-offset-background/80 bg-primary/10":"hover:ring-1 hover:ring-muted-foreground/50"),children:n.type==="text"?t("span",{style:{fontSize:`${y}px`,color:n.color,lineHeight:1,whiteSpace:"nowrap",fontWeight:700,textShadow:"0 1px 3px rgba(0,0,0,0.5)"},children:n.text||"Text"}):t("div",{style:{width:`${y}px`,height:`${y}px`},className:"bg-primary/20 border border-primary/40 rounded flex items-center justify-center p-1 overflow-hidden",children:Y[n.id]||n.imageAssetUrl?t("img",{src:Y[n.id]||n.imageAssetUrl,alt:"Watermark logo",className:"w-full h-full object-contain pointer-events-none"}):t(so,{className:"h-1/2 w-1/2 opacity-70 text-primary"})})},n.id)})})})()})]}),o("div",{className:"w-[35%] flex flex-col bg-card overflow-hidden border-l border-border",children:[t("div",{className:"p-4 border-b border-border bg-muted/10 flex items-center justify-between",children:o("div",{className:"flex items-center gap-2",children:[t(io,{className:"h-4 w-4 text-muted-foreground"}),t("span",{className:"text-xs font-semibold",children:VA()})]})}),o("div",{className:"p-3 border-b border-border bg-background flex items-center justify-between gap-2",children:[o("div",{className:"flex items-center gap-1",children:[t(S,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:d.length<=1,onClick:xt,children:t(an,{className:"h-4 w-4"})}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:t(S,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs font-mono",children:d.length===0?"0 / 0":`${x+1} / ${d.length}`})}),t(_e,{align:"start",className:"w-48",children:d.map((e,l)=>o(K,{onClick:()=>v(e.id),className:"text-xs flex items-center justify-between cursor-pointer",children:[o("span",{className:"flex items-center gap-2 truncate",children:[e.type==="text"?t(Ja,{className:"h-3.5 w-3.5 text-muted-foreground"}):t(so,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.type==="text"?e.text||"Text":e.imageAssetKey||"Image"]}),o("span",{className:"text-[10px] font-mono text-muted-foreground ml-2",children:["#",l+1]})]},e.id))})]}),t(S,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:d.length<=1,onClick:vt,children:t(It,{className:"h-4 w-4"})})]}),o("div",{className:"flex items-center gap-1",children:[i&&t(S,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10",title:ht(),onClick:()=>nt(i.id),children:t(we,{className:"h-4 w-4"})}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:o(S,{size:"sm",className:"h-7 text-xs gap-1",children:[t(pe,{className:"h-3.5 w-3.5"}),Pf()]})}),o(_e,{align:"end",children:[o(K,{onClick:qe,className:"text-xs gap-2 cursor-pointer",children:[t(Ja,{className:"h-3.5 w-3.5"}),Df()]}),o(K,{onClick:ft,className:"text-xs gap-2 cursor-pointer",children:[t(so,{className:"h-3.5 w-3.5"}),qm()]})]})]})]})]}),t(le,{className:"flex-1 min-h-0 p-4",children:i?o("div",{className:"space-y-5 text-xs",children:[o("div",{className:"flex items-center justify-between pb-2 border-b border-border",children:[o("span",{className:"font-semibold text-muted-foreground flex items-center gap-1.5",children:[i.type==="text"?t(Ja,{className:"h-4 w-4 text-primary"}):t(so,{className:"h-4 w-4 text-primary"}),i.type==="text"?Df():qm()]}),o("span",{className:"text-[10px] font-mono text-muted-foreground",children:["ID: ",i.id.slice(0,6)]})]}),i.type==="text"&&o("div",{className:"space-y-2",children:[t(W,{className:"text-xs",children:v1()}),t(z,{type:"text",value:i.text,onChange:(e)=>j(i.id,{text:e.target.value}),className:"text-xs h-8"})]}),i.type==="image"&&o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:$w()}),i.imageAssetKey&&o("button",{type:"button",onClick:()=>j(i.id,{imageAssetKey:"",imageAssetUrl:void 0}),className:"text-xs text-muted-foreground hover:text-destructive flex items-center gap-1 font-medium transition-colors cursor-pointer",children:[t(Ne,{className:"w-3.5 h-3.5"}),Fl?Fl():"Remove"]})]}),t("input",{type:"file",ref:ie,className:"hidden",accept:"image/*",onChange:(e)=>Pe(e,i.id)}),o("div",{onClick:()=>ie.current?.click(),className:"relative aspect-square w-full rounded-xl border border-dashed border-border flex items-center justify-center cursor-pointer overflow-hidden group shadow-inner bg-muted/20 hover:border-primary/50 hover:bg-muted/40 transition-all p-2",children:[Ue&&t("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:o("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[t(O,{className:"w-4 h-4 animate-spin text-primary"}),t("span",{className:"text-xs font-semibold",children:su()})]})}),Y[i.id]||i.imageAssetUrl?o(L,{children:[t("img",{src:Y[i.id]||i.imageAssetUrl,alt:"Uploaded logo preview",className:"max-w-full max-h-full object-contain transition-transform duration-300 group-hover:scale-105"}),o("div",{className:"absolute inset-0 bg-black/45 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col items-center justify-center gap-1 text-white z-10",children:[t(po,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),t("span",{className:"text-xs font-semibold",children:am()})]})]}):o("div",{className:"flex flex-col items-center gap-1.5 text-center p-3",children:[t("div",{className:"p-2 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:t(po,{className:"w-4 h-4 text-muted-foreground"})}),o("div",{children:[t("p",{className:"text-xs font-medium text-foreground",children:uM()}),t("p",{className:"text-[10px] text-muted-foreground mt-0.5 max-w-[150px] mx-auto leading-normal",children:dM()})]})]})]})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:i.type==="text"?rw():Vw()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.size*100),"%"]})]}),o("div",{className:"flex items-center gap-3",children:[t(jo,{min:i.type==="text"?0.01:0.02,max:i.type==="text"?0.12:0.5,step:0.005,value:[i.size],onValueChange:([e])=>j(i.id,{size:e}),className:"flex-1"}),t(z,{type:"number",min:1,max:100,value:Math.round(i.size*100),onChange:(e)=>j(i.id,{size:Math.min(1,Math.max(0.001,Number(e.target.value)/100))}),className:"w-16 h-7 text-xs font-mono text-right"})]})]}),i.type==="text"&&o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:gy()}),t("span",{className:"font-mono text-[11px] text-muted-foreground uppercase",children:i.color})]}),o("div",{className:"flex items-center gap-2",children:[t("input",{type:"color",value:i.color,onChange:(e)=>j(i.id,{color:e.target.value}),className:"w-8 h-8 rounded border border-border cursor-pointer bg-transparent p-0"}),t(z,{type:"text",value:i.color,onChange:(e)=>j(i.id,{color:e.target.value}),className:"flex-1 h-8 text-xs font-mono"})]}),t("div",{className:"flex items-center gap-1.5 pt-1",children:["#FFFFFF","#000000","#999999","#EF4444","#3B82F6","#10B981","#F59E0B"].map((e)=>t("button",{type:"button",onClick:()=>j(i.id,{color:e}),style:{backgroundColor:e},className:"w-5 h-5 rounded-full border border-border hover:scale-110 transition-transform"},e))})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:cE()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.opacity*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.opacity],onValueChange:([e])=>j(i.id,{opacity:e})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:mI()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[i.rotation,"°"]})]}),t(jo,{min:-180,max:180,step:1,value:[i.rotation],onValueChange:([e])=>j(i.id,{rotation:e})}),t("div",{className:"flex items-center gap-1.5 pt-1",children:[-45,-30,0,30,45].map((e)=>o(S,{variant:"outline",size:"sm",className:"h-6 text-[10px] flex-1 px-1 font-mono",onClick:()=>j(i.id,{rotation:e}),children:[e,"°"]},e))})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:VE()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.x*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.x],onValueChange:([e])=>j(i.id,{x:e})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:QE()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.y*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.y],onValueChange:([e])=>j(i.id,{y:e})})]})]}):o("div",{className:"py-12 text-center text-xs text-muted-foreground space-y-3",children:[t("p",{children:PI()}),o(S,{size:"sm",variant:"outline",onClick:qe,children:[t(pe,{className:"h-3.5 w-3.5 mr-1"}),Df()]})]})})]})]})]})}),t(de,{open:Ce,onOpenChange:J,children:o(ce,{className:"max-w-md",children:[t(me,{children:t(ue,{className:"text-sm font-semibold",children:ve==="new"?Eh():Og()})}),t("div",{className:"py-3 space-y-4 text-xs",children:ve==="new"?o("div",{className:"space-y-2",children:[t(W,{children:A1()}),t(z,{type:"text",value:fe,onChange:(e)=>ee(e.target.value),placeholder:Bh(),className:"text-xs"})]}):o("div",{className:"space-y-2",children:[t(W,{children:bA()}),t("select",{value:te||"",onChange:(e)=>ae(e.target.value),className:"w-full h-9 rounded-md border border-input bg-background px-3 text-xs",children:U.map((e)=>t("option",{value:e.id,children:e.name},e.id))})]})}),o(He,{children:[t(S,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>J(!1),children:Re()}),t(S,{size:"sm",className:"text-xs",disabled:Xe||Je,onClick:Nt,children:na()})]})]})})]})}function Oe(...a){return a.filter(Boolean).join(" ")}E();function ut({shareLink:a,viewMode:k,onViewModeChange:h,defaultSortOrder:f,onSortOrderChange:C}){let w=G(),[q,d]=u(a.password||""),[b,c]=u(a.expireAt?new Date(a.expireAt):void 0),[v,R]=u(!1);m(()=>{d(a.password||"")},[a.password]);let[V,F]=u(a.hasPassword),[xe,he]=u(!!a.expireAt),{data:be,refetch:Ce}=Z({queryKey:["share-watermark",a.id],queryFn:async()=>{let s=await g.api.shares[":shareId"].watermark.$get({param:{shareId:a.id}});if(!s.ok)return null;return await s.json()},refetchInterval:(s)=>(s.state.data?.watermarkStatus||a.watermarkStatus)==="processing"?3000:!1}),J=g.api.shares[":shareId"].watermark.$put,{mutate:ve}=B({mutationFn:async()=>{let s=await J({param:{shareId:a.id},json:{enabled:!1}});if(!s.ok)throw Error(xi());return await s.json()},onSuccess:()=>{w.invalidateQueries({queryKey:["shares",a.projectId]}),w.invalidateQueries({queryKey:["share",a.id]}),w.invalidateQueries({queryKey:["share-watermark",a.id]}),M.success(vM())}}),ne=be?.watermarkStatus??a.watermarkStatus??(a.watermarkConfigId?"ready":"disabled"),fe=be?.watermarkConfig?.config??a.watermarkConfig?.config??null,ee=fe!==null&&ne!=="disabled",{data:te}=Z({queryKey:["fields",a.projectId],queryFn:async()=>{let s=await g.api.projects[":projectId"].fields.$get({param:{projectId:a.projectId}});if(!s.ok)throw Error(dv());return await s.json()},enabled:!!a.projectId}),ae=g.api.shares[":shareId"].$put,{mutate:D}=B({mutationFn:async(s)=>{let X=await ae({param:{shareId:a.id},json:s});if(!X.ok)throw Error(xi());return await X.json()},onSuccess:()=>{w.invalidateQueries({queryKey:["shares",a.projectId]}),w.invalidateQueries({queryKey:["share",a.id]}),M.success(za())}}),re=`${window.location.origin}/share/${a.id}`,se=async(s)=>{if(await mo(s))M.success(Py())},De=(s)=>{let X=a.fieldVisibility||{},ye={...X,[s]:!X[s]};D({fieldVisibility:ye})},T="index",H="asc";if(f){let s=f.split(":");T=s[0],H=s[1]||"asc"}return o("div",{className:"flex flex-col h-full bg-background border-l border-border",children:[t("div",{className:"flex-1 overflow-y-auto",children:o("div",{className:"p-4 space-y-6",children:[o("div",{className:"space-y-4",children:[o("div",{className:"flex items-center justify-between",children:[t("h3",{className:"text-sm font-medium",children:cx()}),t(ke,{checked:!a.isDisabled,onCheckedChange:(s)=>D({isDisabled:!s})})]}),o("div",{className:"relative w-full",children:[t(z,{value:re,readOnly:!0,className:"pr-10 bg-muted/50 text-xs"}),t(S,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full",onClick:()=>se(re),children:t(wr,{className:"h-4 w-4"})})]})]}),o("div",{className:"space-y-1",children:[t(Ke,{title:MI(),icon:t(nc,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-4 pt-2",children:[o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:Cp()}),t(ke,{checked:V,onCheckedChange:(s)=>{if(F(s),!s)D({password:null})}})]}),V&&o("div",{className:"flex gap-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[t(z,{type:"text",value:q,onChange:(s)=>d(s.target.value),placeholder:ev(),className:"text-xs"}),t(S,{size:"sm",onClick:()=>D({password:q}),children:Kn()})]})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:av()}),t(ke,{checked:xe,onCheckedChange:(s)=>{if(he(s),!s)c(void 0),D({expireAt:null})}})]}),xe&&t("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:t(Ii,{value:b,onChange:(s)=>{c(s),D({expireAt:s?s.toISOString():null})},className:"text-xs"})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:g_()}),t(ke,{checked:a.allowDownload,onCheckedChange:(s)=>D({allowDownload:s})})]}),t("p",{className:"text-xs text-muted-foreground",children:A_()})]}),o("div",{className:"space-y-2 pt-2 border-t border-border/50",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:VA()}),t(ke,{checked:ee,disabled:ne==="processing",onCheckedChange:(s)=>{if(!s)ve();else R(!0)}})]}),ee&&ne==="processing"&&o("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 font-medium py-1 animate-pulse",children:[t(O,{className:"h-3.5 w-3.5 animate-spin"}),t("span",{children:SM()})]}),ee&&ne!=="processing"&&t(S,{variant:"outline",size:"sm",className:"w-full text-xs gap-1.5 mt-1",onClick:()=>R(!0),children:Bb()})]})]})}),t(Ke,{title:Ff(),icon:t(rc,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-3 pt-2 flex gap-2",children:[o(S,{variant:k==="card"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>h("card"),children:[t(io,{className:"h-4 w-4"}),kw()]}),o(S,{variant:k==="list"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>h("list"),children:[t(Lo,{className:"h-4 w-4"}),dx()]})]})}),t(Ke,{title:Fa(),icon:t(lt,{className:"h-4 w-4"}),children:t("div",{className:"p-3 space-y-3 pt-2",children:te?.map((s)=>o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:s.config?.name}),t(ke,{checked:a.fieldVisibility?.[s.id]??!1,onCheckedChange:()=>De(s.id)})]},s.id))})}),t(Ke,{title:Ll(),icon:t(Gl,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-4 pt-2",children:[o("div",{className:"space-y-2",children:[t(W,{className:"text-xs text-muted-foreground",children:Xf()}),o(Fe,{value:T,onValueChange:(s)=>{if(s==="index")C(null);else C(`${s}:${H}`)},children:[t(Ze,{className:"w-full text-xs h-9",children:t(Le,{})}),o(Be,{children:[t(oe,{value:"index",children:Qp()}),t(oe,{value:"name",children:Zl()}),t(oe,{value:"createdAt",children:Kp()}),t(oe,{value:"size",children:Yp()})]})]})]}),o("div",{className:"space-y-2",children:[t(W,{className:"text-xs text-muted-foreground",children:Ep()}),o(S,{variant:"outline",className:"w-full justify-between font-normal text-xs h-9",disabled:T==="index",onClick:()=>{C(`${T}:${H==="asc"?"desc":"asc"}`)},children:[t("span",{children:T==="name"?H==="asc"?tu():ou():T==="createdAt"?H==="asc"?nu():ru():T==="size"?H==="asc"?Jp():Wp():H==="asc"?Lf():Gf()}),t(mu,{className:"h-4 w-4 opacity-50"})]})]})]})})]})]})}),o("div",{className:"p-4 border-t border-border space-y-2",children:[o(S,{variant:"outline",className:"w-full justify-center",onClick:()=>window.open(re,"_blank"),children:[t($l,{className:"h-4 w-4 mr-2"}),dE()]}),o(S,{className:"w-full justify-center bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>se(re),children:[t(wr,{className:"h-4 w-4 mr-2"}),Oy()]})]}),t(mt,{open:v,onOpenChange:R,initialConfig:fe,shareId:a.id,onSaveSuccess:()=>{Ce(),w.invalidateQueries({queryKey:["share",a.id]}),w.invalidateQueries({queryKey:["shares",a.projectId]})}})]})}function Ke({title:a,icon:k,children:h}){let[f,C]=u(!1);return o("div",{className:"border-b border-border last:border-0",children:[o("button",{onClick:()=>C(!f),className:"w-full flex items-center justify-between py-3 px-2 hover:bg-muted/50 transition-colors",children:[o("div",{className:"flex items-center gap-3",children:[k,t("span",{className:"text-sm font-medium",children:a})]}),t(It,{className:Dt("h-4 w-4 transition-transform",f&&"rotate-90")})]}),f&&h&&t("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:h})]})}function Dt(...a){return a.filter(Boolean).join(" ")}function ot({teamId:a,projectId:k,projectName:h,shareId:f,rootFolderId:C}){let w=G(),{fetchMetadata:q}=br();m(()=>{if(a)q(a)},[a,q]);let{data:d}=Z({queryKey:["share",f],queryFn:async()=>{let r=await g.api.shares[":shareId"].$get({param:{shareId:f}});if(!r.ok)throw Error(mv());return await r.json()}}),b=d?.rootFolderId,[c,v]=u(null),[R,V]=u([]);m(()=>{if(b)v(b),V([]),U(new Set)},[b,f]);let F=mn((r)=>r.setProjectState),xe=mn((r)=>r.clearProjectState),he=(r)=>{if(r===c)return;if(r===b)v(b),V([]);else{let p=R.findIndex((x)=>x.id===r);if(p!==-1)v(r),V(R.slice(p+1))}U(new Set)},[be,Ce]=u(240),[J,ve]=u(360),{shareConfigLeftSidebarCollapsed:ne,shareConfigRightSidebarCollapsed:fe}=Gt(),ee=d?.defaultSortOrder||null,te,ae;if(ee){let r=ee.split(":");te=r[0],ae=r[1]}let D=d?.viewMode??"card",{data:re,fetchNextPage:se,hasNextPage:De,isFetchingNextPage:T,isLoading:H}=pt({queryKey:["folder-children",a,c,"folder",te,ae],queryFn:async({pageParam:r})=>{let p=await g.api.folders[":folderId"].children.$get({param:{folderId:c},query:{assetType:"folder",after:r,sort:te,order:ae}});if(!p.ok)throw Error(pv());return await p.json()},enabled:!!c,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),{data:s,fetchNextPage:X,hasNextPage:ye,isFetchingNextPage:Ue,isLoading:je}=pt({queryKey:["folder-children",a,c,"file",te,ae],queryFn:async({pageParam:r})=>{let p=await g.api.folders[":folderId"].children.$get({param:{folderId:c},query:{assetType:"file",after:r,sort:te,order:ae}});if(!p.ok)throw Error(fv());return await p.json()},enabled:!!c,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),Y=N(()=>re?.pages.flatMap((r)=>r.data??[])??[],[re]),Te=N(()=>s?.pages.flatMap((r)=>r.data??[])??[],[s]);m(()=>{if(d)F({teamId:a,projectId:k,projectName:h,ancestorFolders:R,currentAsset:{name:c===b?d.name:Y.find((r)=>r.id===c)?.name||d.name,type:"folder"},isRootFolder:!1,shareId:f,onFolderClick:he});return()=>xe()},[a,k,h,R,c,b,d,f,Y,F,xe]);let[ie,Se]=u(null),[Pe,U]=u(new Set),Ee=()=>{U(new Set),Se(null)},{dragState:Ie,handleDragStart:Qe,handleDragEnd:Ve}=Kl({teamId:a,projectId:k,assetId:c||"",folders:Y,files:Te,selectedIds:Pe,onClearSelection:Ee}),Ge=g.api.shares[":shareId"].assets[":assetId"].$delete,{mutate:Xe}=B({mutationFn:async(r)=>{if(!(await Ge({param:{shareId:f,assetId:r}})).ok)throw Error(hv())},onSuccess:()=>{w.invalidateQueries({queryKey:["folder-children",a,c]}),M.success(oI())}}),Ye=g.api.shares[":shareId"].$put,{mutate:We}=B({mutationFn:async(r)=>{let p=await Ye({param:{shareId:f},json:r});if(!p.ok)throw Error(xi());return await p.json()},onSuccess:()=>{w.invalidateQueries({queryKey:["share",f]}),M.success(za())}}),Je=(r)=>{if(r.type==="folder"||r.targetType==="folder"){let p=c===b?d?.name||"":Y.find((x)=>x.id===c)?.name||Sn();V((x)=>[{id:c,name:p},...x]),v(r.id),U(new Set)}};if(!d)return t("div",{children:Md()});return o(Wn,{modifiers:[da.configure({anchor:{x:0,y:0}})],sensors:[En.configure({activationConstraints:[new Zr.Distance({value:10})]})],onDragStart:Qe,onDragEnd:Ve,children:[t("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:o("div",{className:"flex flex-1 overflow-hidden relative",children:[!ne&&o(L,{children:[t("div",{className:"bg-background",style:{width:be},children:t(Sr,{teamId:a,projectId:k,projectName:h,rootFolderId:C,dragState:Ie})}),t(Mr,{onResize:(r)=>Ce((p)=>Math.max(180,Math.min(400,p+r)))})]}),t(ki,{teamId:a,projectId:k,assetId:c||"",folders:Y,files:Te,selectedItem:ie,selectedIds:Pe,onItemSelect:(r,p)=>{if(p.metaKey||p.ctrlKey){let x=new Set(Pe);if(x.has(r.id)){if(x.delete(r.id),U(x),ie?.id===r.id){let i=[...Y,...Te].find((qe)=>x.has(qe.id));Se(i||null)}}else x.add(r.id),U(x),Se(r)}else U(new Set([r.id])),Se(r)},onItemDoubleClick:Je,onSaveField:()=>{},displayStyle:D,onClearSelection:Ee,fetchNextFoldersPage:se,hasNextFoldersPage:De,isFetchingNextFoldersPage:T,fetchNextFilesPage:X,hasNextFilesPage:ye,isFetchingNextFilesPage:Ue,isLoading:H||je,filterConditions:[],onFilterChange:()=>{},dragState:Ie,isShareView:!0,onRemoveFromShare:(r)=>{r.forEach((p)=>Xe(p.id))},fieldVisibility:d.fieldVisibility}),!fe&&o(L,{children:[t(Mr,{onResize:(r)=>ve((p)=>Math.max(240,Math.min(600,p-r)))}),t("div",{style:{width:J},className:"flex-shrink-0 h-full",children:t(ut,{shareLink:d,viewMode:D,onViewModeChange:(r)=>We({viewMode:r}),defaultSortOrder:ee,onSortOrderChange:(r)=>We({defaultSortOrder:r})})})]})]})}),t(au,{children:Ie?.isActive?t("div",{className:"flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium shadow-md",children:fS({count:Ie.itemCount})}):null})]})}E();function Mt(){let{projectId:a,shareId:k}=Bt.useParams(),{teamId:h,ensureTeamIdForProject:f}=gt();m(()=>{f(a)},[a,f]);let{data:C}=tr(vm(a)),w=C?.rootFolder,{data:q}=Z({queryKey:["folders",w],queryFn:async()=>{let d=await g.api.folders[":folderId"].$get({param:{folderId:w}});if(!d.ok)throw Error("Failed to fetch folder");return await d.json()},enabled:!!w});if(!h||!w||!q)return t(Tt,{});return t(ot,{teamId:h,projectId:a,projectName:C.name??"",shareId:k,rootFolderId:w})}var Bt=ze("/projects/$projectId/shares/$shareId")({component:Mt});export{Bt as Route};
|
package/bin/chunk-zxqasmvz.js
DELETED