@skillmaker/cli-win32-x64 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/skillmaker.exe +0 -0
- package/package.json +20 -0
- package/viewer-dist/_astro/NextShell.BEF_RI5q.js +31 -0
- package/viewer-dist/_astro/client.Fd5LK8aS.js +33 -0
- package/viewer-dist/_astro/index.CV5TvEA0.css +1 -0
- package/viewer-dist/_astro/index.DBy5LfQW.js +9 -0
- package/viewer-dist/index.html +13 -0
- package/viewer-dist/next/index.html +1 -0
- package/viewer-dist/skillmaker-logo.png +0 -0
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skillmaker/cli-win32-x64",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "skillmaker CLI binary + viewer assets for win32-x64. Installed automatically as an optionalDependency of skillmaker-studio -- not meant to be depended on or invoked directly.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/sociotechnica-org/skillmaker-studio.git"
|
|
9
|
+
},
|
|
10
|
+
"os": [
|
|
11
|
+
"win32"
|
|
12
|
+
],
|
|
13
|
+
"cpu": [
|
|
14
|
+
"x64"
|
|
15
|
+
],
|
|
16
|
+
"files": [
|
|
17
|
+
"bin/skillmaker.exe",
|
|
18
|
+
"viewer-dist/**"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import{r as m}from"./index.DBy5LfQW.js";var an={exports:{}},tt={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Ss;function ho(){if(Ss)return tt;Ss=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,r,o){var a=null;if(o!==void 0&&(a=""+o),r.key!==void 0&&(a=""+r.key),"key"in r){o={};for(var l in r)l!=="key"&&(o[l]=r[l])}else o=r;return r=o.ref,{$$typeof:e,type:s,key:a,ref:r!==void 0?r:null,props:o}}return tt.Fragment=t,tt.jsx=n,tt.jsxs=n,tt}var Ns;function po(){return Ns||(Ns=1,an.exports=ho()),an.exports}var i=po();const mo=(e,t,n)=>Math.min(n,Math.max(t,e)),xo=(e,t)=>{if(typeof window>"u")return t;const n=window.localStorage.getItem(e),s=n===null?Number.NaN:Number(n);return Number.isFinite(s)?s:t};function yn(e,t,n,s,r){const[o,a]=m.useState(()=>xo(t,n)),[l,c]=m.useState(!1),u=m.useRef(o),p=m.useCallback(f=>{f.preventDefault(),c(!0);const h=g=>{const y=e==="left"?g.clientX:window.innerWidth-g.clientX,v=typeof r=="function"?r():r,b=mo(y,s,v);u.current=b,a(b)},x=()=>{window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",x),c(!1);try{window.localStorage.setItem(t,String(u.current))}catch{}};window.addEventListener("mousemove",h),window.addEventListener("mouseup",x)},[e,t,s,r]);return{width:o,dragging:l,onDragStart:p}}function go({size:e=16}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[i.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),i.jsx("line",{x1:"5.5",y1:"2.5",x2:"5.5",y2:"13.5"})]})}function bo({size:e=16}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[i.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),i.jsx("line",{x1:"10.5",y1:"2.5",x2:"10.5",y2:"13.5"})]})}function yo({size:e=16}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[i.jsx("circle",{cx:"3.5",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),i.jsx("line",{x1:"6.5",y1:"4.5",x2:"13.5",y2:"4.5"}),i.jsx("circle",{cx:"3.5",cy:"8",r:"1",fill:"currentColor",stroke:"none"}),i.jsx("line",{x1:"6.5",y1:"8",x2:"13.5",y2:"8"}),i.jsx("circle",{cx:"3.5",cy:"11.5",r:"1",fill:"currentColor",stroke:"none"}),i.jsx("line",{x1:"6.5",y1:"11.5",x2:"13.5",y2:"11.5"})]})}function vo({size:e=15}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[i.jsx("rect",{x:"1.5",y:"2",width:"3.4",height:"9",rx:"0.8"}),i.jsx("rect",{x:"6.3",y:"2",width:"3.4",height:"12",rx:"0.8"}),i.jsx("rect",{x:"11.1",y:"2",width:"3.4",height:"6",rx:"0.8"})]})}function ko({size:e=15}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[i.jsx("path",{d:"M2 4.5l1.5 1.5L6 3.5"}),i.jsx("line",{x1:"8",y1:"4.5",x2:"14",y2:"4.5"}),i.jsx("path",{d:"M2 10.5l1.5 1.5L6 9.5"}),i.jsx("line",{x1:"8",y1:"10.5",x2:"14",y2:"10.5"})]})}function cr({open:e}){return i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:`transition-transform duration-150 ${e?"rotate-90":""}`,children:i.jsx("path",{d:"M6 3.5L10.5 8L6 12.5"})})}function lr({size:e=14}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",children:[i.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),i.jsx("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]})}function wo({size:e=16}){return i.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.jsx("path",{d:"M8 .8a7.2 7.2 0 0 0-2.28 14.03c.36.07.5-.16.5-.35v-1.22c-2 .43-2.43-.97-2.43-.97-.33-.83-.8-1.05-.8-1.05-.66-.45.05-.44.05-.44.72.05 1.1.75 1.1.75.65 1.1 1.7.79 2.1.6.07-.47.26-.79.46-.97-1.6-.18-3.28-.8-3.28-3.56 0-.79.28-1.43.74-1.94-.07-.18-.32-.91.07-1.9 0 0 .6-.2 1.98.74a6.9 6.9 0 0 1 3.6 0c1.38-.93 1.98-.74 1.98-.74.4.99.15 1.72.07 1.9.46.5.74 1.15.74 1.94 0 2.77-1.69 3.38-3.3 3.56.26.22.5.66.5 1.33v1.97c0 .2.13.42.5.35A7.2 7.2 0 0 0 8 .8Z"})})}function jo({size:e=16}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[i.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),i.jsx("path",{d:"M6.2 6.2a1.8 1.8 0 1 1 2.7 1.6c-.55.32-.9.6-.9 1.3v.3"}),i.jsx("circle",{cx:"8",cy:"11.4",r:"0.7",fill:"currentColor",stroke:"none"})]})}function So({size:e=16}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[i.jsx("path",{d:"M9.5 2.5h4v4"}),i.jsx("line",{x1:"13.5",y1:"2.5",x2:"9",y2:"7"}),i.jsx("path",{d:"M6.5 13.5h-4v-4"}),i.jsx("line",{x1:"2.5",y1:"13.5",x2:"7",y2:"9"})]})}function No({size:e=16}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[i.jsx("path",{d:"M7 3v4H3"}),i.jsx("line",{x1:"7",y1:"7",x2:"2.5",y2:"2.5"}),i.jsx("path",{d:"M9 13V9h4"}),i.jsx("line",{x1:"9",y1:"9",x2:"13.5",y2:"13.5"})]})}function Co({size:e=16}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[i.jsx("circle",{cx:"8",cy:"8",r:"3"}),i.jsx("line",{x1:"8",y1:"1.2",x2:"8",y2:"3.2"}),i.jsx("line",{x1:"8",y1:"12.8",x2:"8",y2:"14.8"}),i.jsx("line",{x1:"1.2",y1:"8",x2:"3.2",y2:"8"}),i.jsx("line",{x1:"12.8",y1:"8",x2:"14.8",y2:"8"}),i.jsx("line",{x1:"3.2",y1:"3.2",x2:"4.6",y2:"4.6"}),i.jsx("line",{x1:"11.4",y1:"11.4",x2:"12.8",y2:"12.8"}),i.jsx("line",{x1:"12.8",y1:"3.2",x2:"11.4",y2:"4.6"}),i.jsx("line",{x1:"4.6",y1:"11.4",x2:"3.2",y2:"12.8"})]})}function Eo({size:e=16}){return i.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:i.jsx("path",{d:"M13.2 9.8A5.6 5.6 0 0 1 6.2 2.8a5.6 5.6 0 1 0 7 7Z"})})}function Ro({size:e=16}){return i.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:i.jsx("path",{d:"M1.5 4.5a1 1 0 0 1 1-1h3l1.5 1.8h6.5a1 1 0 0 1 1 1v6.2a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1z"})})}const Ce=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let s=0,r=t.length;s<r;s++)n=t[s](n);return n}}},$o={pipe(){return Ce(this,arguments)}},Jt=(function(){function e(){}return e.prototype=$o,e})(),D=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):n=>t(n,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(n,s){return arguments.length>=2?t(n,s):function(r){return t(r,n)}};case 3:return function(n,s,r){return arguments.length>=3?t(n,s,r):function(o){return t(o,n,s)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);const n=arguments;return function(s){return t(s,...n)}}}},at=e=>e,Io=e=>()=>e,ur=Io(void 0),_o=ur;function Ae(e){const t=new WeakMap;return n=>{if(t.has(n))return t.get(n);const s=e(n);return t.set(n,s),s}}const vn=e=>{const t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");const n=Object.getPrototypeOf(e);let s=n;for(;s!==null&&s!==Object.prototype;){const r=Reflect.ownKeys(s);for(let o=0;o<r.length;o++)t.add(r[o]);s=Object.getPrototypeOf(s)}return t.has("constructor")&&typeof e.constructor=="function"&&n===e.constructor.prototype&&t.delete("constructor"),t},kn=new WeakSet;function dr(e){return typeof e=="string"}function fr(e){return typeof e=="number"}function To(e){return typeof e=="boolean"}function Ao(e){return typeof e=="symbol"}function Oo(e){return dr(e)||fr(e)||Ao(e)}function Bn(e){return typeof e=="function"}function Po(e){return e!=null}function Fo(e){return!0}function Mo(e){return typeof e=="object"&&e!==null||Bn(e)}const G=D(2,(e,t)=>Mo(e)&&t in e),ce="~effect/interfaces/Hash",H=e=>{switch(typeof e){case"number":return Vn(e);case"bigint":return V(e.toString(10));case"boolean":return V(String(e));case"symbol":return V(String(e));case"string":return V(e);case"undefined":return V("undefined");case"function":case"object":{if(e===null)return V("null");if(e instanceof Date)return V(e.toISOString());if(e instanceof RegExp)return V(e.toString());{if(kn.has(e))return wn(e);if(ln.has(e))return ln.get(e);const t=Wo(e,()=>Lo(e)?e[ce]():typeof e=="function"?wn(e):Array.isArray(e)||ArrayBuffer.isView(e)?hr(e):e instanceof Map?Bo(e):e instanceof Set?Vo(e):Uo(e));return ln.set(e,t),t}}default:throw new Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},wn=e=>(cn.has(e)||cn.set(e,Vn(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),cn.get(e)),me=D(2,(e,t)=>e*53^t),Gt=e=>e&3221225471|e>>>1&1073741824,Lo=e=>G(e,ce),Vn=e=>{if(e!==e)return V("NaN");if(e===1/0)return V("Infinity");if(e===-1/0)return V("-Infinity");let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Gt(t)},V=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Gt(t)},Do=(e,t)=>{let n=12289;for(const s of t)n^=me(H(s),H(e[s]));return Gt(n)},Uo=e=>Do(e,vn(e)),Wn=(e,t)=>n=>{let s=e;for(const r of n)s^=t(r);return Gt(s)},hr=Wn(6151,H),Bo=Wn(V("Map"),([e,t])=>me(H(e),H(t))),Vo=Wn(V("Set"),H),cn=new WeakMap,ln=new WeakMap,un=new WeakSet;function Wo(e,t){if(un.has(e))return V("[Circular]");un.add(e);const n=t();return un.delete(e),n}const le="~effect/interfaces/Equal";function ie(){return arguments.length===1?e=>_e(e,arguments[0]):_e(arguments[0],arguments[1])}function _e(e,t){if(e===t)return!0;if(e==null||t==null)return!1;const n=typeof e;return n!==typeof t?!1:n==="number"&&e!==e&&t!==t?!0:n!=="object"&&n!=="function"||kn.has(e)||kn.has(t)?!1:Ho(e,t,qo)}function Ko(e,t,n){const s=dn.has(e),r=fn.has(t);if(s&&r)return!0;if(s||r)return!1;dn.add(e),fn.add(t);const o=n();return dn.delete(e),fn.delete(t),o}const dn=new WeakSet,fn=new WeakSet;function qo(e,t){if(H(e)!==H(t))return!1;if(e instanceof Date)return t instanceof Date?e.toISOString()===t.toISOString():!1;if(e instanceof RegExp)return t instanceof RegExp?e.toString()===t.toString():!1;const n=Cs(e),s=Cs(t);if(n!==s)return!1;const r=n&&s;return typeof e=="function"&&!r?!1:Ko(e,t,()=>r?e[le](t):Array.isArray(e)?!Array.isArray(t)||e.length!==t.length?!1:Jo(e,t):ArrayBuffer.isView(e)?!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength?!1:Go(e,t):e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:Xo(e,t):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:Qo(e,t):zo(e,t))}function Ho(e,t,n){let s=Rt.get(e);if(!s)s=new WeakMap,Rt.set(e,s);else if(s.has(t))return s.get(t);const r=n(e,t);s.set(t,r);let o=Rt.get(t);return o||(o=new WeakMap,Rt.set(t,o)),o.set(e,r),r}const Rt=new WeakMap;function Jo(e,t){for(let n=0;n<e.length;n++)if(!_e(e[n],t[n]))return!1;return!0}function Go(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function zo(e,t){const n=vn(e),s=vn(t);if(n.size!==s.size)return!1;for(const r of n)if(!s.has(r)||!_e(e[r],t[r]))return!1;return!0}function Yo(e,t){return function(s,r){for(const[o,a]of s){let l=!1;for(const[c,u]of r)if(e(o,c)&&t(a,u)){l=!0;break}if(!l)return!1}return!0}}const Xo=Yo(_e,_e);function Zo(e){return function(n,s){for(const r of n){let o=!1;for(const a of s)if(e(r,a)){o=!0;break}if(!o)return!1}return!0}}const Qo=Zo(_e),Cs=e=>G(e,le),ea=()=>ie,pr=e=>e.length>0,Kn=Symbol.for("~effect/Redactable"),ta=e=>G(e,Kn);function na(e){return ta(e)?mr(e):e}function mr(e){return e[Kn](globalThis[ct]?.context??sa)}const ct="~effect/Fiber/currentFiber",sa={"~effect/Context":{},mapUnsafe:new Map,pipe(){return Ce(this,arguments)}};function J(e,t){const n=t?.space??0,s=new WeakSet,r=n?typeof n=="number"?" ".repeat(n):n:"",o=u=>r.repeat(u),a=(u,p)=>{const f=u?.constructor;return f&&f!==Object.prototype.constructor&&f.name?`${f.name}(${p})`:p},l=u=>{try{return Reflect.ownKeys(u)}catch{return["[ownKeys threw]"]}};function c(u,p=0){if(Array.isArray(u)){if(s.has(u))return Es;if(s.add(u),!r||u.length<=1)return`[${u.map(h=>c(h,p)).join(",")}]`;const f=u.map(h=>c(h,p+1)).join(`,
|
|
10
|
+
`+o(p+1));return`[
|
|
11
|
+
${o(p+1)}${f}
|
|
12
|
+
${o(p)}]`}if(u instanceof Date)return ia(u);if(!t?.ignoreToString&&G(u,"toString")&&typeof u.toString=="function"&&u.toString!==Object.prototype.toString&&u.toString!==Array.prototype.toString){const f=oa(u);return u instanceof Error&&u.cause?`${f} (cause: ${c(u.cause,p)})`:f}if(typeof u=="string")return JSON.stringify(u);if(typeof u=="number"||u==null||typeof u=="boolean"||typeof u=="symbol")return String(u);if(typeof u=="bigint")return String(u)+"n";if(typeof u=="object"||typeof u=="function"){if(s.has(u))return Es;if(s.add(u),Kn in u)return J(mr(u));if(Symbol.iterator in u)return`${u.constructor.name}(${c(Array.from(u),p)})`;const f=l(u);if(!r||f.length<=1){const x=`{${f.map(g=>`${Pt(g)}:${c(u[g],p)}`).join(",")}}`;return a(u,x)}const h=`{
|
|
13
|
+
${f.map(x=>`${o(p+1)}${Pt(x)}: ${c(u[x],p+1)}`).join(`,
|
|
14
|
+
`)}
|
|
15
|
+
${o(p)}}`;return a(u,h)}return String(u)}return c(e,0)}const Es="[Circular]";function Pt(e){return typeof e=="string"?JSON.stringify(e):String(e)}function ra(e){return e.map(t=>`[${Pt(t)}]`).join("")}function ia(e){try{return e.toISOString()}catch{return"Invalid Date"}}function oa(e){try{const t=e.toString();return typeof t=="string"?t:String(t)}catch{return"[toString threw]"}}const qn=Symbol.for("nodejs.util.inspect.custom"),xr=e=>{try{if(G(e,"toJSON")&&Bn(e.toJSON)&&e.toJSON.length===0)return e.toJSON();if(Array.isArray(e))return e.map(xr)}catch{return"[toJSON threw]"}return na(e)};class zt{called=!1;self;constructor(t){this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new zt(this.self)}}const aa=()=>{const e="~effect/Utils/internal",t={[e]:r=>r()},n={[e]:r=>{try{return r()}finally{}}};return t[e](()=>new Error().stack)?.includes(e)===!0?t[e]:n[e]},Hn=aa(),Oe="~effect/Effect",pt="~effect/Exit",ca={_A:at,_E:at,_R:at},gr=`${Oe}/identifier`,L=`${Oe}/args`,K=`${Oe}/evaluate`,oe=`${Oe}/successCont`,ve=`${Oe}/failureCont`,We=`${Oe}/ensureCont`,Re=Symbol.for("effect/Effect/Yield"),Jn={pipe(){return Ce(this,arguments)},toJSON(){return{...this}},toString(){return J(this.toJSON(),{ignoreToString:!0,space:2})},[qn](){return this.toJSON()}},la={[Oe]:ca,...Jn,[Symbol.iterator](){return new zt(this)},toJSON(){return{_id:"Effect",op:this[gr],...L in this?{args:this[L]}:void 0}}},ua=e=>G(e,pt),Tt="~effect/Cause",hn="~effect/Cause/Reason",br=e=>G(e,Tt);class Ge{[Tt];reasons;constructor(t){this[Tt]=Tt,this.reasons=t}pipe(){return Ce(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(t=>t.toJSON())}}toString(){return`Cause(${J(this.reasons)})`}[qn](){return this.toJSON()}[le](t){return br(t)&&this.reasons.length===t.reasons.length&&this.reasons.every((n,s)=>ie(n,t.reasons[s]))}[ce](){return hr(this.reasons)}}const Rs=new WeakMap;class Gn{[hn];annotations;_tag;constructor(t,n,s){if(this[hn]=hn,this._tag=t,n!==Yt&&typeof s=="object"&&s!==null&&n.size>0){const r=Rs.get(s);r&&(n=new Map([...r,...n])),Rs.set(s,n)}this.annotations=n}annotate(t,n){if(t.mapUnsafe.size===0)return this;const s=new Map(this.annotations);t.mapUnsafe.forEach((o,a)=>{n?.overwrite!==!0&&s.has(a)||s.set(a,o)});const r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=s,r}pipe(){return Ce(this,arguments)}toString(){return J(this)}[qn](){return this.toString()}}const Yt=new Map;class yr extends Gn{error;constructor(t,n=Yt){super("Fail",n,t),this.error=t}toString(){return`Fail(${J(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[le](t){return zn(t)&&ie(this.error,t.error)&&ie(this.annotations,t.annotations)}[ce](){return me(V(this._tag))(me(H(this.error))(H(this.annotations)))}}const jn=e=>new Ge(e),da=e=>new Ge([new yr(e)]);class fa extends Gn{defect;constructor(t,n=Yt){super("Die",n,t),this.defect=t}toString(){return`Die(${J(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[le](t){return pa(t)&&ie(this.defect,t.defect)&&ie(this.annotations,t.annotations)}[ce](){return me(V(this._tag))(me(H(this.defect))(H(this.annotations)))}}const ha=e=>new Ge([new fa(e)]),Sn=D(e=>br(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new Ge(e.reasons.map(s=>s.annotate(t,n)))),zn=e=>e._tag==="Fail",pa=e=>e._tag==="Die",vr=e=>e._tag==="Interrupt";function ma(e){return mt("Effect.evaluate: Not implemented")}const ze=e=>({...la,[gr]:e.op,[K]:e[K]??ma,[oe]:e[oe],[ve]:e[ve],[We]:e[We]}),be=e=>{const t=ze(e);return function(){const n=Object.create(t);return n[L]=e.single===!1?arguments:arguments[0],n}},kr=e=>{const t={...ze(e),[pt]:pt,_tag:e.op,get[e.prop](){return this[L]},toString(){return`${e.op}(${J(this[L])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[L]}},[le](n){return ua(n)&&n._tag===this._tag&&ie(this[L],n[L])},[ce](){return me(V(e.op),H(this[L]))}};return function(n){const s=Object.create(t);return s[L]=n,s}},je=kr({op:"Success",prop:"value",[K](e){const t=e.getCont(oe);return t?t[oe](this[L],e,this):e.yieldWith(this)}}),Yn={key:"effect/Cause/StackTrace"},Se=kr({op:"Failure",prop:"cause",[K](e){let t=this[L],n=!1;e.currentStackFrame&&(t=Sn(t,{mapUnsafe:new Map([[Yn.key,e.currentStackFrame]])}),n=!0);let s=e.getCont(ve);for(;e.interruptible&&e._interruptedCause&&s;)s=e.getCont(ve);return s?s[ve](t,e,n?void 0:this):e.yieldWith(n?this:Se(t))}}),Xn=e=>Se(da(e)),mt=e=>Se(ha(e)),Nn=be({op:"WithFiber",[K](e){return this[L](e)}}),xa=(function(){class e extends globalThis.Error{}const t=ze({op:"YieldableError",[K](){return Xn(this)}});return delete t.toString,Object.assign(e.prototype,t),e})(),ga=(function(){const e=Symbol.for("effect/Data/Error/plainArgs");return class extends xa{constructor(n){super(n?.message,n?.cause?{cause:n.cause}:void 0),n&&(Object.assign(this,n),Object.defineProperty(this,e,{value:n,enumerable:!1}))}toJSON(){return{...this[e],...this}}}})(),wr=e=>{class t extends ga{_tag=e}return t.prototype.name=e,t},jr="~effect/data/Option",Sr={[jr]:{_A:e=>e},...Jn,[Symbol.iterator](){return new zt(this)}},ba=Object.defineProperty(Object.assign(Object.create(Sr),{_tag:"Some",_op:"Some",[le](e){return Nr(e)&&Er(e)&&ie(this.value,e.value)},[ce](){return me(H(this._tag))(H(this.value))},toString(){return`some(${J(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:xr(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),ya=H("None"),va=Object.assign(Object.create(Sr),{_tag:"None",_op:"None",valueOrUndefined:void 0,[le](e){return Nr(e)&&Cr(e)},[ce](){return ya},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),Nr=e=>G(e,jr),Cr=e=>e._tag==="None",Er=e=>e._tag==="Some",ka=Object.create(va),wa=e=>{const t=Object.create(ba);return t.value=e,t},wt=()=>ka,W=wa,Zn=Cr,$t=Er,Rr=D(2,(e,t)=>Zn(e)?wt():W(t(e.value))),$s=globalThis.Array,xt=e=>$s.isArray(e)?e:$s.from(e),$r=D(2,(e,t)=>[...e,t]),ja=D(2,(e,t)=>xt(e).concat(xt(t))),pn=pr,Ft=pr;function Sa(e,t){return e<0||e>=t.length}const Na=D(2,(e,t)=>{const n=Math.floor(t);if(Sa(n,e))throw new Error(`Index out of bounds: ${n}`);return e[n]}),Ca=Na(0),Ea=e=>e.slice(1),Ra=D(3,(e,t,n)=>{const s=xt(e),r=xt(t);return Ft(s)?Ft(r)?Ta(n)(ja(s,r)):s:r}),$a=D(2,(e,t)=>Ra(e,t,ea())),Ia=()=>[],_a=D(2,(e,t)=>e.map(t)),Ta=D(2,(e,t)=>{const n=xt(e);if(Ft(n)){const s=[Ca(n)],r=Ea(n);for(const o of r)s.every(a=>!t(o,a))&&s.push(o);return s}return[]}),Aa=e=>ze({op:e.label,[K]:e.evaluate}),Oa=Object.getOwnPropertyDescriptor,Pa=Object.prototype.hasOwnProperty,Fa=Object.isExtensible,Ma=()=>{const e=Oa(Error,"stackTraceLimit");return e===void 0?Fa(Error):Pa.call(e,"writable")?e.writable===!0:e.set!==void 0},La=Ma(),Da=()=>Error.stackTraceLimit,Is=e=>{La&&(Error.stackTraceLimit=e)},_s="~effect/Context/Service",Ua=function(){const e=Da();Is(2);const t=new Error;Is(e);function n(){}const s=n;return Object.setPrototypeOf(s,Ba),Object.defineProperty(s,"stack",{get(){return t.stack}}),arguments.length>0?(s.key=arguments[0],arguments[1]?.defaultValue&&(s[Cn]=Cn,s.defaultValue=arguments[1].defaultValue),s):function(r,o){return s.key=r,o?.make&&(s.make=o.make),s}},Ba={[_s]:_s,...Aa({label:"Service",evaluate(e){return je(mn(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key,stack:this.stack}},of(e){return e},context(e){return Tr(this,e)},use(e){return Nn(t=>e(mn(t.context,this)))},useSync(e){return Nn(t=>je(e(mn(t.context,this))))}},Cn="~effect/Context/Reference",Ir="~effect/Context",Xt=e=>{const t=Object.create(Va);return t.mapUnsafe=e,t.mutable=!1,t},Va={...Jn,[Ir]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[le](e){if(!Wa(e)||this.mapUnsafe.size!==e.mapUnsafe.size)return!1;for(const t of this.mapUnsafe.keys())if(!e.mapUnsafe.has(t)||!ie(this.mapUnsafe.get(t),e.mapUnsafe.get(t)))return!1;return!0},[ce](){return Vn(this.mapUnsafe.size)}},Wa=e=>G(e,Ir),_r=()=>Ka,Ka=Xt(new Map),Tr=(e,t)=>Xt(new Map([[e.key,t]])),qa=D(3,(e,t,n)=>za(e,s=>{s.set(t.key,n)})),Ha=D(2,(e,t)=>{if(!e.mapUnsafe.has(t.key)){if(Cn in t)return Ar(t);throw Ga(t)}return e.mapUnsafe.get(t.key)}),mn=Ha,Ja=(e,t)=>e.mapUnsafe.has(t.key)?e.mapUnsafe.get(t.key):Ar(t),xn="~effect/Context/defaultValue",Ar=e=>xn in e?e[xn]:e[xn]=e.defaultValue(),Ga=e=>{const t=new Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(e.stack){const n=e.stack.split(`
|
|
16
|
+
`);if(n.length>2){const s=n[2].match(/at (.*)/);s&&(t.message=t.message+` (defined at ${s[1]})`)}}if(t.stack){const n=t.stack.split(`
|
|
17
|
+
`);n.splice(1,3),t.stack=n.join(`
|
|
18
|
+
`)}return t},za=(e,t)=>{if(e.mutable)return t(e.mapUnsafe),e;const n=new Map(e.mapUnsafe);return t(n),Xt(n)},Ye=Ua,Or=Ye("effect/Scheduler",{defaultValue:()=>new Fr}),Pr="setImmediate"in globalThis?e=>{const t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{const t=setTimeout(e,0);return()=>clearTimeout(t)};class Ya{buckets=[];scheduleTask(t,n){const s=this.buckets,r=s.length;let o,a=0;for(;a<r&&!(s[a][0]>n);a++)o=s[a];o&&o[0]===n?o[1].push(t):a===r?s.push([n,[t]]):s.splice(a,0,[n,[t]])}drain(){const t=this.buckets;return this.buckets=[],t}}class Fr{executionMode;setImmediate;constructor(t="async",n=Pr){this.executionMode=t,this.setImmediate=n}shouldYield(t){return t.currentOpCount>=t.maxOpsBeforeYield}makeDispatcher(){return new Xa(this.setImmediate)}}class Xa{tasks=new Ya;running=void 0;setImmediate;constructor(t=Pr){this.setImmediate=t}scheduleTask(t,n){this.tasks.scheduleTask(t,n),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){const t=this.tasks.drain();for(let n=0;n<t.length;n++){const s=t[n][1];for(let r=0;r<s.length;r++)s[r]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}}const Za=Ye("effect/Scheduler/MaxOpsBeforeYield",{defaultValue:()=>2048}),Qa=Ye("effect/Scheduler/PreventSchedulerYield",{defaultValue:()=>!1}),ec="effect/Tracer/ParentSpan",tc="effect/Tracer",nc="effect/observability/Metric/FiberRuntimeMetricsKey",sc=Ye("effect/References/CurrentStackFrame",{defaultValue:ur}),rc=Ye("effect/References/CurrentLogLevel",{defaultValue:()=>"Info"}),ic=Ye("effect/References/MinimumLogLevel",{defaultValue:()=>"Info"}),oc="dev";class ac extends Gn{fiberId;constructor(t,n=Yt){super("Interrupt",n,"Interrupted"),this.fiberId=t}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[le](t){return vr(t)&&this.fiberId===t.fiberId&&this.annotations===t.annotations}[ce](){return me(V(`${this._tag}:${this.fiberId}`))(wn(this.annotations))}}const cc=e=>new Ge([new ac(e)]),lc=e=>e.reasons.some(vr),uc=D(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;const n=new Ge($a(e.reasons,t.reasons));return ie(e,n)?e:n}),dc=D(2,(e,t)=>{let n=!1;const s=e.reasons.map(r=>zn(r)?(n=!0,new yr(t(r.error))):r);return n?jn(s):e}),Ts=`~effect/Fiber/${oc}`,fc={_A:at,_E:at},hc={id:0},pc=()=>globalThis[ct];class Mr{constructor(t,n=!0){this[Ts]=fc,this.setContext(t),this.id=++hc.id,this.currentOpCount=0,this.currentLoopCount=0,this.interruptible=n,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this.runtimeMetrics?.recordFiberStart(this.context)}[Ts];id;interruptible;currentOpCount;currentLoopCount;_stack;_observers;_exit;_currentExit;_children;_interruptedCause;_yielded;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(t){return Ja(this.context,t)}addObserver(t){return this._exit?(t(this._exit),_o):(this._observers.push(t),()=>{const n=this._observers.indexOf(t);n>=0&&this._observers.splice(n,1)})}interruptUnsafe(t,n){if(this._exit)return;let s=cc(t);this.currentStackFrame&&(s=Sn(s,Tr(Yn,this.currentStackFrame))),n&&(s=Sn(s,n)),this._interruptedCause=this._interruptedCause?uc(this._interruptedCause,s):s,this.interruptible&&this.evaluate(gt(this._interruptedCause))}pollUnsafe(){return this._exit}evaluate(t){if(this._exit)return;if(this._yielded!==void 0){const s=this._yielded;this._yielded=void 0,s()}const n=this.runLoop(t);if(n!==Re){this._exit=n,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let s=0;s<this._observers.length;s++)this._observers[s](n);this._observers.length=0}}runLoop(t){const n=globalThis[ct];globalThis[ct]=this;let s=!1,r=t;this.currentOpCount=0;const o=++this.currentLoopCount;try{for(;;){if(this.currentOpCount++,!s&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){s=!0;const a=r;r=Ee(vc,()=>a)}if(r=this.currentTracerContext?this.currentTracerContext(r,this):r[K](this),o!==this.currentLoopCount)return Re;if(r===Re){const a=this._yielded;return pt in a?(this._yielded=void 0,a):Re}}}catch(a){return G(r,K)?this.runLoop(mt(a)):mt(`Fiber.runLoop: Not a valid effect: ${String(r)}`)}finally{globalThis[ct]=n}}getCont(t){for(;;){const n=this._stack.pop();if(!n)return;const s=n[We]&&n[We](this);if(s)return s[t]=s,s;if(n[t])return n}}yieldWith(t){return this._yielded=t,Re}children(){return this._children??=new Set}pipe(){return Ce(this,arguments)}setContext(t){this.context=t;const n=this.getRef(Or);n!==this.currentScheduler&&(this.currentScheduler=n,this._dispatcher=void 0),this.currentSpan=t.mapUnsafe.get(ec),this.currentLogLevel=this.getRef(rc),this.minimumLogLevel=this.getRef(ic),this.currentStackFrame=t.mapUnsafe.get(sc.key),this.maxOpsBeforeYield=this.getRef(Za),this.currentPreventYield=this.getRef(Qa),this.runtimeMetrics=t.mapUnsafe.get(nc);const s=t.mapUnsafe.get(tc);this.currentTracerContext=s?s.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}}const Lr=e=>{if(!e.currentStackFrame)return;const t=new Map;return t.set(Yn.key,e.currentStackFrame),Xt(t)},mc=e=>Dr(t=>{const n=e[Symbol.iterator](),s=[];let r;function o(){let a=n.next();for(;!a.done;){if(a.value._exit){s.push(a.value._exit),a=n.next();continue}r=a.value.addObserver(l=>{s.push(l),o()});return}t(ae(s))}return o(),bc(()=>r?.())}),xc=e=>Nn(t=>{const n=Lr(t);for(const s of e)s.interruptUnsafe(t.id,n);return $c(mc(e))}),ae=je,gt=Se,gc=Xn,bc=be({op:"Sync",[K](e){const t=this[L](),n=e.getCont(oe);return n?n[oe](t,e):e.yieldWith(je(t))}}),Mt=be({op:"Suspend",[K](e){return this[L]()}}),yc=be({op:"Yield",[K](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Ke)},this[L]??0),e.yieldWith(()=>{t=!0})}}),vc=yc(0),kc=e=>ae(W(e)),wc=ae(wt()),jc=e=>Mt(()=>gt(Hn(e))),Sc=e=>mt(e),It=ae(void 0),Nc=be({op:"Async",single:!1,[K](e){const t=Hn(()=>this[L][0].bind(e.currentScheduler));let n=!1,s=!1;const r=this[L][1]?new AbortController:void 0,o=t(a=>{n||(n=!0,s?e.evaluate(a):s=a)},r?.signal);return s!==!1?s:(s=!0,e._yielded=()=>{n=!0},r===void 0&&o===void 0||e._stack.push(Cc(()=>(n=!0,r?.abort(),o??Ke))),Re)}}),Cc=be({op:"AsyncFinalizer",[We](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Uc))},[ve](e,t){return lc(e)?Ee(this[L](),()=>gt(e)):gt(e)}}),Dr=e=>Nc(e,e.length>=2),Ec=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),Rc=(e,...t)=>Ec(e.length,t.length===0?function(){return As(()=>e.apply(this,arguments))}:function(){let n=As(()=>e.apply(this,arguments));for(const s of t)n=s(n);return n}),As=e=>{try{const t=e();let n;for(;;){const s=t.next(n);if(s.done)return ae(s.value);const r=s.value;if(r&&r._tag==="Success"){n=r.value;continue}else{if(r&&r._tag==="Failure")return s.value;{let o=!0;return Mt(()=>o?(o=!1,Ee(s.value,a=>Os(t,a))):Mt(()=>Os(e())))}}}}catch(t){return Sc(t)}},Os=be({op:"Iterator",single:!1,[oe](e,t){const n=this[L][0];for(;;){const s=n.next(e);if(s.done)return ae(s.value);if(Ne(s.value)){if(s.value._tag==="Failure")return s.value}else return t._stack.push(this),s.value;e=s.value.value}},[K](e){return this[oe](this[L][1],e)}}),$c=e=>Ee(e,t=>Ke),Ee=D(2,(e,t)=>{const n=Object.create(Ic);return n[L]=e,n[oe]=t.length!==1?s=>t(s):t,n}),Ic=ze({op:"OnSuccess",[K](e){return e._stack.push(this),this[L]}}),Ne=e=>pt in e,_c=D(2,(e,t)=>Ne(e)?e._tag==="Success"?t(e.value):e:Ee(e,t)),Tc=D(2,(e,t)=>Ee(e,n=>ae(Hn(()=>t(n))))),Ac=D(2,(e,t)=>Ne(e)?Pc(e,t):Tc(e,t)),Oc=e=>e._tag==="Success",Ke=je(void 0),Pc=D(2,(e,t)=>e._tag==="Success"?je(t(e.value)):e),Fc=D(2,(e,t)=>{const n=Object.create(Mc);return n[L]=e,n[ve]=t.length!==1?s=>t(s):t,n}),Mc=ze({op:"OnFailure",[K](e){return e._stack.push(this),this[L]}}),Ur=e=>Ne(e)?je(e):Lc(e),Lc=be({op:"Exit",[K](e){return e._stack.push(this),this[L]},[oe](e,t,n){return ae(n??je(e))},[ve](e,t,n){return ae(n??Se(e))}}),Dc=be({op:"SetInterruptible",[We](e){if(e.interruptible=this[L],e._interruptedCause&&e.interruptible)return()=>gt(e._interruptedCause)}}),Uc=Dc(!0),Bc=e=>{const t=e.onItem,n=e.step;return(s,r,o)=>{let a=o?.start??0;const l=o?.end??r.length,c=o?.concurrency??1;let u=!1,p,f,h,x=!1,g,y;const v=()=>{let b=!1;for(;!g&&a<l;a++){const w=r[a],j=y??t(s,w,a);if(Ne(j)){if(g=n(s,w,j,a),g)break}else{if(c===1)return Ee(Ur(j),C=>(g=n(s,w,C,a),a++,g??v()??It));if(p){y=void 0;const C=Vc(p,j,!0,!0,"inherit");if(C._exit){if(g=n(s,w,C._exit,a),g)break;continue}f?f.add(C):f=new Set([C]);const E=a;if(C.addObserver(O=>{if(f.delete(C),g){if(!x&&O._tag==="Failure")for(const F of O.cause.reasons)F._tag!=="Interrupt"&&(g._tag==="Failure"?g.cause.reasons.push(F):g=Se(jn([F])))}else{const F=n(s,w,O,E);F&&(g=F._tag==="Failure"?Se(jn(F.cause.reasons.slice())):F,v())}if(b){const F=v();F&&h(F)}else u&&f.size===0&&h(g??It)}),f.size<c)continue;b=!0,a++;return}else return Dr(C=>{p=pc(),y=j,h=C;const E=v();return E?C(E):Mt(()=>(g=Ke,x=!0,f?xc(f):It))})}}if(u=!0,g){if(f&&f.size>0){const w=Lr(p);f.forEach(j=>j.interruptUnsafe(p.id,w));return}if(h||g._tag==="Failure")return g}else if(h)if(f)f.size===0&&h(It);else return Ke};return v()}},Zt=()=>Bc,Vc=(e,t,n=!1,s=!1,r=!1)=>{const o=r==="inherit"?e.interruptible:!r,a=new Mr(e.context,o);return n?a.evaluate(t):e.currentDispatcher.scheduleTask(()=>a.evaluate(t),0),!s&&!a._exit&&(e.children().add(a),a.addObserver(()=>e._children.delete(a))),a},Br=e=>(t,n)=>{const s=new Mr(n?.scheduler?qa(e,Or,n.scheduler):e,n?.uninterruptible!==!0);if(s.evaluate(t),s._exit)return s;if(n?.signal)if(n.signal.aborted)s.interruptUnsafe();else{const r=()=>s.interruptUnsafe();n.signal.addEventListener("abort",r,{once:!0}),s.addObserver(()=>n.signal.removeEventListener("abort",r))}return n?.onFiberStart&&n.onFiberStart(s),s},Wc=e=>{const t=Br(e);return(n,s)=>{const r=t(n,s);return new Promise(o=>{r.addObserver(a=>o(a))})}},Kc=Wc(_r()),qc=e=>{const t=Br(e);return n=>{if(Ne(n))return n;const s=new Fr("sync"),r=t(n,{scheduler:s});return r.currentDispatcher?.flush(),r._exit??mt(new Jc(r))}},Hc=qc(_r()),Ps="~effect/Cause/AsyncFiberError";class Jc extends wr("AsyncFiberError"){[Ps]=Ps;constructor(t){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:t})}}const Vr=zn,Qn=dc,Gc=Se,Qt=Xn,zc=Ke,es=Oc,Yc=class extends Jt{constructor(t){super(),t&&Object.assign(this,t)}},Xc=wr,re=ae,ts=wc,Zc=kc,X=gc,Wr=jc,Qc=Ee,Fs=Ur,Kr=Fc,el=Kc,qr=Hc,Hr=Ac,$e=_c,En=Rc;function st(e,t,n){return t==="__proto__"?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n,e}function tl(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function nl(e){return t=>tl(t)?.[e]}const sl=nl("identifier"),ns=Ae(e=>{const t=sl(e);return typeof t=="string"?t:e.getExpected(ns)}),Rn="~effect/SchemaIssue/Issue";function Jr(e){return G(e,Rn)}let ue=class{[Rn]=Rn;toString(){return fl(this)}},rl=class extends ue{_tag="Filter";actual;filter;issue;constructor(t,n,s){super(),this.actual=t,this.filter=n,this.issue=s}};class il extends ue{_tag="Encoding";ast;actual;issue;constructor(t,n,s){super(),this.ast=t,this.actual=n,this.issue=s}}class Te extends ue{_tag="Pointer";path;issue;constructor(t,n){super(),this.path=t,this.issue=n}}class Gr extends ue{_tag="MissingKey";annotations;constructor(t){super(),this.annotations=t}}class zr extends ue{_tag="UnexpectedKey";ast;actual;constructor(t,n){super(),this.ast=t,this.actual=n}}class Q extends ue{_tag="Composite";ast;actual;issues;constructor(t,n,s){super(),this.ast=t,this.actual=n,this.issues=s}}class jt extends ue{_tag="InvalidType";ast;actual;constructor(t,n){super(),this.ast=t,this.actual=n}}class Lt extends ue{_tag="InvalidValue";actual;annotations;constructor(t,n){super(),this.actual=t,this.annotations=n}}class Ms extends ue{_tag="AnyOf";ast;actual;issues;constructor(t,n,s){super(),this.ast=t,this.actual=n,this.issues=s}}class ol extends ue{_tag="OneOf";ast;actual;successes;constructor(t,n,s){super(),this.ast=t,this.actual=n,this.successes=s}}function $n(e,t){if(Jr(t))return t;if(typeof t=="string")return new Lt(W(e),{message:t});const n=typeof t.issue=="string"?new Lt(W(e),{message:t.issue}):t.issue;return new Te(t.path,n)}function al(e,t){if(t!==void 0)return typeof t=="boolean"?t?void 0:new Lt(W(e)):$n(e,t)}function cl(e,t,n){return Array.isArray(n)?Ft(n)?n.length===1?$n(e,n[0]):new Q(t,W(e),_a(n,s=>$n(e,s))):void 0:al(e,n)}const ll=e=>{const t=bt(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return In(ns(e.ast),Ls(e.actual));case"InvalidValue":return`Invalid data ${Ls(e.actual)}`;case"MissingKey":return"Missing key";case"UnexpectedKey":return`Unexpected key with value ${J(e.actual)}`;case"Forbidden":return"Forbidden operation";case"OneOf":return`Expected exactly one member to match the input ${J(e.actual)}`}},ul=e=>bt(e.issue)??bt(e);function In(e,t){return`Expected ${e}, got ${t}`}function Me(e,t,n,s){switch(e._tag){case"Filter":{const r=s(e);if(r!==void 0)return[{path:t,message:r}];switch(e.issue._tag){case"InvalidValue":return[{path:t,message:In(Yr(e.filter),J(e.actual))}];default:return Me(e.issue,t,n,s)}}case"Encoding":return Me(e.issue,t,n,s);case"Pointer":return Me(e.issue,[...t,...e.path],n,s);case"Composite":return e.issues.flatMap(r=>Me(r,t,n,s));case"AnyOf":{const r=bt(e);if(e.issues.length===0){if(r!==void 0)return[{path:t,message:r}];const o=In(ns(e.ast),J(e.actual));return[{path:t,message:o}]}return e.issues.flatMap(o=>Me(o,t,n,s))}default:return[{path:t,message:n(e)}]}}function Yr(e){const t=e.annotations?.expected;if(typeof t=="string")return t;switch(e._tag){case"Filter":return"<filter>";case"FilterGroup":return e.checks.map(n=>Yr(n)).join(" & ")}}function dl(){return e=>Me(e,[],ll,ul).map(hl).join(`
|
|
19
|
+
`)}const fl=dl();function hl(e){let t=e.message;if(e.path&&e.path.length>0){const n=ra(e.path);t+=`
|
|
20
|
+
at ${n}`}return t}function bt(e){switch(e._tag){case"InvalidType":case"OneOf":case"Composite":case"AnyOf":return nt(e.ast.annotations);case"InvalidValue":case"Forbidden":return nt(e.annotations);case"MissingKey":return nt(e.annotations,"messageMissingKey");case"UnexpectedKey":return nt(e.ast.annotations,"messageUnexpectedKey");case"Filter":return nt(e.filter.annotations);case"Encoding":return bt(e.issue)}}function nt(e,t="message"){const n=e?.[t];if(typeof n=="string")return n}function Ls(e){return Zn(e)?"no value provided":J(e.value)}function ss(e){let t;for(const n of e.reasons){if(!Vr(n)||!Jr(n.error))return;t??=n.error}return t}function Xr(e,t){const n=ss(e);if(n===void 0)throw new Error(t,{cause:e});return n}class yt extends Jt{run;constructor(t){super(),this.run=t}map(t){return new yt((n,s)=>this.run(n,s).pipe(Hr(Rr(t))))}compose(t){return Ds(this)?t:Ds(t)?this:new yt((n,s)=>this.run(n,s).pipe($e(r=>t.run(r,s))))}}const rs=new yt(re);function Ds(e){return e.run===rs.run}function _n(){return rs}function pl(){return rs}function xe(e){return ml(Rr(e))}function ml(e){return new yt(t=>re(e(t)))}function xl(){return xe(globalThis.String)}function Zr(){return xe(globalThis.Number)}const Tn="~effect/SchemaTransformation/Transformation";class ge{[Tn]=Tn;_tag="Transformation";decode;encode;constructor(t,n){this.decode=t,this.encode=n}flip(){return new ge(this.encode,this.decode)}compose(t){return new ge(this.decode.compose(t.decode),t.encode.compose(this.encode))}}function gl(e){return G(e,Tn)}const bl=e=>gl(e)?e:new ge(e.decode,e.encode),yl=new ge(_n(),_n());function vl(){return yl}const Qr=new ge(Zr(),xl());function Xe(e){return t=>t._tag===e}const kl=Xe("Declaration"),wl=Xe("Never"),Dt=Xe("Literal"),jl=Xe("UniqueSymbol"),Sl=Xe("Arrays"),Nl=Xe("Objects");class se{to;transformation;constructor(t,n){this.to=t,this.transformation=n}}const ei={};class Ut{isOptional;isMutable;defaultValue;annotations;constructor(t,n,s=void 0,r=void 0){this.isOptional=t,this.isMutable=n,this.defaultValue=s,this.annotations=r}}const Us="~effect/Schema";class de{[Us]=Us;annotations;checks;encoding;context;constructor(t=void 0,n=void 0,s=void 0,r=void 0){this.annotations=t,this.checks=n,this.encoding=s,this.context=r}toString(){return`<${this._tag}>`}}class is extends de{_tag="Declaration";typeParameters;run;encodingChecks;constructor(t,n,s,r,o,a,l){super(s,r,o,a),this.typeParameters=t,this.run=n,this.encodingChecks=l}getParser(){const t=this.run(this.typeParameters);return(n,s)=>Zn(n)?ts:Hr(t(n.value,this,s),W)}_rebuild(t,n,s){const r=qe(this.typeParameters,t);return r===this.typeParameters&&n===this.checks&&s===this.encodingChecks?this:new is(r,this.run,this.annotations,n,void 0,this.context,s)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}getExpected(){const t=this.annotations?.expected;return typeof t=="string"?t:"<Declaration>"}}let Cl=class extends de{_tag="Null";getParser(){return gi(this,null)}getExpected(){return"null"}};const El=new Cl;let Rl=class extends de{_tag="Unknown";getParser(){return Ct(this,Fo)}getExpected(){return"unknown"}};const $l=new Rl;let lt=class extends de{_tag="Literal";literal;constructor(t,n,s,r,o){if(super(n,s,r,o),typeof t=="number"&&!globalThis.Number.isFinite(t))throw new Error(`A numeric literal must be finite, got ${J(t)}`);this.literal=t}getParser(){return gi(this,this.literal)}matchPart(t,n){return t===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal=="bigint"?Bs(this):this}toCodecStringTree(){return typeof this.literal=="string"?this:Bs(this)}getExpected(){return typeof this.literal=="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Bs(e){const t=globalThis.String(e.literal);return ee(e,[new se(new lt(t),new ge(xe(()=>e.literal),xe(()=>t)))])}let Il=class extends de{_tag="String";getParser(){return Ct(this,dr)}matchPart(t,n){return bi(this,t,n)}getExpected(){return"string"}};const ti=new Il;let _l=class extends de{_tag="Number";getParser(){return Ct(this,fr)}matchKey(t,n){return this._match(eu,t,n)}matchPart(t,n){return this._match(On,t,n)}_match(t,n,s){return t.test(n)?bi(this,globalThis.Number(n),s):void 0}toCodecJson(){return this.checks&&(rt(this.checks,"isFinite")||rt(this.checks,"isInt"))?this:ee(this,[Wl])}toCodecStringTree(){return this.checks&&(rt(this.checks,"isFinite")||rt(this.checks,"isInt"))?ee(this,[nu]):ee(this,[su])}getExpected(){return"number"}};function rt(e,t){return e.some(n=>{switch(n._tag){case"Filter":return n.annotations?.meta?._tag===t;case"FilterGroup":return rt(n.checks,t)}})}const ni=new _l;let Tl=class extends de{_tag="Boolean";getParser(){return Ct(this,To)}getExpected(){return"boolean"}};const Al=new Tl;class en extends de{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(t,n,s,r,o,a,l,c){super(r,o,a,l),this.isMutable=t,this.elements=n,this.rest=s,this.encodingChecks=c;const u=n.findIndex(ke);if(u!==-1&&(n.slice(u+1).some(p=>!ke(p))||s.length>1))throw new Error("A required element cannot follow an optional element. ts(1257)");if(s.length>1&&s.slice(1).some(ke))throw new Error("An optional element cannot follow a rest element. ts(1266)")}getParser(t){const n=this,s=n.elements.map(p=>({ast:p,parser:t(p)})),r=n.rest.map(p=>({ast:p,parser:t(p)})),o=s.length,[a,...l]=r,c=l.length;function u(p,f){return f<o?s[f]:f>=p?l[f-p]:a}return En(function*(p,f){if(p._tag==="None")return p;const h=p.value;if(!Array.isArray(h))return yield*X(new jt(n,p));const x=h.length,g={ast:n,getParser:u,oinput:p,len:x,tailThreshold:Pl(x,o,c),output:new globalThis.Array(x),issues:void 0,options:f},y=os(f?.concurrency),v=Ol(g,h,{concurrency:y?.concurrency,end:n.rest.length===0?o:Math.max(x,o+c)});if(v&&(yield*v),n.rest.length===0&&x>o)for(let b=o;b<=x-1;b++){const w=new Te([b],new zr(n,h[b]));if(f.errors==="all")g.issues?g.issues.push(w):g.issues=[w];else return yield*X(new Q(n,p,[w]))}return g.issues?yield*X(new Q(n,p,g.issues)):W(g.output)})}_rebuild(t,n,s){const r=qe(this.elements,t),o=qe(this.rest,t);return r===this.elements&&o===this.rest&&n===this.checks&&s===this.encodingChecks?this:new en(this.isMutable,r,o,this.annotations,n,void 0,this.context,s)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}getExpected(){return"array"}}const Ol=Zt()({onItem(e,t,n){const s=n<e.len?W(t):wt();return e.getParser(e.tailThreshold,n).parser(s,e.options)},step(e,t,n,s){if(n._tag==="Failure")return Bt(e,e.ast,s,n);if(n.value._tag==="Some")e.output[s]=n.value.value;else{const r=e.getParser(e.tailThreshold,s);if(ke(r.ast))return;const o=new Te([s],new Gr(r.ast.context?.annotations));if(e.options.errors==="all")e.issues?e.issues.push(o):e.issues=[o];else return Qt(new Q(e.ast,e.oinput,[o]))}}});function Pl(e,t,n){return Math.max(t,e-n)}const os=e=>(e=e==="unbounded"?1/0:e??1,e>1?{concurrency:e}:void 0),Bt=(e,t,n,s)=>{if(s.cause.reasons.length===0)return s;const r=ss(s.cause);if(r===void 0)return Gc(Qn(s.cause,a=>new Q(t,e.oinput,[new Te([n],a)])));const o=new Te([n],r);if(e.options.errors==="all")e.issues?e.issues.push(o):e.issues=[o];else return Qt(new Q(t,e.oinput,[o]))},si="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function Fl(e,t,n=ei){let s,r;function o(a){switch(a._tag){case"String":case"TemplateLiteral":return(s??=Object.keys(e)).filter(l=>a.matchPart(l,n)!==void 0);case"Number":return(s??=Object.keys(e)).filter(l=>a.matchKey(l,n)!==void 0);case"Symbol":return(r??=Object.getOwnPropertySymbols(e)).filter(l=>a.matchKey(l,n)!==void 0);case"Union":return[...new Set(a.types.flatMap(o))];default:return[]}}return o(ds(Nt(t)))}class as{name;type;constructor(t,n){this.name=t,this.type=n}}function An(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(An);default:return!1}}function Ml(e){return An(e)&&An(Nt(e))}class ri{parameter;type;merge;constructor(t,n,s){if(!Ml(t))throw new Error(`Invalid index signature parameter ${t._tag}`);if(this.parameter=t,this.type=n,this.merge=s,ke(n)&&!xi(n))throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}}class tn extends de{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(t,n,s,r,o,a,l){super(s,r,o,a),this.propertySignatures=t,this.indexSignatures=n,this.encodingChecks=l;const c=t.map(u=>u.name).filter((u,p,f)=>f.indexOf(u)!==p);if(c.length>0)throw new Error(`Duplicate identifiers: ${JSON.stringify(c)}. ts(2300)`)}getParser(t){const n=this,s=[],r=new Set,o=[];for(const c of n.propertySignatures)s.push(c.name),r.add(c.name),o.push({ps:c,parser:t(c.type),name:c.name,type:c.type});const a=n.indexSignatures.length;if(n.propertySignatures.length===0&&n.indexSignatures.length===0)return Ct(n,Po);const l=a>0?Zt()({onItem:En(function*(c,[u,p]){const h=t(ds(p.parameter))(W(u),c.options),x=Ne(h)?h:yield*Fs(h);if(x._tag==="Failure"){const w=Bt(c,n,u,x);w&&(yield*w);return}const g=W(c.input[u]),v=t(p.type)(g,c.options),b=Ne(v)?v:yield*Fs(v);if(b._tag==="Failure"){const w=Bt(c,n,u,b);w&&(yield*w);return}else if(x.value._tag==="Some"&&b.value._tag==="Some"){const w=x.value.value;if(r.has(u)||r.has(w))return;const j=b.value.value;if(p.merge&&p.merge.decode&&Object.hasOwn(c.out,w)){const[C,E]=p.merge.decode.combine([w,c.out[w]],[w,j]);st(c.out,C,E)}else st(c.out,w,j)}}),step:(c,u,p)=>p._tag==="Failure"?p:void 0}):void 0;return En(function*(c,u){if(c._tag==="None")return c;const p=c.value;if(!(typeof p=="object"&&p!==null&&!Array.isArray(p)))return yield*X(new jt(n,c));const f={},h={ast:n,oinput:c,input:p,out:f,issues:void 0,options:u},x=u.errors==="all",g=u.onExcessProperty==="error",y=u.onExcessProperty==="preserve";let v;if(n.indexSignatures.length===0&&(g||y)){v=Reflect.ownKeys(p);for(let j=0;j<v.length;j++){const C=v[j];if(!r.has(C))if(g){const E=new Te([C],new zr(n,p[C]));if(x){h.issues?h.issues.push(E):h.issues=[E];continue}else return yield*X(new Q(n,c,[E]))}else st(f,C,p[C])}}const b=os(u?.concurrency),w=Ll(h,o,b);if(w&&(yield*w),l){const j=Ia();for(let E=0;E<a;E++){const O=n.indexSignatures[E],F=Fl(p,O.parameter,u);for(let _=0;_<F.length;_++){const k=F[_];j.push([k,O])}}const C=l(h,j,b);C&&(yield*C)}if(h.issues)return yield*X(new Q(n,c,h.issues));if(u.propertyOrder==="original"){const j=(v??Reflect.ownKeys(p)).concat(s),C={};for(const E of j)Object.hasOwn(f,E)&&st(C,E,f[E]);return W(C)}return W(f)})}_rebuild(t,n,s,r,o){const a=qe(this.propertySignatures,c=>{const u=t(c.type);return u===c.type?c:new as(c.name,u)}),l=qe(this.indexSignatures,c=>{const u=n(c.parameter),p=t(c.type),f=s?c.merge?.flip():c.merge;return u===c.parameter&&p===c.type&&f===c.merge?c:new ri(u,p,f)});return a===this.propertySignatures&&l===this.indexSignatures&&r===this.checks&&o===this.encodingChecks?this:new tn(a,l,this.annotations,r,void 0,this.context,o)}flip(t){return this._rebuild(t,t,!0,this.encodingChecks,this.checks)}recur(t,n=t){return this._rebuild(t,n,!1,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?"object | array":"object"}}const Ll=Zt()({onItem(e,t){const n=Object.hasOwn(e.input,t.name)?W(e.input[t.name]):wt();return t.parser(n,e.options)},step(e,t,n){if(n._tag==="Failure")return Bt(e,e.ast,t.name,n);if(n.value._tag==="Some")st(e.out,t.name,n.value.value);else if(!ke(t.type)){const s=new Te([t.name],new Gr(t.type.context?.annotations));if(e.options.errors==="all"){e.issues?e.issues.push(s):e.issues=[s];return}else return Qt(new Q(e.ast,e.oinput,[s]))}}});function ii(e,t){return e?t?[...e,...t]:e:t}function cs(e,t,n){return new tn(Reflect.ownKeys(e).map(s=>new as(s,e[s].ast)),[],n,t)}function Dl(e){return e.ast}function oi(e,t=void 0){return new en(!1,e.map(n=>n.ast),[],void 0,t)}function ls(e,t,n){return new nn(e.map(Dl),t,void 0,n)}function ai(e){switch(e._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return e.propertySignatures.length||e.indexSignatures.length?["object"]:["object","array"];case"Enum":return Array.from(new Set(e.enums.map(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(ai)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function us(e){switch(e._tag){default:return[];case"Declaration":{const t=e.annotations?.["~sentinels"];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(t=>{const n=t.type;if(!ke(n)){if(Dt(n))return[{key:t.name,literal:n.literal}];if(jl(n))return[{key:t.name,literal:n.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,n)=>Dt(t)&&!ke(t)?[{key:n,literal:t.literal}]:[]);case"Suspend":return us(e.thunk())}}const Vs=new WeakMap;function Ul(e){let t=Vs.get(e);if(t)return t;t={};for(const n of e){const s=Nt(n);if(wl(s))continue;const r=ai(s),o=us(s);t.byType??={};for(const a of r)(t.byType[a]??=[]).push(n);if(o.length>0){t.bySentinel??=new Map;for(const{key:a,literal:l}of o){let c=t.bySentinel.get(a);c||t.bySentinel.set(a,c=new Map);let u=c.get(l);u||c.set(l,u=[]),u.push(n)}}else{t.otherwise??={};for(const a of r)(t.otherwise[a]??=[]).push(n)}}return Vs.set(e,t),t}function Ws(e){return t=>{const n=Nt(t);return n._tag==="Literal"?n.literal===e:n._tag==="UniqueSymbol"?n.symbol===e:!0}}function Bl(e,t){const n=Ul(t),s=e===null?"null":Array.isArray(e)?"array":typeof e;if(n.bySentinel){const r=n.otherwise?.[s]??[];if(s==="object"||s==="array"){for(const[o,a]of n.bySentinel)if(Object.hasOwn(e,o)){const l=a.get(e[o]);if(l)return[...l,...r].filter(Ws(e))}}return r}return(n.byType?.[s]??[]).filter(Ws(e))}let nn=class ci extends de{_tag="Union";types;mode;encodingChecks;constructor(t,n,s,r,o,a,l){super(s,r,o,a),this.types=t,this.mode=n,this.encodingChecks=l}getParser(t){const n=this;return(s,r)=>{if(s._tag==="None")return re(s);const o=s.value,a=Bl(o,n.types),l={ast:n,recur:t,oinput:s,input:o,out:void 0,successes:[],issues:void 0,options:r},c=os(r?.concurrency),u=Vl(l,a,c);return u?Qc(u,p=>l.out?re(l.out):X(new Ms(n,o,l.issues??[]))):l.out?re(l.out):X(new Ms(n,o,l.issues??[]))}}_rebuild(t,n,s){const r=qe(this.types,t);return r===this.types&&n===this.checks&&s===this.encodingChecks?this:new ci(r,this.mode,this.annotations,n,void 0,this.context,s)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}matchPart(t,n){for(const s of this.types){const r=s.matchPart(t,n);if(r!==void 0)return r}}getExpected(t){const n=this.annotations?.expected;if(typeof n=="string")return n;if(this.types.length===0)return"never";const s=this.types.map(r=>{const o=Nt(r);switch(o._tag){case"Arrays":{const a=o.elements.filter(Dt);if(a.length>0)return`${Ks(o.isMutable)}[ ${a.map(l=>t(l)+qs(l.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{const a=o.propertySignatures.filter(l=>Dt(l.type));if(a.length>0)return`{ ${a.map(l=>`${Ks(l.type.context?.isMutable)}${Pt(l.name)}${qs(l.type.context?.isOptional)}: ${t(l.type)}`).join(", ")}, ... }`;break}}return t(o)});return Array.from(new Set(s)).join(" | ")}};const Vl=Zt()({onItem(e,t){return e.recur(t)(e.oinput,e.options)},step(e,t,n){if(n._tag==="Failure"){const s=ss(n.cause);if(s===void 0)return n;e.issues?e.issues.push(s):e.issues=[s]}else{if(e.out&&e.ast.mode==="oneOf")return e.successes.push(t),Qt(new ol(e.ast,e.input,e.successes));if(e.out=n.value,e.successes.push(t),e.ast.mode==="anyOf")return zc}}}),li=new nn([new lt("Infinity"),new lt("-Infinity"),new lt("NaN")],"anyOf"),Wl=new se(new nn([ni,li],"anyOf"),new ge(Zr(),xe(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Ks(e){return e?"":"readonly "}function qs(e){return e?"?":""}class Vt extends Jt{_tag="Filter";run;annotations;aborted;constructor(t,n=void 0,s=!1){super(),this.run=t,this.annotations=n,this.aborted=s}annotate(t){return new Vt(this.run,{...this.annotations,...t},this.aborted)}abort(){return new Vt(this.run,this.annotations,!0)}and(t,n){return new Wt([this,t],n)}}class Wt extends Jt{_tag="FilterGroup";checks;annotations;constructor(t,n=void 0){super(),this.checks=t,this.annotations=n}annotate(t){return new Wt(this.checks,{...this.annotations,...t})}and(t,n){return new Wt([this,t],n)}}function Kl(e,t,n=!1){return new Vt((s,r,o)=>cl(s,r,e(s,r,o)),t,n)}function ql(e,t){const n=e.source;return Kl(s=>e.test(s),{expected:`a string matching the RegExp ${n}`,meta:{_tag:"isPattern",regExp:e},arbitrary:{constraint:{patterns:[e.source]}},...t})}function St(e,t){const n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}function ee(e,t){return e.encoding===t?e:St(e,n=>{n.encoding.value=t})}function ui(e,t){return e.context===t?e:St(e,n=>{n.context.value=t})}function di(e,t){if(e.checks){const n=e.checks[e.checks.length-1];return fi(e,$r(e.checks.slice(0,-1),n.annotate(t)))}return St(e,n=>{n.annotations.value={...n.annotations.value,...t}})}function fi(e,t){if(e._tag==="Suspend"&&t!==void 0)throw new Error("Cannot add checks to Suspend");return e.checks===t?e:St(e,n=>{n.checks.value=t})}function Kt(e,t){return fi(e,ii(e.checks,t))}function hi(e,t){const n=e,s=n[n.length-1],r=t(s.to);return r!==s.to?$r(e.slice(0,e.length-1),new se(r,s.transformation)):e}function Hl(e){return t=>t.encoding?ee(t,hi(t.encoding,e)):t}function Jl(e){function t(n){return n.encoding?ee(n,hi(n.encoding,t)):e(n)}return Ae(t)}function Gl(e,t,n){const s=new se(e,t);return ee(n,n.encoding?[...n.encoding,s]:[s])}function qe(e,t){let n=!1;const s=new Array(e.length);for(let r=0;r<e.length;r++){const o=e[r],a=t(o);a!==o&&(n=!0),s[r]=a}return n?s:e}function pi(e,t){const n=e.context?new Ut(e.context.isOptional,e.context.isMutable,e.context.defaultValue,{...e.context.annotations,...t}):new Ut(!1,!1,void 0,t);return ui(e,n)}const zl=Hl(mi);function mi(e){const t=e.context?e.context.isOptional===!1?new Ut(!0,e.context.isMutable,e.context.defaultValue,e.context.annotations):e.context:new Ut(!0,!1);return zl(ui(e,t))}function Yl(e,t,n){return Gl(e,n,t)}function Xl(e){const t=[],n=[];function s(r){switch(r._tag){case"Literal":Oo(r.literal)&&t.push(r.literal);return;case"UniqueSymbol":t.push(r.symbol);return;case"Never":return;case"Union":for(let o=0;o<r.types.length;o++)s(r.types[o]);return;default:n.push(r)}}return s(e),{literals:t,parameters:n}}function Zl(e,t,n){const{literals:s,parameters:r}=Xl(e);return new tn(s.map(o=>new as(o,t)),r.map(o=>new ri(o,t,n)))}function ke(e){return e.context?.isOptional??!1}const qt=Ae(e=>{if(e.encoding)return qt(ee(e,void 0));const t=e,n=t.recur?.(qt)??t,s=n.encodingChecks;return s?St(n,r=>{r.encodingChecks.value=void 0,n===e&&(r.checks.value=ii(n.checks,s))}):n}),Nt=Ae(e=>qt(Be(e)));function Ql(e,t){const n=t,s=n.length,r=n[s-1],o=[new se(Be(ee(e,void 0)),n[0].transformation.flip())];for(let l=1;l<s;l++)o.unshift(new se(Be(n[l-1].to),n[l].transformation.flip()));const a=Be(r.to);return a.encoding?ee(a,[...a.encoding,...o]):ee(a,o)}const Be=Ae(e=>{if(e.encoding)return Ql(e,e.encoding);const t=e;return t.flip?.(Be)??t.recur?.(Be)??t});function xi(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(xi);default:return!1}}function gi(e,t){const n=Zc(t);return s=>s._tag==="None"?ts:s.value===t?n:X(new jt(e,s))}function Ct(e,t){return n=>n._tag==="None"?ts:t(n.value)?re(n):X(new jt(e,n))}function bi(e,t,n){if(n?.disableChecks||e.checks===void 0)return t;const s=[];return ut(e.checks,t,s,e,n),s.length===0?t:void 0}const ds=Jl(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(ds)}}),On=new globalThis.RegExp(`^${si}$`),eu=new globalThis.RegExp(`(?:${si}|Infinity|-Infinity|NaN)`);function tu(e){return ql(On,{expected:"a string representing a finite number",meta:{_tag:"isStringFinite",regExp:On},...e})}const yi=Kt(ti,[tu()]),nu=new se(yi,Qr),su=new se(new nn([yi,li],"anyOf"),Qr);function ut(e,t,n,s,r){for(let o=0;o<e.length;o++){const a=e[o];if(a._tag==="FilterGroup")ut(a.checks,t,n,s,r);else{const l=a.run(t,s,r);if(l&&(n.push(new rl(t,a,l)),a.aborted||r?.errors!=="all"))return}}}const vi="~effect/Schema/Class",ru="~structural",fs=e=>e,it=Ae(e=>{switch(e._tag){case"Declaration":{const t=e.annotations?.[vi];if(Bn(t)){const n=t(e.typeParameters),s=it(n.to);return ee(e,s===n.to?[n]:[new se(s,n.transformation)])}return e}case"Objects":case"Arrays":return e.recur(t=>{const n=t.context?.defaultValue;return n?ee(it(t),n):it(t)});case"Suspend":return e.recur(it);default:return e}});function hs(e){const t=it(qt(e.ast)),n=wi(t);return(s,r)=>n(s,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function ki(e){const t=hs(e);return(n,s)=>{const r=qr(t(n,s));return es(r)?W(r.value):(Xr(r.cause,"Option adapter can only return none for schema issues"),wt())}}function iu(e){const t=hs(e);return(n,s)=>{const r=qr(t(n,s));if(es(r))return r.value;const o=Xr(r.cause,"Constructor adapter can only throw schema issues");throw new Error(o.toString(),{cause:o})}}function ou(e,t){const n=wi(e.ast);return t===void 0?n:(s,r)=>n(s,au(t,r))}const au=(e,t)=>t===void 0?e:{...e,...t};function wi(e){const t=At(e);return(n,s)=>$e(t(W(n),s??ei),r=>r._tag==="None"?X(new Lt(r)):re(r.value))}function Hs(e,t){return Kr(e,n=>Wr(()=>Qn(n,t)))}const At=Ae(e=>{let t;const n=e.checks,s=e.encoding,r=s,o=r?.length??0,a=e.encodingChecks,l=(n?n[n.length-1].annotations:e.annotations)?.parseOptions;if(!e.context&&!s&&!n&&!a)return(p,f)=>(t??=e.getParser(At),l&&(f={...f,...l}),t(p,f));const c=Sl(e)||Nl(e)||kl(e)&&e.typeParameters.length>0,u=n&&c?n.filter(p=>p.annotations?.[ru]):void 0;return(p,f)=>{l&&(f={...f,...l});let h;if(r){for(let y=o-1;y>=0;y--){const v=r[y],b=v.to,w=At(b);if(h=h?$e(h,j=>w(j,f)):w(p,f),v.transformation._tag==="Transformation"){const j=v.transformation.decode;h=$e(h,C=>j.run(C,f))}else h=v.transformation.decode(h,f)}h=Hs(h,y=>new il(e,p,y))}t??=e.getParser(At);const x=y=>{let v=t(y,f);return a&&!f?.disableChecks&&(v=$e(v,b=>{if($t(y)&&$t(b)){const w=[];if(ut(a,y.value,w,e,f),pn(w))return X(new Q(e,y,w))}return re(b)})),n&&!f?.disableChecks&&(f?.errors==="all"&&u&&u.length>0&&$t(y)&&(v=Hs(v,b=>{const w=[];return ut(u,y.value,w,e,f),pn(w)?b._tag==="Composite"&&b.ast===e?new Q(e,b.actual,[...b.issues,...w]):new Q(e,y,[b,...w]):b})),v=$e(v,b=>{if($t(b)){const w=b.value,j=[];if(ut(n,w,j,e,f),pn(j))return X(new Q(e,b,j))}return re(b)})),v};return h?$e(h,x):x(p)}}),Pn="~effect/Schema/Schema",cu={[Pn]:Pn,pipe(){return Ce(this,arguments)},annotate(e){return this.rebuild(di(this.ast,e))},annotateKey(e){return this.rebuild(pi(this.ast,e))},check(...e){return this.rebuild(Kt(this.ast,e))}};function ji(e,t){const n=Object.create(cu);return t&&Object.assign(n,t),n.ast=e,n.rebuild=s=>ji(s,t),n.makeEffect=(s,r)=>Si(hs(n)(s,r)),n.make=iu(n),n.makeOption=ki(n),n}const Fn="~effect/Schema/SchemaError";class lu extends Xc("SchemaError"){[Fn]=Fn;constructor(t){super({issue:t})}get message(){return this.issue.toString()}toString(){return`SchemaError(${this.message})`}}function Si(e){return Kr(e,t=>Wr(()=>Qn(t,n=>new lu(n))))}const dt=Pn;function uu(e){return G(e,Fn)}function du(e,t){const n=ou(e,t);return(s,r)=>Si(n(s,r))}function fu(e,t){let n;for(const s of e.reasons){if(!Vr(s)||!uu(s.error))throw new globalThis.Error(t,{cause:e});n??=s.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function hu(e){return el(e).then(t=>{if(es(t))return t.value;throw fu(t.cause,"Promise adapter can only reject schema errors")})}function He(e,t){const n=du(e,t);return(s,r)=>hu(n(s,r))}const z=ji;function pu(e){return G(e,dt)&&e[dt]===dt}const P=fs(e=>z(mi(e.ast),{schema:e}));function Pe(e){const t=z(new lt(e),{literal:e,transform(n){return t.pipe(ms(Pe(n),{decode:xe(()=>n),encode:xe(()=>e)}))}});return t}const Ni=z($l),mu=z(El),d=z(ti),B=z(ni),Z=z(Al);function ps(e,t){return z(e,{fields:t,mapFields(n,s){const r=n(this.fields);return ps(cs(r,s?.unsafePreserveChecks?this.ast.checks:void 0),r)}})}function te(e){return ps(cs(e,void 0),e)}function xu(e,t,n){return z(Zl(e.ast,t.ast,void 0),{key:e,value:t})}function Ci(e,t){return z(e,{elements:t,mapElements(n,s){const r=n(this.elements);return Ci(oi(r,s?.unsafePreserveChecks?this.ast.checks:void 0),r)}})}function Ei(e){return Ci(oi(e),e)}const $=fs(e=>z(new en(!1,[],[e.ast]),{value:e}));function Ri(e,t){return z(e,{members:t,mapMembers(n,s){const r=n(this.members);return Ri(ls(r,this.ast.mode,s?.unsafePreserveChecks?this.ast.checks:void 0),r)}})}function vt(e,t){return Ri(ls(e,"anyOf",void 0),e)}function U(e){const t=e.map(Pe);return z(ls(t,"anyOf",void 0),{literals:e,members:t,mapMembers(n){return vt(n(this.members))},pick(n){return U(n)},transform(n){return vt(t.map((s,r)=>s.transform(n[r])))}})}const T=fs(e=>vt([e,mu]));function ms(e,t){return n=>z(Yl(n.ast,e.ast,t?bl(t):vl()),{from:n,to:e})}const gu=globalThis.Symbol.for("immer-draftable"),Js={};function $i(e,t,n,s,r){const o=yu(n,t,s),a=Ii(t),l=class extends e{constructor(...[c,u]){const f=u?.["~payload"],h=f?.token===Js?f.value:n.make(c??{},u);super(h,{...u,disableChecks:!0,"~payload":{token:Js,value:h}})}static[dt]=dt;get[a](){return a}static[gu]=!0;static identifier=t;static fields=n.fields;static get ast(){return o(this).ast}static pipe(){return Ce(this,arguments)}static rebuild(c){return o(this).rebuild(c)}static make(c,u){return new this(c,u)}static makeOption(c,u){return ki(o(this))(c??{},u)}static makeEffect(c,u){return o(this).makeEffect(c??{},u)}static annotate(c){return this.rebuild(di(this.ast,c))}static annotateKey(c){return this.rebuild(pi(this.ast,c))}static check(...c){return this.rebuild(Kt(this.ast,c))}static extend(c){return(u,p)=>{const f=_i(u)?u:te(u),h={...n.fields,...f.fields},x=cs(h,n.ast.checks,{identifier:c});return $i(this,c,ps(Kt(x,f.ast.checks),h),p,r)}}static mapFields(c,u){return n.mapFields(c,u)}};return r!==void 0&&Object.assign(l.prototype,r(t)),l}function bu(e){return new ge(xe(t=>new e(t)),_n())}function Ii(e){return`~effect/Schema/Class/${e}`}function yu(e,t,n){let s;return r=>{if(s!==void 0)return s;const o=bu(r),a=z(new is([e.ast],()=>(l,c)=>l instanceof r||G(l,Ii(t))?re(l):X(new jt(c,W(l))),{identifier:t,[vi]:([l])=>new se(l,o),toCodec:([l])=>new se(l.ast,o),toArbitrary:([l])=>()=>({arbitrary:l.arbitrary.map(c=>new r(c)),terminal:l.terminal?.map(c=>new r(c))}),toFormatter:([l])=>c=>`${r.identifier}(${l(c)})`,"~sentinels":us(e.ast),...n}));return s=ms(a,o)(e)}}function _i(e){return pu(e)}const N=e=>(t,n)=>{const s=_i(t)?t:te(t);return $i(Yc,e,s,n,r=>({toString(){return`${r}(${J({...this})})`}}))};class ft extends Error{_tag="RuntimeFetchError";path;status;constructor(t,n,s){super(n),this.name="RuntimeFetchError",this.path=t,this.status=s}}class vu extends Error{_tag="RuntimeDecodeError";path;constructor(t,n){super(n),this.name="RuntimeDecodeError",this.path=t}}const Ze=async(e,t)=>{let n;try{n=await fetch(e,{headers:{accept:"application/json"}})}catch(r){throw new ft(e,`network error fetching ${e}: ${String(r)}`)}if(!n.ok)throw new ft(e,`${e} responded ${n.status}`,n.status);let s;try{s=await n.json()}catch(r){throw new ft(e,`${e} did not return valid JSON: ${String(r)}`)}try{return await He(t)(s)}catch(r){throw new vu(e,`${e} response failed schema decode: ${String(r)}`)}},sn=async(e,t)=>{let n;try{n=await fetch(e,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify(t)})}catch(r){throw new ft(e,`network error posting to ${e}: ${String(r)}`)}let s;try{s=await n.json()}catch(r){throw new ft(e,`${e} did not return valid JSON: ${String(r)}`,n.status)}return{status:n.status,ok:n.ok,body:s}},xs=U(["idea","researching","drafting","evaluating","published"]),Ti=U(["working","awaiting-review"]),Ai=U(["no-version","in-sync","design-changed","output-hand-edited","both"]);class Oi extends N("BundleRecord")({slug:d,name:d,oneLiner:d,tags:$(d),created:d,stage:xs,substate:Ti,archived:Z,designHash:d,outputHash:d,drift:Ai,stageChangedAt:P(d)}){}class Pi extends N("VersionRecord")({bundle:d,hash:d,designHash:d,label:P(d),recordedAt:d,snapshot:P(Z)}){}class fp extends N("BundlesResponse")({bundles:$(Oi),fixtureCounts:xu(d,B)}){}class ku extends N("FixtureRecord")({bundle:d,caseName:d,class:d,risks:$(d),hasPromptMd:Z}){}const wu=U(["covered","partial","gap","n/a"]);class ju extends N("RiskCoverageRecord")({bundle:d,riskId:d,family:d,description:P(d),coverage:wu,fixtureCase:P(d)}){}class Su extends N("WarningRecord")({bundle:P(d),source:d,message:d}){}const Fi=U(["running","completed","failed","infra-error"]),Nu=U(["pass","fail","partial"]);class Cu extends N("RunRecord")({id:d,bundle:d,fixtureCase:P(d),versionHash:d,provider:d,model:d,startedAt:d,endedAt:P(d),status:Fi,verdict:P(Nu),gradedAt:P(d)}){}class Eu extends N("WorkspaceSummary")({path:d,name:d}){}class Ru extends N("ConfigSummary")({skillsDir:d,viewerPort:B,providers:$(d),publishTargets:$(te({id:d,kind:d}))}){}class $u extends N("StateResponse")({workspace:Eu,config:Ru}){}class hp extends N("HealthResponse")({ok:Z,version:d}){}const Je=["idea","researching","drafting","evaluating","published"],Iu={idea:"Idea",researching:"Research",drafting:"Draft",evaluating:"Evals",published:"Publish"};class _u extends N("GuardStatus")({stage:xs,approvedForForward:Z,gateApproved:Z}){}class Qe extends N("ActorView")({kind:U(["user","agent","process"]),name:d,provider:P(d)}){}class Et extends N("EventView")({id:d,type:d,at:d,actor:Qe,payload:Ni}){}class Mi extends N("MeasurementRecord")({bundle:d,fixtureCase:d,versionHash:d,provider:d,model:d,n:B,passes:B,partial:B,fail:B,passRate:B,ci:T(Ei([B,B]))}){}class Tu extends N("StationAvailability")({state:d,skill:d}){}class Au extends N("DossierContext")({name:d,body:d,upstream:P(d),downstream:P(d),hands:P(d)}){}class Ou extends N("DossierRecord")({job:P(d),contexts:$(Au),outOfScope:P(d),basis:P(d),evidence:P(d),fitCriterion:P(d)}){}class Pu extends N("LineageRecord")({custody:$(Et),forkOf:T(d),forks:$(d),upstream:T(te({source:d,ref:T(d)}))}){}class Fu extends N("BundleDetailResponse")({bundle:Oi,guardStatus:_u,events:$(Et),versions:$(Pi),fixtures:$(ku),riskCoverage:$(ju),warnings:$(Su),runs:$(Cu),measurements:$(Mi),station:T(Tu),dossier:Ou,lineage:Pu,files:$(d),instructionsPath:T(d),unverified:Z}){}class Mu extends N("FixtureGradingView")({answerKey:T(d),checks:$(d)}){}class Lu extends N("FixtureDetailResponse")({caseName:d,class:T(d),risks:$(d),context:T(d),promptMd:T(d),legacyPrompt:T(d),grading:T(Mu),warnings:$(d)}){}class Du extends N("RunDetailRun")({id:d,bundle:d,fixtureCase:P(d),skillVersionHash:d,provider:d,model:d,startedAt:d,endedAt:P(d),status:Fi}){}class pp extends N("RunDetailResponse")({run:Du,transcript:$(Ni),artifacts:$(d),gradingHistory:$(Et),checks:$(d)}){}class mp extends N("TriggerRunResponse")({runId:d,status:Pe("started")}){}class xp extends N("TriggerStationRunResponse")({runId:d,status:Pe("started")}){}class Uu extends N("PostEventResponse")({status:U(["appended","already_appended"]),event:Et}){}class gp extends N("RecordVersionResponse")({status:U(["appended","already_appended"]),hash:d,designHash:d,label:T(d)}){}class Bu extends N("CreateBundleResponse")({status:U(["created","already_exists"]),slug:d}){}class Vu extends N("BundleFileResponse")({path:d,content:d}){}class gs extends N("ApiErrorResponse")({error:d}){}const Wu=U(["task","bug","improvement","eval"]),Li=U(["open","in-progress","done","wont-do"]);class Ku extends N("ChecklistItemView")({text:d,done:Z}){}const Di=te({kind:Pe("field-report"),eventId:d}),Ui=te({kind:Pe("intake"),intakeId:d}),Bi=te({kind:Pe("run"),runId:d}),qu=vt([Di,Ui,Bi]),Hu=vt([Di,Ui,Bi,te({kind:U(["field-report","intake"]),ref:d})]),Ju=Hu.pipe(ms(qu,{decode:xe(e=>"ref"in e?e.kind==="field-report"?{kind:"field-report",eventId:e.ref}:{kind:"intake",intakeId:e.ref}:e),encode:pl()}));class Gu extends N("TodoRecord")({id:d,kind:Wu,status:Li,title:d,detail:P(d),checklist:P($(Ku)),priority:B,bundle:P(d),created:d,terminalAt:P(d),pinned:P(Z),swept:Z,source:Qe,origin:P(Ju)}){}class zu extends N("TodosResponse")({todos:$(Gu)}){}class bp extends N("EventsResponse")({events:$(Et),nextCursor:T(d)}){}class Yu extends N("CatalogEntry")({slug:d,name:d,oneLiner:d,tags:$(d),stage:xs,substate:P(Ti),archived:Z,drift:Ai,latestVersion:T(te({hash:d,label:T(d),recordedAt:d})),fixtureCount:B,measuredFixtureCount:B,openTodoCount:B,unverified:Z,lastShipment:T(te({destination:d,versionHash:d,at:d})),lastActivityAt:d}){}class Xu extends N("CatalogResponse")({entries:$(Yu)}){}class Zu extends N("SkillbookChangelogEntry")({type:U(["version","published","gate","shipped","reported"]),at:d,summary:d}){}class Qu extends N("ShipReceipt")({fixtureCase:d,provider:d,model:d,n:B,passes:B,passRate:B,ci:T(Ei([B,B]))}){}class ed extends N("SkillbookShipment")({at:d,versionHash:d,destination:d,purpose:d,receipts:$(Qu)}){}class td extends N("SkillbookBundle")({slug:d,name:d,oneLiner:d,stage:d,designMarkdown:d,latestVersion:T(Pi),measurements:$(Mi),changelog:$(Zu),shipments:$(ed),inBook:Z}){}class yp extends N("SkillbookResponse")({workspaceName:d,bundles:$(td)}){}const nd=U(["worked","failed","surprise"]);class sd extends N("FieldReportView")({id:d,bundle:d,outcome:nd,report:d,versionHash:T(d),destination:T(d),at:d,actor:Qe,fixtureCase:T(d),todo:T(te({id:d,title:d,status:Li}))}){}class vp extends N("FieldReportsResponse")({reports:$(sd)}){}const rd=U(["ours","licensed","unclear"]),id=U(["return","new","conflict"]),bs=U(["aside","load-bearing"]);class od extends N("IntakeCrateView")({intake:d,source:d,ref:T(d),claimedName:T(d),claimedVersionHash:T(d),rights:T(rd),stakes:T(bs),hurts:T(d),notes:T(d),at:d,actor:Qe,verdict:id}){}const ad=U(["return","new","upgrade","fork","salvage"]);class cd extends N("RecentlyRoutedView")({intake:d,disposition:ad,bundle:T(d),reason:d,claimedName:T(d),stakes:T(bs),hurts:T(d),at:d,actor:Qe,unverified:Z}){}class ld extends N("SalvagedCrateView")({intake:d,claimedName:T(d),bundle:T(d),reason:d,stakes:T(bs),hurts:T(d),at:d,actor:Qe}){}class kp extends N("IntakeResponse")({crates:$(od),recentlyRouted:$(cd),salvaged:$(ld)}){}class wp extends N("PublishTarget")({id:d,kind:d,path:P(d)}){}class ud extends N("PublishTargetResult")({target:d,kind:d,status:U(["published","already_published"]),url:P(d)}){}class jp extends N("PublishBundleResponse")({bundle:d,versionHash:d,results:$(ud)}){}const Vi=()=>Ze("/api/state",$u),dd=e=>Ze(`/api/bundles/${encodeURIComponent(e)}`,Fu),fd=(e,t)=>Ze(`/api/bundles/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`,Vu),hd=(e,t)=>Ze(`/api/bundles/${encodeURIComponent(e)}/fixtures/${encodeURIComponent(t)}`,Lu),pd=e=>Ze("/api/todos",zu),Wi=()=>Ze("/api/catalog",Xu),Ki=e=>gs.make({error:`request failed with status ${e}`}),rn=async e=>{const t=await sn("/api/events",e);return t.ok?{ok:!0,response:await He(Uu)(t.body)}:{ok:!1,error:(await He(gs)(t.body).catch(()=>Ki(t.status))).error}},md=async(e,t)=>{const n=await sn("/api/bundles",{slug:e});return n.ok?{ok:!0,response:await He(Bu)(n.body)}:{ok:!1,error:(await He(gs)(n.body).catch(()=>Ki(n.status))).error}},xd=e=>{if(typeof e!="object"||e===null)return;const t=e;if(typeof t.id!="string"||t.id.length===0)return;const n=Array.isArray(t.efforts)?t.efforts.filter(s=>typeof s=="string"):[];return{id:t.id,label:typeof t.label=="string"&&t.label.length>0?t.label:t.id,...typeof t.description=="string"?{description:t.description}:{},efforts:n,...typeof t.defaultEffort=="string"?{defaultEffort:t.defaultEffort}:{}}},gd=e=>{if(typeof e!="object"||e===null)return;const t=e;if(typeof t.provider!="string"||t.provider.length===0)return;const n=Array.isArray(t.models)?t.models.map(xd).filter(s=>s!==void 0):[];return{provider:t.provider,title:typeof t.title=="string"&&t.title.length>0?t.title:t.provider,models:n,...typeof t.currentModelId=="string"?{currentModelId:t.currentModelId}:{},...typeof t.currentEffort=="string"?{currentEffort:t.currentEffort}:{},imageSupport:t.imageSupport!==!1,probed:t.probed===!0,...typeof t.note=="string"?{note:t.note}:{}}},qi=async()=>{try{const e=await fetch("/api/chat/providers",{headers:{accept:"application/json"}});if(!e.ok)return null;const t=await e.json();return Array.isArray(t.providers)?t.providers.map(gd).filter(n=>n!==void 0):null}catch{return null}},Gs=e=>{if(typeof e!="object"||e===null)return;const t=e;if(!(typeof t.skill!="string"||!Array.isArray(t.providers)))return t};function bd(e){const[t,n]=m.useState(!0),[s,r]=m.useState(void 0),[o,a]=m.useState([]),[l,c]=m.useState(void 0),[u,p]=m.useState(0);m.useEffect(()=>{let x=!1;return r(void 0),a([]),fetch(`/api/chat/${encodeURIComponent(e)}/state`,{headers:{accept:"application/json"}}).then(async g=>{if(x)return;if(!g.ok){n(!1);return}const y=Gs(await g.json());if(y===void 0){n(!1);return}n(!0),r(y)}).catch(()=>{x||n(!1)}),()=>{x=!0}},[e]),m.useEffect(()=>{if(!t)return;const x=new EventSource(`/api/chat/${encodeURIComponent(e)}/stream`),g=()=>{a([])},y=v=>{let b;try{b=JSON.parse(String(v.data))}catch{return}if(typeof b=="object"&&b!==null&&b.type==="state"){const w=Gs(b.state);w!==void 0&&r(w);return}a(w=>[...w,b])};return x.addEventListener("open",g),x.addEventListener("message",y),()=>{x.removeEventListener("open",g),x.removeEventListener("message",y),x.close()}},[e,t,u]);const f=m.useCallback((x,g,y)=>{c(void 0),sn(`/api/chat/${encodeURIComponent(e)}/${x}`,g).then(v=>{if(!v.ok){const b=v.body;c(typeof b?.error=="string"?b.error:`${x} failed (${v.status})`);return}y?.()}).catch(v=>c(String(v)))},[e]),h=m.useRef(f);return h.current=f,{available:t,state:s,events:o,actionError:l,start:m.useCallback((x,g,y)=>{h.current("session",{provider:x,mode:g,...y?.model!==void 0?{model:y.model}:{},...y?.effort!==void 0?{effort:y.effort}:{}},()=>p(v=>v+1))},[]),send:m.useCallback((x,g)=>{h.current("message",{text:x,...g!==void 0&&g.length>0?{images:g}:{}})},[]),setModel:m.useCallback((x,g)=>{h.current("model",{model:x,...g!==void 0?{effort:g}:{}})},[]),answerPermission:m.useCallback((x,g,y)=>{h.current("permission",{requestId:x,optionId:g,decision:y})},[]),cancelTurn:m.useCallback(()=>{h.current("cancel",{})},[])}}const yd=new Set(["a","an","the","this","that","these","those","it","its","i","we","you","me","us","my","our","your","and","or","but","so","if","then","than","as","to","of","in","on","at","by","for","from","with","into","onto","about","is","are","was","were","be","been","being","am","do","does","did","can","could","would","should","will","shall","may","might","must","want","wants","need","needs","like","help","please","let","lets","make","makes","create","creates","build","builds","write","writes","skill","skills","new","some","any","all","when","how","what","which","who","there"]),vd=5,zs=3,kd=e=>e.toLowerCase().replace(/[^a-z0-9\s-]/g," ").split(/[\s-]+/).filter(t=>t.length>0),wd=e=>{const t=kd(e);let s=t.filter(r=>!yd.has(r)).slice(0,vd);if(s.length<zs){const r=new Set(s);for(const o of t){if(s.length>=zs)break;r.has(o)||(r.add(o),s=[...s,o])}s=[...s].sort((o,a)=>t.indexOf(o)-t.indexOf(a))}return s.length===0?"new-skill":s.join("-")},jd=(e,t)=>{if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;return`${e}-${n}`},Sd=(e,t)=>jd(wd(e),t),Nd=e=>{if(typeof e!="object"||e===null)return null;const t=e.candidates;if(!Array.isArray(t))return null;const n=[];for(const s of t){if(typeof s!="object"||s===null)continue;const{path:r,slug:o}=s;typeof r!="string"||r.length===0||n.push({path:r,slug:typeof o=="string"&&o.length>0?o:void 0})}return n},Cd=async()=>{try{const e=await fetch("/api/adopt/candidates",{headers:{accept:"application/json"}});return e.ok?Nd(await e.json()):null}catch{return null}},Ed=async()=>{try{return(await Vi()).config.providers}catch{return null}},Rd=(e,t,n,s)=>{const r=s?.trim()??"";return n==="revise"&&r.length===0?{ok:!1,error:"Send back requires notes -- say what needs to change."}:{ok:!0,input:{type:"review.resolved",payload:{bundle:e,state:t,decision:n,...r.length>0?{notes:r}:{}}}}},Hi=e=>Je[Je.indexOf(e)+1],$d=(e,t)=>{const n=Hi(t);return n===void 0?{ok:!1,error:`"${t}" is the last stage -- there is nowhere to advance to.`}:{ok:!0,input:{type:"bundle.stage_changed",payload:{bundle:e,from:t,to:n}}}},Id=(e,t,n,s)=>{if(Je.indexOf(n)>=Je.indexOf(t))return{ok:!1,error:`"${n}" is not earlier than "${t}" -- moving back requires an earlier stage.`};const r=s.trim();return r.length===0?{ok:!1,error:"Moving to an earlier stage requires a reason."}:{ok:!0,input:{type:"bundle.stage_changed",payload:{bundle:e,from:t,to:n,reason:r}}}},ys=async e=>{if(!e.ok)return e;const t=await rn(e.input);return t.ok?{ok:!0}:{ok:!1,error:t.error}},Ji=(e,t,n,s)=>ys(Rd(e,t,n,s)),Gi=(e,t)=>ys($d(e,t)),_d=(e,t,n,s)=>ys(Id(e,t,n,s)),Td=async(e,t)=>{const n=e.trim();if(n.length===0)return{ok:!1,error:"A slug is required."};const s=await md(n);return s.ok?s.response.status==="already_exists"?{ok:!1,error:`A skill named "${s.response.slug}" already exists.`}:{ok:!0,slug:s.response.slug}:{ok:!1,error:s.error}};class Ad extends N("AdoptedEntry")({slug:d,path:d,warnings:$(d)}){}class Od extends N("AdoptReport")({found:B,adopted:$(Ad),skipped:$(te({relativePath:d})),challenged:$(te({path:d})),warnings:$(d)}){}const Pd=async e=>{const t=e.trim();if(t.length===0)return{ok:!1,error:"A project-relative path is required."};const n=await sn("/api/adopt",{path:t});if(!n.ok){const r=n.body;return{ok:!1,error:typeof r?.error=="string"?r.error:`adopt failed with status ${n.status}`}}let s;try{s=await He(Od)(n.body)}catch(r){return{ok:!1,error:`adopt response failed schema decode: ${String(r)}`}}return s.adopted.length===0?{ok:!1,error:Fd(s)}:{ok:!0,report:s}},Fd=e=>e.found===0?"No SKILL.md found at that path.":e.skipped.length>0&&e.challenged.length===0?"That skill is already adopted.":e.challenged.length>0?"That skill looks like an arrival from elsewhere -- route it via `skillmaker receive` instead of adopting.":"Nothing was adopted.",Mn="::",gn=(e,t)=>`${e}${Mn}${t??""}`,Md=e=>{const t=e.indexOf(Mn);if(t===-1)return{provider:e};const n=e.slice(t+Mn.length);return{provider:e.slice(0,t),...n.length>0?{model:n}:{}}},Ld=e=>e.charAt(0).toUpperCase()+e.slice(1),Dd=(e,t)=>{const n=e?.find(r=>r.provider===t.provider),s=t.model!==void 0?n?.models.find(r=>r.id===t.model):void 0;return{...n!==void 0?{entry:n}:{},...s!==void 0?{model:s}:{}}},Ud=(e,t)=>{const n=e?.find(s=>s.provider===t);return n===void 0?!0:n.imageSupport},zi=(e,t)=>{const n=e?.find(r=>r.models.length>0)??e?.[0];if(n!==void 0){const r=n.models.find(o=>o.id===n.currentModelId)??n.models[0];return{provider:n.provider,...r!==void 0?{model:r.id}:{},...r?.defaultEffort!==void 0?{effort:r.defaultEffort}:{}}}const s=t[0];return s!==void 0?{provider:s}:void 0},Ys="cursor-pointer truncate bg-transparent text-xs text-ink-muted outline-none hover:text-ink disabled:cursor-default disabled:opacity-60";function Yi({catalog:e,providers:t,selection:n,onChange:s,disabled:r=!1,lockProvider:o}){const a=e!==null&&e.length>0?e:t.map(f=>({provider:f,title:f,models:[],imageSupport:!0,probed:!1})),{model:l}=Dd(e,n),c=l?.efforts??[],u=n.effort??l?.defaultEffort??c[0]??"",p=f=>{const{provider:h,model:x}=Md(f),g=e?.find(v=>v.provider===h),y=x!==void 0?g?.models.find(v=>v.id===x):void 0;s({provider:h,...x!==void 0?{model:x}:{},...y?.defaultEffort!==void 0?{effort:y.defaultEffort}:{}})};return i.jsxs(i.Fragment,{children:[c.length>0&&i.jsx("select",{className:`max-w-[28%] ${Ys}`,value:u,disabled:r,title:"Reasoning effort for this model",onChange:f=>s({...n,effort:f.target.value}),children:c.map(f=>i.jsx("option",{value:f,children:Ld(f)},f))}),i.jsx("select",{className:`max-w-[45%] ${Ys}`,value:gn(n.provider,n.model),disabled:r,title:"Model for the session (grouped by agent; picking a model picks its agent)",onChange:f=>p(f.target.value),children:a.map(f=>f.models.length>0?i.jsx("optgroup",{label:f.title,children:f.models.map(h=>i.jsx("option",{value:gn(f.provider,h.id),disabled:o!==void 0&&f.provider!==o,title:h.description,children:h.label},h.id))},f.provider):i.jsx("option",{value:gn(f.provider,void 0),disabled:o!==void 0&&f.provider!==o,title:f.note!==void 0?`${f.title}: ${f.note}`:f.title,children:f.title},f.provider))})]})}const ne="overflow-hidden whitespace-nowrap [mask-image:linear-gradient(to_right,black_calc(100%_-_20px),transparent_calc(100%_-_2px))]",vs={Idea:"bg-neutral-200 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300",Research:"bg-sky-100 text-sky-800",Drafting:"bg-indigo-100 text-indigo-800",Evals:"bg-amber-100 text-amber-800",Published:"bg-emerald-100 text-emerald-800"},Bd={proven:"●",partial:"◐",unmeasured:"◌",gap:"○"};function Vd({stage:e}){return i.jsx("span",{className:`shrink-0 rounded px-1.5 text-[10px] ${vs[e]}`,children:e})}function we({label:e,primary:t,onClick:n,title:s,disabled:r}){return i.jsx("button",{type:"button",title:s,onClick:n,disabled:r,className:t?"rounded bg-amber-600 px-3 py-1.5 font-display text-sm text-white shadow hover:bg-amber-700 disabled:cursor-default disabled:bg-amber-600/50 disabled:hover:bg-amber-600/50":"rounded border border-border bg-surface px-3 py-1.5 font-display text-sm text-ink-muted hover:text-ink disabled:cursor-default disabled:opacity-60 disabled:hover:text-ink-muted",children:e})}function Le({active:e,onClick:t,title:n,children:s,className:r="",...o}){return i.jsx("button",{type:"button",title:n,onClick:t,className:`rounded p-1.5 ${e?"bg-surface text-ink shadow-sm":"text-ink-muted hover:bg-surface hover:text-ink"} ${r}`,...o,children:s})}function Wd({project:e,onCreated:t,onAdopted:n}){const[s,r]=m.useState(""),[o,a]=m.useState(void 0),[l,c]=m.useState(null),[u,p]=m.useState(null),[f,h]=m.useState([]),[x,g]=m.useState(new Set),[y,v]=m.useState(!1),[b,w]=m.useState(null),j=o===null,C=!j&&o!==void 0&&!y&&s.trim().length>0,E=u??zi(l,o??[])??void 0;m.useEffect(()=>{let _=!1;return Ed().then(k=>{_||a(k)}),qi().then(k=>{_||c(k)}),Cd().then(k=>{!_&&k!==null&&h(k)}),Wi().then(k=>{_||g(new Set(k.entries.map(M=>M.slug)))},()=>{}),()=>{_=!0}},[]);const O=async()=>{const _=s.trim();if(_.length===0||y||j||o===void 0)return;const k=E?.provider??o[0]??"claude-code";v(!0),w(null);const M=Sd(_,x),Y=await Td(M);if(!Y.ok){v(!1),w(Y.error);return}t(Y.slug,k,_,E?.model,E?.effort)},F=async _=>{if(y||j)return;v(!0),w(null);const k=await Pd(_.path);if(!k.ok){v(!1),w(k.error);return}const M=k.report.adopted[0]?.slug;if(M===void 0){v(!1),w("Nothing was adopted.");return}n(M)};return i.jsx("div",{className:"flex h-full items-center justify-center p-6",children:i.jsxs("div",{className:"w-full max-w-xl",children:[i.jsx("h1",{className:"pb-4 text-center font-display text-xl",children:"What skill would you like to create? Tell us about it."}),i.jsxs("div",{className:"rounded-xl border border-border bg-surface/95 shadow-lg focus-within:border-amber-300",children:[i.jsx("textarea",{className:"max-h-64 w-full resize-none bg-transparent px-4 pb-1.5 pt-3.5 text-sm outline-none disabled:opacity-60",rows:3,placeholder:j?"Start the server to create skills":"A skill that…",value:s,disabled:j||y,autoFocus:!0,onChange:_=>{r(_.target.value),_.target.style.height="auto",_.target.style.height=`${_.target.scrollHeight}px`},onKeyDown:_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),O())}}),i.jsxs("div",{className:"flex items-center justify-end gap-2 px-3 pb-3",children:[E!==void 0?i.jsx(Yi,{catalog:l,providers:o??[],selection:E,onChange:p,disabled:j||y}):i.jsx("select",{className:"max-w-[45%] cursor-default truncate bg-transparent text-xs text-ink-muted outline-none",value:"",disabled:!0,title:"Model for the new skill's session",children:i.jsx("option",{value:"",children:"model"})}),i.jsx("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full bg-amber-600 text-white shadow hover:bg-amber-700 disabled:opacity-35",title:"Create the skill and start the conversation",disabled:!C,onClick:()=>void O(),children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("line",{x1:"8",y1:"13",x2:"8",y2:"3.5"}),i.jsx("path",{d:"M4 7.5L8 3.5l4 4"})]})})]})]}),j&&i.jsx("p",{className:"pt-3 text-center text-xs text-ink-muted",children:"The studio server isn't running — creating and importing skills needs it."}),b!==null&&i.jsx("p",{className:"pt-3 text-center text-xs text-red-600",children:b}),f.length>0&&i.jsxs("section",{className:"pt-6",children:[i.jsx("h2",{className:"pb-2 text-xs uppercase tracking-widest text-ink-muted",children:"Import one of these?"}),i.jsx("div",{className:"space-y-1.5",children:f.map(_=>i.jsxs("button",{type:"button",disabled:y||j,onClick:()=>void F(_),className:"flex w-full items-center gap-2 rounded border border-border bg-surface px-3 py-2 text-left text-sm shadow-sm hover:shadow disabled:opacity-60",title:`Import ${_.path} into ${e}`,children:[i.jsx("span",{className:`min-w-0 flex-1 ${ne}`,children:_.path}),_.slug!==void 0&&i.jsxs("span",{className:"shrink-0 text-xs text-ink-muted",children:["→ ",_.slug]})]},_.path))})]})]})})}const Kd=e=>/\.(md|markdown)$/i.test(e),qd=e=>{const t=e.trim();if(t.length===0)return;const n=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(t);if(n===null)return t;const s=(n[1]??"").toLowerCase();return s==="http"||s==="https"||s==="mailto"?t:void 0},Xs=(e,t,n)=>{let s=e.indexOf(t,n);for(;s>0&&e[s-1]==="\\";)s=e.indexOf(t,s+1);return s},fe=e=>{const t=[];let n="";const s=()=>{n.length>0&&(t.push({kind:"text",text:n}),n="")};let r=0;for(;r<e.length;){const o=e[r]??"";if(o==="`"){const a=e.indexOf("`",r+1);if(a!==-1){s(),t.push({kind:"code",text:e.slice(r+1,a)}),r=a+1;continue}}if(o==="["){const a=/^\[([^\]]*)\]\(((?:[^()\s]|\([^()\s]*\))*)(?:\s+"[^"]*")?\)/.exec(e.slice(r));if(a!==null){const l=a[1]??"",c=a[2]??"",u=qd(c);s(),u!==void 0?t.push({kind:"link",href:u,children:fe(l)}):t.push({kind:"text",text:l}),r+=a[0].length;continue}}if(e.startsWith("**",r)){const a=Xs(e,"**",r+2);if(a!==-1&&a>r+2){s(),t.push({kind:"strong",children:fe(e.slice(r+2,a))}),r=a+2;continue}}if(o==="*"){const a=Xs(e,"*",r+1);if(a!==-1&&a>r+1){s(),t.push({kind:"em",children:fe(e.slice(r+1,a))}),r=a+1;continue}}n+=o,r+=1}return s(),t},Hd=/^\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/,Zs=/^---\s*$/,Jd=e=>{let t=e.split(`
|
|
21
|
+
`);if(Zs.test(t[0]??"")){const o=t.findIndex((a,l)=>l>0&&Zs.test(a));o!==-1&&(t=t.slice(o+1))}const n=[];let s=!1,r=!1;for(const o of t){if(!r&&o.trim().startsWith("```")){s=!s,n.push(o);continue}if(s){n.push(o);continue}let a=o,l="";for(;a.length>0;)if(r){const c=a.indexOf("-->");c===-1?a="":(a=a.slice(c+3),r=!1)}else{const c=a.indexOf("<!--");c===-1?(l+=a,a=""):(l+=a.slice(0,c),a=a.slice(c+4),r=!0)}(l.length>0||o.trim().length===0)&&n.push(l)}return n.join(`
|
|
22
|
+
`)},Qs=e=>{let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>n.trim())},Gd=e=>{const t=Jd(e).split(`
|
|
23
|
+
`),n=[];let s=!1,r,o=[],a=[],l=!1,c=[],u=[];const p=()=>{c.length>0&&(n.push({kind:"paragraph",children:fe(c.join(" "))}),c=[])},f=()=>{a.length>0&&(n.push({kind:"list",ordered:l,items:a}),a=[])},h=()=>{u.length>0&&(n.push({kind:"blockquote",children:fe(u.join(" "))}),u=[])},x=()=>{p(),f(),h()};let g=0;for(;g<t.length;){const y=t[g]??"";if(y.trim().startsWith("```")){if(s)n.push({kind:"code",text:o.join(`
|
|
24
|
+
`),lang:r}),o=[],r=void 0,s=!1;else{x();const C=y.trim().slice(3).trim();r=C.length>0?C:void 0,s=!0}g+=1;continue}if(s){o.push(y),g+=1;continue}const v=/^(#{1,6})\s+(.*)$/.exec(y);if(v!==null){x();const C=Math.min(6,Math.max(1,(v[1]??"#").length));n.push({kind:"heading",level:C,children:fe(v[2]??"")}),g+=1;continue}if(y.trim().startsWith("|")&&Hd.test((t[g+1]??"").trim())){x();const C=Qs(y).map(fe),E=[];let O=g+2;for(;O<t.length&&(t[O]??"").trim().startsWith("|");)E.push(Qs(t[O]??"").map(fe)),O+=1;n.push({kind:"table",header:C,rows:E}),g=O;continue}const b=/^>\s?(.*)$/.exec(y.trim());if(b!==null){p(),f(),u.push(b[1]??""),g+=1;continue}const w=/^\s*[-*+]\s+(.*)$/.exec(y),j=/^\s*\d+[.)]\s+(.*)$/.exec(y);if(w!==null||j!==null){p(),h();const C=w===null;a.length>0&&C!==l&&f(),l=C,a.push(fe(w?.[1]??j?.[1]??"")),g+=1;continue}if(y.trim().length===0){x(),g+=1;continue}f(),h(),c.push(y.trim()),g+=1}return s&&n.push({kind:"code",text:o.join(`
|
|
25
|
+
`),lang:r}),x(),n},he=({nodes:e})=>i.jsx(i.Fragment,{children:e.map((t,n)=>{switch(t.kind){case"text":return i.jsx("span",{children:t.text},n);case"code":return i.jsx("code",{className:"rounded bg-neutral-100 px-1 font-mono text-[0.9em] dark:bg-neutral-900",children:t.text},n);case"strong":return i.jsx("strong",{className:"font-semibold",children:i.jsx(he,{nodes:t.children})},n);case"em":return i.jsx("em",{children:i.jsx(he,{nodes:t.children})},n);case"link":return i.jsx("a",{href:t.href,target:"_blank",rel:"noopener noreferrer",className:"text-sky-700 underline decoration-dotted underline-offset-2 hover:decoration-solid dark:text-sky-300",children:i.jsx(he,{nodes:t.children})},n)}})}),zd={1:"text-base font-semibold text-neutral-900 dark:text-neutral-100",2:"text-sm font-semibold text-neutral-900 dark:text-neutral-100",3:"text-sm font-semibold text-neutral-800 dark:text-neutral-200",4:"text-xs font-semibold text-neutral-800 dark:text-neutral-200",5:"text-xs font-semibold text-neutral-700 dark:text-neutral-300",6:"text-xs font-semibold uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},Yd=({block:e})=>{switch(e.kind){case"heading":{const t=`h${e.level}`;return i.jsx(t,{className:zd[e.level],children:i.jsx(he,{nodes:e.children})})}case"paragraph":return i.jsx("p",{className:"text-neutral-700 dark:text-neutral-300",children:i.jsx(he,{nodes:e.children})});case"list":{const t=e.items.map((n,s)=>i.jsx("li",{children:i.jsx(he,{nodes:n})},s));return e.ordered?i.jsx("ol",{className:"list-decimal pl-5 text-neutral-700 dark:text-neutral-300",children:t}):i.jsx("ul",{className:"list-disc pl-5 text-neutral-700 dark:text-neutral-300",children:t})}case"code":return i.jsx("pre",{className:"overflow-x-auto rounded-md bg-neutral-100 p-2 font-mono text-[0.9em] dark:bg-neutral-900",children:i.jsx("code",{children:e.text})});case"table":return i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"border-collapse text-left",children:[i.jsx("thead",{children:i.jsx("tr",{children:e.header.map((t,n)=>i.jsx("th",{className:"border border-neutral-200 px-2 py-1 font-semibold text-neutral-800 dark:border-neutral-800 dark:text-neutral-200",children:i.jsx(he,{nodes:t})},n))})}),i.jsx("tbody",{children:e.rows.map((t,n)=>i.jsx("tr",{children:t.map((s,r)=>i.jsx("td",{className:"border border-neutral-200 px-2 py-1 text-neutral-700 dark:border-neutral-800 dark:text-neutral-300",children:i.jsx(he,{nodes:s})},r))},n))})]})});case"blockquote":return i.jsx("blockquote",{className:"border-l-2 border-neutral-300 pl-3 text-neutral-600 dark:border-neutral-700 dark:text-neutral-400",children:i.jsx(he,{nodes:e.children})})}},on=({markdown:e,className:t})=>i.jsx("div",{className:t??"flex flex-col gap-2 text-[13px] leading-relaxed",children:Gd(e).map((n,s)=>i.jsx(Yd,{block:n},s))}),Xi=({path:e,content:t,preClassName:n,renderedClassName:s})=>{const[r,o]=m.useState(!1);return Kd(e)?i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("div",{className:"flex justify-end",children:i.jsx("button",{type:"button",onClick:()=>o(l=>!l),"aria-pressed":r,className:"rounded-md border border-neutral-300 px-2 py-0.5 font-mono text-[10px] text-neutral-600 hover:border-neutral-500 dark:border-neutral-700 dark:text-neutral-300",children:r?"Rendered":"Raw"})}),r?i.jsx("pre",{className:n,children:t.length>0?t:"(empty)"}):i.jsx("div",{className:s??"max-h-96 overflow-auto rounded-md border border-neutral-200 p-3 dark:border-neutral-800",children:t.length>0?i.jsx(on,{markdown:t}):i.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"(empty)"})})]}):i.jsx("pre",{className:n,children:t.length>0?t:"(empty)"})},Xd=400,Zd=2e3,Qd=1e3,ef=3e4,tf=(e,{debounceMs:t=Xd,maxWaitMs:n=Zd}={},s={setTimeout:(r,o)=>globalThis.setTimeout(r,o),clearTimeout:r=>globalThis.clearTimeout(r)})=>{let r,o;const a=()=>{r!==void 0&&(s.clearTimeout(r),r=void 0),o!==void 0&&(s.clearTimeout(o),o=void 0)},l=()=>{a(),e()};return{signal:()=>{r!==void 0&&s.clearTimeout(r),r=s.setTimeout(l,t),o===void 0&&(o=s.setTimeout(l,n))},cancel:a}},nf=e=>Math.min(Qd*2**Math.max(0,Math.min(e,30)),ef),De=new Set;let Ve,kt,Ot,ot=0;const sf=()=>{for(const e of[...De])e()},Zi=()=>{if(typeof EventSource>"u")return;const e=new EventSource("/api/events-stream");Ve=e,e.onopen=()=>{const t=ot>0;ot=0,t&&kt?.signal()},e.onmessage=()=>kt?.signal(),e.onerror=()=>{if(e.close(),Ve!==e||(Ve=void 0,De.size===0))return;const t=nf(ot);ot+=1,Ot=setTimeout(Zi,t)}},rf=()=>{if(Ot!==void 0&&(clearTimeout(Ot),Ot=void 0),Ve!==void 0){const e=Ve;Ve=void 0,e.onerror=null,e.close()}kt?.cancel(),kt=void 0,ot=0},Qi=e=>(De.add(e),De.size===1&&(kt=tf(sf),Zi()),()=>{De.delete(e),De.size===0&&rf()}),eo=()=>{const[e,t]=m.useState(0);return m.useEffect(()=>Qi(()=>t(n=>n+1)),[]),e},bn=e=>{const t=e.indexOf("·");return t===-1?e:e.slice(0,t).trim()},to=e=>typeof e=="object"&&e!==null,ht=(e,t)=>{if(!to(e))return;const n=e[t];return typeof n=="string"?n:void 0},of=(e,t)=>{if(!to(e))return[];const n=e[t];return Array.isArray(n)?n.filter(s=>typeof s=="string"):[]},_t=e=>Iu[e]??e,af=(e,t)=>{for(const n of e){if(n.type==="review.resolved")return;if(n.type!=="review.requested")continue;const s=ht(n.payload,"state"),r=s===void 0?"Review the submitted work":`Review the ${_t(s)}-stage work`,o=s!==void 0&&s!==t?`This review was requested by the ${_t(s)} station; this skill has since moved to ${_t(t)}. No ${_t(t)}-stage work exists to approve yet.`:void 0;return{requestedState:s,title:r,staleNote:o,question:ht(n.payload,"question"),artifacts:of(n.payload,"artifacts")}}},cf=(e,t)=>{for(const n of e){if(n.type!=="review.resolved"||ht(n.payload,"state")!==t)continue;const s=ht(n.payload,"decision");if(s!=="approve"&&s!=="revise")continue;const r=ht(n.payload,"notes");return{decision:s,headline:s==="approve"?"Approved":"Sent back",at:n.at,notes:r,nextStep:s==="revise"?"Notes were recorded and will be given to the agent on the next station run.":r!==void 0?"Approval recorded; the notes are kept in the journal for the record.":"Approval recorded — this stage can move forward."}}},lf=(e,t,n)=>{const s=t.filter(r=>r.risks.includes(e)).map(r=>r.caseName);return n!==void 0&&!s.includes(n)?[...s,n]:s},uf=(e,t)=>{const n=new Set(t);return e.filter(s=>!s.risks.some(r=>n.has(r))).map(s=>s.caseName)},df=e=>[...new Set(e.map(t=>t.model))].sort(),ff=e=>{const t=new Set(e.fixtureCases),n=e.measurements.filter(s=>t.has(s.fixtureCase));return e.models.map(s=>{const r=n.filter(l=>l.model===s),o=e.scope==="all"?r:e.latestVersionHash===null?[]:r.filter(l=>l.versionHash===e.latestVersionHash),a=o.some(l=>l.passes>0)?"proven":o.some(l=>l.n>0)?"failing":r.some(l=>l.n>0)?"stale":"unmeasured";return{model:s,status:a}})},hf=(e,t)=>e==="gap"||e==="partial"?e:t.some(n=>n.status==="proven")?"proven":"unmeasured",er=(e,t)=>e.filter(n=>n.fixtureCase===t).slice().sort((n,s)=>s.startedAt.localeCompare(n.startedAt)),tr=72,pf=e=>{const t=e.sentence.trim(),n=t.length>tr?`${t.slice(0,tr-1).trimEnd()}…`:t;return{todo:{id:e.id,kind:"eval",status:"open",title:`Cover ${e.riskId}: ${n}`,detail:`Coverage gap: no fixture covers ${e.riskId}.`,priority:15,bundle:e.bundle,created:e.created,source:{kind:"user",name:"viewer"}}}},mf=e=>{const t=e.promptMd??e.legacyPrompt??e.context;if(t===null)return null;const n=t.split(`
|
|
26
|
+
`).map(s=>s.trim()).find(s=>s.length>0&&!s.startsWith("#"));return n===void 0?null:n.length>160?`${n.slice(0,159).trimEnd()}…`:n},xf=e=>{const t=[],n=new Map;for(const s of e){const r=n.get(s.family);r===void 0?(t.push(s.family),n.set(s.family,[s])):r.push(s)}return t.map(s=>({family:s,claims:n.get(s)??[]}))},gf=(e,t)=>e!==null?`running ${Math.min(e.completed+1,e.total)} of ${e.total}…`:t>0?"running…":"Run all fixtures",ks={idea:"Idea",researching:"Research",drafting:"Drafting",evaluating:"Evals",published:"Published"},bf=e=>({slug:e.slug,stage:ks[e.stage],oneLiner:e.oneLiner,awaitingReview:e.substate==="awaiting-review"}),yf=(e,t)=>[{name:e.workspace.name,path:e.workspace.path,skills:t.filter(n=>!n.archived).map(bf)}],vf=e=>{const t=e.bundle!==void 0?` · ${e.bundle}`:"";switch(e.origin?.kind){case"run":return`run${t}`;case"field-report":return`report${t}`;case"intake":return`intake${t}`;case void 0:return e.kind==="eval"?`gap${t}`:"human"}},kf=e=>e.status==="open"||e.status==="in-progress"?{title:e.title,origin:vf(e),state:e.status}:void 0,wf=e=>e.flatMap(t=>{const n=kf(t);return n===void 0?[]:[n]}),jf=async()=>{const[e,t]=await Promise.all([Vi(),Wi()]);return yf(e,t.entries)},no=async()=>{const e=await pd();return wf(e.todos)},Sf=e=>e==="idea"||e==="researching"||e==="drafting"||e==="evaluating"||e==="published"?e:void 0,Nf=e=>{const t=af(e.events,e.bundle.stage),n=cf(e.events,e.bundle.stage);return{slug:e.bundle.slug,stage:e.bundle.stage,substate:e.bundle.substate,approvedForForward:e.guardStatus.approvedForForward,gateApproved:e.guardStatus.gateApproved,pending:t===void 0?void 0:{requestedState:Sf(t.requestedState),question:t.question,artifacts:t.artifacts},outcome:n===void 0?void 0:{decision:n.decision,at:n.at,notes:n.notes}}},Cf={IN:"Input",RE:"Reasoning",OUT:"Output",ADV:"Adversarial",CHN:"Chain"},Ef=async e=>{const t=await dd(e),n=t.instructionsPath===null?null:await fd(e,t.instructionsPath).then(c=>c.content,()=>null),s=new Set(t.measurements.filter(c=>c.passes>0).map(c=>c.fixtureCase)),r=t.riskCoverage.map(c=>{const u=lf(c.riskId,t.fixtures,c.fixtureCase),p=c.coverage==="gap"?"gap":c.coverage==="partial"?"partial":u.some(f=>s.has(f))?"proven":"unmeasured";return{id:c.riskId,family:Cf[c.family]??c.family,sentence:c.description!==void 0&&c.description.length>0?c.description:"(no description)",status:p,fixtures:u.length,fixtureCases:u}}),o=t.versions.at(-1),a=[...new Set(t.measurements.filter(c=>c.passes>0).map(c=>bn(c.model)))],l=t.riskCoverage.filter(c=>c.coverage!=="gap").length;return{name:t.bundle.name.length>0?t.bundle.name:t.bundle.slug,oneLiner:t.bundle.oneLiner,versions:[...t.versions].map(c=>({hash:c.hash,shortHash:c.hash.replace(/^sha256:/,"").slice(0,8),label:c.label??null,recordedAt:c.recordedAt})).reverse(),loop:Nf(t),instructions:n,stage:ks[t.bundle.stage],versionShort:o===void 0?null:o.hash.replace(/^sha256:/,"").slice(0,8),drift:t.bundle.drift.replace(/-/g," "),provenOn:a.length===0?"none yet":a.join(", "),coverage:`${l} of ${t.riskCoverage.length} claims`,claims:r,evals:{slug:e,latestVersionHash:o?.hash??null,runs:t.runs.map(c=>({id:c.id,fixtureCase:c.fixtureCase??null,versionHash:c.versionHash,provider:c.provider,model:bn(c.model),startedAt:c.startedAt,status:c.status,verdict:c.verdict??null})),measurements:t.measurements.map(c=>({fixtureCase:c.fixtureCase,versionHash:c.versionHash,model:bn(c.model),n:c.n,passes:c.passes})),unclaimed:uf(t.fixtures,t.riskCoverage.map(c=>c.riskId))},events:t.events.slice(0,5).map(c=>({type:c.type,at:new Date(c.at).toLocaleDateString(void 0,{month:"short",day:"numeric"})}))}},Rf=async e=>{const t=await fetch(`/api/bundles/${encodeURIComponent(e)}/files`);if(!t.ok)throw new Error(`files: ${t.status}`);return((await t.json()).files??[]).filter(s=>typeof s.path=="string"&&typeof s.size=="number").filter(s=>!s.path.endsWith("/.gitkeep"))},ws=async(e,t)=>{const n=await fetch(`/api/bundles/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`file: ${n.status}`);const s=await n.json();if(typeof s.content!="string")throw new Error("file: malformed response");return s.content},$f=async(e,t)=>{const n=await hd(e,t);return{summary:mf(n),hasAnswerKey:n.grading!==null&&n.grading.answerKey!==null&&n.grading.answerKey.trim().length>0,checkCount:n.grading?.checks.length??0,fixtureClass:n.class}},If=async(e,t)=>{const n=await fetch(`/api/bundles/${encodeURIComponent(e)}/runs/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`run: ${n.status}`);const s=await n.json();return{skillInvoked:typeof s.skillInvoked=="boolean"?s.skillInvoked:null,artifacts:Array.isArray(s.artifacts)?s.artifacts.filter(r=>typeof r=="string"):[]}};function _f(e){const t=eo(),[n,s]=m.useState({status:"loading"}),r=m.useRef(void 0);return m.useEffect(()=>{let o=!1;const a=r.current===e;return r.current=e,a||s({status:"loading"}),e().then(l=>{o||s({data:l,status:"live"})},()=>{o||s(l=>a&&l.status==="live"?l:{status:"error"})}),()=>{o=!0}},[e,t]),n}function et(e,t){const n=eo(),[s,r]=m.useState(void 0);return m.useEffect(()=>{let o=!1;return e().then(a=>{o||r(a)},()=>{}),()=>{o=!0}},[e,n]),s??t}const pe=e=>typeof e=="object"&&e!==null,Tf=e=>{if(!Array.isArray(e))return[];const t=[];for(const n of e)!pe(n)||typeof n.data!="string"||typeof n.mimeType!="string"||t.push({data:n.data,mimeType:n.mimeType,...typeof n.name=="string"?{name:n.name}:{}});return t},Af=e=>pe(e)&&e.type==="text"&&typeof e.text=="string"?e.text:void 0,Of=e=>typeof e.t=="string"?e.t:"",Pf=e=>{if(!pe(e)||!Array.isArray(e.options))return[];const t=[];for(const n of e.options)pe(n)&&typeof n.optionId=="string"&&typeof n.kind=="string"&&t.push({optionId:n.optionId,kind:n.kind,...typeof n.name=="string"?{name:n.name}:{}});return t},Ff=e=>pe(e)&&pe(e.toolCall)&&typeof e.toolCall.title=="string"?e.toolCall.title:"Permission requested",Mf=e=>({approve:e.find(t=>t.kind==="allow_once")??e.find(t=>t.kind==="allow_always")??e.find(t=>t.kind.includes("allow")),deny:e.find(t=>t.kind==="reject_once")??e.find(t=>t.kind==="reject_always")??e.find(t=>t.kind.includes("reject")||t.kind.includes("deny"))}),Lf=(e,t,n,s)=>{const r=e[e.length-1];r!==void 0&&r.kind===t?e[e.length-1]={...r,text:r.text+n}:e.push({kind:t,text:n,t:s})},Df=e=>{const t=[],n=new Map,s=new Map;for(const r of e){if(!pe(r)||typeof r.type!="string")continue;const o=Of(r);if(r.type==="user_message"&&typeof r.text=="string"){const a=Tf(r.images);t.push({kind:"user",text:r.text,t:o,...a.length>0?{images:a}:{}});continue}if(r.type==="update"&&pe(r.update)&&pe(r.update.update)){const a=r.update.update,l=typeof a.sessionUpdate=="string"?a.sessionUpdate:"";if(l==="agent_message_chunk"||l==="user_message_chunk"){const c=Af(a.content);c!==void 0&&c.length>0&&Lf(t,l==="user_message_chunk"?"user":"agent",c,o);continue}if(l==="tool_call"||l==="tool_call_update"){const c=typeof a.toolCallId=="string"?a.toolCallId:"";if(c.length===0)continue;const u=typeof a.title=="string"?a.title:void 0,p=typeof a.status=="string"?a.status:void 0,f=n.get(c);if(f!==void 0)u!==void 0&&(f.title=u),p!==void 0&&(f.status=p);else{const h={kind:"tool",toolCallId:c,title:u??"tool call",status:p??"pending",t:o};n.set(c,h),t.push(h)}continue}continue}if(r.type==="permission_request"&&typeof r.id=="string"){s.set(r.id,t.length),t.push({kind:"permission",id:r.id,title:Ff(r.params),options:Pf(r.params),resolved:void 0,t:o});continue}if(r.type==="permission_resolved"&&typeof r.id=="string"){const a=s.get(r.id),l=a!==void 0?t[a]:void 0;a!==void 0&&l!==void 0&&l.kind==="permission"&&(t[a]={...l,resolved:{outcome:typeof r.outcome=="string"?r.outcome:"resolved",...typeof r.optionId=="string"?{optionId:r.optionId}:{}}});continue}if(r.type==="error"&&typeof r.message=="string"){t.push({kind:"error",message:r.message,t:o});continue}}return t},Ln=[{name:"skills",path:"~/Documents/code/skills",skills:[{slug:"to-tickets",stage:"Evals",oneLiner:"Decompose a decided scope into tracer-bullet tickets"},{slug:"release-notes",stage:"Idea",oneLiner:"Draft release notes from merged PRs"},{slug:"standup-summarizer",stage:"Idea",oneLiner:"Summarize the day across repos"},{slug:"pr-description-writer",stage:"Drafting",oneLiner:"Write PR descriptions from diffs"},{slug:"changelog-curator",stage:"Research",oneLiner:"Curate user-facing changelogs"},{slug:"incident-scribe",stage:"Idea",oneLiner:"Turn incident channels into postmortems"},{slug:"meeting-actions",stage:"Idea",oneLiner:"Extract action items from transcripts"}]},{name:"skillmaker-studio",path:"~/Documents/code/skillmaker-studio",skills:[{slug:"skillmaker-dev-release",stage:"Published",oneLiner:"Cut a skillmaker-studio release"},{slug:"to-tickets",stage:"Published",oneLiner:"Decompose scope into tickets (installed)"}]}],so=[{title:"IN-1 fixture may not force skill invocation — add trigger variant",origin:"run · to-tickets",state:"open"},{title:"Cover RE-2 (DAG validity) — no fixture yet",origin:"gap · to-tickets",state:"open"},{title:"Grow partial-decomposition past smoke (n=1 of 5)",origin:"gap · to-tickets",state:"open"},{title:"Permission denials review after first canary run",origin:"human",state:"in-progress"}],Uf=[{id:"IN-1",family:"Input",sentence:"Input too vague to decompose: refuses and asks for concrete scope",status:"proven",fixtures:1,fixtureCases:["vague-scope-refusal"]},{id:"IN-2",family:"Input",sentence:"Already-partial decomposition is respected, not discarded",status:"unmeasured",fixtures:1,fixtureCases:["partial-decomposition"]},{id:"RE-1",family:"Reasoning",sentence:"Blocking edges are real — never merely-related",status:"partial",fixtures:1,fixtureCases:["partial-decomposition"]},{id:"RE-2",family:"Reasoning",sentence:"The DAG is valid: no cycles, no dangling references",status:"gap",fixtures:0,fixtureCases:[]},{id:"OUT-3",family:"Output",sentence:"Never talks to a tracker API",status:"gap",fixtures:0,fixtureCases:[]}],Bf=["design.md","output/SKILL.md","research/notes.md","research/decisions.md","evals/risk-map.md","evals/fixtures/vague-scope-refusal/","evals/fixtures/partial-decomposition/"],Vf={name:"to-tickets",oneLiner:"Decompose a decided scope into tracer-bullet tickets",versions:[],loop:null,instructions:"Decompose an already-decided scope into vertical-slice implementation tickets…",stage:"Evals",versionShort:"811e4580",drift:"in sync",provenOn:"Opus 4.6 (1 claim)",coverage:"2 of 5 claims",claims:Uf,evals:null,events:[{type:"run.graded",at:"yesterday"},{type:"station drafting completed",at:"2d ago"},{type:"bundle.created",at:"2d ago"}]},Wf=Bf.map(e=>({path:e,size:0}));function Kf({skill:e,width:t,intro:n=null,onIntroConsumed:s,fileRequest:r=null,onFileRequestHandled:o}){const[a,l]=m.useState("chat"),[c,u]=m.useState(null),[p,f]=m.useState(!0),h=x=>{u(x),x!==null&&t<420&&f(!1)};return m.useEffect(()=>{r!=null&&(l("files"),h(r),o?.())},[r]),i.jsxs("div",{className:"flex h-full flex-col",children:[i.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-1 px-2",children:[["files","chat"].map(x=>i.jsx("button",{type:"button",onClick:()=>l(x),className:`rounded px-2 py-1 font-display text-xs uppercase ${a===x?"bg-surface shadow-sm":"text-ink-muted hover:bg-surface hover:text-ink hover:shadow-sm"}`,children:x},x)),i.jsx("span",{className:"flex-1"}),a==="files"&&c!==null&&i.jsx(Le,{active:p,onClick:()=>f(!p),title:p?"Hide file browser":"Show file browser",children:i.jsx(Ro,{})}),i.jsx("span",{className:"w-16 shrink-0"})]}),a==="files"?i.jsx(Hf,{skill:e,selected:c,treeOpen:p,onSelect:h}):i.jsx(ih,{skill:e,intro:n,onIntroConsumed:s})]})}function qf(e){const t={name:"",path:"",dirs:[],files:[]};for(const n of e){const s=n.path.split("/");let r=t;for(let o=0;o<s.length-1;o++){const a=s.slice(0,o+1).join("/");let l=r.dirs.find(c=>c.path===a);l===void 0&&(l={name:s[o]??"",path:a,dirs:[],files:[]},r.dirs.push(l)),r=l}r.files.push(n)}return t}function Hf({skill:e,selected:t,treeOpen:n,onSelect:s}){const r=m.useCallback(()=>Rf(e),[e]),o=et(r,Wf),a=qf(o),l=yn("right","sm-next-treew",208,140,420);return t===null?i.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-4 text-sm",children:i.jsx(Dn,{dir:a,depth:0,selected:t,onSelect:s})}):i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[i.jsxs("div",{className:`flex shrink-0 items-center gap-1 border-b border-border px-3 py-1.5 text-xs ${ne}`,children:[i.jsx("span",{className:"text-ink-muted",children:e}),t.split("/").map((c,u,p)=>i.jsxs("span",{className:"flex items-center gap-1 whitespace-nowrap",children:[i.jsx("span",{className:"text-ink-muted",children:"›"}),i.jsx("span",{className:u===p.length-1?"font-display":"text-ink-muted",children:c})]},`${c}-${u}`))]}),i.jsxs("div",{className:"flex min-h-0 flex-1",children:[i.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto p-3",children:i.jsx(Gf,{skill:e,path:t})}),i.jsxs("div",{className:`relative shrink-0 overflow-hidden border-border ${l.dragging?"":"transition-[width] duration-200 ease-out"} ${n?"border-l":""}`,style:{width:n?l.width:0},children:[n&&i.jsx("div",{className:"absolute inset-y-0 left-0 z-10 w-2 cursor-col-resize hover:bg-amber-400/40",onMouseDown:l.onDragStart,title:"Drag to resize"}),i.jsx("div",{className:"h-full overflow-y-auto px-1 py-2 text-sm",style:{width:l.width},children:i.jsx(Dn,{dir:a,depth:0,selected:t,onSelect:s})})]})]})]})}function Jf({dir:e,depth:t,selected:n,onSelect:s}){const[r,o]=m.useState(!0);return i.jsxs("div",{children:[i.jsxs("button",{type:"button",onClick:()=>o(!r),className:`flex w-full items-center gap-1 rounded py-0.5 text-left text-ink-muted hover:bg-surface/60 ${ne}`,style:{paddingLeft:6+t*12},title:e.path,children:[i.jsx("span",{className:"shrink-0",children:i.jsx(cr,{open:r})}),i.jsx("span",{className:`min-w-0 flex-1 ${ne}`,children:e.name})]}),r&&i.jsx(Dn,{dir:e,depth:t+1,selected:n,onSelect:s})]})}function Dn({dir:e,depth:t,selected:n,onSelect:s}){return i.jsxs(i.Fragment,{children:[e.dirs.map(r=>i.jsx(Jf,{dir:r,depth:t,selected:n,onSelect:s},r.path)),e.files.map(r=>{const o=r.path.split("/").pop()??r.path,a=r.path===n;return i.jsx("button",{type:"button",onClick:()=>s(r.path),className:`block w-full rounded py-0.5 pr-1 text-left ${ne} ${a?"bg-surface text-ink shadow-sm":"text-ink-muted hover:bg-surface/60"}`,style:{paddingLeft:20+t*12},title:r.path,children:o},r.path)})]})}function Gf({skill:e,path:t}){const n=m.useCallback(()=>ws(e,t),[e,t]),s=et(n,null);return s===null?i.jsx("p",{className:"text-sm text-ink-muted",children:"Loading…"}):i.jsx(Xi,{path:t,content:s,preClassName:"whitespace-pre-wrap break-words text-xs leading-relaxed [font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace]",renderedClassName:"rounded border border-border bg-surface p-3 text-sm shadow-sm"})}const zf=[{role:"agent",text:"Research is approved. Want me to start drafting, or is there anything in the notes you want changed first?",sentAt:"Jul 23, 9:38 AM"},{role:"user",text:"go ahead and draft",sentAt:"Jul 23, 9:41 AM"},{role:"agent",status:"running drafting",text:"Writing design.md and output/SKILL.md in the sandbox…",sentAt:"Jul 23, 9:41 AM"}];function Yf(){return i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[i.jsx("rect",{x:"5.5",y:"5.5",width:"8",height:"8",rx:"1.5"}),i.jsx("path",{d:"M10.5 5.5v-2a1.5 1.5 0 0 0-1.5-1.5h-5A1.5 1.5 0 0 0 2.5 3.5v5A1.5 1.5 0 0 0 4 10h1.5"})]})}function ro({text:e,sentAt:t,align:n}){const[s,r]=m.useState(!1),o=()=>{navigator.clipboard.writeText(e).then(()=>{r(!0),window.setTimeout(()=>r(!1),1200)})},a=i.jsx("button",{type:"button",className:"rounded p-1 hover:bg-surface hover:text-ink hover:shadow-sm",title:"Copy message",onClick:o,children:i.jsx(Yf,{})}),l=i.jsx("span",{children:s?"Copied":t});return i.jsx("div",{className:`flex h-6 items-center gap-1.5 text-xs text-ink-muted opacity-0 transition-opacity group-hover:opacity-100 ${n==="right"?"justify-end pr-1":"pl-0.5"}`,children:n==="left"?i.jsxs(i.Fragment,{children:[a,l]}):i.jsxs(i.Fragment,{children:[l,a]})})}function Xf({image:e}){const[t,n]=m.useState(!1);return i.jsx("button",{type:"button",className:"block overflow-hidden rounded border border-border",title:`${e.name??e.mimeType} — click to ${t?"shrink":"enlarge"}`,onClick:()=>n(!t),children:i.jsx("img",{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name??"attached image",className:t?"max-h-96 max-w-full":"h-16 w-auto"})})}function io({text:e,sentAt:t,images:n=[]}){return i.jsxs("div",{className:"group flex flex-col items-end pt-3",children:[i.jsxs("div",{className:"max-w-[85%] rounded-xl bg-amber-50 px-3 py-2 shadow-sm",children:[n.length>0&&i.jsx("div",{className:"flex flex-wrap justify-end gap-1.5 pb-1",children:n.map((s,r)=>i.jsx(Xf,{image:s},r))}),e.length>0&&i.jsx("p",{className:"whitespace-pre-wrap",children:e})]}),i.jsx("div",{className:"self-stretch",children:i.jsx(ro,{text:e,sentAt:t,align:"right"})})]})}function oo({text:e,sentAt:t,status:n}){return i.jsxs("div",{className:"group pt-3",children:[n&&i.jsx("div",{className:"pb-0.5 font-display text-xs text-ink-muted",children:n}),i.jsx("div",{className:n?"text-ink-muted":"",children:i.jsx(on,{markdown:e})}),i.jsx(ro,{text:e,sentAt:t,align:"left"})]})}function Zf({title:e,status:t}){return i.jsxs("div",{className:"mt-2 flex items-center gap-2 rounded border border-border bg-surface/60 px-2 py-1 text-xs text-ink-muted",title:`${e} — ${t}`,children:[i.jsx("span",{className:"truncate",children:e}),i.jsx("span",{className:"ml-auto shrink-0",children:t})]})}function Qf({item:e,onAnswer:t}){const{approve:n,deny:s}=Mf(e.options);return e.resolved!==void 0?i.jsxs("div",{className:"mt-2 rounded border border-border bg-surface/60 px-2 py-1 text-xs text-ink-muted",children:[e.title," — ",e.resolved.outcome]}):i.jsxs("div",{className:"mt-2 rounded-xl border border-amber-300 bg-amber-50/60 px-3 py-2 text-sm shadow-sm",children:[i.jsx("div",{className:"pb-0.5 font-display text-xs uppercase tracking-widest text-ink-muted",children:"permission"}),i.jsx("p",{className:"pb-2",children:e.title}),i.jsxs("div",{className:"flex gap-2",children:[n&&i.jsx("button",{type:"button",className:"rounded bg-amber-200 px-2 py-1 text-xs hover:bg-amber-300",onClick:()=>t(e.id,n.optionId,"allowed"),children:"Approve"}),s&&i.jsx("button",{type:"button",className:"rounded border border-border px-2 py-1 text-xs hover:bg-surface",onClick:()=>t(e.id,s.optionId,"denied"),children:"Deny"})]})]})}const Ht=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})};function eh({state:e,provider:t,onStart:n}){const s=e.resumable.find(r=>r.provider===t);return i.jsxs("div",{className:"px-3 pt-4 text-sm",children:[i.jsxs("p",{className:"text-ink-muted",children:["Start a session with ",i.jsx("span",{className:"font-display",children:t})," — or pick a different agent below."]}),i.jsxs("div",{className:"flex gap-2 pt-3",children:[s&&i.jsxs("button",{type:"button",className:"rounded bg-amber-200 px-2.5 py-1.5 text-xs hover:bg-amber-300",title:`Resume the session from ${Ht(s.updatedAt)}`,onClick:()=>n(t,"resume"),children:["Resume (",Ht(s.updatedAt),")"]}),i.jsx("button",{type:"button",className:`rounded px-2.5 py-1.5 text-xs ${s?"border border-border hover:bg-surface":"bg-amber-200 hover:bg-amber-300"}`,disabled:t.length===0,onClick:()=>n(t,"new"),children:s?"Start fresh":"Start"})]}),e.lastError&&i.jsx("p",{className:"pt-3 text-xs text-red-600",children:e.lastError})]})}function th(){return i.jsx(i.Fragment,{children:zf.map((e,t)=>e.role==="user"?i.jsx(io,{text:e.text,sentAt:e.sentAt},t):i.jsx(oo,{text:e.text,sentAt:e.sentAt,status:e.status},t))})}const nh=5*1024*1024;function sh(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:i.jsx("path",{d:"M13.2 7.3l-5 5a3.1 3.1 0 0 1-4.4-4.4l5.6-5.6a2.1 2.1 0 0 1 3 3l-5.6 5.6a1.1 1.1 0 0 1-1.6-1.6l5-5"})})}const rh=e=>new Promise(t=>{if(!e.type.startsWith("image/")){t(`"${e.name}" is not an image`);return}if(e.size>nh){t(`"${e.name}" is ${(e.size/(1024*1024)).toFixed(1)}MB — the limit is 5MB per image`);return}const n=new FileReader;n.onerror=()=>t(`could not read "${e.name}"`),n.onload=()=>{const s=String(n.result),r=s.indexOf(",");if(r===-1){t(`could not read "${e.name}"`);return}t({data:s.slice(r+1),mimeType:e.type,name:e.name})},n.readAsDataURL(e)});function ih({skill:e,intro:t=null,onIntroConsumed:n}){const s=bd(e),[r,o]=m.useState(""),[a,l]=m.useState(null),[c,u]=m.useState([]),[p,f]=m.useState(null),[h,x]=m.useState(void 0),g=m.useRef(null),y=m.useRef(null);m.useEffect(()=>{if(!s.available)return;let k=!1;return qi().then(M=>{k||x(M)}),()=>{k=!0}},[s.available]);const v=Df(s.events),b=s.state?.active??null,w=s.available&&b!==null&&b.status==="ready",j=b!==null?{provider:b.provider,...b.modelId!==void 0?{model:b.modelId}:{},...b.effort!==void 0?{effort:b.effort}:{}}:a??zi(h??null,s.state?.providers??[])??{provider:s.state?.defaultProvider??"claude-code"},C=Ud(h??null,j.provider),E=k=>{if(b===null){l(k);return}b.status==="ready"&&k.provider===b.provider&&k.model!==void 0&&s.setModel(k.model,k.effort)},O=m.useRef("start");m.useEffect(()=>{if(!(t===null||t.slug!==e||!s.available||s.state===void 0)){if(O.current==="start"&&(O.current="send",b===null)){s.start(t.provider,"new",t.model!==void 0?{model:t.model,...t.effort!==void 0?{effort:t.effort}:{}}:void 0);return}O.current==="send"&&b!==null&&b.status==="ready"&&(O.current="done",s.send(t.message),n?.())}},[t,e,s,b,n]),m.useEffect(()=>{const k=g.current;k&&(k.scrollTop=k.scrollHeight)},[v.length,b?.status]);const F=k=>{k.length!==0&&(f(null),Promise.all(k.map(rh)).then(M=>{const Y=M.filter(S=>typeof S!="string"),q=M.find(S=>typeof S=="string");Y.length>0&&u(S=>[...S,...Y]),q!==void 0&&f(q)}))},_=()=>{const k=r.trim();k.length===0&&c.length===0||!w||(s.send(k,c),o(""),u([]),f(null))};return i.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[i.jsxs("div",{ref:g,className:"h-full overflow-y-auto px-6 pb-28 text-sm",children:[!s.available&&i.jsx(th,{}),s.available&&s.state!==void 0&&b===null&&i.jsx(eh,{state:s.state,provider:j.provider,onStart:(k,M)=>s.start(k,M,j.model!==void 0?{model:j.model,...j.effort!==void 0?{effort:j.effort}:{}}:void 0)}),s.available&&b!==null&&b.status==="starting"&&i.jsx("p",{className:"pt-3 text-ink-muted",children:"Starting the agent…"}),s.available&&b!==null&&b.modelFallback!==void 0&&i.jsx("p",{className:"pt-2 text-xs text-amber-700 dark:text-amber-400",children:b.modelFallback}),s.available&&v.map((k,M)=>k.kind==="user"?i.jsx(io,{text:k.text,sentAt:Ht(k.t),images:k.images},M):k.kind==="agent"?i.jsx(oo,{text:k.text,sentAt:Ht(k.t)},M):k.kind==="tool"?i.jsx(Zf,{title:k.title,status:k.status},k.toolCallId):k.kind==="permission"?i.jsx(Qf,{item:k,onAnswer:s.answerPermission},k.id):i.jsx("div",{className:"mt-2 rounded border border-red-200 bg-red-50 px-2 py-1 text-xs text-red-700",children:k.message},M)),s.available&&b!==null&&b.status==="running"&&i.jsxs("div",{className:"flex items-center gap-2 pt-3 text-xs text-ink-muted",children:[i.jsx("span",{children:"running…"}),i.jsx("button",{type:"button",className:"rounded border border-border px-1.5 py-0.5 hover:bg-surface",onClick:s.cancelTurn,children:"Stop"})]}),s.actionError&&i.jsx("p",{className:"pt-2 text-xs text-red-600",children:s.actionError})]}),i.jsxs("div",{className:"absolute inset-x-2 bottom-2 rounded-xl border border-border bg-surface/95 shadow-lg backdrop-blur-sm focus-within:border-amber-300",children:[c.length>0&&i.jsx("div",{className:"flex flex-wrap gap-1.5 px-4 pt-3",children:c.map((k,M)=>i.jsxs("span",{className:"relative inline-block",children:[i.jsx("img",{src:`data:${k.mimeType};base64,${k.data}`,alt:k.name??"attachment",className:"h-12 w-auto rounded border border-border"}),i.jsx("button",{type:"button",className:"absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-ink text-[10px] leading-none text-white shadow dark:text-canvas",title:`Remove ${k.name??"image"}`,onClick:()=>u(Y=>Y.filter((q,S)=>S!==M)),children:"×"})]},M))}),p!==null&&i.jsx("p",{className:"px-4 pt-2 text-xs text-red-600",children:p}),i.jsx("input",{className:"w-full bg-transparent px-4 pb-1.5 pt-3.5 text-sm outline-none disabled:opacity-60",placeholder:w||!s.available?"What should we do?":b===null?"Choose a model to start":"Agent is working…",value:r,disabled:s.available&&!w,onChange:k=>o(k.target.value),onPaste:k=>{if(!C)return;const M=Array.from(k.clipboardData?.files??[]).filter(Y=>Y.type.startsWith("image/"));M.length>0&&(k.preventDefault(),F(M))},onKeyDown:k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),_())}}),i.jsxs("div",{className:"flex items-center justify-end gap-2 px-3 pb-3",children:[C&&i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:y,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,className:"hidden",onChange:k=>{F(Array.from(k.target.files??[])),k.target.value=""}}),i.jsx("button",{type:"button",className:"rounded p-1 text-ink-muted hover:bg-surface hover:text-ink disabled:opacity-35",title:"Attach images (or paste into the input)",disabled:s.available&&!w&&b!==null,onClick:()=>y.current?.click(),children:i.jsx(sh,{})})]}),i.jsx("span",{className:"flex-1"}),i.jsx(Yi,{catalog:h??null,providers:s.state?.providers??[],selection:j,onChange:E,disabled:b!==null&&b.status!=="ready",...b!==null?{lockProvider:b.provider}:{}}),i.jsx("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full bg-amber-600 text-white shadow hover:bg-amber-700 disabled:opacity-35",title:"Send",disabled:s.available&&!w,onClick:_,children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("line",{x1:"8",y1:"13",x2:"8",y2:"3.5"}),i.jsx("path",{d:"M4 7.5L8 3.5l4 4"})]})})]})]})]})}const oh=20,ah=6e3,ch=(e,t)=>{const n=e!==null&&Array.isArray(e.active)&&e.active.length>0,s=t!==null&&typeof t.active=="object"&&t.active!==null&&t.active.status==="running";return n||s},nr=async e=>{try{const t=await fetch(e,{headers:{accept:"application/json"}});return t.ok?await t.json():null}catch{return null}},sr=async e=>{const t=e.slice(0,oh),n=await Promise.all(t.map(async s=>{const[r,o]=await Promise.all([nr(`/api/bundles/${encodeURIComponent(s)}/runs-active`),nr(`/api/chat/${encodeURIComponent(s)}/state`)]);return r===null&&o===null?{slug:s,running:!1,reachable:!1}:{slug:s,running:ch(r,o),reachable:!0}}));if(n.length>0&&n.every(s=>!s.reachable))throw new Error("presence: server absent");return new Set(n.filter(s=>s.running).map(s=>s.slug))};function lh(e){const[t,n]=m.useState(new Set),s=m.useRef(!1),r=m.useRef(!1),o=e.join(`
|
|
27
|
+
`);m.useEffect(()=>{let l=!1;const c=o.length===0?[]:o.split(`
|
|
28
|
+
`),u=()=>{s.current||r.current||c.length===0||(r.current=!0,sr(c).then(f=>{l||n(f)}).catch(()=>{s.current=!0,l||n(new Set)}).finally(()=>{r.current=!1}))};u();const p=Qi(u);return()=>{l=!0,p()}},[o]);const a=t.size>0;return m.useEffect(()=>{if(!a||s.current)return;const l=o.length===0?[]:o.split(`
|
|
29
|
+
`),c=setInterval(()=>{s.current||r.current||l.length===0||(r.current=!0,sr(l).then(n).catch(()=>{s.current=!0,n(new Set)}).finally(()=>{r.current=!1}))},ah);return()=>clearInterval(c)},[a,o]),m.useMemo(()=>t,[t])}const ao=["Idea","Research","Drafting","Evals","Published"],rr={idea:"Idea",researching:"Research",drafting:"Drafting",evaluating:"Evals",published:"Published"},uh=e=>typeof e=="string"&&ao.includes(e),dh=e=>typeof e=="string"&&e in rr?rr[e]:uh(e)?e:"Idea",fh=e=>{if(typeof e!="object"||e===null)return null;const t=e;return typeof t.slug!="string"||t.slug.length===0?null:{slug:t.slug,stage:dh(t.stage),oneLiner:typeof t.oneLiner=="string"?t.oneLiner:"",awaitingReview:t.substate==="awaiting-review"}},hh=e=>{if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.name!="string"||t.name.length===0||typeof t.path!="string")return null;const n=Array.isArray(t.skills)?t.skills.map(fh).filter(s=>s!==null):[];return{name:t.name,path:t.path,skills:n}},ph=e=>{if(typeof e!="object"||e===null)return null;const t=e.projects;return Array.isArray(t)?t.map(hh).filter(n=>n!==null):null},mh=async()=>{try{const e=await fetch("/api/projects",{headers:{accept:"application/json"}});return e.ok?ph(await e.json()):null}catch{return null}},xh="sm-theme";function gh(){return document.documentElement.classList.contains("dark")?"dark":"light"}function bh(e){document.documentElement.classList.toggle("dark",e==="dark");try{localStorage.setItem(xh,e)}catch{}}const Un=5;function yh({center:e,onNavigate:t}){const[n,s]=m.useState(Ln),[r,o]=m.useState(()=>Object.fromEntries(Ln.map(h=>[h.name,!0]))),[a,l]=m.useState({}),u=et(no,so).filter(h=>h.state==="open").length,p=n.flatMap(h=>r[h.name]??!1?(a[h.name]??!1?h.skills:h.skills.slice(0,Un)).map(x=>x.slug):[]),f=lh(p);return m.useEffect(()=>{let h=!1;return mh().then(x=>{h||x===null||x.length===0||(s(x),o(Object.fromEntries(x.map(g=>[g.name,!0]))))}),()=>{h=!0}},[]),i.jsxs("div",{className:"flex h-full flex-col",children:[i.jsx("div",{className:"h-11 shrink-0"}),i.jsx("div",{className:"px-4 pb-2",children:i.jsx("span",{className:"font-display text-lg tracking-tight",children:"SKILLMAKER STUDIO"})}),i.jsxs("nav",{className:"px-2",children:[i.jsx(ir,{label:"Board",icon:i.jsx(vo,{}),active:e.kind==="board",onClick:()=>t({kind:"board"})}),i.jsx(ir,{label:"Tasks",icon:i.jsx(ko,{}),active:e.kind==="tasks",badge:u,onClick:()=>t({kind:"tasks"})})]}),i.jsxs("div",{className:"mt-4 flex-1 overflow-y-auto px-2",children:[i.jsxs("div",{className:"group flex items-center pb-1 pl-3 pr-1",children:[i.jsx("span",{className:"flex-1 text-xs uppercase tracking-widest text-ink-muted",children:"Projects"}),i.jsx("button",{type:"button",className:"shrink-0 rounded p-1 text-ink-muted opacity-0 transition-opacity hover:text-ink group-hover:opacity-100",title:"Register a project directory",children:i.jsx(lr,{})})]}),n.map(h=>i.jsx(kh,{project:h,open:r[h.name]??!1,expanded:a[h.name]??!1,center:e,running:f,onToggle:()=>o({...r,[h.name]:!(r[h.name]??!1)}),onToggleExpanded:()=>l({...a,[h.name]:!(a[h.name]??!1)}),onOpenSkill:x=>t({kind:"skill",project:h.name,slug:x}),onNewSkill:()=>t({kind:"new-skill",project:h.name})},h.name))]}),i.jsxs("div",{className:"flex items-center gap-1 border-t border-border px-3 py-2",children:[i.jsx("a",{href:"https://github.com/sociotechnica-org/skillmaker-studio",target:"_blank",rel:"noreferrer",className:"rounded p-1.5 text-ink-muted hover:bg-surface hover:text-ink",title:"GitHub",children:i.jsx(wo,{})}),i.jsx("a",{href:"#",className:"rounded p-1.5 text-ink-muted hover:bg-surface hover:text-ink",title:"Docs",children:i.jsx(jo,{})}),i.jsx(vh,{})]})]})}function vh(){const[e,t]=m.useState(null);if(m.useEffect(()=>{t(gh())},[]),e===null)return i.jsx("span",{className:"h-7 w-7"});const n=e==="dark"?"light":"dark";return i.jsx(Le,{title:n==="dark"?"Switch to dark mode":"Switch to light mode",onClick:()=>{bh(n),t(n)},children:e==="dark"?i.jsx(Co,{}):i.jsx(Eo,{})})}function ir({label:e,icon:t,active:n,badge:s,onClick:r}){return i.jsxs("button",{type:"button",onClick:r,className:`flex w-full items-center gap-2 rounded px-3 py-1.5 text-left font-display text-sm ${n?"bg-surface shadow-sm":"text-ink-muted hover:bg-surface/60"}`,children:[i.jsx("span",{className:"text-ink-muted",children:t}),i.jsx("span",{className:"flex-1",children:e}),s?i.jsx("span",{className:"rounded-full bg-amber-200 px-2 text-xs",children:s}):null]})}function kh({project:e,open:t,expanded:n,center:s,running:r,onToggle:o,onToggleExpanded:a,onOpenSkill:l,onNewSkill:c}){const u=n?e.skills:e.skills.slice(0,Un),p=e.skills.length-Un;return i.jsxs("div",{className:"mb-1",children:[i.jsxs("div",{className:"group flex items-center rounded pr-1 hover:bg-surface/60",children:[i.jsxs("button",{type:"button",onClick:o,className:"flex min-w-0 flex-1 items-center gap-1.5 px-3 py-1 text-left font-display text-sm",title:e.path,children:[i.jsx("span",{className:"shrink-0 text-ink-muted",children:i.jsx(cr,{open:t})}),i.jsx("span",{className:`min-w-0 flex-1 ${ne}`,children:e.name})]}),i.jsx("button",{type:"button",className:"shrink-0 rounded p-1 text-ink-muted opacity-0 transition-opacity hover:text-ink group-hover:opacity-100",title:"New skill · import",onClick:c,children:i.jsx(lr,{})})]}),i.jsx("div",{className:`grid transition-[grid-template-rows] duration-150 ease-out ${t?"[grid-template-rows:1fr]":"[grid-template-rows:0fr]"}`,children:i.jsxs("div",{className:"overflow-hidden",children:[u.map(f=>{const h=s.kind==="skill"&&s.project===e.name&&s.slug===f.slug;return i.jsxs("button",{type:"button",onClick:()=>l(f.slug),className:`flex w-full items-center gap-2 rounded py-1 pl-8 pr-2 text-left text-sm ${h?"bg-surface shadow-sm":"text-ink-muted hover:bg-surface/60"}`,children:[i.jsx("span",{className:`min-w-0 flex-1 ${ne}`,children:f.slug}),f.awaitingReview===!0&&i.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500",title:"Awaiting review"}),i.jsx(Vd,{stage:f.stage}),r.has(f.slug)&&i.jsx("span",{className:"h-3 w-3 shrink-0 animate-spin rounded-full border border-amber-500 border-t-transparent",title:"Running"})]},f.slug)}),p>0&&i.jsx("button",{type:"button",onClick:a,className:"py-0.5 pl-8 text-left text-xs text-ink-muted hover:text-ink",children:n?"Show less":`Show ${p} more`})]})})]})}const wh=3e3,co=async e=>{try{const t=await e.json();if(typeof t.error=="string")return t.error}catch{}return`request failed (${e.status})`},jh=async e=>{const t=await fetch(`/api/bundles/${encodeURIComponent(e)}/runs-active`);if(!t.ok)throw new Error(`runs-active: ${t.status}`);return await t.json()},Sh=async(e,t)=>{const n=await fetch(`/api/bundles/${encodeURIComponent(e)}/run`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({fixture:t})});return n.ok?null:co(n)},Nh=async e=>{const t=await fetch(`/api/bundles/${encodeURIComponent(e)}/run-all`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({})});return t.ok?null:co(t)};function Ch(e){const[t,n]=m.useState({active:[],runAll:null}),[s,r]=m.useState(null),[o,a]=m.useState(!1),l=m.useRef(!0);m.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const c=m.useCallback(async()=>{if(e.length!==0)try{const h=await jh(e);if(!l.current)return;n(h),a(h.active.length>0||h.runAll!==null)}catch{l.current&&a(!1)}},[e]);m.useEffect(()=>{c()},[c]),m.useEffect(()=>{if(!o)return;const h=setInterval(()=>void c(),wh);return()=>clearInterval(h)},[o,c]);const u=m.useCallback(async h=>{if(e.length===0)return;const x=await h();l.current&&(r(x),x===null&&(a(!0),c()))},[c,e]),p=m.useCallback(h=>void u(()=>Sh(e,h)),[u,e]),f=m.useCallback(()=>void u(()=>Nh(e)),[u,e]);return{activeFixtures:new Set(t.active.map(h=>h.fixture)),runAll:t.runAll,error:s,runFixture:p,runAllFixtures:f}}const lo=8,Eh={proven:"bg-emerald-100 text-emerald-800",failing:"bg-rose-100 text-rose-800",stale:"bg-amber-100 text-amber-800",unmeasured:"border border-border text-ink-muted"},Rh={proven:"●",failing:"✕",stale:"◔",unmeasured:"◌"},$h={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",partial:"bg-amber-100 text-amber-800"};function Ih({chips:e}){return i.jsx("span",{className:"flex shrink-0 gap-1",children:e.map(t=>i.jsxs("span",{title:`${t.model}: ${t.status}`,className:`rounded px-1 text-[10px] ${Eh[t.status]}`,children:[Rh[t.status]," ",t.model]},t.model))})}function _h({glance:e}){return e===void 0||e.state!=="ready"||e.value.skillInvoked===null?null:e.value.skillInvoked?i.jsx("span",{className:"rounded bg-sky-100 px-1 text-[10px] text-sky-800",title:"Transcript shows the skill was exercised",children:"invoked"}):i.jsx("span",{className:"rounded bg-rose-100 px-1 text-[10px] text-rose-800",title:"No evidence the skill was exercised — model-default behavior",children:"not invoked"})}const uo=e=>e.replace(/^sha256:/,"").slice(0,8),Th=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})};function Ah({page:e}){const t=e.evals,[n,s]=m.useState("latest"),[r,o]=m.useState(new Set),[a,l]=m.useState(new Set),[c,u]=m.useState({}),[p,f]=m.useState({}),[h,x]=m.useState({}),[g,y]=m.useState(new Set),[v,b]=m.useState(new Set),[w,j]=m.useState({}),C=t===null?[]:df(t.measurements),E=Ch(t?.slug??""),O=E.activeFixtures.size>0||E.runAll!==null,F=(S,R)=>{u(A=>A[R]!==void 0?A:($f(S.slug,R).then(I=>u(ye=>({...ye,[R]:{state:"ready",value:I}})),()=>u(I=>({...I,[R]:{state:"error"}}))),{...A,[R]:{state:"loading"}}))},_=(S,R)=>{f(A=>A[R]!==void 0?A:(If(S.slug,R).then(I=>f(ye=>({...ye,[R]:{state:"ready",value:I}})),()=>f(I=>({...I,[R]:{state:"error"}}))),{...A,[R]:{state:"loading"}}))},k=(S,R)=>{x(A=>A[R]!==void 0?A:(ws(S.slug,`runs/${R}/response.md`).then(I=>x(ye=>({...ye,[R]:{state:"ready",value:I}})),()=>x(I=>({...I,[R]:{state:"ready",value:null}}))),{...A,[R]:{state:"loading"}}))},M=S=>{const R=!r.has(S.id);if(o(A=>{const I=new Set(A);return I.has(S.id)?I.delete(S.id):I.add(S.id),I}),R&&t!==null)for(const A of S.fixtureCases){F(t,A);for(const I of er(t.runs,A).slice(0,lo))_(t,I.id)}},Y=S=>{const R=!a.has(S);l(A=>{const I=new Set(A);return I.has(S)?I.delete(S):I.add(S),I}),R&&t!==null&&(_(t,S),k(t,S))},q=S=>{if(t===null||v.has(S.id)||g.has(S.id))return;const R=pf({riskId:S.id,sentence:S.sentence,bundle:t.slug,id:`td-${crypto.randomUUID()}`,created:new Date().toISOString().slice(0,10)});b(A=>new Set(A).add(S.id)),j(({[S.id]:A,...I})=>I),rn({type:"todo.opened",payload:{todo:R.todo}}).then(A=>{A.ok?y(I=>new Set(I).add(S.id)):j(I=>({...I,[S.id]:A.error}))}).catch(A=>j(I=>({...I,[S.id]:A.message}))).finally(()=>b(A=>{const I=new Set(A);return I.delete(S.id),I}))};return i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t===null?i.jsx("span",{}):i.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[i.jsx("span",{className:"text-ink-muted",children:"Version:"}),[{id:"latest",label:t.latestVersionHash===null?"Latest (none recorded)":`Latest ${uo(t.latestVersionHash)}`},{id:"all",label:"All versions"}].map(S=>i.jsx("button",{type:"button",onClick:()=>s(S.id),className:`rounded-full px-2 py-0.5 font-display ${n===S.id?"bg-surface text-ink shadow-sm":"text-ink-muted hover:text-ink"}`,children:S.label},S.id))]}),i.jsxs("div",{className:"flex shrink-0 gap-2",children:[i.jsx(we,{label:"New claim"}),i.jsx(we,{label:gf(E.runAll,E.activeFixtures.size),primary:!0,disabled:t===null||O,onClick:E.runAllFixtures})]})]}),E.error!==null&&i.jsx("p",{className:"pt-1 text-right text-xs text-rose-700",children:E.error}),i.jsx("div",{className:"mt-1 space-y-2",children:xf(e.claims).map(S=>i.jsxs("div",{children:[i.jsx("div",{className:"pt-1 font-display text-[10px] uppercase tracking-wide text-ink-muted",children:S.family}),i.jsx("div",{className:"mt-1 space-y-1",children:S.claims.map(R=>{const A=t===null?[]:ff({measurements:t.measurements,fixtureCases:R.fixtureCases,scope:n,latestVersionHash:t.latestVersionHash,models:C}),I=t===null?R.status:hf(R.status,A),ye=r.has(R.id);return i.jsxs("div",{className:"rounded border border-border bg-surface px-3 py-2 shadow-sm",children:[i.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[i.jsx("span",{title:I,children:Bd[I]}),i.jsx("span",{className:"min-w-0 flex-1",children:R.sentence}),A.length>0&&i.jsx(Ih,{chips:A}),i.jsx("span",{className:"font-mono text-[10px] text-ink-muted",children:R.id}),i.jsx("span",{className:"rounded bg-neutral-100 px-1.5 text-[10px] text-ink-muted dark:bg-neutral-800",children:I})]}),i.jsx("div",{className:"pl-6 text-xs text-ink-muted",children:R.fixtures>0?t===null?`${R.fixtures} fixture${R.fixtures===1?"":"s"} · expand ▸`:i.jsxs("button",{type:"button",onClick:()=>M(R),className:"hover:text-ink",children:[R.fixtures," fixture",R.fixtures===1?"":"s"," · ",ye?"collapse ▾":"expand ▸"]}):g.has(R.id)?i.jsx("span",{className:"text-emerald-700",children:"queued ✓"}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",onClick:()=>q(R),title:"Mints a task",className:"underline hover:text-ink disabled:opacity-60",disabled:t===null||v.has(R.id),children:v.has(R.id)?"queueing…":"no fixture — add to Tasks"}),w[R.id]!==void 0&&i.jsx("span",{className:"pl-2 text-rose-700",children:w[R.id]})]})}),ye&&t!==null&&i.jsx("div",{className:"mt-2 space-y-2 border-l border-border pl-4",children:R.fixtureCases.map(Fe=>i.jsx(Oh,{caseName:Fe,running:E.activeFixtures.has(Fe),onRun:()=>E.runFixture(Fe),glance:c[Fe],runs:er(t.runs,Fe),runGlances:p,runResponses:h,expandedRuns:a,onToggleRun:Y},Fe))})]},R.id)})})]},S.family))}),t!==null&&t.unclaimed.length>0&&i.jsxs("p",{className:"pt-2 text-xs text-ink-muted",children:["Unclaimed fixtures — evidence without a claim: ",i.jsx("span",{className:"font-mono",children:t.unclaimed.join(", ")})]})]})}function Oh({caseName:e,running:t,onRun:n,glance:s,runs:r,runGlances:o,runResponses:a,expandedRuns:l,onToggleRun:c}){const u=r.slice(0,lo),p=r.length-u.length;return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"font-mono text-ink",children:e}),t?i.jsx("span",{className:"rounded bg-amber-100 px-1 text-[10px] text-amber-800",children:"running…"}):i.jsx("button",{type:"button",onClick:n,title:`Run fixture ${e} (same engine as skillmaker run)`,className:"rounded border border-border px-1 text-[10px] text-ink-muted hover:text-ink",children:"▸ Run"}),s!==void 0&&s.state==="ready"&&i.jsxs(i.Fragment,{children:[s.value.fixtureClass!==null&&i.jsx("span",{className:"rounded bg-neutral-100 px-1 text-[10px] text-ink-muted dark:bg-neutral-800",children:s.value.fixtureClass}),s.value.hasAnswerKey?i.jsx("span",{className:"rounded bg-emerald-100 px-1 text-[10px] text-emerald-800",title:"case.json carries an answer key",children:"answer key"}):i.jsx("span",{className:"rounded border border-border px-1 text-[10px] text-ink-muted",title:"No answer key authored yet",children:"no answer key"}),s.value.checkCount>0&&i.jsxs("span",{className:"text-[10px] text-ink-muted",children:[s.value.checkCount," check",s.value.checkCount===1?"":"s"]})]}),s!==void 0&&s.state==="error"&&i.jsx("span",{className:"text-[10px] text-rose-700",children:"fixture unreadable"})]}),i.jsx("div",{className:`text-xs text-ink-muted ${ne}`,children:s===void 0||s.state==="loading"?"Loading fixture…":s.state==="error"?"":s.value.summary??"(no prompt authored)"}),u.length===0?i.jsx("p",{className:"pt-1 text-[11px] text-ink-muted",children:"No runs yet."}):i.jsxs("div",{className:"mt-1 space-y-1",children:[u.map(f=>{const h=l.has(f.id);return i.jsxs("div",{children:[i.jsxs("button",{type:"button",onClick:()=>c(f.id),className:"flex w-full items-center gap-2 rounded bg-paper px-2 py-1 text-left text-[11px] hover:bg-neutral-100 dark:hover:bg-neutral-800",children:[i.jsx("span",{className:"shrink-0 text-ink-muted",children:h?"▾":"▸"}),i.jsx("span",{className:"shrink-0 text-ink-muted",children:Th(f.startedAt)}),i.jsxs("span",{className:`min-w-0 flex-1 ${ne}`,children:[f.provider," · ",f.model]}),i.jsx("span",{className:"shrink-0 text-ink-muted",children:f.status}),f.verdict!==null&&i.jsx("span",{className:`shrink-0 rounded px-1 text-[10px] ${$h[f.verdict]??""}`,children:f.verdict}),i.jsx(_h,{glance:o[f.id]})]}),h&&i.jsx(Ph,{run:f,glance:o[f.id],response:a[f.id]})]},f.id)}),p>0&&i.jsxs("p",{className:"text-[10px] text-ink-muted",children:["+",p," older run",p===1?"":"s"]})]})]})}function Ph({run:e,glance:t,response:n}){const s=t!==void 0&&t.state==="ready"?t.value.artifacts.filter(r=>!r.endsWith("response.md")):[];return i.jsxs("div",{className:"ml-4 mt-1 rounded border border-border bg-paper p-2",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[10px] text-ink-muted",children:[i.jsx("span",{className:"font-mono",children:e.id}),i.jsxs("span",{children:["version ",uo(e.versionHash)]}),t!==void 0&&t.state==="error"&&i.jsx("span",{className:"text-rose-700",children:"run detail unreadable"})]}),i.jsx("div",{className:"pt-1",children:n===void 0||n.state==="loading"?i.jsx("p",{className:"text-[11px] text-ink-muted",children:"Loading response…"}):n.state==="error"||n.value===null?i.jsx("p",{className:"text-[11px] text-ink-muted",children:"No response captured."}):i.jsx(Xi,{path:"response.md",content:n.value,preClassName:"max-h-60 overflow-auto rounded bg-surface p-2 font-mono text-[11px]",renderedClassName:"max-h-60 overflow-auto rounded border border-border bg-surface p-2"})}),s.length>0&&i.jsxs("p",{className:"pt-1 text-[10px] text-ink-muted",children:["Artifacts: ",i.jsx("span",{className:"font-mono",children:s.join(", ")})]}),i.jsx(Fh,{run:e})]})}function Fh({run:e}){const[t,n]=m.useState(null),[s,r]=m.useState(""),[o,a]=m.useState(!1),[l,c]=m.useState(null),[u,p]=m.useState(!1),f=x=>{n(x),a(!0),c(null);const g={id:e.id,verdict:x,...s.trim().length>0?{notes:s.trim()}:{}};rn({type:"run.graded",payload:g}).then(y=>{y.ok?p(!0):c(y.error)}).catch(y=>c(y.message)).finally(()=>a(!1))},h=e.verdict!==null;return i.jsxs("div",{className:"mt-2 border-t border-border pt-2",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[i.jsx("span",{className:"text-ink-muted",children:u&&t!==null?`Graded: ${t}`:h?`Graded: ${e.verdict} —`:"Grade this run:"}),!u&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",disabled:o,onClick:()=>f("pass"),className:"rounded border border-border bg-surface px-2 py-0.5 font-display hover:bg-emerald-50 disabled:opacity-50",children:h?"Regrade pass":"Pass"}),i.jsx("button",{type:"button",disabled:o,onClick:()=>f("fail"),className:"rounded border border-border bg-surface px-2 py-0.5 font-display hover:bg-rose-50 disabled:opacity-50",children:h?"Regrade fail":"Fail"}),i.jsx("input",{className:"min-w-0 flex-1 rounded border border-border bg-surface px-2 py-0.5 text-[11px] outline-none focus:border-amber-300",placeholder:"Notes (optional)",value:s,onChange:x=>r(x.target.value)})]})]}),l!==null&&i.jsx("p",{className:"pt-1 text-[10px] text-rose-700",children:l})]})}const Ie=e=>ks[e],Mh=async(e,t)=>{const n=await rn({type:"review.requested",payload:{bundle:e,state:t}});if(!n.ok)return{ok:!1,error:n.error};const s=await Ji(e,t,"approve",void 0);return s.ok?Gi(e,t):s};function Lh({loop:e}){return e.substate!=="awaiting-review"?null:i.jsx("div",{className:"pb-4",children:i.jsx(Uh,{loop:e})})}function Dh({loop:e}){const[t,n]=m.useState(!1),[s,r]=m.useState(null),[o,a]=m.useState(!1),l=Je.slice(0,Je.indexOf(e.stage)),[c,u]=m.useState(l[0]??"idea"),[p,f]=m.useState(""),h=Hi(e.stage),x=y=>{n(!0),r(null),y().then(v=>{n(!1),v.ok||r(v.error)})},g=h===void 0||e.substate==="awaiting-review"?null:e.approvedForForward?i.jsx(we,{primary:!0,disabled:t,label:`Move to ${Ie(h)}`,title:"The guard already allows this move (an approved review is on record).",onClick:()=>x(()=>Gi(e.slug,e.stage))}):i.jsx(we,{primary:!0,disabled:t,label:`Approve & move to ${Ie(h)}`,title:"Director sign-off: records the review pair (request, approve) in the journal, then advances.",onClick:()=>x(()=>Mh(e.slug,e.stage))});return g===null&&l.length===0?null:i.jsxs("div",{className:"pb-3",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g,l.length>0&&i.jsx("button",{type:"button",className:"rounded border border-border bg-canvas px-2.5 py-1 font-display text-xs text-ink-muted shadow-sm hover:bg-surface hover:text-ink",onClick:()=>a(!o),children:o?"Cancel":"Move to an earlier stage…"})]}),o&&l.length>0&&i.jsxs("div",{className:"mt-2 rounded border border-border bg-surface p-3 text-sm shadow-sm",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs text-ink-muted",children:"Back to"}),i.jsx("select",{className:"cursor-pointer rounded border border-border bg-transparent px-1.5 py-0.5 text-xs outline-none",value:c,onChange:y=>u(y.target.value),children:l.map(y=>i.jsx("option",{value:y,children:Ie(y)},y))})]}),i.jsx("textarea",{className:"mt-2 w-full rounded border border-border bg-transparent p-2 text-sm outline-none focus:border-amber-300",rows:2,placeholder:"Why is this going back? (required)",value:p,onChange:y=>f(y.target.value)}),i.jsx("div",{className:"pt-1",children:i.jsx(we,{disabled:t,label:`Move back to ${Ie(c)}`,onClick:()=>x(()=>_d(e.slug,e.stage,c,p))})})]}),s!==null&&i.jsx("p",{className:"pt-2 text-xs text-red-600",children:s})]})}function Uh({loop:e}){const[t,n]=m.useState(""),[s,r]=m.useState(!1),[o,a]=m.useState(null),l=e.pending,c=l?.requestedState,u=c!==void 0?`Review the ${Ie(c)} work`:"Review the submitted work",p=c!==void 0&&c!==e.stage?`Requested by the ${Ie(c)} station; this skill has since moved to ${Ie(e.stage)}.`:null,f=c??e.stage,h=x=>{r(!0),a(null),Ji(e.slug,f,x,t.length>0?t:void 0).then(g=>{r(!1),g.ok||a(g.error)})};return i.jsxs("div",{className:"rounded-xl border border-amber-300 bg-amber-50/60 p-4 shadow-sm",children:[i.jsx("div",{className:"pb-1 font-display text-xs uppercase tracking-widest text-ink-muted",children:"awaiting review"}),i.jsx("h2",{className:"font-display text-lg",children:u}),p!==null&&i.jsx("p",{className:"pt-1 text-xs text-ink-muted",children:p}),l?.question!==void 0&&i.jsx("p",{className:"pt-2 text-sm",children:l.question}),l!==void 0&&l.artifacts.length>0&&i.jsx("ul",{className:"pt-2 text-sm",children:l.artifacts.map(x=>i.jsx("li",{className:"font-mono text-xs text-ink-muted",children:x},x))}),i.jsx("textarea",{className:"mt-3 w-full rounded border border-border bg-surface p-2 text-sm outline-none focus:border-amber-300",rows:2,placeholder:"Notes — optional on approve, required to send back",value:t,onChange:x=>n(x.target.value)}),i.jsxs("div",{className:"flex gap-2 pt-2",children:[i.jsx(we,{primary:!0,disabled:s,label:"Approve",onClick:()=>h("approve")}),i.jsx(we,{disabled:s,label:"Send back with notes",title:"Send back requires notes — say what needs to change.",onClick:()=>h("revise")})]}),o!==null&&i.jsx("p",{className:"pt-2 text-xs text-red-600",children:o})]})}const Bh="relative z-10 -mb-px cursor-pointer rounded-t-lg border border-b-0 border-neutral-900/50 bg-well px-3 pb-1.5 pt-2 font-mono text-[11px] uppercase text-ink",Vh="cursor-pointer rounded-t-lg border border-b-0 border-border bg-canvas px-3 py-1.5 font-mono text-[11px] uppercase text-ink-muted hover:bg-well/70 hover:text-ink",Ue="current";function Wh({slug:e,page:t,pinned:n,onOpenFile:s}){const[r,o]=m.useState("overview"),a=g=>{const y=t.events.find(v=>g.some(b=>v.type.startsWith(b)));return y===void 0?"":`${y.type}-${y.at}`},l=a(["station.","review."]),c=a(["run."]),[u,p]=m.useState(()=>{if(typeof window>"u")return{};try{return JSON.parse(window.localStorage.getItem(`sm-tab-seen-${e}`)??"{}")}catch{return{}}}),f=(g,y)=>{const v={...u,[g]:y};p(v);try{window.localStorage.setItem(`sm-tab-seen-${e}`,JSON.stringify(v))}catch{}},h=r!=="research"&&l!==""&&u.research!==l,x=r!=="eval"&&c!==""&&u.eval!==c;return i.jsxs("div",{className:"flex min-h-full flex-col",children:[i.jsx("div",{className:"w-full px-6 pt-4",children:i.jsxs("div",{className:"mx-auto max-w-3xl",children:[t.loop!==null&&i.jsx(Lh,{loop:t.loop}),i.jsx("div",{className:"flex items-end gap-1",children:[{id:"overview",label:"Overview",onClick:()=>o("overview"),dot:!1},{id:"research",label:"Research",onClick:()=>{o("research"),f("research",l)},dot:h},{id:"eval",label:"Eval",onClick:()=>{o("eval"),f("eval",c)},dot:x},{id:"publish",label:"Publish",onClick:()=>o("publish"),dot:!1}].map(g=>i.jsxs("button",{type:"button",onClick:g.onClick,className:r===g.id?Bh:Vh,children:[g.label,g.dot&&i.jsx("span",{className:"ml-1.5 inline-block h-1.5 w-1.5 rounded-full bg-amber-500 align-middle"})]},g.id))})]})}),i.jsx("div",{className:"flex-1 border-t border-neutral-900/50 bg-well",children:i.jsxs("div",{className:"mx-auto max-w-3xl px-6 py-5",children:[r==="overview"&&i.jsx(Hh,{page:t,pinned:n,onOpenFile:s}),r==="research"&&i.jsx(zh,{slug:e,onOpenFile:s}),r==="eval"&&i.jsx(Ah,{page:t}),r==="publish"&&i.jsx(Yh,{page:t,pinned:n})]})})]})}function Kh({slug:e,page:t,pinned:n,onPin:s}){const[r,o]=m.useState(!1),[a,l]=m.useState(!1),c=t.versions.find(u=>u.hash===n);return i.jsxs("div",{className:"relative flex items-center gap-1.5",children:[i.jsx("button",{type:"button",className:`flex h-7 w-7 cursor-pointer items-center justify-center rounded hover:bg-surface ${n===Ue?"text-ink-muted hover:text-ink":"bg-amber-600/15 text-amber-700"}`,title:n===Ue?"Version history — every tab is a lens on the selected draft":`Viewing version ${c?.shortHash??n} — click to change`,onClick:()=>{l(!a),o(!1)},children:i.jsx(qh,{})}),a&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button","aria-label":"Close",className:"fixed inset-0 z-20 cursor-default",onClick:()=>l(!1)}),i.jsxs("div",{className:"absolute right-0 top-9 z-30 w-56 rounded border border-border bg-surface py-1 shadow-xl",children:[i.jsx(or,{selected:n===Ue,label:"Current draft",detail:null,onPick:()=>{s(Ue),l(!1)}}),t.versions.length>0&&i.jsx("div",{className:"mx-2 my-1 border-t border-border"}),t.versions.map(u=>i.jsx(or,{selected:n===u.hash,label:u.shortHash,detail:u.label,onPick:()=>{s(u.hash),l(!1)}},u.hash)),t.versions.length===0&&i.jsx("p",{className:"px-3 py-1.5 text-xs text-ink-muted",children:"No recorded versions yet."})]})]}),i.jsx("button",{type:"button",className:"cursor-pointer rounded bg-amber-600 px-3 py-1 font-display text-sm text-white shadow hover:bg-amber-700",onClick:()=>{o(!r),l(!1)},children:"Publish"}),r&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button","aria-label":"Close",className:"fixed inset-0 z-20 cursor-default",onClick:()=>o(!1)}),i.jsx("div",{className:"absolute right-0 top-9 z-30 w-72 rounded border border-border bg-surface p-3 shadow-xl",children:t.loop===null?i.jsx("p",{className:"text-xs text-ink-muted",children:"Stage actions need the server."}):i.jsx(Dh,{loop:t.loop})})]})]})}function qh(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[i.jsx("path",{d:"M 13.8 6.2 A 6 6 0 1 0 14 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),i.jsx("path",{d:"M 14.6 2.9 L 13.8 6.2 L 10.9 5.2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),i.jsx("path",{d:"M 8 5.2 V 8 L 10 9.4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}function or({selected:e,label:t,detail:n,onPick:s}){return i.jsxs("button",{type:"button",className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-well",onClick:s,children:[i.jsx("span",{className:`w-3 shrink-0 ${e?"text-ink":"text-transparent"}`,children:"✓"}),i.jsx("span",{className:e?"text-ink":"text-ink-muted",children:t}),n!==null&&i.jsx("span",{className:"truncate text-ink-muted/70",children:n})]})}function Hh({page:e,pinned:t,onOpenFile:n}){return i.jsxs("div",{className:"text-sm",children:[t!==Ue&&i.jsx("p",{className:"pb-2 text-xs text-ink-muted",children:"Showing the current draft — historical snapshots arrive with the version store."}),e.instructions===null?i.jsx("p",{className:"text-ink-muted",children:"No SKILL.md yet — start a chat and frame it."}):i.jsxs(i.Fragment,{children:[i.jsx(on,{markdown:Jh(e.instructions)}),i.jsx("button",{type:"button",className:"mt-3 cursor-pointer rounded border border-border bg-canvas px-3 py-1.5 font-display text-xs text-ink-muted hover:text-ink",onClick:()=>n("output/SKILL.md"),children:"Open full SKILL.md in Files"})]})]})}function Jh(e){const t=e.split(`
|
|
30
|
+
`);let n=0;const s=[];for(const r of t){if(/^#{1,3} /.test(r)&&(n+=1,n===2))break;s.push(r)}return s.join(`
|
|
31
|
+
`).trim()}const Gh=["research/notes.md","research/decisions.md"];function zh({slug:e,onOpenFile:t}){const n=m.useCallback(async()=>(await Promise.all(Gh.map(o=>ws(e,o).then(a=>({path:o,content:a}),()=>null)))).filter(o=>o!==null).map(o=>({path:o.path,content:o.content})),[e]),s=et(n,null);return i.jsxs("div",{className:"text-sm",children:[s===null&&i.jsx("p",{className:"text-ink-muted",children:"Loading research…"}),s!==null&&s.length===0&&i.jsx("p",{className:"text-ink-muted",children:"No research yet — run the research station or ask the agent to gather sources."}),s!==null&&s.map(r=>i.jsxs("details",{open:r.path.endsWith("notes.md"),className:"mb-3",children:[i.jsxs("summary",{className:"cursor-pointer font-display text-xs uppercase text-ink-muted hover:text-ink",children:[r.path.replace("research/",""),i.jsx("button",{type:"button",className:"ml-2 cursor-pointer text-[10px] underline",onClick:o=>{o.preventDefault(),t(r.path)},children:"open in Files"})]}),i.jsx("div",{className:"max-h-96 overflow-y-auto pt-1",children:i.jsx(on,{markdown:r.content})})]},r.path))]})}function Yh({page:e,pinned:t}){return i.jsxs("div",{className:"text-sm",children:[i.jsxs("p",{className:"text-ink-muted",children:["Publishing writes the selected draft over the skill's live ",i.jsx("span",{className:"font-mono text-xs",children:"SKILL.md"}),", stamped with its evidence state."]}),i.jsx("h3",{className:"pt-3 font-display text-xs uppercase text-ink-muted",children:"Versions"}),i.jsxs("div",{className:"mt-1 space-y-1",children:[i.jsx(ar,{active:t===Ue,title:"Current draft",subtitle:e.drift,action:i.jsx("button",{type:"button",className:"rounded bg-amber-600 px-2.5 py-1 font-display text-xs text-white opacity-50",title:"Publish flow lands with the version snapshot store — design in progress",disabled:!0,children:"Publish"})}),e.versions.map(n=>i.jsx(ar,{active:t===n.hash,title:n.shortHash+(n.label!==null?` · ${n.label}`:""),subtitle:`recorded ${new Date(n.recordedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}`,action:i.jsx("button",{type:"button",className:"rounded border border-border px-2.5 py-1 font-display text-xs text-ink-muted opacity-50",title:"Revert requires the version snapshot store (versions are hashes today, not content)",disabled:!0,children:"Revert"})},n.hash)),e.versions.length===0&&i.jsx("p",{className:"text-xs text-ink-muted",children:"No versions recorded yet."})]}),i.jsx("p",{className:"pt-3 text-xs text-ink-muted",children:"Evidence per version lives in the Eval tab — pin a version in the top bar and switch tabs to see its measurements."})]})}function ar({active:e,title:t,subtitle:n,action:s}){return i.jsxs("div",{className:`flex items-center gap-2 rounded border px-2 py-1.5 ${e?"border-amber-400 bg-canvas":"border-border"}`,children:[i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsx("span",{className:"font-mono text-xs",children:t}),i.jsx("span",{className:"pl-2 text-xs text-ink-muted",children:n})]}),s]})}function js(e){const t=m.useCallback(()=>Ef(e),[e]);return et(t,Vf)}function Xh({onOpenSkill:e}){const t=et(jf,Ln);return i.jsxs("div",{className:"p-6",children:[i.jsx("h1",{className:"pb-4 font-display text-2xl",children:"Board"}),i.jsx("div",{className:"grid grid-cols-5 gap-3",children:ao.map(n=>i.jsxs("div",{className:"rounded border border-border bg-paper p-2",children:[i.jsx("div",{className:`mb-2 inline-block rounded px-2 py-0.5 font-display text-xs ${vs[n]}`,children:n}),t.flatMap(s=>s.skills.filter(r=>r.stage===n).map(r=>i.jsxs("button",{type:"button",onClick:()=>e(s.name,r.slug),className:"mb-2 block w-full rounded bg-surface p-2 text-left shadow-sm hover:shadow",children:[i.jsx("div",{className:`font-display text-sm ${ne}`,children:r.slug}),i.jsx("div",{className:`text-xs text-ink-muted ${ne}`,children:s.name})]},`${s.name}/${r.slug}`)))]},n))}),i.jsx("p",{className:"pt-3 text-xs text-ink-muted",children:"All projects · Archived: drawer"})]})}function Zh(){const{data:e,status:t}=_f(no),n=t==="error"?so:e??[];return i.jsxs("div",{className:"p-6",children:[i.jsx("h1",{className:"pb-4 font-display text-2xl",children:"Tasks"}),t==="live"&&n.length===0&&i.jsx("p",{className:"text-sm text-ink-muted",children:"No open tasks."}),i.jsx("div",{className:"max-w-2xl space-y-2",children:n.map(s=>i.jsxs("div",{className:"flex items-center justify-between rounded border border-border bg-surface p-3 shadow-sm",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:`text-sm ${ne}`,children:s.title}),i.jsx("div",{className:"text-xs text-ink-muted",children:s.origin})]}),i.jsx(we,{label:s.state==="open"?"Start":"In progress"})]},s.title))})]})}function fo({slug:e,elevated:t}){const n=js(e);return i.jsxs("div",{className:`w-56 rounded border border-border bg-surface p-3 text-sm ${t?"shadow-xl":"shadow-md"}`,children:[i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-ink-muted",children:"Stage"}),i.jsx("span",{className:`rounded px-1.5 text-xs ${vs[n.stage]}`,children:n.stage})]}),i.jsxs("div",{className:"flex justify-between pt-1",children:[i.jsx("span",{className:"text-ink-muted",children:"Version"}),i.jsx("span",{className:"font-mono text-xs",children:n.versionShort??"none"})]}),i.jsxs("div",{className:"flex justify-between pt-1",children:[i.jsx("span",{className:"text-ink-muted",children:"Drift"}),i.jsx("span",{className:"text-xs",children:n.drift})]}),i.jsxs("div",{className:"flex justify-between pt-1",children:[i.jsx("span",{className:"text-ink-muted",children:"Proven on"}),i.jsx("span",{className:"text-xs",children:n.provenOn})]}),i.jsxs("div",{className:"flex justify-between pt-1",children:[i.jsx("span",{className:"text-ink-muted",children:"Coverage"}),i.jsx("span",{className:"text-xs",children:n.coverage})]})]})}function Qh({slug:e,pinned:t,overviewOpen:n,onOpenFile:s}){const r=js(e);return i.jsxs("div",{className:"flex min-h-full",children:[i.jsx("div",{className:"min-w-0 flex-1",children:i.jsx(Wh,{slug:e,page:r,pinned:t,onOpenFile:s})}),i.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-200 ease-out ${n?"w-[244px]":"w-0"}`,children:i.jsx("div",{className:"sticky top-0 mr-[10px] mt-[10px]",children:i.jsx(fo,{slug:e})})})]})}function ep({slug:e,pinned:t,onPin:n}){const s=js(e);return i.jsx(Kh,{slug:e,page:s,pinned:t,onPin:n})}function Sp(){const[e,t]=m.useState(!0),[n,s]=m.useState(!0),[r,o]=m.useState({kind:"skill",project:"skills",slug:"to-tickets"}),[a,l]=m.useState(!0),[c,u]=m.useState(null),[p,f]=m.useState("current"),[h,x]=m.useState(!1),[g,y]=m.useState(null),v=yn("left","sm-next-leftw",256,180,440),b=yn("right","sm-next-rightw",320,240,()=>Math.max(340,window.innerWidth-300-(e?v.width:0))),w=v.dragging||b.dragging,[j,C]=m.useState(!1),E=r.kind==="skill",O=E&&n,F=O&&j,_=r.kind==="board"?"Board":r.kind==="tasks"?"Tasks":r.kind==="new-skill"?"New skill":r.slug,k=a&&!O,M=()=>{O?x(!h):l(!a)},Y=q=>{if(!h)return;const S=q.target;S.closest("[data-overview-overlay]")||S.closest("[data-overview-toggle]")||x(!1)};return i.jsxs("div",{className:`relative flex h-screen overflow-hidden bg-canvas ${w?"cursor-col-resize select-none":""}`,onMouseDownCapture:Y,children:[i.jsx(Le,{active:e,onClick:()=>t(!e),title:e?"Hide sidebar":"Show sidebar",className:"absolute left-2 top-2 z-20",children:i.jsx(go,{})}),O&&i.jsx(Le,{active:j,onClick:()=>C(!j),title:j?"Restore layout":"Expand panel",className:"absolute right-10 top-2 z-20",children:j?i.jsx(No,{}):i.jsx(So,{})}),E&&i.jsx(Le,{active:n,onClick:()=>s(!n),title:n?"Hide panel":"Show panel",className:"absolute right-2 top-2 z-20",children:i.jsx(bo,{})}),i.jsxs("aside",{className:`relative shrink-0 overflow-hidden border-border bg-paper ${v.dragging?"":"transition-[width] duration-200 ease-out"} ${e?"border-r":""}`,style:{width:e?v.width:0},children:[i.jsx("div",{className:"h-full",style:{width:v.width},children:i.jsx(yh,{center:r,onNavigate:o})}),e&&i.jsx("div",{className:"absolute inset-y-0 right-0 z-10 w-2 cursor-col-resize hover:bg-amber-400/40",onMouseDown:v.onDragStart,title:"Drag to resize"})]}),i.jsxs("div",{className:`relative flex min-w-[300px] flex-col ${F?"hidden":"flex-1"}`,children:[r.kind==="skill"&&h&&i.jsx("div",{"data-overview-overlay":!0,className:"absolute right-[10px] top-[54px] z-30",children:i.jsx(fo,{slug:r.slug,elevated:!0})}),i.jsxs("header",{className:"flex h-11 shrink-0 items-center gap-1 border-b border-border px-3",children:[!e&&i.jsx("span",{className:"w-7 shrink-0"}),i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[(r.kind==="skill"||r.kind==="new-skill")&&i.jsxs("span",{className:"shrink-0 whitespace-nowrap font-display text-sm text-ink-muted",children:[r.project," /"]}),i.jsx("span",{className:"truncate font-display text-sm",title:_,children:_}),E&&i.jsx("span",{className:"text-ink-muted",children:"···"})]}),r.kind==="skill"&&i.jsx(ep,{slug:r.slug,pinned:p,onPin:f}),E&&i.jsx(Le,{active:k||h,onClick:M,title:k||h?"Hide overview":"Show overview","data-overview-toggle":!0,children:i.jsx(yo,{})}),E&&!n&&i.jsx("span",{className:"w-7 shrink-0"})]}),i.jsxs("main",{className:"relative flex-1 overflow-y-auto",children:[r.kind==="board"&&i.jsx(Xh,{onOpenSkill:(q,S)=>o({kind:"skill",project:q,slug:S})}),r.kind==="tasks"&&i.jsx(Zh,{}),r.kind==="skill"&&i.jsx(Qh,{slug:r.slug,pinned:p,overviewOpen:k,onOpenFile:q=>{s(!0),u(q)}}),r.kind==="new-skill"&&i.jsx(Wd,{project:r.project,onCreated:(q,S,R,A,I)=>{y({slug:q,provider:S,message:R,...A!==void 0?{model:A}:{},...I!==void 0?{effort:I}:{}}),o({kind:"skill",project:r.project,slug:q}),s(!0)},onAdopted:q=>o({kind:"skill",project:r.project,slug:q})})]})]}),i.jsxs("aside",{className:`relative overflow-hidden border-border bg-paper ${b.dragging||F?"":"transition-[width] duration-200 ease-out"} ${O?"border-l":""} ${F?"flex-1":"shrink-0"}`,style:F?void 0:{width:O?b.width:0},children:[O&&!F&&i.jsx("div",{className:"absolute inset-y-0 left-0 z-10 w-2 cursor-col-resize hover:bg-amber-400/40",onMouseDown:b.onDragStart,title:"Drag to resize"}),i.jsx("div",{className:"h-full",style:F?void 0:{width:b.width},children:E&&i.jsx(Kf,{skill:r.slug,width:F?9999:b.width,fileRequest:c,onFileRequestHandled:()=>u(null),intro:g!==null&&g.slug===r.slug?g:null,onIntroConsumed:()=>y(null)})})]})]})}export{Sp as default};
|