@qaily/playwright-html-reporter 1.0.1-beta.2 → 1.0.1-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/README.md +1 -0
- package/app/assets/{ai-labels-RxWQyXOZ.js → ai-labels-kOY7eKf_.js} +1 -1
- package/app/assets/{chronoscope-view-DzkFIDnY.js → chronoscope-view-D6I7WR1Z.js} +1 -1
- package/app/assets/{classic-view-XwD0J2Xr.js → classic-view-B4rO1rQX.js} +1 -1
- package/app/assets/{classic-view-BsyNALVL.js → classic-view-BrDjGEFT.js} +1 -1
- package/app/assets/{classic-view-BdOOIEJH.js → classic-view-C5zIaQbY.js} +32 -32
- package/app/assets/{classic-view-DsBjeaSR.js → classic-view-CA2jsB8a.js} +1 -1
- package/app/assets/{classic-view-3xvAtjNz.js → classic-view-CLY1_X2f.js} +1 -1
- package/app/assets/{classic-view-Ciekrvgw.js → classic-view-CQn_HJUG.js} +2 -2
- package/app/assets/index-BGc2KRte.js +983 -0
- package/app/assets/{index-CkVAQmKJ.js → index-BSeSdMcj.js} +2 -2
- package/app/assets/{index-mIO1FNDw.js → index-Bo6ugK3I.js} +2 -2
- package/app/assets/{index-Rhk-vtb9.js → index-Bx_mFI-E.js} +2 -2
- package/app/assets/{index-BNQj7yhU.js → index-CEMZIb_j.js} +2 -2
- package/app/assets/{index-DqZr3quD.js → index-CjIdaEbY.js} +2 -2
- package/app/assets/{index-BU7HqveP.js → index-DIUMnB6u.js} +3 -3
- package/app/assets/{index-BXYjgFWc.js → index-DKORV85a.js} +3 -3
- package/app/assets/{monthly-view-CqYfmVC_.js → monthly-view-BBOPlVBV.js} +1 -1
- package/app/assets/{period-BDS3oIgF.js → period-BVCCS0gi.js} +1 -1
- package/app/assets/{runs-DNJBxr_t.js → runs-DF40idw3.js} +1 -1
- package/app/assets/{settings-view-BcQahji5.js → settings-view-CVNbI43B.js} +1 -1
- package/app/assets/{status-CufZD7gm.js → status-U1ziVPrb.js} +1 -1
- package/app/assets/{styles-BVxnhMnQ.js → styles-BtyAt7f-.js} +1 -1
- package/app/assets/{weekly-view-B_7LFIay.js → weekly-view-COWF8G2Z.js} +1 -1
- package/app/index.html +1 -1
- package/dist/cli.mjs +210 -27
- package/package.json +1 -1
- package/app/assets/index-FKJ4jNss.js +0 -983
|
@@ -0,0 +1,983 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CEMZIb_j.js","./runs-DF40idw3.js","./lanes-Bb9_UFmn.js","./index-BSeSdMcj.js","./period-BVCCS0gi.js","./index-Bx_mFI-E.js","./index-DIUMnB6u.js","./index-CjIdaEbY.js","./index-DKORV85a.js","./coverage-BPNr95uF.js","./chronoscope-view-D6I7WR1Z.js","./status-U1ziVPrb.js","./weekly-view-COWF8G2Z.js","./styles-BtyAt7f-.js","./monthly-view-BBOPlVBV.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function t(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=t(r);fetch(r.href,i)}})();class ht extends Error{constructor(e,t){super(`${e} failed (${t.code}): ${t.message}`),this.name="RpcError",this.method=e,this.code=t.code,this.data=t.data}}class xe extends Error{constructor(e){super(e),this.name="ConnectionError"}}class un{constructor(e,t={}){this.ws=null,this.nextId=1,this.clientSeq=1,this.pending=new Map,this.listeners=[],this.closeHandlers=[],this.pingTimer=null,this.pingSupported=!0,this.closed=!1,this.url=e,this.WebSocketImpl=t.WebSocketImpl??globalThis.WebSocket,this.requestTimeoutMs=t.requestTimeoutMs??3e4,this.pingIntervalMs=t.pingIntervalMs??3e4,this.onFrame=t.onFrame}connect(){return new Promise((e,t)=>{let s=!1;const r=new this.WebSocketImpl(this.url);this.ws=r,r.addEventListener("open",()=>{s=!0,this.startPing(),e()}),r.addEventListener("message",i=>this.handleFrame(i.data)),r.addEventListener("close",i=>{this.closed=!0,this.stopPing();for(const[,a]of this.pending)clearTimeout(a.timer),a.reject(new xe(`Connection closed during ${a.method}`));if(this.pending.clear(),!s){t(new xe("Could not connect. Either the agent host is not running at this URL, the connection token was rejected (403), or the host failed to start (503). Chrome may also be waiting for you to allow local network access."));return}for(const a of this.closeHandlers)a({code:i.code,reason:i.reason})}),r.addEventListener("error",()=>{})})}request(e,t,s=this.requestTimeoutMs){if(!this.ws||this.closed)return Promise.reject(new xe("Not connected"));const r=this.nextId++;return new Promise((i,a)=>{const o=setTimeout(()=>{this.pending.delete(r),a(new xe(`${e} timed out after ${s} ms`))},s);this.pending.set(r,{method:e,resolve:i,reject:a,timer:o}),this.send({jsonrpc:"2.0",id:r,method:e,params:t})})}notify(e,t){this.send({jsonrpc:"2.0",method:e,params:t})}dispatch(e,t){const s=this.clientSeq++;return this.notify("dispatchAction",{channel:e,clientSeq:s,action:t}),s}on(e,t,s){const r={method:e,channel:t,handler:s};return this.listeners.push(r),()=>{this.listeners=this.listeners.filter(i=>i!==r)}}onClose(e){this.closeHandlers.push(e)}close(){this.stopPing(),this.ws&&!this.closed&&this.ws.close(1e3)}send(e){if(!this.ws)throw new xe("Not connected");const t=JSON.stringify(e);this.onFrame?.("out",t),this.ws.send(t)}handleFrame(e){const t=typeof e=="string"?e:new TextDecoder().decode(e);this.onFrame?.("in",t);let s;try{s=JSON.parse(t)}catch{console.warn("[ahp] non-JSON frame ignored");return}if(s.id!==void 0&&s.method===void 0){const i=this.pending.get(s.id);if(!i)return;this.pending.delete(s.id),clearTimeout(i.timer),s.error?i.reject(new ht(i.method,s.error)):i.resolve(s.result);return}if(typeof s.method!="string")return;const r=s.params?.channel;for(const i of[...this.listeners])if(i.method===s.method&&!(i.channel!=="*"&&i.channel!==r))try{i.handler(s.params,s)}catch(a){console.error("[ahp] listener failed",a)}}startPing(){this.pingIntervalMs&&(this.pingTimer=setInterval(()=>{this.pingSupported&&this.request("ping",{channel:"ahp-root://"},1e4).catch(e=>{e instanceof ht&&e.code===-32601?this.pingSupported=!1:console.warn("[ahp] ping failed:",e.message)})},this.pingIntervalMs))}stopPing(){this.pingTimer&&clearInterval(this.pingTimer),this.pingTimer=null}}const V="ahp-root://",pn=["1.0.0","0.10.0","0.9.0"];function fn(n){const e=String(n).match(/wss?:\/\/\S+/);if(!e)throw new Error("The agent host URL must start with ws://");const t=new URL(e[0]),s=t.searchParams.get("tkn");return t.searchParams.delete("tkn"),{url:t.toString().replace(/\/$/,"").replace(/\/\?$/,""),tkn:s}}function mn(n,e){const t=new URL(n);return t.searchParams.set("tkn",e),t.toString()}function gn(n){const e=String(n).trim();if(/^[A-Za-z]:[\\/]/.test(e)){const[t,...s]=e.replace(/\\/g,"/").split("/");return`file:///${t}/`+s.map(encodeURIComponent).join("/")}if(e.startsWith("/"))return"file://"+e.split("/").map(encodeURIComponent).join("/");throw new Error("The working directory must be an absolute path")}function yn(n){const e=String(n??"").trim();if(!e)return"";const t=new URL(/^https?:\/\//i.test(e)?e:`https://${e}`);return["github.com","www.github.com","api.github.com"].includes(t.host)?"":`${t.protocol}//${t.host}`}function G(n){return typeof n=="string"?n:n&&typeof n=="object"&&"markdown"in n?String(n.markdown):""}class Et{constructor(e={}){this.client=null,this.protocolVersion=null,this.agents=[],this.rootConfig={},this.clientOptions=e}async connect(e,t){const s=new un(mn(e,t),this.clientOptions);this.client=s,await s.connect();const r=await this.initialize(pn).catch(a=>{const o=a instanceof ht&&a.code===-32005?a.data?.supportedVersions:null;if(Array.isArray(o))return this.initialize(o);throw a});this.protocolVersion=r?.protocolVersion??null;let i=r?.snapshots?.find?.(a=>a.resource===V)?.state;return i||(i=(await s.request("subscribe",{channel:V}))?.snapshot?.state),this.agents=i?.agents??[],this.rootConfig={...i?.config?.values??{}},s.on("action",V,({action:a})=>{a?.type==="root/agentsChanged"&&Array.isArray(a.agents)&&(this.agents=a.agents),a?.type==="root/configChanged"&&(this.rootConfig=a.replace?{...a.config}:{...this.rootConfig,...a.config})}),{protocolVersion:this.protocolVersion,agents:this.agents}}initialize(e){return this.client.request("initialize",{channel:V,protocolVersions:e,clientId:crypto.randomUUID(),clientInfo:{name:"qaily-report",version:"0.1.0"},initialSubscriptions:[V]})}get gitHubEnterpriseUri(){return String(this.rootConfig.githubEnterpriseUri??"")}async setGitHubEnterpriseUri(e){if(e===this.gitHubEnterpriseUri)return!1;const t=this.client,s=new Promise(r=>{const i=t.on("action",V,({action:a})=>{a?.type==="root/agentsChanged"&&(i(),r())});setTimeout(()=>{i(),r()},5e3)});return t.dispatch(V,{type:"root/configChanged",config:{githubEnterpriseUri:e}}),await s,!0}static authResource(e){const t=e?.protectedResources??[];return(t.find(s=>s.required)??t[0])?.resource??null}agent(e){const t=this.agents.find(s=>s.provider===e);if(!t){const s=this.agents.map(r=>r.provider).join(", ")||"none";throw new Error(`The agent host does not offer "${e}" (offered: ${s}). Check Settings → AI → Agent provider.`)}return t}async authenticate(e,t){const s=Et.authResource(this.agent(e));return s?(await this.client.request("authenticate",{channel:V,resource:s,token:t}),s):null}async openChat(e,t,s={}){const r=this.client;if(!r||r.closed)throw new Error("Not connected to the agent host");this.agent(e);const i=`ahp-session:/${crypto.randomUUID()}`;await r.request("createSession",{channel:i,provider:e,workingDirectories:[gn(t)],config:{autoApprove:"default",isolation:"folder",mode:"interactive",...s}},6e4);const o=(await r.request("subscribe",{channel:i}))?.snapshot?.state??{},c=o.chats?.[0],l=o.defaultChat??(typeof c=="string"?c:c?.resource);if(!l)throw new Error("The new agent session has no chat channel");return await r.request("subscribe",{channel:l}),new vn(r,i,l)}close(){this.client?.close(),this.client=null}}class vn{constructor(e,t,s){this.turnStarts=new Map,this.client=e,this.sessionUri=t,this.chatUri=s}onAction(e){return this.client.on("action",this.chatUri,t=>{t?.action&&e(t.action)})}sendPrompt(e){const t=crypto.randomUUID();return this.turnStarts.set(t,Date.now()),this.client.dispatch(this.chatUri,{type:"chat/turnStarted",turnId:t,startedAt:new Date().toISOString(),message:{text:e,origin:{kind:"user"}}}),t}cancelTurn(e){const t=this.turnStarts.get(e)??Date.now();this.client.dispatch(this.chatUri,{type:"chat/turnCancelled",turnId:e,duration:Date.now()-t})}confirmTool(e){const t=e.approved?{type:"chat/toolCallConfirmed",turnId:e.turnId,toolCallId:e.toolCallId,approved:!0,confirmed:"user-action"}:{type:"chat/toolCallConfirmed",turnId:e.turnId,toolCallId:e.toolCallId,approved:!1,reason:"denied"};e.optionId&&(t.selectedOptionId=e.optionId),this.client.dispatch(this.chatUri,t)}}function bn(n){if(n==null)return"";if(typeof n!="string")return JSON.stringify(n,null,2);try{return JSON.stringify(JSON.parse(n),null,2)}catch{return n}}function Ps(n){const e=n.part?.error??n.error??{},t=G(e.message??n.message)||"Unknown error",s=e.errorType?` [${e.errorType}]`:"",r=/No GitHub OAuth token/i.test(t)?" The agent host is not signed in: add a GitHub token (gh auth token) in Settings → Tokens, or sign the host in from VS Code.":/Personal Access Tokens are not supported/i.test(t)||/400 Bad Request/.test(t)?" Personal access tokens do not work through the agent host; use `gh auth token` (gho_…).":"";return`Error${s}: ${t}${r}`}class ut{constructor(e=()=>{}){this.entries=[],this.onChange=e}find(e,t){return this.entries.find(s=>s.kind===e&&s.id===t)}addUser(e,t){this.entries.push({kind:"user",id:e,text:t}),this.onChange()}status(e,t=!1){this.entries.push({kind:"status",id:crypto.randomUUID(),text:e,error:t}),this.onChange()}answerOf(e){return e.map(t=>this.find("text",t)?.text??"").join("")}apply(e){let t=null;switch(e.type){case"chat/responsePart":{const s=e.part??{},r=s.id??crypto.randomUUID();s.kind==="reasoning"||s.kind==="thinking"?this.entries.push({kind:"reasoning",id:r,text:G(s.content??"")}):s.kind==="error"?this.entries.push({kind:"status",id:r,text:Ps({part:s}),error:!0}):(this.entries.push({kind:"text",id:r,text:G(s.content??s.text??"")}),t=r);break}case"chat/delta":{let s=this.find("text",e.partId)??this.find("reasoning",e.partId);s||(s={kind:"text",id:e.partId,text:""},this.entries.push(s)),s.text+=e.content??"",s.kind==="text"&&(t=s.id);break}case"chat/reasoning":{const s=e.partId??`reasoning-${e.turnId}`;let r=this.find("reasoning",s);r||(r={kind:"reasoning",id:s,text:""},this.entries.push(r)),r.text+=G(e.content??e.text??"");break}case"chat/toolCallStart":case"chat/toolCallDelta":case"chat/toolCallReady":case"chat/toolCallConfirmed":case"chat/toolCallComplete":this.tool(e);break;case"chat/usage":{const s=e.model??e.usage?.model;typeof s=="string"&&(this.model=s);break}default:return null}return this.onChange(),t}tool(e){let t=this.find("tool",e.toolCallId);switch(t||(t={kind:"tool",id:e.toolCallId,turnId:e.turnId,name:e.displayName??e.toolName??"Tool",message:"",input:"",status:"preparing",auto:!0,options:[],result:""},this.entries.push(t)),e.type){case"chat/toolCallStart":t.name=e.displayName??e.toolName??t.name;break;case"chat/toolCallDelta":e.invocationMessage&&(t.message=G(e.invocationMessage));break;case"chat/toolCallReady":{const s=G(e.confirmationTitle)||G(e.invocationMessage)||e.intention||"";if(s&&(t.message=s),t.input=bn(e.toolInput),e.confirmed){t.status!=="asking"&&(t.status="running");break}t.auto=!1,t.status="asking";const r=Array.isArray(e.options)&&e.options.length?e.options:[{label:"Deny",kind:"deny"},{label:"Approve",kind:"approve"}];t.options=[...r.filter(i=>i.kind==="deny"),...r.filter(i=>i.kind!=="deny")];break}case"chat/toolCallConfirmed":t.status==="asking"&&(t.status=e.approved?"approved":"denied"),t.options=[];break;case"chat/toolCallComplete":t.status=e.result?.success===!1?"failed":"done",t.options=[],t.result=G(e.result?.pastTenseMessage);break}}pendingApprovals(){return this.entries.filter(e=>e.kind==="tool"&&e.status==="asking")}}function pt(n,e,t,s){return new Promise((r,i)=>{const a=[];let o="";const c=[],l=p=>{if(!o)return void c.push(p);if(p.turnId!==void 0&&p.turnId!==o||p.type==="chat/turnStarted")return;if(p.type==="chat/turnComplete")return u(()=>r(t.answerOf(a)));if(p.type==="chat/turnCancelled")return u(()=>i(new Error("Cancelled")));if(p.type==="chat/error"){const C=Ps(p);return t.status(C,!0),u(()=>i(new Error(C)))}const b=t.apply(p);b&&!a.includes(b)&&a.push(b)},h=n.onAction(l),d=()=>{o&&n.cancelTurn(o),u(()=>i(new Error("Cancelled")))},u=p=>{h(),s?.removeEventListener("abort",d),p()};if(s?.aborted)return u(()=>i(new Error("Cancelled")));s?.addEventListener("abort",d),o=n.sendPrompt(e),t.addUser(o,e);for(const p of c.splice(0))l(p)})}function wn(n){const e=[...n.matchAll(/```([a-zA-Z]*)[^\n]*\n([\s\S]*?)```/g)].map(r=>({lang:r[1].toLowerCase(),body:r[2]})),t=[...e.filter(r=>r.lang==="json").reverse(),...e.filter(r=>r.lang!=="json").reverse()];for(const r of t)try{return JSON.parse(r.body)}catch{}const s=n.trim();if(s.startsWith("{"))try{return JSON.parse(s)}catch{return}}function _n(n,e){if(e==null||Number.isNaN(e))return"none";for(const t of n)if((t.min===void 0||e>=t.min)&&(t.max===void 0||e<=t.max))return t.level;return"none"}function xa(n,e){const t=e.excludeSkipped?n.total-n.skipped:n.total;return t<=0?null:(n.passed+(e.flakyCountsAsPassed?n.flaky:0))/t*100}const ka=1;function xn(n){return n>=200&&n<300?"ok":n===404||n===410?"missing":n===403||n===401?"denied":"unknown"}function $a(n){return n}const Ms=1,Rt={version:Ms,thresholds:{passRate:[{min:100,level:"good"},{min:90,level:"warn"},{level:"bad"}],flakyRate:[{max:2,level:"good"},{max:5,level:"warn"},{level:"bad"}],durationRegressionPct:[{max:10,level:"good"},{max:25,level:"warn"},{level:"bad"}],coverageCell:[{min:100,level:"good"},{min:80,level:"warn"},{level:"bad"}]},metrics:{flakyCountsAsPassed:!0,excludeSkipped:!0},lanes:[{id:"web-dev",label:"Web · Dev",match:{category:"^ui:web$",environment:"dev"}},{id:"web-staging",label:"Web · Staging",match:{category:"^ui:web$",environment:"staging"}},{id:"admin-dev",label:"Admin · Dev",match:{category:"^ui:admin$",environment:"dev"}},{id:"admin-staging",label:"Admin · Staging",match:{category:"^ui:admin$",environment:"staging"}},{id:"web-nightly",label:"Web · Nightly",match:{category:"^ui:web-nightly$"}},{id:"batch",label:"Batch jobs",match:{category:"batch$"}},{id:"other",label:"Other",match:{}}],display:{theme:"chronoscope",colorScheme:"auto",views:{},defaultPage:"monitoring",defaultRangeDays:14,weekStartsOn:1,timeZone:"local",refreshSeconds:60,historyChips:5,reducedMotion:"auto"},themeTokens:{},data:{mainBranches:["main"],requireSyncComplete:!0},connections:{agentHostUrl:"ws://127.0.0.1:8081",workingDirectory:"",pathMap:[],traceViewer:"",github:{apiBase:"https://api.github.com",owner:"",repo:"",branch:"main",dataPath:"data"},s3:{bucket:"",region:"eu-north-1",prefix:"jsonl-report",endpoint:"",pathStyle:!1,dataSource:"website",dataPrefix:"qaily-data",transport:"cors"}},coverage:{levels:["Component","Scenario","Feature","Area"],rules:[]},ai:{provider:"copilotcli",githubHost:"",contextCapKb:30,actions:{analyzeTest:!0,fixTest:!0,analyzeRun:!0}}};var A;(function(n){n.assertEqual=r=>{};function e(r){}n.assertIs=e;function t(r){throw new Error}n.assertNever=t,n.arrayToEnum=r=>{const i={};for(const a of r)i[a]=a;return i},n.getValidEnumValues=r=>{const i=n.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),a={};for(const o of i)a[o]=r[o];return n.objectValues(a)},n.objectValues=r=>n.objectKeys(r).map(function(i){return r[i]}),n.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const i=[];for(const a in r)Object.prototype.hasOwnProperty.call(r,a)&&i.push(a);return i},n.find=(r,i)=>{for(const a of r)if(i(a))return a},n.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,i=" | "){return r.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}n.joinValues=s,n.jsonStringifyReplacer=(r,i)=>typeof i=="bigint"?i.toString():i})(A||(A={}));var Gt;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Gt||(Gt={}));const g=A.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),J=n=>{switch(typeof n){case"undefined":return g.undefined;case"string":return g.string;case"number":return Number.isNaN(n)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(n)?g.array:n===null?g.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?g.promise:typeof Map<"u"&&n instanceof Map?g.map:typeof Set<"u"&&n instanceof Set?g.set:typeof Date<"u"&&n instanceof Date?g.date:g.object;default:return g.unknown}},f=A.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class B extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(i){return i.message},s={_errors:[]},r=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(r);else if(a.code==="invalid_return_type")r(a.returnTypeError);else if(a.code==="invalid_arguments")r(a.argumentsError);else if(a.path.length===0)s._errors.push(t(a));else{let o=s,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return r(this),s}static assert(e){if(!(e instanceof B))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,A.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const r of this.issues)if(r.path.length>0){const i=r.path[0];t[i]=t[i]||[],t[i].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}B.create=n=>new B(n);const ft=(n,e)=>{let t;switch(n.code){case f.invalid_type:n.received===g.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case f.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,A.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:t=`Unrecognized key(s) in object: ${A.joinValues(n.keys,", ")}`;break;case f.invalid_union:t="Invalid input";break;case f.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${A.joinValues(n.options)}`;break;case f.invalid_enum_value:t=`Invalid enum value. Expected ${A.joinValues(n.options)}, received '${n.received}'`;break;case f.invalid_arguments:t="Invalid function arguments";break;case f.invalid_return_type:t="Invalid function return type";break;case f.invalid_date:t="Invalid date";break;case f.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:A.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case f.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case f.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case f.custom:t="Invalid input";break;case f.invalid_intersection_types:t="Intersection results could not be merged";break;case f.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case f.not_finite:t="Number must be finite";break;default:t=e.defaultError,A.assertNever(n)}return{message:t}};let kn=ft;function $n(){return kn}const Sn=n=>{const{data:e,path:t,errorMaps:s,issueData:r}=n,i=[...t,...r.path||[]],a={...r,path:i};if(r.message!==void 0)return{...r,path:i,message:r.message};let o="";const c=s.filter(l=>!!l).slice().reverse();for(const l of c)o=l(a,{data:e,defaultError:o}).message;return{...r,path:i,message:o}};function m(n,e){const t=$n(),s=Sn({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ft?void 0:ft].filter(r=>!!r)});n.common.issues.push(s)}class R{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const r of t){if(r.status==="aborted")return x;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const r of t){const i=await r.key,a=await r.value;s.push({key:i,value:a})}return R.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const r of t){const{key:i,value:a}=r;if(i.status==="aborted"||a.status==="aborted")return x;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||r.alwaysSet)&&(s[i.value]=a.value)}return{status:e.value,value:s}}}const x=Object.freeze({status:"aborted"}),Se=n=>({status:"dirty",value:n}),N=n=>({status:"valid",value:n}),Jt=n=>n.status==="aborted",Kt=n=>n.status==="dirty",pe=n=>n.status==="valid",Fe=n=>typeof Promise<"u"&&n instanceof Promise;var y;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e?.message})(y||(y={}));class j{constructor(e,t,s,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Yt=(n,e)=>{if(pe(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new B(n.common.issues);return this._error=t,this._error}}};function k(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:r}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(a,o)=>{const{message:c}=n;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:r}}class S{get description(){return this._def.description}_getType(e){return J(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:J(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new R,ctx:{common:e.parent.common,data:e.data,parsedType:J(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Fe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)},r=this._parseSync({data:e,path:s.path,parent:s});return Yt(s,r)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return pe(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>pe(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)},r=this._parse({data:e,path:s.path,parent:s}),i=await(Fe(r)?r:Promise.resolve(r));return Yt(s,i)}refine(e,t){const s=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,i)=>{const a=e(r),o=()=>i.addIssue({code:f.custom,...s(r)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof t=="function"?t(s,r):t),!1))}_refinement(e){return new ge({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return X.create(this,this._def)}nullable(){return ye.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return L.create(this)}promise(){return Ke.create(this,this._def)}or(e){return We.create([this,e],this._def)}and(e){return Ge.create(this,e,this._def)}transform(e){return new ge({...k(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new bt({...k(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new Gn({typeName:_.ZodBranded,type:this,...k(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new wt({...k(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ot.create(this,e)}readonly(){return _t.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const An=/^c[^\s-]{8,}$/i,Cn=/^[0-9a-z]+$/,Tn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,En=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Rn=/^[a-z0-9_-]{21}$/i,On=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,In=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,qn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Nn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let rt;const Pn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Mn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Un=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ln=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Us="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Hn=new RegExp(`^${Us}$`);function Ls(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);const t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function zn(n){return new RegExp(`^${Ls(n)}$`)}function Bn(n){let e=`${Us}T${Ls(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Zn(n,e){return!!((e==="v4"||!e)&&Pn.test(n)||(e==="v6"||!e)&&Un.test(n))}function Fn(n,e){if(!On.test(n))return!1;try{const[t]=n.split(".");if(!t)return!1;const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function Vn(n,e){return!!((e==="v4"||!e)&&Mn.test(n)||(e==="v6"||!e)&&Ln.test(n))}class D extends S{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_type,expected:g.string,received:i.parsedType}),x}const s=new R;let r;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(r=this._getOrReturnCtx(e,r),m(r,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="max")e.data.length>i.value&&(r=this._getOrReturnCtx(e,r),m(r,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(r=this._getOrReturnCtx(e,r),a?m(r,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&m(r,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),s.dirty())}else if(i.kind==="email")qn.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"email",code:f.invalid_string,message:i.message}),s.dirty());else if(i.kind==="emoji")rt||(rt=new RegExp(Nn,"u")),rt.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"emoji",code:f.invalid_string,message:i.message}),s.dirty());else if(i.kind==="uuid")En.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"uuid",code:f.invalid_string,message:i.message}),s.dirty());else if(i.kind==="nanoid")Rn.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"nanoid",code:f.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid")An.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"cuid",code:f.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid2")Cn.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"cuid2",code:f.invalid_string,message:i.message}),s.dirty());else if(i.kind==="ulid")Tn.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"ulid",code:f.invalid_string,message:i.message}),s.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),m(r,{validation:"url",code:f.invalid_string,message:i.message}),s.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"regex",code:f.invalid_string,message:i.message}),s.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(r=this._getOrReturnCtx(e,r),m(r,{code:f.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),s.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(r=this._getOrReturnCtx(e,r),m(r,{code:f.invalid_string,validation:{startsWith:i.value},message:i.message}),s.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(r=this._getOrReturnCtx(e,r),m(r,{code:f.invalid_string,validation:{endsWith:i.value},message:i.message}),s.dirty()):i.kind==="datetime"?Bn(i).test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:f.invalid_string,validation:"datetime",message:i.message}),s.dirty()):i.kind==="date"?Hn.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:f.invalid_string,validation:"date",message:i.message}),s.dirty()):i.kind==="time"?zn(i).test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:f.invalid_string,validation:"time",message:i.message}),s.dirty()):i.kind==="duration"?In.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"duration",code:f.invalid_string,message:i.message}),s.dirty()):i.kind==="ip"?Zn(e.data,i.version)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"ip",code:f.invalid_string,message:i.message}),s.dirty()):i.kind==="jwt"?Fn(e.data,i.alg)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"jwt",code:f.invalid_string,message:i.message}),s.dirty()):i.kind==="cidr"?Vn(e.data,i.version)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"cidr",code:f.invalid_string,message:i.message}),s.dirty()):i.kind==="base64"?jn.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"base64",code:f.invalid_string,message:i.message}),s.dirty()):i.kind==="base64url"?Dn.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"base64url",code:f.invalid_string,message:i.message}),s.dirty()):A.assertNever(i);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(r=>e.test(r),{validation:t,code:f.invalid_string,...y.errToObj(s)})}_addCheck(e){return new D({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...y.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...y.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...y.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...y.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...y.errToObj(t)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new D({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new D({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new D({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}D.create=n=>new D({checks:[],typeName:_.ZodString,coerce:n?.coerce??!1,...k(n)});function Wn(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=t>s?t:s,i=Number.parseInt(n.toFixed(r).replace(".","")),a=Number.parseInt(e.toFixed(r).replace(".",""));return i%a/10**r}class fe extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_type,expected:g.number,received:i.parsedType}),x}let s;const r=new R;for(const i of this._def.checks)i.kind==="int"?A.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:f.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:f.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="multipleOf"?Wn(e.data,i.value)!==0&&(s=this._getOrReturnCtx(e,s),m(s,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:f.not_finite,message:i.message}),r.dirty()):A.assertNever(i);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,s,r){return new fe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:y.toString(r)}]})}_addCheck(e){return new fe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&A.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}fe.create=n=>new fe({checks:[],typeName:_.ZodNumber,coerce:n?.coerce||!1,...k(n)});class Ee extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==g.bigint)return this._getInvalidInput(e);let s;const r=new R;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:f.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:f.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),m(s,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):A.assertNever(i);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:g.bigint,received:t.parsedType}),x}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,s,r){return new Ee({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:y.toString(r)}]})}_addCheck(e){return new Ee({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ee.create=n=>new Ee({checks:[],typeName:_.ZodBigInt,coerce:n?.coerce??!1,...k(n)});class mt extends S{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const s=this._getOrReturnCtx(e);return m(s,{code:f.invalid_type,expected:g.boolean,received:s.parsedType}),x}return N(e.data)}}mt.create=n=>new mt({typeName:_.ZodBoolean,coerce:n?.coerce||!1,...k(n)});class Ve extends S{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_type,expected:g.date,received:i.parsedType}),x}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_date}),x}const s=new R;let r;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(r=this._getOrReturnCtx(e,r),m(r,{code:f.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),s.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(r=this._getOrReturnCtx(e,r),m(r,{code:f.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),s.dirty()):A.assertNever(i);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ve({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:y.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ve.create=n=>new Ve({checks:[],coerce:n?.coerce||!1,typeName:_.ZodDate,...k(n)});class Xt extends S{_parse(e){if(this._getType(e)!==g.symbol){const s=this._getOrReturnCtx(e);return m(s,{code:f.invalid_type,expected:g.symbol,received:s.parsedType}),x}return N(e.data)}}Xt.create=n=>new Xt({typeName:_.ZodSymbol,...k(n)});class Qt extends S{_parse(e){if(this._getType(e)!==g.undefined){const s=this._getOrReturnCtx(e);return m(s,{code:f.invalid_type,expected:g.undefined,received:s.parsedType}),x}return N(e.data)}}Qt.create=n=>new Qt({typeName:_.ZodUndefined,...k(n)});class es extends S{_parse(e){if(this._getType(e)!==g.null){const s=this._getOrReturnCtx(e);return m(s,{code:f.invalid_type,expected:g.null,received:s.parsedType}),x}return N(e.data)}}es.create=n=>new es({typeName:_.ZodNull,...k(n)});class ts extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}}ts.create=n=>new ts({typeName:_.ZodAny,...k(n)});class gt extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}}gt.create=n=>new gt({typeName:_.ZodUnknown,...k(n)});class Q extends S{_parse(e){const t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:g.never,received:t.parsedType}),x}}Q.create=n=>new Q({typeName:_.ZodNever,...k(n)});class ss extends S{_parse(e){if(this._getType(e)!==g.undefined){const s=this._getOrReturnCtx(e);return m(s,{code:f.invalid_type,expected:g.void,received:s.parsedType}),x}return N(e.data)}}ss.create=n=>new ss({typeName:_.ZodVoid,...k(n)});class L extends S{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==g.array)return m(t,{code:f.invalid_type,expected:g.array,received:t.parsedType}),x;if(r.exactLength!==null){const a=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(a||o)&&(m(t,{code:a?f.too_big:f.too_small,minimum:o?r.exactLength.value:void 0,maximum:a?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(m(t,{code:f.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(m(t,{code:f.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>r.type._parseAsync(new j(t,a,t.path,o)))).then(a=>R.mergeArray(s,a));const i=[...t.data].map((a,o)=>r.type._parseSync(new j(t,a,t.path,o)));return R.mergeArray(s,i)}get element(){return this._def.type}min(e,t){return new L({...this._def,minLength:{value:e,message:y.toString(t)}})}max(e,t){return new L({...this._def,maxLength:{value:e,message:y.toString(t)}})}length(e,t){return new L({...this._def,exactLength:{value:e,message:y.toString(t)}})}nonempty(e){return this.min(1,e)}}L.create=(n,e)=>new L({type:n,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...k(e)});function de(n){if(n instanceof T){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=X.create(de(s))}return new T({...n._def,shape:()=>e})}else return n instanceof L?new L({...n._def,type:de(n.element)}):n instanceof X?X.create(de(n.unwrap())):n instanceof ye?ye.create(de(n.unwrap())):n instanceof oe?oe.create(n.items.map(e=>de(e))):n}class T extends S{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=A.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==g.object){const l=this._getOrReturnCtx(e);return m(l,{code:f.invalid_type,expected:g.object,received:l.parsedType}),x}const{status:s,ctx:r}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Q&&this._def.unknownKeys==="strip"))for(const l in r.data)a.includes(l)||o.push(l);const c=[];for(const l of a){const h=i[l],d=r.data[l];c.push({key:{status:"valid",value:l},value:h._parse(new j(r,d,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof Q){const l=this._def.unknownKeys;if(l==="passthrough")for(const h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:r.data[h]}});else if(l==="strict")o.length>0&&(m(r,{code:f.unrecognized_keys,keys:o}),s.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const h of o){const d=r.data[h];c.push({key:{status:"valid",value:h},value:l._parse(new j(r,d,r.path,h)),alwaysSet:h in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const h of c){const d=await h.key,u=await h.value;l.push({key:d,value:u,alwaysSet:h.alwaysSet})}return l}).then(l=>R.mergeObjectSync(s,l)):R.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new T({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{const r=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:y.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new T({...this._def,unknownKeys:"strip"})}passthrough(){return new T({...this._def,unknownKeys:"passthrough"})}extend(e){return new T({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new T({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new T({...this._def,catchall:e})}pick(e){const t={};for(const s of A.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new T({...this._def,shape:()=>t})}omit(e){const t={};for(const s of A.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new T({...this._def,shape:()=>t})}deepPartial(){return de(this)}partial(e){const t={};for(const s of A.objectKeys(this.shape)){const r=this.shape[s];e&&!e[s]?t[s]=r:t[s]=r.optional()}return new T({...this._def,shape:()=>t})}required(e){const t={};for(const s of A.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let i=this.shape[s];for(;i instanceof X;)i=i._def.innerType;t[s]=i}return new T({...this._def,shape:()=>t})}keyof(){return js(A.objectKeys(this.shape))}}T.create=(n,e)=>new T({shape:()=>n,unknownKeys:"strip",catchall:Q.create(),typeName:_.ZodObject,...k(e)});T.strictCreate=(n,e)=>new T({shape:()=>n,unknownKeys:"strict",catchall:Q.create(),typeName:_.ZodObject,...k(e)});T.lazycreate=(n,e)=>new T({shape:n,unknownKeys:"strip",catchall:Q.create(),typeName:_.ZodObject,...k(e)});class We extends S{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function r(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new B(o.ctx.common.issues));return m(t,{code:f.invalid_union,unionErrors:a}),x}if(t.common.async)return Promise.all(s.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(r);{let i;const a=[];for(const c of s){const l={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!i&&(i={result:h,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new B(c));return m(t,{code:f.invalid_union,unionErrors:o}),x}}get options(){return this._def.options}}We.create=(n,e)=>new We({options:n,typeName:_.ZodUnion,...k(e)});function yt(n,e){const t=J(n),s=J(e);if(n===e)return{valid:!0,data:n};if(t===g.object&&s===g.object){const r=A.objectKeys(e),i=A.objectKeys(n).filter(o=>r.indexOf(o)!==-1),a={...n,...e};for(const o of i){const c=yt(n[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===g.array&&s===g.array){if(n.length!==e.length)return{valid:!1};const r=[];for(let i=0;i<n.length;i++){const a=n[i],o=e[i],c=yt(a,o);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return t===g.date&&s===g.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Ge extends S{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=(i,a)=>{if(Jt(i)||Jt(a))return x;const o=yt(i.value,a.value);return o.valid?((Kt(i)||Kt(a))&&t.dirty(),{status:t.value,value:o.data}):(m(s,{code:f.invalid_intersection_types}),x)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([i,a])=>r(i,a)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}Ge.create=(n,e,t)=>new Ge({left:n,right:e,typeName:_.ZodIntersection,...k(t)});class oe extends S{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.array)return m(s,{code:f.invalid_type,expected:g.array,received:s.parsedType}),x;if(s.data.length<this._def.items.length)return m(s,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&s.data.length>this._def.items.length&&(m(s,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...s.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new j(s,a,s.path,o)):null}).filter(a=>!!a);return s.common.async?Promise.all(i).then(a=>R.mergeArray(t,a)):R.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new oe({...this._def,rest:e})}}oe.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new oe({items:n,typeName:_.ZodTuple,rest:null,...k(e)})};class Je extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.object)return m(s,{code:f.invalid_type,expected:g.object,received:s.parsedType}),x;const r=[],i=this._def.keyType,a=this._def.valueType;for(const o in s.data)r.push({key:i._parse(new j(s,o,s.path,o)),value:a._parse(new j(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?R.mergeObjectAsync(t,r):R.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof S?new Je({keyType:e,valueType:t,typeName:_.ZodRecord,...k(s)}):new Je({keyType:D.create(),valueType:e,typeName:_.ZodRecord,...k(t)})}}class ns extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.map)return m(s,{code:f.invalid_type,expected:g.map,received:s.parsedType}),x;const r=this._def.keyType,i=this._def.valueType,a=[...s.data.entries()].map(([o,c],l)=>({key:r._parse(new j(s,o,s.path,[l,"key"])),value:i._parse(new j(s,c,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return x;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return x;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}ns.create=(n,e,t)=>new ns({valueType:e,keyType:n,typeName:_.ZodMap,...k(t)});class Re extends S{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.set)return m(s,{code:f.invalid_type,expected:g.set,received:s.parsedType}),x;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(m(s,{code:f.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(m(s,{code:f.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const l=new Set;for(const h of c){if(h.status==="aborted")return x;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((c,l)=>i._parse(new j(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Re({...this._def,minSize:{value:e,message:y.toString(t)}})}max(e,t){return new Re({...this._def,maxSize:{value:e,message:y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Re.create=(n,e)=>new Re({valueType:n,minSize:null,maxSize:null,typeName:_.ZodSet,...k(e)});class rs extends S{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}rs.create=(n,e)=>new rs({getter:n,typeName:_.ZodLazy,...k(e)});class vt extends S{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}}vt.create=(n,e)=>new vt({value:n,typeName:_.ZodLiteral,...k(e)});function js(n,e){return new me({values:n,typeName:_.ZodEnum,...k(e)})}class me extends S{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return m(t,{expected:A.joinValues(s),received:t.parsedType,code:f.invalid_type}),x}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return m(t,{received:t.data,code:f.invalid_enum_value,options:s}),x}return N(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return me.create(e,{...this._def,...t})}exclude(e,t=this._def){return me.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}me.create=js;class is extends S{_parse(e){const t=A.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==g.string&&s.parsedType!==g.number){const r=A.objectValues(t);return m(s,{expected:A.joinValues(r),received:s.parsedType,code:f.invalid_type}),x}if(this._cache||(this._cache=new Set(A.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=A.objectValues(t);return m(s,{received:s.data,code:f.invalid_enum_value,options:r}),x}return N(e.data)}get enum(){return this._def.values}}is.create=(n,e)=>new is({values:n,typeName:_.ZodNativeEnum,...k(e)});class Ke extends S{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.promise&&t.common.async===!1)return m(t,{code:f.invalid_type,expected:g.promise,received:t.parsedType}),x;const s=t.parsedType===g.promise?t.data:Promise.resolve(t.data);return N(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ke.create=(n,e)=>new Ke({type:n,typeName:_.ZodPromise,...k(e)});class ge extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:a=>{m(s,a),a.fatal?t.abort():t.dirty()},get path(){return s.path}};if(i.addIssue=i.addIssue.bind(i),r.type==="preprocess"){const a=r.transform(s.data,i);if(s.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return x;const c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?x:c.status==="dirty"||t.value==="dirty"?Se(c.value):c});{if(t.value==="aborted")return x;const o=this._def.schema._parseSync({data:a,path:s.path,parent:s});return o.status==="aborted"?x:o.status==="dirty"||t.value==="dirty"?Se(o.value):o}}if(r.type==="refinement"){const a=o=>{const c=r.refinement(o,i);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?x:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?x:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(s.common.async===!1){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!pe(a))return x;const o=r.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>pe(a)?Promise.resolve(r.transform(a.value,i)).then(o=>({status:t.value,value:o})):x);A.assertNever(r)}}ge.create=(n,e,t)=>new ge({schema:n,typeName:_.ZodEffects,effect:e,...k(t)});ge.createWithPreprocess=(n,e,t)=>new ge({schema:e,effect:{type:"preprocess",transform:n},typeName:_.ZodEffects,...k(t)});class X extends S{_parse(e){return this._getType(e)===g.undefined?N(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}X.create=(n,e)=>new X({innerType:n,typeName:_.ZodOptional,...k(e)});class ye extends S{_parse(e){return this._getType(e)===g.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ye.create=(n,e)=>new ye({innerType:n,typeName:_.ZodNullable,...k(e)});class bt extends S{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===g.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}bt.create=(n,e)=>new bt({innerType:n,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});class wt extends S{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Fe(r)?r.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new B(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new B(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}wt.create=(n,e)=>new wt({innerType:n,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});class as extends S{_parse(e){if(this._getType(e)!==g.nan){const s=this._getOrReturnCtx(e);return m(s,{code:f.invalid_type,expected:g.nan,received:s.parsedType}),x}return{status:"valid",value:e.data}}}as.create=n=>new as({typeName:_.ZodNaN,...k(n)});class Gn extends S{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ot extends S{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?x:i.status==="dirty"?(t.dirty(),Se(i.value)):this._def.out._parseAsync({data:i.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?x:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,t){return new Ot({in:e,out:t,typeName:_.ZodPipeline})}}class _t extends S{_parse(e){const t=this._def.innerType._parse(e),s=r=>(pe(r)&&(r.value=Object.freeze(r.value)),r);return Fe(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}}_t.create=(n,e)=>new _t({innerType:n,typeName:_.ZodReadonly,...k(e)});var _;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(_||(_={}));const $=D.create,H=fe.create,It=mt.create,Jn=gt.create;Q.create;const I=L.create,q=T.create,Kn=We.create;Ge.create;oe.create;const os=Je.create,cs=vt.create,K=me.create;Ke.create;X.create;ye.create;const Yn=K(["good","warn","bad"]),Xn=q({level:Yn,min:H().optional(),max:H().optional()}).strict(),Ue=I(Xn).min(1),Qn=q({id:$().min(1),label:$().min(1),match:q({category:$().optional(),environment:$().optional(),branch:$().optional()}).strict()}).strict(),er=$().regex(/^--[a-z0-9-]+$/i),W=$().max(300).optional(),tr=q({step:W,tag:W,title:W,file:W,ignoreCase:It().optional(),component:W,scenario:W,feature:W,area:W}).strict(),Sa=[{id:"thresholds",label:"Health thresholds",help:"When metrics turn green, yellow or red. Bands are checked top to bottom; the first match wins."},{id:"metrics",label:"Metrics"},{id:"lanes",label:"Lanes",help:"How runs are grouped on dashboards. The first matching lane wins."},{id:"appearance",label:"Appearance"},{id:"data",label:"Data"},{id:"connections",label:"Connections",help:"Non-secret connection settings. Tokens are stored separately and never shared."},{id:"coverage",label:"Coverage heat map",help:"How test steps map to the coverage matrix. Explicit step annotations in tests win over these rules."},{id:"ai",label:"AI"}],E=(n,e,t,s,r,i)=>({path:n,group:e,label:t,scope:s,help:r,editor:{kind:"text",placeholder:i},schema:$()}),ee=(n,e,t,s,r)=>({path:n,group:e,label:t,scope:s,help:r,editor:{kind:"boolean"},schema:It()}),qt=[{path:"thresholds.passRate",group:"thresholds",label:"Pass rate",scope:"both",editor:{kind:"bands",unit:"%"},schema:Ue,help:"Percent of executed tests that passed."},{path:"thresholds.flakyRate",group:"thresholds",label:"Flaky rate",scope:"both",editor:{kind:"bands",unit:"%"},schema:Ue,help:"Percent of executed tests that passed only on retry."},{path:"thresholds.durationRegressionPct",group:"thresholds",label:"Duration regression",scope:"both",editor:{kind:"bands",unit:"%"},schema:Ue,help:"How much slower a run is than the previous run in the same lane."},{path:"thresholds.coverageCell",group:"thresholds",label:"Heat map cell",scope:"both",editor:{kind:"bands",unit:"%"},schema:Ue,help:"Pass rate of the steps that hit a coverage cell."},ee("metrics.flakyCountsAsPassed","metrics","Flaky tests count as passed","both"),ee("metrics.excludeSkipped","metrics","Leave skipped tests out of the pass rate","both"),{path:"lanes",group:"lanes",label:"Lanes",scope:"team",editor:{kind:"lanes"},schema:I(Qn).min(1),help:'Category and branch are regular expressions; environment is an exact match. Empty means "any".'},{path:"display.theme",group:"appearance",label:"Theme",scope:"both",editor:{kind:"theme"},schema:$().min(1)},{path:"display.colorScheme",group:"appearance",label:"Colour scheme",scope:"personal",schema:K(["auto","light","dark"]),editor:{kind:"select",options:[{value:"auto",label:"Follow system"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}]}},{path:"display.views",group:"appearance",label:"View per page",scope:"personal",editor:{kind:"views"},schema:os($()),help:"Overrides the view the theme picks for a page."},{path:"themeTokens",group:"appearance",label:"Theme token overrides",scope:"both",editor:{kind:"tokens"},schema:os(er,$().max(200)),help:"Applied on top of the active theme."},{path:"display.reducedMotion",group:"appearance",label:"Reduce motion",scope:"personal",schema:K(["auto","on","off"]),editor:{kind:"select",options:[{value:"auto",label:"Follow system"},{value:"on",label:"On"},{value:"off",label:"Off"}]}},{path:"display.defaultPage",group:"appearance",label:"Start page",scope:"both",editor:{kind:"page"},schema:$().min(1)},{path:"display.defaultRangeDays",group:"appearance",label:"Default date range",scope:"both",editor:{kind:"number",min:1,max:366,unit:"days"},schema:H().int().min(1).max(366)},{path:"display.weekStartsOn",group:"appearance",label:"Week starts on",scope:"both",schema:Kn([cs(0),cs(1)]),editor:{kind:"select",options:[{value:1,label:"Monday"},{value:0,label:"Sunday"}]}},{path:"display.timeZone",group:"appearance",label:"Time zone",scope:"both",schema:K(["local","UTC"]),editor:{kind:"select",options:[{value:"local",label:"Browser local time"},{value:"UTC",label:"UTC"}]}},{path:"display.refreshSeconds",group:"appearance",label:"Auto-refresh interval",scope:"both",editor:{kind:"number",min:0,max:3600,unit:"s"},schema:H().int().min(0).max(3600),help:"0 turns auto-refresh off."},{path:"display.historyChips",group:"appearance",label:"History runs per lane",scope:"both",editor:{kind:"number",min:0,max:20},schema:H().int().min(0).max(20)},{path:"data.mainBranches",group:"data",label:"Main branches",scope:"team",editor:{kind:"string-list",placeholder:"main"},schema:I($().min(1)).min(1),help:'Branches shown when the branch filter is "main".'},ee("data.requireSyncComplete","data","Only include runs with a .sync-complete marker","team","Used by `qaily-report build`. Hides runs whose upload has not finished."),E("connections.agentHostUrl","connections","AI agent host URL","personal","The `code agent host` WebSocket address.","ws://127.0.0.1:8081"),E("connections.workingDirectory","connections","Local test repo path","personal",'Working directory for "Fix with AI".',"/Users/me/repos/tests"),{path:"connections.pathMap",group:"connections",label:"Path mapping",scope:"both",editor:{kind:"path-map"},schema:I(q({from:$().min(1),to:$()}).strict()),help:"Rewrites CI paths in stack traces to local paths."},E("connections.traceViewer","connections","Trace viewer","both","Where a self-hosted Playwright trace viewer is, relative to this report (e.g. trace/ or ../trace/), copied there by `qaily-report trace-viewer`. The report reads the trace itself and hands it to the viewer, so it works without CORS. Empty: links to trace.playwright.dev, which needs CORS on the bucket.","trace/"),E("connections.github.apiBase","connections","GitHub API base","team","https://api.github.com, or https://<host>/api/v3 for GitHub Enterprise Server."),E("connections.github.owner","connections","GitHub owner","team","Owner of the repo that publishes this report."),E("connections.github.repo","connections","GitHub repo","team"),E("connections.github.branch","connections","GitHub branch","team"),E("connections.github.dataPath","connections","Data folder in the repo","team"),E("connections.s3.bucket","connections","S3 bucket","both","For me: look at another bucket with your own credentials; the header shows it, with Reset. Its team settings come with it."),E("connections.s3.region","connections","S3 region","both","For Google Cloud Storage use auto. MinIO usually uses us-east-1."),E("connections.s3.prefix","connections","S3 key prefix","both","Where run folders and attachments are. For me: look at another dataset in the same bucket; the header shows it, with Reset."),E("connections.s3.endpoint","connections","S3 endpoint","both","Only for S3-compatible storage. Empty = AWS (for me too: an empty value of your own replaces the team's endpoint).","https://storage.googleapis.com"),ee("connections.s3.pathStyle","connections","Bucket in the URL path","both","Uses host/bucket/key instead of bucket.host/key. MinIO usually needs this; AWS and Google Cloud Storage do not."),{path:"connections.s3.dataSource",group:"connections",label:"Report data source",scope:"both",schema:K(["website","bucket"]),help:"Website: dashboards work without credentials, but anyone who can open the site can read test titles and errors. Bucket: data stays private and needs no site redeploy, but every viewer needs credentials, and CI must run qaily-report publish. Team settings then also come from the bucket. Applies after a reload.",editor:{kind:"select",options:[{value:"website",label:"Website"},{value:"bucket",label:"Bucket"}]}},{path:"connections.s3.transport",group:"connections",label:"Storage access",scope:"both",schema:K(["cors","bridge"]),help:"Direct: the browser reads the bucket itself, which needs CORS rules for this site. Bridge: it reads through a small page in the bucket (qaily-bridge.html, uploaded with `qaily-report bridge`), for storage whose CORS rules you can't change, such as Dell ECS. Applies at once; turn it off here if the bridge gives trouble.",editor:{kind:"select",options:[{value:"cors",label:"Direct (CORS)"},{value:"bridge",label:"Bridge (no CORS)"}]}},E("connections.s3.dataPrefix","connections","Report data key prefix","both","Bucket folder for report data when the source is Bucket. Keep it outside the S3 key prefix. For me: look at another dataset in the same bucket; its team settings (team-settings.json in that folder) come with it.","qaily-data"),{path:"coverage.levels",group:"coverage",label:"Level names",scope:"both",editor:{kind:"string-list",placeholder:"Component, Scenario, Feature, Area"},schema:I($().min(1).max(40)).length(4),help:"Four names, top level first."},{path:"coverage.rules",group:"coverage",label:"Mapping rules",scope:"team",editor:{kind:"coverage-rules"},schema:I(tr).max(500),help:"Conditions are regular expressions; all filled ones must match. Each level comes from the first matching rule that sets it. A step is a hit only when a rule with a Step condition matches it."},E("ai.provider","ai","Agent provider","both","Agent id offered by the host, e.g. copilotcli or claude."),E("ai.githubHost","ai","GitHub host for Copilot","both","Only for GitHub Enterprise with its own domain (e.g. acme.ghe.com). Empty = leave the agent host as it is. This changes host-wide config."),{path:"ai.contextCapKb",group:"ai",label:"Context size cap",scope:"both",editor:{kind:"number",min:4,max:200,unit:"KB"},schema:H().int().min(4).max(200),help:"Maximum test context sent to the agent per test."},ee("ai.actions.analyzeTest","ai",'Enable "Analyze test"',"both"),ee("ai.actions.fixTest","ai",'Enable "Fix with AI"',"both"),ee("ai.actions.analyzeRun","ai",'Enable "Analyze all failures"',"both")];function sr(n){return qt.find(e=>e.path===n)}function Nt(n,e){let t=n;for(const s of e.split(".")){if(t==null||typeof t!="object")return;t=t[s]}return t}function Ne(n,e,t){const[s,...r]=e.split("."),i={...n};if(r.length===0)return t===void 0?delete i[s]:i[s]=t,i;const a=i[s],o=Ne(a&&typeof a=="object"?a:{},r.join("."),t);return Object.keys(o).length===0?delete i[s]:i[s]=o,i}function nr(n,e){return n==="both"||n===e}function ls(n){if(!n||typeof n!="object")return{};const e={...n};return e.version=Ms,e}function ds(n,e,t){const s={team:ls(e),personal:ls(t)};let r=structuredClone(n);const i={},a=[];for(const o of qt){i[o.path]="default";for(const c of["team","personal"]){const l=Nt(s[c],o.path);if(l===void 0)continue;if(!nr(o.scope,c)){a.push(`${o.label}: ignored ${c} value, this setting is ${o.scope}-only`);continue}const h=o.schema.safeParse(l);if(!h.success){a.push(`${o.label}: ignored invalid ${c} value (${h.error.issues[0]?.message??"invalid"})`);continue}r=Ne(r,o.path,h.data),i[o.path]=c}}return{settings:r,sources:i,warnings:a}}const Ye=["connections.s3.bucket","connections.s3.region","connections.s3.endpoint","connections.s3.pathStyle","connections.s3.dataSource","connections.s3.prefix","connections.s3.dataPrefix"];function rr(n,e){let t=structuredClone(n);for(const s of qt){const r=Nt(e,s.path);r!==void 0&&(t=Ne(t,s.path,structuredClone(r)))}return t}function xt(n){return Ne(n,"connections.s3",void 0)}function Aa(n){return n==="connections.s3"||n.startsWith("connections.s3.")}function ir(n){return n.replace(/\d+/g,"N")}function ar(n){return n==null?null:n.replace(/"[^"]*"/g,'"S"').replace(/\d+/g,"N")}function or(n,e){return`${ir(n)}|${ar(e)??""}`}const Ds=1,cr="qaily-ai/1",Hs=["product-bug","test-bug","environment","test-data","flaky","unknown"],zs=K(Hs),Bs=H().min(0).max(1),ve=$().max(4e3),lr=q({summary:$().min(1).max(600),category:zs,confidence:Bs,rootCause:ve,evidence:I($().max(1e3)).max(12).default([]),suggestedFix:ve,relatedFiles:I(q({path:$().max(500),line:H().int().optional()})).max(20).default([])}),dr=q({summary:$().min(1).max(600),filesChanged:I(q({path:$().max(500),description:$().max(1e3)})).max(50).default([]),verification:ve,risk:ve.default(""),needsHumanReview:It().default(!0)}),hr=q({summary:$().min(1).max(2e3),clusters:I(q({title:$().max(300),issueSigs:I($().max(40)).max(50).default([]),category:zs,confidence:Bs,rootCause:ve,recommendation:ve})).max(50).default([]),flakySuspects:I(q({title:$().max(500),reason:$().max(1e3)})).max(30).default([]),nextSteps:I($().max(1e3)).max(15).default([])}),Zs={"test-analysis":lr,"test-fix":dr,"run-analysis":hr},ur=q({schemaVersion:H().int(),kind:K(["test-analysis","test-fix","run-analysis"]),runId:$().min(1),testId:$().optional(),createdAt:$(),author:$().optional(),provider:$(),model:$().optional(),promptVersion:$(),inputHash:$(),result:Jn(),transcript:$().optional()});function pr(n){const e=ur.safeParse(n);if(!e.success)return null;const t=Zs[e.data.kind].safeParse(e.data.result);return t.success?{...e.data,result:t.data}:null}const hs=/^[A-Za-z0-9._-]+$/;function Le(n,e,t){if(!hs.test(e)||e.includes(".."))throw new Error(`Unsafe run id: ${e}`);if(n==="run-analysis")return`runs/${e}/summary.json`;if(!t||!hs.test(t)||t.includes(".."))throw new Error(`Unsafe test id: ${t}`);return`runs/${e}/tests/${t}${n==="test-fix"?".fix":""}.json`}function fr(n,e){const t={schemaVersion:Ds,runs:{...n?.runs??{}}},s={...t.runs[e.runId]??{}};if(e.kind==="run-analysis")s.summary=e.createdAt;else{const r=e.kind==="test-fix"?"fixes":"tests";s[r]=[...new Set([...s[r]??[],e.testId])].sort()}return t.runs[e.runId]=s,t}const mr=/\u001b\[[0-9;]*m/g,Be=n=>(n??"").replace(mr,"");function Ae(n,e){let t=n;for(const s of[...e].sort((r,i)=>i.from.length-r.from.length))s.from&&(t=t.split(s.from).join(s.to));return t}function kt(n,e,t="head"){return n.length<=e?n:t==="head"?`${n.slice(0,e)}
|
|
3
|
+
… (cut, ${n.length-e} more characters)`:`… (cut, ${n.length-e} earlier characters)
|
|
4
|
+
${n.slice(-e)}`}function Fs(n,e){const t=i=>i.filter(a=>a.body.trim()).map(a=>`### ${a.title}
|
|
5
|
+
${a.body.trim()}`).join(`
|
|
6
|
+
|
|
7
|
+
`),s=n.map(i=>({...i}));let r=t(s);for(const i of[...s].sort((a,o)=>o.priority-a.priority)){if(r.length<=e)break;const a=r.length-e;i.body=kt(i.body,Math.max(i.min,i.body.length-a-60),i.keep),r=t(s)}return r.length<=e?r:kt(r,e)}function gr(n){const e=n.summary,t=[...n.attempts].reverse().find(d=>d.errors.length)??n.attempts[n.attempts.length-1],s=t?.errors[0],r=t?.detail?.steps??[],i=t?.detail?.failed_step_idx??r.findIndex(d=>d.status!=="passed"&&d.status!=="skipped"),a=r.map(d=>`${d.idx===i?">>":" "} ${d.idx}. [${d.status}] ${d.title} (${d.dur_ms} ms)`),o=n.history.filter(d=>d.status!=="skipped"),c=o.filter(d=>d.status==="passed"||d.status==="flaky").length,l=n.history.map(d=>({passed:"P",failed:"F",flaky:"f",skipped:"-"})[d.status]??"?").join(""),h=[{title:"Test",priority:0,min:400,body:[`Title: ${e.title}`,`File: ${Ae(e.file,n.pathMap)}${t?.detail?.line_num?`:${t.detail.line_num}`:""}`,`Project: ${e.project}`,`Tags: ${e.tags.map(d=>`@${d}`).join(" ")||"-"}`,`Result: ${e.status} after ${n.attempts.length} attempt(s), ${e.dur_ms} ms`,n.run?`Run: ${n.run.run_id} · branch ${n.run.branch??"?"} · commit ${n.run.commit?.slice(0,10)??"?"} · env ${n.run.environment??"?"} · ${n.run.category??""}`:"",t?.detail?.full_title?`Full title: ${t.detail.full_title}`:""].filter(Boolean).join(`
|
|
8
|
+
`)},{title:"Error",priority:0,min:600,body:s?[`Type: ${s.err_type}`,`Message:
|
|
9
|
+
${Be(s.err_msg)}`,s.failed_step?`Failed step: ${s.failed_step}`:"",s.locator?`Locator: ${s.locator}`:"",s.err_file?`At: ${Ae(s.err_file,n.pathMap)}:${s.err_line??"?"}`:""].filter(Boolean).join(`
|
|
10
|
+
`):"No error was recorded."},{title:"Steps (>> marks the failed step)",priority:1,min:800,body:a.join(`
|
|
11
|
+
`)},{title:"Code at the failure",priority:1,min:400,body:s?.snippet?"```\n"+Ae(Be(s.snippet),n.pathMap)+"\n```":""},{title:"History (oldest → newest, P pass, f flaky, F fail, - skipped)",priority:2,min:120,body:n.history.length?`${l}
|
|
12
|
+
Passed ${c} of ${o.length} executed runs.`:""},{title:"Stack trace",priority:3,min:400,body:s?.stack?"```\n"+Ae(Be(s.stack),n.pathMap)+"\n```":""},{title:"Page snapshot at failure (error-context)",priority:4,min:600,body:n.errorContext??""},{title:"Network log (filtered, most recent last)",priority:5,min:400,keep:"tail",body:n.networkLog?"```\n"+n.networkLog+"\n```":""}];return Fs(h,n.capBytes)}function yr(n){const e=n.run,t=[`Run: ${e.run_id}`,`Branch ${e.branch??"?"} · commit ${e.commit?.slice(0,10)??"?"} · env ${e.environment??"?"} · ${e.category??""} · ${e.tag??""}`,`Tests: ${e.total} total, ${e.passed} passed, ${e.failed} failed, ${e.flaky} flaky, ${e.skipped} skipped`].join(`
|
|
13
|
+
`),s=n.clusters.map((r,i)=>[`#${i+1} issueSig=${r.sig} type=${r.errType} tests=${r.tests.length}`,`Message: ${kt(Be(r.message),700)}`,r.failedStep?`Failed step: ${r.failedStep}`:"",r.location?`At: ${Ae(r.location,n.pathMap)}`:"",`Tests: ${r.tests.map(a=>`${a.title} [${a.status}, ${a.project}]`).join("; ")}`].filter(Boolean).join(`
|
|
14
|
+
`)).join(`
|
|
15
|
+
|
|
16
|
+
`);return Fs([{title:"Run",priority:0,min:300,body:t},{title:"Failure groups (same normalized error and failed step)",priority:1,min:2e3,body:s||"No failures."},{title:"Tests that passed only on retry (flaky)",priority:2,min:200,body:n.flaky.map(r=>`- ${r.title} [${r.project}]`).join(`
|
|
17
|
+
`)}],n.capBytes)}const us=Hs.join(" | "),Vs={"test-analysis":`{
|
|
18
|
+
"summary": "one or two sentences",
|
|
19
|
+
"category": "${us}",
|
|
20
|
+
"confidence": 0.0-1.0,
|
|
21
|
+
"rootCause": "what went wrong and why",
|
|
22
|
+
"evidence": ["facts from the context that support it"],
|
|
23
|
+
"suggestedFix": "what to change, and where",
|
|
24
|
+
"relatedFiles": [{ "path": "file in the repo", "line": 123 }]
|
|
25
|
+
}`,"test-fix":`{
|
|
26
|
+
"summary": "what you changed and why",
|
|
27
|
+
"filesChanged": [{ "path": "file", "description": "the change" }],
|
|
28
|
+
"verification": "how to verify the fix (command or steps)",
|
|
29
|
+
"risk": "what could break",
|
|
30
|
+
"needsHumanReview": true
|
|
31
|
+
}`,"run-analysis":`{
|
|
32
|
+
"summary": "a short overview for the team",
|
|
33
|
+
"clusters": [{ "title": "...", "issueSigs": ["sig from the context"], "category": "${us}", "confidence": 0.0-1.0,
|
|
34
|
+
"rootCause": "...", "recommendation": "..." }],
|
|
35
|
+
"flakySuspects": [{ "title": "test title", "reason": "..." }],
|
|
36
|
+
"nextSteps": ["prioritized actions"]
|
|
37
|
+
}`},Pt=n=>`Reply with a short explanation in plain text, then exactly one \`\`\`json code block with this shape:
|
|
38
|
+
\`\`\`json
|
|
39
|
+
${Vs[n]}
|
|
40
|
+
\`\`\`
|
|
41
|
+
Use only facts from the context or files you read. If you are unsure, say so and lower the confidence.`;function vr(n){return["You are a senior QA engineer. Find the most likely root cause of this failed Playwright test.","The working directory is the test repository: you may read files there to look at the test and page objects.","Do not modify any files, and do not run commands that change anything.",Pt("test-analysis"),"## Context",n].join(`
|
|
42
|
+
|
|
43
|
+
`)}function br(n){return["You are a senior QA engineer. Fix this failing Playwright test in the working directory (the test repository).","Make the smallest change that fixes the real cause. If the cause is a product bug or the environment, do not hide it by weakening assertions: change nothing and explain instead.","Do not commit, push, or change files outside the working directory.",Pt("test-fix"),"## Context",n].join(`
|
|
44
|
+
|
|
45
|
+
`)}function wr(n){return["You are a senior QA engineer. Analyse all failures of this Playwright run for the team.","Group related failures (several groups may share one root cause), separate product bugs from test and environment","problems, and point out likely flaky tests. Refer to groups by the issueSig values given in the context.","You may read files in the working directory (the test repository). Do not modify anything.",Pt("run-analysis"),"## Context",n].join(`
|
|
46
|
+
|
|
47
|
+
`)}function _r(n,e){return`Your answer could not be used: ${e}
|
|
48
|
+
Reply with only the corrected \`\`\`json block with this shape:
|
|
49
|
+
\`\`\`json
|
|
50
|
+
${Vs[n]}
|
|
51
|
+
\`\`\``}class je extends Error{constructor(e,t){super(t),this.name="GitHubError",this.status=e}}function xr(n){const e=atob(n.replace(/\s/g,""));return new TextDecoder().decode(Uint8Array.from(e,t=>t.charCodeAt(0)))}class $t{constructor(e){this.o={...e,apiBase:e.apiBase.replace(/\/+$/,"")},this.fetchImpl=e.fetchImpl??((...t)=>fetch(...t))}get label(){return`${this.o.owner}/${this.o.repo}@${this.o.branch}`}async api(e,t,s,r=[]){const i=await this.fetchImpl(`${this.o.apiBase}${t}`,{method:e,headers:{Authorization:`Bearer ${this.o.token}`,Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28",...s?{"Content-Type":"application/json"}:{}},body:s?JSON.stringify(s):void 0});if(i.ok)return{status:i.status,data:i.status===204?null:await i.json()};if(r.includes(i.status))return{status:i.status,data:null};const a=(await i.json().catch(()=>null))?.message??i.statusText,o=`${this.o.owner}/${this.o.repo}`;throw i.status===401?new je(401,"GitHub rejected the token (401). Store a fresh `gh auth token` in Settings → Tokens."):i.status===403||i.status===404?new je(i.status,`No write access to ${o} (${i.status}: ${a}). The token needs the "repo" scope, and SSO authorization for the org if it uses SSO.`):new je(i.status,`GitHub API ${e} ${t} failed (${i.status}): ${a}`)}repoPath(){return`/repos/${encodeURIComponent(this.o.owner)}/${encodeURIComponent(this.o.repo)}`}async login(){try{return(await this.api("GET","/user")).data?.login??null}catch{return null}}async read(e,t=this.o.branch){const s=e.split("/").map(encodeURIComponent).join("/"),{data:r}=await this.api("GET",`${this.repoPath()}/contents/${s}?ref=${encodeURIComponent(t)}`,void 0,[404]);return r?.content?r.encoding==="base64"?xr(r.content):r.content:null}async commit(e,t,s=3){const r=this.repoPath(),i=encodeURIComponent(this.o.branch);for(let a=1;;a++){const c=(await this.api("GET",`${r}/git/ref/heads/${i}`)).data.object.sha,l=(await this.api("GET",`${r}/git/commits/${c}`)).data,h=await t(b=>this.read(b,c)),d=(await this.api("POST",`${r}/git/trees`,{base_tree:l.tree.sha,tree:h.map(b=>({path:b.path,mode:"100644",type:"blob",content:b.content}))})).data,u=(await this.api("POST",`${r}/git/commits`,{message:e,tree:d.sha,parents:[c]})).data;if((await this.api("PATCH",`${r}/git/refs/heads/${i}`,{sha:u.sha,force:!1},[422])).status!==422)return u.sha;if(a>=s)throw new je(422,"The branch kept changing while publishing. Try again.")}}}class kr{constructor(e){this.label="this report (local server)",this.baseUrl=e}async write(e,t){const s=new URL("__qaily/ai",this.baseUrl);s.searchParams.set("path",e);const r=await fetch(s,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const i=await r.json().catch(()=>null);throw new Error(i?.error??`Saving failed (${r.status})`)}}}class $r{constructor(e,t){this.repo=e,this.dataPath=t.replace(/^\/+|\/+$/g,"")}get label(){return`GitHub ${this.repo.label}`}async write(e,t){const s=this.dataPath?`${this.dataPath}/ai`:"ai";await this.repo.commit(`AI ${t.kind}: ${t.runId}${t.testId?` / ${t.testId}`:""}`,async r=>{let i=null;try{const a=await r(`${s}/index.json`);i=a?JSON.parse(a):null}catch{i=null}return[{path:`${s}/${e}`,content:JSON.stringify(t,null,2)+`
|
|
52
|
+
`},{path:`${s}/index.json`,content:JSON.stringify(fr(i,t),null,2)+`
|
|
53
|
+
`}]})}}class Sr{constructor(){this.mem=new Map,this.db=new Promise(e=>{try{if(typeof indexedDB>"u")return e(null);const t=indexedDB.open("qaily-ai",1);t.onupgradeneeded=()=>t.result.createObjectStore("records",{keyPath:"path"}),t.onsuccess=()=>e(t.result),t.onerror=()=>e(null)}catch{e(null)}})}async tx(e,t){const s=await this.db;if(s)return new Promise((r,i)=>{const a=t(s.transaction("records",e).objectStore("records"));a.onsuccess=()=>r(a.result),a.onerror=()=>i(a.error)})}async all(){return[...await this.tx("readonly",t=>t.getAll()).catch(()=>{})??[],...this.mem.values()]}async get(e){return this.mem.get(e)??await this.tx("readonly",t=>t.get(e)).catch(()=>{})}async put(e){await this.tx("readwrite",s=>s.put(e)).catch(()=>{})===void 0&&this.mem.set(e.path,e)}async delete(e){this.mem.delete(e),await this.tx("readwrite",t=>t.delete(e)).catch(()=>{})}}class Ar{constructor(e){this.rows=new Sr,this.published=new Map,this.indexPromise=null,this.dataUrl=e}refresh(){this.published.clear(),this.indexPromise=null}fetchPublished(e){let t=this.published.get(e);return t||(t=fetch(new URL(`ai/${e}`,this.dataUrl),{cache:"no-cache"}).then(async s=>!s.ok||(s.headers.get("content-type")??"").includes("text/html")?null:pr(await s.json())).catch(()=>null),this.published.set(e,t)),t}publishedIndex(){return this.indexPromise??=fetch(new URL("ai/index.json",this.dataUrl),{cache:"no-cache"}).then(async e=>e.ok&&(e.headers.get("content-type")??"").includes("json")?await e.json():null).catch(()=>null),this.indexPromise}async get(e){const[t,s]=await Promise.all([this.rows.get(e),this.fetchPublished(e)]);return t&&(t.state==="draft"||!s||Date.parse(s.createdAt)<Date.parse(t.record.createdAt))?{path:e,record:t.record,draft:t.state==="draft"}:(t&&s&&this.rows.delete(e),s?{path:e,record:s,draft:!1}:null)}async saveDraft(e,t){return await this.rows.put({path:e,record:t,state:"draft"}),{path:e,record:t,draft:!0}}async publish(e,t){await t.write(e.path,e.record),await this.rows.put({path:e.path,record:e.record,state:"published"}),this.refresh()}async discard(e){await this.rows.delete(e)}async runsWithResults(){const[e,t]=await Promise.all([this.publishedIndex(),this.rows.all()]),s=new Set(Object.keys(e?.runs??{}));for(const r of t)s.add(r.record.runId);return s}}class Cr{constructor(e,t,s,r,i){this.id=crypto.randomUUID(),this.createdAt=new Date,this.status="running",this.result=null,this.abort=new AbortController,this.chat=null,this.kind=e,this.runId=t,this.testId=s,this.title=r,this.transcript=new ut(i)}get info(){const e=this.status==="running"&&this.transcript.pendingApprovals().length>0;return{id:this.id,kind:this.kind,runId:this.runId,testId:this.testId,title:this.title,status:e?"needs-approval":this.status,error:this.error}}confirm(e,t,s,r){this.chat?.confirmTool?.({turnId:e,toolCallId:t,approved:s,optionId:r})}cancel(){this.abort.abort()}}class Tr{constructor(e,t){this.busy=!1,this.session=null,this.abort=null,this.open=e,this.onChange=t,this.transcript=new ut(t)}async send(e){if(!(this.busy||!e.trim())){this.busy=!0,this.abort=new AbortController,this.onChange();try{this.session||(this.transcript.status("Starting an agent session…"),this.session=await this.open()),await pt(this.session,e.trim(),this.transcript,this.abort.signal)}catch(t){const s=t instanceof Error?t.message:String(t);s==="Cancelled"?this.transcript.status("Stopped."):this.transcript.entries.some(r=>r.kind==="status"&&r.text===s)||this.transcript.status(s,!0)}finally{this.busy=!1,this.abort=null,this.onChange()}}}confirm(e,t,s,r){this.session?.confirmTool?.({turnId:e,toolCallId:t,approved:s,optionId:r})}stop(){this.abort?.abort()}detach(){this.stop(),this.session=null}reset(){this.detach(),this.transcript=new ut(this.onChange),this.onChange()}}const ps={"test-analysis":"Analyze","test-fix":"Fix","run-analysis":"Analyze run"};async function Er(n){const e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n));return[...new Uint8Array(e)].slice(0,8).map(t=>t.toString(16).padStart(2,"0")).join("")}class Rr{constructor(e){this.listeners=new Set,this.resultListeners=new Set,this.showListeners=new Set,this._state={status:"disconnected",message:"Not connected to an AI agent."},this.conn=null,this.connecting=null,this._jobs=[],this.author=null,this.o=e,this.chat=new Tr(()=>this.openChatSession(),()=>this.emit())}async openChatSession(){await this.connect();const e=this.o.settings();if(!e.connections.workingDirectory)throw new Error('Set "Local test repo path" in Settings → Connections first: the agent works in that folder.');return this.conn.openChat(e.ai.provider,e.connections.workingDirectory)}state(){return this._state}setState(e){this._state=e,this.emit()}connect(){return this._state.status==="ready"?Promise.resolve():(this.connecting??=this.doConnect().finally(()=>this.connecting=null),this.connecting)}async doConnect(){const e=this.o.settings();this.setState({status:"connecting",message:"Connecting to the agent host…"});try{this.conn=this.o.connect?await this.o.connect():await this.connectHost(e),this.setState({status:"ready",message:`Connected (${e.ai.provider}).`,agent:this.conn.agentName??e.ai.provider})}catch(t){throw this.conn=null,this.setState({status:"error",message:t instanceof Error?t.message:String(t)}),t}}async connectHost(e){const{url:t,tkn:s}=fn(e.connections.agentHostUrl),r=this.o.secrets.get("agentHostToken")??s;if(!r)throw new Error("No agent host connection token. Store it in Settings → Tokens, or include ?tkn=… in the host URL.");const i=new Et(this.o.clientOptions);await i.connect(t,r),e.ai.githubHost&&await i.setGitHubEnterpriseUri(yn(e.ai.githubHost));const a=e.ai.provider,o=i.agent(a),c=this.o.secrets.get("githubToken");return c&&await i.authenticate(a,c),{agentName:o.displayName??a,openChat:(l,h)=>i.openChat(l,h),close:()=>i.close()}}disconnect(){for(const e of this._jobs)e.status==="running"&&e.cancel();this.chat.detach(),this.conn?.close(),this.conn=null,this.setState({status:"disconnected",message:"Disconnected."})}canRun(e){const t=this.o.settings();return{"test-analysis":t.ai.actions.analyzeTest,"test-fix":t.ai.actions.fixTest,"run-analysis":t.ai.actions.analyzeRun}[e]?t.connections.workingDirectory?t.connections.agentHostUrl?{ok:!0}:{ok:!1,reason:"Set the AI agent host URL in Settings → Connections first."}:{ok:!1,reason:'Set "Local test repo path" in Settings → Connections first.'}:{ok:!1,reason:"Turned off in Settings → AI."}}jobs(){return this._jobs}job(e){return this._jobs.find(t=>t.id===e)}jobFor(e,t,s){return this._jobs.find(r=>r.kind===e&&r.runId===t&&r.testId===s)?.info??null}showJob(e){for(const t of this.showListeners)t(e)}onShowJob(e){return this.showListeners.add(e),()=>this.showListeners.delete(e)}analyzeTest(e,t){return this.start("test-analysis",e,t)}fixTest(e,t){return this.start("test-fix",e,t)}analyzeRun(e){return this.start("run-analysis",e)}start(e,t,s){const r=this._jobs.find(o=>o.kind===e&&o.runId===t&&o.testId===s&&o.status==="running");if(r)return this.showJob(r.id),r.info;const i=this.canRun(e);if(!i.ok)throw new Error(i.reason);const a=new Cr(e,t,s,`${ps[e]}: ${s?"test":"run"}`,()=>this.emit());return this._jobs=[a,...this._jobs].slice(0,20),this.emit(),this.showJob(a.id),this.run(a),a.info}async run(e){const t=this.o.settings();try{await this.connect(),e.transcript.status("Collecting context from the report…");const{context:s,title:r}=await this.context(e,t);if(e.title=`${ps[e.kind]}: ${r}`,e.abort.signal.aborted)throw new Error("Cancelled");e.transcript.status("Starting an agent session…"),e.chat=await this.conn.openChat(t.ai.provider,t.connections.workingDirectory);const i={"test-analysis":vr,"test-fix":br,"run-analysis":wr}[e.kind](s);let a=await pt(e.chat,i,e.transcript,e.abort.signal),o=this.validate(e.kind,a);if(!o.ok&&(e.transcript.status(`The answer did not match the expected format (${o.error}); asking once more.`),a=await pt(e.chat,_r(e.kind,o.error),e.transcript,e.abort.signal),o=this.validate(e.kind,a),!o.ok))throw new Error(`The agent's answer could not be used: ${o.error}`);const c={schemaVersion:Ds,kind:e.kind,runId:e.runId,...e.testId?{testId:e.testId}:{},createdAt:new Date().toISOString(),...await this.authorLogin().then(l=>l?{author:l}:{}),provider:t.ai.provider,...e.transcript.model?{model:e.transcript.model}:{},promptVersion:cr,inputHash:await Er(s),result:o.value,transcript:a.length>2e4?`${a.slice(0,2e4)}
|
|
54
|
+
…`:a};e.result=await this.o.store.saveDraft(Le(e.kind,e.runId,e.testId),c),e.status="done",this.emitResults(),e.transcript.status("Saved as a draft. Review it, then publish it to the report.")}catch(s){const r=s instanceof Error?s.message:String(s);e.status=e.abort.signal.aborted||r==="Cancelled"?"cancelled":"error",e.error=r,e.status==="error"&&e.transcript.status(r,!0)}finally{this.emit()}}validate(e,t){const s=wn(t);if(s===void 0)return{ok:!1,error:"no ```json block found"};const r=Zs[e].safeParse(s);if(r.success)return{ok:!0,value:r.data};const i=r.error.issues[0];return{ok:!1,error:`${i?.path.join(".")||"value"}: ${i?.message??"invalid"}`}}authorLogin(){const e=this.o.secrets.get("githubToken"),t=this.o.settings().connections.github;return e?(this.author??=new $t({...t,token:e}).login(),this.author):Promise.resolve(null)}async context(e,t){const s=await this.o.data.runDetail(e.runId),r=t.ai.contextCapKb*1024,i=t.connections.pathMap;if(e.kind==="run-analysis"){if(!s.run)throw new Error("The run was not found in the report.");return{context:yr({...await this.runContextParts(s),run:s.run,pathMap:i,capBytes:r}),title:s.run.run_id}}const a=s.summaries.find(p=>p.test_id===e.testId);if(!a)throw new Error("The test was not found in this run.");const o=s.details.filter(p=>p.test_id===e.testId).sort((p,b)=>p.attempt-b.attempt).map(p=>({detail:p,errors:s.errors.filter(b=>b.test_id===e.testId&&b.attempt===p.attempt)}));o.length||o.push({detail:null,errors:s.errors.filter(p=>p.test_id===e.testId)});const c=[...o].reverse().find(p=>p.errors.length)?.detail?.attempt??o[o.length-1]?.detail?.attempt??0,l=s.attachments.filter(p=>p.test_id===e.testId&&p.attempt===c),[h,d,u]=await Promise.all([this.history(e.testId),this.attachmentText(e.runId,l,"error-context",4e4,"head"),this.attachmentText(e.runId,l,"network-log-filtered",3e4,"tail")]);return{context:gr({run:s.run,summary:a,attempts:o,history:h,errorContext:d,networkLog:u,pathMap:i,capBytes:r}),title:a.title}}async history(e){const t=Date.now();try{return(await this.o.data.query(`SELECT epoch_ms(started_at) AS started_at, status, branch FROM tests WHERE test_id = '${e.replaceAll("'","''")}'
|
|
55
|
+
ORDER BY started_at DESC LIMIT 30`,{from:new Date(t-7776e6),to:new Date(t+1)})).reverse()}catch{return[]}}async attachmentText(e,t,s,r,i){const a=t.find(o=>o.name===s);if(a)try{const{text:o}=await this.o.artifacts.text(e,a.path,i==="head"?r:524288);return i==="head"?o.slice(0,r):o.slice(-r)}catch{return}}async runContextParts(e){const t=e.run;let s=new Map;try{const a=await this.o.data.query(`SELECT test_id, issue_sig FROM issues WHERE run_id = '${t.run_id.replaceAll("'","''")}'`,{from:new Date(Date.parse(t.started_at)-1),to:new Date(Date.parse(t.started_at)+1)});s=new Map(a.map(o=>[o.test_id,o.issue_sig]))}catch{}const r=new Map(e.summaries.map(a=>[a.test_id,a])),i=new Map;for(const a of e.errors){if(e.errors.filter(d=>d.test_id===a.test_id).sort((d,u)=>d.attempt-u.attempt)[0]!==a)continue;const c=s.get(a.test_id)??or(a.err_msg,a.failed_step).slice(0,40),l=r.get(a.test_id),h=i.get(c)??{sig:c,errType:a.err_type,message:a.err_msg,failedStep:a.failed_step,location:a.err_file?`${a.err_file}:${a.err_line??"?"}`:null,tests:[]};h.tests.push({title:l?.title??a.test_id,status:l?.status??"failed",project:l?.project??""}),i.set(c,h)}return{clusters:[...i.values()].sort((a,o)=>o.tests.length-a.tests.length),flaky:e.summaries.filter(a=>a.status==="flaky").map(a=>({title:a.title,project:a.project}))}}async testResults(e,t){const[s,r]=await Promise.all([this.o.store.get(Le("test-analysis",e,t)),this.o.store.get(Le("test-fix",e,t))]);return{analysis:s,fix:r}}runResult(e){return this.o.store.get(Le("run-analysis",e))}runsWithResults(){return this.o.store.runsWithResults()}writer(){if(this.o.localWrites)return new kr(this.o.baseUrl);const e=this.o.settings().connections.github,t=this.o.secrets.get("githubToken");return e.owner&&e.repo&&t?new $r(new $t({...e,token:t}),e.dataPath):null}publishTarget(){const e=this.writer();if(e)return{ok:!0,label:e.label};const t=this.o.settings().connections.github;return{ok:!1,label:"nowhere",reason:!t.owner||!t.repo?"Set the GitHub owner and repo in Settings → Connections (team), or open the report with `qaily-report serve`.":"Store a GitHub token in Settings → Tokens to publish."}}async publish(e){const t=this.writer();if(!t)throw new Error(this.publishTarget().reason);await this.o.store.publish(e,t);for(const s of this._jobs)s.result?.path===e.path&&(s.result={...e,draft:!1});this.emit(),this.emitResults()}async discardDraft(e){await this.o.store.discard(e.path);for(const t of this._jobs)t.result?.path===e.path&&(t.result=null);this.emit(),this.emitResults()}onResults(e){return this.resultListeners.add(e),()=>this.resultListeners.delete(e)}emitResults(){for(const e of this.resultListeners)e()}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(){for(const e of this.listeners)e()}}class Or{constructor(e,t){this.settings=e,this.secrets=t}get label(){const e=this.settings().connections.github;return`GitHub ${e.owner}/${e.repo}`}available(){const e=this.settings().connections.github;return!!(e.owner&&e.repo&&this.secrets.get("githubToken"))}async save(e){const t=this.settings().connections.github,s=this.secrets.get("githubToken");if(!t.owner||!t.repo||!s)throw new Error("Set the GitHub owner and repo (team) and store a GitHub token to save team settings.");const r=`${t.dataPath.replace(/^\/+|\/+$/g,"")}/settings.json`.replace(/^\//,"");await new $t({...t,token:s}).commit("Update report team settings",async()=>[{path:r,content:JSON.stringify(e,null,2)+`
|
|
56
|
+
`}])}}const et=new TextEncoder;function Ir(n){const e=n.trim();let t;try{t=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:`https://${e}`)}catch{throw new Error(`Invalid S3 endpoint: ${n}`)}if(t.protocol!=="https:"&&t.protocol!=="http:"||t.pathname!=="/"||t.search||t.username)throw new Error(`Invalid S3 endpoint (use e.g. https://storage.example.com:9000): ${n}`);return t.origin}function De(n,e=!1){let t="";for(const s of et.encode(n)){const r=String.fromCharCode(s);/[A-Za-z0-9\-_.~]/.test(r)||e&&r==="/"?t+=r:t+=`%${s.toString(16).toUpperCase().padStart(2,"0")}`}return t}function Ws(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function qr(n){return Ws(await crypto.subtle.digest("SHA-256",et.encode(n)))}async function it(n,e){const t=await crypto.subtle.importKey("raw",n,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return crypto.subtle.sign("HMAC",t,et.encode(e))}function Nr(n){return n.toISOString().replace(/[:-]|\.\d{3}/g,"")}async function Pr(n){const e=n.now??new Date,t=Math.min(Math.max(1,Math.floor(n.expiresIn??600)),604800),s=Nr(e),r=s.slice(0,8),i=n.endpoint?.trim()?new URL(Ir(n.endpoint)):null,a=i?.protocol??"https:",o=i?.host??`s3.${n.region}.amazonaws.com`,c=n.host??(n.pathStyle?o:`${n.bucket}.${o}`),l=`${r}/${n.region}/s3/aws4_request`,h=De(n.key.replace(/^\/+/,""),!0),d=n.pathStyle&&!n.host?`/${De(n.bucket)}/${h}`:`/${h}`,u={"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":`${n.accessKeyId}/${l}`,"X-Amz-Date":s,"X-Amz-Expires":String(t),"X-Amz-SignedHeaders":"host"};n.sessionToken&&(u["X-Amz-Security-Token"]=n.sessionToken),n.downloadName&&(u["response-content-disposition"]=`attachment; filename="${n.downloadName.replace(/["\\\r\n]/g,"_")}"`),n.contentType&&(u["response-content-type"]=n.contentType);const p=Object.keys(u).sort().map(Me=>`${De(Me)}=${De(u[Me])}`).join("&"),b=[n.method??"GET",d,p,`host:${c}`,"","host","UNSIGNED-PAYLOAD"].join(`
|
|
57
|
+
`),C=["AWS4-HMAC-SHA256",s,l,await qr(b)].join(`
|
|
58
|
+
`);let O=await it(et.encode(`AWS4${n.secretAccessKey}`),r);for(const Me of[n.region,"s3","aws4_request"])O=await it(O,Me);const Pe=Ws(await it(O,C));return`${a}//${c}${d}?${p}&X-Amz-Signature=${Pe}`}const Mr=/^\s*(?:export\s+|\$env:|set\s+)?(AWS_[A-Z_]+)\s*=\s*["']?([^"'\r\n]*)["']?\s*;?\s*$/i;function Ur(n){const e=n.trim();if(!e)throw new Error("Paste the output of `aws configure export-credentials`.");let t={};if(e.startsWith("{")){let s;try{s=JSON.parse(e)}catch{throw new Error("That looks like JSON but could not be parsed.")}t={accessKeyId:String(s.AccessKeyId??""),secretAccessKey:String(s.SecretAccessKey??""),sessionToken:s.SessionToken?String(s.SessionToken):void 0,expiration:s.Expiration?String(s.Expiration):void 0}}else{const s={};for(const r of e.split(/\r?\n/)){const i=Mr.exec(r);i&&(s[i[1].toUpperCase()]=i[2].trim())}t={accessKeyId:s.AWS_ACCESS_KEY_ID??"",secretAccessKey:s.AWS_SECRET_ACCESS_KEY??"",sessionToken:s.AWS_SESSION_TOKEN||void 0,expiration:s.AWS_CREDENTIAL_EXPIRATION||void 0}}if(!/^[A-Za-z0-9._~+=/-]{3,128}$/.test(t.accessKeyId??""))throw new Error("No valid access key id found.");if(!t.secretAccessKey||t.secretAccessKey.length<8)throw new Error("No secret access key found.");if(t.expiration&&Number.isNaN(Date.parse(t.expiration)))throw new Error("The expiration time is not a valid date.");if(t.expiration&&Gs(t))throw new Error("These credentials have already expired.");return t}function Gs(n,e=new Date,t=6e4){return!!n.expiration&&Date.parse(n.expiration)-t<=e.getTime()}function Lr(n){return n.accessKeyId.startsWith("ASIA")||!!n.sessionToken}function fs(n){return n.length>8?`${n.slice(0,4)}…${n.slice(-4)}`:"****"}class te extends Error{constructor(){super(...arguments),this.name="BridgeError"}}const jr={open(n){const e=document.createElement("iframe");return e.hidden=!0,e.title="Storage bridge",e.setAttribute("aria-hidden","true"),e.referrerPolicy="no-referrer",e.src=n,document.documentElement.append(e),{target:e.contentWindow,close:()=>e.remove(),alive:()=>e.isConnected}},listen(n){const e=t=>n(t);return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}};class Dr{constructor(e,t={}){this.frame=null,this.opening=null,this.pending=new Map,this.active=0,this.queue=[],this.seq=0,this.onReady=null,this.src=e,this.host=t.host??jr,this.readyMs=t.readyMs??2e4,this.requestMs=t.requestMs??3e5,this.maxConcurrent=t.maxConcurrent??6,this.host.listen(s=>this.receive(s))}async fetch(e,t={}){const s=String(e),r=await this.frameFor(new URL(s).origin);await r.ready,await this.slot();try{return await this.send(r,s,t)}finally{this.release()}}close(){this.frame?.close(),this.frame=null,this.opening=null}async frameFor(e){if(this.frame&&!this.frame.alive()&&this.close(),this.frame?.origin===e)return this.frame;this.opening||(this.opening=this.open().finally(()=>this.opening=null));const t=await this.opening;if(t.origin!==e)throw new te(`The storage bridge is on ${t.origin}, but this file is on ${e}.`);return t}async open(){this.close();const e=await this.src();if(!e)throw new te("Report data is stored in the bucket. Connect credentials in Settings → Tokens to view it.");const t=new URL(e).origin,s=this.host.open(e),r=new Promise((a,o)=>{const c=setTimeout(()=>{this.onReady=null,o(new te(`The storage bridge did not load from ${t}. Check that ${Ks} is in the data folder (qaily-report bridge --origin ${globalThis.location?.origin??"<this site>"}), and that this browser trusts the storage's certificate. Or set Settings → Connections → Storage access to Direct.`))},this.readyMs);this.onReady=(l,h)=>{l===s.target&&(clearTimeout(c),this.onReady=null,h!==ms?o(new te(`The storage bridge in the bucket is version ${String(h)}, this report needs ${ms}. Upload it again with qaily-report bridge.`)):a())}}),i={origin:t,target:s.target,close:s.close,alive:s.alive??(()=>!0),ready:r};this.frame=i;try{await r}catch(a){throw this.frame===i&&this.close(),a}return i}send(e,t,s){const r=`${Date.now().toString(36)}-${(this.seq++).toString(36)}`,i=new Headers(s.headers),a={};for(const o of["Range","Content-Type"]){const c=i.get(o);c!==null&&(a[o]=c)}if(s.body!=null&&typeof s.body!="string")throw new te("The storage bridge only sends text bodies.");return new Promise((o,c)=>{const l=setTimeout(()=>{this.pending.delete(r),c(new te("The storage bridge did not answer in time."))},this.requestMs);this.pending.set(r,{resolve:o,reject:c,timer:l}),e.target.postMessage({type:"qaily-fetch",id:r,url:t,method:s.method??"GET",headers:a,body:s.body??void 0},e.origin)})}receive(e){const t=e.data;if(!t||typeof t!="object")return;if(t.type==="qaily-bridge-ready")return this.onReady?.(e.source,t.version);const s=this.frame;if(t.type!=="qaily-response"||!s||e.source!==s.target||e.origin!==s.origin||typeof t.id!="string")return;const r=this.pending.get(t.id);if(!r)return;this.pending.delete(t.id),clearTimeout(r.timer);const i=t;if(i.error||typeof i.status!="number")return r.reject(new te(i.error??"The storage bridge sent an invalid answer."));const a=i.status<200||i.status>599?502:i.status,o=a===204||a===304||i.body==null;r.resolve(new Response(o?null:i.body,{status:a,statusText:i.statusText??"",headers:i.headers??{}}))}slot(){return this.active<this.maxConcurrent?(this.active++,Promise.resolve()):new Promise(e=>this.queue.push(()=>{this.active++,e()}))}release(){this.active--,this.queue.shift()?.()}}function Js(n){return n instanceof Error&&n.name==="BridgeError"}const He="team-settings.json";class Hr{constructor(e,t,s=(...r)=>fetch(...r)){this.target="data",this.seen=void 0,this.artifacts=e,this.where=t,this.fetch=s}get label(){return`bucket ${this.where()}`}available(){return this.artifacts.credentials()!==null}async load(){const e=await this.read();if(!e)return null;try{const t=JSON.parse(e);return t&&typeof t=="object"&&!Array.isArray(t)?xt(t):null}catch{return console.warn(`[qaily settings] ignored ${He}: not valid JSON`),null}}async save(e){const t=this.seen,s=await this.read();if(t!==void 0&&s!==void 0&&s!==t)throw new Error("Someone else changed the team settings after this page loaded them. Reload the page, then make your change again.");const r=JSON.stringify(xt(e),null,2)+`
|
|
59
|
+
`,i=await this.artifacts.dataFileUrl(He,"PUT");if(!i)throw new Error("Connect credentials in Settings → Tokens to save team settings to the bucket.");let a;try{a=await this.fetch(i,{method:"PUT",body:r,headers:{"Content-Type":"application/json"}})}catch(o){throw Js(o)?o:new Error(`Could not save to the bucket. Its CORS rules must allow PUT from ${globalThis.location?.origin??"this site"}.`)}if(a.status===403)throw new Error(`The bucket refused the save (403). The key needs write access to ${this.where()}/${He}; read-only keys can't save.`);if(!a.ok)throw new Error(`Saving team settings to the bucket failed (${a.status})`);this.seen=r}async read(){const e=await this.artifacts.dataFileUrl(He);if(e)try{const t=await this.fetch(e,{cache:"no-store"});return t.status===404?this.seen=null:t.ok?this.seen=await t.text():void 0}catch{return}}}const Ks="qaily-bridge.html",ms=1,zr=3600,Br=1800,gs=600,Zr=()=>`Check that the bucket's CORS rules allow ${globalThis.location?.origin??"this site"}, and your network connection.`;function Fr(n,e,t){const s=t.replace(/^\/+/,"");if(s.split("/").includes("..")||e.includes("/")||e.includes(".."))throw new Error("Invalid attachment path");return[n.replace(/^\/+|\/+$/g,""),e,s].filter(Boolean).join("/")}class Vr{constructor(e){this.listeners=new Set,this.cache=new Map,this.bridge=null,this.images=new Map,this.opts=e}get mode(){return this.opts.localServer?"local":this.opts.s3().bucket?"browser":"static"}status(){const e=this.mode;if(e==="static")return{mode:e,ready:!0,message:"Attachments are published with the report."};if(e==="local")return{mode:e,ready:!0,message:"Served by the local report server (local files first, then S3)."};const t=this.loadCredentials();return t?{mode:e,ready:!0,message:`Signed in the browser as ${fs(t.accessKeyId)}.`}:{mode:e,ready:!1,message:"Attachments are stored in S3-compatible storage. Connect credentials to view them."}}async url(e,t,s={}){const r=this.mode;if(r==="static"){const u=t.replace(/^\/+/,"").split("/").map(encodeURIComponent).join("/");return new URL(`runs/${encodeURIComponent(e)}/${u}`,this.opts.dataUrl).href}if(r==="local"){const u=new URL("__qaily/artifact",this.opts.baseUrl);return u.searchParams.set("run",e),u.searchParams.set("path",t),s.downloadName&&u.searchParams.set("download",s.downloadName),u.href}const i=this.loadCredentials();if(!i)return null;const a=this.opts.s3(),o=Fr(a.prefix,e,t),c=`${o}|${s.downloadName??""}`,l=this.cache.get(c);if(l&&l.until>Date.now()&&!s.fresh)return l.url;const h=await this.sign(i,o,zr,s.downloadName),d=i.expiration?Date.parse(i.expiration)-6e4:1/0;return this.cache.set(c,{url:h,until:Math.min(Date.now()+Br*1e3,d)}),h}async dataFileUrl(e,t="GET"){const s=e.replace(/^\/+/,"");if(s.split("/").includes(".."))throw new Error("Invalid report data path");const r=this.loadCredentials();if(!r)return null;const i=this.opts.s3().dataPrefix.replace(/^\/+|\/+$/g,"");return this.sign(r,[i,s].filter(Boolean).join("/"),gs,void 0,t)}usesBridge(){return this.mode==="browser"&&this.opts.s3().transport==="bridge"}async bridgeUrl(){const e=this.loadCredentials();if(!e)return null;const t=this.opts.s3().dataPrefix.replace(/^\/+|\/+$/g,"");return this.sign(e,[t,Ks].filter(Boolean).join("/"),gs,void 0,"GET","text/html; charset=utf-8")}storageFetch(e,t){return this.usesBridge()?(this.bridge??=new Dr(()=>this.bridgeUrl(),{host:this.opts.bridgeHost}),this.bridge.fetch(e,t)):fetch(e,t)}async imageUrl(e,t,s={}){if(!this.usesBridge())return this.url(e,t,s);const r=`${e}/${t}`;let i=this.images.get(r);if((!i||s.fresh)&&(i=this.fetchAttachment(e,t).then(async o=>URL.createObjectURL(await o.blob())).catch(()=>null),this.images.set(r,i),this.images.size>300)){const[o,c]=this.images.entries().next().value;this.images.delete(o),c.then(l=>l&&URL.revokeObjectURL(l))}const a=await i;return a||this.images.delete(r),a}sign(e,t,s,r,i="GET",a){const o=this.opts.s3();return Pr({method:i,bucket:o.bucket,region:o.region,endpoint:o.endpoint,pathStyle:o.pathStyle,key:t,accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken,expiresIn:s,downloadName:r,contentType:a})}async check(e,t){try{if(this.mode==="local"){const a=new URL(await this.url(e,t)??"");return a.searchParams.set("check","1"),(await(await fetch(a)).json()).status??"unknown"}const s=await this.url(e,t);if(!s)return"unknown";const r=new AbortController,i=await this.storageFetch(s,{headers:{Range:"bytes=0-0"},signal:r.signal});return r.abort(),xn(i.status)}catch{return"unknown"}}async text(e,t,s=256*1024){const r=await this.fetchAttachment(e,t,{headers:{Range:`bytes=0-${s-1}`}}),i=new Uint8Array(await r.arrayBuffer()),a=Number(r.headers.get("content-range")?.split("/")[1]??i.length),o=i.subarray(0,s);return{text:new TextDecoder().decode(o),truncated:a>o.length||i.length>s}}async blob(e,t){return(await this.fetchAttachment(e,t,void 0,!0)).blob()}async fetchAttachment(e,t,s,r=!1){const i=await this.url(e,t,{fresh:r});if(!i)throw new Error("This attachment is stored in S3-compatible storage. Connect credentials in Settings → Tokens to view it.");let a;try{a=await this.storageFetch(i,s)}catch(o){throw Js(o)?o:new Error(`Could not read ${t} from storage. ${Zr()}`)}if(a.status===404&&this.mode==="local"){const o=await a.json().catch(()=>null);throw new Error(o?.error??"This attachment was not found locally or in S3.")}if(a.status===404)throw new Error(this.mode==="static"?"This attachment is not in the report. Large artifacts (traces, logs) may be stored in S3 instead.":"This attachment was not found locally or in S3.");if(a.status===403)throw new Error("S3 refused access (403). The credentials may lack s3:GetObject on this prefix, or have expired.");if(!a.ok)throw new Error(`Could not load ${t} (${a.status})`);return a}connect(e,t){const s=Ur(e);return this.opts.secrets.set("awsCredentials",JSON.stringify(s),t),this.cache.clear(),this.emit(),this.credentials()}disconnect(){this.opts.secrets.forget("awsCredentials"),this.cache.clear();for(const e of this.images.values())e.then(t=>t&&URL.revokeObjectURL(t));this.images.clear(),this.bridge?.close(),this.bridge=null,this.emit(),this.opts.onForget?.()}keepsCredentialsOnDevice(){return this.credentials()?.persistence==="local"}credentials(){const e=this.loadCredentials();return e?{keyId:fs(e.accessKeyId),temporary:Lr(e),expiration:e.expiration??null,persistence:this.opts.secrets.persistence("awsCredentials")}:null}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}loadCredentials(){const e=this.opts.secrets.get("awsCredentials");if(!e)return null;try{const t=JSON.parse(e);if(!t.accessKeyId||!t.secretAccessKey)throw new Error("incomplete");return Gs(t)?(this.opts.secrets.forget("awsCredentials"),this.cache.clear(),queueMicrotask(()=>this.emit()),null):t}catch{return this.opts.secrets.forget("awsCredentials"),null}}emit(){const e=this.status();for(const t of this.listeners)t(e)}}function Mt(n){try{return n==="local"?globalThis.localStorage??null:globalThis.sessionStorage??null}catch{return null}}function ie(n,e){try{const t=Mt(n)?.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Ut(n,e,t){try{const s=Mt(n);return s?(s.setItem(e,JSON.stringify(t)),!0):!1}catch{return!1}}function St(n,e){try{Mt(n)?.removeItem(e)}catch{}}const Ce="qaily.settings.v1";function Wr(n){const e=n.replace(/\/+$/,"")||"/";return e==="/"?Ce:`${Ce}:${e}`}class Gr{constructor(e){this.label="local server",this.baseUrl=e}async save(e){const t=await fetch(new URL("__qaily/settings",this.baseUrl),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const s=await t.json().catch(()=>null);throw new Error(s?.error??`Saving team settings failed (${t.status})`)}}}async function Jr(n){try{const e=await fetch(new URL("__qaily/status",n),{cache:"no-store"});if(!e.ok||!(e.headers.get("content-type")??"").includes("json"))return null;const t=await e.json();return t.ok?{ok:!0,writes:!!t.writes,artifacts:!!t.artifacts}:null}catch{return null}}function Kr(n,e){return n?.writes?new Gr(e):null}async function Yr(n){try{const e=await fetch(new URL("settings.json",n),{cache:"no-cache"});if(!e.ok)return{};const t=await e.json();return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}class Xr{constructor(e,t,s=Rt,r=Ce){this.listeners=new Set,this._data=null,this._site=e,this.writer=t,this.defaults=s,this.storageKey=r,this._personal=ie("local",r)??ie("local",Ce)??{},this._resolved=this.resolve()}get resolved(){return this._resolved}get team(){return this._data?rr(this._site,this._data):this._site}get personal(){return this._personal}get hasDataTeamLayer(){return this._data!==null}setWriter(e){this.writer=e}setDataLayer(e){JSON.stringify(e)!==JSON.stringify(this._data)&&(this._data=e,this.update())}get canSaveTeam(){return this.writer!==null&&(this.writer.available?.()??!0)}get teamWriterLabel(){return this.writer?.label??null}get teamTarget(){return this.writer?this.writer.target??"site":null}get settings(){return this._resolved.settings}setPersonal(e,t){this.setPersonalMany({[e]:t})}setPersonalMany(e){let t=this._personal;for(const[s,r]of Object.entries(e)){if(!sr(s))throw new Error(`Unknown setting: ${s}`);t=Ne(t,s,r)}this.storePersonal(t)}async saveTeam(e){if(!this.writer)throw new Error("This report is read-only: no team settings writer is available");await this.writer.save(e),this.writer.target==="data"?this._data=xt(e):this._site=e,this.update()}exportJson(){return JSON.stringify({team:this.team,personal:this._personal},null,2)}async importJson(e,t){const s=JSON.parse(e),r=(s.team||s.personal?s[t]:s)??{};if(typeof r!="object"||Array.isArray(r))throw new Error("Expected a settings object");if(t==="team")return this.saveTeam(r);this.storePersonal(r)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}teamOrDefault(e){return Nt(ds(this.defaults,this.team,{}).settings,e)}storePersonal(e){this._personal=e,Object.keys(e).length===0&&this.storageKey===Ce?St("local",this.storageKey):Ut("local",this.storageKey,e),this.update()}resolve(){const e=ds(this.defaults,this.team,this._personal);for(const t of e.warnings)console.warn(`[qaily settings] ${t}`);return e}update(){this._resolved=this.resolve();for(const e of this.listeners)e(this._resolved)}}const se=n=>`qaily.secret.${n}`,Qr=["agentHostToken","githubToken","awsCredentials"];class ei{constructor(){this.memory=new Map}get(e){return this.memory.get(e)??ie("session",se(e))??ie("local",se(e))}persistence(e){return this.memory.has(e)?"memory":ie("session",se(e))!==null?"session":ie("local",se(e))!==null?"local":null}set(e,t,s){this.forget(e),s==="memory"?this.memory.set(e,t):Ut(s==="session"?"session":"local",se(e),t)}forget(e){this.memory.delete(e),St("session",se(e)),St("local",se(e))}forgetAll(){for(const e of Qr)this.forget(e)}}const ti="modulepreload",si=function(n,e){return new URL(n,e).href},ys={},P=function(e,t,s){let r=Promise.resolve();if(t&&t.length>0){let l=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const a=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),c=o?.nonce||o?.getAttribute("nonce");r=l(t.map(h=>{if(h=si(h,s),h in ys)return;ys[h]=!0;const d=h.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(s)for(let b=a.length-1;b>=0;b--){const C=a[b];if(C.href===h&&(!d||C.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${u}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":ti,d||(p.as="script"),p.crossOrigin="",p.href=h,c&&p.setAttribute("nonce",c),document.head.appendChild(p),d)return new Promise((b,C)=>{p.addEventListener("load",b),p.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${h}`)))})}))}function i(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return r.then(a=>{for(const o of a||[])o.status==="rejected"&&i(o.reason);return e().catch(i)})};function ni(n){return n.length>1&&n[0]===31&&n[1]===139}async function ri(n){const e=new Blob([n]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(e).arrayBuffer())}function ii(n){const e=[];for(const t of n.split(`
|
|
60
|
+
`)){const s=t.trim();if(s)try{e.push(JSON.parse(s))}catch{}}return e}async function ai(n){return Ys(await fetch(n),n)}async function Ys(n,e){if(n.status===404)return[];if(!n.ok)throw new Error(`Could not load ${e} (${n.status})`);if((n.headers.get("content-type")??"").includes("text/html"))return[];let t=new Uint8Array(await n.arrayBuffer());return ni(t)&&(t=await ri(t)),ii(new TextDecoder().decode(t))}const Xs="qaily-rollups-v1",Lt=()=>typeof caches>"u"?null:caches.open(Xs),Qs=n=>`${globalThis.location?.origin}/__qaily-rollups/${encodeURIComponent(n)}/`,jt=(n,e,t)=>`${Qs(n)}${e}?v=${t}`;async function oi(n,e,t){try{const s=await(await Lt())?.match(jt(n,e,t));return s?new Uint8Array(await s.arrayBuffer()):null}catch{return null}}async function ci(n,e,t,s){try{await(await Lt())?.put(jt(n,e,t),new Response(s.slice()))}catch{}}async function li(n,e){try{const t=await Lt();if(!t)return;const s=Qs(n),r=new Set(e.map(i=>jt(n,i.path,i.hash)));for(const i of await t.keys())i.url.startsWith(s)&&!r.has(i.url)&&await t.delete(i)}catch{}}async function Xe(){try{typeof caches<"u"&&await caches.delete(Xs)}catch{}}class he extends Error{}function di(n){const e=[],t=new Date(Date.UTC(n.from.getUTCFullYear(),n.from.getUTCMonth(),1)),s=new Date(n.to.getTime()-1);for(;t<=s;)e.push(t.toISOString().slice(0,7)),t.setUTCMonth(t.getUTCMonth()+1);return e}class hi{constructor(e,t=null){this.catalogPromise=null,this.monthRuns=new Map,this.duck=null,this.details=new Map,this._accessProblem=null,this.dataUrl=e,this.bucket=t}get readsFromBucket(){return this.bucket!==null}get accessProblem(){return this._accessProblem}catalog(e={}){if(!this.catalogPromise||e.refresh){const t=this.fetchJson("catalog.json","no-cache").then(i=>(this._accessProblem=null,this.bucket?.keepOnDevice()&&li(this.bucket.scope,i.months.flatMap(a=>Object.values(a.files).filter(Boolean).map(o=>({path:o,hash:a.hash})))),i)),s=this.catalogPromise,r=t.catch(i=>{if(i instanceof he&&(this._accessProblem=i),s)return s;throw this.catalogPromise===r&&(this.catalogPromise=null),i});this.catalogPromise=r}return this.catalogPromise}async runs(e){const t=await this.monthsFor(e),s=await Promise.all(t.map(a=>this.runsOfMonth(a))),r=e.from.getTime(),i=e.to.getTime();return s.flat().filter(a=>{const o=Date.parse(a.started_at);return o>=r&&o<i}).sort((a,o)=>o.started_at.localeCompare(a.started_at))}async query(e,t){const s=await this.monthsFor(t);return this.duck??=P(()=>import("./duckdb-goGSUA4o.js"),[],import.meta.url).then(i=>i.openDuckSession()),(await this.duck).query(e,s,this.bucket?{bytes:(i,a)=>this.rollupBytes(i,a)}:{url:i=>new URL(i,this.dataUrl).href})}async json(e){try{return await this.fetchJson(e,"no-cache")}catch{return null}}run(e){return this.findRun(e)}runDetail(e){let t=this.details.get(e);if(!t){const s=r=>{if(!this.bucket)return ai(this.url(`runs/${encodeURIComponent(e)}/${r}.jsonl.gz`));const i=`runs/${e}/${r}.jsonl.gz`;return this.fromBucket(i).then(a=>Ys(a,i))};t=Promise.all([this.findRun(e),s("test-summary"),s("test_details"),s("errors"),s("attachments-index")]).then(([r,i,a,o,c])=>{if(!r&&i.length===0)throw new Error(`Run ${e} was not found`);return{run:r,summaries:i,details:a,errors:o,attachments:c}}),t.catch(()=>this.details.delete(e)),this.details.set(e,t),this.details.size>8&&this.details.delete(this.details.keys().next().value)}return t}async findRun(e){const t=await this.catalog(),s=/^\d{4}-\d{2}/.exec(e)?.[0],r=[...t.months].sort((i,a)=>+(a.month===s)-+(i.month===s));for(const i of r){const a=(await this.runsOfMonth(i)).find(o=>o.run_id===e);if(a)return a}return null}url(e){return new URL(e,this.dataUrl).href}async monthsFor(e){const t=new Set(di(e));return(await this.catalog()).months.filter(s=>t.has(s.month))}runsOfMonth(e){const t=`${e.month}@${e.hash}`;let s=this.monthRuns.get(t);return s||(s=this.bucket?this.rollupBytes(e.files.runs,e.hash).then(r=>JSON.parse(new TextDecoder().decode(r))):this.fetchJson(`${e.files.runs}?v=${e.hash}`,"default"),s.catch(()=>this.monthRuns.delete(t)),this.monthRuns.set(t,s)),s}async fetchJson(e,t){const s=this.bucket?await this.fromBucket(e,{cache:t}):await fetch(new URL(e,this.dataUrl),{cache:t});if(!s.ok)throw new Error(`Could not load ${e} (${s.status})`);if((s.headers.get("content-type")??"").includes("text/html"))throw new Error(`Could not load ${e} (got HTML)`);return await s.json()}async rollupBytes(e,t){const s=this.bucket.keepOnDevice(),r=s?await oi(this.bucket.scope,e,t):null;if(r)return r;const i=await this.fromBucket(e);if(!i.ok)throw new Error(`Could not load ${e} (${i.status})`);const a=new Uint8Array(await i.arrayBuffer());return s&&await ci(this.bucket.scope,e,t,a),a}async fromBucket(e,t){const s=e.split("?")[0],r=await this.bucket.signedUrl(s);if(!r)throw new he("Report data is stored in the bucket. Connect credentials in Settings → Tokens to view it.");let i;try{i=await(this.bucket.fetch??fetch)(r,t)}catch(a){throw a instanceof Error&&a.name==="BridgeError"?new he(a.message):new he(`Could not read ${s} from storage. Check that the bucket's CORS rules allow ${globalThis.location?.origin??"this site"}, and your network connection.`)}if(i.status===403)throw new he(`Storage refused access to ${s} (403). The credentials may lack read access to the report data, or have expired.`);return i}}function ui(n){const e=n.replace(/^#\/?/,""),[t,s=""]=e.split("?"),r={};for(const[i,a]of new URLSearchParams(s))r[i]=a;return{page:decodeURIComponent(t.split("/")[0]??""),params:r}}function z(n,e={}){const t=new URLSearchParams(Object.entries(e).filter(([,s])=>s!==""&&s!=null)).toString();return`#/${encodeURIComponent(n)}${t?`?${t}`:""}`}class pi{constructor(e=window){this.listeners=new Set,this.onHash=()=>this.emit(),this.win=e,e.addEventListener("hashchange",this.onHash)}get current(){return ui(this.win.location.hash)}go(e,t={}){this.win.location.hash=z(e,t)}replace(e,t){this.win.history.replaceState(null,"",z(e,t))}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.win.removeEventListener("hashchange",this.onHash)}emit(){const e=this.current;for(const t of this.listeners)t(e)}}const fi=["range","branch","lanes"];function mi(n,e){const t=Number(n.range);return{rangeDays:Number.isInteger(t)&&t>0&&t<=366?t:e.display.defaultRangeDays,branch:n.branch==="all"?"all":"main",lanes:n.lanes?n.lanes.split(",").filter(Boolean):[]}}function at(n,e){const t={};return n.rangeDays!==e.display.defaultRangeDays&&(t.range=String(n.rangeDays)),n.branch!=="main"&&(t.branch=n.branch),n.lanes.length&&(t.lanes=n.lanes.join(",")),t}function Ca(n,e){const t=new Date(e.getTime()+1);return{from:new Date(e.getTime()-n*864e5),to:t}}function Ta(n,e,t){return e.branch==="all"||n!=null&&t.data.mainBranches.includes(n)}function Ea(n){if(n==null||!Number.isFinite(n))return"–";if(n<1e3)return`${Math.round(n)}ms`;const e=Math.round(n/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60);return t<60?`${t}m ${e%60}s`:`${Math.floor(t/60)}h ${t%60}m`}function Ra(n,e=1){return n==null||!Number.isFinite(n)?"–":`${n===100?"100":n.toFixed(e)}%`}function Oa(n){return new Intl.NumberFormat().format(n)}function en(n){return n.display.timeZone==="UTC"?"UTC":void 0}function tn(n,e){return new Date(n).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",timeZone:en(e)})}function gi(n,e,t={month:"short",day:"numeric"}){return new Date(n).toLocaleDateString(void 0,{...t,timeZone:en(e)})}function Ia(n,e){return`${gi(n,e)} ${tn(n,e)}`}function yi(n,e){const t=(e.getTime()-new Date(n).getTime())/1e3;return t<60?"just now":t<3600?`${Math.floor(t/60)} min ago`:t<86400?`${Math.floor(t/3600)} h ago`:`${Math.floor(t/86400)} d ago`}function tt(n,e){return e.display.timeZone==="UTC"?{y:n.getUTCFullYear(),m:n.getUTCMonth(),d:n.getUTCDate(),weekday:n.getUTCDay()}:{y:n.getFullYear(),m:n.getMonth(),d:n.getDate(),weekday:n.getDay()}}function qa(n,e){const t=tt(new Date(n),e);return`${t.y}-${String(t.m+1).padStart(2,"0")}-${String(t.d).padStart(2,"0")}`}function sn(n,e,t,s){return s.display.timeZone==="UTC"?new Date(Date.UTC(n,e,t)):new Date(n,e,t)}function vi(n,e){const t=tt(n,e);return sn(t.y,t.m,t.d,e)}function bi(n,e,t){const s=tt(n,t);return sn(s.y,s.m,s.d+e,t)}function Na(n,e){const t=vi(n,e),s=(tt(t,e).weekday-e.display.weekStartsOn+7)%7;return bi(t,-s,e)}class wi{constructor(e){this.appliedTokens=[],this.media=window.matchMedia("(prefers-color-scheme: dark)"),this.motion=window.matchMedia("(prefers-reduced-motion: reduce)"),this.themes=e,this.style=document.createElement("style"),this.style.id="qaily-theme",document.head.append(this.style)}theme(e){const t=s=>this.themes.find(r=>r.id===s);return t(e)??t(Rt.display.theme)??this.themes[0]}onSystemChange(e){return this.media.addEventListener("change",e),this.motion.addEventListener("change",e),()=>{this.media.removeEventListener("change",e),this.motion.removeEventListener("change",e)}}apply(e){const t=this.theme(e.display.theme),s=e.display.colorScheme,r=t.forcedColorScheme??(s==="auto"?this.media.matches?"dark":"light":s),i=e.display.reducedMotion==="auto"?this.motion.matches:e.display.reducedMotion==="on",a=document.documentElement;this.style.textContent!==t.css&&(this.style.textContent=t.css),a.dataset.theme=t.id,a.dataset.colorScheme=r,a.style.colorScheme=r,a.toggleAttribute("data-reduced-motion",i);for(const o of this.appliedTokens)a.style.removeProperty(o);this.appliedTokens=[];for(const[o,c]of Object.entries(e.themeTokens))/^--[a-z0-9-]+$/i.test(o)&&(a.style.setProperty(o,c),this.appliedTokens.push(o));return{id:t.id,colorScheme:r,reducedMotion:i}}viewsFor(e){const t=new Set(Object.keys(e.views));for(const s of this.themes)for(const r of Object.keys(s.views?.[e.id]??{}))t.add(r);return[...t]}resolveView(e,t){const s=this.theme(t.display.theme),r=[t.display.views[e.id],s.preferredViews?.[e.id],"classic"];for(const i of r){if(!i)continue;const a=e.views[i]??s.views?.[e.id]?.[i]??this.themes.map(o=>o.views?.[e.id]?.[i]).find(Boolean);if(a)return{name:i,load:a}}return{name:"classic",load:e.views.classic}}}const vs="qaily.notes.v1";class _i{constructor(){this.notes=ie("local",vs)??{}}get(e){return this.notes[e]?.text??""}set(e,t){const s={...this.notes};t.trim()?s[e]={text:t,updatedAt:new Date().toISOString()}:delete s[e],this.notes=s,Ut("local",vs,s)}keys(){return new Set(Object.keys(this.notes))}}const Ze=globalThis,Dt=Ze.ShadowRoot&&(Ze.ShadyCSS===void 0||Ze.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ht=Symbol(),bs=new WeakMap;let nn=class{constructor(e,t,s){if(this._$cssResult$=!0,s!==Ht)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Dt&&e===void 0){const s=t!==void 0&&t.length===1;s&&(e=bs.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),s&&bs.set(t,e))}return e}toString(){return this.cssText}};const xi=n=>new nn(typeof n=="string"?n:n+"",void 0,Ht),F=(n,...e)=>{const t=n.length===1?n[0]:e.reduce((s,r,i)=>s+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+n[i+1],n[0]);return new nn(t,n,Ht)},ki=(n,e)=>{if(Dt)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const s=document.createElement("style"),r=Ze.litNonce;r!==void 0&&s.setAttribute("nonce",r),s.textContent=t.cssText,n.appendChild(s)}},ws=Dt?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return xi(t)})(n):n;const{is:$i,defineProperty:Si,getOwnPropertyDescriptor:Ai,getOwnPropertyNames:Ci,getOwnPropertySymbols:Ti,getPrototypeOf:Ei}=Object,st=globalThis,_s=st.trustedTypes,Ri=_s?_s.emptyScript:"",Oi=st.reactiveElementPolyfillSupport,Te=(n,e)=>n,At={toAttribute(n,e){switch(e){case Boolean:n=n?Ri:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},rn=(n,e)=>!$i(n,e),xs={attribute:!0,type:String,converter:At,reflect:!1,useDefault:!1,hasChanged:rn};Symbol.metadata??=Symbol("metadata"),st.litPropertyMetadata??=new WeakMap;let ue=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=xs){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const s=Symbol(),r=this.getPropertyDescriptor(e,s,t);r!==void 0&&Si(this.prototype,e,r)}}static getPropertyDescriptor(e,t,s){const{get:r,set:i}=Ai(this.prototype,e)??{get(){return this[t]},set(a){this[t]=a}};return{get:r,set(a){const o=r?.call(this);i?.call(this,a),this.requestUpdate(e,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??xs}static _$Ei(){if(this.hasOwnProperty(Te("elementProperties")))return;const e=Ei(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Te("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Te("properties"))){const t=this.properties,s=[...Ci(t),...Ti(t)];for(const r of s)this.createProperty(r,t[r])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[s,r]of t)this.elementProperties.set(s,r)}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const r=this._$Eu(t,s);r!==void 0&&this._$Eh.set(r,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const r of s)t.unshift(ws(r))}else e!==void 0&&t.push(ws(e));return t}static _$Eu(e,t){const s=t.attribute;return s===!1?void 0:typeof s=="string"?s:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const s of t.keys())this.hasOwnProperty(s)&&(e.set(s,this[s]),delete this[s]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ki(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$ET(e,t){const s=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,s);if(r!==void 0&&s.reflect===!0){const i=(s.converter?.toAttribute!==void 0?s.converter:At).toAttribute(t,s.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){const s=this.constructor,r=s._$Eh.get(e);if(r!==void 0&&this._$Em!==r){const i=s.getPropertyOptions(r),a=typeof i.converter=="function"?{fromAttribute:i.converter}:i.converter?.fromAttribute!==void 0?i.converter:At;this._$Em=r;const o=a.fromAttribute(t,i.type);this[r]=o??this._$Ej?.get(r)??o,this._$Em=null}}requestUpdate(e,t,s,r=!1,i){if(e!==void 0){const a=this.constructor;if(r===!1&&(i=this[e]),s??=a.getPropertyOptions(e),!((s.hasChanged??rn)(i,t)||s.useDefault&&s.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,s))))return;this.C(e,t,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:s,reflect:r,wrapped:i},a){s&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),i!==!0||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||s||(t=void 0),this._$AL.set(e,t)),r===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[r,i]of this._$Ep)this[r]=i;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,i]of s){const{wrapped:a}=i,o=this[r];a!==!0||this._$AL.has(r)||o===void 0||this.C(r,void 0,i,o)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(t)):this._$EM()}catch(s){throw e=!1,this._$EM(),s}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(e){}firstUpdated(e){}};ue.elementStyles=[],ue.shadowRootOptions={mode:"open"},ue[Te("elementProperties")]=new Map,ue[Te("finalized")]=new Map,Oi?.({ReactiveElement:ue}),(st.reactiveElementVersions??=[]).push("2.1.2");const zt=globalThis,ks=n=>n,Qe=zt.trustedTypes,$s=Qe?Qe.createPolicy("lit-html",{createHTML:n=>n}):void 0,an="$lit$",Y=`lit$${Math.random().toFixed(9).slice(2)}$`,on="?"+Y,Ii=`<${on}>`,ce=document,Oe=()=>ce.createComment(""),Ie=n=>n===null||typeof n!="object"&&typeof n!="function",Bt=Array.isArray,qi=n=>Bt(n)||typeof n?.[Symbol.iterator]=="function",ot=`[
|
|
61
|
+
\f\r]`,ke=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ss=/-->/g,As=/>/g,ne=RegExp(`>|${ot}(?:([^\\s"'>=/]+)(${ot}*=${ot}*(?:[^
|
|
62
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Cs=/'/g,Ts=/"/g,cn=/^(?:script|style|textarea|title)$/i,ln=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),v=ln(1),le=ln(2),Z=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),Es=new WeakMap,ae=ce.createTreeWalker(ce,129);function dn(n,e){if(!Bt(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return $s!==void 0?$s.createHTML(e):e}const Ni=(n,e)=>{const t=n.length-1,s=[];let r,i=e===2?"<svg>":e===3?"<math>":"",a=ke;for(let o=0;o<t;o++){const c=n[o];let l,h,d=-1,u=0;for(;u<c.length&&(a.lastIndex=u,h=a.exec(c),h!==null);)u=a.lastIndex,a===ke?h[1]==="!--"?a=Ss:h[1]!==void 0?a=As:h[2]!==void 0?(cn.test(h[2])&&(r=RegExp("</"+h[2],"g")),a=ne):h[3]!==void 0&&(a=ne):a===ne?h[0]===">"?(a=r??ke,d=-1):h[1]===void 0?d=-2:(d=a.lastIndex-h[2].length,l=h[1],a=h[3]===void 0?ne:h[3]==='"'?Ts:Cs):a===Ts||a===Cs?a=ne:a===Ss||a===As?a=ke:(a=ne,r=void 0);const p=a===ne&&n[o+1].startsWith("/>")?" ":"";i+=a===ke?c+Ii:d>=0?(s.push(l),c.slice(0,d)+an+c.slice(d)+Y+p):c+Y+(d===-2?o:p)}return[dn(n,i+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),s]};class qe{constructor({strings:e,_$litType$:t},s){let r;this.parts=[];let i=0,a=0;const o=e.length-1,c=this.parts,[l,h]=Ni(e,t);if(this.el=qe.createElement(l,s),ae.currentNode=this.el.content,t===2||t===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(r=ae.nextNode())!==null&&c.length<o;){if(r.nodeType===1){if(r.hasAttributes())for(const d of r.getAttributeNames())if(d.endsWith(an)){const u=h[a++],p=r.getAttribute(d).split(Y),b=/([.?@])?(.*)/.exec(u);c.push({type:1,index:i,name:b[2],strings:p,ctor:b[1]==="."?Mi:b[1]==="?"?Ui:b[1]==="@"?Li:nt}),r.removeAttribute(d)}else d.startsWith(Y)&&(c.push({type:6,index:i}),r.removeAttribute(d));if(cn.test(r.tagName)){const d=r.textContent.split(Y),u=d.length-1;if(u>0){r.textContent=Qe?Qe.emptyScript:"";for(let p=0;p<u;p++)r.append(d[p],Oe()),ae.nextNode(),c.push({type:2,index:++i});r.append(d[u],Oe())}}}else if(r.nodeType===8)if(r.data===on)c.push({type:2,index:i});else{let d=-1;for(;(d=r.data.indexOf(Y,d+1))!==-1;)c.push({type:7,index:i}),d+=Y.length-1}i++}}static createElement(e,t){const s=ce.createElement("template");return s.innerHTML=e,s}}function be(n,e,t=n,s){if(e===Z)return e;let r=s!==void 0?t._$Co?.[s]:t._$Cl;const i=Ie(e)?void 0:e._$litDirective$;return r?.constructor!==i&&(r?._$AO?.(!1),i===void 0?r=void 0:(r=new i(n),r._$AT(n,t,s)),s!==void 0?(t._$Co??=[])[s]=r:t._$Cl=r),r!==void 0&&(e=be(n,r._$AS(n,e.values),r,s)),e}class Pi{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:s}=this._$AD,r=(e?.creationScope??ce).importNode(t,!0);ae.currentNode=r;let i=ae.nextNode(),a=0,o=0,c=s[0];for(;c!==void 0;){if(a===c.index){let l;c.type===2?l=new we(i,i.nextSibling,this,e):c.type===1?l=new c.ctor(i,c.name,c.strings,this,e):c.type===6&&(l=new ji(i,this,e)),this._$AV.push(l),c=s[++o]}a!==c?.index&&(i=ae.nextNode(),a++)}return ae.currentNode=ce,r}p(e){let t=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(e,s,t),t+=s.strings.length-2):s._$AI(e[t])),t++}}class we{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,s,r){this.type=2,this._$AH=w,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=s,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=be(this,e,t),Ie(e)?e===w||e==null||e===""?(this._$AH!==w&&this._$AR(),this._$AH=w):e!==this._$AH&&e!==Z&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):qi(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==w&&Ie(this._$AH)?this._$AA.nextSibling.data=e:this.T(ce.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:s}=e,r=typeof s=="number"?this._$AC(e):(s.el===void 0&&(s.el=qe.createElement(dn(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===r)this._$AH.p(t);else{const i=new Pi(r,this),a=i.u(this.options);i.p(t),this.T(a),this._$AH=i}}_$AC(e){let t=Es.get(e.strings);return t===void 0&&Es.set(e.strings,t=new qe(e)),t}k(e){Bt(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let s,r=0;for(const i of e)r===t.length?t.push(s=new we(this.O(Oe()),this.O(Oe()),this,this.options)):s=t[r],s._$AI(i),r++;r<t.length&&(this._$AR(s&&s._$AB.nextSibling,r),t.length=r)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const s=ks(e).nextSibling;ks(e).remove(),e=s}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}}class nt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,s,r,i){this.type=1,this._$AH=w,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=w}_$AI(e,t=this,s,r){const i=this.strings;let a=!1;if(i===void 0)e=be(this,e,t,0),a=!Ie(e)||e!==this._$AH&&e!==Z,a&&(this._$AH=e);else{const o=e;let c,l;for(e=i[0],c=0;c<i.length-1;c++)l=be(this,o[s+c],t,c),l===Z&&(l=this._$AH[c]),a||=!Ie(l)||l!==this._$AH[c],l===w?e=w:e!==w&&(e+=(l??"")+i[c+1]),this._$AH[c]=l}a&&!r&&this.j(e)}j(e){e===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Mi extends nt{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===w?void 0:e}}class Ui extends nt{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==w)}}class Li extends nt{constructor(e,t,s,r,i){super(e,t,s,r,i),this.type=5}_$AI(e,t=this){if((e=be(this,e,t,0)??w)===Z)return;const s=this._$AH,r=e===w&&s!==w||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,i=e!==w&&(s===w||r);r&&this.element.removeEventListener(this.name,this,s),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class ji{constructor(e,t,s){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(e){be(this,e)}}const Di={I:we},Hi=zt.litHtmlPolyfillSupport;Hi?.(qe,we),(zt.litHtmlVersions??=[]).push("3.3.3");const zi=(n,e,t)=>{const s=t?.renderBefore??e;let r=s._$litPart$;if(r===void 0){const i=t?.renderBefore??null;s._$litPart$=r=new we(e.insertBefore(Oe(),i),i,void 0,t??{})}return r._$AI(n),r};const Zt=globalThis;let U=class extends ue{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=zi(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Z}};U._$litElement$=!0,U.finalized=!0,Zt.litElementHydrateSupport?.({LitElement:U});const Bi=Zt.litElementPolyfillSupport;Bi?.({LitElement:U});(Zt.litElementVersions??=[]).push("4.2.2");const Ft={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4},Vt=n=>(...e)=>({_$litDirective$:n,values:e});let Wt=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,s){this._$Ct=e,this._$AM=t,this._$Ci=s}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};class Ct extends Wt{constructor(e){if(super(e),this.it=w,e.type!==Ft.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===w||e==null)return this._t=void 0,this.it=e;if(e===Z)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}Ct.directiveName="unsafeHTML",Ct.resultType=1;let Tt=class extends Ct{};Tt.directiveName="unsafeSVG",Tt.resultType=2;const Zi=Vt(Tt);const{I:Fi}=Di,Rs=n=>n,Da=n=>n.strings===void 0,Os=()=>document.createComment(""),$e=(n,e,t)=>{const s=n._$AA.parentNode,r=e===void 0?n._$AB:e._$AA;if(t===void 0){const i=s.insertBefore(Os(),r),a=s.insertBefore(Os(),r);t=new Fi(i,a,n,n.options)}else{const i=t._$AB.nextSibling,a=t._$AM,o=a!==n;if(o){let c;t._$AQ?.(n),t._$AM=n,t._$AP!==void 0&&(c=n._$AU)!==a._$AU&&t._$AP(c)}if(i!==r||o){let c=t._$AA;for(;c!==i;){const l=Rs(c).nextSibling;Rs(s).insertBefore(c,r),c=l}}}return t},re=(n,e,t=n)=>(n._$AI(e,t),n),Vi={},Wi=(n,e=Vi)=>n._$AH=e,Gi=n=>n._$AH,ct=n=>{n._$AR(),n._$AA.remove()};const Is=(n,e,t)=>{const s=new Map;for(let r=e;r<=t;r++)s.set(n[r],r);return s},Ji=Vt(class extends Wt{constructor(n){if(super(n),n.type!==Ft.CHILD)throw Error("repeat() can only be used in text expressions")}dt(n,e,t){let s;t===void 0?t=e:e!==void 0&&(s=e);const r=[],i=[];let a=0;for(const o of n)r[a]=s?s(o,a):a,i[a]=t(o,a),a++;return{values:i,keys:r}}render(n,e,t){return this.dt(n,e,t).values}update(n,[e,t,s]){const r=Gi(n),{values:i,keys:a}=this.dt(e,t,s);if(!Array.isArray(r))return this.ut=a,i;const o=this.ut??=[],c=[];let l,h,d=0,u=r.length-1,p=0,b=i.length-1;for(;d<=u&&p<=b;)if(r[d]===null)d++;else if(r[u]===null)u--;else if(o[d]===a[p])c[p]=re(r[d],i[p]),d++,p++;else if(o[u]===a[b])c[b]=re(r[u],i[b]),u--,b--;else if(o[d]===a[b])c[b]=re(r[d],i[b]),$e(n,c[b+1],r[d]),d++,b--;else if(o[u]===a[p])c[p]=re(r[u],i[p]),$e(n,r[d],r[u]),u--,p++;else if(l===void 0&&(l=Is(a,p,b),h=Is(o,d,u)),l.has(o[d]))if(l.has(o[u])){const C=h.get(a[p]),O=C!==void 0?r[C]:null;if(O===null){const Pe=$e(n,r[d]);re(Pe,i[p]),c[p]=Pe}else c[p]=re(O,i[p]),$e(n,r[d],O),r[C]=null;p++}else ct(r[u]),u--;else ct(r[d]),d++;for(;p<=b;){const C=$e(n,c[b+1]);re(C,i[p]),c[p++]=C}for(;d<=u;){const C=r[d++];C!==null&&ct(C)}return this.ut=a,Wi(n,c),Z}});const hn="important",Ki=" !"+hn,Yi=Vt(class extends Wt{constructor(n){if(super(n),n.type!==Ft.ATTRIBUTE||n.name!=="style"||n.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(n){return Object.keys(n).reduce((e,t)=>{const s=n[t];return s==null?e:e+`${t=t.includes("-")?t:t.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`},"")}update(n,[e]){const{style:t}=n.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(e)),this.render(e);for(const s of this.ft)e[s]==null&&(this.ft.delete(s),s.includes("-")?t.removeProperty(s):t[s]=null);for(const s in e){const r=e[s];if(r!=null){this.ft.add(s);const i=typeof r=="string"&&r.endsWith(Ki);s.includes("-")||i?t.setProperty(s,i?r.slice(0,-11):r,i?hn:""):t[s]=r}}return Z}}),_e=F`
|
|
63
|
+
:host {
|
|
64
|
+
color: var(--q-text);
|
|
65
|
+
font-family: var(--q-font);
|
|
66
|
+
font-variant-numeric: tabular-nums;
|
|
67
|
+
}
|
|
68
|
+
*,
|
|
69
|
+
*::before,
|
|
70
|
+
*::after {
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
}
|
|
73
|
+
h1,
|
|
74
|
+
h2,
|
|
75
|
+
h3 {
|
|
76
|
+
font-family: var(--q-font-display);
|
|
77
|
+
margin: 0;
|
|
78
|
+
font-weight: 600;
|
|
79
|
+
}
|
|
80
|
+
a {
|
|
81
|
+
color: var(--q-accent);
|
|
82
|
+
}
|
|
83
|
+
button,
|
|
84
|
+
select,
|
|
85
|
+
input {
|
|
86
|
+
font: inherit;
|
|
87
|
+
color: var(--q-text);
|
|
88
|
+
background: var(--q-surface);
|
|
89
|
+
border: 1px solid var(--q-border);
|
|
90
|
+
border-radius: calc(var(--q-radius) * 0.75);
|
|
91
|
+
padding: 6px 10px;
|
|
92
|
+
}
|
|
93
|
+
button {
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
}
|
|
96
|
+
button:hover:not(:disabled) {
|
|
97
|
+
background: var(--q-surface-2);
|
|
98
|
+
}
|
|
99
|
+
button:disabled {
|
|
100
|
+
opacity: 0.5;
|
|
101
|
+
cursor: not-allowed;
|
|
102
|
+
}
|
|
103
|
+
button.primary {
|
|
104
|
+
background: var(--q-accent);
|
|
105
|
+
color: var(--q-on-accent);
|
|
106
|
+
border-color: transparent;
|
|
107
|
+
}
|
|
108
|
+
:focus-visible {
|
|
109
|
+
outline: 2px solid var(--q-accent);
|
|
110
|
+
outline-offset: 2px;
|
|
111
|
+
}
|
|
112
|
+
.card {
|
|
113
|
+
background: var(--q-surface);
|
|
114
|
+
border: 1px solid var(--q-border);
|
|
115
|
+
border-radius: var(--q-radius);
|
|
116
|
+
box-shadow: var(--q-shadow);
|
|
117
|
+
padding: 16px;
|
|
118
|
+
}
|
|
119
|
+
.muted {
|
|
120
|
+
color: var(--q-text-muted);
|
|
121
|
+
}
|
|
122
|
+
.mono {
|
|
123
|
+
font-family: var(--q-font-mono);
|
|
124
|
+
}
|
|
125
|
+
.level-good {
|
|
126
|
+
--level: var(--q-good);
|
|
127
|
+
}
|
|
128
|
+
.level-warn {
|
|
129
|
+
--level: var(--q-warn);
|
|
130
|
+
}
|
|
131
|
+
.level-bad {
|
|
132
|
+
--level: var(--q-bad);
|
|
133
|
+
}
|
|
134
|
+
.level-none {
|
|
135
|
+
--level: var(--q-none);
|
|
136
|
+
}
|
|
137
|
+
.visually-hidden {
|
|
138
|
+
position: absolute;
|
|
139
|
+
width: 1px;
|
|
140
|
+
height: 1px;
|
|
141
|
+
overflow: hidden;
|
|
142
|
+
clip: rect(0 0 0 0);
|
|
143
|
+
white-space: nowrap;
|
|
144
|
+
}
|
|
145
|
+
`,Xi={activity:'<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>',"calendar-week":'<rect x="3" y="4" width="18" height="18" rx="2"/><path d="M16 2v4M8 2v4M3 10h18M7 14h10M7 18h6"/>',"calendar-month":'<rect x="3" y="4" width="18" height="18" rx="2"/><path d="M16 2v4M8 2v4M3 10h18M8 14h.01M12 14h.01M16 14h.01M8 18h.01M12 18h.01M16 18h.01"/>',alert:'<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4M12 17h.01"/>',list:'<path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"/>',grid:'<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/>',settings:'<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>',refresh:'<path d="M21 12a9 9 0 1 1-3-6.7L21 8"/><path d="M21 3v5h-5"/>',external:'<path d="M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>',chevronLeft:'<path d="m15 18-6-6 6-6"/>',chevronRight:'<path d="m9 18 6-6-6-6"/>',plus:'<path d="M12 5v14M5 12h14"/>',trash:'<path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>',"arrow-up":'<path d="m18 15-6-6-6 6"/>',"arrow-down":'<path d="m6 9 6 6 6-6"/>',maximize:'<path d="M8 3H5a2 2 0 0 0-2 2v3M21 8V5a2 2 0 0 0-2-2h-3M3 16v3a2 2 0 0 0 2 2h3M16 21h3a2 2 0 0 0 2-2v-3"/>',minimize:'<path d="M8 3v3a2 2 0 0 1-2 2H3M21 8h-3a2 2 0 0 1-2-2V3M3 16h3a2 2 0 0 1 2 2v3M16 21v-3a2 2 0 0 1 2-2h3"/>'};class M extends U{constructor(){super(),this.returnFocus=null,this.onKey=e=>{const t=M.stack[M.stack.length-1];e.key==="Escape"&&this.open&&t===this&&!e.defaultPrevented&&(e.preventDefault(),this.close())},this.open=!1,this.heading="",this.wide=!1}static{this.properties={open:{type:Boolean,reflect:!0},heading:{},wide:{type:Boolean}}}static{this.stack=[]}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this.onKey)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.onKey),M.stack=M.stack.filter(e=>e!==this)}updated(e){e.has("open")&&(M.stack=M.stack.filter(t=>t!==this),this.open&&M.stack.push(this),this.open?(this.returnFocus=document.activeElement,this.renderRoot.querySelector(".close")?.focus()):e.get("open")===!0&&this.returnFocus instanceof HTMLElement&&this.returnFocus.focus())}close(){this.dispatchEvent(new CustomEvent("close"))}render(){return this.open?v`<div class="backdrop" @click=${this.close}></div>
|
|
146
|
+
<aside role="dialog" aria-modal="true" aria-label=${this.heading} class=${this.wide?"wide":""}>
|
|
147
|
+
<header>
|
|
148
|
+
<slot name="header"><h2>${this.heading}</h2></slot>
|
|
149
|
+
<button class="close" @click=${this.close} aria-label="Close">✕</button>
|
|
150
|
+
</header>
|
|
151
|
+
<div class="body"><slot></slot></div>
|
|
152
|
+
</aside>`:w}static{this.styles=[_e,F`
|
|
153
|
+
.backdrop {
|
|
154
|
+
position: fixed;
|
|
155
|
+
inset: 0;
|
|
156
|
+
background: rgb(0 0 0 / 0.45);
|
|
157
|
+
z-index: 30;
|
|
158
|
+
}
|
|
159
|
+
aside {
|
|
160
|
+
position: fixed;
|
|
161
|
+
top: 0;
|
|
162
|
+
right: 0;
|
|
163
|
+
bottom: 0;
|
|
164
|
+
width: min(760px, 100vw);
|
|
165
|
+
background: var(--q-bg);
|
|
166
|
+
border-left: 1px solid var(--q-border);
|
|
167
|
+
box-shadow: var(--q-shadow);
|
|
168
|
+
z-index: 31;
|
|
169
|
+
display: flex;
|
|
170
|
+
flex-direction: column;
|
|
171
|
+
animation: slide 0.18s ease-out;
|
|
172
|
+
}
|
|
173
|
+
aside.wide {
|
|
174
|
+
width: min(1100px, 100vw);
|
|
175
|
+
}
|
|
176
|
+
:host-context([data-reduced-motion]) aside {
|
|
177
|
+
animation: none;
|
|
178
|
+
}
|
|
179
|
+
@keyframes slide {
|
|
180
|
+
from {
|
|
181
|
+
transform: translateX(40px);
|
|
182
|
+
opacity: 0;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
header {
|
|
186
|
+
display: flex;
|
|
187
|
+
align-items: flex-start;
|
|
188
|
+
gap: 12px;
|
|
189
|
+
padding: 14px 16px;
|
|
190
|
+
border-bottom: 1px solid var(--q-border);
|
|
191
|
+
background: var(--q-surface);
|
|
192
|
+
}
|
|
193
|
+
header ::slotted(*),
|
|
194
|
+
header h2 {
|
|
195
|
+
flex: 1;
|
|
196
|
+
min-width: 0;
|
|
197
|
+
}
|
|
198
|
+
h2 {
|
|
199
|
+
font-size: 1.05rem;
|
|
200
|
+
}
|
|
201
|
+
.body {
|
|
202
|
+
overflow: auto;
|
|
203
|
+
padding: 16px;
|
|
204
|
+
flex: 1;
|
|
205
|
+
}
|
|
206
|
+
`]}}class Qi extends M{static{this.styles=[...M.styles,F`
|
|
207
|
+
aside,
|
|
208
|
+
aside.wide {
|
|
209
|
+
top: 4vh;
|
|
210
|
+
bottom: 4vh;
|
|
211
|
+
left: 50%;
|
|
212
|
+
right: auto;
|
|
213
|
+
transform: translateX(-50%);
|
|
214
|
+
width: min(1200px, 94vw);
|
|
215
|
+
border: 1px solid var(--q-border);
|
|
216
|
+
border-radius: var(--q-radius);
|
|
217
|
+
animation: none;
|
|
218
|
+
z-index: 41;
|
|
219
|
+
}
|
|
220
|
+
.backdrop {
|
|
221
|
+
z-index: 40;
|
|
222
|
+
}
|
|
223
|
+
`]}}class ea extends U{static{this.properties={labels:{attribute:!1},series:{attribute:!1},bands:{attribute:!1},min:{type:Number},max:{type:Number},hover:{state:!0}}}constructor(){super(),this.labels=[],this.series=[],this.bands=[],this.min=0,this.max=100,this.hover=null}render(){const s={l:36,r:8,t:8,b:24},r=Math.max(this.labels.length,1),i=u=>s.l+(r===1?(800-s.l-s.r)/2:u*(800-s.l-s.r)/(r-1)),a=u=>s.t+(this.max-u)*(240-s.t-s.b)/(this.max-this.min||1),o=[this.min,(this.min+this.max)/2,this.max],c=Math.ceil(r/10),l=u=>{let p="",b=!1;return u.forEach((C,O)=>{if(C==null)return void(b=!1);p+=`${b?"L":"M"}${i(O).toFixed(1)},${a(Math.min(this.max,Math.max(this.min,C))).toFixed(1)}`,b=!0}),p},h=u=>{const p=u.currentTarget.getBoundingClientRect(),b=(u.clientX-p.left)/p.width*800;this.hover=Math.max(0,Math.min(r-1,Math.round((b-s.l)/(800-s.l-s.r)*(r-1))))},d=this.hover;return v`
|
|
224
|
+
<svg viewBox="0 0 ${800} ${240}" role="img" aria-label="Pass rate trend" @pointermove=${h} @pointerleave=${()=>this.hover=null}>
|
|
225
|
+
${this.bands.map(u=>le`<rect x=${s.l} width=${800-s.l-s.r} y=${a(Math.min(u.to,this.max))}
|
|
226
|
+
height=${Math.max(0,a(Math.max(u.from,this.min))-a(Math.min(u.to,this.max)))} fill=${u.color} opacity="0.08" />`)}
|
|
227
|
+
${o.map(u=>le`<line x1=${s.l} x2=${800-s.r} y1=${a(u)} y2=${a(u)} class="grid" />
|
|
228
|
+
<text x=${s.l-6} y=${a(u)+4} text-anchor="end" class="tick">${u}%</text>`)}
|
|
229
|
+
${this.labels.map((u,p)=>p%c===0?le`<text x=${i(p)} y=${234} text-anchor="middle" class="tick">${u}</text>`:w)}
|
|
230
|
+
${d!=null?le`<line x1=${i(d)} x2=${i(d)} y1=${s.t} y2=${240-s.b} class="cursor" />`:w}
|
|
231
|
+
${this.series.map(u=>le`<path d=${l(u.values)} fill="none" stroke=${u.color} stroke-width="2" stroke-linejoin="round" />
|
|
232
|
+
${u.values.map((p,b)=>p==null?w:le`<circle cx=${i(b)} cy=${a(p)} r=${d===b?4:2.5} fill=${u.color} />`)}`)}
|
|
233
|
+
</svg>
|
|
234
|
+
<div class="legend">
|
|
235
|
+
${this.series.map(u=>v`<span><i style=${Yi({background:u.color})}></i>${u.label}${d!=null&&u.values[d]!=null?v`: <b>${u.values[d].toFixed(1)}%</b>`:w}</span>`)}
|
|
236
|
+
${d!=null?v`<span class="muted">${this.labels[d]}</span>`:w}
|
|
237
|
+
</div>
|
|
238
|
+
`}static{this.styles=[_e,F`
|
|
239
|
+
svg {
|
|
240
|
+
width: 100%;
|
|
241
|
+
height: auto;
|
|
242
|
+
display: block;
|
|
243
|
+
touch-action: none;
|
|
244
|
+
}
|
|
245
|
+
.grid {
|
|
246
|
+
stroke: var(--q-border);
|
|
247
|
+
}
|
|
248
|
+
.cursor {
|
|
249
|
+
stroke: var(--q-text-muted);
|
|
250
|
+
stroke-dasharray: 3 3;
|
|
251
|
+
}
|
|
252
|
+
.tick {
|
|
253
|
+
fill: var(--q-text-muted);
|
|
254
|
+
font-size: 11px;
|
|
255
|
+
}
|
|
256
|
+
.legend {
|
|
257
|
+
display: flex;
|
|
258
|
+
flex-wrap: wrap;
|
|
259
|
+
gap: 4px 14px;
|
|
260
|
+
font-size: 0.85rem;
|
|
261
|
+
margin-top: 6px;
|
|
262
|
+
}
|
|
263
|
+
.legend i {
|
|
264
|
+
display: inline-block;
|
|
265
|
+
width: 10px;
|
|
266
|
+
height: 10px;
|
|
267
|
+
border-radius: 2px;
|
|
268
|
+
margin-right: 5px;
|
|
269
|
+
}
|
|
270
|
+
`]}}const Ha=["#4e79a7","#f28e2b","#59a14f","#e15759","#76b7b2","#edc948","#b07aa1","#ff9da7"].map((n,e)=>`var(--q-series-${e+1}, ${n})`),ta={good:"✓",warn:"!",bad:"✕",none:"–"},sa={good:"Good",warn:"Warning",bad:"Bad",none:"No data"};class na extends U{static{this.properties={name:{}}}static{this.styles=F`
|
|
271
|
+
:host {
|
|
272
|
+
display: inline-flex;
|
|
273
|
+
width: 1.1em;
|
|
274
|
+
height: 1.1em;
|
|
275
|
+
}
|
|
276
|
+
svg {
|
|
277
|
+
width: 100%;
|
|
278
|
+
height: 100%;
|
|
279
|
+
}
|
|
280
|
+
`}render(){const e=Xi[this.name]??"";return v`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
|
281
|
+
stroke-linejoin="round" aria-hidden="true">${Zi(e)}</svg>`}}class ra extends U{static{this.properties={level:{},label:{}}}constructor(){super(),this.level="none",this.label=""}static{this.styles=[_e,F`
|
|
282
|
+
:host {
|
|
283
|
+
display: inline-flex;
|
|
284
|
+
}
|
|
285
|
+
span {
|
|
286
|
+
display: inline-flex;
|
|
287
|
+
align-items: center;
|
|
288
|
+
gap: 4px;
|
|
289
|
+
padding: 2px 8px;
|
|
290
|
+
border-radius: 999px;
|
|
291
|
+
background: var(--level);
|
|
292
|
+
color: var(--q-on-status);
|
|
293
|
+
font-weight: 600;
|
|
294
|
+
font-size: 0.85em;
|
|
295
|
+
white-space: nowrap;
|
|
296
|
+
}
|
|
297
|
+
`]}render(){return v`<span class="level-${this.level}" title=${sa[this.level]}
|
|
298
|
+
><span aria-hidden="true" style="padding:0;background:none">${ta[this.level]}</span>${this.label}</span
|
|
299
|
+
>`}}class ia extends U{static{this.properties={kind:{},message:{},retry:{attribute:!1}}}constructor(){super(),this.kind="loading",this.message=""}static{this.styles=[_e,F`
|
|
300
|
+
:host {
|
|
301
|
+
display: block;
|
|
302
|
+
}
|
|
303
|
+
.box {
|
|
304
|
+
padding: 32px;
|
|
305
|
+
text-align: center;
|
|
306
|
+
}
|
|
307
|
+
.error {
|
|
308
|
+
border-color: var(--q-bad);
|
|
309
|
+
}
|
|
310
|
+
.spinner {
|
|
311
|
+
width: 24px;
|
|
312
|
+
height: 24px;
|
|
313
|
+
margin: 0 auto 12px;
|
|
314
|
+
border: 3px solid var(--q-border);
|
|
315
|
+
border-top-color: var(--q-accent);
|
|
316
|
+
border-radius: 50%;
|
|
317
|
+
animation: spin 0.8s linear infinite;
|
|
318
|
+
}
|
|
319
|
+
:host-context([data-reduced-motion]) .spinner {
|
|
320
|
+
animation: none;
|
|
321
|
+
}
|
|
322
|
+
@keyframes spin {
|
|
323
|
+
to {
|
|
324
|
+
transform: rotate(360deg);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
`]}render(){return v`<div class="box card ${this.kind}" role=${this.kind==="error"?"alert":"status"}>
|
|
328
|
+
${this.kind==="loading"?v`<div class="spinner"></div>`:w}
|
|
329
|
+
<div>${this.message||(this.kind==="loading"?"Loading…":this.kind==="empty"?"Nothing to show":"Something went wrong")}</div>
|
|
330
|
+
${this.retry?v`<p><button @click=${()=>this.retry?.()}>Try again</button></p>`:w}
|
|
331
|
+
</div>`}}function aa(){const n=(e,t)=>customElements.get(e)??customElements.define(e,t);n("q-icon",na),n("q-health",ra),n("q-state",ia),n("q-drawer",M),n("q-modal",Qi),n("q-line-chart",ea)}let ze;function za(){if(ze===void 0)try{const n=document.createElement("canvas");ze=!!(n.getContext("webgl2")??n.getContext("webgl"))}catch{ze=!1}return ze}const lt="chat",qs={running:"Running","needs-approval":"Needs your approval",done:"Done",error:"Failed",cancelled:"Cancelled"};function oa(n){return n.split(/^```[^\n]*\n?/m).map((e,t)=>t%2===1?v`<pre class="code"><code>${e.replace(/\n$/,"")}</code></pre>`:v`<div class="prose">${e}</div>`)}class ca extends U{constructor(){super(),this.offs=[],this.frame=0,this.lastStatus=new Map,this.open=!1,this.selected=null,this.tick=0}static{this.properties={open:{state:!0},selected:{state:!0},tick:{state:!0}}}connectedCallback(){super.connectedCallback(),this.offs.push(this.ai.subscribe(()=>{this.announce(),cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>this.tick++)}),this.ai.onShowJob(e=>{this.selected=e,this.open=!0}))}announce(){for(const e of this.ai.jobs()){const t=e.info.status,s=this.lastStatus.get(e.id);if(s===t||(this.lastStatus.set(e.id,t),!s))continue;const r=(i,a="info")=>this.dispatchEvent(new CustomEvent("notify",{detail:{message:i,kind:a}}));t==="done"?r(`AI finished: ${e.title}. Saved as a draft.`):t==="error"?r(`AI job failed: ${e.error??e.title}`,"error"):t==="needs-approval"&&!this.open&&r(`AI is waiting for your approval: ${e.title}`)}}disconnectedCallback(){super.disconnectedCallback();for(const e of this.offs)e();cancelAnimationFrame(this.frame)}updated(){const e=this.renderRoot.querySelector(".log");e&&e.dataset.follow!=="false"&&(e.scrollTop=e.scrollHeight)}connect(){this.ai.connect().catch(()=>{})}resultLink(e){return e.testId?z("tests",{run:e.runId,test:e.testId}):z("issues",{run:e.runId})}async publish(e){if(e.result)try{await this.ai.publish(e.result)}catch(t){this.dispatchEvent(new CustomEvent("notify",{detail:{message:t instanceof Error?t.message:String(t),kind:"error"}}))}}entry(e,t,s=!1){switch(e.kind){case"user":return s?v`<div class="you">${e.text}</div>`:v`<details class="prompt"><summary>Prompt sent (${Math.round(e.text.length/1024)} KB)</summary><pre class="code">${e.text}</pre></details>`;case"text":return v`<div class="agent">${oa(e.text)}</div>`;case"reasoning":return v`<details class="reasoning"><summary>Reasoning</summary><div class="prose">${e.text}</div></details>`;case"status":return v`<div class="status ${e.error?"error":""}" role=${e.error?"alert":w}>${e.text}</div>`;case"tool":{const r=e.status==="asking"?"needs your approval":`${e.auto&&e.status!=="preparing"?"auto-approved by host · ":""}${e.status}`;return v`<div class="tool ${e.status}">
|
|
332
|
+
<div class="tool-head"><b>${e.name}</b><span class="badge">${r}</span></div>
|
|
333
|
+
${e.message?v`<div>${e.message}</div>`:w}
|
|
334
|
+
${e.input?v`<pre class="code">${e.input}</pre>`:w}
|
|
335
|
+
${e.status==="asking"?v`<div class="tool-actions">
|
|
336
|
+
${e.options.map((i,a)=>v`<button class=${i.kind==="deny"?"":"primary"} ?autofocus=${a===0}
|
|
337
|
+
@click=${()=>t(e.turnId,e.id,i.kind!=="deny",i.id)}>${i.label}</button>`)}
|
|
338
|
+
</div>`:w}
|
|
339
|
+
${e.result?v`<div class="muted">${e.result}</div>`:w}
|
|
340
|
+
</div>`}}}jobView(e){const t=e.info,s=this.ai.publishTarget();return v`<div class="job">
|
|
341
|
+
<div class="job-head">
|
|
342
|
+
<button class="back" @click=${()=>this.selected=null} aria-label="Back to jobs">←</button>
|
|
343
|
+
<div class="job-title"><b>${e.title}</b><span class="pill ${t.status}">${qs[t.status]}</span></div>
|
|
344
|
+
${e.status==="running"?v`<button @click=${()=>e.cancel()}>Stop</button>`:w}
|
|
345
|
+
</div>
|
|
346
|
+
${this.log(e.transcript.entries.map(r=>this.entry(r,(...i)=>e.confirm(...i))))}
|
|
347
|
+
${e.result?v`<div class="result">
|
|
348
|
+
<span>${e.result.draft?"Draft saved in this browser.":"Published."}</span>
|
|
349
|
+
<a href=${this.resultLink(e)} @click=${()=>this.open=!1}>Open result</a>
|
|
350
|
+
${e.result.draft?v`<button class="primary" ?disabled=${!s.ok} title=${s.ok?`Publish to ${s.label}`:s.reason??""}
|
|
351
|
+
@click=${()=>this.publish(e)}>Publish</button>`:w}
|
|
352
|
+
</div>
|
|
353
|
+
${e.result.draft&&!s.ok?v`<p class="muted small">${s.reason}</p>`:w}`:w}
|
|
354
|
+
</div>`}log(e){return v`<div class="log" @scroll=${t=>{const s=t.target;s.dataset.follow=String(s.scrollHeight-s.scrollTop-s.clientHeight<40)}}>${e}</div>`}send(e){const t=e.elements.namedItem("message"),s=t.value;!s.trim()||this.ai.chat.busy||(t.value="",this.ai.chat.send(s))}chatView(){const e=this.ai.chat,t=e.transcript.entries;return v`<div class="job">
|
|
355
|
+
<div class="job-head">
|
|
356
|
+
<button class="back" @click=${()=>this.selected=null} aria-label="Back to jobs">←</button>
|
|
357
|
+
<div class="job-title"><b>Chat</b><span class="muted small">Works in ${this.settings().connections.workingDirectory||"your local test repo"}</span></div>
|
|
358
|
+
${e.busy?v`<button @click=${()=>e.stop()}>Stop</button>`:w}
|
|
359
|
+
<button ?disabled=${!t.length} @click=${()=>e.reset()} title="Start a fresh agent session">New chat</button>
|
|
360
|
+
</div>
|
|
361
|
+
${this.log(t.length?t.map(s=>this.entry(s,(...r)=>e.confirm(...r),!0)):v`<p class="muted small">Ask the agent anything. It can read the test repo and run tools; tools that change things ask for your approval here.</p>`)}
|
|
362
|
+
<form class="composer" @submit=${s=>{s.preventDefault(),this.send(s.target)}}>
|
|
363
|
+
<textarea name="message" rows="3" placeholder="Message the agent… (Enter to send, Shift+Enter for a new line)" aria-label="Message"
|
|
364
|
+
@keydown=${s=>{s.key!=="Enter"||s.shiftKey||s.isComposing||(s.preventDefault(),this.send(s.target.form))}}></textarea>
|
|
365
|
+
<button class="primary" type="submit" ?disabled=${e.busy}>${e.busy?"Working…":"Send"}</button>
|
|
366
|
+
</form>
|
|
367
|
+
</div>`}list(){const e=this.ai.state(),t=this.ai.jobs(),s=this.settings();return v`
|
|
368
|
+
<section class="conn">
|
|
369
|
+
<div><span class="dot ${e.status}"></span> <b>${e.status==="ready"?e.agent??"Connected":e.status}</b></div>
|
|
370
|
+
<p class="muted small">${e.message}</p>
|
|
371
|
+
<p class="muted small">Host <code>${s.connections.agentHostUrl.replace(/\?.*$/,"")}</code> · repo
|
|
372
|
+
<code>${s.connections.workingDirectory||"not set"}</code></p>
|
|
373
|
+
<div class="row">
|
|
374
|
+
${e.status==="ready"?v`<button @click=${()=>this.ai.disconnect()}>Disconnect</button>`:v`<button class="primary" ?disabled=${e.status==="connecting"} @click=${this.connect}>Connect</button>`}
|
|
375
|
+
<a href=${z("settings",{section:"connections"})} @click=${()=>this.open=!1}>AI settings</a>
|
|
376
|
+
</div>
|
|
377
|
+
${e.status==="error"||e.status==="disconnected"?v`<details class="help"><summary>How to connect</summary>
|
|
378
|
+
<ol>
|
|
379
|
+
<li>Start the agent host: <code>code agent host --connection-token "$(openssl rand -hex 16)"</code></li>
|
|
380
|
+
<li>Paste the printed <code>Local: ws://…?tkn=…</code> URL into Settings → Connections → AI agent host URL,
|
|
381
|
+
or the URL there and the token in Settings → Tokens.</li>
|
|
382
|
+
<li>Set "Local test repo path" to your checkout of the tests.</li>
|
|
383
|
+
<li>Sign the host in: store <code>gh auth token</code> in Settings → Tokens, or connect VS Code's Agents window to it.</li>
|
|
384
|
+
<li>Chrome may ask to allow access to devices on your local network: allow it.</li>
|
|
385
|
+
</ol>
|
|
386
|
+
<p class="small">The connection token is a remote-control key for an agent that can run tools on your machine.
|
|
387
|
+
The host still approves reads/writes inside the working directory and safe shell commands by itself, so use a
|
|
388
|
+
dedicated checkout.</p>
|
|
389
|
+
</details>`:w}
|
|
390
|
+
</section>
|
|
391
|
+
<section>
|
|
392
|
+
<h3>Chat</h3>
|
|
393
|
+
<button class="chat-open" @click=${()=>this.selected=lt}>
|
|
394
|
+
💬 ${this.ai.chat.transcript.entries.length?"Continue the chat":"Chat with the agent"}
|
|
395
|
+
${this.ai.chat.busy?v`<span class="pill running">Running</span>`:w}
|
|
396
|
+
</button>
|
|
397
|
+
</section>
|
|
398
|
+
<section>
|
|
399
|
+
<h3>Jobs</h3>
|
|
400
|
+
${t.length?v`<ul class="jobs">
|
|
401
|
+
${t.map(r=>{const i=r.info;return v`<li><button @click=${()=>this.selected=r.id}>
|
|
402
|
+
<span class="pill ${i.status}">${qs[i.status]}</span>
|
|
403
|
+
<span class="job-name">${r.title}</span>
|
|
404
|
+
<span class="muted small">${tn(r.createdAt,s)}</span>
|
|
405
|
+
</button></li>`})}
|
|
406
|
+
</ul>`:v`<p class="muted small">No jobs yet. Use "Analyze with AI" on a failed test, or "Analyze all failures" on a run's Issues page.</p>`}
|
|
407
|
+
</section>`}render(){const e=this.ai.state(),t=this.ai.jobs(),s=t.filter(a=>a.info.status==="needs-approval").length,r=t.filter(a=>a.status==="running").length,i=this.selected&&this.selected!==lt?this.ai.job(this.selected):void 0;return v`
|
|
408
|
+
<button class="fab ${s?"attention":""}" @click=${()=>this.open=!this.open} aria-expanded=${this.open}
|
|
409
|
+
aria-label="AI panel${s?`, ${s} waiting for approval`:""}">
|
|
410
|
+
<span class="dot ${e.status}"></span> ✨ AI ${r?v`<span class="count">${r}</span>`:w}
|
|
411
|
+
</button>
|
|
412
|
+
${this.open?v`<aside class="panel" aria-label="AI panel">
|
|
413
|
+
<header><h2>AI assistant</h2><button @click=${()=>this.open=!1} aria-label="Close">✕</button></header>
|
|
414
|
+
<div class="body">${this.selected===lt?this.chatView():i?this.jobView(i):this.list()}</div>
|
|
415
|
+
</aside>`:w}
|
|
416
|
+
`}static{this.styles=[_e,F`
|
|
417
|
+
.fab {
|
|
418
|
+
position: fixed;
|
|
419
|
+
right: 16px;
|
|
420
|
+
bottom: 16px;
|
|
421
|
+
/* Above drawers (31), below modals (40). */
|
|
422
|
+
z-index: 35;
|
|
423
|
+
display: flex;
|
|
424
|
+
align-items: center;
|
|
425
|
+
gap: 6px;
|
|
426
|
+
border-radius: 999px;
|
|
427
|
+
padding: 8px 14px;
|
|
428
|
+
box-shadow: var(--q-shadow);
|
|
429
|
+
background: var(--q-surface);
|
|
430
|
+
}
|
|
431
|
+
.fab.attention {
|
|
432
|
+
border-color: var(--q-warn);
|
|
433
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--q-warn) 40%, transparent);
|
|
434
|
+
}
|
|
435
|
+
.count {
|
|
436
|
+
background: var(--q-accent);
|
|
437
|
+
color: var(--q-on-accent);
|
|
438
|
+
border-radius: 999px;
|
|
439
|
+
padding: 0 6px;
|
|
440
|
+
font-size: 0.75rem;
|
|
441
|
+
}
|
|
442
|
+
.dot {
|
|
443
|
+
display: inline-block;
|
|
444
|
+
width: 9px;
|
|
445
|
+
height: 9px;
|
|
446
|
+
border-radius: 50%;
|
|
447
|
+
background: var(--q-none);
|
|
448
|
+
}
|
|
449
|
+
.dot.ready {
|
|
450
|
+
background: var(--q-good);
|
|
451
|
+
}
|
|
452
|
+
.dot.connecting {
|
|
453
|
+
background: var(--q-warn);
|
|
454
|
+
}
|
|
455
|
+
.dot.error {
|
|
456
|
+
background: var(--q-bad);
|
|
457
|
+
}
|
|
458
|
+
.panel {
|
|
459
|
+
position: fixed;
|
|
460
|
+
right: 16px;
|
|
461
|
+
bottom: 64px;
|
|
462
|
+
top: 70px;
|
|
463
|
+
width: min(480px, calc(100vw - 32px));
|
|
464
|
+
z-index: 36;
|
|
465
|
+
background: var(--q-bg);
|
|
466
|
+
border: 1px solid var(--q-border);
|
|
467
|
+
border-radius: var(--q-radius);
|
|
468
|
+
box-shadow: var(--q-shadow);
|
|
469
|
+
display: flex;
|
|
470
|
+
flex-direction: column;
|
|
471
|
+
}
|
|
472
|
+
.panel header {
|
|
473
|
+
display: flex;
|
|
474
|
+
justify-content: space-between;
|
|
475
|
+
align-items: center;
|
|
476
|
+
padding: 10px 14px;
|
|
477
|
+
border-bottom: 1px solid var(--q-border);
|
|
478
|
+
}
|
|
479
|
+
h2 {
|
|
480
|
+
font-size: 1rem;
|
|
481
|
+
}
|
|
482
|
+
h3 {
|
|
483
|
+
font-size: 0.9rem;
|
|
484
|
+
margin: 12px 0 6px;
|
|
485
|
+
}
|
|
486
|
+
.body {
|
|
487
|
+
flex: 1;
|
|
488
|
+
overflow: auto;
|
|
489
|
+
padding: 12px 14px;
|
|
490
|
+
display: flex;
|
|
491
|
+
flex-direction: column;
|
|
492
|
+
}
|
|
493
|
+
.small {
|
|
494
|
+
font-size: 0.82rem;
|
|
495
|
+
}
|
|
496
|
+
.row {
|
|
497
|
+
display: flex;
|
|
498
|
+
gap: 10px;
|
|
499
|
+
align-items: center;
|
|
500
|
+
}
|
|
501
|
+
.help ol {
|
|
502
|
+
padding-left: 18px;
|
|
503
|
+
font-size: 0.85rem;
|
|
504
|
+
}
|
|
505
|
+
.jobs {
|
|
506
|
+
list-style: none;
|
|
507
|
+
margin: 0;
|
|
508
|
+
padding: 0;
|
|
509
|
+
}
|
|
510
|
+
.jobs button {
|
|
511
|
+
width: 100%;
|
|
512
|
+
display: grid;
|
|
513
|
+
grid-template-columns: auto 1fr auto;
|
|
514
|
+
gap: 8px;
|
|
515
|
+
align-items: center;
|
|
516
|
+
text-align: left;
|
|
517
|
+
margin-bottom: 6px;
|
|
518
|
+
}
|
|
519
|
+
.job-name {
|
|
520
|
+
overflow: hidden;
|
|
521
|
+
text-overflow: ellipsis;
|
|
522
|
+
white-space: nowrap;
|
|
523
|
+
}
|
|
524
|
+
.pill {
|
|
525
|
+
font-size: 0.72rem;
|
|
526
|
+
border-radius: 999px;
|
|
527
|
+
padding: 1px 8px;
|
|
528
|
+
border: 1px solid var(--q-border);
|
|
529
|
+
white-space: nowrap;
|
|
530
|
+
}
|
|
531
|
+
.pill.running {
|
|
532
|
+
color: var(--q-running);
|
|
533
|
+
border-color: var(--q-running);
|
|
534
|
+
}
|
|
535
|
+
.pill.needs-approval {
|
|
536
|
+
color: var(--q-warn);
|
|
537
|
+
border-color: var(--q-warn);
|
|
538
|
+
}
|
|
539
|
+
.pill.done {
|
|
540
|
+
color: var(--q-good);
|
|
541
|
+
border-color: var(--q-good);
|
|
542
|
+
}
|
|
543
|
+
.pill.error {
|
|
544
|
+
color: var(--q-bad);
|
|
545
|
+
border-color: var(--q-bad);
|
|
546
|
+
}
|
|
547
|
+
.job {
|
|
548
|
+
display: flex;
|
|
549
|
+
flex-direction: column;
|
|
550
|
+
gap: 8px;
|
|
551
|
+
min-height: 0;
|
|
552
|
+
flex: 1;
|
|
553
|
+
}
|
|
554
|
+
.job-head {
|
|
555
|
+
display: flex;
|
|
556
|
+
gap: 8px;
|
|
557
|
+
align-items: center;
|
|
558
|
+
}
|
|
559
|
+
.job-title {
|
|
560
|
+
flex: 1;
|
|
561
|
+
min-width: 0;
|
|
562
|
+
display: flex;
|
|
563
|
+
flex-direction: column;
|
|
564
|
+
gap: 2px;
|
|
565
|
+
align-items: flex-start;
|
|
566
|
+
}
|
|
567
|
+
.log {
|
|
568
|
+
flex: 1;
|
|
569
|
+
overflow: auto;
|
|
570
|
+
display: flex;
|
|
571
|
+
flex-direction: column;
|
|
572
|
+
gap: 8px;
|
|
573
|
+
border-top: 1px solid var(--q-border);
|
|
574
|
+
padding-top: 8px;
|
|
575
|
+
min-height: 160px;
|
|
576
|
+
}
|
|
577
|
+
.prose {
|
|
578
|
+
white-space: pre-wrap;
|
|
579
|
+
overflow-wrap: anywhere;
|
|
580
|
+
}
|
|
581
|
+
pre.code {
|
|
582
|
+
white-space: pre-wrap;
|
|
583
|
+
word-break: break-word;
|
|
584
|
+
background: var(--q-surface-2);
|
|
585
|
+
border-radius: 6px;
|
|
586
|
+
padding: 8px;
|
|
587
|
+
font-family: var(--q-font-mono);
|
|
588
|
+
font-size: 0.78rem;
|
|
589
|
+
max-height: 320px;
|
|
590
|
+
overflow: auto;
|
|
591
|
+
}
|
|
592
|
+
.status {
|
|
593
|
+
font-size: 0.85rem;
|
|
594
|
+
color: var(--q-text-muted);
|
|
595
|
+
}
|
|
596
|
+
.status.error {
|
|
597
|
+
color: var(--q-bad);
|
|
598
|
+
}
|
|
599
|
+
.tool {
|
|
600
|
+
border: 1px solid var(--q-border);
|
|
601
|
+
border-radius: 6px;
|
|
602
|
+
padding: 8px;
|
|
603
|
+
font-size: 0.85rem;
|
|
604
|
+
}
|
|
605
|
+
.tool.asking {
|
|
606
|
+
border-color: var(--q-warn);
|
|
607
|
+
}
|
|
608
|
+
.tool-head {
|
|
609
|
+
display: flex;
|
|
610
|
+
justify-content: space-between;
|
|
611
|
+
gap: 8px;
|
|
612
|
+
}
|
|
613
|
+
.badge {
|
|
614
|
+
font-size: 0.75rem;
|
|
615
|
+
color: var(--q-text-muted);
|
|
616
|
+
}
|
|
617
|
+
.tool-actions {
|
|
618
|
+
display: flex;
|
|
619
|
+
gap: 8px;
|
|
620
|
+
margin-top: 6px;
|
|
621
|
+
}
|
|
622
|
+
.you {
|
|
623
|
+
align-self: flex-end;
|
|
624
|
+
max-width: 85%;
|
|
625
|
+
white-space: pre-wrap;
|
|
626
|
+
overflow-wrap: anywhere;
|
|
627
|
+
background: color-mix(in srgb, var(--q-accent) 14%, var(--q-surface));
|
|
628
|
+
border: 1px solid var(--q-border);
|
|
629
|
+
border-radius: 10px;
|
|
630
|
+
padding: 6px 10px;
|
|
631
|
+
}
|
|
632
|
+
.chat-open {
|
|
633
|
+
width: 100%;
|
|
634
|
+
display: flex;
|
|
635
|
+
gap: 8px;
|
|
636
|
+
align-items: center;
|
|
637
|
+
text-align: left;
|
|
638
|
+
}
|
|
639
|
+
.composer {
|
|
640
|
+
display: flex;
|
|
641
|
+
gap: 8px;
|
|
642
|
+
align-items: flex-end;
|
|
643
|
+
border-top: 1px solid var(--q-border);
|
|
644
|
+
padding-top: 8px;
|
|
645
|
+
}
|
|
646
|
+
.composer textarea {
|
|
647
|
+
flex: 1;
|
|
648
|
+
resize: vertical;
|
|
649
|
+
min-height: 3.2em;
|
|
650
|
+
font: inherit;
|
|
651
|
+
color: inherit;
|
|
652
|
+
background: var(--q-surface);
|
|
653
|
+
border: 1px solid var(--q-border);
|
|
654
|
+
border-radius: 6px;
|
|
655
|
+
padding: 6px 8px;
|
|
656
|
+
}
|
|
657
|
+
.result {
|
|
658
|
+
display: flex;
|
|
659
|
+
gap: 10px;
|
|
660
|
+
align-items: center;
|
|
661
|
+
flex-wrap: wrap;
|
|
662
|
+
border-top: 1px solid var(--q-border);
|
|
663
|
+
padding-top: 8px;
|
|
664
|
+
}
|
|
665
|
+
.result span {
|
|
666
|
+
flex: 1;
|
|
667
|
+
}
|
|
668
|
+
`]}}class la{constructor(e,t,s){this.handle=null,this.mounted=null,this.abort=null,this.seq=0,this.modules=new Map,this.fallbackNoted=new Set,this.themes=t,this.onState=s,this.container=document.createElement("div"),this.container.className="page-view",this.overlay=document.createElement("div"),this.overlay.className="page-overlay",e.append(this.overlay,this.container)}module(e){let t=this.modules.get(e.id);return t||(t=e.load().then(s=>s.default),t.catch(()=>this.modules.delete(e.id)),this.modules.set(e.id,t)),t}async show(e,t,s,r=!1){const i=++this.seq;this.abort?.abort();const a=this.abort=new AbortController,o=this.mounted?.pageId===e.id;r||this.setOverlay("loading",o?"Updating…":`Loading ${e.title}…`);let c=null;try{if(c=await this.module(e),i!==this.seq)return;this.onState({page:c,view:this.mounted?.view??null,status:"loading"});let l=this.themes.resolveView(c,s.settings),[h,d]=await Promise.all([c.load(s,t,a.signal),l.load()]);if(i!==this.seq||a.signal.aborted)return;const u=d.isSupported?.(s)??!0;if(u!==!0&&l.name!=="classic"){const p=`${c.id}/${l.name}`;if(this.fallbackNoted.has(p)||(this.fallbackNoted.add(p),s.notify(`Showing the classic ${c.title} view: ${u}`)),l={name:"classic",load:c.views.classic},d=await l.load(),i!==this.seq||a.signal.aborted)return}this.handle&&this.mounted?.pageId===c.id&&this.mounted.view===l.name?this.handle.update(h,s):(this.unmount(),this.handle=d.mount(this.container,h,s),this.mounted={pageId:c.id,view:l.name}),this.setOverlay(null),this.onState({page:c,view:l.name,status:"ready"})}catch(l){if(i!==this.seq||a.signal.aborted)return;console.error(`[qaily] page "${e.id}" failed`,l);const h=l instanceof Error?l.message:String(l);if(r&&this.handle){s.notify(`Refresh failed: ${h}`,"error");return}this.unmount(),this.setOverlay("error",`${e.title} could not be shown: ${h}`,()=>this.show(e,t,s)),this.onState({page:c,view:null,status:"error"})}}showMissing(e){this.seq++,this.abort?.abort(),this.unmount(),this.setOverlay("empty",`There is no page called "${e}".`),this.onState({page:null,view:null,status:"error"})}unmount(){try{this.handle?.destroy()}catch(e){console.error("[qaily] view destroy failed",e)}this.handle=null,this.mounted=null,this.container.replaceChildren()}setOverlay(e,t="",s){if(this.overlay.replaceChildren(),this.container.toggleAttribute("data-busy",e==="loading"&&this.handle!==null),!e||e==="loading"&&this.handle)return;const r=document.createElement("q-state");r.kind=e,r.message=t,r.retry=s,this.overlay.append(r)}}const dt=[{id:"monitoring",title:"Monitoring",icon:"activity",load:()=>P(()=>import("./index-CEMZIb_j.js"),__vite__mapDeps([0,1,2]),import.meta.url)},{id:"weekly",title:"Weekly",icon:"calendar-week",load:()=>P(()=>import("./index-BSeSdMcj.js"),__vite__mapDeps([3,1,2,4]),import.meta.url)},{id:"monthly",title:"Monthly",icon:"calendar-month",load:()=>P(()=>import("./index-Bx_mFI-E.js").then(n=>n.i),__vite__mapDeps([5,1,2,4]),import.meta.url)},{id:"issues",title:"Issues",icon:"alert",load:()=>P(()=>import("./index-DIUMnB6u.js"),__vite__mapDeps([6,2]),import.meta.url)},{id:"tests",title:"Tests",icon:"list",load:()=>P(()=>import("./index-CjIdaEbY.js"),__vite__mapDeps([7,2]),import.meta.url)},{id:"heatmap",title:"Heat Map",icon:"grid",load:()=>P(()=>import("./index-DKORV85a.js").then(n=>n.i),__vite__mapDeps([8,9]),import.meta.url)},{id:"settings",title:"Settings",icon:"settings",load:()=>P(()=>import("./index-Bo6ugK3I.js"),[],import.meta.url)}];function Ns(n){const e=Ye.map(t=>t.slice(15));return Object.fromEntries(e.map(t=>[t,n[t]]))}function da(n,e){const t=a=>e[a]==="personal";if(!Ye.some(t))return null;const r=(n.dataSource==="bucket"&&(t("connections.s3.dataPrefix")||!t("connections.s3.prefix"))?n.dataPrefix:n.prefix).replace(/^\/+|\/+$/g,"");return["bucket","region","endpoint","pathStyle"].some(a=>t(`connections.s3.${a}`))?r?`${n.bucket}/${r}`:n.bucket:r||"(bucket root)"}const ha=[1,7,14,30,90];class ua extends U{constructor(){super(),this.pageHost=null,this.cleanups=[],this.toastSeq=0,this.host={page:null,view:null,status:"idle"},this.catalog=null,this.toasts=[],this.dataAccess=null}static{this.properties={route:{state:!0},host:{state:!0},theme:{state:!0},catalog:{state:!0},toasts:{state:!0},dataAccess:{state:!0}}}connectedCallback(){super.connectedCallback();const{router:e,settings:t,themes:s}=this.services;this.route=e.current,this.theme=s.apply(t.settings),this.cleanups.push(e.subscribe(r=>{const i=(r.page||this.settingsNow.display.defaultPage)!==this.pageId;this.route=r,i&&window.scrollTo(0,0),this.showRoute()}),t.subscribe(r=>this.onSettings(r)),s.onSystemChange(()=>this.onSettings(t.resolved)),this.services.artifacts.subscribe(async()=>{const{data:r,artifacts:i}=this.services;r.readsFromBucket&&(i.keepsCredentialsOnDevice()||Xe(),await this.loadCatalog(!0)),this.showRoute(!0)})),this.loadCatalog()}disconnectedCallback(){super.disconnectedCallback();for(const e of this.cleanups)e();window.clearInterval(this.refreshTimer)}firstUpdated(){const e=this.renderRoot.querySelector("#page-root");this.pageHost=new la(e,this.services.themes,t=>this.host=t),this.showRoute(),this.scheduleRefresh()}get settingsNow(){return this.services.settings.settings}get pageId(){return this.route.page||this.settingsNow.display.defaultPage}get filters(){return mi(this.route.params,this.settingsNow)}get pageParams(){const e={...this.route.params};for(const t of fi)delete e[t];return e}onSettings(e){this.theme=this.services.themes.apply(e.settings),this.scheduleRefresh(),this.showRoute(!0)}async loadCatalog(e=!1){try{const t=this.catalog?.generatedAt;return this.catalog=await this.services.data.catalog({refresh:e}),t!==void 0&&t!==this.catalog.generatedAt}catch(t){return!e&&!(t instanceof he)&&this.notify(`No report data found: ${t instanceof Error?t.message:t}`,"error"),!1}finally{this.dataAccess=this.services.data.accessProblem?.message??null}}scheduleRefresh(){window.clearInterval(this.refreshTimer);const e=this.settingsNow.display.refreshSeconds;e<=0||(this.refreshTimer=window.setInterval(async()=>{document.hidden||await this.loadCatalog(!0)&&this.showRoute(!0)},e*1e3))}registry(){return{pages:dt.map(e=>({id:e.id,title:e.title,views:this.viewNames(e)})),themes:this.services.themes.themes.map(e=>({id:e.id,label:e.label,views:Object.fromEntries(Object.entries(e.views??{}).map(([t,s])=>[t,Object.keys(s)]))}))}}viewNames(e){const t=this.services.themes.themes.flatMap(s=>Object.keys(s.views?.[e.id]??{}));return["classic",...new Set(t.filter(s=>s!=="classic"))]}context(){const{data:e,settings:t,secrets:s,notes:r,artifacts:i,ai:a,router:o}=this.services,c=t.settings,l=this.filters,h=at(l,c);return{data:e,settings:c,settingsApi:t,secrets:s,notes:r,artifacts:i,ai:a,filters:l,theme:this.theme,registry:this.registry(),now:()=>new Date,health:(d,u)=>_n(c.thresholds[d],u),notify:(d,u)=>this.notify(d,u),nav:{href:(d,u={})=>z(d,{...h,...u}),go:(d,u={})=>o.go(d,{...h,...u}),replaceParams:d=>o.replace(this.pageId,{...h,...d})}}}showRoute(e=!1){if(!this.pageHost)return;const t=dt.find(s=>s.id===this.pageId);if(!t)return this.pageHost.showMissing(this.pageId);document.title=`${t.title} · Qaily`,this.pageHost.show(t,this.pageParams,this.context(),e)}setFilters(e){const t=this.settingsNow,s={...this.filters,...e};this.services.router.go(this.pageId,{...this.pageParams,...at(s,t)})}notify(e,t="info"){const s=++this.toastSeq;this.toasts=[...this.toasts,{id:s,message:e,kind:t}],window.setTimeout(()=>this.toasts=this.toasts.filter(r=>r.id!==s),t==="error"?8e3:4e3)}toggleScheme(){const e=this.theme.colorScheme==="dark"?"light":"dark";this.services.settings.setPersonal("display.colorScheme",e)}personalLocation(){return this.services.location.personal}locationChanged(){const e=this.settingsNow.connections.s3;return Ye.some(t=>{const s=t.split(".").pop();return e[s]!==this.services.location[s]})}async reloadForLocation(e){e&&this.services.settings.setPersonalMany(Object.fromEntries(Ye.map(t=>[t,void 0]))),await Xe(),window.location.reload()}modeNote(){const e=this.services.artifacts.status().mode,[t,s]=e==="local"?["Local server","Opened through qaily-report serve: report data from the local folder, attachments from local files first, then S3."]:this.services.data.readsFromBucket?["Bucket data","Bucket data source: dashboards, run data and attachments are all read from S3 with signed links. The site holds only the app and settings.json."]:e==="browser"?["Website data · S3 files","Website data source: dashboard and run data are published with this site; screenshots, traces and other attachments are read from S3."]:["Website data","Everything, attachments included, is published with this site. No bucket is configured."],r=this.personalLocation();return r?v`<span class="muted mode mine" title=${`${s} You are looking at your own location: ${r}. Reset it in the bar below the header.`}>${t} · ${r}</span>`:v`<span class="muted mode" title=${s}>${t}</span>`}render(){const e=new Set(this.host.page?.filters??[]),t=this.filters,s=at(t,this.settingsNow),r=this.services.themes.theme(this.settingsNow.display.theme).forcedColorScheme;return v`
|
|
669
|
+
<header>
|
|
670
|
+
<a class="brand" href=${z(this.settingsNow.display.defaultPage,s)}>Qaily</a>
|
|
671
|
+
<nav aria-label="Pages">
|
|
672
|
+
${dt.map(i=>v`<a href=${z(i.id,s)} aria-current=${i.id===this.pageId?"page":w}
|
|
673
|
+
><q-icon name=${i.icon}></q-icon><span>${i.title}</span></a
|
|
674
|
+
>`)}
|
|
675
|
+
</nav>
|
|
676
|
+
<div class="tools">
|
|
677
|
+
${this.modeNote()}
|
|
678
|
+
${this.catalog?.latestRunAt?v`<span class="muted fresh" title="Newest run in the data">Latest run ${yi(this.catalog.latestRunAt,new Date)}</span>`:w}
|
|
679
|
+
<button
|
|
680
|
+
class="icon"
|
|
681
|
+
title=${r?`This theme is ${r} only`:`Switch to ${this.theme.colorScheme==="dark"?"light":"dark"} mode`}
|
|
682
|
+
?disabled=${!!r}
|
|
683
|
+
@click=${this.toggleScheme}
|
|
684
|
+
>
|
|
685
|
+
${this.theme.colorScheme==="dark"?"☾":"☀"}
|
|
686
|
+
</button>
|
|
687
|
+
</div>
|
|
688
|
+
</header>
|
|
689
|
+
${e.size?v`<div class="filters" role="toolbar" aria-label="Filters">
|
|
690
|
+
${e.has("rangeDays")?v`<label
|
|
691
|
+
>Range
|
|
692
|
+
<select @change=${i=>this.setFilters({rangeDays:Number(i.target.value)})}>
|
|
693
|
+
${[...new Set([...ha,t.rangeDays])].sort((i,a)=>i-a).map(i=>v`<option value=${i} ?selected=${i===t.rangeDays}>${i===1?"24 hours":`${i} days`}</option>`)}
|
|
694
|
+
</select></label
|
|
695
|
+
>`:w}
|
|
696
|
+
${e.has("branch")?v`<label
|
|
697
|
+
>Branch
|
|
698
|
+
<select @change=${i=>this.setFilters({branch:i.target.value})}>
|
|
699
|
+
<option value="main" ?selected=${t.branch==="main"}>${this.settingsNow.data.mainBranches.join(", ")}</option>
|
|
700
|
+
<option value="all" ?selected=${t.branch==="all"}>All branches</option>
|
|
701
|
+
</select></label
|
|
702
|
+
>`:w}
|
|
703
|
+
</div>`:w}
|
|
704
|
+
${this.locationChanged()?v`<div class="access" role="status">
|
|
705
|
+
<span>The data location changed. Reload to see the data from there.</span>
|
|
706
|
+
<button @click=${()=>this.reloadForLocation(!1)}>Reload</button>
|
|
707
|
+
</div>`:this.personalLocation()?v`<div class="access mine" role="status">
|
|
708
|
+
<span>You are looking at <b>${this.personalLocation()}</b>, your own setting, not this report's usual data.</span>
|
|
709
|
+
<button @click=${()=>this.reloadForLocation(!0)}>Reset</button>
|
|
710
|
+
</div>`:w}
|
|
711
|
+
${this.dataAccess?v`<div class="access" role="alert">
|
|
712
|
+
<span>${this.dataAccess}${this.catalog?" Data already loaded stays on screen.":""}</span>
|
|
713
|
+
<a href=${z("settings",{section:"secrets"})}>Connect</a>
|
|
714
|
+
</div>`:w}
|
|
715
|
+
<main id="page-root"></main>
|
|
716
|
+
<qaily-ai-dock .ai=${this.services.ai} .settings=${()=>this.services.settings.settings}
|
|
717
|
+
@notify=${i=>this.notify(i.detail.message,i.detail.kind)}></qaily-ai-dock>
|
|
718
|
+
<div class="toasts" aria-live="polite">
|
|
719
|
+
${Ji(this.toasts,i=>i.id,i=>v`<div class="toast ${i.kind}" role=${i.kind==="error"?"alert":"status"}>${i.message}</div>`)}
|
|
720
|
+
</div>
|
|
721
|
+
`}static{this.styles=[_e,F`
|
|
722
|
+
:host {
|
|
723
|
+
display: flex;
|
|
724
|
+
flex-direction: column;
|
|
725
|
+
min-height: 100vh;
|
|
726
|
+
background: var(--q-bg);
|
|
727
|
+
}
|
|
728
|
+
header {
|
|
729
|
+
display: flex;
|
|
730
|
+
align-items: center;
|
|
731
|
+
gap: 16px;
|
|
732
|
+
padding: 0 16px;
|
|
733
|
+
min-height: 52px;
|
|
734
|
+
background: var(--q-surface);
|
|
735
|
+
border-bottom: 1px solid var(--q-border);
|
|
736
|
+
position: sticky;
|
|
737
|
+
top: 0;
|
|
738
|
+
z-index: 10;
|
|
739
|
+
flex-wrap: wrap;
|
|
740
|
+
}
|
|
741
|
+
.brand {
|
|
742
|
+
font-family: var(--q-font-display);
|
|
743
|
+
font-weight: 700;
|
|
744
|
+
font-size: 1.1rem;
|
|
745
|
+
color: var(--q-accent);
|
|
746
|
+
text-decoration: none;
|
|
747
|
+
}
|
|
748
|
+
nav {
|
|
749
|
+
display: flex;
|
|
750
|
+
gap: 2px;
|
|
751
|
+
overflow-x: auto;
|
|
752
|
+
flex: 1;
|
|
753
|
+
}
|
|
754
|
+
nav a {
|
|
755
|
+
display: inline-flex;
|
|
756
|
+
align-items: center;
|
|
757
|
+
gap: 6px;
|
|
758
|
+
padding: 14px 12px;
|
|
759
|
+
color: var(--q-text-muted);
|
|
760
|
+
text-decoration: none;
|
|
761
|
+
border-bottom: 2px solid transparent;
|
|
762
|
+
white-space: nowrap;
|
|
763
|
+
}
|
|
764
|
+
nav a:hover {
|
|
765
|
+
color: var(--q-text);
|
|
766
|
+
}
|
|
767
|
+
nav a[aria-current='page'] {
|
|
768
|
+
color: var(--q-accent);
|
|
769
|
+
border-bottom-color: var(--q-accent);
|
|
770
|
+
}
|
|
771
|
+
.tools {
|
|
772
|
+
display: flex;
|
|
773
|
+
align-items: center;
|
|
774
|
+
gap: 12px;
|
|
775
|
+
}
|
|
776
|
+
.fresh {
|
|
777
|
+
font-size: 0.85rem;
|
|
778
|
+
}
|
|
779
|
+
.mode {
|
|
780
|
+
font-size: 0.75rem;
|
|
781
|
+
padding: 2px 8px;
|
|
782
|
+
border: 1px solid var(--q-border);
|
|
783
|
+
border-radius: 999px;
|
|
784
|
+
white-space: nowrap;
|
|
785
|
+
cursor: help;
|
|
786
|
+
}
|
|
787
|
+
.mode.mine {
|
|
788
|
+
border-color: var(--q-accent);
|
|
789
|
+
color: var(--q-accent);
|
|
790
|
+
}
|
|
791
|
+
.access.mine {
|
|
792
|
+
border-left: 4px solid var(--q-accent);
|
|
793
|
+
}
|
|
794
|
+
.icon {
|
|
795
|
+
width: 34px;
|
|
796
|
+
padding: 4px;
|
|
797
|
+
}
|
|
798
|
+
.filters {
|
|
799
|
+
/* Above full-screen theme views (fixed canvases in the page), below the sticky header. */
|
|
800
|
+
position: relative;
|
|
801
|
+
z-index: 9;
|
|
802
|
+
display: flex;
|
|
803
|
+
gap: 16px;
|
|
804
|
+
flex-wrap: wrap;
|
|
805
|
+
padding: 8px 16px;
|
|
806
|
+
border-bottom: 1px solid var(--q-border);
|
|
807
|
+
background: var(--q-surface);
|
|
808
|
+
}
|
|
809
|
+
.filters label {
|
|
810
|
+
display: inline-flex;
|
|
811
|
+
align-items: center;
|
|
812
|
+
gap: 6px;
|
|
813
|
+
color: var(--q-text-muted);
|
|
814
|
+
font-size: 0.9rem;
|
|
815
|
+
}
|
|
816
|
+
.access {
|
|
817
|
+
position: relative;
|
|
818
|
+
z-index: 9;
|
|
819
|
+
display: flex;
|
|
820
|
+
flex-wrap: wrap;
|
|
821
|
+
justify-content: space-between;
|
|
822
|
+
gap: 4px 16px;
|
|
823
|
+
padding: 8px 16px;
|
|
824
|
+
border-bottom: 1px solid var(--q-border);
|
|
825
|
+
background: var(--q-surface-2);
|
|
826
|
+
}
|
|
827
|
+
main {
|
|
828
|
+
flex: 1;
|
|
829
|
+
position: relative;
|
|
830
|
+
padding: 16px;
|
|
831
|
+
}
|
|
832
|
+
.page-view[data-busy] {
|
|
833
|
+
opacity: 0.6;
|
|
834
|
+
transition: opacity 0.2s;
|
|
835
|
+
}
|
|
836
|
+
.toasts {
|
|
837
|
+
position: fixed;
|
|
838
|
+
right: 16px;
|
|
839
|
+
bottom: 16px;
|
|
840
|
+
display: flex;
|
|
841
|
+
flex-direction: column;
|
|
842
|
+
gap: 8px;
|
|
843
|
+
z-index: 20;
|
|
844
|
+
max-width: min(420px, calc(100vw - 32px));
|
|
845
|
+
}
|
|
846
|
+
.toast {
|
|
847
|
+
background: var(--q-surface-2);
|
|
848
|
+
border: 1px solid var(--q-border);
|
|
849
|
+
border-left: 4px solid var(--q-accent);
|
|
850
|
+
border-radius: var(--q-radius);
|
|
851
|
+
padding: 10px 14px;
|
|
852
|
+
box-shadow: var(--q-shadow);
|
|
853
|
+
}
|
|
854
|
+
.toast.error {
|
|
855
|
+
border-left-color: var(--q-bad);
|
|
856
|
+
}
|
|
857
|
+
@media (max-width: 640px) {
|
|
858
|
+
nav a span {
|
|
859
|
+
display: none;
|
|
860
|
+
}
|
|
861
|
+
.fresh,
|
|
862
|
+
.mode {
|
|
863
|
+
display: none;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
`]}}const pa=`
|
|
867
|
+
:root {
|
|
868
|
+
--q-font: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
869
|
+
--q-font-display: var(--q-font);
|
|
870
|
+
--q-font-mono: 'IBM Plex Mono', 'Fira Code', Consolas, monospace;
|
|
871
|
+
--q-radius: 8px;
|
|
872
|
+
}
|
|
873
|
+
:root[data-color-scheme='light'] {
|
|
874
|
+
--q-bg: #fafbfc;
|
|
875
|
+
--q-surface: #ffffff;
|
|
876
|
+
--q-surface-2: #f4f6f8;
|
|
877
|
+
--q-border: #e1e5ea;
|
|
878
|
+
--q-text: #1a1d21;
|
|
879
|
+
--q-text-muted: #616e7c;
|
|
880
|
+
--q-accent: #2563eb;
|
|
881
|
+
--q-on-accent: #ffffff;
|
|
882
|
+
--q-good: #16a34a;
|
|
883
|
+
--q-warn: #b45309;
|
|
884
|
+
--q-bad: #dc2626;
|
|
885
|
+
--q-none: #8a95a3;
|
|
886
|
+
--q-on-status: #ffffff;
|
|
887
|
+
--q-pass: #16a34a;
|
|
888
|
+
--q-fail: #dc2626;
|
|
889
|
+
--q-flaky: #d97706;
|
|
890
|
+
--q-skip: #8a95a3;
|
|
891
|
+
--q-running: #0284c7;
|
|
892
|
+
--q-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
|
|
893
|
+
}
|
|
894
|
+
:root[data-color-scheme='dark'] {
|
|
895
|
+
--q-bg: #0d1117;
|
|
896
|
+
--q-surface: #161b22;
|
|
897
|
+
--q-surface-2: #21262d;
|
|
898
|
+
--q-border: #30363d;
|
|
899
|
+
--q-text: #e6edf3;
|
|
900
|
+
--q-text-muted: #8b949e;
|
|
901
|
+
--q-accent: #58a6ff;
|
|
902
|
+
--q-on-accent: #0d1117;
|
|
903
|
+
--q-good: #238636;
|
|
904
|
+
--q-warn: #9e6a03;
|
|
905
|
+
--q-bad: #da3633;
|
|
906
|
+
--q-none: #484f58;
|
|
907
|
+
--q-on-status: #ffffff;
|
|
908
|
+
--q-pass: #3fb950;
|
|
909
|
+
--q-fail: #f85149;
|
|
910
|
+
--q-flaky: #d29922;
|
|
911
|
+
--q-skip: #6e7681;
|
|
912
|
+
--q-running: #58a6ff;
|
|
913
|
+
--q-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
|
|
914
|
+
}
|
|
915
|
+
`,fa={id:"classic",label:"Classic",css:pa},ma=`
|
|
916
|
+
:root {
|
|
917
|
+
--q-font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
918
|
+
--q-font-display: var(--q-font);
|
|
919
|
+
--q-font-mono: Consolas, 'Courier New', monospace;
|
|
920
|
+
--q-radius: 8px;
|
|
921
|
+
--q-bg: #121212;
|
|
922
|
+
--q-surface: #1e1e1e;
|
|
923
|
+
--q-surface-2: #2c2c2c;
|
|
924
|
+
--q-border: #3a3a3a;
|
|
925
|
+
--q-text: #e0e0e0;
|
|
926
|
+
--q-text-muted: #b0b0b0;
|
|
927
|
+
--q-accent: #4ecdc4;
|
|
928
|
+
--q-on-accent: #000000;
|
|
929
|
+
--q-good: #2e7d32;
|
|
930
|
+
--q-warn: #b26a00;
|
|
931
|
+
--q-bad: #c62828;
|
|
932
|
+
--q-none: #616161;
|
|
933
|
+
--q-on-status: #ffffff;
|
|
934
|
+
--q-pass: #4caf50;
|
|
935
|
+
--q-fail: #ff6b6b;
|
|
936
|
+
--q-flaky: #f7b538;
|
|
937
|
+
--q-skip: #9e9e9e;
|
|
938
|
+
--q-running: #4ecdc4;
|
|
939
|
+
--q-shadow: 0 4px 6px rgb(0 0 0 / 0.2);
|
|
940
|
+
}
|
|
941
|
+
`,ga={id:"dark-ops",label:"Dark Ops",css:ma,forcedColorScheme:"dark"},ya=`
|
|
942
|
+
@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@300;500;700;800&family=Manrope:wght@400;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');
|
|
943
|
+
:root {
|
|
944
|
+
--q-font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
945
|
+
--q-font-display: 'Unbounded', 'Arial Black', system-ui, sans-serif;
|
|
946
|
+
--q-font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
|
|
947
|
+
--q-radius: 14px;
|
|
948
|
+
--q-bg: #04060c;
|
|
949
|
+
--q-surface: rgba(16, 24, 42, 0.78);
|
|
950
|
+
--q-surface-2: rgba(28, 40, 66, 0.86);
|
|
951
|
+
--q-border: rgba(150, 180, 255, 0.18);
|
|
952
|
+
--q-text: #e8efff;
|
|
953
|
+
--q-text-muted: #8a97b6;
|
|
954
|
+
--q-accent: #b6a6ff;
|
|
955
|
+
--q-on-accent: #0b0820;
|
|
956
|
+
--q-good: #1fbf7f;
|
|
957
|
+
--q-warn: #d9a12b;
|
|
958
|
+
--q-bad: #e8435f;
|
|
959
|
+
--q-none: #3a4560;
|
|
960
|
+
--q-on-status: #04060c;
|
|
961
|
+
--q-pass: #34f3a0;
|
|
962
|
+
--q-fail: #ff4d6d;
|
|
963
|
+
--q-flaky: #ffc247;
|
|
964
|
+
--q-skip: #7d8aa8;
|
|
965
|
+
--q-running: #4db6ff;
|
|
966
|
+
--q-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.08);
|
|
967
|
+
--q-series-1: #8fe6ff; --q-series-2: #b6a6ff; --q-series-3: #34f3a0; --q-series-4: #ff4d6d;
|
|
968
|
+
--q-series-5: #ffc247; --q-series-6: #4db6ff; --q-series-7: #ff8ad8; --q-series-8: #e8efff;
|
|
969
|
+
}
|
|
970
|
+
qaily-shell {
|
|
971
|
+
background: #04060c;
|
|
972
|
+
isolation: isolate;
|
|
973
|
+
}
|
|
974
|
+
/* The glow sits on its own fixed layer: a fixed background-attachment would repaint the whole page on every scroll. */
|
|
975
|
+
qaily-shell::before {
|
|
976
|
+
content: '';
|
|
977
|
+
position: fixed;
|
|
978
|
+
inset: 0;
|
|
979
|
+
z-index: -1;
|
|
980
|
+
pointer-events: none;
|
|
981
|
+
background: radial-gradient(ellipse at 50% 0%, #0e1a35 0%, #04060c 60%);
|
|
982
|
+
}
|
|
983
|
+
`,va={id:"chronoscope",label:"Chronoscope",css:ya,forcedColorScheme:"dark",views:{monitoring:{dials:()=>P(()=>import("./chronoscope-view-D6I7WR1Z.js"),__vite__mapDeps([10,11]),import.meta.url).then(n=>n.default)},weekly:{carousel:()=>P(()=>import("./weekly-view-COWF8G2Z.js"),__vite__mapDeps([12,13,11]),import.meta.url).then(n=>n.default)},monthly:{carousel:()=>P(()=>import("./monthly-view-BBOPlVBV.js"),__vite__mapDeps([14,13,11]),import.meta.url).then(n=>n.default)}},preferredViews:{monitoring:"dials",weekly:"carousel",monthly:"carousel"}},ba=[va,fa,ga],wa=n=>n.replace(/^\/+|\/+$/g,"");async function _a(){aa(),customElements.define("qaily-shell",ua),customElements.define("qaily-ai-dock",ca);const n=new URL("./",document.baseURI),e=new URL("data/",n),[t,s]=await Promise.all([Yr(e),Jr(n)]),r=new ei,i=new Xr(t,null,Rt,Wr(n.pathname)),a=i.settings.connections.s3,o={...Ns(a),personal:s?.artifacts?null:da(a,i.resolved.sources)},c=!s?.artifacts&&!!a.bucket&&o.dataSource==="bucket",l=new Vr({baseUrl:n,dataUrl:e,localServer:!!s?.artifacts,secrets:r,s3:()=>({...i.settings.connections.s3,...Ns(o)}),onForget:()=>{c&&Xe().finally(()=>window.location.reload())}}),h=`${a.bucket}/${wa(o.dataPrefix)}`,d=c?new Hr(l,()=>h,(C,O)=>l.storageFetch(C instanceof Request?C.url:C,O)):null;i.setWriter(Kr(s,n)??d??new Or(()=>i.settings,r));const u=async()=>{d&&i.setDataLayer(await d.load())};await u(),l.subscribe(()=>{u()});const p=new hi(e,c?{scope:h,signedUrl:C=>l.dataFileUrl(C),keepOnDevice:()=>l.keepsCredentialsOnDevice(),fetch:(C,O)=>l.storageFetch(C,O)}:null);(!c||!l.keepsCredentialsOnDevice())&&Xe();const b=document.createElement("qaily-shell");b.services={data:p,settings:i,secrets:r,artifacts:l,ai:new Rr({baseUrl:n,data:p,artifacts:l,secrets:r,settings:()=>i.settings,store:new Ar(e),localWrites:!!s?.writes}),notes:new _i,themes:new wi(ba),router:new pi,location:o},document.body.replaceChildren(b)}_a().catch(n=>{console.error(n),document.body.textContent=`The report could not start: ${n instanceof Error?n.message:n}`});export{w as A,Ft as B,Da as C,zi as D,Z as E,Wi as F,_n as G,Aa as H,Nt as I,Rt as J,Ne as K,ta as L,Sa as M,qt as N,ka as P,Ha as S,P as _,bi as a,Ta as b,qa as c,$a as d,vi as e,tt as f,F as g,za as h,or as i,v as j,U as k,Ia as l,Ea as m,gi as n,Yi as o,xa as p,tn as q,Ca as r,Na as s,yi as t,Ra as u,_e as v,le as w,Oa as x,Vt as y,Wt as z};
|