PageSourceSearch

https://www.teamhiiv.com/assets/SkillBuilder-DlP-Axgv.js

js teamhiiv.com collected 2026-10-04 05:38:07 UTC 80,257 bytes, 6 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-pptx-DSGYNC4F.js","assets/vendor-react-DUF-THjB.js","assets/vendor-editor-B-sJ1ybM.js","assets/vendor-react-CTahJQl1.css","assets/folder-to-zip-CC_hInvT.js","assets/index-Xk2FoPX9.js","assets/vendor-icons-DHiPf9Xd.js","assets/index-CmHE6ga0.css"])))=>i.map(i=>d[i]);
2import{L as W,a as Me,I as le,F as st,B as L,H as _e,M as Qe,U as ft,V as bt,N as et,u as Qt,dl as Ts,x as zs,y as Ls,z as Ms,C as Fs,E as Ds,G as Os,w as Us,J as Bs,dm as mt,_ as Bt,cn as es,dn as Gs,dp as Gt,dq as Hs}from"./index-Xk2FoPX9.js";import{r as n,j as e,u as ts,d as qs}from"./vendor-react-DUF-THjB.js";import{S as Vs,p as ut}from"./skill-manifest-parser-BJgeG_cy.js";import{a as Ht,S as qt,c as xt,b as ht,d as ss}from"./skill-constants-C5TB16OK.js";import{W as ze,M as rs,c0 as Vt,bz as Ws,g as Zs,N as Ks,bD as gt,P as Js,m as Le,z as pt,h as Ys,dp as Xs,Z as Qs,b5 as er,aL as Wt,aU as tr}from"./vendor-icons-DHiPf9Xd.js";import{r as sr}from"./skill-mutation-capabilities-FAgpdGzY.js";import{D as rr,r as nr,a as ar}from"./docx-preview-BoZO9M04.js";import{C as ir}from"./checkbox-CtnN79iU.js";import"./vendor-editor-B-sJ1ybM.js";import"./purify.es-Jn2rvFN8.js";const lr=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,or=/^\d{4}-\d{2}-\d{2}$/,cr=/^\d+(\.\d{1,2})?$/;function dr(s,r){if(!r)return null;if(r.min_chars!==void 0&&s.length<r.min_chars)return`Must be at least ${r.min_chars} characters`;if(r.max_chars!==void 0&&s.length>r.max_chars)return`Must be at most ${r.max_chars} characters`;if(r.pattern)try{if(!new RegExp(r.pattern).test(s))return"Does not match required pattern"}catch{}if(r.format==="email"&&s&&!lr.test(s))return"Must be a valid email address";if(r.format==="url"&&s)try{new URL(s)}catch{return"Must be a valid URL"}return r.format==="iso-date"&&s&&!or.test(s)?"Must be an ISO date (YYYY-MM-DD)":r.format==="currency"&&s&&!cr.test(s)?"Must be a currency amount (e.g. 1234.56)":null}function mr(s){return s.type==="structured"?[]:s.example??""}function ur(s,r){return s.type==="structured"?!Array.isArray(r)||r.length===0:typeof r!="string"||r.trim().length===0}function pr({placeholder:s,rows:r,onChange:a}){var u;const c=((u=s.schema)==null?void 0:u.columns)??[],i=()=>{const f={};for(const p of c)f[p]="";a([...r,f])},x=f=>{a(r.filter((p,b)=>b!==f))},h=(f,p,b)=>{a(r.map((k,R)=>R===f?{...k,[p]:b}:k))};return c.length===0?e.jsx("p",{className:"text-muted-foreground text-xs italic",children:"No schema columns declared — structured placeholder will be skipped."}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[c.map(f=>e.jsx("th",{className:"px-2 py-1.5 text-left font-medium text-gray-600",children:f},f)),e.jsx("th",{className:"w-12"})]})}),e.jsx("tbody",{children:r.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:c.length+1,className:"px-2 py-3 text-center text-gray-400 italic",children:"No rows yet"})}):r.map((f,p)=>e.jsxs("tr",{className:"border-b last:border-b-0",children:[c.map(b=>e.jsx("td",{className:"px-1 py-1",children:e.jsx(le,{"aria-label":`${s.id} row ${p+1} ${b}`,value:f[b]??"",onChange:k=>h(p,b,k.target.value),className:"h-8 text-xs"})},b)),e.jsx("td",{className:"px-1 py-1 text-right",children:e.jsx(L,{type:"button",variant:"ghost",size:"sm",onClick:()=>x(p),"aria-label":`Remove ${s.id} row ${p+1}`,children:"Remove"})})]},p))})]})}),e.jsx(L,{type:"button",variant:"outline",size:"sm",onClick:i,children:"Add row"})]})}function xr(s){if(!s)return null;const r=[];return s.format&&r.push(`format: ${s.format}`),s.min_chars!==void 0&&r.push(`min ${s.min_chars}`),s.max_chars!==void 0&&r.push(`max ${s.max_chars}`),s.pattern&&r.push(`pattern: ${s.pattern}`),r.length>0?r.join(" · "):null}function hr({placeholders:s,skillId:r,onComplete:a,fetchImpl:c}){const[i,x]=n.useState(()=>{const m={};for(const v of s)m[v.id]=mr(v);return m}),[h,u]=n.useState({}),[f,p]=n.useState(!1),[b,k]=n.useState(null),R=n.useMemo(()=>s.some(m=>m.required?ur(m,i[m.id]):!1),[s,i]),E=Object.values(h).some(m=>m&&m.length>0),T=f||R||E,M=(m,v)=>{x(d=>({...d,[m]:v}))},D=m=>{const v=i[m.id];if(typeof v!="string")return;const d=dr(v,m.constraints);u(S=>{const j={...S};
2return d?j[m.id]=d:delete j[m.id],j})},B=async()=>{p(!0),k(null);const m=c??globalThis.fetch.bind(globalThis);try{const v=await m(`/api/skills/${encodeURIComponent(r)}/run?preview=true`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({values:i,placeholder_count:s.length})});if(!v.ok){let j=`Preview request failed (${v.status})`;try{const C=await v.json();j=C.error??C.message??j}catch{}_e.error(j);return}const d=await v.json(),S={preview_url:d.preview_url,warnings:Array.isArray(d.warnings)?d.warnings:[]};k(S),a==null||a(S)}catch(v){_e.error(v instanceof Error?v.message:"Preview request failed")}finally{p(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-4",children:s.map(m=>{var C;const v=xr(m.constraints),d=m.type==="static"?(C=m.constraints)==null?void 0:C.enum:void 0,S=h[m.id],j=`ph-${m.id}`;return e.jsxs("div",{className:"space-y-2 rounded-md border p-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{htmlFor:j,className:"font-medium text-sm",children:m.id}),e.jsx(Me,{variant:"outline",className:"text-[10px]",children:m.type}),m.required&&e.jsx(Me,{variant:"secondary",className:"text-[10px]",children:"required"})]})}),m.prompt&&e.jsx("p",{className:"text-muted-foreground text-xs",children:m.prompt}),m.type==="static"&&d&&d.length>0?e.jsxs("select",{id:j,"aria-label":m.id,value:typeof i[m.id]=="string"?i[m.id]:"",onChange:z=>M(m.id,z.target.value),onBlur:()=>D(m),className:"w-full rounded-md border px-3 py-1.5 text-sm",children:[e.jsx("option",{value:"",children:"— Select —"}),d.map(z=>e.jsx("option",{value:z,children:z},z))]}):m.type==="static"?e.jsx(le,{id:j,"aria-label":m.id,value:typeof i[m.id]=="string"?i[m.id]:"",onChange:z=>M(m.id,z.target.value),onBlur:()=>D(m)}):m.type==="structured"?e.jsx(pr,{placeholder:m,rows:Array.isArray(i[m.id])?i[m.id]:[],onChange:z=>M(m.id,z)}):e.jsx(st,{id:j,"aria-label":m.id,placeholder:"Example override (optional)",value:typeof i[m.id]=="string"?i[m.id]:"",onChange:z=>M(m.id,z.target.value),rows:3}),v&&e.jsx("p",{className:"text-[11px] text-gray-500",children:v}),S&&e.jsx("p",{role:"alert",className:"text-red-600 text-xs",children:S})]},m.id)})}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-2",children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:[s.length," placeholder",s.length===1?"":"s"]}),e.jsx(L,{type:"button",onClick:B,disabled:T,children:f?"Running…":"Run test"})]}),b&&e.jsxs("div",{className:"space-y-2 rounded-md border border-green-200 bg-green-50 p-3",children:[e.jsx("a",{href:b.preview_url,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-green-800 text-sm underline",children:"Open preview"}),b.warnings.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 font-medium text-green-900 text-xs",children:"Warnings"}),e.jsx("ul",{className:"list-disc space-y-0.5 pl-5",children:b.warnings.map((m,v)=>e.jsx("li",{className:"text-green-800 text-xs",children:m},v))})]})]})]})}function Zt({manifest:s,skillType:r,category:a,useCases:c,iconName:i,testPlaceholder:x,documentTemplateMode:h,onSave:u,saving:f}){const[p,b]=n.useState("organization"),[k,R]=n.useState(a||"general"),[E,T]=n.useState(i||"general"),[M,D]=n.useState(c||[]),B=qt[k]??ze,m=Ht[k]??Ht.general,v=()=>{u({visibility:p,category:k,icon_name:E,shared_with_group_ids:[],use_case:M})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 font-semibold text-gray-700 text-sm",children:"Preview"}),e.jsx("div",{className:"max-w-sm rounded-lg border p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:m},children:e.jsx(B,{size:18,className:"text-gray-700"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:s.name}),e.jsx("p",{className:"mt-0.5 text-gray-500 text-xs",children:s.description}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(Me,{variant:"secondary",className:"text-[10px]",children:r==="prompt_template"?"Prompt":"Code"}),M.slice(0,2).map(d=>e.jsx(Me,{variant:"outline",className:"text-[10px]",children:xt[d]??d},d))]})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 font-semibold text-gray-700 text-sm",children:"Test"}),h?e.jsx(hr,{placeholders:h.placeholders,skillId:h.skillId}):r==="prompt_template"?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(rs,{size:16,className:"mt-0.5 shrink-0 text-blue-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-blue-800 text-sm",children:"How this skill works"}),e.jsx("p",{className:"mt-1 text-blue-600 text-xs",children:"When activated, this skill adds expert context to your conversation. The AI will use the skill's prompt to guide its responses."})]})]})}),x&&e.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-1.5 border-b bg-gray-50 px-3 py-2 font-medium text-gray-500 text-xs",children:[e.jsx(Vt,{size:12}),"Try this after saving"]}),e.jsx("div",{className:"bg-white p-3",children:e.jsxs("p",{className:"text-gray-700 text-sm italic",children:["“",x,"”"]}
2)})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ws,{size:16,className:"mt-0.5 shrink-0 text-blue-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-blue-800 text-sm",children:"How this skill works"}),e.jsx("p",{className:"mt-1 text-blue-600 text-xs",children:"This executable skill runs code in a secure sandbox when triggered. After saving, you can test it from the skill detail page."})]})]})}),x&&e.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-1.5 border-b bg-gray-50 px-3 py-2 font-medium text-gray-500 text-xs",children:[e.jsx(Vt,{size:12}),"Try this after saving"]}),e.jsx("div",{className:"bg-white p-3",children:e.jsxs("p",{className:"text-gray-700 text-sm italic",children:["“",x,"”"]})})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 font-semibold text-gray-700 text-sm",children:"Settings"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block font-medium text-gray-600 text-xs",children:"Visibility"}),e.jsx("div",{className:"flex gap-2",children:["private","team","organization"].map(d=>e.jsx("button",{type:"button",onClick:()=>b(d),className:`rounded-md border px-3 py-1.5 text-xs transition-colors ${p===d?"border-indigo-500 bg-indigo-50 text-indigo-700":"border-gray-200 text-gray-600 hover:bg-gray-50"}`,children:d.charAt(0).toUpperCase()+d.slice(1)},d))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block font-medium text-gray-600 text-xs",children:"Category"}),e.jsx("select",{value:k,onChange:d=>{R(d.target.value),T(d.target.value)},className:"w-full rounded-md border px-3 py-1.5 text-sm",children:Vs.map(d=>e.jsx("option",{value:d,children:ht[d]??d},d))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block font-medium text-gray-600 text-xs",children:"Use Cases"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:ss.map(d=>e.jsx("button",{type:"button",onClick:()=>{D(S=>S.includes(d)?S.filter(j=>j!==d):[...S,d])},className:`rounded-md border px-2 py-1 text-[11px] transition-colors ${M.includes(d)?"border-indigo-500 bg-indigo-50 text-indigo-700":"border-gray-200 text-gray-500 hover:bg-gray-50"}`,children:xt[d]??d},d))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block font-medium text-gray-600 text-xs",children:"Icon"}),e.jsx("div",{className:"grid grid-cols-8 gap-1.5",children:Object.entries(qt).map(([d,S])=>e.jsx("button",{type:"button",onClick:()=>T(d),className:`flex h-8 w-8 items-center justify-center rounded-md border transition-colors ${E===d?"border-indigo-500 bg-indigo-50":"border-gray-200 hover:bg-gray-50"}`,title:ht[d]??d,children:e.jsx(S,{size:14,className:"text-gray-600"})},d))})]})]})]}),e.jsx("div",{className:"flex justify-end border-t pt-4",children:e.jsx(L,{onClick:v,disabled:f,children:f?"Saving...":"Save Skill"})})]})}function gr(s){return s.url&&/docs\.google\.com\/document\/d\//.test(s.url)?"gdoc-url":s.file?s.file.type==="text/markdown"||s.file.name.endsWith(".md")?"skill-md":["application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/html"].includes(s.file.type)||s.file.name.match(/\.(docx|pptx|html)$/i)?"template":"unsupported":"unsupported"}async function fr(s,r={}){const a=r.fetchImpl??fetch,i=`${r.baseUrl??"/api"}/preview/pptx/${encodeURIComponent(s)}/slides`,x={Accept:"application/json"};r.token&&(x.Authorization=`Bearer ${r.token}`);const h=await a(i,{method:"GET",headers:x,signal:r.signal});if(!h.ok)throw new Error(`pptx preview fetch failed: ${h.status} ${h.statusText}`);return(await h.json()).slides??[]}function br(s){if(!s)throw new Error(`Cannot extract pptxId from blob URL: ${JSON.stringify(s)}`);const r=s.match(/\/pptx\/([^/?#]+)/);if(r)return r[1];const c=(s.split("/").pop()||"").replace(/\.pptx$/i,"");if(!c)throw new Error(`Cannot extract pptxId from blob URL: ${JSON.stringify(s)}`);return c}const tt={static:"#3b82f6",structured:"#10b981",generated:"#a855f7"};function yr(s){if(s.nodeType===Node.DOCUMENT_NODE)return"";const r=[];let a=s;for(;a&&a.nodeType===Node.ELEMENT_NODE;){const c=a,i=c.nodeName.toLowerCase();let x=1,h=c.previousSibling;for(;h;)h.nodeType===Node.ELEMENT_NODE&&h.nodeName.toLowerCase()===i&&(x+=1),h=h.previousSibling;r.unshift(`${i}[${x}]`),a=c.parentNode}return"/"+r.join("/")}function jr(s,r){const a=s.ownerDocument;if(!a)return null;const c=r.location.xpath;if(c)try{const h=a.evaluate(c,s,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(h){const u=a.createRange();return u.selectNodeContents(h),u}}catch{}const i=r.location.anchor;if(i){const x=vr(s,i);if(x)return x}return null}function vr(s,r){if(!r)return null;const a=s.ownerDocument;if(!a)return null;const c=a.createTreeWalker(s,NodeFilter.SHOW_TEXT);let i=c.nextNode();for(;i;){const h=(i.nodeValue??"").indexOf(r);if(h!==-1){const u=a.createRange();return u.setStart(i,h),u.setEnd(i,h+r.length),u}i=c.nextNode()}return null}function kr(s,r,a={}){const c=new Map,i=s.ownerDocument;if(!i)return c;for(const x of r){const h=jr(s,x);if(!h)continue;const u=i.createElement("span");u.dataset.phId=x.id,u.dataset.phType=x.type;const f=tt[x.type];if(u.style.outline=`2px solid ${f}`,u.style.outlineOffset="1px",u.style.outlineColor=f,u.style.borderRadius="2px",u.style.cursor="pointer",a.onRegionClick){const p=()=>a.onRegionClick(x.id);u.addEventListener("click",p)}try{h.surroundContents(u),c.set(x.id,u)}catch{try{const p=h.extractContents();u.appendChild(p),h.insertNode(u),c.set(x.id,u)}catch{}}}return c}function Nr(s,r){const a=s.get(r);a&&a.scrollIntoView({behavior:"smooth",block:"center"})}const wr=n.forwardRef(function({extraction:r,blobUrl:a,onSelection:c,onRegionClick:i,authToken:x},h){const u=n.useRef(null),f=n.useRef(new Map),[p,b]=n.useState(null),[k,R]=n.useState(null),[E,T]=n.useState(0),[M,D]=n.useState(null);n.useEffect(()=>{if(r.document_type!=="docx"&&r.document_type!=="gdoc")return;if(!a){b(rr);return}let d=!1;return nr(a).then(S=>{d||b(S)}),()=>{d=!0}},[a,r.document_type]),n.useEffect(()=>{if(r.document_type!=="docx"&&r.document_type!=="gdoc")return;const d=u.current;!d||p==null||(ar(d,p),f.current=kr(d,r.candidate_placeholders,{onRegionClick:i}))},[p,r.candidate_placeholders,r.document_type,i]),n.useEffect(()=>{if(r.document_type!=="pptx")return;const d=new AbortController;let S;try{S=br(a||r.template_blob_url)}catch(j){return D(j.message),R([]),()=>d.abort()}return fr(S,{token:x,signal:d.signal}).then(j=>{R(j),T(0),D(null)}
2).catch(j=>{j.name!=="AbortError"&&(D(j.message),R([]))}),()=>d.abort()},[a,r.document_type,r.template_blob_url,x]),n.useImperativeHandle(h,()=>({scrollToPlaceholder(d){Nr(f.current,d)}}),[]);const B=n.useCallback(()=>{var q,G,oe;const d=u.current;if(!d)return;const S=(oe=(G=(q=d.ownerDocument)==null?void 0:q.defaultView)==null?void 0:G.getSelection)==null?void 0:oe.call(G);if(!S||S.rangeCount===0)return;const j=S.getRangeAt(0);if(j.collapsed||!d.contains(j.commonAncestorContainer))return;const C=S.toString();if(!C.trim())return;const z=j.startContainer.nodeType===Node.ELEMENT_NODE?j.startContainer:j.startContainer.parentNode,N=z?yr(z):"/";c({xpath:N,text:C})},[c]),m=n.useMemo(()=>{const d=new Map;for(const S of r.candidate_placeholders){const j=S.location.slide_index;typeof j=="number"&&(d.has(j)||d.set(j,[]),d.get(j).push(S))}return d},[r.candidate_placeholders]),v=n.useCallback((d,S,j)=>{c({slide_index:d,shape_id:S,text:j})},[c]);if(r.document_type==="docx"||r.document_type==="gdoc")return e.jsx("div",{className:"template-preview-pane template-preview-pane--docx","data-testid":"docx-preview-pane",style:{maxHeight:"80vh",overflowY:"auto",padding:"1.5rem",background:"#fff",border:"1px solid #e5e7eb",borderRadius:"8px"},children:e.jsx("div",{ref:u,onMouseUp:B,"data-testid":"docx-preview-content",style:{lineHeight:1.6,color:"#111827"}})});if(r.document_type==="pptx"){const d=k??[],S=d[E],j=m.get(E)??[];return e.jsxs("div",{className:"template-preview-pane template-preview-pane--pptx","data-testid":"pptx-preview-pane",style:{display:"flex",gap:"1rem",height:"80vh"},children:[e.jsxs("div",{"data-testid":"pptx-slide-rail",style:{display:"flex",flexDirection:"column",gap:"0.5rem",overflowY:"auto",width:"160px"},children:[d.map(C=>e.jsx("button",{type:"button",onClick:()=>T(C.index),"data-slide-index":C.index,style:{border:C.index===E?"2px solid #2563eb":"1px solid #e5e7eb",padding:0,cursor:"pointer",background:"#fff"},children:e.jsx("img",{src:C.png_url,alt:`Slide ${C.index+1}`,style:{width:"100%",display:"block"}})},C.index)),M&&e.jsx("p",{role:"alert",style:{color:"#b91c1c",fontSize:"0.85rem"},children:M})]}),e.jsxs("div",{"data-testid":"pptx-active-pane",style:{position:"relative",flex:1,background:"#fff"},children:[S&&e.jsx("img",{src:S.png_url,alt:`Active slide ${S.index+1}`,style:{width:"100%",height:"auto",display:"block"}}),j.map(C=>e.jsx("button",{type:"button","data-ph-id":C.id,"data-ph-type":C.type,"data-slide-index":C.location.slide_index,"data-shape-id":C.location.shape_id,onClick:()=>{i(C.id),v(C.location.slide_index??0,C.location.shape_id??C.id,C.prompt)},style:{position:"absolute",top:"8px",left:`${8+j.indexOf(C)*48}px`,padding:"4px 8px",outline:`2px solid ${tt[C.type]}`,outlineColor:tt[C.type],background:"rgba(255,255,255,0.85)",borderRadius:"2px",fontSize:"0.75rem",cursor:"pointer",border:"none"},children:C.id},C.id))]})]})}if(r.document_type==="html"){const d=a||r.template_blob_url||"<p>No HTML preview available.</p>";return e.jsx("div",{className:"template-preview-pane template-preview-pane--html","data-testid":"html-preview-pane",style:{height:"80vh"},children:e.jsx("iframe",{"data-testid":"html-preview-iframe",title:"HTML template preview",sandbox:"",srcDoc:d,style:{width:"100%",height:"100%",border:"1px solid #e5e7eb",borderRadius:"8px",background:"#fff"}})})}return e.jsxs("div",{role:"alert","data-testid":"preview-unsupported",children:["Unsupported document type: ",r.document_type]})});function Kt(s){return(s??[]).join(", ")}function Jt(s){return s.split(",").map(r=>r.trim()).filter(r=>r.length>0)}function Sr({placeholder:s,existingIds:r,onChange:a,defaultExpanded:c=!1}){var j,C,z;const[i,x]=n.useState(c),[h,u]=n.useState(!1),[f,p]=n.useState(s.id),[b,k]=n.useState(null),R=tt[s.type],E=()=>{p(s.id),k(null),u(!0)},T=()=>{const N=f.trim();if(N===s.id){u(!1),k(null);return}if(!/^[a-z][a-z0-9_]*$/.test(N)){k("IDs must match ^[a-z][a-z0-9_]*$");return}if(r.has(N)){k("Another placeholder already uses this id");return}k(null),u(!1),a({...s,id:N})},M=N=>{a({...s,type:N})},D=N=>{a({...s,required:N===!0})},B=N=>{a({...s,prompt:N})},m=N=>{a({...s,example:N||void 0})},v=N=>{const q=Jt(N),G={...s.constraints??{}};q.length===0?delete G.enum:G.enum=q,a({...s,constraints:G})},d=N=>{const q=Jt(N);a({...s,schema:{...s.schema??{columns:[]},columns:q}})},S=N=>{const q=N===""?void 0:Number(N),G={...s.constraints??{}};q===void 0||Number.isNaN(q)?delete G.max_chars:G.max_chars=q,a({...s,constraints:G})};return e.jsxs("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm","data-testid":"placeholder-row","data-
2ph-id":s.id,"data-ph-type":s.type,children:[e.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 p-3 text-left",onClick:()=>x(N=>!N),"aria-expanded":i,"aria-label":`Toggle details for ${s.id}`,children:[i?e.jsx(Zs,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Ks,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{"aria-hidden":"true","data-testid":"placeholder-color-dot",className:"inline-block h-3 w-3 rounded-full",style:{backgroundColor:R}}),e.jsx("span",{className:"font-mono text-sm",children:s.id}),e.jsx(Me,{variant:"secondary",className:"ml-auto",children:s.type})]}),i&&e.jsxs("div",{className:"space-y-4 border-t p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(W,{htmlFor:`ph-id-${s.id}`,children:"ID"}),e.jsx("div",{className:"flex items-center gap-2",children:h?e.jsxs(e.Fragment,{children:[e.jsx(le,{id:`ph-id-${s.id}`,value:f,onChange:N=>{p(N.target.value),b&&k(null)},"aria-label":`Rename ${s.id}`}),e.jsx(L,{type:"button",size:"sm",onClick:T,children:"Save"}),e.jsx(L,{type:"button",size:"sm",variant:"outline",onClick:()=>{u(!1),p(s.id),k(null)},children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{id:`ph-id-${s.id}`,value:s.id,readOnly:!0,"aria-label":`${s.id} id`}),e.jsx(L,{type:"button",size:"sm",variant:"outline",onClick:E,"aria-label":`Rename ${s.id}`,children:e.jsx(gt,{className:"h-3 w-3"})})]})}),b&&e.jsx("p",{role:"alert",className:"text-destructive text-xs",children:b})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(W,{htmlFor:`ph-type-${s.id}`,children:"Type"}),e.jsxs("select",{id:`ph-type-${s.id}`,"aria-label":`${s.id} type`,className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:s.type,onChange:N=>M(N.target.value),children:[e.jsx("option",{value:"static",children:"static"}),e.jsx("option",{value:"structured",children:"structured"}),e.jsx("option",{value:"generated",children:"generated"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ir,{id:`ph-req-${s.id}`,checked:s.required===!0,onCheckedChange:D,"aria-label":`${s.id} required`}),e.jsx(W,{htmlFor:`ph-req-${s.id}`,children:"Required"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(W,{htmlFor:`ph-prompt-${s.id}`,children:"Prompt"}),e.jsx(st,{id:`ph-prompt-${s.id}`,"aria-label":`${s.id} prompt`,value:s.prompt,onChange:N=>B(N.target.value),rows:2})]}),s.type==="static"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(W,{htmlFor:`ph-enum-${s.id}`,children:"Enum values (comma-separated)"}),e.jsx(le,{id:`ph-enum-${s.id}`,"aria-label":`${s.id} enum`,value:Kt((j=s.constraints)==null?void 0:j.enum),onChange:N=>v(N.target.value),placeholder:"Draft, Active, Archived"})]}),s.type==="structured"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(W,{htmlFor:`ph-cols-${s.id}`,children:"Columns (comma-separated)"}),e.jsx(le,{id:`ph-cols-${s.id}`,"aria-label":`${s.id} columns`,value:Kt((C=s.schema)==null?void 0:C.columns),onChange:N=>d(N.target.value),placeholder:"name, amount, due_date"})]}),s.type==="generated"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(W,{htmlFor:`ph-max-${s.id}`,children:"Max characters"}),e.jsx(le,{id:`ph-max-${s.id}`,"aria-label":`${s.id} max_chars`,type:"number",min:0,value:((z=s.constraints)==null?void 0:z.max_chars)===void 0?"":String(s.constraints.max_chars),onChange:N=>S(N.target.value),placeholder:"500"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(W,{htmlFor:`ph-ex-${s.id}`,children:"Example"}),e.jsx(le,{id:`ph-ex-${s.id}`,"aria-label":`${s.id} example`,value:s.example??"",onChange:N=>m(N.target.value)})]})]})]})}function Cr(s){return s.map((r,a)=>({p:r,stableIdx:a})).sort((r,a)=>{const c=r.p.location.kind.localeCompare(a.p.location.kind);if(c!==0)return c;const i=r.p.location.start??r.p.location.slide_index??r.p.location.anchor_row??0,x=a.p.location.start??a.p.location.slide_index??a.p.location.anchor_row??0;return i!==x?i-x:r.stableIdx-a.stableIdx}).map(({p:r})=>r)}function _r({placeholders:s,onChange:r,activeSelection:a,onAddFromSelection:c}){const i=n.useMemo(()=>Cr(s),[s]),x=n.useMemo(()=>{const f=s.map(b=>b.id),p=new Map;for(const b of s)p.set(b.id,new Set(f.filter(k=>k!==b.id)));return p},[s]),h=f=>p=>{const b=s.findIndex(R=>R.id===f);if(b===-1){r([...s,p]);return}const k=s.slice();k[b]=p,r(k)},u=()=>{!a||!c||c(a)};return e.jsxs(Qe,{children:[e.jsxs(ft,{className:"flex flex-row items-center justify-between space-y-0",children:[e.jsx(bt,{className:"text-base",children:"Placeholders"}),e.jsxs(L,{type:"button",size:"sm",onClick:u,disabled:!a,"aria-label":"Add placeholder from selection",children:[e.jsx(Js,{className:"mr-1 h-4 w-4"}),"Add placeholder"]})]}),e.jsxs(et,{className:"space-y-3",children:[i.length===0&&e.jsx("p",{className:"text-muted-foreground text-sm",children:"No placeholders yet. Select a regi
2on in the preview to add one."}),i.map(f=>e.jsx(Sr,{placeholder:f,existingIds:x.get(f.id)??new Set,onChange:h(f.id)},f.id))]})]})}function Er(s,r){const a=s.trim().toLowerCase().replace(/[^a-z0-9\s_]/g,"").replace(/\s+/g,"_").slice(0,40).replace(/^[^a-z]+/,"");if(!a){let c=r.size+1;for(;r.has(`placeholder_${c}`);)c++;return`placeholder_${c}`}if(!r.has(a))return a;for(let c=2;c<1e3;c++){const i=`${a}_${c}`;if(!r.has(i))return i}throw new Error("slugifyId: ran out of suffixes")}function Pr(s){return s.location.kind==="table"?"structured":s.location.kind==="paragraph-range"||s.text.length>200?"generated":"static"}function $r({selection:s,existingIds:r,onConfirm:a,onCancel:c,position:i}){const x=n.useMemo(()=>Er(s.text,r),[s.text,r]),h=n.useMemo(()=>Pr(s),[s]),[u,f]=n.useState(x),[p,b]=n.useState(h),[k,R]=n.useState(""),E=u.trim(),T=E!==x&&r.has(E),M=!/^[a-z][a-z0-9_]*$/.test(E),D=!E||T||M,B=()=>{if(D)return;const v={id:E,type:p,location:{kind:s.location.kind??"text-run",...s.location},prompt:k.trim(),required:!1};a(v)},m=i?{position:"absolute",top:i.top,left:i.left,zIndex:50}:{};return e.jsxs("div",{role:"dialog","aria-label":"Add placeholder","data-testid":"placeholder-selection-popover",className:"rounded-lg border bg-background p-4 shadow-md",style:{width:320,...m},children:[e.jsxs("p",{className:"mb-3 truncate text-muted-foreground text-xs",title:s.text,children:['Selection: "',s.text.slice(0,80),s.text.length>80?"…":"",'"']}),e.jsxs("div",{className:"mb-3 space-y-1",children:[e.jsx(W,{htmlFor:"placeholder-popover-id",children:"ID"}),e.jsx(le,{id:"placeholder-popover-id","aria-label":"ID",value:u,onChange:v=>f(v.target.value)}),T&&e.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"An existing placeholder already uses this id."}),!T&&M&&u.length>0&&e.jsxs("p",{role:"alert",className:"text-destructive text-xs",children:["IDs must match ",e.jsx("code",{children:"^[a-z][a-z0-9_]*$"}),"."]})]}),e.jsxs("div",{className:"mb-3 space-y-1",children:[e.jsx(W,{htmlFor:"placeholder-popover-type",children:"Type"}),e.jsxs("select",{id:"placeholder-popover-type","aria-label":"Type",className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:p,onChange:v=>b(v.target.value),children:[e.jsx("option",{value:"static",children:"static"}),e.jsx("option",{value:"structured",children:"structured"}),e.jsx("option",{value:"generated",children:"generated"})]})]}),e.jsxs("div",{className:"mb-3 space-y-1",children:[e.jsx(W,{htmlFor:"placeholder-popover-prompt",children:"Prompt (optional)"}),e.jsx(st,{id:"placeholder-popover-prompt","aria-label":"Prompt",value:k,onChange:v=>R(v.target.value),rows:2,placeholder:"What goes here? e.g. Customer's full legal name"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[c&&e.jsx(L,{type:"button",variant:"outline",onClick:c,children:"Cancel"}),e.jsx(L,{type:"button",onClick:B,disabled:D,children:"Create placeholder"})]})]})}function Ir({onBack:s}){return e.jsxs(Qe,{"data-testid":"template-authoring-disabled",children:[e.jsx(ft,{children:e.jsx(bt,{className:"text-base",children:"Template authoring is not enabled"})}),e.jsxs(et,{className:"space-y-3 text-muted-foreground text-sm",children:[e.jsxs("p",{children:["Template authoring is not enabled in this environment. Set ",e.jsx("code",{children:"VITE_SKILL_TEMPLATE_AUTHORING=true"})," to use this feature."]}),s&&e.jsxs(L,{type:"button",variant:"outline",onClick:s,size:"sm",children:[e.jsx(Le,{className:"mr-1 h-3.5 w-3.5"}),"Back to SKILL.md upload"]})]})]})}function Rr(s,r){const a=new Map(s.map(p=>[p.id,p])),c=new Map(r.map(p=>[p.id,p])),i=r.filter(p=>!a.has(p.id)),x=s.filter(p=>!c.has(p.id)),h=[],u=new Set,f=new Set;for(const p of x){const b=i.find(k=>!u.has(k.id)&&k.prompt&&k.prompt===p.prompt);b&&(h.push({from:p,to:b}),u.add(b.id),f.add(p.id))}return{added:i.filter(p=>!u.has(p.id)),removed:x.filter(p=>!f.has(p.id)),renamed:h}}function Ar({open:s,diff:r,onContinue:a,onCancel:c}){return e.jsx(zs,{open:s,onOpenChange:i=>i?null:c(),children:e.jsxs(Ls,{"data-testid":"version-diff-dialog",children:[e.jsxs(Ms,{children:[e.jsx(Fs,{children:"Placeholder changes detected"}),e.jsx(Ds,{children:"The new upload's placeholders differ from the current skill. Confirm before publishing a new version."})]}),e.jsxs("div",{className:"space-y-4 text-sm",children:[r.added.length>0&&e.jsxs("section",{"aria-label":"Added placeholders",children:[e.jsxs("h4",{className:"font-medium",children:["Added (",r.added.length,")"]}),e.jsx("ul",{className:"ml-5 list-disc text-muted-foreground",children:r.added.map(i=>e.jsx("li",{children:i.id},`add-${i.id}`))})]}),r.removed.length>0&&e.jsxs("section",{"aria-label":"Removed placeholders",children:[e.jsxs("h4",{className:"font-medium",children:["Removed (",r.removed.length,")"]}),e.jsx("ul",{className:"ml-5 list-disc text-muted-foreground",children:r.removed.map(i=>e.jsx("li",{children:i.id},`rm-${i.id}`))})]}),r.renamed.length>0&&e.jsxs("section",{"aria-label":"Renamed placeholders",children:[e.jsxs("h4",{className:"font-medium",children:["Renamed (",r.renamed.length,")"]}),e.jsx("ul",{className:"ml-5 list-disc text-muted-foreground",children:r.renamed.map(({from:i,to:x})=>e.jsxs("li",{children:[i.id," → ",x.id]},`rn-${i.id}-${x.id}`))})]}),r.added.length===0&&r.removed.length===0&&r.renamed.length===0&&e.jsx("p",{className:"text-muted-foreground",children:"No structural changes."})]}),e.jsxs(Os,{children:[e.jsx(L,{type:"button",variant:"outline",onClick:c,children:"Cancel"}),e.jsx(L,{type:"button",onClick:a,children:"Continue"})]})]})})}function Tr(){return!1}async function zr(s){try{const r=await s.json();
2if(typeof(r==null?void 0:r.error)=="string")return r.error;if(typeof(r==null?void 0:r.message)=="string")return r.message}catch{}return`HTTP ${s.status}`}function Lr({source:s,onCancel:r,editSkillId:a,fetchImpl:c}){const i=ts(),x=Qt(),h=c??window.fetch.bind(window),u=n.useMemo(()=>Tr(),[]),[f,p]=n.useState(null),[b,k]=n.useState(null),[R,E]=n.useState(null),[T,M]=n.useState([]),[D,B]=n.useState(null),[m,v]=n.useState(!0),[d,S]=n.useState(""),[j,C]=n.useState(""),[z,N]=n.useState("organization"),[q,G]=n.useState(null),[oe,Ee]=n.useState(null),ue=n.useRef(null),[ce,Fe]=n.useState(null),[Pe,ee]=n.useState(null),[ve,ae]=n.useState(!1),[pe,ke]=n.useState(!1),De=n.useMemo(()=>s.kind==="file"?`file:${s.filename??"anonymous"}:${s.bytes.byteLength}:${s.mime}`:s.kind==="gdoc-url"?`gdoc:${s.url}`:`string:${s.text.length}`,[s]),ie=n.useRef(s);n.useEffect(()=>{ie.current=s},[s]),n.useEffect(()=>{if(!u)return;let y=!1;return(async()=>{const Z=ie.current;try{const re=new FormData;if(Z.kind==="file"){const Se=new Blob([Z.bytes],{type:Z.mime});re.append("file",Se,Z.filename??`template.${Mr(Z.mime)}`)}else Z.kind==="gdoc-url"?re.append("gdoc_url",Z.url):re.append("html",Z.text);const ne=await h("/api/skills/author/from-document?preview=true",{method:"POST",body:re,credentials:"include"});if(!ne.ok){const Se=await zr(ne);y||(B(Se),v(!1),_e.error(Se));return}const he=await ne.json();if(y)return;p(he.session_id),k(he.extraction),E(he.template_blob_url),M(he.extraction.candidate_placeholders??[]),v(!1)}catch(re){if(y)return;const ne=re instanceof Error?re.message:"Preview failed";B(ne),v(!1),_e.error(ne)}})(),()=>{y=!0}},[u,De,h]),n.useEffect(()=>{if(!u||!a)return;let y=!1;return(async()=>{try{const U=await h(`/api/skills/${encodeURIComponent(a)}/versions/latest`,{credentials:"include"});if(!U.ok)return;const Z=await U.json();y||Fe(Z.placeholders??[])}catch{}})(),()=>{y=!0}},[u,a,h]);const Ne=n.useCallback(y=>{let U="text-run";y.slide_index!==void 0?U="text-run":y.anchor_row!==void 0?U="table":y.xpath&&(U="text-content"),G({text:y.text,location:{kind:U,xpath:y.xpath,slide_index:y.slide_index,shape_id:y.shape_id}})},[]),de=n.useCallback(y=>{var U;(U=ue.current)==null||U.scrollToPlaceholder(y)},[]),Oe=n.useCallback(y=>{Ee(y)},[]),te=n.useCallback(()=>{Ee(null)},[]),me=n.useCallback(y=>{M(U=>[...U,y]),Ee(null),G(null)},[]),we=n.useMemo(()=>T.some(y=>(y.required??!1)&&!y.prompt.trim()),[T]),V=!pe&&!m&&!!f&&d.trim().length>0&&j.trim().length>0&&!we,se=n.useCallback(async()=>{if(f){ke(!0);try{const y=await x.contract(Ts,{session_id:f,name:d.trim(),description:j.trim(),visibility:z,placeholders:T});_e.success(`Saved skill ${y.skill_id}@${y.version}`),ke(!1),a||i("/skills")}catch(y){const U=y instanceof Error?y.message:"Save failed";_e.error(U),ke(!1)}}},[f,d,j,z,T,x,i,a]),Y=n.useCallback(()=>{if(V){if(a&&ce&&!ve){const y=Rr(ce,T);if(y.added.length>0||y.removed.length>0||y.renamed.length>0){ee(y);return}}se()}},[V,a,ce,ve,T,se]),xe=n.useCallback(()=>{ee(null),ae(!0),se()},[se]),rt=n.useCallback(()=>{ee(null)},[]);return u?e.jsxs("div",{className:"w-full px-4 py-6","data-testid":"template-authoring-layout",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[r&&e.jsxs(L,{type:"button",variant:"ghost",size:"sm",onClick:r,children:[e.jsx(Le,{className:"mr-1 h-3.5 w-3.5"}),"Back"]}),e.jsx("h1",{className:"font-semibold text-xl",children:"Create skill from template"})]}),m&&e.jsxs("div",{role:"status","aria-live":"polite",className:"mb-4 flex items-center gap-2 text-muted-foreground text-sm","data-testid":"template-authoring-loading",children:[e.jsx(ze,{size:14,className:"animate-pulse"}),"Extracting placeholders…"]}),D&&!m&&e.jsx("div",{role:"alert",className:"mb-4 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive text-sm",children:D}),e.jsxs("div",{className:"grid grid-cols-[1fr_420px_360px] gap-4",children:[e.jsxs("div",{"data-testid":"template-authoring-preview-pane",children:[b&&R&&e.jsx(wr,{ref:ue,extraction:b,blobUrl:R,onSelection:Ne,onRegionClick:de}),!b&&!m&&!D&&e.jsx(Qe,{children:e.jsx(et,{className:"p-6 text-muted-foreground text-sm",children:"No preview available."})})]}),e.jsxs("div",{className:"relative","data-testid":"template-authoring-placeholder-pane",children:[e.jsx(_r,{placeholders:T,onChange:M,activeSelection:q??void 0,onAddFromSelection:Oe}),oe&&e.jsx("div",{className:"mt-3",children:e.jsx($r,{selection:oe,existingIds:new Set(T.map(y=>y.id)),onConfirm:me,onCancel:te})})]}),e.jsx("div",{"data-testid":"template-authoring-config-pane",children:e.jsxs(Qe,{children:[e.jsx(ft,{children:e.jsx(bt,{className:"text-base",children:"Skill details"})}),e.jsxs(et,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(W,{htmlFor:"template-skill-name",children:"Name"}),e.jsx(le,{id:"template-skill-name","aria-label":"Name",value:d,onChange:y=>S(y.target.value),placeholder:"Client Proposal Generator"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(W,{htmlFor:"template-skill-description",children:"Description"}),e.jsx(st,{id:"template-skill-description","aria-label":"Description",value:j,onChange:y=>
2C(y.target.value),placeholder:"What does this skill produce?",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(W,{htmlFor:"template-skill-visibility",children:"Visibility"}),e.jsxs("select",{id:"template-skill-visibility","aria-label":"Visibility",className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:z,onChange:y=>N(y.target.value),children:[e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"organization",children:"Organization"})]})]}),e.jsx(L,{type:"button",onClick:Y,disabled:!V,"data-testid":"template-authoring-save",className:"w-full",children:pe?"Saving…":"Save skill"})]})]})})]}),e.jsx(Ar,{open:!!Pe,diff:Pe??{added:[],removed:[],renamed:[]},onContinue:xe,onCancel:rt})]}):e.jsx("div",{className:"mx-auto max-w-3xl px-4 py-8",children:e.jsx(Ir,{onBack:r})})}function Mr(s){return s.includes("wordprocessingml")?"docx":s.includes("presentationml")?"pptx":s.includes("html")?"html":"bin"}function Yt(s){return Array.isArray(s)?s.filter(r=>typeof r=="string"&&es.includes(r)):[]}function Ce(s){return s.replace(/\.[^.]+$/,"").replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"imported-skill"}function Fr(s){const r=s.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,63),a=/^[a-z]/.test(r)?r:`skill-${r}`;return(a.length>=3?a:`${a}-skill`).replace(/-+$/g,"").slice(0,63)||"imported-skill"}function Xe(s){return!Array.isArray(s)||s.length===0?!1:s.some(r=>{const a=String((r==null?void 0:r.path)??"").toLowerCase();return/\.(py|mjs|cjs|js|ts|tsx)$/.test(a)})}function je(s){const r=s.replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"");if(!r||r.includes("\0"))return null;const a=r.split("/").filter(Boolean);return a.length===0||a.some(c=>c==="."||c==="..")||a.some(c=>c==="__MACOSX")||a[a.length-1]===".DS_Store"?null:a.join("/")}function yt(s){let r="";for(let c=0;c<s.length;c+=32768){const i=s.subarray(c,c+32768);r+=String.fromCharCode(...i)}return btoa(r)}function ns(s){return yt(new TextEncoder().encode(s))}function as(s){var k,R;const r=Ce(s.fileName),a=r.toLowerCase(),c=s.files.map(E=>E.path.toLowerCase()),i=a.includes("docx")||c.some(E=>E.endsWith("office/unpack.py")||E.endsWith("office/pack.py")||E.endsWith("accept_changes.py")||E.endsWith("comment.py")),x=i?"DOCX Document Tools":r.split(/[-_\s]+/g).filter(Boolean).map(E=>E.charAt(0).toUpperCase()+E.slice(1)).join(" ")||"Imported Skill",h=i?"Use this skill when the user wants to create, read, edit, format, or manipulate Microsoft Word .docx documents with bundled helper scripts.":"Imported multi-file skill package with bundled scripts and resources.",u=String(((k=s.manifest)==null?void 0:k.name)??x),f=String(((R=s.manifest)==null?void 0:R.description)??h),p=s.files.map(E=>`- ${E.path}`).join(`
3`),b=i?"This package contains DOCX helper scripts. Keep the bundled directory structure intact when referring to scripts such as `scripts/office/unpack.py`, `scripts/office/pack.py`, `scripts/accept_changes.py`, and `scripts/comment.py`.":"This package contains bundled scripts and resources. The native entry point (e.g. `main.py` or `index.mjs`) executes inside its language runtime; keep the directory structure intact.";return["---",`name: ${JSON.stringify(u)}`,`description: ${JSON.stringify(f)}`,"---","",`# ${u}`,"",f,"","## Bundled files","",b,"",p].join(`
4`)}function Dr(s){let r;try{r=new URL(s.trim())}catch{throw new Error("Enter a valid GitHub folder URL")}if(r.hostname!=="github.com"&&r.hostname!=="www.github.com")throw new Error("Only github.com folder URLs are supported");const a=r.pathname.split("/").filter(Boolean),c=a.indexOf("tree");if(a.length<5||c!==2)throw new Error("Use a GitHub tree URL such as https://github.com/owner/repo/tree/main/path/to/skill");return{owner:a[0],repo:a[1],ref:decodeURIComponent(a[3]),path:a.slice(4).map(decodeURIComponent).join("/")}}function Or(s,r,a,c){const i=a.split("/").filter(Boolean).map(encodeURIComponent).join("/");return`https://api.github.com/repos/${encodeURIComponent(s)}/${encodeURIComponent(r)}/contents/${i}?ref=${encodeURIComponent(c)}`}async function Ur(s){const r=await fetch(s,{headers:{Accept:"application/vnd.github+json"}});if(!r.ok)throw new Error(`GitHub import failed (${r.status}): ${await r.text().catch(()=>r.statusText)}`);return await r.json()}async function Br(s){const r=s.rootPath.replace(/^\/+|\/+$/g,""),a=[],c=async i=>{const x=await Ur(Or(s.owner,s.repo,i,s.ref)),h=Array.isArray(x)?x:[x];for(const u of h){if(u.type==="dir"){await c(u.path);continue}if(u.type!=="file"||!u.download_url)continue;const f=je(r&&u.path.startsWith(`${r}/`)?u.path.slice(r.length+1):u.path);if(!f)continue;const p=await fetch(u.download_url);if(!p.ok)throw new Error(`Failed to download ${u.path} from GitHub`);a.push({path:f,content:yt(new Uint8Array(await p.arrayBuffer())),encoding:"base64"})}};return await c(r),a.sort((i,x)=>i.path.localeCompare(x.path))}function Xt(s,r){const a=r.toLowerCase(),c=s.find(h=>h.path.toLowerCase()===a);if(!c)return null;const i=atob(c.content),x=new Uint8Array(i.length);for(let h=0;h<i.length;h+=1)x[h]=i.charCodeAt(h);return new TextDecoder().decode(x)}function Gr(s,r){const a=Xt(r,"SKILL.md");if(a)return a;let c;const i=Xt(r,"skill.json");if(i)try{c=JSON.parse(i)}catch{c=void 0}const x=as({fileName:s,files:r,manifest:c});return r.some(h=>h.path.toLowerCase()==="skill.md")||r.push({path:"SKILL.md",content:ns(x),encoding:"base64"}),x}function en(){const s=ts(),[r]=qs(),a=r.get("edit"),c=Qt(),{user:i}=Us(),{isAdmin:x,isSuperAdmin:h,loading:u}=Bs(),f=n.useRef(c);f.current=c;const p=n.useRef(0),[b,k]=n.useState("describe"),[R,E]=n.useState(!1),[T,M]=n.useState(!1),[D,B]=n.useState(a?null:!0),[m,v]=n.useState([]),[d,S]=n.useState(""),[j,C]=n.useState(!1),[z,N]=n.useState(null),[q,G]=n.useState(""),[oe,Ee]=n.useState([]),[ue,ce]=n.useState(null),[Fe,Pe]=n.useState(null),[ee,ve]=n.useState(""),[ae,pe]=n.useState(null),[ke,De]=n.useState(""),[ie,Ne]=n.useState([]),[de,Oe]=n.useState(""),[te,me]=n.useState(!1),[we,V]=n.useState(null),[se,Y]=n.useState(null),[xe,rt]=n.useState(null),[y,U]=n.useState(""),[Z,re]=n.useState(""),[ne,he]=n.useState(""),[Se,is]=n.useState(""),[jt,vt]=n.useState("general"),[ls,kt]=n.useState([]),[X,Nt]=n.useState("prompt_template"),[Ue,os]=n.useState("javascript"),[Be,cs]=n.useState([]),[ge,ds]=n.useState({}),[Ge,wt]=n.useState(null),[He,St]=n.useState([]),[ms,us]=n.useState({}),[Ct,ps]=n.useState(""),[I,xs]=n.useState(null),[_t,qe]=n.useState(!1),[$e,Ie]=n.useState(!1),[Re,hs]=n.useState(""),[Ve,gs]=n.useState(""),[Et,fs]=n.useState("general"),[Pt,bs]=n.useState([]),[$t,ys]=n.useState(""),[nt,js]=n.useState(""),[fe,It]=n.useState("prompt_template"),[Rt,vs]=n.useState(""),[At,Tt]=n.useState([]),[be,at]=n.useState({onMessageReceived:!0,onConversationStarted:!1,scheduled:!1}),[zt,ks]=n.useState(""),[Lt,Ns]=n.useState("organization"),ws=t=>{t!==b&&(p.current+=1,Y(null),Ie(!1),k(t))},Ss=async()=>{const t=++p.current;if(Y(null),!Re.trim()||!Ve.trim()){Y("Name and description are required");return}Ie(!0);try{const g={manifest:{skillId:Fr(Re),name:Re,version:"1.0.0",description:Ve,entryPoint:fe==="prompt_template"?"prompt_template":"index.mjs",permissions:At,tenantScopes:["*"],hooks:{...be.onMessageReceived?{onMessageReceived:[{handler:"execute"}]}:{},...be.onConversationStarted?{onConversationStarted:[{handler:"execute"}]}:{},...be.scheduled?{scheduled:[{handler:"execute",cron:zt||"0 */6 * * *"}]}:{}}},skill_type:fe,category:Et,use_case:Pt,icon_name:$t||void 0,visibility:Lt,prompt_template:fe==="prompt_template"?nt:void 0,entry_source:fe==="executable"?Rt:void 0};await c.contract(mt,g),p.current===t&&s("/skills")}catch(o){console.error("Failed to save skill:",o),p.current===t&&Y(o instanceof Error?o.message:"Failed to save skill")}finally{p.current===t&&Ie(!1)}},Mt=n.useCallback(()=>{switch(b){case"upload":{const t=m.filter(o=>o.manifest&&o.errors.length===0);return t.length===1?t[0].markdown:q}case"describe":return ke;case"manual":return""}},[b,m,q,ke]),Ft=n.useCallback(t=>{const o=t.target.files;if(!o||o.length===0)return;const l=o[0];if(l){const _=gr({file:l});if(_==="template"){l.arrayBuffer().then(P=>{Pe({kind:"file",bytes:P,mime:l.type,filename:l.name}),ce(_)}).catch(P=>{console.error("Failed to read template file",P)}),t.target.value="";return}}const g=_=>{const P=_.webkitRelativePath,H=(P&&P.length>
40?P:_.name).replace(/\\/g,"/").split("/").filter(Boolean),Q=H.length>1?H.slice(1).join("/"):H.join("/");return je(Q)},$=Array.from(o),w=$.find(_=>{var O;const P=((O=g(_))==null?void 0:O.toLowerCase())??"";return P==="skill.md"||P.endsWith("/skill.md")}),A=!!w&&$.length>1;(async()=>{const _=[];if(A&&w){try{const P=g(w),O=P.includes("/")?P.slice(0,P.lastIndexOf("/")+1):"",H=[];for(const Ae of $){const Te=g(Ae);if(!Te||O&&!Te.startsWith(O))continue;const lt=O?Te.slice(O.length):Te,ot=je(lt);if(!ot)continue;const Ze=new Uint8Array(await Ae.arrayBuffer());H.push({path:ot,content:yt(Ze),encoding:"base64"})}const Q=await w.text()??"",ye=ut(Q,{fallbackSkillId:Ce(O.replace(/\/$/,"")||w.name),fallbackName:Ce(O.replace(/\/$/,"")||w.name),packageFiles:H});_.push({fileName:O?O.replace(/\/$/,""):w.name,markdown:Q,manifest:ye.errors.length===0?ye:null,packageFiles:H,errors:ye.errors,saved:!1,saving:!1})}catch(P){const O=P instanceof Error?P.message:"Bundle parse error";_.push({fileName:w.name,markdown:"",manifest:null,packageFiles:[],errors:[O],saved:!1,saving:!1})}v(P=>[...P,..._]),_.length>0&&ce("skill-md");return}for(const P of $)try{const O=P.name.toLowerCase();let H="",Q=[];if(O.endsWith(".md")){if(H=await P.text(),/\b(scripts\/|python\s+scripts\/|node\s+scripts\/|\.\/scripts\/)/i.test(H))throw new Error("This SKILL.md references bundled scripts (e.g. scripts/*.py) but you only uploaded the markdown file. Re-upload the entire skill folder (use the folder picker) or supply a .zip of the directory.");Q=[]}else if(O.endsWith(".zip")){const Ae=await Bt(()=>import("./vendor-pptx-DSGYNC4F.js").then(J=>J.J),__vite__mapDeps([0,1,2,3])),lt=await(Ae.default??Ae).loadAsync(await P.arrayBuffer()),Ze=Object.values(lt.files).filter(J=>!J.dir),Ke=Ze.find(J=>{const K=je(String(J.name??""));return(K==null?void 0:K.toLowerCase())==="skill.md"||(K==null?void 0:K.toLowerCase().endsWith("/skill.md"))}),Je=Ke?je(String(Ke.name??"")):null,Ye=Je&&Je.includes("/")?Je.slice(0,Je.lastIndexOf("/")+1):"",Ut=new Map;for(const J of Ze){const K=je(String(J.name??""));if(!K||Ye&&!K.startsWith(Ye))continue;const ct=Ye?K.slice(Ye.length):K,dt=je(ct);dt&&(Ut.set(dt,J),Q.push({path:dt,content:await J.async("base64"),encoding:"base64"}))}if(Ke)H=await Ke.async("text");else{let J;const K=Ut.get("skill.json");if(K)try{J=JSON.parse(await K.async("text"))}catch{J=void 0}H=as({fileName:P.name,files:Q,manifest:J}),Q.some(ct=>ct.path.toLowerCase()==="skill.md")||Q.push({path:"SKILL.md",content:ns(H),encoding:"base64"})}}else continue;const ye=ut(H,{fallbackSkillId:Ce(P.name),fallbackName:Ce(P.name),packageFiles:Q});_.push({fileName:P.name,markdown:H,manifest:ye.errors.length===0?ye:null,packageFiles:Q,errors:ye.errors,saved:!1,saving:!1})}catch(O){const H=O instanceof Error?O.message:"Parse error";_.push({fileName:P.name,markdown:"",manifest:null,packageFiles:[],errors:[H],saved:!1,saving:!1})}v(P=>[...P,..._]),_.length>0&&ce("skill-md")})(),t.target.value=""},[]),Cs=n.useCallback(()=>{ce(null),Pe(null)},[]),_s=n.useCallback(async()=>{C(!0),N(null);try{const t=Dr(d),o=[t.path];t.path.toLowerCase().endsWith("/scripts")&&o.unshift(t.path.replace(/\/scripts$/i,""));let l=[],g=o[0],$=null;for(const F of Array.from(new Set(o)))try{const _=await Br({owner:t.owner,repo:t.repo,ref:t.ref,rootPath:F});if(l=_,g=F,_.some(P=>P.path.toLowerCase()==="skill.md")||_.length>0)break}catch(_){$=_}if(l.length===0)throw $ instanceof Error?$:new Error("No files found at the GitHub URL");const w=Gr(g.split("/").pop()||t.repo,l),A=ut(w,{fallbackSkillId:Ce(g.split("/").pop()||t.repo),fallbackName:g.split("/").pop()||t.repo,packageFiles:l});v(F=>[...F,{fileName:`${t.owner}/${t.repo}/${g}`,markdown:w,manifest:A.errors.length===0?A:null,packageFiles:l,errors:A.errors,saved:!1,saving:!1}])}catch(t){N(t instanceof Error?t.message:"GitHub import failed")}finally{C(!1)}},[d]),it=n.useCallback((t,o={})=>{var F;const l=o.mergeMode===!0,g=_=>typeof _=="string"&&_.trim().length>0,$=_=>Array.isArray(_)&&_.length>0,w=_=>_!==null&&typeof _=="object"&&!Array.isArray(_)&&Object.keys(_).length>0;(!l||g(t==null?void 0:t.skill_markdown))&&De((t==null?void 0:t.skill_markdown)??""),t!=null&&t.parsed_manifest&&((!l||g(t.parsed_manifest.name))&&U(t.parsed_manifest.name),(!l||g(t.parsed_manifest.description))&&re(t.parsed_manifest.description)),(!l||g(t==null?void 0:t.prompt_template))&&he((t==null?void 0:t.prompt_template)??""),(!l||g(t==null?void 0:t.test_placeholder))&&is((t==null?void 0:t.test_placeholder)??""),(!l||g(t==null?void 0:t.category))&&vt((t==null?void 0:t.category)??"general"),(!l||$(t==null?void 0:t.use_case))&&kt(Array.isArray(t==null?void 0:t.use_case)?t.use_case:[]),(!l||t!=null&&t.skill_type)&&Nt((t==null?void 0:t.skill_type)==="executable"?"executable":"prompt_template");const A=(t==null?void 0:t.language)??((F=t==null?void 0:t.parsed_manifest)==null?void 0:F.language);(!l||A)&&os(A==="python"||A==="typescript"||A==="wasm"?A:"javascript"),(!l||$(t==null?void 0:t.network_allowlist))&&cs(Array.isArray(t==null?void 0:t.network_allowlist)?t.network_allowlist:[]),(!l||w(t==null?void 0:t.additional_files))&&ds(t!=null&&t.additional_files&&typeof t.additional_files=="object"?t.additional_files:{}),(!l||g(t==null?void 0:t.entry_source))&&wt((t==null?void 0:t.entry_source)??null),(!l||$(t==null?void 0:t.permissions))&&St(Yt(t==null?void 0:t.permissions)),(!l||w(t==null?void 0:t.hooks))&&us((t==null?void 0:t.hooks)??{}),(!l||g(t==null?void 0:t.capabilities_summary))&&ps((t==null?void 0:t.capabilities_summary)??""),rt((t==null?void 0:t.security_scan)??null)},[]);n.useEffect(()=>{if(!a||u)return;let t=!1;return(async()=>{M(!0);try{const l=await f.current.get(`/skills/${a}`);if(t)return;if(!l){B(!1);return}const g=Gs.safeParse({isSystemIdentity:l.isSystemIdentity});if(!sr({isSystemIdentity:g.success?g.data.isSystemIdentity:void 0,source:typeof l.source=="string"?l.source:"",status:typeof l.status=="string"?l.status:null,creatorUserId:typeof l.created_by_user=="string"?l.created_by_user:null,currentUserId:i==null?void 0:i.id,isAdmin:x,isSuperAdmin:h}).canEdit){B(!1);return}B(!0),U(String(l.name??"")),re(String(l.description??"")),vt(String(l.category??"general")),kt(Array.isArray(l.use_case)?l.use_case:[]),Nt(l.skill_type==="executable"?"executable":"prompt_template"),St(Yt(l.permissions)),he(String(l.prompt_template??"")),l.entry_source&&wt(String(l.entry_source));const w=l.manifest,A=["```skill-manifest",JSON.stringify({skillId:l.skill_id,name:l.name,version:(w==null?void 0:w.version)??l.version??"1.0.0",description:l.description,permissions:l.permissions??[],tenantScopes:(w==null?void 0:w.tenantScopes)??["*"],entryPoint:(w==null?void 0:w.entryPoint)??"index.mjs",category:l.category??"general"},null,2),"```","",l.prompt_template?String(l.prompt_template):""].join(`
5`);De(A),Ne([{role:"user",content:`Edit skill: ${l.name}`},{role:"assistant",content:A}]),k("describe"),E(!0)}catch(l){console.error("Failed to load skill for editing:",l),t||B(!1)}finally{t||M(!1)}})(),()=>{t=!0}},[a,x,h,u,i==null?void 0:i.id]);const Es=async()=>
5{if(ae){await Ps(ae);return}me(!0),V(null);try{const t=await f.current.contract(Gt,{prompt:ee,conversation_history:ie,mode:ie.length===0?"generate":"refine"});it(t),Ne([...ie,{role:"user",content:ee},{role:"assistant",content:(t==null?void 0:t.skill_markdown)??""}]),ve("")}catch(t){console.error("Generation failed:",t),V(t instanceof Error?t.message:"Skill generation failed")}finally{me(!1)}},Ps=async t=>{if(t.size>20*1024*1024){V("Zip too large (max 20 MB).");return}me(!0),V(null);try{const o=await f.current.getAccessToken(),l=encodeURIComponent(ee||"Extract a TeamHiiv skill from the uploaded ZIP bundle."),$=`${"https://teamhiiv-production-apim.azure-api.net/api".replace(/\/$/,"")}/skills/author/generate-from-zip?prompt=${l}`,w=await fetch($,{method:"POST",headers:{...o?{Authorization:`Bearer ${o}`}:{},"Content-Type":"application/zip"},body:t}),A=await w.text();let F=null;try{F=A?JSON.parse(A):null}catch{F=null}if(!w.ok)throw new Error(F&&F.error||(A?A.slice(0,200):`Zip import failed (HTTP ${w.status})`));if(!F)throw new Error("Zip import returned an empty response.");it(F),Ne([...ie,{role:"user",content:`Imported zip: ${t.name}${ee?`
6${ee}`:""}`},{role:"assistant",content:(F==null?void 0:F.skill_markdown)??""}]),ve(""),pe(null)}catch(o){console.error("Zip generation failed:",o),V(o instanceof Error?o.message:"Skill zip import failed")}finally{me(!1)}},Dt=async()=>{if(de.trim()){me(!0),V(null);try{const t=await f.current.contract(Gt,{prompt:de,conversation_history:[...ie,{role:"user",content:de}],mode:"refine"});it(t,{mergeMode:!0}),Ne([...ie,{role:"user",content:de},{role:"assistant",content:(t==null?void 0:t.skill_markdown)??""}]),Oe("")}catch(t){console.error("Refine failed:",t),V(t instanceof Error?t.message:"Skill refinement failed")}finally{me(!1)}}},Ot=async t=>{if(a&&D!==!0){Y("You do not have permission to edit this skill.");return}const o=Mt();if(!o.trim()){Y("No skill content to save. Generate or upload a skill first.");return}const l=b==="describe"&&y;Ie(!0),Y(null);try{let g;if(l){const A=R&&a?a:y.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,63)||"custom-skill",F=Ue==="python"?"main.py":"index.mjs",_=Hs.safeParse(ms);g={markdown:o,package_files:[],manifest:{skillId:A,name:y,version:"1.0.0",description:Z,permissions:He,tenantScopes:["*"],entryPoint:F,language:Ue,...Be.length>0?{networkAllowlist:Be}:{},..._.success&&Object.keys(_.data).length>0?{hooks:_.data}:{}},entry_source:Ge,additional_files:ge,prompt_template:ne||We(o),skill_type:X,approve:!0,...t}}else if(I)g={markdown:o,package_files:oe,manifest:{skillId:I.skillId,name:I.name,version:I.version,description:I.description,permissions:I.permissions,tenantScopes:I.tenantScopes,entryPoint:I.entryPoint,hooks:I.hooks,...I.language?{language:I.language}:{}},entry_source:I.raw.entrySource||null,...I.additionalFiles?{additional_files:I.additionalFiles}:{},prompt_template:I.hasEntrySource||Xe(oe)?null:We(o),skill_type:I.hasEntrySource||Xe(oe)?"executable":"prompt_template",approve:!0,...t};else return;const w=(await f.current.contract(mt,g)).skill_id;if(!w){Y("Save succeeded but no skill id returned by the server.");return}s(`/skills/${w}`)}catch(g){console.error("Save failed:",g),Y(g instanceof Error?g.message:"Failed to save skill")}finally{Ie(!1)}},$s={critical:"bg-red-100 text-red-800 border-red-300",high:"bg-orange-100 text-orange-800 border-orange-300",medium:"bg-yellow-100 text-yellow-800 border-yellow-300",low:"bg-blue-100 text-blue-800 border-blue-300",info:"bg-gray-100 text-gray-700 border-gray-300"},Is=t=>t==="block"?"Blocked — cannot save":t==="pending_review"?"Needs security review":"Clean",Rs=t=>t==="block"?"border-red-400 bg-red-50":t==="pending_review"?"border-orange-400 bg-orange-50":"border-green-400 bg-green-50",As=t=>{const o=t.findings??[],l=o.slice(0,12);return e.jsxs("div",{className:`mb-4 rounded-md border px-4 py-3 text-sm ${Rs(t.decision)}`,children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("strong",{children:["Security scan: ",Is(t.decision)]}),e.jsxs("span",{className:"text-gray-600 text-xs",children:[t.summary.total," finding",t.summary.total===1?"":"s"," — C",t.summary.critical," · H",t.summary.high," · M",t.summary.medium," · L",t.summary.low]})]}),o.length===0?e.jsxs("p",{className:"text-gray-700 text-xs",children:["No issues detected across ",t.detectors_run.join(", ")||"known detectors","."]}):e.jsxs("ul",{className:"space-y-1.5",children:[l.map((g,$)=>e.jsxs("li",{className:`rounded border px-2 py-1.5 text-xs ${$s[g.severity]}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold uppercase",children:g.severity}),e.jsx("span",{className:"font-mono",children:g.detector}),g.file&&e.jsxs("span",{className:"opacity-70",children:["· ",g.f
6ile,g.line?`:${g.line}`:""]})]}),e.jsx("div",{className:"mt-0.5",children:g.message}),g.remediation&&e.jsx("div",{className:"mt-0.5 italic opacity-80",children:g.remediation})]},`${g.detector}-${$}`)),o.length>l.length&&e.jsxs("li",{className:"text-gray-600 text-xs",children:["… +",o.length-l.length," more finding(s)."]})]})]})};function We(t){return t.replace(/```skill-manifest\s*\n[\s\S]*?\n```/i,"").replace(/```skill-entry\s*\n[\s\S]*?\n```/i,"").replace(/```(?:js|mjs|javascript|python|py)\s*\n[\s\S]*?\n```/i,"").trim()||null}if(_t&&b==="describe"&&y){const t=y.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,63)||"custom-skill";return e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-8",children:[e.jsxs("button",{onClick:()=>qe(!1),className:"mb-6 flex items-center gap-1 text-gray-500 text-sm hover:text-gray-700",children:[e.jsx(Le,{size:14}),"Back to editor"]}),e.jsx("h1",{className:"mb-6 font-semibold text-xl",children:"Preview & Save"}),X==="executable"&&e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2 text-xs",children:[e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-2 py-1 font-medium ${Ue==="python"?"border-amber-400 bg-amber-50 text-amber-900":"border-indigo-400 bg-indigo-50 text-indigo-900"}`,children:["Runtime: ",Ue==="python"?"Python 3 (sandbox)":"JavaScript (sandbox)"]}),Be.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-gray-300 bg-gray-50 px-2 py-1 text-gray-700",children:["Network allowlist: ",Be.join(", ")]}),Object.keys(ge).length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-emerald-300 bg-emerald-50 px-2 py-1 text-emerald-900",children:["Bundled files: ",Object.keys(ge).length]})]}),X==="executable"&&Object.keys(ge).length>0&&e.jsxs("details",{className:"mb-3 rounded-md border border-gray-200 bg-gray-50 p-2 text-xs",children:[e.jsxs("summary",{className:"cursor-pointer font-medium text-gray-700",children:[Object.keys(ge).length," bundled file",Object.keys(ge).length===1?"":"s"," (will ship with the skill)"]}),e.jsx("ul",{className:"mt-2 space-y-0.5 font-mono text-[11px] text-gray-600",children:Object.entries(ge).map(([o,l])=>e.jsxs("li",{children:[o," ",e.jsxs("span",{className:"text-gray-400",children:["(",l.length.toLocaleString()," chars)"]})]},o))})]}),se&&e.jsxs("div",{className:"mb-4 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-red-800 text-sm",children:[e.jsx("strong",{children:"Save failed: "}),se]}),xe&&As(xe),e.jsx(Zt,{manifest:{skillId:t,name:y,version:"1.0.0",description:Z,permissions:He},promptTemplate:ne,entrySource:Ge,skillType:X,category:jt,useCases:ls,iconName:jt,testPlaceholder:Se,onSave:(xe==null?void 0:xe.decision)==="block"?()=>Y("Skill is blocked by the security scanner. Resolve the critical findings before saving."):Ot,saving:$e})]})}if(_t&&I&&I.errors.length===0){const t=I.hasEntrySource?"executable":"prompt_template",o=t==="prompt_template"?We(Mt()):null,l=I.raw.entrySource||null;return e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-8",children:[e.jsxs("button",{onClick:()=>qe(!1),className:"mb-6 flex items-center gap-1 text-gray-500 text-sm hover:text-gray-700",children:[e.jsx(Le,{size:14}),"Back to editor"]}),e.jsx("h1",{className:"mb-6 font-semibold text-xl",children:"Preview & Save"}),se&&e.jsxs("div",{className:"mb-4 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-red-800 text-sm",children:[e.jsx("strong",{children:"Save failed: "}),se]}),e.jsx(Zt,{manifest:{skillId:I.skillId,name:I.name,version:I.version,description:I.description,permissions:I.permissions},promptTemplate:o,entrySource:l,skillType:t,category:I.category,useCases:[],iconName:I.category,onSave:Ot,saving:$e})]})}return T?e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-8",children:[e.jsx("h1",{className:"mb-6 font-semibold text-xl",children:"Loading Skill..."}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 text-sm",children:[e.jsx(ze,{size:14,className:"animate-pulse"}),"Loading skill data for editing..."]})]}):a&&D===!1?e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-8",children:[e.jsx("h1",{className:"mb-3 font-semibold text-xl",children:"Skill is read-only"}),e.jsx("p",{className:"mb-6 text-gray-600 text-sm",children:"Only a super admin can edit a platform-owned system skill."}),e.jsxs(L,{variant:"outline",onClick:()=>s(`/skills/${a}`),children:[e.jsx(Le,{size:14,className:"mr-2"})," Back to skill"]})]}):e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-8",children:[e.jsx("h1",{className:"mb-6 font-semibold text-xl",children:R?"Edit Skill":"Create a Skill"}),!R&&e.jsx("div",{className:"mb-6 flex gap-1 rounded-lg bg-gray-100 p-1",children:[{key:"upload",label:"Upload .md / .zip",icon:pt},{key:"describe",label:"AI Generate",icon:rs},{key:"manual",label:"Create from Scratch",icon:gt}].map(({key:t,label:o,icon:l})=>e.jsxs("button",{onClick:()=>ws(t),className:`flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 text-sm transition-colors ${b===t?"bg-white font-medium text-gray-900 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[e.jsx(l,{size:14}),o]},t))}),b==="upload"&&ue!=="template"&&ue!=="gdoc-url"&&e.jsxs("div",{className:"space-y-4","data-testid":"skill-upload-zone",children:[e.jsxs("div",{className:"rounded-lg border-2 border-dashed p-8 text-center",children:[e.jsx(Ys,{size:32,className:"mx-auto mb-3 text-gray-300"}),e.jsx("p",{className:"mb-3 text-gray-600 text-sm",children:"Drag & drop SKILL.md, a skill folder, or a .zip — or click to browse"}),e.jsx("p",{className:"mb-3 text-gray-400 text-xs",children:"Upload a zipped skill folder, an entire folder (Anthropic-style with scripts/ + templates/), a single .md, or a .docx/.pptx/.html template. Folder upload preserves the script directory tree."}),e.jsxs("div",{className:"flex justify-center gap-2",children:[e.jsx("input",{type:"file",accept:".md,.docx,.pptx,.html,.zip,application/zip,application/x-zip-compressed",multiple:!0,onChange:Ft,className:"hidden",id:"skill-upload"}),e.jsx("label",{htmlFor:"skill-upload",className:"inline-flex cursor-pointer items-center rounded-md border border-indigo-200 px-4 py-2 font-medium text-indigo-600 text-sm hover:bg-indigo-50",children:"Choose files"}),e.jsx("input",{type:"file",multiple:!0,onChange:Ft,className:"hidden",id:"skill-upload-folder",ref:t=>{t&&t.setAttribute("webkitdirectory","")}}),e.jsx("label",{htmlFor:"skill-upload-folder",className:"inline-flex cursor-pointer items-center rounded-md border border-indigo-200 px-4 py-2 font-medium text-indigo-600 text-sm hover:bg-indigo-50",children:"Choose folder"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(Xs,{size:16,className:"text-gray-500"}),e.jsx("span",{className:"font-medium text-gray-900 text-sm",children:"Import from GitHub"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"url",value:d,onChange:t=>S(t.target.value),placeholder:"https://github.com/owner/repo/tree/main/path/to/skill",className:"min-w-0 flex-1 rounded-md border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500"}),e.jsx(L,{type:"button",variant:"outline",onClick:_s,disabled:j||!d.trim(),children:j?"Importing...":"Import"})]}),z&&e.jsx("div",{className:"mt-2 text-red-600 text-xs",children:z})]}),m.length>0&&e.jsxs("div",{className:"space-y-2",children:[m.map((t,o)=>e.jsxs("div",{className:`flex items-center justify-between rounded-lg border p-3 ${t.errors.length>0?"border-red-200 bg-red-50":(t.saved,"border-green-200 bg-green-50")}`,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-gray-900 text-sm",children:t.fileName}),t.errors.length===0&&t.manifest&&e.jsx("span",{className:"text-green-600 text-xs",children:t.manifest.name}),t.errors.length===0&&t.packageFiles.length>1&&e.jsxs("span",{className:"text-gray-500 text-xs",children:[t.packageFiles.length," files"]}),t.saved&&e.jsx("span",{className:"font-medium text-green-700 text-xs",children:"Saved"})]}),t.errors.length>0&&e.jsx("div",{className:"mt-1",children:t.errors.map((l,g)=>e.jsx("div",{className:"text-red-600 text-xs",children:l},g))})]}),e.jsxs("div",{className:"ml-3 flex items-center gap-2",children:[t.errors.length===0&&!t.saved&&e.jsx(L,{size:"sm",variant:"outline",className:"text-xs",onClick:()=>{t.manifest&&(xs(t.manifest),G(t.markdown),Ee(t.packageFiles),qe(!0))},children:"Preview"}),e.jsxs("button",{type:"button",onClick:()=>{v(l=>l.filter((g,$)=>$!==o))},className:"p-1 text-gray-400 hover:text-gray-600",children:[e.jsx("span",{className:"sr-only",children:"Remove"}),"×"]})]})]},`${t.fileName}-${o}`)),m.some(t=>t.errors.length===0&&!t.saved)&&e.jsx("div",{className:"flex justify-end",children:e.jsx(L,{onClick:async()=>{for(let t=0;t<m.length;t++){const o=m[t];if(!(o.errors.length>0||o.saved||!o.manifest)){v(l=>l.map((g,$)=>$===t?{...g,saving:!0}:g));try{const l={markdown:o.markdown,package_files:o.packageFiles,manifest:{skillId:o.manifest.skillId,name:o.manifest.name,version:o.manifest.version,description:o.manifest.description,permissions:o.manifest.permissions,tenantScopes:o.manifest.tenantScopes,entryPoint:o.manifest.entryPoint,hooks:o.manifest.hooks,...o.manifest.language?{language:o.manifest.language}:{}},entry_source:o.manifest.raw.entrySource||null,...o.manifest.additionalFiles?{additional_files:o.manifest.additionalFiles}:{},prompt_template:o.manifest.hasEntrySource||Xe(o.packageFiles)?null:We(o.markdown),skill_type:o.manifest.hasEntrySource||Xe(o.packageFiles)?"executable":"prompt_template",approve:!0};await f.current.contract(mt,l),v(g=>g.map(($,w)=>w===t?{...$,saved:!0,saving:!1}:$))}catch(l){const g=l instanceof Error?l.message:"Save failed";v($=>$.map((w,A)=>A===t?{...w,saving:!1,errors:[...w.errors,g]}:w))}}}},disabled:$e,children:"Save All Valid Skills"})})]})]}),b==="upload"&&(ue==="template"||ue==="gdoc-url")&&Fe&&e.jsx(Lr,{source:Fe,onCancel:Cs,editSkillId:a}),b==="describe"&&e.jsx("div",{className:"space-y-4",children:ie.length===0?e.jsxs(e.Fragment,{children:[e.jsx("textarea",{value:ee,onChange:t=>ve(t.target.value),placeholder:"Describe the skill you want to create... e.g. 'A skill that helps write cold outreach emails for B2B SaaS companies, with personalization variables and follow-up sequences'",className:"h-40 w-full resize-none rounded-md border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(L,{onClick:Es,disabled:te||!ae&&!ee.trim(),children:te?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ze,{size:14,className:"animate-pulse"}),"Generating your skill..."]}):ae?"Process uploaded ZIP":"Generate Skill"}),e.jsxs("label",{className:`inline-flex cursor-pointer items-center gap-2 rounded-md border px-3 py-2 text-sm ${te?"cursor-not-allowed border-gray-200 text-gray-400":"border-gray-300 text-gray-700 hover:bg-gray-50"}`,children:[e.jsx(pt,{size:14}),ae?"Replace ZIP":"Attach skill ZIP",e.jsx("input",{type:"file",accept:".zip,application/zip,application/x-zip-compressed",className:"hidden",disabled:te,onChange:t=>{var l;const o=(l=t.target.files)==null?void 0:l[0];if(t.target.value="",!!o){if(o.size>20*1024*1024){V("Zip too large (max 20 MB).");return}V(null),pe(o)}}})]}),e.jsxs("label",{className:`inline-flex cursor-pointer items-center gap-2 rounded-md border px-3 py-2 text-sm ${te?"cursor-not-allowed border-gray-200 text-gray-400":"border-gray-300 text-gray-700 hover:bg-gray-50"}`,children:[e.jsx(pt,{size:14}),"Attach skill folder",e.jsx("input",{type:"file",webkitdirectory:"",directory:"",multiple:!0,className:"hidden",disabled:te,onChange:async t=>{var l;const o=Array.from(t.target.files??[]);if(t.target.value="",!!o.length)try{const{folderToZip:g}=await Bt(async()=>{const{folderToZip:F}=await import("./folder-to-zip-CC_hInvT.js");return{folderToZip:F}},__vite__mapDeps([4,5,1,2,3,6,7])),$=await g(o),w=((l=o[0].webkitRelativePath)==null?void 0:l.split("/")[0])??"skill",A=new File([$],`${w}.zip`,{type:"application/zip"});V(null),pe(A)}catch(g){V(g instanceof Error?g.message:"Folder upload failed")}}})]}),ae&&e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-md border border-emerald-300 bg-emerald-50 px-2 py-1 text-emerald-900 text-xs",children:["ZIP attached: ",ae.name," (",Math.round(ae.size/1024)," KB)",e.jsx("button",{type:"button",onClick:()=>pe(null),disabled:te,className:"ml-1 text-emerald-700 underline-offset-2 hover:underline",children:"clear"})]}),e.jsx("span",{className:"text-gray-500 text-xs",children:"Attach a ZIP (≤ 20 MB), then describe any edits in the prompt above. Source files are copied verbatim unless your prompt asks for changes."})]}),we&&e.jsxs("div",{className:"mt-2 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-red-800 text-sm",children:[e.jsx("strong",{children:"Generation failed: "}),we]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex items-center gap-2 rounded-lg border px-4 py-3 ${X==="executable"?"border-indigo-200 bg-indigo-50":"border-green-200 bg-green-50"}`,children:[X==="executable"?e.jsx(Qs,{size:16,className:"shrink-0 text-indigo-600"}):e.jsx(ze,{size:16,className:"shrink-0 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:`font-medium text-sm ${X==="executable"?"text-indigo-800":"text-green-800"}
6`,children:X==="executable"?"Executable skill generated with automation capabilities":"Prompt skill generated — review and customize below"}),X==="executable"&&Ct&&e.jsx("p",{className:"mt-1 text-indigo-600 text-xs",children:Ct})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block font-medium text-gray-600 text-xs",children:"Skill Name"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:y,onChange:t=>U(t.target.value),className:"w-full rounded-md border px-3 py-2 pr-8 font-medium text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500",placeholder:"Enter a name for your skill"}),e.jsx(gt,{size:14,className:"absolute top-1/2 right-3 -translate-y-1/2 text-gray-400"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block font-medium text-gray-600 text-xs",children:"Description"}),e.jsx("textarea",{value:Z,onChange:t=>re(t.target.value),className:"h-20 w-full resize-none rounded-md border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500",placeholder:"Describe what this skill does"})]}),X==="executable"&&e.jsxs(e.Fragment,{children:[He.length>0&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1.5 block flex items-center gap-1 font-medium text-gray-600 text-xs",children:[e.jsx(er,{size:12}),"Required Permissions"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:He.map(t=>e.jsx("span",{className:"inline-flex items-center rounded-md border border-amber-200 bg-amber-50 px-2 py-1 font-medium text-[11px] text-amber-700",children:t},t))})]}),Ge&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1.5 block flex items-center gap-1 font-medium text-gray-600 text-xs",children:[e.jsx(Wt,{size:12}),"Generated Skill Code"]}),e.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-1.5 border-gray-700 border-b bg-gray-800 px-3 py-2 text-gray-400 text-xs",children:[e.jsx(Wt,{size:12}),"index.mjs — Runs in a secure sandbox"]}),e.jsx("pre",{className:"max-h-60 overflow-auto bg-gray-900 p-3 font-mono text-gray-100 text-xs leading-relaxed",children:Ge})]})]})]}),ne&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block font-medium text-gray-600 text-xs",children:X==="executable"?"Prompt Context (Optional)":"Generated Expert Prompt"}),e.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-1.5 border-b bg-gray-50 px-3 py-2 text-gray-500 text-xs",children:[e.jsx(tr,{size:12}),X==="executable"?"Additional prompt context used during execution":"This prompt will guide the AI when users activate this skill"]}),e.jsx("div",{className:"max-h-48 overflow-auto whitespace-pre-wrap bg-white p-3 text-gray-700 text-xs leading-relaxed",children:ne})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:de,onChange:t=>Oe(t.target.value),placeholder:"Want changes? e.g. 'Make the tone more formal' or 'Add email integration'",className:"flex-1 rounded-md border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500",onKeyDown:t=>t.key==="Enter"&&Dt()}),e.jsx(L,{onClick:Dt,disabled:te||!de.trim(),variant:"outline",size:"sm",children:te?"Refining...":"Refine"})]}),we&&e.jsxs("div",{className:"rounded-md border border-red-300 bg-red-50 px-3 py-2 text-red-800 text-sm",children:[e.jsx("strong",{children:"Refinement failed: "}),we]}),e.jsx(L,{onClick:()=>qe(!0),disabled:!y.trim(),children:R?"Save Changes":"Finalize & Preview"})]})}),b==="manual"&&e.jsxs("div",{className:"mx-auto max-w-3xl space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Basics"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium text-sm",children:"Name *"}),e.jsx("input",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:Re,onChange:t=>hs(t.target.value),placeholder:"e.g., Email Response Drafter"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium text-sm",children:"Description *"}),e.jsx("textarea",{className:"min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:Ve,onChange:t=>
6gs(t.target.value),placeholder:"What does this skill do?"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium text-sm",children:"Category"}),e.jsx("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:Et,onChange:t=>fs(t.target.value),children:Object.entries(ht).map(([t,o])=>e.jsx("option",{value:t,children:o},t))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium text-sm",children:"Icon Name"}),e.jsx("input",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:$t,onChange:t=>ys(t.target.value),placeholder:"e.g., Mail, FileText, Brain"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium text-sm",children:"Use Cases"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ss.map(t=>e.jsx("button",{type:"button",onClick:()=>bs(o=>o.includes(t)?o.filter(l=>l!==t):[...o,t]),className:`rounded-full border px-3 py-1 font-medium text-xs transition-colors ${Pt.includes(t)?"border-primary bg-primary text-primary-foreground":"border-input bg-background text-muted-foreground hover:bg-muted"}`,children:xt[t]||t},t))})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Prompt Template"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"This prompt will be injected as a system message whenever this skill is used in a conversation."}),e.jsx("textarea",{className:"min-h-[300px] w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm",value:nt,onChange:t=>js(t.target.value),placeholder:"You are an expert..."}),e.jsxs("p",{className:"text-right text-muted-foreground text-xs",children:[nt.length," characters"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Skill Type"}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[e.jsx("input",{type:"radio",checked:fe==="prompt_template",onChange:()=>It("prompt_template")}),e.jsx("span",{className:"text-sm",children:"Prompt Template"})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[e.jsx("input",{type:"radio",checked:fe==="executable",onChange:()=>It("executable")}),e.jsx("span",{className:"text-sm",children:"Executable (JS/MJS)"})]})]}),fe==="executable"&&e.jsx("textarea",{className:"min-h-[200px] w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm",value:Rt,onChange:t=>vs(t.target.value),placeholder:"export default async function run(api, input) { ... }"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Permissions"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:es.map(t=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:At.includes(t),onChange:o=>{o.target.checked?Tt(l=>[...l,t]):Tt(l=>l.filter(g=>g!==t))}}),t]},t))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Execution Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium text-sm",children:"Hooks"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:be.onMessageReceived,onChange:t=>at(o=>({...o,onMessageReceived:t.target.checked}))}),"On Message Received"]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:be.onConversationStarted,onChange:t=>at(o=>({...o,onConversationStarted:t.target.checked}))}),"On Conversation Started"]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:be.scheduled,onChange:t=>at(o=>({...o,scheduled:t.target.checked}))}),"Scheduled"]}),be.scheduled&&e.jsx("input",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:zt,onCh
6ange:t=>ks(t.target.value),placeholder:"0 */6 * * * (every 6 hours)"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium text-sm",children:"Visibility"}),e.jsx("div",{className:"flex gap-4",children:["private","team","organization"].map(t=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm",children:[e.jsx("input",{type:"radio",checked:Lt===t,onChange:()=>Ns(t)}),t.charAt(0).toUpperCase()+t.slice(1)]},t))})]})]}),se&&e.jsxs("div",{role:"alert",className:"rounded-md border border-red-300 bg-red-50 px-3 py-2 text-red-800 text-sm",children:[e.jsx("strong",{children:"Save failed: "}),se]}),e.jsxs("div",{className:"flex justify-end gap-3 border-t pt-4",children:[e.jsx(L,{variant:"outline",onClick:()=>s("/skills"),children:"Cancel"}),e.jsx(L,{onClick:Ss,disabled:$e||!Re.trim()||!Ve.trim(),children:$e?"Saving...":"Save Skill"})]})]})]})}export{en as default};

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.