tarsk 0.6.88 → 0.6.89

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 (96) hide show
  1. package/README.md +63 -24
  2. package/dist/index.js +787 -738
  3. package/dist/node_modules/@libsql/darwin-x64/README.md +3 -0
  4. package/dist/node_modules/@libsql/{darwin-arm64 → darwin-x64}/index.node +0 -0
  5. package/dist/node_modules/@libsql/{darwin-arm64 → darwin-x64}/package.json +6 -6
  6. package/dist/public/assets/api-8Rp2LlXt.js +1 -0
  7. package/dist/public/assets/api-Cp9I7CxD.js +2 -0
  8. package/dist/public/assets/{async-error-boundary-FT8_xvjy.js → async-error-boundary-CFVUPiuG.js} +1 -1
  9. package/dist/public/assets/{browser-tab-DCjHytQ8.js → browser-tab-CPPorbL6.js} +2 -2
  10. package/dist/public/assets/{chat-dock-context-a2bV9cnz.js → chat-dock-context-DbiJNr3O.js} +1 -1
  11. package/dist/public/assets/chat-handlers-context-DYU2LQ5V.js +9 -0
  12. package/dist/public/assets/{commit-dialog-C1oUFznJ.js → commit-dialog-DPaci3dp.js} +1 -1
  13. package/dist/public/assets/{commit-error-dialog--NTHg7Aw.js → commit-error-dialog-Dnlkgb_H.js} +1 -1
  14. package/dist/public/assets/{conversation-history-view-CdfE7JTD.js → conversation-history-view-CqIugfyO.js} +1 -1
  15. package/dist/public/assets/{create-project-dialog-BdR6iQE9.js → create-project-dialog-DStWPoDE.js} +2 -2
  16. package/dist/public/assets/{create-project-workspace-DSTTGom_.js → create-project-workspace-CJ94yHAB.js} +2 -2
  17. package/dist/public/assets/{create-repo-dialog-gw-8Rpdm.js → create-repo-dialog-B_QiEz-v.js} +1 -1
  18. package/dist/public/assets/diff-view-4koPcOcE.js +4 -0
  19. package/dist/public/assets/{explorer-file-drop-CzyAqZgf.js → explorer-file-drop-DAP7ha-E.js} +1 -1
  20. package/dist/public/assets/explorer-tab-view-Bt9hRZUm.js +2 -0
  21. package/dist/public/assets/explorer-tree-CAs89lPz.js +1 -0
  22. package/dist/public/assets/{explorer-view-Daxl93oM.js → explorer-view-B1JuejkU.js} +2 -2
  23. package/dist/public/assets/index-CcAwxnT5.js +97 -0
  24. package/dist/public/assets/index-dNrgKdYv.css +1 -0
  25. package/dist/public/assets/{markdown-renderer-D2VcKU4g.js → markdown-renderer-DQONI6WG.js} +3 -3
  26. package/dist/public/assets/{mcp-manager-D1HmLT3t.js → mcp-manager-D2FG-h2e.js} +1 -1
  27. package/dist/public/assets/{model-list-controls-rXmaDp2r.js → model-list-controls-B6ofHWh3.js} +1 -1
  28. package/dist/public/assets/{onboarding-dialog-DSqBJyBa.js → onboarding-dialog-DAut3X4K.js} +1 -1
  29. package/dist/public/assets/{pill-tabs-DtdTmrg7.js → pill-tabs-BAhOHad7.js} +1 -1
  30. package/dist/public/assets/{project-coding-view-DP4qKePE.js → project-coding-view-B2FpHeiO.js} +1 -1
  31. package/dist/public/assets/{project-danger-zone-view-CGxIenpr.js → project-danger-zone-view-BqP1dcRT.js} +1 -1
  32. package/dist/public/assets/{project-env-vars-view-DKyQkh7h.js → project-env-vars-view-zhigkQFG.js} +1 -1
  33. package/dist/public/assets/{project-model-aliases-view-BewwJZAx.js → project-model-aliases-view-APAVFfym.js} +1 -1
  34. package/dist/public/assets/{project-settings-view-CE4nAz5B.js → project-settings-view-FnK-LRsv.js} +1 -1
  35. package/dist/public/assets/project-tools-view-Dmp5ViRC.js +1 -0
  36. package/dist/public/assets/providers-list-view-Clbp73Hh.js +1 -0
  37. package/dist/public/assets/{pull-request-dialog-nKYATjbm.js → pull-request-dialog-D40BQPMk.js} +1 -1
  38. package/dist/public/assets/{pull-with-changes-dialog-zzoFzCv4.js → pull-with-changes-dialog-pkXK-VP2.js} +1 -1
  39. package/dist/public/assets/query-keys-CcnonAAG.js +1 -0
  40. package/dist/public/assets/{remote-media-url-CyuN31H_.js → remote-media-url-C-GdJb-D.js} +1 -1
  41. package/dist/public/assets/{scroll-area-CGEZ1gAL.js → scroll-area-DGF9wUqQ.js} +1 -1
  42. package/dist/public/assets/{select-BR2pG61R.js → select-DMcNYwgt.js} +1 -1
  43. package/dist/public/assets/{settings-general-tabs-view-BWR0UX2P.js → settings-general-tabs-view-DBZQbihJ.js} +2 -2
  44. package/dist/public/assets/settings-general-view-0dhBET2R.js +1 -0
  45. package/dist/public/assets/{settings-list-Dgip9HpD.js → settings-list-Co3JPr9w.js} +1 -1
  46. package/dist/public/assets/{settings-logs-view-CS29x4VT.js → settings-logs-view-DvHXUDko.js} +2 -2
  47. package/dist/public/assets/settings-mcp-servers-view-414Dt5py.js +5 -0
  48. package/dist/public/assets/{settings-models-view-DS7nm54P.js → settings-models-view-ByeR7Enb.js} +1 -1
  49. package/dist/public/assets/{settings-plugins-view-avaUE36r.js → settings-plugins-view-8te2MPyh.js} +2 -2
  50. package/dist/public/assets/{settings-providers-view-B39k1iRQ.js → settings-providers-view-BAuv9gam.js} +2 -2
  51. package/dist/public/assets/{settings-remote-machines-view-BXondQG_.js → settings-remote-machines-view-CHyywazU.js} +1 -1
  52. package/dist/public/assets/{settings-setup-view-I5MGUi_D.js → settings-setup-view-Btp46Vh_.js} +2 -2
  53. package/dist/public/assets/{settings-skills-view-BKrUABbi.js → settings-skills-view-BNVx4bZl.js} +2 -2
  54. package/dist/public/assets/{settings-slack-view-B0p-96GC.js → settings-slack-view-Caly5yGt.js} +1 -1
  55. package/dist/public/assets/settings-slash-commands-view-m6mp1knu.js +1 -0
  56. package/dist/public/assets/{settings-statistics-view-B3g6BD7p.js → settings-statistics-view-BnOxr4sZ.js} +1 -1
  57. package/dist/public/assets/settings-storage-view-Dg8xfpTG.js +1 -0
  58. package/dist/public/assets/{settings-subagents-view-BziLwvNq.js → settings-subagents-view-CucwEk2A.js} +1 -1
  59. package/dist/public/assets/{settings-system-prompt-view-BqAk56cD.js → settings-system-prompt-view-CEDU2saT.js} +1 -1
  60. package/dist/public/assets/{settings-tab-bar-DYzU_lmi.js → settings-tab-bar-CdIbQ0WI.js} +1 -1
  61. package/dist/public/assets/settings-view-XcJhRclT.js +2 -0
  62. package/dist/public/assets/task-utils-Cnq9Eszt.js +1 -0
  63. package/dist/public/assets/tasks-view-B8_jkq_a.js +1 -0
  64. package/dist/public/assets/{terminal-panel-Bm_ZelN-.js → terminal-panel-xoLVfA-h.js} +1 -1
  65. package/dist/public/assets/{use-account-settings-query-C-zOdREq.js → use-account-settings-query-D_qL1I4w.js} +1 -1
  66. package/dist/public/assets/{use-active-dock-panel-instance-4Ss8lB9K.js → use-active-dock-panel-instance-kmJOnmL7.js} +1 -1
  67. package/dist/public/assets/use-git-check-BD9gdXpK.js +1 -0
  68. package/dist/public/assets/{use-installed-ai-files-DQey9Zm3.js → use-installed-ai-files-Nn-sN_V2.js} +1 -1
  69. package/dist/public/assets/{use-open-chat-dock-panel-DqfWJ8e8.js → use-open-chat-dock-panel-CXzpgxVs.js} +1 -1
  70. package/dist/public/assets/use-projects-B0xTjTaA.js +2 -0
  71. package/dist/public/assets/{web-CGP-jEpi.js → web-C1tBQoCB.js} +1 -1
  72. package/dist/public/assets/{web-CKC9gpFi.js → web-cJXG33sT.js} +1 -1
  73. package/dist/public/index.html +18 -18
  74. package/package.json +4 -4
  75. package/dist/node_modules/@libsql/darwin-arm64/README.md +0 -3
  76. package/dist/public/assets/account-view-DkuCOxkE.js +0 -1
  77. package/dist/public/assets/api-B_GSyYGh.js +0 -1
  78. package/dist/public/assets/api-C4ukGdyH.js +0 -2
  79. package/dist/public/assets/chat-handlers-context-2xSKzkKa.js +0 -9
  80. package/dist/public/assets/diff-view-B6JJNyn1.js +0 -4
  81. package/dist/public/assets/explorer-tab-view-CiUPh4uK.js +0 -2
  82. package/dist/public/assets/explorer-tree-BA12VLz_.js +0 -1
  83. package/dist/public/assets/index-CoY8DilQ.js +0 -97
  84. package/dist/public/assets/index-D14wLW4o.css +0 -1
  85. package/dist/public/assets/project-tools-view-CbDfst02.js +0 -1
  86. package/dist/public/assets/providers-list-view-BtwccvX2.js +0 -1
  87. package/dist/public/assets/query-keys-BwswkbMn.js +0 -1
  88. package/dist/public/assets/settings-general-view-BhtrDmJH.js +0 -1
  89. package/dist/public/assets/settings-mcp-servers-view-B5ithpfh.js +0 -5
  90. package/dist/public/assets/settings-slash-commands-view-DA1scWv1.js +0 -1
  91. package/dist/public/assets/settings-storage-view-BJvjhI4f.js +0 -1
  92. package/dist/public/assets/settings-view-zjMs7jNe.js +0 -2
  93. package/dist/public/assets/task-utils-BZPVmvY4.js +0 -1
  94. package/dist/public/assets/tasks-view-wFf77AQX.js +0 -1
  95. package/dist/public/assets/use-git-check-CumqGAvN.js +0 -1
  96. package/dist/public/assets/use-projects-CizIH2Fa.js +0 -2
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/providers-list-view-BtwccvX2.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/react-vendor-D61Uve5n.js","assets/chunk-QFMPRPBF-Cy-_pFSM.js","assets/dist-v_MvKS2-.js","assets/store-W78TGOIO.js","assets/utils-CqsIXqSC.js","assets/api-C4ukGdyH.js","assets/loader-circle-CrqRIqdA.js","assets/createLucideIcon-2A3hmV_e.js","assets/x-ByOPrz5I.js","assets/button-DDaJhJP1.js","assets/tooltip-CqwCZ7wt.js","assets/dist-AbkJBHH5.js","assets/dist-2xH_pFmV.js","assets/progress-indicator-hJ74ac5W.js","assets/suspense-resource-DzlMlIgR.js","assets/use-suspense-resource-uCX26gOk.js","assets/index-CoY8DilQ.js","assets/useBaseQuery-yghQO052.js","assets/QueryClientProvider-CYXTUmYo.js","assets/useInfiniteQuery-BpKy1sCq.js","assets/use-account-settings-query-C-zOdREq.js","assets/useQuery-DWt09r77.js","assets/query-keys-BwswkbMn.js","assets/chat-handlers-context-2xSKzkKa.js","assets/create-project-workspace-DSTTGom_.js","assets/terminal-output-activity-D_FxlE-L.js","assets/task-utils-BZPVmvY4.js","assets/random-uuid-Dc3UrwVo.js","assets/use-toast-CKgZ8YeP.js","assets/remote-media-url-CyuN31H_.js","assets/use-open-chat-dock-panel-DqfWJ8e8.js","assets/chat-dock-context-a2bV9cnz.js","assets/explorer-tab-context-BwR8CM8l.js","assets/main-tab-context-Dsp4OYi9.js","assets/dist-CgbWuuq4.js","assets/markdown-renderer-D2VcKU4g.js","assets/explorer-media-CRzhs0NW.js","assets/check-skFQ1X72.js","assets/copy-bi9iX3xn.js","assets/download-CWhQNGlF.js","assets/external-link-Dcikmdm_.js","assets/minus-CgQcbBQT.js","assets/dialog-D_12AsZd.js","assets/dist-DfnQ9YJh.js","assets/es2015-eNVkKfFF.js","assets/use-browser-overlay-block-CO1pUEAZ.js","assets/play-Dn1mbRpD.js","assets/plus-DoMzejDu.js","assets/rotate-ccw-Dthg8Pv6.js","assets/chevron-down-Bpo4ncEN.js","assets/chevron-right-Dga3q1bZ.js","assets/chevron-up-BxgjX7B3.js","assets/circle-alert-CC2eO3yt.js","assets/circle-DQwOli2u.js","assets/grip-vertical-_jCIw8Mw.js","assets/square-CtxvwmM2.js","assets/dist-B-h6Wj39.js","assets/label-BCs5CZEs.js","assets/dist-Dx8OsX8-.js","assets/dist-pCVg1Jdl.js","assets/dist-DOz2WXwX.js","assets/dist-JGbQ_EJY.js","assets/scroll-area-CGEZ1gAL.js","assets/alert-dialog-BcZULJsX.js","assets/use-projects-CizIH2Fa.js","assets/explorer-file-drop-CzyAqZgf.js","assets/api-B_GSyYGh.js","assets/dist-CkGJjZXY.js","assets/select-BR2pG61R.js","assets/mcp-manager-D1HmLT3t.js","assets/index-D14wLW4o.css","assets/async-error-boundary-FT8_xvjy.js","assets/card-DAc45J1v.js","assets/sorting-DqwxPMRN.js","assets/pending-changes-Bn-0ak1d.js","assets/settings-list-Dgip9HpD.js","assets/use-deferred-search-xgS_2fMW.js","assets/model-list-controls-rXmaDp2r.js","assets/settings-models-view-DS7nm54P.js","assets/table-CQMqIW_-.js","assets/toggle-group-CPmseZfb.js","assets/commit-method-fields-Xt3vbwUg.js","assets/project-model-aliases-view-BewwJZAx.js","assets/use-settings-page-loading-B5WU5d1c.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,o as n,r,t as i}from"./react-vendor-D61Uve5n.js";import{o as a,s as o}from"./chunk-QFMPRPBF-Cy-_pFSM.js";import"./dist-v_MvKS2-.js";import{t as s}from"./progress-indicator-hJ74ac5W.js";import{t as c}from"./settings-tab-bar-DYzU_lmi.js";import{o as l,s as u}from"./settings-view-zjMs7jNe.js";var d=t(),f=e(n(),1),p=i(),m=(0,f.lazy)(function(){return r(()=>import(`./providers-list-view-BtwccvX2.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79]))}),h=(0,f.lazy)(function(){return r(()=>import(`./settings-models-view-DS7nm54P.js`),__vite__mapDeps([80,1,2,4,5,6,7,11,12,13,14,15,16,17,18,3,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,9,40,41,42,43,44,10,45,46,47,48,49,50,51,52,53,54,55,56,8,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,81,82,83,73,74,75,77,78,79]))}),g=(0,f.lazy)(function(){return r(()=>import(`./project-model-aliases-view-BewwJZAx.js`),__vite__mapDeps([84,1,2,22,19,20,23,4,7,24,6,11,30,70,39,9,51,53,13,14,12,46,62,60,64,69,18,3,21,5,25,26,27,28,16,29,31,32,33,34,35,36,37,38,40,41,42,43,44,10,45,47,48,49,50,52,54,55,56,8,57,58,59,61,63,15,65,66,17,67,68,71,72,81,85]))});function _(e){let t=(0,d.c)(22),{fallbackTab:n}=e,r=n===void 0?`providers`:n,i=a(),_=o(),v;t[0]!==r||t[1]!==i?(v=r===`providers`?u(i.pathname)??r:r,t[0]=r,t[1]=i,t[2]=v):v=t[2];let y=v,b;t[3]===_?b=t[4]:(b=function(e){_(`/settings/${e}`)},t[3]=_,t[4]=b);let x=b,S;t[5]!==y||t[6]!==x?(S=(0,p.jsx)(c,{value:y,onValueChange:x,options:l}),t[5]=y,t[6]=x,t[7]=S):S=t[7];let C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,p.jsx)(s,{centered:!0,label:`Loading provider settings...`}),t[8]=C):C=t[8];let w;t[9]===y?w=t[10]:(w=y===`providers`&&(0,p.jsx)(m,{}),t[9]=y,t[10]=w);let T;t[11]===y?T=t[12]:(T=y===`models`&&(0,p.jsx)(h,{}),t[11]=y,t[12]=T);let E;t[13]===y?E=t[14]:(E=y===`model-aliases`&&(0,p.jsx)(g,{}),t[13]=y,t[14]=E);let D;t[15]!==w||t[16]!==T||t[17]!==E?(D=(0,p.jsx)(`div`,{className:`min-h-0 flex-1`,role:`region`,"aria-label":`Provider settings`,children:(0,p.jsxs)(f.Suspense,{fallback:C,children:[w,T,E]})}),t[15]=w,t[16]=T,t[17]=E,t[18]=D):D=t[18];let O;return t[19]!==S||t[20]!==D?(O=(0,p.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[S,D]}),t[19]=S,t[20]=D,t[21]=O):O=t[21],O}export{_ as default};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/providers-list-view-Clbp73Hh.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/react-vendor-D61Uve5n.js","assets/chunk-QFMPRPBF-Cy-_pFSM.js","assets/dist-v_MvKS2-.js","assets/store-W78TGOIO.js","assets/utils-CqsIXqSC.js","assets/api-Cp9I7CxD.js","assets/loader-circle-CrqRIqdA.js","assets/createLucideIcon-2A3hmV_e.js","assets/x-ByOPrz5I.js","assets/button-DDaJhJP1.js","assets/tooltip-CqwCZ7wt.js","assets/dist-AbkJBHH5.js","assets/dist-2xH_pFmV.js","assets/progress-indicator-hJ74ac5W.js","assets/suspense-resource-DzlMlIgR.js","assets/use-suspense-resource-uCX26gOk.js","assets/index-CcAwxnT5.js","assets/useBaseQuery-yghQO052.js","assets/QueryClientProvider-CYXTUmYo.js","assets/useInfiniteQuery-BpKy1sCq.js","assets/use-account-settings-query-D_qL1I4w.js","assets/useQuery-DWt09r77.js","assets/query-keys-CcnonAAG.js","assets/chat-handlers-context-DYU2LQ5V.js","assets/create-project-workspace-CJ94yHAB.js","assets/terminal-output-activity-D_FxlE-L.js","assets/task-utils-Cnq9Eszt.js","assets/random-uuid-Dc3UrwVo.js","assets/use-toast-CKgZ8YeP.js","assets/remote-media-url-C-GdJb-D.js","assets/use-open-chat-dock-panel-CXzpgxVs.js","assets/chat-dock-context-DbiJNr3O.js","assets/explorer-tab-context-BwR8CM8l.js","assets/main-tab-context-Dsp4OYi9.js","assets/dist-CgbWuuq4.js","assets/markdown-renderer-DQONI6WG.js","assets/explorer-media-CRzhs0NW.js","assets/check-skFQ1X72.js","assets/copy-bi9iX3xn.js","assets/download-CWhQNGlF.js","assets/external-link-Dcikmdm_.js","assets/minus-CgQcbBQT.js","assets/dialog-D_12AsZd.js","assets/dist-DfnQ9YJh.js","assets/es2015-eNVkKfFF.js","assets/use-browser-overlay-block-CO1pUEAZ.js","assets/play-Dn1mbRpD.js","assets/plus-DoMzejDu.js","assets/rotate-ccw-Dthg8Pv6.js","assets/chevron-down-Bpo4ncEN.js","assets/chevron-right-Dga3q1bZ.js","assets/chevron-up-BxgjX7B3.js","assets/circle-alert-CC2eO3yt.js","assets/circle-DQwOli2u.js","assets/grip-vertical-_jCIw8Mw.js","assets/square-CtxvwmM2.js","assets/dist-B-h6Wj39.js","assets/label-BCs5CZEs.js","assets/dist-Dx8OsX8-.js","assets/dist-pCVg1Jdl.js","assets/dist-DOz2WXwX.js","assets/dist-JGbQ_EJY.js","assets/scroll-area-DGF9wUqQ.js","assets/alert-dialog-BcZULJsX.js","assets/use-projects-B0xTjTaA.js","assets/explorer-file-drop-DAP7ha-E.js","assets/api-8Rp2LlXt.js","assets/dist-CkGJjZXY.js","assets/select-DMcNYwgt.js","assets/mcp-manager-D2FG-h2e.js","assets/index-dNrgKdYv.css","assets/async-error-boundary-CFVUPiuG.js","assets/card-DAc45J1v.js","assets/sorting-DqwxPMRN.js","assets/pending-changes-Bn-0ak1d.js","assets/settings-list-Co3JPr9w.js","assets/use-deferred-search-xgS_2fMW.js","assets/model-list-controls-B6ofHWh3.js","assets/settings-models-view-ByeR7Enb.js","assets/table-CQMqIW_-.js","assets/toggle-group-CPmseZfb.js","assets/commit-method-fields-Xt3vbwUg.js","assets/project-model-aliases-view-APAVFfym.js","assets/use-settings-page-loading-B5WU5d1c.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,o as n,r,t as i}from"./react-vendor-D61Uve5n.js";import{o as a,s as o}from"./chunk-QFMPRPBF-Cy-_pFSM.js";import"./dist-v_MvKS2-.js";import{t as s}from"./progress-indicator-hJ74ac5W.js";import{t as c}from"./settings-tab-bar-CdIbQ0WI.js";import{o as l,s as u}from"./settings-view-XcJhRclT.js";var d=t(),f=e(n(),1),p=i(),m=(0,f.lazy)(function(){return r(()=>import(`./providers-list-view-Clbp73Hh.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79]))}),h=(0,f.lazy)(function(){return r(()=>import(`./settings-models-view-ByeR7Enb.js`),__vite__mapDeps([80,1,2,4,5,6,7,11,12,13,14,15,16,17,18,3,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,9,40,41,42,43,44,10,45,46,47,48,49,50,51,52,53,54,55,56,8,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,81,82,83,73,74,75,77,78,79]))}),g=(0,f.lazy)(function(){return r(()=>import(`./project-model-aliases-view-APAVFfym.js`),__vite__mapDeps([84,1,2,22,19,20,23,4,7,24,6,11,30,70,39,9,51,53,13,14,12,46,62,60,64,69,18,3,21,5,25,26,27,28,16,29,31,32,33,34,35,36,37,38,40,41,42,43,44,10,45,47,48,49,50,52,54,55,56,8,57,58,59,61,63,15,65,66,17,67,68,71,72,81,85]))});function _(e){let t=(0,d.c)(22),{fallbackTab:n}=e,r=n===void 0?`providers`:n,i=a(),_=o(),v;t[0]!==r||t[1]!==i?(v=r===`providers`?u(i.pathname)??r:r,t[0]=r,t[1]=i,t[2]=v):v=t[2];let y=v,b;t[3]===_?b=t[4]:(b=function(e){_(`/settings/${e}`)},t[3]=_,t[4]=b);let x=b,S;t[5]!==y||t[6]!==x?(S=(0,p.jsx)(c,{value:y,onValueChange:x,options:l}),t[5]=y,t[6]=x,t[7]=S):S=t[7];let C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,p.jsx)(s,{centered:!0,label:`Loading provider settings...`}),t[8]=C):C=t[8];let w;t[9]===y?w=t[10]:(w=y===`providers`&&(0,p.jsx)(m,{}),t[9]=y,t[10]=w);let T;t[11]===y?T=t[12]:(T=y===`models`&&(0,p.jsx)(h,{}),t[11]=y,t[12]=T);let E;t[13]===y?E=t[14]:(E=y===`model-aliases`&&(0,p.jsx)(g,{}),t[13]=y,t[14]=E);let D;t[15]!==w||t[16]!==T||t[17]!==E?(D=(0,p.jsx)(`div`,{className:`min-h-0 flex-1`,role:`region`,"aria-label":`Provider settings`,children:(0,p.jsxs)(f.Suspense,{fallback:C,children:[w,T,E]})}),t[15]=w,t[16]=T,t[17]=E,t[18]=D):D=t[18];let O;return t[19]!==S||t[20]!==D?(O=(0,p.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[S,D]}),t[19]=S,t[20]=D,t[21]=O):O=t[21],O}export{_ as default};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,o as n,t as r}from"./react-vendor-D61Uve5n.js";import{a as i,i as a,l as o,n as s,o as c,t as l}from"./use-account-settings-query-C-zOdREq.js";import{n as u}from"./QueryClientProvider-CYXTUmYo.js";import{U as d,x as f}from"./dist-v_MvKS2-.js";import{F as p,Ui as m,_a as h,an as g,gr as _,la as v,li as y,ma as b,n as x,sn as S}from"./api-C4ukGdyH.js";import{t as C}from"./utils-CqsIXqSC.js";import{t as w}from"./check-skFQ1X72.js";import{t as T}from"./copy-bi9iX3xn.js";import{t as E}from"./loader-circle-CrqRIqdA.js";import{a as D,i as O,o as k,r as A,s as j,t as M}from"./dialog-D_12AsZd.js";import{t as N}from"./plus-DoMzejDu.js";import{t as P}from"./x-ByOPrz5I.js";import{t as F}from"./button-DDaJhJP1.js";import{i as I,n as ee,t as L}from"./tooltip-CqwCZ7wt.js";import{t as R}from"./label-BCs5CZEs.js";import{t as te}from"./use-toast-CKgZ8YeP.js";import{a as z,c as ne,i as B,n as V,o as H,r as U,s as W,t as G}from"./alert-dialog-BcZULJsX.js";import{$n as K,Bt as q,G as re,Ht as J,Mr as Y,Vt as ie,Wn as ae,at as oe,dn as se,dt as ce,fn as le,gn as X,gt as ue,j as de,lt as fe,mn as pe,nt as me,o as he,pn as ge,pt as _e}from"./index-CoY8DilQ.js";import{t as ve}from"./use-settings-page-loading-B5WU5d1c.js";var Z=t(),Q=e(n(),1),ye=f(`app.use-local-machine-name.hook`);function be(){let e=(0,Z.c)(12),{data:t,isLoading:n}=a(),r=i(),o=t?.machineName??``,[s,c]=(0,Q.useState)(``),l,u;e[0]===o?(l=e[1],u=e[2]):(l=function(){o&&c(o)},u=[o],e[0]=o,e[1]=l,e[2]=u),(0,Q.useEffect)(l,u);let d;e[3]!==s||e[4]!==o||e[5]!==r?(d=async function(){let e=s.trim();if(!e||e===o){c(o);return}try{let t=await r.mutateAsync({machineName:e});c(t.machineName)}catch(e){let t=e;throw ye.error(`Failed to update machine name:`,t),c(o),t}},e[3]=s,e[4]=o,e[5]=r,e[6]=d):d=e[6];let f=d,p;return e[7]!==s||e[8]!==n||e[9]!==f||e[10]!==r.isPending?(p={draftMachineName:s,isLoading:n,isSaving:r.isPending,setDraftMachineName:c,saveDraftMachineName:f},e[7]=s,e[8]=n,e[9]=f,e[10]=r.isPending,e[11]=p):p=e[11],p}var xe=f(`app.use-remote-machines.hook`);function Se(e){return[...e].sort(function(e,t){let n=e.machineName.localeCompare(t.machineName,void 0,{sensitivity:`base`});return n===0?e.publicUrl.localeCompare(t.publicUrl):n})}function Ce(e){let t={};for(let n of e)t[n.id]=n.machineName;return t}function we(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)({}),[i,a]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(()=>new Set);(0,Q.useEffect)(()=>{let e=!1;async function n(){try{let n=await g();e||(t(n.remoteMachines),r(Ce(n.remoteMachines)))}catch(e){xe.error(`Failed to load remote machines:`,e)}finally{e||a(!1)}}return n(),()=>{e=!0}},[]);async function c(e){let n=(await x(e)).remoteMachine;return t(e=>Se([...e,n])),r(e=>({...e,[n.id]:n.machineName})),n}async function l(e){await p(e),t(t=>t.filter(t=>t.id!==e)),r(t=>{let n={...t};return delete n[e],n})}function u(e,t){r(n=>({...n,[e]:t}))}async function d(r){let i=e.find(e=>e.id===r),a=(n[r]??``).trim();if(i){if(!a||a===i.machineName){u(r,i.machineName);return}s(e=>new Set(e).add(r));try{let e=await _(r,a);t(t=>Se(t.map(t=>t.id===r?e.remoteMachine:t))),u(r,e.remoteMachine.machineName)}catch(e){throw xe.error(`Failed to update remote machine name:`,e),u(r,i.machineName),e}finally{s(e=>{let t=new Set(e);return t.delete(r),t})}}}function f(e){return o.has(e)}return{addMachine:c,draftNames:n,isLoading:i,isSavingId:f,remoteMachines:e,removeMachine:l,saveDraftName:d,setDraftName:u}}var Te=f(`app.use-server-bind-mode.hook`),Ee=`local`,De=`tarsk-server-bind-mode-changed`;function Oe(e){v(e)}function ke(){if(typeof window>`u`)return!1;try{return sessionStorage.getItem(De)===`true`}catch{return!1}}function Ae(e){if(typeof window<`u`)try{e?sessionStorage.setItem(De,`true`):sessionStorage.removeItem(De)}catch{}}function je(e){let t=(0,Z.c)(4),[n,r]=(0,Q.useState)(null),i,a;return t[0]!==n||t[1]!==e?(i=function(){e!==void 0&&n===null&&r(e)},a=[n,e],t[0]=n,t[1]=e,t[2]=i,t[3]=a):(i=t[2],a=t[3]),(0,Q.useEffect)(i,a),n}function Me(e,t){let n=(0,Z.c)(4),r,i;n[0]!==t||n[1]!==e?(r=function(){e!==void 0&&t!==void 0&&Oe({networkAddresses:t,serverBindMode:e})},i=[t,e],n[0]=t,n[1]=e,n[2]=r,n[3]=i):(r=n[2],i=n[3]),(0,Q.useEffect)(r,i)}function Ne(e,t){let{serverBindMode:n=Ee}=t??{},{serverBindMode:r=n}=e??{};return r}function Pe(e,t){let{networkAddresses:n=[]}=t??{},{networkAddresses:r=n}=e??{};return r}function Fe(e){let{tunnelUrl:t=null,tunnelStatus:n=`off`,tunnelError:r=null}=e??{};return{tunnelUrl:t,tunnelStatus:n,tunnelError:r}}function Ie(e,t,n,r){return{serverBindMode:Ne(e,t),networkAddresses:Pe(e,t),...Fe(e),isLoading:n||r&&t===null}}function Le(e){let t=(0,Z.c)(8),n=(0,Q.useSyncExternalStore)(ie,q,Re),r=J(),i=r&&n,a,o;t[0]!==r||t[1]!==e?(a=function(){if(r)return de(function(t){t===`tunnel`&&s(e).catch(function(){})})},o=[r,e],t[0]=r,t[1]=e,t[2]=a,t[3]=o):(a=t[2],o=t[3]),(0,Q.useEffect)(a,o);let c,u;return t[4]!==e||t[5]!==i?(c=function(){if(i)return he(function(t){if(!h(t.status))return;let n=t.status;e.getQueryData(l())?e.setQueryData(l(),function(e){return e&&{...e,tunnelError:t.error,tunnelStatus:n,tunnelUrl:t.url}}):s(e).catch(function(){})})},u=[e,i],t[4]=e,t[5]=i,t[6]=c,t[7]=u):(c=t[6],u=t[7]),(0,Q.useEffect)(c,u),i}function Re(){return!1}function ze(e,t,n,r){let i=(0,Z.c)(6),a,o;i[0]!==t||i[1]!==e||i[2]!==r||i[3]!==n?(a=function(){if(t||!n||r)return;let i=0,a=!1,o=setInterval(function(){if(i+=1,i>20){clearInterval(o);return}s(e).catch(function(){}).finally(function(){a&&clearInterval(o)})},2e3);return function(){a=!0,clearInterval(o)}},o=[t,e,r,n],i[0]=t,i[1]=e,i[2]=r,i[3]=n,i[4]=a,i[5]=o):(a=i[4],o=i[5]),(0,Q.useEffect)(a,o)}function Be(){let e=(0,Z.c)(17),t=u(),{isLoading:n}=c(),{data:r,isLoading:o}=a(),s=i(),[l,d]=(0,Q.useState)(ke),f;e[0]!==n||e[1]!==r||e[2]!==o?(f=Ie(r,m(),n,o),e[0]=n,e[1]=r,e[2]=o,e[3]=f):f=e[3];let p=f,h=r?.serverBindMode,g=je(h);Me(h,r?.networkAddresses);let _;e[4]===s?_=e[5]:(_=async function(e){try{let t=await s.mutateAsync({serverBindMode:e});Oe({networkAddresses:t.networkAddresses,serverBindMode:t.serverBindMode}),d(!0),Ae(!0)}catch(e){let t=e;throw Te.error(`Failed to update server bind mode:`,t),te({title:`Could not update network access`,description:t instanceof Error?t.message:`Could not update network access.`,variant:`destructive`}),t}},e[4]=s,e[5]=_);let v=_,y=g!==null&&p.serverBindMode!==g,b=y||l,x=p.serverBindMode===`network`&&(p.tunnelStatus===`starting`||p.tunnelStatus===`off`&&!b),S=Le(t);ze(t,p.isLoading,x,S);let C;return e[6]!==y||e[7]!==b||e[8]!==v||e[9]!==s.isPending||e[10]!==p.isLoading||e[11]!==p.networkAddresses||e[12]!==p.serverBindMode||e[13]!==p.tunnelError||e[14]!==p.tunnelStatus||e[15]!==p.tunnelUrl?(C={defaultServerBindMode:Ee,hasServerBindModeChanged:y,isLoading:p.isLoading,isSaving:s.isPending,needsRestart:b,networkAddresses:p.networkAddresses,serverBindMode:p.serverBindMode,tunnelError:p.tunnelError,tunnelStatus:p.tunnelStatus,tunnelUrl:p.tunnelUrl,updateServerBindMode:v},e[6]=y,e[7]=b,e[8]=v,e[9]=s.isPending,e[10]=p.isLoading,e[11]=p.networkAddresses,e[12]=p.serverBindMode,e[13]=p.tunnelError,e[14]=p.tunnelStatus,e[15]=p.tunnelUrl,e[16]=C):C=e[16],C}var $=r();function Ve({open:e,onOpenChange:t,onSave:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1);function l(){i(``),o(null),c(!1)}function u(e){e||l(),t(e)}async function f(){let e=r.trim();if(!e){o(`Enter a Tarsk public address.`);return}c(!0),o(null);try{await n(e),u(!1)}catch(e){let t=e instanceof Error?e.message:`Could not add that Remote Machine.`;o(t)}finally{c(!1)}}return(0,$.jsx)(M,{open:e,onOpenChange:u,children:(0,$.jsxs)(A,{className:`sm:max-w-md`,children:[(0,$.jsxs)(k,{children:[(0,$.jsx)(j,{children:`Add Machine`}),(0,$.jsxs)(O,{children:[`Enter the public id or full address for another Tarsk on `,b,`.`,` `,Y]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(R,{htmlFor:`remote-machine-address`,children:`Public address`}),(0,$.jsx)(X,{id:`remote-machine-address`,value:r,onChange:e=>{i(e.target.value),o(null)},placeholder:`rsawt2ud3n`,disabled:s,"aria-invalid":a!=null,className:`font-mono`}),a?(0,$.jsx)(`p`,{className:d.bodyMuted,children:a}):null]}),(0,$.jsxs)(D,{children:[(0,$.jsx)(F,{type:`button`,variant:`outline`,onClick:()=>u(!1),disabled:s,children:`Cancel`}),(0,$.jsx)(F,{type:`button`,onClick:()=>{f()},disabled:s,children:s?(0,$.jsx)(E,{className:`h-4 w-4 animate-spin`}):`Save`})]})]})})}var He=Object.defineProperty,Ue=Object.getOwnPropertySymbols,We=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable,Ke=(e,t,n)=>t in e?He(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qe=(e,t)=>{for(var n in t||={})We.call(t,n)&&Ke(e,n,t[n]);if(Ue)for(var n of Ue(t))Ge.call(t,n)&&Ke(e,n,t[n]);return e},Je=(e,t)=>{var n={};for(var r in e)We.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ue)for(var r of Ue(e))t.indexOf(r)<0&&Ge.call(e,r)&&(n[r]=e[r]);return n},Ye;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(!(a>>>15));for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(!(t>>>18));for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(!(n>>>8)),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return!!(e>>>t&1)}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i=0;for(;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(Ye||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(Ye||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(Ye||={});var Xe=Ye,Ze={L:Xe.QrCode.Ecc.LOW,M:Xe.QrCode.Ecc.MEDIUM,Q:Xe.QrCode.Ecc.QUARTILE,H:Xe.QrCode.Ecc.HIGH},Qe=128,$e=`L`,et=`#FFFFFF`,tt=`#000000`,nt=!1,rt=1,it=4,at=0,ot=.1;function st(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function ct(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function lt(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*ot),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function ut(e,t){return t==null?e?it:at:Math.max(Math.floor(t),0)}function dt({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=Q.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...Xe.QrSegment.makeSegments(t)),e),[]);return Xe.QrCode.encodeSegments(r,Ze[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=Q.useMemo(()=>{let e=c.getModules(),t=ut(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:lt(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var ft=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),pt=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=Qe,level:a=$e,bgColor:o=et,fgColor:s=tt,includeMargin:c=nt,minVersion:l=rt,boostLevel:u,marginSize:d,imageSettings:f}=n,p=Je(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=Je(p,[`style`]),g=f?.src,_=Q.useRef(null),v=Q.useRef(null),y=Q.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=Q.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=dt({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});Q.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=ct(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,ft?t.fill(new Path2D(st(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),Q.useEffect(()=>{x(!1)},[g]);let E=qe({height:i,width:i},m),D=null;return g!=null&&(D=Q.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),Q.createElement(Q.Fragment,null,Q.createElement(`canvas`,qe({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});pt.displayName=`QRCodeCanvas`;var mt=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=Qe,level:a=$e,bgColor:o=et,fgColor:s=tt,includeMargin:c=nt,minVersion:l=rt,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=Je(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=dt({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=ct(g,v.excavation)),b=Q.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=st(y,h);return Q.createElement(`svg`,qe({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&Q.createElement(`title`,null,d),Q.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),Q.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});mt.displayName=`QRCodeSVG`;function ht(e){let t=(0,Z.c)(8),{inputId:n,value:r,disabled:i,onChange:a,onBlur:o}=e,s=n===void 0?`machine-name`:n,c;t[0]===a?c=t[1]:(c=e=>{a(e.target.value)},t[0]=a,t[1]=c);let l;return t[2]!==i||t[3]!==s||t[4]!==o||t[5]!==c||t[6]!==r?(l=(0,$.jsx)(me,{title:`Machine name`,controlLayout:`row-end`,className:`mt-3`,action:(0,$.jsx)(X,{id:s,value:r,onChange:c,onBlur:o,disabled:i,"aria-label":`Machine name`,className:`w-64 font-mono`})}),t[2]=i,t[3]=s,t[4]=o,t[5]=c,t[6]=r,t[7]=l):l=t[7],l}function gt(e){let t=(0,Z.c)(15),{copied:n,label:r,onCopy:i}=e,a;t[0]===i?a=t[1]:(a=function(){i()},t[0]=i,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=n?(0,$.jsx)(w,{className:`h-3.5 w-3.5 text-brand`}):(0,$.jsx)(T,{className:`h-3.5 w-3.5`}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=(0,$.jsx)(`span`,{className:`sr-only`,children:r}),t[4]=r,t[5]=c);let l;t[6]!==o||t[7]!==s||t[8]!==c?(l=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex h-7 w-7 align-middle items-center justify-center rounded-md border border-border bg-background/90 text-foreground shadow-sm transition-colors hover:bg-background`,children:[s,c]})}),t[6]=o,t[7]=s,t[8]=c,t[9]=l):l=t[9];let u=n?`Copied!`:`Copy to clipboard`,d;t[10]===u?d=t[11]:(d=(0,$.jsx)(ee,{children:u}),t[10]=u,t[11]=d);let f;return t[12]!==l||t[13]!==d?(f=(0,$.jsxs)(L,{children:[l,d]}),t[12]=l,t[13]=d,t[14]=f):f=t[14],f}function _t(e){let t=(0,Z.c)(18),{email:n,url:r,copied:i,onCopy:a}=e,o=n??`your account`,s;t[0]===o?s=t[1]:(s=(0,$.jsxs)(`p`,{className:d.bodyMuted,children:[`You can access this machine by signing in as `,o,` to:`]}),t[0]=o,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,$.jsx)(`span`,{className:`${d.mono} break-all`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==i||t[5]!==a?(l=(0,$.jsx)(gt,{copied:i,label:`Copy public address`,onCopy:a}),t[4]=i,t[5]=a,t[6]=l):l=t[6];let u;t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(`p`,{className:d.bodyMuted,children:[c,` `,l,` in a browser or in the Tarsk mobile app by scanning this QR Code`]}),t[7]=c,t[8]=l,t[9]=u):u=t[9];let f;t[10]!==s||t[11]!==u?(f=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s,u]}),t[10]=s,t[11]=u,t[12]=f):f=t[12];let p;t[13]===r?p=t[14]:(p=(0,$.jsx)(`div`,{className:`w-fit rounded-lg bg-background p-3`,children:(0,$.jsx)(mt,{value:r,size:128,bgColor:`hsl(var(--background))`,fgColor:`hsl(var(--foreground))`,level:`M`})}),t[13]=r,t[14]=p);let m;return t[15]!==f||t[16]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,p]}),t[15]=f,t[16]=p,t[17]=m):m=t[17],m}function vt(e){let t=(0,Z.c)(14),{accountEmail:n,bindMode:r,tunnelUrl:i,tunnelStatus:a,tunnelError:o,copiedTunnelUrl:s,onCopyTunnelUrl:c}=e,l=r===`network`,u=l&&!i&&a===`starting`,f=l&&a===`error`&&!!o,p;t[0]!==n||t[1]!==s||t[2]!==c||t[3]!==i?(p=i?(0,$.jsx)(_t,{email:n,url:i,copied:s,onCopy:c}):null,t[0]=n,t[1]=s,t[2]=c,t[3]=i,t[4]=p):p=t[4];let m;t[5]===u?m=t[6]:(m=u?(0,$.jsx)(`p`,{className:d.bodyMuted,children:`Starting a public address…`}):null,t[5]=u,t[6]=m);let h;t[7]!==f||t[8]!==o?(h=f?(0,$.jsx)(`p`,{className:d.bodyMuted,children:o}):null,t[7]=f,t[8]=o,t[9]=h):h=t[9];let g;return t[10]!==p||t[11]!==m||t[12]!==h?(g=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[p,m,h]}),t[10]=p,t[11]=m,t[12]=h,t[13]=g):g=t[13],g}function yt(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`p`,{className:`${d.bodyMuted} mt-3`,children:`Log in before turning this on.`}),e[0]=t):t=e[0],t}function bt(e){let t=(0,Z.c)(2),{bindMode:n,tunnelUrl:r}=e,i=n===`network`&&!r?` The public address appears after restart.`:``,a;return t[0]===i?a=t[1]:(a=(0,$.jsxs)(`p`,{className:`${d.bodyMuted} mt-3`,children:[`You will need to restart for this setting to take effect.`,i]}),t[0]=i,t[1]=a),a}function xt(e){let t=(0,Z.c)(25),{accountEmail:n,bindMode:r,signedIn:i,isLoading:a,isSaving:o,needsRestart:s,tunnelUrl:c,tunnelStatus:l,tunnelError:u,copiedTunnelUrl:d,localMachineName:f,isLocalMachineNameLoading:p,isLocalMachineNameSaving:m,onCopyTunnelUrl:h,onLocalMachineNameChange:g,onLocalMachineNameBlur:_}=e,v=!!(c||l===`starting`||u),y=!i&&r!==`network`,b;t[0]!==n||t[1]!==r||t[2]!==d||t[3]!==h||t[4]!==v||t[5]!==u||t[6]!==l||t[7]!==c?(b=v?(0,$.jsx)(vt,{accountEmail:n,bindMode:r,tunnelUrl:c,tunnelStatus:l,tunnelError:u,copiedTunnelUrl:d,onCopyTunnelUrl:h}):null,t[0]=n,t[1]=r,t[2]=d,t[3]=h,t[4]=v,t[5]=u,t[6]=l,t[7]=c,t[8]=b):b=t[8];let x;t[9]===y?x=t[10]:(x=y?(0,$.jsx)(yt,{}):null,t[9]=y,t[10]=x);let S;t[11]!==r||t[12]!==s||t[13]!==c?(S=s?(0,$.jsx)(bt,{bindMode:r,tunnelUrl:c}):null,t[11]=r,t[12]=s,t[13]=c,t[14]=S):S=t[14];let C=a||o||p||m,w;t[15]!==f||t[16]!==_||t[17]!==g||t[18]!==C?(w=(0,$.jsx)(ht,{inputId:`local-machine-name`,value:f,disabled:C,onChange:g,onBlur:_}),t[15]=f,t[16]=_,t[17]=g,t[18]=C,t[19]=w):w=t[19];let T;return t[20]!==b||t[21]!==x||t[22]!==S||t[23]!==w?(T=(0,$.jsxs)($.Fragment,{children:[b,x,S,w]}),t[20]=b,t[21]=x,t[22]=S,t[23]=w,t[24]=T):T=t[24],T}function St(e,t,n){switch(e){case`success`:return{title:`Signed in`,description:`This computer is now authorized to clone from ${n}.`};case`code`:return{title:`Check your email`,description:`We sent a 6-digit code to ${t}.`};default:return{title:`Sign in to Remote Machine`,description:`Sign in to ${n} to authorize remote cloning. Saving a bookmark does not grant access.`}}}function Ct(e){return e.step===`email`?e.busy?`Sending…`:`Next`:e.busy?`Verifying…`:`Sign in`}function wt({form:e}){if(e.step===`email`)return(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(R,{htmlFor:`remote-machine-email`,children:`Email`}),(0,$.jsx)(X,{id:`remote-machine-email`,type:`email`,autoComplete:`email`,required:!0,value:e.email,disabled:e.busy,onChange:function(t){e.setEmail(t.target.value)}})]});function t(t){t.preventDefault(),e.codeInputRef.current?.focus()}function n(e){return e.replace(/\\D/g,``)}function r(t){e.busy||e.setCode(t)}return(0,$.jsx)(`div`,{className:`flex justify-center py-2`,onMouseDown:t,children:(0,$.jsx)(se,{ref:e.codeInputRef,maxLength:6,pattern:pe,pasteTransformer:n,value:e.code,"aria-label":`Verification code`,"aria-invalid":!!e.error,onChange:r,children:(0,$.jsxs)(le,{children:[(0,$.jsx)(ge,{index:0}),(0,$.jsx)(ge,{index:1}),(0,$.jsx)(ge,{index:2}),(0,$.jsx)(ge,{index:3}),(0,$.jsx)(ge,{index:4}),(0,$.jsx)(ge,{index:5})]})})})}function Tt(e){let t=(0,Z.c)(22),{form:n}=e,r;t[0]!==n.busy||t[1]!==n.code||t[2]!==n.email||t[3]!==n.step?(r=n.busy||(n.step===`email`?!n.email.trim():n.code.length!==6),t[0]=n.busy,t[1]=n.code,t[2]=n.email,t[3]=n.step,t[4]=r):r=t[4];let i=r,a;t[5]!==n.busy||t[6]!==n.onClose?(a=(0,$.jsx)(F,{type:`button`,variant:`outline`,disabled:n.busy,onClick:n.onClose,children:`Cancel`}),t[5]=n.busy,t[6]=n.onClose,t[7]=a):a=t[7];let o;t[8]!==n.busy||t[9]!==n.onBack||t[10]!==n.step?(o=n.step===`code`&&(0,$.jsx)(F,{type:`button`,variant:`ghost`,disabled:n.busy,onClick:n.onBack,children:`Back`}),t[8]=n.busy,t[9]=n.onBack,t[10]=n.step,t[11]=o):o=t[11];let s=n.busy,c;t[12]===n?c=t[13]:(c=Ct(n),t[12]=n,t[13]=c);let l;t[14]!==n.busy||t[15]!==i||t[16]!==c?(l=(0,$.jsx)(F,{type:`submit`,disabled:i,"aria-busy":s,children:c}),t[14]=n.busy,t[15]=i,t[16]=c,t[17]=l):l=t[17];let u;return t[18]!==a||t[19]!==o||t[20]!==l?(u=(0,$.jsxs)(D,{children:[a,o,l]}),t[18]=a,t[19]=o,t[20]=l,t[21]=u):u=t[21],u}function Et(e){let t=(0,Z.c)(11),{form:n}=e,r;t[0]===n?r=t[1]:(r=(0,$.jsx)(wt,{form:n}),t[0]=n,t[1]=r);let i;t[2]===n.error?i=t[3]:(i=n.error?(0,$.jsx)(`p`,{className:C(d.body,`text-destructive`),role:`alert`,children:n.error.message}):null,t[2]=n.error,t[3]=i);let a;t[4]===n?a=t[5]:(a=(0,$.jsx)(Tt,{form:n}),t[4]=n,t[5]=a);let o;return t[6]!==n.onSubmit||t[7]!==r||t[8]!==i||t[9]!==a?(o=(0,$.jsxs)(`form`,{onSubmit:n.onSubmit,className:`grid gap-4 py-2`,children:[r,i,a]}),t[6]=n.onSubmit,t[7]=r,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}function Dt(e){let t=(0,Z.c)(63),{machine:n,onClose:r}=e,[i,a]=(0,Q.useState)(`email`),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),f=(0,Q.useRef)(null),p=`api/account/remote-machines/${encodeURIComponent(n.id)}`,m;t[0]===p?m=t[1]:(m=async function(e){if(!(await y(`${p}/request-code`,{email:e})).success)throw Error(`Could not send the verification code. Try again.`)},t[0]=p,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=function(e,t){c(t),u(``),a(`code`)},t[2]=h):h=t[2];let g;t[3]===m?g=t[4]:(g={mutationFn:m,onSuccess:h},t[3]=m,t[4]=g);let _=o(g),v;t[5]!==l||t[6]!==s||t[7]!==p?(v=async function(){if(!(await y(`${p}/verify`,{email:s,code:l})).success)throw Error(`That code didn't work. Try again.`)},t[5]=l,t[6]=s,t[7]=p,t[8]=v):v=t[8];let b,x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=function(){u(``),a(`success`)},x=function(){u(``)},t[9]=b,t[10]=x):(b=t[9],x=t[10]);let S;t[11]===v?S=t[12]:(S={mutationFn:v,onSuccess:b,onError:x},t[11]=v,t[12]=S);let w=o(S),T=_.isPending||w.isPending,E=i===`email`?_.error:w.error,N,P;t[13]===i?(N=t[14],P=t[15]):(N=function(){if(i!==`code`)return;f.current?.focus();let e=requestAnimationFrame(function(){f.current?.focus()});return function(){cancelAnimationFrame(e)}},P=[i],t[13]=i,t[14]=N,t[15]=P),(0,Q.useEffect)(N,P);let I;t[16]!==T||t[17]!==l||t[18]!==s||t[19]!==_||t[20]!==i||t[21]!==w?(I=function(e){if(e.preventDefault(),!T){if(i===`email`){let e=s.trim().toLowerCase();e&&_.mutate(e)}else i===`code`&&l.length===6&&w.mutate()}},t[16]=T,t[17]=l,t[18]=s,t[19]=_,t[20]=i,t[21]=w,t[22]=I):I=t[22];let ee=I,L;t[23]!==_||t[24]!==w?(L=function(){a(`email`),u(``),_.reset(),w.reset()},t[23]=_,t[24]=w,t[25]=L):L=t[25];let R=L,te=i===`code`?`code`:`email`,z;t[26]!==R||t[27]!==T||t[28]!==l||t[29]!==s||t[30]!==E||t[31]!==ee||t[32]!==r||t[33]!==te?(z={step:te,email:s,code:l,busy:T,error:E,codeInputRef:f,setEmail:c,setCode:u,onSubmit:ee,onClose:r,onBack:R},t[26]=R,t[27]=T,t[28]=l,t[29]=s,t[30]=E,t[31]=ee,t[32]=r,t[33]=te,t[34]=z):z=t[34];let ne=z,B;t[35]!==s||t[36]!==n.machineName||t[37]!==i?(B=St(i,s,n.machineName),t[35]=s,t[36]=n.machineName,t[37]=i,t[38]=B):B=t[38];let V=B,H;t[39]!==T||t[40]!==r?(H=function(e){!e&&!T&&r()},t[39]=T,t[40]=r,t[41]=H):H=t[41];let U;t[42]===V.title?U=t[43]:(U=(0,$.jsx)(j,{children:V.title}),t[42]=V.title,t[43]=U);let W;t[44]===V.description?W=t[45]:(W=(0,$.jsx)(O,{children:V.description}),t[44]=V.description,t[45]=W);let G;t[46]!==U||t[47]!==W?(G=(0,$.jsxs)(k,{children:[U,W]}),t[46]=U,t[47]=W,t[48]=G):G=t[48];let K;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(K=C(d.compact,`break-all font-mono text-muted-foreground`),t[49]=K):K=t[49];let q;t[50]===n.publicUrl?q=t[51]:(q=(0,$.jsx)(`p`,{className:K,children:n.publicUrl}),t[50]=n.publicUrl,t[51]=q);let re;t[52]!==ne||t[53]!==r||t[54]!==i?(re=i===`success`?(0,$.jsx)(D,{children:(0,$.jsx)(F,{onClick:r,children:`Done`})}):(0,$.jsx)(Et,{form:ne}),t[52]=ne,t[53]=r,t[54]=i,t[55]=re):re=t[55];let J;t[56]!==G||t[57]!==q||t[58]!==re?(J=(0,$.jsxs)(A,{className:`max-w-md`,children:[G,q,re]}),t[56]=G,t[57]=q,t[58]=re,t[59]=J):J=t[59];let Y;return t[60]!==H||t[61]!==J?(Y=(0,$.jsx)(M,{open:!0,onOpenChange:H,children:J}),t[60]=H,t[61]=J,t[62]=Y):Y=t[62],Y}function Ot(e){let t=(0,Z.c)(13),{label:n,disabled:r,onClick:i,className:a,children:o}=e,s;t[0]===a?s=t[1]:(s=C(`shrink-0`,a),t[0]=a,t[1]=s);let c;t[2]!==o||t[3]!==r||t[4]!==n||t[5]!==i||t[6]!==s?(c=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(F,{type:`button`,variant:`ghost`,size:`icon-sm`,className:s,onClick:i,disabled:r,"aria-label":n,children:o})}),t[2]=o,t[3]=r,t[4]=n,t[5]=i,t[6]=s,t[7]=c):c=t[7];let l;t[8]===n?l=t[9]:(l=(0,$.jsx)(ee,{children:n}),t[8]=n,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(L,{children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u}function kt(e){let t=(0,Z.c)(41),{machine:n,draftName:r,disabled:i,onDraftNameChange:a,onDraftNameBlur:o,onRemove:s,onSignIn:c}=e,[l,u]=(0,Q.useState)(!1),f=(0,Q.useRef)(null),p,m;t[0]===l?(p=t[1],m=t[2]):(p=()=>{l&&(f.current?.focus(),f.current?.select())},m=[l],t[0]=l,t[1]=p,t[2]=m),(0,Q.useEffect)(p,m);let h;t[3]===o?h=t[4]:(h=function(){o(),u(!1)},t[3]=o,t[4]=h);let g=h,_;t[5]!==n.machineName||t[6]!==a?(_=function(){a(n.machineName),u(!1)},t[5]=n.machineName,t[6]=a,t[7]=_):_=t[7];let v=_,y;t[8]===n.publicUrl?y=t[9]:(y=function(e){e.preventDefault(),S(n.publicUrl)},t[8]=n.publicUrl,t[9]=y);let b=y,x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(K,{className:`h-10 w-10 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),t[10]=x):x=t[10];let w;t[11]!==v||t[12]!==i||t[13]!==r||t[14]!==g||t[15]!==n.id||t[16]!==n.machineName||t[17]!==a||t[18]!==l?(w=(0,$.jsx)(`div`,{className:`flex min-w-0 items-center gap-1`,children:l?(0,$.jsx)(X,{ref:f,id:`remote-machine-name-${n.id}`,value:r,onChange:e=>{a(e.target.value)},onBlur:g,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur()),e.key===`Escape`&&(e.preventDefault(),v())},disabled:i,"aria-label":`Machine name`,className:`h-8 max-w-md`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:C(d.label,`min-w-0 truncate`),children:n.machineName}),(0,$.jsx)(Ot,{label:`Rename`,disabled:i,className:`pointer-events-none opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100`,onClick:()=>{u(!0)},children:(0,$.jsx)(ae,{className:`h-4 w-4`})})]})}),t[11]=v,t[12]=i,t[13]=r,t[14]=g,t[15]=n.id,t[16]=n.machineName,t[17]=a,t[18]=l,t[19]=w):w=t[19];let T=n.publicUrl,E;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=C(d.compact,`mt-1 block truncate font-mono text-muted-foreground hover:underline`),t[20]=E):E=t[20];let D;t[21]!==n.publicUrl||t[22]!==b?(D=(0,$.jsx)(`a`,{href:T,onClick:b,className:E,children:n.publicUrl}),t[21]=n.publicUrl,t[22]=b,t[23]=D):D=t[23];let O;t[24]!==D||t[25]!==w?(O=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,D]}),t[24]=D,t[25]=w,t[26]=O):O=t[26];let k;t[27]!==i||t[28]!==c?(k=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(F,{type:`button`,variant:`outline`,disabled:i,onClick:c,children:`Sign in`})}),t[27]=i,t[28]=c,t[29]=k):k=t[29];let A;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(ee,{children:`Authorize cloning from this Remote Machine`}),t[30]=A):A=t[30];let j;t[31]===k?j=t[32]:(j=(0,$.jsxs)(L,{children:[k,A]}),t[31]=k,t[32]=j);let M;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(P,{className:`h-4 w-4`}),t[33]=M):M=t[33];let N;t[34]!==i||t[35]!==s?(N=(0,$.jsx)(Ot,{label:`Remove`,disabled:i,onClick:s,children:M}),t[34]=i,t[35]=s,t[36]=N):N=t[36];let R;return t[37]!==O||t[38]!==j||t[39]!==N?(R=(0,$.jsxs)(`div`,{className:`group flex items-center gap-4 rounded-lg border border-border/60 bg-background/40 p-4`,children:[x,O,j,N]}),t[37]=O,t[38]=j,t[39]=N,t[40]=R):R=t[40],R}function At({remoteMachines:e,draftNames:t,isLoading:n,isSavingId:r,onDraftNameChange:i,onDraftNameBlur:a,onRemoveMachine:o}){let[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(!1);async function g(){if(l){h(!0),p(null);try{await o(l.id),u(null)}catch(e){p(e instanceof Error?e.message:`Could not remove that Remote Machine.`)}finally{h(!1)}}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:d.bodyMuted,children:Y}),n?(0,$.jsx)(`p`,{className:d.bodyMuted,children:`Loading Remote Machines…`}):e.length===0?(0,$.jsx)(`p`,{className:d.bodyMuted,children:`No Remote Machines yet.`}):(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map(e=>{let o=r(e.id);return(0,$.jsx)(kt,{machine:e,draftName:t[e.id]??e.machineName,disabled:n||o||m,onDraftNameChange:t=>{i(e.id,t)},onDraftNameBlur:()=>{a(e.id)},onSignIn:function(){c(e)},onRemove:()=>{p(null),u(e)}},e.id)})}),s?(0,$.jsx)(Dt,{machine:s,onClose:function(){c(null)}},s.id):null,(0,$.jsx)(G,{open:l!=null,onOpenChange:e=>{!e&&!m&&(u(null),p(null))},children:(0,$.jsxs)(B,{children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(ne,{children:`Remove Remote Machine?`}),(0,$.jsx)(z,{children:l?`Remove ${l.machineName} from this list? This only deletes the bookmark on this computer.`:null})]}),f?(0,$.jsx)(`p`,{className:C(d.bodyMuted,`text-destructive`),children:f}):null,(0,$.jsxs)(H,{children:[(0,$.jsx)(U,{disabled:m,children:`Cancel`}),(0,$.jsx)(V,{disabled:m,onClick:e=>{e.preventDefault(),g()},children:`Remove`})]})]})})]})}function jt(){let e=(0,Z.c)(65),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(!1),{session:a,isLoading:o}=c(),{isLoading:s,isSaving:l,needsRestart:u,serverBindMode:d,tunnelError:f,tunnelStatus:p,tunnelUrl:m,updateServerBindMode:h}=Be(),{draftMachineName:g,isLoading:_,isSaving:v,setDraftMachineName:y,saveDraftMachineName:b}=be(),{addMachine:x,draftNames:S,isLoading:C,isSavingId:w,remoteMachines:T,removeMachine:E,saveDraftName:D,setDraftName:O}=we(),k;e[0]!==_||e[1]!==C||e[2]!==s?(k=[s,_,C],e[0]=_,e[1]=C,e[2]=s,e[3]=k):k=e[3];let A=ve(`remote-machines`,k),j;e[4]===m?j=e[5]:(j=async function(){if(m)try{await navigator.clipboard.writeText(m),i(!0),te({title:`Copied`,description:`Public address copied to clipboard.`}),window.setTimeout(function(){i(!1)},1500)}catch(e){let t=e;te({title:`Copy failed`,description:t instanceof Error?t.message:`Could not copy the address.`,variant:`destructive`})}},e[4]=m,e[5]=j);let M=j,P=!o&&a!==null,R=d===`network`,z;e[6]===h?z=e[7]:(z=e=>{h(e?`network`:`local`)},e[6]=h,e[7]=z);let ne=s||l,B=!P,V;e[8]!==R||e[9]!==z||e[10]!==ne||e[11]!==B?(V=(0,$.jsx)(oe,{title:`Mobile & Network Access`,className:`[&>div:first-child]:py-2`,sticky:!1,action:(0,$.jsx)(re,{value:R,onChange:z,disabled:ne,disableOn:B,ariaLabel:`Mobile & Network Access`})}),e[8]=R,e[9]=z,e[10]=ne,e[11]=B,e[12]=V):V=e[12];let H=a?.email??null,U;e[13]===b?U=e[14]:(U=()=>{b()},e[13]=b,e[14]=U);let W;e[15]!==r||e[16]!==g||e[17]!==M||e[18]!==_||e[19]!==v||e[20]!==s||e[21]!==l||e[22]!==u||e[23]!==d||e[24]!==y||e[25]!==P||e[26]!==H||e[27]!==U||e[28]!==f||e[29]!==p||e[30]!==m?(W=(0,$.jsx)(_e,{className:`max-w-none pt-0`,children:(0,$.jsx)(ce,{children:(0,$.jsx)(xt,{accountEmail:H,bindMode:d,signedIn:P,isLoading:s,isSaving:l,needsRestart:u,tunnelUrl:m,tunnelStatus:p,tunnelError:f,copiedTunnelUrl:r,localMachineName:g,isLocalMachineNameLoading:_,isLocalMachineNameSaving:v,onCopyTunnelUrl:M,onLocalMachineNameChange:y,onLocalMachineNameBlur:U})})}),e[15]=r,e[16]=g,e[17]=M,e[18]=_,e[19]=v,e[20]=s,e[21]=l,e[22]=u,e[23]=d,e[24]=y,e[25]=P,e[26]=H,e[27]=U,e[28]=f,e[29]=p,e[30]=m,e[31]=W):W=e[31];let G;e[32]!==V||e[33]!==W?(G=(0,$.jsxs)(ue,{className:`shrink-0`,children:[V,W]}),e[32]=V,e[33]=W,e[34]=G):G=e[34];let K;e[35]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>n(!0),e[35]=K):K=e[35];let q;e[36]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(N,{className:`h-4 w-4`}),e[36]=q):q=e[36];let J;e[37]===C?J=e[38]:(J=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(F,{type:`button`,variant:`outline`,size:`icon`,className:`shrink-0`,onClick:K,disabled:C,"aria-label":`Add Machine`,children:q})}),e[37]=C,e[38]=J);let Y;e[39]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,$.jsx)(ee,{children:`Add Machine`}),e[39]=Y):Y=e[39];let ie;e[40]===J?ie=e[41]:(ie=(0,$.jsx)(oe,{title:`Remote Machines`,className:`[&>div:first-child]:py-2`,sticky:!1,action:(0,$.jsxs)(L,{children:[J,Y]})}),e[40]=J,e[41]=ie);let ae;e[42]!==S||e[43]!==C||e[44]!==w||e[45]!==T||e[46]!==E||e[47]!==D||e[48]!==O?(ae=(0,$.jsx)(_e,{className:`max-w-none pt-0`,children:(0,$.jsx)(ce,{children:(0,$.jsx)(At,{remoteMachines:T,draftNames:S,isLoading:C,isSavingId:w,onDraftNameChange:O,onDraftNameBlur:D,onRemoveMachine:E})})}),e[42]=S,e[43]=C,e[44]=w,e[45]=T,e[46]=E,e[47]=D,e[48]=O,e[49]=ae):ae=e[49];let se;e[50]!==ie||e[51]!==ae?(se=(0,$.jsxs)(ue,{className:`shrink-0 pt-6`,children:[ie,ae]}),e[50]=ie,e[51]=ae,e[52]=se):se=e[52];let le;e[53]!==G||e[54]!==se?(le=(0,$.jsxs)(`div`,{className:`divide-y divide-table-border [&>*]:rounded-none`,children:[G,se]}),e[53]=G,e[54]=se,e[55]=le):le=e[55];let X;e[56]===x?X=e[57]:(X=async function(e){await x(e)},e[56]=x,e[57]=X);let de;e[58]!==t||e[59]!==X?(de=(0,$.jsx)(Ve,{open:t,onOpenChange:n,onSave:X}),e[58]=t,e[59]=X,e[60]=de):de=e[60];let pe;return e[61]!==A||e[62]!==le||e[63]!==de?(pe=(0,$.jsxs)(fe,{loading:A,children:[le,de]}),e[61]=A,e[62]=le,e[63]=de,e[64]=pe):pe=e[64],pe}export{jt as default};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,o as n,t as r}from"./react-vendor-D61Uve5n.js";import{a as i,i as a,l as o,n as s,o as c,t as l}from"./use-account-settings-query-D_qL1I4w.js";import{n as u}from"./QueryClientProvider-CYXTUmYo.js";import{U as d,x as f}from"./dist-v_MvKS2-.js";import{P as p,Vi as m,fa as h,ha as g,in as _,mr as v,on as y,sa as b,si as x,t as S}from"./api-Cp9I7CxD.js";import{t as C}from"./utils-CqsIXqSC.js";import{t as w}from"./check-skFQ1X72.js";import{t as T}from"./copy-bi9iX3xn.js";import{t as E}from"./loader-circle-CrqRIqdA.js";import{a as D,i as O,o as k,r as A,s as j,t as M}from"./dialog-D_12AsZd.js";import{t as N}from"./plus-DoMzejDu.js";import{t as P}from"./x-ByOPrz5I.js";import{t as F}from"./button-DDaJhJP1.js";import{i as I,n as ee,t as L}from"./tooltip-CqwCZ7wt.js";import{t as R}from"./label-BCs5CZEs.js";import{t as te}from"./use-toast-CKgZ8YeP.js";import{a as z,c as ne,i as B,n as V,o as H,r as U,s as W,t as G}from"./alert-dialog-BcZULJsX.js";import{Ar as K,Bt as q,G as re,Ht as J,Qn as Y,Un as ie,Vt as ae,at as oe,dn as se,dt as ce,fn as le,gn as X,gt as ue,j as de,lt as fe,mn as pe,nt as me,o as he,pn as ge,pt as _e}from"./index-CcAwxnT5.js";import{t as ve}from"./use-settings-page-loading-B5WU5d1c.js";var Z=t(),Q=e(n(),1),ye=f(`app.use-local-machine-name.hook`);function be(){let e=(0,Z.c)(12),{data:t,isLoading:n}=a(),r=i(),o=t?.machineName??``,[s,c]=(0,Q.useState)(``),l,u;e[0]===o?(l=e[1],u=e[2]):(l=function(){o&&c(o)},u=[o],e[0]=o,e[1]=l,e[2]=u),(0,Q.useEffect)(l,u);let d;e[3]!==s||e[4]!==o||e[5]!==r?(d=async function(){let e=s.trim();if(!e||e===o){c(o);return}try{let t=await r.mutateAsync({machineName:e});c(t.machineName)}catch(e){let t=e;throw ye.error(`Failed to update machine name:`,t),c(o),t}},e[3]=s,e[4]=o,e[5]=r,e[6]=d):d=e[6];let f=d,p;return e[7]!==s||e[8]!==n||e[9]!==f||e[10]!==r.isPending?(p={draftMachineName:s,isLoading:n,isSaving:r.isPending,setDraftMachineName:c,saveDraftMachineName:f},e[7]=s,e[8]=n,e[9]=f,e[10]=r.isPending,e[11]=p):p=e[11],p}var xe=f(`app.use-remote-machines.hook`);function Se(e){return[...e].sort(function(e,t){let n=e.machineName.localeCompare(t.machineName,void 0,{sensitivity:`base`});return n===0?e.publicUrl.localeCompare(t.publicUrl):n})}function Ce(e){let t={};for(let n of e)t[n.id]=n.machineName;return t}function we(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)({}),[i,a]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(()=>new Set);(0,Q.useEffect)(()=>{let e=!1;async function n(){try{let n=await _();e||(t(n.remoteMachines),r(Ce(n.remoteMachines)))}catch(e){xe.error(`Failed to load remote machines:`,e)}finally{e||a(!1)}}return n(),()=>{e=!0}},[]);async function c(e){let n=(await S(e)).remoteMachine;return t(e=>Se([...e,n])),r(e=>({...e,[n.id]:n.machineName})),n}async function l(e){await p(e),t(t=>t.filter(t=>t.id!==e)),r(t=>{let n={...t};return delete n[e],n})}function u(e,t){r(n=>({...n,[e]:t}))}async function d(r){let i=e.find(e=>e.id===r),a=(n[r]??``).trim();if(i){if(!a||a===i.machineName){u(r,i.machineName);return}s(e=>new Set(e).add(r));try{let e=await v(r,a);t(t=>Se(t.map(t=>t.id===r?e.remoteMachine:t))),u(r,e.remoteMachine.machineName)}catch(e){throw xe.error(`Failed to update remote machine name:`,e),u(r,i.machineName),e}finally{s(e=>{let t=new Set(e);return t.delete(r),t})}}}function f(e){return o.has(e)}return{addMachine:c,draftNames:n,isLoading:i,isSavingId:f,remoteMachines:e,removeMachine:l,saveDraftName:d,setDraftName:u}}var Te=f(`app.use-server-bind-mode.hook`),Ee=`local`,De=`tarsk-server-bind-mode-changed`;function Oe(e){b(e)}function ke(){if(typeof window>`u`)return!1;try{return sessionStorage.getItem(De)===`true`}catch{return!1}}function Ae(e){if(typeof window<`u`)try{e?sessionStorage.setItem(De,`true`):sessionStorage.removeItem(De)}catch{}}function je(e){let t=(0,Z.c)(4),[n,r]=(0,Q.useState)(null),i,a;return t[0]!==n||t[1]!==e?(i=function(){e!==void 0&&n===null&&r(e)},a=[n,e],t[0]=n,t[1]=e,t[2]=i,t[3]=a):(i=t[2],a=t[3]),(0,Q.useEffect)(i,a),n}function Me(e,t){let n=(0,Z.c)(4),r,i;n[0]!==t||n[1]!==e?(r=function(){e!==void 0&&t!==void 0&&Oe({networkAddresses:t,serverBindMode:e})},i=[t,e],n[0]=t,n[1]=e,n[2]=r,n[3]=i):(r=n[2],i=n[3]),(0,Q.useEffect)(r,i)}function Ne(e,t){let{serverBindMode:n=Ee}=t??{},{serverBindMode:r=n}=e??{};return r}function Pe(e,t){let{networkAddresses:n=[]}=t??{},{networkAddresses:r=n}=e??{};return r}function Fe(e){let{tunnelUrl:t=null,tunnelStatus:n=`off`,tunnelError:r=null}=e??{};return{tunnelUrl:t,tunnelStatus:n,tunnelError:r}}function Ie(e,t,n,r){return{serverBindMode:Ne(e,t),networkAddresses:Pe(e,t),...Fe(e),isLoading:n||r&&t===null}}function Le(e){let t=(0,Z.c)(8),n=(0,Q.useSyncExternalStore)(ae,q,Re),r=J(),i=r&&n,a,o;t[0]!==r||t[1]!==e?(a=function(){if(r)return de(function(t){t===`tunnel`&&s(e).catch(function(){})})},o=[r,e],t[0]=r,t[1]=e,t[2]=a,t[3]=o):(a=t[2],o=t[3]),(0,Q.useEffect)(a,o);let c,u;return t[4]!==e||t[5]!==i?(c=function(){if(i)return he(function(t){if(!g(t.status))return;let n=t.status;e.getQueryData(l())?e.setQueryData(l(),function(e){return e&&{...e,tunnelError:t.error,tunnelStatus:n,tunnelUrl:t.url}}):s(e).catch(function(){})})},u=[e,i],t[4]=e,t[5]=i,t[6]=c,t[7]=u):(c=t[6],u=t[7]),(0,Q.useEffect)(c,u),i}function Re(){return!1}function ze(e,t,n,r){let i=(0,Z.c)(6),a,o;i[0]!==t||i[1]!==e||i[2]!==r||i[3]!==n?(a=function(){if(t||!n||r)return;let i=0,a=!1,o=setInterval(function(){if(i+=1,i>20){clearInterval(o);return}s(e).catch(function(){}).finally(function(){a&&clearInterval(o)})},2e3);return function(){a=!0,clearInterval(o)}},o=[t,e,r,n],i[0]=t,i[1]=e,i[2]=r,i[3]=n,i[4]=a,i[5]=o):(a=i[4],o=i[5]),(0,Q.useEffect)(a,o)}function Be(){let e=(0,Z.c)(17),t=u(),{isLoading:n}=c(),{data:r,isLoading:o}=a(),s=i(),[l,d]=(0,Q.useState)(ke),f;e[0]!==n||e[1]!==r||e[2]!==o?(f=Ie(r,m(),n,o),e[0]=n,e[1]=r,e[2]=o,e[3]=f):f=e[3];let p=f,h=r?.serverBindMode,g=je(h);Me(h,r?.networkAddresses);let _;e[4]===s?_=e[5]:(_=async function(e){try{let t=await s.mutateAsync({serverBindMode:e});Oe({networkAddresses:t.networkAddresses,serverBindMode:t.serverBindMode}),d(!0),Ae(!0)}catch(e){let t=e;throw Te.error(`Failed to update server bind mode:`,t),te({title:`Could not update network access`,description:t instanceof Error?t.message:`Could not update network access.`,variant:`destructive`}),t}},e[4]=s,e[5]=_);let v=_,y=g!==null&&p.serverBindMode!==g,b=y||l,x=p.serverBindMode===`network`&&(p.tunnelStatus===`starting`||p.tunnelStatus===`off`&&!b),S=Le(t);ze(t,p.isLoading,x,S);let C;return e[6]!==y||e[7]!==b||e[8]!==v||e[9]!==s.isPending||e[10]!==p.isLoading||e[11]!==p.networkAddresses||e[12]!==p.serverBindMode||e[13]!==p.tunnelError||e[14]!==p.tunnelStatus||e[15]!==p.tunnelUrl?(C={defaultServerBindMode:Ee,hasServerBindModeChanged:y,isLoading:p.isLoading,isSaving:s.isPending,needsRestart:b,networkAddresses:p.networkAddresses,serverBindMode:p.serverBindMode,tunnelError:p.tunnelError,tunnelStatus:p.tunnelStatus,tunnelUrl:p.tunnelUrl,updateServerBindMode:v},e[6]=y,e[7]=b,e[8]=v,e[9]=s.isPending,e[10]=p.isLoading,e[11]=p.networkAddresses,e[12]=p.serverBindMode,e[13]=p.tunnelError,e[14]=p.tunnelStatus,e[15]=p.tunnelUrl,e[16]=C):C=e[16],C}var $=r();function Ve({open:e,onOpenChange:t,onSave:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1);function l(){i(``),o(null),c(!1)}function u(e){e||l(),t(e)}async function f(){let e=r.trim();if(!e){o(`Enter a Tarsk public address.`);return}c(!0),o(null);try{await n(e),u(!1)}catch(e){let t=e instanceof Error?e.message:`Could not add that Remote Machine.`;o(t)}finally{c(!1)}}return(0,$.jsx)(M,{open:e,onOpenChange:u,children:(0,$.jsxs)(A,{className:`sm:max-w-md`,children:[(0,$.jsxs)(k,{children:[(0,$.jsx)(j,{children:`Add Machine`}),(0,$.jsxs)(O,{children:[`Enter the public id or full address for another Tarsk on `,h,`.`,` `,K]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(R,{htmlFor:`remote-machine-address`,children:`Public address`}),(0,$.jsx)(X,{id:`remote-machine-address`,value:r,onChange:e=>{i(e.target.value),o(null)},placeholder:`rsawt2ud3n`,disabled:s,"aria-invalid":a!=null,className:`font-mono`}),a?(0,$.jsx)(`p`,{className:d.bodyMuted,children:a}):null]}),(0,$.jsxs)(D,{children:[(0,$.jsx)(F,{type:`button`,variant:`outline`,onClick:()=>u(!1),disabled:s,children:`Cancel`}),(0,$.jsx)(F,{type:`button`,onClick:()=>{f()},disabled:s,children:s?(0,$.jsx)(E,{className:`h-4 w-4 animate-spin`}):`Save`})]})]})})}var He=Object.defineProperty,Ue=Object.getOwnPropertySymbols,We=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable,Ke=(e,t,n)=>t in e?He(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qe=(e,t)=>{for(var n in t||={})We.call(t,n)&&Ke(e,n,t[n]);if(Ue)for(var n of Ue(t))Ge.call(t,n)&&Ke(e,n,t[n]);return e},Je=(e,t)=>{var n={};for(var r in e)We.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ue)for(var r of Ue(e))t.indexOf(r)<0&&Ge.call(e,r)&&(n[r]=e[r]);return n},Ye;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(!(a>>>15));for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(!(t>>>18));for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(!(n>>>8)),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return!!(e>>>t&1)}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i=0;for(;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(Ye||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(Ye||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(Ye||={});var Xe=Ye,Ze={L:Xe.QrCode.Ecc.LOW,M:Xe.QrCode.Ecc.MEDIUM,Q:Xe.QrCode.Ecc.QUARTILE,H:Xe.QrCode.Ecc.HIGH},Qe=128,$e=`L`,et=`#FFFFFF`,tt=`#000000`,nt=!1,rt=1,it=4,at=0,ot=.1;function st(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function ct(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function lt(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*ot),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function ut(e,t){return t==null?e?it:at:Math.max(Math.floor(t),0)}function dt({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=Q.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...Xe.QrSegment.makeSegments(t)),e),[]);return Xe.QrCode.encodeSegments(r,Ze[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=Q.useMemo(()=>{let e=c.getModules(),t=ut(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:lt(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var ft=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),pt=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=Qe,level:a=$e,bgColor:o=et,fgColor:s=tt,includeMargin:c=nt,minVersion:l=rt,boostLevel:u,marginSize:d,imageSettings:f}=n,p=Je(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=Je(p,[`style`]),g=f?.src,_=Q.useRef(null),v=Q.useRef(null),y=Q.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=Q.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=dt({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});Q.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=ct(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,ft?t.fill(new Path2D(st(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),Q.useEffect(()=>{x(!1)},[g]);let E=qe({height:i,width:i},m),D=null;return g!=null&&(D=Q.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),Q.createElement(Q.Fragment,null,Q.createElement(`canvas`,qe({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});pt.displayName=`QRCodeCanvas`;var mt=Q.forwardRef(function(e,t){let n=e,{value:r,size:i=Qe,level:a=$e,bgColor:o=et,fgColor:s=tt,includeMargin:c=nt,minVersion:l=rt,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=Je(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=dt({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=ct(g,v.excavation)),b=Q.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=st(y,h);return Q.createElement(`svg`,qe({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&Q.createElement(`title`,null,d),Q.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),Q.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});mt.displayName=`QRCodeSVG`;function ht(e){let t=(0,Z.c)(8),{inputId:n,value:r,disabled:i,onChange:a,onBlur:o}=e,s=n===void 0?`machine-name`:n,c;t[0]===a?c=t[1]:(c=e=>{a(e.target.value)},t[0]=a,t[1]=c);let l;return t[2]!==i||t[3]!==s||t[4]!==o||t[5]!==c||t[6]!==r?(l=(0,$.jsx)(me,{title:`Machine name`,controlLayout:`row-end`,className:`mt-3`,action:(0,$.jsx)(X,{id:s,value:r,onChange:c,onBlur:o,disabled:i,"aria-label":`Machine name`,className:`w-64 font-mono`})}),t[2]=i,t[3]=s,t[4]=o,t[5]=c,t[6]=r,t[7]=l):l=t[7],l}function gt(e){let t=(0,Z.c)(15),{copied:n,label:r,onCopy:i}=e,a;t[0]===i?a=t[1]:(a=function(){i()},t[0]=i,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=n?(0,$.jsx)(w,{className:`h-3.5 w-3.5 text-brand`}):(0,$.jsx)(T,{className:`h-3.5 w-3.5`}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=(0,$.jsx)(`span`,{className:`sr-only`,children:r}),t[4]=r,t[5]=c);let l;t[6]!==o||t[7]!==s||t[8]!==c?(l=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex h-7 w-7 align-middle items-center justify-center rounded-md border border-border bg-background/90 text-foreground shadow-sm transition-colors hover:bg-background`,children:[s,c]})}),t[6]=o,t[7]=s,t[8]=c,t[9]=l):l=t[9];let u=n?`Copied!`:`Copy to clipboard`,d;t[10]===u?d=t[11]:(d=(0,$.jsx)(ee,{children:u}),t[10]=u,t[11]=d);let f;return t[12]!==l||t[13]!==d?(f=(0,$.jsxs)(L,{children:[l,d]}),t[12]=l,t[13]=d,t[14]=f):f=t[14],f}function _t(e){let t=(0,Z.c)(18),{email:n,url:r,copied:i,onCopy:a}=e,o=n??`your account`,s;t[0]===o?s=t[1]:(s=(0,$.jsxs)(`p`,{className:d.bodyMuted,children:[`You can access this machine by signing in as `,o,` to:`]}),t[0]=o,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,$.jsx)(`span`,{className:`${d.mono} break-all`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==i||t[5]!==a?(l=(0,$.jsx)(gt,{copied:i,label:`Copy public address`,onCopy:a}),t[4]=i,t[5]=a,t[6]=l):l=t[6];let u;t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(`p`,{className:d.bodyMuted,children:[c,` `,l,` in a browser or in the Tarsk mobile app by scanning this QR Code`]}),t[7]=c,t[8]=l,t[9]=u):u=t[9];let f;t[10]!==s||t[11]!==u?(f=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s,u]}),t[10]=s,t[11]=u,t[12]=f):f=t[12];let p;t[13]===r?p=t[14]:(p=(0,$.jsx)(`div`,{className:`w-fit rounded-lg bg-background p-3`,children:(0,$.jsx)(mt,{value:r,size:128,bgColor:`hsl(var(--background))`,fgColor:`hsl(var(--foreground))`,level:`M`})}),t[13]=r,t[14]=p);let m;return t[15]!==f||t[16]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,p]}),t[15]=f,t[16]=p,t[17]=m):m=t[17],m}function vt(e){let t=(0,Z.c)(14),{accountEmail:n,bindMode:r,tunnelUrl:i,tunnelStatus:a,tunnelError:o,copiedTunnelUrl:s,onCopyTunnelUrl:c}=e,l=r===`network`,u=l&&!i&&a===`starting`,f=l&&a===`error`&&!!o,p;t[0]!==n||t[1]!==s||t[2]!==c||t[3]!==i?(p=i?(0,$.jsx)(_t,{email:n,url:i,copied:s,onCopy:c}):null,t[0]=n,t[1]=s,t[2]=c,t[3]=i,t[4]=p):p=t[4];let m;t[5]===u?m=t[6]:(m=u?(0,$.jsx)(`p`,{className:d.bodyMuted,children:`Starting a public address…`}):null,t[5]=u,t[6]=m);let h;t[7]!==f||t[8]!==o?(h=f?(0,$.jsx)(`p`,{className:d.bodyMuted,children:o}):null,t[7]=f,t[8]=o,t[9]=h):h=t[9];let g;return t[10]!==p||t[11]!==m||t[12]!==h?(g=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[p,m,h]}),t[10]=p,t[11]=m,t[12]=h,t[13]=g):g=t[13],g}function yt(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`p`,{className:`${d.bodyMuted} mt-3`,children:`Log in before turning this on.`}),e[0]=t):t=e[0],t}function bt(e){let t=(0,Z.c)(2),{bindMode:n,tunnelUrl:r}=e,i=n===`network`&&!r?` The public address appears after restart.`:``,a;return t[0]===i?a=t[1]:(a=(0,$.jsxs)(`p`,{className:`${d.bodyMuted} mt-3`,children:[`You will need to restart for this setting to take effect.`,i]}),t[0]=i,t[1]=a),a}function xt(e){let t=(0,Z.c)(25),{accountEmail:n,bindMode:r,signedIn:i,isLoading:a,isSaving:o,needsRestart:s,tunnelUrl:c,tunnelStatus:l,tunnelError:u,copiedTunnelUrl:d,localMachineName:f,isLocalMachineNameLoading:p,isLocalMachineNameSaving:m,onCopyTunnelUrl:h,onLocalMachineNameChange:g,onLocalMachineNameBlur:_}=e,v=!!(c||l===`starting`||u),y=!i&&r!==`network`,b;t[0]!==n||t[1]!==r||t[2]!==d||t[3]!==h||t[4]!==v||t[5]!==u||t[6]!==l||t[7]!==c?(b=v?(0,$.jsx)(vt,{accountEmail:n,bindMode:r,tunnelUrl:c,tunnelStatus:l,tunnelError:u,copiedTunnelUrl:d,onCopyTunnelUrl:h}):null,t[0]=n,t[1]=r,t[2]=d,t[3]=h,t[4]=v,t[5]=u,t[6]=l,t[7]=c,t[8]=b):b=t[8];let x;t[9]===y?x=t[10]:(x=y?(0,$.jsx)(yt,{}):null,t[9]=y,t[10]=x);let S;t[11]!==r||t[12]!==s||t[13]!==c?(S=s?(0,$.jsx)(bt,{bindMode:r,tunnelUrl:c}):null,t[11]=r,t[12]=s,t[13]=c,t[14]=S):S=t[14];let C=a||o||p||m,w;t[15]!==f||t[16]!==_||t[17]!==g||t[18]!==C?(w=(0,$.jsx)(ht,{inputId:`local-machine-name`,value:f,disabled:C,onChange:g,onBlur:_}),t[15]=f,t[16]=_,t[17]=g,t[18]=C,t[19]=w):w=t[19];let T;return t[20]!==b||t[21]!==x||t[22]!==S||t[23]!==w?(T=(0,$.jsxs)($.Fragment,{children:[b,x,S,w]}),t[20]=b,t[21]=x,t[22]=S,t[23]=w,t[24]=T):T=t[24],T}function St(e,t,n){switch(e){case`success`:return{title:`Signed in`,description:`This computer is now authorized to clone from ${n}.`};case`code`:return{title:`Check your email`,description:`We sent a 6-digit code to ${t}.`};default:return{title:`Sign in to Remote Machine`,description:`Sign in to ${n} to authorize remote cloning. Saving a bookmark does not grant access.`}}}function Ct(e){return e.step===`email`?e.busy?`Sending…`:`Next`:e.busy?`Verifying…`:`Sign in`}function wt({form:e}){if(e.step===`email`)return(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(R,{htmlFor:`remote-machine-email`,children:`Email`}),(0,$.jsx)(X,{id:`remote-machine-email`,type:`email`,autoComplete:`email`,required:!0,value:e.email,disabled:e.busy,onChange:function(t){e.setEmail(t.target.value)}})]});function t(t){t.preventDefault(),e.codeInputRef.current?.focus()}function n(e){return e.replace(/\\D/g,``)}function r(t){e.busy||e.setCode(t)}return(0,$.jsx)(`div`,{className:`flex justify-center py-2`,onMouseDown:t,children:(0,$.jsx)(se,{ref:e.codeInputRef,maxLength:6,pattern:pe,pasteTransformer:n,value:e.code,"aria-label":`Verification code`,"aria-invalid":!!e.error,onChange:r,children:(0,$.jsxs)(le,{children:[(0,$.jsx)(ge,{index:0}),(0,$.jsx)(ge,{index:1}),(0,$.jsx)(ge,{index:2}),(0,$.jsx)(ge,{index:3}),(0,$.jsx)(ge,{index:4}),(0,$.jsx)(ge,{index:5})]})})})}function Tt(e){let t=(0,Z.c)(22),{form:n}=e,r;t[0]!==n.busy||t[1]!==n.code||t[2]!==n.email||t[3]!==n.step?(r=n.busy||(n.step===`email`?!n.email.trim():n.code.length!==6),t[0]=n.busy,t[1]=n.code,t[2]=n.email,t[3]=n.step,t[4]=r):r=t[4];let i=r,a;t[5]!==n.busy||t[6]!==n.onClose?(a=(0,$.jsx)(F,{type:`button`,variant:`outline`,disabled:n.busy,onClick:n.onClose,children:`Cancel`}),t[5]=n.busy,t[6]=n.onClose,t[7]=a):a=t[7];let o;t[8]!==n.busy||t[9]!==n.onBack||t[10]!==n.step?(o=n.step===`code`&&(0,$.jsx)(F,{type:`button`,variant:`ghost`,disabled:n.busy,onClick:n.onBack,children:`Back`}),t[8]=n.busy,t[9]=n.onBack,t[10]=n.step,t[11]=o):o=t[11];let s=n.busy,c;t[12]===n?c=t[13]:(c=Ct(n),t[12]=n,t[13]=c);let l;t[14]!==n.busy||t[15]!==i||t[16]!==c?(l=(0,$.jsx)(F,{type:`submit`,disabled:i,"aria-busy":s,children:c}),t[14]=n.busy,t[15]=i,t[16]=c,t[17]=l):l=t[17];let u;return t[18]!==a||t[19]!==o||t[20]!==l?(u=(0,$.jsxs)(D,{children:[a,o,l]}),t[18]=a,t[19]=o,t[20]=l,t[21]=u):u=t[21],u}function Et(e){let t=(0,Z.c)(11),{form:n}=e,r;t[0]===n?r=t[1]:(r=(0,$.jsx)(wt,{form:n}),t[0]=n,t[1]=r);let i;t[2]===n.error?i=t[3]:(i=n.error?(0,$.jsx)(`p`,{className:C(d.body,`text-destructive`),role:`alert`,children:n.error.message}):null,t[2]=n.error,t[3]=i);let a;t[4]===n?a=t[5]:(a=(0,$.jsx)(Tt,{form:n}),t[4]=n,t[5]=a);let o;return t[6]!==n.onSubmit||t[7]!==r||t[8]!==i||t[9]!==a?(o=(0,$.jsxs)(`form`,{onSubmit:n.onSubmit,className:`grid gap-4 py-2`,children:[r,i,a]}),t[6]=n.onSubmit,t[7]=r,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}function Dt(e){let t=(0,Z.c)(63),{machine:n,onClose:r}=e,[i,a]=(0,Q.useState)(`email`),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),f=(0,Q.useRef)(null),p=`api/account/remote-machines/${encodeURIComponent(n.id)}`,m;t[0]===p?m=t[1]:(m=async function(e){if(!(await x(`${p}/request-code`,{email:e})).success)throw Error(`Could not send the verification code. Try again.`)},t[0]=p,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=function(e,t){c(t),u(``),a(`code`)},t[2]=h):h=t[2];let g;t[3]===m?g=t[4]:(g={mutationFn:m,onSuccess:h},t[3]=m,t[4]=g);let _=o(g),v;t[5]!==l||t[6]!==s||t[7]!==p?(v=async function(){if(!(await x(`${p}/verify`,{email:s,code:l})).success)throw Error(`That code didn't work. Try again.`)},t[5]=l,t[6]=s,t[7]=p,t[8]=v):v=t[8];let y,b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=function(){u(``),a(`success`)},b=function(){u(``)},t[9]=y,t[10]=b):(y=t[9],b=t[10]);let S;t[11]===v?S=t[12]:(S={mutationFn:v,onSuccess:y,onError:b},t[11]=v,t[12]=S);let w=o(S),T=_.isPending||w.isPending,E=i===`email`?_.error:w.error,N,P;t[13]===i?(N=t[14],P=t[15]):(N=function(){if(i!==`code`)return;f.current?.focus();let e=requestAnimationFrame(function(){f.current?.focus()});return function(){cancelAnimationFrame(e)}},P=[i],t[13]=i,t[14]=N,t[15]=P),(0,Q.useEffect)(N,P);let I;t[16]!==T||t[17]!==l||t[18]!==s||t[19]!==_||t[20]!==i||t[21]!==w?(I=function(e){if(e.preventDefault(),!T){if(i===`email`){let e=s.trim().toLowerCase();e&&_.mutate(e)}else i===`code`&&l.length===6&&w.mutate()}},t[16]=T,t[17]=l,t[18]=s,t[19]=_,t[20]=i,t[21]=w,t[22]=I):I=t[22];let ee=I,L;t[23]!==_||t[24]!==w?(L=function(){a(`email`),u(``),_.reset(),w.reset()},t[23]=_,t[24]=w,t[25]=L):L=t[25];let R=L,te=i===`code`?`code`:`email`,z;t[26]!==R||t[27]!==T||t[28]!==l||t[29]!==s||t[30]!==E||t[31]!==ee||t[32]!==r||t[33]!==te?(z={step:te,email:s,code:l,busy:T,error:E,codeInputRef:f,setEmail:c,setCode:u,onSubmit:ee,onClose:r,onBack:R},t[26]=R,t[27]=T,t[28]=l,t[29]=s,t[30]=E,t[31]=ee,t[32]=r,t[33]=te,t[34]=z):z=t[34];let ne=z,B;t[35]!==s||t[36]!==n.machineName||t[37]!==i?(B=St(i,s,n.machineName),t[35]=s,t[36]=n.machineName,t[37]=i,t[38]=B):B=t[38];let V=B,H;t[39]!==T||t[40]!==r?(H=function(e){!e&&!T&&r()},t[39]=T,t[40]=r,t[41]=H):H=t[41];let U;t[42]===V.title?U=t[43]:(U=(0,$.jsx)(j,{children:V.title}),t[42]=V.title,t[43]=U);let W;t[44]===V.description?W=t[45]:(W=(0,$.jsx)(O,{children:V.description}),t[44]=V.description,t[45]=W);let G;t[46]!==U||t[47]!==W?(G=(0,$.jsxs)(k,{children:[U,W]}),t[46]=U,t[47]=W,t[48]=G):G=t[48];let K;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(K=C(d.compact,`break-all font-mono text-muted-foreground`),t[49]=K):K=t[49];let q;t[50]===n.publicUrl?q=t[51]:(q=(0,$.jsx)(`p`,{className:K,children:n.publicUrl}),t[50]=n.publicUrl,t[51]=q);let re;t[52]!==ne||t[53]!==r||t[54]!==i?(re=i===`success`?(0,$.jsx)(D,{children:(0,$.jsx)(F,{onClick:r,children:`Done`})}):(0,$.jsx)(Et,{form:ne}),t[52]=ne,t[53]=r,t[54]=i,t[55]=re):re=t[55];let J;t[56]!==G||t[57]!==q||t[58]!==re?(J=(0,$.jsxs)(A,{className:`max-w-md`,children:[G,q,re]}),t[56]=G,t[57]=q,t[58]=re,t[59]=J):J=t[59];let Y;return t[60]!==H||t[61]!==J?(Y=(0,$.jsx)(M,{open:!0,onOpenChange:H,children:J}),t[60]=H,t[61]=J,t[62]=Y):Y=t[62],Y}function Ot(e){let t=(0,Z.c)(13),{label:n,disabled:r,onClick:i,className:a,children:o}=e,s;t[0]===a?s=t[1]:(s=C(`shrink-0`,a),t[0]=a,t[1]=s);let c;t[2]!==o||t[3]!==r||t[4]!==n||t[5]!==i||t[6]!==s?(c=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(F,{type:`button`,variant:`ghost`,size:`icon-sm`,className:s,onClick:i,disabled:r,"aria-label":n,children:o})}),t[2]=o,t[3]=r,t[4]=n,t[5]=i,t[6]=s,t[7]=c):c=t[7];let l;t[8]===n?l=t[9]:(l=(0,$.jsx)(ee,{children:n}),t[8]=n,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(L,{children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u}function kt(e){let t=(0,Z.c)(41),{machine:n,draftName:r,disabled:i,onDraftNameChange:a,onDraftNameBlur:o,onRemove:s,onSignIn:c}=e,[l,u]=(0,Q.useState)(!1),f=(0,Q.useRef)(null),p,m;t[0]===l?(p=t[1],m=t[2]):(p=()=>{l&&(f.current?.focus(),f.current?.select())},m=[l],t[0]=l,t[1]=p,t[2]=m),(0,Q.useEffect)(p,m);let h;t[3]===o?h=t[4]:(h=function(){o(),u(!1)},t[3]=o,t[4]=h);let g=h,_;t[5]!==n.machineName||t[6]!==a?(_=function(){a(n.machineName),u(!1)},t[5]=n.machineName,t[6]=a,t[7]=_):_=t[7];let v=_,b;t[8]===n.publicUrl?b=t[9]:(b=function(e){e.preventDefault(),y(n.publicUrl)},t[8]=n.publicUrl,t[9]=b);let x=b,S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(Y,{className:`h-10 w-10 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),t[10]=S):S=t[10];let w;t[11]!==v||t[12]!==i||t[13]!==r||t[14]!==g||t[15]!==n.id||t[16]!==n.machineName||t[17]!==a||t[18]!==l?(w=(0,$.jsx)(`div`,{className:`flex min-w-0 items-center gap-1`,children:l?(0,$.jsx)(X,{ref:f,id:`remote-machine-name-${n.id}`,value:r,onChange:e=>{a(e.target.value)},onBlur:g,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur()),e.key===`Escape`&&(e.preventDefault(),v())},disabled:i,"aria-label":`Machine name`,className:`h-8 max-w-md`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:C(d.label,`min-w-0 truncate`),children:n.machineName}),(0,$.jsx)(Ot,{label:`Rename`,disabled:i,className:`pointer-events-none opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100`,onClick:()=>{u(!0)},children:(0,$.jsx)(ie,{className:`h-4 w-4`})})]})}),t[11]=v,t[12]=i,t[13]=r,t[14]=g,t[15]=n.id,t[16]=n.machineName,t[17]=a,t[18]=l,t[19]=w):w=t[19];let T=n.publicUrl,E;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=C(d.compact,`mt-1 block truncate font-mono text-muted-foreground hover:underline`),t[20]=E):E=t[20];let D;t[21]!==n.publicUrl||t[22]!==x?(D=(0,$.jsx)(`a`,{href:T,onClick:x,className:E,children:n.publicUrl}),t[21]=n.publicUrl,t[22]=x,t[23]=D):D=t[23];let O;t[24]!==D||t[25]!==w?(O=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,D]}),t[24]=D,t[25]=w,t[26]=O):O=t[26];let k;t[27]!==i||t[28]!==c?(k=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(F,{type:`button`,variant:`outline`,disabled:i,onClick:c,children:`Sign in`})}),t[27]=i,t[28]=c,t[29]=k):k=t[29];let A;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(ee,{children:`Authorize cloning from this Remote Machine`}),t[30]=A):A=t[30];let j;t[31]===k?j=t[32]:(j=(0,$.jsxs)(L,{children:[k,A]}),t[31]=k,t[32]=j);let M;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(P,{className:`h-4 w-4`}),t[33]=M):M=t[33];let N;t[34]!==i||t[35]!==s?(N=(0,$.jsx)(Ot,{label:`Remove`,disabled:i,onClick:s,children:M}),t[34]=i,t[35]=s,t[36]=N):N=t[36];let R;return t[37]!==O||t[38]!==j||t[39]!==N?(R=(0,$.jsxs)(`div`,{className:`group flex items-center gap-4 rounded-lg border border-border/60 bg-background/40 p-4`,children:[S,O,j,N]}),t[37]=O,t[38]=j,t[39]=N,t[40]=R):R=t[40],R}function At({remoteMachines:e,draftNames:t,isLoading:n,isSavingId:r,onDraftNameChange:i,onDraftNameBlur:a,onRemoveMachine:o}){let[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(!1);async function g(){if(l){h(!0),p(null);try{await o(l.id),u(null)}catch(e){p(e instanceof Error?e.message:`Could not remove that Remote Machine.`)}finally{h(!1)}}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:d.bodyMuted,children:K}),n?(0,$.jsx)(`p`,{className:d.bodyMuted,children:`Loading Remote Machines…`}):e.length===0?(0,$.jsx)(`p`,{className:d.bodyMuted,children:`No Remote Machines yet.`}):(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map(e=>{let o=r(e.id);return(0,$.jsx)(kt,{machine:e,draftName:t[e.id]??e.machineName,disabled:n||o||m,onDraftNameChange:t=>{i(e.id,t)},onDraftNameBlur:()=>{a(e.id)},onSignIn:function(){c(e)},onRemove:()=>{p(null),u(e)}},e.id)})}),s?(0,$.jsx)(Dt,{machine:s,onClose:function(){c(null)}},s.id):null,(0,$.jsx)(G,{open:l!=null,onOpenChange:e=>{!e&&!m&&(u(null),p(null))},children:(0,$.jsxs)(B,{children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(ne,{children:`Remove Remote Machine?`}),(0,$.jsx)(z,{children:l?`Remove ${l.machineName} from this list? This only deletes the bookmark on this computer.`:null})]}),f?(0,$.jsx)(`p`,{className:C(d.bodyMuted,`text-destructive`),children:f}):null,(0,$.jsxs)(H,{children:[(0,$.jsx)(U,{disabled:m,children:`Cancel`}),(0,$.jsx)(V,{disabled:m,onClick:e=>{e.preventDefault(),g()},children:`Remove`})]})]})})]})}function jt(){let e=(0,Z.c)(65),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(!1),{session:a,isLoading:o}=c(),{isLoading:s,isSaving:l,needsRestart:u,serverBindMode:d,tunnelError:f,tunnelStatus:p,tunnelUrl:m,updateServerBindMode:h}=Be(),{draftMachineName:g,isLoading:_,isSaving:v,setDraftMachineName:y,saveDraftMachineName:b}=be(),{addMachine:x,draftNames:S,isLoading:C,isSavingId:w,remoteMachines:T,removeMachine:E,saveDraftName:D,setDraftName:O}=we(),k;e[0]!==_||e[1]!==C||e[2]!==s?(k=[s,_,C],e[0]=_,e[1]=C,e[2]=s,e[3]=k):k=e[3];let A=ve(`remote-machines`,k),j;e[4]===m?j=e[5]:(j=async function(){if(m)try{await navigator.clipboard.writeText(m),i(!0),te({title:`Copied`,description:`Public address copied to clipboard.`}),window.setTimeout(function(){i(!1)},1500)}catch(e){let t=e;te({title:`Copy failed`,description:t instanceof Error?t.message:`Could not copy the address.`,variant:`destructive`})}},e[4]=m,e[5]=j);let M=j,P=!o&&a!==null,R=d===`network`,z;e[6]===h?z=e[7]:(z=e=>{h(e?`network`:`local`)},e[6]=h,e[7]=z);let ne=s||l,B=!P,V;e[8]!==R||e[9]!==z||e[10]!==ne||e[11]!==B?(V=(0,$.jsx)(oe,{title:`Mobile & Network Access`,className:`[&>div:first-child]:py-2`,sticky:!1,action:(0,$.jsx)(re,{value:R,onChange:z,disabled:ne,disableOn:B,ariaLabel:`Mobile & Network Access`})}),e[8]=R,e[9]=z,e[10]=ne,e[11]=B,e[12]=V):V=e[12];let H=a?.email??null,U;e[13]===b?U=e[14]:(U=()=>{b()},e[13]=b,e[14]=U);let W;e[15]!==r||e[16]!==g||e[17]!==M||e[18]!==_||e[19]!==v||e[20]!==s||e[21]!==l||e[22]!==u||e[23]!==d||e[24]!==y||e[25]!==P||e[26]!==H||e[27]!==U||e[28]!==f||e[29]!==p||e[30]!==m?(W=(0,$.jsx)(_e,{className:`max-w-none pt-0`,children:(0,$.jsx)(ce,{children:(0,$.jsx)(xt,{accountEmail:H,bindMode:d,signedIn:P,isLoading:s,isSaving:l,needsRestart:u,tunnelUrl:m,tunnelStatus:p,tunnelError:f,copiedTunnelUrl:r,localMachineName:g,isLocalMachineNameLoading:_,isLocalMachineNameSaving:v,onCopyTunnelUrl:M,onLocalMachineNameChange:y,onLocalMachineNameBlur:U})})}),e[15]=r,e[16]=g,e[17]=M,e[18]=_,e[19]=v,e[20]=s,e[21]=l,e[22]=u,e[23]=d,e[24]=y,e[25]=P,e[26]=H,e[27]=U,e[28]=f,e[29]=p,e[30]=m,e[31]=W):W=e[31];let G;e[32]!==V||e[33]!==W?(G=(0,$.jsxs)(ue,{className:`shrink-0`,children:[V,W]}),e[32]=V,e[33]=W,e[34]=G):G=e[34];let K;e[35]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>n(!0),e[35]=K):K=e[35];let q;e[36]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(N,{className:`h-4 w-4`}),e[36]=q):q=e[36];let J;e[37]===C?J=e[38]:(J=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(F,{type:`button`,variant:`outline`,size:`icon`,className:`shrink-0`,onClick:K,disabled:C,"aria-label":`Add Machine`,children:q})}),e[37]=C,e[38]=J);let Y;e[39]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,$.jsx)(ee,{children:`Add Machine`}),e[39]=Y):Y=e[39];let ie;e[40]===J?ie=e[41]:(ie=(0,$.jsx)(oe,{title:`Remote Machines`,className:`[&>div:first-child]:py-2`,sticky:!1,action:(0,$.jsxs)(L,{children:[J,Y]})}),e[40]=J,e[41]=ie);let ae;e[42]!==S||e[43]!==C||e[44]!==w||e[45]!==T||e[46]!==E||e[47]!==D||e[48]!==O?(ae=(0,$.jsx)(_e,{className:`max-w-none pt-0`,children:(0,$.jsx)(ce,{children:(0,$.jsx)(At,{remoteMachines:T,draftNames:S,isLoading:C,isSavingId:w,onDraftNameChange:O,onDraftNameBlur:D,onRemoveMachine:E})})}),e[42]=S,e[43]=C,e[44]=w,e[45]=T,e[46]=E,e[47]=D,e[48]=O,e[49]=ae):ae=e[49];let se;e[50]!==ie||e[51]!==ae?(se=(0,$.jsxs)(ue,{className:`shrink-0 pt-6`,children:[ie,ae]}),e[50]=ie,e[51]=ae,e[52]=se):se=e[52];let le;e[53]!==G||e[54]!==se?(le=(0,$.jsxs)(`div`,{className:`divide-y divide-table-border [&>*]:rounded-none`,children:[G,se]}),e[53]=G,e[54]=se,e[55]=le):le=e[55];let X;e[56]===x?X=e[57]:(X=async function(e){await x(e)},e[56]=x,e[57]=X);let de;e[58]!==t||e[59]!==X?(de=(0,$.jsx)(Ve,{open:t,onOpenChange:n,onSave:X}),e[58]=t,e[59]=X,e[60]=de):de=e[60];let pe;return e[61]!==A||e[62]!==le||e[63]!==de?(pe=(0,$.jsxs)(fe,{loading:A,children:[le,de]}),e[61]=A,e[62]=le,e[63]=de,e[64]=pe):pe=e[64],pe}export{jt as default};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-coding-view-DP4qKePE.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/react-vendor-D61Uve5n.js","assets/chunk-QFMPRPBF-Cy-_pFSM.js","assets/dist-v_MvKS2-.js","assets/store-W78TGOIO.js","assets/utils-CqsIXqSC.js","assets/api-C4ukGdyH.js","assets/loader-circle-CrqRIqdA.js","assets/createLucideIcon-2A3hmV_e.js","assets/button-DDaJhJP1.js","assets/tooltip-CqwCZ7wt.js","assets/dist-AbkJBHH5.js","assets/dist-2xH_pFmV.js","assets/use-toast-CKgZ8YeP.js","assets/progress-indicator-hJ74ac5W.js","assets/index-CoY8DilQ.js","assets/useBaseQuery-yghQO052.js","assets/QueryClientProvider-CYXTUmYo.js","assets/useInfiniteQuery-BpKy1sCq.js","assets/use-account-settings-query-C-zOdREq.js","assets/useQuery-DWt09r77.js","assets/query-keys-BwswkbMn.js","assets/chat-handlers-context-2xSKzkKa.js","assets/create-project-workspace-DSTTGom_.js","assets/terminal-output-activity-D_FxlE-L.js","assets/task-utils-BZPVmvY4.js","assets/suspense-resource-DzlMlIgR.js","assets/random-uuid-Dc3UrwVo.js","assets/remote-media-url-CyuN31H_.js","assets/use-open-chat-dock-panel-DqfWJ8e8.js","assets/chat-dock-context-a2bV9cnz.js","assets/explorer-tab-context-BwR8CM8l.js","assets/main-tab-context-Dsp4OYi9.js","assets/dist-CgbWuuq4.js","assets/markdown-renderer-D2VcKU4g.js","assets/explorer-media-CRzhs0NW.js","assets/check-skFQ1X72.js","assets/copy-bi9iX3xn.js","assets/download-CWhQNGlF.js","assets/external-link-Dcikmdm_.js","assets/minus-CgQcbBQT.js","assets/dialog-D_12AsZd.js","assets/x-ByOPrz5I.js","assets/dist-DfnQ9YJh.js","assets/es2015-eNVkKfFF.js","assets/use-browser-overlay-block-CO1pUEAZ.js","assets/play-Dn1mbRpD.js","assets/plus-DoMzejDu.js","assets/rotate-ccw-Dthg8Pv6.js","assets/chevron-down-Bpo4ncEN.js","assets/chevron-right-Dga3q1bZ.js","assets/chevron-up-BxgjX7B3.js","assets/circle-alert-CC2eO3yt.js","assets/circle-DQwOli2u.js","assets/grip-vertical-_jCIw8Mw.js","assets/square-CtxvwmM2.js","assets/dist-B-h6Wj39.js","assets/label-BCs5CZEs.js","assets/dist-Dx8OsX8-.js","assets/dist-pCVg1Jdl.js","assets/dist-DOz2WXwX.js","assets/dist-JGbQ_EJY.js","assets/scroll-area-CGEZ1gAL.js","assets/alert-dialog-BcZULJsX.js","assets/use-projects-CizIH2Fa.js","assets/use-suspense-resource-uCX26gOk.js","assets/explorer-file-drop-CzyAqZgf.js","assets/api-B_GSyYGh.js","assets/dist-CkGJjZXY.js","assets/select-BR2pG61R.js","assets/mcp-manager-D1HmLT3t.js","assets/index-D14wLW4o.css","assets/commit-method-fields-Xt3vbwUg.js","assets/toggle-group-CPmseZfb.js","assets/use-settings-page-loading-B5WU5d1c.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,o as n,r,t as i}from"./react-vendor-D61Uve5n.js";import{o as a,s as o}from"./chunk-QFMPRPBF-Cy-_pFSM.js";import"./dist-v_MvKS2-.js";import{Z as s,n as c,r as l}from"./store-W78TGOIO.js";import{t as u}from"./progress-indicator-hJ74ac5W.js";import{M as d,at as f,gt as p,pt as m}from"./index-CoY8DilQ.js";import{t as h}from"./settings-tab-bar-DYzU_lmi.js";var g=[{value:`setup`,label:`Setup`},{value:`commands`,label:`Commands`}];function _(e){let t=e.replace(/\/+$/,``);return/^\/settings\/project\/[^/]+\/coding$/.test(t)?`setup`:/^\/settings\/project\/[^/]+\/coding\/commands$/.test(t)?`commands`:null}var v=e(n(),1),y=t(),b=i();function x(e){let t=(0,y.c)(9),{projectId:n}=e,r=c(),i;t[0]===n?i=t[1]:(i=function(e){return e.projects.find(e=>e.projectId===n)?.commands??[]},t[0]=n,t[1]=i);let a=l(i),o;t[2]===r?o=t[3]:(o=function(){r({type:s.ConfigUpdated})},t[2]=r,t[3]=o);let u=o,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,b.jsx)(f,{title:`Project Commands`,description:`Create and manage reusable commands for this project.`}),t[4]=h):h=t[4];let g;return t[5]!==a||t[6]!==u||t[7]!==n?(g=(0,b.jsx)(p,{className:`shrink-0`,children:(0,b.jsxs)(m,{children:[h,(0,b.jsx)(d,{embedded:!0,open:!0,projectId:n,commands:a,onRefresh:u})]})}),t[5]=a,t[6]=u,t[7]=n,t[8]=g):g=t[8],g}var S=(0,v.lazy)(function(){return r(()=>import(`./project-coding-view-DP4qKePE.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75]))});function C(e){let t=(0,y.c)(22),{projectId:n,onProjectUpdated:r}=e,i=a(),s=o(),c;t[0]===i.pathname?c=t[1]:(c=_(i.pathname)??`setup`,t[0]=i.pathname,t[1]=c);let l=c,d;t[2]!==s||t[3]!==n?(d=function(e){s(e===`setup`?`/settings/project/${n}/coding`:`/settings/project/${n}/coding/${e}`)},t[2]=s,t[3]=n,t[4]=d):d=t[4];let f=d,p;t[5]!==l||t[6]!==f?(p=(0,b.jsx)(h,{value:l,onValueChange:f,options:g}),t[5]=l,t[6]=f,t[7]=p):p=t[7];let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,b.jsx)(u,{centered:!0,label:`Loading project setup...`}),t[8]=m):m=t[8];let C;t[9]!==l||t[10]!==r||t[11]!==n?(C=l===`setup`&&(0,b.jsx)(S,{projectId:n,onProjectUpdated:r}),t[9]=l,t[10]=r,t[11]=n,t[12]=C):C=t[12];let w;t[13]!==l||t[14]!==n?(w=l===`commands`&&(0,b.jsx)(x,{projectId:n}),t[13]=l,t[14]=n,t[15]=w):w=t[15];let T;t[16]!==C||t[17]!==w?(T=(0,b.jsx)(`div`,{className:`min-h-0 flex-1`,role:`region`,"aria-label":`Project setup`,children:(0,b.jsxs)(v.Suspense,{fallback:m,children:[C,w]})}),t[16]=C,t[17]=w,t[18]=T):T=t[18];let E;return t[19]!==p||t[20]!==T?(E=(0,b.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[p,T]}),t[19]=p,t[20]=T,t[21]=E):E=t[21],E}export{C as default};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-coding-view-B2FpHeiO.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/react-vendor-D61Uve5n.js","assets/chunk-QFMPRPBF-Cy-_pFSM.js","assets/dist-v_MvKS2-.js","assets/store-W78TGOIO.js","assets/utils-CqsIXqSC.js","assets/api-Cp9I7CxD.js","assets/loader-circle-CrqRIqdA.js","assets/createLucideIcon-2A3hmV_e.js","assets/button-DDaJhJP1.js","assets/tooltip-CqwCZ7wt.js","assets/dist-AbkJBHH5.js","assets/dist-2xH_pFmV.js","assets/use-toast-CKgZ8YeP.js","assets/progress-indicator-hJ74ac5W.js","assets/index-CcAwxnT5.js","assets/useBaseQuery-yghQO052.js","assets/QueryClientProvider-CYXTUmYo.js","assets/useInfiniteQuery-BpKy1sCq.js","assets/use-account-settings-query-D_qL1I4w.js","assets/useQuery-DWt09r77.js","assets/query-keys-CcnonAAG.js","assets/chat-handlers-context-DYU2LQ5V.js","assets/create-project-workspace-CJ94yHAB.js","assets/terminal-output-activity-D_FxlE-L.js","assets/task-utils-Cnq9Eszt.js","assets/suspense-resource-DzlMlIgR.js","assets/random-uuid-Dc3UrwVo.js","assets/remote-media-url-C-GdJb-D.js","assets/use-open-chat-dock-panel-CXzpgxVs.js","assets/chat-dock-context-DbiJNr3O.js","assets/explorer-tab-context-BwR8CM8l.js","assets/main-tab-context-Dsp4OYi9.js","assets/dist-CgbWuuq4.js","assets/markdown-renderer-DQONI6WG.js","assets/explorer-media-CRzhs0NW.js","assets/check-skFQ1X72.js","assets/copy-bi9iX3xn.js","assets/download-CWhQNGlF.js","assets/external-link-Dcikmdm_.js","assets/minus-CgQcbBQT.js","assets/dialog-D_12AsZd.js","assets/x-ByOPrz5I.js","assets/dist-DfnQ9YJh.js","assets/es2015-eNVkKfFF.js","assets/use-browser-overlay-block-CO1pUEAZ.js","assets/play-Dn1mbRpD.js","assets/plus-DoMzejDu.js","assets/rotate-ccw-Dthg8Pv6.js","assets/chevron-down-Bpo4ncEN.js","assets/chevron-right-Dga3q1bZ.js","assets/chevron-up-BxgjX7B3.js","assets/circle-alert-CC2eO3yt.js","assets/circle-DQwOli2u.js","assets/grip-vertical-_jCIw8Mw.js","assets/square-CtxvwmM2.js","assets/dist-B-h6Wj39.js","assets/label-BCs5CZEs.js","assets/dist-Dx8OsX8-.js","assets/dist-pCVg1Jdl.js","assets/dist-DOz2WXwX.js","assets/dist-JGbQ_EJY.js","assets/scroll-area-DGF9wUqQ.js","assets/alert-dialog-BcZULJsX.js","assets/use-projects-B0xTjTaA.js","assets/use-suspense-resource-uCX26gOk.js","assets/explorer-file-drop-DAP7ha-E.js","assets/api-8Rp2LlXt.js","assets/dist-CkGJjZXY.js","assets/select-DMcNYwgt.js","assets/mcp-manager-D2FG-h2e.js","assets/index-dNrgKdYv.css","assets/commit-method-fields-Xt3vbwUg.js","assets/toggle-group-CPmseZfb.js","assets/use-settings-page-loading-B5WU5d1c.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,o as n,r,t as i}from"./react-vendor-D61Uve5n.js";import{o as a,s as o}from"./chunk-QFMPRPBF-Cy-_pFSM.js";import"./dist-v_MvKS2-.js";import{Z as s,n as c,r as l}from"./store-W78TGOIO.js";import{t as u}from"./progress-indicator-hJ74ac5W.js";import{M as d,at as f,gt as p,pt as m}from"./index-CcAwxnT5.js";import{t as h}from"./settings-tab-bar-CdIbQ0WI.js";var g=[{value:`setup`,label:`Setup`},{value:`commands`,label:`Commands`}];function _(e){let t=e.replace(/\/+$/,``);return/^\/settings\/project\/[^/]+\/coding$/.test(t)?`setup`:/^\/settings\/project\/[^/]+\/coding\/commands$/.test(t)?`commands`:null}var v=e(n(),1),y=t(),b=i();function x(e){let t=(0,y.c)(9),{projectId:n}=e,r=c(),i;t[0]===n?i=t[1]:(i=function(e){return e.projects.find(e=>e.projectId===n)?.commands??[]},t[0]=n,t[1]=i);let a=l(i),o;t[2]===r?o=t[3]:(o=function(){r({type:s.ConfigUpdated})},t[2]=r,t[3]=o);let u=o,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,b.jsx)(f,{title:`Project Commands`,description:`Create and manage reusable commands for this project.`}),t[4]=h):h=t[4];let g;return t[5]!==a||t[6]!==u||t[7]!==n?(g=(0,b.jsx)(p,{className:`shrink-0`,children:(0,b.jsxs)(m,{children:[h,(0,b.jsx)(d,{embedded:!0,open:!0,projectId:n,commands:a,onRefresh:u})]})}),t[5]=a,t[6]=u,t[7]=n,t[8]=g):g=t[8],g}var S=(0,v.lazy)(function(){return r(()=>import(`./project-coding-view-B2FpHeiO.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75]))});function C(e){let t=(0,y.c)(22),{projectId:n,onProjectUpdated:r}=e,i=a(),s=o(),c;t[0]===i.pathname?c=t[1]:(c=_(i.pathname)??`setup`,t[0]=i.pathname,t[1]=c);let l=c,d;t[2]!==s||t[3]!==n?(d=function(e){s(e===`setup`?`/settings/project/${n}/coding`:`/settings/project/${n}/coding/${e}`)},t[2]=s,t[3]=n,t[4]=d):d=t[4];let f=d,p;t[5]!==l||t[6]!==f?(p=(0,b.jsx)(h,{value:l,onValueChange:f,options:g}),t[5]=l,t[6]=f,t[7]=p):p=t[7];let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,b.jsx)(u,{centered:!0,label:`Loading project setup...`}),t[8]=m):m=t[8];let C;t[9]!==l||t[10]!==r||t[11]!==n?(C=l===`setup`&&(0,b.jsx)(S,{projectId:n,onProjectUpdated:r}),t[9]=l,t[10]=r,t[11]=n,t[12]=C):C=t[12];let w;t[13]!==l||t[14]!==n?(w=l===`commands`&&(0,b.jsx)(x,{projectId:n}),t[13]=l,t[14]=n,t[15]=w):w=t[15];let T;t[16]!==C||t[17]!==w?(T=(0,b.jsx)(`div`,{className:`min-h-0 flex-1`,role:`region`,"aria-label":`Project setup`,children:(0,b.jsxs)(v.Suspense,{fallback:m,children:[C,w]})}),t[16]=C,t[17]=w,t[18]=T):T=t[18];let E;return t[19]!==p||t[20]!==T?(E=(0,b.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[p,T]}),t[19]=p,t[20]=T,t[21]=E):E=t[21],E}export{C as default};
@@ -1,2 +1,2 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,o as n,t as r}from"./react-vendor-D61Uve5n.js";import{U as i}from"./dist-v_MvKS2-.js";import{r as a,rt as o}from"./store-W78TGOIO.js";import{Ar as s,Cr as c,Dr as l,Ei as u,Er as d,Fi as f,Gi as p,Hi as m,Kn as h,Ln as g,Or as _,Ti as v,Tr as y,Wn as b,br as x,ca as S,da as C,jr as w,k as T,sn as E,xr as D,yr as O}from"./api-C4ukGdyH.js";import{t as k}from"./markdown-renderer-D2VcKU4g.js";import{p as A,t as j}from"./utils-CqsIXqSC.js";import{t as M}from"./chevron-down-Bpo4ncEN.js";import{t as ee}from"./download-CWhQNGlF.js";import{t as N}from"./external-link-Dcikmdm_.js";import{t as P}from"./loader-circle-CrqRIqdA.js";import{a as F,i as I,o as L,r as R,s as te,t as z}from"./dialog-D_12AsZd.js";import{t as ne}from"./plus-DoMzejDu.js";import{t as B}from"./button-DDaJhJP1.js";import{i as V,n as H,r as U,t as W}from"./tooltip-CqwCZ7wt.js";import{t as G}from"./label-BCs5CZEs.js";import{t as K}from"./use-toast-CKgZ8YeP.js";import{t as re}from"./progress-indicator-hJ74ac5W.js";import{a as ie,c as ae,i as oe,n as se,o as ce,r as le,s as ue,t as de}from"./alert-dialog-BcZULJsX.js";import{a as fe,n as pe,o as me,r as he,t as ge}from"./select-BR2pG61R.js";import{Gn as _e,Hn as ve,Ut as ye,Wn as be,at as q,dr as xe,ft as Se,gn as J,gt as Ce,hn as we,ht as Te,i as Ee,in as Y,ir as De,it as Oe,lt as ke,nt as Ae,on as je,pt as Me,rn as Ne,tn as Pe,tt as Fe,un as Ie,vn as Le}from"./index-CoY8DilQ.js";import{t as Re}from"./delete-confirm-dialog-D1N86piR.js";import{t as ze}from"./use-settings-page-loading-B5WU5d1c.js";import{a as Be,o as Ve,r as He}from"./settings-list-Dgip9HpD.js";import{t as Ue}from"./use-deferred-search-xgS_2fMW.js";import{i as We,n as Ge,r as Ke,t as qe}from"./slug-utils-CO6nui1C.js";import{i as Je,n as Ye,r as Xe,t as Ze}from"./use-installed-ai-files-DQey9Zm3.js";var Qe=`custom-`;function $e(e){return e.startsWith(Qe)}var X=t(),Z=e(n(),1),Q=r();function et({threadId:e,onSkillCreated:t}){let[n,r]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),l=Ke(n),u=Ge(l),d=async()=>{if(u&&a.trim()&&e){c(!0);try{let n=await T(e,l,a.trim());K({title:`Skill created`,description:`Skill '${l}' was created successfully.`}),r(``),o(``),t?.(n.path,`SKILL.md`)}catch(e){K({title:`Error`,description:e instanceof Error?e.message:`Failed to create skill`,variant:`destructive`})}finally{c(!1)}}};return e?(0,Q.jsx)(Te,{children:(0,Q.jsxs)(Fe,{children:[(0,Q.jsx)(q,{title:`Add Skill`,description:`Saved as SKILL.md in .agents/skills.`,sticky:!0,className:`pr-10`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(Ae,{title:`Skill Name`,controlLayout:`stack`,className:`pt-6`,children:[(0,Q.jsx)(J,{id:`skillName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Code Review`,disabled:s}),n?(0,Q.jsxs)(`p`,{className:j(i.caption,`mt-2`),children:[`Folder name: `,(0,Q.jsx)(`span`,{className:`font-mono`,children:l||`...`})]}):null]}),(0,Q.jsx)(Ae,{title:`Description`,controlLayout:`stack`,className:`pt-6`,children:(0,Q.jsx)(we,{id:`skillDescription`,value:a,onChange:e=>o(e.target.value),placeholder:`Describe when Tarsk should apply this skill`,className:`resize-none min-h-[120px]`,disabled:s})}),(0,Q.jsx)(We,{onContinue:()=>void d(),disabled:!u||!a.trim(),creating:s})]})]})}):(0,Q.jsx)(Se,{title:`No thread selected`,children:`Please select a thread to add a skill.`})}var tt=`.agents/skills`;function nt(e){return`${tt}/${e}`}function rt(e){return`${nt(e)}/SKILL.md`}function it(e,t){let n=t.trim();if(!n)return e;let r=n.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(r)||e.description.toLowerCase().includes(r))}function at(e){let t=[`---`,`name: ${e.id}`,`description: ${e.description}`];return e.allowedTools&&t.push(`allowed-tools: ${e.allowedTools}`),e.license&&t.push(`license: ${e.license}`),t.push(`---`,``,e.instructions??``),t.join(`
2
- `)}function ot(e,t,n){return it(e,t).filter(e=>!n.has(rt(e.id)))}function st(e){return e.endsWith(`.md`)||e.endsWith(`.mdx`)}function ct(e){return e.includes(`SKILL.md`)?`SKILL.md`:e[0]??`SKILL.md`}function lt(e,t){let n=e?.sourceId??t;if(n&&n!=="default")return n}function ut(e,t,n){let[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),h=lt(t,n),g=!!h;return(0,Z.useEffect)(()=>{if(!e||!t)return;let r=t,a=lt(r,n),s=!1;async function l(){u(!0),m(null),i([]),o(null),c(``);try{if(a){let e=await D(a,r.id);if(s)return;i(e.files),o(ct(e.files))}else{if(s)return;i([`SKILL.md`]),o(`SKILL.md`),c(at(r))}}catch(e){if(s)return;m(e instanceof Error?e.message:`Failed to load skill files`)}finally{s||u(!1)}}return l(),()=>{s=!0}},[e,t,n]),(0,Z.useEffect)(()=>{if(!e||!t||!a||!g||!h)return;let n=t,r=a,i=!1;async function o(){f(!0),m(null);try{let e=await x(h,n.id,r);if(i)return;c(e.content)}catch(e){if(i)return;m(e instanceof Error?e.message:`Failed to load file`),c(``)}finally{i||f(!1)}}return o(),()=>{i=!0}},[e,t,a,g,h]),{files:r,selectedFile:a,setSelectedFile:o,fileContent:s,loadingFiles:l,contentLoading:l||g&&d,loadError:p,isCatalogSkill:g,effectiveSourceId:h}}function dt({open:e,onOpenChange:t,skill:n,catalogSourceId:r,onInstall:a}){let[o,s]=(0,Z.useState)(!1),{files:c,selectedFile:l,setSelectedFile:u,fileContent:d,loadingFiles:f,contentLoading:p,loadError:m,effectiveSourceId:h}=ut(e,n,r),g=(0,Z.useCallback)(async()=>{if(!n)return;let e=h?{...n,sourceId:h}:n;s(!0);try{await a(e),t(!1)}finally{s(!1)}},[n,h,a,t]),_=l?st(l):!1,v=(0,Z.useMemo)(()=>c.map(e=>(0,Q.jsxs)(ye,{selected:e===l,onClick:()=>u(e),className:`gap-2 cursor-pointer`,children:[(0,Q.jsx)(xe,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:j(i.caption,`truncate`),children:e})]},e)),[c,l]);return(0,Q.jsx)(z,{open:e,onOpenChange:t,children:(0,Q.jsxs)(R,{className:`flex max-h-[90vh] max-w-5xl flex-col gap-0 overflow-hidden p-0`,children:[(0,Q.jsxs)(L,{className:`border-b border-border px-6 py-4`,children:[(0,Q.jsx)(te,{children:n?.name??`Review skill`}),n?.description?(0,Q.jsx)(I,{children:n.description}):null]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row`,children:[(0,Q.jsxs)(`div`,{className:`flex max-h-40 shrink-0 flex-col border-b border-border sm:max-h-none sm:w-56 sm:border-b-0 sm:border-r`,children:[(0,Q.jsx)(`div`,{className:j(i.labelMuted,`px-3 py-2`),children:`Files`}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 pb-2`,children:f?(0,Q.jsx)(re,{centered:!0,containerClassName:`py-8`,label:`Loading files...`}):c.length===0?(0,Q.jsx)(`p`,{className:j(i.caption,`px-3 py-2 text-muted-foreground`),children:`No files found.`}):v})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-4`,children:m?(0,Q.jsx)(`p`,{className:j(i.body,`text-destructive`),children:m}):p?(0,Q.jsx)(re,{centered:!0,containerClassName:`py-12`,label:`Loading preview...`}):_?(0,Q.jsx)(k,{content:d,enableMermaid:!1}):(0,Q.jsx)(`pre`,{className:j(i.caption,`overflow-x-auto whitespace-pre-wrap font-mono`),children:d})})]}),(0,Q.jsxs)(F,{className:`border-t border-border px-6 py-4 sm:justify-between`,children:[(0,Q.jsx)(B,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(B,{type:`button`,onClick:()=>void g(),disabled:o||!n,children:o?`Installing...`:`Install`})]})]})})}function ft({open:e,onOpenChange:t,editingSource:n,onSourceAdded:r,onSourceUpdated:a,onSourceDeleted:o}){let[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),b=n!=null;function x(){l(``),d(``),p(null),h(!1),_(!1),y(!1)}function S(e){e||x(),t(e)}(0,Z.useEffect)(()=>{if(e){if(n){l(n.title),d(n.url),p(null);return}l(``),d(``),p(null)}},[e,n]);async function C(){let e=c.trim(),t=u.trim();if(!e||!t){p(`Title and URL are required.`);return}h(!0),p(null);try{if(b&&n){let r=await s(n.id,e,t);a?.(r.source)}else r((await w(e,t)).source);S(!1)}catch(e){p(e instanceof Error?e.message:`Failed to verify skill source`)}finally{h(!1)}}async function T(){if(n){_(!0),p(null);try{await O(n.id),o?.(n.id),y(!1),S(!1)}catch(e){p(e instanceof Error?e.message:`Failed to delete skill source`),y(!1)}finally{_(!1)}}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{open:e,onOpenChange:S,children:(0,Q.jsxs)(R,{className:`sm:max-w-lg`,children:[(0,Q.jsxs)(L,{children:[(0,Q.jsx)(te,{children:b?`Edit Skill Source`:`Add Skill Source`}),(0,Q.jsx)(I,{children:b?`Update the title or GitHub skills folder URL for this custom source.`:`Add a GitHub skills folder URL. The source is verified by loading at least one skill from the repository.`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(G,{htmlFor:`skill-source-title`,children:`Title`}),(0,Q.jsx)(J,{id:`skill-source-title`,placeholder:`e.g. My Team Skills`,value:c,onChange:e=>l(e.target.value),disabled:m||g,autoFocus:!0})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(G,{htmlFor:`skill-source-url`,children:`URL`}),(0,Q.jsx)(J,{id:`skill-source-url`,placeholder:`https://github.com/org/repo or .../tree/main/skills`,value:u,onChange:e=>d(e.target.value),disabled:m||g})]}),f?(0,Q.jsx)(`p`,{className:j(i.caption,`text-destructive`),children:f}):null]}),(0,Q.jsxs)(F,{className:`flex-col-reverse gap-2 sm:flex-row sm:justify-between`,children:[b?(0,Q.jsx)(B,{type:`button`,variant:`destructive`,onClick:()=>y(!0),disabled:m||g,children:`Delete`}):(0,Q.jsx)(`div`,{className:`hidden sm:block`}),(0,Q.jsxs)(`div`,{className:`flex w-full flex-col-reverse gap-2 sm:w-auto sm:flex-row`,children:[(0,Q.jsx)(B,{variant:`outline`,onClick:()=>S(!1),disabled:m||g,children:`Cancel`}),(0,Q.jsx)(B,{onClick:()=>void C(),disabled:m||g||!c.trim()||!u.trim(),children:m?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{className:`mr-2 h-4 w-4 animate-spin`}),`Verifying...`]}):b?`Save Changes`:`Add Source`})]})]})]})}),(0,Q.jsx)(de,{open:v,onOpenChange:y,children:(0,Q.jsxs)(oe,{children:[(0,Q.jsxs)(ue,{children:[(0,Q.jsx)(ae,{children:`Delete Skill Source`}),(0,Q.jsxs)(ie,{children:[`Are you sure you want to delete "`,n?.title,`"? This removes the source from your list but does not uninstall skills you already added.`]})]}),(0,Q.jsxs)(ce,{children:[(0,Q.jsx)(le,{disabled:g,children:`Cancel`}),(0,Q.jsx)(se,{onClick:()=>void T(),disabled:g,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:g?`Deleting...`:`Delete`})]})]})})]})}function pt(e){let t=e.trim();if(!t)return null;if(/^https?:\/\//i.test(t))try{return new URL(t),t}catch{return null}if(t.startsWith(`tarsk://`))try{let e=new URL(`https://tarsk.invalid/${t.slice(8)}`);if(e.pathname===`/skill-install`&&e.searchParams.get(`url`))return e.searchParams.get(`url`)}catch{return null}return null}function mt(e){let t=(0,X.c)(40),{open:n,onOpenChange:r,onSubmit:a}=e,[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=function(){s(``),l(null)},t[0]=u):u=t[0];let d=u,f;t[1]===r?f=t[2]:(f=function(e){e||d(),r(e)},t[1]=r,t[2]=f);let p=f,m,h;t[3]===n?(m=t[4],h=t[5]):(m=()=>{n&&d()},h=[n],t[3]=n,t[4]=m,t[5]=h),(0,Z.useEffect)(m,h);let g;t[6]!==p||t[7]!==a||t[8]!==o?(g=function(){let e=pt(o);if(!e){l(`Enter a valid http(s) URL for the plugin archive or paste a tarsk:// install link.`);return}a(e),p(!1)},t[6]=p,t[7]=a,t[8]=o,t[9]=g):g=t[9];let _=g,v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsxs)(L,{children:[(0,Q.jsx)(te,{children:`Add Skill via URL`}),(0,Q.jsx)(I,{children:`Paste the URL of a plugin archive. Its skills and MCP servers are installed into this project.`})]}),t[10]=v):v=t[10];let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(G,{htmlFor:`add-skill-url`,children:`URL`}),t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>s(e.target.value),t[12]=b):b=t[12];let x;t[13]===_?x=t[14]:(x=e=>{e.key===`Enter`&&(e.preventDefault(),_())},t[13]=_,t[14]=x);let S;t[15]!==x||t[16]!==o?(S=(0,Q.jsx)(J,{id:`add-skill-url`,placeholder:`https://example.com/my-plugin.zip`,value:o,onChange:b,autoFocus:!0,onKeyDown:x}),t[15]=x,t[16]=o,t[17]=S):S=t[17];let C;t[18]===c?C=t[19]:(C=c?(0,Q.jsx)(`p`,{className:j(i.caption,`text-destructive`),children:c}):null,t[18]=c,t[19]=C);let w;t[20]!==S||t[21]!==C?(w=(0,Q.jsx)(`div`,{className:`grid gap-4 py-2`,children:(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[y,S,C]})}),t[20]=S,t[21]=C,t[22]=w):w=t[22];let T;t[23]===p?T=t[24]:(T=(0,Q.jsx)(B,{variant:`outline`,onClick:()=>p(!1),children:`Cancel`}),t[23]=p,t[24]=T);let E;t[25]===o?E=t[26]:(E=o.trim(),t[25]=o,t[26]=E);let D=!E,O;t[27]!==_||t[28]!==D?(O=(0,Q.jsx)(B,{onClick:_,disabled:D,children:`Continue`}),t[27]=_,t[28]=D,t[29]=O):O=t[29];let k;t[30]!==T||t[31]!==O?(k=(0,Q.jsxs)(F,{children:[T,O]}),t[30]=T,t[31]=O,t[32]=k):k=t[32];let A;t[33]!==w||t[34]!==k?(A=(0,Q.jsxs)(R,{className:`sm:max-w-lg`,children:[v,w,k]}),t[33]=w,t[34]=k,t[35]=A):A=t[35];let M;return t[36]!==p||t[37]!==n||t[38]!==A?(M=(0,Q.jsx)(z,{open:n,onOpenChange:p,children:A}),t[36]=p,t[37]=n,t[38]=A,t[39]=M):M=t[39],M}function ht(e){let t=(0,X.c)(7),{items:n,onPreview:r}=e,a;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=e=>{let t=qe(e.name);return(0,Q.jsxs)(`div`,{className:`group flex min-h-13 items-center gap-3 px-3 py-2`,role:`button`,tabIndex:0,onClick:()=>r(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(e))},children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:j(i.label,`truncate`),children:t}),(0,Q.jsx)(`p`,{className:j(i.caption,`truncate`),children:e.description})]}),(0,Q.jsx)(U,{delayDuration:300,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(V,{asChild:!0,children:(0,Q.jsx)(B,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`shrink-0 opacity-0 pointer-events-none can-hover:group-hover:opacity-100 can-hover:group-hover:pointer-events-auto`,"aria-label":`Install ${t}`,onClick:t=>{t.stopPropagation(),r(e)},children:(0,Q.jsx)(ee,{className:`h-4 w-4`})})}),(0,Q.jsx)(H,{children:`Install skill`})]})})]},e.id)},t[3]=r,t[4]=e),a=n.map(e),t[0]=n,t[1]=r,t[2]=a}else a=t[2];let o;return t[5]===a?o=t[6]:(o=(0,Q.jsx)(`div`,{className:`divide-y divide-table-border`,children:a}),t[5]=a,t[6]=o),o}function gt(e){let t=(0,X.c)(11),{searchQuery:n,isLoadingCatalog:r,isDefaultSource:i,availablePopular:a,availableCatalog:o,onPreviewPopular:s,onPreviewCatalog:c}=e;if(r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(re,{centered:!0,containerClassName:`py-12`,label:`Loading skills...`}),t[0]=e):e=t[0],e}if(i){if(a.length===0){let e;return t[1]===n?e=t[2]:(e=(0,Q.jsx)(Be,{searchQuery:n,emptyLabel:`No available skills found.`}),t[1]=n,t[2]=e),e}let e;return t[3]!==a||t[4]!==s?(e=(0,Q.jsx)(ht,{items:a,onPreview:s}),t[3]=a,t[4]=s,t[5]=e):e=t[5],e}if(o.length===0){let e;return t[6]===n?e=t[7]:(e=(0,Q.jsx)(Be,{searchQuery:n,emptyLabel:`No available skills found.`}),t[6]=n,t[7]=e),e}let l;return t[8]!==o||t[9]!==c?(l=(0,Q.jsx)(ht,{items:o,onPreview:c}),t[8]=o,t[9]=c,t[10]=l):l=t[10],l}function _t(e){return e?{ariaLabel:`Edit skill source`,tooltip:`Edit this custom skill source`,icon:be}:{ariaLabel:`Add skill source`,tooltip:`Add a custom skill source`,icon:ne}}function vt(e){let t=(0,X.c)(42),{availableSearch:n,onSearchChange:r,selectedSourceId:i,onSourceChange:a,sources:o,selectedCustomSource:s,availableCatalogLoading:c,isDefaultSource:l,availablePopular:u,availableCatalog:d,onPreviewPopular:f,onPreviewCatalog:p,onAddSource:m}=e,h;t[0]===s?h=t[1]:(h=_t(s),t[0]=s,t[1]=h);let g=h,_=g.icon,v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(U,{children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(V,{asChild:!0,children:(0,Q.jsx)(`span`,{className:`cursor-help`,children:`Available Skills`})}),(0,Q.jsx)(H,{children:`Browse and install skills from the catalog.`})]})}),t[2]=v):v=t[2];let y;t[3]!==n||t[4]!==r?(y=(0,Q.jsx)(Ve,{placeholder:`Search`,value:n,onChange:r,className:`mb-0 w-64`}),t[3]=n,t[4]=r,t[5]=y):y=t[5];let b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(fe,{className:`w-40`,"aria-label":`Skill source`,children:(0,Q.jsx)(me,{placeholder:`Default`})}),t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(he,{value:`default`,children:`Default`}),t[7]=x):x=t[7];let S;t[8]===o?S=t[9]:(S=o.map(yt),t[8]=o,t[9]=S);let C;t[10]===S?C=t[11]:(C=(0,Q.jsxs)(pe,{children:[x,S]}),t[10]=S,t[11]=C);let w;t[12]!==a||t[13]!==i||t[14]!==C?(w=(0,Q.jsxs)(ge,{value:i,onValueChange:a,children:[b,C]}),t[12]=a,t[13]=i,t[14]=C,t[15]=w):w=t[15];let T;t[16]===_?T=t[17]:(T=(0,Q.jsx)(_,{className:`h-4 w-4`}),t[16]=_,t[17]=T);let E;t[18]!==m||t[19]!==g.ariaLabel||t[20]!==T?(E=(0,Q.jsx)(V,{asChild:!0,children:(0,Q.jsx)(B,{type:`button`,variant:`outline`,size:`icon`,className:`shrink-0`,onClick:m,"aria-label":g.ariaLabel,children:T})}),t[18]=m,t[19]=g.ariaLabel,t[20]=T,t[21]=E):E=t[21];let D;t[22]===g.tooltip?D=t[23]:(D=(0,Q.jsx)(H,{children:g.tooltip}),t[22]=g.tooltip,t[23]=D);let O;t[24]!==E||t[25]!==D?(O=(0,Q.jsx)(U,{children:(0,Q.jsxs)(W,{children:[E,D]})}),t[24]=E,t[25]=D,t[26]=O):O=t[26];let k;t[27]!==O||t[28]!==y||t[29]!==w?(k=(0,Q.jsx)(q,{title:v,action:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y,w,O]}),sticky:!1}),t[27]=O,t[28]=y,t[29]=w,t[30]=k):k=t[30];let A;t[31]!==d||t[32]!==c||t[33]!==u||t[34]!==n||t[35]!==l||t[36]!==p||t[37]!==f?(A=(0,Q.jsx)(Me,{className:`pt-6`,children:(0,Q.jsx)(gt,{searchQuery:n,isLoadingCatalog:c,isDefaultSource:l,availablePopular:u,availableCatalog:d,onPreviewPopular:f,onPreviewCatalog:p})}),t[31]=d,t[32]=c,t[33]=u,t[34]=n,t[35]=l,t[36]=p,t[37]=f,t[38]=A):A=t[38];let j;return t[39]!==k||t[40]!==A?(j=(0,Q.jsxs)(Ce,{className:`shrink-0`,children:[k,A]}),t[39]=k,t[40]=A,t[41]=j):j=t[41],j}function yt(e){return(0,Q.jsx)(he,{value:e.id,children:e.title},e.id)}var bt=`https://tarsk.io/skills/list/`;function xt(e){let t=(0,X.c)(20),{onSelectMode:n,manualDisabled:r}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(Ie,{asChild:!0,children:(0,Q.jsxs)(B,{className:`gap-1`,children:[`Add Skill`,(0,Q.jsx)(M,{className:`h-4 w-4 opacity-70`})]})}),t[0]=a):a=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=j(i.body,`gap-2`),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=()=>n(`manual`),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(_e,{className:`h-4 w-4 shrink-0`}),t[4]=c):c=t[4];let l;t[5]!==r||t[6]!==s?(l=(0,Q.jsxs)(Y,{className:o,disabled:r,onSelect:s,children:[c,`Manually Enter`]}),t[5]=r,t[6]=s,t[7]=l):l=t[7];let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=j(i.body,`gap-2`),t[8]=u):u=t[8];let d;t[9]===n?d=t[10]:(d=()=>n(`url`),t[9]=n,t[10]=d);let f;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(De,{className:`h-4 w-4 shrink-0`}),t[11]=f):f=t[11];let p;t[12]===d?p=t[13]:(p=(0,Q.jsxs)(Y,{className:u,onSelect:d,children:[f,`Via URL`]}),t[12]=d,t[13]=p);let m;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(je,{}),t[14]=m):m=t[14];let h;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(h=j(i.body,`gap-2`),t[15]=h):h=t[15];let g;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsxs)(Y,{className:h,onSelect:St,children:[(0,Q.jsx)(N,{className:`h-4 w-4 shrink-0`}),`Marketplace`]}),t[16]=g):g=t[16];let _;return t[17]!==l||t[18]!==p?(_=(0,Q.jsxs)(Pe,{children:[a,(0,Q.jsxs)(Ne,{align:`end`,className:`w-44`,children:[l,p,m,g]})]}),t[17]=l,t[18]=p,t[19]=_):_=t[19],_}function St(){E(bt)}var Ct=`This skill uses no additional context as it is manually invoked`;function wt(e){return e.builtIn?`text-muted-foreground/50`:e.disableModelInvocation?`text-brand`:`text-foreground`}function Tt(e){return e.disableModelInvocation?Ct:`≈${o(e.description)} tokens of context`}function Et(e){let t=(0,X.c)(22),n,r,i,a,o,s;if(t[0]!==e){let{onClick:c,ariaLabel:l,...u}=e,d=(0,Q.jsx)(ve,{className:j(`h-4 w-4 shrink-0`,wt(u)),"aria-hidden":`true`});i=U,s=300,r=W,t[7]!==l||t[8]!==d||t[9]!==c?(o=(0,Q.jsx)(V,{asChild:!0,children:c?(0,Q.jsx)(`button`,{type:`button`,"aria-label":l,className:`shrink-0 cursor-pointer rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:e=>{e.stopPropagation(),c()},onKeyDown:Dt,children:d}):d}),t[7]=l,t[8]=d,t[9]=c,t[10]=o):o=t[10],n=H,a=Tt(u),t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s}else n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6];let c;t[11]!==n||t[12]!==a?(c=(0,Q.jsx)(n,{children:a}),t[11]=n,t[12]=a,t[13]=c):c=t[13];let l;t[14]!==r||t[15]!==o||t[16]!==c?(l=(0,Q.jsxs)(r,{children:[o,c]}),t[14]=r,t[15]=o,t[16]=c,t[17]=l):l=t[17];let u;return t[18]!==i||t[19]!==s||t[20]!==l?(u=(0,Q.jsx)(i,{delayDuration:s,children:l}),t[18]=i,t[19]=s,t[20]=l,t[21]=u):u=t[21],u}function Dt(e){(e.key===`Enter`||e.key===` `)&&e.stopPropagation()}function Ot(e){let t=[];for(let n of e){if(n.path===`.agents/skills`&&n.type===`folder`&&n.children)for(let e of n.children)e.type===`folder`&&t.push(e);n.children&&n.children.length>0&&t.push(...Ot(n.children))}return t}function kt(e){return`${e.disableModelInvocation?`Enable`:`Disable`} model invocation for ${e.name}`}function At(e){return e?{title:`MCP server installed`,description:`Its MCP servers were added to this project.`}:{title:`Plugin installed`,description:`Its skills and MCP servers were added to this project.`}}function jt(e){return e?.disableModelInvocation?{title:`Enable model invocation?`,description:`"${e.name}" will be offered to the model automatically again, so its description counts towards the context window.`,actionLabel:`Enable`,nextDisableModelInvocation:!1}:{title:`Disable model invocation?`,description:`"${e?.name}" will no longer be offered to the model automatically, so its description stops counting towards the context window. Invoke it manually with /${e?.name}.`,actionLabel:`Disable`,nextDisableModelInvocation:!0}}function Mt(e){let t=(0,X.c)(24),{skills:n,threadId:r,onOpenSkill:a,onDelete:o,onAddManual:s,onAddUrl:c,onChangeModelInvocation:l}=e,u=!r,d;t[0]!==s||t[1]!==c?(d=e=>{e===`manual`?s():c()},t[0]=s,t[1]=c,t[2]=d):d=t[2];let f;t[3]!==u||t[4]!==d?(f=(0,Q.jsx)(q,{title:`Installed Skills`,description:`Reusable instruction sets that guide agent behavior in this project.`,action:(0,Q.jsx)(xt,{manualDisabled:u,onSelectMode:d}),sticky:!1}),t[3]=u,t[4]=d,t[5]=f):f=t[5];let p;t[6]===r?p=t[7]:(p=!r&&(0,Q.jsx)(Oe,{children:`Select a thread to add or install skills.`}),t[6]=r,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m={icon:Le,title:`No skills installed`,description:`Add skills to extend agent capabilities with reusable instructions.`},t[8]=m):m=t[8];let h;t[9]===l?h=t[10]:(h=e=>(0,Q.jsxs)(`span`,{className:j(i.body,`flex min-w-0 items-center gap-2 text-left`),children:[(0,Q.jsx)(Et,{description:e.description,disableModelInvocation:e.disableModelInvocation,builtIn:e.virtual,onClick:e.virtual?void 0:()=>l(e),ariaLabel:kt(e)}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]}),t[9]=l,t[10]=h);let g;t[11]===a?g=t[12]:(g=e=>a(e.path),t[11]=a,t[12]=g);let _;t[13]!==o||t[14]!==n||t[15]!==h||t[16]!==g?(_=(0,Q.jsx)(He,{showHeader:!1,compact:!0,loading:!1,items:n,emptyState:m,getKey:Ft,renderContent:h,onItemClick:g,itemClickLabel:Pt,onDelete:o,deleteAriaLabel:Nt,deleteTooltip:`Remove this skill from the project`}),t[13]=o,t[14]=n,t[15]=h,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==p||t[19]!==_?(v=(0,Q.jsxs)(Me,{className:`pt-6`,children:[p,_]}),t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==f||t[22]!==v?(y=(0,Q.jsxs)(Ce,{className:`shrink-0`,children:[f,v]}),t[21]=f,t[22]=v,t[23]=y):y=t[23],y}function Nt(e){return`Delete ${e.name}`}function Pt(e){return`Open ${e.name} in Files`}function Ft(e){return e.id}function It(e){let t=(0,X.c)(24),{open:n,onOpenChange:r,skill:i,onConfirm:a}=e,o;t[0]===i?o=t[1]:(o=jt(i),t[0]=i,t[1]=o);let s=o,c;t[2]===s.title?c=t[3]:(c=(0,Q.jsx)(ae,{children:s.title}),t[2]=s.title,t[3]=c);let l;t[4]===s.description?l=t[5]:(l=(0,Q.jsx)(ie,{children:s.description}),t[4]=s.description,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Q.jsxs)(ue,{children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(le,{children:`Cancel`}),t[9]=d):d=t[9];let f;t[10]!==s.nextDisableModelInvocation||t[11]!==a||t[12]!==i?(f=()=>{i&&a(i,s.nextDisableModelInvocation)},t[10]=s.nextDisableModelInvocation,t[11]=a,t[12]=i,t[13]=f):f=t[13];let p;t[14]!==s.actionLabel||t[15]!==f?(p=(0,Q.jsxs)(ce,{children:[d,(0,Q.jsx)(se,{onClick:f,children:s.actionLabel})]}),t[14]=s.actionLabel,t[15]=f,t[16]=p):p=t[16];let m;t[17]!==u||t[18]!==p?(m=(0,Q.jsxs)(oe,{children:[u,p]}),t[17]=u,t[18]=p,t[19]=m):m=t[19];let h;return t[20]!==r||t[21]!==n||t[22]!==m?(h=(0,Q.jsx)(de,{open:n,onOpenChange:r,children:m}),t[20]=r,t[21]=n,t[22]=m,t[23]=h):h=t[23],h}function Lt(){let e=(0,X.c)(10),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(!1),h;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=function(e){f(e),m(!0)},e[0]=h):h=e[0];let g=h,_;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=function(e){e||u(null)},e[1]=_):_=e[1];let v=_,y;return e[2]!==d||e[3]!==s||e[4]!==l||e[5]!==t||e[6]!==a||e[7]!==p||e[8]!==r?(y={showAddDialog:t,setShowAddDialog:n,showUrlDialog:r,setShowUrlDialog:i,showAddSourceDialog:a,setShowAddSourceDialog:o,pluginImportUrl:s,setPluginImportUrl:c,previewSkill:l,setPreviewSkill:u,invocationSkill:d,showInvocationDialog:p,setShowInvocationDialog:m,openInvocationDialog:g,handlePreviewDialogOpenChange:v},e[2]=d,e[3]=s,e[4]=l,e[5]=t,e[6]=a,e[7]=p,e[8]=r,e[9]=y):y=e[9],y}var Rt=`skills:popular`;function zt(e){return e.map(e=>`${e.id}~${e.name}~${e.description}`).join(`|`)}function Bt(){let e=(0,X.c)(5),[t,n]=(0,Z.useState)(Ut),[r,i]=(0,Z.useState)(Ht),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{c().then(e=>{Je(Rt,e),n(t=>zt(t)===zt(e)?t:e)}).catch(Vt).finally(()=>i(!1))},o=[],e[0]=a,e[1]=o):(a=e[0],o=e[1]),(0,Z.useEffect)(a,o);let s;return e[2]!==r||e[3]!==t?(s={popularSkills:t,loadingPopularSkills:r},e[2]=r,e[3]=t,e[4]=s):s=e[4],s}function Vt(){}function Ht(){return!Ye(Rt)}function Ut(){return Xe(Rt)??[]}var $=new Map;function Wt(e){let t=$.get(e);if(t)return t;let n=y(e).finally(()=>{$.delete(e)});return $.set(e,n),n}function Gt(e,t){return t.map(t=>({...t,sourceId:t.sourceId??e}))}function Kt(){let e=(0,X.c)(18),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0];let[n,r]=(0,Z.useState)(t),[i,a]=(0,Z.useState)(m),o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],e[1]=o):o=e[1];let[s,c]=(0,Z.useState)(o),[h,g]=(0,Z.useState)(!1),[_,y]=(0,Z.useState)(!1),b;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=async()=>{try{let e=await d();r(e)}catch{r([])}},e[2]=b):b=e[2];let x=b,w,T;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{(async function(){let e=f();if(e.length>0)try{await l(e),v()}catch{}await x()})()},T=[x],e[3]=w,e[4]=T):(w=e[3],T=e[4]),(0,Z.useEffect)(w,T);let E;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>{a(e),S(e)},e[5]=E):E=e[5];let D=E,O;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>{r(t=>[...t.filter(t=>t.id!==e.id),e].sort(Jt)),D(e.id)},e[6]=O):O=e[6];let k=O,A;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>{r(t=>t.map(t=>t.id===e.id?e:t).sort(qt)),u(e.id)},e[7]=A):A=e[7];let j=A,M;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>{r(t=>t.filter(t=>t.id!==e)),u(e),a(t=>t===e?(S(`default`),`default`):t)},e[8]=M):M=e[8];let ee=M,N,P;e[9]===i?(N=e[10],P=e[11]):(P=()=>{if(i==="default"){c([]),g(!1),y(!1);return}let e=p(i);e?.skills?(c(Gt(i,e.skills)),g(!1)):(c([]),g(!0));let t=!1;return y(!!e?.skills),Wt(i).then(e=>{if(t)return;let n=Gt(i,e);c(n),C(i,{fetchedAt:Date.now(),skills:n})}).catch(n=>{t||(e?.skills||c([]),K({title:`Error`,description:n instanceof Error?n.message:`Failed to load skill catalog`,variant:`destructive`}))}).finally(()=>{t||(g(!1),y(!1))}),()=>{t=!0}},N=[i],e[9]=i,e[10]=N,e[11]=P),(0,Z.useEffect)(P,N);let F;return e[12]!==s||e[13]!==h||e[14]!==_||e[15]!==i||e[16]!==n?(F={sources:n,selectedSourceId:i,setSelectedSourceId:D,addSource:k,updateSource:j,removeSource:ee,reloadSources:x,catalogSkills:s,isLoadingCatalog:h,isRefreshingCatalog:_},e[12]=s,e[13]=h,e[14]=_,e[15]=i,e[16]=n,e[17]=F):F=e[17],F}function qt(e,t){return e.title.localeCompare(t.title)}function Jt(e,t){return e.title.localeCompare(t.title)}function Yt(e){let t=(0,X.c)(26),{popularSkills:n,loadingPopularSkills:r}=Bt(),{sources:i,selectedSourceId:a,setSelectedSourceId:o,addSource:s,updateSource:c,removeSource:l,catalogSkills:u,isLoadingCatalog:d}=Kt(),{query:f,setQuery:p,deferredQuery:m}=Ue(),h=a==="default",g;t[0]!==a||t[1]!==i?(g=$e(a)?i.find(e=>e.id===a)??null:null,t[0]=a,t[1]=i,t[2]=g):g=t[2];let _=g,v=!h&&d&&u.length===0,y;t[3]!==m||t[4]!==e||t[5]!==n?(y=ot(n,m,e),t[3]=m,t[4]=e,t[5]=n,t[6]=y):y=t[6];let b=y,x;t[7]!==u||t[8]!==m||t[9]!==e?(x=ot(u,m,e),t[7]=u,t[8]=m,t[9]=e,t[10]=x):x=t[10];let S=x,C;return t[11]!==s||t[12]!==S||t[13]!==v||t[14]!==b||t[15]!==f||t[16]!==h||t[17]!==r||t[18]!==l||t[19]!==_||t[20]!==a||t[21]!==p||t[22]!==o||t[23]!==i||t[24]!==c?(C={availableSearch:f,setAvailableSearch:p,availablePopular:b,availableCatalog:S,availableCatalogLoading:v,isDefaultSource:h,selectedCustomSource:_,sources:i,selectedSourceId:a,setSelectedSourceId:o,addSource:s,updateSource:c,removeSource:l,loadingPopularSkills:r},t[11]=s,t[12]=S,t[13]=v,t[14]=b,t[15]=f,t[16]=h,t[17]=r,t[18]=l,t[19]=_,t[20]=a,t[21]=p,t[22]=o,t[23]=i,t[24]=c,t[25]=C):C=t[25],C}async function Xt(e,t){let n=rt(t.id);if(!e.threadId||e.installedFilePaths.has(n))return;let r=t.sourceId??(e.selectedSourceId==="default"?void 0:e.selectedSourceId);try{r?await _(e.threadId,r,t.id,nt(t.id)):await g(e.threadId,n,at(t)),e.setInstalledFilePaths(e=>new Set(e).add(n)),e.triggerExplorerRefresh(),e.reloadSkills(),K({title:`Skill installed`,description:t.name})}catch(e){throw K({title:`Error`,description:e instanceof Error?e.message:`Failed to install skill`,variant:`destructive`}),e}}async function Zt(e,t,n){if(e.projectId)try{try{await b(e.projectId,t.name,n)}catch{if(!e.threadId)throw Error(`No thread selected to update this skill`);await h(e.threadId,t.name,n)}e.triggerExplorerRefresh(),await e.reloadSkills(),K({title:n?`Model invocation disabled`:`Model invocation enabled`,description:n?`${t.name} is now invoked manually with /${t.name}.`:`${t.name} is offered to the model again.`})}catch(e){K({title:`Error`,description:e instanceof Error?e.message:`Failed to update skill`,variant:`destructive`})}}function Qt(){let e=(0,X.c)(34),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={findItems:Ot,installedPathSuffix:`/SKILL.md`,explorerPathSuffix:`/SKILL.md`,sortByName:!0,removedToastTitle:`Skill removed`},e[0]=t):t=e[0];let n=Ze(t),r=a($t),i=r.find(e=>e.projectId===n.selectedProjectId)??null,o=Lt(),s=Yt(n.installedFilePaths),c;e[1]!==s.loadingPopularSkills||e[2]!==n.loading?(c=[n.loading,s.loadingPopularSkills],e[1]=s.loadingPopularSkills,e[2]=n.loading,e[3]=c):c=e[3];let l=ze(n.selectedProjectId?`${n.selectedProjectId}:${n.selectedThreadId??``}`:null,c),u;e[4]!==s.selectedSourceId||e[5]!==n.installedFilePaths||e[6]!==n.loadItems||e[7]!==n.selectedThreadId||e[8]!==n.setInstalledFilePaths||e[9]!==n.triggerExplorerRefresh?(u=function(e){return Xt({threadId:n.selectedThreadId,selectedSourceId:s.selectedSourceId,installedFilePaths:n.installedFilePaths,setInstalledFilePaths:n.setInstalledFilePaths,triggerExplorerRefresh:n.triggerExplorerRefresh,reloadSkills:n.loadItems},e)},e[4]=s.selectedSourceId,e[5]=n.installedFilePaths,e[6]=n.loadItems,e[7]=n.selectedThreadId,e[8]=n.setInstalledFilePaths,e[9]=n.triggerExplorerRefresh,e[10]=u):u=e[10];let d=u,f;e[11]!==n.loadItems||e[12]!==n.selectedProjectId||e[13]!==n.selectedThreadId||e[14]!==n.triggerExplorerRefresh?(f=function(e,t){return Zt({projectId:n.selectedProjectId,threadId:n.selectedThreadId,triggerExplorerRefresh:n.triggerExplorerRefresh,reloadSkills:n.loadItems},e,t)},e[11]=n.loadItems,e[12]=n.selectedProjectId,e[13]=n.selectedThreadId,e[14]=n.triggerExplorerRefresh,e[15]=f):f=e[15];let p=f,m;e[16]===n?m=e[17]:(m=function(e){e||n.setDeleteConfirm(null)},e[16]=n,e[17]=m);let h=m,g;e[18]===n?g=e[19]:(g=function(){n.deleteConfirm&&n.handleDelete(n.deleteConfirm)},e[18]=n,e[19]=g);let _=g,v;e[20]===n?v=e[21]:(v=function(e){n.loadItems(),n.triggerExplorerRefresh(),K(At(e))},e[20]=n,e[21]=v);let y=v,b=i?A(i):null,x;return e[22]!==s||e[23]!==o||e[24]!==p||e[25]!==_||e[26]!==h||e[27]!==d||e[28]!==y||e[29]!==n||e[30]!==l||e[31]!==r||e[32]!==b?(x={installed:n,projects:r,selectedProjectName:b,dialogs:o,available:s,pageLoading:l,handleInstallPreviewSkill:d,handleConfirmModelInvocation:p,handleDeleteDialogOpenChange:h,handleDeleteConfirm:_,handlePluginInstalled:y},e[22]=s,e[23]=o,e[24]=p,e[25]=_,e[26]=h,e[27]=d,e[28]=y,e[29]=n,e[30]=l,e[31]=r,e[32]=b,e[33]=x):x=e[33],x}function $t(e){return e.projects}function en(){let e=(0,X.c)(101),t=Qt(),{installed:n,dialogs:r,available:i}=t;if(!n.selectedProjectId){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(Se,{children:`Select a project to manage skills.`}),e[0]=t):t=e[0],t}let a,o;e[1]===r?(a=e[2],o=e[3]):(a=()=>r.setShowAddDialog(!0),o=()=>r.setShowUrlDialog(!0),e[1]=r,e[2]=a,e[3]=o);let s;e[4]!==r.openInvocationDialog||e[5]!==n.handleOpenInExplorer||e[6]!==n.items||e[7]!==n.selectedThreadId||e[8]!==n.setDeleteConfirm||e[9]!==a||e[10]!==o?(s=(0,Q.jsx)(Mt,{skills:n.items,threadId:n.selectedThreadId,onOpenSkill:n.handleOpenInExplorer,onDelete:n.setDeleteConfirm,onAddManual:a,onAddUrl:o,onChangeModelInvocation:r.openInvocationDialog}),e[4]=r.openInvocationDialog,e[5]=n.handleOpenInExplorer,e[6]=n.items,e[7]=n.selectedThreadId,e[8]=n.setDeleteConfirm,e[9]=a,e[10]=o,e[11]=s):s=e[11];let c;e[12]===r?c=e[13]:(c=e=>r.setPreviewSkill(e),e[12]=r,e[13]=c);let l;e[14]!==i.selectedSourceId||e[15]!==r?(l=e=>r.setPreviewSkill({...e,sourceId:e.sourceId??i.selectedSourceId}),e[14]=i.selectedSourceId,e[15]=r,e[16]=l):l=e[16];let u;e[17]===r?u=e[18]:(u=()=>r.setShowAddSourceDialog(!0),e[17]=r,e[18]=u);let d;e[19]!==i.availableCatalog||e[20]!==i.availableCatalogLoading||e[21]!==i.availablePopular||e[22]!==i.availableSearch||e[23]!==i.isDefaultSource||e[24]!==i.selectedCustomSource||e[25]!==i.selectedSourceId||e[26]!==i.setAvailableSearch||e[27]!==i.setSelectedSourceId||e[28]!==i.sources||e[29]!==c||e[30]!==l||e[31]!==u?(d=(0,Q.jsx)(vt,{availableSearch:i.availableSearch,onSearchChange:i.setAvailableSearch,selectedSourceId:i.selectedSourceId,onSourceChange:i.setSelectedSourceId,sources:i.sources,selectedCustomSource:i.selectedCustomSource,availableCatalogLoading:i.availableCatalogLoading,isDefaultSource:i.isDefaultSource,availablePopular:i.availablePopular,availableCatalog:i.availableCatalog,onPreviewPopular:c,onPreviewCatalog:l,onAddSource:u}),e[19]=i.availableCatalog,e[20]=i.availableCatalogLoading,e[21]=i.availablePopular,e[22]=i.availableSearch,e[23]=i.isDefaultSource,e[24]=i.selectedCustomSource,e[25]=i.selectedSourceId,e[26]=i.setAvailableSearch,e[27]=i.setSelectedSourceId,e[28]=i.sources,e[29]=c,e[30]=l,e[31]=u,e[32]=d):d=e[32];let f;e[33]!==t.pageLoading||e[34]!==s||e[35]!==d?(f=(0,Q.jsxs)(ke,{loading:t.pageLoading,children:[s,d]}),e[33]=t.pageLoading,e[34]=s,e[35]=d,e[36]=f):f=e[36];let p=r.previewSkill!==null,m=i.isDefaultSource?void 0:i.selectedSourceId,h;e[37]!==r.handlePreviewDialogOpenChange||e[38]!==r.previewSkill||e[39]!==t.handleInstallPreviewSkill||e[40]!==p||e[41]!==m?(h=(0,Q.jsx)(dt,{open:p,onOpenChange:r.handlePreviewDialogOpenChange,skill:r.previewSkill,catalogSourceId:m,onInstall:t.handleInstallPreviewSkill}),e[37]=r.handlePreviewDialogOpenChange,e[38]=r.previewSkill,e[39]=t.handleInstallPreviewSkill,e[40]=p,e[41]=m,e[42]=h):h=e[42];let g;e[43]!==r.invocationSkill||e[44]!==r.setShowInvocationDialog||e[45]!==r.showInvocationDialog||e[46]!==t.handleConfirmModelInvocation?(g=(0,Q.jsx)(It,{open:r.showInvocationDialog,onOpenChange:r.setShowInvocationDialog,skill:r.invocationSkill,onConfirm:t.handleConfirmModelInvocation}),e[43]=r.invocationSkill,e[44]=r.setShowInvocationDialog,e[45]=r.showInvocationDialog,e[46]=t.handleConfirmModelInvocation,e[47]=g):g=e[47];let _,v,y;e[48]===i?(_=e[49],v=e[50],y=e[51]):(_=e=>{i.addSource(e),K({title:`Skill source added`,description:`${e.title} is now available in the source list.`})},v=e=>{i.updateSource(e),K({title:`Skill source updated`,description:`${e.title} has been saved.`})},y=e=>{i.removeSource(e),K({title:`Skill source removed`,description:`The custom source has been deleted.`})},e[48]=i,e[49]=_,e[50]=v,e[51]=y);let b;e[52]!==i.selectedCustomSource||e[53]!==r.setShowAddSourceDialog||e[54]!==r.showAddSourceDialog||e[55]!==_||e[56]!==v||e[57]!==y?(b=(0,Q.jsx)(ft,{open:r.showAddSourceDialog,onOpenChange:r.setShowAddSourceDialog,editingSource:i.selectedCustomSource,onSourceAdded:_,onSourceUpdated:v,onSourceDeleted:y}),e[52]=i.selectedCustomSource,e[53]=r.setShowAddSourceDialog,e[54]=r.showAddSourceDialog,e[55]=_,e[56]=v,e[57]=y,e[58]=b):b=e[58];let x;e[59]!==r||e[60]!==n?(x=()=>{r.setShowAddDialog(!1),n.loadItems(),n.triggerExplorerRefresh()},e[59]=r,e[60]=n,e[61]=x):x=e[61];let S;e[62]!==n.selectedThreadId||e[63]!==x?(S=(0,Q.jsx)(R,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,Q.jsx)(et,{threadId:n.selectedThreadId,onSkillCreated:x})}),e[62]=n.selectedThreadId,e[63]=x,e[64]=S):S=e[64];let C;e[65]!==r.setShowAddDialog||e[66]!==r.showAddDialog||e[67]!==S?(C=(0,Q.jsx)(z,{open:r.showAddDialog,onOpenChange:r.setShowAddDialog,children:S}),e[65]=r.setShowAddDialog,e[66]=r.showAddDialog,e[67]=S,e[68]=C):C=e[68];let w;e[69]===r?w=e[70]:(w=e=>r.setPluginImportUrl(e),e[69]=r,e[70]=w);let T;e[71]!==r.setShowUrlDialog||e[72]!==r.showUrlDialog||e[73]!==w?(T=(0,Q.jsx)(mt,{open:r.showUrlDialog,onOpenChange:r.setShowUrlDialog,onSubmit:w}),e[71]=r.setShowUrlDialog,e[72]=r.showUrlDialog,e[73]=w,e[74]=T):T=e[74];let E;e[75]===r?E=e[76]:(E=()=>r.setPluginImportUrl(null),e[75]=r,e[76]=E);let D;e[77]===t?D=e[78]:(D=e=>{let{mcpOnly:n}=e;t.handlePluginInstalled(n)},e[77]=t,e[78]=D);let O;e[79]!==r.pluginImportUrl||e[80]!==n.selectedProjectId||e[81]!==t.projects||e[82]!==t.selectedProjectName||e[83]!==E||e[84]!==D?(O=(0,Q.jsx)(Ee,{url:r.pluginImportUrl,projectId:n.selectedProjectId,projectName:t.selectedProjectName,projects:t.projects,onSelectProject:tn,onClose:E,onInstalled:D}),e[79]=r.pluginImportUrl,e[80]=n.selectedProjectId,e[81]=t.projects,e[82]=t.selectedProjectName,e[83]=E,e[84]=D,e[85]=O):O=e[85];let k=n.deleteConfirm!==null,A=`Are you sure you want to delete the skill "${n.deleteConfirm?.name}"? This action cannot be undone.`,j;e[86]!==n.deleting||e[87]!==t.handleDeleteConfirm||e[88]!==t.handleDeleteDialogOpenChange||e[89]!==k||e[90]!==A?(j=(0,Q.jsx)(Re,{open:k,onOpenChange:t.handleDeleteDialogOpenChange,title:`Delete Skill`,description:A,onConfirm:t.handleDeleteConfirm,confirming:n.deleting}),e[86]=n.deleting,e[87]=t.handleDeleteConfirm,e[88]=t.handleDeleteDialogOpenChange,e[89]=k,e[90]=A,e[91]=j):j=e[91];let M;return e[92]!==h||e[93]!==g||e[94]!==b||e[95]!==C||e[96]!==T||e[97]!==O||e[98]!==j||e[99]!==f?(M=(0,Q.jsxs)(Q.Fragment,{children:[f,h,g,b,C,T,O,j]}),e[92]=h,e[93]=g,e[94]=b,e[95]=C,e[96]=T,e[97]=O,e[98]=j,e[99]=f,e[100]=M):M=e[100],M}function tn(){}export{en as SettingsSkillsView,en as default};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,o as n,t as r}from"./react-vendor-D61Uve5n.js";import{U as i}from"./dist-v_MvKS2-.js";import{r as a,rt as o}from"./store-W78TGOIO.js";import{Bi as s,Ci as c,Cr as l,Er as u,Hn as d,In as f,Ni as p,O as m,Or as h,Tr as g,Ui as _,Wn as v,_r as y,kr as b,la as x,oa as S,on as C,vr as w,wi as T,wr as E,xr as D,yr as O}from"./api-Cp9I7CxD.js";import{t as k}from"./markdown-renderer-DQONI6WG.js";import{p as A,t as j}from"./utils-CqsIXqSC.js";import{t as M}from"./chevron-down-Bpo4ncEN.js";import{t as ee}from"./download-CWhQNGlF.js";import{t as N}from"./external-link-Dcikmdm_.js";import{t as P}from"./loader-circle-CrqRIqdA.js";import{a as F,i as I,o as L,r as R,s as te,t as z}from"./dialog-D_12AsZd.js";import{t as ne}from"./plus-DoMzejDu.js";import{t as B}from"./button-DDaJhJP1.js";import{i as V,n as H,r as U,t as W}from"./tooltip-CqwCZ7wt.js";import{t as G}from"./label-BCs5CZEs.js";import{t as K}from"./use-toast-CKgZ8YeP.js";import{t as re}from"./progress-indicator-hJ74ac5W.js";import{a as ie,c as ae,i as oe,n as se,o as ce,r as le,s as ue,t as de}from"./alert-dialog-BcZULJsX.js";import{a as fe,n as pe,o as me,r as he,t as ge}from"./select-DMcNYwgt.js";import{Un as _e,Ut as ve,Vn as ye,Wn as be,at as q,ft as xe,gn as J,gt as Se,hn as Ce,ht as we,i as Te,in as Y,it as Ee,lt as De,nt as Oe,on as ke,pt as Ae,rn as je,rr as Me,tn as Ne,tt as Pe,un as Fe,ur as Ie,vn as Le}from"./index-CcAwxnT5.js";import{t as Re}from"./delete-confirm-dialog-D1N86piR.js";import{t as ze}from"./use-settings-page-loading-B5WU5d1c.js";import{a as Be,o as Ve,r as He}from"./settings-list-Co3JPr9w.js";import{t as Ue}from"./use-deferred-search-xgS_2fMW.js";import{i as We,n as Ge,r as Ke,t as qe}from"./slug-utils-CO6nui1C.js";import{i as Je,n as Ye,r as Xe,t as Ze}from"./use-installed-ai-files-Nn-sN_V2.js";var Qe=`custom-`;function $e(e){return e.startsWith(Qe)}var X=t(),Z=e(n(),1),Q=r();function et({threadId:e,onSkillCreated:t}){let[n,r]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),l=Ke(n),u=Ge(l),d=async()=>{if(u&&a.trim()&&e){c(!0);try{let n=await m(e,l,a.trim());K({title:`Skill created`,description:`Skill '${l}' was created successfully.`}),r(``),o(``),t?.(n.path,`SKILL.md`)}catch(e){K({title:`Error`,description:e instanceof Error?e.message:`Failed to create skill`,variant:`destructive`})}finally{c(!1)}}};return e?(0,Q.jsx)(we,{children:(0,Q.jsxs)(Pe,{children:[(0,Q.jsx)(q,{title:`Add Skill`,description:`Saved as SKILL.md in .agents/skills.`,sticky:!0,className:`pr-10`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(Oe,{title:`Skill Name`,controlLayout:`stack`,className:`pt-6`,children:[(0,Q.jsx)(J,{id:`skillName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Code Review`,disabled:s}),n?(0,Q.jsxs)(`p`,{className:j(i.caption,`mt-2`),children:[`Folder name: `,(0,Q.jsx)(`span`,{className:`font-mono`,children:l||`...`})]}):null]}),(0,Q.jsx)(Oe,{title:`Description`,controlLayout:`stack`,className:`pt-6`,children:(0,Q.jsx)(Ce,{id:`skillDescription`,value:a,onChange:e=>o(e.target.value),placeholder:`Describe when Tarsk should apply this skill`,className:`resize-none min-h-[120px]`,disabled:s})}),(0,Q.jsx)(We,{onContinue:()=>void d(),disabled:!u||!a.trim(),creating:s})]})]})}):(0,Q.jsx)(xe,{title:`No thread selected`,children:`Please select a thread to add a skill.`})}var tt=`.agents/skills`;function nt(e){return`${tt}/${e}`}function rt(e){return`${nt(e)}/SKILL.md`}function it(e,t){let n=t.trim();if(!n)return e;let r=n.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(r)||e.description.toLowerCase().includes(r))}function at(e){let t=[`---`,`name: ${e.id}`,`description: ${e.description}`];return e.allowedTools&&t.push(`allowed-tools: ${e.allowedTools}`),e.license&&t.push(`license: ${e.license}`),t.push(`---`,``,e.instructions??``),t.join(`
2
+ `)}function ot(e,t,n){return it(e,t).filter(e=>!n.has(rt(e.id)))}function st(e){return e.endsWith(`.md`)||e.endsWith(`.mdx`)}function ct(e){return e.includes(`SKILL.md`)?`SKILL.md`:e[0]??`SKILL.md`}function lt(e,t){let n=e?.sourceId??t;if(n&&n!=="default")return n}function ut(e,t,n){let[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),h=lt(t,n),g=!!h;return(0,Z.useEffect)(()=>{if(!e||!t)return;let r=t,a=lt(r,n),s=!1;async function l(){u(!0),m(null),i([]),o(null),c(``);try{if(a){let e=await O(a,r.id);if(s)return;i(e.files),o(ct(e.files))}else{if(s)return;i([`SKILL.md`]),o(`SKILL.md`),c(at(r))}}catch(e){if(s)return;m(e instanceof Error?e.message:`Failed to load skill files`)}finally{s||u(!1)}}return l(),()=>{s=!0}},[e,t,n]),(0,Z.useEffect)(()=>{if(!e||!t||!a||!g||!h)return;let n=t,r=a,i=!1;async function o(){f(!0),m(null);try{let e=await w(h,n.id,r);if(i)return;c(e.content)}catch(e){if(i)return;m(e instanceof Error?e.message:`Failed to load file`),c(``)}finally{i||f(!1)}}return o(),()=>{i=!0}},[e,t,a,g,h]),{files:r,selectedFile:a,setSelectedFile:o,fileContent:s,loadingFiles:l,contentLoading:l||g&&d,loadError:p,isCatalogSkill:g,effectiveSourceId:h}}function dt({open:e,onOpenChange:t,skill:n,catalogSourceId:r,onInstall:a}){let[o,s]=(0,Z.useState)(!1),{files:c,selectedFile:l,setSelectedFile:u,fileContent:d,loadingFiles:f,contentLoading:p,loadError:m,effectiveSourceId:h}=ut(e,n,r),g=(0,Z.useCallback)(async()=>{if(!n)return;let e=h?{...n,sourceId:h}:n;s(!0);try{await a(e),t(!1)}finally{s(!1)}},[n,h,a,t]),_=l?st(l):!1,v=(0,Z.useMemo)(()=>c.map(e=>(0,Q.jsxs)(ve,{selected:e===l,onClick:()=>u(e),className:`gap-2 cursor-pointer`,children:[(0,Q.jsx)(Ie,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:j(i.caption,`truncate`),children:e})]},e)),[c,l]);return(0,Q.jsx)(z,{open:e,onOpenChange:t,children:(0,Q.jsxs)(R,{className:`flex max-h-[90vh] max-w-5xl flex-col gap-0 overflow-hidden p-0`,children:[(0,Q.jsxs)(L,{className:`border-b border-border px-6 py-4`,children:[(0,Q.jsx)(te,{children:n?.name??`Review skill`}),n?.description?(0,Q.jsx)(I,{children:n.description}):null]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row`,children:[(0,Q.jsxs)(`div`,{className:`flex max-h-40 shrink-0 flex-col border-b border-border sm:max-h-none sm:w-56 sm:border-b-0 sm:border-r`,children:[(0,Q.jsx)(`div`,{className:j(i.labelMuted,`px-3 py-2`),children:`Files`}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 pb-2`,children:f?(0,Q.jsx)(re,{centered:!0,containerClassName:`py-8`,label:`Loading files...`}):c.length===0?(0,Q.jsx)(`p`,{className:j(i.caption,`px-3 py-2 text-muted-foreground`),children:`No files found.`}):v})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-4`,children:m?(0,Q.jsx)(`p`,{className:j(i.body,`text-destructive`),children:m}):p?(0,Q.jsx)(re,{centered:!0,containerClassName:`py-12`,label:`Loading preview...`}):_?(0,Q.jsx)(k,{content:d,enableMermaid:!1}):(0,Q.jsx)(`pre`,{className:j(i.caption,`overflow-x-auto whitespace-pre-wrap font-mono`),children:d})})]}),(0,Q.jsxs)(F,{className:`border-t border-border px-6 py-4 sm:justify-between`,children:[(0,Q.jsx)(B,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(B,{type:`button`,onClick:()=>void g(),disabled:o||!n,children:o?`Installing...`:`Install`})]})]})})}function ft({open:e,onOpenChange:t,editingSource:n,onSourceAdded:r,onSourceUpdated:a,onSourceDeleted:o}){let[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,x]=(0,Z.useState)(!1),S=n!=null;function C(){c(``),u(``),f(null),m(!1),_(!1),x(!1)}function w(e){e||C(),t(e)}(0,Z.useEffect)(()=>{if(e){if(n){c(n.title),u(n.url),f(null);return}c(``),u(``),f(null)}},[e,n]);async function T(){let e=s.trim(),t=l.trim();if(!e||!t){f(`Title and URL are required.`);return}m(!0),f(null);try{if(S&&n){let r=await h(n.id,e,t);a?.(r.source)}else r((await b(e,t)).source);w(!1)}catch(e){f(e instanceof Error?e.message:`Failed to verify skill source`)}finally{m(!1)}}async function E(){if(n){_(!0),f(null);try{await y(n.id),o?.(n.id),x(!1),w(!1)}catch(e){f(e instanceof Error?e.message:`Failed to delete skill source`),x(!1)}finally{_(!1)}}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{open:e,onOpenChange:w,children:(0,Q.jsxs)(R,{className:`sm:max-w-lg`,children:[(0,Q.jsxs)(L,{children:[(0,Q.jsx)(te,{children:S?`Edit Skill Source`:`Add Skill Source`}),(0,Q.jsx)(I,{children:S?`Update the title or GitHub skills folder URL for this custom source.`:`Add a GitHub skills folder URL. The source is verified by loading at least one skill from the repository.`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(G,{htmlFor:`skill-source-title`,children:`Title`}),(0,Q.jsx)(J,{id:`skill-source-title`,placeholder:`e.g. My Team Skills`,value:s,onChange:e=>c(e.target.value),disabled:p||g,autoFocus:!0})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(G,{htmlFor:`skill-source-url`,children:`URL`}),(0,Q.jsx)(J,{id:`skill-source-url`,placeholder:`https://github.com/org/repo or .../tree/main/skills`,value:l,onChange:e=>u(e.target.value),disabled:p||g})]}),d?(0,Q.jsx)(`p`,{className:j(i.caption,`text-destructive`),children:d}):null]}),(0,Q.jsxs)(F,{className:`flex-col-reverse gap-2 sm:flex-row sm:justify-between`,children:[S?(0,Q.jsx)(B,{type:`button`,variant:`destructive`,onClick:()=>x(!0),disabled:p||g,children:`Delete`}):(0,Q.jsx)(`div`,{className:`hidden sm:block`}),(0,Q.jsxs)(`div`,{className:`flex w-full flex-col-reverse gap-2 sm:w-auto sm:flex-row`,children:[(0,Q.jsx)(B,{variant:`outline`,onClick:()=>w(!1),disabled:p||g,children:`Cancel`}),(0,Q.jsx)(B,{onClick:()=>void T(),disabled:p||g||!s.trim()||!l.trim(),children:p?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{className:`mr-2 h-4 w-4 animate-spin`}),`Verifying...`]}):S?`Save Changes`:`Add Source`})]})]})]})}),(0,Q.jsx)(de,{open:v,onOpenChange:x,children:(0,Q.jsxs)(oe,{children:[(0,Q.jsxs)(ue,{children:[(0,Q.jsx)(ae,{children:`Delete Skill Source`}),(0,Q.jsxs)(ie,{children:[`Are you sure you want to delete "`,n?.title,`"? This removes the source from your list but does not uninstall skills you already added.`]})]}),(0,Q.jsxs)(ce,{children:[(0,Q.jsx)(le,{disabled:g,children:`Cancel`}),(0,Q.jsx)(se,{onClick:()=>void E(),disabled:g,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:g?`Deleting...`:`Delete`})]})]})})]})}function pt(e){let t=e.trim();if(!t)return null;if(/^https?:\/\//i.test(t))try{return new URL(t),t}catch{return null}if(t.startsWith(`tarsk://`))try{let e=new URL(`https://tarsk.invalid/${t.slice(8)}`);if(e.pathname===`/skill-install`&&e.searchParams.get(`url`))return e.searchParams.get(`url`)}catch{return null}return null}function mt(e){let t=(0,X.c)(40),{open:n,onOpenChange:r,onSubmit:a}=e,[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=function(){s(``),l(null)},t[0]=u):u=t[0];let d=u,f;t[1]===r?f=t[2]:(f=function(e){e||d(),r(e)},t[1]=r,t[2]=f);let p=f,m,h;t[3]===n?(m=t[4],h=t[5]):(m=()=>{n&&d()},h=[n],t[3]=n,t[4]=m,t[5]=h),(0,Z.useEffect)(m,h);let g;t[6]!==p||t[7]!==a||t[8]!==o?(g=function(){let e=pt(o);if(!e){l(`Enter a valid http(s) URL for the plugin archive or paste a tarsk:// install link.`);return}a(e),p(!1)},t[6]=p,t[7]=a,t[8]=o,t[9]=g):g=t[9];let _=g,v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsxs)(L,{children:[(0,Q.jsx)(te,{children:`Add Skill via URL`}),(0,Q.jsx)(I,{children:`Paste the URL of a plugin archive. Its skills and MCP servers are installed into this project.`})]}),t[10]=v):v=t[10];let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(G,{htmlFor:`add-skill-url`,children:`URL`}),t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>s(e.target.value),t[12]=b):b=t[12];let x;t[13]===_?x=t[14]:(x=e=>{e.key===`Enter`&&(e.preventDefault(),_())},t[13]=_,t[14]=x);let S;t[15]!==x||t[16]!==o?(S=(0,Q.jsx)(J,{id:`add-skill-url`,placeholder:`https://example.com/my-plugin.zip`,value:o,onChange:b,autoFocus:!0,onKeyDown:x}),t[15]=x,t[16]=o,t[17]=S):S=t[17];let C;t[18]===c?C=t[19]:(C=c?(0,Q.jsx)(`p`,{className:j(i.caption,`text-destructive`),children:c}):null,t[18]=c,t[19]=C);let w;t[20]!==S||t[21]!==C?(w=(0,Q.jsx)(`div`,{className:`grid gap-4 py-2`,children:(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[y,S,C]})}),t[20]=S,t[21]=C,t[22]=w):w=t[22];let T;t[23]===p?T=t[24]:(T=(0,Q.jsx)(B,{variant:`outline`,onClick:()=>p(!1),children:`Cancel`}),t[23]=p,t[24]=T);let E;t[25]===o?E=t[26]:(E=o.trim(),t[25]=o,t[26]=E);let D=!E,O;t[27]!==_||t[28]!==D?(O=(0,Q.jsx)(B,{onClick:_,disabled:D,children:`Continue`}),t[27]=_,t[28]=D,t[29]=O):O=t[29];let k;t[30]!==T||t[31]!==O?(k=(0,Q.jsxs)(F,{children:[T,O]}),t[30]=T,t[31]=O,t[32]=k):k=t[32];let A;t[33]!==w||t[34]!==k?(A=(0,Q.jsxs)(R,{className:`sm:max-w-lg`,children:[v,w,k]}),t[33]=w,t[34]=k,t[35]=A):A=t[35];let M;return t[36]!==p||t[37]!==n||t[38]!==A?(M=(0,Q.jsx)(z,{open:n,onOpenChange:p,children:A}),t[36]=p,t[37]=n,t[38]=A,t[39]=M):M=t[39],M}function ht(e){let t=(0,X.c)(7),{items:n,onPreview:r}=e,a;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=e=>{let t=qe(e.name);return(0,Q.jsxs)(`div`,{className:`group flex min-h-13 items-center gap-3 px-3 py-2`,role:`button`,tabIndex:0,onClick:()=>r(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(e))},children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:j(i.label,`truncate`),children:t}),(0,Q.jsx)(`p`,{className:j(i.caption,`truncate`),children:e.description})]}),(0,Q.jsx)(U,{delayDuration:300,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(V,{asChild:!0,children:(0,Q.jsx)(B,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`shrink-0 opacity-0 pointer-events-none can-hover:group-hover:opacity-100 can-hover:group-hover:pointer-events-auto`,"aria-label":`Install ${t}`,onClick:t=>{t.stopPropagation(),r(e)},children:(0,Q.jsx)(ee,{className:`h-4 w-4`})})}),(0,Q.jsx)(H,{children:`Install skill`})]})})]},e.id)},t[3]=r,t[4]=e),a=n.map(e),t[0]=n,t[1]=r,t[2]=a}else a=t[2];let o;return t[5]===a?o=t[6]:(o=(0,Q.jsx)(`div`,{className:`divide-y divide-table-border`,children:a}),t[5]=a,t[6]=o),o}function gt(e){let t=(0,X.c)(11),{searchQuery:n,isLoadingCatalog:r,isDefaultSource:i,availablePopular:a,availableCatalog:o,onPreviewPopular:s,onPreviewCatalog:c}=e;if(r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(re,{centered:!0,containerClassName:`py-12`,label:`Loading skills...`}),t[0]=e):e=t[0],e}if(i){if(a.length===0){let e;return t[1]===n?e=t[2]:(e=(0,Q.jsx)(Be,{searchQuery:n,emptyLabel:`No available skills found.`}),t[1]=n,t[2]=e),e}let e;return t[3]!==a||t[4]!==s?(e=(0,Q.jsx)(ht,{items:a,onPreview:s}),t[3]=a,t[4]=s,t[5]=e):e=t[5],e}if(o.length===0){let e;return t[6]===n?e=t[7]:(e=(0,Q.jsx)(Be,{searchQuery:n,emptyLabel:`No available skills found.`}),t[6]=n,t[7]=e),e}let l;return t[8]!==o||t[9]!==c?(l=(0,Q.jsx)(ht,{items:o,onPreview:c}),t[8]=o,t[9]=c,t[10]=l):l=t[10],l}function _t(e){return e?{ariaLabel:`Edit skill source`,tooltip:`Edit this custom skill source`,icon:_e}:{ariaLabel:`Add skill source`,tooltip:`Add a custom skill source`,icon:ne}}function vt(e){let t=(0,X.c)(42),{availableSearch:n,onSearchChange:r,selectedSourceId:i,onSourceChange:a,sources:o,selectedCustomSource:s,availableCatalogLoading:c,isDefaultSource:l,availablePopular:u,availableCatalog:d,onPreviewPopular:f,onPreviewCatalog:p,onAddSource:m}=e,h;t[0]===s?h=t[1]:(h=_t(s),t[0]=s,t[1]=h);let g=h,_=g.icon,v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(U,{children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(V,{asChild:!0,children:(0,Q.jsx)(`span`,{className:`cursor-help`,children:`Available Skills`})}),(0,Q.jsx)(H,{children:`Browse and install skills from the catalog.`})]})}),t[2]=v):v=t[2];let y;t[3]!==n||t[4]!==r?(y=(0,Q.jsx)(Ve,{placeholder:`Search`,value:n,onChange:r,className:`mb-0 w-64`}),t[3]=n,t[4]=r,t[5]=y):y=t[5];let b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(fe,{className:`w-40`,"aria-label":`Skill source`,children:(0,Q.jsx)(me,{placeholder:`Default`})}),t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(he,{value:`default`,children:`Default`}),t[7]=x):x=t[7];let S;t[8]===o?S=t[9]:(S=o.map(yt),t[8]=o,t[9]=S);let C;t[10]===S?C=t[11]:(C=(0,Q.jsxs)(pe,{children:[x,S]}),t[10]=S,t[11]=C);let w;t[12]!==a||t[13]!==i||t[14]!==C?(w=(0,Q.jsxs)(ge,{value:i,onValueChange:a,children:[b,C]}),t[12]=a,t[13]=i,t[14]=C,t[15]=w):w=t[15];let T;t[16]===_?T=t[17]:(T=(0,Q.jsx)(_,{className:`h-4 w-4`}),t[16]=_,t[17]=T);let E;t[18]!==m||t[19]!==g.ariaLabel||t[20]!==T?(E=(0,Q.jsx)(V,{asChild:!0,children:(0,Q.jsx)(B,{type:`button`,variant:`outline`,size:`icon`,className:`shrink-0`,onClick:m,"aria-label":g.ariaLabel,children:T})}),t[18]=m,t[19]=g.ariaLabel,t[20]=T,t[21]=E):E=t[21];let D;t[22]===g.tooltip?D=t[23]:(D=(0,Q.jsx)(H,{children:g.tooltip}),t[22]=g.tooltip,t[23]=D);let O;t[24]!==E||t[25]!==D?(O=(0,Q.jsx)(U,{children:(0,Q.jsxs)(W,{children:[E,D]})}),t[24]=E,t[25]=D,t[26]=O):O=t[26];let k;t[27]!==O||t[28]!==y||t[29]!==w?(k=(0,Q.jsx)(q,{title:v,action:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y,w,O]}),sticky:!1}),t[27]=O,t[28]=y,t[29]=w,t[30]=k):k=t[30];let A;t[31]!==d||t[32]!==c||t[33]!==u||t[34]!==n||t[35]!==l||t[36]!==p||t[37]!==f?(A=(0,Q.jsx)(Ae,{className:`pt-6`,children:(0,Q.jsx)(gt,{searchQuery:n,isLoadingCatalog:c,isDefaultSource:l,availablePopular:u,availableCatalog:d,onPreviewPopular:f,onPreviewCatalog:p})}),t[31]=d,t[32]=c,t[33]=u,t[34]=n,t[35]=l,t[36]=p,t[37]=f,t[38]=A):A=t[38];let j;return t[39]!==k||t[40]!==A?(j=(0,Q.jsxs)(Se,{className:`shrink-0`,children:[k,A]}),t[39]=k,t[40]=A,t[41]=j):j=t[41],j}function yt(e){return(0,Q.jsx)(he,{value:e.id,children:e.title},e.id)}var bt=`https://tarsk.io/skills/list/`;function xt(e){let t=(0,X.c)(20),{onSelectMode:n,manualDisabled:r}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(Fe,{asChild:!0,children:(0,Q.jsxs)(B,{className:`gap-1`,children:[`Add Skill`,(0,Q.jsx)(M,{className:`h-4 w-4 opacity-70`})]})}),t[0]=a):a=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=j(i.body,`gap-2`),t[1]=o):o=t[1];let s;t[2]===n?s=t[3]:(s=()=>n(`manual`),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(be,{className:`h-4 w-4 shrink-0`}),t[4]=c):c=t[4];let l;t[5]!==r||t[6]!==s?(l=(0,Q.jsxs)(Y,{className:o,disabled:r,onSelect:s,children:[c,`Manually Enter`]}),t[5]=r,t[6]=s,t[7]=l):l=t[7];let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=j(i.body,`gap-2`),t[8]=u):u=t[8];let d;t[9]===n?d=t[10]:(d=()=>n(`url`),t[9]=n,t[10]=d);let f;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(Me,{className:`h-4 w-4 shrink-0`}),t[11]=f):f=t[11];let p;t[12]===d?p=t[13]:(p=(0,Q.jsxs)(Y,{className:u,onSelect:d,children:[f,`Via URL`]}),t[12]=d,t[13]=p);let m;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(ke,{}),t[14]=m):m=t[14];let h;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(h=j(i.body,`gap-2`),t[15]=h):h=t[15];let g;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsxs)(Y,{className:h,onSelect:St,children:[(0,Q.jsx)(N,{className:`h-4 w-4 shrink-0`}),`Marketplace`]}),t[16]=g):g=t[16];let _;return t[17]!==l||t[18]!==p?(_=(0,Q.jsxs)(Ne,{children:[a,(0,Q.jsxs)(je,{align:`end`,className:`w-44`,children:[l,p,m,g]})]}),t[17]=l,t[18]=p,t[19]=_):_=t[19],_}function St(){C(bt)}var Ct=`This skill uses no additional context as it is manually invoked`;function wt(e){return e.builtIn?`text-muted-foreground/50`:e.disableModelInvocation?`text-brand`:`text-foreground`}function Tt(e){return e.disableModelInvocation?Ct:`≈${o(e.description)} tokens of context`}function Et(e){let t=(0,X.c)(22),n,r,i,a,o,s;if(t[0]!==e){let{onClick:c,ariaLabel:l,...u}=e,d=(0,Q.jsx)(ye,{className:j(`h-4 w-4 shrink-0`,wt(u)),"aria-hidden":`true`});i=U,s=300,r=W,t[7]!==l||t[8]!==d||t[9]!==c?(o=(0,Q.jsx)(V,{asChild:!0,children:c?(0,Q.jsx)(`button`,{type:`button`,"aria-label":l,className:`shrink-0 cursor-pointer rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:e=>{e.stopPropagation(),c()},onKeyDown:Dt,children:d}):d}),t[7]=l,t[8]=d,t[9]=c,t[10]=o):o=t[10],n=H,a=Tt(u),t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s}else n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6];let c;t[11]!==n||t[12]!==a?(c=(0,Q.jsx)(n,{children:a}),t[11]=n,t[12]=a,t[13]=c):c=t[13];let l;t[14]!==r||t[15]!==o||t[16]!==c?(l=(0,Q.jsxs)(r,{children:[o,c]}),t[14]=r,t[15]=o,t[16]=c,t[17]=l):l=t[17];let u;return t[18]!==i||t[19]!==s||t[20]!==l?(u=(0,Q.jsx)(i,{delayDuration:s,children:l}),t[18]=i,t[19]=s,t[20]=l,t[21]=u):u=t[21],u}function Dt(e){(e.key===`Enter`||e.key===` `)&&e.stopPropagation()}function Ot(e){let t=[];for(let n of e){if(n.path===`.agents/skills`&&n.type===`folder`&&n.children)for(let e of n.children)e.type===`folder`&&t.push(e);n.children&&n.children.length>0&&t.push(...Ot(n.children))}return t}function kt(e){return`${e.disableModelInvocation?`Enable`:`Disable`} model invocation for ${e.name}`}function At(e){return e?{title:`MCP server installed`,description:`Its MCP servers were added to this project.`}:{title:`Plugin installed`,description:`Its skills and MCP servers were added to this project.`}}function jt(e){return e?.disableModelInvocation?{title:`Enable model invocation?`,description:`"${e.name}" will be offered to the model automatically again, so its description counts towards the context window.`,actionLabel:`Enable`,nextDisableModelInvocation:!1}:{title:`Disable model invocation?`,description:`"${e?.name}" will no longer be offered to the model automatically, so its description stops counting towards the context window. Invoke it manually with /${e?.name}.`,actionLabel:`Disable`,nextDisableModelInvocation:!0}}function Mt(e){let t=(0,X.c)(24),{skills:n,threadId:r,onOpenSkill:a,onDelete:o,onAddManual:s,onAddUrl:c,onChangeModelInvocation:l}=e,u=!r,d;t[0]!==s||t[1]!==c?(d=e=>{e===`manual`?s():c()},t[0]=s,t[1]=c,t[2]=d):d=t[2];let f;t[3]!==u||t[4]!==d?(f=(0,Q.jsx)(q,{title:`Installed Skills`,description:`Reusable instruction sets that guide agent behavior in this project.`,action:(0,Q.jsx)(xt,{manualDisabled:u,onSelectMode:d}),sticky:!1}),t[3]=u,t[4]=d,t[5]=f):f=t[5];let p;t[6]===r?p=t[7]:(p=!r&&(0,Q.jsx)(Ee,{children:`Select a thread to add or install skills.`}),t[6]=r,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m={icon:Le,title:`No skills installed`,description:`Add skills to extend agent capabilities with reusable instructions.`},t[8]=m):m=t[8];let h;t[9]===l?h=t[10]:(h=e=>(0,Q.jsxs)(`span`,{className:j(i.body,`flex min-w-0 items-center gap-2 text-left`),children:[(0,Q.jsx)(Et,{description:e.description,disableModelInvocation:e.disableModelInvocation,builtIn:e.virtual,onClick:e.virtual?void 0:()=>l(e),ariaLabel:kt(e)}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]}),t[9]=l,t[10]=h);let g;t[11]===a?g=t[12]:(g=e=>a(e.path),t[11]=a,t[12]=g);let _;t[13]!==o||t[14]!==n||t[15]!==h||t[16]!==g?(_=(0,Q.jsx)(He,{showHeader:!1,compact:!0,loading:!1,items:n,emptyState:m,getKey:Ft,renderContent:h,onItemClick:g,itemClickLabel:Pt,onDelete:o,deleteAriaLabel:Nt,deleteTooltip:`Remove this skill from the project`}),t[13]=o,t[14]=n,t[15]=h,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==p||t[19]!==_?(v=(0,Q.jsxs)(Ae,{className:`pt-6`,children:[p,_]}),t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==f||t[22]!==v?(y=(0,Q.jsxs)(Se,{className:`shrink-0`,children:[f,v]}),t[21]=f,t[22]=v,t[23]=y):y=t[23],y}function Nt(e){return`Delete ${e.name}`}function Pt(e){return`Open ${e.name} in Files`}function Ft(e){return e.id}function It(e){let t=(0,X.c)(24),{open:n,onOpenChange:r,skill:i,onConfirm:a}=e,o;t[0]===i?o=t[1]:(o=jt(i),t[0]=i,t[1]=o);let s=o,c;t[2]===s.title?c=t[3]:(c=(0,Q.jsx)(ae,{children:s.title}),t[2]=s.title,t[3]=c);let l;t[4]===s.description?l=t[5]:(l=(0,Q.jsx)(ie,{children:s.description}),t[4]=s.description,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Q.jsxs)(ue,{children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(le,{children:`Cancel`}),t[9]=d):d=t[9];let f;t[10]!==s.nextDisableModelInvocation||t[11]!==a||t[12]!==i?(f=()=>{i&&a(i,s.nextDisableModelInvocation)},t[10]=s.nextDisableModelInvocation,t[11]=a,t[12]=i,t[13]=f):f=t[13];let p;t[14]!==s.actionLabel||t[15]!==f?(p=(0,Q.jsxs)(ce,{children:[d,(0,Q.jsx)(se,{onClick:f,children:s.actionLabel})]}),t[14]=s.actionLabel,t[15]=f,t[16]=p):p=t[16];let m;t[17]!==u||t[18]!==p?(m=(0,Q.jsxs)(oe,{children:[u,p]}),t[17]=u,t[18]=p,t[19]=m):m=t[19];let h;return t[20]!==r||t[21]!==n||t[22]!==m?(h=(0,Q.jsx)(de,{open:n,onOpenChange:r,children:m}),t[20]=r,t[21]=n,t[22]=m,t[23]=h):h=t[23],h}function Lt(){let e=(0,X.c)(10),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(!1),h;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=function(e){f(e),m(!0)},e[0]=h):h=e[0];let g=h,_;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=function(e){e||u(null)},e[1]=_):_=e[1];let v=_,y;return e[2]!==d||e[3]!==s||e[4]!==l||e[5]!==t||e[6]!==a||e[7]!==p||e[8]!==r?(y={showAddDialog:t,setShowAddDialog:n,showUrlDialog:r,setShowUrlDialog:i,showAddSourceDialog:a,setShowAddSourceDialog:o,pluginImportUrl:s,setPluginImportUrl:c,previewSkill:l,setPreviewSkill:u,invocationSkill:d,showInvocationDialog:p,setShowInvocationDialog:m,openInvocationDialog:g,handlePreviewDialogOpenChange:v},e[2]=d,e[3]=s,e[4]=l,e[5]=t,e[6]=a,e[7]=p,e[8]=r,e[9]=y):y=e[9],y}var Rt=`skills:popular`;function zt(e){return e.map(e=>`${e.id}~${e.name}~${e.description}`).join(`|`)}function Bt(){let e=(0,X.c)(5),[t,n]=(0,Z.useState)(Ut),[r,i]=(0,Z.useState)(Ht),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{D().then(e=>{Je(Rt,e),n(t=>zt(t)===zt(e)?t:e)}).catch(Vt).finally(()=>i(!1))},o=[],e[0]=a,e[1]=o):(a=e[0],o=e[1]),(0,Z.useEffect)(a,o);let s;return e[2]!==r||e[3]!==t?(s={popularSkills:t,loadingPopularSkills:r},e[2]=r,e[3]=t,e[4]=s):s=e[4],s}function Vt(){}function Ht(){return!Ye(Rt)}function Ut(){return Xe(Rt)??[]}var $=new Map;function Wt(e){let t=$.get(e);if(t)return t;let n=l(e).finally(()=>{$.delete(e)});return $.set(e,n),n}function Gt(e,t){return t.map(t=>({...t,sourceId:t.sourceId??e}))}function Kt(){let e=(0,X.c)(18),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0];let[n,r]=(0,Z.useState)(t),[i,a]=(0,Z.useState)(s),o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],e[1]=o):o=e[1];let[l,u]=(0,Z.useState)(o),[d,f]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),v;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=async()=>{try{let e=await E();r(e)}catch{r([])}},e[2]=v):v=e[2];let y=v,b,C;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{(async function(){let e=p();if(e.length>0)try{await g(e),c()}catch{}await y()})()},C=[y],e[3]=b,e[4]=C):(b=e[3],C=e[4]),(0,Z.useEffect)(b,C);let w;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(w=e=>{a(e),S(e)},e[5]=w):w=e[5];let D=w,O;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>{r(t=>[...t.filter(t=>t.id!==e.id),e].sort(Jt)),D(e.id)},e[6]=O):O=e[6];let k=O,A;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>{r(t=>t.map(t=>t.id===e.id?e:t).sort(qt)),T(e.id)},e[7]=A):A=e[7];let j=A,M;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>{r(t=>t.filter(t=>t.id!==e)),T(e),a(t=>t===e?(S(`default`),`default`):t)},e[8]=M):M=e[8];let ee=M,N,P;e[9]===i?(N=e[10],P=e[11]):(P=()=>{if(i==="default"){u([]),f(!1),h(!1);return}let e=_(i);e?.skills?(u(Gt(i,e.skills)),f(!1)):(u([]),f(!0));let t=!1;return h(!!e?.skills),Wt(i).then(e=>{if(t)return;let n=Gt(i,e);u(n),x(i,{fetchedAt:Date.now(),skills:n})}).catch(n=>{t||(e?.skills||u([]),K({title:`Error`,description:n instanceof Error?n.message:`Failed to load skill catalog`,variant:`destructive`}))}).finally(()=>{t||(f(!1),h(!1))}),()=>{t=!0}},N=[i],e[9]=i,e[10]=N,e[11]=P),(0,Z.useEffect)(P,N);let F;return e[12]!==l||e[13]!==d||e[14]!==m||e[15]!==i||e[16]!==n?(F={sources:n,selectedSourceId:i,setSelectedSourceId:D,addSource:k,updateSource:j,removeSource:ee,reloadSources:y,catalogSkills:l,isLoadingCatalog:d,isRefreshingCatalog:m},e[12]=l,e[13]=d,e[14]=m,e[15]=i,e[16]=n,e[17]=F):F=e[17],F}function qt(e,t){return e.title.localeCompare(t.title)}function Jt(e,t){return e.title.localeCompare(t.title)}function Yt(e){let t=(0,X.c)(26),{popularSkills:n,loadingPopularSkills:r}=Bt(),{sources:i,selectedSourceId:a,setSelectedSourceId:o,addSource:s,updateSource:c,removeSource:l,catalogSkills:u,isLoadingCatalog:d}=Kt(),{query:f,setQuery:p,deferredQuery:m}=Ue(),h=a==="default",g;t[0]!==a||t[1]!==i?(g=$e(a)?i.find(e=>e.id===a)??null:null,t[0]=a,t[1]=i,t[2]=g):g=t[2];let _=g,v=!h&&d&&u.length===0,y;t[3]!==m||t[4]!==e||t[5]!==n?(y=ot(n,m,e),t[3]=m,t[4]=e,t[5]=n,t[6]=y):y=t[6];let b=y,x;t[7]!==u||t[8]!==m||t[9]!==e?(x=ot(u,m,e),t[7]=u,t[8]=m,t[9]=e,t[10]=x):x=t[10];let S=x,C;return t[11]!==s||t[12]!==S||t[13]!==v||t[14]!==b||t[15]!==f||t[16]!==h||t[17]!==r||t[18]!==l||t[19]!==_||t[20]!==a||t[21]!==p||t[22]!==o||t[23]!==i||t[24]!==c?(C={availableSearch:f,setAvailableSearch:p,availablePopular:b,availableCatalog:S,availableCatalogLoading:v,isDefaultSource:h,selectedCustomSource:_,sources:i,selectedSourceId:a,setSelectedSourceId:o,addSource:s,updateSource:c,removeSource:l,loadingPopularSkills:r},t[11]=s,t[12]=S,t[13]=v,t[14]=b,t[15]=f,t[16]=h,t[17]=r,t[18]=l,t[19]=_,t[20]=a,t[21]=p,t[22]=o,t[23]=i,t[24]=c,t[25]=C):C=t[25],C}async function Xt(e,t){let n=rt(t.id);if(!e.threadId||e.installedFilePaths.has(n))return;let r=t.sourceId??(e.selectedSourceId==="default"?void 0:e.selectedSourceId);try{r?await u(e.threadId,r,t.id,nt(t.id)):await f(e.threadId,n,at(t)),e.setInstalledFilePaths(e=>new Set(e).add(n)),e.triggerExplorerRefresh(),e.reloadSkills(),K({title:`Skill installed`,description:t.name})}catch(e){throw K({title:`Error`,description:e instanceof Error?e.message:`Failed to install skill`,variant:`destructive`}),e}}async function Zt(e,t,n){if(e.projectId)try{try{await d(e.projectId,t.name,n)}catch{if(!e.threadId)throw Error(`No thread selected to update this skill`);await v(e.threadId,t.name,n)}e.triggerExplorerRefresh(),await e.reloadSkills(),K({title:n?`Model invocation disabled`:`Model invocation enabled`,description:n?`${t.name} is now invoked manually with /${t.name}.`:`${t.name} is offered to the model again.`})}catch(e){K({title:`Error`,description:e instanceof Error?e.message:`Failed to update skill`,variant:`destructive`})}}function Qt(){let e=(0,X.c)(34),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={findItems:Ot,installedPathSuffix:`/SKILL.md`,explorerPathSuffix:`/SKILL.md`,sortByName:!0,removedToastTitle:`Skill removed`},e[0]=t):t=e[0];let n=Ze(t),r=a($t),i=r.find(e=>e.projectId===n.selectedProjectId)??null,o=Lt(),s=Yt(n.installedFilePaths),c;e[1]!==s.loadingPopularSkills||e[2]!==n.loading?(c=[n.loading,s.loadingPopularSkills],e[1]=s.loadingPopularSkills,e[2]=n.loading,e[3]=c):c=e[3];let l=ze(n.selectedProjectId?`${n.selectedProjectId}:${n.selectedThreadId??``}`:null,c),u;e[4]!==s.selectedSourceId||e[5]!==n.installedFilePaths||e[6]!==n.loadItems||e[7]!==n.selectedThreadId||e[8]!==n.setInstalledFilePaths||e[9]!==n.triggerExplorerRefresh?(u=function(e){return Xt({threadId:n.selectedThreadId,selectedSourceId:s.selectedSourceId,installedFilePaths:n.installedFilePaths,setInstalledFilePaths:n.setInstalledFilePaths,triggerExplorerRefresh:n.triggerExplorerRefresh,reloadSkills:n.loadItems},e)},e[4]=s.selectedSourceId,e[5]=n.installedFilePaths,e[6]=n.loadItems,e[7]=n.selectedThreadId,e[8]=n.setInstalledFilePaths,e[9]=n.triggerExplorerRefresh,e[10]=u):u=e[10];let d=u,f;e[11]!==n.loadItems||e[12]!==n.selectedProjectId||e[13]!==n.selectedThreadId||e[14]!==n.triggerExplorerRefresh?(f=function(e,t){return Zt({projectId:n.selectedProjectId,threadId:n.selectedThreadId,triggerExplorerRefresh:n.triggerExplorerRefresh,reloadSkills:n.loadItems},e,t)},e[11]=n.loadItems,e[12]=n.selectedProjectId,e[13]=n.selectedThreadId,e[14]=n.triggerExplorerRefresh,e[15]=f):f=e[15];let p=f,m;e[16]===n?m=e[17]:(m=function(e){e||n.setDeleteConfirm(null)},e[16]=n,e[17]=m);let h=m,g;e[18]===n?g=e[19]:(g=function(){n.deleteConfirm&&n.handleDelete(n.deleteConfirm)},e[18]=n,e[19]=g);let _=g,v;e[20]===n?v=e[21]:(v=function(e){n.loadItems(),n.triggerExplorerRefresh(),K(At(e))},e[20]=n,e[21]=v);let y=v,b=i?A(i):null,x;return e[22]!==s||e[23]!==o||e[24]!==p||e[25]!==_||e[26]!==h||e[27]!==d||e[28]!==y||e[29]!==n||e[30]!==l||e[31]!==r||e[32]!==b?(x={installed:n,projects:r,selectedProjectName:b,dialogs:o,available:s,pageLoading:l,handleInstallPreviewSkill:d,handleConfirmModelInvocation:p,handleDeleteDialogOpenChange:h,handleDeleteConfirm:_,handlePluginInstalled:y},e[22]=s,e[23]=o,e[24]=p,e[25]=_,e[26]=h,e[27]=d,e[28]=y,e[29]=n,e[30]=l,e[31]=r,e[32]=b,e[33]=x):x=e[33],x}function $t(e){return e.projects}function en(){let e=(0,X.c)(101),t=Qt(),{installed:n,dialogs:r,available:i}=t;if(!n.selectedProjectId){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(xe,{children:`Select a project to manage skills.`}),e[0]=t):t=e[0],t}let a,o;e[1]===r?(a=e[2],o=e[3]):(a=()=>r.setShowAddDialog(!0),o=()=>r.setShowUrlDialog(!0),e[1]=r,e[2]=a,e[3]=o);let s;e[4]!==r.openInvocationDialog||e[5]!==n.handleOpenInExplorer||e[6]!==n.items||e[7]!==n.selectedThreadId||e[8]!==n.setDeleteConfirm||e[9]!==a||e[10]!==o?(s=(0,Q.jsx)(Mt,{skills:n.items,threadId:n.selectedThreadId,onOpenSkill:n.handleOpenInExplorer,onDelete:n.setDeleteConfirm,onAddManual:a,onAddUrl:o,onChangeModelInvocation:r.openInvocationDialog}),e[4]=r.openInvocationDialog,e[5]=n.handleOpenInExplorer,e[6]=n.items,e[7]=n.selectedThreadId,e[8]=n.setDeleteConfirm,e[9]=a,e[10]=o,e[11]=s):s=e[11];let c;e[12]===r?c=e[13]:(c=e=>r.setPreviewSkill(e),e[12]=r,e[13]=c);let l;e[14]!==i.selectedSourceId||e[15]!==r?(l=e=>r.setPreviewSkill({...e,sourceId:e.sourceId??i.selectedSourceId}),e[14]=i.selectedSourceId,e[15]=r,e[16]=l):l=e[16];let u;e[17]===r?u=e[18]:(u=()=>r.setShowAddSourceDialog(!0),e[17]=r,e[18]=u);let d;e[19]!==i.availableCatalog||e[20]!==i.availableCatalogLoading||e[21]!==i.availablePopular||e[22]!==i.availableSearch||e[23]!==i.isDefaultSource||e[24]!==i.selectedCustomSource||e[25]!==i.selectedSourceId||e[26]!==i.setAvailableSearch||e[27]!==i.setSelectedSourceId||e[28]!==i.sources||e[29]!==c||e[30]!==l||e[31]!==u?(d=(0,Q.jsx)(vt,{availableSearch:i.availableSearch,onSearchChange:i.setAvailableSearch,selectedSourceId:i.selectedSourceId,onSourceChange:i.setSelectedSourceId,sources:i.sources,selectedCustomSource:i.selectedCustomSource,availableCatalogLoading:i.availableCatalogLoading,isDefaultSource:i.isDefaultSource,availablePopular:i.availablePopular,availableCatalog:i.availableCatalog,onPreviewPopular:c,onPreviewCatalog:l,onAddSource:u}),e[19]=i.availableCatalog,e[20]=i.availableCatalogLoading,e[21]=i.availablePopular,e[22]=i.availableSearch,e[23]=i.isDefaultSource,e[24]=i.selectedCustomSource,e[25]=i.selectedSourceId,e[26]=i.setAvailableSearch,e[27]=i.setSelectedSourceId,e[28]=i.sources,e[29]=c,e[30]=l,e[31]=u,e[32]=d):d=e[32];let f;e[33]!==t.pageLoading||e[34]!==s||e[35]!==d?(f=(0,Q.jsxs)(De,{loading:t.pageLoading,children:[s,d]}),e[33]=t.pageLoading,e[34]=s,e[35]=d,e[36]=f):f=e[36];let p=r.previewSkill!==null,m=i.isDefaultSource?void 0:i.selectedSourceId,h;e[37]!==r.handlePreviewDialogOpenChange||e[38]!==r.previewSkill||e[39]!==t.handleInstallPreviewSkill||e[40]!==p||e[41]!==m?(h=(0,Q.jsx)(dt,{open:p,onOpenChange:r.handlePreviewDialogOpenChange,skill:r.previewSkill,catalogSourceId:m,onInstall:t.handleInstallPreviewSkill}),e[37]=r.handlePreviewDialogOpenChange,e[38]=r.previewSkill,e[39]=t.handleInstallPreviewSkill,e[40]=p,e[41]=m,e[42]=h):h=e[42];let g;e[43]!==r.invocationSkill||e[44]!==r.setShowInvocationDialog||e[45]!==r.showInvocationDialog||e[46]!==t.handleConfirmModelInvocation?(g=(0,Q.jsx)(It,{open:r.showInvocationDialog,onOpenChange:r.setShowInvocationDialog,skill:r.invocationSkill,onConfirm:t.handleConfirmModelInvocation}),e[43]=r.invocationSkill,e[44]=r.setShowInvocationDialog,e[45]=r.showInvocationDialog,e[46]=t.handleConfirmModelInvocation,e[47]=g):g=e[47];let _,v,y;e[48]===i?(_=e[49],v=e[50],y=e[51]):(_=e=>{i.addSource(e),K({title:`Skill source added`,description:`${e.title} is now available in the source list.`})},v=e=>{i.updateSource(e),K({title:`Skill source updated`,description:`${e.title} has been saved.`})},y=e=>{i.removeSource(e),K({title:`Skill source removed`,description:`The custom source has been deleted.`})},e[48]=i,e[49]=_,e[50]=v,e[51]=y);let b;e[52]!==i.selectedCustomSource||e[53]!==r.setShowAddSourceDialog||e[54]!==r.showAddSourceDialog||e[55]!==_||e[56]!==v||e[57]!==y?(b=(0,Q.jsx)(ft,{open:r.showAddSourceDialog,onOpenChange:r.setShowAddSourceDialog,editingSource:i.selectedCustomSource,onSourceAdded:_,onSourceUpdated:v,onSourceDeleted:y}),e[52]=i.selectedCustomSource,e[53]=r.setShowAddSourceDialog,e[54]=r.showAddSourceDialog,e[55]=_,e[56]=v,e[57]=y,e[58]=b):b=e[58];let x;e[59]!==r||e[60]!==n?(x=()=>{r.setShowAddDialog(!1),n.loadItems(),n.triggerExplorerRefresh()},e[59]=r,e[60]=n,e[61]=x):x=e[61];let S;e[62]!==n.selectedThreadId||e[63]!==x?(S=(0,Q.jsx)(R,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,Q.jsx)(et,{threadId:n.selectedThreadId,onSkillCreated:x})}),e[62]=n.selectedThreadId,e[63]=x,e[64]=S):S=e[64];let C;e[65]!==r.setShowAddDialog||e[66]!==r.showAddDialog||e[67]!==S?(C=(0,Q.jsx)(z,{open:r.showAddDialog,onOpenChange:r.setShowAddDialog,children:S}),e[65]=r.setShowAddDialog,e[66]=r.showAddDialog,e[67]=S,e[68]=C):C=e[68];let w;e[69]===r?w=e[70]:(w=e=>r.setPluginImportUrl(e),e[69]=r,e[70]=w);let T;e[71]!==r.setShowUrlDialog||e[72]!==r.showUrlDialog||e[73]!==w?(T=(0,Q.jsx)(mt,{open:r.showUrlDialog,onOpenChange:r.setShowUrlDialog,onSubmit:w}),e[71]=r.setShowUrlDialog,e[72]=r.showUrlDialog,e[73]=w,e[74]=T):T=e[74];let E;e[75]===r?E=e[76]:(E=()=>r.setPluginImportUrl(null),e[75]=r,e[76]=E);let D;e[77]===t?D=e[78]:(D=e=>{let{mcpOnly:n}=e;t.handlePluginInstalled(n)},e[77]=t,e[78]=D);let O;e[79]!==r.pluginImportUrl||e[80]!==n.selectedProjectId||e[81]!==t.projects||e[82]!==t.selectedProjectName||e[83]!==E||e[84]!==D?(O=(0,Q.jsx)(Te,{url:r.pluginImportUrl,projectId:n.selectedProjectId,projectName:t.selectedProjectName,projects:t.projects,onSelectProject:tn,onClose:E,onInstalled:D}),e[79]=r.pluginImportUrl,e[80]=n.selectedProjectId,e[81]=t.projects,e[82]=t.selectedProjectName,e[83]=E,e[84]=D,e[85]=O):O=e[85];let k=n.deleteConfirm!==null,A=`Are you sure you want to delete the skill "${n.deleteConfirm?.name}"? This action cannot be undone.`,j;e[86]!==n.deleting||e[87]!==t.handleDeleteConfirm||e[88]!==t.handleDeleteDialogOpenChange||e[89]!==k||e[90]!==A?(j=(0,Q.jsx)(Re,{open:k,onOpenChange:t.handleDeleteDialogOpenChange,title:`Delete Skill`,description:A,onConfirm:t.handleDeleteConfirm,confirming:n.deleting}),e[86]=n.deleting,e[87]=t.handleDeleteConfirm,e[88]=t.handleDeleteDialogOpenChange,e[89]=k,e[90]=A,e[91]=j):j=e[91];let M;return e[92]!==h||e[93]!==g||e[94]!==b||e[95]!==C||e[96]!==T||e[97]!==O||e[98]!==j||e[99]!==f?(M=(0,Q.jsxs)(Q.Fragment,{children:[f,h,g,b,C,T,O,j]}),e[92]=h,e[93]=g,e[94]=b,e[95]=C,e[96]=T,e[97]=O,e[98]=j,e[99]=f,e[100]=M):M=e[100],M}function tn(){}export{en as SettingsSkillsView,en as default};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,o as n,t as r}from"./react-vendor-D61Uve5n.js";import{U as i}from"./dist-v_MvKS2-.js";import{Gn as a,Ht as o,I as s,Nt as c,T as l,Ut as u,h as d}from"./api-C4ukGdyH.js";import{t as f}from"./utils-CqsIXqSC.js";import{t as p}from"./copy-bi9iX3xn.js";import{t as m}from"./download-CWhQNGlF.js";import{t as h}from"./loader-circle-CrqRIqdA.js";import{t as g}from"./button-DDaJhJP1.js";import{t as _}from"./use-toast-CKgZ8YeP.js";import{a as v,n as y,o as b,r as x,t as S}from"./select-BR2pG61R.js";import{dt as C,gn as w,mt as T,nt as E,ot as D,wn as O}from"./index-CoY8DilQ.js";var k=t(),A=r();function j(e){return e.configured?[e.botUsername?`@${e.botUsername}`:e.botTokenPreview,`Bridge ${e.bridgeRunning?`running`:`stopped`}`,e.teamName].filter(Boolean).join(` · `):`Not configured`}function M(e){let t=(0,k.c)(51),{settings:n,drafts:r,isSavingTokens:a,onDraftChange:o,onSaveTokens:s,onClearTokens:c,onCopyManifest:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,A.jsx)(D,{title:`Slack App`}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=()=>l(),t[1]=l,t[2]=d);let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,A.jsx)(p,{className:`mr-2 h-4 w-4`}),t[3]=_):_=t[3];let v;t[4]===d?v=t[5]:(v=(0,A.jsxs)(g,{type:`button`,variant:`outline`,size:`sm`,onClick:d,children:[_,`Copy app manifest`]}),t[4]=d,t[5]=v);let y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,A.jsx)(g,{type:`button`,variant:`outline`,size:`sm`,asChild:!0,children:(0,A.jsxs)(`a`,{href:`/slack-app-icon.png`,download:`tarsk-slack-app-icon.png`,children:[(0,A.jsx)(m,{className:`mr-2 h-4 w-4`}),`Download app icon`]})}),t[6]=y):y=t[6];let b;t[7]===v?b=t[8]:(b=(0,A.jsx)(E,{title:`App Manifest`,description:`Create a Slack app from this manifest, enable Socket Mode, then paste the Bot and App-Level tokens below. The Slack manifest cannot include an app icon — download the Tarsk logo and upload it under Basic Information after creating the app.`,controlLayout:`row-end`,action:(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[v,y]})}),t[7]=v,t[8]=b);let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=f(`text-muted-foreground`,i.bodyMuted),t[9]=x):x=t[9];let S;t[10]===n?S=t[11]:(S=j(n),t[10]=n,t[11]=S);let T;t[12]===S?T=t[13]:(T=(0,A.jsx)(E,{title:`Status`,description:`Bot identity and Socket Mode bridge status.`,children:(0,A.jsx)(`span`,{className:x,children:S})}),t[12]=S,t[13]=T);let O=n.botTokenPreview||`xoxb-…`,M;t[14]===o?M=t[15]:(M=e=>o(`botToken`,e.target.value),t[14]=o,t[15]=M);let N;t[16]!==r.botToken||t[17]!==O||t[18]!==M?(N=(0,A.jsx)(E,{title:`Bot Token`,description:`Bot User OAuth Token from your Slack app (starts with xoxb-).`,children:(0,A.jsx)(w,{id:`slack-bot-token`,type:`password`,autoComplete:`off`,placeholder:O,value:r.botToken,onChange:M})}),t[16]=r.botToken,t[17]=O,t[18]=M,t[19]=N):N=t[19];let P=n.appTokenPreview||`xapp-…`,F;t[20]===o?F=t[21]:(F=e=>o(`appToken`,e.target.value),t[20]=o,t[21]=F);let I;t[22]!==r.appToken||t[23]!==P||t[24]!==F?(I=(0,A.jsx)(E,{title:`App-Level Token`,description:`App-Level Token with connections:write for Socket Mode (starts with xapp-).`,children:(0,A.jsx)(w,{id:`slack-app-token`,type:`password`,autoComplete:`off`,placeholder:P,value:r.appToken,onChange:F})}),t[22]=r.appToken,t[23]=P,t[24]=F,t[25]=I):I=t[25];let L;t[26]===s?L=t[27]:(L=()=>s(),t[26]=s,t[27]=L);let R;t[28]!==r.appToken||t[29]!==r.botToken||t[30]!==a?(R=a||!r.botToken.trim()||!r.appToken.trim(),t[28]=r.appToken,t[29]=r.botToken,t[30]=a,t[31]=R):R=t[31];let z;t[32]===a?z=t[33]:(z=a?(0,A.jsx)(h,{className:`mr-2 h-4 w-4 animate-spin`}):null,t[32]=a,t[33]=z);let B;t[34]!==L||t[35]!==R||t[36]!==z?(B=(0,A.jsxs)(g,{type:`button`,onClick:L,disabled:R,children:[z,`Save`]}),t[34]=L,t[35]=R,t[36]=z,t[37]=B):B=t[37];let V;t[38]!==a||t[39]!==c||t[40]!==n.configured?(V=n.configured?(0,A.jsx)(g,{type:`button`,variant:`outline`,onClick:()=>c(),disabled:a,children:`Clear`}):null,t[38]=a,t[39]=c,t[40]=n.configured,t[41]=V):V=t[41];let H;t[42]!==B||t[43]!==V?(H=(0,A.jsx)(E,{title:`Tokens`,description:`Save both tokens to start the bridge, or clear them to disconnect.`,controlLayout:`row-end`,action:(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[B,V]})}),t[42]=B,t[43]=V,t[44]=H):H=t[44];let U;return t[45]!==N||t[46]!==I||t[47]!==H||t[48]!==b||t[49]!==T?(U=(0,A.jsxs)(`div`,{children:[u,(0,A.jsxs)(C,{children:[b,T,N,I,H]})]}),t[45]=N,t[46]=I,t[47]=H,t[48]=b,t[49]=T,t[50]=U):U=t[50],U}function N(e,t){return t.find(t=>t.projectId===e.projectId)?.name||e.projectId}function P(e){let t=(0,k.c)(20),{binding:n,projects:r,onDelete:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=f(i.compact),t[0]=o):o=t[0];let s=n.slackChannelName||n.slackChannelId,c;t[1]===s?c=t[2]:(c=(0,A.jsx)(`div`,{className:`font-medium`,children:s}),t[1]=s,t[2]=c);let l;t[3]!==n||t[4]!==r?(l=N(n,r),t[3]=n,t[4]=r,t[5]=l):l=t[5];let u;t[6]===l?u=t[7]:(u=(0,A.jsx)(`div`,{className:`text-muted-foreground`,children:l}),t[6]=l,t[7]=u);let d;t[8]!==c||t[9]!==u?(d=(0,A.jsxs)(`div`,{className:o,children:[c,u]}),t[8]=c,t[9]=u,t[10]=d):d=t[10];let p;t[11]!==n||t[12]!==a?(p=()=>a(n),t[11]=n,t[12]=a,t[13]=p):p=t[13];let m;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,A.jsx)(O,{className:`h-4 w-4`}),t[14]=m):m=t[14];let h;t[15]===p?h=t[16]:(h=(0,A.jsx)(g,{type:`button`,variant:`ghost`,size:`icon`,onClick:p,"aria-label":`Remove binding`,children:m}),t[15]=p,t[16]=h);let _;return t[17]!==d||t[18]!==h?(_=(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border px-3 py-2`,children:[d,h]}),t[17]=d,t[18]=h,t[19]=_):_=t[19],_}function F(e){let t=(0,k.c)(45),{settings:n,projects:r,drafts:a,isSavingBinding:o,onDraftChange:s,onAddBinding:c,onDeleteBinding:l}=e,u=n.channels.length>0,d=r.length>0,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,A.jsx)(D,{title:`Channel Bindings`}),t[0]=p):p=t[0];let m;t[1]!==a.channelId||t[2]!==u||t[3]!==s||t[4]!==n.channels?(m=(0,A.jsx)(E,{title:`Slack Channel`,description:`Invite the bot to the channel first. Only channels the bot can see are listed.`,children:u?(0,A.jsxs)(S,{value:a.channelId||void 0,onValueChange:e=>s(`channelId`,e),children:[(0,A.jsx)(v,{id:`slack-channel`,"aria-label":`Slack Channel`,children:(0,A.jsx)(b,{placeholder:`Select a channel…`})}),(0,A.jsx)(y,{children:n.channels.map(L)})]}):(0,A.jsx)(w,{id:`slack-channel`,placeholder:`Channel ID (C…)`,value:a.channelId,onChange:e=>s(`channelId`,e.target.value)})}),t[1]=a.channelId,t[2]=u,t[3]=s,t[4]=n.channels,t[5]=m):m=t[5];let _=a.projectId||void 0,x;t[6]===s?x=t[7]:(x=e=>s(`projectId`,e),t[6]=s,t[7]=x);let T=!d,O=d?`Select a project…`:`No projects`,j;t[8]===O?j=t[9]:(j=(0,A.jsx)(v,{id:`slack-project`,"aria-label":`Tarsk Project`,children:(0,A.jsx)(b,{placeholder:O})}),t[8]=O,t[9]=j);let M;t[10]===r?M=t[11]:(M=r.map(I),t[10]=r,t[11]=M);let N;t[12]===M?N=t[13]:(N=(0,A.jsx)(y,{children:M}),t[12]=M,t[13]=N);let F;t[14]!==_||t[15]!==x||t[16]!==T||t[17]!==j||t[18]!==N?(F=(0,A.jsx)(E,{title:`Tarsk Project`,description:`Each Slack channel maps to one Tarsk project.`,children:(0,A.jsxs)(S,{value:_,onValueChange:x,disabled:T,children:[j,N]})}),t[14]=_,t[15]=x,t[16]=T,t[17]=j,t[18]=N,t[19]=F):F=t[19];let R;t[20]===c?R=t[21]:(R=()=>c(),t[20]=c,t[21]=R);let z;t[22]!==a.channelId||t[23]!==a.projectId||t[24]!==o?(z=o||!a.channelId.trim()||!a.projectId,t[22]=a.channelId,t[23]=a.projectId,t[24]=o,t[25]=z):z=t[25];let B;t[26]===o?B=t[27]:(B=o?(0,A.jsx)(h,{className:`mr-2 h-4 w-4 animate-spin`}):null,t[26]=o,t[27]=B);let V;t[28]!==R||t[29]!==z||t[30]!==B?(V=(0,A.jsx)(E,{title:`Bind`,description:`Create a channel ↔ project binding.`,controlLayout:`row-end`,action:(0,A.jsxs)(g,{type:`button`,onClick:R,disabled:z,children:[B,`Bind channel`]})}),t[28]=R,t[29]=z,t[30]=B,t[31]=V):V=t[31];let H;t[32]!==F||t[33]!==V||t[34]!==m?(H=(0,A.jsxs)(C,{children:[m,F,V]}),t[32]=F,t[33]=V,t[34]=m,t[35]=H):H=t[35];let U;t[36]!==l||t[37]!==r||t[38]!==n.bindings?(U=n.bindings.length===0?(0,A.jsx)(`p`,{className:f(`text-muted-foreground`,i.compact),children:`No bindings yet.`}):n.bindings.map(e=>(0,A.jsx)(P,{binding:e,projects:r,onDelete:l},`${e.slackTeamId}:${e.slackChannelId}`)),t[36]=l,t[37]=r,t[38]=n.bindings,t[39]=U):U=t[39];let W;t[40]===U?W=t[41]:(W=(0,A.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:U}),t[40]=U,t[41]=W);let G;return t[42]!==H||t[43]!==W?(G=(0,A.jsxs)(`div`,{children:[p,H,W]}),t[42]=H,t[43]=W,t[44]=G):G=t[44],G}function I(e){return(0,A.jsx)(x,{value:e.projectId,children:e.name},e.projectId)}function L(e){return(0,A.jsx)(x,{value:e.id,children:e.name},e.id)}var R=e(n(),1),z={botToken:``,appToken:``,channelId:``,projectId:``},B={tokens:!1,binding:!1};function V(e,t){_({title:e,description:t instanceof Error?t.message:String(t),variant:`destructive`})}function H(){let[e,t]=(0,R.useState)(null),[n,r]=(0,R.useState)([]),[i,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(z),[h,g]=(0,R.useState)(!0),[v,y]=(0,R.useState)(B),b=(0,R.useCallback)(async()=>{let[e,n]=await Promise.all([u(),c()]);t(e),r(n.projects)},[]);(0,R.useEffect)(()=>{let e=!1;async function n(){g(!0);try{let[n,i,a]=await Promise.all([u(),c(),o()]);e||(t(n),r(i.projects),f(a.manifest),i.projects[0]&&m(e=>e.projectId?e:{...e,projectId:i.projects[0].projectId}))}catch(t){e||V(`Failed to load Slack settings`,t)}finally{e||g(!1)}}return n(),()=>{e=!0}},[]);function x(e,t){m(n=>({...n,[e]:t}))}function S(e,t){y(n=>({...n,[e]:t}))}async function C(){let e=p.botToken.trim(),t=p.appToken.trim();if(e&&t){S(`tokens`,!0);try{await a({botToken:e,appToken:t}),m(e=>({...e,botToken:``,appToken:``})),await b(),_({title:`Slack tokens saved`})}catch(e){V(`Failed to save tokens`,e)}finally{S(`tokens`,!1)}}}async function w(){S(`tokens`,!0);try{await d(),await b(),_({title:`Slack tokens cleared`})}catch(e){V(`Failed to clear tokens`,e)}finally{S(`tokens`,!1)}}async function T(){let t=p.channelId.trim();if(t&&p.projectId){S(`binding`,!0);try{let n=e?.channels.find(e=>e.id===t);await l({slackChannelId:t,projectId:p.projectId,...n?{slackChannelName:n.name}:{}}),m(e=>({...e,channelId:``})),await b(),_({title:`Channel bound`})}catch(e){V(`Failed to bind channel`,e)}finally{S(`binding`,!1)}}}async function E(e){try{await s(e.slackTeamId,e.slackChannelId),await b(),_({title:`Binding removed`})}catch(e){V(`Failed to remove binding`,e)}}async function D(){try{await navigator.clipboard.writeText(i||(await o()).manifest),_({title:`Manifest copied`})}catch(e){V(`Failed to copy manifest`,e)}}return{settings:e,projects:n,manifest:i,drafts:p,isLoading:h,saving:v,setDraft:x,saveTokens:C,clearTokens:w,addBinding:T,deleteBinding:E,copyManifest:D}}function U(){let e=(0,k.c)(20),t=H();if(t.isLoading||!t.settings){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,A.jsx)(T,{title:`Slack`,description:`Loading Slack settings…`,children:(0,A.jsxs)(`div`,{className:f(`flex items-center gap-2 text-muted-foreground`,i.compact),children:[(0,A.jsx)(h,{className:`h-4 w-4 animate-spin`}),`Loading Slack settings…`]})}),e[0]=t):t=e[0],t}let n;e[1]!==t.clearTokens||e[2]!==t.copyManifest||e[3]!==t.drafts||e[4]!==t.saveTokens||e[5]!==t.saving.tokens||e[6]!==t.setDraft||e[7]!==t.settings?(n=(0,A.jsx)(M,{settings:t.settings,drafts:t.drafts,isSavingTokens:t.saving.tokens,onDraftChange:t.setDraft,onSaveTokens:t.saveTokens,onClearTokens:t.clearTokens,onCopyManifest:t.copyManifest}),e[1]=t.clearTokens,e[2]=t.copyManifest,e[3]=t.drafts,e[4]=t.saveTokens,e[5]=t.saving.tokens,e[6]=t.setDraft,e[7]=t.settings,e[8]=n):n=e[8];let r;e[9]!==t.addBinding||e[10]!==t.deleteBinding||e[11]!==t.drafts||e[12]!==t.projects||e[13]!==t.saving.binding||e[14]!==t.setDraft||e[15]!==t.settings?(r=(0,A.jsx)(F,{settings:t.settings,projects:t.projects,drafts:t.drafts,isSavingBinding:t.saving.binding,onDraftChange:t.setDraft,onAddBinding:t.addBinding,onDeleteBinding:t.deleteBinding}),e[9]=t.addBinding,e[10]=t.deleteBinding,e[11]=t.drafts,e[12]=t.projects,e[13]=t.saving.binding,e[14]=t.setDraft,e[15]=t.settings,e[16]=r):r=e[16];let a;return e[17]!==n||e[18]!==r?(a=(0,A.jsx)(T,{title:`Slack`,description:`Connect a Slack app (Socket Mode) and bind channels to Tarsk projects.`,children:(0,A.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[n,r]})}),e[17]=n,e[18]=r,e[19]=a):a=e[19],a}export{U as default};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,o as n,t as r}from"./react-vendor-D61Uve5n.js";import{U as i}from"./dist-v_MvKS2-.js";import{F as a,Ht as o,Mt as s,Un as c,Vt as l,m as u,w as d}from"./api-Cp9I7CxD.js";import{t as f}from"./utils-CqsIXqSC.js";import{t as p}from"./copy-bi9iX3xn.js";import{t as m}from"./download-CWhQNGlF.js";import{t as h}from"./loader-circle-CrqRIqdA.js";import{t as g}from"./button-DDaJhJP1.js";import{t as _}from"./use-toast-CKgZ8YeP.js";import{a as v,n as y,o as b,r as x,t as S}from"./select-DMcNYwgt.js";import{Cn as C,dt as w,gn as T,mt as E,nt as D,ot as O}from"./index-CcAwxnT5.js";var k=t(),A=r();function j(e){return e.configured?[e.botUsername?`@${e.botUsername}`:e.botTokenPreview,`Bridge ${e.bridgeRunning?`running`:`stopped`}`,e.teamName].filter(Boolean).join(` · `):`Not configured`}function M(e){let t=(0,k.c)(51),{settings:n,drafts:r,isSavingTokens:a,onDraftChange:o,onSaveTokens:s,onClearTokens:c,onCopyManifest:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,A.jsx)(O,{title:`Slack App`}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=()=>l(),t[1]=l,t[2]=d);let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,A.jsx)(p,{className:`mr-2 h-4 w-4`}),t[3]=_):_=t[3];let v;t[4]===d?v=t[5]:(v=(0,A.jsxs)(g,{type:`button`,variant:`outline`,size:`sm`,onClick:d,children:[_,`Copy app manifest`]}),t[4]=d,t[5]=v);let y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,A.jsx)(g,{type:`button`,variant:`outline`,size:`sm`,asChild:!0,children:(0,A.jsxs)(`a`,{href:`/slack-app-icon.png`,download:`tarsk-slack-app-icon.png`,children:[(0,A.jsx)(m,{className:`mr-2 h-4 w-4`}),`Download app icon`]})}),t[6]=y):y=t[6];let b;t[7]===v?b=t[8]:(b=(0,A.jsx)(D,{title:`App Manifest`,description:`Create a Slack app from this manifest, enable Socket Mode, then paste the Bot and App-Level tokens below. The Slack manifest cannot include an app icon — download the Tarsk logo and upload it under Basic Information after creating the app.`,controlLayout:`row-end`,action:(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[v,y]})}),t[7]=v,t[8]=b);let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=f(`text-muted-foreground`,i.bodyMuted),t[9]=x):x=t[9];let S;t[10]===n?S=t[11]:(S=j(n),t[10]=n,t[11]=S);let C;t[12]===S?C=t[13]:(C=(0,A.jsx)(D,{title:`Status`,description:`Bot identity and Socket Mode bridge status.`,children:(0,A.jsx)(`span`,{className:x,children:S})}),t[12]=S,t[13]=C);let E=n.botTokenPreview||`xoxb-…`,M;t[14]===o?M=t[15]:(M=e=>o(`botToken`,e.target.value),t[14]=o,t[15]=M);let N;t[16]!==r.botToken||t[17]!==E||t[18]!==M?(N=(0,A.jsx)(D,{title:`Bot Token`,description:`Bot User OAuth Token from your Slack app (starts with xoxb-).`,children:(0,A.jsx)(T,{id:`slack-bot-token`,type:`password`,autoComplete:`off`,placeholder:E,value:r.botToken,onChange:M})}),t[16]=r.botToken,t[17]=E,t[18]=M,t[19]=N):N=t[19];let P=n.appTokenPreview||`xapp-…`,F;t[20]===o?F=t[21]:(F=e=>o(`appToken`,e.target.value),t[20]=o,t[21]=F);let I;t[22]!==r.appToken||t[23]!==P||t[24]!==F?(I=(0,A.jsx)(D,{title:`App-Level Token`,description:`App-Level Token with connections:write for Socket Mode (starts with xapp-).`,children:(0,A.jsx)(T,{id:`slack-app-token`,type:`password`,autoComplete:`off`,placeholder:P,value:r.appToken,onChange:F})}),t[22]=r.appToken,t[23]=P,t[24]=F,t[25]=I):I=t[25];let L;t[26]===s?L=t[27]:(L=()=>s(),t[26]=s,t[27]=L);let R;t[28]!==r.appToken||t[29]!==r.botToken||t[30]!==a?(R=a||!r.botToken.trim()||!r.appToken.trim(),t[28]=r.appToken,t[29]=r.botToken,t[30]=a,t[31]=R):R=t[31];let z;t[32]===a?z=t[33]:(z=a?(0,A.jsx)(h,{className:`mr-2 h-4 w-4 animate-spin`}):null,t[32]=a,t[33]=z);let B;t[34]!==L||t[35]!==R||t[36]!==z?(B=(0,A.jsxs)(g,{type:`button`,onClick:L,disabled:R,children:[z,`Save`]}),t[34]=L,t[35]=R,t[36]=z,t[37]=B):B=t[37];let V;t[38]!==a||t[39]!==c||t[40]!==n.configured?(V=n.configured?(0,A.jsx)(g,{type:`button`,variant:`outline`,onClick:()=>c(),disabled:a,children:`Clear`}):null,t[38]=a,t[39]=c,t[40]=n.configured,t[41]=V):V=t[41];let H;t[42]!==B||t[43]!==V?(H=(0,A.jsx)(D,{title:`Tokens`,description:`Save both tokens to start the bridge, or clear them to disconnect.`,controlLayout:`row-end`,action:(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[B,V]})}),t[42]=B,t[43]=V,t[44]=H):H=t[44];let U;return t[45]!==N||t[46]!==I||t[47]!==H||t[48]!==b||t[49]!==C?(U=(0,A.jsxs)(`div`,{children:[u,(0,A.jsxs)(w,{children:[b,C,N,I,H]})]}),t[45]=N,t[46]=I,t[47]=H,t[48]=b,t[49]=C,t[50]=U):U=t[50],U}function N(e,t){return t.find(t=>t.projectId===e.projectId)?.name||e.projectId}function P(e){let t=(0,k.c)(20),{binding:n,projects:r,onDelete:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=f(i.compact),t[0]=o):o=t[0];let s=n.slackChannelName||n.slackChannelId,c;t[1]===s?c=t[2]:(c=(0,A.jsx)(`div`,{className:`font-medium`,children:s}),t[1]=s,t[2]=c);let l;t[3]!==n||t[4]!==r?(l=N(n,r),t[3]=n,t[4]=r,t[5]=l):l=t[5];let u;t[6]===l?u=t[7]:(u=(0,A.jsx)(`div`,{className:`text-muted-foreground`,children:l}),t[6]=l,t[7]=u);let d;t[8]!==c||t[9]!==u?(d=(0,A.jsxs)(`div`,{className:o,children:[c,u]}),t[8]=c,t[9]=u,t[10]=d):d=t[10];let p;t[11]!==n||t[12]!==a?(p=()=>a(n),t[11]=n,t[12]=a,t[13]=p):p=t[13];let m;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,A.jsx)(C,{className:`h-4 w-4`}),t[14]=m):m=t[14];let h;t[15]===p?h=t[16]:(h=(0,A.jsx)(g,{type:`button`,variant:`ghost`,size:`icon`,onClick:p,"aria-label":`Remove binding`,children:m}),t[15]=p,t[16]=h);let _;return t[17]!==d||t[18]!==h?(_=(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border px-3 py-2`,children:[d,h]}),t[17]=d,t[18]=h,t[19]=_):_=t[19],_}function F(e){let t=(0,k.c)(45),{settings:n,projects:r,drafts:a,isSavingBinding:o,onDraftChange:s,onAddBinding:c,onDeleteBinding:l}=e,u=n.channels.length>0,d=r.length>0,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,A.jsx)(O,{title:`Channel Bindings`}),t[0]=p):p=t[0];let m;t[1]!==a.channelId||t[2]!==u||t[3]!==s||t[4]!==n.channels?(m=(0,A.jsx)(D,{title:`Slack Channel`,description:`Invite the bot to the channel first. Only channels the bot can see are listed.`,children:u?(0,A.jsxs)(S,{value:a.channelId||void 0,onValueChange:e=>s(`channelId`,e),children:[(0,A.jsx)(v,{id:`slack-channel`,"aria-label":`Slack Channel`,children:(0,A.jsx)(b,{placeholder:`Select a channel…`})}),(0,A.jsx)(y,{children:n.channels.map(L)})]}):(0,A.jsx)(T,{id:`slack-channel`,placeholder:`Channel ID (C…)`,value:a.channelId,onChange:e=>s(`channelId`,e.target.value)})}),t[1]=a.channelId,t[2]=u,t[3]=s,t[4]=n.channels,t[5]=m):m=t[5];let _=a.projectId||void 0,x;t[6]===s?x=t[7]:(x=e=>s(`projectId`,e),t[6]=s,t[7]=x);let C=!d,E=d?`Select a project…`:`No projects`,j;t[8]===E?j=t[9]:(j=(0,A.jsx)(v,{id:`slack-project`,"aria-label":`Tarsk Project`,children:(0,A.jsx)(b,{placeholder:E})}),t[8]=E,t[9]=j);let M;t[10]===r?M=t[11]:(M=r.map(I),t[10]=r,t[11]=M);let N;t[12]===M?N=t[13]:(N=(0,A.jsx)(y,{children:M}),t[12]=M,t[13]=N);let F;t[14]!==_||t[15]!==x||t[16]!==C||t[17]!==j||t[18]!==N?(F=(0,A.jsx)(D,{title:`Tarsk Project`,description:`Each Slack channel maps to one Tarsk project.`,children:(0,A.jsxs)(S,{value:_,onValueChange:x,disabled:C,children:[j,N]})}),t[14]=_,t[15]=x,t[16]=C,t[17]=j,t[18]=N,t[19]=F):F=t[19];let R;t[20]===c?R=t[21]:(R=()=>c(),t[20]=c,t[21]=R);let z;t[22]!==a.channelId||t[23]!==a.projectId||t[24]!==o?(z=o||!a.channelId.trim()||!a.projectId,t[22]=a.channelId,t[23]=a.projectId,t[24]=o,t[25]=z):z=t[25];let B;t[26]===o?B=t[27]:(B=o?(0,A.jsx)(h,{className:`mr-2 h-4 w-4 animate-spin`}):null,t[26]=o,t[27]=B);let V;t[28]!==R||t[29]!==z||t[30]!==B?(V=(0,A.jsx)(D,{title:`Bind`,description:`Create a channel ↔ project binding.`,controlLayout:`row-end`,action:(0,A.jsxs)(g,{type:`button`,onClick:R,disabled:z,children:[B,`Bind channel`]})}),t[28]=R,t[29]=z,t[30]=B,t[31]=V):V=t[31];let H;t[32]!==F||t[33]!==V||t[34]!==m?(H=(0,A.jsxs)(w,{children:[m,F,V]}),t[32]=F,t[33]=V,t[34]=m,t[35]=H):H=t[35];let U;t[36]!==l||t[37]!==r||t[38]!==n.bindings?(U=n.bindings.length===0?(0,A.jsx)(`p`,{className:f(`text-muted-foreground`,i.compact),children:`No bindings yet.`}):n.bindings.map(e=>(0,A.jsx)(P,{binding:e,projects:r,onDelete:l},`${e.slackTeamId}:${e.slackChannelId}`)),t[36]=l,t[37]=r,t[38]=n.bindings,t[39]=U):U=t[39];let W;t[40]===U?W=t[41]:(W=(0,A.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:U}),t[40]=U,t[41]=W);let G;return t[42]!==H||t[43]!==W?(G=(0,A.jsxs)(`div`,{children:[p,H,W]}),t[42]=H,t[43]=W,t[44]=G):G=t[44],G}function I(e){return(0,A.jsx)(x,{value:e.projectId,children:e.name},e.projectId)}function L(e){return(0,A.jsx)(x,{value:e.id,children:e.name},e.id)}var R=e(n(),1),z={botToken:``,appToken:``,channelId:``,projectId:``},B={tokens:!1,binding:!1};function V(e,t){_({title:e,description:t instanceof Error?t.message:String(t),variant:`destructive`})}function H(){let[e,t]=(0,R.useState)(null),[n,r]=(0,R.useState)([]),[i,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(z),[h,g]=(0,R.useState)(!0),[v,y]=(0,R.useState)(B),b=(0,R.useCallback)(async()=>{let[e,n]=await Promise.all([o(),s()]);t(e),r(n.projects)},[]);(0,R.useEffect)(()=>{let e=!1;async function n(){g(!0);try{let[n,i,a]=await Promise.all([o(),s(),l()]);e||(t(n),r(i.projects),f(a.manifest),i.projects[0]&&m(e=>e.projectId?e:{...e,projectId:i.projects[0].projectId}))}catch(t){e||V(`Failed to load Slack settings`,t)}finally{e||g(!1)}}return n(),()=>{e=!0}},[]);function x(e,t){m(n=>({...n,[e]:t}))}function S(e,t){y(n=>({...n,[e]:t}))}async function C(){let e=p.botToken.trim(),t=p.appToken.trim();if(e&&t){S(`tokens`,!0);try{await c({botToken:e,appToken:t}),m(e=>({...e,botToken:``,appToken:``})),await b(),_({title:`Slack tokens saved`})}catch(e){V(`Failed to save tokens`,e)}finally{S(`tokens`,!1)}}}async function w(){S(`tokens`,!0);try{await u(),await b(),_({title:`Slack tokens cleared`})}catch(e){V(`Failed to clear tokens`,e)}finally{S(`tokens`,!1)}}async function T(){let t=p.channelId.trim();if(t&&p.projectId){S(`binding`,!0);try{let n=e?.channels.find(e=>e.id===t);await d({slackChannelId:t,projectId:p.projectId,...n?{slackChannelName:n.name}:{}}),m(e=>({...e,channelId:``})),await b(),_({title:`Channel bound`})}catch(e){V(`Failed to bind channel`,e)}finally{S(`binding`,!1)}}}async function E(e){try{await a(e.slackTeamId,e.slackChannelId),await b(),_({title:`Binding removed`})}catch(e){V(`Failed to remove binding`,e)}}async function D(){try{await navigator.clipboard.writeText(i||(await l()).manifest),_({title:`Manifest copied`})}catch(e){V(`Failed to copy manifest`,e)}}return{settings:e,projects:n,manifest:i,drafts:p,isLoading:h,saving:v,setDraft:x,saveTokens:C,clearTokens:w,addBinding:T,deleteBinding:E,copyManifest:D}}function U(){let e=(0,k.c)(20),t=H();if(t.isLoading||!t.settings){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,A.jsx)(E,{title:`Slack`,description:`Loading Slack settings…`,children:(0,A.jsxs)(`div`,{className:f(`flex items-center gap-2 text-muted-foreground`,i.compact),children:[(0,A.jsx)(h,{className:`h-4 w-4 animate-spin`}),`Loading Slack settings…`]})}),e[0]=t):t=e[0],t}let n;e[1]!==t.clearTokens||e[2]!==t.copyManifest||e[3]!==t.drafts||e[4]!==t.saveTokens||e[5]!==t.saving.tokens||e[6]!==t.setDraft||e[7]!==t.settings?(n=(0,A.jsx)(M,{settings:t.settings,drafts:t.drafts,isSavingTokens:t.saving.tokens,onDraftChange:t.setDraft,onSaveTokens:t.saveTokens,onClearTokens:t.clearTokens,onCopyManifest:t.copyManifest}),e[1]=t.clearTokens,e[2]=t.copyManifest,e[3]=t.drafts,e[4]=t.saveTokens,e[5]=t.saving.tokens,e[6]=t.setDraft,e[7]=t.settings,e[8]=n):n=e[8];let r;e[9]!==t.addBinding||e[10]!==t.deleteBinding||e[11]!==t.drafts||e[12]!==t.projects||e[13]!==t.saving.binding||e[14]!==t.setDraft||e[15]!==t.settings?(r=(0,A.jsx)(F,{settings:t.settings,projects:t.projects,drafts:t.drafts,isSavingBinding:t.saving.binding,onDraftChange:t.setDraft,onAddBinding:t.addBinding,onDeleteBinding:t.deleteBinding}),e[9]=t.addBinding,e[10]=t.deleteBinding,e[11]=t.drafts,e[12]=t.projects,e[13]=t.saving.binding,e[14]=t.setDraft,e[15]=t.settings,e[16]=r):r=e[16];let a;return e[17]!==n||e[18]!==r?(a=(0,A.jsx)(E,{title:`Slack`,description:`Connect a Slack app (Socket Mode) and bind channels to Tarsk projects.`,children:(0,A.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[n,r]})}),e[17]=n,e[18]=r,e[19]=a):a=e[19],a}export{U as default};