@blinkk/root-cms 3.1.4 → 3.1.5

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 (102) hide show
  1. package/dist/app.js +3 -2
  2. package/dist/{chunk-NC3CRIFA.js → chunk-6CTCV2PN.js} +1 -1
  3. package/dist/{chunk-AFBSITEO.js → chunk-ETHWZSNM.js} +4 -0
  4. package/dist/{chunk-MYN76V3L.js → chunk-MUXSUGFF.js} +2 -2
  5. package/dist/cli.js +1 -1
  6. package/dist/client.js +1 -1
  7. package/dist/core/schema.d.ts +88 -3
  8. package/dist/core.js +1 -1
  9. package/dist/functions.js +2 -2
  10. package/dist/plugin.js +3 -3
  11. package/dist/ui/AIPage-25WICIOT.js +1 -0
  12. package/dist/ui/{AssetsPage-QUL2NBWK.js → AssetsPage-WKTM2J2G.js} +1 -1
  13. package/dist/ui/CollectionPage-5ZOVG7IG.js +1 -0
  14. package/dist/ui/{ComparePage-DCP5QHDE.js → ComparePage-DDIFYYTK.js} +1 -1
  15. package/dist/ui/{DataPage-TUVFBALT.js → DataPage-RFNGSDDN.js} +1 -1
  16. package/dist/ui/{DataSourcePage-YE2ZOHYI.js → DataSourcePage-U46CDIH2.js} +1 -1
  17. package/dist/ui/{DocTranslationsPage-3ILTQOP2.js → DocTranslationsPage-BFCM2PE3.js} +1 -1
  18. package/dist/ui/{DocumentPage-JFQ3Y2GH.js → DocumentPage-OTBXM55S.js} +1 -1
  19. package/dist/ui/{EditDataSourcePage-WHPZDMD4.js → EditDataSourcePage-NKKIF6AD.js} +1 -1
  20. package/dist/ui/EditReleasePage-TKNOUT7A.js +1 -0
  21. package/dist/ui/EmbeddedAIPage-4AX7VO3T.js +1 -0
  22. package/dist/ui/{EmbeddedDocumentPage-6FYHUHTE.js → EmbeddedDocumentPage-2CNQJTW5.js} +1 -1
  23. package/dist/ui/{ImageEditorDialog-Q44YTLB5.js → ImageEditorDialog-YDKOGVJV.js} +1 -1
  24. package/dist/ui/LogsPage-SCECIAZH.js +1 -0
  25. package/dist/ui/{NewDataSourcePage-QXW54CHQ.js → NewDataSourcePage-FAOPK2RZ.js} +1 -1
  26. package/dist/ui/NewReleasePage-HD6T6UV2.js +1 -0
  27. package/dist/ui/{NotFoundPage-RMNPVSD3.js → NotFoundPage-JRYFUENW.js} +1 -1
  28. package/dist/ui/{ProjectPage-VY4EJX6J.js → ProjectPage-2WIMWCSX.js} +1 -1
  29. package/dist/ui/ReleasePage-GUMEMLF6.js +1 -0
  30. package/dist/ui/{ReleasesPage-A4BLUNJE.js → ReleasesPage-AW6PICTQ.js} +1 -1
  31. package/dist/ui/{SettingsPage-MP3YHQDP.js → SettingsPage-KFLNZ356.js} +1 -1
  32. package/dist/ui/{SidebarToolsPage-S5DMIEQ6.js → SidebarToolsPage-3R7BQ2F7.js} +1 -1
  33. package/dist/ui/{TaskPage-LCBDMA4I.js → TaskPage-GZGPKIL5.js} +1 -1
  34. package/dist/ui/TasksPage-G3GBTV3L.js +1 -0
  35. package/dist/ui/{TranslationsArbPage-B7TIRREV.js → TranslationsArbPage-K272JEAA.js} +1 -1
  36. package/dist/ui/{TranslationsEditPage-VQG4YHA6.js → TranslationsEditPage-XWXPNKRQ.js} +1 -1
  37. package/dist/ui/{TranslationsPage-6VCVMNXI.js → TranslationsPage-7KUHVTLK.js} +1 -1
  38. package/dist/ui/{chunk-IMXZTYAA.js → chunk-2FQMT5AB.js} +1 -1
  39. package/dist/ui/{chunk-EYVQCOAD.js → chunk-2PTLQRTU.js} +1 -1
  40. package/dist/ui/{chunk-FF4CLAZS.js → chunk-2RRM4HEQ.js} +1 -1
  41. package/dist/ui/{chunk-MAZJRNAL.js → chunk-34W6H4YG.js} +1 -1
  42. package/dist/ui/{chunk-L3O3CLWO.js → chunk-44ZU5WMI.js} +1 -1
  43. package/dist/ui/{chunk-MYKJ6VAM.js → chunk-535JU7FU.js} +1 -1
  44. package/dist/ui/{chunk-JSWRHHTZ.js → chunk-5KSGCGYY.js} +1 -1
  45. package/dist/ui/{chunk-UHK5N75L.js → chunk-75NMQ3LW.js} +1 -1
  46. package/dist/ui/{chunk-W2ZAVRAT.js → chunk-7UHZS56B.js} +57 -57
  47. package/dist/ui/{chunk-76PG55CM.js → chunk-DWV5J2W7.js} +1 -1
  48. package/dist/ui/{chunk-VB5VMEN7.js → chunk-F7RQT4XN.js} +1 -1
  49. package/dist/ui/{chunk-CSUKZZK5.js → chunk-FVWSVOOY.js} +1 -1
  50. package/dist/ui/{chunk-V3G3554T.js → chunk-GCSN3YEC.js} +1 -1
  51. package/dist/ui/{chunk-74OB6FM4.js → chunk-H37RXS4R.js} +1 -1
  52. package/dist/ui/{chunk-LC6WLVRS.js → chunk-HV3JJ5UT.js} +1 -1
  53. package/dist/ui/{chunk-K3UM5OQF.js → chunk-HXSB6YB2.js} +1 -1
  54. package/dist/ui/{chunk-AZ2SK2ZK.js → chunk-IGZDFHVM.js} +1 -1
  55. package/dist/ui/chunk-ISUGBMXC.js +1 -0
  56. package/dist/ui/{chunk-WN7HUDGY.js → chunk-JBLSUM6W.js} +1 -1
  57. package/dist/ui/{chunk-F4F5MH7A.js → chunk-N5RJIILP.js} +1 -1
  58. package/dist/ui/{chunk-KBJ4AK5O.js → chunk-NCZD5IWS.js} +1 -1
  59. package/dist/ui/{chunk-NEA3XU6N.js → chunk-NXWYS4HG.js} +1 -1
  60. package/dist/ui/{chunk-4N6CPIOQ.js → chunk-OWBT6YUM.js} +1 -1
  61. package/dist/ui/chunk-OWYV43BT.js +1 -0
  62. package/dist/ui/{chunk-XM35ZJBQ.js → chunk-PIJ3E47R.js} +1 -1
  63. package/dist/ui/{chunk-WAT22UHZ.js → chunk-PLYSJ7W5.js} +1 -1
  64. package/dist/ui/{chunk-H3PYPGNR.js → chunk-QFDU6FXP.js} +1 -1
  65. package/dist/ui/{chunk-W3ICOHMF.js → chunk-QLIIVG5Q.js} +1 -1
  66. package/dist/ui/{chunk-ELKXEMOU.js → chunk-QRAFYIAW.js} +1 -1
  67. package/dist/ui/{chunk-VRRRFAIV.js → chunk-QWB6MAPJ.js} +1 -1
  68. package/dist/ui/{chunk-GCMX5V3P.js → chunk-RB23LLKL.js} +1 -1
  69. package/dist/ui/{chunk-3WQCVKK4.js → chunk-T5BJNOWE.js} +1 -1
  70. package/dist/ui/chunk-TNW2GNUR.js +1 -0
  71. package/dist/ui/{chunk-HVYNDEA7.js → chunk-UCYWQEAS.js} +1 -1
  72. package/dist/ui/{chunk-6P75AZ3B.js → chunk-UJX25CXD.js} +1 -1
  73. package/dist/ui/chunk-UPN3EMUS.js +1 -0
  74. package/dist/ui/{chunk-5SY2SVEX.js → chunk-VPZHG7JL.js} +1 -1
  75. package/dist/ui/{chunk-WS37MDM3.js → chunk-WASID5UU.js} +1 -1
  76. package/dist/ui/{chunk-2PDMFZBF.js → chunk-WC7KMPEQ.js} +1 -1
  77. package/dist/ui/chunk-WRA24P66.js +7 -0
  78. package/dist/ui/{chunk-ETPZ3TXX.js.LEGAL.txt → chunk-WRA24P66.js.LEGAL.txt} +4 -1
  79. package/dist/ui/{chunk-XJUQOX4E.js → chunk-XUBZH4ON.js} +1 -1
  80. package/dist/ui/{chunk-QHOZXW7Y.js → chunk-Y5EOMMNI.js} +1 -1
  81. package/dist/ui/{chunk-EIMRPYCD.js → chunk-YBHFGQ3Z.js} +1 -1
  82. package/dist/ui/{chunk-62VPTZJL.js → chunk-YP6ZH3MT.js} +1 -1
  83. package/dist/ui/{chunk-PR7NB5VK.js → chunk-Z3ZJJWFT.js} +1 -1
  84. package/dist/ui/ui.css +1 -1
  85. package/dist/ui/ui.js +1 -1
  86. package/package.json +3 -3
  87. package/dist/ui/AIPage-4W4MFELY.js +0 -1
  88. package/dist/ui/CollectionPage-7VU6SUUP.js +0 -1
  89. package/dist/ui/EditReleasePage-QKWHIURV.js +0 -1
  90. package/dist/ui/EmbeddedAIPage-SQLOV4IT.js +0 -1
  91. package/dist/ui/LogsPage-RC5O722W.js +0 -1
  92. package/dist/ui/NewReleasePage-TKYWVTOH.js +0 -1
  93. package/dist/ui/ReleasePage-VZAL4KUI.js +0 -1
  94. package/dist/ui/TasksPage-72KVSUQY.js +0 -1
  95. package/dist/ui/chunk-ETPZ3TXX.js +0 -7
  96. package/dist/ui/chunk-J5KDO4RM.js +0 -1
  97. package/dist/ui/chunk-SLLTYDVX.js +0 -1
  98. package/dist/ui/chunk-SWTNOWNE.js +0 -1
  99. package/dist/ui/chunk-YV5SGR24.js +0 -1
  100. /package/dist/ui/{ImageEditorDialog-Q44YTLB5.js.LEGAL.txt → ImageEditorDialog-YDKOGVJV.js.LEGAL.txt} +0 -0
  101. /package/dist/ui/{chunk-W2ZAVRAT.js.LEGAL.txt → chunk-7UHZS56B.js.LEGAL.txt} +0 -0
  102. /package/dist/ui/{chunk-5SY2SVEX.js.LEGAL.txt → chunk-VPZHG7JL.js.LEGAL.txt} +0 -0
@@ -1 +1 @@
1
- import{e as z,j as I}from"./chunk-J5KDO4RM.js";import{c as N,e as L}from"./chunk-SLLTYDVX.js";import{a as C}from"./chunk-H3PYPGNR.js";import{a as w,c as y}from"./chunk-ELKXEMOU.js";import{b as v}from"./chunk-5MV6XVGA.js";import{Dc as B,Ga as e,V as P,a as g,da as p,g as M,j as x,ua as S,za as f}from"./chunk-ETPZ3TXX.js";x();x();function O(o,t){return M(()=>{if(!t.trim())return o;let l=t.toLowerCase();return o.filter(c=>{let[a,u]=c.id.split("/"),r=c.fields||{},n=window.__ROOT_CTX.collections[a],s=v(r,n.preview?.title||"meta.title")||"";return c.id.toLowerCase().includes(l)||s.toLowerCase().includes(l)||u.toLowerCase().includes(l)})},[o,t])}var h="DocPickerModal";function ee(){let o=w(),t=y();return{open:l=>{o.openContextModal(h,{...t,innerProps:l,size:"700px",overflow:"inside"})},close:()=>{o.closeModal(h)}}}function k(o){let{innerProps:t}=o,l=Object.keys(window.__ROOT_CTX.collections);t.collections?.length&&(l=l.filter(i=>t.collections?.includes(i)));let c=[{value:"",label:"Select"}];l.forEach(i=>{c.push({value:i,label:i})});let[a,u]=C("DocPickerModal.lastSelectedCollection",""),r=()=>t.initialCollection?t.initialCollection:a&&l.includes(a)?a:l.length===1?l[0]:"",[n,D]=g(r()),s=i=>{D(i),u(i)};function m(i){t.multiSelect&&t.onChangeMulti?t.onChangeMulti(i.id,!0):t.onChange&&t.onChange(i.id)}function b(i){t.multiSelect&&t.onChangeMulti&&t.onChangeMulti(i.id,!1)}return e("div",{className:"DocPickerModal",children:[l.length===0&&e("div",{className:"DocPickerModal__noCollections",children:"No collections matching schema field definition."}),l.length>0&&e(k.DocsList,{collection:n,onDocSelected:m,onDocUnselected:b,onCollectionChange:s,multiSelect:t.multiSelect,selectedDocIds:t.selectedDocIds,options:{enableSearch:t.enableSearch??!0,enableSort:t.enableSort??!0,enableCreate:t.enableCreate??!0,enableStatusBadges:t.enableStatusBadges??!0,showCollectionSelect:l.length>1,collectionSelectValue:n,collectionSelectOptions:c}})]})}k.DocsList=o=>{let[t,l]=g(""),[c,a]=C(`root::DocPickerModal:${o.collection}:sortBy`,"modifiedAt"),[u,r]=g(!1),[n,D,s]=z(o.collection||"",{orderBy:c}),m=O(s,t),b=[{value:"modifiedAt",label:"Last Modified"},{value:"slug",label:"A-Z"},{value:"slugDesc",label:"Z-A"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"}],i=o.selectedDocIds||[],d=o.options||{};return e("div",{className:"DocPickerModal__DocsList",children:[e("div",{className:"DocPickerModal__DocsList__stickyHeader",children:[d.showCollectionSelect&&e("div",{className:"DocPickerModal__collection__select",children:[e("div",{className:"DocPickerModal__collection__select__label",children:"Content Type:"}),e(f,{data:d.collectionSelectOptions||[],value:d.collectionSelectValue,placeholder:"Select",onChange:_=>{o.onCollectionChange?.(_||"")},size:"xs",radius:0,searchable:!0,autoFocus:!0,dropdownComponent:"div"}),d.collectionSelectValue&&e(p,{variant:"outline",color:"dark",size:"xs",onClick:()=>r(!0),children:"New"})]}),d.enableSearch&&d.collectionSelectValue&&e("div",{className:"DocPickerModal__DocsList__controls",children:[e(S,{placeholder:"Search documents...",value:t,onChange:_=>l(_.target.value),icon:e(B,{size:16}),size:"xs",className:"DocPickerModal__DocsList__controls__search"}),d.enableSort&&e(f,{data:b,value:c,onChange:_=>a(_||"modifiedAt"),size:"xs",className:"DocPickerModal__DocsList__controls__sort"})]}),!n&&s.length>0&&e("div",{className:"DocPickerModal__DocsList__count",children:["Showing ",m.length," of ",s.length," documents"]})]}),e("div",{className:"DocPickerModal__DocsList__docsContainer",children:o.collection?n?e("div",{className:"DocPickerModal__DocsList__loading",children:e(P,{color:"gray",size:"xl"})}):m.length===0?e("div",{className:"DocPickerModal__DocsList__empty",children:s.length===0?"Collection is empty.":"No documents match your search."}):e("div",{className:"DocPickerModal__DocsList__docs",children:m.map(_=>e(k.DocCard,{doc:_,onDocSelected:o.onDocSelected,onDocUnselected:o.onDocUnselected,multiSelect:o.multiSelect,selected:i.includes(_.id),enableStatusBadges:d.enableStatusBadges},_.id))}):e("div",{className:"DocPickerModal__DocsList__empty",children:"Select a content type to view documents"})}),d.collectionSelectValue&&e(I,{collection:d.collectionSelectValue,opened:u,skipNavigation:!0,onClose:()=>{r(!1),D()}})]})};k.DocCard=o=>{let[t,l]=g(!!o.selected),c=o.doc,[a,u]=c.id.split("/"),r=c.fields||{},n=window.__ROOT_CTX.collections[a],D=`/cms/content/${a}/${u}`,s=v(r,n.preview?.title||"meta.title"),m=v(r,n.preview?.image||"meta.image")||n.preview?.defaultImage;return e("div",{className:"DocPickerModal__DocCard",children:[e("div",{className:"DocPickerModal__DocCard__image",onClick:()=>window.open(D,"_blank"),children:e(L,{file:m,width:120,height:90,withPlaceholder:!m?.src})}),e("div",{className:"DocPickerModal__DocCard__content",children:[e("div",{className:"DocPickerModal__DocCard__content__header",children:e("div",{className:"DocPickerModal__DocCard__content__header__docId",onClick:()=>window.open(D,"_blank"),children:c.id})}),e("div",{className:"DocPickerModal__DocCard__content__title",children:e("div",{className:"DocPickerModal__DocCard__content__link",onClick:()=>window.open(D,"_blank"),children:s||"[UNTITLED]"})}),o.enableStatusBadges&&e("div",{className:"DocPickerModal__DocCard__content__badges",children:e(N,{doc:c})})]}),e("div",{className:"DocPickerModal__DocCard__controls",children:e("div",{className:"DocPickerModal__DocCard__controls__buttons",children:o.multiSelect?t?e(p,{variant:"light",color:"blue",size:"xs",onClick:()=>{l(!1),o.onDocUnselected(o.doc)},children:"Unselect"}):e(p,{variant:"filled",color:"blue",size:"xs",onClick:()=>{l(!0),o.onDocSelected(o.doc)},children:"Select"}):e(p,{color:"blue",size:"xs",onClick:()=>o.onDocSelected(o.doc),children:"Select"})})})]})};k.id=h;export{ee as a,k as b};
1
+ import{e as z,j as I}from"./chunk-UPN3EMUS.js";import{d as N,f as L}from"./chunk-TNW2GNUR.js";import{a as C}from"./chunk-QFDU6FXP.js";import{a as w,c as y}from"./chunk-QRAFYIAW.js";import{b as v}from"./chunk-5MV6XVGA.js";import{Ga as e,Gc as B,V as P,a as g,da as p,g as M,j as x,ua as S,za as f}from"./chunk-WRA24P66.js";x();x();function O(o,t){return M(()=>{if(!t.trim())return o;let l=t.toLowerCase();return o.filter(c=>{let[a,u]=c.id.split("/"),r=c.fields||{},n=window.__ROOT_CTX.collections[a],s=v(r,n.preview?.title||"meta.title")||"";return c.id.toLowerCase().includes(l)||s.toLowerCase().includes(l)||u.toLowerCase().includes(l)})},[o,t])}var h="DocPickerModal";function ee(){let o=w(),t=y();return{open:l=>{o.openContextModal(h,{...t,innerProps:l,size:"700px",overflow:"inside"})},close:()=>{o.closeModal(h)}}}function k(o){let{innerProps:t}=o,l=Object.keys(window.__ROOT_CTX.collections);t.collections?.length&&(l=l.filter(i=>t.collections?.includes(i)));let c=[{value:"",label:"Select"}];l.forEach(i=>{c.push({value:i,label:i})});let[a,u]=C("DocPickerModal.lastSelectedCollection",""),r=()=>t.initialCollection?t.initialCollection:a&&l.includes(a)?a:l.length===1?l[0]:"",[n,D]=g(r()),s=i=>{D(i),u(i)};function m(i){t.multiSelect&&t.onChangeMulti?t.onChangeMulti(i.id,!0):t.onChange&&t.onChange(i.id)}function b(i){t.multiSelect&&t.onChangeMulti&&t.onChangeMulti(i.id,!1)}return e("div",{className:"DocPickerModal",children:[l.length===0&&e("div",{className:"DocPickerModal__noCollections",children:"No collections matching schema field definition."}),l.length>0&&e(k.DocsList,{collection:n,onDocSelected:m,onDocUnselected:b,onCollectionChange:s,multiSelect:t.multiSelect,selectedDocIds:t.selectedDocIds,options:{enableSearch:t.enableSearch??!0,enableSort:t.enableSort??!0,enableCreate:t.enableCreate??!0,enableStatusBadges:t.enableStatusBadges??!0,showCollectionSelect:l.length>1,collectionSelectValue:n,collectionSelectOptions:c}})]})}k.DocsList=o=>{let[t,l]=g(""),[c,a]=C(`root::DocPickerModal:${o.collection}:sortBy`,"modifiedAt"),[u,r]=g(!1),[n,D,s]=z(o.collection||"",{orderBy:c}),m=O(s,t),b=[{value:"modifiedAt",label:"Last Modified"},{value:"slug",label:"A-Z"},{value:"slugDesc",label:"Z-A"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"}],i=o.selectedDocIds||[],d=o.options||{};return e("div",{className:"DocPickerModal__DocsList",children:[e("div",{className:"DocPickerModal__DocsList__stickyHeader",children:[d.showCollectionSelect&&e("div",{className:"DocPickerModal__collection__select",children:[e("div",{className:"DocPickerModal__collection__select__label",children:"Content Type:"}),e(f,{data:d.collectionSelectOptions||[],value:d.collectionSelectValue,placeholder:"Select",onChange:_=>{o.onCollectionChange?.(_||"")},size:"xs",radius:0,searchable:!0,autoFocus:!0,dropdownComponent:"div"}),d.collectionSelectValue&&e(p,{variant:"outline",color:"dark",size:"xs",onClick:()=>r(!0),children:"New"})]}),d.enableSearch&&d.collectionSelectValue&&e("div",{className:"DocPickerModal__DocsList__controls",children:[e(S,{placeholder:"Search documents...",value:t,onChange:_=>l(_.target.value),icon:e(B,{size:16}),size:"xs",className:"DocPickerModal__DocsList__controls__search"}),d.enableSort&&e(f,{data:b,value:c,onChange:_=>a(_||"modifiedAt"),size:"xs",className:"DocPickerModal__DocsList__controls__sort"})]}),!n&&s.length>0&&e("div",{className:"DocPickerModal__DocsList__count",children:["Showing ",m.length," of ",s.length," documents"]})]}),e("div",{className:"DocPickerModal__DocsList__docsContainer",children:o.collection?n?e("div",{className:"DocPickerModal__DocsList__loading",children:e(P,{color:"gray",size:"xl"})}):m.length===0?e("div",{className:"DocPickerModal__DocsList__empty",children:s.length===0?"Collection is empty.":"No documents match your search."}):e("div",{className:"DocPickerModal__DocsList__docs",children:m.map(_=>e(k.DocCard,{doc:_,onDocSelected:o.onDocSelected,onDocUnselected:o.onDocUnselected,multiSelect:o.multiSelect,selected:i.includes(_.id),enableStatusBadges:d.enableStatusBadges},_.id))}):e("div",{className:"DocPickerModal__DocsList__empty",children:"Select a content type to view documents"})}),d.collectionSelectValue&&e(I,{collection:d.collectionSelectValue,opened:u,skipNavigation:!0,onClose:()=>{r(!1),D()}})]})};k.DocCard=o=>{let[t,l]=g(!!o.selected),c=o.doc,[a,u]=c.id.split("/"),r=c.fields||{},n=window.__ROOT_CTX.collections[a],D=`/cms/content/${a}/${u}`,s=v(r,n.preview?.title||"meta.title"),m=v(r,n.preview?.image||"meta.image")||n.preview?.defaultImage;return e("div",{className:"DocPickerModal__DocCard",children:[e("div",{className:"DocPickerModal__DocCard__image",onClick:()=>window.open(D,"_blank"),children:e(L,{file:m,width:120,height:90,withPlaceholder:!m?.src})}),e("div",{className:"DocPickerModal__DocCard__content",children:[e("div",{className:"DocPickerModal__DocCard__content__header",children:e("div",{className:"DocPickerModal__DocCard__content__header__docId",onClick:()=>window.open(D,"_blank"),children:c.id})}),e("div",{className:"DocPickerModal__DocCard__content__title",children:e("div",{className:"DocPickerModal__DocCard__content__link",onClick:()=>window.open(D,"_blank"),children:s||"[UNTITLED]"})}),o.enableStatusBadges&&e("div",{className:"DocPickerModal__DocCard__content__badges",children:e(N,{doc:c})})]}),e("div",{className:"DocPickerModal__DocCard__controls",children:e("div",{className:"DocPickerModal__DocCard__controls__buttons",children:o.multiSelect?t?e(p,{variant:"light",color:"blue",size:"xs",onClick:()=>{l(!1),o.onDocUnselected(o.doc)},children:"Unselect"}):e(p,{variant:"filled",color:"blue",size:"xs",onClick:()=>{l(!0),o.onDocSelected(o.doc)},children:"Select"}):e(p,{color:"blue",size:"xs",onClick:()=>o.onDocSelected(o.doc),children:"Select"})})})]})};k.id=h;export{ee as a,k as b};
@@ -1 +1 @@
1
- import{Ga as o,Nc as c,Yc as r}from"./chunk-ETPZ3TXX.js";function m(e){let a=e.size??36,t=Math.round(a*.55),n=e.className?`DataSourceIcon ${e.className}`:"DataSourceIcon";return o("div",{className:n,style:{width:`${a}px`,height:`${a}px`},children:e.type==="gsheet"?o(c,{size:t,stroke:1.5}):o(r,{size:t,stroke:1.5})})}export{m as a};
1
+ import{$c as r,Ga as o,Qc as c}from"./chunk-WRA24P66.js";function m(e){let a=e.size??36,t=Math.round(a*.55),n=e.className?`DataSourceIcon ${e.className}`:"DataSourceIcon";return o("div",{className:n,style:{width:`${a}px`,height:`${a}px`},children:e.type==="gsheet"?o(c,{size:t,stroke:1.5}):o(r,{size:t,stroke:1.5})})}export{m as a};
@@ -1 +1 @@
1
- import{c as T}from"./chunk-JDW4UORS.js";import{k as z}from"./chunk-RN4XVVWD.js";import{C as _}from"./chunk-YV5SGR24.js";import{D as l,a as f,b as w,c as s,g as b,i as k,n as v,o as j,q as u,t as R,u as c,v as y,x as I}from"./chunk-XOWWPE7X.js";var O=["agile","airy","alert","amber","amused","ancient","aqua","arctic","astral","autumn","avid","azure","balmy","beige","big","bitter","black","blazing","blissful","blooming","blue","bold","bouncy","brainy","brave","breezy","bright","brisk","broad","bronze","brown","bubbly","busy","calm","candid","careful","caring","charming","cheerful","cherry","chilly","chipper","classic","clean","clear","clever","cloudy","coastal","cobalt","cold","cool","copper","coral","cosmic","cosy","cozy","crafty","creamy","crimson","crisp","cuddly","curious","dandy","dapper","daring","dark","dawn","dazzling","dear","deep","deft","delicate","dewy","dizzy","dotted","dreamy","driven","dry","dusky","dusty","eager","early","earnest","earthy","eastern","easy","ebony","elated","electric","elegant","emerald","empty","epic","even","every","faint","fair","falling","famous","fancy","fast","feisty","festive","fierce","fiery","fine","firm","flat","floral","flowing","fluffy","foggy","fond","forest","fragrant","fresh","friendly","frisky","frosty","funky","funny","fuzzy","gallant","gentle","giant","gilded","glad","gleaming","glossy","glowing","gold","golden","good","graceful","grand","grassy","gray","green","groovy","gusty","handy","happy","hardy","hazy","hearty","heavy","helpful","heroic","hidden","high","holy","honest","honeyed","hopeful","humble","humming","hushed","icy","ideal","idle","indigo","inky","iron","ivory","jade","jaunty","jazzy","jolly","jovial","joyful","jubilant","juicy","jumpy","keen","kind","kindly","lacy","late","lazy","leafy","lemon","light","limber","lime","linen","little","lively","lone","long","loud","lovely","loyal","lucid","lucky","luminous","lunar","lush","magenta","magic","majestic","mango","marble","maritime","maroon","massive","mauve","mellow","merry","mighty","mild","milky","mindful","minty","misty","mocha","modest","morning","mossy","muddy","mysterious","mythic","narrow","navy","neat","neon","new","nimble","noble","noisy","noon","northern","nosy","nutty","oaken","oceanic","odd","old","olive","onyx","opal","open","orange","orderly","pale","pastel","patient","peaceful","peach","peachy","pearly","pebbly","peppy","perky","pink","placid","plain","playful","pleasant","plucky","plum","plush","polar","polite","prime","pristine","proud","pure","purple","quaint","quick","quiet","quirky","radiant","rapid","rare","raven","ready","red","regal","restless","rich","rolling","rosy","rough","round","royal","ruby","rugged","rumbling","russet","rustic","sable","safe","sage","salty","sandy","sapphire","savvy","scarlet","scenic","secret","sepia","serene","shaggy","sharp","shimmering","shiny","short","shrewd","shy","silent","silky","silly","silver","simple","sleek","sleepy","slim","slow","small","smart","smoky","smooth","snappy","snowy","soaring","soft","solar","solid","southern","sparkly","speedy","spicy","spiffy","spotted","spry","square","starry","steady","steel","stellar","sticky","still","stony","stormy","striped","strong","sturdy","subtle","sunlit","sunny","super","supreme","swank","sweet","swift","tame","tan","tangy","tart","teal","tender","thin","thirsty","thriving","tidal","tidy","tiny","tireless","toasty","topaz","tough","tranquil","trim","tropical","true","twinkly","umber","upbeat","urban","useful","valiant","vast","velvet","verdant","vernal","vibrant","vintage","violet","vivid","wandering","warm","watchful","wavy","wee","western","whimsical","whispering","white","wholesome","wild","winding","windy","winter","wintry","wise","witty","wondrous","woody","wool","yellow","young","youthful","zany","zealous","zen","zesty","zippy"],A=["acorn","almond","alpaca","anchor","antler","apple","apricot","arrow","aspen","aurora","autumn","avocado","badger","bagel","bamboo","banana","basil","bay","bayou","beach","bear","bee","beetle","bell","berry","birch","bird","biscuit","bison","blossom","bluff","boat","bobcat","bonfire","book","boot","bottle","boulder","branch","brass","breeze","bridge","brook","broom","brunch","bubble","bucket","bud","buffalo","bug","bunny","burrow","butter","button","cabin","cactus","cake","camel","canary","candle","canyon","cape","caravan","cardinal","carrot","cascade","cashew","castle","cat","cave","cedar","chair","cherry","chestnut","chickpea","chime","cinnamon","citadel","cliff","cloud","clove","clover","cocoa","comet","compass","condor","cookie","coral","cottage","cotton","cove","coyote","crane","crayon","creek","cricket","crocus","crow","crumpet","crystal","cup","cupcake","currant","cypress","daffodil","dahlia","daisy","dawn","deer","delta","desert","dew","diamond","dingo","dock","dogwood","dolphin","donut","dove","dragon","drift","drizzle","drum","duck","dumpling","dune","eagle","echo","eclipse","eel","egg","elder","elephant","elk","ember","ermine","estuary","evergreen","falcon","fawn","feather","fennel","fern","ferret","field","fig","finch","fir","firefly","fish","fjord","flame","flamingo","flask","flax","fleece","flicker","flower","flute","fog","forest","fossil","fountain","fox","frog","frost","galaxy","garden","gazelle","gecko","gem","geyser","ginger","glacier","glade","glen","globe","glow","goat","goose","gorge","gourd","granite","grape","grass","grotto","grove","gull","hammock","harbor","hare","harp","harvest","hat","hawk","haystack","hazel","hearth","heather","hedge","heron","hibiscus","hickory","hill","hollow","honey","horizon","horse","hummingbird","ibis","iceberg","icicle","inlet","iris","island","ivy","jackal","jacket","jade","jaguar","jam","jar","jasmine","jay","jelly","jetty","juniper","kayak","kelp","kestrel","kettle","key","kingfisher","kite","kitten","kiwi","knoll","koala","ladybug","lagoon","lake","lamp","lantern","lark","lava","lavender","leaf","ledge","lemon","lemur","leopard","lichen","lighthouse","lilac","lily","lime","lion","llama","lobster","log","loon","lotus","lynx","lyric","magnet","manatee","mango","mangrove","maple","marble","marigold","marlin","marsh","meadow","melody","melon","mermaid","mesa","meteor","minnow","mint","mirage","mist","mitten","mole","monkey","moon","moose","morel","mosaic","moss","moth","mountain","mouse","muffin","mushroom","mussel","narwhal","nautilus","nectar","needle","nest","nettle","newt","nightingale","nimbus","noodle","north","note","nutmeg","oak","oasis","oats","ocean","ocelot","octopus","olive","onion","opal","orange","orca","orchid","oriole","osprey","otter","owl","oyster","paddle","palm","panda","pansy","panther","papaya","paper","parrot","parsley","partridge","pasture","path","peach","peacock","pear","pebble","pecan","pelican","penguin","peony","pepper","petal","petunia","pheasant","phoenix","pie","pigeon","pine","pineapple","pistachio","planet","plateau","plover","plum","pond","pony","poppy","porpoise","pouch","prairie","pretzel","primrose","puffin","pumpkin","quail","quartz","queen","quill","quince","quokka","rabbit","raccoon","radish","rain","rainbow","rapids","raspberry","raven","redwood","reef","reel","reindeer","rhino","ribbon","ridge","river","road","robin","rock","rooster","rose","rosemary","rowan","rye","saffron","sage","salmon","sand","sapphire","satellite","savanna","scallop","scarf","sea","seagull","seal","seed","sequoia","sesame","shark","shell","shore","shrimp","silk","silo","sky","skylark","sleet","snail","snake","snow","sock","sorbet","spark","sparrow","spider","spire","spoon","spring","sprout","spruce","squirrel","star","starfish","starling","stone","stork","storm","stream","summer","sun","sundial","sunflower","swan","swift","sycamore","tadpole","tamarind","tangerine","tea","teal","tern","terrace","thicket","thistle","thrush","thunder","tide","tiger","timber","toad","toffee","tooth","topaz","tortoise","totem","toucan","tower","tractor","trail","tree","trout","truffle","tugboat","tulip","tundra","turnip","turtle","twig","twilight","umbrella","unicorn","urchin","valley","vanilla","vine","violet","vista","volcano","voyage","vulture","wagon","walnut","walrus","wasp","water","waterfall","wave","whale","wharf","wheat","whisker","wildcat","wildflower","willow","wind","window","winter","wisteria","wolf","wombat","wood","wren","yak","yam","yarrow","yew","yucca","zebra","zephyr","zinnia","zucchini"];var x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",S="YYYYMMDD";function D(e,r){let a=r?.now??new Date,o=r?.random??Math.random,t=e.replace(/\{([^{}]+?)\}/g,(n,d)=>{let[p,g]=q(d);switch(p){case"date":return E(a,g||S);case"adjective":return C(O,o);case"noun":return C(A,o);case"random":return M(Y(g,6),o);default:return n}});return T(t.toLowerCase())}function q(e){let r=e.indexOf(":");return r===-1?[e.trim(),void 0]:[e.slice(0,r).trim(),e.slice(r+1)]}function Y(e,r){if(!e)return r;let a=parseInt(e,10);return Number.isFinite(a)&&a>0?a:r}function C(e,r){return e[Math.floor(r()*e.length)]}function M(e,r){let a=[];for(let o=0;o<e;o++)a.push(x.charAt(Math.floor(r()*x.length)));return a.join("")}function E(e,r){let a={YYYY:String(e.getFullYear()),YY:String(e.getFullYear()).slice(-2),MM:m(e.getMonth()+1),DD:m(e.getDate()),HH:m(e.getHours()),mm:m(e.getMinutes()),ss:m(e.getSeconds())};return r.replace(/YYYY|YY|MM|DD|HH|mm|ss/g,o=>a[o]??o)}function m(e){return e<10?`0${e}`:String(e)}var i="Releases";async function V(e,r){if(!e)throw new Error("missing data source id");let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await R(o,async n=>{if((await n.get(t)).exists())throw new Error(`release exists: ${e}`);await n.set(t,{...r,id:e,createdAt:y(),createdBy:window.firebase.user.email})}),l("release.create",{metadata:{releaseId:e}})}async function G(){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,a=w(r,"Projects",e,i),o=b(a,k("createdAt","desc")),t=await j(o),n=[];return t.forEach(d=>{n.push(d.data())}),n}async function h(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e),t=await v(o);return t.exists()?t.data():null}async function K(e,r){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await u(t,r),l("release.save",{metadata:{releaseId:e}})}async function Q(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e);await u(o,{archivedAt:y(),archivedBy:window.firebase.user.email}),l("release.archive",{metadata:{releaseId:e}})}async function W(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e);await u(o,{archivedAt:c(),archivedBy:c()}),l("release.unarchive",{metadata:{releaseId:e}})}async function Z(e){let r=await h(e);if(!r)throw new Error(`release not found: ${e}`);if(r.archivedAt)throw new Error(`release is archived: ${e}`);let a=r.docIds||[],o=r.dataSourceIds||[];if(a.length===0&&o.length===0)throw new Error(`no docs or data sources to publish for release: ${e}`);let t=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,d=s(n,"Projects",t,i,e),p=I(n);p.update(d,{publishedAt:y(),publishedBy:window.firebase.user.email,scheduledAt:c(),scheduledBy:c()}),o.length>0&&await z(o,{batch:p,commitBatch:!1}),await _(a,{batch:p,releaseId:e,publishMessage:r.description}),console.log(`published release: ${e}`);let g={releaseId:e,docIds:a,dataSourceIds:o};r.description&&(g.publishMessage=r.description),l("release.publish",{metadata:g})}async function ee(e,r){let a=await h(e);if(!a)throw new Error(`release not found: ${e}`);if(a.archivedAt)throw new Error(`release is archived: ${e}`);typeof r=="number"&&(r=f.fromMillis(r));let o=window.__ROOT_CTX.rootConfig.projectId,t=window.firebase.db,n=s(t,"Projects",o,i,e);await u(n,{scheduledAt:r,scheduledBy:window.firebase.user.email}),l("release.publish",{metadata:{releaseId:e,scheduledAt:r.toMillis()}})}function re(){return D("{date}-{adjective}-{noun}")}async function ae(e){if(!await h(e))throw new Error(`release not found: ${e}`);let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await u(t,{scheduledAt:c(),scheduledBy:c()}),l("release.unschedule",{metadata:{releaseId:e}})}export{D as a,V as b,G as c,h as d,K as e,Q as f,W as g,Z as h,ee as i,re as j,ae as k};
1
+ import{c as T}from"./chunk-JDW4UORS.js";import{k as z}from"./chunk-RN4XVVWD.js";import{C as _}from"./chunk-ISUGBMXC.js";import{D as l,a as f,b as w,c as s,g as b,i as k,n as v,o as j,q as u,t as R,u as c,v as y,x as I}from"./chunk-XOWWPE7X.js";var O=["agile","airy","alert","amber","amused","ancient","aqua","arctic","astral","autumn","avid","azure","balmy","beige","big","bitter","black","blazing","blissful","blooming","blue","bold","bouncy","brainy","brave","breezy","bright","brisk","broad","bronze","brown","bubbly","busy","calm","candid","careful","caring","charming","cheerful","cherry","chilly","chipper","classic","clean","clear","clever","cloudy","coastal","cobalt","cold","cool","copper","coral","cosmic","cosy","cozy","crafty","creamy","crimson","crisp","cuddly","curious","dandy","dapper","daring","dark","dawn","dazzling","dear","deep","deft","delicate","dewy","dizzy","dotted","dreamy","driven","dry","dusky","dusty","eager","early","earnest","earthy","eastern","easy","ebony","elated","electric","elegant","emerald","empty","epic","even","every","faint","fair","falling","famous","fancy","fast","feisty","festive","fierce","fiery","fine","firm","flat","floral","flowing","fluffy","foggy","fond","forest","fragrant","fresh","friendly","frisky","frosty","funky","funny","fuzzy","gallant","gentle","giant","gilded","glad","gleaming","glossy","glowing","gold","golden","good","graceful","grand","grassy","gray","green","groovy","gusty","handy","happy","hardy","hazy","hearty","heavy","helpful","heroic","hidden","high","holy","honest","honeyed","hopeful","humble","humming","hushed","icy","ideal","idle","indigo","inky","iron","ivory","jade","jaunty","jazzy","jolly","jovial","joyful","jubilant","juicy","jumpy","keen","kind","kindly","lacy","late","lazy","leafy","lemon","light","limber","lime","linen","little","lively","lone","long","loud","lovely","loyal","lucid","lucky","luminous","lunar","lush","magenta","magic","majestic","mango","marble","maritime","maroon","massive","mauve","mellow","merry","mighty","mild","milky","mindful","minty","misty","mocha","modest","morning","mossy","muddy","mysterious","mythic","narrow","navy","neat","neon","new","nimble","noble","noisy","noon","northern","nosy","nutty","oaken","oceanic","odd","old","olive","onyx","opal","open","orange","orderly","pale","pastel","patient","peaceful","peach","peachy","pearly","pebbly","peppy","perky","pink","placid","plain","playful","pleasant","plucky","plum","plush","polar","polite","prime","pristine","proud","pure","purple","quaint","quick","quiet","quirky","radiant","rapid","rare","raven","ready","red","regal","restless","rich","rolling","rosy","rough","round","royal","ruby","rugged","rumbling","russet","rustic","sable","safe","sage","salty","sandy","sapphire","savvy","scarlet","scenic","secret","sepia","serene","shaggy","sharp","shimmering","shiny","short","shrewd","shy","silent","silky","silly","silver","simple","sleek","sleepy","slim","slow","small","smart","smoky","smooth","snappy","snowy","soaring","soft","solar","solid","southern","sparkly","speedy","spicy","spiffy","spotted","spry","square","starry","steady","steel","stellar","sticky","still","stony","stormy","striped","strong","sturdy","subtle","sunlit","sunny","super","supreme","swank","sweet","swift","tame","tan","tangy","tart","teal","tender","thin","thirsty","thriving","tidal","tidy","tiny","tireless","toasty","topaz","tough","tranquil","trim","tropical","true","twinkly","umber","upbeat","urban","useful","valiant","vast","velvet","verdant","vernal","vibrant","vintage","violet","vivid","wandering","warm","watchful","wavy","wee","western","whimsical","whispering","white","wholesome","wild","winding","windy","winter","wintry","wise","witty","wondrous","woody","wool","yellow","young","youthful","zany","zealous","zen","zesty","zippy"],A=["acorn","almond","alpaca","anchor","antler","apple","apricot","arrow","aspen","aurora","autumn","avocado","badger","bagel","bamboo","banana","basil","bay","bayou","beach","bear","bee","beetle","bell","berry","birch","bird","biscuit","bison","blossom","bluff","boat","bobcat","bonfire","book","boot","bottle","boulder","branch","brass","breeze","bridge","brook","broom","brunch","bubble","bucket","bud","buffalo","bug","bunny","burrow","butter","button","cabin","cactus","cake","camel","canary","candle","canyon","cape","caravan","cardinal","carrot","cascade","cashew","castle","cat","cave","cedar","chair","cherry","chestnut","chickpea","chime","cinnamon","citadel","cliff","cloud","clove","clover","cocoa","comet","compass","condor","cookie","coral","cottage","cotton","cove","coyote","crane","crayon","creek","cricket","crocus","crow","crumpet","crystal","cup","cupcake","currant","cypress","daffodil","dahlia","daisy","dawn","deer","delta","desert","dew","diamond","dingo","dock","dogwood","dolphin","donut","dove","dragon","drift","drizzle","drum","duck","dumpling","dune","eagle","echo","eclipse","eel","egg","elder","elephant","elk","ember","ermine","estuary","evergreen","falcon","fawn","feather","fennel","fern","ferret","field","fig","finch","fir","firefly","fish","fjord","flame","flamingo","flask","flax","fleece","flicker","flower","flute","fog","forest","fossil","fountain","fox","frog","frost","galaxy","garden","gazelle","gecko","gem","geyser","ginger","glacier","glade","glen","globe","glow","goat","goose","gorge","gourd","granite","grape","grass","grotto","grove","gull","hammock","harbor","hare","harp","harvest","hat","hawk","haystack","hazel","hearth","heather","hedge","heron","hibiscus","hickory","hill","hollow","honey","horizon","horse","hummingbird","ibis","iceberg","icicle","inlet","iris","island","ivy","jackal","jacket","jade","jaguar","jam","jar","jasmine","jay","jelly","jetty","juniper","kayak","kelp","kestrel","kettle","key","kingfisher","kite","kitten","kiwi","knoll","koala","ladybug","lagoon","lake","lamp","lantern","lark","lava","lavender","leaf","ledge","lemon","lemur","leopard","lichen","lighthouse","lilac","lily","lime","lion","llama","lobster","log","loon","lotus","lynx","lyric","magnet","manatee","mango","mangrove","maple","marble","marigold","marlin","marsh","meadow","melody","melon","mermaid","mesa","meteor","minnow","mint","mirage","mist","mitten","mole","monkey","moon","moose","morel","mosaic","moss","moth","mountain","mouse","muffin","mushroom","mussel","narwhal","nautilus","nectar","needle","nest","nettle","newt","nightingale","nimbus","noodle","north","note","nutmeg","oak","oasis","oats","ocean","ocelot","octopus","olive","onion","opal","orange","orca","orchid","oriole","osprey","otter","owl","oyster","paddle","palm","panda","pansy","panther","papaya","paper","parrot","parsley","partridge","pasture","path","peach","peacock","pear","pebble","pecan","pelican","penguin","peony","pepper","petal","petunia","pheasant","phoenix","pie","pigeon","pine","pineapple","pistachio","planet","plateau","plover","plum","pond","pony","poppy","porpoise","pouch","prairie","pretzel","primrose","puffin","pumpkin","quail","quartz","queen","quill","quince","quokka","rabbit","raccoon","radish","rain","rainbow","rapids","raspberry","raven","redwood","reef","reel","reindeer","rhino","ribbon","ridge","river","road","robin","rock","rooster","rose","rosemary","rowan","rye","saffron","sage","salmon","sand","sapphire","satellite","savanna","scallop","scarf","sea","seagull","seal","seed","sequoia","sesame","shark","shell","shore","shrimp","silk","silo","sky","skylark","sleet","snail","snake","snow","sock","sorbet","spark","sparrow","spider","spire","spoon","spring","sprout","spruce","squirrel","star","starfish","starling","stone","stork","storm","stream","summer","sun","sundial","sunflower","swan","swift","sycamore","tadpole","tamarind","tangerine","tea","teal","tern","terrace","thicket","thistle","thrush","thunder","tide","tiger","timber","toad","toffee","tooth","topaz","tortoise","totem","toucan","tower","tractor","trail","tree","trout","truffle","tugboat","tulip","tundra","turnip","turtle","twig","twilight","umbrella","unicorn","urchin","valley","vanilla","vine","violet","vista","volcano","voyage","vulture","wagon","walnut","walrus","wasp","water","waterfall","wave","whale","wharf","wheat","whisker","wildcat","wildflower","willow","wind","window","winter","wisteria","wolf","wombat","wood","wren","yak","yam","yarrow","yew","yucca","zebra","zephyr","zinnia","zucchini"];var x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",S="YYYYMMDD";function D(e,r){let a=r?.now??new Date,o=r?.random??Math.random,t=e.replace(/\{([^{}]+?)\}/g,(n,d)=>{let[p,g]=q(d);switch(p){case"date":return E(a,g||S);case"adjective":return C(O,o);case"noun":return C(A,o);case"random":return M(Y(g,6),o);default:return n}});return T(t.toLowerCase())}function q(e){let r=e.indexOf(":");return r===-1?[e.trim(),void 0]:[e.slice(0,r).trim(),e.slice(r+1)]}function Y(e,r){if(!e)return r;let a=parseInt(e,10);return Number.isFinite(a)&&a>0?a:r}function C(e,r){return e[Math.floor(r()*e.length)]}function M(e,r){let a=[];for(let o=0;o<e;o++)a.push(x.charAt(Math.floor(r()*x.length)));return a.join("")}function E(e,r){let a={YYYY:String(e.getFullYear()),YY:String(e.getFullYear()).slice(-2),MM:m(e.getMonth()+1),DD:m(e.getDate()),HH:m(e.getHours()),mm:m(e.getMinutes()),ss:m(e.getSeconds())};return r.replace(/YYYY|YY|MM|DD|HH|mm|ss/g,o=>a[o]??o)}function m(e){return e<10?`0${e}`:String(e)}var i="Releases";async function V(e,r){if(!e)throw new Error("missing data source id");let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await R(o,async n=>{if((await n.get(t)).exists())throw new Error(`release exists: ${e}`);await n.set(t,{...r,id:e,createdAt:y(),createdBy:window.firebase.user.email})}),l("release.create",{metadata:{releaseId:e}})}async function G(){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,a=w(r,"Projects",e,i),o=b(a,k("createdAt","desc")),t=await j(o),n=[];return t.forEach(d=>{n.push(d.data())}),n}async function h(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e),t=await v(o);return t.exists()?t.data():null}async function K(e,r){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await u(t,r),l("release.save",{metadata:{releaseId:e}})}async function Q(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e);await u(o,{archivedAt:y(),archivedBy:window.firebase.user.email}),l("release.archive",{metadata:{releaseId:e}})}async function W(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e);await u(o,{archivedAt:c(),archivedBy:c()}),l("release.unarchive",{metadata:{releaseId:e}})}async function Z(e){let r=await h(e);if(!r)throw new Error(`release not found: ${e}`);if(r.archivedAt)throw new Error(`release is archived: ${e}`);let a=r.docIds||[],o=r.dataSourceIds||[];if(a.length===0&&o.length===0)throw new Error(`no docs or data sources to publish for release: ${e}`);let t=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,d=s(n,"Projects",t,i,e),p=I(n);p.update(d,{publishedAt:y(),publishedBy:window.firebase.user.email,scheduledAt:c(),scheduledBy:c()}),o.length>0&&await z(o,{batch:p,commitBatch:!1}),await _(a,{batch:p,releaseId:e,publishMessage:r.description}),console.log(`published release: ${e}`);let g={releaseId:e,docIds:a,dataSourceIds:o};r.description&&(g.publishMessage=r.description),l("release.publish",{metadata:g})}async function ee(e,r){let a=await h(e);if(!a)throw new Error(`release not found: ${e}`);if(a.archivedAt)throw new Error(`release is archived: ${e}`);typeof r=="number"&&(r=f.fromMillis(r));let o=window.__ROOT_CTX.rootConfig.projectId,t=window.firebase.db,n=s(t,"Projects",o,i,e);await u(n,{scheduledAt:r,scheduledBy:window.firebase.user.email}),l("release.publish",{metadata:{releaseId:e,scheduledAt:r.toMillis()}})}function re(){return D("{date}-{adjective}-{noun}")}async function ae(e){if(!await h(e))throw new Error(`release not found: ${e}`);let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await u(t,{scheduledAt:c(),scheduledBy:c()}),l("release.unschedule",{metadata:{releaseId:e}})}export{D as a,V as b,G as c,h as d,K as e,Q as f,W as g,Z as h,ee as i,re as j,ae as k};
@@ -1,4 +1,4 @@
1
- import{A as ue,B as vo,C as We,D as te,E as se,F as Ge,G as ce,H as ie,I as ve,J as ye,K as xe,L as de,M as xo,N as Ae,O as wo,Q as So,R as Co,S as To,X as Io,Y as ko,Z as jo,a as Ue,b as yt,c as go,d as bt,e as $e,f as Et,g as Ve,h as le,i as e,j as re,k as vt,l as _o,m as Ce,n as fo,o as _e,p as xt,q as nt,r as pe,s as Ee,t as yo,u as at,v as Je,w as wt,x as bo,y as C,z as T}from"./chunk-AAR7DBEN.js";import{a as St}from"./chunk-YDO2EDVY.js";import{S as mo,U as Nt,Y as ot,_ as ho}from"./chunk-YV5SGR24.js";import{a as io,b as so,c as lo,g as uo,j as co,n as we,o as po,p as ft,q as Rt,v as Ne}from"./chunk-XOWWPE7X.js";import{c as jt,e as et,h as tt,k as _t,y as Ot}from"./chunk-ETPZ3TXX.js";import{b as ta,d as oa}from"./chunk-PVAE643M.js";var Ro=ta((Fl,Oo)=>{"use strict";function na(t,o){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let n,a=0;return function(...i){clearTimeout(n);let u=Date.now(),s=u-a,g=o-s;g<=0?(a=u,t.apply(this,i)):n=setTimeout(()=>{a=Date.now(),t.apply(this,i)},g)}}Oo.exports=na});Ot();var Ao=oa(Ro(),1);Ot();Ot();var Eo=(t,o,n)=>{if(!o.has(t))throw TypeError("Cannot "+n)},ge=(t,o,n)=>(Eo(t,o,"read from private field"),n?n.call(t):o.get(t)),Re=(t,o,n)=>{if(o.has(t))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(t):o.set(t,n)},Me=(t,o,n,a)=>(Eo(t,o,"write to private field"),a?a.call(t,n):o.set(t,n),n);function ia(t,o){return o!=null?(0,Ao.default)(t,o):t}var Se,Ct,Tt,rt,it,st,Be,At,Mt,sa=class{constructor(t=[]){Re(this,Se,void 0),Re(this,Ct,"ready"),Re(this,Tt,void 0),Re(this,rt,new Set),Re(this,it,new Set),Re(this,st,new Set),this.pushMessage=o=>{Me(this,Se,ge(this,Se).concat(o)),ge(this,Be).call(this)},this.popMessage=()=>{Me(this,Se,ge(this,Se).slice(0,-1)),ge(this,Be).call(this)},this.replaceMessage=(o,n)=>{Me(this,Se,[...ge(this,Se).slice(0,o),this.snapshot(n),...ge(this,Se).slice(o+1)]),ge(this,Be).call(this)},this.snapshot=o=>structuredClone(o),this["~registerMessagesCallback"]=(o,n)=>{let a=n?ia(o,n):o;return ge(this,rt).add(a),()=>{ge(this,rt).delete(a)}},this["~registerStatusCallback"]=o=>(ge(this,it).add(o),()=>{ge(this,it).delete(o)}),this["~registerErrorCallback"]=o=>(ge(this,st).add(o),()=>{ge(this,st).delete(o)}),Re(this,Be,()=>{ge(this,rt).forEach(o=>o())}),Re(this,At,()=>{ge(this,it).forEach(o=>o())}),Re(this,Mt,()=>{ge(this,st).forEach(o=>o())}),Me(this,Se,t)}get status(){return ge(this,Ct)}set status(t){Me(this,Ct,t),ge(this,At).call(this)}get error(){return ge(this,Tt)}set error(t){Me(this,Tt,t),ge(this,Mt).call(this)}get messages(){return ge(this,Se)}set messages(t){Me(this,Se,[...t]),ge(this,Be).call(this)}};Se=new WeakMap;Ct=new WeakMap;Tt=new WeakMap;rt=new WeakMap;it=new WeakMap;st=new WeakMap;Be=new WeakMap;At=new WeakMap;Mt=new WeakMap;var Ke,No=class extends To{constructor({messages:t,...o}){let n=new sa(t);super({...o,state:n}),Re(this,Ke,void 0),this["~registerMessagesCallback"]=(a,r)=>ge(this,Ke)["~registerMessagesCallback"](a,r),this["~registerStatusCallback"]=a=>ge(this,Ke)["~registerStatusCallback"](a),this["~registerErrorCallback"]=a=>ge(this,Ke)["~registerErrorCallback"](a),Me(this,Ke,n)}};Ke=new WeakMap;function Vl({experimental_throttle:t,resume:o=!1,...n}={}){let a=et("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(a.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});let r={...n,onToolCall:h=>{var v,_;return(_=(v=a.current).onToolCall)==null?void 0:_.call(v,h)},onData:h=>{var v,_;return(_=(v=a.current).onData)==null?void 0:_.call(v,h)},onFinish:h=>{var v,_;return(_=(v=a.current).onFinish)==null?void 0:_.call(v,h)},onError:h=>{var v,_;return(_=(v=a.current).onError)==null?void 0:_.call(v,h)},sendAutomaticallyWhen:h=>{var v,_,y;return(y=(_=(v=a.current).sendAutomaticallyWhen)==null?void 0:_.call(v,h))!=null?y:!1}},i=et("chat"in n?n.chat:new No(r));("chat"in n&&n.chat!==i.current||"id"in n&&i.current.id!==n.id)&&(i.current="chat"in n?n.chat:new No(r));let s=tt(h=>i.current["~registerMessagesCallback"](h,t),[t,i.current.id]),g=_t(s,()=>i.current.messages,()=>i.current.messages),m=_t(i.current["~registerStatusCallback"],()=>i.current.status,()=>i.current.status),l=_t(i.current["~registerErrorCallback"],()=>i.current.error,()=>i.current.error),p=tt(h=>{typeof h=="function"&&(h=h(i.current.messages)),i.current.messages=h},[i]);return jt(()=>{o&&i.current.resumeStream()},[o,i]),{id:i.current.id,messages:g,setMessages:p,sendMessage:i.current.sendMessage,regenerate:i.current.regenerate,clearError:i.current.clearError,stop:i.current.stop,error:l,resumeStream:i.current.resumeStream,status:m,addToolResult:i.current.addToolOutput,addToolOutput:i.current.addToolOutput,addToolApprovalResponse:i.current.addToolApprovalResponse}}var la="3.0.74",ua=C(()=>T(e.object({type:e.literal("error"),error:e.object({type:e.string(),message:e.string()})}))),Mo=ye({errorSchema:ua,errorToMessage:t=>t.error.message}),ca=C(()=>T(e.object({type:e.literal("message"),id:e.string().nullish(),model:e.string().nullish(),content:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("text"),text:e.string(),citations:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("web_search_result_location"),cited_text:e.string(),url:e.string(),title:e.string(),encrypted_index:e.string()}),e.object({type:e.literal("page_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_page_number:e.number(),end_page_number:e.number()}),e.object({type:e.literal("char_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_char_index:e.number(),end_char_index:e.number()})])).optional()}),e.object({type:e.literal("thinking"),thinking:e.string(),signature:e.string()}),e.object({type:e.literal("redacted_thinking"),data:e.string()}),e.object({type:e.literal("compaction"),content:e.string()}),e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.unknown(),caller:e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("server_tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).nullish(),caller:e.union([e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("mcp_tool_use"),id:e.string(),name:e.string(),input:e.unknown(),server_name:e.string()}),e.object({type:e.literal("mcp_tool_result"),tool_use_id:e.string(),is_error:e.boolean(),content:e.array(e.union([e.string(),e.object({type:e.literal("text"),text:e.string()})]))}),e.object({type:e.literal("web_fetch_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("web_fetch_result"),url:e.string(),retrieved_at:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),media_type:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),media_type:e.literal("text/plain"),data:e.string()})])})}),e.object({type:e.literal("web_fetch_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("web_search_tool_result"),tool_use_id:e.string(),content:e.union([e.array(e.object({type:e.literal("web_search_result"),url:e.string(),title:e.string(),encrypted_content:e.string(),page_age:e.string().nullish()})),e.object({type:e.literal("web_search_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("code_execution_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("bash_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("text_editor_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})])}),e.object({type:e.literal("tool_search_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("tool_search_tool_search_result"),tool_references:e.array(e.object({type:e.literal("tool_reference"),tool_name:e.string()}))}),e.object({type:e.literal("tool_search_tool_result_error"),error_code:e.string()})])})])),stop_reason:e.string().nullish(),stop_sequence:e.string().nullish(),usage:e.looseObject({input_tokens:e.number(),output_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish(),iterations:e.array(e.object({type:e.union([e.literal("compaction"),e.literal("message")]),input_tokens:e.number(),output_tokens:e.number()})).nullish()}),container:e.object({expires_at:e.string(),id:e.string(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skill_id:e.string(),version:e.string()})).nullish()}).nullish(),context_management:e.object({applied_edits:e.array(e.union([e.object({type:e.literal("clear_tool_uses_20250919"),cleared_tool_uses:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("clear_thinking_20251015"),cleared_thinking_turns:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("compact_20260112")})]))}).nullish()}))),da=C(()=>T(e.discriminatedUnion("type",[e.object({type:e.literal("message_start"),message:e.object({id:e.string().nullish(),model:e.string().nullish(),role:e.string().nullish(),usage:e.looseObject({input_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish()}),content:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.unknown(),caller:e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()})])).nullish(),stop_reason:e.string().nullish(),container:e.object({expires_at:e.string(),id:e.string()}).nullish()})}),e.object({type:e.literal("content_block_start"),index:e.number(),content_block:e.discriminatedUnion("type",[e.object({type:e.literal("text"),text:e.string()}),e.object({type:e.literal("thinking"),thinking:e.string()}),e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).optional(),caller:e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("redacted_thinking"),data:e.string()}),e.object({type:e.literal("compaction"),content:e.string().nullish()}),e.object({type:e.literal("server_tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).nullish(),caller:e.union([e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("mcp_tool_use"),id:e.string(),name:e.string(),input:e.unknown(),server_name:e.string()}),e.object({type:e.literal("mcp_tool_result"),tool_use_id:e.string(),is_error:e.boolean(),content:e.array(e.union([e.string(),e.object({type:e.literal("text"),text:e.string()})]))}),e.object({type:e.literal("web_fetch_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("web_fetch_result"),url:e.string(),retrieved_at:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),media_type:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),media_type:e.literal("text/plain"),data:e.string()})])})}),e.object({type:e.literal("web_fetch_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("web_search_tool_result"),tool_use_id:e.string(),content:e.union([e.array(e.object({type:e.literal("web_search_result"),url:e.string(),title:e.string(),encrypted_content:e.string(),page_age:e.string().nullish()})),e.object({type:e.literal("web_search_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("code_execution_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("bash_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("text_editor_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})])}),e.object({type:e.literal("tool_search_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("tool_search_tool_search_result"),tool_references:e.array(e.object({type:e.literal("tool_reference"),tool_name:e.string()}))}),e.object({type:e.literal("tool_search_tool_result_error"),error_code:e.string()})])})])}),e.object({type:e.literal("content_block_delta"),index:e.number(),delta:e.discriminatedUnion("type",[e.object({type:e.literal("input_json_delta"),partial_json:e.string()}),e.object({type:e.literal("text_delta"),text:e.string()}),e.object({type:e.literal("thinking_delta"),thinking:e.string()}),e.object({type:e.literal("signature_delta"),signature:e.string()}),e.object({type:e.literal("compaction_delta"),content:e.string().nullish()}),e.object({type:e.literal("citations_delta"),citation:e.discriminatedUnion("type",[e.object({type:e.literal("web_search_result_location"),cited_text:e.string(),url:e.string(),title:e.string(),encrypted_index:e.string()}),e.object({type:e.literal("page_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_page_number:e.number(),end_page_number:e.number()}),e.object({type:e.literal("char_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_char_index:e.number(),end_char_index:e.number()})])})])}),e.object({type:e.literal("content_block_stop"),index:e.number()}),e.object({type:e.literal("error"),error:e.object({type:e.string(),message:e.string()})}),e.object({type:e.literal("message_delta"),delta:e.object({stop_reason:e.string().nullish(),stop_sequence:e.string().nullish(),container:e.object({expires_at:e.string(),id:e.string(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skill_id:e.string(),version:e.string()})).nullish()}).nullish()}),usage:e.looseObject({input_tokens:e.number().nullish(),output_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish(),iterations:e.array(e.object({type:e.union([e.literal("compaction"),e.literal("message")]),input_tokens:e.number(),output_tokens:e.number()})).nullish()}),context_management:e.object({applied_edits:e.array(e.union([e.object({type:e.literal("clear_tool_uses_20250919"),cleared_tool_uses:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("clear_thinking_20251015"),cleared_thinking_turns:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("compact_20260112")})]))}).nullish()}),e.object({type:e.literal("message_stop")}),e.object({type:e.literal("ping")})]))),pa=C(()=>T(e.object({signature:e.string().optional(),redactedData:e.string().optional()}))),zo=e.object({citations:e.object({enabled:e.boolean()}).optional(),title:e.string().optional(),context:e.string().optional()}),Do=e.object({sendReasoning:e.boolean().optional(),structuredOutputMode:e.enum(["outputFormat","jsonTool","auto"]).optional(),thinking:e.discriminatedUnion("type",[e.object({type:e.literal("adaptive"),display:e.enum(["omitted","summarized"]).optional()}),e.object({type:e.literal("enabled"),budgetTokens:e.number().optional()}),e.object({type:e.literal("disabled")})]).optional(),disableParallelToolUse:e.boolean().optional(),cacheControl:e.object({type:e.literal("ephemeral"),ttl:e.union([e.literal("5m"),e.literal("1h")]).optional()}).optional(),metadata:e.object({userId:e.string().optional()}).optional(),mcpServers:e.array(e.object({type:e.literal("url"),name:e.string(),url:e.string(),authorizationToken:e.string().nullish(),toolConfiguration:e.object({enabled:e.boolean().nullish(),allowedTools:e.array(e.string()).nullish()}).nullish()})).optional(),container:e.object({id:e.string().optional(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skillId:e.string(),version:e.string().optional()})).optional()}).optional(),toolStreaming:e.boolean().optional(),effort:e.enum(["low","medium","high","xhigh","max"]).optional(),taskBudget:e.object({type:e.literal("tokens"),total:e.number().int().min(2e4),remaining:e.number().int().min(0).optional()}).optional(),speed:e.enum(["fast","standard"]).optional(),inferenceGeo:e.enum(["us","global"]).optional(),anthropicBeta:e.array(e.string()).optional(),contextManagement:e.object({edits:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("clear_tool_uses_20250919"),trigger:e.discriminatedUnion("type",[e.object({type:e.literal("input_tokens"),value:e.number()}),e.object({type:e.literal("tool_uses"),value:e.number()})]).optional(),keep:e.object({type:e.literal("tool_uses"),value:e.number()}).optional(),clearAtLeast:e.object({type:e.literal("input_tokens"),value:e.number()}).optional(),clearToolInputs:e.boolean().optional(),excludeTools:e.array(e.string()).optional()}),e.object({type:e.literal("clear_thinking_20251015"),keep:e.union([e.literal("all"),e.object({type:e.literal("thinking_turns"),value:e.number()})]).optional()}),e.object({type:e.literal("compact_20260112"),trigger:e.object({type:e.literal("input_tokens"),value:e.number()}).optional(),pauseAfterCompaction:e.boolean().optional(),instructions:e.string().optional()})]))}).optional()}),Po=4;function ma(t){var o;let n=t?.anthropic;return(o=n?.cacheControl)!=null?o:n?.cache_control}var qt=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(t,o){let n=ma(t);if(n){if(!o.canCache){this.warnings.push({type:"unsupported",feature:"cache_control on non-cacheable context",details:`cache_control cannot be set on ${o.type}. It will be ignored.`});return}if(this.breakpointCount++,this.breakpointCount>Po){this.warnings.push({type:"unsupported",feature:"cacheControl breakpoint limit",details:`Maximum ${Po} cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`});return}return n}}getWarnings(){return this.warnings}},ha=C(()=>T(e.object({maxCharacters:e.number().optional()}))),ga=C(()=>T(e.object({command:e.enum(["view","create","str_replace","insert"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),_a=ce({id:"anthropic.text_editor_20250728",inputSchema:ga}),fa=(t={})=>_a(t),ya=C(()=>T(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),userLocation:e.object({type:e.literal("approximate"),city:e.string().optional(),region:e.string().optional(),country:e.string().optional(),timezone:e.string().optional()}).optional()}))),ba=C(()=>T(e.array(e.object({url:e.string(),title:e.string().nullable(),pageAge:e.string().nullable(),encryptedContent:e.string(),type:e.literal("web_search_result")})))),va=C(()=>T(e.object({query:e.string()}))),xa=ie({id:"anthropic.web_search_20260209",inputSchema:va,outputSchema:ba,supportsDeferredResults:!0}),wa=(t={})=>xa(t),Sa=C(()=>T(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),userLocation:e.object({type:e.literal("approximate"),city:e.string().optional(),region:e.string().optional(),country:e.string().optional(),timezone:e.string().optional()}).optional()}))),Lo=C(()=>T(e.array(e.object({url:e.string(),title:e.string().nullable(),pageAge:e.string().nullable(),encryptedContent:e.string(),type:e.literal("web_search_result")})))),Ca=C(()=>T(e.object({query:e.string()}))),Ta=ie({id:"anthropic.web_search_20250305",inputSchema:Ca,outputSchema:Lo,supportsDeferredResults:!0}),Ia=(t={})=>Ta(t),ka=C(()=>T(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),citations:e.object({enabled:e.boolean()}).optional(),maxContentTokens:e.number().optional()}))),ja=C(()=>T(e.object({type:e.literal("web_fetch_result"),url:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),mediaType:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),mediaType:e.literal("text/plain"),data:e.string()})])}),retrievedAt:e.string().nullable()}))),Oa=C(()=>T(e.object({url:e.string()}))),Ra=ie({id:"anthropic.web_fetch_20260209",inputSchema:Oa,outputSchema:ja,supportsDeferredResults:!0}),Na=(t={})=>Ra(t),Ea=C(()=>T(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),citations:e.object({enabled:e.boolean()}).optional(),maxContentTokens:e.number().optional()}))),Ho=C(()=>T(e.object({type:e.literal("web_fetch_result"),url:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),mediaType:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),mediaType:e.literal("text/plain"),data:e.string()})])}),retrievedAt:e.string().nullable()}))),Aa=C(()=>T(e.object({url:e.string()}))),Ma=ie({id:"anthropic.web_fetch_20250910",inputSchema:Aa,outputSchema:Ho,supportsDeferredResults:!0}),za=(t={})=>Ma(t);async function Da({tools:t,toolChoice:o,disableParallelToolUse:n,cacheControlValidator:a,supportsStructuredOutput:r,supportsStrictTools:i,defaultEagerInputStreaming:u=!1}){var s,g;t=t?.length?t:void 0;let m=[],l=new Set,p=a||new qt;if(t==null)return{tools:void 0,toolChoice:void 0,toolWarnings:m,betas:l};let h=[];for(let _ of t)switch(_.type){case"function":{let y=p.getCacheControl(_.providerOptions,{type:"tool definition",canCache:!0}),I=(s=_.providerOptions)==null?void 0:s.anthropic,S=(g=I?.eagerInputStreaming)!=null?g:u,b=I?.deferLoading,O=I?.allowedCallers;!i&&_.strict!=null&&m.push({type:"unsupported",feature:"strict",details:`Tool '${_.name}' has strict: ${_.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`}),h.push({name:_.name,description:_.description,input_schema:_.inputSchema,cache_control:y,...S?{eager_input_streaming:!0}:{},...i===!0&&_.strict!=null?{strict:_.strict}:{},...b!=null?{defer_loading:b}:{},...O!=null?{allowed_callers:O}:{},..._.inputExamples!=null?{input_examples:_.inputExamples.map(N=>N.input)}:{}}),r===!0&&l.add("structured-outputs-2025-11-13"),(_.inputExamples!=null||O!=null)&&l.add("advanced-tool-use-2025-11-20");break}case"provider":{switch(_.id){case"anthropic.code_execution_20250522":{l.add("code-execution-2025-05-22"),h.push({type:"code_execution_20250522",name:"code_execution",cache_control:void 0});break}case"anthropic.code_execution_20250825":{l.add("code-execution-2025-08-25"),h.push({type:"code_execution_20250825",name:"code_execution"});break}case"anthropic.code_execution_20260120":{h.push({type:"code_execution_20260120",name:"code_execution"});break}case"anthropic.computer_20250124":{l.add("computer-use-2025-01-24"),h.push({name:"computer",type:"computer_20250124",display_width_px:_.args.displayWidthPx,display_height_px:_.args.displayHeightPx,display_number:_.args.displayNumber,cache_control:void 0});break}case"anthropic.computer_20251124":{l.add("computer-use-2025-11-24"),h.push({name:"computer",type:"computer_20251124",display_width_px:_.args.displayWidthPx,display_height_px:_.args.displayHeightPx,display_number:_.args.displayNumber,enable_zoom:_.args.enableZoom,cache_control:void 0});break}case"anthropic.computer_20241022":{l.add("computer-use-2024-10-22"),h.push({name:"computer",type:"computer_20241022",display_width_px:_.args.displayWidthPx,display_height_px:_.args.displayHeightPx,display_number:_.args.displayNumber,cache_control:void 0});break}case"anthropic.text_editor_20250124":{l.add("computer-use-2025-01-24"),h.push({name:"str_replace_editor",type:"text_editor_20250124",cache_control:void 0});break}case"anthropic.text_editor_20241022":{l.add("computer-use-2024-10-22"),h.push({name:"str_replace_editor",type:"text_editor_20241022",cache_control:void 0});break}case"anthropic.text_editor_20250429":{l.add("computer-use-2025-01-24"),h.push({name:"str_replace_based_edit_tool",type:"text_editor_20250429",cache_control:void 0});break}case"anthropic.text_editor_20250728":{let y=await ue({value:_.args,schema:ha});h.push({name:"str_replace_based_edit_tool",type:"text_editor_20250728",max_characters:y.maxCharacters,cache_control:void 0});break}case"anthropic.bash_20250124":{l.add("computer-use-2025-01-24"),h.push({name:"bash",type:"bash_20250124",cache_control:void 0});break}case"anthropic.bash_20241022":{l.add("computer-use-2024-10-22"),h.push({name:"bash",type:"bash_20241022",cache_control:void 0});break}case"anthropic.memory_20250818":{l.add("context-management-2025-06-27"),h.push({name:"memory",type:"memory_20250818"});break}case"anthropic.web_fetch_20250910":{l.add("web-fetch-2025-09-10");let y=await ue({value:_.args,schema:Ea});h.push({type:"web_fetch_20250910",name:"web_fetch",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,citations:y.citations,max_content_tokens:y.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260209":{l.add("code-execution-web-tools-2026-02-09");let y=await ue({value:_.args,schema:ka});h.push({type:"web_fetch_20260209",name:"web_fetch",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,citations:y.citations,max_content_tokens:y.maxContentTokens,cache_control:void 0});break}case"anthropic.web_search_20250305":{let y=await ue({value:_.args,schema:Sa});h.push({type:"web_search_20250305",name:"web_search",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,user_location:y.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260209":{l.add("code-execution-web-tools-2026-02-09");let y=await ue({value:_.args,schema:ya});h.push({type:"web_search_20260209",name:"web_search",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,user_location:y.userLocation,cache_control:void 0});break}case"anthropic.tool_search_regex_20251119":{h.push({type:"tool_search_tool_regex_20251119",name:"tool_search_tool_regex"});break}case"anthropic.tool_search_bm25_20251119":{h.push({type:"tool_search_tool_bm25_20251119",name:"tool_search_tool_bm25"});break}default:{m.push({type:"unsupported",feature:`provider-defined tool ${_.id}`});break}}break}default:{m.push({type:"unsupported",feature:`tool ${_}`});break}}if(o==null)return{tools:h,toolChoice:n?{type:"auto",disable_parallel_tool_use:n}:void 0,toolWarnings:m,betas:l};let v=o.type;switch(v){case"auto":return{tools:h,toolChoice:{type:"auto",disable_parallel_tool_use:n},toolWarnings:m,betas:l};case"required":return{tools:h,toolChoice:{type:"any",disable_parallel_tool_use:n},toolWarnings:m,betas:l};case"none":return{tools:void 0,toolChoice:void 0,toolWarnings:m,betas:l};case"tool":return{tools:h,toolChoice:{type:"tool",name:o.toolName,disable_parallel_tool_use:n},toolWarnings:m,betas:l};default:{let _=v;throw new le({functionality:`tool choice type: ${_}`})}}}function qo({usage:t,rawUsage:o}){var n,a;let r=(n=t.cache_creation_input_tokens)!=null?n:0,i=(a=t.cache_read_input_tokens)!=null?a:0,u,s;if(t.iterations&&t.iterations.length>0){let g=t.iterations.reduce((m,l)=>({input:m.input+l.input_tokens,output:m.output+l.output_tokens}),{input:0,output:0});u=g.input,s=g.output}else u=t.input_tokens,s=t.output_tokens;return{inputTokens:{total:u+r+i,noCache:u,cacheRead:i,cacheWrite:r},outputTokens:{total:s,text:void 0,reasoning:void 0},raw:o??t}}var Vo=C(()=>T(e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}))),Pa=C(()=>T(e.object({code:e.string()}))),qa=ie({id:"anthropic.code_execution_20250522",inputSchema:Pa,outputSchema:Vo}),Ua=(t={})=>qa(t),Jo=C(()=>T(e.discriminatedUnion("type",[e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})]))),$a=C(()=>T(e.discriminatedUnion("type",[e.object({type:e.literal("programmatic-tool-call"),code:e.string()}),e.object({type:e.literal("bash_code_execution"),command:e.string()}),e.discriminatedUnion("command",[e.object({type:e.literal("text_editor_code_execution"),command:e.literal("view"),path:e.string()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("create"),path:e.string(),file_text:e.string().nullish()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()})])]))),Fa=ie({id:"anthropic.code_execution_20250825",inputSchema:$a,outputSchema:Jo,supportsDeferredResults:!0}),La=(t={})=>Fa(t),Wo=C(()=>T(e.discriminatedUnion("type",[e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})]))),Ha=C(()=>T(e.discriminatedUnion("type",[e.object({type:e.literal("programmatic-tool-call"),code:e.string()}),e.object({type:e.literal("bash_code_execution"),command:e.string()}),e.discriminatedUnion("command",[e.object({type:e.literal("text_editor_code_execution"),command:e.literal("view"),path:e.string()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("create"),path:e.string(),file_text:e.string().nullish()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()})])]))),Va=ie({id:"anthropic.code_execution_20260120",inputSchema:Ha,outputSchema:Wo,supportsDeferredResults:!0}),Ja=(t={})=>Va(t),Go=C(()=>T(e.array(e.object({type:e.literal("tool_reference"),toolName:e.string()})))),Wa=C(()=>T(e.object({pattern:e.string(),limit:e.number().optional()}))),Ga=ie({id:"anthropic.tool_search_regex_20251119",inputSchema:Wa,outputSchema:Go,supportsDeferredResults:!0}),Ba=(t={})=>Ga(t);function Ka(t){if(typeof t=="string")return new TextDecoder().decode(Ce(t));if(t instanceof Uint8Array)return new TextDecoder().decode(t);throw t instanceof URL?new le({functionality:"URL-based text documents are not supported for citations"}):new le({functionality:`unsupported data type for text documents: ${typeof t}`})}function zt(t){return t instanceof URL||Ya(t)}function Ya(t){return typeof t=="string"&&/^https?:\/\//i.test(t)}function Dt(t){return t instanceof URL?t.toString():t}async function Xa({prompt:t,sendReasoning:o,warnings:n,cacheControlValidator:a,toolNameMapping:r}){var i,u,s,g,m,l,p,h,v,_,y,I,S,b,O,N,V,F,D;let f=new Set,c=Qa(t),H=a||new qt,U,W=[];async function Z(R){var $,j;let A=await te({provider:"anthropic",providerOptions:R,schema:zo});return(j=($=A?.citations)==null?void 0:$.enabled)!=null?j:!1}async function q(R){let $=await te({provider:"anthropic",providerOptions:R,schema:zo});return{title:$?.title,context:$?.context}}for(let R=0;R<c.length;R++){let $=c[R],j=R===c.length-1,A=$.type;switch(A){case"system":{if(U!=null)throw new le({functionality:"Multiple system messages that are separated by user/assistant messages"});U=$.messages.map(({content:P,providerOptions:J})=>({type:"text",text:P,cache_control:H.getCacheControl(J,{type:"system message",canCache:!0})}));break}case"user":{let P=[];for(let J of $.messages){let{role:M,content:G}=J;switch(M){case"user":{for(let ae=0;ae<G.length;ae++){let K=G[ae],ee=ae===G.length-1,w=(i=H.getCacheControl(K.providerOptions,{type:"user message part",canCache:!0}))!=null?i:ee?H.getCacheControl(J.providerOptions,{type:"user message",canCache:!0}):void 0;switch(K.type){case"text":{P.push({type:"text",text:K.text,cache_control:w});break}case"file":{if(K.mediaType.startsWith("image/"))P.push({type:"image",source:zt(K.data)?{type:"url",url:Dt(K.data)}:{type:"base64",media_type:K.mediaType==="image/*"?"image/jpeg":K.mediaType,data:_e(K.data)},cache_control:w});else if(K.mediaType==="application/pdf"){f.add("pdfs-2024-09-25");let Y=await Z(K.providerOptions),B=await q(K.providerOptions);P.push({type:"document",source:zt(K.data)?{type:"url",url:Dt(K.data)}:{type:"base64",media_type:"application/pdf",data:_e(K.data)},title:(u=B.title)!=null?u:K.filename,...B.context&&{context:B.context},...Y&&{citations:{enabled:!0}},cache_control:w})}else if(K.mediaType==="text/plain"){let Y=await Z(K.providerOptions),B=await q(K.providerOptions);P.push({type:"document",source:zt(K.data)?{type:"url",url:Dt(K.data)}:{type:"text",media_type:"text/plain",data:Ka(K.data)},title:(s=B.title)!=null?s:K.filename,...B.context&&{context:B.context},...Y&&{citations:{enabled:!0}},cache_control:w})}else throw new le({functionality:`media type: ${K.mediaType}`});break}}}break}case"tool":{for(let ae=0;ae<G.length;ae++){let K=G[ae];if(K.type==="tool-approval-response")continue;let ee=ae===G.length-1,w=(g=H.getCacheControl(K.providerOptions,{type:"tool result part",canCache:!0}))!=null?g:ee?H.getCacheControl(J.providerOptions,{type:"tool result message",canCache:!0}):void 0,Y=K.output,B;switch(Y.type){case"content":B=Y.value.map(Q=>{var k;switch(Q.type){case"text":return{type:"text",text:Q.text};case"image-data":return{type:"image",source:{type:"base64",media_type:Q.mediaType,data:Q.data}};case"image-url":return{type:"image",source:{type:"url",url:Q.url}};case"file-url":return{type:"document",source:{type:"url",url:Q.url}};case"file-data":{if(Q.mediaType==="application/pdf")return f.add("pdfs-2024-09-25"),{type:"document",source:{type:"base64",media_type:Q.mediaType,data:Q.data}};n.push({type:"other",message:`unsupported tool content part type: ${Q.type} with media type: ${Q.mediaType}`});return}case"custom":{let z=(k=Q.providerOptions)==null?void 0:k.anthropic;if(z?.type==="tool-reference")return{type:"tool_reference",tool_name:z.toolName};n.push({type:"other",message:"unsupported custom tool content part"});return}default:{n.push({type:"other",message:`unsupported tool content part type: ${Q.type}`});return}}}).filter(at);break;case"text":case"error-text":B=Y.value;break;case"execution-denied":B=(m=Y.reason)!=null?m:"Tool execution denied.";break;default:B=JSON.stringify(Y.value);break}P.push({type:"tool_result",tool_use_id:K.toolCallId,content:B,is_error:Y.type==="error-text"||Y.type==="error-json"?!0:void 0,cache_control:w})}break}default:{let ae=M;throw new Error(`Unsupported role: ${ae}`)}}}W.push({role:"user",content:P});break}case"assistant":{let P=[],J=new Set;for(let M=0;M<$.messages.length;M++){let G=$.messages[M],ae=M===$.messages.length-1,{content:K}=G;for(let ee=0;ee<K.length;ee++){let w=K[ee],Y=ee===K.length-1,B=(l=H.getCacheControl(w.providerOptions,{type:"assistant message part",canCache:!0}))!=null?l:Y?H.getCacheControl(G.providerOptions,{type:"assistant message",canCache:!0}):void 0;switch(w.type){case"text":{let Q=(p=w.providerOptions)==null?void 0:p.anthropic;Q?.type==="compaction"?P.push({type:"compaction",content:w.text,cache_control:B}):P.push({type:"text",text:j&&ae&&Y?w.text.trim():w.text,cache_control:B});break}case"reasoning":{if(o){let Q=await te({provider:"anthropic",providerOptions:w.providerOptions,schema:pa});Q!=null?Q.signature!=null?(H.getCacheControl(w.providerOptions,{type:"thinking block",canCache:!1}),P.push({type:"thinking",thinking:w.text,signature:Q.signature})):Q.redactedData!=null?(H.getCacheControl(w.providerOptions,{type:"redacted thinking block",canCache:!1}),P.push({type:"redacted_thinking",data:Q.redactedData})):n.push({type:"other",message:"unsupported reasoning metadata"}):n.push({type:"other",message:"unsupported reasoning metadata"})}else n.push({type:"other",message:"sending reasoning content is disabled for this model"});break}case"tool-call":{if(w.providerExecuted){let z=r.toProviderToolName(w.toolName);if(((v=(h=w.providerOptions)==null?void 0:h.anthropic)==null?void 0:v.type)==="mcp-tool-use"){J.add(w.toolCallId);let x=(y=(_=w.providerOptions)==null?void 0:_.anthropic)==null?void 0:y.serverName;if(x==null||typeof x!="string"){n.push({type:"other",message:"mcp tool use server name is required and must be a string"});break}P.push({type:"mcp_tool_use",id:w.toolCallId,name:w.toolName,input:w.input,server_name:x,cache_control:B})}else if(z==="code_execution"&&w.input!=null&&typeof w.input=="object"&&"type"in w.input&&typeof w.input.type=="string"&&(w.input.type==="bash_code_execution"||w.input.type==="text_editor_code_execution"))P.push({type:"server_tool_use",id:w.toolCallId,name:w.input.type,input:w.input,cache_control:B});else if(z==="code_execution"&&w.input!=null&&typeof w.input=="object"&&"type"in w.input&&w.input.type==="programmatic-tool-call"){let{type:x,...ne}=w.input;P.push({type:"server_tool_use",id:w.toolCallId,name:"code_execution",input:ne,cache_control:B})}else z==="code_execution"||z==="web_fetch"||z==="web_search"?P.push({type:"server_tool_use",id:w.toolCallId,name:z,input:w.input,cache_control:B}):z==="tool_search_tool_regex"||z==="tool_search_tool_bm25"?P.push({type:"server_tool_use",id:w.toolCallId,name:z,input:w.input,cache_control:B}):n.push({type:"other",message:`provider executed tool call for tool ${w.toolName} is not supported`});break}let Q=(I=w.providerOptions)==null?void 0:I.anthropic,k=Q?.caller?(Q.caller.type==="code_execution_20250825"||Q.caller.type==="code_execution_20260120")&&Q.caller.toolId?{type:Q.caller.type,tool_id:Q.caller.toolId}:Q.caller.type==="direct"?{type:"direct"}:void 0:void 0;P.push({type:"tool_use",id:w.toolCallId,name:w.toolName,input:w.input,...k&&{caller:k},cache_control:B});break}case"tool-result":{let Q=r.toProviderToolName(w.toolName);if(J.has(w.toolCallId)){let k=w.output;if(k.type!=="json"&&k.type!=="error-json"){n.push({type:"other",message:`provider executed tool result output type ${k.type} for tool ${w.toolName} is not supported`});break}P.push({type:"mcp_tool_result",tool_use_id:w.toolCallId,is_error:k.type==="error-json",content:k.value,cache_control:B})}else if(Q==="code_execution"){let k=w.output;if(k.type==="error-text"||k.type==="error-json"){let z={};try{typeof k.value=="string"?z=JSON.parse(k.value):typeof k.value=="object"&&k.value!==null&&(z=k.value)}catch{}z.type==="code_execution_tool_result_error"?P.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:"code_execution_tool_result_error",error_code:(S=z.errorCode)!=null?S:"unknown"},cache_control:B}):P.push({type:"bash_code_execution_tool_result",tool_use_id:w.toolCallId,cache_control:B,content:{type:"bash_code_execution_tool_result_error",error_code:(b=z.errorCode)!=null?b:"unknown"}});break}if(k.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${k.type} for tool ${w.toolName} is not supported`});break}if(k.value==null||typeof k.value!="object"||!("type"in k.value)||typeof k.value.type!="string"){n.push({type:"other",message:`provider executed tool result output value is not a valid code execution result for tool ${w.toolName}`});break}if(k.value.type==="code_execution_result"){let z=await ue({value:k.value,schema:Vo});P.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:z.type,stdout:z.stdout,stderr:z.stderr,return_code:z.return_code,content:(O=z.content)!=null?O:[]},cache_control:B})}else if(k.value.type==="encrypted_code_execution_result"){let z=await ue({value:k.value,schema:Wo});z.type==="encrypted_code_execution_result"&&P.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:z.type,encrypted_stdout:z.encrypted_stdout,stderr:z.stderr,return_code:z.return_code,content:(N=z.content)!=null?N:[]},cache_control:B})}else{let z=await ue({value:k.value,schema:Jo});z.type==="code_execution_result"?P.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:z.type,stdout:z.stdout,stderr:z.stderr,return_code:z.return_code,content:(V=z.content)!=null?V:[]},cache_control:B}):z.type==="bash_code_execution_result"||z.type==="bash_code_execution_tool_result_error"?P.push({type:"bash_code_execution_tool_result",tool_use_id:w.toolCallId,cache_control:B,content:z}):P.push({type:"text_editor_code_execution_tool_result",tool_use_id:w.toolCallId,cache_control:B,content:z})}break}if(Q==="web_fetch"){let k=w.output;if(k.type==="error-json"){let E={};try{typeof k.value=="string"?E=JSON.parse(k.value):typeof k.value=="object"&&k.value!==null&&(E=k.value)}catch{let ne=(F=k.value)==null?void 0:F.errorCode;E={errorCode:typeof ne=="string"?ne:"unavailable"}}P.push({type:"web_fetch_tool_result",tool_use_id:w.toolCallId,content:{type:"web_fetch_tool_result_error",error_code:(D=E.errorCode)!=null?D:"unavailable"},cache_control:B});break}if(k.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${k.type} for tool ${w.toolName} is not supported`});break}let z=await ue({value:k.value,schema:Ho});P.push({type:"web_fetch_tool_result",tool_use_id:w.toolCallId,content:{type:"web_fetch_result",url:z.url,retrieved_at:z.retrievedAt,content:{type:"document",title:z.content.title,citations:z.content.citations,source:{type:z.content.source.type,media_type:z.content.source.mediaType,data:z.content.source.data}}},cache_control:B});break}if(Q==="web_search"){let k=w.output;if(k.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${k.type} for tool ${w.toolName} is not supported`});break}let z=await ue({value:k.value,schema:Lo});P.push({type:"web_search_tool_result",tool_use_id:w.toolCallId,content:z.map(E=>({url:E.url,title:E.title,page_age:E.pageAge,encrypted_content:E.encryptedContent,type:E.type})),cache_control:B});break}if(Q==="tool_search_tool_regex"||Q==="tool_search_tool_bm25"){let k=w.output;if(k.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${k.type} for tool ${w.toolName} is not supported`});break}let E=(await ue({value:k.value,schema:Go})).map(x=>({type:"tool_reference",tool_name:x.toolName}));P.push({type:"tool_search_tool_result",tool_use_id:w.toolCallId,content:{type:"tool_search_tool_search_result",tool_references:E},cache_control:B});break}n.push({type:"other",message:`provider executed tool result for tool ${w.toolName} is not supported`});break}}}}W.push({role:"assistant",content:P});break}default:{let P=A;throw new Error(`content type: ${P}`)}}}return{prompt:{system:U,messages:W},betas:f}}function Qa(t){let o=[],n;for(let a of t){let{role:r}=a;switch(r){case"system":{n?.type!=="system"&&(n={type:"system",messages:[]},o.push(n)),n.messages.push(a);break}case"assistant":{n?.type!=="assistant"&&(n={type:"assistant",messages:[]},o.push(n)),n.messages.push(a);break}case"user":{n?.type!=="user"&&(n={type:"user",messages:[]},o.push(n)),n.messages.push(a);break}case"tool":{n?.type!=="user"&&(n={type:"user",messages:[]},o.push(n)),n.messages.push(a);break}default:{let i=r;throw new Error(`Unsupported role: ${i}`)}}}return o}function Pt({finishReason:t,isJsonResponseFromTool:o}){switch(t){case"pause_turn":case"end_turn":case"stop_sequence":return"stop";case"refusal":return"content-filter";case"tool_use":return o?"stop":"tool-calls";case"max_tokens":case"model_context_window_exceeded":return"length";case"compaction":return"other";default:return"other"}}var Bo=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),Za=["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","minItems","maxItems","uniqueItems","minProperties","maxProperties","not"];function er(t){return Ko(t)}function ze(t){return typeof t=="boolean"||!ar(t)?t:Ko(t)}function Ko(t){let o={},n=t;if(t.$ref!=null)return{$ref:t.$ref};if(t.$schema!=null&&(o.$schema=t.$schema),t.$id!=null&&(o.$id=t.$id),t.title!=null&&(o.title=t.title),t.description!=null&&(o.description=t.description),t.default!==void 0&&(o.default=t.default),t.const!==void 0&&(o.const=t.const),t.enum!=null&&(o.enum=t.enum),t.type!=null&&(o.type=t.type),t.anyOf!=null?o.anyOf=t.anyOf.map(ze):t.oneOf!=null&&(o.anyOf=t.oneOf.map(ze)),t.allOf!=null&&(o.allOf=t.allOf.map(ze)),t.definitions!=null&&(o.definitions=Object.fromEntries(Object.entries(t.definitions).map(([r,i])=>[r,ze(i)]))),n.$defs!=null){let r=o;r.$defs=Object.fromEntries(Object.entries(n.$defs).map(([i,u])=>[i,ze(u)]))}(t.type==="object"||t.properties!=null)&&(t.properties!=null&&(o.properties=Object.fromEntries(Object.entries(t.properties).map(([r,i])=>[r,ze(i)]))),o.additionalProperties=!1,t.required!=null&&(o.required=t.required)),t.items!=null&&(o.items=Array.isArray(t.items)?t.items.map(ze):ze(t.items)),typeof t.format=="string"&&Bo.has(t.format)&&(o.format=t.format);let a=tr(t);return a!=null&&(o.description=o.description==null?a:`${o.description}
1
+ import{A as ue,B as vo,C as We,D as te,E as se,F as Ge,G as ce,H as ie,I as ve,J as ye,K as xe,L as de,M as xo,N as Ae,O as wo,Q as So,R as Co,S as To,X as Io,Y as ko,Z as jo,a as Ue,b as yt,c as go,d as bt,e as $e,f as Et,g as Ve,h as le,i as e,j as re,k as vt,l as _o,m as Ce,n as fo,o as _e,p as xt,q as nt,r as pe,s as Ee,t as yo,u as at,v as Je,w as wt,x as bo,y as C,z as T}from"./chunk-AAR7DBEN.js";import{a as St}from"./chunk-YDO2EDVY.js";import{S as mo,U as Nt,Y as ot,_ as ho}from"./chunk-ISUGBMXC.js";import{a as io,b as so,c as lo,g as uo,j as co,n as we,o as po,p as ft,q as Rt,v as Ne}from"./chunk-XOWWPE7X.js";import{c as jt,e as et,h as tt,k as _t,y as Ot}from"./chunk-WRA24P66.js";import{b as ta,d as oa}from"./chunk-PVAE643M.js";var Ro=ta((Fl,Oo)=>{"use strict";function na(t,o){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let n,a=0;return function(...i){clearTimeout(n);let u=Date.now(),s=u-a,g=o-s;g<=0?(a=u,t.apply(this,i)):n=setTimeout(()=>{a=Date.now(),t.apply(this,i)},g)}}Oo.exports=na});Ot();var Ao=oa(Ro(),1);Ot();Ot();var Eo=(t,o,n)=>{if(!o.has(t))throw TypeError("Cannot "+n)},ge=(t,o,n)=>(Eo(t,o,"read from private field"),n?n.call(t):o.get(t)),Re=(t,o,n)=>{if(o.has(t))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(t):o.set(t,n)},Me=(t,o,n,a)=>(Eo(t,o,"write to private field"),a?a.call(t,n):o.set(t,n),n);function ia(t,o){return o!=null?(0,Ao.default)(t,o):t}var Se,Ct,Tt,rt,it,st,Be,At,Mt,sa=class{constructor(t=[]){Re(this,Se,void 0),Re(this,Ct,"ready"),Re(this,Tt,void 0),Re(this,rt,new Set),Re(this,it,new Set),Re(this,st,new Set),this.pushMessage=o=>{Me(this,Se,ge(this,Se).concat(o)),ge(this,Be).call(this)},this.popMessage=()=>{Me(this,Se,ge(this,Se).slice(0,-1)),ge(this,Be).call(this)},this.replaceMessage=(o,n)=>{Me(this,Se,[...ge(this,Se).slice(0,o),this.snapshot(n),...ge(this,Se).slice(o+1)]),ge(this,Be).call(this)},this.snapshot=o=>structuredClone(o),this["~registerMessagesCallback"]=(o,n)=>{let a=n?ia(o,n):o;return ge(this,rt).add(a),()=>{ge(this,rt).delete(a)}},this["~registerStatusCallback"]=o=>(ge(this,it).add(o),()=>{ge(this,it).delete(o)}),this["~registerErrorCallback"]=o=>(ge(this,st).add(o),()=>{ge(this,st).delete(o)}),Re(this,Be,()=>{ge(this,rt).forEach(o=>o())}),Re(this,At,()=>{ge(this,it).forEach(o=>o())}),Re(this,Mt,()=>{ge(this,st).forEach(o=>o())}),Me(this,Se,t)}get status(){return ge(this,Ct)}set status(t){Me(this,Ct,t),ge(this,At).call(this)}get error(){return ge(this,Tt)}set error(t){Me(this,Tt,t),ge(this,Mt).call(this)}get messages(){return ge(this,Se)}set messages(t){Me(this,Se,[...t]),ge(this,Be).call(this)}};Se=new WeakMap;Ct=new WeakMap;Tt=new WeakMap;rt=new WeakMap;it=new WeakMap;st=new WeakMap;Be=new WeakMap;At=new WeakMap;Mt=new WeakMap;var Ke,No=class extends To{constructor({messages:t,...o}){let n=new sa(t);super({...o,state:n}),Re(this,Ke,void 0),this["~registerMessagesCallback"]=(a,r)=>ge(this,Ke)["~registerMessagesCallback"](a,r),this["~registerStatusCallback"]=a=>ge(this,Ke)["~registerStatusCallback"](a),this["~registerErrorCallback"]=a=>ge(this,Ke)["~registerErrorCallback"](a),Me(this,Ke,n)}};Ke=new WeakMap;function Vl({experimental_throttle:t,resume:o=!1,...n}={}){let a=et("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(a.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});let r={...n,onToolCall:h=>{var v,_;return(_=(v=a.current).onToolCall)==null?void 0:_.call(v,h)},onData:h=>{var v,_;return(_=(v=a.current).onData)==null?void 0:_.call(v,h)},onFinish:h=>{var v,_;return(_=(v=a.current).onFinish)==null?void 0:_.call(v,h)},onError:h=>{var v,_;return(_=(v=a.current).onError)==null?void 0:_.call(v,h)},sendAutomaticallyWhen:h=>{var v,_,y;return(y=(_=(v=a.current).sendAutomaticallyWhen)==null?void 0:_.call(v,h))!=null?y:!1}},i=et("chat"in n?n.chat:new No(r));("chat"in n&&n.chat!==i.current||"id"in n&&i.current.id!==n.id)&&(i.current="chat"in n?n.chat:new No(r));let s=tt(h=>i.current["~registerMessagesCallback"](h,t),[t,i.current.id]),g=_t(s,()=>i.current.messages,()=>i.current.messages),m=_t(i.current["~registerStatusCallback"],()=>i.current.status,()=>i.current.status),l=_t(i.current["~registerErrorCallback"],()=>i.current.error,()=>i.current.error),p=tt(h=>{typeof h=="function"&&(h=h(i.current.messages)),i.current.messages=h},[i]);return jt(()=>{o&&i.current.resumeStream()},[o,i]),{id:i.current.id,messages:g,setMessages:p,sendMessage:i.current.sendMessage,regenerate:i.current.regenerate,clearError:i.current.clearError,stop:i.current.stop,error:l,resumeStream:i.current.resumeStream,status:m,addToolResult:i.current.addToolOutput,addToolOutput:i.current.addToolOutput,addToolApprovalResponse:i.current.addToolApprovalResponse}}var la="3.0.74",ua=C(()=>T(e.object({type:e.literal("error"),error:e.object({type:e.string(),message:e.string()})}))),Mo=ye({errorSchema:ua,errorToMessage:t=>t.error.message}),ca=C(()=>T(e.object({type:e.literal("message"),id:e.string().nullish(),model:e.string().nullish(),content:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("text"),text:e.string(),citations:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("web_search_result_location"),cited_text:e.string(),url:e.string(),title:e.string(),encrypted_index:e.string()}),e.object({type:e.literal("page_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_page_number:e.number(),end_page_number:e.number()}),e.object({type:e.literal("char_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_char_index:e.number(),end_char_index:e.number()})])).optional()}),e.object({type:e.literal("thinking"),thinking:e.string(),signature:e.string()}),e.object({type:e.literal("redacted_thinking"),data:e.string()}),e.object({type:e.literal("compaction"),content:e.string()}),e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.unknown(),caller:e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("server_tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).nullish(),caller:e.union([e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("mcp_tool_use"),id:e.string(),name:e.string(),input:e.unknown(),server_name:e.string()}),e.object({type:e.literal("mcp_tool_result"),tool_use_id:e.string(),is_error:e.boolean(),content:e.array(e.union([e.string(),e.object({type:e.literal("text"),text:e.string()})]))}),e.object({type:e.literal("web_fetch_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("web_fetch_result"),url:e.string(),retrieved_at:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),media_type:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),media_type:e.literal("text/plain"),data:e.string()})])})}),e.object({type:e.literal("web_fetch_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("web_search_tool_result"),tool_use_id:e.string(),content:e.union([e.array(e.object({type:e.literal("web_search_result"),url:e.string(),title:e.string(),encrypted_content:e.string(),page_age:e.string().nullish()})),e.object({type:e.literal("web_search_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("code_execution_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("bash_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("text_editor_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})])}),e.object({type:e.literal("tool_search_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("tool_search_tool_search_result"),tool_references:e.array(e.object({type:e.literal("tool_reference"),tool_name:e.string()}))}),e.object({type:e.literal("tool_search_tool_result_error"),error_code:e.string()})])})])),stop_reason:e.string().nullish(),stop_sequence:e.string().nullish(),usage:e.looseObject({input_tokens:e.number(),output_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish(),iterations:e.array(e.object({type:e.union([e.literal("compaction"),e.literal("message")]),input_tokens:e.number(),output_tokens:e.number()})).nullish()}),container:e.object({expires_at:e.string(),id:e.string(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skill_id:e.string(),version:e.string()})).nullish()}).nullish(),context_management:e.object({applied_edits:e.array(e.union([e.object({type:e.literal("clear_tool_uses_20250919"),cleared_tool_uses:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("clear_thinking_20251015"),cleared_thinking_turns:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("compact_20260112")})]))}).nullish()}))),da=C(()=>T(e.discriminatedUnion("type",[e.object({type:e.literal("message_start"),message:e.object({id:e.string().nullish(),model:e.string().nullish(),role:e.string().nullish(),usage:e.looseObject({input_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish()}),content:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.unknown(),caller:e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()})])).nullish(),stop_reason:e.string().nullish(),container:e.object({expires_at:e.string(),id:e.string()}).nullish()})}),e.object({type:e.literal("content_block_start"),index:e.number(),content_block:e.discriminatedUnion("type",[e.object({type:e.literal("text"),text:e.string()}),e.object({type:e.literal("thinking"),thinking:e.string()}),e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).optional(),caller:e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("redacted_thinking"),data:e.string()}),e.object({type:e.literal("compaction"),content:e.string().nullish()}),e.object({type:e.literal("server_tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).nullish(),caller:e.union([e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]).optional()}),e.object({type:e.literal("mcp_tool_use"),id:e.string(),name:e.string(),input:e.unknown(),server_name:e.string()}),e.object({type:e.literal("mcp_tool_result"),tool_use_id:e.string(),is_error:e.boolean(),content:e.array(e.union([e.string(),e.object({type:e.literal("text"),text:e.string()})]))}),e.object({type:e.literal("web_fetch_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("web_fetch_result"),url:e.string(),retrieved_at:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),media_type:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),media_type:e.literal("text/plain"),data:e.string()})])})}),e.object({type:e.literal("web_fetch_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("web_search_tool_result"),tool_use_id:e.string(),content:e.union([e.array(e.object({type:e.literal("web_search_result"),url:e.string(),title:e.string(),encrypted_content:e.string(),page_age:e.string().nullish()})),e.object({type:e.literal("web_search_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("code_execution_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("bash_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("text_editor_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})])}),e.object({type:e.literal("tool_search_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("tool_search_tool_search_result"),tool_references:e.array(e.object({type:e.literal("tool_reference"),tool_name:e.string()}))}),e.object({type:e.literal("tool_search_tool_result_error"),error_code:e.string()})])})])}),e.object({type:e.literal("content_block_delta"),index:e.number(),delta:e.discriminatedUnion("type",[e.object({type:e.literal("input_json_delta"),partial_json:e.string()}),e.object({type:e.literal("text_delta"),text:e.string()}),e.object({type:e.literal("thinking_delta"),thinking:e.string()}),e.object({type:e.literal("signature_delta"),signature:e.string()}),e.object({type:e.literal("compaction_delta"),content:e.string().nullish()}),e.object({type:e.literal("citations_delta"),citation:e.discriminatedUnion("type",[e.object({type:e.literal("web_search_result_location"),cited_text:e.string(),url:e.string(),title:e.string(),encrypted_index:e.string()}),e.object({type:e.literal("page_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_page_number:e.number(),end_page_number:e.number()}),e.object({type:e.literal("char_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_char_index:e.number(),end_char_index:e.number()})])})])}),e.object({type:e.literal("content_block_stop"),index:e.number()}),e.object({type:e.literal("error"),error:e.object({type:e.string(),message:e.string()})}),e.object({type:e.literal("message_delta"),delta:e.object({stop_reason:e.string().nullish(),stop_sequence:e.string().nullish(),container:e.object({expires_at:e.string(),id:e.string(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skill_id:e.string(),version:e.string()})).nullish()}).nullish()}),usage:e.looseObject({input_tokens:e.number().nullish(),output_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish(),iterations:e.array(e.object({type:e.union([e.literal("compaction"),e.literal("message")]),input_tokens:e.number(),output_tokens:e.number()})).nullish()}),context_management:e.object({applied_edits:e.array(e.union([e.object({type:e.literal("clear_tool_uses_20250919"),cleared_tool_uses:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("clear_thinking_20251015"),cleared_thinking_turns:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("compact_20260112")})]))}).nullish()}),e.object({type:e.literal("message_stop")}),e.object({type:e.literal("ping")})]))),pa=C(()=>T(e.object({signature:e.string().optional(),redactedData:e.string().optional()}))),zo=e.object({citations:e.object({enabled:e.boolean()}).optional(),title:e.string().optional(),context:e.string().optional()}),Do=e.object({sendReasoning:e.boolean().optional(),structuredOutputMode:e.enum(["outputFormat","jsonTool","auto"]).optional(),thinking:e.discriminatedUnion("type",[e.object({type:e.literal("adaptive"),display:e.enum(["omitted","summarized"]).optional()}),e.object({type:e.literal("enabled"),budgetTokens:e.number().optional()}),e.object({type:e.literal("disabled")})]).optional(),disableParallelToolUse:e.boolean().optional(),cacheControl:e.object({type:e.literal("ephemeral"),ttl:e.union([e.literal("5m"),e.literal("1h")]).optional()}).optional(),metadata:e.object({userId:e.string().optional()}).optional(),mcpServers:e.array(e.object({type:e.literal("url"),name:e.string(),url:e.string(),authorizationToken:e.string().nullish(),toolConfiguration:e.object({enabled:e.boolean().nullish(),allowedTools:e.array(e.string()).nullish()}).nullish()})).optional(),container:e.object({id:e.string().optional(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skillId:e.string(),version:e.string().optional()})).optional()}).optional(),toolStreaming:e.boolean().optional(),effort:e.enum(["low","medium","high","xhigh","max"]).optional(),taskBudget:e.object({type:e.literal("tokens"),total:e.number().int().min(2e4),remaining:e.number().int().min(0).optional()}).optional(),speed:e.enum(["fast","standard"]).optional(),inferenceGeo:e.enum(["us","global"]).optional(),anthropicBeta:e.array(e.string()).optional(),contextManagement:e.object({edits:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("clear_tool_uses_20250919"),trigger:e.discriminatedUnion("type",[e.object({type:e.literal("input_tokens"),value:e.number()}),e.object({type:e.literal("tool_uses"),value:e.number()})]).optional(),keep:e.object({type:e.literal("tool_uses"),value:e.number()}).optional(),clearAtLeast:e.object({type:e.literal("input_tokens"),value:e.number()}).optional(),clearToolInputs:e.boolean().optional(),excludeTools:e.array(e.string()).optional()}),e.object({type:e.literal("clear_thinking_20251015"),keep:e.union([e.literal("all"),e.object({type:e.literal("thinking_turns"),value:e.number()})]).optional()}),e.object({type:e.literal("compact_20260112"),trigger:e.object({type:e.literal("input_tokens"),value:e.number()}).optional(),pauseAfterCompaction:e.boolean().optional(),instructions:e.string().optional()})]))}).optional()}),Po=4;function ma(t){var o;let n=t?.anthropic;return(o=n?.cacheControl)!=null?o:n?.cache_control}var qt=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(t,o){let n=ma(t);if(n){if(!o.canCache){this.warnings.push({type:"unsupported",feature:"cache_control on non-cacheable context",details:`cache_control cannot be set on ${o.type}. It will be ignored.`});return}if(this.breakpointCount++,this.breakpointCount>Po){this.warnings.push({type:"unsupported",feature:"cacheControl breakpoint limit",details:`Maximum ${Po} cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`});return}return n}}getWarnings(){return this.warnings}},ha=C(()=>T(e.object({maxCharacters:e.number().optional()}))),ga=C(()=>T(e.object({command:e.enum(["view","create","str_replace","insert"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),_a=ce({id:"anthropic.text_editor_20250728",inputSchema:ga}),fa=(t={})=>_a(t),ya=C(()=>T(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),userLocation:e.object({type:e.literal("approximate"),city:e.string().optional(),region:e.string().optional(),country:e.string().optional(),timezone:e.string().optional()}).optional()}))),ba=C(()=>T(e.array(e.object({url:e.string(),title:e.string().nullable(),pageAge:e.string().nullable(),encryptedContent:e.string(),type:e.literal("web_search_result")})))),va=C(()=>T(e.object({query:e.string()}))),xa=ie({id:"anthropic.web_search_20260209",inputSchema:va,outputSchema:ba,supportsDeferredResults:!0}),wa=(t={})=>xa(t),Sa=C(()=>T(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),userLocation:e.object({type:e.literal("approximate"),city:e.string().optional(),region:e.string().optional(),country:e.string().optional(),timezone:e.string().optional()}).optional()}))),Lo=C(()=>T(e.array(e.object({url:e.string(),title:e.string().nullable(),pageAge:e.string().nullable(),encryptedContent:e.string(),type:e.literal("web_search_result")})))),Ca=C(()=>T(e.object({query:e.string()}))),Ta=ie({id:"anthropic.web_search_20250305",inputSchema:Ca,outputSchema:Lo,supportsDeferredResults:!0}),Ia=(t={})=>Ta(t),ka=C(()=>T(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),citations:e.object({enabled:e.boolean()}).optional(),maxContentTokens:e.number().optional()}))),ja=C(()=>T(e.object({type:e.literal("web_fetch_result"),url:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),mediaType:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),mediaType:e.literal("text/plain"),data:e.string()})])}),retrievedAt:e.string().nullable()}))),Oa=C(()=>T(e.object({url:e.string()}))),Ra=ie({id:"anthropic.web_fetch_20260209",inputSchema:Oa,outputSchema:ja,supportsDeferredResults:!0}),Na=(t={})=>Ra(t),Ea=C(()=>T(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),citations:e.object({enabled:e.boolean()}).optional(),maxContentTokens:e.number().optional()}))),Ho=C(()=>T(e.object({type:e.literal("web_fetch_result"),url:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),mediaType:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),mediaType:e.literal("text/plain"),data:e.string()})])}),retrievedAt:e.string().nullable()}))),Aa=C(()=>T(e.object({url:e.string()}))),Ma=ie({id:"anthropic.web_fetch_20250910",inputSchema:Aa,outputSchema:Ho,supportsDeferredResults:!0}),za=(t={})=>Ma(t);async function Da({tools:t,toolChoice:o,disableParallelToolUse:n,cacheControlValidator:a,supportsStructuredOutput:r,supportsStrictTools:i,defaultEagerInputStreaming:u=!1}){var s,g;t=t?.length?t:void 0;let m=[],l=new Set,p=a||new qt;if(t==null)return{tools:void 0,toolChoice:void 0,toolWarnings:m,betas:l};let h=[];for(let _ of t)switch(_.type){case"function":{let y=p.getCacheControl(_.providerOptions,{type:"tool definition",canCache:!0}),I=(s=_.providerOptions)==null?void 0:s.anthropic,S=(g=I?.eagerInputStreaming)!=null?g:u,b=I?.deferLoading,O=I?.allowedCallers;!i&&_.strict!=null&&m.push({type:"unsupported",feature:"strict",details:`Tool '${_.name}' has strict: ${_.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`}),h.push({name:_.name,description:_.description,input_schema:_.inputSchema,cache_control:y,...S?{eager_input_streaming:!0}:{},...i===!0&&_.strict!=null?{strict:_.strict}:{},...b!=null?{defer_loading:b}:{},...O!=null?{allowed_callers:O}:{},..._.inputExamples!=null?{input_examples:_.inputExamples.map(N=>N.input)}:{}}),r===!0&&l.add("structured-outputs-2025-11-13"),(_.inputExamples!=null||O!=null)&&l.add("advanced-tool-use-2025-11-20");break}case"provider":{switch(_.id){case"anthropic.code_execution_20250522":{l.add("code-execution-2025-05-22"),h.push({type:"code_execution_20250522",name:"code_execution",cache_control:void 0});break}case"anthropic.code_execution_20250825":{l.add("code-execution-2025-08-25"),h.push({type:"code_execution_20250825",name:"code_execution"});break}case"anthropic.code_execution_20260120":{h.push({type:"code_execution_20260120",name:"code_execution"});break}case"anthropic.computer_20250124":{l.add("computer-use-2025-01-24"),h.push({name:"computer",type:"computer_20250124",display_width_px:_.args.displayWidthPx,display_height_px:_.args.displayHeightPx,display_number:_.args.displayNumber,cache_control:void 0});break}case"anthropic.computer_20251124":{l.add("computer-use-2025-11-24"),h.push({name:"computer",type:"computer_20251124",display_width_px:_.args.displayWidthPx,display_height_px:_.args.displayHeightPx,display_number:_.args.displayNumber,enable_zoom:_.args.enableZoom,cache_control:void 0});break}case"anthropic.computer_20241022":{l.add("computer-use-2024-10-22"),h.push({name:"computer",type:"computer_20241022",display_width_px:_.args.displayWidthPx,display_height_px:_.args.displayHeightPx,display_number:_.args.displayNumber,cache_control:void 0});break}case"anthropic.text_editor_20250124":{l.add("computer-use-2025-01-24"),h.push({name:"str_replace_editor",type:"text_editor_20250124",cache_control:void 0});break}case"anthropic.text_editor_20241022":{l.add("computer-use-2024-10-22"),h.push({name:"str_replace_editor",type:"text_editor_20241022",cache_control:void 0});break}case"anthropic.text_editor_20250429":{l.add("computer-use-2025-01-24"),h.push({name:"str_replace_based_edit_tool",type:"text_editor_20250429",cache_control:void 0});break}case"anthropic.text_editor_20250728":{let y=await ue({value:_.args,schema:ha});h.push({name:"str_replace_based_edit_tool",type:"text_editor_20250728",max_characters:y.maxCharacters,cache_control:void 0});break}case"anthropic.bash_20250124":{l.add("computer-use-2025-01-24"),h.push({name:"bash",type:"bash_20250124",cache_control:void 0});break}case"anthropic.bash_20241022":{l.add("computer-use-2024-10-22"),h.push({name:"bash",type:"bash_20241022",cache_control:void 0});break}case"anthropic.memory_20250818":{l.add("context-management-2025-06-27"),h.push({name:"memory",type:"memory_20250818"});break}case"anthropic.web_fetch_20250910":{l.add("web-fetch-2025-09-10");let y=await ue({value:_.args,schema:Ea});h.push({type:"web_fetch_20250910",name:"web_fetch",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,citations:y.citations,max_content_tokens:y.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260209":{l.add("code-execution-web-tools-2026-02-09");let y=await ue({value:_.args,schema:ka});h.push({type:"web_fetch_20260209",name:"web_fetch",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,citations:y.citations,max_content_tokens:y.maxContentTokens,cache_control:void 0});break}case"anthropic.web_search_20250305":{let y=await ue({value:_.args,schema:Sa});h.push({type:"web_search_20250305",name:"web_search",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,user_location:y.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260209":{l.add("code-execution-web-tools-2026-02-09");let y=await ue({value:_.args,schema:ya});h.push({type:"web_search_20260209",name:"web_search",max_uses:y.maxUses,allowed_domains:y.allowedDomains,blocked_domains:y.blockedDomains,user_location:y.userLocation,cache_control:void 0});break}case"anthropic.tool_search_regex_20251119":{h.push({type:"tool_search_tool_regex_20251119",name:"tool_search_tool_regex"});break}case"anthropic.tool_search_bm25_20251119":{h.push({type:"tool_search_tool_bm25_20251119",name:"tool_search_tool_bm25"});break}default:{m.push({type:"unsupported",feature:`provider-defined tool ${_.id}`});break}}break}default:{m.push({type:"unsupported",feature:`tool ${_}`});break}}if(o==null)return{tools:h,toolChoice:n?{type:"auto",disable_parallel_tool_use:n}:void 0,toolWarnings:m,betas:l};let v=o.type;switch(v){case"auto":return{tools:h,toolChoice:{type:"auto",disable_parallel_tool_use:n},toolWarnings:m,betas:l};case"required":return{tools:h,toolChoice:{type:"any",disable_parallel_tool_use:n},toolWarnings:m,betas:l};case"none":return{tools:void 0,toolChoice:void 0,toolWarnings:m,betas:l};case"tool":return{tools:h,toolChoice:{type:"tool",name:o.toolName,disable_parallel_tool_use:n},toolWarnings:m,betas:l};default:{let _=v;throw new le({functionality:`tool choice type: ${_}`})}}}function qo({usage:t,rawUsage:o}){var n,a;let r=(n=t.cache_creation_input_tokens)!=null?n:0,i=(a=t.cache_read_input_tokens)!=null?a:0,u,s;if(t.iterations&&t.iterations.length>0){let g=t.iterations.reduce((m,l)=>({input:m.input+l.input_tokens,output:m.output+l.output_tokens}),{input:0,output:0});u=g.input,s=g.output}else u=t.input_tokens,s=t.output_tokens;return{inputTokens:{total:u+r+i,noCache:u,cacheRead:i,cacheWrite:r},outputTokens:{total:s,text:void 0,reasoning:void 0},raw:o??t}}var Vo=C(()=>T(e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}))),Pa=C(()=>T(e.object({code:e.string()}))),qa=ie({id:"anthropic.code_execution_20250522",inputSchema:Pa,outputSchema:Vo}),Ua=(t={})=>qa(t),Jo=C(()=>T(e.discriminatedUnion("type",[e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})]))),$a=C(()=>T(e.discriminatedUnion("type",[e.object({type:e.literal("programmatic-tool-call"),code:e.string()}),e.object({type:e.literal("bash_code_execution"),command:e.string()}),e.discriminatedUnion("command",[e.object({type:e.literal("text_editor_code_execution"),command:e.literal("view"),path:e.string()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("create"),path:e.string(),file_text:e.string().nullish()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()})])]))),Fa=ie({id:"anthropic.code_execution_20250825",inputSchema:$a,outputSchema:Jo,supportsDeferredResults:!0}),La=(t={})=>Fa(t),Wo=C(()=>T(e.discriminatedUnion("type",[e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})]))),Ha=C(()=>T(e.discriminatedUnion("type",[e.object({type:e.literal("programmatic-tool-call"),code:e.string()}),e.object({type:e.literal("bash_code_execution"),command:e.string()}),e.discriminatedUnion("command",[e.object({type:e.literal("text_editor_code_execution"),command:e.literal("view"),path:e.string()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("create"),path:e.string(),file_text:e.string().nullish()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()})])]))),Va=ie({id:"anthropic.code_execution_20260120",inputSchema:Ha,outputSchema:Wo,supportsDeferredResults:!0}),Ja=(t={})=>Va(t),Go=C(()=>T(e.array(e.object({type:e.literal("tool_reference"),toolName:e.string()})))),Wa=C(()=>T(e.object({pattern:e.string(),limit:e.number().optional()}))),Ga=ie({id:"anthropic.tool_search_regex_20251119",inputSchema:Wa,outputSchema:Go,supportsDeferredResults:!0}),Ba=(t={})=>Ga(t);function Ka(t){if(typeof t=="string")return new TextDecoder().decode(Ce(t));if(t instanceof Uint8Array)return new TextDecoder().decode(t);throw t instanceof URL?new le({functionality:"URL-based text documents are not supported for citations"}):new le({functionality:`unsupported data type for text documents: ${typeof t}`})}function zt(t){return t instanceof URL||Ya(t)}function Ya(t){return typeof t=="string"&&/^https?:\/\//i.test(t)}function Dt(t){return t instanceof URL?t.toString():t}async function Xa({prompt:t,sendReasoning:o,warnings:n,cacheControlValidator:a,toolNameMapping:r}){var i,u,s,g,m,l,p,h,v,_,y,I,S,b,O,N,V,F,D;let f=new Set,c=Qa(t),H=a||new qt,U,W=[];async function Z(R){var $,j;let A=await te({provider:"anthropic",providerOptions:R,schema:zo});return(j=($=A?.citations)==null?void 0:$.enabled)!=null?j:!1}async function q(R){let $=await te({provider:"anthropic",providerOptions:R,schema:zo});return{title:$?.title,context:$?.context}}for(let R=0;R<c.length;R++){let $=c[R],j=R===c.length-1,A=$.type;switch(A){case"system":{if(U!=null)throw new le({functionality:"Multiple system messages that are separated by user/assistant messages"});U=$.messages.map(({content:P,providerOptions:J})=>({type:"text",text:P,cache_control:H.getCacheControl(J,{type:"system message",canCache:!0})}));break}case"user":{let P=[];for(let J of $.messages){let{role:M,content:G}=J;switch(M){case"user":{for(let ae=0;ae<G.length;ae++){let K=G[ae],ee=ae===G.length-1,w=(i=H.getCacheControl(K.providerOptions,{type:"user message part",canCache:!0}))!=null?i:ee?H.getCacheControl(J.providerOptions,{type:"user message",canCache:!0}):void 0;switch(K.type){case"text":{P.push({type:"text",text:K.text,cache_control:w});break}case"file":{if(K.mediaType.startsWith("image/"))P.push({type:"image",source:zt(K.data)?{type:"url",url:Dt(K.data)}:{type:"base64",media_type:K.mediaType==="image/*"?"image/jpeg":K.mediaType,data:_e(K.data)},cache_control:w});else if(K.mediaType==="application/pdf"){f.add("pdfs-2024-09-25");let Y=await Z(K.providerOptions),B=await q(K.providerOptions);P.push({type:"document",source:zt(K.data)?{type:"url",url:Dt(K.data)}:{type:"base64",media_type:"application/pdf",data:_e(K.data)},title:(u=B.title)!=null?u:K.filename,...B.context&&{context:B.context},...Y&&{citations:{enabled:!0}},cache_control:w})}else if(K.mediaType==="text/plain"){let Y=await Z(K.providerOptions),B=await q(K.providerOptions);P.push({type:"document",source:zt(K.data)?{type:"url",url:Dt(K.data)}:{type:"text",media_type:"text/plain",data:Ka(K.data)},title:(s=B.title)!=null?s:K.filename,...B.context&&{context:B.context},...Y&&{citations:{enabled:!0}},cache_control:w})}else throw new le({functionality:`media type: ${K.mediaType}`});break}}}break}case"tool":{for(let ae=0;ae<G.length;ae++){let K=G[ae];if(K.type==="tool-approval-response")continue;let ee=ae===G.length-1,w=(g=H.getCacheControl(K.providerOptions,{type:"tool result part",canCache:!0}))!=null?g:ee?H.getCacheControl(J.providerOptions,{type:"tool result message",canCache:!0}):void 0,Y=K.output,B;switch(Y.type){case"content":B=Y.value.map(Q=>{var k;switch(Q.type){case"text":return{type:"text",text:Q.text};case"image-data":return{type:"image",source:{type:"base64",media_type:Q.mediaType,data:Q.data}};case"image-url":return{type:"image",source:{type:"url",url:Q.url}};case"file-url":return{type:"document",source:{type:"url",url:Q.url}};case"file-data":{if(Q.mediaType==="application/pdf")return f.add("pdfs-2024-09-25"),{type:"document",source:{type:"base64",media_type:Q.mediaType,data:Q.data}};n.push({type:"other",message:`unsupported tool content part type: ${Q.type} with media type: ${Q.mediaType}`});return}case"custom":{let z=(k=Q.providerOptions)==null?void 0:k.anthropic;if(z?.type==="tool-reference")return{type:"tool_reference",tool_name:z.toolName};n.push({type:"other",message:"unsupported custom tool content part"});return}default:{n.push({type:"other",message:`unsupported tool content part type: ${Q.type}`});return}}}).filter(at);break;case"text":case"error-text":B=Y.value;break;case"execution-denied":B=(m=Y.reason)!=null?m:"Tool execution denied.";break;default:B=JSON.stringify(Y.value);break}P.push({type:"tool_result",tool_use_id:K.toolCallId,content:B,is_error:Y.type==="error-text"||Y.type==="error-json"?!0:void 0,cache_control:w})}break}default:{let ae=M;throw new Error(`Unsupported role: ${ae}`)}}}W.push({role:"user",content:P});break}case"assistant":{let P=[],J=new Set;for(let M=0;M<$.messages.length;M++){let G=$.messages[M],ae=M===$.messages.length-1,{content:K}=G;for(let ee=0;ee<K.length;ee++){let w=K[ee],Y=ee===K.length-1,B=(l=H.getCacheControl(w.providerOptions,{type:"assistant message part",canCache:!0}))!=null?l:Y?H.getCacheControl(G.providerOptions,{type:"assistant message",canCache:!0}):void 0;switch(w.type){case"text":{let Q=(p=w.providerOptions)==null?void 0:p.anthropic;Q?.type==="compaction"?P.push({type:"compaction",content:w.text,cache_control:B}):P.push({type:"text",text:j&&ae&&Y?w.text.trim():w.text,cache_control:B});break}case"reasoning":{if(o){let Q=await te({provider:"anthropic",providerOptions:w.providerOptions,schema:pa});Q!=null?Q.signature!=null?(H.getCacheControl(w.providerOptions,{type:"thinking block",canCache:!1}),P.push({type:"thinking",thinking:w.text,signature:Q.signature})):Q.redactedData!=null?(H.getCacheControl(w.providerOptions,{type:"redacted thinking block",canCache:!1}),P.push({type:"redacted_thinking",data:Q.redactedData})):n.push({type:"other",message:"unsupported reasoning metadata"}):n.push({type:"other",message:"unsupported reasoning metadata"})}else n.push({type:"other",message:"sending reasoning content is disabled for this model"});break}case"tool-call":{if(w.providerExecuted){let z=r.toProviderToolName(w.toolName);if(((v=(h=w.providerOptions)==null?void 0:h.anthropic)==null?void 0:v.type)==="mcp-tool-use"){J.add(w.toolCallId);let x=(y=(_=w.providerOptions)==null?void 0:_.anthropic)==null?void 0:y.serverName;if(x==null||typeof x!="string"){n.push({type:"other",message:"mcp tool use server name is required and must be a string"});break}P.push({type:"mcp_tool_use",id:w.toolCallId,name:w.toolName,input:w.input,server_name:x,cache_control:B})}else if(z==="code_execution"&&w.input!=null&&typeof w.input=="object"&&"type"in w.input&&typeof w.input.type=="string"&&(w.input.type==="bash_code_execution"||w.input.type==="text_editor_code_execution"))P.push({type:"server_tool_use",id:w.toolCallId,name:w.input.type,input:w.input,cache_control:B});else if(z==="code_execution"&&w.input!=null&&typeof w.input=="object"&&"type"in w.input&&w.input.type==="programmatic-tool-call"){let{type:x,...ne}=w.input;P.push({type:"server_tool_use",id:w.toolCallId,name:"code_execution",input:ne,cache_control:B})}else z==="code_execution"||z==="web_fetch"||z==="web_search"?P.push({type:"server_tool_use",id:w.toolCallId,name:z,input:w.input,cache_control:B}):z==="tool_search_tool_regex"||z==="tool_search_tool_bm25"?P.push({type:"server_tool_use",id:w.toolCallId,name:z,input:w.input,cache_control:B}):n.push({type:"other",message:`provider executed tool call for tool ${w.toolName} is not supported`});break}let Q=(I=w.providerOptions)==null?void 0:I.anthropic,k=Q?.caller?(Q.caller.type==="code_execution_20250825"||Q.caller.type==="code_execution_20260120")&&Q.caller.toolId?{type:Q.caller.type,tool_id:Q.caller.toolId}:Q.caller.type==="direct"?{type:"direct"}:void 0:void 0;P.push({type:"tool_use",id:w.toolCallId,name:w.toolName,input:w.input,...k&&{caller:k},cache_control:B});break}case"tool-result":{let Q=r.toProviderToolName(w.toolName);if(J.has(w.toolCallId)){let k=w.output;if(k.type!=="json"&&k.type!=="error-json"){n.push({type:"other",message:`provider executed tool result output type ${k.type} for tool ${w.toolName} is not supported`});break}P.push({type:"mcp_tool_result",tool_use_id:w.toolCallId,is_error:k.type==="error-json",content:k.value,cache_control:B})}else if(Q==="code_execution"){let k=w.output;if(k.type==="error-text"||k.type==="error-json"){let z={};try{typeof k.value=="string"?z=JSON.parse(k.value):typeof k.value=="object"&&k.value!==null&&(z=k.value)}catch{}z.type==="code_execution_tool_result_error"?P.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:"code_execution_tool_result_error",error_code:(S=z.errorCode)!=null?S:"unknown"},cache_control:B}):P.push({type:"bash_code_execution_tool_result",tool_use_id:w.toolCallId,cache_control:B,content:{type:"bash_code_execution_tool_result_error",error_code:(b=z.errorCode)!=null?b:"unknown"}});break}if(k.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${k.type} for tool ${w.toolName} is not supported`});break}if(k.value==null||typeof k.value!="object"||!("type"in k.value)||typeof k.value.type!="string"){n.push({type:"other",message:`provider executed tool result output value is not a valid code execution result for tool ${w.toolName}`});break}if(k.value.type==="code_execution_result"){let z=await ue({value:k.value,schema:Vo});P.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:z.type,stdout:z.stdout,stderr:z.stderr,return_code:z.return_code,content:(O=z.content)!=null?O:[]},cache_control:B})}else if(k.value.type==="encrypted_code_execution_result"){let z=await ue({value:k.value,schema:Wo});z.type==="encrypted_code_execution_result"&&P.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:z.type,encrypted_stdout:z.encrypted_stdout,stderr:z.stderr,return_code:z.return_code,content:(N=z.content)!=null?N:[]},cache_control:B})}else{let z=await ue({value:k.value,schema:Jo});z.type==="code_execution_result"?P.push({type:"code_execution_tool_result",tool_use_id:w.toolCallId,content:{type:z.type,stdout:z.stdout,stderr:z.stderr,return_code:z.return_code,content:(V=z.content)!=null?V:[]},cache_control:B}):z.type==="bash_code_execution_result"||z.type==="bash_code_execution_tool_result_error"?P.push({type:"bash_code_execution_tool_result",tool_use_id:w.toolCallId,cache_control:B,content:z}):P.push({type:"text_editor_code_execution_tool_result",tool_use_id:w.toolCallId,cache_control:B,content:z})}break}if(Q==="web_fetch"){let k=w.output;if(k.type==="error-json"){let E={};try{typeof k.value=="string"?E=JSON.parse(k.value):typeof k.value=="object"&&k.value!==null&&(E=k.value)}catch{let ne=(F=k.value)==null?void 0:F.errorCode;E={errorCode:typeof ne=="string"?ne:"unavailable"}}P.push({type:"web_fetch_tool_result",tool_use_id:w.toolCallId,content:{type:"web_fetch_tool_result_error",error_code:(D=E.errorCode)!=null?D:"unavailable"},cache_control:B});break}if(k.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${k.type} for tool ${w.toolName} is not supported`});break}let z=await ue({value:k.value,schema:Ho});P.push({type:"web_fetch_tool_result",tool_use_id:w.toolCallId,content:{type:"web_fetch_result",url:z.url,retrieved_at:z.retrievedAt,content:{type:"document",title:z.content.title,citations:z.content.citations,source:{type:z.content.source.type,media_type:z.content.source.mediaType,data:z.content.source.data}}},cache_control:B});break}if(Q==="web_search"){let k=w.output;if(k.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${k.type} for tool ${w.toolName} is not supported`});break}let z=await ue({value:k.value,schema:Lo});P.push({type:"web_search_tool_result",tool_use_id:w.toolCallId,content:z.map(E=>({url:E.url,title:E.title,page_age:E.pageAge,encrypted_content:E.encryptedContent,type:E.type})),cache_control:B});break}if(Q==="tool_search_tool_regex"||Q==="tool_search_tool_bm25"){let k=w.output;if(k.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${k.type} for tool ${w.toolName} is not supported`});break}let E=(await ue({value:k.value,schema:Go})).map(x=>({type:"tool_reference",tool_name:x.toolName}));P.push({type:"tool_search_tool_result",tool_use_id:w.toolCallId,content:{type:"tool_search_tool_search_result",tool_references:E},cache_control:B});break}n.push({type:"other",message:`provider executed tool result for tool ${w.toolName} is not supported`});break}}}}W.push({role:"assistant",content:P});break}default:{let P=A;throw new Error(`content type: ${P}`)}}}return{prompt:{system:U,messages:W},betas:f}}function Qa(t){let o=[],n;for(let a of t){let{role:r}=a;switch(r){case"system":{n?.type!=="system"&&(n={type:"system",messages:[]},o.push(n)),n.messages.push(a);break}case"assistant":{n?.type!=="assistant"&&(n={type:"assistant",messages:[]},o.push(n)),n.messages.push(a);break}case"user":{n?.type!=="user"&&(n={type:"user",messages:[]},o.push(n)),n.messages.push(a);break}case"tool":{n?.type!=="user"&&(n={type:"user",messages:[]},o.push(n)),n.messages.push(a);break}default:{let i=r;throw new Error(`Unsupported role: ${i}`)}}}return o}function Pt({finishReason:t,isJsonResponseFromTool:o}){switch(t){case"pause_turn":case"end_turn":case"stop_sequence":return"stop";case"refusal":return"content-filter";case"tool_use":return o?"stop":"tool-calls";case"max_tokens":case"model_context_window_exceeded":return"length";case"compaction":return"other";default:return"other"}}var Bo=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),Za=["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","minItems","maxItems","uniqueItems","minProperties","maxProperties","not"];function er(t){return Ko(t)}function ze(t){return typeof t=="boolean"||!ar(t)?t:Ko(t)}function Ko(t){let o={},n=t;if(t.$ref!=null)return{$ref:t.$ref};if(t.$schema!=null&&(o.$schema=t.$schema),t.$id!=null&&(o.$id=t.$id),t.title!=null&&(o.title=t.title),t.description!=null&&(o.description=t.description),t.default!==void 0&&(o.default=t.default),t.const!==void 0&&(o.const=t.const),t.enum!=null&&(o.enum=t.enum),t.type!=null&&(o.type=t.type),t.anyOf!=null?o.anyOf=t.anyOf.map(ze):t.oneOf!=null&&(o.anyOf=t.oneOf.map(ze)),t.allOf!=null&&(o.allOf=t.allOf.map(ze)),t.definitions!=null&&(o.definitions=Object.fromEntries(Object.entries(t.definitions).map(([r,i])=>[r,ze(i)]))),n.$defs!=null){let r=o;r.$defs=Object.fromEntries(Object.entries(n.$defs).map(([i,u])=>[i,ze(u)]))}(t.type==="object"||t.properties!=null)&&(t.properties!=null&&(o.properties=Object.fromEntries(Object.entries(t.properties).map(([r,i])=>[r,ze(i)]))),o.additionalProperties=!1,t.required!=null&&(o.required=t.required)),t.items!=null&&(o.items=Array.isArray(t.items)?t.items.map(ze):ze(t.items)),typeof t.format=="string"&&Bo.has(t.format)&&(o.format=t.format);let a=tr(t);return a!=null&&(o.description=o.description==null?a:`${o.description}
2
2
  ${a}`),o}function tr(t){let o=Za.flatMap(n=>{let a=t[n];return a==null||a===!1?[]:`${or(n)}: ${nr(a)}`});return typeof t.format=="string"&&!Bo.has(t.format)&&o.push(`format: ${t.format}`),o.length===0?void 0:`${o.join("; ")}.`}function or(t){return t.replace(/[A-Z]/g,o=>` ${o.toLowerCase()}`)}function nr(t){return typeof t=="string"?t:JSON.stringify(t)}function ar(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Uo(t,o,n){var a;if(t.type==="web_search_result_location")return{type:"source",sourceType:"url",id:n(),url:t.url,title:t.title,providerMetadata:{anthropic:{citedText:t.cited_text,encryptedIndex:t.encrypted_index}}};if(t.type!=="page_location"&&t.type!=="char_location")return;let r=o[t.document_index];if(r)return{type:"source",sourceType:"document",id:n(),mediaType:r.mediaType,title:(a=t.document_title)!=null?a:r.title,filename:r.filename,providerMetadata:{anthropic:t.type==="page_location"?{citedText:t.cited_text,startPageNumber:t.start_page_number,endPageNumber:t.end_page_number}:{citedText:t.cited_text,startCharIndex:t.start_char_index,endCharIndex:t.end_char_index}}}}var rr=class{constructor(t,o){this.specificationVersion="v3";var n;this.modelId=t,this.config=o,this.generateId=(n=o.generateId)!=null?n:pe}supportsUrl(t){return t.protocol==="https:"}get provider(){return this.config.provider}get providerOptionsName(){let t=this.config.provider,o=t.indexOf(".");return o===-1?t:t.substring(0,o)}get supportedUrls(){var t,o,n;return(n=(o=(t=this.config).supportedUrls)==null?void 0:o.call(t))!=null?n:{}}async getArgs({userSuppliedBetas:t,prompt:o,maxOutputTokens:n,temperature:a,topP:r,topK:i,frequencyPenalty:u,presencePenalty:s,stopSequences:g,responseFormat:m,seed:l,tools:p,toolChoice:h,providerOptions:v,stream:_}){var y,I,S,b,O,N,V,F,D,f;let c=[];u!=null&&c.push({type:"unsupported",feature:"frequencyPenalty"}),s!=null&&c.push({type:"unsupported",feature:"presencePenalty"}),l!=null&&c.push({type:"unsupported",feature:"seed"}),a!=null&&a>1?(c.push({type:"unsupported",feature:"temperature",details:`${a} exceeds anthropic maximum of 1.0. clamped to 1.0`}),a=1):a!=null&&a<0&&(c.push({type:"unsupported",feature:"temperature",details:`${a} is below anthropic minimum of 0. clamped to 0`}),a=0),m?.type==="json"&&m.schema==null&&c.push({type:"unsupported",feature:"responseFormat",details:"JSON response format requires a schema. The response format is ignored."});let H=this.providerOptionsName,U=await te({provider:"anthropic",providerOptions:v,schema:Do}),W=H!=="anthropic"?await te({provider:H,providerOptions:v,schema:Do}):null,Z=W!=null,q=Object.assign({},U??{},W??{}),{maxOutputTokens:R,supportsStructuredOutput:$,rejectsSamplingParameters:j,isKnownModel:A}=ir(this.modelId);j&&(a!=null&&(c.push({type:"unsupported",feature:"temperature",details:`temperature is not supported by ${this.modelId} and will be ignored`}),a=void 0),i!=null&&(c.push({type:"unsupported",feature:"topK",details:`topK is not supported by ${this.modelId} and will be ignored`}),i=void 0),r!=null&&(c.push({type:"unsupported",feature:"topP",details:`topP is not supported by ${this.modelId} and will be ignored`}),r=void 0));let P=A||this.modelId.startsWith("claude-"),J=((y=this.config.supportsNativeStructuredOutput)!=null?y:!0)&&$,M=((I=this.config.supportsStrictTools)!=null?I:!0)&&$,G=(S=q?.structuredOutputMode)!=null?S:"auto",ae=G==="outputFormat"||G==="auto"&&J,K=m?.type==="json"&&m.schema!=null&&!ae?{type:"function",name:"json",description:"Respond with a JSON object.",inputSchema:m.schema}:void 0,ee=q?.contextManagement,w=new qt,Y=vt({tools:p,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"}}),{prompt:B,betas:Q}=await Xa({prompt:o,sendReasoning:(b=q?.sendReasoning)!=null?b:!0,warnings:c,cacheControlValidator:w,toolNameMapping:Y}),k=(O=q?.thinking)==null?void 0:O.type,z=k==="enabled"||k==="adaptive",E=k==="enabled"?(N=q?.thinking)==null?void 0:N.budgetTokens:void 0,x=k==="adaptive"?(V=q?.thinking)==null?void 0:V.display:void 0,ne=n??R,X={model:this.modelId,max_tokens:ne,temperature:a,top_k:i,top_p:r,stop_sequences:g,...z&&{thinking:{type:k,...E!=null&&{budget_tokens:E},...x!=null&&{display:x}}},...(q?.effort||q?.taskBudget||ae&&m?.type==="json"&&m.schema!=null)&&{output_config:{...q?.effort&&{effort:q.effort},...q?.taskBudget&&{task_budget:{type:q.taskBudget.type,total:q.taskBudget.total,...q.taskBudget.remaining!=null&&{remaining:q.taskBudget.remaining}}},...ae&&m?.type==="json"&&m.schema!=null&&{format:{type:"json_schema",schema:er(m.schema)}}}},...q?.speed&&{speed:q.speed},...q?.inferenceGeo&&{inference_geo:q.inferenceGeo},...q?.cacheControl&&{cache_control:q.cacheControl},...((F=q?.metadata)==null?void 0:F.userId)!=null&&{metadata:{user_id:q.metadata.userId}},...q?.mcpServers&&q.mcpServers.length>0&&{mcp_servers:q.mcpServers.map(oe=>({type:oe.type,name:oe.name,url:oe.url,authorization_token:oe.authorizationToken,tool_configuration:oe.toolConfiguration?{allowed_tools:oe.toolConfiguration.allowedTools,enabled:oe.toolConfiguration.enabled}:void 0}))},...q?.container&&{container:q.container.skills&&q.container.skills.length>0?{id:q.container.id,skills:q.container.skills.map(oe=>({type:oe.type,skill_id:oe.skillId,version:oe.version}))}:q.container.id},system:B.system,messages:B.messages,...ee&&{context_management:{edits:ee.edits.map(oe=>{let Ze=oe.type;switch(Ze){case"clear_tool_uses_20250919":return{type:oe.type,...oe.trigger!==void 0&&{trigger:oe.trigger},...oe.keep!==void 0&&{keep:oe.keep},...oe.clearAtLeast!==void 0&&{clear_at_least:oe.clearAtLeast},...oe.clearToolInputs!==void 0&&{clear_tool_inputs:oe.clearToolInputs},...oe.excludeTools!==void 0&&{exclude_tools:oe.excludeTools}};case"clear_thinking_20251015":return{type:oe.type,...oe.keep!==void 0&&{keep:oe.keep}};case"compact_20260112":return{type:oe.type,...oe.trigger!==void 0&&{trigger:oe.trigger},...oe.pauseAfterCompaction!==void 0&&{pause_after_compaction:oe.pauseAfterCompaction},...oe.instructions!==void 0&&{instructions:oe.instructions}};default:c.push({type:"other",message:`Unknown context management strategy: ${Ze}`});return}}).filter(oe=>oe!==void 0)}}};z?(k==="enabled"&&E==null&&(c.push({type:"compatibility",feature:"extended thinking",details:"thinking budget is required when thinking is enabled. using default budget of 1024 tokens."}),X.thinking={type:"enabled",budget_tokens:1024},E=1024),X.temperature!=null&&(X.temperature=void 0,c.push({type:"unsupported",feature:"temperature",details:"temperature is not supported when thinking is enabled"})),i!=null&&(X.top_k=void 0,c.push({type:"unsupported",feature:"topK",details:"topK is not supported when thinking is enabled"})),r!=null&&(X.top_p=void 0,c.push({type:"unsupported",feature:"topP",details:"topP is not supported when thinking is enabled"})),X.max_tokens=ne+(E??0)):P&&r!=null&&a!=null&&(c.push({type:"unsupported",feature:"topP",details:"topP is not supported when temperature is set. topP is ignored."}),X.top_p=void 0),A&&X.max_tokens>R&&(n!=null&&c.push({type:"unsupported",feature:"maxOutputTokens",details:`${X.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${R} max output tokens. The max output tokens have been limited to ${R}.`}),X.max_tokens=R),q?.mcpServers&&q.mcpServers.length>0&&Q.add("mcp-client-2025-04-04"),ee&&(Q.add("context-management-2025-06-27"),ee.edits.some(oe=>oe.type==="compact_20260112")&&Q.add("compact-2026-01-12")),q?.container&&q.container.skills&&q.container.skills.length>0&&(Q.add("code-execution-2025-08-25"),Q.add("skills-2025-10-02"),Q.add("files-api-2025-04-14"),p?.some(oe=>oe.type==="provider"&&(oe.id==="anthropic.code_execution_20250825"||oe.id==="anthropic.code_execution_20260120"))||c.push({type:"other",message:"code execution tool is required when using skills"})),q?.effort&&Q.add("effort-2025-11-24"),q?.taskBudget&&Q.add("task-budgets-2026-03-13"),q?.speed==="fast"&&Q.add("fast-mode-2026-02-01");let me=_&&((D=q?.toolStreaming)!=null?D:!0),{tools:be,toolChoice:Qe,toolWarnings:qe,betas:ht}=await Da(K!=null?{tools:[...p??[],K],toolChoice:{type:"required"},disableParallelToolUse:!0,cacheControlValidator:w,supportsStructuredOutput:!1,supportsStrictTools:M,defaultEagerInputStreaming:me}:{tools:p??[],toolChoice:h,disableParallelToolUse:q?.disableParallelToolUse,cacheControlValidator:w,supportsStructuredOutput:J,supportsStrictTools:M,defaultEagerInputStreaming:me}),gt=w.getWarnings();return{args:{...X,tools:be,tool_choice:Qe,stream:_===!0?!0:void 0},warnings:[...c,...qe,...gt],betas:new Set([...Q,...ht,...t,...(f=q?.anthropicBeta)!=null?f:[]]),usesJsonResponseTool:K!=null,toolNameMapping:Y,providerOptionsName:H,usedCustomProviderKey:Z}}async getHeaders({betas:t,headers:o}){return re(await ve(this.config.headers),o,t.size>0?{"anthropic-beta":Array.from(t).join(",")}:{})}async getBetasFromHeaders(t){var o,n;let r=(o=(await ve(this.config.headers))["anthropic-beta"])!=null?o:"",i=(n=t?.["anthropic-beta"])!=null?n:"";return new Set([...r.toLowerCase().split(","),...i.toLowerCase().split(",")].map(u=>u.trim()).filter(u=>u!==""))}buildRequestUrl(t){var o,n,a;return(a=(n=(o=this.config).buildRequestUrl)==null?void 0:n.call(o,this.config.baseURL,t))!=null?a:`${this.config.baseURL}/messages`}transformRequestBody(t,o){var n,a,r;return(r=(a=(n=this.config).transformRequestBody)==null?void 0:a.call(n,t,o))!=null?r:t}extractCitationDocuments(t){let o=n=>{var a,r;if(n.type!=="file"||n.mediaType!=="application/pdf"&&n.mediaType!=="text/plain")return!1;let i=(a=n.providerOptions)==null?void 0:a.anthropic,u=i?.citations;return(r=u?.enabled)!=null?r:!1};return t.filter(n=>n.role==="user").flatMap(n=>n.content).filter(o).map(n=>{var a;let r=n;return{title:(a=r.filename)!=null?a:"Untitled Document",filename:r.filename,mediaType:r.mediaType}})}async doGenerate(t){var o,n,a,r,i,u,s;let{args:g,warnings:m,betas:l,usesJsonResponseTool:p,toolNameMapping:h,providerOptionsName:v,usedCustomProviderKey:_}=await this.getArgs({...t,stream:!1,userSuppliedBetas:await this.getBetasFromHeaders(t.headers)}),y=[...this.extractCitationDocuments(t.prompt)],I=$o(g.tools),{responseHeaders:S,value:b,rawValue:O}=await se({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:l,headers:t.headers}),body:this.transformRequestBody(g,l),failedResponseHandler:Mo,successfulResponseHandler:de(ca),abortSignal:t.abortSignal,fetch:this.config.fetch}),N=[],V={},F={},D=!1;for(let f of b.content)switch(f.type){case"text":{if(!p&&(N.push({type:"text",text:f.text}),f.citations))for(let c of f.citations){let H=Uo(c,y,this.generateId);H&&N.push(H)}break}case"thinking":{N.push({type:"reasoning",text:f.thinking,providerMetadata:{anthropic:{signature:f.signature}}});break}case"redacted_thinking":{N.push({type:"reasoning",text:"",providerMetadata:{anthropic:{redactedData:f.data}}});break}case"compaction":{N.push({type:"text",text:f.content,providerMetadata:{anthropic:{type:"compaction"}}});break}case"tool_use":{if(p&&f.name==="json")D=!0,N.push({type:"text",text:JSON.stringify(f.input)});else{let H=f.caller,U=H?{type:H.type,toolId:"tool_id"in H?H.tool_id:void 0}:void 0;N.push({type:"tool-call",toolCallId:f.id,toolName:f.name,input:JSON.stringify(f.input),...U&&{providerMetadata:{anthropic:{caller:U}}}})}break}case"server_tool_use":{if(f.name==="text_editor_code_execution"||f.name==="bash_code_execution")N.push({type:"tool-call",toolCallId:f.id,toolName:h.toCustomToolName("code_execution"),input:JSON.stringify({type:f.name,...f.input}),providerExecuted:!0});else if(f.name==="web_search"||f.name==="code_execution"||f.name==="web_fetch"){let c=f.name==="code_execution"&&f.input!=null&&typeof f.input=="object"&&"code"in f.input&&!("type"in f.input)?{type:"programmatic-tool-call",...f.input}:f.input;N.push({type:"tool-call",toolCallId:f.id,toolName:h.toCustomToolName(f.name),input:JSON.stringify(c),providerExecuted:!0,...I&&f.name==="code_execution"?{dynamic:!0}:{}})}else(f.name==="tool_search_tool_regex"||f.name==="tool_search_tool_bm25")&&(F[f.id]=f.name,N.push({type:"tool-call",toolCallId:f.id,toolName:h.toCustomToolName(f.name),input:JSON.stringify(f.input),providerExecuted:!0}));break}case"mcp_tool_use":{V[f.id]={type:"tool-call",toolCallId:f.id,toolName:f.name,input:JSON.stringify(f.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:f.server_name}}},N.push(V[f.id]);break}case"mcp_tool_result":{N.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:V[f.tool_use_id].toolName,isError:f.is_error,result:f.content,dynamic:!0,providerMetadata:V[f.tool_use_id].providerMetadata});break}case"web_fetch_tool_result":{f.content.type==="web_fetch_result"?(y.push({title:(o=f.content.content.title)!=null?o:f.content.url,mediaType:f.content.content.source.media_type}),N.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:f.content.url,retrievedAt:f.content.retrieved_at,content:{type:f.content.content.type,title:f.content.content.title,citations:f.content.content.citations,source:{type:f.content.content.source.type,mediaType:f.content.content.source.media_type,data:f.content.content.source.data}}}})):f.content.type==="web_fetch_tool_result_error"&&N.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:f.content.error_code}});break}case"web_search_tool_result":{if(Array.isArray(f.content)){N.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("web_search"),result:f.content.map(c=>{var H;return{url:c.url,title:c.title,pageAge:(H=c.page_age)!=null?H:null,encryptedContent:c.encrypted_content,type:c.type}})});for(let c of f.content)N.push({type:"source",sourceType:"url",id:this.generateId(),url:c.url,title:c.title,providerMetadata:{anthropic:{pageAge:(n=c.page_age)!=null?n:null}}})}else N.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:f.content.error_code}});break}case"code_execution_tool_result":{f.content.type==="code_execution_result"?N.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:{type:f.content.type,stdout:f.content.stdout,stderr:f.content.stderr,return_code:f.content.return_code,content:(a=f.content.content)!=null?a:[]}}):f.content.type==="encrypted_code_execution_result"?N.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:{type:f.content.type,encrypted_stdout:f.content.encrypted_stdout,stderr:f.content.stderr,return_code:f.content.return_code,content:(r=f.content.content)!=null?r:[]}}):f.content.type==="code_execution_tool_result_error"&&N.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:f.content.error_code}});break}case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":{N.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:f.content});break}case"tool_search_tool_result":{let c=F[f.tool_use_id];if(c==null){let H=h.toCustomToolName("tool_search_tool_bm25"),U=h.toCustomToolName("tool_search_tool_regex");H!=="tool_search_tool_bm25"?c="tool_search_tool_bm25":c="tool_search_tool_regex"}f.content.type==="tool_search_tool_search_result"?N.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName(c),result:f.content.tool_references.map(H=>({type:H.type,toolName:H.tool_name}))}):N.push({type:"tool-result",toolCallId:f.tool_use_id,toolName:h.toCustomToolName(c),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:f.content.error_code}});break}}return{content:N,finishReason:{unified:Pt({finishReason:b.stop_reason,isJsonResponseFromTool:D}),raw:(i=b.stop_reason)!=null?i:void 0},usage:qo({usage:b.usage}),request:{body:g},response:{id:(u=b.id)!=null?u:void 0,modelId:(s=b.model)!=null?s:void 0,headers:S,body:O},warnings:m,providerMetadata:(()=>{var f,c,H,U,W;let Z={usage:b.usage,cacheCreationInputTokens:(f=b.usage.cache_creation_input_tokens)!=null?f:null,stopSequence:(c=b.stop_sequence)!=null?c:null,iterations:b.usage.iterations?b.usage.iterations.map(R=>({type:R.type,inputTokens:R.input_tokens,outputTokens:R.output_tokens})):null,container:b.container?{expiresAt:b.container.expires_at,id:b.container.id,skills:(U=(H=b.container.skills)==null?void 0:H.map(R=>({type:R.type,skillId:R.skill_id,version:R.version})))!=null?U:null}:null,contextManagement:(W=Fo(b.context_management))!=null?W:null},q={anthropic:Z};return _&&v!=="anthropic"&&(q[v]=Z),q})()}}async doStream(t){var o,n;let{args:a,warnings:r,betas:i,usesJsonResponseTool:u,toolNameMapping:s,providerOptionsName:g,usedCustomProviderKey:m}=await this.getArgs({...t,stream:!0,userSuppliedBetas:await this.getBetasFromHeaders(t.headers)}),l=[...this.extractCitationDocuments(t.prompt)],p=$o(a.tools),h=this.buildRequestUrl(!0),{responseHeaders:v,value:_}=await se({url:h,headers:await this.getHeaders({betas:i,headers:t.headers}),body:this.transformRequestBody(a,i),failedResponseHandler:Mo,successfulResponseHandler:xe(da),abortSignal:t.abortSignal,fetch:this.config.fetch}),y={unified:"other",raw:void 0},I={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,iterations:null},S={},b={},O={},N=null,V,F=null,D=null,f=null,c=!1,H,U=this.generateId,W=_.pipeThrough(new TransformStream({start($){$.enqueue({type:"stream-start",warnings:r})},transform($,j){var A,P,J,M,G,ae,K,ee,w,Y,B,Q,k,z;if(t.includeRawChunks&&j.enqueue({type:"raw",rawValue:$.rawValue}),!$.success){j.enqueue({type:"error",error:$.error});return}let E=$.value;switch(E.type){case"ping":return;case"content_block_start":{let x=E.content_block,ne=x.type;switch(H=ne,ne){case"text":{if(u)return;S[E.index]={type:"text"},j.enqueue({type:"text-start",id:String(E.index)});return}case"thinking":{S[E.index]={type:"reasoning"},j.enqueue({type:"reasoning-start",id:String(E.index)});return}case"redacted_thinking":{S[E.index]={type:"reasoning"},j.enqueue({type:"reasoning-start",id:String(E.index),providerMetadata:{anthropic:{redactedData:x.data}}});return}case"compaction":{S[E.index]={type:"text"},j.enqueue({type:"text-start",id:String(E.index),providerMetadata:{anthropic:{type:"compaction"}}});return}case"tool_use":{if(u&&x.name==="json")c=!0,S[E.index]={type:"text"},j.enqueue({type:"text-start",id:String(E.index)});else{let me=x.caller,be=me?{type:me.type,toolId:"tool_id"in me?me.tool_id:void 0}:void 0,qe=x.input&&Object.keys(x.input).length>0?JSON.stringify(x.input):"";S[E.index]={type:"tool-call",toolCallId:x.id,toolName:x.name,input:qe,firstDelta:qe.length===0,...be&&{caller:be}},j.enqueue({type:"tool-input-start",id:x.id,toolName:x.name})}return}case"server_tool_use":{if(["web_fetch","web_search","code_execution","text_editor_code_execution","bash_code_execution"].includes(x.name)){let X=x.name==="text_editor_code_execution"||x.name==="bash_code_execution"?"code_execution":x.name,me=s.toCustomToolName(X),be=x.input!=null&&typeof x.input=="object"&&Object.keys(x.input).length>0?JSON.stringify(x.input):"";S[E.index]={type:"tool-call",toolCallId:x.id,toolName:me,input:be,providerExecuted:!0,...p&&X==="code_execution"?{dynamic:!0}:{},firstDelta:!0,providerToolName:x.name},j.enqueue({type:"tool-input-start",id:x.id,toolName:me,providerExecuted:!0,...p&&X==="code_execution"?{dynamic:!0}:{}})}else if(x.name==="tool_search_tool_regex"||x.name==="tool_search_tool_bm25"){O[x.id]=x.name;let X=s.toCustomToolName(x.name);S[E.index]={type:"tool-call",toolCallId:x.id,toolName:X,input:"",providerExecuted:!0,firstDelta:!0,providerToolName:x.name},j.enqueue({type:"tool-input-start",id:x.id,toolName:X,providerExecuted:!0})}return}case"web_fetch_tool_result":{x.content.type==="web_fetch_result"?(l.push({title:(A=x.content.content.title)!=null?A:x.content.url,mediaType:x.content.content.source.media_type}),j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:x.content.url,retrievedAt:x.content.retrieved_at,content:{type:x.content.content.type,title:x.content.content.title,citations:x.content.content.citations,source:{type:x.content.content.source.type,mediaType:x.content.content.source.media_type,data:x.content.content.source.data}}}})):x.content.type==="web_fetch_tool_result_error"&&j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:x.content.error_code}});return}case"web_search_tool_result":{if(Array.isArray(x.content)){j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("web_search"),result:x.content.map(X=>{var me;return{url:X.url,title:X.title,pageAge:(me=X.page_age)!=null?me:null,encryptedContent:X.encrypted_content,type:X.type}})});for(let X of x.content)j.enqueue({type:"source",sourceType:"url",id:U(),url:X.url,title:X.title,providerMetadata:{anthropic:{pageAge:(P=X.page_age)!=null?P:null}}})}else j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:x.content.error_code}});return}case"code_execution_tool_result":{x.content.type==="code_execution_result"?j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("code_execution"),result:{type:x.content.type,stdout:x.content.stdout,stderr:x.content.stderr,return_code:x.content.return_code,content:(J=x.content.content)!=null?J:[]}}):x.content.type==="encrypted_code_execution_result"?j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("code_execution"),result:{type:x.content.type,encrypted_stdout:x.content.encrypted_stdout,stderr:x.content.stderr,return_code:x.content.return_code,content:(M=x.content.content)!=null?M:[]}}):x.content.type==="code_execution_tool_result_error"&&j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:x.content.error_code}});return}case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":{j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName("code_execution"),result:x.content});return}case"tool_search_tool_result":{let X=O[x.tool_use_id];if(X==null){let me=s.toCustomToolName("tool_search_tool_bm25"),be=s.toCustomToolName("tool_search_tool_regex");me!=="tool_search_tool_bm25"?X="tool_search_tool_bm25":X="tool_search_tool_regex"}x.content.type==="tool_search_tool_search_result"?j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName(X),result:x.content.tool_references.map(me=>({type:me.type,toolName:me.tool_name}))}):j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:s.toCustomToolName(X),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:x.content.error_code}});return}case"mcp_tool_use":{b[x.id]={type:"tool-call",toolCallId:x.id,toolName:x.name,input:JSON.stringify(x.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:x.server_name}}},j.enqueue(b[x.id]);return}case"mcp_tool_result":{j.enqueue({type:"tool-result",toolCallId:x.tool_use_id,toolName:b[x.tool_use_id].toolName,isError:x.is_error,result:x.content,dynamic:!0,providerMetadata:b[x.tool_use_id].providerMetadata});return}default:{let X=ne;throw new Error(`Unsupported content block type: ${X}`)}}}case"content_block_stop":{if(S[E.index]!=null){let x=S[E.index];switch(x.type){case"text":{j.enqueue({type:"text-end",id:String(E.index)});break}case"reasoning":{j.enqueue({type:"reasoning-end",id:String(E.index)});break}case"tool-call":if(!(u&&x.toolName==="json")){j.enqueue({type:"tool-input-end",id:x.toolCallId});let X=x.input===""?"{}":x.input;if(x.providerToolName==="code_execution")try{let me=JSON.parse(X);me!=null&&typeof me=="object"&&"code"in me&&!("type"in me)&&(X=JSON.stringify({type:"programmatic-tool-call",...me}))}catch{}j.enqueue({type:"tool-call",toolCallId:x.toolCallId,toolName:x.toolName,input:X,providerExecuted:x.providerExecuted,...p&&x.providerToolName==="code_execution"?{dynamic:!0}:{},...x.caller&&{providerMetadata:{anthropic:{caller:x.caller}}}})}break}delete S[E.index]}H=void 0;return}case"content_block_delta":{let x=E.delta.type;switch(x){case"text_delta":{if(u)return;j.enqueue({type:"text-delta",id:String(E.index),delta:E.delta.text});return}case"thinking_delta":{j.enqueue({type:"reasoning-delta",id:String(E.index),delta:E.delta.thinking});return}case"signature_delta":{H==="thinking"&&j.enqueue({type:"reasoning-delta",id:String(E.index),delta:"",providerMetadata:{anthropic:{signature:E.delta.signature}}});return}case"compaction_delta":{E.delta.content!=null&&j.enqueue({type:"text-delta",id:String(E.index),delta:E.delta.content});return}case"input_json_delta":{let ne=S[E.index],X=E.delta.partial_json;if(X.length===0)return;if(c){if(ne?.type!=="text")return;j.enqueue({type:"text-delta",id:String(E.index),delta:X})}else{if(ne?.type!=="tool-call")return;ne.firstDelta&&(ne.providerToolName==="bash_code_execution"||ne.providerToolName==="text_editor_code_execution")&&(X=`{"type": "${ne.providerToolName}",${X.substring(1)}`),j.enqueue({type:"tool-input-delta",id:ne.toolCallId,delta:X}),ne.input+=X,ne.firstDelta=!1}return}case"citations_delta":{let ne=E.delta.citation,X=Uo(ne,l,U);X&&j.enqueue(X);return}default:{let ne=x;throw new Error(`Unsupported delta type: ${ne}`)}}}case"message_start":{if(I.input_tokens=E.message.usage.input_tokens,I.cache_read_input_tokens=(G=E.message.usage.cache_read_input_tokens)!=null?G:0,I.cache_creation_input_tokens=(ae=E.message.usage.cache_creation_input_tokens)!=null?ae:0,V={...E.message.usage},F=(K=E.message.usage.cache_creation_input_tokens)!=null?K:null,E.message.container!=null&&(f={expiresAt:E.message.container.expires_at,id:E.message.container.id,skills:null}),E.message.stop_reason!=null&&(y={unified:Pt({finishReason:E.message.stop_reason,isJsonResponseFromTool:c}),raw:E.message.stop_reason}),j.enqueue({type:"response-metadata",id:(ee=E.message.id)!=null?ee:void 0,modelId:(w=E.message.model)!=null?w:void 0}),E.message.content!=null)for(let x=0;x<E.message.content.length;x++){let ne=E.message.content[x];if(ne.type==="tool_use"){let X=ne.caller,me=X?{type:X.type,toolId:"tool_id"in X?X.tool_id:void 0}:void 0;j.enqueue({type:"tool-input-start",id:ne.id,toolName:ne.name});let be=JSON.stringify((Y=ne.input)!=null?Y:{});j.enqueue({type:"tool-input-delta",id:ne.id,delta:be}),j.enqueue({type:"tool-input-end",id:ne.id}),j.enqueue({type:"tool-call",toolCallId:ne.id,toolName:ne.name,input:be,...me&&{providerMetadata:{anthropic:{caller:me}}}})}}return}case"message_delta":{E.usage.input_tokens!=null&&I.input_tokens!==E.usage.input_tokens&&(I.input_tokens=E.usage.input_tokens),I.output_tokens=E.usage.output_tokens,E.usage.cache_read_input_tokens!=null&&(I.cache_read_input_tokens=E.usage.cache_read_input_tokens),E.usage.cache_creation_input_tokens!=null&&(I.cache_creation_input_tokens=E.usage.cache_creation_input_tokens,F=E.usage.cache_creation_input_tokens),E.usage.iterations!=null&&(I.iterations=E.usage.iterations),y={unified:Pt({finishReason:E.delta.stop_reason,isJsonResponseFromTool:c}),raw:(B=E.delta.stop_reason)!=null?B:void 0},D=(Q=E.delta.stop_sequence)!=null?Q:null,f=E.delta.container!=null?{expiresAt:E.delta.container.expires_at,id:E.delta.container.id,skills:(z=(k=E.delta.container.skills)==null?void 0:k.map(x=>({type:x.type,skillId:x.skill_id,version:x.version})))!=null?z:null}:null,E.context_management&&(N=Fo(E.context_management)),V={...V,...E.usage};return}case"message_stop":{let x={usage:V??null,cacheCreationInputTokens:F,stopSequence:D,iterations:I.iterations?I.iterations.map(X=>({type:X.type,inputTokens:X.input_tokens,outputTokens:X.output_tokens})):null,container:f,contextManagement:N},ne={anthropic:x};m&&g!=="anthropic"&&(ne[g]=x),j.enqueue({type:"finish",finishReason:y,usage:qo({usage:I,rawUsage:V}),providerMetadata:ne});return}case"error":{j.enqueue({type:"error",error:E.error});return}default:{let x=E;throw new Error(`Unsupported chunk type: ${x}`)}}}})),[Z,q]=W.tee(),R=Z.getReader();try{await R.read();let $=await R.read();if(((o=$.value)==null?void 0:o.type)==="raw"&&($=await R.read()),((n=$.value)==null?void 0:n.type)==="error"){let j=$.value.error;throw new yt({message:j.message,url:h,requestBodyValues:a,statusCode:j.type==="overloaded_error"?529:500,responseHeaders:v,responseBody:JSON.stringify(j),isRetryable:j.type==="overloaded_error"})}}finally{R.cancel().catch(()=>{}),R.releaseLock()}return{stream:q,request:{body:a},response:{headers:v}}}};function ir(t){return t.includes("claude-opus-4-7")?{maxOutputTokens:128e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!0,isKnownModel:!0}:t.includes("claude-sonnet-4-6")||t.includes("claude-opus-4-6")?{maxOutputTokens:128e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,isKnownModel:!0}:t.includes("claude-sonnet-4-5")||t.includes("claude-opus-4-5")||t.includes("claude-haiku-4-5")?{maxOutputTokens:64e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,isKnownModel:!0}:t.includes("claude-opus-4-1")?{maxOutputTokens:32e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,isKnownModel:!0}:t.includes("claude-sonnet-4-")?{maxOutputTokens:64e3,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!0}:t.includes("claude-opus-4-")?{maxOutputTokens:32e3,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!0}:t.includes("claude-3-haiku")?{maxOutputTokens:4096,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!0}:{maxOutputTokens:4096,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!1}}function $o(t){if(!t)return!1;let o=!1,n=!1;for(let a of t){if("type"in a&&(a.type==="web_fetch_20260209"||a.type==="web_search_20260209")){o=!0;continue}if(a.name==="code_execution"){n=!0;break}}return o&&!n}function Fo(t){return t?{appliedEdits:t.applied_edits.map(o=>{switch(o.type){case"clear_tool_uses_20250919":return{type:o.type,clearedToolUses:o.cleared_tool_uses,clearedInputTokens:o.cleared_input_tokens};case"clear_thinking_20251015":return{type:o.type,clearedThinkingTurns:o.cleared_thinking_turns,clearedInputTokens:o.cleared_input_tokens};case"compact_20260112":return{type:o.type}}}).filter(o=>o!==void 0)}:null}var sr=C(()=>T(e.object({command:e.string(),restart:e.boolean().optional()}))),lr=ce({id:"anthropic.bash_20241022",inputSchema:sr}),ur=C(()=>T(e.object({command:e.string(),restart:e.boolean().optional()}))),cr=ce({id:"anthropic.bash_20250124",inputSchema:ur}),dr=C(()=>T(e.object({action:e.enum(["key","type","mouse_move","left_click","left_click_drag","right_click","middle_click","double_click","screenshot","cursor_position"]),coordinate:e.array(e.number().int()).optional(),text:e.string().optional()}))),pr=ce({id:"anthropic.computer_20241022",inputSchema:dr}),mr=C(()=>T(e.object({action:e.enum(["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:e.tuple([e.number().int(),e.number().int()]).optional(),duration:e.number().optional(),scroll_amount:e.number().optional(),scroll_direction:e.enum(["up","down","left","right"]).optional(),start_coordinate:e.tuple([e.number().int(),e.number().int()]).optional(),text:e.string().optional()}))),hr=ce({id:"anthropic.computer_20250124",inputSchema:mr}),gr=C(()=>T(e.object({action:e.enum(["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:e.tuple([e.number().int(),e.number().int()]).optional(),duration:e.number().optional(),region:e.tuple([e.number().int(),e.number().int(),e.number().int(),e.number().int()]).optional(),scroll_amount:e.number().optional(),scroll_direction:e.enum(["up","down","left","right"]).optional(),start_coordinate:e.tuple([e.number().int(),e.number().int()]).optional(),text:e.string().optional()}))),_r=ce({id:"anthropic.computer_20251124",inputSchema:gr}),fr=C(()=>T(e.discriminatedUnion("command",[e.object({command:e.literal("view"),path:e.string(),view_range:e.tuple([e.number(),e.number()]).optional()}),e.object({command:e.literal("create"),path:e.string(),file_text:e.string()}),e.object({command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()}),e.object({command:e.literal("insert"),path:e.string(),insert_line:e.number(),insert_text:e.string()}),e.object({command:e.literal("delete"),path:e.string()}),e.object({command:e.literal("rename"),old_path:e.string(),new_path:e.string()})]))),yr=ce({id:"anthropic.memory_20250818",inputSchema:fr}),br=C(()=>T(e.object({command:e.enum(["view","create","str_replace","insert","undo_edit"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),vr=ce({id:"anthropic.text_editor_20241022",inputSchema:br}),xr=C(()=>T(e.object({command:e.enum(["view","create","str_replace","insert","undo_edit"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),wr=ce({id:"anthropic.text_editor_20250124",inputSchema:xr}),Sr=C(()=>T(e.object({command:e.enum(["view","create","str_replace","insert"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),Cr=ce({id:"anthropic.text_editor_20250429",inputSchema:Sr}),Tr=C(()=>T(e.array(e.object({type:e.literal("tool_reference"),toolName:e.string()})))),Ir=C(()=>T(e.object({query:e.string(),limit:e.number().optional()}))),kr=ie({id:"anthropic.tool_search_bm25_20251119",inputSchema:Ir,outputSchema:Tr,supportsDeferredResults:!0}),jr=(t={})=>kr(t),Or={bash_20241022:lr,bash_20250124:cr,codeExecution_20250522:Ua,codeExecution_20250825:La,codeExecution_20260120:Ja,computer_20241022:pr,computer_20250124:hr,computer_20251124:_r,memory_20250818:yr,textEditor_20241022:vr,textEditor_20250124:wr,textEditor_20250429:Cr,textEditor_20250728:fa,webFetch_20250910:za,webFetch_20260209:Na,webSearch_20250305:Ia,webSearch_20260209:wa,toolSearchRegex_20251119:Ba,toolSearchBm25_20251119:jr};function Ut(t={}){var o,n;let a=(o=Ae(wt({settingValue:t.baseURL,environmentVariableName:"ANTHROPIC_BASE_URL"})))!=null?o:"https://api.anthropic.com/v1",r=(n=t.name)!=null?n:"anthropic.messages";if(t.apiKey&&t.authToken)throw new go({argument:"apiKey/authToken",message:"Both apiKey and authToken were provided. Please use only one authentication method."});let i=()=>{let g=t.authToken?{Authorization:`Bearer ${t.authToken}`}:{"x-api-key":Je({apiKey:t.apiKey,environmentVariableName:"ANTHROPIC_API_KEY",description:"Anthropic"})};return Ee({"anthropic-version":"2023-06-01",...g,...t.headers},`ai-sdk/anthropic/${la}`)},u=g=>{var m;return new rr(g,{provider:r,baseURL:a,headers:i,fetch:t.fetch,generateId:(m=t.generateId)!=null?m:pe,supportedUrls:()=>({"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]})})},s=function(g){if(new.target)throw new Error("The Anthropic model function cannot be called with the new keyword.");return u(g)};return s.specificationVersion="v3",s.languageModel=u,s.chat=u,s.messages=u,s.embeddingModel=g=>{throw new Et({modelId:g,modelType:"embeddingModel"})},s.textEmbeddingModel=s.embeddingModel,s.imageModel=g=>{throw new Et({modelId:g,modelType:"imageModel"})},s.tools=Or,s}var Gu=Ut();var Rr="3.0.67",Nr=C(()=>T(e.object({error:e.object({code:e.number().nullable(),message:e.string(),status:e.string()})}))),Fe=ye({errorSchema:Nr,errorToMessage:t=>t.error.message}),Er=e.union([e.object({text:e.string()}),e.object({inlineData:e.object({mimeType:e.string(),data:e.string()})})]),Ar=C(()=>T(e.object({outputDimensionality:e.number().optional(),taskType:e.enum(["SEMANTIC_SIMILARITY","CLASSIFICATION","CLUSTERING","RETRIEVAL_DOCUMENT","RETRIEVAL_QUERY","QUESTION_ANSWERING","FACT_VERIFICATION","CODE_RETRIEVAL_QUERY"]).optional(),content:e.array(e.array(Er).min(1).nullable()).optional()}))),Mr=class{constructor(t,o){this.specificationVersion="v3",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0,this.modelId=t,this.config=o}get provider(){return this.config.provider}async doEmbed({values:t,headers:o,abortSignal:n,providerOptions:a}){let r=await te({provider:"google",providerOptions:a,schema:Ar});if(t.length>this.maxEmbeddingsPerCall)throw new Ve({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:t});let i=re(await ve(this.config.headers),o),u=r?.content;if(u!=null&&u.length!==t.length)throw new Error(`The number of multimodal content entries (${u.length}) must match the number of values (${t.length}).`);if(t.length===1){let l=u?.[0],p=t[0]?[{text:t[0]}]:[],h=l!=null?[...p,...l]:[{text:t[0]}],{responseHeaders:v,value:_,rawValue:y}=await se({url:`${this.config.baseURL}/models/${this.modelId}:embedContent`,headers:i,body:{model:`models/${this.modelId}`,content:{parts:h},outputDimensionality:r?.outputDimensionality,taskType:r?.taskType},failedResponseHandler:Fe,successfulResponseHandler:de(Dr),abortSignal:n,fetch:this.config.fetch});return{warnings:[],embeddings:[_.embedding.values],usage:void 0,response:{headers:v,body:y}}}let{responseHeaders:s,value:g,rawValue:m}=await se({url:`${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,headers:i,body:{requests:t.map((l,p)=>{let h=u?.[p],v=l?[{text:l}]:[];return{model:`models/${this.modelId}`,content:{role:"user",parts:h!=null?[...v,...h]:[{text:l}]},outputDimensionality:r?.outputDimensionality,taskType:r?.taskType}})},failedResponseHandler:Fe,successfulResponseHandler:de(zr),abortSignal:n,fetch:this.config.fetch});return{warnings:[],embeddings:g.embeddings.map(l=>l.values),usage:void 0,response:{headers:s,body:m}}}},zr=C(()=>T(e.object({embeddings:e.array(e.object({values:e.array(e.number())}))}))),Dr=C(()=>T(e.object({embedding:e.object({values:e.array(e.number())})})));function Yo(t){var o,n,a,r;if(t==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 i=(o=t.promptTokenCount)!=null?o:0,u=(n=t.candidatesTokenCount)!=null?n:0,s=(a=t.cachedContentTokenCount)!=null?a:0,g=(r=t.thoughtsTokenCount)!=null?r:0;return{inputTokens:{total:i,noCache:i-s,cacheRead:s,cacheWrite:void 0},outputTokens:{total:u+g,text:u,reasoning:g},raw:t}}function Te(t,o=!0){if(t==null)return;if(Pr(t))return o?void 0:typeof t=="object"&&t.description?{type:"object",description:t.description}:{type:"object"};if(typeof t=="boolean")return{type:"boolean",properties:{}};let{type:n,description:a,required:r,properties:i,items:u,allOf:s,anyOf:g,oneOf:m,format:l,const:p,minLength:h,enum:v}=t,_={};if(a&&(_.description=a),r&&(_.required=r),l&&(_.format=l),p!==void 0&&(_.enum=[p]),n)if(Array.isArray(n)){let y=n.includes("null"),I=n.filter(S=>S!=="null");I.length===0?_.type="null":(_.anyOf=I.map(S=>({type:S})),y&&(_.nullable=!0))}else _.type=n;if(v!==void 0&&(_.enum=v),i!=null&&(_.properties=Object.entries(i).reduce((y,[I,S])=>(y[I]=Te(S,!1),y),{})),u&&(_.items=Array.isArray(u)?u.map(y=>Te(y,!1)):Te(u,!1)),s&&(_.allOf=s.map(y=>Te(y,!1))),g)if(g.some(y=>typeof y=="object"&&y?.type==="null")){let y=g.filter(I=>!(typeof I=="object"&&I?.type==="null"));if(y.length===1){let I=Te(y[0],!1);typeof I=="object"&&(_.nullable=!0,Object.assign(_,I))}else _.anyOf=y.map(I=>Te(I,!1)),_.nullable=!0}else _.anyOf=g.map(y=>Te(y,!1));return m&&(_.oneOf=m.map(y=>Te(y,!1))),h!==void 0&&(_.minLength=h),_}function Pr(t){return t!=null&&typeof t=="object"&&t.type==="object"&&(t.properties==null||Object.keys(t.properties).length===0)&&!t.additionalProperties}var qr=/^data:([^;,]+);base64,(.+)$/s;function Ur(t){let o=qr.exec(t);if(o!=null)return{mediaType:o[1],data:o[2]}}function $r(t){let o=Ur(t);if(o!=null)return{inlineData:{mimeType:o.mediaType,data:o.data}}}function Fr(t,o,n){let a=[],r=[];for(let i of n)switch(i.type){case"text":{r.push(i.text);break}case"image-data":case"file-data":{a.push({inlineData:{mimeType:i.mediaType,data:i.data}});break}case"image-url":case"file-url":{let u=$r(i.url);u!=null?a.push(u):r.push(JSON.stringify(i));break}default:{r.push(JSON.stringify(i));break}}t.push({functionResponse:{name:o,response:{name:o,content:r.length>0?r.join(`
3
3
  `):"Tool executed successfully."},...a.length>0?{parts:a}:{}}})}function Lr(t,o,n){for(let a of n)switch(a.type){case"text":t.push({functionResponse:{name:o,response:{name:o,content:a.text}}});break;case"image-data":t.push({inlineData:{mimeType:String(a.mediaType),data:String(a.data)}},{text:"Tool executed successfully and returned this image as a response"});break;default:t.push({text:JSON.stringify(a)});break}}function Hr(t,o){var n,a,r,i,u,s,g,m;let l=[],p=[],h=!0,v=(n=o?.isGemmaModel)!=null?n:!1,_=(a=o?.providerOptionsName)!=null?a:"google",y=(r=o?.supportsFunctionResponseParts)!=null?r:!0;for(let{role:I,content:S}of t)switch(I){case"system":{if(!h)throw new le({functionality:"system messages are only supported at the beginning of the conversation"});l.push({text:S});break}case"user":{h=!1;let b=[];for(let O of S)switch(O.type){case"text":{b.push({text:O.text});break}case"file":{let N=O.mediaType==="image/*"?"image/jpeg":O.mediaType;b.push(O.data instanceof URL?{fileData:{mimeType:N,fileUri:O.data.toString()}}:{inlineData:{mimeType:N,data:_e(O.data)}});break}}p.push({role:"user",parts:b});break}case"assistant":{h=!1,p.push({role:"model",parts:S.map(b=>{var O,N,V,F;let D=(F=(O=b.providerOptions)==null?void 0:O[_])!=null?F:_!=="google"?(N=b.providerOptions)==null?void 0:N.google:(V=b.providerOptions)==null?void 0:V.vertex,f=D?.thoughtSignature!=null?String(D.thoughtSignature):void 0;switch(b.type){case"text":return b.text.length===0?void 0:{text:b.text,thoughtSignature:f};case"reasoning":return b.text.length===0?void 0:{text:b.text,thought:!0,thoughtSignature:f};case"file":{if(b.data instanceof URL)throw new le({functionality:"File data URLs in assistant messages are not supported"});return{inlineData:{mimeType:b.mediaType,data:_e(b.data)},...D?.thought===!0?{thought:!0}:{},thoughtSignature:f}}case"tool-call":{let c=D?.serverToolCallId!=null?String(D.serverToolCallId):void 0,H=D?.serverToolType!=null?String(D.serverToolType):void 0;return c&&H?{toolCall:{toolType:H,args:typeof b.input=="string"?JSON.parse(b.input):b.input,id:c},thoughtSignature:f}:{functionCall:{name:b.toolName,args:b.input},thoughtSignature:f}}case"tool-result":{let c=D?.serverToolCallId!=null?String(D.serverToolCallId):void 0,H=D?.serverToolType!=null?String(D.serverToolType):void 0;return c&&H?{toolResponse:{toolType:H,response:b.output.type==="json"?b.output.value:{},id:c},thoughtSignature:f}:void 0}}}).filter(b=>b!==void 0)});break}case"tool":{h=!1;let b=[];for(let O of S){if(O.type==="tool-approval-response")continue;let N=(g=(i=O.providerOptions)==null?void 0:i[_])!=null?g:_!=="google"?(u=O.providerOptions)==null?void 0:u.google:(s=O.providerOptions)==null?void 0:s.vertex,V=N?.serverToolCallId!=null?String(N.serverToolCallId):void 0,F=N?.serverToolType!=null?String(N.serverToolType):void 0;if(V&&F){let f=N?.thoughtSignature!=null?String(N.thoughtSignature):void 0;if(p.length>0){let c=p[p.length-1];if(c.role==="model"){c.parts.push({toolResponse:{toolType:F,response:O.output.type==="json"?O.output.value:{},id:V},thoughtSignature:f});continue}}}let D=O.output;D.type==="content"?y?Fr(b,O.toolName,D.value):Lr(b,O.toolName,D.value):b.push({functionResponse:{name:O.toolName,response:{name:O.toolName,content:D.type==="execution-denied"?(m=D.reason)!=null?m:"Tool execution denied.":D.value}}})}p.push({role:"user",parts:b});break}}if(v&&l.length>0&&p.length>0&&p[0].role==="user"){let I=l.map(S=>S.text).join(`
4
4
 
@@ -1 +1 @@
1
- import{c as x,n as y}from"./chunk-XOWWPE7X.js";import{a as d,c as g,j as R}from"./chunk-ETPZ3TXX.js";var v=3600*1e3,p=new Map,P=new Map,h=new Set;function A(e){return e.trim().toLowerCase()}function E(e){let r=p.get(e);if(r){if(Date.now()-r.fetchedAt>v){p.delete(e);return}return r}}function M(){h.forEach(e=>e())}function T(e){let r=window.firebase.db,s=window.__ROOT_CTX.rootConfig.projectId;return x(r,"Projects",s,"UserProfiles",e)}function a(e){if(!e)return null;let r=E(A(e));return r?r.value:void 0}async function U(e){if(!e)return null;let r=A(e),s=E(r);if(s)return s.value;let n=P.get(r);if(n)return n;let i=(async()=>{try{let t=await y(T(r)),l=t.exists()?t.data():null;return p.set(r,{value:l,fetchedAt:Date.now()}),M(),l}catch(t){return console.error("failed to fetch user profile:",e,t),p.set(r,{value:null,fetchedAt:Date.now()}),null}finally{P.delete(r)}})();return P.set(r,i),i}function b(e){return h.add(e),()=>{h.delete(e)}}function O(e,r){if(!(r||e||"").trim())return"?";if(r){let t=r.trim().split(/\s+/).map(l=>l.replace(/[^a-zA-Z0-9]/g,"")).filter(Boolean);if(t.length>=2)return(t[0][0]+t[1][0]).toUpperCase();if(t.length===1&&t[0].length>0)return t[0].slice(0,2).toUpperCase()}let i=(e.split("@")[0]||e).replace(/[^a-zA-Z0-9]/g,"");return i.length===0?"?":i.slice(0,2).toUpperCase()}function S(e){let r=e.trim();if(!r)return"?";let[s,n=""]=r.split("@"),t=(_(r)?n:s||r).replace(/[^a-zA-Z0-9]/g,"");return t.length===0?"?":t[0].toUpperCase()}function _(e){return e.trim().startsWith("*@")}function z(e){let r=["#1f6feb","#0e7490","#0f766e","#15803d","#9333ea","#c026d3","#db2777","#dc2626","#ea580c","#b45309"],s=0;for(let n=0;n<e.length;n++)s=s*31+e.charCodeAt(n)>>>0;return r[s%r.length]}R();function H(e){let r=e?a(e):null,[s,n]=d(r??null),[i,t]=d(!!e&&r===void 0);return g(()=>{if(!e){n(null),t(!1);return}let l=!1,o=a(e);o!==void 0?(n(o),t(!1)):(t(!0),U(e).then(f=>{l||(n(f),t(!1))}));let c=b(()=>{if(l||!e)return;let f=a(e);f!==void 0&&n(f)});return()=>{l=!0,c()}},[e]),{profile:s,loading:i}}function W(e){let r=e.filter(o=>!!o).map(o=>o.toLowerCase()),s=r.slice().sort().join(","),[n,i]=d(()=>{let o=new Map;return r.forEach(c=>{let f=a(c);f!==void 0&&o.set(c,f)}),o}),[t,l]=d(r.length>0);return g(()=>{if(r.length===0){i(new Map),l(!1);return}let o=!1;function c(){let u=new Map,w=!1;r.forEach(C=>{let m=a(C);m===void 0?w=!0:u.set(C,m)}),i(u),l(w)}c(),Promise.all(r.filter(u=>a(u)===void 0).map(u=>U(u))).then(()=>{o||c()});let f=b(()=>{o||c()});return()=>{o=!0,f()}},[s]),{profiles:n,loading:t}}export{O as a,S as b,_ as c,z as d,H as e,W as f};
1
+ import{c as x,n as y}from"./chunk-XOWWPE7X.js";import{a as d,c as g,j as R}from"./chunk-WRA24P66.js";var v=3600*1e3,p=new Map,P=new Map,h=new Set;function A(e){return e.trim().toLowerCase()}function E(e){let r=p.get(e);if(r){if(Date.now()-r.fetchedAt>v){p.delete(e);return}return r}}function M(){h.forEach(e=>e())}function T(e){let r=window.firebase.db,s=window.__ROOT_CTX.rootConfig.projectId;return x(r,"Projects",s,"UserProfiles",e)}function a(e){if(!e)return null;let r=E(A(e));return r?r.value:void 0}async function U(e){if(!e)return null;let r=A(e),s=E(r);if(s)return s.value;let n=P.get(r);if(n)return n;let i=(async()=>{try{let t=await y(T(r)),l=t.exists()?t.data():null;return p.set(r,{value:l,fetchedAt:Date.now()}),M(),l}catch(t){return console.error("failed to fetch user profile:",e,t),p.set(r,{value:null,fetchedAt:Date.now()}),null}finally{P.delete(r)}})();return P.set(r,i),i}function b(e){return h.add(e),()=>{h.delete(e)}}function O(e,r){if(!(r||e||"").trim())return"?";if(r){let t=r.trim().split(/\s+/).map(l=>l.replace(/[^a-zA-Z0-9]/g,"")).filter(Boolean);if(t.length>=2)return(t[0][0]+t[1][0]).toUpperCase();if(t.length===1&&t[0].length>0)return t[0].slice(0,2).toUpperCase()}let i=(e.split("@")[0]||e).replace(/[^a-zA-Z0-9]/g,"");return i.length===0?"?":i.slice(0,2).toUpperCase()}function S(e){let r=e.trim();if(!r)return"?";let[s,n=""]=r.split("@"),t=(_(r)?n:s||r).replace(/[^a-zA-Z0-9]/g,"");return t.length===0?"?":t[0].toUpperCase()}function _(e){return e.trim().startsWith("*@")}function z(e){let r=["#1f6feb","#0e7490","#0f766e","#15803d","#9333ea","#c026d3","#db2777","#dc2626","#ea580c","#b45309"],s=0;for(let n=0;n<e.length;n++)s=s*31+e.charCodeAt(n)>>>0;return r[s%r.length]}R();function H(e){let r=e?a(e):null,[s,n]=d(r??null),[i,t]=d(!!e&&r===void 0);return g(()=>{if(!e){n(null),t(!1);return}let l=!1,o=a(e);o!==void 0?(n(o),t(!1)):(t(!0),U(e).then(f=>{l||(n(f),t(!1))}));let c=b(()=>{if(l||!e)return;let f=a(e);f!==void 0&&n(f)});return()=>{l=!0,c()}},[e]),{profile:s,loading:i}}function W(e){let r=e.filter(o=>!!o).map(o=>o.toLowerCase()),s=r.slice().sort().join(","),[n,i]=d(()=>{let o=new Map;return r.forEach(c=>{let f=a(c);f!==void 0&&o.set(c,f)}),o}),[t,l]=d(r.length>0);return g(()=>{if(r.length===0){i(new Map),l(!1);return}let o=!1;function c(){let u=new Map,w=!1;r.forEach(C=>{let m=a(C);m===void 0?w=!0:u.set(C,m)}),i(u),l(w)}c(),Promise.all(r.filter(u=>a(u)===void 0).map(u=>U(u))).then(()=>{o||c()});let f=b(()=>{o||c()});return()=>{o=!0,f()}},[s]),{profiles:n,loading:t}}export{O as a,S as b,_ as c,z as d,H as e,W as f};
@@ -1 +1 @@
1
- import{i as t,j as i}from"./chunk-ETPZ3TXX.js";import{j as r,k as o}from"./chunk-KUCVLANF.js";o();i();var s=r(null);function n(){let e=t(s);if(!e)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return e}export{s as a,n as b};
1
+ import{i as t,j as i}from"./chunk-WRA24P66.js";import{j as r,k as o}from"./chunk-KUCVLANF.js";o();i();var s=r(null);function n(){let e=t(s);if(!e)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return e}export{s as a,n as b};
@@ -1 +1 @@
1
- import{e as n}from"./chunk-WS37MDM3.js";import{Ga as t}from"./chunk-ETPZ3TXX.js";function f(a){let{className:r,as:h,size:e,weight:o,color:i,children:g,...s}=a;return t(h||"h2",{...s,className:n(r,"heading",e&&`size:${e}`,o&&`weight:${o}`,i&&`color:${i}`),children:g})}export{f as a};
1
+ import{e as n}from"./chunk-WASID5UU.js";import{Ga as t}from"./chunk-WRA24P66.js";function f(a){let{className:r,as:h,size:e,weight:o,color:i,children:g,...s}=a;return t(h||"h2",{...s,className:n(r,"heading",e&&`size:${e}`,o&&`weight:${o}`,i&&`color:${i}`),children:g})}export{f as a};