libre-webui 0.34.1 → 0.34.2

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 (77) hide show
  1. package/backend/package.json +3 -3
  2. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  3. package/frontend/dist/artifact-runtime/framer-motion.js +3 -3
  4. package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
  5. package/frontend/dist/assets/{index-CxFIHoRc.css → index-C59a0tht.css} +1 -1
  6. package/frontend/dist/assets/index-Cyi10ekV.js +43 -0
  7. package/frontend/dist/assets/{markdown-math-Ddr6Z9Sf.css → markdown-math-B3MBJsZb.css} +1 -1
  8. package/frontend/dist/index.html +21 -21
  9. package/frontend/dist/js/{ArtifactContainer-Cdrv0kJM.js → ArtifactContainer-CQjqR9G1.js} +1 -1
  10. package/frontend/dist/js/{ArtifactDemoPage-BcXPfD-W.js → ArtifactDemoPage-DbbqglMU.js} +1 -1
  11. package/frontend/dist/js/{ArtifactSandboxFrame-5qM5QELi.js → ArtifactSandboxFrame-DI2b9BW5.js} +1 -1
  12. package/frontend/dist/js/{ArtifactSlideOutPanel-tuGsj_HW.js → ArtifactSlideOutPanel-B_UX92CK.js} +1 -1
  13. package/frontend/dist/js/{AutomationModal-DL9kNzgL.js → AutomationModal-CNiy1Dxm.js} +1 -1
  14. package/frontend/dist/js/{AutomationsPage-BMtR7wCN.js → AutomationsPage-CeAsldk_.js} +1 -1
  15. package/frontend/dist/js/{AvatarUpload-DrfSzzOZ.js → AvatarUpload-xCWQm3_w.js} +1 -1
  16. package/frontend/dist/js/CalendarPage-Cwk0X00z.js +1 -0
  17. package/frontend/dist/js/ChannelsPage-BG3n4ElV.js +1 -0
  18. package/frontend/dist/js/ChatPage-wSRfAOeh.js +14 -0
  19. package/frontend/dist/js/{ConnectModels-flyZgito.js → ConnectModels-D7ZTGihA.js} +1 -1
  20. package/frontend/dist/js/{EvaluationsPage-DUntWRVo.js → EvaluationsPage-C795TI_6.js} +2 -2
  21. package/frontend/dist/js/{FirstTimeSetup-CMQ000Hh.js → FirstTimeSetup-C4C5GLjW.js} +1 -1
  22. package/frontend/dist/js/{GalleryPage-DNSo3Q0p.js → GalleryPage-DVWl3LaC.js} +1 -1
  23. package/frontend/dist/js/{HomePage-BOXsuk3g.js → HomePage-BljB9ZMN.js} +1 -1
  24. package/frontend/dist/js/{LanguageSwitcher-BIrE0C-N.js → LanguageSwitcher-BuS3i6u5.js} +1 -1
  25. package/frontend/dist/js/{LibreClawPage-D97-90n6.js → LibreClawPage-OD6iZtiy.js} +1 -1
  26. package/frontend/dist/js/{ModelManagerModals-DzEVkCuT.js → ModelManagerModals-DdL3LeGl.js} +1 -1
  27. package/frontend/dist/js/NotesPage-rqL0zS8z.js +3 -0
  28. package/frontend/dist/js/{PasswordStrengthMeter-DLQ5jaO_.js → PasswordStrengthMeter-H0Os6XbX.js} +1 -1
  29. package/frontend/dist/js/{PersonasPage-D8-4PyoM.js → PersonasPage-Babix8IA.js} +1 -1
  30. package/frontend/dist/js/{PluginUsagePage-CHcweo11.js → PluginUsagePage-CudDkMxy.js} +1 -1
  31. package/frontend/dist/js/RichMessageContent-B-U0EcyW.js +1 -0
  32. package/frontend/dist/js/{RichMessageContent-yWLHf4YS.js → RichMessageContent-CcKn_kcQ.js} +2 -2
  33. package/frontend/dist/js/SettingsModal-CXU60RIf.js +19 -0
  34. package/frontend/dist/js/{ShareDialog-J5zbwIWY.js → ShareDialog-CnU4ptx7.js} +1 -1
  35. package/frontend/dist/js/{SystemPage-CEjZpR5I.js → SystemPage-BzpTjdQY.js} +1 -1
  36. package/frontend/dist/js/{UserManagementPage-DdpcN4-Q.js → UserManagementPage-BHEMaK5a.js} +1 -1
  37. package/frontend/dist/js/{UserManagementPanel-Dhwk4I0s.js → UserManagementPanel-pbtLqF8X.js} +1 -1
  38. package/frontend/dist/js/{WhatsNewModal-5lCndkFc.js → WhatsNewModal-TuDrBWKj.js} +1 -1
  39. package/frontend/dist/js/WorkPage-DCeqm0BN.js +7 -0
  40. package/frontend/dist/js/api-BIVGtaZy.js +1 -0
  41. package/frontend/dist/js/{api-DEOxp9DN.js → api-CgnEj5Jc.js} +1 -1
  42. package/frontend/dist/js/{appNavigation-DToyRu19.js → appNavigation-DySHcEGS.js} +1 -1
  43. package/frontend/dist/js/{appStore-Bsxed1km.js → appStore-DrTsJPfh.js} +2 -2
  44. package/frontend/dist/js/appVersion-CAidQlBP.js +1 -0
  45. package/frontend/dist/js/{authStore-8w9Idb5o.js → authStore-CieFdk4S.js} +3 -3
  46. package/frontend/dist/js/authStore-GaOHAAsM.js +1 -0
  47. package/frontend/dist/js/{chatStore-lyGhYu24.js → chatStore-BvZkd8Un.js} +3 -3
  48. package/frontend/dist/js/{composerStyles-DqJg-2vE.js → composerStyles-BjJm_BgC.js} +1 -1
  49. package/frontend/dist/js/{config-B5SBQwEe.js → config-D7WLbWrW.js} +1 -1
  50. package/frontend/dist/js/{evaluationsApi-BvkmhMgQ.js → evaluationsApi-Dn-WNzzH.js} +1 -1
  51. package/frontend/dist/js/{i18next-ChipS_AK.js → i18next-Dq_6N9uy.js} +1 -1
  52. package/frontend/dist/js/markdownMath-BW8RNkEl.js +1 -0
  53. package/frontend/dist/js/{messageCodeStyles-DchDafYE.js → messageCodeStyles-C0pbLr0L.js} +2 -2
  54. package/frontend/dist/js/router-vendor-Epc3_KZ_.js +1 -0
  55. package/frontend/dist/js/{teamEventStream-C0_UAzCG.js → teamEventStream-CI_GSbae.js} +1 -1
  56. package/frontend/dist/js/{ui-BQojEu4t.js → ui-CgokQU6I.js} +2 -2
  57. package/frontend/dist/js/ui-vendor-Dt9hfsGD.js +177 -0
  58. package/frontend/dist/js/{useChat-CDllZR7C.js → useChat-DIGuMg5j.js} +1 -1
  59. package/frontend/dist/js/{workApi-0L8fBGq1.js → workApi-C-WfyZSs.js} +2 -2
  60. package/frontend/dist/js/workApi-CApikuye.js +1 -0
  61. package/package.json +5 -1
  62. package/frontend/dist/assets/index-Bv773ECu.js +0 -17
  63. package/frontend/dist/js/CalendarPage-BBkLlXa5.js +0 -1
  64. package/frontend/dist/js/ChannelsPage-C2KWU3sZ.js +0 -1
  65. package/frontend/dist/js/ChatPage-CWsAjCPP.js +0 -14
  66. package/frontend/dist/js/NotesPage-VBGqE4aV.js +0 -3
  67. package/frontend/dist/js/RichMessageContent-D7wqrY68.js +0 -1
  68. package/frontend/dist/js/SettingsModal-CxVt1ObR.js +0 -19
  69. package/frontend/dist/js/WorkPage-c8xOdYyy.js +0 -7
  70. package/frontend/dist/js/api-CHEuZtwG.js +0 -1
  71. package/frontend/dist/js/appVersion-CgCvuf4s.js +0 -1
  72. package/frontend/dist/js/authStore-DwmcyHDN.js +0 -1
  73. package/frontend/dist/js/markdownMath-CoDj1i7z.js +0 -1
  74. package/frontend/dist/js/router-vendor-CMbYTGdh.js +0 -1
  75. package/frontend/dist/js/ui-vendor-BvD5yGW1.js +0 -177
  76. package/frontend/dist/js/workApi-BjDBLsFh.js +0 -1
  77. /package/frontend/dist/js/{markdown-math-Dg-WB9ui.js → markdown-math-gtdBxaM5.js} +0 -0
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-D0Ec-185.js";import{t as i}from"./useQuery-BKulzCS7.js";import{d as a}from"./router-vendor-CMbYTGdh.js";import{t as o}from"./logger-DnuT4jgB.js";import{t as s}from"./useTranslation-rdLmo6zV.js";import{t as c}from"./utils-CKWltgs8.js";import{h as l,s as u,t as d}from"./chatStore-lyGhYu24.js";import{Dn as f,G as p,Jn as m,Jt as h,Kt as g,M as _,Pn as v,Pt as y,S as b,Sn as x,Tn as S,Ut as C,Yn as ee,Z as w,c as T,et as te,n as E,nr as D,or as O,t as k,xr as A}from"./ui-vendor-BvD5yGW1.js";import{C as ne,g as re,t as ie,y as j}from"./api-DEOxp9DN.js";import{t as ae}from"./authStore-8w9Idb5o.js";var M=e(t(),1),oe=n(),N=r();function P(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function se({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:a,hfGgufFiles:o,loadingGguf:l,pullingModel:u,pullProgress:d,setHfTask:f,setHfSort:p,onToggleHfModel:h,onPullHfGguf:_,onCancelPull:v,onRefreshHfModels:b}){let{t:C}=s();return(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0 space-y-2`,children:(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsxs)(`select`,{value:e,onChange:e=>f(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`flex-1 px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,N.jsx)(`option`,{value:`text-generation`,children:C(`modelManager.huggingface.taskTextGeneration`)}),(0,N.jsx)(`option`,{value:`text-to-speech`,children:C(`modelManager.huggingface.taskTextToSpeech`)}),(0,N.jsx)(`option`,{value:`text-to-image`,children:C(`modelManager.huggingface.taskTextToImage`)}),(0,N.jsx)(`option`,{value:`automatic-speech-recognition`,children:C(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,N.jsxs)(`select`,{value:t,onChange:e=>p(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,N.jsx)(`option`,{value:`downloads`,children:C(`modelManager.huggingface.sortDownloads`)}),(0,N.jsx)(`option`,{value:`likes`,children:C(`modelManager.huggingface.sortLikes`)}),(0,N.jsx)(`option`,{value:`lastModified`,children:C(`modelManager.huggingface.sortRecent`)})]})]})}),(0,N.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,N.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:C(`modelSelector.pullRestricted`)}),r?(0,N.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,N.jsx)(y,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,N.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(k,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,N.jsx)(`p`,{className:`text-sm`,children:C(`modelManager.huggingface.noModelsFound`)})]}):(0,N.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=a===e.id,r=o[e.id]||[],i=l===e.id;return(0,N.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,N.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),h(e.id)},children:(0,N.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,N.jsx)(`div`,{className:`flex-shrink-0 rounded-lg bg-yellow-500/20 p-2 dark:bg-yellow-900/30`,children:(0,N.jsx)(k,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,N.jsx)(`span`,{className:`rounded bg-yellow-500/20 px-1.5 py-0.5 text-xs text-ink dark:bg-yellow-900/30`,children:`Gated`})]}),(0,N.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(S,{className:`h-3 w-3`}),P(e.downloads)]}),(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(g,{className:`h-3 w-3`}),P(e.likes)]}),e.pipeline_tag&&(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,N.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(x,{className:`h-4 w-4 text-gray-400`})}),(0,N.jsx)(m,{className:c(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,N.jsx)(`div`,{className:`px-3 pb-3 pt-1 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-200`,children:i?(0,N.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,N.jsx)(y,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,N.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:C(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,N.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:C(`modelManager.huggingface.noGgufAvailable`)}):(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:C(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=u===e.ollamaCommand;return(0,N.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300`,children:[(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:d?.percent===void 0?`...`:`${d.percent}%`}),(0,N.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),v()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,N.jsx)(E,{className:`h-4 w-4`})})]}):n?(0,N.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),_(e.ollamaCommand,e.filename)},disabled:!!u,className:c(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,N.jsx)(S,{className:`h-3 w-3 inline mr-1`}),C(`models.pull`)]}):(0,N.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:C(`modelSelector.adminOnlyPull`)})]},e.filename)}),u?.startsWith(`hf.co/`)&&u.includes(e.id)&&d?.percent!==void 0&&(0,N.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,N.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${d.percent}%`}})})]})})]},e.id)})})]}),(0,N.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,N.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,N.jsx)(x,{className:`h-3 w-3`}),C(`modelManager.huggingface.browseAllLink`)]}),(0,N.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),b()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(w,{className:c(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}function ce({filteredGroups:e,selectedModel:t,showImageGen:n,getModelValue:r,getModelIcon:i,getModelLabel:a,getModelSubLabel:o,onModelSelect:l,onOpenGallery:u}){let{t:d}=s();return(0,N.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400`,children:[e.length>0?e.map(e=>(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300 border-b border-gray-200 dark:border-dark-400 sticky top-0`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon,e.label,` (`,e.models.length,`)`]})}),e.models.map(e=>{let n=r(e);return(0,N.jsx)(`button`,{type:`button`,"data-testid":`model-selector-option`,"data-model-value":n,"aria-pressed":t===n,onClick:()=>l(n),className:c(`block w-full cursor-pointer border-b border-gray-100 px-3 py-3 text-start last:border-b-0 dark:border-dark-200`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`bg-white dark:bg-dark-100 transition-colors`,`focus-visible:relative focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/50`,t===n&&`bg-primary-50 dark:bg-primary-900/30`),children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i(e),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsx)(`div`,{dir:e.isPersona?`auto`:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:a(e)}),o(e)&&(0,N.jsx)(`div`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:o(e)})]}),t===n&&(0,N.jsx)(ee,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 flex-shrink-0`})]})},n)})]},e.type)):(0,N.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(f,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,N.jsx)(`p`,{className:`text-sm`,children:d(`models.noModelsFound`)})]}),n&&(0,N.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(te,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),d(`modelSelector.actions`)]})}),(0,N.jsx)(`div`,{onMouseDown:e=>{e.preventDefault(),u()},className:`px-3 py-3 cursor-pointer hover:bg-blue-50 dark:hover:bg-blue-900/20 bg-white dark:bg-dark-100`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(C,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,N.jsxs)(`div`,{className:`flex-1`,children:[(0,N.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:d(`gallery.generate`)}),(0,N.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:d(`gallery.generateDescription`)})]})]})})]})]})}function le({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:a,pullProgress:o,setLibraryCategory:l,isModelInstalled:u,onModelSelect:d,onPullModel:f,onCancelPull:p,onRefreshLibrary:m}){let{t:h}=s();return(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0`,children:(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,N.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:c(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,t===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,N.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,N.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:h(`modelSelector.pullRestricted`)}),r?(0,N.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,N.jsx)(y,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,N.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(v,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,N.jsx)(`p`,{className:`text-sm`,children:h(`models.noModelsFound`)})]}):(0,N.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=u(e.name),r=a===e.name;return(0,N.jsxs)(`div`,{className:c(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,N.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,N.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex-shrink-0`,children:(0,N.jsx)(v,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`,children:h(`modelSelector.installed`)}),(e.category===`cloud`||e.tags?.includes(`cloud`))&&(0,N.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400 flex items-center gap-1`,children:[(0,N.jsx)(v,{className:`h-3 w-3`}),`Cloud`]})]}),(0,N.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:e},e)),e.pulls&&(0,N.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,N.jsx)(S,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,N.jsx)(`div`,{className:`flex-shrink-0`,children:r?(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:o?.percent===void 0?`...`:`${o.percent}%`}),(0,N.jsx)(`button`,{onClick:p,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,N.jsx)(E,{className:`h-4 w-4`})})]}):t?(0,N.jsx)(`button`,{onClick:()=>d(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-900/50`,children:h(`modelSelector.use`)}):n?(0,N.jsxs)(`button`,{onClick:()=>f(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50`,children:[(0,N.jsx)(S,{className:`h-3 w-3 inline mr-1`}),h(`modelSelector.pull`)]}):(0,N.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:h(`modelSelector.adminOnlyPull`)})})]}),r&&o?.percent!==void 0&&(0,N.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,N.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${o.percent}%`}})})]},e.name)})})]}),(0,N.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,N.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,N.jsx)(x,{className:`h-3 w-3`}),h(`modelManager.huggingface.browseAllLink`)]}),(0,N.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),m()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(w,{className:c(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var ue=o(`components:model-selector`),F=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:o,disabled:f=!1,compact:g=!1,showImageGen:y=!1,onModelsRefresh:x,getModelValue:S,getModelLabel:C,getModelTitle:ee,triggerRef:w,triggerTestId:te,selectTestId:ie,ariaLabel:P})=>{let{t:F}=s(),[I,de]=(0,M.useState)(!1),[L,R]=(0,M.useState)(``),[z,B]=(0,M.useState)(`installed`),fe=(0,M.useRef)(null),V=(0,M.useRef)(null),H=(0,M.useRef)(null),U=(0,M.useRef)(null),pe=a(),{user:me,systemInfo:he}=ae(),W=me?.role===`admin`||he?.requiresAuth===!1,[G,ge]=(0,M.useState)(`all`),[_e,ve]=(0,M.useState)(``),[ye,be]=(0,M.useState)(`text-generation`),[xe,Se]=(0,M.useState)(`downloads`),[Ce,we]=(0,M.useState)(``),[Te,Ee]=(0,M.useState)(null),[De,Oe]=(0,M.useState)({}),[ke,Ae]=(0,M.useState)(null),[K,q]=(0,M.useState)(null),[je,J]=(0,M.useState)(null),[Me,Y]=(0,M.useState)(null),Ne=[`all`,`general`,`coding`,`reasoning`,`vision`,`embedding`,`cloud`],Pe=[{type:`legacy`,label:F(`modelSelector.providerNotRecorded`,`Provider not recorded`),icon:(0,N.jsx)(D,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isLegacySelection),color:`gray`},{type:`unavailable`,label:F(`modelSelector.unavailableSelections`,`Unavailable selections`),icon:(0,N.jsx)(E,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isUnavailable&&!e.isLegacySelection),color:`gray`},{type:`personas`,label:F(`modelSelector.personas`),icon:(0,N.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPersona&&!e.isUnavailable),color:`purple`},{type:`agents`,label:F(`modelSelector.agentModels`,`Agents`),icon:(0,N.jsx)(b,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isAgent&&!e.isUnavailable),color:`green`},{type:`ollama`,label:F(`modelSelector.ollamaModels`),icon:(0,N.jsx)(O,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>l(e)&&!e.name.includes(`embed`)),color:`green`},{type:`plugins`,label:F(`modelSelector.pluginModels`),icon:(0,N.jsx)(k,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPlugin&&!e.isUnavailable),color:`green`}].filter(e=>e.models.length>0).map(e=>({...e,models:e.models.filter(e=>e.name.toLowerCase().includes(L.toLowerCase())||e.personaName&&e.personaName.toLowerCase().includes(L.toLowerCase())||e.pluginName&&e.pluginName.toLowerCase().includes(L.toLowerCase()))})).filter(e=>e.models.length>0),X=e=>S?.(e)??e.name,Fe=d(e=>e.modelMetadata),Ie=d(e=>e.personas),Z=e.find(e=>X(e)===t),Le=e=>{if(!e.name.startsWith(`persona:`))return;let t=e.name.slice(8),n=t;try{n=decodeURIComponent(t)}catch{}let r=Ie[t]??Ie[n];if(r?.name)return r.name;if(e.personaName&&e.personaName!==t)return e.personaName},Re=e=>{if(!e.name.startsWith(`persona:`))return;let t=e.name.slice(8),n=t;try{n=decodeURIComponent(t)}catch{}return Ie[t]??Ie[n]};(0,M.useImperativeHandle)(w,()=>H.current);let Q=(0,M.useCallback)((e=!0)=>{de(!1),R(``),e&&window.requestAnimationFrame(()=>H.current?.focus())},[]),{data:ze=[],isLoading:Be,refetch:Ve}=i({queryKey:[`ollama-library-selector`,_e,G===`cloud`?`cloud`:`all`],queryFn:async()=>{let e=await j.getLibraryModels({search:_e||void 0,sort:`popular`,category:G===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:I&&z===`ollama`}),{data:He=[],isLoading:Ue,refetch:We}=i({queryKey:[`hf-models-selector`,ye,Ce,xe],queryFn:async()=>{let e=await ne.getModels({task:ye,search:Ce||void 0,sort:xe,limit:30});return e.success&&e.data?e.data:[]},enabled:I&&z===`huggingface`}),Ge=ze.filter(e=>{let t=!L||e.name.toLowerCase().includes(L.toLowerCase())||e.description.toLowerCase().includes(L.toLowerCase()),n=G===`all`||e.category===G;return t&&n}),Ke=(0,M.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){Ae(e);try{let r=await ne.getGgufFiles(t,n);r.success&&r.data&&Oe(t=>({...t,[e]:r.data}))}catch(e){ue.error(`Failed to load GGUF files:`,e)}finally{Ae(null)}}},[]),qe=(0,M.useCallback)(e=>{Te===e?Ee(null):(Ee(e),De[e]||Ke(e))},[Te,De,Ke]),Je=(0,M.useCallback)((e,t)=>{if(!W){A.error(F(`modelSelector.pullRestricted`));return}if(!K){q(e),J({status:`starting`});try{let n=j.pullModelStream(e,e=>{J(e)},()=>{J(null),q(null),Y(null),A.success(F(`modelDownload.success`,{name:t})),x?.()},e=>{J(null),q(null),Y(null),A.error(F(`modelDownload.failed`,{error:e}))});Y(()=>n)}catch{J(null),q(null),A.error(F(`modelDownload.startFailed`))}}},[W,x,K,F]);(0,M.useEffect)(()=>{let e=setTimeout(()=>{z===`huggingface`?we(L):z===`ollama`&&ve(L)},300);return()=>clearTimeout(e)},[L,z]),(0,M.useEffect)(()=>{if(!I)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),Q();return}if(e.key===`Tab`&&V.current){let t=Array.from(V.current.querySelectorAll(`button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1];if(!n||!r)return;e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Q,I]),(0,M.useEffect)(()=>{I&&U.current&&U.current.focus()},[I]);let Ye=async t=>{let r=e.find(e=>X(e)===t)??e.find(e=>!e.isPlugin&&!e.isPersona&&e.name===t),i=r?X(r):t,a=r?.name??t;Q();try{let e=await j.listRunningModels();if(e.success&&e.data){let t=e.data;t.length>0&&(r?.isPlugin!==!0&&t.some(e=>e.name===a||a.startsWith(`persona:`))||await j.unloadAllModels())}}catch(e){ue.warn(`Failed to unload models before switch:`,e)}n({target:{value:i}})},Xe=async e=>{if(!W){A.error(F(`modelSelector.pullRestricted`));return}if(!K){q(e),J({status:`starting`});try{let t=j.pullModelStream(e,e=>{J(e)},()=>{J(null),q(null),Y(null),A.success(F(`modelDownload.success`,{name:e})),x?.()},e=>{J(null),q(null),Y(null),A.error(F(`modelDownload.failed`,{error:e}))});Y(()=>t)}catch{J(null),q(null),A.error(F(`modelDownload.startFailed`))}}},Ze=()=>{Me&&(Me(),Y(null),q(null),J(null),A.success(F(`modelDownload.cancelled`)))},Qe=t=>e.some(e=>l(e)&&(e.name===t||e.name.startsWith(t+`:`))),$e=e=>{let t=Fe[u(e)]?.avatar;if(t&&!e.isPersona)return(0,N.jsx)(`img`,{src:t,alt:``,className:`h-4 w-4 shrink-0 rounded-full object-cover`});if(e.isPersona||e.isLegacySelection){let t=Re(e);if(t)return(0,N.jsx)(`img`,{src:re(t,64),alt:``,className:`h-4 w-4 shrink-0 rounded object-cover`})}return e.isLegacySelection?(0,N.jsx)(D,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPersona?(0,N.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPlugin?(0,N.jsx)(k,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):(0,N.jsx)(O,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`})},$=e=>{if(C)return C(e);let t=Fe[u(e)]?.label;return t&&!e.isPersona?t:e.isLegacySelection?`${Le(e)??e.name} (${F(`modelSelector.legacyProvider`,`provider not recorded`)})`:e.isPersona?Le(e)||e.personaName||e.name:e.isAgent?e.isUnavailable?`${e.agentName||e.name} (${F(`modelSelector.unavailable`,`unavailable`)})`:e.agentName||e.name:(e.isPlugin,e.isUnavailable?`${e.name} (${F(`modelSelector.unavailable`,`unavailable`)})`:e.name)},et=e=>e.isLegacySelection?e.isUnavailable?F(`modelSelector.providerUnavailable`,`provider unavailable`):F(`modelSelector.reselectProvider`,`reselect a provider to pin this model`):e.isPersona?`via ${e.model}`:e.isPlugin?e.isUnavailable?`via ${e.pluginName||e.pluginId} · ${F(`modelSelector.providerUnavailable`,`provider unavailable`)}`:`via ${e.pluginName}`:e.isUnavailable?F(`modelSelector.providerUnavailable`,`provider unavailable`):null;return(0,N.jsxs)(`div`,{className:c(`relative min-w-0`,o),ref:fe,children:[(0,N.jsxs)(`button`,{ref:H,"data-testid":te,type:`button`,onClick:()=>!f&&de(!I),disabled:f,"aria-haspopup":`dialog`,"aria-expanded":I,"aria-label":P&&Z?`${P}: ${$(Z)}`:P,className:c(g?`flex h-9 w-full min-w-0 items-center justify-between gap-2 px-2.5 text-start`:`w-full flex items-center justify-between gap-2 px-3 py-2.5 text-start`,`rounded-xl border border-line bg-surface-subtle text-sm text-ink hover:bg-hover-solid`,`transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500/40`,f?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:g?Z?ee?.(Z)??$(Z):F(`modelSelector.selectModel`):void 0,children:[(()=>{if(!Z)return g?(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,N.jsx)(O,{className:`h-4 w-4 shrink-0`}),(0,N.jsx)(`span`,{className:`truncate text-xs font-medium text-ink-subtle`,children:F(`modelSelector.selectModel`)})]}):F(`modelSelector.selectModel`);if(g){let e=$(Z);return(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`shrink-0`,children:$e(Z)}),(0,N.jsx)(`span`,{dir:Z.isPersona?`auto`:`ltr`,className:`truncate text-xs font-medium text-ink`,children:e})]})}let e=$(Z),t=et(Z);return(0,N.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[$e(Z),(0,N.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,N.jsx)(`span`,{dir:Z.isPersona?`auto`:`ltr`,className:`text-sm font-medium truncate`,children:e}),t&&(0,N.jsx)(`span`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),Z.isPersona&&r&&(0,N.jsxs)(`div`,{className:`flex items-center gap-1 ms-auto`,children:[(0,N.jsx)(D,{className:`h-3 w-3 text-gray-500 dark:text-dark-600`}),r.embedding_model&&(0,N.jsx)(_,{className:`h-3 w-3 text-gray-400 dark:text-dark-500`})]})]})})(),(0,N.jsx)(m,{className:c(g?`h-3 w-3`:`h-4 w-4`,`shrink-0 text-ink-subtle transition-transform duration-150 motion-reduce:transition-none`,I&&`rotate-180`)})]}),I&&(0,oe.createPortal)((0,N.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-3 sm:p-6`,children:[(0,N.jsx)(`div`,{className:`absolute inset-0 bg-gray-950/55 backdrop-blur-md`,onClick:()=>Q()}),(0,N.jsxs)(`div`,{ref:V,role:`dialog`,"aria-modal":`true`,"aria-label":F(`modelSelector.selectModel`),className:c(`relative flex w-full max-w-xl flex-col overflow-hidden bg-white/[0.98] dark:bg-dark-25/[0.98]`,`h-[min(620px,88vh)] rounded-[1.5rem] border border-black/[0.08] dark:border-white/[0.09]`,`shadow-[0_30px_100px_rgba(0,0,0,0.28)] backdrop-blur-xl animate-scale-in`),onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4 sm:px-5 sm:pt-5`,children:[(0,N.jsx)(`h2`,{className:`text-lg font-medium tracking-[-0.025em] text-gray-950 dark:text-dark-950 rtl:tracking-normal`,children:F(`modelSelector.selectModel`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>Q(),className:`flex h-9 w-9 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-950 dark:text-dark-500 dark:hover:bg-dark-200 dark:hover:text-dark-950`,title:F(`common.close`),children:(0,N.jsx)(E,{className:`h-4 w-4`})})]}),(0,N.jsx)(`div`,{className:`px-4 pb-3 sm:px-5`,children:(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsx)(p,{className:`absolute start-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,N.jsx)(`input`,{ref:U,type:`text`,placeholder:F(z===`installed`?`modelSelector.searchInstalled`:z===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:L,onChange:e=>R(e.target.value),className:c(`w-full rounded-xl border border-black/[0.07] bg-gray-100/70 py-2.5 ps-10 pe-4 text-sm dark:border-white/[0.07] dark:bg-dark-200/70`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`text-gray-900 dark:text-dark-900 placeholder:text-gray-400 dark:placeholder:text-dark-500`)})]})}),(0,N.jsxs)(`div`,{className:`mx-4 mb-3 flex rounded-xl bg-gray-100/70 p-1 dark:bg-dark-200/70 sm:mx-5`,children:[(0,N.jsxs)(`button`,{onClick:()=>{B(`installed`)},className:c(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,z===`installed`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":z===`installed`,children:[(0,N.jsx)(h,{className:`h-4 w-4 inline me-1.5`}),F(`modelSelector.installed`)]}),(0,N.jsxs)(`button`,{onClick:()=>{B(`ollama`)},className:c(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,z===`ollama`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":z===`ollama`,children:[(0,N.jsx)(v,{className:`h-4 w-4 inline me-1.5`}),`Ollama`]}),(0,N.jsxs)(`button`,{onClick:()=>{B(`huggingface`)},className:c(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,z===`huggingface`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":z===`huggingface`,children:[(0,N.jsx)(k,{className:`h-4 w-4 inline me-1.5`}),`HuggingFace`]})]})]}),z===`installed`&&(0,N.jsx)(ce,{filteredGroups:Pe,selectedModel:t,showImageGen:y,getModelValue:X,getModelIcon:$e,getModelLabel:$,getModelSubLabel:et,onModelSelect:Ye,onOpenGallery:()=>{Q(!1),pe(`/gallery`)}}),z===`ollama`&&(0,N.jsx)(le,{libraryCategories:Ne,libraryCategory:G,canInstallModels:W,loadingLibrary:Be,filteredLibraryModels:Ge,pullingModel:K,pullProgress:je,setLibraryCategory:ge,isModelInstalled:Qe,onModelSelect:Ye,onPullModel:Xe,onCancelPull:Ze,onRefreshLibrary:()=>{Ve()}}),z===`huggingface`&&(0,N.jsx)(se,{hfTask:ye,hfSort:xe,canInstallModels:W,loadingHf:Ue,hfModels:He,expandedHfModel:Te,hfGgufFiles:De,loadingGguf:ke,pullingModel:K,pullProgress:je,setHfTask:be,setHfSort:Se,onToggleHfModel:qe,onPullHfGguf:Je,onCancelPull:Ze,onRefreshHfModels:()=>{We()}})]})]}),document.body),(0,N.jsx)(`select`,{"data-testid":ie,"aria-label":P,"aria-hidden":`true`,dir:`ltr`,value:t,onChange:n,className:`hidden`,tabIndex:-1,children:e.map(e=>(0,N.jsx)(`option`,{value:X(e),children:$(e)},`${e.isLegacySelection?`legacy`:e.isPersona?`persona`:e.isPlugin?`plugin`:`ollama`}:${e.pluginId||``}:${X(e)}`))})]})},I=o(`hooks:dictation`),de=()=>{if(typeof window>`u`)return;let e=window;return e.SpeechRecognition||e.webkitSpeechRecognition},L=[{mimeType:`audio/webm;codecs=opus`,format:`webm`}],R=300,z=.25,B=e=>`${encodeURIComponent(e.plugin)}:${encodeURIComponent(e.model)}`;function fe(e){if(typeof MediaRecorder>`u`)return;let t=new Set((e.config?.formats||[]).map(e=>e.toLowerCase()));return L.find(e=>(t.size===0||t.has(e.format))&&(typeof MediaRecorder.isTypeSupported!=`function`||MediaRecorder.isTypeSupported(e.mimeType)))?.mimeType}function V({onStart:e,onText:t,ownerKey:n}){let{t:r,i18n:i}=s(),[a,o]=(0,M.useState)(`idle`),[c,l]=(0,M.useState)([]),u=(0,M.useRef)(null),d=(0,M.useRef)(null),f=(0,M.useRef)(null),p=(0,M.useRef)(null),m=(0,M.useRef)(null),h=(0,M.useRef)(0),g=(0,M.useRef)(`idle`),_=(0,M.useRef)(void 0),v=(0,M.useRef)(e),y=(0,M.useRef)(t);(0,M.useEffect)(()=>{v.current=e,y.current=t},[e,t]),(0,M.useEffect)(()=>{let e=!1;return ie.getModels().then(t=>{!e&&t.success&&t.data&&l(t.data)}).catch(()=>{e||l([])}),()=>{e=!0}},[]);let b=(0,M.useMemo)(()=>typeof window<`u`&&window.isSecureContext&&typeof navigator<`u`&&!!navigator.mediaDevices&&!!de(),[]),x=typeof window<`u`&&window.isSecureContext&&typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia,S=(0,M.useMemo)(()=>[...b?[{key:`browser`,kind:`browser`}]:[],...x?c.filter(e=>!!fe(e)).map(e=>({key:B(e),kind:`provider`,model:e})):[]],[b,x,c]),[C,ee]=(0,M.useState)(``),w=(0,M.useMemo)(()=>S.find(e=>e.key===C)??S[0],[C,S]),T=w?.kind===`provider`?w.model:void 0,te=S.length>0,E=(0,M.useCallback)(()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)},[]),D=(0,M.useCallback)(e=>{g.current=e,o(e)},[]),O=(0,M.useCallback)(()=>{h.current+=1,E(),u.current?.stop(),u.current=null,p.current?.abort(),p.current=null;let e=d.current;d.current=null,e&&(e.ondataavailable=null,e.onerror=null,e.onstop=null,e.state===`recording`&&e.stop()),f.current?.getTracks().forEach(e=>e.stop()),f.current=null,D(`idle`)},[E,D]);return(0,M.useEffect)(()=>(_.current=n,O),[O,n]),{supported:te,phase:a,toggle:(0,M.useCallback)(async()=>{let e=g.current;if(e===`starting`||e===`transcribing`){O();return}if(e===`recording`){d.current?.state===`recording`?(D(`transcribing`),d.current.stop()):O();return}if(T){let e=h.current+1;h.current=e;let t=_.current;v.current(),D(`starting`);try{let n=await navigator.mediaDevices.getUserMedia({audio:!0});if(h.current!==e||_.current!==t){n.getTracks().forEach(e=>e.stop());return}f.current=n;let a=fe(T),o=a?new MediaRecorder(n,{mimeType:a}):new MediaRecorder(n),s=[];o.ondataavailable=e=>{e.data.size>0&&s.push(e.data)},o.onerror=()=>{n.getTracks().forEach(e=>e.stop()),E(),h.current===e&&(d.current=null,f.current=null,D(`idle`),A.error(r(`voiceMode.transcriptionFailed`)))},o.onstop=()=>{if(n.getTracks().forEach(e=>e.stop()),E(),h.current!==e||_.current!==t)return;if(d.current=null,f.current=null,s.length===0){D(`idle`);return}let a=new Blob(s,{type:o.mimeType||s[0].type||`audio/webm`}),c=new AbortController;p.current=c,D(`transcribing`),ie.transcribe(a,T,{language:i.language,signal:c.signal,fallbackMessage:r(`voiceMode.transcriptionFailed`)}).then(n=>{h.current!==e||_.current!==t||c.signal.aborted||y.current(n.text.trim())}).catch(e=>{c.signal.aborted||(I.error(`Provider transcription failed:`,e),A.error(e instanceof Error?e.message:r(`voiceMode.transcriptionFailed`)))}).finally(()=>{p.current===c&&h.current===e&&(p.current=null,D(`idle`))})},d.current=o,o.start(250);let c=T.config?.max_duration_seconds,l=typeof c==`number`&&c>0?Math.min(c,R):R;m.current=window.setTimeout(()=>{h.current===e&&o.state===`recording`&&o.stop()},Math.max(.1,l-z)*1e3),D(`recording`);return}catch(t){if(h.current!==e)return;I.error(`Failed to start provider dictation:`,t),E(),f.current?.getTracks().forEach(e=>e.stop()),f.current=null,d.current=null,D(`idle`),A.error(r(`voiceMode.transcriptionFailed`));return}}let t=de();if(!t)return;let n=h.current+1;h.current=n;let a=_.current,o=new t;o.lang=i.language,o.continuous=!0,o.interimResults=!0,v.current(),o.onresult=e=>{if(h.current!==n||_.current!==a||u.current!==o)return;let t=``;for(let n=0;n<e.results.length;n++)t+=e.results[n][0]?.transcript??``;y.current(t.trim())},o.onend=()=>{h.current===n&&(u.current=null,D(`idle`))},o.onerror=()=>{h.current===n&&(u.current=null,D(`idle`))},u.current=o,D(`recording`);try{o.start()}catch(e){I.error(`Failed to start dictation:`,e),u.current=null,D(`idle`)}},[O,E,i.language,T,D,r]),cancel:O,sources:S,activeSourceKey:w?.key??``,setSourceKey:ee,providerModel:T}}var H=`relative rounded-[24px] border border-line bg-surface p-2.5 shadow-subtle transition-[border-color,box-shadow,background-color] duration-150 ease-out focus-within:border-primary-500/50 focus-within:ring-2 focus-within:ring-primary-500/10 dark:bg-surface-subtle dark:focus-within:border-primary-400/50 dark:focus-within:ring-primary-400/10 motion-reduce:transition-none`,U=`h-9 w-9 shrink-0 rounded-full border-transparent bg-ink p-0 text-ink-inverse shadow-none hover:bg-ink hover:text-ink-inverse hover:opacity-90 disabled:border-line disabled:bg-surface-subtle disabled:text-ink-subtle disabled:opacity-100 disabled:hover:bg-surface-subtle disabled:hover:text-ink-subtle disabled:hover:opacity-100 dark:disabled:bg-surface-raised dark:disabled:hover:bg-surface-raised focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40 focus-visible:ring-offset-2 focus-visible:ring-offset-surface dark:focus-visible:ring-primary-400/40 transition-[background-color,color,opacity,box-shadow] duration-150 ease-out motion-reduce:transition-none touch-manipulation`;export{F as i,H as n,V as r,U as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-D0Ec-185.js";import{t as i}from"./useQuery-BKulzCS7.js";import{d as a}from"./router-vendor-Epc3_KZ_.js";import{t as o}from"./logger-DnuT4jgB.js";import{t as s}from"./useTranslation-rdLmo6zV.js";import{t as c}from"./utils-CKWltgs8.js";import{h as l,s as u,t as d}from"./chatStore-BvZkd8Un.js";import{Dn as f,G as p,Jn as m,Jt as h,Kt as g,M as _,Pn as v,Pt as y,S as b,Sn as x,Tn as S,Ut as C,Yn as ee,Z as w,c as T,n as E,nr as D,or as O,t as k,tt as te,xr as A}from"./ui-vendor-Dt9hfsGD.js";import{C as ne,g as re,t as ie,y as j}from"./api-CgnEj5Jc.js";import{t as ae}from"./authStore-CieFdk4S.js";var M=e(t(),1),oe=n(),N=r();function P(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function se({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:a,hfGgufFiles:o,loadingGguf:l,pullingModel:u,pullProgress:d,setHfTask:f,setHfSort:p,onToggleHfModel:h,onPullHfGguf:_,onCancelPull:v,onRefreshHfModels:b}){let{t:C}=s();return(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0 space-y-2`,children:(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsxs)(`select`,{value:e,onChange:e=>f(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`flex-1 px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,N.jsx)(`option`,{value:`text-generation`,children:C(`modelManager.huggingface.taskTextGeneration`)}),(0,N.jsx)(`option`,{value:`text-to-speech`,children:C(`modelManager.huggingface.taskTextToSpeech`)}),(0,N.jsx)(`option`,{value:`text-to-image`,children:C(`modelManager.huggingface.taskTextToImage`)}),(0,N.jsx)(`option`,{value:`automatic-speech-recognition`,children:C(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,N.jsxs)(`select`,{value:t,onChange:e=>p(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,N.jsx)(`option`,{value:`downloads`,children:C(`modelManager.huggingface.sortDownloads`)}),(0,N.jsx)(`option`,{value:`likes`,children:C(`modelManager.huggingface.sortLikes`)}),(0,N.jsx)(`option`,{value:`lastModified`,children:C(`modelManager.huggingface.sortRecent`)})]})]})}),(0,N.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,N.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:C(`modelSelector.pullRestricted`)}),r?(0,N.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,N.jsx)(y,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,N.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(k,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,N.jsx)(`p`,{className:`text-sm`,children:C(`modelManager.huggingface.noModelsFound`)})]}):(0,N.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=a===e.id,r=o[e.id]||[],i=l===e.id;return(0,N.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,N.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),h(e.id)},children:(0,N.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,N.jsx)(`div`,{className:`flex-shrink-0 rounded-lg bg-yellow-500/20 p-2 dark:bg-yellow-900/30`,children:(0,N.jsx)(k,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,N.jsx)(`span`,{className:`rounded bg-yellow-500/20 px-1.5 py-0.5 text-xs text-ink dark:bg-yellow-900/30`,children:`Gated`})]}),(0,N.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(S,{className:`h-3 w-3`}),P(e.downloads)]}),(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(g,{className:`h-3 w-3`}),P(e.likes)]}),e.pipeline_tag&&(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,N.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(x,{className:`h-4 w-4 text-gray-400`})}),(0,N.jsx)(m,{className:c(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,N.jsx)(`div`,{className:`px-3 pb-3 pt-1 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-200`,children:i?(0,N.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,N.jsx)(y,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,N.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:C(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,N.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:C(`modelManager.huggingface.noGgufAvailable`)}):(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:C(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=u===e.ollamaCommand;return(0,N.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300`,children:[(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:d?.percent===void 0?`...`:`${d.percent}%`}),(0,N.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),v()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,N.jsx)(E,{className:`h-4 w-4`})})]}):n?(0,N.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),_(e.ollamaCommand,e.filename)},disabled:!!u,className:c(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,N.jsx)(S,{className:`h-3 w-3 inline mr-1`}),C(`models.pull`)]}):(0,N.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:C(`modelSelector.adminOnlyPull`)})]},e.filename)}),u?.startsWith(`hf.co/`)&&u.includes(e.id)&&d?.percent!==void 0&&(0,N.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,N.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${d.percent}%`}})})]})})]},e.id)})})]}),(0,N.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,N.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,N.jsx)(x,{className:`h-3 w-3`}),C(`modelManager.huggingface.browseAllLink`)]}),(0,N.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),b()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(w,{className:c(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}function ce({filteredGroups:e,selectedModel:t,showImageGen:n,getModelValue:r,getModelIcon:i,getModelLabel:a,getModelSubLabel:o,onModelSelect:l,onOpenGallery:u}){let{t:d}=s();return(0,N.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400`,children:[e.length>0?e.map(e=>(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300 border-b border-gray-200 dark:border-dark-400 sticky top-0`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon,e.label,` (`,e.models.length,`)`]})}),e.models.map(e=>{let n=r(e);return(0,N.jsx)(`button`,{type:`button`,"data-testid":`model-selector-option`,"data-model-value":n,"aria-pressed":t===n,onClick:()=>l(n),className:c(`block w-full cursor-pointer border-b border-gray-100 px-3 py-3 text-start last:border-b-0 dark:border-dark-200`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`bg-white dark:bg-dark-100 transition-colors`,`focus-visible:relative focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/50`,t===n&&`bg-primary-50 dark:bg-primary-900/30`),children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i(e),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsx)(`div`,{dir:e.isPersona?`auto`:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:a(e)}),o(e)&&(0,N.jsx)(`div`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:o(e)})]}),t===n&&(0,N.jsx)(ee,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 flex-shrink-0`})]})},n)})]},e.type)):(0,N.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(f,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,N.jsx)(`p`,{className:`text-sm`,children:d(`models.noModelsFound`)})]}),n&&(0,N.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(te,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),d(`modelSelector.actions`)]})}),(0,N.jsx)(`div`,{onMouseDown:e=>{e.preventDefault(),u()},className:`px-3 py-3 cursor-pointer hover:bg-blue-50 dark:hover:bg-blue-900/20 bg-white dark:bg-dark-100`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(C,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,N.jsxs)(`div`,{className:`flex-1`,children:[(0,N.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:d(`gallery.generate`)}),(0,N.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:d(`gallery.generateDescription`)})]})]})})]})]})}function le({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:a,pullProgress:o,setLibraryCategory:l,isModelInstalled:u,onModelSelect:d,onPullModel:f,onCancelPull:p,onRefreshLibrary:m}){let{t:h}=s();return(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0`,children:(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,N.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:c(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,t===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,N.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,N.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:h(`modelSelector.pullRestricted`)}),r?(0,N.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,N.jsx)(y,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,N.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(v,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,N.jsx)(`p`,{className:`text-sm`,children:h(`models.noModelsFound`)})]}):(0,N.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=u(e.name),r=a===e.name;return(0,N.jsxs)(`div`,{className:c(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,N.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,N.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex-shrink-0`,children:(0,N.jsx)(v,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`,children:h(`modelSelector.installed`)}),(e.category===`cloud`||e.tags?.includes(`cloud`))&&(0,N.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400 flex items-center gap-1`,children:[(0,N.jsx)(v,{className:`h-3 w-3`}),`Cloud`]})]}),(0,N.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:e},e)),e.pulls&&(0,N.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,N.jsx)(S,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,N.jsx)(`div`,{className:`flex-shrink-0`,children:r?(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:o?.percent===void 0?`...`:`${o.percent}%`}),(0,N.jsx)(`button`,{onClick:p,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,N.jsx)(E,{className:`h-4 w-4`})})]}):t?(0,N.jsx)(`button`,{onClick:()=>d(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-900/50`,children:h(`modelSelector.use`)}):n?(0,N.jsxs)(`button`,{onClick:()=>f(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50`,children:[(0,N.jsx)(S,{className:`h-3 w-3 inline mr-1`}),h(`modelSelector.pull`)]}):(0,N.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:h(`modelSelector.adminOnlyPull`)})})]}),r&&o?.percent!==void 0&&(0,N.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,N.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${o.percent}%`}})})]},e.name)})})]}),(0,N.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,N.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,N.jsx)(x,{className:`h-3 w-3`}),h(`modelManager.huggingface.browseAllLink`)]}),(0,N.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),m()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(w,{className:c(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var ue=o(`components:model-selector`),F=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:o,disabled:f=!1,compact:g=!1,showImageGen:y=!1,onModelsRefresh:x,getModelValue:S,getModelLabel:C,getModelTitle:ee,triggerRef:w,triggerTestId:te,selectTestId:ie,ariaLabel:P})=>{let{t:F}=s(),[I,de]=(0,M.useState)(!1),[L,R]=(0,M.useState)(``),[z,B]=(0,M.useState)(`installed`),fe=(0,M.useRef)(null),V=(0,M.useRef)(null),H=(0,M.useRef)(null),U=(0,M.useRef)(null),pe=a(),{user:me,systemInfo:he}=ae(),W=me?.role===`admin`||he?.requiresAuth===!1,[G,ge]=(0,M.useState)(`all`),[_e,ve]=(0,M.useState)(``),[ye,be]=(0,M.useState)(`text-generation`),[xe,Se]=(0,M.useState)(`downloads`),[Ce,we]=(0,M.useState)(``),[Te,Ee]=(0,M.useState)(null),[De,Oe]=(0,M.useState)({}),[ke,Ae]=(0,M.useState)(null),[K,q]=(0,M.useState)(null),[je,J]=(0,M.useState)(null),[Me,Y]=(0,M.useState)(null),Ne=[`all`,`general`,`coding`,`reasoning`,`vision`,`embedding`,`cloud`],Pe=[{type:`legacy`,label:F(`modelSelector.providerNotRecorded`,`Provider not recorded`),icon:(0,N.jsx)(D,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isLegacySelection),color:`gray`},{type:`unavailable`,label:F(`modelSelector.unavailableSelections`,`Unavailable selections`),icon:(0,N.jsx)(E,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isUnavailable&&!e.isLegacySelection),color:`gray`},{type:`personas`,label:F(`modelSelector.personas`),icon:(0,N.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPersona&&!e.isUnavailable),color:`purple`},{type:`agents`,label:F(`modelSelector.agentModels`,`Agents`),icon:(0,N.jsx)(b,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isAgent&&!e.isUnavailable),color:`green`},{type:`ollama`,label:F(`modelSelector.ollamaModels`),icon:(0,N.jsx)(O,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>l(e)&&!e.name.includes(`embed`)),color:`green`},{type:`plugins`,label:F(`modelSelector.pluginModels`),icon:(0,N.jsx)(k,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPlugin&&!e.isUnavailable),color:`green`}].filter(e=>e.models.length>0).map(e=>({...e,models:e.models.filter(e=>e.name.toLowerCase().includes(L.toLowerCase())||e.personaName&&e.personaName.toLowerCase().includes(L.toLowerCase())||e.pluginName&&e.pluginName.toLowerCase().includes(L.toLowerCase()))})).filter(e=>e.models.length>0),X=e=>S?.(e)??e.name,Fe=d(e=>e.modelMetadata),Ie=d(e=>e.personas),Z=e.find(e=>X(e)===t),Le=e=>{if(!e.name.startsWith(`persona:`))return;let t=e.name.slice(8),n=t;try{n=decodeURIComponent(t)}catch{}let r=Ie[t]??Ie[n];if(r?.name)return r.name;if(e.personaName&&e.personaName!==t)return e.personaName},Re=e=>{if(!e.name.startsWith(`persona:`))return;let t=e.name.slice(8),n=t;try{n=decodeURIComponent(t)}catch{}return Ie[t]??Ie[n]};(0,M.useImperativeHandle)(w,()=>H.current);let Q=(0,M.useCallback)((e=!0)=>{de(!1),R(``),e&&window.requestAnimationFrame(()=>H.current?.focus())},[]),{data:ze=[],isLoading:Be,refetch:Ve}=i({queryKey:[`ollama-library-selector`,_e,G===`cloud`?`cloud`:`all`],queryFn:async()=>{let e=await j.getLibraryModels({search:_e||void 0,sort:`popular`,category:G===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:I&&z===`ollama`}),{data:He=[],isLoading:Ue,refetch:We}=i({queryKey:[`hf-models-selector`,ye,Ce,xe],queryFn:async()=>{let e=await ne.getModels({task:ye,search:Ce||void 0,sort:xe,limit:30});return e.success&&e.data?e.data:[]},enabled:I&&z===`huggingface`}),Ge=ze.filter(e=>{let t=!L||e.name.toLowerCase().includes(L.toLowerCase())||e.description.toLowerCase().includes(L.toLowerCase()),n=G===`all`||e.category===G;return t&&n}),Ke=(0,M.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){Ae(e);try{let r=await ne.getGgufFiles(t,n);r.success&&r.data&&Oe(t=>({...t,[e]:r.data}))}catch(e){ue.error(`Failed to load GGUF files:`,e)}finally{Ae(null)}}},[]),qe=(0,M.useCallback)(e=>{Te===e?Ee(null):(Ee(e),De[e]||Ke(e))},[Te,De,Ke]),Je=(0,M.useCallback)((e,t)=>{if(!W){A.error(F(`modelSelector.pullRestricted`));return}if(!K){q(e),J({status:`starting`});try{let n=j.pullModelStream(e,e=>{J(e)},()=>{J(null),q(null),Y(null),A.success(F(`modelDownload.success`,{name:t})),x?.()},e=>{J(null),q(null),Y(null),A.error(F(`modelDownload.failed`,{error:e}))});Y(()=>n)}catch{J(null),q(null),A.error(F(`modelDownload.startFailed`))}}},[W,x,K,F]);(0,M.useEffect)(()=>{let e=setTimeout(()=>{z===`huggingface`?we(L):z===`ollama`&&ve(L)},300);return()=>clearTimeout(e)},[L,z]),(0,M.useEffect)(()=>{if(!I)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),Q();return}if(e.key===`Tab`&&V.current){let t=Array.from(V.current.querySelectorAll(`button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1];if(!n||!r)return;e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Q,I]),(0,M.useEffect)(()=>{I&&U.current&&U.current.focus()},[I]);let Ye=async t=>{let r=e.find(e=>X(e)===t)??e.find(e=>!e.isPlugin&&!e.isPersona&&e.name===t),i=r?X(r):t,a=r?.name??t;Q();try{let e=await j.listRunningModels();if(e.success&&e.data){let t=e.data;t.length>0&&(r?.isPlugin!==!0&&t.some(e=>e.name===a||a.startsWith(`persona:`))||await j.unloadAllModels())}}catch(e){ue.warn(`Failed to unload models before switch:`,e)}n({target:{value:i}})},Xe=async e=>{if(!W){A.error(F(`modelSelector.pullRestricted`));return}if(!K){q(e),J({status:`starting`});try{let t=j.pullModelStream(e,e=>{J(e)},()=>{J(null),q(null),Y(null),A.success(F(`modelDownload.success`,{name:e})),x?.()},e=>{J(null),q(null),Y(null),A.error(F(`modelDownload.failed`,{error:e}))});Y(()=>t)}catch{J(null),q(null),A.error(F(`modelDownload.startFailed`))}}},Ze=()=>{Me&&(Me(),Y(null),q(null),J(null),A.success(F(`modelDownload.cancelled`)))},Qe=t=>e.some(e=>l(e)&&(e.name===t||e.name.startsWith(t+`:`))),$e=e=>{let t=Fe[u(e)]?.avatar;if(t&&!e.isPersona)return(0,N.jsx)(`img`,{src:t,alt:``,className:`h-4 w-4 shrink-0 rounded-full object-cover`});if(e.isPersona||e.isLegacySelection){let t=Re(e);if(t)return(0,N.jsx)(`img`,{src:re(t,64),alt:``,className:`h-4 w-4 shrink-0 rounded object-cover`})}return e.isLegacySelection?(0,N.jsx)(D,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPersona?(0,N.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPlugin?(0,N.jsx)(k,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):(0,N.jsx)(O,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`})},$=e=>{if(C)return C(e);let t=Fe[u(e)]?.label;return t&&!e.isPersona?t:e.isLegacySelection?`${Le(e)??e.name} (${F(`modelSelector.legacyProvider`,`provider not recorded`)})`:e.isPersona?Le(e)||e.personaName||e.name:e.isAgent?e.isUnavailable?`${e.agentName||e.name} (${F(`modelSelector.unavailable`,`unavailable`)})`:e.agentName||e.name:(e.isPlugin,e.isUnavailable?`${e.name} (${F(`modelSelector.unavailable`,`unavailable`)})`:e.name)},et=e=>e.isLegacySelection?e.isUnavailable?F(`modelSelector.providerUnavailable`,`provider unavailable`):F(`modelSelector.reselectProvider`,`reselect a provider to pin this model`):e.isPersona?`via ${e.model}`:e.isPlugin?e.isUnavailable?`via ${e.pluginName||e.pluginId} · ${F(`modelSelector.providerUnavailable`,`provider unavailable`)}`:`via ${e.pluginName}`:e.isUnavailable?F(`modelSelector.providerUnavailable`,`provider unavailable`):null;return(0,N.jsxs)(`div`,{className:c(`relative min-w-0`,o),ref:fe,children:[(0,N.jsxs)(`button`,{ref:H,"data-testid":te,type:`button`,onClick:()=>!f&&de(!I),disabled:f,"aria-haspopup":`dialog`,"aria-expanded":I,"aria-label":P&&Z?`${P}: ${$(Z)}`:P,className:c(g?`flex h-9 w-full min-w-0 items-center justify-between gap-2 px-2.5 text-start`:`w-full flex items-center justify-between gap-2 px-3 py-2.5 text-start`,`rounded-xl border border-line bg-surface-subtle text-sm text-ink hover:bg-hover-solid`,`transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500/40`,f?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:g?Z?ee?.(Z)??$(Z):F(`modelSelector.selectModel`):void 0,children:[(()=>{if(!Z)return g?(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,N.jsx)(O,{className:`h-4 w-4 shrink-0`}),(0,N.jsx)(`span`,{className:`truncate text-xs font-medium text-ink-subtle`,children:F(`modelSelector.selectModel`)})]}):F(`modelSelector.selectModel`);if(g){let e=$(Z);return(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`shrink-0`,children:$e(Z)}),(0,N.jsx)(`span`,{dir:Z.isPersona?`auto`:`ltr`,className:`truncate text-xs font-medium text-ink`,children:e})]})}let e=$(Z),t=et(Z);return(0,N.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[$e(Z),(0,N.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,N.jsx)(`span`,{dir:Z.isPersona?`auto`:`ltr`,className:`text-sm font-medium truncate`,children:e}),t&&(0,N.jsx)(`span`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),Z.isPersona&&r&&(0,N.jsxs)(`div`,{className:`flex items-center gap-1 ms-auto`,children:[(0,N.jsx)(D,{className:`h-3 w-3 text-gray-500 dark:text-dark-600`}),r.embedding_model&&(0,N.jsx)(_,{className:`h-3 w-3 text-gray-400 dark:text-dark-500`})]})]})})(),(0,N.jsx)(m,{className:c(g?`h-3 w-3`:`h-4 w-4`,`shrink-0 text-ink-subtle transition-transform duration-150 motion-reduce:transition-none`,I&&`rotate-180`)})]}),I&&(0,oe.createPortal)((0,N.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-3 sm:p-6`,children:[(0,N.jsx)(`div`,{className:`absolute inset-0 bg-gray-950/55 backdrop-blur-md`,onClick:()=>Q()}),(0,N.jsxs)(`div`,{ref:V,role:`dialog`,"aria-modal":`true`,"aria-label":F(`modelSelector.selectModel`),className:c(`relative flex w-full max-w-xl flex-col overflow-hidden bg-white/[0.98] dark:bg-dark-25/[0.98]`,`h-[min(620px,88vh)] rounded-[1.5rem] border border-black/[0.08] dark:border-white/[0.09]`,`shadow-[0_30px_100px_rgba(0,0,0,0.28)] backdrop-blur-xl animate-scale-in`),onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4 sm:px-5 sm:pt-5`,children:[(0,N.jsx)(`h2`,{className:`text-lg font-medium tracking-[-0.025em] text-gray-950 dark:text-dark-950 rtl:tracking-normal`,children:F(`modelSelector.selectModel`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>Q(),className:`flex h-9 w-9 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-950 dark:text-dark-500 dark:hover:bg-dark-200 dark:hover:text-dark-950`,title:F(`common.close`),children:(0,N.jsx)(E,{className:`h-4 w-4`})})]}),(0,N.jsx)(`div`,{className:`px-4 pb-3 sm:px-5`,children:(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsx)(p,{className:`absolute start-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,N.jsx)(`input`,{ref:U,type:`text`,placeholder:F(z===`installed`?`modelSelector.searchInstalled`:z===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:L,onChange:e=>R(e.target.value),className:c(`w-full rounded-xl border border-black/[0.07] bg-gray-100/70 py-2.5 ps-10 pe-4 text-sm dark:border-white/[0.07] dark:bg-dark-200/70`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`text-gray-900 dark:text-dark-900 placeholder:text-gray-400 dark:placeholder:text-dark-500`)})]})}),(0,N.jsxs)(`div`,{className:`mx-4 mb-3 flex rounded-xl bg-gray-100/70 p-1 dark:bg-dark-200/70 sm:mx-5`,children:[(0,N.jsxs)(`button`,{onClick:()=>{B(`installed`)},className:c(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,z===`installed`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":z===`installed`,children:[(0,N.jsx)(h,{className:`h-4 w-4 inline me-1.5`}),F(`modelSelector.installed`)]}),(0,N.jsxs)(`button`,{onClick:()=>{B(`ollama`)},className:c(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,z===`ollama`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":z===`ollama`,children:[(0,N.jsx)(v,{className:`h-4 w-4 inline me-1.5`}),`Ollama`]}),(0,N.jsxs)(`button`,{onClick:()=>{B(`huggingface`)},className:c(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,z===`huggingface`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":z===`huggingface`,children:[(0,N.jsx)(k,{className:`h-4 w-4 inline me-1.5`}),`HuggingFace`]})]})]}),z===`installed`&&(0,N.jsx)(ce,{filteredGroups:Pe,selectedModel:t,showImageGen:y,getModelValue:X,getModelIcon:$e,getModelLabel:$,getModelSubLabel:et,onModelSelect:Ye,onOpenGallery:()=>{Q(!1),pe(`/gallery`)}}),z===`ollama`&&(0,N.jsx)(le,{libraryCategories:Ne,libraryCategory:G,canInstallModels:W,loadingLibrary:Be,filteredLibraryModels:Ge,pullingModel:K,pullProgress:je,setLibraryCategory:ge,isModelInstalled:Qe,onModelSelect:Ye,onPullModel:Xe,onCancelPull:Ze,onRefreshLibrary:()=>{Ve()}}),z===`huggingface`&&(0,N.jsx)(se,{hfTask:ye,hfSort:xe,canInstallModels:W,loadingHf:Ue,hfModels:He,expandedHfModel:Te,hfGgufFiles:De,loadingGguf:ke,pullingModel:K,pullProgress:je,setHfTask:be,setHfSort:Se,onToggleHfModel:qe,onPullHfGguf:Je,onCancelPull:Ze,onRefreshHfModels:()=>{We()}})]})]}),document.body),(0,N.jsx)(`select`,{"data-testid":ie,"aria-label":P,"aria-hidden":`true`,dir:`ltr`,value:t,onChange:n,className:`hidden`,tabIndex:-1,children:e.map(e=>(0,N.jsx)(`option`,{value:X(e),children:$(e)},`${e.isLegacySelection?`legacy`:e.isPersona?`persona`:e.isPlugin?`plugin`:`ollama`}:${e.pluginId||``}:${X(e)}`))})]})},I=o(`hooks:dictation`),de=()=>{if(typeof window>`u`)return;let e=window;return e.SpeechRecognition||e.webkitSpeechRecognition},L=[{mimeType:`audio/webm;codecs=opus`,format:`webm`}],R=300,z=.25,B=e=>`${encodeURIComponent(e.plugin)}:${encodeURIComponent(e.model)}`;function fe(e){if(typeof MediaRecorder>`u`)return;let t=new Set((e.config?.formats||[]).map(e=>e.toLowerCase()));return L.find(e=>(t.size===0||t.has(e.format))&&(typeof MediaRecorder.isTypeSupported!=`function`||MediaRecorder.isTypeSupported(e.mimeType)))?.mimeType}function V({onStart:e,onText:t,ownerKey:n}){let{t:r,i18n:i}=s(),[a,o]=(0,M.useState)(`idle`),[c,l]=(0,M.useState)([]),u=(0,M.useRef)(null),d=(0,M.useRef)(null),f=(0,M.useRef)(null),p=(0,M.useRef)(null),m=(0,M.useRef)(null),h=(0,M.useRef)(0),g=(0,M.useRef)(`idle`),_=(0,M.useRef)(void 0),v=(0,M.useRef)(e),y=(0,M.useRef)(t);(0,M.useEffect)(()=>{v.current=e,y.current=t},[e,t]),(0,M.useEffect)(()=>{let e=!1;return ie.getModels().then(t=>{!e&&t.success&&t.data&&l(t.data)}).catch(()=>{e||l([])}),()=>{e=!0}},[]);let b=(0,M.useMemo)(()=>typeof window<`u`&&window.isSecureContext&&typeof navigator<`u`&&!!navigator.mediaDevices&&!!de(),[]),x=typeof window<`u`&&window.isSecureContext&&typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia,S=(0,M.useMemo)(()=>[...b?[{key:`browser`,kind:`browser`}]:[],...x?c.filter(e=>!!fe(e)).map(e=>({key:B(e),kind:`provider`,model:e})):[]],[b,x,c]),[C,ee]=(0,M.useState)(``),w=(0,M.useMemo)(()=>S.find(e=>e.key===C)??S[0],[C,S]),T=w?.kind===`provider`?w.model:void 0,E=S.length>0,D=(0,M.useCallback)(()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)},[]),O=(0,M.useCallback)(e=>{g.current=e,o(e)},[]),k=(0,M.useCallback)(()=>{h.current+=1,D(),u.current?.stop(),u.current=null,p.current?.abort(),p.current=null;let e=d.current;d.current=null,e&&(e.ondataavailable=null,e.onerror=null,e.onstop=null,e.state===`recording`&&e.stop()),f.current?.getTracks().forEach(e=>e.stop()),f.current=null,O(`idle`)},[D,O]);return(0,M.useEffect)(()=>(_.current=n,k),[k,n]),{supported:E,phase:a,toggle:(0,M.useCallback)(async()=>{let e=g.current;if(e===`starting`||e===`transcribing`){k();return}if(e===`recording`){d.current?.state===`recording`?(O(`transcribing`),d.current.stop()):k();return}if(T){let e=h.current+1;h.current=e;let t=_.current;v.current(),O(`starting`);try{let n=await navigator.mediaDevices.getUserMedia({audio:!0});if(h.current!==e||_.current!==t){n.getTracks().forEach(e=>e.stop());return}f.current=n;let a=fe(T),o=a?new MediaRecorder(n,{mimeType:a}):new MediaRecorder(n),s=[];o.ondataavailable=e=>{e.data.size>0&&s.push(e.data)},o.onerror=()=>{n.getTracks().forEach(e=>e.stop()),D(),h.current===e&&(d.current=null,f.current=null,O(`idle`),A.error(r(`voiceMode.transcriptionFailed`)))},o.onstop=()=>{if(n.getTracks().forEach(e=>e.stop()),D(),h.current!==e||_.current!==t)return;if(d.current=null,f.current=null,s.length===0){O(`idle`);return}let a=new Blob(s,{type:o.mimeType||s[0].type||`audio/webm`}),c=new AbortController;p.current=c,O(`transcribing`),ie.transcribe(a,T,{language:i.language,signal:c.signal,fallbackMessage:r(`voiceMode.transcriptionFailed`)}).then(n=>{h.current!==e||_.current!==t||c.signal.aborted||y.current(n.text.trim())}).catch(e=>{c.signal.aborted||(I.error(`Provider transcription failed:`,e),A.error(e instanceof Error?e.message:r(`voiceMode.transcriptionFailed`)))}).finally(()=>{p.current===c&&h.current===e&&(p.current=null,O(`idle`))})},d.current=o,o.start(250);let c=T.config?.max_duration_seconds,l=typeof c==`number`&&c>0?Math.min(c,R):R;m.current=window.setTimeout(()=>{h.current===e&&o.state===`recording`&&o.stop()},Math.max(.1,l-z)*1e3),O(`recording`);return}catch(t){if(h.current!==e)return;I.error(`Failed to start provider dictation:`,t),D(),f.current?.getTracks().forEach(e=>e.stop()),f.current=null,d.current=null,O(`idle`),A.error(r(`voiceMode.transcriptionFailed`));return}}let t=de();if(!t)return;let n=h.current+1;h.current=n;let a=_.current,o=new t;o.lang=i.language,o.continuous=!0,o.interimResults=!0,v.current(),o.onresult=e=>{if(h.current!==n||_.current!==a||u.current!==o)return;let t=``;for(let n=0;n<e.results.length;n++)t+=e.results[n][0]?.transcript??``;y.current(t.trim())},o.onend=()=>{h.current===n&&(u.current=null,O(`idle`))},o.onerror=()=>{h.current===n&&(u.current=null,O(`idle`))},u.current=o,O(`recording`);try{o.start()}catch(e){I.error(`Failed to start dictation:`,e),u.current=null,O(`idle`)}},[k,D,i.language,T,O,r]),cancel:k,sources:S,activeSourceKey:w?.key??``,setSourceKey:ee,providerModel:T}}var H=`relative rounded-[24px] border border-line bg-surface p-2.5 shadow-subtle transition-[border-color,box-shadow,background-color] duration-150 ease-out focus-within:border-primary-500/50 focus-within:ring-2 focus-within:ring-primary-500/10 dark:bg-surface-subtle dark:focus-within:border-primary-400/50 dark:focus-within:ring-primary-400/10 motion-reduce:transition-none`,U=`h-9 w-9 shrink-0 rounded-full border-transparent bg-ink p-0 text-ink-inverse shadow-none hover:bg-ink hover:text-ink-inverse hover:opacity-90 disabled:border-line disabled:bg-surface-subtle disabled:text-ink-subtle disabled:opacity-100 disabled:hover:bg-surface-subtle disabled:hover:text-ink-subtle disabled:hover:opacity-100 dark:disabled:bg-surface-raised dark:disabled:hover:bg-surface-raised focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40 focus-visible:ring-offset-2 focus-visible:ring-offset-surface dark:focus-visible:ring-primary-400/40 transition-[background-color,color,opacity,box-shadow] duration-150 ease-out motion-reduce:transition-none touch-manipulation`;export{F as i,H as n,V as r,U as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./logger-DnuT4jgB.js";var n=t(`config`);function r(e){return e.apiBaseUrl?.trim()?e.apiBaseUrl.trim():e.protocol===`file:`?`http://localhost:3001/api`:`${e.origin}/api`}var i=r({protocol:window.location.protocol,origin:window.location.origin,apiBaseUrl:void 0}),a=e(),o=()=>{a&&(n.debug(`API_BASE_URL configured as:`,i),n.debug(`Window location:`,window.location),n.debug(`Environment variables:`,{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.34.1`}))};export{o as n,i as t};
1
+ import{n as e,t}from"./logger-DnuT4jgB.js";var n=t(`config`);function r(e){return e.apiBaseUrl?.trim()?e.apiBaseUrl.trim():e.protocol===`file:`?`http://localhost:3001/api`:`${e.origin}/api`}var i=r({protocol:window.location.protocol,origin:window.location.origin,apiBaseUrl:void 0}),a=e(),o=()=>{a&&(n.debug(`API_BASE_URL configured as:`,i),n.debug(`Window location:`,window.location),n.debug(`Environment variables:`,{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.34.2`}))};export{o as n,i as t};
@@ -1 +1 @@
1
- import{a as e}from"./logger-DnuT4jgB.js";import{n as t,r as n}from"./workApi-0L8fBGq1.js";var r={upsertFeedback:r=>e()?Promise.resolve(n(void 0)):t.post(`/evaluations/feedback`,r).then(e=>e.data),deleteFeedback:e=>t.delete(`/evaluations/feedback/${encodeURIComponent(e)}`).then(()=>void 0),listFeedback:(e=!1)=>t.get(e?`/evaluations/feedback/all`:`/evaluations/feedback`).then(e=>e.data),runArenaMatch:e=>t.post(`/evaluations/arena/matches`,e).then(e=>e.data),voteArena:e=>t.post(`/evaluations/arena/votes`,e).then(e=>e.data),leaderboard:()=>t.get(`/evaluations/arena/leaderboard`).then(e=>e.data),listSets:()=>t.get(`/evaluations/sets`).then(e=>e.data),saveSet:e=>(e.id?t.put(`/evaluations/sets/${encodeURIComponent(e.id)}`,e):t.post(`/evaluations/sets`,e)).then(e=>e.data),deleteSet:e=>t.delete(`/evaluations/sets/${encodeURIComponent(e)}`).then(()=>void 0),listRuns:e=>t.get(`/evaluations/runs`,{params:e?{setId:e}:{}}).then(e=>e.data),startRun:e=>t.post(`/evaluations/runs`,e).then(e=>e.data),getRun:e=>t.get(`/evaluations/runs/${encodeURIComponent(e)}`).then(e=>e.data),cancelRun:e=>t.post(`/evaluations/runs/${encodeURIComponent(e)}/cancel`).then(()=>void 0),exportRun:e=>t.get(`/evaluations/runs/${encodeURIComponent(e)}/export`,{responseType:`blob`}).then(e=>e.data)};export{r as t};
1
+ import{a as e}from"./logger-DnuT4jgB.js";import{n as t,r as n}from"./workApi-C-WfyZSs.js";var r={upsertFeedback:r=>e()?Promise.resolve(n(void 0)):t.post(`/evaluations/feedback`,r).then(e=>e.data),deleteFeedback:e=>t.delete(`/evaluations/feedback/${encodeURIComponent(e)}`).then(()=>void 0),listFeedback:(e=!1)=>t.get(e?`/evaluations/feedback/all`:`/evaluations/feedback`).then(e=>e.data),runArenaMatch:e=>t.post(`/evaluations/arena/matches`,e).then(e=>e.data),voteArena:e=>t.post(`/evaluations/arena/votes`,e).then(e=>e.data),leaderboard:()=>t.get(`/evaluations/arena/leaderboard`).then(e=>e.data),listSets:()=>t.get(`/evaluations/sets`).then(e=>e.data),saveSet:e=>(e.id?t.put(`/evaluations/sets/${encodeURIComponent(e.id)}`,e):t.post(`/evaluations/sets`,e)).then(e=>e.data),deleteSet:e=>t.delete(`/evaluations/sets/${encodeURIComponent(e)}`).then(()=>void 0),listRuns:e=>t.get(`/evaluations/runs`,{params:e?{setId:e}:{}}).then(e=>e.data),startRun:e=>t.post(`/evaluations/runs`,e).then(e=>e.data),getRun:e=>t.get(`/evaluations/runs/${encodeURIComponent(e)}`).then(e=>e.data),cancelRun:e=>t.post(`/evaluations/runs/${encodeURIComponent(e)}/cancel`).then(()=>void 0),exportRun:e=>t.get(`/evaluations/runs/${encodeURIComponent(e)}/export`,{responseType:`blob`}).then(e=>e.data)};export{r as t};
@@ -1 +1 @@
1
- var e=e=>typeof e==`string`,t=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},n=e=>e==null?``:String(e),r=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},i=/###/g,a=e=>e&&e.includes(`###`)?e.replace(i,`.`):e,o=t=>!t||e(t),s=(t,n,r)=>{let i=e(n)?n.split(`.`):n,s=0;for(;s<i.length-1;){if(o(t))return{};let e=a(i[s]);!t[e]&&r&&(t[e]=new r),t=Object.prototype.hasOwnProperty.call(t,e)?t[e]:{},++s}return o(t)?{}:{obj:t,k:a(i[s])}},c=(e,t,n)=>{let{obj:r,k:i}=s(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),c=s(e,o,Object);for(;c.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),c=s(e,o,Object),c?.obj&&c.obj[`${c.k}.${a}`]!==void 0&&(c.obj=void 0);c.obj[`${c.k}.${a}`]=n},l=(e,t,n,r)=>{let{obj:i,k:a}=s(e,t,Object);i[a]=i[a]||[],i[a].push(n)},u=(e,t)=>{let{obj:n,k:r}=s(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},d=(e,t,n)=>{let r=u(e,n);return r===void 0?u(t,n):r},f=(t,n,r)=>{for(let i in n)i!==`__proto__`&&i!==`constructor`&&(Object.prototype.hasOwnProperty.call(t,i)?e(t[i])||t[i]instanceof String||e(n[i])||n[i]instanceof String?r&&(t[i]=n[i]):f(t[i],n[i],r):t[i]=n[i]);return t},p=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),m={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`,"/":`&#x2F;`},h=t=>e(t)?t.replace(/[&<>"'\/]/g,e=>m[e]):t,g=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},_=[` `,`,`,`?`,`!`,`;`],v=new g(20),y=(e,t,n)=>{t||=``,n||=``;let r=_.filter(e=>!t.includes(e)&&!n.includes(e));if(r.length===0)return!0;let i=v.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},b=(e,t,n=`.`)=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].includes(typeof t)&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},x=e=>e?.replace(/_/g,`-`),S={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},C=new class t{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||`i18next:`,this.logger=e||S,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,`log`,``,!0)}warn(...e){return this.forward(e,`warn`,``,!0)}error(...e){return this.forward(e,`error`,``)}deprecate(...e){return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(t,n,r,i){return i&&!this.debug?null:(t=t.map(t=>e(t)?t.replace(/[\r\n\x00-\x1F\x7F]/g,` `):t),e(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(e){return new t(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e||=this.options,e.prefix=e.prefix||this.prefix,new t(this.logger,e)}},w=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(([n,r])=>{for(let i=0;i<r;i++)n(e,...t)})}},T=class extends w{constructor(e,t={ns:[`translation`],defaultNS:`translation`}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(t,n,r,i={}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=i.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:i.ignoreJSONStructure,s;t.includes(`.`)?s=t.split(`.`):(s=[t,n],r&&(Array.isArray(r)?s.push(...r):e(r)&&a?s.push(...r.split(a)):s.push(r)));let c=u(this.data,s);return!c&&!n&&!r&&t.includes(`.`)&&(t=s[0],n=s[1],r=s.slice(2).join(`.`)),c||!o||!e(r)?c:b(this.data?.[t]?.[n],r,a)}addResource(e,t,n,r,i={silent:!1}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.includes(`.`)&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),c(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(t,n,r,i={silent:!1}){for(let i in r)(e(r[i])||Array.isArray(r[i]))&&this.addResource(t,n,i,r[i],{silent:!0});i.silent||this.emit(`added`,t,n,r)}addResourceBundle(e,t,n,r,i,a={silent:!1,skipCopy:!1}){let o=[e,t];e.includes(`.`)&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=u(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?f(s,n,i):s={...s,...n},c(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}},E={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},D=Symbol(`i18next/PATH_KEY`);function O(){let e=[],t=Object.create(null),n;return t.get=(r,i)=>(n?.revoke?.(),i===D?e:(e.push(i),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function k(e,t){let{[D]:n}=e(O()),r=t?.keySeparator??`.`,i=t?.nsSeparator??`:`,a=t?.enableSelector===`strict`;if(n.length>1&&i){let e=t?.ns,o=a?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(o&&(a?o:o.length>1?o.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}var A=t=>!e(t)&&typeof t!=`boolean`&&typeof t!=`number`,j=class t extends w{constructor(e,t={}){super(),r([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=C.create(`translator`),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(e==null)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let i=A(r.res);return!(n.returnObjects===!1&&i)}extractFromKey(t,n){let r=n.nsSeparator===void 0?this.options.nsSeparator:n.nsSeparator;r===void 0&&(r=`:`);let i=n.keySeparator===void 0?this.options.keySeparator:n.keySeparator,a=n.ns||this.options.defaultNS||[],o=r&&t.includes(r),s=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!y(t,r,i);if(o&&!s){let n=t.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:t,namespaces:e(a)?[a]:a};let o=t.split(r);(r!==i||r===i&&this.options.ns.includes(o[0]))&&(a=o.shift()),t=o.join(i)}return{key:t,namespaces:e(a)?[a]:a}}translate(n,r,i){let a=typeof r==`object`?{...r}:r;if(typeof a!=`object`&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a==`object`&&(a={...a}),a||={},n==null)return``;typeof n==`function`&&(n=k(n,{...this.options,...a})),Array.isArray(n)||(n=[String(n)]),n=n.map(e=>typeof e==`function`?k(e,{...this.options,...a}):String(e));let o=a.returnDetails===void 0?this.options.returnDetails:a.returnDetails,s=a.keySeparator===void 0?this.options.keySeparator:a.keySeparator,{key:c,namespaces:l}=this.extractFromKey(n[n.length-1],a),u=l[l.length-1],d=a.nsSeparator===void 0?this.options.nsSeparator:a.nsSeparator;d===void 0&&(d=`:`);let f=a.lng||this.language,p=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()===`cimode`)return p?o?{res:`${u}${d}${c}`,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(a)}:`${u}${d}${c}`:o?{res:c,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(a)}:c;let m=this.resolve(n,a),h=m?.res,g=m?.usedKey||c,_=m?.exactUsedKey||c,v=[`[object Number]`,`[object Function]`,`[object RegExp]`],y=a.joinArrays===void 0?this.options.joinArrays:a.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,x=a.count!==void 0&&!e(a.count),S=t.hasDefaultValue(a),C=x?this.pluralResolver.getSuffix(f,a.count,a):``,w=a.ordinal&&x?this.pluralResolver.getSuffix(f,a.count,{ordinal:!1}):``,T=x&&!a.ordinal&&a.count===0,E=T&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${C}`]||a[`defaultValue${w}`]||a.defaultValue,D=h;b&&!h&&S&&(D=E);let O=A(D),j=Object.prototype.toString.apply(D);if(b&&D&&O&&!v.includes(j)&&!(e(y)&&Array.isArray(D))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,D,{...a,ns:l}):`key '${c} (${this.language})' returned an object instead of string.`;return o?(m.res=e,m.usedParams=this.getUsedParamsDetails(a),m):e}if(s){let e=Array.isArray(D),t=e?[]:{},n=e?_:g;for(let e in D)if(Object.prototype.hasOwnProperty.call(D,e)){let r=`${n}${s}${e}`;t[e]=S&&!h?this.translate(r,{...a,defaultValue:A(E)?E[e]:void 0,joinArrays:!1,ns:l}):this.translate(r,{...a,joinArrays:!1,ns:l}),t[e]===r&&(t[e]=D[e])}h=t}}else if(b&&e(y)&&Array.isArray(h))h=h.join(y),h&&=this.extendTranslation(h,n,a,i);else{let e=!1,t=!1;!this.isValidLookup(h)&&S&&(e=!0,h=E),this.isValidLookup(h)||(t=!0,h=c);let r=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&t?void 0:h,o=S&&E!==h&&this.options.updateMissing;if(t||e||o){if(this.logger.log(o?`updateKey`:`missingKey`,f,u,x&&!o?`${c}${this.pluralResolver.getSuffix(f,a.count,a)}`:c,o?E:h),s){let e=this.resolve(c,{...a,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(a.lng||this.language):e.push(a.lng||this.language);let n=(e,t,n)=>{let i=S&&n!==h?n:r;this.options.missingKeyHandler?this.options.missingKeyHandler(e,u,t,i,o,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,u,t,i,o,a),this.emit(`missingKey`,e,u,t,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&x?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,a);T&&a[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],c+t,a[`defaultValue${t}`]||E)})}):n(e,c,E))}h=this.extendTranslation(h,n,a,m,i),t&&h===c&&this.options.appendNamespaceToMissingKey&&(h=`${u}${d}${c}`),(t||e)&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${c}`:c,e?h:void 0,a))}return o?(m.res=h,m.usedParams=this.getUsedParamsDetails(a),m):h}extendTranslation(t,n,r,i,a){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});let o=e(t)&&(r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables),s;if(o){let e=t.match(this.interpolator.nestingRegexp);s=e&&e.length}let c=r.replace&&!e(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),t=this.interpolator.interpolate(t,c,r.lng||this.language||i.usedLng,r),o){let e=t.match(this.interpolator.nestingRegexp),n=e&&e.length;s<n&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,(...e)=>a?.[0]===e[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${n[0]}`),null):this.translate(...e,n),r)),r.interpolation&&this.interpolator.reset()}let o=r.postProcess||this.options.postProcess,s=e(o)?[o]:o;return t!=null&&s?.length&&r.applyPostProcessor!==!1&&(t=E.handle(s,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t,n={}){let r,i,a,o,s;return e(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(e=>typeof e==`function`?k(e,{...this.options,...n}):e)),t.forEach(t=>{if(this.isValidLookup(r))return;let c=this.extractFromKey(t,n),l=c.key;i=l;let u=c.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let d=n.count!==void 0&&!e(n.count),f=d&&!n.ordinal&&n.count===0,p=n.context!==void 0&&(e(n.context)||typeof n.context==`number`)&&n.context!==``,m=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);u.forEach(e=>{this.isValidLookup(r)||(s=e,!this.checkedLoadedFor[`${m[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(s)&&(this.checkedLoadedFor[`${m[0]}-${e}`]=!0,this.logger.warn(`key "${i}" for languages "${m.join(`, `)}" won't get resolved as namespace "${s}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),m.forEach(t=>{if(this.isValidLookup(r))return;o=t;let i=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(i,l,t,e,n);else{let e;d&&(e=this.pluralResolver.getSuffix(t,n.count,n));let r=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(n.ordinal&&e.startsWith(a)&&i.push(l+e.replace(a,this.options.pluralSeparator)),i.push(l+e),f&&i.push(l+r)),p){let t=`${l}${this.options.contextSeparator||`_`}${n.context}`;i.push(t),d&&(n.ordinal&&e.startsWith(a)&&i.push(t+e.replace(a,this.options.pluralSeparator)),i.push(t+e),f&&i.push(t+r))}}let s;for(;s=i.pop();)this.isValidLookup(r)||(a=s,r=this.getResource(t,e,s,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:o,usedNS:s}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(t={}){let n=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],r=t.replace&&!e(t.replace),i=r?t.replace:t;if(r&&t.count!==void 0&&(i={...i,count:t.count}),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(let e of n)delete i[e]}return i}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith(`defaultValue`)&&e[t]!==void 0)return!0;return!1}},M=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=C.create(`languageUtils`),this.resolveHierarchyCache={}}clearCache(){this.resolveHierarchyCache={}}getScriptPartFromCode(e){if(e=x(e),!e||!e.includes(`-`))return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=x(e),!e||!e.includes(`-`))return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(t){if(e(t)&&t.includes(`-`)){let e;try{e=Intl.getCanonicalLocales(t)[0]}catch{}return e&&this.options.lowerCaseLng&&(e=e.toLowerCase()),e||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?!0:!e.includes(`-`)&&!r.includes(`-`)?!1:!!(e.includes(`-`)&&!r.includes(`-`)&&e.slice(0,e.indexOf(`-`))===r||e.startsWith(r)&&r.length>1))}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(t,n){if(!t)return[];if(typeof t==`function`&&(t=t(n)),e(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||=t[this.getScriptPartFromCode(n)],r||=t[this.formatLanguageCode(n)],r||=t[this.getLanguagePartFromCode(n)],r||=t.default,r||[]}toResolveHierarchy(t,n){let r=this.options.fallbackLng,i=Array.isArray(r)?r.join(`|`):r;i!==this._cachedFallbackLng&&(this.resolveHierarchyCache={},this._cachedFallbackLng=i);let a=n===void 0||n===!1||e(n),o=n===void 0&&typeof this.options.fallbackLng==`function`,s=e(t)&&a&&!o,c=null;if(s){let e;e=n===void 0?`undefined`:n===!1?`boolean:false`:`string:${n}`,c=`${t.length}:${t}|${e}`}if(c!==null){let e=this.resolveHierarchyCache[c];if(e!==void 0)return e.slice()}let l=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],t),u=[],d=e=>{e&&(this.isSupportedCode(e)?u.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return e(t)&&(t.includes(`-`)||t.includes(`_`))?(this.options.load!==`languageOnly`&&d(this.formatLanguageCode(t)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&d(this.getScriptPartFromCode(t)),this.options.load!==`currentOnly`&&d(this.getLanguagePartFromCode(t))):e(t)&&d(this.formatLanguageCode(t)),l.forEach(e=>{u.includes(e)||d(this.formatLanguageCode(e))}),c===null?u:(this.resolveHierarchyCache[c]=u,u.slice())}},N={zero:0,one:1,two:2,few:3,many:4,other:5},P={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},F=class{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=C.create(`pluralResolver`),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n=x(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(typeof Intl>`u`)return this.logger.error(`No Intl support, please use an Intl polyfill!`),P;if(!e.match(/-|_/))return P;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>N[e]-N[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},I=(t,n,r,i=`.`,a=!0)=>{let o=d(t,n,r);return!o&&a&&e(r)&&(o=b(t,r,i),o===void 0&&(o=b(n,r,i))),o},L=e=>e.replace(/\$/g,`$$$$`),R=class{constructor(e={}){this.logger=C.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:m,nestingSuffixEscaped:g,nestingOptionsSeparator:_,maxReplaces:v,alwaysFormat:y}=e.interpolation;this.escape=t===void 0?h:t,this.escapeValue=n===void 0||n,this.useRawValueToEscape=r!==void 0&&r,this.prefix=i?p(i):a||`{{`,this.suffix=o?p(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u?p(u):`-`,this.unescapeSuffix=this.unescapePrefix?``:l?p(l):``,this.nestingPrefix=d?p(d):f||p(`$t(`),this.nestingSuffix=m?p(m):g||p(`)`),this.nestingOptionsSeparator=_||`,`,this.maxReplaces=v||1e3,this.alwaysFormat=y!==void 0&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,r,i,a){let o,s,c,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=e=>{if(!e.includes(this.formatSeparator)){let t=I(r,l,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(t,void 0,i,{...a,...r,interpolationkey:e}):t}let t=e.split(this.formatSeparator),n=t.shift().trim(),o=t.join(this.formatSeparator).trim();return this.format(I(r,l,n,this.options.keySeparator,this.options.ignoreJSONStructure),o,i,{...a,...r,interpolationkey:n})};this.resetRegExp(),!this.escapeValue&&typeof t==`string`&&/\$t\([^)]*\{[^}]*\{\{/.test(t)&&this.logger.warn(`nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.`);let d=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=a?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:a.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e):e}].forEach(r=>{for(c=0;o=r.regex.exec(t);){let i=o[1].trim();if(s=u(i),s===void 0){if(typeof d==`function`){let n=d(t,o,a);s=e(n)?n:``}else if(a&&Object.prototype.hasOwnProperty.call(a,i))s=``;else if(f){s=o[0];continue}else this.logger.warn(`missed to pass in variable ${i} for interpolating ${t}`),s=``}else!e(s)&&!this.useRawValueToEscape&&(s=n(s));let l=r.safeValue(s);if(t=t.replace(o[0],L(l)),f?(r.regex.lastIndex+=l.length,r.regex.lastIndex-=o[0].length):r.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),t}nest(t,r,i={}){let a,o,s,c=(e,t)=>{let n=this.nestingOptionsSeparator;if(!e.includes(n))return e;let r=e.split(RegExp(`${p(n)}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,s);let a=i.match(/'/g),o=i.match(/"/g);((a?.length??0)%2==0&&!o||(o?.length??0)%2!=0)&&(i=i.replace(/'/g,`"`));try{s=JSON.parse(i),t&&(s={...t,...s})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return s.defaultValue&&s.defaultValue.includes(this.prefix)&&delete s.defaultValue,e};for(;a=this.nestingRegexp.exec(t);){let l=[];s={...i},s=s.replace&&!e(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;let u=/{.*}/s.test(a[1])?a[1].lastIndexOf(`}`)+1:a[1].indexOf(this.formatSeparator);if(u!==-1&&(l=a[1].slice(u).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),a[1]=a[1].slice(0,u)),o=r(c.call(this,a[1].trim(),s),s),o&&a[0]===t&&!e(o))return o;e(o)||(o=n(o)),o||=(this.logger.warn(`missed to resolve ${a[1]} for nesting ${t}`),``),l.length&&(o=l.reduce((e,t)=>this.format(e,t,i.lng,{...i,interpolationkey:a[1].trim()}),o.trim())),t=t.replace(a[0],o),this.regexp.lastIndex=0}return t}},z=e=>{let t=e.toLowerCase().trim(),n={};if(e.includes(`(`)){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].slice(0,-1);t===`currency`&&!i.includes(`:`)?n.currency||=i.trim():t===`relativetime`&&!i.includes(`:`)?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},B=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(x(r),i),t[o]=s),s(n)}},V=e=>(t,n,r)=>e(x(n),r)(t),H=class{constructor(e={}){this.logger=C.create(`formatter`),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||`,`;let n=t.cacheInBuiltFormats?B:V;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=B(t)}format(e,t,n,r={}){if(!t||e==null)return e;let i=t.split(this.formatSeparator),a=[];for(let e=0;e<i.length;e++){let t=i[e];for(;t.indexOf(`(`)>-1&&!t.includes(`)`)&&e+1<i.length;)t=`${t}${this.formatSeparator}${i[++e]}`;a.push(t)}return a.reduce((e,t)=>{let{formatName:i,formatOptions:a}=z(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e},e)}},U=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},W=class extends w{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=C.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{l(n.loaded,[i],a),U(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}if(o&&s&&r<this.maxRetries){setTimeout(()=>{this.read(e,t,n,r+1,i*2,a)},i);return}a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2){try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}return}return s(e,t,o)}prepareLoading(t,n,r={},i){if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),i&&i();e(t)&&(t=this.languageUtils.toResolveHierarchy(t)),e(n)&&(n=[n]);let a=this.queueLoad(t,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=``){let n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);return}if(n!=null&&n!==``){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}!e||!e[0]||this.store.addResource(e[0],t,n,r)}}},G=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let n={};if(typeof t[1]==`object`&&(n=t[1]),e(t[1])&&(n.defaultValue=t[1]),e(t[2])&&(n.tDescription=t[2]),typeof t[2]==`object`||typeof t[3]==`object`){let e=t[3]||t[2];Object.keys(e).forEach(t=>{n[t]=e[t]})}return n},interpolation:{escapeValue:!0,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),K=t=>(e(t.ns)&&(t.ns=[t.ns]),e(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),e(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&!t.supportedLngs.includes(`cimode`)&&(t.supportedLngs=t.supportedLngs.concat([`cimode`])),t),q=()=>{},J=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},Y=class n extends w{constructor(e={},t){if(super(),this.options=K(e),this.services={},this.logger=C,this.modules={external:[]},J(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(n={},r){this.isInitializing=!0,typeof n==`function`&&(r=n,n={}),n.defaultNS==null&&n.ns&&(e(n.ns)?n.defaultNS=n.ns:n.ns.includes(`translation`)||(n.defaultNS=n.ns[0]));let i=G();this.options={...i,...this.options,...K(n)},this.options.interpolation={...i.interpolation,...this.options.interpolation},n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator),typeof this.options.overloadTranslationOptionHandler!=`function`&&(this.options.overloadTranslationOptionHandler=i.overloadTranslationOptionHandler);let a=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?C.init(a(this.modules.logger),this.options):C.init(null,this.options);let e;e=this.modules.formatter?this.modules.formatter:H;let t=new M(this.options);this.store=new T(this.options.resources,this.options);let n=this.services;n.logger=C,n.resourceStore=this.store,n.languageUtils=t,n.pluralResolver=new F(t,{prepend:this.options.pluralSeparator}),e&&(n.formatter=a(e),n.formatter.init&&n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new R(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new W(a(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(n.languageDetector=a(this.modules.languageDetector),n.languageDetector.init&&n.languageDetector.init(n,this.options.detection,this.options)),this.modules.i18nFormat&&(n.i18nFormat=a(this.modules.i18nFormat),n.i18nFormat.init&&n.i18nFormat.init(this)),this.translator=new j(this.services,this.options),this.translator.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,r||=q,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let o=t(),s=()=>{let e=(e,t)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),o.resolve(t),r(e,t)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?s():setTimeout(s,0),o}loadResources(t,n=q){let r=n,i=e(t)?t:this.language;if(typeof t==`function`&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return r();let e=[],t=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&(e.includes(t)||e.push(t))})};i?t(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(e)})}else r(null)}reloadResources(e,n,r){let i=t();return typeof e==`function`&&(r=e,e=void 0),typeof n==`function`&&(r=n,n=void 0),e||=this.languages,n||=this.options.ns,r||=q,this.services.backendConnector.reload(e,n,e=>{i.resolve(),r(e)}),i}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&E.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&![`cimode`,`dev`].includes(e)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(![`cimode`,`dev`].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(n,r){this.isLanguageChangingTo=n;let i=t();this.emit(`languageChanging`,n);let a=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(e,t)=>{t?this.isLanguageChangingTo===n&&(a(t),this.translator.changeLanguage(t),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,t),this.logger.log(`languageChanged`,t)):this.isLanguageChangingTo=void 0,i.resolve((...e)=>this.t(...e)),r&&r(e,(...e)=>this.t(...e))},s=t=>{!n&&!t&&this.services.languageDetector&&(t=[]);let r=e(t)?t:t&&t[0],i=this.store.hasLanguageSomeTranslations(r)?r:this.services.languageUtils.getBestMatchFromCodes(e(t)?[t]:t);i&&(this.language||a(i),this.translator.language||this.translator.changeLanguage(i),this.services.languageDetector?.cacheUserLanguage?.(i)),this.loadResources(i,e=>{o(e,i)})};return!n&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!n&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(n),i}getFixedT(t,n,r,i){let a=i?.scopeNs,o=(e,t,...n)=>{let i;i=typeof t==`object`?{...t}:this.options.overloadTranslationOptionHandler([e,t].concat(n)),i.lng=i.lng||o.lng,i.lngs=i.lngs||o.lngs;let s=i.ns!==void 0&&i.ns!==null;i.ns=i.ns||o.ns,i.keyPrefix!==``&&(i.keyPrefix=i.keyPrefix||r||o.keyPrefix);let c={...this.options,...i};Array.isArray(a)&&!s&&(c.ns=a),typeof i.keyPrefix==`function`&&(i.keyPrefix=k(i.keyPrefix,c));let l=this.options.keySeparator||`.`,u;return i.keyPrefix&&Array.isArray(e)?u=e.map(e=>(typeof e==`function`&&(e=k(e,c)),`${i.keyPrefix}${l}${e}`)):(typeof e==`function`&&(e=k(e,c)),u=i.keyPrefix?`${i.keyPrefix}${l}${e}`:e),this.t(u,i)};return e(t)?o.lng=t:o.lngs=t,o.ns=n,o.keyPrefix=r,o}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!r||a(i,e)))}loadNamespaces(n,r){let i=t();return this.options.ns?(e(n)&&(n=[n]),n.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{i.resolve(),r&&r(e)}),i):(r&&r(),Promise.resolve())}loadLanguages(n,r){let i=t();e(n)&&(n=[n]);let a=this.options.preload||[],o=n.filter(e=>!a.includes(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=a.concat(o),this.loadResources(e=>{i.resolve(),r&&r(e)}),i):(r&&r(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch{}let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new M(G());return e.toLowerCase().indexOf(`-latn`)>1?`ltr`:t.includes(n.getLanguagePartFromCode(e))||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(e={},t){let r=new n(e,t);return r.createInstance=n.createInstance,r}cloneInstance(e={},t=q){let r=e.forkResourceStore;r&&delete e.forkResourceStore;let i={...this.options,...e,isClone:!0},a=new n(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new T(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),i),a.services.resourceStore=a.store),e.interpolation){let t={...G().interpolation,...this.options.interpolation,...e.interpolation},n={...i,interpolation:t};a.services.interpolator=new R(n)}return a.translator=new j(a.services,i),a.translator.on(`*`,(e,...t)=>{a.emit(e,...t)}),a.init(i,t),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}.createInstance();Y.createInstance,Y.dir,Y.init,Y.loadResources,Y.reloadResources,Y.use,Y.changeLanguage,Y.getFixedT,Y.t,Y.exists,Y.setDefaultNamespace,Y.hasLoadedNamespace,Y.loadNamespaces,Y.loadLanguages;export{k as n,Y as t};
1
+ var e=e=>typeof e==`string`,t=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},n=e=>e==null?``:String(e),r=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},i=/###/g,a=e=>e&&e.includes(`###`)?e.replace(i,`.`):e,o=t=>!t||e(t),s=(t,n,r)=>{let i=e(n)?n.split(`.`):n,s=0;for(;s<i.length-1;){if(o(t))return{};let e=a(i[s]);!t[e]&&r&&(t[e]=new r),t=Object.prototype.hasOwnProperty.call(t,e)?t[e]:{},++s}return o(t)?{}:{obj:t,k:a(i[s])}},c=(e,t,n)=>{let{obj:r,k:i}=s(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),c=s(e,o,Object);for(;c.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),c=s(e,o,Object),c?.obj&&c.obj[`${c.k}.${a}`]!==void 0&&(c.obj=void 0);c.obj[`${c.k}.${a}`]=n},l=(e,t,n,r)=>{let{obj:i,k:a}=s(e,t,Object);i[a]=i[a]||[],i[a].push(n)},u=(e,t)=>{let{obj:n,k:r}=s(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},d=(e,t,n)=>{let r=u(e,n);return r===void 0?u(t,n):r},f=(t,n,r)=>{for(let i in n)i!==`__proto__`&&i!==`constructor`&&(Object.prototype.hasOwnProperty.call(t,i)?e(t[i])||t[i]instanceof String||e(n[i])||n[i]instanceof String?r&&(t[i]=n[i]):f(t[i],n[i],r):t[i]=n[i]);return t},p=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),m={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`,"/":`&#x2F;`},h=t=>e(t)?t.replace(/[&<>"'\/]/g,e=>m[e]):t,g=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},_=[` `,`,`,`?`,`!`,`;`],v=new g(20),y=(e,t,n)=>{t||=``,n||=``;let r=_.filter(e=>!t.includes(e)&&!n.includes(e));if(r.length===0)return!0;let i=v.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},b=(e,t,n=`.`)=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].includes(typeof t)&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},x=e=>e?.replace(/_/g,`-`),S={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},C=new class t{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||`i18next:`,this.logger=e||S,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,`log`,``,!0)}warn(...e){return this.forward(e,`warn`,``,!0)}error(...e){return this.forward(e,`error`,``)}deprecate(...e){return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(t,n,r,i){return i&&!this.debug?null:(t=t.map(t=>e(t)?t.replace(/[\r\n\x00-\x1F\x7F]/g,` `):t),e(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(e){return new t(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e||=this.options,e.prefix=e.prefix||this.prefix,new t(this.logger,e)}},w=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(([n,r])=>{for(let i=0;i<r;i++)n(e,...t)})}},T=class extends w{constructor(e,t={ns:[`translation`],defaultNS:`translation`}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(t,n,r,i={}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=i.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:i.ignoreJSONStructure,s;t.includes(`.`)?s=t.split(`.`):(s=[t,n],r&&(Array.isArray(r)?s.push(...r):e(r)&&a?s.push(...r.split(a)):s.push(r)));let c=u(this.data,s);return!c&&!n&&!r&&t.includes(`.`)&&(t=s[0],n=s[1],r=s.slice(2).join(`.`)),c||!o||!e(r)?c:b(this.data?.[t]?.[n],r,a)}addResource(e,t,n,r,i={silent:!1}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.includes(`.`)&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),c(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(t,n,r,i={silent:!1}){for(let i in r)(e(r[i])||Array.isArray(r[i]))&&this.addResource(t,n,i,r[i],{silent:!0});i.silent||this.emit(`added`,t,n,r)}addResourceBundle(e,t,n,r,i,a={silent:!1,skipCopy:!1}){let o=[e,t];e.includes(`.`)&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=u(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?f(s,n,i):s={...s,...n},c(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}},E={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},D=Symbol(`i18next/PATH_KEY`);function O(){let e=[],t=Object.create(null),n;return t.get=(r,i)=>(n?.revoke?.(),i===D?e:(e.push(i),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function k(e,t){let{[D]:n}=e(O()),r=t?.keySeparator??`.`,i=t?.nsSeparator??`:`,a=t?.enableSelector===`strict`;if(n.length>1&&i){let e=t?.ns,o=a?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(o&&(a?o:o.length>1?o.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}var A=t=>!e(t)&&typeof t!=`boolean`&&typeof t!=`number`,j=class t extends w{constructor(e,t={}){super(),r([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=C.create(`translator`),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(e==null)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let i=A(r.res);return!(n.returnObjects===!1&&i)}extractFromKey(t,n){let r=n.nsSeparator===void 0?this.options.nsSeparator:n.nsSeparator;r===void 0&&(r=`:`);let i=n.keySeparator===void 0?this.options.keySeparator:n.keySeparator,a=n.ns||this.options.defaultNS||[],o=r&&t.includes(r),s=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!y(t,r,i);if(o&&!s){let n=t.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:t,namespaces:e(a)?[a]:a};let o=t.split(r);(r!==i||r===i&&this.options.ns.includes(o[0]))&&(a=o.shift()),t=o.join(i)}return{key:t,namespaces:e(a)?[a]:a}}translate(n,r,i){let a=typeof r==`object`?{...r}:r;if(typeof a!=`object`&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a==`object`&&(a={...a}),a||={},n==null)return``;typeof n==`function`&&(n=k(n,{...this.options,...a})),Array.isArray(n)||(n=[String(n)]),n=n.map(e=>typeof e==`function`?k(e,{...this.options,...a}):String(e));let o=a.returnDetails===void 0?this.options.returnDetails:a.returnDetails,s=a.keySeparator===void 0?this.options.keySeparator:a.keySeparator,{key:c,namespaces:l}=this.extractFromKey(n[n.length-1],a),u=l[l.length-1],d=a.nsSeparator===void 0?this.options.nsSeparator:a.nsSeparator;d===void 0&&(d=`:`);let f=a.lng||this.language,p=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()===`cimode`)return p?o?{res:`${u}${d}${c}`,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(a)}:`${u}${d}${c}`:o?{res:c,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(a)}:c;let m=this.resolve(n,a),h=m?.res,g=m?.usedKey||c,_=m?.exactUsedKey||c,v=[`[object Number]`,`[object Function]`,`[object RegExp]`],y=a.joinArrays===void 0?this.options.joinArrays:a.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,x=a.count!==void 0&&!e(a.count),S=t.hasDefaultValue(a),C=x?this.pluralResolver.getSuffix(f,a.count,a):``,w=a.ordinal&&x?this.pluralResolver.getSuffix(f,a.count,{ordinal:!1}):``,T=x&&!a.ordinal&&a.count===0,E=T&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${C}`]||a[`defaultValue${w}`]||a.defaultValue,D=h;b&&!h&&S&&(D=E);let O=A(D),j=Object.prototype.toString.apply(D);if(b&&D&&O&&!v.includes(j)&&!(e(y)&&Array.isArray(D))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,D,{...a,ns:l}):`key '${c} (${this.language})' returned an object instead of string.`;return o?(m.res=e,m.usedParams=this.getUsedParamsDetails(a),m):e}if(s){let e=Array.isArray(D),t=e?[]:{},n=e?_:g;for(let e in D)if(Object.prototype.hasOwnProperty.call(D,e)){let r=`${n}${s}${e}`;t[e]=S&&!h?this.translate(r,{...a,defaultValue:A(E)?E[e]:void 0,joinArrays:!1,ns:l}):this.translate(r,{...a,joinArrays:!1,ns:l}),t[e]===r&&(t[e]=D[e])}h=t}}else if(b&&e(y)&&Array.isArray(h))h=h.join(y),h&&=this.extendTranslation(h,n,a,i);else{let e=!1,t=!1;!this.isValidLookup(h)&&S&&(e=!0,h=E),this.isValidLookup(h)||(t=!0,h=c);let r=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&t?void 0:h,o=S&&E!==h&&this.options.updateMissing;if(t||e||o){if(this.logger.log(o?`updateKey`:`missingKey`,f,u,x&&!o?`${c}${this.pluralResolver.getSuffix(f,a.count,a)}`:c,o?E:h),s){let e=this.resolve(c,{...a,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(a.lng||this.language):e.push(a.lng||this.language);let n=(e,t,n)=>{let i=S&&n!==h?n:r;this.options.missingKeyHandler?this.options.missingKeyHandler(e,u,t,i,o,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,u,t,i,o,a),this.emit(`missingKey`,e,u,t,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&x?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,a);T&&a[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],c+t,a[`defaultValue${t}`]||E)})}):n(e,c,E))}h=this.extendTranslation(h,n,a,m,i),t&&h===c&&this.options.appendNamespaceToMissingKey&&(h=`${u}${d}${c}`),(t||e)&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${c}`:c,e?h:void 0,a))}return o?(m.res=h,m.usedParams=this.getUsedParamsDetails(a),m):h}extendTranslation(t,n,r,i,a){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});let o=e(t)&&(r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables),s;if(o){let e=t.match(this.interpolator.nestingRegexp);s=e&&e.length}let c=r.replace&&!e(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),t=this.interpolator.interpolate(t,c,r.lng||this.language||i.usedLng,r),o){let e=t.match(this.interpolator.nestingRegexp),n=e&&e.length;s<n&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,(...e)=>a?.[0]===e[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${n[0]}`),null):this.translate(...e,n),r)),r.interpolation&&this.interpolator.reset()}let o=r.postProcess||this.options.postProcess,s=e(o)?[o]:o;return t!=null&&s?.length&&r.applyPostProcessor!==!1&&(t=E.handle(s,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t,n={}){let r,i,a,o,s;return e(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(e=>typeof e==`function`?k(e,{...this.options,...n}):e)),t.forEach(t=>{if(this.isValidLookup(r))return;let c=this.extractFromKey(t,n),l=c.key;i=l;let u=c.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let d=n.count!==void 0&&!e(n.count),f=d&&!n.ordinal&&n.count===0,p=n.context!==void 0&&(e(n.context)||typeof n.context==`number`)&&n.context!==``,m=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);u.forEach(e=>{this.isValidLookup(r)||(s=e,!this.checkedLoadedFor[`${m[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(s)&&(this.checkedLoadedFor[`${m[0]}-${e}`]=!0,this.logger.warn(`key "${i}" for languages "${m.join(`, `)}" won't get resolved as namespace "${s}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),m.forEach(t=>{if(this.isValidLookup(r))return;o=t;let i=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(i,l,t,e,n);else{let e;d&&(e=this.pluralResolver.getSuffix(t,n.count,n));let r=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(n.ordinal&&e.startsWith(a)&&i.push(l+e.replace(a,this.options.pluralSeparator)),i.push(l+e),f&&i.push(l+r)),p){let t=`${l}${this.options.contextSeparator||`_`}${n.context}`;i.push(t),d&&(n.ordinal&&e.startsWith(a)&&i.push(t+e.replace(a,this.options.pluralSeparator)),i.push(t+e),f&&i.push(t+r))}}let s;for(;s=i.pop();)this.isValidLookup(r)||(a=s,r=this.getResource(t,e,s,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:o,usedNS:s}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(t={}){let n=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],r=t.replace&&!e(t.replace),i=r?t.replace:t;if(r&&t.count!==void 0&&(i={...i,count:t.count}),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(let e of n)delete i[e]}return i}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith(`defaultValue`)&&e[t]!==void 0)return!0;return!1}},M=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=C.create(`languageUtils`),this.resolveHierarchyCache={}}clearCache(){this.resolveHierarchyCache={}}getScriptPartFromCode(e){if(e=x(e),!e||!e.includes(`-`))return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=x(e),!e||!e.includes(`-`))return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(t){if(e(t)&&t.includes(`-`)){let e;try{e=Intl.getCanonicalLocales(t)[0]}catch{}return e&&this.options.lowerCaseLng&&(e=e.toLowerCase()),e||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?!0:!e.includes(`-`)&&!r.includes(`-`)?!1:!!(e.includes(`-`)&&!r.includes(`-`)&&e.slice(0,e.indexOf(`-`))===r||e.startsWith(r)&&r.length>1))}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(t,n){if(!t)return[];if(typeof t==`function`&&(t=t(n)),e(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||=t[this.getScriptPartFromCode(n)],r||=t[this.formatLanguageCode(n)],r||=t[this.getLanguagePartFromCode(n)],r||=t.default,r||[]}toResolveHierarchy(t,n){let r=this.options.fallbackLng,i=Array.isArray(r)?r.join(`|`):r;i!==this._cachedFallbackLng&&(this.resolveHierarchyCache={},this._cachedFallbackLng=i);let a=n===void 0||n===!1||e(n),o=n===void 0&&typeof this.options.fallbackLng==`function`,s=e(t)&&a&&!o,c=null;if(s){let e;e=n===void 0?`undefined`:n===!1?`boolean:false`:`string:${n}`,c=`${t.length}:${t}|${e}`}if(c!==null){let e=this.resolveHierarchyCache[c];if(e!==void 0)return e.slice()}let l=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],t),u=[],d=e=>{e&&(this.isSupportedCode(e)?u.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return e(t)&&(t.includes(`-`)||t.includes(`_`))?(this.options.load!==`languageOnly`&&d(this.formatLanguageCode(t)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&d(this.getScriptPartFromCode(t)),this.options.load!==`currentOnly`&&d(this.getLanguagePartFromCode(t))):e(t)&&d(this.formatLanguageCode(t)),l.forEach(e=>{u.includes(e)||d(this.formatLanguageCode(e))}),c===null?u:(this.resolveHierarchyCache[c]=u,u.slice())}},N={zero:0,one:1,two:2,few:3,many:4,other:5},P={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},F=class{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=C.create(`pluralResolver`),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n=x(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(typeof Intl>`u`)return this.logger.error(`No Intl support, please use an Intl polyfill!`),P;if(!e.match(/-|_/))return P;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>N[e]-N[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},I=(t,n,r,i=`.`,a=!0)=>{let o=d(t,n,r);return!o&&a&&e(r)&&(o=b(t,r,i),o===void 0&&(o=b(n,r,i))),o},L=e=>e.replace(/\$/g,`$$$$`),R=class{constructor(e={}){this.logger=C.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:m,nestingSuffixEscaped:g,nestingOptionsSeparator:_,maxReplaces:v,alwaysFormat:y}=e.interpolation;this.escape=t===void 0?h:t,this.escapeValue=n===void 0||n,this.useRawValueToEscape=r!==void 0&&r,this.prefix=i?p(i):a||`{{`,this.suffix=o?p(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u?p(u):`-`,this.unescapeSuffix=this.unescapePrefix?``:l?p(l):``,this.nestingPrefix=d?p(d):f||p(`$t(`),this.nestingSuffix=m?p(m):g||p(`)`),this.nestingOptionsSeparator=_||`,`,this.maxReplaces=v||1e3,this.alwaysFormat=y!==void 0&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,r,i,a){let o,s,c,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=e=>{if(!e.includes(this.formatSeparator)){let t=I(r,l,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(t,void 0,i,{...a,...r,interpolationkey:e}):t}let t=e.split(this.formatSeparator),n=t.shift().trim(),o=t.join(this.formatSeparator).trim();return this.format(I(r,l,n,this.options.keySeparator,this.options.ignoreJSONStructure),o,i,{...a,...r,interpolationkey:n})};this.resetRegExp(),!this.escapeValue&&typeof t==`string`&&/\$t\([^)]*\{[^}]*\{\{/.test(t)&&this.logger.warn(`nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.`);let d=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=a?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:a.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e):e}].forEach(r=>{for(c=0;o=r.regex.exec(t);){let i=o[1].trim();if(s=u(i),s===void 0){if(typeof d==`function`){let n=d(t,o,a);s=e(n)?n:``}else if(a&&Object.prototype.hasOwnProperty.call(a,i))s=``;else if(f){s=o[0];continue}else this.logger.warn(`missed to pass in variable ${i} for interpolating ${t}`),s=``}else!e(s)&&!this.useRawValueToEscape&&(s=n(s));let l=r.safeValue(s);if(t=t.replace(o[0],L(l)),f?(r.regex.lastIndex+=l.length,r.regex.lastIndex-=o[0].length):r.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),t}nest(t,r,i={}){let a,o,s,c=(e,t)=>{let n=this.nestingOptionsSeparator;if(!e.includes(n))return e;let r=e.split(RegExp(`${p(n)}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,s);let a=i.match(/'/g),o=i.match(/"/g);((a?.length??0)%2==0&&!o||(o?.length??0)%2!=0)&&(i=i.replace(/'/g,`"`));try{s=JSON.parse(i),t&&(s={...t,...s})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return s.defaultValue&&s.defaultValue.includes(this.prefix)&&delete s.defaultValue,e};for(;a=this.nestingRegexp.exec(t);){let l=[];s={...i},s=s.replace&&!e(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;let u=/{.*}/s.test(a[1])?a[1].lastIndexOf(`}`)+1:a[1].indexOf(this.formatSeparator);if(u!==-1&&(l=a[1].slice(u).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),a[1]=a[1].slice(0,u)),o=r(c.call(this,a[1].trim(),s),s),o&&a[0]===t&&!e(o))return o;e(o)||(o=n(o)),o||=(this.logger.warn(`missed to resolve ${a[1]} for nesting ${t}`),``),l.length&&(o=l.reduce((e,t)=>this.format(e,t,i.lng,{...i,interpolationkey:a[1].trim()}),o.trim())),t=t.replace(a[0],L(n(o))),this.regexp.lastIndex=0}return t}},z=e=>{let t=e.toLowerCase().trim(),n={};if(e.includes(`(`)){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].slice(0,-1);t===`currency`&&!i.includes(`:`)?n.currency||=i.trim():t===`relativetime`&&!i.includes(`:`)?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},B=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(x(r),i),t[o]=s),s(n)}},V=e=>(t,n,r)=>e(x(n),r)(t),H=class{constructor(e={}){this.logger=C.create(`formatter`),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||`,`;let n=t.cacheInBuiltFormats?B:V;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=B(t)}format(e,t,n,r={}){if(!t||e==null)return e;let i=t.split(this.formatSeparator),a=[];for(let e=0;e<i.length;e++){let t=i[e];for(;t.indexOf(`(`)>-1&&!t.includes(`)`)&&e+1<i.length;)t=`${t}${this.formatSeparator}${i[++e]}`;a.push(t)}return a.reduce((e,t)=>{let{formatName:i,formatOptions:a}=z(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e},e)}},U=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},W=class extends w{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=C.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{l(n.loaded,[i],a),U(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}if(o&&s&&r<this.maxRetries){setTimeout(()=>{this.read(e,t,n,r+1,i*2,a)},i);return}a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2){try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}return}return s(e,t,o)}prepareLoading(t,n,r={},i){if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),i&&i();e(t)&&(t=this.languageUtils.toResolveHierarchy(t)),e(n)&&(n=[n]);let a=this.queueLoad(t,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=``){let n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);return}if(n!=null&&n!==``){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}!e||!e[0]||this.store.addResource(e[0],t,n,r)}}},G=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let n={};if(typeof t[1]==`object`&&(n=t[1]),e(t[1])&&(n.defaultValue=t[1]),e(t[2])&&(n.tDescription=t[2]),typeof t[2]==`object`||typeof t[3]==`object`){let e=t[3]||t[2];Object.keys(e).forEach(t=>{n[t]=e[t]})}return n},interpolation:{escapeValue:!0,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),K=t=>(e(t.ns)&&(t.ns=[t.ns]),e(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),e(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&!t.supportedLngs.includes(`cimode`)&&(t.supportedLngs=t.supportedLngs.concat([`cimode`])),t),q=()=>{},J=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},Y=class n extends w{constructor(e={},t){if(super(),this.options=K(e),this.services={},this.logger=C,this.modules={external:[]},J(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(n={},r){this.isInitializing=!0,typeof n==`function`&&(r=n,n={}),n.defaultNS==null&&n.ns&&(e(n.ns)?n.defaultNS=n.ns:n.ns.includes(`translation`)||(n.defaultNS=n.ns[0]));let i=G();this.options={...i,...this.options,...K(n)},this.options.interpolation={...i.interpolation,...this.options.interpolation},n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator),typeof this.options.overloadTranslationOptionHandler!=`function`&&(this.options.overloadTranslationOptionHandler=i.overloadTranslationOptionHandler);let a=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?C.init(a(this.modules.logger),this.options):C.init(null,this.options);let e;e=this.modules.formatter?this.modules.formatter:H;let t=new M(this.options);this.store=new T(this.options.resources,this.options);let n=this.services;n.logger=C,n.resourceStore=this.store,n.languageUtils=t,n.pluralResolver=new F(t,{prepend:this.options.pluralSeparator}),e&&(n.formatter=a(e),n.formatter.init&&n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new R(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new W(a(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(n.languageDetector=a(this.modules.languageDetector),n.languageDetector.init&&n.languageDetector.init(n,this.options.detection,this.options)),this.modules.i18nFormat&&(n.i18nFormat=a(this.modules.i18nFormat),n.i18nFormat.init&&n.i18nFormat.init(this)),this.translator=new j(this.services,this.options),this.translator.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,r||=q,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let o=t(),s=()=>{let e=(e,t)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),o.resolve(t),r(e,t)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?s():setTimeout(s,0),o}loadResources(t,n=q){let r=n,i=e(t)?t:this.language;if(typeof t==`function`&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return r();let e=[],t=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&(e.includes(t)||e.push(t))})};i?t(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(e)})}else r(null)}reloadResources(e,n,r){let i=t();return typeof e==`function`&&(r=e,e=void 0),typeof n==`function`&&(r=n,n=void 0),e||=this.languages,n||=this.options.ns,r||=q,this.services.backendConnector.reload(e,n,e=>{i.resolve(),r(e)}),i}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&E.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&![`cimode`,`dev`].includes(e)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(![`cimode`,`dev`].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(n,r){this.isLanguageChangingTo=n;let i=t();this.emit(`languageChanging`,n);let a=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(e,t)=>{t?this.isLanguageChangingTo===n&&(a(t),this.translator.changeLanguage(t),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,t),this.logger.log(`languageChanged`,t)):this.isLanguageChangingTo=void 0,i.resolve((...e)=>this.t(...e)),r&&r(e,(...e)=>this.t(...e))},s=t=>{!n&&!t&&this.services.languageDetector&&(t=[]);let r=e(t)?t:t&&t[0],i=this.store.hasLanguageSomeTranslations(r)?r:this.services.languageUtils.getBestMatchFromCodes(e(t)?[t]:t);i&&(this.language||a(i),this.translator.language||this.translator.changeLanguage(i),this.services.languageDetector?.cacheUserLanguage?.(i)),this.loadResources(i,e=>{o(e,i)})};return!n&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!n&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(n),i}getFixedT(t,n,r,i){let a=i?.scopeNs,o=(e,t,...n)=>{let i;i=typeof t==`object`?{...t}:this.options.overloadTranslationOptionHandler([e,t].concat(n)),i.lng=i.lng||o.lng,i.lngs=i.lngs||o.lngs;let s=i.ns!==void 0&&i.ns!==null;i.ns=i.ns||o.ns,i.keyPrefix!==``&&(i.keyPrefix=i.keyPrefix||r||o.keyPrefix);let c={...this.options,...i};Array.isArray(a)&&!s&&(c.ns=a),typeof i.keyPrefix==`function`&&(i.keyPrefix=k(i.keyPrefix,c));let l=this.options.keySeparator||`.`,u;return i.keyPrefix&&Array.isArray(e)?u=e.map(e=>(typeof e==`function`&&(e=k(e,c)),`${i.keyPrefix}${l}${e}`)):(typeof e==`function`&&(e=k(e,c)),u=i.keyPrefix?`${i.keyPrefix}${l}${e}`:e),this.t(u,i)};return e(t)?o.lng=t:o.lngs=t,o.ns=n,o.keyPrefix=r,o}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!r||a(i,e)))}loadNamespaces(n,r){let i=t();return this.options.ns?(e(n)&&(n=[n]),n.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{i.resolve(),r&&r(e)}),i):(r&&r(),Promise.resolve())}loadLanguages(n,r){let i=t();e(n)&&(n=[n]);let a=this.options.preload||[],o=n.filter(e=>!a.includes(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=a.concat(o),this.loadResources(e=>{i.resolve(),r&&r(e)}),i):(r&&r(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch{}let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new M(G());return e.toLowerCase().indexOf(`-latn`)>1?`ltr`:t.includes(n.getLanguagePartFromCode(e))||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(e={},t){let r=new n(e,t);return r.createInstance=n.createInstance,r}cloneInstance(e={},t=q){let r=e.forkResourceStore;r&&delete e.forkResourceStore;let i={...this.options,...e,isClone:!0},a=new n(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new T(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),i),a.services.resourceStore=a.store),e.interpolation){let t={...G().interpolation,...this.options.interpolation,...e.interpolation},n={...i,interpolation:t};a.services.interpolator=new R(n)}return a.translator=new j(a.services,i),a.translator.on(`*`,(e,...t)=>{a.emit(e,...t)}),a.init(i,t),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}.createInstance();Y.createInstance,Y.dir,Y.init,Y.loadResources,Y.reloadResources,Y.use,Y.changeLanguage,Y.getFixedT,Y.t,Y.exists,Y.setDefaultNamespace,Y.hasLoadedNamespace,Y.loadNamespaces,Y.loadLanguages;export{k as n,Y as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./markdown-math-gtdBxaM5.js";export{t as rehypeKatex,e as remarkMath};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{t as r}from"./logger-DnuT4jgB.js";import{t as i}from"./useTranslation-rdLmo6zV.js";import{i as a}from"./utils-CKWltgs8.js";import{Gn as o,Nn as s,On as c,Tn as l,Un as u,Yn as d,bn as f}from"./ui-vendor-BvD5yGW1.js";import{t as p}from"./appStore-Bsxed1km.js";var m=e(t(),1),h={selection:8,impact:14,success:[10,28,12],warning:[18,42,18]},g=()=>typeof window>`u`||typeof navigator>`u`?!1:navigator.maxTouchPoints>0||window.matchMedia?.(`(pointer: coarse)`).matches===!0,_=()=>typeof navigator<`u`&&typeof navigator.vibrate==`function`&&g(),v=(e=`selection`)=>p.getState().preferences.hapticFeedbackEnabled!==!0||!_()?!1:navigator.vibrate(h[e]),y=[/^ {0,3}(?:`{3,}|~{3,})/m,/`[^`\n]+`/,/^\s{0,3}#{1,6}\s/m,/^\s{0,3}[-*+]\s/m,/^\s{0,3}\d+\.\s/m,/^\s{0,3}>\s/m,/\[[^\]]+\]\([^)]+\)/,/!\[[^\]]*]\([^)]+\)/,/\|.*\|/,/\*\*[^*]+\*\*/,/__[^_]+__/,/~~[^~]+~~/,/\\\[[\s\S]*?\\\]/,/\\\([\s\S]*?\\\)/,/\$\$[\s\S]*?\$\$/,/(^|[^$])\$[^$\n]+\$/],b=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);function x(e){let t=[],n=/^( {0,3})(`{3,}|~{3,})([^\n\r]*)(?:\r?\n|$)/gm,r;for(;r=n.exec(e);){let i=r[1].length,a=r[2],o=a[0],s=r[3].trim();if(o==="`"&&s.includes("`"))continue;let c=n.lastIndex,l=RegExp(`^ {0,3}${b(o)}{${a.length},}[ \\t]*(?:\\r?\\n|$)`,`gm`);l.lastIndex=c;let u=l.exec(e),d=s.split(/\s+/)[0]||null;if(!u){t.push({start:r.index,end:e.length,codeStart:c,codeEnd:e.length,indent:i,language:d,complete:!1});break}t.push({start:r.index,end:l.lastIndex,codeStart:c,codeEnd:u.index,indent:i,language:d,complete:!0}),n.lastIndex=l.lastIndex}return t}function S(e){return/<(?:html|head|body)(?:\s|>)|<\/(?:head|body|html)\s*>/i.test(e)}function C(e,t){return e.start<t.end&&t.start<e.end}function w(e,t){let n=/^( {0,3})(<!doctype\s+html(?:\s|>|$)|<html(?:\s[^>\n\r]*)?>)/gim,r;for(;r=n.exec(e);){let n=r.index+r[1].length;if(t.some(e=>n>=e.start&&n<e.end))continue;let i=e.slice(n);if(!S(i.slice(r[2].length)))continue;let a=/<\/html\s*>/i.exec(i),o=a?n+a.index+a[0].length:e.length;return{start:r.index,end:o,codeStart:n,codeEnd:o,indent:0,language:`html`,complete:!!a}}return null}function T(e){let t=x(e),n=w(e,t);return n?[...t.filter(e=>!C(e,n)),n].sort((e,t)=>e.start-t.start):t}function E(e,t){return t===0?e:e.replace(RegExp(`^ {1,${t}}`,`gm`),``)}function D(e){return y.some(t=>t.test(e))}function O(e){let t=[],n=T(e),r=0;for(let i of n){let n=e.slice(r,i.start);n&&t.push({type:`text`,content:n}),t.push({type:`code`,language:i.language,content:E(e.slice(i.codeStart,i.codeEnd),i.indent),complete:i.complete}),r=i.end}let i=e.slice(r);return(i||t.length===0)&&t.push({type:`text`,content:i}),t}function k(e){let t=e=>e.replace(/\\\[([\s\S]*?)\\\]/g,(e,t)=>`$$${t}$$`).replace(/\\\(([\s\S]*?)\\\)/g,(e,t)=>`$${t}$`),n=e=>{let n=/`[^`\n]+`/g,r=``,i=0,a;for(;a=n.exec(e);)r+=t(e.slice(i,a.index)),r+=a[0],i=n.lastIndex;return r+t(e.slice(i))},r=x(e),i=``,a=0;for(let t of r)i+=n(e.slice(a,t.start)),i+=e.slice(t.start,t.end),a=t.end;return i+=n(e.slice(a)),i}var A=n(),j=r(`components:ui:message-code-block`),M=24,N={bash:`sh`,c:`c`,cpp:`cpp`,csharp:`cs`,css:`css`,go:`go`,html:`html`,htm:`html`,java:`java`,javascript:`js`,js:`js`,json:`json`,jsx:`jsx`,kotlin:`kt`,markdown:`md`,mermaid:`mmd`,php:`php`,python:`py`,py:`py`,ruby:`rb`,rust:`rs`,sh:`sh`,shell:`sh`,sql:`sql`,svg:`svg`,swift:`swift`,toml:`toml`,ts:`ts`,tsx:`tsx`,typescript:`ts`,xml:`xml`,yaml:`yaml`,yml:`yaml`,zsh:`sh`};function P(e,t){let n=(e||``).toLowerCase();if(n===`html`||n===`htm`)return`html`;if(n===`svg`)return`svg`;if(n===`mermaid`)return`mermaid`;let r=t.slice(0,500).toLowerCase();return(!n||n===`xml`)&&r.includes(`<svg`)?`svg`:!n&&(r.includes(`<!doctype html`)||r.includes(`<html`))?`html`:null}function F({code:e,language:t,state:n,children:r}){let{t:h}=i(),g=p(e=>e.openArtifactPanel),[_,y]=m.useState(null),[b,x]=m.useState(null),S=m.useRef(null),C=_===e,w=t||`text`,T=h(C?`artifacts.copied`:`artifacts.copy`),E=`${T}: ${w}`,D=m.useMemo(()=>e?e.split(`
2
- `).length:0,[e]),O=b===null?n===`complete`&&D>M:!b,k=n===`complete`?P(t,e):null;return m.useEffect(()=>()=>{S.current!==null&&window.clearTimeout(S.current)},[]),(0,A.jsxs)(`div`,{dir:`ltr`,"data-testid":`code-block`,"data-state":n,"data-language":w,"data-collapsed":O,className:`group relative my-4 overflow-hidden rounded-xl border border-line bg-surface-subtle text-left text-ink shadow-[0_12px_32px_rgba(13,17,23,0.1)] dark:border-white/10 dark:bg-dark-50 dark:text-dark-900 dark:shadow-[0_12px_32px_rgba(13,17,23,0.16)]`,children:[(0,A.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b border-line bg-surface-raised/70 px-3.5 dark:border-white/10 dark:bg-white/[0.035]`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,A.jsx)(s,{className:`h-3.5 w-3.5 shrink-0 text-ink-subtle dark:text-dark-500`}),(0,A.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium lowercase tracking-[-0.01em] text-ink-muted dark:text-dark-700`,children:w})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[n===`streaming`&&(0,A.jsx)(`span`,{role:`status`,"aria-label":h(`common.loading`),className:`flex h-7 w-7 items-center justify-center`,children:(0,A.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-primary-400`})}),D>M&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>x(O),className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-900`,title:h(O?`artifacts.expand`:`artifacts.collapse`),"aria-label":h(O?`artifacts.expand`:`artifacts.collapse`),"aria-expanded":!O,children:O?(0,A.jsx)(u,{className:`h-3.5 w-3.5`}):(0,A.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{if(!e)return;let n=N[(t||``).toLowerCase()]||`txt`,r=new Blob([e],{type:`text/plain;charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`snippet.${n}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)},disabled:!e,className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 disabled:cursor-default disabled:opacity-35 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-900`,title:h(`common.download`),"aria-label":`${h(`common.download`)}: ${w}`,children:(0,A.jsx)(l,{className:`h-3.5 w-3.5`})}),k&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{if(!k||!e)return;let t=Date.now();g({id:a(),type:k,title:`${w} ${h(`artifacts.preview`)}`,content:e,language:w,createdAt:t,updatedAt:t})},className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-900`,title:h(`artifacts.preview`),"aria-label":`${h(`artifacts.preview`)}: ${w}`,children:(0,A.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,A.jsx)(`button`,{type:`button`,onClick:async()=>{if(e)try{await navigator.clipboard.writeText(e),v(`success`),y(e),S.current!==null&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{y(null),S.current=null},2e3)}catch(e){j.error(`Failed to copy code:`,e)}},disabled:!e,className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 disabled:cursor-default disabled:opacity-35 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-900`,title:T,"aria-label":E,children:C?(0,A.jsx)(d,{className:`h-3.5 w-3.5 text-green-400`}):(0,A.jsx)(c,{className:`h-3.5 w-3.5`})}),(0,A.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:C?E:``})]})]}),O?(0,A.jsx)(`button`,{type:`button`,onClick:()=>x(!0),className:`block w-full px-3.5 py-2.5 text-left font-mono text-[11px] italic text-ink-subtle transition-colors hover:bg-surface-raised/70 hover:text-ink dark:text-dark-500 dark:hover:bg-white/[0.035] dark:hover:text-dark-900`,children:h(`chatMessage.hiddenLines`,{count:D})}):r]})}var I=`rgb(var(--color-dark-50))`,L=`rgb(var(--color-surface-subtle))`,R=`max-h-[60vh] min-h-12 overflow-auto bg-surface-subtle p-4 text-left font-mono text-[14px] leading-6 text-ink whitespace-pre tabular-nums dark:bg-dark-50 dark:text-dark-900`,z={maxHeight:`60vh`,minHeight:`3rem`,overflow:`auto`,padding:`1rem`,fontSize:`14px`,lineHeight:`1.5rem`,fontFamily:`"JetBrains Mono", ui-monospace, SFMono-Regular, monospace`,whiteSpace:`pre`};export{F as a,D as c,z as i,v as l,L as n,O as o,R as r,k as s,I as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{t as r}from"./logger-DnuT4jgB.js";import{t as i}from"./useTranslation-rdLmo6zV.js";import{i as a}from"./utils-CKWltgs8.js";import{Mn as o,On as s,Tn as c,Un as l,Wn as u,Yn as d,bn as f}from"./ui-vendor-Dt9hfsGD.js";import{t as p}from"./appStore-DrTsJPfh.js";var m=e(t(),1),h={selection:8,impact:14,success:[10,28,12],warning:[18,42,18]},g=()=>typeof window>`u`||typeof navigator>`u`?!1:navigator.maxTouchPoints>0||window.matchMedia?.(`(pointer: coarse)`).matches===!0,_=()=>typeof navigator<`u`&&typeof navigator.vibrate==`function`&&g(),v=(e=`selection`)=>p.getState().preferences.hapticFeedbackEnabled!==!0||!_()?!1:navigator.vibrate(h[e]),y=[/^ {0,3}(?:`{3,}|~{3,})/m,/`[^`\n]+`/,/^\s{0,3}#{1,6}\s/m,/^\s{0,3}[-*+]\s/m,/^\s{0,3}\d+\.\s/m,/^\s{0,3}>\s/m,/\[[^\]]+\]\([^)]+\)/,/!\[[^\]]*]\([^)]+\)/,/\|.*\|/,/\*\*[^*]+\*\*/,/__[^_]+__/,/~~[^~]+~~/,/\\\[[\s\S]*?\\\]/,/\\\([\s\S]*?\\\)/,/\$\$[\s\S]*?\$\$/,/(^|[^$])\$[^$\n]+\$/],b=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);function x(e){let t=[],n=/^( {0,3})(`{3,}|~{3,})([^\n\r]*)(?:\r?\n|$)/gm,r;for(;r=n.exec(e);){let i=r[1].length,a=r[2],o=a[0],s=r[3].trim();if(o==="`"&&s.includes("`"))continue;let c=n.lastIndex,l=RegExp(`^ {0,3}${b(o)}{${a.length},}[ \\t]*(?:\\r?\\n|$)`,`gm`);l.lastIndex=c;let u=l.exec(e),d=s.split(/\s+/)[0]||null;if(!u){t.push({start:r.index,end:e.length,codeStart:c,codeEnd:e.length,indent:i,language:d,complete:!1});break}t.push({start:r.index,end:l.lastIndex,codeStart:c,codeEnd:u.index,indent:i,language:d,complete:!0}),n.lastIndex=l.lastIndex}return t}function S(e){return/<(?:html|head|body)(?:\s|>)|<\/(?:head|body|html)\s*>/i.test(e)}function C(e,t){return e.start<t.end&&t.start<e.end}function w(e,t){let n=/^( {0,3})(<!doctype\s+html(?:\s|>|$)|<html(?:\s[^>\n\r]*)?>)/gim,r;for(;r=n.exec(e);){let n=r.index+r[1].length;if(t.some(e=>n>=e.start&&n<e.end))continue;let i=e.slice(n);if(!S(i.slice(r[2].length)))continue;let a=/<\/html\s*>/i.exec(i),o=a?n+a.index+a[0].length:e.length;return{start:r.index,end:o,codeStart:n,codeEnd:o,indent:0,language:`html`,complete:!!a}}return null}function T(e){let t=x(e),n=w(e,t);return n?[...t.filter(e=>!C(e,n)),n].sort((e,t)=>e.start-t.start):t}function E(e,t){return t===0?e:e.replace(RegExp(`^ {1,${t}}`,`gm`),``)}function D(e){return y.some(t=>t.test(e))}function O(e){let t=[],n=T(e),r=0;for(let i of n){let n=e.slice(r,i.start);n&&t.push({type:`text`,content:n}),t.push({type:`code`,language:i.language,content:E(e.slice(i.codeStart,i.codeEnd),i.indent),complete:i.complete}),r=i.end}let i=e.slice(r);return(i||t.length===0)&&t.push({type:`text`,content:i}),t}function k(e){let t=e=>e.replace(/\\\[([\s\S]*?)\\\]/g,(e,t)=>`$$${t}$$`).replace(/\\\(([\s\S]*?)\\\)/g,(e,t)=>`$${t}$`),n=e=>{let n=/`[^`\n]+`/g,r=``,i=0,a;for(;a=n.exec(e);)r+=t(e.slice(i,a.index)),r+=a[0],i=n.lastIndex;return r+t(e.slice(i))},r=x(e),i=``,a=0;for(let t of r)i+=n(e.slice(a,t.start)),i+=e.slice(t.start,t.end),a=t.end;return i+=n(e.slice(a)),i}var A=n(),j=r(`components:ui:message-code-block`),M=24,N={bash:`sh`,c:`c`,cpp:`cpp`,csharp:`cs`,css:`css`,go:`go`,html:`html`,htm:`html`,java:`java`,javascript:`js`,js:`js`,json:`json`,jsx:`jsx`,kotlin:`kt`,markdown:`md`,mermaid:`mmd`,php:`php`,python:`py`,py:`py`,ruby:`rb`,rust:`rs`,sh:`sh`,shell:`sh`,sql:`sql`,svg:`svg`,swift:`swift`,toml:`toml`,ts:`ts`,tsx:`tsx`,typescript:`ts`,xml:`xml`,yaml:`yaml`,yml:`yaml`,zsh:`sh`};function P(e,t){let n=(e||``).toLowerCase();if(n===`html`||n===`htm`)return`html`;if(n===`svg`)return`svg`;if(n===`mermaid`)return`mermaid`;let r=t.slice(0,500).toLowerCase();return(!n||n===`xml`)&&r.includes(`<svg`)?`svg`:!n&&(r.includes(`<!doctype html`)||r.includes(`<html`))?`html`:null}function F({code:e,language:t,state:n,children:r}){let{t:h}=i(),g=p(e=>e.openArtifactPanel),[_,y]=m.useState(null),[b,x]=m.useState(null),S=m.useRef(null),C=_===e,w=t||`text`,T=h(C?`artifacts.copied`:`artifacts.copy`),E=`${T}: ${w}`,D=m.useMemo(()=>e?e.split(`
2
+ `).length:0,[e]),O=b===null?n===`complete`&&D>M:!b,k=n===`complete`?P(t,e):null;return m.useEffect(()=>()=>{S.current!==null&&window.clearTimeout(S.current)},[]),(0,A.jsxs)(`div`,{dir:`ltr`,"data-testid":`code-block`,"data-state":n,"data-language":w,"data-collapsed":O,className:`group relative my-4 overflow-hidden rounded-xl border border-line bg-surface-subtle text-left text-ink shadow-[0_12px_32px_rgba(13,17,23,0.1)] dark:border-white/10 dark:bg-dark-50 dark:text-dark-900 dark:shadow-[0_12px_32px_rgba(13,17,23,0.16)]`,children:[(0,A.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b border-line bg-surface-raised/70 px-3.5 dark:border-white/10 dark:bg-white/[0.035]`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,A.jsx)(o,{className:`h-3.5 w-3.5 shrink-0 text-ink-subtle dark:text-dark-500`}),(0,A.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium lowercase tracking-[-0.01em] text-ink-muted dark:text-dark-700`,children:w})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[n===`streaming`&&(0,A.jsx)(`span`,{role:`status`,"aria-label":h(`common.loading`),className:`flex h-7 w-7 items-center justify-center`,children:(0,A.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-primary-400`})}),D>M&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>x(O),className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-900`,title:h(O?`artifacts.expand`:`artifacts.collapse`),"aria-label":h(O?`artifacts.expand`:`artifacts.collapse`),"aria-expanded":!O,children:O?(0,A.jsx)(l,{className:`h-3.5 w-3.5`}):(0,A.jsx)(u,{className:`h-3.5 w-3.5`})}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{if(!e)return;let n=N[(t||``).toLowerCase()]||`txt`,r=new Blob([e],{type:`text/plain;charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`snippet.${n}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)},disabled:!e,className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 disabled:cursor-default disabled:opacity-35 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-900`,title:h(`common.download`),"aria-label":`${h(`common.download`)}: ${w}`,children:(0,A.jsx)(c,{className:`h-3.5 w-3.5`})}),k&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{if(!k||!e)return;let t=Date.now();g({id:a(),type:k,title:`${w} ${h(`artifacts.preview`)}`,content:e,language:w,createdAt:t,updatedAt:t})},className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-900`,title:h(`artifacts.preview`),"aria-label":`${h(`artifacts.preview`)}: ${w}`,children:(0,A.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,A.jsx)(`button`,{type:`button`,onClick:async()=>{if(e)try{await navigator.clipboard.writeText(e),v(`success`),y(e),S.current!==null&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{y(null),S.current=null},2e3)}catch(e){j.error(`Failed to copy code:`,e)}},disabled:!e,className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 disabled:cursor-default disabled:opacity-35 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-900`,title:T,"aria-label":E,children:C?(0,A.jsx)(d,{className:`h-3.5 w-3.5 text-green-400`}):(0,A.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,A.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:C?E:``})]})]}),O?(0,A.jsx)(`button`,{type:`button`,onClick:()=>x(!0),className:`block w-full px-3.5 py-2.5 text-left font-mono text-[11px] italic text-ink-subtle transition-colors hover:bg-surface-raised/70 hover:text-ink dark:text-dark-500 dark:hover:bg-white/[0.035] dark:hover:text-dark-900`,children:h(`chatMessage.hiddenLines`,{count:D})}):r]})}var I=`rgb(var(--color-dark-50))`,L=`rgb(var(--color-surface-subtle))`,R=`max-h-[60vh] min-h-12 overflow-auto bg-surface-subtle p-4 text-left font-mono text-[14px] leading-6 text-ink whitespace-pre tabular-nums dark:bg-dark-50 dark:text-dark-900`,z={maxHeight:`60vh`,minHeight:`3rem`,overflow:`auto`,padding:`1rem`,fontSize:`14px`,lineHeight:`1.5rem`,fontFamily:`"JetBrains Mono", ui-monospace, SFMono-Regular, monospace`,whiteSpace:`pre`};export{F as a,D as c,z as i,v as l,L as n,O as o,R as r,k as s,I as t};