PageSourceSearch

https://hiiiam-lizpaw1.hf.space/assets/SkillDrawer-DI2-Qvlw.js

js hiiiam-lizpaw1.hf.space collected 2026-10-03 16:57:02 UTC 8,073 bytes, 2 lines download raw bytes

1import{r as c,j as e}from"./react-vendor-DbzdS4FP.js";import{u as V,k as J}from"./index-kSfDswZP.js";import{s as W}from"./markdown-B8mVm3vi.js";import{r as K}from"./index-DyV_w88U.js";import{u as q}from"./i18n-vendor-BrUIoOSg.js";import{cG as G,cX as g,eu as Q,i4 as U,cF as I,cd as Y,e_ as Z,en as ee,cE as f,cv as R}from"./ui-vendor-DCtmHMLE.js";import{d as te}from"./skillMetadata-TCIsEf6A.js";const se="index-module__markdownCopy__NGt4R",oe="index-module__controls__OIVwB",re="index-module__controlGroup__bPEXQ",le="index-module__previewToggle__b4LMK",ae="index-module__previewLabel__arwJn",ne="index-module__markdownViewer__2WXPx",ce="index-module__textareaContainer__zOSti",ie="index-module__textarea__aVu-C",b={markdownCopy:se,controls:oe,controlGroup:re,previewToggle:le,previewLabel:ae,markdownViewer:ne,textareaContainer:ce,textarea:ie};function de({content:i,showMarkdown:l=!0,onShowMarkdownChange:v,copyButtonProps:y={},markdownViewerProps:s={},textareaProps:o={},showControls:C=!0,editable:d=!1,onContentChange:_}){const{t:x}=q(),{message:t}=V(),[z,P]=c.useState(!1),[S,m]=c.useState(i),[h,T]=c.useState(l),E=c.useMemo(()=>W(i||""),[i]);c.useEffect(()=>{m(i)},[i]),c.useEffect(()=>{d&&!o.disabled?T(!1):T(l)},[d,o.disabled,l]);const w=async()=>{const u=h&&!(d&&!o.disabled)?i:d?S:i;if(u){P(!0);try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(u),t.success(x("common.copied"));else{const a=document.createElement("textarea");a.value=u,a.style.position="fixed",a.style.left="-999999px",a.style.top="-999999px",document.body.appendChild(a),a.focus(),a.select(),document.execCommand("copy"),a.remove(),t.success(x("common.copied"))}}catch(a){console.error("Failed to copy text: ",a),t.error(x("common.copyFailed"))}finally{P(!1)}}},F=u=>{const a=u.target.value;m(a),_&&_(a)},N=u=>{T(u),v&&v(u)},A={type:"text",size:"small",...y},k={style:{padding:16,height:"100%",overflow:"auto",backgroundColor:"var(--app-surface)",color:"var(--app-text)",borderRadius:6,...s.style},...s},O={rows:12,placeholder:x("common.contentPlaceholder"),...o};return e.jsxs("div",{className:b.markdownCopy,children:[C&&e.jsxs("div",{className:b.controls,children:[e.jsx("div",{children:x("common.content")}),e.jsxs("div",{className:b.controlGroup,children:[e.jsxs("div",{className:b.previewToggle,children:[e.jsx("span",{className:b.previewLabel,children:x("common.preview")}),e.jsx(G,{checked:h,onChange:N,size:"small"})]}),e.jsx(g,{icon:e.jsx(Q,{}),...A,onClick:w,loading:z})]})]}),h?e.jsx("div",{className:b.markdownViewer,children:e.jsx(U,{content:E,...k,components:K,dompurifyConfig:{ADD_TAGS:["pre","code"],ADD_ATTR:["data-block","data-state","data-lang","class"]}})}):e.jsx("div",{className:b.textareaContainer,children:e.jsx(I.TextArea,{value:d?S:i,onChange:F,...O,className:b.textarea,readOnly:!d||o.disabled})})]})}function L(i){try{const l=i.trim();if(!l.startsWith("---"))return null;const v=l.indexOf("---",3);if(v===-1)return null;const y=l.slice(3,v).trim();if(!y)return null;const s={};for(const o of y.split(`
2`)){const C=o.indexOf(":");if(C>0){const d=o.slice(0,C).trim(),_=o.slice(C+1).trim();s[d]=_}}return s}catch{return null}}const me=[{label:"all",value:"all"},{label:"console",value:"console"},{label:"discord",value:"discord"},{label:"telegram",value:"telegram"},{label:"dingtalk",value:"dingtalk"},{label:"feishu",value:"feishu"},{label:"imessage",value:"imessage"},{label:"qq",value:"qq"},{label:"mattermost",value:"mattermost"},{label:"wecom",value:"wecom"},{label:"mqtt",value:"mqtt"}],D=8,M=16;function ue({open:i,editing:l,editingName:v="",loading:y=!1,editingSkill:s,form:o,availableTags:C=[],onClose:d,onSubmit:_,onContentChange:x}){const{t,i18n:z}=q(),[P,S]=c.useState(!0),[m,h]=c.useState(""),[T,E]=c.useState(!1),w=c.useRef(null),[F,N]=c.useState("{}"),[A,k]=c.useState(""),{message:O}=V(),u=c.useCallback((r,n)=>{const p=m||n;if(!p||!p.trim())return Promise.reject(new Error(t("skills.pleaseInputContent")));const j=L(p);return j?j.name?j.description?Promise.resolve():Promise.reject(new Error(t("skills.frontmatterDescriptionRequired"))):Promise.reject(new Error(t("skills.frontmatterNameRequired"))):Promise.reject(new Error(t("skills.frontmatterRequired")))},[m,t]);c.useEffect(()=>{if(l&&s){const r=s.channels||["all"];h(s.content),N(JSON.stringify(s.config||{},null,2)),o.setFieldsValue({name:s.name,content:s.content,channels:r,preload:s.preload??!1,tags:s.tags||[],source:s.source}),k("")}else l||(h(""),N("{}"),k(""),o.resetFields())},[l,s,o,t]);const a=async r=>{let n;const p=F.trim();if(!p)n={};else try{n=JSON.parse(p),k("")}catch{k(t("skills.configInvalidJson"));return}_({...s,...r,content:m||r.content,source:(s==null?void 0:s.source)||"",config:n})},X=r=>{h(r),o.setFieldsValue({content:r}),o.validateFields(["content"]).catch(()=>{}),x&&x(r)},$=async()=>
2{if(!m.trim()){O.warning(t("skills.noContentToOptimize"));return}E(!0),w.current=new AbortController;const r=m;h("");try{await J.streamOptimizeSkill(r,n=>{h(p=>{const j=p+n;return o.setFieldsValue({content:j}),j})},w.current.signal,z.language),O.success(t("skills.optimizeSuccess"))}catch(n){n instanceof DOMException&&n.name==="AbortError"||O.error(n instanceof Error?n.message:t("skills.optimizeFailed"))}finally{E(!1),w.current=null}},B=()=>{w.current&&(w.current.abort(),E(!1),w.current=null)},H=l?e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(g,{onClick:d,children:t("common.cancel")}),e.jsx(g,{type:"primary",onClick:()=>o.submit(),disabled:y,children:t("common.save")})]}):e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("div",{children:T?e.jsx(g,{type:"default",danger:!0,icon:e.jsx(Z,{}),onClick:B,children:t("skills.stopOptimize")}):e.jsx(g,{type:"default",icon:e.jsx(Y,{}),onClick:$,disabled:!m.trim(),children:t("skills.optimizeWithAI")})}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(g,{onClick:d,children:t("common.cancel")}),e.jsx(g,{type:"primary",onClick:()=>o.submit(),children:t("skills.create")})]})]});return e.jsx(ee,{width:520,placement:"right",title:l?`${t("skills.viewSkill")}${v?`: ${v}`:""}`:t("skills.createSkill"),open:i,onClose:d,destroyOnHidden:!0,footer:H,children:y?e.jsx("div",{style:{padding:24,textAlign:"center"},children:t("common.loading")}):e.jsxs(f,{form:o,layout:"vertical",onFinish:a,children:[l?e.jsx(f.Item,{name:"name",label:"Name",children:e.jsx(I,{})}):e.jsx(f.Item,{name:"name",label:"Name",rules:[{required:!0,message:t("skills.pleaseInputName")}],children:e.jsx(I,{placeholder:t("skills.skillNamePlaceholder")})}),e.jsx(f.Item,{name:"content",label:"Content",rules:[{required:!0,validator:u}],children:e.jsx(de,{content:m,showMarkdown:P,onShowMarkdownChange:S,editable:!0,onContentChange:X,textareaProps:{...!l&&{placeholder:t("skills.contentPlaceholder")},rows:12}})}),e.jsx(f.Item,{name:"channels",label:t("skills.channels"),children:e.jsx(R,{mode:"multiple",options:me})}),e.jsx(f.Item,{name:"preload",label:t("skills.preload"),valuePropName:"checked",initialValue:!1,tooltip:t("skills.preloadHint"),children:e.jsx(G,{})}),e.jsx(f.Item,{name:"tags",label:t("skillPool.tags"),rules:[{validator:(r,n)=>(n||[]).find(j=>j.length>M)?Promise.reject(t("skillPool.tagTooLong",{max:M})):Promise.resolve()}],children:e.jsx(R,{mode:"tags",options:C.map(r=>({label:r,value:r})),placeholder:t("skillPool.tagsPlaceholder"),maxCount:D})}),e.jsx(f.Item,{label:t("skills.config"),validateStatus:A?"error":void 0,help:A||void 0,children:e.jsx(I.TextArea,{rows:4,value:F,onChange:r=>{N(r.target.value),k("")},placeholder:t("skills.configPlaceholder")})}),l&&s&&e.jsxs(e.Fragment,{children:[e.jsx(f.Item,{name:"source",label:t("skills.type"),children:e.jsx(I,{disabled:!0})}),e.jsx(f.Item,{label:t("skills.installedFrom"),children:e.jsx(I,{disabled:!0,value:te(s.installed_from)})})]})]})})}const be=Object.freeze(Object.defineProperty({__proto__:null,MAX_TAGS:D,MAX_TAG_LENGTH:M,SkillDrawer:ue,parseFrontmatter:L},Symbol.toStringTag,{value:"Module"}));export{de as M,ue as S,D as a,M as b,be as c,L as p};

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.