@devqubit/ui 0.1.11-beta.2 → 0.1.11-beta.3
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/dist/api/client.d.ts +9 -4
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/components/ExportRunButton/ExportRunButton.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +5 -5
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -7,6 +7,14 @@ export interface ApiConfig {
|
|
|
7
7
|
baseUrl?: string;
|
|
8
8
|
headers?: Record<string, string>;
|
|
9
9
|
}
|
|
10
|
+
export interface RequestOptions {
|
|
11
|
+
body?: unknown;
|
|
12
|
+
params?: Record<string, unknown>;
|
|
13
|
+
/** Per-request headers (merged with instance headers; per-request wins). */
|
|
14
|
+
headers?: Record<string, string>;
|
|
15
|
+
/** Fetch credentials mode (e.g. 'same-origin', 'include'). */
|
|
16
|
+
credentials?: RequestCredentials;
|
|
17
|
+
}
|
|
10
18
|
/**
|
|
11
19
|
* DevQubit API Client.
|
|
12
20
|
*
|
|
@@ -16,10 +24,7 @@ export declare class ApiClient {
|
|
|
16
24
|
protected baseUrl: string;
|
|
17
25
|
protected headers: Record<string, string>;
|
|
18
26
|
constructor(config?: ApiConfig);
|
|
19
|
-
protected request<T>(method: string, path: string, options?:
|
|
20
|
-
body?: unknown;
|
|
21
|
-
params?: Record<string, unknown>;
|
|
22
|
-
}): Promise<T>;
|
|
27
|
+
protected request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
23
28
|
getCapabilities(): Promise<Capabilities>;
|
|
24
29
|
listRuns(params?: {
|
|
25
30
|
project?: string;
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,OAAO,EACP,KAAK,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,EACT,MAAM,UAAU,CAAC;AAElB,qBAAa,QAAS,SAAQ,KAAK;IAExB,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED;;;;GAIG;AACH,qBAAa,SAAS;IACpB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAE9B,MAAM,GAAE,SAAc;cAQlB,OAAO,CAAC,CAAC,EACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,OAAO,EACP,KAAK,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,EACT,MAAM,UAAU,CAAC;AAElB,qBAAa,QAAS,SAAQ,KAAK;IAExB,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,8DAA8D;IAC9D,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED;;;;GAIG;AACH,qBAAa,SAAS;IACpB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAE9B,MAAM,GAAE,SAAc;cAQlB,OAAO,CAAC,CAAC,EACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,CAAC,CAAC;IAiCP,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC;IAIxC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAI5C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,SAAS,CAAA;KAAE,CAAC;IAIlD,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAMxE,YAAY,CAAC,MAAM,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;IAI/E,UAAU,CAAC,MAAM,CAAC,EAAE;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,KAAK,EAAE,CAAA;KAAE,CAAC;IAI1B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC;IAI5E,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QACrD,KAAK,EAAE,UAAU,CAAC;QAClB,KAAK,EAAE,UAAU,CAAC;QAClB,MAAM,EAAE,UAAU,CAAC;KACpB,CAAC;IAMI,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QACvD,QAAQ,EAAE,QAAQ,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,iBAAiB,EAAE,OAAO,CAAC;QAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IAIF,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAItD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QACzC,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,EAAE,MAAM,EAAE,CAAC;KAC3B,CAAC;IAII,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAC1C,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IAIF,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAG5C;AAED,eAAO,MAAM,GAAG,WAAkB,CAAC"}
|
package/dist/api/index.d.ts
CHANGED
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpD,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpD,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportRunButton.d.ts","sourceRoot":"","sources":["../../../src/components/ExportRunButton/ExportRunButton.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,WAAW,oBAAoB;IACnC,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;IAC5C,kBAAkB;IAClB,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,OAAO,CAAC;IAChF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,OAAO,EACP,OAAqB,EACrB,IAAW,EACX,SAAc,GACf,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"ExportRunButton.d.ts","sourceRoot":"","sources":["../../../src/components/ExportRunButton/ExportRunButton.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,WAAW,oBAAoB;IACnC,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;IAC5C,kBAAkB;IAClB,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,OAAO,CAAC;IAChF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,OAAO,EACP,OAAqB,EACrB,IAAW,EACX,SAAc,GACf,EAAE,oBAAoB,2CAsLtB"}
|
package/dist/hooks/useTheme.d.ts
CHANGED
|
@@ -12,18 +12,18 @@ export interface ThemeProviderProps {
|
|
|
12
12
|
storageKey?: string;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Theme Provider
|
|
15
|
+
* Default Theme Provider — always resolves to 'light'.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Override by providing your own ThemeProvider that satisfies
|
|
18
|
+
* the same ThemeContextValue interface.
|
|
19
19
|
*/
|
|
20
20
|
export declare function ThemeProvider({ children }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
21
21
|
/**
|
|
22
|
-
* Hook to access theme context
|
|
22
|
+
* Hook to access theme context.
|
|
23
23
|
*/
|
|
24
24
|
export declare function useTheme(): ThemeContextValue;
|
|
25
25
|
/**
|
|
26
|
-
* Hook that returns theme context or defaults if not in ThemeProvider
|
|
26
|
+
* Hook that returns theme context or defaults if not in ThemeProvider.
|
|
27
27
|
*/
|
|
28
28
|
export declare function useThemeOptional(): ThemeContextValue;
|
|
29
29
|
//# sourceMappingURL=useTheme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEhD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,EAAE,OAAO,GAAG,MAAM,CAAC;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAID,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CAa7D;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAW5C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,iBAAiB,CAEpD"}
|
package/dist/index.cjs
CHANGED
|
@@ -11,4 +11,4 @@ Check the top-level render call using <`+x+">.")}return l}}function wt(s,l){{if(
|
|
|
11
11
|
<%s {...props} />
|
|
12
12
|
React keys must be passed directly to JSX without using spread:
|
|
13
13
|
let props = %s;
|
|
14
|
-
<%s key={someKey} {...props} />`,Qe,de,ks,de),Et[de+Qe]=!0}}return s===n?Es(F):Rs(F),F}}function Ss(s,l,x){return St(s,l,x,!0)}function Cs(s,l,x){return St(s,l,x,!1)}var Ts=Cs,Ps=Ss;we.Fragment=n,we.jsx=Ts,we.jsxs=Ps})()),we}var Pt;function Fs(){return Pt||(Pt=1,process.env.NODE_ENV==="production"?Oe.exports=As():Oe.exports=Ls()),Oe.exports}var e=Fs();class je extends Error{constructor(r,a){super(a),this.status=r,this.name="ApiError"}}class Dt{baseUrl;headers;constructor(r={}){this.baseUrl=r.baseUrl??"",this.headers={"Content-Type":"application/json",...r.headers}}async request(r,a,n={}){let o=`${this.baseUrl}${a}`;if(n.params){const u=new URLSearchParams;Object.entries(n.params).forEach(([f,h])=>{h!=null&&h!==""&&u.set(f,String(h))});const i=u.toString();i&&(o+=`?${i}`)}const d=await fetch(o,{method:r,headers:this.headers,body:n.body?JSON.stringify(n.body):void 0});if(!d.ok){const u=await d.json().catch(()=>({detail:"Unknown error"}));throw new je(d.status,u.detail||d.statusText)}if(!(d.status===204||d.headers.get("content-length")==="0"))return d.json()}async getCapabilities(){return this.request("GET","/api/v1/capabilities")}async listRuns(r){return this.request("GET","/api/runs",{params:r})}async getRun(r){return this.request("GET",`/api/runs/${r}`)}async deleteRun(r){await this.request("DELETE",`/api/runs/${r}`)}async setBaseline(r,a){return this.request("POST",`/api/projects/${r}/baseline/${a}`,{params:{redirect:"false"}})}async listProjects(r){return this.request("GET","/api/projects",{params:r})}async listGroups(r){return this.request("GET","/api/groups",{params:r})}async getGroup(r){return this.request("GET",`/api/groups/${r}`)}async getDiff(r,a){return this.request("GET","/api/diff",{params:{a:r,b:a}})}async getArtifact(r,a){return this.request("GET",`/api/runs/${r}/artifacts/${a}`)}getArtifactDownloadUrl(r,a){return`${this.baseUrl}/api/runs/${r}/artifacts/${a}/raw`}async createExport(r){return this.request("POST",`/api/runs/${r}/export`)}async getExportInfo(r){return this.request("GET",`/api/runs/${r}/export/info`)}getExportDownloadUrl(r){return`${this.baseUrl}/api/runs/${r}/export/download`}}const At=new Dt;function Q(t){return t?.slice(0,8)??""}function $e(t){return t?.slice(0,12)??"N/A"}function Se(t){const r=new Date(t),n=Math.floor((new Date().getTime()-r.getTime())/1e3);if(n<60)return"just now";if(n<3600){const d=Math.floor(n/60);return`${d} minute${d!==1?"s":""} ago`}if(n<86400){const d=Math.floor(n/3600);return`${d} hour${d!==1?"s":""} ago`}if(n<2592e3){const d=Math.floor(n/86400);return`${d} day${d!==1?"s":""} ago`}if(n<31536e3){const d=Math.floor(n/2592e3);return`${d} month${d!==1?"s":""} ago`}const o=Math.floor(n/31536e3);return`${o} year${o!==1?"s":""} ago`}function Lt(t,r=6){return typeof t!="number"||isNaN(t)?String(t):Number(t.toPrecision(r)).toString()}function Ee(t){return t<1024?`${t} bytes`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1048576).toFixed(1)} MB`}function Ft(t){return JSON.stringify(t,null,2)}function Ot(t,r=60){return t?t.length<=r?t:t.slice(0,r-3)+"...":""}function Os(t,r){const a=new URLSearchParams;Object.entries(r).forEach(([o,d])=>{d!=null&&d!==""&&a.set(o,String(d))});const n=a.toString();return n?`${t}?${n}`:t}function O(...t){return t.filter(Boolean).join(" ")}function et(t,r){const a=new Date(t).getTime(),n=r?new Date(r).getTime():Date.now();return Math.max(0,Math.floor((n-a)/1e3))}function tt(t){if(t<60)return`${t}s`;const r=Math.floor(t/86400),a=Math.floor(t%86400/3600),n=Math.floor(t%3600/60),o=t%60;return r>0?`${r}d ${a}h ${n}m`:a>0?`${a}h ${n}m ${o}s`:`${n}m ${o}s`}function Ie(t){return t==="FINISHED"||t==="FAILED"||t==="KILLED"}const $t=p.createContext(null);function $s({children:t}){const r={theme:"light",resolvedTheme:"light",setTheme:()=>{},toggleTheme:()=>{}};return e.jsx($t.Provider,{value:r,children:t})}function Bt(){const t=p.useContext($t);return t||{theme:"light",resolvedTheme:"light",setTheme:()=>{},toggleTheme:()=>{}}}function Bs(){return Bt()}const st=1e3,It=p.createContext(null);function qt({children:t,api:r=At,initialWorkspace:a=null}){const[n,o]=p.useState(null),[d,u]=p.useState(a);return p.useEffect(()=>{r.getCapabilities().then(o).catch(console.error)},[r]),e.jsx(It.Provider,{value:{api:r,capabilities:n,currentWorkspace:d,setCurrentWorkspace:u},children:t})}function V(){const t=p.useContext(It);if(!t)throw new Error("useApp must be used within AppProvider");return t}function ue(t,r=[]){const[a,n]=p.useState({data:null,loading:!0,error:null}),o=p.useRef(!0),d=p.useRef(t);d.current=t;const u=p.useCallback(async()=>{n(i=>({...i,loading:!0,error:null}));try{const i=await d.current();o.current&&n({data:i,loading:!1,error:null})}catch(i){o.current&&n({data:null,loading:!1,error:i instanceof je?i:new je(500,String(i))})}},[]);return p.useEffect(()=>(o.current=!0,u(),()=>{o.current=!1}),r),{...a,refetch:u}}function rt(t,r,a){p.useEffect(()=>{if(!a)return;const n=setInterval(t,r),o=()=>{document.visibilityState==="visible"&&t()};return document.addEventListener("visibilitychange",o),()=>{clearInterval(n),document.removeEventListener("visibilitychange",o)}},[t,r,a])}function nt(t){const{api:r,currentWorkspace:a}=V(),n=ue(()=>r.listRuns({...t,workspace:a?.id}),[r,a?.id,t?.project,t?.status,t?.q,t?.limit]);return rt(n.refetch,st,!0),n}function at(t){const{api:r}=V(),a=ue(async()=>{const{run:o}=await r.getRun(t);return o},[r,t]),n=a.data?!Ie(a.data.status):!1;return rt(a.refetch,st,n),a}function Ce(){const{api:t,currentWorkspace:r}=V();return ue(async()=>{const{projects:a}=await t.listProjects({workspace:r?.id});return a},[t,r?.id])}function Mt(t){const{api:r,currentWorkspace:a}=V();return ue(async()=>{const{groups:n}=await r.listGroups({...t,workspace:a?.id});return n},[r,a?.id,t?.project])}function Ut(t){const{api:r}=V();return ue(()=>r.getGroup(t),[r,t])}function Gt(t,r){const{api:a}=V();return ue(()=>a.getDiff(t,r),[a,t,r])}function Wt(t,r){const{api:a}=V();return ue(()=>a.getArtifact(t,r),[a,t,r])}function pe(t){const[r,a]=p.useState(!1),[n,o]=p.useState(null);return{mutate:p.useCallback(async(...u)=>{a(!0),o(null);try{return await t(...u)}catch(i){const f=i instanceof je?i:new je(500,String(i));throw o(f),f}finally{a(!1)}},[t]),loading:r,error:n}}const Is=[{href:"/runs",label:"Runs",matchPaths:["/runs"]},{href:"/projects",label:"Projects",matchPaths:["/projects"]},{href:"/groups",label:"Groups",matchPaths:["/groups"]},{href:"/diff",label:"Compare",matchPaths:["/diff"]},{href:"/search",label:"Search",matchPaths:["/search"]}],Vt=p.createContext(null);function qs({config:t,children:r}){return e.jsx(Vt.Provider,{value:t,children:r})}function zt(){return p.useContext(Vt)}function W({children:t,config:r}){const a=k.useLocation(),o={...zt(),...r},d=o?.navLinks??Is,u=[...o?.prependNavLinks??[],...d,...o?.appendNavLinks??[]],i=o?.logo??{text:"devqubit",icon:"⚛"},f=h=>h.matchPaths?h.matchPaths.some(m=>a.pathname.startsWith(m)):a.pathname===h.href;return e.jsxs("div",{className:"dq-layout",children:[e.jsx("header",{className:"dq-header",children:e.jsxs("div",{className:"dq-header-inner",children:[e.jsxs("div",{className:"dq-header-left",children:[e.jsxs(k.Link,{to:"/",className:"dq-logo",children:[i.icon&&e.jsx("span",{className:"dq-logo-icon",children:i.icon}),i.text]}),e.jsx("nav",{className:"dq-nav",children:u.map(h=>e.jsx(k.Link,{to:h.href,className:O("dq-nav-link",f(h)&&"active"),children:h.label},h.href))})]}),e.jsx("div",{className:"dq-header-right",children:o?.headerRight})]})}),e.jsx("main",{className:"dq-main fade-in",children:t})]})}function ge({title:t,subtitle:r,actions:a}){return e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:t}),r&&e.jsx("p",{className:"text-sm text-muted mt-1",children:r})]}),a&&e.jsx("div",{className:"flex gap-2",children:a})]})}function H({variant:t="gray",className:r,children:a,...n}){return e.jsx("span",{className:O("badge",`badge-${t}`,r),...n,children:a})}const D=p.forwardRef(({variant:t="secondary",size:r="default",loading:a,className:n,children:o,disabled:d,...u},i)=>e.jsxs("button",{ref:i,className:O("btn",t==="ghost-danger"?"btn-ghost-danger":`btn-${t}`,r==="sm"&&"btn-sm",n),disabled:d||a,...u,children:[a&&e.jsx(I,{}),o]}));D.displayName="Button";function b({className:t,children:r,...a}){return e.jsx("div",{className:O("card",t),...a,children:r})}function U({className:t,children:r,...a}){return e.jsx("div",{className:O("card-header",t),...a,children:r})}function G({className:t,children:r,...a}){return e.jsx("h3",{className:O("card-title",t),...a,children:r})}function Ms({variant:t="info",className:r,children:a,...n}){return e.jsx("div",{className:O("alert",`alert-${t}`,r),...n,children:a})}function I({className:t,...r}){return e.jsx("span",{className:O("spinner",t),...r})}function le({message:t,hint:r,className:a,...n}){return e.jsxs("div",{className:O("empty-state",a),...n,children:[e.jsx("p",{children:t}),r&&e.jsx("p",{className:"text-sm text-muted mt-2",children:r})]})}function Be({items:t,className:r,...a}){return e.jsx("dl",{className:O("kv-list",r),...a,children:t.map(({label:n,value:o})=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{children:n}),e.jsx("dd",{children:o})]},n))})}function qe({open:t,onClose:r,title:a,children:n,actions:o}){return t?e.jsx("div",{className:O("modal-backdrop",t&&"active"),onClick:d=>d.target===d.currentTarget&&r(),children:e.jsxs("div",{className:"modal",onClick:d=>d.stopPropagation(),children:[e.jsx("h3",{className:"modal-title",children:a}),e.jsx("div",{className:"modal-body",children:n}),o&&e.jsx("div",{className:"modal-actions",children:o})]})}):null}function ve({message:t,variant:r="info",visible:a,onClose:n}){if(!a)return null;const o={success:"✓",error:"✕",info:"i"}[r],d={success:"text-[#059669]",error:"text-[#DC4A4A]",info:"text-[#2563EB]"}[r];return e.jsxs("div",{className:"toast",onClick:n,children:[e.jsx("span",{className:O("mr-2 font-bold",d),children:o}),t]})}function Z({children:t,className:r}){return e.jsx("div",{className:O("form-group",r),children:t})}function ne({className:t,children:r,...a}){return e.jsx("label",{className:O("form-label",t),...a,children:r})}const Me=p.forwardRef(({className:t,...r},a)=>e.jsx("input",{ref:a,className:O("form-input",t),...r}));Me.displayName="Input";const ce=p.forwardRef(({className:t,children:r,...a},n)=>e.jsx("select",{ref:n,className:O("form-input",t),...a,children:r}));ce.displayName="Select";function it({children:t,className:r}){return e.jsx("div",{className:O("form-row",r),children:t})}function $({className:t,children:r,...a}){return e.jsx("table",{className:O("table",t),...a,children:r})}function se({className:t,children:r,...a}){return e.jsx("thead",{className:t,...a,children:r})}function B({className:t,children:r,...a}){return e.jsx("tbody",{className:t,...a,children:r})}function j({className:t,children:r,...a}){return e.jsx("tr",{className:t,...a,children:r})}function N({className:t,children:r,...a}){return e.jsx("th",{className:t,...a,children:r})}function c({className:t,children:r,...a}){return e.jsx("td",{className:t,...a,children:r})}function ct({status:t}){const r={FINISHED:"success",FAILED:"danger",KILLED:"gray",RUNNING:"warning",UNKNOWN:"gray"}[t];return e.jsx(H,{variant:r,children:t})}function Us({createdAt:t,endedAt:r,status:a}){const n=!Ie(a),[o,d]=p.useState(Date.now());p.useEffect(()=>{if(!n)return;const h=setInterval(()=>d(Date.now()),1e3);return()=>clearInterval(h)},[n]);const i=et(t,n?void 0:r),f=n?Math.max(0,Math.floor((o-new Date(t).getTime())/1e3)):i;return e.jsx("span",{className:n?"tabular-nums":void 0,children:tt(f)})}function Ue({runs:t,onDelete:r,loading:a,emptyHint:n,baselineRunId:o}){const[d,u]=p.useState(null),i=()=>{d&&r&&(r(d.run_id),u(null))};return t.length?e.jsxs(e.Fragment,{children:[e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Run ID"}),e.jsx(N,{children:"Name"}),e.jsx(N,{children:"Project"}),e.jsx(N,{children:"Status"}),e.jsx(N,{children:"Duration"}),e.jsx(N,{children:"Created"}),e.jsx(N,{children:"Actions"})]})}),e.jsx(B,{children:t.map(f=>e.jsxs(j,{children:[e.jsxs(c,{children:[e.jsx(k.Link,{to:`/runs/${f.run_id}`,className:"font-mono",children:Q(f.run_id)}),f.run_id===o&&e.jsx(H,{variant:"info",className:"ml-2",children:"Baseline"})]}),e.jsx(c,{children:f.run_name||"—"}),e.jsx(c,{children:f.project}),e.jsx(c,{children:e.jsx(ct,{status:f.status})}),e.jsx(c,{className:"font-mono text-sm",children:e.jsx(Us,{createdAt:f.created_at,endedAt:f.ended_at,status:f.status})}),e.jsx(c,{className:"text-muted",children:Se(f.created_at)}),e.jsx(c,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k.Link,{to:`/runs/${f.run_id}`,children:e.jsx(D,{variant:"secondary",size:"sm",children:"View"})}),r&&e.jsx(D,{variant:"ghost-danger",size:"sm",onClick:()=>u(f),disabled:a,children:"Delete"})]})})]},f.run_id))})]}),e.jsxs(qe,{open:!!d,onClose:()=>u(null),title:"Delete Run",actions:e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"secondary",onClick:()=>u(null),children:"Cancel"}),e.jsxs(D,{variant:"danger",onClick:i,disabled:a,children:[a&&e.jsx(I,{}),"Delete"]})]}),children:[e.jsx("p",{children:"Are you sure you want to delete this run?"}),d&&e.jsx("p",{className:"font-mono text-sm mt-2",children:Q(d.run_id)}),e.jsx("p",{className:"text-sm text-danger mt-2",children:"This action cannot be undone."})]})]}):e.jsx(le,{message:"No runs found",hint:n??"Try adjusting your filters"})}function Yt(){const[t,r]=k.useSearchParams(),{api:a}=V(),{data:n}=Ce(),[o,d]=p.useState(null),[u,i]=p.useState({project:t.get("project")||"",status:t.get("status")||"",q:t.get("q")||"",limit:parseInt(t.get("limit")||"25",10)}),{data:f,loading:h,refetch:m}=nt(u),g=pe(w=>a.deleteRun(w));p.useEffect(()=>{if(o){const w=setTimeout(()=>d(null),3e3);return()=>clearTimeout(w)}},[o]);const _=p.useCallback((w,K)=>{i(q=>({...q,[w]:K}));const T=new URLSearchParams(t);K?T.set(w,String(K)):T.delete(w),r(T,{replace:!0})},[t,r]),z=p.useCallback(async w=>{try{await g.mutate(w),d({message:"Run deleted",variant:"success"}),m()}catch{d({message:"Failed to delete run",variant:"error"})}},[g,m]);return e.jsxs(W,{children:[e.jsx(ge,{title:"Runs"}),e.jsx(b,{className:"mb-4",children:e.jsxs(it,{children:[e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"project",children:"Project"}),e.jsxs(ce,{id:"project",value:u.project,onChange:w=>_("project",w.target.value),children:[e.jsx("option",{value:"",children:"All projects"}),n?.map(w=>e.jsx("option",{value:w.name,children:w.name},w.name))]})]}),e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"status",children:"Status"}),e.jsxs(ce,{id:"status",value:u.status,onChange:w=>_("status",w.target.value),children:[e.jsx("option",{value:"",children:"All"}),e.jsx("option",{value:"FINISHED",children:"Finished"}),e.jsx("option",{value:"FAILED",children:"Failed"}),e.jsx("option",{value:"RUNNING",children:"Running"})]})]}),e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"q",children:"Query"}),e.jsx(Me,{id:"q",value:u.q,onChange:w=>_("q",w.target.value),placeholder:"metric.fidelity > 0.9"})]}),e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"limit",children:"Limit"}),e.jsxs(ce,{id:"limit",value:u.limit,onChange:w=>_("limit",parseInt(w.target.value,10)),children:[e.jsx("option",{value:"25",children:"25"}),e.jsx("option",{value:"50",children:"50"}),e.jsx("option",{value:"100",children:"100"})]})]}),e.jsxs(Z,{className:"flex items-end gap-2",children:[e.jsx(D,{variant:"primary",onClick:()=>m(),children:"Filter"}),h&&e.jsx(I,{})]})]})}),e.jsx(b,{children:h&&!f?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(I,{})}):e.jsx(Ue,{runs:f?.runs??[],onDelete:z,loading:g.loading,baselineRunId:u.project?n?.find(w=>w.name===u.project)?.baseline?.run_id:void 0})}),o&&e.jsx(ve,{message:o.message,variant:o.variant,visible:!!o,onClose:()=>d(null)})]})}function Ht({projects:t,currentWorkspace:r}){if(!t.length)return e.jsx(le,{message:"No projects yet",hint:"Projects are created automatically when you log runs"});const a=n=>{const o=new URLSearchParams({project:n});return r&&o.set("workspace",r.id),`/runs?${o}`};return e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Project"}),e.jsx(N,{children:"Runs"}),e.jsx(N,{children:"Baseline"}),e.jsx(N,{})]})}),e.jsx(B,{children:t.map(n=>e.jsxs(j,{children:[e.jsxs(c,{children:[e.jsx("span",{className:"font-medium",children:n.name}),n.description&&e.jsx("p",{className:"text-muted text-sm",children:Ot(n.description)})]}),e.jsx(c,{children:e.jsx(H,{variant:"gray",children:n.run_count??0})}),e.jsx(c,{children:n.baseline?e.jsxs(e.Fragment,{children:[e.jsx(k.Link,{to:`/runs/${n.baseline.run_id}`,className:"font-mono text-sm",children:Q(n.baseline.run_id)}),n.baseline.run_name&&e.jsx("p",{className:"text-muted text-sm",children:n.baseline.run_name})]}):e.jsx("span",{className:"text-muted",children:"—"})}),e.jsx(c,{className:"text-right",children:e.jsx(k.Link,{to:a(n.name),children:e.jsx(D,{variant:"secondary",size:"sm",children:"View Runs"})})})]},n.name))})]})}function Kt({groups:t}){return t.length?e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Group ID"}),e.jsx(N,{children:"Name"}),e.jsx(N,{children:"Project"}),e.jsx(N,{children:"Runs"}),e.jsx(N,{children:"Actions"})]})}),e.jsx(B,{children:t.map(r=>e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:Q(r.group_id)}),e.jsx(c,{children:r.group_name||"—"}),e.jsx(c,{children:r.project}),e.jsx(c,{children:e.jsx(H,{variant:"gray",children:r.run_count})}),e.jsx(c,{children:e.jsx(k.Link,{to:`/groups/${r.group_id}`,children:e.jsx(D,{variant:"secondary",size:"sm",children:"View Runs"})})})]},r.group_id))})]}):e.jsx(le,{message:"No groups found",hint:"Groups are created when runs have a group_id set"})}function Jt({runId:t,runName:r,variant:a="secondary",size:n="sm",className:o=""}){const{api:d}=V(),[u,i]=p.useState({status:"idle"}),[f,h]=p.useState(!1),[m,g]=p.useState(null),_=async()=>{i({status:"preparing",message:"Preparing bundle..."}),h(!0);try{const T=await d.createExport(t);i({status:"packing",message:"Creating bundle...",artifactCount:T.artifact_count,objectCount:T.object_count}),i(he=>({...he,status:"downloading",message:"Downloading bundle..."}));const q=d.getExportDownloadUrl(t),P=await fetch(q,{credentials:"same-origin"});if(!P.ok)throw new Error("Download failed");const re=await P.blob(),ae=r?`${r.replace(/[^a-zA-Z0-9_-]/g,"_")}_${t.slice(0,8)}.zip`:`run_${t.slice(0,8)}.zip`,J=URL.createObjectURL(re),ee=document.createElement("a");ee.href=J,ee.download=ae,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(J),i({status:"complete",message:"Export complete!",bundleSize:re.size,artifactCount:T.artifact_count,objectCount:T.object_count}),g({message:"Bundle downloaded successfully",variant:"success"}),setTimeout(()=>{h(!1),i({status:"idle"})},2e3)}catch(T){const q=T instanceof Error?T.message:"Export failed";i({status:"error",message:q}),g({message:q,variant:"error"})}},z=()=>{u.status!=="preparing"&&u.status!=="packing"&&u.status!=="downloading"&&(h(!1),i({status:"idle"}))},w=T=>T<1024?`${T} B`:T<1024*1024?`${(T/1024).toFixed(1)} KB`:`${(T/(1024*1024)).toFixed(1)} MB`,K=["preparing","packing","downloading"].includes(u.status);return e.jsxs(e.Fragment,{children:[e.jsxs(D,{variant:a,size:n,onClick:_,disabled:K,className:o,children:[K&&e.jsx(I,{}),e.jsx(Gs,{}),"Export"]}),e.jsx(qe,{open:f,onClose:z,title:"Export Run",actions:u.status==="error"||u.status==="complete"?e.jsx(D,{variant:"secondary",onClick:z,children:"Close"}):void 0,children:e.jsxs("div",{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[u.status==="error"?e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--dq-danger-bg)] flex items-center justify-center",children:e.jsx(Vs,{})}):u.status==="complete"?e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--dq-success-bg)] flex items-center justify-center",children:e.jsx(Ws,{})}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--dq-primary-bg)] flex items-center justify-center",children:e.jsx(I,{})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:u.message}),u.status==="error"&&e.jsx("p",{className:"text-sm text-[var(--dq-text-muted)]",children:"Please try again or contact support."})]})]}),(u.artifactCount!==void 0||u.objectCount!==void 0||u.bundleSize!==void 0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-4",children:[u.artifactCount!==void 0&&e.jsxs(H,{variant:"gray",children:[u.artifactCount," artifacts"]}),u.objectCount!==void 0&&e.jsxs(H,{variant:"gray",children:[u.objectCount," objects"]}),u.bundleSize!==void 0&&e.jsx(H,{variant:"info",children:w(u.bundleSize)})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--dq-border-light)]",children:[e.jsxs("p",{className:"text-sm text-[var(--dq-text-muted)]",children:["Run ID: ",e.jsx("code",{className:"text-xs",children:t})]}),r&&e.jsxs("p",{className:"text-sm text-[var(--dq-text-muted)]",children:["Name: ",r]})]})]})}),m&&e.jsx(ve,{message:m.message,variant:m.variant,visible:!!m,onClose:()=>g(null)})]})}function Gs(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function Ws(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--dq-success)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function Vs(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--dq-danger)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}function zs({createdAt:t,endedAt:r,status:a}){const n=!Ie(a),[o,d]=p.useState(Date.now());p.useEffect(()=>{if(!n)return;const i=setInterval(()=>d(Date.now()),1e3);return()=>clearInterval(i)},[n]);const u=n?Math.max(0,Math.floor((o-new Date(t).getTime())/1e3)):et(t,r);return e.jsx("span",{className:n?"tabular-nums":void 0,children:tt(u)})}function Xt(){const{runId:t}=k.useParams(),r=k.useNavigate(),{api:a}=V(),{data:n,loading:o,error:d,refetch:u}=at(t),{data:i,refetch:f}=Ce(),[h,m]=p.useState(!1),[g,_]=p.useState(null),{mutate:z,loading:w}=pe(()=>a.setBaseline(n.project,n.run_id)),{mutate:K,loading:T}=pe(()=>a.deleteRun(t)),P=i?.find(R=>R.name===n?.project)?.baseline?.run_id===t;if(p.useEffect(()=>{if(g){const R=setTimeout(()=>_(null),3e3);return()=>clearTimeout(R)}},[g]),o)return e.jsx(W,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(I,{})})});if(d||!n)return e.jsx(W,{children:e.jsx(b,{children:e.jsx(le,{message:"Run not found",hint:d?.message||`Run ${t} does not exist`})})});const re=n.backend||{},ae=n.fingerprints||{},J=n.data?.params||{},ee=n.data?.metrics||{},he=n.data?.tags||{},xe=n.artifacts||[],be=n.errors||[],Ge=async()=>{try{await z(),await f(),u(),_({message:"Baseline updated",variant:"success"})}catch{_({message:"Failed to set baseline",variant:"error"})}},We=async()=>{try{await K(),m(!1),_({message:"Run deleted",variant:"success"}),setTimeout(()=>r("/runs"),1e3)}catch{_({message:"Failed to delete run",variant:"error"}),m(!1)}},Te=async R=>{const A=xe[R];try{const Pe=a.getArtifactDownloadUrl(n.run_id,R),Ne=await fetch(Pe);if(!Ne.ok)throw new Error("Download failed");const ke=await Ne.blob(),oe=document.createElement("a");oe.href=URL.createObjectURL(ke),oe.download=A?.kind||`artifact-${R}`,oe.click(),URL.revokeObjectURL(oe.href),_({message:"Download started",variant:"success"})}catch{_({message:"Download failed",variant:"error"})}},te=[{label:"Project",value:e.jsx(k.Link,{to:`/runs?project=${n.project}`,children:n.project})},{label:"Name",value:n.run_name||"—"},{label:"Adapter",value:n.adapter||"N/A"},{label:"Status",value:e.jsx(ct,{status:n.status})},{label:"Created",value:`${n.created_at} (${Se(n.created_at)})`},{label:"Duration",value:e.jsx(zs,{createdAt:n.created_at,endedAt:n.ended_at,status:n.status})},...n.ended_at?[{label:"Ended",value:`${n.ended_at} (${Se(n.ended_at)})`}]:[],{label:"Backend",value:re.name||"N/A"},...n.group_id?[{label:"Group",value:e.jsx(k.Link,{to:`/groups/${n.group_id}`,children:n.group_name||Q(n.group_id)})}]:[]];return e.jsxs(W,{children:[P&&e.jsxs("div",{className:"mb-4 px-4 py-3 bg-[#EFF6FF] border border-[#2563EB]/20 rounded-md text-[#2563EB] text-sm font-medium",children:['This run is the current baseline for project "',n.project,'"']}),e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:n.run_name||"Unnamed Run"}),e.jsx("p",{className:"text-muted text-sm font-mono",children:n.run_id})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Jt,{runId:n.run_id,runName:n.run_name}),!P&&e.jsxs(D,{variant:"secondary",size:"sm",onClick:Ge,disabled:w,children:[w&&e.jsx(I,{}),"Set as Baseline"]}),e.jsx(D,{variant:"ghost-danger",size:"sm",onClick:()=>m(!0),children:"Delete"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Overview"})}),e.jsx(Be,{items:te})]}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Fingerprints"})}),e.jsx(Be,{items:[{label:"Run",value:e.jsx("span",{className:"font-mono text-sm truncate",children:ae.run||"N/A"})},{label:"Program",value:e.jsx("span",{className:"font-mono text-sm truncate",children:ae.program||"N/A"})}]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Parameters"})}),Object.keys(J).length?e.jsx($,{children:e.jsx(B,{children:Object.entries(J).map(([R,A])=>e.jsxs(j,{children:[e.jsx(c,{children:R}),e.jsx(c,{className:"font-mono",children:String(A)})]},R))})}):e.jsx("p",{className:"text-muted",children:"No parameters"})]}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Metrics"})}),Object.keys(ee).length?e.jsx($,{children:e.jsx(B,{children:Object.entries(ee).map(([R,A])=>e.jsxs(j,{children:[e.jsx(c,{children:R}),e.jsx(c,{className:"font-mono",children:typeof A=="number"?Lt(A):String(A)})]},R))})}):e.jsx("p",{className:"text-muted",children:"No metrics"})]}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Tags"})}),Object.keys(he).length?e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(he).map(([R,A])=>e.jsxs(H,{variant:"gray",children:[R,": ",String(A)]},R))}):e.jsx("p",{className:"text-muted",children:"No tags"})]})]}),e.jsxs(b,{className:"mb-4",children:[e.jsx(U,{children:e.jsxs(G,{children:["Artifacts (",xe.length,")"]})}),xe.length?e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"#"}),e.jsx(N,{children:"Kind"}),e.jsx(N,{children:"Role"}),e.jsx(N,{children:"Media Type"}),e.jsx(N,{children:"Digest"}),e.jsx(N,{children:"Actions"})]})}),e.jsx(B,{children:xe.map((R,A)=>e.jsxs(j,{children:[e.jsx(c,{children:A}),e.jsx(c,{className:"font-mono text-sm",children:R.kind}),e.jsx(c,{children:e.jsx(H,{variant:"gray",children:R.role})}),e.jsx(c,{className:"text-muted text-sm",children:R.media_type}),e.jsx(c,{className:"font-mono text-sm",children:$e(R.digest)}),e.jsx(c,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k.Link,{to:`/runs/${n.run_id}/artifacts/${A}`,children:e.jsx(D,{variant:"secondary",size:"sm",children:"View"})}),e.jsx(D,{variant:"secondary",size:"sm",onClick:()=>Te(A),children:"Download"})]})})]},A))})]}):e.jsx("p",{className:"text-muted",children:"No artifacts"})]}),be.length>0&&e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{className:"text-danger",children:"Errors"})}),be.map((R,A)=>e.jsxs("div",{className:"mb-2",children:[e.jsx("strong",{children:R.type}),": ",R.message,R.traceback&&e.jsx("pre",{className:"mt-2",children:R.traceback})]},A))]}),e.jsxs(qe,{open:h,onClose:()=>m(!1),title:"Delete Run",actions:e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),e.jsxs(D,{variant:"danger",onClick:We,disabled:T,children:[T&&e.jsx(I,{}),"Delete"]})]}),children:[e.jsx("p",{children:"Are you sure you want to delete this run?"}),e.jsx("p",{className:"font-mono text-sm mt-2",children:Q(n.run_id)}),e.jsx("p",{className:"text-sm text-danger mt-2",children:"This action cannot be undone."})]}),g&&e.jsx(ve,{message:g.message,variant:g.variant,visible:!!g,onClose:()=>_(null)})]})}function Qt(){const{currentWorkspace:t}=V(),{data:r,loading:a}=Ce();return e.jsxs(W,{children:[e.jsx(ge,{title:"Projects"}),e.jsx(b,{children:a?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(I,{})}):e.jsx(Ht,{projects:r??[],currentWorkspace:t})})]})}function Zt(){const[t,r]=k.useSearchParams(),{data:a}=Ce(),[n,o]=p.useState(t.get("project")||""),{data:d,loading:u,refetch:i}=Mt({project:n||void 0}),f=p.useCallback(h=>{o(h);const m=new URLSearchParams(t);h?m.set("project",h):m.delete("project"),r(m,{replace:!0})},[t,r]);return e.jsxs(W,{children:[e.jsx(ge,{title:"Run Groups"}),e.jsx(b,{className:"mb-4",children:e.jsxs(it,{children:[e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"project",children:"Project"}),e.jsxs(ce,{id:"project",value:n,onChange:h=>f(h.target.value),children:[e.jsx("option",{value:"",children:"All projects"}),a?.map(h=>e.jsx("option",{value:h.name,children:h.name},h.name))]})]}),e.jsxs(Z,{className:"flex items-end gap-2",children:[e.jsx(D,{variant:"primary",onClick:()=>i(),children:"Filter"}),u&&e.jsx(I,{})]})]})}),e.jsx(b,{children:u&&!d?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(I,{})}):e.jsx(Kt,{groups:d??[]})})]})}function es(){const{groupId:t}=k.useParams(),{api:r}=V(),{data:a,loading:n,error:o,refetch:d}=Ut(t),[u,i]=p.useState(null),f=pe(m=>r.deleteRun(m));p.useEffect(()=>{if(u){const m=setTimeout(()=>i(null),3e3);return()=>clearTimeout(m)}},[u]);const h=async m=>{try{await f.mutate(m),i({message:"Run deleted",variant:"success"}),d()}catch{i({message:"Failed to delete run",variant:"error"})}};return n?e.jsx(W,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(I,{})})}):o||!a?e.jsx(W,{children:e.jsx(b,{children:e.jsx(le,{message:"Group not found",hint:o?.message})})}):e.jsxs(W,{children:[e.jsx(ge,{title:e.jsxs(e.Fragment,{children:["Group ",e.jsx("span",{className:"font-mono",children:Q(t)})]}),subtitle:e.jsx("span",{className:"font-mono text-muted",children:t})}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsxs(G,{children:["Runs in Group (",a.runs.length,")"]})}),e.jsx(Ue,{runs:a.runs,onDelete:h,loading:f.loading})]}),u&&e.jsx(ve,{message:u.message,variant:u.variant,visible:!!u,onClose:()=>i(null)})]})}function Ys({className:t=""}){return e.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function Hs({className:t=""}){return e.jsxs("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Ks({className:t=""}){return e.jsxs("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function Ze({className:t=""}){return e.jsxs("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function Re({match:t}){return t?e.jsxs("span",{className:"diff-match inline-flex items-center gap-1.5",children:[e.jsx(Ys,{className:"flex-shrink-0"}),e.jsx("span",{className:"font-medium",children:"Match"})]}):e.jsxs("span",{className:"diff-mismatch inline-flex items-center gap-1.5",children:[e.jsx(Hs,{className:"flex-shrink-0"}),e.jsx("span",{className:"font-medium",children:"Different"})]})}function Js({warnings:t}){return!t||t.length===0?null:e.jsx("div",{className:"alert alert-warning mb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Ks,{className:"flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold mb-1",children:t.length===1?"Warning":`${t.length} Warnings`}),e.jsx("ul",{className:"space-y-1",children:t.map((r,a)=>e.jsx("li",{className:"text-sm",children:r},a))})]})]})})}function kt({label:t,run:r,variant:a}){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:`absolute top-0 left-0 w-1 h-full rounded-l ${a==="a"?"bg-info":"bg-primary"}`}),e.jsxs("div",{className:"pl-4",children:[e.jsx("p",{className:`text-xs font-semibold uppercase tracking-wider mb-2 ${a==="a"?"text-info":"text-primary"}`,children:t}),e.jsx(k.Link,{to:`/runs/${r.run_id}`,className:"text-base font-medium hover:underline",children:r.run_name||"Unnamed Run"}),e.jsx("p",{className:"font-mono text-xs mt-1 text-muted",children:Q(r.run_id)}),e.jsxs("p",{className:"text-sm mt-1 text-muted",children:[r.project," · ",Se(r.created_at)]})]})]})}function ie({children:t,badge:r}){return e.jsx(U,{children:e.jsx(G,{children:e.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[t,r&&e.jsx(H,{variant:r.variant,children:r.label})]})})})}function Xs({tvd:t,noiseContext:r}){if(t===0)return e.jsx("p",{className:"text-sm mt-4 text-success",children:"✓ Distributions are identical (TVD = 0)"});if(!r)return null;const{p_value:a,noise_ratio:n}=r;return a!=null?a>=.1?e.jsx("p",{className:"text-sm mt-4 text-success",children:"✓ Consistent with sampling noise — difference is not statistically significant"}):a>=.05?e.jsxs("p",{className:"text-sm mt-4 text-warning",children:["⚠ Borderline (p=",a.toFixed(2),") — consider increasing shots"]}):e.jsxs("p",{className:"text-sm mt-4 text-danger",children:["✗ Statistically significant difference (p=",a.toFixed(2),") — results show meaningful divergence"]}):n!=null?n<1.5?e.jsx("p",{className:"text-sm mt-4 text-success",children:"✓ TVD is within expected shot noise range"}):n<3?e.jsxs("p",{className:"text-sm mt-4 text-warning",children:["⚠ Ambiguous (",n.toFixed(1),"× expected noise) — consider increasing shots"]}):e.jsxs("p",{className:"text-sm mt-4 text-danger",children:["✗ TVD exceeds expected noise (",n.toFixed(1),"×) — results show meaningful differences"]}):null}function Qs(){const[t,r]=k.useSearchParams(),{data:a}=nt({limit:100}),n=a?.runs??[],[o,d]=p.useState(t.get("a")||""),[u,i]=p.useState(t.get("b")||""),[f,h]=p.useState(""),m=g=>{if(g.preventDefault(),!o||!u){h("Please select both runs to compare");return}if(o===u){h("Please select two different runs");return}h(""),r({a:o,b:u})};return e.jsxs(e.Fragment,{children:[e.jsx(b,{children:e.jsxs("form",{onSubmit:m,children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"a",children:"Run A (Baseline)"}),e.jsxs(ce,{id:"a",value:o,onChange:g=>{d(g.target.value),h("")},children:[e.jsx("option",{value:"",children:"Select run..."}),n.map(g=>e.jsxs("option",{value:g.run_id,children:[g.run_name||"Unnamed"," (",Q(g.run_id),") — ",g.project]},g.run_id))]})]}),e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"b",children:"Run B (Candidate)"}),e.jsxs(ce,{id:"b",value:u,onChange:g=>{i(g.target.value),h("")},children:[e.jsx("option",{value:"",children:"Select run..."}),n.map(g=>e.jsxs("option",{value:g.run_id,children:[g.run_name||"Unnamed"," (",Q(g.run_id),") — ",g.project]},g.run_id))]})]})]}),f&&e.jsx("p",{className:"text-sm mb-3 text-danger",children:f}),e.jsx(D,{type:"submit",variant:"primary",children:"Compare"})]})}),e.jsxs(b,{className:"mt-4",children:[e.jsx(U,{children:e.jsx(G,{children:"How it works"})}),e.jsxs("div",{className:"space-y-2 text-sm text-muted",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ze,{className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:"Select two runs to compare their parameters, metrics, and artifacts"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ze,{className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:"The diff shows changed values and computes TVD for result distributions"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ze,{className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:"You can also compare from the run detail page"})]})]})]})]})}function Zs({runIdA:t,runIdB:r}){const{data:a,loading:n,error:o}=Gt(t,r);if(n)return e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:[e.jsx(I,{}),e.jsx("p",{className:"text-sm text-muted",children:"Comparing runs..."})]})});if(o||!a)return e.jsx(b,{children:e.jsx(le,{message:"Failed to load diff",hint:o?.message})});const{run_a:d,run_b:u,report:i}=a,f=i.device_drift?.significant_drift?{variant:"warning",label:"Drift Detected"}:i.device_drift?.has_calibration_data?{variant:"success",label:"Stable"}:{variant:"gray",label:"No Data"};return e.jsxs(e.Fragment,{children:[e.jsx(Js,{warnings:i.warnings||[]}),e.jsx(b,{className:"mb-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsx(kt,{label:"Run A (Baseline)",run:d,variant:"a"}),e.jsx(kt,{label:"Run B (Candidate)",run:u,variant:"b"})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(b,{children:[e.jsx(ie,{children:"Metadata"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Project"}),e.jsx(c,{children:e.jsx(Re,{match:i.metadata.project_match})})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Backend"}),e.jsx(c,{children:e.jsx(Re,{match:i.metadata.backend_match})})]}),!i.metadata.project_match&&e.jsxs(e.Fragment,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"text-sm text-muted",children:"Project A"}),e.jsx(c,{className:"font-mono text-sm",children:i.metadata.project_a||"N/A"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"text-sm text-muted",children:"Project B"}),e.jsx(c,{className:"font-mono text-sm",children:i.metadata.project_b||"N/A"})]})]}),!i.metadata.backend_match&&e.jsxs(e.Fragment,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"text-sm text-muted",children:"Backend A"}),e.jsx(c,{className:"font-mono text-sm",children:i.metadata.backend_a||"N/A"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"text-sm text-muted",children:"Backend B"}),e.jsx(c,{className:"font-mono text-sm",children:i.metadata.backend_b||"N/A"})]})]})]})})]}),e.jsxs(b,{children:[e.jsx(ie,{children:"Fingerprints"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Run A"}),e.jsx(c,{className:"font-mono text-sm",children:$e(i.fingerprints.a)})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Run B"}),e.jsx(c,{className:"font-mono text-sm",children:$e(i.fingerprints.b)})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Match"}),e.jsx(c,{children:e.jsx(Re,{match:i.fingerprints.a===i.fingerprints.b})})]})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(b,{children:[e.jsx(ie,{badge:{variant:i.program.exact_match?"success":i.program.structural_match?"info":"warning",label:i.program.exact_match?"Exact Match":i.program.structural_match?"Structural Match":"Different"},children:"Program"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Exact Match"}),e.jsx(c,{children:e.jsx(Re,{match:i.program.exact_match})})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Structural Match"}),e.jsx(c,{children:e.jsx(Re,{match:i.program.structural_match})})]})]})})]}),e.jsxs(b,{children:[e.jsx(ie,{badge:f,children:"Device Calibration"}),i.device_drift?.significant_drift?e.jsx("p",{className:"text-sm text-warning",children:"Significant calibration drift detected between runs"}):i.device_drift?.has_calibration_data?e.jsx("p",{className:"text-muted",children:"Calibration within acceptable thresholds"}):e.jsx("p",{className:"text-muted",children:"No calibration data available"})]})]}),e.jsxs(b,{className:"mb-4",children:[e.jsx(ie,{badge:{variant:i.params.match?"success":"warning",label:i.params.match?"Match":"Different"},children:"Parameters"}),i.params.match?e.jsx("p",{className:"text-muted",children:"All parameters match"}):e.jsx(e.Fragment,{children:i.params.changed&&Object.keys(i.params.changed).length>0&&e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Parameter"}),e.jsx(N,{children:"Run A"}),e.jsx(N,{children:"Run B"})]})}),e.jsx(B,{children:Object.entries(i.params.changed).map(([h,m])=>e.jsxs(j,{children:[e.jsx(c,{children:h}),e.jsx(c,{className:"font-mono",children:String(m.a)}),e.jsx(c,{className:"font-mono",children:String(m.b)})]},h))})]})})]}),e.jsxs(b,{className:"mb-4",children:[e.jsx(ie,{badge:{variant:i.metrics.match?"success":"warning",label:i.metrics.match?"Match":"Different"},children:"Metrics"}),i.metrics.match?e.jsx("p",{className:"text-muted",children:"All metrics match"}):e.jsx(e.Fragment,{children:i.metrics.changed&&Object.keys(i.metrics.changed).length>0&&e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Metric"}),e.jsx(N,{children:"Run A"}),e.jsx(N,{children:"Run B"})]})}),e.jsx(B,{children:Object.entries(i.metrics.changed).map(([h,m])=>e.jsxs(j,{children:[e.jsx(c,{children:h}),e.jsx(c,{className:"font-mono",children:m.a}),e.jsx(c,{className:"font-mono",children:m.b})]},h))})]})})]}),i.circuit_diff&&e.jsxs(b,{className:"mb-4",children:[e.jsx(ie,{badge:{variant:i.circuit_diff.match?"success":"warning",label:i.circuit_diff.match?"Match":"Different"},children:"Circuit"}),i.circuit_diff.match?e.jsx("p",{className:"text-muted",children:"Circuit structure matches"}):e.jsxs("div",{className:"space-y-4",children:[i.circuit_diff.changed&&Object.keys(i.circuit_diff.changed).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"Changed Properties"}),e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Property"}),e.jsx(N,{children:"Run A"}),e.jsx(N,{children:"Run B"}),e.jsx(N,{children:"Delta"})]})}),e.jsx(B,{children:Object.entries(i.circuit_diff.changed).map(([h,m])=>e.jsxs(j,{children:[e.jsx(c,{children:m.label||h}),e.jsx(c,{className:"font-mono",children:String(m.a)}),e.jsx(c,{className:"font-mono",children:String(m.b)}),e.jsx(c,{className:"font-mono",children:m.delta!=null&&e.jsxs("span",{className:m.delta>0?"text-danger":"text-success",children:[m.delta>0?"+":"",m.delta,m.pct!=null&&` (${m.pct>0?"+":""}${m.pct.toFixed(1)}%)`]})})]},h))})]})]}),i.circuit_diff.is_clifford_changed&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"Clifford Status"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Run A"}),e.jsx(c,{className:"font-mono",children:i.circuit_diff.is_clifford_a!=null?String(i.circuit_diff.is_clifford_a):"unknown"})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Run B"}),e.jsx(c,{className:"font-mono",children:i.circuit_diff.is_clifford_b!=null?String(i.circuit_diff.is_clifford_b):"unknown"})]})]})})]}),i.circuit_diff.added_gates&&i.circuit_diff.added_gates.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"New Gate Types (in B)"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.circuit_diff.added_gates.map(h=>e.jsx(H,{variant:"success",children:h},h))})]}),i.circuit_diff.removed_gates&&i.circuit_diff.removed_gates.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"Removed Gate Types (from A)"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.circuit_diff.removed_gates.map(h=>e.jsx(H,{variant:"danger",children:h},h))})]})]})]}),i.tvd!=null&&e.jsxs(b,{className:"mb-4",children:[e.jsx(ie,{children:"Results Distribution"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Total Variation Distance (TVD)"}),e.jsx(c,{className:"font-mono font-medium",children:i.tvd.toFixed(6)})]}),i.shots&&e.jsxs(j,{children:[e.jsx(c,{children:"Total Shots (A / B)"}),e.jsxs(c,{className:"font-mono",children:[i.shots.a," / ",i.shots.b]})]}),i.noise_context?.noise_p95&&e.jsxs(j,{children:[e.jsx(c,{children:"Noise Threshold (p95)"}),e.jsx(c,{className:"font-mono",children:i.noise_context.noise_p95.toFixed(6)})]}),i.noise_context?.p_value!=null&&e.jsxs(j,{children:[e.jsx(c,{children:"p-value"}),e.jsx(c,{className:"font-mono",children:i.noise_context.p_value.toFixed(4)})]})]})}),e.jsx(Xs,{tvd:i.tvd,noiseContext:i.noise_context})]})]})}function ts(){const[t]=k.useSearchParams(),r=t.get("a"),a=t.get("b"),n=r&&a;return e.jsxs(W,{children:[e.jsx("div",{className:"page-header",children:e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:"Compare Runs"}),n&&e.jsx("p",{className:"text-sm mt-1 text-muted",children:e.jsx(k.Link,{to:"/diff",children:"← Select different runs"})})]})}),n?e.jsx(Zs,{runIdA:r,runIdB:a}):e.jsx(Qs,{})]})}function ss(){const{api:t}=V(),[r,a]=p.useState(""),[n,o]=p.useState(null),[d,u]=p.useState(!1),[i,f]=p.useState(""),{mutate:h,loading:m}=pe(async()=>{const _=await t.listRuns({q:r,limit:100});return o(_.runs),u(!0),_}),g=_=>{if(_.preventDefault(),!r.trim()){f("Please enter a search query");return}f(""),h()};return e.jsxs(W,{children:[e.jsx("div",{className:"page-header",children:e.jsx("h1",{className:"page-title",children:"Search Runs"})}),e.jsx(b,{className:"mb-4",children:e.jsxs("form",{onSubmit:g,children:[e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"q",children:"Query"}),e.jsx(Me,{id:"q",type:"text",value:r,onChange:_=>{a(_.target.value),f("")},placeholder:"metric.fidelity > 0.95 and params.shots = 1000",className:"font-mono"})]}),i&&e.jsx("p",{className:"text-sm text-[#DC4A4A] mb-3",children:i}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(D,{type:"submit",variant:"primary",disabled:m,children:[m&&e.jsx(I,{}),"Search"]}),m&&e.jsx("span",{className:"text-muted text-sm",children:"Searching..."})]})]})}),d&&n&&e.jsx(b,{className:"mb-4",children:n.length>0?e.jsx(Ue,{runs:n}):e.jsx("p",{className:"text-muted text-center py-8",children:"No runs match your query"})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Query Syntax"})}),e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Field"}),e.jsx(N,{children:"Description"})]})}),e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"params.X"}),e.jsx(c,{children:"Parameter value"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"metric.X"}),e.jsx(c,{children:"Metric value"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"tags.X"}),e.jsx(c,{children:"Tag value"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"status"}),e.jsx(c,{children:"Run status"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"project"}),e.jsx(c,{children:"Project name"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"backend"}),e.jsx(c,{children:"Backend name"})]})]})]})]}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Operators"})}),e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Operator"}),e.jsx(N,{children:"Description"})]})}),e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"="}),e.jsx(c,{children:"Equals"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"!="}),e.jsx(c,{children:"Not equals"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:">"}),e.jsx(c,{children:"Greater than"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:">="}),e.jsx(c,{children:"Greater or equal"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"<"}),e.jsx(c,{children:"Less than"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"<="}),e.jsx(c,{children:"Less or equal"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"~"}),e.jsx(c,{children:"Contains"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"and"}),e.jsx(c,{children:"Combine conditions"})]})]})]})]})]}),e.jsxs(b,{className:"mt-4",children:[e.jsx(U,{children:e.jsx(G,{children:"Examples"})}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"metric.fidelity > 0.95"}),e.jsx(c,{children:"High fidelity runs"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"params.shots = 1000 and status = FINISHED"}),e.jsx(c,{children:"Finished runs with 1000 shots"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"tags.backend ~ ibm"}),e.jsx(c,{children:"Runs with IBM backends"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"metric.error < 0.01"}),e.jsx(c,{children:"Low error runs"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"project = vqe and metric.energy < -2.0"}),e.jsx(c,{children:"VQE runs with low energy"})]})]})})]})]})}function rs(){const{runId:t,index:r}=k.useParams(),a=parseInt(r,10),{api:n}=V(),{data:o}=at(t),{data:d,loading:u,error:i}=Wt(t,a),[f,h]=p.useState(null);p.useEffect(()=>{if(f){const P=setTimeout(()=>h(null),3e3);return()=>clearTimeout(P)}},[f]);const m=async()=>{try{const P=n.getArtifactDownloadUrl(t,a),re=await fetch(P);if(!re.ok)throw new Error("Download failed");const ae=await re.blob(),J=document.createElement("a");J.href=URL.createObjectURL(ae),J.download=g?.kind||`artifact-${a}`,J.click(),URL.revokeObjectURL(J.href),h({message:"Download started",variant:"success"})}catch{h({message:"Download failed",variant:"error"})}};if(u)return e.jsx(W,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(I,{})})});if(i||!d)return e.jsx(W,{children:e.jsx(b,{children:e.jsx(le,{message:"Artifact not found",hint:i?.message})})});const{artifact:g,size:_,content:z,content_json:w,preview_available:K,error:T}=d,q=10*1024*1024;return e.jsxs(W,{children:[e.jsx(ge,{title:g.kind,subtitle:e.jsxs(e.Fragment,{children:["← Back to run ",e.jsxs(k.Link,{to:`/runs/${t}`,children:[Q(t),o?.run_name&&` — ${o.run_name}`]})]}),actions:e.jsx(D,{variant:"primary",onClick:m,children:"Download"})}),e.jsx(b,{className:"mb-4",children:e.jsx(Be,{items:[{label:"Kind",value:e.jsx("span",{className:"font-mono",children:g.kind})},{label:"Role",value:e.jsx(H,{variant:"gray",children:g.role})},{label:"Media Type",value:g.media_type},{label:"Digest",value:e.jsx("span",{className:"font-mono text-sm",children:g.digest})},{label:"Size",value:Ee(_)}]})}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Content"})}),T?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-danger",children:["Error loading artifact: ",T]}),e.jsx("p",{className:"text-muted mt-2",children:e.jsx(D,{variant:"primary",onClick:m,children:"Download to view"})})]}):K?w?e.jsx("pre",{children:Ft(w)}):z?e.jsx("pre",{children:z}):e.jsxs("p",{className:"text-muted",children:["Binary content (",Ee(_),") — download to view"]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-muted",children:[e.jsx("strong",{children:"Artifact too large for preview"})," (",Ee(_)," exceeds ",Ee(q)," limit)"]}),e.jsx("p",{className:"text-sm text-muted mt-2",children:"Download the artifact to view its contents."}),e.jsx("p",{className:"mt-4",children:e.jsx(D,{variant:"primary",onClick:m,children:"Download"})})]})]}),f&&e.jsx(ve,{message:f.message,variant:f.variant,visible:!!f,onClose:()=>h(null)})]})}const ns=[{path:"/",element:e.jsx(k.Navigate,{to:"/runs",replace:!0})},{path:"/runs",element:e.jsx(Yt,{})},{path:"/runs/:runId",element:e.jsx(Xt,{})},{path:"/runs/:runId/artifacts/:index",element:e.jsx(rs,{})},{path:"/projects",element:e.jsx(Qt,{})},{path:"/groups",element:e.jsx(Zt,{})},{path:"/groups/:groupId",element:e.jsx(es,{})},{path:"/diff",element:e.jsx(ts,{})},{path:"/search",element:e.jsx(ss,{})}];function lt(t=[]){return k.createBrowserRouter([...ns,...t])}const as=lt();function er({additionalRoutes:t,...r}){const a=t?.length?lt(t):as;return e.jsx(qt,{...r,children:e.jsx(k.RouterProvider,{router:a})})}exports.Alert=Ms;exports.ApiClient=Dt;exports.ApiError=je;exports.App=er;exports.AppProvider=qt;exports.ArtifactPage=rs;exports.Badge=H;exports.Button=D;exports.Card=b;exports.CardHeader=U;exports.CardTitle=G;exports.DiffPage=ts;exports.EmptyState=le;exports.ExportRunButton=Jt;exports.FormGroup=Z;exports.FormRow=it;exports.GroupDetailPage=es;exports.GroupsPage=Zt;exports.GroupsTable=Kt;exports.Input=Me;exports.KVList=Be;exports.Label=ne;exports.Layout=W;exports.LayoutConfigProvider=qs;exports.Modal=qe;exports.POLL_INTERVAL=st;exports.PageHeader=ge;exports.ProjectsPage=Qt;exports.ProjectsTable=Ht;exports.RunDetailPage=Xt;exports.RunsPage=Yt;exports.RunsTable=Ue;exports.SearchPage=ss;exports.Select=ce;exports.Spinner=I;exports.StatusBadge=ct;exports.Table=$;exports.TableBody=B;exports.TableCell=c;exports.TableHead=se;exports.TableHeader=N;exports.TableRow=j;exports.ThemeProvider=$s;exports.Toast=ve;exports.api=At;exports.buildUrl=Os;exports.cn=O;exports.coreRoutes=ns;exports.createRouter=lt;exports.elapsedSeconds=et;exports.formatBytes=Ee;exports.formatDuration=tt;exports.formatNumber=Lt;exports.isTerminalStatus=Ie;exports.jsonPretty=Ft;exports.router=as;exports.shortDigest=$e;exports.shortId=Q;exports.timeAgo=Se;exports.truncate=Ot;exports.useApp=V;exports.useArtifact=Wt;exports.useDiff=Gt;exports.useGroup=Ut;exports.useGroups=Mt;exports.useLayoutConfig=zt;exports.useMutation=pe;exports.usePolling=rt;exports.useProjects=Ce;exports.useRun=at;exports.useRuns=nt;exports.useTheme=Bt;exports.useThemeOptional=Bs;
|
|
14
|
+
<%s key={someKey} {...props} />`,Qe,de,ks,de),Et[de+Qe]=!0}}return s===n?Es(F):Rs(F),F}}function Ss(s,l,x){return St(s,l,x,!0)}function Cs(s,l,x){return St(s,l,x,!1)}var Ts=Cs,Ps=Ss;we.Fragment=n,we.jsx=Ts,we.jsxs=Ps})()),we}var Pt;function Fs(){return Pt||(Pt=1,process.env.NODE_ENV==="production"?Oe.exports=As():Oe.exports=Ls()),Oe.exports}var e=Fs();class je extends Error{constructor(r,a){super(a),this.status=r,this.name="ApiError"}}class Dt{baseUrl;headers;constructor(r={}){this.baseUrl=r.baseUrl??"",this.headers={"Content-Type":"application/json",...r.headers}}async request(r,a,n={}){let o=`${this.baseUrl}${a}`;if(n.params){const u=new URLSearchParams;Object.entries(n.params).forEach(([f,h])=>{h!=null&&h!==""&&u.set(f,String(h))});const i=u.toString();i&&(o+=`?${i}`)}const d=await fetch(o,{method:r,headers:{...this.headers,...n.headers},body:n.body?JSON.stringify(n.body):void 0,credentials:n.credentials});if(!d.ok){const u=await d.json().catch(()=>({detail:"Unknown error"}));throw new je(d.status,u.detail||d.statusText)}if(!(d.status===204||d.headers.get("content-length")==="0"))return d.json()}async getCapabilities(){return this.request("GET","/api/v1/capabilities")}async listRuns(r){return this.request("GET","/api/runs",{params:r})}async getRun(r){return this.request("GET",`/api/runs/${r}`)}async deleteRun(r){await this.request("DELETE",`/api/runs/${r}`)}async setBaseline(r,a){return this.request("POST",`/api/projects/${r}/baseline/${a}`,{params:{redirect:"false"}})}async listProjects(r){return this.request("GET","/api/projects",{params:r})}async listGroups(r){return this.request("GET","/api/groups",{params:r})}async getGroup(r){return this.request("GET",`/api/groups/${r}`)}async getDiff(r,a){return this.request("GET","/api/diff",{params:{a:r,b:a}})}async getArtifact(r,a){return this.request("GET",`/api/runs/${r}/artifacts/${a}`)}getArtifactDownloadUrl(r,a){return`${this.baseUrl}/api/runs/${r}/artifacts/${a}/raw`}async createExport(r){return this.request("POST",`/api/runs/${r}/export`)}async getExportInfo(r){return this.request("GET",`/api/runs/${r}/export/info`)}getExportDownloadUrl(r){return`${this.baseUrl}/api/runs/${r}/export/download`}}const At=new Dt;function Q(t){return t?.slice(0,8)??""}function $e(t){return t?.slice(0,12)??"N/A"}function Se(t){const r=new Date(t),n=Math.floor((new Date().getTime()-r.getTime())/1e3);if(n<60)return"just now";if(n<3600){const d=Math.floor(n/60);return`${d} minute${d!==1?"s":""} ago`}if(n<86400){const d=Math.floor(n/3600);return`${d} hour${d!==1?"s":""} ago`}if(n<2592e3){const d=Math.floor(n/86400);return`${d} day${d!==1?"s":""} ago`}if(n<31536e3){const d=Math.floor(n/2592e3);return`${d} month${d!==1?"s":""} ago`}const o=Math.floor(n/31536e3);return`${o} year${o!==1?"s":""} ago`}function Lt(t,r=6){return typeof t!="number"||isNaN(t)?String(t):Number(t.toPrecision(r)).toString()}function Ee(t){return t<1024?`${t} bytes`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1048576).toFixed(1)} MB`}function Ft(t){return JSON.stringify(t,null,2)}function Ot(t,r=60){return t?t.length<=r?t:t.slice(0,r-3)+"...":""}function Os(t,r){const a=new URLSearchParams;Object.entries(r).forEach(([o,d])=>{d!=null&&d!==""&&a.set(o,String(d))});const n=a.toString();return n?`${t}?${n}`:t}function O(...t){return t.filter(Boolean).join(" ")}function et(t,r){const a=new Date(t).getTime(),n=r?new Date(r).getTime():Date.now();return Math.max(0,Math.floor((n-a)/1e3))}function tt(t){if(t<60)return`${t}s`;const r=Math.floor(t/86400),a=Math.floor(t%86400/3600),n=Math.floor(t%3600/60),o=t%60;return r>0?`${r}d ${a}h ${n}m`:a>0?`${a}h ${n}m ${o}s`:`${n}m ${o}s`}function Ie(t){return t==="FINISHED"||t==="FAILED"||t==="KILLED"}const $t=p.createContext(null);function $s({children:t}){const r={theme:"light",resolvedTheme:"light",setTheme:()=>{},toggleTheme:()=>{}};return e.jsx($t.Provider,{value:r,children:t})}function Bt(){const t=p.useContext($t);return t||{theme:"light",resolvedTheme:"light",setTheme:()=>{},toggleTheme:()=>{}}}function Bs(){return Bt()}const st=1e3,It=p.createContext(null);function qt({children:t,api:r=At,initialWorkspace:a=null}){const[n,o]=p.useState(null),[d,u]=p.useState(a);return p.useEffect(()=>{r.getCapabilities().then(o).catch(console.error)},[r]),e.jsx(It.Provider,{value:{api:r,capabilities:n,currentWorkspace:d,setCurrentWorkspace:u},children:t})}function V(){const t=p.useContext(It);if(!t)throw new Error("useApp must be used within AppProvider");return t}function ue(t,r=[]){const[a,n]=p.useState({data:null,loading:!0,error:null}),o=p.useRef(!0),d=p.useRef(t);d.current=t;const u=p.useCallback(async()=>{n(i=>({...i,loading:!0,error:null}));try{const i=await d.current();o.current&&n({data:i,loading:!1,error:null})}catch(i){o.current&&n({data:null,loading:!1,error:i instanceof je?i:new je(500,String(i))})}},[]);return p.useEffect(()=>(o.current=!0,u(),()=>{o.current=!1}),r),{...a,refetch:u}}function rt(t,r,a){p.useEffect(()=>{if(!a)return;const n=setInterval(t,r),o=()=>{document.visibilityState==="visible"&&t()};return document.addEventListener("visibilitychange",o),()=>{clearInterval(n),document.removeEventListener("visibilitychange",o)}},[t,r,a])}function nt(t){const{api:r,currentWorkspace:a}=V(),n=ue(()=>r.listRuns({...t,workspace:a?.id}),[r,a?.id,t?.project,t?.status,t?.q,t?.limit]);return rt(n.refetch,st,!0),n}function at(t){const{api:r}=V(),a=ue(async()=>{const{run:o}=await r.getRun(t);return o},[r,t]),n=a.data?!Ie(a.data.status):!1;return rt(a.refetch,st,n),a}function Ce(){const{api:t,currentWorkspace:r}=V();return ue(async()=>{const{projects:a}=await t.listProjects({workspace:r?.id});return a},[t,r?.id])}function Mt(t){const{api:r,currentWorkspace:a}=V();return ue(async()=>{const{groups:n}=await r.listGroups({...t,workspace:a?.id});return n},[r,a?.id,t?.project])}function Ut(t){const{api:r}=V();return ue(()=>r.getGroup(t),[r,t])}function Gt(t,r){const{api:a}=V();return ue(()=>a.getDiff(t,r),[a,t,r])}function Wt(t,r){const{api:a}=V();return ue(()=>a.getArtifact(t,r),[a,t,r])}function pe(t){const[r,a]=p.useState(!1),[n,o]=p.useState(null);return{mutate:p.useCallback(async(...u)=>{a(!0),o(null);try{return await t(...u)}catch(i){const f=i instanceof je?i:new je(500,String(i));throw o(f),f}finally{a(!1)}},[t]),loading:r,error:n}}const Is=[{href:"/runs",label:"Runs",matchPaths:["/runs"]},{href:"/projects",label:"Projects",matchPaths:["/projects"]},{href:"/groups",label:"Groups",matchPaths:["/groups"]},{href:"/diff",label:"Compare",matchPaths:["/diff"]},{href:"/search",label:"Search",matchPaths:["/search"]}],Vt=p.createContext(null);function qs({config:t,children:r}){return e.jsx(Vt.Provider,{value:t,children:r})}function zt(){return p.useContext(Vt)}function W({children:t,config:r}){const a=k.useLocation(),o={...zt(),...r},d=o?.navLinks??Is,u=[...o?.prependNavLinks??[],...d,...o?.appendNavLinks??[]],i=o?.logo??{text:"devqubit",icon:"⚛"},f=h=>h.matchPaths?h.matchPaths.some(m=>a.pathname.startsWith(m)):a.pathname===h.href;return e.jsxs("div",{className:"dq-layout",children:[e.jsx("header",{className:"dq-header",children:e.jsxs("div",{className:"dq-header-inner",children:[e.jsxs("div",{className:"dq-header-left",children:[e.jsxs(k.Link,{to:"/",className:"dq-logo",children:[i.icon&&e.jsx("span",{className:"dq-logo-icon",children:i.icon}),i.text]}),e.jsx("nav",{className:"dq-nav",children:u.map(h=>e.jsx(k.Link,{to:h.href,className:O("dq-nav-link",f(h)&&"active"),children:h.label},h.href))})]}),e.jsx("div",{className:"dq-header-right",children:o?.headerRight})]})}),e.jsx("main",{className:"dq-main fade-in",children:t})]})}function ge({title:t,subtitle:r,actions:a}){return e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:t}),r&&e.jsx("p",{className:"text-sm text-muted mt-1",children:r})]}),a&&e.jsx("div",{className:"flex gap-2",children:a})]})}function H({variant:t="gray",className:r,children:a,...n}){return e.jsx("span",{className:O("badge",`badge-${t}`,r),...n,children:a})}const D=p.forwardRef(({variant:t="secondary",size:r="default",loading:a,className:n,children:o,disabled:d,...u},i)=>e.jsxs("button",{ref:i,className:O("btn",t==="ghost-danger"?"btn-ghost-danger":`btn-${t}`,r==="sm"&&"btn-sm",n),disabled:d||a,...u,children:[a&&e.jsx(I,{}),o]}));D.displayName="Button";function b({className:t,children:r,...a}){return e.jsx("div",{className:O("card",t),...a,children:r})}function U({className:t,children:r,...a}){return e.jsx("div",{className:O("card-header",t),...a,children:r})}function G({className:t,children:r,...a}){return e.jsx("h3",{className:O("card-title",t),...a,children:r})}function Ms({variant:t="info",className:r,children:a,...n}){return e.jsx("div",{className:O("alert",`alert-${t}`,r),...n,children:a})}function I({className:t,...r}){return e.jsx("span",{className:O("spinner",t),...r})}function le({message:t,hint:r,className:a,...n}){return e.jsxs("div",{className:O("empty-state",a),...n,children:[e.jsx("p",{children:t}),r&&e.jsx("p",{className:"text-sm text-muted mt-2",children:r})]})}function Be({items:t,className:r,...a}){return e.jsx("dl",{className:O("kv-list",r),...a,children:t.map(({label:n,value:o})=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{children:n}),e.jsx("dd",{children:o})]},n))})}function qe({open:t,onClose:r,title:a,children:n,actions:o}){return t?e.jsx("div",{className:O("modal-backdrop",t&&"active"),onClick:d=>d.target===d.currentTarget&&r(),children:e.jsxs("div",{className:"modal",onClick:d=>d.stopPropagation(),children:[e.jsx("h3",{className:"modal-title",children:a}),e.jsx("div",{className:"modal-body",children:n}),o&&e.jsx("div",{className:"modal-actions",children:o})]})}):null}function ve({message:t,variant:r="info",visible:a,onClose:n}){if(!a)return null;const o={success:"✓",error:"✕",info:"i"}[r],d={success:"text-[#059669]",error:"text-[#DC4A4A]",info:"text-[#2563EB]"}[r];return e.jsxs("div",{className:"toast",onClick:n,children:[e.jsx("span",{className:O("mr-2 font-bold",d),children:o}),t]})}function Z({children:t,className:r}){return e.jsx("div",{className:O("form-group",r),children:t})}function ne({className:t,children:r,...a}){return e.jsx("label",{className:O("form-label",t),...a,children:r})}const Me=p.forwardRef(({className:t,...r},a)=>e.jsx("input",{ref:a,className:O("form-input",t),...r}));Me.displayName="Input";const ce=p.forwardRef(({className:t,children:r,...a},n)=>e.jsx("select",{ref:n,className:O("form-input",t),...a,children:r}));ce.displayName="Select";function it({children:t,className:r}){return e.jsx("div",{className:O("form-row",r),children:t})}function $({className:t,children:r,...a}){return e.jsx("table",{className:O("table",t),...a,children:r})}function se({className:t,children:r,...a}){return e.jsx("thead",{className:t,...a,children:r})}function B({className:t,children:r,...a}){return e.jsx("tbody",{className:t,...a,children:r})}function j({className:t,children:r,...a}){return e.jsx("tr",{className:t,...a,children:r})}function N({className:t,children:r,...a}){return e.jsx("th",{className:t,...a,children:r})}function c({className:t,children:r,...a}){return e.jsx("td",{className:t,...a,children:r})}function ct({status:t}){const r={FINISHED:"success",FAILED:"danger",KILLED:"gray",RUNNING:"warning",UNKNOWN:"gray"}[t];return e.jsx(H,{variant:r,children:t})}function Us({createdAt:t,endedAt:r,status:a}){const n=!Ie(a),[o,d]=p.useState(Date.now());p.useEffect(()=>{if(!n)return;const h=setInterval(()=>d(Date.now()),1e3);return()=>clearInterval(h)},[n]);const i=et(t,n?void 0:r),f=n?Math.max(0,Math.floor((o-new Date(t).getTime())/1e3)):i;return e.jsx("span",{className:n?"tabular-nums":void 0,children:tt(f)})}function Ue({runs:t,onDelete:r,loading:a,emptyHint:n,baselineRunId:o}){const[d,u]=p.useState(null),i=()=>{d&&r&&(r(d.run_id),u(null))};return t.length?e.jsxs(e.Fragment,{children:[e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Run ID"}),e.jsx(N,{children:"Name"}),e.jsx(N,{children:"Project"}),e.jsx(N,{children:"Status"}),e.jsx(N,{children:"Duration"}),e.jsx(N,{children:"Created"}),e.jsx(N,{children:"Actions"})]})}),e.jsx(B,{children:t.map(f=>e.jsxs(j,{children:[e.jsxs(c,{children:[e.jsx(k.Link,{to:`/runs/${f.run_id}`,className:"font-mono",children:Q(f.run_id)}),f.run_id===o&&e.jsx(H,{variant:"info",className:"ml-2",children:"Baseline"})]}),e.jsx(c,{children:f.run_name||"—"}),e.jsx(c,{children:f.project}),e.jsx(c,{children:e.jsx(ct,{status:f.status})}),e.jsx(c,{className:"font-mono text-sm",children:e.jsx(Us,{createdAt:f.created_at,endedAt:f.ended_at,status:f.status})}),e.jsx(c,{className:"text-muted",children:Se(f.created_at)}),e.jsx(c,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k.Link,{to:`/runs/${f.run_id}`,children:e.jsx(D,{variant:"secondary",size:"sm",children:"View"})}),r&&e.jsx(D,{variant:"ghost-danger",size:"sm",onClick:()=>u(f),disabled:a,children:"Delete"})]})})]},f.run_id))})]}),e.jsxs(qe,{open:!!d,onClose:()=>u(null),title:"Delete Run",actions:e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"secondary",onClick:()=>u(null),children:"Cancel"}),e.jsxs(D,{variant:"danger",onClick:i,disabled:a,children:[a&&e.jsx(I,{}),"Delete"]})]}),children:[e.jsx("p",{children:"Are you sure you want to delete this run?"}),d&&e.jsx("p",{className:"font-mono text-sm mt-2",children:Q(d.run_id)}),e.jsx("p",{className:"text-sm text-danger mt-2",children:"This action cannot be undone."})]})]}):e.jsx(le,{message:"No runs found",hint:n??"Try adjusting your filters"})}function Yt(){const[t,r]=k.useSearchParams(),{api:a}=V(),{data:n}=Ce(),[o,d]=p.useState(null),[u,i]=p.useState({project:t.get("project")||"",status:t.get("status")||"",q:t.get("q")||"",limit:parseInt(t.get("limit")||"25",10)}),{data:f,loading:h,refetch:m}=nt(u),g=pe(w=>a.deleteRun(w));p.useEffect(()=>{if(o){const w=setTimeout(()=>d(null),3e3);return()=>clearTimeout(w)}},[o]);const _=p.useCallback((w,K)=>{i(q=>({...q,[w]:K}));const T=new URLSearchParams(t);K?T.set(w,String(K)):T.delete(w),r(T,{replace:!0})},[t,r]),z=p.useCallback(async w=>{try{await g.mutate(w),d({message:"Run deleted",variant:"success"}),m()}catch{d({message:"Failed to delete run",variant:"error"})}},[g,m]);return e.jsxs(W,{children:[e.jsx(ge,{title:"Runs"}),e.jsx(b,{className:"mb-4",children:e.jsxs(it,{children:[e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"project",children:"Project"}),e.jsxs(ce,{id:"project",value:u.project,onChange:w=>_("project",w.target.value),children:[e.jsx("option",{value:"",children:"All projects"}),n?.map(w=>e.jsx("option",{value:w.name,children:w.name},w.name))]})]}),e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"status",children:"Status"}),e.jsxs(ce,{id:"status",value:u.status,onChange:w=>_("status",w.target.value),children:[e.jsx("option",{value:"",children:"All"}),e.jsx("option",{value:"FINISHED",children:"Finished"}),e.jsx("option",{value:"FAILED",children:"Failed"}),e.jsx("option",{value:"RUNNING",children:"Running"})]})]}),e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"q",children:"Query"}),e.jsx(Me,{id:"q",value:u.q,onChange:w=>_("q",w.target.value),placeholder:"metric.fidelity > 0.9"})]}),e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"limit",children:"Limit"}),e.jsxs(ce,{id:"limit",value:u.limit,onChange:w=>_("limit",parseInt(w.target.value,10)),children:[e.jsx("option",{value:"25",children:"25"}),e.jsx("option",{value:"50",children:"50"}),e.jsx("option",{value:"100",children:"100"})]})]}),e.jsxs(Z,{className:"flex items-end gap-2",children:[e.jsx(D,{variant:"primary",onClick:()=>m(),children:"Filter"}),h&&e.jsx(I,{})]})]})}),e.jsx(b,{children:h&&!f?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(I,{})}):e.jsx(Ue,{runs:f?.runs??[],onDelete:z,loading:g.loading,baselineRunId:u.project?n?.find(w=>w.name===u.project)?.baseline?.run_id:void 0})}),o&&e.jsx(ve,{message:o.message,variant:o.variant,visible:!!o,onClose:()=>d(null)})]})}function Ht({projects:t,currentWorkspace:r}){if(!t.length)return e.jsx(le,{message:"No projects yet",hint:"Projects are created automatically when you log runs"});const a=n=>{const o=new URLSearchParams({project:n});return r&&o.set("workspace",r.id),`/runs?${o}`};return e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Project"}),e.jsx(N,{children:"Runs"}),e.jsx(N,{children:"Baseline"}),e.jsx(N,{})]})}),e.jsx(B,{children:t.map(n=>e.jsxs(j,{children:[e.jsxs(c,{children:[e.jsx("span",{className:"font-medium",children:n.name}),n.description&&e.jsx("p",{className:"text-muted text-sm",children:Ot(n.description)})]}),e.jsx(c,{children:e.jsx(H,{variant:"gray",children:n.run_count??0})}),e.jsx(c,{children:n.baseline?e.jsxs(e.Fragment,{children:[e.jsx(k.Link,{to:`/runs/${n.baseline.run_id}`,className:"font-mono text-sm",children:Q(n.baseline.run_id)}),n.baseline.run_name&&e.jsx("p",{className:"text-muted text-sm",children:n.baseline.run_name})]}):e.jsx("span",{className:"text-muted",children:"—"})}),e.jsx(c,{className:"text-right",children:e.jsx(k.Link,{to:a(n.name),children:e.jsx(D,{variant:"secondary",size:"sm",children:"View Runs"})})})]},n.name))})]})}function Kt({groups:t}){return t.length?e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Group ID"}),e.jsx(N,{children:"Name"}),e.jsx(N,{children:"Project"}),e.jsx(N,{children:"Runs"}),e.jsx(N,{children:"Actions"})]})}),e.jsx(B,{children:t.map(r=>e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:Q(r.group_id)}),e.jsx(c,{children:r.group_name||"—"}),e.jsx(c,{children:r.project}),e.jsx(c,{children:e.jsx(H,{variant:"gray",children:r.run_count})}),e.jsx(c,{children:e.jsx(k.Link,{to:`/groups/${r.group_id}`,children:e.jsx(D,{variant:"secondary",size:"sm",children:"View Runs"})})})]},r.group_id))})]}):e.jsx(le,{message:"No groups found",hint:"Groups are created when runs have a group_id set"})}function Jt({runId:t,runName:r,variant:a="secondary",size:n="sm",className:o=""}){const{api:d}=V(),[u,i]=p.useState({status:"idle"}),[f,h]=p.useState(!1),[m,g]=p.useState(null),_=async()=>{i({status:"preparing",message:"Preparing bundle..."}),h(!0);try{const T=await d.createExport(t);i({status:"packing",message:"Creating bundle...",artifactCount:T.artifact_count,objectCount:T.object_count}),i(he=>({...he,status:"downloading",message:"Downloading bundle..."}));const q=d.getExportDownloadUrl(t),P=await fetch(q,{credentials:"same-origin"});if(!P.ok)throw new Error("Download failed");const re=await P.blob(),ae=r?`${r.replace(/[^a-zA-Z0-9_-]/g,"_")}_${t.slice(0,8)}.zip`:`run_${t.slice(0,8)}.zip`,J=URL.createObjectURL(re),ee=document.createElement("a");ee.href=J,ee.download=ae,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(J),i({status:"complete",message:"Export complete!",bundleSize:re.size,artifactCount:T.artifact_count,objectCount:T.object_count}),g({message:"Bundle downloaded successfully",variant:"success"})}catch(T){const q=T instanceof Error?T.message:"Export failed";i({status:"error",message:q}),g({message:q,variant:"error"})}},z=()=>{u.status!=="preparing"&&u.status!=="packing"&&u.status!=="downloading"&&(h(!1),i({status:"idle"}))},w=T=>T<1024?`${T} B`:T<1024*1024?`${(T/1024).toFixed(1)} KB`:`${(T/(1024*1024)).toFixed(1)} MB`,K=["preparing","packing","downloading"].includes(u.status);return e.jsxs(e.Fragment,{children:[e.jsxs(D,{variant:a,size:n,onClick:_,disabled:K,className:o,children:[K&&e.jsx(I,{}),e.jsx(Gs,{}),"Export"]}),e.jsx(qe,{open:f,onClose:z,title:"Export Run",actions:u.status==="error"||u.status==="complete"?e.jsx(D,{variant:"secondary",onClick:z,children:"Close"}):void 0,children:e.jsxs("div",{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[u.status==="error"?e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--dq-danger-bg)] flex items-center justify-center",children:e.jsx(Vs,{})}):u.status==="complete"?e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--dq-success-bg)] flex items-center justify-center",children:e.jsx(Ws,{})}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--dq-primary-bg)] flex items-center justify-center",children:e.jsx(I,{})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:u.message}),u.status==="error"&&e.jsx("p",{className:"text-sm text-[var(--dq-text-muted)]",children:"Please try again or contact support."})]})]}),(u.artifactCount!==void 0||u.objectCount!==void 0||u.bundleSize!==void 0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-4",children:[u.artifactCount!==void 0&&e.jsxs(H,{variant:"gray",children:[u.artifactCount," artifacts"]}),u.objectCount!==void 0&&e.jsxs(H,{variant:"gray",children:[u.objectCount," objects"]}),u.bundleSize!==void 0&&e.jsx(H,{variant:"info",children:w(u.bundleSize)})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--dq-border-light)]",children:[e.jsxs("p",{className:"text-sm text-[var(--dq-text-muted)]",children:["Run ID: ",e.jsx("code",{className:"text-xs",children:t})]}),r&&e.jsxs("p",{className:"text-sm text-[var(--dq-text-muted)]",children:["Name: ",r]})]})]})}),m&&e.jsx(ve,{message:m.message,variant:m.variant,visible:!!m,onClose:()=>g(null)})]})}function Gs(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function Ws(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--dq-success)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function Vs(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--dq-danger)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}function zs({createdAt:t,endedAt:r,status:a}){const n=!Ie(a),[o,d]=p.useState(Date.now());p.useEffect(()=>{if(!n)return;const i=setInterval(()=>d(Date.now()),1e3);return()=>clearInterval(i)},[n]);const u=n?Math.max(0,Math.floor((o-new Date(t).getTime())/1e3)):et(t,r);return e.jsx("span",{className:n?"tabular-nums":void 0,children:tt(u)})}function Xt(){const{runId:t}=k.useParams(),r=k.useNavigate(),{api:a}=V(),{data:n,loading:o,error:d,refetch:u}=at(t),{data:i,refetch:f}=Ce(),[h,m]=p.useState(!1),[g,_]=p.useState(null),{mutate:z,loading:w}=pe(()=>a.setBaseline(n.project,n.run_id)),{mutate:K,loading:T}=pe(()=>a.deleteRun(t)),P=i?.find(R=>R.name===n?.project)?.baseline?.run_id===t;if(p.useEffect(()=>{if(g){const R=setTimeout(()=>_(null),3e3);return()=>clearTimeout(R)}},[g]),o)return e.jsx(W,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(I,{})})});if(d||!n)return e.jsx(W,{children:e.jsx(b,{children:e.jsx(le,{message:"Run not found",hint:d?.message||`Run ${t} does not exist`})})});const re=n.backend||{},ae=n.fingerprints||{},J=n.data?.params||{},ee=n.data?.metrics||{},he=n.data?.tags||{},xe=n.artifacts||[],be=n.errors||[],Ge=async()=>{try{await z(),await f(),u(),_({message:"Baseline updated",variant:"success"})}catch{_({message:"Failed to set baseline",variant:"error"})}},We=async()=>{try{await K(),m(!1),_({message:"Run deleted",variant:"success"}),setTimeout(()=>r("/runs"),1e3)}catch{_({message:"Failed to delete run",variant:"error"}),m(!1)}},Te=async R=>{const A=xe[R];try{const Pe=a.getArtifactDownloadUrl(n.run_id,R),Ne=await fetch(Pe);if(!Ne.ok)throw new Error("Download failed");const ke=await Ne.blob(),oe=document.createElement("a");oe.href=URL.createObjectURL(ke),oe.download=A?.kind||`artifact-${R}`,oe.click(),URL.revokeObjectURL(oe.href),_({message:"Download started",variant:"success"})}catch{_({message:"Download failed",variant:"error"})}},te=[{label:"Project",value:e.jsx(k.Link,{to:`/runs?project=${n.project}`,children:n.project})},{label:"Name",value:n.run_name||"—"},{label:"Adapter",value:n.adapter||"N/A"},{label:"Status",value:e.jsx(ct,{status:n.status})},{label:"Created",value:`${n.created_at} (${Se(n.created_at)})`},{label:"Duration",value:e.jsx(zs,{createdAt:n.created_at,endedAt:n.ended_at,status:n.status})},...n.ended_at?[{label:"Ended",value:`${n.ended_at} (${Se(n.ended_at)})`}]:[],{label:"Backend",value:re.name||"N/A"},...n.group_id?[{label:"Group",value:e.jsx(k.Link,{to:`/groups/${n.group_id}`,children:n.group_name||Q(n.group_id)})}]:[]];return e.jsxs(W,{children:[P&&e.jsxs("div",{className:"mb-4 px-4 py-3 bg-[#EFF6FF] border border-[#2563EB]/20 rounded-md text-[#2563EB] text-sm font-medium",children:['This run is the current baseline for project "',n.project,'"']}),e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:n.run_name||"Unnamed Run"}),e.jsx("p",{className:"text-muted text-sm font-mono",children:n.run_id})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Jt,{runId:n.run_id,runName:n.run_name}),!P&&e.jsxs(D,{variant:"secondary",size:"sm",onClick:Ge,disabled:w,children:[w&&e.jsx(I,{}),"Set as Baseline"]}),e.jsx(D,{variant:"ghost-danger",size:"sm",onClick:()=>m(!0),children:"Delete"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Overview"})}),e.jsx(Be,{items:te})]}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Fingerprints"})}),e.jsx(Be,{items:[{label:"Run",value:e.jsx("span",{className:"font-mono text-sm truncate",children:ae.run||"N/A"})},{label:"Program",value:e.jsx("span",{className:"font-mono text-sm truncate",children:ae.program||"N/A"})}]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Parameters"})}),Object.keys(J).length?e.jsx($,{children:e.jsx(B,{children:Object.entries(J).map(([R,A])=>e.jsxs(j,{children:[e.jsx(c,{children:R}),e.jsx(c,{className:"font-mono",children:String(A)})]},R))})}):e.jsx("p",{className:"text-muted",children:"No parameters"})]}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Metrics"})}),Object.keys(ee).length?e.jsx($,{children:e.jsx(B,{children:Object.entries(ee).map(([R,A])=>e.jsxs(j,{children:[e.jsx(c,{children:R}),e.jsx(c,{className:"font-mono",children:typeof A=="number"?Lt(A):String(A)})]},R))})}):e.jsx("p",{className:"text-muted",children:"No metrics"})]}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Tags"})}),Object.keys(he).length?e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(he).map(([R,A])=>e.jsxs(H,{variant:"gray",children:[R,": ",String(A)]},R))}):e.jsx("p",{className:"text-muted",children:"No tags"})]})]}),e.jsxs(b,{className:"mb-4",children:[e.jsx(U,{children:e.jsxs(G,{children:["Artifacts (",xe.length,")"]})}),xe.length?e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"#"}),e.jsx(N,{children:"Kind"}),e.jsx(N,{children:"Role"}),e.jsx(N,{children:"Media Type"}),e.jsx(N,{children:"Digest"}),e.jsx(N,{children:"Actions"})]})}),e.jsx(B,{children:xe.map((R,A)=>e.jsxs(j,{children:[e.jsx(c,{children:A}),e.jsx(c,{className:"font-mono text-sm",children:R.kind}),e.jsx(c,{children:e.jsx(H,{variant:"gray",children:R.role})}),e.jsx(c,{className:"text-muted text-sm",children:R.media_type}),e.jsx(c,{className:"font-mono text-sm",children:$e(R.digest)}),e.jsx(c,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k.Link,{to:`/runs/${n.run_id}/artifacts/${A}`,children:e.jsx(D,{variant:"secondary",size:"sm",children:"View"})}),e.jsx(D,{variant:"secondary",size:"sm",onClick:()=>Te(A),children:"Download"})]})})]},A))})]}):e.jsx("p",{className:"text-muted",children:"No artifacts"})]}),be.length>0&&e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{className:"text-danger",children:"Errors"})}),be.map((R,A)=>e.jsxs("div",{className:"mb-2",children:[e.jsx("strong",{children:R.type}),": ",R.message,R.traceback&&e.jsx("pre",{className:"mt-2",children:R.traceback})]},A))]}),e.jsxs(qe,{open:h,onClose:()=>m(!1),title:"Delete Run",actions:e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),e.jsxs(D,{variant:"danger",onClick:We,disabled:T,children:[T&&e.jsx(I,{}),"Delete"]})]}),children:[e.jsx("p",{children:"Are you sure you want to delete this run?"}),e.jsx("p",{className:"font-mono text-sm mt-2",children:Q(n.run_id)}),e.jsx("p",{className:"text-sm text-danger mt-2",children:"This action cannot be undone."})]}),g&&e.jsx(ve,{message:g.message,variant:g.variant,visible:!!g,onClose:()=>_(null)})]})}function Qt(){const{currentWorkspace:t}=V(),{data:r,loading:a}=Ce();return e.jsxs(W,{children:[e.jsx(ge,{title:"Projects"}),e.jsx(b,{children:a?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(I,{})}):e.jsx(Ht,{projects:r??[],currentWorkspace:t})})]})}function Zt(){const[t,r]=k.useSearchParams(),{data:a}=Ce(),[n,o]=p.useState(t.get("project")||""),{data:d,loading:u,refetch:i}=Mt({project:n||void 0}),f=p.useCallback(h=>{o(h);const m=new URLSearchParams(t);h?m.set("project",h):m.delete("project"),r(m,{replace:!0})},[t,r]);return e.jsxs(W,{children:[e.jsx(ge,{title:"Run Groups"}),e.jsx(b,{className:"mb-4",children:e.jsxs(it,{children:[e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"project",children:"Project"}),e.jsxs(ce,{id:"project",value:n,onChange:h=>f(h.target.value),children:[e.jsx("option",{value:"",children:"All projects"}),a?.map(h=>e.jsx("option",{value:h.name,children:h.name},h.name))]})]}),e.jsxs(Z,{className:"flex items-end gap-2",children:[e.jsx(D,{variant:"primary",onClick:()=>i(),children:"Filter"}),u&&e.jsx(I,{})]})]})}),e.jsx(b,{children:u&&!d?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(I,{})}):e.jsx(Kt,{groups:d??[]})})]})}function es(){const{groupId:t}=k.useParams(),{api:r}=V(),{data:a,loading:n,error:o,refetch:d}=Ut(t),[u,i]=p.useState(null),f=pe(m=>r.deleteRun(m));p.useEffect(()=>{if(u){const m=setTimeout(()=>i(null),3e3);return()=>clearTimeout(m)}},[u]);const h=async m=>{try{await f.mutate(m),i({message:"Run deleted",variant:"success"}),d()}catch{i({message:"Failed to delete run",variant:"error"})}};return n?e.jsx(W,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(I,{})})}):o||!a?e.jsx(W,{children:e.jsx(b,{children:e.jsx(le,{message:"Group not found",hint:o?.message})})}):e.jsxs(W,{children:[e.jsx(ge,{title:e.jsxs(e.Fragment,{children:["Group ",e.jsx("span",{className:"font-mono",children:Q(t)})]}),subtitle:e.jsx("span",{className:"font-mono text-muted",children:t})}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsxs(G,{children:["Runs in Group (",a.runs.length,")"]})}),e.jsx(Ue,{runs:a.runs,onDelete:h,loading:f.loading})]}),u&&e.jsx(ve,{message:u.message,variant:u.variant,visible:!!u,onClose:()=>i(null)})]})}function Ys({className:t=""}){return e.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function Hs({className:t=""}){return e.jsxs("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Ks({className:t=""}){return e.jsxs("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function Ze({className:t=""}){return e.jsxs("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function Re({match:t}){return t?e.jsxs("span",{className:"diff-match inline-flex items-center gap-1.5",children:[e.jsx(Ys,{className:"flex-shrink-0"}),e.jsx("span",{className:"font-medium",children:"Match"})]}):e.jsxs("span",{className:"diff-mismatch inline-flex items-center gap-1.5",children:[e.jsx(Hs,{className:"flex-shrink-0"}),e.jsx("span",{className:"font-medium",children:"Different"})]})}function Js({warnings:t}){return!t||t.length===0?null:e.jsx("div",{className:"alert alert-warning mb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Ks,{className:"flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold mb-1",children:t.length===1?"Warning":`${t.length} Warnings`}),e.jsx("ul",{className:"space-y-1",children:t.map((r,a)=>e.jsx("li",{className:"text-sm",children:r},a))})]})]})})}function kt({label:t,run:r,variant:a}){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:`absolute top-0 left-0 w-1 h-full rounded-l ${a==="a"?"bg-info":"bg-primary"}`}),e.jsxs("div",{className:"pl-4",children:[e.jsx("p",{className:`text-xs font-semibold uppercase tracking-wider mb-2 ${a==="a"?"text-info":"text-primary"}`,children:t}),e.jsx(k.Link,{to:`/runs/${r.run_id}`,className:"text-base font-medium hover:underline",children:r.run_name||"Unnamed Run"}),e.jsx("p",{className:"font-mono text-xs mt-1 text-muted",children:Q(r.run_id)}),e.jsxs("p",{className:"text-sm mt-1 text-muted",children:[r.project," · ",Se(r.created_at)]})]})]})}function ie({children:t,badge:r}){return e.jsx(U,{children:e.jsx(G,{children:e.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[t,r&&e.jsx(H,{variant:r.variant,children:r.label})]})})})}function Xs({tvd:t,noiseContext:r}){if(t===0)return e.jsx("p",{className:"text-sm mt-4 text-success",children:"✓ Distributions are identical (TVD = 0)"});if(!r)return null;const{p_value:a,noise_ratio:n}=r;return a!=null?a>=.1?e.jsx("p",{className:"text-sm mt-4 text-success",children:"✓ Consistent with sampling noise — difference is not statistically significant"}):a>=.05?e.jsxs("p",{className:"text-sm mt-4 text-warning",children:["⚠ Borderline (p=",a.toFixed(2),") — consider increasing shots"]}):e.jsxs("p",{className:"text-sm mt-4 text-danger",children:["✗ Statistically significant difference (p=",a.toFixed(2),") — results show meaningful divergence"]}):n!=null?n<1.5?e.jsx("p",{className:"text-sm mt-4 text-success",children:"✓ TVD is within expected shot noise range"}):n<3?e.jsxs("p",{className:"text-sm mt-4 text-warning",children:["⚠ Ambiguous (",n.toFixed(1),"× expected noise) — consider increasing shots"]}):e.jsxs("p",{className:"text-sm mt-4 text-danger",children:["✗ TVD exceeds expected noise (",n.toFixed(1),"×) — results show meaningful differences"]}):null}function Qs(){const[t,r]=k.useSearchParams(),{data:a}=nt({limit:100}),n=a?.runs??[],[o,d]=p.useState(t.get("a")||""),[u,i]=p.useState(t.get("b")||""),[f,h]=p.useState(""),m=g=>{if(g.preventDefault(),!o||!u){h("Please select both runs to compare");return}if(o===u){h("Please select two different runs");return}h(""),r({a:o,b:u})};return e.jsxs(e.Fragment,{children:[e.jsx(b,{children:e.jsxs("form",{onSubmit:m,children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"a",children:"Run A (Baseline)"}),e.jsxs(ce,{id:"a",value:o,onChange:g=>{d(g.target.value),h("")},children:[e.jsx("option",{value:"",children:"Select run..."}),n.map(g=>e.jsxs("option",{value:g.run_id,children:[g.run_name||"Unnamed"," (",Q(g.run_id),") — ",g.project]},g.run_id))]})]}),e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"b",children:"Run B (Candidate)"}),e.jsxs(ce,{id:"b",value:u,onChange:g=>{i(g.target.value),h("")},children:[e.jsx("option",{value:"",children:"Select run..."}),n.map(g=>e.jsxs("option",{value:g.run_id,children:[g.run_name||"Unnamed"," (",Q(g.run_id),") — ",g.project]},g.run_id))]})]})]}),f&&e.jsx("p",{className:"text-sm mb-3 text-danger",children:f}),e.jsx(D,{type:"submit",variant:"primary",children:"Compare"})]})}),e.jsxs(b,{className:"mt-4",children:[e.jsx(U,{children:e.jsx(G,{children:"How it works"})}),e.jsxs("div",{className:"space-y-2 text-sm text-muted",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ze,{className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:"Select two runs to compare their parameters, metrics, and artifacts"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ze,{className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:"The diff shows changed values and computes TVD for result distributions"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ze,{className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:"You can also compare from the run detail page"})]})]})]})]})}function Zs({runIdA:t,runIdB:r}){const{data:a,loading:n,error:o}=Gt(t,r);if(n)return e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:[e.jsx(I,{}),e.jsx("p",{className:"text-sm text-muted",children:"Comparing runs..."})]})});if(o||!a)return e.jsx(b,{children:e.jsx(le,{message:"Failed to load diff",hint:o?.message})});const{run_a:d,run_b:u,report:i}=a,f=i.device_drift?.significant_drift?{variant:"warning",label:"Drift Detected"}:i.device_drift?.has_calibration_data?{variant:"success",label:"Stable"}:{variant:"gray",label:"No Data"};return e.jsxs(e.Fragment,{children:[e.jsx(Js,{warnings:i.warnings||[]}),e.jsx(b,{className:"mb-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsx(kt,{label:"Run A (Baseline)",run:d,variant:"a"}),e.jsx(kt,{label:"Run B (Candidate)",run:u,variant:"b"})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(b,{children:[e.jsx(ie,{children:"Metadata"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Project"}),e.jsx(c,{children:e.jsx(Re,{match:i.metadata.project_match})})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Backend"}),e.jsx(c,{children:e.jsx(Re,{match:i.metadata.backend_match})})]}),!i.metadata.project_match&&e.jsxs(e.Fragment,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"text-sm text-muted",children:"Project A"}),e.jsx(c,{className:"font-mono text-sm",children:i.metadata.project_a||"N/A"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"text-sm text-muted",children:"Project B"}),e.jsx(c,{className:"font-mono text-sm",children:i.metadata.project_b||"N/A"})]})]}),!i.metadata.backend_match&&e.jsxs(e.Fragment,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"text-sm text-muted",children:"Backend A"}),e.jsx(c,{className:"font-mono text-sm",children:i.metadata.backend_a||"N/A"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"text-sm text-muted",children:"Backend B"}),e.jsx(c,{className:"font-mono text-sm",children:i.metadata.backend_b||"N/A"})]})]})]})})]}),e.jsxs(b,{children:[e.jsx(ie,{children:"Fingerprints"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Run A"}),e.jsx(c,{className:"font-mono text-sm",children:$e(i.fingerprints.a)})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Run B"}),e.jsx(c,{className:"font-mono text-sm",children:$e(i.fingerprints.b)})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Match"}),e.jsx(c,{children:e.jsx(Re,{match:i.fingerprints.a===i.fingerprints.b})})]})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(b,{children:[e.jsx(ie,{badge:{variant:i.program.exact_match?"success":i.program.structural_match?"info":"warning",label:i.program.exact_match?"Exact Match":i.program.structural_match?"Structural Match":"Different"},children:"Program"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Exact Match"}),e.jsx(c,{children:e.jsx(Re,{match:i.program.exact_match})})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Structural Match"}),e.jsx(c,{children:e.jsx(Re,{match:i.program.structural_match})})]})]})})]}),e.jsxs(b,{children:[e.jsx(ie,{badge:f,children:"Device Calibration"}),i.device_drift?.significant_drift?e.jsx("p",{className:"text-sm text-warning",children:"Significant calibration drift detected between runs"}):i.device_drift?.has_calibration_data?e.jsx("p",{className:"text-muted",children:"Calibration within acceptable thresholds"}):e.jsx("p",{className:"text-muted",children:"No calibration data available"})]})]}),e.jsxs(b,{className:"mb-4",children:[e.jsx(ie,{badge:{variant:i.params.match?"success":"warning",label:i.params.match?"Match":"Different"},children:"Parameters"}),i.params.match?e.jsx("p",{className:"text-muted",children:"All parameters match"}):e.jsx(e.Fragment,{children:i.params.changed&&Object.keys(i.params.changed).length>0&&e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Parameter"}),e.jsx(N,{children:"Run A"}),e.jsx(N,{children:"Run B"})]})}),e.jsx(B,{children:Object.entries(i.params.changed).map(([h,m])=>e.jsxs(j,{children:[e.jsx(c,{children:h}),e.jsx(c,{className:"font-mono",children:String(m.a)}),e.jsx(c,{className:"font-mono",children:String(m.b)})]},h))})]})})]}),e.jsxs(b,{className:"mb-4",children:[e.jsx(ie,{badge:{variant:i.metrics.match?"success":"warning",label:i.metrics.match?"Match":"Different"},children:"Metrics"}),i.metrics.match?e.jsx("p",{className:"text-muted",children:"All metrics match"}):e.jsx(e.Fragment,{children:i.metrics.changed&&Object.keys(i.metrics.changed).length>0&&e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Metric"}),e.jsx(N,{children:"Run A"}),e.jsx(N,{children:"Run B"})]})}),e.jsx(B,{children:Object.entries(i.metrics.changed).map(([h,m])=>e.jsxs(j,{children:[e.jsx(c,{children:h}),e.jsx(c,{className:"font-mono",children:m.a}),e.jsx(c,{className:"font-mono",children:m.b})]},h))})]})})]}),i.circuit_diff&&e.jsxs(b,{className:"mb-4",children:[e.jsx(ie,{badge:{variant:i.circuit_diff.match?"success":"warning",label:i.circuit_diff.match?"Match":"Different"},children:"Circuit"}),i.circuit_diff.match?e.jsx("p",{className:"text-muted",children:"Circuit structure matches"}):e.jsxs("div",{className:"space-y-4",children:[i.circuit_diff.changed&&Object.keys(i.circuit_diff.changed).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"Changed Properties"}),e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Property"}),e.jsx(N,{children:"Run A"}),e.jsx(N,{children:"Run B"}),e.jsx(N,{children:"Delta"})]})}),e.jsx(B,{children:Object.entries(i.circuit_diff.changed).map(([h,m])=>e.jsxs(j,{children:[e.jsx(c,{children:m.label||h}),e.jsx(c,{className:"font-mono",children:String(m.a)}),e.jsx(c,{className:"font-mono",children:String(m.b)}),e.jsx(c,{className:"font-mono",children:m.delta!=null&&e.jsxs("span",{className:m.delta>0?"text-danger":"text-success",children:[m.delta>0?"+":"",m.delta,m.pct!=null&&` (${m.pct>0?"+":""}${m.pct.toFixed(1)}%)`]})})]},h))})]})]}),i.circuit_diff.is_clifford_changed&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"Clifford Status"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Run A"}),e.jsx(c,{className:"font-mono",children:i.circuit_diff.is_clifford_a!=null?String(i.circuit_diff.is_clifford_a):"unknown"})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Run B"}),e.jsx(c,{className:"font-mono",children:i.circuit_diff.is_clifford_b!=null?String(i.circuit_diff.is_clifford_b):"unknown"})]})]})})]}),i.circuit_diff.added_gates&&i.circuit_diff.added_gates.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"New Gate Types (in B)"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.circuit_diff.added_gates.map(h=>e.jsx(H,{variant:"success",children:h},h))})]}),i.circuit_diff.removed_gates&&i.circuit_diff.removed_gates.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"Removed Gate Types (from A)"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.circuit_diff.removed_gates.map(h=>e.jsx(H,{variant:"danger",children:h},h))})]})]})]}),i.tvd!=null&&e.jsxs(b,{className:"mb-4",children:[e.jsx(ie,{children:"Results Distribution"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Total Variation Distance (TVD)"}),e.jsx(c,{className:"font-mono font-medium",children:i.tvd.toFixed(6)})]}),i.shots&&e.jsxs(j,{children:[e.jsx(c,{children:"Total Shots (A / B)"}),e.jsxs(c,{className:"font-mono",children:[i.shots.a," / ",i.shots.b]})]}),i.noise_context?.noise_p95&&e.jsxs(j,{children:[e.jsx(c,{children:"Noise Threshold (p95)"}),e.jsx(c,{className:"font-mono",children:i.noise_context.noise_p95.toFixed(6)})]}),i.noise_context?.p_value!=null&&e.jsxs(j,{children:[e.jsx(c,{children:"p-value"}),e.jsx(c,{className:"font-mono",children:i.noise_context.p_value.toFixed(4)})]})]})}),e.jsx(Xs,{tvd:i.tvd,noiseContext:i.noise_context})]})]})}function ts(){const[t]=k.useSearchParams(),r=t.get("a"),a=t.get("b"),n=r&&a;return e.jsxs(W,{children:[e.jsx("div",{className:"page-header",children:e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:"Compare Runs"}),n&&e.jsx("p",{className:"text-sm mt-1 text-muted",children:e.jsx(k.Link,{to:"/diff",children:"← Select different runs"})})]})}),n?e.jsx(Zs,{runIdA:r,runIdB:a}):e.jsx(Qs,{})]})}function ss(){const{api:t}=V(),[r,a]=p.useState(""),[n,o]=p.useState(null),[d,u]=p.useState(!1),[i,f]=p.useState(""),{mutate:h,loading:m}=pe(async()=>{const _=await t.listRuns({q:r,limit:100});return o(_.runs),u(!0),_}),g=_=>{if(_.preventDefault(),!r.trim()){f("Please enter a search query");return}f(""),h()};return e.jsxs(W,{children:[e.jsx("div",{className:"page-header",children:e.jsx("h1",{className:"page-title",children:"Search Runs"})}),e.jsx(b,{className:"mb-4",children:e.jsxs("form",{onSubmit:g,children:[e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"q",children:"Query"}),e.jsx(Me,{id:"q",type:"text",value:r,onChange:_=>{a(_.target.value),f("")},placeholder:"metric.fidelity > 0.95 and params.shots = 1000",className:"font-mono"})]}),i&&e.jsx("p",{className:"text-sm text-[#DC4A4A] mb-3",children:i}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(D,{type:"submit",variant:"primary",disabled:m,children:[m&&e.jsx(I,{}),"Search"]}),m&&e.jsx("span",{className:"text-muted text-sm",children:"Searching..."})]})]})}),d&&n&&e.jsx(b,{className:"mb-4",children:n.length>0?e.jsx(Ue,{runs:n}):e.jsx("p",{className:"text-muted text-center py-8",children:"No runs match your query"})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Query Syntax"})}),e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Field"}),e.jsx(N,{children:"Description"})]})}),e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"params.X"}),e.jsx(c,{children:"Parameter value"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"metric.X"}),e.jsx(c,{children:"Metric value"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"tags.X"}),e.jsx(c,{children:"Tag value"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"status"}),e.jsx(c,{children:"Run status"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"project"}),e.jsx(c,{children:"Project name"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"backend"}),e.jsx(c,{children:"Backend name"})]})]})]})]}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Operators"})}),e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Operator"}),e.jsx(N,{children:"Description"})]})}),e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"="}),e.jsx(c,{children:"Equals"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"!="}),e.jsx(c,{children:"Not equals"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:">"}),e.jsx(c,{children:"Greater than"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:">="}),e.jsx(c,{children:"Greater or equal"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"<"}),e.jsx(c,{children:"Less than"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"<="}),e.jsx(c,{children:"Less or equal"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"~"}),e.jsx(c,{children:"Contains"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"and"}),e.jsx(c,{children:"Combine conditions"})]})]})]})]})]}),e.jsxs(b,{className:"mt-4",children:[e.jsx(U,{children:e.jsx(G,{children:"Examples"})}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"metric.fidelity > 0.95"}),e.jsx(c,{children:"High fidelity runs"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"params.shots = 1000 and status = FINISHED"}),e.jsx(c,{children:"Finished runs with 1000 shots"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"tags.backend ~ ibm"}),e.jsx(c,{children:"Runs with IBM backends"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"metric.error < 0.01"}),e.jsx(c,{children:"Low error runs"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"project = vqe and metric.energy < -2.0"}),e.jsx(c,{children:"VQE runs with low energy"})]})]})})]})]})}function rs(){const{runId:t,index:r}=k.useParams(),a=parseInt(r,10),{api:n}=V(),{data:o}=at(t),{data:d,loading:u,error:i}=Wt(t,a),[f,h]=p.useState(null);p.useEffect(()=>{if(f){const P=setTimeout(()=>h(null),3e3);return()=>clearTimeout(P)}},[f]);const m=async()=>{try{const P=n.getArtifactDownloadUrl(t,a),re=await fetch(P);if(!re.ok)throw new Error("Download failed");const ae=await re.blob(),J=document.createElement("a");J.href=URL.createObjectURL(ae),J.download=g?.kind||`artifact-${a}`,J.click(),URL.revokeObjectURL(J.href),h({message:"Download started",variant:"success"})}catch{h({message:"Download failed",variant:"error"})}};if(u)return e.jsx(W,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(I,{})})});if(i||!d)return e.jsx(W,{children:e.jsx(b,{children:e.jsx(le,{message:"Artifact not found",hint:i?.message})})});const{artifact:g,size:_,content:z,content_json:w,preview_available:K,error:T}=d,q=10*1024*1024;return e.jsxs(W,{children:[e.jsx(ge,{title:g.kind,subtitle:e.jsxs(e.Fragment,{children:["← Back to run ",e.jsxs(k.Link,{to:`/runs/${t}`,children:[Q(t),o?.run_name&&` — ${o.run_name}`]})]}),actions:e.jsx(D,{variant:"primary",onClick:m,children:"Download"})}),e.jsx(b,{className:"mb-4",children:e.jsx(Be,{items:[{label:"Kind",value:e.jsx("span",{className:"font-mono",children:g.kind})},{label:"Role",value:e.jsx(H,{variant:"gray",children:g.role})},{label:"Media Type",value:g.media_type},{label:"Digest",value:e.jsx("span",{className:"font-mono text-sm",children:g.digest})},{label:"Size",value:Ee(_)}]})}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Content"})}),T?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-danger",children:["Error loading artifact: ",T]}),e.jsx("p",{className:"text-muted mt-2",children:e.jsx(D,{variant:"primary",onClick:m,children:"Download to view"})})]}):K?w?e.jsx("pre",{children:Ft(w)}):z?e.jsx("pre",{children:z}):e.jsxs("p",{className:"text-muted",children:["Binary content (",Ee(_),") — download to view"]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-muted",children:[e.jsx("strong",{children:"Artifact too large for preview"})," (",Ee(_)," exceeds ",Ee(q)," limit)"]}),e.jsx("p",{className:"text-sm text-muted mt-2",children:"Download the artifact to view its contents."}),e.jsx("p",{className:"mt-4",children:e.jsx(D,{variant:"primary",onClick:m,children:"Download"})})]})]}),f&&e.jsx(ve,{message:f.message,variant:f.variant,visible:!!f,onClose:()=>h(null)})]})}const ns=[{path:"/",element:e.jsx(k.Navigate,{to:"/runs",replace:!0})},{path:"/runs",element:e.jsx(Yt,{})},{path:"/runs/:runId",element:e.jsx(Xt,{})},{path:"/runs/:runId/artifacts/:index",element:e.jsx(rs,{})},{path:"/projects",element:e.jsx(Qt,{})},{path:"/groups",element:e.jsx(Zt,{})},{path:"/groups/:groupId",element:e.jsx(es,{})},{path:"/diff",element:e.jsx(ts,{})},{path:"/search",element:e.jsx(ss,{})}];function lt(t=[]){return k.createBrowserRouter([...ns,...t])}const as=lt();function er({additionalRoutes:t,...r}){const a=t?.length?lt(t):as;return e.jsx(qt,{...r,children:e.jsx(k.RouterProvider,{router:a})})}exports.Alert=Ms;exports.ApiClient=Dt;exports.ApiError=je;exports.App=er;exports.AppProvider=qt;exports.ArtifactPage=rs;exports.Badge=H;exports.Button=D;exports.Card=b;exports.CardHeader=U;exports.CardTitle=G;exports.DiffPage=ts;exports.EmptyState=le;exports.ExportRunButton=Jt;exports.FormGroup=Z;exports.FormRow=it;exports.GroupDetailPage=es;exports.GroupsPage=Zt;exports.GroupsTable=Kt;exports.Input=Me;exports.KVList=Be;exports.Label=ne;exports.Layout=W;exports.LayoutConfigProvider=qs;exports.Modal=qe;exports.POLL_INTERVAL=st;exports.PageHeader=ge;exports.ProjectsPage=Qt;exports.ProjectsTable=Ht;exports.RunDetailPage=Xt;exports.RunsPage=Yt;exports.RunsTable=Ue;exports.SearchPage=ss;exports.Select=ce;exports.Spinner=I;exports.StatusBadge=ct;exports.Table=$;exports.TableBody=B;exports.TableCell=c;exports.TableHead=se;exports.TableHeader=N;exports.TableRow=j;exports.ThemeProvider=$s;exports.Toast=ve;exports.api=At;exports.buildUrl=Os;exports.cn=O;exports.coreRoutes=ns;exports.createRouter=lt;exports.elapsedSeconds=et;exports.formatBytes=Ee;exports.formatDuration=tt;exports.formatNumber=Lt;exports.isTerminalStatus=Ie;exports.jsonPretty=Ft;exports.router=as;exports.shortDigest=$e;exports.shortId=Q;exports.timeAgo=Se;exports.truncate=Ot;exports.useApp=V;exports.useArtifact=Wt;exports.useDiff=Gt;exports.useGroup=Ut;exports.useGroups=Mt;exports.useLayoutConfig=zt;exports.useMutation=pe;exports.usePolling=rt;exports.useProjects=Ce;exports.useRun=at;exports.useRuns=nt;exports.useTheme=Bt;exports.useThemeOptional=Bs;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { AppProvider, useApp } from './hooks';
|
|
|
4
4
|
export type { AppProviderProps, AppContextValue, AsyncState } from './hooks';
|
|
5
5
|
export { router, createRouter, coreRoutes } from './router';
|
|
6
6
|
export { ApiClient, ApiError, api } from './api';
|
|
7
|
-
export type { ApiConfig } from './api';
|
|
7
|
+
export type { ApiConfig, RequestOptions } from './api';
|
|
8
8
|
export { useRuns, useRun, useProjects, useGroups, useGroup, useDiff, useArtifact, useMutation, usePolling, POLL_INTERVAL, ThemeProvider, useTheme, useThemeOptional, } from './hooks';
|
|
9
9
|
export type { Theme, ThemeContextValue, ThemeProviderProps } from './hooks';
|
|
10
10
|
export { Layout, PageHeader, LayoutConfigProvider, useLayoutConfig } from './components/Layout';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9C,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG7E,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG5D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjD,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9C,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG7E,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG5D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjD,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,EACL,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,QAAQ,EACR,OAAO,EACP,WAAW,EACX,WAAW,EACX,UAAU,EACV,aAAa,EACb,aAAa,EACb,QAAQ,EACR,gBAAgB,GACjB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG5E,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAChG,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGxE,OAAO,EACL,KAAK,EACL,MAAM,EACN,IAAI,EACJ,UAAU,EACV,SAAS,EACT,KAAK,EACL,OAAO,EACP,UAAU,EACV,MAAM,EACN,KAAK,EACL,KAAK,EACL,SAAS,EACT,OAAO,EACP,KAAK,EACL,KAAK,EACL,MAAM,GACP,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,YAAY,EACZ,UAAU,EACV,aAAa,EACb,UAAU,EACV,WAAW,EACX,SAAS,EACT,eAAe,EACf,cAAc,EACd,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,eAAe,EACf,WAAW,EACX,UAAU,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,KAAK,EACL,SAAS,EACT,SAAS,EACT,QAAQ,EACR,WAAW,EACX,SAAS,GACV,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAChE,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGzF,OAAO,EACL,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,UAAU,EACV,eAAe,EACf,QAAQ,EACR,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,OAAO,EACP,WAAW,EACX,OAAO,EACP,YAAY,EACZ,WAAW,EACX,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,gBAAgB,EAChB,cAAc,EACd,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,SAAS,EACT,OAAO,EACP,KAAK,EACL,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,SAAS,EACT,OAAO,EACP,YAAY,GACb,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -637,8 +637,9 @@ class Rt {
|
|
|
637
637
|
}
|
|
638
638
|
const d = await fetch(o, {
|
|
639
639
|
method: r,
|
|
640
|
-
headers: this.headers,
|
|
641
|
-
body: n.body ? JSON.stringify(n.body) : void 0
|
|
640
|
+
headers: { ...this.headers, ...n.headers },
|
|
641
|
+
body: n.body ? JSON.stringify(n.body) : void 0,
|
|
642
|
+
credentials: n.credentials
|
|
642
643
|
});
|
|
643
644
|
if (!d.ok) {
|
|
644
645
|
const u = await d.json().catch(() => ({ detail: "Unknown error" }));
|
|
@@ -1374,9 +1375,7 @@ function Ut({
|
|
|
1374
1375
|
bundleSize: te.size,
|
|
1375
1376
|
artifactCount: T.artifact_count,
|
|
1376
1377
|
objectCount: T.object_count
|
|
1377
|
-
}), p({ message: "Bundle downloaded successfully", variant: "success" })
|
|
1378
|
-
h(!1), i({ status: "idle" });
|
|
1379
|
-
}, 2e3);
|
|
1378
|
+
}), p({ message: "Bundle downloaded successfully", variant: "success" });
|
|
1380
1379
|
} catch (T) {
|
|
1381
1380
|
const B = T instanceof Error ? T.message : "Export failed";
|
|
1382
1381
|
i({ status: "error", message: B }), p({ message: B, variant: "error" });
|