@shumai-one/shumai 0.3.4 → 0.3.6
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-c4nenmry.js → chunk-0jesq6sm.js} +1 -1
- package/bin/{chunk-gg1wfpm8.js → chunk-0jr6q4j4.js} +2 -2
- package/bin/{chunk-cwpmf8tx.js → chunk-0sajh8fw.js} +2 -2
- package/bin/{chunk-ardp3pze.js → chunk-1b7shyfp.js} +1 -1
- package/bin/{chunk-kfbztymc.js → chunk-1f8rr3ef.js} +2 -2
- package/bin/{chunk-zpq34g0w.js → chunk-1fq10abj.js} +2 -2
- package/bin/chunk-1hn9v6hv.js +2 -0
- package/bin/{chunk-4rexdetz.js → chunk-20wtz3kc.js} +3 -3
- package/bin/chunk-2882s5sp.js +1 -0
- package/bin/{chunk-6gjn8trh.js → chunk-29nhtrfv.js} +1 -1
- package/bin/chunk-3egeywt8.js +1 -0
- package/bin/chunk-3htn4m2d.js +7 -0
- package/bin/{chunk-tbdgkpgw.js → chunk-47093mwk.js} +1 -1
- package/bin/{chunk-2mr99scd.js → chunk-4a9sdfyp.js} +2 -2
- package/bin/{chunk-3t7v2de9.js → chunk-4ajat3xv.js} +57 -57
- package/bin/{chunk-6b0f3d07.js → chunk-55myfmhy.js} +2 -2
- package/bin/{chunk-5e48saab.js → chunk-5wrakb8p.js} +1 -1
- package/bin/{chunk-d4sjezbk.js → chunk-6awkqp09.js} +1 -1
- package/bin/chunk-6bztpk7h.js +1 -0
- package/bin/{chunk-j5q3t199.js → chunk-6edadcpn.js} +2 -2
- package/bin/chunk-74zstxav.js +6 -0
- package/bin/chunk-76hs7g0x.js +2 -0
- package/bin/{chunk-s584wxzj.js → chunk-7b60a9sy.js} +2 -2
- package/bin/{chunk-v5zdafv4.js → chunk-7fm1hznx.js} +2 -2
- package/bin/{chunk-sfmhbk59.js → chunk-800vdz5n.js} +1 -1
- package/bin/{chunk-5qwzveck.js → chunk-89kqtj7x.js} +2 -2
- package/bin/chunk-8g0mhzsg.js +2 -0
- package/bin/chunk-8jdgzy22.js +2 -0
- package/bin/chunk-8js9m1j7.js +1 -0
- package/bin/{chunk-r9thyg31.js → chunk-9annjnj2.js} +2 -2
- package/bin/{chunk-pew69nxg.js → chunk-9hsfjqgq.js} +2 -2
- package/bin/{chunk-e6rmqgzv.js → chunk-9p5n3m2z.js} +1 -1
- package/bin/{chunk-8pa1n500.js → chunk-9tnfhrnh.js} +2 -2
- package/bin/{chunk-qw5yjhab.js → chunk-a5fw02xq.js} +3 -3
- package/bin/chunk-adekdctx.css +1 -0
- package/bin/{chunk-q9tm2d21.js → chunk-aeg4kya9.js} +1 -1
- package/bin/{chunk-vzx1r87y.js → chunk-bq2aq6v8.js} +2 -2
- package/bin/{chunk-ddfx823h.js → chunk-c9bpf8gp.js} +2 -2
- package/bin/{chunk-ankkm2wz.js → chunk-ce50f746.js} +2 -2
- package/bin/{chunk-h0k9zw29.js → chunk-crdvxq38.js} +2 -2
- package/bin/{chunk-3vbx3x11.js → chunk-d2qp8g98.js} +2 -2
- package/bin/{chunk-5dqn7egd.js → chunk-d8bpqbdw.js} +1 -1
- package/bin/{chunk-4a185tez.js → chunk-dfzmqx1v.js} +3 -3
- package/bin/{chunk-03pw611p.js → chunk-dmjzrdan.js} +2 -2
- package/bin/chunk-e5s7202g.js +2 -0
- package/bin/{chunk-bpb0szs5.js → chunk-ef5v7gta.js} +2 -2
- package/bin/{chunk-7kdz1eng.js → chunk-ew4cxkcc.js} +2 -2
- package/bin/{chunk-axe5rq99.js → chunk-ex4qa7gv.js} +1 -1
- package/bin/{chunk-75x3w5hx.js → chunk-f2eh802w.js} +1 -1
- package/bin/{chunk-c1j58ekb.js → chunk-f44d9fpd.js} +2 -2
- package/bin/chunk-f5zg7b38.js +1 -0
- package/bin/chunk-fdm1yc29.js +1 -0
- package/bin/{chunk-w3xzd86e.js → chunk-fwbrcfaq.js} +2 -2
- package/bin/{chunk-bhqrqt97.js → chunk-fzaw1e34.js} +2 -2
- package/bin/{chunk-58y9bagr.js → chunk-g70eyttc.js} +2 -2
- package/bin/{chunk-nabagpah.js → chunk-gct52xks.js} +2 -2
- package/bin/{chunk-j5dejr3e.js → chunk-gewh7p42.js} +6 -6
- package/bin/chunk-gg1gwjtn.js +2 -0
- package/bin/chunk-gh64hag9.js +2 -0
- package/bin/{chunk-898hrxwq.js → chunk-ghz19a7t.js} +2 -2
- package/bin/{chunk-n7cmya8k.js → chunk-gra3617w.js} +2 -2
- package/bin/{chunk-jnx8p6kj.js → chunk-gx5rjm9m.js} +1 -1
- package/bin/chunk-h0p8yew4.js +1 -0
- package/bin/{chunk-6ab9eftx.js → chunk-hcvpb1hw.js} +1 -1
- package/bin/chunk-hgngnc1k.js +1 -0
- package/bin/chunk-hqbzjzsm.js +2 -0
- package/bin/{chunk-d4sg0z3y.js → chunk-j1awxx51.js} +2 -2
- package/bin/{chunk-khc3dydj.js → chunk-js0genbf.js} +1 -1
- package/bin/chunk-jt4yh37q.js +62 -0
- package/bin/{chunk-c9f6n4sf.js → chunk-jtd7rydv.js} +1 -1
- package/bin/chunk-k0xpskyq.js +1 -0
- package/bin/{chunk-jgxhv36z.js → chunk-kaxwma6y.js} +1 -1
- package/bin/{chunk-8wzepzp3.js → chunk-kk0gx8eg.js} +2 -2
- package/bin/{chunk-8tnq43k9.js → chunk-mgbqjbfc.js} +1 -1
- package/bin/{chunk-xkh6b42h.js → chunk-mhj0pqq3.js} +2 -2
- package/bin/{chunk-05m8w09t.js → chunk-mmrtjcst.js} +1 -1
- package/bin/{chunk-bagxeg82.js → chunk-mxee09jk.js} +2 -2
- package/bin/{chunk-z544s59c.js → chunk-n198tewr.js} +2 -2
- package/bin/{chunk-1bfrnc6b.js → chunk-n9cjmkky.js} +1 -1
- package/bin/{chunk-4153rke8.js → chunk-nh31ma8d.js} +2 -2
- package/bin/{chunk-gg8dmkwd.js → chunk-nh8azwsx.js} +2 -2
- package/bin/chunk-nhc72y4x.js +2 -0
- package/bin/{chunk-8qe7cpbr.js → chunk-pm64et9d.js} +1 -1
- package/bin/chunk-px6q3jpz.js +1 -0
- package/bin/{chunk-q2shr586.js → chunk-q7xfrtnj.js} +1 -1
- package/bin/{chunk-scfbmsy7.js → chunk-rmm6y799.js} +2 -2
- package/bin/{chunk-sddrv3ep.js → chunk-snexx7ks.js} +1 -1
- package/bin/chunk-sx3by19j.js +1 -0
- package/bin/{chunk-2ydhnafa.js → chunk-sx7kparv.js} +2 -2
- package/bin/{chunk-2y9t0qxp.js → chunk-t5561vz5.js} +1 -1
- package/bin/chunk-thj4cpev.js +2 -0
- package/bin/{chunk-3xfhbvar.js → chunk-tqxmj05h.js} +2 -2
- package/bin/{chunk-d2xrh0vv.js → chunk-vgr9db5g.js} +2 -2
- package/bin/{chunk-7pcba64w.js → chunk-vqgz25av.js} +1 -1
- package/bin/{chunk-m8tnsds1.js → chunk-vw1rhgjs.js} +2 -2
- package/bin/chunk-vz75bqvx.js +2 -0
- package/bin/{chunk-zned6mj8.js → chunk-w16jgdfx.js} +1 -1
- package/bin/{chunk-s5s1rk4n.js → chunk-w4ycztv5.js} +1 -1
- package/bin/{chunk-38hp9gfh.js → chunk-w98wvk17.js} +2 -2
- package/bin/chunk-wa8k9fwx.js +1 -0
- package/bin/{chunk-89chaa11.js → chunk-y0yrmcf3.js} +2 -2
- package/bin/{chunk-2jnyk045.js → chunk-y1t47c7f.js} +1 -1
- package/bin/{chunk-1apsnd7e.js → chunk-y8vw7zv1.js} +1 -1
- package/bin/{chunk-k78m3rar.js → chunk-ym47952x.js} +2 -2
- package/bin/{chunk-kgr3ytpb.js → chunk-yzra1x8f.js} +2 -2
- package/bin/{chunk-7xfx7741.js → chunk-z0tbq08w.js} +1 -1
- package/bin/{chunk-9deae0n7.js → chunk-z0zevgb6.js} +1 -1
- package/bin/{chunk-2967rnmn.js → chunk-z2ef8zpz.js} +1 -1
- package/bin/chunk-z3p3qz9d.js +3 -0
- package/bin/chunk-zv85aqwb.css +1 -0
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +490 -340
- package/package.json +7 -7
- package/prisma/migrations/20260810025327_add_mcp_servers/migration.sql +71 -0
- package/prisma/migrations/20260810074554_mcp_server_cleanup/migration.sql +12 -0
- package/prisma/migrations/20260810124707_add_mcp_server_instructions/migration.sql +2 -0
- package/prisma/schema.prisma +69 -0
- package/bin/chunk-0ark0qrm.js +0 -1
- package/bin/chunk-21h9kgp5.js +0 -1
- package/bin/chunk-2errtbmb.js +0 -2
- package/bin/chunk-2pxev94x.js +0 -2
- package/bin/chunk-61hfhfce.js +0 -2
- package/bin/chunk-7e39zmss.js +0 -1
- package/bin/chunk-7h1m1e0b.js +0 -1
- package/bin/chunk-8btfb5g6.js +0 -2
- package/bin/chunk-bn1sts8x.js +0 -3
- package/bin/chunk-cwh21vfb.js +0 -2
- package/bin/chunk-dtjx1097.js +0 -2
- package/bin/chunk-e32bzfza.js +0 -1
- package/bin/chunk-ersxsrz8.js +0 -62
- package/bin/chunk-gnx9g8px.js +0 -2
- package/bin/chunk-htrzgs2a.css +0 -1
- package/bin/chunk-j2jdrmaa.js +0 -2
- package/bin/chunk-k41vt2gq.js +0 -1
- package/bin/chunk-krpr6g8a.js +0 -1
- package/bin/chunk-mfmcsdd7.js +0 -1
- package/bin/chunk-msjv1ykh.js +0 -2
- package/bin/chunk-n73dbqps.js +0 -1
- package/bin/chunk-nn5qpr0q.js +0 -1
- package/bin/chunk-q7v8sj72.js +0 -1
- package/bin/chunk-twhj7h73.js +0 -1
- package/bin/chunk-yn7mxpmb.js +0 -7
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
function q(k){let b=3735928559,d=1103547991;for(let f=0;f<k.length;f++){let l=k.charCodeAt(f);b=Math.imul(b^l,2654435761),d=Math.imul(d^l,1597334677)}return b=Math.imul(b^b>>>16,2246822507)^Math.imul(d^d>>>13,3266489909),d=Math.imul(d^d>>>16,2246822507)^Math.imul(b^b>>>13,3266489909),(d>>>0).toString(36)+(b>>>0).toString(36)}
|
|
3
|
-
export{q as
|
|
3
|
+
export{q as Tk};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as g}from"./chunk-thj4cpev.js";import"./chunk-e5s7202g.js";import"./chunk-tqxmj05h.js";import"./chunk-4ajat3xv.js";import"./chunk-mhj0pqq3.js";import"./chunk-3htn4m2d.js";import"./chunk-76hs7g0x.js";import"./chunk-0sajh8fw.js";import"./chunk-j1awxx51.js";import"./chunk-ym47952x.js";import"./chunk-nhc72y4x.js";import"./chunk-vw1rhgjs.js";import"./chunk-ef5v7gta.js";import"./chunk-gct52xks.js";import"./chunk-55myfmhy.js";import"./chunk-mmrtjcst.js";import"./chunk-ce50f746.js";import"./chunk-d2qp8g98.js";import{Of as x}from"./chunk-89kqtj7x.js";import{Qf as f}from"./chunk-9hsfjqgq.js";import"./chunk-nh8azwsx.js";import"./chunk-mxee09jk.js";import"./chunk-bq2aq6v8.js";import"./chunk-0jr6q4j4.js";import"./chunk-7b60a9sy.js";import"./chunk-f44d9fpd.js";import"./chunk-4a9sdfyp.js";import"./chunk-n198tewr.js";import"./chunk-ghz19a7t.js";import"./chunk-7fm1hznx.js";import"./chunk-6edadcpn.js";import{rh as p}from"./chunk-w98wvk17.js";import{$h as h,Ch as r,Dh as o,Ph as c,vh as v,xh as a}from"./chunk-jt4yh37q.js";import{Il as w}from"./chunk-mgbqjbfc.js";var b=w(v(),1);function d(){let{projectId:e}=y.useParams(),{teamId:s,ensureTeamIdForProject:n}=p();b.useEffect(()=>{n(e)},[e,n]);let{data:i}=o(x(e)),t=i?.rootFolder,{data:m}=r({queryKey:["folders",t],queryFn:async()=>{let l=await h.api.folders[":folderId"].$get({param:{folderId:t}});if(!l.ok)throw Error("failed to fetch folder");return await l.json()},enabled:!!t});if(!s||!t||!m)return a(f,{});return a(g,{teamId:s,projectId:e,projectName:i.name??"",assetId:t,rootFolderId:t})}var y=c("/projects/$projectId/")({component:d});export{y as Route};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-xg9xscqz.js";import{
|
|
2
|
+
import"./chunk-xg9xscqz.js";import{Dc as w,lc as I}from"./chunk-dfzmqx1v.js";import"./chunk-g70eyttc.js";import"./chunk-mgbqjbfc.js";function R(q,$){if(typeof q==="string"&&typeof $==="string")return q.toLowerCase()===$.toLowerCase();return q===$}function y(q,$){if(typeof q!=="string")return $.includes(q);return $.some((E)=>typeof E==="string"&&q.toLowerCase()===E.toLowerCase())}function j(q,$){return!y(q,$)}function g(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().includes($.toLowerCase())}function f(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().startsWith($.toLowerCase())}function V(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().endsWith($.toLowerCase())}var v=(q,$)=>{let E=null,M=w({config:{adapterId:"memory",adapterName:"Memory Adapter",usePlural:!1,debugLogs:$?.debugLogs||!1,supportsArrays:!0,customTransformInput(P){if(P.options.advanced?.database?.generateId==="serial"&&P.field==="id"&&P.action==="create")return q[P.model].length+1;return P.data},transaction:async(P)=>{let A=structuredClone(q);try{return await P(M(E))}catch(_){throw Object.keys(q).forEach((S)=>{q[S]=A[S]}),_}}},adapter:({getFieldName:P,getDefaultFieldName:A,options:_,getModelName:S})=>{let N=(x,K,Y)=>{if(!K)return x;return x.sort((L,Z)=>{let z=P({model:Y,field:K.field}),D=L[z],X=Z[z],Q=0;if(D==null&&X==null)Q=0;else if(D==null)Q=-1;else if(X==null)Q=1;else if(typeof D==="string"&&typeof X==="string")Q=D.localeCompare(X);else if(D instanceof Date&&X instanceof Date)Q=D.getTime()-X.getTime();else if(typeof D==="number"&&typeof X==="number")Q=D-X;else if(typeof D==="boolean"&&typeof X==="boolean")Q=D===X?0:D?1:-1;else Q=String(D).localeCompare(String(X));return K.direction==="asc"?Q:-Q})};function F(x,K,Y,L){let Z=(()=>{let X=q[K];if(!X)throw I.error(`[MemoryAdapter] Model ${K} not found in the DB`,Object.keys(q)),Error(`Model ${K} not found`);let Q=(G,O)=>{let{field:J,value:H,operator:B,mode:k="sensitive"}=O,U=k==="insensitive"&&(typeof H==="string"||Array.isArray(H)&&H.every((W)=>typeof W==="string"));switch(B){case"in":if(!Array.isArray(H))throw Error("Value must be an array");if(U)return y(G[J],H);return H.includes(G[J]);case"not_in":if(!Array.isArray(H))throw Error("Value must be an array");if(U)return j(G[J],H);return!H.includes(G[J]);case"contains":if(U)return g(G[J],H);return G[J]?.includes(H);case"starts_with":if(U)return f(G[J],H);return G[J].startsWith(H);case"ends_with":if(U)return V(G[J],H);return G[J].endsWith(H);case"ne":return U?!R(G[J],H):G[J]!==H;case"gt":return H!=null&&Boolean(G[J]>H);case"gte":return H!=null&&Boolean(G[J]>=H);case"lt":return H!=null&&Boolean(G[J]<H);case"lte":return H!=null&&Boolean(G[J]<=H);default:if(U)return R(G[J],H);if(H===null)return G[J]==null;return G[J]===H}},T=X.filter((G)=>{if(!x.length||x.length===0)return!0;let O=Q(G,x[0]);for(let J of x){let H=Q(G,J);if(J.connector==="OR")O=O||H;else O=O&&H}return O});if(L?.length&&L.length>0)T=T.map((G)=>Object.fromEntries(Object.entries(G).filter(([O])=>L.includes(A({model:K,field:O})))));return T})();if(!Y)return Z;let z=new Map,D=new Map;for(let X of Z){let Q=String(X.id);if(!z.has(Q)){let G={...X};for(let[O,J]of Object.entries(Y)){let H=S(O);if(J.relation==="one-to-one")G[H]=null;else G[H]=[],D.set(`${Q}-${O}`,new Set)}z.set(Q,G)}let T=z.get(Q);for(let[G,O]of Object.entries(Y)){let J=S(G),H=q[J];if(!H)throw I.error(`[MemoryAdapter] JoinOption model ${J} not found in the DB`,Object.keys(q)),Error(`JoinOption model ${J} not found`);let B=H.filter((k)=>k[O.on.to]===X[O.on.from]);if(O.relation==="one-to-one")T[J]=B[0]||null;else{let k=D.get(`${Q}-${G}`),U=O.limit??100,W=0;for(let C of B){if(W>=U)break;if(!k.has(C.id))T[J].push(C),k.add(C.id),W++}}}}return Array.from(z.values())}return{create:async({model:x,data:K})=>{if(_.advanced?.database?.generateId==="serial")K.id=q[S(x)].length+1;if(!q[x])q[x]=[];return q[x].push(K),K},findOne:async({model:x,where:K,select:Y,join:L})=>{let Z=F(K,x,L,Y);if(L){let z=Z;if(!z.length)return null;return z[0]}return Z[0]||null},findMany:async({model:x,where:K,sortBy:Y,limit:L,select:Z,offset:z,join:D})=>{let X=F(K||[],x,D,Z);if(D){let T=X;if(!T.length)return[];N(T,Y,x);let G=T;if(z!==void 0)G=G.slice(z);if(L!==void 0)G=G.slice(0,L);return G}let Q=N(X,Y,x);if(z!==void 0)Q=Q.slice(z);if(L!==void 0)Q=Q.slice(0,L);return Q||[]},count:async({model:x,where:K})=>{if(K)return F(K,x).length;return q[x].length},update:async({model:x,where:K,update:Y})=>{let L=F(K,x);return L.forEach((Z)=>{Object.assign(Z,Y)}),L[0]||null},delete:async({model:x,where:K})=>{let Y=q[x],L=F(K,x);q[x]=Y.filter((Z)=>!L.includes(Z))},deleteMany:async({model:x,where:K})=>{let Y=q[x],L=F(K,x),Z=0;return q[x]=Y.filter((z)=>{if(L.includes(z))return Z++,!1;return!L.includes(z)}),Z},consumeOne:async({model:x,where:K})=>{let Y=q[x],L=F(K,x)[0];if(!L)return null;return q[x]=Y.filter((Z)=>Z!==L),L},updateMany({model:x,where:K,update:Y}){let L=F(K,x);return L.forEach((Z)=>{Object.assign(Z,Y)}),L[0]||null}}}});return(P)=>{return E=P,M(P)}};export{v as memoryAdapter};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{B as
|
|
1
|
+
import{Qf as A}from"./chunk-9hsfjqgq.js";import{$h as z,Oh as w,xh as v}from"./chunk-jt4yh37q.js";var B=(b)=>({queryKey:["projects",b],queryFn:async()=>{let h=await z.api.projects[":projectId"].$get({param:{projectId:b}});if(!h.ok)throw Error("Failed to fetch project");return await h.json()}}),H=w("/projects/$projectId/shares/$shareId")({loader:({context:{queryClient:b},params:{projectId:h}})=>b.ensureQueryData(B(h)),pendingComponent:()=>v(A,{})});
|
|
2
|
+
export{B as Ff,H as Gf};
|
|
@@ -21,4 +21,4 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
21
21
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
22
22
|
|
|
23
23
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
24
|
-
`);this.baseURL=z.baseURL,this.timeout=z.timeout??x2.DEFAULT_TIMEOUT,this.logger=z.logger??console;let N="warn";this.logLevel=N,this.logLevel=Z2(z.logLevel,"ClientOptions.logLevel",this)??Z2(a("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??N,this.fetchOptions=z.fetchOptions,this.maxRetries=z.maxRetries??2,this.fetch=z.fetch??b2(),E(this,m0,g2,"f"),this._options=z,this.apiKey=typeof Z==="string"?Z:"Missing Key",this.organization=Y,this.project=$,this.webhookSecret=G}withOptions(X){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...X})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:X,nulls:Z}){return}async authHeaders(X){return V([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(X){return n2(X)}getUserAgent(){return`${this.constructor.name}/JS ${NX}`}defaultIdempotencyKey(){return`stainless-node-retry-${u0()}`}makeStatusError(X,Z,Y,$){return f.generate(X,Z,Y,$)}async _callApiKey(){let X=this._options.apiKey;if(typeof X!=="function")return!1;let Z;try{Z=await X()}catch(Y){if(Y instanceof U)throw Y;throw new U(`Failed to get token from 'apiKey' function: ${Y.message}`,{cause:Y})}if(typeof Z!=="string"||!Z)throw new U(`Expected 'apiKey' function argument to return a string but it returned ${Z}`);return this.apiKey=Z,!0}buildURL(X,Z,Y){let $=!K(this,O2,"m",y3).call(this)&&Y||this.baseURL,G=C2(X)?new URL(X):new URL($+($.endsWith("/")&&X.startsWith("/")?X.slice(1):X)),W=this.defaultQuery();if(!D2(W))Z={...W,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))G.search=this.stringifyQuery(Z);return G.toString()}async prepareOptions(X){await this._callApiKey()}async prepareRequest(X,{url:Z,options:Y}){}get(X,Z){return this.methodRequest("get",X,Z)}post(X,Z){return this.methodRequest("post",X,Z)}patch(X,Z){return this.methodRequest("patch",X,Z)}put(X,Z){return this.methodRequest("put",X,Z)}delete(X,Z){return this.methodRequest("delete",X,Z)}methodRequest(X,Z,Y){return this.request(Promise.resolve(Y).then(($)=>{return{method:X,path:Z,...$}}))}request(X,Z=null){return new xX(this,this.makeRequest(X,Z,void 0))}async makeRequest(X,Z,Y){let $=await X,G=$.maxRetries??this.maxRetries;if(Z==null)Z=G;await this.prepareOptions($);let{req:W,url:z,timeout:N}=await this.buildRequest($,{retryCount:G-Z});await this.prepareRequest(W,{url:z,options:$});let w="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),F=Y===void 0?"":`, retryOf: ${Y}`,M=Date.now();if(S(this).debug(`[${w}] sending request`,GX({retryOfRequestLogID:Y,method:$.method,url:z,options:$,headers:W.headers})),$.signal?.aborted)throw new I;let H=new AbortController,B=await this.fetchWithTimeout(z,W,N,H).catch(wZ),q=Date.now();if(B instanceof globalThis.Error){let C=`retrying, ${Z} attempts remaining`;if($.signal?.aborted)throw new I;let P=VZ(B)||/timed? ?out/i.test(String(B)+("cause"in B?String(B.cause):""));if(Z)return S(this).info(`[${w}] connection ${P?"timed out":"failed"} - ${C}`),S(this).debug(`[${w}] connection ${P?"timed out":"failed"} (${C})`,GX({retryOfRequestLogID:Y,url:z,durationMs:q-M,message:B.message})),this.retryRequest($,Z,Y??w);if(S(this).info(`[${w}] connection ${P?"timed out":"failed"} - error; no more retries left`),S(this).debug(`[${w}] connection ${P?"timed out":"failed"} (error; no more retries left)`,GX({retryOfRequestLogID:Y,url:z,durationMs:q-M,message:B.message})),P)throw new OX;throw new LX({cause:B})}let T=[...B.headers.entries()].filter(([C])=>C==="x-request-id").map(([C,P])=>", "+C+": "+JSON.stringify(P)).join(""),D=`[${w}${F}${T}] ${W.method} ${z} ${B.ok?"succeeded":"failed"} with status ${B.status} in ${q-M}ms`;if(!B.ok){let C=await this.shouldRetry(B);if(Z&&C){let j=`retrying, ${Z} attempts remaining`;return await v2(B.body),S(this).info(`${D} - ${j}`),S(this).debug(`[${w}] response error (${j})`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,durationMs:q-M})),this.retryRequest($,Z,Y??w,B.headers)}let P=C?"error; no more retries left":"error; not retryable";S(this).info(`${D} - ${P}`);let x=await B.text().catch((j)=>wZ(j).message),_=S2(x),R=_?void 0:x;throw S(this).debug(`[${w}] response error (${P})`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,message:R,durationMs:Date.now()-M})),this.makeStatusError(B.status,_,R,B.headers)}return S(this).info(D),S(this).debug(`[${w}] response start`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,durationMs:q-M})),{response:B,options:$,controller:H,requestLogID:w,retryOfRequestLogID:Y,startTime:M}}getAPIList(X,Z,Y){return this.requestAPIList(Z,Y&&"then"in Y?Y.then(($)=>({method:"get",path:X,...$})):{method:"get",path:X,...Y})}requestAPIList(X,Z){let Y=this.makeRequest(Z,null,void 0);return new q0(this,Y,X)}async fetchWithTimeout(X,Z,Y,$){let{signal:G,method:W,...z}=Z||{},N=this._makeAbort($);if(G)G.addEventListener("abort",N,{once:!0});let w=setTimeout(N,Y),F=globalThis.ReadableStream&&z.body instanceof globalThis.ReadableStream||typeof z.body==="object"&&z.body!==null&&Symbol.asyncIterator in z.body,M={signal:$.signal,...F?{duplex:"half"}:{},method:"GET",...z};if(W)M.method=W.toUpperCase();try{return await this.fetch.call(void 0,X,M)}finally{clearTimeout(w)}}async shouldRetry(X){let Z=X.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if(X.status===408)return!0;if(X.status===409)return!0;if(X.status===429)return!0;if(X.status>=500)return!0;return!1}async retryRequest(X,Z,Y,$){let G,W=$?.get("retry-after-ms");if(W){let N=parseFloat(W);if(!Number.isNaN(N))G=N}let z=$?.get("retry-after");if(z&&!G){let N=parseFloat(z);if(!Number.isNaN(N))G=N*1000;else G=Date.parse(z)-Date.now()}if(G===void 0){let N=X.maxRetries??this.maxRetries;G=this.calculateDefaultRetryTimeoutMillis(Z,N)}return await s(G),this.makeRequest(X,Z-1,Y)}calculateDefaultRetryTimeoutMillis(X,Z){let G=Z-X,W=Math.min(0.5*Math.pow(2,G),8),z=1-Math.random()*0.25;return W*z*1000}async buildRequest(X,{retryCount:Z=0}={}){let Y={...X},{method:$,path:G,query:W,defaultBaseURL:z}=Y,N=this.buildURL(G,W,z);if("timeout"in Y)R2("timeout",Y.timeout);Y.timeout=Y.timeout??this.timeout;let{bodyHeaders:w,body:F}=this.buildBody({options:Y}),M=await this.buildHeaders({options:X,method:$,bodyHeaders:w,retryCount:Z});return{req:{method:$,headers:M,...Y.signal&&{signal:Y.signal},...globalThis.ReadableStream&&F instanceof globalThis.ReadableStream&&{duplex:"half"},...F&&{body:F},...this.fetchOptions??{},...Y.fetchOptions??{}},url:N,timeout:Y.timeout}}async buildHeaders({options:X,method:Z,bodyHeaders:Y,retryCount:$}){let G={};if(this.idempotencyHeader&&Z!=="get"){if(!X.idempotencyKey)X.idempotencyKey=this.defaultIdempotencyKey();G[this.idempotencyHeader]=X.idempotencyKey}let W=V([G,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String($),...X.timeout?{"X-Stainless-Timeout":String(Math.trunc(X.timeout/1000))}:{},...y2(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(X),this._options.defaultHeaders,Y,X.headers]);return this.validateHeaders(W),W.values}_makeAbort(X){return()=>X.abort()}buildBody({options:{body:X,headers:Z}}){if(!X)return{bodyHeaders:void 0,body:void 0};let Y=V([Z]);if(ArrayBuffer.isView(X)||X instanceof ArrayBuffer||X instanceof DataView||typeof X==="string"&&Y.values.has("content-type")||globalThis.Blob&&X instanceof globalThis.Blob||X instanceof FormData||X instanceof URLSearchParams||globalThis.ReadableStream&&X instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:X};else if(typeof X==="object"&&((Symbol.asyncIterator in X)||(Symbol.iterator in X)&&("next"in X)&&typeof X.next==="function"))return{bodyHeaders:void 0,body:w0(X)};else if(typeof X==="object"&&Y.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(X)};else return K(this,m0,"f").call(this,{body:X,headers:Y})}}x2=L,m0=new WeakMap,O2=new WeakSet,y3=function(){return this.baseURL!=="https://api.openai.com/v1"};L.OpenAI=x2;L.DEFAULT_TIMEOUT=600000;L.OpenAIError=U;L.APIError=f;L.APIConnectionError=LX;L.APIConnectionTimeoutError=OX;L.APIUserAbortError=I;L.NotFoundError=TZ;L.ConflictError=MZ;L.RateLimitError=qZ;L.BadRequestError=HZ;L.AuthenticationError=UZ;L.InternalServerError=LZ;L.PermissionDeniedError=FZ;L.UnprocessableEntityError=EZ;L.InvalidWebhookSignatureError=$X;L.toFile=O0;L.Completions=sX;L.Chat=CX;L.Embeddings=oX;L.Files=XZ;L.Images=GZ;L.Audio=QX;L.Moderations=KZ;L.Models=WZ;L.FineTuning=ZX;L.Graders=bX;L.VectorStores=qX;L.Webhooks=NZ;L.Beta=XX;L.Batches=nX;L.Uploads=vX;L.Responses=MX;L.Realtime=FX;L.Conversations=IX;L.Evals=yX;L.Containers=jX;L.Skills=EX;L.Videos=QZ;class b3 extends L{constructor({baseURL:X=a("OPENAI_BASE_URL"),apiKey:Z=a("AZURE_OPENAI_API_KEY"),apiVersion:Y=a("OPENAI_API_VERSION"),endpoint:$,deployment:G,azureADTokenProvider:W,dangerouslyAllowBrowser:z,...N}={}){if(!Y)throw new U("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");if(typeof W==="function")z=!0;if(!W&&!Z)throw new U("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(W&&Z)throw new U("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(N.defaultQuery={...N.defaultQuery,"api-version":Y},!X){if(!$)$=process.env.AZURE_OPENAI_ENDPOINT;if(!$)throw new U("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");X=`${$}/openai`}else if($)throw new U("baseURL and endpoint are mutually exclusive");super({apiKey:W??Z,baseURL:X,...N,...z!==void 0?{dangerouslyAllowBrowser:z}:{}});this.apiVersion="",this.apiVersion=Y,this.deploymentName=G}async buildRequest(X,Z={}){if(J8.has(X.path)&&X.method==="post"&&X.body!==void 0){if(!gX(X.body))throw Error("Expected request body to be an object");let Y=this.deploymentName||X.body.model||X.__metadata?.model;if(Y!==void 0&&!this.baseURL.includes("/deployments"))X.path=`/deployments/${Y}${X.path}`}return super.buildRequest(X,Z)}async authHeaders(X){if(typeof this._options.apiKey==="string")return V([{"api-key":this.apiKey}]);return super.authHeaders(X)}}var J8=new Set(["/completions","/chat/completions","/embeddings","/audio/transcriptions","/audio/translations","/audio/speech","/images/generations","/batches","/images/edits"]);export{L as Vj,b3 as Wj};
|
|
24
|
+
`);this.baseURL=z.baseURL,this.timeout=z.timeout??x2.DEFAULT_TIMEOUT,this.logger=z.logger??console;let N="warn";this.logLevel=N,this.logLevel=Z2(z.logLevel,"ClientOptions.logLevel",this)??Z2(a("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??N,this.fetchOptions=z.fetchOptions,this.maxRetries=z.maxRetries??2,this.fetch=z.fetch??b2(),E(this,m0,g2,"f"),this._options=z,this.apiKey=typeof Z==="string"?Z:"Missing Key",this.organization=Y,this.project=$,this.webhookSecret=G}withOptions(X){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...X})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:X,nulls:Z}){return}async authHeaders(X){return V([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(X){return n2(X)}getUserAgent(){return`${this.constructor.name}/JS ${NX}`}defaultIdempotencyKey(){return`stainless-node-retry-${u0()}`}makeStatusError(X,Z,Y,$){return f.generate(X,Z,Y,$)}async _callApiKey(){let X=this._options.apiKey;if(typeof X!=="function")return!1;let Z;try{Z=await X()}catch(Y){if(Y instanceof U)throw Y;throw new U(`Failed to get token from 'apiKey' function: ${Y.message}`,{cause:Y})}if(typeof Z!=="string"||!Z)throw new U(`Expected 'apiKey' function argument to return a string but it returned ${Z}`);return this.apiKey=Z,!0}buildURL(X,Z,Y){let $=!K(this,O2,"m",y3).call(this)&&Y||this.baseURL,G=C2(X)?new URL(X):new URL($+($.endsWith("/")&&X.startsWith("/")?X.slice(1):X)),W=this.defaultQuery();if(!D2(W))Z={...W,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))G.search=this.stringifyQuery(Z);return G.toString()}async prepareOptions(X){await this._callApiKey()}async prepareRequest(X,{url:Z,options:Y}){}get(X,Z){return this.methodRequest("get",X,Z)}post(X,Z){return this.methodRequest("post",X,Z)}patch(X,Z){return this.methodRequest("patch",X,Z)}put(X,Z){return this.methodRequest("put",X,Z)}delete(X,Z){return this.methodRequest("delete",X,Z)}methodRequest(X,Z,Y){return this.request(Promise.resolve(Y).then(($)=>{return{method:X,path:Z,...$}}))}request(X,Z=null){return new xX(this,this.makeRequest(X,Z,void 0))}async makeRequest(X,Z,Y){let $=await X,G=$.maxRetries??this.maxRetries;if(Z==null)Z=G;await this.prepareOptions($);let{req:W,url:z,timeout:N}=await this.buildRequest($,{retryCount:G-Z});await this.prepareRequest(W,{url:z,options:$});let w="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),F=Y===void 0?"":`, retryOf: ${Y}`,M=Date.now();if(S(this).debug(`[${w}] sending request`,GX({retryOfRequestLogID:Y,method:$.method,url:z,options:$,headers:W.headers})),$.signal?.aborted)throw new I;let H=new AbortController,B=await this.fetchWithTimeout(z,W,N,H).catch(wZ),q=Date.now();if(B instanceof globalThis.Error){let C=`retrying, ${Z} attempts remaining`;if($.signal?.aborted)throw new I;let P=VZ(B)||/timed? ?out/i.test(String(B)+("cause"in B?String(B.cause):""));if(Z)return S(this).info(`[${w}] connection ${P?"timed out":"failed"} - ${C}`),S(this).debug(`[${w}] connection ${P?"timed out":"failed"} (${C})`,GX({retryOfRequestLogID:Y,url:z,durationMs:q-M,message:B.message})),this.retryRequest($,Z,Y??w);if(S(this).info(`[${w}] connection ${P?"timed out":"failed"} - error; no more retries left`),S(this).debug(`[${w}] connection ${P?"timed out":"failed"} (error; no more retries left)`,GX({retryOfRequestLogID:Y,url:z,durationMs:q-M,message:B.message})),P)throw new OX;throw new LX({cause:B})}let T=[...B.headers.entries()].filter(([C])=>C==="x-request-id").map(([C,P])=>", "+C+": "+JSON.stringify(P)).join(""),D=`[${w}${F}${T}] ${W.method} ${z} ${B.ok?"succeeded":"failed"} with status ${B.status} in ${q-M}ms`;if(!B.ok){let C=await this.shouldRetry(B);if(Z&&C){let j=`retrying, ${Z} attempts remaining`;return await v2(B.body),S(this).info(`${D} - ${j}`),S(this).debug(`[${w}] response error (${j})`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,durationMs:q-M})),this.retryRequest($,Z,Y??w,B.headers)}let P=C?"error; no more retries left":"error; not retryable";S(this).info(`${D} - ${P}`);let x=await B.text().catch((j)=>wZ(j).message),_=S2(x),R=_?void 0:x;throw S(this).debug(`[${w}] response error (${P})`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,message:R,durationMs:Date.now()-M})),this.makeStatusError(B.status,_,R,B.headers)}return S(this).info(D),S(this).debug(`[${w}] response start`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,durationMs:q-M})),{response:B,options:$,controller:H,requestLogID:w,retryOfRequestLogID:Y,startTime:M}}getAPIList(X,Z,Y){return this.requestAPIList(Z,Y&&"then"in Y?Y.then(($)=>({method:"get",path:X,...$})):{method:"get",path:X,...Y})}requestAPIList(X,Z){let Y=this.makeRequest(Z,null,void 0);return new q0(this,Y,X)}async fetchWithTimeout(X,Z,Y,$){let{signal:G,method:W,...z}=Z||{},N=this._makeAbort($);if(G)G.addEventListener("abort",N,{once:!0});let w=setTimeout(N,Y),F=globalThis.ReadableStream&&z.body instanceof globalThis.ReadableStream||typeof z.body==="object"&&z.body!==null&&Symbol.asyncIterator in z.body,M={signal:$.signal,...F?{duplex:"half"}:{},method:"GET",...z};if(W)M.method=W.toUpperCase();try{return await this.fetch.call(void 0,X,M)}finally{clearTimeout(w)}}async shouldRetry(X){let Z=X.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if(X.status===408)return!0;if(X.status===409)return!0;if(X.status===429)return!0;if(X.status>=500)return!0;return!1}async retryRequest(X,Z,Y,$){let G,W=$?.get("retry-after-ms");if(W){let N=parseFloat(W);if(!Number.isNaN(N))G=N}let z=$?.get("retry-after");if(z&&!G){let N=parseFloat(z);if(!Number.isNaN(N))G=N*1000;else G=Date.parse(z)-Date.now()}if(G===void 0){let N=X.maxRetries??this.maxRetries;G=this.calculateDefaultRetryTimeoutMillis(Z,N)}return await s(G),this.makeRequest(X,Z-1,Y)}calculateDefaultRetryTimeoutMillis(X,Z){let G=Z-X,W=Math.min(0.5*Math.pow(2,G),8),z=1-Math.random()*0.25;return W*z*1000}async buildRequest(X,{retryCount:Z=0}={}){let Y={...X},{method:$,path:G,query:W,defaultBaseURL:z}=Y,N=this.buildURL(G,W,z);if("timeout"in Y)R2("timeout",Y.timeout);Y.timeout=Y.timeout??this.timeout;let{bodyHeaders:w,body:F}=this.buildBody({options:Y}),M=await this.buildHeaders({options:X,method:$,bodyHeaders:w,retryCount:Z});return{req:{method:$,headers:M,...Y.signal&&{signal:Y.signal},...globalThis.ReadableStream&&F instanceof globalThis.ReadableStream&&{duplex:"half"},...F&&{body:F},...this.fetchOptions??{},...Y.fetchOptions??{}},url:N,timeout:Y.timeout}}async buildHeaders({options:X,method:Z,bodyHeaders:Y,retryCount:$}){let G={};if(this.idempotencyHeader&&Z!=="get"){if(!X.idempotencyKey)X.idempotencyKey=this.defaultIdempotencyKey();G[this.idempotencyHeader]=X.idempotencyKey}let W=V([G,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String($),...X.timeout?{"X-Stainless-Timeout":String(Math.trunc(X.timeout/1000))}:{},...y2(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(X),this._options.defaultHeaders,Y,X.headers]);return this.validateHeaders(W),W.values}_makeAbort(X){return()=>X.abort()}buildBody({options:{body:X,headers:Z}}){if(!X)return{bodyHeaders:void 0,body:void 0};let Y=V([Z]);if(ArrayBuffer.isView(X)||X instanceof ArrayBuffer||X instanceof DataView||typeof X==="string"&&Y.values.has("content-type")||globalThis.Blob&&X instanceof globalThis.Blob||X instanceof FormData||X instanceof URLSearchParams||globalThis.ReadableStream&&X instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:X};else if(typeof X==="object"&&((Symbol.asyncIterator in X)||(Symbol.iterator in X)&&("next"in X)&&typeof X.next==="function"))return{bodyHeaders:void 0,body:w0(X)};else if(typeof X==="object"&&Y.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(X)};else return K(this,m0,"f").call(this,{body:X,headers:Y})}}x2=L,m0=new WeakMap,O2=new WeakSet,y3=function(){return this.baseURL!=="https://api.openai.com/v1"};L.OpenAI=x2;L.DEFAULT_TIMEOUT=600000;L.OpenAIError=U;L.APIError=f;L.APIConnectionError=LX;L.APIConnectionTimeoutError=OX;L.APIUserAbortError=I;L.NotFoundError=TZ;L.ConflictError=MZ;L.RateLimitError=qZ;L.BadRequestError=HZ;L.AuthenticationError=UZ;L.InternalServerError=LZ;L.PermissionDeniedError=FZ;L.UnprocessableEntityError=EZ;L.InvalidWebhookSignatureError=$X;L.toFile=O0;L.Completions=sX;L.Chat=CX;L.Embeddings=oX;L.Files=XZ;L.Images=GZ;L.Audio=QX;L.Moderations=KZ;L.Models=WZ;L.FineTuning=ZX;L.Graders=bX;L.VectorStores=qX;L.Webhooks=NZ;L.Beta=XX;L.Batches=nX;L.Uploads=vX;L.Responses=MX;L.Realtime=FX;L.Conversations=IX;L.Evals=yX;L.Containers=jX;L.Skills=EX;L.Videos=QZ;class b3 extends L{constructor({baseURL:X=a("OPENAI_BASE_URL"),apiKey:Z=a("AZURE_OPENAI_API_KEY"),apiVersion:Y=a("OPENAI_API_VERSION"),endpoint:$,deployment:G,azureADTokenProvider:W,dangerouslyAllowBrowser:z,...N}={}){if(!Y)throw new U("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");if(typeof W==="function")z=!0;if(!W&&!Z)throw new U("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(W&&Z)throw new U("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(N.defaultQuery={...N.defaultQuery,"api-version":Y},!X){if(!$)$=process.env.AZURE_OPENAI_ENDPOINT;if(!$)throw new U("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");X=`${$}/openai`}else if($)throw new U("baseURL and endpoint are mutually exclusive");super({apiKey:W??Z,baseURL:X,...N,...z!==void 0?{dangerouslyAllowBrowser:z}:{}});this.apiVersion="",this.apiVersion=Y,this.deploymentName=G}async buildRequest(X,Z={}){if(J8.has(X.path)&&X.method==="post"&&X.body!==void 0){if(!gX(X.body))throw Error("Expected request body to be an object");let Y=this.deploymentName||X.body.model||X.__metadata?.model;if(Y!==void 0&&!this.baseURL.includes("/deployments"))X.path=`/deployments/${Y}${X.path}`}return super.buildRequest(X,Z)}async authHeaders(X){if(typeof this._options.apiKey==="string")return V([{"api-key":this.apiKey}]);return super.authHeaders(X)}}var J8=new Set(["/completions","/chat/completions","/embeddings","/audio/transcriptions","/audio/translations","/audio/speech","/images/generations","/batches","/images/edits"]);export{L as Uk,b3 as Vk};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as y}from"./chunk-thj4cpev.js";import"./chunk-e5s7202g.js";import"./chunk-tqxmj05h.js";import"./chunk-4ajat3xv.js";import"./chunk-mhj0pqq3.js";import"./chunk-3htn4m2d.js";import"./chunk-76hs7g0x.js";import"./chunk-0sajh8fw.js";import"./chunk-j1awxx51.js";import"./chunk-ym47952x.js";import"./chunk-nhc72y4x.js";import"./chunk-vw1rhgjs.js";import"./chunk-ef5v7gta.js";import"./chunk-gct52xks.js";import"./chunk-55myfmhy.js";import"./chunk-mmrtjcst.js";import"./chunk-ce50f746.js";import"./chunk-d2qp8g98.js";import{wf as v,xf as m}from"./chunk-fwbrcfaq.js";import"./chunk-nh8azwsx.js";import"./chunk-mxee09jk.js";import"./chunk-bq2aq6v8.js";import"./chunk-0jr6q4j4.js";import"./chunk-7b60a9sy.js";import"./chunk-f44d9fpd.js";import"./chunk-4a9sdfyp.js";import"./chunk-n198tewr.js";import"./chunk-ghz19a7t.js";import"./chunk-7fm1hznx.js";import"./chunk-6edadcpn.js";import{rh as w}from"./chunk-w98wvk17.js";import{$h as r,Ch as i,Dh as f,Eh as x,Ek as g,Ph as b,vh as q,xh as n}from"./chunk-jt4yh37q.js";import{Il as W}from"./chunk-mgbqjbfc.js";var d=W(q(),1);function A(){let{projectId:e,collectionId:l}=K.useParams(),{teamId:o,ensureTeamIdForProject:h}=w();d.useEffect(()=>{h(e)},[e,h]);let{data:p}=f(v(e)),{data:s,refetch:z}=i({...m(l)}),{mutate:k}=x({mutationFn:async(a)=>{let c=await r.api.collections[":collectionId"].$patch({param:{collectionId:l},json:a});if(!c.ok)throw Error("Failed to update collection");return await c.json()},onSuccess:()=>{z()}}),t=p?.rootFolder,{data:u}=i({queryKey:["folders",t],queryFn:async()=>{let a=await r.api.folders[":folderId"].$get({param:{folderId:t}});if(!a.ok)throw Error("Failed to fetch folder");return await a.json()},enabled:!!t});if(!o||!t||!u||!s)return n("div",{children:g.loading_collection()});let C=s.filter.sourceFolderId||t;return n(y,{teamId:o,projectId:e,projectName:p.name??"",assetId:C,rootFolderId:t,collection:s,onUpdateCollection:k})}var K=b("/projects/$projectId/collections/$collectionId")({component:A});export{K as Route};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{l as
|
|
1
|
+
import{wk as o,xh as a}from"./chunk-jt4yh37q.js";function l({className:t,...e}){return a("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:a("table",{"data-slot":"table",className:o("w-full caption-bottom text-sm",t),...e})})}function n({className:t,...e}){return a("thead",{"data-slot":"table-header",className:o("[&_tr]:border-b",t),...e})}function c({className:t,...e}){return a("tbody",{"data-slot":"table-body",className:o("[&_tr:last-child]:border-0",t),...e})}function d({className:t,...e}){return a("tr",{"data-slot":"table-row",className:o("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),...e})}function s({className:t,...e}){return a("th",{"data-slot":"table-head",className:o("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e})}function b({className:t,...e}){return a("td",{"data-slot":"table-cell",className:o("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e})}
|
|
2
|
+
export{l as c,n as d,c as e,d as f,s as g,b as h};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Mk as _1}from"./chunk-z0tbq08w.js";import{Nk as P1,Ok as f1}from"./chunk-y1t47c7f.js";import{Wk as D1}from"./chunk-kaxwma6y.js";import{Xk as B1}from"./chunk-fzaw1e34.js";import{Yk as j1,Zk as S0}from"./chunk-yzra1x8f.js";import{ol as T1,rl as I1,sl as R1,tl as k1,ul as y1}from"./chunk-29nhtrfv.js";import{vl as c}from"./chunk-800vdz5n.js";import{wl as S1}from"./chunk-f2eh802w.js";import{Cl as j0}from"./chunk-ew4cxkcc.js";import{El as A1}from"./chunk-hcvpb1hw.js";import"./chunk-mgbqjbfc.js";function U(X,Z,$,W,Y){if(W==="m")throw TypeError("Private method is not writable");if(W==="a"&&!Y)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?X!==Z||!Y:!Z.has(X))throw TypeError("Cannot write private member to an object whose class did not declare it");return W==="a"?Y.call(X,$):Y?Y.value=$:Z.set(X,$),$}function z(X,Z,$,W){if($==="a"&&!W)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?X!==Z||!W:!Z.has(X))throw TypeError("Cannot read private member from an object whose class did not declare it");return $==="m"?W:$==="a"?W.call(X):W?W.value:Z.get(X)}var pZ=function(){let{crypto:X}=globalThis;if(X?.randomUUID)return pZ=X.randomUUID.bind(X),X.randomUUID();let Z=new Uint8Array(1),$=X?()=>X.getRandomValues(Z)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(W)=>(+W^$()&15>>+W/4).toString(16))};function d(X){return typeof X==="object"&&X!==null&&(("name"in X)&&X.name==="AbortError"||("message"in X)&&String(X.message).includes("FetchRequestCanceledException"))}var xX=(X)=>{if(X instanceof Error)return X;if(typeof X==="object"&&X!==null){try{if(Object.prototype.toString.call(X)==="[object Error]"){let Z=Error(X.message,X.cause?{cause:X.cause}:{});if(X.stack)Z.stack=X.stack;if(X.cause&&!Z.cause)Z.cause=X.cause;if(X.name)Z.name=X.name;return Z}}catch{}try{return Error(JSON.stringify(X))}catch{}}return Error(X)};class C extends Error{}class A extends C{constructor(X,Z,$,W,Y){super(`${A.makeMessage(X,Z,$)}`);this.status=X,this.headers=W,this.requestID=W?.get("request-id"),this.error=Z,this.type=Y??null}static makeMessage(X,Z,$){let W=Z?.message?typeof Z.message==="string"?Z.message:JSON.stringify(Z.message):Z?JSON.stringify(Z):$;if(X&&W)return`${X} ${W}`;if(X)return`${X} status code (no body)`;if(W)return W;return"(no status code or body)"}static generate(X,Z,$,W){if(!X||!W)return new s({message:$,cause:xX(Z)});let Y=Z,J=Y?.error?.type;if(X===400)return new FX(X,Y,$,W,J);if(X===401)return new LX(X,Y,$,W,J);if(X===403)return new AX(X,Y,$,W,J);if(X===404)return new jX(X,Y,$,W,J);if(X===409)return new SX(X,Y,$,W,J);if(X===422)return new BX(X,Y,$,W,J);if(X===429)return new DX(X,Y,$,W,J);if(X>=500)return new TX(X,Y,$,W,J);return new A(X,Y,$,W,J)}}class D extends A{constructor({message:X}={}){super(void 0,void 0,X||"Request was aborted.",void 0)}}class s extends A{constructor({message:X,cause:Z}){super(void 0,void 0,X||"Connection error.",void 0);if(Z)this.cause=Z}}class HX extends s{constructor({message:X}={}){super({message:X??"Request timed out."})}}class FX extends A{}class LX extends A{}class AX extends A{}class jX extends A{}class SX extends A{}class BX extends A{}class DX extends A{}class TX extends A{}var c1=/^[a-z][a-z0-9+.-]*:/i,P0=(X)=>{return c1.test(X)},lZ=(X)=>(lZ=Array.isArray,lZ(X)),iZ=lZ;function qZ(X){if(typeof X!=="object")return{};return X??{}}function nZ(X){if(!X)return!0;for(let Z in X)return!1;return!0}function f0(X,Z){return Object.prototype.hasOwnProperty.call(X,Z)}var I0=(X,Z)=>{if(typeof Z!=="number"||!Number.isInteger(Z))throw new C(`${X} must be an integer`);if(Z<0)throw new C(`${X} must be a positive integer`);return Z};var CZ=(X)=>{try{return JSON.parse(X)}catch(Z){return}};var R0=(X)=>new Promise((Z)=>setTimeout(Z,X));var i="0.91.1";var h0=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"};function d1(){if(typeof Deno<"u"&&Deno.build!=null)return"deno";if(typeof EdgeRuntime<"u")return"edge";if(Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]")return"node";return"unknown"}var m1=()=>{let X=d1();if(X==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":i,"X-Stainless-OS":y0(Deno.build.os),"X-Stainless-Arch":k0(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":i,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(X==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":i,"X-Stainless-OS":y0(globalThis.process.platform??"unknown"),"X-Stainless-Arch":k0(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let Z=u1();if(Z)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":i,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${Z.browser}`,"X-Stainless-Runtime-Version":Z.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":i,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function u1(){if(typeof navigator>"u"||!navigator)return null;let X=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:Z,pattern:$}of X){let W=$.exec(navigator.userAgent);if(W){let Y=W[1]||0,J=W[2]||0,Q=W[3]||0;return{browser:Z,version:`${Y}.${J}.${Q}`}}}return null}var k0=(X)=>{if(X==="x32")return"x32";if(X==="x86_64"||X==="x64")return"x64";if(X==="arm")return"arm";if(X==="aarch64"||X==="arm64")return"arm64";if(X)return`other:${X}`;return"unknown"},y0=(X)=>{if(X=X.toLowerCase(),X.includes("ios"))return"iOS";if(X==="android")return"Android";if(X==="darwin")return"MacOS";if(X==="win32")return"Windows";if(X==="freebsd")return"FreeBSD";if(X==="openbsd")return"OpenBSD";if(X==="linux")return"Linux";if(X)return`Other:${X}`;return"Unknown"},_0,g0=()=>{return _0??(_0=m1())};function b0(){if(typeof fetch<"u")return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function rZ(...X){let Z=globalThis.ReadableStream;if(typeof Z>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new Z(...X)}function OZ(X){let Z=Symbol.asyncIterator in X?X[Symbol.asyncIterator]():X[Symbol.iterator]();return rZ({start(){},async pull($){let{done:W,value:Y}=await Z.next();if(W)$.close();else $.enqueue(Y)},async cancel(){await Z.return?.()}})}function PX(X){if(X[Symbol.asyncIterator])return X;let Z=X.getReader();return{async next(){try{let $=await Z.read();if($?.done)Z.releaseLock();return $}catch($){throw Z.releaseLock(),$}},async return(){let $=Z.cancel();return Z.releaseLock(),await $,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function v0(X){if(X===null||typeof X!=="object")return;if(X[Symbol.asyncIterator]){await X[Symbol.asyncIterator]().return?.();return}let Z=X.getReader(),$=Z.cancel();Z.releaseLock(),await $}var c0=({headers:X,body:Z})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(Z)}};function d0(X){return Object.entries(X).filter(([Z,$])=>typeof $<"u").map(([Z,$])=>{if(typeof $==="string"||typeof $==="number"||typeof $==="boolean")return`${encodeURIComponent(Z)}=${encodeURIComponent($)}`;if($===null)return`${encodeURIComponent(Z)}=`;throw new C(`Cannot stringify type ${typeof $}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}function p0(X){let Z=0;for(let Y of X)Z+=Y.length;let $=new Uint8Array(Z),W=0;for(let Y of X)$.set(Y,W),W+=Y.length;return $}var m0;function fX(X){let Z;return(m0??(Z=new globalThis.TextEncoder,m0=Z.encode.bind(Z)))(X)}var u0;function aZ(X){let Z;return(u0??(Z=new globalThis.TextDecoder,u0=Z.decode.bind(Z)))(X)}var f,I;class n{constructor(){f.set(this,void 0),I.set(this,void 0),U(this,f,new Uint8Array,"f"),U(this,I,null,"f")}decode(X){if(X==null)return[];let Z=X instanceof ArrayBuffer?new Uint8Array(X):typeof X==="string"?fX(X):X;U(this,f,p0([z(this,f,"f"),Z]),"f");let $=[],W;while((W=i1(z(this,f,"f"),z(this,I,"f")))!=null){if(W.carriage&&z(this,I,"f")==null){U(this,I,W.index,"f");continue}if(z(this,I,"f")!=null&&(W.index!==z(this,I,"f")+1||W.carriage)){$.push(aZ(z(this,f,"f").subarray(0,z(this,I,"f")-1))),U(this,f,z(this,f,"f").subarray(z(this,I,"f")),"f"),U(this,I,null,"f");continue}let Y=z(this,I,"f")!==null?W.preceding-1:W.preceding,J=aZ(z(this,f,"f").subarray(0,Y));$.push(J),U(this,f,z(this,f,"f").subarray(W.index),"f"),U(this,I,null,"f")}return $}flush(){if(!z(this,f,"f").length)return[];return this.decode(`
|
|
3
3
|
`)}}f=new WeakMap,I=new WeakMap;n.NEWLINE_CHARS=new Set([`
|
|
4
4
|
`,"\r"]);n.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function i1(X,Z){for(let Y=Z??0;Y<X.length;Y++){if(X[Y]===10)return{preceding:Y,index:Y+1,carriage:!1};if(X[Y]===13)return{preceding:Y,index:Y+1,carriage:!0}}return null}function l0(X){for(let W=0;W<X.length-1;W++){if(X[W]===10&&X[W+1]===10)return W+2;if(X[W]===13&&X[W+1]===13)return W+2;if(X[W]===13&&X[W+1]===10&&W+3<X.length&&X[W+2]===13&&X[W+3]===10)return W+4}return-1}var MZ={off:0,error:200,warn:300,info:400,debug:500},oZ=(X,Z,$)=>{if(!X)return;if(f0(MZ,X))return X;S($).warn(`${Z} was set to ${JSON.stringify(X)}, expected one of ${JSON.stringify(Object.keys(MZ))}`);return};function IX(){}function EZ(X,Z,$){if(!Z||MZ[X]>MZ[$])return IX;else return Z[X].bind(Z)}var n1={error:IX,warn:IX,info:IX,debug:IX},i0=new WeakMap;function S(X){let Z=X.logger,$=X.logLevel??"off";if(!Z)return n1;let W=i0.get(Z);if(W&&W[0]===$)return W[1];let Y={error:EZ("error",Z,$),warn:EZ("warn",Z,$),info:EZ("info",Z,$),debug:EZ("debug",Z,$)};return i0.set(Z,[$,Y]),Y}var m=(X)=>{if(X.options)X.options={...X.options},delete X.options.headers;if(X.headers)X.headers=Object.fromEntries((X.headers instanceof Headers?[...X.headers]:Object.entries(X.headers)).map(([Z,$])=>[Z,Z.toLowerCase()==="x-api-key"||Z.toLowerCase()==="authorization"||Z.toLowerCase()==="cookie"||Z.toLowerCase()==="set-cookie"?"***":$]));if("retryOfRequestLogID"in X){if(X.retryOfRequestLogID)X.retryOf=X.retryOfRequestLogID;delete X.retryOfRequestLogID}return X};var RX;class R{constructor(X,Z,$){this.iterator=X,RX.set(this,void 0),this.controller=Z,U(this,RX,$,"f")}static fromSSEResponse(X,Z,$){let W=!1,Y=$?S($):console;async function*J(){if(W)throw new C("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");W=!0;let Q=!1;try{for await(let w of r1(X,Z)){if(w.event==="completion")try{yield JSON.parse(w.data)}catch(G){throw Y.error("Could not parse message into JSON:",w.data),Y.error("From chunk:",w.raw),G}if(w.event==="message_start"||w.event==="message_delta"||w.event==="message_stop"||w.event==="content_block_start"||w.event==="content_block_delta"||w.event==="content_block_stop"||w.event==="message"||w.event==="user.message"||w.event==="user.interrupt"||w.event==="user.tool_confirmation"||w.event==="user.custom_tool_result"||w.event==="agent.message"||w.event==="agent.thinking"||w.event==="agent.tool_use"||w.event==="agent.tool_result"||w.event==="agent.mcp_tool_use"||w.event==="agent.mcp_tool_result"||w.event==="agent.custom_tool_use"||w.event==="agent.thread_context_compacted"||w.event==="session.status_running"||w.event==="session.status_idle"||w.event==="session.status_rescheduled"||w.event==="session.status_terminated"||w.event==="session.error"||w.event==="session.deleted"||w.event==="span.model_request_start"||w.event==="span.model_request_end")try{yield JSON.parse(w.data)}catch(G){throw Y.error("Could not parse message into JSON:",w.data),Y.error("From chunk:",w.raw),G}if(w.event==="ping")continue;if(w.event==="error"){let G=CZ(w.data)??w.data,M=G?.error?.type;throw new A(void 0,G,void 0,X.headers,M)}}Q=!0}catch(w){if(d(w))return;throw w}finally{if(!Q)Z.abort()}}return new R(J,Z,$)}static fromReadableStream(X,Z,$){let W=!1;async function*Y(){let Q=new n,w=PX(X);for await(let G of w)for(let M of Q.decode(G))yield M;for(let G of Q.flush())yield G}async function*J(){if(W)throw new C("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");W=!0;let Q=!1;try{for await(let w of Y()){if(Q)continue;if(w)yield JSON.parse(w)}Q=!0}catch(w){if(d(w))return;throw w}finally{if(!Q)Z.abort()}}return new R(J,Z,$)}[(RX=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let X=[],Z=[],$=this.iterator(),W=(Y)=>{return{next:()=>{if(Y.length===0){let J=$.next();X.push(J),Z.push(J)}return Y.shift()}}};return[new R(()=>W(X),this.controller,z(this,RX,"f")),new R(()=>W(Z),this.controller,z(this,RX,"f"))]}toReadableStream(){let X=this,Z;return rZ({async start(){Z=X[Symbol.asyncIterator]()},async pull($){try{let{value:W,done:Y}=await Z.next();if(Y)return $.close();let J=fX(JSON.stringify(W)+`
|
|
5
5
|
`);$.enqueue(J)}catch(W){$.error(W)}},async cancel(){await Z.return?.()}})}}async function*r1(X,Z){if(!X.body){if(Z.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative")throw new C("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new C("Attempted to iterate over a response with no body")}let $=new n0,W=new n,Y=PX(X.body);for await(let J of a1(Y))for(let Q of W.decode(J)){let w=$.decode(Q);if(w)yield w}for(let J of W.flush()){let Q=$.decode(J);if(Q)yield Q}}async function*a1(X){let Z=new Uint8Array;for await(let $ of X){if($==null)continue;let W=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?fX($):$,Y=new Uint8Array(Z.length+W.length);Y.set(Z),Y.set(W,Z.length),Z=Y;let J;while((J=l0(Z))!==-1)yield Z.slice(0,J),Z=Z.slice(J)}if(Z.length>0)yield Z}class n0{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(X){if(X.endsWith("\r"))X=X.substring(0,X.length-1);if(!X){if(!this.event&&!this.data.length)return null;let Y={event:this.event,data:this.data.join(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{m as U1}from"./chunk-e5s7202g.js";import{n as v1,o as M1}from"./chunk-tqxmj05h.js";import{t as Q1}from"./chunk-4ajat3xv.js";import{w as E1}from"./chunk-3htn4m2d.js";import{E as k1,R as q1}from"./chunk-76hs7g0x.js";import{oa as O1}from"./chunk-vw1rhgjs.js";import{Ma as v,Pa as H1,Qa as W1,Za as y1,ab as L1,cb as i}from"./chunk-ef5v7gta.js";import{Sf as $1}from"./chunk-nh8azwsx.js";import{vg as B1,wg as I}from"./chunk-0jr6q4j4.js";import{Cg as V1}from"./chunk-4a9sdfyp.js";import{sh as K1}from"./chunk-w98wvk17.js";import{$h as Y,Ch as r,Eh as J1,Ek as _1,Fh as a,Kh as Y1,vh as hx,wh as o,wk as Z1,xh as X,yh as W,zh as G1}from"./chunk-jt4yh37q.js";import{Il as zx}from"./chunk-mgbqjbfc.js";var w=zx(hx(),1);function X1(n,h,y,A,V,Z){let R=n.type==="folder",_=h.type==="folder";if(R!==_)return null;let $=_?A:V,L=$.findIndex((J)=>J.id===y),k=$.findIndex((J)=>J.id===h.id);if(L===-1||k===-1)return null;let g=Math.min(L,k),D=Math.max(L,k),O=$.slice(g,D+1),T=new Set(Z);return O.forEach((J)=>{if(J.id)T.add(J.id)}),T}function wx({teamId:n,projectId:h,projectName:y,assetId:A,rootFolderId:V,collection:Z,onUpdateCollection:R}){let _=Y1(),$=G1(),{canEdit:L}=K1(h),{setFields:k}=k1(),g=Y.api.files[":fileId"].metadata.$patch,{mutate:D}=J1({mutationFn:async(x)=>{if(!(await g(x)).ok)throw Error("Failed to patch metadata");return null}}),{data:O}=r({queryKey:["fields",h],queryFn:async()=>{let x=await Y.api.projects[":projectId"].fields.$get({param:{projectId:h}});if(!x.ok)throw Error("Failed to fetch fields");return await x.json()},enabled:!!h});w.useEffect(()=>{if(O)k(O,h)},[O,h,k]);let T=A==="recently-deleted",[J,P]=w.useState(null),[B,M]=w.useState(new Set),[u,l]=w.useState(null),[N1,b1]=w.useState(240),[f1,R1]=w.useState(360),{isChatbotOpen:C}=I(),{members:g1,fetchMembers:s}=q1(),{metadata:D1,fetchMetadata:d,setMetadata:P1}=$1();w.useEffect(()=>{if(n)s(n),d(n)},[n,s,d]);let p=w.useMemo(()=>{return Z?.filter?.searchFilter?.conditions||[]},[Z]),[q,F]=w.useState(p);w.useEffect(()=>{F(p)},[p]);let t=`project:${h}:sort`,E=D1[t]||{field:"custom",order:"asc"},u1=(x)=>{if(x)P1(n,t,x)},K=!!Z,m=q.length>0||K,{fileListLeftSidebarCollapsed:e,setFileListLeftSidebarCollapsed:C1,fileListRightSidebarCollapsed:x1,setFileListRightSidebarCollapsed:p1,viewModes:F1}=V1(),z1=F1[h]??"card",m1=w.useRef(null),{data:N}=T?{data:void 0}:r({queryKey:["folders",A],queryFn:async()=>{let x=await Y.api.folders[":folderId"].$get({param:{folderId:A}});if(!x.ok)throw Error("failed to fetch folder");return await x.json()}}),{setProjectState:h1,clearProjectState:w1}=B1();w.useEffect(()=>{return h1({teamId:n,projectId:h,projectName:y,ancestorFolders:N?.ancestorFolders??[],currentAsset:T?{name:"Recently Deleted",type:"folder"}:K?{name:Z.name,type:"folder"}:{name:N?.name,type:"folder"},isRootFolder:!T&&!K&&A===V,onFolderClick:(x)=>{_({to:"/projects/$projectId/folders/$folderId",params:{projectId:h,folderId:x}})}}),()=>w1()},[n,h,y,N,T,A,V,h1,w1,_]);let{data:S,fetchNextPage:S1,hasNextPage:j1,isFetchingNextPage:c1}=a({queryKey:T?["projects",h,"recently-deleted","folder"]:["search",n,A,"folder",q,E,K],queryFn:async({pageParam:x})=>{if(T||K){if(T){let G=await Y.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:h},query:{assetType:"folder",after:x}});if(!G.ok)throw Error("failed to fetch recently deleted folders");return await G.json()}return{data:[],pageInfo:{total:0}}}if(m)return{data:[],pageInfo:{total:0}};let z=await Y.api.folders[":folderId"].search.$post({param:{folderId:A},json:{assetType:"folder",after:x,recursively:!1,sort:E,conditions:[]}});if(!z.ok)throw Error("failed to search folders");return await z.json()},enabled:!m,initialPageParam:"",getNextPageParam:(x)=>{return x.pageInfo?.cursor||void 0}}),{data:j,fetchNextPage:o1,hasNextPage:r1,isFetchingNextPage:a1}=a({queryKey:T?["projects",h,"recently-deleted","file"]:["search",n,A,"file",q,E,K],queryFn:async({pageParam:x})=>{if(T){let G=await Y.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:h},query:{assetType:"file",after:x}});if(!G.ok)throw Error("failed to fetch recently deleted files");return await G.json()}let z=await Y.api.folders[":folderId"].search.$post({param:{folderId:A},json:{assetType:"file",after:x,recursively:m||K,conditions:q,sort:E}});if(!z.ok)throw Error("failed to search files");return await z.json()},initialPageParam:"",getNextPageParam:(x)=>{return x.pageInfo?.cursor||void 0}}),b=S?.pages.flatMap((x)=>x.data??[])??[],H=j?.pages.flatMap((x)=>x.data??[])??[],I1=S?.pages[0]?.pageInfo?.total,i1=j?.pages[0]?.pageInfo?.total,l1=S?.pages[0]?.pageInfo?.totalSize,s1=j?.pages[0]?.pageInfo?.totalSize,n1=()=>{M(new Set),P(null),l(null)},{dragState:Q,handleDragStart:d1,handleDragEnd:t1}=M1({teamId:n,projectId:h,assetId:A,folders:b,files:H,selectedIds:B,onClearSelection:n1}),c=w.useMemo(()=>{if(B.size!==1)return null;let x=Array.from(B)[0];return H.find((G)=>G.id===x)||null},[B,H]),e1=(x)=>{if(T)return;if(x.type==="folder")F([]),_({to:"/projects/$projectId/folders/$folderId",params:{projectId:h,folderId:x.id}});else _({to:"/projects/$projectId/files/$fileId",params:{projectId:h,fileId:x.versionStack?x.versionStack.id:x.id},search:{version:void 0}})},xx=(x,z)=>{let G=z.metaKey||z.ctrlKey;if(z.shiftKey&&u){let T1=[...b,...H].find((f)=>f.id===u);if(T1){let f=X1(T1,x,u,b,H,B);if(f){M(f),P(x);return}}}if(G){let U=new Set(B);if(U.has(x.id))U.delete(x.id);else U.add(x.id);M(U)}else M(new Set([x.id]));l(x.id),P(x)},A1=(x,z,G)=>{D({param:{fileId:x},json:[{key:z,value:G}]},{onSuccess:()=>{$.invalidateQueries({queryKey:["folders",A,"children",{assetType:"file"}]}),$.invalidateQueries({queryKey:["search",n,A]})}})};return W(y1,{modifiers:[v1.configure({anchor:{x:0,y:0}})],plugins:(x)=>x.map((z)=>{if(z===v)return v.configure({dropAnimation:null});if(typeof z==="object"&&z!==null&&"plugin"in z&&z.plugin===v)return v.configure({dropAnimation:null});return z}),sensors:T||!L?[]:[W1.configure({activationConstraints:[new H1.Distance({value:10})]})],onDragStart:d1,onDragEnd:t1,children:[X("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:W("div",{ref:m1,className:"flex flex-1 overflow-hidden relative",children:[!e&&X("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>C1(!0)}),(!x1||C)&&X("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>{p1(!0),I.getState().setIsChatbotOpen(!1)}}),!e&&W(o,{children:[X("div",{className:"bg-background",style:{width:N1},children:X(O1,{teamId:n,projectId:h,projectName:y,rootFolderId:V,dragState:Q,ancestorFolders:N?.ancestorFolders??[]})}),X(i,{onResize:(x)=>{b1((z)=>Math.max(180,Math.min(400,z+x)))},className:"hidden md:block"})]}),X(E1,{teamId:n,projectId:h,assetId:A,folders:b,files:H,totalFolders:I1,totalFiles:i1,totalFoldersSize:l1,totalFilesSize:s1,selectedItem:J,selectedIds:B,onItemSelect:xx,onItemDoubleClick:e1,onSaveField:A1,displayStyle:z1,onClearSelection:n1,fetchNextFoldersPage:S1,hasNextFoldersPage:j1||!1,isFetchingNextFoldersPage:c1,fetchNextFilesPage:o1,hasNextFilesPage:r1||!1,isFetchingNextFilesPage:a1,isRecentlyDeleted:T,filterConditions:q,onFilterChange:F,sort:E,onSortChange:u1,dragState:Q,collection:Z,onUpdateCollection:R,rootFolderId:V}),(!x1||C)&&W(o,{children:[X(i,{onResize:(x)=>{R1((z)=>Math.max(240,Math.min(600,z-x)))},className:"hidden md:block"}),X("div",{style:{width:f1},className:"bg-background flex flex-col flex-shrink-0",children:C?X(U1,{projectId:h,contextAssetId:A}):c?X(Q1,{teamId:n,projectId:h,file:c,onSaveField:(x,z)=>A1(c.id,x,z),members:g1,hideAnnotationControl:!0}):X("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:_1.select_asset_to_view_details()})})]})]})}),X(L1,{children:Q?.isActive?X("div",{className:Z1("flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium text-popover-foreground shadow-md ring-1 ring-border cursor-grabbing",z1==="list"&&"w-30 h-[40px] px-0 flex-none overflow-hidden justify-center"),style:{transform:"translate(0px, 0px)"},children:W("span",{children:["Moving ",Q.itemCount," item",Q.itemCount!==1?"s":""]})}):null})]})}
|
|
2
|
+
export{wx as l};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{D as
|
|
1
|
+
import{wa as j,ya as F}from"./chunk-ef5v7gta.js";import{wg as p}from"./chunk-0jr6q4j4.js";import{$h as f,Eh as P,Zh as _,vh as s,zh as q}from"./chunk-jt4yh37q.js";import{Il as l}from"./chunk-mgbqjbfc.js";var i={x:0.5,y:0.5};class D extends F{apply({activatorEvent:Z,shape:L,transform:E}){if(!L||!(Z instanceof PointerEvent))return E;let M=this.options?.anchor??i,{boundingRectangle:G}=L.initial,Q=G.left+G.width*M.x,J=G.top+G.height*M.y;return{x:E.x+Z.clientX-Q,y:E.y+Z.clientY-J}}static configure=j(D)}var C=l(s(),1);function YO({teamId:Z,projectId:L,assetId:E,folders:M,files:G,selectedIds:Q,onClearSelection:J}){let T=q(),[N,A]=C.useState(void 0),y=(Y,R)=>{let h=["search",Z,E,Y?"folder":"file"],U=T.getQueriesData({queryKey:h}),H=(X)=>{if(typeof X!=="object"||X===null)return!1;let O=X;return"field"in O&&"order"in O&&typeof O.field==="string"&&(O.order==="asc"||O.order==="desc")};for(let[X,O]of U){if(!O||!Array.isArray(O.pages))continue;let z=X.find(H),k=O.pages.flatMap((w)=>w.data??[]),K=k.findIndex((w)=>w.id===R.id);if(K===-1)continue;if(k[K]={...k[K],...R},z?.field==="custom"){let w=z.order==="desc";k.sort((B,x)=>{let $=B.sortIndex??"",b=x.sortIndex??"";if($===b)return 0;if(w)return $<b?1:-1;else return $<b?-1:1})}let V=0,o=O.pages.map((w)=>{let B=w.data?w.data.length:0,x=k.slice(V,V+B);return V+=B,{...w,data:x}});T.setQueryData(X,{...O,pages:o})}},v=f.api.projects[":projectId"].reparent.$post,{mutate:c}=P({mutationFn:async(Y)=>{if(!(await v(Y)).ok)throw Error("Failed to move assets");return null}}),n=f.api.folders[":folderId"].order.$patch,{mutate:u}=P({mutationFn:async(Y)=>{let R=await n(Y);if(!R.ok)throw Error("Failed to reorder folder");return await R.json()}}),m=f.api.files[":fileId"].order.$patch,{mutate:S}=P({mutationFn:async(Y)=>{let R=await m(Y);if(!R.ok)throw Error("Failed to reorder file");return await R.json()}}),I=f.api.shares[":shareId"].assets.$post,{mutate:g}=P({mutationFn:async(Y)=>{let R=await I(Y);if(!R.ok)throw Error("Failed to add asset to share");return await R.json()}});return{dragState:N,handleDragStart:(Y)=>{let R=Y.operation.source;if(!R)return;let W=R.id.split(":").pop(),h=R.data;if(!h)return;let U,H;if(Q.has(W))U=new Set(Q),H=[...M,...G].filter((O)=>Q.has(O.id));else U=new Set([W]),H=[h.item];let X=H.some((O)=>O.type==="folder");A({isActive:!0,draggedIds:U,hasFolders:X,itemCount:U.size})},handleDragEnd:(Y)=>{let{target:R}=Y.operation;if(R&&N){let W=R.id.split(":").pop(),h=R.data;if(h?.type==="chatbot-sidebar"){let X=[...M,...G].filter((O)=>N.draggedIds.has(O.id)).map((O)=>({id:O.id,name:O.name||"Unnamed",type:O.type}));p.getState().addAssets(X),J(),A(void 0);return}if(h?.type==="share-link"){let H=W,X=Array.from(N.draggedIds);g({param:{shareId:H},json:{assetIds:X}},{onSuccess:(O)=>{if(O.addedCount===0)_.info("Assets already exists in share");else _.success(`Added ${O.addedCount} item(s) to share link`);T.invalidateQueries({queryKey:["shares",L]}),J()},onError:(O)=>{_.error(`Failed to add to share: ${O.message}`)}}),A(void 0);return}let U=!1;if(h&&!N.draggedIds.has(W)){if(h.type==="folder"||h.type==="reorder")U=!0;else if(h.type==="file"){if(!N.hasFolders&&N.itemCount===1)U=!0}}if(h?.type==="reorder"){let{position:H,item:X}=h,O=N.hasFolders,z=Array.from(N.draggedIds)[0];if(O)u({param:{folderId:z},json:H==="before"?{beforeIndex:X.sortIndex??void 0}:{afterIndex:X.sortIndex??void 0}},{onSuccess:(k)=>{_.success("Folder reordered"),y(!0,k),J()},onError:(k)=>{_.error(`Failed to reorder: ${k.message}`)}});else S({param:{fileId:z},json:H==="before"?{beforeIndex:X.sortIndex??void 0}:{afterIndex:X.sortIndex??void 0}},{onSuccess:(k)=>{_.success("File reordered"),y(!1,k),J()},onError:(k)=>{_.error(`Failed to reorder: ${k.message}`)}})}else if(U)c({param:{projectId:L},json:{assetIds:Array.from(N.draggedIds),newParentId:W}},{onSuccess:()=>{_.success("Assets moved successfully"),T.invalidateQueries({queryKey:["search",Z,E]}),T.invalidateQueries({queryKey:["folders"]}),J()},onError:()=>{_.error("Failed to move assets")}})}A(void 0)}}}
|
|
2
|
+
export{D as n,YO as o};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{d as
|
|
1
|
+
import{wk as r,xh as o}from"./chunk-jt4yh37q.js";function d({className:t,...a}){return o("div",{"data-slot":"card",className:r("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",t),...a})}function n({className:t,...a}){return o("div",{"data-slot":"card-header",className:r("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...a})}function c({className:t,...a}){return o("div",{"data-slot":"card-title",className:r("leading-none font-semibold",t),...a})}function s({className:t,...a}){return o("div",{"data-slot":"card-description",className:r("text-sm text-muted-foreground",t),...a})}function i({className:t,...a}){return o("div",{"data-slot":"card-content",className:r("px-6",t),...a})}function l({className:t,...a}){return o("div",{"data-slot":"card-footer",className:r("flex items-center px-6 [.border-t]:pt-6",t),...a})}
|
|
2
|
+
export{d as If,n as Jf,c as Kf,s as Lf,i as Mf,l as Nf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ja as cz}from"./chunk-6b0f3d07.js";import"./chunk-05m8w09t.js";import{eb as r}from"./chunk-ankkm2wz.js";import{fb as Cz,gb as fz,hb as Iz,ib as gz,jb as uz,kb as lz,lb as dz,mb as pz}from"./chunk-3vbx3x11.js";import"./chunk-898hrxwq.js";import{Xf as yz}from"./chunk-j5q3t199.js";import{cg as Dz}from"./chunk-gg8dmkwd.js";import{ig as m}from"./chunk-v5zdafv4.js";import{jg as C,lg as f,mg as I,ng as w,wg as bz}from"./chunk-38hp9gfh.js";import{Ag as P,Aj as hz,Bg as z,Bj as Sz,Cg as J,Ch as Rz,Cj as wz,Dg as i,Fi as Zz,Fj as V,Gg as o,Gj as j,Hj as kz,Ig as q,Ij as qz,Jh as a,Jj as Az,Kj as Ez,Lj as Fz,Mj as Uz,Og as n,Tg as Bz,Xi as Jz,bh as Yz,cj as Kz,dh as X,eh as Vz,fh as Pz,mh as vz,oh as Gz,qh as Tz,rh as Lz,xg as Mz,xj as _z,zg as $z,zj as F}from"./chunk-ersxsrz8.js";import{Jk as Wz}from"./chunk-8tnq43k9.js";var k=Wz($z(),1);function Nz({open:Z,onOpenChange:T,mode:L,teamId:U,project:W}){let A=i(),K=n(),[H,O]=k.useState(""),[y,B]=k.useState(!0),[g,M]=k.useState(void 0),[b,N]=k.useState(void 0),[E,D]=k.useState(!1),v=k.useRef(null);k.useEffect(()=>{if(Z)if(L==="edit"&&W)O(W.name||""),M(W.coverImageKey),N(W.coverImage),B(W.enableNotification!==!1);else O(""),M(void 0),N(void 0),B(!0)},[Z,L,W]);let u=X.api.teams[":teamId"].projects.$post,{mutate:t}=q({mutationFn:async(Q)=>{let _=await u({param:{teamId:U},json:Q});if(!_.ok)throw Error(V.failed_create_project());return await _.json()},onSuccess:(Q)=>{A.invalidateQueries({queryKey:["teams",U,"projects"]}),T(!1);let _=Q;if(_&&typeof _.id==="string")K({to:"/projects/$projectId",params:{projectId:_.id}})}}),l=X.api.projects[":projectId"].$put,{mutate:s}=q({mutationFn:async(Q)=>{let _=await l({param:{projectId:W.id},json:Q});if(!_.ok)throw Error(V.failed_update_project());return await _.json()},onSuccess:()=>{A.invalidateQueries({queryKey:["teams",U,"projects"]}),T(!1)}}),e=X.api.teams[":teamId"].files.$post,{mutate:d}=q({mutationFn:async({file:Q})=>{let _=await e({param:{teamId:U},form:{file:Q}});if(!_.ok)throw Error(V.failed_upload_file());return await _.json()},onSuccess:(Q)=>{let _=Q;if(_&&typeof _.key==="string")M(_.key);D(!1)},onError:()=>{D(!1)}}),R=(Q)=>{let _=Q.target.files?.[0];if(_){D(!0);let zz=URL.createObjectURL(_);N(zz),d({file:_})}},h=()=>{v.current?.click()},p=(Q)=>{Q.stopPropagation(),M(void 0),N(void 0)},S=()=>{if(!H.trim())return;if(L==="create")t({name:H.trim(),coverImageKey:g,enableNotification:y});else if(L==="edit"&&W?.id)s({name:H.trim(),coverImageKey:g,enableNotification:y})};return z(kz,{open:Z,onOpenChange:T,children:J(qz,{className:"sm:max-w-[550px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 backdrop-blur-md shadow-2xl p-0 gap-0",children:[J(Az,{className:"relative overflow-hidden bg-gradient-to-br from-primary/5 to-transparent p-6 border-b border-border/40",children:[z("div",{className:"absolute top-0 right-0 w-24 h-24 bg-primary/10 rounded-full blur-2xl pointer-events-none"}),z("div",{className:"absolute bottom-0 left-10 w-32 h-12 bg-primary/5 rounded-full blur-xl pointer-events-none"}),z("div",{className:"flex items-center gap-3",children:J("div",{children:[z(Fz,{className:"text-xl font-semibold tracking-tight text-foreground",children:L==="create"?V.create_new_project():V.project_settings()}),z(Uz,{className:"text-xs text-muted-foreground/80 mt-1",children:L==="create"?V.configure_new_project_description():V.manage_project_description()})]})})]}),J("div",{className:"space-y-6 p-6 max-h-[75vh] overflow-y-auto",children:[J("div",{className:"space-y-2",children:[z(m,{htmlFor:"name",className:"text-sm font-semibold tracking-tight text-foreground",children:V.project_name()}),J("div",{className:"relative",children:[z(j,{id:"name",value:H,onChange:(Q)=>O(Q.target.value),placeholder:V.project_name_placeholder(),className:"h-11 px-4 rounded-xl border-border/80 focus-visible:ring-ring/25 focus-visible:border-primary transition-all shadow-xs pr-10"}),H.trim()&&z("div",{className:"absolute inset-y-0 right-3 flex items-center",children:z(a,{className:"w-4 h-4 text-primary"})})]}),z("p",{className:"text-[11px] text-muted-foreground",children:V.project_name_hint()})]}),J("div",{className:"space-y-3 border-t border-border/40 pt-5",children:[J("div",{className:"flex items-center justify-between",children:[J(m,{className:"text-sm font-semibold tracking-tight text-foreground flex items-center gap-1.5",children:[z(Lz,{className:"w-4 h-4 text-primary"}),V.project_cover()]}),b&&J("button",{type:"button",onClick:p,className:"text-xs text-muted-foreground hover:text-destructive hover:bg-destructive/5 px-2.5 py-1 rounded-lg transition-all flex items-center gap-1 font-medium",children:[z(Kz,{className:"w-3.5 h-3.5"}),V.remove_cover()]})]}),J("div",{className:"relative aspect-square w-48 mx-auto rounded-2xl border border-dashed border-border flex items-center justify-center cursor-pointer overflow-hidden group shadow-inner bg-muted/20 transition-all duration-300 hover:border-primary/50 hover:bg-muted/40",onClick:h,children:[z("input",{type:"file",ref:v,className:"hidden",accept:"image/*",onChange:R}),E&&z("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:J("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[z(Gz,{className:"w-4 h-4 animate-spin text-primary"}),z("span",{className:"text-xs font-semibold text-foreground",children:V.uploading()})]})}),b?J(P,{children:[z("img",{src:b,alt:V.cover_preview(),className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"}),J("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.5 text-white z-10",children:[z(Jz,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),z("span",{className:"text-xs font-semibold",children:V.upload_image()})]})]}):J("div",{className:"flex flex-col items-center gap-2 text-center p-4",children:[z("div",{className:"p-2.5 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:z(Jz,{className:"w-4 h-4 text-muted-foreground"})}),J("div",{children:[z("p",{className:"text-xs font-medium text-foreground",children:V.upload_cover()}),z("p",{className:"text-[11px] text-muted-foreground mt-0.5 max-w-[140px] mx-auto leading-normal",children:V.upload_cover_hint()})]})]})]})]}),J("div",{className:"space-y-3 border-t border-border/40 pt-5",children:[J(m,{className:"text-sm font-semibold tracking-tight text-foreground flex items-center gap-1.5",children:[z(Tz,{className:"w-4 h-4 text-primary"}),V.project_preferences()]}),J("div",{className:"flex items-start justify-between rounded-xl border border-border/50 bg-muted/10 p-4 transition-all duration-300 hover:bg-muted/20",children:[J("div",{className:"space-y-1 pr-4",children:[J("div",{className:"text-sm font-semibold flex items-center gap-2 text-foreground",children:[z(Rz,{className:"w-4 h-4 text-primary"}),V.activity_notifications()]}),z("p",{className:"text-xs text-muted-foreground leading-normal",children:V.activity_notifications_description()})]}),z(r,{checked:y,onCheckedChange:B,disabled:E,className:"mt-0.5"})]})]})]}),J(Ez,{className:"flex items-center justify-end gap-3 px-6 py-4 bg-muted/20 border-t border-border/40",children:[z(F,{type:"button",variant:"ghost",onClick:()=>T(!1),disabled:E,className:"rounded-xl h-10 px-4 hover:bg-muted font-medium text-sm text-muted-foreground hover:text-foreground transition-colors",children:V.cancel()}),z(F,{type:"submit",onClick:S,disabled:!H.trim()||E,className:"rounded-xl h-10 px-5 bg-primary text-primary-foreground hover:bg-primary/90 font-semibold text-sm shadow-lg shadow-primary/10 hover:shadow-primary/20 active:scale-98 transition-all flex items-center gap-2",children:E?J(P,{children:[z(Gz,{className:"w-4 h-4 animate-spin"}),V.processing()]}):L==="create"?V.create_project():V.save_changes()})]})]})})}function Oz({sortBy:Z,sortDirection:T,onSortChange:L}){let U=(H)=>{L(H,T)},W=()=>{L(Z,T==="asc"?"desc":"asc")},A=(H)=>{switch(H){case"name":return V.sort_name();case"created_at":return V.sort_created();case"updated_at":return V.sort_updated();default:return H}},K=T==="asc";return J(C,{children:[z(f,{asChild:!0,children:J(F,{variant:"outline",className:"gap-2 bg-muted/50",children:[z("span",{className:"text-muted-foreground",children:V.sorted_by_label()}),z("span",{className:"font-medium text-foreground",children:A(Z)})]})}),J(I,{align:"end",className:"w-56 p-2",children:[z("div",{className:"text-xs font-semibold text-muted-foreground mb-2 px-2",children:V.sort_by()}),J(C,{children:[z(f,{asChild:!0,children:J(F,{variant:"ghost",className:"w-full justify-between font-normal px-2 h-10 bg-muted/50 hover:bg-muted mb-2 border",children:[z("span",{children:A(Z)}),z(Vz,{className:"h-4 w-4 opacity-50"})]})}),z(I,{className:"w-52",children:["name","created_at","updated_at"].map((H)=>J(w,{onClick:()=>U(H),className:"justify-between",children:[A(H),Z===H&&z(a,{className:"h-4 w-4"})]},H))})]}),J(F,{variant:"ghost",className:"w-full justify-between font-normal px-2 h-10 bg-muted/50 hover:bg-muted border",onClick:W,children:[z("span",{className:"text-muted-foreground",children:Z==="name"?K?z(P,{children:V.sort_a_to_z()}):z(P,{children:V.sort_z_to_a()}):K?z(P,{children:V.sort_oldest_to_newest()}):z(P,{children:V.sort_newest_to_oldest()})}),K?z(Pz,{className:"h-4 w-4 opacity-50"}):z(Vz,{className:"h-4 w-4 opacity-50"})]})]})]})}var $=Wz($z(),1);function JG(){let{teamId:Z}=VG.useParams(),{canEdit:T,canAdmin:L}=bz(),U=n(),W=i(),[A,K]=$.useState(null),[H,O]=$.useState(!1),[y,B]=$.useState("create"),[g,M]=$.useState(void 0),[b,N]=$.useState(!1),[E,D]=$.useState(void 0),[v,u]=$.useState(""),[t,l]=$.useState(!1),{metadata:s,setMetadata:e}=Dz(),d=`team:${Z}:projects:sort`,R=s[d],[h,p]=$.useState(()=>R?.sortBy||"name"),[S,Q]=$.useState(()=>R?.sortDirection||"asc");$.useEffect(()=>{if(R?.sortBy&&R.sortBy!==h)p(R.sortBy);if(R?.sortDirection&&R.sortDirection!==S)Q(R.sortDirection)},[R]);let _=X.api.teams[":teamId"].projects.$get,{data:zz}=o({queryKey:["teams",Z,"projects",h,S],queryFn:async()=>{let G=await _({param:{teamId:Z},query:{sortBy:h,sortDirection:S}});if(!G.ok)throw Error("Failed to fetch projects");return await G.json()},placeholderData:Mz}),{data:Hz}=o({queryKey:["teams",Z,"members"],queryFn:async()=>{let G=await X.api.teams[":teamId"].members.$get({param:{teamId:Z},query:{}});if(!G.ok)throw Error("Failed to fetch members");return await G.json()}}),{data:Qz}=o({queryKey:["teams",Z,"me"],queryFn:async()=>{let G=await X.api.teams[":teamId"].me.$get({param:{teamId:Z}});if(!G.ok)throw Error("Failed to fetch me");return await G.json()}}),xz=X.api.teams[":teamId"].invite.$post,mz=q({mutationFn:async(G)=>{let Y=await xz(G);if(!Y.ok)throw Error("Failed to invite");return await Y.json()}}),c=q({mutationFn:async(G)=>{if(!(await X.api.projects[":projectId"].$delete({param:{projectId:G}})).ok)throw Error("Failed to delete project")},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"projects"]})}}),iz=q({mutationFn:async(G)=>{let Y=await X.api.projects[":projectId"].$put({param:{projectId:G.id},json:{enableNotification:!G.enableNotification}});if(!Y.ok)throw Error("Failed to update project notification settings");return await Y.json()},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"projects"]}),Yz.success(V.project_notification_updated())},onError:(G)=>{Yz.error(G instanceof Error?G.message:V.failed_update_project_notification())}}),Xz=()=>{B("create"),M(void 0),O(!0)},nz=()=>{K("create"),setTimeout(()=>{K(null)},100),setTimeout(()=>{Xz()},200)},az=(G)=>{B("edit"),M(G),O(!0)},jz=(G)=>{D(G),u(""),N(!0)},rz=async()=>{if(E&&v==="delete")try{await c.mutateAsync(E.id),N(!1)}catch(G){console.error(G)}},oz=(G,Y)=>{if(Y.detail>1)return;K(G),setTimeout(()=>{K(null)},100),setTimeout(()=>{U({to:"/projects/$projectId",params:{projectId:G}})},200)},tz=async(G)=>{return(await mz.mutateAsync({param:{teamId:Z},json:{role:G}})).code},sz=q({mutationFn:async({userId:G,role:Y})=>{if(!(await X.api.teams[":teamId"].members[":userId"].$patch({param:{teamId:Z,userId:G},json:{role:Y}})).ok)throw Error("Failed to update member role")},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"members"]})}}),ez=q({mutationFn:async(G)=>{if(!(await X.api.teams[":teamId"].members[":userId"].$delete({param:{teamId:Z,userId:G}})).ok)throw Error("Failed to remove member")},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"members"]})}}),zG=(G)=>{if(!G)return"??";return G.split(" ").map((Y)=>Y[0]).slice(0,2).join("").toUpperCase()},GG=(G,Y)=>{p(G),Q(Y),e(Z,d,{sortBy:G,sortDirection:Y})},x=Array.isArray(Hz)?Hz:[];return J("div",{className:"flex-1 overflow-y-auto p-4",children:[J("div",{className:"flex flex-wrap items-center justify-between mb-4 gap-4",children:[z("h1",{className:"text-2xl font-bold",children:V.projects()}),J("div",{className:"flex flex-wrap items-center gap-4",children:[J("div",{className:"flex items-center -space-x-2 cursor-pointer hover:opacity-90",onClick:()=>l(!0),"data-testid":"team-members-trigger",children:[x.slice(0,3).map((G)=>J(hz,{className:"border-2 border-background w-8 h-8",children:[G.image&&z(Sz,{src:G.image,alt:G.name,className:"object-cover"}),z(wz,{className:"text-[10px]",children:zG(G.name)})]},G.id)),x.length>3&&J("div",{className:"flex items-center justify-center w-8 h-8 rounded-full border-2 border-background bg-muted text-[10px] font-medium",children:["+",x.length-3]})]}),z(Oz,{sortBy:h,sortDirection:S,onSortChange:GG}),T&&J(F,{className:"bg-orange-600 hover:bg-orange-700 text-white gap-2",onClick:Xz,children:[z(Zz,{className:"w-4 h-4"}),V.create_project()]})]})]}),J("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 gap-4",children:[zz?.data?.map((G)=>z("div",{className:_z("shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out",A===G.id?"scale-95":"scale-100"),onClick:(Y)=>oz(G.id,Y),children:J("div",{className:"flex flex-col",children:[J("div",{className:"relative w-full h-full aspect-square flex items-center justify-center bg-zinc-400/20",children:[G.coverImage?z("img",{src:G.coverImage,alt:G.name,className:"w-full h-full object-cover rounded"}):J("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 180.95 164.7",preserveAspectRatio:"xMidYMid slice",className:"w-full h-full object-cover rounded",children:[z("polygon",{fill:"#FC9F8E",points:"0 18.5 0 76.0 151.69 164.7 180.95 164.7 180.95 113.6"}),z("polygon",{fill:"#FEBAB8",points:"0 0 74.58 61.5 90.53 51.6 110.33 63.9 180.95 18.9 180.95 0"}),z("polyline",{fill:"#FAA5A5",points:"0 18.5 74.58 61.5 90.53 51.6 110.33 63.9 180.95 18.9 180.95 0 0 0"}),z("polygon",{fill:"#EC5B6C",points:"0 76.0 0 164.7 151.69 164.7"}),z("polygon",{fill:"#E85C71",points:"180.95 18.9 110.33 63.9 117.37 68.0 117.26 73.4 180.95 113.6"}),z("polygon",{fill:"#C8405B",points:"117.26 73.4 117.37 99.0 90.53 114.9 174.35 164.7 180.95 164.7 180.95 113.6"}),z("polygon",{fill:"#FFCCBE",points:"90.53 51.6 63.69 68.1 90.53 83.4"}),z("path",{fill:"#FB9991",d:"M 90.53 51.6 L 90.53 61.3 L 100.87 67.4 L 90.53 73.5 L 90.53 83.4 L 117.37 68.0 C 117.15 67.6 90.53 51.6 90.53 51.6 Z"}),z("path",{fill:"#FFEACD",d:"M 63.69 68.1 C 63.47 68.5 64.02 99.3 64.02 99.3 C 64.02 99.3 64.46 99.6 64.9 99.9 L 90.53 83.4 L 63.69 68.1 Z"}),z("polygon",{fill:"#FFCFB5",points:"64.02 99.3 90.53 114.9 90.53 83.4"}),z("path",{fill:"#F67D73",d:"M 90.53 83.4 L 90.53 114.9 L 117.37 99.0 Z"}),z("path",{fill:"#F26560",d:"M 90.53 83.4 L 117.37 99.0 L 117.37 68.0 Z"}),z("polygon",{fill:"#EB5F5B",points:"80.08 67.5 90.53 73.5 90.53 61.3"}),z("polygon",{fill:"#DB4D50",points:"90.53 61.3 90.53 73.5 100.87 67.4"})]}),z("div",{className:"absolute bottom-0 left-0 w-full h-[65%] bg-linear-to-t from-black/35 to-black/0"}),z("p",{className:"absolute left-1 bottom-2 text-white",children:G.name})]}),J("div",{className:"px-2 h-10 flex justify-between items-center",children:[J("p",{className:"truncate pr-1 text-xs text-muted-foreground",children:[V.updated_ago()," ",yz(G.updatedAt??"")]}),z("div",{onClick:(Y)=>Y.stopPropagation(),children:J(C,{modal:!1,children:[z(f,{asChild:!0,children:z("button",{className:"hover:bg-muted outline-none flex px-1",children:z(vz,{className:"w-5 h-5 text-muted-foreground"})})}),J(I,{align:"end",children:[T&&z(w,{onClick:(Y)=>{Y.stopPropagation(),az(G)},children:V.project_settings()}),J(w,{className:"flex items-center justify-between gap-4 cursor-pointer",onSelect:(Y)=>{Y.preventDefault(),iz.mutate(G)},children:[z("span",{children:V.notification()}),z(r,{checked:G.enableNotification??!0,className:"pointer-events-none"})]}),L&&z(w,{className:"text-destructive focus:text-destructive",onClick:()=>jz(G),children:V.delete()})]})]})})]})]})},G.id)),T&&z("div",{className:_z("shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out border-dashed hover:border-orange-600/50 group",A==="create"?"scale-95":"scale-100"),onClick:nz,children:J("div",{className:"flex flex-col",children:[z("div",{className:"relative w-full aspect-square flex items-center justify-center bg-zinc-400/5 group-hover:bg-orange-600/5 transition-colors",children:z(Zz,{className:"w-8 h-8 text-zinc-400 group-hover:text-orange-600 transition-colors"})}),z("div",{className:"px-2 h-10 flex items-center justify-center bg-zinc-400/10 border-t group-hover:bg-orange-600/10 transition-colors",children:z("p",{className:"text-sm text-muted-foreground group-hover:text-orange-600 transition-colors",children:V.create_project()})})]})})]}),z(Nz,{open:H,onOpenChange:O,mode:y,teamId:Z,project:g}),z(Cz,{open:b,onOpenChange:N,children:J(fz,{children:[J(Iz,{children:[z(uz,{children:V.are_you_sure()}),J(lz,{children:[V.delete_project_warning({name:E?.name??""}),J("div",{className:"mt-4 flex flex-col gap-2 text-foreground",children:[z("span",{className:"text-sm font-medium",children:V.type_delete_to_confirm()}),z(j,{value:v,onChange:(G)=>u(G.target.value),placeholder:V.delete_placeholder(),className:"h-9",autoFocus:!0})]})]})]}),J(gz,{children:[z(pz,{disabled:c.isPending,children:V.cancel()}),z(dz,{onClick:(G)=>{G.preventDefault(),rz()},disabled:v!=="delete"||c.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:c.isPending?V.deleting():V.delete()})]})]})}),z(cz,{open:t,onOpenChange:l,title:V.team_members(),type:"team",members:x,isOwner:Qz?.role==="owner",onInvite:tz,onUpdateRole:async(G,Y)=>{await sz.mutateAsync({userId:G,role:Y})},onRemoveMember:async(G)=>{await ez.mutateAsync(G)},currentUserId:Qz?.id})]})}var VG=Bz("/teams/$teamId/")({component:JG});export{VG as Route};
|
|
1
|
+
import{fb as cz}from"./chunk-55myfmhy.js";import"./chunk-mmrtjcst.js";import{hb as r}from"./chunk-ce50f746.js";import{ib as Cz,jb as fz,kb as Iz,lb as gz,mb as uz,nb as lz,ob as dz,pb as pz}from"./chunk-d2qp8g98.js";import{Sf as Dz}from"./chunk-nh8azwsx.js";import"./chunk-ghz19a7t.js";import{Jg as m}from"./chunk-7fm1hznx.js";import{eh as yz}from"./chunk-6edadcpn.js";import{fh as C,hh as f,ih as I,jh as w,sh as bz}from"./chunk-w98wvk17.js";import{$h as X,Ak as Sz,Bj as Zz,Bk as wz,Ch as o,Eh as q,Ek as V,Fi as a,Fk as j,Gk as kz,Hk as qz,Ik as Az,Jk as Ez,Kh as n,Kk as Fz,Lk as Uz,Ph as Bz,Wj as Jz,Zh as Yz,ai as Vz,bi as Pz,bk as Kz,ii as vz,ki as Gz,mi as Tz,ni as Lz,th as Mz,vh as $z,wh as P,wk as _z,xh as z,yh as J,yi as Rz,yk as F,zh as i,zk as hz}from"./chunk-jt4yh37q.js";import{Il as Wz}from"./chunk-mgbqjbfc.js";var k=Wz($z(),1);function Nz({open:Z,onOpenChange:T,mode:L,teamId:U,project:W}){let A=i(),K=n(),[H,O]=k.useState(""),[y,B]=k.useState(!0),[g,M]=k.useState(void 0),[b,N]=k.useState(void 0),[E,D]=k.useState(!1),v=k.useRef(null);k.useEffect(()=>{if(Z)if(L==="edit"&&W)O(W.name||""),M(W.coverImageKey),N(W.coverImage),B(W.enableNotification!==!1);else O(""),M(void 0),N(void 0),B(!0)},[Z,L,W]);let u=X.api.teams[":teamId"].projects.$post,{mutate:t}=q({mutationFn:async(Q)=>{let _=await u({param:{teamId:U},json:Q});if(!_.ok)throw Error(V.failed_create_project());return await _.json()},onSuccess:(Q)=>{A.invalidateQueries({queryKey:["teams",U,"projects"]}),T(!1);let _=Q;if(_&&typeof _.id==="string")K({to:"/projects/$projectId",params:{projectId:_.id}})}}),l=X.api.projects[":projectId"].$put,{mutate:s}=q({mutationFn:async(Q)=>{let _=await l({param:{projectId:W.id},json:Q});if(!_.ok)throw Error(V.failed_update_project());return await _.json()},onSuccess:()=>{A.invalidateQueries({queryKey:["teams",U,"projects"]}),T(!1)}}),e=X.api.teams[":teamId"].files.$post,{mutate:d}=q({mutationFn:async({file:Q})=>{let _=await e({param:{teamId:U},form:{file:Q}});if(!_.ok)throw Error(V.failed_upload_file());return await _.json()},onSuccess:(Q)=>{let _=Q;if(_&&typeof _.key==="string")M(_.key);D(!1)},onError:()=>{D(!1)}}),R=(Q)=>{let _=Q.target.files?.[0];if(_){D(!0);let zz=URL.createObjectURL(_);N(zz),d({file:_})}},h=()=>{v.current?.click()},p=(Q)=>{Q.stopPropagation(),M(void 0),N(void 0)},S=()=>{if(!H.trim())return;if(L==="create")t({name:H.trim(),coverImageKey:g,enableNotification:y});else if(L==="edit"&&W?.id)s({name:H.trim(),coverImageKey:g,enableNotification:y})};return z(kz,{open:Z,onOpenChange:T,children:J(qz,{className:"sm:max-w-[550px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 backdrop-blur-md shadow-2xl p-0 gap-0",children:[J(Az,{className:"relative overflow-hidden bg-gradient-to-br from-primary/5 to-transparent p-6 border-b border-border/40",children:[z("div",{className:"absolute top-0 right-0 w-24 h-24 bg-primary/10 rounded-full blur-2xl pointer-events-none"}),z("div",{className:"absolute bottom-0 left-10 w-32 h-12 bg-primary/5 rounded-full blur-xl pointer-events-none"}),z("div",{className:"flex items-center gap-3",children:J("div",{children:[z(Fz,{className:"text-xl font-semibold tracking-tight text-foreground",children:L==="create"?V.create_new_project():V.project_settings()}),z(Uz,{className:"text-xs text-muted-foreground/80 mt-1",children:L==="create"?V.configure_new_project_description():V.manage_project_description()})]})})]}),J("div",{className:"space-y-6 p-6 max-h-[75vh] overflow-y-auto",children:[J("div",{className:"space-y-2",children:[z(m,{htmlFor:"name",className:"text-sm font-semibold tracking-tight text-foreground",children:V.project_name()}),J("div",{className:"relative",children:[z(j,{id:"name",value:H,onChange:(Q)=>O(Q.target.value),placeholder:V.project_name_placeholder(),className:"h-11 px-4 rounded-xl border-border/80 focus-visible:ring-ring/25 focus-visible:border-primary transition-all shadow-xs pr-10"}),H.trim()&&z("div",{className:"absolute inset-y-0 right-3 flex items-center",children:z(a,{className:"w-4 h-4 text-primary"})})]}),z("p",{className:"text-[11px] text-muted-foreground",children:V.project_name_hint()})]}),J("div",{className:"space-y-3 border-t border-border/40 pt-5",children:[J("div",{className:"flex items-center justify-between",children:[J(m,{className:"text-sm font-semibold tracking-tight text-foreground flex items-center gap-1.5",children:[z(Lz,{className:"w-4 h-4 text-primary"}),V.project_cover()]}),b&&J("button",{type:"button",onClick:p,className:"text-xs text-muted-foreground hover:text-destructive hover:bg-destructive/5 px-2.5 py-1 rounded-lg transition-all flex items-center gap-1 font-medium",children:[z(Kz,{className:"w-3.5 h-3.5"}),V.remove_cover()]})]}),J("div",{className:"relative aspect-square w-48 mx-auto rounded-2xl border border-dashed border-border flex items-center justify-center cursor-pointer overflow-hidden group shadow-inner bg-muted/20 transition-all duration-300 hover:border-primary/50 hover:bg-muted/40",onClick:h,children:[z("input",{type:"file",ref:v,className:"hidden",accept:"image/*",onChange:R}),E&&z("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:J("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[z(Gz,{className:"w-4 h-4 animate-spin text-primary"}),z("span",{className:"text-xs font-semibold text-foreground",children:V.uploading()})]})}),b?J(P,{children:[z("img",{src:b,alt:V.cover_preview(),className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"}),J("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.5 text-white z-10",children:[z(Jz,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),z("span",{className:"text-xs font-semibold",children:V.upload_image()})]})]}):J("div",{className:"flex flex-col items-center gap-2 text-center p-4",children:[z("div",{className:"p-2.5 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:z(Jz,{className:"w-4 h-4 text-muted-foreground"})}),J("div",{children:[z("p",{className:"text-xs font-medium text-foreground",children:V.upload_cover()}),z("p",{className:"text-[11px] text-muted-foreground mt-0.5 max-w-[140px] mx-auto leading-normal",children:V.upload_cover_hint()})]})]})]})]}),J("div",{className:"space-y-3 border-t border-border/40 pt-5",children:[J(m,{className:"text-sm font-semibold tracking-tight text-foreground flex items-center gap-1.5",children:[z(Tz,{className:"w-4 h-4 text-primary"}),V.project_preferences()]}),J("div",{className:"flex items-start justify-between rounded-xl border border-border/50 bg-muted/10 p-4 transition-all duration-300 hover:bg-muted/20",children:[J("div",{className:"space-y-1 pr-4",children:[J("div",{className:"text-sm font-semibold flex items-center gap-2 text-foreground",children:[z(Rz,{className:"w-4 h-4 text-primary"}),V.activity_notifications()]}),z("p",{className:"text-xs text-muted-foreground leading-normal",children:V.activity_notifications_description()})]}),z(r,{checked:y,onCheckedChange:B,disabled:E,className:"mt-0.5"})]})]})]}),J(Ez,{className:"flex items-center justify-end gap-3 px-6 py-4 bg-muted/20 border-t border-border/40",children:[z(F,{type:"button",variant:"ghost",onClick:()=>T(!1),disabled:E,className:"rounded-xl h-10 px-4 hover:bg-muted font-medium text-sm text-muted-foreground hover:text-foreground transition-colors",children:V.cancel()}),z(F,{type:"submit",onClick:S,disabled:!H.trim()||E,className:"rounded-xl h-10 px-5 bg-primary text-primary-foreground hover:bg-primary/90 font-semibold text-sm shadow-lg shadow-primary/10 hover:shadow-primary/20 active:scale-98 transition-all flex items-center gap-2",children:E?J(P,{children:[z(Gz,{className:"w-4 h-4 animate-spin"}),V.processing()]}):L==="create"?V.create_project():V.save_changes()})]})]})})}function Oz({sortBy:Z,sortDirection:T,onSortChange:L}){let U=(H)=>{L(H,T)},W=()=>{L(Z,T==="asc"?"desc":"asc")},A=(H)=>{switch(H){case"name":return V.sort_name();case"created_at":return V.sort_created();case"updated_at":return V.sort_updated();default:return H}},K=T==="asc";return J(C,{children:[z(f,{asChild:!0,children:J(F,{variant:"outline",className:"gap-2 bg-muted/50",children:[z("span",{className:"text-muted-foreground",children:V.sorted_by_label()}),z("span",{className:"font-medium text-foreground",children:A(Z)})]})}),J(I,{align:"end",className:"w-56 p-2",children:[z("div",{className:"text-xs font-semibold text-muted-foreground mb-2 px-2",children:V.sort_by()}),J(C,{children:[z(f,{asChild:!0,children:J(F,{variant:"ghost",className:"w-full justify-between font-normal px-2 h-10 bg-muted/50 hover:bg-muted mb-2 border",children:[z("span",{children:A(Z)}),z(Vz,{className:"h-4 w-4 opacity-50"})]})}),z(I,{className:"w-52",children:["name","created_at","updated_at"].map((H)=>J(w,{onClick:()=>U(H),className:"justify-between",children:[A(H),Z===H&&z(a,{className:"h-4 w-4"})]},H))})]}),J(F,{variant:"ghost",className:"w-full justify-between font-normal px-2 h-10 bg-muted/50 hover:bg-muted border",onClick:W,children:[z("span",{className:"text-muted-foreground",children:Z==="name"?K?z(P,{children:V.sort_a_to_z()}):z(P,{children:V.sort_z_to_a()}):K?z(P,{children:V.sort_oldest_to_newest()}):z(P,{children:V.sort_newest_to_oldest()})}),K?z(Pz,{className:"h-4 w-4 opacity-50"}):z(Vz,{className:"h-4 w-4 opacity-50"})]})]})]})}var $=Wz($z(),1);function JG(){let{teamId:Z}=VG.useParams(),{canEdit:T,canAdmin:L}=bz(),U=n(),W=i(),[A,K]=$.useState(null),[H,O]=$.useState(!1),[y,B]=$.useState("create"),[g,M]=$.useState(void 0),[b,N]=$.useState(!1),[E,D]=$.useState(void 0),[v,u]=$.useState(""),[t,l]=$.useState(!1),{metadata:s,setMetadata:e}=Dz(),d=`team:${Z}:projects:sort`,R=s[d],[h,p]=$.useState(()=>R?.sortBy||"name"),[S,Q]=$.useState(()=>R?.sortDirection||"asc");$.useEffect(()=>{if(R?.sortBy&&R.sortBy!==h)p(R.sortBy);if(R?.sortDirection&&R.sortDirection!==S)Q(R.sortDirection)},[R]);let _=X.api.teams[":teamId"].projects.$get,{data:zz}=o({queryKey:["teams",Z,"projects",h,S],queryFn:async()=>{let G=await _({param:{teamId:Z},query:{sortBy:h,sortDirection:S}});if(!G.ok)throw Error("Failed to fetch projects");return await G.json()},placeholderData:Mz}),{data:Hz}=o({queryKey:["teams",Z,"members"],queryFn:async()=>{let G=await X.api.teams[":teamId"].members.$get({param:{teamId:Z},query:{}});if(!G.ok)throw Error("Failed to fetch members");return await G.json()}}),{data:Qz}=o({queryKey:["teams",Z,"me"],queryFn:async()=>{let G=await X.api.teams[":teamId"].me.$get({param:{teamId:Z}});if(!G.ok)throw Error("Failed to fetch me");return await G.json()}}),xz=X.api.teams[":teamId"].invite.$post,mz=q({mutationFn:async(G)=>{let Y=await xz(G);if(!Y.ok)throw Error("Failed to invite");return await Y.json()}}),c=q({mutationFn:async(G)=>{if(!(await X.api.projects[":projectId"].$delete({param:{projectId:G}})).ok)throw Error("Failed to delete project")},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"projects"]})}}),iz=q({mutationFn:async(G)=>{let Y=await X.api.projects[":projectId"].$put({param:{projectId:G.id},json:{enableNotification:!G.enableNotification}});if(!Y.ok)throw Error("Failed to update project notification settings");return await Y.json()},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"projects"]}),Yz.success(V.project_notification_updated())},onError:(G)=>{Yz.error(G instanceof Error?G.message:V.failed_update_project_notification())}}),Xz=()=>{B("create"),M(void 0),O(!0)},nz=()=>{K("create"),setTimeout(()=>{K(null)},100),setTimeout(()=>{Xz()},200)},az=(G)=>{B("edit"),M(G),O(!0)},jz=(G)=>{D(G),u(""),N(!0)},rz=async()=>{if(E&&v==="delete")try{await c.mutateAsync(E.id),N(!1)}catch(G){console.error(G)}},oz=(G,Y)=>{if(Y.detail>1)return;K(G),setTimeout(()=>{K(null)},100),setTimeout(()=>{U({to:"/projects/$projectId",params:{projectId:G}})},200)},tz=async(G)=>{return(await mz.mutateAsync({param:{teamId:Z},json:{role:G}})).code},sz=q({mutationFn:async({userId:G,role:Y})=>{if(!(await X.api.teams[":teamId"].members[":userId"].$patch({param:{teamId:Z,userId:G},json:{role:Y}})).ok)throw Error("Failed to update member role")},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"members"]})}}),ez=q({mutationFn:async(G)=>{if(!(await X.api.teams[":teamId"].members[":userId"].$delete({param:{teamId:Z,userId:G}})).ok)throw Error("Failed to remove member")},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"members"]})}}),zG=(G)=>{if(!G)return"??";return G.split(" ").map((Y)=>Y[0]).slice(0,2).join("").toUpperCase()},GG=(G,Y)=>{p(G),Q(Y),e(Z,d,{sortBy:G,sortDirection:Y})},x=Array.isArray(Hz)?Hz:[];return J("div",{className:"flex-1 overflow-y-auto p-4",children:[J("div",{className:"flex flex-wrap items-center justify-between mb-4 gap-4",children:[z("h1",{className:"text-2xl font-bold",children:V.projects()}),J("div",{className:"flex flex-wrap items-center gap-4",children:[J("div",{className:"flex items-center -space-x-2 cursor-pointer hover:opacity-90",onClick:()=>l(!0),"data-testid":"team-members-trigger",children:[x.slice(0,3).map((G)=>J(hz,{className:"border-2 border-background w-8 h-8",children:[G.image&&z(Sz,{src:G.image,alt:G.name,className:"object-cover"}),z(wz,{className:"text-[10px]",children:zG(G.name)})]},G.id)),x.length>3&&J("div",{className:"flex items-center justify-center w-8 h-8 rounded-full border-2 border-background bg-muted text-[10px] font-medium",children:["+",x.length-3]})]}),z(Oz,{sortBy:h,sortDirection:S,onSortChange:GG}),T&&J(F,{className:"bg-orange-600 hover:bg-orange-700 text-white gap-2",onClick:Xz,children:[z(Zz,{className:"w-4 h-4"}),V.create_project()]})]})]}),J("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 gap-4",children:[zz?.data?.map((G)=>z("div",{className:_z("shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out",A===G.id?"scale-95":"scale-100"),onClick:(Y)=>oz(G.id,Y),children:J("div",{className:"flex flex-col",children:[J("div",{className:"relative w-full h-full aspect-square flex items-center justify-center bg-zinc-400/20",children:[G.coverImage?z("img",{src:G.coverImage,alt:G.name,className:"w-full h-full object-cover rounded"}):J("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 180.95 164.7",preserveAspectRatio:"xMidYMid slice",className:"w-full h-full object-cover rounded",children:[z("polygon",{fill:"#FC9F8E",points:"0 18.5 0 76.0 151.69 164.7 180.95 164.7 180.95 113.6"}),z("polygon",{fill:"#FEBAB8",points:"0 0 74.58 61.5 90.53 51.6 110.33 63.9 180.95 18.9 180.95 0"}),z("polyline",{fill:"#FAA5A5",points:"0 18.5 74.58 61.5 90.53 51.6 110.33 63.9 180.95 18.9 180.95 0 0 0"}),z("polygon",{fill:"#EC5B6C",points:"0 76.0 0 164.7 151.69 164.7"}),z("polygon",{fill:"#E85C71",points:"180.95 18.9 110.33 63.9 117.37 68.0 117.26 73.4 180.95 113.6"}),z("polygon",{fill:"#C8405B",points:"117.26 73.4 117.37 99.0 90.53 114.9 174.35 164.7 180.95 164.7 180.95 113.6"}),z("polygon",{fill:"#FFCCBE",points:"90.53 51.6 63.69 68.1 90.53 83.4"}),z("path",{fill:"#FB9991",d:"M 90.53 51.6 L 90.53 61.3 L 100.87 67.4 L 90.53 73.5 L 90.53 83.4 L 117.37 68.0 C 117.15 67.6 90.53 51.6 90.53 51.6 Z"}),z("path",{fill:"#FFEACD",d:"M 63.69 68.1 C 63.47 68.5 64.02 99.3 64.02 99.3 C 64.02 99.3 64.46 99.6 64.9 99.9 L 90.53 83.4 L 63.69 68.1 Z"}),z("polygon",{fill:"#FFCFB5",points:"64.02 99.3 90.53 114.9 90.53 83.4"}),z("path",{fill:"#F67D73",d:"M 90.53 83.4 L 90.53 114.9 L 117.37 99.0 Z"}),z("path",{fill:"#F26560",d:"M 90.53 83.4 L 117.37 99.0 L 117.37 68.0 Z"}),z("polygon",{fill:"#EB5F5B",points:"80.08 67.5 90.53 73.5 90.53 61.3"}),z("polygon",{fill:"#DB4D50",points:"90.53 61.3 90.53 73.5 100.87 67.4"})]}),z("div",{className:"absolute bottom-0 left-0 w-full h-[65%] bg-linear-to-t from-black/35 to-black/0"}),z("p",{className:"absolute left-1 bottom-2 text-white",children:G.name})]}),J("div",{className:"px-2 h-10 flex justify-between items-center",children:[J("p",{className:"truncate pr-1 text-xs text-muted-foreground",children:[V.updated_ago()," ",yz(G.updatedAt??"")]}),z("div",{onClick:(Y)=>Y.stopPropagation(),children:J(C,{modal:!1,children:[z(f,{asChild:!0,children:z("button",{className:"hover:bg-muted outline-none flex px-1",children:z(vz,{className:"w-5 h-5 text-muted-foreground"})})}),J(I,{align:"end",children:[T&&z(w,{onClick:(Y)=>{Y.stopPropagation(),az(G)},children:V.project_settings()}),J(w,{className:"flex items-center justify-between gap-4 cursor-pointer",onSelect:(Y)=>{Y.preventDefault(),iz.mutate(G)},children:[z("span",{children:V.notification()}),z(r,{checked:G.enableNotification??!0,className:"pointer-events-none"})]}),L&&z(w,{className:"text-destructive focus:text-destructive",onClick:()=>jz(G),children:V.delete()})]})]})})]})]})},G.id)),T&&z("div",{className:_z("shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out border-dashed hover:border-orange-600/50 group",A==="create"?"scale-95":"scale-100"),onClick:nz,children:J("div",{className:"flex flex-col",children:[z("div",{className:"relative w-full aspect-square flex items-center justify-center bg-zinc-400/5 group-hover:bg-orange-600/5 transition-colors",children:z(Zz,{className:"w-8 h-8 text-zinc-400 group-hover:text-orange-600 transition-colors"})}),z("div",{className:"px-2 h-10 flex items-center justify-center bg-zinc-400/10 border-t group-hover:bg-orange-600/10 transition-colors",children:z("p",{className:"text-sm text-muted-foreground group-hover:text-orange-600 transition-colors",children:V.create_project()})})]})})]}),z(Nz,{open:H,onOpenChange:O,mode:y,teamId:Z,project:g}),z(Cz,{open:b,onOpenChange:N,children:J(fz,{children:[J(Iz,{children:[z(uz,{children:V.are_you_sure()}),J(lz,{children:[V.delete_project_warning({name:E?.name??""}),J("div",{className:"mt-4 flex flex-col gap-2 text-foreground",children:[z("span",{className:"text-sm font-medium",children:V.type_delete_to_confirm()}),z(j,{value:v,onChange:(G)=>u(G.target.value),placeholder:V.delete_placeholder(),className:"h-9",autoFocus:!0})]})]})]}),J(gz,{children:[z(pz,{disabled:c.isPending,children:V.cancel()}),z(dz,{onClick:(G)=>{G.preventDefault(),rz()},disabled:v!=="delete"||c.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:c.isPending?V.deleting():V.delete()})]})]})}),z(cz,{open:t,onOpenChange:l,title:V.team_members(),type:"team",members:x,isOwner:Qz?.role==="owner",onInvite:tz,onUpdateRole:async(G,Y)=>{await sz.mutateAsync({userId:G,role:Y})},onRemoveMember:async(G)=>{await ez.mutateAsync(G)},currentUserId:Qz?.id})]})}var VG=Bz("/teams/$teamId/")({component:JG});export{VG as Route};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Fa as BK,Ha as gJ}from"./chunk-bpb0szs5.js";import{bb as ZJ}from"./chunk-nabagpah.js";import{fb as ZK,gb as _K,hb as $K,ib as GK,jb as zK,kb as QK,lb as HK,mb as UK}from"./chunk-3vbx3x11.js";import{vf as $J}from"./chunk-z544s59c.js";import{jg as QJ,lg as HJ,mg as UJ,ng as w,rg as KK,wg as WK}from"./chunk-38hp9gfh.js";import{Ag as iJ,Bg as J,Cg as X,Dg as lJ,Dh as rJ,Fi as wJ,Fj as W,Gj as XK,Hj as TJ,Ig as v,Ij as RJ,Jg as _J,Jj as SJ,Kh as oJ,Kj as fJ,Lj as hJ,Mg as dJ,Mh as sJ,Mi as JK,Mj as YK,Ng as h,Og as GJ,Oh as XJ,Ph as YJ,Rh as tJ,Ui as uJ,Xh as DJ,bh as z,ci as eJ,dh as U,ki as kJ,mh as zJ,oh as p,sh as nJ,uh as aJ,xj as O,zg as NK,zj as N}from"./chunk-ersxsrz8.js";import{Jk as vK}from"./chunk-8tnq43k9.js";var _=vK(NK(),1);function cK({teamId:B,projectId:Z,projectName:$,rootFolderId:P,dragState:b,onSelect:M,selectedFolderId:A,hideCollections:m,hideShares:C,ancestorFolders:D}){let q=GJ(),Q=lJ(),{canEdit:V}=WK(Z),j=dJ({from:"/projects/$projectId/recently-deleted",shouldThrow:!1}),[L,r]=_.useState(!0),[T,BJ]=_.useState(!0),[u,bJ]=_.useState(!0),{data:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:R}=_J({queryKey:["shares",Z],queryFn:async({pageParam:K})=>{let Y=await U.api.projects[":projectId"].shares.$get({param:{projectId:Z},query:{first:"20",after:K}});if(!Y.ok)throw Error(W.failed_fetch_share_links());return await Y.json()},initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0,enabled:!!Z}),{data:l,fetchNextPage:o,hasNextPage:d,isFetchingNextPage:n}=_J({queryKey:["collections",Z],queryFn:async({pageParam:K})=>{let Y=await U.api.projects[":projectId"].collections.$get({param:{projectId:Z},query:{first:"20",after:K}});if(!Y.ok)throw Error(W.failed_fetch_collections());return await Y.json()},initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0,enabled:!!Z}),{ref:qJ,inView:s}=$J(),{ref:VJ,inView:t}=$J();_.useEffect(()=>{if(s&&d&&!n)o()},[s,d,n,o]),_.useEffect(()=>{if(t&&g&&!R)i()},[t,g,R,i]);let AJ=_.useMemo(()=>l?.pages.flatMap((K)=>K.data)||[],[l]),OJ=_.useMemo(()=>c?.pages.flatMap((K)=>K.data)||[],[c]),{mutate:PJ}=v({mutationFn:async()=>{let K=await U.api.projects[":projectId"].collections.$post({param:{projectId:Z},json:{name:W.untitled_collection(),filter:{sourceFolderId:P,searchFilter:{conditions:[],recursively:!0}}}});if(!K.ok)throw Error(W.failed_create_collection());return await K.json()},onSuccess:(K)=>{Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_created()),q({to:"/projects/$projectId/collections/$collectionId",params:{projectId:Z,collectionId:K.id}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:MJ}=v({mutationFn:async()=>{let K=await U.api.projects[":projectId"].shares.$post({param:{projectId:Z},json:{name:new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}});if(!K.ok)throw Error(W.failed_create_share_link());return await K.json()},onSuccess:(K)=>{Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_created()),q({to:"/projects/$projectId/shares/$shareId",params:{projectId:Z,shareId:K.id}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),e=h({from:"/projects/$projectId/collections/$collectionId",shouldThrow:!1}),LJ=h({from:"/projects/$projectId/shares/$shareId",shouldThrow:!1}),G=h({from:"/projects/$projectId/folders/$folderId",shouldThrow:!1}),[y,yJ]=_.useState(null),[F,EJ]=_.useState("collection"),[E,JJ]=_.useState(""),[qK,k]=_.useState(!1),[vJ,NJ]=_.useState(null),[S,CJ]=_.useState("collection"),[VK,f]=_.useState(!1),{mutate:IJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.folders[":folderId"].$put({param:{folderId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_folder());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["search",B]}),Q.invalidateQueries({queryKey:["folders"]}),z.success(W.folder_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:AK}=v({mutationFn:async(K)=>{if(!(await U.api.folders.$delete({json:{ids:[K]}})).ok)throw Error(W.failed_delete_folder());return K},onSuccess:(K)=>{if(Q.invalidateQueries({queryKey:["search",B]}),Q.invalidateQueries({queryKey:["folders"]}),z.success(W.folder_deleted()),f(!1),G?.folderId===K)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),[OK,a]=_.useState(!1),[KJ,xJ]=_.useState(!1),[FJ,pJ]=_.useState([]),PK=async(K)=>{a(!0),xJ(!0),pJ([]);try{let Y=await U.api.files["download-links"].$post({json:{ids:[K]}});if(!Y.ok)throw Error(W.failed_to_prepare_download_links());let H=await Y.json();pJ(H.files)}catch(Y){z.error(W.failed_to_prepare_download_links()),a(!1),console.error(Y)}finally{xJ(!1)}},MK=()=>{let K=[...FJ];if(a(!1),K.length===0)return;z.info(W.starting_download_files({count:K.length}),{duration:5000});let Y=(WJ)=>new Promise((I)=>setTimeout(I,WJ));(async()=>{for(let I=0;I<K.length;I+=5){let EK=K.slice(I,I+5);for(let cJ of EK){let x=document.createElement("a");x.href=cJ.url,x.download=cJ.name,x.target="_blank",document.body.appendChild(x),x.click(),x.remove()}await Y(1000)}})().catch((WJ)=>{console.error("Background downloads failed:",WJ),z.error(W.some_downloads_failed())})},{mutate:mJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.collections[":collectionId"].$patch({param:{collectionId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_collection());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:LK}=v({mutationFn:async(K)=>{let Y=await U.api.collections[":collectionId"].$delete({param:{collectionId:K}});if(!Y.ok)throw Error(W.failed_delete_collection());return await Y.json()},onSuccess:(K,Y)=>{if(Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_deleted()),f(!1),e?.collectionId===Y)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:jJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.shares[":shareId"].$put({param:{shareId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_share_link());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:yK}=v({mutationFn:async(K)=>{if(!(await U.api.shares[":shareId"].$delete({param:{shareId:K}})).ok)throw Error(W.failed_delete_share_link());return K},onSuccess:(K)=>{if(Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_deleted()),f(!1),LJ?.shareId===K)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}});return X("div",{className:"flex flex-col h-full overflow-hidden p-3 gap-4 bg-background",children:[X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4",L?"flex-1 min-h-[50%] h-full":"flex-none h-[44px] max-h-[44px]"),children:[J("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>r(!L),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.folder_tree_assets()}),L?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]})}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",L?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[J(bK,{teamId:B,projectId:Z,folder:{id:P,name:$,type:"folder",sizeByte:0,fileCount:0,status:"processed",createdAt:"",updatedAt:""},level:0,isRoot:!0,dragState:b,onSelect:M,selectedFolderId:A,canEdit:V,onRenameTrigger:(K,Y)=>{yJ(K),EJ("folder"),JJ(Y),k(!0)},onDeleteTrigger:(K)=>{NJ(K),CJ("folder"),f(!0)},onDownloadTrigger:(K)=>{PK(K)},ancestorFolders:D},P),V&&X("div",{className:O("group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",j&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>q({to:"/projects/$projectId/recently-deleted",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(uJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.recently_deleted()})]})]})})]}),!m&&X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4",T?"flex-1 min-h-0 h-full":"flex-none h-[44px] max-h-[44px]"),children:[X("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:[X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>BJ(!T),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.collections()}),T?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]}),V&&J("button",{"data-testid":"create-collection",onClick:()=>PJ(),className:"text-muted-foreground hover:text-foreground flex-none",children:J(wJ,{className:"h-3.5 w-3.5"})})]}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",T?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[X("div",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>q({to:"/projects/$projectId/collections",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(kJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.all_collections_count({count:l?.pages[0]?.pageInfo?.total||0})})]}),AJ.map((K)=>{let Y=e?.collectionId===K.id;return X("div",{className:O("group flex cursor-pointer items-center justify-between rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",Y&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>q({to:"/projects/$projectId/collections/$collectionId",params:{projectId:Z,collectionId:K.id}}),children:[X("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[J("div",{className:"flex h-4 w-4 items-center justify-center shrink-0",children:J(rJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"truncate text-sidebar-foreground flex-1",children:K.name})]}),V&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(H)=>H.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[J(w,{onClick:()=>{yJ(K.id),EJ("collection"),JJ(K.name),k(!0)},children:W.rename()}),J(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{NJ(K.id),CJ("collection"),f(!0)},children:W.delete()})]})]})})]},K.id)}),J("div",{ref:qJ,className:"h-1"}),n&&J("div",{className:"flex justify-center p-2",children:J(p,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]})})]}),!C&&X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out",u?"flex-1 min-h-0 h-full":"flex-none h-[44px] max-h-[44px]"),children:[X("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:[X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>bJ(!u),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.share_links()}),u?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]}),V&&J("div",{className:"flex items-center gap-1 flex-none",children:J("button",{onClick:()=>MJ(),className:"text-muted-foreground hover:text-foreground",children:J(wJ,{className:"h-3.5 w-3.5"})})})]}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",u?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[X("div",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>q({to:"/projects/$projectId/shares",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(kJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.all_share_links_count({count:c?.pages[0]?.pageInfo?.total||0})})]}),OJ.map((K)=>J(CK,{link:K,projectId:Z,dragState:b,canEdit:V,onRenameTrigger:(Y,H)=>{yJ(Y),EJ("share"),JJ(H),k(!0)},onDeleteTrigger:(Y)=>{NJ(Y),CJ("share"),f(!0)}},K.id)),J("div",{ref:VJ,className:"h-1"}),R&&J("div",{className:"flex justify-center p-2",children:J(p,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]})})]}),J(TJ,{open:qK,onOpenChange:k,children:X(RJ,{onClick:(K)=>K.stopPropagation(),children:[J(SJ,{children:J(hJ,{children:F==="collection"?W.rename_collection():F==="share"?W.rename_share_link():W.rename_folder()})}),J("div",{className:"py-4",children:J(XK,{value:E,onChange:(K)=>JJ(K.target.value),placeholder:W.enter_new_name(),onKeyDown:(K)=>{if(K.key==="Enter"&&E.trim()){if(F==="collection")mJ({id:y,name:E});else if(F==="share")jJ({id:y,name:E});else if(F==="folder")IJ({id:y,name:E})}}})}),X(fJ,{children:[J(N,{variant:"ghost",onClick:()=>k(!1),children:W.cancel()}),J(N,{disabled:!E.trim(),onClick:()=>{if(F==="collection")mJ({id:y,name:E});else if(F==="share")jJ({id:y,name:E});else if(F==="folder")IJ({id:y,name:E})},children:W.rename()})]})]})}),J(ZK,{open:VK,onOpenChange:f,children:X(_K,{onClick:(K)=>K.stopPropagation(),children:[X($K,{children:[J(zK,{children:S==="collection"?W.delete_collection_confirm():S==="share"?W.delete_share_link_confirm():W.delete_folder_confirm()}),J(QK,{children:W.delete_confirm_description({type:S==="collection"?W.collection():S==="share"?W.share_link():W.folder().toLowerCase()})})]}),X(GK,{children:[J(UK,{children:W.cancel()}),J(HK,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{if(S==="collection")LK(vJ);else if(S==="share")yK(vJ);else if(S==="folder")AK(vJ)},children:W.delete()})]})]})}),J(TJ,{open:OK,onOpenChange:a,children:X(RJ,{className:"sm:max-w-md",children:[X(SJ,{children:[J(hJ,{children:KJ?W.preparing_download():W.confirm_download()}),J(YK,{children:KJ?W.resolving_files_wait():W.folder_files_download_description()})]}),KJ?X("div",{className:"space-y-4 py-6 flex flex-col items-center justify-center",children:[J(p,{className:"h-8 w-8 animate-spin text-primary"}),J("span",{className:"text-sm font-medium text-muted-foreground mt-2",children:W.preparing_download_links()})]}):X("div",{className:"space-y-4 py-2",children:[J("div",{className:"text-sm text-muted-foreground",children:W.download_includes_files({count:FJ.length})}),X("div",{className:"flex items-start gap-3 p-3 text-sm rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 border border-amber-200 dark:border-amber-900/30",children:[J(aJ,{className:"h-5 w-5 shrink-0 mt-0.5"}),X("div",{children:[J("p",{className:"font-semibold",children:W.no_folder_structure()}),J("p",{className:"mt-0.5 text-xs text-amber-700/90 dark:text-amber-400/90",children:W.folder_structure_warning()})]})]})]}),J(fJ,{children:!KJ?X(iJ,{children:[J(N,{variant:"outline",onClick:()=>a(!1),children:W.cancel()}),X(N,{onClick:MK,className:"gap-2",disabled:FJ.length===0,children:[J(DJ,{className:"h-4 w-4"}),W.start_download()]})]}):J(N,{disabled:!0,variant:"outline",children:W.cancel()})})]})})]})}function CK({link:B,projectId:Z,dragState:$,canEdit:P,onRenameTrigger:b,onDeleteTrigger:M}){let A=GJ(),C=h({from:"/projects/$projectId/shares/$shareId",shouldThrow:!1})?.shareId===B.id,{ref:D,isDropTarget:q}=gJ({id:`share:${B.id}`,data:{type:"share-link",id:B.id}}),Q=!!$?.isActive;return X("div",{ref:D,className:O("group flex cursor-pointer items-center justify-between rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",C&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium",q&&Q&&"bg-sidebar-accent ring-2 ring-primary ring-inset"),onClick:()=>A({to:"/projects/$projectId/shares/$shareId",params:{projectId:Z,shareId:B.id}}),children:[X("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[J("div",{className:"flex h-4 w-4 items-center justify-center shrink-0",children:J(JK,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"truncate text-sidebar-foreground flex-1",children:B.name})]}),P&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(V)=>V.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[J(w,{onClick:()=>{b(B.id,B.name)},children:W.rename()}),J(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{M(B.id)},children:W.delete()})]})]})})]})}function bK({teamId:B,projectId:Z,folder:$,level:P,isRoot:b,dragState:M,onSelect:A,selectedFolderId:m,canEdit:C,onRenameTrigger:D,onDeleteTrigger:q,onDownloadTrigger:Q,ancestorFolders:V}){let j=_.useMemo(()=>{return V?.some((G)=>G.id===$.id)??!1},[V,$.id]),[L,r]=_.useState(b||j);_.useEffect(()=>{if(j)r(!0)},[j]);let T=GJ(),BJ=h({from:"/projects/$projectId/folders/$folderId",select:(G)=>({folderId:G.folderId}),shouldThrow:!1}),u=h({from:"/projects/$projectId/",shouldThrow:!1}),bJ=b?!!u:BJ?.folderId===$.id,{data:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:R,isLoading:l}=_J({queryKey:["folders",$.id,"children",{assetType:"folder"}],queryFn:async({pageParam:G})=>{let y=await U.api.folders[":folderId"].children.$get({param:{folderId:$.id},query:{assetType:"folder",after:G,first:"20"}});if(!y.ok)throw Error(W.failed_to_fetch_folder_children());return await y.json()},initialPageParam:"",getNextPageParam:(G)=>{return G.pageInfo?.cursor||void 0},enabled:L||!!b}),{ref:o,inView:d}=$J();_.useEffect(()=>{if(d&&g&&!R)i()},[d,g,R,i]);let n=c?.pages.flatMap((G)=>G.data??[])??[],qJ=(G)=>{G.stopPropagation(),r(!L)},s=()=>{if(A){A($);return}if(b)T({to:"/projects/$projectId",params:{projectId:Z}});else T({to:"/projects/$projectId/folders/$folderId",params:{projectId:Z,folderId:$.id}})},{ref:VJ,isDragging:t}=BK({id:`tree:${$.id}`,data:{type:"folder",item:$},disabled:!!b||!!A||!C}),{ref:AJ,isDropTarget:OJ}=gJ({id:`tree:${$.id}`,data:{type:"folder",item:$},disabled:M?.draggedIds.has($.id)||!!A||!C}),PJ=(G)=>{VJ(G),AJ(G)},MJ=_.useMemo(()=>{if(A)return!1;if(!M?.isActive)return!1;if(M.draggedIds.has($.id))return!1;return!0},[M,$.id,A]),e=OJ&&MJ,LJ=m===$.id;return X("div",{children:[X("div",{ref:PJ,className:O("group flex cursor-pointer items-center gap-1 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",(bJ||LJ)&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium",t&&"opacity-50",e&&"bg-sidebar-accent ring-2 ring-primary ring-inset"),style:{...b?{}:{paddingLeft:`${P*12+8}px`}},onClick:s,children:[!b&&J("button",{onClick:qJ,className:"flex h-4 w-4 items-center justify-center shrink-0",children:L?J(oJ,{className:"h-3 w-3"}):J(sJ,{className:"h-3 w-3"})}),b?J(tJ,{className:"h-4 w-4 text-sidebar-primary shrink-0"}):J(eJ,{className:"h-4 w-4 text-sidebar-primary shrink-0"}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:$.name}),C&&!b&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(G)=>G.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[X(w,{onClick:()=>{D($.id,$.name)},children:[J(nJ,{className:"mr-2 h-4 w-4"}),W.rename()]}),X(w,{onClick:()=>{Q($.id)},children:[J(DJ,{className:"mr-2 h-4 w-4"}),W.download()]}),J(KK,{}),X(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{q($.id)},children:[J(uJ,{className:"mr-2 h-4 w-4"}),W.delete()]})]})]})})]}),L&&X("div",{children:[l&&J("div",{className:"flex items-center justify-center p-2",style:{paddingLeft:`${(P+1)*12+8}px`},children:J(p,{className:"h-4 w-4 animate-spin"})}),n.map((G)=>J(bK,{teamId:B,projectId:Z,folder:G,level:P+1,dragState:M,onSelect:A,selectedFolderId:m,canEdit:C,onRenameTrigger:D,onDeleteTrigger:q,onDownloadTrigger:Q,ancestorFolders:V},G.id)),g&&J("div",{ref:o,className:"flex items-center justify-center p-2",style:{paddingLeft:`${(P+1)*12+8}px`},children:R&&J(p,{className:"h-4 w-4 animate-spin"})})]})]})}
|
|
2
|
-
export{cK as
|
|
1
|
+
import{$a as BK,bb as gJ}from"./chunk-ef5v7gta.js";import{db as ZJ}from"./chunk-gct52xks.js";import{ib as ZK,jb as _K,kb as $K,lb as GK,mb as zK,nb as QK,ob as HK,pb as UK}from"./chunk-d2qp8g98.js";import{Dg as $J}from"./chunk-n198tewr.js";import{fh as QJ,hh as HJ,ih as UJ,jh as w,nh as KK,sh as WK}from"./chunk-w98wvk17.js";import{$h as U,Bj as wJ,Eh as v,Ek as W,Fh as _J,Fk as XK,Gi as oJ,Gk as TJ,Hk as RJ,Ih as dJ,Ii as sJ,Ik as SJ,Jh as h,Jk as fJ,Kh as GJ,Ki as XJ,Kj as JK,Kk as hJ,Li as YJ,Lk as YK,Ni as tJ,Ti as DJ,Tj as uJ,Zh as z,_i as eJ,gj as kJ,ii as zJ,ki as p,oi as nJ,qi as aJ,vh as NK,wh as iJ,wk as O,xh as J,yh as X,yk as N,zh as lJ,zi as rJ}from"./chunk-jt4yh37q.js";import{Il as vK}from"./chunk-mgbqjbfc.js";var _=vK(NK(),1);function cK({teamId:B,projectId:Z,projectName:$,rootFolderId:P,dragState:b,onSelect:M,selectedFolderId:A,hideCollections:m,hideShares:C,ancestorFolders:D}){let q=GJ(),Q=lJ(),{canEdit:V}=WK(Z),j=dJ({from:"/projects/$projectId/recently-deleted",shouldThrow:!1}),[L,r]=_.useState(!0),[T,BJ]=_.useState(!0),[u,bJ]=_.useState(!0),{data:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:R}=_J({queryKey:["shares",Z],queryFn:async({pageParam:K})=>{let Y=await U.api.projects[":projectId"].shares.$get({param:{projectId:Z},query:{first:"20",after:K}});if(!Y.ok)throw Error(W.failed_fetch_share_links());return await Y.json()},initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0,enabled:!!Z}),{data:l,fetchNextPage:o,hasNextPage:d,isFetchingNextPage:n}=_J({queryKey:["collections",Z],queryFn:async({pageParam:K})=>{let Y=await U.api.projects[":projectId"].collections.$get({param:{projectId:Z},query:{first:"20",after:K}});if(!Y.ok)throw Error(W.failed_fetch_collections());return await Y.json()},initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0,enabled:!!Z}),{ref:qJ,inView:s}=$J(),{ref:VJ,inView:t}=$J();_.useEffect(()=>{if(s&&d&&!n)o()},[s,d,n,o]),_.useEffect(()=>{if(t&&g&&!R)i()},[t,g,R,i]);let AJ=_.useMemo(()=>l?.pages.flatMap((K)=>K.data)||[],[l]),OJ=_.useMemo(()=>c?.pages.flatMap((K)=>K.data)||[],[c]),{mutate:PJ}=v({mutationFn:async()=>{let K=await U.api.projects[":projectId"].collections.$post({param:{projectId:Z},json:{name:W.untitled_collection(),filter:{sourceFolderId:P,searchFilter:{conditions:[],recursively:!0}}}});if(!K.ok)throw Error(W.failed_create_collection());return await K.json()},onSuccess:(K)=>{Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_created()),q({to:"/projects/$projectId/collections/$collectionId",params:{projectId:Z,collectionId:K.id}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:MJ}=v({mutationFn:async()=>{let K=await U.api.projects[":projectId"].shares.$post({param:{projectId:Z},json:{name:new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}});if(!K.ok)throw Error(W.failed_create_share_link());return await K.json()},onSuccess:(K)=>{Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_created()),q({to:"/projects/$projectId/shares/$shareId",params:{projectId:Z,shareId:K.id}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),e=h({from:"/projects/$projectId/collections/$collectionId",shouldThrow:!1}),LJ=h({from:"/projects/$projectId/shares/$shareId",shouldThrow:!1}),G=h({from:"/projects/$projectId/folders/$folderId",shouldThrow:!1}),[y,yJ]=_.useState(null),[F,EJ]=_.useState("collection"),[E,JJ]=_.useState(""),[qK,k]=_.useState(!1),[vJ,NJ]=_.useState(null),[S,CJ]=_.useState("collection"),[VK,f]=_.useState(!1),{mutate:IJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.folders[":folderId"].$put({param:{folderId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_folder());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["search",B]}),Q.invalidateQueries({queryKey:["folders"]}),z.success(W.folder_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:AK}=v({mutationFn:async(K)=>{if(!(await U.api.folders.$delete({json:{ids:[K]}})).ok)throw Error(W.failed_delete_folder());return K},onSuccess:(K)=>{if(Q.invalidateQueries({queryKey:["search",B]}),Q.invalidateQueries({queryKey:["folders"]}),z.success(W.folder_deleted()),f(!1),G?.folderId===K)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),[OK,a]=_.useState(!1),[KJ,xJ]=_.useState(!1),[FJ,pJ]=_.useState([]),PK=async(K)=>{a(!0),xJ(!0),pJ([]);try{let Y=await U.api.files["download-links"].$post({json:{ids:[K]}});if(!Y.ok)throw Error(W.failed_to_prepare_download_links());let H=await Y.json();pJ(H.files)}catch(Y){z.error(W.failed_to_prepare_download_links()),a(!1),console.error(Y)}finally{xJ(!1)}},MK=()=>{let K=[...FJ];if(a(!1),K.length===0)return;z.info(W.starting_download_files({count:K.length}),{duration:5000});let Y=(WJ)=>new Promise((I)=>setTimeout(I,WJ));(async()=>{for(let I=0;I<K.length;I+=5){let EK=K.slice(I,I+5);for(let cJ of EK){let x=document.createElement("a");x.href=cJ.url,x.download=cJ.name,x.target="_blank",document.body.appendChild(x),x.click(),x.remove()}await Y(1000)}})().catch((WJ)=>{console.error("Background downloads failed:",WJ),z.error(W.some_downloads_failed())})},{mutate:mJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.collections[":collectionId"].$patch({param:{collectionId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_collection());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:LK}=v({mutationFn:async(K)=>{let Y=await U.api.collections[":collectionId"].$delete({param:{collectionId:K}});if(!Y.ok)throw Error(W.failed_delete_collection());return await Y.json()},onSuccess:(K,Y)=>{if(Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_deleted()),f(!1),e?.collectionId===Y)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:jJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.shares[":shareId"].$put({param:{shareId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_share_link());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:yK}=v({mutationFn:async(K)=>{if(!(await U.api.shares[":shareId"].$delete({param:{shareId:K}})).ok)throw Error(W.failed_delete_share_link());return K},onSuccess:(K)=>{if(Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_deleted()),f(!1),LJ?.shareId===K)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}});return X("div",{className:"flex flex-col h-full overflow-hidden p-3 gap-4 bg-background",children:[X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4",L?"flex-1 min-h-[50%] h-full":"flex-none h-[44px] max-h-[44px]"),children:[J("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>r(!L),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.folder_tree_assets()}),L?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]})}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",L?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[J(bK,{teamId:B,projectId:Z,folder:{id:P,name:$,type:"folder",sizeByte:0,fileCount:0,status:"processed",createdAt:"",updatedAt:""},level:0,isRoot:!0,dragState:b,onSelect:M,selectedFolderId:A,canEdit:V,onRenameTrigger:(K,Y)=>{yJ(K),EJ("folder"),JJ(Y),k(!0)},onDeleteTrigger:(K)=>{NJ(K),CJ("folder"),f(!0)},onDownloadTrigger:(K)=>{PK(K)},ancestorFolders:D},P),V&&X("div",{className:O("group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",j&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>q({to:"/projects/$projectId/recently-deleted",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(uJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.recently_deleted()})]})]})})]}),!m&&X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4",T?"flex-1 min-h-0 h-full":"flex-none h-[44px] max-h-[44px]"),children:[X("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:[X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>BJ(!T),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.collections()}),T?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]}),V&&J("button",{"data-testid":"create-collection",onClick:()=>PJ(),className:"text-muted-foreground hover:text-foreground flex-none",children:J(wJ,{className:"h-3.5 w-3.5"})})]}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",T?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[X("div",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>q({to:"/projects/$projectId/collections",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(kJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.all_collections_count({count:l?.pages[0]?.pageInfo?.total||0})})]}),AJ.map((K)=>{let Y=e?.collectionId===K.id;return X("div",{className:O("group flex cursor-pointer items-center justify-between rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",Y&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>q({to:"/projects/$projectId/collections/$collectionId",params:{projectId:Z,collectionId:K.id}}),children:[X("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[J("div",{className:"flex h-4 w-4 items-center justify-center shrink-0",children:J(rJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"truncate text-sidebar-foreground flex-1",children:K.name})]}),V&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(H)=>H.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[J(w,{onClick:()=>{yJ(K.id),EJ("collection"),JJ(K.name),k(!0)},children:W.rename()}),J(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{NJ(K.id),CJ("collection"),f(!0)},children:W.delete()})]})]})})]},K.id)}),J("div",{ref:qJ,className:"h-1"}),n&&J("div",{className:"flex justify-center p-2",children:J(p,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]})})]}),!C&&X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out",u?"flex-1 min-h-0 h-full":"flex-none h-[44px] max-h-[44px]"),children:[X("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:[X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>bJ(!u),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.share_links()}),u?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]}),V&&J("div",{className:"flex items-center gap-1 flex-none",children:J("button",{onClick:()=>MJ(),className:"text-muted-foreground hover:text-foreground",children:J(wJ,{className:"h-3.5 w-3.5"})})})]}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",u?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[X("div",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>q({to:"/projects/$projectId/shares",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(kJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.all_share_links_count({count:c?.pages[0]?.pageInfo?.total||0})})]}),OJ.map((K)=>J(CK,{link:K,projectId:Z,dragState:b,canEdit:V,onRenameTrigger:(Y,H)=>{yJ(Y),EJ("share"),JJ(H),k(!0)},onDeleteTrigger:(Y)=>{NJ(Y),CJ("share"),f(!0)}},K.id)),J("div",{ref:VJ,className:"h-1"}),R&&J("div",{className:"flex justify-center p-2",children:J(p,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]})})]}),J(TJ,{open:qK,onOpenChange:k,children:X(RJ,{onClick:(K)=>K.stopPropagation(),children:[J(SJ,{children:J(hJ,{children:F==="collection"?W.rename_collection():F==="share"?W.rename_share_link():W.rename_folder()})}),J("div",{className:"py-4",children:J(XK,{value:E,onChange:(K)=>JJ(K.target.value),placeholder:W.enter_new_name(),onKeyDown:(K)=>{if(K.key==="Enter"&&E.trim()){if(F==="collection")mJ({id:y,name:E});else if(F==="share")jJ({id:y,name:E});else if(F==="folder")IJ({id:y,name:E})}}})}),X(fJ,{children:[J(N,{variant:"ghost",onClick:()=>k(!1),children:W.cancel()}),J(N,{disabled:!E.trim(),onClick:()=>{if(F==="collection")mJ({id:y,name:E});else if(F==="share")jJ({id:y,name:E});else if(F==="folder")IJ({id:y,name:E})},children:W.rename()})]})]})}),J(ZK,{open:VK,onOpenChange:f,children:X(_K,{onClick:(K)=>K.stopPropagation(),children:[X($K,{children:[J(zK,{children:S==="collection"?W.delete_collection_confirm():S==="share"?W.delete_share_link_confirm():W.delete_folder_confirm()}),J(QK,{children:W.delete_confirm_description({type:S==="collection"?W.collection():S==="share"?W.share_link():W.folder().toLowerCase()})})]}),X(GK,{children:[J(UK,{children:W.cancel()}),J(HK,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{if(S==="collection")LK(vJ);else if(S==="share")yK(vJ);else if(S==="folder")AK(vJ)},children:W.delete()})]})]})}),J(TJ,{open:OK,onOpenChange:a,children:X(RJ,{className:"sm:max-w-md",children:[X(SJ,{children:[J(hJ,{children:KJ?W.preparing_download():W.confirm_download()}),J(YK,{children:KJ?W.resolving_files_wait():W.folder_files_download_description()})]}),KJ?X("div",{className:"space-y-4 py-6 flex flex-col items-center justify-center",children:[J(p,{className:"h-8 w-8 animate-spin text-primary"}),J("span",{className:"text-sm font-medium text-muted-foreground mt-2",children:W.preparing_download_links()})]}):X("div",{className:"space-y-4 py-2",children:[J("div",{className:"text-sm text-muted-foreground",children:W.download_includes_files({count:FJ.length})}),X("div",{className:"flex items-start gap-3 p-3 text-sm rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 border border-amber-200 dark:border-amber-900/30",children:[J(aJ,{className:"h-5 w-5 shrink-0 mt-0.5"}),X("div",{children:[J("p",{className:"font-semibold",children:W.no_folder_structure()}),J("p",{className:"mt-0.5 text-xs text-amber-700/90 dark:text-amber-400/90",children:W.folder_structure_warning()})]})]})]}),J(fJ,{children:!KJ?X(iJ,{children:[J(N,{variant:"outline",onClick:()=>a(!1),children:W.cancel()}),X(N,{onClick:MK,className:"gap-2",disabled:FJ.length===0,children:[J(DJ,{className:"h-4 w-4"}),W.start_download()]})]}):J(N,{disabled:!0,variant:"outline",children:W.cancel()})})]})})]})}function CK({link:B,projectId:Z,dragState:$,canEdit:P,onRenameTrigger:b,onDeleteTrigger:M}){let A=GJ(),C=h({from:"/projects/$projectId/shares/$shareId",shouldThrow:!1})?.shareId===B.id,{ref:D,isDropTarget:q}=gJ({id:`share:${B.id}`,data:{type:"share-link",id:B.id}}),Q=!!$?.isActive;return X("div",{ref:D,className:O("group flex cursor-pointer items-center justify-between rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",C&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium",q&&Q&&"bg-sidebar-accent ring-2 ring-primary ring-inset"),onClick:()=>A({to:"/projects/$projectId/shares/$shareId",params:{projectId:Z,shareId:B.id}}),children:[X("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[J("div",{className:"flex h-4 w-4 items-center justify-center shrink-0",children:J(JK,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"truncate text-sidebar-foreground flex-1",children:B.name})]}),P&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(V)=>V.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[J(w,{onClick:()=>{b(B.id,B.name)},children:W.rename()}),J(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{M(B.id)},children:W.delete()})]})]})})]})}function bK({teamId:B,projectId:Z,folder:$,level:P,isRoot:b,dragState:M,onSelect:A,selectedFolderId:m,canEdit:C,onRenameTrigger:D,onDeleteTrigger:q,onDownloadTrigger:Q,ancestorFolders:V}){let j=_.useMemo(()=>{return V?.some((G)=>G.id===$.id)??!1},[V,$.id]),[L,r]=_.useState(b||j);_.useEffect(()=>{if(j)r(!0)},[j]);let T=GJ(),BJ=h({from:"/projects/$projectId/folders/$folderId",select:(G)=>({folderId:G.folderId}),shouldThrow:!1}),u=h({from:"/projects/$projectId/",shouldThrow:!1}),bJ=b?!!u:BJ?.folderId===$.id,{data:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:R,isLoading:l}=_J({queryKey:["folders",$.id,"children",{assetType:"folder"}],queryFn:async({pageParam:G})=>{let y=await U.api.folders[":folderId"].children.$get({param:{folderId:$.id},query:{assetType:"folder",after:G,first:"20"}});if(!y.ok)throw Error(W.failed_to_fetch_folder_children());return await y.json()},initialPageParam:"",getNextPageParam:(G)=>{return G.pageInfo?.cursor||void 0},enabled:L||!!b}),{ref:o,inView:d}=$J();_.useEffect(()=>{if(d&&g&&!R)i()},[d,g,R,i]);let n=c?.pages.flatMap((G)=>G.data??[])??[],qJ=(G)=>{G.stopPropagation(),r(!L)},s=()=>{if(A){A($);return}if(b)T({to:"/projects/$projectId",params:{projectId:Z}});else T({to:"/projects/$projectId/folders/$folderId",params:{projectId:Z,folderId:$.id}})},{ref:VJ,isDragging:t}=BK({id:`tree:${$.id}`,data:{type:"folder",item:$},disabled:!!b||!!A||!C}),{ref:AJ,isDropTarget:OJ}=gJ({id:`tree:${$.id}`,data:{type:"folder",item:$},disabled:M?.draggedIds.has($.id)||!!A||!C}),PJ=(G)=>{VJ(G),AJ(G)},MJ=_.useMemo(()=>{if(A)return!1;if(!M?.isActive)return!1;if(M.draggedIds.has($.id))return!1;return!0},[M,$.id,A]),e=OJ&&MJ,LJ=m===$.id;return X("div",{children:[X("div",{ref:PJ,className:O("group flex cursor-pointer items-center gap-1 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",(bJ||LJ)&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium",t&&"opacity-50",e&&"bg-sidebar-accent ring-2 ring-primary ring-inset"),style:{...b?{}:{paddingLeft:`${P*12+8}px`}},onClick:s,children:[!b&&J("button",{onClick:qJ,className:"flex h-4 w-4 items-center justify-center shrink-0",children:L?J(oJ,{className:"h-3 w-3"}):J(sJ,{className:"h-3 w-3"})}),b?J(tJ,{className:"h-4 w-4 text-sidebar-primary shrink-0"}):J(eJ,{className:"h-4 w-4 text-sidebar-primary shrink-0"}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:$.name}),C&&!b&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(G)=>G.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[X(w,{onClick:()=>{D($.id,$.name)},children:[J(nJ,{className:"mr-2 h-4 w-4"}),W.rename()]}),X(w,{onClick:()=>{Q($.id)},children:[J(DJ,{className:"mr-2 h-4 w-4"}),W.download()]}),J(KK,{}),X(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{q($.id)},children:[J(uJ,{className:"mr-2 h-4 w-4"}),W.delete()]})]})]})})]}),L&&X("div",{children:[l&&J("div",{className:"flex items-center justify-center p-2",style:{paddingLeft:`${(P+1)*12+8}px`},children:J(p,{className:"h-4 w-4 animate-spin"})}),n.map((G)=>J(bK,{teamId:B,projectId:Z,folder:G,level:P+1,dragState:M,onSelect:A,selectedFolderId:m,canEdit:C,onRenameTrigger:D,onDeleteTrigger:q,onDownloadTrigger:Q,ancestorFolders:V},G.id)),g&&J("div",{ref:o,className:"flex items-center justify-center p-2",style:{paddingLeft:`${(P+1)*12+8}px`},children:R&&J(p,{className:"h-4 w-4 animate-spin"})})]})]})}
|
|
2
|
+
export{cK as oa};
|