"use strict";(()=>{var e={};e.id=3058,e.ids=[3058],e.modules={85890:e=>{e.exports=require("better-sqlite3")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},78893:e=>{e.exports=require("buffer")},61282:e=>{e.exports=require("child_process")},84770:e=>{e.exports=require("crypto")},17702:e=>{e.exports=require("events")},92048:e=>{e.exports=require("fs")},20629:e=>{e.exports=require("fs/promises")},32615:e=>{e.exports=require("http")},35240:e=>{e.exports=require("https")},98216:e=>{e.exports=require("net")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},76162:e=>{e.exports=require("stream")},82452:e=>{e.exports=require("tls")},17360:e=>{e.exports=require("url")},21764:e=>{e.exports=require("util")},71568:e=>{e.exports=require("zlib")},17679:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>P,patchFetch:()=>k,requestAsyncStorage:()=>v,routeModule:()=>x,serverHooks:()=>w,staticGenerationAsyncStorage:()=>q});var s={};r.r(s),r.d(s,{GET:()=>f,dynamic:()=>g});var o=r(49303),i=r(88716),n=r(60670),a=r(87070),p=r(97425),u=r(75748),c=r(55837),l=r(83513),d=r(89194),h=r(13561),m=r(2693);let g="force-dynamic";async function f(e){try{let t=(0,p.getDbInstance)(),r=e.nextUrl?.searchParams,s=r?.get("repository"),o=(0,u.Xv)(t,s||void 0),i=c.g.getInstance(),n=l.tK,g=await Promise.all(o.map(async e=>{let r={},s=!1,o=!1,a=!1;for(let p of n){let n=i.getTool(p),c=await n.isRunning(e.id),l=!1,g=!1;if(c)try{let r="opencode"===p?m.uC:100,s=await (0,d.NA)(e.id,p,r),o=(0,h._)(s,p);l="waiting"===o.status,g="running"===o.status,!o.hasActivePrompt&&(0,u._U)(t,e.id,void 0,10,p).some(e=>"prompt"===e.messageType&&e.promptData?.status!=="answered")&&(0,u.GP)(t,e.id,p)}catch{g=!0}r[p]={isRunning:c,isWaitingForResponse:l,isProcessing:g},c&&(s=!0),l&&(o=!0),g&&(a=!0)}return{...e,isSessionRunning:s,isWaitingForResponse:o,isProcessing:a,sessionStatusByCli:r}})),f=(0,u.ER)(t);return a.NextResponse.json({worktrees:g,repositories:f},{status:200})}catch(e){return console.error("Error fetching worktrees:",e),a.NextResponse.json({error:"Failed to fetch worktrees"},{status:500})}}let x=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/worktrees/route",pathname:"/api/worktrees",filename:"route",bundlePath:"app/api/worktrees/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:v,staticGenerationAsyncStorage:q,serverHooks:w}=x,P="/api/worktrees/route";function k(){return(0,n.patchFetch)({serverHooks:w,staticGenerationAsyncStorage:q})}},13561:(e,t,r)=>{r.d(t,{_:()=>i});var s=r(19377),o=r(63661);function i(e,t,r){let i=(0,s.vp)(e),n=i.split("\n"),a=n.length-1;for(;a>=0&&""===n[a].trim();)a--;let p=n.slice(0,a+1),u=p.slice(-15).join("\n"),c=p.slice(-5).join("\n"),l=(0,s.Sg)(t);if((0,o.F)((0,s.BN)(i),l).isPrompt)return{status:"waiting",confidence:"high",reason:"prompt_detected",hasActivePrompt:!0};if((0,s.Wg)(t,c))return{status:"running",confidence:"high",reason:"thinking_indicator",hasActivePrompt:!1};if("opencode"===t){if(s.nT.test(u))return{status:"running",confidence:"high",reason:"opencode_processing_indicator",hasActivePrompt:!1};let e=(0,s.BN)(i).split("\n"),t=Math.max(0,e.length-7);for(let r=e.length-1;r>=Math.max(0,e.length-10);r--)if(/ctrl\+[tp]/.test(e[r])){t=Math.max(0,r-2);break}let r=e.slice(0,t),o=r.length-1;for(;o>=0&&""===r[o].trim();)o--;if(o>=0){let e=r.slice(Math.max(0,o-5+1),o+1).join("\n");if((0,s.Wg)("opencode",e))return{status:"running",confidence:"high",reason:"thinking_indicator",hasActivePrompt:!1};let t=r.slice(Math.max(0,o-15+1),o+1).join("\n");if(s.n9.test(t))return{status:"ready",confidence:"high",reason:"opencode_response_complete",hasActivePrompt:!1}}}let{promptPattern:d}=(0,s.bs)(t);return d.test(u)?{status:"ready",confidence:"high",reason:"input_prompt",hasActivePrompt:!1}:r&&Date.now()-r.getTime()>5e3?{status:"ready",confidence:"low",reason:"no_recent_output",hasActivePrompt:!1}:{status:"running",confidence:"low",reason:"default",hasActivePrompt:!1}}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8948,5972,3853,4893,7425,7566,4952],()=>r(17679));module.exports=s})();