module.exports=[22734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},46786,(e,t,r)=>{t.exports=e.x("os",()=>require("os"))},74533,(e,t,r)=>{t.exports=e.x("node:child_process",()=>require("node:child_process"))},83935,(e,t,r)=>{t.exports=e.x("sql.js-59d66b30daa0a8d2/dist/sql-asm.js",()=>require("sql.js-59d66b30daa0a8d2/dist/sql-asm.js"))},84501,14966,e=>{"use strict";e.s(["ensureDb",()=>_,"getDb",()=>R],84501);var t=e.i(22734),r=e.i(14747),a=e.i(46786);let s=r.default.join(a.default.homedir(),".idea-manager","data");function n(){return r.default.join((t.default.existsSync(s)||t.default.mkdirSync(s,{recursive:!0}),s),"im.db")}let i=r.default.join(a.default.homedir(),".idea-manager","sync");function o(){return t.default.existsSync(i)||t.default.mkdirSync(i,{recursive:!0}),i}e.s(["getDbPath",()=>n,"getSyncDir",()=>o],14966);var d=e.i(74533);let l=!1,u="";async function p(){let e=new Date,t=e.getHours(),r=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;if(9===t&&u!==r)try{let e,t;await _();let a=R(),s=a.prepare("SELECT t.title, t.status, p.name as project_name FROM tasks t JOIN projects p ON t.project_id = p.id WHERE t.is_today = 1 AND t.status != 'done'").all(),n=a.prepare("SELECT COUNT(*) as count FROM tasks WHERE status IN ('submitted', 'testing')").get(),i=a.prepare("SELECT COUNT(*) as count FROM tasks WHERE status = 'problem'").get(),o=[];if(s.length>0){for(let e of(o.push(`Today: ${s.length}개`),s.slice(0,5)))o.push(`  - ${e.title}`);s.length>5&&o.push(`  ... +${s.length-5}개`)}else o.push("Today 태스크가 없습니다.");n.count>0&&o.push(`진행 중: ${n.count}개`),i.count>0&&o.push(`문제: ${i.count}개`),e=o.join("\n").replace(/"/g,'\\"').replace(/\n/g,"\\n"),t=`display notification "${e}" with title "IM - 오늘의 할 일"`,(0,d.exec)(`osascript -e '${t}'`,e=>{e&&console.error("[Scheduler] notification error:",e.message)}),u=r}catch(e){console.error("[Scheduler] error:",e)}}class c{db;dbPath;dirty=!1;constructor(e,t){this.db=e,this.dbPath=t}save(){if(!this.dirty)return;let e=this.db.export();t.default.writeFileSync(this.dbPath,Buffer.from(e)),this.dirty=!1}immediatelySave(){this.dirty=!0,this.save()}rowsToObjects(e,t){return t.map(t=>{let r={};return e.forEach((e,a)=>{r[e]=t[a]}),r})}prepare(e){let t=this,r=/^\s*(INSERT|UPDATE|DELETE|CREATE|ALTER|DROP)/i.test(e);return{all(...r){let a=t.db.prepare(e);r.length>0&&a.bind(r);let s=a.getColumnNames(),n=[];for(;a.step();)n.push(a.get());return a.free(),t.rowsToObjects(s,n)},get(...r){let a,s=t.db.prepare(e);if(r.length>0&&s.bind(r),s.step()){let e=s.getColumnNames(),t=s.get(),r={};e.forEach((e,a)=>{r[e]=t[a]}),a=r}return s.free(),a},run:(...a)=>(t.db.run(e,a),r&&t.immediatelySave(),{changes:t.db.getRowsModified()})}}exec(e){this.db.exec(e),/^\s*(INSERT|UPDATE|DELETE|CREATE|ALTER|DROP)/im.test(e)&&this.immediatelySave()}pragma(e){if(e.startsWith("table_info(")){let t=e.match(/table_info\((\w+)\)/)?.[1];if(!t)return[];let r=this.db.exec(`PRAGMA table_info(${t})`);return r.length?this.rowsToObjects(r[0].columns,r[0].values):[]}if(e.includes("journal_mode")||e.includes("wal_checkpoint"))return this.immediatelySave(),"memory";if(e.includes("foreign_keys")){try{this.db.run(`PRAGMA ${e}`)}catch{}return}try{let t=this.db.exec(`PRAGMA ${e}`);if(t.length>0&&t[0].values.length>0)return t[0].values[0][0]}catch{}}transaction(e){let t=this;return()=>{t.db.run("BEGIN");try{let r=e();return t.db.run("COMMIT"),t.immediatelySave(),r}catch(e){throw t.db.run("ROLLBACK"),e}}}close(){this.immediatelySave(),this.db.close()}}let E=null,T=null;async function m(){var r;let a,s,i;if(E)return E;let o=e.r(83935),d=await o(),u=n();if(t.default.existsSync(u)){let e=t.default.readFileSync(u);a=new d.Database(e)}else a=new d.Database;return(r=E=new c(a,u)).exec(`
    CREATE TABLE IF NOT EXISTS projects (
      id TEXT PRIMARY KEY,
      name TEXT NOT NULL,
      description TEXT NOT NULL DEFAULT '',
      project_path TEXT,
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      updated_at TEXT NOT NULL DEFAULT (datetime('now'))
    );

    CREATE TABLE IF NOT EXISTS brainstorms (
      id TEXT PRIMARY KEY,
      project_id TEXT NOT NULL,
      content TEXT NOT NULL DEFAULT '',
      version INTEGER NOT NULL DEFAULT 1,
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      updated_at TEXT NOT NULL DEFAULT (datetime('now')),
      FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
    );

  `),(s=r.prepare("PRAGMA table_info(projects)").all()).some(e=>"project_path"===e.name)||r.exec("ALTER TABLE projects ADD COLUMN project_path TEXT"),s.some(e=>"ai_context"===e.name)||r.exec("ALTER TABLE projects ADD COLUMN ai_context TEXT NOT NULL DEFAULT ''"),s.some(e=>"watch_enabled"===e.name)||r.exec("ALTER TABLE projects ADD COLUMN watch_enabled INTEGER NOT NULL DEFAULT 0"),s.some(e=>"agent_type"===e.name)||r.exec("ALTER TABLE projects ADD COLUMN agent_type TEXT NOT NULL DEFAULT 'claude'"),r.exec(`
    CREATE TABLE IF NOT EXISTS sub_projects (
      id TEXT PRIMARY KEY,
      project_id TEXT NOT NULL,
      name TEXT NOT NULL,
      description TEXT NOT NULL DEFAULT '',
      folder_path TEXT,
      sort_order INTEGER NOT NULL DEFAULT 0,
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      updated_at TEXT NOT NULL DEFAULT (datetime('now')),
      FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
    );

    CREATE TABLE IF NOT EXISTS tasks (
      id TEXT PRIMARY KEY,
      project_id TEXT NOT NULL,
      sub_project_id TEXT NOT NULL,
      title TEXT NOT NULL,
      description TEXT NOT NULL DEFAULT '',
      status TEXT NOT NULL DEFAULT 'idea'
        CHECK(status IN ('idea','writing','submitted','testing','done','problem')),
      priority TEXT NOT NULL DEFAULT 'medium'
        CHECK(priority IN ('high','medium','low')),
      is_today INTEGER NOT NULL DEFAULT 0,
      sort_order INTEGER NOT NULL DEFAULT 0,
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      updated_at TEXT NOT NULL DEFAULT (datetime('now')),
      FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
      FOREIGN KEY (sub_project_id) REFERENCES sub_projects(id) ON DELETE CASCADE
    );

    CREATE TABLE IF NOT EXISTS task_prompts (
      id TEXT PRIMARY KEY,
      task_id TEXT NOT NULL UNIQUE,
      content TEXT NOT NULL DEFAULT '',
      prompt_type TEXT NOT NULL DEFAULT 'manual'
        CHECK(prompt_type IN ('manual','ai_assisted')),
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      updated_at TEXT NOT NULL DEFAULT (datetime('now')),
      FOREIGN KEY (task_id) REFERENCES tasks(id) ON DELETE CASCADE
    );

    CREATE TABLE IF NOT EXISTS global_memos (
      id TEXT PRIMARY KEY,
      content TEXT NOT NULL DEFAULT '',
      updated_at TEXT NOT NULL DEFAULT (datetime('now'))
    );

    CREATE TABLE IF NOT EXISTS task_conversations (
      id TEXT PRIMARY KEY,
      task_id TEXT NOT NULL,
      role TEXT NOT NULL CHECK(role IN ('assistant','user')),
      content TEXT NOT NULL,
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      FOREIGN KEY (task_id) REFERENCES tasks(id) ON DELETE CASCADE
    );
  `),(i=r.prepare("PRAGMA table_info(tasks)").all()).some(e=>"is_archived"===e.name)||r.exec("ALTER TABLE tasks ADD COLUMN is_archived INTEGER NOT NULL DEFAULT 0"),i.some(e=>"tags"===e.name)||r.exec("ALTER TABLE tasks ADD COLUMN tags TEXT NOT NULL DEFAULT '[]'"),process.on("exit",()=>E?.close()),l||(l=!0,setInterval(p,6e4),p(),console.log("[Scheduler] Morning notification scheduler started")),E}async function _(){return E||(T||(T=m()),T)}function R(){if(!E)throw Error("Database not initialized. Call await ensureDb() first.");return E}},66680,(e,t,r)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},31308,e=>{"use strict";let t,r;var a=e.i(66680);function s(){return function(e=21){var s;s=e|=0,!t||t.length<s?(t=Buffer.allocUnsafe(128*s),a.webcrypto.getRandomValues(t),r=0):r+s>t.length&&(a.webcrypto.getRandomValues(t),r=0),r+=s;let n="";for(let a=r-e;a<r;a++)n+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&t[a]];return n}(16)}e.s(["generateId",()=>s],31308)},88095,e=>{"use strict";var t=e.i(84501),r=e.i(31308);function a(e){return{...e,watch_enabled:1===e.watch_enabled,agent_type:e.agent_type||"claude"}}function s(){return(0,t.getDb)().prepare("SELECT * FROM projects ORDER BY updated_at DESC").all().map(a)}function n(e){let r=(0,t.getDb)().prepare("SELECT * FROM projects WHERE id = ?").get(e);return r?a(r):void 0}function i(e,a="",s){let o=(0,t.getDb)(),d=(0,r.generateId)(),l=new Date().toISOString();o.prepare("INSERT INTO projects (id, name, description, project_path, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)").run(d,e,a,s??null,l,l);let u=(0,r.generateId)();return o.prepare("INSERT INTO brainstorms (id, project_id, content, version, created_at, updated_at) VALUES (?, ?, ?, 1, ?, ?)").run(u,d,"",l,l),n(d)}function o(e,r){let a=(0,t.getDb)(),s=n(e);if(!s)return;let i=new Date().toISOString();return a.prepare("UPDATE projects SET name = ?, description = ?, project_path = ?, ai_context = ?, watch_enabled = ?, agent_type = ?, updated_at = ? WHERE id = ?").run(r.name??s.name,r.description??s.description,void 0!==r.project_path?r.project_path:s.project_path,void 0!==r.ai_context?r.ai_context:s.ai_context??"",void 0!==r.watch_enabled?+!!r.watch_enabled:+!!s.watch_enabled,r.agent_type??s.agent_type??"claude",i,e),n(e)}function d(e){return(0,t.getDb)().prepare("DELETE FROM projects WHERE id = ?").run(e).changes>0}e.s(["createProject",()=>i,"deleteProject",()=>d,"getProject",()=>n,"listProjects",()=>s,"updateProject",()=>o])},2004,e=>{"use strict";var t=e.i(84501),r=e.i(31308);function a(e){let t=[];try{t=JSON.parse(e.tags||"[]")}catch{}return{...e,is_today:1===e.is_today,is_archived:(e.is_archived??0)===1,tags:t}}function s(e){return(0,t.getDb)().prepare("SELECT * FROM tasks WHERE sub_project_id = ? AND is_archived = 0 ORDER BY sort_order ASC").all(e).map(a)}function n(e){let r=(0,t.getDb)().prepare("SELECT * FROM tasks WHERE id = ?").get(e);return r?a(r):void 0}function i(e){let r=(0,t.getDb)();return(e?r.prepare("SELECT * FROM tasks WHERE project_id = ? AND is_archived = 1 ORDER BY updated_at DESC").all(e):r.prepare("SELECT * FROM tasks WHERE is_archived = 1 ORDER BY updated_at DESC").all()).map(a)}function o(e){let r=(0,t.getDb)(),a=new Date().toISOString();return r.prepare("UPDATE tasks SET is_archived = 1, is_today = 0, updated_at = ? WHERE id = ?").run(a,e),n(e)}function d(e){let r=(0,t.getDb)(),a=new Date().toISOString();return r.prepare("UPDATE tasks SET is_archived = 0, updated_at = ? WHERE id = ?").run(a,e),n(e)}function l(e){let a=(0,t.getDb)(),s=(0,r.generateId)(),i=new Date().toISOString(),o=a.prepare("SELECT MAX(sort_order) as max_order FROM tasks WHERE sub_project_id = ?").get(e.sub_project_id),d=(o?.max_order??-1)+1;return a.prepare(`INSERT INTO tasks (id, project_id, sub_project_id, title, description, status, priority, is_today, sort_order, created_at, updated_at)
     VALUES (?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?)`).run(s,e.project_id,e.sub_project_id,e.title,e.description??"",e.status??"idea",e.priority??"medium",d,i,i),n(s)}function u(e,r){let a=(0,t.getDb)(),s=a.prepare("SELECT * FROM tasks WHERE id = ?").get(e);if(!s)return;let i=new Date().toISOString();return a.prepare(`
    UPDATE tasks SET
      title = ?, description = ?, status = ?, priority = ?,
      is_today = ?, sort_order = ?, sub_project_id = ?, tags = ?, updated_at = ?
    WHERE id = ?
  `).run(r.title??s.title,r.description??s.description,r.status??s.status,r.priority??s.priority,void 0!==r.is_today?+!!r.is_today:s.is_today,r.sort_order??s.sort_order,r.sub_project_id??s.sub_project_id,r.tags?JSON.stringify(r.tags):s.tags,i,e),n(e)}function p(e){return(0,t.getDb)().prepare("DELETE FROM tasks WHERE id = ?").run(e).changes>0}e.s(["archiveTask",()=>o,"createTask",()=>l,"deleteTask",()=>p,"getArchivedTasks",()=>i,"getTask",()=>n,"getTasks",()=>s,"restoreTask",()=>d,"updateTask",()=>u])},10520,e=>{"use strict";var t=e.i(84501),r=e.i(31308);function a(e){return(0,t.getDb)().prepare("SELECT * FROM task_prompts WHERE task_id = ?").get(e)}function s(e,n,i="manual"){let o=(0,t.getDb)(),d=a(e),l=new Date().toISOString();if(d)o.prepare("UPDATE task_prompts SET content = ?, prompt_type = ?, updated_at = ? WHERE task_id = ?").run(n,i,l,e);else{let t=(0,r.generateId)();o.prepare("INSERT INTO task_prompts (id, task_id, content, prompt_type, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)").run(t,e,n,i,l,l)}return a(e)}e.s(["getTaskPrompt",()=>a,"upsertTaskPrompt",()=>s])},27543,e=>{"use strict";var t=e.i(84501);function r(e){return(0,t.getDb)().prepare("SELECT * FROM brainstorms WHERE project_id = ? ORDER BY version DESC LIMIT 1").get(e)}function a(e,a){let s=(0,t.getDb)(),n=new Date().toISOString(),i=r(e);if(i)return s.prepare("UPDATE brainstorms SET content = ?, version = version + 1, updated_at = ? WHERE id = ?").run(a,n,i.id),s.prepare("UPDATE projects SET updated_at = ? WHERE id = ?").run(n,e),r(e)}e.s(["getBrainstorm",()=>r,"updateBrainstorm",()=>a])},63909,e=>{"use strict";var t=e.i(74533);let r={claude:{name:"Claude",binary:"claude",buildArgs:({streaming:e})=>["--dangerously-skip-permissions","--model","opus",...e?["--output-format","stream-json","--verbose"]:["--output-format","text"],"--max-turns","80","-p","-"],buildEnv:()=>{let e={...process.env};for(let t of(delete e.CLAUDECODE,delete e.CLAUDE_CODE_ENTRYPOINT,delete e.CLAUDE_CODE_MAX_OUTPUT_TOKENS,Object.keys(e)))(t.startsWith("CLAUDE_CODE_")||"ANTHROPIC_PARENT_SESSION"===t)&&delete e[t];return{...e,FORCE_COLOR:"0"}},parseStreamEvent:e=>{if("content_block_delta"===e.type&&e.delta?.text)return{text:e.delta.text};if("assistant"===e.type&&e.message?.content){let t="";for(let r of e.message.content)"text"===r.type&&(t+=r.text);return{final:t}}return"result"===e.type&&e.result?{final:e.result}:null},cleanOutput:e=>e.replace(/Error: Reached max turns \(\d+\)\s*/g,"").trim()},gemini:{name:"Gemini",binary:"gemini",buildArgs:({streaming:e})=>["--yolo","-m","gemini-2.5-flash",...e?["--output-format","stream-json"]:["--output-format","json"],"-p","-"],buildEnv:()=>({...process.env,FORCE_COLOR:"0"}),parseStreamEvent:e=>"content_block_delta"===e.type&&e.delta?.text?{text:e.delta.text}:"result"===e.type?{final:e.response||e.text||e.result}:null,cleanOutput:e=>{let t=e.trim();if(!t.startsWith("{"))return t;try{let e=JSON.parse(t);return e.response||e.text||e.result||t}catch{return t}}},codex:{name:"Codex",binary:"codex",buildArgs:({streaming:e})=>["exec","--full-auto",...e?["--json"]:[],"-"],buildEnv:()=>({...process.env,FORCE_COLOR:"0"}),parseStreamEvent:e=>"item.completed"===e.type&&e.item?.type==="agent_message"?{final:e.item.text}:"item.updated"===e.type&&e.item?.type==="agent_message"?{text:e.item.text}:null}};function a(e,a,s,n,i){let o=r[e];return o?new Promise((e,r)=>{let d=!!(s||n),l=o.buildArgs({streaming:d}),u=o.buildEnv(),p=(0,t.spawn)(o.binary,l,{cwd:i?.cwd||process.cwd(),stdio:["pipe","pipe","pipe"],shell:"win32"===process.platform,env:u}),c=null,E=!1;i?.timeoutMs&&(c=setTimeout(()=>{E=!0,p.kill("SIGTERM")},i.timeoutMs)),p.stdin?.write(a),p.stdin?.end();let T="",m="",_="",R=0;d?p.stdout?.on("data",e=>{let t=(T+=e.toString()).split("\n");for(let e of(T=t.pop()??"",t)){let t=e.trim();if(t)try{let e=JSON.parse(t);n?.(e);let r=o.parseStreamEvent(e);if(r)if(r.final){if(r.final.length>R){let e=r.final.slice(R);s?.(e),R=r.final.length}m=r.final}else r.text&&(m+=r.text,R=m.length,s?.(r.text))}catch{}}}):p.stdout?.on("data",e=>{m+=e.toString()}),p.stderr?.on("data",e=>{_+=e.toString()}),p.on("error",e=>{r(Error(`${o.name} CLI error: ${e.message}`))}),p.on("exit",(t,a)=>{if(c&&clearTimeout(c),!d&&o.cleanOutput&&(m=o.cleanOutput(m)),E)return void r(Error(`${o.name} CLI timed out after ${Math.round((i?.timeoutMs||0)/1e3)}s`));if(0!==t&&!m){let e=_.slice(0,500)||(a?`killed by signal ${a}`:"no output");r(Error(`${o.name} CLI exited with code ${t}: ${e}`));return}e(m)})}):Promise.reject(Error(`Unknown agent type: ${e}`))}e.s(["runAgent",()=>a],63909)},16566,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),s=e.i(59756),n=e.i(61916),i=e.i(74677),o=e.i(69741),d=e.i(16795),l=e.i(87718),u=e.i(95169),p=e.i(47587),c=e.i(66012),E=e.i(70101),T=e.i(74838),m=e.i(10372),_=e.i(93695);e.i(52474);var R=e.i(220),g=e.i(89171),L=e.i(84501),N=e.i(31308);function h(e){return(0,L.getDb)().prepare("SELECT * FROM task_conversations WHERE task_id = ? ORDER BY created_at ASC").all(e)}function f(e,t,r){let a=(0,L.getDb)(),s=(0,N.generateId)(),n=new Date().toISOString();return a.prepare("INSERT INTO task_conversations (id, task_id, role, content, created_at) VALUES (?, ?, ?, ?, ?)").run(s,e,t,r,n),a.prepare("SELECT * FROM task_conversations WHERE id = ?").get(s)}var A=e.i(2004),O=e.i(10520),D=e.i(27543),b=e.i(88095),S=e.i(63909);async function x(e,{params:t}){await (0,L.ensureDb)();let{taskId:r}=await t,a=h(r);return g.NextResponse.json(a)}async function C(e,{params:t}){await (0,L.ensureDb)();let{id:r,taskId:a}=await t,s=await e.json();if(!s.message||"string"!=typeof s.message)return g.NextResponse.json({error:"message is required"},{status:400});let n=(0,A.getTask)(a);if(!n)return g.NextResponse.json({error:"Task not found"},{status:404});let i=f(a,"user",s.message),o=h(a),d=(0,O.getTaskPrompt)(a),l=(0,D.getBrainstorm)(r),u=(0,b.getProject)(r),p=u?.ai_context?`

Project AI Policy:
${u.ai_context}`:"",c=`You are a helpful assistant helping refine a development task. Respond in Korean. Be concise.
${p}
Task: ${n.title}
Description: ${n.description}
Status: ${n.status}
${d?.content?`Current prompt:
${d.content}`:""}
${l?.content?`
Brainstorming context:
${l.content.slice(0,3e3)}`:""}`,E=o.map(e=>`${"user"===e.role?"User":"Assistant"}: ${e.content}`).join("\n");try{let e=u?.agent_type||"claude",t=u?.project_path||void 0,r=(await (0,S.runAgent)(e,`${c}

Conversation:
${E}`,void 0,void 0,{cwd:t})).trim();if(!r){let e=f(a,"assistant","(AI 응답을 생성하지 못했습니다. 다시 시도해주세요.)");return g.NextResponse.json({userMessage:i,aiMessage:e})}let s=f(a,"assistant",r);return g.NextResponse.json({userMessage:i,aiMessage:s})}catch{let e=f(a,"assistant","(AI 호출에 실패했습니다. Claude CLI가 설치되어 있는지 확인해주세요.)");return g.NextResponse.json({userMessage:i,aiMessage:e})}}e.s(["GET",()=>x,"POST",()=>C],24675);var y=e.i(24675);let v=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/projects/[id]/sub-projects/[subId]/tasks/[taskId]/chat/route",pathname:"/api/projects/[id]/sub-projects/[subId]/tasks/[taskId]/chat",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/projects/[id]/sub-projects/[subId]/tasks/[taskId]/chat/route.ts",nextConfigOutput:"",userland:y}),{workAsyncStorage:U,workUnitAsyncStorage:j,serverHooks:I}=v;function w(){return(0,a.patchFetch)({workAsyncStorage:U,workUnitAsyncStorage:j})}async function k(e,t,a){v.isDev&&(0,s.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let g="/api/projects/[id]/sub-projects/[subId]/tasks/[taskId]/chat/route";g=g.replace(/\/index$/,"")||"/";let L=await v.prepare(e,t,{srcPage:g,multiZoneDraftMode:!1});if(!L)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:N,params:h,nextConfig:f,parsedUrl:A,isDraftMode:O,prerenderManifest:D,routerServerContext:b,isOnDemandRevalidate:S,revalidateOnlyGenerated:x,resolvedPathname:C,clientReferenceManifest:y,serverActionsManifest:U}=L,j=(0,o.normalizeAppPath)(g),I=!!(D.dynamicRoutes[j]||D.routes[C]),w=async()=>((null==b?void 0:b.render404)?await b.render404(e,t,A,!1):t.end("This page could not be found"),null);if(I&&!O){let e=!!D.routes[C],t=D.dynamicRoutes[j];if(t&&!1===t.fallback&&!e){if(f.experimental.adapterPath)return await w();throw new _.NoFallbackError}}let k=null;!I||v.isDev||O||(k="/index"===(k=C)?"/":k);let F=!0===v.isDev||!I,P=I&&!F;U&&y&&(0,i.setManifestsSingleton)({page:g,clientReferenceManifest:y,serverActionsManifest:U});let M=e.method||"GET",X=(0,n.getTracer)(),H=X.getActiveScopeSpan(),$={params:h,prerenderManifest:D,renderOpts:{experimental:{authInterrupts:!!f.experimental.authInterrupts},cacheComponents:!!f.cacheComponents,supportsDynamicResponse:F,incrementalCache:(0,s.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:f.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,s)=>v.onRequestError(e,t,a,s,b)},sharedContext:{buildId:N}},B=new d.NodeNextRequest(e),q=new d.NodeNextResponse(t),Y=l.NextRequestAdapter.fromNodeNextRequest(B,(0,l.signalFromNodeResponse)(t));try{let i=async e=>v.handle(Y,$).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=X.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${M} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t)}else e.updateName(`${M} ${g}`)}),o=!!(0,s.getRequestMeta)(e,"minimalMode"),d=async s=>{var n,d;let l=async({previousCacheEntry:r})=>{try{if(!o&&S&&x&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let n=await i(s);e.fetchMetrics=$.renderOpts.fetchMetrics;let d=$.renderOpts.pendingWaitUntil;d&&a.waitUntil&&(a.waitUntil(d),d=void 0);let l=$.renderOpts.collectedTags;if(!I)return await (0,c.sendResponse)(B,q,n,$.renderOpts.pendingWaitUntil),null;{let e=await n.blob(),t=(0,E.toNodeOutgoingHttpHeaders)(n.headers);l&&(t[m.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==$.renderOpts.collectedRevalidate&&!($.renderOpts.collectedRevalidate>=m.INFINITE_CACHE)&&$.renderOpts.collectedRevalidate,a=void 0===$.renderOpts.collectedExpire||$.renderOpts.collectedExpire>=m.INFINITE_CACHE?void 0:$.renderOpts.collectedExpire;return{value:{kind:R.CachedRouteKind.APP_ROUTE,status:n.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await v.onRequestError(e,t,{routerKind:"App Router",routePath:g,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:S})},!1,b),t}},u=await v.handleResponse({req:e,nextConfig:f,cacheKey:k,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:D,isRoutePPREnabled:!1,isOnDemandRevalidate:S,revalidateOnlyGenerated:x,responseGenerator:l,waitUntil:a.waitUntil,isMinimalMode:o});if(!I)return null;if((null==u||null==(n=u.value)?void 0:n.kind)!==R.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(d=u.value)?void 0:d.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});o||t.setHeader("x-nextjs-cache",S?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),O&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let _=(0,E.fromNodeOutgoingHttpHeaders)(u.value.headers);return o&&I||_.delete(m.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||_.get("Cache-Control")||_.set("Cache-Control",(0,T.getCacheControlHeader)(u.cacheControl)),await (0,c.sendResponse)(B,q,new Response(u.value.body,{headers:_,status:u.value.status||200})),null};H?await d(H):await X.withPropagatedContext(e.headers,()=>X.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${g}`,kind:n.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},d))}catch(t){if(t instanceof _.NoFallbackError||await v.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:S})},!1,b),I)throw t;return await (0,c.sendResponse)(B,q,new Response(null,{status:500})),null}}e.s(["handler",()=>k,"patchFetch",()=>w,"routeModule",()=>v,"serverHooks",()=>I,"workAsyncStorage",()=>U,"workUnitAsyncStorage",()=>j],16566)}];

//# sourceMappingURL=%5Broot-of-the-server%5D__2a52210d._.js.map