@shumai-one/shumai 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/bin/{chunk-wbmqbpgm.js → chunk-01ym2agz.js} +1 -1
  2. package/bin/{chunk-ncv8v6mj.js → chunk-047n9gfs.js} +2 -2
  3. package/bin/chunk-0a4ahz7r.js +2 -0
  4. package/bin/{chunk-v5hz09a1.js → chunk-0awcpx0a.js} +2 -2
  5. package/bin/{chunk-bcyvxp1c.js → chunk-0fbgfgxv.js} +4 -4
  6. package/bin/{chunk-jt6v15wx.js → chunk-0nnqha4f.js} +1 -1
  7. package/bin/chunk-0tvggyy4.js +1 -0
  8. package/bin/{chunk-s9sf37dv.js → chunk-113baw0m.js} +1 -1
  9. package/bin/{chunk-axeq2pq5.js → chunk-1dbjyarc.js} +1 -1
  10. package/bin/{chunk-d1q1tn36.js → chunk-1qre79kf.js} +1 -1
  11. package/bin/chunk-27v3yepb.js +1 -0
  12. package/bin/{chunk-gvcjqcjf.js → chunk-2rq3w8sg.js} +1 -1
  13. package/bin/{chunk-wperd2h9.js → chunk-3020am4q.js} +1 -1
  14. package/bin/chunk-3pwwg1xm.js +1 -0
  15. package/bin/{chunk-scvepfv8.js → chunk-3sfb63fp.js} +1 -1
  16. package/bin/{chunk-y6xyc4wp.js → chunk-3tg10kwz.js} +1 -1
  17. package/bin/{chunk-hsx4pns6.js → chunk-4g4pxmef.js} +1 -1
  18. package/bin/{chunk-9fyb95r5.js → chunk-4jj92zwa.js} +1 -1
  19. package/bin/{chunk-6pwf7qa6.js → chunk-4yhvexzk.js} +1 -1
  20. package/bin/chunk-58cbk6e8.js +1 -0
  21. package/bin/{chunk-59ayg5am.js → chunk-59t9s2jh.js} +1 -1
  22. package/bin/{chunk-5y3kx4kk.js → chunk-5e7r7a9d.js} +1 -1
  23. package/bin/{chunk-4nkwe7dz.js → chunk-5m51b7af.js} +1 -1
  24. package/bin/{chunk-fnkkwna8.js → chunk-65t6rm5d.js} +1 -1
  25. package/bin/chunk-6bed0rz4.js +1 -0
  26. package/bin/{chunk-w4adkd0a.js → chunk-6smn0q1n.js} +4 -4
  27. package/bin/{chunk-b3tkvdfk.js → chunk-6zerk0em.js} +1 -1
  28. package/bin/{chunk-t6myw0jf.js → chunk-7bbsv8g0.js} +1 -1
  29. package/bin/chunk-83bdgs2c.js +1 -0
  30. package/bin/{chunk-zpk87b33.js → chunk-86qtjd30.js} +5 -5
  31. package/bin/{chunk-b5r0be06.js → chunk-8rekh4h9.js} +1 -1
  32. package/bin/{chunk-68xsb3t8.js → chunk-8s9fehda.js} +1 -1
  33. package/bin/{chunk-srv5kvm4.js → chunk-8sf2hf31.js} +1 -1
  34. package/bin/{chunk-2rrcdhkj.js → chunk-9d3w678j.js} +1 -1
  35. package/bin/{chunk-ppb4aj0y.js → chunk-9gftd4f7.js} +2 -2
  36. package/bin/{chunk-6hs63sva.js → chunk-9rcg8zgs.js} +32 -32
  37. package/bin/{chunk-xfmnfcv2.js → chunk-a23q1kc4.js} +2 -2
  38. package/bin/{chunk-eshwjf91.js → chunk-a6cdt85k.js} +1 -1
  39. package/bin/chunk-a76h3ehe.js +1 -0
  40. package/bin/{chunk-3wcvema0.js → chunk-b1bkd2p4.js} +7 -7
  41. package/bin/{chunk-np39aknv.js → chunk-bf5m8f6t.js} +1 -1
  42. package/bin/{chunk-24nx3krz.js → chunk-cf57fk11.js} +1 -1
  43. package/bin/{chunk-929abwgr.js → chunk-cv5xx81e.js} +1 -1
  44. package/bin/{chunk-fpjvr3qw.js → chunk-czybv3vy.js} +1 -1
  45. package/bin/{chunk-fsr83nb1.js → chunk-d4sbcvpa.js} +1 -1
  46. package/bin/{chunk-b6dbqs39.js → chunk-d6xezgrg.js} +1 -1
  47. package/bin/{chunk-hy5ncvpf.js → chunk-da86fpjt.js} +1 -1
  48. package/bin/{chunk-me3zmpj5.js → chunk-dzjmwat0.js} +7 -7
  49. package/bin/{chunk-909h3qzp.js → chunk-eex8sjfs.js} +1 -1
  50. package/bin/{chunk-qqapw198.js → chunk-emgyjhmx.js} +1 -1
  51. package/bin/{chunk-y5h5d5gx.js → chunk-exmwerag.js} +4 -4
  52. package/bin/{chunk-fznchvm7.js → chunk-f38xyahm.js} +1 -1
  53. package/bin/{chunk-cqnected.js → chunk-fb1bes2h.js} +1 -1
  54. package/bin/chunk-fbvak7q2.js +1 -0
  55. package/bin/{chunk-tqdde9bj.js → chunk-fg9sr6r9.js} +1 -1
  56. package/bin/{chunk-m41tbrvt.js → chunk-fyb6t7ct.js} +2 -2
  57. package/bin/{chunk-cfqny70c.js → chunk-g2ptqqm3.js} +2 -2
  58. package/bin/{chunk-k3ds96cb.js → chunk-ggwqxn95.js} +1 -1
  59. package/bin/chunk-ghk54h71.js +13 -0
  60. package/bin/{chunk-40tmh04g.js → chunk-h1fbev9c.js} +1 -1
  61. package/bin/{chunk-6sq6dfa1.js → chunk-h9akn41s.js} +1 -1
  62. package/bin/{chunk-zq5j9wsc.js → chunk-hdansxny.js} +1 -1
  63. package/bin/{chunk-zsg61vr0.js → chunk-hjwpd09v.js} +1 -1
  64. package/bin/{chunk-03zkxckm.js → chunk-hjzbw975.js} +1 -1
  65. package/bin/{chunk-mzme3m82.js → chunk-j4p3eqtd.js} +1 -1
  66. package/bin/chunk-jtkxeat4.js +2 -0
  67. package/bin/{chunk-5ebb2pdf.js → chunk-jw4g9628.js} +3 -3
  68. package/bin/{chunk-hbnpx0a5.js → chunk-jxebakyq.js} +1 -1
  69. package/bin/{chunk-d1rjpbgv.js → chunk-kfewyax2.js} +1 -1
  70. package/bin/chunk-kk3m4za5.js +1 -0
  71. package/bin/{chunk-24da4wg9.js → chunk-m7tnj47b.js} +1 -1
  72. package/bin/{chunk-b88tdt79.js → chunk-maw5ah8t.js} +2 -2
  73. package/bin/{chunk-hn2g40r6.js → chunk-n0wwtjwv.js} +1 -1
  74. package/bin/{chunk-qcpeefhr.js → chunk-nahdd2t9.js} +1 -1
  75. package/bin/{chunk-fa9yq17g.js → chunk-nv7tztvh.js} +28 -28
  76. package/bin/{chunk-srmx5z3v.js → chunk-nyjwdxyj.js} +2 -2
  77. package/bin/{chunk-t1h12r3q.js → chunk-p0yfxt5e.js} +5 -5
  78. package/bin/{chunk-4bc3gqmn.js → chunk-q27qn367.js} +2 -2
  79. package/bin/{chunk-9ca8a5f2.js → chunk-q36sdt2w.js} +1 -1
  80. package/bin/{chunk-zzbn0b6c.js → chunk-qbj5pe8t.js} +1 -1
  81. package/bin/chunk-qj0bxb1m.js +2 -0
  82. package/bin/{chunk-xdrpahym.js → chunk-qk5hsn6e.js} +1 -1
  83. package/bin/{chunk-qjdvs1s5.js → chunk-qnyqtaf0.js} +1 -1
  84. package/bin/{chunk-3ahax79y.js → chunk-qqkr6h07.js} +2 -2
  85. package/bin/chunk-qyqc5j3a.css +1 -0
  86. package/bin/chunk-qzaf6bre.js +2 -0
  87. package/bin/{chunk-nmd1901j.js → chunk-r1e59gf0.js} +1 -1
  88. package/bin/chunk-ra5csbkr.js +2 -0
  89. package/bin/{chunk-2w2bknn2.js → chunk-rx9g95wk.js} +3 -3
  90. package/bin/{chunk-04nqnkzs.js → chunk-rxyy37wa.js} +3 -3
  91. package/bin/{chunk-bn0taqr3.js → chunk-scez7ppq.js} +2 -2
  92. package/bin/{chunk-26am2rzm.js → chunk-t2a1vq34.js} +1 -1
  93. package/bin/chunk-t879v3b7.js +1 -0
  94. package/bin/{chunk-a8bymrv1.js → chunk-tjavzarz.js} +2 -2
  95. package/bin/{chunk-n08h1jgx.js → chunk-treyx8em.js} +1 -1
  96. package/bin/{chunk-p7zw53ep.js → chunk-v3z4z04s.js} +1 -1
  97. package/bin/{chunk-461gcgrs.js → chunk-v3z63tpw.js} +1 -1
  98. package/bin/{chunk-s0vfj06y.js → chunk-v9bes1fv.js} +1 -1
  99. package/bin/{chunk-vsnq4381.js → chunk-vjyget8s.js} +1 -1
  100. package/bin/{chunk-s6g2mzpn.js → chunk-vmm9m3nv.js} +1 -1
  101. package/bin/{chunk-qx553512.js → chunk-vvr8tnse.js} +36 -36
  102. package/bin/{chunk-hgy9rqt1.js → chunk-w3stry4v.js} +1 -1
  103. package/bin/{chunk-8ts3xkme.js → chunk-w89czwjj.js} +1 -1
  104. package/bin/{chunk-157axqz1.js → chunk-wk0hk00z.js} +1 -1
  105. package/bin/{chunk-pwq6dbb5.js → chunk-ww9qq8yq.js} +1 -1
  106. package/bin/{chunk-q1gfypy3.js → chunk-x4q082e6.js} +1 -1
  107. package/bin/{chunk-cvfznrnt.js → chunk-x6rf77jm.js} +1 -1
  108. package/bin/chunk-x7dyj53k.js +2 -0
  109. package/bin/{chunk-j420aqk8.js → chunk-xcrd0y8v.js} +3 -3
  110. package/bin/{chunk-q4qqmes7.js → chunk-z0z0jn5h.js} +2 -2
  111. package/bin/{chunk-1tesbv8w.js → chunk-zasjhrwc.js} +1 -1
  112. package/bin/chunk-zefds5gg.js +1 -0
  113. package/bin/{chunk-2pt9h882.js → chunk-zzzgk1d5.js} +2 -2
  114. package/bin/shumai-app.html +1 -1
  115. package/bin/shumai-app.js +364 -364
  116. package/package.json +8 -11
  117. package/bin/chunk-45p7d22e.js +0 -2
  118. package/bin/chunk-87secbzy.js +0 -1
  119. package/bin/chunk-8pykp70z.js +0 -1
  120. package/bin/chunk-cb37q6t0.js +0 -1
  121. package/bin/chunk-g2z0c39g.js +0 -1
  122. package/bin/chunk-gnt9gewm.js +0 -2
  123. package/bin/chunk-hk659cg2.css +0 -1
  124. package/bin/chunk-k97axrc4.js +0 -13
  125. package/bin/chunk-m9f21ye9.js +0 -1
  126. package/bin/chunk-md7pgk86.js +0 -2
  127. package/bin/chunk-mg6sybt0.js +0 -1
  128. package/bin/chunk-r3s1x5wp.js +0 -1
  129. package/bin/chunk-sjbvt3wa.js +0 -2
  130. package/bin/chunk-t8jfp3vx.js +0 -1
  131. package/bin/chunk-vk9ecq8n.js +0 -2
  132. package/bin/chunk-xhngtwn9.js +0 -1
  133. package/bin/chunk-xjnehexk.js +0 -2
  134. package/bin/chunk-xzb0t8mx.js +0 -1
  135. package/bin/chunk-zts21ft7.js +0 -1
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{G}from"./chunk-a8bymrv1.js";var n=null;function c(e){if(typeof process>"u"||!process.versions?.bun||Object.keys(process.env).length>0)return;if(n===null){n=new Map;try{let{readFileSync:t}=G("fs"),s=t("/proc/self/environ","utf-8");for(let r of s.split("\x00")){let o=r.indexOf("=");if(o>0)n.set(r.slice(0,o),r.slice(o+1))}}catch{}}return n.get(e)}function dr(e,t){return t?.[e]||(typeof process<"u"?process.env[e]:void 0)||c(e)||void 0}
2
+ import{V}from"./chunk-tjavzarz.js";var n=null;function c(e){if(typeof process>"u"||!process.versions?.bun||Object.keys(process.env).length>0)return;if(n===null){n=new Map;try{let{readFileSync:t}=V("fs"),s=t("/proc/self/environ","utf-8");for(let r of s.split("\x00")){let o=r.indexOf("=");if(o>0)n.set(r.slice(0,o),r.slice(o+1))}}catch{}}return n.get(e)}function dr(e,t){return t?.[e]||(typeof process<"u"?process.env[e]:void 0)||c(e)||void 0}
3
3
  export{dr};
@@ -1,2 +1,2 @@
1
- import{I}from"./chunk-qx553512.js";var c=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Nr=I("copy",c);
1
+ import{I}from"./chunk-vvr8tnse.js";var c=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Nr=I("copy",c);
2
2
  export{Nr};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Dt}from"./chunk-3ahax79y.js";import{Ge}from"./chunk-y5h5d5gx.js";import{H}from"./chunk-a8bymrv1.js";var i=H(Ge());var t=H(Ge());import{exec as u}from"child_process";import{promisify as w}from"util";var a=H(Dt()),p=(r,e,o)=>{if(e.Version!==1)throw Error(`Profile ${r} credential_process did not return Version 1.`);if(e.AccessKeyId===void 0||e.SecretAccessKey===void 0)throw Error(`Profile ${r} credential_process returned invalid credentials.`);if(e.Expiration){let d=new Date;if(new Date(e.Expiration)<d)throw Error(`Profile ${r} credential_process returned expired credentials.`)}let s=e.AccountId;if(!s&&o?.[r]?.aws_account_id)s=o[r].aws_account_id;let n={accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,...e.SessionToken&&{sessionToken:e.SessionToken},...e.Expiration&&{expiration:new Date(e.Expiration)},...e.CredentialScope&&{credentialScope:e.CredentialScope},...s&&{accountId:s}};return a.setCredentialFeature(n,"CREDENTIALS_PROCESS","w"),n};var f=async(r,e,o)=>{let s=e[r];if(e[r]){let n=s.credential_process;if(n!==void 0){let d=w(t.externalDataInterceptor?.getTokenRecord?.().exec??u);try{let{stdout:c}=await d(n),l;try{l=JSON.parse(c.trim())}catch{throw Error(`Profile ${r} credential_process returned invalid JSON.`)}return p(r,l,e)}catch(c){throw new t.CredentialsProviderError(c.message,{logger:o})}}else throw new t.CredentialsProviderError(`Profile ${r} did not contain credential_process.`,{logger:o})}else throw new t.CredentialsProviderError(`Profile ${r} could not be found in shared credentials file.`,{logger:o})};var P=(r={})=>async({callerClientConfig:e}={})=>{r.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");let o=await i.parseKnownFiles(r);return f(i.getProfileName({profile:r.profile??e?.profile}),o,r.logger)};export{P as fromProcess};
2
+ import{Dt}from"./chunk-qqkr6h07.js";import{Ge}from"./chunk-exmwerag.js";import{H}from"./chunk-tjavzarz.js";var i=H(Ge());var t=H(Ge());import{exec as u}from"child_process";import{promisify as w}from"util";var a=H(Dt()),p=(r,e,o)=>{if(e.Version!==1)throw Error(`Profile ${r} credential_process did not return Version 1.`);if(e.AccessKeyId===void 0||e.SecretAccessKey===void 0)throw Error(`Profile ${r} credential_process returned invalid credentials.`);if(e.Expiration){let d=new Date;if(new Date(e.Expiration)<d)throw Error(`Profile ${r} credential_process returned expired credentials.`)}let s=e.AccountId;if(!s&&o?.[r]?.aws_account_id)s=o[r].aws_account_id;let n={accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,...e.SessionToken&&{sessionToken:e.SessionToken},...e.Expiration&&{expiration:new Date(e.Expiration)},...e.CredentialScope&&{credentialScope:e.CredentialScope},...s&&{accountId:s}};return a.setCredentialFeature(n,"CREDENTIALS_PROCESS","w"),n};var f=async(r,e,o)=>{let s=e[r];if(e[r]){let n=s.credential_process;if(n!==void 0){let d=w(t.externalDataInterceptor?.getTokenRecord?.().exec??u);try{let{stdout:c}=await d(n),l;try{l=JSON.parse(c.trim())}catch{throw Error(`Profile ${r} credential_process returned invalid JSON.`)}return p(r,l,e)}catch(c){throw new t.CredentialsProviderError(c.message,{logger:o})}}else throw new t.CredentialsProviderError(`Profile ${r} did not contain credential_process.`,{logger:o})}else throw new t.CredentialsProviderError(`Profile ${r} could not be found in shared credentials file.`,{logger:o})};var P=(r={})=>async({callerClientConfig:e}={})=>{r.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");let o=await i.parseKnownFiles(r);return f(i.getProfileName({profile:r.profile??e?.profile}),o,r.logger)};export{P as fromProcess};
@@ -1 +1 @@
1
- import{m,u,S,L,t,o,Re,gn,ze,I,ir,O,to,on,E,Mm,iy,ay,Wf,Jf,kw,lS,cS,_p,pE,mE,hE,Vg,zC,jC,z,f,R,W,Ul,zl,jl}from"./chunk-qx553512.js";import{nr}from"./chunk-qqapw198.js";var v=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],w=I("key-round",v);S();var x=R({password:f().min(3,_p()),confirmPassword:f().min(3,_p())}).refine((s)=>s.password===s.confirmPassword,{message:hE(),path:["confirmPassword"]}),b=ze("/reset-password")({component:N});function N(){let s=Re(),r=b.useSearch().token||"",[n,a]=u(null),[l,c]=u(!1),[i,h]=u(!1),e=zl({resolver:jl(x),defaultValues:{password:"",confirmPassword:""}});m(()=>{if(i){let d=setTimeout(()=>{s({to:"/login"})},3000);return()=>clearTimeout(d)}},[i,s]);let g=async(d)=>{if(!r){a(Jf());return}c(!0),a(null);let{error:p}=await Mm({newPassword:d.password,token:r});if(c(!1),p){a(p.message||Jf());return}h(!0)};return o(Ul,{children:[o("div",{className:"mb-8",children:[t("h1",{className:"text-2xl font-bold tracking-tight text-foreground",children:Vg()}),t("p",{className:"text-muted-foreground text-sm mt-1",children:zC()})]}),!r?o("div",{className:"space-y-6",children:[o("div",{className:"p-4 bg-destructive/10 border border-destructive/20 text-destructive rounded-xl text-sm flex items-start gap-3",children:[t(nr,{className:"w-5 h-5 shrink-0 mt-0.5"}),o("div",{className:"space-y-1",children:[t("p",{className:"font-semibold",children:Jf()}),t("p",{className:"text-xs text-muted-foreground",children:kw()})]})]}),t(gn,{to:"/login",className:"block w-full",children:o(E,{variant:"outline",className:"w-full h-11 rounded-xl flex items-center justify-center gap-2",children:[Wf(),t(to,{className:"w-4 h-4"})]})})]}):i?o("div",{className:"space-y-6",children:[o("div",{className:"p-4 bg-emerald-500/10 border border-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded-xl text-sm flex items-start gap-3",children:[t(ir,{className:"w-5 h-5 shrink-0 mt-0.5"}),o("div",{className:"space-y-1",children:[t("p",{className:"font-semibold",children:pE()}),t("p",{className:"text-xs text-muted-foreground",children:mE()})]})]}),t(gn,{to:"/login",className:"block w-full",children:o(E,{className:"w-full h-11 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-600 hover:to-orange-600 text-white font-semibold rounded-xl shadow-md shadow-rose-500/10 hover:shadow-rose-500/20 active:scale-[0.98] transition-all flex items-center justify-center gap-2 border-0",children:[Wf(),t(to,{className:"w-4 h-4"})]})})]}):o("form",{onSubmit:e.handleSubmit(g),className:"space-y-5",children:[n&&t("div",{className:"p-3 bg-destructive/10 border border-destructive/20 text-destructive rounded-xl text-sm text-center font-medium",children:n}),o("div",{className:"space-y-2",children:[t(W,{htmlFor:"password",className:"text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:lS()}),o("div",{className:"relative group",children:[t(on,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground transition-colors group-focus-within:text-rose-500"}),t(z,{id:"password",type:"password",...e.register("password"),placeholder:cS(),className:"pl-10.5 h-11 border-border focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"})]}),e.formState.errors.password&&t("p",{className:"text-destructive text-xs font-medium",children:e.formState.errors.password.message})]}),o("div",{className:"space-y-2",children:[t(W,{htmlFor:"confirmPassword",className:"text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:iy()}),o("div",{className:"relative group",children:[t(on,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground transition-colors group-focus-within:text-rose-500"}),t(z,{id:"confirmPassword",type:"password",...e.register("confirmPassword"),placeholder:ay(),className:"pl-10.5 h-11 border-border focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"})]}),e.formState.errors.confirmPassword&&t("p",{className:"text-destructive text-xs font-medium",children:e.formState.errors.confirmPassword.message})]}),t(E,{type:"submit",className:"w-full h-11 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-600 hover:to-orange-600 text-white font-semibold rounded-xl shadow-md shadow-rose-500/10 hover:shadow-rose-500/20 active:scale-[0.98] transition-all flex items-center justify-center gap-2 border-0",disabled:l,children:l?o(L,{children:[t(O,{className:"h-4 w-4 animate-spin"}),jC()]}):o(L,{children:[t(w,{className:"w-4 h-4"}),Vg()]})}),t("div",{className:"pt-2 text-center text-sm",children:t(gn,{to:"/login",className:"font-semibold text-rose-500 hover:text-rose-600 dark:text-rose-400 dark:hover:text-rose-300 transition-colors hover:underline inline-flex items-center gap-1",children:Wf()})})]})]})}export{b as Route};
1
+ import{m,u,S,L,t,o,ke,gn,Ue,I,ir,O,to,on,C,Pm,iy,ay,Yf,Xf,kw,lS,cS,yp,pE,mE,hE,Wg,zC,jC,z,f,R,W,Ul,zl,jl}from"./chunk-vvr8tnse.js";import{nr}from"./chunk-emgyjhmx.js";var v=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],w=I("key-round",v);S();var x=R({password:f().min(3,yp()),confirmPassword:f().min(3,yp())}).refine((s)=>s.password===s.confirmPassword,{message:hE(),path:["confirmPassword"]}),b=Ue("/reset-password")({component:N});function N(){let s=ke(),r=b.useSearch().token||"",[n,a]=u(null),[l,c]=u(!1),[i,h]=u(!1),e=zl({resolver:jl(x),defaultValues:{password:"",confirmPassword:""}});m(()=>{if(i){let d=setTimeout(()=>{s({to:"/login"})},3000);return()=>clearTimeout(d)}},[i,s]);let g=async(d)=>{if(!r){a(Xf());return}c(!0),a(null);let{error:p}=await Pm({newPassword:d.password,token:r});if(c(!1),p){a(p.message||Xf());return}h(!0)};return o(Ul,{children:[o("div",{className:"mb-8",children:[t("h1",{className:"text-2xl font-bold tracking-tight text-foreground",children:Wg()}),t("p",{className:"text-muted-foreground text-sm mt-1",children:zC()})]}),!r?o("div",{className:"space-y-6",children:[o("div",{className:"p-4 bg-destructive/10 border border-destructive/20 text-destructive rounded-xl text-sm flex items-start gap-3",children:[t(nr,{className:"w-5 h-5 shrink-0 mt-0.5"}),o("div",{className:"space-y-1",children:[t("p",{className:"font-semibold",children:Xf()}),t("p",{className:"text-xs text-muted-foreground",children:kw()})]})]}),t(gn,{to:"/login",className:"block w-full",children:o(C,{variant:"outline",className:"w-full h-11 rounded-xl flex items-center justify-center gap-2",children:[Yf(),t(to,{className:"w-4 h-4"})]})})]}):i?o("div",{className:"space-y-6",children:[o("div",{className:"p-4 bg-emerald-500/10 border border-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded-xl text-sm flex items-start gap-3",children:[t(ir,{className:"w-5 h-5 shrink-0 mt-0.5"}),o("div",{className:"space-y-1",children:[t("p",{className:"font-semibold",children:pE()}),t("p",{className:"text-xs text-muted-foreground",children:mE()})]})]}),t(gn,{to:"/login",className:"block w-full",children:o(C,{className:"w-full h-11 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-600 hover:to-orange-600 text-white font-semibold rounded-xl shadow-md shadow-rose-500/10 hover:shadow-rose-500/20 active:scale-[0.98] transition-all flex items-center justify-center gap-2 border-0",children:[Yf(),t(to,{className:"w-4 h-4"})]})})]}):o("form",{onSubmit:e.handleSubmit(g),className:"space-y-5",children:[n&&t("div",{className:"p-3 bg-destructive/10 border border-destructive/20 text-destructive rounded-xl text-sm text-center font-medium",children:n}),o("div",{className:"space-y-2",children:[t(W,{htmlFor:"password",className:"text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:lS()}),o("div",{className:"relative group",children:[t(on,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground transition-colors group-focus-within:text-rose-500"}),t(z,{id:"password",type:"password",...e.register("password"),placeholder:cS(),className:"pl-10.5 h-11 border-border focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"})]}),e.formState.errors.password&&t("p",{className:"text-destructive text-xs font-medium",children:e.formState.errors.password.message})]}),o("div",{className:"space-y-2",children:[t(W,{htmlFor:"confirmPassword",className:"text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:iy()}),o("div",{className:"relative group",children:[t(on,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground transition-colors group-focus-within:text-rose-500"}),t(z,{id:"confirmPassword",type:"password",...e.register("confirmPassword"),placeholder:ay(),className:"pl-10.5 h-11 border-border focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"})]}),e.formState.errors.confirmPassword&&t("p",{className:"text-destructive text-xs font-medium",children:e.formState.errors.confirmPassword.message})]}),t(C,{type:"submit",className:"w-full h-11 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-600 hover:to-orange-600 text-white font-semibold rounded-xl shadow-md shadow-rose-500/10 hover:shadow-rose-500/20 active:scale-[0.98] transition-all flex items-center justify-center gap-2 border-0",disabled:l,children:l?o(L,{children:[t(O,{className:"h-4 w-4 animate-spin"}),jC()]}):o(L,{children:[t(w,{className:"w-4 h-4"}),Wg()]})}),t("div",{className:"pt-2 text-center text-sm",children:t(gn,{to:"/login",className:"font-semibold text-rose-500 hover:text-rose-600 dark:text-rose-400 dark:hover:text-rose-300 transition-colors hover:underline inline-flex items-center gap-1",children:Yf()})})]})]})}export{b as Route};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{df,Jr}from"./chunk-5ebb2pdf.js";import{dr}from"./chunk-b5r0be06.js";import{Ui}from"./chunk-5bpvwv66.js";import{zi,ji}from"./chunk-rq2h2bwt.js";import{ls}from"./chunk-6hzktewz.js";import{He,po,uf,Tr,gm,mo}from"./chunk-m41tbrvt.js";import{pn}from"./chunk-3fjgf7eb.js";import{mn}from"./chunk-ncv8v6mj.js";import{Jt}from"./chunk-q7t5zs7n.js";function f(e,t,r,s,n){if(s==="m")throw TypeError("Private method is not writable");if(s==="a"&&!n)throw TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!n:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r}function a(e,t,r,s){if(r==="a"&&!s)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!s:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}var Vt=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return Vt=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),r=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(s)=>(+s^r()&15>>+s/4).toString(16))};function U(e){return typeof e==="object"&&e!==null&&(("name"in e)&&e.name==="AbortError"||("message"in e)&&String(e.message).includes("FetchRequestCanceledException"))}var ye=(e)=>{if(e instanceof Error)return e;if(typeof e==="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){let t=Error(e.message,e.cause?{cause:e.cause}:{});if(e.stack)t.stack=e.stack;if(e.cause&&!t.cause)t.cause=e.cause;if(e.name)t.name=e.name;return t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};class m extends Error{}class k extends m{constructor(e,t,r,s,n){super(`${k.makeMessage(e,t,r)}`);this.status=e,this.headers=s,this.requestID=s?.get("request-id"),this.error=t,this.type=n??null}static makeMessage(e,t,r){let s=t?.message?typeof t.message==="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):r;if(e&&s)return`${e} ${s}`;if(e)return`${e} status code (no body)`;if(s)return s;return"(no status code or body)"}static generate(e,t,r,s){if(!e||!s)return new Y({message:r,cause:ye(t)});let n=t,o=n?.error?.type;if(e===400)return new xe(e,n,r,s,o);if(e===401)return new Se(e,n,r,s,o);if(e===403)return new ke(e,n,r,s,o);if(e===404)return new Pe(e,n,r,s,o);if(e===409)return new Re(e,n,r,s,o);if(e===422)return new ve(e,n,r,s,o);if(e===429)return new Ee(e,n,r,s,o);if(e>=500)return new Me(e,n,r,s,o);return new k(e,n,r,s,o)}}class E extends k{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class Y extends k{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0);if(t)this.cause=t}}class we extends Y{constructor({message:e}={}){super({message:e??"Request timed out."})}}class xe extends k{}class Se extends k{}class ke extends k{}class Pe extends k{}class Re extends k{}class ve extends k{}class Ee extends k{}class Me extends k{}var Is=/^[a-z][a-z0-9+.-]*:/i,Ir=(e)=>Is.test(e),Xt=(e)=>(Xt=Array.isArray,Xt(e)),Kt=Xt;function mt(e){if(typeof e!=="object")return{};return e??{}}function Gt(e){if(!e)return!0;for(let t in e)return!1;return!0}function $r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Cr=(e,t)=>{if(typeof t!=="number"||!Number.isInteger(t))throw new m(`${e} must be an integer`);if(t<0)throw new m(`${e} must be a positive integer`);return t};var gt=(e)=>{try{return JSON.parse(e)}catch(t){return}};var Or=(e)=>new Promise((t)=>setTimeout(t,e));var V="0.91.1";var qr=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function $s(){if(typeof Deno<"u"&&Deno.build!=null)return"deno";if(typeof EdgeRuntime<"u")return"edge";if(Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]")return"node";return"unknown"}var Cs=()=>{let e=$s();if(e==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":V,"X-Stainless-OS":Lr(Deno.build.os),"X-Stainless-Arch":Nr(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":V,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(e==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":V,"X-Stainless-OS":Lr(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Nr(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=Os();if(t)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":V,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":V,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Os(){if(typeof navigator>"u"||!navigator)return null;let e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:t,pattern:r}of e){let s=r.exec(navigator.userAgent);if(s){let n=s[1]||0,o=s[2]||0,c=s[3]||0;return{browser:t,version:`${n}.${o}.${c}`}}}return null}var Nr=(e)=>{if(e==="x32")return"x32";if(e==="x86_64"||e==="x64")return"x64";if(e==="arm")return"arm";if(e==="aarch64"||e==="arm64")return"arm64";if(e)return`other:${e}`;return"unknown"},Lr=(e)=>{if(e=e.toLowerCase(),e.includes("ios"))return"iOS";if(e==="android")return"Android";if(e==="darwin")return"MacOS";if(e==="win32")return"Windows";if(e==="freebsd")return"FreeBSD";if(e==="openbsd")return"OpenBSD";if(e==="linux")return"Linux";if(e)return`Other:${e}`;return"Unknown"},Fr,Br=()=>Fr??(Fr=Cs());function jr(){if(typeof fetch<"u")return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function zt(...e){let t=globalThis.ReadableStream;if(typeof t>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function _t(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return zt({start(){},async pull(r){let{done:s,value:n}=await t.next();if(s)r.close();else r.enqueue(n)},async cancel(){await t.return?.()}})}function Te(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let r=await t.read();if(r?.done)t.releaseLock();return r}catch(r){throw t.releaseLock(),r}},async return(){let r=t.cancel();return t.releaseLock(),await r,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Ur(e){if(e===null||typeof e!=="object")return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),r=t.cancel();t.releaseLock(),await r}var Hr=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});function Wr(e){return Object.entries(e).filter(([t,r])=>typeof r<"u").map(([t,r])=>{if(typeof r==="string"||typeof r==="number"||typeof r==="boolean")return`${encodeURIComponent(t)}=${encodeURIComponent(r)}`;if(r===null)return`${encodeURIComponent(t)}=`;throw new m(`Cannot stringify type ${typeof r}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}function Xr(e){let t=0;for(let n of e)t+=n.length;let r=new Uint8Array(t),s=0;for(let n of e)r.set(n,s),s+=n.length;return r}var Dr;function Ae(e){let t;return(Dr??(t=new globalThis.TextEncoder,Dr=t.encode.bind(t)))(e)}var Vr;function Qt(e){let t;return(Vr??(t=new globalThis.TextDecoder,Vr=t.decode.bind(t)))(e)}var A,I;class X{constructor(){A.set(this,void 0),I.set(this,void 0),f(this,A,new Uint8Array,"f"),f(this,I,null,"f")}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==="string"?Ae(e):e;f(this,A,Xr([a(this,A,"f"),t]),"f");let r=[],s;while((s=Fs(a(this,A,"f"),a(this,I,"f")))!=null){if(s.carriage&&a(this,I,"f")==null){f(this,I,s.index,"f");continue}if(a(this,I,"f")!=null&&(s.index!==a(this,I,"f")+1||s.carriage)){r.push(Qt(a(this,A,"f").subarray(0,a(this,I,"f")-1))),f(this,A,a(this,A,"f").subarray(a(this,I,"f")),"f"),f(this,I,null,"f");continue}let n=a(this,I,"f")!==null?s.preceding-1:s.preceding,o=Qt(a(this,A,"f").subarray(0,n));r.push(o),f(this,A,a(this,A,"f").subarray(s.index),"f"),f(this,I,null,"f")}return r}flush(){if(!a(this,A,"f").length)return[];return this.decode(`
2
+ import{ff,Jr}from"./chunk-jw4g9628.js";import{dr}from"./chunk-8rekh4h9.js";import{Ui}from"./chunk-5bpvwv66.js";import{zi,ji}from"./chunk-rq2h2bwt.js";import{ls}from"./chunk-6hzktewz.js";import{He,po,df,Tr,ym,mo}from"./chunk-fyb6t7ct.js";import{pn}from"./chunk-3fjgf7eb.js";import{mn}from"./chunk-047n9gfs.js";import{Jt}from"./chunk-q7t5zs7n.js";function f(e,t,r,s,n){if(s==="m")throw TypeError("Private method is not writable");if(s==="a"&&!n)throw TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!n:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r}function a(e,t,r,s){if(r==="a"&&!s)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!s:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}var Vt=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return Vt=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),r=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(s)=>(+s^r()&15>>+s/4).toString(16))};function U(e){return typeof e==="object"&&e!==null&&(("name"in e)&&e.name==="AbortError"||("message"in e)&&String(e.message).includes("FetchRequestCanceledException"))}var ye=(e)=>{if(e instanceof Error)return e;if(typeof e==="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){let t=Error(e.message,e.cause?{cause:e.cause}:{});if(e.stack)t.stack=e.stack;if(e.cause&&!t.cause)t.cause=e.cause;if(e.name)t.name=e.name;return t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};class m extends Error{}class k extends m{constructor(e,t,r,s,n){super(`${k.makeMessage(e,t,r)}`);this.status=e,this.headers=s,this.requestID=s?.get("request-id"),this.error=t,this.type=n??null}static makeMessage(e,t,r){let s=t?.message?typeof t.message==="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):r;if(e&&s)return`${e} ${s}`;if(e)return`${e} status code (no body)`;if(s)return s;return"(no status code or body)"}static generate(e,t,r,s){if(!e||!s)return new Y({message:r,cause:ye(t)});let n=t,o=n?.error?.type;if(e===400)return new xe(e,n,r,s,o);if(e===401)return new Se(e,n,r,s,o);if(e===403)return new ke(e,n,r,s,o);if(e===404)return new Pe(e,n,r,s,o);if(e===409)return new Re(e,n,r,s,o);if(e===422)return new ve(e,n,r,s,o);if(e===429)return new Ee(e,n,r,s,o);if(e>=500)return new Me(e,n,r,s,o);return new k(e,n,r,s,o)}}class E extends k{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class Y extends k{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0);if(t)this.cause=t}}class we extends Y{constructor({message:e}={}){super({message:e??"Request timed out."})}}class xe extends k{}class Se extends k{}class ke extends k{}class Pe extends k{}class Re extends k{}class ve extends k{}class Ee extends k{}class Me extends k{}var Is=/^[a-z][a-z0-9+.-]*:/i,Ir=(e)=>Is.test(e),Xt=(e)=>(Xt=Array.isArray,Xt(e)),Kt=Xt;function mt(e){if(typeof e!=="object")return{};return e??{}}function Gt(e){if(!e)return!0;for(let t in e)return!1;return!0}function $r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Cr=(e,t)=>{if(typeof t!=="number"||!Number.isInteger(t))throw new m(`${e} must be an integer`);if(t<0)throw new m(`${e} must be a positive integer`);return t};var gt=(e)=>{try{return JSON.parse(e)}catch(t){return}};var Or=(e)=>new Promise((t)=>setTimeout(t,e));var V="0.91.1";var qr=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function $s(){if(typeof Deno<"u"&&Deno.build!=null)return"deno";if(typeof EdgeRuntime<"u")return"edge";if(Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]")return"node";return"unknown"}var Cs=()=>{let e=$s();if(e==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":V,"X-Stainless-OS":Lr(Deno.build.os),"X-Stainless-Arch":Nr(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":V,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(e==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":V,"X-Stainless-OS":Lr(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Nr(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=Os();if(t)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":V,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":V,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Os(){if(typeof navigator>"u"||!navigator)return null;let e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:t,pattern:r}of e){let s=r.exec(navigator.userAgent);if(s){let n=s[1]||0,o=s[2]||0,c=s[3]||0;return{browser:t,version:`${n}.${o}.${c}`}}}return null}var Nr=(e)=>{if(e==="x32")return"x32";if(e==="x86_64"||e==="x64")return"x64";if(e==="arm")return"arm";if(e==="aarch64"||e==="arm64")return"arm64";if(e)return`other:${e}`;return"unknown"},Lr=(e)=>{if(e=e.toLowerCase(),e.includes("ios"))return"iOS";if(e==="android")return"Android";if(e==="darwin")return"MacOS";if(e==="win32")return"Windows";if(e==="freebsd")return"FreeBSD";if(e==="openbsd")return"OpenBSD";if(e==="linux")return"Linux";if(e)return`Other:${e}`;return"Unknown"},Fr,Br=()=>Fr??(Fr=Cs());function jr(){if(typeof fetch<"u")return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function zt(...e){let t=globalThis.ReadableStream;if(typeof t>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function _t(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return zt({start(){},async pull(r){let{done:s,value:n}=await t.next();if(s)r.close();else r.enqueue(n)},async cancel(){await t.return?.()}})}function Te(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let r=await t.read();if(r?.done)t.releaseLock();return r}catch(r){throw t.releaseLock(),r}},async return(){let r=t.cancel();return t.releaseLock(),await r,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Ur(e){if(e===null||typeof e!=="object")return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),r=t.cancel();t.releaseLock(),await r}var Hr=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});function Wr(e){return Object.entries(e).filter(([t,r])=>typeof r<"u").map(([t,r])=>{if(typeof r==="string"||typeof r==="number"||typeof r==="boolean")return`${encodeURIComponent(t)}=${encodeURIComponent(r)}`;if(r===null)return`${encodeURIComponent(t)}=`;throw new m(`Cannot stringify type ${typeof r}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}function Xr(e){let t=0;for(let n of e)t+=n.length;let r=new Uint8Array(t),s=0;for(let n of e)r.set(n,s),s+=n.length;return r}var Dr;function Ae(e){let t;return(Dr??(t=new globalThis.TextEncoder,Dr=t.encode.bind(t)))(e)}var Vr;function Qt(e){let t;return(Vr??(t=new globalThis.TextDecoder,Vr=t.decode.bind(t)))(e)}var A,I;class X{constructor(){A.set(this,void 0),I.set(this,void 0),f(this,A,new Uint8Array,"f"),f(this,I,null,"f")}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==="string"?Ae(e):e;f(this,A,Xr([a(this,A,"f"),t]),"f");let r=[],s;while((s=Fs(a(this,A,"f"),a(this,I,"f")))!=null){if(s.carriage&&a(this,I,"f")==null){f(this,I,s.index,"f");continue}if(a(this,I,"f")!=null&&(s.index!==a(this,I,"f")+1||s.carriage)){r.push(Qt(a(this,A,"f").subarray(0,a(this,I,"f")-1))),f(this,A,a(this,A,"f").subarray(a(this,I,"f")),"f"),f(this,I,null,"f");continue}let n=a(this,I,"f")!==null?s.preceding-1:s.preceding,o=Qt(a(this,A,"f").subarray(0,n));r.push(o),f(this,A,a(this,A,"f").subarray(s.index),"f"),f(this,I,null,"f")}return r}flush(){if(!a(this,A,"f").length)return[];return this.decode(`
3
3
  `)}}A=new WeakMap,I=new WeakMap;X.NEWLINE_CHARS=new Set([`
4
4
  `,"\r"]);X.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Fs(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function Kr(e){for(let s=0;s<e.length-1;s++){if(e[s]===10&&e[s+1]===10)return s+2;if(e[s]===13&&e[s+1]===13)return s+2;if(e[s]===13&&e[s+1]===10&&s+3<e.length&&e[s+2]===13&&e[s+3]===10)return s+4}return-1}var yt={off:0,error:200,warn:300,info:400,debug:500},Yt=(e,t,r)=>{if(!e)return;if($r(yt,e))return e;R(r).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(yt))}`);return};function Ie(){}function bt(e,t,r){if(!t||yt[e]>yt[r])return Ie;else return t[e].bind(t)}var qs={error:Ie,warn:Ie,info:Ie,debug:Ie},Gr=new WeakMap;function R(e){let t=e.logger,r=e.logLevel??"off";if(!t)return qs;let s=Gr.get(t);if(s&&s[0]===r)return s[1];let n={error:bt("error",t,r),warn:bt("warn",t,r),info:bt("info",t,r),debug:bt("debug",t,r)};return Gr.set(t,[r,n]),n}var H=(e)=>{if(e.options)e.options={...e.options},delete e.options.headers;if(e.headers)e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([t,r])=>[t,t.toLowerCase()==="x-api-key"||t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":r]));if("retryOfRequestLogID"in e){if(e.retryOfRequestLogID)e.retryOf=e.retryOfRequestLogID;delete e.retryOfRequestLogID}return e};var $e;class C{constructor(e,t,r){this.iterator=e,$e.set(this,void 0),this.controller=t,f(this,$e,r,"f")}static fromSSEResponse(e,t,r){let s=!1,n=r?R(r):console;async function*o(){if(s)throw new m("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let c=!1;try{for await(let i of Bs(e,t)){if(i.event==="completion")try{yield JSON.parse(i.data)}catch(h){throw n.error("Could not parse message into JSON:",i.data),n.error("From chunk:",i.raw),h}if(i.event==="message_start"||i.event==="message_delta"||i.event==="message_stop"||i.event==="content_block_start"||i.event==="content_block_delta"||i.event==="content_block_stop"||i.event==="message"||i.event==="user.message"||i.event==="user.interrupt"||i.event==="user.tool_confirmation"||i.event==="user.custom_tool_result"||i.event==="agent.message"||i.event==="agent.thinking"||i.event==="agent.tool_use"||i.event==="agent.tool_result"||i.event==="agent.mcp_tool_use"||i.event==="agent.mcp_tool_result"||i.event==="agent.custom_tool_use"||i.event==="agent.thread_context_compacted"||i.event==="session.status_running"||i.event==="session.status_idle"||i.event==="session.status_rescheduled"||i.event==="session.status_terminated"||i.event==="session.error"||i.event==="session.deleted"||i.event==="span.model_request_start"||i.event==="span.model_request_end")try{yield JSON.parse(i.data)}catch(h){throw n.error("Could not parse message into JSON:",i.data),n.error("From chunk:",i.raw),h}if(i.event==="ping")continue;if(i.event==="error"){let h=gt(i.data)??i.data,b=h?.error?.type;throw new k(void 0,h,void 0,e.headers,b)}}c=!0}catch(i){if(U(i))return;throw i}finally{if(!c)t.abort()}}return new C(o,t,r)}static fromReadableStream(e,t,r){let s=!1;async function*n(){let c=new X,i=Te(e);for await(let h of i)for(let b of c.decode(h))yield b;for(let h of c.flush())yield h}async function*o(){if(s)throw new m("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let c=!1;try{for await(let i of n()){if(c)continue;if(i)yield JSON.parse(i)}c=!0}catch(i){if(U(i))return;throw i}finally{if(!c)t.abort()}}return new C(o,t,r)}[($e=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],r=this.iterator(),s=(n)=>({next:()=>{if(n.length===0){let o=r.next();e.push(o),t.push(o)}return n.shift()}});return[new C(()=>s(e),this.controller,a(this,$e,"f")),new C(()=>s(t),this.controller,a(this,$e,"f"))]}toReadableStream(){let e=this,t;return zt({async start(){t=e[Symbol.asyncIterator]()},async pull(r){try{let{value:s,done:n}=await t.next();if(n)return r.close();let o=Ae(JSON.stringify(s)+`
5
5
  `);r.enqueue(o)}catch(s){r.error(s)}},async cancel(){await t.return?.()}})}}async function*Bs(e,t){if(!e.body){if(t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative")throw new m("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new m("Attempted to iterate over a response with no body")}let r=new zr,s=new X,n=Te(e.body);for await(let o of js(n))for(let c of s.decode(o)){let i=r.decode(c);if(i)yield i}for(let o of s.flush()){let c=r.decode(o);if(c)yield c}}async function*js(e){let t=new Uint8Array;for await(let r of e){if(r==null)continue;let s=r instanceof ArrayBuffer?new Uint8Array(r):typeof r==="string"?Ae(r):r,n=new Uint8Array(t.length+s.length);n.set(t),n.set(s,t.length),t=n;let o;while((o=Kr(t))!==-1)yield t.slice(0,o),t=t.slice(o)}if(t.length>0)yield t}class zr{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r"))e=e.substring(0,e.length-1);if(!e){if(!this.event&&!this.data.length)return null;let n={event:this.event,data:this.data.join(`
@@ -42,4 +42,4 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
42
42
  `));let r=e.map((n)=>{if(n.type==="text")return{type:"text",text:He(n.text)};return{type:"image",source:{type:"base64",media_type:n.mimeType,data:n.data}}});if(!r.some((n)=>n.type==="text"))r.unshift({type:"text",text:"(see attached image)"});return r}var Nn="fine-grained-tool-streaming-2025-05-14",Ln="interleaved-thinking-2025-05-14";function Dt(e){return{supportsEagerToolInputStreaming:e.compat?.supportsEagerToolInputStreaming??!0,supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??!0,sendSessionAffinityHeaders:e.compat?.sendSessionAffinityHeaders??!1,supportsCacheControlOnTools:e.compat?.supportsCacheControlOnTools??!0,supportsTemperature:e.compat?.supportsTemperature??!0,allowEmptySignature:e.compat?.allowEmptySignature??!1,supportsStrictTools:e.compat?.supportsStrictTools??!1,supportsToolReferences:e.compat?.supportsToolReferences??Fn(e)}}function Fn(e){if(e.provider!=="anthropic"||e.id.includes("haiku"))return!1;let t=e.id.match(/^claude-(?:opus|sonnet|fable)-(\d+)(?:-(\d+))?(?:-|$)/);if(!t)return!1;let r=Number(t[1]),s=t[2]&&t[2].length<8?Number(t[2]):0;return r>4||r===4&&s>=5}function kr(...e){let t={};for(let r of e)if(r)Object.assign(t,r);return t}function Pr(e,t){if(!e)return!1;let r=t.toLowerCase();for(let[s,n]of Object.entries(e))if(s.toLowerCase()===r&&n!==null&&n.trim().length>0)return!0;return!1}function Ms(e,t,r){if(t)return;if(Pr(r,"authorization")||Pr(r,"x-api-key")||Pr(r,"cf-aig-authorization"))return;throw Error(`No API key for provider: ${e}`)}var qn=new Set(["message_start","message_delta","message_stop","content_block_start","content_block_delta","content_block_stop"]);function Ts(e){if(!e.event&&e.data.length===0)return null;let t={event:e.event,data:e.data.join(`
43
43
  `),raw:[...e.raw]};return e.event=null,e.data=[],e.raw=[],t}function Rr(e,t){if(e==="")return Ts(t);if(t.raw.push(e),e.startsWith(":"))return null;let r=e.indexOf(":"),s=r===-1?e:e.slice(0,r),n=r===-1?"":e.slice(r+1);if(n.startsWith(" "))n=n.slice(1);if(s==="event")t.event=n;else if(s==="data")t.data.push(n);return null}function Bn(e){let t=e.indexOf("\r"),r=e.indexOf(`
44
44
  `);if(t===-1)return r;if(r===-1)return t;return Math.min(t,r)}function Ht(e){let t=Bn(e);if(t===-1)return null;let r=t+1;if(e[t]==="\r"&&e[r]===`
45
- `)r+=1;return{line:e.slice(0,t),rest:e.slice(r)}}async function*jn(e,t){let r=e.getReader(),s=new TextDecoder,n={event:null,data:[],raw:[]},o="";try{while(!0){if(t?.aborted)throw Error("Request was aborted");let{value:h,done:b}=await r.read();if(b)break;o+=s.decode(h,{stream:!0});let g=Ht(o);while(g){o=g.rest;let _=Rr(g.line,n);if(_)yield _;g=Ht(o)}}o+=s.decode();let c=Ht(o);while(c){o=c.rest;let h=Rr(c.line,n);if(h)yield h;c=Ht(o)}if(o.length>0){let h=Rr(o,n);if(h)yield h}let i=Ts(n);if(i)yield i}finally{r.releaseLock()}}async function*Un(e,t){if(!e.body)throw Error("Attempted to iterate over an Anthropic response with no body");let r=!1,s=!1;for await(let n of jn(e.body,t)){if(n.event==="error")throw Error(n.data);if(!qn.has(n.event??""))continue;try{let o=df(n.data);if(o.type==="message_start")r=!0;else if(o.type==="message_stop")s=!0;yield o}catch(o){let c=o instanceof Error?o.message:String(o);throw Error(`Could not parse Anthropic SSE event ${n.event}: ${c}; data=${n.data}; raw=${n.raw.join("\\n")}`)}}if(r&&!s)throw Error("Anthropic stream ended before message_stop")}var vr=(e,t,r)=>{let s=new Jt;return(async()=>{let n={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let o,c;if(r?.client)o=r.client,c=!1;else{let l=r?.apiKey;Ms(e.provider,l,r?.headers);let p;if(e.provider==="github-copilot"){let L=zi(t.messages);p=ji({messages:t.messages,hasImages:L})}let v=Es(r?.cacheRetention,r?.env)==="none"?void 0:r?.sessionId,N=Dn(e,l,r?.interleavedThinking??!0,Gn(e,t),r?.headers,p,v);o=N.client,c=N.isOAuthToken}let i=Jn(e,t,c,r),h=await r?.onPayload?.(i,e);if(h!==void 0)i=h;let b={...r?.signal?{signal:r.signal}:{},...r?.timeoutMs!==void 0?{timeout:r.timeoutMs}:{},maxRetries:0},g=await ls(()=>o.messages.create({...i,stream:!0},b).asResponse(),{maxRetries:r?.maxRetries,maxRetryDelayMs:r?.maxRetryDelayMs,signal:r?.signal});await r?.onResponse?.({status:g.status,headers:pn(g.headers)},e),s.push({type:"start",partial:n});let _=n.content;for await(let l of Un(g,r?.signal))if(l.type==="message_start")n.responseId=l.message.id,n.usage.input=l.message.usage.input_tokens||0,n.usage.output=l.message.usage.output_tokens||0,n.usage.cacheRead=l.message.usage.cache_read_input_tokens||0,n.usage.cacheWrite=l.message.usage.cache_creation_input_tokens||0,n.usage.cacheWrite1h=l.message.usage.cache_creation?.ephemeral_1h_input_tokens||0,n.usage.totalTokens=n.usage.input+n.usage.output+n.usage.cacheRead+n.usage.cacheWrite,mn(e,n.usage);else if(l.type==="content_block_start"){if(l.content_block.type==="text"){let p={type:"text",text:"",index:l.index};n.content.push(p),s.push({type:"text_start",contentIndex:n.content.length-1,partial:n})}else if(l.content_block.type==="thinking"){let p={type:"thinking",thinking:"",thinkingSignature:"",index:l.index};n.content.push(p),s.push({type:"thinking_start",contentIndex:n.content.length-1,partial:n})}else if(l.content_block.type==="redacted_thinking"){let p={type:"thinking",thinking:"[Reasoning redacted]",thinkingSignature:l.content_block.data,redacted:!0,index:l.index};n.content.push(p),s.push({type:"thinking_start",contentIndex:n.content.length-1,partial:n})}else if(l.content_block.type==="tool_use"){let p={type:"toolCall",id:l.content_block.id,name:c?Cn(l.content_block.name,t.tools):l.content_block.name,arguments:l.content_block.input??{},partialJson:"",index:l.index};n.content.push(p),s.push({type:"toolcall_start",contentIndex:n.content.length-1,partial:n})}}else if(l.type==="content_block_delta"){if(l.delta.type==="text_delta"){let p=_.findIndex((v)=>v.index===l.index),w=_[p];if(w&&w.type==="text")w.text+=l.delta.text,s.push({type:"text_delta",contentIndex:p,delta:l.delta.text,partial:n})}else if(l.delta.type==="thinking_delta"){let p=_.findIndex((v)=>v.index===l.index),w=_[p];if(w&&w.type==="thinking")w.thinking+=l.delta.thinking,s.push({type:"thinking_delta",contentIndex:p,delta:l.delta.thinking,partial:n})}else if(l.delta.type==="input_json_delta"){let p=_.findIndex((v)=>v.index===l.index),w=_[p];if(w&&w.type==="toolCall")w.partialJson+=l.delta.partial_json,w.arguments=Jr(w.partialJson),s.push({type:"toolcall_delta",contentIndex:p,delta:l.delta.partial_json,partial:n})}else if(l.delta.type==="signature_delta"){let p=_.findIndex((v)=>v.index===l.index),w=_[p];if(w&&w.type==="thinking")w.thinkingSignature=w.thinkingSignature||"",w.thinkingSignature+=l.delta.signature}}else if(l.type==="content_block_stop"){let p=_.findIndex((v)=>v.index===l.index),w=_[p];if(w){if(delete w.index,w.type==="text")s.push({type:"text_end",contentIndex:p,content:w.text,partial:n});else if(w.type==="thinking")s.push({type:"thinking_end",contentIndex:p,content:w.thinking,partial:n});else if(w.type==="toolCall")w.arguments=Jr(w.partialJson),delete w.partialJson,s.push({type:"toolcall_end",contentIndex:p,toolCall:w,partial:n})}}else if(l.type==="message_delta"){if(l.delta.stop_reason){let p=zn(l.delta.stop_reason,l.delta.stop_details);if(n.stopReason=p.stopReason,p.errorMessage)n.errorMessage=p.errorMessage}if(l.usage){if(l.usage.input_tokens!=null)n.usage.input=l.usage.input_tokens;if(l.usage.output_tokens!=null)n.usage.output=l.usage.output_tokens;if(l.usage.cache_read_input_tokens!=null)n.usage.cacheRead=l.usage.cache_read_input_tokens;if(l.usage.cache_creation_input_tokens!=null)n.usage.cacheWrite=l.usage.cache_creation_input_tokens;let p=l.usage.output_tokens_details?.thinking_tokens;if(p!=null)n.usage.reasoning=p}n.usage.totalTokens=n.usage.input+n.usage.output+n.usage.cacheRead+n.usage.cacheWrite,mn(e,n.usage)}if(r?.signal?.aborted)throw Error("Request was aborted");if(n.stopReason==="aborted"||n.stopReason==="error")throw Error(n.errorMessage||"An unknown error occurred");s.push({type:"done",reason:n.stopReason,message:n}),s.end()}catch(o){for(let c of n.content)delete c.index,delete c.partialJson;n.stopReason=r?.signal?.aborted?"aborted":"error",n.errorMessage=o instanceof Error?o.message:JSON.stringify(o),s.push({type:"error",reason:n.stopReason,error:n}),s.end()}})(),s};function Hn(e,t){let r=t?e.thinkingLevelMap?.[t]:void 0;if(typeof r==="string")return r;switch(t){case"minimal":case"low":return"low";case"medium":return"medium";case"high":return"high";default:return"high"}}var Gl=(e,t,r)=>{Ms(e.provider,r?.apiKey,r?.headers);let s=Tr(e,t,r,r?.apiKey);if(!r?.reasoning)return vr(e,t,{...s,thinkingEnabled:!1});if(e.compat?.forceAdaptiveThinking===!0){let c=Hn(e,r.reasoning);return vr(e,t,{...s,thinkingEnabled:!0,effort:c})}let n=gm(s.maxTokens,e.maxTokens,r.reasoning,r.thinkingBudgets),o=uf(e,t,n.maxTokens);return vr(e,t,{...s,maxTokens:o,thinkingEnabled:!0,thinkingBudgetTokens:Math.min(n.thinkingBudget,Math.max(0,o-1024))})};function Wn(e){return e.includes("sk-ant-oat")}function Dn(e,t,r,s,n,o,c){let i=r&&e.compat?.forceAdaptiveThinking!==!0,h=[];if(s)h.push(Nn);if(i)h.push(Ln);if(e.provider==="github-copilot")return{client:new j({apiKey:null,authToken:t??null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:kr({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...h.length>0?{"anthropic-beta":h.join(",")}:{}},e.headers,o,n)}),isOAuthToken:!1};if(t&&Wn(t))return{client:new j({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:kr({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","anthropic-beta":["claude-code-20250219","oauth-2025-04-20",...h].join(","),"user-agent":`claude-cli/${An}`,"x-app":"cli"},e.headers,n)}),isOAuthToken:!0};let b=c&&Dt(e).sendSessionAffinityHeaders?{"x-session-affinity":c}:{},g=kr({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...h.length>0?{"anthropic-beta":h.join(",")}:{}},b,e.headers,n);return{client:new j({apiKey:t??null,authToken:null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:g}),isOAuthToken:!1}}function Jn(e,t,r,s){let{cacheControl:n}=Tn(e,s?.cacheRetention,s?.env),o=Dt(e),c=mo(t.messages,e,Vn),i=r?Wt:(p)=>p,h=Ui({...t,messages:c},o.supportsToolReferences,i),b=h.immediate,g=[...h.deferred.values()];if(b.length===0&&g.length>0)b=g,g=[];let _=new Set(g.map((p)=>i(p.name))),l={model:e.id,messages:Kn(c,r,n,o.allowEmptySignature,_,i),max_tokens:s?.maxTokens??e.maxTokens,stream:!0};if(r){if(l.system=[{type:"text",text:"You are Claude Code, Anthropic's official CLI for Claude.",...n?{cache_control:n}:{}}],t.systemPrompt)l.system.push({type:"text",text:He(t.systemPrompt),...n?{cache_control:n}:{}})}else if(t.systemPrompt)l.system=[{type:"text",text:He(t.systemPrompt),...n?{cache_control:n}:{}}];if(s?.temperature!==void 0&&!s?.thinkingEnabled&&o.supportsTemperature)l.temperature=s.temperature;if(b.length>0||g.length>0)l.tools=[...vs(b,r,o.supportsEagerToolInputStreaming,o.supportsStrictTools,o.supportsCacheControlOnTools?n:void 0),...vs(g,r,o.supportsEagerToolInputStreaming,o.supportsStrictTools,void 0,!0)];if(e.reasoning){if(s?.thinkingEnabled){let p=s.thinkingDisplay??"summarized";if(e.compat?.forceAdaptiveThinking===!0){if(l.thinking={type:"adaptive",display:p},s.effort)l.output_config=s.effort==="xhigh"?{effort:s.effort}:{effort:s.effort}}else l.thinking={type:"enabled",budget_tokens:s.thinkingBudgetTokens||1024,display:p}}else if(s?.thinkingEnabled===!1&&e.thinkingLevelMap?.off!==null)l.thinking={type:"disabled"}}if(s?.metadata){let p=s.metadata.user_id;if(typeof p==="string")l.metadata={user_id:p}}if(s?.toolChoice)if(typeof s.toolChoice==="string")l.tool_choice={type:s.toolChoice};else l.tool_choice=s.toolChoice;return l}function Vn(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)}function Xn(e,t,r,s,n){let o=[];for(let i of e.addedToolNames??[]){let h=n(i);if(!r.has(h)||s.has(h))continue;s.add(h),o.push({type:"tool_reference",tool_name:t?Wt(i):i})}let c=On(e.content);return{toolResult:{type:"tool_result",tool_use_id:e.toolCallId,content:o.length>0?o:c,is_error:e.isError},siblingContent:o.length===0?[]:typeof c==="string"?[{type:"text",text:c}]:c}}function Kn(e,t,r,s=!1,n=new Set,o=(c)=>c){let c=[],i=new Set;for(let h=0;h<e.length;h++){let b=e[h];if(b.role==="user")if(typeof b.content==="string"){if(b.content.trim().length>0)c.push({role:"user",content:He(b.content)})}else{let _=b.content.map((l)=>{if(l.type==="text")return{type:"text",text:He(l.text)};else return{type:"image",source:{type:"base64",media_type:l.mimeType,data:l.data}}}).filter((l)=>{if(l.type==="text")return l.text.trim().length>0;return!0});if(_.length===0)continue;c.push({role:"user",content:_})}else if(b.role==="assistant"){let g=[];for(let _ of b.content)if(_.type==="text"){if(_.text.trim().length===0)continue;g.push({type:"text",text:He(_.text)})}else if(_.type==="thinking"){if(_.redacted){g.push({type:"redacted_thinking",data:_.thinkingSignature});continue}let l=_.thinkingSignature,p=!!l&&l.trim().length>0;if(_.thinking.trim().length===0&&!p)continue;if(!p)g.push(s?{type:"thinking",thinking:He(_.thinking),signature:""}:{type:"text",text:He(_.thinking)});else g.push({type:"thinking",thinking:He(_.thinking),signature:l})}else if(_.type==="toolCall")g.push({type:"tool_use",id:_.id,name:t?Wt(_.name):_.name,input:_.arguments??{}});if(g.length===0)continue;c.push({role:"assistant",content:g})}else if(b.role==="toolResult"){let g=[],_=[],l=h;while(l<e.length&&e[l].role==="toolResult"){let p=Xn(e[l],t,n,i,o);g.push(p.toolResult),_.push(...p.siblingContent),l++}h=l-1,c.push({role:"user",content:[...g,..._]})}}if(r&&c.length>0){let h=c[c.length-1];if(h.role==="user"){if(Array.isArray(h.content)){let b=h.content[h.content.length-1];if(b&&(b.type==="text"||b.type==="image"||b.type==="tool_result"))b.cache_control=r}else if(typeof h.content==="string")h.content=[{type:"text",text:h.content,cache_control:r}]}}return c}function Gn(e,t){return!!t.tools?.length&&!Dt(e).supportsEagerToolInputStreaming}function vs(e,t,r,s,n,o=!1){if(!e)return[];return e.map((c,i)=>{let h=po(c,s),b=c.parameters,g={type:"object",properties:b.properties??{},required:b.required??[]},_=h===!0?{...c.parameters,...g}:g;return{name:t?Wt(c.name):c.name,description:c.description,...r?{eager_input_streaming:!0}:{},...h===!0?{strict:!0}:{},input_schema:_,...o?{defer_loading:!0}:{},...n&&i===e.length-1?{cache_control:n}:{}}})}function zn(e,t){switch(e){case"end_turn":return{stopReason:"stop"};case"max_tokens":return{stopReason:"length"};case"tool_use":return{stopReason:"toolUse"};case"refusal":return{stopReason:"error",errorMessage:t?.explanation||"The model refused to complete the request"};case"pause_turn":return{stopReason:"stop"};case"stop_sequence":return{stopReason:"stop"};case"sensitive":return{stopReason:"error"};default:throw Error(`Unhandled stop reason: ${e}`)}}export{vr as stream,Gl as streamSimple};
45
+ `)r+=1;return{line:e.slice(0,t),rest:e.slice(r)}}async function*jn(e,t){let r=e.getReader(),s=new TextDecoder,n={event:null,data:[],raw:[]},o="";try{while(!0){if(t?.aborted)throw Error("Request was aborted");let{value:h,done:b}=await r.read();if(b)break;o+=s.decode(h,{stream:!0});let g=Ht(o);while(g){o=g.rest;let _=Rr(g.line,n);if(_)yield _;g=Ht(o)}}o+=s.decode();let c=Ht(o);while(c){o=c.rest;let h=Rr(c.line,n);if(h)yield h;c=Ht(o)}if(o.length>0){let h=Rr(o,n);if(h)yield h}let i=Ts(n);if(i)yield i}finally{r.releaseLock()}}async function*Un(e,t){if(!e.body)throw Error("Attempted to iterate over an Anthropic response with no body");let r=!1,s=!1;for await(let n of jn(e.body,t)){if(n.event==="error")throw Error(n.data);if(!qn.has(n.event??""))continue;try{let o=ff(n.data);if(o.type==="message_start")r=!0;else if(o.type==="message_stop")s=!0;yield o}catch(o){let c=o instanceof Error?o.message:String(o);throw Error(`Could not parse Anthropic SSE event ${n.event}: ${c}; data=${n.data}; raw=${n.raw.join("\\n")}`)}}if(r&&!s)throw Error("Anthropic stream ended before message_stop")}var vr=(e,t,r)=>{let s=new Jt;return(async()=>{let n={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let o,c;if(r?.client)o=r.client,c=!1;else{let l=r?.apiKey;Ms(e.provider,l,r?.headers);let p;if(e.provider==="github-copilot"){let L=zi(t.messages);p=ji({messages:t.messages,hasImages:L})}let v=Es(r?.cacheRetention,r?.env)==="none"?void 0:r?.sessionId,N=Dn(e,l,r?.interleavedThinking??!0,Gn(e,t),r?.headers,p,v);o=N.client,c=N.isOAuthToken}let i=Jn(e,t,c,r),h=await r?.onPayload?.(i,e);if(h!==void 0)i=h;let b={...r?.signal?{signal:r.signal}:{},...r?.timeoutMs!==void 0?{timeout:r.timeoutMs}:{},maxRetries:0},g=await ls(()=>o.messages.create({...i,stream:!0},b).asResponse(),{maxRetries:r?.maxRetries,maxRetryDelayMs:r?.maxRetryDelayMs,signal:r?.signal});await r?.onResponse?.({status:g.status,headers:pn(g.headers)},e),s.push({type:"start",partial:n});let _=n.content;for await(let l of Un(g,r?.signal))if(l.type==="message_start")n.responseId=l.message.id,n.usage.input=l.message.usage.input_tokens||0,n.usage.output=l.message.usage.output_tokens||0,n.usage.cacheRead=l.message.usage.cache_read_input_tokens||0,n.usage.cacheWrite=l.message.usage.cache_creation_input_tokens||0,n.usage.cacheWrite1h=l.message.usage.cache_creation?.ephemeral_1h_input_tokens||0,n.usage.totalTokens=n.usage.input+n.usage.output+n.usage.cacheRead+n.usage.cacheWrite,mn(e,n.usage);else if(l.type==="content_block_start"){if(l.content_block.type==="text"){let p={type:"text",text:"",index:l.index};n.content.push(p),s.push({type:"text_start",contentIndex:n.content.length-1,partial:n})}else if(l.content_block.type==="thinking"){let p={type:"thinking",thinking:"",thinkingSignature:"",index:l.index};n.content.push(p),s.push({type:"thinking_start",contentIndex:n.content.length-1,partial:n})}else if(l.content_block.type==="redacted_thinking"){let p={type:"thinking",thinking:"[Reasoning redacted]",thinkingSignature:l.content_block.data,redacted:!0,index:l.index};n.content.push(p),s.push({type:"thinking_start",contentIndex:n.content.length-1,partial:n})}else if(l.content_block.type==="tool_use"){let p={type:"toolCall",id:l.content_block.id,name:c?Cn(l.content_block.name,t.tools):l.content_block.name,arguments:l.content_block.input??{},partialJson:"",index:l.index};n.content.push(p),s.push({type:"toolcall_start",contentIndex:n.content.length-1,partial:n})}}else if(l.type==="content_block_delta"){if(l.delta.type==="text_delta"){let p=_.findIndex((v)=>v.index===l.index),w=_[p];if(w&&w.type==="text")w.text+=l.delta.text,s.push({type:"text_delta",contentIndex:p,delta:l.delta.text,partial:n})}else if(l.delta.type==="thinking_delta"){let p=_.findIndex((v)=>v.index===l.index),w=_[p];if(w&&w.type==="thinking")w.thinking+=l.delta.thinking,s.push({type:"thinking_delta",contentIndex:p,delta:l.delta.thinking,partial:n})}else if(l.delta.type==="input_json_delta"){let p=_.findIndex((v)=>v.index===l.index),w=_[p];if(w&&w.type==="toolCall")w.partialJson+=l.delta.partial_json,w.arguments=Jr(w.partialJson),s.push({type:"toolcall_delta",contentIndex:p,delta:l.delta.partial_json,partial:n})}else if(l.delta.type==="signature_delta"){let p=_.findIndex((v)=>v.index===l.index),w=_[p];if(w&&w.type==="thinking")w.thinkingSignature=w.thinkingSignature||"",w.thinkingSignature+=l.delta.signature}}else if(l.type==="content_block_stop"){let p=_.findIndex((v)=>v.index===l.index),w=_[p];if(w){if(delete w.index,w.type==="text")s.push({type:"text_end",contentIndex:p,content:w.text,partial:n});else if(w.type==="thinking")s.push({type:"thinking_end",contentIndex:p,content:w.thinking,partial:n});else if(w.type==="toolCall")w.arguments=Jr(w.partialJson),delete w.partialJson,s.push({type:"toolcall_end",contentIndex:p,toolCall:w,partial:n})}}else if(l.type==="message_delta"){if(l.delta.stop_reason){let p=zn(l.delta.stop_reason,l.delta.stop_details);if(n.stopReason=p.stopReason,p.errorMessage)n.errorMessage=p.errorMessage}if(l.usage){if(l.usage.input_tokens!=null)n.usage.input=l.usage.input_tokens;if(l.usage.output_tokens!=null)n.usage.output=l.usage.output_tokens;if(l.usage.cache_read_input_tokens!=null)n.usage.cacheRead=l.usage.cache_read_input_tokens;if(l.usage.cache_creation_input_tokens!=null)n.usage.cacheWrite=l.usage.cache_creation_input_tokens;let p=l.usage.output_tokens_details?.thinking_tokens;if(p!=null)n.usage.reasoning=p}n.usage.totalTokens=n.usage.input+n.usage.output+n.usage.cacheRead+n.usage.cacheWrite,mn(e,n.usage)}if(r?.signal?.aborted)throw Error("Request was aborted");if(n.stopReason==="aborted"||n.stopReason==="error")throw Error(n.errorMessage||"An unknown error occurred");s.push({type:"done",reason:n.stopReason,message:n}),s.end()}catch(o){for(let c of n.content)delete c.index,delete c.partialJson;n.stopReason=r?.signal?.aborted?"aborted":"error",n.errorMessage=o instanceof Error?o.message:JSON.stringify(o),s.push({type:"error",reason:n.stopReason,error:n}),s.end()}})(),s};function Hn(e,t){let r=t?e.thinkingLevelMap?.[t]:void 0;if(typeof r==="string")return r;switch(t){case"minimal":case"low":return"low";case"medium":return"medium";case"high":return"high";default:return"high"}}var Gl=(e,t,r)=>{Ms(e.provider,r?.apiKey,r?.headers);let s=Tr(e,t,r,r?.apiKey);if(!r?.reasoning)return vr(e,t,{...s,thinkingEnabled:!1});if(e.compat?.forceAdaptiveThinking===!0){let c=Hn(e,r.reasoning);return vr(e,t,{...s,thinkingEnabled:!0,effort:c})}let n=ym(s.maxTokens,e.maxTokens,r.reasoning,r.thinkingBudgets),o=df(e,t,n.maxTokens);return vr(e,t,{...s,maxTokens:o,thinkingEnabled:!0,thinkingBudgetTokens:Math.min(n.thinkingBudget,Math.max(0,o-1024))})};function Wn(e){return e.includes("sk-ant-oat")}function Dn(e,t,r,s,n,o,c){let i=r&&e.compat?.forceAdaptiveThinking!==!0,h=[];if(s)h.push(Nn);if(i)h.push(Ln);if(e.provider==="github-copilot")return{client:new j({apiKey:null,authToken:t??null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:kr({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...h.length>0?{"anthropic-beta":h.join(",")}:{}},e.headers,o,n)}),isOAuthToken:!1};if(t&&Wn(t))return{client:new j({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:kr({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","anthropic-beta":["claude-code-20250219","oauth-2025-04-20",...h].join(","),"user-agent":`claude-cli/${An}`,"x-app":"cli"},e.headers,n)}),isOAuthToken:!0};let b=c&&Dt(e).sendSessionAffinityHeaders?{"x-session-affinity":c}:{},g=kr({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...h.length>0?{"anthropic-beta":h.join(",")}:{}},b,e.headers,n);return{client:new j({apiKey:t??null,authToken:null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:g}),isOAuthToken:!1}}function Jn(e,t,r,s){let{cacheControl:n}=Tn(e,s?.cacheRetention,s?.env),o=Dt(e),c=mo(t.messages,e,Vn),i=r?Wt:(p)=>p,h=Ui({...t,messages:c},o.supportsToolReferences,i),b=h.immediate,g=[...h.deferred.values()];if(b.length===0&&g.length>0)b=g,g=[];let _=new Set(g.map((p)=>i(p.name))),l={model:e.id,messages:Kn(c,r,n,o.allowEmptySignature,_,i),max_tokens:s?.maxTokens??e.maxTokens,stream:!0};if(r){if(l.system=[{type:"text",text:"You are Claude Code, Anthropic's official CLI for Claude.",...n?{cache_control:n}:{}}],t.systemPrompt)l.system.push({type:"text",text:He(t.systemPrompt),...n?{cache_control:n}:{}})}else if(t.systemPrompt)l.system=[{type:"text",text:He(t.systemPrompt),...n?{cache_control:n}:{}}];if(s?.temperature!==void 0&&!s?.thinkingEnabled&&o.supportsTemperature)l.temperature=s.temperature;if(b.length>0||g.length>0)l.tools=[...vs(b,r,o.supportsEagerToolInputStreaming,o.supportsStrictTools,o.supportsCacheControlOnTools?n:void 0),...vs(g,r,o.supportsEagerToolInputStreaming,o.supportsStrictTools,void 0,!0)];if(e.reasoning){if(s?.thinkingEnabled){let p=s.thinkingDisplay??"summarized";if(e.compat?.forceAdaptiveThinking===!0){if(l.thinking={type:"adaptive",display:p},s.effort)l.output_config=s.effort==="xhigh"?{effort:s.effort}:{effort:s.effort}}else l.thinking={type:"enabled",budget_tokens:s.thinkingBudgetTokens||1024,display:p}}else if(s?.thinkingEnabled===!1&&e.thinkingLevelMap?.off!==null)l.thinking={type:"disabled"}}if(s?.metadata){let p=s.metadata.user_id;if(typeof p==="string")l.metadata={user_id:p}}if(s?.toolChoice)if(typeof s.toolChoice==="string")l.tool_choice={type:s.toolChoice};else l.tool_choice=s.toolChoice;return l}function Vn(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)}function Xn(e,t,r,s,n){let o=[];for(let i of e.addedToolNames??[]){let h=n(i);if(!r.has(h)||s.has(h))continue;s.add(h),o.push({type:"tool_reference",tool_name:t?Wt(i):i})}let c=On(e.content);return{toolResult:{type:"tool_result",tool_use_id:e.toolCallId,content:o.length>0?o:c,is_error:e.isError},siblingContent:o.length===0?[]:typeof c==="string"?[{type:"text",text:c}]:c}}function Kn(e,t,r,s=!1,n=new Set,o=(c)=>c){let c=[],i=new Set;for(let h=0;h<e.length;h++){let b=e[h];if(b.role==="user")if(typeof b.content==="string"){if(b.content.trim().length>0)c.push({role:"user",content:He(b.content)})}else{let _=b.content.map((l)=>{if(l.type==="text")return{type:"text",text:He(l.text)};else return{type:"image",source:{type:"base64",media_type:l.mimeType,data:l.data}}}).filter((l)=>{if(l.type==="text")return l.text.trim().length>0;return!0});if(_.length===0)continue;c.push({role:"user",content:_})}else if(b.role==="assistant"){let g=[];for(let _ of b.content)if(_.type==="text"){if(_.text.trim().length===0)continue;g.push({type:"text",text:He(_.text)})}else if(_.type==="thinking"){if(_.redacted){g.push({type:"redacted_thinking",data:_.thinkingSignature});continue}let l=_.thinkingSignature,p=!!l&&l.trim().length>0;if(_.thinking.trim().length===0&&!p)continue;if(!p)g.push(s?{type:"thinking",thinking:He(_.thinking),signature:""}:{type:"text",text:He(_.thinking)});else g.push({type:"thinking",thinking:He(_.thinking),signature:l})}else if(_.type==="toolCall")g.push({type:"tool_use",id:_.id,name:t?Wt(_.name):_.name,input:_.arguments??{}});if(g.length===0)continue;c.push({role:"assistant",content:g})}else if(b.role==="toolResult"){let g=[],_=[],l=h;while(l<e.length&&e[l].role==="toolResult"){let p=Xn(e[l],t,n,i,o);g.push(p.toolResult),_.push(...p.siblingContent),l++}h=l-1,c.push({role:"user",content:[...g,..._]})}}if(r&&c.length>0){let h=c[c.length-1];if(h.role==="user"){if(Array.isArray(h.content)){let b=h.content[h.content.length-1];if(b&&(b.type==="text"||b.type==="image"||b.type==="tool_result"))b.cache_control=r}else if(typeof h.content==="string")h.content=[{type:"text",text:h.content,cache_control:r}]}}return c}function Gn(e,t){return!!t.tools?.length&&!Dt(e).supportsEagerToolInputStreaming}function vs(e,t,r,s,n,o=!1){if(!e)return[];return e.map((c,i)=>{let h=po(c,s),b=c.parameters,g={type:"object",properties:b.properties??{},required:b.required??[]},_=h===!0?{...c.parameters,...g}:g;return{name:t?Wt(c.name):c.name,description:c.description,...r?{eager_input_streaming:!0}:{},...h===!0?{strict:!0}:{},input_schema:_,...o?{defer_loading:!0}:{},...n&&i===e.length-1?{cache_control:n}:{}}})}function zn(e,t){switch(e){case"end_turn":return{stopReason:"stop"};case"max_tokens":return{stopReason:"length"};case"tool_use":return{stopReason:"toolUse"};case"refusal":return{stopReason:"error",errorMessage:t?.explanation||"The model refused to complete the request"};case"pause_turn":return{stopReason:"stop"};case"stop_sequence":return{stopReason:"stop"};case"sensitive":return{stopReason:"error"};default:throw Error(`Unhandled stop reason: ${e}`)}}export{vr as stream,Gl as streamSimple};