@shumai-one/shumai 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/bin/{chunk-qag3w2dd.js → chunk-0aj303as.js} +1 -1
  2. package/bin/{chunk-976v5s8y.js → chunk-0qkj838r.js} +1 -1
  3. package/bin/{chunk-mg6fce5x.js → chunk-0rxhc7ka.js} +1 -1
  4. package/bin/chunk-0xbf8bcg.js +2 -0
  5. package/bin/{chunk-t1mxqskx.js → chunk-15sefy5t.js} +1 -1
  6. package/bin/{chunk-jfjcxyhf.js → chunk-1wm57c6y.js} +3 -3
  7. package/bin/{chunk-7ktvhtp1.js → chunk-1xpec5r8.js} +1 -1
  8. package/bin/chunk-23d3968z.js +2 -0
  9. package/bin/{chunk-y4s3xr4n.js → chunk-262hkppb.js} +2 -2
  10. package/bin/{chunk-qj2kpkje.js → chunk-29tx9qe2.js} +1 -1
  11. package/bin/chunk-2a9n3dhx.js +1 -0
  12. package/bin/{chunk-a5s5ny4z.js → chunk-2aamsc5v.js} +1 -1
  13. package/bin/{chunk-gd5xwgp6.js → chunk-2aascrtb.js} +1 -1
  14. package/bin/{chunk-pv76qkym.js → chunk-31baz5n0.js} +1 -1
  15. package/bin/chunk-3hzj13pj.js +1 -0
  16. package/bin/{chunk-2xnys7v4.js → chunk-3n1rezd0.js} +1 -1
  17. package/bin/{chunk-zn9jbc6t.js → chunk-3qks722n.js} +1 -1
  18. package/bin/{chunk-hmsb7ehr.js → chunk-46ar48f9.js} +1 -1
  19. package/bin/{chunk-ga0drqj7.js → chunk-4qpa7b5t.js} +1 -1
  20. package/bin/{chunk-9n783gva.js → chunk-5d2q46mx.js} +1 -1
  21. package/bin/{chunk-ydagqpny.js → chunk-5t6c3038.js} +1 -1
  22. package/bin/chunk-5vkf99sk.js +1 -0
  23. package/bin/chunk-6xg65n5y.js +2 -0
  24. package/bin/chunk-6z65xd0w.js +3 -0
  25. package/bin/chunk-6zascpcz.js +2 -0
  26. package/bin/{chunk-qjjr3fff.js → chunk-77r8w95d.js} +1 -1
  27. package/bin/{chunk-58aabg1f.js → chunk-7hsgmjpa.js} +2 -2
  28. package/bin/{chunk-7mnezagc.js → chunk-88fg1sw7.js} +1 -1
  29. package/bin/{chunk-jyjnt0s9.js → chunk-898q6x3q.js} +2 -2
  30. package/bin/chunk-8dqq1fk0.js +2 -0
  31. package/bin/chunk-8tf6kgdj.js +2 -0
  32. package/bin/{chunk-b9hb5jzt.js → chunk-8wqfkm4c.js} +1 -1
  33. package/bin/{chunk-ag35pxnb.js → chunk-922nnh39.js} +1 -1
  34. package/bin/{chunk-ymyyap80.js → chunk-925q4paa.js} +1 -1
  35. package/bin/{chunk-0a5k9avd.js → chunk-97jzve52.js} +1 -1
  36. package/bin/{chunk-dzm2f82x.js → chunk-9ab6k4rq.js} +1 -1
  37. package/bin/{chunk-mwh2n8yt.js → chunk-9avkn3x1.js} +1 -1
  38. package/bin/{chunk-pmx9760x.js → chunk-9h027f50.js} +1 -1
  39. package/bin/chunk-av71yjaa.js +1 -0
  40. package/bin/{chunk-9bpjfkjf.js → chunk-b73ktdmd.js} +1 -1
  41. package/bin/{chunk-mjncyjwf.js → chunk-b8js74jk.js} +1 -1
  42. package/bin/{chunk-861dz0bf.js → chunk-bd71dp4j.js} +1 -1
  43. package/bin/{chunk-v3j7acwn.js → chunk-bs0fjz3w.js} +2 -2
  44. package/bin/chunk-carknytp.js +1 -0
  45. package/bin/chunk-chkx04mw.js +1 -0
  46. package/bin/chunk-crt1e1w1.js +2 -0
  47. package/bin/{chunk-kj751zje.js → chunk-cxhmr356.js} +1 -1
  48. package/bin/{chunk-hcz4snm7.js → chunk-d3wmdjze.js} +1 -1
  49. package/bin/{chunk-qf7n519d.js → chunk-dgat7wqv.js} +2 -2
  50. package/bin/{chunk-dwf5e5g3.js → chunk-dghtwyq1.js} +1 -1
  51. package/bin/chunk-dm2w12rc.js +2 -0
  52. package/bin/{chunk-5k03xpzq.js → chunk-dqgv5yy1.js} +1 -1
  53. package/bin/{chunk-q72ax3m8.js → chunk-e3s3rz2e.js} +1 -1
  54. package/bin/{chunk-79n633wf.js → chunk-e52nga6c.js} +1 -1
  55. package/bin/{chunk-8abs8d48.js → chunk-e7ndw3hg.js} +2 -2
  56. package/bin/{chunk-044xt1se.js → chunk-fbte2rmd.js} +1 -1
  57. package/bin/{chunk-k1r17nfa.js → chunk-fcvtgx1y.js} +1 -1
  58. package/bin/{chunk-cpr05qng.js → chunk-fz88kkk1.js} +1 -1
  59. package/bin/{chunk-82w2419d.js → chunk-g21jxrt9.js} +2 -2
  60. package/bin/{chunk-6724dtsx.js → chunk-g8th86na.js} +1 -1
  61. package/bin/chunk-gswbc6y9.js +2 -0
  62. package/bin/{chunk-pvy0gccg.js → chunk-gtrc5ka2.js} +1 -1
  63. package/bin/{chunk-mv8c5fky.js → chunk-hkbybhww.js} +1 -1
  64. package/bin/chunk-hnhq0dh9.js +1 -0
  65. package/bin/{chunk-e3c6hyz8.js → chunk-hr97a5j5.js} +1 -1
  66. package/bin/chunk-j0c7d9y1.js +1 -0
  67. package/bin/{chunk-7h75r7ep.js → chunk-j8qtab70.js} +1 -1
  68. package/bin/chunk-jqh8kavv.js +2 -0
  69. package/bin/{chunk-1w9dnk5p.js → chunk-js9yf457.js} +1 -1
  70. package/bin/chunk-jyzegph4.js +1 -0
  71. package/bin/{chunk-azfgjqjx.js → chunk-kfhtk3eh.js} +1 -1
  72. package/bin/chunk-kr06nrbx.js +2 -0
  73. package/bin/{chunk-nceqrqey.js → chunk-m4zpf9gg.js} +1 -1
  74. package/bin/{chunk-hqptebzb.js → chunk-mnfqdxms.js} +1 -1
  75. package/bin/{chunk-1ae8csk6.js → chunk-mqjzmn0e.js} +1 -1
  76. package/bin/{chunk-sp75qe28.js → chunk-mzg1h07d.js} +1 -1
  77. package/bin/chunk-nhsqp8jc.js +2 -0
  78. package/bin/chunk-nnkkem25.js +3 -0
  79. package/bin/{chunk-cj5qwc9c.js → chunk-nrwna4ha.js} +1 -1
  80. package/bin/chunk-nyhqy6q2.js +62 -0
  81. package/bin/{chunk-2djd6pq1.js → chunk-qksb0v3c.js} +2 -2
  82. package/bin/{chunk-wfex9jw0.js → chunk-qwg2e3wr.js} +6 -6
  83. package/bin/{chunk-2dz8nn9v.js → chunk-re0b7sj7.js} +1 -1
  84. package/bin/{chunk-x9q2vzn8.js → chunk-rtngbgpk.js} +1 -1
  85. package/bin/{chunk-k5bekrrp.js → chunk-s46zwr4p.js} +1 -1
  86. package/bin/chunk-s8t74q9m.js +1 -0
  87. package/bin/chunk-se8rgwp8.js +1 -0
  88. package/bin/{chunk-v98yavtp.js → chunk-srn8t0v7.js} +1 -1
  89. package/bin/{chunk-46c5xkmn.js → chunk-t3t6021k.js} +1 -1
  90. package/bin/{chunk-jbde7evp.js → chunk-thsbcbay.js} +1 -1
  91. package/bin/chunk-tm6z4hkd.css +1 -0
  92. package/bin/{chunk-v05d1aeq.js → chunk-w7dn1m95.js} +1 -1
  93. package/bin/{chunk-w1d5vmtc.js → chunk-wc8sc9r9.js} +1 -1
  94. package/bin/chunk-wckjyvtb.js +5 -0
  95. package/bin/{chunk-p3emandj.js → chunk-wfx81mfv.js} +2 -2
  96. package/bin/chunk-wsyg4rwg.js +2 -0
  97. package/bin/chunk-wtjc4565.js +1 -0
  98. package/bin/{chunk-ga3mh3cd.js → chunk-xcwbg4w9.js} +1 -1
  99. package/bin/chunk-y79r28gd.js +1 -0
  100. package/bin/{chunk-ngd23mtc.js → chunk-ybhgmvxa.js} +1 -1
  101. package/bin/{chunk-phw4ne8b.js → chunk-ygz6pawn.js} +1 -1
  102. package/bin/{chunk-m11g9hx7.js → chunk-yj4x7tpw.js} +2 -2
  103. package/bin/{chunk-hy50c4pw.js → chunk-ymeycphq.js} +2 -2
  104. package/bin/{chunk-c1v946wb.js → chunk-zemrvz79.js} +2 -2
  105. package/bin/{chunk-29pkpmvy.js → chunk-zzx99j8t.js} +1 -1
  106. package/bin/shumai-app.html +1 -1
  107. package/bin/shumai-app.js +248 -224
  108. package/package.json +8 -8
  109. package/prisma/migrations/20260723025234_add_ai_usage_table/migration.sql +28 -0
  110. package/prisma/migrations/20260723032755_add_ai_usage_unique_constraint/migration.sql +8 -0
  111. package/prisma/schema.prisma +25 -0
  112. package/bin/chunk-211y81mp.js +0 -1
  113. package/bin/chunk-25d1g086.js +0 -2
  114. package/bin/chunk-4fnak2zn.js +0 -2
  115. package/bin/chunk-4zq8vxcy.css +0 -1
  116. package/bin/chunk-50ebjdkv.js +0 -2
  117. package/bin/chunk-5j7axztv.js +0 -2
  118. package/bin/chunk-6h4ay2p8.js +0 -2
  119. package/bin/chunk-6w5cn6p3.js +0 -3
  120. package/bin/chunk-75jka5v9.js +0 -5
  121. package/bin/chunk-99db4j0k.js +0 -3
  122. package/bin/chunk-9evm8x70.js +0 -1
  123. package/bin/chunk-bepnbw1g.js +0 -2
  124. package/bin/chunk-bg24g9kk.js +0 -1
  125. package/bin/chunk-dqtq9t8e.js +0 -1
  126. package/bin/chunk-fgnxtqtk.js +0 -1
  127. package/bin/chunk-fxvb6g2r.js +0 -1
  128. package/bin/chunk-kjkmh26f.js +0 -1
  129. package/bin/chunk-m3dwydr3.js +0 -2
  130. package/bin/chunk-mk1jewvw.js +0 -2
  131. package/bin/chunk-q9sgjs4d.js +0 -1
  132. package/bin/chunk-s2725w64.js +0 -1
  133. package/bin/chunk-saq5797j.js +0 -1
  134. package/bin/chunk-sy8rqacm.js +0 -2
  135. package/bin/chunk-t84t3v6q.js +0 -1
  136. package/bin/chunk-ttsqdsxr.js +0 -2
  137. package/bin/chunk-vreq89j6.js +0 -1
  138. package/bin/chunk-wbhsmhgp.js +0 -2
  139. package/bin/chunk-wf4d1anc.js +0 -62
  140. package/bin/chunk-xv4mfppt.js +0 -2
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{hk as V,ik as k,jk as _,kk as E}from"./chunk-mv8c5fky.js";import{mk as b,nk as f,ok as A}from"./chunk-58aabg1f.js";import"./chunk-7h75r7ep.js";import{qk as L}from"./chunk-ydagqpny.js";import{rk as N}from"./chunk-dzm2f82x.js";import"./chunk-c1v946wb.js";import"./chunk-v3j7acwn.js";import{wk as B}from"./chunk-ga0drqj7.js";import{Ik as M}from"./chunk-2dz8nn9v.js";import{Mk as D,Nk as U}from"./chunk-ag35pxnb.js";import"./chunk-pmx9760x.js";import"./chunk-976v5s8y.js";var y=new Set(["openai","openai-codex","opencode"]);function H(w){if(w)return w;if(typeof process<"u"&&process.env.PI_CACHE_RETENTION==="long")return"long";return"short"}function S(w){return{sendSessionIdHeader:w.compat?.sendSessionIdHeader??!0,supportsLongCacheRetention:w.compat?.supportsLongCacheRetention??!0}}function T(w,F){return F==="long"&&w.supportsLongCacheRetention?"24h":void 0}function C(w){if(w instanceof Error){let F=w.status,z=typeof F==="number"?F:void 0;if(z!==void 0)return`OpenAI API error (${z}): ${w.message}`;return w.message}try{return JSON.stringify(w)}catch{return String(w)}}var I=(w,F,z)=>{let G=new U;return(async()=>{let Q={role:"assistant",content:[],api:w.api,provider:w.provider,model:w.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let W=z?.apiKey;if(!W)throw Error(`No API key for provider: ${w.provider}`);let X=H(z?.cacheRetention)==="none"?void 0:z?.sessionId,Z=v(w,F,W,z?.headers,X),Y=x(w,F,z),$=await z?.onPayload?.(Y,w);if($!==void 0)Y=$;let j={...z?.signal?{signal:z.signal}:{},...z?.timeoutMs!==void 0?{timeout:z.timeoutMs}:{},maxRetries:z?.maxRetries??0},{data:K,response:q}=await Z.responses.create(Y,j).withResponse();if(await z?.onResponse?.({status:q.status,headers:B(q.headers)},w),G.push({type:"start",partial:Q}),await A(K,Q,G,w,{serviceTier:z?.serviceTier,applyServiceTierPricing:(P,O)=>h(P,O,w)}),z?.signal?.aborted)throw Error("Request was aborted");if(Q.stopReason==="aborted"||Q.stopReason==="error")throw Error("An unknown error occurred");G.push({type:"done",reason:Q.stopReason,message:Q}),G.end()}catch(W){for(let J of Q.content)delete J.index,delete J.partialJson;Q.stopReason=z?.signal?.aborted?"aborted":"error",Q.errorMessage=C(W),G.push({type:"error",reason:Q.stopReason,error:Q}),G.end()}})(),G},i=(w,F,z)=>{let G=z?.apiKey;if(!G)throw Error(`No API key for provider: ${w.provider}`);let Q=M(w,z,G),W=z?.reasoning?D(w,z.reasoning):void 0;return I(w,F,{...Q,reasoningEffort:W==="off"?void 0:W})};function v(w,F,z,G,Q){let W=S(w),J={...w.headers};if(w.provider==="github-copilot"){let Z=_(F.messages),Y=E({messages:F.messages,hasImages:Z});Object.assign(J,Y)}if(Q){if(W.sendSessionIdHeader)J.session_id=Q;J["x-client-request-id"]=Q}if(G)Object.assign(J,G);let X=w.provider==="cloudflare-ai-gateway"?{...J,Authorization:J.Authorization??null,"cf-aig-authorization":`Bearer ${z}`}:J;return new N({apiKey:z,baseURL:V(w.provider)?k(w):w.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:X})}function x(w,F,z){let G=b(w,F,y),Q=H(z?.cacheRetention),W=S(w),J={model:w.id,input:G,stream:!0,prompt_cache_key:Q==="none"?void 0:L(z?.sessionId),prompt_cache_retention:T(W,Q),store:!1};if(z?.maxTokens)J.max_output_tokens=z?.maxTokens;if(z?.temperature!==void 0)J.temperature=z?.temperature;if(z?.serviceTier!==void 0)J.service_tier=z.serviceTier;if(F.tools&&F.tools.length>0)J.tools=f(F.tools);if(w.reasoning){if(z?.reasoningEffort||z?.reasoningSummary){let X=z?.reasoningEffort?w.thinkingLevelMap?.[z.reasoningEffort]??z.reasoningEffort:"medium";J.reasoning={effort:X,summary:z?.reasoningSummary||"auto"},J.include=["reasoning.encrypted_content"]}else if(w.provider!=="github-copilot"&&w.thinkingLevelMap?.off!==null)J.reasoning={effort:w.thinkingLevelMap?.off??"none"}}return J}function R(w,F){switch(F){case"flex":return 0.5;case"priority":return w.id==="gpt-5.5"?2.5:2;default:return 1}}function h(w,F,z){let G=R(z,F);if(G===1)return;w.cost.input*=G,w.cost.output*=G,w.cost.cacheRead*=G,w.cost.cacheWrite*=G,w.cost.total=w.cost.input+w.cost.output+w.cost.cacheRead+w.cost.cacheWrite}export{i as streamSimpleOpenAIResponses,I as streamOpenAIResponses};
2
+ import{nk as V,ok as k,pk as _,qk as E}from"./chunk-hkbybhww.js";import{sk as b,tk as f,uk as A}from"./chunk-7hsgmjpa.js";import"./chunk-j8qtab70.js";import{wk as L}from"./chunk-5t6c3038.js";import{xk as N}from"./chunk-9ab6k4rq.js";import"./chunk-zemrvz79.js";import"./chunk-bs0fjz3w.js";import{Ck as B}from"./chunk-4qpa7b5t.js";import{Ok as M}from"./chunk-re0b7sj7.js";import{Sk as D,Tk as U}from"./chunk-922nnh39.js";import"./chunk-9h027f50.js";import"./chunk-0qkj838r.js";var y=new Set(["openai","openai-codex","opencode"]);function H(w){if(w)return w;if(typeof process<"u"&&process.env.PI_CACHE_RETENTION==="long")return"long";return"short"}function S(w){return{sendSessionIdHeader:w.compat?.sendSessionIdHeader??!0,supportsLongCacheRetention:w.compat?.supportsLongCacheRetention??!0}}function T(w,F){return F==="long"&&w.supportsLongCacheRetention?"24h":void 0}function C(w){if(w instanceof Error){let F=w.status,z=typeof F==="number"?F:void 0;if(z!==void 0)return`OpenAI API error (${z}): ${w.message}`;return w.message}try{return JSON.stringify(w)}catch{return String(w)}}var I=(w,F,z)=>{let G=new U;return(async()=>{let Q={role:"assistant",content:[],api:w.api,provider:w.provider,model:w.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let W=z?.apiKey;if(!W)throw Error(`No API key for provider: ${w.provider}`);let X=H(z?.cacheRetention)==="none"?void 0:z?.sessionId,Z=v(w,F,W,z?.headers,X),Y=x(w,F,z),$=await z?.onPayload?.(Y,w);if($!==void 0)Y=$;let j={...z?.signal?{signal:z.signal}:{},...z?.timeoutMs!==void 0?{timeout:z.timeoutMs}:{},maxRetries:z?.maxRetries??0},{data:K,response:q}=await Z.responses.create(Y,j).withResponse();if(await z?.onResponse?.({status:q.status,headers:B(q.headers)},w),G.push({type:"start",partial:Q}),await A(K,Q,G,w,{serviceTier:z?.serviceTier,applyServiceTierPricing:(P,O)=>h(P,O,w)}),z?.signal?.aborted)throw Error("Request was aborted");if(Q.stopReason==="aborted"||Q.stopReason==="error")throw Error("An unknown error occurred");G.push({type:"done",reason:Q.stopReason,message:Q}),G.end()}catch(W){for(let J of Q.content)delete J.index,delete J.partialJson;Q.stopReason=z?.signal?.aborted?"aborted":"error",Q.errorMessage=C(W),G.push({type:"error",reason:Q.stopReason,error:Q}),G.end()}})(),G},i=(w,F,z)=>{let G=z?.apiKey;if(!G)throw Error(`No API key for provider: ${w.provider}`);let Q=M(w,z,G),W=z?.reasoning?D(w,z.reasoning):void 0;return I(w,F,{...Q,reasoningEffort:W==="off"?void 0:W})};function v(w,F,z,G,Q){let W=S(w),J={...w.headers};if(w.provider==="github-copilot"){let Z=_(F.messages),Y=E({messages:F.messages,hasImages:Z});Object.assign(J,Y)}if(Q){if(W.sendSessionIdHeader)J.session_id=Q;J["x-client-request-id"]=Q}if(G)Object.assign(J,G);let X=w.provider==="cloudflare-ai-gateway"?{...J,Authorization:J.Authorization??null,"cf-aig-authorization":`Bearer ${z}`}:J;return new N({apiKey:z,baseURL:V(w.provider)?k(w):w.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:X})}function x(w,F,z){let G=b(w,F,y),Q=H(z?.cacheRetention),W=S(w),J={model:w.id,input:G,stream:!0,prompt_cache_key:Q==="none"?void 0:L(z?.sessionId),prompt_cache_retention:T(W,Q),store:!1};if(z?.maxTokens)J.max_output_tokens=z?.maxTokens;if(z?.temperature!==void 0)J.temperature=z?.temperature;if(z?.serviceTier!==void 0)J.service_tier=z.serviceTier;if(F.tools&&F.tools.length>0)J.tools=f(F.tools);if(w.reasoning){if(z?.reasoningEffort||z?.reasoningSummary){let X=z?.reasoningEffort?w.thinkingLevelMap?.[z.reasoningEffort]??z.reasoningEffort:"medium";J.reasoning={effort:X,summary:z?.reasoningSummary||"auto"},J.include=["reasoning.encrypted_content"]}else if(w.provider!=="github-copilot"&&w.thinkingLevelMap?.off!==null)J.reasoning={effort:w.thinkingLevelMap?.off??"none"}}return J}function R(w,F){switch(F){case"flex":return 0.5;case"priority":return w.id==="gpt-5.5"?2.5:2;default:return 1}}function h(w,F,z){let G=R(z,F);if(G===1)return;w.cost.input*=G,w.cost.output*=G,w.cost.cacheRead*=G,w.cost.cacheWrite*=G,w.cost.total=w.cost.input+w.cost.output+w.cost.cacheRead+w.cost.cacheWrite}export{i as streamSimpleOpenAIResponses,I as streamOpenAIResponses};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Ae as k,De as E,Fe as J,He as I,Ie as V,Ke as X,Ne as _,oe as JG,pe as r,qe as u,se as H,xe as W,ye as l,ze as N}from"./chunk-ga3mh3cd.js";function q(G,Q){let Y={};if(!Object.keys(Q).length)return Y=G,Y;for(let[K,B]of Object.entries(G)){let O=Q[K];if(O===null)continue;Y[O??K]=B}return Y}function UG(G){let Q={};for(let[Y,K]of Object.entries(G))if(typeof K<"u")Q[Y]=K;return Q}class C extends Error{rawValue;rawMessage;static[Symbol.hasInstance](G){if(!(G instanceof Error))return!1;if(!("rawValue"in G))return!1;if(!("rawMessage"in G))return!1;if(!("pretty"in G))return!1;if(typeof G.pretty!=="function")return!1;return!0}constructor(G,Q,Y){super(`${G}: ${Q}`);this.name="SDKValidationError",this.cause=Q,this.rawValue=Y,this.rawMessage=G}pretty(){if(this.cause instanceof r)return`${this.rawMessage}
2
+ import{Ae as k,De as E,Fe as J,He as I,Ie as V,Ke as X,Ne as _,oe as JG,pe as r,qe as u,se as H,xe as W,ye as l,ze as N}from"./chunk-xcwbg4w9.js";function q(G,Q){let Y={};if(!Object.keys(Q).length)return Y=G,Y;for(let[K,B]of Object.entries(G)){let O=Q[K];if(O===null)continue;Y[O??K]=B}return Y}function UG(G){let Q={};for(let[Y,K]of Object.entries(G))if(typeof K<"u")Q[Y]=K;return Q}class C extends Error{rawValue;rawMessage;static[Symbol.hasInstance](G){if(!(G instanceof Error))return!1;if(!("rawValue"in G))return!1;if(!("rawMessage"in G))return!1;if(!("pretty"in G))return!1;if(typeof G.pretty!=="function")return!1;return!0}constructor(G,Q,Y){super(`${G}: ${Q}`);this.name="SDKValidationError",this.cause=Q,this.rawValue=Y,this.rawMessage=G}pretty(){if(this.cause instanceof r)return`${this.rawMessage}
3
3
  ${yG(this.cause)}`;else return this.toString()}}function yG(G){return u(G)}function t(G){return{ok:!0,value:G}}function s(G){return{ok:!1,error:G}}async function vG(G){let Q=await G;if(!Q.ok)throw Q.error;return Q.value}function i(G,Q,Y){try{return t(Q(G))}catch(K){return s(new C(Y,K,G))}}var o=J({prompt_tokens:W().default(0),completion_tokens:W().default(0),total_tokens:W().default(0),prompt_audio_seconds:_(W()).optional()}).catchall(N()).transform((G)=>{return q(G,{prompt_tokens:"promptTokens",completion_tokens:"completionTokens",total_tokens:"totalTokens",prompt_audio_seconds:"promptAudioSeconds"})}),hG=J({promptTokens:W().default(0),completionTokens:W().default(0),totalTokens:W().default(0),promptAudioSeconds:_(W()).optional()}).catchall(N()).transform((G)=>{return{...q(G,{promptTokens:"prompt_tokens",completionTokens:"completion_tokens",totalTokens:"total_tokens",promptAudioSeconds:"prompt_audio_seconds"})}});function j(G){return z++,G}var z=0,a=0;function P(){a++;let G=z;return{end:(Q)=>{let Y=z-G;if(z=G+(Q??Y),--a===0)z=0;return Y}}}function M(G){let Q=Object.values(G);return I([...Q.map((Y)=>X(Y)),H().transform((Y)=>j(Y))])}function lG(G){let Q=Object.values(G).filter((Y)=>typeof Y==="number");return I([...Q.map((Y)=>X(Y)),W().transform((Y)=>j(Y))])}function f(G){return H()}function cG(G){return W()}var e=Symbol("UNKNOWN");function n(G){return typeof G==="object"&&G!==null&&e in G}function GG(G,Q,Y={}){let{unknownValue:K="UNKNOWN",outputPropertyName:B}=Y;return k().transform((O)=>{let w=Object.defineProperties({raw:O,[B??G]:K,isUnknown:!0},{[e]:{value:!0,enumerable:!1,configurable:!1}});if(!(typeof O==="object"&&O!==null))return w;let F=O[G];if(typeof F!=="string")return w;if(!(F in Q))return w;let $=Q[F];if(!$)return w;let T=P(),y=$.safeParse(O);if(!y.success)return T.end(0),w;if(T.end(),B)y.data[B]=F;return y.data})}var HG=/^\d{4}-\d{2}-\d{2}$/;class v{serialized;static today(){return new v(new Date)}constructor(G){if(typeof G==="string"&&!HG.test(G))throw RangeError("RFCDate: date strings must be in the format YYYY-MM-DD: "+G);let Q=new Date(G);if(isNaN(+Q))throw RangeError("RFCDate: invalid date provided: "+G);if(this.serialized=Q.toISOString().slice(0,10),!HG.test(this.serialized))throw TypeError(`RFCDate: failed to build valid date with given value: ${G} serialized to ${this.serialized}`)}toJSON(){return this.toString()}toString(){return this.serialized}}function Z(G){return k().transform((Q,Y)=>{let K=[],B=G.map(()=>[]),O=P();for(let[D,F]of G.entries()){let $=P(),T=F.safeParse(Q),y=$.end(),xG=0;if(T.success){K.push({data:T.data,inexactCount:y,zeroDefaultCount:0,fieldCount:-1});continue}B[D].push(...T.error.issues)}if(K.length===0)return O.end(0),Y.addIssue({input:Q,code:"invalid_union",errors:B}),JG;let w=K[0];for(let D of K){if(K.length>1)D.fieldCount=PG(D.data);w=zG(D,w)}return O.end(w.inexactCount),w.data})}function zG(G,Q){let Y=G.inexactCount===0,K=Q.inexactCount===0;if(Y!==K)return Y?G:Q;let B=G.fieldCount-G.zeroDefaultCount,O=Q.fieldCount-Q.zeroDefaultCount;if(B!==O)return B>O?G:Q;return G.inexactCount<Q.inexactCount?G:Q}function PG(G){let Q=0,Y=[G],K=0;while(K<Y.length){let B=Y[K++];if(B===void 0||n(B))continue;let O=typeof B;if(B===null||O==="number"||O==="string"||O==="boolean"||O==="bigint"||B instanceof Date||B instanceof v){Q++;continue}if(Array.isArray(B)){Y.push(...B);continue}if(O==="object")Y.push(...Object.values(B))}return Q}var QG=J({type:X("input_audio"),input_audio:H()}).transform((G)=>{return q(G,{input_audio:"inputAudio"})}),XG=J({type:X("input_audio"),inputAudio:H()}).transform((G)=>{return q(G,{inputAudio:"input_audio"})});var YG=J({type:X("document_url").default("document_url"),document_url:H(),document_name:_(H()).optional()}).transform((G)=>{return q(G,{document_url:"documentUrl",document_name:"documentName"})}),_G=J({type:X("document_url").default("document_url"),documentUrl:H(),documentName:_(H()).optional()}).transform((G)=>{return q(G,{documentUrl:"document_url",documentName:"document_name"})});var ZG=J({type:X("file").default("file"),file_id:H()}).transform((G)=>{return q(G,{file_id:"fileId"})}),WG=J({type:X("file").default("file"),fileId:H()}).transform((G)=>{return q(G,{fileId:"file_id"})});var qG={Low:"low",Auto:"auto",High:"high"},BG=M(qG),KG=f(qG);var b=J({url:H(),detail:_(BG).optional()}),p=J({url:H(),detail:_(KG).optional()});var BH=Z([b,H()]),KH=Z([p,H()]);var OG=J({type:X("image_url").default("image_url"),image_url:Z([b,H()])}).transform((G)=>{return q(G,{image_url:"imageUrl"})}),AG=J({type:X("image_url").default("image_url"),imageUrl:Z([p,H()])}).transform((G)=>{return q(G,{imageUrl:"image_url"})});var wH=Z([W(),H()]),NH=Z([W(),H()]);var L=J({type:X("reference").default("reference"),reference_ids:E(Z([W(),H()]))}).transform((G)=>{return q(G,{reference_ids:"referenceIds"})}),R=J({type:X("reference").default("reference"),referenceIds:E(Z([W(),H()]))}).transform((G)=>{return q(G,{referenceIds:"reference_ids"})});var x=J({type:X("text").default("text"),text:H()}),U=J({type:X("text").default("text"),text:H()});var EG={WebSearch:"web_search",WebSearchPremium:"web_search_premium",CodeInterpreter:"code_interpreter",ImageGeneration:"image_generation",DocumentLibrary:"document_library"},h=M(EG),g=f(EG);var yH=Z([h,H()]),zH=Z([g,H()]);var d=J({type:X("tool_reference").default("tool_reference"),tool:Z([h,H()]),title:H(),url:_(H()).optional(),favicon:_(H()).optional(),description:_(H()).optional()}),m=J({type:X("tool_reference").default("tool_reference"),tool:Z([g,H()]),title:H(),url:_(H()).optional(),favicon:_(H()).optional(),description:_(H()).optional()});var UH=Z([d,x,L]),$H=Z([m,U,R]);var wG=J({type:X("thinking").default("thinking"),thinking:E(Z([d,x,L])),signature:_(H()).optional(),closed:l().optional()}),NG=J({type:X("thinking").default("thinking"),thinking:E(Z([m,U,R])),signature:_(H()).optional(),closed:l().optional()});var c=GG("type",{image_url:OG.and(J({type:X("image_url")})),document_url:YG.and(J({type:X("document_url")})),text:x.and(J({type:X("text")})),reference:L.and(J({type:X("reference")})),file:ZG.and(J({type:X("file")})),thinking:wG.and(J({type:X("thinking")})),input_audio:QG}),gH=I([AG.and(J({type:X("image_url")})),_G.and(J({type:X("document_url")})),U.and(J({type:X("text")})),R.and(J({type:X("reference")})),WG.and(J({type:X("file")})),NG.and(J({type:X("thinking")})),XG]);var lH=Z([V(H(),N()),H()]),cH=Z([V(H(),N()),H()]);var VG=J({name:H(),arguments:Z([V(H(),N()),H()])}),DG=J({name:H(),arguments:Z([V(H(),N()),H()])});var FG=J({id:H().default("null"),type:H().optional(),function:VG,index:W().default(0)}),tH=J({id:H().default("null"),type:H().optional(),function:DG,index:W().default(0)});var nH=Z([H(),E(c)]);var TG=J({role:_(H()).optional(),content:_(Z([H(),E(c)])).optional(),tool_calls:_(E(FG)).optional(),tool_call_id:_(H()).optional(),index:_(W()).optional(),metadata:_(V(H(),N())).optional()}).transform((G)=>{return q(G,{tool_calls:"toolCalls",tool_call_id:"toolCallId"})});var IG={Stop:"stop",Length:"length",Error:"error",ToolCalls:"tool_calls"},LG=M(IG),MG=J({index:W(),delta:TG,finish_reason:_(LG)}).transform((G)=>{return q(G,{finish_reason:"finishReason"})});var RG=J({id:H(),object:H().optional(),created:W().optional(),model:H(),usage:o.optional(),choices:E(MG)});function ZJ(G){return i(G,(Q)=>RG.parse(JSON.parse(Q)),"Failed to parse 'CompletionChunk' from JSON")}
4
4
  export{yG as gb,t as hb,s as ib,vG as jb,i as kb,q as lb,UG as mb,M as nb,lG as ob,f as pb,cG as qb,GG as rb,Z as sb,YG as tb,_G as ub,WG as vb,OG as wb,AG as xb,x as yb,U as zb,h as Ab,g as Bb,d as Cb,m as Db,wG as Eb,NG as Fb,c as Gb,gH as Hb,FG as Ib,tH as Jb,TG as Kb,o as Lb,hG as Mb,RG as Nb,ZJ as Ob};
@@ -21,4 +21,4 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
21
21
  new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
22
22
 
23
23
  https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
24
- `);this.baseURL=z.baseURL,this.timeout=z.timeout??x2.DEFAULT_TIMEOUT,this.logger=z.logger??console;let N="warn";this.logLevel=N,this.logLevel=Z2(z.logLevel,"ClientOptions.logLevel",this)??Z2(a("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??N,this.fetchOptions=z.fetchOptions,this.maxRetries=z.maxRetries??2,this.fetch=z.fetch??b2(),E(this,m0,g2,"f"),this._options=z,this.apiKey=typeof Z==="string"?Z:"Missing Key",this.organization=Y,this.project=$,this.webhookSecret=G}withOptions(X){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...X})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:X,nulls:Z}){return}async authHeaders(X){return V([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(X){return n2(X)}getUserAgent(){return`${this.constructor.name}/JS ${NX}`}defaultIdempotencyKey(){return`stainless-node-retry-${u0()}`}makeStatusError(X,Z,Y,$){return f.generate(X,Z,Y,$)}async _callApiKey(){let X=this._options.apiKey;if(typeof X!=="function")return!1;let Z;try{Z=await X()}catch(Y){if(Y instanceof U)throw Y;throw new U(`Failed to get token from 'apiKey' function: ${Y.message}`,{cause:Y})}if(typeof Z!=="string"||!Z)throw new U(`Expected 'apiKey' function argument to return a string but it returned ${Z}`);return this.apiKey=Z,!0}buildURL(X,Z,Y){let $=!K(this,O2,"m",y3).call(this)&&Y||this.baseURL,G=C2(X)?new URL(X):new URL($+($.endsWith("/")&&X.startsWith("/")?X.slice(1):X)),W=this.defaultQuery();if(!D2(W))Z={...W,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))G.search=this.stringifyQuery(Z);return G.toString()}async prepareOptions(X){await this._callApiKey()}async prepareRequest(X,{url:Z,options:Y}){}get(X,Z){return this.methodRequest("get",X,Z)}post(X,Z){return this.methodRequest("post",X,Z)}patch(X,Z){return this.methodRequest("patch",X,Z)}put(X,Z){return this.methodRequest("put",X,Z)}delete(X,Z){return this.methodRequest("delete",X,Z)}methodRequest(X,Z,Y){return this.request(Promise.resolve(Y).then(($)=>{return{method:X,path:Z,...$}}))}request(X,Z=null){return new xX(this,this.makeRequest(X,Z,void 0))}async makeRequest(X,Z,Y){let $=await X,G=$.maxRetries??this.maxRetries;if(Z==null)Z=G;await this.prepareOptions($);let{req:W,url:z,timeout:N}=await this.buildRequest($,{retryCount:G-Z});await this.prepareRequest(W,{url:z,options:$});let w="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),F=Y===void 0?"":`, retryOf: ${Y}`,M=Date.now();if(S(this).debug(`[${w}] sending request`,GX({retryOfRequestLogID:Y,method:$.method,url:z,options:$,headers:W.headers})),$.signal?.aborted)throw new I;let H=new AbortController,B=await this.fetchWithTimeout(z,W,N,H).catch(wZ),q=Date.now();if(B instanceof globalThis.Error){let C=`retrying, ${Z} attempts remaining`;if($.signal?.aborted)throw new I;let P=VZ(B)||/timed? ?out/i.test(String(B)+("cause"in B?String(B.cause):""));if(Z)return S(this).info(`[${w}] connection ${P?"timed out":"failed"} - ${C}`),S(this).debug(`[${w}] connection ${P?"timed out":"failed"} (${C})`,GX({retryOfRequestLogID:Y,url:z,durationMs:q-M,message:B.message})),this.retryRequest($,Z,Y??w);if(S(this).info(`[${w}] connection ${P?"timed out":"failed"} - error; no more retries left`),S(this).debug(`[${w}] connection ${P?"timed out":"failed"} (error; no more retries left)`,GX({retryOfRequestLogID:Y,url:z,durationMs:q-M,message:B.message})),P)throw new OX;throw new LX({cause:B})}let T=[...B.headers.entries()].filter(([C])=>C==="x-request-id").map(([C,P])=>", "+C+": "+JSON.stringify(P)).join(""),D=`[${w}${F}${T}] ${W.method} ${z} ${B.ok?"succeeded":"failed"} with status ${B.status} in ${q-M}ms`;if(!B.ok){let C=await this.shouldRetry(B);if(Z&&C){let j=`retrying, ${Z} attempts remaining`;return await v2(B.body),S(this).info(`${D} - ${j}`),S(this).debug(`[${w}] response error (${j})`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,durationMs:q-M})),this.retryRequest($,Z,Y??w,B.headers)}let P=C?"error; no more retries left":"error; not retryable";S(this).info(`${D} - ${P}`);let x=await B.text().catch((j)=>wZ(j).message),_=S2(x),R=_?void 0:x;throw S(this).debug(`[${w}] response error (${P})`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,message:R,durationMs:Date.now()-M})),this.makeStatusError(B.status,_,R,B.headers)}return S(this).info(D),S(this).debug(`[${w}] response start`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,durationMs:q-M})),{response:B,options:$,controller:H,requestLogID:w,retryOfRequestLogID:Y,startTime:M}}getAPIList(X,Z,Y){return this.requestAPIList(Z,Y&&"then"in Y?Y.then(($)=>({method:"get",path:X,...$})):{method:"get",path:X,...Y})}requestAPIList(X,Z){let Y=this.makeRequest(Z,null,void 0);return new q0(this,Y,X)}async fetchWithTimeout(X,Z,Y,$){let{signal:G,method:W,...z}=Z||{},N=this._makeAbort($);if(G)G.addEventListener("abort",N,{once:!0});let w=setTimeout(N,Y),F=globalThis.ReadableStream&&z.body instanceof globalThis.ReadableStream||typeof z.body==="object"&&z.body!==null&&Symbol.asyncIterator in z.body,M={signal:$.signal,...F?{duplex:"half"}:{},method:"GET",...z};if(W)M.method=W.toUpperCase();try{return await this.fetch.call(void 0,X,M)}finally{clearTimeout(w)}}async shouldRetry(X){let Z=X.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if(X.status===408)return!0;if(X.status===409)return!0;if(X.status===429)return!0;if(X.status>=500)return!0;return!1}async retryRequest(X,Z,Y,$){let G,W=$?.get("retry-after-ms");if(W){let N=parseFloat(W);if(!Number.isNaN(N))G=N}let z=$?.get("retry-after");if(z&&!G){let N=parseFloat(z);if(!Number.isNaN(N))G=N*1000;else G=Date.parse(z)-Date.now()}if(G===void 0){let N=X.maxRetries??this.maxRetries;G=this.calculateDefaultRetryTimeoutMillis(Z,N)}return await s(G),this.makeRequest(X,Z-1,Y)}calculateDefaultRetryTimeoutMillis(X,Z){let G=Z-X,W=Math.min(0.5*Math.pow(2,G),8),z=1-Math.random()*0.25;return W*z*1000}async buildRequest(X,{retryCount:Z=0}={}){let Y={...X},{method:$,path:G,query:W,defaultBaseURL:z}=Y,N=this.buildURL(G,W,z);if("timeout"in Y)R2("timeout",Y.timeout);Y.timeout=Y.timeout??this.timeout;let{bodyHeaders:w,body:F}=this.buildBody({options:Y}),M=await this.buildHeaders({options:X,method:$,bodyHeaders:w,retryCount:Z});return{req:{method:$,headers:M,...Y.signal&&{signal:Y.signal},...globalThis.ReadableStream&&F instanceof globalThis.ReadableStream&&{duplex:"half"},...F&&{body:F},...this.fetchOptions??{},...Y.fetchOptions??{}},url:N,timeout:Y.timeout}}async buildHeaders({options:X,method:Z,bodyHeaders:Y,retryCount:$}){let G={};if(this.idempotencyHeader&&Z!=="get"){if(!X.idempotencyKey)X.idempotencyKey=this.defaultIdempotencyKey();G[this.idempotencyHeader]=X.idempotencyKey}let W=V([G,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String($),...X.timeout?{"X-Stainless-Timeout":String(Math.trunc(X.timeout/1000))}:{},...y2(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(X),this._options.defaultHeaders,Y,X.headers]);return this.validateHeaders(W),W.values}_makeAbort(X){return()=>X.abort()}buildBody({options:{body:X,headers:Z}}){if(!X)return{bodyHeaders:void 0,body:void 0};let Y=V([Z]);if(ArrayBuffer.isView(X)||X instanceof ArrayBuffer||X instanceof DataView||typeof X==="string"&&Y.values.has("content-type")||globalThis.Blob&&X instanceof globalThis.Blob||X instanceof FormData||X instanceof URLSearchParams||globalThis.ReadableStream&&X instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:X};else if(typeof X==="object"&&((Symbol.asyncIterator in X)||(Symbol.iterator in X)&&("next"in X)&&typeof X.next==="function"))return{bodyHeaders:void 0,body:w0(X)};else if(typeof X==="object"&&Y.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(X)};else return K(this,m0,"f").call(this,{body:X,headers:Y})}}x2=L,m0=new WeakMap,O2=new WeakSet,y3=function(){return this.baseURL!=="https://api.openai.com/v1"};L.OpenAI=x2;L.DEFAULT_TIMEOUT=600000;L.OpenAIError=U;L.APIError=f;L.APIConnectionError=LX;L.APIConnectionTimeoutError=OX;L.APIUserAbortError=I;L.NotFoundError=TZ;L.ConflictError=MZ;L.RateLimitError=qZ;L.BadRequestError=HZ;L.AuthenticationError=UZ;L.InternalServerError=LZ;L.PermissionDeniedError=FZ;L.UnprocessableEntityError=EZ;L.InvalidWebhookSignatureError=$X;L.toFile=O0;L.Completions=sX;L.Chat=CX;L.Embeddings=oX;L.Files=XZ;L.Images=GZ;L.Audio=QX;L.Moderations=KZ;L.Models=WZ;L.FineTuning=ZX;L.Graders=bX;L.VectorStores=qX;L.Webhooks=NZ;L.Beta=XX;L.Batches=nX;L.Uploads=vX;L.Responses=MX;L.Realtime=FX;L.Conversations=IX;L.Evals=yX;L.Containers=jX;L.Skills=EX;L.Videos=QZ;class b3 extends L{constructor({baseURL:X=a("OPENAI_BASE_URL"),apiKey:Z=a("AZURE_OPENAI_API_KEY"),apiVersion:Y=a("OPENAI_API_VERSION"),endpoint:$,deployment:G,azureADTokenProvider:W,dangerouslyAllowBrowser:z,...N}={}){if(!Y)throw new U("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");if(typeof W==="function")z=!0;if(!W&&!Z)throw new U("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(W&&Z)throw new U("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(N.defaultQuery={...N.defaultQuery,"api-version":Y},!X){if(!$)$=process.env.AZURE_OPENAI_ENDPOINT;if(!$)throw new U("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");X=`${$}/openai`}else if($)throw new U("baseURL and endpoint are mutually exclusive");super({apiKey:W??Z,baseURL:X,...N,...z!==void 0?{dangerouslyAllowBrowser:z}:{}});this.apiVersion="",this.apiVersion=Y,this.deploymentName=G}async buildRequest(X,Z={}){if(J8.has(X.path)&&X.method==="post"&&X.body!==void 0){if(!gX(X.body))throw Error("Expected request body to be an object");let Y=this.deploymentName||X.body.model||X.__metadata?.model;if(Y!==void 0&&!this.baseURL.includes("/deployments"))X.path=`/deployments/${Y}${X.path}`}return super.buildRequest(X,Z)}async authHeaders(X){if(typeof this._options.apiKey==="string")return V([{"api-key":this.apiKey}]);return super.authHeaders(X)}}var J8=new Set(["/completions","/chat/completions","/embeddings","/audio/transcriptions","/audio/translations","/audio/speech","/images/generations","/batches","/images/edits"]);export{L as rk,b3 as sk};
24
+ `);this.baseURL=z.baseURL,this.timeout=z.timeout??x2.DEFAULT_TIMEOUT,this.logger=z.logger??console;let N="warn";this.logLevel=N,this.logLevel=Z2(z.logLevel,"ClientOptions.logLevel",this)??Z2(a("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??N,this.fetchOptions=z.fetchOptions,this.maxRetries=z.maxRetries??2,this.fetch=z.fetch??b2(),E(this,m0,g2,"f"),this._options=z,this.apiKey=typeof Z==="string"?Z:"Missing Key",this.organization=Y,this.project=$,this.webhookSecret=G}withOptions(X){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...X})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:X,nulls:Z}){return}async authHeaders(X){return V([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(X){return n2(X)}getUserAgent(){return`${this.constructor.name}/JS ${NX}`}defaultIdempotencyKey(){return`stainless-node-retry-${u0()}`}makeStatusError(X,Z,Y,$){return f.generate(X,Z,Y,$)}async _callApiKey(){let X=this._options.apiKey;if(typeof X!=="function")return!1;let Z;try{Z=await X()}catch(Y){if(Y instanceof U)throw Y;throw new U(`Failed to get token from 'apiKey' function: ${Y.message}`,{cause:Y})}if(typeof Z!=="string"||!Z)throw new U(`Expected 'apiKey' function argument to return a string but it returned ${Z}`);return this.apiKey=Z,!0}buildURL(X,Z,Y){let $=!K(this,O2,"m",y3).call(this)&&Y||this.baseURL,G=C2(X)?new URL(X):new URL($+($.endsWith("/")&&X.startsWith("/")?X.slice(1):X)),W=this.defaultQuery();if(!D2(W))Z={...W,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))G.search=this.stringifyQuery(Z);return G.toString()}async prepareOptions(X){await this._callApiKey()}async prepareRequest(X,{url:Z,options:Y}){}get(X,Z){return this.methodRequest("get",X,Z)}post(X,Z){return this.methodRequest("post",X,Z)}patch(X,Z){return this.methodRequest("patch",X,Z)}put(X,Z){return this.methodRequest("put",X,Z)}delete(X,Z){return this.methodRequest("delete",X,Z)}methodRequest(X,Z,Y){return this.request(Promise.resolve(Y).then(($)=>{return{method:X,path:Z,...$}}))}request(X,Z=null){return new xX(this,this.makeRequest(X,Z,void 0))}async makeRequest(X,Z,Y){let $=await X,G=$.maxRetries??this.maxRetries;if(Z==null)Z=G;await this.prepareOptions($);let{req:W,url:z,timeout:N}=await this.buildRequest($,{retryCount:G-Z});await this.prepareRequest(W,{url:z,options:$});let w="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),F=Y===void 0?"":`, retryOf: ${Y}`,M=Date.now();if(S(this).debug(`[${w}] sending request`,GX({retryOfRequestLogID:Y,method:$.method,url:z,options:$,headers:W.headers})),$.signal?.aborted)throw new I;let H=new AbortController,B=await this.fetchWithTimeout(z,W,N,H).catch(wZ),q=Date.now();if(B instanceof globalThis.Error){let C=`retrying, ${Z} attempts remaining`;if($.signal?.aborted)throw new I;let P=VZ(B)||/timed? ?out/i.test(String(B)+("cause"in B?String(B.cause):""));if(Z)return S(this).info(`[${w}] connection ${P?"timed out":"failed"} - ${C}`),S(this).debug(`[${w}] connection ${P?"timed out":"failed"} (${C})`,GX({retryOfRequestLogID:Y,url:z,durationMs:q-M,message:B.message})),this.retryRequest($,Z,Y??w);if(S(this).info(`[${w}] connection ${P?"timed out":"failed"} - error; no more retries left`),S(this).debug(`[${w}] connection ${P?"timed out":"failed"} (error; no more retries left)`,GX({retryOfRequestLogID:Y,url:z,durationMs:q-M,message:B.message})),P)throw new OX;throw new LX({cause:B})}let T=[...B.headers.entries()].filter(([C])=>C==="x-request-id").map(([C,P])=>", "+C+": "+JSON.stringify(P)).join(""),D=`[${w}${F}${T}] ${W.method} ${z} ${B.ok?"succeeded":"failed"} with status ${B.status} in ${q-M}ms`;if(!B.ok){let C=await this.shouldRetry(B);if(Z&&C){let j=`retrying, ${Z} attempts remaining`;return await v2(B.body),S(this).info(`${D} - ${j}`),S(this).debug(`[${w}] response error (${j})`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,durationMs:q-M})),this.retryRequest($,Z,Y??w,B.headers)}let P=C?"error; no more retries left":"error; not retryable";S(this).info(`${D} - ${P}`);let x=await B.text().catch((j)=>wZ(j).message),_=S2(x),R=_?void 0:x;throw S(this).debug(`[${w}] response error (${P})`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,message:R,durationMs:Date.now()-M})),this.makeStatusError(B.status,_,R,B.headers)}return S(this).info(D),S(this).debug(`[${w}] response start`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,durationMs:q-M})),{response:B,options:$,controller:H,requestLogID:w,retryOfRequestLogID:Y,startTime:M}}getAPIList(X,Z,Y){return this.requestAPIList(Z,Y&&"then"in Y?Y.then(($)=>({method:"get",path:X,...$})):{method:"get",path:X,...Y})}requestAPIList(X,Z){let Y=this.makeRequest(Z,null,void 0);return new q0(this,Y,X)}async fetchWithTimeout(X,Z,Y,$){let{signal:G,method:W,...z}=Z||{},N=this._makeAbort($);if(G)G.addEventListener("abort",N,{once:!0});let w=setTimeout(N,Y),F=globalThis.ReadableStream&&z.body instanceof globalThis.ReadableStream||typeof z.body==="object"&&z.body!==null&&Symbol.asyncIterator in z.body,M={signal:$.signal,...F?{duplex:"half"}:{},method:"GET",...z};if(W)M.method=W.toUpperCase();try{return await this.fetch.call(void 0,X,M)}finally{clearTimeout(w)}}async shouldRetry(X){let Z=X.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if(X.status===408)return!0;if(X.status===409)return!0;if(X.status===429)return!0;if(X.status>=500)return!0;return!1}async retryRequest(X,Z,Y,$){let G,W=$?.get("retry-after-ms");if(W){let N=parseFloat(W);if(!Number.isNaN(N))G=N}let z=$?.get("retry-after");if(z&&!G){let N=parseFloat(z);if(!Number.isNaN(N))G=N*1000;else G=Date.parse(z)-Date.now()}if(G===void 0){let N=X.maxRetries??this.maxRetries;G=this.calculateDefaultRetryTimeoutMillis(Z,N)}return await s(G),this.makeRequest(X,Z-1,Y)}calculateDefaultRetryTimeoutMillis(X,Z){let G=Z-X,W=Math.min(0.5*Math.pow(2,G),8),z=1-Math.random()*0.25;return W*z*1000}async buildRequest(X,{retryCount:Z=0}={}){let Y={...X},{method:$,path:G,query:W,defaultBaseURL:z}=Y,N=this.buildURL(G,W,z);if("timeout"in Y)R2("timeout",Y.timeout);Y.timeout=Y.timeout??this.timeout;let{bodyHeaders:w,body:F}=this.buildBody({options:Y}),M=await this.buildHeaders({options:X,method:$,bodyHeaders:w,retryCount:Z});return{req:{method:$,headers:M,...Y.signal&&{signal:Y.signal},...globalThis.ReadableStream&&F instanceof globalThis.ReadableStream&&{duplex:"half"},...F&&{body:F},...this.fetchOptions??{},...Y.fetchOptions??{}},url:N,timeout:Y.timeout}}async buildHeaders({options:X,method:Z,bodyHeaders:Y,retryCount:$}){let G={};if(this.idempotencyHeader&&Z!=="get"){if(!X.idempotencyKey)X.idempotencyKey=this.defaultIdempotencyKey();G[this.idempotencyHeader]=X.idempotencyKey}let W=V([G,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String($),...X.timeout?{"X-Stainless-Timeout":String(Math.trunc(X.timeout/1000))}:{},...y2(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(X),this._options.defaultHeaders,Y,X.headers]);return this.validateHeaders(W),W.values}_makeAbort(X){return()=>X.abort()}buildBody({options:{body:X,headers:Z}}){if(!X)return{bodyHeaders:void 0,body:void 0};let Y=V([Z]);if(ArrayBuffer.isView(X)||X instanceof ArrayBuffer||X instanceof DataView||typeof X==="string"&&Y.values.has("content-type")||globalThis.Blob&&X instanceof globalThis.Blob||X instanceof FormData||X instanceof URLSearchParams||globalThis.ReadableStream&&X instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:X};else if(typeof X==="object"&&((Symbol.asyncIterator in X)||(Symbol.iterator in X)&&("next"in X)&&typeof X.next==="function"))return{bodyHeaders:void 0,body:w0(X)};else if(typeof X==="object"&&Y.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(X)};else return K(this,m0,"f").call(this,{body:X,headers:Y})}}x2=L,m0=new WeakMap,O2=new WeakSet,y3=function(){return this.baseURL!=="https://api.openai.com/v1"};L.OpenAI=x2;L.DEFAULT_TIMEOUT=600000;L.OpenAIError=U;L.APIError=f;L.APIConnectionError=LX;L.APIConnectionTimeoutError=OX;L.APIUserAbortError=I;L.NotFoundError=TZ;L.ConflictError=MZ;L.RateLimitError=qZ;L.BadRequestError=HZ;L.AuthenticationError=UZ;L.InternalServerError=LZ;L.PermissionDeniedError=FZ;L.UnprocessableEntityError=EZ;L.InvalidWebhookSignatureError=$X;L.toFile=O0;L.Completions=sX;L.Chat=CX;L.Embeddings=oX;L.Files=XZ;L.Images=GZ;L.Audio=QX;L.Moderations=KZ;L.Models=WZ;L.FineTuning=ZX;L.Graders=bX;L.VectorStores=qX;L.Webhooks=NZ;L.Beta=XX;L.Batches=nX;L.Uploads=vX;L.Responses=MX;L.Realtime=FX;L.Conversations=IX;L.Evals=yX;L.Containers=jX;L.Skills=EX;L.Videos=QZ;class b3 extends L{constructor({baseURL:X=a("OPENAI_BASE_URL"),apiKey:Z=a("AZURE_OPENAI_API_KEY"),apiVersion:Y=a("OPENAI_API_VERSION"),endpoint:$,deployment:G,azureADTokenProvider:W,dangerouslyAllowBrowser:z,...N}={}){if(!Y)throw new U("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");if(typeof W==="function")z=!0;if(!W&&!Z)throw new U("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(W&&Z)throw new U("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(N.defaultQuery={...N.defaultQuery,"api-version":Y},!X){if(!$)$=process.env.AZURE_OPENAI_ENDPOINT;if(!$)throw new U("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");X=`${$}/openai`}else if($)throw new U("baseURL and endpoint are mutually exclusive");super({apiKey:W??Z,baseURL:X,...N,...z!==void 0?{dangerouslyAllowBrowser:z}:{}});this.apiVersion="",this.apiVersion=Y,this.deploymentName=G}async buildRequest(X,Z={}){if(J8.has(X.path)&&X.method==="post"&&X.body!==void 0){if(!gX(X.body))throw Error("Expected request body to be an object");let Y=this.deploymentName||X.body.model||X.__metadata?.model;if(Y!==void 0&&!this.baseURL.includes("/deployments"))X.path=`/deployments/${Y}${X.path}`}return super.buildRequest(X,Z)}async authHeaders(X){if(typeof this._options.apiKey==="string")return V([{"api-key":this.apiKey}]);return super.authHeaders(X)}}var J8=new Set(["/completions","/chat/completions","/embeddings","/audio/transcriptions","/audio/translations","/audio/speech","/images/generations","/batches","/images/edits"]);export{L as xk,b3 as yk};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Uk as G}from"./chunk-976v5s8y.js";var q=null;function H(k){if(typeof process>"u"||!process.versions?.bun||Object.keys(process.env).length>0)return;if(q===null){q=new Map;try{let{readFileSync:w}=G("fs"),D=w("/proc/self/environ","utf-8");for(let z of D.split("\x00")){let A=z.indexOf("=");if(A>0)q.set(z.slice(0,A),z.slice(A+1))}}catch{}}return q.get(k)}function I(k,w){return w?.[k]||(typeof process<"u"?process.env[k]:void 0)||H(k)||void 0}
2
+ import{_k as G}from"./chunk-0qkj838r.js";var q=null;function H(k){if(typeof process>"u"||!process.versions?.bun||Object.keys(process.env).length>0)return;if(q===null){q=new Map;try{let{readFileSync:w}=G("fs"),D=w("/proc/self/environ","utf-8");for(let z of D.split("\x00")){let A=z.indexOf("=");if(A>0)q.set(z.slice(0,A),z.slice(A+1))}}catch{}}return q.get(k)}function I(k,w){return w?.[k]||(typeof process<"u"?process.env[k]:void 0)||H(k)||void 0}
3
3
  export{I as Zb};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  function f(b){return b.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"")}
3
- export{f as Ok};
3
+ export{f as Uk};
@@ -0,0 +1 @@
1
+ import{Ya as lz}from"./chunk-kr06nrbx.js";import{Za as a}from"./chunk-b8js74jk.js";import{$a as Dz,_a as yz,ab as bz,bb as Cz,cb as fz,db as Iz,eb as gz,fb as uz}from"./chunk-0xbf8bcg.js";import{Ng as hz}from"./chunk-fz88kkk1.js";import{Og as c}from"./chunk-dghtwyq1.js";import{Qg as E,Rg as b,Tg as C,Ug as f,Vg as M,ch as wz,dh as n,eh as Rz,fh as Kz,gh as kz,hh as qz,ih as Az,jh as Ez}from"./chunk-gswbc6y9.js";import{$h as Bz,Bh as m,Fj as Gz,Gh as Pz,Mj as Lz,Qh as Yz,Sh as X,Th as Jz,Uh as Uz,ai as zz,ci as Wz,di as $z,gk as _z,hk as Sz,ik as Mz,jk as vz,mh as Xz,mk as V,nh as N,oh as z,oi as Tz,oj as Zz,ph as J,qh as x,th as Vz,uh as Oz,vh as k,vi as i}from"./chunk-nyhqy6q2.js";import{Vk as Qz}from"./chunk-0qkj838r.js";var K=Qz(Xz(),1);function Fz({open:Z,onOpenChange:$,mode:T,teamId:F,project:W}){let q=x(),R=m(),[H,O]=K.useState(""),[v,B]=K.useState(!0),[I,P]=K.useState(void 0),[h,U]=K.useState(void 0),[A,w]=K.useState(!1),S=K.useRef(null);K.useEffect(()=>{if(Z)if(T==="edit"&&W)O(W.name||""),P(W.coverImageKey),U(W.coverImage),B(W.enableNotification!==!1);else O(""),P(void 0),U(void 0),B(!0)},[Z,T,W]);let g=X.api.teams[":teamId"].projects.$post,{mutate:j}=k({mutationFn:async(Q)=>{let _=await g({param:{teamId:F},json:Q});if(!_.ok)throw Error(V.failed_create_project());return await _.json()},onSuccess:(Q)=>{q.invalidateQueries({queryKey:["teams",F,"projects"]}),$(!1);let _=Q;if(_&&typeof _.id==="string")R({to:"/projects/$projectId",params:{projectId:_.id}})}}),u=X.api.projects[":projectId"].$put,{mutate:y}=k({mutationFn:async(Q)=>{let _=await u({param:{projectId:W.id},json:Q});if(!_.ok)throw Error(V.failed_update_project());return await _.json()},onSuccess:()=>{q.invalidateQueries({queryKey:["teams",F,"projects"]}),$(!1)}}),r=X.api.teams[":teamId"].files.$post,{mutate:D}=k({mutationFn:async({file:Q})=>{let _=await r({param:{teamId:F},form:{file:Q}});if(!_.ok)throw Error(V.failed_upload_file());return await _.json()},onSuccess:(Q)=>{let _=Q;if(_&&typeof _.key==="string")P(_.key);w(!1)},onError:()=>{w(!1)}}),o=(Q)=>{let _=Q.target.files?.[0];if(_){w(!0);let e=URL.createObjectURL(_);U(e),D({file:_})}},t=()=>{S.current?.click()},s=(Q)=>{Q.stopPropagation(),P(void 0),U(void 0)},l=()=>{if(!H.trim())return;if(T==="create")j({name:H.trim(),coverImageKey:I,enableNotification:v});else if(T==="edit"&&W?.id)y({name:H.trim(),coverImageKey:I,enableNotification:v})};return z(Rz,{open:Z,onOpenChange:$,children:J(Kz,{className:"sm:max-w-[550px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 backdrop-blur-md shadow-2xl p-0 gap-0",children:[J(kz,{className:"relative overflow-hidden bg-gradient-to-br from-primary/5 to-transparent p-6 border-b border-border/40",children:[z("div",{className:"absolute top-0 right-0 w-24 h-24 bg-primary/10 rounded-full blur-2xl pointer-events-none"}),z("div",{className:"absolute bottom-0 left-10 w-32 h-12 bg-primary/5 rounded-full blur-xl pointer-events-none"}),z("div",{className:"flex items-center gap-3",children:J("div",{children:[z(Az,{className:"text-xl font-semibold tracking-tight text-foreground",children:T==="create"?V.create_new_project():V.project_settings()}),z(Ez,{className:"text-xs text-muted-foreground/80 mt-1",children:T==="create"?V.configure_new_project_description():V.manage_project_description()})]})})]}),J("div",{className:"space-y-6 p-6 max-h-[75vh] overflow-y-auto",children:[J("div",{className:"space-y-2",children:[z(c,{htmlFor:"name",className:"text-sm font-semibold tracking-tight text-foreground",children:V.project_name()}),J("div",{className:"relative",children:[z(n,{id:"name",value:H,onChange:(Q)=>O(Q.target.value),placeholder:V.project_name_placeholder(),className:"h-11 px-4 rounded-xl border-border/80 focus-visible:ring-ring/25 focus-visible:border-primary transition-all shadow-xs pr-10"}),H.trim()&&z("div",{className:"absolute inset-y-0 right-3 flex items-center",children:z(i,{className:"w-4 h-4 text-primary"})})]}),z("p",{className:"text-[11px] text-muted-foreground",children:V.project_name_hint()})]}),J("div",{className:"space-y-3 border-t border-border/40 pt-5",children:[J("div",{className:"flex items-center justify-between",children:[J(c,{className:"text-sm font-semibold tracking-tight text-foreground flex items-center gap-1.5",children:[z($z,{className:"w-4 h-4 text-primary"}),V.project_cover()]}),h&&J("button",{type:"button",onClick:s,className:"text-xs text-muted-foreground hover:text-destructive hover:bg-destructive/5 px-2.5 py-1 rounded-lg transition-all flex items-center gap-1 font-medium",children:[z(Lz,{className:"w-3.5 h-3.5"}),V.remove_cover()]})]}),J("div",{className:"relative aspect-square w-48 mx-auto rounded-2xl border border-dashed border-border flex items-center justify-center cursor-pointer overflow-hidden group shadow-inner bg-muted/20 transition-all duration-300 hover:border-primary/50 hover:bg-muted/40",onClick:t,children:[z("input",{type:"file",ref:S,className:"hidden",accept:"image/*",onChange:o}),A&&z("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:J("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[z(zz,{className:"w-4 h-4 animate-spin text-primary"}),z("span",{className:"text-xs font-semibold text-foreground",children:V.uploading()})]})}),h?J(N,{children:[z("img",{src:h,alt:V.cover_preview(),className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"}),J("div",{className:"absolute inset-0 bg-black/45 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col items-center justify-center gap-1.5 text-white z-10",children:[z(Gz,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),z("span",{className:"text-xs font-semibold",children:V.upload_image()})]})]}):J("div",{className:"flex flex-col items-center gap-2 text-center p-4",children:[z("div",{className:"p-2.5 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:z(Gz,{className:"w-4 h-4 text-muted-foreground"})}),J("div",{children:[z("p",{className:"text-xs font-medium text-foreground",children:V.upload_cover()}),z("p",{className:"text-[11px] text-muted-foreground mt-0.5 max-w-[140px] mx-auto leading-normal",children:V.upload_cover_hint()})]})]})]})]}),J("div",{className:"space-y-3 border-t border-border/40 pt-5",children:[J(c,{className:"text-sm font-semibold tracking-tight text-foreground flex items-center gap-1.5",children:[z(Wz,{className:"w-4 h-4 text-primary"}),V.project_preferences()]}),J("div",{className:"flex items-start justify-between rounded-xl border border-border/50 bg-muted/10 p-4 transition-all duration-300 hover:bg-muted/20",children:[J("div",{className:"space-y-1 pr-4",children:[J("div",{className:"text-sm font-semibold flex items-center gap-2 text-foreground",children:[z(Tz,{className:"w-4 h-4 text-primary"}),V.activity_notifications()]}),z("p",{className:"text-xs text-muted-foreground leading-normal",children:V.activity_notifications_description()})]}),z(a,{checked:v,onCheckedChange:B,disabled:A,className:"mt-0.5"})]})]})]}),J(qz,{className:"flex items-center justify-end gap-3 px-6 py-4 bg-muted/20 border-t border-border/40",children:[z(E,{type:"button",variant:"ghost",onClick:()=>$(!1),disabled:A,className:"rounded-xl h-10 px-4 hover:bg-muted font-medium text-sm text-muted-foreground hover:text-foreground transition-colors",children:V.cancel()}),z(E,{type:"submit",onClick:l,disabled:!H.trim()||A,className:"rounded-xl h-10 px-5 bg-primary text-primary-foreground hover:bg-primary/90 font-semibold text-sm shadow-lg shadow-primary/10 hover:shadow-primary/20 active:scale-98 transition-all flex items-center gap-2",children:A?J(N,{children:[z(zz,{className:"w-4 h-4 animate-spin"}),V.processing()]}):T==="create"?V.create_project():V.save_changes()})]})]})})}function Nz({sortBy:Z,sortDirection:$,onSortChange:T}){let F=(H)=>{T(H,$)},W=()=>{T(Z,$==="asc"?"desc":"asc")},q=(H)=>{switch(H){case"name":return V.sort_name();case"created_at":return V.sort_created();case"updated_at":return V.sort_updated();default:return H}},R=$==="asc";return J(b,{children:[z(C,{asChild:!0,children:J(E,{variant:"outline",className:"gap-2 bg-muted/50",children:[z("span",{className:"text-muted-foreground",children:V.sorted_by_label()}),z("span",{className:"font-medium text-foreground",children:q(Z)})]})}),J(f,{align:"end",className:"w-56 p-2",children:[z("div",{className:"text-xs font-semibold text-muted-foreground mb-2 px-2",children:V.sort_by()}),J(b,{children:[z(C,{asChild:!0,children:J(E,{variant:"ghost",className:"w-full justify-between font-normal px-2 h-10 bg-muted/50 hover:bg-muted mb-2 border",children:[z("span",{children:q(Z)}),z(Jz,{className:"h-4 w-4 opacity-50"})]})}),z(f,{className:"w-52",children:["name","created_at","updated_at"].map((H)=>J(M,{onClick:()=>F(H),className:"justify-between",children:[q(H),Z===H&&z(i,{className:"h-4 w-4"})]},H))})]}),J(E,{variant:"ghost",className:"w-full justify-between font-normal px-2 h-10 bg-muted/50 hover:bg-muted border",onClick:W,children:[z("span",{className:"text-muted-foreground",children:Z==="name"?R?z(N,{children:V.sort_a_to_z()}):z(N,{children:V.sort_z_to_a()}):R?z(N,{children:V.sort_oldest_to_newest()}):z(N,{children:V.sort_newest_to_oldest()})}),R?z(Uz,{className:"h-4 w-4 opacity-50"}):z(Jz,{className:"h-4 w-4 opacity-50"})]})]})]})}var L=Qz(Xz(),1);function tz(){let{teamId:Z}=sz.useParams(),{canEdit:$,canAdmin:T}=wz(),F=m(),W=x(),[q,R]=L.useState(null),[H,O]=L.useState(!1),[v,B]=L.useState("create"),[I,P]=L.useState(void 0),[h,U]=L.useState(!1),[A,w]=L.useState(void 0),[S,g]=L.useState(""),[j,u]=L.useState(!1),[y,r]=L.useState("name"),[D,o]=L.useState("asc"),t=X.api.teams[":teamId"].projects.$get,{data:s}=Oz({queryKey:["teams",Z,"projects",y,D],queryFn:async()=>{let G=await t({param:{teamId:Z},query:{sortBy:y,sortDirection:D}});if(!G.ok)throw Error("Failed to fetch projects");return await G.json()}}),{data:l}=Vz({queryKey:["teams",Z,"members"],queryFn:async()=>{let G=await X.api.teams[":teamId"].members.$get({param:{teamId:Z},query:{}});if(!G.ok)throw Error("Failed to fetch members");return await G.json()}}),{data:Q}=Vz({queryKey:["teams",Z,"me"],queryFn:async()=>{let G=await X.api.teams[":teamId"].me.$get({param:{teamId:Z}});if(!G.ok)throw Error("Failed to fetch me");return await G.json()}}),_=X.api.teams[":teamId"].invite.$post,e=k({mutationFn:async(G)=>{let Y=await _(G);if(!Y.ok)throw Error("Failed to invite");return await Y.json()}}),d=k({mutationFn:async(G)=>{if(!(await X.api.projects[":projectId"].$delete({param:{projectId:G}})).ok)throw Error("Failed to delete project")},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"projects"]})}}),dz=k({mutationFn:async(G)=>{let Y=await X.api.projects[":projectId"].$put({param:{projectId:G.id},json:{enableNotification:!G.enableNotification}});if(!Y.ok)throw Error("Failed to update project notification settings");return await Y.json()},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"projects"]}),Yz.success(V.project_notification_updated())},onError:(G)=>{Yz.error(G instanceof Error?G.message:V.failed_update_project_notification())}}),Hz=()=>{B("create"),P(void 0),O(!0)},pz=()=>{R("create"),setTimeout(()=>{R(null)},100),setTimeout(()=>{Hz()},200)},cz=(G)=>{B("edit"),P(G),O(!0)},xz=(G)=>{w(G),g(""),U(!0)},mz=async()=>{if(A&&S==="delete")try{await d.mutateAsync(A.id),U(!1)}catch(G){console.error(G)}},iz=(G,Y)=>{if(Y.detail>1)return;R(G),setTimeout(()=>{R(null)},100),setTimeout(()=>{F({to:"/projects/$projectId",params:{projectId:G}})},200)},nz=async(G)=>{return(await e.mutateAsync({param:{teamId:Z},json:{role:G}})).code},az=k({mutationFn:async({userId:G,role:Y})=>{if(!(await X.api.teams[":teamId"].members[":userId"].$patch({param:{teamId:Z,userId:G},json:{role:Y}})).ok)throw Error("Failed to update member role")},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"members"]})}}),jz=k({mutationFn:async(G)=>{if(!(await X.api.teams[":teamId"].members[":userId"].$delete({param:{teamId:Z,userId:G}})).ok)throw Error("Failed to remove member")},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"members"]})}}),rz=(G)=>{if(!G)return"??";return G.split(" ").map((Y)=>Y[0]).slice(0,2).join("").toUpperCase()},oz=(G,Y)=>{r(G),o(Y)},p=Array.isArray(l)?l:[];return J("div",{className:"flex-1 overflow-y-auto p-4",children:[J("div",{className:"flex flex-wrap items-center justify-between mb-4 gap-4",children:[z("h1",{className:"text-2xl font-bold",children:V.projects()}),J("div",{className:"flex flex-wrap items-center gap-4",children:[J("div",{className:"flex items-center -space-x-2 cursor-pointer hover:opacity-90",onClick:()=>u(!0),children:[p.slice(0,3).map((G)=>J(Sz,{className:"border-2 border-background w-8 h-8",children:[G.image&&z(Mz,{src:G.image,alt:G.name,className:"object-cover"}),z(vz,{className:"text-[10px]",children:rz(G.name)})]},G.id)),p.length>3&&J("div",{className:"flex items-center justify-center w-8 h-8 rounded-full border-2 border-background bg-muted text-[10px] font-medium",children:["+",p.length-3]})]}),z(Nz,{sortBy:y,sortDirection:D,onSortChange:oz}),$&&J(E,{className:"bg-orange-600 hover:bg-orange-700 text-white gap-2",onClick:Hz,children:[z(Zz,{className:"w-4 h-4"}),V.create_project()]})]})]}),J("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 gap-4",children:[s.data?.map((G)=>z("div",{className:_z("shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out",q===G.id?"scale-95":"scale-100"),onClick:(Y)=>iz(G.id,Y),children:J("div",{className:"flex flex-col",children:[J("div",{className:"relative w-full h-full aspect-square flex items-center justify-center bg-zinc-400/20",children:[G.coverImage?z("img",{src:G.coverImage,alt:G.name,className:"w-full h-full object-cover rounded"}):J("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 180.95 164.7",preserveAspectRatio:"xMidYMid slice",className:"w-full h-full object-cover rounded",children:[z("polygon",{fill:"#FC9F8E",points:"0 18.5 0 76.0 151.69 164.7 180.95 164.7 180.95 113.6"}),z("polygon",{fill:"#FEBAB8",points:"0 0 74.58 61.5 90.53 51.6 110.33 63.9 180.95 18.9 180.95 0"}),z("polyline",{fill:"#FAA5A5",points:"0 18.5 74.58 61.5 90.53 51.6 110.33 63.9 180.95 18.9 180.95 0 0 0"}),z("polygon",{fill:"#EC5B6C",points:"0 76.0 0 164.7 151.69 164.7"}),z("polygon",{fill:"#E85C71",points:"180.95 18.9 110.33 63.9 117.37 68.0 117.26 73.4 180.95 113.6"}),z("polygon",{fill:"#C8405B",points:"117.26 73.4 117.37 99.0 90.53 114.9 174.35 164.7 180.95 164.7 180.95 113.6"}),z("polygon",{fill:"#FFCCBE",points:"90.53 51.6 63.69 68.1 90.53 83.4"}),z("path",{fill:"#FB9991",d:"M 90.53 51.6 L 90.53 61.3 L 100.87 67.4 L 90.53 73.5 L 90.53 83.4 L 117.37 68.0 C 117.15 67.6 90.53 51.6 90.53 51.6 Z"}),z("path",{fill:"#FFEACD",d:"M 63.69 68.1 C 63.47 68.5 64.02 99.3 64.02 99.3 C 64.02 99.3 64.46 99.6 64.9 99.9 L 90.53 83.4 L 63.69 68.1 Z"}),z("polygon",{fill:"#FFCFB5",points:"64.02 99.3 90.53 114.9 90.53 83.4"}),z("path",{fill:"#F67D73",d:"M 90.53 83.4 L 90.53 114.9 L 117.37 99.0 Z"}),z("path",{fill:"#F26560",d:"M 90.53 83.4 L 117.37 99.0 L 117.37 68.0 Z"}),z("polygon",{fill:"#EB5F5B",points:"80.08 67.5 90.53 73.5 90.53 61.3"}),z("polygon",{fill:"#DB4D50",points:"90.53 61.3 90.53 73.5 100.87 67.4"})]}),z("div",{className:"absolute bottom-0 left-0 w-full h-[65%] bg-linear-to-t from-black/35 to-black/0"}),z("p",{className:"absolute left-1 bottom-2 text-white",children:G.name})]}),J("div",{className:"px-2 h-10 flex justify-between items-center",children:[J("p",{className:"truncate pr-1 text-xs text-muted-foreground",children:[V.updated_ago()," ",hz(G.updatedAt??"")]}),z("div",{onClick:(Y)=>Y.stopPropagation(),children:J(b,{modal:!1,children:[z(C,{asChild:!0,children:z("button",{className:"hover:bg-muted outline-none flex px-1",children:z(Bz,{className:"w-5 h-5 text-muted-foreground"})})}),J(f,{align:"end",children:[$&&z(M,{onClick:(Y)=>{Y.stopPropagation(),cz(G)},children:V.project_settings()}),J(M,{className:"flex items-center justify-between gap-4 cursor-pointer",onSelect:(Y)=>{Y.preventDefault(),dz.mutate(G)},children:[z("span",{children:V.notification()}),z(a,{checked:G.enableNotification??!0,className:"pointer-events-none"})]}),T&&z(M,{className:"text-destructive focus:text-destructive",onClick:()=>xz(G),children:V.delete()})]})]})})]})]})},G.id)),$&&z("div",{className:_z("shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out border-dashed hover:border-orange-600/50 group",q==="create"?"scale-95":"scale-100"),onClick:pz,children:J("div",{className:"flex flex-col",children:[z("div",{className:"relative w-full aspect-square flex items-center justify-center bg-zinc-400/5 group-hover:bg-orange-600/5 transition-colors",children:z(Zz,{className:"w-8 h-8 text-zinc-400 group-hover:text-orange-600 transition-colors"})}),z("div",{className:"px-2 h-10 flex items-center justify-center bg-zinc-400/10 border-t group-hover:bg-orange-600/10 transition-colors",children:z("p",{className:"text-sm text-muted-foreground group-hover:text-orange-600 transition-colors",children:V.create_project()})})]})})]}),z(Fz,{open:H,onOpenChange:O,mode:v,teamId:Z,project:I}),z(yz,{open:h,onOpenChange:U,children:J(Dz,{children:[J(bz,{children:[z(fz,{children:V.are_you_sure()}),J(Iz,{children:[V.delete_project_warning({name:A?.name??""}),J("div",{className:"mt-4 flex flex-col gap-2 text-foreground",children:[z("span",{className:"text-sm font-medium",children:V.type_delete_to_confirm()}),z(n,{value:S,onChange:(G)=>g(G.target.value),placeholder:V.delete_placeholder(),className:"h-9",autoFocus:!0})]})]})]}),J(Cz,{children:[z(uz,{disabled:d.isPending,children:V.cancel()}),z(gz,{onClick:(G)=>{G.preventDefault(),mz()},disabled:S!=="delete"||d.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:d.isPending?V.deleting():V.delete()})]})]})}),z(lz,{open:j,onOpenChange:u,title:V.team_members(),type:"team",members:p,isOwner:Q?.role==="owner",onInvite:nz,onUpdateRole:async(G,Y)=>{await az.mutateAsync({userId:G,role:Y})},onRemoveMember:async(G)=>{await jz.mutateAsync(G)},currentUserId:Q?.id})]})}var sz=Pz("/teams/$teamId/")({component:tz});export{sz as Route};
@@ -1,4 +1,4 @@
1
- import{B as gO,D as Jd,F as F5,G as B5,H as O5,O as Qd,P as bO,Q as $k,R as cl,S as i3,T as P7,U as H3}from"./chunk-4fnak2zn.js";import{ea as Ed}from"./chunk-6h4ay2p8.js";import{Wa as _p}from"./chunk-azfgjqjx.js";import{$a as Hd,_a as Od,ab as Md,bb as Dd,cb as Td,db as Rd,eb as Nd,fb as zd}from"./chunk-sy8rqacm.js";import{Bf as C3,Cf as _3,Df as v_,Ff as kb,Gf as S_,Hf as y_,Jf as k_,Kf as M_,Lf as Cb,Mf as C_,Nf as __,Of as wd,Pf as jd,Qf as dd,Rf as qd,Sf as hO,Tf as cO,Uf as kp,Vf as Cp,ag as _5}from"./chunk-qjjr3fff.js";import{og as uO,pg as wo,qg as hi}from"./chunk-2xnys7v4.js";import{Mg as yd}from"./chunk-cpr05qng.js";import{Og as c8}from"./chunk-dwf5e5g3.js";import{$h as iO,$j as mO,Bj as E2,Ch as bd,Dh as Zd,Fi as l3,Fj as Mi,Hj as Ln,Ij as Ad,Ji as f3,Jj as vd,Ki as ul,Kj as Sd,Lj as Mf,Mh as Ud,Ni as Xd,Nj as Df,Oh as r8,Oi as Vk,Oj as Tf,Pi as hh,Pj as l1,Qh as O3,Qi as ch,Rg as Pa,Sg as mo,Si as Kd,Sj as n3,Tg as x,Ti as Yk,Ug as rt,Vg as k5,Vh as Id,Vi as Jk,Xg as po,Yh as oh,Zg as Hf,Zh as jo,Zi as Ld,Zj as It,_g as oO,_h as aO,_j as Yd,aj as l8,ak as h8,bk as kd,cj as pd,ck as Cd,dk as _d,ei as Gd,ej as Vd,fk as Fd,gi as $_,gk as Bd,ji as Vn,jj as Qk,kj as Zk,mi as C5,mj as qo,nh as xd,uh as Le}from"./chunk-wf4d1anc.js";import{Pk as Ie,Qk as Me,Rk as o4}from"./chunk-976v5s8y.js";var kw=Me((lJ,yw)=>{var qw=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,wM=/\n/g,jM=/^\s*/,dM=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,qM=/^:\s*/,AM=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,vM=/^[;\s]*/,SM=/^\s+|\s+$/g,yM=`
1
+ import{B as gO,D as Jd,F as F5,G as B5,H as O5,O as Qd,P as bO,Q as $k,R as cl,S as i3,T as P7,U as H3}from"./chunk-crt1e1w1.js";import{ea as Ed}from"./chunk-wsyg4rwg.js";import{Wa as _p}from"./chunk-kfhtk3eh.js";import{$a as Hd,_a as Od,ab as Md,bb as Dd,cb as Td,db as Rd,eb as Nd,fb as zd}from"./chunk-0xbf8bcg.js";import{Bf as C3,Cf as _3,Df as v_,Ff as kb,Gf as S_,Hf as y_,Jf as k_,Kf as M_,Lf as Cb,Mf as C_,Nf as __,Of as wd,Pf as jd,Qf as dd,Rf as qd,Sf as hO,Tf as cO,Uf as kp,Vf as Cp,ag as _5}from"./chunk-77r8w95d.js";import{og as uO,pg as wo,qg as hi}from"./chunk-3n1rezd0.js";import{Mg as yd}from"./chunk-fz88kkk1.js";import{Og as c8}from"./chunk-dghtwyq1.js";import{Qg as Ln,Rg as Mf,Tg as Df,Ug as Tf,Vg as l1,Yg as n3,bh as Yd,ch as mO,dh as h8,eh as kd,fh as Cd,gh as _d,ih as Fd,jh as Bd}from"./chunk-gswbc6y9.js";import{$h as bd,Aj as l8,Cj as pd,Ei as Gd,Ej as Vd,Gi as $_,Ji as Vn,Jj as Qk,Kj as Zk,Lh as xd,Mi as C5,Mj as qo,Sh as Le,ai as Zd,bk as E2,dj as l3,gk as Mi,hj as f3,hk as Ad,ij as ul,ik as vd,ji as Ud,jk as Sd,li as r8,lj as Xd,mh as Pa,mj as Vk,mk as It,nh as mo,ni as O3,nj as hh,oh as x,oj as ch,ph as rt,qh as k5,qj as Kd,rj as Yk,si as Id,th as po,tj as Jk,vh as Hf,vi as oh,wh as oO,wi as jo,xi as aO,xj as Ld,yi as iO}from"./chunk-nyhqy6q2.js";import{Vk as Ie,Wk as Me,Xk as o4}from"./chunk-0qkj838r.js";var kw=Me((lJ,yw)=>{var qw=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,wM=/\n/g,jM=/^\s*/,dM=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,qM=/^:\s*/,AM=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,vM=/^[;\s]*/,SM=/^\s+|\s+$/g,yM=`
2
2
  `,Aw="/",vw="*",Cf="",kM="comment",CM="declaration";function _M(t,e){if(typeof t!=="string")throw TypeError("First argument must be a string");if(!t)return[];e=e||{};var a=1,i=1;function s(d){var v=d.match(wM);if(v)a+=v.length;var k=d.lastIndexOf(yM);i=~k?d.length-k:i+d.length}function n(){var d={line:a,column:i};return function(v){return v.position=new l(d),c(),v}}function l(d){this.start=d,this.end={line:a,column:i},this.source=e.source}l.prototype.content=t;function f(d){var v=Error(e.source+":"+a+":"+i+": "+d);if(v.reason=d,v.filename=e.source,v.line=a,v.column=i,v.source=t,e.silent);else throw v}function o(d){var v=d.exec(t);if(!v)return;var k=v[0];return s(k),t=t.slice(k.length),v}function c(){o(jM)}function u(d){var v;d=d||[];while(v=m())if(v!==!1)d.push(v);return d}function m(){var d=n();if(Aw!=t.charAt(0)||vw!=t.charAt(1))return;var v=2;while(Cf!=t.charAt(v)&&(vw!=t.charAt(v)||Aw!=t.charAt(v+1)))++v;if(v+=2,Cf===t.charAt(v-1))return f("End of comment missing");var k=t.slice(2,v-2);return i+=2,s(k),t=t.slice(v),i+=2,d({type:kM,comment:k})}function p(){var d=n(),v=o(dM);if(!v)return;if(m(),!o(qM))return f("property missing ':'");var k=o(AM),y=d({type:CM,property:Sw(v[0].replace(qw,Cf)),value:k?Sw(k[0].replace(qw,Cf)):Cf});return o(vM),y}function w(){var d=[];u(d);var v;while(v=p())if(v!==!1)d.push(v),u(d);return d}return c(),w()}function Sw(t){return t?t.replace(SM,Cf):Cf}yw.exports=_M});var Cw=Me((Dc)=>{var FM=Dc&&Dc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Dc,"__esModule",{value:!0});Dc.default=OM;var BM=FM(kw());function OM(t,e){let a=null;if(!t||typeof t!=="string")return a;let i=(0,BM.default)(t),s=typeof e==="function";return i.forEach((n)=>{if(n.type!=="declaration")return;let{property:l,value:f}=n;if(s)e(l,f,n);else if(f)a=a||{},a[l]=f}),a}});var Ow=Me((Fw)=>{Object.defineProperty(Fw,"__esModule",{value:!0});Fw.camelCase=void 0;var HM=/^--[a-zA-Z0-9_-]+$/,MM=/-([a-z])/g,DM=/^[^-]+$/,TM=/^-(webkit|moz|ms|o|khtml)-/,RM=/^-(ms)-/,NM=function(t){return!t||DM.test(t)||HM.test(t)},zM=function(t,e){return e.toUpperCase()},_w=function(t,e){return"".concat(e,"-")},EM=function(t,e){if(e===void 0)e={};if(NM(t))return t;if(t=t.toLowerCase(),e.reactCompat)t=t.replace(RM,_w);else t=t.replace(TM,_w);return t.replace(MM,zM)};Fw.camelCase=EM});var Mw=Me((j4,Hw)=>{var xM=j4&&j4.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},UM=xM(Cw()),IM=Ow();function w4(t,e){var a={};if(!t||typeof t!=="string")return a;return(0,UM.default)(t,function(i,s){if(i&&s)a[(0,IM.camelCase)(i,e)]=s}),a}w4.default=w4;Hw.exports=w4});var ad=Me((ZP,ed)=>{var v5=Object.prototype.hasOwnProperty,td=Object.prototype.toString,Jj=Object.defineProperty,Qj=Object.getOwnPropertyDescriptor,Zj=function(e){if(typeof Array.isArray==="function")return Array.isArray(e);return td.call(e)==="[object Array]"},$j=function(e){if(!e||td.call(e)!=="[object Object]")return!1;var a=v5.call(e,"constructor"),i=e.constructor&&e.constructor.prototype&&v5.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!a&&!i)return!1;var s;for(s in e);return typeof s>"u"||v5.call(e,s)},Wj=function(e,a){if(Jj&&a.name==="__proto__")Jj(e,a.name,{enumerable:!0,configurable:!0,value:a.newValue,writable:!0});else e[a.name]=a.newValue},Pj=function(e,a){if(a==="__proto__"){if(!v5.call(e,a))return;else if(Qj)return Qj(e,a).value}return e[a]};ed.exports=function t(){var e,a,i,s,n,l,f=arguments[0],o=1,c=arguments.length,u=!1;if(typeof f==="boolean")u=f,f=arguments[1]||{},o=2;if(f==null||typeof f!=="object"&&typeof f!=="function")f={};for(;o<c;++o)if(e=arguments[o],e!=null){for(a in e)if(i=Pj(f,a),s=Pj(e,a),f!==s){if(u&&s&&($j(s)||(n=Zj(s)))){if(n)n=!1,l=i&&Zj(i)?i:[];else l=i&&$j(i)?i:{};Wj(f,{name:a,newValue:t(u,l,s)})}else if(typeof s<"u")Wj(f,{name:a,newValue:s})}}return f}});var h0=Me((Met,Wd)=>{var $c;if(typeof window<"u")$c=window;else if(typeof global<"u")$c=global;else if(typeof self<"u")$c=self;else $c={};Wd.exports=$c});var u8=Me((Det,tq)=>{var Pd=Array.prototype.slice;tq.exports=AR;function AR(t,e){if(!("length"in t))t=[t];t=Pd.call(t);while(t.length){var a=t.shift(),i=e(a);if(i)return i;if(a.childNodes&&a.childNodes.length)t=Pd.call(a.childNodes).concat(t)}}});var aq=Me((Tet,eq)=>{eq.exports=Ao;function Ao(t,e){if(!(this instanceof Ao))return new Ao(t,e);this.data=t,this.nodeValue=t,this.length=t.length,this.ownerDocument=e||null}Ao.prototype.nodeType=8;Ao.prototype.nodeName="#comment";Ao.prototype.toString=function(){return"[object Comment]"}});var sq=Me((Ret,iq)=>{iq.exports=ml;function ml(t,e){if(!(this instanceof ml))return new ml(t);this.data=t||"",this.length=this.data.length,this.ownerDocument=e||null}ml.prototype.type="DOMTextNode";ml.prototype.nodeType=3;ml.prototype.nodeName="#text";ml.prototype.toString=function(){return this.data};ml.prototype.replaceData=function(e,a,i){var s=this.data,n=s.substring(0,e),l=s.substring(e+a,s.length);this.data=n+i+l,this.length=this.data.length}});var m8=Me((Net,nq)=>{nq.exports=vR;function vR(t){var e=this,a=t.type;if(!t.target)t.target=e;if(!e.listeners)e.listeners={};var i=e.listeners[a];if(i)return i.forEach(function(s){if(t.currentTarget=e,typeof s==="function")s(t);else s.handleEvent(t)});if(e.parentNode)e.parentNode.dispatchEvent(t)}});var g8=Me((zet,lq)=>{lq.exports=SR;function SR(t,e){var a=this;if(!a.listeners)a.listeners={};if(!a.listeners[t])a.listeners[t]=[];if(a.listeners[t].indexOf(e)===-1)a.listeners[t].push(e)}});var b8=Me((Eet,fq)=>{fq.exports=yR;function yR(t,e){var a=this;if(!a.listeners)return;if(!a.listeners[t])return;var i=a.listeners[t],s=i.indexOf(e);if(s!==-1)i.splice(s,1)}});var cq=Me((xet,hq)=>{hq.exports=rq;var kR=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function rq(t){switch(t.nodeType){case 3:return p8(t.data);case 8:return"<!--"+t.data+"-->";default:return CR(t)}}function CR(t){var e=[],a=t.tagName;if(t.namespaceURI==="http://www.w3.org/1999/xhtml")a=a.toLowerCase();if(e.push("<"+a+OR(t)+BR(t)),kR.indexOf(a)>-1)e.push(" />");else{if(e.push(">"),t.childNodes.length)e.push.apply(e,t.childNodes.map(rq));else if(t.textContent||t.innerText)e.push(p8(t.textContent||t.innerText));else if(t.innerHTML)e.push(t.innerHTML);e.push("</"+a+">")}return e.join("")}function _R(t,e){var a=typeof t[e];if(e==="style"&&Object.keys(t.style).length>0)return!0;return t.hasOwnProperty(e)&&(a==="string"||a==="boolean"||a==="number")&&e!=="nodeName"&&e!=="className"&&e!=="tagName"&&e!=="textContent"&&e!=="innerText"&&e!=="namespaceURI"&&e!=="innerHTML"}function FR(t){if(typeof t==="string")return t;var e="";return Object.keys(t).forEach(function(a){var i=t[a];a=a.replace(/[A-Z]/g,function(s){return"-"+s.toLowerCase()}),e+=a+":"+i+";"}),e}function BR(t){var e=t.dataset,a=[];for(var i in e)a.push({name:"data-"+i,value:e[i]});return a.length?oq(a):""}function oq(t){var e=[];return t.forEach(function(a){var{name:i,value:s}=a;if(i==="style")s=FR(s);e.push(i+'="'+HR(s)+'"')}),e.length?" "+e.join(" "):""}function OR(t){var e=[];for(var a in t)if(_R(t,a))e.push({name:a,value:t[a]});for(var i in t._attributes)for(var s in t._attributes[i]){var n=t._attributes[i][s],l=(n.prefix?n.prefix+":":"")+s;e.push({name:l,value:n.value})}if(t.className)e.push({name:"class",value:t.className});return e.length?oq(e):""}function p8(t){var e="";if(typeof t==="string")e=t;else if(t)e=t.toString();return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function HR(t){return p8(t).replace(/"/g,"&quot;")}});var j8=Me((Uet,mq)=>{var w8=u8(),MR=m8(),DR=g8(),TR=b8(),RR=cq(),uq="http://www.w3.org/1999/xhtml";mq.exports=Ca;function Ca(t,e,a){if(!(this instanceof Ca))return new Ca(t);var i=a===void 0?uq:a||null;if(this.tagName=i===uq?String(t).toUpperCase():t,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=e||null,this.namespaceURI=i,this._attributes={},this.tagName==="INPUT")this.type="text"}Ca.prototype.type="DOMElement";Ca.prototype.nodeType=1;Ca.prototype.appendChild=function(e){if(e.parentNode)e.parentNode.removeChild(e);return this.childNodes.push(e),e.parentNode=this,e};Ca.prototype.replaceChild=function(e,a){if(e.parentNode)e.parentNode.removeChild(e);var i=this.childNodes.indexOf(a);return a.parentNode=null,this.childNodes[i]=e,e.parentNode=this,a};Ca.prototype.removeChild=function(e){var a=this.childNodes.indexOf(e);return this.childNodes.splice(a,1),e.parentNode=null,e};Ca.prototype.insertBefore=function(e,a){if(e.parentNode)e.parentNode.removeChild(e);var i=a===null||a===void 0?-1:this.childNodes.indexOf(a);if(i>-1)this.childNodes.splice(i,0,e);else this.childNodes.push(e);return e.parentNode=this,e};Ca.prototype.setAttributeNS=function(e,a,i){var s=null,n=a,l=a.indexOf(":");if(l>-1)s=a.substr(0,l),n=a.substr(l+1);if(this.tagName==="INPUT"&&a==="type")this.type=i;else{var f=this._attributes[e]||(this._attributes[e]={});f[n]={value:i,prefix:s}}};Ca.prototype.getAttributeNS=function(e,a){var i=this._attributes[e],s=i&&i[a]&&i[a].value;if(this.tagName==="INPUT"&&a==="type")return this.type;if(typeof s!=="string")return null;return s};Ca.prototype.removeAttributeNS=function(e,a){if(!Object.prototype.hasOwnProperty.call(this._attributes,e))return;var i=this._attributes[e];if(i&&Object.prototype.hasOwnProperty.call(i,a))delete i[a]};Ca.prototype.hasAttributeNS=function(e,a){var i=this._attributes[e];return!!i&&a in i};Ca.prototype.setAttribute=function(e,a){return this.setAttributeNS(null,e,a)};Ca.prototype.getAttribute=function(e){return this.getAttributeNS(null,e)};Ca.prototype.removeAttribute=function(e){return this.removeAttributeNS(null,e)};Ca.prototype.hasAttribute=function(e){return this.hasAttributeNS(null,e)};Ca.prototype.removeEventListener=TR;Ca.prototype.addEventListener=DR;Ca.prototype.dispatchEvent=MR;Ca.prototype.focus=function(){return};Ca.prototype.toString=function(){return RR(this)};Ca.prototype.getElementsByClassName=function(e){var a=e.split(" "),i=[];return w8(this,function(s){if(s.nodeType===1){var n=s.className||"",l=n.split(" ");if(a.every(function(f){return l.indexOf(f)!==-1}))i.push(s)}}),i};Ca.prototype.getElementsByTagName=function(e){e=e.toLowerCase();var a=[];return w8(this.childNodes,function(i){if(i.nodeType===1&&(e==="*"||i.tagName.toLowerCase()===e))a.push(i)}),a};Ca.prototype.contains=function(e){return w8(this,function(a){return e===a})||!1}});var bq=Me((Iet,gq)=>{var d8=j8();gq.exports=c0;function c0(t){if(!(this instanceof c0))return new c0;this.childNodes=[],this.parentNode=null,this.ownerDocument=t||null}c0.prototype.type="DocumentFragment";c0.prototype.nodeType=11;c0.prototype.nodeName="#document-fragment";c0.prototype.appendChild=d8.prototype.appendChild;c0.prototype.replaceChild=d8.prototype.replaceChild;c0.prototype.removeChild=d8.prototype.removeChild;c0.prototype.toString=function(){return this.childNodes.map(function(e){return String(e)}).join("")}});var wq=Me((Get,pq)=>{pq.exports=q8;function q8(t){}q8.prototype.initEvent=function(e,a,i){this.type=e,this.bubbles=a,this.cancelable=i};q8.prototype.preventDefault=function(){}});var dq=Me((Xet,jq)=>{var NR=u8(),zR=aq(),ER=sq(),Wc=j8(),xR=bq(),UR=wq(),IR=m8(),GR=g8(),XR=b8();jq.exports=H5;function H5(){if(!(this instanceof H5))return new H5;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var Ws=H5.prototype;Ws.createTextNode=function(e){return new ER(e,this)};Ws.createElementNS=function(e,a){var i=e===null?null:String(e);return new Wc(a,this,i)};Ws.createElement=function(e){return new Wc(e,this)};Ws.createDocumentFragment=function(){return new xR(this)};Ws.createEvent=function(e){return new UR(e)};Ws.createComment=function(e){return new zR(e,this)};Ws.getElementById=function(e){e=String(e);var a=NR(this.childNodes,function(i){if(String(i.id)===e)return i});return a||null};Ws.getElementsByClassName=Wc.prototype.getElementsByClassName;Ws.getElementsByTagName=Wc.prototype.getElementsByTagName;Ws.contains=Wc.prototype.contains;Ws.removeEventListener=XR;Ws.addEventListener=GR;Ws.dispatchEvent=IR});var Aq=Me((Ket,qq)=>{var KR=dq();qq.exports=new KR});var A8=Me((Let,Sq)=>{var vq=typeof global<"u"?global:typeof window<"u"?window:{},LR=Aq(),Pc;if(typeof document<"u")Pc=document;else if(Pc=vq["__GLOBAL_DOCUMENT_CACHE@4"],!Pc)Pc=vq["__GLOBAL_DOCUMENT_CACHE@4"]=LR;Sq.exports=Pc});var yq=Me((Vet,f1)=>{function v8(){return f1.exports=v8=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var i in a)({}).hasOwnProperty.call(a,i)&&(t[i]=a[i])}return t},f1.exports.__esModule=!0,f1.exports.default=f1.exports,v8.apply(null,arguments)}f1.exports=v8,f1.exports.__esModule=!0,f1.exports.default=f1.exports});var Cq=Me((Yet,kq)=>{kq.exports=YR;var VR=Object.prototype.toString;function YR(t){if(!t)return!1;var e=VR.call(t);return e==="[object Function]"||typeof t==="function"&&e!=="[object RegExp]"||typeof window<"u"&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)}});var Bq=Me((Jet,Fq)=>{function JR(t,e){var a=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(a)return(a=a.call(t)).next.bind(a);if(Array.isArray(t)||(a=QR(t))||e&&t&&typeof t.length==="number"){if(a)t=a;var i=0;return function(){if(i>=t.length)return{done:!0};return{done:!1,value:t[i++]}}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function QR(t,e){if(!t)return;if(typeof t==="string")return _q(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);if(a==="Object"&&t.constructor)a=t.constructor.name;if(a==="Map"||a==="Set")return Array.from(t);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _q(t,e)}function _q(t,e){if(e==null||e>t.length)e=t.length;for(var a=0,i=Array(e);a<e;a++)i[a]=t[a];return i}var ZR=function(){function t(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1}var e=t.prototype;return e.getIsEnabled=function(){return this.enabled_},e.enable=function(){this.enabled_=!0},e.disable=function(){this.enabled_=!1},e.reset=function(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1},e.addInterceptor=function(i,s){if(!this.typeToInterceptorsMap_.has(i))this.typeToInterceptorsMap_.set(i,new Set);var n=this.typeToInterceptorsMap_.get(i);if(n.has(s))return!1;return n.add(s),!0},e.removeInterceptor=function(i,s){var n=this.typeToInterceptorsMap_.get(i);if(n&&n.has(s))return n.delete(s),!0;return!1},e.clearInterceptorsByType=function(i){var s=this.typeToInterceptorsMap_.get(i);if(!s)return!1;return this.typeToInterceptorsMap_.delete(i),this.typeToInterceptorsMap_.set(i,new Set),!0},e.clear=function(){if(!this.typeToInterceptorsMap_.size)return!1;return this.typeToInterceptorsMap_=new Map,!0},e.getForType=function(i){return this.typeToInterceptorsMap_.get(i)||new Set},e.execute=function(i,s){var n=this.getForType(i);for(var l=JR(n),f;!(f=l()).done;){var o=f.value;try{s=o(s)}catch(c){}}return s},t}();Fq.exports=ZR});var Hq=Me((Qet,Oq)=>{var $R=function(){function t(){this.maxAttempts_=1,this.delayFactor_=0.1,this.fuzzFactor_=0.1,this.initialDelay_=1000,this.enabled_=!1}var e=t.prototype;return e.getIsEnabled=function(){return this.enabled_},e.enable=function(){this.enabled_=!0},e.disable=function(){this.enabled_=!1},e.reset=function(){this.maxAttempts_=1,this.delayFactor_=0.1,this.fuzzFactor_=0.1,this.initialDelay_=1000,this.enabled_=!1},e.getMaxAttempts=function(){return this.maxAttempts_},e.setMaxAttempts=function(i){this.maxAttempts_=i},e.getDelayFactor=function(){return this.delayFactor_},e.setDelayFactor=function(i){this.delayFactor_=i},e.getFuzzFactor=function(){return this.fuzzFactor_},e.setFuzzFactor=function(i){this.fuzzFactor_=i},e.getInitialDelay=function(){return this.initialDelay_},e.setInitialDelay=function(i){this.initialDelay_=i},e.createRetry=function(i){var s=i===void 0?{}:i,n=s.maxAttempts,l=s.delayFactor,f=s.fuzzFactor,o=s.initialDelay;return new WR({maxAttempts:n||this.maxAttempts_,delayFactor:l||this.delayFactor_,fuzzFactor:f||this.fuzzFactor_,initialDelay:o||this.initialDelay_})},t}(),WR=function(){function t(a){this.maxAttempts_=a.maxAttempts,this.delayFactor_=a.delayFactor,this.fuzzFactor_=a.fuzzFactor,this.currentDelay_=a.initialDelay,this.currentAttempt_=1}var e=t.prototype;return e.moveToNextAttempt=function(){this.currentAttempt_++;var i=this.currentDelay_*this.delayFactor_;this.currentDelay_=this.currentDelay_+i},e.shouldRetry=function(){return this.currentAttempt_<this.maxAttempts_},e.getCurrentDelay=function(){return this.currentDelay_},e.getCurrentMinPossibleDelay=function(){return(1-this.fuzzFactor_)*this.currentDelay_},e.getCurrentMaxPossibleDelay=function(){return(1+this.fuzzFactor_)*this.currentDelay_},e.getCurrentFuzzedDelay=function(){var i=this.getCurrentMinPossibleDelay(),s=this.getCurrentMaxPossibleDelay();return i+Math.random()*(s-i)},t}();Oq.exports=$R});var Dq=Me((Zet,Mq)=>{var PR=h0(),tN=function(e,a){if(a===void 0)a=!1;return function(i,s,n){if(i){e(i);return}if(s.statusCode>=400&&s.statusCode<=599){var l=n;if(a)if(PR.TextDecoder){var f=eN(s.headers&&s.headers["content-type"]);try{l=new TextDecoder(f).decode(n)}catch(o){}}else l=String.fromCharCode.apply(null,new Uint8Array(n));e({cause:l});return}e(null,n)}};function eN(t){if(t===void 0)t="";return t.toLowerCase().split(";").reduce(function(e,a){var i=a.split("="),s=i[0],n=i[1];if(s.trim()==="charset")return n.trim();return e},"utf-8")}Mq.exports=tN});var zq=Me(($et,y8)=>{var Tq=h0(),aN=yq(),iN=Cq(),Rq=Bq(),sN=Hq();ti.httpHandler=Dq();ti.requestInterceptorsStorage=new Rq;ti.responseInterceptorsStorage=new Rq;ti.retryManager=new sN;var nN=function(e){var a={};if(!e)return a;return e.trim().split(`
4
4
  `).forEach(function(i){var s=i.indexOf(":"),n=i.slice(0,s).trim().toLowerCase(),l=i.slice(s+1).trim();if(typeof a[n]>"u")a[n]=l;else if(Array.isArray(a[n]))a[n].push(l);else a[n]=[a[n],l]}),a};y8.exports=ti;y8.exports.default=ti;ti.XMLHttpRequest=Tq.XMLHttpRequest||oN;ti.XDomainRequest="withCredentials"in new ti.XMLHttpRequest?ti.XMLHttpRequest:Tq.XDomainRequest;lN(["get","put","post","patch","head","delete"],function(t){ti[t==="delete"?"del":t]=function(e,a,i){return a=Nq(e,a,i),a.method=t.toUpperCase(),S8(a)}});function lN(t,e){for(var a=0;a<t.length;a++)e(t[a])}function fN(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}function Nq(t,e,a){var i=t;if(iN(e)){if(a=e,typeof t==="string")i={uri:t}}else i=aN({},e,{uri:t});return i.callback=a,i}function ti(t,e,a){return e=Nq(t,e,a),S8(e)}function S8(t){if(typeof t.callback>"u")throw Error("callback argument missing");if(t.requestType&&ti.requestInterceptorsStorage.getIsEnabled()){var e={uri:t.uri||t.url,headers:t.headers||{},body:t.body,metadata:t.metadata||{},retry:t.retry,timeout:t.timeout},a=ti.requestInterceptorsStorage.execute(t.requestType,e);t.uri=a.uri,t.headers=a.headers,t.body=a.body,t.metadata=a.metadata,t.retry=a.retry,t.timeout=a.timeout}var i=!1,s=function(D,T,z){if(!i)i=!0,t.callback(D,T,z)};function n(){if(c.readyState===4&&!ti.responseInterceptorsStorage.getIsEnabled())setTimeout(o,0)}function l(){var M=void 0;if(c.response)M=c.response;else M=c.responseText||rN(c);if(y)try{M=JSON.parse(M)}catch(D){}return M}function f(M){if(clearTimeout(B),clearTimeout(t.retryTimeout),!(M instanceof Error))M=Error(""+(M||"Unknown XMLHttpRequest Error"));if(M.statusCode=0,!m&&ti.retryManager.getIsEnabled()&&t.retry&&t.retry.shouldRetry()){t.retryTimeout=setTimeout(function(){t.retry.moveToNextAttempt(),t.xhr=c,S8(t)},t.retry.getCurrentFuzzedDelay());return}if(t.requestType&&ti.responseInterceptorsStorage.getIsEnabled()){var D={headers:H.headers||{},body:H.body,responseUrl:c.responseURL,responseType:c.responseType},T=ti.responseInterceptorsStorage.execute(t.requestType,D);H.body=T.body,H.headers=T.headers}return s(M,H)}function o(){if(m)return;var M;if(clearTimeout(B),clearTimeout(t.retryTimeout),t.useXDR&&c.status===void 0)M=200;else M=c.status===1223?204:c.status;var D=H,T=null;if(M!==0){if(D={body:l(),statusCode:M,method:w,headers:{},url:p,rawRequest:c},c.getAllResponseHeaders)D.headers=nN(c.getAllResponseHeaders())}else T=Error("Internal XMLHttpRequest Error");if(t.requestType&&ti.responseInterceptorsStorage.getIsEnabled()){var z={headers:D.headers||{},body:D.body,responseUrl:c.responseURL,responseType:c.responseType},E=ti.responseInterceptorsStorage.execute(t.requestType,z);D.body=E.body,D.headers=E.headers}return s(T,D,D.body)}var c=t.xhr||null;if(!c)if(t.cors||t.useXDR)c=new ti.XDomainRequest;else c=new ti.XMLHttpRequest;var u,m,p=c.url=t.uri||t.url,w=c.method=t.method||"GET",d=t.body||t.data,v=c.headers=t.headers||{},k=!!t.sync,y=!1,B,H={body:void 0,headers:{},statusCode:0,method:w,url:p,rawRequest:c};if("json"in t&&t.json!==!1){if(y=!0,v.accept||v.Accept||(v.Accept="application/json"),w!=="GET"&&w!=="HEAD")v["content-type"]||v["Content-Type"]||(v["Content-Type"]="application/json"),d=JSON.stringify(t.json===!0?d:t.json)}if(c.onreadystatechange=n,c.onload=o,c.onerror=f,c.onprogress=function(){},c.onabort=function(){m=!0,clearTimeout(t.retryTimeout)},c.ontimeout=f,c.open(w,p,!k,t.username,t.password),!k)c.withCredentials=!!t.withCredentials;if(!k&&t.timeout>0)B=setTimeout(function(){if(m)return;m=!0,c.abort("timeout");var M=Error("XMLHttpRequest timeout");M.code="ETIMEDOUT",f(M)},t.timeout);if(c.setRequestHeader){for(u in v)if(v.hasOwnProperty(u))c.setRequestHeader(u,v[u])}else if(t.headers&&!fN(t.headers))throw Error("Headers cannot be set on an XDomainRequest object");if("responseType"in t)c.responseType=t.responseType;if("beforeSend"in t&&typeof t.beforeSend==="function")t.beforeSend(c);return c.send(d||null),c}function rN(t){try{if(t.responseType==="document")return t.responseXML;var e=t.responseXML&&t.responseXML.documentElement.nodeName==="parsererror";if(t.responseType===""&&!e)return t.responseXML}catch(a){}return null}function oN(){}});var Kq=Me((Wet,Xq)=>{var Eq=A8(),C8=Object.create||function(){function t(){}return function(e){if(arguments.length!==1)throw Error("Object.create shim only accepts one parameter.");return t.prototype=e,new t}}();function Ps(t,e){this.name="ParsingError",this.code=t.code,this.message=e||t.message}Ps.prototype=C8(Error.prototype);Ps.prototype.constructor=Ps;Ps.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function _8(t){function e(i,s,n,l){return(i|0)*3600+(s|0)*60+(n|0)+(l|0)/1000}var a=t.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);if(!a)return null;if(a[3])return e(a[1],a[2],a[3].replace(":",""),a[4]);else if(a[1]>59)return e(a[1],a[2],0,a[4]);else return e(0,a[1],a[2],a[4])}function e2(){this.values=C8(null)}e2.prototype={set:function(t,e){if(!this.get(t)&&e!=="")this.values[t]=e},get:function(t,e,a){if(a)return this.has(t)?this.values[t]:e[a];return this.has(t)?this.values[t]:e},has:function(t){return t in this.values},alt:function(t,e,a){for(var i=0;i<a.length;++i)if(e===a[i]){this.set(t,e);break}},integer:function(t,e){if(/^-?\d+$/.test(e))this.set(t,parseInt(e,10))},percent:function(t,e){var a;if(a=e.match(/^([\d]{1,3})(\.[\d]*)?%$/)){if(e=parseFloat(e),e>=0&&e<=100)return this.set(t,e),!0}return!1}};function t2(t,e,a,i){var s=i?t.split(i):[t];for(var n in s){if(typeof s[n]!=="string")continue;var l=s[n].split(a);if(l.length!==2)continue;var f=l[0].trim(),o=l[1].trim();e(f,o)}}function hN(t,e,a){var i=t;function s(){var f=_8(t);if(f===null)throw new Ps(Ps.Errors.BadTimeStamp,"Malformed timestamp: "+i);return t=t.replace(/^[^\sa-zA-Z-]+/,""),f}function n(f,o){var c=new e2;t2(f,function(u,m){switch(u){case"region":for(var p=a.length-1;p>=0;p--)if(a[p].id===m){c.set(u,a[p].region);break}break;case"vertical":c.alt(u,m,["rl","lr"]);break;case"line":var w=m.split(","),d=w[0];if(c.integer(u,d),c.percent(u,d)&&c.set("snapToLines",!1),c.alt(u,d,["auto"]),w.length===2)c.alt("lineAlign",w[1],["start","center","end"]);break;case"position":if(w=m.split(","),c.percent(u,w[0]),w.length===2)c.alt("positionAlign",w[1],["start","center","end"]);break;case"size":c.percent(u,m);break;case"align":c.alt(u,m,["start","center","end","left","right"]);break}},/:/,/\s/),o.region=c.get("region",null),o.vertical=c.get("vertical","");try{o.line=c.get("line","auto")}catch(u){}o.lineAlign=c.get("lineAlign","start"),o.snapToLines=c.get("snapToLines",!0),o.size=c.get("size",100);try{o.align=c.get("align","center")}catch(u){o.align=c.get("align","middle")}try{o.position=c.get("position","auto")}catch(u){o.position=c.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},o.align)}o.positionAlign=c.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},o.align)}function l(){t=t.replace(/^\s+/,"")}if(l(),e.startTime=s(),l(),t.substr(0,3)!=="-->")throw new Ps(Ps.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+i);t=t.substr(3),l(),e.endTime=s(),l(),n(t,e)}var k8=Eq.createElement&&Eq.createElement("textarea"),cN={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},xq={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},uN={v:"title",lang:"lang"},Uq={rt:"ruby"};function Gq(t,e){function a(){if(!e)return null;function d(k){return e=e.substr(k.length),k}var v=e.match(/^([^<]*)(<[^>]*>?)?/);return d(v[1]?v[1]:v[2])}function i(d){return k8.innerHTML=d,d=k8.textContent,k8.textContent="",d}function s(d,v){return!Uq[v.localName]||Uq[v.localName]===d.localName}function n(d,v){var k=cN[d];if(!k)return null;var y=t.document.createElement(k),B=uN[d];if(B&&v)y[B]=v.trim();return y}var l=t.document.createElement("div"),f=l,o,c=[];while((o=a())!==null){if(o[0]==="<"){if(o[1]==="/"){if(c.length&&c[c.length-1]===o.substr(2).replace(">",""))c.pop(),f=f.parentNode;continue}var u=_8(o.substr(1,o.length-2)),m;if(u){m=t.document.createProcessingInstruction("timestamp",u),f.appendChild(m);continue}var p=o.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!p)continue;if(m=n(p[1],p[3]),!m)continue;if(!s(f,m))continue;if(p[2]){var w=p[2].split(".");w.forEach(function(d){var v=/^bg_/.test(d),k=v?d.slice(3):d;if(xq.hasOwnProperty(k)){var y=v?"background-color":"color",B=xq[k];m.style[y]=B}}),m.className=w.join(" ")}c.push(p[1]),f.appendChild(m),f=m;continue}f.appendChild(t.document.createTextNode(i(o)))}return l}var Iq=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function mN(t){for(var e=0;e<Iq.length;e++){var a=Iq[e];if(t>=a[0]&&t<=a[1])return!0}return!1}function gN(t){var e=[],a="",i;if(!t||!t.childNodes)return"ltr";function s(f,o){for(var c=o.childNodes.length-1;c>=0;c--)f.push(o.childNodes[c])}function n(f){if(!f||!f.length)return null;var o=f.pop(),c=o.textContent||o.innerText;if(c){var u=c.match(/^.*(\n|\r)/);if(u)return f.length=0,u[0];return c}if(o.tagName==="ruby")return n(f);if(o.childNodes)return s(f,o),n(f)}s(e,t);while(a=n(e))for(var l=0;l<a.length;l++)if(i=a.charCodeAt(l),mN(i))return"rtl";return"ltr"}function bN(t){if(typeof t.line==="number"&&(t.snapToLines||t.line>=0&&t.line<=100))return t.line;if(!t.track||!t.track.textTrackList||!t.track.textTrackList.mediaElement)return-1;var e=t.track,a=e.textTrackList,i=0;for(var s=0;s<a.length&&a[s]!==e;s++)if(a[s].mode==="showing")i++;return++i*-1}function D5(){}D5.prototype.applyStyles=function(t,e){e=e||this.div;for(var a in t)if(t.hasOwnProperty(a))e.style[a]=t[a]};D5.prototype.formatStyle=function(t,e){return t===0?0:t+e};function M5(t,e,a){D5.call(this),this.cue=e,this.cueDiv=Gq(t,e.text);var i={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(i,this.cueDiv),this.div=t.document.createElement("div"),i={direction:gN(this.cueDiv),writingMode:e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:e.align==="middle"?"center":e.align,font:a.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(i),this.div.appendChild(this.cueDiv);var s=0;switch(e.positionAlign){case"start":case"line-left":s=e.position;break;case"center":s=e.position-e.size/2;break;case"end":case"line-right":s=e.position-e.size;break}if(e.vertical==="")this.applyStyles({left:this.formatStyle(s,"%"),width:this.formatStyle(e.size,"%")});else this.applyStyles({top:this.formatStyle(s,"%"),height:this.formatStyle(e.size,"%")});this.move=function(n){this.applyStyles({top:this.formatStyle(n.top,"px"),bottom:this.formatStyle(n.bottom,"px"),left:this.formatStyle(n.left,"px"),right:this.formatStyle(n.right,"px"),height:this.formatStyle(n.height,"px"),width:this.formatStyle(n.width,"px")})}}M5.prototype=C8(D5.prototype);M5.prototype.constructor=M5;function hs(t){var e,a,i,s;if(t.div){a=t.div.offsetHeight,i=t.div.offsetWidth,s=t.div.offsetTop;var n=(n=t.div.childNodes)&&(n=n[0])&&n.getClientRects&&n.getClientRects();t=t.div.getBoundingClientRect(),e=n?Math.max(n[0]&&n[0].height||0,t.height/n.length):0}this.left=t.left,this.right=t.right,this.top=t.top||s,this.height=t.height||a,this.bottom=t.bottom||s+(t.height||a),this.width=t.width||i,this.lineHeight=e!==void 0?e:t.lineHeight}hs.prototype.move=function(t,e){switch(e=e!==void 0?e:this.lineHeight,t){case"+x":this.left+=e,this.right+=e;break;case"-x":this.left-=e,this.right-=e;break;case"+y":this.top+=e,this.bottom+=e;break;case"-y":this.top-=e,this.bottom-=e;break}};hs.prototype.overlaps=function(t){return this.left<t.right&&this.right>t.left&&this.top<t.bottom&&this.bottom>t.top};hs.prototype.overlapsAny=function(t){for(var e=0;e<t.length;e++)if(this.overlaps(t[e]))return!0;return!1};hs.prototype.within=function(t){return this.top>=t.top&&this.bottom<=t.bottom&&this.left>=t.left&&this.right<=t.right};hs.prototype.overlapsOppositeAxis=function(t,e){switch(e){case"+x":return this.left<t.left;case"-x":return this.right>t.right;case"+y":return this.top<t.top;case"-y":return this.bottom>t.bottom}};hs.prototype.intersectPercentage=function(t){var e=Math.max(0,Math.min(this.right,t.right)-Math.max(this.left,t.left)),a=Math.max(0,Math.min(this.bottom,t.bottom)-Math.max(this.top,t.top)),i=e*a;return i/(this.height*this.width)};hs.prototype.toCSSCompatValues=function(t){return{top:this.top-t.top,bottom:t.bottom-this.bottom,left:this.left-t.left,right:t.right-this.right,height:this.height,width:this.width}};hs.getSimpleBoxPosition=function(t){var e=t.div?t.div.offsetHeight:t.tagName?t.offsetHeight:0,a=t.div?t.div.offsetWidth:t.tagName?t.offsetWidth:0,i=t.div?t.div.offsetTop:t.tagName?t.offsetTop:0;t=t.div?t.div.getBoundingClientRect():t.tagName?t.getBoundingClientRect():t;var s={left:t.left,right:t.right,top:t.top||i,height:t.height||e,bottom:t.bottom||i+(t.height||e),width:t.width||a};return s};function pN(t,e,a,i){function s(k,y){var B,H=new hs(k),M=1;for(var D=0;D<y.length;D++){while(k.overlapsOppositeAxis(a,y[D])||k.within(a)&&k.overlapsAny(i))k.move(y[D]);if(k.within(a))return k;var T=k.intersectPercentage(a);if(M>T)B=new hs(k),M=T;k=new hs(H)}return B||H}var n=new hs(e),l=e.cue,f=bN(l),o=[];if(l.snapToLines){var c;switch(l.vertical){case"":o=["+y","-y"],c="height";break;case"rl":o=["+x","-x"],c="width";break;case"lr":o=["-x","+x"],c="width";break}var u=n.lineHeight,m=u*Math.round(f),p=a[c]+u,w=o[0];if(Math.abs(m)>p)m=m<0?-1:1,m*=Math.ceil(p/u)*u;if(f<0)m+=l.vertical===""?a.height:a.width,o=o.reverse();n.move(w,m)}else{var d=n.lineHeight/a.height*100;switch(l.lineAlign){case"center":f-=d/2;break;case"end":f-=d;break}switch(l.vertical){case"":e.applyStyles({top:e.formatStyle(f,"%")});break;case"rl":e.applyStyles({left:e.formatStyle(f,"%")});break;case"lr":e.applyStyles({right:e.formatStyle(f,"%")});break}o=["+y","-x","+x","-y"],n=new hs(e)}var v=s(n,o);e.move(v.toCSSCompatValues(a))}function vo(){}vo.StringDecoder=function(){return{decode:function(t){if(!t)return"";if(typeof t!=="string")throw Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}};vo.convertCueToDOMTree=function(t,e){if(!t||!e)return null;return Gq(t,e)};var wN=0.05,jN="sans-serif",dN="1.5%";vo.processCues=function(t,e,a){if(!t||!e||!a)return null;while(a.firstChild)a.removeChild(a.firstChild);var i=t.document.createElement("div");i.style.position="absolute",i.style.left="0",i.style.right="0",i.style.top="0",i.style.bottom="0",i.style.margin=dN,a.appendChild(i);function s(u){for(var m=0;m<u.length;m++)if(u[m].hasBeenReset||!u[m].displayState)return!0;return!1}if(!s(e)){for(var n=0;n<e.length;n++)i.appendChild(e[n].displayState);return}var l=[],f=hs.getSimpleBoxPosition(i),o=Math.round(f.height*wN*100)/100,c={font:o+"px "+jN};(function(){var u,m;for(var p=0;p<e.length;p++)m=e[p],u=new M5(t,m,c),i.appendChild(u.div),pN(t,u,f,l),m.displayState=u.div,l.push(hs.getSimpleBoxPosition(u))})()};vo.Parser=function(t,e,a){if(!a)a=e,e={};if(!e)e={};this.window=t,this.vttjs=e,this.state="INITIAL",this.buffer="",this.decoder=a||new TextDecoder("utf8"),this.regionList=[]};vo.Parser.prototype={reportOrThrowError:function(t){if(t instanceof Ps)this.onparsingerror&&this.onparsingerror(t);else throw t},parse:function(t){var e=this;if(t)e.buffer+=e.decoder.decode(t,{stream:!0});function a(){var u=e.buffer,m=0;while(m<u.length&&u[m]!=="\r"&&u[m]!==`
@@ -1,2 +1,2 @@
1
- import{Cj as e,Fj as a,Tg as t}from"./chunk-wf4d1anc.js";function n({className:i,size:r="default",...s}){return t(e.Root,{"data-slot":"switch","data-size":r,className:a("peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",i),...s,children:t(e.Thumb,{"data-slot":"switch-thumb",className:a("pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground")})})}
1
+ import{ck as e,gk as a,oh as t}from"./chunk-nyhqy6q2.js";function n({className:i,size:r="default",...s}){return t(e.Root,{"data-slot":"switch","data-size":r,className:a("peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",i),...s,children:t(e.Thumb,{"data-slot":"switch-thumb",className:a("pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground")})})}
2
2
  export{n as Za};