@shumai-one/shumai 0.4.7 → 0.4.9

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.
Files changed (151) hide show
  1. package/bin/chunk-01v2xh5b.js +1 -0
  2. package/bin/{chunk-4m8gk79m.js → chunk-09367z2r.js} +2 -2
  3. package/bin/{chunk-781990k7.js → chunk-0g7ayjb5.js} +4 -4
  4. package/bin/{chunk-5wp37g6w.js → chunk-0mv8jp7h.js} +6 -6
  5. package/bin/{chunk-11c93g1m.js → chunk-0w3388vp.js} +2 -2
  6. package/bin/chunk-15n1v8mm.js +1 -0
  7. package/bin/chunk-17k9a427.js +211 -0
  8. package/bin/{chunk-dyq6h9ha.js → chunk-1kr1jsrt.js} +1 -1
  9. package/bin/{chunk-njabdtvb.js → chunk-1v11geh0.js} +2 -2
  10. package/bin/chunk-258tjpym.js +1 -0
  11. package/bin/chunk-2ar64j3z.js +2 -0
  12. package/bin/{chunk-ebf1r872.js → chunk-2j31y48k.js} +5 -5
  13. package/bin/{chunk-z9jpgxf1.js → chunk-2txahdj8.js} +2 -2
  14. package/bin/{chunk-gc6m7agb.js → chunk-315w58w6.js} +2 -2
  15. package/bin/{chunk-0ygtayqf.js → chunk-41fbx9mc.js} +1 -1
  16. package/bin/{chunk-zz0522zr.js → chunk-46brm12f.js} +4 -4
  17. package/bin/{chunk-q1d7x1cc.js → chunk-46hmh2ag.js} +1 -1
  18. package/bin/{chunk-zbt4h7n0.js → chunk-4cj3pz27.js} +1 -1
  19. package/bin/{chunk-camzbwqh.js → chunk-4sqbjvjt.js} +1 -1
  20. package/bin/{chunk-jde9r5mj.js → chunk-5e4de0a1.js} +1 -1
  21. package/bin/{chunk-b3aqmcps.js → chunk-5w7yxz6p.js} +2 -2
  22. package/bin/{chunk-ebx3bd4c.js → chunk-6m44n3ms.js} +1 -1
  23. package/bin/{chunk-hye75kp0.js → chunk-6mnj9adr.js} +2 -2
  24. package/bin/{chunk-twyxs4z2.js → chunk-6snwrej9.js} +1 -1
  25. package/bin/{chunk-mm1a0zja.js → chunk-6vqga3ma.js} +1 -1
  26. package/bin/{chunk-t3t7dcfq.js → chunk-6yayg55q.js} +1 -1
  27. package/bin/{chunk-9va1mzeq.js → chunk-7hmt2gs5.js} +2 -2
  28. package/bin/{chunk-3h9c5ak3.js → chunk-7zfyrt40.js} +1 -1
  29. package/bin/{chunk-fvgb6rps.js → chunk-82cg5497.js} +2 -2
  30. package/bin/{chunk-628k58ek.js → chunk-8mhj6r2q.js} +2 -2
  31. package/bin/{chunk-radcwage.js → chunk-8mjb093y.js} +2 -2
  32. package/bin/{chunk-h3wr8nnk.js → chunk-8r9q7xcv.js} +1 -1
  33. package/bin/{chunk-wvq717b5.js → chunk-9fe75ns9.js} +2 -2
  34. package/bin/{chunk-05tnmf8h.js → chunk-aant41bd.js} +2 -2
  35. package/bin/{chunk-v1sgrg0r.js → chunk-anky1dmg.js} +1 -1
  36. package/bin/{chunk-k810fstm.js → chunk-bg2vgnzt.js} +1 -1
  37. package/bin/{chunk-3tyk9xgf.js → chunk-c0wqfya9.js} +2 -2
  38. package/bin/{chunk-8b1w6bj9.js → chunk-c3010erf.js} +1 -1
  39. package/bin/{chunk-vdnmq163.js → chunk-c7hr2jga.js} +2 -2
  40. package/bin/chunk-c8aw8dye.js +2 -0
  41. package/bin/{chunk-zr11zfwc.js → chunk-ckd5hnd0.js} +2 -2
  42. package/bin/{chunk-dkzyv61a.js → chunk-cphwmdq5.js} +2 -2
  43. package/bin/{chunk-typ46eqd.js → chunk-d70acjwn.js} +5 -5
  44. package/bin/{chunk-xznabrt2.js → chunk-dzj91k6v.js} +1 -1
  45. package/bin/chunk-e2724ggn.js +2 -0
  46. package/bin/chunk-e2j3vwcv.js +2 -0
  47. package/bin/{chunk-k3qypq3x.js → chunk-e2qn4d57.js} +1 -1
  48. package/bin/{chunk-kg2c445x.js → chunk-eedhf8eb.js} +1 -1
  49. package/bin/chunk-ef3av8ay.js +1 -0
  50. package/bin/{chunk-j41mya13.js → chunk-f3f6cary.js} +3 -3
  51. package/bin/chunk-fjvbgahx.css +1 -0
  52. package/bin/chunk-fw0f45qw.js +2 -0
  53. package/bin/{chunk-s30fjvzs.js → chunk-fw5xzcnf.js} +4 -4
  54. package/bin/{chunk-8sf106rq.js → chunk-g6rw4jj5.js} +1 -1
  55. package/bin/{chunk-dscq4a4k.js → chunk-g7qejgap.js} +2 -2
  56. package/bin/{chunk-4jgq9m51.js → chunk-gj0yxtqz.js} +7 -7
  57. package/bin/{chunk-m2h7a172.js → chunk-gvbajsje.js} +1 -1
  58. package/bin/{chunk-s63vj79f.js → chunk-h29rwayb.js} +1 -1
  59. package/bin/chunk-h37zfvmp.js +3 -0
  60. package/bin/{chunk-m638fg4n.js → chunk-ht4chp45.js} +5 -5
  61. package/bin/{chunk-3g5pyw2e.js → chunk-jpjc44j6.js} +2 -2
  62. package/bin/{chunk-9v6eqa3n.js → chunk-jraqe5z0.js} +2 -2
  63. package/bin/{chunk-yqvhgtez.js → chunk-jxfz4h24.js} +2 -2
  64. package/bin/chunk-jy8by162.js +1 -0
  65. package/bin/{chunk-53vtc74g.js → chunk-jyg525f5.js} +2 -2
  66. package/bin/chunk-jz9mcrj6.js +1 -0
  67. package/bin/chunk-k4n9rdq3.js +1 -0
  68. package/bin/{chunk-e17daz1x.js → chunk-kemfwmyq.js} +2 -2
  69. package/bin/{chunk-6rjkbwz6.js → chunk-kmx350y5.js} +9 -9
  70. package/bin/{chunk-887pj9xd.js → chunk-kn82bccp.js} +2 -2
  71. package/bin/chunk-kx0qbs28.js +1 -0
  72. package/bin/{chunk-nnq8g9yy.js → chunk-m0xbfmf0.js} +3 -3
  73. package/bin/{chunk-rbagbd0e.js → chunk-n6sny5c8.js} +1 -1
  74. package/bin/{chunk-ayq8dskd.js → chunk-nhfbnqdr.js} +2 -2
  75. package/bin/{chunk-5qkwpy8c.js → chunk-nr80mrry.js} +2 -2
  76. package/bin/{chunk-4f5pnnah.js → chunk-ns8whqp6.js} +30 -30
  77. package/bin/{chunk-p5fwjk5c.js → chunk-nz16584e.js} +1 -1
  78. package/bin/{chunk-yr03tf5r.js → chunk-p46em0kf.js} +3 -3
  79. package/bin/{chunk-gf4n4ahk.js → chunk-p4nbgn3v.js} +1 -1
  80. package/bin/chunk-p7j6zgdg.js +2 -0
  81. package/bin/chunk-pbyp1xnb.js +2 -0
  82. package/bin/{chunk-r55htzxr.js → chunk-pw81eh3g.js} +2 -2
  83. package/bin/{chunk-rkafv27g.js → chunk-q6k1ctph.js} +2 -2
  84. package/bin/{chunk-fhazy8f9.js → chunk-qa7pphr5.js} +1 -1
  85. package/bin/chunk-qah2r4xa.js +2 -0
  86. package/bin/chunk-r4w1e3bd.js +2 -0
  87. package/bin/{chunk-6kdf411z.js → chunk-rbh4w2v2.js} +1 -1
  88. package/bin/{chunk-3p1bb08a.js → chunk-rd5ek2sk.js} +2 -2
  89. package/bin/{chunk-8ystwvdt.js → chunk-rv15x8aw.js} +2 -2
  90. package/bin/{chunk-b0rjvx5g.js → chunk-ryvq9pbw.js} +2 -2
  91. package/bin/{chunk-4a88wwg2.js → chunk-s9whhdb3.js} +2 -2
  92. package/bin/{chunk-ycw3rwhx.js → chunk-sby10fz6.js} +3 -3
  93. package/bin/{chunk-q45n02fs.js → chunk-sedbz4km.js} +1 -1
  94. package/bin/{chunk-ccvjwhqq.js → chunk-sfwmwrq3.js} +1 -1
  95. package/bin/{chunk-zmjtv19e.js → chunk-sg8hjkyg.js} +1 -1
  96. package/bin/{chunk-3r5yc5wm.js → chunk-snedd3at.js} +6 -6
  97. package/bin/{chunk-an6nsq1t.js → chunk-spm13ndr.js} +2 -2
  98. package/bin/chunk-ss1jchgx.js +1 -0
  99. package/bin/{chunk-rdscv38p.js → chunk-szjkmkwc.js} +1 -1
  100. package/bin/chunk-t0nktwrm.js +1 -0
  101. package/bin/{chunk-1ntn42d2.js → chunk-t9eb2mdq.js} +3 -3
  102. package/bin/{chunk-njqf50vw.js → chunk-tcyp8qtg.js} +2 -2
  103. package/bin/{chunk-nn5hyf6f.js → chunk-tefct00a.js} +1 -1
  104. package/bin/{chunk-xca338dw.js → chunk-thzf89fp.js} +3 -3
  105. package/bin/{chunk-pcspeqwq.js → chunk-tnv4ggx2.js} +4 -4
  106. package/bin/chunk-tptgxbqa.js +2 -0
  107. package/bin/{chunk-xzyfnfck.js → chunk-v2901ff5.js} +8 -8
  108. package/bin/{chunk-vx66rms0.js → chunk-v2vdm22x.js} +1 -1
  109. package/bin/{chunk-5rk7dyx9.js → chunk-v8ngtwzx.js} +53 -53
  110. package/bin/chunk-xex9v0rn.js +2 -0
  111. package/bin/chunk-xs2w45vp.js +1 -0
  112. package/bin/{chunk-s41mgkse.js → chunk-xw7jea6g.js} +1 -1
  113. package/bin/chunk-xza8wate.js +2 -0
  114. package/bin/{chunk-pa1fmskf.js → chunk-yet4fnab.js} +1 -1
  115. package/bin/{chunk-ny7qjn6s.js → chunk-yfjyjjpz.js} +1 -1
  116. package/bin/{chunk-5vvvgjvz.js → chunk-ytffpk7c.js} +2 -2
  117. package/bin/{chunk-kq2qbwx1.js → chunk-yyj21k15.js} +1 -1
  118. package/bin/{chunk-5v4s2kp4.js → chunk-zhtc1j3r.js} +1 -1
  119. package/bin/{chunk-8gna37dd.js → chunk-zpk482rb.js} +2 -2
  120. package/bin/{chunk-zcdqsp1e.js → chunk-zy32pf0s.js} +1 -1
  121. package/bin/shumai-app.html +1 -1
  122. package/bin/shumai-app.js +562 -317
  123. package/package.json +7 -7
  124. package/prisma/migrations/20260927092537_add_notification_email_status/migration.sql +11 -0
  125. package/prisma/schema.prisma +10 -0
  126. package/bin/chunk-0xsgx9ep.js +0 -1
  127. package/bin/chunk-1ajgdv26.js +0 -1
  128. package/bin/chunk-30dsxm8s.js +0 -1
  129. package/bin/chunk-3b6h719s.js +0 -3
  130. package/bin/chunk-3m5kwcj7.js +0 -2
  131. package/bin/chunk-58e1a3re.js +0 -2
  132. package/bin/chunk-6ksrrayx.css +0 -1
  133. package/bin/chunk-bgm76rzj.js +0 -1
  134. package/bin/chunk-btmxr226.js +0 -1
  135. package/bin/chunk-ee3mrvqp.js +0 -2
  136. package/bin/chunk-fg6zf2gb.js +0 -2
  137. package/bin/chunk-fk712d68.js +0 -2
  138. package/bin/chunk-g9gmht89.js +0 -2
  139. package/bin/chunk-htpjtarr.js +0 -2
  140. package/bin/chunk-j547gtag.js +0 -2
  141. package/bin/chunk-jf4kcad0.js +0 -1
  142. package/bin/chunk-jt04mf5s.js +0 -2
  143. package/bin/chunk-k5hnrtrt.js +0 -1
  144. package/bin/chunk-q6jsw0rr.js +0 -211
  145. package/bin/chunk-qjzyze00.js +0 -1
  146. package/bin/chunk-rfhmk32e.js +0 -1
  147. package/bin/chunk-rkqpnyzx.js +0 -2
  148. package/bin/chunk-xbge27m4.js +0 -1
  149. package/bin/chunk-xcsz1wp7.js +0 -1
  150. package/bin/chunk-zb0az2tq.js +0 -2
  151. package/bin/chunk-zej27b5c.js +0 -2
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{xc,Sc,Zu}from"./chunk-2ar64j3z.js";export{xc as ENV_KEY,Sc as ENV_SECRET,Zu as fromEnv};
@@ -0,0 +1 @@
1
+ import{h,S,t,Z,ze,A,lt,xt,sm}from"./chunk-17k9a427.js";import"./chunk-kn82bccp.js";import"./chunk-46brm12f.js";import"./chunk-q6k1ctph.js";import"./chunk-dzj91k6v.js";import{Ua}from"./chunk-ns8whqp6.js";import"./chunk-spm13ndr.js";import"./chunk-ryvq9pbw.js";import{rr}from"./chunk-e2724ggn.js";import"./chunk-09367z2r.js";import"./chunk-xza8wate.js";import"./chunk-7hmt2gs5.js";import"./chunk-g6rw4jj5.js";S();function p(){let{projectId:e,folderId:d}=s.useParams(),{teamId:r,ensureTeamIdForProject:i}=lt();h(()=>{i(e)},[e,i]);let{data:a}=rr(sm(e)),o=a?.rootFolder,{data:l}=Z({queryKey:["folders",o],queryFn:async()=>{let n=await A.api.folders[":folderId"].$get({param:{folderId:o}});if(!n.ok)throw Error("failed to fetch folder");return await n.json()},enabled:!!o});if(!r||!o||!l)return t(xt,{});return t(Ua,{teamId:r,projectId:e,projectName:a.name??"",assetId:d,rootFolderId:o,isRoot:!1})}var s=ze("/projects/$projectId/folders/$folderId_/agentsmd")({component:p});export{s as Route};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{el,tl}from"./chunk-53vtc74g.js";import{Jr,En}from"./chunk-njabdtvb.js";var m=class extends tl{},p=class{#e;#t;constructor(e){this.#e={...e}}async init(){if(this.#t=new w(this.#e.database),this.#e.onCreateConnection)await this.#e.onCreateConnection(this.#t)}async acquireConnection(){return this.#t}async beginTransaction(){throw Error("D1 does not support interactive transactions. Use the D1 batch() API instead.")}async commitTransaction(){throw Error("D1 does not support interactive transactions. Use the D1 batch() API instead.")}async rollbackTransaction(){throw Error("D1 does not support interactive transactions. Use the D1 batch() API instead.")}async releaseConnection(){}async destroy(){}},w=class{#e;constructor(e){this.#e=e}async executeQuery(e){let t=await this.#e.prepare(e.sql).bind(...e.parameters).all(),a=t.meta.changes!=null?BigInt(t.meta.changes):void 0;return{insertId:t.meta.last_row_id===void 0||t.meta.last_row_id===null?void 0:BigInt(t.meta.last_row_id),rows:t?.results||[],numAffectedRows:a}}async*streamQuery(){throw Error("D1 does not support streaming queries.")}},d=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let t=this.#e.selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").where("name","not like","_cf_%").select(["name","type","sql"]).$castTo();if(!e.withInternalKyselyTables)t=t.where("name","!=",Jr).where("name","!=",En);let a=await t.execute();if(a.length===0)return[];let c=a.map((s)=>this.#t.prepare("SELECT * FROM pragma_table_info(?)").bind(s.name)),l=await this.#t.batch(c);return a.map((s,u)=>{let o=l[u]?.results??[],r=s.sql?.split(/[(),]/)?.find((n)=>n.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.filter(Boolean)?.[0]?.replace(/["`]/g,"");if(!r){let n=o.filter((h)=>h.pk>0),i=n.length===1?n[0]:void 0;if(i&&i.type.toLowerCase()==="integer")r=i.name}return{name:s.name,isView:s.type==="view",columns:o.map((n)=>({name:n.name,dataType:n.type,isNullable:!n.notnull,isAutoIncrementing:n.name===r,hasDefaultValue:n.dflt_value!=null}))}})}async getMetadata(e){return{tables:await this.getTables(e)}}},y=class extends el{},f=class{#e;constructor(e){this.#e={...e}}createDriver(){return new p(this.#e)}createQueryCompiler(){return new y}createAdapter(){return new m}createIntrospector(e){return new d(e,this.#e.database)}};export{f as D1SqliteDialect};
2
+ import{rl,nl}from"./chunk-jyg525f5.js";import{Jr,En}from"./chunk-1v11geh0.js";var m=class extends nl{},p=class{#e;#t;constructor(e){this.#e={...e}}async init(){if(this.#t=new w(this.#e.database),this.#e.onCreateConnection)await this.#e.onCreateConnection(this.#t)}async acquireConnection(){return this.#t}async beginTransaction(){throw Error("D1 does not support interactive transactions. Use the D1 batch() API instead.")}async commitTransaction(){throw Error("D1 does not support interactive transactions. Use the D1 batch() API instead.")}async rollbackTransaction(){throw Error("D1 does not support interactive transactions. Use the D1 batch() API instead.")}async releaseConnection(){}async destroy(){}},w=class{#e;constructor(e){this.#e=e}async executeQuery(e){let t=await this.#e.prepare(e.sql).bind(...e.parameters).all(),a=t.meta.changes!=null?BigInt(t.meta.changes):void 0;return{insertId:t.meta.last_row_id===void 0||t.meta.last_row_id===null?void 0:BigInt(t.meta.last_row_id),rows:t?.results||[],numAffectedRows:a}}async*streamQuery(){throw Error("D1 does not support streaming queries.")}},d=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let t=this.#e.selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").where("name","not like","_cf_%").select(["name","type","sql"]).$castTo();if(!e.withInternalKyselyTables)t=t.where("name","!=",Jr).where("name","!=",En);let a=await t.execute();if(a.length===0)return[];let c=a.map((s)=>this.#t.prepare("SELECT * FROM pragma_table_info(?)").bind(s.name)),l=await this.#t.batch(c);return a.map((s,u)=>{let o=l[u]?.results??[],r=s.sql?.split(/[(),]/)?.find((n)=>n.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.filter(Boolean)?.[0]?.replace(/["`]/g,"");if(!r){let n=o.filter((h)=>h.pk>0),i=n.length===1?n[0]:void 0;if(i&&i.type.toLowerCase()==="integer")r=i.name}return{name:s.name,isView:s.type==="view",columns:o.map((n)=>({name:n.name,dataType:n.type,isNullable:!n.notnull,isAutoIncrementing:n.name===r,hasDefaultValue:n.dflt_value!=null}))}})}async getMetadata(e){return{tables:await this.getTables(e)}}},y=class extends rl{},f=class{#e;constructor(e){this.#e={...e}}createDriver(){return new p(this.#e)}createQueryCompiler(){return new y}createAdapter(){return new m}createIntrospector(e){return new d(e,this.#e.database)}};export{f as D1SqliteDialect};
@@ -0,0 +1,2 @@
1
+ import{I}from"./chunk-17k9a427.js";var e=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Kl=I("code",e);
2
+ export{Kl};
@@ -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=a.baseURL,this.timeout=a.timeout??Ps.DEFAULT_TIMEOUT,this.logger=a.logger??console;let f="warn";this.logLevel=f,this.logLevel=rs(a.logLevel,"ClientOptions.logLevel",this)??rs(K("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??f,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??Ls(),b(this,Wr,Us,"f"),this._options=a,this.apiKey=typeof t==="string"?t:"Missing Key",this.organization=r,this.project=s,this.webhookSecret=n}withOptions(e){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,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){return}async authHeaders(e){return h([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return Ks(e)}getUserAgent(){return`${this.constructor.name}/JS ${fe}`}defaultIdempotencyKey(){return`stainless-node-retry-${Hr()}`}makeStatusError(e,t,r,s){return O.generate(e,t,r,s)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!=="function")return!1;let t;try{t=await e()}catch(r){if(r instanceof m)throw r;throw new m(`Failed to get token from 'apiKey' function: ${r.message}`,{cause:r})}if(typeof t!=="string"||!t)throw new m(`Expected 'apiKey' function argument to return a string but it returned ${t}`);return this.apiKey=t,!0}buildURL(e,t,r){let s=!i(this,Is,"m",Ln).call(this)&&r||this.baseURL,n=Cs(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();if(!Es(o))t={...o,...t};if(typeof t==="object"&&t&&!Array.isArray(t))n.search=this.stringifyQuery(t);return n.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:t,options:r}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,r){return this.request(Promise.resolve(r).then((s)=>({method:e,path:t,...s})))}request(e,t=null){return new Ie(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,r){let s=await e,n=s.maxRetries??this.maxRetries;if(t==null)t=n;await this.prepareOptions(s);let{req:o,url:a,timeout:f}=await this.buildRequest(s,{retryCount:n-t});await this.prepareRequest(o,{url:a,options:s});let d="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),_=r===void 0?"":`, retryOf: ${r}`,y=Date.now();if(v(this).debug(`[${d}] sending request`,ne({retryOfRequestLogID:r,method:s.method,url:a,options:s,headers:o.headers})),s.signal?.aborted)throw new F;let p=new AbortController,u=await this.fetchWithTimeout(a,o,f,p).catch(pt),w=Date.now();if(u instanceof globalThis.Error){let S=`retrying, ${t} attempts remaining`;if(s.signal?.aborted)throw new F;let I=dt(u)||/timed? ?out/i.test(String(u)+("cause"in u?String(u.cause):""));if(t)return v(this).info(`[${d}] connection ${I?"timed out":"failed"} - ${S}`),v(this).debug(`[${d}] connection ${I?"timed out":"failed"} (${S})`,ne({retryOfRequestLogID:r,url:a,durationMs:w-y,message:u.message})),this.retryRequest(s,t,r??d);if(v(this).info(`[${d}] connection ${I?"timed out":"failed"} - error; no more retries left`),v(this).debug(`[${d}] connection ${I?"timed out":"failed"} (error; no more retries left)`,ne({retryOfRequestLogID:r,url:a,durationMs:w-y,message:u.message})),I)throw new Ae;throw new xe({cause:u})}let g=[...u.headers.entries()].filter(([S])=>S==="x-request-id").map(([S,I])=>", "+S+": "+JSON.stringify(I)).join(""),R=`[${d}${_}${g}] ${o.method} ${a} ${u.ok?"succeeded":"failed"} with status ${u.status} in ${w-y}ms`;if(!u.ok){let S=await this.shouldRetry(u);if(t&&S){let T=`retrying, ${t} attempts remaining`;return await Bs(u.body),v(this).info(`${R} - ${T}`),v(this).debug(`[${d}] response error (${T})`,ne({retryOfRequestLogID:r,url:u.url,status:u.status,headers:u.headers,durationMs:w-y})),this.retryRequest(s,t,r??d,u.headers)}let I=S?"error; no more retries left":"error; not retryable";v(this).info(`${R} - ${I}`);let A=await u.text().catch((T)=>pt(T).message),k=ks(A),E=k?void 0:A;throw v(this).debug(`[${d}] response error (${I})`,ne({retryOfRequestLogID:r,url:u.url,status:u.status,headers:u.headers,message:E,durationMs:Date.now()-y})),this.makeStatusError(u.status,k,E,u.headers)}return v(this).info(R),v(this).debug(`[${d}] response start`,ne({retryOfRequestLogID:r,url:u.url,status:u.status,headers:u.headers,durationMs:w-y})),{response:u,options:s,controller:p,requestLogID:d,retryOfRequestLogID:r,startTime:y}}getAPIList(e,t,r){return this.requestAPIList(t,r&&"then"in r?r.then((s)=>({method:"get",path:e,...s})):{method:"get",path:e,...r})}requestAPIList(e,t){let r=this.makeRequest(t,null,void 0);return new xr(this,r,e)}async fetchWithTimeout(e,t,r,s){let{signal:n,method:o,...a}=t||{},f=this._makeAbort(s);if(n)n.addEventListener("abort",f,{once:!0});let d=setTimeout(f,r),_=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body==="object"&&a.body!==null&&Symbol.asyncIterator in a.body,y={signal:s.signal,..._?{duplex:"half"}:{},method:"GET",...a};if(o)y.method=o.toUpperCase();try{return await this.fetch.call(void 0,e,y)}finally{clearTimeout(d)}}async shouldRetry(e){let t=e.headers.get("x-should-retry");if(t==="true")return!0;if(t==="false")return!1;if(e.status===408)return!0;if(e.status===409)return!0;if(e.status===429)return!0;if(e.status>=500)return!0;return!1}async retryRequest(e,t,r,s){let n,o=s?.get("retry-after-ms");if(o){let f=parseFloat(o);if(!Number.isNaN(f))n=f}let a=s?.get("retry-after");if(a&&!n){let f=parseFloat(a);if(!Number.isNaN(f))n=f*1000;else n=Date.parse(a)-Date.now()}if(n===void 0){let f=e.maxRetries??this.maxRetries;n=this.calculateDefaultRetryTimeoutMillis(t,f)}return await z(n),this.makeRequest(e,t-1,r)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e,o=Math.min(0.5*Math.pow(2,n),8),a=1-Math.random()*0.25;return o*a*1000}async buildRequest(e,{retryCount:t=0}={}){let r={...e},{method:s,path:n,query:o,defaultBaseURL:a}=r,f=this.buildURL(n,o,a);if("timeout"in r)$s("timeout",r.timeout);r.timeout=r.timeout??this.timeout;let{bodyHeaders:d,body:_}=this.buildBody({options:r}),y=await this.buildHeaders({options:e,method:s,bodyHeaders:d,retryCount:t});return{req:{method:s,headers:y,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&_ instanceof globalThis.ReadableStream&&{duplex:"half"},..._&&{body:_},...this.fetchOptions??{},...r.fetchOptions??{}},url:f,timeout:r.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:r,retryCount:s}){let n={};if(this.idempotencyHeader&&t!=="get"){if(!e.idempotencyKey)e.idempotencyKey=this.defaultIdempotencyKey();n[this.idempotencyHeader]=e.idempotencyKey}let o=h([n,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1000))}:{},...Ms(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);return this.validateHeaders(o),o.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let r=h([t]);if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==="string"&&r.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:e};else if(typeof e==="object"&&((Symbol.asyncIterator in e)||(Symbol.iterator in e)&&("next"in e)&&typeof e.next==="function"))return{bodyHeaders:void 0,body:pr(e)};else if(typeof e==="object"&&r.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)};else return i(this,Wr,"f").call(this,{body:e,headers:r})}}Ps=We,Wr=new WeakMap,Is=new WeakSet,Ln=function(){return this.baseURL!=="https://api.openai.com/v1"};We.OpenAI=Ps;We.DEFAULT_TIMEOUT=600000;We.OpenAIError=m;We.APIError=O;We.APIConnectionError=xe;We.APIConnectionTimeoutError=Ae;We.APIUserAbortError=F;We.NotFoundError=yt;We.ConflictError=bt;We.RateLimitError=xt;We.BadRequestError=mt;We.AuthenticationError=_t;We.InternalServerError=At;We.PermissionDeniedError=gt;We.UnprocessableEntityError=wt;We.InvalidWebhookSignatureError=se;We.toFile=Ir;We.Completions=Qe;We.Chat=Re;We.Embeddings=Ze;We.Files=tt;We.Images=ot;We.Audio=ce;We.Moderations=at;We.Models=it;We.FineTuning=te;We.Graders=Me;We.VectorStores=we;We.Webhooks=ht;We.Beta=ee;We.Batches=Ke;We.Uploads=Le;We.Responses=ye;We.Realtime=_e;We.Conversations=Fe;We.Evals=Ne;We.Containers=Te;We.Skills=be;We.Videos=ut;class Au extends We{constructor({baseURL:e=K("OPENAI_BASE_URL"),apiKey:t=K("AZURE_OPENAI_API_KEY"),apiVersion:r=K("OPENAI_API_VERSION"),endpoint:s,deployment:n,azureADTokenProvider:o,dangerouslyAllowBrowser:a,...f}={}){if(!r)throw new m("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 o==="function")a=!0;if(!o&&!t)throw new m("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(o&&t)throw new m("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(f.defaultQuery={...f.defaultQuery,"api-version":r},!e){if(!s)s=process.env.AZURE_OPENAI_ENDPOINT;if(!s)throw new m("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");e=`${s}/openai`}else if(s)throw new m("baseURL and endpoint are mutually exclusive");super({apiKey:o??t,baseURL:e,...f,...a!==void 0?{dangerouslyAllowBrowser:a}:{}});this.apiVersion="",this.apiVersion=r,this.deploymentName=n}async buildRequest(e,t={}){if(ui.has(e.path)&&e.method==="post"&&e.body!==void 0){if(!Be(e.body))throw Error("Expected request body to be an object");let r=this.deploymentName||e.body.model||e.__metadata?.model;if(r!==void 0&&!this.baseURL.includes("/deployments"))e.path=`/deployments/${r}${e.path}`}return super.buildRequest(e,t)}async authHeaders(e){if(typeof this._options.apiKey==="string")return h([{"api-key":this.apiKey}]);return super.authHeaders(e)}}var ui=new Set(["/completions","/chat/completions","/embeddings","/audio/transcriptions","/audio/translations","/audio/speech","/images/generations","/batches","/images/edits"]);export{We,Au};
24
+ `);this.baseURL=a.baseURL,this.timeout=a.timeout??Ps.DEFAULT_TIMEOUT,this.logger=a.logger??console;let f="warn";this.logLevel=f,this.logLevel=rs(a.logLevel,"ClientOptions.logLevel",this)??rs(K("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??f,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??Ls(),b(this,Wr,Us,"f"),this._options=a,this.apiKey=typeof t==="string"?t:"Missing Key",this.organization=r,this.project=s,this.webhookSecret=n}withOptions(e){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,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){return}async authHeaders(e){return h([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return Ks(e)}getUserAgent(){return`${this.constructor.name}/JS ${fe}`}defaultIdempotencyKey(){return`stainless-node-retry-${Hr()}`}makeStatusError(e,t,r,s){return O.generate(e,t,r,s)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!=="function")return!1;let t;try{t=await e()}catch(r){if(r instanceof m)throw r;throw new m(`Failed to get token from 'apiKey' function: ${r.message}`,{cause:r})}if(typeof t!=="string"||!t)throw new m(`Expected 'apiKey' function argument to return a string but it returned ${t}`);return this.apiKey=t,!0}buildURL(e,t,r){let s=!i(this,Is,"m",Ln).call(this)&&r||this.baseURL,n=Cs(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();if(!Es(o))t={...o,...t};if(typeof t==="object"&&t&&!Array.isArray(t))n.search=this.stringifyQuery(t);return n.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:t,options:r}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,r){return this.request(Promise.resolve(r).then((s)=>({method:e,path:t,...s})))}request(e,t=null){return new Ie(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,r){let s=await e,n=s.maxRetries??this.maxRetries;if(t==null)t=n;await this.prepareOptions(s);let{req:o,url:a,timeout:f}=await this.buildRequest(s,{retryCount:n-t});await this.prepareRequest(o,{url:a,options:s});let d="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),_=r===void 0?"":`, retryOf: ${r}`,y=Date.now();if(v(this).debug(`[${d}] sending request`,ne({retryOfRequestLogID:r,method:s.method,url:a,options:s,headers:o.headers})),s.signal?.aborted)throw new F;let p=new AbortController,u=await this.fetchWithTimeout(a,o,f,p).catch(pt),w=Date.now();if(u instanceof globalThis.Error){let S=`retrying, ${t} attempts remaining`;if(s.signal?.aborted)throw new F;let I=dt(u)||/timed? ?out/i.test(String(u)+("cause"in u?String(u.cause):""));if(t)return v(this).info(`[${d}] connection ${I?"timed out":"failed"} - ${S}`),v(this).debug(`[${d}] connection ${I?"timed out":"failed"} (${S})`,ne({retryOfRequestLogID:r,url:a,durationMs:w-y,message:u.message})),this.retryRequest(s,t,r??d);if(v(this).info(`[${d}] connection ${I?"timed out":"failed"} - error; no more retries left`),v(this).debug(`[${d}] connection ${I?"timed out":"failed"} (error; no more retries left)`,ne({retryOfRequestLogID:r,url:a,durationMs:w-y,message:u.message})),I)throw new Ae;throw new xe({cause:u})}let g=[...u.headers.entries()].filter(([S])=>S==="x-request-id").map(([S,I])=>", "+S+": "+JSON.stringify(I)).join(""),R=`[${d}${_}${g}] ${o.method} ${a} ${u.ok?"succeeded":"failed"} with status ${u.status} in ${w-y}ms`;if(!u.ok){let S=await this.shouldRetry(u);if(t&&S){let T=`retrying, ${t} attempts remaining`;return await Bs(u.body),v(this).info(`${R} - ${T}`),v(this).debug(`[${d}] response error (${T})`,ne({retryOfRequestLogID:r,url:u.url,status:u.status,headers:u.headers,durationMs:w-y})),this.retryRequest(s,t,r??d,u.headers)}let I=S?"error; no more retries left":"error; not retryable";v(this).info(`${R} - ${I}`);let A=await u.text().catch((T)=>pt(T).message),k=ks(A),E=k?void 0:A;throw v(this).debug(`[${d}] response error (${I})`,ne({retryOfRequestLogID:r,url:u.url,status:u.status,headers:u.headers,message:E,durationMs:Date.now()-y})),this.makeStatusError(u.status,k,E,u.headers)}return v(this).info(R),v(this).debug(`[${d}] response start`,ne({retryOfRequestLogID:r,url:u.url,status:u.status,headers:u.headers,durationMs:w-y})),{response:u,options:s,controller:p,requestLogID:d,retryOfRequestLogID:r,startTime:y}}getAPIList(e,t,r){return this.requestAPIList(t,r&&"then"in r?r.then((s)=>({method:"get",path:e,...s})):{method:"get",path:e,...r})}requestAPIList(e,t){let r=this.makeRequest(t,null,void 0);return new xr(this,r,e)}async fetchWithTimeout(e,t,r,s){let{signal:n,method:o,...a}=t||{},f=this._makeAbort(s);if(n)n.addEventListener("abort",f,{once:!0});let d=setTimeout(f,r),_=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body==="object"&&a.body!==null&&Symbol.asyncIterator in a.body,y={signal:s.signal,..._?{duplex:"half"}:{},method:"GET",...a};if(o)y.method=o.toUpperCase();try{return await this.fetch.call(void 0,e,y)}finally{clearTimeout(d)}}async shouldRetry(e){let t=e.headers.get("x-should-retry");if(t==="true")return!0;if(t==="false")return!1;if(e.status===408)return!0;if(e.status===409)return!0;if(e.status===429)return!0;if(e.status>=500)return!0;return!1}async retryRequest(e,t,r,s){let n,o=s?.get("retry-after-ms");if(o){let f=parseFloat(o);if(!Number.isNaN(f))n=f}let a=s?.get("retry-after");if(a&&!n){let f=parseFloat(a);if(!Number.isNaN(f))n=f*1000;else n=Date.parse(a)-Date.now()}if(n===void 0){let f=e.maxRetries??this.maxRetries;n=this.calculateDefaultRetryTimeoutMillis(t,f)}return await z(n),this.makeRequest(e,t-1,r)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e,o=Math.min(0.5*Math.pow(2,n),8),a=1-Math.random()*0.25;return o*a*1000}async buildRequest(e,{retryCount:t=0}={}){let r={...e},{method:s,path:n,query:o,defaultBaseURL:a}=r,f=this.buildURL(n,o,a);if("timeout"in r)$s("timeout",r.timeout);r.timeout=r.timeout??this.timeout;let{bodyHeaders:d,body:_}=this.buildBody({options:r}),y=await this.buildHeaders({options:e,method:s,bodyHeaders:d,retryCount:t});return{req:{method:s,headers:y,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&_ instanceof globalThis.ReadableStream&&{duplex:"half"},..._&&{body:_},...this.fetchOptions??{},...r.fetchOptions??{}},url:f,timeout:r.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:r,retryCount:s}){let n={};if(this.idempotencyHeader&&t!=="get"){if(!e.idempotencyKey)e.idempotencyKey=this.defaultIdempotencyKey();n[this.idempotencyHeader]=e.idempotencyKey}let o=h([n,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1000))}:{},...Ms(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);return this.validateHeaders(o),o.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let r=h([t]);if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==="string"&&r.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:e};else if(typeof e==="object"&&((Symbol.asyncIterator in e)||(Symbol.iterator in e)&&("next"in e)&&typeof e.next==="function"))return{bodyHeaders:void 0,body:pr(e)};else if(typeof e==="object"&&r.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)};else return i(this,Wr,"f").call(this,{body:e,headers:r})}}Ps=We,Wr=new WeakMap,Is=new WeakSet,Ln=function(){return this.baseURL!=="https://api.openai.com/v1"};We.OpenAI=Ps;We.DEFAULT_TIMEOUT=600000;We.OpenAIError=m;We.APIError=O;We.APIConnectionError=xe;We.APIConnectionTimeoutError=Ae;We.APIUserAbortError=F;We.NotFoundError=yt;We.ConflictError=bt;We.RateLimitError=xt;We.BadRequestError=mt;We.AuthenticationError=_t;We.InternalServerError=At;We.PermissionDeniedError=gt;We.UnprocessableEntityError=wt;We.InvalidWebhookSignatureError=se;We.toFile=Ir;We.Completions=Qe;We.Chat=Re;We.Embeddings=Ze;We.Files=tt;We.Images=ot;We.Audio=ce;We.Moderations=at;We.Models=it;We.FineTuning=te;We.Graders=Me;We.VectorStores=we;We.Webhooks=ht;We.Beta=ee;We.Batches=Ke;We.Uploads=Le;We.Responses=ye;We.Realtime=_e;We.Conversations=Fe;We.Evals=Ne;We.Containers=Te;We.Skills=be;We.Videos=ut;class yu extends We{constructor({baseURL:e=K("OPENAI_BASE_URL"),apiKey:t=K("AZURE_OPENAI_API_KEY"),apiVersion:r=K("OPENAI_API_VERSION"),endpoint:s,deployment:n,azureADTokenProvider:o,dangerouslyAllowBrowser:a,...f}={}){if(!r)throw new m("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 o==="function")a=!0;if(!o&&!t)throw new m("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(o&&t)throw new m("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(f.defaultQuery={...f.defaultQuery,"api-version":r},!e){if(!s)s=process.env.AZURE_OPENAI_ENDPOINT;if(!s)throw new m("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");e=`${s}/openai`}else if(s)throw new m("baseURL and endpoint are mutually exclusive");super({apiKey:o??t,baseURL:e,...f,...a!==void 0?{dangerouslyAllowBrowser:a}:{}});this.apiVersion="",this.apiVersion=r,this.deploymentName=n}async buildRequest(e,t={}){if(ui.has(e.path)&&e.method==="post"&&e.body!==void 0){if(!Be(e.body))throw Error("Expected request body to be an object");let r=this.deploymentName||e.body.model||e.__metadata?.model;if(r!==void 0&&!this.baseURL.includes("/deployments"))e.path=`/deployments/${r}${e.path}`}return super.buildRequest(e,t)}async authHeaders(e){if(typeof this._options.apiKey==="string")return h([{"api-key":this.apiKey}]);return super.authHeaders(e)}}var ui=new Set(["/completions","/chat/completions","/embeddings","/audio/transcriptions","/audio/translations","/audio/speech","/images/generations","/batches","/images/edits"]);export{We,yu};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{$e,qt}from"./chunk-781990k7.js";import{z}from"./chunk-yqvhgtez.js";var _=z($e());var N=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.AccessKeyId==="string"&&typeof e.SecretAccessKey==="string"&&typeof e.Token==="string"&&typeof e.Expiration==="string",h=(e)=>({accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,sessionToken:e.Token,expiration:new Date(e.Expiration),...e.AccountId&&{accountId:e.AccountId}});var C=({maxRetries:e=0,timeout:t=1000})=>({maxRetries:e,timeout:t});var v=z($e());import R from"http";function E(e){return new Promise((t,n)=>{let o=R.request({method:"GET",...e,hostname:e.hostname?.replace(/^\[(.+)\]$/,"$1")});o.on("error",(r)=>{n(Object.assign(new v.ProviderError("Unable to connect to instance metadata service"),r)),o.destroy()}),o.on("timeout",()=>{n(new v.ProviderError("TimeoutError from instance metadata service")),o.destroy()}),o.on("response",(r)=>{let{statusCode:a=400}=r;if(a<200||300<=a)n(Object.assign(new v.ProviderError("Error response received from instance metadata service"),{statusCode:a})),o.destroy();let p=[];r.on("data",(s)=>{p.push(s)}),r.on("end",()=>{t(Buffer.concat(p)),o.destroy()})}),o.end()})}var T=(e,t)=>{let n=e();for(let o=0;o<t;o++)n=n.catch(e);return n};var A="AWS_CONTAINER_CREDENTIALS_FULL_URI",g="AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",D="AWS_CONTAINER_AUTHORIZATION_TOKEN",G=(e={})=>{let{timeout:t,maxRetries:n}=C(e);return()=>T(async()=>{let o=await J({logger:e.logger}),r=JSON.parse(await H(t,o));if(!N(r))throw new _.CredentialsProviderError("Invalid response received from instance metadata service.",{logger:e.logger});return h(r)},n)},H=async(e,t)=>{if(process.env[D])t.headers={...t.headers,Authorization:process.env[D]};return(await E({...t,timeout:e})).toString()},q="169.254.170.2",Y=new Set(["localhost","127.0.0.1"]),j=new Set(["http:","https:"]),J=async({logger:e})=>{if(process.env[g])return{hostname:q,path:process.env[g]};if(process.env[A]){let t;try{t=new URL(process.env[A])}catch{throw new _.CredentialsProviderError(`${process.env[A]} is not a valid container metadata service URL`,{tryNextLink:!1,logger:e})}if(!t.hostname||!Y.has(t.hostname))throw new _.CredentialsProviderError(`${t.hostname} is not a valid container metadata service hostname`,{tryNextLink:!1,logger:e});if(!t.protocol||!j.has(t.protocol))throw new _.CredentialsProviderError(`${t.protocol} is not a valid container metadata service protocol`,{tryNextLink:!1,logger:e});return{protocol:t.protocol,hostname:t.hostname,path:t.pathname+t.search,port:t.port?parseInt(t.port,10):void 0}}throw new _.CredentialsProviderError(`The container metadata credential provider cannot be used unless the ${g} or ${A} environment variable is set`,{tryNextLink:!1,logger:e})};var u=z($e());var y=z($e());class O extends y.CredentialsProviderError{tryNextLink;name="InstanceMetadataV1FallbackError";constructor(e,t=!0){super(e,t);this.tryNextLink=t,Object.setPrototypeOf(this,O.prototype)}}var w=z($e()),F=z(qt());var S;(function(e){e.IPv4="http://169.254.169.254",e.IPv6="http://[fd00:ec2::254]"})(S||(S={}));var P={environmentVariableSelector:(e)=>e.AWS_EC2_METADATA_SERVICE_ENDPOINT,configFileSelector:(e)=>e.ec2_metadata_service_endpoint,default:void 0};var l;(function(e){e.IPv4="IPv4",e.IPv6="IPv6"})(l||(l={}));var X="AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE",Z="ec2_metadata_service_endpoint_mode",L={environmentVariableSelector:(e)=>e[X],configFileSelector:(e)=>e[Z],default:l.IPv4};var b=async()=>F.parseUrl(await Q()||await ee()),Q=async()=>w.loadConfig(P)(),ee=async()=>{let e=await w.loadConfig(L)();switch(e){case l.IPv4:return S.IPv4;case l.IPv6:return S.IPv6;default:throw Error(`Unsupported endpoint mode: ${e}. Select from ${Object.values(l)}`)}};var M=(e,t)=>{let n=300+Math.floor(Math.random()*300),o=new Date(Date.now()+n*1000);t.warn(`Attempting credential expiration extension due to a credential service availability issue. A refresh of these credentials will be attempted after ${new Date(o)}.
2
+ import{Ge,qt}from"./chunk-0g7ayjb5.js";import{z}from"./chunk-jxfz4h24.js";var _=z(Ge());var N=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.AccessKeyId==="string"&&typeof e.SecretAccessKey==="string"&&typeof e.Token==="string"&&typeof e.Expiration==="string",h=(e)=>({accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,sessionToken:e.Token,expiration:new Date(e.Expiration),...e.AccountId&&{accountId:e.AccountId}});var C=({maxRetries:e=0,timeout:t=1000})=>({maxRetries:e,timeout:t});var v=z(Ge());import R from"http";function E(e){return new Promise((t,n)=>{let o=R.request({method:"GET",...e,hostname:e.hostname?.replace(/^\[(.+)\]$/,"$1")});o.on("error",(r)=>{n(Object.assign(new v.ProviderError("Unable to connect to instance metadata service"),r)),o.destroy()}),o.on("timeout",()=>{n(new v.ProviderError("TimeoutError from instance metadata service")),o.destroy()}),o.on("response",(r)=>{let{statusCode:a=400}=r;if(a<200||300<=a)n(Object.assign(new v.ProviderError("Error response received from instance metadata service"),{statusCode:a})),o.destroy();let p=[];r.on("data",(s)=>{p.push(s)}),r.on("end",()=>{t(Buffer.concat(p)),o.destroy()})}),o.end()})}var T=(e,t)=>{let n=e();for(let o=0;o<t;o++)n=n.catch(e);return n};var A="AWS_CONTAINER_CREDENTIALS_FULL_URI",g="AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",D="AWS_CONTAINER_AUTHORIZATION_TOKEN",G=(e={})=>{let{timeout:t,maxRetries:n}=C(e);return()=>T(async()=>{let o=await J({logger:e.logger}),r=JSON.parse(await H(t,o));if(!N(r))throw new _.CredentialsProviderError("Invalid response received from instance metadata service.",{logger:e.logger});return h(r)},n)},H=async(e,t)=>{if(process.env[D])t.headers={...t.headers,Authorization:process.env[D]};return(await E({...t,timeout:e})).toString()},q="169.254.170.2",Y=new Set(["localhost","127.0.0.1"]),j=new Set(["http:","https:"]),J=async({logger:e})=>{if(process.env[g])return{hostname:q,path:process.env[g]};if(process.env[A]){let t;try{t=new URL(process.env[A])}catch{throw new _.CredentialsProviderError(`${process.env[A]} is not a valid container metadata service URL`,{tryNextLink:!1,logger:e})}if(!t.hostname||!Y.has(t.hostname))throw new _.CredentialsProviderError(`${t.hostname} is not a valid container metadata service hostname`,{tryNextLink:!1,logger:e});if(!t.protocol||!j.has(t.protocol))throw new _.CredentialsProviderError(`${t.protocol} is not a valid container metadata service protocol`,{tryNextLink:!1,logger:e});return{protocol:t.protocol,hostname:t.hostname,path:t.pathname+t.search,port:t.port?parseInt(t.port,10):void 0}}throw new _.CredentialsProviderError(`The container metadata credential provider cannot be used unless the ${g} or ${A} environment variable is set`,{tryNextLink:!1,logger:e})};var u=z(Ge());var y=z(Ge());class O extends y.CredentialsProviderError{tryNextLink;name="InstanceMetadataV1FallbackError";constructor(e,t=!0){super(e,t);this.tryNextLink=t,Object.setPrototypeOf(this,O.prototype)}}var w=z(Ge()),F=z(qt());var S;(function(e){e.IPv4="http://169.254.169.254",e.IPv6="http://[fd00:ec2::254]"})(S||(S={}));var P={environmentVariableSelector:(e)=>e.AWS_EC2_METADATA_SERVICE_ENDPOINT,configFileSelector:(e)=>e.ec2_metadata_service_endpoint,default:void 0};var l;(function(e){e.IPv4="IPv4",e.IPv6="IPv6"})(l||(l={}));var X="AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE",Z="ec2_metadata_service_endpoint_mode",L={environmentVariableSelector:(e)=>e[X],configFileSelector:(e)=>e[Z],default:l.IPv4};var b=async()=>F.parseUrl(await Q()||await ee()),Q=async()=>w.loadConfig(P)(),ee=async()=>{let e=await w.loadConfig(L)();switch(e){case l.IPv4:return S.IPv4;case l.IPv6:return S.IPv6;default:throw Error(`Unsupported endpoint mode: ${e}. Select from ${Object.values(l)}`)}};var M=(e,t)=>{let n=300+Math.floor(Math.random()*300),o=new Date(Date.now()+n*1000);t.warn(`Attempting credential expiration extension due to a credential service availability issue. A refresh of these credentials will be attempted after ${new Date(o)}.
3
3
  For more information, please visit: https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html`);let r=e.originalExpiration??e.expiration;return{...e,...r?{originalExpiration:r}:{},expiration:o}};var V=(e,t={})=>{let n=t?.logger||console,o;return async()=>{let r;try{if(r=await e(),r.expiration&&r.expiration.getTime()<Date.now())r=M(r,n)}catch(a){if(o)n.warn("Credential renew failed: ",a),r=M(o,n);else throw a}return o=r,r}};var W="/latest/meta-data/iam/security-credentials/",te="/latest/api/token",x="AWS_EC2_METADATA_V1_DISABLED",k="ec2_metadata_v1_disabled",U="x-aws-ec2-metadata-token",oe=(e={})=>V(re(e),{logger:e.logger}),re=(e={})=>{let t=!1,{logger:n,profile:o}=e,{timeout:r,maxRetries:a}=C(e),p=async(s,m)=>{if(t||m.headers?.[U]==null){let i=!1,c=!1,B=await u.loadConfig({environmentVariableSelector:(d)=>{let f=d[x];if(c=!!f&&f!=="false",f===void 0)throw new u.CredentialsProviderError(`${x} not set in env, checking config file next.`,{logger:e.logger});return c},configFileSelector:(d)=>{let f=d[k];return i=!!f&&f!=="false",i},default:!1},{profile:o})();if(e.ec2MetadataV1Disabled||B){let d=[];if(e.ec2MetadataV1Disabled)d.push("credential provider initialization (runtime option ec2MetadataV1Disabled)");if(i)d.push(`config file profile (${k})`);if(c)d.push(`process environment variable (${x})`);throw new O(`AWS EC2 Metadata v1 fallback has been blocked by AWS SDK configuration in the following: [${d.join(", ")}].`)}}let K=(await T(async()=>{let i;try{i=await ae(m)}catch(c){if(c.statusCode===401)t=!1;throw c}return i},s)).trim();return T(async()=>{let i;try{i=await se(K,m,e)}catch(c){if(c.statusCode===401)t=!1;throw c}return i},s)};return async()=>{let s=await b();if(t)return n?.debug("AWS SDK Instance Metadata","using v1 fallback (no token fetch)"),p(a,{...s,timeout:r});else{let m;try{m=(await ne({...s,timeout:r})).toString()}catch(I){if(I?.statusCode===400)throw Object.assign(I,{message:"EC2 Metadata token request returned error"});else if(I.message==="TimeoutError"||[403,404,405].includes(I.statusCode))t=!0;return n?.debug("AWS SDK Instance Metadata","using v1 fallback (initial)"),p(a,{...s,timeout:r})}return p(a,{...s,headers:{[U]:m},timeout:r})}}},ne=async(e)=>E({...e,path:te,method:"PUT",headers:{"x-aws-ec2-metadata-token-ttl-seconds":"21600"}}),ae=async(e)=>(await E({...e,path:W})).toString(),se=async(e,t,n)=>{let o=JSON.parse((await E({...t,path:W+e})).toString());if(!N(o))throw new u.CredentialsProviderError("Invalid response received from instance metadata service.",{logger:n.logger});return h(o)};export{A as ENV_CMDS_FULL_URI,g as ENV_CMDS_RELATIVE_URI,G as fromContainerMetadata,oe as fromInstanceMetadata};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var c=(s)=>s;function Fa(s,i,t=c){let n=new Map;for(let e of s.tools??[])n.set(t(e.name),e);if(!i)return{immediate:[...n.values()],deferred:new Map};let a=new Set,f=new Set;for(let e of s.messages)if(e.role==="assistant"){for(let o of e.content)if(o.type==="toolCall")f.add(t(o.name))}else if(e.role==="toolResult")for(let o of e.addedToolNames??[]){let l=t(o);if(!f.has(l))a.add(l)}let d=[],r=new Map;for(let[e,o]of n)if(a.has(e))r.set(e,o);else d.push(o);return{immediate:d,deferred:r}}
3
- export{Fa};
2
+ var c=(s)=>s;function Li(s,i,t=c){let n=new Map;for(let e of s.tools??[])n.set(t(e.name),e);if(!i)return{immediate:[...n.values()],deferred:new Map};let a=new Set,f=new Set;for(let e of s.messages)if(e.role==="assistant"){for(let o of e.content)if(o.type==="toolCall")f.add(t(o.name))}else if(e.role==="toolResult")for(let o of e.addedToolNames??[]){let l=t(o);if(!f.has(l))a.add(l)}let d=[],r=new Map;for(let[e,o]of n)if(a.has(e))r.set(e,o);else d.push(o);return{immediate:d,deferred:r}}
3
+ export{Li};
@@ -1,2 +1,2 @@
1
- import{h,D,b,u,S,L,t,o,K,Z,B,ft,Me,A,C,Cg,Ig,hC,Pt,As,Nr,An,$n,Vc,yr,on,Ur,$t,lr,gr,Lo}from"./chunk-q6jsw0rr.js";import{Or}from"./chunk-5rk7dyx9.js";import{xa}from"./chunk-6rjkbwz6.js";import{wa}from"./chunk-rkafv27g.js";import{ai,Zl}from"./chunk-r55htzxr.js";import{Bl}from"./chunk-4a88wwg2.js";import{Sa}from"./chunk-xca338dw.js";import{Er}from"./chunk-xznabrt2.js";S();function ke(i,s,P,r,c,f){let O=i.type==="folder",y=s.type==="folder";if(O!==y)return null;let w=y?r:c,k=w.findIndex((a)=>a.id===P),v=w.findIndex((a)=>a.id===s.id);if(k===-1||v===-1)return null;let W=Math.min(k,v),U=Math.max(k,v),N=w.slice(W,U+1),l=new Set(f);return N.forEach((a)=>{if(a.id)l.add(a.id)}),l}function Gn({teamId:i,projectId:s,projectName:P,assetId:r,rootFolderId:c,collection:f,onUpdateCollection:O}){let y=Me(),w=K(),{canEdit:k}=Pt(s),{setFields:v}=Or(),W=A.api.files[":fileId"].metadata.$patch,{mutate:U}=B({mutationFn:async(e)=>{if(!(await W(e)).ok)throw Error("Failed to patch metadata");return null}}),{data:N}=Z({queryKey:["fields",s],queryFn:async()=>{let e=await A.api.projects[":projectId"].fields.$get({param:{projectId:s}});if(!e.ok)throw Error("Failed to fetch fields");return await e.json()},enabled:!!s});h(()=>{if(N)v(N,s)},[N,s,v]);let l=r==="recently-deleted",a=r==="recents",[_,M]=u(null),[p,z]=u(new Set),[H,E]=u(null),[Ne,Ae]=u(240),[ze,Le]=u(360),{isChatbotOpen:V}=lr(),{members:Re,fetchMembers:oe}=Ur(),{metadata:ae,fetchMetadata:re,setMetadata:je}=gr(),ie=Boolean(ae["appearance.hideAgent"]);h(()=>{if(i)oe(i),re(i)},[i,oe,re]);let X=D(()=>f?.filter?.searchFilter?.conditions||[],[f]),[R,G]=u(X);h(()=>{G(X)},[X]);let le=`project:${s}:sort`,j=ae[le]||{field:"custom",order:"asc"},De=(e)=>{if(e)je(i,le,e)},x=!!f,Q=R.length>0||x,{fileListLeftSidebarCollapsed:de,setFileListLeftSidebarCollapsed:$e,fileListRightSidebarCollapsed:ce,setFileListRightSidebarCollapsed:Te,viewModes:qe}=$t(),fe=qe[s]??"card",Ee=b(null),{data:T}=l||a?{data:void 0}:Z({queryKey:["folders",r],queryFn:async()=>{let e=await A.api.folders[":folderId"].$get({param:{folderId:r}});if(!e.ok)throw Error("failed to fetch folder");return await e.json()}}),{setProjectState:pe,clearProjectState:ue}=on();h(()=>(pe({teamId:i,projectId:s,projectName:P,rootFolderId:c,ancestorFolders:T?.ancestorFolders??[],currentAsset:l?{name:Cg(),type:"folder"}:a?{name:Ig(),type:"folder"}:x?{id:f.id,name:f.name,type:"folder"}:{id:T?.id||r,name:T?.name,type:"folder"},isRootFolder:!l&&!a&&!x&&r===c,onFolderClick:(e)=>{y({to:"/projects/$projectId/folders/$folderId",params:{projectId:s,folderId:e}})}}),()=>ue()),[i,s,P,T,l,a,r,c,pe,ue,y]);let{data:J,fetchNextPage:ge,hasNextPage:he,isFetchingNextPage:me,isLoading:Ke}=ft({queryKey:l?["projects",s,"recently-deleted","folder"]:a?["projects",s,"recents","folder"]:["search",i,r,"folder",R,j,x],queryFn:async({pageParam:e})=>{if(l||x||a){if(l){let d=await A.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:s},query:{assetType:"folder",after:e}});if(!d.ok)throw Error("failed to fetch recently deleted folders");return await d.json()}return{data:[],pageInfo:{total:0}}}if(Q)return{data:[],pageInfo:{total:0}};let n=await A.api.folders[":folderId"].search.$post({param:{folderId:r},json:{assetType:"folder",after:e,recursively:!1,sort:j,conditions:[]}});if(!n.ok)throw Error("failed to search folders");return await n.json()},enabled:!Q&&!a,initialPageParam:"",getNextPageParam:(e)=>e.pageInfo?.cursor||void 0}),{data:Y,fetchNextPage:ye,hasNextPage:xe,isFetchingNextPage:Se,isLoading:Qe}=ft({queryKey:l?["projects",s,"recently-deleted","file"]:a?["projects",s,"recents","file"]:["search",i,r,"file",R,j,x],queryFn:async({pageParam:e})=>{if(l){let d=await A.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:s},query:{assetType:"file",after:e}});if(!d.ok)throw Error("failed to fetch recently deleted files");return await d.json()}if(a){let d=await A.api.projects[":projectId"].recents.$get({param:{projectId:s},query:{after:e,first:"20"}});if(!d.ok)throw Error("failed to fetch recent files");return await d.json()}let n=await A.api.folders[":folderId"].search.$post({param:{folderId:r},json:{assetType:"file",after:e,recursively:Q||x,conditions:R,sort:j}});if(!n.ok)throw Error("failed to search files");return await n.json()},initialPageParam:"",getNextPageParam:(e)=>e.pageInfo?.cursor||void 0}),I=J?.pages.flatMap((e)=>e.data??[])??[],g=Y?.pages.flatMap((e)=>e.data??[])??[],Fe=(!Q&&!a?Ke:!1)||Qe,we=J?.pages[0]?.pageInfo?.total,be=Y?.pages[0]?.pageInfo?.total,ve=J?.pages[0]?.pageInfo?.totalSize,Ie=Y?.pages[0]?.pageInfo?.totalSize,ee=()=>{z(new Set),M(null),E(null)},{dragState:q,handleDragStart:Oe,handleDragEnd:We}=Zl({teamId:i,projectId:s,assetId:r,folders:I,files:g,selectedIds:p,onClearSelection:ee}),te=D(()=>{if(p.size!==1)return null;let e=Array.from(p)[0];return g.find((d)=>d.id===e)||null},[p,g]),Ce=(e)=>{if(l)return;if(e.type==="folder")G([]),y({to:"/projects/$projectId/folders/$folderId",params:{projectId:s,folderId:e.id}});else y({to:"/projects/$projectId/files/$fileId",params:{projectId:s,fileId:e.versionStack?e.versionStack.id:e.id},search:{version:void 0}})},Pe=(e,n)=>{let d=n.metaKey||n.ctrlKey;if(n.shiftKey&&H){let ne=[...I,...g].find((m)=>m.id===H);if(ne){let m=ke(ne,e,H,I,g,p);if(m){z(m),M(e);return}}}if(d){let F=new Set(p);if(F.has(e.id)){if(F.delete(e.id),z(F),_?.id===e.id){let m=[...I,...g].find((Ue)=>F.has(Ue.id));M(m||null),E(m?m.id:null)}}else F.add(e.id),z(F),E(e.id),M(e);return}z(new Set([e.id])),E(e.id),M(e)},se=(e,n,d)=>{U({param:{fileId:e},json:[{key:n,value:d}]},{onSuccess:()=>{w.invalidateQueries({queryKey:["folders",r,"children",{assetType:"file"}]}),w.invalidateQueries({queryKey:["search",i,r]})}})};if(Lo())return t(Bl,{teamId:i,projectId:s,assetId:r,folders:I,files:g,totalFolders:we,totalFiles:be,totalFoldersSize:ve,totalFilesSize:Ie,selectedItem:_,selectedIds:p,onItemSelect:Pe,onItemDoubleClick:Ce,onSaveField:se,onClearSelection:ee,fetchNextFoldersPage:ge,hasNextFoldersPage:he||!1,isFetchingNextFoldersPage:me,fetchNextFilesPage:ye,hasNextFilesPage:xe||!1,isFetchingNextFilesPage:Se,isRecentlyDeleted:l,isRecents:a,isLoading:Fe,rootFolderId:c});return o($n,{modifiers:[ai.configure({anchor:{x:0,y:0}})],plugins:(e)=>e.map((n)=>{if(n===As)return As.configure({dropAnimation:null});if(typeof n==="object"&&n!==null&&"plugin"in n&&n.plugin===As)return As.configure({dropAnimation:null});return n}),sensors:l||a||!k?[]:[An.configure({activationConstraints:[new Nr.Distance({value:10})]})],onDragStart:Oe,onDragEnd:We,children:[t("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:o("div",{ref:Ee,className:"flex flex-1 overflow-hidden relative",children:[!de&&t("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>$e(!0)}),(!ce||V)&&t("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>{Te(!0),lr.getState().setIsChatbotOpen(!1)}}),!de&&o(L,{children:[t("div",{className:"bg-background",style:{width:Ne},children:t(yr,{teamId:i,projectId:s,projectName:P,rootFolderId:c,dragState:q,ancestorFolders:T?.ancestorFolders??[]})}),t(Er,{onResize:(e)=>{Ae((n)=>Math.max(180,Math.min(400,n+e)))},className:"hidden md:block"})]}),t(xa,{teamId:i,projectId:s,assetId:r,folders:I,files:g,totalFolders:we,totalFiles:be,totalFoldersSize:ve,totalFilesSize:Ie,selectedItem:_,selectedIds:p,onItemSelect:Pe,onItemDoubleClick:Ce,onSaveField:se,displayStyle:fe,onClearSelection:ee,fetchNextFoldersPage:ge,hasNextFoldersPage:he||!1,isFetchingNextFoldersPage:me,fetchNextFilesPage:ye,hasNextFilesPage:xe||!1,isFetchingNextFilesPage:Se,isRecentlyDeleted:l,isRecents:a,isLoading:Fe,filterConditions:R,onFilterChange:G,sort:j,onSortChange:De,dragState:q,collection:f,onUpdateCollection:O,rootFolderId:c}),(!ce||V&&!ie)&&o(L,{children:[t(Er,{onResize:(e)=>{Le((n)=>Math.max(240,Math.min(600,n-e)))},className:"hidden md:block"}),t("div",{style:{width:ze},className:"bg-background flex flex-col flex-shrink-0",children:V&&!ie?t(wa,{projectId:s,contextAssetId:r}):te?t(Sa,{teamId:i,projectId:s,file:te,onSaveField:(e,n)=>se(te.id,e,n),members:Re,hideAnnotationControl:!0}):t("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:hC()})})]})]})}),t(Vc,{children:q?.isActive?t("div",{className:C("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",fe==="list"&&"w-30 h-[40px] px-0 flex-none overflow-hidden justify-center"),style:{transform:"translate(0px, 0px)"},children:o("span",{children:["Moving ",q.itemCount," item",q.itemCount!==1?"s":""]})}):null})]})}
1
+ import{h,P,b,u,S,L,t,o,Q,Z,B,ft,ke,A,C,Dg,Og,kC,Dt,As,Nr,An,$n,Kc,yr,on,Ur,$t,lr,gr,Lo}from"./chunk-17k9a427.js";import{Or}from"./chunk-v8ngtwzx.js";import{Si}from"./chunk-kmx350y5.js";import{xi}from"./chunk-q6k1ctph.js";import{aa,Bl}from"./chunk-pw81eh3g.js";import{Ul}from"./chunk-s9whhdb3.js";import{Ei}from"./chunk-thzf89fp.js";import{Er}from"./chunk-dzj91k6v.js";S();function Ne(i,s,k,r,c,f){let O=i.type==="folder",y=s.type==="folder";if(O!==y)return null;let w=y?r:c,N=w.findIndex((a)=>a.id===k),v=w.findIndex((a)=>a.id===s.id);if(N===-1||v===-1)return null;let W=Math.min(N,v),U=Math.max(N,v),M=w.slice(W,U+1),l=new Set(f);return M.forEach((a)=>{if(a.id)l.add(a.id)}),l}function Gn({teamId:i,projectId:s,projectName:k,assetId:r,rootFolderId:c,collection:f,onUpdateCollection:O}){let y=ke(),w=Q(),{canEdit:N}=Dt(s),{setFields:v}=Or(),W=A.api.files[":fileId"].metadata.$patch,{mutate:U}=B({mutationFn:async(e)=>{if(!(await W(e)).ok)throw Error("Failed to patch metadata");return null}}),{data:M}=Z({queryKey:["fields",s],queryFn:async()=>{let e=await A.api.projects[":projectId"].fields.$get({param:{projectId:s}});if(!e.ok)throw Error("Failed to fetch fields");return await e.json()},enabled:!!s});h(()=>{if(M)v(M,s)},[M,s,v]);let l=r==="recently-deleted",a=r==="recents",[_,z]=u(null),[p,R]=u(new Set),[H,E]=u(null),[Me,Ae]=u(240),[ze,Le]=u(360),{isChatbotOpen:V}=lr(),{members:Re,fetchMembers:oe}=Ur(),{metadata:ae,fetchMetadata:re,setMetadata:je}=gr(),ie=Boolean(ae["appearance.hideAgent"]);h(()=>{if(i)oe(i),re(i)},[i,oe,re]);let X=P(()=>f?.filter?.searchFilter?.conditions||[],[f]),[j,G]=u(X);h(()=>{G(X)},[X]);let le=`project:${s}:sort`,D=ae[le]||{field:"custom",order:"asc"},De=(e)=>{if(e)je(i,le,e)},x=!!f,K=j.length>0||x,{fileListLeftSidebarCollapsed:de,setFileListLeftSidebarCollapsed:$e,fileListRightSidebarCollapsed:ce,setFileListRightSidebarCollapsed:Te,viewModes:qe}=$t(),fe=qe[s]??"card",Ee=b(null),{data:T}=l||a?{data:void 0}:Z({queryKey:["folders",r],queryFn:async()=>{let e=await A.api.folders[":folderId"].$get({param:{folderId:r}});if(!e.ok)throw Error("failed to fetch folder");return await e.json()}}),{setProjectState:pe,clearProjectState:ue}=on();h(()=>(pe({teamId:i,projectId:s,projectName:k,rootFolderId:c,ancestorFolders:T?.ancestorFolders??[],currentAsset:l?{name:Dg(),type:"folder"}:a?{name:Og(),type:"folder"}:x?{id:f.id,name:f.name,type:"folder"}:{id:T?.id||r,name:T?.name,type:"folder"},isRootFolder:!l&&!a&&!x&&r===c,onFolderClick:(e)=>{y({to:"/projects/$projectId/folders/$folderId",params:{projectId:s,folderId:e}})}}),()=>ue()),[i,s,k,T,l,a,r,c,pe,ue,y]);let{data:J,fetchNextPage:ge,hasNextPage:he,isFetchingNextPage:me,isLoading:Ke}=ft({queryKey:l?["projects",s,"recently-deleted","folder"]:a?["projects",s,"recents","folder"]:["search",i,r,"folder",j,D,x],queryFn:async({pageParam:e})=>{if(l||x||a){if(l){let d=await A.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:s},query:{assetType:"folder",after:e}});if(!d.ok)throw Error("failed to fetch recently deleted folders");return await d.json()}return{data:[],pageInfo:{total:0}}}if(K)return{data:[],pageInfo:{total:0}};let n=await A.api.folders[":folderId"].search.$post({param:{folderId:r},json:{assetType:"folder",after:e,recursively:!1,sort:D,conditions:[]}});if(!n.ok)throw Error("failed to search folders");return await n.json()},enabled:!K&&!a,initialPageParam:"",getNextPageParam:(e)=>e.pageInfo?.cursor||void 0}),{data:Y,fetchNextPage:ye,hasNextPage:xe,isFetchingNextPage:Se,isLoading:Qe}=ft({queryKey:l?["projects",s,"recently-deleted","file"]:a?["projects",s,"recents","file"]:["search",i,r,"file",j,D,x],queryFn:async({pageParam:e})=>{if(l){let d=await A.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:s},query:{assetType:"file",after:e}});if(!d.ok)throw Error("failed to fetch recently deleted files");return await d.json()}if(a){let d=await A.api.projects[":projectId"].recents.$get({param:{projectId:s},query:{after:e,first:"20"}});if(!d.ok)throw Error("failed to fetch recent files");return await d.json()}let n=await A.api.folders[":folderId"].search.$post({param:{folderId:r},json:{assetType:"file",after:e,recursively:K||x,conditions:j,sort:D}});if(!n.ok)throw Error("failed to search files");return await n.json()},initialPageParam:"",getNextPageParam:(e)=>e.pageInfo?.cursor||void 0}),I=J?.pages.flatMap((e)=>e.data??[])??[],g=Y?.pages.flatMap((e)=>e.data??[])??[],Fe=(!K&&!a?Ke:!1)||Qe,we=J?.pages[0]?.pageInfo?.total,be=Y?.pages[0]?.pageInfo?.total,ve=J?.pages[0]?.pageInfo?.totalSize,Ie=Y?.pages[0]?.pageInfo?.totalSize,ee=()=>{R(new Set),z(null),E(null)},{dragState:q,handleDragStart:Oe,handleDragEnd:We}=Bl({teamId:i,projectId:s,assetId:r,folders:I,files:g,selectedIds:p,onClearSelection:ee}),te=P(()=>{if(p.size!==1)return null;let e=Array.from(p)[0];return g.find((d)=>d.id===e)||null},[p,g]),Ce=(e)=>{if(l)return;if(e.type==="folder")G([]),y({to:"/projects/$projectId/folders/$folderId",params:{projectId:s,folderId:e.id}});else y({to:"/projects/$projectId/files/$fileId",params:{projectId:s,fileId:e.versionStack?e.versionStack.id:e.id},search:{version:void 0}})},Pe=(e,n)=>{let d=n.metaKey||n.ctrlKey;if(n.shiftKey&&H){let ne=[...I,...g].find((m)=>m.id===H);if(ne){let m=Ne(ne,e,H,I,g,p);if(m){R(m),z(e);return}}}if(d){let F=new Set(p);if(F.has(e.id)){if(F.delete(e.id),R(F),_?.id===e.id){let m=[...I,...g].find((Ue)=>F.has(Ue.id));z(m||null),E(m?m.id:null)}}else F.add(e.id),R(F),E(e.id),z(e);return}R(new Set([e.id])),E(e.id),z(e)},se=(e,n,d)=>{U({param:{fileId:e},json:[{key:n,value:d}]},{onSuccess:()=>{w.invalidateQueries({queryKey:["folders",r,"children",{assetType:"file"}]}),w.invalidateQueries({queryKey:["search",i,r]})}})};if(Lo())return t(Ul,{teamId:i,projectId:s,assetId:r,folders:I,files:g,totalFolders:we,totalFiles:be,totalFoldersSize:ve,totalFilesSize:Ie,selectedItem:_,selectedIds:p,onItemSelect:Pe,onItemDoubleClick:Ce,onSaveField:se,onClearSelection:ee,fetchNextFoldersPage:ge,hasNextFoldersPage:he||!1,isFetchingNextFoldersPage:me,fetchNextFilesPage:ye,hasNextFilesPage:xe||!1,isFetchingNextFilesPage:Se,isRecentlyDeleted:l,isRecents:a,isLoading:Fe,rootFolderId:c});return o($n,{modifiers:[aa.configure({anchor:{x:0,y:0}})],plugins:(e)=>e.map((n)=>{if(n===As)return As.configure({dropAnimation:null});if(typeof n==="object"&&n!==null&&"plugin"in n&&n.plugin===As)return As.configure({dropAnimation:null});return n}),sensors:l||a||!N?[]:[An.configure({activationConstraints:[new Nr.Distance({value:10})]})],onDragStart:Oe,onDragEnd:We,children:[t("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:o("div",{ref:Ee,className:"flex flex-1 overflow-hidden relative",children:[!de&&t("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>$e(!0)}),(!ce||V)&&t("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>{Te(!0),lr.getState().setIsChatbotOpen(!1)}}),!de&&o(L,{children:[t("div",{className:"bg-background",style:{width:Me},children:t(yr,{teamId:i,projectId:s,projectName:k,rootFolderId:c,dragState:q,ancestorFolders:T?.ancestorFolders??[]})}),t(Er,{onResize:(e)=>{Ae((n)=>Math.max(180,Math.min(400,n+e)))},className:"hidden md:block"})]}),t(Si,{teamId:i,projectId:s,assetId:r,folders:I,files:g,totalFolders:we,totalFiles:be,totalFoldersSize:ve,totalFilesSize:Ie,selectedItem:_,selectedIds:p,onItemSelect:Pe,onItemDoubleClick:Ce,onSaveField:se,displayStyle:fe,onClearSelection:ee,fetchNextFoldersPage:ge,hasNextFoldersPage:he||!1,isFetchingNextFoldersPage:me,fetchNextFilesPage:ye,hasNextFilesPage:xe||!1,isFetchingNextFilesPage:Se,isRecentlyDeleted:l,isRecents:a,isLoading:Fe,filterConditions:j,onFilterChange:G,sort:D,onSortChange:De,dragState:q,collection:f,onUpdateCollection:O,rootFolderId:c}),(!ce||V&&!ie)&&o(L,{children:[t(Er,{onResize:(e)=>{Le((n)=>Math.max(240,Math.min(600,n-e)))},className:"hidden md:block"}),t("div",{style:{width:ze},className:"bg-background flex flex-col flex-shrink-0",children:V&&!ie?t(xi,{projectId:s,contextAssetId:r}):te?t(Ei,{teamId:i,projectId:s,file:te,onSaveField:(e,n)=>se(te.id,e,n),members:Re,hideAnnotationControl:!0}):t("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:kC()})})]})]})}),t(Kc,{children:q?.isActive?t("div",{className:C("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",fe==="list"&&"w-30 h-[40px] px-0 flex-none overflow-hidden justify-center"),style:{transform:"translate(0px, 0px)"},children:o("span",{children:["Moving ",q.itemCount," item",q.itemCount!==1?"s":""]})}):null})]})}
2
2
  export{Gn};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Dt}from"./chunk-s30fjvzs.js";import{$e}from"./chunk-781990k7.js";import{z}from"./chunk-yqvhgtez.js";var p=z($e());var G=(e)=>e&&(typeof e.sso_start_url==="string"||typeof e.sso_account_id==="string"||typeof e.sso_session==="string"||typeof e.sso_region==="string"||typeof e.sso_role_name==="string");var N=z(Dt());var c=z($e());var K=300000,_="To refresh this SSO session run 'aws sso login' with the corresponding profile.";var H=async(e,o={},r)=>{let{SSOOIDCClient:t}=await import("./chunk-ccvjwhqq.js"),n=(f)=>o.clientConfig?.[f]??o.parentClientConfig?.[f]??r?.[f];return new t(Object.assign({},o.clientConfig??{},{region:e??o.clientConfig?.region,logger:n("logger"),userAgentAppId:n("userAgentAppId")}))};var U=async(e,o,r={},t)=>{let{CreateTokenCommand:n}=await import("./chunk-ccvjwhqq.js");return(await H(o,r,t)).send(new n({clientId:e.clientId,clientSecret:e.clientSecret,refreshToken:e.refreshToken,grantType:"refresh_token"}))};var j=z($e());var A=(e)=>{if(e.expiration&&e.expiration.getTime()<Date.now())throw new j.TokenProviderError(`Token is expired. ${_}`,!1)};var q=z($e());var m=(e,o,r=!1)=>{if(typeof o>"u")throw new q.TokenProviderError(`Value not present for '${e}' in SSO Token${r?". Cannot refresh":""}. ${_}`,!1)};var W=z($e());import{promises as Q}from"fs";var{writeFile:Z}=Q,X=(e,o)=>{let r=W.getSSOTokenFilepath(e),t=JSON.stringify(o,null,2);return Z(r,t)};var J=new Map,I=(e={})=>async({callerClientConfig:o}={})=>{e.logger?.debug("@aws-sdk/token-providers - fromSso");let r=await c.parseKnownFiles(e),t=c.getProfileName({profile:e.profile??o?.profile}),n=r[t];if(!n)throw new c.TokenProviderError(`Profile '${t}' could not be found in shared credentials file.`,!1);else if(!n.sso_session)throw new c.TokenProviderError(`Profile '${t}' is missing required property 'sso_session'.`);let i=n.sso_session,g=(await c.loadSsoSessionData(e))[i];if(!g)throw new c.TokenProviderError(`Sso session '${i}' could not be found in shared credentials file.`,!1);for(let l of["sso_start_url","sso_region"])if(!g[l])throw new c.TokenProviderError(`Sso session '${i}' is missing required property '${l}'.`,!1);let{sso_start_url:S,sso_region:O}=g,s;try{s=await c.getSSOTokenFromFile(i)}catch(l){throw new c.TokenProviderError(`The SSO session token associated with profile=${t} was not found or is invalid. ${_}`,!1)}m("accessToken",s.accessToken),m("expiresAt",s.expiresAt);let{accessToken:k,expiresAt:T}=s,a={token:k,expiration:new Date(T)};if(a.expiration.getTime()-Date.now()>K)return a;let d=J.get(i)??0;if(Date.now()-d<30000)return A(a),a;m("clientId",s.clientId,!0),m("clientSecret",s.clientSecret,!0),m("refreshToken",s.refreshToken,!0);try{J.set(i,Date.now());let l=await U(s,O,e,o);m("accessToken",l.accessToken),m("expiresIn",l.expiresIn);let x=new Date(Date.now()+l.expiresIn*1000);try{await X(i,{...s,accessToken:l.accessToken,expiresAt:x.toISOString(),refreshToken:l.refreshToken})}catch(h){}return{token:l.accessToken,expiration:x}}catch(l){return A(a),a}};var w=z($e()),C=!1,R=async({ssoStartUrl:e,ssoSession:o,ssoAccountId:r,ssoRegion:t,ssoRoleName:n,ssoClient:i,clientConfig:f,parentClientConfig:g,callerClientConfig:S,profile:O,filepath:s,configFilepath:k,ignoreCache:T,logger:a})=>{let d,l="To refresh this SSO session run aws sso login with the corresponding profile.";if(o)try{let u=await I({profile:O,filepath:s,configFilepath:k,ignoreCache:T,clientConfig:f,parentClientConfig:g,logger:a})({callerClientConfig:S});d={accessToken:u.token,expiresAt:new Date(u.expiration).toISOString()}}catch(u){throw new w.CredentialsProviderError(u.message,{tryNextLink:C,logger:a})}else try{d=await w.getSSOTokenFromFile(e)}catch(u){throw new w.CredentialsProviderError("The SSO session associated with this profile is invalid. To refresh this SSO session run aws sso login with the corresponding profile.",{tryNextLink:C,logger:a})}if(new Date(d.expiresAt).getTime()-Date.now()<=0)throw new w.CredentialsProviderError("The SSO session associated with this profile has expired. To refresh this SSO session run aws sso login with the corresponding profile.",{tryNextLink:C,logger:a});let{accessToken:x}=d,{SSOClient:h,GetRoleCredentialsCommand:y}=await import("./chunk-nn5hyf6f.js"),B=i||new h(Object.assign({},f??{},{logger:f?.logger??S?.logger??g?.logger,region:f?.region??t,userAgentAppId:f?.userAgentAppId??S?.userAgentAppId??g?.userAgentAppId})),v;try{v=await B.send(new y({accountId:r,roleName:n,accessToken:x}))}catch(u){throw new w.CredentialsProviderError(u,{tryNextLink:C,logger:a})}let{roleCredentials:{accessKeyId:P,secretAccessKey:F,sessionToken:D,expiration:L,credentialScope:M,accountId:b}={}}=v;if(!P||!F||!D||!L)throw new w.CredentialsProviderError("SSO returns an invalid temporary credential.",{tryNextLink:C,logger:a});let E={accessKeyId:P,secretAccessKey:F,sessionToken:D,expiration:new Date(L),...M&&{credentialScope:M},...b&&{accountId:b}};if(o)N.setCredentialFeature(E,"CREDENTIALS_SSO","s");else N.setCredentialFeature(E,"CREDENTIALS_SSO_LEGACY","u");return E};var V=z($e()),Y=(e,o)=>{let{sso_start_url:r,sso_account_id:t,sso_region:n,sso_role_name:i}=e;if(!r||!t||!n||!i)throw new V.CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", "sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(e).join(", ")}
2
+ import{Pt}from"./chunk-fw5xzcnf.js";import{Ge}from"./chunk-0g7ayjb5.js";import{z}from"./chunk-jxfz4h24.js";var p=z(Ge());var G=(e)=>e&&(typeof e.sso_start_url==="string"||typeof e.sso_account_id==="string"||typeof e.sso_session==="string"||typeof e.sso_region==="string"||typeof e.sso_role_name==="string");var N=z(Pt());var c=z(Ge());var K=300000,_="To refresh this SSO session run 'aws sso login' with the corresponding profile.";var H=async(e,o={},r)=>{let{SSOOIDCClient:t}=await import("./chunk-sfwmwrq3.js"),n=(f)=>o.clientConfig?.[f]??o.parentClientConfig?.[f]??r?.[f];return new t(Object.assign({},o.clientConfig??{},{region:e??o.clientConfig?.region,logger:n("logger"),userAgentAppId:n("userAgentAppId")}))};var U=async(e,o,r={},t)=>{let{CreateTokenCommand:n}=await import("./chunk-sfwmwrq3.js");return(await H(o,r,t)).send(new n({clientId:e.clientId,clientSecret:e.clientSecret,refreshToken:e.refreshToken,grantType:"refresh_token"}))};var j=z(Ge());var A=(e)=>{if(e.expiration&&e.expiration.getTime()<Date.now())throw new j.TokenProviderError(`Token is expired. ${_}`,!1)};var q=z(Ge());var m=(e,o,r=!1)=>{if(typeof o>"u")throw new q.TokenProviderError(`Value not present for '${e}' in SSO Token${r?". Cannot refresh":""}. ${_}`,!1)};var W=z(Ge());import{promises as Q}from"fs";var{writeFile:Z}=Q,X=(e,o)=>{let r=W.getSSOTokenFilepath(e),t=JSON.stringify(o,null,2);return Z(r,t)};var J=new Map,I=(e={})=>async({callerClientConfig:o}={})=>{e.logger?.debug("@aws-sdk/token-providers - fromSso");let r=await c.parseKnownFiles(e),t=c.getProfileName({profile:e.profile??o?.profile}),n=r[t];if(!n)throw new c.TokenProviderError(`Profile '${t}' could not be found in shared credentials file.`,!1);else if(!n.sso_session)throw new c.TokenProviderError(`Profile '${t}' is missing required property 'sso_session'.`);let i=n.sso_session,g=(await c.loadSsoSessionData(e))[i];if(!g)throw new c.TokenProviderError(`Sso session '${i}' could not be found in shared credentials file.`,!1);for(let l of["sso_start_url","sso_region"])if(!g[l])throw new c.TokenProviderError(`Sso session '${i}' is missing required property '${l}'.`,!1);let{sso_start_url:S,sso_region:O}=g,s;try{s=await c.getSSOTokenFromFile(i)}catch(l){throw new c.TokenProviderError(`The SSO session token associated with profile=${t} was not found or is invalid. ${_}`,!1)}m("accessToken",s.accessToken),m("expiresAt",s.expiresAt);let{accessToken:k,expiresAt:T}=s,a={token:k,expiration:new Date(T)};if(a.expiration.getTime()-Date.now()>K)return a;let d=J.get(i)??0;if(Date.now()-d<30000)return A(a),a;m("clientId",s.clientId,!0),m("clientSecret",s.clientSecret,!0),m("refreshToken",s.refreshToken,!0);try{J.set(i,Date.now());let l=await U(s,O,e,o);m("accessToken",l.accessToken),m("expiresIn",l.expiresIn);let x=new Date(Date.now()+l.expiresIn*1000);try{await X(i,{...s,accessToken:l.accessToken,expiresAt:x.toISOString(),refreshToken:l.refreshToken})}catch(h){}return{token:l.accessToken,expiration:x}}catch(l){return A(a),a}};var w=z(Ge()),C=!1,R=async({ssoStartUrl:e,ssoSession:o,ssoAccountId:r,ssoRegion:t,ssoRoleName:n,ssoClient:i,clientConfig:f,parentClientConfig:g,callerClientConfig:S,profile:O,filepath:s,configFilepath:k,ignoreCache:T,logger:a})=>{let d,l="To refresh this SSO session run aws sso login with the corresponding profile.";if(o)try{let u=await I({profile:O,filepath:s,configFilepath:k,ignoreCache:T,clientConfig:f,parentClientConfig:g,logger:a})({callerClientConfig:S});d={accessToken:u.token,expiresAt:new Date(u.expiration).toISOString()}}catch(u){throw new w.CredentialsProviderError(u.message,{tryNextLink:C,logger:a})}else try{d=await w.getSSOTokenFromFile(e)}catch(u){throw new w.CredentialsProviderError("The SSO session associated with this profile is invalid. To refresh this SSO session run aws sso login with the corresponding profile.",{tryNextLink:C,logger:a})}if(new Date(d.expiresAt).getTime()-Date.now()<=0)throw new w.CredentialsProviderError("The SSO session associated with this profile has expired. To refresh this SSO session run aws sso login with the corresponding profile.",{tryNextLink:C,logger:a});let{accessToken:x}=d,{SSOClient:h,GetRoleCredentialsCommand:y}=await import("./chunk-tefct00a.js"),B=i||new h(Object.assign({},f??{},{logger:f?.logger??S?.logger??g?.logger,region:f?.region??t,userAgentAppId:f?.userAgentAppId??S?.userAgentAppId??g?.userAgentAppId})),v;try{v=await B.send(new y({accountId:r,roleName:n,accessToken:x}))}catch(u){throw new w.CredentialsProviderError(u,{tryNextLink:C,logger:a})}let{roleCredentials:{accessKeyId:P,secretAccessKey:F,sessionToken:D,expiration:L,credentialScope:M,accountId:b}={}}=v;if(!P||!F||!D||!L)throw new w.CredentialsProviderError("SSO returns an invalid temporary credential.",{tryNextLink:C,logger:a});let E={accessKeyId:P,secretAccessKey:F,sessionToken:D,expiration:new Date(L),...M&&{credentialScope:M},...b&&{accountId:b}};if(o)N.setCredentialFeature(E,"CREDENTIALS_SSO","s");else N.setCredentialFeature(E,"CREDENTIALS_SSO_LEGACY","u");return E};var V=z(Ge()),Y=(e,o)=>{let{sso_start_url:r,sso_account_id:t,sso_region:n,sso_role_name:i}=e;if(!r||!t||!n||!i)throw new V.CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", "sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(e).join(", ")}
3
3
  Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`,{tryNextLink:!1,logger:o});return e};var ee=(e={})=>async({callerClientConfig:o}={})=>{e.logger?.debug("@aws-sdk/credential-provider-sso - fromSSO");let{ssoStartUrl:r,ssoAccountId:t,ssoRegion:n,ssoRoleName:i,ssoSession:f}=e,{ssoClient:g}=e,S=p.getProfileName({profile:e.profile??o?.profile});if(!r&&!t&&!n&&!i&&!f){let s=(await p.parseKnownFiles(e))[S];if(!s)throw new p.CredentialsProviderError(`Profile ${S} was not found.`,{logger:e.logger});if(!G(s))throw new p.CredentialsProviderError(`Profile ${S} is not configured with SSO credentials.`,{logger:e.logger});if(s?.sso_session){let h=(await p.loadSsoSessionData(e))[s.sso_session],y=` configurations in profile ${S} and sso-session ${s.sso_session}`;if(n&&n!==h.sso_region)throw new p.CredentialsProviderError("Conflicting SSO region"+y,{tryNextLink:!1,logger:e.logger});if(r&&r!==h.sso_start_url)throw new p.CredentialsProviderError("Conflicting SSO start_url"+y,{tryNextLink:!1,logger:e.logger});s.sso_region=h.sso_region,s.sso_start_url=h.sso_start_url}let{sso_start_url:k,sso_account_id:T,sso_region:a,sso_role_name:d,sso_session:l}=Y(s,e.logger);return R({ssoStartUrl:k,ssoSession:l,ssoAccountId:T,ssoRegion:a,ssoRoleName:d,ssoClient:g,clientConfig:e.clientConfig,parentClientConfig:e.parentClientConfig,callerClientConfig:e.callerClientConfig,profile:S,filepath:e.filepath,configFilepath:e.configFilepath,ignoreCache:e.ignoreCache,logger:e.logger})}else if(!r||!t||!n||!i)throw new p.CredentialsProviderError('Incomplete configuration. The fromSSO() argument hash must include "ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"',{tryNextLink:!1,logger:e.logger});else return R({ssoStartUrl:r,ssoSession:f,ssoAccountId:t,ssoRegion:n,ssoRoleName:i,ssoClient:g,clientConfig:e.clientConfig,parentClientConfig:e.parentClientConfig,callerClientConfig:e.callerClientConfig,profile:S,filepath:e.filepath,configFilepath:e.configFilepath,ignoreCache:e.ignoreCache,logger:e.logger})};export{ee as fromSSO};
@@ -1,2 +1,2 @@
1
- import{I}from"./chunk-q6jsw0rr.js";var a=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Pl=I("external-link",a);
2
- export{Pl};
1
+ import{I}from"./chunk-17k9a427.js";var a=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Ol=I("external-link",a);
2
+ export{Ol};
@@ -1 +1 @@
1
- import{h,D,u,S,L,t,o,K,Z,B,ft,Ue,A,I,nr,F,Gr,St,jn,rn,bt,Ci,tr,Ls,vo,fe,wo,we,Re,C,E,Ce,Ie,Te,he,ge,Ae,W,zm,Vm,Ne,y_,E_,Pc,ey,ty,If,it,Ty,My,By,Uy,ud,Wy,uh,Tn,bv,vv,wv,xv,Sv,Ev,Cv,gd,ew,ox,Qh,Ix,Bx,ig,Tg,zs,Dd,Ep,Pd,Kg,Dp,v1,w1,Wg,Yg,Jg,Xg,eA,Fd,tA,I1,gs,Je,Xe,et,tt,rt,nt,ot,st,ue,ie,me,Ge,le,Tt,H,ce,Jo,Nr,An,$n,_s,Dr,Bd,Nt,k,xe,hr,Qe,Br,Aa,mA,oo,$p,ni,oi,ya,Q,je,Fe,Le,Ze,Be,ne,ba,Hd,$d,Gd,Qd}from"./chunk-q6jsw0rr.js";import{Bi}from"./chunk-b0rjvx5g.js";import{Vn,io}from"./chunk-8ystwvdt.js";import{sn}from"./chunk-fhazy8f9.js";S();var at=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],De=I("pen",at);function Se({scope:e,onScopeChange:r,selectedGoal:x,onClearGoal:p,onCreateTask:N,canCreateTask:v=!0}){return o("header",{className:"h-14 border-b border-border bg-card/60 backdrop-blur-sm px-4 flex items-center justify-between gap-3 shrink-0 select-none",children:[o("div",{className:"flex items-center gap-3 min-w-0",children:[o("div",{className:"flex items-center bg-muted/60 p-0.5 rounded-lg border border-border/50",children:[o(E,{variant:e==="team"?"secondary":"ghost",size:"sm",onClick:()=>r("team"),className:`h-7 px-2.5 text-xs font-medium gap-1.5 transition-all ${e==="team"?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"}`,children:[t(io,{className:"w-3.5 h-3.5"}),t("span",{children:I1()})]}),o(E,{variant:e==="my"?"secondary":"ghost",size:"sm",onClick:()=>r("my"),className:`h-7 px-2.5 text-xs font-medium gap-1.5 transition-all ${e==="my"?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"}`,children:[t(Vn,{className:"w-3.5 h-3.5"}),t("span",{children:ox()})]})]}),x&&o("div",{className:"hidden sm:flex items-center gap-1.5 px-2 py-1 rounded-md bg-sidebar-accent border border-sidebar-border text-xs text-sidebar-accent-foreground min-w-0 max-w-[200px] md:max-w-[280px]",children:[t(wo,{className:"w-3.5 h-3.5 text-sidebar-primary shrink-0"}),t("span",{className:"truncate font-medium",children:x.id===Aa?gs():x.title}),t(E,{variant:"ghost",size:"icon-xs",onClick:p,className:"h-4 w-4 p-0 ml-0.5 text-muted-foreground hover:text-foreground",title:E_(),children:t(Re,{className:"w-3 h-3"})})]})]}),v&&t("div",{className:"flex items-center gap-2 shrink-0",children:o(E,{size:"sm",onClick:N,className:"h-8 px-3 text-xs gap-1.5 shadow-xs",children:[t(fe,{className:"w-3.5 h-3.5"}),t("span",{children:If()})]})})]})}S();S();function pe({teamId:e,isOpen:r,onClose:x,goalToEdit:p}){let N=K(),[v,P]=u(""),[g,M]=u("");h(()=>{if(p)P(p.title),M(p.description||"");else P(""),M("")},[p,r]);let{mutate:G,isPending:q}=B({mutationFn:async()=>{let n=await A.api.teams[":teamId"].kanban.goals.$post({param:{teamId:e},json:{title:v.trim(),description:g.trim()||void 0}});if(!n.ok){let b=await n.json().catch(()=>({message:Tn()}));throw Error(b.message||Tn())}return await n.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),k.success(bv()),x()},onError:(n)=>{k.error(n.message)}}),{mutate:z,isPending:O}=B({mutationFn:async()=>{if(!p)return;let n=await A.api.teams[":teamId"].kanban.goals[":goalId"].$patch({param:{teamId:e,goalId:p.id},json:{title:v.trim(),description:g.trim()||null}});if(!n.ok){let b=await n.json().catch(()=>({message:Tn()}));throw Error(b.message||Tn())}return await n.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),k.success(Cv()),x()},onError:(n)=>{k.error(n.message)}}),U=(n)=>{if(n.preventDefault(),!v.trim())return;if(p)z();else G()},d=q||O;return t(ue,{open:r,onOpenChange:(n)=>!n&&x(),children:t(ie,{className:"sm:max-w-xl",children:o("form",{onSubmit:U,className:"space-y-4",children:[o(me,{children:[t(le,{children:p?uh():ty()}),t(Tt,{children:p?uh():ey()})]}),o("div",{className:"space-y-3 py-2",children:[o("div",{className:"space-y-1.5",children:[t(Q,{htmlFor:"goal-title",children:Sv()}),t(H,{id:"goal-title",value:v,onChange:(n)=>P(n.target.value),placeholder:Ev(),required:!0,autoFocus:!0})]}),o("div",{className:"space-y-1.5",children:[t(Q,{htmlFor:"goal-description",children:wv()}),t(ya,{id:"goal-description",value:g,onChange:(n)=>M(n.target.value),placeholder:xv(),rows:3})]})]}),o(Ge,{children:[t(E,{type:"button",variant:"outline",onClick:x,disabled:d,children:Ne()}),o(E,{type:"submit",disabled:!v.trim()||d,children:[d&&t(F,{className:"w-4 h-4 mr-1.5 animate-spin"}),p?zs():Pc()]})]})]})})})}function Ke({teamId:e,selectedGoalId:r,onSelectGoal:x,isOwnerOrEditor:p=!0}){let N=K(),[v,P]=u(!1),[g,M]=u(null),[G,q]=u(null),[z,O]=u(!1),{data:U,isLoading:d}=Z({queryKey:["teams",e,"kanban","goals"],queryFn:async()=>{let i=await A.api.teams[":teamId"].kanban.goals.$get({param:{teamId:e},query:{}});if(!i.ok)throw Error("Failed to fetch goals");return await i.json()},enabled:!!e}),n=U?.data||[],b=n.reduce((i,s)=>i+(s.taskCount||0),0),{mutate:T,isPending:l}=B({mutationFn:async(i)=>{let s=await A.api.teams[":teamId"].kanban.goals[":goalId"].$delete({param:{teamId:e,goalId:i}});if(!s.ok){let m=await s.json().catch(()=>({message:Tn()}));throw Error(m.message||Tn())}return await s.json()},onSuccess:(i,s)=>{if(N.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),N.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]}),k.success(vv()),r===s)x(null);q(null)},onError:(i)=>{k.error(i.message)}});if(z)return o("div",{className:"border-r border-sidebar-border bg-sidebar flex flex-col items-center w-12 shrink-0 transition-all duration-300",children:[t("div",{className:"h-14 flex items-center justify-center border-b border-sidebar-border w-full shrink-0",children:t(E,{variant:"ghost",size:"icon-sm",onClick:()=>O(!1),title:gd(),className:"text-sidebar-foreground/70 hover:text-sidebar-foreground",children:t(bt,{className:"w-4 h-4"})})}),o("div",{className:"mt-3 flex flex-col items-center gap-2",children:[t(E,{variant:r===null?"secondary":"ghost",size:"icon-sm",onClick:()=>x(null),title:zm(),className:C("w-8 h-8 rounded-md",r===null&&"bg-sidebar-accent text-sidebar-accent-foreground"),children:t(Bi,{className:"w-4 h-4"})}),t(E,{variant:"ghost",size:"icon-sm",onClick:()=>P(!0),title:Qh(),className:"w-8 h-8 rounded-md text-sidebar-foreground/70 hover:text-sidebar-foreground",children:t(fe,{className:"w-4 h-4"})})]}),v&&t(pe,{teamId:e,isOpen:v,onClose:()=>P(!1)})]});return o("aside",{className:"w-64 border-r border-sidebar-border bg-sidebar flex flex-col shrink-0 transition-all duration-300 select-none",children:[o("div",{className:"h-14 px-3 flex items-center justify-between border-b border-sidebar-border shrink-0",children:[o("div",{className:"flex items-center gap-2 font-semibold text-xs tracking-wider uppercase text-sidebar-foreground/70",children:[t(wo,{className:"w-4 h-4 text-sidebar-primary"}),t("span",{children:gd()})]}),o("div",{className:"flex items-center gap-1",children:[p&&t(E,{variant:"ghost",size:"icon-sm",onClick:()=>P(!0),className:"h-7 w-7 text-sidebar-foreground/70 hover:text-sidebar-foreground",title:Qh(),children:t(fe,{className:"w-4 h-4"})}),t(E,{variant:"ghost",size:"icon-sm",onClick:()=>O(!0),className:"h-7 w-7 text-sidebar-foreground/70 hover:text-sidebar-foreground",title:"Collapse",children:t(rn,{className:"w-4 h-4"})})]})]}),t(ce,{className:"flex-1 p-2",children:o("div",{className:"space-y-1",children:[o("div",{onClick:()=>x(null),className:C("flex items-center justify-between px-2.5 py-1 rounded-md text-xs font-medium cursor-pointer transition-colors group h-8 min-h-[32px]",r===null?"bg-sidebar-accent text-sidebar-accent-foreground font-semibold shadow-xs":"text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"),children:[o("div",{className:"flex items-center gap-2 truncate min-w-0",children:[t(Bi,{className:"w-3.5 h-3.5 shrink-0 text-sidebar-primary"}),t("span",{className:"truncate",children:zm()})]}),b>0&&t("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-sidebar-border text-sidebar-foreground/60 shrink-0",children:b})]}),d?t("div",{className:"flex items-center justify-center p-4",children:t(F,{className:"w-4 h-4 animate-spin text-muted-foreground"})}):n.length===0?t("div",{className:"px-2.5 py-4 text-center text-xs text-muted-foreground",children:Ix()}):n.map((i)=>{let s=r===i.id,m=i.id===Aa,y=m?gs():i.title,f=p&&!m;return o("div",{onClick:()=>x(i.id),className:C("flex items-center justify-between px-2.5 py-1 rounded-md text-xs font-medium cursor-pointer transition-colors group relative min-h-[32px]",s?"bg-sidebar-accent text-sidebar-accent-foreground font-semibold shadow-xs":"text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"),children:[o("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[t(wo,{className:C("w-3.5 h-3.5 shrink-0",s?"text-sidebar-primary":"text-muted-foreground")}),t("span",{className:"line-clamp-2 break-words leading-tight",title:y,children:y})]}),t("div",{className:"flex items-center shrink-0 ml-1",children:f?o(L,{children:[(i.taskCount??0)>0&&t("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-sidebar-border text-sidebar-foreground/60 group-hover:hidden group-focus-within:hidden [&:has(~_div_[data-state=open])]:hidden",children:i.taskCount}),t("div",{className:"hidden group-hover:flex group-focus-within:flex [&:has([data-state=open])]:flex items-center",onClick:(c)=>c.stopPropagation(),children:o(he,{modal:!1,children:[t(ge,{asChild:!0,children:t(E,{variant:"ghost",size:"icon-xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",children:t(nr,{className:"w-3.5 h-3.5"})})}),o(Ae,{align:"end",className:"w-36",children:[o(W,{onClick:()=>{M(i)},children:[t(De,{className:"w-3.5 h-3.5 mr-2"}),Wy()]}),o(W,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{q(i)},children:[t(we,{className:"w-3.5 h-3.5 mr-2"}),it()]})]})]})})]}):(i.taskCount??0)>0&&t("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-sidebar-border text-sidebar-foreground/60",children:i.taskCount})})]},i.id)})]})}),(v||g)&&t(pe,{teamId:e,isOpen:v||!!g,goalToEdit:g,onClose:()=>{P(!1),M(null)}}),G&&t(Je,{open:!!G,onOpenChange:(i)=>!i&&q(null),children:o(Xe,{children:[o(et,{children:[t(rt,{children:Ty()}),t(nt,{children:My({title:G.title})})]}),o(tt,{children:[t(st,{disabled:l,children:Ne()}),o(ot,{onClick:()=>T(G.id),disabled:l,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[l&&t(F,{className:"w-4 h-4 mr-1.5 animate-spin"}),it()]})]})]})})]})}S();S();function _e(e){return+xe(e)<Date.now()}function Pe({task:e,onClick:r,onDelete:x,disabled:p,isFirst:N,isLast:v,showBottomIndicator:P,currentUserId:g,currentUserRole:M}){let{source:G}=Bd(),q=!!G,z=M?.toLowerCase()==="owner",O=M?.toLowerCase()==="editor",U=!!g&&e.creator?.id===g,d=e.reporter?.id===g||U,n=e.assignee?.id===g,b=z||O||d||n,T=U||z||d,l=p||!b,{ref:i,isDragging:s}=_s({id:e.id,data:{type:"kanban_task",task:e},disabled:l}),{ref:m,isDropTarget:y}=Dr({id:`reorder-before-${e.id}`,data:{type:"reorder",task:e,position:"before"},disabled:s||p}),{ref:f,isDropTarget:c}=Dr({id:`reorder-after-${e.id}`,data:{type:"reorder",task:e,position:"after"},disabled:s||p}),_=e.isAgentTask,j=e.status===Qe.BLOCKED,w=e.dueDate?_e(new Date(e.dueDate))&&e.status!==Qe.DONE:!1;return o("div",{className:"relative",children:[t("div",{ref:m,className:C("absolute left-0 right-0 z-20",N?"-top-6 h-[calc(50%+24px)]":"-top-1 h-[calc(50%+4px)]",q&&!s?"pointer-events-auto":"pointer-events-none")}),t("div",{ref:f,className:C("absolute bottom-0 left-0 right-0 z-20",v?"-bottom-6 h-[calc(50%+24px)]":"h-1/2",q&&!s?"pointer-events-auto":"pointer-events-none")}),y&&!s&&t("div",{className:"absolute -top-1.5 left-0 right-0 h-[3px] rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.6)] z-30 pointer-events-none"}),(c||P)&&!s&&t("div",{className:"absolute -bottom-1.5 left-0 right-0 h-[3px] rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.6)] z-30 pointer-events-none"}),o("div",{ref:i,onClick:()=>r(e),className:C("group relative flex flex-col gap-2 p-3 rounded-lg border text-card-foreground transition-all duration-200 cursor-pointer select-none",s&&"opacity-40 scale-95 shadow-lg ring-2 ring-primary",!s&&"hover:shadow-md","border-border/80 bg-card hover:border-primary/50 shadow-2xs",j&&"border-red-500/60 bg-red-500/[0.03] ring-1 ring-red-500/20"),children:[o("div",{className:"flex items-center justify-between gap-1.5 min-w-0",children:[o("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[t("span",{className:C("px-1.5 py-0.5 rounded text-[10px] font-medium border uppercase tracking-wider shrink-0",oi(e.priority)),children:ni(e.priority)}),_&&o("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-orange-500/15 text-orange-600 dark:text-orange-400 border border-orange-500/30 shrink-0",children:[t(St,{className:"w-3 h-3"}),t("span",{children:Fd()})]}),e.goal&&o("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-muted text-muted-foreground border border-border/70 truncate max-w-[130px]",children:[t(wo,{className:"w-2.5 h-2.5 shrink-0"}),t("span",{className:"truncate",children:e.goal.title})]})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:T&&t("div",{className:"opacity-0 group-hover:opacity-100 [&:has([data-state=open])]:opacity-100 focus-within:opacity-100 transition-opacity flex items-center",onClick:(X)=>X.stopPropagation(),children:o(he,{modal:!1,children:[t(ge,{asChild:!0,children:t(E,{variant:"ghost",size:"icon-xs",className:"h-5 w-5 p-0 text-muted-foreground hover:text-foreground",children:t(nr,{className:"w-3.5 h-3.5"})})}),t(Ae,{align:"end",className:"w-32",children:o(W,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>x?.(e),children:[t(we,{className:"w-3.5 h-3.5 mr-2"}),it()]})})]})})})]}),t("h4",{className:"text-xs font-semibold leading-snug line-clamp-2 text-foreground break-words",children:e.title}),j&&o("div",{className:"flex items-start gap-1.5 p-1.5 rounded bg-red-500/10 border border-red-500/20 text-[11px] text-red-600 dark:text-red-400",children:[t(Gr,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),t("span",{className:"line-clamp-2 break-words",children:e.latestStatusEvent?.blockReason||e.latestStatusEvent?.reason||e.latestStatusEvent?.summary||Kg()})]}),e.status===Qe.IN_REVIEW&&e.latestStatusEvent?.summary&&o("div",{className:"flex items-start gap-1.5 p-1.5 rounded bg-purple-500/10 border border-purple-500/20 text-[11px] text-purple-600 dark:text-purple-400",children:[t(sn,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),t("span",{className:"line-clamp-2 break-words",children:e.latestStatusEvent.summary})]}),o("div",{className:"flex items-center justify-between gap-2 pt-1 mt-auto border-t border-border/40 text-[11px] text-muted-foreground",children:[t("div",{className:"flex items-center gap-1.5 min-w-0",children:e.assignee?o(L,{children:[_?t("div",{className:"w-5 h-5 rounded-full bg-orange-500/15 border border-orange-500/30 flex items-center justify-center shrink-0",children:t(St,{className:"w-3 h-3 text-orange-600 dark:text-orange-400"})}):o(Ce,{size:"sm",className:"w-5 h-5 border border-border",children:[t(Ie,{src:e.assignee.image}),t(Te,{className:"text-[9px]",children:e.assignee.name.slice(0,2).toUpperCase()})]}),t("span",{className:"truncate text-xs font-medium text-foreground/80 max-w-[90px]",children:e.assignee.name})]}):t("span",{className:"text-[11px] italic text-muted-foreground/60",children:gs()})}),o("div",{className:"flex items-center gap-2 shrink-0",children:[e.dueDate&&o("div",{className:C("flex items-center gap-1 text-[10px] font-mono",w?"text-red-500 font-semibold":"text-muted-foreground"),title:hr(new Date(e.dueDate),"yyyy/MM/dd HH:mm"),children:[t(jn,{className:"w-3 h-3"}),t("span",{children:hr(new Date(e.dueDate),"MM/dd")})]}),e.assetCount>0&&o("div",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",title:ew({count:e.assetCount}),children:[t(Ci,{className:"w-3 h-3"}),t("span",{children:e.assetCount})]}),e.dependencyCount>0&&o("div",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",title:`${e.dependencyCount} dependencies`,children:[t(Ls,{className:"w-3 h-3"}),t("span",{children:e.dependencyCount})]}),e.commentCount>0&&o("div",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",title:`${e.commentCount} comments`,children:[t(vo,{className:"w-3 h-3"}),t("span",{children:e.commentCount})]})]})]})]})]})}function Ee({teamId:e,status:r,selectedGoalId:x,scope:p,currentUserId:N,currentUserRole:v,onTaskClick:P,onDeleteTask:g,onCreateTaskInColumn:M}){let G=v?.toLowerCase()==="owner"||v?.toLowerCase()==="editor",q=p==="my"?N:void 0,{data:z,fetchNextPage:O,hasNextPage:U,isFetchingNextPage:d,isLoading:n}=ft({queryKey:["teams",e,"kanban","tasks",{status:r,goalId:x,assigneeId:q}],queryFn:async({pageParam:R=""})=>{let J=await A.api.teams[":teamId"].kanban.tasks.$get({param:{teamId:e},query:{status:r,goalId:x||void 0,assigneeId:q||void 0,first:"20",after:R||void 0}});if(!J.ok)throw Error("Failed to fetch column tasks");return await J.json()},initialPageParam:"",getNextPageParam:(R)=>R.pageInfo?.cursor||void 0,refetchInterval:5000,enabled:!!e}),{ref:b,inView:T}=Nt({threshold:0.1});h(()=>{if(T&&U&&!d)O()},[T,U,d,O]);let l=D(()=>z?.pages?.flatMap((R)=>Array.isArray(R?.data)?R.data:[])||[],[z]),{source:i,target:s}=Bd(),m=l.filter((R)=>R.id!==i?.id).at(-1),{ref:y,isDropTarget:f}=Dr({id:r,data:{type:"kanban_column",status:r,lastTask:m}}),c=i?.data?.type==="kanban_task",_=c&&(f||s?.data?.type==="kanban_column"&&s.data.status===r||s?.data?.type==="reorder"&&s.data.task?.status===r),j=c&&s?.data?.type==="kanban_column"&&s.data.status===r,w=z?.pages?.[0]?.pageInfo?.total??l.length,X=$p(r);return o("div",{ref:y,className:C("flex flex-col h-full max-h-full w-80 md:w-84 shrink-0 rounded-xl bg-card/60 border border-border/70 shadow-xs transition-colors duration-200 overflow-hidden select-none",_&&"ring-2 ring-primary/60 bg-primary/[0.03] border-primary/40"),children:[o("div",{className:"h-11 px-3.5 flex items-center justify-between border-b border-border/60 bg-card/80 shrink-0",children:[o("div",{className:"flex items-center gap-2 min-w-0",children:[t("div",{className:C("w-2.5 h-2.5 rounded-full shrink-0",X.dot)}),t("h3",{className:"text-xs font-bold tracking-wide uppercase text-foreground/90 truncate",children:oo(r)})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:t("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded-full bg-muted font-medium text-muted-foreground",children:w})})]}),t(ce,{className:"flex-1 min-h-0 [&>div>div]:block!",children:o("div",{className:"p-2.5 space-y-2.5 min-h-full flex flex-col",children:[n?t("div",{className:"flex items-center justify-center py-10",children:t(F,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):l.length===0?t("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:t("p",{className:"text-xs text-muted-foreground/70",children:Bx()})}):l.map((R,J)=>t(Pe,{task:R,onClick:P,onDelete:g,isFirst:J===0,isLast:J===l.length-1,showBottomIndicator:j&&R.id===m?.id,currentUserId:N,currentUserRole:v},R.id)),t("div",{ref:b,className:"h-2"}),d&&t("div",{className:"flex justify-center py-2",children:t(F,{className:"w-4 h-4 animate-spin text-muted-foreground"})})]})}),G&&t("div",{className:"p-2 border-t border-border/50 bg-card/90 shrink-0",children:o(E,{variant:"ghost",size:"sm",onClick:()=>M(r),className:"w-full justify-center h-8 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/80 border border-dashed border-border/80",children:[t(fe,{className:"w-3.5 h-3.5 mr-1.5"}),t("span",{children:If()})]})})]})}function Me({teamId:e,selectedGoalId:r,scope:x,currentUserId:p,currentUserRole:N,onTaskClick:v,onCreateTaskInColumn:P}){let g=K(),[M,G]=u(null),{mutate:q,isPending:z}=B({mutationFn:async(d)=>{let n=await A.api.teams[":teamId"].kanban.tasks[":taskId"].$delete({param:{teamId:e,taskId:d}});if(!n.ok){let b=await n.json().catch(()=>({message:Tn()}));throw Error(b.message||Tn())}return await n.json()},onSuccess:()=>{g.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]}),g.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),k.success(w1()),G(null)},onError:(d)=>{k.error(d.message)}}),{mutate:O}=B({mutationFn:async({taskId:d,fromStatus:n,status:b,reason:T,beforeIndex:l,afterIndex:i})=>{let s=await A.api.teams[":teamId"].kanban.tasks[":taskId"].$patch({param:{teamId:e,taskId:d},json:{fromStatus:n,status:b,reason:T,beforeIndex:l,afterIndex:i}});if(!s.ok){let m=await s.json().catch(()=>({message:Tn()}));throw Error(m.message||Tn())}return await s.json()},onMutate:async({taskId:d,status:n,targetTaskId:b,position:T})=>{await g.cancelQueries({queryKey:["teams",e,"kanban","tasks"]});let l=g.getQueriesData({queryKey:["teams",e,"kanban","tasks"]}),i=null,s=(m)=>m[0]==="teams"&&m[1]===e&&m[2]==="kanban"&&m[3]==="tasks"&&typeof m[4]==="object"&&m[4]!==null&&("status"in m[4]);if(g.setQueriesData({predicate:(m)=>s(m.queryKey)},(m)=>{if(!m||!Array.isArray(m.pages))return m;let y=!1,f=m.pages.map((c)=>{if(!c||!Array.isArray(c.data))return c;let _=c.data.find((j)=>j.id===d);if(_)return i={..._,status:n},y=!0,{...c,data:c.data.filter((j)=>j.id!==d),pageInfo:{...c.pageInfo,total:Math.max(0,(c.pageInfo?.total??c.data.length)-1)}};return c});return y?{...m,pages:f}:m}),i){let m=i;g.setQueriesData({predicate:(y)=>{if(!s(y.queryKey))return!1;return y.queryKey[4]?.status===n}},(y)=>{if(!y||!Array.isArray(y.pages))return y;let f=y.pages.flatMap((w)=>w?.data??[]).filter((w)=>w.id!==d),c=f.length;if(b){let w=f.findIndex((X)=>X.id===b);if(w!==-1)c=T==="before"?w:w+1}f.splice(c,0,m);let _=0,j=y.pages.map((w,X)=>{let R=w?.data?w.data.length:0,J=X===0&&R===0?1:X===y.pages.length-1?f.length-_:R,te=f.slice(_,_+J);return _+=J,{...w,data:te,pageInfo:{...w?.pageInfo,total:(w?.pageInfo?.total??0)+1}}});if(_<f.length&&j.length>0){let w=j.length-1;j[w]={...j[w],data:[...j[w]?.data??[],...f.slice(_)]}}return{...y,pages:j}})}return{previousQueries:l}},onError:(d,n,b)=>{if(b?.previousQueries)for(let[T,l]of b.previousQueries)g.setQueryData(T,l);k.error(d.message)},onSettled:()=>{g.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]})}}),U=(d)=>{if(d.canceled)return;let{source:n,target:b}=d.operation;if(!n||!b)return;let T=n.data;if(T?.type!=="kanban_task"||!T.task)return;let l=T.task,i=N?.toLowerCase()==="owner",s=N?.toLowerCase()==="editor",m=l.reporter?.id===p||l.creator?.id===p,y=l.assignee?.id===p;if(!i&&!s&&!m&&!y){k.error(y_());return}let f=b.data;if(!f)return;if(f.type==="reorder"&&f.task&&f.position){let c=f.task,_=c.status;if(l.id===c.id)return;let j=f.position==="before"?c.sortIndex??void 0:void 0,w=f.position==="after"?c.sortIndex??void 0:void 0;O({taskId:l.id,fromStatus:l.status,status:_,beforeIndex:j,afterIndex:w,targetTaskId:c.id,position:f.position});return}if(f.type==="kanban_column"&&f.status){let{status:c,lastTask:_}=f;if(_){if(l.id===_.id){if(l.status===c)return;O({taskId:l.id,fromStatus:l.status,status:c});return}O({taskId:l.id,fromStatus:l.status,status:c,afterIndex:_.sortIndex??void 0,targetTaskId:_.id,position:"after"});return}if(l.status===c)return;O({taskId:l.id,fromStatus:l.status,status:c})}};return o($n,{sensors:[An.configure({activationConstraints:[new Nr.Distance({value:8})]}),Jo],onDragEnd:U,children:[t("div",{className:"flex-1 min-h-0 overflow-x-auto overflow-y-hidden p-4 bg-background/50",children:t("div",{className:"flex gap-4 h-full min-w-max pb-2",children:mA.map((d)=>t(Ee,{teamId:e,status:d,selectedGoalId:r,scope:x,currentUserId:p,currentUserRole:N,onTaskClick:v,onDeleteTask:(n)=>G(n),onCreateTaskInColumn:P},d))})}),M&&t(Je,{open:!!M,onOpenChange:(d)=>!d&&G(null),children:o(Xe,{children:[o(et,{children:[t(rt,{children:By()}),t(nt,{children:Uy({title:M.title})})]}),o(tt,{children:[t(st,{disabled:z,children:Ne()}),o(ot,{onClick:()=>q(M.id),disabled:z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[z&&t(F,{className:"w-4 h-4 mr-1.5 animate-spin"}),it()]})]})]})})]})}S();function Oe({teamId:e,isOpen:r,onClose:x,initialGoalId:p}){let N=K(),v=p===Aa||!p?"none":p,[P,g]=u(""),[M,G]=u(""),[q,z]=u(!1),[O,U]=u(Br.MEDIUM),[d,n]=u(v),[b,T]=u("none"),[l,i]=u("none"),[s,m]=u(void 0),[y,f]=u(void 0),[c,_]=u(null),[j,w]=u(null),[X,R]=u(null),[J,te]=u([]),[se,re]=u([]),[be,ve]=u(!1),{data:ke}=Z({queryKey:["teams",e,"me"],queryFn:async()=>{let a=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!a.ok)return null;return await a.json()},enabled:!!e&&r});h(()=>{if(r)g(""),G(""),z(!1),U(Br.MEDIUM),n(v),T("none"),i(ke?.id||"none"),m(void 0),f(void 0),_(null),w(null),R(null),te([]),re([])},[r,v,ke?.id]);let{data:ye=[]}=Z({queryKey:["teams",e,"members","human"],queryFn:async()=>{let a=await A.api.teams[":teamId"].members.$get({param:{teamId:e},query:{includeAgents:"false"}});if(!a.ok)return[];let V=await a.json();return Array.isArray(V)?V:[]},enabled:!!e&&r}),{data:$e=[]}=Z({queryKey:["teams",e,"agents"],queryFn:async()=>{let a=await A.api.teams[":teamId"].agents.$get({param:{teamId:e}});if(!a.ok)return[];return await a.json()||[]},enabled:!!e&&r}),{data:He}=Z({queryKey:["teams",e,"kanban","goals"],queryFn:async()=>{let a=await A.api.teams[":teamId"].kanban.goals.$get({param:{teamId:e},query:{}});if(!a.ok)return{data:[]};return await a.json()},enabled:!!e&&r}),Ve=He?.data||[],{mutate:We,isPending:ae}=B({mutationFn:async()=>{let a=await A.api.teams[":teamId"].kanban.tasks.$post({param:{teamId:e},json:{title:P.trim(),description:M.trim()||void 0,isAgentTask:q,priority:O,goalId:d!=="none"?d:void 0,assigneeId:b!=="none"?b:void 0,reporterId:l!=="none"?l:void 0,startDate:s?s.toISOString():void 0,dueDate:y?y.toISOString():void 0,projectId:c||void 0,targetFolderId:j||void 0,parentIds:J.length>0?J:void 0,assetIds:se.length>0?se.map((V)=>V.id):void 0}});if(!a.ok){let V=await a.text().catch(()=>""),Y=Tn();if(V)try{let de=JSON.parse(V);if(de&&typeof de.message==="string")Y=de.message}catch{Y=V}throw Error(Y)}return await a.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]}),N.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),k.success(v1()),x()},onError:(a)=>{k.error(a.message)}}),Ye=(a)=>{if(a.preventDefault(),!P.trim()||ae)return;We()},oe=q;return t(ue,{open:r,onOpenChange:(a)=>!a&&x(),children:o(ie,{className:"sm:max-w-3xl max-h-[90vh] overflow-y-auto",children:[o("form",{onSubmit:Ye,className:"space-y-4",children:[t(me,{children:t(le,{children:If()})}),o("div",{className:"space-y-3.5 py-1",children:[o("div",{className:"space-y-1.5",children:[t(Q,{htmlFor:"create-task-title",children:Xg()}),t(H,{id:"create-task-title",value:P,onChange:(a)=>g(a.target.value),placeholder:eA(),required:!0,autoFocus:!0})]}),o("div",{className:"space-y-1.5",children:[t(Q,{htmlFor:"create-task-desc",children:Wg()}),t(ya,{id:"create-task-desc",value:M,onChange:(a)=>G(a.target.value),placeholder:Yg(),rows:3})]}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[o("div",{className:"sm:col-span-2 flex items-center justify-between space-x-2 rounded-lg border border-border/80 bg-muted/30 p-2.5 h-14",children:[o("div",{className:"space-y-0.5 min-w-0 pr-2",children:[o(Q,{htmlFor:"create-is-agent-task",className:"text-xs font-medium cursor-pointer flex items-center gap-1.5",children:[t(St,{className:"w-3.5 h-3.5 text-orange-500"}),t("span",{children:Fd()})]}),t("p",{className:"text-[11px] text-muted-foreground line-clamp-1",children:tA()})]}),t(je,{id:"create-is-agent-task",checked:q,onCheckedChange:(a)=>{z(a),T("none")}})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs font-medium text-muted-foreground",children:Jg()}),o(Fe,{value:O,onValueChange:(a)=>U(a),children:[t(Ze,{className:"w-full h-9 text-xs",children:t(Le,{})}),t(Be,{children:Object.values(Br).map((a)=>t(ne,{value:a,children:t("span",{className:C("px-1.5 py-0.5 rounded text-[10px] uppercase font-medium",oi(a)),children:ni(a)})},a))})]})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs font-medium text-muted-foreground",children:gd()}),o(Fe,{value:d,onValueChange:n,children:[t(Ze,{className:"w-full h-9 text-xs",children:t(Le,{placeholder:"None"})}),o(Be,{children:[t(ne,{value:"none",children:t("span",{className:"text-muted-foreground italic",children:"None"})}),Ve.filter((a)=>a.id!==Aa).map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[t(wo,{className:"w-3.5 h-3.5 text-primary"}),t("span",{children:a.title})]})},a.id))]})]})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs font-medium text-muted-foreground",children:oe?Dd():Vm()}),o(Fe,{value:b,onValueChange:T,children:[t(Ze,{className:"w-full h-9 text-xs",children:t(Le,{placeholder:gs()})}),o(Be,{children:[t(ne,{value:"none",children:t("span",{className:"text-muted-foreground italic",children:gs()})}),oe?$e.map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[t(St,{className:"w-3.5 h-3.5 text-purple-500"}),t("span",{children:a.name})]})},a.id)):ye.map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{size:"sm",className:"w-4 h-4",children:[t(Ie,{src:a.image}),t(Te,{className:"text-[8px]",children:a.name.slice(0,2).toUpperCase()})]}),t("span",{children:a.name})]})},a.id))]})]})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs font-medium text-muted-foreground",children:Tg()}),o(Fe,{value:l,onValueChange:i,children:[t(Ze,{className:"w-full h-9 text-xs",children:t(Le,{placeholder:gs()})}),o(Be,{children:[t(ne,{value:"none",children:t("span",{className:"text-muted-foreground italic",children:gs()})}),ye.map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{size:"sm",className:"w-4 h-4",children:[t(Ie,{src:a.image}),t(Te,{className:"text-[8px]",children:a.name.slice(0,2).toUpperCase()})]}),t("span",{children:a.name})]})},a.id))]})]})]}),oe&&o("div",{className:"sm:col-span-2 space-y-1.5",children:[t(Q,{className:"text-xs font-medium text-muted-foreground",children:Dp()}),o(E,{type:"button",variant:"outline",size:"sm",onClick:()=>ve(!0),className:"w-full justify-start h-9 text-xs truncate font-normal",children:[t(tr,{className:"w-3.5 h-3.5 mr-2 text-primary shrink-0"}),t("span",{className:"truncate",children:X||Ep()})]})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs font-medium text-muted-foreground",children:Pd()}),t(ba,{value:s,onChange:m,placeholder:Pd(),className:"h-9 text-xs"})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs font-medium text-muted-foreground",children:ud()}),t(ba,{value:y,onChange:f,placeholder:ud(),className:"h-9 text-xs"})]}),o("div",{className:"sm:col-span-2 space-y-1.5",children:[t(Q,{className:"text-xs font-medium text-muted-foreground",children:ig()}),t(Hd,{teamId:e,value:J,onChange:te})]}),t("div",{className:"sm:col-span-2 pt-1",children:t($d,{teamId:e,projectId:c,assets:se,onAddAssets:(a)=>re((V)=>[...V,...a]),onRemoveAsset:(a)=>re((V)=>V.filter((Y)=>Y.id!==a))})})]})]}),o(Ge,{children:[t(E,{type:"button",variant:"outline",onClick:x,disabled:ae,children:Ne()}),o(E,{type:"submit",disabled:!P.trim()||ae,children:[ae&&t(F,{className:"w-4 h-4 mr-1.5 animate-spin"}),Pc()]})]})]}),be&&t(Gd,{teamId:e,currentProjectId:c,currentTargetFolderId:j,isOpen:be,onClose:()=>ve(!1),onSelect:(a,V,Y)=>{_(a),w(V),R(Y||"Selected Folder")}})]})})}function qe({teamId:e,initialTaskId:r}){let[x,p]=u("team"),[N,v]=u(null),[P,g]=u(r??null),[M,G]=u(!1);h(()=>{if(r)g(r)},[r]);let[q,z]=u(Qe.TODO),{data:O,isLoading:U}=Z({queryKey:["teams",e,"me"],queryFn:async()=>{let s=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!s.ok)throw Error("Failed to fetch me");return await s.json()},enabled:!!e}),{data:d}=Z({queryKey:["teams",e,"kanban","goals"],queryFn:async()=>{let s=await A.api.teams[":teamId"].kanban.goals.$get({param:{teamId:e},query:{}});if(!s.ok)return{data:[]};return await s.json()},enabled:!!e}),n=d?.data||[],b=N?n.find((s)=>s.id===N)||null:null,T=O?.role?.toLowerCase()==="owner"||O?.role?.toLowerCase()==="editor",l=(s=Qe.TODO)=>{z(s),G(!0)},i=(s)=>{g(s.id)};if(U)return t("div",{className:"flex h-full items-center justify-center",children:t(F,{className:"w-8 h-8 animate-spin text-muted-foreground"})});return o("div",{className:"flex flex-row h-full bg-background overflow-hidden font-sans",children:[t(Ke,{teamId:e,selectedGoalId:N,onSelectGoal:v,isOwnerOrEditor:T}),o("div",{className:"flex-1 flex flex-col min-w-0 h-full overflow-hidden",children:[t(Se,{scope:x,onScopeChange:p,selectedGoal:b,onClearGoal:()=>v(null),onCreateTask:()=>l(Qe.TODO),canCreateTask:T}),t(Me,{teamId:e,selectedGoalId:N,scope:x,currentUserId:O?.id,currentUserRole:O?.role,onTaskClick:i,onCreateTaskInColumn:(s)=>l(s)})]}),P&&t(Qd,{teamId:e,taskId:P,isOpen:!!P,onClose:()=>g(null),canEdit:T}),M&&t(Oe,{teamId:e,isOpen:M,initialStatus:q,initialGoalId:N,onClose:()=>G(!1)})]})}function lt(){let{teamId:e}=ze.useParams(),{taskId:r}=ze.useSearch();return t(qe,{teamId:e,initialTaskId:r})}var ze=Ue("/teams/$teamId/kanban")({component:lt});export{ze as Route};
1
+ import{h,P,u,S,L,t,o,Q,Z,B,ft,ze,A,I,nr,F,Gr,Et,jn,rn,vt,Ia,tr,Ls,vo,pe,wo,we,Ne,C,E,Ce,Ie,Te,he,ge,Ae,W,$m,Ym,Pe,M0,O0,Oc,uy,dy,kf,at,Zy,By,Ky,Wy,fd,ib,mh,Tn,Dv,Ov,Fv,Lv,Zv,Bv,Uv,_d,mw,_x,rg,zx,Xx,hg,Fg,zs,Od,Mp,Fd,sA,Lp,tI,rI,iA,aA,lA,cA,uA,Zd,dA,aI,gs,Je,Xe,et,tt,rt,nt,ot,st,ue,ae,fe,qe,le,Ct,H,ce,Jo,Nr,An,$n,_s,Pr,zd,Nt,k,xe,hr,Qe,Br,_i,SA,oo,Kp,oa,sa,bi,K,De,Le,Ze,Be,Ue,ne,vi,Gd,Vd,Qd,Wd}from"./chunk-17k9a427.js";import{za}from"./chunk-ryvq9pbw.js";import{Vn,ao}from"./chunk-rv15x8aw.js";import{sn}from"./chunk-qa7pphr5.js";S();var it=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Se=I("pen",it);function Ke({scope:e,onScopeChange:r,selectedGoal:x,onClearGoal:p,onCreateTask:N,canCreateTask:v=!0}){return o("header",{className:"h-14 border-b border-border bg-card/60 backdrop-blur-sm px-4 flex items-center justify-between gap-3 shrink-0 select-none",children:[o("div",{className:"flex items-center gap-3 min-w-0",children:[o("div",{className:"flex items-center bg-muted/60 p-0.5 rounded-lg border border-border/50",children:[o(E,{variant:e==="team"?"secondary":"ghost",size:"sm",onClick:()=>r("team"),className:`h-7 px-2.5 text-xs font-medium gap-1.5 transition-all ${e==="team"?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"}`,children:[t(ao,{className:"w-3.5 h-3.5"}),t("span",{children:aI()})]}),o(E,{variant:e==="my"?"secondary":"ghost",size:"sm",onClick:()=>r("my"),className:`h-7 px-2.5 text-xs font-medium gap-1.5 transition-all ${e==="my"?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"}`,children:[t(Vn,{className:"w-3.5 h-3.5"}),t("span",{children:_x()})]})]}),x&&o("div",{className:"hidden sm:flex items-center gap-1.5 px-2 py-1 rounded-md bg-sidebar-accent border border-sidebar-border text-xs text-sidebar-accent-foreground min-w-0 max-w-[200px] md:max-w-[280px]",children:[t(wo,{className:"w-3.5 h-3.5 text-sidebar-primary shrink-0"}),t("span",{className:"truncate font-medium",children:x.id===_i?gs():x.title}),t(E,{variant:"ghost",size:"icon-xs",onClick:p,className:"h-4 w-4 p-0 ml-0.5 text-muted-foreground hover:text-foreground",title:O0(),children:t(Ne,{className:"w-3 h-3"})})]})]}),v&&t("div",{className:"flex items-center gap-2 shrink-0",children:o(E,{size:"sm",onClick:N,className:"h-8 px-3 text-xs gap-1.5 shadow-xs",children:[t(pe,{className:"w-3.5 h-3.5"}),t("span",{children:kf()})]})})]})}S();S();function me({teamId:e,isOpen:r,onClose:x,goalToEdit:p}){let N=Q(),[v,_]=u(""),[g,M]=u("");h(()=>{if(p)_(p.title),M(p.description||"");else _(""),M("")},[p,r]);let{mutate:G,isPending:q}=B({mutationFn:async()=>{let n=await A.api.teams[":teamId"].kanban.goals.$post({param:{teamId:e},json:{title:v.trim(),description:g.trim()||void 0}});if(!n.ok){let b=await n.json().catch(()=>({message:Tn()}));throw Error(b.message||Tn())}return await n.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),k.success(Dv()),x()},onError:(n)=>{k.error(n.message)}}),{mutate:z,isPending:O}=B({mutationFn:async()=>{if(!p)return;let n=await A.api.teams[":teamId"].kanban.goals[":goalId"].$patch({param:{teamId:e,goalId:p.id},json:{title:v.trim(),description:g.trim()||null}});if(!n.ok){let b=await n.json().catch(()=>({message:Tn()}));throw Error(b.message||Tn())}return await n.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),k.success(Uv()),x()},onError:(n)=>{k.error(n.message)}}),U=(n)=>{if(n.preventDefault(),!v.trim())return;if(p)z();else G()},d=q||O;return t(ue,{open:r,onOpenChange:(n)=>!n&&x(),children:t(ae,{className:"sm:max-w-xl",children:o("form",{onSubmit:U,className:"space-y-4",children:[o(fe,{children:[t(le,{children:p?mh():dy()}),t(Ct,{children:p?mh():uy()})]}),o("div",{className:"space-y-3 py-2",children:[o("div",{className:"space-y-1.5",children:[t(K,{htmlFor:"goal-title",children:Zv()}),t(H,{id:"goal-title",value:v,onChange:(n)=>_(n.target.value),placeholder:Bv(),required:!0,autoFocus:!0})]}),o("div",{className:"space-y-1.5",children:[t(K,{htmlFor:"goal-description",children:Fv()}),t(bi,{id:"goal-description",value:g,onChange:(n)=>M(n.target.value),placeholder:Lv(),rows:3})]})]}),o(qe,{children:[t(E,{type:"button",variant:"outline",onClick:x,disabled:d,children:Pe()}),o(E,{type:"submit",disabled:!v.trim()||d,children:[d&&t(F,{className:"w-4 h-4 mr-1.5 animate-spin"}),p?zs():Oc()]})]})]})})})}function _e({teamId:e,selectedGoalId:r,onSelectGoal:x,isOwnerOrEditor:p=!0}){let N=Q(),[v,_]=u(!1),[g,M]=u(null),[G,q]=u(null),[z,O]=u(!1),{data:U,isLoading:d}=Z({queryKey:["teams",e,"kanban","goals"],queryFn:async()=>{let i=await A.api.teams[":teamId"].kanban.goals.$get({param:{teamId:e},query:{}});if(!i.ok)throw Error("Failed to fetch goals");return await i.json()},enabled:!!e}),n=U?.data||[],b=n.reduce((i,s)=>i+(s.taskCount||0),0),{mutate:D,isPending:l}=B({mutationFn:async(i)=>{let s=await A.api.teams[":teamId"].kanban.goals[":goalId"].$delete({param:{teamId:e,goalId:i}});if(!s.ok){let m=await s.json().catch(()=>({message:Tn()}));throw Error(m.message||Tn())}return await s.json()},onSuccess:(i,s)=>{if(N.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),N.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]}),k.success(Ov()),r===s)x(null);q(null)},onError:(i)=>{k.error(i.message)}});if(z)return o("div",{className:"border-r border-sidebar-border bg-sidebar flex flex-col items-center w-12 shrink-0 transition-all duration-300",children:[t("div",{className:"h-14 flex items-center justify-center border-b border-sidebar-border w-full shrink-0",children:t(E,{variant:"ghost",size:"icon-sm",onClick:()=>O(!1),title:_d(),className:"text-sidebar-foreground/70 hover:text-sidebar-foreground",children:t(vt,{className:"w-4 h-4"})})}),o("div",{className:"mt-3 flex flex-col items-center gap-2",children:[t(E,{variant:r===null?"secondary":"ghost",size:"icon-sm",onClick:()=>x(null),title:$m(),className:C("w-8 h-8 rounded-md",r===null&&"bg-sidebar-accent text-sidebar-accent-foreground"),children:t(za,{className:"w-4 h-4"})}),t(E,{variant:"ghost",size:"icon-sm",onClick:()=>_(!0),title:rg(),className:"w-8 h-8 rounded-md text-sidebar-foreground/70 hover:text-sidebar-foreground",children:t(pe,{className:"w-4 h-4"})})]}),v&&t(me,{teamId:e,isOpen:v,onClose:()=>_(!1)})]});return o("aside",{className:"w-64 border-r border-sidebar-border bg-sidebar flex flex-col shrink-0 transition-all duration-300 select-none",children:[o("div",{className:"h-14 px-3 flex items-center justify-between border-b border-sidebar-border shrink-0",children:[o("div",{className:"flex items-center gap-2 font-semibold text-xs tracking-wider uppercase text-sidebar-foreground/70",children:[t(wo,{className:"w-4 h-4 text-sidebar-primary"}),t("span",{children:_d()})]}),o("div",{className:"flex items-center gap-1",children:[p&&t(E,{variant:"ghost",size:"icon-sm",onClick:()=>_(!0),className:"h-7 w-7 text-sidebar-foreground/70 hover:text-sidebar-foreground",title:rg(),children:t(pe,{className:"w-4 h-4"})}),t(E,{variant:"ghost",size:"icon-sm",onClick:()=>O(!0),className:"h-7 w-7 text-sidebar-foreground/70 hover:text-sidebar-foreground",title:"Collapse",children:t(rn,{className:"w-4 h-4"})})]})]}),t(ce,{className:"flex-1 p-2",children:o("div",{className:"space-y-1",children:[o("div",{onClick:()=>x(null),className:C("flex items-center justify-between px-2.5 py-1 rounded-md text-xs font-medium cursor-pointer transition-colors group h-8 min-h-[32px]",r===null?"bg-sidebar-accent text-sidebar-accent-foreground font-semibold shadow-xs":"text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"),children:[o("div",{className:"flex items-center gap-2 truncate min-w-0",children:[t(za,{className:"w-3.5 h-3.5 shrink-0 text-sidebar-primary"}),t("span",{className:"truncate",children:$m()})]}),b>0&&t("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-sidebar-border text-sidebar-foreground/60 shrink-0",children:b})]}),d?t("div",{className:"flex items-center justify-center p-4",children:t(F,{className:"w-4 h-4 animate-spin text-muted-foreground"})}):n.length===0?t("div",{className:"px-2.5 py-4 text-center text-xs text-muted-foreground",children:zx()}):n.map((i)=>{let s=r===i.id,m=i.id===_i,y=m?gs():i.title,f=p&&!m;return o("div",{onClick:()=>x(i.id),className:C("flex items-center justify-between px-2.5 py-1 rounded-md text-xs font-medium cursor-pointer transition-colors group relative min-h-[32px]",s?"bg-sidebar-accent text-sidebar-accent-foreground font-semibold shadow-xs":"text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"),children:[o("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[t(wo,{className:C("w-3.5 h-3.5 shrink-0",s?"text-sidebar-primary":"text-muted-foreground")}),t("span",{className:"line-clamp-2 break-words leading-tight",title:y,children:y})]}),t("div",{className:"flex items-center shrink-0 ml-1",children:f?o(L,{children:[(i.taskCount??0)>0&&t("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-sidebar-border text-sidebar-foreground/60 group-hover:hidden group-focus-within:hidden [&:has(~_div_[data-state=open])]:hidden",children:i.taskCount}),t("div",{className:"hidden group-hover:flex group-focus-within:flex [&:has([data-state=open])]:flex items-center",onClick:(c)=>c.stopPropagation(),children:o(he,{modal:!1,children:[t(ge,{asChild:!0,children:t(E,{variant:"ghost",size:"icon-xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",children:t(nr,{className:"w-3.5 h-3.5"})})}),o(Ae,{align:"end",className:"w-36",children:[o(W,{onClick:()=>{M(i)},children:[t(Se,{className:"w-3.5 h-3.5 mr-2"}),ib()]}),o(W,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{q(i)},children:[t(we,{className:"w-3.5 h-3.5 mr-2"}),at()]})]})]})})]}):(i.taskCount??0)>0&&t("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-sidebar-border text-sidebar-foreground/60",children:i.taskCount})})]},i.id)})]})}),(v||g)&&t(me,{teamId:e,isOpen:v||!!g,goalToEdit:g,onClose:()=>{_(!1),M(null)}}),G&&t(Je,{open:!!G,onOpenChange:(i)=>!i&&q(null),children:o(Xe,{children:[o(et,{children:[t(rt,{children:Zy()}),t(nt,{children:By({title:G.title})})]}),o(tt,{children:[t(st,{disabled:l,children:Pe()}),o(ot,{onClick:()=>D(G.id),disabled:l,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[l&&t(F,{className:"w-4 h-4 mr-1.5 animate-spin"}),at()]})]})]})})]})}S();S();function Fe(e){return+xe(e)<Date.now()}function Ee({task:e,onClick:r,onDelete:x,disabled:p,isFirst:N,isLast:v,showBottomIndicator:_,currentUserId:g,currentUserRole:M}){let{source:G}=zd(),q=!!G,z=M?.toLowerCase()==="owner",O=M?.toLowerCase()==="editor",U=!!g&&e.creator?.id===g,d=e.reporter?.id===g||U,n=e.assignee?.id===g,b=z||O||d||n,D=U||z||d,l=p||!b,{ref:i,isDragging:s}=_s({id:e.id,data:{type:"kanban_task",task:e},disabled:l}),{ref:m,isDropTarget:y}=Pr({id:`reorder-before-${e.id}`,data:{type:"reorder",task:e,position:"before"},disabled:s||p}),{ref:f,isDropTarget:c}=Pr({id:`reorder-after-${e.id}`,data:{type:"reorder",task:e,position:"after"},disabled:s||p}),T=e.isAgentTask,j=e.status===Qe.BLOCKED,w=e.dueDate?Fe(new Date(e.dueDate))&&e.status!==Qe.DONE:!1;return o("div",{className:"relative",children:[t("div",{ref:m,className:C("absolute left-0 right-0 z-20",N?"-top-6 h-[calc(50%+24px)]":"-top-1 h-[calc(50%+4px)]",q&&!s?"pointer-events-auto":"pointer-events-none")}),t("div",{ref:f,className:C("absolute bottom-0 left-0 right-0 z-20",v?"-bottom-6 h-[calc(50%+24px)]":"h-1/2",q&&!s?"pointer-events-auto":"pointer-events-none")}),y&&!s&&t("div",{className:"absolute -top-1.5 left-0 right-0 h-[3px] rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.6)] z-30 pointer-events-none"}),(c||_)&&!s&&t("div",{className:"absolute -bottom-1.5 left-0 right-0 h-[3px] rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.6)] z-30 pointer-events-none"}),o("div",{ref:i,onClick:()=>r(e),className:C("group relative flex flex-col gap-2 p-3 rounded-lg border text-card-foreground transition-all duration-200 cursor-pointer select-none",s&&"opacity-40 scale-95 shadow-lg ring-2 ring-primary",!s&&"hover:shadow-md","border-border/80 bg-card hover:border-primary/50 shadow-2xs",j&&"border-red-500/60 bg-red-500/[0.03] ring-1 ring-red-500/20"),children:[o("div",{className:"flex items-center justify-between gap-1.5 min-w-0",children:[o("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[t("span",{className:C("px-1.5 py-0.5 rounded text-[10px] font-medium border uppercase tracking-wider shrink-0",sa(e.priority)),children:oa(e.priority)}),T&&o("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-orange-500/15 text-orange-600 dark:text-orange-400 border border-orange-500/30 shrink-0",children:[t(Et,{className:"w-3 h-3"}),t("span",{children:Zd()})]}),e.goal&&o("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-muted text-muted-foreground border border-border/70 truncate max-w-[130px]",children:[t(wo,{className:"w-2.5 h-2.5 shrink-0"}),t("span",{className:"truncate",children:e.goal.title})]})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:D&&t("div",{className:"opacity-0 group-hover:opacity-100 [&:has([data-state=open])]:opacity-100 focus-within:opacity-100 transition-opacity flex items-center",onClick:(X)=>X.stopPropagation(),children:o(he,{modal:!1,children:[t(ge,{asChild:!0,children:t(E,{variant:"ghost",size:"icon-xs",className:"h-5 w-5 p-0 text-muted-foreground hover:text-foreground",children:t(nr,{className:"w-3.5 h-3.5"})})}),t(Ae,{align:"end",className:"w-32",children:o(W,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>x?.(e),children:[t(we,{className:"w-3.5 h-3.5 mr-2"}),at()]})})]})})})]}),t("h4",{className:"text-xs font-semibold leading-snug line-clamp-2 text-foreground break-words",children:e.title}),j&&o("div",{className:"flex items-start gap-1.5 p-1.5 rounded bg-red-500/10 border border-red-500/20 text-[11px] text-red-600 dark:text-red-400",children:[t(Gr,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),t("span",{className:"line-clamp-2 break-words",children:e.latestStatusEvent?.blockReason||e.latestStatusEvent?.reason||e.latestStatusEvent?.summary||sA()})]}),e.status===Qe.IN_REVIEW&&e.latestStatusEvent?.summary&&o("div",{className:"flex items-start gap-1.5 p-1.5 rounded bg-purple-500/10 border border-purple-500/20 text-[11px] text-purple-600 dark:text-purple-400",children:[t(sn,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),t("span",{className:"line-clamp-2 break-words",children:e.latestStatusEvent.summary})]}),o("div",{className:"flex items-center justify-between gap-2 pt-1 mt-auto border-t border-border/40 text-[11px] text-muted-foreground",children:[t("div",{className:"flex items-center gap-1.5 min-w-0",children:e.assignee?o(L,{children:[T?t("div",{className:"w-5 h-5 rounded-full bg-orange-500/15 border border-orange-500/30 flex items-center justify-center shrink-0",children:t(Et,{className:"w-3 h-3 text-orange-600 dark:text-orange-400"})}):o(Ce,{size:"sm",className:"w-5 h-5 border border-border",children:[t(Ie,{src:e.assignee.image}),t(Te,{className:"text-[9px]",children:e.assignee.name.slice(0,2).toUpperCase()})]}),t("span",{className:"truncate text-xs font-medium text-foreground/80 max-w-[90px]",children:e.assignee.name})]}):t("span",{className:"text-[11px] italic text-muted-foreground/60",children:gs()})}),o("div",{className:"flex items-center gap-2 shrink-0",children:[e.dueDate&&o("div",{className:C("flex items-center gap-1 text-[10px] font-mono",w?"text-red-500 font-semibold":"text-muted-foreground"),title:hr(new Date(e.dueDate),"yyyy/MM/dd HH:mm"),children:[t(jn,{className:"w-3 h-3"}),t("span",{children:hr(new Date(e.dueDate),"MM/dd")})]}),e.assetCount>0&&o("div",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",title:mw({count:e.assetCount}),children:[t(Ia,{className:"w-3 h-3"}),t("span",{children:e.assetCount})]}),e.dependencyCount>0&&o("div",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",title:`${e.dependencyCount} dependencies`,children:[t(Ls,{className:"w-3 h-3"}),t("span",{children:e.dependencyCount})]}),e.commentCount>0&&o("div",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",title:`${e.commentCount} comments`,children:[t(vo,{className:"w-3 h-3"}),t("span",{children:e.commentCount})]})]})]})]})]})}function Me({teamId:e,status:r,selectedGoalId:x,scope:p,currentUserId:N,currentUserRole:v,onTaskClick:_,onDeleteTask:g,onCreateTaskInColumn:M}){let G=v?.toLowerCase()==="owner"||v?.toLowerCase()==="editor",q=p==="my"?N:void 0,{data:z,fetchNextPage:O,hasNextPage:U,isFetchingNextPage:d,isLoading:n}=ft({queryKey:["teams",e,"kanban","tasks",{status:r,goalId:x,assigneeId:q}],queryFn:async({pageParam:R=""})=>{let J=await A.api.teams[":teamId"].kanban.tasks.$get({param:{teamId:e},query:{status:r,goalId:x||void 0,assigneeId:q||void 0,first:"20",after:R||void 0}});if(!J.ok)throw Error("Failed to fetch column tasks");return await J.json()},initialPageParam:"",getNextPageParam:(R)=>R.pageInfo?.cursor||void 0,refetchInterval:5000,enabled:!!e}),{ref:b,inView:D}=Nt({threshold:0.1});h(()=>{if(D&&U&&!d)O()},[D,U,d,O]);let l=P(()=>z?.pages?.flatMap((R)=>Array.isArray(R?.data)?R.data:[])||[],[z]),{source:i,target:s}=zd(),m=l.filter((R)=>R.id!==i?.id).at(-1),{ref:y,isDropTarget:f}=Pr({id:r,data:{type:"kanban_column",status:r,lastTask:m}}),c=i?.data?.type==="kanban_task",T=c&&(f||s?.data?.type==="kanban_column"&&s.data.status===r||s?.data?.type==="reorder"&&s.data.task?.status===r),j=c&&s?.data?.type==="kanban_column"&&s.data.status===r,w=z?.pages?.[0]?.pageInfo?.total??l.length,X=Kp(r);return o("div",{ref:y,className:C("flex flex-col h-full max-h-full w-80 md:w-84 shrink-0 rounded-xl bg-card/60 border border-border/70 shadow-xs transition-colors duration-200 overflow-hidden select-none",T&&"ring-2 ring-primary/60 bg-primary/[0.03] border-primary/40"),children:[o("div",{className:"h-11 px-3.5 flex items-center justify-between border-b border-border/60 bg-card/80 shrink-0",children:[o("div",{className:"flex items-center gap-2 min-w-0",children:[t("div",{className:C("w-2.5 h-2.5 rounded-full shrink-0",X.dot)}),t("h3",{className:"text-xs font-bold tracking-wide uppercase text-foreground/90 truncate",children:oo(r)})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:t("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded-full bg-muted font-medium text-muted-foreground",children:w})})]}),t(ce,{className:"flex-1 min-h-0 [&>div>div]:block!",children:o("div",{className:"p-2.5 space-y-2.5 min-h-full flex flex-col",children:[n?t("div",{className:"flex items-center justify-center py-10",children:t(F,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):l.length===0?t("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:t("p",{className:"text-xs text-muted-foreground/70",children:Xx()})}):l.map((R,J)=>t(Ee,{task:R,onClick:_,onDelete:g,isFirst:J===0,isLast:J===l.length-1,showBottomIndicator:j&&R.id===m?.id,currentUserId:N,currentUserRole:v},R.id)),t("div",{ref:b,className:"h-2"}),d&&t("div",{className:"flex justify-center py-2",children:t(F,{className:"w-4 h-4 animate-spin text-muted-foreground"})})]})}),G&&t("div",{className:"p-2 border-t border-border/50 bg-card/90 shrink-0",children:o(E,{variant:"ghost",size:"sm",onClick:()=>M(r),className:"w-full justify-center h-8 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/80 border border-dashed border-border/80",children:[t(pe,{className:"w-3.5 h-3.5 mr-1.5"}),t("span",{children:kf()})]})})]})}function Oe({teamId:e,selectedGoalId:r,scope:x,currentUserId:p,currentUserRole:N,onTaskClick:v,onCreateTaskInColumn:_}){let g=Q(),[M,G]=u(null),{mutate:q,isPending:z}=B({mutationFn:async(d)=>{let n=await A.api.teams[":teamId"].kanban.tasks[":taskId"].$delete({param:{teamId:e,taskId:d}});if(!n.ok){let b=await n.json().catch(()=>({message:Tn()}));throw Error(b.message||Tn())}return await n.json()},onSuccess:()=>{g.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]}),g.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),k.success(rI()),G(null)},onError:(d)=>{k.error(d.message)}}),{mutate:O}=B({mutationFn:async({taskId:d,fromStatus:n,status:b,reason:D,beforeIndex:l,afterIndex:i})=>{let s=await A.api.teams[":teamId"].kanban.tasks[":taskId"].$patch({param:{teamId:e,taskId:d},json:{fromStatus:n,status:b,reason:D,beforeIndex:l,afterIndex:i}});if(!s.ok){let m=await s.json().catch(()=>({message:Tn()}));throw Error(m.message||Tn())}return await s.json()},onMutate:async({taskId:d,status:n,targetTaskId:b,position:D})=>{await g.cancelQueries({queryKey:["teams",e,"kanban","tasks"]});let l=g.getQueriesData({queryKey:["teams",e,"kanban","tasks"]}),i=null,s=(m)=>m[0]==="teams"&&m[1]===e&&m[2]==="kanban"&&m[3]==="tasks"&&typeof m[4]==="object"&&m[4]!==null&&("status"in m[4]);if(g.setQueriesData({predicate:(m)=>s(m.queryKey)},(m)=>{if(!m||!Array.isArray(m.pages))return m;let y=!1,f=m.pages.map((c)=>{if(!c||!Array.isArray(c.data))return c;let T=c.data.find((j)=>j.id===d);if(T)return i={...T,status:n},y=!0,{...c,data:c.data.filter((j)=>j.id!==d),pageInfo:{...c.pageInfo,total:Math.max(0,(c.pageInfo?.total??c.data.length)-1)}};return c});return y?{...m,pages:f}:m}),i){let m=i;g.setQueriesData({predicate:(y)=>{if(!s(y.queryKey))return!1;return y.queryKey[4]?.status===n}},(y)=>{if(!y||!Array.isArray(y.pages))return y;let f=y.pages.flatMap((w)=>w?.data??[]).filter((w)=>w.id!==d),c=f.length;if(b){let w=f.findIndex((X)=>X.id===b);if(w!==-1)c=D==="before"?w:w+1}f.splice(c,0,m);let T=0,j=y.pages.map((w,X)=>{let R=w?.data?w.data.length:0,J=X===0&&R===0?1:X===y.pages.length-1?f.length-T:R,te=f.slice(T,T+J);return T+=J,{...w,data:te,pageInfo:{...w?.pageInfo,total:(w?.pageInfo?.total??0)+1}}});if(T<f.length&&j.length>0){let w=j.length-1;j[w]={...j[w],data:[...j[w]?.data??[],...f.slice(T)]}}return{...y,pages:j}})}return{previousQueries:l}},onError:(d,n,b)=>{if(b?.previousQueries)for(let[D,l]of b.previousQueries)g.setQueryData(D,l);k.error(d.message)},onSettled:()=>{g.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]})}}),U=(d)=>{if(d.canceled)return;let{source:n,target:b}=d.operation;if(!n||!b)return;let D=n.data;if(D?.type!=="kanban_task"||!D.task)return;let l=D.task,i=N?.toLowerCase()==="owner",s=N?.toLowerCase()==="editor",m=l.reporter?.id===p||l.creator?.id===p,y=l.assignee?.id===p;if(!i&&!s&&!m&&!y){k.error(M0());return}let f=b.data;if(!f)return;if(f.type==="reorder"&&f.task&&f.position){let c=f.task,T=c.status;if(l.id===c.id)return;let j=f.position==="before"?c.sortIndex??void 0:void 0,w=f.position==="after"?c.sortIndex??void 0:void 0;O({taskId:l.id,fromStatus:l.status,status:T,beforeIndex:j,afterIndex:w,targetTaskId:c.id,position:f.position});return}if(f.type==="kanban_column"&&f.status){let{status:c,lastTask:T}=f;if(T){if(l.id===T.id){if(l.status===c)return;O({taskId:l.id,fromStatus:l.status,status:c});return}O({taskId:l.id,fromStatus:l.status,status:c,afterIndex:T.sortIndex??void 0,targetTaskId:T.id,position:"after"});return}if(l.status===c)return;O({taskId:l.id,fromStatus:l.status,status:c})}};return o($n,{sensors:[An.configure({activationConstraints:[new Nr.Distance({value:8})]}),Jo],onDragEnd:U,children:[t("div",{className:"flex-1 min-h-0 overflow-x-auto overflow-y-hidden p-4 bg-background/50",children:t("div",{className:"flex gap-4 h-full min-w-max pb-2",children:SA.map((d)=>t(Me,{teamId:e,status:d,selectedGoalId:r,scope:x,currentUserId:p,currentUserRole:N,onTaskClick:v,onDeleteTask:(n)=>G(n),onCreateTaskInColumn:_},d))})}),M&&t(Je,{open:!!M,onOpenChange:(d)=>!d&&G(null),children:o(Xe,{children:[o(et,{children:[t(rt,{children:Ky()}),t(nt,{children:Wy({title:M.title})})]}),o(tt,{children:[t(st,{disabled:z,children:Pe()}),o(ot,{onClick:()=>q(M.id),disabled:z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[z&&t(F,{className:"w-4 h-4 mr-1.5 animate-spin"}),at()]})]})]})})]})}S();function Ge({teamId:e,isOpen:r,onClose:x,initialGoalId:p}){let N=Q(),v=p===_i||!p?"none":p,[_,g]=u(""),[M,G]=u(""),[q,z]=u(!1),[O,U]=u(Br.MEDIUM),[d,n]=u(v),[b,D]=u("none"),[l,i]=u("none"),[s,m]=u(void 0),[y,f]=u(void 0),[c,T]=u(null),[j,w]=u(null),[X,R]=u(null),[J,te]=u([]),[re,oe]=u([]),[be,ve]=u(!1),{data:ke}=Z({queryKey:["teams",e,"me"],queryFn:async()=>{let a=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!a.ok)return null;return await a.json()},enabled:!!e&&r});h(()=>{if(r)g(""),G(""),z(!1),U(Br.MEDIUM),n(v),D("none"),i(ke?.id||"none"),m(void 0),f(void 0),T(null),w(null),R(null),te([]),oe([])},[r,v,ke?.id]);let{data:ye=[]}=Z({queryKey:["teams",e,"members","human"],queryFn:async()=>{let a=await A.api.teams[":teamId"].members.$get({param:{teamId:e},query:{includeAgents:"false"}});if(!a.ok)return[];let V=await a.json();return Array.isArray(V)?V:[]},enabled:!!e&&r}),{data:$e=[]}=Z({queryKey:["teams",e,"agents"],queryFn:async()=>{let a=await A.api.teams[":teamId"].agents.$get({param:{teamId:e}});if(!a.ok)return[];return await a.json()||[]},enabled:!!e&&r}),{data:He}=Z({queryKey:["teams",e,"kanban","goals"],queryFn:async()=>{let a=await A.api.teams[":teamId"].kanban.goals.$get({param:{teamId:e},query:{}});if(!a.ok)return{data:[]};return await a.json()},enabled:!!e&&r}),Ve=He?.data||[],{mutate:We,isPending:se}=B({mutationFn:async()=>{let a=await A.api.teams[":teamId"].kanban.tasks.$post({param:{teamId:e},json:{title:_.trim(),description:M.trim()||void 0,isAgentTask:q,priority:O,goalId:d!=="none"?d:void 0,assigneeId:b!=="none"?b:void 0,reporterId:l!=="none"?l:void 0,startDate:s?s.toISOString():void 0,dueDate:y?y.toISOString():void 0,projectId:c||void 0,targetFolderId:j||void 0,parentIds:J.length>0?J:void 0,assetIds:re.length>0?re.map((V)=>V.id):void 0}});if(!a.ok){let V=await a.text().catch(()=>""),Y=Tn();if(V)try{let de=JSON.parse(V);if(de&&typeof de.message==="string")Y=de.message}catch{Y=V}throw Error(Y)}return await a.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]}),N.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),k.success(tI()),x()},onError:(a)=>{k.error(a.message)}}),Ye=(a)=>{if(a.preventDefault(),!_.trim()||se)return;We()},ie=q;return t(ue,{open:r,onOpenChange:(a)=>!a&&x(),children:o(ae,{className:"sm:max-w-3xl max-h-[90vh] overflow-y-auto",children:[o("form",{onSubmit:Ye,className:"space-y-4",children:[t(fe,{children:t(le,{children:kf()})}),o("div",{className:"space-y-3.5 py-1",children:[o("div",{className:"space-y-1.5",children:[t(K,{htmlFor:"create-task-title",children:cA()}),t(H,{id:"create-task-title",value:_,onChange:(a)=>g(a.target.value),placeholder:uA(),required:!0,autoFocus:!0})]}),o("div",{className:"space-y-1.5",children:[t(K,{htmlFor:"create-task-desc",children:iA()}),t(bi,{id:"create-task-desc",value:M,onChange:(a)=>G(a.target.value),placeholder:aA(),rows:3})]}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[o("div",{className:"sm:col-span-2 flex items-center justify-between space-x-2 rounded-lg border border-border/80 bg-muted/30 p-2.5 h-14",children:[o("div",{className:"space-y-0.5 min-w-0 pr-2",children:[o(K,{htmlFor:"create-is-agent-task",className:"text-xs font-medium cursor-pointer flex items-center gap-1.5",children:[t(Et,{className:"w-3.5 h-3.5 text-orange-500"}),t("span",{children:Zd()})]}),t("p",{className:"text-[11px] text-muted-foreground line-clamp-1",children:dA()})]}),t(De,{id:"create-is-agent-task",checked:q,onCheckedChange:(a)=>{z(a),D("none")}})]}),o("div",{className:"space-y-1.5",children:[t(K,{className:"text-xs font-medium text-muted-foreground",children:lA()}),o(Le,{value:O,onValueChange:(a)=>U(a),children:[t(Be,{className:"w-full h-9 text-xs",children:t(Ze,{})}),t(Ue,{children:Object.values(Br).map((a)=>t(ne,{value:a,children:t("span",{className:C("px-1.5 py-0.5 rounded text-[10px] uppercase font-medium",sa(a)),children:oa(a)})},a))})]})]}),o("div",{className:"space-y-1.5",children:[t(K,{className:"text-xs font-medium text-muted-foreground",children:_d()}),o(Le,{value:d,onValueChange:n,children:[t(Be,{className:"w-full h-9 text-xs",children:t(Ze,{placeholder:"None"})}),o(Ue,{children:[t(ne,{value:"none",children:t("span",{className:"text-muted-foreground italic",children:"None"})}),Ve.filter((a)=>a.id!==_i).map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[t(wo,{className:"w-3.5 h-3.5 text-primary"}),t("span",{children:a.title})]})},a.id))]})]})]}),o("div",{className:"space-y-1.5",children:[t(K,{className:"text-xs font-medium text-muted-foreground",children:ie?Od():Ym()}),o(Le,{value:b,onValueChange:D,children:[t(Be,{className:"w-full h-9 text-xs",children:t(Ze,{placeholder:gs()})}),o(Ue,{children:[t(ne,{value:"none",children:t("span",{className:"text-muted-foreground italic",children:gs()})}),ie?$e.map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[t(Et,{className:"w-3.5 h-3.5 text-purple-500"}),t("span",{children:a.name})]})},a.id)):ye.map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{size:"sm",className:"w-4 h-4",children:[t(Ie,{src:a.image}),t(Te,{className:"text-[8px]",children:a.name.slice(0,2).toUpperCase()})]}),t("span",{children:a.name})]})},a.id))]})]})]}),o("div",{className:"space-y-1.5",children:[t(K,{className:"text-xs font-medium text-muted-foreground",children:Fg()}),o(Le,{value:l,onValueChange:i,children:[t(Be,{className:"w-full h-9 text-xs",children:t(Ze,{placeholder:gs()})}),o(Ue,{children:[t(ne,{value:"none",children:t("span",{className:"text-muted-foreground italic",children:gs()})}),ye.map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{size:"sm",className:"w-4 h-4",children:[t(Ie,{src:a.image}),t(Te,{className:"text-[8px]",children:a.name.slice(0,2).toUpperCase()})]}),t("span",{children:a.name})]})},a.id))]})]})]}),ie&&o("div",{className:"sm:col-span-2 space-y-1.5",children:[t(K,{className:"text-xs font-medium text-muted-foreground",children:Lp()}),o(E,{type:"button",variant:"outline",size:"sm",onClick:()=>ve(!0),className:"w-full justify-start h-9 text-xs truncate font-normal",children:[t(tr,{className:"w-3.5 h-3.5 mr-2 text-primary shrink-0"}),t("span",{className:"truncate",children:X||Mp()})]})]}),o("div",{className:"space-y-1.5",children:[t(K,{className:"text-xs font-medium text-muted-foreground",children:Fd()}),t(vi,{value:s,onChange:m,placeholder:Fd(),className:"h-9 text-xs"})]}),o("div",{className:"space-y-1.5",children:[t(K,{className:"text-xs font-medium text-muted-foreground",children:fd()}),t(vi,{value:y,onChange:f,placeholder:fd(),className:"h-9 text-xs"})]}),o("div",{className:"sm:col-span-2 space-y-1.5",children:[t(K,{className:"text-xs font-medium text-muted-foreground",children:hg()}),t(Gd,{teamId:e,value:J,onChange:te})]}),t("div",{className:"sm:col-span-2 pt-1",children:t(Vd,{teamId:e,projectId:c,assets:re,onAddAssets:(a)=>oe((V)=>[...V,...a]),onRemoveAsset:(a)=>oe((V)=>V.filter((Y)=>Y.id!==a))})})]})]}),o(qe,{children:[t(E,{type:"button",variant:"outline",onClick:x,disabled:se,children:Pe()}),o(E,{type:"submit",disabled:!_.trim()||se,children:[se&&t(F,{className:"w-4 h-4 mr-1.5 animate-spin"}),Oc()]})]})]}),be&&t(Qd,{teamId:e,currentProjectId:c,currentTargetFolderId:j,isOpen:be,onClose:()=>ve(!1),onSelect:(a,V,Y)=>{T(a),w(V),R(Y||"Selected Folder")}})]})})}function je({teamId:e,initialTaskId:r}){let[x,p]=u("team"),[N,v]=u(null),[_,g]=u(r??null),[M,G]=u(!1);h(()=>{if(r)g(r)},[r]);let[q,z]=u(Qe.TODO),{data:O,isLoading:U}=Z({queryKey:["teams",e,"me"],queryFn:async()=>{let s=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!s.ok)throw Error("Failed to fetch me");return await s.json()},enabled:!!e}),{data:d}=Z({queryKey:["teams",e,"kanban","goals"],queryFn:async()=>{let s=await A.api.teams[":teamId"].kanban.goals.$get({param:{teamId:e},query:{}});if(!s.ok)return{data:[]};return await s.json()},enabled:!!e}),n=d?.data||[],b=N?n.find((s)=>s.id===N)||null:null,D=O?.role?.toLowerCase()==="owner"||O?.role?.toLowerCase()==="editor",l=(s=Qe.TODO)=>{z(s),G(!0)},i=(s)=>{g(s.id)};if(U)return t("div",{className:"flex h-full items-center justify-center",children:t(F,{className:"w-8 h-8 animate-spin text-muted-foreground"})});return o("div",{className:"flex flex-row h-full bg-background overflow-hidden font-sans",children:[t(_e,{teamId:e,selectedGoalId:N,onSelectGoal:v,isOwnerOrEditor:D}),o("div",{className:"flex-1 flex flex-col min-w-0 h-full overflow-hidden",children:[t(Ke,{scope:x,onScopeChange:p,selectedGoal:b,onClearGoal:()=>v(null),onCreateTask:()=>l(Qe.TODO),canCreateTask:D}),t(Oe,{teamId:e,selectedGoalId:N,scope:x,currentUserId:O?.id,currentUserRole:O?.role,onTaskClick:i,onCreateTaskInColumn:(s)=>l(s)})]}),_&&t(Wd,{teamId:e,taskId:_,isOpen:!!_,onClose:()=>g(null),canEdit:D}),M&&t(Ge,{teamId:e,isOpen:M,initialStatus:q,initialGoalId:N,onClose:()=>G(!1)})]})}function lt(){let{teamId:e}=Re.useParams(),{taskId:r}=Re.useSearch();return t(je,{teamId:e,initialTaskId:r})}var Re=ze("/teams/$teamId/kanban")({component:lt});export{Re as Route};
@@ -25,7 +25,7 @@
25
25
  <meta name="theme-color" content="#ffffff" />
26
26
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
27
27
  <title>Shumai</title>
28
- <link rel="stylesheet" crossorigin href="./chunk-6ksrrayx.css"><script type="module" crossorigin src="./chunk-q6jsw0rr.js"></script></head>
28
+ <link rel="stylesheet" crossorigin href="./chunk-fjvbgahx.css"><script type="module" crossorigin src="./chunk-17k9a427.js"></script></head>
29
29
  <body>
30
30
  <div id="root"></div>
31
31