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",()=>L,"getDb",()=>h],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 E=!1,l="";async function u(){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&&l!==r)try{let e,t;await L();let a=h(),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)}),l=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 p=null,T=null;async function N(){var r;let a,s,i;if(p)return p;let o=e.r(83935),d=await o(),l=n();if(t.default.existsSync(l)){let e=t.default.readFileSync(l);a=new d.Database(e)}else a=new d.Database;return(r=p=new c(a,l)).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",()=>p?.close()),E||(E=!0,setInterval(u,6e4),u(),console.log("[Scheduler] Morning notification scheduler started")),p}async function L(){return p||(T||(T=N()),T)}function h(){if(!p)throw Error("Database not initialized. Call await ensureDb() first.");return p}},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)},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 s(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 n(e){let s=(0,t.getDb)(),n=(0,r.generateId)(),i=new Date().toISOString(),o=s.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 s.prepare(`INSERT INTO sub_projects (id, project_id, name, description, folder_path, sort_order, created_at, updated_at)
     VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(n,e.project_id,e.name,e.description??"",e.folder_path??null,d,i,i),a(n)}function i(e,r){let s=(0,t.getDb)(),n=a(e);if(!n)return;let i=new Date().toISOString();return s.prepare("UPDATE sub_projects SET name = ?, description = ?, folder_path = ?, updated_at = ? WHERE id = ?").run(r.name??n.name,r.description??n.description,void 0!==r.folder_path?r.folder_path:n.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)(),s=a.prepare("UPDATE sub_projects SET sort_order = ? WHERE id = ? AND project_id = ?");a.transaction(()=>{r.forEach((t,r)=>s.run(r,t,e))})()}e.s(["createSubProject",()=>n,"deleteSubProject",()=>o,"getSubProject",()=>a,"getSubProjectsWithStats",()=>s,"reorderSubProjects",()=>d,"updateSubProject",()=>i])},41366,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),E=e.i(87718),l=e.i(95169),u=e.i(47587),c=e.i(66012),p=e.i(70101),T=e.i(74838),N=e.i(10372),L=e.i(93695);e.i(52474);var h=e.i(220),R=e.i(89171),A=e.i(60636),m=e.i(84501);async function _(e,{params:t}){await (0,m.ensureDb)();let{id:r}=await t,a=(0,A.getSubProjectsWithStats)(r);return R.NextResponse.json(a)}async function f(e,{params:t}){await (0,m.ensureDb)();let{id:r}=await t,a=await e.json();if(!a.name||"string"!=typeof a.name)return R.NextResponse.json({error:"name is required"},{status:400});let s=(0,A.createSubProject)({project_id:r,name:a.name,description:a.description,folder_path:a.folder_path});return R.NextResponse.json(s,{status:201})}async function g(e,{params:t}){await (0,m.ensureDb)();let{id:r}=await t,a=await e.json();if(!Array.isArray(a.orderedIds))return R.NextResponse.json({error:"orderedIds array is required"},{status:400});(0,A.reorderSubProjects)(r,a.orderedIds);let s=(0,A.getSubProjectsWithStats)(r);return R.NextResponse.json(s)}e.s(["GET",()=>_,"POST",()=>f,"PUT",()=>g],45821);var b=e.i(45821);let O=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/projects/[id]/sub-projects/route",pathname:"/api/projects/[id]/sub-projects",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/projects/[id]/sub-projects/route.ts",nextConfigOutput:"",userland:b}),{workAsyncStorage:S,workUnitAsyncStorage:U,serverHooks:D}=O;function x(){return(0,a.patchFetch)({workAsyncStorage:S,workUnitAsyncStorage:U})}async function C(e,t,a){O.isDev&&(0,s.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let R="/api/projects/[id]/sub-projects/route";R=R.replace(/\/index$/,"")||"/";let A=await O.prepare(e,t,{srcPage:R,multiZoneDraftMode:!1});if(!A)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:m,params:_,nextConfig:f,parsedUrl:g,isDraftMode:b,prerenderManifest:S,routerServerContext:U,isOnDemandRevalidate:D,revalidateOnlyGenerated:x,resolvedPathname:C,clientReferenceManifest:j,serverActionsManifest:w}=A,v=(0,o.normalizeAppPath)(R),y=!!(S.dynamicRoutes[v]||S.routes[C]),I=async()=>((null==U?void 0:U.render404)?await U.render404(e,t,g,!1):t.end("This page could not be found"),null);if(y&&!b){let e=!!S.routes[C],t=S.dynamicRoutes[v];if(t&&!1===t.fallback&&!e){if(f.experimental.adapterPath)return await I();throw new L.NoFallbackError}}let F=null;!y||O.isDev||b||(F="/index"===(F=C)?"/":F);let P=!0===O.isDev||!y,X=y&&!P;w&&j&&(0,i.setManifestsSingleton)({page:R,clientReferenceManifest:j,serverActionsManifest:w});let H=e.method||"GET",M=(0,n.getTracer)(),k=M.getActiveScopeSpan(),q={params:_,prerenderManifest:S,renderOpts:{experimental:{authInterrupts:!!f.experimental.authInterrupts},cacheComponents:!!f.cacheComponents,supportsDynamicResponse:P,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)=>O.onRequestError(e,t,a,s,U)},sharedContext:{buildId:m}},W=new d.NodeNextRequest(e),K=new d.NodeNextResponse(t),B=E.NextRequestAdapter.fromNodeNextRequest(W,(0,E.signalFromNodeResponse)(t));try{let i=async e=>O.handle(B,q).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=M.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==l.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=`${H} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t)}else e.updateName(`${H} ${R}`)}),o=!!(0,s.getRequestMeta)(e,"minimalMode"),d=async s=>{var n,d;let E=async({previousCacheEntry:r})=>{try{if(!o&&D&&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=q.renderOpts.fetchMetrics;let d=q.renderOpts.pendingWaitUntil;d&&a.waitUntil&&(a.waitUntil(d),d=void 0);let E=q.renderOpts.collectedTags;if(!y)return await (0,c.sendResponse)(W,K,n,q.renderOpts.pendingWaitUntil),null;{let e=await n.blob(),t=(0,p.toNodeOutgoingHttpHeaders)(n.headers);E&&(t[N.NEXT_CACHE_TAGS_HEADER]=E),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==q.renderOpts.collectedRevalidate&&!(q.renderOpts.collectedRevalidate>=N.INFINITE_CACHE)&&q.renderOpts.collectedRevalidate,a=void 0===q.renderOpts.collectedExpire||q.renderOpts.collectedExpire>=N.INFINITE_CACHE?void 0:q.renderOpts.collectedExpire;return{value:{kind:h.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 O.onRequestError(e,t,{routerKind:"App Router",routePath:R,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:X,isOnDemandRevalidate:D})},!1,U),t}},l=await O.handleResponse({req:e,nextConfig:f,cacheKey:F,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:S,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:x,responseGenerator:E,waitUntil:a.waitUntil,isMinimalMode:o});if(!y)return null;if((null==l||null==(n=l.value)?void 0:n.kind)!==h.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==l||null==(d=l.value)?void 0:d.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});o||t.setHeader("x-nextjs-cache",D?"REVALIDATED":l.isMiss?"MISS":l.isStale?"STALE":"HIT"),b&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let L=(0,p.fromNodeOutgoingHttpHeaders)(l.value.headers);return o&&y||L.delete(N.NEXT_CACHE_TAGS_HEADER),!l.cacheControl||t.getHeader("Cache-Control")||L.get("Cache-Control")||L.set("Cache-Control",(0,T.getCacheControlHeader)(l.cacheControl)),await (0,c.sendResponse)(W,K,new Response(l.value.body,{headers:L,status:l.value.status||200})),null};k?await d(k):await M.withPropagatedContext(e.headers,()=>M.trace(l.BaseServerSpan.handleRequest,{spanName:`${H} ${R}`,kind:n.SpanKind.SERVER,attributes:{"http.method":H,"http.target":e.url}},d))}catch(t){if(t instanceof L.NoFallbackError||await O.onRequestError(e,t,{routerKind:"App Router",routePath:v,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:X,isOnDemandRevalidate:D})},!1,U),y)throw t;return await (0,c.sendResponse)(W,K,new Response(null,{status:500})),null}}e.s(["handler",()=>C,"patchFetch",()=>x,"routeModule",()=>O,"serverHooks",()=>D,"workAsyncStorage",()=>S,"workUnitAsyncStorage",()=>U],41366)}];

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