PageSourceSearch

https://ainowork.ai/assets/SkillsPage-BamRowc5.js

js ainowork.ai collected 2026-10-05 14:00:07 UTC 32,902 bytes, 1 lines download raw bytes

1import{r as e,j as s,a}from"./vendor-BrFbdvfN.js";import{f as t,u as r}from"./router-D1D-CY2D.js";import{A as l}from"./index-Dfu6jSUb.js";import{C as o}from"./ContentPanel-CLTGkTdc.js";import{A as n,t as i,a as c}from"./index-C_PVNRFj.js";import{A as d}from"./index-BUteM_8b.js";import{A as u}from"./index-BgxWPiGV.js";import{A as p}from"./index-DoNcyBlY.js";import{A as m}from"./index-TuALcKuB.js";import{A as h}from"./index-DKHVHqW4.js";import{A as x}from"./index-l8GLbxks.js";import{A as g}from"./index-DuveTdGO.js";import{A as f,a as j,b as v,c as b}from"./index-BR9Du_hM.js";import{A as k}from"./index-D63wnlpP.js";import{q as _,r as y,l as w,s as C,t as N,u as S,v as z,i as A,L as R,w as E,X as P,x as W,T as F,y as M,z as T,U as L,B as I,H as D,k as q,P as $,j as B,p as O,n as H}from"./icons-BM-S0DN8.js";import{u as U,a as K,b as V,c as G,d as J,e as Q,f as X,g as Y,h as Z,i as ee,p as se}from"./use-skills-COM8beUJ.js";import{u as ae}from"./useDebounce-Dj2iY7dT.js";import{A as te}from"./index-Cz96gkO2.js";import{A as re}from"./index-BGa2bK5J.js";import{A as le}from"./index-CPb4lQjj.js";import{A as oe}from"./index-BO_xbY_M.js";import{A as ne}from"./index-D1Cw86CL.js";import{u as ie}from"./i18n-BRRhXaHa.js";import{u as ce}from"./file-upload-CI-lr977.js";import{S as de}from"./files-zdtMSPH0.js";import"./query-OVg_3KLz.js";import"./zustand-BcOr8Ggu.js";import"./radix-EJqNORMW.js";import"./index-D5OYaf12.js";import"./motion-D0-MsV41.js";import"./use-auth-D9QQ1h8S.js";var ue=(e=>(e.enabled="enabled",e.disabled="disabled",e))(ue||{});function pe({tags:a}){const t=e.useRef(null),[r,l]=e.useState(a.length),o=e.useCallback(()=>{const e=t.current;if(!e)return;const s=e.clientWidth,a=e.querySelector("[data-measure]");if(!a)return;const r=a.querySelectorAll("[data-tag]");if(0===r.length)return;let o=0,n=0;for(let t=0;t<r.length;t++){const e=r[t].offsetWidth,a=n>0?6:0;if(!(o+a+e+(t<r.length-1?38:0)<=s))break;o+=a+e,n++}l(n)},[]);if(e.useEffect(()=>{o();const e=new ResizeObserver(o);return t.current&&e.observe(t.current),()=>e.disconnect()},[a,o]),0===a.length)return null;const n=a.slice(r),i=r<a.length;return s.jsxs("div",{ref:t,className:"flex items-center gap-1.5 mt-3 overflow-hidden",children:[s.jsx("div",{"data-measure":!0,className:"flex items-center gap-1.5",style:{position:"absolute",visibility:"hidden",pointerEvents:"none"},"aria-hidden":!0,children:a.map(e=>s.jsx("span",{"data-tag":!0,className:"px-1.5 py-0.5 rounded text-[10px] whitespace-nowrap shrink-0",children:e},e))}),a.slice(0,r).map(e=>s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] whitespace-nowrap shrink-0",style:{backgroundColor:"var(--aino-color-bg)",border:"1px solid var(--aino-color-border)",color:"var(--aino-color-text-muted)"},children:e},e)),i&&s.jsx(k,{content:s.jsx("div",{className:"flex flex-wrap gap-1",children:n.map(e=>s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] whitespace-nowrap",style:{backgroundColor:"var(--aino-color-bg)",border:"1px solid var(--aino-color-border)",color:"var(--aino-color-text-muted)"},children:e},e))}),children:s.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] whitespace-nowrap shrink-0 cursor-default",style:{backgroundColor:"var(--aino-color-accent-subtle)",border:"1px solid var(--aino-color-accent)",color:"var(--aino-color-accent)"},children:["+",n.length]})})]})}const me=[C,N,S,z,A];function he({skill:e,onDelete:a,onToggleStatus:t,onClick:r,t:l,refCallback:o,onMouseEnter:i,onMouseLeave:c}){const d=function(e){let s=0;for(let a=0;a<e.length;a++)s=31*s+e.charCodeAt(a)>>>0;return me[s%me.length]}(e.name),u=!0===e.editable;return s.jsxs(f,{ref:o,onClick:()=>{window.getSelection()?.toString()||r()},onMouseEnter:i,onMouseLeave:c,children:[s.jsx(j,{icon:s.jsx(d,{className:"w-5 h-5"}),title:e.name,"data-source":e.source,extraRight:s.jsx(g,{variant:e.status===ue.enabled?"success":"default",size:"sm",children:e.status===ue.enabled?l("card.status_enabled"):l("card.status_disabled")})}),s.jsxs(v,{children:[s.jsx("p",{className:"text-xs leading-relaxed",style:{color:"var(--aino-color-text-muted)",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.description}),s.jsx(pe,{tags:e.tags??[]})]}),s.jsxs(b,{className:"justify-between",children:[s.jsx("div",{className:"flex items-center gap-2",children:!u&&e.repo_name?s.jsx(g,{variant:"info",size:"sm",children:e.repo_name}):s.jsxs("span",{className:"text-[10px]",style:{color:"var(--aino-color-text-muted)",fontFamily:"var(--aino-font-mono)"},children:["v",e.version,".0"]})}),s.jsxs("div",{className:"flex items-center gap-1 -mr-1",children:[s.jsx(n,{ghost:!0,size:"icon-xs",style:{color:e.status===ue.enabled?"var(--aino-color-success)":"var(--aino-color-text-muted)"},title:e.status===ue.enabled?l("card.action_disable"):l("card.action_enable"),onClick:s=>{s.stopPropagation(),t(e.id,e.status)},children:e.status===ue.enabled?s.jsx(_,{}):s.jsx(y,{})}),u&&s.jsx(h,{title:l("card.delete_popover_title"),description:l("card.delete_popover_description"),confirmText:l("card.delete_popover_confirm"),variant:"danger",onConfirm:async()=>{await a(e.id)},children:s.jsx(n,{ghost:!0,variant:"danger",size:"icon-xs",title:l("card.action_delete"),children:s.jsx(w,{})})})]})]})]})}const xe="user://";function ge({open:a,repo:t,onClose:r,onSuccess:l}){const{t:o}=ie("capabilities"),d=null!==t,u=Y(),p=X(),m=Z(),[h,x]=e.useState(""),[g,f]=e.useState(""),[j,v]=e.useState("main"),[b,k]=e.useState(""),[_,y]=e.useState(""),[w,C]=e.useState(!1),[N,S]=e.useState([]),[z,A]=e.useState(1),[W,F]=e.useState(0),[M,T]=e.useState(""),[L,I]=e.useState(!1),[D,q]=e.useState(!1),[$,B]=e.useState(!1),[O,H]=e.useState(!1),[U,K]=e.useState(!1),V=e.useRef(""),G=e.useRef(""),J=e.useRef(!0),Q=e.useRef(0),ee=ae(g,500),se=ae(M,300);e.useEffect(()=>{a&&(t?(x(t.name),f(t.url),v(t.branch),k(t.subdirectory||""),y(t.description||""),V.current=t.url,G.current="",S([]),A(1),F(0),T(""),I(!1),q(!1),B(!1),H(!1),K(!1),J.current=!0,Q.current=0):(x(""),f(""),v("main"),k(""),y(""),V.current="",G.current="",S([]),A(1),F(0),T(""),I(!1),q(!1),B(!1),H(!1),K(!1),J.current=!0,Q.current=0))},[a,t]);const ce=e.useCallback(async(e,s,a,t,r)=>{const l=g.trim();if(!l)return;Q.current+=1;const o=Q.current;s();try{const s=await m.mutateAsync({url:l,page:e.page,page_size:20,search:e.search||void 0});if(Q.current!==o)return;s.data&&a(s.data)}catch{if(Q.current!==o)return;t()}finally{Q.current===o&&r()}},[g,m]),de=e.useCallback(e=>ce({page:e},()=>{I(!0),K(!1)},e=>{S(e.branches),v(e.default_branch),F(e.total),A(e.page),K(!1),H(!0)},()=>{S([]),K(!0)},()=>I(!1)),[ce]),ue=e.useCallback((e,s)=>s?ce({page:e,search:s},()=>B(!0),e=>{S(e.branches),F(e.total),A(e.page),H(!0)},()=>{},()=>
1B(!1)):void 0,[ce]),pe=e.useCallback((e,s)=>ce({page:e,search:s},()=>q(!0),e=>{S(s=>[...s,...e.branches]),F(e.total),A(e.page),H(!0)},()=>{},()=>q(!1)),[ce]);e.useEffect(()=>{if(!a)return;const e=g.trim();if(e&&!e.startsWith("user://"))try{const s=new URL(e).pathname.replace(/\.git$/,"").replace(/^\/|\/$/g,"");!s||h.trim()&&h.trim()!==G.current||(x(s),G.current=s)}catch{}},[g,a]),e.useEffect(()=>{if(!a)return;const e=ee.trim();if(!e||e.startsWith("user://"))return S([]),A(1),F(0),void I(!1);d&&e===V.current||(T(""),A(1),de(1))},[ee,a,d]),e.useEffect(()=>{if(!a)return;if(J.current)return void(J.current=!1);const e=g.trim();e&&!e.startsWith("user://")&&se&&(A(1),ue(1,se))},[se]);const me=e.useCallback(e=>{T(e)},[]),he=e.useCallback(()=>{pe(z+1,M||void 0)},[z,M,pe]),xe=N.length>0&&N.length<W,ge=g.trim().startsWith("user://")||N.length>0||d,fe=h.trim().length>0&&g.trim().length>0&&j.trim().length>0&&ge&&!w,je=d||O;e.useEffect(()=>{U&&i.error(o("skills.market_page.repo_branch_failed"))},[U,o]);const ve=e.useMemo(()=>L?s.jsx(R,{className:"h-3.5 w-3.5 animate-spin",style:{color:"var(--aino-color-text-muted)"}}):O?s.jsx(E,{className:"h-3.5 w-3.5",style:{color:"var(--aino-color-success)"}}):U?s.jsx(P,{className:"h-3.5 w-3.5",style:{color:"var(--aino-color-error)"}}):null,[L,O,U]),be=e.useMemo(()=>N.length>0?N.map(e=>s.jsx(oe.Option,{value:e,children:e},e)):[s.jsx(oe.Option,{value:j,children:j},"__current")],[N,j]);return s.jsxs(c,{open:a,onClose:r,maxWidth:"480px",children:[s.jsx(c.Header,{title:o(d?"skills.market_page.edit_repo":"skills.market_page.add_repo")}),s.jsx(c.Body,{children:s.jsxs(te,{noValidate:!0,children:[s.jsx(re,{label:o("skills.market_page.repo_url"),required:!0,htmlFor:"repo-url",children:s.jsx(le,{id:"repo-url",value:g,onChange:e=>f(e.target.value),placeholder:o("skills.market_page.repo_url_placeholder"),size:"sm",suffix:ve})}),s.jsx("div",{style:{display:je?void 0:"none"},children:s.jsx(re,{label:o("skills.market_page.repo_name"),required:!0,htmlFor:"repo-name",children:s.jsx(le,{id:"repo-name",value:h,onChange:e=>x(e.target.value),placeholder:o("skills.market_page.repo_name_placeholder"),size:"sm"})})}),s.jsx("div",{style:{display:je?void 0:"none"},children:s.jsx(re,{label:o("skills.market_page.repo_branch"),required:!0,error:U?o("skills.market_page.repo_branch_failed"):void 0,children:s.jsx(oe,{value:j,onChange:e=>v(e),placeholder:o("skills.market_page.repo_branch_placeholder"),size:"sm",disabled:w,loading:L,searchable:N.length>0,searchPlaceholder:o("skills.market_page.repo_branch_search_placeholder"),searchValue:M,searchLoading:$,onSearchChange:me,onLoadMore:he,loadingMore:D,hasMore:xe,matchTriggerWidth:!0,emptyText:o("skills.market_page.repo_branch_empty"),children:be})})}),s.jsx("div",{style:{display:je?void 0:"none"},children:s.jsx(re,{label:o("skills.market_page.repo_subdirectory"),htmlFor:"repo-subdirectory",children:s.jsx(le,{id:"repo-subdirectory",value:b,onChange:e=>k(e.target.value),placeholder:o("skills.market_page.repo_subdirectory_placeholder"),size:"sm"})})}),s.jsx("div",{style:{display:je?void 0:"none"},children:s.jsx(re,{label:o("skills.market_page.repo_description"),htmlFor:"repo-description",children:s.jsx(ne,{id:"repo-description",value:_,onChange:e=>y(e.target.value),placeholder:o("skills.market_page.repo_description_placeholder"),size:"sm",rows:3})})})]})}),s.jsxs(c.Footer,{children:[s.jsx(n,{variant:"secondary",onClick:r,disabled:w,children:o("skills.market_modal.cancel")}),s.jsx(n,{variant:"primary",onClick:async()=>{if(fe){C(!0);try{if(d)await p.mutateAsync({id:t.id,data:{name:h.trim(),url:g.trim(),branch:j.trim()||"main",subdirectory:b.trim()||"",description:_.trim()||void 0}}),i.success(o("skills.market_page.update_repo_success")),l();else{const e=await u.mutateAsync({name:h.trim(),url:g.trim(),branch:j.trim()||"main",subdirectory:b.trim()||"",description:_.trim()||void 0});i.success(o("skills.market_page.create_repo_success")),l(e?.id)}}finally{C(!1)}}},disabled:!fe,children:o(w?"skills.create_skill_modal.confirming":d?"skills.create_skill_modal.confirm":"skills.market_page.add_repo")})]})]})}async function fe(e){if(e.isFile){return[{file:await new Promise((s,a)=>{e.file(s,a)}),path:e.fullPath.startsWith("/")?e.fullPath.slice(1):e.fullPath}]}const s=e.createReader(),a=[],t=()=>new Promise((e,a)=>s.readEntries(e,a));let r=await t();for(;r.length>0;){for(const e of r){const s=await fe(e);a.push(...s)}r=await t()}return a}function je({open:a,onClose:t,onSuccess:r}){const l=ee(),{t:o}=ie("capabilities"),u=e.useRef(null),[p,m]=e.useState(!0),[h,x]=e.useState(!1),[g,f]=e.useState([]),[j,v]=e.useState(!1),[b,k]=e.useState(new Set),[_,y]=e.useState(""),[w,C]=e.useState(""),[N,S]=e.useState(""),[z,A]=e.useState(!1);e.useEffect(()=>{a&&(m(!0),x(!1),f([]),k(new Set),y(""),C(""),S(""),A(!1))},[a]),e.useEffect(()=>{if(g.length>1){const e=g.filter(e=>e.parsed?.name&&e.parsed?.name).map(e=>e.session_id);k(new Set(e))}},[g]);const R=e.useMemo(()=>new Set(g.filter(e=>e.parsed?.name&&e.parsed?.name).map(e=>e.session_id)),[g]),E=g.length>1&&b.size===R.size,P=e.useCallback(e=>{k(s=>{const a=new Set(s);return a.has(e)?a.delete(e):a.add(e),a})},[]),M=e.useCallback(()=>{k(E?new Set:new Set(R))},[E,R]),T=e.useCallback(async e=>{x(!0);try{for(const s of e)await ce({file:s.file,destPath:s.path,storage:de.skillUpload});const a=new Set;let t=!1;for(const s of e)if(s.path.toLowerCase().endsWith("skill.md")){const e=s.path.split("/");e.pop();const r=e.join("/");r?a.add(r):t=!0}t&&a.add("");const r=[];for(const e of a)try{const s=await se(e),a=s.data?.items?.[0];a&&r.push({session_id:a.session_id,parsed:a.parsed?{name:a.parsed.name,description:a.parsed.description,tags:a.parsed.tags,metadata:a.parsed.metadata}:void 0,has_conflict:a.has_conflict,files:a.files})}catch(s){console.error("Failed to parse uploaded skill directory:",e,s)}if(0===r.length)return void i.error(o("skills.create_skill_modal.upload_error"));f(r),m(!1),1===r.length&&r[0].parsed&&(y(r[0].parsed.name||""),C(r[0].parsed.description||""),S((r[0].parsed.tags||[]).join(", ")))}finally{x(!1),u.current&&(u.current.value="")}},[o]),L=e.useCallback(async()=>{const e=u.current;if(!e||!e.files||0===e.files.length)return;const s=Array.from(e.files).map(e=>({file:e,path:e.webkitRelativePath||e.name}));await T(s)},[T]),I=e.useCallback(e=>{e.preventDefault(),e.stopPropagation()},[]),D=e.useCallback(e=>{e.preventDefault(),e.stopPropagation(),v(!0)},[]),q=e.useCallback(e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget===e.target&&v(!1)},[]),$=e.useCallback(async e=>{e.preventDefault(),e.stopPropagation(),v(!1);const s=e.dataTransfer.items;if(!s||0===s.length)return;const a=[];for(let t=0;t<s.length;t++){const e=s[t];if("file"!==e.kind)continue;const r=e.webkitGetAsEntry?.();if(!r)continue;const l=await fe(r);a.push(...l)}0!==a.length?await T(a):i.error(o("skills.create_skill_modal.upload_error"))},[T,o]),B=1===g.length&&_.trim().length>0&&!z,O=g.length>1&&!z&&b.size>0,H=B||O,U=()=>{m(!0),f([]),k(new Set),y(""),C(""),S("")},K=e=>o(`skills.create_skill_modal.${e}`),V=g.length>1,G=R.size,J=g.length-G;return s.jsxs(c,{open:a,onClose:t,maxWidth:"520px",children:[s.jsx(c.Header,{title:K(p?"title_upload":V?"title_batch_review":"title_review")}),s.jsx(c.Body,{className:"space-y-4",children:p?s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:u,type:"file",webkitdirectory:"",multiple:!0,className:"hidden",onChange:L}),s.jsx("div",{className:"flex flex-col items-center justify-center gap-3 p-8 rounded-xl cursor-pointer transition-colors border-2 border-dashed",style:{borderColor:j?"var(--aino-color-accent)":"var(--aino-color-border)",backgroundColor:j?"var(--aino-color-accent-subtle)":"var(--aino-color-card-alt)"},onClick:()=>u.current?.click(),onDragOver:I,onDragEnter:D,onDragLeave:q,onDrop:$,children:h?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"w-8 h-8 rounded-full animate-spin border-2 border-t-transparent",style:{borderColor:"var(--aino-color-accent)",borderTopColor:"transparent"}}),s.jsx("p",{className:"text-sm",style:{color:"var(--aino-color-text-muted)"},children:K("uploading")})]}
1):s.jsxs(s.Fragment,{children:[s.jsx(W,{className:"w-10 h-10",style:{color:"var(--aino-color-text-muted)"}}),s.jsx("p",{className:"text-sm font-medium",style:{color:"var(--aino-color-text)"},children:K("upload_click")}),s.jsx("p",{className:"text-xs",style:{color:"var(--aino-color-text-muted)"},children:K("upload_hint")})]})})]}):V?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-xs",style:{color:"var(--aino-color-text-muted)"},children:o("skills.create_skill_modal.batch_count",{count:g.length})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs",style:{color:"var(--aino-color-text-muted)"},children:o("skills.create_skill_modal.batch_selected_count",{selected:b.size,total:G})}),s.jsx(n,{ghost:!0,size:"sm",onClick:M,children:o(E?"skills.create_skill_modal.batch_deselect_all":"skills.create_skill_modal.batch_select_all")})]})]}),s.jsx("div",{className:"space-y-2 max-h-[320px] overflow-y-auto",children:g.map((e,a)=>{const t=!!e.parsed?.name&&!!e.parsed?.name,r=b.has(e.session_id),l=e.has_conflict;return s.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg",style:{backgroundColor:"var(--aino-color-card-alt)",opacity:t?1:.5},children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t?s.jsx(d,{size:"sm",checked:r,onChange:()=>P(e.session_id)}):s.jsx(d,{size:"sm",checked:!1,disabled:!0}),s.jsx("span",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium shrink-0",style:{backgroundColor:"var(--aino-color-accent-subtle)",color:"var(--aino-color-accent)"},children:a+1}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("p",{className:"text-sm font-medium truncate",style:{color:"var(--aino-color-text)"},children:e.parsed?.name||"-"}),l&&s.jsx("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded text-[10px] shrink-0",style:{backgroundColor:"color-mix(in srgb, var(--aino-color-warning) 12%, transparent)",color:"var(--aino-color-warning)"},title:o("skills.create_skill_modal.batch_conflict_warning"),children:s.jsx(F,{className:"w-3 h-3"})})]}),!t&&s.jsx("p",{className:"text-[10px] mt-0.5",style:{color:"var(--aino-color-text-muted)"},children:o("skills.create_skill_modal.batch_item_invalid")}),l&&s.jsx("p",{className:"text-[10px] mt-0.5",style:{color:"var(--aino-color-warning)"},children:o("skills.create_skill_modal.batch_conflict_warning")})]})]}),s.jsx("span",{className:"text-xs shrink-0",style:{color:"var(--aino-color-text-muted)"},children:o("skills.create_skill_modal.batch_file_count",{count:e.files.length})})]},e.session_id)})}),g.filter(e=>e.has_conflict).length>0&&s.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg text-xs",style:{backgroundColor:"color-mix(in srgb, var(--aino-color-warning) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--aino-color-warning) 20%, transparent)",color:"var(--aino-color-warning)"},children:[s.jsx(F,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),s.jsx("span",{children:o("skills.create_skill_modal.batch_conflict_summary",{count:g.filter(e=>e.has_conflict).length})})]}),J>0&&s.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg text-xs",style:{backgroundColor:"color-mix(in srgb, var(--aino-color-text-muted) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--aino-color-text-muted) 15%, transparent)",color:"var(--aino-color-text-muted)"},children:[s.jsx(F,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),s.jsx("span",{children:o("skills.create_skill_modal.batch_item_invalid",{count:J})})]}),s.jsx(n,{ghost:!0,size:"sm",onClick:U,children:K("re_upload")})]}):s.jsxs(s.Fragment,{children:[s.jsx(ve,{label:K("field_name"),required:!0,children:s.jsx(le,{placeholder:K("field_name_placeholder"),value:_,onChange:e=>y(e.target.value)})}),s.jsx(ve,{label:K("field_tags"),children:s.jsx(le,{placeholder:K("field_tags_placeholder"),value:N,onChange:e=>S(e.target.value)})}),s.jsx(ve,{label:K("field_description"),children:s.jsx(ne,{size:"sm",placeholder:K("field_description_placeholder"),value:w,onChange:e=>C(e.target.value)})}),g[0]&&g[0].files.length>0&&s.jsx("div",{className:"p-2 rounded-lg text-xs",style:{backgroundColor:"var(--aino-color-card-alt)"},children:s.jsx("p",{className:"font-medium mb-1",style:{color:"var(--aino-color-text-muted)"},children:o("skills.create_skill_modal.files_uploaded")})}),s.jsx(n,{ghost:!0,size:"sm",onClick:U,children:K("re_upload")})]})}),s.jsxs(c.Footer,{children:[s.jsx(n,{variant:"secondary",size:"sm",onClick:t,children:K("cancel")}),!p&&s.jsx(n,{variant:"primary",size:"sm",onClick:async()=>
1{if(H){A(!0);try{if(1===g.length){const e=await l.mutateAsync({name:_.trim(),description:w.trim(),tags:N.split(",").map(e=>e.trim()).filter(Boolean),source:8,upload_session_id:g[0].session_id,metadata:g[0].parsed?.metadata});e.warning?i.warning(e.warning):i.success(o("skills.create_skill_modal.success"))}else{let s=0,a=0;for(const t of g)if(b.has(t.session_id)&&t.parsed?.name&&t.parsed?.name)try{const e=await l.mutateAsync({name:t.parsed.name,description:t.parsed.description,tags:t.parsed.tags||[],source:8,upload_session_id:t.session_id,metadata:t.parsed.metadata});s++,e.warning&&i.warning(e.warning)}catch(e){console.error("Failed to create skill:",t.parsed?.name,e),a++}a>0?i.success(o("skills.create_skill_modal.batch_success_partial",{success:s,fail:a})):i.success(o("skills.create_skill_modal.batch_success",{count:s}))}r(),t()}finally{A(!1)}}},disabled:!H,children:z?K("batch_confirming"):V?o("skills.create_skill_modal.batch_confirm_n",{count:b.size}):K("confirm")})]})]})}function ve({label:e,hint:a,required:t,children:r}){return s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("label",{className:"flex items-center gap-1 text-xs font-medium",style:{color:"var(--aino-color-text)"},children:[e,t&&s.jsx("span",{style:{color:"var(--aino-color-error, #ef4444)"},children:"*"})]}),r,a&&s.jsx("p",{className:"text-[11px] leading-relaxed",style:{color:"var(--aino-color-text-muted)"},children:a})]})}function be(e){return e===ue.enabled?"var(--aino-color-success)":(ue.disabled,"var(--aino-color-text-muted)")}function ke(){const{t:c}=ie("capabilities"),{loading:g,repos:f,reposLoading:j,selectedRepoId:v,setSelectedRepoId:b,browseErrors:k,search:_,setSearch:y,statusFilters:C,setStatusFilters:N,skills:S,totalPages:z,page:R,setPage:E,deleteSkill:P,toggleSkillStatus:W,handleSync:Y,confirmDeleteRepo:Z,handleToggleRepoActive:ee,refresh:se,loadRepos:te,syncing:re,syncRepo:le}=function(){const[s,a]=e.useState(1),[t,r]=e.useState({page:1,page_size:32}),[l,o]=e.useState(""),[n,c]=e.useState([]),d=ae(l,200),u=ae(s,200),[p,m]=e.useState([]),[h,x]=e.useState(!0),[g,f]=e.useState(null),[j,v]=e.useState([]),[b,k]=e.useState(!1),{data:_,isLoading:y,refetch:w}=U(t),C=K(),N=V(),{data:S}=G(),z=J(),A=Q(),R=X(),E=_?.items??[],P=_?.total??0,W=Math.max(1,Math.ceil(P/32)),F=(()=>{const e=p.find(e=>e.url?.startsWith(xe));return e?.id??null})();e.useEffect(()=>{S&&(m(S.items),x(!1))},[S]),e.useEffect(()=>{a(1);const e={page:1,page_size:32};n.length>0&&(e.status=n.join(",")),g&&(e.repo_id=g),d&&(e.search=d),r(e)},[g,n,d]),e.useEffect(()=>{const e={page:u,page_size:32};n.length>0&&(e.status=n.join(",")),g&&(e.repo_id=g),l&&(e.search=l),r(e)},[u]),e.useEffect(()=>{s>W&&a(W)},[W,s]);const M=e.useCallback(async()=>{x(!0);try{await w()}finally{x(!1)}},[w]),T=e.useCallback(()=>{w()},[w]),L=e.useCallback(async e=>{k(!0);try{const s=await z.mutateAsync(e);s&&v(s.errors||[]),i.success("Sync successful"),T()}finally{k(!1)}},[T,z]),I=e.useCallback(async()=>{g&&await L(g)},[g,L]),D=e.useCallback(async e=>{await C.mutateAsync(e)},[C]),q=e.useCallback(async(e,s)=>{const a=s===ue.enabled?ue.disabled:ue.enabled;await N.mutateAsync({code:e,status:a})},[N]),$=e.useCallback(async e=>{await A.mutateAsync(e.id),i.success("Repo deleted"),g===e.id&&f(null),M()},[g,M,A]),B=e.useCallback(async e=>{await R.mutateAsync({id:e.id,data:{is_active:!e.is_active}}),i.success(e.is_active?"Repo disabled":"Repo enabled"),e.is_active||g!==e.id||f(null),M()},[g,M,R]);return{skills:E,total:P,loading:y,page:s,totalPages:W,setPage:a,repos:p,reposLoading:h,selectedRepoId:g,setSelectedRepoId:f,personalRepoId:F,browseErrors:j,syncing:b,search:l,setSearch:o,statusFilters:n,setStatusFilters:c,deleteSkill:D,toggleSkillStatus:q,handleSync:I,syncRepo:L,confirmDeleteRepo:$,handleToggleRepoActive:B,refresh:T,loadRepos:M}}(),oe=t({from:"/capabilities/skills"}),ne=r({from:"/capabilities/skills"}),[ce,de]=e.useState(null),pe=e.useRef(new Map),me=e.useCallback(e=>{const s=pe.current.get(e);s&&de({id:e,rect:s.getBoundingClientRect()})},[]),fe=e.useCallback(()=>{de(null)},[]),ve=e.useRef(!1);e.useEffect(()=>{ve.current||(ve.current=!0,oe.repoId&&b(oe.repoId),oe.status&&N(oe.status.split(",")),oe.page&&E(Number(oe.page)))},[]),e.useEffect(()=>{const e={repoId:void 0,status:void 0,page:void 0};v&&(e.repoId=v),C.length>0&&(e.status=C.join(",")),R>1&&(e.page=String(R)),ne({search:e,replace:!0})},[v,C,R,ne]);const[ke,ye]=e.useState(!1),[we,Ce]=e.useState(!1),[Ne,Se]=e.useState(null),ze=e.useRef(!1);e.useEffect(()=>{if(ze.current){const e=f.find(e=>e.url?.startsWith(xe));e&&(b(e.id),ze.current=!1)}},[f,b]);const Ae=e.useCallback(()=>{const e=f.find(e=>e.url?.startsWith(xe));e?b(e.id):(ze.current=!0,te()),se()},[f,b,se,te]),Re=e.useCallback(async e=>{Ce(!1),Se(null),await te(),e&&(b(e),le(e))},[te,b,le]),Ee=f.find(e=>e.id===v),Pe=1===Ee?.source,We=e=>c(`skills.${e}`),Fe=e=>c(`skills.market_page.${e}`);return s.jsxs(l,{children:[s.jsxs(m,{className:"w-[280px] flex flex-col shrink-0","data-tour":"skill-repo-sidebar",children:[s.jsxs(m.Header,{className:"justify-between",children:[s.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--aino-color-text)"},children:Fe("skill_repos")}),s.jsx(n,{ghost:!0,size:"icon",onClick:()=>Ce(!0),title:Fe("add_repo"),children:s.jsx(M,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-3 space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-semibold px-2 mb-2 uppercase tracking-wider",style:{color:"var(--aino-color-text-muted)"},children:We("filter.repo_title")}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2 p-1.5 px-2 rounded cursor-pointer transition-colors text-sm",style:{color:null===v?"var(--aino-color-accent)":"var(--aino-color-text-muted)",backgroundColor:null===v?"var(--aino-color-card-alt)":"transparent"},onClick:()=>b(null),onMouseEnter:e=>{null!==v&&(e.currentTarget.style.backgroundColor="var(--aino-color-card-alt)")},onMouseLeave:e=>{null!==v&&(e.currentTarget.style.backgroundColor="transparent")},children:[s.jsx(T,{className:"w-3.5 h-3.5 shrink-0"}),s.jsx("span",{children:We("filter.repo_all")})]}),f.filter(e=>e.url?.startsWith(xe)).map(e=>{const a=v===e.id;return s.jsxs("div",{className:"flex items-center gap-2 p-1.5 px-2 rounded cursor-pointer transition-colors text-sm",style:{color:a?"var(--aino-color-accent)":"var(--aino-color-text-muted)",backgroundColor:a?"var(--aino-color-card-alt)":"transparent"},onClick:()=>b(e.id),onMouseEnter:e=>{a||(e.currentTarget.style.backgroundColor="var(--aino-color-card-alt)")},onMouseLeave:e=>{a||(e.currentTarget.style.backgroundColor="transparent")},children:[s.jsx(L,{className:"w-3.5 h-3.5 shrink-0"}),s.jsx("span",{children:We("filter.repo_personal")})]},e.id)}),!j&&0===f.filter(e=>!e.url?.startsWith(xe)).length&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-6 text-xs px-4",style:{color:"var(--aino-color-text-muted)"},children:[s.jsx(I,{className:"w-8 h-8 mb-2 opacity-30"}),s.jsx("p",{className:"font-medium text-center",children:Fe("no_repos")}),s.jsxs("p",{className:"text-center mt-1",children:[Fe("no_repos_desc_prefix")," ",s.jsx("span",{className:"underline cursor-pointer hover:text-[var(--aino-color-accent)]",onClick:()=>Ce(!0),children:Fe("add_repo")}),Fe("no_repos_desc_suffix")]})]}),f.filter(e=>!e.url?.startsWith(xe)).map(e=>
1{const a=v===e.id,t=1===e.source;return s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors text-[13px] group/repo",style:{color:a?"var(--aino-color-accent)":"var(--aino-color-text)",backgroundColor:a?"var(--aino-color-card-alt)":"transparent"},onClick:()=>b(e.id),children:[s.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.is_active?"#22c55e":"var(--aino-color-border)"},title:e.is_active?Fe("active"):Fe("inactive")}),s.jsx("span",{className:"flex-1 truncate",children:e.name}),t?s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded shrink-0",style:{backgroundColor:"var(--aino-color-accent-subtle)",color:"var(--aino-color-accent)"},children:Fe("builtin_badge")}):s.jsxs(u,{children:[s.jsx(u.Trigger,{children:s.jsx(n,{ghost:!0,size:"icon",className:"w-6 h-6 rounded opacity-0 group-hover/repo:opacity-100 transition-opacity",onClick:e=>e.stopPropagation(),"aria-label":Fe("more_actions"),children:s.jsx(D,{className:"w-4 h-4 text-aino-text-muted"})})}),s.jsxs(u.Content,{align:"end",sideOffset:4,children:[s.jsxs(u.Item,{onClick:()=>Se(e),children:[s.jsx(q,{className:"w-4 h-4"}),Fe("edit_repo")]}),s.jsx(u.Item,{onSelect:e=>e.preventDefault(),children:s.jsx(h,{title:c("skills.market_page.delete_repo_confirm",{name:e.name}),confirmText:Fe("delete_repo"),variant:"danger",onConfirm:()=>Z(e),children:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(w,{className:"w-4 h-4"}),Fe("delete_repo")]})})}),s.jsx(u.Separator,{}),s.jsx(u.Item,{onClick:()=>ee(e),children:e.is_active?s.jsxs(s.Fragment,{children:[s.jsx($,{className:"w-4 h-4"}),Fe("disable")]}):s.jsxs(s.Fragment,{children:[s.jsx(B,{className:"w-4 h-4"}),Fe("enable")]})})]})]})]},e.id)})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-semibold px-2 mb-2 uppercase tracking-wider",style:{color:"var(--aino-color-text-muted)"},children:We("filter.status_title")}),s.jsx("div",{className:"space-y-0.5",children:[ue.enabled,ue.disabled].map(e=>s.jsxs("label",{className:"flex items-center gap-2 p-1.5 px-2 rounded cursor-pointer transition-colors",style:{color:"var(--aino-color-text)"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="var(--aino-color-border-subtle)"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent"},children:[s.jsx(d,{checked:C.includes(e),onChange:()=>(e=>{N(C.includes(e)?C.filter(s=>s!==e):[...C,e])})(e)}),s.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:be(e)}}),s.jsx("span",{className:"text-sm",children:e===ue.enabled?We("filter.status_active"):We("filter.status_disabled")})]},e))})]})]})]}),s.jsxs(o,{icon:A,title:Ee?Ee.url?.startsWith(xe)?We("filter.repo_personal"):Ee.name:We("page.title"),description:Ee?void 0:We("page.description"),toolbar:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(x,{placeholder:We("page.search_placeholder"),value:_,onChange:e=>y(e.target.value)}),Ee&&!Pe&&!Ee?.url?.startsWith(xe)&&s.jsxs(n,{ghost:!0,size:"sm",loading:!1,onClick:Y,children:[s.jsx(O,{className:re?"w-4 h-4 animate-spin":"w-4 h-4"}),s.jsx("span",{className:"text-xs",children:Fe("sync")})]}),(!v||Ee?.url?.startsWith(xe))&&s.jsxs(n,{variant:"primary",className:"flex items-center gap-1.5",size:"sm","data-tour":"skill-create-btn",onClick:()=>ye(!0),children:[s.jsx(H,{className:"w-4 h-4"}),We("page.create_skill")]})]}),children:[k.length>0&&s.jsxs("div",{className:"mx-4 mt-3 flex items-start gap-2 px-3 py-2 rounded-lg text-[12px]",style:{backgroundColor:"color-mix(in srgb, var(--aino-color-warning) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--aino-color-warning) 30%, transparent)",color:"var(--aino-color-warning)"},children:[s.jsx(F,{className:"w-4 h-4 shrink-0 mt-0.5"}),s.jsx("div",{children:k.map((e,a)=>s.jsx("div",{children:e},a))})]}),s.jsx(p,{items:S,loading:g&&0===S.length,renderItem:e=>s.jsx(he,{skill:e,onDelete:P,onToggleStatus:W,onClick:()=>ne({to:"/capabilities/skills/$skillId",params:{skillId:e.id}}),t:We,refCallback:s=>{s?pe.current.set(e.id,s):pe.current.delete(e.id)},onMouseEnter:()=>me(e.id),onMouseLeave:fe}),itemKey:e=>{return e.id||(s=e.name,`${e.market_repo_id||""}:${s}`);var s},empty:s.jsxs("div",{className:"flex flex-col items-center justify-center h-40 text-sm text-aino-text-muted",children:[s.jsx(A,{className:"w-10 h-10 mb-3 opacity-30"}),s.jsx("p",{className:"font-medium",children:We("empty.title")}),s.jsx("p",{className:"text-xs mt-1",children:We("empty.description")})]}),page:R,totalPages:z,onPageChange:E,dataTour:"skill-card-grid"})]}),ce&&a.createPortal(s.jsx(_e,{preview:ce,skill:S.find(e=>e.id===ce.id)??null,t:We}),document.body),s.jsx(je,{open:ke,onClose:()=>ye(!1),onSuccess:Ae}),s.jsx(ge,{open:we||null!==Ne,repo:Ne,onClose:()=>{Ce(!1),Se(null)},onSuccess:Re})]})}function _e({preview:e,skill:a,t:t}){if(!a)return null;const r=a.description,l=a.tags??[],o=r||l.length>0,n=24+18*(r?Math.ceil(r.length/60):0)+(l.length>0?28:0),i=window.innerHeight-e.rect.bottom-8,c=i>=n||i>=e.rect.top-8;return s.jsx("div",{className:"fixed z-50 pointer-events-none",style:{left:e.rect.left,width:e.rect.width,top:c?e.rect.bottom+8:e.rect.top-n-8},children:s.jsx("div",{className:"rounded-xl border shadow-[var(--aino-sha
1dow-md)] p-3",style:{backgroundColor:"var(--aino-color-panel)",borderColor:"var(--aino-color-border)"},children:o?s.jsxs(s.Fragment,{children:[r&&s.jsx("p",{className:"text-xs leading-relaxed mb-2",style:{color:"var(--aino-color-text)"},children:r}),l.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:l.map(e=>s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] whitespace-nowrap",style:{backgroundColor:"var(--aino-color-bg)",border:"1px solid var(--aino-color-border)",color:"var(--aino-color-text-muted)"},children:e},e))})]}):s.jsx("div",{className:"text-xs",style:{color:"var(--aino-color-text-muted)"},children:t("card.no_description")})})})}export{ke as SkillsPage};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.