'+(t?r:E(r,!0))+`
`:""+(t?r:E(r,!0))+`
`}blockquote({tokens:s}){return`${this.parser.parse(s)}`}html({text:s}){return s}def(s){return""}heading({tokens:s,depth:e}){return`
${this.parser.parseInline(s)}
`}table(s){let e="",t="";for(let r=0;r${E(s,!0)}`}br(s){return"An error occurred:
"+E(t.message+"",!0)+"";return e?Promise.resolve(n):n}if(e)return Promise.reject(t);throw t}}},N=new Wt;function x(s,e){return N.parse(s,e)}x.options=x.setOptions=function(s){return N.setOptions(s),x.defaults=N.defaults,_e(x.defaults),x};x.getDefaults=me;x.defaults=H;x.use=function(...s){return N.use(...s),x.defaults=N.defaults,_e(x.defaults),x};x.walkTokens=function(s,e){return N.walkTokens(s,e)};x.parseInline=N.parseInline;x.Parser=C;x.parser=C.parse;x.Renderer=ie;x.TextRenderer=ze;x.Lexer=z;x.lexer=z.lex;x.Tokenizer=le;x.Hooks=W;x.parse=x;x.options;x.setOptions;x.use;x.walkTokens;x.parseInline;C.parse;z.lex;const Xt=lt({__name:"SkillEditor",props:{mode:{},slug:{},forkOf:{},initialName:{},initialDescription:{},initialAllowedTools:{},initialArgumentHint:{},initialModel:{},initialUserInvocable:{type:Boolean},initialDisableModelInvocation:{type:Boolean},initialContext:{},initialAgent:{},initialHooks:{},initialBody:{},initialAuthor:{},initialAuthorEmail:{},initialTags:{},availableTools:{},availableModels:{},availableTags:{}},setup(s,{expose:e}){e();const t=s,n=t.availableTools??["Bash","Read","Write","Edit","Glob","Grep","WebFetch","WebSearch","Task","NotebookEdit"],r=t.availableModels??[{id:"claude-opus-4-6",display_name:"Claude Opus 4.6"},{id:"claude-sonnet-4-5-20250929",display_name:"Claude Sonnet 4.5"},{id:"claude-haiku-4-5-20251001",display_name:"Claude Haiku 4.5"}],i=Q(()=>!!t.forkOf),l=m(t.initialName||""),c=m(t.initialDescription||""),a=m(t.initialArgumentHint||""),p=m(t.initialModel||""),u=m(t.initialUserInvocable??!0),g=m(t.initialDisableModelInvocation??!1),d=m(t.initialContext||""),w=m(t.initialAgent||""),b=m(t.initialHooks||""),y=m(t.initialTags?t.initialTags.split(",").map(h=>h.trim()).filter(Boolean):[]),I=m(""),F=m(!1),V=m(),U=t.availableTags?t.availableTags.split(",").map(h=>h.trim()).filter(Boolean):[],Z=m(t.initialBody||""),O=m(!1),B=m(""),ce=m(""),ue=m(""),pe=m(typeof localStorage<"u"&&localStorage.getItem("skillshere-token")||""),_=m(new Set(t.initialAllowedTools?t.initialAllowedTools.split(",").map(h=>h.trim()).filter(Boolean):[]));function Je(h){_.value.has(h)?_.value.delete(h):_.value.add(h),_.value=new Set(_.value)}const We=Q(()=>{const h=I.value.toLowerCase().trim(),k=new Set(y.value.map($=>$.toLowerCase())),R=U.filter($=>!k.has($.toLowerCase())&&(!h||$.toLowerCase().includes(h)));return h&&!k.has(h)&&!R.some($=>$.toLowerCase()===h)&&R.push(h),R}),Xe=h=>!U.some(k=>k.toLowerCase()===h.toLowerCase());function he(h){const k=h.trim().toLowerCase();k&&!y.value.some(R=>R.toLowerCase()===k)&&y.value.push(k),I.value="",V.value?.focus()}function Ke(h){y.value.splice(h,1)}function Ye(h){h.key==="Enter"||h.key===","?(h.preventDefault(),I.value.trim()&&he(I.value)):h.key==="Backspace"&&!I.value&&y.value.length&&y.value.pop()}let K;function et(){K=setTimeout(()=>{F.value=!1},200)}function tt(h){clearTimeout(K),he(h)}const Y=Q(()=>t.mode==="edit"&&t.slug?t.slug:l.value.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)||"my-skill"),rt=Q(()=>t.forkOf?Y.value===t.forkOf:!1),nt=Q(()=>Z.value.split(` `).length);let de=m(""),ee;it(Z,h=>{clearTimeout(ee),ee=setTimeout(async()=>{de.value=await x(h||"")},300)},{immediate:!0});function Ce(){const h=[..._.value],k=["---"];if(k.push(`name: ${l.value}`),c.value&&k.push(`description: ${c.value}`),i.value?(ce.value&&k.push(`author: ${ce.value}`),ue.value&&k.push(`author-email: ${ue.value}`),k.push(`fork-of: ${t.forkOf}`)):(t.initialAuthor&&k.push(`author: ${t.initialAuthor}`),t.initialAuthorEmail&&k.push(`author-email: ${t.initialAuthorEmail}`)),a.value&&k.push(`argument-hint: ${a.value}`),h.length>0&&k.push(`allowed-tools: ${h.join(", ")}`),y.value.length>0&&k.push(`tags: ${y.value.join(", ")}`),p.value&&k.push(`model: ${p.value}`),u.value===!1&&k.push("user-invocable: false"),g.value&&k.push("disable-model-invocation: true"),d.value&&k.push(`context: ${d.value}`),w.value&&k.push(`agent: ${w.value}`),b.value.trim())try{const R=JSON.parse(b.value.trim());k.push(`hooks: ${JSON.stringify(R)}`)}catch{}return k.push("---"),k.join(` `)+` `+Z.value.trim()+` `}async function st(){O.value=!0,B.value="";try{const h=Ce(),k={"Content-Type":"application/json"};if(!i.value&&pe.value&&(k.Authorization=`Bearer ${pe.value}`),t.mode==="create"){const R=await fetch("/api/skills",{method:"POST",headers:k,body:JSON.stringify({slug:Y.value,content:h})});if(!R.ok){const $=await R.json();throw new Error($.error||"Failed to create skill")}window.location.href=`/${Y.value}`}else{const R=await fetch(`/api/skills/${t.slug}`,{method:"PUT",headers:k,body:JSON.stringify({content:h})});if(!R.ok){const $=await R.json();throw new Error($.error||"Failed to update skill")}window.location.href=`/${t.slug}`}}catch(h){B.value=h instanceof Error?h.message:"Something went wrong"}finally{O.value=!1}}const $e={props:t,AVAILABLE_TOOLS:n,AVAILABLE_MODELS:r,isFork:i,name:l,description:c,argumentHint:a,model:p,userInvocable:u,disableModelInvocation:g,context:d,agent:w,hooksJson:b,tags:y,tagQuery:I,tagSuggestionsOpen:F,tagInputEl:V,knownTags:U,body:Z,saving:O,error:B,forkAuthorName:ce,forkAuthorEmail:ue,authorToken:pe,selectedTools:_,toggleTool:Je,tagSuggestions:We,isNewTag:Xe,addTag:he,removeTag:Ke,onTagKeydown:Ye,get tagBlurTimer(){return K},set tagBlurTimer(h){K=h},onTagBlur:et,onTagSuggestionClick:tt,computedSlug:Y,slugMatchesOriginal:rt,bodyLines:nt,get previewHtml(){return de},set previewHtml(h){de=h},get debounceTimer(){return ee},set debounceTimer(h){ee=h},buildContent:Ce,save:st};return Object.defineProperty($e,"__isScriptSetup",{enumerable:!1,value:!0}),$e}}),Kt={key:0,class:"rounded-xl border border-[var(--color-accent-500)]/20 bg-[var(--color-accent-500)]/5 p-4 space-y-3"},Yt={class:"grid gap-3 sm:grid-cols-2"},er={key:1,class:"rounded-xl border border-amber-500/20 bg-amber-500/5 p-4"},tr={class:"grid gap-4 sm:grid-cols-2"},rr={class:"mt-1.5 text-xs text-gray-600 flex justify-between"},nr={class:"relative"},sr=["onClick"],lr={key:0,class:"absolute z-10 mt-1 w-full max-h-40 overflow-auto rounded-xl border border-white/[0.08] bg-[var(--color-surface-200)] shadow-xl"},ir=["onMousedown"],ar={key:0,class:"text-[var(--color-accent-500)] text-xs"},or={key:1,class:"text-xs text-gray-600"},cr={class:"flex flex-wrap gap-1.5 rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] px-3 py-2.5 min-h-[42px]"},ur=["onClick"],pr={class:"grid gap-4 sm:grid-cols-3"},hr=["value"],dr={class:"flex flex-wrap gap-6"},gr={class:"flex items-center gap-2.5 cursor-pointer group"},fr={class:"flex items-center gap-2.5 cursor-pointer group"},kr={class:"group"},xr={class:"mt-3"},br={class:"grid gap-4 lg:grid-cols-2"},mr={class:"flex justify-between text-xs font-medium uppercase tracking-wider text-gray-500 mb-1.5"},wr=["innerHTML"],yr={class:"flex items-center gap-4 pt-2"},vr=["disabled","title"],Sr={key:0,class:"h-4 w-4 animate-spin",fill:"none",viewBox:"0 0 24 24"},Tr={key:0,class:"text-sm text-red-400"};function Rr(s,e,t,n,r,i){return S(),v("form",{onSubmit:fe(n.save,["prevent"]),class:"space-y-6"},[n.isFork?(S(),v("div",Kt,[e[19]||(e[19]=o("p",{class:"text-sm text-[var(--color-accent-400)]"},"Claim this fork as yours. It will stay open for editing until you push from CLI, which registers a token and locks it to you.",-1)),o("div",Yt,[o("div",null,[e[17]||(e[17]=o("label",{class:"block text-xs font-medium uppercase tracking-wider text-gray-500 mb-1"},"Your Name",-1)),A(o("input",{"onUpdate:modelValue":e[0]||(e[0]=l=>n.forkAuthorName=l),type:"text",placeholder:"Jane Doe",class:"w-full rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] px-4 py-2.5 text-sm text-white placeholder-gray-600 focus:border-[var(--color-accent-500)]/50 focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)]/20 transition-all"},null,512),[[P,n.forkAuthorName]])]),o("div",null,[e[18]||(e[18]=o("label",{class:"block text-xs font-medium uppercase tracking-wider text-gray-500 mb-1"},"Your Email",-1)),A(o("input",{"onUpdate:modelValue":e[1]||(e[1]=l=>n.forkAuthorEmail=l),type:"email",placeholder:"jane@example.com",class:"w-full rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] px-4 py-2.5 text-sm text-white placeholder-gray-600 focus:border-[var(--color-accent-500)]/50 focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)]/20 transition-all"},null,512),[[P,n.forkAuthorEmail]])])])])):q("",!0),n.isFork&&n.slugMatchesOriginal?(S(),v("div",er,[...e[20]||(e[20]=[o("p",{class:"text-sm text-amber-400"},[M("Change the "),o("strong",null,"name"),M(" to generate a different slug. You can't save a fork with the same slug as the original.")],-1)])])):q("",!0),o("div",tr,[o("div",null,[e[22]||(e[22]=o("label",{class:"block text-xs font-medium uppercase tracking-wider text-gray-500 mb-1.5"},"Name",-1)),A(o("input",{"onUpdate:modelValue":e[2]||(e[2]=l=>n.name=l),type:"text",required:"",maxlength:"64",placeholder:"My Awesome Skill",class:j(["w-full rounded-xl border px-4 py-2.5 text-sm text-white placeholder-gray-600 focus:outline-none focus:ring-1 transition-all",n.isFork&&n.slugMatchesOriginal?"border-amber-500/30 bg-[var(--color-surface-100)] focus:border-amber-500/50 focus:ring-amber-500/20":"border-white/[0.06] bg-[var(--color-surface-100)] focus:border-[var(--color-accent-500)]/50 focus:ring-[var(--color-accent-500)]/20"])},null,2),[[P,n.name]]),o("p",rr,[o("span",null,[e[21]||(e[21]=M("Slug: ",-1)),o("code",{class:j(["font-mono",n.isFork&&n.slugMatchesOriginal?"text-amber-500":"text-gray-500"])},L(n.computedSlug),3)]),o("span",{class:j(n.name.length>58?"text-amber-500":"")},L(n.name.length)+"/64",3)])]),o("div",null,[e[23]||(e[23]=o("label",{class:"block text-xs font-medium uppercase tracking-wider text-gray-500 mb-1.5"},"Description",-1)),A(o("input",{"onUpdate:modelValue":e[3]||(e[3]=l=>n.description=l),type:"text",maxlength:"200",placeholder:"Brief description of what this skill does",class:"w-full rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] px-4 py-2.5 text-sm text-white placeholder-gray-600 focus:border-[var(--color-accent-500)]/50 focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)]/20 transition-all"},null,512),[[P,n.description]]),o("p",{class:j(["mt-1.5 text-xs text-gray-600 text-right",n.description.length>180?"text-amber-500":""])},L(n.description.length)+"/200",3)])]),o("div",nr,[e[25]||(e[25]=o("label",{class:"block text-xs font-medium uppercase tracking-wider text-gray-500 mb-1.5"},"Tags",-1)),o("div",{class:"flex flex-wrap items-center gap-1.5 rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] px-3 py-2 min-h-[42px] cursor-text focus-within:border-[var(--color-accent-500)]/50 focus-within:ring-1 focus-within:ring-[var(--color-accent-500)]/20 transition-all",onClick:e[8]||(e[8]=l=>n.tagInputEl?.focus())},[(S(!0),v(te,null,re(n.tags,(l,c)=>(S(),v("span",{key:l,class:"inline-flex items-center gap-1 rounded-full bg-[var(--color-accent-500)]/15 border border-[var(--color-accent-500)]/25 pl-2.5 pr-1.5 py-0.5 text-xs font-medium text-[var(--color-accent-400)]"},[M(L(l)+" ",1),o("button",{type:"button",onClick:fe(a=>n.removeTag(c),["stop"]),class:"rounded-full p-0.5 hover:bg-[var(--color-accent-500)]/30 transition-colors"},[...e[24]||(e[24]=[o("svg",{class:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2.5"},[o("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18 18 6M6 6l12 12"})],-1)])],8,sr)]))),128)),A(o("input",{ref:"tagInputEl","onUpdate:modelValue":e[4]||(e[4]=l=>n.tagQuery=l),type:"text",placeholder:"Add tag...",class:"flex-1 min-w-[80px] bg-transparent text-sm text-white placeholder-gray-600 outline-none",onKeydown:n.onTagKeydown,onFocus:e[5]||(e[5]=l=>n.tagSuggestionsOpen=!0),onClick:e[6]||(e[6]=l=>n.tagSuggestionsOpen=!0),onInput:e[7]||(e[7]=l=>n.tagSuggestionsOpen=!0),onBlur:n.onTagBlur},null,544),[[P,n.tagQuery]])]),n.tagSuggestionsOpen&&n.tagSuggestions.length>0?(S(),v("div",lr,[(S(!0),v(te,null,re(n.tagSuggestions,l=>(S(),v("button",{key:l,type:"button",onMousedown:fe(c=>n.onTagSuggestionClick(l),["prevent"]),class:"flex w-full items-center gap-2 px-4 py-2 text-sm text-gray-300 hover:bg-white/[0.06] hover:text-white transition-colors text-left"},[n.isNewTag(l)?(S(),v("span",ar,"+")):q("",!0),M(" "+L(l)+" ",1),n.isNewTag(l)?(S(),v("span",or,"(new)")):q("",!0)],40,ir))),128))])):q("",!0),e[26]||(e[26]=o("p",{class:"mt-1.5 text-xs text-gray-600"},"Type and press Enter or comma. Click suggestions to add.",-1))]),o("div",null,[e[27]||(e[27]=o("label",{class:"block text-xs font-medium uppercase tracking-wider text-gray-500 mb-1.5"},"Allowed Tools",-1)),o("div",cr,[(S(!0),v(te,null,re(n.AVAILABLE_TOOLS,l=>(S(),v("button",{key:l,type:"button",onClick:c=>n.toggleTool(l),class:j(["rounded-md px-2.5 py-1 text-xs font-medium transition-all",n.selectedTools.has(l)?"bg-[var(--color-accent-500)] text-white shadow-sm":"bg-white/[0.04] border border-white/[0.06] text-gray-500 hover:text-gray-300 hover:bg-white/[0.08]"])},L(l),11,ur))),128))])]),o("div",pr,[o("div",null,[e[29]||(e[29]=o("label",{class:"block text-xs font-medium uppercase tracking-wider text-gray-500 mb-1.5"},"Model",-1)),A(o("select",{"onUpdate:modelValue":e[9]||(e[9]=l=>n.model=l),class:"w-full rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] px-4 py-2.5 text-sm text-white focus:border-[var(--color-accent-500)]/50 focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)]/20 transition-all"},[e[28]||(e[28]=o("option",{value:""},"Default",-1)),(S(!0),v(te,null,re(n.AVAILABLE_MODELS,l=>(S(),v("option",{key:l.id,value:l.id},L(l.display_name),9,hr))),128))],512),[[ge,n.model]])]),o("div",null,[e[30]||(e[30]=o("label",{class:"block text-xs font-medium uppercase tracking-wider text-gray-500 mb-1.5"},"Argument Hint",-1)),A(o("input",{"onUpdate:modelValue":e[10]||(e[10]=l=>n.argumentHint=l),type:"text",placeholder:"e.g.