@shumai-one/shumai 0.4.6 → 0.4.7

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 (143) hide show
  1. package/bin/{chunk-1bgsphyz.js → chunk-05tnmf8h.js} +2 -2
  2. package/bin/chunk-0xsgx9ep.js +1 -0
  3. package/bin/{chunk-3d5rm1d1.js → chunk-0ygtayqf.js} +1 -1
  4. package/bin/{chunk-crja7whq.js → chunk-11c93g1m.js} +2 -2
  5. package/bin/chunk-1ajgdv26.js +1 -0
  6. package/bin/{chunk-ba33nf0q.js → chunk-1ntn42d2.js} +3 -3
  7. package/bin/chunk-2kxhdnma.js +3 -0
  8. package/bin/chunk-30dsxm8s.js +1 -0
  9. package/bin/chunk-3b6h719s.js +3 -0
  10. package/bin/{chunk-pdh9bnyj.js → chunk-3g5pyw2e.js} +2 -2
  11. package/bin/{chunk-p75f5pgq.js → chunk-3h9c5ak3.js} +2 -2
  12. package/bin/{chunk-2qjfpmcf.js → chunk-3m5kwcj7.js} +1 -1
  13. package/bin/{chunk-w1wxzqqb.js → chunk-3p1bb08a.js} +2 -2
  14. package/bin/{chunk-6vxzkrsj.js → chunk-3r5yc5wm.js} +4 -4
  15. package/bin/{chunk-sab7tjxw.js → chunk-3tyk9xgf.js} +3 -3
  16. package/bin/{chunk-h9mka9br.js → chunk-4a88wwg2.js} +1 -1
  17. package/bin/{chunk-z08bqvkc.js → chunk-4f5pnnah.js} +14 -14
  18. package/bin/{chunk-dpc11hpd.js → chunk-4jgq9m51.js} +7 -7
  19. package/bin/{chunk-d7fwggt6.js → chunk-4m8gk79m.js} +1 -1
  20. package/bin/{chunk-b9hyc0a1.js → chunk-53vtc74g.js} +2 -2
  21. package/bin/{chunk-1kt5dzjv.js → chunk-58e1a3re.js} +2 -2
  22. package/bin/{chunk-dmvvt8va.js → chunk-5qkwpy8c.js} +2 -2
  23. package/bin/{chunk-07jszkhj.js → chunk-5rk7dyx9.js} +58 -58
  24. package/bin/{chunk-ga3pahzf.js → chunk-5v4s2kp4.js} +1 -1
  25. package/bin/{chunk-v8v8vdf7.js → chunk-5wp37g6w.js} +4 -4
  26. package/bin/{chunk-hs2r9qaw.js → chunk-628k58ek.js} +2 -2
  27. package/bin/{chunk-rp4pc6kz.js → chunk-6kdf411z.js} +1 -1
  28. package/bin/chunk-6ksrrayx.css +1 -0
  29. package/bin/chunk-6rjkbwz6.js +14 -0
  30. package/bin/{chunk-md5pcq46.js → chunk-781990k7.js} +4 -4
  31. package/bin/{chunk-ey3h4sct.js → chunk-887pj9xd.js} +2 -2
  32. package/bin/{chunk-1jybg56e.js → chunk-8b1w6bj9.js} +1 -1
  33. package/bin/{chunk-0wvhahzh.js → chunk-8gna37dd.js} +1 -1
  34. package/bin/{chunk-rmzcarv9.js → chunk-8sf106rq.js} +1 -1
  35. package/bin/{chunk-2jrjwaqr.js → chunk-8ystwvdt.js} +1 -1
  36. package/bin/{chunk-3j5njrpr.js → chunk-9v6eqa3n.js} +2 -2
  37. package/bin/{chunk-rsd164d9.js → chunk-9va1mzeq.js} +1 -1
  38. package/bin/{chunk-kmbjp5kp.js → chunk-an6nsq1t.js} +1 -1
  39. package/bin/{chunk-vzj2j11x.js → chunk-ayq8dskd.js} +1 -1
  40. package/bin/{chunk-y20sbaz5.js → chunk-b0rjvx5g.js} +1 -1
  41. package/bin/chunk-bgm76rzj.js +1 -0
  42. package/bin/chunk-btmxr226.js +1 -0
  43. package/bin/chunk-camzbwqh.js +2 -0
  44. package/bin/{chunk-t350k3s1.js → chunk-ccvjwhqq.js} +1 -1
  45. package/bin/{chunk-pgj2kjnn.js → chunk-dkzyv61a.js} +2 -2
  46. package/bin/{chunk-y56yvezn.js → chunk-dyq6h9ha.js} +1 -1
  47. package/bin/{chunk-teqprbd8.js → chunk-e17daz1x.js} +1 -1
  48. package/bin/{chunk-dbw8c1jj.js → chunk-ebf1r872.js} +4 -4
  49. package/bin/{chunk-2vzzd0q6.js → chunk-ebx3bd4c.js} +1 -1
  50. package/bin/{chunk-161rxeq2.js → chunk-ee3mrvqp.js} +1 -1
  51. package/bin/chunk-fg6zf2gb.js +2 -0
  52. package/bin/{chunk-6y4xkcte.js → chunk-fhazy8f9.js} +1 -1
  53. package/bin/{chunk-gqr5hxhj.js → chunk-fk712d68.js} +1 -1
  54. package/bin/{chunk-afnzb9ne.js → chunk-fvgb6rps.js} +2 -2
  55. package/bin/chunk-g9gmht89.js +2 -0
  56. package/bin/{chunk-1t51fp6n.js → chunk-gf4n4ahk.js} +1 -1
  57. package/bin/{chunk-gcjsw9yp.js → chunk-h3wr8nnk.js} +1 -1
  58. package/bin/chunk-htpjtarr.js +2 -0
  59. package/bin/{chunk-kg8eg9z3.js → chunk-hye75kp0.js} +2 -2
  60. package/bin/{chunk-3tg39jx7.js → chunk-j41mya13.js} +2 -2
  61. package/bin/chunk-j547gtag.js +2 -0
  62. package/bin/{chunk-a4056d0r.js → chunk-jde9r5mj.js} +1 -1
  63. package/bin/chunk-jf4kcad0.js +1 -0
  64. package/bin/{chunk-tgr86ac4.js → chunk-jt04mf5s.js} +1 -1
  65. package/bin/{chunk-hnhdq2wd.js → chunk-k3qypq3x.js} +1 -1
  66. package/bin/chunk-k5hnrtrt.js +1 -0
  67. package/bin/{chunk-mtb9fpj2.js → chunk-k810fstm.js} +1 -1
  68. package/bin/{chunk-3n4224c0.js → chunk-kg2c445x.js} +1 -1
  69. package/bin/{chunk-edqd8evk.js → chunk-kq2qbwx1.js} +1 -1
  70. package/bin/{chunk-7nvk7waw.js → chunk-m2h7a172.js} +1 -1
  71. package/bin/{chunk-brwbhbmc.js → chunk-m638fg4n.js} +5 -5
  72. package/bin/{chunk-3dgahs95.js → chunk-mm1a0zja.js} +1 -1
  73. package/bin/{chunk-hxyg5q2a.js → chunk-njabdtvb.js} +2 -2
  74. package/bin/{chunk-b6q287d1.js → chunk-njqf50vw.js} +1 -1
  75. package/bin/{chunk-47tn3vtg.js → chunk-nn5hyf6f.js} +1 -1
  76. package/bin/{chunk-t7bvde99.js → chunk-nnq8g9yy.js} +3 -3
  77. package/bin/{chunk-8cn7fx40.js → chunk-ny7qjn6s.js} +1 -1
  78. package/bin/{chunk-3d9tfxp4.js → chunk-p5fwjk5c.js} +1 -1
  79. package/bin/{chunk-s05cdax2.js → chunk-pa1fmskf.js} +1 -1
  80. package/bin/{chunk-a796sgcw.js → chunk-pcspeqwq.js} +2 -2
  81. package/bin/{chunk-yfr0hzb7.js → chunk-q1d7x1cc.js} +1 -1
  82. package/bin/{chunk-y1b3ck7m.js → chunk-q45n02fs.js} +1 -1
  83. package/bin/chunk-q6jsw0rr.js +211 -0
  84. package/bin/chunk-qjzyze00.js +1 -0
  85. package/bin/{chunk-2yr5k567.js → chunk-r55htzxr.js} +1 -1
  86. package/bin/{chunk-46wfxyd7.js → chunk-r7e2fmmx.js} +2 -2
  87. package/bin/{chunk-5kvc1gp2.js → chunk-rbagbd0e.js} +1 -1
  88. package/bin/{chunk-dz076sh7.js → chunk-rdscv38p.js} +1 -1
  89. package/bin/chunk-rfhmk32e.js +1 -0
  90. package/bin/{chunk-qs7855cz.js → chunk-rkafv27g.js} +2 -2
  91. package/bin/{chunk-hd6dnnyg.js → chunk-rkqpnyzx.js} +1 -1
  92. package/bin/{chunk-z6jpt0h6.js → chunk-s30fjvzs.js} +3 -3
  93. package/bin/{chunk-dj5a6kkh.js → chunk-s41mgkse.js} +1 -1
  94. package/bin/{chunk-988casfy.js → chunk-s63vj79f.js} +1 -1
  95. package/bin/{chunk-9d0thqcy.js → chunk-t3t7dcfq.js} +1 -1
  96. package/bin/{chunk-gsfcpcye.js → chunk-twyxs4z2.js} +1 -1
  97. package/bin/{chunk-1dqsf5qj.js → chunk-typ46eqd.js} +5 -5
  98. package/bin/chunk-v1sgrg0r.js +1 -0
  99. package/bin/{chunk-j9ks8bd7.js → chunk-vdnmq163.js} +1 -1
  100. package/bin/{chunk-jg2v25d2.js → chunk-vx66rms0.js} +2 -2
  101. package/bin/{chunk-9nvymwqj.js → chunk-wvq717b5.js} +2 -2
  102. package/bin/chunk-xbge27m4.js +1 -0
  103. package/bin/{chunk-ysv80zyb.js → chunk-xca338dw.js} +3 -3
  104. package/bin/chunk-xcsz1wp7.js +1 -0
  105. package/bin/{chunk-ehpfg3km.js → chunk-xznabrt2.js} +1 -1
  106. package/bin/{chunk-pvg3msgw.js → chunk-xzyfnfck.js} +3 -3
  107. package/bin/{chunk-9trnkbtr.js → chunk-ycw3rwhx.js} +3 -3
  108. package/bin/{chunk-qbqym9m6.js → chunk-yqvhgtez.js} +2 -2
  109. package/bin/{chunk-4syt6rn0.js → chunk-yr03tf5r.js} +2 -2
  110. package/bin/{chunk-n3xjwszr.js → chunk-z9jpgxf1.js} +1 -1
  111. package/bin/chunk-zb0az2tq.js +2 -0
  112. package/bin/{chunk-pwkby9h7.js → chunk-zbt4h7n0.js} +1 -1
  113. package/bin/{chunk-kk42xhgz.js → chunk-zcdqsp1e.js} +1 -1
  114. package/bin/chunk-zej27b5c.js +2 -0
  115. package/bin/{chunk-axmd242s.js → chunk-zmjtv19e.js} +1 -1
  116. package/bin/{chunk-7e5z637e.js → chunk-zr11zfwc.js} +1 -1
  117. package/bin/{chunk-k6avge95.js → chunk-zz0522zr.js} +4 -4
  118. package/bin/shumai-app.html +1 -1
  119. package/bin/shumai-app.js +294 -293
  120. package/package.json +7 -7
  121. package/bin/chunk-0c67210c.js +0 -1
  122. package/bin/chunk-2z1pnt7h.js +0 -2
  123. package/bin/chunk-3vmapyk9.js +0 -1
  124. package/bin/chunk-886pnknh.js +0 -3
  125. package/bin/chunk-908pypkr.js +0 -1
  126. package/bin/chunk-952qwf17.js +0 -2
  127. package/bin/chunk-9a2tf0mh.js +0 -2
  128. package/bin/chunk-apfrw0wd.js +0 -3
  129. package/bin/chunk-batadmvr.js +0 -2
  130. package/bin/chunk-bvdvp192.js +0 -1
  131. package/bin/chunk-db1msmdh.js +0 -2
  132. package/bin/chunk-dkx3pmdz.js +0 -1
  133. package/bin/chunk-hacyjx1s.js +0 -1
  134. package/bin/chunk-he5nvmqw.js +0 -1
  135. package/bin/chunk-hyr1vtfp.js +0 -1
  136. package/bin/chunk-jh8q3885.js +0 -211
  137. package/bin/chunk-jzbrt2vk.js +0 -1
  138. package/bin/chunk-nqym3zbs.js +0 -1
  139. package/bin/chunk-sebbjvgv.css +0 -1
  140. package/bin/chunk-t8gv2ekj.js +0 -14
  141. package/bin/chunk-vm5tn0zm.js +0 -2
  142. package/bin/chunk-wmjp8dcm.js +0 -1
  143. package/bin/chunk-wy8dkyxj.js +0 -1
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- function qe(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"")}function sc(e,n,t){let r=n[t];if(typeof r!=="string")throw Error(`Grammar tool call "${e}" requires argument "${t}" to be a string.`);return r}function ac(e,n,t,r){if(e.closed){if(r&&t===e.input)return;throw Error(`grammar tool input for property "${n}" changed after it was closed`)}if(!t.startsWith(e.input))throw Error(`grammar tool input for property "${n}" changed non-monotonically`);let o=t.slice(e.input.length);if(!r&&o.length===0)return;let i="";if(!e.started)i+=`{${JSON.stringify(n)}:"`,e.started=!0;if(i+=JSON.stringify(o).slice(1,-1),e.input=t,r)i+='"}',e.closed=!0;return i}function C(e){let n=e.parameters;if(n.type!=="object")throw Error("grammar constrained sampling requires an object parameter schema");if(!Array.isArray(n.required)||n.required.length!==1||typeof n.required[0]!=="string")throw Error("grammar constrained sampling requires exactly one required string property");let t=n.required[0];if(!n.properties?.[t])throw Error(`grammar constrained sampling requires a properties entry for ${t}`);if(n.properties[t]?.type!=="string")throw Error(`grammar constrained sampling property ${t} must have type string`);return t}function uo(e,n){let t=e.constrainedSampling;if(!t||t.type!=="json_schema")return;if(n)return!0;if(t.strict==="require")throw Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`);return}function Vi(e,n){let t=e.constrainedSampling;if(!t||t.type!=="grammar")return;if(!n)return;let r=t.variants.openai_lark,o=t.variants.openai_regex,i=typeof r==="string"&&r.trim().length>0,d=typeof o==="string"&&o.trim().length>0;if(!i&&!d)throw Error(`Tool "${e.name}" cannot use grammar constrained sampling: no supported grammar variant was provided.`);try{return{format:i?"lark":"regex",definition:i?r:o,inputProperty:C(e)}}catch(l){let c=l instanceof Error?l.message:String(l);throw Error(`Tool "${e.name}" cannot use grammar constrained sampling: ${c}.`)}}function Qn(e,n){let t=new Map;for(let r of e??[]){let o=Vi(r,n);if(o)t.set(r.name,o.inputProperty)}return t}function R(e){return e.totalTokens||e.input+e.output+e.cacheRead+e.cacheWrite}function S(e){try{return JSON.stringify(e)??"undefined"}catch{return"[unserializable]"}}function N(e){if(typeof e==="string")return e.length;let n=0;for(let t of e)n+=t.type==="text"?t.text.length:4800;return n}function k(e){return Math.ceil(e.length/4)}function y(e){return Math.ceil(N(e)/4)}function I(e){let n=0;if(e.role==="user")return y(e.content);if(e.role==="toolResult")return y(e.content);for(let t of e.content)if(t.type==="text")n+=t.text.length;else if(t.type==="thinking")n+=t.thinking.length;else n+=t.name.length+S(t.arguments).length;return Math.ceil(n/4)}function O(e){let n=Number.NEGATIVE_INFINITY,t;for(let r=0;r<e.length;r++){let o=e[r];if(o.role==="assistant"){let i=o;if(i.timestamp>=n&&i.stopReason!=="aborted"&&i.stopReason!=="error"&&R(i.usage)>0)t={usage:i.usage,index:r}}n=Math.max(n,o.timestamp)}return t}function E(e){let n=O(e);if(n){let r=R(n.usage),o=0;for(let i=n.index+1;i<e.length;i++)o+=I(e[i]);return{tokens:r+o,usageTokens:r,trailingTokens:o,lastUsageIndex:n.index}}let t=0;for(let r of e)t+=I(r);return{tokens:t,usageTokens:0,trailingTokens:t,lastUsageIndex:null}}function M(e){if(!e||e.length===0)return 0;return k(S(e))}function D(e){return Array.isArray(e)}function w(e){if(D(e))return E(e);let n=E(e.messages);if(n.lastUsageIndex!==null){let r=new Set(e.messages.slice(n.lastUsageIndex+1).filter((i)=>i.role==="toolResult").flatMap((i)=>i.addedToolNames??[])),o=M(e.tools?.filter((i)=>r.has(i.name)));return{tokens:n.tokens+o,usageTokens:n.usageTokens,trailingTokens:n.trailingTokens+o,lastUsageIndex:n.lastUsageIndex}}let t=(e.systemPrompt?k(e.systemPrompt):0)+M(e.tools);return{tokens:n.tokens+t,usageTokens:n.usageTokens,trailingTokens:n.trailingTokens+t,lastUsageIndex:n.lastUsageIndex}}var P=4096,_=1;function Jd(e,n,t){if(e.contextWindow<=0)return Math.max(_,t);let r=e.contextWindow-w(n).tokens-P;return Math.min(t,Math.max(_,r))}function Cr(e,n,t,r){return{temperature:t?.temperature,maxTokens:Jd(e,n,t?.maxTokens??e.maxTokens),signal:t?.signal,apiKey:r||t?.apiKey,transport:t?.transport,cacheRetention:t?.cacheRetention,sessionId:t?.sessionId,headers:t?.headers,onPayload:t?.onPayload,onResponse:t?.onResponse,timeoutMs:t?.timeoutMs,websocketConnectTimeoutMs:t?.websocketConnectTimeoutMs,maxRetries:t?.maxRetries,maxRetryDelayMs:t?.maxRetryDelayMs,metadata:t?.metadata,env:t?.env}}function v(e){return e==="xhigh"||e==="max"?"high":e}function sm(e,n,t,r){let i={...{minimal:1024,low:2048,medium:8192,high:16384},...r},d=1024,l=v(t),c=i[l],f=e===void 0?n:Math.min(e+c,n);if(f<=c)c=Math.max(0,f-1024);return{maxTokens:f,thinkingBudget:c}}function A(e,n){let t=[],r=!1;for(let o of e){if(o.type==="image"){if(!r)t.push({type:"text",text:n});r=!0;continue}t.push(o),r=o.text===n}return t}function F(e,n){if(n.input.includes("image"))return e;return e.map((t)=>{if(t.role==="user"&&Array.isArray(t.content))return{...t,content:A(t.content,"(image omitted: model does not support images)")};if(t.role==="toolResult")return{...t,content:A(t.content,"(tool image omitted: model does not support images)")};return t})}function fo(e,n,t){let r=new Map,o=e.map((a)=>a.content==null?{...a,content:[]}:a),d=F(o,n).map((a)=>{if(a.role==="user")return a;if(a.role==="toolResult"){let s=r.get(a.toolCallId);if(s&&s!==a.toolCallId)return{...a,toolCallId:s};return a}if(a.role==="assistant"){let s=a,p=s.provider===n.provider&&s.api===n.api&&s.model===n.id,h=s.content.flatMap((u)=>{if(u.type==="thinking"){if(u.redacted)return p?u:[];if(p&&u.thinkingSignature)return u;if(!u.thinking||u.thinking.trim()==="")return[];if(p)return u;return{type:"text",text:u.thinking}}if(u.type==="text"){if(p)return u;return{type:"text",text:u.text}}if(u.type==="toolCall"){let m=u,g=m;if(!p&&m.thoughtSignature)g={...m},delete g.thoughtSignature;if(!p&&t){let x=t(m.id,n,s);if(x!==m.id)r.set(m.id,x),g={...g,id:x}}return g}return u});return{...s,content:h}}return a}),l=[],c=[],f=new Set,T=()=>{if(c.length>0){for(let a of c)if(!f.has(a.id))l.push({role:"toolResult",toolCallId:a.id,toolName:a.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});c=[],f=new Set}};for(let a=0;a<d.length;a++){let s=d[a];if(s.role==="assistant"){T();let p=s;if(p.stopReason==="error"||p.stopReason==="aborted")continue;let h=p.content.filter((u)=>u.type==="toolCall");if(h.length>0)c=h,f=new Set;l.push(s)}else if(s.role==="toolResult")f.add(s.toolCallId),l.push(s);else if(s.role==="user")T(),l.push(s);else l.push(s)}return T(),l}
3
- export{qe,sc,ac,uo,Vi,Qn,Jd,Cr,sm,fo};
2
+ function qe(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"")}function sc(e,n,t){let r=n[t];if(typeof r!=="string")throw Error(`Grammar tool call "${e}" requires argument "${t}" to be a string.`);return r}function ac(e,n,t,r){if(e.closed){if(r&&t===e.input)return;throw Error(`grammar tool input for property "${n}" changed after it was closed`)}if(!t.startsWith(e.input))throw Error(`grammar tool input for property "${n}" changed non-monotonically`);let o=t.slice(e.input.length);if(!r&&o.length===0)return;let i="";if(!e.started)i+=`{${JSON.stringify(n)}:"`,e.started=!0;if(i+=JSON.stringify(o).slice(1,-1),e.input=t,r)i+='"}',e.closed=!0;return i}function C(e){let n=e.parameters;if(n.type!=="object")throw Error("grammar constrained sampling requires an object parameter schema");if(!Array.isArray(n.required)||n.required.length!==1||typeof n.required[0]!=="string")throw Error("grammar constrained sampling requires exactly one required string property");let t=n.required[0];if(!n.properties?.[t])throw Error(`grammar constrained sampling requires a properties entry for ${t}`);if(n.properties[t]?.type!=="string")throw Error(`grammar constrained sampling property ${t} must have type string`);return t}function uo(e,n){let t=e.constrainedSampling;if(!t||t.type!=="json_schema")return;if(n)return!0;if(t.strict==="require")throw Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`);return}function Vi(e,n){let t=e.constrainedSampling;if(!t||t.type!=="grammar")return;if(!n)return;let r=t.variants.openai_lark,o=t.variants.openai_regex,i=typeof r==="string"&&r.trim().length>0,d=typeof o==="string"&&o.trim().length>0;if(!i&&!d)throw Error(`Tool "${e.name}" cannot use grammar constrained sampling: no supported grammar variant was provided.`);try{return{format:i?"lark":"regex",definition:i?r:o,inputProperty:C(e)}}catch(l){let c=l instanceof Error?l.message:String(l);throw Error(`Tool "${e.name}" cannot use grammar constrained sampling: ${c}.`)}}function Qn(e,n){let t=new Map;for(let r of e??[]){let o=Vi(r,n);if(o)t.set(r.name,o.inputProperty)}return t}function R(e){return e.totalTokens||e.input+e.output+e.cacheRead+e.cacheWrite}function S(e){try{return JSON.stringify(e)??"undefined"}catch{return"[unserializable]"}}function N(e){if(typeof e==="string")return e.length;let n=0;for(let t of e)n+=t.type==="text"?t.text.length:4800;return n}function k(e){return Math.ceil(e.length/4)}function y(e){return Math.ceil(N(e)/4)}function I(e){let n=0;if(e.role==="user")return y(e.content);if(e.role==="toolResult")return y(e.content);for(let t of e.content)if(t.type==="text")n+=t.text.length;else if(t.type==="thinking")n+=t.thinking.length;else n+=t.name.length+S(t.arguments).length;return Math.ceil(n/4)}function O(e){let n=Number.NEGATIVE_INFINITY,t;for(let r=0;r<e.length;r++){let o=e[r];if(o.role==="assistant"){let i=o;if(i.timestamp>=n&&i.stopReason!=="aborted"&&i.stopReason!=="error"&&R(i.usage)>0)t={usage:i.usage,index:r}}n=Math.max(n,o.timestamp)}return t}function E(e){let n=O(e);if(n){let r=R(n.usage),o=0;for(let i=n.index+1;i<e.length;i++)o+=I(e[i]);return{tokens:r+o,usageTokens:r,trailingTokens:o,lastUsageIndex:n.index}}let t=0;for(let r of e)t+=I(r);return{tokens:t,usageTokens:0,trailingTokens:t,lastUsageIndex:null}}function M(e){if(!e||e.length===0)return 0;return k(S(e))}function D(e){return Array.isArray(e)}function w(e){if(D(e))return E(e);let n=E(e.messages);if(n.lastUsageIndex!==null){let r=new Set(e.messages.slice(n.lastUsageIndex+1).filter((i)=>i.role==="toolResult").flatMap((i)=>i.addedToolNames??[])),o=M(e.tools?.filter((i)=>r.has(i.name)));return{tokens:n.tokens+o,usageTokens:n.usageTokens,trailingTokens:n.trailingTokens+o,lastUsageIndex:n.lastUsageIndex}}let t=(e.systemPrompt?k(e.systemPrompt):0)+M(e.tools);return{tokens:n.tokens+t,usageTokens:n.usageTokens,trailingTokens:n.trailingTokens+t,lastUsageIndex:n.lastUsageIndex}}var P=4096,_=1;function ef(e,n,t){if(e.contextWindow<=0)return Math.max(_,t);let r=e.contextWindow-w(n).tokens-P;return Math.min(t,Math.max(_,r))}function Cr(e,n,t,r){return{temperature:t?.temperature,maxTokens:ef(e,n,t?.maxTokens??e.maxTokens),signal:t?.signal,apiKey:r||t?.apiKey,transport:t?.transport,cacheRetention:t?.cacheRetention,sessionId:t?.sessionId,headers:t?.headers,onPayload:t?.onPayload,onResponse:t?.onResponse,timeoutMs:t?.timeoutMs,websocketConnectTimeoutMs:t?.websocketConnectTimeoutMs,maxRetries:t?.maxRetries,maxRetryDelayMs:t?.maxRetryDelayMs,metadata:t?.metadata,env:t?.env}}function v(e){return e==="xhigh"||e==="max"?"high":e}function am(e,n,t,r){let i={...{minimal:1024,low:2048,medium:8192,high:16384},...r},d=1024,l=v(t),c=i[l],f=e===void 0?n:Math.min(e+c,n);if(f<=c)c=Math.max(0,f-1024);return{maxTokens:f,thinkingBudget:c}}function A(e,n){let t=[],r=!1;for(let o of e){if(o.type==="image"){if(!r)t.push({type:"text",text:n});r=!0;continue}t.push(o),r=o.text===n}return t}function F(e,n){if(n.input.includes("image"))return e;return e.map((t)=>{if(t.role==="user"&&Array.isArray(t.content))return{...t,content:A(t.content,"(image omitted: model does not support images)")};if(t.role==="toolResult")return{...t,content:A(t.content,"(tool image omitted: model does not support images)")};return t})}function fo(e,n,t){let r=new Map,o=e.map((a)=>a.content==null?{...a,content:[]}:a),d=F(o,n).map((a)=>{if(a.role==="user")return a;if(a.role==="toolResult"){let s=r.get(a.toolCallId);if(s&&s!==a.toolCallId)return{...a,toolCallId:s};return a}if(a.role==="assistant"){let s=a,p=s.provider===n.provider&&s.api===n.api&&s.model===n.id,h=s.content.flatMap((u)=>{if(u.type==="thinking"){if(u.redacted)return p?u:[];if(p&&u.thinkingSignature)return u;if(!u.thinking||u.thinking.trim()==="")return[];if(p)return u;return{type:"text",text:u.thinking}}if(u.type==="text"){if(p)return u;return{type:"text",text:u.text}}if(u.type==="toolCall"){let m=u,g=m;if(!p&&m.thoughtSignature)g={...m},delete g.thoughtSignature;if(!p&&t){let x=t(m.id,n,s);if(x!==m.id)r.set(m.id,x),g={...g,id:x}}return g}return u});return{...s,content:h}}return a}),l=[],c=[],f=new Set,T=()=>{if(c.length>0){for(let a of c)if(!f.has(a.id))l.push({role:"toolResult",toolCallId:a.id,toolName:a.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});c=[],f=new Set}};for(let a=0;a<d.length;a++){let s=d[a];if(s.role==="assistant"){T();let p=s;if(p.stopReason==="error"||p.stopReason==="aborted")continue;let h=p.content.filter((u)=>u.type==="toolCall");if(h.length>0)c=h,f=new Set;l.push(s)}else if(s.role==="toolResult")f.add(s.toolCallId),l.push(s);else if(s.role==="user")T(),l.push(s);else l.push(s)}return T(),l}
3
+ export{qe,sc,ac,uo,Vi,Qn,ef,Cr,am,fo};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{G}from"./chunk-qbqym9m6.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 lr(e,t){return t?.[e]||(typeof process<"u"?process.env[e]:void 0)||c(e)||void 0}
3
- export{lr};
2
+ import{G}from"./chunk-yqvhgtez.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 cr(e,t){return t?.[e]||(typeof process<"u"?process.env[e]:void 0)||c(e)||void 0}
3
+ export{cr};
@@ -1,2 +1,2 @@
1
- import{I}from"./chunk-jh8q3885.js";var o=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],Ol=I("arrow-up-narrow-wide",o);
1
+ import{I}from"./chunk-q6jsw0rr.js";var o=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],Ol=I("arrow-up-narrow-wide",o);
2
2
  export{Ol};
@@ -1,2 +1,2 @@
1
- import{at,O,P,dt,D,b,S,t,C,us,pt,Y,Ft,se,Hn,da,fl,pl}from"./chunk-jh8q3885.js";S();S();var M=Object.defineProperty,k=(s,e)=>M(s,"name",{value:e,configurable:!0}),F="Toggle",T=O(k(function(e,o){let{pressed:r,defaultPressed:n,onPressedChange:a,...g}=e,[l,i]=Ft({prop:r,onChange:a,defaultProp:n??!1,caller:F});return t(se.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":e.disabled?"":void 0,...g,ref:o,onClick:Y(e.onClick,()=>{if(!e.disabled)i(!l)})})},"Toggle"));S();var A=Object.defineProperty,p=(s,e)=>A(s,"name",{value:e,configurable:!0}),m="ToggleGroup",[h,ie]=pt(m,[da]),x=da(),E=O(p(function(e,o){let{type:r,...n}=e;if(r==="single")return t(N,{role:"radiogroup",...n,ref:o});if(r==="multiple")return t(j,{role:"toolbar",...n,ref:o});throw Error(`Missing prop \`type\` expected on \`${m}\``)},"ToggleGroup")),[I,_]=h(m),N=O(p(function(e,o){let{value:r,defaultValue:n,onValueChange:a=p(()=>{},"onValueChange"),...g}=e,[l,i]=Ft({prop:r,defaultProp:n??"",onChange:a,caller:m});return t(I,{scope:e.__scopeToggleGroup,type:"single",value:D(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:P(()=>i(""),[i]),children:t(V,{...g,ref:o})})},"ToggleGroupImplSingle")),j=O(p(function(e,o){let{value:r,defaultValue:n,onValueChange:a=p(()=>{},"onValueChange"),...g}=e,[l,i]=Ft({prop:r,defaultProp:n??[],onChange:a,caller:m}),u=P((c)=>i((d=[])=>[...d,c]),[i]),f=P((c)=>i((d=[])=>d.filter((z)=>z!==c)),[i]);return t(I,{scope:e.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:u,onItemDeactivate:f,children:t(V,{...g,ref:o})})},"ToggleGroupImplMultiple")),[B,H]=h(m),V=O(p(function(e,o){let{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:g,dir:l,loop:i=!0,...u}=e,f=x(r),c=Hn(l),d={dir:c,...u};return t(B,{scope:r,rovingFocus:a,disabled:n,children:a?t(fl,{asChild:!0,...f,orientation:g,dir:c,loop:i,children:t(se.div,{...d,ref:o})}):t(se.div,{...d,ref:o})})},"ToggleGroupImpl")),v="ToggleGroupItem",L=O(p(function(e,o){let r=_(v,e.__scopeToggleGroup),n=H(v,e.__scopeToggleGroup),a=x(e.__scopeToggleGroup),g=r.value.includes(e.value),l=n.disabled||e.disabled,i={...e,pressed:g,disabled:l},u=b(null);return n.rovingFocus?t(pl,{asChild:!0,...a,focusable:!l,active:g,ref:u,children:t(R,{...i,ref:o})}):t(R,{...i,ref:o})},"ToggleGroupItem")),R=O(p(function(e,o){let{__scopeToggleGroup:r,value:n,...a}=e,g=_(v,r),l={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},i=g.type==="single"?l:void 0;return t(T,{...i,...a,ref:o,onPressedChange:(u)=>{if(u)g.onItemActivate(n);else g.onItemDeactivate(n)}})},"ToggleGroupItemImpl"));var y=us("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 min-w-9 px-2",sm:"h-8 min-w-8 px-1.5",lg:"h-10 min-w-10 px-2.5"}},defaultVariants:{variant:"default",size:"default"}});var w=at({size:"default",variant:"default",spacing:0});function To({className:s,variant:e,size:o,spacing:r=0,children:n,...a}){return t(E,{"data-slot":"toggle-group","data-variant":e,"data-size":o,"data-spacing":r,style:{"--gap":r},className:C("group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs",s),...a,children:t(w.Provider,{value:{variant:e,size:o,spacing:r},children:n})})}function gr({className:s,children:e,variant:o,size:r,...n}){let a=dt(w);return t(L,{"data-slot":"toggle-group-item","data-variant":a.variant||o,"data-size":a.size||r,"data-spacing":a.spacing,className:C(y({variant:a.variant||o,size:a.size||r}),"w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10","data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l",s),...n,children:e})}
2
- export{To,gr};
1
+ import{at,O,P,dt,D,b,S,t,C,ds,pt,Y,Ft,se,Hn,fa,fl,pl}from"./chunk-q6jsw0rr.js";S();S();var M=Object.defineProperty,k=(s,e)=>M(s,"name",{value:e,configurable:!0}),F="Toggle",T=O(k(function(e,o){let{pressed:r,defaultPressed:n,onPressedChange:a,...g}=e,[l,i]=Ft({prop:r,onChange:a,defaultProp:n??!1,caller:F});return t(se.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":e.disabled?"":void 0,...g,ref:o,onClick:Y(e.onClick,()=>{if(!e.disabled)i(!l)})})},"Toggle"));S();var A=Object.defineProperty,p=(s,e)=>A(s,"name",{value:e,configurable:!0}),m="ToggleGroup",[h,ie]=pt(m,[fa]),x=fa(),E=O(p(function(e,o){let{type:r,...n}=e;if(r==="single")return t(N,{role:"radiogroup",...n,ref:o});if(r==="multiple")return t(j,{role:"toolbar",...n,ref:o});throw Error(`Missing prop \`type\` expected on \`${m}\``)},"ToggleGroup")),[I,_]=h(m),N=O(p(function(e,o){let{value:r,defaultValue:n,onValueChange:a=p(()=>{},"onValueChange"),...g}=e,[l,i]=Ft({prop:r,defaultProp:n??"",onChange:a,caller:m});return t(I,{scope:e.__scopeToggleGroup,type:"single",value:D(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:P(()=>i(""),[i]),children:t(V,{...g,ref:o})})},"ToggleGroupImplSingle")),j=O(p(function(e,o){let{value:r,defaultValue:n,onValueChange:a=p(()=>{},"onValueChange"),...g}=e,[l,i]=Ft({prop:r,defaultProp:n??[],onChange:a,caller:m}),u=P((c)=>i((d=[])=>[...d,c]),[i]),f=P((c)=>i((d=[])=>d.filter((z)=>z!==c)),[i]);return t(I,{scope:e.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:u,onItemDeactivate:f,children:t(V,{...g,ref:o})})},"ToggleGroupImplMultiple")),[B,H]=h(m),V=O(p(function(e,o){let{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:g,dir:l,loop:i=!0,...u}=e,f=x(r),c=Hn(l),d={dir:c,...u};return t(B,{scope:r,rovingFocus:a,disabled:n,children:a?t(fl,{asChild:!0,...f,orientation:g,dir:c,loop:i,children:t(se.div,{...d,ref:o})}):t(se.div,{...d,ref:o})})},"ToggleGroupImpl")),v="ToggleGroupItem",L=O(p(function(e,o){let r=_(v,e.__scopeToggleGroup),n=H(v,e.__scopeToggleGroup),a=x(e.__scopeToggleGroup),g=r.value.includes(e.value),l=n.disabled||e.disabled,i={...e,pressed:g,disabled:l},u=b(null);return n.rovingFocus?t(pl,{asChild:!0,...a,focusable:!l,active:g,ref:u,children:t(R,{...i,ref:o})}):t(R,{...i,ref:o})},"ToggleGroupItem")),R=O(p(function(e,o){let{__scopeToggleGroup:r,value:n,...a}=e,g=_(v,r),l={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},i=g.type==="single"?l:void 0;return t(T,{...i,...a,ref:o,onPressedChange:(u)=>{if(u)g.onItemActivate(n);else g.onItemDeactivate(n)}})},"ToggleGroupItemImpl"));var y=ds("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 min-w-9 px-2",sm:"h-8 min-w-8 px-1.5",lg:"h-10 min-w-10 px-2.5"}},defaultVariants:{variant:"default",size:"default"}});var w=at({size:"default",variant:"default",spacing:0});function To({className:s,variant:e,size:o,spacing:r=0,children:n,...a}){return t(E,{"data-slot":"toggle-group","data-variant":e,"data-size":o,"data-spacing":r,style:{"--gap":r},className:C("group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs",s),...a,children:t(w.Provider,{value:{variant:e,size:o,spacing:r},children:n})})}function Ar({className:s,children:e,variant:o,size:r,...n}){let a=dt(w);return t(L,{"data-slot":"toggle-group-item","data-variant":a.variant||o,"data-size":a.size||r,"data-spacing":a.spacing,className:C(y({variant:a.variant||o,size:a.size||r}),"w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10","data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l",s),...n,children:e})}
2
+ export{To,Ar};
@@ -1,10 +1,10 @@
1
1
  // @bun
2
- import{z,w,G}from"./chunk-qbqym9m6.js";var es=w(function(Xp,Zn){function Ee(e,t){if(typeof t==="boolean")t={forever:t};if(this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Zn.exports=Ee;Ee.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};Ee.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);if(this._timer)clearTimeout(this._timer);this._timeouts=[],this._cachedTimeouts=null};Ee.prototype.retry=function(e){if(this._timeout)clearTimeout(this._timeout);if(!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var n=this;if(this._timer=setTimeout(function(){if(n._attempts++,n._operationTimeoutCb){if(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref)n._timeout.unref()}n._fn(n._attempts)},r),this._options.unref)this._timer.unref();return!0};Ee.prototype.attempt=function(e,t){if(this._fn=e,t){if(t.timeout)this._operationTimeout=t.timeout;if(t.cb)this._operationTimeoutCb=t.cb}var r=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};Ee.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};Ee.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};Ee.prototype.start=Ee.prototype.try;Ee.prototype.errors=function(){return this._errors};Ee.prototype.attempts=function(){return this._attempts};Ee.prototype.mainError=function(){if(this._errors.length===0)return null;var e={},t=null,r=0;for(var n=0;n<this._errors.length;n++){var s=this._errors[n],i=s.message,u=(e[i]||0)+1;if(e[i]=u,u>=r)t=s,r=u}return t}});var rs=w(function(mr){var lu=es();mr.operation=function(e){var t=mr.timeouts(e);return new lu(t,{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};mr.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var n=[];for(var s=0;s<t.retries;s++)n.push(this.createTimeout(s,t));if(e&&e.forever&&!n.length)n.push(this.createTimeout(s,t));return n.sort(function(i,u){return i-u}),n};mr.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout),n};mr.wrap=function(e,t,r){if(t instanceof Array)r=t,t=null;if(!r){r=[];for(var n in e)if(typeof e[n]==="function")r.push(n)}for(var s=0;s<r.length;s++){var i=r[s],u=e[i];e[i]=function(y){var S=mr.operation(t),A=Array.prototype.slice.call(arguments,1),k=A.pop();A.push(function(N){if(S.retry(N))return;if(N)arguments[0]=S.mainError();k.apply(this,arguments)}),S.attempt(function(){y.apply(e,A)})}.bind(e,u),e[i].options=t}}});var yu=w(function(Zp,Pt){var pu=rs(),gu=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class Er extends Error{constructor(e){super();if(e instanceof Error)this.originalError=e,{message:e}=e;else this.originalError=Error(e),this.originalError.stack=this.stack;this.name="AbortError",this.message=e}}var _u=(e,t,r)=>{let n=r.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=n,e},mu=(e)=>gu.includes(e),ns=(e,t)=>new Promise((r,n)=>{t={onFailedAttempt:()=>{},retries:10,...t};let s=pu.operation(t);s.attempt(async(i)=>{try{r(await e(i))}catch(u){if(!(u instanceof Error)){n(TypeError(`Non-error was thrown: "${u}". You should only throw errors.`));return}if(u instanceof Er)s.stop(),n(u.originalError);else if(u instanceof TypeError&&!mu(u.message))s.stop(),n(u);else{_u(u,i,t);try{await t.onFailedAttempt(u)}catch(h){n(h);return}if(!s.retry(u))n(s.mainError())}}})});Pt.exports=ns;Pt.exports.default=ns;Pt.exports.AbortError=Er});var wr=w(function(eg,hs){var It=Object.prototype.hasOwnProperty,ls=Object.prototype.toString,{defineProperty:ss,getOwnPropertyDescriptor:is}=Object,os=function(t){if(typeof Array.isArray==="function")return Array.isArray(t);return ls.call(t)==="[object Array]"},as=function(t){if(!t||ls.call(t)!=="[object Object]")return!1;var r=It.call(t,"constructor"),n=t.constructor&&t.constructor.prototype&&It.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!n)return!1;var s;for(s in t);return typeof s>"u"||It.call(t,s)},cs=function(t,r){if(ss&&r.name==="__proto__")ss(t,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0});else t[r.name]=r.newValue},us=function(t,r){if(r==="__proto__"){if(!It.call(t,r))return;else if(is)return is(t,r).value}return t[r]};hs.exports=function e(){var t,r,n,s,i,u,h=arguments[0],y=1,S=arguments.length,A=!1;if(typeof h==="boolean")A=h,h=arguments[1]||{},y=2;if(h==null||typeof h!=="object"&&typeof h!=="function")h={};for(;y<S;++y)if(t=arguments[y],t!=null){for(r in t)if(n=us(h,r),s=us(t,r),h!==s){if(A&&s&&(as(s)||(i=os(s)))){if(i)i=!1,u=n&&os(n)?n:[];else u=n&&as(n)?n:{};cs(h,{name:r,newValue:e(A,u,s)})}else if(typeof s<"u")cs(h,{name:r,newValue:s})}}return h}});var fs=w(function(tg,Eu){Eu.exports={name:"gaxios",version:"7.3.1",description:"A simple common HTTP client specifically for Google APIs and services.",main:"build/cjs/src/index.js",types:"build/cjs/src/index.d.ts",files:["build/"],exports:{".":{import:{types:"./build/esm/src/index.d.ts",default:"./build/esm/src/index.js"},require:{types:"./build/cjs/src/index.d.ts",default:"./build/cjs/src/index.js"}}},scripts:{lint:"gts check --no-inline-config",test:"c8 mocha build/esm/test","presystem-test":"npm run compile","system-test":"mocha build/esm/system-test --timeout 80000",compile:"tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs",fix:"gts fix",prepare:"npm run compile",pretest:"npm run compile",webpack:"webpack","prebrowser-test":"npm run compile","browser-test":"node build/browser-test/browser-test-runner.js",docs:"jsdoc -c .jsdoc.js","samples-test":"cd samples/ && npm link ../ && npm test && cd ../",prelint:"cd samples; npm link ../; npm install",clean:"gts clean"},repository:{type:"git",directory:"core/packages/gaxios",url:"https://github.com/googleapis/google-cloud-node.git"},keywords:["google"],engines:{node:">=18"},author:"Google, LLC",license:"Apache-2.0",devDependencies:{"@babel/plugin-proposal-private-methods":"^7.18.6","@types/cors":"^2.8.6","@types/express":"^5.0.0","@types/extend":"^3.0.1","@types/mocha":"^10.0.10","@types/multiparty":"4.2.1","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","@types/tmp":"^0.2.6",assert:"^2.0.0",browserify:"^17.0.0",c8:"^10.1.3",cors:"^2.8.5",express:"^5.0.0",gts:"^6.0.2","is-docker":"^3.0.0",jsdoc:"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0",karma:"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-remap-coverage":"^0.1.5","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.0",mocha:"^11.1.0",multiparty:"^4.2.1",mv:"^2.1.1",ncp:"^2.0.0",nock:"14.0.5","null-loader":"^4.0.1","pack-n-play":"^4.0.0",puppeteer:"^24.0.0",sinon:"21.0.3","stream-browserify":"^3.0.0",tmp:"0.2.7","ts-loader":"^9.5.2",typescript:"5.8.3","undici-types":"^7.24.1",webpack:"^5.97.1","webpack-cli":"^6.0.1"},dependencies:{extend:"^3.0.2","https-proxy-agent":"^7.0.1","node-fetch":"^3.3.2"},homepage:"https://github.com/googleapis/google-cloud-node/tree/main/core/packages/gaxios"}});var ps=w(function(rg,ds){var wu=fs();ds.exports={pkg:wu}});var vr=w(function(we){var _s=we&&we.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(we,"__esModule",{value:!0});we.GaxiosError=we.GAXIOS_ERROR_SYMBOL=void 0;we.defaultErrorRedactor=ys;var gs=_s(wr()),Tu=_s(ps()),Tr=Tu.default.pkg;we.GAXIOS_ERROR_SYMBOL=Symbol.for(`${Tr.name}-gaxios-error`);class Ar extends Error{config;response;code;status;error;[we.GAXIOS_ERROR_SYMBOL]=Tr.version;static[Symbol.hasInstance](e){if(e&&typeof e==="object"&&we.GAXIOS_ERROR_SYMBOL in e&&e[we.GAXIOS_ERROR_SYMBOL]===Tr.version)return!0;return Function.prototype[Symbol.hasInstance].call(Ar,e)}constructor(e,t,r,n){super(e,{cause:n});if(this.config=t,this.response=r,this.error=n instanceof Error?n:void 0,this.config=(0,gs.default)(!0,{},t),this.response)this.response.config=(0,gs.default)(!0,{},this.response.config);if(this.response){try{this.response.data=Au(this.config.responseType,this.response?.bodyUsed?this.response?.data:void 0)}catch{}this.status=this.response.status}if(n instanceof DOMException)this.code=n.name;else if(n&&typeof n==="object"&&"code"in n&&(typeof n.code==="string"||typeof n.code==="number"))this.code=n.code}static extractAPIErrorFromResponse(e,t="The request failed"){let r=t;if(typeof e.data==="string")r=e.data;if(e.data&&typeof e.data==="object"&&"error"in e.data&&e.data.error&&!e.ok){if(typeof e.data.error==="string")return{message:e.data.error,code:e.status,status:e.statusText};if(typeof e.data.error==="object"){r="message"in e.data.error&&typeof e.data.error.message==="string"?e.data.error.message:r;let n="status"in e.data.error&&typeof e.data.error.status==="string"?e.data.error.status:e.statusText,s="code"in e.data.error&&typeof e.data.error.code==="number"?e.data.error.code:e.status;if("errors"in e.data.error&&Array.isArray(e.data.error.errors)){let i=[];for(let u of e.data.error.errors)if(typeof u==="object"&&"message"in u&&typeof u.message==="string")i.push(u.message);return Object.assign({message:i.join(`
3
- `)||r,code:s,status:n},e.data.error)}return Object.assign({message:r,code:s,status:n},e.data.error)}}return{message:r,code:e.status,status:e.statusText}}}we.GaxiosError=Ar;function Au(e,t){switch(e){case"stream":return t;case"json":return JSON.parse(JSON.stringify(t));case"arraybuffer":return JSON.parse(Buffer.from(t).toString("utf8"));case"blob":return JSON.parse(t.text());default:return t}}function ys(e){function r(i){if(!i)return;i.forEach((u,h)=>{if(/^authentication$/i.test(h)||/^authorization$/i.test(h)||/secret/i.test(h))i.set(h,"<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")})}function n(i,u){if(typeof i==="object"&&i!==null&&typeof i[u]==="string"){let h=i[u];if(/grant_type=/i.test(h)||/assertion=/i.test(h)||/secret/i.test(h))i[u]="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>."}}function s(i){if(!i||typeof i!=="object")return;else if(i instanceof FormData||i instanceof URLSearchParams||"forEach"in i&&"set"in i)i.forEach((u,h)=>{if(["grant_type","assertion"].includes(h)||/secret/.test(h))i.set(h,"<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")});else{if("grant_type"in i)i.grant_type="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";if("assertion"in i)i.assertion="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";if("client_secret"in i)i.client_secret="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>."}}if(e.config){if(r(e.config.headers),n(e.config,"data"),s(e.config.data),n(e.config,"body"),s(e.config.body),e.config.url.searchParams.has("token"))e.config.url.searchParams.set("token","<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.");if(e.config.url.searchParams.has("client_secret"))e.config.url.searchParams.set("client_secret","<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")}if(e.response){if(ys({config:e.response.config}),r(e.response.headers),e.response.bodyUsed)n(e.response,"data"),s(e.response.data)}return e}});var ws=w(function(Es){Object.defineProperty(Es,"__esModule",{value:!0});Es.getRetryConfig=vu;async function vu(e){let t=ms(e);if(!e||!e.config||!t&&!e.config.retry)return{shouldRetry:!1};t=t||{},t.currentRetryAttempt=t.currentRetryAttempt||0,t.retry=t.retry===void 0||t.retry===null?3:t.retry,t.httpMethodsToRetry=t.httpMethodsToRetry||["GET","HEAD","PUT","OPTIONS","DELETE"],t.noResponseRetries=t.noResponseRetries===void 0||t.noResponseRetries===null?2:t.noResponseRetries,t.retryDelayMultiplier=t.retryDelayMultiplier?t.retryDelayMultiplier:2,t.timeOfFirstRequest=t.timeOfFirstRequest?t.timeOfFirstRequest:Date.now(),t.totalTimeout=t.totalTimeout?t.totalTimeout:Number.MAX_SAFE_INTEGER,t.maxRetryDelay=t.maxRetryDelay?t.maxRetryDelay:Number.MAX_SAFE_INTEGER;let r=[[100,199],[408,408],[429,429],[500,599]];if(t.statusCodesToRetry=t.statusCodesToRetry||r,e.config.retryConfig=t,!await(t.shouldRetry||Su)(e))return{shouldRetry:!1,config:e.config};let s=Cu(t);e.config.retryConfig.currentRetryAttempt+=1;let i=t.retryBackoff?t.retryBackoff(e,s):new Promise((u)=>{setTimeout(u,s)});if(t.onRetryAttempt)await t.onRetryAttempt(e);return await i,{shouldRetry:!0,config:e.config}}function Su(e){let t=ms(e);if(e.config.signal?.aborted&&e.code!=="TimeoutError"||e.code==="AbortError")return!1;if(!t||t.retry===0)return!1;if(!e.response&&(t.currentRetryAttempt||0)>=t.noResponseRetries)return!1;if(!t.httpMethodsToRetry||!t.httpMethodsToRetry.includes(e.config.method?.toUpperCase()||"GET"))return!1;if(e.response&&e.response.status){let r=!1;for(let[n,s]of t.statusCodesToRetry){let i=e.response.status;if(i>=n&&i<=s){r=!0;break}}if(!r)return!1}if(t.currentRetryAttempt=t.currentRetryAttempt||0,t.currentRetryAttempt>=t.retry)return!1;return!0}function ms(e){if(e&&e.config&&e.config.retryConfig)return e.config.retryConfig;return}function Cu(e){let r=(e.currentRetryAttempt?0:e.retryDelay??100)+(Math.pow(e.retryDelayMultiplier,e.currentRetryAttempt)-1)/2*1000,n=e.totalTimeout-(Date.now()-e.timeOfFirstRequest);return Math.min(r,n,e.maxRetryDelay)}});var Sr=w(function(As){Object.defineProperty(As,"__esModule",{value:!0});As.GaxiosInterceptorManager=void 0;class Ts extends Set{}As.GaxiosInterceptorManager=Ts});var Os=w(function(et){var ku=et&&et.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},Ze;Object.defineProperty(et,"__esModule",{value:!0});et.Gaxios=void 0;var bu=ku(wr()),xu=G("https"),We=vr(),Ru=ws(),Ss=G("stream"),Cs=Sr(),Nu=async()=>globalThis.crypto?.randomUUID()||(await import("crypto")).randomUUID(),Pu=204;class Cr{agentCache=new Map;defaults;interceptors;constructor(e){this.defaults=e||{},this.interceptors={request:new Cs.GaxiosInterceptorManager,response:new Cs.GaxiosInterceptorManager}}fetch(...e){let t=e[0],r=e[1],n=void 0,s=new Headers;if(typeof t==="string")n=new URL(t);else if(t instanceof URL)n=t;else if(t&&t.url)n=new URL(t.url);if(t&&typeof t==="object"&&"headers"in t)Ze.mergeHeaders(s,t.headers);if(r)Ze.mergeHeaders(s,new Headers(r.headers));if(typeof t==="object"&&!(t instanceof URL))return this.request({...r,...t,headers:s,url:n});else return this.request({...r,headers:s,url:n})}async request(e={}){let t=await this.#n(e);return t=await this.#t(t),this.#r(this._request(t))}async _defaultAdapter(e){let t=e.fetchImplementation||this.defaults.fetchImplementation||await Ze.#c(),r={...e};delete r.data;let n=await t(e.url,r),s=await this.getResponseData(e,n);if(!Object.getOwnPropertyDescriptor(n,"data")?.configurable)Object.defineProperties(n,{data:{configurable:!0,writable:!0,enumerable:!0,value:s}});return Object.assign(n,{config:e,data:s})}async _request(e){try{let t;if(e.adapter)t=await e.adapter(e,this._defaultAdapter.bind(this));else t=await this._defaultAdapter(e);if(!e.validateStatus(t.status)){if(e.responseType==="stream"){let n=[];for await(let s of t.data)n.push(s);t.data=Buffer.concat(n.map((s)=>typeof s==="string"?Buffer.from(s):s)).toString("utf8")}let r=We.GaxiosError.extractAPIErrorFromResponse(t,`Request failed with status code ${t.status}`);throw new We.GaxiosError(r?.message,e,t,r)}return t}catch(t){let r;if(t instanceof We.GaxiosError)r=t;else if(t instanceof Error)r=new We.GaxiosError(t.message,e,void 0,t);else r=new We.GaxiosError("Unexpected Gaxios Error",e,void 0,t);let{shouldRetry:n,config:s}=await Ru.getRetryConfig(r);if(n&&s)return r.config.retryConfig.currentRetryAttempt=s.retryConfig.currentRetryAttempt,e.retryConfig=r.config?.retryConfig,this.#s(e),this._request(e);if(e.errorRedactor)e.errorRedactor(r);throw r}}async getResponseData(e,t){if(t.status===Pu)return"";if(e.maxContentLength&&t.headers.has("content-length")&&e.maxContentLength<Number.parseInt(t.headers?.get("content-length")||""))throw new We.GaxiosError("Response's `Content-Length` is over the limit.",e,Object.assign(t,{config:e}));switch(e.responseType){case"stream":return t.body;case"json":{let r=await t.text();try{return JSON.parse(r)}catch{return r}}case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"text":return t.text();default:return this.getResponseDataFromContentType(t)}}#e(e,t=[]){let r=new URL(e),n=[...t],s=(process.env.NO_PROXY??process.env.no_proxy)?.split(",")||[];for(let i of s)n.push(i.trim());for(let i of n)if(i instanceof RegExp){if(i.test(r.toString()))return!1}else if(i instanceof URL){if(i.origin===r.origin)return!1}else if(i.startsWith("*.")||i.startsWith(".")){let u=i.replace(/^\*\./,".");if(r.hostname.endsWith(u))return!1}else if(i===r.origin||i===r.hostname||i===r.href)return!1;return!0}async#t(e){let t=Promise.resolve(e);for(let r of this.interceptors.request.values())if(r)t=t.then(r.resolved,r.rejected);return t}async#r(e){let t=Promise.resolve(e);for(let r of this.interceptors.response.values())if(r)t=t.then(r.resolved,r.rejected);return t}async#n(e){let t=new Headers(this.defaults.headers);Ze.mergeHeaders(t,e.headers);let r=(0,bu.default)(!0,{},this.defaults,e);if(!r.url)throw Error("URL is required.");if(r.baseURL)r.url=new URL(r.url,r.baseURL);if(r.url=new URL(r.url),r.params)if(r.paramsSerializer){let i=r.paramsSerializer(r.params);if(i.startsWith("?"))i=i.slice(1);let u=r.url.toString().includes("?")?"&":"?";r.url=r.url+u+i}else{let i=r.url instanceof URL?r.url:new URL(r.url);for(let[u,h]of new URLSearchParams(r.params))i.searchParams.append(u,h);r.url=i}if(typeof e.maxContentLength==="number")r.size=e.maxContentLength;if(typeof e.maxRedirects==="number")r.follow=e.maxRedirects;let n=typeof r.data==="string"||r.data instanceof ArrayBuffer||r.data instanceof Blob||globalThis.File&&r.data instanceof File||r.data instanceof FormData||r.data instanceof Ss.Readable||r.data instanceof ReadableStream||r.data instanceof String||r.data instanceof URLSearchParams||ArrayBuffer.isView(r.data)||["Blob","File","FormData"].includes(r.data?.constructor?.name||"");if(r.multipart?.length){let i=await Nu();t.set("content-type",`multipart/related; boundary=${i}`),r.body=Ss.Readable.from(this.getMultipartRequest(r.multipart,i))}else if(n)r.body=r.data;else if(typeof r.data==="object")if(t.get("Content-Type")==="application/x-www-form-urlencoded")r.body=r.paramsSerializer?r.paramsSerializer(r.data):new URLSearchParams(r.data);else{if(!t.has("content-type"))t.set("content-type","application/json");r.body=JSON.stringify(r.data)}else if(r.data)r.body=r.data;if(r.validateStatus=r.validateStatus||this.validateStatus,r.responseType=r.responseType||"unknown",!t.has("accept")&&r.responseType==="json")t.set("accept","application/json");let s=r.proxy||process?.env?.HTTPS_PROXY||process?.env?.https_proxy||process?.env?.HTTP_PROXY||process?.env?.http_proxy;if(r.agent);else if(s&&this.#e(r.url,r.noProxy)){let i=await Ze.#a();if(this.agentCache.has(s))r.agent=this.agentCache.get(s);else r.agent=new i(s,{cert:r.cert,key:r.key}),this.agentCache.set(s,r.agent)}else if(r.cert&&r.key)if(this.agentCache.has(r.key))r.agent=this.agentCache.get(r.key);else r.agent=new xu.Agent({cert:r.cert,key:r.key}),this.agentCache.set(r.key,r.agent);if(typeof r.errorRedactor!=="function"&&r.errorRedactor!==!1)r.errorRedactor=We.defaultErrorRedactor;if(r.body&&!("duplex"in r))r.duplex="half";return this.#s(r),Object.assign(r,{headers:t,url:r.url instanceof URL?r.url:new URL(r.url)})}#s(e){if(e.timeout){let t=AbortSignal.timeout(e.timeout);if(e.signal&&!e.signal.aborted)e.signal=AbortSignal.any([e.signal,t]);else e.signal=t}}validateStatus(e){return e>=200&&e<300}async getResponseDataFromContentType(e){let t=e.headers.get("Content-Type");if(t===null)return e.text();if(t=t.toLowerCase(),t.includes("application/json")){let r=await e.text();try{r=JSON.parse(r)}catch{}return r}else if(t.match(/^text\//))return e.text();else return e.blob()}async*getMultipartRequest(e,t){let r=`--${t}--`;for(let n of e){let s=n.headers.get("Content-Type")||"application/octet-stream";if(yield`--${t}\r
2
+ import{z,w,G}from"./chunk-yqvhgtez.js";var es=w(function(Xp,Zn){function Ee(e,t){if(typeof t==="boolean")t={forever:t};if(this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Zn.exports=Ee;Ee.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};Ee.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);if(this._timer)clearTimeout(this._timer);this._timeouts=[],this._cachedTimeouts=null};Ee.prototype.retry=function(e){if(this._timeout)clearTimeout(this._timeout);if(!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var n=this;if(this._timer=setTimeout(function(){if(n._attempts++,n._operationTimeoutCb){if(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref)n._timeout.unref()}n._fn(n._attempts)},r),this._options.unref)this._timer.unref();return!0};Ee.prototype.attempt=function(e,t){if(this._fn=e,t){if(t.timeout)this._operationTimeout=t.timeout;if(t.cb)this._operationTimeoutCb=t.cb}var r=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};Ee.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};Ee.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};Ee.prototype.start=Ee.prototype.try;Ee.prototype.errors=function(){return this._errors};Ee.prototype.attempts=function(){return this._attempts};Ee.prototype.mainError=function(){if(this._errors.length===0)return null;var e={},t=null,r=0;for(var n=0;n<this._errors.length;n++){var s=this._errors[n],i=s.message,u=(e[i]||0)+1;if(e[i]=u,u>=r)t=s,r=u}return t}});var rs=w(function(mr){var lu=es();mr.operation=function(e){var t=mr.timeouts(e);return new lu(t,{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};mr.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var n=[];for(var s=0;s<t.retries;s++)n.push(this.createTimeout(s,t));if(e&&e.forever&&!n.length)n.push(this.createTimeout(s,t));return n.sort(function(i,u){return i-u}),n};mr.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout),n};mr.wrap=function(e,t,r){if(t instanceof Array)r=t,t=null;if(!r){r=[];for(var n in e)if(typeof e[n]==="function")r.push(n)}for(var s=0;s<r.length;s++){var i=r[s],u=e[i];e[i]=function(y){var S=mr.operation(t),A=Array.prototype.slice.call(arguments,1),k=A.pop();A.push(function(N){if(S.retry(N))return;if(N)arguments[0]=S.mainError();k.apply(this,arguments)}),S.attempt(function(){y.apply(e,A)})}.bind(e,u),e[i].options=t}}});var bu=w(function(Zp,Pt){var pu=rs(),gu=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class Er extends Error{constructor(e){super();if(e instanceof Error)this.originalError=e,{message:e}=e;else this.originalError=Error(e),this.originalError.stack=this.stack;this.name="AbortError",this.message=e}}var _u=(e,t,r)=>{let n=r.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=n,e},yu=(e)=>gu.includes(e),ns=(e,t)=>new Promise((r,n)=>{t={onFailedAttempt:()=>{},retries:10,...t};let s=pu.operation(t);s.attempt(async(i)=>{try{r(await e(i))}catch(u){if(!(u instanceof Error)){n(TypeError(`Non-error was thrown: "${u}". You should only throw errors.`));return}if(u instanceof Er)s.stop(),n(u.originalError);else if(u instanceof TypeError&&!yu(u.message))s.stop(),n(u);else{_u(u,i,t);try{await t.onFailedAttempt(u)}catch(h){n(h);return}if(!s.retry(u))n(s.mainError())}}})});Pt.exports=ns;Pt.exports.default=ns;Pt.exports.AbortError=Er});var wr=w(function(eg,hs){var It=Object.prototype.hasOwnProperty,ls=Object.prototype.toString,{defineProperty:ss,getOwnPropertyDescriptor:is}=Object,os=function(t){if(typeof Array.isArray==="function")return Array.isArray(t);return ls.call(t)==="[object Array]"},as=function(t){if(!t||ls.call(t)!=="[object Object]")return!1;var r=It.call(t,"constructor"),n=t.constructor&&t.constructor.prototype&&It.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!n)return!1;var s;for(s in t);return typeof s>"u"||It.call(t,s)},cs=function(t,r){if(ss&&r.name==="__proto__")ss(t,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0});else t[r.name]=r.newValue},us=function(t,r){if(r==="__proto__"){if(!It.call(t,r))return;else if(is)return is(t,r).value}return t[r]};hs.exports=function e(){var t,r,n,s,i,u,h=arguments[0],y=1,S=arguments.length,A=!1;if(typeof h==="boolean")A=h,h=arguments[1]||{},y=2;if(h==null||typeof h!=="object"&&typeof h!=="function")h={};for(;y<S;++y)if(t=arguments[y],t!=null){for(r in t)if(n=us(h,r),s=us(t,r),h!==s){if(A&&s&&(as(s)||(i=os(s)))){if(i)i=!1,u=n&&os(n)?n:[];else u=n&&as(n)?n:{};cs(h,{name:r,newValue:e(A,u,s)})}else if(typeof s<"u")cs(h,{name:r,newValue:s})}}return h}});var fs=w(function(tg,mu){mu.exports={name:"gaxios",version:"7.3.1",description:"A simple common HTTP client specifically for Google APIs and services.",main:"build/cjs/src/index.js",types:"build/cjs/src/index.d.ts",files:["build/"],exports:{".":{import:{types:"./build/esm/src/index.d.ts",default:"./build/esm/src/index.js"},require:{types:"./build/cjs/src/index.d.ts",default:"./build/cjs/src/index.js"}}},scripts:{lint:"gts check --no-inline-config",test:"c8 mocha build/esm/test","presystem-test":"npm run compile","system-test":"mocha build/esm/system-test --timeout 80000",compile:"tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs",fix:"gts fix",prepare:"npm run compile",pretest:"npm run compile",webpack:"webpack","prebrowser-test":"npm run compile","browser-test":"node build/browser-test/browser-test-runner.js",docs:"jsdoc -c .jsdoc.js","samples-test":"cd samples/ && npm link ../ && npm test && cd ../",prelint:"cd samples; npm link ../; npm install",clean:"gts clean"},repository:{type:"git",directory:"core/packages/gaxios",url:"https://github.com/googleapis/google-cloud-node.git"},keywords:["google"],engines:{node:">=18"},author:"Google, LLC",license:"Apache-2.0",devDependencies:{"@babel/plugin-proposal-private-methods":"^7.18.6","@types/cors":"^2.8.6","@types/express":"^5.0.0","@types/extend":"^3.0.1","@types/mocha":"^10.0.10","@types/multiparty":"4.2.1","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","@types/tmp":"^0.2.6",assert:"^2.0.0",browserify:"^17.0.0",c8:"^10.1.3",cors:"^2.8.5",express:"^5.0.0",gts:"^6.0.2","is-docker":"^3.0.0",jsdoc:"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0",karma:"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-remap-coverage":"^0.1.5","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.0",mocha:"^11.1.0",multiparty:"^4.2.1",mv:"^2.1.1",ncp:"^2.0.0",nock:"14.0.5","null-loader":"^4.0.1","pack-n-play":"^4.0.0",puppeteer:"^24.0.0",sinon:"21.0.3","stream-browserify":"^3.0.0",tmp:"0.2.7","ts-loader":"^9.5.2",typescript:"5.8.3","undici-types":"^7.24.1",webpack:"^5.97.1","webpack-cli":"^6.0.1"},dependencies:{extend:"^3.0.2","https-proxy-agent":"^7.0.1","node-fetch":"^3.3.2"},homepage:"https://github.com/googleapis/google-cloud-node/tree/main/core/packages/gaxios"}});var ps=w(function(rg,ds){var Eu=fs();ds.exports={pkg:Eu}});var vr=w(function(we){var _s=we&&we.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(we,"__esModule",{value:!0});we.GaxiosError=we.GAXIOS_ERROR_SYMBOL=void 0;we.defaultErrorRedactor=ys;var gs=_s(wr()),wu=_s(ps()),Tr=wu.default.pkg;we.GAXIOS_ERROR_SYMBOL=Symbol.for(`${Tr.name}-gaxios-error`);class Ar extends Error{config;response;code;status;error;[we.GAXIOS_ERROR_SYMBOL]=Tr.version;static[Symbol.hasInstance](e){if(e&&typeof e==="object"&&we.GAXIOS_ERROR_SYMBOL in e&&e[we.GAXIOS_ERROR_SYMBOL]===Tr.version)return!0;return Function.prototype[Symbol.hasInstance].call(Ar,e)}constructor(e,t,r,n){super(e,{cause:n});if(this.config=t,this.response=r,this.error=n instanceof Error?n:void 0,this.config=(0,gs.default)(!0,{},t),this.response)this.response.config=(0,gs.default)(!0,{},this.response.config);if(this.response){try{this.response.data=Tu(this.config.responseType,this.response?.bodyUsed?this.response?.data:void 0)}catch{}this.status=this.response.status}if(n instanceof DOMException)this.code=n.name;else if(n&&typeof n==="object"&&"code"in n&&(typeof n.code==="string"||typeof n.code==="number"))this.code=n.code}static extractAPIErrorFromResponse(e,t="The request failed"){let r=t;if(typeof e.data==="string")r=e.data;if(e.data&&typeof e.data==="object"&&"error"in e.data&&e.data.error&&!e.ok){if(typeof e.data.error==="string")return{message:e.data.error,code:e.status,status:e.statusText};if(typeof e.data.error==="object"){r="message"in e.data.error&&typeof e.data.error.message==="string"?e.data.error.message:r;let n="status"in e.data.error&&typeof e.data.error.status==="string"?e.data.error.status:e.statusText,s="code"in e.data.error&&typeof e.data.error.code==="number"?e.data.error.code:e.status;if("errors"in e.data.error&&Array.isArray(e.data.error.errors)){let i=[];for(let u of e.data.error.errors)if(typeof u==="object"&&"message"in u&&typeof u.message==="string")i.push(u.message);return Object.assign({message:i.join(`
3
+ `)||r,code:s,status:n},e.data.error)}return Object.assign({message:r,code:s,status:n},e.data.error)}}return{message:r,code:e.status,status:e.statusText}}}we.GaxiosError=Ar;function Tu(e,t){switch(e){case"stream":return t;case"json":return JSON.parse(JSON.stringify(t));case"arraybuffer":return JSON.parse(Buffer.from(t).toString("utf8"));case"blob":return JSON.parse(t.text());default:return t}}function ys(e){function r(i){if(!i)return;i.forEach((u,h)=>{if(/^authentication$/i.test(h)||/^authorization$/i.test(h)||/secret/i.test(h))i.set(h,"<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")})}function n(i,u){if(typeof i==="object"&&i!==null&&typeof i[u]==="string"){let h=i[u];if(/grant_type=/i.test(h)||/assertion=/i.test(h)||/secret/i.test(h))i[u]="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>."}}function s(i){if(!i||typeof i!=="object")return;else if(i instanceof FormData||i instanceof URLSearchParams||"forEach"in i&&"set"in i)i.forEach((u,h)=>{if(["grant_type","assertion"].includes(h)||/secret/.test(h))i.set(h,"<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")});else{if("grant_type"in i)i.grant_type="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";if("assertion"in i)i.assertion="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";if("client_secret"in i)i.client_secret="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>."}}if(e.config){if(r(e.config.headers),n(e.config,"data"),s(e.config.data),n(e.config,"body"),s(e.config.body),e.config.url.searchParams.has("token"))e.config.url.searchParams.set("token","<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.");if(e.config.url.searchParams.has("client_secret"))e.config.url.searchParams.set("client_secret","<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")}if(e.response){if(ys({config:e.response.config}),r(e.response.headers),e.response.bodyUsed)n(e.response,"data"),s(e.response.data)}return e}});var ws=w(function(Es){Object.defineProperty(Es,"__esModule",{value:!0});Es.getRetryConfig=Au;async function Au(e){let t=ms(e);if(!e||!e.config||!t&&!e.config.retry)return{shouldRetry:!1};t=t||{},t.currentRetryAttempt=t.currentRetryAttempt||0,t.retry=t.retry===void 0||t.retry===null?3:t.retry,t.httpMethodsToRetry=t.httpMethodsToRetry||["GET","HEAD","PUT","OPTIONS","DELETE"],t.noResponseRetries=t.noResponseRetries===void 0||t.noResponseRetries===null?2:t.noResponseRetries,t.retryDelayMultiplier=t.retryDelayMultiplier?t.retryDelayMultiplier:2,t.timeOfFirstRequest=t.timeOfFirstRequest?t.timeOfFirstRequest:Date.now(),t.totalTimeout=t.totalTimeout?t.totalTimeout:Number.MAX_SAFE_INTEGER,t.maxRetryDelay=t.maxRetryDelay?t.maxRetryDelay:Number.MAX_SAFE_INTEGER;let r=[[100,199],[408,408],[429,429],[500,599]];if(t.statusCodesToRetry=t.statusCodesToRetry||r,e.config.retryConfig=t,!await(t.shouldRetry||vu)(e))return{shouldRetry:!1,config:e.config};let s=Su(t);e.config.retryConfig.currentRetryAttempt+=1;let i=t.retryBackoff?t.retryBackoff(e,s):new Promise((u)=>{setTimeout(u,s)});if(t.onRetryAttempt)await t.onRetryAttempt(e);return await i,{shouldRetry:!0,config:e.config}}function vu(e){let t=ms(e);if(e.config.signal?.aborted&&e.code!=="TimeoutError"||e.code==="AbortError")return!1;if(!t||t.retry===0)return!1;if(!e.response&&(t.currentRetryAttempt||0)>=t.noResponseRetries)return!1;if(!t.httpMethodsToRetry||!t.httpMethodsToRetry.includes(e.config.method?.toUpperCase()||"GET"))return!1;if(e.response&&e.response.status){let r=!1;for(let[n,s]of t.statusCodesToRetry){let i=e.response.status;if(i>=n&&i<=s){r=!0;break}}if(!r)return!1}if(t.currentRetryAttempt=t.currentRetryAttempt||0,t.currentRetryAttempt>=t.retry)return!1;return!0}function ms(e){if(e&&e.config&&e.config.retryConfig)return e.config.retryConfig;return}function Su(e){let r=(e.currentRetryAttempt?0:e.retryDelay??100)+(Math.pow(e.retryDelayMultiplier,e.currentRetryAttempt)-1)/2*1000,n=e.totalTimeout-(Date.now()-e.timeOfFirstRequest);return Math.min(r,n,e.maxRetryDelay)}});var Sr=w(function(As){Object.defineProperty(As,"__esModule",{value:!0});As.GaxiosInterceptorManager=void 0;class Ts extends Set{}As.GaxiosInterceptorManager=Ts});var Os=w(function(et){var Ou=et&&et.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},Ze;Object.defineProperty(et,"__esModule",{value:!0});et.Gaxios=void 0;var ku=Ou(wr()),xu=G("https"),We=vr(),Ru=ws(),Ss=G("stream"),Cs=Sr(),Nu=async()=>globalThis.crypto?.randomUUID()||(await import("crypto")).randomUUID(),Pu=204;class Cr{agentCache=new Map;defaults;interceptors;constructor(e){this.defaults=e||{},this.interceptors={request:new Cs.GaxiosInterceptorManager,response:new Cs.GaxiosInterceptorManager}}fetch(...e){let t=e[0],r=e[1],n=void 0,s=new Headers;if(typeof t==="string")n=new URL(t);else if(t instanceof URL)n=t;else if(t&&t.url)n=new URL(t.url);if(t&&typeof t==="object"&&"headers"in t)Ze.mergeHeaders(s,t.headers);if(r)Ze.mergeHeaders(s,new Headers(r.headers));if(typeof t==="object"&&!(t instanceof URL))return this.request({...r,...t,headers:s,url:n});else return this.request({...r,headers:s,url:n})}async request(e={}){let t=await this.#n(e);return t=await this.#t(t),this.#r(this._request(t))}async _defaultAdapter(e){let t=e.fetchImplementation||this.defaults.fetchImplementation||await Ze.#c(),r={...e};delete r.data;let n=await t(e.url,r),s=await this.getResponseData(e,n);if(!Object.getOwnPropertyDescriptor(n,"data")?.configurable)Object.defineProperties(n,{data:{configurable:!0,writable:!0,enumerable:!0,value:s}});return Object.assign(n,{config:e,data:s})}async _request(e){try{let t;if(e.adapter)t=await e.adapter(e,this._defaultAdapter.bind(this));else t=await this._defaultAdapter(e);if(!e.validateStatus(t.status)){if(e.responseType==="stream"){let n=[];for await(let s of t.data)n.push(s);t.data=Buffer.concat(n.map((s)=>typeof s==="string"?Buffer.from(s):s)).toString("utf8")}let r=We.GaxiosError.extractAPIErrorFromResponse(t,`Request failed with status code ${t.status}`);throw new We.GaxiosError(r?.message,e,t,r)}return t}catch(t){let r;if(t instanceof We.GaxiosError)r=t;else if(t instanceof Error)r=new We.GaxiosError(t.message,e,void 0,t);else r=new We.GaxiosError("Unexpected Gaxios Error",e,void 0,t);let{shouldRetry:n,config:s}=await Ru.getRetryConfig(r);if(n&&s)return r.config.retryConfig.currentRetryAttempt=s.retryConfig.currentRetryAttempt,e.retryConfig=r.config?.retryConfig,this.#s(e),this._request(e);if(e.errorRedactor)e.errorRedactor(r);throw r}}async getResponseData(e,t){if(t.status===Pu)return"";if(e.maxContentLength&&t.headers.has("content-length")&&e.maxContentLength<Number.parseInt(t.headers?.get("content-length")||""))throw new We.GaxiosError("Response's `Content-Length` is over the limit.",e,Object.assign(t,{config:e}));switch(e.responseType){case"stream":return t.body;case"json":{let r=await t.text();try{return JSON.parse(r)}catch{return r}}case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"text":return t.text();default:return this.getResponseDataFromContentType(t)}}#e(e,t=[]){let r=new URL(e),n=[...t],s=(process.env.NO_PROXY??process.env.no_proxy)?.split(",")||[];for(let i of s)n.push(i.trim());for(let i of n)if(i instanceof RegExp){if(i.test(r.toString()))return!1}else if(i instanceof URL){if(i.origin===r.origin)return!1}else if(i.startsWith("*.")||i.startsWith(".")){let u=i.replace(/^\*\./,".");if(r.hostname.endsWith(u))return!1}else if(i===r.origin||i===r.hostname||i===r.href)return!1;return!0}async#t(e){let t=Promise.resolve(e);for(let r of this.interceptors.request.values())if(r)t=t.then(r.resolved,r.rejected);return t}async#r(e){let t=Promise.resolve(e);for(let r of this.interceptors.response.values())if(r)t=t.then(r.resolved,r.rejected);return t}async#n(e){let t=new Headers(this.defaults.headers);Ze.mergeHeaders(t,e.headers);let r=(0,ku.default)(!0,{},this.defaults,e);if(!r.url)throw Error("URL is required.");if(r.baseURL)r.url=new URL(r.url,r.baseURL);if(r.url=new URL(r.url),r.params)if(r.paramsSerializer){let i=r.paramsSerializer(r.params);if(i.startsWith("?"))i=i.slice(1);let u=r.url.toString().includes("?")?"&":"?";r.url=r.url+u+i}else{let i=r.url instanceof URL?r.url:new URL(r.url);for(let[u,h]of new URLSearchParams(r.params))i.searchParams.append(u,h);r.url=i}if(typeof e.maxContentLength==="number")r.size=e.maxContentLength;if(typeof e.maxRedirects==="number")r.follow=e.maxRedirects;let n=typeof r.data==="string"||r.data instanceof ArrayBuffer||r.data instanceof Blob||globalThis.File&&r.data instanceof File||r.data instanceof FormData||r.data instanceof Ss.Readable||r.data instanceof ReadableStream||r.data instanceof String||r.data instanceof URLSearchParams||ArrayBuffer.isView(r.data)||["Blob","File","FormData"].includes(r.data?.constructor?.name||"");if(r.multipart?.length){let i=await Nu();t.set("content-type",`multipart/related; boundary=${i}`),r.body=Ss.Readable.from(this.getMultipartRequest(r.multipart,i))}else if(n)r.body=r.data;else if(typeof r.data==="object")if(t.get("Content-Type")==="application/x-www-form-urlencoded")r.body=r.paramsSerializer?r.paramsSerializer(r.data):new URLSearchParams(r.data);else{if(!t.has("content-type"))t.set("content-type","application/json");r.body=JSON.stringify(r.data)}else if(r.data)r.body=r.data;if(r.validateStatus=r.validateStatus||this.validateStatus,r.responseType=r.responseType||"unknown",!t.has("accept")&&r.responseType==="json")t.set("accept","application/json");let s=r.proxy||process?.env?.HTTPS_PROXY||process?.env?.https_proxy||process?.env?.HTTP_PROXY||process?.env?.http_proxy;if(r.agent);else if(s&&this.#e(r.url,r.noProxy)){let i=await Ze.#a();if(this.agentCache.has(s))r.agent=this.agentCache.get(s);else r.agent=new i(s,{cert:r.cert,key:r.key}),this.agentCache.set(s,r.agent)}else if(r.cert&&r.key)if(this.agentCache.has(r.key))r.agent=this.agentCache.get(r.key);else r.agent=new xu.Agent({cert:r.cert,key:r.key}),this.agentCache.set(r.key,r.agent);if(typeof r.errorRedactor!=="function"&&r.errorRedactor!==!1)r.errorRedactor=We.defaultErrorRedactor;if(r.body&&!("duplex"in r))r.duplex="half";return this.#s(r),Object.assign(r,{headers:t,url:r.url instanceof URL?r.url:new URL(r.url)})}#s(e){if(e.timeout){let t=AbortSignal.timeout(e.timeout);if(e.signal&&!e.signal.aborted)e.signal=AbortSignal.any([e.signal,t]);else e.signal=t}}validateStatus(e){return e>=200&&e<300}async getResponseDataFromContentType(e){let t=e.headers.get("Content-Type");if(t===null)return e.text();if(t=t.toLowerCase(),t.includes("application/json")){let r=await e.text();try{r=JSON.parse(r)}catch{}return r}else if(t.match(/^text\//))return e.text();else return e.blob()}async*getMultipartRequest(e,t){let r=`--${t}--`;for(let n of e){let s=n.headers.get("Content-Type")||"application/octet-stream";if(yield`--${t}\r
4
4
  Content-Type: ${s}\r
5
5
  \r
6
6
  `,typeof n.content==="string")yield n.content;else yield*n.content;yield`\r
7
- `}yield r}static#i;static#o;static async#a(){return this.#i||=(await import("./chunk-pwkby9h7.js").then((m)=>z(m.default))).HttpsProxyAgent,this.#i}static async#c(){let e=typeof window<"u"&&!!window;return this.#o||=e?window.fetch:(await import("node-fetch")).default,this.#o}static mergeHeaders(e,...t){e=e instanceof Headers?e:new Headers(e);for(let r of t)(r instanceof Headers?r:new Headers(r)).forEach((s,i)=>{i==="set-cookie"?e.append(i,s):e.set(i,s)});return e}}et.Gaxios=Cr;Ze=Cr});var ie=w(function(le){var Iu=le&&le.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),ju=le&&le.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Iu(t,e,r)};Object.defineProperty(le,"__esModule",{value:!0});le.instance=le.Gaxios=le.GaxiosError=void 0;le.request=Uu;var ks=Os();Object.defineProperty(le,"Gaxios",{enumerable:!0,get:function(){return ks.Gaxios}});var Du=vr();Object.defineProperty(le,"GaxiosError",{enumerable:!0,get:function(){return Du.GaxiosError}});ju(Sr(),le);le.instance=new ks.Gaxios;async function Uu(e){return le.instance.request(e)}});var Or=w(function(bs,jt){(function(e){var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,{ceil:n,floor:s}=Math,i="[BigNumber Error] ",u=i+"Number primitive has more than 15 significant digits: ",h=100000000000000,y=14,S=9007199254740991,A=[1,10,100,1000,1e4,1e5,1e6,1e7,1e8,1e9,10000000000,100000000000,1000000000000,10000000000000],k=1e7,N=1e9;function F(U){var D,B,X,C=v.prototype={constructor:v,toString:null,valueOf:null},ne=new v(1),Q=20,Z=4,he=-7,fe=21,Ke=-1e7,Se=1e7,Je=!1,ft=1,Le=0,fr={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Ve="0123456789abcdefghijklmnopqrstuvwxyz",dr=!0;function v(o,a){var c,_,f,p,E,l,d,m,g=this;if(!(g instanceof v))return new v(o,a);if(a==null){if(o&&o._isBigNumber===!0){if(g.s=o.s,!o.c||o.e>Se)g.c=g.e=null;else if(o.e<Ke)g.c=[g.e=0];else g.e=o.e,g.c=o.c.slice();return}if((l=typeof o=="number")&&o*0==0){if(g.s=1/o<0?(o=-o,-1):1,o===~~o){for(p=0,E=o;E>=10;E/=10,p++);if(p>Se)g.c=g.e=null;else g.e=p,g.c=[o];return}m=String(o)}else{if(!r.test(m=String(o)))return X(g,m,l);g.s=m.charCodeAt(0)==45?(m=m.slice(1),-1):1}if((p=m.indexOf("."))>-1)m=m.replace(".","");if((E=m.search(/e/i))>0){if(p<0)p=E;p+=+m.slice(E+1),m=m.substring(0,E)}else if(p<0)p=m.length}else{if(b(a,2,Ve.length,"Base"),a==10&&dr)return g=new v(o),ye(g,Q+g.e+1,Z);if(m=String(o),l=typeof o=="number"){if(o*0!=0)return X(g,m,l,a);if(g.s=1/o<0?(m=m.slice(1),-1):1,v.DEBUG&&m.replace(/^0\.0*|\./,"").length>15)throw Error(u+o)}else g.s=m.charCodeAt(0)===45?(m=m.slice(1),-1):1;c=Ve.slice(0,a),p=E=0;for(d=m.length;E<d;E++)if(c.indexOf(_=m.charAt(E))<0){if(_=="."){if(E>p){p=d;continue}}else if(!f){if(m==m.toUpperCase()&&(m=m.toLowerCase())||m==m.toLowerCase()&&(m=m.toUpperCase())){f=!0,E=-1,p=0;continue}}return X(g,String(o),l,a)}if(l=!1,m=B(m,a,10,g.s),(p=m.indexOf("."))>-1)m=m.replace(".","");else p=m.length}for(E=0;m.charCodeAt(E)===48;E++);for(d=m.length;m.charCodeAt(--d)===48;);if(m=m.slice(E,++d)){if(d-=E,l&&v.DEBUG&&d>15&&(o>S||o!==s(o)))throw Error(u+g.s*o);if((p=p-E-1)>Se)g.c=g.e=null;else if(p<Ke)g.c=[g.e=0];else{if(g.e=p,g.c=[],E=(p+1)%y,p<0)E+=y;if(E<d){if(E)g.c.push(+m.slice(0,E));for(d-=y;E<d;)g.c.push(+m.slice(E,E+=y));E=y-(m=m.slice(E)).length}else E-=d;for(;E--;m+="0");g.c.push(+m)}}else g.c=[g.e=0]}v.clone=F,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(o){var a,c;if(o!=null)if(typeof o=="object"){if(o.hasOwnProperty(a="DECIMAL_PLACES"))c=o[a],b(c,0,N,a),Q=c;if(o.hasOwnProperty(a="ROUNDING_MODE"))c=o[a],b(c,0,8,a),Z=c;if(o.hasOwnProperty(a="EXPONENTIAL_AT"))if(c=o[a],c&&c.pop)b(c[0],-N,0,a),b(c[1],0,N,a),he=c[0],fe=c[1];else b(c,-N,N,a),he=-(fe=c<0?-c:c);if(o.hasOwnProperty(a="RANGE"))if(c=o[a],c&&c.pop)b(c[0],-N,-1,a),b(c[1],1,N,a),Ke=c[0],Se=c[1];else if(b(c,-N,N,a),c)Ke=-(Se=c<0?-c:c);else throw Error(i+a+" cannot be zero: "+c);if(o.hasOwnProperty(a="CRYPTO"))if(c=o[a],c===!!c)if(c)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))Je=c;else throw Je=!c,Error(i+"crypto unavailable");else Je=c;else throw Error(i+a+" not true or false: "+c);if(o.hasOwnProperty(a="MODULO_MODE"))c=o[a],b(c,0,9,a),ft=c;if(o.hasOwnProperty(a="POW_PRECISION"))c=o[a],b(c,0,N,a),Le=c;if(o.hasOwnProperty(a="FORMAT"))if(c=o[a],typeof c=="object")fr=c;else throw Error(i+a+" not an object: "+c);if(o.hasOwnProperty(a="ALPHABET"))if(c=o[a],typeof c=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(c))dr=c.slice(0,10)=="0123456789",Ve=c;else throw Error(i+a+" invalid: "+c)}else throw Error(i+"Object expected: "+o);return{DECIMAL_PLACES:Q,ROUNDING_MODE:Z,EXPONENTIAL_AT:[he,fe],RANGE:[Ke,Se],CRYPTO:Je,MODULO_MODE:ft,POW_PRECISION:Le,FORMAT:fr,ALPHABET:Ve}},v.isBigNumber=function(o){if(!o||o._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var a,c,{c:_,e:f,s:p}=o;e:if({}.toString.call(_)=="[object Array]"){if((p===1||p===-1)&&f>=-N&&f<=N&&f===s(f)){if(_[0]===0){if(f===0&&_.length===1)return!0;break e}if(a=(f+1)%y,a<1)a+=y;if(String(_[0]).length==a){for(a=0;a<_.length;a++)if(c=_[a],c<0||c>=h||c!==s(c))break e;if(c!==0)return!0}}}else if(_===null&&f===null&&(p===null||p===1||p===-1))return!0;throw Error(i+"Invalid BigNumber: "+o)},v.maximum=v.max=function(){return Qn(arguments,-1)},v.minimum=v.min=function(){return Qn(arguments,1)},v.random=function(){var o=9007199254740992,a=Math.random()*o&2097151?function(){return s(Math.random()*o)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(c){var _,f,p,E,l,d=0,m=[],g=new v(ne);if(c==null)c=Q;else b(c,0,N);if(E=n(c/y),Je)if(crypto.getRandomValues){_=crypto.getRandomValues(new Uint32Array(E*=2));for(;d<E;)if(l=_[d]*131072+(_[d+1]>>>11),l>=9000000000000000)f=crypto.getRandomValues(new Uint32Array(2)),_[d]=f[0],_[d+1]=f[1];else m.push(l%100000000000000),d+=2;d=E/2}else if(crypto.randomBytes){_=crypto.randomBytes(E*=7);for(;d<E;)if(l=(_[d]&31)*281474976710656+_[d+1]*1099511627776+_[d+2]*4294967296+_[d+3]*16777216+(_[d+4]<<16)+(_[d+5]<<8)+_[d+6],l>=9000000000000000)crypto.randomBytes(7).copy(_,d);else m.push(l%100000000000000),d+=7;d=E/7}else throw Je=!1,Error(i+"crypto unavailable");if(!Je){for(;d<E;)if(l=a(),l<9000000000000000)m[d++]=l%100000000000000}if(E=m[--d],c%=y,E&&c)l=A[y-c],m[d]=s(E/l)*l;for(;m[d]===0;m.pop(),d--);if(d<0)m=[p=0];else{for(p=-1;m[0]===0;m.splice(0,1),p-=y);for(d=1,l=m[0];l>=10;l/=10,d++);if(d<y)p-=y-d}return g.e=p,g.c=m,g}}(),v.sum=function(){var o=1,a=arguments,c=new v(a[0]);for(;o<a.length;)c=c.plus(a[o++]);return c},B=function(){var o="0123456789";function a(c,_,f,p){var E,l=[0],d,m=0,g=c.length;for(;m<g;){for(d=l.length;d--;l[d]*=_);l[0]+=p.indexOf(c.charAt(m++));for(E=0;E<l.length;E++)if(l[E]>f-1){if(l[E+1]==null)l[E+1]=0;l[E+1]+=l[E]/f|0,l[E]%=f}}return l.reverse()}return function(c,_,f,p,E){var l,d,m,g,T,R,P,L,ee=c.indexOf("."),se=Q,M=Z;if(ee>=0)g=Le,Le=0,c=c.replace(".",""),L=new v(_),R=L.pow(c.length-ee),Le=g,L.c=a(ce(x(R.c),R.e,"0"),10,f,o),L.e=L.c.length;P=a(c,_,f,E?(l=Ve,o):(l=o,Ve)),m=g=P.length;for(;P[--g]==0;P.pop());if(!P[0])return l.charAt(0);if(ee<0)--m;else R.c=P,R.e=m,R.s=p,R=D(R,L,se,M,f),P=R.c,T=R.r,m=R.e;if(d=m+se+1,ee=P[d],g=f/2,T=T||d<0||P[d+1]!=null,T=M<4?(ee!=null||T)&&(M==0||M==(R.s<0?3:2)):ee>g||ee==g&&(M==4||T||M==6&&P[d-1]&1||M==(R.s<0?8:7)),d<1||!P[0])c=T?ce(l.charAt(1),-se,l.charAt(0)):l.charAt(0);else{if(P.length=d,T){for(--f;++P[--d]>f;)if(P[d]=0,!d)++m,P=[1].concat(P)}for(g=P.length;!P[--g];);for(ee=0,c="";ee<=g;c+=l.charAt(P[ee++]));c=ce(c,m,l.charAt(0))}return c}}(),D=function(){function o(_,f,p){var E,l,d,m,g=0,T=_.length,R=f%k,P=f/k|0;for(_=_.slice();T--;)d=_[T]%k,m=_[T]/k|0,E=P*d+m*R,l=R*d+E%k*k+g,g=(l/p|0)+(E/k|0)+P*m,_[T]=l%p;if(g)_=[g].concat(_);return _}function a(_,f,p,E){var l,d;if(p!=E)d=p>E?1:-1;else for(l=d=0;l<p;l++)if(_[l]!=f[l]){d=_[l]>f[l]?1:-1;break}return d}function c(_,f,p,E){var l=0;for(;p--;)_[p]-=l,l=_[p]<f[p]?1:0,_[p]=l*E+_[p]-f[p];for(;!_[0]&&_.length>1;_.splice(0,1));}return function(_,f,p,E,l){var d,m,g,T,R,P,L,ee,se,M,K,ae,Nt,_r,yr,Re,dt,me=_.s==f.s?1:-1,ue=_.c,te=f.c;if(!ue||!ue[0]||!te||!te[0])return new v(!_.s||!f.s||(ue?te&&ue[0]==te[0]:!te)?NaN:ue&&ue[0]==0||!te?me*0:me/0);if(ee=new v(me),se=ee.c=[],m=_.e-f.e,me=p+m+1,!l)l=h,m=V(_.e/y)-V(f.e/y),me=me/y|0;for(g=0;te[g]==(ue[g]||0);g++);if(te[g]>(ue[g]||0))m--;if(me<0)se.push(1),T=!0;else{if(_r=ue.length,Re=te.length,g=0,me+=2,R=s(l/(te[0]+1)),R>1)te=o(te,R,l),ue=o(ue,R,l),Re=te.length,_r=ue.length;Nt=Re,M=ue.slice(0,Re),K=M.length;for(;K<Re;M[K++]=0);if(dt=te.slice(),dt=[0].concat(dt),yr=te[0],te[1]>=l/2)yr++;do{if(R=0,d=a(te,M,Re,K),d<0){if(ae=M[0],Re!=K)ae=ae*l+(M[1]||0);if(R=s(ae/yr),R>1){if(R>=l)R=l-1;P=o(te,R,l),L=P.length,K=M.length;while(a(P,M,L,K)==1)R--,c(P,Re<L?dt:te,L,l),L=P.length,d=1}else{if(R==0)d=R=1;P=te.slice(),L=P.length}if(L<K)P=[0].concat(P);if(c(M,P,K,l),K=M.length,d==-1)while(a(te,M,Re,K)<1)R++,c(M,Re<K?dt:te,K,l),K=M.length}else if(d===0)R++,M=[0];if(se[g++]=R,M[0])M[K++]=ue[Nt]||0;else M=[ue[Nt]],K=1}while((Nt++<_r||M[0]!=null)&&me--);if(T=M[0]!=null,!se[0])se.splice(0,1)}if(l==h){for(g=1,me=se[0];me>=10;me/=10,g++);ye(ee,p+(ee.e=g+m*y-1)+1,E,T)}else ee.e=m,ee.r=+T;return ee}}();function pr(o,a,c,_){var f,p,E,l,d;if(c==null)c=Z;else b(c,0,8);if(!o.c)return o.toString();if(f=o.c[0],E=o.e,a==null)d=x(o.c),d=_==1||_==2&&(E<=he||E>=fe)?re(d,E):ce(d,E,"0");else if(o=ye(new v(o),a,c),p=o.e,d=x(o.c),l=d.length,_==1||_==2&&(a<=p||p<=he)){for(;l<a;d+="0",l++);d=re(d,p)}else if(a-=E+(_===2&&p>E),d=ce(d,p,"0"),p+1>l){if(--a>0)for(d+=".";a--;d+="0");}else if(a+=p-l,a>0){if(p+1==l)d+=".";for(;a--;d+="0");}return o.s<0&&f?"-"+d:d}function Qn(o,a){var c,_,f=1,p=new v(o[0]);for(;f<o.length;f++)if(_=new v(o[f]),!_.s||(c=j(p,_))===a||c===0&&p.s===a)p=_;return p}function gr(o,a,c){var _=1,f=a.length;for(;!a[--f];a.pop());for(f=a[0];f>=10;f/=10,_++);if((c=_+c*y-1)>Se)o.c=o.e=null;else if(c<Ke)o.c=[o.e=0];else o.e=c,o.c=a;return o}X=function(){var o=/^(-?)0([xbo])(?=\w[\w.]*$)/i,a=/^([^.]+)\.$/,c=/^\.([^.]+)$/,_=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(p,E,l,d){var m,g=l?E:E.replace(f,"");if(_.test(g))p.s=isNaN(g)?null:g<0?-1:1;else{if(!l){if(g=g.replace(o,function(T,R,P){return m=(P=P.toLowerCase())=="x"?16:P=="b"?2:8,!d||d==m?R:T}),d)m=d,g=g.replace(a,"$1").replace(c,"0.$1");if(E!=g)return new v(g,m)}if(v.DEBUG)throw Error(i+"Not a"+(d?" base "+d:"")+" number: "+E);p.s=null}p.c=p.e=null}}();function ye(o,a,c,_){var f,p,E,l,d,m,g,T=o.c,R=A;if(T){e:{for(f=1,l=T[0];l>=10;l/=10,f++);if(p=a-f,p<0)p+=y,E=a,d=T[m=0],g=s(d/R[f-E-1]%10);else if(m=n((p+1)/y),m>=T.length)if(_){for(;T.length<=m;T.push(0));d=g=0,f=1,p%=y,E=p-y+1}else break e;else{d=l=T[m];for(f=1;l>=10;l/=10,f++);p%=y,E=p-y+f,g=E<0?0:s(d/R[f-E-1]%10)}if(_=_||a<0||T[m+1]!=null||(E<0?d:d%R[f-E-1]),_=c<4?(g||_)&&(c==0||c==(o.s<0?3:2)):g>5||g==5&&(c==4||_||c==6&&(p>0?E>0?d/R[f-E]:0:T[m-1])%10&1||c==(o.s<0?8:7)),a<1||!T[0]){if(T.length=0,_)a-=o.e+1,T[0]=R[(y-a%y)%y],o.e=-a||0;else T[0]=o.e=0;return o}if(p==0)T.length=m,l=1,m--;else T.length=m+1,l=R[y-p],T[m]=E>0?s(d/R[f-E]%R[E])*l:0;if(_)for(;;)if(m==0){for(p=1,E=T[0];E>=10;E/=10,p++);E=T[0]+=l;for(l=1;E>=10;E/=10,l++);if(p!=l){if(o.e++,T[0]==h)T[0]=1}break}else{if(T[m]+=l,T[m]!=h)break;T[m--]=0,l=1}for(p=T.length;T[--p]===0;T.pop());}if(o.e>Se)o.c=o.e=null;else if(o.e<Ke)o.c=[o.e=0]}return o}function je(o){var a,c=o.e;if(c===null)return o.toString();return a=x(o.c),a=c<=he||c>=fe?re(a,c):ce(a,c,"0"),o.s<0?"-"+a:a}if(C.absoluteValue=C.abs=function(){var o=new v(this);if(o.s<0)o.s=1;return o},C.comparedTo=function(o,a){return j(this,new v(o,a))},C.decimalPlaces=C.dp=function(o,a){var c,_,f,p=this;if(o!=null){if(b(o,0,N),a==null)a=Z;else b(a,0,8);return ye(new v(p),o+p.e+1,a)}if(!(c=p.c))return null;if(_=((f=c.length-1)-V(this.e/y))*y,f=c[f])for(;f%10==0;f/=10,_--);if(_<0)_=0;return _},C.dividedBy=C.div=function(o,a){return D(this,new v(o,a),Q,Z)},C.dividedToIntegerBy=C.idiv=function(o,a){return D(this,new v(o,a),0,1)},C.exponentiatedBy=C.pow=function(o,a){var c,_,f,p,E,l,d,m,g,T=this;if(o=new v(o),o.c&&!o.isInteger())throw Error(i+"Exponent not an integer: "+je(o));if(a!=null)a=new v(a);if(l=o.e>14,!T.c||!T.c[0]||T.c[0]==1&&!T.e&&T.c.length==1||!o.c||!o.c[0])return g=new v(Math.pow(+je(T),l?o.s*(2-H(o)):+je(o))),a?g.mod(a):g;if(d=o.s<0,a){if(a.c?!a.c[0]:!a.s)return new v(NaN);if(_=!d&&T.isInteger()&&a.isInteger(),_)T=T.mod(a)}else if(o.e>9&&(T.e>0||T.e<-1||(T.e==0?T.c[0]>1||l&&T.c[1]>=240000000:T.c[0]<80000000000000||l&&T.c[0]<=99999750000000))){if(p=T.s<0&&H(o)?-0:0,T.e>-1)p=1/p;return new v(d?1/p:p)}else if(Le)p=n(Le/y+2);if(l){if(c=new v(0.5),d)o.s=1;m=H(o)}else f=Math.abs(+je(o)),m=f%2;g=new v(ne);for(;;){if(m){if(g=g.times(T),!g.c)break;if(p){if(g.c.length>p)g.c.length=p}else if(_)g=g.mod(a)}if(f){if(f=s(f/2),f===0)break;m=f%2}else if(o=o.times(c),ye(o,o.e+1,1),o.e>14)m=H(o);else{if(f=+je(o),f===0)break;m=f%2}if(T=T.times(T),p){if(T.c&&T.c.length>p)T.c.length=p}else if(_)T=T.mod(a)}if(_)return g;if(d)g=ne.div(g);return a?g.mod(a):p?ye(g,Le,Z,E):g},C.integerValue=function(o){var a=new v(this);if(o==null)o=Z;else b(o,0,8);return ye(a,a.e+1,o)},C.isEqualTo=C.eq=function(o,a){return j(this,new v(o,a))===0},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(o,a){return j(this,new v(o,a))>0},C.isGreaterThanOrEqualTo=C.gte=function(o,a){return(a=j(this,new v(o,a)))===1||a===0},C.isInteger=function(){return!!this.c&&V(this.e/y)>this.c.length-2},C.isLessThan=C.lt=function(o,a){return j(this,new v(o,a))<0},C.isLessThanOrEqualTo=C.lte=function(o,a){return(a=j(this,new v(o,a)))===-1||a===0},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&this.c[0]==0},C.minus=function(o,a){var c,_,f,p,E=this,l=E.s;if(o=new v(o,a),a=o.s,!l||!a)return new v(NaN);if(l!=a)return o.s=-a,E.plus(o);var d=E.e/y,m=o.e/y,g=E.c,T=o.c;if(!d||!m){if(!g||!T)return g?(o.s=-a,o):new v(T?E:NaN);if(!g[0]||!T[0])return T[0]?(o.s=-a,o):new v(g[0]?E:Z==3?-0:0)}if(d=V(d),m=V(m),g=g.slice(),l=d-m){if(p=l<0)l=-l,f=g;else m=d,f=T;f.reverse();for(a=l;a--;f.push(0));f.reverse()}else{_=(p=(l=g.length)<(a=T.length))?l:a;for(l=a=0;a<_;a++)if(g[a]!=T[a]){p=g[a]<T[a];break}}if(p)f=g,g=T,T=f,o.s=-o.s;if(a=(_=T.length)-(c=g.length),a>0)for(;a--;g[c++]=0);a=h-1;for(;_>l;){if(g[--_]<T[_]){for(c=_;c&&!g[--c];g[c]=a);--g[c],g[_]+=h}g[_]-=T[_]}for(;g[0]==0;g.splice(0,1),--m);if(!g[0])return o.s=Z==3?-1:1,o.c=[o.e=0],o;return gr(o,g,m)},C.modulo=C.mod=function(o,a){var c,_,f=this;if(o=new v(o,a),!f.c||!o.s||o.c&&!o.c[0])return new v(NaN);else if(!o.c||f.c&&!f.c[0])return new v(f);if(ft==9)_=o.s,o.s=1,c=D(f,o,0,3),o.s=_,c.s*=_;else c=D(f,o,0,ft);if(o=f.minus(c.times(o)),!o.c[0]&&ft==1)o.s=f.s;return o},C.multipliedBy=C.times=function(o,a){var c,_,f,p,E,l,d,m,g,T,R,P,L,ee,se,M=this,K=M.c,ae=(o=new v(o,a)).c;if(!K||!ae||!K[0]||!ae[0]){if(!M.s||!o.s||K&&!K[0]&&!ae||ae&&!ae[0]&&!K)o.c=o.e=o.s=null;else if(o.s*=M.s,!K||!ae)o.c=o.e=null;else o.c=[0],o.e=0;return o}if(_=V(M.e/y)+V(o.e/y),o.s*=M.s,d=K.length,T=ae.length,d<T)L=K,K=ae,ae=L,f=d,d=T,T=f;for(f=d+T,L=[];f--;L.push(0));ee=h,se=k;for(f=T;--f>=0;){c=0,R=ae[f]%se,P=ae[f]/se|0;for(E=d,p=f+E;p>f;)m=K[--E]%se,g=K[E]/se|0,l=P*m+g*R,m=R*m+l%se*se+L[p]+c,c=(m/ee|0)+(l/se|0)+P*g,L[p--]=m%ee;L[p]=c}if(c)++_;else L.splice(0,1);return gr(o,L,_)},C.negated=function(){var o=new v(this);return o.s=-o.s||null,o},C.plus=function(o,a){var c,_=this,f=_.s;if(o=new v(o,a),a=o.s,!f||!a)return new v(NaN);if(f!=a)return o.s=-a,_.minus(o);var p=_.e/y,E=o.e/y,l=_.c,d=o.c;if(!p||!E){if(!l||!d)return new v(f/0);if(!l[0]||!d[0])return d[0]?o:new v(l[0]?_:f*0)}if(p=V(p),E=V(E),l=l.slice(),f=p-E){if(f>0)E=p,c=d;else f=-f,c=l;c.reverse();for(;f--;c.push(0));c.reverse()}if(f=l.length,a=d.length,f-a<0)c=d,d=l,l=c,a=f;for(f=0;a;)f=(l[--a]=l[a]+d[a]+f)/h|0,l[a]=h===l[a]?0:l[a]%h;if(f)l=[f].concat(l),++E;return gr(o,l,E)},C.precision=C.sd=function(o,a){var c,_,f,p=this;if(o!=null&&o!==!!o){if(b(o,1,N),a==null)a=Z;else b(a,0,8);return ye(new v(p),o,a)}if(!(c=p.c))return null;if(f=c.length-1,_=f*y+1,f=c[f]){for(;f%10==0;f/=10,_--);for(f=c[0];f>=10;f/=10,_++);}if(o&&p.e+1>_)_=p.e+1;return _},C.shiftedBy=function(o){return b(o,-S,S),this.times("1e"+o)},C.squareRoot=C.sqrt=function(){var o,a,c,_,f,p=this,{c:E,s:l,e:d}=p,m=Q+4,g=new v("0.5");if(l!==1||!E||!E[0])return new v(!l||l<0&&(!E||E[0])?NaN:E?p:1/0);if(l=Math.sqrt(+je(p)),l==0||l==1/0){if(a=x(E),(a.length+d)%2==0)a+="0";if(l=Math.sqrt(+a),d=V((d+1)/2)-(d<0||d%2),l==1/0)a="5e"+d;else a=l.toExponential(),a=a.slice(0,a.indexOf("e")+1)+d;c=new v(a)}else c=new v(l+"");if(c.c[0]){if(d=c.e,l=d+m,l<3)l=0;for(;;)if(f=c,c=g.times(f.plus(D(p,f,m,1))),x(f.c).slice(0,l)===(a=x(c.c)).slice(0,l)){if(c.e<d)--l;if(a=a.slice(l-3,l+1),a=="9999"||!_&&a=="4999"){if(!_){if(ye(f,f.e+Q+2,0),f.times(f).eq(p)){c=f;break}}m+=4,l+=4,_=1}else{if(!+a||!+a.slice(1)&&a.charAt(0)=="5")ye(c,c.e+Q+2,1),o=!c.times(c).eq(p);break}}}return ye(c,c.e+Q+1,Z,o)},C.toExponential=function(o,a){if(o!=null)b(o,0,N),o++;return pr(this,o,a,1)},C.toFixed=function(o,a){if(o!=null)b(o,0,N),o=o+this.e+1;return pr(this,o,a)},C.toFormat=function(o,a,c){var _,f=this;if(c==null)if(o!=null&&a&&typeof a=="object")c=a,a=null;else if(o&&typeof o=="object")c=o,o=a=null;else c=fr;else if(typeof c!="object")throw Error(i+"Argument not an object: "+c);if(_=f.toFixed(o,a),f.c){var p,E=_.split("."),l=+c.groupSize,d=+c.secondaryGroupSize,m=c.groupSeparator||"",g=E[0],T=E[1],R=f.s<0,P=R?g.slice(1):g,L=P.length;if(d)p=l,l=d,d=p,L-=p;if(l>0&&L>0){p=L%l||l,g=P.substr(0,p);for(;p<L;p+=l)g+=m+P.substr(p,l);if(d>0)g+=m+P.slice(p);if(R)g="-"+g}_=T?g+(c.decimalSeparator||"")+((d=+c.fractionGroupSize)?T.replace(new RegExp("\\d{"+d+"}\\B","g"),"$&"+(c.fractionGroupSeparator||"")):T):g}return(c.prefix||"")+_+(c.suffix||"")},C.toFraction=function(o){var a,c,_,f,p,E,l,d,m,g,T,R,P=this,L=P.c;if(o!=null){if(l=new v(o),!l.isInteger()&&(l.c||l.s!==1)||l.lt(ne))throw Error(i+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+je(l))}if(!L)return new v(P);a=new v(ne),m=c=new v(ne),_=d=new v(ne),R=x(L),p=a.e=R.length-P.e-1,a.c[0]=A[(E=p%y)<0?y+E:E],o=!o||l.comparedTo(a)>0?p>0?a:m:l,E=Se,Se=1/0,l=new v(R),d.c[0]=0;for(;;){if(g=D(l,a,0,1),f=c.plus(g.times(_)),f.comparedTo(o)==1)break;c=_,_=f,m=d.plus(g.times(f=m)),d=f,a=l.minus(g.times(f=a)),l=f}return f=D(o.minus(c),_,0,1),d=d.plus(f.times(m)),c=c.plus(f.times(_)),d.s=m.s=P.s,p=p*2,T=D(m,_,p,Z).minus(P).abs().comparedTo(D(d,c,p,Z).minus(P).abs())<1?[m,_]:[d,c],Se=E,T},C.toNumber=function(){return+je(this)},C.toPrecision=function(o,a){if(o!=null)b(o,1,N);return pr(this,o,a,2)},C.toString=function(o){var a,c=this,_=c.s,f=c.e;if(f===null)if(_){if(a="Infinity",_<0)a="-"+a}else a="NaN";else{if(o==null)a=f<=he||f>=fe?re(x(c.c),f):ce(x(c.c),f,"0");else if(o===10&&dr)c=ye(new v(c),Q+f+1,Z),a=ce(x(c.c),c.e,"0");else b(o,2,Ve.length,"Base"),a=B(ce(x(c.c),f,"0"),10,o,_,!0);if(_<0&&c.c[0])a="-"+a}return a},C.valueOf=C.toJSON=function(){return je(this)},C._isBigNumber=!0,U!=null)v.set(U);return v}function V(U){var D=U|0;return U>0||U===D?D:D-1}function x(U){var D,B,X=1,C=U.length,ne=U[0]+"";for(;X<C;){D=U[X++]+"",B=y-D.length;for(;B--;D="0"+D);ne+=D}for(C=ne.length;ne.charCodeAt(--C)===48;);return ne.slice(0,C+1||1)}function j(U,D){var B,X,C=U.c,ne=D.c,Q=U.s,Z=D.s,he=U.e,fe=D.e;if(!Q||!Z)return null;if(B=C&&!C[0],X=ne&&!ne[0],B||X)return B?X?0:-Z:Q;if(Q!=Z)return Q;if(B=Q<0,X=he==fe,!C||!ne)return X?0:!C^B?1:-1;if(!X)return he>fe^B?1:-1;Z=(he=C.length)<(fe=ne.length)?he:fe;for(Q=0;Q<Z;Q++)if(C[Q]!=ne[Q])return C[Q]>ne[Q]^B?1:-1;return he==fe?0:he>fe^B?1:-1}function b(U,D,B,X){if(U<D||U>B||U!==s(U))throw Error(i+(X||"Argument")+(typeof U=="number"?U<D||U>B?" out of range: ":" not an integer: ":" not a primitive number: ")+String(U))}function H(U){var D=U.c.length-1;return V(U.e/y)==D&&U.c[D]%2!=0}function re(U,D){return(U.length>1?U.charAt(0)+"."+U.slice(1):U)+(D<0?"e":"e+")+D}function ce(U,D,B){var X,C;if(D<0){for(C=B+".";++D;C+=B);U=C+U}else if(X=U.length,++D>X){for(C=B,D-=X;--D;C+=B);U+=C}else if(D<X)U=U.slice(0,D)+"."+U.slice(D);return U}if(t=F(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd)define(function(){return t});else if(typeof jt<"u"&&jt.exports)jt.exports=t;else{if(!e)e=typeof self<"u"&&self?self:window;e.BigNumber=t}})(bs)});var Ps=w(function(cg,Ns){var xs=Or(),Rs=cg;(function(){function e(S){return S<10?"0"+S:S}var t=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,r=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n,s,i={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':"\\\"","\\":"\\\\"},u;function h(S){return r.lastIndex=0,r.test(S)?'"'+S.replace(r,function(A){var k=i[A];return typeof k==="string"?k:"\\u"+("0000"+A.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+S+'"'}function y(S,A){var k,N,F,V,x=n,j,b=A[S],H=b!=null&&(b instanceof xs||xs.isBigNumber(b));if(b&&typeof b==="object"&&typeof b.toJSON==="function")b=b.toJSON(S);if(typeof u==="function")b=u.call(A,S,b);switch(typeof b){case"string":if(H)return b;else return h(b);case"number":return isFinite(b)?String(b):"null";case"boolean":case"null":case"bigint":return String(b);case"object":if(!b)return"null";if(n+=s,j=[],Object.prototype.toString.apply(b)==="[object Array]"){V=b.length;for(k=0;k<V;k+=1)j[k]=y(k,b)||"null";return F=j.length===0?"[]":n?`[
7
+ `}yield r}static#i;static#o;static async#a(){return this.#i||=(await import("./chunk-zbt4h7n0.js").then((m)=>z(m.default))).HttpsProxyAgent,this.#i}static async#c(){let e=typeof window<"u"&&!!window;return this.#o||=e?window.fetch:(await import("node-fetch")).default,this.#o}static mergeHeaders(e,...t){e=e instanceof Headers?e:new Headers(e);for(let r of t)(r instanceof Headers?r:new Headers(r)).forEach((s,i)=>{i==="set-cookie"?e.append(i,s):e.set(i,s)});return e}}et.Gaxios=Cr;Ze=Cr});var ie=w(function(le){var Iu=le&&le.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),ju=le&&le.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Iu(t,e,r)};Object.defineProperty(le,"__esModule",{value:!0});le.instance=le.Gaxios=le.GaxiosError=void 0;le.request=Uu;var ks=Os();Object.defineProperty(le,"Gaxios",{enumerable:!0,get:function(){return ks.Gaxios}});var Du=vr();Object.defineProperty(le,"GaxiosError",{enumerable:!0,get:function(){return Du.GaxiosError}});ju(Sr(),le);le.instance=new ks.Gaxios;async function Uu(e){return le.instance.request(e)}});var Or=w(function(bs,jt){(function(e){var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,{ceil:n,floor:s}=Math,i="[BigNumber Error] ",u=i+"Number primitive has more than 15 significant digits: ",h=100000000000000,y=14,S=9007199254740991,A=[1,10,100,1000,1e4,1e5,1e6,1e7,1e8,1e9,10000000000,100000000000,1000000000000,10000000000000],k=1e7,N=1e9;function F(U){var D,B,X,C=v.prototype={constructor:v,toString:null,valueOf:null},ne=new v(1),Q=20,Z=4,he=-7,fe=21,Ke=-1e7,Se=1e7,Je=!1,ft=1,Le=0,fr={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Ve="0123456789abcdefghijklmnopqrstuvwxyz",dr=!0;function v(o,a){var c,_,f,p,E,l,d,m,g=this;if(!(g instanceof v))return new v(o,a);if(a==null){if(o&&o._isBigNumber===!0){if(g.s=o.s,!o.c||o.e>Se)g.c=g.e=null;else if(o.e<Ke)g.c=[g.e=0];else g.e=o.e,g.c=o.c.slice();return}if((l=typeof o=="number")&&o*0==0){if(g.s=1/o<0?(o=-o,-1):1,o===~~o){for(p=0,E=o;E>=10;E/=10,p++);if(p>Se)g.c=g.e=null;else g.e=p,g.c=[o];return}m=String(o)}else{if(!r.test(m=String(o)))return X(g,m,l);g.s=m.charCodeAt(0)==45?(m=m.slice(1),-1):1}if((p=m.indexOf("."))>-1)m=m.replace(".","");if((E=m.search(/e/i))>0){if(p<0)p=E;p+=+m.slice(E+1),m=m.substring(0,E)}else if(p<0)p=m.length}else{if(b(a,2,Ve.length,"Base"),a==10&&dr)return g=new v(o),ye(g,Q+g.e+1,Z);if(m=String(o),l=typeof o=="number"){if(o*0!=0)return X(g,m,l,a);if(g.s=1/o<0?(m=m.slice(1),-1):1,v.DEBUG&&m.replace(/^0\.0*|\./,"").length>15)throw Error(u+o)}else g.s=m.charCodeAt(0)===45?(m=m.slice(1),-1):1;c=Ve.slice(0,a),p=E=0;for(d=m.length;E<d;E++)if(c.indexOf(_=m.charAt(E))<0){if(_=="."){if(E>p){p=d;continue}}else if(!f){if(m==m.toUpperCase()&&(m=m.toLowerCase())||m==m.toLowerCase()&&(m=m.toUpperCase())){f=!0,E=-1,p=0;continue}}return X(g,String(o),l,a)}if(l=!1,m=B(m,a,10,g.s),(p=m.indexOf("."))>-1)m=m.replace(".","");else p=m.length}for(E=0;m.charCodeAt(E)===48;E++);for(d=m.length;m.charCodeAt(--d)===48;);if(m=m.slice(E,++d)){if(d-=E,l&&v.DEBUG&&d>15&&(o>S||o!==s(o)))throw Error(u+g.s*o);if((p=p-E-1)>Se)g.c=g.e=null;else if(p<Ke)g.c=[g.e=0];else{if(g.e=p,g.c=[],E=(p+1)%y,p<0)E+=y;if(E<d){if(E)g.c.push(+m.slice(0,E));for(d-=y;E<d;)g.c.push(+m.slice(E,E+=y));E=y-(m=m.slice(E)).length}else E-=d;for(;E--;m+="0");g.c.push(+m)}}else g.c=[g.e=0]}v.clone=F,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(o){var a,c;if(o!=null)if(typeof o=="object"){if(o.hasOwnProperty(a="DECIMAL_PLACES"))c=o[a],b(c,0,N,a),Q=c;if(o.hasOwnProperty(a="ROUNDING_MODE"))c=o[a],b(c,0,8,a),Z=c;if(o.hasOwnProperty(a="EXPONENTIAL_AT"))if(c=o[a],c&&c.pop)b(c[0],-N,0,a),b(c[1],0,N,a),he=c[0],fe=c[1];else b(c,-N,N,a),he=-(fe=c<0?-c:c);if(o.hasOwnProperty(a="RANGE"))if(c=o[a],c&&c.pop)b(c[0],-N,-1,a),b(c[1],1,N,a),Ke=c[0],Se=c[1];else if(b(c,-N,N,a),c)Ke=-(Se=c<0?-c:c);else throw Error(i+a+" cannot be zero: "+c);if(o.hasOwnProperty(a="CRYPTO"))if(c=o[a],c===!!c)if(c)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))Je=c;else throw Je=!c,Error(i+"crypto unavailable");else Je=c;else throw Error(i+a+" not true or false: "+c);if(o.hasOwnProperty(a="MODULO_MODE"))c=o[a],b(c,0,9,a),ft=c;if(o.hasOwnProperty(a="POW_PRECISION"))c=o[a],b(c,0,N,a),Le=c;if(o.hasOwnProperty(a="FORMAT"))if(c=o[a],typeof c=="object")fr=c;else throw Error(i+a+" not an object: "+c);if(o.hasOwnProperty(a="ALPHABET"))if(c=o[a],typeof c=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(c))dr=c.slice(0,10)=="0123456789",Ve=c;else throw Error(i+a+" invalid: "+c)}else throw Error(i+"Object expected: "+o);return{DECIMAL_PLACES:Q,ROUNDING_MODE:Z,EXPONENTIAL_AT:[he,fe],RANGE:[Ke,Se],CRYPTO:Je,MODULO_MODE:ft,POW_PRECISION:Le,FORMAT:fr,ALPHABET:Ve}},v.isBigNumber=function(o){if(!o||o._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var a,c,{c:_,e:f,s:p}=o;e:if({}.toString.call(_)=="[object Array]"){if((p===1||p===-1)&&f>=-N&&f<=N&&f===s(f)){if(_[0]===0){if(f===0&&_.length===1)return!0;break e}if(a=(f+1)%y,a<1)a+=y;if(String(_[0]).length==a){for(a=0;a<_.length;a++)if(c=_[a],c<0||c>=h||c!==s(c))break e;if(c!==0)return!0}}}else if(_===null&&f===null&&(p===null||p===1||p===-1))return!0;throw Error(i+"Invalid BigNumber: "+o)},v.maximum=v.max=function(){return Qn(arguments,-1)},v.minimum=v.min=function(){return Qn(arguments,1)},v.random=function(){var o=9007199254740992,a=Math.random()*o&2097151?function(){return s(Math.random()*o)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(c){var _,f,p,E,l,d=0,m=[],g=new v(ne);if(c==null)c=Q;else b(c,0,N);if(E=n(c/y),Je)if(crypto.getRandomValues){_=crypto.getRandomValues(new Uint32Array(E*=2));for(;d<E;)if(l=_[d]*131072+(_[d+1]>>>11),l>=9000000000000000)f=crypto.getRandomValues(new Uint32Array(2)),_[d]=f[0],_[d+1]=f[1];else m.push(l%100000000000000),d+=2;d=E/2}else if(crypto.randomBytes){_=crypto.randomBytes(E*=7);for(;d<E;)if(l=(_[d]&31)*281474976710656+_[d+1]*1099511627776+_[d+2]*4294967296+_[d+3]*16777216+(_[d+4]<<16)+(_[d+5]<<8)+_[d+6],l>=9000000000000000)crypto.randomBytes(7).copy(_,d);else m.push(l%100000000000000),d+=7;d=E/7}else throw Je=!1,Error(i+"crypto unavailable");if(!Je){for(;d<E;)if(l=a(),l<9000000000000000)m[d++]=l%100000000000000}if(E=m[--d],c%=y,E&&c)l=A[y-c],m[d]=s(E/l)*l;for(;m[d]===0;m.pop(),d--);if(d<0)m=[p=0];else{for(p=-1;m[0]===0;m.splice(0,1),p-=y);for(d=1,l=m[0];l>=10;l/=10,d++);if(d<y)p-=y-d}return g.e=p,g.c=m,g}}(),v.sum=function(){var o=1,a=arguments,c=new v(a[0]);for(;o<a.length;)c=c.plus(a[o++]);return c},B=function(){var o="0123456789";function a(c,_,f,p){var E,l=[0],d,m=0,g=c.length;for(;m<g;){for(d=l.length;d--;l[d]*=_);l[0]+=p.indexOf(c.charAt(m++));for(E=0;E<l.length;E++)if(l[E]>f-1){if(l[E+1]==null)l[E+1]=0;l[E+1]+=l[E]/f|0,l[E]%=f}}return l.reverse()}return function(c,_,f,p,E){var l,d,m,g,T,R,P,L,ee=c.indexOf("."),se=Q,M=Z;if(ee>=0)g=Le,Le=0,c=c.replace(".",""),L=new v(_),R=L.pow(c.length-ee),Le=g,L.c=a(ce(x(R.c),R.e,"0"),10,f,o),L.e=L.c.length;P=a(c,_,f,E?(l=Ve,o):(l=o,Ve)),m=g=P.length;for(;P[--g]==0;P.pop());if(!P[0])return l.charAt(0);if(ee<0)--m;else R.c=P,R.e=m,R.s=p,R=D(R,L,se,M,f),P=R.c,T=R.r,m=R.e;if(d=m+se+1,ee=P[d],g=f/2,T=T||d<0||P[d+1]!=null,T=M<4?(ee!=null||T)&&(M==0||M==(R.s<0?3:2)):ee>g||ee==g&&(M==4||T||M==6&&P[d-1]&1||M==(R.s<0?8:7)),d<1||!P[0])c=T?ce(l.charAt(1),-se,l.charAt(0)):l.charAt(0);else{if(P.length=d,T){for(--f;++P[--d]>f;)if(P[d]=0,!d)++m,P=[1].concat(P)}for(g=P.length;!P[--g];);for(ee=0,c="";ee<=g;c+=l.charAt(P[ee++]));c=ce(c,m,l.charAt(0))}return c}}(),D=function(){function o(_,f,p){var E,l,d,m,g=0,T=_.length,R=f%k,P=f/k|0;for(_=_.slice();T--;)d=_[T]%k,m=_[T]/k|0,E=P*d+m*R,l=R*d+E%k*k+g,g=(l/p|0)+(E/k|0)+P*m,_[T]=l%p;if(g)_=[g].concat(_);return _}function a(_,f,p,E){var l,d;if(p!=E)d=p>E?1:-1;else for(l=d=0;l<p;l++)if(_[l]!=f[l]){d=_[l]>f[l]?1:-1;break}return d}function c(_,f,p,E){var l=0;for(;p--;)_[p]-=l,l=_[p]<f[p]?1:0,_[p]=l*E+_[p]-f[p];for(;!_[0]&&_.length>1;_.splice(0,1));}return function(_,f,p,E,l){var d,m,g,T,R,P,L,ee,se,M,K,ae,Nt,_r,yr,Re,dt,me=_.s==f.s?1:-1,ue=_.c,te=f.c;if(!ue||!ue[0]||!te||!te[0])return new v(!_.s||!f.s||(ue?te&&ue[0]==te[0]:!te)?NaN:ue&&ue[0]==0||!te?me*0:me/0);if(ee=new v(me),se=ee.c=[],m=_.e-f.e,me=p+m+1,!l)l=h,m=V(_.e/y)-V(f.e/y),me=me/y|0;for(g=0;te[g]==(ue[g]||0);g++);if(te[g]>(ue[g]||0))m--;if(me<0)se.push(1),T=!0;else{if(_r=ue.length,Re=te.length,g=0,me+=2,R=s(l/(te[0]+1)),R>1)te=o(te,R,l),ue=o(ue,R,l),Re=te.length,_r=ue.length;Nt=Re,M=ue.slice(0,Re),K=M.length;for(;K<Re;M[K++]=0);if(dt=te.slice(),dt=[0].concat(dt),yr=te[0],te[1]>=l/2)yr++;do{if(R=0,d=a(te,M,Re,K),d<0){if(ae=M[0],Re!=K)ae=ae*l+(M[1]||0);if(R=s(ae/yr),R>1){if(R>=l)R=l-1;P=o(te,R,l),L=P.length,K=M.length;while(a(P,M,L,K)==1)R--,c(P,Re<L?dt:te,L,l),L=P.length,d=1}else{if(R==0)d=R=1;P=te.slice(),L=P.length}if(L<K)P=[0].concat(P);if(c(M,P,K,l),K=M.length,d==-1)while(a(te,M,Re,K)<1)R++,c(M,Re<K?dt:te,K,l),K=M.length}else if(d===0)R++,M=[0];if(se[g++]=R,M[0])M[K++]=ue[Nt]||0;else M=[ue[Nt]],K=1}while((Nt++<_r||M[0]!=null)&&me--);if(T=M[0]!=null,!se[0])se.splice(0,1)}if(l==h){for(g=1,me=se[0];me>=10;me/=10,g++);ye(ee,p+(ee.e=g+m*y-1)+1,E,T)}else ee.e=m,ee.r=+T;return ee}}();function pr(o,a,c,_){var f,p,E,l,d;if(c==null)c=Z;else b(c,0,8);if(!o.c)return o.toString();if(f=o.c[0],E=o.e,a==null)d=x(o.c),d=_==1||_==2&&(E<=he||E>=fe)?re(d,E):ce(d,E,"0");else if(o=ye(new v(o),a,c),p=o.e,d=x(o.c),l=d.length,_==1||_==2&&(a<=p||p<=he)){for(;l<a;d+="0",l++);d=re(d,p)}else if(a-=E+(_===2&&p>E),d=ce(d,p,"0"),p+1>l){if(--a>0)for(d+=".";a--;d+="0");}else if(a+=p-l,a>0){if(p+1==l)d+=".";for(;a--;d+="0");}return o.s<0&&f?"-"+d:d}function Qn(o,a){var c,_,f=1,p=new v(o[0]);for(;f<o.length;f++)if(_=new v(o[f]),!_.s||(c=j(p,_))===a||c===0&&p.s===a)p=_;return p}function gr(o,a,c){var _=1,f=a.length;for(;!a[--f];a.pop());for(f=a[0];f>=10;f/=10,_++);if((c=_+c*y-1)>Se)o.c=o.e=null;else if(c<Ke)o.c=[o.e=0];else o.e=c,o.c=a;return o}X=function(){var o=/^(-?)0([xbo])(?=\w[\w.]*$)/i,a=/^([^.]+)\.$/,c=/^\.([^.]+)$/,_=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(p,E,l,d){var m,g=l?E:E.replace(f,"");if(_.test(g))p.s=isNaN(g)?null:g<0?-1:1;else{if(!l){if(g=g.replace(o,function(T,R,P){return m=(P=P.toLowerCase())=="x"?16:P=="b"?2:8,!d||d==m?R:T}),d)m=d,g=g.replace(a,"$1").replace(c,"0.$1");if(E!=g)return new v(g,m)}if(v.DEBUG)throw Error(i+"Not a"+(d?" base "+d:"")+" number: "+E);p.s=null}p.c=p.e=null}}();function ye(o,a,c,_){var f,p,E,l,d,m,g,T=o.c,R=A;if(T){e:{for(f=1,l=T[0];l>=10;l/=10,f++);if(p=a-f,p<0)p+=y,E=a,d=T[m=0],g=s(d/R[f-E-1]%10);else if(m=n((p+1)/y),m>=T.length)if(_){for(;T.length<=m;T.push(0));d=g=0,f=1,p%=y,E=p-y+1}else break e;else{d=l=T[m];for(f=1;l>=10;l/=10,f++);p%=y,E=p-y+f,g=E<0?0:s(d/R[f-E-1]%10)}if(_=_||a<0||T[m+1]!=null||(E<0?d:d%R[f-E-1]),_=c<4?(g||_)&&(c==0||c==(o.s<0?3:2)):g>5||g==5&&(c==4||_||c==6&&(p>0?E>0?d/R[f-E]:0:T[m-1])%10&1||c==(o.s<0?8:7)),a<1||!T[0]){if(T.length=0,_)a-=o.e+1,T[0]=R[(y-a%y)%y],o.e=-a||0;else T[0]=o.e=0;return o}if(p==0)T.length=m,l=1,m--;else T.length=m+1,l=R[y-p],T[m]=E>0?s(d/R[f-E]%R[E])*l:0;if(_)for(;;)if(m==0){for(p=1,E=T[0];E>=10;E/=10,p++);E=T[0]+=l;for(l=1;E>=10;E/=10,l++);if(p!=l){if(o.e++,T[0]==h)T[0]=1}break}else{if(T[m]+=l,T[m]!=h)break;T[m--]=0,l=1}for(p=T.length;T[--p]===0;T.pop());}if(o.e>Se)o.c=o.e=null;else if(o.e<Ke)o.c=[o.e=0]}return o}function je(o){var a,c=o.e;if(c===null)return o.toString();return a=x(o.c),a=c<=he||c>=fe?re(a,c):ce(a,c,"0"),o.s<0?"-"+a:a}if(C.absoluteValue=C.abs=function(){var o=new v(this);if(o.s<0)o.s=1;return o},C.comparedTo=function(o,a){return j(this,new v(o,a))},C.decimalPlaces=C.dp=function(o,a){var c,_,f,p=this;if(o!=null){if(b(o,0,N),a==null)a=Z;else b(a,0,8);return ye(new v(p),o+p.e+1,a)}if(!(c=p.c))return null;if(_=((f=c.length-1)-V(this.e/y))*y,f=c[f])for(;f%10==0;f/=10,_--);if(_<0)_=0;return _},C.dividedBy=C.div=function(o,a){return D(this,new v(o,a),Q,Z)},C.dividedToIntegerBy=C.idiv=function(o,a){return D(this,new v(o,a),0,1)},C.exponentiatedBy=C.pow=function(o,a){var c,_,f,p,E,l,d,m,g,T=this;if(o=new v(o),o.c&&!o.isInteger())throw Error(i+"Exponent not an integer: "+je(o));if(a!=null)a=new v(a);if(l=o.e>14,!T.c||!T.c[0]||T.c[0]==1&&!T.e&&T.c.length==1||!o.c||!o.c[0])return g=new v(Math.pow(+je(T),l?o.s*(2-H(o)):+je(o))),a?g.mod(a):g;if(d=o.s<0,a){if(a.c?!a.c[0]:!a.s)return new v(NaN);if(_=!d&&T.isInteger()&&a.isInteger(),_)T=T.mod(a)}else if(o.e>9&&(T.e>0||T.e<-1||(T.e==0?T.c[0]>1||l&&T.c[1]>=240000000:T.c[0]<80000000000000||l&&T.c[0]<=99999750000000))){if(p=T.s<0&&H(o)?-0:0,T.e>-1)p=1/p;return new v(d?1/p:p)}else if(Le)p=n(Le/y+2);if(l){if(c=new v(0.5),d)o.s=1;m=H(o)}else f=Math.abs(+je(o)),m=f%2;g=new v(ne);for(;;){if(m){if(g=g.times(T),!g.c)break;if(p){if(g.c.length>p)g.c.length=p}else if(_)g=g.mod(a)}if(f){if(f=s(f/2),f===0)break;m=f%2}else if(o=o.times(c),ye(o,o.e+1,1),o.e>14)m=H(o);else{if(f=+je(o),f===0)break;m=f%2}if(T=T.times(T),p){if(T.c&&T.c.length>p)T.c.length=p}else if(_)T=T.mod(a)}if(_)return g;if(d)g=ne.div(g);return a?g.mod(a):p?ye(g,Le,Z,E):g},C.integerValue=function(o){var a=new v(this);if(o==null)o=Z;else b(o,0,8);return ye(a,a.e+1,o)},C.isEqualTo=C.eq=function(o,a){return j(this,new v(o,a))===0},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(o,a){return j(this,new v(o,a))>0},C.isGreaterThanOrEqualTo=C.gte=function(o,a){return(a=j(this,new v(o,a)))===1||a===0},C.isInteger=function(){return!!this.c&&V(this.e/y)>this.c.length-2},C.isLessThan=C.lt=function(o,a){return j(this,new v(o,a))<0},C.isLessThanOrEqualTo=C.lte=function(o,a){return(a=j(this,new v(o,a)))===-1||a===0},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&this.c[0]==0},C.minus=function(o,a){var c,_,f,p,E=this,l=E.s;if(o=new v(o,a),a=o.s,!l||!a)return new v(NaN);if(l!=a)return o.s=-a,E.plus(o);var d=E.e/y,m=o.e/y,g=E.c,T=o.c;if(!d||!m){if(!g||!T)return g?(o.s=-a,o):new v(T?E:NaN);if(!g[0]||!T[0])return T[0]?(o.s=-a,o):new v(g[0]?E:Z==3?-0:0)}if(d=V(d),m=V(m),g=g.slice(),l=d-m){if(p=l<0)l=-l,f=g;else m=d,f=T;f.reverse();for(a=l;a--;f.push(0));f.reverse()}else{_=(p=(l=g.length)<(a=T.length))?l:a;for(l=a=0;a<_;a++)if(g[a]!=T[a]){p=g[a]<T[a];break}}if(p)f=g,g=T,T=f,o.s=-o.s;if(a=(_=T.length)-(c=g.length),a>0)for(;a--;g[c++]=0);a=h-1;for(;_>l;){if(g[--_]<T[_]){for(c=_;c&&!g[--c];g[c]=a);--g[c],g[_]+=h}g[_]-=T[_]}for(;g[0]==0;g.splice(0,1),--m);if(!g[0])return o.s=Z==3?-1:1,o.c=[o.e=0],o;return gr(o,g,m)},C.modulo=C.mod=function(o,a){var c,_,f=this;if(o=new v(o,a),!f.c||!o.s||o.c&&!o.c[0])return new v(NaN);else if(!o.c||f.c&&!f.c[0])return new v(f);if(ft==9)_=o.s,o.s=1,c=D(f,o,0,3),o.s=_,c.s*=_;else c=D(f,o,0,ft);if(o=f.minus(c.times(o)),!o.c[0]&&ft==1)o.s=f.s;return o},C.multipliedBy=C.times=function(o,a){var c,_,f,p,E,l,d,m,g,T,R,P,L,ee,se,M=this,K=M.c,ae=(o=new v(o,a)).c;if(!K||!ae||!K[0]||!ae[0]){if(!M.s||!o.s||K&&!K[0]&&!ae||ae&&!ae[0]&&!K)o.c=o.e=o.s=null;else if(o.s*=M.s,!K||!ae)o.c=o.e=null;else o.c=[0],o.e=0;return o}if(_=V(M.e/y)+V(o.e/y),o.s*=M.s,d=K.length,T=ae.length,d<T)L=K,K=ae,ae=L,f=d,d=T,T=f;for(f=d+T,L=[];f--;L.push(0));ee=h,se=k;for(f=T;--f>=0;){c=0,R=ae[f]%se,P=ae[f]/se|0;for(E=d,p=f+E;p>f;)m=K[--E]%se,g=K[E]/se|0,l=P*m+g*R,m=R*m+l%se*se+L[p]+c,c=(m/ee|0)+(l/se|0)+P*g,L[p--]=m%ee;L[p]=c}if(c)++_;else L.splice(0,1);return gr(o,L,_)},C.negated=function(){var o=new v(this);return o.s=-o.s||null,o},C.plus=function(o,a){var c,_=this,f=_.s;if(o=new v(o,a),a=o.s,!f||!a)return new v(NaN);if(f!=a)return o.s=-a,_.minus(o);var p=_.e/y,E=o.e/y,l=_.c,d=o.c;if(!p||!E){if(!l||!d)return new v(f/0);if(!l[0]||!d[0])return d[0]?o:new v(l[0]?_:f*0)}if(p=V(p),E=V(E),l=l.slice(),f=p-E){if(f>0)E=p,c=d;else f=-f,c=l;c.reverse();for(;f--;c.push(0));c.reverse()}if(f=l.length,a=d.length,f-a<0)c=d,d=l,l=c,a=f;for(f=0;a;)f=(l[--a]=l[a]+d[a]+f)/h|0,l[a]=h===l[a]?0:l[a]%h;if(f)l=[f].concat(l),++E;return gr(o,l,E)},C.precision=C.sd=function(o,a){var c,_,f,p=this;if(o!=null&&o!==!!o){if(b(o,1,N),a==null)a=Z;else b(a,0,8);return ye(new v(p),o,a)}if(!(c=p.c))return null;if(f=c.length-1,_=f*y+1,f=c[f]){for(;f%10==0;f/=10,_--);for(f=c[0];f>=10;f/=10,_++);}if(o&&p.e+1>_)_=p.e+1;return _},C.shiftedBy=function(o){return b(o,-S,S),this.times("1e"+o)},C.squareRoot=C.sqrt=function(){var o,a,c,_,f,p=this,{c:E,s:l,e:d}=p,m=Q+4,g=new v("0.5");if(l!==1||!E||!E[0])return new v(!l||l<0&&(!E||E[0])?NaN:E?p:1/0);if(l=Math.sqrt(+je(p)),l==0||l==1/0){if(a=x(E),(a.length+d)%2==0)a+="0";if(l=Math.sqrt(+a),d=V((d+1)/2)-(d<0||d%2),l==1/0)a="5e"+d;else a=l.toExponential(),a=a.slice(0,a.indexOf("e")+1)+d;c=new v(a)}else c=new v(l+"");if(c.c[0]){if(d=c.e,l=d+m,l<3)l=0;for(;;)if(f=c,c=g.times(f.plus(D(p,f,m,1))),x(f.c).slice(0,l)===(a=x(c.c)).slice(0,l)){if(c.e<d)--l;if(a=a.slice(l-3,l+1),a=="9999"||!_&&a=="4999"){if(!_){if(ye(f,f.e+Q+2,0),f.times(f).eq(p)){c=f;break}}m+=4,l+=4,_=1}else{if(!+a||!+a.slice(1)&&a.charAt(0)=="5")ye(c,c.e+Q+2,1),o=!c.times(c).eq(p);break}}}return ye(c,c.e+Q+1,Z,o)},C.toExponential=function(o,a){if(o!=null)b(o,0,N),o++;return pr(this,o,a,1)},C.toFixed=function(o,a){if(o!=null)b(o,0,N),o=o+this.e+1;return pr(this,o,a)},C.toFormat=function(o,a,c){var _,f=this;if(c==null)if(o!=null&&a&&typeof a=="object")c=a,a=null;else if(o&&typeof o=="object")c=o,o=a=null;else c=fr;else if(typeof c!="object")throw Error(i+"Argument not an object: "+c);if(_=f.toFixed(o,a),f.c){var p,E=_.split("."),l=+c.groupSize,d=+c.secondaryGroupSize,m=c.groupSeparator||"",g=E[0],T=E[1],R=f.s<0,P=R?g.slice(1):g,L=P.length;if(d)p=l,l=d,d=p,L-=p;if(l>0&&L>0){p=L%l||l,g=P.substr(0,p);for(;p<L;p+=l)g+=m+P.substr(p,l);if(d>0)g+=m+P.slice(p);if(R)g="-"+g}_=T?g+(c.decimalSeparator||"")+((d=+c.fractionGroupSize)?T.replace(new RegExp("\\d{"+d+"}\\B","g"),"$&"+(c.fractionGroupSeparator||"")):T):g}return(c.prefix||"")+_+(c.suffix||"")},C.toFraction=function(o){var a,c,_,f,p,E,l,d,m,g,T,R,P=this,L=P.c;if(o!=null){if(l=new v(o),!l.isInteger()&&(l.c||l.s!==1)||l.lt(ne))throw Error(i+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+je(l))}if(!L)return new v(P);a=new v(ne),m=c=new v(ne),_=d=new v(ne),R=x(L),p=a.e=R.length-P.e-1,a.c[0]=A[(E=p%y)<0?y+E:E],o=!o||l.comparedTo(a)>0?p>0?a:m:l,E=Se,Se=1/0,l=new v(R),d.c[0]=0;for(;;){if(g=D(l,a,0,1),f=c.plus(g.times(_)),f.comparedTo(o)==1)break;c=_,_=f,m=d.plus(g.times(f=m)),d=f,a=l.minus(g.times(f=a)),l=f}return f=D(o.minus(c),_,0,1),d=d.plus(f.times(m)),c=c.plus(f.times(_)),d.s=m.s=P.s,p=p*2,T=D(m,_,p,Z).minus(P).abs().comparedTo(D(d,c,p,Z).minus(P).abs())<1?[m,_]:[d,c],Se=E,T},C.toNumber=function(){return+je(this)},C.toPrecision=function(o,a){if(o!=null)b(o,1,N);return pr(this,o,a,2)},C.toString=function(o){var a,c=this,_=c.s,f=c.e;if(f===null)if(_){if(a="Infinity",_<0)a="-"+a}else a="NaN";else{if(o==null)a=f<=he||f>=fe?re(x(c.c),f):ce(x(c.c),f,"0");else if(o===10&&dr)c=ye(new v(c),Q+f+1,Z),a=ce(x(c.c),c.e,"0");else b(o,2,Ve.length,"Base"),a=B(ce(x(c.c),f,"0"),10,o,_,!0);if(_<0&&c.c[0])a="-"+a}return a},C.valueOf=C.toJSON=function(){return je(this)},C._isBigNumber=!0,U!=null)v.set(U);return v}function V(U){var D=U|0;return U>0||U===D?D:D-1}function x(U){var D,B,X=1,C=U.length,ne=U[0]+"";for(;X<C;){D=U[X++]+"",B=y-D.length;for(;B--;D="0"+D);ne+=D}for(C=ne.length;ne.charCodeAt(--C)===48;);return ne.slice(0,C+1||1)}function j(U,D){var B,X,C=U.c,ne=D.c,Q=U.s,Z=D.s,he=U.e,fe=D.e;if(!Q||!Z)return null;if(B=C&&!C[0],X=ne&&!ne[0],B||X)return B?X?0:-Z:Q;if(Q!=Z)return Q;if(B=Q<0,X=he==fe,!C||!ne)return X?0:!C^B?1:-1;if(!X)return he>fe^B?1:-1;Z=(he=C.length)<(fe=ne.length)?he:fe;for(Q=0;Q<Z;Q++)if(C[Q]!=ne[Q])return C[Q]>ne[Q]^B?1:-1;return he==fe?0:he>fe^B?1:-1}function b(U,D,B,X){if(U<D||U>B||U!==s(U))throw Error(i+(X||"Argument")+(typeof U=="number"?U<D||U>B?" out of range: ":" not an integer: ":" not a primitive number: ")+String(U))}function H(U){var D=U.c.length-1;return V(U.e/y)==D&&U.c[D]%2!=0}function re(U,D){return(U.length>1?U.charAt(0)+"."+U.slice(1):U)+(D<0?"e":"e+")+D}function ce(U,D,B){var X,C;if(D<0){for(C=B+".";++D;C+=B);U=C+U}else if(X=U.length,++D>X){for(C=B,D-=X;--D;C+=B);U+=C}else if(D<X)U=U.slice(0,D)+"."+U.slice(D);return U}if(t=F(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd)define(function(){return t});else if(typeof jt<"u"&&jt.exports)jt.exports=t;else{if(!e)e=typeof self<"u"&&self?self:window;e.BigNumber=t}})(bs)});var Ps=w(function(cg,Ns){var xs=Or(),Rs=cg;(function(){function e(S){return S<10?"0"+S:S}var t=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,r=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n,s,i={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':"\\\"","\\":"\\\\"},u;function h(S){return r.lastIndex=0,r.test(S)?'"'+S.replace(r,function(A){var k=i[A];return typeof k==="string"?k:"\\u"+("0000"+A.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+S+'"'}function y(S,A){var k,N,F,V,x=n,j,b=A[S],H=b!=null&&(b instanceof xs||xs.isBigNumber(b));if(b&&typeof b==="object"&&typeof b.toJSON==="function")b=b.toJSON(S);if(typeof u==="function")b=u.call(A,S,b);switch(typeof b){case"string":if(H)return b;else return h(b);case"number":return isFinite(b)?String(b):"null";case"boolean":case"null":case"bigint":return String(b);case"object":if(!b)return"null";if(n+=s,j=[],Object.prototype.toString.apply(b)==="[object Array]"){V=b.length;for(k=0;k<V;k+=1)j[k]=y(k,b)||"null";return F=j.length===0?"[]":n?`[
8
8
  `+n+j.join(`,
9
9
  `+n)+`
10
10
  `+x+"]":"["+j.join(",")+"]",n=x,F}if(u&&typeof u==="object"){V=u.length;for(k=0;k<V;k+=1)if(typeof u[k]==="string"){if(N=u[k],F=y(N,b),F)j.push(h(N)+(n?": ":":")+F)}}else Object.keys(b).forEach(function(re){var ce=y(re,b);if(ce)j.push(h(re)+(n?": ":":")+ce)});return F=j.length===0?"{}":n?`{
@@ -29,4 +29,4 @@ To learn more about authentication and Google APIs, visit:
29
29
  https://cloud.google.com/docs/authentication/getting-started`,NO_ADC_FOUND:"Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.",NO_UNIVERSE_DOMAIN_FOUND:`Unable to detect a Universe Domain in the current environment.
30
30
  To learn more about Universe Domain retrieval, visit:
31
31
  https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys`};class Hc{checkIsGCE=void 0;useJWTAccessWithScope;defaultServicePath;get isGCE(){return this.checkIsGCE}_findProjectIdPromise;_cachedProjectId;jsonContent=null;apiKey;cachedCredential=null;#e=null;defaultScopes;keyFilename;scopes;clientOptions={};constructor(e={}){if(this._cachedProjectId=e.projectId||null,this.cachedCredential=e.authClient||null,this.keyFilename=e.keyFilename||e.keyFile,this.scopes=e.scopes,this.clientOptions=e.clientOptions||{},this.jsonContent=e.credentials||null,this.apiKey=e.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw RangeError($c.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);if(e.universeDomain)this.clientOptions.universeDomain=e.universeDomain}setGapicJWTValues(e){e.defaultServicePath=this.defaultServicePath,e.useJWTAccessWithScope=this.useJWTAccessWithScope,e.defaultScopes=this.defaultScopes}getProjectId(e){if(e)this.getProjectIdAsync().then((t)=>e(null,t),e);else return this.getProjectIdAsync()}async getProjectIdOptional(){try{return await this.getProjectId()}catch(e){if(e instanceof Error&&e.message===$c.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;else throw e}}async findAndCacheProjectId(){let e=null;if(e||=await this.getProductionProjectId(),e||=await this.getFileProjectId(),e||=await this.getDefaultServiceProjectId(),e||=await this.getGCEProjectId(),e||=await this.getExternalAccountClientProjectId(),e)return this._cachedProjectId=e,e;else throw Error($c.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){if(this._cachedProjectId)return this._cachedProjectId;if(!this._findProjectIdPromise)this._findProjectIdPromise=this.findAndCacheProjectId();return this._findProjectIdPromise}async getUniverseDomainFromMetadataServer(){let e;try{e=await Rt.universe("universe-domain"),e||=Vn.DEFAULT_UNIVERSE}catch(t){if(t&&t?.response?.status===404)e=Vn.DEFAULT_UNIVERSE;else throw t}return e}async getUniverseDomain(){let e=Lc.originalOrCamelOptions(this.clientOptions).get("universe_domain");try{e??=(await this.getClient()).universeDomain}catch{e??=Vn.DEFAULT_UNIVERSE}return e}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(e={},t){let r;if(typeof e==="function")t=e;else r=e;if(t)this.getApplicationDefaultAsync(r).then((n)=>t(null,n.credential,n.projectId),t);else return this.getApplicationDefaultAsync(r)}async getApplicationDefaultAsync(e={}){if(this.cachedCredential)return await this.#t(this.cachedCredential,null);let t;if(t=await this._tryGetApplicationCredentialsFromEnvironmentVariable(e),t){if(t instanceof ut.JWT)t.scopes=this.scopes;else if(t instanceof bt.BaseExternalAccountClient)t.scopes=this.getAnyScopes();return await this.#t(t)}if(t=await this._tryGetApplicationCredentialsFromWellKnownFile(e),t){if(t instanceof ut.JWT)t.scopes=this.scopes;else if(t instanceof bt.BaseExternalAccountClient)t.scopes=this.getAnyScopes();return await this.#t(t)}if(await this._checkIsGCE())return e.scopes=this.getAnyScopes(),await this.#t(new wp.Compute(e));throw Error($c.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async#t(e,t=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){let r=await this.getProjectIdOptional();if(t)e.quotaProjectId=t;return this.cachedCredential=e,{credential:e,projectId:r}}async _checkIsGCE(){if(this.checkIsGCE===void 0)this.checkIsGCE=Rt.getGCPResidency()||await Rt.isAvailable();return this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(e){let t=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!t||t.length===0)return null;try{return await this._getApplicationCredentialsFromFilePath(t,e)}catch(r){if(r instanceof Error)r.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${r.message}`;throw r}}async _tryGetApplicationCredentialsFromWellKnownFile(e){let t=process.env.CLOUDSDK_CONFIG;if(!t)if(this._isWindows()){if(process.env.APPDATA)t=hr.join(process.env.APPDATA,"gcloud")}else{let s=process.env.HOME;if(s)t=hr.join(s,".config","gcloud")}if(!t)return null;let r=hr.join(t,"application_default_credentials.json");if(!xt.existsSync(r))return null;return await this._getApplicationCredentialsFromFilePath(r,e)}async _getApplicationCredentialsFromFilePath(e,t={}){if(!e||e.length===0)throw Error("The file path is invalid.");try{if(e=xt.realpathSync(e),!xt.lstatSync(e).isFile())throw Error()}catch(n){if(n instanceof Error)n.message=`The file at ${e} does not exist, or it is not a file. ${n.message}`;throw n}let r=xt.createReadStream(e);return this.fromStream(r,t)}fromImpersonatedJSON(e){if(!e)throw Error("Must pass in a JSON object containing an impersonated refresh token");if(e.type!==ht.IMPERSONATED_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${ht.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!e.source_credentials)throw Error("The incoming JSON object does not contain a source_credentials field");if(!e.service_account_impersonation_url)throw Error("The incoming JSON object does not contain a service_account_impersonation_url field");let t=this.fromJSON(e.source_credentials);if(e.service_account_impersonation_url?.length>256)throw RangeError(`Target principal is too long: ${e.service_account_impersonation_url}`);let r=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(e.service_account_impersonation_url)?.groups?.target;if(!r)throw RangeError(`Cannot extract target principal from ${e.service_account_impersonation_url}`);let n=(this.scopes||e.scopes||this.defaultScopes)??[];return new ht.Impersonated({...e,sourceClient:t,targetPrincipal:r,targetScopes:Array.isArray(n)?n:[n]})}fromJSON(e,t={}){let r,n=Lc.originalOrCamelOptions(t).get("universe_domain");if(e.type===Gc.USER_REFRESH_ACCOUNT_TYPE)r=new Gc.UserRefreshClient(t),r.fromJSON(e);else if(e.type===ht.IMPERSONATED_ACCOUNT_TYPE)r=this.fromImpersonatedJSON(e);else if(e.type===bt.EXTERNAL_ACCOUNT_TYPE)r=vp.ExternalAccountClient.fromJSON({...e,...t}),r.scopes=this.getAnyScopes();else if(e.type===Bc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE)r=new Bc.ExternalAccountAuthorizedUserClient({...e,...t});else if(e.type===Wn.GDCH_SERVICE_ACCOUNT_TYPE)r=new Wn.GdchClient(t),r.fromJSON(e);else t.scopes=this.scopes,r=new ut.JWT(t),this.setGapicJWTValues(r),r.fromJSON(e);if(n)r.universeDomain=n;return r}_cacheClientFromJSON(e,t){let r=this.fromJSON(e,t);return this.jsonContent=e,this.cachedCredential=r,r}fromStream(e,t={},r){let n={};if(typeof t==="function")r=t;else n=t;if(r)this.fromStreamAsync(e,n).then((s)=>r(null,s),r);else return this.fromStreamAsync(e,n)}fromStreamAsync(e,t){return new Promise((r,n)=>{if(!e)throw Error("Must pass in a stream containing the Google auth settings.");let s=[];e.setEncoding("utf8").on("error",n).on("data",(i)=>s.push(i)).on("end",()=>{try{try{let i=JSON.parse(s.join("")),u=this._cacheClientFromJSON(i,t);return r(u)}catch(i){if(!this.keyFilename)throw i;let u=new ut.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=u,this.setGapicJWTValues(u),r(u)}}catch(i){return n(i)}})})}fromAPIKey(e,t={}){return new ut.JWT({...t,apiKey:e})}_isWindows(){let e=mp.platform();if(e&&e.length>=3){if(e.substring(0,3).toLowerCase()==="win")return!0}return!1}async getDefaultServiceProjectId(){return new Promise((e)=>{_p.exec("gcloud config config-helper --format json",(t,r)=>{if(!t&&r)try{let n=JSON.parse(r).configuration.properties.core.project;e(n);return}catch(n){}e(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){let t=await this.getClient();if(t&&t.projectId)return t.projectId}let e=await this._tryGetApplicationCredentialsFromEnvironmentVariable();if(e)return e.projectId;else return null}async getExternalAccountClientProjectId(){if(!this.jsonContent||this.jsonContent.type!==bt.EXTERNAL_ACCOUNT_TYPE)return null;return await(await this.getClient()).getProjectId()}async getGCEProjectId(){try{return await Rt.project("project-id")}catch(e){return null}}getCredentials(e){if(e)this.getCredentialsAsync().then((t)=>e(null,t),e);else return this.getCredentialsAsync()}async getCredentialsAsync(){let e=await this.getClient();if(e instanceof ht.Impersonated)return{client_email:e.getTargetPrincipal()};if(e instanceof bt.BaseExternalAccountClient){let t=e.getServiceAccountEmail();if(t)return{client_email:t,universe_domain:e.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){let[t,r]=await Promise.all([Rt.instance("service-accounts/default/email"),this.getUniverseDomain()]);return{client_email:t,universe_domain:r}}throw Error($c.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;this.#e=this.#e||this.#r();try{let e=await this.#e;if(e instanceof Wn.GdchClient&&!e.apiAudience){let t=this.clientOptions,r=t.apiEndpoint||t.servicePath;if(r){let s=`${r.startsWith("http")?"":"https://"}${r}`.replace(/\/+$/,""),i=e.createWithGdchAudience(s);return this.cachedCredential=i,i}}return e}finally{this.#e=null}}async#r(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);else if(this.keyFilename){let e=hr.resolve(this.keyFilename),t=xt.createReadStream(e);return await this.fromStreamAsync(t,this.clientOptions)}else if(this.apiKey){let e=await this.fromAPIKey(this.apiKey,this.clientOptions);e.scopes=this.scopes;let{credential:t}=await this.#t(e);return t}else{let{credential:e}=await this.getApplicationDefaultAsync(this.clientOptions);return e}}async getIdTokenClient(e){let t=await this.getClient();if(!("fetchIdToken"in t))throw Error("Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.");return new Tp.IdTokenClient({targetAudience:e,idTokenProvider:t})}async getAccessToken(){return(await(await this.getClient()).getAccessToken()).token}async getRequestHeaders(e){return(await this.getClient()).getRequestHeaders(e)}async authorizeRequest(e={}){let t=e.url,n=await(await this.getClient()).getRequestHeaders(t);return e.headers=yp.Gaxios.mergeHeaders(e.headers,n),e}async fetch(...e){return(await this.getClient()).fetch(...e)}async request(e){return(await this.getClient()).request(e)}getEnv(){return Ap.getEnv()}async sign(e,t){let r=await this.getClient(),n=await this.getUniverseDomain();if(t=t||`https://iamcredentials.${n}/v1/projects/-/serviceAccounts/`,r instanceof ht.Impersonated)return(await r.sign(e)).signedBlob;let s=Ep.createCrypto();if(r instanceof ut.JWT&&r.key)return await s.sign(r.key,e);let i=await this.getCredentials();if(!i.client_email)throw Error("Cannot sign data without `client_email`.");return this.signBlob(s,i.client_email,e,t)}async signBlob(e,t,r,n){let s=new URL(n+`${t}:signBlob`);return(await this.request({method:"POST",url:s.href,data:{payload:e.encodeBase64StringUtf8(r)},retry:!0,retryConfig:{httpMethodsToRetry:["POST"]}})).data.signedBlob}}$c.GoogleAuth=Hc});var zc=w(function(Wc){Object.defineProperty(Wc,"__esModule",{value:!0});Wc.IAMAuth=void 0;class Vc{selector;token;constructor(e,t){this.selector=e,this.token=t,this.selector=e,this.token=t}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}}Wc.IAMAuth=Vc});var eu=w(function(Qc){Object.defineProperty(Qc,"__esModule",{value:!0});Qc.DownscopedClient=Qc.EXPIRATION_TIME_OFFSET=Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;var Sp=ie(),Cp=G("stream"),Yn=_e(),Op=er(),kp="urn:ietf:params:oauth:grant-type:token-exchange",bp="urn:ietf:params:oauth:token-type:access_token",xp="urn:ietf:params:oauth:token-type:access_token";Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT=10;Qc.EXPIRATION_TIME_OFFSET=300000;class Xc extends Yn.AuthClient{authClient;credentialAccessBoundary;cachedDownscopedAccessToken;stsCredential;constructor(e,t={accessBoundary:{accessBoundaryRules:[]}}){super(e instanceof Yn.AuthClient?{}:e);if(e instanceof Yn.AuthClient)this.authClient=e,this.credentialAccessBoundary=t;else this.authClient=e.authClient,this.credentialAccessBoundary=e.credentialAccessBoundary;if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length===0)throw Error("At least one access boundary rule needs to be defined.");else if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw Error(`The provided access boundary has more than ${Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(let r of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(r.availablePermissions.length===0)throw Error("At least one permission should be defined in access boundary rules.");this.stsCredential=new Op.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(e){if(!e.expiry_date)throw Error("The access token expiry_date field is missing in the provided credentials.");super.setCredentials(e),this.cachedDownscopedAccessToken=e}async getAccessToken(){if(!this.cachedDownscopedAccessToken||this.isExpired(this.cachedDownscopedAccessToken))await this.refreshAccessTokenAsync();return{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){let r;try{let n=await this.getRequestHeaders();e.headers=Sp.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,n),r=await this.transporter.request(e)}catch(n){let s=n.response;if(s){let i=s.status,u=s.config.data instanceof Cp.Readable;if(!t&&(i===401||i===403)&&!u&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){let e=(await this.authClient.getAccessToken()).token,t={grantType:kp,requestedTokenType:bp,subjectToken:e,subjectTokenType:xp},r=await this.stsCredential.exchangeToken(t,void 0,this.credentialAccessBoundary),n=this.authClient.credentials?.expiry_date||null,s=r.expires_in?new Date().getTime()+r.expires_in*1000:n;return this.cachedDownscopedAccessToken={access_token:r.access_token,expiry_date:s,res:r.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedDownscopedAccessToken}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}}Qc.DownscopedClient=Xc});var su=w(function(ru){Object.defineProperty(ru,"__esModule",{value:!0});ru.PassThroughClient=void 0;var Np=_e();class tu extends Np.AuthClient{async request(e){return this.transporter.request(e)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}}ru.PassThroughClient=tu});var dc=w(function(O){var Pp=O&&O.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Ip=O&&O.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Pp(t,e,r)};Object.defineProperty(O,"__esModule",{value:!0});O.GoogleAuth=O.auth=O.GDCH_SERVICE_ACCOUNT_TYPE=O.GdchClient=O.PassThroughClient=O.ExternalAccountAuthorizedUserClient=O.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=O.ExecutableError=O.PluggableAuthClient=O.DownscopedClient=O.BaseExternalAccountClient=O.ExternalAccountClient=O.IdentityPoolClient=O.AwsRequestSigner=O.AwsClient=O.UserRefreshClient=O.LoginTicket=O.ClientAuthentication=O.OAuth2Client=O.CodeChallengeMethod=O.Impersonated=O.JWT=O.JWTAccess=O.IdTokenClient=O.IAMAuth=O.GCPEnv=O.Compute=O.DEFAULT_UNIVERSE=O.AuthClient=O.gaxios=O.gcpMetadata=void 0;var iu=Jc();Object.defineProperty(O,"GoogleAuth",{enumerable:!0,get:function(){return iu.GoogleAuth}});O.gcpMetadata=yt();O.gaxios=ie();var ou=_e();Object.defineProperty(O,"AuthClient",{enumerable:!0,get:function(){return ou.AuthClient}});Object.defineProperty(O,"DEFAULT_UNIVERSE",{enumerable:!0,get:function(){return ou.DEFAULT_UNIVERSE}});var jp=Wr();Object.defineProperty(O,"Compute",{enumerable:!0,get:function(){return jp.Compute}});var Dp=zr();Object.defineProperty(O,"GCPEnv",{enumerable:!0,get:function(){return Dp.GCPEnv}});var Up=zc();Object.defineProperty(O,"IAMAuth",{enumerable:!0,get:function(){return Up.IAMAuth}});var qp=Yr();Object.defineProperty(O,"IdTokenClient",{enumerable:!0,get:function(){return qp.IdTokenClient}});var Fp=ln();Object.defineProperty(O,"JWTAccess",{enumerable:!0,get:function(){return Fp.JWTAccess}});var Mp=fn();Object.defineProperty(O,"JWT",{enumerable:!0,get:function(){return Mp.JWT}});var Lp=pn();Object.defineProperty(O,"Impersonated",{enumerable:!0,get:function(){return Lp.Impersonated}});var Xn=Be();Object.defineProperty(O,"CodeChallengeMethod",{enumerable:!0,get:function(){return Xn.CodeChallengeMethod}});Object.defineProperty(O,"OAuth2Client",{enumerable:!0,get:function(){return Xn.OAuth2Client}});Object.defineProperty(O,"ClientAuthentication",{enumerable:!0,get:function(){return Xn.ClientAuthentication}});var Gp=Jr();Object.defineProperty(O,"LoginTicket",{enumerable:!0,get:function(){return Gp.LoginTicket}});var Bp=dn();Object.defineProperty(O,"UserRefreshClient",{enumerable:!0,get:function(){return Bp.UserRefreshClient}});var Hp=On();Object.defineProperty(O,"AwsClient",{enumerable:!0,get:function(){return Hp.AwsClient}});var $p=Cn();Object.defineProperty(O,"AwsRequestSigner",{enumerable:!0,get:function(){return $p.AwsRequestSigner}});var Kp=Sn();Object.defineProperty(O,"IdentityPoolClient",{enumerable:!0,get:function(){return Kp.IdentityPoolClient}});var Jp=Gn();Object.defineProperty(O,"ExternalAccountClient",{enumerable:!0,get:function(){return Jp.ExternalAccountClient}});var Vp=$e();Object.defineProperty(O,"BaseExternalAccountClient",{enumerable:!0,get:function(){return Vp.BaseExternalAccountClient}});var Wp=eu();Object.defineProperty(O,"DownscopedClient",{enumerable:!0,get:function(){return Wp.DownscopedClient}});var au=Ln();Object.defineProperty(O,"PluggableAuthClient",{enumerable:!0,get:function(){return au.PluggableAuthClient}});Object.defineProperty(O,"ExecutableError",{enumerable:!0,get:function(){return au.ExecutableError}});var cu=Hn();Object.defineProperty(O,"EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE",{enumerable:!0,get:function(){return cu.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}});Object.defineProperty(O,"ExternalAccountAuthorizedUserClient",{enumerable:!0,get:function(){return cu.ExternalAccountAuthorizedUserClient}});var Yp=su();Object.defineProperty(O,"PassThroughClient",{enumerable:!0,get:function(){return Yp.PassThroughClient}});var uu=Jn();Object.defineProperty(O,"GdchClient",{enumerable:!0,get:function(){return uu.GdchClient}});Object.defineProperty(O,"GDCH_SERVICE_ACCOUNT_TYPE",{enumerable:!0,get:function(){return uu.GDCH_SERVICE_ACCOUNT_TYPE}});Ip(cn(),O);var zp=new iu.GoogleAuth;O.auth=zp});
32
- export{yu,dc};
32
+ export{bu,dc};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{Yr}from"./chunk-9trnkbtr.js";import{ws}from"./chunk-46wfxyd7.js";import{qe,sc,ac,uo,Vi,fo}from"./chunk-pdh9bnyj.js";import{cn}from"./chunk-1bgsphyz.js";function v(i,o){let a={v:1,id:i};if(o)a.phase=o;return JSON.stringify(a)}function C(i){if(!i)return;if(i.startsWith("{"))try{let o=JSON.parse(i);if(o.v===1&&typeof o.id==="string"){if(o.phase==="commentary"||o.phase==="final_answer")return{id:o.id,phase:o.phase};return{id:o.id}}}catch{}return{id:i}}function J(i,o){let a=o.filter((l)=>l.type==="text").map((l)=>l.text).join(`
3
- `),u=o.filter((l)=>l.type==="image"),p=a.length>0;if(u.length===0||!i.input.includes("image"))return qe(p?a:u.length>0?"(see attached image)":"(no tool output)");let f=[];if(p)f.push({type:"input_text",text:qe(a)});for(let l of u)f.push({type:"input_image",detail:"auto",image_url:`data:${l.mimeType};base64,${l.data}`});return f}function Ks(i,o,a,u){let p=[],f=new Set,l=(r)=>{let c=r.replace(/[^a-zA-Z0-9_-]/g,"_");return(c.length>64?c.slice(0,64):c).replace(/_+$/,"")},y=(r)=>{let c=`fc_${ws(r)}`;return c.length>64?c.slice(0,64):c},m=(r,c,t)=>{if(!a.has(i.provider))return l(r);if(!r.includes("|"))return l(r);let[e,n]=r.split("|"),s=l(e),g=t.provider!==i.provider||t.api!==i.api?y(n):l(n);if(!g.startsWith("fc_"))g=l(`fc_${g}`);return`${s}|${g}`},h=fo(o.messages,i,m);if((u?.includeSystemPrompt??!0)&&o.systemPrompt){let r=i.compat,c=i.reasoning&&r?.supportsDeveloperRole!==!1?"developer":"system";p.push({role:c,content:qe(o.systemPrompt)})}let x=0;for(let r of h){if(r.role==="user")if(typeof r.content==="string")p.push({role:"user",content:[{type:"input_text",text:qe(r.content)}]});else{let c=r.content.map((t)=>{if(t.type==="text")return{type:"input_text",text:qe(t.text)};return{type:"input_image",detail:"auto",image_url:`data:${t.mimeType};base64,${t.data}`}});if(c.length===0)continue;p.push({role:"user",content:c})}else if(r.role==="assistant"){let c=[],t=r,e=t.model!==i.id&&t.provider===i.provider&&t.api===i.api,n=0;for(let s of r.content)if(s.type==="thinking"){if(s.thinkingSignature){let d=JSON.parse(s.thinkingSignature);c.push(d)}}else if(s.type==="text"){let d=s,g=C(d.textSignature),b=n===0?`msg_pi_${x}`:`msg_pi_${x}_${n}`;n++;let _=g?.id;if(!_)_=b;else if(_.length>64)_=`msg_${ws(_)}`;c.push({type:"message",role:"assistant",content:[{type:"output_text",text:qe(d.text),annotations:[]}],status:"completed",id:_,phase:g?.phase})}else if(s.type==="toolCall"){let d=s,[g,b]=d.id.split("|"),_=u?.grammarToolInputProperties?.get(d.name),k=b;if(e&&k?.startsWith("fc_")||_===void 0&&!k?.startsWith("fc_"))k=void 0;if(_!==void 0)c.push({type:"custom_tool_call",id:k,call_id:g,name:d.name,input:qe(sc(d.name,d.arguments,_))});else c.push({type:"function_call",id:k,call_id:g,name:d.name,arguments:JSON.stringify(d.arguments)})}if(c.length===0)continue;p.push(...c)}else if(r.role==="toolResult"){let[c]=r.toolCallId.split("|"),t=J(i,r.content);if(u?.grammarToolInputProperties?.has(r.toolName))p.push({type:"custom_tool_call_output",call_id:c,output:t});else p.push({type:"function_call_output",call_id:c,output:t});let e=[];for(let n of r.addedToolNames??[]){let s=u?.deferredTools?.get(n);if(!s||f.has(n))continue;f.add(n),e.push(s)}if(e.length>0){let n=e.map((d)=>d.name),s=`pi_tool_load_${ws(`${r.toolCallId}:${n.join(",")}`)}`;p.push({type:"tool_search_call",call_id:s,execution:"client",status:"completed",arguments:{query:n.join(" "),limit:n.length}}),p.push({type:"tool_search_output",call_id:s,execution:"client",status:"completed",tools:Ws(e,{...u?.toolOptions,deferLoading:!0})})}}x++}return p}function Ws(i,o){let a=o?.strict===void 0?!1:o.strict,u=o?.supportsStrictMode??!0,p=o?.supportsOpenAIGrammarTools??!1;return i.map((f)=>{let l=Vi(f,p);if(l)return{type:"custom",name:f.name,description:f.description,format:{type:"grammar",syntax:l.format,definition:l.definition},...o?.deferLoading?{defer_loading:!0}:{}};let y=uo(f,u),m={type:"function",name:f.name,description:f.description,parameters:f.parameters,...o?.deferLoading?{defer_loading:!0}:{}};if(u)m.strict=y??a;return m})}function T(i){let o=i.customInput?.property;if(o===void 0)return"";let a=i.arguments[o];return typeof a==="string"?a:""}function S(i,o,a){let u=i.customInput;if(!u)return;let p=ac(u.jsonBuffer,u.property,o,a);return i.arguments={[u.property]:o},p}async function Ys(i,o,a,u,p){let f=!1,l=new Map,y=new Map,m=(t,e)=>{let n=l.get(t);return n?.type===e?n:void 0},h=(t,e)=>{if(e===void 0)return;a.push({type:"toolcall_delta",contentIndex:t.contentIndex,delta:e,partial:o})},I=(t,e)=>{if(e.type==="reasoning"){let n={type:"thinking",thinking:""};o.content.push(n);let s={type:"thinking",block:n,contentIndex:o.content.length-1};return l.set(t,s),a.push({type:"thinking_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="message"){let n={type:"text",text:""};o.content.push(n);let s={type:"text",block:n,contentIndex:o.content.length-1};return l.set(t,s),a.push({type:"text_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="function_call"){let n={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{},partialJson:e.arguments||""};o.content.push(n);let s={type:"toolCall",block:n,contentIndex:o.content.length-1};return l.set(t,s),a.push({type:"toolcall_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="custom_tool_call"){let n=p?.grammarToolInputProperties?.get(e.name)??"input",s=e.input||"",d={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{[n]:s},customInput:{property:n,jsonBuffer:{input:"",started:!1,closed:!1}}};o.content.push(d);let g={type:"toolCall",block:d,contentIndex:o.content.length-1};return l.set(t,g),a.push({type:"toolcall_start",contentIndex:g.contentIndex,partial:o}),g}return},x=(t,e)=>l.get(t)??I(t,e),r=(t)=>{for(let e of t){if(e.type!=="reasoning"||!e.encrypted_content)continue;let n=y.get(e.id);if(!n?.thinkingSignature)continue;let s=JSON.parse(n.thinkingSignature);if(s.encrypted_content)continue;n.thinkingSignature=JSON.stringify({...s,encrypted_content:e.encrypted_content})}},c=(t)=>{if(f=!0,r(t.output??[]),t?.id)o.responseId=t.id;if(t?.usage){let e=t.usage.input_tokens_details,n=e?.cached_tokens||0,s=e?.cache_write_tokens||0;o.usage={input:Math.max(0,(t.usage.input_tokens||0)-n-s),output:t.usage.output_tokens||0,cacheRead:n,cacheWrite:s,reasoning:t.usage.output_tokens_details?.reasoning_tokens||0,totalTokens:t.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(cn(u,o.usage),p?.applyServiceTierPricing){let e=p.resolveServiceTier?p.resolveServiceTier(t?.service_tier,p.serviceTier):t?.service_tier??p.serviceTier;p.applyServiceTierPricing(o.usage,e)}if(o.stopReason=w(t?.status),o.content.some((e)=>e.type==="toolCall")&&o.stopReason==="stop")o.stopReason="toolUse"};for await(let t of i)if(t.type==="response.created")o.responseId=t.response.id;else if(t.type==="response.output_item.added")I(t.output_index,t.item);else if(t.type==="response.reasoning_summary_text.delta"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=t.delta,a.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.reasoning_summary_part.done"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=`
2
+ import{Yr}from"./chunk-ycw3rwhx.js";import{xs}from"./chunk-r7e2fmmx.js";import{qe,sc,ac,uo,Vi,fo}from"./chunk-3g5pyw2e.js";import{cn}from"./chunk-05tnmf8h.js";function v(i,o){let a={v:1,id:i};if(o)a.phase=o;return JSON.stringify(a)}function C(i){if(!i)return;if(i.startsWith("{"))try{let o=JSON.parse(i);if(o.v===1&&typeof o.id==="string"){if(o.phase==="commentary"||o.phase==="final_answer")return{id:o.id,phase:o.phase};return{id:o.id}}}catch{}return{id:i}}function J(i,o){let a=o.filter((l)=>l.type==="text").map((l)=>l.text).join(`
3
+ `),u=o.filter((l)=>l.type==="image"),p=a.length>0;if(u.length===0||!i.input.includes("image"))return qe(p?a:u.length>0?"(see attached image)":"(no tool output)");let f=[];if(p)f.push({type:"input_text",text:qe(a)});for(let l of u)f.push({type:"input_image",detail:"auto",image_url:`data:${l.mimeType};base64,${l.data}`});return f}function Ws(i,o,a,u){let p=[],f=new Set,l=(r)=>{let c=r.replace(/[^a-zA-Z0-9_-]/g,"_");return(c.length>64?c.slice(0,64):c).replace(/_+$/,"")},y=(r)=>{let c=`fc_${xs(r)}`;return c.length>64?c.slice(0,64):c},m=(r,c,t)=>{if(!a.has(i.provider))return l(r);if(!r.includes("|"))return l(r);let[e,n]=r.split("|"),s=l(e),g=t.provider!==i.provider||t.api!==i.api?y(n):l(n);if(!g.startsWith("fc_"))g=l(`fc_${g}`);return`${s}|${g}`},h=fo(o.messages,i,m);if((u?.includeSystemPrompt??!0)&&o.systemPrompt){let r=i.compat,c=i.reasoning&&r?.supportsDeveloperRole!==!1?"developer":"system";p.push({role:c,content:qe(o.systemPrompt)})}let x=0;for(let r of h){if(r.role==="user")if(typeof r.content==="string")p.push({role:"user",content:[{type:"input_text",text:qe(r.content)}]});else{let c=r.content.map((t)=>{if(t.type==="text")return{type:"input_text",text:qe(t.text)};return{type:"input_image",detail:"auto",image_url:`data:${t.mimeType};base64,${t.data}`}});if(c.length===0)continue;p.push({role:"user",content:c})}else if(r.role==="assistant"){let c=[],t=r,e=t.model!==i.id&&t.provider===i.provider&&t.api===i.api,n=0;for(let s of r.content)if(s.type==="thinking"){if(s.thinkingSignature){let d=JSON.parse(s.thinkingSignature);c.push(d)}}else if(s.type==="text"){let d=s,g=C(d.textSignature),b=n===0?`msg_pi_${x}`:`msg_pi_${x}_${n}`;n++;let _=g?.id;if(!_)_=b;else if(_.length>64)_=`msg_${xs(_)}`;c.push({type:"message",role:"assistant",content:[{type:"output_text",text:qe(d.text),annotations:[]}],status:"completed",id:_,phase:g?.phase})}else if(s.type==="toolCall"){let d=s,[g,b]=d.id.split("|"),_=u?.grammarToolInputProperties?.get(d.name),k=b;if(e&&k?.startsWith("fc_")||_===void 0&&!k?.startsWith("fc_"))k=void 0;if(_!==void 0)c.push({type:"custom_tool_call",id:k,call_id:g,name:d.name,input:qe(sc(d.name,d.arguments,_))});else c.push({type:"function_call",id:k,call_id:g,name:d.name,arguments:JSON.stringify(d.arguments)})}if(c.length===0)continue;p.push(...c)}else if(r.role==="toolResult"){let[c]=r.toolCallId.split("|"),t=J(i,r.content);if(u?.grammarToolInputProperties?.has(r.toolName))p.push({type:"custom_tool_call_output",call_id:c,output:t});else p.push({type:"function_call_output",call_id:c,output:t});let e=[];for(let n of r.addedToolNames??[]){let s=u?.deferredTools?.get(n);if(!s||f.has(n))continue;f.add(n),e.push(s)}if(e.length>0){let n=e.map((d)=>d.name),s=`pi_tool_load_${xs(`${r.toolCallId}:${n.join(",")}`)}`;p.push({type:"tool_search_call",call_id:s,execution:"client",status:"completed",arguments:{query:n.join(" "),limit:n.length}}),p.push({type:"tool_search_output",call_id:s,execution:"client",status:"completed",tools:Ys(e,{...u?.toolOptions,deferLoading:!0})})}}x++}return p}function Ys(i,o){let a=o?.strict===void 0?!1:o.strict,u=o?.supportsStrictMode??!0,p=o?.supportsOpenAIGrammarTools??!1;return i.map((f)=>{let l=Vi(f,p);if(l)return{type:"custom",name:f.name,description:f.description,format:{type:"grammar",syntax:l.format,definition:l.definition},...o?.deferLoading?{defer_loading:!0}:{}};let y=uo(f,u),m={type:"function",name:f.name,description:f.description,parameters:f.parameters,...o?.deferLoading?{defer_loading:!0}:{}};if(u)m.strict=y??a;return m})}function T(i){let o=i.customInput?.property;if(o===void 0)return"";let a=i.arguments[o];return typeof a==="string"?a:""}function S(i,o,a){let u=i.customInput;if(!u)return;let p=ac(u.jsonBuffer,u.property,o,a);return i.arguments={[u.property]:o},p}async function Js(i,o,a,u,p){let f=!1,l=new Map,y=new Map,m=(t,e)=>{let n=l.get(t);return n?.type===e?n:void 0},h=(t,e)=>{if(e===void 0)return;a.push({type:"toolcall_delta",contentIndex:t.contentIndex,delta:e,partial:o})},I=(t,e)=>{if(e.type==="reasoning"){let n={type:"thinking",thinking:""};o.content.push(n);let s={type:"thinking",block:n,contentIndex:o.content.length-1};return l.set(t,s),a.push({type:"thinking_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="message"){let n={type:"text",text:""};o.content.push(n);let s={type:"text",block:n,contentIndex:o.content.length-1};return l.set(t,s),a.push({type:"text_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="function_call"){let n={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{},partialJson:e.arguments||""};o.content.push(n);let s={type:"toolCall",block:n,contentIndex:o.content.length-1};return l.set(t,s),a.push({type:"toolcall_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="custom_tool_call"){let n=p?.grammarToolInputProperties?.get(e.name)??"input",s=e.input||"",d={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{[n]:s},customInput:{property:n,jsonBuffer:{input:"",started:!1,closed:!1}}};o.content.push(d);let g={type:"toolCall",block:d,contentIndex:o.content.length-1};return l.set(t,g),a.push({type:"toolcall_start",contentIndex:g.contentIndex,partial:o}),g}return},x=(t,e)=>l.get(t)??I(t,e),r=(t)=>{for(let e of t){if(e.type!=="reasoning"||!e.encrypted_content)continue;let n=y.get(e.id);if(!n?.thinkingSignature)continue;let s=JSON.parse(n.thinkingSignature);if(s.encrypted_content)continue;n.thinkingSignature=JSON.stringify({...s,encrypted_content:e.encrypted_content})}},c=(t)=>{if(f=!0,r(t.output??[]),t?.id)o.responseId=t.id;if(t?.usage){let e=t.usage.input_tokens_details,n=e?.cached_tokens||0,s=e?.cache_write_tokens||0;o.usage={input:Math.max(0,(t.usage.input_tokens||0)-n-s),output:t.usage.output_tokens||0,cacheRead:n,cacheWrite:s,reasoning:t.usage.output_tokens_details?.reasoning_tokens||0,totalTokens:t.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(cn(u,o.usage),p?.applyServiceTierPricing){let e=p.resolveServiceTier?p.resolveServiceTier(t?.service_tier,p.serviceTier):t?.service_tier??p.serviceTier;p.applyServiceTierPricing(o.usage,e)}if(o.stopReason=w(t?.status),o.content.some((e)=>e.type==="toolCall")&&o.stopReason==="stop")o.stopReason="toolUse"};for await(let t of i)if(t.type==="response.created")o.responseId=t.response.id;else if(t.type==="response.output_item.added")I(t.output_index,t.item);else if(t.type==="response.reasoning_summary_text.delta"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=t.delta,a.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.reasoning_summary_part.done"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=`
4
4
 
5
5
  `,a.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:`
6
6
 
@@ -9,4 +9,4 @@ import{Yr}from"./chunk-9trnkbtr.js";import{ws}from"./chunk-46wfxyd7.js";import{q
9
9
  `)||"",d=e.content?.map((g)=>g.text).join(`
10
10
 
11
11
  `)||"";n.block.thinking=s||d||n.block.thinking,n.block.thinkingSignature=JSON.stringify(e),y.set(e.id,n.block),a.push({type:"thinking_end",contentIndex:n.contentIndex,content:n.block.thinking,partial:o}),l.delete(t.output_index)}else if(e.type==="message"&&n?.type==="text")n.block.text=e.content?.map((s)=>s.type==="output_text"?s.text:s.refusal).join("")||"",n.block.textSignature=v(e.id,e.phase??void 0),a.push({type:"text_end",contentIndex:n.contentIndex,content:n.block.text,partial:o}),l.delete(t.output_index);else if(e.type==="function_call"&&n?.type==="toolCall"&&n.block.partialJson!==void 0)n.block.arguments=Yr(e.arguments||n.block.partialJson||"{}"),delete n.block.partialJson,a.push({type:"toolcall_end",contentIndex:n.contentIndex,toolCall:n.block,partial:o}),l.delete(t.output_index);else if(e.type==="custom_tool_call"&&n?.type==="toolCall"&&n.block.customInput)h(n,S(n.block,e.input??T(n.block),!0)),delete n.block.customInput,a.push({type:"toolcall_end",contentIndex:n.contentIndex,toolCall:n.block,partial:o}),l.delete(t.output_index)}else if(t.type==="response.completed"||t.type==="response.incomplete")c(t.response);else if(t.type==="error")throw Error(`Error Code ${t.code}: ${t.message}`||"Unknown error");else if(t.type==="response.failed"){f=!0;let e=t.response?.error,n=t.response?.incomplete_details,s=e?`${e.code||"unknown"}: ${e.message||"no message"}`:n?.reason?`incomplete: ${n.reason}`:"Unknown error (no error details in response)";throw Error(s)}if(!f)throw Error("OpenAI Responses stream ended before a terminal response event")}function w(i){if(!i)return"stop";switch(i){case"completed":return"stop";case"incomplete":return"length";case"failed":case"cancelled":return"error";case"in_progress":case"queued":return"stop";default:throw Error(`Unhandled stop reason: ${i}`)}}
12
- export{Ks,Ws,Ys};
12
+ export{Ws,Ys,Js};
@@ -1,2 +1,2 @@
1
- import{h,b,u,S,Z,t,o,K,B,A,F,Gr,ve,bt,vt,Ps,pe,E,he,ge,Ae,W,Ne,Xa,Ym,it,Fc,Lc,ih,Xy,eb,wh,xh,Sh,Kf,Wf,Yf,Jf,yl,Qh,tp,rp,og,sg,Ap,Cg,Hg,Dp,j1,Lp,Zp,Je,Xe,et,tt,rt,nt,ot,st,ue,ie,me,Ge,le,Tt,H,Pt,Nt,k,Kr,_n,fA}from"./chunk-jh8q3885.js";import{eu,tu,ru,nu,ou}from"./chunk-t8gv2ekj.js";import{Zo}from"./chunk-07jszkhj.js";import{lo}from"./chunk-yfr0hzb7.js";S();var Se=[];function Bl({teamId:r,projectId:D,assetId:m,folders:a,files:l,totalFolders:Me,totalFiles:Re,totalFoldersSize:ze,totalFilesSize:Ue,selectedItem:G,selectedIds:w,onItemSelect:J,onItemDoubleClick:X,onSaveField:Be,onClearSelection:qe,fetchNextFoldersPage:Y,hasNextFoldersPage:ee,isFetchingNextFoldersPage:y,fetchNextFilesPage:te,hasNextFilesPage:oe,isFetchingNextFilesPage:x,isRecentlyDeleted:C=!1,isRecents:N=!1,isLoading:se=!1,isShareView:q=!1,isPublic:re=!1,shareId:$e,allowDownload:ne=!0}){let d=K(),{canEdit:_,canAdmin:Oe}=Pt(D),ae=b(null),de=b(null),[O,We]=u(!0),[j,je]=u(!0),[Qe,I]=u(!1),[T,ce]=u(""),[He,Q]=u(!1),fe=Me??a.length,we=Re??l.length,De=ze??(a.length>0?a.reduce((e,s)=>e+(s.sizeByte||0),0):-1),ye=Ue??(l.length>0?l.reduce((e,s)=>e+(s.sizeByte||0),0):-1),Ke=De>-1,Le=ye>-1,be=(e,s)=>{if(s)return e===1?Wf({count:e}):Kf({count:e});else return e===1?Jf({count:e}):Yf({count:e})},{editingItemId:xe,setEditingItemId:ke,handleAction:Ce,onRenameSubmit:_e,isDeleteDialogOpen:Pe,setIsDeleteDialogOpen:Ve,confirmDelete:Ye,isDownloadDialogOpen:Ze,setIsDownloadDialogOpen:L,isLoadingLinks:M,resolvedFiles:Fe,startDownload:at}=ou({teamId:r,projectId:D,assetId:m,folders:a,files:l,selectedIds:w,isPublic:re,shareId:$e}),{ref:lt,inView:Ie}=Nt();h(()=>{if(Ie){if(ee&&!y)Y();else if(oe&&!x)te()}},[Ie,ee,y,oe,x,Y,te]);let dt=_n((e)=>e.startTask),ct=A.api.teams[":teamId"].upload.tasks.$post,{mutate:mt}=B({mutationFn:async(e)=>{let s=await ct(e);if(!s.ok)throw Error("Failed to create upload task");return await s.json()},onMutate:()=>({files:[...Se]}),onSuccess:async(e,s,n)=>{let p=n?.files||[],f=p.map((i)=>{let v=e.createdAssets?.find((c)=>c.tempId===i.id),z=e.presignedUrls?.find((c)=>c.id===i.id);return{fileId:v?.assetId||z?.fileId||i.id,name:i.file.name,size:i.file.size}}).filter((i)=>!!i.fileId),g=p.filter((i)=>!i.file.name.startsWith(".")),R=g.length===1?g[0].file.name:`${g.length} Items`;if(e.taskId)dt(e.taskId,R,f);d.invalidateQueries({queryKey:["search",r,m]}),d.invalidateQueries({queryKey:["teams",r,"upload","tasks"]}),await tu({files:p,taskId:e.taskId,teamId:r,storageBackend:e.storageBackend||"local",createdAssets:e.createdAssets,presignedUrls:e.presignedUrls,onFileFinished:async()=>{await d.invalidateQueries({queryKey:["search",r,m]})}}),d.invalidateQueries({queryKey:["search",r,m]}),d.invalidateQueries({queryKey:["teams",r,"upload","tasks"]})}}),Te=(e)=>{if(!e||e.length===0)return;let s=[],n=[],p=new Map;for(let f of e){let g=(f.webkitRelativePath||f.name).split("/");if(g.some((U)=>U.startsWith(".")))continue;let R=g.pop(),i=n,v="";for(let U of g)if(v=`${v}/${U}`,!p.has(v)){let V=[],wt={name:U,type:"folder",id:Zo(),children:V,size:0};i.push(wt),p.set(v,V),i=V}else i=p.get(v);let z={file:f,id:Zo()};s.push(z);let c=f.type;if(R.toLowerCase().endsWith(".wma")&&c?.startsWith("video/"))c=c.replace(/^video\//,"audio/");i.push({name:R,size:f.size,type:"file",id:z.id,children:[],mediaType:c})}Se=s,mt({param:{teamId:r},json:{parentId:m,files:n}})},pt=A.api.folders.$post,{mutate:ut,isPending:Ee}=B({mutationFn:async(e)=>{let s=await pt({json:{name:e,parentId:m}});if(!s.ok)throw Error("Failed to create folder");return await s.json()},onSuccess:()=>{k.success(yl()),I(!1),ce(""),d.invalidateQueries({queryKey:["search",r,m]}),d.invalidateQueries({queryKey:["folders"]})},onError:(e)=>{k.error(`Error: ${e.message}`)}}),{mutate:ft,isPending:P}=B({mutationFn:async()=>{let e=await A.api.projects[":projectId"]["empty-trash"].$post({param:{projectId:D}});if(!e.ok)throw Error("Failed to empty trash");return await e.json()},onSuccess:()=>{k.success(j1()),d.invalidateQueries({queryKey:["projects",D,"recently-deleted"]}),qe(),Q(!1)},onError:(e)=>{k.error(`Error: ${e.message}`)}}),gt=(e)=>{if(e.preventDefault(),!T.trim())return;ut(T.trim())},ht=!se&&a.length===0&&l.length===0&&!y&&!x;return o("div",{className:"flex-1 flex flex-col min-h-0 bg-background overflow-hidden relative",children:[_&&o(Z,{children:[t("input",{type:"file",ref:ae,multiple:!0,className:"hidden",onChange:(e)=>{if(e.target.files)Te(e.target.files)}}),t("input",{type:"file",ref:de,multiple:!0,webkitdirectory:"true",className:"hidden",onChange:(e)=>{if(e.target.files)Te(e.target.files)}})]}),C&&o("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border text-sm shrink-0",children:[o("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t(Gr,{className:"h-4 w-4 text-amber-500 shrink-0"}),t("span",{className:"text-xs",children:Ap()})]}),Oe&&t(E,{variant:"destructive",size:"sm",disabled:P||a.length===0&&l.length===0,onClick:()=>Q(!0),className:"h-7 px-2.5 text-xs font-medium bg-destructive/10 text-destructive border border-destructive/20 hover:bg-destructive hover:text-destructive-foreground",children:"Delete"})]}),o("div",{className:"flex-1 overflow-y-auto min-h-0 p-3 pb-24",children:[se&&a.length===0&&l.length===0?t(fA,{}):o("div",{className:"max-w-lg mx-auto w-full",children:[fe>0&&o("div",{className:"mb-4",children:[o("button",{onClick:()=>We(!O),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground mb-3 font-medium select-none cursor-pointer",children:[O?t(ve,{className:"h-4 w-4"}):t(bt,{className:"h-4 w-4"}),o("span",{children:[be(fe,!1),Ke?` • ${Kr(De)}`:""]})]}),O&&t("div",{className:"grid grid-cols-1 gap-4 w-full",children:a.map((e)=>t(nu,{item:e,isSelected:G?.id===e.id,isChecked:w.has(e.id),isEditing:xe===e.id,onSelect:J,onDoubleClick:X,onContextMenu:()=>{},onDragStart:()=>{},onDrop:()=>{},onRename:(s)=>_e(e,s),onFinishEditing:()=>ke(null),onAction:(s,n)=>Ce(s,n),isRecentlyDeleted:C,isRecents:N,selectedCount:w.size,canEdit:_,isShareView:q,allowDownload:ne},e.id))})]}),we>0&&o("div",{className:"mb-4",children:[o("button",{onClick:()=>je(!j),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground mb-3 font-medium select-none cursor-pointer",children:[j?t(ve,{className:"h-4 w-4"}):t(bt,{className:"h-4 w-4"}),o("span",{children:[be(we,!0),Le?` • ${Kr(ye)}`:""]})]}),j&&t("div",{className:"grid grid-cols-1 gap-4 w-full",children:l.map((e)=>t(ru,{teamId:r,item:e,isSelected:G?.id===e.id,isChecked:w.has(e.id),isEditing:xe===e.id,onSelect:J,onDoubleClick:X,onContextMenu:()=>{},onDragStart:()=>{},onDrop:()=>{},onRename:(s)=>_e(e,s),onFinishEditing:()=>ke(null),onSaveField:(s,n)=>Be?.(e.id,s,n),fields:[],onAction:(s,n)=>Ce(s,n),isRecentlyDeleted:C,isRecents:N,selectedCount:w.size,canEdit:_,isShareView:q,allowDownload:ne},e.id))})]})]}),ht&&t("div",{className:"flex flex-col items-center justify-center h-64 text-sm text-muted-foreground p-6 text-center",children:N?o("div",{className:"flex flex-col items-center gap-2",children:[t(Ps,{className:"h-10 w-10 text-muted-foreground/40 mb-1"}),t("p",{className:"font-medium text-foreground",children:tp()}),t("p",{className:"text-xs text-muted-foreground",children:rp()})]}):t("span",{children:Dp()})}),t("div",{ref:lt,className:"py-4 flex justify-center items-center min-h-6",children:(y||x)&&t(F,{className:"h-5 w-5 animate-spin text-muted-foreground"})})]}),_&&!C&&!N&&!q&&!re&&t("div",{className:"fixed bottom-6 right-6 z-30",children:o(he,{modal:!1,children:[t(ge,{asChild:!0,children:t(E,{size:"icon",className:"h-14 w-14 rounded-full bg-primary text-primary-foreground shadow-lg shadow-primary/25 hover:bg-primary/90 flex items-center justify-center","aria-label":"Actions",children:t(pe,{className:"h-6 w-6"})})}),o(Ae,{align:"end",side:"top",className:"w-48 mb-2",children:[o(W,{onClick:()=>ae.current?.click(),className:"flex items-center gap-2.5 py-2 cursor-pointer",children:[t(lo,{className:"h-4 w-4"}),t("span",{children:Lp()})]}),o(W,{onClick:()=>de.current?.click(),className:"flex items-center gap-2.5 py-2 cursor-pointer",children:[t(lo,{className:"h-4 w-4"}),t("span",{children:Zp()})]}),o(W,{onClick:()=>I(!0),className:"flex items-center gap-2.5 py-2 cursor-pointer",children:[t(eu,{className:"h-4 w-4"}),t("span",{children:yl()})]})]})]})}),t(ue,{open:Qe,onOpenChange:I,children:t(ie,{className:"sm:max-w-md",children:o("form",{onSubmit:gt,children:[o(me,{children:[t(le,{children:yl()}),t(Tt,{children:xh()})]}),t("div",{className:"py-4",children:t(H,{autoFocus:!0,placeholder:xh(),value:T,onChange:(e)=>ce(e.target.value)})}),o(Ge,{children:[t(E,{type:"button",variant:"outline",onClick:()=>I(!1),children:Ne()}),o(E,{type:"submit",disabled:!T.trim()||Ee,children:[Ee?t(F,{className:"h-4 w-4 animate-spin mr-2"}):null,Xa()]})]})]})})}),t(Je,{open:Pe,onOpenChange:Ve,children:o(Xe,{children:[o(et,{children:[t(rt,{children:Lc()}),t(nt,{children:Fc()})]}),o(tt,{children:[t(st,{children:Ne()}),t(ot,{onClick:()=>Ye(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:it()})]})]})}),t(Je,{open:He,onOpenChange:Q,children:o(Xe,{children:[o(et,{children:[t(rt,{children:eb()}),t(nt,{children:Xy()})]}),o(tt,{children:[t(st,{children:Ne()}),t(ot,{onClick:()=>ft(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:P,children:P?"Deleting...":it()})]})]})}),t(ue,{open:Ze,onOpenChange:L,children:o(ie,{className:"sm:max-w-md",children:[o(me,{children:[t(le,{children:M?og():Ym()}),t(Tt,{children:M?Cg():wh()})]}),M?o("div",{className:"space-y-4 py-6 flex flex-col items-center justify-center",children:[t(F,{className:"h-8 w-8 animate-spin text-primary"}),t("span",{className:"text-sm font-medium text-muted-foreground mt-2",children:sg()})]}):o("div",{className:"space-y-4 py-2",children:[t("div",{className:"text-sm text-muted-foreground",children:ih({count:Fe.length})}),o("div",{className:"flex items-start gap-3 p-3 text-sm rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 border border-amber-200 dark:border-amber-900/30",children:[t(Gr,{className:"h-5 w-5 shrink-0 mt-0.5"}),o("div",{children:[t("p",{className:"font-semibold",children:Qh()}),t("p",{className:"mt-0.5 text-xs text-amber-700/90 dark:text-amber-400/90",children:Sh()})]})]})]}),t(Ge,{children:!M?o(Z,{children:[t(E,{variant:"outline",onClick:()=>L(!1),children:Ne()}),o(E,{onClick:at,className:"gap-2",disabled:Fe.length===0,children:[t(vt,{className:"h-4 w-4"}),Hg()]})]}):t(E,{variant:"outline",onClick:()=>L(!1),children:Ne()})})]})})]})}
1
+ import{h,b,u,S,L,t,o,K,B,A,F,Gr,ve,bt,vt,Os,fe,E,he,ge,Ae,W,Ne,Xa,Jm,it,Fc,Lc,ch,ob,sb,Sh,Eh,Ch,Yf,Jf,Xf,ep,yl,Jh,np,op,lg,cg,yp,kg,Qg,Op,J1,Bp,Up,Je,Xe,et,tt,rt,nt,ot,st,ue,ie,me,Ge,le,Tt,H,Pt,Nt,k,Kr,_n,AA}from"./chunk-q6jsw0rr.js";import{tu,ru,nu,ou,su}from"./chunk-6rjkbwz6.js";import{Zo}from"./chunk-5rk7dyx9.js";import{lo}from"./chunk-q1d7x1cc.js";S();var Se=[];function Bl({teamId:r,projectId:D,assetId:m,folders:a,files:l,totalFolders:Me,totalFiles:Re,totalFoldersSize:ze,totalFilesSize:Ue,selectedItem:J,selectedIds:w,onItemSelect:X,onItemDoubleClick:Y,onSaveField:Be,onClearSelection:qe,fetchNextFoldersPage:Z,hasNextFoldersPage:ee,isFetchingNextFoldersPage:y,fetchNextFilesPage:te,hasNextFilesPage:oe,isFetchingNextFilesPage:x,isRecentlyDeleted:C=!1,isRecents:N=!1,isLoading:se=!1,isShareView:q=!1,isPublic:re=!1,shareId:$e,allowDownload:ne=!0}){let d=K(),{canEdit:_,canAdmin:Oe}=Pt(D),ae=b(null),de=b(null),[O,We]=u(!0),[j,je]=u(!0),[Qe,I]=u(!1),[T,ce]=u(""),[He,Q]=u(!1),pe=Me??a.length,we=Re??l.length,De=ze??(a.length>0?a.reduce((e,s)=>e+(s.sizeByte||0),0):-1),ye=Ue??(l.length>0?l.reduce((e,s)=>e+(s.sizeByte||0),0):-1),Ke=De>-1,Le=ye>-1,be=(e,s)=>{if(s)return e===1?Jf({count:e}):Yf({count:e});else return e===1?ep({count:e}):Xf({count:e})},{editingItemId:xe,setEditingItemId:ke,handleAction:Ce,onRenameSubmit:_e,isDeleteDialogOpen:Pe,setIsDeleteDialogOpen:Ve,confirmDelete:Ye,isDownloadDialogOpen:Ze,setIsDownloadDialogOpen:P,isLoadingLinks:M,resolvedFiles:Fe,startDownload:at}=su({teamId:r,projectId:D,assetId:m,folders:a,files:l,selectedIds:w,isPublic:re,shareId:$e}),{ref:lt,inView:Ie}=Nt();h(()=>{if(Ie){if(ee&&!y)Z();else if(oe&&!x)te()}},[Ie,ee,y,oe,x,Z,te]);let dt=_n((e)=>e.startTask),ct=A.api.teams[":teamId"].upload.tasks.$post,{mutate:mt}=B({mutationFn:async(e)=>{let s=await ct(e);if(!s.ok)throw Error("Failed to create upload task");return await s.json()},onMutate:()=>({files:[...Se]}),onSuccess:async(e,s,n)=>{let p=n?.files||[],f=p.map((i)=>{let v=e.createdAssets?.find((c)=>c.tempId===i.id),z=e.presignedUrls?.find((c)=>c.id===i.id);return{fileId:v?.assetId||z?.fileId||i.id,name:i.file.name,size:i.file.size}}).filter((i)=>!!i.fileId),g=p.filter((i)=>!i.file.name.startsWith(".")),R=g.length===1?g[0].file.name:`${g.length} Items`;if(e.taskId)dt(e.taskId,R,f);d.invalidateQueries({queryKey:["search",r,m]}),d.invalidateQueries({queryKey:["teams",r,"upload","tasks"]}),await ru({files:p,taskId:e.taskId,teamId:r,storageBackend:e.storageBackend||"local",createdAssets:e.createdAssets,presignedUrls:e.presignedUrls,onFileFinished:async()=>{await d.invalidateQueries({queryKey:["search",r,m]})}}),d.invalidateQueries({queryKey:["search",r,m]}),d.invalidateQueries({queryKey:["teams",r,"upload","tasks"]})}}),Te=(e)=>{if(!e||e.length===0)return;let s=[],n=[],p=new Map;for(let f of e){let g=(f.webkitRelativePath||f.name).split("/");if(g.some((U)=>U.startsWith(".")))continue;let R=g.pop(),i=n,v="";for(let U of g)if(v=`${v}/${U}`,!p.has(v)){let G=[],wt={name:U,type:"folder",id:Zo(),children:G,size:0};i.push(wt),p.set(v,G),i=G}else i=p.get(v);let z={file:f,id:Zo()};s.push(z);let c=f.type;if(R.toLowerCase().endsWith(".wma")&&c?.startsWith("video/"))c=c.replace(/^video\//,"audio/");i.push({name:R,size:f.size,type:"file",id:z.id,children:[],mediaType:c})}Se=s,mt({param:{teamId:r},json:{parentId:m,files:n}})},pt=A.api.folders.$post,{mutate:ut,isPending:Ee}=B({mutationFn:async(e)=>{let s=await pt({json:{name:e,parentId:m}});if(!s.ok)throw Error("Failed to create folder");return await s.json()},onSuccess:()=>{k.success(yl()),I(!1),ce(""),d.invalidateQueries({queryKey:["search",r,m]}),d.invalidateQueries({queryKey:["folders"]})},onError:(e)=>{k.error(`Error: ${e.message}`)}}),{mutate:ft,isPending:V}=B({mutationFn:async()=>{let e=await A.api.projects[":projectId"]["empty-trash"].$post({param:{projectId:D}});if(!e.ok)throw Error("Failed to empty trash");return await e.json()},onSuccess:()=>{k.success(J1()),d.invalidateQueries({queryKey:["projects",D,"recently-deleted"]}),qe(),Q(!1)},onError:(e)=>{k.error(`Error: ${e.message}`)}}),gt=(e)=>{if(e.preventDefault(),!T.trim())return;ut(T.trim())},ht=!se&&a.length===0&&l.length===0&&!y&&!x;return o("div",{className:"flex-1 flex flex-col min-h-0 bg-background overflow-hidden relative",children:[_&&o(L,{children:[t("input",{type:"file",ref:ae,multiple:!0,className:"hidden",onChange:(e)=>{if(e.target.files)Te(e.target.files)}}),t("input",{type:"file",ref:de,multiple:!0,webkitdirectory:"true",className:"hidden",onChange:(e)=>{if(e.target.files)Te(e.target.files)}})]}),C&&o("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border text-sm shrink-0",children:[o("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t(Gr,{className:"h-4 w-4 text-amber-500 shrink-0"}),t("span",{className:"text-xs",children:yp()})]}),Oe&&t(E,{variant:"destructive",size:"sm",disabled:V||a.length===0&&l.length===0,onClick:()=>Q(!0),className:"h-7 px-2.5 text-xs font-medium bg-destructive/10 text-destructive border border-destructive/20 hover:bg-destructive hover:text-destructive-foreground",children:"Delete"})]}),o("div",{className:"flex-1 overflow-y-auto min-h-0 p-3 pb-24",children:[se&&a.length===0&&l.length===0?t(AA,{}):o("div",{className:"max-w-lg mx-auto w-full",children:[pe>0&&o("div",{className:"mb-4",children:[o("button",{onClick:()=>We(!O),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground mb-3 font-medium select-none cursor-pointer",children:[O?t(ve,{className:"h-4 w-4"}):t(bt,{className:"h-4 w-4"}),o("span",{children:[be(pe,!1),Ke?` • ${Kr(De)}`:""]})]}),O&&t("div",{className:"grid grid-cols-1 gap-4 w-full",children:a.map((e)=>t(ou,{item:e,isSelected:J?.id===e.id,isChecked:w.has(e.id),isEditing:xe===e.id,onSelect:X,onDoubleClick:Y,onContextMenu:()=>{},onDragStart:()=>{},onDrop:()=>{},onRename:(s)=>_e(e,s),onFinishEditing:()=>ke(null),onAction:(s,n)=>Ce(s,n),isRecentlyDeleted:C,isRecents:N,selectedCount:w.size,canEdit:_,isShareView:q,allowDownload:ne},e.id))})]}),we>0&&o("div",{className:"mb-4",children:[o("button",{onClick:()=>je(!j),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground mb-3 font-medium select-none cursor-pointer",children:[j?t(ve,{className:"h-4 w-4"}):t(bt,{className:"h-4 w-4"}),o("span",{children:[be(we,!0),Le?` • ${Kr(ye)}`:""]})]}),j&&t("div",{className:"grid grid-cols-1 gap-4 w-full",children:l.map((e)=>t(nu,{teamId:r,item:e,isSelected:J?.id===e.id,isChecked:w.has(e.id),isEditing:xe===e.id,onSelect:X,onDoubleClick:Y,onContextMenu:()=>{},onDragStart:()=>{},onDrop:()=>{},onRename:(s)=>_e(e,s),onFinishEditing:()=>ke(null),onSaveField:(s,n)=>Be?.(e.id,s,n),fields:[],onAction:(s,n)=>Ce(s,n),isRecentlyDeleted:C,isRecents:N,selectedCount:w.size,canEdit:_,isShareView:q,allowDownload:ne},e.id))})]})]}),ht&&t("div",{className:"flex flex-col items-center justify-center h-64 text-sm text-muted-foreground p-6 text-center",children:N?o("div",{className:"flex flex-col items-center gap-2",children:[t(Os,{className:"h-10 w-10 text-muted-foreground/40 mb-1"}),t("p",{className:"font-medium text-foreground",children:np()}),t("p",{className:"text-xs text-muted-foreground",children:op()})]}):t("span",{children:Op()})}),t("div",{ref:lt,className:"py-4 flex justify-center items-center min-h-6",children:(y||x)&&t(F,{className:"h-5 w-5 animate-spin text-muted-foreground"})})]}),_&&!C&&!N&&!q&&!re&&t("div",{className:"fixed bottom-6 right-6 z-30",children:o(he,{modal:!1,children:[t(ge,{asChild:!0,children:t(E,{size:"icon",className:"h-14 w-14 rounded-full bg-primary text-primary-foreground shadow-lg shadow-primary/25 hover:bg-primary/90 flex items-center justify-center","aria-label":"Actions",children:t(fe,{className:"h-6 w-6"})})}),o(Ae,{align:"end",side:"top",className:"w-48 mb-2",children:[o(W,{onClick:()=>ae.current?.click(),className:"flex items-center gap-2.5 py-2 cursor-pointer",children:[t(lo,{className:"h-4 w-4"}),t("span",{children:Bp()})]}),o(W,{onClick:()=>de.current?.click(),className:"flex items-center gap-2.5 py-2 cursor-pointer",children:[t(lo,{className:"h-4 w-4"}),t("span",{children:Up()})]}),o(W,{onClick:()=>I(!0),className:"flex items-center gap-2.5 py-2 cursor-pointer",children:[t(tu,{className:"h-4 w-4"}),t("span",{children:yl()})]})]})]})}),t(ue,{open:Qe,onOpenChange:I,children:t(ie,{className:"sm:max-w-md",children:o("form",{onSubmit:gt,children:[o(me,{children:[t(le,{children:yl()}),t(Tt,{children:Eh()})]}),t("div",{className:"py-4",children:t(H,{autoFocus:!0,placeholder:Eh(),value:T,onChange:(e)=>ce(e.target.value)})}),o(Ge,{children:[t(E,{type:"button",variant:"outline",onClick:()=>I(!1),children:Ne()}),o(E,{type:"submit",disabled:!T.trim()||Ee,children:[Ee?t(F,{className:"h-4 w-4 animate-spin mr-2"}):null,Xa()]})]})]})})}),t(Je,{open:Pe,onOpenChange:Ve,children:o(Xe,{children:[o(et,{children:[t(rt,{children:Lc()}),t(nt,{children:Fc()})]}),o(tt,{children:[t(st,{children:Ne()}),t(ot,{onClick:()=>Ye(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:it()})]})]})}),t(Je,{open:He,onOpenChange:Q,children:o(Xe,{children:[o(et,{children:[t(rt,{children:sb()}),t(nt,{children:ob()})]}),o(tt,{children:[t(st,{children:Ne()}),t(ot,{onClick:()=>ft(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:V,children:V?"Deleting...":it()})]})]})}),t(ue,{open:Ze,onOpenChange:P,children:o(ie,{className:"sm:max-w-md",children:[o(me,{children:[t(le,{children:M?lg():Jm()}),t(Tt,{children:M?kg():Sh()})]}),M?o("div",{className:"space-y-4 py-6 flex flex-col items-center justify-center",children:[t(F,{className:"h-8 w-8 animate-spin text-primary"}),t("span",{className:"text-sm font-medium text-muted-foreground mt-2",children:cg()})]}):o("div",{className:"space-y-4 py-2",children:[t("div",{className:"text-sm text-muted-foreground",children:ch({count:Fe.length})}),o("div",{className:"flex items-start gap-3 p-3 text-sm rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 border border-amber-200 dark:border-amber-900/30",children:[t(Gr,{className:"h-5 w-5 shrink-0 mt-0.5"}),o("div",{children:[t("p",{className:"font-semibold",children:Jh()}),t("p",{className:"mt-0.5 text-xs text-amber-700/90 dark:text-amber-400/90",children:Ch()})]})]})]}),t(Ge,{children:!M?o(L,{children:[t(E,{variant:"outline",onClick:()=>P(!1),children:Ne()}),o(E,{onClick:at,className:"gap-2",disabled:Fe.length===0,children:[t(vt,{className:"h-4 w-4"}),Qg()]})]}):t(E,{variant:"outline",onClick:()=>P(!1),children:Ne()})})]})})]})}
2
2
  export{Bl};