bunqueue-dashboard 0.0.29 → 0.0.31

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 (74) hide show
  1. package/agent/db.ts +16 -19
  2. package/agent/server.ts +4 -4
  3. package/dist/.vite/manifest.json +194 -146
  4. package/dist/assets/{AddJob-UCSTFuum.js → AddJob-CAhdg38n.js} +1 -1
  5. package/dist/assets/{Alerts-CofRabaP.js → Alerts-70bxf-PT.js} +1 -1
  6. package/dist/assets/{AreaChart-Dl_9G6GH.js → AreaChart-2gM0YoZT.js} +1 -1
  7. package/dist/assets/{Benchmark-B1VUJJLw.js → Benchmark-CFZ3WCvj.js} +1 -1
  8. package/dist/assets/{BulkAddJobs-DVgkRtrp.js → BulkAddJobs-BzgzpGg_.js} +1 -1
  9. package/dist/assets/CopilotPanel-DZUGIf1q.js +44 -0
  10. package/dist/assets/{Cron-CqlZj2V5.js → Cron-ltjSoTjj.js} +1 -1
  11. package/dist/assets/CronManager-BcFALDeT.js +1 -0
  12. package/dist/assets/{Database-BYZ8LJb5.js → Database-CV2yt5O2.js} +2 -2
  13. package/dist/assets/{Diagnostics-Dk1ErNCF.js → Diagnostics-D-EK4GEi.js} +1 -1
  14. package/dist/assets/Dlq-fZAKwQoC.js +1 -0
  15. package/dist/assets/DlqControl-eTrrQCrn.js +1 -0
  16. package/dist/assets/{DlqPro-D8DOy5MI.js → DlqPro-CF79339e.js} +1 -1
  17. package/dist/assets/{Flows-DP9-h7a0.js → Flows-Ba8G7mcC.js} +1 -1
  18. package/dist/assets/JobInspector--d_8ca9p.js +2 -0
  19. package/dist/assets/Jobs-DEqAc1A5.js +1 -0
  20. package/dist/assets/JobsPro-BcaokZIf.js +1 -0
  21. package/dist/assets/Logs-DBTukPIX.js +1 -0
  22. package/dist/assets/LogsPro-Wl_e6hZM.js +1 -0
  23. package/dist/assets/{McpServer-MfQ0qsAI.js → McpServer-CnWJsKw7.js} +1 -1
  24. package/dist/assets/{Metrics-C4Dwg_DP.js → Metrics-DzeIhNL-.js} +1 -1
  25. package/dist/assets/{MetricsPro-Bt9zLjkN.js → MetricsPro-O9eVJSH0.js} +1 -1
  26. package/dist/assets/Overview-Bnu7rWqt.js +1 -0
  27. package/dist/assets/{Pagination-BQg6KGW1.js → Pagination-D4ki-pGz.js} +1 -1
  28. package/dist/assets/QueueActions-DHoSkWRz.js +1 -0
  29. package/dist/assets/QueueControl-DKqEXnkM.js +1 -0
  30. package/dist/assets/{QueueDetail-wjRLlCYY.js → QueueDetail-DLRow04B.js} +1 -1
  31. package/dist/assets/QueueDetailPro-BYmOVd4T.js +1 -0
  32. package/dist/assets/Queues-CoyjRFN7.js +1 -0
  33. package/dist/assets/{QueuesOverview-DfRqAfS1.js → QueuesOverview-BeWdJpKi.js} +1 -1
  34. package/dist/assets/{S3Backup-UQ_HKrn0.js → S3Backup-BaLFgl9d.js} +1 -1
  35. package/dist/assets/{S3BackupPro-V3JNhUK8.js → S3BackupPro-DJB4oWgz.js} +1 -1
  36. package/dist/assets/{ServerControl-DXidWdsq.js → ServerControl-_0lVB33E.js} +1 -1
  37. package/dist/assets/{Settings-0j8DZK9n.js → Settings-zKFJTtnq.js} +1 -1
  38. package/dist/assets/Usage-CKGkvl0j.js +1 -0
  39. package/dist/assets/{UsagePro-CbVFCD3J.js → UsagePro-B-TJ6fp4.js} +1 -1
  40. package/dist/assets/{Webhooks-Dr0oBZr9.js → Webhooks-C3zmvY-_.js} +1 -1
  41. package/dist/assets/{Workers-Bwil4zIU.js → Workers-jKhhXl3W.js} +1 -1
  42. package/dist/assets/{WorkersPro-BRYPAhyx.js → WorkersPro-mvY5VX8I.js} +1 -1
  43. package/dist/assets/{connectionStore-B-hNUqwK.js → connectionStore-Ci04lJmR.js} +1 -1
  44. package/dist/assets/dist-1f1fMHVO.js +11 -0
  45. package/dist/assets/dist-BlWBaCN6.js +11 -0
  46. package/dist/assets/dist-DZL8soAh.js +79 -0
  47. package/dist/assets/dist-DjvZiKhB.js +2 -0
  48. package/dist/assets/dist-DpZcbP9W.js +11 -0
  49. package/dist/assets/{form-C-zZyKfB.js → form-DGinTEEb.js} +1 -1
  50. package/dist/assets/index-BOcegTHa.js +8 -0
  51. package/dist/assets/index-DWV3tgrk.css +1 -0
  52. package/dist/assets/{react-vendor-B68RYDeC.js → react-vendor-BcouBxpZ.js} +2 -2
  53. package/dist/assets/{useThroughputSeries-defI_JpV.js → useThroughputSeries-Chp5OLx3.js} +1 -1
  54. package/dist/index.html +4 -4
  55. package/package.json +5 -5
  56. package/scripts/embedded.gen.ts +122 -112
  57. package/scripts/serve.ts +11 -0
  58. package/dist/assets/CopilotPanel-BJeJYfaz.js +0 -152
  59. package/dist/assets/CronManager-C6kjWCLE.js +0 -1
  60. package/dist/assets/Dlq-DANXiXsm.js +0 -1
  61. package/dist/assets/DlqControl-DUturU7q.js +0 -1
  62. package/dist/assets/JobInspector-BHZtkFL6.js +0 -2
  63. package/dist/assets/Jobs-Bgr-HRmL.js +0 -1
  64. package/dist/assets/JobsPro-C2Vc2iRC.js +0 -1
  65. package/dist/assets/Logs-CaOn3IpL.js +0 -1
  66. package/dist/assets/LogsPro-BpSZaHzN.js +0 -1
  67. package/dist/assets/Overview-BO3xG6I0.js +0 -1
  68. package/dist/assets/QueueActions-Bez_iOjl.js +0 -1
  69. package/dist/assets/QueueControl-CEXlJDkE.js +0 -1
  70. package/dist/assets/QueueDetailPro-CuVyxX4Z.js +0 -1
  71. package/dist/assets/Queues-2W2E6e5R.js +0 -1
  72. package/dist/assets/Usage-C5DsZvR5.js +0 -1
  73. package/dist/assets/index-BjRjwWwc.js +0 -8
  74. package/dist/assets/index-mF63w920.css +0 -1
@@ -0,0 +1,2 @@
1
+ import{$ as e,A as t,Ct as n,Et as r,Ft as i,G as a,Ht as o,I as s,It as c,K as l,Lt as u,M as d,Mt as f,Nt as p,Ot as m,Q as h,Rt as g,S as _,U as v,Vt as y,W as b,Wt as x,Z as S,_ as C,_t as w,c as T,ct as E,d as D,ft as O,gt as k,h as ee,ht as A,it as j,jt as M,k as N,kt as P,l as F,lt as I,mt as L,nt as R,pt as z,q as B,qt as V,rt as H,u as U,v as W,wt as G,x as K,y as q,yt as J,z as te}from"./dist-DZL8soAh.js";var Y=C({errorSchema:v(()=>A(f({type:m(`error`),error:f({type:i(),message:i()})}))),errorToMessage:e=>e.error.message}),ne=v(()=>A(f({id:i(),type:m(`file`),filename:i(),mime_type:i(),size_bytes:M(),created_at:i(),downloadable:G().nullish()}))),re=class{constructor(e){this.config=e,this.specificationVersion=`v4`}get provider(){return this.config.provider}async uploadFile({data:e,mediaType:t,filename:n}){let r=U(e),i=new Blob([r],{type:t}),a=new FormData;n==null?a.append(`file`,i):a.append(`file`,i,n);let{value:o}=await h({url:`${this.config.baseURL}/files`,headers:T(this.config.headers(),{"anthropic-beta":`files-api-2025-04-14`}),formData:a,failedResponseHandler:Y,successfulResponseHandler:W(ne),fetch:this.config.fetch});return{warnings:[],providerReference:{anthropic:o.id},mediaType:o.mime_type??t,filename:o.filename??n,providerMetadata:{anthropic:{filename:o.filename,mimeType:o.mime_type,sizeBytes:o.size_bytes,createdAt:o.created_at,...o.downloadable==null?{}:{downloadable:o.downloadable}}}}}},X=f({type:i(),category:i().nullish(),explanation:i().nullish(),recommended_model:i().nullish()}),ie=v(()=>A(f({type:m(`message`),id:i().nullish(),model:i().nullish(),content:n(r(`type`,[f({type:m(`text`),text:i(),citations:n(r(`type`,[f({type:m(`web_search_result_location`),cited_text:i(),url:i(),title:i(),encrypted_index:i()}),f({type:m(`page_location`),cited_text:i(),document_index:M(),document_title:i().nullable(),start_page_number:M(),end_page_number:M()}),f({type:m(`char_location`),cited_text:i(),document_index:M(),document_title:i().nullable(),start_char_index:M(),end_char_index:M()})])).optional()}),f({type:m(`thinking`),thinking:i(),signature:i()}),f({type:m(`redacted_thinking`),data:i()}),f({type:m(`compaction`),content:i()}),f({type:m(`tool_use`),id:i(),name:i(),input:g(),caller:u([f({type:m(`code_execution_20250825`),tool_id:i()}),f({type:m(`code_execution_20260120`),tool_id:i()}),f({type:m(`direct`)})]).optional()}),f({type:m(`server_tool_use`),id:i(),name:i(),input:p(i(),g()).nullish(),caller:u([f({type:m(`code_execution_20260120`),tool_id:i()}),f({type:m(`direct`)})]).optional()}),f({type:m(`mcp_tool_use`),id:i(),name:i(),input:g(),server_name:i()}),f({type:m(`mcp_tool_result`),tool_use_id:i(),is_error:G(),content:n(u([i(),f({type:m(`text`),text:i()})]))}),f({type:m(`web_fetch_tool_result`),tool_use_id:i(),content:u([f({type:m(`web_fetch_result`),url:i(),retrieved_at:i(),content:f({type:m(`document`),title:i().nullable(),citations:f({enabled:G()}).optional(),source:u([f({type:m(`base64`),media_type:m(`application/pdf`),data:i()}),f({type:m(`text`),media_type:m(`text/plain`),data:i()})])})}),f({type:m(`web_fetch_tool_result_error`),error_code:i()})])}),f({type:m(`web_search_tool_result`),tool_use_id:i(),content:u([n(f({type:m(`web_search_result`),url:i(),title:i(),encrypted_content:i(),page_age:i().nullish()})),f({type:m(`web_search_tool_result_error`),error_code:i()})])}),f({type:m(`code_execution_tool_result`),tool_use_id:i(),content:u([f({type:m(`code_execution_result`),stdout:i(),stderr:i(),return_code:M(),content:n(f({type:m(`code_execution_output`),file_id:i()})).optional().default([])}),f({type:m(`encrypted_code_execution_result`),encrypted_stdout:i(),stderr:i(),return_code:M(),content:n(f({type:m(`code_execution_output`),file_id:i()})).optional().default([])}),f({type:m(`code_execution_tool_result_error`),error_code:i()})])}),f({type:m(`bash_code_execution_tool_result`),tool_use_id:i(),content:r(`type`,[f({type:m(`bash_code_execution_result`),content:n(f({type:m(`bash_code_execution_output`),file_id:i()})),stdout:i(),stderr:i(),return_code:M()}),f({type:m(`bash_code_execution_tool_result_error`),error_code:i()})])}),f({type:m(`text_editor_code_execution_tool_result`),tool_use_id:i(),content:r(`type`,[f({type:m(`text_editor_code_execution_tool_result_error`),error_code:i()}),f({type:m(`text_editor_code_execution_view_result`),content:i(),file_type:i(),num_lines:M().nullable(),start_line:M().nullable(),total_lines:M().nullable()}),f({type:m(`text_editor_code_execution_create_result`),is_file_update:G()}),f({type:m(`text_editor_code_execution_str_replace_result`),lines:n(i()).nullable(),new_lines:M().nullable(),new_start:M().nullable(),old_lines:M().nullable(),old_start:M().nullable()})])}),f({type:m(`tool_search_tool_result`),tool_use_id:i(),content:u([f({type:m(`tool_search_tool_search_result`),tool_references:n(f({type:m(`tool_reference`),tool_name:i()}))}),f({type:m(`tool_search_tool_result_error`),error_code:i()})])}),f({type:m(`advisor_tool_result`),tool_use_id:i(),content:r(`type`,[f({type:m(`advisor_result`),text:i()}),f({type:m(`advisor_redacted_result`),encrypted_content:i()}),f({type:m(`advisor_tool_result_error`),error_code:i()})])}),f({type:m(`fallback`)})])),stop_reason:i().nullish(),stop_sequence:i().nullish(),stop_details:X.nullish(),usage:P({input_tokens:M(),output_tokens:M(),cache_creation_input_tokens:M().nullish(),cache_read_input_tokens:M().nullish(),iterations:n(f({type:u([m(`compaction`),m(`message`),m(`advisor_message`),m(`fallback_message`)]),model:i().nullish(),input_tokens:M(),output_tokens:M(),cache_creation_input_tokens:M().nullish(),cache_read_input_tokens:M().nullish()})).nullish()}),container:f({expires_at:i(),id:i(),skills:n(f({type:u([m(`anthropic`),m(`custom`)]),skill_id:i(),version:i()})).nullish()}).nullish(),context_management:f({applied_edits:n(u([f({type:m(`clear_tool_uses_20250919`),cleared_tool_uses:M(),cleared_input_tokens:M()}),f({type:m(`clear_thinking_20251015`),cleared_thinking_turns:M(),cleared_input_tokens:M()}),f({type:m(`compact_20260112`)})]))}).nullish()}))),ae=v(()=>A(r(`type`,[f({type:m(`message_start`),message:f({id:i().nullish(),model:i().nullish(),role:i().nullish(),usage:P({input_tokens:M(),cache_creation_input_tokens:M().nullish(),cache_read_input_tokens:M().nullish()}),content:n(r(`type`,[f({type:m(`tool_use`),id:i(),name:i(),input:g(),caller:u([f({type:m(`code_execution_20250825`),tool_id:i()}),f({type:m(`code_execution_20260120`),tool_id:i()}),f({type:m(`direct`)})]).optional()})])).nullish(),stop_reason:i().nullish(),container:f({expires_at:i(),id:i()}).nullish()})}),f({type:m(`content_block_start`),index:M(),content_block:r(`type`,[f({type:m(`text`),text:i()}),f({type:m(`thinking`),thinking:i()}),f({type:m(`tool_use`),id:i(),name:i(),input:p(i(),g()).optional(),caller:u([f({type:m(`code_execution_20250825`),tool_id:i()}),f({type:m(`code_execution_20260120`),tool_id:i()}),f({type:m(`direct`)})]).optional()}),f({type:m(`redacted_thinking`),data:i()}),f({type:m(`compaction`),content:i().nullish()}),f({type:m(`server_tool_use`),id:i(),name:i(),input:p(i(),g()).nullish(),caller:u([f({type:m(`code_execution_20260120`),tool_id:i()}),f({type:m(`direct`)})]).optional()}),f({type:m(`mcp_tool_use`),id:i(),name:i(),input:g(),server_name:i()}),f({type:m(`mcp_tool_result`),tool_use_id:i(),is_error:G(),content:n(u([i(),f({type:m(`text`),text:i()})]))}),f({type:m(`web_fetch_tool_result`),tool_use_id:i(),content:u([f({type:m(`web_fetch_result`),url:i(),retrieved_at:i(),content:f({type:m(`document`),title:i().nullable(),citations:f({enabled:G()}).optional(),source:u([f({type:m(`base64`),media_type:m(`application/pdf`),data:i()}),f({type:m(`text`),media_type:m(`text/plain`),data:i()})])})}),f({type:m(`web_fetch_tool_result_error`),error_code:i()})])}),f({type:m(`web_search_tool_result`),tool_use_id:i(),content:u([n(f({type:m(`web_search_result`),url:i(),title:i(),encrypted_content:i(),page_age:i().nullish()})),f({type:m(`web_search_tool_result_error`),error_code:i()})])}),f({type:m(`code_execution_tool_result`),tool_use_id:i(),content:u([f({type:m(`code_execution_result`),stdout:i(),stderr:i(),return_code:M(),content:n(f({type:m(`code_execution_output`),file_id:i()})).optional().default([])}),f({type:m(`encrypted_code_execution_result`),encrypted_stdout:i(),stderr:i(),return_code:M(),content:n(f({type:m(`code_execution_output`),file_id:i()})).optional().default([])}),f({type:m(`code_execution_tool_result_error`),error_code:i()})])}),f({type:m(`bash_code_execution_tool_result`),tool_use_id:i(),content:r(`type`,[f({type:m(`bash_code_execution_result`),content:n(f({type:m(`bash_code_execution_output`),file_id:i()})),stdout:i(),stderr:i(),return_code:M()}),f({type:m(`bash_code_execution_tool_result_error`),error_code:i()})])}),f({type:m(`text_editor_code_execution_tool_result`),tool_use_id:i(),content:r(`type`,[f({type:m(`text_editor_code_execution_tool_result_error`),error_code:i()}),f({type:m(`text_editor_code_execution_view_result`),content:i(),file_type:i(),num_lines:M().nullable(),start_line:M().nullable(),total_lines:M().nullable()}),f({type:m(`text_editor_code_execution_create_result`),is_file_update:G()}),f({type:m(`text_editor_code_execution_str_replace_result`),lines:n(i()).nullable(),new_lines:M().nullable(),new_start:M().nullable(),old_lines:M().nullable(),old_start:M().nullable()})])}),f({type:m(`tool_search_tool_result`),tool_use_id:i(),content:u([f({type:m(`tool_search_tool_search_result`),tool_references:n(f({type:m(`tool_reference`),tool_name:i()}))}),f({type:m(`tool_search_tool_result_error`),error_code:i()})])}),f({type:m(`advisor_tool_result`),tool_use_id:i(),content:r(`type`,[f({type:m(`advisor_result`),text:i()}),f({type:m(`advisor_redacted_result`),encrypted_content:i()}),f({type:m(`advisor_tool_result_error`),error_code:i()})])}),f({type:m(`fallback`)})])}),f({type:m(`content_block_delta`),index:M(),delta:r(`type`,[f({type:m(`input_json_delta`),partial_json:i()}),f({type:m(`text_delta`),text:i()}),f({type:m(`thinking_delta`),thinking:i()}),f({type:m(`signature_delta`),signature:i()}),f({type:m(`compaction_delta`),content:i().nullish()}),f({type:m(`citations_delta`),citation:r(`type`,[f({type:m(`web_search_result_location`),cited_text:i(),url:i(),title:i(),encrypted_index:i()}),f({type:m(`page_location`),cited_text:i(),document_index:M(),document_title:i().nullable(),start_page_number:M(),end_page_number:M()}),f({type:m(`char_location`),cited_text:i(),document_index:M(),document_title:i().nullable(),start_char_index:M(),end_char_index:M()})])})])}),f({type:m(`content_block_stop`),index:M()}),f({type:m(`error`),error:f({type:i(),message:i()})}),f({type:m(`message_delta`),delta:f({stop_reason:i().nullish(),stop_sequence:i().nullish(),stop_details:X.nullish(),container:f({expires_at:i(),id:i(),skills:n(f({type:u([m(`anthropic`),m(`custom`)]),skill_id:i(),version:i()})).nullish()}).nullish()}),usage:P({input_tokens:M().nullish(),output_tokens:M(),cache_creation_input_tokens:M().nullish(),cache_read_input_tokens:M().nullish(),iterations:n(f({type:u([m(`compaction`),m(`message`),m(`advisor_message`),m(`fallback_message`)]),model:i().nullish(),input_tokens:M(),output_tokens:M(),cache_creation_input_tokens:M().nullish(),cache_read_input_tokens:M().nullish()})).nullish()}),context_management:f({applied_edits:n(u([f({type:m(`clear_tool_uses_20250919`),cleared_tool_uses:M(),cleared_input_tokens:M()}),f({type:m(`clear_thinking_20251015`),cleared_thinking_turns:M(),cleared_input_tokens:M()}),f({type:m(`compact_20260112`)})]))}).nullish()}),f({type:m(`message_stop`)}),f({type:m(`ping`)})]))),oe=v(()=>A(f({signature:i().optional(),redactedData:i().optional()}))),Z=f({containerUpload:G().optional(),citations:f({enabled:G()}).optional(),title:i().optional(),context:i().optional()}),se=f({sendReasoning:G().optional(),structuredOutputMode:J([`outputFormat`,`jsonTool`,`auto`]).optional(),thinking:r(`type`,[f({type:m(`adaptive`),display:J([`omitted`,`summarized`]).optional()}),f({type:m(`enabled`),budgetTokens:M().optional()}),f({type:m(`disabled`)})]).optional(),disableParallelToolUse:G().optional(),cacheControl:f({type:m(`ephemeral`),ttl:u([m(`5m`),m(`1h`)]).optional()}).optional(),metadata:f({userId:i().optional()}).optional(),mcpServers:n(f({type:m(`url`),name:i(),url:i(),authorizationToken:i().nullish(),toolConfiguration:f({enabled:G().nullish(),allowedTools:n(i()).nullish()}).nullish()})).optional(),container:f({id:i().optional(),skills:n(r(`type`,[f({type:m(`anthropic`),skillId:i(),version:i().optional()}),f({type:m(`custom`),providerReference:p(i(),i()),version:i().optional()})])).optional()}).optional(),toolStreaming:G().optional(),effort:J([`low`,`medium`,`high`,`xhigh`,`max`]).optional(),taskBudget:f({type:m(`tokens`),total:M().int().min(2e4),remaining:M().int().min(0).optional()}).optional(),speed:J([`fast`,`standard`]).optional(),inferenceGeo:J([`us`,`global`]).optional(),fallbacks:n(f({model:i(),max_tokens:M().int().optional(),thinking:p(i(),g()).optional(),output_config:p(i(),g()).optional(),speed:J([`fast`,`standard`]).optional()})).optional(),anthropicBeta:n(i()).optional(),contextManagement:f({edits:n(r(`type`,[f({type:m(`clear_tool_uses_20250919`),trigger:r(`type`,[f({type:m(`input_tokens`),value:M()}),f({type:m(`tool_uses`),value:M()})]).optional(),keep:f({type:m(`tool_uses`),value:M()}).optional(),clearAtLeast:f({type:m(`input_tokens`),value:M()}).optional(),clearToolInputs:G().optional(),excludeTools:n(i()).optional()}),f({type:m(`clear_thinking_20251015`),keep:u([m(`all`),f({type:m(`thinking_turns`),value:M()})]).optional()}),f({type:m(`compact_20260112`),trigger:f({type:m(`input_tokens`),value:M()}).optional(),pauseAfterCompaction:G().optional(),instructions:i().optional()})]))}).optional()}),ce=4;function le(e){let t=e?.anthropic;return t?.cacheControl??t?.cache_control}var Q=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(e,t){let n=le(e);if(n){if(!t.canCache){this.warnings.push({type:`unsupported`,feature:`cache_control on non-cacheable context`,details:`cache_control cannot be set on ${t.type}. It will be ignored.`});return}if(this.breakpointCount++,this.breakpointCount>ce){this.warnings.push({type:`unsupported`,feature:`cacheControl breakpoint limit`,details:`Maximum ${ce} cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`});return}return n}}getWarnings(){return this.warnings}},ue=v(()=>A(f({model:i(),maxUses:M().optional(),caching:f({type:m(`ephemeral`),ttl:u([m(`5m`),m(`1h`)])}).optional()}))),de=v(()=>A(r(`type`,[f({type:m(`advisor_result`),text:i()}),f({type:m(`advisor_redacted_result`),encryptedContent:i()}),f({type:m(`advisor_tool_result_error`),errorCode:i()})]))),fe=K({id:`anthropic.advisor_20260301`,inputSchema:v(()=>A(f({}).strict())),outputSchema:de,supportsDeferredResults:!0}),pe=e=>fe(e),me=v(()=>A(f({maxCharacters:M().optional()}))),he=q({id:`anthropic.text_editor_20250728`,inputSchema:v(()=>A(f({command:J([`view`,`create`,`str_replace`,`insert`]),path:i(),file_text:i().optional(),insert_line:M().int().optional(),new_str:i().optional(),insert_text:i().optional(),old_str:i().optional(),view_range:n(M().int()).optional()})))}),ge=(e={})=>he(e),_e=v(()=>A(f({maxUses:M().optional(),allowedDomains:n(i()).optional(),blockedDomains:n(i()).optional(),userLocation:f({type:m(`approximate`),city:i().optional(),region:i().optional(),country:i().optional(),timezone:i().optional()}).optional()}))),ve=v(()=>A(n(f({url:i(),title:i().nullable(),pageAge:i().nullable(),encryptedContent:i(),type:m(`web_search_result`)})))),ye=K({id:`anthropic.web_search_20260209`,inputSchema:v(()=>A(f({query:i()}))),outputSchema:ve,supportsDeferredResults:!0}),be=(e={})=>ye(e),xe=v(()=>A(f({maxUses:M().optional(),allowedDomains:n(i()).optional(),blockedDomains:n(i()).optional(),userLocation:f({type:m(`approximate`),city:i().optional(),region:i().optional(),country:i().optional(),timezone:i().optional()}).optional()}))),Se=v(()=>A(n(f({url:i(),title:i().nullable(),pageAge:i().nullable(),encryptedContent:i(),type:m(`web_search_result`)})))),Ce=K({id:`anthropic.web_search_20250305`,inputSchema:v(()=>A(f({query:i()}))),outputSchema:Se,supportsDeferredResults:!0}),we=(e={})=>Ce(e),Te=v(()=>A(f({maxUses:M().optional(),allowedDomains:n(i()).optional(),blockedDomains:n(i()).optional(),citations:f({enabled:G()}).optional(),maxContentTokens:M().optional()}))),Ee=v(()=>A(f({type:m(`web_fetch_result`),url:i(),content:f({type:m(`document`),title:i().nullable(),citations:f({enabled:G()}).optional(),source:u([f({type:m(`base64`),mediaType:m(`application/pdf`),data:i()}),f({type:m(`text`),mediaType:m(`text/plain`),data:i()})])}),retrievedAt:i().nullable()}))),De=K({id:`anthropic.web_fetch_20260209`,inputSchema:v(()=>A(f({url:i()}))),outputSchema:Ee,supportsDeferredResults:!0}),Oe=(e={})=>De(e),ke=v(()=>A(f({maxUses:M().optional(),allowedDomains:n(i()).optional(),blockedDomains:n(i()).optional(),citations:f({enabled:G()}).optional(),maxContentTokens:M().optional()}))),Ae=v(()=>A(f({type:m(`web_fetch_result`),url:i(),content:f({type:m(`document`),title:i().nullable(),citations:f({enabled:G()}).optional(),source:u([f({type:m(`base64`),mediaType:m(`application/pdf`),data:i()}),f({type:m(`text`),mediaType:m(`text/plain`),data:i()})])}),retrievedAt:i().nullable()}))),je=K({id:`anthropic.web_fetch_20250910`,inputSchema:v(()=>A(f({url:i()}))),outputSchema:Ae,supportsDeferredResults:!0}),Me=(e={})=>je(e);async function Ne({tools:e,toolChoice:t,disableParallelToolUse:n,cacheControlValidator:r,supportsStructuredOutput:i,supportsStrictTools:a,defaultEagerInputStreaming:o=!1}){e=e?.length?e:void 0;let s=[],c=new Set,l=r||new Q;if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:s,betas:c};let u=[];for(let t of e)switch(t.type){case`function`:{let e=l.getCacheControl(t.providerOptions,{type:`tool definition`,canCache:!0}),n=t.providerOptions?.anthropic,r=n?.eagerInputStreaming??o,d=n?.deferLoading,f=n?.allowedCallers;!a&&t.strict!=null&&s.push({type:`unsupported`,feature:`strict`,details:`Tool '${t.name}' has strict: ${t.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`}),u.push({name:t.name,description:t.description,input_schema:t.inputSchema,cache_control:e,...r?{eager_input_streaming:!0}:{},...a===!0&&t.strict!=null?{strict:t.strict}:{},...d==null?{}:{defer_loading:d},...f==null?{}:{allowed_callers:f},...t.inputExamples==null?{}:{input_examples:t.inputExamples.map(e=>e.input)}}),i===!0&&c.add(`structured-outputs-2025-11-13`),(t.inputExamples!=null||f!=null)&&c.add(`advanced-tool-use-2025-11-20`);break}case`provider`:switch(t.id){case`anthropic.code_execution_20250522`:c.add(`code-execution-2025-05-22`),u.push({type:`code_execution_20250522`,name:`code_execution`,cache_control:void 0});break;case`anthropic.code_execution_20250825`:c.add(`code-execution-2025-08-25`),u.push({type:`code_execution_20250825`,name:`code_execution`});break;case`anthropic.code_execution_20260120`:u.push({type:`code_execution_20260120`,name:`code_execution`});break;case`anthropic.computer_20250124`:c.add(`computer-use-2025-01-24`),u.push({name:`computer`,type:`computer_20250124`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case`anthropic.computer_20251124`:c.add(`computer-use-2025-11-24`),u.push({name:`computer`,type:`computer_20251124`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,enable_zoom:t.args.enableZoom,cache_control:void 0});break;case`anthropic.computer_20241022`:c.add(`computer-use-2024-10-22`),u.push({name:`computer`,type:`computer_20241022`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case`anthropic.text_editor_20250124`:c.add(`computer-use-2025-01-24`),u.push({name:`str_replace_editor`,type:`text_editor_20250124`,cache_control:void 0});break;case`anthropic.text_editor_20241022`:c.add(`computer-use-2024-10-22`),u.push({name:`str_replace_editor`,type:`text_editor_20241022`,cache_control:void 0});break;case`anthropic.text_editor_20250429`:c.add(`computer-use-2025-01-24`),u.push({name:`str_replace_based_edit_tool`,type:`text_editor_20250429`,cache_control:void 0});break;case`anthropic.text_editor_20250728`:{let e=await O({value:t.args,schema:me});u.push({name:`str_replace_based_edit_tool`,type:`text_editor_20250728`,max_characters:e.maxCharacters,cache_control:void 0});break}case`anthropic.bash_20250124`:c.add(`computer-use-2025-01-24`),u.push({name:`bash`,type:`bash_20250124`,cache_control:void 0});break;case`anthropic.bash_20241022`:c.add(`computer-use-2024-10-22`),u.push({name:`bash`,type:`bash_20241022`,cache_control:void 0});break;case`anthropic.memory_20250818`:c.add(`context-management-2025-06-27`),u.push({name:`memory`,type:`memory_20250818`});break;case`anthropic.web_fetch_20250910`:{c.add(`web-fetch-2025-09-10`);let e=await O({value:t.args,schema:ke});u.push({type:`web_fetch_20250910`,name:`web_fetch`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case`anthropic.web_fetch_20260209`:{c.add(`code-execution-web-tools-2026-02-09`);let e=await O({value:t.args,schema:Te});u.push({type:`web_fetch_20260209`,name:`web_fetch`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case`anthropic.web_search_20250305`:{let e=await O({value:t.args,schema:xe});u.push({type:`web_search_20250305`,name:`web_search`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case`anthropic.web_search_20260209`:{c.add(`code-execution-web-tools-2026-02-09`);let e=await O({value:t.args,schema:_e});u.push({type:`web_search_20260209`,name:`web_search`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case`anthropic.tool_search_regex_20251119`:u.push({type:`tool_search_tool_regex_20251119`,name:`tool_search_tool_regex`});break;case`anthropic.tool_search_bm25_20251119`:u.push({type:`tool_search_tool_bm25_20251119`,name:`tool_search_tool_bm25`});break;case`anthropic.advisor_20260301`:{c.add(`advisor-tool-2026-03-01`);let e=await O({value:t.args,schema:ue});u.push({type:`advisor_20260301`,name:`advisor`,model:e.model,...e.maxUses!==void 0&&{max_uses:e.maxUses},...e.caching!==void 0&&{caching:e.caching}});break}default:s.push({type:`unsupported`,feature:`provider-defined tool ${t.id}`});break}break;default:s.push({type:`unsupported`,feature:`tool ${t}`});break}if(t==null)return{tools:u,toolChoice:n?{type:`auto`,disable_parallel_tool_use:n}:void 0,toolWarnings:s,betas:c};let d=t.type;switch(d){case`auto`:return{tools:u,toolChoice:{type:`auto`,disable_parallel_tool_use:n},toolWarnings:s,betas:c};case`required`:return{tools:u,toolChoice:{type:`any`,disable_parallel_tool_use:n},toolWarnings:s,betas:c};case`none`:return{tools:void 0,toolChoice:void 0,toolWarnings:s,betas:c};case`tool`:return{tools:u,toolChoice:{type:`tool`,name:t.toolName,disable_parallel_tool_use:n},toolWarnings:s,betas:c};default:throw new V({functionality:`tool choice type: ${d}`})}}function Pe({usage:e,rawUsage:t}){let n=e.cache_creation_input_tokens??0,r=e.cache_read_input_tokens??0,i,a,o=e.iterations?.some(e=>e.type===`fallback_message`);if(e.iterations&&e.iterations.length>0&&!o){let t=e.iterations.filter(e=>e.type===`compaction`||e.type===`message`);if(t.length>0){let e=t.reduce((e,t)=>({input:e.input+t.input_tokens,output:e.output+t.output_tokens}),{input:0,output:0});i=e.input,a=e.output}else i=e.input_tokens,a=e.output_tokens}else i=e.input_tokens,a=e.output_tokens;return{inputTokens:{total:i+n+r,noCache:i,cacheRead:r,cacheWrite:n},outputTokens:{total:a,text:void 0,reasoning:void 0},raw:t??e}}var Fe=v(()=>A(f({type:m(`code_execution_result`),stdout:i(),stderr:i(),return_code:M(),content:n(f({type:m(`code_execution_output`),file_id:i()})).optional().default([])}))),Ie=K({id:`anthropic.code_execution_20250522`,inputSchema:v(()=>A(f({code:i()}))),outputSchema:Fe}),Le=(e={})=>Ie(e),Re=v(()=>A(r(`type`,[f({type:m(`code_execution_result`),stdout:i(),stderr:i(),return_code:M(),content:n(f({type:m(`code_execution_output`),file_id:i()})).optional().default([])}),f({type:m(`bash_code_execution_result`),content:n(f({type:m(`bash_code_execution_output`),file_id:i()})),stdout:i(),stderr:i(),return_code:M()}),f({type:m(`bash_code_execution_tool_result_error`),error_code:i()}),f({type:m(`text_editor_code_execution_tool_result_error`),error_code:i()}),f({type:m(`text_editor_code_execution_view_result`),content:i(),file_type:i(),num_lines:M().nullable(),start_line:M().nullable(),total_lines:M().nullable()}),f({type:m(`text_editor_code_execution_create_result`),is_file_update:G()}),f({type:m(`text_editor_code_execution_str_replace_result`),lines:n(i()).nullable(),new_lines:M().nullable(),new_start:M().nullable(),old_lines:M().nullable(),old_start:M().nullable()})]))),ze=K({id:`anthropic.code_execution_20250825`,inputSchema:v(()=>A(r(`type`,[f({type:m(`programmatic-tool-call`),code:i()}),f({type:m(`bash_code_execution`),command:i()}),r(`command`,[f({type:m(`text_editor_code_execution`),command:m(`view`),path:i()}),f({type:m(`text_editor_code_execution`),command:m(`create`),path:i(),file_text:i().nullish()}),f({type:m(`text_editor_code_execution`),command:m(`str_replace`),path:i(),old_str:i(),new_str:i()})])]))),outputSchema:Re,supportsDeferredResults:!0}),Be=(e={})=>ze(e),Ve=v(()=>A(r(`type`,[f({type:m(`code_execution_result`),stdout:i(),stderr:i(),return_code:M(),content:n(f({type:m(`code_execution_output`),file_id:i()})).optional().default([])}),f({type:m(`encrypted_code_execution_result`),encrypted_stdout:i(),stderr:i(),return_code:M(),content:n(f({type:m(`code_execution_output`),file_id:i()})).optional().default([])}),f({type:m(`bash_code_execution_result`),content:n(f({type:m(`bash_code_execution_output`),file_id:i()})),stdout:i(),stderr:i(),return_code:M()}),f({type:m(`bash_code_execution_tool_result_error`),error_code:i()}),f({type:m(`text_editor_code_execution_tool_result_error`),error_code:i()}),f({type:m(`text_editor_code_execution_view_result`),content:i(),file_type:i(),num_lines:M().nullable(),start_line:M().nullable(),total_lines:M().nullable()}),f({type:m(`text_editor_code_execution_create_result`),is_file_update:G()}),f({type:m(`text_editor_code_execution_str_replace_result`),lines:n(i()).nullable(),new_lines:M().nullable(),new_start:M().nullable(),old_lines:M().nullable(),old_start:M().nullable()})]))),He=K({id:`anthropic.code_execution_20260120`,inputSchema:v(()=>A(r(`type`,[f({type:m(`programmatic-tool-call`),code:i()}),f({type:m(`bash_code_execution`),command:i()}),r(`command`,[f({type:m(`text_editor_code_execution`),command:m(`view`),path:i()}),f({type:m(`text_editor_code_execution`),command:m(`create`),path:i(),file_text:i().nullish()}),f({type:m(`text_editor_code_execution`),command:m(`str_replace`),path:i(),old_str:i(),new_str:i()})])]))),outputSchema:Ve,supportsDeferredResults:!0}),Ue=(e={})=>He(e),We=v(()=>A(n(f({type:m(`tool_reference`),toolName:i()})))),Ge=K({id:`anthropic.tool_search_regex_20251119`,inputSchema:v(()=>A(f({pattern:i(),limit:M().optional()}))),outputSchema:We,supportsDeferredResults:!0}),Ke=(e={})=>Ge(e);function qe(e){return typeof e==`string`?new TextDecoder().decode(F(e)):new TextDecoder().decode(e)}function Je(e){try{if(typeof e==`string`)return E(e);if(typeof e==`object`&&e)return e}catch{let t=e?.errorCode;return{errorCode:typeof t==`string`?t:`unavailable`}}return{}}async function Ye({prompt:e,sendReasoning:t,warnings:n,cacheControlValidator:r,toolNameMapping:i}){let a=new Set,o=Xe(e),s=r||new Q,c,l=[];async function u(e){return(await S({provider:`anthropic`,providerOptions:e,schema:Z}))?.citations?.enabled??!1}async function f(e){return(await S({provider:`anthropic`,providerOptions:e,schema:Z}))?.containerUpload??!1}async function p(e){let t=await S({provider:`anthropic`,providerOptions:e,schema:Z});return{title:t?.title,context:t?.context}}for(let e=0;e<o.length;e++){let r=o[e],m=e===o.length-1,h=r.type;switch(h){case`system`:{let e=r.messages.map(({content:e,providerOptions:t})=>({type:`text`,text:e,cache_control:s.getCacheControl(t,{type:`system message`,canCache:!0})}));c==null?c=e:(l.push({role:`system`,content:e}),a.add(`mid-conversation-system-2026-04-07`));break}case`user`:{let e=[];for(let t of r.messages){let{role:r,content:i}=t;switch(r){case`user`:for(let n=0;n<i.length;n++){let r=i[n],o=n===i.length-1,c=s.getCacheControl(r.providerOptions,{type:`user message part`,canCache:!0})??(o?s.getCacheControl(t.providerOptions,{type:`user message`,canCache:!0}):void 0);switch(r.type){case`text`:e.push({type:`text`,text:r.text,cache_control:c});break;case`file`:switch(r.data.type){case`reference`:{let t=j({reference:r.data.reference,provider:`anthropic`});a.add(`files-api-2025-04-14`),await f(r.providerOptions)?e.push({type:`container_upload`,file_id:t}):d(r.mediaType)===`image`?e.push({type:`image`,source:{type:`file`,file_id:t},cache_control:c}):e.push({type:`document`,source:{type:`file`,file_id:t},cache_control:c});break}case`text`:{let t=await u(r.providerOptions),n=await p(r.providerOptions);e.push({type:`document`,source:{type:`text`,media_type:`text/plain`,data:r.data.text},title:n.title??r.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:c});break}case`url`:case`data`:{let t=d(r.mediaType);if(t===`image`)e.push({type:`image`,source:r.data.type===`url`?{type:`url`,url:r.data.url.toString()}:{type:`base64`,media_type:H({part:r}),data:D(r.data.data)},cache_control:c});else if(t===`application`&&(r.data.type===`url`?r.mediaType===`application/pdf`:H({part:r})===`application/pdf`)){a.add(`pdfs-2024-09-25`);let t=await u(r.providerOptions),n=await p(r.providerOptions);e.push({type:`document`,source:r.data.type===`url`?{type:`url`,url:r.data.url.toString()}:{type:`base64`,media_type:`application/pdf`,data:D(r.data.data)},title:n.title??r.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:c})}else if(r.mediaType===`text/plain`){let t=await u(r.providerOptions),n=await p(r.providerOptions);e.push({type:`document`,source:r.data.type===`url`?{type:`url`,url:r.data.url.toString()}:{type:`text`,media_type:`text/plain`,data:qe(r.data.data)},title:n.title??r.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:c})}else throw new V({functionality:`media type: ${r.mediaType}`});break}}break}}break;case`tool`:for(let r=0;r<i.length;r++){let o=i[r];if(o.type===`tool-approval-response`)continue;let c=o.output,l=`providerOptions`in c?c.providerOptions:c.type===`content`?c.value.find(e=>e.providerOptions!=null)?.providerOptions:void 0,u=r===i.length-1,f=s.getCacheControl(o.providerOptions,{type:`tool result part`,canCache:!0})??s.getCacheControl(l,{type:`tool result output`,canCache:!0})??(u?s.getCacheControl(t.providerOptions,{type:`tool result message`,canCache:!0}):void 0),p;switch(c.type){case`content`:p=c.value.map(e=>{switch(e.type){case`text`:return{type:`text`,text:e.text};case`file`:{let t=d(e.mediaType);if(e.data.type===`url`)return t===`image`?{type:`image`,source:{type:`url`,url:e.data.url.toString()}}:{type:`document`,source:{type:`url`,url:e.data.url.toString()}};if(e.data.type===`data`){if(t===`image`)return{type:`image`,source:{type:`base64`,media_type:H({part:e}),data:D(e.data.data)}};if(H({part:e})===`application/pdf`)return a.add(`pdfs-2024-09-25`),{type:`document`,source:{type:`base64`,media_type:`application/pdf`,data:D(e.data.data)}};n.push({type:`other`,message:`unsupported tool content part type: ${e.type} with media type: ${e.mediaType}`});return}n.push({type:`other`,message:`unsupported tool content part type: ${e.type} with data type: ${e.data.type}`});return}case`custom`:{let t=e.providerOptions?.anthropic;if(t?.type===`tool-reference`)return{type:`tool_reference`,tool_name:t.toolName};n.push({type:`other`,message:`unsupported custom tool content part`});return}default:n.push({type:`other`,message:`unsupported tool content part type: ${e.type}`});return}}).filter(te);break;case`text`:case`error-text`:p=c.value;break;case`execution-denied`:p=c.reason??`Tool call execution denied.`;break;default:p=JSON.stringify(c.value);break}e.push({type:`tool_result`,tool_use_id:o.toolCallId,content:p,is_error:c.type===`error-text`||c.type===`error-json`||void 0,cache_control:f})}break;default:throw Error(`Unsupported role: ${r}`)}}l.push({role:`user`,content:e});break}case`assistant`:{let e=[],a=new Set;for(let o=0;o<r.messages.length;o++){let c=r.messages[o],l=o===r.messages.length-1,{content:u}=c;for(let r=0;r<u.length;r++){let o=u[r],d=r===u.length-1,f=s.getCacheControl(o.providerOptions,{type:`assistant message part`,canCache:!0})??(d?s.getCacheControl(c.providerOptions,{type:`assistant message`,canCache:!0}):void 0);switch(o.type){case`text`:o.providerOptions?.anthropic?.type===`compaction`?e.push({type:`compaction`,content:o.text,cache_control:f}):e.push({type:`text`,text:m&&l&&d?o.text.trim():o.text,cache_control:f});break;case`reasoning`:if(t){let t=await S({provider:`anthropic`,providerOptions:o.providerOptions,schema:oe});t==null?n.push({type:`other`,message:`unsupported reasoning metadata`}):t.signature==null?t.redactedData==null?n.push({type:`other`,message:`unsupported reasoning metadata`}):(s.getCacheControl(o.providerOptions,{type:`redacted thinking block`,canCache:!1}),e.push({type:`redacted_thinking`,data:t.redactedData})):(s.getCacheControl(o.providerOptions,{type:`thinking block`,canCache:!1}),e.push({type:`thinking`,thinking:o.text,signature:t.signature}))}else n.push({type:`other`,message:`sending reasoning content is disabled for this model`});break;case`tool-call`:{if(o.providerExecuted){let t=i.toProviderToolName(o.toolName);if(o.providerOptions?.anthropic?.type===`mcp-tool-use`){a.add(o.toolCallId);let t=o.providerOptions?.anthropic?.serverName;if(t==null||typeof t!=`string`){n.push({type:`other`,message:`mcp tool use server name is required and must be a string`});break}e.push({type:`mcp_tool_use`,id:o.toolCallId,name:o.toolName,input:o.input,server_name:t,cache_control:f})}else if(t===`code_execution`&&o.input!=null&&typeof o.input==`object`&&`type`in o.input&&typeof o.input.type==`string`&&(o.input.type===`bash_code_execution`||o.input.type===`text_editor_code_execution`))e.push({type:`server_tool_use`,id:o.toolCallId,name:o.input.type,input:o.input,cache_control:f});else if(t===`code_execution`&&o.input!=null&&typeof o.input==`object`&&`type`in o.input&&o.input.type===`programmatic-tool-call`){let{type:t,...n}=o.input;e.push({type:`server_tool_use`,id:o.toolCallId,name:`code_execution`,input:n,cache_control:f})}else t===`code_execution`||t===`web_fetch`||t===`web_search`||t===`tool_search_tool_regex`||t===`tool_search_tool_bm25`?e.push({type:`server_tool_use`,id:o.toolCallId,name:t,input:o.input,cache_control:f}):t===`advisor`?e.push({type:`server_tool_use`,id:o.toolCallId,name:`advisor`,input:{},cache_control:f}):n.push({type:`other`,message:`provider executed tool call for tool ${o.toolName} is not supported`});break}let t=o.providerOptions?.anthropic,r=t?.caller?(t.caller.type===`code_execution_20250825`||t.caller.type===`code_execution_20260120`)&&t.caller.toolId?{type:t.caller.type,tool_id:t.caller.toolId}:t.caller.type===`direct`?{type:`direct`}:void 0:void 0;e.push({type:`tool_use`,id:o.toolCallId,name:o.toolName,input:o.input,...r&&{caller:r},cache_control:f});break}case`tool-result`:{let t=i.toProviderToolName(o.toolName);if(a.has(o.toolCallId)){let t=o.output;if(t.type!==`json`&&t.type!==`error-json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${o.toolName} is not supported`});break}e.push({type:`mcp_tool_result`,tool_use_id:o.toolCallId,is_error:t.type===`error-json`,content:t.value,cache_control:f})}else if(t===`code_execution`){let t=o.output;if(t.type===`error-text`||t.type===`error-json`){let n={};try{typeof t.value==`string`?n=E(t.value):typeof t.value==`object`&&t.value!==null&&(n=t.value)}catch{}n.type===`code_execution_tool_result_error`?e.push({type:`code_execution_tool_result`,tool_use_id:o.toolCallId,content:{type:`code_execution_tool_result_error`,error_code:n.errorCode??`unknown`},cache_control:f}):e.push({type:`bash_code_execution_tool_result`,tool_use_id:o.toolCallId,cache_control:f,content:{type:`bash_code_execution_tool_result_error`,error_code:n.errorCode??`unknown`}});break}if(t.type!==`json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${o.toolName} is not supported`});break}if(t.value==null||typeof t.value!=`object`||!(`type`in t.value)||typeof t.value.type!=`string`){n.push({type:`other`,message:`provider executed tool result output value is not a valid code execution result for tool ${o.toolName}`});break}if(t.value.type===`code_execution_result`){let n=await O({value:t.value,schema:Fe});e.push({type:`code_execution_tool_result`,tool_use_id:o.toolCallId,content:{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:f})}else if(t.value.type===`encrypted_code_execution_result`){let n=await O({value:t.value,schema:Ve});n.type===`encrypted_code_execution_result`&&e.push({type:`code_execution_tool_result`,tool_use_id:o.toolCallId,content:{type:n.type,encrypted_stdout:n.encrypted_stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:f})}else{let n=await O({value:t.value,schema:Re});n.type===`code_execution_result`?e.push({type:`code_execution_tool_result`,tool_use_id:o.toolCallId,content:{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:f}):n.type===`bash_code_execution_result`||n.type===`bash_code_execution_tool_result_error`?e.push({type:`bash_code_execution_tool_result`,tool_use_id:o.toolCallId,cache_control:f,content:n}):e.push({type:`text_editor_code_execution_tool_result`,tool_use_id:o.toolCallId,cache_control:f,content:n})}break}if(t===`web_fetch`){let t=o.output;if(t.type===`error-json`){e.push({type:`web_fetch_tool_result`,tool_use_id:o.toolCallId,content:{type:`web_fetch_tool_result_error`,error_code:Je(t.value).errorCode??`unavailable`},cache_control:f});break}if(t.type!==`json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${o.toolName} is not supported`});break}let r=await O({value:t.value,schema:Ae});e.push({type:`web_fetch_tool_result`,tool_use_id:o.toolCallId,content:{type:`web_fetch_result`,url:r.url,retrieved_at:r.retrievedAt,content:{type:`document`,title:r.content.title,citations:r.content.citations,source:{type:r.content.source.type,media_type:r.content.source.mediaType,data:r.content.source.data}}},cache_control:f});break}if(t===`web_search`){let t=o.output;if(t.type===`error-json`){e.push({type:`web_search_tool_result`,tool_use_id:o.toolCallId,content:{type:`web_search_tool_result_error`,error_code:Je(t.value).errorCode??`unavailable`},cache_control:f});break}if(t.type!==`json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${o.toolName} is not supported`});break}let r=await O({value:t.value,schema:Se});e.push({type:`web_search_tool_result`,tool_use_id:o.toolCallId,content:r.map(e=>({url:e.url,title:e.title,page_age:e.pageAge,encrypted_content:e.encryptedContent,type:e.type})),cache_control:f});break}if(t===`tool_search_tool_regex`||t===`tool_search_tool_bm25`){let t=o.output;if(t.type!==`json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${o.toolName} is not supported`});break}let r=(await O({value:t.value,schema:We})).map(e=>({type:`tool_reference`,tool_name:e.toolName}));e.push({type:`tool_search_tool_result`,tool_use_id:o.toolCallId,content:{type:`tool_search_tool_search_result`,tool_references:r},cache_control:f});break}if(t===`advisor`){let t=o.output;if(t.type!==`json`&&t.type!==`error-json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${o.toolName} is not supported`});break}let r=await O({value:t.value,schema:de});r.type===`advisor_result`?e.push({type:`advisor_tool_result`,tool_use_id:o.toolCallId,content:{type:`advisor_result`,text:r.text},cache_control:f}):r.type===`advisor_redacted_result`?e.push({type:`advisor_tool_result`,tool_use_id:o.toolCallId,content:{type:`advisor_redacted_result`,encrypted_content:r.encryptedContent},cache_control:f}):e.push({type:`advisor_tool_result`,tool_use_id:o.toolCallId,content:{type:`advisor_tool_result_error`,error_code:r.errorCode},cache_control:f});break}n.push({type:`other`,message:`provider executed tool result for tool ${o.toolName} is not supported`});break}}}}l.push({role:`assistant`,content:Ze(e)});break}default:throw Error(`content type: ${h}`)}}return{prompt:{system:c,messages:l},betas:a}}function Xe(e){let t=[],n;for(let r of e){let{role:e}=r;switch(e){case`system`:n?.type!==`system`&&(n={type:`system`,messages:[]},t.push(n)),n.messages.push(r);break;case`assistant`:n?.type!==`assistant`&&(n={type:`assistant`,messages:[]},t.push(n)),n.messages.push(r);break;case`user`:n?.type!==`user`&&(n={type:`user`,messages:[]},t.push(n)),n.messages.push(r);break;case`tool`:n?.type!==`user`&&(n={type:`user`,messages:[]},t.push(n)),n.messages.push(r);break;default:throw Error(`Unsupported role: ${e}`)}}return t}function Ze(e){let t=[],n=[];function r(){t.push(...n.filter(e=>e.type!==`tool_use`),...n.filter(e=>e.type===`tool_use`)),n=[]}for(let i of e)i.type===`thinking`||i.type===`redacted_thinking`?(r(),t.push(i)):n.push(i);return r(),t}function Qe({finishReason:e,isJsonResponseFromTool:t}){switch(e){case`pause_turn`:case`end_turn`:case`stop_sequence`:return`stop`;case`refusal`:return`content-filter`;case`tool_use`:return t?`stop`:`tool-calls`;case`max_tokens`:case`model_context_window_exceeded`:return`length`;case`compaction`:return`other`;default:return`other`}}var $e=new Set([`date-time`,`time`,`date`,`duration`,`email`,`hostname`,`uri`,`ipv4`,`ipv6`,`uuid`]),et=[`minimum`,`maximum`,`exclusiveMinimum`,`exclusiveMaximum`,`multipleOf`,`minLength`,`maxLength`,`pattern`,`minItems`,`maxItems`,`uniqueItems`,`minProperties`,`maxProperties`,`not`];function tt(e){return nt(e)}function $(e){return typeof e==`boolean`||!ot(e)?e:nt(e)}function nt(e){let t={},n=e;if(e.$ref!=null)return{$ref:e.$ref};if(e.$schema!=null&&(t.$schema=e.$schema),e.$id!=null&&(t.$id=e.$id),e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description),e.default!==void 0&&(t.default=e.default),e.const!==void 0&&(t.const=e.const),e.enum!=null&&(t.enum=e.enum),e.type!=null&&(t.type=e.type),e.anyOf==null?e.oneOf!=null&&(t.anyOf=e.oneOf.map($)):t.anyOf=e.anyOf.map($),e.allOf!=null&&(t.allOf=e.allOf.map($)),e.definitions!=null&&(t.definitions=Object.fromEntries(Object.entries(e.definitions).map(([e,t])=>[e,$(t)]))),n.$defs!=null){let e=t;e.$defs=Object.fromEntries(Object.entries(n.$defs).map(([e,t])=>[e,$(t)]))}(e.type===`object`||e.properties!=null)&&(e.properties!=null&&(t.properties=Object.fromEntries(Object.entries(e.properties).map(([e,t])=>[e,$(t)]))),t.additionalProperties=!1,e.required!=null&&(t.required=e.required)),e.items!=null&&(t.items=Array.isArray(e.items)?e.items.map($):$(e.items)),typeof e.format==`string`&&$e.has(e.format)&&(t.format=e.format);let r=rt(e);return r!=null&&(t.description=t.description==null?r:`${t.description}
2
+ ${r}`),t}function rt(e){let t=et.flatMap(t=>{let n=e[t];return n==null||n===!1?[]:`${it(t)}: ${at(n)}`});return typeof e.format==`string`&&!$e.has(e.format)&&t.push(`format: ${e.format}`),t.length===0?void 0:`${t.join(`; `)}.`}function it(e){return e.replace(/[A-Z]/g,e=>` ${e.toLowerCase()}`)}function at(e){return typeof e==`string`?e:JSON.stringify(e)}function ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function st(e,t,n){if(e.type===`web_search_result_location`)return{type:`source`,sourceType:`url`,id:n(),url:e.url,title:e.title,providerMetadata:{anthropic:{citedText:e.cited_text,encryptedIndex:e.encrypted_index}}};if(e.type!==`page_location`&&e.type!==`char_location`)return;let r=t[e.document_index];if(r)return{type:`source`,sourceType:`document`,id:n(),mediaType:r.mediaType,title:e.document_title??r.title,filename:r.filename,providerMetadata:{anthropic:e.type===`page_location`?{citedText:e.cited_text,startPageNumber:e.start_page_number,endPageNumber:e.end_page_number}:{citedText:e.cited_text,startCharIndex:e.start_char_index,endCharIndex:e.end_char_index}}}}var ct=class t{constructor(e,t){this.specificationVersion=`v4`,this.modelId=e,this.config=t,this.generateId=t.generateId??N}static[w](e){return I({modelId:e.modelId,config:e.config})}static[k](e){return new t(e.modelId,e.config)}supportsUrl(e){return e.protocol===`https:`}get provider(){return this.config.provider}get providerOptionsName(){let e=this.config.provider,t=e.indexOf(`.`);return t===-1?e:e.substring(0,t)}get supportedUrls(){var e;return(e=this.config).supportedUrls?.call(e)??{}}async getArgs({userSuppliedBetas:e,prompt:t,maxOutputTokens:n,temperature:r,topP:i,topK:a,frequencyPenalty:o,presencePenalty:c,stopSequences:l,responseFormat:u,seed:d,tools:f,toolChoice:p,reasoning:m,providerOptions:h,stream:g}){let v=[];o!=null&&v.push({type:`unsupported`,feature:`frequencyPenalty`}),c!=null&&v.push({type:`unsupported`,feature:`presencePenalty`}),d!=null&&v.push({type:`unsupported`,feature:`seed`}),r!=null&&r>1?(v.push({type:`unsupported`,feature:`temperature`,details:`${r} exceeds anthropic maximum of 1.0. clamped to 1.0`}),r=1):r!=null&&r<0&&(v.push({type:`unsupported`,feature:`temperature`,details:`${r} is below anthropic minimum of 0. clamped to 0`}),r=0),u?.type===`json`&&(u.schema??v.push({type:`unsupported`,feature:`responseFormat`,details:`JSON response format requires a schema. The response format is ignored.`}));let y=this.providerOptionsName,b=await S({provider:`anthropic`,providerOptions:h,schema:se}),x=y===`anthropic`?null:await S({provider:y,providerOptions:h,schema:se}),C=x!=null,w=Object.assign({},b??{},x??{}),{maxOutputTokens:T,supportsStructuredOutput:E,supportsAdaptiveThinking:D,rejectsSamplingParameters:O,supportsXhighEffort:k,isKnownModel:ee}=lt(this.modelId);O&&(r!=null&&(v.push({type:`unsupported`,feature:`temperature`,details:`temperature is not supported by ${this.modelId} and will be ignored`}),r=void 0),a!=null&&(v.push({type:`unsupported`,feature:`topK`,details:`topK is not supported by ${this.modelId} and will be ignored`}),a=void 0),i!=null&&(v.push({type:`unsupported`,feature:`topP`,details:`topP is not supported by ${this.modelId} and will be ignored`}),i=void 0));let A=ee||this.modelId.startsWith(`claude-`),M=(this.config.supportsNativeStructuredOutput??!0)&&E,N=(this.config.supportsStrictTools??!0)&&E,P=w?.structuredOutputMode??`auto`,F=P===`outputFormat`||P===`auto`&&M,I=u?.type===`json`&&u.schema!=null&&!F?{type:`function`,name:`json`,description:`Respond with a JSON object.`,inputSchema:u.schema}:void 0,L=w?.contextManagement,R=new Q,z=_({tools:f,providerToolNames:{"anthropic.code_execution_20250522":`code_execution`,"anthropic.code_execution_20250825":`code_execution`,"anthropic.code_execution_20260120":`code_execution`,"anthropic.computer_20241022":`computer`,"anthropic.computer_20250124":`computer`,"anthropic.text_editor_20241022":`str_replace_editor`,"anthropic.text_editor_20250124":`str_replace_editor`,"anthropic.text_editor_20250429":`str_replace_based_edit_tool`,"anthropic.text_editor_20250728":`str_replace_based_edit_tool`,"anthropic.bash_20241022":`bash`,"anthropic.bash_20250124":`bash`,"anthropic.memory_20250818":`memory`,"anthropic.web_search_20250305":`web_search`,"anthropic.web_search_20260209":`web_search`,"anthropic.web_fetch_20250910":`web_fetch`,"anthropic.web_fetch_20260209":`web_fetch`,"anthropic.tool_search_regex_20251119":`tool_search_tool_regex`,"anthropic.tool_search_bm25_20251119":`tool_search_tool_bm25`,"anthropic.advisor_20260301":`advisor`}}),{prompt:B,betas:V}=await Ye({prompt:t,sendReasoning:w?.sendReasoning??!0,warnings:v,cacheControlValidator:R,toolNameMapping:z});if(s(m)&&w?.effort==null){let e=dt({reasoning:m,supportsAdaptiveThinking:D,supportsXhighEffort:k,maxOutputTokensForModel:T,warnings:v});e!=null&&(w.thinking??=e.thinking,e.effort!=null&&w.thinking?.type!==`disabled`&&(w.effort=e.effort))}let H=w?.thinking?.type,U=H===`enabled`||H===`adaptive`,W=H===`enabled`?w?.thinking?.budgetTokens:void 0,G=H===`adaptive`?w?.thinking?.display:void 0,K=n??T,q={model:this.modelId,max_tokens:K,temperature:r,top_k:a,top_p:i,stop_sequences:l,...U&&{thinking:{type:H,...W!=null&&{budget_tokens:W},...G!=null&&{display:G}}},...(w?.effort||w?.taskBudget||F&&u?.type===`json`&&u.schema!=null)&&{output_config:{...w?.effort&&{effort:w.effort},...w?.taskBudget&&{task_budget:{type:w.taskBudget.type,total:w.taskBudget.total,...w.taskBudget.remaining!=null&&{remaining:w.taskBudget.remaining}}},...F&&u?.type===`json`&&u.schema!=null&&{format:{type:`json_schema`,schema:tt(u.schema)}}}},...w?.speed&&{speed:w.speed},...w?.inferenceGeo&&{inference_geo:w.inferenceGeo},...w?.fallbacks&&w.fallbacks.length>0&&{fallbacks:w.fallbacks},...w?.cacheControl&&{cache_control:w.cacheControl},...w?.metadata?.userId!=null&&{metadata:{user_id:w.metadata.userId}},...w?.mcpServers&&w.mcpServers.length>0&&{mcp_servers:w.mcpServers.map(e=>({type:e.type,name:e.name,url:e.url,authorization_token:e.authorizationToken,tool_configuration:e.toolConfiguration?{allowed_tools:e.toolConfiguration.allowedTools,enabled:e.toolConfiguration.enabled}:void 0}))},...w?.container&&{container:w.container.skills&&w.container.skills.length>0?{id:w.container.id,skills:w.container.skills.map(e=>({type:e.type,skill_id:e.type===`custom`?j({reference:e.providerReference,provider:`anthropic`}):e.skillId,version:e.version}))}:w.container.id},system:B.system,messages:B.messages,...L&&{context_management:{edits:L.edits.map(e=>{let t=e.type;switch(t){case`clear_tool_uses_20250919`:return{type:e.type,...e.trigger!==void 0&&{trigger:e.trigger},...e.keep!==void 0&&{keep:e.keep},...e.clearAtLeast!==void 0&&{clear_at_least:e.clearAtLeast},...e.clearToolInputs!==void 0&&{clear_tool_inputs:e.clearToolInputs},...e.excludeTools!==void 0&&{exclude_tools:e.excludeTools}};case`clear_thinking_20251015`:return{type:e.type,...e.keep!==void 0&&{keep:e.keep}};case`compact_20260112`:return{type:e.type,...e.trigger!==void 0&&{trigger:e.trigger},...e.pauseAfterCompaction!==void 0&&{pause_after_compaction:e.pauseAfterCompaction},...e.instructions!==void 0&&{instructions:e.instructions}};default:v.push({type:`other`,message:`Unknown context management strategy: ${t}`});return}}).filter(e=>e!==void 0)}}};U?(H===`enabled`&&W==null&&(v.push({type:`compatibility`,feature:`extended thinking`,details:`thinking budget is required when thinking is enabled. using default budget of 1024 tokens.`}),q.thinking={type:`enabled`,budget_tokens:1024},W=1024),q.temperature!=null&&(q.temperature=void 0,v.push({type:`unsupported`,feature:`temperature`,details:`temperature is not supported when thinking is enabled`})),a!=null&&(q.top_k=void 0,v.push({type:`unsupported`,feature:`topK`,details:`topK is not supported when thinking is enabled`})),i!=null&&(q.top_p=void 0,v.push({type:`unsupported`,feature:`topP`,details:`topP is not supported when thinking is enabled`})),q.max_tokens=K+(W??0)):A&&i!=null&&r!=null&&(v.push({type:`unsupported`,feature:`topP`,details:`topP is not supported when temperature is set. topP is ignored.`}),q.top_p=void 0),ee&&q.max_tokens>T&&(n!=null&&v.push({type:`unsupported`,feature:`maxOutputTokens`,details:`${q.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${T} max output tokens. The max output tokens have been limited to ${T}.`}),q.max_tokens=T),w?.mcpServers&&w.mcpServers.length>0&&V.add(`mcp-client-2025-04-04`),L&&(V.add(`context-management-2025-06-27`),L.edits.some(e=>e.type===`compact_20260112`)&&V.add(`compact-2026-01-12`)),w?.container&&w.container.skills&&w.container.skills.length>0&&(V.add(`code-execution-2025-08-25`),V.add(`skills-2025-10-02`),V.add(`files-api-2025-04-14`),f?.some(e=>e.type===`provider`&&(e.id===`anthropic.code_execution_20250825`||e.id===`anthropic.code_execution_20260120`))||v.push({type:`other`,message:`code execution tool is required when using skills`})),w?.taskBudget&&V.add(`task-budgets-2026-03-13`),w?.speed===`fast`&&V.add(`fast-mode-2026-02-01`),w?.fallbacks&&w.fallbacks.length>0&&V.add(`server-side-fallback-2026-06-01`);let J=g&&(w?.toolStreaming??!0),{tools:te,toolChoice:Y,toolWarnings:ne,betas:re}=await Ne(I==null?{tools:f??[],toolChoice:p,disableParallelToolUse:w?.disableParallelToolUse,cacheControlValidator:R,supportsStructuredOutput:M,supportsStrictTools:N,defaultEagerInputStreaming:J}:{tools:[...f??[],I],toolChoice:{type:`required`},disableParallelToolUse:!0,cacheControlValidator:R,supportsStructuredOutput:!1,supportsStrictTools:N,defaultEagerInputStreaming:J}),X=R.getWarnings();return{args:{...q,tools:te,tool_choice:Y,stream:g===!0||void 0},warnings:[...v,...ne,...X],betas:new Set([...V,...re,...e,...w?.anthropicBeta??[]]),usesJsonResponseTool:I!=null,toolNameMapping:z,providerOptionsName:y,usedCustomProviderKey:C}}async getHeaders({betas:e,headers:t}){return T(this.config.headers?await R(this.config.headers):void 0,t,e.size>0?{"anthropic-beta":Array.from(e).join(`,`)}:{})}async getBetasFromHeaders(e){let t=(this.config.headers?await R(this.config.headers):void 0)?.[`anthropic-beta`]??``,n=e?.[`anthropic-beta`]??``;return new Set([...t.toLowerCase().split(`,`),...n.toLowerCase().split(`,`)].map(e=>e.trim()).filter(e=>e!==``))}buildRequestUrl(e){var t;return(t=this.config).buildRequestUrl?.call(t,this.config.baseURL,e)??`${this.config.baseURL}/messages`}transformRequestBody(e,t){var n;return(n=this.config).transformRequestBody?.call(n,e,t)??e}extractCitationDocuments(e){return e.filter(e=>e.role===`user`).flatMap(e=>e.content).filter(e=>e.type!==`file`||e.mediaType!==`application/pdf`&&e.mediaType!==`text/plain`?!1:e.providerOptions?.anthropic?.citations?.enabled??!1).map(e=>{let t=e;return{title:t.filename??`Untitled Document`,filename:t.filename,mediaType:t.mediaType}})}async doGenerate(t){let{args:n,warnings:r,betas:i,usesJsonResponseTool:a,toolNameMapping:o,providerOptionsName:s,usedCustomProviderKey:c}=await this.getArgs({...t,stream:!1,userSuppliedBetas:await this.getBetasFromHeaders(t.headers)}),l=[...this.extractCitationDocuments(t.prompt)],u=ut(n.tools),{responseHeaders:d,value:f,rawValue:p}=await e({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:i,headers:t.headers}),body:this.transformRequestBody(n,i),failedResponseHandler:Y,successfulResponseHandler:W(ie),abortSignal:t.abortSignal,fetch:this.config.fetch}),m=[],h={},g={},_=!1;for(let e of f.content)switch(e.type){case`text`:if(!a&&(m.push({type:`text`,text:e.text}),e.citations))for(let t of e.citations){let e=st(t,l,this.generateId);e&&m.push(e)}break;case`thinking`:m.push({type:`reasoning`,text:e.thinking,providerMetadata:{anthropic:{signature:e.signature}}});break;case`redacted_thinking`:m.push({type:`reasoning`,text:``,providerMetadata:{anthropic:{redactedData:e.data}}});break;case`compaction`:m.push({type:`text`,text:e.content,providerMetadata:{anthropic:{type:`compaction`}}});break;case`tool_use`:if(a&&e.name===`json`)_=!0,m.push({type:`text`,text:JSON.stringify(e.input)});else{let t=e.caller,n=t?{type:t.type,toolId:`tool_id`in t?t.tool_id:void 0}:void 0;m.push({type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),...n&&{providerMetadata:{anthropic:{caller:n}}}})}break;case`server_tool_use`:if(e.name===`text_editor_code_execution`||e.name===`bash_code_execution`)m.push({type:`tool-call`,toolCallId:e.id,toolName:o.toCustomToolName(`code_execution`),input:JSON.stringify({type:e.name,...e.input}),providerExecuted:!0,...u?{dynamic:!0}:{}});else if(e.name===`web_search`||e.name===`code_execution`||e.name===`web_fetch`){let t=e.name===`code_execution`&&e.input!=null&&typeof e.input==`object`&&`code`in e.input&&!(`type`in e.input)?{type:`programmatic-tool-call`,...e.input}:e.input;m.push({type:`tool-call`,toolCallId:e.id,toolName:o.toCustomToolName(e.name),input:JSON.stringify(t),providerExecuted:!0,...u&&e.name===`code_execution`?{dynamic:!0}:{}})}else e.name===`tool_search_tool_regex`||e.name===`tool_search_tool_bm25`?(g[e.id]=e.name,m.push({type:`tool-call`,toolCallId:e.id,toolName:o.toCustomToolName(e.name),input:JSON.stringify(e.input),providerExecuted:!0})):e.name===`advisor`&&m.push({type:`tool-call`,toolCallId:e.id,toolName:o.toCustomToolName(`advisor`),input:JSON.stringify(e.input),providerExecuted:!0});break;case`mcp_tool_use`:h[e.id]={type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:`mcp-tool-use`,serverName:e.server_name}}},m.push(h[e.id]);break;case`mcp_tool_result`:m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:h[e.tool_use_id].toolName,isError:e.is_error,result:e.content,dynamic:!0,providerMetadata:h[e.tool_use_id].providerMetadata});break;case`web_fetch_tool_result`:e.content.type===`web_fetch_result`?(l.push({title:e.content.content.title??e.content.url,mediaType:e.content.content.source.media_type}),m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`web_fetch`),result:{type:`web_fetch_result`,url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}}})):e.content.type===`web_fetch_tool_result_error`&&m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`web_fetch`),isError:!0,result:{type:`web_fetch_tool_result_error`,errorCode:e.content.error_code}});break;case`web_search_tool_result`:if(Array.isArray(e.content)){m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`web_search`),result:e.content.map(e=>({url:e.url,title:e.title,pageAge:e.page_age??null,encryptedContent:e.encrypted_content,type:e.type}))});for(let t of e.content)m.push({type:`source`,sourceType:`url`,id:this.generateId(),url:t.url,title:t.title,providerMetadata:{anthropic:{pageAge:t.page_age??null}}})}else m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`web_search`),isError:!0,result:{type:`web_search_tool_result_error`,errorCode:e.content.error_code}});break;case`code_execution_tool_result`:e.content.type===`code_execution_result`?m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`code_execution`),result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):e.content.type===`encrypted_code_execution_result`?m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`code_execution`),result:{type:e.content.type,encrypted_stdout:e.content.encrypted_stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):e.content.type===`code_execution_tool_result_error`&&m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`code_execution`),isError:!0,result:{type:`code_execution_tool_result_error`,errorCode:e.content.error_code}});break;case`bash_code_execution_tool_result`:case`text_editor_code_execution_tool_result`:m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`code_execution`),result:e.content});break;case`tool_search_tool_result`:{let t=g[e.tool_use_id];if(t==null){let e=o.toCustomToolName(`tool_search_tool_bm25`);o.toCustomToolName(`tool_search_tool_regex`),t=e===`tool_search_tool_bm25`?`tool_search_tool_regex`:`tool_search_tool_bm25`}e.content.type===`tool_search_tool_search_result`?m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(t),result:e.content.tool_references.map(e=>({type:e.type,toolName:e.tool_name}))}):m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(t),isError:!0,result:{type:`tool_search_tool_result_error`,errorCode:e.content.error_code}});break}case`advisor_tool_result`:{let t=o.toCustomToolName(`advisor`);e.content.type===`advisor_result`?m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,result:{type:`advisor_result`,text:e.content.text}}):e.content.type===`advisor_redacted_result`?m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,result:{type:`advisor_redacted_result`,encryptedContent:e.content.encrypted_content}}):m.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,isError:!0,result:{type:`advisor_tool_result_error`,errorCode:e.content.error_code}});break}case`fallback`:break}return{content:m,finishReason:{unified:Qe({finishReason:f.stop_reason,isJsonResponseFromTool:_}),raw:f.stop_reason??void 0},usage:Pe({usage:f.usage}),request:{body:n},response:{id:f.id??void 0,modelId:f.model??void 0,headers:d,body:p},warnings:r,providerMetadata:(()=>{let e=pt(f.stop_details),t={usage:f.usage,stopSequence:f.stop_sequence??null,...e==null?{}:{stopDetails:e},iterations:f.usage.iterations?f.usage.iterations.map(e=>({type:e.type,...e.model==null?{}:{model:e.model},inputTokens:e.input_tokens,outputTokens:e.output_tokens,...e.cache_creation_input_tokens?{cacheCreationInputTokens:e.cache_creation_input_tokens}:{},...e.cache_read_input_tokens?{cacheReadInputTokens:e.cache_read_input_tokens}:{}})):null,container:f.container?{expiresAt:f.container.expires_at,id:f.container.id,skills:f.container.skills?.map(e=>({type:e.type,skillId:e.skill_id,version:e.version}))??null}:null,contextManagement:ft(f.context_management)??null},n={anthropic:t};return c&&s!==`anthropic`&&(n[s]=t),n})()}}async doStream(t){"use step";let{args:n,warnings:r,betas:i,usesJsonResponseTool:a,toolNameMapping:o,providerOptionsName:s,usedCustomProviderKey:c}=await this.getArgs({...t,stream:!0,userSuppliedBetas:await this.getBetasFromHeaders(t.headers)}),l=[...this.extractCitationDocuments(t.prompt)],u=ut(n.tools),d=this.buildRequestUrl(!0),{responseHeaders:f,value:p}=await e({url:d,headers:await this.getHeaders({betas:i,headers:t.headers}),body:this.transformRequestBody(n,i),failedResponseHandler:Y,successfulResponseHandler:ee(ae),abortSignal:t.abortSignal,fetch:this.config.fetch}),m={unified:`other`,raw:void 0},h={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,iterations:null},g={},_={},v={},b=null,x,S=null,C,w=null,T=!1,D,O=this.generateId,[k,A]=p.pipeThrough(new TransformStream({start(e){e.enqueue({type:`stream-start`,warnings:r})},transform(e,n){if(t.includeRawChunks&&n.enqueue({type:`raw`,rawValue:e.rawValue}),!e.success){n.enqueue({type:`error`,error:e.error});return}let r=e.value;switch(r.type){case`ping`:return;case`content_block_start`:{let e=r.content_block,t=e.type;if(t===`fallback`)return;switch(D=t,t){case`text`:if(a)return;g[r.index]={type:`text`},n.enqueue({type:`text-start`,id:String(r.index)});return;case`thinking`:g[r.index]={type:`reasoning`},n.enqueue({type:`reasoning-start`,id:String(r.index)});return;case`redacted_thinking`:g[r.index]={type:`reasoning`},n.enqueue({type:`reasoning-start`,id:String(r.index),providerMetadata:{anthropic:{redactedData:e.data}}});return;case`compaction`:g[r.index]={type:`text`},n.enqueue({type:`text-start`,id:String(r.index),providerMetadata:{anthropic:{type:`compaction`}}});return;case`tool_use`:if(a&&e.name===`json`)T=!0,g[r.index]={type:`text`},n.enqueue({type:`text-start`,id:String(r.index)});else{let t=e.caller,i=t?{type:t.type,toolId:`tool_id`in t?t.tool_id:void 0}:void 0,a=e.input&&Object.keys(e.input).length>0?JSON.stringify(e.input):``;g[r.index]={type:`tool-call`,toolCallId:e.id,toolName:e.name,input:a,firstDelta:a.length===0,...i&&{caller:i}},n.enqueue({type:`tool-input-start`,id:e.id,toolName:e.name})}return;case`server_tool_use`:if([`web_fetch`,`web_search`,`code_execution`,`text_editor_code_execution`,`bash_code_execution`].includes(e.name)){let t=e.name===`text_editor_code_execution`||e.name===`bash_code_execution`?`code_execution`:e.name,i=e.name===`text_editor_code_execution`||e.name===`bash_code_execution`?e.name:e.name===`code_execution`?`programmatic-tool-call`:void 0,a=o.toCustomToolName(t),s=e.input!=null&&typeof e.input==`object`&&Object.keys(e.input).length>0?JSON.stringify(e.input):``;g[r.index]={type:`tool-call`,toolCallId:e.id,toolName:a,input:s,providerExecuted:!0,...u&&t===`code_execution`?{dynamic:!0}:{},firstDelta:s.length===0,providerToolName:t,providerToolInputType:i},n.enqueue({type:`tool-input-start`,id:e.id,toolName:a,providerExecuted:!0,...u&&t===`code_execution`?{dynamic:!0}:{}})}else if(e.name===`tool_search_tool_regex`||e.name===`tool_search_tool_bm25`){v[e.id]=e.name;let t=o.toCustomToolName(e.name);g[r.index]={type:`tool-call`,toolCallId:e.id,toolName:t,input:``,providerExecuted:!0,firstDelta:!0,providerToolName:e.name},n.enqueue({type:`tool-input-start`,id:e.id,toolName:t,providerExecuted:!0})}else if(e.name===`advisor`){let t=o.toCustomToolName(`advisor`);g[r.index]={type:`tool-call`,toolCallId:e.id,toolName:t,input:`{}`,providerExecuted:!0,firstDelta:!0,providerToolName:e.name},n.enqueue({type:`tool-input-start`,id:e.id,toolName:t,providerExecuted:!0})}return;case`web_fetch_tool_result`:e.content.type===`web_fetch_result`?(l.push({title:e.content.content.title??e.content.url,mediaType:e.content.content.source.media_type}),n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`web_fetch`),result:{type:`web_fetch_result`,url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}}})):e.content.type===`web_fetch_tool_result_error`&&n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`web_fetch`),isError:!0,result:{type:`web_fetch_tool_result_error`,errorCode:e.content.error_code}});return;case`web_search_tool_result`:if(Array.isArray(e.content)){n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`web_search`),result:e.content.map(e=>({url:e.url,title:e.title,pageAge:e.page_age??null,encryptedContent:e.encrypted_content,type:e.type}))});for(let t of e.content)n.enqueue({type:`source`,sourceType:`url`,id:O(),url:t.url,title:t.title,providerMetadata:{anthropic:{pageAge:t.page_age??null}}})}else n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`web_search`),isError:!0,result:{type:`web_search_tool_result_error`,errorCode:e.content.error_code}});return;case`code_execution_tool_result`:e.content.type===`code_execution_result`?n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`code_execution`),result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):e.content.type===`encrypted_code_execution_result`?n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`code_execution`),result:{type:e.content.type,encrypted_stdout:e.content.encrypted_stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):e.content.type===`code_execution_tool_result_error`&&n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`code_execution`),isError:!0,result:{type:`code_execution_tool_result_error`,errorCode:e.content.error_code}});return;case`bash_code_execution_tool_result`:case`text_editor_code_execution_tool_result`:n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(`code_execution`),result:e.content});return;case`tool_search_tool_result`:{let t=v[e.tool_use_id];if(t==null){let e=o.toCustomToolName(`tool_search_tool_bm25`);o.toCustomToolName(`tool_search_tool_regex`),t=e===`tool_search_tool_bm25`?`tool_search_tool_regex`:`tool_search_tool_bm25`}e.content.type===`tool_search_tool_search_result`?n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(t),result:e.content.tool_references.map(e=>({type:e.type,toolName:e.tool_name}))}):n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:o.toCustomToolName(t),isError:!0,result:{type:`tool_search_tool_result_error`,errorCode:e.content.error_code}});return}case`advisor_tool_result`:{let t=o.toCustomToolName(`advisor`);e.content.type===`advisor_result`?n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,result:{type:`advisor_result`,text:e.content.text}}):e.content.type===`advisor_redacted_result`?n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,result:{type:`advisor_redacted_result`,encryptedContent:e.content.encrypted_content}}):n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,isError:!0,result:{type:`advisor_tool_result_error`,errorCode:e.content.error_code}});return}case`mcp_tool_use`:_[e.id]={type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:`mcp-tool-use`,serverName:e.server_name}}},n.enqueue(_[e.id]);return;case`mcp_tool_result`:n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:_[e.tool_use_id].toolName,isError:e.is_error,result:e.content,dynamic:!0,providerMetadata:_[e.tool_use_id].providerMetadata});return;default:throw Error(`Unsupported content block type: ${t}`)}}case`content_block_stop`:if(g[r.index]!=null){let e=g[r.index];switch(e.type){case`text`:n.enqueue({type:`text-end`,id:String(r.index)});break;case`reasoning`:n.enqueue({type:`reasoning-end`,id:String(r.index)});break;case`tool-call`:if(!(a&&e.toolName===`json`)){n.enqueue({type:`tool-input-end`,id:e.toolCallId});let t=e.input===``?`{}`:e.input;if(e.providerToolName===`code_execution`)try{let e=E(t);typeof e==`object`&&e&&`code`in e&&!(`type`in e)&&(t=JSON.stringify({type:`programmatic-tool-call`,...e}))}catch{}n.enqueue({type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:t,providerExecuted:e.providerExecuted,...u&&e.providerToolName===`code_execution`?{dynamic:!0}:{},...e.caller&&{providerMetadata:{anthropic:{caller:e.caller}}}})}break}delete g[r.index]}D=void 0;return;case`content_block_delta`:{let e=r.delta.type;switch(e){case`text_delta`:if(a)return;n.enqueue({type:`text-delta`,id:String(r.index),delta:r.delta.text});return;case`thinking_delta`:n.enqueue({type:`reasoning-delta`,id:String(r.index),delta:r.delta.thinking});return;case`signature_delta`:D===`thinking`&&n.enqueue({type:`reasoning-delta`,id:String(r.index),delta:``,providerMetadata:{anthropic:{signature:r.delta.signature}}});return;case`compaction_delta`:r.delta.content!=null&&n.enqueue({type:`text-delta`,id:String(r.index),delta:r.delta.content});return;case`input_json_delta`:{let e=g[r.index],t=r.delta.partial_json;if(t.length===0)return;if(T){if(e?.type!==`text`)return;n.enqueue({type:`text-delta`,id:String(r.index),delta:t})}else{if(e?.type!==`tool-call`)return;e.firstDelta&&e.providerToolInputType!=null&&(t=`{"type": "${e.providerToolInputType}",${t.substring(1)}`),n.enqueue({type:`tool-input-delta`,id:e.toolCallId,delta:t}),e.input+=t,e.firstDelta=!1}return}case`citations_delta`:{let e=r.delta.citation,t=st(e,l,O);t&&n.enqueue(t);return}default:throw Error(`Unsupported delta type: ${e}`)}}case`message_start`:if(h.input_tokens=r.message.usage.input_tokens,h.cache_read_input_tokens=r.message.usage.cache_read_input_tokens??0,h.cache_creation_input_tokens=r.message.usage.cache_creation_input_tokens??0,x={...r.message.usage},r.message.container!=null&&(w={expiresAt:r.message.container.expires_at,id:r.message.container.id,skills:null}),r.message.stop_reason!=null&&(m={unified:Qe({finishReason:r.message.stop_reason,isJsonResponseFromTool:T}),raw:r.message.stop_reason}),n.enqueue({type:`response-metadata`,id:r.message.id??void 0,modelId:r.message.model??void 0}),r.message.content!=null)for(let e=0;e<r.message.content.length;e++){let t=r.message.content[e];if(t.type===`tool_use`){let e=t.caller,r=e?{type:e.type,toolId:`tool_id`in e?e.tool_id:void 0}:void 0;n.enqueue({type:`tool-input-start`,id:t.id,toolName:t.name});let i=JSON.stringify(t.input??{});n.enqueue({type:`tool-input-delta`,id:t.id,delta:i}),n.enqueue({type:`tool-input-end`,id:t.id}),n.enqueue({type:`tool-call`,toolCallId:t.id,toolName:t.name,input:i,...r&&{providerMetadata:{anthropic:{caller:r}}}})}}return;case`message_delta`:r.usage.input_tokens!=null&&h.input_tokens!==r.usage.input_tokens&&(h.input_tokens=r.usage.input_tokens),h.output_tokens=r.usage.output_tokens,r.usage.cache_read_input_tokens!=null&&(h.cache_read_input_tokens=r.usage.cache_read_input_tokens),r.usage.cache_creation_input_tokens!=null&&(h.cache_creation_input_tokens=r.usage.cache_creation_input_tokens),r.usage.iterations!=null&&(h.iterations=r.usage.iterations),m={unified:Qe({finishReason:r.delta.stop_reason,isJsonResponseFromTool:T}),raw:r.delta.stop_reason??void 0},S=r.delta.stop_sequence??null,C=pt(r.delta.stop_details),w=r.delta.container==null?null:{expiresAt:r.delta.container.expires_at,id:r.delta.container.id,skills:r.delta.container.skills?.map(e=>({type:e.type,skillId:e.skill_id,version:e.version}))??null},r.context_management&&(b=ft(r.context_management)),x={...x,...r.usage};return;case`message_stop`:{let e={usage:x??null,stopSequence:S,...C==null?{}:{stopDetails:C},iterations:h.iterations?h.iterations.map(e=>({type:e.type,...e.model==null?{}:{model:e.model},inputTokens:e.input_tokens,outputTokens:e.output_tokens,...e.cache_creation_input_tokens?{cacheCreationInputTokens:e.cache_creation_input_tokens}:{},...e.cache_read_input_tokens?{cacheReadInputTokens:e.cache_read_input_tokens}:{}})):null,container:w,contextManagement:b},t={anthropic:e};c&&s!==`anthropic`&&(t[s]=e),n.enqueue({type:`finish`,finishReason:m,usage:Pe({usage:h,rawUsage:x}),providerMetadata:t});return}case`error`:n.enqueue({type:`error`,error:r.error});return;default:throw Error(`Unsupported chunk type: ${r}`)}}})).tee(),j=k.getReader();try{await j.read();let e=await j.read();if(e.value?.type===`raw`&&(e=await j.read()),e.value?.type===`error`){let t=e.value.error;throw new y({message:t.message,url:d,requestBodyValues:n,statusCode:t.type===`overloaded_error`?529:500,responseHeaders:f,responseBody:JSON.stringify(t),isRetryable:t.type===`overloaded_error`})}}finally{j.cancel().catch(()=>{}),j.releaseLock()}return{stream:A,request:{body:n},response:{headers:f}}}};function lt(e){return e.includes(`claude-opus-4-8`)||e.includes(`claude-opus-4-7`)||e.includes(`claude-fable-5`)||e.includes(`claude-sonnet-5`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,isKnownModel:!0}:e.includes(`claude-sonnet-4-6`)||e.includes(`claude-opus-4-6`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!1,supportsXhighEffort:!1,isKnownModel:!0}:e.includes(`claude-sonnet-4-5`)||e.includes(`claude-opus-4-5`)||e.includes(`claude-haiku-4-5`)?{maxOutputTokens:64e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,isKnownModel:!0}:e.includes(`claude-opus-4-1`)?{maxOutputTokens:32e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,isKnownModel:!0}:e.includes(`claude-sonnet-4-`)?{maxOutputTokens:64e3,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,isKnownModel:!0}:e.includes(`claude-opus-4-`)?{maxOutputTokens:32e3,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,isKnownModel:!0}:e.includes(`claude-3-haiku`)?{maxOutputTokens:4096,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,isKnownModel:!0}:{maxOutputTokens:4096,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,isKnownModel:!1}}function ut(e){if(!e)return!1;let t=!1,n=!1;for(let r of e){if(`type`in r&&(r.type===`web_fetch_20260209`||r.type===`web_search_20260209`)){t=!0;continue}if(r.name===`code_execution`){n=!0;break}}return t&&!n}function dt({reasoning:e,supportsAdaptiveThinking:t,supportsXhighEffort:n,maxOutputTokensForModel:r,warnings:i}){if(!s(e))return;if(e===`none`)return{thinking:{type:`disabled`}};if(t)return{thinking:{type:`adaptive`},effort:B({reasoning:e,effortMap:{minimal:`low`,low:`low`,medium:`medium`,high:`high`,xhigh:n?`xhigh`:`max`},warnings:i})};let a=l({reasoning:e,maxOutputTokens:r,maxReasoningBudget:r,warnings:i});if(a!=null)return{thinking:{type:`enabled`,budgetTokens:a}}}function ft(e){return e?{appliedEdits:e.applied_edits.map(e=>{switch(e.type){case`clear_tool_uses_20250919`:return{type:e.type,clearedToolUses:e.cleared_tool_uses,clearedInputTokens:e.cleared_input_tokens};case`clear_thinking_20251015`:return{type:e.type,clearedThinkingTurns:e.cleared_thinking_turns,clearedInputTokens:e.cleared_input_tokens};case`compact_20260112`:return{type:e.type}}}).filter(e=>e!==void 0)}:null}function pt(e){if(e!=null)return{type:e.type,...e.category==null?{}:{category:e.category},...e.explanation==null?{}:{explanation:e.explanation},...e.recommended_model==null?{}:{recommendedModel:e.recommended_model}}}var mt=q({id:`anthropic.bash_20241022`,inputSchema:v(()=>A(f({command:i(),restart:G().optional()})))});function ht(e={}){let{execute:t,...n}=e;return mt(t===void 0?{...n,execute:async({command:e},{abortSignal:t,experimental_sandbox:n})=>{if(!n)throw Error(`Sandbox session is not available`);return await n.run({command:e,abortSignal:t})}}:{...n,...t===null?{}:{execute:t}})}var gt=q({id:`anthropic.bash_20250124`,inputSchema:v(()=>A(f({command:i(),restart:G().optional()})))});function _t(e={}){let{execute:t,...n}=e;return gt(t===void 0?{...n,execute:async({command:e},{abortSignal:t,experimental_sandbox:n})=>{if(!n)throw Error(`Sandbox session is not available`);return await n.run({command:e,abortSignal:t})}}:{...n,...t===null?{}:{execute:t}})}var vt=q({id:`anthropic.computer_20241022`,inputSchema:v(()=>A(f({action:J([`key`,`type`,`mouse_move`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`screenshot`,`cursor_position`]),coordinate:n(M().int()).optional(),text:i().optional()})))}),yt=q({id:`anthropic.computer_20250124`,inputSchema:v(()=>A(f({action:J([`key`,`hold_key`,`type`,`cursor_position`,`mouse_move`,`left_mouse_down`,`left_mouse_up`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`triple_click`,`scroll`,`wait`,`screenshot`]),coordinate:c([M().int(),M().int()]).optional(),duration:M().optional(),scroll_amount:M().optional(),scroll_direction:J([`up`,`down`,`left`,`right`]).optional(),start_coordinate:c([M().int(),M().int()]).optional(),text:i().optional()})))}),bt=q({id:`anthropic.computer_20251124`,inputSchema:v(()=>A(f({action:J([`key`,`hold_key`,`type`,`cursor_position`,`mouse_move`,`left_mouse_down`,`left_mouse_up`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`triple_click`,`scroll`,`wait`,`screenshot`,`zoom`]),coordinate:c([M().int(),M().int()]).optional(),duration:M().optional(),region:c([M().int(),M().int(),M().int(),M().int()]).optional(),scroll_amount:M().optional(),scroll_direction:J([`up`,`down`,`left`,`right`]).optional(),start_coordinate:c([M().int(),M().int()]).optional(),text:i().optional()})))}),xt=q({id:`anthropic.memory_20250818`,inputSchema:v(()=>A(r(`command`,[f({command:m(`view`),path:i(),view_range:c([M(),M()]).optional()}),f({command:m(`create`),path:i(),file_text:i()}),f({command:m(`str_replace`),path:i(),old_str:i(),new_str:i()}),f({command:m(`insert`),path:i(),insert_line:M(),insert_text:i()}),f({command:m(`delete`),path:i()}),f({command:m(`rename`),old_path:i(),new_path:i()})])))}),St=q({id:`anthropic.text_editor_20241022`,inputSchema:v(()=>A(f({command:J([`view`,`create`,`str_replace`,`insert`,`undo_edit`]),path:i(),file_text:i().optional(),insert_line:M().int().optional(),new_str:i().optional(),insert_text:i().optional(),old_str:i().optional(),view_range:n(M().int()).optional()})))}),Ct=q({id:`anthropic.text_editor_20250124`,inputSchema:v(()=>A(f({command:J([`view`,`create`,`str_replace`,`insert`,`undo_edit`]),path:i(),file_text:i().optional(),insert_line:M().int().optional(),new_str:i().optional(),insert_text:i().optional(),old_str:i().optional(),view_range:n(M().int()).optional()})))}),wt=q({id:`anthropic.text_editor_20250429`,inputSchema:v(()=>A(f({command:J([`view`,`create`,`str_replace`,`insert`]),path:i(),file_text:i().optional(),insert_line:M().int().optional(),new_str:i().optional(),insert_text:i().optional(),old_str:i().optional(),view_range:n(M().int()).optional()})))}),Tt=v(()=>A(n(f({type:m(`tool_reference`),toolName:i()})))),Et=K({id:`anthropic.tool_search_bm25_20251119`,inputSchema:v(()=>A(f({query:i(),limit:M().optional()}))),outputSchema:Tt,supportsDeferredResults:!0}),Dt={advisor_20260301:pe,bash_20241022:ht,bash_20250124:_t,codeExecution_20250522:Le,codeExecution_20250825:Be,codeExecution_20260120:Ue,computer_20241022:vt,computer_20250124:yt,computer_20251124:bt,memory_20250818:xt,textEditor_20241022:St,textEditor_20250124:Ct,textEditor_20250429:wt,textEditor_20250728:ge,webFetch_20250910:Me,webFetch_20260209:Oe,webSearch_20250305:we,webSearch_20260209:be,toolSearchRegex_20251119:Ke,toolSearchBm25_20251119:(e={})=>Et(e)},Ot=v(()=>A(f({id:i(),display_title:i().nullish(),name:i().nullish(),description:i().nullish(),latest_version:i().nullish(),source:i(),created_at:i(),updated_at:i()})));v(()=>A(f({data:n(f({version:i()}))})));var kt=v(()=>A(f({type:i(),skill_id:i(),name:i().nullish(),description:i().nullish()}))),At=class{constructor(e){this.config=e,this.specificationVersion=`v4`}get provider(){return this.config.provider}async getHeaders(){return T(await R(this.config.headers),{"anthropic-beta":`skills-2025-10-02`})}async fetchVersionMetadata({skillId:e,version:n,headers:r}){let{value:i}=await t({url:`${this.config.baseURL}/skills/${e}/versions/${n}`,headers:r,failedResponseHandler:Y,successfulResponseHandler:W(kt),fetch:this.config.fetch});return{...i.name==null?{}:{name:i.name},...i.description==null?{}:{description:i.description}}}async uploadSkill(e){let t=[],n=new FormData;e.displayTitle!=null&&n.append(`display_title`,e.displayTitle);for(let t of e.files){let e=U(t.data);n.append(`files[]`,new Blob([e]),t.path)}let r=await this.getHeaders(),{value:i}=await h({url:`${this.config.baseURL}/skills`,headers:r,formData:n,failedResponseHandler:Y,successfulResponseHandler:W(Ot),fetch:this.config.fetch}),a=i.latest_version==null?{}:await this.fetchVersionMetadata({skillId:i.id,version:i.latest_version,headers:r}),o=a.name??i.name,s=a.description??i.description;return{providerReference:{anthropic:i.id},...i.display_title==null?{}:{displayTitle:i.display_title},...o==null?{}:{name:o},...s==null?{}:{description:s},...i.latest_version==null?{}:{latestVersion:i.latest_version},providerMetadata:{anthropic:{...i.source==null?{}:{source:i.source},...i.created_at==null?{}:{createdAt:i.created_at},...i.updated_at==null?{}:{updatedAt:i.updated_at}}},warnings:t}}},jt=`4.0.7`,Mt=`https://api.anthropic.com`,Nt=`${Mt}/v1`;function Pt(e){let t=L(e);return t===Mt?Nt:t}function Ft(e={}){let t=Pt(a({settingValue:e.baseURL,environmentVariableName:`ANTHROPIC_BASE_URL`}))??Nt,n=e.name??`anthropic.messages`;if(e.apiKey&&e.authToken)throw new o({argument:`apiKey/authToken`,message:`Both apiKey and authToken were provided. Please use only one authentication method.`});let r=()=>z({"anthropic-version":`2023-06-01`,...e.authToken?{Authorization:`Bearer ${e.authToken}`}:{"x-api-key":b({apiKey:e.apiKey,environmentVariableName:`ANTHROPIC_API_KEY`,description:`Anthropic`})},...e.headers},`ai-sdk/anthropic/${jt}`),i=i=>new ct(i,{provider:n,baseURL:t,headers:r,fetch:e.fetch,generateId:e.generateId??N,supportedUrls:()=>({"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]})}),s=()=>new At({provider:`${n.replace(`.messages`,``)}.skills`,baseURL:t,headers:r,fetch:e.fetch}),c=function(e){if(new.target)throw Error(`The Anthropic model function cannot be called with the new keyword.`);return i(e)};return c.specificationVersion=`v4`,c.languageModel=i,c.chat=i,c.messages=i,c.embeddingModel=e=>{throw new x({modelId:e,modelType:`embeddingModel`})},c.textEmbeddingModel=c.embeddingModel,c.imageModel=e=>{throw new x({modelId:e,modelType:`imageModel`})},c.files=()=>new re({provider:n,baseURL:t,headers:r,fetch:e.fetch}),c.skills=s,c.tools=Dt,c}Ft();export{Ft as createAnthropic};
@@ -0,0 +1,11 @@
1
+ import{$ as e,Ct as t,Ft as n,Gt as r,I as i,Lt as a,M as o,Mt as s,Nt as c,Ot as l,Q as u,St as d,T as f,Ut as p,Z as m,_ as h,_t as g,c as _,d as v,f as y,gt as b,h as x,i as S,jt as C,k as w,kt as T,l as E,lt as D,mt as O,pt as ee,qt as k,rt as A,v as j,wt as M,yt as te}from"./dist-DZL8soAh.js";function N(e){return e.replace(/[_-]([a-z])/g,e=>e[1].toUpperCase())}function ne(e,t){let n=N(e);return n!==e&&t?.[n]!=null?n:e}function P({rawName:e,providerOptions:t,warnings:n}){let r=N(e);r!==e&&t?.[e]!=null&&n.push({type:`deprecated`,setting:`providerOptions key '${e}'`,message:`Use '${r}' instead.`})}var F={errorSchema:s({error:s({message:n(),type:n().nullish(),param:d().nullish(),code:a([n(),C()]).nullish()})}),errorToMessage:e=>e.error.message};function re(e){if(e==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let t=e.prompt_tokens??0,n=e.completion_tokens??0,r=e.prompt_tokens_details?.cached_tokens??0,i=e.completion_tokens_details?.reasoning_tokens??0;return{inputTokens:{total:t,noCache:t-r,cacheRead:r,cacheWrite:void 0},outputTokens:{total:n,text:n-i,reasoning:i},raw:e}}function I(e){return e?.providerOptions?.openaiCompatible??{}}function ie(e){switch(e){case`audio/wav`:return`wav`;case`audio/mp3`:case`audio/mpeg`:return`mp3`;default:return null}}function ae(e){let t=[];for(let{role:n,content:r,...i}of e){let e=I({...i});switch(n){case`system`:t.push({role:`system`,content:r,...e});break;case`user`:if(r.length===1&&r[0].type===`text`){t.push({role:`user`,content:r[0].text,...I(r[0])});break}t.push({role:`user`,content:r.map(e=>{let t=I(e);switch(e.type){case`text`:return{type:`text`,text:e.text,...t};case`file`:switch(e.data.type){case`reference`:throw new k({functionality:`file parts with provider references`});case`text`:throw new k({functionality:`text file parts`});case`url`:case`data`:{let n=o(e.mediaType);if(n===`image`)return{type:`image_url`,image_url:{url:e.data.type===`url`?e.data.url.toString():`data:${A({part:e})};base64,${v(e.data.data)}`},...t};if(n===`audio`){if(e.data.type===`url`)throw new k({functionality:`audio file parts with URLs`});let n=A({part:e}),r=ie(n);if(r===null)throw new k({functionality:`audio media type ${n}`});return{type:`input_audio`,input_audio:{data:v(e.data.data),format:r},...t}}if(n===`application`){if(e.data.type===`url`)throw new k({functionality:`PDF file parts with URLs`});let n=A({part:e});if(n!==`application/pdf`)throw new k({functionality:`file part media type ${n}`});return{type:`file`,file:{filename:e.filename??`document.pdf`,file_data:`data:application/pdf;base64,${v(e.data.data)}`},...t}}if(n===`text`)return{type:`text`,text:e.data.type===`url`?e.data.url.toString():typeof e.data.data==`string`?new TextDecoder().decode(E(e.data.data)):new TextDecoder().decode(e.data.data),...t};throw new k({functionality:`file part media type ${e.mediaType}`})}}}}),...e});break;case`assistant`:{let n=``,i=``,a=[];for(let e of r){let t=I(e);switch(e.type){case`text`:n+=e.text;break;case`reasoning`:i+=e.text;break;case`tool-call`:{let n=e.providerOptions?.google?.thoughtSignature;a.push({id:e.toolCallId,type:`function`,function:{name:e.toolName,arguments:JSON.stringify(e.input)},...t,...n?{extra_content:{google:{thought_signature:String(n)}}}:{}});break}}}t.push({role:`assistant`,content:a.length>0?n||null:n,...i.length>0?{reasoning_content:i}:{},tool_calls:a.length>0?a:void 0,...e});break}case`tool`:for(let e of r){if(e.type===`tool-approval-response`)continue;let n=e.output,r;switch(n.type){case`text`:case`error-text`:r=n.value;break;case`execution-denied`:r=n.reason??`Tool call execution denied.`;break;case`content`:case`json`:case`error-json`:r=JSON.stringify(n.value);break}let i=I(e);t.push({role:`tool`,tool_call_id:e.toolCallId,content:r,...i})}break;default:throw Error(`Unsupported role: ${n}`)}}return t}function L({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n==null?void 0:new Date(n*1e3)}}function R(e){switch(e){case`stop`:return`stop`;case`length`:return`length`;case`content_filter`:return`content-filter`;case`function_call`:case`tool_calls`:return`tool-calls`;default:return`other`}}var z=s({user:n().optional(),reasoningEffort:n().optional(),textVerbosity:n().optional(),strictJsonSchema:M().optional()});function oe({tools:e,toolChoice:t}){e=e?.length?e:void 0;let n=[];if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:n};let r=[];for(let t of e)t.type===`provider`?n.push({type:`unsupported`,feature:`provider-defined tool ${t.id}`}):r.push({type:`function`,function:{name:t.name,description:t.description,parameters:t.inputSchema,...t.strict==null?{}:{strict:t.strict}}});if(t==null)return{tools:r,toolChoice:void 0,toolWarnings:n};let i=t.type;switch(i){case`auto`:case`none`:case`required`:return{tools:r,toolChoice:i,toolWarnings:n};case`tool`:return{tools:r,toolChoice:{type:`function`,function:{name:t.toolName}},toolWarnings:n};default:throw new k({functionality:`tool choice type: ${i}`})}}var se=class t{constructor(e,t){this.specificationVersion=`v4`,this.modelId=e,this.config=t;let n=t.errorStructure??F;this.chunkSchema=U(n.errorSchema),this.failedResponseHandler=h(n),this.supportsStructuredOutputs=t.supportsStructuredOutputs??!1}static[g](e){return D({modelId:e.modelId,config:e.config})}static[b](e){return new t(e.modelId,e.config)}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(`.`)[0].trim()}get supportedUrls(){var e;return(e=this.config).supportedUrls?.call(e)??{}}transformRequestBody(e){var t;return(t=this.config).transformRequestBody?.call(t,e)??e}convertUsage(e){var t;return(t=this.config).convertUsage?.call(t,e)??re(e)}async getArgs({prompt:e,maxOutputTokens:t,temperature:n,topP:r,topK:a,frequencyPenalty:o,presencePenalty:s,reasoning:c,providerOptions:l,stopSequences:u,responseFormat:d,seed:f,toolChoice:p,tools:h}){let g=[],_=await m({provider:`openai-compatible`,providerOptions:l,schema:z});_!=null&&g.push({type:`deprecated`,setting:`providerOptions key 'openai-compatible'`,message:`Use 'openaiCompatible' instead.`}),P({rawName:this.providerOptionsName,providerOptions:l,warnings:g});let v=Object.assign(_??{},await m({provider:`openaiCompatible`,providerOptions:l,schema:z})??{},await m({provider:this.providerOptionsName,providerOptions:l,schema:z})??{},await m({provider:N(this.providerOptionsName),providerOptions:l,schema:z})??{}),y=v?.strictJsonSchema??!0;a!=null&&g.push({type:`unsupported`,feature:`topK`}),d?.type===`json`&&d.schema!=null&&!this.supportsStructuredOutputs&&g.push({type:`unsupported`,feature:`responseFormat`,details:`JSON response format schema is only supported with structuredOutputs`});let{tools:b,toolChoice:x,toolWarnings:S}=oe({tools:h,toolChoice:p});return{metadataKey:ne(this.providerOptionsName,l),args:{model:this.modelId,user:v.user,max_tokens:t,temperature:n,top_p:r,frequency_penalty:o,presence_penalty:s,response_format:d?.type===`json`?this.supportsStructuredOutputs===!0&&d.schema!=null?{type:`json_schema`,json_schema:{schema:d.schema,strict:y,name:d.name??`response`,description:d.description}}:{type:`json_object`}:void 0,stop:u,seed:f,...Object.fromEntries(Object.entries({...l?.[this.providerOptionsName],...l?.[N(this.providerOptionsName)]}).filter(([e])=>!Object.keys(z.shape).includes(e))),reasoning_effort:v.reasoningEffort??(i(c)&&c!==`none`?c:void 0),verbosity:v.textVerbosity,messages:ae(e),tools:b,tool_choice:x},warnings:[...g,...S]}}async doGenerate(t){var n,r;let{args:i,warnings:a,metadataKey:o}=await this.getArgs({...t}),s=this.transformRequestBody(i),c=JSON.stringify(s),{responseHeaders:l,value:u,rawValue:d}=await e({url:this.config.url({path:`/chat/completions`,modelId:this.modelId}),headers:_((n=this.config).headers?.call(n),t.headers),body:s,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:j(V),abortSignal:t.abortSignal,fetch:this.config.fetch}),f=u.choices[0],p=[],m=f.message.content;m!=null&&m.length>0&&p.push({type:`text`,text:m});let h=f.message.reasoning_content??f.message.reasoning;if(h!=null&&h.length>0&&p.push({type:`reasoning`,text:h}),f.message.tool_calls!=null)for(let e of f.message.tool_calls){let t=e.extra_content?.google?.thought_signature;p.push({type:`tool-call`,toolCallId:e.id??w(),toolName:e.function.name,input:e.function.arguments,...t?{providerMetadata:{[o]:{thoughtSignature:t}}}:{}})}let g={[o]:{},...await((r=this.config.metadataExtractor)?.extractMetadata)?.call(r,{parsedBody:d})},v=u.usage?.completion_tokens_details;return v?.accepted_prediction_tokens!=null&&(g[o].acceptedPredictionTokens=v?.accepted_prediction_tokens),v?.rejected_prediction_tokens!=null&&(g[o].rejectedPredictionTokens=v?.rejected_prediction_tokens),{content:p,finishReason:{unified:R(f.finish_reason),raw:f.finish_reason??void 0},usage:this.convertUsage(u.usage),providerMetadata:g,request:{body:c},response:{...L(u),headers:l,body:d},warnings:a}}async doStream(t){var n;let{args:r,warnings:i,metadataKey:a}=await this.getArgs({...t}),o=this.transformRequestBody({...r,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0}),s=this.config.metadataExtractor?.createStreamExtractor(),{responseHeaders:c,value:l}=await e({url:this.config.url({path:`/chat/completions`,modelId:this.modelId}),headers:_((n=this.config).headers?.call(n),t.headers),body:o,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:x(this.chunkSchema),abortSignal:t.abortSignal,fetch:this.config.fetch}),u=a,d,f=new Map,p=new Set,m=e=>{let t=e.index;if(t==null||p.has(t)){d.processDelta(e);return}let n=f.get(t);n==null?(n={id:e.id??null,bufferedArguments:``,extraContent:e.extra_content??null},f.set(t,n)):(n.id==null&&e.id!=null&&(n.id=e.id),n.extraContent==null&&e.extra_content!=null&&(n.extraContent=e.extra_content));let r=e.function?.arguments;r!=null&&(n.bufferedArguments+=r);let i=e.function?.name;if(i!=null){let e={index:t,id:n.id,function:{name:i,arguments:n.bufferedArguments},extra_content:n.extraContent??void 0};d.processDelta(e),f.delete(t),p.add(t)}},h={unified:`other`,raw:void 0},g,v=!0,y=!1,b=!1,C=e=>this.convertUsage(e);return{stream:l.pipeThrough(new TransformStream({start(e){d=new S(e,{generateId:w,extractMetadata:e=>{let t=e.extra_content?.google?.thought_signature;return t?{[u]:{thoughtSignature:t}}:void 0},buildToolCallProviderMetadata:e=>e}),e.enqueue({type:`stream-start`,warnings:i})},transform(e,n){if(t.includeRawChunks&&n.enqueue({type:`raw`,rawValue:e.rawValue}),!e.success){h={unified:`error`,raw:void 0},n.enqueue({type:`error`,error:e.error});return}if(s?.processChunk(e.rawValue),`error`in e.value){h={unified:`error`,raw:void 0},n.enqueue({type:`error`,error:e.value.error.message});return}let r=e.value;v&&(v=!1,n.enqueue({type:`response-metadata`,...L(r)})),r.usage!=null&&(g=r.usage);let i=r.choices[0];if(i?.finish_reason!=null&&(h={unified:R(i.finish_reason),raw:i.finish_reason??void 0}),i?.delta==null)return;let a=i.delta,o=a.reasoning_content??a.reasoning;if(o&&(y||=(n.enqueue({type:`reasoning-start`,id:`reasoning-0`}),!0),n.enqueue({type:`reasoning-delta`,id:`reasoning-0`,delta:o})),a.content&&(y&&=(n.enqueue({type:`reasoning-end`,id:`reasoning-0`}),!1),b||=(n.enqueue({type:`text-start`,id:`txt-0`}),!0),n.enqueue({type:`text-delta`,id:`txt-0`,delta:a.content})),a.tool_calls!=null){y&&=(n.enqueue({type:`reasoning-end`,id:`reasoning-0`}),!1);for(let e of a.tool_calls)m(e)}},flush(e){y&&e.enqueue({type:`reasoning-end`,id:`reasoning-0`}),b&&e.enqueue({type:`text-end`,id:`txt-0`});for(let[e,t]of f)d.processDelta({index:e,id:t.id,function:{arguments:t.bufferedArguments}});f.clear(),d.flush();let t={[u]:{},...s?.buildMetadata()};g?.completion_tokens_details?.accepted_prediction_tokens!=null&&(t[u].acceptedPredictionTokens=g?.completion_tokens_details?.accepted_prediction_tokens),g?.completion_tokens_details?.rejected_prediction_tokens!=null&&(t[u].rejectedPredictionTokens=g?.completion_tokens_details?.rejected_prediction_tokens),e.enqueue({type:`finish`,finishReason:h,usage:C(g),providerMetadata:t})}})),request:{body:o},response:{headers:c}}}},B=T({prompt_tokens:C().nullish(),completion_tokens:C().nullish(),total_tokens:C().nullish(),prompt_tokens_details:s({cached_tokens:C().nullish()}).nullish(),completion_tokens_details:s({reasoning_tokens:C().nullish(),accepted_prediction_tokens:C().nullish(),rejected_prediction_tokens:C().nullish()}).nullish()}).nullish(),V=T({id:n().nullish(),created:C().nullish(),model:n().nullish(),choices:t(s({message:s({role:l(`assistant`).nullish(),content:n().nullish(),reasoning_content:n().nullish(),reasoning:n().nullish(),tool_calls:t(s({id:n().nullish(),function:s({name:n(),arguments:n()}),extra_content:s({google:s({thought_signature:n().nullish()}).nullish()}).nullish()})).nullish()}),finish_reason:n().nullish()})),usage:B}),H=T({id:n().nullish(),created:C().nullish(),model:n().nullish(),choices:t(s({delta:s({role:te([`assistant`,``]).nullish(),content:n().nullish(),reasoning_content:n().nullish(),reasoning:n().nullish(),tool_calls:t(s({index:C().nullish(),id:n().nullish(),function:s({name:n().nullish(),arguments:n().nullish()}),extra_content:s({google:s({thought_signature:n().nullish()}).nullish()}).nullish()})).nullish()}).nullish(),finish_reason:n().nullish()})),usage:B}),U=e=>a([H,e]);function W(e){if(e==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let t=e.prompt_tokens??0,n=e.completion_tokens??0;return{inputTokens:{total:t,noCache:t,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:n,text:n,reasoning:void 0},raw:e}}function G({prompt:e,user:t=`user`,assistant:n=`assistant`}){let r=``;e[0].role===`system`&&(r+=`${e[0].content}
2
+
3
+ `,e=e.slice(1));for(let{role:i,content:a}of e)switch(i){case`system`:throw new p({message:"Unexpected system message in prompt: ${content}",prompt:e});case`user`:{let e=a.map(e=>{switch(e.type){case`text`:return e.text}}).filter(Boolean).join(``);r+=`${t}:
4
+ ${e}
5
+
6
+ `;break}case`assistant`:{let e=a.map(e=>{switch(e.type){case`text`:return e.text;case`tool-call`:throw new k({functionality:`tool-call messages`})}}).join(``);r+=`${n}:
7
+ ${e}
8
+
9
+ `;break}case`tool`:throw new k({functionality:`tool messages`});default:throw Error(`Unsupported role: ${i}`)}return r+=`${n}:
10
+ `,{prompt:r,stopSequences:[`
11
+ ${t}:`]}}function K({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n==null?void 0:new Date(n*1e3)}}function q(e){switch(e){case`stop`:return`stop`;case`length`:return`length`;case`content_filter`:return`content-filter`;case`function_call`:case`tool_calls`:return`tool-calls`;default:return`other`}}var J=s({echo:M().optional(),logitBias:c(n(),C()).optional(),suffix:n().optional(),user:n().optional()}),ce=class t{constructor(e,t){this.specificationVersion=`v4`,this.modelId=e,this.config=t;let n=t.errorStructure??F;this.chunkSchema=ue(n.errorSchema),this.failedResponseHandler=h(n)}static[g](e){return D({modelId:e.modelId,config:e.config})}static[b](e){return new t(e.modelId,e.config)}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(`.`)[0].trim()}get supportedUrls(){var e;return(e=this.config).supportedUrls?.call(e)??{}}async getArgs({prompt:e,maxOutputTokens:t,temperature:n,topP:r,topK:i,frequencyPenalty:a,presencePenalty:o,stopSequences:s,responseFormat:c,seed:l,providerOptions:u,tools:d,toolChoice:f}){let p=[];P({rawName:this.providerOptionsName,providerOptions:u,warnings:p});let h=Object.assign(await m({provider:this.providerOptionsName,providerOptions:u,schema:J})??{},await m({provider:N(this.providerOptionsName),providerOptions:u,schema:J})??{});i!=null&&p.push({type:`unsupported`,feature:`topK`}),d?.length&&p.push({type:`unsupported`,feature:`tools`}),f!=null&&p.push({type:`unsupported`,feature:`toolChoice`}),c!=null&&c.type!==`text`&&p.push({type:`unsupported`,feature:`responseFormat`,details:`JSON response format is not supported.`});let{prompt:g,stopSequences:_}=G({prompt:e}),v=[..._??[],...s??[]];return{args:{model:this.modelId,echo:h.echo,logit_bias:h.logitBias,suffix:h.suffix,user:h.user,max_tokens:t,temperature:n,top_p:r,frequency_penalty:a,presence_penalty:o,seed:l,...u?.[this.providerOptionsName],...u?.[N(this.providerOptionsName)],prompt:g,stop:v.length>0?v:void 0},warnings:p}}async doGenerate(t){var n;let{args:r,warnings:i}=await this.getArgs(t),{responseHeaders:a,value:o,rawValue:s}=await e({url:this.config.url({path:`/completions`,modelId:this.modelId}),headers:_((n=this.config).headers?.call(n),t.headers),body:r,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:j(le),abortSignal:t.abortSignal,fetch:this.config.fetch}),c=o.choices[0],l=[];return c.text!=null&&c.text.length>0&&l.push({type:`text`,text:c.text}),{content:l,usage:W(o.usage),finishReason:{unified:q(c.finish_reason),raw:c.finish_reason},request:{body:r},response:{...K(o),headers:a,body:s},warnings:i}}async doStream(t){var n;let{args:r,warnings:i}=await this.getArgs(t),a={...r,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0},{responseHeaders:o,value:s}=await e({url:this.config.url({path:`/completions`,modelId:this.modelId}),headers:_((n=this.config).headers?.call(n),t.headers),body:a,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:x(this.chunkSchema),abortSignal:t.abortSignal,fetch:this.config.fetch}),c={unified:`other`,raw:void 0},l,u=!0;return{stream:s.pipeThrough(new TransformStream({start(e){e.enqueue({type:`stream-start`,warnings:i})},transform(e,n){if(t.includeRawChunks&&n.enqueue({type:`raw`,rawValue:e.rawValue}),!e.success){c={unified:`error`,raw:void 0},n.enqueue({type:`error`,error:e.error});return}let r=e.value;if(`error`in r){c={unified:`error`,raw:void 0},n.enqueue({type:`error`,error:r.error});return}u&&(u=!1,n.enqueue({type:`response-metadata`,...K(r)}),n.enqueue({type:`text-start`,id:`0`})),r.usage!=null&&(l=r.usage);let i=r.choices[0];i?.finish_reason!=null&&(c={unified:q(i.finish_reason),raw:i.finish_reason??void 0}),i?.text!=null&&n.enqueue({type:`text-delta`,id:`0`,delta:i.text})},flush(e){u||e.enqueue({type:`text-end`,id:`0`}),e.enqueue({type:`finish`,finishReason:c,usage:W(l)})}})),request:{body:a},response:{headers:o}}}},Y=s({prompt_tokens:C(),completion_tokens:C(),total_tokens:C()}),le=s({id:n().nullish(),created:C().nullish(),model:n().nullish(),choices:t(s({text:n(),finish_reason:n()})),usage:Y.nullish()}),ue=e=>a([s({id:n().nullish(),created:C().nullish(),model:n().nullish(),choices:t(s({text:n(),finish_reason:n().nullish(),index:C()})),usage:Y.nullish()}),e]),X=s({dimensions:C().optional(),user:n().optional()}),de=class t{constructor(e,t){this.specificationVersion=`v4`,this.modelId=e,this.config=t}get provider(){return this.config.provider}get maxEmbeddingsPerCall(){return this.config.maxEmbeddingsPerCall??2048}get supportsParallelCalls(){return this.config.supportsParallelCalls??!0}static[g](e){return D({modelId:e.modelId,config:e.config})}static[b](e){return new t(e.modelId,e.config)}get providerOptionsName(){return this.config.provider.split(`.`)[0].trim()}async doEmbed({values:t,headers:n,abortSignal:i,providerOptions:a}){var o;let s=[],c=await m({provider:`openai-compatible`,providerOptions:a,schema:X});c!=null&&s.push({type:`deprecated`,setting:`providerOptions key 'openai-compatible'`,message:`Use 'openaiCompatible' instead.`}),P({rawName:this.providerOptionsName,providerOptions:a,warnings:s});let l=Object.assign(c??{},await m({provider:`openaiCompatible`,providerOptions:a,schema:X})??{},await m({provider:this.providerOptionsName,providerOptions:a,schema:X})??{});if(t.length>this.maxEmbeddingsPerCall)throw new r({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:t});let{responseHeaders:u,value:d,rawValue:f}=await e({url:this.config.url({path:`/embeddings`,modelId:this.modelId}),headers:_((o=this.config).headers?.call(o),n),body:{model:this.modelId,input:t,encoding_format:`float`,dimensions:l.dimensions,user:l.user},failedResponseHandler:h(this.config.errorStructure??F),successfulResponseHandler:j(Z),abortSignal:i,fetch:this.config.fetch});return{warnings:s,embeddings:d.data.map(e=>e.embedding),usage:d.usage?{tokens:d.usage.prompt_tokens}:void 0,providerMetadata:d.providerMetadata,response:{headers:u,body:f}}}},Z=s({data:t(s({embedding:t(C())})),usage:s({prompt_tokens:C()}).nullish(),providerMetadata:c(n(),c(n(),d())).optional()}),fe=class t{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`,this.maxImagesPerCall=10}get provider(){return this.config.provider}get providerOptionsKey(){return this.config.provider.split(`.`)[0].trim()}static[g](e){return D({modelId:e.modelId,config:e.config})}static[b](e){return new t(e.modelId,e.config)}getArgs(e,t){return P({rawName:this.providerOptionsKey,providerOptions:e,warnings:t}),{...e[this.providerOptionsKey],...e[N(this.providerOptionsKey)]}}async doGenerate({prompt:t,n,size:r,aspectRatio:i,seed:a,providerOptions:o,headers:s,abortSignal:c,files:l,mask:d}){var f,p,m;let g=[];i!=null&&g.push({type:`unsupported`,feature:`aspectRatio`,details:"This model does not support aspect ratio. Use `size` instead."}),a!=null&&g.push({type:`unsupported`,feature:`seed`});let v=((f=this.config._internal)?.currentDate)?.call(f)??new Date,b=this.getArgs(o,g);if(l!=null&&l.length>0){let{value:e,responseHeaders:i}=await u({url:this.config.url({path:`/images/edits`,modelId:this.modelId}),headers:_((p=this.config).headers?.call(p),s),formData:y({model:this.modelId,prompt:t,image:await Promise.all(l.map(e=>$(e))),mask:d==null?void 0:await $(d),n,size:r,...b}),failedResponseHandler:h(this.config.errorStructure??F),successfulResponseHandler:j(Q),abortSignal:c,fetch:this.config.fetch});return{images:e.data.map(e=>e.b64_json),warnings:g,response:{timestamp:v,modelId:this.modelId,headers:i}}}let{value:x,responseHeaders:S}=await e({url:this.config.url({path:`/images/generations`,modelId:this.modelId}),headers:_((m=this.config).headers?.call(m),s),body:{model:this.modelId,prompt:t,n,size:r,...b,response_format:`b64_json`},failedResponseHandler:h(this.config.errorStructure??F),successfulResponseHandler:j(Q),abortSignal:c,fetch:this.config.fetch});return{images:x.data.map(e=>e.b64_json),warnings:g,response:{timestamp:v,modelId:this.modelId,headers:S}}}},Q=s({data:t(s({b64_json:n()}))});async function $(e){if(e.type===`url`)return f(e.url);let t=e.data instanceof Uint8Array?e.data:E(e.data);return new Blob([t],{type:e.mediaType})}var pe=`3.0.5`;function me(e){let t=O(e.baseURL),n=e.name,r={...e.apiKey&&{Authorization:`Bearer ${e.apiKey}`},...e.headers},i=()=>ee(r,`ai-sdk/openai-compatible/${pe}`),a=r=>({provider:`${n}.${r}`,url:({path:n})=>{let r=new URL(`${t}${n}`);return e.queryParams&&(r.search=new URLSearchParams(e.queryParams).toString()),r.toString()},headers:i,fetch:e.fetch}),o=e=>s(e),s=t=>new se(t,{...a(`chat`),includeUsage:e.includeUsage,supportsStructuredOutputs:e.supportsStructuredOutputs,supportedUrls:e.supportedUrls,transformRequestBody:e.transformRequestBody,metadataExtractor:e.metadataExtractor,convertUsage:e.convertUsage}),c=t=>new ce(t,{...a(`completion`),includeUsage:e.includeUsage}),l=e=>new de(e,{...a(`embedding`)}),u=e=>new fe(e,a(`image`)),d=e=>o(e);return d.specificationVersion=`v4`,d.languageModel=o,d.chatModel=s,d.completionModel=c,d.embeddingModel=l,d.textEmbeddingModel=l,d.imageModel=u,d}export{me as createOpenAICompatible};
@@ -1 +1 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r}from"./react-vendor-B68RYDeC.js";var i=e(n(),1),a=r();function o({children:e,htmlFor:t}){return(0,a.jsx)(`label`,{htmlFor:t,className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e})}function s({label:e,hint:t,children:n}){let r=(0,i.useId)(),s=n,c;if((0,i.isValidElement)(n)){let e=n;c=e.props.id??r,s=e.props.id?e:(0,i.cloneElement)(e,{id:r})}return(0,a.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,a.jsx)(o,{htmlFor:c,children:e}),s,t&&(0,a.jsx)(`p`,{className:`text-xs leading-relaxed text-faint`,children:t})]})}var c=`h-9 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30 transition-colors`;function l({className:e,...n}){return(0,a.jsx)(`input`,{className:t(c,`w-full`,e),...n})}function u({className:e,children:n,...r}){return(0,a.jsx)(`select`,{className:t(c,`w-full cursor-pointer pr-8`,e),...r,children:n})}function d({checked:e,onChange:n,label:r,disabled:i}){return(0,a.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:i,onClick:()=>n(!e),className:t(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,e?`bg-accent`:`bg-surface-2 border border-line`,i&&`opacity-40`),children:(0,a.jsx)(`span`,{className:t(`inline-block size-4 transform rounded-full bg-white shadow transition-transform`,e?`translate-x-6`:`translate-x-1`)})})}function f({options:e,value:n,onChange:r,disabled:i}){return(0,a.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-lg border border-line bg-surface p-1`,children:e.map(e=>(0,a.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>r(e),className:t(`rounded-md px-3 py-1 text-xs font-medium capitalize transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,n===e?`bg-surface-2 text-fg`:`text-muted hover:text-fg`,i&&`opacity-40`),children:e},e))})}export{u as a,f as i,l as n,d as o,o as r,s as t};
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r}from"./react-vendor-BcouBxpZ.js";var i=e(n(),1),a=r();function o({children:e,htmlFor:t}){return(0,a.jsx)(`label`,{htmlFor:t,className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e})}function s({label:e,hint:t,children:n}){let r=(0,i.useId)(),s=n,c;if((0,i.isValidElement)(n)){let e=n;c=e.props.id??r,s=e.props.id?e:(0,i.cloneElement)(e,{id:r})}return(0,a.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,a.jsx)(o,{htmlFor:c,children:e}),s,t&&(0,a.jsx)(`p`,{className:`text-xs leading-relaxed text-faint`,children:t})]})}var c=`h-9 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30 transition-colors`;function l({className:e,...n}){return(0,a.jsx)(`input`,{className:t(c,`w-full`,e),...n})}function u({className:e,children:n,...r}){return(0,a.jsx)(`select`,{className:t(c,`w-full cursor-pointer pr-8`,e),...r,children:n})}function d({checked:e,onChange:n,label:r,disabled:i}){return(0,a.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:i,onClick:()=>n(!e),className:t(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,e?`bg-accent`:`bg-surface-2 border border-line`,i&&`opacity-40`),children:(0,a.jsx)(`span`,{className:t(`inline-block size-4 transform rounded-full bg-white shadow transition-transform`,e?`translate-x-6`:`translate-x-1`)})})}function f({options:e,value:n,onChange:r,disabled:i}){return(0,a.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-lg border border-line bg-surface p-1`,children:e.map(e=>(0,a.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>r(e),className:t(`rounded-md px-3 py-1 text-xs font-medium capitalize transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,n===e?`bg-surface-2 text-fg`:`text-muted hover:text-fg`,i&&`opacity-40`),children:e},e))})}export{u as a,f as i,l as n,d as o,o as r,s as t};
@@ -0,0 +1,8 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CopilotPanel-DZUGIf1q.js","assets/cn-CMFYpumL.js","assets/react-vendor-BcouBxpZ.js","assets/dist-DZL8soAh.js","assets/form-DGinTEEb.js","assets/AddJob-CAhdg38n.js","assets/Benchmark-CFZ3WCvj.js","assets/connectionStore-Ci04lJmR.js","assets/AreaChart-2gM0YoZT.js","assets/BulkAddJobs-BzgzpGg_.js","assets/CronManager-BcFALDeT.js","assets/Pagination-D4ki-pGz.js","assets/Database-CV2yt5O2.js","assets/Diagnostics-D-EK4GEi.js","assets/DlqControl-eTrrQCrn.js","assets/exportFile-tdUeW5m5.js","assets/DlqPro-CF79339e.js","assets/promisePool-Daxkc1OB.js","assets/Flows-Ba8G7mcC.js","assets/JobInspector--d_8ca9p.js","assets/jobActions-CuOdMglt.js","assets/JobsPro-BcaokZIf.js","assets/LogsPro-Wl_e6hZM.js","assets/McpServer-CnWJsKw7.js","assets/MetricsPro-O9eVJSH0.js","assets/useThroughputSeries-Chp5OLx3.js","assets/QueueControl-DKqEXnkM.js","assets/QueueActions-DHoSkWRz.js","assets/QueueDetailPro-BYmOVd4T.js","assets/QueuesOverview-BeWdJpKi.js","assets/S3BackupPro-DJB4oWgz.js","assets/ServerControl-_0lVB33E.js","assets/UsagePro-B-TJ6fp4.js","assets/Webhooks-C3zmvY-_.js","assets/WorkersPro-mvY5VX8I.js","assets/Alerts-70bxf-PT.js","assets/Cron-ltjSoTjj.js","assets/Dlq-fZAKwQoC.js","assets/Jobs-DEqAc1A5.js","assets/Logs-DBTukPIX.js","assets/Metrics-DzeIhNL-.js","assets/Overview-Bnu7rWqt.js","assets/QueueDetail-DLRow04B.js","assets/Queues-CoyjRFN7.js","assets/S3Backup-BaLFgl9d.js","assets/Settings-zKFJTtnq.js","assets/Usage-CKGkvl0j.js","assets/Workers-jKhhXl3W.js"])))=>i.map(i=>d[i]);
2
+ import{r as e,t}from"./cn-CMFYpumL.js";import{a as n,c as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./react-vendor-BcouBxpZ.js";import{a as h,i as g,n as _,o as v,r as y,t as ee}from"./connectionStore-Ci04lJmR.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var b=e(i(),1),x=s(),te=()=>`${Date.now().toString(36)}${Math.floor(Math.random()*1e6).toString(36)}`;function ne(e){return{channels:e.channels.map(e=>e.type===`email`?e:{...e,target:``}),rules:e.rules}}var S=v()(h(e=>({channels:[],rules:[],addChannel:(t,n)=>e(e=>({channels:[...e.channels,{id:te(),type:t,target:n}]})),removeChannel:t=>e(e=>({channels:e.channels.filter(e=>e.id!==t)})),addRule:t=>e(e=>({rules:[...e.rules,{...t,id:te()}]})),removeRule:t=>e(e=>({rules:e.rules.filter(e=>e.id!==t)})),toggleRule:t=>e(e=>({rules:e.rules.map(e=>e.id===t?{...e,enabled:!e.enabled}:e)}))}),{name:`bq-dash-alerts`,partialize:ne})),re={error_rate:`error rate`,p99_latency:`p99 latency`,waiting:`waiting jobs`,failed:`failed jobs`,dlq:`DLQ size`},ie=1,C=v(e=>({toasts:[],push:({level:t,title:n,detail:r,ttlMs:i})=>{let a=ie++,o=i??(t===`error`?8e3:4e3);return e(e=>({toasts:[...e.toasts,{id:a,level:t,title:n,detail:r,ttlMs:o}].slice(-5)})),a},dismiss:t=>e(e=>({toasts:e.toasts.filter(e=>e.id!==t)}))})),ae={success:(e,t)=>C.getState().push({level:`success`,title:e,detail:t}),error:(e,t)=>C.getState().push({level:`error`,title:e,detail:t}),info:(e,t)=>C.getState().push({level:`info`,title:e,detail:t})},w=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`BqError`}};async function oe(e,t,n,r,i=!0,a=`server`){let o=await fetch(e+t,{...r,headers:{"Content-Type":`application/json`,...n,...r?.headers}});if(!o.ok){let e=`HTTP ${o.status}`;try{let t=await o.json();t?.error&&(e=t.error)}catch{}throw o.status===401&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(`auth:required`,{detail:{scope:a}})),new w(e,o.status)}if(o.status===204)return;let s=await o.text();if(!s)return;let c;try{c=JSON.parse(s)}catch{throw new w(`Invalid JSON response (HTTP ${o.status})`,o.status)}if(i&&c&&typeof c==`object`&&c.ok===!1){let e=c.error;throw new w(e??`Operation failed`,o.status)}return c}var T=(e,t,n=!0)=>oe(y(),e,_(),t,n),se=(globalThis.__BUNQUEUE_AGENT_URL__||`http://localhost:6800`).replace(/\/$/,``),E=(e,t)=>oe(se,e,ee(),t,!0,`agent`),D=e=>encodeURIComponent(e),O=(e,t)=>({method:e,body:t===void 0?void 0:JSON.stringify(t)}),ce=[`job.pushed`,`job.started`,`job.completed`,`job.failed`,`job.progress`],k={overview:()=>T(`/dashboard`),queues:(e=500,t=0)=>T(`/dashboard/queues?limit=${e}&offset=${t}`),queuesSummary:()=>T(`/queues/summary`),queueDetail:(e,t=!0)=>T(`/dashboard/queues/${D(e)}?includeJobs=${t}`),stats:()=>T(`/stats`),storage:()=>T(`/storage`),health:()=>T(`/health`,void 0,!1),ping:()=>T(`/ping`),prometheusUrl:()=>`${y()}/prometheus`,gc:()=>T(`/gc`,O(`POST`)),heapStats:()=>T(`/heapstats`),jobsList:(e,t,n=50,r=0)=>{let i=new URLSearchParams;return t?.length&&i.set(`states`,t.join(`,`)),i.set(`limit`,String(n)),i.set(`offset`,String(r)),T(`/queues/${D(e)}/jobs/list?${i}`)},job:e=>T(`/jobs/${D(e)}`),jobByCustomId:e=>T(`/jobs/custom/${D(e)}`),jobResult:e=>T(`/jobs/${D(e)}/result`),jobLogs:e=>T(`/jobs/${D(e)}/logs`),jobChildren:e=>T(`/jobs/${D(e)}/children`),addJob:(e,t)=>T(`/queues/${D(e)}/jobs`,O(`POST`,t)),addJobsBulk:(e,t)=>T(`/queues/${D(e)}/jobs/bulk`,O(`POST`,{jobs:t})),pullBatch:(e,t)=>T(`/queues/${D(e)}/jobs/pull-batch`,O(`POST`,{count:t})),ackBatch:e=>T(`/jobs/ack-batch`,O(`POST`,{ids:e})),cancelJob:e=>T(`/jobs/${D(e)}`,{method:`DELETE`}),promoteJob:e=>T(`/jobs/${D(e)}/promote`,O(`POST`)),discardJob:e=>T(`/jobs/${D(e)}/discard`,O(`POST`)),retryJob:e=>T(`/jobs/${D(e)}/move-to-wait`,O(`POST`)),failJob:(e,t)=>T(`/jobs/${D(e)}/fail`,O(`POST`,{error:t})),updateJobData:(e,t)=>T(`/jobs/${D(e)}/data`,O(`PUT`,{data:t})),changePriority:(e,t)=>T(`/jobs/${D(e)}/priority`,O(`PUT`,{priority:t})),changeDelay:(e,t)=>T(`/jobs/${D(e)}/delay`,O(`PUT`,{delay:t})),moveToDelayed:(e,t)=>T(`/jobs/${D(e)}/move-to-delayed`,O(`POST`,{delay:t})),addJobLog:(e,t,n)=>T(`/jobs/${D(e)}/logs`,O(`POST`,{message:t,level:n})),clearJobLogs:e=>T(`/jobs/${D(e)}/logs`,{method:`DELETE`}),setJobProgress:(e,t,n)=>T(`/jobs/${D(e)}/progress`,O(`POST`,{progress:t,message:n})),counts:e=>T(`/queues/${D(e)}/counts`),pause:e=>T(`/queues/${D(e)}/pause`,O(`POST`)),resume:e=>T(`/queues/${D(e)}/resume`,O(`POST`)),drain:e=>T(`/queues/${D(e)}/drain`,O(`POST`)),obliterate:e=>T(`/queues/${D(e)}/obliterate`,O(`POST`)),clean:(e,t={})=>T(`/queues/${D(e)}/clean`,O(`POST`,t)),promoteJobs:(e,t)=>T(`/queues/${D(e)}/promote-jobs`,O(`POST`,t==null?void 0:{count:t})),retryCompleted:(e,t)=>T(`/queues/${D(e)}/retry-completed`,O(`POST`,t?{id:t}:void 0)),setRateLimit:(e,t)=>T(`/queues/${D(e)}/rate-limit`,O(`PUT`,{limit:t})),clearRateLimit:e=>T(`/queues/${D(e)}/rate-limit`,{method:`DELETE`}),setConcurrency:(e,t)=>T(`/queues/${D(e)}/concurrency`,O(`PUT`,{concurrency:t})),clearConcurrency:e=>T(`/queues/${D(e)}/concurrency`,{method:`DELETE`}),getStallConfig:e=>T(`/queues/${D(e)}/stall-config`),setStallConfig:(e,t)=>T(`/queues/${D(e)}/stall-config`,O(`PUT`,{config:t})),getDlqConfig:e=>T(`/queues/${D(e)}/dlq-config`),setDlqConfig:(e,t)=>T(`/queues/${D(e)}/dlq-config`,O(`PUT`,{config:t})),dlq:(e,t=100,n=0)=>T(`/queues/${D(e)}/dlq?limit=${t}&offset=${n}`),dlqStats:e=>T(`/queues/${D(e)}/dlq/stats`),retryDlq:(e,t)=>T(`/queues/${D(e)}/dlq/retry`,O(`POST`,t?{jobId:t}:void 0)),purgeDlq:e=>T(`/queues/${D(e)}/dlq/purge`,O(`POST`)),crons:()=>T(`/crons`),createCron:e=>T(`/crons`,O(`POST`,e)),deleteCron:e=>T(`/crons/${D(e)}`,{method:`DELETE`}),webhooks:()=>T(`/webhooks`),addWebhook:e=>T(`/webhooks`,O(`POST`,e)),removeWebhook:e=>T(`/webhooks/${D(e)}`,{method:`DELETE`}),setWebhookEnabled:(e,t)=>T(`/webhooks/${D(e)}/enabled`,O(`PUT`,{enabled:t})),workers:()=>T(`/workers`),unregisterWorker:e=>T(`/workers/${D(e)}`,{method:`DELETE`}),eventsUrl:e=>y()+(e?`/events/queues/${D(e)}`:`/events`),db:{info:()=>E(`/db/info`),tables:()=>E(`/db/tables`),schema:e=>E(`/db/tables/${D(e)}/schema`),rows:(e,t=50,n=0,r,i=`asc`,a)=>E(`/db/tables/${D(e)}?limit=${t}&offset=${n}`+(r?`&orderBy=${D(r)}&dir=${i}`:``)+(a?.value?`&fcol=${D(a.column)}&fop=${a.op}&fval=${D(a.value)}`:``)),cell:(e,t,n)=>E(`/db/tables/${D(e)}/cell?rowid=${t}&column=${D(n)}`),query:e=>E(`/db/query`,O(`POST`,{sql:e}))},agentBase:se,control:{status:()=>E(`/control/status`),start:()=>E(`/control/start`,{method:`POST`}),stop:()=>E(`/control/stop`,{method:`POST`}),restart:()=>E(`/control/restart`,{method:`POST`}),logs:()=>E(`/control/logs`),getConfig:()=>E(`/control/config`),setConfig:e=>E(`/control/config`,O(`PUT`,e))}},le=15e3,ue=6e4,de=v(e=>({breaching:[],setBreaching:t=>e({breaching:t})}));async function fe(){if(typeof Notification>`u`)return`denied`;if(Notification.permission===`granted`)return`granted`;try{return await Notification.requestPermission()}catch{return`denied`}}function pe(e,t,n){switch(t){case`>=`:return e>=n;case`>`:return e>n;case`<=`:return e<=n;case`<`:return e<n;default:return!1}}var me=(e,t)=>{let n=e+t;return n>0?t/n*100:0};function he(e,t){let n=e.queue.trim();switch(e.metric){case`waiting`:return t.summary?n?t.summary.find(e=>e.name===n)?.counts.waiting??null:t.summary.reduce((e,t)=>e+t.counts.waiting,0):null;case`failed`:return t.summary?n?t.summary.find(e=>e.name===n)?.counts.failed??null:t.summary.reduce((e,t)=>e+t.counts.failed,0):null;case`dlq`:return t.queues?n?t.queues.find(e=>e.name===n)?.dlq??null:t.queues.reduce((e,t)=>e+(t.dlq??0),0):null;case`error_rate`:if(!t.summary)return null;if(n){let e=t.summary.find(e=>e.name===n);return e?me(e.counts.completed,e.counts.failed):null}return me(t.summary.reduce((e,t)=>e+t.counts.completed,0),t.summary.reduce((e,t)=>e+t.counts.failed,0));case`p99_latency`:{let e=t.overview?.latency?.percentiles;if(!e)return null;let n=Object.values(e).map(e=>e.p99).filter(e=>Number.isFinite(e));return n.length?Math.max(...n):null}default:return null}}function ge(e){let t=`${e.queue||`All queues`}: ${e.metricLabel} ${e.operator} ${e.threshold} (now ${Math.round(e.value)})`;if(ae.error(`Alert: ${e.ruleName}`,t),typeof Notification<`u`&&Notification.permission===`granted`)try{new Notification(`bunqueue alert: ${e.ruleName}`,{body:t,tag:e.ruleId})}catch{}}function _e(){let e=S(e=>e.rules),t=de(e=>e.setBreaching),n=(0,b.useRef)(new Map),r=(0,b.useRef)(new Map),i=(0,b.useRef)(new Map),a=e.filter(e=>e.enabled).map(e=>`${e.id}:${e.metric}:${e.operator}:${e.threshold}:${e.queue}`).join(`|`);(0,b.useEffect)(()=>{if(!a){t([]),n.current.clear(),r.current.clear(),i.current.clear();return}let e=!1,o=!1,s=async()=>{if(!o){o=!0;try{let[a,o,s]=await Promise.all([k.queuesSummary().catch(()=>null),k.queues().catch(()=>null),k.overview().catch(()=>null)]);if(e||!s)return;let c={summary:a,queues:o?.queues??null,overview:s},l=Date.now(),u=[],d=S.getState().rules.filter(e=>e.enabled),f=new Set(d.map(e=>e.id));for(let e of d){let t=he(e,c);if(t==null)continue;let a=pe(t,e.operator,e.threshold),o=n.current.get(e.id)??!1;if(a){let n=o?i.current.get(e.id)??l:l;i.current.set(e.id,n);let a={ruleId:e.id,ruleName:e.name,metricLabel:re[e.metric],operator:e.operator,threshold:e.threshold,value:t,queue:e.queue,at:n};u.push(a);let s=l-(r.current.get(e.id)??0)>ue;!o&&s&&(ge(a),r.current.set(e.id,l))}else i.current.delete(e.id);n.current.set(e.id,a)}for(let e of[...n.current.keys()])f.has(e)||(n.current.delete(e),r.current.delete(e),i.current.delete(e));t(u)}finally{o=!1}}};s();let c=setInterval(s,le);return()=>{e=!0,clearInterval(c)}},[a,t])}function ve(){return _e(),null}var A=p();function ye(){let[e,t]=(0,b.useState)(!1),[n,r]=(0,b.useState)(`server`),[i,a]=(0,b.useState)(``),o=g(e=>e.baseUrl),s=g(e=>e.setToken),c=g(e=>e.setAgentToken),l=(0,b.useRef)(null);return(0,b.useEffect)(()=>{let e=e=>{let n=e.detail?.scope;r(n===`agent`?`agent`:`server`),t(!0)};return window.addEventListener(`auth:required`,e),()=>window.removeEventListener(`auth:required`,e)},[]),(0,b.useEffect)(()=>{if(!e)return;let t=requestAnimationFrame(()=>l.current?.focus());return()=>cancelAnimationFrame(t)},[e]),e?(0,A.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4`,children:(0,A.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let r=i.trim();r&&(n===`agent`?c(r):s(r),a(``),t(!1))},role:`dialog`,"aria-modal":`true`,"aria-label":`Authentication required`,className:`w-full max-w-sm rounded-xl border border-line-strong bg-surface p-6 shadow-2xl`,children:[(0,A.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Authentication required`}),n===`agent`?(0,A.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[`The control agent at `,(0,A.jsx)(`span`,{className:`break-all font-mono text-fg`,children:k.agentBase}),` `,`rejected the request (401). Enter its`,` `,(0,A.jsx)(`span`,{className:`font-mono text-fg`,children:`AGENT_TOKEN`}),` to continue.`]}):(0,A.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[`The server at `,(0,A.jsx)(`span`,{className:`break-all font-mono text-fg`,children:o}),` rejected the request (401). Enter its bearer token to continue.`]}),(0,A.jsx)(`input`,{ref:l,type:`password`,value:i,onChange:e=>a(e.target.value),placeholder:n===`agent`?`AGENT_TOKEN`:`Bearer token`,"aria-label":n===`agent`?`Agent token`:`Bearer token`,autoComplete:`off`,className:`mt-4 w-full rounded-lg border border-line bg-surface-2 px-3 py-2 text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/50`}),(0,A.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3`,children:[(0,A.jsx)(d,{to:`/settings`,onClick:()=>t(!1),className:`text-xs text-muted underline-offset-2 hover:text-fg hover:underline`,children:`Open Settings instead`}),(0,A.jsx)(`button`,{type:`submit`,disabled:!i.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-50`,children:`Unlock`})]})]})}):null}function j(e){typeof document<`u`&&(document.documentElement.dataset.theme=e,document.documentElement.style.colorScheme=e)}var M=v()(h((e,t)=>({theme:`dark`,toggle:()=>{let n=t().theme===`dark`?`light`:`dark`;j(n),e({theme:n})},setTheme:t=>{j(t),e({theme:t})}}),{name:`bq-dash-theme`,onRehydrateStorage:()=>e=>{e&&j(e.theme)}}));function be(){j(M.getState().theme)}function N({children:e,...t}){return(0,A.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,...t,children:e})}var xe=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`path`,{d:`M3 3v18h18`}),(0,A.jsx)(`rect`,{x:`7`,y:`12`,width:`3`,height:`6`}),(0,A.jsx)(`rect`,{x:`12`,y:`8`,width:`3`,height:`10`}),(0,A.jsx)(`rect`,{x:`17`,y:`5`,width:`3`,height:`13`})]}),P=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`line`,{x1:`8`,y1:`6`,x2:`21`,y2:`6`}),(0,A.jsx)(`line`,{x1:`8`,y1:`12`,x2:`21`,y2:`12`}),(0,A.jsx)(`line`,{x1:`8`,y1:`18`,x2:`21`,y2:`18`}),(0,A.jsx)(`line`,{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`}),(0,A.jsx)(`line`,{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`}),(0,A.jsx)(`line`,{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`})]}),F=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`rect`,{x:`2`,y:`7`,width:`20`,height:`14`,rx:`2`}),(0,A.jsx)(`path`,{d:`M16 7V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`})]}),I=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z`}),(0,A.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,A.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}),Se=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,A.jsx)(`polyline`,{points:`12 7 12 12 15 14`})]}),Ce=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`path`,{d:`M3 3v18h18`}),(0,A.jsx)(`path`,{d:`m19 9-5 5-4-4-3 3`})]}),L=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`8`,rx:`2`}),(0,A.jsx)(`rect`,{x:`4`,y:`14`,width:`16`,height:`6`,rx:`2`}),(0,A.jsx)(`line`,{x1:`8`,y1:`8`,x2:`8.01`,y2:`8`}),(0,A.jsx)(`line`,{x1:`8`,y1:`17`,x2:`8.01`,y2:`17`})]}),we=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`path`,{d:`M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9`}),(0,A.jsx)(`path`,{d:`M13.73 21a2 2 0 0 1-3.46 0`})]}),Te=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`line`,{x1:`8`,y1:`6`,x2:`21`,y2:`6`}),(0,A.jsx)(`line`,{x1:`8`,y1:`12`,x2:`21`,y2:`12`}),(0,A.jsx)(`line`,{x1:`8`,y1:`18`,x2:`21`,y2:`18`}),(0,A.jsx)(`path`,{d:`M3 6h.01M3 12h.01M3 18h.01`})]}),Ee=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`path`,{d:`M12 20V10`}),(0,A.jsx)(`path`,{d:`M18 20V4`}),(0,A.jsx)(`path`,{d:`M6 20v-4`})]}),De=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,A.jsx)(`path`,{d:`M4 5v6c0 1.66 3.58 3 8 3s8-1.34 8-3V5`}),(0,A.jsx)(`path`,{d:`M4 11v6c0 1.66 3.58 3 8 3s8-1.34 8-3v-6`})]}),Oe=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,A.jsx)(`path`,{d:`M3 10h18`}),(0,A.jsx)(`path`,{d:`M9 10v10`})]}),ke=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,A.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z`})]}),Ae=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,A.jsx)(`path`,{d:`M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41`})]}),je=e=>(0,A.jsx)(N,{...e,children:(0,A.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79Z`})}),Me=e=>(0,A.jsx)(N,{...e,children:(0,A.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),Ne=e=>(0,A.jsx)(N,{...e,children:(0,A.jsx)(`polyline`,{points:`9 18 15 12 9 6`})}),Pe=e=>(0,A.jsx)(N,{...e,children:(0,A.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})}),Fe=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`rect`,{x:`6`,y:`4`,width:`4`,height:`16`}),(0,A.jsx)(`rect`,{x:`14`,y:`4`,width:`4`,height:`16`})]}),Ie=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`polyline`,{points:`3 6 5 6 21 6`}),(0,A.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})]}),Le=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`polyline`,{points:`23 4 23 10 17 10`}),(0,A.jsx)(`polyline`,{points:`1 20 1 14 7 14`}),(0,A.jsx)(`path`,{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`})]}),Re=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,A.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),ze=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`path`,{d:`M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8Z`}),(0,A.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]}),R=e=>(0,A.jsx)(N,{...e,children:(0,A.jsx)(`polygon`,{points:`13 2 3 14 12 14 11 22 21 10 12 10 13 2`})}),z=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,A.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]}),Be=e=>(0,A.jsx)(N,{...e,children:(0,A.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),B=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,A.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]}),Ve=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,A.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]}),He=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`line`,{x1:`3`,y1:`6`,x2:`21`,y2:`6`}),(0,A.jsx)(`line`,{x1:`3`,y1:`12`,x2:`21`,y2:`12`}),(0,A.jsx)(`line`,{x1:`3`,y1:`18`,x2:`21`,y2:`18`})]}),Ue=e=>(0,A.jsxs)(N,{...e,children:[(0,A.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,A.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,A.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]}),We=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`ApiError`}};async function V(e,t,n=!0){let r=await fetch(y()+e,{...t,headers:{"Content-Type":`application/json`,..._(),...t?.headers}});if(!r.ok){let e=`HTTP ${r.status}`;try{let t=await r.json();t?.error&&(e=t.error)}catch{}throw new We(e,r.status)}if(r.status===204)return;let i=await r.json();if(n&&i&&typeof i==`object`&&i.ok===!1){let e=i.error;throw new We(e??`Operation failed`,r.status)}return i}var H=e=>encodeURIComponent(e),U=(e,t)=>V(e,{method:`POST`,body:t?JSON.stringify(t):void 0}),Ge=(e,t)=>V(e,{method:`PUT`,body:t?JSON.stringify(t):void 0}),W=e=>V(e,{method:`DELETE`}),G={overview:()=>V(`/dashboard`),queues:(e=200,t=0)=>V(`/dashboard/queues?limit=${e}&offset=${t}`),queueDetail:(e,t=!0)=>V(`/dashboard/queues/${H(e)}?includeJobs=${t}`),stats:()=>V(`/stats`),storage:()=>V(`/storage`,void 0,!1),health:()=>V(`/health`,void 0,!1),jobsList:(e,t={})=>{let n=new URLSearchParams;return t.states?.length&&n.set(`states`,t.states.join(`,`)),n.set(`limit`,String(t.limit??50)),n.set(`offset`,String(t.offset??0)),V(`/queues/${H(e)}/jobs/list?${n.toString()}`)},job:e=>V(`/jobs/${H(e)}`),cancelJob:e=>W(`/jobs/${H(e)}`),promoteJob:e=>U(`/jobs/${H(e)}/promote`),retryJob:e=>U(`/jobs/${H(e)}/move-to-wait`),pause:e=>U(`/queues/${H(e)}/pause`),resume:e=>U(`/queues/${H(e)}/resume`),drain:e=>U(`/queues/${H(e)}/drain`),obliterate:e=>U(`/queues/${H(e)}/obliterate`),clean:(e,t=0,n=1e3)=>U(`/queues/${H(e)}/clean`,{grace:t,limit:n}),retryCompleted:e=>U(`/queues/${H(e)}/retry-completed`),setRateLimit:(e,t)=>Ge(`/queues/${H(e)}/rate-limit`,{limit:t}),clearRateLimit:e=>W(`/queues/${H(e)}/rate-limit`),setConcurrency:(e,t)=>Ge(`/queues/${H(e)}/concurrency`,{concurrency:t}),clearConcurrency:e=>W(`/queues/${H(e)}/concurrency`),dlq:(e,t=50,n=0)=>V(`/queues/${H(e)}/dlq?limit=${t}&offset=${n}`),dlqStats:e=>V(`/queues/${H(e)}/dlq/stats`),retryDlq:e=>U(`/queues/${H(e)}/dlq/retry`),purgeDlq:e=>U(`/queues/${H(e)}/dlq/purge`),crons:()=>V(`/crons`),deleteCron:e=>W(`/crons/${H(e)}`),workers:()=>V(`/workers`),eventsUrl:e=>y()+(e?`/events/queues/${H(e)}`:`/events`)};function Ke(e){let t=!0;return()=>t?(t=!1,!0):!e()}function qe(e,t=[],n={}){let r=g(e=>e.refreshMs),i=n.intervalMs??r,[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)(!0),d=(0,b.useRef)(e);d.current=e;let f=(0,b.useRef)(!0),p=(0,b.useRef)(0),m=(0,b.useRef)(void 0),h=(0,b.useRef)(!0),_=(0,b.useRef)(!1),v=(0,b.useCallback)(async()=>{let e=++p.current;try{let t=await d.current();if(!f.current||e!==p.current)return;let n;try{n=JSON.stringify(t)}catch{n=String(Math.random())}n!==m.current&&(m.current=n,o(t)),_.current&&(_.current=!1,c(null))}catch(t){if(!f.current||e!==p.current)return;_.current=!0,c(t)}finally{f.current&&e===p.current&&h.current&&(h.current=!1,u(!1))}},[]);return(0,b.useEffect)(()=>{f.current=!0,m.current=void 0,h.current=!0,u(!0),_.current&&(_.current=!1,c(null));let e=null,t=!1,n=()=>typeof document<`u`&&document.hidden,r=Ke(n),a=async()=>{t||(r()&&await v(),!t&&(e=setTimeout(a,i)))};a();let o=()=>{!n()&&!t&&v()};return typeof document<`u`&&document.addEventListener(`visibilitychange`,o),()=>{t=!0,f.current=!1,e&&clearTimeout(e),typeof document<`u`&&document.removeEventListener(`visibilitychange`,o)}},[i,v,...t]),{data:a,error:s,loading:l,refreshing:l,refetch:v}}function Je(e){try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return t.remove(),n}catch{return!1}}function Ye({value:e,className:n}){let[r,i]=(0,b.useState)(`idle`),a=(0,b.useRef)(null);return(0,b.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]),(0,A.jsx)(`button`,{type:`button`,onClick:async()=>{let t=!1;if(navigator.clipboard)try{await navigator.clipboard.writeText(e),t=!0}catch{}t||=Je(e),i(t?`copied`:`failed`),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(`idle`),1500)},"aria-label":`Copy to clipboard`,title:r===`failed`?`Copy failed`:`Copy to clipboard`,className:t(`inline-flex size-6 shrink-0 items-center justify-center rounded-md text-faint transition-colors hover:bg-surface-2 hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,n),children:r===`copied`?(0,A.jsx)(Be,{className:`size-3.5 text-success`}):r===`failed`?(0,A.jsx)(z,{className:`size-3.5 text-danger`}):(0,A.jsx)(Ve,{className:`size-3.5`})})}var Xe;function K(){return Xe===void 0&&(Xe=Ze()),Xe}function Ze(){if(typeof window>`u`)return!1;let{search:e,hash:t}=window.location;return new URLSearchParams(e).has(`demo`)||t.replace(/^#/,``)===`demo`}var Qe=`https://github.com/egeominotti/bunqueue-dashboard`,$e=`https://egeominotti.github.io/bunqueue-dashboard/docs/`,et=`bunx bunqueue-dashboard`;function tt(){return(0,A.jsxs)(`div`,{className:`mx-3 mb-2 rounded-lg border border-accent/30 bg-accent/5 p-3`,children:[(0,A.jsx)(`p`,{className:`mb-2 text-[11px] font-medium leading-snug text-fg`,children:`Like it? Run it on your own bunqueue server.`}),(0,A.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 rounded-md border border-line bg-surface-2 px-2 py-1`,children:[(0,A.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-fg`,children:et}),(0,A.jsx)(Ye,{value:et})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsxs)(`a`,{href:Qe,target:`_blank`,rel:`noreferrer`,className:`flex flex-1 items-center justify-center gap-1 rounded-md bg-accent px-2 py-1.5 text-[11px] font-semibold text-accent-fg transition-opacity hover:opacity-90`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,children:`★`}),` Star`]}),(0,A.jsx)(`a`,{href:$e,target:`_blank`,rel:`noreferrer`,className:`flex flex-1 items-center justify-center rounded-md border border-line px-2 py-1.5 text-[11px] font-medium text-muted transition-colors hover:bg-surface-2 hover:text-fg`,children:`Docs`})]})]})}function nt(){let e=g(e=>e.baseUrl),t=e===`/api`?`localhost:6790`:e.replace(/^https?:\/\//,``);return(0,A.jsxs)(A.Fragment,{children:[K()&&(0,A.jsx)(tt,{}),(0,A.jsxs)(`div`,{className:`mx-3 mb-3 flex items-center gap-2.5 rounded-lg border border-line bg-surface px-3 py-2`,children:[(0,A.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-accent to-fuchsia-600 text-[11px] font-bold text-white`,children:`bq`}),(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsx)(`div`,{className:`truncate text-xs font-medium text-fg`,children:`bunqueue`}),(0,A.jsx)(`div`,{className:`truncate font-mono text-[10px] text-faint`,title:e,children:t})]}),(0,A.jsx)(d,{to:`/settings`,"aria-label":`Settings`,className:`text-faint transition-colors hover:text-fg`,children:(0,A.jsx)(ke,{className:`size-4`})})]})]})}var rt=[{section:null,items:[{to:`/`,label:`Overview`,icon:xe,end:!0}]},{section:`Queues`,items:[{to:`/queues`,label:`Queues`,icon:P},{to:`/jobs`,label:`Jobs`,icon:F},{to:`/dlq`,label:`Dead Letter Queue`,icon:I},{to:`/cron`,label:`Cron Jobs`,icon:Se},{to:`/flows`,label:`Flows`,icon:B}]},{section:`Monitoring`,items:[{to:`/metrics`,label:`Metrics`,icon:Ce},{to:`/workers`,label:`Workers`,icon:L},{to:`/logs`,label:`Logs`,icon:Te},{to:`/alerts`,label:`Alerts`,icon:we}]},{section:`Control`,items:[{to:`/server`,label:`Server`,icon:L},{to:`/add-job`,label:`Add Job`,icon:F},{to:`/jobs/bulk-add`,label:`Bulk Add`,icon:F},{to:`/job`,label:`Job Inspector`,icon:ze},{to:`/queue-control`,label:`Queue Control`,icon:P},{to:`/dlq-control`,label:`DLQ Control`,icon:I},{to:`/webhooks`,label:`Webhooks`,icon:R},{to:`/diagnostics`,label:`Diagnostics`,icon:Ce},{to:`/benchmark`,label:`Benchmark`,icon:R}]},{section:`Management`,items:[{to:`/database`,label:`Database`,icon:Oe},{to:`/mcp`,label:`MCP`,icon:R},{to:`/usage`,label:`Usage`,icon:Ee},{to:`/s3`,label:`S3 Backup`,icon:De},{to:`/settings`,label:`Settings`,icon:ke}]}];function it(){let e=g(e=>e.baseUrl),{data:n,error:r,loading:i}=qe(async()=>({ok:(await G.health()).ok}),[],{intervalMs:15e3}),a=!r&&n!=null&&n.ok!==!1,o=e.replace(/^https?:\/\//,``)||`local`;return(0,A.jsxs)(`div`,{className:`mx-3 mb-4 flex items-center gap-2 rounded-lg border border-line bg-surface px-3 py-1.5`,children:[(0,A.jsx)(`span`,{className:t(`size-1.5 rounded-full`,i?`bg-zinc-500`:a?`bg-emerald-400`:`bg-red-400`),title:i?`connecting`:a?`connected`:`offline`}),(0,A.jsx)(`span`,{className:`truncate font-mono text-[11px] text-muted`,title:e,children:o}),(0,A.jsx)(`span`,{className:`sr-only`,children:i?`connecting`:a?`connected`:`offline`})]})}function at(){let e=M(e=>e.theme),t=M(e=>e.toggle),n=e===`dark`;return(0,A.jsxs)(`button`,{type:`button`,onClick:t,className:`mx-3 mb-3 flex items-center gap-3 rounded-lg px-3 py-2 text-sm text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[n?(0,A.jsx)(Ae,{className:`size-4`}):(0,A.jsx)(je,{className:`size-4`}),n?`Light Mode`:`Dark Mode`]})}function ot({open:e=!1,onClose:n}){return(0,A.jsxs)(A.Fragment,{children:[e&&(0,A.jsx)(`button`,{type:`button`,"aria-label":`Close navigation`,onClick:n,className:`fixed inset-0 z-40 bg-black/50 lg:hidden`}),(0,A.jsxs)(`aside`,{id:`app-nav`,className:t(`flex w-60 shrink-0 flex-col border-r border-line bg-sidebar`,`fixed inset-y-0 left-0 z-50 transition-[transform,visibility] lg:static lg:z-auto lg:translate-x-0`,e?`translate-x-0`:`-translate-x-full lg:translate-x-0 invisible lg:visible`),children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-5`,children:[(0,A.jsx)(`span`,{className:`text-lg font-bold tracking-tight text-fg`,children:`bunqueue`}),(0,A.jsx)(`span`,{className:`rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider text-accent`,children:`dash`}),(0,A.jsx)(`span`,{title:`Beta — under active development`,className:`rounded-md bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider text-warning`,children:`beta`})]}),(0,A.jsx)(`nav`,{className:`flex-1 overflow-y-auto px-3 pb-4`,children:rt.map(e=>(0,A.jsxs)(`div`,{className:`mb-4`,children:[e.section&&(0,A.jsx)(`div`,{className:`px-2 pb-2 pt-1 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:e.section}),(0,A.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.items.map(({to:e,label:n,icon:r,end:i})=>(0,A.jsx)(a,{to:e,end:i,className:({isActive:e})=>t(`group relative flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,e?`bg-surface-2 text-fg`:`text-muted hover:bg-surface-2/60 hover:text-fg`),children:({isActive:e})=>(0,A.jsxs)(A.Fragment,{children:[e&&(0,A.jsx)(`span`,{className:`absolute inset-y-1.5 left-0 w-0.5 rounded-full bg-accent`}),(0,A.jsx)(r,{className:`size-[18px] shrink-0`}),(0,A.jsx)(`span`,{className:`truncate`,children:n})]})},e))})]},e.section??`root`))}),(0,A.jsx)(it,{}),(0,A.jsx)(at,{}),(0,A.jsx)(nt,{})]})]})}var st=`https://egeominotti.github.io/bunqueue-dashboard/docs/`;function ct(){let[e,t]=(0,b.useState)(!1),[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(0),o=m(),s=M(e=>e.toggle),c=(0,b.useRef)(null),l=(0,b.useRef)(null),u=(0,b.useMemo)(()=>{let e=rt.flatMap(e=>e.items.map(t=>({id:`nav:${t.to}`,label:t.label,hint:e.section??`Home`,run:()=>o(t.to)}))),t=[{id:`act:theme`,label:`Toggle theme (dark / light)`,hint:`Action`,run:s},{id:`act:docs`,label:`Open documentation`,hint:`Action`,run:()=>window.open(st,`_blank`,`noopener`)}];return[...e,...t]},[o,s]),d=(0,b.useMemo)(()=>{let e=n.trim().toLowerCase();return e?u.filter(t=>`${t.label} ${t.hint}`.toLowerCase().includes(e)):u},[u,n]);(0,b.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),t(e=>!e))},n=()=>t(!0);return window.addEventListener(`keydown`,e),window.addEventListener(`command-palette:open`,n),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`command-palette:open`,n)}},[]),(0,b.useEffect)(()=>{if(!e)return;let t=document.activeElement;r(``),a(0);let n=requestAnimationFrame(()=>c.current?.focus());return()=>{cancelAnimationFrame(n),t?.focus?.()}},[e]),(0,b.useEffect)(()=>{l.current?.querySelector(`[data-idx="${i}"]`)?.scrollIntoView({block:`nearest`})},[i]);let f=(0,b.useCallback)(()=>t(!1),[]),p=(0,b.useCallback)(e=>{e&&(e.run(),t(!1))},[]);return e?(0,A.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center p-4 pt-[12vh]`,children:[(0,A.jsx)(`button`,{type:`button`,"aria-label":`Close command palette`,onClick:f,className:`fixed inset-0 bg-black/50`}),(0,A.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:`relative z-10 w-full max-w-lg overflow-hidden rounded-xl border border-line-strong bg-surface shadow-2xl`,children:[(0,A.jsx)(`input`,{ref:c,value:n,onChange:e=>{r(e.target.value),a(0)},onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),f()):e.key===`ArrowDown`?(e.preventDefault(),a(e=>Math.min(e+1,d.length-1))):e.key===`ArrowUp`?(e.preventDefault(),a(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),p(d[i]))},placeholder:`Search pages and actions…`,"aria-label":`Search pages and actions`,className:`w-full border-b border-line bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-faint`}),(0,A.jsxs)(`ul`,{ref:l,className:`max-h-80 overflow-y-auto py-2`,"aria-label":`Results`,children:[d.length===0&&(0,A.jsx)(`li`,{className:`px-4 py-6 text-center text-sm text-faint`,children:`No matches`}),d.map((e,t)=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`button`,{type:`button`,"data-idx":t,onMouseEnter:()=>a(t),onClick:()=>p(e),className:`flex w-full items-center justify-between gap-3 px-4 py-2 text-left text-sm transition-colors ${t===i?`bg-accent/15 text-fg`:`text-muted`}`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:e.label}),(0,A.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e.hint})]})},e.id))]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-t border-line px-4 py-2 text-xs text-faint`,children:[(0,A.jsx)(`span`,{children:`↑↓ navigate · ↵ open · esc close`}),(0,A.jsx)(`span`,{className:`font-mono`,children:`⌘K`})]})]})]}):null}var lt=()=>typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}`,q=new Map,J=(e,t,n)=>e.map(e=>e.id===t?n(e):e);function ut(e){return{config:{provider:e.config.provider,baseURL:e.config.baseURL,model:e.config.model}}}var dt=v()(h(e=>({open:!1,config:{provider:`anthropic`,baseURL:``,model:`claude-opus-4-8`,apiKey:``},messages:[],pending:[],busy:!1,setOpen:t=>e({open:t}),toggle:()=>e(e=>({open:!e.open})),setConfig:t=>e(e=>({config:{...e.config,...t}})),clear:()=>{for(let e of q.values())e(!1);q.clear(),e({messages:[],pending:[]})},cancelPending:()=>{for(let e of q.values())e(!1);q.clear(),e({pending:[]})},setBusy:t=>e({busy:t}),addUser:t=>e(e=>({messages:[...e.messages,{id:lt(),role:`user`,content:t}]})),startAssistant:()=>{let t=lt();return e(e=>({messages:[...e.messages,{id:t,role:`assistant`,content:``,tools:[]}]})),t},appendAssistant:(t,n)=>e(e=>({messages:J(e.messages,t,e=>({...e,content:e.content+n}))})),finishAssistant:(t,n)=>e(e=>({messages:J(e.messages,t,e=>({...e,done:!0,error:!!n?.error,content:n?.error?e.content||n.error:e.content}))})),addTool:(t,n)=>e(e=>({messages:J(e.messages,t,e=>({...e,tools:[...e.tools??[],n]}))})),updateTool:(t,n,r)=>e(e=>({messages:J(e.messages,t,e=>({...e,tools:(e.tools??[]).map(e=>e.id===n?{...e,...r}:e)}))})),requestConfirm:t=>new Promise(n=>{let r=lt();q.set(r,n),e(e=>({pending:[...e.pending,{...t,id:r}]}))}),resolveConfirm:(t,n)=>{let r=q.get(t);r&&(q.delete(t),r(n)),e(e=>({pending:e.pending.filter(e=>e.id!==t)}))}}),{name:`bq-dash-copilot`,partialize:e=>ut(e),merge:(e,t)=>{let n=e??{};return{...t,config:{...t.config,...n.config??{},apiKey:``}}}})),ft=(0,b.lazy)(()=>u(()=>import(`./CopilotPanel-DZUGIf1q.js`).then(e=>({default:e.CopilotPanel})),__vite__mapDeps([0,1,2,3,4])));function pt({className:e}){return(0,A.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,A.jsx)(`path`,{d:`M12 3l1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3z`,fill:`currentColor`}),(0,A.jsx)(`path`,{d:`M19 14l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8.8-2z`,fill:`currentColor`,opacity:`0.7`})]})}function mt(){let e=dt(e=>e.open),t=dt(e=>e.setOpen);return(0,A.jsxs)(A.Fragment,{children:[!e&&(0,A.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`fixed bottom-5 right-5 z-40 flex items-center gap-2 rounded-full border border-line bg-surface px-4 py-2.5 text-sm font-medium text-fg shadow-lg transition-colors hover:border-accent/50 hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,"aria-label":`Open Copilot`,children:[(0,A.jsx)(pt,{className:`size-4 text-accent`}),`Copilot`,(0,A.jsx)(`span`,{className:`rounded bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-accent`,children:`beta`})]}),e&&(0,A.jsx)(b.Suspense,{fallback:(0,A.jsx)(`div`,{className:`fixed inset-y-0 right-0 z-[60] flex w-full max-w-md items-center justify-center border-l border-line bg-surface text-sm text-muted`,children:`Loading Copilot…`}),children:(0,A.jsx)(ft,{})})]})}var ht={default:`border border-line bg-surface-2 text-fg hover:bg-surface-2/70 hover:border-line-strong`,ghost:`text-muted hover:text-fg hover:bg-surface-2`,accent:`bg-accent text-accent-fg hover:opacity-90 border border-transparent`,danger:`border border-red-500/30 text-danger hover:bg-red-500/10 hover:border-red-500/50`,warning:`border border-amber-500/30 text-warning hover:bg-amber-500/10 hover:border-amber-500/50`,success:`bg-emerald-500 text-white hover:bg-emerald-500/90 border border-transparent`},gt={sm:`h-8 px-3 text-xs gap-1.5`,md:`h-9 px-4 text-sm gap-2`};function _t({children:e,variant:n=`default`,size:r=`md`,className:i,...a}){return(0,A.jsx)(`button`,{type:`button`,className:t(`inline-flex items-center justify-center rounded-lg font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,`disabled:cursor-not-allowed disabled:opacity-50`,ht[n],gt[r],i),...a,children:e})}function vt({children:e,className:n,variant:r=`ghost`,...i}){return(0,A.jsx)(`button`,{type:`button`,className:t(`inline-flex size-8 items-center justify-center rounded-lg transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,`disabled:cursor-not-allowed disabled:opacity-50`,ht[r],n),...i,children:e})}function Y({children:e,className:n,padded:r=!0}){return(0,A.jsx)(`div`,{className:t(`rounded-xl border border-line bg-surface`,r&&`p-5`,n),children:e})}function yt({title:e,action:t,icon:n}){return(0,A.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[n,e]}),t]})}function bt({className:e}){return(0,A.jsx)(`span`,{className:t(`inline-block size-4 animate-spin rounded-full border-2 border-current border-t-transparent`,e),role:`status`,"aria-label":`Loading`})}function xt({label:e=`Loading…`}){return(0,A.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-16 text-sm text-muted`,children:[(0,A.jsx)(bt,{}),e]})}function St({icon:e,title:t,hint:n,action:r}){return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-line py-14 text-center`,children:[e&&(0,A.jsx)(`div`,{className:`text-faint [&>svg]:size-8`,children:e}),(0,A.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t}),n&&(0,A.jsx)(`div`,{className:`max-w-sm text-xs text-faint`,children:n}),r&&(0,A.jsx)(`div`,{className:`mt-2`,children:r})]})}function Ct({onRetry:e,message:t=`Not connected to the bunqueue server — showing empty data.`}){return(0,A.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3 rounded-lg border border-amber-500/25 bg-amber-500/[0.06] px-4 py-2.5 text-sm`,children:[(0,A.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-amber-400`,"aria-hidden":`true`}),(0,A.jsx)(`span`,{className:`text-amber-300/90 light:text-amber-700`,children:t}),e&&(0,A.jsx)(`button`,{type:`button`,onClick:e,className:`ml-auto shrink-0 rounded-md border border-amber-500/30 px-2.5 py-1 text-xs font-medium text-amber-200 light:text-amber-700 hover:border-amber-400/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Retry`})]})}function wt({error:e,onRetry:t}){return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 rounded-xl border border-red-500/20 bg-red-500/5 py-14 text-center`,children:[(0,A.jsx)(`div`,{className:`text-sm font-medium text-danger`,children:`Something went wrong`}),(0,A.jsx)(`div`,{className:`max-w-md text-xs text-faint`,children:e.message}),t&&(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`mt-1 rounded-lg border border-line bg-surface-2 px-3 py-1.5 text-xs font-medium text-fg hover:border-line-strong`,children:`Retry`})]})}var Tt=class extends b.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught an error`,e,t.componentStack)}componentDidUpdate(e){this.state.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){let{error:e}=this.state;return e?(0,A.jsx)(`div`,{className:`flex min-h-screen items-center justify-center p-6`,children:(0,A.jsxs)(Y,{className:`w-full max-w-lg`,children:[(0,A.jsx)(wt,{error:e}),(0,A.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,A.jsx)(_t,{onClick:()=>window.location.reload(),children:`Reload`})})]})}):this.props.children}},Et={success:{bar:`bg-emerald-500`,title:`text-success`},error:{bar:`bg-red-500`,title:`text-danger`},info:{bar:`bg-accent`,title:`text-accent`}};function Dt({toast:e,dismiss:n}){(0,b.useEffect)(()=>{let t=window.setTimeout(()=>n(e.id),e.ttlMs);return()=>window.clearTimeout(t)},[e.id,e.ttlMs,n]);let r=Et[e.level];return(0,A.jsxs)(`div`,{className:`pointer-events-auto flex w-80 max-w-[calc(100vw-2rem)] overflow-hidden rounded-lg border border-line bg-surface shadow-lg`,children:[(0,A.jsx)(`span`,{className:t(`w-1 shrink-0`,r.bar),"aria-hidden":`true`}),(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3 px-3 py-2.5`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsx)(`div`,{className:t(`text-sm font-medium`,r.title),children:e.title}),e.detail&&(0,A.jsx)(`div`,{className:`mt-0.5 break-words text-xs text-muted`,children:e.detail})]}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-label":`Dismiss notification`,className:`-mr-1 shrink-0 rounded p-0.5 text-faint hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,A.jsx)(z,{className:`size-4`})})]})]})}function Ot(){let e=C(e=>e.toasts),t=C(e=>e.dismiss);return e.length===0?null:(0,A.jsx)(`section`,{className:`pointer-events-none fixed bottom-4 right-4 z-[60] flex flex-col gap-2`,"aria-label":`Notifications`,"aria-live":`polite`,children:e.map(e=>(0,A.jsx)(Dt,{toast:e,dismiss:t},e.id))})}var kt=K(),At={"/":`Overview`,"/queues":`Queues`,"/jobs":`Jobs`,"/dlq":`Dead Letter Queue`,"/cron":`Cron Jobs`,"/flows":`Flows`,"/metrics":`Metrics`,"/workers":`Workers`,"/logs":`Logs`,"/server":`Server`,"/add-job":`Add Job`,"/jobs/bulk-add":`Bulk Add Jobs`,"/job":`Job Inspector`,"/queue-control":`Queue Control`,"/dlq-control":`DLQ Control`,"/webhooks":`Webhooks`,"/diagnostics":`Diagnostics`,"/alerts":`Alerts`,"/benchmark":`Benchmark`,"/database":`Database`,"/mcp":`MCP`,"/usage":`Usage`,"/s3":`S3 Backup`,"/settings":`Settings`,"/overview-classic":`Overview (classic)`,"/queues-classic":`Queues (classic)`,"/jobs-classic":`Jobs (classic)`,"/dlq-classic":`DLQ (classic)`,"/metrics-classic":`Metrics (classic)`,"/logs-classic":`Logs (classic)`,"/s3-classic":`S3 Backup (classic)`};function jt(e){if(At[e])return At[e];if(e.startsWith(`/queues/`)){let t=e.slice(8);try{t=decodeURIComponent(t)}catch{}return`${t} · Queue`}return`bunqueue`}function Mt({onMenu:e,navOpen:t=!1}){let{pathname:n}=o();return(0,A.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-14 items-center justify-between gap-3 border-b border-line bg-bg/80 px-4 backdrop-blur sm:px-6 lg:px-8`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,A.jsx)(`button`,{type:`button`,"aria-label":`Open navigation`,"aria-expanded":t,"aria-controls":`app-nav`,onClick:e,className:`-ml-1 flex size-9 shrink-0 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 lg:hidden`,children:(0,A.jsx)(He,{className:`size-5`})}),(0,A.jsxs)(`div`,{className:`truncate text-sm text-muted`,children:[(0,A.jsx)(`span`,{className:`text-faint`,children:jt(n)}),(0,A.jsx)(`span`,{className:`mx-2 hidden text-faint sm:inline`,children:`·`}),(0,A.jsx)(`span`,{className:`hidden text-faint sm:inline`,children:`bunqueue`})]})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[kt&&(0,A.jsxs)(`span`,{title:`Showing canned sample data. No real bunqueue server is connected.`,className:`hidden items-center gap-1.5 rounded-full border border-accent/40 bg-accent/10 px-2.5 py-1 text-xs font-medium text-accent sm:inline-flex`,children:[(0,A.jsx)(`span`,{className:`size-1.5 rounded-full bg-accent`}),`Live demo`]}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>window.dispatchEvent(new Event(`command-palette:open`)),title:`Command palette`,"aria-label":`Open command palette`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 sm:hidden`,children:(0,A.jsx)(Re,{className:`size-5`})}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>window.dispatchEvent(new Event(`command-palette:open`)),title:`Command palette (⌘K)`,"aria-label":`Open command palette`,className:`hidden items-center gap-2 rounded-lg border border-line px-2.5 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 sm:flex`,children:[(0,A.jsx)(`span`,{children:`Search`}),(0,A.jsx)(`kbd`,{className:`rounded border border-line bg-surface-2 px-1 font-mono text-[10px]`,children:`⌘K`})]}),(0,A.jsx)(d,{to:`/settings`,title:`Settings`,"aria-label":`Open settings`,className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-accent to-fuchsia-600 text-xs font-bold text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`bq`})]})]})}function Nt(){let[e,n]=(0,b.useState)(!1),{pathname:r,key:i}=o();return(0,b.useEffect)(()=>n(!1),[r]),(0,b.useEffect)(()=>{let e=window.matchMedia(`(min-width: 1024px)`),t=()=>e.matches&&n(!1);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,b.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,b.useEffect)(()=>{if(!e)return;let t=document.activeElement,n=()=>{let e=document.getElementById(`app-nav`);return e?Array.from(e.querySelectorAll(`a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])`)):[]};n()[0]?.focus();let r=e=>{if(e.key!==`Tab`)return;let t=n();if(!t.length)return;let r=t[0],i=t[t.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r.focus())};return window.addEventListener(`keydown`,r),()=>{window.removeEventListener(`keydown`,r),t?.focus?.()}},[e]),(0,A.jsx)(Tt,{children:(0,A.jsxs)(`div`,{className:`flex h-screen overflow-hidden bg-bg text-fg`,children:[(0,A.jsx)(`a`,{href:`#main`,className:`sr-only rounded-md bg-accent px-3 py-2 text-sm font-medium text-accent-fg shadow-lg focus:not-sr-only focus:absolute focus:left-4 focus:top-3 focus:z-50`,children:`Skip to content`}),(0,A.jsx)(ot,{open:e,onClose:()=>n(!1)}),(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,A.jsx)(Mt,{navOpen:e,onMenu:()=>n(!0)}),(0,A.jsx)(`main`,{id:`main`,tabIndex:-1,className:t(`flex-1 px-4 pt-5 pb-24 outline-none sm:px-6 lg:px-8 lg:pt-6`,e?`overflow-hidden`:`overflow-y-auto`),children:(0,A.jsx)(b.Suspense,{fallback:(0,A.jsx)(`div`,{className:`p-2 text-sm text-muted`,children:`Loading…`}),children:(0,A.jsx)(Tt,{resetKey:i,children:(0,A.jsx)(l,{})})})})]}),(0,A.jsx)(ct,{}),(0,A.jsx)(ye,{}),(0,A.jsx)(mt,{}),(0,A.jsx)(Ot,{}),(0,A.jsx)(ve,{})]})})}var Pt={completed:`text-success bg-emerald-500/10`,active:`text-blue-400 light:text-blue-700 bg-blue-500/10`,failed:`text-danger bg-red-500/10`,waiting:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,prioritized:`text-violet-400 light:text-violet-700 bg-violet-500/10`,delayed:`text-warning bg-amber-500/10`,paused:`text-orange-400 light:text-orange-700 bg-orange-500/10`,"waiting-children":`text-cyan-400 light:text-cyan-700 bg-cyan-500/10`,stalled:`text-orange-400 light:text-orange-700 bg-orange-500/10`,enqueued:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,started:`text-blue-400 light:text-blue-700 bg-blue-500/10`,finished:`text-success bg-emerald-500/10`,retry:`text-warning bg-amber-500/10`,cancelled:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,default:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`};function Ft({status:e}){let n=(e||``).toLowerCase();return(0,A.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium capitalize`,Pt[n]??Pt.default),children:[(0,A.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e||`unknown`]})}function It({label:e,tone:n=`green`}){return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted`,children:[(0,A.jsx)(`span`,{className:t(`size-1.5 rounded-full`,n===`green`?`bg-emerald-400`:n===`amber`?`bg-amber-400`:n===`red`?`bg-red-400`:`bg-zinc-400`)}),e]})}function Lt({title:e,description:t,live:n,actions:r,back:i}){return(0,A.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[i,(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg`,children:e}),n&&(0,A.jsx)(It,{label:`Live`,tone:`green`})]}),t&&(0,A.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:t})]})]}),r&&(0,A.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:r})]})}var Rt={default:`text-fg`,green:`text-success`,red:`text-danger`,blue:`text-blue-400 light:text-blue-700`,amber:`text-warning`,accent:`text-accent`};function X({label:e,value:n,tone:r=`default`,hint:i,compact:a}){return(0,A.jsxs)(`div`,{className:t(`rounded-xl border border-line bg-surface`,a?`px-4 py-3`:`px-5 py-4`),children:[(0,A.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,A.jsx)(`div`,{className:t(`mt-2 font-semibold tnum`,a?`text-xl`:`text-3xl`,Rt[r]),children:n}),i!=null&&(0,A.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:i})]})}var zt=new Intl.NumberFormat(`de-DE`),Bt=new Intl.DateTimeFormat(`it-IT`,{day:`2-digit`,month:`2-digit`,year:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`});function Z(e){return e==null||!Number.isFinite(e)?`0`:zt.format(e)}function Vt(e,t=2){return e==null||!Number.isFinite(e)?`0%`:`${(e*100).toFixed(t)}%`}function Ht(e,t){let n=e+t;return n>0?t/n:null}function Ut(e){if(e==null||!Number.isFinite(e))return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:Bt.format(t)}function Wt(e,t=Date.now()){if(e==null||!Number.isFinite(e))return`—`;let n=Math.max(0,t-e),r=Math.floor(n/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function Gt(e){if(e==null||!Number.isFinite(e)||e<0)return`—`;let t=Math.round(e);if(t<1e3)return`${t}ms`;let n=e/1e3;if(n<59.95)return`${n.toFixed(1)}s`;let r=Math.round(n);return`${Math.floor(r/60)}m ${r%60}s`}function Kt(e,t){if(e==null||t==null)return;let n=t-e;return n>=0?n:void 0}function qt(e){if(e==null||!Number.isFinite(e))return`—`;let t=Math.floor(e),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60),a=[];return n&&a.push(`${n}d`),(r||n)&&a.push(`${r}h`),a.push(`${i}m`),a.join(` `)}function Jt(e){return e==null||!Number.isFinite(e)?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(Math.round(e))}function Yt(e){if(e==null||!Number.isFinite(e))return`—`;if(e>=1e3)return`${(e/1e3).toFixed(2)}s`;let t=+(e<10);return Number(e.toFixed(t))>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(t)}ms`}var Xt=/(?:\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b[@-Z\\^_])/g;function Zt(e){return e.replace(Xt,``)}function Qt(e){if(e==null||!Number.isFinite(e))return`—`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n.toFixed(r===0?0:1)} ${t[r]}`}function $t(e){return!0}function en(e){let t=`message`,n,r=[];for(let i of e.split(`
3
+ `)){if(!i||i.startsWith(`:`))continue;let e=i.indexOf(`:`),a=e===-1?i:i.slice(0,e),o=e===-1?``:i.slice(e+1).replace(/^ /,``);a===`event`?t=o:a===`data`?r.push(o):a===`id`&&(n=o)}if(r.length===0)return null;let i=r.join(`
4
+ `),a=i;try{a=JSON.parse(i)}catch{}return{id:n,event:t,data:a}}async function tn(e,t,n){let r=await fetch(e,{headers:{Accept:`text/event-stream`,..._()},signal:n});if(!r.ok||!r.body)throw Error(`SSE connect failed: HTTP ${r.status}`);let i=r.body.getReader(),a=new TextDecoder,o=``;try{for(;;){let{done:e,value:n}=await i.read();if(e)break;for(o+=a.decode(n,{stream:!0});;){let e=o.indexOf(`
5
+
6
+ `),n=o.indexOf(`\r
7
+ \r
8
+ `),r,i;if(e!==-1&&(n===-1||e<=n))r=e,i=2;else if(n!==-1)r=n,i=4;else break;let a=o.slice(0,r);o=o.slice(r+i);let s=en(a.replace(/\r/g,``));s&&t(s)}}}finally{i.releaseLock()}}var Q={total:0,completed:0,failed:0,waiting:0,active:0},nn=250;function rn(e){let t=e.includes(`:`)?e.split(`:`)[1]:e;switch(t){case`pushed`:case`added`:return`waiting`;case`pulled`:return`active`;case`progress`:return`active`;default:return t}}function an(e){let t=g(e=>e.baseUrl),n=g(e=>e.token),[r,i]=(0,b.useState)([]),[a,o]=(0,b.useState)(Q),[s,c]=(0,b.useState)(0),[l,u]=(0,b.useState)(!1),d=(0,b.useRef)([]),f=(0,b.useRef)([]),p=(0,b.useRef)({...Q});return(0,b.useEffect)(()=>{let t=new AbortController,n=0,r=!1;i([]),o(Q),d.current=[],f.current=[],p.current={...Q};let a=e=>new Promise(n=>{let r=()=>{clearTimeout(i),n()},i=setTimeout(()=>{t.signal.removeEventListener(`abort`,r),n()},e);t.signal.addEventListener(`abort`,r,{once:!0})}),s=e=>{if($t(e)&&u(!0),!e.event.startsWith(`job:`))return;let t=e.data??{},r=rn(e.event),i={seq:++n,event:e.event,queue:t.queue,jobId:t.jobId,name:t.name,status:r,timestamp:t.timestamp??Date.now(),error:t.error,progress:t.progress};f.current.push(i);let a=p.current;a.total+=1,r===`completed`?a.completed+=1:r===`failed`?a.failed+=1:r===`waiting`?a.waiting+=1:r===`active`&&(a.active+=1),d.current.push(Date.now())};(async()=>{for(;!r;){try{await tn(G.eventsUrl(e),s,t.signal)}catch{}if(r)break;u(!1),await a(2e3)}})();let c=setInterval(()=>{if(f.current.length){let e=f.current;f.current=[],e.reverse(),i(t=>[...e,...t].slice(0,nn))}let e=p.current;e.total&&(p.current={...Q},o(t=>({total:t.total+e.total,completed:t.completed+e.completed,failed:t.failed+e.failed,waiting:t.waiting+e.waiting,active:t.active+e.active})))},150);return()=>{r=!0,t.abort(),clearInterval(c),u(!1)}},[e,t,n]),(0,b.useEffect)(()=>{let e=setInterval(()=>{let e=Date.now();d.current=d.current.filter(t=>e-t<5e3),c(d.current.length/5)},1e3);return()=>clearInterval(e)},[]),{events:r,counters:a,throughput:s,connected:l}}var on={overview:{stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},memory:{heapUsed:0,heapTotal:0,rss:0},crons:{total:0}},queuesTotal:0,details:[],failedTotal:0},sn=100;function cn(){let e=g(e=>e.baseUrl),n=(0,b.useRef)(null),{data:r,error:i,loading:a,refetch:o}=qe(async()=>{let[e,t]=await Promise.all([k.overview(),k.queuesSummary()]),r=[...t].sort((e,t)=>(t.counts?.failed??0)-(e.counts?.failed??0)||(t.counts?.waiting??0)-(e.counts?.waiting??0)).slice(0,6).map(e=>({name:e.name,paused:e.paused,counts:e.counts})),i=t.reduce((e,t)=>e+(t.counts?.failed??0),0);return n.current=Date.now(),{overview:e,queuesTotal:t.length,details:r,failedTotal:i}},[]);if(a&&!r&&!i)return(0,A.jsx)(xt,{label:`Loading overview…`});let{overview:s,queuesTotal:c,details:l,failedTotal:u}=r??on,{stats:f,throughput:p,memory:m,crons:h}=s,_=Ht(f.completed,u),v=e===`/api`?`localhost:6790`:e.replace(/^https?:\/\//,``),y=f.uptime?qt(f.uptime/1e3):`—`,ee=Qt(m.rss*1024*1024),x=!!i;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(Lt,{title:`Overview`,description:`Real-time system health at a glance.`,live:!0}),i&&(0,A.jsx)(Ct,{onRetry:o}),(0,A.jsxs)(`div`,{className:t(`mb-6 flex flex-wrap items-center justify-between gap-y-2 rounded-xl border px-5 py-4`,x?`border-amber-500/25 bg-amber-500/[0.06]`:`border-emerald-500/25 bg-emerald-500/[0.06]`),children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,A.jsxs)(`span`,{className:`relative flex size-2.5`,children:[!x&&(0,A.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-emerald-400 opacity-60`}),(0,A.jsx)(`span`,{className:t(`relative inline-flex size-2.5 rounded-full`,x?`bg-amber-400`:`bg-emerald-400`)})]}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`div`,{className:t(`font-semibold`,x?`text-warning`:`text-success`),children:x?`Connection lost — showing last known data`:`bunqueue server connected`}),(0,A.jsxs)(`div`,{className:`truncate font-mono text-xs text-muted`,children:[v,` · uptime `,y,` · `,ee,` RAM`,x&&(0,A.jsxs)(A.Fragment,{children:[` `,`· last updated `,n.current?Wt(n.current):`never`]})]})]})]}),(0,A.jsx)(`span`,{className:t(`rounded-full px-3 py-1 text-xs font-medium`,x?`bg-amber-500/15 text-warning`:`bg-emerald-500/15 text-success`),children:x?`Stale`:`Online`})]}),(0,A.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,A.jsx)(X,{label:`Error Rate`,value:_==null?`—`:Vt(_),tone:_==null?`default`:_>.05?`red`:`green`,hint:`failed / processed`}),(0,A.jsx)(X,{label:`Failed`,value:Z(u),tone:u?`red`:`default`,hint:`recorded across queues`}),(0,A.jsx)(X,{label:`DLQ`,value:Z(f.dlq),tone:f.dlq?`red`:`default`,hint:`dead-lettered jobs`})]}),(0,A.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,A.jsx)(X,{label:`Completed`,value:Z(f.completed),tone:`green`,compact:!0}),(0,A.jsx)(X,{label:`Active`,value:Z(f.active),tone:`blue`,compact:!0}),(0,A.jsx)(X,{label:`Waiting`,value:Z(f.waiting),tone:f.waiting>sn?`amber`:`default`,compact:!0}),(0,A.jsx)(X,{label:`Push/sec`,value:p.pushPerSec.toFixed(1),tone:`accent`,hint:`${Jt(f.totalPushed)} since restart`,compact:!0}),(0,A.jsx)(X,{label:`Pull/sec`,value:p.pullPerSec.toFixed(1),tone:`accent`,hint:`${Jt(f.totalPulled)} since restart`,compact:!0}),(0,A.jsx)(X,{label:`Queues`,value:Z(c),hint:`${h.total} cron active`,compact:!0})]}),(0,A.jsxs)(`div`,{className:`mt-8`,children:[(0,A.jsx)(un,{title:`Queue Health — most loaded`,to:`/queues`}),l.length===0?(0,A.jsx)(Y,{children:(0,A.jsx)(`p`,{className:`py-4 text-center text-sm text-faint`,children:`No queues yet.`})}):(0,A.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3`,children:l.map(e=>(0,A.jsxs)(d,{to:`/queues/${encodeURIComponent(e.name)}`,className:`rounded-xl border border-line bg-surface p-4 transition-colors hover:border-line-strong`,children:[(0,A.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,A.jsx)(`span`,{className:`truncate font-mono text-sm font-medium text-accent`,children:e.name}),(0,A.jsx)(`span`,{className:t(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 font-mono text-xs text-faint`,children:[(0,A.jsx)($,{label:`W`,value:e.counts?.waiting,tone:`text-warning`}),(0,A.jsx)($,{label:`A`,value:e.counts?.active,tone:`text-blue-400`}),(0,A.jsx)($,{label:`C`,value:e.counts?.completed,tone:`text-success`}),(0,A.jsx)($,{label:`F`,value:e.counts?.failed,tone:`text-danger`})]})]},e.name))})]}),(0,A.jsx)(ln,{})]})}function ln(){let{events:e,connected:n}=an();return(0,A.jsxs)(`div`,{className:`mt-8`,children:[(0,A.jsx)(un,{title:`Recent Activity`,to:`/logs`}),(0,A.jsxs)(Y,{padded:!1,children:[!n&&e.length>0&&(0,A.jsx)(`p`,{className:`border-b border-line px-5 py-2 text-xs text-warning`,children:`Event stream disconnected — reconnecting…`}),e.length===0?(0,A.jsx)(`p`,{className:`py-8 text-center text-sm text-faint`,children:n?`Waiting for live activity…`:`Connecting to the event stream…`}):(0,A.jsx)(`ul`,{className:`divide-y divide-line`,children:e.slice(0,8).map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:t(`size-2 rounded-full`,dn(e.status))}),(0,A.jsxs)(`div`,{className:`text-sm`,children:[(0,A.jsx)(`span`,{className:`font-mono font-medium text-fg`,children:e.queue||`—`}),(0,A.jsx)(`span`,{className:`text-faint`,children:` · `}),(0,A.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.jobId?e.jobId.slice(0,8):`—`}),(0,A.jsx)(`span`,{className:`text-faint`,children:` · `}),(0,A.jsx)(`span`,{className:`capitalize text-muted`,children:e.status})]})]}),(0,A.jsx)(`span`,{className:`text-xs text-faint`,children:Wt(e.timestamp)})]},e.seq))})]})]})}function un({title:e,to:t}){return(0,A.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,A.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:e}),(0,A.jsxs)(d,{to:t,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View All `,(0,A.jsx)(B,{className:`size-3.5`})]})]})}function $({label:e,value:n,tone:r}){return(0,A.jsxs)(`span`,{children:[e,` `,(0,A.jsx)(`span`,{className:t(`tnum font-semibold`,r),children:n==null?`—`:Z(n)})]})}function dn(e){switch(e){case`completed`:return`bg-emerald-400`;case`failed`:return`bg-red-400`;case`active`:return`bg-blue-400`;case`waiting`:return`bg-amber-400`;default:return`bg-accent`}}function fn(){return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-24 text-center`,children:[(0,A.jsx)(`div`,{className:`text-5xl font-bold text-faint`,children:`404`}),(0,A.jsx)(`p`,{className:`text-sm text-muted`,children:`This page does not exist.`}),(0,A.jsx)(d,{to:`/`,className:`rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm font-medium text-fg hover:border-line-strong`,children:`Back to Overview`})]})}var pn=(0,b.lazy)(()=>u(()=>import(`./AddJob-CAhdg38n.js`).then(e=>({default:e.AddJob})),__vite__mapDeps([5,1,2,4]))),mn=(0,b.lazy)(()=>u(()=>import(`./Benchmark-CFZ3WCvj.js`).then(e=>({default:e.Benchmark})),__vite__mapDeps([6,1,2,7,4,8]))),hn=(0,b.lazy)(()=>u(()=>import(`./BulkAddJobs-BzgzpGg_.js`).then(e=>({default:e.BulkAddJobs})),__vite__mapDeps([9,1,2,4]))),gn=(0,b.lazy)(()=>u(()=>import(`./CronManager-BcFALDeT.js`).then(e=>({default:e.CronManager})),__vite__mapDeps([10,1,2,4,11]))),_n=(0,b.lazy)(()=>u(()=>import(`./Database-CV2yt5O2.js`).then(e=>({default:e.Database})),__vite__mapDeps([12,1,2,4,11]))),vn=(0,b.lazy)(()=>u(()=>import(`./Diagnostics-D-EK4GEi.js`).then(e=>({default:e.Diagnostics})),__vite__mapDeps([13,1,2]))),yn=(0,b.lazy)(()=>u(()=>import(`./DlqControl-eTrrQCrn.js`).then(e=>({default:e.DlqControl})),__vite__mapDeps([14,1,2,4,11,15]))),bn=(0,b.lazy)(()=>u(()=>import(`./DlqPro-CF79339e.js`).then(e=>({default:e.DlqPro})),__vite__mapDeps([16,1,2,4,11,15,17]))),xn=(0,b.lazy)(()=>u(()=>import(`./Flows-Ba8G7mcC.js`).then(e=>({default:e.Flows})),__vite__mapDeps([18,1,2]))),Sn=(0,b.lazy)(()=>u(()=>import(`./JobInspector--d_8ca9p.js`).then(e=>({default:e.JobInspector})),__vite__mapDeps([19,1,2,4,20,15]))),Cn=(0,b.lazy)(()=>u(()=>import(`./JobsPro-BcaokZIf.js`).then(e=>({default:e.JobsPro})),__vite__mapDeps([21,1,2,4,11,20,15]))),wn=(0,b.lazy)(()=>u(()=>import(`./LogsPro-Wl_e6hZM.js`).then(e=>({default:e.LogsPro})),__vite__mapDeps([22,1,2,4,11]))),Tn=(0,b.lazy)(()=>u(()=>import(`./McpServer-CnWJsKw7.js`).then(e=>({default:e.McpServer})),__vite__mapDeps([23,2,1]))),En=(0,b.lazy)(()=>u(()=>import(`./MetricsPro-O9eVJSH0.js`).then(e=>({default:e.MetricsPro})),__vite__mapDeps([24,1,2,11,8,25]))),Dn=(0,b.lazy)(()=>u(()=>import(`./QueueControl-DKqEXnkM.js`).then(e=>({default:e.QueueControl})),__vite__mapDeps([26,1,2,4,27]))),On=(0,b.lazy)(()=>u(()=>import(`./QueueDetailPro-BYmOVd4T.js`).then(e=>({default:e.QueueDetailPro})),__vite__mapDeps([28,1,2,8,25,27,4]))),kn=(0,b.lazy)(()=>u(()=>import(`./QueuesOverview-BeWdJpKi.js`).then(e=>({default:e.QueuesOverview})),__vite__mapDeps([29,1,2,11,17]))),An=(0,b.lazy)(()=>u(()=>import(`./S3BackupPro-DJB4oWgz.js`).then(e=>({default:e.S3BackupPro})),__vite__mapDeps([30,1,2,7,4]))),jn=(0,b.lazy)(()=>u(()=>import(`./ServerControl-_0lVB33E.js`).then(e=>({default:e.ServerControl})),__vite__mapDeps([31,1,2,4]))),Mn=(0,b.lazy)(()=>u(()=>import(`./UsagePro-B-TJ6fp4.js`).then(e=>({default:e.UsagePro})),__vite__mapDeps([32,2,1]))),Nn=(0,b.lazy)(()=>u(()=>import(`./Webhooks-C3zmvY-_.js`).then(e=>({default:e.Webhooks})),__vite__mapDeps([33,1,2,4,11]))),Pn=(0,b.lazy)(()=>u(()=>import(`./WorkersPro-mvY5VX8I.js`).then(e=>({default:e.WorkersPro})),__vite__mapDeps([34,1,2]))),Fn=(0,b.lazy)(()=>u(()=>import(`./Alerts-70bxf-PT.js`).then(e=>({default:e.Alerts})),__vite__mapDeps([35,1,2,4]))),In=(0,b.lazy)(()=>u(()=>import(`./Cron-ltjSoTjj.js`).then(e=>({default:e.Cron})),__vite__mapDeps([36,1,2,11]))),Ln=(0,b.lazy)(()=>u(()=>import(`./Dlq-fZAKwQoC.js`).then(e=>({default:e.Dlq})),__vite__mapDeps([37,1,2,4,11]))),Rn=(0,b.lazy)(()=>u(()=>import(`./Jobs-DEqAc1A5.js`).then(e=>({default:e.Jobs})),__vite__mapDeps([38,1,2,4,20]))),zn=(0,b.lazy)(()=>u(()=>import(`./Logs-DBTukPIX.js`).then(e=>({default:e.Logs})),__vite__mapDeps([39,1,2,4,11]))),Bn=(0,b.lazy)(()=>u(()=>import(`./Metrics-DzeIhNL-.js`).then(e=>({default:e.Metrics})),__vite__mapDeps([40,2,1]))),Vn=(0,b.lazy)(()=>u(()=>import(`./Overview-Bnu7rWqt.js`).then(e=>({default:e.Overview})),__vite__mapDeps([41,2,1]))),Hn=(0,b.lazy)(()=>u(()=>import(`./QueueDetail-DLRow04B.js`).then(e=>({default:e.QueueDetail})),__vite__mapDeps([42,1,2,4]))),Un=(0,b.lazy)(()=>u(()=>import(`./Queues-CoyjRFN7.js`).then(e=>({default:e.Queues})),__vite__mapDeps([43,1,2,11]))),Wn=(0,b.lazy)(()=>u(()=>import(`./S3Backup-BaLFgl9d.js`).then(e=>({default:e.S3Backup})),__vite__mapDeps([44,2,1]))),Gn=(0,b.lazy)(()=>u(()=>import(`./Settings-zKFJTtnq.js`).then(e=>({default:e.Settings})),__vite__mapDeps([45,1,2,7,4]))),Kn=(0,b.lazy)(()=>u(()=>import(`./Usage-CKGkvl0j.js`).then(e=>({default:e.Usage})),__vite__mapDeps([46,2,1]))),qn=(0,b.lazy)(()=>u(()=>import(`./Workers-jKhhXl3W.js`).then(e=>({default:e.Workers})),__vite__mapDeps([47,1,2,11])));function Jn(){return(0,A.jsx)(r,{children:(0,A.jsxs)(f,{element:(0,A.jsx)(Nt,{}),children:[(0,A.jsx)(f,{path:`/`,element:(0,A.jsx)(cn,{})}),(0,A.jsx)(f,{path:`/overview-classic`,element:(0,A.jsx)(Vn,{})}),(0,A.jsx)(f,{path:`/queues`,element:(0,A.jsx)(kn,{})}),(0,A.jsx)(f,{path:`/queues-classic`,element:(0,A.jsx)(Un,{})}),(0,A.jsx)(f,{path:`/queues/:name`,element:(0,A.jsx)(On,{})}),(0,A.jsx)(f,{path:`/queues-classic/:name`,element:(0,A.jsx)(Hn,{})}),(0,A.jsx)(f,{path:`/jobs`,element:(0,A.jsx)(Cn,{})}),(0,A.jsx)(f,{path:`/jobs-classic`,element:(0,A.jsx)(Rn,{})}),(0,A.jsx)(f,{path:`/dlq`,element:(0,A.jsx)(bn,{})}),(0,A.jsx)(f,{path:`/dlq-classic`,element:(0,A.jsx)(Ln,{})}),(0,A.jsx)(f,{path:`/cron`,element:(0,A.jsx)(gn,{})}),(0,A.jsx)(f,{path:`/cron-classic`,element:(0,A.jsx)(In,{})}),(0,A.jsx)(f,{path:`/flows`,element:(0,A.jsx)(xn,{})}),(0,A.jsx)(f,{path:`/metrics`,element:(0,A.jsx)(En,{})}),(0,A.jsx)(f,{path:`/metrics-classic`,element:(0,A.jsx)(Bn,{})}),(0,A.jsx)(f,{path:`/workers`,element:(0,A.jsx)(Pn,{})}),(0,A.jsx)(f,{path:`/workers-classic`,element:(0,A.jsx)(qn,{})}),(0,A.jsx)(f,{path:`/logs`,element:(0,A.jsx)(wn,{})}),(0,A.jsx)(f,{path:`/logs-classic`,element:(0,A.jsx)(zn,{})}),(0,A.jsx)(f,{path:`/server`,element:(0,A.jsx)(jn,{})}),(0,A.jsx)(f,{path:`/add-job`,element:(0,A.jsx)(pn,{})}),(0,A.jsx)(f,{path:`/jobs/bulk-add`,element:(0,A.jsx)(hn,{})}),(0,A.jsx)(f,{path:`/job`,element:(0,A.jsx)(Sn,{})}),(0,A.jsx)(f,{path:`/queue-control`,element:(0,A.jsx)(Dn,{})}),(0,A.jsx)(f,{path:`/cron-manager`,element:(0,A.jsx)(n,{to:`/cron`,replace:!0})}),(0,A.jsx)(f,{path:`/dlq-control`,element:(0,A.jsx)(yn,{})}),(0,A.jsx)(f,{path:`/webhooks`,element:(0,A.jsx)(Nn,{})}),(0,A.jsx)(f,{path:`/diagnostics`,element:(0,A.jsx)(vn,{})}),(0,A.jsx)(f,{path:`/alerts`,element:(0,A.jsx)(Fn,{})}),(0,A.jsx)(f,{path:`/benchmark`,element:(0,A.jsx)(mn,{})}),(0,A.jsx)(f,{path:`/database`,element:(0,A.jsx)(_n,{})}),(0,A.jsx)(f,{path:`/mcp`,element:(0,A.jsx)(Tn,{})}),(0,A.jsx)(f,{path:`/usage`,element:(0,A.jsx)(Mn,{})}),(0,A.jsx)(f,{path:`/usage-classic`,element:(0,A.jsx)(Kn,{})}),(0,A.jsx)(f,{path:`/s3`,element:(0,A.jsx)(An,{})}),(0,A.jsx)(f,{path:`/s3-classic`,element:(0,A.jsx)(Wn,{})}),(0,A.jsx)(f,{path:`/settings`,element:(0,A.jsx)(Gn,{})}),(0,A.jsx)(f,{path:`*`,element:(0,A.jsx)(fn,{})})]})})}be();var Yn=document.getElementById(`root`);if(!Yn)throw Error(`Root element #root not found`);function Xn(){(0,x.createRoot)(Yn).render((0,A.jsx)(b.StrictMode,{children:(0,A.jsx)(c,{basename:`/`,children:(0,A.jsx)(Jn,{})})}))}K()?u(()=>import(`./install-DhTYJCUC.js`).then(e=>e.installDemo()),[]).catch(()=>{}).finally(Xn):Xn();export{de as $,qe as A,ze as B,yt as C,K as D,dt as E,Ne as F,P as G,Te as H,z as I,Re as J,Le as K,Se as L,B as M,Be as N,Ye as O,Me as P,fe as Q,I as R,Y as S,vt as T,Fe as U,R as V,Pe as W,L as X,Ie as Y,M as Z,It as _,Ut as a,S as at,xt as b,Z as c,qt as d,w as et,Kt as f,Ft as g,Lt as h,Jt as i,re as it,G as j,Ke as k,Vt as l,X as m,Ht as n,k as nt,Gt as o,Zt as p,De as q,Qt as r,ae as rt,Yt as s,an as t,ce as tt,Wt as u,St as v,_t as w,Ct as x,wt as y,Ue as z};