import { i as defineEventHandler, t as getProvider, u as getQuery, o as fetchBoardTasks, T as statusesForFilter, F as mergeTasksById, N as resolveActiveTaskId } from '../../nitro/nitro.mjs';
import 'node:path';
import 'node:module';
import 'node:fs';
import 'node:os';
import 'dotenv';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:crypto';
import 'node:async_hooks';
import 'node:url';
import 'node:net';
import '@iconify/utils';
import 'consola';

const tasks_get = defineEventHandler(async (event) => {
  var _a, _b, _c, _d;
  const { config, provider, nonCodeProvider, cwd, dist } = getProvider(event);
  const q = getQuery(event);
  const filter = (typeof q.status === "string" ? q.status : "all").toLowerCase();
  let tasks;
  if (filter === "all" || filter === "") {
    tasks = await fetchBoardTasks(config, provider);
  } else {
    const mapped = statusesForFilter(config, filter);
    if (!mapped || mapped.length === 0) {
      tasks = await fetchBoardTasks(config, provider);
    } else {
      tasks = await provider.fetchTasksByStatus(mapped, {
        skipAttachments: true,
        omitDescription: true
      });
    }
  }
  if (nonCodeProvider) {
    try {
      const nonCodeTasks = await fetchBoardTasks(config, nonCodeProvider);
      tasks = mergeTasksById(tasks, nonCodeTasks);
    } catch {
    }
  }
  const suggestedTagEntries = [
    { key: "clickupTag", label: "code" },
    { key: "nonCodeTag", label: "non-code" },
    { key: "thinkingTag", label: "thinking" },
    { key: "planningTag", label: "planning" },
    { key: "acceptedTag", label: "accepted" }
  ];
  const suggestedTags = suggestedTagEntries.map(({ key, label }) => ({ tag: config[key] || "", label })).filter((s) => s.tag.length > 0);
  return {
    filter,
    provider: config.provider,
    tasks,
    filters: {
      open: (_a = statusesForFilter(config, "open")) != null ? _a : [],
      pending: (_b = statusesForFilter(config, "pending")) != null ? _b : [],
      inProgress: (_c = statusesForFilter(config, "inprogress")) != null ? _c : [],
      review: (_d = statusesForFilter(config, "review")) != null ? _d : [],
      done: config.doneStatus ? [config.doneStatus] : []
    },
    activeTaskId: resolveActiveTaskId(cwd, dist),
    suggestedTags
  };
});

export { tasks_get as default };
//# sourceMappingURL=tasks.get.mjs.map
