import{c as x,y as v,f as $,H as w,m as i,l,I as _,p as k,n as m,B as f,G as C,t as y}from"./index-Cl9Gy4vs.js";var D=y('<form class="flex flex-col gap-4 p-6 pt-0"><div class="flex items-center gap-2 text-12-regular text-text-weak"><span></span></div><div class="flex justify-end gap-2">'),S=y('<p class="text-12-regular text-red-500">');function z(b){const u=x(),g=v(),r=$(),[t,a]=w({url:"",busy:!1,error:""});async function p(){const e=t.url.trim();if(!(!e||t.busy)){a("busy",!0),a("error","");try{const n=await g.fetch(`${g.url}/global/clone`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})}),s=await n.json();if(!n.ok){a("error",s.error||r.t("dialog.clone.error"));return}b.onSelect(s.path),u.close()}catch{a("error",r.t("dialog.clone.error"))}finally{a("busy",!1)}}}function h(e){e.preventDefault(),p()}return i(C,{get title(){return r.t("dialog.clone.title")},class:"w-full max-w-[440px] mx-auto",get children(){var e=D(),n=e.firstChild,s=n.firstChild,c=n.nextSibling;return e.addEventListener("submit",h),l(n,i(_,{name:"branch",size:"small",class:"shrink-0 text-icon-weak"}),s),l(s,()=>r.t("dialog.clone.description")),l(e,i(k,{autofocus:!0,type:"url",placeholder:"https://github.com/owner/repo",get value(){return t.url},onChange:o=>a("url",o),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),p())}}),c),l(e,(()=>{var o=m(()=>!!t.error);return()=>o()&&(()=>{var d=S();return l(d,()=>t.error),d})()})(),c),l(c,i(f,{type:"button",variant:"ghost",size:"large",onClick:()=>u.close(),get children(){return r.t("common.cancel")}}),null),l(c,i(f,{type:"submit",variant:"primary",size:"large",get disabled(){return!t.url.trim()||t.busy},get children(){return m(()=>!!t.busy)()?r.t("common.loading"):r.t("dialog.clone.action")}}),null),e}})}export{z as DialogCloneProject};
