@duckmind/duckmind-darwin-x64 1.2.98 → 1.3.6

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 (26) hide show
  1. package/.duckmind/plugins/.duckmind-managed-plugins.json +1 -1
  2. package/.duckmind/web/assets/{dialog-connect-provider-DqlW9pvn.js → dialog-connect-provider-jjqkH3fb.js} +2 -2
  3. package/.duckmind/web/assets/{dialog-edit-project-CzkH2te1.js → dialog-edit-project-DOemY3AL.js} +1 -1
  4. package/.duckmind/web/assets/{dialog-fork-OPHiOO-C.js → dialog-fork-BmnqME4F.js} +1 -1
  5. package/.duckmind/web/assets/{dialog-manage-models-DZPMD3UM.js → dialog-manage-models-D4NfKd0g.js} +1 -1
  6. package/.duckmind/web/assets/{dialog-select-directory-Dolr2s7s.js → dialog-select-directory-CzrpEaT8.js} +1 -1
  7. package/.duckmind/web/assets/{dialog-select-file-D32HXwjt.js → dialog-select-file-Di34JDys.js} +1 -1
  8. package/.duckmind/web/assets/{dialog-select-mcp-CYpIL68e.js → dialog-select-mcp-CfzzoOQ0.js} +1 -1
  9. package/.duckmind/web/assets/{dialog-select-model-unpaid-Drf0Wo8J.js → dialog-select-model-unpaid-BVinN3w5.js} +2 -2
  10. package/.duckmind/web/assets/{dialog-select-provider-CZw0JIcb.js → dialog-select-provider-DNa_XLNK.js} +1 -1
  11. package/.duckmind/web/assets/{dialog-select-server-CZWv28SL.js → dialog-select-server-CXhQWGJN.js} +1 -1
  12. package/.duckmind/web/assets/{dialog-settings-CEmNVCR7.js → dialog-settings-BZcMt_Zh.js} +1 -1
  13. package/.duckmind/web/assets/{file-icon-vO6wN-HW.js → file-icon-B_-1whMc.js} +1 -1
  14. package/.duckmind/web/assets/{ghostty-web-DyPkyuK6.js → ghostty-web-o_xRAlFy.js} +1 -1
  15. package/.duckmind/web/assets/{home-B6RNk4hy.js → home-XqeLA6yi.js} +1 -1
  16. package/.duckmind/web/assets/{index-Bj2ueAL8.js → index-D-WWa_X8.js} +3 -3
  17. package/.duckmind/web/assets/{list-FNV9nNTY.js → list-Dk_vU1zd.js} +1 -1
  18. package/.duckmind/web/assets/{provider-icon-BO5C5h8K.js → provider-icon-CbXUEYMU.js} +1 -1
  19. package/.duckmind/web/assets/{select-Df3XuuZj.js → select-iTRCZro5.js} +1 -1
  20. package/.duckmind/web/assets/{server-row--RKYaqbn.js → server-row-LxKRQxMm.js} +1 -1
  21. package/.duckmind/web/assets/{session-Df_z3CAQ.js → session-BmqyKO6_.js} +10 -10
  22. package/.duckmind/web/assets/{status-popover-body-BHs7f0l2.js → status-popover-body-D8K1NeBF.js} +2 -2
  23. package/.duckmind/web/assets/{switch-DyYMuMHL.js → switch-CiVaw2SH.js} +1 -1
  24. package/.duckmind/web/index.html +1 -1
  25. package/bin/duckmind +0 -0
  26. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  {
2
- "updated_at": "2026-03-31T17:38:47.319445+00:00",
2
+ "updated_at": "2026-04-03T16:41:57.555509+00:00",
3
3
  "files": [
4
4
  "duckmind-websearch-cited.js"
5
5
  ]
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dialog-select-provider-CZw0JIcb.js","assets/index-Bj2ueAL8.js","assets/index-jvk-T241.css","assets/list-FNV9nNTY.js","assets/provider-icon-BO5C5h8K.js"])))=>i.map(i=>d[i]);
2
- import{b as ve,s as he,w as me,x as fe,i as o,t as x,aB as re,c as ge,u as xe,bv as ye,f as be,aF as _e,q as we,g as _,ay as $e,n as F,o as ke,h as r,S as L,M as m,m as Y,ah as Z,I as Se,j as Ce,a5 as Ie,aV as De,bz as j,B as R,v as ze,bx as Pe,al as Ee,a7 as Ke}from"./index-Bj2ueAL8.js";import{L as ee}from"./list-FNV9nNTY.js";import{P as Le}from"./provider-icon-BO5C5h8K.js";var Te=x("<a>");function G(h){const T=ve(),[b,S]=he(h,["href","children","class"]);return(()=>{var n=Te();return n.$$click=O=>{b.href&&(O.preventDefault(),T.openLink(b.href))},me(n,fe({get href(){return b.href},get class(){return`text-text-strong underline ${b.class??""}`}},S),!1,!0),o(n,()=>b.children),n})()}re(["click"]);var Me=x('<div class="w-full flex flex-col gap-1.5"><div class="text-14-regular text-text-base"></div><div>'),Fe=x('<form class="flex flex-col items-start gap-4">'),je=x('<div class="w-full flex items-center gap-x-2"><div class="w-4 h-2 rounded-[1px] bg-input-base shadow-xs-border-base flex items-center justify-center"><div class="w-2.5 h-0.5 ml-0 bg-icon-strong-base hidden"data-slot=list-item-extra-icon></div></div><span></span><span class="text-14-regular text-text-weak">'),te=x('<div class="text-14-regular text-text-base">'),Oe=x("<div>"),Ae=x('<div class="w-full flex items-center gap-x-2"><div class="w-4 h-2 rounded-[1px] bg-input-base shadow-xs-border-base flex items-center justify-center"><div class="w-2.5 h-0.5 ml-0 bg-icon-strong-base hidden"data-slot=list-item-extra-icon></div></div><span>'),Ve=x('<div class="flex flex-col gap-4"><div class="text-14-regular text-text-base"></div><div class="text-14-regular text-text-base"></div><div class="text-14-regular text-text-base">'),qe=x('<div class="flex flex-col gap-6"><form class="flex flex-col items-start gap-4">'),Be=x('<div class="flex flex-col gap-6"><div class="text-14-regular text-text-base"></div><form class="flex flex-col items-start gap-4">'),Ze=x('<div class="flex flex-col gap-6"><div class="text-14-regular text-text-base"></div><div class="text-14-regular text-text-base flex items-center gap-4"><span>'),H=x('<div class="text-14-regular text-text-base"><div class="flex items-center gap-x-2"><span>'),Re=x('<div class="flex flex-col gap-6 px-2.5 pb-3"><div class="px-2.5 flex gap-4 items-center"><div class="text-16-medium text-text-strong"></div></div><div class="px-2.5 pb-10 flex flex-col gap-6"><div tabindex=0>');function Ge(h){const T=ge(),b=xe(),S=ye(),n=be(),O=_e(),J=()=>{Ke(()=>import("./dialog-select-provider-CZw0JIcb.js").then(e=>e.d),__vite__mapDeps([0,1,2,3,4])).then(e=>{T.show(()=>r(e.DialogSelectProvider,{}))})},C={value:!0},w={current:void 0};we(()=>{C.value=!1,w.current!==void 0&&(clearTimeout(w.current),w.current=void 0)});const $=_(()=>O.all().find(e=>e.id===h.provider)??b.data.provider.all.find(e=>e.id===h.provider)),A=_(()=>[{type:"api",label:n.t("provider.connect.method.apiKey")}]),[N]=$e(()=>h.provider,async()=>{const e=b.data.provider_auth[h.provider];if(e)return e;const t=await S.client.provider.auth();return C.value?(b.set("provider_auth",t.data??{}),t.data?.[h.provider]??A()):A()}),Q=_(()=>N.loading&&!b.data.provider_auth[h.provider]),D=_(()=>N.latest??b.data.provider_auth[h.provider]??A()),[d,ne]=F({methodIndex:void 0,authorization:void 0,state:"pending",error:void 0});function k(e){ne(Pe(t=>{if(e.type==="method.select"){t.methodIndex=e.index,t.authorization=void 0,t.state=void 0,t.error=void 0;return}if(e.type==="method.reset"){t.methodIndex=void 0,t.authorization=void 0,t.state=void 0,t.error=void 0;return}if(e.type==="auth.prompt"){t.state="prompt",t.error=void 0;return}if(e.type==="auth.pending"){t.state="pending",t.error=void 0;return}if(e.type==="auth.complete"){t.state="complete",t.authorization=e.authorization,t.error=void 0;return}t.state="error",t.error=e.error}))}const z=_(()=>d.methodIndex!==void 0?D().at(d.methodIndex):void 0),ie=e=>e?e.type==="api"?n.t("provider.connect.method.apiKey"):e.label??"":"";function M(e,t){if(e&&typeof e=="object"&&"data"in e){const i=e.data;if(typeof i?.message=="string"&&i.message)return i.message}if(e&&typeof e=="object"&&"error"in e){const i=M(e.error,"");if(i)return i}if(e&&typeof e=="object"&&"message"in e){const i=e.message;if(typeof i=="string"&&i)return i}return e instanceof Error&&e.message?e.message:typeof e=="string"&&e?e:t}async function V(e,t){w.current!==void 0&&(clearTimeout(w.current),w.current=void 0);const i=D()[e];if(k({type:"method.select",index:e}),i.type==="oauth"){if(i.prompts?.length&&!t){k({type:"auth.prompt"});return}k({type:"auth.pending"});const c=Date.now();await S.client.provider.oauth.authorize({providerID:h.provider,method:e,inputs:t},{throwOnError:!0}).then(a=>{if(!C.value)return;const u=1e3-(Date.now()-c);if(u>0){w.current!==void 0&&clearTimeout(w.current),w.current=setTimeout(()=>{w.current=void 0,C.value&&k({type:"auth.complete",authorization:a.data})},u);return}k({type:"auth.complete",authorization:a.data})}).catch(a=>{C.value&&k({type:"auth.error",error:M(a,n.t("common.requestFailed"))})})}}function oe(){const[e,t]=F({value:{},index:0}),i=_(()=>{const l=z();return l?.type!=="oauth"?[]:l.prompts??[]}),c=(l,p)=>{if(!l.when)return!0;const g=p[l.when.key];return g===void 0?!1:l.when.op==="eq"?g===l.when.value:g!==l.when.value},a=_(()=>{const l=i(),p=l.findIndex((g,K)=>K>=e.index&&c(g,e.value));if(p!==-1)return{index:p,prompt:l[p]}}),s=_(()=>{const l=a();return!l||l.prompt.type!=="text"?!1:(e.value[l.prompt.key]??"").trim().length>0});async function u(l,p){if(d.methodIndex===void 0)return;const g=i().findIndex((K,y)=>y>l&&c(K,p));if(g!==-1){t("index",g);return}await V(d.methodIndex,p)}async function v(l){l.preventDefault();const p=a();!p||p.prompt.type!=="text"||s()&&await u(p.index,e.value)}const f=()=>a(),P=_(()=>{const l=f()?.prompt;if(!(!l||l.type!=="text"))return l}),E=_(()=>{const l=f()?.prompt;if(!(!l||l.type!=="select"))return l});return(()=>{var l=Fe();return l.addEventListener("submit",v),o(l,r(L,{get children(){return[r(m,{get when(){return f()?.prompt.type==="text"},get children(){return[r(j,{type:"text",get label(){return P()?.message??""},get placeholder(){return P()?.placeholder},get value(){return Y(()=>!!P())()?e.value[P().key]??"":""},onChange:p=>{const g=P();g&&t("value",g.key,p)}}),r(R,{class:"w-auto",type:"submit",size:"large",variant:"primary",get disabled(){return!s()},get children(){return n.t("common.continue")}})]}}),r(m,{get when(){return f()?.prompt.type==="select"},get children(){var p=Me(),g=p.firstChild,K=g.nextSibling;return o(g,()=>E()?.message),o(K,r(ee,{get items(){return E()?.options??[]},key:y=>y.value,get current(){return E()?.options.find(y=>y.value===e.value[E().key])},onSelect:y=>{if(!y)return;const I=E();if(!I)return;const B={...e.value,[I.key]:y.value};t("value",I.key,y.value),u(f().index,B)},children:y=>(()=>{var I=je(),B=I.firstChild,X=B.nextSibling,pe=X.nextSibling;return o(X,()=>y.label),o(pe,()=>y.hint),I})()})),p}})]}})),l})()}let U;function ae(e){e.key==="Enter"&&e.target instanceof HTMLInputElement||e.key!=="Escape"&&U?.onKeyDown(e)}let W=!1;ke(()=>{W||Q()||D().length===1&&(W=!0,V(0))});async function q(){await S.client.global.dispose(),T.close(),Ee({variant:"success",icon:"circle-check",title:n.t("provider.connect.toast.connected.title",{provider:$().name}),description:n.t("provider.connect.toast.connected.description",{provider:$().name})})}function le(){if(D().length===1){J();return}if(d.authorization){k({type:"method.reset"});return}if(d.methodIndex!==void 0){k({type:"method.reset"});return}J()}function se(){return[(()=>{var e=te();return o(e,()=>n.t("provider.connect.selectMethod",{provider:$().name})),e})(),(()=>{var e=Oe();return o(e,r(ee,{ref:t=>{U=t},items:D,key:t=>t?.label,onSelect:async(t,i)=>{t&&V(i)},children:t=>(()=>{var i=Ae(),c=i.firstChild,a=c.nextSibling;return o(a,()=>ie(t)),i})()})),e})()]}function ce(){const[e,t]=F({value:"",error:void 0});async function i(c){c.preventDefault();const a=c.currentTarget,u=new FormData(a).get("apiKey");if(!u?.trim()){t("error",n.t("provider.connect.apiKey.required"));return}t("error",void 0),await S.client.auth.set({providerID:h.provider,auth:{type:"api",key:u}}),await q()}return(()=>{var c=qe(),a=c.firstChild;return o(c,r(L,{get children(){return[r(m,{get when(){return $().id==="duckmind"},get children(){var s=Ve(),u=s.firstChild,v=u.nextSibling,f=v.nextSibling;return o(u,()=>n.t("provider.connect.duckmindZen.line1")),o(v,()=>n.t("provider.connect.duckmindZen.line2")),o(f,()=>n.t("provider.connect.duckmindZen.visit.prefix"),null),o(f,r(G,{href:"https://duckmind.ai/zen",tabIndex:-1,get children(){return n.t("provider.connect.duckmindZen.visit.link")}}),null),o(f,()=>n.t("provider.connect.duckmindZen.visit.suffix"),null),s}}),r(m,{when:!0,get children(){var s=te();return o(s,()=>n.t("provider.connect.apiKey.description",{provider:$().name})),s}})]}}),a),a.addEventListener("submit",i),o(a,r(j,{autofocus:!0,type:"text",get label(){return n.t("provider.connect.apiKey.label",{provider:$().name})},get placeholder(){return n.t("provider.connect.apiKey.placeholder")},name:"apiKey",get value(){return e.value},onChange:s=>t("value",s),get validationState(){return e.error?"invalid":void 0},get error(){return e.error}}),null),o(a,r(R,{class:"w-auto",type:"submit",size:"large",variant:"primary",get children(){return n.t("common.continue")}}),null),c})()}function ue(){const[e,t]=F({value:"",error:void 0});async function i(c){c.preventDefault();const a=c.currentTarget,u=new FormData(a).get("code");if(!u?.trim()){t("error",n.t("provider.connect.oauth.code.required"));return}t("error",void 0);const v=await S.client.provider.oauth.callback({providerID:h.provider,method:d.methodIndex,code:u}).then(f=>f.error?{ok:!1,error:f.error}:{ok:!0}).catch(f=>({ok:!1,error:f}));if(v.ok){await q();return}t("error",M(v.error,n.t("provider.connect.oauth.code.invalid")))}return(()=>{var c=Be(),a=c.firstChild,s=a.nextSibling;return o(a,()=>n.t("provider.connect.oauth.code.visit.prefix"),null),o(a,r(G,{get href(){return d.authorization.url},get children(){return n.t("provider.connect.oauth.code.visit.link")}}),null),o(a,()=>n.t("provider.connect.oauth.code.visit.suffix",{provider:$().name}),null),s.addEventListener("submit",i),o(s,r(j,{autofocus:!0,type:"text",get label(){return n.t("provider.connect.oauth.code.label",{method:z()?.label??""})},get placeholder(){return n.t("provider.connect.oauth.code.placeholder")},name:"code",get value(){return e.value},onChange:u=>t("value",u),get validationState(){return e.error?"invalid":void 0},get error(){return e.error}}),null),o(s,r(R,{class:"w-auto",type:"submit",size:"large",variant:"primary",get children(){return n.t("common.continue")}}),null),c})()}function de(){const e=_(()=>{const t=d.authorization?.instructions;return t?.includes(":")?t.split(":")[1]?.trim():t});return ze(()=>{(async()=>{const t=await S.client.provider.oauth.callback({providerID:h.provider,method:d.methodIndex}).then(i=>i.error?{ok:!1,error:i.error}:{ok:!0}).catch(i=>({ok:!1,error:i}));if(C.value){if(!t.ok){const i=M(t.error,n.t("common.requestFailed"));k({type:"auth.error",error:i});return}await q()}})()}),(()=>{var t=Ze(),i=t.firstChild,c=i.nextSibling,a=c.firstChild;return o(i,()=>n.t("provider.connect.oauth.auto.visit.prefix"),null),o(i,r(G,{get href(){return d.authorization.url},get children(){return n.t("provider.connect.oauth.auto.visit.link")}}),null),o(i,()=>n.t("provider.connect.oauth.auto.visit.suffix",{provider:$().name}),null),o(t,r(j,{get label(){return n.t("provider.connect.oauth.auto.confirmationCode")},class:"font-mono",get value(){return e()},readOnly:!0,copyable:!0}),c),o(c,r(Z,{}),a),o(a,()=>n.t("provider.connect.status.waiting")),t})()}return r(De,{get title(){return r(Ie,{tabIndex:-1,icon:"arrow-left",variant:"ghost",onClick:le,get"aria-label"(){return n.t("common.goBack")}})},get children(){var e=Re(),t=e.firstChild,i=t.firstChild,c=t.nextSibling,a=c.firstChild;return o(t,r(Le,{get id(){return h.provider},class:"size-5 shrink-0 icon-strong-base"}),i),o(i,r(L,{get children(){return[r(m,{get when(){return Y(()=>h.provider==="anthropic")()&&z()?.label?.toLowerCase().includes("max")},get children(){return n.t("provider.connect.title.anthropicProMax")}}),r(m,{when:!0,get children(){return n.t("provider.connect.title",{provider:$().name})}})]}})),a.$$keydown=ae,o(a,r(L,{get children(){return[r(m,{get when(){return Q()},get children(){var s=H(),u=s.firstChild,v=u.firstChild;return o(u,r(Z,{}),v),o(v,()=>n.t("provider.connect.status.inProgress")),s}}),r(m,{get when(){return d.methodIndex===void 0},get children(){return r(se,{})}}),r(m,{get when(){return d.state==="pending"},get children(){var s=H(),u=s.firstChild,v=u.firstChild;return o(u,r(Z,{}),v),o(v,()=>n.t("provider.connect.status.inProgress")),s}}),r(m,{get when(){return d.state==="prompt"},get children(){return r(oe,{})}}),r(m,{get when(){return d.state==="error"},get children(){var s=H(),u=s.firstChild,v=u.firstChild;return o(u,r(Se,{name:"circle-ban-sign",class:"text-icon-critical-base"}),v),o(v,()=>n.t("provider.connect.status.failed",{error:d.error??""})),s}}),r(m,{get when(){return z()?.type==="api"},get children(){return r(ce,{})}}),r(m,{get when(){return z()?.type==="oauth"},get children(){return r(L,{get children(){return[r(m,{get when(){return d.authorization?.method==="code"},get children(){return r(ue,{})}}),r(m,{get when(){return d.authorization?.method==="auto"},get children(){return r(de,{})}})]}})}})]}})),Ce(()=>a.autofocus=d.methodIndex===void 0?!0:void 0),e}})}re(["keydown"]);const Qe=Object.freeze(Object.defineProperty({__proto__:null,DialogConnectProvider:Ge},Symbol.toStringTag,{value:"Module"}));export{Ge as D,G as L,Qe as d};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dialog-select-provider-DNa_XLNK.js","assets/index-D-WWa_X8.js","assets/index-jvk-T241.css","assets/list-Dk_vU1zd.js","assets/provider-icon-CbXUEYMU.js"])))=>i.map(i=>d[i]);
2
+ import{b as ve,s as he,w as me,x as fe,i as o,t as x,aB as re,c as ge,u as xe,bv as ye,f as be,aF as _e,q as we,g as _,ay as $e,n as F,o as ke,h as r,S as L,M as m,m as Y,ah as Z,I as Se,j as Ce,a5 as Ie,aV as De,bz as j,B as R,v as ze,bx as Pe,al as Ee,a7 as Ke}from"./index-D-WWa_X8.js";import{L as ee}from"./list-Dk_vU1zd.js";import{P as Le}from"./provider-icon-CbXUEYMU.js";var Te=x("<a>");function G(h){const T=ve(),[b,S]=he(h,["href","children","class"]);return(()=>{var n=Te();return n.$$click=O=>{b.href&&(O.preventDefault(),T.openLink(b.href))},me(n,fe({get href(){return b.href},get class(){return`text-text-strong underline ${b.class??""}`}},S),!1,!0),o(n,()=>b.children),n})()}re(["click"]);var Me=x('<div class="w-full flex flex-col gap-1.5"><div class="text-14-regular text-text-base"></div><div>'),Fe=x('<form class="flex flex-col items-start gap-4">'),je=x('<div class="w-full flex items-center gap-x-2"><div class="w-4 h-2 rounded-[1px] bg-input-base shadow-xs-border-base flex items-center justify-center"><div class="w-2.5 h-0.5 ml-0 bg-icon-strong-base hidden"data-slot=list-item-extra-icon></div></div><span></span><span class="text-14-regular text-text-weak">'),te=x('<div class="text-14-regular text-text-base">'),Oe=x("<div>"),Ae=x('<div class="w-full flex items-center gap-x-2"><div class="w-4 h-2 rounded-[1px] bg-input-base shadow-xs-border-base flex items-center justify-center"><div class="w-2.5 h-0.5 ml-0 bg-icon-strong-base hidden"data-slot=list-item-extra-icon></div></div><span>'),Ve=x('<div class="flex flex-col gap-4"><div class="text-14-regular text-text-base"></div><div class="text-14-regular text-text-base"></div><div class="text-14-regular text-text-base">'),qe=x('<div class="flex flex-col gap-6"><form class="flex flex-col items-start gap-4">'),Be=x('<div class="flex flex-col gap-6"><div class="text-14-regular text-text-base"></div><form class="flex flex-col items-start gap-4">'),Ze=x('<div class="flex flex-col gap-6"><div class="text-14-regular text-text-base"></div><div class="text-14-regular text-text-base flex items-center gap-4"><span>'),H=x('<div class="text-14-regular text-text-base"><div class="flex items-center gap-x-2"><span>'),Re=x('<div class="flex flex-col gap-6 px-2.5 pb-3"><div class="px-2.5 flex gap-4 items-center"><div class="text-16-medium text-text-strong"></div></div><div class="px-2.5 pb-10 flex flex-col gap-6"><div tabindex=0>');function Ge(h){const T=ge(),b=xe(),S=ye(),n=be(),O=_e(),J=()=>{Ke(()=>import("./dialog-select-provider-DNa_XLNK.js").then(e=>e.d),__vite__mapDeps([0,1,2,3,4])).then(e=>{T.show(()=>r(e.DialogSelectProvider,{}))})},C={value:!0},w={current:void 0};we(()=>{C.value=!1,w.current!==void 0&&(clearTimeout(w.current),w.current=void 0)});const $=_(()=>O.all().find(e=>e.id===h.provider)??b.data.provider.all.find(e=>e.id===h.provider)),A=_(()=>[{type:"api",label:n.t("provider.connect.method.apiKey")}]),[N]=$e(()=>h.provider,async()=>{const e=b.data.provider_auth[h.provider];if(e)return e;const t=await S.client.provider.auth();return C.value?(b.set("provider_auth",t.data??{}),t.data?.[h.provider]??A()):A()}),Q=_(()=>N.loading&&!b.data.provider_auth[h.provider]),D=_(()=>N.latest??b.data.provider_auth[h.provider]??A()),[d,ne]=F({methodIndex:void 0,authorization:void 0,state:"pending",error:void 0});function k(e){ne(Pe(t=>{if(e.type==="method.select"){t.methodIndex=e.index,t.authorization=void 0,t.state=void 0,t.error=void 0;return}if(e.type==="method.reset"){t.methodIndex=void 0,t.authorization=void 0,t.state=void 0,t.error=void 0;return}if(e.type==="auth.prompt"){t.state="prompt",t.error=void 0;return}if(e.type==="auth.pending"){t.state="pending",t.error=void 0;return}if(e.type==="auth.complete"){t.state="complete",t.authorization=e.authorization,t.error=void 0;return}t.state="error",t.error=e.error}))}const z=_(()=>d.methodIndex!==void 0?D().at(d.methodIndex):void 0),ie=e=>e?e.type==="api"?n.t("provider.connect.method.apiKey"):e.label??"":"";function M(e,t){if(e&&typeof e=="object"&&"data"in e){const i=e.data;if(typeof i?.message=="string"&&i.message)return i.message}if(e&&typeof e=="object"&&"error"in e){const i=M(e.error,"");if(i)return i}if(e&&typeof e=="object"&&"message"in e){const i=e.message;if(typeof i=="string"&&i)return i}return e instanceof Error&&e.message?e.message:typeof e=="string"&&e?e:t}async function V(e,t){w.current!==void 0&&(clearTimeout(w.current),w.current=void 0);const i=D()[e];if(k({type:"method.select",index:e}),i.type==="oauth"){if(i.prompts?.length&&!t){k({type:"auth.prompt"});return}k({type:"auth.pending"});const c=Date.now();await S.client.provider.oauth.authorize({providerID:h.provider,method:e,inputs:t},{throwOnError:!0}).then(a=>{if(!C.value)return;const u=1e3-(Date.now()-c);if(u>0){w.current!==void 0&&clearTimeout(w.current),w.current=setTimeout(()=>{w.current=void 0,C.value&&k({type:"auth.complete",authorization:a.data})},u);return}k({type:"auth.complete",authorization:a.data})}).catch(a=>{C.value&&k({type:"auth.error",error:M(a,n.t("common.requestFailed"))})})}}function oe(){const[e,t]=F({value:{},index:0}),i=_(()=>{const l=z();return l?.type!=="oauth"?[]:l.prompts??[]}),c=(l,p)=>{if(!l.when)return!0;const g=p[l.when.key];return g===void 0?!1:l.when.op==="eq"?g===l.when.value:g!==l.when.value},a=_(()=>{const l=i(),p=l.findIndex((g,K)=>K>=e.index&&c(g,e.value));if(p!==-1)return{index:p,prompt:l[p]}}),s=_(()=>{const l=a();return!l||l.prompt.type!=="text"?!1:(e.value[l.prompt.key]??"").trim().length>0});async function u(l,p){if(d.methodIndex===void 0)return;const g=i().findIndex((K,y)=>y>l&&c(K,p));if(g!==-1){t("index",g);return}await V(d.methodIndex,p)}async function v(l){l.preventDefault();const p=a();!p||p.prompt.type!=="text"||s()&&await u(p.index,e.value)}const f=()=>a(),P=_(()=>{const l=f()?.prompt;if(!(!l||l.type!=="text"))return l}),E=_(()=>{const l=f()?.prompt;if(!(!l||l.type!=="select"))return l});return(()=>{var l=Fe();return l.addEventListener("submit",v),o(l,r(L,{get children(){return[r(m,{get when(){return f()?.prompt.type==="text"},get children(){return[r(j,{type:"text",get label(){return P()?.message??""},get placeholder(){return P()?.placeholder},get value(){return Y(()=>!!P())()?e.value[P().key]??"":""},onChange:p=>{const g=P();g&&t("value",g.key,p)}}),r(R,{class:"w-auto",type:"submit",size:"large",variant:"primary",get disabled(){return!s()},get children(){return n.t("common.continue")}})]}}),r(m,{get when(){return f()?.prompt.type==="select"},get children(){var p=Me(),g=p.firstChild,K=g.nextSibling;return o(g,()=>E()?.message),o(K,r(ee,{get items(){return E()?.options??[]},key:y=>y.value,get current(){return E()?.options.find(y=>y.value===e.value[E().key])},onSelect:y=>{if(!y)return;const I=E();if(!I)return;const B={...e.value,[I.key]:y.value};t("value",I.key,y.value),u(f().index,B)},children:y=>(()=>{var I=je(),B=I.firstChild,X=B.nextSibling,pe=X.nextSibling;return o(X,()=>y.label),o(pe,()=>y.hint),I})()})),p}})]}})),l})()}let U;function ae(e){e.key==="Enter"&&e.target instanceof HTMLInputElement||e.key!=="Escape"&&U?.onKeyDown(e)}let W=!1;ke(()=>{W||Q()||D().length===1&&(W=!0,V(0))});async function q(){await S.client.global.dispose(),T.close(),Ee({variant:"success",icon:"circle-check",title:n.t("provider.connect.toast.connected.title",{provider:$().name}),description:n.t("provider.connect.toast.connected.description",{provider:$().name})})}function le(){if(D().length===1){J();return}if(d.authorization){k({type:"method.reset"});return}if(d.methodIndex!==void 0){k({type:"method.reset"});return}J()}function se(){return[(()=>{var e=te();return o(e,()=>n.t("provider.connect.selectMethod",{provider:$().name})),e})(),(()=>{var e=Oe();return o(e,r(ee,{ref:t=>{U=t},items:D,key:t=>t?.label,onSelect:async(t,i)=>{t&&V(i)},children:t=>(()=>{var i=Ae(),c=i.firstChild,a=c.nextSibling;return o(a,()=>ie(t)),i})()})),e})()]}function ce(){const[e,t]=F({value:"",error:void 0});async function i(c){c.preventDefault();const a=c.currentTarget,u=new FormData(a).get("apiKey");if(!u?.trim()){t("error",n.t("provider.connect.apiKey.required"));return}t("error",void 0),await S.client.auth.set({providerID:h.provider,auth:{type:"api",key:u}}),await q()}return(()=>{var c=qe(),a=c.firstChild;return o(c,r(L,{get children(){return[r(m,{get when(){return $().id==="duckmind"},get children(){var s=Ve(),u=s.firstChild,v=u.nextSibling,f=v.nextSibling;return o(u,()=>n.t("provider.connect.duckmindZen.line1")),o(v,()=>n.t("provider.connect.duckmindZen.line2")),o(f,()=>n.t("provider.connect.duckmindZen.visit.prefix"),null),o(f,r(G,{href:"https://duckmind.ai/zen",tabIndex:-1,get children(){return n.t("provider.connect.duckmindZen.visit.link")}}),null),o(f,()=>n.t("provider.connect.duckmindZen.visit.suffix"),null),s}}),r(m,{when:!0,get children(){var s=te();return o(s,()=>n.t("provider.connect.apiKey.description",{provider:$().name})),s}})]}}),a),a.addEventListener("submit",i),o(a,r(j,{autofocus:!0,type:"text",get label(){return n.t("provider.connect.apiKey.label",{provider:$().name})},get placeholder(){return n.t("provider.connect.apiKey.placeholder")},name:"apiKey",get value(){return e.value},onChange:s=>t("value",s),get validationState(){return e.error?"invalid":void 0},get error(){return e.error}}),null),o(a,r(R,{class:"w-auto",type:"submit",size:"large",variant:"primary",get children(){return n.t("common.continue")}}),null),c})()}function ue(){const[e,t]=F({value:"",error:void 0});async function i(c){c.preventDefault();const a=c.currentTarget,u=new FormData(a).get("code");if(!u?.trim()){t("error",n.t("provider.connect.oauth.code.required"));return}t("error",void 0);const v=await S.client.provider.oauth.callback({providerID:h.provider,method:d.methodIndex,code:u}).then(f=>f.error?{ok:!1,error:f.error}:{ok:!0}).catch(f=>({ok:!1,error:f}));if(v.ok){await q();return}t("error",M(v.error,n.t("provider.connect.oauth.code.invalid")))}return(()=>{var c=Be(),a=c.firstChild,s=a.nextSibling;return o(a,()=>n.t("provider.connect.oauth.code.visit.prefix"),null),o(a,r(G,{get href(){return d.authorization.url},get children(){return n.t("provider.connect.oauth.code.visit.link")}}),null),o(a,()=>n.t("provider.connect.oauth.code.visit.suffix",{provider:$().name}),null),s.addEventListener("submit",i),o(s,r(j,{autofocus:!0,type:"text",get label(){return n.t("provider.connect.oauth.code.label",{method:z()?.label??""})},get placeholder(){return n.t("provider.connect.oauth.code.placeholder")},name:"code",get value(){return e.value},onChange:u=>t("value",u),get validationState(){return e.error?"invalid":void 0},get error(){return e.error}}),null),o(s,r(R,{class:"w-auto",type:"submit",size:"large",variant:"primary",get children(){return n.t("common.continue")}}),null),c})()}function de(){const e=_(()=>{const t=d.authorization?.instructions;return t?.includes(":")?t.split(":")[1]?.trim():t});return ze(()=>{(async()=>{const t=await S.client.provider.oauth.callback({providerID:h.provider,method:d.methodIndex}).then(i=>i.error?{ok:!1,error:i.error}:{ok:!0}).catch(i=>({ok:!1,error:i}));if(C.value){if(!t.ok){const i=M(t.error,n.t("common.requestFailed"));k({type:"auth.error",error:i});return}await q()}})()}),(()=>{var t=Ze(),i=t.firstChild,c=i.nextSibling,a=c.firstChild;return o(i,()=>n.t("provider.connect.oauth.auto.visit.prefix"),null),o(i,r(G,{get href(){return d.authorization.url},get children(){return n.t("provider.connect.oauth.auto.visit.link")}}),null),o(i,()=>n.t("provider.connect.oauth.auto.visit.suffix",{provider:$().name}),null),o(t,r(j,{get label(){return n.t("provider.connect.oauth.auto.confirmationCode")},class:"font-mono",get value(){return e()},readOnly:!0,copyable:!0}),c),o(c,r(Z,{}),a),o(a,()=>n.t("provider.connect.status.waiting")),t})()}return r(De,{get title(){return r(Ie,{tabIndex:-1,icon:"arrow-left",variant:"ghost",onClick:le,get"aria-label"(){return n.t("common.goBack")}})},get children(){var e=Re(),t=e.firstChild,i=t.firstChild,c=t.nextSibling,a=c.firstChild;return o(t,r(Le,{get id(){return h.provider},class:"size-5 shrink-0 icon-strong-base"}),i),o(i,r(L,{get children(){return[r(m,{get when(){return Y(()=>h.provider==="anthropic")()&&z()?.label?.toLowerCase().includes("max")},get children(){return n.t("provider.connect.title.anthropicProMax")}}),r(m,{when:!0,get children(){return n.t("provider.connect.title",{provider:$().name})}})]}})),a.$$keydown=ae,o(a,r(L,{get children(){return[r(m,{get when(){return Q()},get children(){var s=H(),u=s.firstChild,v=u.firstChild;return o(u,r(Z,{}),v),o(v,()=>n.t("provider.connect.status.inProgress")),s}}),r(m,{get when(){return d.methodIndex===void 0},get children(){return r(se,{})}}),r(m,{get when(){return d.state==="pending"},get children(){var s=H(),u=s.firstChild,v=u.firstChild;return o(u,r(Z,{}),v),o(v,()=>n.t("provider.connect.status.inProgress")),s}}),r(m,{get when(){return d.state==="prompt"},get children(){return r(oe,{})}}),r(m,{get when(){return d.state==="error"},get children(){var s=H(),u=s.firstChild,v=u.firstChild;return o(u,r(Se,{name:"circle-ban-sign",class:"text-icon-critical-base"}),v),o(v,()=>n.t("provider.connect.status.failed",{error:d.error??""})),s}}),r(m,{get when(){return z()?.type==="api"},get children(){return r(ce,{})}}),r(m,{get when(){return z()?.type==="oauth"},get children(){return r(L,{get children(){return[r(m,{get when(){return d.authorization?.method==="code"},get children(){return r(ue,{})}}),r(m,{get when(){return d.authorization?.method==="auto"},get children(){return r(de,{})}})]}})}})]}})),Ce(()=>a.autofocus=d.methodIndex===void 0?!0:void 0),e}})}re(["keydown"]);const Qe=Object.freeze(Object.defineProperty({__proto__:null,DialogConnectProvider:Ge},Symbol.toStringTag,{value:"Module"}));export{Ge as D,G as L,Qe as d};
@@ -1 +1 @@
1
- import{c as te,bv as re,u as ae,f as oe,g as A,ad as ie,n as ne,b2 as le,h as l,i as o,bz as F,$ as I,j as _,aD as j,cB as P,x as R,cC as B,I as K,aA as se,F as ce,k as M,B as T,m as de,aV as ue,t as p,aB as ve}from"./index-Bj2ueAL8.js";var ge=p('<img class="size-full object-cover">'),fe=p('<div class="flex flex-col gap-2"><label class="text-12-medium text-text-weak"></label><div class="flex gap-1.5">'),me=p('<form class="flex flex-col gap-6 p-6 pt-0"><div class="flex flex-col gap-4"><div class="flex flex-col gap-2"><label class="text-12-medium text-text-weak"></label><div class="flex gap-3 items-start"><div class=relative><div class="relative size-16 rounded-md transition-colors cursor-pointer"></div><div class="absolute inset-0 size-16 bg-surface-raised-stronger-non-alpha/90 rounded-[6px] z-10 pointer-events-none flex items-center justify-center transition-opacity"></div><div class="absolute inset-0 size-16 bg-surface-raised-stronger-non-alpha/90 rounded-[6px] z-10 pointer-events-none flex items-center justify-center transition-opacity"></div></div><input id=icon-upload type=file accept=image/* class=hidden><div class="flex flex-col gap-1.5 text-12-regular text-text-weak self-center"><span></span><span></span></div></div></div></div><div class="flex justify-end gap-2">'),pe=p('<div class="size-full flex items-center justify-center">'),be=p("<button type=button>");const xe=["pink","mint","orange","purple","cyan","lime"];function je(s){const w=te(),G=re(),L=ae(),i=oe(),y=A(()=>ie(s.project.worktree)),k=A(()=>s.project.name||y()),[e,c]=ne({name:k(),color:s.project.icon?.color||"pink",iconUrl:s.project.icon?.override||"",startup:s.project.commands?.start??"",dragOver:!1,iconHover:!1});let U;function z(r){if(!r.type.startsWith("image/"))return;const a=new FileReader;a.onload=g=>{c("iconUrl",g.target?.result),c("iconHover",!1)},a.readAsDataURL(r)}function N(r){r.preventDefault(),c("dragOver",!1);const a=r.dataTransfer?.files[0];a&&z(a)}function V(r){r.preventDefault(),c("dragOver",!0)}function W(){c("dragOver",!1)}function Y(r){const g=r.target.files?.[0];g&&z(g)}function q(){c("iconUrl","")}const b=le(()=>({mutationFn:async()=>{const r=e.name.trim()===y()?"":e.name.trim(),a=e.startup.trim();if(s.project.id&&s.project.id!=="global"){await G.client.project.update({projectID:s.project.id,directory:s.project.worktree,name:r,icon:{color:e.color,override:e.iconUrl},commands:{start:a}}),L.project.icon(s.project.worktree,e.iconUrl||void 0),w.close();return}L.project.meta(s.project.worktree,{name:r,icon:{color:e.color,override:e.iconUrl||void 0},commands:{start:a||void 0}}),w.close()}}));function J(r){r.preventDefault(),!b.isPending&&b.mutate()}return l(ue,{get title(){return i.t("dialog.project.edit.title")},class:"w-full max-w-[480px] mx-auto",get children(){var r=me(),a=r.firstChild,g=a.firstChild,C=g.firstChild,Q=C.nextSibling,x=Q.firstChild,f=x.firstChild,h=f.nextSibling,$=h.nextSibling,S=x.nextSibling,X=S.nextSibling,D=X.firstChild,Z=D.nextSibling,E=a.nextSibling;return r.addEventListener("submit",J),o(a,l(F,{autofocus:!0,type:"text",get label(){return i.t("dialog.project.edit.name")},get placeholder(){return y()},get value(){return e.name},onChange:t=>c("name",t)}),g),o(C,()=>i.t("dialog.project.edit.icon")),x.addEventListener("mouseleave",()=>c("iconHover",!1)),x.addEventListener("mouseenter",()=>c("iconHover",!0)),f.$$click=()=>{e.iconUrl&&e.iconHover?q():U?.click()},f.addEventListener("dragleave",W),f.addEventListener("dragover",V),f.addEventListener("drop",N),o(f,l(I,{get when(){return e.iconUrl},get fallback(){return(()=>{var t=pe();return o(t,l(P,R({get fallback(){return e.name||k()}},()=>B(e.color),{class:"size-full text-[32px]"}))),t})()},get children(){var t=ge();return _(d=>{var m=e.iconUrl,n=i.t("dialog.project.edit.icon.alt");return m!==d.e&&j(t,"src",d.e=m),n!==d.t&&j(t,"alt",d.t=n),d},{e:void 0,t:void 0}),t}})),o(h,l(K,{name:"cloud-upload",size:"large",class:"text-icon-on-interactive-base drop-shadow-sm"})),o($,l(K,{name:"trash",size:"large",class:"text-icon-on-interactive-base drop-shadow-sm"})),S.addEventListener("change",Y),se(t=>{U=t},S),o(D,()=>i.t("dialog.project.edit.icon.hint")),o(Z,()=>i.t("dialog.project.edit.icon.recommended")),o(a,l(I,{get when(){return!e.iconUrl},get children(){var t=fe(),d=t.firstChild,m=d.nextSibling;return o(d,()=>i.t("dialog.project.edit.color")),o(m,l(ce,{each:xe,children:n=>(()=>{var v=be();return v.$$click=()=>c("color",n),o(v,l(P,R({get fallback(){return e.name||k()}},()=>B(n),{class:"size-full rounded"}))),_(u=>{var H=i.t("dialog.project.edit.color.select",{color:n}),O=e.color===n,ee={"flex items-center justify-center size-10 p-0.5 rounded-lg overflow-hidden transition-colors cursor-default":!0,"bg-transparent border-2 border-icon-strong-base hover:bg-surface-base-hover":e.color===n,"bg-transparent border border-transparent hover:bg-surface-base-hover hover:border-border-weak-base":e.color!==n};return H!==u.e&&j(v,"aria-label",u.e=H),O!==u.t&&j(v,"aria-pressed",u.t=O),u.a=M(v,ee,u.a),u},{e:void 0,t:void 0,a:void 0}),v})()})),t}}),null),o(a,l(F,{multiline:!0,get label(){return i.t("dialog.project.edit.worktree.startup")},get description(){return i.t("dialog.project.edit.worktree.startup.description")},get placeholder(){return i.t("dialog.project.edit.worktree.startup.placeholder")},get value(){return e.startup},onChange:t=>c("startup",t),spellcheck:!1,class:"max-h-14 w-full overflow-y-auto font-mono text-xs"}),null),o(E,l(T,{type:"button",variant:"ghost",size:"large",onClick:()=>w.close(),get children(){return i.t("common.cancel")}}),null),o(E,l(T,{type:"submit",variant:"primary",size:"large",get disabled(){return b.isPending},get children(){return de(()=>!!b.isPending)()?i.t("common.saving"):i.t("common.save")}}),null),_(t=>{var d={"border-text-interactive-base bg-surface-info-base/20":e.dragOver,"border-border-base hover:border-border-strong":!e.dragOver,"overflow-hidden":!!e.iconUrl},m=!!(e.iconHover&&!e.iconUrl),n=!(e.iconHover&&!e.iconUrl),v=!!(e.iconHover&&e.iconUrl),u=!(e.iconHover&&e.iconUrl);return t.e=M(f,d,t.e),m!==t.t&&h.classList.toggle("opacity-100",t.t=m),n!==t.a&&h.classList.toggle("opacity-0",t.a=n),v!==t.o&&$.classList.toggle("opacity-100",t.o=v),u!==t.i&&$.classList.toggle("opacity-0",t.i=u),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r}})}ve(["click"]);export{je as DialogEditProject};
1
+ import{c as te,bv as re,u as ae,f as oe,g as A,ad as ie,n as ne,b2 as le,h as l,i as o,bz as F,$ as I,j as _,aD as j,cB as P,x as R,cC as B,I as K,aA as se,F as ce,k as M,B as T,m as de,aV as ue,t as p,aB as ve}from"./index-D-WWa_X8.js";var ge=p('<img class="size-full object-cover">'),fe=p('<div class="flex flex-col gap-2"><label class="text-12-medium text-text-weak"></label><div class="flex gap-1.5">'),me=p('<form class="flex flex-col gap-6 p-6 pt-0"><div class="flex flex-col gap-4"><div class="flex flex-col gap-2"><label class="text-12-medium text-text-weak"></label><div class="flex gap-3 items-start"><div class=relative><div class="relative size-16 rounded-md transition-colors cursor-pointer"></div><div class="absolute inset-0 size-16 bg-surface-raised-stronger-non-alpha/90 rounded-[6px] z-10 pointer-events-none flex items-center justify-center transition-opacity"></div><div class="absolute inset-0 size-16 bg-surface-raised-stronger-non-alpha/90 rounded-[6px] z-10 pointer-events-none flex items-center justify-center transition-opacity"></div></div><input id=icon-upload type=file accept=image/* class=hidden><div class="flex flex-col gap-1.5 text-12-regular text-text-weak self-center"><span></span><span></span></div></div></div></div><div class="flex justify-end gap-2">'),pe=p('<div class="size-full flex items-center justify-center">'),be=p("<button type=button>");const xe=["pink","mint","orange","purple","cyan","lime"];function je(s){const w=te(),G=re(),L=ae(),i=oe(),y=A(()=>ie(s.project.worktree)),k=A(()=>s.project.name||y()),[e,c]=ne({name:k(),color:s.project.icon?.color||"pink",iconUrl:s.project.icon?.override||"",startup:s.project.commands?.start??"",dragOver:!1,iconHover:!1});let U;function z(r){if(!r.type.startsWith("image/"))return;const a=new FileReader;a.onload=g=>{c("iconUrl",g.target?.result),c("iconHover",!1)},a.readAsDataURL(r)}function N(r){r.preventDefault(),c("dragOver",!1);const a=r.dataTransfer?.files[0];a&&z(a)}function V(r){r.preventDefault(),c("dragOver",!0)}function W(){c("dragOver",!1)}function Y(r){const g=r.target.files?.[0];g&&z(g)}function q(){c("iconUrl","")}const b=le(()=>({mutationFn:async()=>{const r=e.name.trim()===y()?"":e.name.trim(),a=e.startup.trim();if(s.project.id&&s.project.id!=="global"){await G.client.project.update({projectID:s.project.id,directory:s.project.worktree,name:r,icon:{color:e.color,override:e.iconUrl},commands:{start:a}}),L.project.icon(s.project.worktree,e.iconUrl||void 0),w.close();return}L.project.meta(s.project.worktree,{name:r,icon:{color:e.color,override:e.iconUrl||void 0},commands:{start:a||void 0}}),w.close()}}));function J(r){r.preventDefault(),!b.isPending&&b.mutate()}return l(ue,{get title(){return i.t("dialog.project.edit.title")},class:"w-full max-w-[480px] mx-auto",get children(){var r=me(),a=r.firstChild,g=a.firstChild,C=g.firstChild,Q=C.nextSibling,x=Q.firstChild,f=x.firstChild,h=f.nextSibling,$=h.nextSibling,S=x.nextSibling,X=S.nextSibling,D=X.firstChild,Z=D.nextSibling,E=a.nextSibling;return r.addEventListener("submit",J),o(a,l(F,{autofocus:!0,type:"text",get label(){return i.t("dialog.project.edit.name")},get placeholder(){return y()},get value(){return e.name},onChange:t=>c("name",t)}),g),o(C,()=>i.t("dialog.project.edit.icon")),x.addEventListener("mouseleave",()=>c("iconHover",!1)),x.addEventListener("mouseenter",()=>c("iconHover",!0)),f.$$click=()=>{e.iconUrl&&e.iconHover?q():U?.click()},f.addEventListener("dragleave",W),f.addEventListener("dragover",V),f.addEventListener("drop",N),o(f,l(I,{get when(){return e.iconUrl},get fallback(){return(()=>{var t=pe();return o(t,l(P,R({get fallback(){return e.name||k()}},()=>B(e.color),{class:"size-full text-[32px]"}))),t})()},get children(){var t=ge();return _(d=>{var m=e.iconUrl,n=i.t("dialog.project.edit.icon.alt");return m!==d.e&&j(t,"src",d.e=m),n!==d.t&&j(t,"alt",d.t=n),d},{e:void 0,t:void 0}),t}})),o(h,l(K,{name:"cloud-upload",size:"large",class:"text-icon-on-interactive-base drop-shadow-sm"})),o($,l(K,{name:"trash",size:"large",class:"text-icon-on-interactive-base drop-shadow-sm"})),S.addEventListener("change",Y),se(t=>{U=t},S),o(D,()=>i.t("dialog.project.edit.icon.hint")),o(Z,()=>i.t("dialog.project.edit.icon.recommended")),o(a,l(I,{get when(){return!e.iconUrl},get children(){var t=fe(),d=t.firstChild,m=d.nextSibling;return o(d,()=>i.t("dialog.project.edit.color")),o(m,l(ce,{each:xe,children:n=>(()=>{var v=be();return v.$$click=()=>c("color",n),o(v,l(P,R({get fallback(){return e.name||k()}},()=>B(n),{class:"size-full rounded"}))),_(u=>{var H=i.t("dialog.project.edit.color.select",{color:n}),O=e.color===n,ee={"flex items-center justify-center size-10 p-0.5 rounded-lg overflow-hidden transition-colors cursor-default":!0,"bg-transparent border-2 border-icon-strong-base hover:bg-surface-base-hover":e.color===n,"bg-transparent border border-transparent hover:bg-surface-base-hover hover:border-border-weak-base":e.color!==n};return H!==u.e&&j(v,"aria-label",u.e=H),O!==u.t&&j(v,"aria-pressed",u.t=O),u.a=M(v,ee,u.a),u},{e:void 0,t:void 0,a:void 0}),v})()})),t}}),null),o(a,l(F,{multiline:!0,get label(){return i.t("dialog.project.edit.worktree.startup")},get description(){return i.t("dialog.project.edit.worktree.startup.description")},get placeholder(){return i.t("dialog.project.edit.worktree.startup.placeholder")},get value(){return e.startup},onChange:t=>c("startup",t),spellcheck:!1,class:"max-h-14 w-full overflow-y-auto font-mono text-xs"}),null),o(E,l(T,{type:"button",variant:"ghost",size:"large",onClick:()=>w.close(),get children(){return i.t("common.cancel")}}),null),o(E,l(T,{type:"submit",variant:"primary",size:"large",get disabled(){return b.isPending},get children(){return de(()=>!!b.isPending)()?i.t("common.saving"):i.t("common.save")}}),null),_(t=>{var d={"border-text-interactive-base bg-surface-info-base/20":e.dragOver,"border-border-base hover:border-border-strong":!e.dragOver,"overflow-hidden":!!e.iconUrl},m=!!(e.iconHover&&!e.iconUrl),n=!(e.iconHover&&!e.iconUrl),v=!!(e.iconHover&&e.iconUrl),u=!(e.iconHover&&e.iconUrl);return t.e=M(f,d,t.e),m!==t.t&&h.classList.toggle("opacity-100",t.t=m),n!==t.a&&h.classList.toggle("opacity-0",t.a=n),v!==t.o&&$.classList.toggle("opacity-100",t.o=v),u!==t.i&&$.classList.toggle("opacity-0",t.i=u),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r}})}ve(["click"]);export{je as DialogEditProject};
@@ -1 +1 @@
1
- import{A as v,d as D,a8 as S,aK as k,aR as _,c as $,f as w,g as P,h as d,i as u,aV as F,l as L,al as p,t as I}from"./index-Bj2ueAL8.js";import{L as K}from"./list-FNV9nNTY.js";import{e as T}from"./session-Df_z3CAQ.js";import"./select-Df3XuuZj.js";import"./provider-icon-BO5C5h8K.js";import"./file-icon-vO6wN-HW.js";var b=I('<div class="w-full flex items-center gap-2"><span class="truncate flex-1 min-w-0 text-left font-normal"></span><span class="text-text-weak shrink-0 font-normal">');function q(i){return i.toLocaleTimeString(void 0,{timeStyle:"short"})}const V=()=>{const i=v(),g=D(),c=S(),l=k(),f=_(),h=$(),r=w(),x=P(()=>{const t=i.id;if(!t)return[];const a=c.data.message[t]??[],o=[];for(const s of a){if(s.role!=="user")continue;const e=(c.data.part[s.id]??[]).find(n=>n.type==="text"&&!n.synthetic&&!n.ignored);e&&o.push({id:s.id,text:e.text.replace(/\n/g," ").slice(0,200),time:q(new Date(s.time.created))})}return o.reverse()}),y=t=>{if(!t)return;const a=i.id;if(!a)return;const o=c.data.part[t.id]??[],s=T(o,{directory:l.directory,attachmentName:r.t("common.attachment")}),m=L(l.directory);l.client.session.fork({sessionID:a,messageID:t.id}).then(e=>{if(!e.data){p({title:r.t("common.requestFailed")});return}h.close(),f.set(s,void 0,{dir:m,id:e.data.id}),g(`/${m}/session/${e.data.id}`)}).catch(e=>{const n=e instanceof Error?e.message:String(e);p({title:r.t("common.requestFailed"),description:n})})};return d(F,{get title(){return r.t("command.session.fork")},get children(){return d(K,{class:"flex-1 min-h-0 [&_[data-slot=list-scroll]]:flex-1 [&_[data-slot=list-scroll]]:min-h-0",get search(){return{placeholder:r.t("common.search.placeholder"),autofocus:!0}},get emptyMessage(){return r.t("dialog.fork.empty")},key:t=>t.id,items:x,filterKeys:["text"],onSelect:y,children:t=>(()=>{var a=b(),o=a.firstChild,s=o.nextSibling;return u(o,()=>t.text),u(s,()=>t.time),a})()})}})};export{V as DialogFork};
1
+ import{A as v,d as D,a8 as S,aK as k,aR as _,c as $,f as w,g as P,h as d,i as u,aV as F,l as L,al as p,t as I}from"./index-D-WWa_X8.js";import{L as K}from"./list-Dk_vU1zd.js";import{e as T}from"./session-BmqyKO6_.js";import"./select-iTRCZro5.js";import"./provider-icon-CbXUEYMU.js";import"./file-icon-B_-1whMc.js";var b=I('<div class="w-full flex items-center gap-2"><span class="truncate flex-1 min-w-0 text-left font-normal"></span><span class="text-text-weak shrink-0 font-normal">');function q(i){return i.toLocaleTimeString(void 0,{timeStyle:"short"})}const V=()=>{const i=v(),g=D(),c=S(),l=k(),f=_(),h=$(),r=w(),x=P(()=>{const t=i.id;if(!t)return[];const a=c.data.message[t]??[],o=[];for(const s of a){if(s.role!=="user")continue;const e=(c.data.part[s.id]??[]).find(n=>n.type==="text"&&!n.synthetic&&!n.ignored);e&&o.push({id:s.id,text:e.text.replace(/\n/g," ").slice(0,200),time:q(new Date(s.time.created))})}return o.reverse()}),y=t=>{if(!t)return;const a=i.id;if(!a)return;const o=c.data.part[t.id]??[],s=T(o,{directory:l.directory,attachmentName:r.t("common.attachment")}),m=L(l.directory);l.client.session.fork({sessionID:a,messageID:t.id}).then(e=>{if(!e.data){p({title:r.t("common.requestFailed")});return}h.close(),f.set(s,void 0,{dir:m,id:e.data.id}),g(`/${m}/session/${e.data.id}`)}).catch(e=>{const n=e instanceof Error?e.message:String(e);p({title:r.t("common.requestFailed"),description:n})})};return d(F,{get title(){return r.t("command.session.fork")},get children(){return d(K,{class:"flex-1 min-h-0 [&_[data-slot=list-scroll]]:flex-1 [&_[data-slot=list-scroll]]:min-h-0",get search(){return{placeholder:r.t("common.search.placeholder"),autofocus:!0}},get emptyMessage(){return r.t("dialog.fork.empty")},key:t=>t.id,items:x,filterKeys:["text"],onSelect:y,children:t=>(()=>{var a=b(),o=a.firstChild,s=o.nextSibling;return u(o,()=>t.text),u(s,()=>t.time),a})()})}})};export{V as DialogFork};
@@ -1 +1 @@
1
- import{aP as y,f as b,c as D,h as o,i as n,aj as I,B as k,aV as $,t as g,aW as P,aB as C}from"./index-Bj2ueAL8.js";import{L as B}from"./list-FNV9nNTY.js";import{S as c}from"./switch-DyYMuMHL.js";import{a as L}from"./dialog-select-provider-CZw0JIcb.js";import"./provider-icon-BO5C5h8K.js";import"./dialog-connect-provider-DqlW9pvn.js";var V=g("<span>"),_=g('<div class="w-full flex items-center justify-between gap-x-3"><span></span><div>');const E=()=>{const t=y(),a=b(),u=D(),v=()=>{u.show(()=>o(L,{}))},s=e=>P.indexOf(e),m=e=>t.model.list().filter(r=>r.provider.id===e),h=e=>m(e).every(r=>t.model.visible({modelID:r.id,providerID:r.provider.id})),f=(e,r)=>{m(e).forEach(i=>{t.model.setVisibility({modelID:i.id,providerID:i.provider.id},r)})};return o($,{get title(){return a.t("dialog.model.manage")},get description(){return a.t("dialog.model.manage.description")},get action(){return o(k,{class:"h-7 -my-1 text-14-medium",icon:"plus-small",tabIndex:-1,onClick:v,get children(){return a.t("command.provider.connect")}})},get children(){return o(B,{get search(){return{placeholder:a.t("dialog.model.search.placeholder"),autofocus:!0}},get emptyMessage(){return a.t("dialog.model.empty")},key:e=>`${e?.provider?.id}:${e?.id}`,get items(){return t.model.list()},filterKeys:["provider.name","name","id"],sortBy:(e,r)=>e.name.localeCompare(r.name),groupBy:e=>e.provider.id,groupHeader:e=>{const r=e.items[0].provider;return[(()=>{var i=V();return n(i,()=>r.name),i})(),o(I,{placement:"top",get value(){return a.t("dialog.model.manage.provider.toggle",{provider:r.name})},get children(){return o(c,{class:"-mr-1",get checked(){return h(r.id)},onChange:i=>f(r.id,i),hideLabel:!0,get children(){return r.name}})}})]},sortGroupsBy:(e,r)=>{const i=s(e.items[0].provider.id),l=s(r.items[0].provider.id),d=i>=0,p=l>=0;return d&&!p?-1:!d&&p?1:i-l},onSelect:e=>{if(!e)return;const r={modelID:e.id,providerID:e.provider.id};t.model.setVisibility(r,!t.model.visible(r))},children:e=>(()=>{var r=_(),i=r.firstChild,l=i.nextSibling;return n(i,()=>e.name),l.$$click=d=>d.stopPropagation(),n(l,o(c,{get checked(){return!!t.model.visible({modelID:e.id,providerID:e.provider.id})},onChange:d=>{t.model.setVisibility({modelID:e.id,providerID:e.provider.id},d)}})),r})()})}})};C(["click"]);export{E as DialogManageModels};
1
+ import{aP as y,f as b,c as D,h as o,i as n,aj as I,B as k,aV as $,t as g,aW as P,aB as C}from"./index-D-WWa_X8.js";import{L as B}from"./list-Dk_vU1zd.js";import{S as c}from"./switch-CiVaw2SH.js";import{a as L}from"./dialog-select-provider-DNa_XLNK.js";import"./provider-icon-CbXUEYMU.js";import"./dialog-connect-provider-jjqkH3fb.js";var V=g("<span>"),_=g('<div class="w-full flex items-center justify-between gap-x-3"><span></span><div>');const E=()=>{const t=y(),a=b(),u=D(),v=()=>{u.show(()=>o(L,{}))},s=e=>P.indexOf(e),m=e=>t.model.list().filter(r=>r.provider.id===e),h=e=>m(e).every(r=>t.model.visible({modelID:r.id,providerID:r.provider.id})),f=(e,r)=>{m(e).forEach(i=>{t.model.setVisibility({modelID:i.id,providerID:i.provider.id},r)})};return o($,{get title(){return a.t("dialog.model.manage")},get description(){return a.t("dialog.model.manage.description")},get action(){return o(k,{class:"h-7 -my-1 text-14-medium",icon:"plus-small",tabIndex:-1,onClick:v,get children(){return a.t("command.provider.connect")}})},get children(){return o(B,{get search(){return{placeholder:a.t("dialog.model.search.placeholder"),autofocus:!0}},get emptyMessage(){return a.t("dialog.model.empty")},key:e=>`${e?.provider?.id}:${e?.id}`,get items(){return t.model.list()},filterKeys:["provider.name","name","id"],sortBy:(e,r)=>e.name.localeCompare(r.name),groupBy:e=>e.provider.id,groupHeader:e=>{const r=e.items[0].provider;return[(()=>{var i=V();return n(i,()=>r.name),i})(),o(I,{placement:"top",get value(){return a.t("dialog.model.manage.provider.toggle",{provider:r.name})},get children(){return o(c,{class:"-mr-1",get checked(){return h(r.id)},onChange:i=>f(r.id,i),hideLabel:!0,get children(){return r.name}})}})]},sortGroupsBy:(e,r)=>{const i=s(e.items[0].provider.id),l=s(r.items[0].provider.id),d=i>=0,p=l>=0;return d&&!p?-1:!d&&p?1:i-l},onSelect:e=>{if(!e)return;const r={modelID:e.id,providerID:e.provider.id};t.model.setVisibility(r,!t.model.visible(r))},children:e=>(()=>{var r=_(),i=r.firstChild,l=i.nextSibling;return n(i,()=>e.name),l.$$click=d=>d.stopPropagation(),n(l,o(c,{get checked(){return!!t.model.visible({modelID:e.id,providerID:e.provider.id})},onChange:d=>{t.model.setVisibility({modelID:e.id,providerID:e.provider.id},d)}})),r})()})}})};C(["click"]);export{E as DialogManageModels};
@@ -1,3 +1,3 @@
1
- import{u as V,bv as E,a as H,c as J,f as N,r as Q,g as A,ay as U,ad as j,h as z,i as P,aM as X,aV as Y,t as I}from"./index-Bj2ueAL8.js";import{F as R}from"./file-icon-vO6wN-HW.js";import{L as tt,f as et}from"./list-FNV9nNTY.js";var rt=I('<div class="w-full flex items-center justify-between rounded-md"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular min-w-0"><span class="text-text-strong whitespace-nowrap">~</span><span class="text-text-weak whitespace-nowrap">/'),nt=I('<div class="w-full flex items-center justify-between rounded-md"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular min-w-0"><span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0"></span><span class="text-text-strong whitespace-nowrap"></span><span class="text-text-weak whitespace-nowrap">/');function K(r){return((r??"").split(/\r?\n/)[0]??"").replace(/[\u0000-\u001F\u007F]/g,"").trim()}function st(r){const t=r.replaceAll("\\","/");return t.startsWith("//")&&!t.startsWith("///")?"//"+t.slice(2).replace(/\/+/g,"/"):t.replace(/\/+/g,"/")}function v(r){const t=st(r);return/^[A-Za-z]:$/.test(t)?t+"/":t}function d(r){const t=v(r);return t==="/"||t==="//"||/^[A-Za-z]:\/$/.test(t)?t:t.replace(/\/+$/,"")}function ot(r,t){const o=d(r??""),c=d(t).replace(/^\/+/,"");return o?c?o.endsWith("/")?o+c:o+"/"+c:o:c}function L(r){const t=v(r);return t.startsWith("//")?"//":t.startsWith("/")?"/":/^[A-Za-z]:\//.test(t)?t.slice(0,3):""}function at(r){const t=d(r);if(t==="/"||t==="//"||/^[A-Za-z]:\/$/.test(t))return t;const o=t.lastIndexOf("/");return o<=0?"/":o===2&&/^[A-Za-z]:/.test(t)?t.slice(0,3):t.slice(0,o)}function it(r){const t=v(r.trim());return t?t.startsWith("~")?"tilde":L(t)?"absolute":"relative":"relative"}function G(r,t){const o=d(r);if(!t)return"";const c=d(t),x=o.toLowerCase(),u=c.toLowerCase();return x===u?"~":x.startsWith(u+"/")?"~"+o.slice(c.length):""}function Z(r,t,o){const c=d(r);return it(t)==="absolute"?c:G(c,o)||c}function B(r,t,o){const c=d(r),x=G(c,t),u=l=>l?l.endsWith("/")?l:l+"/":"",y=Array.from(new Set([c,u(c),x,u(x),j(c)].filter(Boolean))).join(`
1
+ import{u as V,bv as E,a as H,c as J,f as N,r as Q,g as A,ay as U,ad as j,h as z,i as P,aM as X,aV as Y,t as I}from"./index-D-WWa_X8.js";import{F as R}from"./file-icon-B_-1whMc.js";import{L as tt,f as et}from"./list-Dk_vU1zd.js";var rt=I('<div class="w-full flex items-center justify-between rounded-md"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular min-w-0"><span class="text-text-strong whitespace-nowrap">~</span><span class="text-text-weak whitespace-nowrap">/'),nt=I('<div class="w-full flex items-center justify-between rounded-md"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular min-w-0"><span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0"></span><span class="text-text-strong whitespace-nowrap"></span><span class="text-text-weak whitespace-nowrap">/');function K(r){return((r??"").split(/\r?\n/)[0]??"").replace(/[\u0000-\u001F\u007F]/g,"").trim()}function st(r){const t=r.replaceAll("\\","/");return t.startsWith("//")&&!t.startsWith("///")?"//"+t.slice(2).replace(/\/+/g,"/"):t.replace(/\/+/g,"/")}function v(r){const t=st(r);return/^[A-Za-z]:$/.test(t)?t+"/":t}function d(r){const t=v(r);return t==="/"||t==="//"||/^[A-Za-z]:\/$/.test(t)?t:t.replace(/\/+$/,"")}function ot(r,t){const o=d(r??""),c=d(t).replace(/^\/+/,"");return o?c?o.endsWith("/")?o+c:o+"/"+c:o:c}function L(r){const t=v(r);return t.startsWith("//")?"//":t.startsWith("/")?"/":/^[A-Za-z]:\//.test(t)?t.slice(0,3):""}function at(r){const t=d(r);if(t==="/"||t==="//"||/^[A-Za-z]:\/$/.test(t))return t;const o=t.lastIndexOf("/");return o<=0?"/":o===2&&/^[A-Za-z]:/.test(t)?t.slice(0,3):t.slice(0,o)}function it(r){const t=v(r.trim());return t?t.startsWith("~")?"tilde":L(t)?"absolute":"relative":"relative"}function G(r,t){const o=d(r);if(!t)return"";const c=d(t),x=o.toLowerCase(),u=c.toLowerCase();return x===u?"~":x.startsWith(u+"/")?"~"+o.slice(c.length):""}function Z(r,t,o){const c=d(r);return it(t)==="absolute"?c:G(c,o)||c}function B(r,t,o){const c=d(r),x=G(c,t),u=l=>l?l.endsWith("/")?l:l+"/":"",y=Array.from(new Set([c,u(c),x,u(x),j(c)].filter(Boolean))).join(`
2
2
  `);return{absolute:c,search:y,group:o}}function ct(r){const t=new Set;return r.filter(o=>t.has(o.absolute)?!1:(t.add(o.absolute),!0))}function lt(r){const t=new Map;let o=0;const c=y=>{const l=r.start();if(!l)return;const a=v(y);if(!a)return{directory:d(l),path:""};const m=r.home();if(a==="~")return{directory:d(m||l),path:""};if(a.startsWith("~/"))return{directory:d(m||l),path:a.slice(2)};const i=L(a);return i?{directory:d(i),path:a.slice(i.length)}:{directory:d(l),path:a}},x=async y=>{const l=d(y),a=t.get(l);if(a)return a;const m=r.sdk.client.file.list({directory:l,path:""}).then(i=>i.data??[]).catch(()=>[]).then(i=>i.filter(f=>f.type==="directory").map(f=>({name:f.name,absolute:d(v(f.absolute))})));return t.set(l,m),m},u=async(y,l,a)=>{const m=await x(y);return l?et.go(l,m,{key:"name",limit:a}).map(i=>i.obj.absolute):m.slice(0,a).map(i=>i.absolute)};return async y=>{const l=++o,a=()=>l===o,m=K(y),i=c(m);if(!i)return[];const f=v(m),C=f.startsWith("~")||!!L(f)||f.includes("/"),S=v(i.path),_=()=>r.sdk.client.find.files({directory:i.directory,query:S,type:"directory",limit:50}).then(h=>h.data??[]).catch(()=>[]);if(!C){const h=await _();return a()?h.map(F=>ot(i.directory,F)).slice(0,50):[]}const k=S.replace(/^\/+/,"").split("/"),D=k.slice(0,k.length-1).filter(h=>h&&h!=="."),e=k[k.length-1]??"",p=12,n=4;let s=[i.directory];for(const h of D){if(!a())return[];if(h===".."){s=s.map(at);continue}const F=(await Promise.all(s.map(T=>u(T,h,n)))).flat();if(!a())return[];if(s=Array.from(new Set(F)).slice(0,p),s.length===0)return[]}const w=(await Promise.all(s.map(h=>u(h,e,50)))).flat();if(!a())return[];const g=Array.from(new Set(w)),b=f.startsWith("~")?d(i.directory):"";if(!!f.endsWith("/")||!e)return(b?Array.from(new Set([b,...g])):g).slice(0,50);const W=e.toLowerCase(),M=g.filter(h=>j(h).toLowerCase()===W)[0];if(!M)return g.slice(0,50);const q=await u(M,"",30);if(!a())return[];const O=Array.from(new Set([...g,...q]));return(b?Array.from(new Set([b,...O])):O).slice(0,50)}}function ht(r){const t=V(),o=E(),c=H(),x=J(),u=N(),[y,l]=Q("");let a;const m=A(()=>!(t.data.path.home||t.data.path.directory)),[i]=U(()=>m()?!0:void 0,async()=>o.client.path.get().then(e=>e.data).catch(()=>{}),{initialValue:void 0}),f=A(()=>t.data.path.home||i()?.home||""),C=A(()=>t.data.path.home||t.data.path.directory||i()?.home||i()?.directory),S=lt({sdk:o,home:f,start:C}),_=A(()=>{const e=c.projects.list(),p=new Map;for(const n of e){let s=0;const w=[n.worktree,...n.sandboxes??[]];for(const g of w){const b=t.child(g,{bootstrap:!1})[0].session;for(const $ of b){if($.time.archived)continue;const W=$.time.updated??$.time.created;W>s&&(s=W)}}p.set(n.worktree,s)}return e.map((n,s)=>({project:n,at:p.get(n.worktree)??0,index:s})).sort((n,s)=>s.at-n.at||n.index-s.index).slice(0,5).map(({project:n})=>{const s=B(n.worktree,f(),"recent"),w=n.name||j(n.worktree);return{...s,search:`${s.search}
3
3
  ${w}`}})}),k=async e=>{const n=(await S(e)).map(s=>B(s,f(),"folders"));return ct([..._(),...n])};function D(e){r.onSelect(r.multiple?[e]:e),x.close()}return z(Y,{get title(){return r.title??u.t("command.project.open")},get children(){return z(tt,{get search(){return{placeholder:u.t("dialog.directory.search.placeholder"),autofocus:!0}},get emptyMessage(){return u.t("dialog.directory.empty")},get loadingMessage(){return u.t("common.loading")},items:k,key:e=>e.absolute,filterKeys:["search"],groupBy:e=>e.group,sortGroupsBy:(e,p)=>e.category===p.category?0:e.category==="recent"?-1:1,groupHeader:e=>e.category==="recent"?u.t("home.recentProjects"):u.t("command.project.open"),ref:e=>a=e,onFilter:e=>l(K(e)),onKeyEvent:(e,p)=>{if(e.key!=="Tab"||e.shiftKey||!p)return;e.preventDefault(),e.stopPropagation();const n=Z(p.absolute,y(),f());a?.setFilter(n.endsWith("/")?n:n+"/")},onSelect:e=>{e&&D(e.absolute)},children:e=>{const p=Z(e.absolute,y(),f());return p==="~"?(()=>{var n=rt(),s=n.firstChild,w=s.firstChild;return P(s,z(R,{get node(){return{path:e.absolute,type:"directory"}},class:"shrink-0 size-4"}),w),n})():(()=>{var n=nt(),s=n.firstChild,w=s.firstChild,g=w.firstChild,b=g.nextSibling;return P(s,z(R,{get node(){return{path:e.absolute,type:"directory"}},class:"shrink-0 size-4"}),w),P(g,()=>X(p)),P(b,()=>j(p)),n})()}})}})}export{ht as DialogSelectDirectory};
@@ -1 +1 @@
1
- import{aa as Q,f as U,a as X,aH as Z,c as ee,d as te,bv as ne,u as se,r as re,g as b,q as ae,h as y,ac as oe,S as ie,M as L,i as p,$ as D,cz as ce,I as le,j as K,aM as de,ad as O,aV as ue,l as fe,t as _}from"./index-Bj2ueAL8.js";import{F as ge}from"./file-icon-vO6wN-HW.js";import{u as he,c as pe,K as me}from"./session-Df_z3CAQ.js";import{L as we}from"./list-FNV9nNTY.js";import"./select-Df3XuuZj.js";import"./provider-icon-BO5C5h8K.js";function ye(t,n){const i=new Date(t),r=new Date().getTime()-i.getTime(),c=Math.floor(r/1e3),u=Math.floor(c/60),a=Math.floor(u/60),f=Math.floor(a/24);return c<60?n("common.time.justNow"):u<60?n("common.time.minutesAgo.short",{count:u}):a<24?n("common.time.hoursAgo.short",{count:a}):n("common.time.daysAgo.short",{count:f})}var P=_('<span class="text-14-regular text-text-weak truncate">'),ve=_('<div class="w-full flex items-center justify-between gap-4"><div class="flex items-center gap-2 min-w-0"><span class="text-14-regular text-text-strong whitespace-nowrap">'),be=_('<span class="text-12-regular text-text-weak whitespace-nowrap ml-2">'),xe=_('<div class="w-full flex items-center justify-between rounded-md pl-1"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center gap-2 min-w-0"><span class="text-14-regular text-text-strong truncate">'),ke=_('<div class="w-full flex items-center justify-between rounded-md pl-1"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular"><span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0"></span><span class="text-text-strong whitespace-nowrap">');const T=5,$e=["session.new","workspace.new","session.previous","session.next","terminal.toggle","review.toggle"],q=t=>{const n=new Set,i=[];for(const g of t)n.has(g.id)||(n.add(g.id),i.push(g));return i},A=(t,n)=>({id:"command:"+t.id,type:"command",title:t.title,description:t.description,keybind:t.keybind,category:n,option:t}),C=(t,n)=>({id:"file:"+t,type:"file",title:t,category:n,path:t}),Se=(t,n)=>({id:`session:${t.directory}:${t.id}`,type:"session",title:t.title,description:t.description,category:n,directory:t.directory,sessionID:t.id,archived:t.archived,updated:t.updated});function _e(t){const n=b(()=>t.filesOnly()?[]:t.command.options.filter(r=>!r.disabled&&!r.id.startsWith("suggested.")&&r.id!=="file.open")),i=b(()=>{const r=t.language.t("palette.group.commands");return n().map(c=>A(c,r))}),g=b(()=>{const r=n(),c=new Map($e.map((o,l)=>[o,l])),u=r.filter(o=>c.has(o.id)),a=u.length?u:r.slice(0,T),f=u.length?[...a].sort((o,l)=>(c.get(o.id)??0)-(c.get(l.id)??0)):a,v=t.language.t("palette.group.commands");return f.map(o=>A(o,v))});return{allowed:n,list:i,picks:g}}function Me(t){const n=pe({tabs:t.tabs,pathFromTab:t.file.pathFromTab,normalizeTab:r=>r.startsWith("file://")?t.file.tab(r):r}),i=b(()=>{const r=n.openedTabs(),c=n.activeFileTab(),u=c?[c,...r.filter(o=>o!==c)]:r,a=new Set,f=t.language.t("palette.group.files"),v=[];for(const o of u){const l=t.file.pathFromTab(o);l&&(a.has(l)||(a.add(l),v.push(C(l,f))))}return v.slice(0,T)}),g=b(()=>{const r=t.language.t("palette.group.files");return t.file.tree.children("").filter(a=>a.type==="file").map(a=>a.path).sort((a,f)=>a.localeCompare(f)).slice(0,T).map(a=>C(a,r))});return{recent:i,root:g}}function De(t){const n={token:0,inflight:void 0,cached:void 0};return{sessions:g=>{if(!g.trim())return n.token+=1,n.inflight=void 0,n.cached=void 0,[];if(n.cached)return n.cached;if(n.inflight)return n.inflight;const c=n.token,u=t.workspaces();return u.length===0?[]:(n.inflight=Promise.all(u.map(a=>{const f=t.label(a);return t.globalSDK.client.session.list({directory:a,roots:!0}).then(v=>(v.data??[]).filter(o=>!!o?.id).map(o=>({id:o.id,title:o.title??t.language.t("command.session.new"),description:f,directory:a,archived:o.time?.archived,updated:o.time?.updated}))).catch(()=>[])})).then(a=>{if(n.token!==c)return[];const f=new Set,v=t.language.t("command.category.session"),o=a.flat().filter(l=>{const k=`${l.directory}:${l.id}`;return f.has(k)?!1:(f.add(k),!0)}).map(l=>Se(l,v));return n.cached=o,o}).catch(()=>[]).finally(()=>{n.inflight=void 0}),n.inflight)}}}function Le(t){const n=Q(),i=U(),g=X(),r=Z(),c=ee(),u=te(),a=ne(),f=se(),{params:v,tabs:o,view:l}=he(),k=()=>t.mode==="files",$={cleanup:void 0,committed:!1},[N,z]=re(!1),E=_e({filesOnly:k,command:n,language:i}),S=Me({file:r,tabs:o,language:i}),I=b(()=>oe(v.dir)??""),j=b(()=>{const e=I();if(e)return g.projects.list().find(s=>s.worktree===e||s.sandboxes?.includes(e))}),G=b(()=>{const e=I(),s=j();if(!s)return e?[e]:[];const d=[s.worktree,...s.sandboxes??[]];return e&&!d.includes(e)?[...d,e]:d}),H=b(()=>f.data.path.home),R=e=>{const s=j(),d=s&&e===s.worktree?i.t("workspace.type.local"):i.t("workspace.type.sandbox"),[m]=f.child(e,{bootstrap:!1}),h=H(),w=h?e.replace(h,"~"):e,x=m.vcs?.branch??O(e);return`${d} : ${x||w}`},{sessions:W}=De({workspaces:G,label:R,globalSDK:a,language:i}),B=async e=>{const s=e.trim();if(z(s.length>0),!s&&k()){const x=r.tree.state("")?.loaded,F=x?Promise.resolve():r.tree.list(""),M=q([...S.recent(),...S.root()]);return x||M.length>0?M:(await F,q([...S.recent(),...S.root()]))}if(!s)return[...E.picks(),...S.recent()];if(k()){const x=await r.searchFiles(s),F=i.t("palette.group.files");return x.map(M=>C(M,F))}const[d,m]=await Promise.all([r.searchFiles(s),Promise.resolve(W(s))]),h=i.t("palette.group.files"),w=d.map(x=>C(x,h));return[...E.list(),...m,...w]},V=e=>{$.cleanup?.(),e&&e.type==="command"&&($.cleanup=e.option?.onHighlight?.())},Y=e=>{const s=r.tab(e);o().open(s),r.load(e),l().reviewPanel.opened()||l().reviewPanel.open(),g.fileTree.setTab("all"),t.onOpenFile?.(e),o().setActive(s)},J=e=>{if(e){if($.committed=!0,$.cleanup=void 0,c.close(),e.type==="command"){e.option?.onSelect?.("palette");return}if(e.type==="session"){if(!e.directory||!e.sessionID)return;u(`/${fe(e.directory)}/session/${e.sessionID}`);return}e.path&&Y(e.path)}};return ae(()=>{$.committed||$.cleanup?.()}),y(ue,{class:"pt-3 pb-0 !max-h-[480px]",transition:!0,get children(){return y(we,{get search(){return{placeholder:k()?i.t("session.header.searchFiles"):i.t("palette.search.placeholder"),autofocus:!0,hideIcon:!0}},get emptyMessage(){return i.t("palette.empty")},get loadingMessage(){return i.t("common.loading")},items:B,key:e=>e.id,filterKeys:["title","description","category"],get groupBy(){return N()?e=>e.category:()=>""},onMove:V,onSelect:J,children:e=>y(ie,{get fallback(){return(()=>{var s=ke(),d=s.firstChild,m=d.firstChild,h=m.firstChild,w=h.nextSibling;return p(d,y(ge,{get node(){return{path:e.path??"",type:"file"}},class:"shrink-0 size-4"}),m),p(h,()=>de(e.path??"")),p(w,()=>O(e.path??"")),s})()},get children(){return[y(L,{get when(){return e.type==="command"},get children(){var s=ve(),d=s.firstChild,m=d.firstChild;return p(m,()=>e.title),p(d,y(D,{get when(){return e.description},get children(){var h=P();return p(h,()=>e.description),h}}),null),p(s,y(D,{get when(){return e.keybind},get children(){return y(me,{class:"rounded-[4px]",get children(){return ce(e.keybind??"",i.t)}})}}),null),s}}),y(L,{get when(){return e.type==="session"},get children(){var s=xe(),d=s.firstChild,m=d.firstChild,h=m.firstChild;return p(d,y(le,{name:"bubble-5",size:"small",class:"shrink-0 text-icon-weak"}),m),p(h,()=>e.title),p(m,y(D,{get when(){return e.description},get children(){var w=P();return p(w,()=>e.description),K(()=>w.classList.toggle("opacity-70",!!e.archived)),w}}),null),p(s,y(D,{get when(){return e.updated},get children(){var w=be();return p(w,()=>ye(new Date(e.updated).toISOString(),i.t)),w}}),null),K(()=>h.classList.toggle("opacity-70",!!e.archived)),s}})]}})})}})}export{Le as DialogSelectFile};
1
+ import{aa as Q,f as U,a as X,aH as Z,c as ee,d as te,bv as ne,u as se,r as re,g as b,q as ae,h as y,ac as oe,S as ie,M as L,i as p,$ as D,cz as ce,I as le,j as K,aM as de,ad as O,aV as ue,l as fe,t as _}from"./index-D-WWa_X8.js";import{F as ge}from"./file-icon-B_-1whMc.js";import{u as he,c as pe,K as me}from"./session-BmqyKO6_.js";import{L as we}from"./list-Dk_vU1zd.js";import"./select-iTRCZro5.js";import"./provider-icon-CbXUEYMU.js";function ye(t,n){const i=new Date(t),r=new Date().getTime()-i.getTime(),c=Math.floor(r/1e3),u=Math.floor(c/60),a=Math.floor(u/60),f=Math.floor(a/24);return c<60?n("common.time.justNow"):u<60?n("common.time.minutesAgo.short",{count:u}):a<24?n("common.time.hoursAgo.short",{count:a}):n("common.time.daysAgo.short",{count:f})}var P=_('<span class="text-14-regular text-text-weak truncate">'),ve=_('<div class="w-full flex items-center justify-between gap-4"><div class="flex items-center gap-2 min-w-0"><span class="text-14-regular text-text-strong whitespace-nowrap">'),be=_('<span class="text-12-regular text-text-weak whitespace-nowrap ml-2">'),xe=_('<div class="w-full flex items-center justify-between rounded-md pl-1"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center gap-2 min-w-0"><span class="text-14-regular text-text-strong truncate">'),ke=_('<div class="w-full flex items-center justify-between rounded-md pl-1"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular"><span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0"></span><span class="text-text-strong whitespace-nowrap">');const T=5,$e=["session.new","workspace.new","session.previous","session.next","terminal.toggle","review.toggle"],q=t=>{const n=new Set,i=[];for(const g of t)n.has(g.id)||(n.add(g.id),i.push(g));return i},A=(t,n)=>({id:"command:"+t.id,type:"command",title:t.title,description:t.description,keybind:t.keybind,category:n,option:t}),C=(t,n)=>({id:"file:"+t,type:"file",title:t,category:n,path:t}),Se=(t,n)=>({id:`session:${t.directory}:${t.id}`,type:"session",title:t.title,description:t.description,category:n,directory:t.directory,sessionID:t.id,archived:t.archived,updated:t.updated});function _e(t){const n=b(()=>t.filesOnly()?[]:t.command.options.filter(r=>!r.disabled&&!r.id.startsWith("suggested.")&&r.id!=="file.open")),i=b(()=>{const r=t.language.t("palette.group.commands");return n().map(c=>A(c,r))}),g=b(()=>{const r=n(),c=new Map($e.map((o,l)=>[o,l])),u=r.filter(o=>c.has(o.id)),a=u.length?u:r.slice(0,T),f=u.length?[...a].sort((o,l)=>(c.get(o.id)??0)-(c.get(l.id)??0)):a,v=t.language.t("palette.group.commands");return f.map(o=>A(o,v))});return{allowed:n,list:i,picks:g}}function Me(t){const n=pe({tabs:t.tabs,pathFromTab:t.file.pathFromTab,normalizeTab:r=>r.startsWith("file://")?t.file.tab(r):r}),i=b(()=>{const r=n.openedTabs(),c=n.activeFileTab(),u=c?[c,...r.filter(o=>o!==c)]:r,a=new Set,f=t.language.t("palette.group.files"),v=[];for(const o of u){const l=t.file.pathFromTab(o);l&&(a.has(l)||(a.add(l),v.push(C(l,f))))}return v.slice(0,T)}),g=b(()=>{const r=t.language.t("palette.group.files");return t.file.tree.children("").filter(a=>a.type==="file").map(a=>a.path).sort((a,f)=>a.localeCompare(f)).slice(0,T).map(a=>C(a,r))});return{recent:i,root:g}}function De(t){const n={token:0,inflight:void 0,cached:void 0};return{sessions:g=>{if(!g.trim())return n.token+=1,n.inflight=void 0,n.cached=void 0,[];if(n.cached)return n.cached;if(n.inflight)return n.inflight;const c=n.token,u=t.workspaces();return u.length===0?[]:(n.inflight=Promise.all(u.map(a=>{const f=t.label(a);return t.globalSDK.client.session.list({directory:a,roots:!0}).then(v=>(v.data??[]).filter(o=>!!o?.id).map(o=>({id:o.id,title:o.title??t.language.t("command.session.new"),description:f,directory:a,archived:o.time?.archived,updated:o.time?.updated}))).catch(()=>[])})).then(a=>{if(n.token!==c)return[];const f=new Set,v=t.language.t("command.category.session"),o=a.flat().filter(l=>{const k=`${l.directory}:${l.id}`;return f.has(k)?!1:(f.add(k),!0)}).map(l=>Se(l,v));return n.cached=o,o}).catch(()=>[]).finally(()=>{n.inflight=void 0}),n.inflight)}}}function Le(t){const n=Q(),i=U(),g=X(),r=Z(),c=ee(),u=te(),a=ne(),f=se(),{params:v,tabs:o,view:l}=he(),k=()=>t.mode==="files",$={cleanup:void 0,committed:!1},[N,z]=re(!1),E=_e({filesOnly:k,command:n,language:i}),S=Me({file:r,tabs:o,language:i}),I=b(()=>oe(v.dir)??""),j=b(()=>{const e=I();if(e)return g.projects.list().find(s=>s.worktree===e||s.sandboxes?.includes(e))}),G=b(()=>{const e=I(),s=j();if(!s)return e?[e]:[];const d=[s.worktree,...s.sandboxes??[]];return e&&!d.includes(e)?[...d,e]:d}),H=b(()=>f.data.path.home),R=e=>{const s=j(),d=s&&e===s.worktree?i.t("workspace.type.local"):i.t("workspace.type.sandbox"),[m]=f.child(e,{bootstrap:!1}),h=H(),w=h?e.replace(h,"~"):e,x=m.vcs?.branch??O(e);return`${d} : ${x||w}`},{sessions:W}=De({workspaces:G,label:R,globalSDK:a,language:i}),B=async e=>{const s=e.trim();if(z(s.length>0),!s&&k()){const x=r.tree.state("")?.loaded,F=x?Promise.resolve():r.tree.list(""),M=q([...S.recent(),...S.root()]);return x||M.length>0?M:(await F,q([...S.recent(),...S.root()]))}if(!s)return[...E.picks(),...S.recent()];if(k()){const x=await r.searchFiles(s),F=i.t("palette.group.files");return x.map(M=>C(M,F))}const[d,m]=await Promise.all([r.searchFiles(s),Promise.resolve(W(s))]),h=i.t("palette.group.files"),w=d.map(x=>C(x,h));return[...E.list(),...m,...w]},V=e=>{$.cleanup?.(),e&&e.type==="command"&&($.cleanup=e.option?.onHighlight?.())},Y=e=>{const s=r.tab(e);o().open(s),r.load(e),l().reviewPanel.opened()||l().reviewPanel.open(),g.fileTree.setTab("all"),t.onOpenFile?.(e),o().setActive(s)},J=e=>{if(e){if($.committed=!0,$.cleanup=void 0,c.close(),e.type==="command"){e.option?.onSelect?.("palette");return}if(e.type==="session"){if(!e.directory||!e.sessionID)return;u(`/${fe(e.directory)}/session/${e.sessionID}`);return}e.path&&Y(e.path)}};return ae(()=>{$.committed||$.cleanup?.()}),y(ue,{class:"pt-3 pb-0 !max-h-[480px]",transition:!0,get children(){return y(we,{get search(){return{placeholder:k()?i.t("session.header.searchFiles"):i.t("palette.search.placeholder"),autofocus:!0,hideIcon:!0}},get emptyMessage(){return i.t("palette.empty")},get loadingMessage(){return i.t("common.loading")},items:B,key:e=>e.id,filterKeys:["title","description","category"],get groupBy(){return N()?e=>e.category:()=>""},onMove:V,onSelect:J,children:e=>y(ie,{get fallback(){return(()=>{var s=ke(),d=s.firstChild,m=d.firstChild,h=m.firstChild,w=h.nextSibling;return p(d,y(ge,{get node(){return{path:e.path??"",type:"file"}},class:"shrink-0 size-4"}),m),p(h,()=>de(e.path??"")),p(w,()=>O(e.path??"")),s})()},get children(){return[y(L,{get when(){return e.type==="command"},get children(){var s=ve(),d=s.firstChild,m=d.firstChild;return p(m,()=>e.title),p(d,y(D,{get when(){return e.description},get children(){var h=P();return p(h,()=>e.description),h}}),null),p(s,y(D,{get when(){return e.keybind},get children(){return y(me,{class:"rounded-[4px]",get children(){return ce(e.keybind??"",i.t)}})}}),null),s}}),y(L,{get when(){return e.type==="session"},get children(){var s=xe(),d=s.firstChild,m=d.firstChild,h=m.firstChild;return p(d,y(le,{name:"bubble-5",size:"small",class:"shrink-0 text-icon-weak"}),m),p(h,()=>e.title),p(m,y(D,{get when(){return e.description},get children(){var w=P();return p(w,()=>e.description),K(()=>w.classList.toggle("opacity-70",!!e.archived)),w}}),null),p(s,y(D,{get when(){return e.updated},get children(){var w=be();return p(w,()=>ye(new Date(e.updated).toISOString(),i.t)),w}}),null),K(()=>h.classList.toggle("opacity-70",!!e.archived)),s}})]}})})}})}export{Le as DialogSelectFile};
@@ -1 +1 @@
1
- import{a8 as P,aK as M,f as D,n as E,o as b,p as K,al as j,g as h,b2 as B,h as u,aB as F,i as c,$ as v,m as y,aV as q,t as m}from"./index-Bj2ueAL8.js";import{L as O}from"./list-FNV9nNTY.js";import{S as T}from"./switch-DyYMuMHL.js";var V=m('<span class="text-11-regular text-text-weaker">'),z=m('<span class="text-11-regular text-text-weak">'),A=m('<span class="text-11-regular text-text-weaker truncate">'),G=m('<div class="w-full flex items-center justify-between gap-x-3"><div class="flex flex-col gap-0.5 min-w-0"><div class="flex items-center gap-2"><span class=truncate></span></div></div><div>');const H={connected:"mcp.status.connected",failed:"mcp.status.failed",needs_auth:"mcp.status.needs_auth",disabled:"mcp.status.disabled"},Q=()=>{const s=P(),d=M(),l=D(),[_,o]=E({done:!1,loading:!1});b(K(()=>s.data.mcp_ready,(e,t)=>{!e&&t&&o("done",!1)},{defer:!0})),b(()=>{if(!(_.done||_.loading)){if(s.data.mcp_ready){o("done",!0);return}o("loading",!0),d.client.mcp.status().then(e=>{s.set("mcp",e.data??{}),s.set("mcp_ready",!0),o("done",!0)}).catch(e=>{o("done",!0),j({variant:"error",title:l.t("common.requestFailed"),description:e instanceof Error?e.message:String(e)})}).finally(()=>{o("loading",!1)})}});const p=h(()=>Object.entries(s.data.mcp??{}).map(([e,t])=>({name:e,status:t.status})).sort((e,t)=>e.name.localeCompare(t.name))),n=B(()=>({mutationFn:async e=>{s.data.mcp[e]?.status==="connected"?await d.client.mcp.disconnect({name:e}):await d.client.mcp.connect({name:e});const i=await d.client.mcp.status();i.data&&s.set("mcp",i.data)}})),S=h(()=>p().filter(e=>e.status==="connected").length),k=h(()=>p().length);return u(q,{get title(){return l.t("dialog.mcp.title")},get description(){return l.t("dialog.mcp.description",{enabled:S(),total:k()})},get children(){return u(O,{get search(){return{placeholder:l.t("common.search.placeholder"),autofocus:!0}},get emptyMessage(){return l.t("dialog.mcp.empty")},key:e=>e?.name??"",items:p,filterKeys:["name","status"],sortBy:(e,t)=>e.name.localeCompare(t.name),onSelect:e=>{!e||n.isPending||n.mutate(e.name)},children:e=>{const t=()=>s.data.mcp[e.name],i=()=>t()?.status,w=()=>{const r=i()?H[i()]:void 0;if(r)return l.t(r)},x=()=>{const r=t();return r?.status==="failed"?r.error:void 0},C=()=>i()==="connected";return(()=>{var r=G(),g=r.firstChild,f=g.firstChild,L=f.firstChild,$=g.nextSibling;return c(L,()=>e.name),c(f,u(v,{get when(){return w()},get children(){var a=V();return c(a,w),a}}),null),c(f,u(v,{get when(){return y(()=>!!n.isPending)()&&n.variables===e.name},get children(){var a=z();return c(a,()=>l.t("common.loading.ellipsis")),a}}),null),c(g,u(v,{get when(){return x()},get children(){var a=A();return c(a,x),a}}),null),$.$$click=a=>a.stopPropagation(),c($,u(T,{get checked(){return C()},get disabled(){return y(()=>!!n.isPending)()&&n.variables===e.name},onChange:()=>{n.isPending||n.mutate(e.name)}})),r})()}})}})};F(["click"]);export{Q as DialogSelectMcp};
1
+ import{a8 as P,aK as M,f as D,n as E,o as b,p as K,al as j,g as h,b2 as B,h as u,aB as F,i as c,$ as v,m as y,aV as q,t as m}from"./index-D-WWa_X8.js";import{L as O}from"./list-Dk_vU1zd.js";import{S as T}from"./switch-CiVaw2SH.js";var V=m('<span class="text-11-regular text-text-weaker">'),z=m('<span class="text-11-regular text-text-weak">'),A=m('<span class="text-11-regular text-text-weaker truncate">'),G=m('<div class="w-full flex items-center justify-between gap-x-3"><div class="flex flex-col gap-0.5 min-w-0"><div class="flex items-center gap-2"><span class=truncate></span></div></div><div>');const H={connected:"mcp.status.connected",failed:"mcp.status.failed",needs_auth:"mcp.status.needs_auth",disabled:"mcp.status.disabled"},Q=()=>{const s=P(),d=M(),l=D(),[_,o]=E({done:!1,loading:!1});b(K(()=>s.data.mcp_ready,(e,t)=>{!e&&t&&o("done",!1)},{defer:!0})),b(()=>{if(!(_.done||_.loading)){if(s.data.mcp_ready){o("done",!0);return}o("loading",!0),d.client.mcp.status().then(e=>{s.set("mcp",e.data??{}),s.set("mcp_ready",!0),o("done",!0)}).catch(e=>{o("done",!0),j({variant:"error",title:l.t("common.requestFailed"),description:e instanceof Error?e.message:String(e)})}).finally(()=>{o("loading",!1)})}});const p=h(()=>Object.entries(s.data.mcp??{}).map(([e,t])=>({name:e,status:t.status})).sort((e,t)=>e.name.localeCompare(t.name))),n=B(()=>({mutationFn:async e=>{s.data.mcp[e]?.status==="connected"?await d.client.mcp.disconnect({name:e}):await d.client.mcp.connect({name:e});const i=await d.client.mcp.status();i.data&&s.set("mcp",i.data)}})),S=h(()=>p().filter(e=>e.status==="connected").length),k=h(()=>p().length);return u(q,{get title(){return l.t("dialog.mcp.title")},get description(){return l.t("dialog.mcp.description",{enabled:S(),total:k()})},get children(){return u(O,{get search(){return{placeholder:l.t("common.search.placeholder"),autofocus:!0}},get emptyMessage(){return l.t("dialog.mcp.empty")},key:e=>e?.name??"",items:p,filterKeys:["name","status"],sortBy:(e,t)=>e.name.localeCompare(t.name),onSelect:e=>{!e||n.isPending||n.mutate(e.name)},children:e=>{const t=()=>s.data.mcp[e.name],i=()=>t()?.status,w=()=>{const r=i()?H[i()]:void 0;if(r)return l.t(r)},x=()=>{const r=t();return r?.status==="failed"?r.error:void 0},C=()=>i()==="connected";return(()=>{var r=G(),g=r.firstChild,f=g.firstChild,L=f.firstChild,$=g.nextSibling;return c(L,()=>e.name),c(f,u(v,{get when(){return w()},get children(){var a=V();return c(a,w),a}}),null),c(f,u(v,{get when(){return y(()=>!!n.isPending)()&&n.variables===e.name},get children(){var a=z();return c(a,()=>l.t("common.loading.ellipsis")),a}}),null),c(g,u(v,{get when(){return x()},get children(){var a=A();return c(a,x),a}}),null),$.$$click=a=>a.stopPropagation(),c($,u(T,{get checked(){return C()},get disabled(){return y(()=>!!n.isPending)()&&n.variables===e.name},onChange:()=>{n.isPending||n.mutate(e.name)}})),r})()}})}})};F(["click"]);export{Q as DialogSelectMcp};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dialog-connect-provider-DqlW9pvn.js","assets/index-Bj2ueAL8.js","assets/index-jvk-T241.css","assets/list-FNV9nNTY.js","assets/provider-icon-BO5C5h8K.js","assets/dialog-select-provider-CZw0JIcb.js"])))=>i.map(i=>d[i]);
2
- import{aP as P,c as E,aF as I,f as L,h as t,i as r,$ as u,aj as S,m as T,aW as p,B as M,aV as B,t as c,a7 as w,aB as O}from"./index-Bj2ueAL8.js";import{L as $}from"./list-FNV9nNTY.js";import{T as m,P as A}from"./provider-icon-BO5C5h8K.js";import{M as R}from"./session-Df_z3CAQ.js";import"./select-Df3XuuZj.js";import"./file-icon-vO6wN-HW.js";var V=c('<div class="flex flex-col gap-3 px-2.5"><div class="text-14-medium text-text-base px-2.5">'),j=c('<div class="px-1.5 pb-1.5"><div class="w-full rounded-sm border border-border-weak-base bg-surface-raised-base"><div class="w-full flex flex-col items-start gap-4 px-1.5 pt-4 pb-4"><div class="px-2 text-14-medium text-text-base"></div><div class=w-full>'),K=c('<div class="w-full flex items-center gap-x-2.5"><span>'),h=c('<div class="text-14-regular text-text-weak">'),W=c('<div class="w-full flex items-center gap-x-3"><span>');const J=k=>{const v=k.model??P().model,f=E(),b=I(),d=L(),y=l=>{w(()=>import("./dialog-connect-provider-DqlW9pvn.js").then(s=>s.d),__vite__mapDeps([0,1,2,3,4])).then(s=>{f.show(()=>t(s.DialogConnectProvider,{provider:l}))})},D=()=>{w(()=>import("./dialog-select-provider-CZw0JIcb.js").then(l=>l.d),__vite__mapDeps([5,1,2,3,4,0])).then(l=>{f.show(()=>t(l.DialogSelectProvider,{}))})};let _;const C=l=>{l.key!=="Escape"&&_?.onKeyDown(l)};return t(B,{get title(){return d.t("dialog.model.select.title")},class:"overflow-y-auto [&_[data-slot=dialog-body]]:overflow-visible [&_[data-slot=dialog-body]]:flex-none",get children(){return[(()=>{var l=V(),s=l.firstChild;return l.$$keydown=C,r(s,()=>d.t("dialog.model.unpaid.freeModels.title")),r(l,t($,{class:"[&_[data-slot=list-scroll]]:overflow-visible",ref:e=>_=e,get items(){return v.list},get current(){return v.current()},key:e=>`${e.provider.id}:${e.id}`,itemWrapper:(e,a)=>t(S,{class:"w-full",placement:"right-start",gutter:12,get value(){return t(R,{model:e,get latest(){return e.latest},get free(){return T(()=>e.provider.id==="duckmind")()&&(!e.cost||e.cost.input===0)}})},children:a}),onSelect:e=>{v.set(e?{modelID:e.id,providerID:e.provider.id}:void 0,{recent:!0}),f.close()},children:e=>(()=>{var a=K(),g=a.firstChild;return r(g,()=>e.name),r(a,t(m,{get children(){return d.t("model.tag.free")}}),null),r(a,t(u,{get when(){return e.latest},get children(){return t(m,{get children(){return d.t("model.tag.latest")}})}}),null),a})()}),null),l})(),(()=>{var l=j(),s=l.firstChild,e=s.firstChild,a=e.firstChild,g=a.nextSibling;return r(a,()=>d.t("dialog.model.unpaid.addMore.title")),r(g,t($,{class:"w-full px-0",key:i=>i?.id,get items(){return b.popular},activeIcon:"plus-small",sortBy:(i,o)=>p.includes(i.id)&&p.includes(o.id)?p.indexOf(i.id)-p.indexOf(o.id):i.name.localeCompare(o.name),onSelect:i=>{i&&y(i.id)},children:i=>(()=>{var o=W(),x=o.firstChild;return r(o,t(A,{"data-slot":"list-item-extra-icon",get id(){return i.id}}),x),r(x,()=>i.name),r(o,t(u,{get when(){return i.id==="duckmind"},get children(){var n=h();return r(n,()=>d.t("dialog.provider.duckmind.tagline")),n}}),null),r(o,t(u,{get when(){return i.id==="duckmind"},get children(){return t(m,{get children(){return d.t("dialog.provider.tag.recommended")}})}}),null),r(o,t(u,{get when(){return i.id==="duckmind-go"},get children(){return[(()=>{var n=h();return r(n,()=>d.t("dialog.provider.duckmindGo.tagline")),n})(),t(m,{get children(){return d.t("dialog.provider.tag.recommended")}})]}}),null),r(o,t(u,{get when(){return i.id==="anthropic"},get children(){var n=h();return r(n,()=>d.t("dialog.provider.anthropic.note")),n}}),null),o})()}),null),r(g,t(M,{variant:"ghost",class:"w-full justify-start px-[11px] py-3.5 gap-4.5 text-14-medium",icon:"dot-grid",onClick:D,get children(){return d.t("dialog.provider.viewAll")}}),null),l})()]}})};O(["keydown"]);export{J as DialogSelectModelUnpaid};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dialog-connect-provider-jjqkH3fb.js","assets/index-D-WWa_X8.js","assets/index-jvk-T241.css","assets/list-Dk_vU1zd.js","assets/provider-icon-CbXUEYMU.js","assets/dialog-select-provider-DNa_XLNK.js"])))=>i.map(i=>d[i]);
2
+ import{aP as P,c as E,aF as I,f as L,h as t,i as r,$ as u,aj as S,m as T,aW as p,B as M,aV as B,t as c,a7 as w,aB as O}from"./index-D-WWa_X8.js";import{L as $}from"./list-Dk_vU1zd.js";import{T as m,P as A}from"./provider-icon-CbXUEYMU.js";import{M as R}from"./session-BmqyKO6_.js";import"./select-iTRCZro5.js";import"./file-icon-B_-1whMc.js";var V=c('<div class="flex flex-col gap-3 px-2.5"><div class="text-14-medium text-text-base px-2.5">'),j=c('<div class="px-1.5 pb-1.5"><div class="w-full rounded-sm border border-border-weak-base bg-surface-raised-base"><div class="w-full flex flex-col items-start gap-4 px-1.5 pt-4 pb-4"><div class="px-2 text-14-medium text-text-base"></div><div class=w-full>'),K=c('<div class="w-full flex items-center gap-x-2.5"><span>'),h=c('<div class="text-14-regular text-text-weak">'),W=c('<div class="w-full flex items-center gap-x-3"><span>');const J=k=>{const v=k.model??P().model,f=E(),b=I(),d=L(),y=l=>{w(()=>import("./dialog-connect-provider-jjqkH3fb.js").then(s=>s.d),__vite__mapDeps([0,1,2,3,4])).then(s=>{f.show(()=>t(s.DialogConnectProvider,{provider:l}))})},D=()=>{w(()=>import("./dialog-select-provider-DNa_XLNK.js").then(l=>l.d),__vite__mapDeps([5,1,2,3,4,0])).then(l=>{f.show(()=>t(l.DialogSelectProvider,{}))})};let _;const C=l=>{l.key!=="Escape"&&_?.onKeyDown(l)};return t(B,{get title(){return d.t("dialog.model.select.title")},class:"overflow-y-auto [&_[data-slot=dialog-body]]:overflow-visible [&_[data-slot=dialog-body]]:flex-none",get children(){return[(()=>{var l=V(),s=l.firstChild;return l.$$keydown=C,r(s,()=>d.t("dialog.model.unpaid.freeModels.title")),r(l,t($,{class:"[&_[data-slot=list-scroll]]:overflow-visible",ref:e=>_=e,get items(){return v.list},get current(){return v.current()},key:e=>`${e.provider.id}:${e.id}`,itemWrapper:(e,a)=>t(S,{class:"w-full",placement:"right-start",gutter:12,get value(){return t(R,{model:e,get latest(){return e.latest},get free(){return T(()=>e.provider.id==="duckmind")()&&(!e.cost||e.cost.input===0)}})},children:a}),onSelect:e=>{v.set(e?{modelID:e.id,providerID:e.provider.id}:void 0,{recent:!0}),f.close()},children:e=>(()=>{var a=K(),g=a.firstChild;return r(g,()=>e.name),r(a,t(m,{get children(){return d.t("model.tag.free")}}),null),r(a,t(u,{get when(){return e.latest},get children(){return t(m,{get children(){return d.t("model.tag.latest")}})}}),null),a})()}),null),l})(),(()=>{var l=j(),s=l.firstChild,e=s.firstChild,a=e.firstChild,g=a.nextSibling;return r(a,()=>d.t("dialog.model.unpaid.addMore.title")),r(g,t($,{class:"w-full px-0",key:i=>i?.id,get items(){return b.popular},activeIcon:"plus-small",sortBy:(i,o)=>p.includes(i.id)&&p.includes(o.id)?p.indexOf(i.id)-p.indexOf(o.id):i.name.localeCompare(o.name),onSelect:i=>{i&&y(i.id)},children:i=>(()=>{var o=W(),x=o.firstChild;return r(o,t(A,{"data-slot":"list-item-extra-icon",get id(){return i.id}}),x),r(x,()=>i.name),r(o,t(u,{get when(){return i.id==="duckmind"},get children(){var n=h();return r(n,()=>d.t("dialog.provider.duckmind.tagline")),n}}),null),r(o,t(u,{get when(){return i.id==="duckmind"},get children(){return t(m,{get children(){return d.t("dialog.provider.tag.recommended")}})}}),null),r(o,t(u,{get when(){return i.id==="duckmind-go"},get children(){return[(()=>{var n=h();return r(n,()=>d.t("dialog.provider.duckmindGo.tagline")),n})(),t(m,{get children(){return d.t("dialog.provider.tag.recommended")}})]}}),null),r(o,t(u,{get when(){return i.id==="anthropic"},get children(){var n=h();return r(n,()=>d.t("dialog.provider.anthropic.note")),n}}),null),o})()}),null),r(g,t(M,{variant:"ghost",class:"w-full justify-start px-[11px] py-3.5 gap-4.5 text-14-medium",icon:"dot-grid",onClick:D,get children(){return d.t("dialog.provider.viewAll")}}),null),l})()]}})};O(["keydown"]);export{J as DialogSelectModelUnpaid};
@@ -1 +1 @@
1
- import{c as Z,u as le,bv as ne,f as ee,n as se,b2 as de,al as V,h as o,i as a,bz as k,F as A,a5 as T,j as W,aD as N,B as j,m as ce,aV as re,t as B,z as G,bx as z,aF as ue,$ as U,aW as K}from"./index-Bj2ueAL8.js";import{L as ve}from"./list-FNV9nNTY.js";import{P as te,T as H}from"./provider-icon-BO5C5h8K.js";import{L as me,D as pe}from"./dialog-connect-provider-DqlW9pvn.js";const ge=/^[a-z0-9][a-z0-9-_]*$/,he="@ai-sdk/openai-compatible";function fe(n){const h=n.form.providerID.trim(),s=n.form.name.trim(),x=n.form.baseURL.trim(),r=n.form.apiKey.trim(),d=r.match(/^\{env:([^}]+)\}$/)?.[1]?.trim(),v=r&&!d?r:void 0,t=h?ge.test(h)?void 0:n.t("provider.custom.error.providerID.format"):n.t("provider.custom.error.providerID.required"),u=s?void 0:n.t("provider.custom.error.name.required"),g=x?/^https?:\/\//.test(x)?void 0:n.t("provider.custom.error.baseURL.format"):n.t("provider.custom.error.baseURL.required"),y=n.disabledProviders.includes(h),_=t?void 0:n.existingProviderIDs.has(h)&&!y?n.t("provider.custom.error.providerID.exists"):void 0,w=new Set,S=n.form.models.map(l=>{const p=l.id.trim(),f=p?w.has(p)?n.t("provider.custom.error.duplicate"):(()=>{w.add(p)})():n.t("provider.custom.error.required"),P=l.name.trim()?void 0:n.t("provider.custom.error.required");return{id:f,name:P}}),M=S.every(l=>!l.id&&!l.name),q=Object.fromEntries(n.form.models.map(l=>[l.id.trim(),{name:l.name.trim()}])),D=new Set,L=n.form.headers.map(l=>{const p=l.key.trim(),f=l.value.trim();if(!p&&!f)return{};const P=p?D.has(p.toLowerCase())?n.t("provider.custom.error.duplicate"):(()=>{D.add(p.toLowerCase())})():n.t("provider.custom.error.required"),E=f?void 0:n.t("provider.custom.error.required");return{key:P,value:E}}),e=L.every(l=>!l.key&&!l.value),i=Object.fromEntries(n.form.headers.map(l=>({key:l.key.trim(),value:l.value.trim()})).filter(l=>!!l.key&&!!l.value).map(l=>[l.key,l.value])),m={providerID:t??_,name:u,baseURL:g};return!t&&!_&&!u&&!g&&M&&e?{err:m,models:S,headers:L,result:{providerID:h,name:s,key:v,config:{npm:he,name:s,...d?{env:[d]}:{},options:{baseURL:x,...Object.keys(i).length?{headers:i}:{}},models:q}}}:{err:m,models:S,headers:L}}let be=0;const oe=()=>`row-${be++}`,J=()=>({row:oe(),id:"",name:"",err:{}}),Q=()=>({row:oe(),key:"",value:"",err:{}});var xe=B('<div class="flex flex-col gap-6 px-2.5 pb-3 overflow-y-auto max-h-[60vh]"><div class="px-2.5 flex gap-4 items-center"><div class="text-16-medium text-text-strong"></div></div><form class="px-2.5 pb-6 flex flex-col gap-6"><p class="text-14-regular text-text-base"></p><div class="flex flex-col gap-4"></div><div class="flex flex-col gap-3"><label class="text-12-medium text-text-weak"></label></div><div class="flex flex-col gap-3"><label class="text-12-medium text-text-weak">'),X=B('<div class="flex gap-2 items-start"><div class=flex-1></div><div class=flex-1>');function ye(n){const h=Z(),s=le(),x=ne(),r=ee(),[d,v]=se({providerID:"",name:"",baseURL:"",apiKey:"",models:[J()],headers:[Q()],err:{}}),t=()=>{if(n.back==="close"){h.close();return}h.show(()=>o(ae,{}))},u=()=>{v("models",z(e=>{e.push(J())}))},g=e=>{d.models.length<=1||v("models",z(i=>{i.splice(e,1)}))},y=()=>{v("headers",z(e=>{e.push(Q())}))},_=e=>{d.headers.length<=1||v("headers",z(i=>{i.splice(e,1)}))},w=(e,i)=>{v(e,i),e!=="apiKey"&&v("err",e,void 0)},S=(e,i,m)=>{G(()=>{v("models",e,i,m),v("models",e,"err",i,void 0)})},M=(e,i,m)=>{G(()=>{v("headers",e,i,m),v("headers",e,"err",i,void 0)})},q=()=>{const e=fe({form:d,t:r.t,disabledProviders:s.data.config.disabled_providers??[],existingProviderIDs:new Set(s.data.provider.all.map(i=>i.id))});return G(()=>{v("err",e.err),e.models.forEach((i,m)=>v("models",m,"err",i)),e.headers.forEach((i,m)=>v("headers",m,"err",i))}),e.result},D=de(()=>({mutationFn:async e=>{const m=(s.data.config.disabled_providers??[]).filter($=>$!==e.providerID);return e.key&&await x.client.auth.set({providerID:e.providerID,auth:{type:"api",key:e.key}}),await s.updateConfig({provider:{[e.providerID]:e.config},disabled_providers:m}),e},onSuccess:e=>{h.close(),V({variant:"success",icon:"circle-check",title:r.t("provider.connect.toast.connected.title",{provider:e.name}),description:r.t("provider.connect.toast.connected.description",{provider:e.name})})},onError:e=>{const i=e instanceof Error?e.message:String(e);V({title:r.t("common.requestFailed"),description:i})}})),L=e=>{if(e.preventDefault(),D.isPending)return;const i=q();i&&D.mutate(i)};return o(re,{get title(){return o(T,{tabIndex:-1,icon:"arrow-left",variant:"ghost",onClick:t,get"aria-label"(){return r.t("common.goBack")}})},transition:!0,get children(){var e=xe(),i=e.firstChild,m=i.firstChild,$=i.nextSibling,l=$.firstChild,p=l.nextSibling,f=p.nextSibling,P=f.firstChild,E=f.nextSibling,ie=E.firstChild;return a(i,o(te,{id:"synthetic",class:"size-5 shrink-0 icon-strong-base"}),m),a(m,()=>r.t("provider.custom.title")),$.addEventListener("submit",L),a(l,()=>r.t("provider.custom.description.prefix"),null),a(l,o(me,{href:"https://duckmind.ai/docs/providers/#custom-provider",tabIndex:-1,get children(){return r.t("provider.custom.description.link")}}),null),a(l,()=>r.t("provider.custom.description.suffix"),null),a(p,o(k,{autofocus:!0,get label(){return r.t("provider.custom.field.providerID.label")},get placeholder(){return r.t("provider.custom.field.providerID.placeholder")},get description(){return r.t("provider.custom.field.providerID.description")},get value(){return d.providerID},onChange:c=>w("providerID",c),get validationState(){return d.err.providerID?"invalid":void 0},get error(){return d.err.providerID}}),null),a(p,o(k,{get label(){return r.t("provider.custom.field.name.label")},get placeholder(){return r.t("provider.custom.field.name.placeholder")},get value(){return d.name},onChange:c=>w("name",c),get validationState(){return d.err.name?"invalid":void 0},get error(){return d.err.name}}),null),a(p,o(k,{get label(){return r.t("provider.custom.field.baseURL.label")},get placeholder(){return r.t("provider.custom.field.baseURL.placeholder")},get value(){return d.baseURL},onChange:c=>w("baseURL",c),get validationState(){return d.err.baseURL?"invalid":void 0},get error(){return d.err.baseURL}}),null),a(p,o(k,{get label(){return r.t("provider.custom.field.apiKey.label")},get placeholder(){return r.t("provider.custom.field.apiKey.placeholder")},get description(){return r.t("provider.custom.field.apiKey.description")},get value(){return d.apiKey},onChange:c=>w("apiKey",c)}),null),a(P,()=>r.t("provider.custom.models.label")),a(f,o(A,{get each(){return d.models},children:(c,C)=>(()=>{var b=X(),R=b.firstChild,F=R.nextSibling;return a(R,o(k,{get label(){return r.t("provider.custom.models.id.label")},hideLabel:!0,get placeholder(){return r.t("provider.custom.models.id.placeholder")},get value(){return c.id},onChange:I=>S(C(),"id",I),get validationState(){return c.err.id?"invalid":void 0},get error(){return c.err.id}})),a(F,o(k,{get label(){return r.t("provider.custom.models.name.label")},hideLabel:!0,get placeholder(){return r.t("provider.custom.models.name.placeholder")},get value(){return c.name},onChange:I=>S(C(),"name",I),get validationState(){return c.err.name?"invalid":void 0},get error(){return c.err.name}})),a(b,o(T,{type:"button",icon:"trash",variant:"ghost",class:"mt-1.5",onClick:()=>g(C()),get disabled(){return d.models.length<=1},get"aria-label"(){return r.t("provider.custom.models.remove")}}),null),W(()=>N(b,"data-row",c.row)),b})()}),null),a(f,o(j,{type:"button",size:"small",variant:"ghost",icon:"plus-small",onClick:u,class:"self-start",get children(){return r.t("provider.custom.models.add")}}),null),a(ie,()=>r.t("provider.custom.headers.label")),a(E,o(A,{get each(){return d.headers},children:(c,C)=>(()=>{var b=X(),R=b.firstChild,F=R.nextSibling;return a(R,o(k,{get label(){return r.t("provider.custom.headers.key.label")},hideLabel:!0,get placeholder(){return r.t("provider.custom.headers.key.placeholder")},get value(){return c.key},onChange:I=>M(C(),"key",I),get validationState(){return c.err.key?"invalid":void 0},get error(){return c.err.key}})),a(F,o(k,{get label(){return r.t("provider.custom.headers.value.label")},hideLabel:!0,get placeholder(){return r.t("provider.custom.headers.value.placeholder")},get value(){return c.value},onChange:I=>M(C(),"value",I),get validationState(){return c.err.value?"invalid":void 0},get error(){return c.err.value}})),a(b,o(T,{type:"button",icon:"trash",variant:"ghost",class:"mt-1.5",onClick:()=>_(C()),get disabled(){return d.headers.length<=1},get"aria-label"(){return r.t("provider.custom.headers.remove")}}),null),W(()=>N(b,"data-row",c.row)),b})()}),null),a(E,o(j,{type:"button",size:"small",variant:"ghost",icon:"plus-small",onClick:y,class:"self-start",get children(){return r.t("provider.custom.headers.add")}}),null),a($,o(j,{class:"w-auto self-start",type:"submit",size:"large",variant:"primary",get disabled(){return D.isPending},get children(){return ce(()=>!!D.isPending)()?r.t("common.saving"):r.t("common.submit")}}),null),e}})}var Y=B('<div class="text-14-regular text-text-weak">'),ke=B('<div class="px-1.25 w-full flex items-center gap-x-3"><span>');const O="_custom",ae=()=>{const n=Z(),h=ue(),s=ee(),x=()=>s.t("dialog.provider.group.popular"),r=()=>s.t("dialog.provider.group.other"),d=()=>s.t("settings.providers.tag.custom"),v=t=>{if(t==="anthropic")return s.t("dialog.provider.anthropic.note");if(t==="openai")return s.t("dialog.provider.openai.note");if(t.startsWith("github-copilot"))return s.t("dialog.provider.copilot.note");if(t==="duckmind-go")return s.t("dialog.provider.duckmindGo.tagline")};return o(re,{get title(){return s.t("command.provider.connect")},transition:!0,get children(){return o(ve,{get search(){return{placeholder:s.t("dialog.provider.search.placeholder"),autofocus:!0}},get emptyMessage(){return s.t("dialog.provider.empty")},activeIcon:"plus-small",key:t=>t?.id,items:()=>(s.locale(),[{id:O,name:d()},...h.all()]),filterKeys:["id","name"],groupBy:t=>K.includes(t.id)?x():r(),sortBy:(t,u)=>t.id===O?-1:u.id===O?1:K.includes(t.id)&&K.includes(u.id)?K.indexOf(t.id)-K.indexOf(u.id):t.name.localeCompare(u.name),sortGroupsBy:(t,u)=>{const g=x();return t.category===g&&u.category!==g?-1:u.category===g&&t.category!==g?1:0},onSelect:t=>{if(t){if(t.id===O){n.show(()=>o(ye,{back:"providers"}));return}n.show(()=>o(pe,{get provider(){return t.id}}))}},children:t=>(()=>{var u=ke(),g=u.firstChild;return a(u,o(te,{"data-slot":"list-item-extra-icon",get id(){return t.id}}),g),a(g,()=>t.name),a(u,o(U,{get when(){return t.id==="duckmind"},get children(){var y=Y();return a(y,()=>s.t("dialog.provider.duckmind.tagline")),y}}),null),a(u,o(U,{get when(){return t.id===O},get children(){return o(H,{get children(){return s.t("settings.providers.tag.custom")}})}}),null),a(u,o(U,{get when(){return t.id==="duckmind"},get children(){return o(H,{get children(){return s.t("dialog.provider.tag.recommended")}})}}),null),a(u,o(U,{get when(){return v(t.id)},children:y=>(()=>{var _=Y();return a(_,y),_})()}),null),a(u,o(U,{get when(){return t.id==="duckmind-go"},get children(){return o(H,{get children(){return s.t("dialog.provider.tag.recommended")}})}}),null),u})()})}})},Ie=Object.freeze(Object.defineProperty({__proto__:null,DialogSelectProvider:ae},Symbol.toStringTag,{value:"Module"}));export{ye as D,ae as a,Ie as d};
1
+ import{c as Z,u as le,bv as ne,f as ee,n as se,b2 as de,al as V,h as o,i as a,bz as k,F as A,a5 as T,j as W,aD as N,B as j,m as ce,aV as re,t as B,z as G,bx as z,aF as ue,$ as U,aW as K}from"./index-D-WWa_X8.js";import{L as ve}from"./list-Dk_vU1zd.js";import{P as te,T as H}from"./provider-icon-CbXUEYMU.js";import{L as me,D as pe}from"./dialog-connect-provider-jjqkH3fb.js";const ge=/^[a-z0-9][a-z0-9-_]*$/,he="@ai-sdk/openai-compatible";function fe(n){const h=n.form.providerID.trim(),s=n.form.name.trim(),x=n.form.baseURL.trim(),r=n.form.apiKey.trim(),d=r.match(/^\{env:([^}]+)\}$/)?.[1]?.trim(),v=r&&!d?r:void 0,t=h?ge.test(h)?void 0:n.t("provider.custom.error.providerID.format"):n.t("provider.custom.error.providerID.required"),u=s?void 0:n.t("provider.custom.error.name.required"),g=x?/^https?:\/\//.test(x)?void 0:n.t("provider.custom.error.baseURL.format"):n.t("provider.custom.error.baseURL.required"),y=n.disabledProviders.includes(h),_=t?void 0:n.existingProviderIDs.has(h)&&!y?n.t("provider.custom.error.providerID.exists"):void 0,w=new Set,S=n.form.models.map(l=>{const p=l.id.trim(),f=p?w.has(p)?n.t("provider.custom.error.duplicate"):(()=>{w.add(p)})():n.t("provider.custom.error.required"),P=l.name.trim()?void 0:n.t("provider.custom.error.required");return{id:f,name:P}}),M=S.every(l=>!l.id&&!l.name),q=Object.fromEntries(n.form.models.map(l=>[l.id.trim(),{name:l.name.trim()}])),D=new Set,L=n.form.headers.map(l=>{const p=l.key.trim(),f=l.value.trim();if(!p&&!f)return{};const P=p?D.has(p.toLowerCase())?n.t("provider.custom.error.duplicate"):(()=>{D.add(p.toLowerCase())})():n.t("provider.custom.error.required"),E=f?void 0:n.t("provider.custom.error.required");return{key:P,value:E}}),e=L.every(l=>!l.key&&!l.value),i=Object.fromEntries(n.form.headers.map(l=>({key:l.key.trim(),value:l.value.trim()})).filter(l=>!!l.key&&!!l.value).map(l=>[l.key,l.value])),m={providerID:t??_,name:u,baseURL:g};return!t&&!_&&!u&&!g&&M&&e?{err:m,models:S,headers:L,result:{providerID:h,name:s,key:v,config:{npm:he,name:s,...d?{env:[d]}:{},options:{baseURL:x,...Object.keys(i).length?{headers:i}:{}},models:q}}}:{err:m,models:S,headers:L}}let be=0;const oe=()=>`row-${be++}`,J=()=>({row:oe(),id:"",name:"",err:{}}),Q=()=>({row:oe(),key:"",value:"",err:{}});var xe=B('<div class="flex flex-col gap-6 px-2.5 pb-3 overflow-y-auto max-h-[60vh]"><div class="px-2.5 flex gap-4 items-center"><div class="text-16-medium text-text-strong"></div></div><form class="px-2.5 pb-6 flex flex-col gap-6"><p class="text-14-regular text-text-base"></p><div class="flex flex-col gap-4"></div><div class="flex flex-col gap-3"><label class="text-12-medium text-text-weak"></label></div><div class="flex flex-col gap-3"><label class="text-12-medium text-text-weak">'),X=B('<div class="flex gap-2 items-start"><div class=flex-1></div><div class=flex-1>');function ye(n){const h=Z(),s=le(),x=ne(),r=ee(),[d,v]=se({providerID:"",name:"",baseURL:"",apiKey:"",models:[J()],headers:[Q()],err:{}}),t=()=>{if(n.back==="close"){h.close();return}h.show(()=>o(ae,{}))},u=()=>{v("models",z(e=>{e.push(J())}))},g=e=>{d.models.length<=1||v("models",z(i=>{i.splice(e,1)}))},y=()=>{v("headers",z(e=>{e.push(Q())}))},_=e=>{d.headers.length<=1||v("headers",z(i=>{i.splice(e,1)}))},w=(e,i)=>{v(e,i),e!=="apiKey"&&v("err",e,void 0)},S=(e,i,m)=>{G(()=>{v("models",e,i,m),v("models",e,"err",i,void 0)})},M=(e,i,m)=>{G(()=>{v("headers",e,i,m),v("headers",e,"err",i,void 0)})},q=()=>{const e=fe({form:d,t:r.t,disabledProviders:s.data.config.disabled_providers??[],existingProviderIDs:new Set(s.data.provider.all.map(i=>i.id))});return G(()=>{v("err",e.err),e.models.forEach((i,m)=>v("models",m,"err",i)),e.headers.forEach((i,m)=>v("headers",m,"err",i))}),e.result},D=de(()=>({mutationFn:async e=>{const m=(s.data.config.disabled_providers??[]).filter($=>$!==e.providerID);return e.key&&await x.client.auth.set({providerID:e.providerID,auth:{type:"api",key:e.key}}),await s.updateConfig({provider:{[e.providerID]:e.config},disabled_providers:m}),e},onSuccess:e=>{h.close(),V({variant:"success",icon:"circle-check",title:r.t("provider.connect.toast.connected.title",{provider:e.name}),description:r.t("provider.connect.toast.connected.description",{provider:e.name})})},onError:e=>{const i=e instanceof Error?e.message:String(e);V({title:r.t("common.requestFailed"),description:i})}})),L=e=>{if(e.preventDefault(),D.isPending)return;const i=q();i&&D.mutate(i)};return o(re,{get title(){return o(T,{tabIndex:-1,icon:"arrow-left",variant:"ghost",onClick:t,get"aria-label"(){return r.t("common.goBack")}})},transition:!0,get children(){var e=xe(),i=e.firstChild,m=i.firstChild,$=i.nextSibling,l=$.firstChild,p=l.nextSibling,f=p.nextSibling,P=f.firstChild,E=f.nextSibling,ie=E.firstChild;return a(i,o(te,{id:"synthetic",class:"size-5 shrink-0 icon-strong-base"}),m),a(m,()=>r.t("provider.custom.title")),$.addEventListener("submit",L),a(l,()=>r.t("provider.custom.description.prefix"),null),a(l,o(me,{href:"https://duckmind.ai/docs/providers/#custom-provider",tabIndex:-1,get children(){return r.t("provider.custom.description.link")}}),null),a(l,()=>r.t("provider.custom.description.suffix"),null),a(p,o(k,{autofocus:!0,get label(){return r.t("provider.custom.field.providerID.label")},get placeholder(){return r.t("provider.custom.field.providerID.placeholder")},get description(){return r.t("provider.custom.field.providerID.description")},get value(){return d.providerID},onChange:c=>w("providerID",c),get validationState(){return d.err.providerID?"invalid":void 0},get error(){return d.err.providerID}}),null),a(p,o(k,{get label(){return r.t("provider.custom.field.name.label")},get placeholder(){return r.t("provider.custom.field.name.placeholder")},get value(){return d.name},onChange:c=>w("name",c),get validationState(){return d.err.name?"invalid":void 0},get error(){return d.err.name}}),null),a(p,o(k,{get label(){return r.t("provider.custom.field.baseURL.label")},get placeholder(){return r.t("provider.custom.field.baseURL.placeholder")},get value(){return d.baseURL},onChange:c=>w("baseURL",c),get validationState(){return d.err.baseURL?"invalid":void 0},get error(){return d.err.baseURL}}),null),a(p,o(k,{get label(){return r.t("provider.custom.field.apiKey.label")},get placeholder(){return r.t("provider.custom.field.apiKey.placeholder")},get description(){return r.t("provider.custom.field.apiKey.description")},get value(){return d.apiKey},onChange:c=>w("apiKey",c)}),null),a(P,()=>r.t("provider.custom.models.label")),a(f,o(A,{get each(){return d.models},children:(c,C)=>(()=>{var b=X(),R=b.firstChild,F=R.nextSibling;return a(R,o(k,{get label(){return r.t("provider.custom.models.id.label")},hideLabel:!0,get placeholder(){return r.t("provider.custom.models.id.placeholder")},get value(){return c.id},onChange:I=>S(C(),"id",I),get validationState(){return c.err.id?"invalid":void 0},get error(){return c.err.id}})),a(F,o(k,{get label(){return r.t("provider.custom.models.name.label")},hideLabel:!0,get placeholder(){return r.t("provider.custom.models.name.placeholder")},get value(){return c.name},onChange:I=>S(C(),"name",I),get validationState(){return c.err.name?"invalid":void 0},get error(){return c.err.name}})),a(b,o(T,{type:"button",icon:"trash",variant:"ghost",class:"mt-1.5",onClick:()=>g(C()),get disabled(){return d.models.length<=1},get"aria-label"(){return r.t("provider.custom.models.remove")}}),null),W(()=>N(b,"data-row",c.row)),b})()}),null),a(f,o(j,{type:"button",size:"small",variant:"ghost",icon:"plus-small",onClick:u,class:"self-start",get children(){return r.t("provider.custom.models.add")}}),null),a(ie,()=>r.t("provider.custom.headers.label")),a(E,o(A,{get each(){return d.headers},children:(c,C)=>(()=>{var b=X(),R=b.firstChild,F=R.nextSibling;return a(R,o(k,{get label(){return r.t("provider.custom.headers.key.label")},hideLabel:!0,get placeholder(){return r.t("provider.custom.headers.key.placeholder")},get value(){return c.key},onChange:I=>M(C(),"key",I),get validationState(){return c.err.key?"invalid":void 0},get error(){return c.err.key}})),a(F,o(k,{get label(){return r.t("provider.custom.headers.value.label")},hideLabel:!0,get placeholder(){return r.t("provider.custom.headers.value.placeholder")},get value(){return c.value},onChange:I=>M(C(),"value",I),get validationState(){return c.err.value?"invalid":void 0},get error(){return c.err.value}})),a(b,o(T,{type:"button",icon:"trash",variant:"ghost",class:"mt-1.5",onClick:()=>_(C()),get disabled(){return d.headers.length<=1},get"aria-label"(){return r.t("provider.custom.headers.remove")}}),null),W(()=>N(b,"data-row",c.row)),b})()}),null),a(E,o(j,{type:"button",size:"small",variant:"ghost",icon:"plus-small",onClick:y,class:"self-start",get children(){return r.t("provider.custom.headers.add")}}),null),a($,o(j,{class:"w-auto self-start",type:"submit",size:"large",variant:"primary",get disabled(){return D.isPending},get children(){return ce(()=>!!D.isPending)()?r.t("common.saving"):r.t("common.submit")}}),null),e}})}var Y=B('<div class="text-14-regular text-text-weak">'),ke=B('<div class="px-1.25 w-full flex items-center gap-x-3"><span>');const O="_custom",ae=()=>{const n=Z(),h=ue(),s=ee(),x=()=>s.t("dialog.provider.group.popular"),r=()=>s.t("dialog.provider.group.other"),d=()=>s.t("settings.providers.tag.custom"),v=t=>{if(t==="anthropic")return s.t("dialog.provider.anthropic.note");if(t==="openai")return s.t("dialog.provider.openai.note");if(t.startsWith("github-copilot"))return s.t("dialog.provider.copilot.note");if(t==="duckmind-go")return s.t("dialog.provider.duckmindGo.tagline")};return o(re,{get title(){return s.t("command.provider.connect")},transition:!0,get children(){return o(ve,{get search(){return{placeholder:s.t("dialog.provider.search.placeholder"),autofocus:!0}},get emptyMessage(){return s.t("dialog.provider.empty")},activeIcon:"plus-small",key:t=>t?.id,items:()=>(s.locale(),[{id:O,name:d()},...h.all()]),filterKeys:["id","name"],groupBy:t=>K.includes(t.id)?x():r(),sortBy:(t,u)=>t.id===O?-1:u.id===O?1:K.includes(t.id)&&K.includes(u.id)?K.indexOf(t.id)-K.indexOf(u.id):t.name.localeCompare(u.name),sortGroupsBy:(t,u)=>{const g=x();return t.category===g&&u.category!==g?-1:u.category===g&&t.category!==g?1:0},onSelect:t=>{if(t){if(t.id===O){n.show(()=>o(ye,{back:"providers"}));return}n.show(()=>o(pe,{get provider(){return t.id}}))}},children:t=>(()=>{var u=ke(),g=u.firstChild;return a(u,o(te,{"data-slot":"list-item-extra-icon",get id(){return t.id}}),g),a(g,()=>t.name),a(u,o(U,{get when(){return t.id==="duckmind"},get children(){var y=Y();return a(y,()=>s.t("dialog.provider.duckmind.tagline")),y}}),null),a(u,o(U,{get when(){return t.id===O},get children(){return o(H,{get children(){return s.t("settings.providers.tag.custom")}})}}),null),a(u,o(U,{get when(){return t.id==="duckmind"},get children(){return o(H,{get children(){return s.t("dialog.provider.tag.recommended")}})}}),null),a(u,o(U,{get when(){return v(t.id)},children:y=>(()=>{var _=Y();return a(_,y),_})()}),null),a(u,o(U,{get when(){return t.id==="duckmind-go"},get children(){return o(H,{get children(){return s.t("dialog.provider.tag.recommended")}})}}),null),u})()})}})},Ie=Object.freeze(Object.defineProperty({__proto__:null,DialogSelectProvider:ae},Symbol.toStringTag,{value:"Module"}));export{ye as D,ae as a,Ie as d};
@@ -1 +1 @@
1
- import{d as me,c as he,e as fe,b as Y,f as R,c3 as Z,n as pe,b2 as G,c4 as z,c5 as h,g as C,o as J,q as Se,i as S,h as a,a5 as O,m as w,$,I as we,ai as p,B as Q,aV as ye,ay as be,c6 as ke,t as F,bz as N,al as Ce}from"./index-Bj2ueAL8.js";import{L as xe}from"./list-FNV9nNTY.js";import{S as _e,a as Pe}from"./server-row--RKYaqbn.js";var De=F('<div class=px-5><div class="bg-surface-base rounded-md p-5 flex flex-col gap-3"><div class="flex-1 min-w-0 [&amp;_[data-slot=input-wrapper]]:relative"></div><div class="grid grid-cols-2 gap-2 min-w-0">'),$e=F('<div class="flex items-center gap-2 -ml-2"><span>'),Ie=F('<div class="flex flex-col gap-2"><div class="px-5 pb-5">'),Ee=F('<div class="flex items-center gap-3 min-w-0 flex-1 w-full group/item"><div class="flex flex-col h-full items-start w-5"></div><div class="flex items-center justify-center gap-4 pl-4">'),Ae=F('<span class="text-text-base bg-surface-base text-14-regular px-1.5 rounded-xs">');const K="duckmind";function X(i,l){Ce({variant:"error",title:i.t("common.requestFailed"),description:l instanceof Error?l.message:String(l)})}function Fe(){const i=R(),l=Y(),[o,u]=be(async()=>{try{const g=await l.getDefaultServer?.();return g||null}catch(g){return X(i,g),null}},{initialValue:null}),s=C(()=>!!l.getDefaultServer&&!!l.setDefaultServer);return{defaultKey:o,canDefault:s,setDefault:async g=>{try{await l.setDefaultServer?.(g),u.mutate(g)}catch(x){X(i,x)}}}}function Me(){const i=Z(),l=u=>{const s=z(u);if(!s)return!1;const m=s.replace(/^https?:\/\//,"").split("/")[0];return m?m.includes("localhost")||m.startsWith("127.0.0.1")?!0:m.includes(".")||m.includes(":"):!1};return{previewStatus:async(u,s,m,g)=>{if(g(void 0),!l(u))return;const x=z(u);if(!x)return;const y={url:x};s&&(y.username=s),m&&(y.password=m);const A=await i(y);g(A.healthy)}}}function Ne(i){const l=R(),o=u=>{if(u.stopPropagation(),u.key==="Escape"){u.preventDefault(),i.onBack();return}u.key!=="Enter"||u.isComposing||(u.preventDefault(),i.onSubmit())};return(()=>{var u=De(),s=u.firstChild,m=s.firstChild,g=m.nextSibling;return S(m,a(N,{type:"text",get label(){return l.t("dialog.server.add.url")},get placeholder(){return i.placeholder},get value(){return i.value},autofocus:!0,get validationState(){return i.error?"invalid":"valid"},get error(){return i.error},get disabled(){return i.busy},get onChange(){return i.onChange},onKeyDown:o})),S(s,a(N,{type:"text",get label(){return l.t("dialog.server.add.name")},get placeholder(){return l.t("dialog.server.add.namePlaceholder")},get value(){return i.name},get disabled(){return i.busy},get onChange(){return i.onNameChange},onKeyDown:o}),g),S(g,a(N,{type:"text",get label(){return l.t("dialog.server.add.username")},get placeholder(){return l.t("dialog.server.add.usernamePlaceholder")},get value(){return i.username},get disabled(){return i.busy},get onChange(){return i.onUsernameChange},onKeyDown:o}),null),S(g,a(N,{type:"password",get label(){return l.t("dialog.server.add.password")},get placeholder(){return l.t("dialog.server.add.passwordPlaceholder")},get value(){return i.password},get disabled(){return i.busy},get onChange(){return i.onPasswordChange},onKeyDown:o}),null),u})()}function Be(){const i=me(),l=he(),o=fe(),u=Y(),s=R(),{defaultKey:m,canDefault:g,setDefault:x}=Fe(),{previewStatus:y}=Me(),A=Z(),[r,d]=pe({status:{},addServer:{url:"",name:"",username:K,password:"",error:"",showForm:!1,status:void 0},editServer:{id:void 0,value:"",name:"",username:"",password:"",error:"",status:void 0}}),M=()=>{d("addServer",{url:"",name:"",username:K,password:"",error:"",showForm:!1,status:void 0})},I=()=>{d("editServer",{id:void 0,value:"",name:"",username:"",password:"",error:"",status:void 0})},_=G(()=>({mutationFn:async e=>{const t=z(e);if(!t){M();return}const n={type:"http",http:{url:t}};if(r.addServer.name.trim()&&(n.displayName=r.addServer.name.trim()),r.addServer.password&&(n.http.password=r.addServer.password),r.addServer.password&&r.addServer.username&&(n.http.username=r.addServer.username),!(await A(n.http)).healthy){d("addServer",{error:s.t("dialog.server.add.error")});return}M(),await q(n,!0)}})),P=G(()=>({mutationFn:async e=>{if(e.original.type!=="http")return;const t=z(e.value);if(!t){I();return}const n=r.editServer.name.trim()||void 0,v=r.editServer.username||void 0,c=r.editServer.password||void 0,b=e.original.displayName;if(t===e.original.http.url&&n===b&&v===e.original.http.username&&c===e.original.http.password){I();return}const k={type:"http",displayName:n,http:{url:t,username:v,password:c}};if(!(await A(k.http)).healthy){d("editServer",{error:s.t("dialog.server.add.error")});return}t===e.original.http.url?o.add(k):ee(e.original,k),I()}})),ee=(e,t)=>{const n=o.key,v=o.add(t);if(!v)return;const c=n===h.key(e)?h.key(v):n;c&&o.setActive(c),o.remove(h.key(e))},E=C(()=>{const e=o.current,t=o.list;return e?t.includes(e)?[e,...t.filter(n=>n!==e)]:[e,...t]:t}),H=C(()=>E().find(e=>h.key(e)===o.key)??E()[0]),re=C(()=>{const e=E();if(!e.length)return e;const t=H(),n=new Map(e.map((c,b)=>[c,b])),v=c=>c?.healthy===!0?0:c?.healthy===!1?2:1;return e.slice().sort((c,b)=>{if(c===t)return-1;if(b===t)return 1;const k=v(r.status[h.key(c)])-v(r.status[h.key(b)]);return k!==0?k:(n.get(c)??0)-(n.get(b)??0)})});async function T(){const e={};await Promise.all(E().map(async t=>{e[h.key(t)]=await A(t.http)})),d("status",ke(e))}J(()=>{E(),T();const e=setInterval(T,1e4);Se(()=>clearInterval(e))});async function q(e,t){if(!(!t&&r.status[h.key(e)]?.healthy===!1)){if(l.close(),t&&e.type==="http"){o.add(e),i("/");return}i("/"),queueMicrotask(()=>o.setActive(h.key(e)))}}const te=e=>{_.isPending||(d("addServer",{url:e,error:""}),y(e,r.addServer.username,r.addServer.password,t=>d("addServer",{status:t})))},ae=e=>{_.isPending||d("addServer",{name:e,error:""})},ne=e=>{_.isPending||(d("addServer",{username:e,error:""}),y(r.addServer.url,e,r.addServer.password,t=>d("addServer",{status:t})))},se=e=>{_.isPending||(d("addServer",{password:e,error:""}),y(r.addServer.url,r.addServer.username,e,t=>d("addServer",{status:t})))},ie=e=>{P.isPending||(d("editServer",{value:e,error:""}),y(e,r.editServer.username,r.editServer.password,t=>d("editServer",{status:t})))},de=e=>{P.isPending||d("editServer",{name:e,error:""})},le=e=>{P.isPending||(d("editServer",{username:e,error:""}),y(r.editServer.value,e,r.editServer.password,t=>d("editServer",{status:t})))},oe=e=>{P.isPending||(d("editServer",{password:e,error:""}),y(r.editServer.value,r.editServer.username,e,t=>d("editServer",{status:t})))},L=C(()=>r.editServer.id?"edit":r.addServer.showForm?"add":"list"),V=C(()=>{if(r.editServer.id)return E().find(e=>e.type==="http"&&e.http.url===r.editServer.id)}),j=()=>{M(),I()},ue=()=>{I(),d("addServer",{showForm:!0,url:"",name:"",username:K,password:"",error:"",status:void 0})},ce=e=>{M(),d("editServer",{id:e.http.url,value:e.http.url,name:e.displayName??"",username:e.http.username??"",password:e.http.password??"",error:"",status:r.status[h.key(e)]?.healthy})},W=()=>{if(L()==="add"){if(_.isPending)return;d("addServer",{error:""}),_.mutate(r.addServer.url);return}const e=V();e&&(P.isPending||(d("editServer",{error:""}),P.mutate({original:e,value:r.editServer.value})))},U=C(()=>L()!=="list"),f=C(()=>L()==="add"),B=C(()=>f()?_.isPending:P.isPending),ge=C(()=>U()?(()=>{var e=$e(),t=e.firstChild;return S(e,a(O,{icon:"arrow-left",variant:"ghost",onClick:j,get"aria-label"(){return s.t("common.goBack")}}),t),S(t,(()=>{var n=w(()=>!!f());return()=>n()?s.t("dialog.server.add.title"):s.t("dialog.server.edit.title")})()),e})():s.t("dialog.server.title"));J(()=>{r.editServer.id&&(V()||I())});async function ve(e){o.remove(e),await u.getDefaultServer?.()===e&&u.setDefaultServer?.(null)}return a(ye,{get title(){return ge()},get children(){var e=Ie(),t=e.firstChild;return S(e,a($,{get when(){return!U()},get fallback(){return a(Ne,{get value(){return w(()=>!!f())()?r.addServer.url:r.editServer.value},get name(){return w(()=>!!f())()?r.addServer.name:r.editServer.name},get username(){return w(()=>!!f())()?r.addServer.username:r.editServer.username},get password(){return w(()=>!!f())()?r.addServer.password:r.editServer.password},get placeholder(){return s.t("dialog.server.add.placeholder")},get busy(){return B()},get error(){return w(()=>!!f())()?r.addServer.error:r.editServer.error},get status(){return w(()=>!!f())()?r.addServer.status:r.editServer.status},get onChange(){return f()?te:ie},get onNameChange(){return f()?ae:de},get onUsernameChange(){return f()?ne:le},get onPasswordChange(){return f()?se:oe},onSubmit:W,onBack:j})},get children(){return a(xe,{get search(){return{placeholder:s.t("dialog.server.search.placeholder"),autofocus:!1}},noInitialSelection:!0,get emptyMessage(){return s.t("dialog.server.empty")},items:re,key:n=>n.http.url,onSelect:n=>{n&&q(n)},divider:!0,class:"px-5 [&_[data-slot=list-search-wrapper]]:w-full [&_[data-slot=list-scroll]]h-[300px] [&_[data-slot=list-scroll]]:overflow-y-auto [&_[data-slot=list-items]]:bg-surface-base [&_[data-slot=list-items]]:rounded-md [&_[data-slot=list-item]]:min-h-14 [&_[data-slot=list-item]]:p-3 [&_[data-slot=list-item]]:!bg-transparent",children:n=>{const v=h.key(n);return(()=>{var c=Ee(),b=c.firstChild,k=b.nextSibling;return S(b,a(_e,{get health(){return r.status[v]}})),S(c,a(Pe,{conn:n,get dimmed(){return r.status[v]?.healthy===!1},get status(){return r.status[v]},class:"flex items-center gap-3 min-w-0 flex-1",get badge(){return a($,{get when(){return m()===h.key(n)},get children(){var D=Ae();return S(D,()=>s.t("dialog.server.status.default")),D}})},showCredentials:!0}),k),S(k,a($,{get when(){return h.key(H())===v},get children(){return a(we,{name:"check",class:"h-6"})}}),null),S(k,a($,{get when(){return n.type==="http"},get children(){return a(p,{get children(){return[a(p.Trigger,{as:O,icon:"dot-grid",variant:"ghost",class:"shrink-0 size-8 hover:bg-surface-base-hover data-[expanded]:bg-surface-base-active",onClick:D=>D.stopPropagation(),onPointerDown:D=>D.stopPropagation()}),a(p.Portal,{get children(){return a(p.Content,{class:"mt-1",get children(){return[a(p.Item,{onSelect:()=>{n.type==="http"&&ce(n)},get children(){return a(p.ItemLabel,{get children(){return s.t("dialog.server.menu.edit")}})}}),a($,{get when(){return w(()=>!!g())()&&m()!==v},get children(){return a(p.Item,{onSelect:()=>x(v),get children(){return a(p.ItemLabel,{get children(){return s.t("dialog.server.menu.default")}})}})}}),a($,{get when(){return w(()=>!!g())()&&m()===v},get children(){return a(p.Item,{onSelect:()=>x(null),get children(){return a(p.ItemLabel,{get children(){return s.t("dialog.server.menu.defaultRemove")}})}})}}),a(p.Separator,{}),a(p.Item,{onSelect:()=>ve(h.key(n)),class:"text-text-on-critical-base hover:bg-surface-critical-weak",get children(){return a(p.ItemLabel,{get children(){return s.t("dialog.server.menu.delete")}})}})]}})}})]}})}}),null),c})()}})}}),t),S(t,a($,{get when(){return U()},get fallback(){return a(Q,{variant:"secondary",icon:"plus-small",size:"large",onClick:ue,class:"py-1.5 pl-1.5 pr-3 flex items-center gap-1.5",get children(){return s.t("dialog.server.add.button")}})},get children(){return a(Q,{variant:"primary",size:"large",onClick:W,get disabled(){return B()},class:"px-3 py-1.5",get children(){return w(()=>!!B())()?s.t("dialog.server.add.checking"):w(()=>!!f())()?s.t("dialog.server.add.button"):s.t("common.save")}})}})),e}})}export{Be as DialogSelectServer};
1
+ import{d as me,c as he,e as fe,b as Y,f as R,c3 as Z,n as pe,b2 as G,c4 as z,c5 as h,g as C,o as J,q as Se,i as S,h as a,a5 as O,m as w,$,I as we,ai as p,B as Q,aV as ye,ay as be,c6 as ke,t as F,bz as N,al as Ce}from"./index-D-WWa_X8.js";import{L as xe}from"./list-Dk_vU1zd.js";import{S as _e,a as Pe}from"./server-row-LxKRQxMm.js";var De=F('<div class=px-5><div class="bg-surface-base rounded-md p-5 flex flex-col gap-3"><div class="flex-1 min-w-0 [&amp;_[data-slot=input-wrapper]]:relative"></div><div class="grid grid-cols-2 gap-2 min-w-0">'),$e=F('<div class="flex items-center gap-2 -ml-2"><span>'),Ie=F('<div class="flex flex-col gap-2"><div class="px-5 pb-5">'),Ee=F('<div class="flex items-center gap-3 min-w-0 flex-1 w-full group/item"><div class="flex flex-col h-full items-start w-5"></div><div class="flex items-center justify-center gap-4 pl-4">'),Ae=F('<span class="text-text-base bg-surface-base text-14-regular px-1.5 rounded-xs">');const K="duckmind";function X(i,l){Ce({variant:"error",title:i.t("common.requestFailed"),description:l instanceof Error?l.message:String(l)})}function Fe(){const i=R(),l=Y(),[o,u]=be(async()=>{try{const g=await l.getDefaultServer?.();return g||null}catch(g){return X(i,g),null}},{initialValue:null}),s=C(()=>!!l.getDefaultServer&&!!l.setDefaultServer);return{defaultKey:o,canDefault:s,setDefault:async g=>{try{await l.setDefaultServer?.(g),u.mutate(g)}catch(x){X(i,x)}}}}function Me(){const i=Z(),l=u=>{const s=z(u);if(!s)return!1;const m=s.replace(/^https?:\/\//,"").split("/")[0];return m?m.includes("localhost")||m.startsWith("127.0.0.1")?!0:m.includes(".")||m.includes(":"):!1};return{previewStatus:async(u,s,m,g)=>{if(g(void 0),!l(u))return;const x=z(u);if(!x)return;const y={url:x};s&&(y.username=s),m&&(y.password=m);const A=await i(y);g(A.healthy)}}}function Ne(i){const l=R(),o=u=>{if(u.stopPropagation(),u.key==="Escape"){u.preventDefault(),i.onBack();return}u.key!=="Enter"||u.isComposing||(u.preventDefault(),i.onSubmit())};return(()=>{var u=De(),s=u.firstChild,m=s.firstChild,g=m.nextSibling;return S(m,a(N,{type:"text",get label(){return l.t("dialog.server.add.url")},get placeholder(){return i.placeholder},get value(){return i.value},autofocus:!0,get validationState(){return i.error?"invalid":"valid"},get error(){return i.error},get disabled(){return i.busy},get onChange(){return i.onChange},onKeyDown:o})),S(s,a(N,{type:"text",get label(){return l.t("dialog.server.add.name")},get placeholder(){return l.t("dialog.server.add.namePlaceholder")},get value(){return i.name},get disabled(){return i.busy},get onChange(){return i.onNameChange},onKeyDown:o}),g),S(g,a(N,{type:"text",get label(){return l.t("dialog.server.add.username")},get placeholder(){return l.t("dialog.server.add.usernamePlaceholder")},get value(){return i.username},get disabled(){return i.busy},get onChange(){return i.onUsernameChange},onKeyDown:o}),null),S(g,a(N,{type:"password",get label(){return l.t("dialog.server.add.password")},get placeholder(){return l.t("dialog.server.add.passwordPlaceholder")},get value(){return i.password},get disabled(){return i.busy},get onChange(){return i.onPasswordChange},onKeyDown:o}),null),u})()}function Be(){const i=me(),l=he(),o=fe(),u=Y(),s=R(),{defaultKey:m,canDefault:g,setDefault:x}=Fe(),{previewStatus:y}=Me(),A=Z(),[r,d]=pe({status:{},addServer:{url:"",name:"",username:K,password:"",error:"",showForm:!1,status:void 0},editServer:{id:void 0,value:"",name:"",username:"",password:"",error:"",status:void 0}}),M=()=>{d("addServer",{url:"",name:"",username:K,password:"",error:"",showForm:!1,status:void 0})},I=()=>{d("editServer",{id:void 0,value:"",name:"",username:"",password:"",error:"",status:void 0})},_=G(()=>({mutationFn:async e=>{const t=z(e);if(!t){M();return}const n={type:"http",http:{url:t}};if(r.addServer.name.trim()&&(n.displayName=r.addServer.name.trim()),r.addServer.password&&(n.http.password=r.addServer.password),r.addServer.password&&r.addServer.username&&(n.http.username=r.addServer.username),!(await A(n.http)).healthy){d("addServer",{error:s.t("dialog.server.add.error")});return}M(),await q(n,!0)}})),P=G(()=>({mutationFn:async e=>{if(e.original.type!=="http")return;const t=z(e.value);if(!t){I();return}const n=r.editServer.name.trim()||void 0,v=r.editServer.username||void 0,c=r.editServer.password||void 0,b=e.original.displayName;if(t===e.original.http.url&&n===b&&v===e.original.http.username&&c===e.original.http.password){I();return}const k={type:"http",displayName:n,http:{url:t,username:v,password:c}};if(!(await A(k.http)).healthy){d("editServer",{error:s.t("dialog.server.add.error")});return}t===e.original.http.url?o.add(k):ee(e.original,k),I()}})),ee=(e,t)=>{const n=o.key,v=o.add(t);if(!v)return;const c=n===h.key(e)?h.key(v):n;c&&o.setActive(c),o.remove(h.key(e))},E=C(()=>{const e=o.current,t=o.list;return e?t.includes(e)?[e,...t.filter(n=>n!==e)]:[e,...t]:t}),H=C(()=>E().find(e=>h.key(e)===o.key)??E()[0]),re=C(()=>{const e=E();if(!e.length)return e;const t=H(),n=new Map(e.map((c,b)=>[c,b])),v=c=>c?.healthy===!0?0:c?.healthy===!1?2:1;return e.slice().sort((c,b)=>{if(c===t)return-1;if(b===t)return 1;const k=v(r.status[h.key(c)])-v(r.status[h.key(b)]);return k!==0?k:(n.get(c)??0)-(n.get(b)??0)})});async function T(){const e={};await Promise.all(E().map(async t=>{e[h.key(t)]=await A(t.http)})),d("status",ke(e))}J(()=>{E(),T();const e=setInterval(T,1e4);Se(()=>clearInterval(e))});async function q(e,t){if(!(!t&&r.status[h.key(e)]?.healthy===!1)){if(l.close(),t&&e.type==="http"){o.add(e),i("/");return}i("/"),queueMicrotask(()=>o.setActive(h.key(e)))}}const te=e=>{_.isPending||(d("addServer",{url:e,error:""}),y(e,r.addServer.username,r.addServer.password,t=>d("addServer",{status:t})))},ae=e=>{_.isPending||d("addServer",{name:e,error:""})},ne=e=>{_.isPending||(d("addServer",{username:e,error:""}),y(r.addServer.url,e,r.addServer.password,t=>d("addServer",{status:t})))},se=e=>{_.isPending||(d("addServer",{password:e,error:""}),y(r.addServer.url,r.addServer.username,e,t=>d("addServer",{status:t})))},ie=e=>{P.isPending||(d("editServer",{value:e,error:""}),y(e,r.editServer.username,r.editServer.password,t=>d("editServer",{status:t})))},de=e=>{P.isPending||d("editServer",{name:e,error:""})},le=e=>{P.isPending||(d("editServer",{username:e,error:""}),y(r.editServer.value,e,r.editServer.password,t=>d("editServer",{status:t})))},oe=e=>{P.isPending||(d("editServer",{password:e,error:""}),y(r.editServer.value,r.editServer.username,e,t=>d("editServer",{status:t})))},L=C(()=>r.editServer.id?"edit":r.addServer.showForm?"add":"list"),V=C(()=>{if(r.editServer.id)return E().find(e=>e.type==="http"&&e.http.url===r.editServer.id)}),j=()=>{M(),I()},ue=()=>{I(),d("addServer",{showForm:!0,url:"",name:"",username:K,password:"",error:"",status:void 0})},ce=e=>{M(),d("editServer",{id:e.http.url,value:e.http.url,name:e.displayName??"",username:e.http.username??"",password:e.http.password??"",error:"",status:r.status[h.key(e)]?.healthy})},W=()=>{if(L()==="add"){if(_.isPending)return;d("addServer",{error:""}),_.mutate(r.addServer.url);return}const e=V();e&&(P.isPending||(d("editServer",{error:""}),P.mutate({original:e,value:r.editServer.value})))},U=C(()=>L()!=="list"),f=C(()=>L()==="add"),B=C(()=>f()?_.isPending:P.isPending),ge=C(()=>U()?(()=>{var e=$e(),t=e.firstChild;return S(e,a(O,{icon:"arrow-left",variant:"ghost",onClick:j,get"aria-label"(){return s.t("common.goBack")}}),t),S(t,(()=>{var n=w(()=>!!f());return()=>n()?s.t("dialog.server.add.title"):s.t("dialog.server.edit.title")})()),e})():s.t("dialog.server.title"));J(()=>{r.editServer.id&&(V()||I())});async function ve(e){o.remove(e),await u.getDefaultServer?.()===e&&u.setDefaultServer?.(null)}return a(ye,{get title(){return ge()},get children(){var e=Ie(),t=e.firstChild;return S(e,a($,{get when(){return!U()},get fallback(){return a(Ne,{get value(){return w(()=>!!f())()?r.addServer.url:r.editServer.value},get name(){return w(()=>!!f())()?r.addServer.name:r.editServer.name},get username(){return w(()=>!!f())()?r.addServer.username:r.editServer.username},get password(){return w(()=>!!f())()?r.addServer.password:r.editServer.password},get placeholder(){return s.t("dialog.server.add.placeholder")},get busy(){return B()},get error(){return w(()=>!!f())()?r.addServer.error:r.editServer.error},get status(){return w(()=>!!f())()?r.addServer.status:r.editServer.status},get onChange(){return f()?te:ie},get onNameChange(){return f()?ae:de},get onUsernameChange(){return f()?ne:le},get onPasswordChange(){return f()?se:oe},onSubmit:W,onBack:j})},get children(){return a(xe,{get search(){return{placeholder:s.t("dialog.server.search.placeholder"),autofocus:!1}},noInitialSelection:!0,get emptyMessage(){return s.t("dialog.server.empty")},items:re,key:n=>n.http.url,onSelect:n=>{n&&q(n)},divider:!0,class:"px-5 [&_[data-slot=list-search-wrapper]]:w-full [&_[data-slot=list-scroll]]h-[300px] [&_[data-slot=list-scroll]]:overflow-y-auto [&_[data-slot=list-items]]:bg-surface-base [&_[data-slot=list-items]]:rounded-md [&_[data-slot=list-item]]:min-h-14 [&_[data-slot=list-item]]:p-3 [&_[data-slot=list-item]]:!bg-transparent",children:n=>{const v=h.key(n);return(()=>{var c=Ee(),b=c.firstChild,k=b.nextSibling;return S(b,a(_e,{get health(){return r.status[v]}})),S(c,a(Pe,{conn:n,get dimmed(){return r.status[v]?.healthy===!1},get status(){return r.status[v]},class:"flex items-center gap-3 min-w-0 flex-1",get badge(){return a($,{get when(){return m()===h.key(n)},get children(){var D=Ae();return S(D,()=>s.t("dialog.server.status.default")),D}})},showCredentials:!0}),k),S(k,a($,{get when(){return h.key(H())===v},get children(){return a(we,{name:"check",class:"h-6"})}}),null),S(k,a($,{get when(){return n.type==="http"},get children(){return a(p,{get children(){return[a(p.Trigger,{as:O,icon:"dot-grid",variant:"ghost",class:"shrink-0 size-8 hover:bg-surface-base-hover data-[expanded]:bg-surface-base-active",onClick:D=>D.stopPropagation(),onPointerDown:D=>D.stopPropagation()}),a(p.Portal,{get children(){return a(p.Content,{class:"mt-1",get children(){return[a(p.Item,{onSelect:()=>{n.type==="http"&&ce(n)},get children(){return a(p.ItemLabel,{get children(){return s.t("dialog.server.menu.edit")}})}}),a($,{get when(){return w(()=>!!g())()&&m()!==v},get children(){return a(p.Item,{onSelect:()=>x(v),get children(){return a(p.ItemLabel,{get children(){return s.t("dialog.server.menu.default")}})}})}}),a($,{get when(){return w(()=>!!g())()&&m()===v},get children(){return a(p.Item,{onSelect:()=>x(null),get children(){return a(p.ItemLabel,{get children(){return s.t("dialog.server.menu.defaultRemove")}})}})}}),a(p.Separator,{}),a(p.Item,{onSelect:()=>ve(h.key(n)),class:"text-text-on-critical-base hover:bg-surface-critical-weak",get children(){return a(p.ItemLabel,{get children(){return s.t("dialog.server.menu.delete")}})}})]}})}})]}})}}),null),c})()}})}}),t),S(t,a($,{get when(){return U()},get fallback(){return a(Q,{variant:"secondary",icon:"plus-small",size:"large",onClick:ue,class:"py-1.5 pl-1.5 pr-3 flex items-center gap-1.5",get children(){return s.t("dialog.server.add.button")}})},get children(){return a(Q,{variant:"primary",size:"large",onClick:W,get disabled(){return B()},class:"px-3 py-1.5",get children(){return w(()=>!!B())()?s.t("dialog.server.add.checking"):w(()=>!!f())()?s.t("dialog.server.add.button"):s.t("common.save")}})}})),e}})}export{Be as DialogSelectServer};