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",()=>u,"getDb",()=>A],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 i(){return r.default.join((t.default.existsSync(s)||t.default.mkdirSync(s,{recursive:!0}),s),"im.db")}let T=r.default.join(a.default.homedir(),".idea-manager","sync");function E(){return t.default.existsSync(T)||t.default.mkdirSync(T,{recursive:!0}),T}e.s(["getDbPath",()=>i,"getSyncDir",()=>E],14966);var n=e.i(74533);let o=!1,d="";async function L(){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&&d!==r)try{let e,t;await u();let a=A(),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(),i=a.prepare("SELECT COUNT(*) as count FROM tasks WHERE status IN ('submitted', 'testing')").get(),T=a.prepare("SELECT COUNT(*) as count FROM tasks WHERE status = 'problem'").get(),E=[];if(s.length>0){for(let e of(E.push(`Today: ${s.length}개`),s.slice(0,5)))E.push(`  - ${e.title}`);s.length>5&&E.push(`  ... +${s.length-5}개`)}else E.push("Today 태스크가 없습니다.");i.count>0&&E.push(`진행 중: ${i.count}개`),T.count>0&&E.push(`문제: ${T.count}개`),e=E.join("\n").replace(/"/g,'\\"').replace(/\n/g,"\\n"),t=`display notification "${e}" with title "IM - 오늘의 할 일"`,(0,n.exec)(`osascript -e '${t}'`,e=>{e&&console.error("[Scheduler] notification error:",e.message)}),d=r}catch(e){console.error("[Scheduler] error:",e)}}class l{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(),i=[];for(;a.step();)i.push(a.get());return a.free(),t.rowsToObjects(s,i)},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 c=null,p=null;async function N(){var r;let a,s,T;if(c)return c;let E=e.r(83935),n=await E(),d=i();if(t.default.existsSync(d)){let e=t.default.readFileSync(d);a=new n.Database(e)}else a=new n.Database;return(r=c=new l(a,d)).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
    );
  `),(T=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"),T.some(e=>"tags"===e.name)||r.exec("ALTER TABLE tasks ADD COLUMN tags TEXT NOT NULL DEFAULT '[]'"),process.on("exit",()=>c?.close()),o||(o=!0,setInterval(L,6e4),L(),console.log("[Scheduler] Morning notification scheduler started")),c}async function u(){return c||(p||(p=N()),p)}function A(){if(!c)throw Error("Database not initialized. Call await ensureDb() first.");return c}},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))}];

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