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",()=>N,"getDb",()=>_],84501);var t=e.i(22734),r=e.i(14747),a=e.i(46786);let n=r.default.join(a.default.homedir(),".idea-manager","data");function s(){return r.default.join((t.default.existsSync(n)||t.default.mkdirSync(n,{recursive:!0}),n),"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",()=>s,"getSyncDir",()=>o],14966);var d=e.i(74533);let l=!1,u="";async function c(){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 N();let a=_(),n=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(),s=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(n.length>0){for(let e of(o.push(`Today: ${n.length}개`),n.slice(0,5)))o.push(`  - ${e.title}`);n.length>5&&o.push(`  ... +${n.length-5}개`)}else o.push("Today 태스크가 없습니다.");s.count>0&&o.push(`진행 중: ${s.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 p{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 n=a.getColumnNames(),s=[];for(;a.step();)s.push(a.get());return a.free(),t.rowsToObjects(n,s)},get(...r){let a,n=t.db.prepare(e);if(r.length>0&&n.bind(r),n.step()){let e=n.getColumnNames(),t=n.get(),r={};e.forEach((e,a)=>{r[e]=t[a]}),a=r}return n.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,n,i;if(E)return E;let o=e.r(83935),d=await o(),u=s();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 p(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
    );

  `),(n=r.prepare("PRAGMA table_info(projects)").all()).some(e=>"project_path"===e.name)||r.exec("ALTER TABLE projects ADD COLUMN project_path TEXT"),n.some(e=>"ai_context"===e.name)||r.exec("ALTER TABLE projects ADD COLUMN ai_context TEXT NOT NULL DEFAULT ''"),n.some(e=>"watch_enabled"===e.name)||r.exec("ALTER TABLE projects ADD COLUMN watch_enabled INTEGER NOT NULL DEFAULT 0"),n.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(c,6e4),c(),console.log("[Scheduler] Morning notification scheduler started")),E}async function N(){return E||(T||(T=m()),T)}function _(){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 n(){return function(e=21){var n;n=e|=0,!t||t.length<n?(t=Buffer.allocUnsafe(128*n),a.webcrypto.getRandomValues(t),r=0):r+n>t.length&&(a.webcrypto.getRandomValues(t),r=0),r+=n;let s="";for(let a=r-e;a<r;a++)s+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&t[a]];return s}(16)}e.s(["generateId",()=>n],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 n(){return(0,t.getDb)().prepare("SELECT * FROM projects ORDER BY updated_at DESC").all().map(a)}function s(e){let r=(0,t.getDb)().prepare("SELECT * FROM projects WHERE id = ?").get(e);return r?a(r):void 0}function i(e,a="",n){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,n??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),s(d)}function o(e,r){let a=(0,t.getDb)(),n=s(e);if(!n)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??n.name,r.description??n.description,void 0!==r.project_path?r.project_path:n.project_path,void 0!==r.ai_context?r.ai_context:n.ai_context??"",void 0!==r.watch_enabled?+!!r.watch_enabled:+!!n.watch_enabled,r.agent_type??n.agent_type??"claude",i,e),s(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",()=>s,"listProjects",()=>n,"updateProject",()=>o])},60636,e=>{"use strict";var t=e.i(84501),r=e.i(31308);function a(e){return(0,t.getDb)().prepare("SELECT * FROM sub_projects WHERE id = ?").get(e)}function n(e){let r=(0,t.getDb)();return r.prepare("SELECT * FROM sub_projects WHERE project_id = ? ORDER BY sort_order ASC").all(e).map(e=>{let t=r.prepare(`
      SELECT
        COUNT(*) as task_count,
        SUM(CASE WHEN status IN ('submitted','testing') THEN 1 ELSE 0 END) as active_count,
        SUM(CASE WHEN status IN ('idea','writing') THEN 1 ELSE 0 END) as pending_count,
        SUM(CASE WHEN status = 'done' THEN 1 ELSE 0 END) as done_count,
        SUM(CASE WHEN status = 'problem' THEN 1 ELSE 0 END) as problem_count,
        MAX(updated_at) as last_activity
      FROM tasks WHERE sub_project_id = ? AND is_archived = 0
    `).get(e.id),a=r.prepare(`SELECT title, status FROM tasks WHERE sub_project_id = ? AND is_archived = 0
       ORDER BY CASE status
         WHEN 'submitted' THEN 0 WHEN 'testing' THEN 1 WHEN 'writing' THEN 2
         WHEN 'idea' THEN 3 WHEN 'problem' THEN 4 WHEN 'done' THEN 5
       END, sort_order ASC LIMIT 5`).all(e.id);return{...e,task_count:t.task_count??0,active_count:t.active_count??0,pending_count:t.pending_count??0,done_count:t.done_count??0,problem_count:t.problem_count??0,last_activity:t.last_activity,preview_tasks:a}})}function s(e){let n=(0,t.getDb)(),s=(0,r.generateId)(),i=new Date().toISOString(),o=n.prepare("SELECT MAX(sort_order) as max_order FROM sub_projects WHERE project_id = ?").get(e.project_id),d=(o?.max_order??-1)+1;return n.prepare(`INSERT INTO sub_projects (id, project_id, name, description, folder_path, sort_order, created_at, updated_at)
     VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(s,e.project_id,e.name,e.description??"",e.folder_path??null,d,i,i),a(s)}function i(e,r){let n=(0,t.getDb)(),s=a(e);if(!s)return;let i=new Date().toISOString();return n.prepare("UPDATE sub_projects SET name = ?, description = ?, folder_path = ?, updated_at = ? WHERE id = ?").run(r.name??s.name,r.description??s.description,void 0!==r.folder_path?r.folder_path:s.folder_path,i,e),a(e)}function o(e){return(0,t.getDb)().prepare("DELETE FROM sub_projects WHERE id = ?").run(e).changes>0}function d(e,r){let a=(0,t.getDb)(),n=a.prepare("UPDATE sub_projects SET sort_order = ? WHERE id = ? AND project_id = ?");a.transaction(()=>{r.forEach((t,r)=>n.run(r,t,e))})()}e.s(["createSubProject",()=>s,"deleteSubProject",()=>o,"getSubProject",()=>a,"getSubProjectsWithStats",()=>n,"reorderSubProjects",()=>d,"updateSubProject",()=>i])},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 n=(0,t.getDb)(),s=new Date().toISOString(),i=r(e);if(i)return n.prepare("UPDATE brainstorms SET content = ?, version = version + 1, updated_at = ? WHERE id = ?").run(a,s,i.id),n.prepare("UPDATE projects SET updated_at = ? WHERE id = ?").run(s,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,n,s,i){let o=r[e];return o?new Promise((e,r)=>{let d=!!(n||s),l=o.buildArgs({streaming:d}),u=o.buildEnv(),c=(0,t.spawn)(o.binary,l,{cwd:i?.cwd||process.cwd(),stdio:["pipe","pipe","pipe"],shell:"win32"===process.platform,env:u}),p=null,E=!1;i?.timeoutMs&&(p=setTimeout(()=>{E=!0,c.kill("SIGTERM")},i.timeoutMs)),c.stdin?.write(a),c.stdin?.end();let T="",m="",N="",_=0;d?c.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);s?.(e);let r=o.parseStreamEvent(e);if(r)if(r.final){if(r.final.length>_){let e=r.final.slice(_);n?.(e),_=r.final.length}m=r.final}else r.text&&(m+=r.text,_=m.length,n?.(r.text))}catch{}}}):c.stdout?.on("data",e=>{m+=e.toString()}),c.stderr?.on("data",e=>{N+=e.toString()}),c.on("error",e=>{r(Error(`${o.name} CLI error: ${e.message}`))}),c.on("exit",(t,a)=>{if(p&&clearTimeout(p),!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=N.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)},37256,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),n=e.i(59756),s=e.i(61916),i=e.i(74677),o=e.i(69741),d=e.i(16795),l=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),E=e.i(70101),T=e.i(74838),m=e.i(10372),N=e.i(93695);e.i(52474);var _=e.i(220),h=e.i(89171),L=e.i(27543),g=e.i(60636),R=e.i(88095),f=e.i(63909),b=e.i(84501);async function A(e,{params:t}){await (0,b.ensureDb)();let{id:r}=await t,a=(0,R.getProject)(r);if(!a)return h.NextResponse.json({error:"Project not found"},{status:404});let n=(0,L.getBrainstorm)(r);if(!n?.content?.trim())return h.NextResponse.json({error:"No brainstorming content"},{status:400});let s=(0,g.getSubProjectsWithStats)(r),i=s.length>0?`

Existing sub-projects:
${s.map(e=>{let t=e.preview_tasks.length>0?e.preview_tasks.map(e=>`    - ${e.title} (${e.status})`).join("\n"):"    (no tasks)";return`  - "${e.name}" (${e.task_count} tasks)
${t}`}).join("\n")}`:"",o=`You are a task distribution assistant. Analyze the brainstorming content below and distribute it into sub-projects and tasks.

Rules:
- Respond ONLY with a valid JSON object, no markdown, no explanation.
- Use existing sub-projects when the content fits. Create new ones only when needed.
- Each task should be a concrete, actionable item.
- Task titles should be concise (under 60 chars).
- Priority: "high", "medium", or "low".
- Respond in the same language as the brainstorming content.

Brainstorming content:
${n.content.slice(0,5e3)}
${i}

Respond with this exact JSON structure:
{
  "distributions": [
    {
      "sub_project_name": "Name of sub-project",
      "is_new": false,
      "existing_sub_id": "id-if-existing-or-null",
      "tasks": [
        { "title": "Task title", "description": "Brief description", "priority": "medium" }
      ]
    }
  ]
}`;try{let e,t=a.agent_type||"claude",r=(await (0,f.runAgent)(t,o)).trim(),n=(r=(r=r.replace(/```(?:json)?\s*\n?/gi,"").replace(/\n?```/g,"")).trim()).match(/\{\s*"distributions"\s*:\s*\[[\s\S]*\]\s*\}/),i=n?null:r.match(/\{[\s\S]*\}/),d=n?.[0]||i?.[0];if(!d)return h.NextResponse.json({error:"AI did not return valid JSON",raw:r.slice(0,500)},{status:500});try{e=JSON.parse(d)}catch{return h.NextResponse.json({error:"JSON parse failed",raw:d.slice(0,500)},{status:500})}if(!e.distributions||!Array.isArray(e.distributions))return h.NextResponse.json({error:"Invalid distribution format",raw:d.slice(0,500)},{status:500});for(let t of e.distributions)if(!t.is_new&&!t.existing_sub_id){let e=s.find(e=>e.name.toLowerCase()===t.sub_project_name.toLowerCase());e?(t.existing_sub_id=e.id,t.is_new=!1):t.is_new=!0}return h.NextResponse.json(e)}catch(t){let e=t instanceof Error?t.message:"Unknown error";return h.NextResponse.json({error:`AI call failed: ${e}`},{status:500})}}e.s(["POST",()=>A],40095);var O=e.i(40095);let S=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/projects/[id]/auto-distribute/route",pathname:"/api/projects/[id]/auto-distribute",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/projects/[id]/auto-distribute/route.ts",nextConfigOutput:"",userland:O}),{workAsyncStorage:x,workUnitAsyncStorage:D,serverHooks:C}=S;function j(){return(0,a.patchFetch)({workAsyncStorage:x,workUnitAsyncStorage:D})}async function U(e,t,a){S.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let h="/api/projects/[id]/auto-distribute/route";h=h.replace(/\/index$/,"")||"/";let L=await S.prepare(e,t,{srcPage:h,multiZoneDraftMode:!1});if(!L)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:g,params:R,nextConfig:f,parsedUrl:b,isDraftMode:A,prerenderManifest:O,routerServerContext:x,isOnDemandRevalidate:D,revalidateOnlyGenerated:C,resolvedPathname:j,clientReferenceManifest:U,serverActionsManifest:w}=L,v=(0,o.normalizeAppPath)(h),y=!!(O.dynamicRoutes[v]||O.routes[j]),I=async()=>((null==x?void 0:x.render404)?await x.render404(e,t,b,!1):t.end("This page could not be found"),null);if(y&&!A){let e=!!O.routes[j],t=O.dynamicRoutes[v];if(t&&!1===t.fallback&&!e){if(f.experimental.adapterPath)return await I();throw new N.NoFallbackError}}let F=null;!y||S.isDev||A||(F="/index"===(F=j)?"/":F);let P=!0===S.isDev||!y,k=y&&!P;w&&U&&(0,i.setManifestsSingleton)({page:h,clientReferenceManifest:U,serverActionsManifest:w});let M=e.method||"GET",H=(0,s.getTracer)(),X=H.getActiveScopeSpan(),$={params:R,prerenderManifest:O,renderOpts:{experimental:{authInterrupts:!!f.experimental.authInterrupts},cacheComponents:!!f.cacheComponents,supportsDynamicResponse:P,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:f.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>S.onRequestError(e,t,a,n,x)},sharedContext:{buildId:g}},W=new d.NodeNextRequest(e),B=new d.NodeNextResponse(t),q=l.NextRequestAdapter.fromNodeNextRequest(W,(0,l.signalFromNodeResponse)(t));try{let i=async e=>S.handle(q,$).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=H.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} ${h}`)}),o=!!(0,n.getRequestMeta)(e,"minimalMode"),d=async n=>{var s,d;let l=async({previousCacheEntry:r})=>{try{if(!o&&D&&C&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await i(n);e.fetchMetrics=$.renderOpts.fetchMetrics;let d=$.renderOpts.pendingWaitUntil;d&&a.waitUntil&&(a.waitUntil(d),d=void 0);let l=$.renderOpts.collectedTags;if(!y)return await (0,p.sendResponse)(W,B,s,$.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,E.toNodeOutgoingHttpHeaders)(s.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:_.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await S.onRequestError(e,t,{routerKind:"App Router",routePath:h,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:k,isOnDemandRevalidate:D})},!1,x),t}},u=await S.handleResponse({req:e,nextConfig:f,cacheKey:F,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:O,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:C,responseGenerator:l,waitUntil:a.waitUntil,isMinimalMode:o});if(!y)return null;if((null==u||null==(s=u.value)?void 0:s.kind)!==_.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",D?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),A&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let N=(0,E.fromNodeOutgoingHttpHeaders)(u.value.headers);return o&&y||N.delete(m.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||N.get("Cache-Control")||N.set("Cache-Control",(0,T.getCacheControlHeader)(u.cacheControl)),await (0,p.sendResponse)(W,B,new Response(u.value.body,{headers:N,status:u.value.status||200})),null};X?await d(X):await H.withPropagatedContext(e.headers,()=>H.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${h}`,kind:s.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},d))}catch(t){if(t instanceof N.NoFallbackError||await S.onRequestError(e,t,{routerKind:"App Router",routePath:v,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:k,isOnDemandRevalidate:D})},!1,x),y)throw t;return await (0,p.sendResponse)(W,B,new Response(null,{status:500})),null}}e.s(["handler",()=>U,"patchFetch",()=>j,"routeModule",()=>S,"serverHooks",()=>C,"workAsyncStorage",()=>x,"workUnitAsyncStorage",()=>D],37256)}];

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