@kaitranntt/ccs 7.56.0-dev.2 → 7.56.0-dev.4

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 (54) hide show
  1. package/README.md +20 -11
  2. package/dist/bin/droid-runtime.d.ts +1 -0
  3. package/dist/bin/droid-runtime.d.ts.map +1 -0
  4. package/dist/bin/droid-runtime.js +5 -0
  5. package/dist/bin/droid-runtime.js.map +1 -0
  6. package/dist/commands/api-command/create-command.d.ts.map +1 -1
  7. package/dist/commands/api-command/create-command.js +8 -4
  8. package/dist/commands/api-command/create-command.js.map +1 -1
  9. package/dist/commands/cliproxy/variant-subcommand.d.ts.map +1 -1
  10. package/dist/commands/cliproxy/variant-subcommand.js +12 -6
  11. package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
  12. package/dist/commands/help-command.d.ts.map +1 -1
  13. package/dist/commands/help-command.js +9 -7
  14. package/dist/commands/help-command.js.map +1 -1
  15. package/dist/targets/target-resolver.d.ts +2 -2
  16. package/dist/targets/target-resolver.d.ts.map +1 -1
  17. package/dist/targets/target-resolver.js +68 -18
  18. package/dist/targets/target-resolver.js.map +1 -1
  19. package/dist/ui/assets/{accounts-BikRyqcT.js → accounts-BSknYWh4.js} +1 -1
  20. package/dist/ui/assets/{alert-dialog-CwEJfEUX.js → alert-dialog-BsXoK0Gt.js} +1 -1
  21. package/dist/ui/assets/api-C-ZXD7TW.js +4 -0
  22. package/dist/ui/assets/{auth-section-CrFrby6w.js → auth-section-CjGg1fit.js} +1 -1
  23. package/dist/ui/assets/{backups-section-CdMvSnSm.js → backups-section-fHW6gGBE.js} +1 -1
  24. package/dist/ui/assets/{checkbox-CC0rU-9-.js → checkbox-K93r237H.js} +1 -1
  25. package/dist/ui/assets/claude-extension-feiyhDgC.js +1 -0
  26. package/dist/ui/assets/{cliproxy-BSNSGNOv.js → cliproxy-CVv_-PsP.js} +2 -2
  27. package/dist/ui/assets/{cliproxy-ai-providers-D-U6NKfV.js → cliproxy-ai-providers-0JQCQ6YS.js} +12 -12
  28. package/dist/ui/assets/{cliproxy-control-panel-BCexyz40.js → cliproxy-control-panel-CrHA_sjo.js} +1 -1
  29. package/dist/ui/assets/{confirm-dialog-Bee0kh6i.js → confirm-dialog-_wN3tR_n.js} +1 -1
  30. package/dist/ui/assets/{copilot-BZRAvPLD.js → copilot-Cao_05p3.js} +2 -2
  31. package/dist/ui/assets/cursor-Cbe1L5vq.js +1 -0
  32. package/dist/ui/assets/{droid-CcKqoQtO.js → droid-Cu3rERcX.js} +2 -2
  33. package/dist/ui/assets/{globalenv-section-CBRvmZbS.js → globalenv-section-CtzXlKoL.js} +1 -1
  34. package/dist/ui/assets/{health-DgrTQESI.js → health-CjuQlQLu.js} +1 -1
  35. package/dist/ui/assets/{index-BOhcsuQK.js → index-17YWpyV1.js} +1 -1
  36. package/dist/ui/assets/{index-D90gSn57.js → index-B4MTOnn6.js} +1 -1
  37. package/dist/ui/assets/index-CKpdevWy.css +1 -0
  38. package/dist/ui/assets/{index-DJCPwAoe.js → index-CtS8lmbp.js} +1 -1
  39. package/dist/ui/assets/{index-CursmDny.js → index-DRuiCZZ-.js} +1 -1
  40. package/dist/ui/assets/index-gjtWXRc2.js +47 -0
  41. package/dist/ui/assets/{proxy-status-widget-C8cOlsqE.js → proxy-status-widget-9CJglirI.js} +1 -1
  42. package/dist/ui/assets/{searchable-select-CF22qEzz.js → searchable-select-CGOND84a.js} +1 -1
  43. package/dist/ui/assets/{separator-CAoIlNuN.js → separator-2e8ySql0.js} +1 -1
  44. package/dist/ui/assets/{shared-zeFjETE6.js → shared-598yR3xg.js} +1 -1
  45. package/dist/ui/assets/{switch-BeqpDfK5.js → switch-BUqDuRxm.js} +1 -1
  46. package/dist/ui/assets/{updates-By9S46EJ.js → updates-CQW2-eYw.js} +1 -1
  47. package/dist/ui/index.html +2 -2
  48. package/package.json +3 -2
  49. package/scripts/add-shebang.js +33 -20
  50. package/dist/ui/assets/api-BYSEdQYh.js +0 -4
  51. package/dist/ui/assets/claude-extension-CzGeZYz8.js +0 -1
  52. package/dist/ui/assets/cursor-CO2rCNKC.js +0 -1
  53. package/dist/ui/assets/index-kGiBvBM-.css +0 -1
  54. package/dist/ui/assets/index-sCtK1kDn.js +0 -47
@@ -1 +1 @@
1
- import{j as s}from"./radix-ui-Dt3edmE5.js";import{g as Se,r as j}from"./react-vendor-CNOkPC89.js";import{bm as me,bn as pe,bo as xe,bp as Ce,bq as _,br as Y,bs as U,bt as Ae,bu as we,a as Ee,bl as ke,aP as Ve,bv as Te,bw as Pe,bx as $e,by as We,bz as Ie,c as q,B as oe,aB as De,M as Oe,O as Re,r as Fe,s as Le,t as Ue,v as qe,w as Me,d as ne,T as _e,p as Be,q as ze,Y as He}from"./index-sCtK1kDn.js";import{A as Ke,a as Ze,b as Qe,c as Xe,d as Ye,e as Ge,f as Je,g as et}from"./alert-dialog-CwEJfEUX.js";import{u as fe,a as tt,b as st,e as nt}from"./tanstack-B8i0evp-.js";import{t as G}from"./notifications-B2HqRBj7.js";import{t as rt,A as at,R as z,b1 as it,b2 as ot,b3 as lt,X as ct,d as ut,b4 as dt,b5 as mt,U as pt,u as xt,l as ft,x as gt,as as ht,T as J,aG as yt}from"./icons-DR-ORtNe.js";var ee,le;function bt(){return le||(le=1,ee={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),ee}var jt=bt();const Nt=Se(jt);var vt=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function ce(e){var t={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(Nt[n[1]]||e.charAt(e.length-2)==="/")&&(t.voidElement=!0),t.name.startsWith("!--"))){var r=e.indexOf("-->");return{type:"comment",comment:r!==-1?e.slice(4,r):""}}for(var a=new RegExp(vt),i=null;(i=a.exec(e))!==null;)if(i[0].trim())if(i[1]){var o=i[1].trim(),c=[o,""];o.indexOf("=")>-1&&(c=o.split("=")),t.attrs[c[0]]=c[1],a.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}var St=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Ct=/^\s*$/,At=Object.create(null);function ge(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?(function(n){var r=[];for(var a in n)r.push(a+'="'+n[a]+'"');return r.length?" "+r.join(" "):""})(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(ge,"")+"</"+t.name+">";case"comment":return e+"<!--"+t.comment+"-->"}}var wt={parse:function(e,t){t||(t={}),t.components||(t.components=At);var n,r=[],a=[],i=-1,o=!1;if(e.indexOf("<")!==0){var c=e.indexOf("<");r.push({type:"text",content:c===-1?e:e.substring(0,c)})}return e.replace(St,function(d,u){if(o){if(d!=="</"+n.name+">")return;o=!1}var f,E=d.charAt(1)!=="/",V=d.startsWith("<!--"),p=u+d.length,m=e.charAt(p);if(V){var N=ce(d);return i<0?(r.push(N),r):((f=a[i]).children.push(N),r)}if(E&&(i++,(n=ce(d)).type==="tag"&&t.components[n.name]&&(n.type="component",o=!0),n.voidElement||o||!m||m==="<"||n.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),i===0&&r.push(n),(f=a[i-1])&&f.children.push(n),a[i]=n),(!E||n.voidElement)&&(i>-1&&(n.voidElement||n.name===d.slice(2,-1))&&(i--,n=i===-1?r:a[i]),!o&&m!=="<"&&m)){f=i===-1?r:a[i].children;var b=e.indexOf("<",p),P=e.slice(p,b===-1?void 0:b);Ct.test(P)&&(P=" "),(b>-1&&i+f.length>=0||P!==" ")&&f.push({type:"text",content:P})}}),r},stringify:function(e){return e.reduce(function(t,n){return t+ge("",n)},"")}};const K=(e,t)=>{if(!e)return!1;const n=e.props?.children??e.children;return t?n.length>0:!!n},Z=e=>{if(!e)return[];const t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?M(t):t},Et=e=>Array.isArray(e)&&e.every(j.isValidElement),M=e=>Array.isArray(e)?e:[e],kt=(e,t)=>{const n={...t};return n.props={...t.props,...e.props},n},Vt=e=>{const t={};if(!e)return t;const n=r=>{M(r).forEach(i=>{_(i)||(K(i)?n(Z(i)):U(i)&&!j.isValidElement(i)&&Object.assign(t,i))})};return n(e),t},he=(e,t,n,r)=>{if(!e)return"";let a="";const i=M(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return i.forEach((c,d)=>{if(_(c)){a+=`${c}`;return}if(j.isValidElement(c)){const{props:u,type:f}=c,E=Object.keys(u).length,V=o.indexOf(f)>-1,p=u.children;if(!p&&V&&!E){a+=`<${f}/>`;return}if(!p&&(!V||E)||u.i18nIsDynamicList){a+=`<${d}></${d}>`;return}if(V&&E===1&&_(p)){a+=`<${f}>${p}</${f}>`;return}const m=he(p,t,n,r);a+=`<${d}>${m}</${d}>`;return}if(c===null){Y(n,"TRANS_NULL_VALUE","Passed in a null value as child",{i18nKey:r});return}if(U(c)){const{format:u,...f}=c,E=Object.keys(f);if(E.length===1){const V=u?`${E[0]}, ${u}`:E[0];a+=`{{${V}}}`;return}Y(n,"TRANS_INVALID_OBJ","Invalid child - Object should only have keys {{ value, format }} (format is optional).",{i18nKey:r,child:c});return}Y(n,"TRANS_INVALID_VAR","Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.",{i18nKey:r,child:c})}),a},Tt=(e,t=[],n={})=>{if(!e)return e;const r=Object.keys(n),a=[...t,...r];let i="",o=0;for(;o<e.length;)if(e[o]==="<"){let c=!1;const d=e.slice(o).match(/^<\/(\d+|[a-zA-Z][a-zA-Z0-9_-]*)>/);if(d){const u=d[1];(/^\d+$/.test(u)||a.includes(u))&&(c=!0,i+=d[0],o+=d[0].length)}if(!c){const u=e.slice(o).match(/^<(\d+|[a-zA-Z][a-zA-Z0-9_-]*)(\s+[\w-]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*(\/)?>/);if(u){const f=u[1];(/^\d+$/.test(f)||a.includes(f))&&(c=!0,i+=u[0],o+=u[0].length)}}c||(i+="&lt;",o+=1)}else i+=e[o],o+=1;return i},Pt=(e,t,n,r,a,i,o)=>{if(n==="")return[];const c=a.transKeepBasicHtmlNodesFor||[],d=n&&new RegExp(c.map(x=>`<${x}`).join("|")).test(n);if(!e&&!t&&!d&&!o)return[n];const u=t??{},f=x=>{M(x).forEach(g=>{_(g)||(K(g)?f(Z(g)):U(g)&&!j.isValidElement(g)&&Object.assign(u,g))})};f(e);const E=Tt(n,c,u),V=wt.parse(`<0>${E}</0>`),p={...u,...i},m=(x,k,g)=>{const C=Z(x),I=b(C,k.children,g);return Et(C)&&I.length===0||x.props?.i18nIsDynamicList?C:I},N=(x,k,g,C,I)=>{x.dummy?(x.children=k,g.push(j.cloneElement(x,{key:C},I?void 0:k))):g.push(...j.Children.map([x],h=>{const l="data-i18n-is-dynamic-list",A={key:C,[l]:void 0};return h&&h.props&&Object.keys(h.props).forEach(T=>{T==="ref"||T==="children"||T==="i18nIsDynamicList"||T===l||(A[T]=h.props[T])}),j.cloneElement(h,A,I?null:k)}))},b=(x,k,g)=>{const C=M(x);return M(k).reduce((h,l,A)=>{const T=l.children?.[0]?.content&&r.services.interpolator.interpolate(l.children[0].content,p,r.language);if(l.type==="tag"){let v=C[parseInt(l.name,10)];!v&&t&&(v=t[l.name]),g.length===1&&!v&&(v=g[0][l.name]),v||(v={});const W={...l.attrs};o&&Object.keys(W).forEach(y=>{const F=W[y];_(F)&&(W[y]=Ae(F))});const S=Object.keys(W).length!==0?kt({props:W},v):v,$=j.isValidElement(S),R=$&&K(l,!0)&&!l.voidElement,D=d&&U(S)&&S.dummy&&!$,B=U(t)&&Object.hasOwnProperty.call(t,l.name);if(_(S)){const y=r.services.interpolator.interpolate(S,p,r.language);h.push(y)}else if(K(S)||R){const y=m(S,l,g);N(S,y,h,A)}else if(D){const y=b(C,l.children,g);N(S,y,h,A)}else if(Number.isNaN(parseFloat(l.name)))if(B){const y=m(S,l,g);N(S,y,h,A,l.voidElement)}else if(a.transSupportBasicHtmlNodes&&c.indexOf(l.name)>-1)if(l.voidElement)h.push(j.createElement(l.name,{key:`${l.name}-${A}`}));else{const y=b(C,l.children,g);h.push(j.createElement(l.name,{key:`${l.name}-${A}`},y))}else if(l.voidElement)h.push(`<${l.name} />`);else{const y=b(C,l.children,g);h.push(`<${l.name}>${y}</${l.name}>`)}else if(U(S)&&!$){const y=l.children[0]?T:null;y&&h.push(y)}else N(S,T,h,A,l.children.length!==1||!T)}else if(l.type==="text"){const v=a.transWrapTextNodes,W=typeof a.unescape=="function"?a.unescape:xe().unescape,S=o?W(r.services.interpolator.interpolate(l.content,p,r.language)):r.services.interpolator.interpolate(l.content,p,r.language);v?h.push(j.createElement(v,{key:`${l.name}-${A}`},S)):h.push(S)}return h},[])},P=b([{dummy:!0,children:e||[]}],V,M(e||[]));return Z(P[0])},ye=(e,t,n)=>{const r=e.key||t,a=j.cloneElement(e,{key:r});if(!a.props||!a.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return a;function i(){return j.createElement(j.Fragment,null,a)}return j.createElement(i,{key:r})},$t=(e,t)=>e.map((n,r)=>ye(n,r,t)),Wt=(e,t)=>{const n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:ye(e[r],r,t)})}),n},It=(e,t,n,r)=>e?Array.isArray(e)?$t(e,t):U(e)?Wt(e,t):(me(n,"TRANS_INVALID_COMPONENTS",'<Trans /> "components" prop expects an object or array',{i18nKey:r}),null):null,Dt=e=>!U(e)||Array.isArray(e)?!1:Object.keys(e).reduce((t,n)=>t&&Number.isNaN(Number.parseFloat(n)),!0);function Ot({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:i={},values:o,defaults:c,components:d,ns:u,i18n:f,t:E,shouldUnescape:V,...p}){const m=f||pe();if(!m)return me(m,"NO_I18NEXT_INSTANCE","Trans: You need to pass in an i18next instance using i18nextReactModule",{i18nKey:r}),e;const N=E||m.t.bind(m)||(L=>L),b={...xe(),...m.options?.react};let P=u||N.ns||m.options?.defaultNS;P=_(P)?[P]:P||["translation"];const{transDefaultProps:x}=b,k=x?.tOptions?{...x.tOptions,...i}:i,g=V??x?.shouldUnescape,C=x?.values?{...x.values,...o}:o,I=x?.components?{...x.components,...d}:d,h=he(e,b,m,r),l=c||k?.defaultValue||h||b.transEmptyNodeValue||(typeof r=="function"?Ce(r):r),{hashTransKey:A}=b,T=r||(A?A(h||l):h||l);m.options?.interpolation?.defaultVariables?o=C&&Object.keys(C).length>0?{...C,...m.options.interpolation.defaultVariables}:{...m.options.interpolation.defaultVariables}:o=C;const v=Vt(e);v&&typeof v.count=="number"&&t===void 0&&(t=v.count);const W=o||t!==void 0&&!m.options?.interpolation?.alwaysFormat||!e?k.interpolation:{interpolation:{...k.interpolation,prefix:"#$?",suffix:"?$#"}},S={...k,context:a||k.context,count:t,...o,...W,defaultValue:l,ns:P};let $=T?N(T,S):l;$===T&&l&&($=l);const R=It(I,$,m,r);let D=R||e,B=null;Dt(R)&&(B=R,D=e);const y=Pt(D,B,$,m,b,S,g),F=n??b.defaultTransParent;return F?j.createElement(F,p,y):y}function ue({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:i={},values:o,defaults:c,components:d,ns:u,i18n:f,t:E,shouldUnescape:V,...p}){const{i18n:m,defaultNS:N}=j.useContext(we)||{},b=f||m||pe(),P=E||b?.t.bind(b);return Ot({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:i,values:o,defaults:c,components:d,ns:u||P?.ns||N||b?.options?.defaultNS,i18n:b,t:E,shouldUnescape:V,...p})}async function Rt(){const e=await fetch("/api/cliproxy/sync/status");if(!e.ok){let t="Failed to fetch sync status";try{const n=await e.json();t=n.error||n.message||t}catch{}throw new Error(t)}return e.json()}async function Ft(){const e=new AbortController,t=setTimeout(()=>e.abort(),3e4);try{const n=await fetch("/api/cliproxy/sync",{method:"POST",headers:{"Content-Type":"application/json"},signal:e.signal});if(!n.ok){let r="Sync failed";try{const a=await n.json();r=a.error||a.message||r}catch{}throw new Error(r)}return n.json()}catch(n){throw n instanceof Error&&n.name==="AbortError"?new Error("Sync request timed out after 30 seconds"):n}finally{clearTimeout(t)}}function Lt(){return fe({queryKey:["cliproxy-sync-status"],queryFn:Rt,refetchInterval:3e4,retry:1,staleTime:1e4})}function Ut(){const e=tt();return st({mutationFn:Ft,onSuccess:t=>{e.invalidateQueries({queryKey:["cliproxy-sync-status"]}),e.invalidateQueries({queryKey:["cliproxy-sync-preview"]}),t.syncedCount===0?G.info("No profiles to sync"):G.success(`Synced ${t.syncedCount} profile${t.syncedCount===1?"":"s"} to CLIProxy`)},onError:t=>{G.error(`Sync failed: ${t.message}`)}})}function de(e){return e.replace(/-\d+$/,"").split(".").map(Number)}function re(e,t){const n=de(e),r=de(t);for(let a=0;a<3;a+=1){const i=n[a]||0,o=r[a]||0;if(i>o)return 1;if(i<o)return-1}return 0}function te(e,t){return re(e,t)>0}function se(e,t,n){return re(e,t)>=0&&re(e,n)<=0}function qt(e){if(!e)return"";const t=new Date(e).getTime(),r=Date.now()-t,a=Math.floor(r/(1e3*60*60)),i=Math.floor(r%(1e3*60*60)/(1e3*60));return a>0?`${a}h ${i}m`:`${i}m`}function Mt(e,t){if(!e)return"";const n=Date.now()-e,r=Math.floor(n/(1e3*60)),a=Math.floor(n/(1e3*60*60));return r<1?t("proxyStatusWidget.justNow"):r<60?t("proxyStatusWidget.minutesAgo",{count:r}):t("proxyStatusWidget.hoursAgo",{count:a})}function H({icon:e,tooltip:t,onClick:n,disabled:r,isPending:a,className:i,variant:o="ghost"}){return s.jsxs(_e,{children:[s.jsx(Be,{asChild:!0,children:s.jsx(ne,{variant:o==="destructive-ghost"?"ghost":o,size:"sm",className:q("h-7 w-7 p-0",o==="destructive-ghost"&&"hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30",i),onClick:n,disabled:r,children:a?s.jsx(z,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(e,{className:"w-3.5 h-3.5"})})}),s.jsx(ze,{side:"bottom",className:"text-xs",children:t})]})}function Xt(){const{t:e}=Ee(),{data:t,isLoading:n}=ke(),{data:r}=Ve(),{data:a,isLoading:i}=Te(),o=Pe(),c=$e(),d=We(),u=Ie(),{data:f}=Lt(),{mutate:E,isPending:V}=Ut(),[p,m]=j.useState(!1),[N,b]=j.useState(""),[P,x]=j.useState(!1),[k,g]=j.useState(null),[C,I]=j.useState(null),{data:h}=fe({queryKey:["cliproxy-server-config"],queryFn:()=>He.cliproxyServer.get(),staleTime:3e4}),l=nt({mutationKey:["update-backend"]})>0,A=h?.remote,T=A?.enabled&&A?.host,v=t?.running??!1,W=o.isPending||c.isPending||d.isPending||u.isPending||l||V,S=r?.hasUpdate??!1,$=r?.isStable===!1,R=r?.currentVersion,D=f?.configured??!1,B=e(D?"proxyStatusWidget.syncReady":"proxyStatusWidget.noConfig"),y=$?r?.maxStableVersion||a?.latestStable:r?.latestVersion,F=a?.maxStableVersion||r?.maxStableVersion||"6.6.80",L=a?.faultyRange,be=L&&`${L.min.replace(/-\d+$/,"")}-${L.max.replace(/-\d+$/,"")}`,Q=(w,O)=>{g(w),I(O),x(!0)},ae=async w=>{if(!w)return;const O=te(w,F);if(L!==void 0&&se(w,L.min,L.max)){Q(w,"faulty");return}if(O){Q(w,"experimental");return}try{const ie=await u.mutateAsync({version:w});ie.requiresConfirmation&&Q(w,ie.isFaulty?"faulty":"experimental")}catch{}},je=()=>{k&&u.mutate({version:k,force:!0}),x(!1),g(null),I(null)},Ne=()=>{x(!1),g(null),I(null)},ve=T?(()=>{const w=A.protocol||"http",O=A.port||(w==="https"?443:80);return w==="https"&&O===443||w==="http"&&O===80?A.host:`${A.host}:${O}`})():null;return T?s.jsxs("div",{className:q("rounded-lg border p-3 transition-colors","border-blue-500/30 bg-blue-500/5"),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(rt,{className:"w-4 h-4 text-blue-500"}),s.jsx("span",{className:"text-sm font-medium",children:e("proxyStatusWidget.remoteProxy")}),s.jsx(oe,{variant:"secondary",className:"text-[10px] h-4 px-1.5 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:e("proxyStatusWidget.active")})]}),s.jsx(at,{className:"w-3 h-3 text-blue-600"})]}),s.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[s.jsx("div",{className:"flex items-center gap-1 mb-1",children:s.jsx("span",{className:"font-mono",children:ve})}),s.jsx("p",{className:"text-[10px] text-muted-foreground/70 leading-tight",children:e("proxyStatusWidget.trafficAutoRouted")})]})]}):s.jsx(De,{delayDuration:300,children:s.jsxs("div",{className:q("rounded-lg border p-3 transition-colors",v?"border-green-500/30 bg-green-500/5":"border-muted bg-muted/30"),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:q("w-2 h-2 rounded-full",v?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),s.jsx("span",{className:"text-sm font-medium",children:r?.backendLabel??"CLIProxy"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[n?s.jsx(z,{className:"w-3 h-3 animate-spin text-muted-foreground"}):v?s.jsxs(s.Fragment,{children:[s.jsx(H,{icon:V?z:it,tooltip:e("proxyStatusWidget.tooltipSync"),onClick:()=>E(),disabled:!D||W,isPending:V}),s.jsx(H,{icon:ot,tooltip:e("proxyStatusWidget.tooltipRestart"),onClick:()=>d.mutate(),disabled:W,isPending:d.isPending}),s.jsx(H,{icon:lt,tooltip:e("proxyStatusWidget.tooltipStop"),onClick:()=>c.mutate(),disabled:W,isPending:c.isPending,variant:"destructive-ghost"})]}):null,s.jsx(H,{icon:p?ct:ut,tooltip:e(p?"proxyStatusWidget.tooltipClose":"proxyStatusWidget.tooltipVersionSettings"),onClick:()=>m(!p),className:p?"bg-muted":void 0})]})]}),R&&s.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[s.jsxs("span",{className:q("text-xs font-mono text-muted-foreground",$&&"text-amber-600 dark:text-amber-400"),children:["v",R]}),(S||$)&&y&&s.jsxs(oe,{variant:"secondary",className:q("text-[10px] h-4 px-1.5 gap-0.5 cursor-pointer transition-colors",$?"bg-amber-100 text-amber-700 hover:bg-amber-200 dark:bg-amber-900/30 dark:text-amber-400 dark:hover:bg-amber-900/50":"bg-green-100 text-green-700 hover:bg-green-200 dark:bg-green-900/30 dark:text-green-400 dark:hover:bg-green-900/50"),onClick:()=>void ae(y),title:e($?"proxyStatusWidget.clickToDowngrade":"proxyStatusWidget.clickToUpdate"),children:[$?s.jsx(dt,{className:"w-2.5 h-2.5"}):s.jsx(mt,{className:"w-2.5 h-2.5"}),y]})]}),v&&t&&s.jsxs("div",{className:"mt-2 flex items-center gap-4 text-xs text-muted-foreground",children:[s.jsx("span",{className:"flex items-center gap-1",children:e("proxyStatusWidget.port",{port:t.port})}),t.sessionCount!==void 0&&t.sessionCount>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(pt,{className:"w-3 h-3"}),e("proxyStatusWidget.sessionCount",{count:t.sessionCount})]}),t.startedAt&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(xt,{className:"w-3 h-3"}),qt(t.startedAt)]})]}),s.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs",children:[D?s.jsx(ft,{className:"w-3 h-3 text-green-600 dark:text-green-400"}):s.jsx(gt,{className:"w-3 h-3 text-muted-foreground"}),s.jsx("span",{className:q("text-xs",D?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:B})]}),s.jsx(Oe,{open:p,onOpenChange:m,children:s.jsxs(Re,{className:"mt-3 pt-3 border-t border-muted",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-3",children:e("proxyStatusWidget.versionManagement")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Fe,{value:N,onValueChange:b,disabled:i,children:[s.jsx(Le,{className:"h-8 text-xs flex-1",children:s.jsx(Ue,{placeholder:e("proxyStatusWidget.selectVersionPlaceholder")})}),s.jsx(qe,{children:a?.versions.slice(0,20).map(w=>{const O=a?.maxStableVersion&&te(w,a.maxStableVersion),X=a?.faultyRange&&se(w,a.faultyRange.min,a.faultyRange.max);return s.jsx(Me,{value:w,className:"text-xs",children:s.jsxs("span",{className:"flex items-center gap-2",children:["v",w,w===a.latestStable&&s.jsx("span",{className:"text-green-600 dark:text-green-400",children:e("proxyStatusWidget.stable")}),(X||O)&&s.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"⚠"})]})},w)})})]}),s.jsxs(ne,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 px-3",onClick:()=>void ae(N),disabled:u.isPending||!N,children:[u.isPending?s.jsx(z,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(ht,{className:"w-3.5 h-3.5"}),e("proxyStatusWidget.install")]})]}),N&&a?.maxStableVersion&&te(N,a.maxStableVersion)&&s.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[s.jsx(J,{className:"w-3.5 h-3.5 flex-shrink-0"}),s.jsx("span",{children:e("proxyStatusWidget.versionsAboveUnstable",{version:a.maxStableVersion})})]}),N&&a?.faultyRange&&se(N,a.faultyRange.min,a.faultyRange.max)&&s.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[s.jsx(J,{className:"w-3.5 h-3.5 flex-shrink-0"}),s.jsx("span",{children:e("proxyStatusWidget.versionsKnownIssues",{version:N})})]}),r?.checkedAt&&s.jsx("div",{className:"mt-2 text-[10px] text-muted-foreground/60",children:e("proxyStatusWidget.lastChecked",{time:Mt(r.checkedAt,e)})})]})}),!v&&s.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:e("proxyStatusWidget.notRunning")}),s.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>o.mutate(),disabled:o.isPending,children:[o.isPending?s.jsx(z,{className:"w-3 h-3 animate-spin"}):s.jsx(yt,{className:"w-3 h-3"}),e("proxyStatusWidget.start")]})]}),s.jsx(Ke,{open:P,onOpenChange:x,children:s.jsxs(Ze,{children:[s.jsxs(Qe,{children:[s.jsxs(Xe,{className:"flex items-center gap-2",children:[s.jsx(J,{className:"w-5 h-5 text-amber-500"}),e(C==="faulty"?"proxyStatusWidget.installFaultyTitle":"proxyStatusWidget.installUnstableTitle")]}),s.jsxs(Ye,{className:"space-y-2",children:[C==="faulty"?s.jsx("p",{children:s.jsx(ue,{i18nKey:"proxyStatusWidget.installFaultyDesc",values:{version:k??"",range:be||""},components:{strong:s.jsx("strong",{})}})}):s.jsx("p",{children:s.jsx(ue,{i18nKey:"proxyStatusWidget.installUnstableDesc",values:{version:k??"",maxStable:F},components:{strong:s.jsx("strong",{})}})}),s.jsx("p",{className:"text-amber-600 dark:text-amber-400",children:e(C==="faulty"?"proxyStatusWidget.installFaultyWarning":"proxyStatusWidget.installUnstableWarning")}),s.jsx("p",{children:e("proxyStatusWidget.installUnstableConfirm")})]})]}),s.jsxs(Ge,{children:[s.jsx(Je,{onClick:Ne,children:e("proxyStatusWidget.cancel")}),s.jsx(et,{onClick:je,className:"bg-amber-500 hover:bg-amber-600 text-white",children:e("proxyStatusWidget.installAnyway")})]})]})})]})})}export{Xt as P};
1
+ import{j as s}from"./radix-ui-Dt3edmE5.js";import{g as Se,r as j}from"./react-vendor-CNOkPC89.js";import{bm as me,bn as pe,bo as xe,bp as Ce,bq as _,br as Y,bs as U,bt as Ae,bu as we,a as Ee,bl as ke,aP as Ve,bv as Te,bw as Pe,bx as $e,by as We,bz as Ie,c as q,B as oe,aB as De,M as Oe,O as Re,r as Fe,s as Le,t as Ue,v as qe,w as Me,d as ne,T as _e,p as Be,q as ze,Y as He}from"./index-gjtWXRc2.js";import{A as Ke,a as Ze,b as Qe,c as Xe,d as Ye,e as Ge,f as Je,g as et}from"./alert-dialog-BsXoK0Gt.js";import{u as fe,a as tt,b as st,e as nt}from"./tanstack-B8i0evp-.js";import{t as G}from"./notifications-B2HqRBj7.js";import{t as rt,A as at,R as z,b1 as it,b2 as ot,b3 as lt,X as ct,d as ut,b4 as dt,b5 as mt,U as pt,u as xt,l as ft,x as gt,as as ht,T as J,aG as yt}from"./icons-DR-ORtNe.js";var ee,le;function bt(){return le||(le=1,ee={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),ee}var jt=bt();const Nt=Se(jt);var vt=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function ce(e){var t={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(Nt[n[1]]||e.charAt(e.length-2)==="/")&&(t.voidElement=!0),t.name.startsWith("!--"))){var r=e.indexOf("-->");return{type:"comment",comment:r!==-1?e.slice(4,r):""}}for(var a=new RegExp(vt),i=null;(i=a.exec(e))!==null;)if(i[0].trim())if(i[1]){var o=i[1].trim(),c=[o,""];o.indexOf("=")>-1&&(c=o.split("=")),t.attrs[c[0]]=c[1],a.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}var St=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Ct=/^\s*$/,At=Object.create(null);function ge(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?(function(n){var r=[];for(var a in n)r.push(a+'="'+n[a]+'"');return r.length?" "+r.join(" "):""})(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(ge,"")+"</"+t.name+">";case"comment":return e+"<!--"+t.comment+"-->"}}var wt={parse:function(e,t){t||(t={}),t.components||(t.components=At);var n,r=[],a=[],i=-1,o=!1;if(e.indexOf("<")!==0){var c=e.indexOf("<");r.push({type:"text",content:c===-1?e:e.substring(0,c)})}return e.replace(St,function(d,u){if(o){if(d!=="</"+n.name+">")return;o=!1}var f,E=d.charAt(1)!=="/",V=d.startsWith("<!--"),p=u+d.length,m=e.charAt(p);if(V){var N=ce(d);return i<0?(r.push(N),r):((f=a[i]).children.push(N),r)}if(E&&(i++,(n=ce(d)).type==="tag"&&t.components[n.name]&&(n.type="component",o=!0),n.voidElement||o||!m||m==="<"||n.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),i===0&&r.push(n),(f=a[i-1])&&f.children.push(n),a[i]=n),(!E||n.voidElement)&&(i>-1&&(n.voidElement||n.name===d.slice(2,-1))&&(i--,n=i===-1?r:a[i]),!o&&m!=="<"&&m)){f=i===-1?r:a[i].children;var b=e.indexOf("<",p),P=e.slice(p,b===-1?void 0:b);Ct.test(P)&&(P=" "),(b>-1&&i+f.length>=0||P!==" ")&&f.push({type:"text",content:P})}}),r},stringify:function(e){return e.reduce(function(t,n){return t+ge("",n)},"")}};const K=(e,t)=>{if(!e)return!1;const n=e.props?.children??e.children;return t?n.length>0:!!n},Z=e=>{if(!e)return[];const t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?M(t):t},Et=e=>Array.isArray(e)&&e.every(j.isValidElement),M=e=>Array.isArray(e)?e:[e],kt=(e,t)=>{const n={...t};return n.props={...t.props,...e.props},n},Vt=e=>{const t={};if(!e)return t;const n=r=>{M(r).forEach(i=>{_(i)||(K(i)?n(Z(i)):U(i)&&!j.isValidElement(i)&&Object.assign(t,i))})};return n(e),t},he=(e,t,n,r)=>{if(!e)return"";let a="";const i=M(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return i.forEach((c,d)=>{if(_(c)){a+=`${c}`;return}if(j.isValidElement(c)){const{props:u,type:f}=c,E=Object.keys(u).length,V=o.indexOf(f)>-1,p=u.children;if(!p&&V&&!E){a+=`<${f}/>`;return}if(!p&&(!V||E)||u.i18nIsDynamicList){a+=`<${d}></${d}>`;return}if(V&&E===1&&_(p)){a+=`<${f}>${p}</${f}>`;return}const m=he(p,t,n,r);a+=`<${d}>${m}</${d}>`;return}if(c===null){Y(n,"TRANS_NULL_VALUE","Passed in a null value as child",{i18nKey:r});return}if(U(c)){const{format:u,...f}=c,E=Object.keys(f);if(E.length===1){const V=u?`${E[0]}, ${u}`:E[0];a+=`{{${V}}}`;return}Y(n,"TRANS_INVALID_OBJ","Invalid child - Object should only have keys {{ value, format }} (format is optional).",{i18nKey:r,child:c});return}Y(n,"TRANS_INVALID_VAR","Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.",{i18nKey:r,child:c})}),a},Tt=(e,t=[],n={})=>{if(!e)return e;const r=Object.keys(n),a=[...t,...r];let i="",o=0;for(;o<e.length;)if(e[o]==="<"){let c=!1;const d=e.slice(o).match(/^<\/(\d+|[a-zA-Z][a-zA-Z0-9_-]*)>/);if(d){const u=d[1];(/^\d+$/.test(u)||a.includes(u))&&(c=!0,i+=d[0],o+=d[0].length)}if(!c){const u=e.slice(o).match(/^<(\d+|[a-zA-Z][a-zA-Z0-9_-]*)(\s+[\w-]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*(\/)?>/);if(u){const f=u[1];(/^\d+$/.test(f)||a.includes(f))&&(c=!0,i+=u[0],o+=u[0].length)}}c||(i+="&lt;",o+=1)}else i+=e[o],o+=1;return i},Pt=(e,t,n,r,a,i,o)=>{if(n==="")return[];const c=a.transKeepBasicHtmlNodesFor||[],d=n&&new RegExp(c.map(x=>`<${x}`).join("|")).test(n);if(!e&&!t&&!d&&!o)return[n];const u=t??{},f=x=>{M(x).forEach(g=>{_(g)||(K(g)?f(Z(g)):U(g)&&!j.isValidElement(g)&&Object.assign(u,g))})};f(e);const E=Tt(n,c,u),V=wt.parse(`<0>${E}</0>`),p={...u,...i},m=(x,k,g)=>{const C=Z(x),I=b(C,k.children,g);return Et(C)&&I.length===0||x.props?.i18nIsDynamicList?C:I},N=(x,k,g,C,I)=>{x.dummy?(x.children=k,g.push(j.cloneElement(x,{key:C},I?void 0:k))):g.push(...j.Children.map([x],h=>{const l="data-i18n-is-dynamic-list",A={key:C,[l]:void 0};return h&&h.props&&Object.keys(h.props).forEach(T=>{T==="ref"||T==="children"||T==="i18nIsDynamicList"||T===l||(A[T]=h.props[T])}),j.cloneElement(h,A,I?null:k)}))},b=(x,k,g)=>{const C=M(x);return M(k).reduce((h,l,A)=>{const T=l.children?.[0]?.content&&r.services.interpolator.interpolate(l.children[0].content,p,r.language);if(l.type==="tag"){let v=C[parseInt(l.name,10)];!v&&t&&(v=t[l.name]),g.length===1&&!v&&(v=g[0][l.name]),v||(v={});const W={...l.attrs};o&&Object.keys(W).forEach(y=>{const F=W[y];_(F)&&(W[y]=Ae(F))});const S=Object.keys(W).length!==0?kt({props:W},v):v,$=j.isValidElement(S),R=$&&K(l,!0)&&!l.voidElement,D=d&&U(S)&&S.dummy&&!$,B=U(t)&&Object.hasOwnProperty.call(t,l.name);if(_(S)){const y=r.services.interpolator.interpolate(S,p,r.language);h.push(y)}else if(K(S)||R){const y=m(S,l,g);N(S,y,h,A)}else if(D){const y=b(C,l.children,g);N(S,y,h,A)}else if(Number.isNaN(parseFloat(l.name)))if(B){const y=m(S,l,g);N(S,y,h,A,l.voidElement)}else if(a.transSupportBasicHtmlNodes&&c.indexOf(l.name)>-1)if(l.voidElement)h.push(j.createElement(l.name,{key:`${l.name}-${A}`}));else{const y=b(C,l.children,g);h.push(j.createElement(l.name,{key:`${l.name}-${A}`},y))}else if(l.voidElement)h.push(`<${l.name} />`);else{const y=b(C,l.children,g);h.push(`<${l.name}>${y}</${l.name}>`)}else if(U(S)&&!$){const y=l.children[0]?T:null;y&&h.push(y)}else N(S,T,h,A,l.children.length!==1||!T)}else if(l.type==="text"){const v=a.transWrapTextNodes,W=typeof a.unescape=="function"?a.unescape:xe().unescape,S=o?W(r.services.interpolator.interpolate(l.content,p,r.language)):r.services.interpolator.interpolate(l.content,p,r.language);v?h.push(j.createElement(v,{key:`${l.name}-${A}`},S)):h.push(S)}return h},[])},P=b([{dummy:!0,children:e||[]}],V,M(e||[]));return Z(P[0])},ye=(e,t,n)=>{const r=e.key||t,a=j.cloneElement(e,{key:r});if(!a.props||!a.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return a;function i(){return j.createElement(j.Fragment,null,a)}return j.createElement(i,{key:r})},$t=(e,t)=>e.map((n,r)=>ye(n,r,t)),Wt=(e,t)=>{const n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:ye(e[r],r,t)})}),n},It=(e,t,n,r)=>e?Array.isArray(e)?$t(e,t):U(e)?Wt(e,t):(me(n,"TRANS_INVALID_COMPONENTS",'<Trans /> "components" prop expects an object or array',{i18nKey:r}),null):null,Dt=e=>!U(e)||Array.isArray(e)?!1:Object.keys(e).reduce((t,n)=>t&&Number.isNaN(Number.parseFloat(n)),!0);function Ot({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:i={},values:o,defaults:c,components:d,ns:u,i18n:f,t:E,shouldUnescape:V,...p}){const m=f||pe();if(!m)return me(m,"NO_I18NEXT_INSTANCE","Trans: You need to pass in an i18next instance using i18nextReactModule",{i18nKey:r}),e;const N=E||m.t.bind(m)||(L=>L),b={...xe(),...m.options?.react};let P=u||N.ns||m.options?.defaultNS;P=_(P)?[P]:P||["translation"];const{transDefaultProps:x}=b,k=x?.tOptions?{...x.tOptions,...i}:i,g=V??x?.shouldUnescape,C=x?.values?{...x.values,...o}:o,I=x?.components?{...x.components,...d}:d,h=he(e,b,m,r),l=c||k?.defaultValue||h||b.transEmptyNodeValue||(typeof r=="function"?Ce(r):r),{hashTransKey:A}=b,T=r||(A?A(h||l):h||l);m.options?.interpolation?.defaultVariables?o=C&&Object.keys(C).length>0?{...C,...m.options.interpolation.defaultVariables}:{...m.options.interpolation.defaultVariables}:o=C;const v=Vt(e);v&&typeof v.count=="number"&&t===void 0&&(t=v.count);const W=o||t!==void 0&&!m.options?.interpolation?.alwaysFormat||!e?k.interpolation:{interpolation:{...k.interpolation,prefix:"#$?",suffix:"?$#"}},S={...k,context:a||k.context,count:t,...o,...W,defaultValue:l,ns:P};let $=T?N(T,S):l;$===T&&l&&($=l);const R=It(I,$,m,r);let D=R||e,B=null;Dt(R)&&(B=R,D=e);const y=Pt(D,B,$,m,b,S,g),F=n??b.defaultTransParent;return F?j.createElement(F,p,y):y}function ue({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:i={},values:o,defaults:c,components:d,ns:u,i18n:f,t:E,shouldUnescape:V,...p}){const{i18n:m,defaultNS:N}=j.useContext(we)||{},b=f||m||pe(),P=E||b?.t.bind(b);return Ot({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:i,values:o,defaults:c,components:d,ns:u||P?.ns||N||b?.options?.defaultNS,i18n:b,t:E,shouldUnescape:V,...p})}async function Rt(){const e=await fetch("/api/cliproxy/sync/status");if(!e.ok){let t="Failed to fetch sync status";try{const n=await e.json();t=n.error||n.message||t}catch{}throw new Error(t)}return e.json()}async function Ft(){const e=new AbortController,t=setTimeout(()=>e.abort(),3e4);try{const n=await fetch("/api/cliproxy/sync",{method:"POST",headers:{"Content-Type":"application/json"},signal:e.signal});if(!n.ok){let r="Sync failed";try{const a=await n.json();r=a.error||a.message||r}catch{}throw new Error(r)}return n.json()}catch(n){throw n instanceof Error&&n.name==="AbortError"?new Error("Sync request timed out after 30 seconds"):n}finally{clearTimeout(t)}}function Lt(){return fe({queryKey:["cliproxy-sync-status"],queryFn:Rt,refetchInterval:3e4,retry:1,staleTime:1e4})}function Ut(){const e=tt();return st({mutationFn:Ft,onSuccess:t=>{e.invalidateQueries({queryKey:["cliproxy-sync-status"]}),e.invalidateQueries({queryKey:["cliproxy-sync-preview"]}),t.syncedCount===0?G.info("No profiles to sync"):G.success(`Synced ${t.syncedCount} profile${t.syncedCount===1?"":"s"} to CLIProxy`)},onError:t=>{G.error(`Sync failed: ${t.message}`)}})}function de(e){return e.replace(/-\d+$/,"").split(".").map(Number)}function re(e,t){const n=de(e),r=de(t);for(let a=0;a<3;a+=1){const i=n[a]||0,o=r[a]||0;if(i>o)return 1;if(i<o)return-1}return 0}function te(e,t){return re(e,t)>0}function se(e,t,n){return re(e,t)>=0&&re(e,n)<=0}function qt(e){if(!e)return"";const t=new Date(e).getTime(),r=Date.now()-t,a=Math.floor(r/(1e3*60*60)),i=Math.floor(r%(1e3*60*60)/(1e3*60));return a>0?`${a}h ${i}m`:`${i}m`}function Mt(e,t){if(!e)return"";const n=Date.now()-e,r=Math.floor(n/(1e3*60)),a=Math.floor(n/(1e3*60*60));return r<1?t("proxyStatusWidget.justNow"):r<60?t("proxyStatusWidget.minutesAgo",{count:r}):t("proxyStatusWidget.hoursAgo",{count:a})}function H({icon:e,tooltip:t,onClick:n,disabled:r,isPending:a,className:i,variant:o="ghost"}){return s.jsxs(_e,{children:[s.jsx(Be,{asChild:!0,children:s.jsx(ne,{variant:o==="destructive-ghost"?"ghost":o,size:"sm",className:q("h-7 w-7 p-0",o==="destructive-ghost"&&"hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30",i),onClick:n,disabled:r,children:a?s.jsx(z,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(e,{className:"w-3.5 h-3.5"})})}),s.jsx(ze,{side:"bottom",className:"text-xs",children:t})]})}function Xt(){const{t:e}=Ee(),{data:t,isLoading:n}=ke(),{data:r}=Ve(),{data:a,isLoading:i}=Te(),o=Pe(),c=$e(),d=We(),u=Ie(),{data:f}=Lt(),{mutate:E,isPending:V}=Ut(),[p,m]=j.useState(!1),[N,b]=j.useState(""),[P,x]=j.useState(!1),[k,g]=j.useState(null),[C,I]=j.useState(null),{data:h}=fe({queryKey:["cliproxy-server-config"],queryFn:()=>He.cliproxyServer.get(),staleTime:3e4}),l=nt({mutationKey:["update-backend"]})>0,A=h?.remote,T=A?.enabled&&A?.host,v=t?.running??!1,W=o.isPending||c.isPending||d.isPending||u.isPending||l||V,S=r?.hasUpdate??!1,$=r?.isStable===!1,R=r?.currentVersion,D=f?.configured??!1,B=e(D?"proxyStatusWidget.syncReady":"proxyStatusWidget.noConfig"),y=$?r?.maxStableVersion||a?.latestStable:r?.latestVersion,F=a?.maxStableVersion||r?.maxStableVersion||"6.6.80",L=a?.faultyRange,be=L&&`${L.min.replace(/-\d+$/,"")}-${L.max.replace(/-\d+$/,"")}`,Q=(w,O)=>{g(w),I(O),x(!0)},ae=async w=>{if(!w)return;const O=te(w,F);if(L!==void 0&&se(w,L.min,L.max)){Q(w,"faulty");return}if(O){Q(w,"experimental");return}try{const ie=await u.mutateAsync({version:w});ie.requiresConfirmation&&Q(w,ie.isFaulty?"faulty":"experimental")}catch{}},je=()=>{k&&u.mutate({version:k,force:!0}),x(!1),g(null),I(null)},Ne=()=>{x(!1),g(null),I(null)},ve=T?(()=>{const w=A.protocol||"http",O=A.port||(w==="https"?443:80);return w==="https"&&O===443||w==="http"&&O===80?A.host:`${A.host}:${O}`})():null;return T?s.jsxs("div",{className:q("rounded-lg border p-3 transition-colors","border-blue-500/30 bg-blue-500/5"),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(rt,{className:"w-4 h-4 text-blue-500"}),s.jsx("span",{className:"text-sm font-medium",children:e("proxyStatusWidget.remoteProxy")}),s.jsx(oe,{variant:"secondary",className:"text-[10px] h-4 px-1.5 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:e("proxyStatusWidget.active")})]}),s.jsx(at,{className:"w-3 h-3 text-blue-600"})]}),s.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[s.jsx("div",{className:"flex items-center gap-1 mb-1",children:s.jsx("span",{className:"font-mono",children:ve})}),s.jsx("p",{className:"text-[10px] text-muted-foreground/70 leading-tight",children:e("proxyStatusWidget.trafficAutoRouted")})]})]}):s.jsx(De,{delayDuration:300,children:s.jsxs("div",{className:q("rounded-lg border p-3 transition-colors",v?"border-green-500/30 bg-green-500/5":"border-muted bg-muted/30"),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:q("w-2 h-2 rounded-full",v?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),s.jsx("span",{className:"text-sm font-medium",children:r?.backendLabel??"CLIProxy"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[n?s.jsx(z,{className:"w-3 h-3 animate-spin text-muted-foreground"}):v?s.jsxs(s.Fragment,{children:[s.jsx(H,{icon:V?z:it,tooltip:e("proxyStatusWidget.tooltipSync"),onClick:()=>E(),disabled:!D||W,isPending:V}),s.jsx(H,{icon:ot,tooltip:e("proxyStatusWidget.tooltipRestart"),onClick:()=>d.mutate(),disabled:W,isPending:d.isPending}),s.jsx(H,{icon:lt,tooltip:e("proxyStatusWidget.tooltipStop"),onClick:()=>c.mutate(),disabled:W,isPending:c.isPending,variant:"destructive-ghost"})]}):null,s.jsx(H,{icon:p?ct:ut,tooltip:e(p?"proxyStatusWidget.tooltipClose":"proxyStatusWidget.tooltipVersionSettings"),onClick:()=>m(!p),className:p?"bg-muted":void 0})]})]}),R&&s.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[s.jsxs("span",{className:q("text-xs font-mono text-muted-foreground",$&&"text-amber-600 dark:text-amber-400"),children:["v",R]}),(S||$)&&y&&s.jsxs(oe,{variant:"secondary",className:q("text-[10px] h-4 px-1.5 gap-0.5 cursor-pointer transition-colors",$?"bg-amber-100 text-amber-700 hover:bg-amber-200 dark:bg-amber-900/30 dark:text-amber-400 dark:hover:bg-amber-900/50":"bg-green-100 text-green-700 hover:bg-green-200 dark:bg-green-900/30 dark:text-green-400 dark:hover:bg-green-900/50"),onClick:()=>void ae(y),title:e($?"proxyStatusWidget.clickToDowngrade":"proxyStatusWidget.clickToUpdate"),children:[$?s.jsx(dt,{className:"w-2.5 h-2.5"}):s.jsx(mt,{className:"w-2.5 h-2.5"}),y]})]}),v&&t&&s.jsxs("div",{className:"mt-2 flex items-center gap-4 text-xs text-muted-foreground",children:[s.jsx("span",{className:"flex items-center gap-1",children:e("proxyStatusWidget.port",{port:t.port})}),t.sessionCount!==void 0&&t.sessionCount>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(pt,{className:"w-3 h-3"}),e("proxyStatusWidget.sessionCount",{count:t.sessionCount})]}),t.startedAt&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(xt,{className:"w-3 h-3"}),qt(t.startedAt)]})]}),s.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs",children:[D?s.jsx(ft,{className:"w-3 h-3 text-green-600 dark:text-green-400"}):s.jsx(gt,{className:"w-3 h-3 text-muted-foreground"}),s.jsx("span",{className:q("text-xs",D?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:B})]}),s.jsx(Oe,{open:p,onOpenChange:m,children:s.jsxs(Re,{className:"mt-3 pt-3 border-t border-muted",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-3",children:e("proxyStatusWidget.versionManagement")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Fe,{value:N,onValueChange:b,disabled:i,children:[s.jsx(Le,{className:"h-8 text-xs flex-1",children:s.jsx(Ue,{placeholder:e("proxyStatusWidget.selectVersionPlaceholder")})}),s.jsx(qe,{children:a?.versions.slice(0,20).map(w=>{const O=a?.maxStableVersion&&te(w,a.maxStableVersion),X=a?.faultyRange&&se(w,a.faultyRange.min,a.faultyRange.max);return s.jsx(Me,{value:w,className:"text-xs",children:s.jsxs("span",{className:"flex items-center gap-2",children:["v",w,w===a.latestStable&&s.jsx("span",{className:"text-green-600 dark:text-green-400",children:e("proxyStatusWidget.stable")}),(X||O)&&s.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"⚠"})]})},w)})})]}),s.jsxs(ne,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 px-3",onClick:()=>void ae(N),disabled:u.isPending||!N,children:[u.isPending?s.jsx(z,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(ht,{className:"w-3.5 h-3.5"}),e("proxyStatusWidget.install")]})]}),N&&a?.maxStableVersion&&te(N,a.maxStableVersion)&&s.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[s.jsx(J,{className:"w-3.5 h-3.5 flex-shrink-0"}),s.jsx("span",{children:e("proxyStatusWidget.versionsAboveUnstable",{version:a.maxStableVersion})})]}),N&&a?.faultyRange&&se(N,a.faultyRange.min,a.faultyRange.max)&&s.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[s.jsx(J,{className:"w-3.5 h-3.5 flex-shrink-0"}),s.jsx("span",{children:e("proxyStatusWidget.versionsKnownIssues",{version:N})})]}),r?.checkedAt&&s.jsx("div",{className:"mt-2 text-[10px] text-muted-foreground/60",children:e("proxyStatusWidget.lastChecked",{time:Mt(r.checkedAt,e)})})]})}),!v&&s.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:e("proxyStatusWidget.notRunning")}),s.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>o.mutate(),disabled:o.isPending,children:[o.isPending?s.jsx(z,{className:"w-3 h-3 animate-spin"}):s.jsx(yt,{className:"w-3 h-3"}),e("proxyStatusWidget.start")]})]}),s.jsx(Ke,{open:P,onOpenChange:x,children:s.jsxs(Ze,{children:[s.jsxs(Qe,{children:[s.jsxs(Xe,{className:"flex items-center gap-2",children:[s.jsx(J,{className:"w-5 h-5 text-amber-500"}),e(C==="faulty"?"proxyStatusWidget.installFaultyTitle":"proxyStatusWidget.installUnstableTitle")]}),s.jsxs(Ye,{className:"space-y-2",children:[C==="faulty"?s.jsx("p",{children:s.jsx(ue,{i18nKey:"proxyStatusWidget.installFaultyDesc",values:{version:k??"",range:be||""},components:{strong:s.jsx("strong",{})}})}):s.jsx("p",{children:s.jsx(ue,{i18nKey:"proxyStatusWidget.installUnstableDesc",values:{version:k??"",maxStable:F},components:{strong:s.jsx("strong",{})}})}),s.jsx("p",{className:"text-amber-600 dark:text-amber-400",children:e(C==="faulty"?"proxyStatusWidget.installFaultyWarning":"proxyStatusWidget.installUnstableWarning")}),s.jsx("p",{children:e("proxyStatusWidget.installUnstableConfirm")})]})]}),s.jsxs(Ge,{children:[s.jsx(Je,{onClick:Ne,children:e("proxyStatusWidget.cancel")}),s.jsx(et,{onClick:je,className:"bg-amber-500 hover:bg-amber-600 text-white",children:e("proxyStatusWidget.installAnyway")})]})]})})]})})}export{Xt as P};
@@ -1 +1 @@
1
- import{j as n}from"./radix-ui-Dt3edmE5.js";import{r as a}from"./react-vendor-CNOkPC89.js";import{e as P,f as Q,d as $,c as w,g as B,I as G,n as H}from"./index-sCtK1kDn.js";import{aI as L,ak as V,l as J}from"./icons-DR-ORtNe.js";function S(o){return o.trim().toLowerCase()}function M(o,h){return`${o}-option-${h.replace(/[^a-z0-9_-]+/gi,"-")}`}function ee({value:o,onChange:h,options:d,groups:g,placeholder:j,searchPlaceholder:k,emptyText:E,disabled:F,className:q,triggerClassName:K,contentClassName:R}){const[l,T]=a.useState(!1),[y,A]=a.useState(""),[i,u]=a.useState(),m=a.useId(),I=a.useRef(null),N=a.useRef({}),O=a.useMemo(()=>d.find(e=>e.value===o),[d,o]),f=a.useMemo(()=>{const e=S(y);return e?d.filter(t=>[t.searchText,...t.keywords??[]].some(c=>S(c).includes(e))):d},[d,y]),z=a.useMemo(()=>{const e=new Map((g??[]).map(r=>[r.key,r])),t=f.filter(r=>!r.groupKey||!e.has(r.groupKey)),c=(g??[]).map(r=>({...r,options:f.filter(x=>x.groupKey===r.key)})).filter(r=>r.options.length>0);return t.length===0?c:[{key:"__default",options:t},...c]},[f,g]),s=a.useMemo(()=>f.filter(e=>!e.disabled),[f]),D=O?.triggerContent??O?.itemContent,v=e=>{T(e),e||(A(""),u(void 0))},b=()=>I.current?.focus();a.useEffect(()=>{if(l){if(s.length===0){u(void 0);return}u(e=>e&&s.some(t=>t.value===e)?e:s.find(t=>t.value===o)?.value??s[0]?.value)}},[s,l,o]),a.useEffect(()=>{!l||!i||N.current[i]?.scrollIntoView({block:"nearest"})},[i,l]);const p=e=>{if(s.length===0)return;if(e==="first"){u(s[0]?.value);return}if(e==="last"){u(s.at(-1)?.value);return}const t=s.findIndex(_=>_.value===i),c=e==="next"?-1:s.length,r=t>=0?t:c,x=e==="next"?Math.min(r+1,s.length-1):Math.max(r-1,0);u(s[x]?.value)},C=e=>{h(e),v(!1)},U=()=>{if(!i)return;const e=s.find(t=>t.value===i);e&&C(e.value)};return n.jsxs(P,{open:l,onOpenChange:v,children:[n.jsx(Q,{asChild:!0,children:n.jsxs($,{type:"button",variant:"outline","aria-expanded":l,"aria-controls":l?m:void 0,"aria-haspopup":"dialog",disabled:F,onKeyDown:e=>{if(e.key!=="ArrowDown"&&e.key!=="ArrowUp")return;e.preventDefault(),v(!0);const t=()=>{b(),p(e.key==="ArrowDown"?"first":"last")};if(typeof requestAnimationFrame=="function"){requestAnimationFrame(t);return}setTimeout(t,0)},className:w("w-full justify-between font-normal",q,K,!D&&"text-muted-foreground"),children:[n.jsx("div",{className:"min-w-0 flex-1 text-left",children:D??n.jsx("span",{children:j})}),n.jsx(L,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),n.jsxs(B,{align:"start",className:w("w-[var(--radix-popover-trigger-width)] p-0",R),onOpenAutoFocus:e=>{if(e.preventDefault(),typeof requestAnimationFrame=="function"){requestAnimationFrame(b);return}setTimeout(b,0)},children:[n.jsx("div",{className:"border-b p-2",children:n.jsxs("div",{className:"relative",children:[n.jsx(V,{className:"text-muted-foreground absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2"}),n.jsx(G,{ref:I,value:y,onChange:e=>A(e.target.value),role:"combobox","aria-label":k,"aria-autocomplete":"list","aria-expanded":l,"aria-controls":m,"aria-activedescendant":i?M(m,i):void 0,onKeyDown:e=>{if(e.key==="ArrowDown"){e.preventDefault(),p("next");return}if(e.key==="ArrowUp"){e.preventDefault(),p("previous");return}if(e.key==="Home"){e.preventDefault(),p("first");return}if(e.key==="End"){e.preventDefault(),p("last");return}if(e.key==="Enter"){e.preventDefault(),U();return}e.key==="Escape"&&(e.preventDefault(),v(!1))},placeholder:k,className:"pl-8"})]})}),n.jsx(H,{className:"max-h-72",children:f.length===0?n.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:E}):n.jsx("div",{id:m,role:"listbox","aria-label":j,className:"p-1",children:z.map(e=>n.jsxs("div",{children:[e.label&&n.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:e.label}),e.options.map(t=>{const c=t.value===i,r=t.value===o;return n.jsxs("button",{id:M(m,t.value),type:"button",role:"option","aria-selected":r,disabled:t.disabled,tabIndex:-1,ref:x=>{N.current[t.value]=x},onMouseMove:()=>{t.disabled||u(t.value)},onFocus:()=>{t.disabled||u(t.value)},onClick:()=>C(t.value),className:w("hover:bg-accent hover:text-accent-foreground flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm outline-none","focus-visible:ring-ring focus-visible:ring-1",c&&"bg-accent text-accent-foreground",r&&"bg-accent text-accent-foreground",t.disabled&&"pointer-events-none opacity-50"),children:[n.jsx("div",{className:"min-w-0 flex-1",children:t.itemContent}),r&&n.jsx(J,{className:"h-4 w-4 shrink-0"})]},t.value)})]},e.key))})})]})]})}export{ee as S};
1
+ import{j as n}from"./radix-ui-Dt3edmE5.js";import{r as a}from"./react-vendor-CNOkPC89.js";import{e as P,f as Q,d as $,c as w,g as B,I as G,n as H}from"./index-gjtWXRc2.js";import{aI as L,ak as V,l as J}from"./icons-DR-ORtNe.js";function S(o){return o.trim().toLowerCase()}function M(o,h){return`${o}-option-${h.replace(/[^a-z0-9_-]+/gi,"-")}`}function ee({value:o,onChange:h,options:d,groups:g,placeholder:j,searchPlaceholder:k,emptyText:E,disabled:F,className:q,triggerClassName:K,contentClassName:R}){const[l,T]=a.useState(!1),[y,A]=a.useState(""),[i,u]=a.useState(),m=a.useId(),I=a.useRef(null),N=a.useRef({}),O=a.useMemo(()=>d.find(e=>e.value===o),[d,o]),f=a.useMemo(()=>{const e=S(y);return e?d.filter(t=>[t.searchText,...t.keywords??[]].some(c=>S(c).includes(e))):d},[d,y]),z=a.useMemo(()=>{const e=new Map((g??[]).map(r=>[r.key,r])),t=f.filter(r=>!r.groupKey||!e.has(r.groupKey)),c=(g??[]).map(r=>({...r,options:f.filter(x=>x.groupKey===r.key)})).filter(r=>r.options.length>0);return t.length===0?c:[{key:"__default",options:t},...c]},[f,g]),s=a.useMemo(()=>f.filter(e=>!e.disabled),[f]),D=O?.triggerContent??O?.itemContent,v=e=>{T(e),e||(A(""),u(void 0))},b=()=>I.current?.focus();a.useEffect(()=>{if(l){if(s.length===0){u(void 0);return}u(e=>e&&s.some(t=>t.value===e)?e:s.find(t=>t.value===o)?.value??s[0]?.value)}},[s,l,o]),a.useEffect(()=>{!l||!i||N.current[i]?.scrollIntoView({block:"nearest"})},[i,l]);const p=e=>{if(s.length===0)return;if(e==="first"){u(s[0]?.value);return}if(e==="last"){u(s.at(-1)?.value);return}const t=s.findIndex(_=>_.value===i),c=e==="next"?-1:s.length,r=t>=0?t:c,x=e==="next"?Math.min(r+1,s.length-1):Math.max(r-1,0);u(s[x]?.value)},C=e=>{h(e),v(!1)},U=()=>{if(!i)return;const e=s.find(t=>t.value===i);e&&C(e.value)};return n.jsxs(P,{open:l,onOpenChange:v,children:[n.jsx(Q,{asChild:!0,children:n.jsxs($,{type:"button",variant:"outline","aria-expanded":l,"aria-controls":l?m:void 0,"aria-haspopup":"dialog",disabled:F,onKeyDown:e=>{if(e.key!=="ArrowDown"&&e.key!=="ArrowUp")return;e.preventDefault(),v(!0);const t=()=>{b(),p(e.key==="ArrowDown"?"first":"last")};if(typeof requestAnimationFrame=="function"){requestAnimationFrame(t);return}setTimeout(t,0)},className:w("w-full justify-between font-normal",q,K,!D&&"text-muted-foreground"),children:[n.jsx("div",{className:"min-w-0 flex-1 text-left",children:D??n.jsx("span",{children:j})}),n.jsx(L,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),n.jsxs(B,{align:"start",className:w("w-[var(--radix-popover-trigger-width)] p-0",R),onOpenAutoFocus:e=>{if(e.preventDefault(),typeof requestAnimationFrame=="function"){requestAnimationFrame(b);return}setTimeout(b,0)},children:[n.jsx("div",{className:"border-b p-2",children:n.jsxs("div",{className:"relative",children:[n.jsx(V,{className:"text-muted-foreground absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2"}),n.jsx(G,{ref:I,value:y,onChange:e=>A(e.target.value),role:"combobox","aria-label":k,"aria-autocomplete":"list","aria-expanded":l,"aria-controls":m,"aria-activedescendant":i?M(m,i):void 0,onKeyDown:e=>{if(e.key==="ArrowDown"){e.preventDefault(),p("next");return}if(e.key==="ArrowUp"){e.preventDefault(),p("previous");return}if(e.key==="Home"){e.preventDefault(),p("first");return}if(e.key==="End"){e.preventDefault(),p("last");return}if(e.key==="Enter"){e.preventDefault(),U();return}e.key==="Escape"&&(e.preventDefault(),v(!1))},placeholder:k,className:"pl-8"})]})}),n.jsx(H,{className:"max-h-72",children:f.length===0?n.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:E}):n.jsx("div",{id:m,role:"listbox","aria-label":j,className:"p-1",children:z.map(e=>n.jsxs("div",{children:[e.label&&n.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:e.label}),e.options.map(t=>{const c=t.value===i,r=t.value===o;return n.jsxs("button",{id:M(m,t.value),type:"button",role:"option","aria-selected":r,disabled:t.disabled,tabIndex:-1,ref:x=>{N.current[t.value]=x},onMouseMove:()=>{t.disabled||u(t.value)},onFocus:()=>{t.disabled||u(t.value)},onClick:()=>C(t.value),className:w("hover:bg-accent hover:text-accent-foreground flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm outline-none","focus-visible:ring-ring focus-visible:ring-1",c&&"bg-accent text-accent-foreground",r&&"bg-accent text-accent-foreground",t.disabled&&"pointer-events-none opacity-50"),children:[n.jsx("div",{className:"min-w-0 flex-1",children:t.itemContent}),r&&n.jsx(J,{className:"h-4 w-4 shrink-0"})]},t.value)})]},e.key))})})]})]})}export{ee as S};
@@ -1 +1 @@
1
- import{j as i,_ as n}from"./radix-ui-Dt3edmE5.js";import"./react-vendor-CNOkPC89.js";import{c as e}from"./index-sCtK1kDn.js";function m({className:t,orientation:a="horizontal",decorative:o=!0,...r}){return i.jsx(n,{"data-slot":"separator",decorative:o,orientation:a,className:e("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...r})}export{m as S};
1
+ import{j as i,_ as n}from"./radix-ui-Dt3edmE5.js";import"./react-vendor-CNOkPC89.js";import{c as e}from"./index-gjtWXRc2.js";function m({className:t,orientation:a="horizontal",decorative:o=!0,...r}){return i.jsx(n,{"data-slot":"separator",decorative:o,orientation:a,className:e("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...r})}export{m as S};
@@ -1,4 +1,4 @@
1
- import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{a as Q,ba as ee,bb as se,bc as te,Q as ae,R as re,U as ne,B as $,b3 as S,b4 as M,b5 as L,d as I,I as le,n as B,c as U,C as ie,b as de}from"./index-sCtK1kDn.js";import{$ as ce,a4 as oe,aV as me,T as E,R as T,F as he,ak as ue,x as xe}from"./icons-DR-ORtNe.js";import"./tanstack-B8i0evp-.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Se(){const{t:s}=Q(),[a,l]=j.useState("commands"),t={commands:s("sharedPage.commands"),skills:s("sharedPage.skills"),agents:s("sharedPage.agents")},[r,d]=j.useState(""),[n,o]=j.useState(null),{data:c,isError:h,error:p,refetch:w}=ee(),{data:m,isLoading:x,isFetching:y,isError:g,error:q,refetch:D}=se(a),N=m?.items??[],C=r.trim().toLowerCase(),b=r.trim(),u=j.useMemo(()=>{const i=m?.items??[];return C?i.filter(v=>[v.name,v.description,v.path].some(Y=>Y.toLowerCase().includes(C))):i},[m,C]),f=j.useMemo(()=>u.length===0?null:n?u.find(i=>i.path===n)??u[0]:u[0],[u,n]),{data:P,isLoading:O,isError:_,error:V,refetch:W}=te(a,f?.path??null),z=[{id:"commands",label:t.commands,icon:ce,count:c?.commands??0},{id:"skills",label:t.skills,icon:oe,count:c?.skills??0},{id:"agents",label:t.agents,icon:me,count:c?.agents??0}],H=z.reduce((i,v)=>i+v.count,0),K=!x&&!g&&N.length===0,Z=!x&&!g&&N.length>0&&u.length===0,G=A(p,"Shared item totals could not be loaded. Listing still works."),J=A(q,`Unable to fetch shared ${a}. Please try again.`),X=A(V,`Unable to load content for ${f?.name??"selected item"}.`);return e.jsxs("div",{className:"h-full overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-6 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:s("sharedPage.title")}),e.jsx("p",{className:"text-muted-foreground",children:s("sharedPage.subtitle")})]}),e.jsx(ae,{value:a,onValueChange:i=>{l(i),d(""),o(null)},children:e.jsx(re,{className:"h-auto flex-wrap justify-start",children:z.map(i=>e.jsxs(ne,{value:i.id,className:"flex items-center gap-2",children:[e.jsx(i.icon,{className:"w-4 h-4"}),e.jsx("span",{children:i.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",i.count,")"]})]},i.id))})})]}),e.jsxs("div",{className:"flex flex-col gap-2 lg:items-end",children:[e.jsxs("div",{className:"grid w-full gap-2 sm:w-auto sm:min-w-[340px] sm:grid-cols-3",children:[e.jsx(F,{label:s("sharedPage.totalShared"),value:H}),e.jsx(F,{label:t[a],value:N.length}),e.jsx(F,{label:s("sharedPage.visible"),value:u.length})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx($,{variant:"secondary",children:s("sharedPage.markdownDetail")}),b?e.jsxs($,{variant:"outline",children:[s("sharedPage.filterPrefix")," ",b]}):null]})]})]}),c&&!c.symlinkStatus.valid&&e.jsxs(S,{variant:"warning",children:[e.jsx(E,{className:"h-4 w-4"}),e.jsx(M,{children:s("sharedPage.configurationRequired")}),e.jsxs(L,{children:[c.symlinkStatus.message,". Run `ccs sync` to configure."]})]}),h&&e.jsxs(S,{variant:"info",children:[e.jsx(E,{className:"h-4 w-4"}),e.jsx(M,{children:s("sharedPage.countsUnavailable")}),e.jsxs(L,{children:[e.jsx("p",{children:G}),e.jsx("div",{className:"mt-3",children:e.jsxs(I,{size:"sm",variant:"outline",onClick:()=>{w()},children:[e.jsx(T,{className:"w-4 h-4 mr-2"}),s("sharedPage.retryCounts")]})})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 px-6 pb-6",children:e.jsx("div",{className:"h-full rounded-lg border overflow-hidden bg-background",children:e.jsxs("div",{className:"grid h-full min-h-0 lg:grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs("div",{className:"min-h-0 border-b lg:border-b-0 lg:border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(he,{className:"w-4 h-4 text-primary shrink-0"}),e.jsx("h2",{className:"font-semibold truncate",children:t[a]})]}),!x&&!g&&e.jsxs($,{variant:"outline",className:"text-[10px] h-5",children:[u.length,"/",N.length]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(ue,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(le,{value:r,onChange:i=>d(i.target.value),placeholder:s("sharedPage.filterPlaceholder",{tab:a}),"aria-label":s("sharedPage.filterPlaceholder",{tab:a}),className:"pl-8 h-9"})]}),!x&&!g&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s("sharedPage.showing",{visible:u.length,total:N.length,tab:a}),b?s("sharedPage.showingQuery",{query:b}):"",y?s("sharedPage.refreshing"):""]})]}),e.jsx(B,{className:"flex-1 min-h-0",children:x?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("sharedPage.loadingShared",{tab:a})}):g?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(xe,{className:"w-10 h-10 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("sharedPage.failedLoadShared",{tab:a})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:J})]}),e.jsxs(I,{size:"sm",variant:"outline",onClick:()=>{D()},children:[e.jsx(T,{className:"w-4 h-4 mr-2"}),s("sharedPage.retry")]})]})}):K?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("sharedPage.noSharedFound",{tab:a})}):Z?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("sharedPage.noMatch",{tab:a,query:b})}):e.jsx("div",{className:"p-2 space-y-1",children:u.map(i=>e.jsxs("button",{type:"button",onClick:()=>o(i.path),className:U("w-full text-left p-3 rounded-md border transition-colors",f?.path===i.path?"bg-primary/10 border-primary/30":"bg-background hover:bg-muted border-transparent"),children:[e.jsx("p",{className:"text-sm font-medium truncate",children:i.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:i.description}),e.jsx("p",{className:"text-[11px] text-muted-foreground/90 mt-2 font-mono truncate",children:i.path})]},`${i.type}:${i.path}`))})})]}),e.jsx("div",{className:"min-w-0 min-h-0 flex flex-col bg-muted/20",children:f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-4 py-3 border-b bg-background",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-base font-semibold truncate",children:f.name}),e.jsx($,{variant:"outline",className:"uppercase text-[10px]",children:f.type})]})}),e.jsxs("div",{className:"p-4 space-y-4 min-h-0 flex-1 flex flex-col",children:[e.jsx("div",{className:"rounded-md border bg-muted/35 p-3",children:e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(R,{label:s("sharedPage.pathLabel"),value:f.path,mono:!0}),P?.contentPath&&P.contentPath!==f.path&&e.jsx(R,{label:s("sharedPage.resolvedSource"),value:P.contentPath,mono:!0})]})}),e.jsx(ie,{className:"min-h-0 flex-1",children:e.jsx(de,{className:"p-0 h-full",children:e.jsx(B,{className:"h-full px-5 py-4",children:O?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("sharedPage.loadingMarkdown")}):_?e.jsxs(S,{variant:"destructive",className:"max-w-2xl",children:[e.jsx(E,{className:"h-4 w-4"}),e.jsx(M,{children:s("sharedPage.failedLoadContent")}),e.jsxs(L,{children:[e.jsx("p",{children:X}),e.jsx("div",{className:"mt-3",children:e.jsxs(I,{size:"sm",variant:"outline",onClick:()=>{W()},children:[e.jsx(T,{className:"w-4 h-4 mr-2"}),s("sharedPage.retryContent")]})})]})]}):e.jsx(pe,{content:P?.content??""})})})})]})]}):e.jsx("div",{className:"min-h-[320px] flex items-center justify-center p-6 text-center text-muted-foreground",children:s("sharedPage.selectOne",{tab:a.slice(0,-1)})})})]})})})]})}function F({label:s,value:a}){return e.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:s}),e.jsx("p",{className:"text-lg font-semibold leading-tight mt-1",children:a})]})}function R({label:s,value:a,mono:l=!1}){return e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:s}),e.jsx("p",{className:U("text-xs mt-1 break-words",l?"font-mono":"text-sm"),children:a})]})}function A(s,a){if(!(s instanceof Error))return a;const l=s.message.toLowerCase();return l.includes("failed to fetch")||l.includes("network")?"Connection to dashboard server lost or restarting. Keep `ccs config` running, then retry.":s.message||a}function pe({content:s}){const{t:a}=Q(),l=j.useMemo(()=>fe(s),[s]);return l.blocks.length===0&&l.frontmatter.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("sharedPage.noMarkdown")}):e.jsxs("div",{className:"space-y-5",children:[l.frontmatter.length>0?e.jsx("div",{className:"rounded-md border bg-muted/35 p-3",children:e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:l.frontmatter.map(t=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:ge(t.key)}),e.jsx("p",{className:"text-xs mt-1 break-words",children:t.value})]},`${t.key}:${t.value}`))})}):null,l.blocks.map((t,r)=>{if(t.type==="heading"){const d=t.level<=1?"text-xl font-semibold":t.level===2?"text-lg font-semibold":"text-base font-semibold";return e.jsx("h3",{className:d,children:k(t.text,`heading-${r}`)},`heading-${r}`)}return t.type==="paragraph"?e.jsx("p",{className:"text-sm leading-6 whitespace-pre-wrap",children:k(t.text,`paragraph-${r}`)},`paragraph-${r}`):t.type==="unordered-list"?e.jsx("ul",{className:"list-disc pl-5 space-y-1 text-sm leading-6",children:t.items.map((d,n)=>e.jsx("li",{children:k(d,`ul-item-${r}-${n}`)},`ul-item-${r}-${n}`))},`ul-${r}`):t.type==="ordered-list"?e.jsx("ol",{className:"list-decimal pl-5 space-y-1 text-sm leading-6",children:t.items.map((d,n)=>e.jsx("li",{children:k(d,`ol-item-${r}-${n}`)},`ol-item-${r}-${n}`))},`ol-${r}`):e.jsxs("div",{className:"rounded-md border bg-muted/60 p-3 font-mono text-xs leading-5 overflow-x-auto",children:[t.language&&e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground mb-2",children:t.language}),e.jsx("pre",{className:"whitespace-pre-wrap break-words m-0",children:t.content})]},`code-${r}`)})]})}function ge(s){return s.replace(/[-_]/g," ")}function k(s,a){const l=/(\*\*([^*]+)\*\*|`([^`]+)`|\*([^*]+)\*|\[([^\]]+)\]\(([^)]+)\))/g,t=[];let r=0,d=0;for(const n of s.matchAll(l)){const o=n[0],c=n.index??0;if(c>r&&t.push(s.slice(r,c)),n[2])t.push(e.jsx("strong",{className:"font-semibold",children:n[2]},`${a}-strong-${d}`));else if(n[3])t.push(e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[0.82em]",children:n[3]},`${a}-code-${d}`));else if(n[4])t.push(e.jsx("em",{className:"italic",children:n[4]},`${a}-em-${d}`));else if(n[5]&&n[6]){const h=n[6].trim();/^(https?:\/\/|mailto:)/i.test(h)?t.push(e.jsx("a",{href:h,target:"_blank",rel:"noreferrer",className:"text-primary underline underline-offset-2 hover:opacity-90",children:n[5]},`${a}-link-${d}`)):t.push(n[5])}else t.push(o);r=c+o.length,d+=1}return r<s.length&&t.push(s.slice(r)),t.length===0?[s]:t}function fe(s){const a=s.replace(/\r\n/g,`
1
+ import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{a as Q,ba as ee,bb as se,bc as te,Q as ae,R as re,U as ne,B as $,b3 as S,b4 as M,b5 as L,d as I,I as le,n as B,c as U,C as ie,b as de}from"./index-gjtWXRc2.js";import{$ as ce,a4 as oe,aV as me,T as E,R as T,F as he,ak as ue,x as xe}from"./icons-DR-ORtNe.js";import"./tanstack-B8i0evp-.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Se(){const{t:s}=Q(),[a,l]=j.useState("commands"),t={commands:s("sharedPage.commands"),skills:s("sharedPage.skills"),agents:s("sharedPage.agents")},[r,d]=j.useState(""),[n,o]=j.useState(null),{data:c,isError:h,error:p,refetch:w}=ee(),{data:m,isLoading:x,isFetching:y,isError:g,error:q,refetch:D}=se(a),N=m?.items??[],C=r.trim().toLowerCase(),b=r.trim(),u=j.useMemo(()=>{const i=m?.items??[];return C?i.filter(v=>[v.name,v.description,v.path].some(Y=>Y.toLowerCase().includes(C))):i},[m,C]),f=j.useMemo(()=>u.length===0?null:n?u.find(i=>i.path===n)??u[0]:u[0],[u,n]),{data:P,isLoading:O,isError:_,error:V,refetch:W}=te(a,f?.path??null),z=[{id:"commands",label:t.commands,icon:ce,count:c?.commands??0},{id:"skills",label:t.skills,icon:oe,count:c?.skills??0},{id:"agents",label:t.agents,icon:me,count:c?.agents??0}],H=z.reduce((i,v)=>i+v.count,0),K=!x&&!g&&N.length===0,Z=!x&&!g&&N.length>0&&u.length===0,G=A(p,"Shared item totals could not be loaded. Listing still works."),J=A(q,`Unable to fetch shared ${a}. Please try again.`),X=A(V,`Unable to load content for ${f?.name??"selected item"}.`);return e.jsxs("div",{className:"h-full overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-6 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:s("sharedPage.title")}),e.jsx("p",{className:"text-muted-foreground",children:s("sharedPage.subtitle")})]}),e.jsx(ae,{value:a,onValueChange:i=>{l(i),d(""),o(null)},children:e.jsx(re,{className:"h-auto flex-wrap justify-start",children:z.map(i=>e.jsxs(ne,{value:i.id,className:"flex items-center gap-2",children:[e.jsx(i.icon,{className:"w-4 h-4"}),e.jsx("span",{children:i.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",i.count,")"]})]},i.id))})})]}),e.jsxs("div",{className:"flex flex-col gap-2 lg:items-end",children:[e.jsxs("div",{className:"grid w-full gap-2 sm:w-auto sm:min-w-[340px] sm:grid-cols-3",children:[e.jsx(F,{label:s("sharedPage.totalShared"),value:H}),e.jsx(F,{label:t[a],value:N.length}),e.jsx(F,{label:s("sharedPage.visible"),value:u.length})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx($,{variant:"secondary",children:s("sharedPage.markdownDetail")}),b?e.jsxs($,{variant:"outline",children:[s("sharedPage.filterPrefix")," ",b]}):null]})]})]}),c&&!c.symlinkStatus.valid&&e.jsxs(S,{variant:"warning",children:[e.jsx(E,{className:"h-4 w-4"}),e.jsx(M,{children:s("sharedPage.configurationRequired")}),e.jsxs(L,{children:[c.symlinkStatus.message,". Run `ccs sync` to configure."]})]}),h&&e.jsxs(S,{variant:"info",children:[e.jsx(E,{className:"h-4 w-4"}),e.jsx(M,{children:s("sharedPage.countsUnavailable")}),e.jsxs(L,{children:[e.jsx("p",{children:G}),e.jsx("div",{className:"mt-3",children:e.jsxs(I,{size:"sm",variant:"outline",onClick:()=>{w()},children:[e.jsx(T,{className:"w-4 h-4 mr-2"}),s("sharedPage.retryCounts")]})})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 px-6 pb-6",children:e.jsx("div",{className:"h-full rounded-lg border overflow-hidden bg-background",children:e.jsxs("div",{className:"grid h-full min-h-0 lg:grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs("div",{className:"min-h-0 border-b lg:border-b-0 lg:border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(he,{className:"w-4 h-4 text-primary shrink-0"}),e.jsx("h2",{className:"font-semibold truncate",children:t[a]})]}),!x&&!g&&e.jsxs($,{variant:"outline",className:"text-[10px] h-5",children:[u.length,"/",N.length]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(ue,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(le,{value:r,onChange:i=>d(i.target.value),placeholder:s("sharedPage.filterPlaceholder",{tab:a}),"aria-label":s("sharedPage.filterPlaceholder",{tab:a}),className:"pl-8 h-9"})]}),!x&&!g&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s("sharedPage.showing",{visible:u.length,total:N.length,tab:a}),b?s("sharedPage.showingQuery",{query:b}):"",y?s("sharedPage.refreshing"):""]})]}),e.jsx(B,{className:"flex-1 min-h-0",children:x?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("sharedPage.loadingShared",{tab:a})}):g?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(xe,{className:"w-10 h-10 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("sharedPage.failedLoadShared",{tab:a})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:J})]}),e.jsxs(I,{size:"sm",variant:"outline",onClick:()=>{D()},children:[e.jsx(T,{className:"w-4 h-4 mr-2"}),s("sharedPage.retry")]})]})}):K?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("sharedPage.noSharedFound",{tab:a})}):Z?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("sharedPage.noMatch",{tab:a,query:b})}):e.jsx("div",{className:"p-2 space-y-1",children:u.map(i=>e.jsxs("button",{type:"button",onClick:()=>o(i.path),className:U("w-full text-left p-3 rounded-md border transition-colors",f?.path===i.path?"bg-primary/10 border-primary/30":"bg-background hover:bg-muted border-transparent"),children:[e.jsx("p",{className:"text-sm font-medium truncate",children:i.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:i.description}),e.jsx("p",{className:"text-[11px] text-muted-foreground/90 mt-2 font-mono truncate",children:i.path})]},`${i.type}:${i.path}`))})})]}),e.jsx("div",{className:"min-w-0 min-h-0 flex flex-col bg-muted/20",children:f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-4 py-3 border-b bg-background",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-base font-semibold truncate",children:f.name}),e.jsx($,{variant:"outline",className:"uppercase text-[10px]",children:f.type})]})}),e.jsxs("div",{className:"p-4 space-y-4 min-h-0 flex-1 flex flex-col",children:[e.jsx("div",{className:"rounded-md border bg-muted/35 p-3",children:e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(R,{label:s("sharedPage.pathLabel"),value:f.path,mono:!0}),P?.contentPath&&P.contentPath!==f.path&&e.jsx(R,{label:s("sharedPage.resolvedSource"),value:P.contentPath,mono:!0})]})}),e.jsx(ie,{className:"min-h-0 flex-1",children:e.jsx(de,{className:"p-0 h-full",children:e.jsx(B,{className:"h-full px-5 py-4",children:O?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("sharedPage.loadingMarkdown")}):_?e.jsxs(S,{variant:"destructive",className:"max-w-2xl",children:[e.jsx(E,{className:"h-4 w-4"}),e.jsx(M,{children:s("sharedPage.failedLoadContent")}),e.jsxs(L,{children:[e.jsx("p",{children:X}),e.jsx("div",{className:"mt-3",children:e.jsxs(I,{size:"sm",variant:"outline",onClick:()=>{W()},children:[e.jsx(T,{className:"w-4 h-4 mr-2"}),s("sharedPage.retryContent")]})})]})]}):e.jsx(pe,{content:P?.content??""})})})})]})]}):e.jsx("div",{className:"min-h-[320px] flex items-center justify-center p-6 text-center text-muted-foreground",children:s("sharedPage.selectOne",{tab:a.slice(0,-1)})})})]})})})]})}function F({label:s,value:a}){return e.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:s}),e.jsx("p",{className:"text-lg font-semibold leading-tight mt-1",children:a})]})}function R({label:s,value:a,mono:l=!1}){return e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:s}),e.jsx("p",{className:U("text-xs mt-1 break-words",l?"font-mono":"text-sm"),children:a})]})}function A(s,a){if(!(s instanceof Error))return a;const l=s.message.toLowerCase();return l.includes("failed to fetch")||l.includes("network")?"Connection to dashboard server lost or restarting. Keep `ccs config` running, then retry.":s.message||a}function pe({content:s}){const{t:a}=Q(),l=j.useMemo(()=>fe(s),[s]);return l.blocks.length===0&&l.frontmatter.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("sharedPage.noMarkdown")}):e.jsxs("div",{className:"space-y-5",children:[l.frontmatter.length>0?e.jsx("div",{className:"rounded-md border bg-muted/35 p-3",children:e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:l.frontmatter.map(t=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:ge(t.key)}),e.jsx("p",{className:"text-xs mt-1 break-words",children:t.value})]},`${t.key}:${t.value}`))})}):null,l.blocks.map((t,r)=>{if(t.type==="heading"){const d=t.level<=1?"text-xl font-semibold":t.level===2?"text-lg font-semibold":"text-base font-semibold";return e.jsx("h3",{className:d,children:k(t.text,`heading-${r}`)},`heading-${r}`)}return t.type==="paragraph"?e.jsx("p",{className:"text-sm leading-6 whitespace-pre-wrap",children:k(t.text,`paragraph-${r}`)},`paragraph-${r}`):t.type==="unordered-list"?e.jsx("ul",{className:"list-disc pl-5 space-y-1 text-sm leading-6",children:t.items.map((d,n)=>e.jsx("li",{children:k(d,`ul-item-${r}-${n}`)},`ul-item-${r}-${n}`))},`ul-${r}`):t.type==="ordered-list"?e.jsx("ol",{className:"list-decimal pl-5 space-y-1 text-sm leading-6",children:t.items.map((d,n)=>e.jsx("li",{children:k(d,`ol-item-${r}-${n}`)},`ol-item-${r}-${n}`))},`ol-${r}`):e.jsxs("div",{className:"rounded-md border bg-muted/60 p-3 font-mono text-xs leading-5 overflow-x-auto",children:[t.language&&e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground mb-2",children:t.language}),e.jsx("pre",{className:"whitespace-pre-wrap break-words m-0",children:t.content})]},`code-${r}`)})]})}function ge(s){return s.replace(/[-_]/g," ")}function k(s,a){const l=/(\*\*([^*]+)\*\*|`([^`]+)`|\*([^*]+)\*|\[([^\]]+)\]\(([^)]+)\))/g,t=[];let r=0,d=0;for(const n of s.matchAll(l)){const o=n[0],c=n.index??0;if(c>r&&t.push(s.slice(r,c)),n[2])t.push(e.jsx("strong",{className:"font-semibold",children:n[2]},`${a}-strong-${d}`));else if(n[3])t.push(e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[0.82em]",children:n[3]},`${a}-code-${d}`));else if(n[4])t.push(e.jsx("em",{className:"italic",children:n[4]},`${a}-em-${d}`));else if(n[5]&&n[6]){const h=n[6].trim();/^(https?:\/\/|mailto:)/i.test(h)?t.push(e.jsx("a",{href:h,target:"_blank",rel:"noreferrer",className:"text-primary underline underline-offset-2 hover:opacity-90",children:n[5]},`${a}-link-${d}`)):t.push(n[5])}else t.push(o);r=c+o.length,d+=1}return r<s.length&&t.push(s.slice(r)),t.length===0?[s]:t}function fe(s){const a=s.replace(/\r\n/g,`
2
2
  `).trim();if(!a)return{blocks:[],frontmatter:[]};let l=a;const t=[];if(l.startsWith(`---
3
3
  `)){const r=l.indexOf(`
4
4
  ---
@@ -1 +1 @@
1
- import{j as a,a1 as s,a2 as n}from"./radix-ui-Dt3edmE5.js";import"./react-vendor-CNOkPC89.js";import{c as e}from"./index-sCtK1kDn.js";function c({className:t,...r}){return a.jsx(s,{"data-slot":"switch",className:e("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...r,children:a.jsx(n,{"data-slot":"switch-thumb",className:e("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{c as S};
1
+ import{j as a,a1 as s,a2 as n}from"./radix-ui-Dt3edmE5.js";import"./react-vendor-CNOkPC89.js";import{c as e}from"./index-gjtWXRc2.js";function c({className:t,...r}){return a.jsx(s,{"data-slot":"switch",className:e("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...r,children:a.jsx(n,{"data-slot":"switch-thumb",className:e("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{c as S};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Dt3edmE5.js";import{L as P,r as o}from"./react-vendor-CNOkPC89.js";import{a as p,B as y,c as k,d as x,x as E,bd as M,C as g,j,k as N,_ as w,b as v,n as b,be as U,bf as z,I as B,bg as L}from"./index-sCtK1kDn.js";import{Y as $,Q,aW as Y,v as q,E as G,I as J,a4 as V,C as F,aX as H,ak as K}from"./icons-DR-ORtNe.js";import"./tanstack-B8i0evp-.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const W={new:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-900/50 dark:bg-blue-900/20 dark:text-blue-300",stable:"border-green-200 bg-green-50 text-green-700 dark:border-green-900/50 dark:bg-green-900/20 dark:text-green-300",planned:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/50 dark:bg-amber-900/20 dark:text-amber-300"};function X({status:s,className:a}){const{t}=p(),d={new:t("updates.statusNew"),stable:t("updates.statusStable"),planned:t("updates.statusPlanned")};return e.jsx(y,{variant:"outline",className:k("font-medium",W[s],a),children:d[s]})}const I="ccs:updates:notice-progress:v1";function Z(s){return s==="new"?"new":"seen"}function u(s,a){return a[s.id]??Z(s.status)}function A(s){return s!=="done"&&s!=="dismissed"}function ee(){if(typeof window>"u")return{};try{const s=window.localStorage.getItem(I);if(!s)return{};const a=JSON.parse(s);if(!a||typeof a!="object"||Array.isArray(a))return{};const t={};for(const[d,l]of Object.entries(a))typeof d=="string"&&(l==="new"||l==="seen"||l==="done"||l==="dismissed")&&(t[d]=l);return t}catch{return{}}}function se(s){typeof window>"u"||window.localStorage.setItem(I,JSON.stringify(s))}function R({state:s,className:a}){const{t}=p(),d={new:{label:t("updates.progressNeedsAction"),className:"border-amber-300/70 bg-amber-100/70 text-amber-800 dark:border-amber-500/40 dark:bg-amber-500/15 dark:text-amber-300",showDot:!0},seen:{label:t("updates.progressInReview"),className:"border-blue-300/70 bg-blue-100/70 text-blue-800 dark:border-blue-500/40 dark:bg-blue-500/15 dark:text-blue-300"},done:{label:t("updates.progressDone"),className:"border-emerald-300/70 bg-emerald-100/70 text-emerald-800 dark:border-emerald-500/40 dark:bg-emerald-500/15 dark:text-emerald-300"},dismissed:{label:t("updates.progressDismissed"),className:"border-muted-foreground/20 bg-muted text-muted-foreground dark:border-muted-foreground/30"}}[s];return e.jsxs(y,{variant:"outline",className:k("gap-1.5 border text-[10px] font-medium",d.className,a),children:[d.showDot&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),d.label]})}function ae({action:s}){const{t:a}=p();return e.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:s.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description})]}),s.type==="route"&&s.path&&e.jsx(x,{size:"sm",asChild:!0,children:e.jsxs(P,{to:s.path,children:[a("updates.open"),e.jsx($,{className:"h-3.5 w-3.5"})]})})]}),s.type==="command"&&s.command&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 rounded-md border bg-background px-2 py-1.5",children:[e.jsx(Q,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("code",{className:"min-w-0 flex-1 truncate text-[11px]",children:s.command}),e.jsx(E,{value:s.command})]})]})}function re({notice:s,progress:a,relatedEntries:t,onUpdateProgress:d}){const{t:l}=p();return s?e.jsxs("div",{className:"flex-1 min-w-0 bg-background grid grid-rows-[auto_minmax(0,1fr)] overflow-hidden",children:[e.jsxs("div",{className:"border-b bg-background px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h2",{className:"text-base font-semibold leading-tight",children:s.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.summary})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a&&e.jsx(R,{state:a}),e.jsx(X,{status:s.status})]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Y,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:l("updates.published",{date:M(s.publishedAt)})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(x,{size:"sm",onClick:()=>d("done"),children:[e.jsx(q,{className:"h-4 w-4"}),l("updates.markDone")]}),e.jsxs(x,{size:"sm",variant:"outline",onClick:()=>d("dismissed"),children:[e.jsx(G,{className:"h-4 w-4"}),l("updates.dismiss")]}),e.jsxs(x,{size:"sm",variant:"ghost",onClick:()=>d("new"),children:[e.jsx(J,{className:"h-4 w-4"}),l("updates.reopen")]})]})]}),e.jsx("div",{className:"min-h-0 p-4",children:e.jsxs("div",{className:"grid h-full gap-4 xl:grid-cols-[minmax(0,1.5fr)_minmax(320px,1fr)] overflow-hidden",children:[e.jsxs(g,{className:"h-full overflow-hidden",children:[e.jsxs(j,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-4 w-4 text-primary"}),e.jsx(N,{className:"text-base",children:l("updates.doNext")})]}),e.jsx(w,{children:s.primaryAction})]}),e.jsx(v,{className:"min-h-0",children:e.jsx(b,{className:"h-full pr-2",children:e.jsx("div",{className:"space-y-3",children:s.actions.map(n=>e.jsx(ae,{action:n},`${s.id}-${n.id}`))})})})]}),e.jsxs("div",{className:"grid h-full grid-rows-[minmax(0,1fr)_minmax(0,1fr)] gap-4 overflow-hidden",children:[e.jsxs(g,{className:"overflow-hidden",children:[e.jsxs(j,{className:"pb-3",children:[e.jsx(N,{className:"text-base",children:l("updates.impactedIntegrations")}),e.jsx(w,{children:l("updates.impactedDesc")})]}),e.jsx(v,{className:"min-h-0",children:e.jsx(b,{className:"h-full pr-2",children:e.jsx("div",{className:"space-y-2",children:t.map(n=>e.jsxs("div",{className:"rounded-md border bg-muted/20 p-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 truncate text-sm font-medium",children:n.name}),e.jsx(y,{variant:"outline",className:"h-5 px-1.5 text-[10px]",children:U[n.scope]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[n.routes[0]&&e.jsx(x,{size:"sm",variant:"outline",asChild:!0,children:e.jsx(P,{to:n.routes[0].path,children:n.routes[0].label})}),n.commands[0]&&e.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-1.5",children:[e.jsx("code",{className:"truncate rounded bg-background px-1.5 py-0.5 text-[11px]",children:n.commands[0]}),e.jsx(E,{value:n.commands[0]})]})]})]},n.id))})})})]}),e.jsxs(g,{className:"overflow-hidden",children:[e.jsxs(j,{className:"pb-3",children:[e.jsx(N,{className:"text-base",children:l("updates.whyMatters")}),e.jsx(w,{children:l("updates.whyMattersDesc")})]}),e.jsx(v,{className:"min-h-0",children:e.jsx(b,{className:"h-full pr-2",children:e.jsx("ul",{className:"space-y-2 text-sm text-muted-foreground",children:s.highlights.map(n=>e.jsxs("li",{children:["- ",n]},`${s.id}-${n}`))})})})]})]})]})})]}):e.jsx("div",{className:"flex h-full items-center justify-center rounded-lg border border-dashed bg-muted/20 p-6",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:l("updates.noUpdates")})})}function te({notice:s,progress:a,selected:t,onSelect:d}){return e.jsxs("button",{type:"button",onClick:d,className:k("w-full rounded-lg border px-3 py-3 text-left transition-colors",t?"border-primary/30 bg-primary/10":"border-transparent bg-background/40 hover:border-border hover:bg-muted/70"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:s.title}),e.jsx("p",{className:"line-clamp-2 text-xs text-muted-foreground",children:s.primaryAction})]}),e.jsx(F,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:M(s.publishedAt)}),e.jsx(R,{state:a})]})]})}function de(s,a){return a?[s.title,s.summary,s.primaryAction,...s.highlights,...s.commands,...s.actions.map(d=>`${d.label} ${d.description} ${d.command||""}`),...s.routes.map(d=>d.label)].join(" ").toLowerCase().includes(a):!0}function be(){const{t:s}=p(),a=o.useMemo(()=>[...z].sort((r,i)=>i.publishedAt.localeCompare(r.publishedAt)),[]),[t,d]=o.useState("inbox"),[l,n]=o.useState(""),[c,C]=o.useState(()=>ee()),[S,T]=o.useState(null);o.useEffect(()=>{se(c)},[c]);const h=o.useMemo(()=>{const r=l.trim().toLowerCase();return a.filter(i=>{const f=u(i,c);return de(i,r)?t==="done"?f==="done":t==="inbox"?A(f):!0:!1})},[a,c,l,t]),m=o.useMemo(()=>{const r=t==="all"?a:h;return r.find(i=>i.id===S)??r[0]??null},[a,S,t,h]),D=r=>{T(r.id),C(i=>u(r,i)!=="new"?i:{...i,[r.id]:"seen"})},O=o.useMemo(()=>a.filter(r=>A(u(r,c))).length,[a,c]),_=o.useMemo(()=>a.filter(r=>u(r,c)==="done").length,[a,c]);return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r bg-muted/30 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b bg-background space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("updates.inboxTitle")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("updates.inboxSubtitle")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"rounded-md border bg-background px-2 py-1.5",children:[e.jsx("p",{className:"text-muted-foreground",children:s("updates.needsAction")}),e.jsx("p",{className:"text-base font-semibold",children:O})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-1.5",children:[e.jsx("p",{className:"text-muted-foreground",children:s("updates.doneCount")}),e.jsx("p",{className:"text-base font-semibold",children:_})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(K,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(B,{value:l,onChange:r=>n(r.target.value),placeholder:s("updates.searchPlaceholder"),className:"h-9 pl-8"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:[{id:"inbox",label:s("updates.actionRequired")},{id:"done",label:s("updates.done")},{id:"all",label:s("updates.all")}].map(r=>e.jsx(x,{size:"sm",variant:t===r.id?"default":"outline",onClick:()=>d(r.id),children:r.label},r.id))})]}),e.jsx(b,{className:"flex-1",children:e.jsx("div",{className:"space-y-2 p-2",children:h.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-xs text-muted-foreground",children:s("updates.noNotices")}):h.map(r=>e.jsx(te,{notice:r,progress:u(r,c),selected:m?.id===r.id,onSelect:()=>D(r)},r.id))})})]}),e.jsx(re,{notice:m,progress:m?u(m,c):null,relatedEntries:m?L(m):[],onUpdateProgress:r=>{m&&C(i=>({...i,[m.id]:r}))}})]})}export{be as UpdatesPage};
1
+ import{j as e}from"./radix-ui-Dt3edmE5.js";import{L as P,r as o}from"./react-vendor-CNOkPC89.js";import{a as p,B as y,c as k,d as x,x as E,bd as M,C as g,j,k as N,_ as w,b as v,n as b,be as U,bf as z,I as B,bg as L}from"./index-gjtWXRc2.js";import{Y as $,Q,aW as Y,v as q,E as G,I as J,a4 as V,C as F,aX as H,ak as K}from"./icons-DR-ORtNe.js";import"./tanstack-B8i0evp-.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const W={new:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-900/50 dark:bg-blue-900/20 dark:text-blue-300",stable:"border-green-200 bg-green-50 text-green-700 dark:border-green-900/50 dark:bg-green-900/20 dark:text-green-300",planned:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/50 dark:bg-amber-900/20 dark:text-amber-300"};function X({status:s,className:a}){const{t}=p(),d={new:t("updates.statusNew"),stable:t("updates.statusStable"),planned:t("updates.statusPlanned")};return e.jsx(y,{variant:"outline",className:k("font-medium",W[s],a),children:d[s]})}const I="ccs:updates:notice-progress:v1";function Z(s){return s==="new"?"new":"seen"}function u(s,a){return a[s.id]??Z(s.status)}function A(s){return s!=="done"&&s!=="dismissed"}function ee(){if(typeof window>"u")return{};try{const s=window.localStorage.getItem(I);if(!s)return{};const a=JSON.parse(s);if(!a||typeof a!="object"||Array.isArray(a))return{};const t={};for(const[d,l]of Object.entries(a))typeof d=="string"&&(l==="new"||l==="seen"||l==="done"||l==="dismissed")&&(t[d]=l);return t}catch{return{}}}function se(s){typeof window>"u"||window.localStorage.setItem(I,JSON.stringify(s))}function R({state:s,className:a}){const{t}=p(),d={new:{label:t("updates.progressNeedsAction"),className:"border-amber-300/70 bg-amber-100/70 text-amber-800 dark:border-amber-500/40 dark:bg-amber-500/15 dark:text-amber-300",showDot:!0},seen:{label:t("updates.progressInReview"),className:"border-blue-300/70 bg-blue-100/70 text-blue-800 dark:border-blue-500/40 dark:bg-blue-500/15 dark:text-blue-300"},done:{label:t("updates.progressDone"),className:"border-emerald-300/70 bg-emerald-100/70 text-emerald-800 dark:border-emerald-500/40 dark:bg-emerald-500/15 dark:text-emerald-300"},dismissed:{label:t("updates.progressDismissed"),className:"border-muted-foreground/20 bg-muted text-muted-foreground dark:border-muted-foreground/30"}}[s];return e.jsxs(y,{variant:"outline",className:k("gap-1.5 border text-[10px] font-medium",d.className,a),children:[d.showDot&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),d.label]})}function ae({action:s}){const{t:a}=p();return e.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:s.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description})]}),s.type==="route"&&s.path&&e.jsx(x,{size:"sm",asChild:!0,children:e.jsxs(P,{to:s.path,children:[a("updates.open"),e.jsx($,{className:"h-3.5 w-3.5"})]})})]}),s.type==="command"&&s.command&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 rounded-md border bg-background px-2 py-1.5",children:[e.jsx(Q,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("code",{className:"min-w-0 flex-1 truncate text-[11px]",children:s.command}),e.jsx(E,{value:s.command})]})]})}function re({notice:s,progress:a,relatedEntries:t,onUpdateProgress:d}){const{t:l}=p();return s?e.jsxs("div",{className:"flex-1 min-w-0 bg-background grid grid-rows-[auto_minmax(0,1fr)] overflow-hidden",children:[e.jsxs("div",{className:"border-b bg-background px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h2",{className:"text-base font-semibold leading-tight",children:s.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.summary})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a&&e.jsx(R,{state:a}),e.jsx(X,{status:s.status})]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Y,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:l("updates.published",{date:M(s.publishedAt)})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(x,{size:"sm",onClick:()=>d("done"),children:[e.jsx(q,{className:"h-4 w-4"}),l("updates.markDone")]}),e.jsxs(x,{size:"sm",variant:"outline",onClick:()=>d("dismissed"),children:[e.jsx(G,{className:"h-4 w-4"}),l("updates.dismiss")]}),e.jsxs(x,{size:"sm",variant:"ghost",onClick:()=>d("new"),children:[e.jsx(J,{className:"h-4 w-4"}),l("updates.reopen")]})]})]}),e.jsx("div",{className:"min-h-0 p-4",children:e.jsxs("div",{className:"grid h-full gap-4 xl:grid-cols-[minmax(0,1.5fr)_minmax(320px,1fr)] overflow-hidden",children:[e.jsxs(g,{className:"h-full overflow-hidden",children:[e.jsxs(j,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-4 w-4 text-primary"}),e.jsx(N,{className:"text-base",children:l("updates.doNext")})]}),e.jsx(w,{children:s.primaryAction})]}),e.jsx(v,{className:"min-h-0",children:e.jsx(b,{className:"h-full pr-2",children:e.jsx("div",{className:"space-y-3",children:s.actions.map(n=>e.jsx(ae,{action:n},`${s.id}-${n.id}`))})})})]}),e.jsxs("div",{className:"grid h-full grid-rows-[minmax(0,1fr)_minmax(0,1fr)] gap-4 overflow-hidden",children:[e.jsxs(g,{className:"overflow-hidden",children:[e.jsxs(j,{className:"pb-3",children:[e.jsx(N,{className:"text-base",children:l("updates.impactedIntegrations")}),e.jsx(w,{children:l("updates.impactedDesc")})]}),e.jsx(v,{className:"min-h-0",children:e.jsx(b,{className:"h-full pr-2",children:e.jsx("div",{className:"space-y-2",children:t.map(n=>e.jsxs("div",{className:"rounded-md border bg-muted/20 p-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 truncate text-sm font-medium",children:n.name}),e.jsx(y,{variant:"outline",className:"h-5 px-1.5 text-[10px]",children:U[n.scope]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[n.routes[0]&&e.jsx(x,{size:"sm",variant:"outline",asChild:!0,children:e.jsx(P,{to:n.routes[0].path,children:n.routes[0].label})}),n.commands[0]&&e.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-1.5",children:[e.jsx("code",{className:"truncate rounded bg-background px-1.5 py-0.5 text-[11px]",children:n.commands[0]}),e.jsx(E,{value:n.commands[0]})]})]})]},n.id))})})})]}),e.jsxs(g,{className:"overflow-hidden",children:[e.jsxs(j,{className:"pb-3",children:[e.jsx(N,{className:"text-base",children:l("updates.whyMatters")}),e.jsx(w,{children:l("updates.whyMattersDesc")})]}),e.jsx(v,{className:"min-h-0",children:e.jsx(b,{className:"h-full pr-2",children:e.jsx("ul",{className:"space-y-2 text-sm text-muted-foreground",children:s.highlights.map(n=>e.jsxs("li",{children:["- ",n]},`${s.id}-${n}`))})})})]})]})]})})]}):e.jsx("div",{className:"flex h-full items-center justify-center rounded-lg border border-dashed bg-muted/20 p-6",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:l("updates.noUpdates")})})}function te({notice:s,progress:a,selected:t,onSelect:d}){return e.jsxs("button",{type:"button",onClick:d,className:k("w-full rounded-lg border px-3 py-3 text-left transition-colors",t?"border-primary/30 bg-primary/10":"border-transparent bg-background/40 hover:border-border hover:bg-muted/70"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:s.title}),e.jsx("p",{className:"line-clamp-2 text-xs text-muted-foreground",children:s.primaryAction})]}),e.jsx(F,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:M(s.publishedAt)}),e.jsx(R,{state:a})]})]})}function de(s,a){return a?[s.title,s.summary,s.primaryAction,...s.highlights,...s.commands,...s.actions.map(d=>`${d.label} ${d.description} ${d.command||""}`),...s.routes.map(d=>d.label)].join(" ").toLowerCase().includes(a):!0}function be(){const{t:s}=p(),a=o.useMemo(()=>[...z].sort((r,i)=>i.publishedAt.localeCompare(r.publishedAt)),[]),[t,d]=o.useState("inbox"),[l,n]=o.useState(""),[c,C]=o.useState(()=>ee()),[S,T]=o.useState(null);o.useEffect(()=>{se(c)},[c]);const h=o.useMemo(()=>{const r=l.trim().toLowerCase();return a.filter(i=>{const f=u(i,c);return de(i,r)?t==="done"?f==="done":t==="inbox"?A(f):!0:!1})},[a,c,l,t]),m=o.useMemo(()=>{const r=t==="all"?a:h;return r.find(i=>i.id===S)??r[0]??null},[a,S,t,h]),D=r=>{T(r.id),C(i=>u(r,i)!=="new"?i:{...i,[r.id]:"seen"})},O=o.useMemo(()=>a.filter(r=>A(u(r,c))).length,[a,c]),_=o.useMemo(()=>a.filter(r=>u(r,c)==="done").length,[a,c]);return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r bg-muted/30 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b bg-background space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("updates.inboxTitle")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("updates.inboxSubtitle")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"rounded-md border bg-background px-2 py-1.5",children:[e.jsx("p",{className:"text-muted-foreground",children:s("updates.needsAction")}),e.jsx("p",{className:"text-base font-semibold",children:O})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-1.5",children:[e.jsx("p",{className:"text-muted-foreground",children:s("updates.doneCount")}),e.jsx("p",{className:"text-base font-semibold",children:_})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(K,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(B,{value:l,onChange:r=>n(r.target.value),placeholder:s("updates.searchPlaceholder"),className:"h-9 pl-8"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:[{id:"inbox",label:s("updates.actionRequired")},{id:"done",label:s("updates.done")},{id:"all",label:s("updates.all")}].map(r=>e.jsx(x,{size:"sm",variant:t===r.id?"default":"outline",onClick:()=>d(r.id),children:r.label},r.id))})]}),e.jsx(b,{className:"flex-1",children:e.jsx("div",{className:"space-y-2 p-2",children:h.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-xs text-muted-foreground",children:s("updates.noNotices")}):h.map(r=>e.jsx(te,{notice:r,progress:u(r,c),selected:m?.id===r.id,onSelect:()=>D(r)},r.id))})})]}),e.jsx(re,{notice:m,progress:m?u(m,c):null,relatedEntries:m?L(m):[],onUpdateProgress:r=>{m&&C(i=>({...i,[m.id]:r}))}})]})}export{be as UpdatesPage};
@@ -24,7 +24,7 @@
24
24
  href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap"
25
25
  rel="stylesheet"
26
26
  />
27
- <script type="module" crossorigin src="/assets/index-sCtK1kDn.js"></script>
27
+ <script type="module" crossorigin src="/assets/index-gjtWXRc2.js"></script>
28
28
  <link rel="modulepreload" crossorigin href="/assets/react-vendor-CNOkPC89.js">
29
29
  <link rel="modulepreload" crossorigin href="/assets/radix-ui-Dt3edmE5.js">
30
30
  <link rel="modulepreload" crossorigin href="/assets/tanstack-B8i0evp-.js">
@@ -33,7 +33,7 @@
33
33
  <link rel="modulepreload" crossorigin href="/assets/utils-CzKF5WmX.js">
34
34
  <link rel="modulepreload" crossorigin href="/assets/form-utils-Bcoyqxpq.js">
35
35
  <link rel="modulepreload" crossorigin href="/assets/code-highlight-BRUf_pqB.js">
36
- <link rel="stylesheet" crossorigin href="/assets/index-kGiBvBM-.css">
36
+ <link rel="stylesheet" crossorigin href="/assets/index-CKpdevWy.css">
37
37
  </head>
38
38
  <body>
39
39
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaitranntt/ccs",
3
- "version": "7.56.0-dev.2",
3
+ "version": "7.56.0-dev.4",
4
4
  "description": "Claude Code Switch - Instant profile switching between Claude, GLM, Kimi, and more",
5
5
  "keywords": [
6
6
  "cli",
@@ -27,7 +27,8 @@
27
27
  "types": "dist/ccs.d.ts",
28
28
  "bin": {
29
29
  "ccs": "dist/ccs.js",
30
- "ccsd": "dist/ccs.js"
30
+ "ccs-droid": "dist/bin/droid-runtime.js",
31
+ "ccsd": "dist/bin/droid-runtime.js"
31
32
  },
32
33
  "files": [
33
34
  "dist/",
@@ -4,36 +4,49 @@
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
 
7
+ function getExecutablePaths() {
8
+ const packageJsonPath = path.join(__dirname, '../package.json');
9
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
10
+ const binEntries = packageJson.bin || {};
11
+ const uniqueRelativePaths = [...new Set(Object.values(binEntries))];
12
+
13
+ return uniqueRelativePaths.map((relativePath) => path.join(__dirname, '..', relativePath));
14
+ }
15
+
7
16
  /**
8
- * Add shebang to dist/ccs.js and make executable
17
+ * Add shebangs to all published bin entrypoints and make them executable.
9
18
  * Run after: tsc
10
19
  */
11
20
  function addShebang() {
12
- const ccsPath = path.join(__dirname, '../dist/ccs.js');
13
-
14
- if (!fs.existsSync(ccsPath)) {
15
- console.error('[X] dist/ccs.js not found. Run tsc first.');
21
+ const executablePaths = getExecutablePaths();
22
+ const missingPaths = executablePaths.filter((executablePath) => !fs.existsSync(executablePath));
23
+ if (missingPaths.length > 0) {
24
+ console.error(`[X] Missing built executable(s): ${missingPaths.join(', ')}. Run tsc first.`);
16
25
  process.exit(1);
17
26
  }
18
27
 
19
- let content = fs.readFileSync(ccsPath, 'utf8');
28
+ for (const executablePath of executablePaths) {
29
+ let content = fs.readFileSync(executablePath, 'utf8');
20
30
 
21
- // Add shebang if missing
22
- if (!content.startsWith('#!/usr/bin/env node')) {
23
- content = '#!/usr/bin/env node\n' + content;
24
- fs.writeFileSync(ccsPath, content);
25
- console.log('[OK] Shebang added to dist/ccs.js');
26
- }
31
+ if (!content.startsWith('#!/usr/bin/env node')) {
32
+ content = '#!/usr/bin/env node\n' + content;
33
+ fs.writeFileSync(executablePath, content);
34
+ console.log(`[OK] Shebang added to ${path.relative(path.join(__dirname, '..'), executablePath)}`);
35
+ }
27
36
 
28
- // Make executable (Unix-like systems)
29
- if (process.platform !== 'win32') {
30
- try {
31
- fs.chmodSync(ccsPath, 0o755);
32
- console.log('[OK] dist/ccs.js is now executable');
33
- } catch (err) {
34
- console.warn('[!] Could not chmod dist/ccs.js:', err.message);
37
+ if (process.platform !== 'win32') {
38
+ try {
39
+ fs.chmodSync(executablePath, 0o755);
40
+ console.log(
41
+ `[OK] ${path.relative(path.join(__dirname, '..'), executablePath)} is now executable`
42
+ );
43
+ } catch (err) {
44
+ console.warn(
45
+ `[!] Could not chmod ${path.relative(path.join(__dirname, '..'), executablePath)}: ${err.message}`
46
+ );
47
+ }
35
48
  }
36
49
  }
37
50
  }
38
51
 
39
- addShebang();
52
+ addShebang();
@@ -1,4 +0,0 @@
1
- import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as x,h as He}from"./react-vendor-CNOkPC89.js";import{B as R,c as _,T as Qe,p as $e,q as ze,r as Ke,s as Je,t as Be,v as qe,w as xe,d as j,I as M,a as q,n as ne,L as T,x as B,y as we,z as Ye,A as Ve,D as Ge,E as We,S as ue,F as se,G as le,H as Ce,J as Xe,K as Ze,M as ye,N as ke,O as Pe,Q as es,R as ss,U as he,V as pe,W as te,X as ts,Y as as,Z as de,C as Se,b as Oe,j as rs,k as ns,_ as is,$ as ls,a0 as os,a1 as cs,a2 as ds,a3 as ms,a4 as xs,a5 as us,a6 as hs,a7 as ps}from"./index-sCtK1kDn.js";import{a as gs,u as fs,b as ge}from"./tanstack-B8i0evp-.js";import{C as oe}from"./confirm-dialog-Bee0kh6i.js";import{t as P}from"./notifications-B2HqRBj7.js";import{L as ae,R as X,ai as Te,aj as js,E as Ns,f as vs,a3 as re,O as bs,ak as Ee,a4 as me,C as Ae,al as ws,a2 as Cs,am as ys,o as ce,X as ks,Z as _e,an as fe,m as je,ao as Re,ap as Ps,a6 as Ss,aq as Os,x as Me,ar as Ts,v as De,n as Es,as as As}from"./icons-DR-ORtNe.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CwEJfEUX.js";function _s({className:s,showTooltip:t=!0}){const n=e.jsxs(R,{variant:"outline",className:_("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return t?e.jsxs(Qe,{children:[e.jsx($e,{asChild:!0,children:n}),e.jsx(ze,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):n}function Ne(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(n=>n.test(s))}function Le(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Rs(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function Ms(s,t){const n={...s};return t.opus?n.ANTHROPIC_DEFAULT_OPUS_MODEL=t.opus:delete n.ANTHROPIC_DEFAULT_OPUS_MODEL,t.sonnet?n.ANTHROPIC_DEFAULT_SONNET_MODEL=t.sonnet:delete n.ANTHROPIC_DEFAULT_SONNET_MODEL,t.haiku?n.ANTHROPIC_DEFAULT_HAIKU_MODEL=t.haiku:delete n.ANTHROPIC_DEFAULT_HAIKU_MODEL,n}function Ds({profileName:s,target:t,data:n,settings:d,isLoading:l,isSaving:g,isTargetSaving:r,hasChanges:f,isRawJsonValid:a,onTargetChange:p,onRefresh:u,onDelete:v,onSave:b}){const k=g||r,N=l||k;return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),n?.path&&e.jsx(R,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*\//,"")}),Le(d)&&e.jsx(_s,{className:"ml-1"})]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default target:"}),e.jsxs(Ke,{value:t,onValueChange:S=>{N||p(S)},disabled:N,children:[e.jsx(Je,{className:"h-7 w-[170px] text-xs",disabled:N,children:e.jsx(Be,{})}),e.jsxs(qe,{children:[e.jsx(xe,{value:"claude",children:"Claude Code"}),e.jsx(xe,{value:"droid",children:"Factory Droid"})]})]}),r&&e.jsx(ae,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{variant:"ghost",size:"sm",onClick:u,disabled:N,children:e.jsx(X,{className:`w-4 h-4 ${l?"animate-spin":""}`})}),v&&e.jsx(j,{variant:"ghost",size:"sm",onClick:v,disabled:k,children:e.jsx(Te,{className:"w-4 h-4 text-destructive"})}),e.jsx(j,{size:"sm",onClick:b,disabled:k||!f||!a,children:g?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(js,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Ie({label:s,...t}){const[n,d]=x.useState(!1);return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx("label",{className:"text-sm font-medium",children:s}),e.jsxs("div",{className:"relative",children:[e.jsx(M,{type:n?"text":"password",className:"pr-10 font-mono",...t}),e.jsx(j,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3",onClick:()=>d(!n),tabIndex:-1,children:n?e.jsx(Ns,{className:"w-4 h-4"}):e.jsx(vs,{className:"w-4 h-4"})})]})]})}function Ls({currentSettings:s,newEnvKey:t,newEnvValue:n,onNewEnvKeyChange:d,onNewEnvValueChange:l,onEnvValueChange:g,onAddEnvVar:r}){const{t:f}=q();return e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([a,p])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(T,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[a,Ne(a)&&e.jsx(R,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:f("envEditor.sensitive")})]}),Ne(a)?e.jsx(Ie,{value:p,onChange:u=>g(a,u.target.value),className:"font-mono text-sm h-8"}):e.jsx(M,{value:p,onChange:u=>g(a,u.target.value),className:"font-mono text-sm h-8"})]},a))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:f("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:f("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:f("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(M,{placeholder:f("envEditor.keyPlaceholder"),value:t,onChange:a=>d(a.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:a=>a.key==="Enter"&&t.trim()&&r()}),e.jsx(M,{placeholder:f("envEditor.valuePlaceholder"),value:n,onChange:a=>l(a.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:a=>a.key==="Enter"&&t.trim()&&r()}),e.jsx(j,{variant:"outline",size:"sm",className:"h-8",onClick:r,disabled:!t.trim(),children:e.jsx(re,{className:"w-4 h-4"})})]})]})]})}function Is({profileName:s,target:t,data:n}){const{t:d}=q(),l=t==="droid";return e.jsx(ne,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(bs,{className:"w-4 h-4"}),d("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:d("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:n.profile})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:d("profileEditor.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(B,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:d("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:d("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:t})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:d("profileEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:d("profileEditor.runWithProfile")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(B,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:d(l?"profileEditor.droidAliasExplicit":"profileEditor.runOnDroid")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:l?`ccsd ${s} "prompt"`:`ccs ${s} --target droid "prompt"`}),e.jsx(B,{value:l?`ccsd ${s} "prompt"`:`ccs ${s} --target droid "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:d(l?"profileEditor.overrideToClaude":"profileEditor.overrideToClaudeExplicit")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' --target claude "prompt"']}),e.jsx(B,{value:`ccs ${s} --target claude "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:d("profileEditor.setAsDefault")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(B,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function Fs({value:s,onChange:t,placeholder:n="Search models...",className:d}){const[l,g]=x.useState(""),[r,f]=x.useState(null),{models:a,isLoading:p,isError:u,isFetching:v}=we(),b=Ye(),k=x.useMemo(()=>Ve(a,l,{category:r??void 0}),[a,l,r]),N=x.useMemo(()=>Ge(a,2),[a]),S=!l.trim()&&!r,F=x.useMemo(()=>{const c={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};k.forEach(h=>{c[h.category].push(h)});for(const h of Object.keys(c))c[h]=We(c[h]);return c},[k]),w=x.useCallback(()=>{b()},[b]),E=a.find(c=>c.id===s);return p&&a.length===0?e.jsxs("div",{className:_("space-y-2",d),children:[e.jsx(ue,{className:"h-10 w-full"}),e.jsx(ue,{className:"h-32 w-full"})]}):e.jsxs("div",{className:_("space-y-2 w-full min-w-0 overflow-hidden",d),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ee,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(M,{value:l,onChange:c=>g(c.target.value),placeholder:n,className:"pl-9"})]}),e.jsx(j,{variant:"outline",size:"icon",onClick:w,disabled:v,title:"Refresh models",children:v?e.jsx(ae,{className:"h-4 w-4 animate-spin"}):e.jsx(X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(R,{variant:r===null?"default":"outline",className:"cursor-pointer",onClick:()=>f(null),children:["All (",a.length,")"]}),Object.keys(se).map(c=>{const h=F[c].length;return h===0?null:e.jsxs(R,{variant:r===c?"default":"outline",className:"cursor-pointer",onClick:()=>f(c),children:[se[c]," (",h,")"]},c)})]}),E&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:E.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[le(E.pricing)," |"," ",Ce(E.context_length)]})]}),e.jsx(ne,{className:"h-72 w-full rounded-md border",children:u?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(j,{variant:"link",onClick:w,children:"Retry"})]}):k.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',l,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[S&&N.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(me,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:N.map(c=>e.jsx(ve,{model:c,isSelected:c.id===s,onClick:()=>t(c.id),showAge:!0},c.id))})]}),Object.keys(se).map(c=>{const h=F[c];return h.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:se[c]}),e.jsx("div",{className:"space-y-1",children:h.map(i=>e.jsx(ve,{model:i,isSelected:i.id===s,onClick:()=>t(i.id)},i.id))})]},c)})]})})]})}function ve({model:s,isSelected:t,onClick:n,showAge:d=!1}){return e.jsxs("button",{type:"button",onClick:n,className:_("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",t&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:_("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",t?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[d&&s.created&&e.jsx(R,{variant:"outline",className:_("text-[10px] px-1",t?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:Xe(s.created)}),s.isFree?e.jsx(R,{variant:"secondary",className:_("text-[10px] px-1",t?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(R,{variant:"outline",className:_("text-[10px] px-1 border-emerald-500/50 text-emerald-600",t?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:le(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:le(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Ce(s.context_length)})]})]})}function Us({selectedModel:s,value:t,onChange:n,className:d}){const{t:l}=q(),{models:g}=we(),r=x.useMemo(()=>s?Ze(s,g):{},[s,g]),f=()=>{n(r)},a=(u,v)=>{n({...t,[u]:v||void 0})},p=s&&Object.keys(r).length>0;return e.jsxs(ye,{className:_("group",d),children:[e.jsxs(ke,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(Ae,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),l("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",l("modelTierMapping.advanced"),")"]})]}),e.jsxs(Pe,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:l("modelTierMapping.description")}),p&&e.jsxs(j,{type:"button",variant:"outline",size:"sm",onClick:f,children:[e.jsx(ws,{className:"mr-1 h-4 w-4"}),l("modelTierMapping.autoSuggest",{provider:s?.split("/")[0]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(M,{id:"tier-opus",value:t.opus??"",onChange:u=>a("opus",u.target.value),placeholder:l("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(M,{id:"tier-sonnet",value:t.sonnet??"",onChange:u=>a("sonnet",u.target.value),placeholder:l("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(M,{id:"tier-haiku",value:t.haiku??"",onChange:u=>a("haiku",u.target.value),placeholder:l("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:l("modelTierMapping.footer")})]})]})}function Hs({profileName:s,target:t,data:n,currentSettings:d,newEnvKey:l,newEnvValue:g,onNewEnvKeyChange:r,onNewEnvValueChange:f,onEnvValueChange:a,onAddEnvVar:p,onEnvBulkChange:u}){const v=Le(d),b=d?.env,k=x.useMemo(()=>Rs(b??{}),[b]),N=b??{},S=i=>{if(u){const U={...N,ANTHROPIC_MODEL:i,ANTHROPIC_DEFAULT_OPUS_MODEL:i,ANTHROPIC_DEFAULT_SONNET_MODEL:i,ANTHROPIC_DEFAULT_HAIKU_MODEL:i};u(U)}else a("ANTHROPIC_MODEL",i),a("ANTHROPIC_DEFAULT_OPUS_MODEL",i),a("ANTHROPIC_DEFAULT_SONNET_MODEL",i),a("ANTHROPIC_DEFAULT_HAIKU_MODEL",i);P.success(te.t("commonToast.appliedModelAllTiers"),{duration:2e3})},F=i=>{if(u){const U=Ms(N,i);u(U)}else i.opus!==void 0&&a("ANTHROPIC_DEFAULT_OPUS_MODEL",i.opus||""),i.sonnet!==void 0&&a("ANTHROPIC_DEFAULT_SONNET_MODEL",i.sonnet||""),i.haiku!==void 0&&a("ANTHROPIC_DEFAULT_HAIKU_MODEL",i.haiku||"")},[w,E]=x.useState(!1),c=new Set(["ANTHROPIC_AUTH_TOKEN"]),h=Object.entries(N).filter(([i])=>!c.has(i));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(es,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ss,{className:"w-full",children:[e.jsx(he,{value:"env",className:"flex-1",children:v?"Configuration":"Environment Variables"}),e.jsx(he,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(pe,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:v?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(Fs,{value:N.ANTHROPIC_MODEL,onChange:S,placeholder:"Search OpenRouter models..."})]}),e.jsx(Us,{selectedModel:N.ANTHROPIC_MODEL,value:k,onChange:F}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"API Key"}),e.jsx(Ie,{value:N.ANTHROPIC_AUTH_TOKEN||"",onChange:i=>a("ANTHROPIC_AUTH_TOKEN",i.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),h.length>0&&e.jsxs(ye,{open:w,onOpenChange:E,children:[e.jsxs(ke,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(Ae,{className:_("h-4 w-4 transition-transform",w&&"rotate-90")}),e.jsx(Cs,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",h.length,")"]})]}),e.jsx(Pe,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:h.map(([i,U])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:i}),e.jsx(M,{value:U,onChange:Q=>a(i,Q.target.value),className:"font-mono text-xs h-8"})]},i))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(M,{placeholder:"VARIABLE_NAME",value:l,onChange:i=>r(i.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:i=>i.key==="Enter"&&l.trim()&&p()}),e.jsx(M,{placeholder:"value",value:g,onChange:i=>f(i.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:i=>i.key==="Enter"&&l.trim()&&p()}),e.jsx(j,{variant:"outline",size:"sm",className:"h-8",onClick:p,disabled:!l.trim(),children:e.jsx(re,{className:"w-4 h-4"})})]})]})]}):e.jsx(Ls,{currentSettings:d,newEnvKey:l,newEnvValue:g,onNewEnvKeyChange:r,onNewEnvValueChange:f,onEnvValueChange:a,onAddEnvVar:p})}),e.jsx(pe,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Is,{profileName:s,target:t,data:n})})]})]})})}function Qs({profileName:s,profileTarget:t,onDelete:n,onHasChangesUpdate:d}){const[l,g]=x.useState({}),[r,f]=x.useState(!1),[a,p]=x.useState(null),[u,v]=x.useState(""),[b,k]=x.useState(""),N=gs(),{data:S,isLoading:F,isError:w,refetch:E}=fs({queryKey:["settings",s],queryFn:async()=>{const m=await fetch(`/api/settings/${s}/raw`);if(!m.ok)throw new Error(`Failed to load settings: ${m.status}`);return m.json()}}),c=S?.settings,h=x.useMemo(()=>{if(a!==null)try{return JSON.parse(a)}catch{}if(c)return{...c,env:{...c.env,...l}}},[c,l,a]),i=x.useMemo(()=>a!==null?a:c?JSON.stringify(c,null,2):"",[a,c]),U=x.useCallback(m=>{p(m)},[]),Q=(m,y)=>{const D={...h?.env||{},[m]:y};g($=>({...$,[m]:y})),p(JSON.stringify({...h,env:D},null,2))},Y=m=>{const y={...h?.env||{},...m};g(D=>({...D,...m})),p(JSON.stringify({...h,env:y},null,2))},J=()=>{if(!u.trim())return;const m=u.trim(),y=b,D={...h?.env||{},[m]:y};g($=>({...$,[m]:y})),p(JSON.stringify({...h,env:D},null,2)),v(""),k("")},V=x.useMemo(()=>{try{return JSON.parse(i),!0}catch{return!1}},[i]),O=x.useMemo(()=>a!==null?a!==JSON.stringify(c,null,2):Object.keys(l).length>0,[a,l,c]),Z=x.useMemo(()=>{const m=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],y=h?.env||{};return m.filter(D=>!y[D]?.trim())},[h]);x.useEffect(()=>{d?.(O)},[O,d]);const C=ge({mutationFn:async()=>{let m;try{m=JSON.parse(i)}catch{m={...S?.settings,env:{...S?.settings?.env,...l}}}const y=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:m,expectedMtime:S?.mtime})});if(y.status===409)throw new Error("CONFLICT");if(!y.ok)throw new Error("Failed to save");return y.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["settings",s]}),N.invalidateQueries({queryKey:["profiles"]}),g({}),p(null),P.success(te.t("commonToast.settingsSaved"))},onError:m=>{m.message==="CONFLICT"?f(!0):P.error(m.message)}}),H=ge({mutationFn:async m=>(await as.profiles.update(s,{target:m}),m),onSuccess:()=>{N.invalidateQueries({queryKey:["profiles"]}),P.success(te.t("commonToast.defaultTargetUpdated"))},onError:(m,y)=>{const D=y==="droid"?"Factory Droid":"Claude Code",$=m.message.trim()?`: ${m.message}`:"";P.error(te.t("commonToast.failedUpdateDefaultTarget",{target:D,suffix:$}))}}),G=t||"claude",W=C.isPending||H.isPending,ee=async m=>{f(!1),m?(await E(),C.mutate()):(g({}),p(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ds,{profileName:s,target:G,data:S,settings:h,isLoading:F,isSaving:C.isPending,isTargetSaving:H.isPending,hasChanges:O,isRawJsonValid:V,onTargetChange:m=>{W||m!==G&&H.mutate(m)},onRefresh:()=>{W||E()},onDelete:n,onSave:()=>{W||C.mutate()}}),F?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(ae,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):w?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load settings."}),e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>E(),children:[e.jsx(X,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5 min-w-0",children:e.jsx(Hs,{profileName:s,target:G,data:S,currentSettings:h,newEnvKey:u,newEnvValue:b,onNewEnvKeyChange:v,onNewEnvValueChange:k,onEnvValueChange:Q,onEnvBulkChange:Y,onAddEnvVar:J})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(ys,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(ts,{rawJsonContent:i,isRawJsonValid:V,rawJsonEdits:a,settings:c,onChange:U,missingRequiredFields:Z})]})]}),e.jsx(oe,{open:r,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>ee(!0),onCancel:()=>ee(!1)})]},s)}const be="ccs:openrouter-banner-dismissed";function $s({onCreateClick:s}){const[t,n]=x.useState(!0),{modelCount:d,isLoading:l}=de();x.useEffect(()=>{const r=localStorage.getItem(be)==="true";n(r)},[]);const g=()=>{localStorage.setItem(be,"true"),n(!0)};return t?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(me,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",l?"300+":`${d}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(j,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(ce,{className:"w-3 h-3"})]}),e.jsxs(j,{size:"icon",variant:"ghost",onClick:g,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(ks,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function ie({badge:s,badgeClassName:t,className:n,title:d,description:l,visual:g,highlights:r,actionLabel:f,actionClassName:a,onAction:p,footer:u}){return e.jsxs(Se,{className:_("flex h-full flex-col border shadow-sm",n),children:[e.jsxs(rs,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[g,e.jsx(R,{variant:"secondary",className:t,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ns,{className:"text-base",children:d}),e.jsx(is,{className:"text-sm leading-6",children:l})]})]}),e.jsxs(Oe,{className:"mt-auto flex flex-1 flex-col gap-4 pt-0",children:[e.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map(v=>e.jsxs("div",{className:"flex items-center gap-2",children:[v.icon,e.jsx("span",{children:v.label})]},v.label))}),e.jsxs(j,{onClick:p,className:a,children:[f,e.jsx(Ps,{className:"ml-2 h-4 w-4"})]}),u?e.jsx("div",{className:"text-xs text-muted-foreground",children:u}):null]})]})}function zs({hasProfiles:s,profileCount:t,onOpenRouterClick:n,onAlibabaCodingPlanClick:d,onCliproxyClick:l,onCustomClick:g}){const{t:r}=q(),{modelCount:f,isLoading:a}=de(),p=a?"300+":`${f}+`,u=s?r("openrouterQuickStart.profileCount",{count:t}):r("openrouterQuickStart.recommended"),v=r(s?"openrouterQuickStart.selectProfileTitle":"apiProfiles.noProfilesYet"),b=s?r("openrouterQuickStart.summaryDescriptionWithProfiles",{count:t}):r("openrouterQuickStart.summaryDescriptionNoProfiles");return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-auto bg-muted/20 p-4 sm:p-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-7xl flex-col gap-4",children:[e.jsx(Se,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Oe,{className:"flex flex-col gap-4 p-5 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{variant:"secondary",children:u}),e.jsx(R,{variant:"outline",children:r("openrouterQuickStart.openrouterModelsBadge",{modelCountLabel:p})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:v}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:b})]})]}),e.jsx(j,{variant:"outline",onClick:g,className:"shrink-0",children:r("openrouterQuickStart.createCustomProfile")})]})}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(ie,{badge:r("openrouterQuickStart.recommended"),title:r("openrouterQuickStart.title"),description:r("openrouterQuickStart.description",{modelCountLabel:p}),visual:e.jsx("div",{className:"rounded-lg bg-accent/10 p-2",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(_e,{className:"h-3.5 w-3.5 text-accent"}),label:r("openrouterQuickStart.featureOneApi")},{icon:e.jsx(me,{className:"h-3.5 w-3.5 text-accent"}),label:r("openrouterQuickStart.featureTierMapping")}],actionLabel:r("openrouterQuickStart.createOpenRouterProfile"),actionClassName:"w-full bg-accent text-white hover:bg-accent/90",onAction:n,footer:e.jsxs(e.Fragment,{children:[r("openrouterQuickStart.getApiKeyAt")," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-accent hover:underline",children:["openrouter.ai/keys",e.jsx(ce,{className:"h-3 w-3"})]})]})}),e.jsx(ie,{badge:r("openrouterQuickStart.runtimeProviderBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",title:r("openrouterQuickStart.runtimeProviderTitle"),description:r("openrouterQuickStart.runtimeProviderDescription"),visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx(fe,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(fe,{className:"h-3.5 w-3.5 text-emerald-600"}),label:r("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(je,{className:"h-3.5 w-3.5 text-emerald-600"}),label:r("openrouterQuickStart.runtimeProviderFeatureSecrets")}],actionLabel:r("openrouterQuickStart.runtimeProviderTitle"),actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:l,footer:e.jsx("span",{children:r("openrouterQuickStart.runtimeProviderFooter")})}),e.jsx(ie,{badge:r("alibabaCodingPlanQuickStart.recommended"),badgeClassName:"bg-orange-500/10 text-orange-700 dark:bg-orange-500/20 dark:text-orange-200",className:"lg:col-span-2",title:r("alibabaCodingPlanQuickStart.title"),description:r("alibabaCodingPlanQuickStart.description"),visual:e.jsx("div",{className:"rounded-lg bg-orange-500/10 p-2",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"Alibaba Coding Plan",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Re,{className:"h-3.5 w-3.5 text-orange-600"}),label:r("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(je,{className:"h-3.5 w-3.5 text-orange-600"}),label:r("alibabaCodingPlanQuickStart.featureKeyFormat")}],actionLabel:r("alibabaCodingPlanQuickStart.createAlibabaProfile"),actionClassName:"w-full bg-orange-600 text-white hover:bg-orange-600/90",onAction:d,footer:e.jsxs(e.Fragment,{children:[r("alibabaCodingPlanQuickStart.readGuideAt")," ",e.jsxs("a",{href:"https://www.alibabacloud.com/help/en/model-studio/coding-plan",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-orange-700 hover:underline dark:text-orange-400",children:["Alibaba Cloud Model Studio",e.jsx(ce,{className:"h-3 w-3"})]})]})})]})]})})}function Ks({onCreateClick:s}){const{modelCount:t,isLoading:n}=de();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[n?"300+":`${t}+`," models available"]})]}),e.jsxs(j,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(_e,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Js({onCreateClick:s}){const{t}=q();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-orange-500/5 to-orange-500/10 dark:from-orange-500/10 dark:to-orange-500/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-orange-500/10 dark:bg-orange-500/20 rounded shrink-0",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-orange-700 dark:text-orange-300",children:t("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:t("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(j,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-orange-700 dark:text-orange-300 hover:text-orange-700 hover:bg-orange-500/10 dark:hover:bg-orange-500/20",children:[e.jsx(Re,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:t("alibabaCodingPlanPromo.add")})]})]})})}function rt(){const{t:s}=q(),t=He(),{data:n,isLoading:d,isError:l,refetch:g}=ls(),r=os(),f=cs(),a=ds(),p=ms(),u=xs(),v=us(),[b,k]=x.useState(null),[N,S]=x.useState(""),[F,w]=x.useState(!1),[E,c]=x.useState("normal"),[h,i]=x.useState(null),[U,Q]=x.useState(!1),[Y,J]=x.useState(null),V=x.useRef(null);hs();const O=x.useMemo(()=>n?.profiles||[],[n?.profiles]),Z=x.useMemo(()=>O.filter(o=>o.name.toLowerCase().includes(N.toLowerCase())),[O,N]),C=b?O.find(o=>o.name===b):null,H=o=>{U&&b!==o?J(o):k(o)},G=o=>{r.mutate(o,{onSuccess:()=>{b===o&&(k(null),Q(!1),J(null)),i(null)}})},W=o=>{w(!1),H(o)},ee=o=>{H(o)},m=(o,L)=>{const A=JSON.stringify(L,null,2)+`
2
- `,z=new Blob([A],{type:"application/json"}),I=URL.createObjectURL(z),K=document.createElement("a");K.href=I,K.download=o,document.body.appendChild(K),K.click(),K.remove(),URL.revokeObjectURL(I)},y=async()=>{try{const o=await f.mutateAsync();if(o.orphans.length===0){P.success("No orphan profile settings found");return}const L=o.orphans.filter(K=>K.validation.valid).length;if(!window.confirm(`Found ${o.orphans.length} orphan settings file(s). Register ${L} valid profile(s) now?`))return;const z=await a.mutateAsync({}),I=z.skipped.length>0?`, skipped ${z.skipped.length}`:"";P.success(`Registered ${z.registered.length} profile(s)${I}`)}catch(o){P.error(o.message)}},D=async()=>{if(!C)return;const o=window.prompt(`Copy profile "${C.name}" to new profile name:`,`${C.name}-copy`);if(!o)return;const L=o.trim();if(!L){P.error("Destination profile name cannot be empty");return}try{const A=await p.mutateAsync({name:C.name,data:{destination:L}});H(L),A.warnings&&A.warnings.length>0&&P.info(A.warnings.join(`
3
- `))}catch(A){P.error(A.message)}},$=async()=>{if(C)try{const o=await u.mutateAsync({name:C.name});m(`${C.name}.ccs-profile.json`,o.bundle),o.redacted?P.info("Export created with redacted token. Use include-secrets flow in CLI if needed."):P.success("Profile export downloaded")}catch(o){P.error(o.message)}},Fe=()=>{V.current?.click()},Ue=async o=>{const L=o.target.files?.[0];if(o.target.value="",!!L)try{const A=await L.text(),z=JSON.parse(A),I=await v.mutateAsync({bundle:z});I.name&&H(I.name),I.warnings&&I.warnings.length>0&&P.info(I.warnings.join(`
4
- `))}catch(A){P.error(A.message||"Failed to import profile bundle")}};return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsx($s,{onCreateClick:()=>w(!0)}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ss,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("apiProfiles.title")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(j,{size:"sm",variant:"outline",onClick:()=>void y(),disabled:f.isPending||a.isPending,"aria-label":"Discover orphan profiles",title:"Discover orphan profiles",children:e.jsx(X,{className:`w-4 h-4 ${f.isPending?"animate-spin":""}`})}),e.jsx(j,{size:"sm",variant:"outline",onClick:Fe,disabled:v.isPending,"aria-label":"Import profile bundle",title:"Import profile bundle",children:e.jsx(Os,{className:"w-4 h-4"})}),e.jsxs(j,{size:"sm",onClick:()=>{w(!0)},children:[e.jsx(re,{className:"w-4 h-4 mr-1"}),s("apiProfiles.new")]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Ee,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(M,{placeholder:s("apiProfiles.searchPlaceholder"),className:"pl-8 h-9",value:N,onChange:o=>S(o.target.value)})]})]}),e.jsx(ne,{className:"flex-1 min-h-0",children:d?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("apiProfiles.loadingProfiles")}):l?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Me,{className:"w-12 h-12 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.failedLoadTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.failedLoadDesc")})]}),e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>g(),children:[e.jsx(X,{className:"w-4 h-4 mr-1"}),s("apiProfiles.retry")]})]})}):Z.length===0?e.jsx("div",{className:"p-4 text-center",children:O.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Ts,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.noProfilesYet")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.noProfilesDesc")})]}),e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>{w(!0)},children:[e.jsx(re,{className:"w-4 h-4 mr-1"}),s("apiProfiles.createProfile")]})]}):e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:s("apiProfiles.noProfileMatch",{query:N})})}):e.jsx("div",{className:"p-2 space-y-1",children:Z.map(o=>e.jsx(Bs,{profile:o,isSelected:b===o.name,onSelect:()=>ee(o.name),onDelete:()=>i(o.name)},o.name))})}),O.length>0&&e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("apiProfiles.profileCount",{count:O.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(De,{className:"w-3 h-3 text-green-600"}),s("apiProfiles.configuredCount",{count:O.filter(o=>o.configured).length})]})]})}),e.jsx(Ks,{onCreateClick:()=>{c("openrouter"),w(!0)}}),e.jsx(Js,{onCreateClick:()=>{c("alibaba-coding-plan"),w(!0)}})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:C?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-2 border-b bg-background flex items-center justify-end gap-2",children:[e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>void D(),disabled:p.isPending,children:[e.jsx(Es,{className:"w-4 h-4 mr-1"}),"Copy"]}),e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>void $(),disabled:u.isPending,children:[e.jsx(As,{className:"w-4 h-4 mr-1"}),"Export"]})]}),e.jsx(Qs,{profileName:C.name,profileTarget:C.target,onDelete:()=>i(C.name),onHasChangesUpdate:Q},C.name)]}):e.jsx(zs,{hasProfiles:O.length>0,profileCount:O.length,onCliproxyClick:()=>{t("/cliproxy/ai-providers")},onOpenRouterClick:()=>{c("openrouter"),w(!0)},onAlibabaCodingPlanClick:()=>{c("alibaba-coding-plan"),w(!0)},onCustomClick:()=>{c("normal"),w(!0)}})})]}),e.jsx("input",{ref:V,type:"file",accept:".json,application/json",className:"hidden",onChange:o=>void Ue(o)}),e.jsx(ps,{open:F,onOpenChange:w,onSuccess:W,initialMode:E}),e.jsx(oe,{open:!!h,title:s("apiProfiles.deleteProfileTitle"),description:s("apiProfiles.deleteProfileDesc",{name:h??""}),confirmText:s("apiProfiles.delete"),variant:"destructive",onConfirm:()=>h&&G(h),onCancel:()=>i(null)}),e.jsx(oe,{open:!!Y,title:s("apiProfiles.unsavedChangesTitle"),description:s("apiProfiles.unsavedChangesDesc",{current:b??"",next:Y??""}),confirmText:s("apiProfiles.discardSwitch"),variant:"destructive",onConfirm:()=>{Q(!1),k(Y),J(null)},onCancel:()=>J(null)})]})}function Bs({profile:s,isSelected:t,onSelect:n,onDelete:d}){return e.jsxs("div",{className:_("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[s.configured?e.jsx(De,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(Me,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(R,{variant:"outline",className:"text-[10px] h-4 px-1.5 uppercase",children:s.target||"claude"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:s.settingsPath}),e.jsx(B,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(j,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:l=>{l.stopPropagation(),d()},children:e.jsx(Te,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{rt as ApiPage};